ShopController.php 24 KB

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