GoodOfflineLog.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. namespace app\admin\controller;
  3. use think\facade\Db;
  4. use think\facade\Validate;
  5. class GoodOfflineLog extends Base
  6. {
  7. //列表
  8. public function getList()
  9. {
  10. $param = $this->request->only(['start_date' => '', 'end_date' => '', 'creater' => '', 'page' => 1, 'size' => 15], 'post', 'trim');
  11. $where = [];
  12. if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['addtime', 'between', [$param['start_date'], $param['end_date']]];
  13. if ($param['creater'] != '') $where[] = ['creater', 'like', '%' . $param['creater'] . '%'];
  14. $count = Db::name('good_offline_log')->where($where)->count('id');
  15. $list = Db::name('good_offline_log')
  16. ->field('id,spuCode,good_name,creater,addtime')
  17. ->where($where)
  18. ->order('addtime', 'desc')
  19. ->page($param['page'], $param['size'])
  20. ->select()
  21. ->toArray();
  22. return app_show(0, "获取成功", ['list' => $list, 'count' => $count]);
  23. }
  24. //详情
  25. public function getDetail()
  26. {
  27. $code = $this->request->post('code', null, 'trim');
  28. $val = Validate::rule(['code' => 'require']);
  29. if (!$val->check(['code' => $code])) return error_show(1004, $val->getError());
  30. else {
  31. $res = Db::name('good_offline_log')
  32. ->alias('gol')
  33. ->field('gol.*,ri.result')
  34. ->where(function ($query) use ($code) {
  35. return $query->whereFindInSet('gol.skuCodes', $code)->whereOr('gol.spuCode', $code);
  36. })
  37. ->leftJoin('result_info ri', 'ri.result_code=gol.offline_reason')
  38. ->find();
  39. $res['children_list'] = Db::name('good_platform')
  40. ->alias('gp')
  41. ->field('gp.id,gp.skuCode,p.platform_name,g.creater purchease,gp.creater')
  42. ->where(['gp.spuCode' => $res['spuCode']])
  43. ->whereIn('gp.skuCode', $res['skuCodes'])
  44. ->leftJoin('platform p', 'p.id=gp.platform_code')
  45. ->leftJoin('good g', 'g.spuCode=gp.spuCode')
  46. ->select()
  47. ->toArray();
  48. return app_show(0, "获取成功", $res);
  49. }
  50. }
  51. }