GoodOfflineLog.php 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\model\DataGroup as DataGroupModel;
  4. use think\facade\Db;
  5. use think\facade\Validate;
  6. class GoodOfflineLog extends Base
  7. {
  8. //列表
  9. public function getList()
  10. {
  11. $param = $this->request->only(['start_date' => '', "spuCode"=>'',"good_name"=>'','end_date' => '', 'creater' => '',
  12. 'page' => 1,'size' => 15], 'post', 'trim');
  13. $where = [];
  14. if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['addtime', 'between', [$param['start_date'], $param['end_date']]];
  15. if ($param['creater'] != '') $where[] = ['creater', 'like', '%' . $param['creater'] . '%'];
  16. if ($param['spuCode'] != '') $where[] = ['spuCode', 'like', '%' . $param['spuCode'] . '%'];
  17. if ($param['good_name'] != '') $where[] = ['good_name', 'like', '%' . $param['good_name'] . '%'];
  18. // $role = $this->checkDataShare();
  19. // if (!empty($role[DataGroupModel::$type_全部])) $where[] = ["createrid", "in", $role[DataGroupModel::$type_全部]];
  20. $role = $this->checkDataShare();
  21. $hand = resign_hand_user($this->uid,0);
  22. if (!empty($role[DataGroupModel::$type_全部])) {
  23. $arr= array_unique(array_merge($hand,$role[DataGroupModel::$type_全部]));
  24. $where[] = ['createrid', 'in',$arr];
  25. }
  26. $count = Db::name('good_offline_log')->where($where)->count('id');
  27. $list = Db::name('good_offline_log')
  28. ->field('id,spuCode,good_name,creater,addtime,createrid')
  29. ->where($where)
  30. ->order('addtime', 'desc')
  31. ->page($param['page'], $param['size'])
  32. ->append(['is_allow_update'])
  33. ->withAttr('is_allow_update', function ($val, $data) use ($role) {
  34. return (in_array($this->roleid, [1, 33]) || in_array($data['createrid'], $role[DataGroupModel::$type_可编辑])) ? 1 : 0; //是否具有编辑权限
  35. })
  36. ->select()
  37. ->toArray();
  38. return app_show(0, "获取成功", ['list' => $list, 'count' => $count]);
  39. }
  40. //详情
  41. public function getDetail()
  42. {
  43. $id = $this->request->post('id', null, 'trim');
  44. $val = Validate::rule(['id' => 'require|number|gt:0']);
  45. if (!$val->check(['id' => $id])) return error_show(1004, $val->getError());
  46. else {
  47. $res = Db::name('good_offline_log')
  48. ->alias('gol')
  49. ->field('gol.*,ri.result')
  50. ->where('gol.id', $id)
  51. ->leftJoin('result_info ri', 'ri.result_code=gol.offline_reason')
  52. ->find();
  53. $res['children_list'] = Db::name('good_platform')
  54. ->alias('gp')
  55. ->field('gp.id,gp.skuCode,p.platform_name,g.creater purchease,gp.creater')
  56. ->where(['gp.spuCode' => $res['spuCode']])
  57. ->whereIn('gp.skuCode', $res['skuCodes'])
  58. ->leftJoin('platform p', 'p.id=gp.platform_code')
  59. ->leftJoin('good g', 'g.spuCode=gp.spuCode')
  60. ->select()
  61. ->toArray();
  62. return app_show(0, "获取成功", $res);
  63. }
  64. }
  65. }