GoodOfflineLog.php 3.3 KB

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