123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- <?php
- namespace app\admin\controller;
- use app\admin\model\DataGroup as DataGroupModel;
- use think\facade\Db;
- use think\facade\Validate;
- class GoodOfflineLog extends Base
- {
- //列表
- public function getList()
- {
- $param = $this->request->only(['start_date' => '','companyNo' => '','supplierNo' => '','relaComNo' => '', "spuCode"=>'',"good_name"=>'','end_date' => '', 'creater' => '', 'page' => 1,'size' => 15], 'post', 'trim');
- $where = [];
- if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['a.addtime', 'between', [$param['start_date'], $param['end_date']]];
- if ($param['creater'] != '') $where[] = ['a.creater', 'like', '%' . $param['creater'] . '%'];
- if ($param['spuCode'] != '') $where[] = ['a.spuCode', 'like', '%' . $param['spuCode'] . '%'];
- if ($param['good_name'] != '') $where[] = ['a.good_name', 'like', '%' . $param['good_name'] . '%'];
- if ($param['companyNo'] != '') $where[] = ['b.companyNo', 'like', '%' . $param['companyNo'] . '%'];
- if ($param['supplierNo'] != '') $where[] = ['b.supplierNo', 'like', '%' . $param['supplierNo'] . '%'];
- // if ($param['relaComNo'] != '') $where[] = ['b.companyNo|b.supplierNo', 'like', '%' . $param['relaComNo'] . '%'];
- // $role = $this->checkDataShare();
- // if (!empty($role[DataGroupModel::$type_全部])) $where[] = ["createrid", "in", $role[DataGroupModel::$type_全部]];
- //只有level2的账号过滤数据权限
- if ($this->level == 2) {
- $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[] = ['a.createrid', 'in', $arr];
- }
- }
- $count = Db::name('good_offline_log')
- ->alias("a")
- ->leftJoin("good_basic b","a.spuCode=b.spuCode")
- ->where($where)
- ->count('a.id');
- $list = Db::name('good_offline_log')
- ->alias("a")
- ->field('a.id,a.spuCode,a.good_name,a.creater,a.addtime,a.createrid,b.companyNo,b.supplierNo')
- ->leftJoin("good_basic b","a.spuCode=b.spuCode")
- ->where($where)
- ->order('a.addtime', 'desc')
- ->page($param['page'], $param['size'])
- // ->append(['is_allow_update'])
- // ->withAttr('is_allow_update', function ($val, $data) use ($role) {
- // if ($this->level == 2) return (in_array($this->roleid, [1, 33]) || in_array($data['createrid'], $role[DataGroupModel::$type_可编辑])) ? 1 : 0; //是否具有编辑权限
- //
- // })
- ->select()
- ->toArray();
- $userCommon=\app\admin\common\User::getIns();
- $supplierInfo = $userCommon->handle('getCodeAndName',['code'=>array_merge(array_column($list,'companyNo'),array_column($list,'supplierNo'))]);
- foreach ($list as &$value){
- $value['companyName'] = $supplierInfo["data"][$value['companyNo']]??"";
- $value['supplierName'] = $supplierInfo["data"][$value['supplierNo']]??"";
- }
- return json_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);
- }
- }
- }
|