| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- namespace app\extra\service\cutter;
- use app\extra\basic\Service;
- use app\extra\dao\cutter\CutterTaskDao;
- use DI\Attribute\Inject;
- class CutterTaskService extends Service
- {
- /**
- * 设置模型
- * @return string
- */
- public function __construct()
- {
- $this->dao = new CutterTaskDao();
- }
- #[Inject]
- protected CutterOrderService $orderService;
- /**
- * 列表
- * @param array $param
- */
- public function getList(array $param = [],string $field = '*', int $page = 0,int $limit = 0,string $order = 'id desc')
- {
- if(isset($param['order_key']) && $param['order_key']){
- $order = ($param['order_key'] == 'time'?'created_at':$param['order_key']).' '.$param['order_sort']??'desc';
- }
- if(isset($param['id']) && $param['id']){
- $order = "id={$param['id']} desc,".$order;
- }
- $list = $this->dao->getList(function($query)use($param){
- $query->where($this->searchFilter($param))->when(isset($param['uid']) && $param['uid'],function ($query)use($param){
- $query->whereNotIn('id',function($query)use($param){
- $query->name('cutter_order')->where('uid',$param['uid'])->where('status','>=',0)->field('task_id');
- });
- });
- },$field,$page,$limit,$order);
- $count = $this->dao->count($this->searchFilter($param));
- return compact('list','count');
- }
- protected function searchFilter(array $param = []): array
- {
- $filter = [];
- !empty($param['status']) && $filter[] = ["status", '=', $param['status']];
- !empty($param['grade']) && $filter[] = ["grade", '<=', $param['grade']];
- isset($param['is_del']) && $filter[] = ["is_del", '=', $param['is_del']];
- !empty($param['type']) && $filter[] = ["type", '=', $param['type']];
- return $filter;
- }
- }
|