GoodOfflineLog.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. $count = Db::name('good_offline_log')->where($where)->count('id');
  21. $list = Db::name('good_offline_log')
  22. ->field('id,spuCode,good_name,creater,addtime,createrid')
  23. ->where($where)
  24. ->order('addtime', 'desc')
  25. ->page($param['page'], $param['size'])
  26. ->append(['is_allow_update'])
  27. ->withAttr('is_allow_update', function ($val, $data) use ($role) {
  28. return (in_array($this->roleid, [1, 33]) || in_array($data['createrid'], $role[DataGroupModel::$type_可编辑])) ? 1 : 0; //是否具有编辑权限
  29. })
  30. ->select()
  31. ->toArray();
  32. return app_show(0, "获取成功", ['list' => $list, 'count' => $count]);
  33. }
  34. //详情
  35. public function getDetail()
  36. {
  37. $id = $this->request->post('id', null, 'trim');
  38. $val = Validate::rule(['id' => 'require|number|gt:0']);
  39. if (!$val->check(['id' => $id])) return error_show(1004, $val->getError());
  40. else {
  41. $res = Db::name('good_offline_log')
  42. ->alias('gol')
  43. ->field('gol.*,ri.result')
  44. ->where('gol.id', $id)
  45. ->leftJoin('result_info ri', 'ri.result_code=gol.offline_reason')
  46. ->find();
  47. $res['children_list'] = Db::name('good_platform')
  48. ->alias('gp')
  49. ->field('gp.id,gp.skuCode,p.platform_name,g.creater purchease,gp.creater')
  50. ->where(['gp.spuCode' => $res['spuCode']])
  51. ->whereIn('gp.skuCode', $res['skuCodes'])
  52. ->leftJoin('platform p', 'p.id=gp.platform_code')
  53. ->leftJoin('good g', 'g.spuCode=gp.spuCode')
  54. ->select()
  55. ->toArray();
  56. return app_show(0, "获取成功", $res);
  57. }
  58. }
  59. }