ShopController.php 22 KB

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