GoodOfflineLog.php 3.1 KB

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