GoodOfflineLog.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. ->select()
  19. ->toArray();
  20. return app_show(0, "获取成功", ['list' => $list, 'count' => $count]);
  21. }
  22. //详情
  23. public function getDetail()
  24. {
  25. $id = $this->request->post('id', null, 'trim');
  26. $val = Validate::rule(['id|ID' => 'require|number|gt:0']);
  27. if (!$val->check(['id' => $id])) return error_show(1004, $val->getError());
  28. else {
  29. $res = Db::name('good_offline_log')
  30. ->alias('gol')
  31. ->field('gol.*,ri.result_desc')
  32. ->where('gol.id', $id)
  33. ->leftJoin('result_info ri', 'ri.result_code=gol.offline_reason')
  34. ->find();
  35. return app_show(0, "获取成功", $res);
  36. }
  37. }
  38. }