Report.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. <?php
  2. namespace app\admin\controller;
  3. use think\facade\Db;
  4. use think\facade\Validate;
  5. //报表处理类
  6. class Report extends Base
  7. {
  8. //产品价格和产品导出
  9. public function exportGood()
  10. {
  11. $param = $this->request->only(['date', 'platform_id', 'status'], 'post', 'trim');
  12. $val = Validate::rule([
  13. 'date|筛选时间' => 'require|date',
  14. 'platform_id|筛选平台ID' => 'require|number|gt:0',
  15. 'status|状态' => 'require|number|in:5,6,8',
  16. ]);
  17. if (!$val->check($param)) return error_show(1004, $val->getError());
  18. $where_ladder = [['gl.is_del', '=', 0]];
  19. $where_good = [['g.is_del', '=', 0]];
  20. if (!empty($param['date'])) {
  21. $where_ladder[] = ['gl.addtime', 'between', [$param['date'] . ' 00:00:00', $param['date'] . ' 23:59:59']];
  22. $where_good[] = ['g.addtime', 'between', [$param['date'] . ' 00:00:00', $param['date'] . ' 23:59:59']];
  23. }
  24. if (!empty($param['platform_id'])) {
  25. $where_ladder[] = ['gp.platform_code', '=', $param['platform_id']];
  26. $where_good[] = ['gp.platform_code', '=', $param['platform_id']];
  27. }
  28. if (!empty($param['status'])) {
  29. $where_ladder[] = ['g.status', '=', $param['status']];
  30. $where_good[] = ['g.status', '=', $param['status']];
  31. }
  32. $data = [];
  33. //产品价格
  34. $rs_ladder = Db::name('good_ladder')
  35. ->alias('gl')
  36. ->field('g.good_name 商品名称,gl.market_price 市场价,gl.origin_rate 税率,g.moq 起订量,gl.sale_price 售价,gl.skuCode 商品编码,gl.cost_fee 工艺费,gl.market_platform 对比平台')
  37. ->where($where_ladder)
  38. ->leftJoin('good_platform gp', 'gp.skuCode=gl.skuCode AND gp.is_del=0')
  39. ->leftJoin('good g', 'g.spuCode=gp.spuCode AND g.is_del=0')
  40. ->order('gl.id')
  41. ->select()
  42. ->toArray();
  43. if (!empty($rs_ladder)) {
  44. $data[] = [
  45. 'head' => array_keys($rs_ladder[0]),
  46. 'list' => $rs_ladder,
  47. 'filename' => '产品价格' . date('YmdHis'),
  48. ];
  49. }
  50. //产品
  51. $rs_temp_good = Db::name('good')
  52. ->alias('g')
  53. ->field('"" 一级分类,"" 二级分类, g.cat_id 三级分类,g.good_name 商品名称,g.good_type 商品类型,g.brand_id 商品品牌,\'\' 型号,g.origin_place 产地,g.good_unit 计量单位,g.weight 重量g,\'\' 响应时间,g.lead_time 供货周期,g.good_size 商品尺寸,g.packing_size 装箱尺寸,g.packing_way 包装方式,g.packing_spec 装箱规格,g.packing_list 包装清单,g.delivery_place 发货地,g.delivery_day 物流时间,gp.skuCode 商品编码,g.spuCode')
  54. ->where($where_good)
  55. ->leftJoin('good_platform gp', 'gp.spuCode=g.spuCode AND gp.is_del=0')
  56. ->order('g.id')
  57. ->select()
  58. ->toArray();
  59. $all_good_type = [1 => '定制商品', 2 => '常规商品'];
  60. $all_brand = Db::name('brand')->whereIn('id', array_column($rs_temp_good, '商品品牌'))->where('is_del', 0)->column('brand_name', 'id');
  61. $all_cat = Db::name('cat')
  62. ->alias('c3')
  63. ->whereIn('c3.id', array_column($rs_temp_good, '三级分类'))
  64. ->where('c3.is_del', 0)
  65. ->leftJoin('cat c2', 'c2.id=c3.pid AND c2.is_del=0')
  66. ->leftJoin('cat c1', 'c1.id=c2.pid AND c1.is_del=0')
  67. ->column('c3.cat_name cat_name_3,c2.cat_name cat_name_2,c1.cat_name cat_name_1', 'c3.id');
  68. $all_unit = Db::name('unit')->whereIn('id', array_column($rs_temp_good, '计量单位'))->where('is_del', 0)->column('unit', 'id');
  69. foreach ($rs_temp_good as &$value) {
  70. $value['商品品牌'] = isset($all_brand[$value['商品品牌']]) ? $all_brand[$value['商品品牌']] : '';
  71. $value['商品类型'] = isset($all_good_type[$value['商品类型']]) ? $all_good_type[$value['商品类型']] : '';
  72. $value['一级分类'] = isset($all_cat[$value['三级分类']]['cat_name_1']) ? $all_cat[$value['三级分类']]['cat_name_1'] : '';
  73. $value['二级分类'] = isset($all_cat[$value['三级分类']]['cat_name_2']) ? $all_cat[$value['三级分类']]['cat_name_2'] : '';
  74. $value['三级分类'] = isset($all_cat[$value['三级分类']]['cat_name_3']) ? $all_cat[$value['三级分类']]['cat_name_3'] : '';
  75. $temp = explode(',', $value['产地']);
  76. $value['产地'] = GetAddr(json_encode(['provice_code' => isset($temp[0]) ? $temp[0] : '', 'city_code' => isset($temp[1]) ? $temp[1] : '', 'area_code' => isset($temp[2]) ? $temp[2] : '']));
  77. $value['计量单位'] = isset($all_unit[$value['计量单位']]) ? $all_unit[$value['计量单位']] : '';
  78. $temp_2 = explode(',', $value['发货地']);
  79. $value['发货地'] = GetAddr(json_encode(['provice_code' => isset($temp_2[0]) ? $temp_2[0] : '', 'city_code' => isset($temp_2[1]) ? $temp_2[1] : '', 'area_code' => isset($temp_2[2]) ? $temp_2[2] : '']));
  80. $value['型号'] = Db::name('good_spec')
  81. ->alias('gp')
  82. ->field('')
  83. ->leftJoin('specs s', 's.id=gp.spec_id AND s.is_del=0')
  84. ->leftJoin('spec_value sv', 'sv.id=gp.spec_value_id AND s.is_del=0')
  85. ->where([
  86. 'gp.spuCode' => $value['spuCode'],
  87. 'gp.is_del' => 0,
  88. 's.spec_name' => '型号',
  89. ])
  90. ->value('sv.spec_value', '');
  91. $value['响应时间'] = Db::name('good_spec')
  92. ->alias('gp')
  93. ->field('')
  94. ->leftJoin('specs s', 's.id=gp.spec_id AND s.is_del=0')
  95. ->leftJoin('spec_value sv', 'sv.id=gp.spec_value_id AND s.is_del=0')
  96. ->where([
  97. 'gp.spuCode' => $value['spuCode'],
  98. 'gp.is_del' => 0,
  99. 's.spec_name' => '响应时间',
  100. ])
  101. ->value('sv.spec_value', '');
  102. unset($value['spuCode']);
  103. }
  104. if (!empty($rs_temp_good)) {
  105. $data[] = [
  106. 'head' => array_keys($rs_temp_good[0]),
  107. 'list' => $rs_temp_good,
  108. 'filename' => '产品' . date('YmdHis'),
  109. ];
  110. }
  111. if (empty($data)) return error_show(1005, '没有可供导出的数据');
  112. else excelSaveBatch($data);
  113. }
  114. //【一、采购日报表】1.咨询单总数
  115. public function zixunTotal()
  116. {
  117. $param = $this->request->only([
  118. 'token',
  119. 'start_date' => date('Y-m-d'),
  120. 'end_date' => date('Y-m-d'),
  121. ], 'post', 'trim');
  122. $val_params = Validate::rule([
  123. 'start_date' => 'date|elt:end_date',
  124. 'end_date' => 'date',
  125. ]);
  126. if (!$val_params->check($param)) return error_show(1004, $val_params->getError());
  127. $rs = Db::name('good_zixun')
  128. ->alias('gz')
  129. ->field('gz.id,DATE_FORMAT(gz.addtime,"%Y-%m-%d") addtime,gz.createrid,du.itemid,ci.name')
  130. ->leftJoin('depart_user du', 'du.uid=gz.createrid AND du.is_del=0')
  131. ->leftJoin('company_item ci', 'ci.id=du.itemid AND ci.is_del=0')
  132. ->where('gz.is_del', 0)
  133. ->whereBetween('gz.addtime', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59'])
  134. ->cursor();
  135. $data = [];
  136. foreach ($rs as $value) {
  137. $addtime_stamp = strtotime($value['addtime']);
  138. if (!isset($data[$addtime_stamp])) $data[$addtime_stamp] = [
  139. 'date' => $value['addtime'],
  140. 'list' => [],
  141. ];
  142. if (isset($data[$addtime_stamp]['list'][$value['itemid']])) {
  143. $data[$addtime_stamp]['list'][$value['itemid']]['total']++;
  144. } else {
  145. $data[$addtime_stamp]['list'][$value['itemid']] = [
  146. 'total' => 1,
  147. 'name' => $value['name'],
  148. ];
  149. }
  150. }
  151. //去掉下标
  152. foreach ($data as &$v) {
  153. $v['list'] = array_merge($v['list']);
  154. }
  155. return app_show(0, '请求成功', array_merge($data));
  156. }
  157. //【一、采购日报表】2.采购订单总金额
  158. public function purcheaseOrderSum()
  159. {
  160. $param = $this->request->only([
  161. 'token',
  162. 'start_date' => date('Y-m-d'),
  163. 'end_date' => date('Y-m-d'),
  164. ], 'post', 'trim');
  165. $val_params = Validate::rule([
  166. 'start_date' => 'date|elt:end_date',
  167. 'end_date' => 'date',
  168. ]);
  169. if (!$val_params->check($param)) return error_show(1004, $val_params->getError());
  170. $rs = Db::name('purchease_order')
  171. ->alias('po')
  172. ->field('DATE_FORMAT(po.addtime,"%Y-%m-%d") addtime,SUM(po.total_fee) total_fee,SUM(po.good_num) good_num,po.status,du.itemid,ci.name,"" wait_total_fee,"" wait_good_num')
  173. ->leftJoin('depart_user du', 'du.uid=po.cgder_id AND du.is_del=0')
  174. ->leftJoin('company_item ci', 'ci.id=du.itemid AND ci.is_del=0')
  175. ->where('po.is_del', 0)
  176. ->group('addtime,du.itemid,po.status')
  177. ->order('addtime,itemid')
  178. ->whereBetween('po.addtime', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59'])
  179. ->cursor();
  180. $data = [];
  181. foreach ($rs as $value) {
  182. if (!isset($data[$value['addtime']][$value['itemid']])) {
  183. $data[$value['addtime']][$value['itemid']] = [
  184. 'addtime' => $value['addtime'],
  185. 'itemid' => $value['itemid'],
  186. 'name' => $value['name'],
  187. 'total_fee' => 0,
  188. 'good_num' => 0,
  189. 'wait_total_fee' => 0,
  190. 'wait_good_num' => 0,
  191. ];
  192. }
  193. if ($value['status'] == 0) {
  194. $data[$value['addtime']][$value['itemid']]['wait_total_fee'] += $value['total_fee'];
  195. $data[$value['addtime']][$value['itemid']]['wait_good_num'] += $value['good_num'];
  196. } else {
  197. $data[$value['addtime']][$value['itemid']]['total_fee'] += $value['total_fee'];
  198. $data[$value['addtime']][$value['itemid']]['good_num'] += $value['good_num'];
  199. }
  200. }
  201. //去除下标
  202. $da = [];
  203. foreach ($data as $v) {
  204. foreach ($v as $vvv) {
  205. $da[] = $vvv;
  206. }
  207. }
  208. return app_show(0, '请求成功', $da);
  209. }
  210. //【一、采购日报表】3.采购员回复咨询单数
  211. public function consultBidsSum()
  212. {
  213. $param = $this->request->only([
  214. 'token',
  215. 'start_date' => date('Y-m-d'),
  216. 'end_date' => date('Y-m-d'),
  217. ], 'post', 'trim');
  218. $val_params = Validate::rule([
  219. 'start_date' => 'date|elt:end_date',
  220. 'end_date' => 'date',
  221. ]);
  222. if (!$val_params->check($param)) return error_show(1004, $val_params->getError());
  223. $rs = Db::name('consult_bids')
  224. ->alias('cb')
  225. ->field('DATE_FORMAT(cb.addtime,"%Y-%m-%d") addtime,du.itemid,cb.createrid,SUM(c.num) num,COUNT(cb.id) total,du.nickname,ci.name')
  226. ->leftJoin('consult c', 'c.zxNo=cb.zxNo AND c.is_del=0')
  227. ->leftJoin('depart_user du', 'du.uid=cb.createrid AND du.is_del=0')
  228. ->leftJoin('company_item ci', 'ci.id=du.itemid AND ci.is_del=0')
  229. ->where('cb.is_del', 0)
  230. ->group('addtime,du.itemid,ci.name ,cb.createrid,du.nickname')
  231. ->order('addtime,du.itemid,ci.name ,cb.createrid,du.nickname')
  232. ->whereBetween('cb.addtime', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59'])
  233. ->select()
  234. ->toArray();
  235. $rs[] = ['addtime' => '汇总', 'itemid' => 0, 'createrid' => 0, 'num' => array_sum(array_column($rs, 'num')), 'total' => array_sum(array_column($rs, 'total')), 'nickname' => '', 'name' => ''];
  236. return app_show(0, '请求成功', array_merge($rs));
  237. }
  238. //【一、采购日报表】4.采购员订单金额
  239. public function purcheaseOrderSumByUser()
  240. {
  241. $param = $this->request->only([
  242. 'token',
  243. 'start_date' => date('Y-m-d'),
  244. 'end_date' => date('Y-m-d'),
  245. ], 'post', 'trim');
  246. $val_params = Validate::rule([
  247. 'start_date' => 'date|elt:end_date',
  248. 'end_date' => 'date',
  249. ]);
  250. if (!$val_params->check($param)) return error_show(1004, $val_params->getError());
  251. $rs = Db::name('purchease_order')
  252. ->field('DATE_FORMAT(addtime, "%Y-%m-%d") addtime,cgder_id,cgder,SUM(total_fee) total_fee,SUM(good_num) good_num,status,0 wait_total_fee,0 wait_good_num')
  253. ->where('is_del', 0)
  254. ->group('addtime,cgder_id,cgder,status')
  255. ->order('addtime,cgder_id')
  256. ->whereBetween('addtime', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59'])
  257. ->cursor();
  258. $data = [];
  259. foreach ($rs as $value) {
  260. if (!isset($data[$value['addtime']][$value['cgder_id']])) {
  261. $data[$value['addtime']][$value['cgder_id']] = [
  262. 'addtime' => $value['addtime'],
  263. 'cgder' => $value['cgder'],
  264. 'total_fee' => 0.00,
  265. 'good_num' => 0,
  266. 'wait_total_fee' => 0.00,
  267. 'wait_good_num' => 0,
  268. ];
  269. }
  270. if ($value['status'] == 0) {
  271. $data[$value['addtime']][$value['cgder_id']]['wait_total_fee'] += $value['total_fee'];
  272. $data[$value['addtime']][$value['cgder_id']]['wait_good_num'] += $value['good_num'];
  273. } else {
  274. $data[$value['addtime']][$value['cgder_id']]['total_fee'] += $value['total_fee'];
  275. $data[$value['addtime']][$value['cgder_id']]['good_num'] += $value['good_num'];
  276. }
  277. }
  278. $da = [];
  279. //去除下标
  280. foreach ($data as $v) {
  281. foreach ($v as $vv) {
  282. $da[] = $vv;
  283. }
  284. }
  285. return app_show(0, '请求成功', $da);
  286. }
  287. //【二、咨询单报表】1.已采反报价信息
  288. public function consultInfoBidsSum()
  289. {
  290. $param = $this->request->only([
  291. 'token',
  292. 'zxNo' => [],
  293. 'start_date' => date('Y-m-d'),
  294. 'end_date' => date('Y-m-d'),
  295. 'page' => 1,
  296. 'size' => 15,
  297. 'is_export' => 0,//是否导出,1导出,0不导出
  298. ], 'post', 'trim');
  299. $val_params = Validate::rule([
  300. 'start_date' => 'date|elt:end_date',
  301. 'end_date' => 'date',
  302. 'is_export' => 'in:0,1',
  303. ]);
  304. if (!$val_params->check($param)) return error_show(1004, $val_params->getError());
  305. $rs = Db::name('consult_bids')
  306. ->alias('cb')
  307. ->where('cb.is_del', 0);
  308. if (!empty($param['start_date']) && !empty($param['end_date'])) $rs->whereBetween('cb.addtime', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']);
  309. if (!empty($param['zxNo'])) $rs->whereIn('cb.zxNo', $param['zxNo']);
  310. if ($param['is_export'] == 1) {
  311. $data = $rs
  312. ->field('ci.addtime as 咨询时间,cb.bidNo as 采购单反馈单号,cb.zxNo as 咨询订单号,cb.addtime as 回复时间,cb.good_name as 产品名称,s.name as 供应商名称,cb.total_fee 成本合计,cb.delivery_day 物流时间,cb.work_day 产品工期,cb.expire_day 信息有效期,cb.creater 采购员,ci.num 需求数量,ci.arrival_time 要求到货日期,co.salesman 业务人员,csi.companyName 客户名称')
  313. ->leftJoin('consult_info ci', 'ci.zxNo=cb.zxNo AND ci.is_del=0')
  314. ->leftJoin('consult_order co', 'co.zxNo=cb.zxNo AND co.is_del=0')
  315. ->leftJoin('supplier s', 's.code=cb.supplierNo AND s.is_del=0')
  316. ->leftJoin('customer_info csi', 'csi.companyNo=co.khNo AND csi.is_del=0')
  317. ->select()
  318. ->toArray();
  319. if (empty($data)) return error_show(1005, '没有可供导出的数据');
  320. else {
  321. $headerArr = array_keys($data[0]);
  322. excelSave('咨询单报表-已采反报价信息' . date('YmdHis'), $headerArr, $data);
  323. }
  324. } else {
  325. $total = $rs->count('cb.id');
  326. $data = $rs
  327. ->field('cb.id,ci.addtime,cb.bidNo,cb.zxNo,cb.addtime cbaddtime,cb.good_name,s.name supplier,cb.total_fee,cb.delivery_day,cb.work_day,cb.expire_day,cb.creater,ci.num,ci.arrival_time,co.salesman,csi.companyName')
  328. ->leftJoin('consult_info ci', 'ci.zxNo=cb.zxNo AND ci.is_del=0')
  329. ->leftJoin('consult_order co', 'co.zxNo=cb.zxNo AND co.is_del=0')
  330. ->leftJoin('supplier s', 's.code=cb.supplierNo AND s.is_del=0')
  331. ->leftJoin('customer_info csi', 'csi.companyNo=co.khNo AND csi.is_del=0')
  332. ->page($param['page'], $param['size'])
  333. ->select()
  334. ->toArray();
  335. return app_show(0, '请求成功', ['list' => $data, 'total' => $total]);
  336. }
  337. }
  338. //【二、咨询单报表】2.未采反信息
  339. public function consultInfoBidsSumNot()
  340. {
  341. $param = $this->request->only([
  342. 'token',
  343. 'companyName' => '',
  344. 'start_date' => date('Y-m-d'),
  345. 'end_date' => date('Y-m-d'),
  346. 'page' => 1,
  347. 'size' => 15,
  348. 'is_export' => 0,//是否导出,1导出,0不导出
  349. ], 'post', 'trim');
  350. $val_params = Validate::rule([
  351. 'start_date' => 'date|elt:end_date',
  352. 'end_date' => 'date',
  353. 'is_export' => 'in:0,1',
  354. ]);
  355. if (!$val_params->check($param)) return error_show(1004, $val_params->getError());
  356. $rs = Db::name('consult_bids')
  357. ->alias('cb')
  358. ->leftJoin('consult_info ci', 'ci.zxNo=cb.zxNo AND ci.is_del=0')
  359. ->leftJoin('consult_order co', 'co.zxNo=cb.zxNo AND co.is_del=0')
  360. ->leftJoin('customer_info csi', 'csi.companyNo=co.khNo AND csi.is_del=0')
  361. ->where('cb.is_del', 0)
  362. ->order('co.endtime', 'desc');
  363. if ($param['start_date'] != '' && $param['end_date'] != '') $rs->whereBetween('ci.addtime', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']);
  364. if ($param['companyName'] != '') $rs->whereLike('csi.companyName', '%' . $param['companyName'] . '%');
  365. if ($param['is_export'] == 1) {
  366. $data = $rs
  367. ->field('cb.zxNo 咨询订单号,cb.good_name 产品名称,ci.num 需求数量,csi.companyName 客户名称,ci.addtime 咨询时间,co.endtime 截止时间')
  368. ->select()
  369. ->toArray();
  370. if (empty($data)) return error_show(1005, '没有可供导出的数据');
  371. else {
  372. $headerArr = array_keys($data[0]);
  373. excelSave('咨询单报表-未采反信息' . date('YmdHis'), $headerArr, $data);
  374. }
  375. } else {
  376. $total = $rs->count('cb.id');
  377. $data = $rs
  378. ->field('cb.zxNo,cb.good_name,ci.num,csi.companyName,ci.addtime,co.endtime')
  379. ->page($param['page'], $param['size'])
  380. ->select()
  381. ->toArray();
  382. return app_show(0, '请求成功', ['list' => $data, 'total' => $total]);
  383. }
  384. }
  385. //【三、订单明细报表】
  386. public function orderListDetailed()
  387. {
  388. $param = $this->request->only([
  389. 'token',
  390. 'start_date' => date('Y-m-d'),
  391. 'end_date' => date('Y-m-d'),
  392. 'page' => 1,
  393. 'size' => 15,
  394. 'is_export' => 0,//是否导出,1导出,0不导出
  395. ], 'post', 'trim');
  396. $val_params = Validate::rule([
  397. 'start_date' => 'date|elt:end_date',
  398. 'end_date' => 'date',
  399. 'is_export' => 'in:0,1',
  400. ]);
  401. if (!$val_params->check($param)) return error_show(1004, $val_params->getError());
  402. $rs = Db::name('purchease_order')
  403. ->alias('po');
  404. // ->leftJoin('consult_info ci', 'ci.zxNo=cb.zxNo AND ci.is_del=0')
  405. // ->leftJoin('consult_order co', 'co.zxNo=cb.zxNo AND co.is_del=0')
  406. // ->leftJoin('customer_info csi', 'csi.companyNo=co.khNo AND csi.is_del=0')
  407. // ->where('cb.is_del', 0)
  408. // ->order('co.endtime', 'desc');
  409. if ($param['start_date'] != '' && $param['end_date'] != '') $rs->whereBetween('ci.addtime', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']);
  410. if ($param['companyName'] != '') $rs->whereLike('csi.companyName', '%' . $param['companyName'] . '%');
  411. if ($param['is_export'] == 1) {
  412. $data = $rs
  413. ->field('cb.zxNo 咨询订单号,cb.good_name 产品名称,ci.num 需求数量,csi.companyName 客户名称,ci.addtime 咨询时间,co.endtime 截止时间')
  414. ->select()
  415. ->toArray();
  416. if (empty($data)) return error_show(1005, '没有可供导出的数据');
  417. else {
  418. $headerArr = array_keys($data[0]);
  419. excelSave('咨询单报表-未采反信息' . date('YmdHis'), $headerArr, $data);
  420. }
  421. } else {
  422. $total = $rs->count('po.id');
  423. $data = $rs
  424. ->field('po.,po.,po.,po.,po.,po.,po.,po.')
  425. ->page($param['page'], $param['size'])
  426. ->select()
  427. ->toArray();
  428. return app_show(0, '请求成功', ['list' => $data, 'total' => $total]);
  429. }
  430. }
  431. }