GoodOfflineLog.php 2.3 KB

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