ShopController.php 23 KB

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