request->only(['start_date' => '', "spuCode"=>'',"good_name"=>'','end_date' => '', 'creater' => '', 'page' => 1,'size' => 15], 'post', 'trim'); $where = []; if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['addtime', 'between', [$param['start_date'], $param['end_date']]]; if ($param['creater'] != '') $where[] = ['creater', 'like', '%' . $param['creater'] . '%']; if ($param['spuCode'] != '') $where[] = ['spuCode', 'like', '%' . $param['spuCode'] . '%']; if ($param['good_name'] != '') $where[] = ['good_name', 'like', '%' . $param['good_name'] . '%']; // $role = $this->checkDataShare(); // if (!empty($role[DataGroupModel::$type_全部])) $where[] = ["createrid", "in", $role[DataGroupModel::$type_全部]]; $role = $this->checkDataShare(); $hand = resign_hand_user($this->uid,0); if (!empty($role[DataGroupModel::$type_全部])) { $arr= array_unique(array_merge($hand,$role[DataGroupModel::$type_全部])); $where[] = ['createrid', 'in',$arr]; } $count = Db::name('good_offline_log')->where($where)->count('id'); $list = Db::name('good_offline_log') ->field('id,spuCode,good_name,creater,addtime,createrid') ->where($where) ->order('addtime', 'desc') ->page($param['page'], $param['size']) ->append(['is_allow_update']) ->withAttr('is_allow_update', function ($val, $data) use ($role) { return (in_array($this->roleid, [1, 33]) || in_array($data['createrid'], $role[DataGroupModel::$type_可编辑])) ? 1 : 0; //是否具有编辑权限 }) ->select() ->toArray(); return app_show(0, "获取成功", ['list' => $list, 'count' => $count]); } //详情 public function getDetail() { $id = $this->request->post('id', null, 'trim'); $val = Validate::rule(['id' => 'require|number|gt:0']); if (!$val->check(['id' => $id])) return error_show(1004, $val->getError()); else { $res = Db::name('good_offline_log') ->alias('gol') ->field('gol.*,ri.result') ->where('gol.id', $id) ->leftJoin('result_info ri', 'ri.result_code=gol.offline_reason') ->find(); $res['children_list'] = Db::name('good_platform') ->alias('gp') ->field('gp.id,gp.skuCode,p.platform_name,g.creater purchease,gp.creater') ->where(['gp.spuCode' => $res['spuCode']]) ->whereIn('gp.skuCode', $res['skuCodes']) ->leftJoin('platform p', 'p.id=gp.platform_code') ->leftJoin('good g', 'g.spuCode=gp.spuCode') ->select() ->toArray(); return app_show(0, "获取成功", $res); } } }