GoodOfflineLog.php 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\model\DataGroup as DataGroupModel;
  4. use think\facade\Db;
  5. use think\facade\Validate;
  6. class GoodOfflineLog extends Base
  7. {
  8. //列表
  9. public function getList()
  10. {
  11. $param = $this->request->only(['start_date' => '',"type"=>1,'companyNo' => '','supplierNo' => '','relaComNo' =>
  12. '', "spuCode"=>'',"good_name"=>'','end_date' => '', 'creater' => '', 'page' => 1,'size' => 15], 'post', 'trim');
  13. $where = [["a.type","=",$param["type"]]];
  14. if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['a.addtime', 'between', [$param['start_date'], $param['end_date']]];
  15. if ($param['creater'] != '') $where[] = ['a.creater', 'like', '%' . $param['creater'] . '%'];
  16. if ($param['spuCode'] != '') $where[] = ['a.spuCode', 'like', '%' . $param['spuCode'] . '%'];
  17. if ($param['good_name'] != '') $where[] = ['a.good_name', 'like', '%' . $param['good_name'] . '%'];
  18. if ($param['companyNo'] != '') $where[] = ['b.companyNo', 'like', '%' . $param['companyNo'] . '%'];
  19. if ($param['supplierNo'] != '') $where[] = ['b.supplierNo', 'like', '%' . $param['supplierNo'] . '%'];
  20. $count = Db::name('good_offline_log')
  21. ->alias("a")
  22. ->leftJoin("good_basic b","a.spuCode=b.spuCode")
  23. ->where($where)
  24. ->count('a.id');
  25. $list = Db::name('good_offline_log')
  26. ->alias("a")
  27. ->field('a.id,a.spuCode,a.good_name,a.creater,a.addtime,a.createrid,b.companyNo,b.supplierNo')
  28. ->leftJoin("good_basic b","a.spuCode=b.spuCode")
  29. ->where($where)
  30. ->order('a.addtime', 'desc')
  31. ->page($param['page'], $param['size'])
  32. ->select()
  33. ->toArray();
  34. $userCommon=\app\admin\common\User::getIns();
  35. $supplierInfo = $userCommon->handle('getCodeAndName',['code'=>array_merge(array_column($list,'companyNo'),array_column($list,'supplierNo'))]);
  36. foreach ($list as &$value){
  37. $value['companyName'] = $supplierInfo["data"][$value['companyNo']]??"";
  38. $value['supplierName'] = $supplierInfo["data"][$value['supplierNo']]??"";
  39. }
  40. return json_show(0, "获取成功", ['list' => $list, 'count' => $count]);
  41. }
  42. //详情
  43. public function getDetail()
  44. {
  45. $id = $this->request->post('id', null, 'trim');
  46. $val = Validate::rule(['id' => 'require|number|gt:0']);
  47. if (!$val->check(['id' => $id])) return error_show(1004, $val->getError());
  48. else {
  49. $res = Db::name('good_offline_log')
  50. ->alias('gol')
  51. ->field('gol.*,ri.result')
  52. ->where('gol.id', $id)
  53. ->leftJoin('result_info ri', 'ri.result_code=gol.offline_reason')
  54. ->find();
  55. $res['children_list'] = Db::name('good_platform')
  56. ->alias('gp')
  57. ->field('gp.id,gp.skuCode,p.platform_name,g.creater purchease,gp.creater')
  58. ->where(['gp.spuCode' => $res['spuCode']])
  59. ->whereIn('gp.skuCode', $res['skuCodes'])
  60. ->leftJoin('platform p', 'p.id=gp.platform_code')
  61. ->leftJoin('good g', 'g.spuCode=gp.spuCode')
  62. ->select()
  63. ->toArray();
  64. return app_show(0, "获取成功", $res);
  65. }
  66. }
  67. }