GoodOfflineLog.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. $id = $this->request->post('id', null, 'trim');
  28. $val = Validate::rule(['id' => 'require|number|gt:0']);
  29. if (!$val->check(['id' => $id])) 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('gol.id', $id)
  35. ->leftJoin('result_info ri', 'ri.result_code=gol.offline_reason')
  36. ->find();
  37. $res['children_list'] = Db::name('good_platform')
  38. ->alias('gp')
  39. ->field('gp.id,gp.skuCode,p.platform_name,g.creater purchease,gp.creater')
  40. ->where(['gp.spuCode' => $res['spuCode']])
  41. ->whereIn('gp.skuCode', $res['skuCodes'])
  42. ->leftJoin('platform p', 'p.id=gp.platform_code')
  43. ->leftJoin('good g', 'g.spuCode=gp.spuCode')
  44. ->select()
  45. ->toArray();
  46. return app_show(0, "获取成功", $res);
  47. }
  48. }
  49. }