GoodOfflineLog.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. ->select()
  20. ->toArray();
  21. return app_show(0, "获取成功", ['list' => $list, 'count' => $count]);
  22. }
  23. //详情
  24. public function getDetail()
  25. {
  26. $id = $this->request->post('id', null, 'trim');
  27. $val = Validate::rule(['id|ID' => 'require|number|gt:0']);
  28. if (!$val->check(['id' => $id])) return error_show(1004, $val->getError());
  29. else {
  30. $res = Db::name('good_offline_log')
  31. ->alias('gol')
  32. ->field('gol.*,ri.result_desc')
  33. ->where('gol.id', $id)
  34. ->leftJoin('result_info ri', 'ri.result_code=gol.offline_reason')
  35. ->find();
  36. $res['children_list'] = Db::name('good_platform')
  37. ->alias('gp')
  38. ->field('gp.id,gp.skuCode,p.platform_name,g.creater purchease,gp.creater')
  39. ->where(['gp.spuCode' => $res['spuCode']])
  40. ->whereIn('gp.skuCode', $res['skuCodes'])
  41. ->leftJoin('platform p', 'p.id=gp.platform_code')
  42. ->leftJoin('good g', 'g.spuCode=gp.spuCode')
  43. ->select()
  44. ->toArray();
  45. return app_show(0, "获取成功", $res);
  46. }
  47. }
  48. }