OrderController.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689
  1. <?php
  2. namespace app\admin\controller;
  3. use think\exception\ValidateException;
  4. use app\model\Order;
  5. use app\model\OrderStaff;
  6. use app\model\OrderCount;
  7. use app\model\Store;
  8. use app\model\Express;
  9. use app\model\OrderHistory;
  10. use app\model\OrderExpress;
  11. use app\model\Technical;
  12. use app\model\MessageMp;
  13. use app\model\MessageMini;
  14. use app\model\Paymethod;
  15. use app\model\RegisterField;
  16. use app\model\Operatingcity;
  17. use app\model\OrderTuanzhang;
  18. use app\model\Goods;
  19. use app\model\QrcodeMod;
  20. use app\model\Config;
  21. use app\samos\wechat\MiniProgram;
  22. class OrderController extends Base
  23. {
  24. function index()
  25. {
  26. $status = input('post.status', '', 'serach_in');
  27. $query = $this->setSearch();
  28. $querycount = clone $query;
  29. $countdata['statuscount1'] = Order::statuscount(clone $querycount, 1);
  30. $countdata['statuscount2'] = Order::statuscount(clone $querycount, 2);
  31. $countdata['statuscount3'] = Order::statuscount(clone $querycount, 3);
  32. $countdata['statuscount4'] = Order::statuscount(clone $querycount, 4);
  33. $countdata['statuscount5'] = Order::statuscount(clone $querycount, 5);
  34. $countdata['statuscount6'] = Order::statuscount(clone $querycount, 6);
  35. $countdata['statuscount7'] = Order::statuscount(clone $querycount, 7);
  36. if (!empty($status)) {
  37. $query->where('order_status_id', $status);
  38. }
  39. $res = $query->order('id desc')
  40. ->paginate(getpage())
  41. ->toArray();
  42. $sql = $query->getLastsql();
  43. foreach ($res['data'] as &$vo) {
  44. $vo = Order::conversion($vo);
  45. Order::where('id', $vo['id'])->update(['searchkeyword' => '']);
  46. }
  47. $data['data'] = $res;
  48. $data['sql'] = $sql;
  49. $data['countdata'] = $countdata;
  50. return $this->json($data);
  51. }
  52. function setSearch()
  53. {
  54. $weid = weid();
  55. $path = input('post.path', '', 'serach_in');
  56. $keyword = input('post.keyword', '', 'serach_in');
  57. $deliverymode = input('post.deliverymode', '', 'serach_in');
  58. $uid = input('post.uid', '', 'intval');
  59. $create_time = input('post.create_time', '', 'serach_in');
  60. $query = Order::where(['weid' => $weid]);
  61. if (!empty($deliverymode)) {
  62. $query->where('deliverymode', $deliverymode);
  63. }
  64. if (!empty($uid)) {
  65. $query->where('uid', $uid);
  66. }
  67. if (!empty($this->sid)) {
  68. $query->where('sid', $this->sid);
  69. }
  70. if (!empty($this->ocid)) {
  71. $Operatingcitydata = Operatingcity::find($this->ocid);
  72. if ($Operatingcitydata) {
  73. $Operatingcitydata = $Operatingcitydata->toArray();
  74. if (empty($Operatingcitydata['areatype'])) {
  75. $Operatingcitydata['areatype'] = 3;
  76. }
  77. if ($Operatingcitydata['areatype'] == 3) {
  78. $query->where('shipping_district_name', $Operatingcitydata['district_name']);
  79. } elseif ($Operatingcitydata['areatype'] == 2) {
  80. $query->where('shipping_city_name', $Operatingcitydata['city_name']);
  81. } elseif ($Operatingcitydata['areatype'] == 1) {
  82. $query->where('shipping_province_name', $Operatingcitydata['province_name']);
  83. }
  84. } else {
  85. $query->where('shipping_city_name', '无');
  86. }
  87. }
  88. if (!empty($this->tzid)) {
  89. if (!empty($this->tzid)) {
  90. $query->where('sid', Store::getidbytzid($this->tzid));
  91. }
  92. }
  93. if ($path == '/order/service' || $path == '/order/storeservice') {
  94. $query->where('ptype', 2)->where('is_times', 0);
  95. } elseif ($path == '/order/timescard') {
  96. $query->where('ptype', 2)->where('is_times', 1);
  97. } elseif ($path == '/order/goodsgiftcard') {
  98. $query->where('ptype', 2)->where('is_times', 3);
  99. } elseif ($path == '/order/goods') {
  100. $query->where('ptype', 1)->where('is_times', 0);
  101. }
  102. $query->with(['member', 'orderGoods', 'paymethod']);
  103. if (!empty($create_time)) {
  104. $query->where('create_time', 'between', [strtotime($create_time[0]), strtotime($create_time[1])]);
  105. }
  106. if (!empty($keyword)) {
  107. $query->where('name|searchkeyword|pay_subject|shipping_name|shipping_tel|shipping_province_name|shipping_city_name|shipping_district_name|shipping_address|order_num_alias', 'like', '%' . $keyword . '%');
  108. }
  109. return $query;
  110. }
  111. public function total()
  112. {
  113. $postdata = input('post.');
  114. $skumore = json_decode($postdata['skumore'], true);
  115. $Goods = new Goods;
  116. $buygoods = $Goods->cartGoods([
  117. 'id' => $postdata['goods_id'],
  118. 'sku' => $postdata['sku'],
  119. 'quantity' => $postdata['number'],
  120. 'is_skumore' => $postdata['is_skumore'],
  121. 'skumore' => $skumore
  122. ]);
  123. $data["amountTotle"] = $buygoods['total'];
  124. $data["amountTotle"] = round($data["amountTotle"], 2);
  125. return $this->json(['data' => $data]);
  126. }
  127. function add()
  128. {
  129. $msg = '添加成功';
  130. $postdata = input('post.');
  131. $Configdata = Config::getconfig();
  132. $ordermod = new Order;
  133. if (!empty($postdata['order_num_alias'])) {
  134. if (Order::where(['order_num_alias' => $postdata['order_num_alias']])->find()) {
  135. throw new ValidateException('订单编号已存在');
  136. } else {
  137. $order['order_num_alias'] = $postdata['order_num_alias'];
  138. }
  139. }
  140. if ($Configdata['external_order_pay'] == 1) {
  141. $payment = 'offline_pay';
  142. } else {
  143. $payment = 'wx_pay';
  144. }
  145. $servicetime = input('post.servicetime', '', 'serach_in');
  146. if (!empty($servicetime)) {
  147. $servicetime = explode(' ', $servicetime);
  148. }
  149. if (empty($servicetime[1])) {
  150. $timetmp = explode('-', $servicetime[1]);
  151. }
  152. $order['begin_time'] = strtotime($servicetime[0] . ' ' . $timetmp[0]);
  153. $order['end_time'] = strtotime($servicetime[0] . ' ' . $timetmp[1]);
  154. $order['goods_id'] = $postdata['goods_id'];
  155. $order['total'] = $postdata['total'];
  156. $order['number'] = $postdata['number'];
  157. //支付方式
  158. if (!empty($payment)) {
  159. $order['payment_code'] = $payment;
  160. $paymentdata = Paymethod::where(['code' => $payment, 'weid' => weid()])->find();
  161. $order['pay_method_id'] = $paymentdata->id;
  162. }
  163. $area = $postdata['area'];
  164. $order['shipping_province_name'] = $area[0];
  165. $order['shipping_city_name'] = $area[1];
  166. $order['shipping_district_name'] = $area[2];
  167. $order['shipping_name'] = $postdata['shipping_name'];
  168. $order['shipping_tel'] = $postdata['shipping_tel'];
  169. $order['shipping_address'] = $postdata['shipping_address'];
  170. $order['remark'] = $postdata['remark'];
  171. //var_dump($order);
  172. $data = $ordermod->add_order($order);
  173. if (!empty($data['id'])) {
  174. if ($Configdata['external_order_pay'] == 1) {
  175. $pay_time = time();
  176. Order::where(['id' => $data['id']])->update(['pay_time' => $pay_time]);
  177. $ordermod = new Order;
  178. $ordermod->pay_order(['order_num_alias' => $data['order_num_alias']]);
  179. }
  180. }
  181. return $this->json(['msg' => $msg, 'data' => $data]);
  182. }
  183. function update()
  184. {
  185. $msg = '修改成功';
  186. $postdata = input('post.');
  187. $orderInfo = $postdata['orderInfo'];
  188. try {
  189. $order_history['order_status_id'] = $orderInfo['order_status_id'];
  190. $order_history['order_id'] = $orderInfo['id'];
  191. $order_history['remark'] = $postdata['words'];
  192. if (empty($order_history['remark'])) {
  193. $order_history['remark'] = '修改订单';
  194. }
  195. $order_history['notify'] = 1;
  196. OrderHistory::create($order_history);
  197. $orderup = $orderInfo;
  198. unset($orderup['create_time']);
  199. unset($orderup['update_time']);
  200. unset($orderup['pay_time']);
  201. unset($orderup['ServiceTime']);
  202. unset($orderup['ServiceTime']);
  203. if (!empty($postdata['is_express'])) {
  204. $orderup['is_express'] = $postdata['is_express'];
  205. }
  206. $fieldsdata = RegisterField::fieldToData($postdata, 'pc')['data'];
  207. $orderup['customtext'] = $fieldsdata['customtext'];
  208. order::update($orderup);
  209. $orderup['uid'] = $orderInfo['uid'];
  210. OrderCount::createuserdata($orderup);
  211. } catch (\Exception $e) {
  212. throw new ValidateException($e->getMessage());
  213. }
  214. return $this->json(['msg' => $msg]);
  215. }
  216. public function delivery()
  217. {
  218. $msg = '操作成功';
  219. $orderid = input('post.id');
  220. $orderinfo = Order::find($orderid);
  221. if (!empty($orderinfo)) {
  222. Order::settlement($orderid);
  223. } else {
  224. $msg = '订单不存在';
  225. }
  226. return $this->json(['msg' => $msg]);
  227. }
  228. function staff()
  229. {
  230. $postdata = input('post.');
  231. $orderInfo = $postdata['orderInfo'];
  232. try {
  233. if (empty($this->sid)) {
  234. if (empty($orderInfo['sendto'])) {
  235. throw new ValidateException('请选择指派给');
  236. }
  237. //平台派单
  238. if ($orderInfo['sendto'] == 2) {
  239. if (empty($postdata['uuid'])) {
  240. throw new ValidateException('请选择师傅');
  241. }
  242. $order_staff['order_id'] = $orderInfo['id'];
  243. $order_staff['uuid'] = $postdata['uuid'];
  244. $order_staff['begin_time'] = $orderInfo['begin_time'];
  245. $order_staff['end_time'] = $orderInfo['end_time'];
  246. OrderStaff::addstaff($order_staff);
  247. MessageMini::sendMiniStaff($orderInfo);
  248. MessageMp::distribution($postdata['uuid'], $orderInfo);
  249. $orderup['sid'] = 0;
  250. $msg = '派单成功';
  251. } elseif ($orderInfo['sendto'] == 1) {
  252. if (empty($orderInfo['sid'])) {
  253. throw new ValidateException('请选择商家');
  254. }
  255. OrderStaff::where('order_id', $orderInfo['id'])->delete();
  256. $msg = '派单成功';
  257. $orderup['sid'] = $orderInfo['sid'];
  258. }
  259. } else {
  260. //商家派单
  261. $order_staff['order_id'] = $orderInfo['id'];
  262. $order_staff['uuid'] = $postdata['siduuid'];
  263. $order_staff['begin_time'] = $orderInfo['begin_time'];
  264. $order_staff['end_time'] = $orderInfo['end_time'];
  265. OrderStaff::addstaff($order_staff);
  266. MessageMini::sendMiniStaff($orderInfo);
  267. MessageMp::distribution($postdata['uuid'], $orderInfo);
  268. $msg = '派单成功';
  269. }
  270. if ($orderInfo['order_status_id'] == 2) {
  271. $order_history['order_status_id'] = 3;
  272. $orderup['order_status_id'] = 3;
  273. } else if ($orderInfo['order_status_id'] == 8) {
  274. $order_history['order_status_id'] = 9;
  275. $orderup['order_status_id'] = 9;
  276. }
  277. $order_history['order_id'] = $orderInfo['id'];
  278. $order_history['remark'] = '派单';
  279. $order_history['notify'] = 1;
  280. OrderHistory::create($order_history);
  281. $orderup['id'] = $orderInfo['id'];
  282. $orderup['sendto'] = $orderInfo['sendto'];
  283. order::update($orderup);
  284. $orderup['uid'] = $orderInfo['uid'];
  285. OrderCount::createuserdata($orderup);
  286. } catch (\Exception $e) {
  287. throw new ValidateException($e->getMessage());
  288. }
  289. return $this->json(['msg' => $msg]);
  290. }
  291. function send()
  292. {
  293. $postdata = input('post.');
  294. $orderInfo = $postdata['orderInfo'];
  295. if ($orderInfo['order_status_id'] == 2) {
  296. $order_history['order_status_id'] = 3;
  297. $orderup['order_status_id'] = 3;
  298. } else if ($orderInfo['order_status_id'] == 8) {
  299. $order_history['order_status_id'] = 9;
  300. $orderup['order_status_id'] = 9;
  301. }
  302. try {
  303. $order_history['order_id'] = $orderInfo['id'];
  304. $order_history['remark'] = $postdata['words'];
  305. $order_history['notify'] = 1;
  306. OrderHistory::create($order_history);
  307. $order_express['weid'] = weid();
  308. $order_express['order_id'] = $orderInfo['id'];
  309. $order_express['expressname'] = Express::getExname($postdata['express_code']);
  310. $order_express['express_code'] = $postdata['express_code'];
  311. $order_express['express_no'] = $postdata['express_no'];
  312. if (OrderExpress::where('order_id', $orderInfo['id'])->find()) {
  313. OrderExpress::where('order_id', $orderInfo['id'])->update($order_express);
  314. $msg = '修改物流信息成功';
  315. } else {
  316. OrderExpress::create($order_express);
  317. $msg = '发货成功';
  318. }
  319. $orderup['is_express'] = $postdata['is_express'];
  320. $orderup['id'] = $orderInfo['id'];
  321. order::update($orderup);
  322. $orderup['uid'] = $orderInfo['uid'];
  323. OrderCount::createuserdata($orderup);
  324. } catch (\Exception $e) {
  325. throw new ValidateException($e->getMessage());
  326. }
  327. return $this->json(['msg' => $msg]);
  328. }
  329. function getSendInfo()
  330. {
  331. $id = $this->request->post('id', '', 'serach_in');
  332. if (!$id) throw new ValidateException('参数错误');
  333. $orderInfo = Order::find($id);
  334. if ($orderInfo) {
  335. $orderInfo = $orderInfo->toArray();
  336. if ($orderInfo['deliverymode'] == 5) {
  337. $tuanzhang = OrderTuanzhang::getTuanzhang($orderInfo['id']);
  338. if (!empty($tuanzhang)) {
  339. $orderInfo['shipping_name'] = $tuanzhang['title'];
  340. $orderInfo['shipping_tel'] = $tuanzhang['tel'];
  341. $orderInfo['shipping_address'] = $tuanzhang['region_name'];
  342. }
  343. }
  344. }
  345. $data = OrderExpress::where('order_id', $id)->find();
  346. if ($data) {
  347. $data = $data->toArray();
  348. }
  349. $data['orderInfo'] = $orderInfo;
  350. $data['is_express'] = $orderInfo['is_express'];
  351. return $this->json(['data' => $data]);
  352. }
  353. function offlinepay()
  354. {
  355. $postdata = input('post.');
  356. $orderInfo = $postdata['orderInfo'];
  357. $id = $orderInfo['id'];
  358. $orderinfo = Order::where(['id' => $id])->find();
  359. if (!empty($orderinfo)) {
  360. $pay_time = time();
  361. Order::where(['id' => $id])->update(['pay_time' => $pay_time]);
  362. $ordermod = new Order;
  363. $ordermod->pay_order(['order_num_alias' => $orderinfo['order_num_alias']]);
  364. }
  365. return $this->json(['msg' => '操作成功']);
  366. }
  367. function getInfo()
  368. {
  369. $id = $this->request->post('id', '', 'serach_in');
  370. if (!$id) throw new ValidateException('参数错误');
  371. $data = Order::order_info($id);
  372. $data['sid'] = (int) $this->sid;
  373. $data['sidarray'] = Store::getpcarray();
  374. $data['technical'] = Technical::getpcarraydetailed($data['sid'], $data['orderInfo']['cate_ids'], $data['orderInfo']['shipping_city_name']);
  375. if ($data['orderInfo']['deliverymode'] == 5) {
  376. $tuanzhang = OrderTuanzhang::getTuanzhang($data['orderInfo']['id']);
  377. if (!empty($tuanzhang)) {
  378. $data['orderInfo']['shipping_name'] = $tuanzhang['title'];
  379. $data['orderInfo']['shipping_tel'] = $tuanzhang['tel'];
  380. $data['orderInfo']['shipping_address'] = $tuanzhang['region_name'];
  381. }
  382. }
  383. if ($data['orderInfo']['payment_code'] == 'offline_pay') {
  384. $data['offline_img'] = Order::getoffline($id);
  385. }
  386. if ($data['orderInfo']['sid'] == 0) {
  387. $data['orderInfo']['sid'] = '';
  388. }
  389. if (empty($data['orderInfo']['member'])) {
  390. $data['orderInfo']['member'] = [];
  391. }
  392. $data['is_express'] = 1;
  393. foreach ($data['goods'] as $gvo) {
  394. $data['goodsquantity'] = $data['goodsquantity'] + $gvo['quantity'];
  395. }
  396. $data['uuid'] = OrderStaff::getuuid($data['orderInfo']['id']);
  397. if ($data['sid']) {
  398. $data['siduuid'] = $data['uuid'];
  399. }
  400. $page = 'pagesA/my/myOrder/yuyueDetail?id=' . $data['orderInfo']['id'];
  401. $data['orderInfo']['qrcode'] = MiniProgram::getQrcode2($page);
  402. $page = 'pagesA/my/publicOrder/orderpay';
  403. $scene = $data['orderInfo']['id'];
  404. $data['orderInfo']['payqrcode'] = MiniProgram::getQrcode($scene, $page);
  405. $customtext = iunserializer($data['orderInfo']['customtext']);
  406. $RegisterField = RegisterField::getinputField('complete');
  407. foreach ($RegisterField as &$vo) {
  408. if ($vo['is_sys'] == 1) {
  409. } else {
  410. $vo['fieldsvalue'] = $customtext[$vo['inputtype']][$vo['id']];
  411. }
  412. if ($vo['inputtype'] == 'pics') {
  413. $vo['fieldsvalue1'] = $vo['fieldsvalue'];
  414. if (empty($vo['fieldsvalue'])) {
  415. $vo['fieldsvalue'] = [];
  416. } else {
  417. $vo['fieldsvalue'] = setPicsView($vo['fieldsvalue']);
  418. }
  419. }
  420. }
  421. $data['fields'] = $RegisterField;
  422. return $this->json(['data' => $data]);
  423. }
  424. function delete()
  425. {
  426. return $this->del(new Order());
  427. }
  428. function getTechnical()
  429. {
  430. $sid = $this->request->post('sid', '', 'serach_in');
  431. $data['technical'] = Technical::getpcarray($this->sid);
  432. return $this->json(['data' => $data]);
  433. }
  434. function getExpress()
  435. {
  436. $data['expressArray'] = Express::getpcarray();
  437. return $this->json(['data' => $data]);
  438. }
  439. function dumpdata()
  440. {
  441. $datalist = [];
  442. $page = $this->request->post('page', 1, 'intval');
  443. $limit = config('my.dumpsize') ? config('my.dumpsize') : 1000;
  444. $query = $this->setSearch();
  445. $status = input('post.status', '', 'serach_in');
  446. if (!empty($status)) {
  447. $query->where('order_status_id', $status);
  448. }
  449. $count = $query->count();
  450. $res = $query->order('id desc')->limit(($page - 1) * $limit, $limit)->select()->toArray();
  451. //var_dump($query->getLastSql());
  452. $servicedumpField = [
  453. [
  454. 'fieldsmingcheng' => 'order_num_alias',
  455. 'viewmingcheng' => '订单号'
  456. ],
  457. [
  458. 'fieldsmingcheng' => 'pay_subject',
  459. 'viewmingcheng' => '预约服务'
  460. ],
  461. [
  462. 'fieldsmingcheng' => 'total',
  463. 'viewmingcheng' => '订单金额'
  464. ],
  465. [
  466. 'fieldsmingcheng' => 'sid',
  467. 'viewmingcheng' => '派单门店'
  468. ],
  469. [
  470. 'fieldsmingcheng' => 'staff',
  471. 'viewmingcheng' => '派单师傅'
  472. ],
  473. [
  474. 'fieldsmingcheng' => 'member_nickname',
  475. 'viewmingcheng' => '下单用户'
  476. ],
  477. [
  478. 'fieldsmingcheng' => 'shipping_name',
  479. 'viewmingcheng' => '联系人'
  480. ],
  481. [
  482. 'fieldsmingcheng' => 'shipping_tel',
  483. 'viewmingcheng' => '电 话'
  484. ],
  485. [
  486. 'fieldsmingcheng' => 'yue_time',
  487. 'viewmingcheng' => '预约时间'
  488. ], [
  489. 'fieldsmingcheng' => 'shipping_city_name',
  490. 'viewmingcheng' => '所在城市'
  491. ],
  492. [
  493. 'fieldsmingcheng' => 'shipping_address',
  494. 'viewmingcheng' => '详细地址'
  495. ],
  496. [
  497. 'fieldsmingcheng' => 'order_status',
  498. 'viewmingcheng' => '订单状态'
  499. ],
  500. [
  501. 'fieldsmingcheng' => 'payment_code_name',
  502. 'viewmingcheng' => '支付方式'
  503. ],
  504. [
  505. 'fieldsmingcheng' => 'pay_time',
  506. 'viewmingcheng' => '支付时间'
  507. ]
  508. ];
  509. $goodsdumpField = [
  510. [
  511. 'fieldsmingcheng' => 'order_num_alias',
  512. 'viewmingcheng' => '订单号'
  513. ],
  514. [
  515. 'fieldsmingcheng' => 'pay_subject',
  516. 'viewmingcheng' => '商品'
  517. ],
  518. [
  519. 'fieldsmingcheng' => 'total',
  520. 'viewmingcheng' => '订单金额'
  521. ],
  522. [
  523. 'fieldsmingcheng' => 'member_nickname',
  524. 'viewmingcheng' => '下单用户'
  525. ],
  526. [
  527. 'fieldsmingcheng' => 'order_status',
  528. 'viewmingcheng' => '订单状态'
  529. ],
  530. [
  531. 'fieldsmingcheng' => 'payment_code_name',
  532. 'viewmingcheng' => '支付方式'
  533. ],
  534. [
  535. 'fieldsmingcheng' => 'pay_time',
  536. 'viewmingcheng' => '支付时间'
  537. ],
  538. [
  539. 'fieldsmingcheng' => 'shipping_name',
  540. 'viewmingcheng' => '收货人'
  541. ],
  542. [
  543. 'fieldsmingcheng' => 'shipping_tel',
  544. 'viewmingcheng' => '电话'
  545. ],
  546. [
  547. 'fieldsmingcheng' => 'shipping_city_name',
  548. 'viewmingcheng' => '城市'
  549. ],
  550. [
  551. 'fieldsmingcheng' => 'shipping_address',
  552. 'viewmingcheng' => '地址'
  553. ],
  554. [
  555. 'fieldsmingcheng' => 'shipping_time',
  556. 'viewmingcheng' => '发货时间'
  557. ],
  558. [
  559. 'fieldsmingcheng' => 'shipping_express_id',
  560. 'viewmingcheng' => '快递公司'
  561. ],
  562. [
  563. 'fieldsmingcheng' => 'shipping_code',
  564. 'viewmingcheng' => '快递单号'
  565. ]
  566. ];
  567. if ($res[0]['ptype'] == 1) {
  568. $dumpField = $goodsdumpField;
  569. } elseif ($res[0]['ptype'] == 2) {
  570. $dumpField = $servicedumpField;
  571. }
  572. foreach ($res as $k => $vo) {
  573. $vo = Order::conversion($vo);
  574. foreach ($dumpField as $key => $fvo) {
  575. $datalist[$k][$key] = $vo[$fvo['fieldsmingcheng']];
  576. }
  577. }
  578. foreach ($dumpField as $key => $vo) {
  579. $data['header'][$key] = $vo['viewmingcheng'];
  580. }
  581. $data['percentage'] = ceil($page * 100 / ceil($count / $limit));
  582. $data['filename'] = '订单.' . config('my.dump_extension');
  583. $data['data'] = $datalist;
  584. return $this->json($data);
  585. }
  586. }