StoreOrder.php 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057
  1. <?php
  2. /**
  3. *
  4. * @author: xaboy<365615158@qq.com>
  5. * @day: 2017/11/11
  6. */
  7. namespace app\admin\controller\order;
  8. use app\admin\controller\AuthController;
  9. use app\admin\model\order\StoreOrderCartInfo;
  10. use app\admin\model\system\Express;
  11. use crmeb\repositories\OrderRepository;
  12. use crmeb\repositories\ShortLetterRepositories;
  13. use crmeb\services\{ExpressService,
  14. JsonService,
  15. JsonService as Json,
  16. MiniProgramService,
  17. WechatService,
  18. FormBuilder as Form,
  19. CacheService,
  20. UtilService as Util
  21. };
  22. use app\admin\model\order\StoreOrderStatus;
  23. use app\admin\model\ump\StorePink;
  24. use think\exception\ValidateException;
  25. use think\facade\App;
  26. use think\facade\Filesystem;
  27. use app\admin\model\user\{
  28. User, UserBill
  29. };
  30. use crmeb\basic\BaseModel;
  31. use think\facade\Route as Url;
  32. use app\admin\model\order\StoreOrder as StoreOrderModel;
  33. use crmeb\services\YLYService;
  34. use think\facade\Log;
  35. /**
  36. * 订单管理控制器 同一个订单表放在一个控制器
  37. * Class StoreOrder
  38. * @package app\admin\controller\store
  39. */
  40. class StoreOrder extends AuthController
  41. {
  42. /**
  43. * @return mixed
  44. */
  45. public function index()
  46. {
  47. $this->assign([
  48. 'year' => get_month(),
  49. 'real_name' => $this->request->get('real_name', ''),
  50. 'status' => $this->request->param('status', ''),
  51. 'orderCount' => StoreOrderModel::orderCount(),
  52. 'payTypeCount' => StoreOrderModel::payTypeCount(),
  53. ]);
  54. return $this->fetch();
  55. }
  56. /**
  57. * 获取头部订单金额等信息
  58. * return json
  59. */
  60. public function getBadge()
  61. {
  62. $where = Util::postMore([
  63. ['status', ''],
  64. ['real_name', ''],
  65. ['is_del', 0],
  66. ['data', ''],
  67. ['type', ''],
  68. ['pay_type', ''],
  69. ['order', '']
  70. ]);
  71. return Json::successful(StoreOrderModel::getBadge($where));
  72. }
  73. /**
  74. * 获取订单列表
  75. * return json
  76. */
  77. public function order_list()
  78. {
  79. $where = Util::getMore([
  80. ['status', ''],
  81. ['real_name', $this->request->param('real_name', '')],
  82. ['is_del', 0],
  83. ['data', ''],
  84. ['type', ''],
  85. ['pay_type', ''],
  86. ['order', ''],
  87. ['page', 1],
  88. ['limit', 20],
  89. ['excel', 0]
  90. ]);
  91. return Json::successlayui(StoreOrderModel::OrderList($where));
  92. }
  93. public function order_print($id = '')
  94. {
  95. if (!$id) {
  96. return JsonService::fail('缺少参数');
  97. }
  98. $order = StoreOrderModel::get($id);
  99. if (!$order) {
  100. return JsonService::fail('订单没有查到,无法打印!');
  101. }
  102. try {
  103. $order['cart_id'] = is_string($order['cart_id']) ? json_decode($order['cart_id'], true) : $order['cart_id'];
  104. $cartInfo = StoreOrderCartInfo::whereIn('cart_id', $order['cart_id'])->field('cart_info')->select();
  105. $cartInfo = count($cartInfo) ? $cartInfo->toArray() : [];
  106. $product = [];
  107. foreach ($cartInfo as $item) {
  108. $value = is_string($item['cart_info']) ? json_decode($item['cart_info'], true) : $item['cart_info'];
  109. $value['productInfo']['store_name'] = $value['productInfo']['store_name'] ?? "";
  110. $value['productInfo']['store_name'] = StoreOrderCartInfo::getSubstrUTf8($value['productInfo']['store_name'], 10, 'UTF-8', '');
  111. $product[] = $value;
  112. }
  113. $res = YLYService::instance()->setContent(sys_config('site_name'), is_object($order) ? $order->toArray() : $order, $product)->orderPrinting();
  114. if ($res) {
  115. return JsonService::successful('打印成功');
  116. } else {
  117. return JsonService::fail('打印失败');
  118. }
  119. } catch (\Exception $e) {
  120. Log::error('小票打印出现错误,错误原因:' . $e->getMessage());
  121. return JsonService::fail($e->getMessage());
  122. }
  123. }
  124. /**
  125. * 核销码核销
  126. * @param string $verify_code
  127. * @return html
  128. */
  129. public function write_order($verify_code = '', $is_confirm = 0)
  130. {
  131. if ($this->request->isAjax()) {
  132. if (!$verify_code) return Json::fail('缺少核销码!');
  133. StoreOrderModel::beginTrans();
  134. $orderInfo = StoreOrderModel::where('verify_code', $verify_code)->where('paid', 1)->where('refund_status', 0)->find();
  135. if (!$orderInfo) return Json::fail('核销订单不存在!');
  136. if ($orderInfo->status > 0) return Json::fail('订单已核销!');
  137. if ($orderInfo->combination_id && $orderInfo->pink_id) {
  138. $res = StorePink::where('id', $orderInfo->pink_id)->where('status', '<>', 2)->count();
  139. if ($res) return Json::fail('拼团订单暂未成功无法核销!');
  140. }
  141. if ($is_confirm == 0) {
  142. $orderInfo['nickname'] = User::where(['uid' => $orderInfo['uid']])->value('nickname');
  143. return Json::successful($orderInfo);
  144. }
  145. $orderInfo->status = 2;
  146. if ($orderInfo->save()) {
  147. OrderRepository::storeProductOrderTakeDeliveryAdmin($orderInfo);
  148. StoreOrderStatus::setStatus($orderInfo->id, 'take_delivery', '已核销');
  149. //发送短信
  150. event('ShortMssageSend', [$orderInfo['order_id'], 'Receiving']);
  151. StoreOrderModel::commitTrans();
  152. return Json::successful('核销成功!');
  153. } else {
  154. StoreOrderModel::rollbackTrans();
  155. return Json::fail('核销失败');
  156. }
  157. } else
  158. $this->assign('is_layui', 1);
  159. return $this->fetch();
  160. }
  161. public function orderchart()
  162. {
  163. $where = Util::getMore([
  164. ['status', ''],
  165. ['real_name', ''],
  166. ['is_del', 0],
  167. ['data', ''],
  168. ['combination_id', ''],
  169. ['export', 0],
  170. ['order', 'id desc']
  171. ], $this->request);
  172. $limitTimeList = [
  173. 'today' => implode(' - ', [date('Y/m/d'), date('Y/m/d', strtotime('+1 day'))]),
  174. 'week' => implode(' - ', [
  175. date('Y/m/d', (time() - ((date('w') == 0 ? 7 : date('w')) - 1) * 24 * 3600)),
  176. date('Y-m-d', (time() + (7 - (date('w') == 0 ? 7 : date('w'))) * 24 * 3600))
  177. ]),
  178. 'month' => implode(' - ', [date('Y/m') . '/01', date('Y/m') . '/' . date('t')]),
  179. 'quarter' => implode(' - ', [
  180. date('Y') . '/' . (ceil((date('n')) / 3) * 3 - 3 + 1) . '/01',
  181. date('Y') . '/' . (ceil((date('n')) / 3) * 3) . '/' . date('t', mktime(0, 0, 0, (ceil((date('n')) / 3) * 3), 1, date('Y')))
  182. ]),
  183. 'year' => implode(' - ', [
  184. date('Y') . '/01/01', date('Y/m/d', strtotime(date('Y') . '/01/01 + 1year -1 day'))
  185. ])
  186. ];
  187. if ($where['data'] == '') $where['data'] = $limitTimeList['today'];
  188. $orderCount = [
  189. urlencode('未支付') => StoreOrderModel::getOrderWhere($where, StoreOrderModel::statusByWhere(0))->count(),
  190. urlencode('未发货') => StoreOrderModel::getOrderWhere($where, StoreOrderModel::statusByWhere(1))->count(),
  191. urlencode('待收货') => StoreOrderModel::getOrderWhere($where, StoreOrderModel::statusByWhere(2))->count(),
  192. urlencode('待评价') => StoreOrderModel::getOrderWhere($where, StoreOrderModel::statusByWhere(3))->count(),
  193. urlencode('交易完成') => StoreOrderModel::getOrderWhere($where, StoreOrderModel::statusByWhere(4))->count(),
  194. urlencode('退款中') => StoreOrderModel::getOrderWhere($where, StoreOrderModel::statusByWhere(-1))->count(),
  195. urlencode('已退款') => StoreOrderModel::getOrderWhere($where, StoreOrderModel::statusByWhere(-2))->count()
  196. ];
  197. $model = StoreOrderModel::getOrderWhere($where, new StoreOrderModel())->field('sum(total_num) total_num,count(*) count,sum(total_price) total_price,sum(refund_price) refund_price,from_unixtime(add_time,\'%Y-%m-%d\') add_time')
  198. ->group('from_unixtime(add_time,\'%Y-%m-%d\')');
  199. $orderPrice = $model->select()->toArray();
  200. $orderDays = [];
  201. $orderCategory = [
  202. ['name' => '商品数', 'type' => 'line', 'data' => []],
  203. ['name' => '订单数', 'type' => 'line', 'data' => []],
  204. ['name' => '订单金额', 'type' => 'line', 'data' => []],
  205. ['name' => '退款金额', 'type' => 'line', 'data' => []]
  206. ];
  207. foreach ($orderPrice as $price) {
  208. $orderDays[] = $price['add_time'];
  209. $orderCategory[0]['data'][] = $price['total_num'];
  210. $orderCategory[1]['data'][] = $price['count'];
  211. $orderCategory[2]['data'][] = $price['total_price'];
  212. $orderCategory[3]['data'][] = $price['refund_price'];
  213. }
  214. $this->assign(StoreOrderModel::systemPage($where, $this->adminId));
  215. $this->assign('price', StoreOrderModel::getOrderPrice($where));
  216. $this->assign(compact('limitTimeList', 'where', 'orderCount', 'orderPrice', 'orderDays', 'orderCategory'));
  217. return $this->fetch();
  218. }
  219. /**
  220. * 修改支付金额等
  221. * @param $id
  222. * @return mixed|\think\response\Json|void
  223. */
  224. public function edit($id)
  225. {
  226. if (!$id) return $this->failed('数据不存在');
  227. $product = StoreOrderModel::get($id);
  228. if (!$product) return Json::fail('数据不存在!');
  229. $f = [];
  230. $f[] = Form::input('order_id', '订单编号', $product->getData('order_id'))->disabled(1);
  231. $f[] = Form::number('total_price', '商品总价', $product->getData('total_price'))->min(0);
  232. $f[] = Form::number('total_postage', '原始邮费', $product->getData('total_postage'))->min(0);
  233. $f[] = Form::number('pay_price', '实际支付金额', $product->getData('pay_price'))->min(0);
  234. $f[] = Form::number('pay_postage', '实际支付邮费', $product->getData('pay_postage'));
  235. $f[] = Form::number('gain_integral', '赠送积分', $product->getData('gain_integral'));
  236. // $f[] = Form::radio('status','状态',$product->getData('status'))->options([['label'=>'开启','value'=>1],['label'=>'关闭','value'=>0]]);
  237. $form = Form::make_post_form('修改订单', $f, Url::buildUrl('update', array('id' => $id)));
  238. $this->assign(compact('form'));
  239. return $this->fetch('public/form-builder');
  240. }
  241. /**
  242. * 修改订单提交更新
  243. * @param $id
  244. */
  245. public function update($id)
  246. {
  247. $data = Util::postMore([
  248. 'order_id',
  249. 'total_price',
  250. 'total_postage',
  251. 'pay_price',
  252. 'pay_postage',
  253. 'gain_integral',
  254. ]);
  255. if ($data['total_price'] <= 0) return Json::fail('请输入商品总价');
  256. if ($data['pay_price'] <= 0) return Json::fail('请输入实际支付金额');
  257. $source_info = StoreOrderModel::where('order_id', $data['order_id'])->find();
  258. $data['order_id'] = StoreOrderModel::changeOrderId($data['order_id']);
  259. StoreOrderModel::edit($data, $id);
  260. //改价短信提醒
  261. if ($data['pay_price'] != $source_info['pay_price']) {
  262. $switch = sys_config('price_revision_switch') ? true : false;
  263. ShortLetterRepositories::send($switch, $source_info['user_phone'], ['order_id' => $source_info, 'pay_price' => $source_info['pay_price']], 'PRICE_REVISION_CODE');
  264. }
  265. event('StoreProductOrderEditAfter', [$data, $id]);
  266. StoreOrderStatus::setStatus($id, 'order_edit', '修改商品总价为:' . $data['total_price'] . ' 实际支付金额' . $data['pay_price']);
  267. return Json::successful('修改成功!');
  268. }
  269. /*
  270. * 发送货
  271. * @param int $id
  272. * @return html
  273. * */
  274. public function order_goods($id = 0)
  275. {
  276. $list = Express::where('is_show', 1)->order('sort desc')->column('name', 'id');
  277. $this->assign([
  278. 'list' => $list,
  279. 'id' => $id
  280. ]);
  281. return $this->fetch();
  282. }
  283. /*
  284. * 删除订单
  285. * */
  286. public function del_order()
  287. {
  288. $ids = Util::postMore(['ids'])['ids'];
  289. if (!count($ids)) return Json::fail('请选择需要删除的订单');
  290. if (StoreOrderModel::where('is_del', 0)->where('id', 'in', $ids)->count())
  291. return Json::fail('您选择的的订单存在用户未删除的订单,无法删除用户未删除的订单');
  292. $res = StoreOrderModel::where('id', 'in', $ids)->update(['is_system_del' => 1]);
  293. if ($res)
  294. return Json::successful('删除成功');
  295. else
  296. return Json::fail('删除失败');
  297. }
  298. /**
  299. * TODO 送货信息提交
  300. * @param Request $request
  301. * @param $id
  302. */
  303. public function update_delivery($id = 0)
  304. {
  305. $data = Util::postMore([
  306. ['type', 1],
  307. ['delivery_name', ''],
  308. ['delivery_id', ''],
  309. ['sh_delivery_name', ''],
  310. ['sh_delivery_id', ''],
  311. ], $this->request);
  312. switch ((int)$data['type']) {
  313. case 1:
  314. //发货
  315. $data['delivery_type'] = 'express';
  316. if (!$data['delivery_name']) return Json::fail('请选择快递公司');
  317. if (!$data['delivery_id']) return Json::fail('请输入快递单号');
  318. $data['status'] = 1;
  319. StoreOrderModel::edit($data, $id);
  320. event('StoreProductOrderDeliveryGoodsAfter', [$data, $id]);
  321. StoreOrderStatus::setStatus($id, 'delivery_goods', '已发货 快递公司:' . $data['delivery_name'] . ' 快递单号:' . $data['delivery_id']);
  322. break;
  323. case 2:
  324. //送货
  325. $data['delivery_type'] = 'send';
  326. $data['delivery_name'] = $data['sh_delivery_name'];
  327. $data['delivery_id'] = $data['sh_delivery_id'];
  328. unset($data['sh_delivery_name'], $data['sh_delivery_id']);
  329. if (!$data['delivery_name']) return Json::fail('请输入送货人姓名');
  330. if (!(int)$data['delivery_id']) return Json::fail('请输入送货人电话号码');
  331. else if (!preg_match("/^1[3456789]{1}\d{9}$/", $data['delivery_id'])) return Json::fail('请输入正确的送货人电话号码');
  332. $data['status'] = 1;
  333. StoreOrderModel::edit($data, $id);
  334. event('StoreProductOrderDeliveryAfter', [$data, $id]);
  335. StoreOrderStatus::setStatus($id, 'delivery', '已配送 发货人:' . $data['delivery_name'] . ' 发货人电话:' . $data['delivery_id']);
  336. break;
  337. case 3:
  338. //虚拟发货
  339. $data['delivery_type'] = 'fictitious';
  340. $data['status'] = 1;
  341. StoreOrderModel::edit($data, $id);
  342. event('StoreProductOrderDeliveryAfter', [$data, $id]);
  343. StoreOrderStatus::setStatus($id, 'delivery_fictitious', '已虚拟发货');
  344. break;
  345. default:
  346. return Json::fail('暂时不支持其他发货类型');
  347. break;
  348. }
  349. //短信发送
  350. event('ShortMssageSend', [StoreOrderModel::where('id', $id)->value('order_id'), 'Deliver']);
  351. return Json::successful('修改成功!');
  352. }
  353. /**
  354. * TODO 填写送货信息
  355. * @param $id
  356. * @return mixed|void
  357. * @throws \think\exception\DbException
  358. */
  359. public function delivery($id)
  360. {
  361. if (!$id) return $this->failed('数据不存在');
  362. $product = StoreOrderModel::get($id);
  363. if (!$product) return Json::fail('数据不存在!');
  364. if ($product['paid'] == 1 && $product['status'] == 0) {
  365. $f = [];
  366. $f[] = Form::input('delivery_name', '送货人姓名')->required('送货人姓名不能为空', 'required:true;');
  367. $f[] = Form::input('delivery_id', '送货人电话')->required('请输入正确电话号码', 'telephone');
  368. $form = Form::make_post_form('修改订单', $f, Url::buildUrl('updateDelivery', array('id' => $id)), 7);
  369. $this->assign(compact('form'));
  370. return $this->fetch('public/form-builder');
  371. } else $this->failedNotice('订单状态错误');
  372. }
  373. /**
  374. * TODO 送货信息提交
  375. * @param $id
  376. */
  377. public function updateDelivery($id)
  378. {
  379. $data = Util::postMore([
  380. 'delivery_name',
  381. 'delivery_id',
  382. ]);
  383. $data['delivery_type'] = 'send';
  384. if (!$data['delivery_name']) return Json::fail('请输入送货人姓名');
  385. if (!(int)$data['delivery_id']) return Json::fail('请输入送货人电话号码');
  386. else if (!preg_match("/^1[3456789]{1}\d{9}$/", $data['delivery_id'])) return Json::fail('请输入正确的送货人电话号码');
  387. $data['status'] = 1;
  388. StoreOrderModel::edit($data, $id);
  389. event('StoreProductOrderDeliveryAfter', [$data, $id]);
  390. StoreOrderStatus::setStatus($id, 'delivery', '已配送 发货人:' . $data['delivery_name'] . ' 发货人电话:' . $data['delivery_id']);
  391. return Json::successful('修改成功!');
  392. }
  393. /**
  394. * TODO 填写发货信息
  395. * @param $id
  396. * @return mixed|void
  397. * @throws \think\exception\DbException
  398. */
  399. public function deliver_goods($id)
  400. {
  401. if (!$id) return $this->failed('数据不存在');
  402. $product = StoreOrderModel::get($id);
  403. if (!$product) return Json::fail('数据不存在!');
  404. if ($product['paid'] == 1 && $product['status'] == 0) {
  405. $f = [];
  406. $f[] = Form::select('delivery_name', '快递公司')->setOptions(function () {
  407. $list = Express::where('is_show', 1)->order('sort DESC')->column('name', 'id');
  408. $menus = [];
  409. foreach ($list as $k => $v) {
  410. $menus[] = ['value' => $v, 'label' => $v];
  411. }
  412. return $menus;
  413. })->filterable(1);
  414. $f[] = Form::input('delivery_id', '快递单号');
  415. $form = Form::make_post_form('修改订单', $f, Url::buildUrl('updateDeliveryGoods', array('id' => $id)), 7);
  416. $this->assign(compact('form'));
  417. return $this->fetch('public/form-builder');
  418. } else return $this->failedNotice('订单状态错误');
  419. }
  420. /**
  421. * TODO 发货信息提交
  422. * @param $id
  423. */
  424. public function updateDeliveryGoods($id)
  425. {
  426. $data = Util::postMore([
  427. 'delivery_name',
  428. 'delivery_id',
  429. ]);
  430. $data['delivery_type'] = 'express';
  431. if (!$data['delivery_name']) return Json::fail('请选择快递公司');
  432. if (!$data['delivery_id']) return Json::fail('请输入快递单号');
  433. $data['status'] = 1;
  434. StoreOrderModel::edit($data, $id);
  435. event('StoreProductOrderDeliveryGoodsAfter', [$data, $id]);
  436. StoreOrderStatus::setStatus($id, 'delivery_goods', '已发货 快递公司:' . $data['delivery_name'] . ' 快递单号:' . $data['delivery_id']);
  437. return Json::successful('修改成功!');
  438. }
  439. /**
  440. * 修改状态为已收货
  441. * @param $id
  442. * @return \think\response\Json|void
  443. */
  444. public function take_delivery($id)
  445. {
  446. if (!$id) return $this->failed('数据不存在');
  447. $order = StoreOrderModel::get($id);
  448. if (!$order) return Json::fail('数据不存在!');
  449. if ($order['status'] == 2) return Json::fail('不能重复收货!');
  450. if ($order['paid'] == 1 && $order['status'] == 1) $data['status'] = 2;
  451. else if ($order['pay_type'] == 'offline') $data['status'] = 2;
  452. else return Json::fail('请先发货或者送货!');
  453. StoreOrderModel::beginTrans();
  454. try {
  455. if (!StoreOrderModel::edit($data, $id)) {
  456. StoreOrderModel::rollbackTrans();
  457. return Json::fail(StoreOrderModel::getErrorInfo('收货失败,请稍候再试!'));
  458. } else {
  459. OrderRepository::storeProductOrderTakeDeliveryAdmin($order, $id);
  460. StoreOrderStatus::setStatus($id, 'take_delivery', '已收货');
  461. StoreOrderModel::commitTrans();
  462. //发送短信
  463. event('ShortMssageSend', [$order['order_id'], 'Receiving']);
  464. return Json::successful('收货成功!');
  465. }
  466. } catch (\Exception $e) {
  467. StoreOrderModel::rollbackTrans();
  468. return Json::fail($e->getMessage());
  469. }
  470. }
  471. /**
  472. * 修改退款状态
  473. * @param $id
  474. * @return \think\response\Json|void
  475. */
  476. public function refund_y($id)
  477. {
  478. if (!$id) return $this->failed('数据不存在');
  479. $product = StoreOrderModel::get($id);
  480. if (!$product) return Json::fail('数据不存在!');
  481. if ($product['paid'] == 1) {
  482. $f = [];
  483. $f[] = Form::input('order_id', '退款单号', $product->getData('order_id'))->disabled(1);
  484. $f[] = Form::number('refund_price', '退款金额', $product->getData('pay_price'))->precision(2)->min(0.01);
  485. $f[] = Form::radio('type', '状态', 1)->options([['label' => '直接退款', 'value' => 1], ['label' => '退款后,返回原状态', 'value' => 2]]);
  486. $form = Form::make_post_form('退款处理', $f, Url::buildUrl('updateRefundY', array('id' => $id)), 7);
  487. $this->assign(compact('form'));
  488. return $this->fetch('public/form-builder');
  489. } else return Json::fail('数据不存在!');
  490. }
  491. /**
  492. * 退款处理
  493. * @param $id
  494. */
  495. public function updateRefundY($id)
  496. {
  497. $data = Util::postMore([
  498. 'refund_price',
  499. ['type', 1],
  500. ]);
  501. if (!$id) return $this->failed('数据不存在');
  502. $product = StoreOrderModel::get($id);
  503. if (!$product) return Json::fail('数据不存在!');
  504. if ($product['pay_price'] == $product['refund_price']) return Json::fail('已退完支付金额!不能再退款了');
  505. if (!$data['refund_price']) return Json::fail('请输入退款金额');
  506. $refund_price = $data['refund_price'];
  507. $data['refund_price'] = bcadd($data['refund_price'], $product['refund_price'], 2);
  508. $bj = bccomp((float)$product['pay_price'], (float)$data['refund_price'], 2);
  509. if ($bj < 0) return Json::fail('退款金额大于支付金额,请修改退款金额');
  510. if ($data['type'] == 1) {
  511. $data['refund_status'] = 2;
  512. } else if ($data['type'] == 2) {
  513. $data['refund_status'] = 0;
  514. }
  515. $type = $data['type'];
  516. unset($data['type']);
  517. $refund_data['pay_price'] = $product['pay_price'];
  518. $refund_data['refund_price'] = $refund_price;
  519. if ($product['pay_type'] == 'weixin') {
  520. if ($product['is_channel'] == 1) {//小程序
  521. try {
  522. MiniProgramService::payOrderRefund($product['order_id'], $refund_data);//2.5.36
  523. } catch (\Exception $e) {
  524. return Json::fail($e->getMessage());
  525. }
  526. } else {//TODO 公众号
  527. try {
  528. WechatService::payOrderRefund($product['order_id'], $refund_data);
  529. } catch (\Exception $e) {
  530. return Json::fail($e->getMessage());
  531. }
  532. }
  533. } else if ($product['pay_type'] == 'yue') {
  534. BaseModel::beginTrans();
  535. $usermoney = User::where('uid', $product['uid'])->value('now_money');
  536. $res1 = User::bcInc($product['uid'], 'now_money', $refund_price, 'uid');
  537. $res2 = $res2 = UserBill::income('商品退款', $product['uid'], 'now_money', 'pay_product_refund', $refund_price, $product['id'], bcadd($usermoney, $refund_price, 2), '订单退款到余额' . floatval($refund_price) . '元');
  538. try {
  539. OrderRepository::storeOrderYueRefund($product, $refund_data);
  540. } catch (\Exception $e) {
  541. BaseModel::rollbackTrans();
  542. return Json::fail($e->getMessage());
  543. }
  544. $res = $res1 && $res2;
  545. BaseModel::checkTrans($res);
  546. if (!$res) return Json::fail('余额退款失败!');
  547. }else if ($product['pay_type'] == 'integral') {
  548. BaseModel::beginTrans();
  549. $usermoney = User::where('uid', $product['uid'])->value('integral');
  550. $res1 = User::bcInc($product['uid'], 'integral', $refund_price, 'uid');
  551. $res2 = $res2 = UserBill::income('商品退款', $product['uid'], 'integral', 'integral_pay_product_refund', $refund_price, $product['id'], bcadd($usermoney, $refund_price, 2), '订单退款到积分' . floatval($refund_price) . '分');
  552. try {
  553. OrderRepository::storeOrderYueRefund($product, $refund_data);
  554. } catch (\Exception $e) {
  555. BaseModel::rollbackTrans();
  556. return Json::fail($e->getMessage());
  557. }
  558. $res = $res1 && $res2;
  559. BaseModel::checkTrans($res);
  560. if (!$res) return Json::fail('余额退款失败!');
  561. }
  562. $resEdit = StoreOrderModel::edit($data, $id);
  563. $res = true;
  564. if ($resEdit) {
  565. $data['type'] = $type;
  566. if ($data['type'] == 1) $res = StorePink::setRefundPink($id);
  567. if (!$res) return Json::fail('修改失败');
  568. try {
  569. OrderRepository::storeProductOrderRefundY($data, $id);
  570. } catch (\Exception $e) {
  571. BaseModel::rollbackTrans();
  572. return Json::fail($e->getMessage());
  573. }
  574. StoreOrderStatus::setStatus($id, 'refund_price', '退款给用户' . $refund_price . '元');
  575. //退佣金
  576. $brokerage_list = UserBill::where('category', 'now_money')
  577. ->where('type', 'brokerage')
  578. ->where('link_id', $id)
  579. ->where('pm', 1)
  580. ->select()->toArray();
  581. if ($brokerage_list)
  582. foreach ($brokerage_list as $item) {
  583. $usermoney = User::where('uid', $item['uid'])->value('brokerage_price');
  584. if ($item['number'] > $usermoney)
  585. $item['number'] = $usermoney;
  586. User::bcDec($item['uid'], 'brokerage_price', $item['number'], 'uid');
  587. UserBill::expend('退款退佣金', $item['uid'], 'now_money', 'brokerage', $item['number'], $id, bcsub($usermoney, $item['number'], 2), '订单退款扣除佣金' . floatval($item['number']) . '元');
  588. }
  589. BaseModel::commitTrans();
  590. return Json::successful('修改成功!');
  591. } else {
  592. StoreOrderStatus::setStatus($id, 'refund_price', '退款给用户' . $refund_price . '元失败');
  593. return Json::fail('修改失败!');
  594. }
  595. }
  596. /**
  597. * 退款处理
  598. * @param $id
  599. */
  600. public static function updateRefundY2($id, $refund_price, $type = 1)
  601. {
  602. $data = [
  603. 'refund_price' => $refund_price,
  604. 'type' => $type,
  605. ];
  606. if (!$id) return Json::fail('数据不存在');
  607. $product = StoreOrderModel::get($id);
  608. if (!$product) return Json::fail('数据不存在!');
  609. if ($product['pay_price'] == $product['refund_price']) return Json::fail('已退完支付金额!不能再退款了');
  610. if (!$data['refund_price']) return Json::fail('请输入退款金额');
  611. $refund_price = $data['refund_price'];
  612. $data['refund_price'] = bcadd($data['refund_price'], $product['refund_price'], 2);
  613. $bj = bccomp((float)$product['pay_price'], (float)$data['refund_price'], 2);
  614. if ($bj < 0) return Json::fail('退款金额大于支付金额,请修改退款金额');
  615. if ($data['type'] == 1) {
  616. $data['refund_status'] = 2;
  617. } else if ($data['type'] == 2) {
  618. $data['refund_status'] = 0;
  619. }
  620. $type = $data['type'];
  621. unset($data['type']);
  622. $refund_data['pay_price'] = $product['pay_price'];
  623. $refund_data['refund_price'] = $refund_price;
  624. if ($product['pay_type'] == 'weixin') {
  625. //('msg.txt','微信退款');
  626. if ($product['is_channel'] == 1) {//小程序
  627. try {
  628. MiniProgramService::payOrderRefund($product['order_id'], $refund_data);//2.5.36
  629. } catch (\Exception $e) {
  630. Log::write($e->getMessage(),'error');
  631. return Json::fail($e->getMessage());
  632. }
  633. } else {//TODO 公众号
  634. try {
  635. WechatService::payOrderRefund($product['order_id'], $refund_data);
  636. } catch (\Exception $e) {
  637. Log::write($e->getMessage(),'error');
  638. return Json::fail($e->getMessage());
  639. }
  640. }
  641. } else if ($product['pay_type'] == 'yue') {
  642. BaseModel::beginTrans();
  643. $usermoney = User::where('uid', $product['uid'])->value('now_money');
  644. $res1 = User::bcInc($product['uid'], 'now_money', $refund_price, 'uid');
  645. $res2 = $res2 = UserBill::income('商品退款', $product['uid'], 'now_money', 'pay_product_refund', $refund_price, $product['id'], bcadd($usermoney, $refund_price, 2), '订单退款到余额' . floatval($refund_price) . '元');
  646. try {
  647. OrderRepository::storeOrderYueRefund($product, $refund_data);
  648. } catch (\Exception $e) {
  649. BaseModel::rollbackTrans();
  650. return Json::fail($e->getMessage());
  651. }
  652. $res = $res1 && $res2;
  653. BaseModel::checkTrans($res);
  654. if (!$res) return Json::fail('余额退款失败!');
  655. }
  656. $resEdit = StoreOrderModel::edit($data, $id);
  657. $res = true;
  658. if ($resEdit) {
  659. Log::write('微信退款2','error');
  660. $data['type'] = $type;
  661. if ($data['type'] == 1) $res = StorePink::setRefundPink($id);
  662. if (!$res) return Json::fail('修改失败');
  663. try {
  664. OrderRepository::storeProductOrderRefundY($data, $id);
  665. } catch (\Exception $e) {
  666. BaseModel::rollbackTrans();
  667. return Json::fail($e->getMessage());
  668. }
  669. StoreOrderStatus::setStatus($id, 'refund_price', '退款给用户' . $refund_price . '元');
  670. //退佣金
  671. $brokerage_list = UserBill::where('category', 'now_money')
  672. ->where('type', 'brokerage')
  673. ->where('link_id', $id)
  674. ->where('pm', 1)
  675. ->select()->toArray();
  676. if ($brokerage_list)
  677. foreach ($brokerage_list as $item) {
  678. $usermoney = User::where('uid', $item['uid'])->value('brokerage_price');
  679. if ($item['number'] > $usermoney)
  680. $item['number'] = $usermoney;
  681. User::bcDec($item['uid'], 'brokerage_price', $item['number'], 'uid');
  682. UserBill::expend('退款退佣金', $item['uid'], 'now_money', 'brokerage', $item['number'], $id, bcsub($usermoney, $item['number'], 2), '订单退款扣除佣金' . floatval($item['number']) . '元');
  683. }
  684. BaseModel::commitTrans();
  685. return Json::successful('修改成功!');
  686. } else {
  687. StoreOrderStatus::setStatus($id, 'refund_price', '退款给用户' . $refund_price . '元失败');
  688. return Json::fail('修改失败!');
  689. }
  690. }
  691. public function order_info($oid = '')
  692. {
  693. if (!$oid || !($orderInfo = StoreOrderModel::get($oid)))
  694. return $this->failed('订单不存在!');
  695. $userInfo = User::getUserInfos($orderInfo['uid']);
  696. if ($userInfo['spread_uid']) {
  697. $spread = User::where('uid', $userInfo['spread_uid'])->value('nickname');
  698. } else {
  699. $spread = '';
  700. }
  701. $this->assign(compact('orderInfo', 'userInfo', 'spread'));
  702. return $this->fetch();
  703. }
  704. public function express($oid = '')
  705. {
  706. if (!$oid || !($order = StoreOrderModel::get($oid)))
  707. return $this->failed('订单不存在!');
  708. if ($order['delivery_type'] != 'express' || !$order['delivery_id']) return $this->failed('该订单不存在快递单号!');
  709. $cacheName = $order['order_id'] . $order['delivery_id'];
  710. $result = CacheService::get($cacheName, null);
  711. if ($result === null) {
  712. $result = ExpressService::query($order['delivery_id']);
  713. if (is_array($result) &&
  714. isset($result['result']) &&
  715. isset($result['result']['deliverystatus']) &&
  716. $result['result']['deliverystatus'] >= 3)
  717. $cacheTime = 0;
  718. else
  719. $cacheTime = 1800;
  720. CacheService::set($cacheName, $result, $cacheTime);
  721. }
  722. $this->assign([
  723. 'order' => $order,
  724. 'express' => $result
  725. ]);
  726. return $this->fetch();
  727. }
  728. /**
  729. * 修改配送信息
  730. * @param $id
  731. * @return mixed|\think\response\Json|void
  732. */
  733. public function distribution($id)
  734. {
  735. if (!$id) return $this->failed('数据不存在');
  736. $product = StoreOrderModel::get($id);
  737. if (!$product) return Json::fail('数据不存在!');
  738. $f = [];
  739. $f[] = Form::input('order_id', '退款单号', $product->getData('order_id'))->disabled(1);
  740. if ($product['delivery_type'] == 'send') {
  741. $f[] = Form::input('delivery_name', '送货人姓名', $product->getData('delivery_name'));
  742. $f[] = Form::input('delivery_id', '送货人电话', $product->getData('delivery_id'));
  743. } else if ($product['delivery_type'] == 'express') {
  744. $f[] = Form::select('delivery_name', '快递公司', $product->getData('delivery_name'))->setOptions(function () {
  745. $list = Express::where('is_show', 1)->column('name', 'id');
  746. $menus = [];
  747. foreach ($list as $k => $v) {
  748. $menus[] = ['value' => $v, 'label' => $v];
  749. }
  750. return $menus;
  751. });
  752. $f[] = Form::input('delivery_id', '快递单号', $product->getData('delivery_id'));
  753. }
  754. $form = Form::make_post_form('配送信息', $f, Url::buildUrl('updateDistribution', array('id' => $id)), 7);
  755. $this->assign(compact('form'));
  756. return $this->fetch('public/form-builder');
  757. }
  758. /**
  759. * 修改配送信息
  760. * @param $id
  761. */
  762. public function updateDistribution($id)
  763. {
  764. $data = Util::postMore([
  765. 'delivery_name',
  766. 'delivery_id',
  767. ]);
  768. if (!$id) return $this->failed('数据不存在');
  769. $product = StoreOrderModel::get($id);
  770. if (!$product) return Json::fail('数据不存在!');
  771. if ($product['delivery_type'] == 'send') {
  772. if (!$data['delivery_name']) return Json::fail('请输入送货人姓名');
  773. if (!(int)$data['delivery_id']) return Json::fail('请输入送货人电话号码');
  774. else if (!preg_match("/^1[3456789]{1}\d{9}$/", $data['delivery_id'])) return Json::fail('请输入正确的送货人电话号码');
  775. } else if ($product['delivery_type'] == 'express') {
  776. if (!$data['delivery_name']) return Json::fail('请选择快递公司');
  777. if (!$data['delivery_id']) return Json::fail('请输入快递单号');
  778. }
  779. StoreOrderModel::edit($data, $id);
  780. event('StoreProductOrderDistributionAfter', [$data, $id]);
  781. StoreOrderStatus::setStatus($id, 'distribution', '修改发货信息为' . $data['delivery_name'] . '号' . $data['delivery_id']);
  782. return Json::successful('修改成功!');
  783. }
  784. /**
  785. * 修改退款状态
  786. * @param $id
  787. * @return mixed|\think\response\Json|void
  788. */
  789. public function refund_n($id)
  790. {
  791. if (!$id) return $this->failed('数据不存在');
  792. $product = StoreOrderModel::get($id);
  793. if (!$product) return Json::fail('数据不存在!');
  794. $f[] = Form::input('order_id', '退款单号', $product->getData('order_id'))->disabled(1);
  795. $f[] = Form::input('refund_reason', '退款原因')->type('textarea');
  796. $form = Form::make_post_form('退款', $f, Url::buildUrl('updateRefundN', array('id' => $id)));
  797. $this->assign(compact('form'));
  798. return $this->fetch('public/form-builder');
  799. }
  800. /**
  801. * 不退款原因
  802. * @param $id
  803. */
  804. public function updateRefundN($id)
  805. {
  806. $data = Util::postMore([
  807. 'refund_reason',
  808. ]);
  809. if (!$id) return $this->failed('数据不存在');
  810. $product = StoreOrderModel::get($id);
  811. if (!$product) return Json::fail('数据不存在!');
  812. if (!$data['refund_reason']) return Json::fail('请输入退款原因');
  813. $data['refund_status'] = 0;
  814. StoreOrderModel::edit($data, $id);
  815. event('StoreProductOrderRefundNAfter', [$data['refund_reason'], $id]);
  816. StoreOrderStatus::setStatus($id, 'refund_n', '不退款原因:' . $data['refund_reason']);
  817. return Json::successful('修改成功!');
  818. }
  819. /**
  820. * 立即支付
  821. * @param $id
  822. */
  823. public function offline($id)
  824. {
  825. $res = StoreOrderModel::updateOffline($id);
  826. if ($res) {
  827. event('StoreProductOrderOffline', [$id]);
  828. StoreOrderStatus::setStatus($id, 'offline', '线下付款');
  829. return Json::successful('修改成功!');
  830. } else {
  831. return Json::fail(StoreOrderModel::getErrorInfo('修改失败!'));
  832. }
  833. }
  834. /**
  835. * 修改积分和金额
  836. * @param $id
  837. * @return mixed|\think\response\Json|void
  838. */
  839. public function integral_back($id)
  840. {
  841. if (!$id) return $this->failed('数据不存在');
  842. $product = StoreOrderModel::get($id);
  843. if (!$product) return Json::fail('数据不存在!');
  844. if ($product['paid'] == 1) {
  845. $f[] = Form::input('order_id', '退款单号', $product->getData('order_id'))->disabled(1);
  846. $f[] = Form::number('use_integral', '使用的积分', $product->getData('use_integral'))->min(0)->disabled(1);
  847. $f[] = Form::number('use_integrals', '已退积分', $product->getData('back_integral'))->min(0)->disabled(1);
  848. $f[] = Form::number('back_integral', '可退积分', bcsub($product->getData('use_integral'), $product->getData('use_integral')))->min(0);
  849. $form = Form::make_post_form('退积分', $f, Url::buildUrl('updateIntegralBack', array('id' => $id)), 7);
  850. $this->assign(compact('form'));
  851. return $this->fetch('public/form-builder');
  852. } else {
  853. return Json::fail('参数错误!');
  854. }
  855. return $this->fetch('public/form-builder');
  856. }
  857. /**
  858. * 退积分保存
  859. * @param $id
  860. */
  861. public function updateIntegralBack($id)
  862. {
  863. $data = Util::postMore([
  864. 'back_integral',
  865. ]);
  866. if (!$id) return $this->failed('数据不存在');
  867. $product = StoreOrderModel::get($id);
  868. if (!$product) return Json::fail('数据不存在!');
  869. if ($data['back_integral'] <= 0) return Json::fail('请输入积分');
  870. if ($product['use_integral'] == $product['back_integral']) return Json::fail('已退完积分!不能再积分了');
  871. $back_integral = $data['back_integral'];
  872. $data['back_integral'] = bcadd($data['back_integral'], $product['back_integral'], 2);
  873. $bj = bccomp((float)$product['use_integral'], (float)$data['back_integral'], 2);
  874. if ($bj < 0) return Json::fail('退积分大于支付积分,请修改退积分');
  875. BaseModel::beginTrans();
  876. $integral = User::where('uid', $product['uid'])->value('integral');
  877. $res1 = User::bcInc($product['uid'], 'integral', $back_integral, 'uid');
  878. $res2 = UserBill::income('商品退积分', $product['uid'], 'integral', 'pay_product_integral_back', $back_integral, $product['id'], bcadd($integral, $back_integral, 2), '订单退积分' . floatval($back_integral) . '积分到用户积分');
  879. event('StoreOrderIntegralBack', [$product, $back_integral]);
  880. try {
  881. OrderRepository::storeOrderIntegralBack($product, $back_integral);
  882. } catch (\Exception $e) {
  883. BaseModel::rollbackTrans();
  884. return Json::fail($e->getMessage());
  885. }
  886. $res = $res1 && $res2;
  887. BaseModel::checkTrans($res);
  888. if (!$res) return Json::fail('退积分失败!');
  889. if ($product['pay_price'] == 0 && $bj == 0) {
  890. $data['refund_status'] = 2;
  891. }
  892. StoreOrderModel::edit($data, $id);
  893. StoreOrderStatus::setStatus($id, 'integral_back', '商品退积分:' . $data['back_integral']);
  894. return Json::successful('退积分成功!');
  895. }
  896. public function remark()
  897. {
  898. $data = Util::postMore(['id', 'remark']);
  899. if (!$data['id']) return Json::fail('参数错误!');
  900. if ($data['remark'] == '') return Json::fail('请输入要备注的内容!');
  901. $id = $data['id'];
  902. unset($data['id']);
  903. StoreOrderModel::edit($data, $id);
  904. return Json::successful('备注成功!');
  905. }
  906. public function order_status($oid)
  907. {
  908. if (!$oid) return $this->failed('数据不存在');
  909. $this->assign(StoreOrderStatus::systemPage($oid));
  910. return $this->fetch();
  911. }
  912. /*
  913. * 订单列表推荐人详细
  914. */
  915. public function order_spread_user($uid)
  916. {
  917. $spread = User::where('uid', $uid)->find();
  918. $this->assign('spread', $spread);
  919. return $this->fetch();
  920. }
  921. /**
  922. * 立即核销
  923. * @param $id
  924. */
  925. public function verify($id)
  926. {
  927. StoreOrderModel::beginTrans();
  928. $orderInfo = StoreOrderModel::where('id', $id)->find();
  929. if (!$orderInfo) return Json::fail('核销订单不存在!');
  930. if ($orderInfo->status > 0) return Json::fail('订单已核销!');
  931. if ($orderInfo->combination_id && $orderInfo->pink_id) {
  932. $res = StorePink::where('id', $orderInfo->pink_id)->where('status', '<>', 2)->count();
  933. if ($res) return Json::fail('拼团订单暂未成功无法核销!');
  934. }
  935. $orderInfo->status = 2;
  936. if ($orderInfo->save()) {
  937. OrderRepository::storeProductOrderTakeDeliveryAdmin($orderInfo);
  938. StoreOrderStatus::setStatus($orderInfo->id, 'take_delivery', '已核销');
  939. //发送短信
  940. event('ShortMssageSend', [$orderInfo['order_id'], 'Receiving']);
  941. StoreOrderModel::commitTrans();
  942. return Json::successful('核销成功!');
  943. } else {
  944. StoreOrderModel::rollbackTrans();
  945. return Json::fail('核销失败');
  946. }
  947. }
  948. /**
  949. * 订单导入
  950. * @return \think\response\View|void
  951. * @throws \PHPExcel_Exception
  952. * @throws \PHPExcel_Reader_Exception
  953. */
  954. public function order_import()
  955. {
  956. $files = $this->request->file();
  957. if (!$files) {
  958. return Json::fail('请选择文件上传');
  959. }
  960. try {
  961. validate(['file' => [
  962. 'fileSize' => 1024 * 1024 * 30,
  963. 'fileExt' => 'xlsx'
  964. ]])->check($files);
  965. } catch (ValidateException $e) {
  966. return Json::fail('上传失败:文件类型或大小不对');
  967. }
  968. $savename = Filesystem::putFile('temp', $files['orderImportTable']);
  969. if (!$savename) {
  970. return Json::fail('文件保存失败');
  971. }
  972. $fullPath = App::getRootPath() . "/public/uploads/" . $savename;
  973. $obj_PHPExcel = \PHPExcel_IOFactory::load($fullPath); //加载文件内容
  974. $excel_array = $obj_PHPExcel->getsheet(0)->toArray(); //转换为数组格式
  975. $obj_PHPExcel->disconnectWorksheets(); //关闭表格
  976. array_shift($excel_array); //删除第一个数组(标题);
  977. array_shift($excel_array); //删除第二个数组(字段名);
  978. $data = [];
  979. $fail = 0; //失败条数
  980. $suc = 0; //成功条数
  981. foreach ($excel_array as $key => $item) { //逐个发货
  982. if ($item[0] == NULL || $item[1] == NULL || $item[2] == NULL || $item[3] == NULL) { //内容为空,该条失败
  983. $fail++;
  984. continue;
  985. }
  986. $id = trim($item[0]);
  987. $delivery_name = trim($item[2]);
  988. $delivery_id = trim($item[3]);
  989. if (preg_match('/^\d{1,}$/', $id) == 0) {//id不是数字,该条失败
  990. $fail++;
  991. continue;
  992. }
  993. if (!$delivery_name || !$delivery_id) { //内容为空,该条失败
  994. $fail++;
  995. continue;
  996. }
  997. $res = StoreOrderModel::orderPostageExpress($id, $delivery_name, $delivery_id); //发货
  998. if ($res)
  999. $suc++;
  1000. else
  1001. $fail++;
  1002. }
  1003. unlink($fullPath); //导入后,删除模板文件
  1004. $this->assign('msg', "数据导入成功,成功{$suc}条,失败{$fail}条");
  1005. return view();
  1006. }
  1007. }