ShopController.php 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: leo
  5. * Date: 2018/2/24
  6. * Time: 下午12:48
  7. */
  8. namespace backendApi\modules\v1\controllers;
  9. use backendApi\modules\v1\models\AdminCountry;
  10. use backendApi\modules\v1\models\AdminRole;
  11. use backendApi\modules\v1\models\exportForms\BaShopExportForm;
  12. use backendApi\modules\v1\models\exportForms\ShopExportForm;
  13. use backendApi\modules\v1\models\lists\shop\DecOrderList;
  14. use backendApi\modules\v1\models\lists\shop\GoodsList;
  15. use backendApi\modules\v1\models\lists\shop\OrderDecList;
  16. use backendApi\modules\v1\models\lists\shop\OrderList;
  17. use backendApi\modules\v1\models\lists\shop\BaOrderList;
  18. use backendApi\modules\v1\models\lists\shop\OrderPeriodAdjustList;
  19. use backendApi\modules\v1\models\lists\shop\OrderShopList;
  20. use backendApi\modules\v1\models\lists\shop\OrderStandardList;
  21. use backendApi\modules\v1\models\lists\shop\PackageList;
  22. use backendApi\modules\v1\models\lists\shop\RemainPvList;
  23. use backendApi\modules\v1\models\lists\shop\FlowRemainPvList;
  24. use common\helpers\Cache;
  25. use common\helpers\Date;
  26. use common\helpers\Form;
  27. use common\helpers\LoggerTool;
  28. use common\models\Countries;
  29. use common\models\Currency;
  30. use common\models\CurrencyConversions;
  31. use common\models\DeclarationPackage;
  32. use common\models\DecOrder;
  33. use common\models\FlowWallet;
  34. use common\models\forms\DecPackageForm;
  35. use common\models\forms\ExcelOrderDecForm;
  36. use common\models\forms\ExcelOrderShopForm;
  37. use common\models\forms\ExcelOrderStandardForm;
  38. use common\models\forms\OrderDeleteForm;
  39. use common\models\forms\OrderForm;
  40. use common\models\forms\OrderPeriodAdjustForm;
  41. use common\models\forms\ShopGoodsForm;
  42. use common\models\forms\UploadForm;
  43. use common\models\Order;
  44. use common\models\OrderPeriodAdjust;
  45. use common\models\Period;
  46. use common\models\ShopGoods;
  47. use common\models\ShopGoodsNature;
  48. use common\models\User;
  49. use common\models\UserInfo;
  50. use Yii;
  51. use yii\web\HttpException;
  52. use yii\web\UploadedFile;
  53. use yii\base\Exception;
  54. class ShopController extends BaseController {
  55. public $modelClass = DecOrder::class;
  56. public function behaviors() {
  57. $behaviors = parent::behaviors();
  58. //$behaviors['contentNegotiator']['formats']['text/html'] = Response::FORMAT_JSON;
  59. return $behaviors;
  60. }
  61. /**
  62. * 商品列表
  63. * @return mixed
  64. * @throws Exception
  65. * @throws HttpException
  66. */
  67. public function actionIndex() {
  68. $filter = $this->filterCondition([
  69. 'TYPE'=> 'TYPE',
  70. 'GIFT_TYPE'=> 'GIFT_TYPE',
  71. 'STATUS'=> 'STATUS',
  72. 'GOODS_NAME'=> 'GOODS_NAME',
  73. 'GOODS_NO'=> 'GOODS_NO',
  74. 'SELL_TYPE'=> 'SELL_TYPE',
  75. 'PRICE_PV'=> 'PRICE_PV',
  76. 'CATEGORY_TYPE' => 'CATEGORY_TYPE',
  77. 'AUTO_MAINTENANCE' => 'AUTO_MAINTENANCE',
  78. ]);
  79. $condition = $filter['condition'];
  80. $params = $filter['params'];
  81. $condition .= ' ';
  82. $listObj = new GoodsList();
  83. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  84. return static::notice($data);
  85. }
  86. /**
  87. * 商品属性
  88. * @return mixed
  89. * @throws Exception
  90. * @throws HttpException
  91. */
  92. public function actionGoodsNature() {
  93. $data = ShopGoodsNature::findAllAsArray('GOODS_ID=:GOODS_ID', [':GOODS_ID' => \Yii::$app->request->get('GOOD_ID')]);
  94. return static::notice($data);
  95. }
  96. /**
  97. * 商品列表导出
  98. * @return mixed
  99. * @throws \yii\db\Exception
  100. * @throws HttpException
  101. */
  102. public function actionGoodsListExport()
  103. {
  104. $filter = $this->filterCondition([
  105. 'TYPE'=> 'TYPE',
  106. 'GIFT_TYPE'=> 'GIFT_TYPE',
  107. 'STATUS'=> 'STATUS',
  108. 'GOODS_NAME'=> 'GOODS_NAME',
  109. 'GOODS_NO'=> 'GOODS_NO',
  110. 'SELL_TYPE'=> 'SELL_TYPE',
  111. 'PRICE_PV'=> 'PRICE_PV',
  112. 'CATEGORY_TYPE' => 'CATEGORY_TYPE',
  113. 'AUTO_MAINTENANCE' => 'AUTO_MAINTENANCE',
  114. ]);
  115. $form = new ShopExportForm();
  116. $result = $form->run($filter, \Yii::t('ctx', 'shopExportListName')); // 商品列表
  117. if (!$result) {
  118. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  119. }
  120. return static::notice(\Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  121. }
  122. /**
  123. * 添加商品
  124. * @return mixed
  125. * @throws Exception
  126. * @throws HttpException
  127. */
  128. public function actionGoodsAdd() {
  129. if (\Yii::$app->request->isPost) {
  130. $formModel = new ShopGoodsForm();
  131. $formModel->scenario = 'add';
  132. if ($formModel->load(\Yii::$app->request->post(), '') && $result = $formModel->add()) {
  133. return static::notice(\Yii::t('ctx', 'shopProductAddSucceededNotice'));
  134. } else {
  135. return static::notice(Form::formatErrorsForApi($formModel->getErrors()),400);
  136. }
  137. }
  138. $countries = Cache::getCountries();
  139. $isSuper = AdminRole::isSuperAdmin(\Yii::$app->getUser()->getUserInfo()['roleId']);
  140. if (!$isSuper) {
  141. $adminId = Yii::$app->getUser()->getUserInfo()['id'];
  142. $adminCountry = AdminCountry::getCountry($adminId);
  143. $countries = array_filter($countries, fn($country) => in_array($country['ID'], $adminCountry));
  144. $countries = array_values($countries);
  145. }
  146. // 货币
  147. $currencies = Cache::getCurrencies();
  148. $currencies = array_column($currencies, NULL, 'ID');
  149. // 货币汇率
  150. $currenciesConversions = CurrencyConversions::getFromCache();
  151. $currenciesConversions = array_column($currenciesConversions, NULL, 'TO_CURRENCY_ID');
  152. foreach ($countries as $key => $country) {
  153. $countries[$key]['LOCAL_CURRENCY_NAME'] = $currencies[$country['LOCAL_CURRENCY_ID']]['NAME'] ?? '';
  154. $countries[$key]['CURRENCY_PRODUCT_RATE'] = $currenciesConversions[$country['LOCAL_CURRENCY_ID']]['PRODUCT_RATE'] ?? 0;
  155. }
  156. return static::notice([
  157. 'sellType' => ShopGoods::getSaleType(),
  158. 'goodsType' => ShopGoods::getGoodType(),
  159. 'giftType' => ShopGoods::getGiftType(),
  160. 'categoryType' => ShopGoods::getCategoryType(),
  161. 'countries' => $countries,
  162. ]);
  163. }
  164. /**
  165. * 编辑商品
  166. * @return mixed
  167. * @throws Exception
  168. * @throws HttpException
  169. */
  170. public function actionGoodsEdit() {
  171. $id = \Yii::$app->request->get('id');
  172. if (\Yii::$app->request->isPost) {
  173. $formModel = new ShopGoodsForm();
  174. $formModel->scenario = 'edit';
  175. $formModel->id = $id;
  176. if ($formModel->load(\Yii::$app->request->post(), '') && $result = $formModel->edit()) {
  177. return static::notice(\Yii::t('ctx', 'shopProductEditSucceed'));
  178. } else {
  179. return static::notice(Form::formatErrorsForApi($formModel->getErrors()),400);
  180. }
  181. }
  182. $data = ShopGoods::findOneAsArray('ID=:ID', [':ID' => $id]);
  183. $data['SELL_TYPE'] = explode(',',$data['SELL_TYPE']);
  184. $data['GIFT_TYPE'] = explode(',',$data['GIFT_TYPE']);
  185. if ($data['TYPE'] == 1 || $data['TYPE'] == 2) {
  186. $data['SELL_DISCOUNT'] = ShopGoods::getGoodType()[$data['TYPE']]['discount']/100;
  187. }
  188. // 国家
  189. $countries = Cache::getCountries();
  190. // 货币
  191. $currencies = Cache::getCurrencies();
  192. $currencies = array_column($currencies, NULL, 'ID');
  193. // 货币汇率
  194. $currenciesConversions = CurrencyConversions::getFromCache();
  195. $currenciesConversions = array_column($currenciesConversions, NULL, 'TO_CURRENCY_ID');
  196. $isSuper = AdminRole::isSuperAdmin(\Yii::$app->getUser()->getUserInfo()['roleId']);
  197. if (!$isSuper) {
  198. $adminId = Yii::$app->getUser()->getUserInfo()['id'];
  199. $adminCountry = AdminCountry::getCountry($adminId);
  200. $countries = array_filter($countries, fn($country) => in_array($country['ID'], $adminCountry));
  201. $countries = array_values($countries);
  202. }
  203. foreach ($countries as $key => $country) {
  204. // 货币
  205. $countries[$key]['LOCAL_CURRENCY_NAME'] = $currencies[$country['LOCAL_CURRENCY_ID']]['NAME'] ?? '';
  206. $countries[$key]['CURRENCY_PRODUCT_RATE'] = $currenciesConversions[$country['LOCAL_CURRENCY_ID']]['PRODUCT_RATE'] ?? 0;
  207. // 商品属性
  208. $countries[$key]['SHOP_GOODS_NATURE'] = ShopGoodsNature::findAllAsArray('GOODS_ID=:GOODS_ID AND COUNTRY_ID=:COUNTRY_ID', [':GOODS_ID' => $id, ':COUNTRY_ID' => $country['ID']]);
  209. }
  210. $data['SHOP_GOODS_NATURE'] = array_values($countries);
  211. return static::notice(
  212. [
  213. 'goodsInfo'=>$data,
  214. 'sellType' => ShopGoods::getSaleType(),
  215. 'goodsType' => ShopGoods::getGoodType(),
  216. 'giftType' => ShopGoods::getGiftType(),//ShopGoods::GIFT_TYPE,
  217. 'categoryType' => ShopGoods::getCategoryType(),//ShopGoods::CATEGORY_TYPE,
  218. ]
  219. );
  220. }
  221. /**
  222. * 上传图片
  223. * @return mixed
  224. * @throws \yii\base\Exception
  225. * @throws \yii\db\Exception
  226. * @throws HttpException
  227. */
  228. public function actionUpload(){
  229. if(\Yii::$app->request->isPost){
  230. $formModel = new UploadForm();
  231. $formModel->scenario = 'goodsImg';
  232. $formModel->file = UploadedFile::getInstanceByName('file');
  233. $formModel->token = \Yii::$app->request->request('uploadToken');
  234. if($formModel->file && $uploader = $formModel->upload()){
  235. return static::notice($uploader->URL);
  236. } else {
  237. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  238. }
  239. } else {
  240. $token = Cache::setUploadToken();
  241. return static::notice($token);
  242. }
  243. }
  244. /**
  245. * 商品上下架
  246. * @return mixed
  247. * @throws Exception
  248. */
  249. public function actionGoodsStatus() {
  250. $id = \Yii::$app->request->get('id');
  251. if (\Yii::$app->request->isPost) {
  252. $formModel = new ShopGoodsForm();
  253. $formModel->scenario = 'changeStatus';
  254. if ($formModel->load(\Yii::$app->request->post(), '') && $result = $formModel->changeStatus()) {
  255. return static::notice(\Yii::t('ctx', 'shopStatusSetSucceedNotice')); // 状态设置成功
  256. } else {
  257. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  258. }
  259. }
  260. }
  261. /**
  262. * 删除商品
  263. * @return mixed
  264. * @throws \yii\db\Exception
  265. * @throws HttpException
  266. */
  267. public function actionGoodsDelete(){
  268. $result = static::delete(ShopGoods::class);
  269. return $result;
  270. }
  271. /**
  272. * 套餐列表
  273. * @return mixed
  274. * @throws Exception
  275. * @throws HttpException
  276. */
  277. public function actionPackage() {
  278. $filter = $this->filterCondition([
  279. 'LEVEL_NAME'=> 'DP.LEVEL_ID',
  280. 'PACKAGE_NAME'=> 'DP.PACKAGE_NAME',
  281. 'AMOUNT'=> 'DP.AMOUNT',
  282. 'PV'=> 'DP.PV',
  283. 'STATUS'=> 'DP.STATUS',
  284. 'STORE_NUMS'=>'DP.STORE_NUMS',
  285. ]);
  286. $condition = $filter['condition'];
  287. $params = $filter['params'];
  288. $condition .= ' AND DP.IS_DEL=0';
  289. $listObj = new PackageList();
  290. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  291. return static::notice($data);
  292. }
  293. /**
  294. * 添加报单套餐
  295. * @return mixed
  296. * @throws HttpException
  297. */
  298. public function actionPackageAdd() {
  299. if (\Yii::$app->request->isPost) {
  300. return static::edit(DecPackageForm::class, '报单套餐添加成功', 'add', null, null, function () {
  301. // Log::adminHandle('添加报单套餐', 1);
  302. });
  303. }
  304. return static::notice('非法请求', 405);
  305. }
  306. /**
  307. * 报单套餐获取
  308. * @return mixed
  309. * @throws HttpException
  310. */
  311. public function actionPackageGet() {
  312. $id = \Yii::$app->request->get('id');
  313. if (\Yii::$app->request->isPost) {
  314. return static::edit(DecPackageForm::class, '套餐编辑成功', 'edit', null, null, function () {
  315. // Log::adminHandle('编辑报单套餐', 1);
  316. });
  317. }
  318. $package = DeclarationPackage::findOneAsArray('ID=:ID', [':ID' => $id]);
  319. return static::notice(['id' => $package['ID'],'packageName' => $package['PACKAGE_NAME'],'packageNo' => $package['PACKAGE_NO'], 'amount' => $package['AMOUNT'], 'amountPv' => $package['PV'], 'levelId' => $package['LEVEL_ID'], 'packageContent' => $package['PACKAGE_CONTENT'],'amountStandard' => $package['AMOUNT_STANDARD'],'storenums' => $package['STORE_NUMS']]);
  320. }
  321. /**
  322. * 套餐上下架
  323. * @return mixed
  324. * @throws Exception
  325. */
  326. public function actionPackageStatus() {
  327. $id = \Yii::$app->request->get('id');
  328. if (\Yii::$app->request->isPost) {
  329. $formModel = new DecPackageForm();
  330. $formModel->scenario = 'changeStatus';
  331. if ($formModel->load(\Yii::$app->request->post(), '') && $result = $formModel->changeStatus()) {
  332. return static::notice('Status setting succeeded'); // 状态设置成功
  333. } else {
  334. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  335. }
  336. }
  337. }
  338. /**
  339. * 删除套餐
  340. * @return mixed
  341. * @throws \yii\db\Exception
  342. * @throws HttpException
  343. */
  344. public function actionPackageDelete(){
  345. $result = static::delete(DeclarationPackage::class);
  346. return $result;
  347. }
  348. /**
  349. * 报单表
  350. * @return mixed
  351. * @throws Exception
  352. * @throws HttpException
  353. */
  354. public function actionDecOrderList() {
  355. $filter = $this->filterCondition([
  356. 'DEC_SN'=> 'DO.DEC_SN',
  357. 'ORDER_SN'=> 'DO.ORDER_SN',
  358. 'USER_NAME'=> 'U.USER_NAME',
  359. 'TO_USER_NAME'=> 'TU.USER_NAME',
  360. 'REAL_NAME'=> 'TU.REAL_NAME',
  361. 'ID_CARD'=> 'TU.ID_CARD',
  362. 'MOBILE'=> 'TU.MOBILE',
  363. 'DEC_LV_NAME' => 'TU.DEC_LV',
  364. 'DEC_REAL_NAME'=> 'DU.REAL_NAME',
  365. 'DEC_AMOUNT'=> 'DO.DEC_AMOUNT',
  366. 'DEC_PV'=> 'DO.DEC_PV',
  367. 'PERIOD_NUM'=> 'DO.PERIOD_NUM',
  368. 'REC_USER_NAME'=> 'RU.USER_NAME',
  369. 'CREATED_AT'=> 'DO.CREATED_AT',
  370. 'UPDATED_AT'=> 'DO.UPDATED_AT',
  371. ]);
  372. $condition = $filter['condition'];
  373. $params = $filter['params'];
  374. $condition .= ' AND DO.IS_DEL=0';
  375. $listObj = new DecOrderList();
  376. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  377. return static::notice($data);
  378. }
  379. /**
  380. * 报单表导出
  381. * @return mixed
  382. * @throws \yii\db\Exception
  383. * @throws HttpException
  384. */
  385. public function actionDecOrderListExport()
  386. {
  387. $filter = $this->filterCondition([
  388. 'DEC_SN'=> 'DO.DEC_SN',
  389. 'ORDER_SN'=> 'DO.ORDER_SN',
  390. 'USER_NAME'=> 'U.USER_NAME',
  391. 'TO_USER_NAME'=> 'TU.USER_NAME',
  392. 'DEC_AMOUNT'=> 'DO.DEC_AMOUNT',
  393. 'DEC_PV'=> 'DO.DEC_PV',
  394. 'PERIOD_NUM'=> 'DO.PERIOD_NUM',
  395. 'CREATED_AT'=> 'DO.CREATED_AT',
  396. 'UPDATED_AT'=> 'DO.UPDATED_AT',
  397. ]);
  398. $filter['condition'] .= ' AND DO.IS_DEL=0';
  399. $form = new ShopExportForm();
  400. $result = $form->run($filter, \Yii::t('ctx', 'shopDecOrderListExport'));
  401. if (!$result) {
  402. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  403. }
  404. return static::notice(\Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  405. }
  406. // 删除订单
  407. public function actionDeleteOrder() {
  408. if (\Yii::$app->request->isPost) {
  409. $formModel = new OrderDeleteForm();
  410. if ($formModel->load(\Yii::$app->request->post(), '') && $result = $formModel->returnOrder()) {
  411. return static::notice(\Yii::t('ctx', 'shopDelOrderSuccedNotice'));
  412. } else {
  413. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  414. }
  415. }
  416. }
  417. /**
  418. * 订单表
  419. * @return mixed
  420. * @throws Exception
  421. * @throws HttpException
  422. */
  423. public function actionOrderList() {
  424. $filter = $this->filterCondition([
  425. 'SN'=> 'O.SN',
  426. 'USER_NAME'=> 'U.USER_NAME',
  427. 'MOBILE'=> 'O.MOBILE',
  428. 'PERIOD_NUM'=> 'O.PERIOD_NUM',
  429. 'CREATED_AT'=> 'O.CREATED_AT',
  430. 'ORDER_TYPE'=> 'O.ORDER_TYPE',
  431. 'STATUS' => 'O.STATUS',
  432. 'COUNTRY' => 'O.COUNTRY_ID',
  433. 'AUTO_MAINTENANCE' => 'O.AUTO_MAINTENANCE'
  434. ]);
  435. $condition = ' 1=1 ' . $filter['condition'];
  436. $isSuper = AdminRole::isSuperAdmin(\Yii::$app->getUser()->getUserInfo()['roleId']);
  437. if (!$isSuper) {
  438. $adminId = Yii::$app->getUser()->getUserInfo()['id'];
  439. $adminCountry = AdminCountry::getCountry($adminId);
  440. $quotedAdminCountry = array_map(function($item) {
  441. return "'" . addslashes($item) . "'";
  442. }, $adminCountry);
  443. $condition = ' 1=1 ' . $filter['condition'] . " AND O.COUNTRY_ID IN (" . implode(',', $quotedAdminCountry) . ")";
  444. }
  445. $params = $filter['params'];
  446. $condition .= $condition ? ' AND O.IS_DELETE=0' : ' O.IS_DELETE=0';
  447. $listObj = new OrderList();
  448. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  449. return static::notice($data);
  450. }
  451. /**
  452. * 订单表导出
  453. * @return mixed
  454. * @throws \yii\db\Exception
  455. * @throws HttpException
  456. */
  457. public function actionOrderListExport()
  458. {
  459. $filter = $this->filterCondition([
  460. 'SN'=> 'O.SN',
  461. 'USER_NAME'=> 'U.USER_NAME',
  462. 'MOBILE'=> 'O.MOBILE',
  463. 'PERIOD_NUM'=> 'O.PERIOD_NUM',
  464. 'CREATED_AT'=> 'O.CREATED_AT',
  465. 'ORDER_TYPE'=> 'O.ORDER_TYPE',
  466. 'STATUS' => 'O.STATUS',
  467. 'AUTO_MAINTENANCE' => 'O.AUTO_MAINTENANCE'
  468. ]);
  469. $isSuper = AdminRole::isSuperAdmin(\Yii::$app->getUser()->getUserInfo()['roleId']);
  470. if (!$isSuper) {
  471. $adminId = Yii::$app->getUser()->getUserInfo()['id'];
  472. $adminCountry = AdminCountry::getCountry($adminId);
  473. $quotedAdminCountry = array_map(function($item) {
  474. return "'" . addslashes($item) . "'";
  475. }, $adminCountry);
  476. $filter['condition'] = ('O.IS_DELETE=0 ' . $filter['condition']) . " AND O.COUNTRY_ID IN (" . implode(',', $quotedAdminCountry) . ")";
  477. } else {
  478. $filter['condition'] = ('O.IS_DELETE=0 ' . $filter['condition']);
  479. }
  480. $form = new ShopExportForm();
  481. $result = $form->run($filter, \Yii::t('ctx', 'shopOrderListExport')); // 订单列表
  482. if (!$result) {
  483. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  484. }
  485. return static::notice(\Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  486. }
  487. /**
  488. * 外部商城订单列表
  489. * @return mixed
  490. * @throws Exception
  491. * @throws HttpException
  492. */
  493. public function actionOrderShopList() {
  494. $filter = $this->filterCondition([
  495. 'SN'=> 'O.SN',
  496. 'USER_NAME'=> 'U.USER_NAME',
  497. 'PERIOD_NUM'=> 'O.PERIOD_NUM',
  498. 'CREATED_AT'=> 'O.CREATED_AT',
  499. ]);
  500. $condition = $filter['condition'];
  501. $params = $filter['params'];
  502. $condition .= ' AND O.IS_DELETE=0';
  503. $listObj = new OrderShopList();
  504. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  505. return static::notice($data);
  506. }
  507. /**
  508. * 外部商城报单列表
  509. * @return mixed
  510. * @throws Exception
  511. * @throws HttpException
  512. */
  513. public function actionOrderDecList() {
  514. $filter = $this->filterCondition([
  515. 'SN'=> 'O.SN',
  516. 'USER_NAME'=> 'U.USER_NAME',
  517. 'PERIOD_NUM'=> 'O.PERIOD_NUM',
  518. 'CREATED_AT'=> 'O.CREATED_AT',
  519. ]);
  520. $condition = $filter['condition'];
  521. $params = $filter['params'];
  522. $condition .= ' AND O.IS_DELETE=0';
  523. $listObj = new OrderDecList();
  524. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  525. return static::notice($data);
  526. }
  527. /**
  528. * 分页导入excel文件到待导入数据的表中
  529. * @return mixed
  530. */
  531. public function actionImportOrderShopToExcelTable()
  532. {
  533. // 先上传到服务器文件
  534. if (\Yii::$app->request->isPost) {
  535. $excelImportId = \Yii::$app->request->post('excelImportId');
  536. $rowCount = \Yii::$app->request->post('rowCount');
  537. //$periodNum = \Yii::$app->request->post('periodNum');
  538. $orderDay = \Yii::$app->request->post('orderDay');
  539. $orderType = \Yii::$app->request->post('orderType');
  540. $startRow = \Yii::$app->request->post('startRow');
  541. $limit = \Yii::$app->request->post('limit', 1000);
  542. $errorMsg = '';
  543. try {
  544. if( $startRow == 1 ) {
  545. $excelOrderShop = new ExcelOrderShopForm();
  546. $excelOrderShop->checkStatus($orderDay,$orderType);
  547. }
  548. $excel = new \common\helpers\Excel();
  549. $result = $excel->pageImportCustomDataFromExcel('orderShop', $excelImportId, $rowCount, $startRow, $limit,$orderDay,$orderType);
  550. } catch (\Exception $e) {
  551. $result = false;
  552. $errorMsg = $e->getMessage();
  553. }
  554. // 还有数据
  555. if ($result === 1) {
  556. return static::notice(['finish' => false]);
  557. } elseif ($result === 0) {
  558. return static::notice(['finish' => true]);
  559. } else {
  560. return static::notice('Error:' . $errorMsg, 400);
  561. }
  562. }
  563. }
  564. /**
  565. * 导入完成标记
  566. * @return mixed
  567. * @throws HttpException
  568. */
  569. public function actionImportOrderShop() {
  570. //$periodNum = \Yii::$app->request->post('periodNum');
  571. $orderDay = \Yii::$app->request->post('orderDay');
  572. $orderType = \Yii::$app->request->post('orderType');
  573. $excelOrderShop = new ExcelOrderShopForm();
  574. $finishStatus = $excelOrderShop->finished($orderDay,$orderType);
  575. if ($finishStatus) {
  576. return static::notice(['finish' => true]);
  577. } else {
  578. return static::notice(\Yii::t('ctx', 'shopStatusUpdateErrorNotice'), 400);
  579. }
  580. }
  581. /**
  582. * 报单订单——分页导入excel文件到待导入数据的表中
  583. * @return mixed
  584. */
  585. public function actionImportOrderDecToExcelTable()
  586. {
  587. // 先上传到服务器文件
  588. if (\Yii::$app->request->isPost) {
  589. $excelImportId = \Yii::$app->request->post('excelImportId');
  590. $rowCount = \Yii::$app->request->post('rowCount');
  591. //$periodNum = \Yii::$app->request->post('periodNum');
  592. $orderDay = \Yii::$app->request->post('orderDay');
  593. $startRow = \Yii::$app->request->post('startRow');
  594. $limit = \Yii::$app->request->post('limit', 1000);
  595. $errorMsg = '';
  596. try {
  597. if( $startRow == 1 ) {
  598. $excelOrderShop = new ExcelOrderDecForm();
  599. $excelOrderShop->checkStatus($orderDay);
  600. }
  601. $excel = new \common\helpers\Excel();
  602. $result = $excel->pageImportCustomDataFromExcel('orderDec', $excelImportId, $rowCount, $startRow, $limit,$orderDay);
  603. } catch (\Exception $e) {
  604. $result = false;
  605. $errorMsg = $e->getMessage();
  606. }
  607. // 还有数据
  608. if ($result === 1) {
  609. return static::notice(['finish' => false]);
  610. } elseif ($result === 0) {
  611. return static::notice(['finish' => true]);
  612. } else {
  613. return static::notice('Error:' . $errorMsg, 400);
  614. }
  615. }
  616. }
  617. /**
  618. * 报单订单导入完成标记
  619. * @return mixed
  620. * @throws HttpException
  621. */
  622. public function actionImportOrderDec() {
  623. //$periodNum = \Yii::$app->request->post('periodNum');
  624. $orderDay = \Yii::$app->request->post('orderDay');
  625. $excelOrderShop = new ExcelOrderDecForm();
  626. $finishStatus = $excelOrderShop->finished($orderDay);
  627. if ($finishStatus) {
  628. return static::notice(['finish' => true]);
  629. } else {
  630. return static::notice(\Yii::t('ctx', 'shopStatusUpdateErrorNotice'), 400);
  631. }
  632. }
  633. /**
  634. * 见习达标订单列表
  635. * @return mixed
  636. * @throws Exception
  637. * @throws HttpException
  638. */
  639. public function actionOrderStandardList() {
  640. $filter = $this->filterCondition([
  641. 'SN'=> 'O.SN',
  642. 'USER_NAME'=> 'U.USER_NAME',
  643. 'PERIOD_NUM'=> 'O.PERIOD_NUM',
  644. 'CREATED_AT'=> 'O.CREATED_AT',
  645. ]);
  646. $condition = $filter['condition'];
  647. $params = $filter['params'];
  648. $condition .= ' AND O.IS_DELETE=0';
  649. $listObj = new OrderStandardList();
  650. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  651. return static::notice($data);
  652. }
  653. /**
  654. * 分页导入excel文件到待导入数据的表中
  655. * @return mixed
  656. * @throws HttpException
  657. */
  658. public function actionImportOrderStandardToExcelTable()
  659. {
  660. // 先上传到服务器文件
  661. if (\Yii::$app->request->isPost) {
  662. $excelImportId = \Yii::$app->request->post('excelImportId');
  663. $rowCount = \Yii::$app->request->post('rowCount');
  664. //$periodNum = \Yii::$app->request->post('periodNum');
  665. $orderMonth = \Yii::$app->request->post('orderMonth');
  666. // $orderType = \Yii::$app->request->post('orderType');
  667. $orderType = 'cash';
  668. $startRow = \Yii::$app->request->post('startRow');
  669. $limit = \Yii::$app->request->post('limit', 1000);
  670. $errorMsg = '';
  671. try {
  672. if( $startRow == 1 ) {
  673. //清空已经导入的表数据
  674. $excelOrderStandard = new ExcelOrderStandardForm();
  675. $excelOrderStandard->checkStatus($orderMonth);
  676. }
  677. $excel = new \common\helpers\Excel();
  678. $result = $excel->pageImportCustomDataFromExcel('orderShopStandard', $excelImportId, $rowCount, $startRow, $limit,$orderMonth,$orderType);
  679. } catch (Exception $e) {
  680. $result = false;
  681. $errorMsg = $e->getMessage();
  682. }
  683. // 还有数据
  684. if ($result === 1) {
  685. return static::notice(['finish' => false]);
  686. } elseif ($result === 0) {
  687. return static::notice(['finish' => true]);
  688. } else {
  689. return static::notice('Error:' . $errorMsg, 400);
  690. }
  691. }
  692. }
  693. /**
  694. * 达标订单导入完成标记
  695. * @return mixed
  696. * @throws HttpException
  697. */
  698. public function actionImportOrderStandard() {
  699. $orderMonth = \Yii::$app->request->post('orderMonth');
  700. $excelOrderStandard = new ExcelOrderStandardForm();
  701. $finishStatus = $excelOrderStandard->finished($orderMonth);
  702. if ($finishStatus) {
  703. return static::notice(['finish' => true]);
  704. } else {
  705. return static::notice(\Yii::t('ctx', 'shopStatusUpdateErrorNotice'), 400);
  706. }
  707. }
  708. /**
  709. * 管理员发货
  710. * @return mixed
  711. * @throws HttpException
  712. */
  713. public function actionOrderDelivery() {
  714. if(\Yii::$app->request->isPost) {
  715. return parent::edit(OrderForm::class, '发货成功', 'adminDelivery', ['adminDelivery']);
  716. }
  717. return static::notice(\Yii::t('ctx', 'illegalRequest'), 400); // 非法请求
  718. }
  719. /**
  720. * 报单表导出
  721. * @return mixed
  722. * @throws \yii\db\Exception
  723. * @throws HttpException
  724. */
  725. public function actionOrderListExportPdf()
  726. {
  727. $orderSn = \Yii::$app->request->get('orderSn');
  728. $filter = $this->filterCondition([
  729. 'SN'=> 'O.SN',
  730. 'USER_NAME'=> 'U.USER_NAME',
  731. 'MOBILE'=> 'O.MOBILE',
  732. 'PERIOD_NUM'=> 'O.PERIOD_NUM',
  733. 'CREATED_AT'=> 'O.CREATED_AT',
  734. ]);
  735. $filter['condition'] = ' O.IS_DELETE=0 AND O.SN=:SN';
  736. $filter['params'] = [':SN' => $orderSn];
  737. $form = new ShopExportForm();
  738. $result = $form->run($filter, \Yii::t('ctx', 'shopOrderListExportPdf'));
  739. if (!$result) {
  740. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  741. }
  742. return static::notice(\Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  743. }
  744. /**
  745. * 报单表导出
  746. * @return mixed
  747. * @throws \yii\db\Exception
  748. * @throws HttpException
  749. */
  750. public function actionDecOrderListExportPdf()
  751. {
  752. $orderSn = \Yii::$app->request->get('orderSn');
  753. $filter = $this->filterCondition([
  754. 'SN'=> 'O.SN',
  755. 'USER_NAME'=> 'U.USER_NAME',
  756. 'MOBILE'=> 'O.MOBILE',
  757. 'PERIOD_NUM'=> 'O.PERIOD_NUM',
  758. 'CREATED_AT'=> 'O.CREATED_AT',
  759. ]);
  760. $filter['condition'] = ' 1=1 AND O.IS_DELETE=0 AND O.SN=:SN';
  761. $filter['params'] = [':SN' => $orderSn];
  762. $form = new ShopExportForm();
  763. $result = $form->run($filter, \Yii::t('ctx', 'shopOrderListExportPdf'));
  764. if (!$result) {
  765. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  766. }
  767. return static::notice(\Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  768. }
  769. /**
  770. * 管理员订单退款
  771. * @return mixed
  772. * @throws HttpException
  773. */
  774. public function actionOrderRefund()
  775. {
  776. if(\Yii::$app->request->isPost) {
  777. return parent::edit(OrderForm::class, \Yii::t('ctx', 'shopadminRefund'), 'adminRefund', ['adminRefund']);
  778. }
  779. return static::notice(\Yii::t('ctx', 'illegalRequest'), 400); // 非法请求
  780. }
  781. /*
  782. * 剩余BV页
  783. *
  784. */
  785. public function actionRemainPv()
  786. {
  787. $filter = $this->filterCondition([
  788. 'USER_NAME' => 'U.USER_NAME',
  789. ]);
  790. $condition = $filter['condition'];
  791. $params = $filter['params'];
  792. $listObj = new RemainPvList();
  793. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  794. return static::notice($data);
  795. }
  796. /*
  797. * 剩余BV流水
  798. *
  799. */
  800. public function actionFlowRemainPv()
  801. {
  802. $filter = $this->filterCondition([
  803. 'USER_NAME' => 'U.USER_NAME',
  804. ]);
  805. $condition = $filter['condition'];
  806. $params = $filter['params'];
  807. $listObj = new FlowRemainPvList();
  808. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  809. return static::notice($data);
  810. }
  811. /**
  812. * BA订单表
  813. * @return mixed
  814. * @throws Exception
  815. * @throws HttpException
  816. */
  817. public function actionBaOrderList() {
  818. $filter = $this->filterCondition([
  819. 'SN'=> 'O.SN',
  820. 'USER_NAME'=> 'U.USER_NAME',
  821. 'MOBILE'=> 'O.MOBILE',
  822. 'PERIOD_NUM'=> 'O.PERIOD_NUM',
  823. 'CREATED_AT'=> 'O.CREATED_AT',
  824. 'ORDER_TYPE'=> 'O.ORDER_TYPE',
  825. 'STATUS' => 'O.STATUS',
  826. ]);
  827. $condition = ' 1=1 ' . $filter['condition'];
  828. $params = $filter['params'];
  829. $condition .= $condition ? ' AND O.IS_DELETE=0' : ' O.IS_DELETE=0';
  830. $listObj = new BaOrderList();
  831. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  832. return static::notice($data);
  833. }
  834. /**
  835. * BA订单表导出
  836. * @return mixed
  837. * @throws \yii\db\Exception
  838. * @throws HttpException
  839. */
  840. public function actionBaOrderListExport()
  841. {
  842. $filter = $this->filterCondition([
  843. 'SN'=> 'O.SN',
  844. 'USER_NAME'=> 'U.USER_NAME',
  845. 'MOBILE'=> 'O.MOBILE',
  846. 'PERIOD_NUM'=> 'O.PERIOD_NUM',
  847. 'CREATED_AT'=> 'O.CREATED_AT',
  848. 'STATUS' => 'O.STATUS',
  849. ]);
  850. $filter['condition'] = !$filter['condition'] ? '1=1 AND O.IS_DELETE=0' : ('O.IS_DELETE=0 ' . $filter['condition']);
  851. $form = new BaShopExportForm();
  852. $result = $form->run($filter, \Yii::t('ctx', 'shopBaOrderListExport')); // 订单列表
  853. if (!$result) {
  854. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  855. }
  856. return static::notice(\Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  857. }
  858. /**
  859. * 报单表导出
  860. * @return mixed
  861. * @throws \yii\db\Exception
  862. * @throws HttpException
  863. */
  864. public function actionBaOrderListExportPdf()
  865. {
  866. $orderSn = \Yii::$app->request->get('orderSn');
  867. $filter = $this->filterCondition([
  868. 'SN'=> 'O.SN',
  869. 'USER_NAME'=> 'U.USER_NAME',
  870. 'MOBILE'=> 'O.MOBILE',
  871. 'PERIOD_NUM'=> 'O.PERIOD_NUM',
  872. 'CREATED_AT'=> 'O.CREATED_AT',
  873. ]);
  874. $filter['condition'] = ' O.IS_DELETE=0 AND O.SN=:SN';
  875. $filter['params'] = [':SN' => $orderSn];
  876. $form = new BaShopExportForm();
  877. $result = $form->run($filter, \Yii::t('ctx', 'shopBrandAmbassadorOrderExport'));
  878. if (!$result) {
  879. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  880. }
  881. return static::notice(\Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  882. }
  883. /**
  884. * 调整订单期数
  885. * @return mixed
  886. * @throws Exception
  887. * @throws \yii\db\Exception
  888. * @throws \yii\web\HttpException
  889. */
  890. public function actionOrderPeriodAdjust()
  891. {
  892. if (\Yii::$app->request->isPost) {
  893. $formModel = new OrderPeriodAdjustForm();
  894. $formModel->scenario = 'orderPeriodAdjust';
  895. if ($formModel->load(\Yii::$app->request->post(), '') && $formModel->periodAdjust()) {
  896. return static::notice(Yii::t('ctx', 'successfully'));
  897. } else {
  898. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  899. }
  900. } else {
  901. $filter = $this->filterCondition([
  902. 'ORDER_SN' => 'P.ORDER_SN',
  903. 'ORIGIN_PERIOD'=> 'P.ORIGIN_PERIOD',
  904. 'MODERN_PERIOD'=> 'P.MODERN_PERIOD',
  905. 'CREATED_AT'=> 'P.CREATED_AT',
  906. ]);
  907. $isSuper = AdminRole::isSuperAdmin(\Yii::$app->getUser()->getUserInfo()['roleId']);
  908. if (!$isSuper) {
  909. $adminId = Yii::$app->getUser()->getUserInfo()['id'];
  910. $adminCountry = AdminCountry::getCountry($adminId);
  911. $quotedAdminCountry = array_map(function($item) {
  912. return "'" . addslashes($item) . "'";
  913. }, $adminCountry);
  914. $filter['condition'] .= ' AND O.COUNTRY_ID IN (' . implode(',', $quotedAdminCountry) . ')';
  915. }
  916. $listObj = new OrderPeriodAdjustList();
  917. $data = $listObj->getList(['condition' => $filter['condition'], 'params' => $filter['params']]);
  918. return static::notice($data);
  919. }
  920. }
  921. /**
  922. * 订单详情
  923. * @return mixed
  924. * @throws \yii\web\HttpException
  925. */
  926. public function actionOrderDetail()
  927. {
  928. $orderSn = \Yii::$app->request->get('orderSn');
  929. $isSuper = AdminRole::isSuperAdmin(\Yii::$app->getUser()->getUserInfo()['roleId']);
  930. if (!$isSuper) {
  931. $adminId = Yii::$app->getUser()->getUserInfo()['id'];
  932. $adminCountry = AdminCountry::getCountry($adminId);
  933. $quotedAdminCountry = array_map(function ($item) {
  934. return "'" . addslashes($item) . "'";
  935. }, $adminCountry);
  936. $order = Order::findOneAsArray('SN=:SN AND COUNTRY_ID IN (' . implode(',', $quotedAdminCountry) . ')', [':SN' => $orderSn]);
  937. } else {
  938. $order = Order::findOneAsArray('SN=:SN', [':SN' => $orderSn]);
  939. }
  940. if (!$order) {
  941. return static::notice(Yii::t('ctx', 'orderNotExist'), 400);
  942. }
  943. $order['ORDER_TYPE'] = $order['ORDER_TYPE'] === 'ZC' ? Yii::t('ctx', 'shopOrderListOrderTypeZc') : Yii::t('ctx', 'shopOrderListOrderTypeFx');
  944. $order['COUNTRY'] = Countries::getById($order['COUNTRY_ID'])['NAME'] ?? '';
  945. // 已挂网,不可调整
  946. $period = Period::getInfoByPeriodNum($order['PERIOD_NUM']);
  947. if (!$period) {
  948. return static::notice(Yii::t('ctx', 'invalidPcNo'), 400);
  949. }
  950. if ($period['IS_SENT'] > 0) {
  951. return static::notice(Yii::t('ctx', 'orderHasBeenConnected'), 400);
  952. }
  953. // 可调整期数
  954. $availablePeriod = [];
  955. if ($order['PERIOD_NUM']) {
  956. $availablePeriod = Period::getPeriodList(+$order['PERIOD_NUM'] - 1);
  957. foreach ($availablePeriod as $k => $item) {
  958. $availablePeriod[$k]['disabled'] = (+$item['IS_SENT'] > 0) || ($order['PERIOD_NUM'] == $item['PERIOD_NUM']);
  959. }
  960. }
  961. return static::notice(['order' => $order, 'availablePeriod' => $availablePeriod]);
  962. }
  963. public function actionOrderPeriodAdjustBatch()
  964. {
  965. $db = \Yii::$app->db;
  966. $transaction = $db->beginTransaction();
  967. $orderList = [];
  968. $orderErr = [];
  969. try {
  970. $modernPeriod = 150; // todo: 修改后期数
  971. $oldPeriod = 151; // todo: 修改前期数
  972. foreach ($orderList as $orderSn) {
  973. $orderObj = Order::findOneAsArray('SN=:SN', [':SN' => $orderSn]);
  974. if (!$orderObj) {
  975. $orderErr[] = $orderSn;
  976. continue;
  977. }
  978. // 调整订单期数
  979. Order::updateAll(['PERIOD_NUM' => $modernPeriod], 'SN = :SN', [':SN' => $orderSn]);
  980. if ($orderObj['ORDER_TYPE'] === 'ZC') {
  981. // 调整报单期数
  982. DecOrder::updateAll(['PERIOD_NUM' => $modernPeriod], 'ORDER_SN = :ORDER_SN', ['ORDER_SN' => $orderSn]);
  983. // 调整会员的期数
  984. User::updateAll(['PERIOD_AT' => $modernPeriod], 'ID = :USER_ID', ['USER_ID' => $orderObj['USER_ID']]);
  985. UserInfo::updateAll(['HIGHEST_EMP_LV_PERIOD' => $modernPeriod], 'USER_ID = :USER_ID', ['USER_ID' => $orderObj['USER_ID']]);
  986. }
  987. // 调整流水的期数
  988. switch ($orderObj['PAY_TYPE']){
  989. case 'cash':
  990. FlowWallet::updateAll(['PERIOD_NUM' => $modernPeriod], 'ORDER_SN = :ORDER_SN', ['ORDER_SN' => $orderSn]);
  991. break;
  992. default:
  993. break;
  994. }
  995. // 写入调整记录
  996. $orderModel = new OrderPeriodAdjust();
  997. $orderModel->ORDER_SN = $orderSn;
  998. $orderModel->ORIGIN_PERIOD = $oldPeriod;
  999. $orderModel->MODERN_PERIOD = $modernPeriod;
  1000. $orderModel->ADMIN_ID = 'admin';
  1001. $orderModel->CREATED_AT = Date::nowTime();
  1002. if (!$orderModel->save()) {
  1003. return static::notice($orderModel->getErrors(), 400);
  1004. }
  1005. }
  1006. $transaction->commit();
  1007. } catch(\Exception $e) {
  1008. $transaction->rollBack();
  1009. return static::notice($e->getMessage(), 400);
  1010. }
  1011. return static::notice('成功. ' . json_encode($orderErr));
  1012. }
  1013. }