ShopController.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629
  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\exportForms\OrderExportForm;
  10. use backendApi\modules\v1\models\exportForms\ShopExportForm;
  11. use backendApi\modules\v1\models\lists\shop\DecOrderList;
  12. use backendApi\modules\v1\models\lists\shop\GoodsList;
  13. use backendApi\modules\v1\models\lists\shop\OrderDecList;
  14. use backendApi\modules\v1\models\lists\shop\OrderList;
  15. use backendApi\modules\v1\models\lists\shop\OrderShopList;
  16. use backendApi\modules\v1\models\lists\shop\OrderStandardList;
  17. use backendApi\modules\v1\models\lists\shop\PackageList;
  18. use common\helpers\Cache;
  19. use common\helpers\Date;
  20. use common\helpers\Form;
  21. use common\helpers\Log;
  22. use common\helpers\snowflake\SnowFake;
  23. use common\libs\export\module\ShopExport;
  24. use common\models\DeclarationPackage;
  25. use common\models\DecOrder;
  26. use common\models\ExcelOrderShop;
  27. use common\models\forms\DecPackageForm;
  28. use common\models\forms\ExcelOrderDecForm;
  29. use common\models\forms\ExcelOrderShopForm;
  30. use common\models\forms\ExcelOrderStandardForm;
  31. use common\models\forms\OrderForm;
  32. use common\models\forms\ShopGoodsForm;
  33. use common\models\forms\UploadForm;
  34. use common\models\ShopGoods;
  35. use yii\web\UploadedFile;
  36. use yii\base\Exception;
  37. class ShopController extends BaseController {
  38. public $modelClass = DecOrder::class;
  39. public function behaviors() {
  40. $behaviors = parent::behaviors();
  41. //$behaviors['contentNegotiator']['formats']['text/html'] = Response::FORMAT_JSON;
  42. return $behaviors;
  43. }
  44. /**
  45. * 商品列表
  46. * @return mixed
  47. * @throws Exception
  48. * @throws \yii\web\HttpException
  49. */
  50. public function actionIndex() {
  51. $filter = $this->filterCondition([
  52. 'TYPE'=> 'TYPE',
  53. 'STATUS'=> 'STATUS',
  54. 'GOODS_NAME'=> 'GOODS_NAME',
  55. 'GOODS_NO'=> 'GOODS_NO',
  56. 'SELL_TYPE'=> 'SELL_TYPE',
  57. 'SELL_PRICE'=> 'SELL_PRICE',
  58. 'PRICE_PV'=> 'PRICE_PV',
  59. ]);
  60. $condition = $filter['condition'];
  61. $params = $filter['params'];
  62. $condition .= ' ';
  63. $listObj = new GoodsList();
  64. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  65. return static::notice($data);
  66. }
  67. /**
  68. * 商品列表导出
  69. * @return mixed
  70. * @throws \yii\db\Exception
  71. * @throws \yii\web\HttpException
  72. */
  73. public function actionGoodsListExport()
  74. {
  75. $filter = $this->filterCondition([
  76. 'TYPE'=> 'TYPE',
  77. 'STATUS'=> 'STATUS',
  78. 'GOODS_NAME'=> 'GOODS_NAME',
  79. 'GOODS_NO'=> 'GOODS_NO',
  80. 'SELL_TYPE'=> 'SELL_TYPE',
  81. 'SELL_PRICE'=> 'SELL_PRICE',
  82. 'PRICE_PV'=> 'PRICE_PV',
  83. ]);
  84. $form = new ShopExportForm();
  85. $result = $form->run($filter, '商品列表');
  86. if (!$result) {
  87. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  88. }
  89. return static::notice('导出开始,请到文件管理-导出文件查看');
  90. }
  91. /**
  92. * 添加商品
  93. * @return mixed
  94. * @throws Exception
  95. * @throws \yii\web\HttpException
  96. */
  97. public function actionGoodsAdd() {
  98. if (\Yii::$app->request->isPost) {
  99. $formModel = new ShopGoodsForm();
  100. $formModel->scenario = 'add';
  101. if ($formModel->load(\Yii::$app->request->post(), '') && $result = $formModel->add()) {
  102. return static::notice('商品添加成功');
  103. } else {
  104. return static::notice(Form::formatErrorsForApi($formModel->getErrors()),400);
  105. }
  106. }
  107. return static::notice(['sellType' => ShopGoods::SALE_TYPE, 'goodsType' => ShopGoods::GOODS_TYPE]);
  108. }
  109. /**
  110. * 编辑商品
  111. * @return mixed
  112. * @throws Exception
  113. * @throws \yii\web\HttpException
  114. */
  115. public function actionGoodsEdit() {
  116. $id = \Yii::$app->request->get('id');
  117. if (\Yii::$app->request->isPost) {
  118. $formModel = new ShopGoodsForm();
  119. $formModel->scenario = 'edit';
  120. $formModel->id = $id;
  121. if ($formModel->load(\Yii::$app->request->post(), '') && $result = $formModel->edit()) {
  122. return static::notice('商品编辑成功');
  123. } else {
  124. return static::notice(Form::formatErrorsForApi($formModel->getErrors()),400);
  125. }
  126. }
  127. $data = ShopGoods::findOneAsArray('ID=:ID', [':ID' => $id]);
  128. $data['SELL_TYPE'] = explode(',',$data['SELL_TYPE']);
  129. return static::notice(['goodsInfo'=>$data,'sellType' => ShopGoods::SALE_TYPE, 'goodsType' => ShopGoods::GOODS_TYPE]);
  130. }
  131. /**
  132. * 上传图片
  133. * @return mixed
  134. * @throws \yii\base\Exception
  135. * @throws \yii\db\Exception
  136. * @throws \yii\web\HttpException
  137. */
  138. public function actionUpload(){
  139. if(\Yii::$app->request->isPost){
  140. $formModel = new UploadForm();
  141. $formModel->scenario = 'goodsImg';
  142. $formModel->file = UploadedFile::getInstanceByName('file');
  143. $formModel->token = \Yii::$app->request->request('uploadToken');
  144. if($formModel->file && $uploader = $formModel->upload()){
  145. return static::notice($uploader->URL);
  146. } else {
  147. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  148. }
  149. } else {
  150. $token = Cache::setUploadToken();
  151. return static::notice($token);
  152. }
  153. }
  154. /**
  155. * 商品上下架
  156. * @return mixed
  157. * @throws Exception
  158. */
  159. public function actionGoodsStatus() {
  160. $id = \Yii::$app->request->get('id');
  161. if (\Yii::$app->request->isPost) {
  162. $formModel = new ShopGoodsForm();
  163. $formModel->scenario = 'changeStatus';
  164. if ($formModel->load(\Yii::$app->request->post(), '') && $result = $formModel->changeStatus()) {
  165. // foreach ($result['logs'] as $k => $value) {
  166. // Log::adminHandle('改变商品状态至' . ShopGoods::STATUS_NAME[$result['status']], 1, $k);
  167. // }
  168. return static::notice('状态设置成功');
  169. } else {
  170. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  171. }
  172. }
  173. }
  174. /**
  175. * 删除商品
  176. * @return mixed
  177. * @throws \yii\db\Exception
  178. * @throws \yii\web\HttpException
  179. */
  180. public function actionGoodsDelete(){
  181. $result = static::delete(ShopGoods::class);
  182. return $result;
  183. }
  184. /**
  185. * 套餐列表
  186. * @return mixed
  187. * @throws Exception
  188. * @throws \yii\web\HttpException
  189. */
  190. public function actionPackage() {
  191. $filter = $this->filterCondition([
  192. 'LEVEL_NAME'=> 'DP.LEVEL_ID',
  193. 'PACKAGE_NAME'=> 'DP.PACKAGE_NAME',
  194. 'AMOUNT'=> 'DP.AMOUNT',
  195. 'PV'=> 'DP.PV',
  196. 'STATUS'=> 'DP.STATUS',
  197. ]);
  198. $condition = $filter['condition'];
  199. $params = $filter['params'];
  200. $condition .= ' AND DP.IS_DEL=0';
  201. $listObj = new PackageList();
  202. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  203. return static::notice($data);
  204. }
  205. /**
  206. * 添加报单套餐
  207. * @return mixed
  208. * @throws \yii\web\HttpException
  209. */
  210. public function actionPackageAdd() {
  211. if (\Yii::$app->request->isPost) {
  212. return static::edit(DecPackageForm::class, '报单套餐添加成功', 'add', null, null, function () {
  213. // Log::adminHandle('添加报单套餐', 1);
  214. });
  215. }
  216. return static::notice('非发请求', 405);
  217. }
  218. /**
  219. * 报单套餐获取
  220. * @return mixed
  221. * @throws \yii\web\HttpException
  222. */
  223. public function actionPackageGet() {
  224. $id = \Yii::$app->request->get('id');
  225. if (\Yii::$app->request->isPost) {
  226. return static::edit(DecPackageForm::class, '套餐编辑成功', 'edit', null, null, function () {
  227. // Log::adminHandle('编辑报单套餐', 1);
  228. });
  229. }
  230. $package = DeclarationPackage::findOneAsArray('ID=:ID', [':ID' => $id]);
  231. 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']]);
  232. }
  233. /**
  234. * 套餐上下架
  235. * @return mixed
  236. * @throws Exception
  237. */
  238. public function actionPackageStatus() {
  239. $id = \Yii::$app->request->get('id');
  240. if (\Yii::$app->request->isPost) {
  241. $formModel = new DecPackageForm();
  242. $formModel->scenario = 'changeStatus';
  243. if ($formModel->load(\Yii::$app->request->post(), '') && $result = $formModel->changeStatus()) {
  244. return static::notice('状态设置成功');
  245. } else {
  246. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  247. }
  248. }
  249. }
  250. /**
  251. * 删除套餐
  252. * @return mixed
  253. * @throws \yii\db\Exception
  254. * @throws \yii\web\HttpException
  255. */
  256. public function actionPackageDelete(){
  257. $result = static::delete(DeclarationPackage::class);
  258. return $result;
  259. }
  260. /**
  261. * 报单表
  262. * @return mixed
  263. * @throws Exception
  264. * @throws \yii\web\HttpException
  265. */
  266. public function actionDecOrderList() {
  267. $filter = $this->filterCondition([
  268. 'DEC_SN'=> 'DO.DEC_SN',
  269. 'ORDER_SN'=> 'DO.ORDER_SN',
  270. 'USER_NAME'=> 'U.USER_NAME',
  271. 'TO_USER_NAME'=> 'TU.USER_NAME',
  272. 'REAL_NAME'=> 'TU.REAL_NAME',
  273. 'ID_CARD'=> 'TU.ID_CARD',
  274. 'MOBILE'=> 'TU.MOBILE',
  275. 'DEC_LV_NAME' => 'TU.DEC_LV',
  276. 'DEC_REAL_NAME'=> 'DU.REAL_NAME',
  277. 'DEC_AMOUNT'=> 'DO.DEC_AMOUNT',
  278. 'DEC_PV'=> 'DO.DEC_PV',
  279. 'PERIOD_NUM'=> 'DO.PERIOD_NUM',
  280. 'REC_USER_NAME'=> 'RU.USER_NAME',
  281. 'CREATED_AT'=> 'DO.CREATED_AT',
  282. 'UPDATED_AT'=> 'DO.UPDATED_AT',
  283. ]);
  284. $condition = $filter['condition'];
  285. $params = $filter['params'];
  286. $condition .= ' AND DO.IS_DEL=0';
  287. $listObj = new DecOrderList();
  288. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  289. return static::notice($data);
  290. }
  291. /**
  292. * 报单表导出
  293. * @return mixed
  294. * @throws \yii\db\Exception
  295. * @throws \yii\web\HttpException
  296. */
  297. public function actionDecOrderListExport()
  298. {
  299. $filter = $this->filterCondition([
  300. 'DEC_SN'=> 'DO.DEC_SN',
  301. 'ORDER_SN'=> 'DO.ORDER_SN',
  302. 'USER_NAME'=> 'U.USER_NAME',
  303. 'TO_USER_NAME'=> 'TU.USER_NAME',
  304. 'DEC_AMOUNT'=> 'DO.DEC_AMOUNT',
  305. 'DEC_PV'=> 'DO.DEC_PV',
  306. 'PERIOD_NUM'=> 'DO.PERIOD_NUM',
  307. 'CREATED_AT'=> 'DO.CREATED_AT',
  308. 'UPDATED_AT'=> 'DO.UPDATED_AT',
  309. ]);
  310. $filter['condition'] .= ' AND DO.IS_DEL=0';
  311. $form = new ShopExportForm();
  312. $result = $form->run($filter, '报单列表');
  313. if (!$result) {
  314. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  315. }
  316. return static::notice('导出开始,请到文件管理-导出文件查看');
  317. }
  318. /**
  319. * 订单表
  320. * @return mixed
  321. * @throws Exception
  322. * @throws \yii\web\HttpException
  323. */
  324. public function actionOrderList() {
  325. $filter = $this->filterCondition([
  326. 'SN'=> 'O.SN',
  327. 'USER_NAME'=> 'U.USER_NAME',
  328. 'MOBILE'=> 'O.MOBILE',
  329. 'PERIOD_NUM'=> 'O.PERIOD_NUM',
  330. 'CREATED_AT'=> 'O.CREATED_AT',
  331. ]);
  332. $condition = $filter['condition'];
  333. $params = $filter['params'];
  334. $condition .= ' AND O.IS_DELETE=0';
  335. $listObj = new OrderList();
  336. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  337. return static::notice($data);
  338. }
  339. /**
  340. * 订单表导出
  341. * @return mixed
  342. * @throws \yii\db\Exception
  343. * @throws \yii\web\HttpException
  344. */
  345. public function actionOrderListExport()
  346. {
  347. $filter = $this->filterCondition([
  348. 'SN'=> 'O.SN',
  349. 'USER_NAME'=> 'U.USER_NAME',
  350. 'MOBILE'=> 'O.MOBILE',
  351. 'PERIOD_NUM'=> 'O.PERIOD_NUM',
  352. 'CREATED_AT'=> 'O.CREATED_AT',
  353. ]);
  354. $filter['condition'] .= ' AND O.IS_DELETE=0';
  355. $form = new ShopExportForm();
  356. $result = $form->run($filter, '订单列表');
  357. if (!$result) {
  358. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  359. }
  360. return static::notice('导出开始,请到文件管理-导出文件查看');
  361. }
  362. /**
  363. * 外部商城订单列表
  364. * @return mixed
  365. * @throws Exception
  366. * @throws \yii\web\HttpException
  367. */
  368. public function actionOrderShopList() {
  369. $filter = $this->filterCondition([
  370. 'SN'=> 'O.SN',
  371. 'USER_NAME'=> 'U.USER_NAME',
  372. 'PERIOD_NUM'=> 'O.PERIOD_NUM',
  373. 'CREATED_AT'=> 'O.CREATED_AT',
  374. ]);
  375. $condition = $filter['condition'];
  376. $params = $filter['params'];
  377. $condition .= ' AND O.IS_DELETE=0';
  378. $listObj = new OrderShopList();
  379. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  380. return static::notice($data);
  381. }
  382. /**
  383. * 外部商城报单列表
  384. * @return mixed
  385. * @throws Exception
  386. * @throws \yii\web\HttpException
  387. */
  388. public function actionOrderDecList() {
  389. $filter = $this->filterCondition([
  390. 'SN'=> 'O.SN',
  391. 'USER_NAME'=> 'U.USER_NAME',
  392. 'PERIOD_NUM'=> 'O.PERIOD_NUM',
  393. 'CREATED_AT'=> 'O.CREATED_AT',
  394. ]);
  395. $condition = $filter['condition'];
  396. $params = $filter['params'];
  397. $condition .= ' AND O.IS_DELETE=0';
  398. $listObj = new OrderDecList();
  399. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  400. return static::notice($data);
  401. }
  402. /**
  403. * 分页导入excel文件到待导入数据的表中
  404. * @return mixed
  405. */
  406. public function actionImportOrderShopToExcelTable()
  407. {
  408. // 先上传到服务器文件
  409. if (\Yii::$app->request->isPost) {
  410. $excelImportId = \Yii::$app->request->post('excelImportId');
  411. $rowCount = \Yii::$app->request->post('rowCount');
  412. //$periodNum = \Yii::$app->request->post('periodNum');
  413. $orderDay = \Yii::$app->request->post('orderDay');
  414. $orderType = \Yii::$app->request->post('orderType');
  415. $startRow = \Yii::$app->request->post('startRow');
  416. $limit = \Yii::$app->request->post('limit', 1000);
  417. $errorMsg = '';
  418. try {
  419. if( $startRow == 1 ) {
  420. $excelOrderShop = new ExcelOrderShopForm();
  421. $excelOrderShop->checkStatus($orderDay,$orderType);
  422. }
  423. $excel = new \common\helpers\Excel();
  424. $result = $excel->pageImportCustomDataFromExcel('orderShop', $excelImportId, $rowCount, $startRow, $limit,$orderDay,$orderType);
  425. } catch (\Exception $e) {
  426. $result = false;
  427. $errorMsg = $e->getMessage();
  428. }
  429. // 还有数据
  430. if ($result === 1) {
  431. return static::notice(['finish' => false]);
  432. } elseif ($result === 0) {
  433. return static::notice(['finish' => true]);
  434. } else {
  435. return static::notice('发生错误:' . $errorMsg, 400);
  436. }
  437. }
  438. }
  439. /**
  440. * 导入完成标记
  441. * @return mixed
  442. * @throws \yii\web\HttpException
  443. */
  444. public function actionImportOrderShop() {
  445. //$periodNum = \Yii::$app->request->post('periodNum');
  446. $orderDay = \Yii::$app->request->post('orderDay');
  447. $orderType = \Yii::$app->request->post('orderType');
  448. $excelOrderShop = new ExcelOrderShopForm();
  449. $finishStatus = $excelOrderShop->finished($orderDay,$orderType);
  450. if ($finishStatus) {
  451. return static::notice(['finish' => true]);
  452. } else {
  453. return static::notice('状态更新错误', 400);
  454. }
  455. }
  456. /**
  457. * 报单订单——分页导入excel文件到待导入数据的表中
  458. * @return mixed
  459. */
  460. public function actionImportOrderDecToExcelTable()
  461. {
  462. // 先上传到服务器文件
  463. if (\Yii::$app->request->isPost) {
  464. $excelImportId = \Yii::$app->request->post('excelImportId');
  465. $rowCount = \Yii::$app->request->post('rowCount');
  466. //$periodNum = \Yii::$app->request->post('periodNum');
  467. $orderDay = \Yii::$app->request->post('orderDay');
  468. $startRow = \Yii::$app->request->post('startRow');
  469. $limit = \Yii::$app->request->post('limit', 1000);
  470. $errorMsg = '';
  471. try {
  472. if( $startRow == 1 ) {
  473. $excelOrderShop = new ExcelOrderDecForm();
  474. $excelOrderShop->checkStatus($orderDay);
  475. }
  476. $excel = new \common\helpers\Excel();
  477. $result = $excel->pageImportCustomDataFromExcel('orderDec', $excelImportId, $rowCount, $startRow, $limit,$orderDay);
  478. } catch (\Exception $e) {
  479. $result = false;
  480. $errorMsg = $e->getMessage();
  481. }
  482. // 还有数据
  483. if ($result === 1) {
  484. return static::notice(['finish' => false]);
  485. } elseif ($result === 0) {
  486. return static::notice(['finish' => true]);
  487. } else {
  488. return static::notice('发生错误:' . $errorMsg, 400);
  489. }
  490. }
  491. }
  492. /**
  493. * 报单订单导入完成标记
  494. * @return mixed
  495. * @throws \yii\web\HttpException
  496. */
  497. public function actionImportOrderDec() {
  498. //$periodNum = \Yii::$app->request->post('periodNum');
  499. $orderDay = \Yii::$app->request->post('orderDay');
  500. $excelOrderShop = new ExcelOrderDecForm();
  501. $finishStatus = $excelOrderShop->finished($orderDay);
  502. if ($finishStatus) {
  503. return static::notice(['finish' => true]);
  504. } else {
  505. return static::notice('状态更新错误', 400);
  506. }
  507. }
  508. /**
  509. * 见习达标订单列表
  510. * @return mixed
  511. * @throws Exception
  512. * @throws \yii\web\HttpException
  513. */
  514. public function actionOrderStandardList() {
  515. $filter = $this->filterCondition([
  516. 'SN'=> 'O.SN',
  517. 'USER_NAME'=> 'U.USER_NAME',
  518. 'PERIOD_NUM'=> 'O.PERIOD_NUM',
  519. 'CREATED_AT'=> 'O.CREATED_AT',
  520. ]);
  521. $condition = $filter['condition'];
  522. $params = $filter['params'];
  523. $condition .= ' AND O.IS_DELETE=0';
  524. $listObj = new OrderStandardList();
  525. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  526. return static::notice($data);
  527. }
  528. /**
  529. * 分页导入excel文件到待导入数据的表中
  530. * @return mixed
  531. * @throws \yii\web\HttpException
  532. */
  533. public function actionImportOrderStandardToExcelTable()
  534. {
  535. // 先上传到服务器文件
  536. if (\Yii::$app->request->isPost) {
  537. $excelImportId = \Yii::$app->request->post('excelImportId');
  538. $rowCount = \Yii::$app->request->post('rowCount');
  539. //$periodNum = \Yii::$app->request->post('periodNum');
  540. $orderMonth = \Yii::$app->request->post('orderMonth');
  541. // $orderType = \Yii::$app->request->post('orderType');
  542. $orderType = 'cash';
  543. $startRow = \Yii::$app->request->post('startRow');
  544. $limit = \Yii::$app->request->post('limit', 1000);
  545. $errorMsg = '';
  546. try {
  547. if( $startRow == 1 ) {
  548. //清空已经导入的表数据
  549. $excelOrderStandard = new ExcelOrderStandardForm();
  550. $excelOrderStandard->checkStatus($orderMonth);
  551. }
  552. $excel = new \common\helpers\Excel();
  553. $result = $excel->pageImportCustomDataFromExcel('orderShopStandard', $excelImportId, $rowCount, $startRow, $limit,$orderMonth,$orderType);
  554. } catch (Exception $e) {
  555. $result = false;
  556. $errorMsg = $e->getMessage();
  557. }
  558. // 还有数据
  559. if ($result === 1) {
  560. return static::notice(['finish' => false]);
  561. } elseif ($result === 0) {
  562. return static::notice(['finish' => true]);
  563. } else {
  564. return static::notice('发生错误:' . $errorMsg, 400);
  565. }
  566. }
  567. }
  568. /**
  569. * 达标订单导入完成标记
  570. * @return mixed
  571. * @throws \yii\web\HttpException
  572. */
  573. public function actionImportOrderStandard() {
  574. $orderMonth = \Yii::$app->request->post('orderMonth');
  575. $excelOrderStandard = new ExcelOrderStandardForm();
  576. $finishStatus = $excelOrderStandard->finished($orderMonth);
  577. if ($finishStatus) {
  578. return static::notice(['finish' => true]);
  579. } else {
  580. return static::notice('状态更新错误', 400);
  581. }
  582. }
  583. /**
  584. * 管理员发货
  585. * @return mixed
  586. * @throws \yii\web\HttpException
  587. */
  588. public function actionOrderDelivery() {
  589. if(\Yii::$app->request->isPost) {
  590. return parent::edit(OrderForm::class, '发货成功', 'adminDelivery', ['adminDelivery']);
  591. }
  592. return static::notice('非法请求', 400);
  593. }
  594. }