filterCondition([ 'TYPE'=> 'TYPE', 'GIFT_TYPE'=> 'GIFT_TYPE', 'STATUS'=> 'STATUS', 'GOODS_NAME'=> 'GOODS_NAME', 'GOODS_NO'=> 'GOODS_NO', 'SELL_TYPE'=> 'SELL_TYPE', 'SELL_PRICE'=> 'SELL_PRICE', 'PRICE_PV'=> 'PRICE_PV', ]); $condition = $filter['condition']; $params = $filter['params']; $condition .= ' '; $listObj = new GoodsList(); $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]); return static::notice($data); } /** * 商品列表导出 * @return mixed * @throws \yii\db\Exception * @throws \yii\web\HttpException */ public function actionGoodsListExport() { $filter = $this->filterCondition([ 'TYPE'=> 'TYPE', 'GIFT_TYPE'=> 'GIFT_TYPE', 'STATUS'=> 'STATUS', 'GOODS_NAME'=> 'GOODS_NAME', 'GOODS_NO'=> 'GOODS_NO', 'SELL_TYPE'=> 'SELL_TYPE', 'SELL_PRICE'=> 'SELL_PRICE', 'PRICE_PV'=> 'PRICE_PV', ]); $form = new ShopExportForm(); $result = $form->run($filter, '商品列表'); if (!$result) { return static::notice(Form::formatErrorsForApi($form->getErrors()), 400); } return static::notice('导出开始,请到文件管理-导出文件查看'); } /** * 添加商品 * @return mixed * @throws Exception * @throws \yii\web\HttpException */ public function actionGoodsAdd() { if (\Yii::$app->request->isPost) { $formModel = new ShopGoodsForm(); $formModel->scenario = 'add'; if ($formModel->load(\Yii::$app->request->post(), '') && $result = $formModel->add()) { return static::notice('商品添加成功'); } else { return static::notice(Form::formatErrorsForApi($formModel->getErrors()),400); } } return static::notice(['sellType' => ShopGoods::SALE_TYPE, 'goodsType' => ShopGoods::GOODS_TYPE, 'giftType' => ShopGoods::GIFT_TYPE]); } /** * 编辑商品 * @return mixed * @throws Exception * @throws \yii\web\HttpException */ public function actionGoodsEdit() { $id = \Yii::$app->request->get('id'); if (\Yii::$app->request->isPost) { $formModel = new ShopGoodsForm(); $formModel->scenario = 'edit'; $formModel->id = $id; if ($formModel->load(\Yii::$app->request->post(), '') && $result = $formModel->edit()) { return static::notice('商品编辑成功'); } else { return static::notice(Form::formatErrorsForApi($formModel->getErrors()),400); } } $data = ShopGoods::findOneAsArray('ID=:ID', [':ID' => $id]); $data['SELL_TYPE'] = explode(',',$data['SELL_TYPE']); $data['GIFT_TYPE'] = explode(',',$data['GIFT_TYPE']); return static::notice(['goodsInfo'=>$data,'sellType' => ShopGoods::SALE_TYPE, 'goodsType' => ShopGoods::GOODS_TYPE, 'giftType' => ShopGoods::GIFT_TYPE]); } /** * 上传图片 * @return mixed * @throws \yii\base\Exception * @throws \yii\db\Exception * @throws \yii\web\HttpException */ public function actionUpload(){ if(\Yii::$app->request->isPost){ $formModel = new UploadForm(); $formModel->scenario = 'goodsImg'; $formModel->file = UploadedFile::getInstanceByName('file'); $formModel->token = \Yii::$app->request->request('uploadToken'); if($formModel->file && $uploader = $formModel->upload()){ return static::notice($uploader->URL); } else { return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400); } } else { $token = Cache::setUploadToken(); return static::notice($token); } } /** * 商品上下架 * @return mixed * @throws Exception */ public function actionGoodsStatus() { $id = \Yii::$app->request->get('id'); if (\Yii::$app->request->isPost) { $formModel = new ShopGoodsForm(); $formModel->scenario = 'changeStatus'; if ($formModel->load(\Yii::$app->request->post(), '') && $result = $formModel->changeStatus()) { // foreach ($result['logs'] as $k => $value) { // Log::adminHandle('改变商品状态至' . ShopGoods::STATUS_NAME[$result['status']], 1, $k); // } return static::notice('状态设置成功'); } else { return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400); } } } /** * 删除商品 * @return mixed * @throws \yii\db\Exception * @throws \yii\web\HttpException */ public function actionGoodsDelete(){ $result = static::delete(ShopGoods::class); return $result; } /** * 套餐列表 * @return mixed * @throws Exception * @throws \yii\web\HttpException */ public function actionPackage() { $filter = $this->filterCondition([ 'LEVEL_NAME'=> 'DP.LEVEL_ID', 'PACKAGE_NAME'=> 'DP.PACKAGE_NAME', 'AMOUNT'=> 'DP.AMOUNT', 'PV'=> 'DP.PV', 'STATUS'=> 'DP.STATUS', 'STORE_NUMS'=>'DP.STORE_NUMS', 'STATUS_DATE'=>'DP.STATUS_DATE', 'PACKAGE_DATE'=>'DP.PACKAGE_DATE', 'PACKAGE_STATUS_DATE'=>'DP.PACKAGE_STATUS_DATE' ]); $condition = $filter['condition']; $params = $filter['params']; $condition .= ' AND DP.IS_DEL=0'; $listObj = new PackageList(); $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]); return static::notice($data); } /** * 添加报单套餐 * @return mixed * @throws \yii\web\HttpException */ public function actionPackageAdd() { if (\Yii::$app->request->isPost) { return static::edit(DecPackageForm::class, '报单套餐添加成功', 'add', null, null, function () { // Log::adminHandle('添加报单套餐', 1); }); } return static::notice('非发请求', 405); } /** * 报单套餐获取 * @return mixed * @throws \yii\web\HttpException */ public function actionPackageGet() { $id = \Yii::$app->request->get('id'); if (\Yii::$app->request->isPost) { return static::edit(DecPackageForm::class, '套餐编辑成功', 'edit', null, null, function () { // Log::adminHandle('编辑报单套餐', 1); }); } $package = DeclarationPackage::findOneAsArray('ID=:ID', [':ID' => $id]); 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'],'sort'=>$package['SORT']]); } /** * 套餐上下架 * @return mixed * @throws Exception */ public function actionPackageStatus() { $id = \Yii::$app->request->get('id'); if (\Yii::$app->request->isPost) { $formModel = new DecPackageForm(); $formModel->scenario = 'changeStatus'; if ($formModel->load(\Yii::$app->request->post(), '') && $result = $formModel->changeStatus()) { return static::notice('状态设置成功'); } else { return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400); } } } /** * 删除套餐 * @return mixed * @throws \yii\db\Exception * @throws \yii\web\HttpException */ public function actionPackageDelete(){ $result = static::delete(DeclarationPackage::class); return $result; } /** * 报单表 * @return mixed * @throws Exception * @throws \yii\web\HttpException */ public function actionDecOrderList() { $filter = $this->filterCondition([ 'DEC_SN'=> 'DO.DEC_SN', 'ORDER_SN'=> 'DO.ORDER_SN', 'USER_NAME'=> 'U.USER_NAME', 'TO_USER_NAME'=> 'TU.USER_NAME', 'REAL_NAME'=> 'TU.REAL_NAME', 'ID_CARD'=> 'TU.ID_CARD', 'MOBILE'=> 'TU.MOBILE', 'DEC_LV_NAME' => 'TU.DEC_LV', 'DEC_REAL_NAME'=> 'DU.REAL_NAME', 'DEC_AMOUNT'=> 'DO.DEC_AMOUNT', 'DEC_PV'=> 'DO.DEC_PV', 'PERIOD_NUM'=> 'DO.PERIOD_NUM', 'REC_USER_NAME'=> 'RU.USER_NAME', 'CREATED_AT'=> 'DO.CREATED_AT', 'UPDATED_AT'=> 'DO.UPDATED_AT', ]); $condition = $filter['condition']; $params = $filter['params']; $condition .= ' AND DO.IS_DEL=0'; $listObj = new DecOrderList(); $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]); return static::notice($data); } /** * 报单表导出 * @return mixed * @throws \yii\db\Exception * @throws \yii\web\HttpException */ public function actionDecOrderListExport() { $filter = $this->filterCondition([ 'DEC_SN'=> 'DO.DEC_SN', 'ORDER_SN'=> 'DO.ORDER_SN', 'USER_NAME'=> 'U.USER_NAME', 'TO_USER_NAME'=> 'TU.USER_NAME', 'DEC_AMOUNT'=> 'DO.DEC_AMOUNT', 'DEC_PV'=> 'DO.DEC_PV', 'PERIOD_NUM'=> 'DO.PERIOD_NUM', 'CREATED_AT'=> 'DO.CREATED_AT', 'UPDATED_AT'=> 'DO.UPDATED_AT', ]); $filter['condition'] .= ' AND DO.IS_DEL=0'; $form = new ShopExportForm(); $result = $form->run($filter, '报单列表'); if (!$result) { return static::notice(Form::formatErrorsForApi($form->getErrors()), 400); } return static::notice('导出开始,请到文件管理-导出文件查看'); } /** * 订单表 * @return mixed * @throws Exception * @throws \yii\web\HttpException */ public function actionOrderList() { $filter = $this->filterCondition([ 'SN'=> 'O.SN', 'USER_NAME'=> 'U.USER_NAME', 'MOBILE'=> 'O.MOBILE', 'PERIOD_NUM'=> 'O.PERIOD_NUM', 'CREATED_AT'=> 'O.CREATED_AT', 'PAY_TYPE'=> 'O.PAY_TYPE', ]); // $condition = ' 1=1 ' . $filter['condition']; // $params = $filter['params']; // $condition .= $condition ? ' AND O.IS_DELETE=0' : ' O.IS_DELETE=0'; $condition = $filter['condition']; $params = $filter['params']; $condition .= ' AND O.IS_DELETE=0'; $listObj = new OrderList(); $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]); return static::notice($data); } // 删除订单 public function actionDeleteOrder() { if (\Yii::$app->request->isPost) { $formModel = new OrderDeleteForm(); if ($formModel->load(\Yii::$app->request->post(), '') && $result = $formModel->returnOrder()) { return static::notice('删除订单成功,请重新生成业绩单,计算奖金'); } else { return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400); } } } /** * 订单表导出 * @return mixed * @throws \yii\db\Exception * @throws \yii\web\HttpException */ public function actionOrderListExport() { $filter = $this->filterCondition([ 'SN'=> 'O.SN', 'USER_NAME'=> 'U.USER_NAME', 'MOBILE'=> 'O.MOBILE', 'PERIOD_NUM'=> 'O.PERIOD_NUM', 'CREATED_AT'=> 'O.CREATED_AT', 'PAY_TYPE'=> 'O.PAY_TYPE', ]); // $filter['condition'] = !$filter['condition'] ? '1=1 AND O.IS_DELETE=0' : ('O.IS_DELETE=0 ' . $filter['condition']); $filter['condition'] .= ' AND O.IS_DELETE=0'; $form = new ShopExportForm(); $result = $form->run($filter, '订单列表'); if (!$result) { return static::notice(Form::formatErrorsForApi($form->getErrors()), 400); } return static::notice('导出开始,请到文件管理-导出文件查看'); } /** * 外部商城订单列表 * @return mixed * @throws Exception * @throws \yii\web\HttpException */ public function actionOrderShopList() { $filter = $this->filterCondition([ 'SN'=> 'O.SN', 'USER_NAME'=> 'U.USER_NAME', 'PERIOD_NUM'=> 'O.PERIOD_NUM', 'CREATED_AT'=> 'O.CREATED_AT', ]); $condition = $filter['condition']; $params = $filter['params']; $condition .= ' AND O.IS_DELETE=0'; $listObj = new OrderShopList(); $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]); return static::notice($data); } /** * 外部商城报单列表 * @return mixed * @throws Exception * @throws \yii\web\HttpException */ public function actionOrderDecList() { $filter = $this->filterCondition([ 'SN'=> 'O.SN', 'USER_NAME'=> 'U.USER_NAME', 'PERIOD_NUM'=> 'O.PERIOD_NUM', 'CREATED_AT'=> 'O.CREATED_AT', ]); $condition = $filter['condition']; $params = $filter['params']; $condition .= ' AND O.IS_DELETE=0'; $listObj = new OrderDecList(); $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]); return static::notice($data); } /** * 分页导入excel文件到待导入数据的表中 * @return mixed */ public function actionImportOrderShopToExcelTable() { // 先上传到服务器文件 if (\Yii::$app->request->isPost) { $excelImportId = \Yii::$app->request->post('excelImportId'); $rowCount = \Yii::$app->request->post('rowCount'); //$periodNum = \Yii::$app->request->post('periodNum'); $orderDay = \Yii::$app->request->post('orderDay'); $orderType = \Yii::$app->request->post('orderType'); $startRow = \Yii::$app->request->post('startRow'); $limit = \Yii::$app->request->post('limit', 1000); $errorMsg = ''; try { if( $startRow == 1 ) { $excelOrderShop = new ExcelOrderShopForm(); $excelOrderShop->checkStatus($orderDay,$orderType); } $excel = new \common\helpers\Excel(); $result = $excel->pageImportCustomDataFromExcel('orderShop', $excelImportId, $rowCount, $startRow, $limit,$orderDay,$orderType); } catch (\Exception $e) { $result = false; $errorMsg = $e->getMessage(); } // 还有数据 if ($result === 1) { return static::notice(['finish' => false]); } elseif ($result === 0) { return static::notice(['finish' => true]); } else { return static::notice('发生错误:' . $errorMsg, 400); } } } /** * 导入完成标记 * @return mixed * @throws \yii\web\HttpException */ public function actionImportOrderShop() { //$periodNum = \Yii::$app->request->post('periodNum'); $orderDay = \Yii::$app->request->post('orderDay'); $orderType = \Yii::$app->request->post('orderType'); $excelOrderShop = new ExcelOrderShopForm(); $finishStatus = $excelOrderShop->finished($orderDay,$orderType); if ($finishStatus) { return static::notice(['finish' => true]); } else { return static::notice('状态更新错误', 400); } } /** * 报单订单——分页导入excel文件到待导入数据的表中 * @return mixed */ public function actionImportOrderDecToExcelTable() { // 先上传到服务器文件 if (\Yii::$app->request->isPost) { $excelImportId = \Yii::$app->request->post('excelImportId'); $rowCount = \Yii::$app->request->post('rowCount'); //$periodNum = \Yii::$app->request->post('periodNum'); $orderDay = \Yii::$app->request->post('orderDay'); $startRow = \Yii::$app->request->post('startRow'); $limit = \Yii::$app->request->post('limit', 1000); $errorMsg = ''; try { if( $startRow == 1 ) { $excelOrderShop = new ExcelOrderDecForm(); $excelOrderShop->checkStatus($orderDay); } $excel = new \common\helpers\Excel(); $result = $excel->pageImportCustomDataFromExcel('orderDec', $excelImportId, $rowCount, $startRow, $limit,$orderDay); } catch (\Exception $e) { $result = false; $errorMsg = $e->getMessage(); } // 还有数据 if ($result === 1) { return static::notice(['finish' => false]); } elseif ($result === 0) { return static::notice(['finish' => true]); } else { return static::notice('发生错误:' . $errorMsg, 400); } } } /** * 报单订单导入完成标记 * @return mixed * @throws \yii\web\HttpException */ public function actionImportOrderDec() { //$periodNum = \Yii::$app->request->post('periodNum'); $orderDay = \Yii::$app->request->post('orderDay'); $excelOrderShop = new ExcelOrderDecForm(); $finishStatus = $excelOrderShop->finished($orderDay); if ($finishStatus) { return static::notice(['finish' => true]); } else { return static::notice('状态更新错误', 400); } } /** * 见习达标订单列表 * @return mixed * @throws Exception * @throws \yii\web\HttpException */ public function actionOrderStandardList() { $filter = $this->filterCondition([ 'SN'=> 'O.SN', 'USER_NAME'=> 'U.USER_NAME', 'PERIOD_NUM'=> 'O.PERIOD_NUM', 'CREATED_AT'=> 'O.CREATED_AT', ]); $condition = $filter['condition']; $params = $filter['params']; $condition .= ' AND O.IS_DELETE=0'; $listObj = new OrderStandardList(); $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]); return static::notice($data); } /** * 分页导入excel文件到待导入数据的表中 * @return mixed * @throws \yii\web\HttpException */ public function actionImportOrderStandardToExcelTable() { // 先上传到服务器文件 if (\Yii::$app->request->isPost) { $excelImportId = \Yii::$app->request->post('excelImportId'); $rowCount = \Yii::$app->request->post('rowCount'); //$periodNum = \Yii::$app->request->post('periodNum'); $orderMonth = \Yii::$app->request->post('orderMonth'); // $orderType = \Yii::$app->request->post('orderType'); $orderType = 'cash'; $startRow = \Yii::$app->request->post('startRow'); $limit = \Yii::$app->request->post('limit', 1000); $errorMsg = ''; try { if( $startRow == 1 ) { //清空已经导入的表数据 $excelOrderStandard = new ExcelOrderStandardForm(); $excelOrderStandard->checkStatus($orderMonth); } $excel = new \common\helpers\Excel(); $result = $excel->pageImportCustomDataFromExcel('orderShopStandard', $excelImportId, $rowCount, $startRow, $limit,$orderMonth,$orderType); } catch (Exception $e) { $result = false; $errorMsg = $e->getMessage(); } // 还有数据 if ($result === 1) { return static::notice(['finish' => false]); } elseif ($result === 0) { return static::notice(['finish' => true]); } else { return static::notice('发生错误:' . $errorMsg, 400); } } } /** * 达标订单导入完成标记 * @return mixed * @throws \yii\web\HttpException */ public function actionImportOrderStandard() { $orderMonth = \Yii::$app->request->post('orderMonth'); $excelOrderStandard = new ExcelOrderStandardForm(); $finishStatus = $excelOrderStandard->finished($orderMonth); if ($finishStatus) { return static::notice(['finish' => true]); } else { return static::notice('状态更新错误', 400); } } /** * 管理员发货 * @return mixed * @throws \yii\web\HttpException */ public function actionOrderDelivery() { if(\Yii::$app->request->isPost) { return parent::edit(OrderForm::class, '发货成功', 'adminDelivery', ['adminDelivery']); } return static::notice('非法请求', 400); } /* * 剩余BV页 * */ public function actionRemainPv() { $filter = $this->filterCondition([ 'USER_NAME' => 'U.USER_NAME', ]); $condition = $filter['condition']; $params = $filter['params']; $listObj = new RemainPvList(); $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]); return static::notice($data); } /* * 剩余BV流水 * */ public function actionFlowRemainPv() { $filter = $this->filterCondition([ 'USER_NAME' => 'U.USER_NAME', ]); $condition = $filter['condition']; $params = $filter['params']; $listObj = new FlowRemainPvList(); $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]); return static::notice($data); } /** * 订单详情 * @return mixed * @throws \yii\web\HttpException */ public function actionOrderDetail() { $orderSn = \Yii::$app->request->get('orderSn'); $order = Order::findOneAsArray('SN=:SN', [':SN' => $orderSn]); if (!$order) { return static::notice('订单不存在', 400); } $order['ORDER_TYPE'] = $order['ORDER_TYPE'] === 'ZC' ? '首单' : '复消'; // 如果当前订单所在期数已挂网,则不可调整 $period = Period::getInfoByPeriodNum($order['PERIOD_NUM']); if (!$period) { return static::notice('期数无效', 400); } if ($period['IS_SENT'] > 0) { return static::notice('订单已挂网', 400); } // 根据订单期数查询可调整期数 $availablePeriod = []; if ($order['PERIOD_NUM']) { $availablePeriod = Period::getPeriodList(+$order['PERIOD_NUM'] - 1); foreach ($availablePeriod as $k => $item) { $availablePeriod[$k]['disabled'] = (+$item['IS_SENT'] > 0) || ($order['PERIOD_NUM'] == $item['PERIOD_NUM']); } } return static::notice(['order' => $order, 'availablePeriod' => $availablePeriod]); } /** * 期数检查 * @return mixed * @throws \yii\web\HttpException */ public function actionPeriodInspect() { $modernPeriod = \Yii::$app->request->get('modernPeriod'); $period = Period::getInfoByPeriodNum($modernPeriod); if (!$period) { return static::notice('期数不存在', 400); } if ($period['IS_SENT'] > 0) { return static::notice('调整后的期数已未挂网', 400); } } /** * 调整订单期数 * @return mixed * @throws Exception * @throws \yii\db\Exception * @throws \yii\web\HttpException */ public function actionOrderPeriodAdjust() { if (\Yii::$app->request->isPost) { $formModel = new OrderPeriodAdjustForm(); $formModel->scenario = 'orderPeriodAdjust'; if ($formModel->load(\Yii::$app->request->post(), '') && $formModel->periodAdjust()) { return static::notice('成功'); } else { return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400); } } else { $filter = $this->filterCondition([ 'ORDER_SN' => 'P.ORDER_SN', 'ORIGIN_PERIOD'=> 'P.ORIGIN_PERIOD', 'MODERN_PERIOD'=> 'P.MODERN_PERIOD', 'CREATED_AT'=> 'P.CREATED_AT', ]); $listObj = new OrderPeriodAdjustList(); $data = $listObj->getList(['condition' => $filter['condition'], 'params' => $filter['params']]); return static::notice($data); } } public function actionOrderPeriodAdjustBatch() { // if (\Yii::$app->request->isPost) { $db = \Yii::$app->db; $transaction = $db->beginTransaction(); $orderList = ['OS202408124810250102', 'OS202408125510154541', 'OS202408129710155101', 'OS202408129950985348', 'OS202408125153559954', 'OS202408125651509952', 'OS202408122632848244', 'OS202408122142828444', 'OS202408124332467022', 'OS202408123211846634', 'OS202408125704667483', 'OS202408124455418626', 'OS202408122717654666', 'OS202408120441445446', 'OS202408126815950310', 'OS202408128289488841', 'OS202408122459822888', 'OS202408126942458027', 'OS202408124366873315', 'OS202408121024910210', 'OS202408125710056531', 'OS202408125550100544', 'OS202408125498521021', 'OS202408129949994857', 'OS202408125054555354', 'OS202408125099501025', 'OS202408126671797982', 'OS202408129862232343', 'OS202408121498243182', 'OS202408126605496278', 'OS202408126152036612', 'OS202408121015557101', 'OS202408125610152505', 'OS202408125750521015', 'OS202408125557574856', 'OS202408125754525656', 'OS202408124856511029', 'OS202408121009799505', 'OS202408125010048505', 'OS202408125452989998', 'OS202408125749539848', 'OS202408125452545054', 'OS202408121005299100', 'OS202408125798102521', 'OS202408121001004855', 'OS202408125498101485', 'OS202408125210155525', 'OS202408125497974810', 'OS202408121005110210', 'OS202408125553511005', 'OS202408129956100521', 'OS202408129750102485', 'OS202408124855531011', 'OS202408121019910048', 'OS202408125110248569', 'OS202408125349985752', 'OS202408125797575748', 'OS202408125654975355', 'OS202408129810010252', 'OS202408125352575049', 'OS202408124810057575', 'OS202408129850525497', 'OS202408125553531019', 'OS202408125697535552', 'OS202408125297569755', 'OS202408125110198100', 'OS202408125548559997', 'OS202408129798525454', 'OS202408121005153999', 'OS202408129898559998', 'OS202408124949495755', 'OS202408124998521005', 'OS202408125654485710', 'OS202408125255975399', 'OS202408125454994949', 'OS202408129898525049', 'OS202408121025710098', 'OS202408121004810048', 'OS202408125453525653', 'OS202408124997985249', 'OS202408129752549750', 'OS202408121011014948', 'OS202408121025454509', 'OS202408129951985010', 'OS202408129750515349', 'OS202408125652529910', 'OS202408125699575054', 'OS202408126373959498', 'OS202408122855234468', 'OS202408129897999997', 'OS202408125198101509', 'OS202408125397481015', 'OS202408121025155569', 'OS202408121025797102', 'OS202408125149541021', 'OS202408125055501019', 'OS202408125710048101', 'OS202408125710050531', 'OS202408124910010051', 'OS202408125250519910', 'OS202408121024951495', 'OS202408120278963899', 'OS202408122468558358', 'OS202408128488898728', 'OS202408120668414449', 'OS202408122203908524', 'OS202408120842886466', 'OS202408125655971019', 'OS202408122864806084', 'OS202408125750534856', 'OS202408121015050975', 'OS202408128841334459', 'OS202408126548409724', 'OS202408123469880431', 'OS202408122139215963', 'OS202408124638848447', 'OS202408126610424679', 'OS202408127186683544', 'OS202408127213461201', 'OS202408126889501454', 'OS202408128235014016', 'OS202408123826968604', 'OS202408126324628624', 'OS202408125026200244', 'OS202408122671636578', 'OS202408122272420084', 'OS202408128421826164', 'OS202408129284082866', 'OS202408129951144421', 'OS202408122832368750', 'OS202408125633836704', 'OS202408126318481378', 'OS202408129062986684', 'OS202408126358961486', 'OS202408123033853388', 'OS202408124994261531', 'OS202408128289462234', 'OS202408128407101645', 'OS202408122786586662', 'OS202408125858809548', 'OS202408124850575553', 'OS202408125754535752', 'OS202408121005450515', 'OS202408129753515510', 'OS202408125153541029', 'OS202408121025497505', 'OS202408125656985555', 'OS202408121005649501', 'OS202408125756100991', 'OS202408129855565097', 'OS202408125310252491', 'OS202408125651100101', 'OS202408124953985156', 'OS202408125198525098', 'OS202408125657559852', 'OS202408125297981009', 'OS202408125210249985', 'OS202408125597525298', 'OS202408125250101505', 'OS202408124810097514', 'OS202408129899971005', 'OS202408125498545599', 'OS202408129910049509', 'OS202408125254101505', 'OS202408125197101541', 'OS202408121005249102', 'OS202408125656981029', 'OS202408125251495310', 'OS202408129951999798', 'OS202408129899100495', 'OS202408124948515248', 'OS202408125099579898', 'OS202408129955981009', 'OS202408125099511005', 'OS202408125010248579', 'OS202408129797575550', 'OS202408125456101514', 'OS202408124897525610', 'OS202408124898984855', 'OS202408121005654501', 'OS202408129857555348', 'OS202408124849989957', 'OS202408125056515610', 'OS202408125798100975', 'OS202408125450564898', 'OS202408124899515552', 'OS202408125657531004', 'OS202408125557561005', 'OS202408129850100991', 'OS202408121029855100', 'OS202408125010097575', 'OS202408125697535598', 'OS202408121025097491', 'OS202408129998102985', 'OS202408121025597555', 'OS202408124998979753', 'OS202408125449985310', 'OS202408125010155991', 'OS202408125051531005', 'OS202408125251102515', 'OS202408125350101975', 'OS202408125552101565', 'OS202408121015249515', 'OS202408129997100100', 'OS202408129999979848', 'OS202408125748539956', 'OS202408129952531001', 'OS202408125310098555', 'OS202408125455499850', 'OS202408124951501025', 'OS202408125555494955', 'OS202408125050574857', 'OS202408129948521015', 'OS202408125249101991', 'OS202408125699102991', 'OS202408121015599515', 'OS202408121029956529', 'OS202408125310057555', 'OS202408125410149525', 'OS202408125210154555', 'OS202408125252101515', 'OS202408121005157995', 'OS202408129851989910', 'OS202408125054531024', 'OS202408129849565399', 'OS202408125753519757', 'OS202408125156101979', 'OS202408125010010156', 'OS202408125698555010', 'OS202408125010053495', 'OS202408129853505010', 'OS202408129853534851', 'OS202408125398545110', 'OS202408129950101505', 'OS202408129950535757', 'OS202408125453975756', 'OS202408121025348534', 'OS202408121021001015', 'OS202408121011004897', 'OS202408125510049100', 'OS202408124856525252', 'OS202408129954975556', 'OS202408125597549853', 'OS202408125552565152', 'OS202408125097545354', 'OS202408125199531025', 'OS202408121021019757', 'OS202408125055575110', 'OS202408129756101535', 'OS202408125155101985', 'OS202408125055999810', 'OS202408124952554997', 'OS202408125097555597', 'OS202408125454541025', 'OS202408121015150545', 'OS202408125354102975', 'OS202408125357535356', 'OS202408125599501019', 'OS202408125410248499', 'OS202408121025651985', 'OS202408129952569797', 'OS202408129799985250', 'OS202408129849999999', 'OS202408125054539854', 'OS202408121015351574', 'OS202408125054545398', 'OS202408125253100989', 'OS202408125399575710', 'OS202408124681070152', 'OS202408124462194243', 'OS202408120425594620', 'OS202408124828680424', 'OS202408122868688902', 'OS202408126361869462', 'OS202408124822505150', 'OS202408127258081101', 'OS202408129444885180', 'OS202408122488221666', 'OS202408125883858578', 'OS202408120281842426', 'OS202408125866482622', 'OS202408121464468638', 'OS202408124485834920', 'OS202408129683286546', 'OS202408125799991019', 'OS202408129898100519', 'OS202408125098100101', 'OS202408129910054975', 'OS202408124854555453', 'OS202408125310249489', 'OS202408121011015749', 'OS202408125410154499', 'OS202408129754985756', 'OS202408125353485253', 'OS202408129710055535', 'OS202408128858023692', 'OS202408122284407634', 'OS202408121015648511', 'OS202408122026862936', 'OS202408120164243569', 'OS202408128184071952', 'OS202408120622725287', 'OS202408125054495553', 'OS202408128767496844', 'OS202408124892248462', 'OS202408127081682268', 'OS202408123144285829', 'OS202408124422125882', 'OS202408122384408102', 'OS202408129810250559', 'OS202408129749102555', 'OS202408121021015450']; $orderErr = []; try { $modernPeriod = 227; foreach ($orderList as $orderSn) { $orderObj = Order::findOneAsArray('SN=:SN', [':SN' => $orderSn]); if (!$orderObj) { $orderErr[] = $orderSn; continue; } // 调整订单期数 Order::updateAll(['PERIOD_NUM' => $modernPeriod], 'SN = :SN', [':SN' => $orderSn]); if ($orderObj['ORDER_TYPE'] === 'ZC') { // 调整报单期数 DecOrder::updateAll(['PERIOD_NUM' => $modernPeriod], 'ORDER_SN = :ORDER_SN', ['ORDER_SN' => $orderSn]); // 调整会员的期数 User::updateAll(['PERIOD_AT' => $modernPeriod], 'ID = :USER_ID', ['USER_ID' => $orderObj['USER_ID']]); UserInfo::updateAll(['HIGHEST_EMP_LV_PERIOD' => $modernPeriod], 'USER_ID = :USER_ID', ['USER_ID' => $orderObj['USER_ID']]); } // 调整流水的期数 switch ($orderObj['PAY_TYPE']){ case 'cash': FlowWallet::updateAll(['PERIOD_NUM' => $modernPeriod], 'ORDER_SN = :ORDER_SN', ['ORDER_SN' => $orderSn]); break; case 'point': FlowReconsumePoints::updateAll(['PERIOD_NUM' => $modernPeriod], 'ORDER_SN = :ORDER_SN', ['ORDER_SN' => $orderSn]); break; case 'exchange': FlowExchangePoints::updateAll(['PERIOD_NUM' => $modernPeriod], 'ORDER_SN = :ORDER_SN', ['ORDER_SN' => $orderSn]); break; default: break; } // 写入调整记录 $orderModel = new OrderPeriodAdjust(); $orderModel->ORDER_SN = $orderSn; $orderModel->ORIGIN_PERIOD = 224; $orderModel->MODERN_PERIOD = $modernPeriod; $orderModel->ADMIN_ID = '3rwvmynvct'; $orderModel->CREATED_AT = Date::nowTime(); if (!$orderModel->save()) { return static::notice($orderModel->getErrors(), 400); } } $transaction->commit(); } catch(\Exception $e) { $transaction->rollBack(); return static::notice($e->getMessage(), 400); } return static::notice('成功. ' . json_encode($orderErr)); // } } }