ShopController.php 22 KB

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