| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849 |
- <?php
- /**
- * Created by PhpStorm.
- * User: leo
- * Date: 2018/2/24
- * Time: 下午12:48
- */
- namespace backendApi\modules\v1\controllers;
- use backendApi\modules\v1\models\exportForms\BaShopExportForm;
- use backendApi\modules\v1\models\exportForms\ShopExportForm;
- use backendApi\modules\v1\models\lists\shop\DecOrderList;
- use backendApi\modules\v1\models\lists\shop\GoodsList;
- use backendApi\modules\v1\models\lists\shop\OrderDecList;
- use backendApi\modules\v1\models\lists\shop\OrderList;
- use backendApi\modules\v1\models\lists\shop\BaOrderList;
- use backendApi\modules\v1\models\lists\shop\OrderShopList;
- use backendApi\modules\v1\models\lists\shop\OrderStandardList;
- use backendApi\modules\v1\models\lists\shop\PackageList;
- use backendApi\modules\v1\models\lists\shop\RemainPvList;
- use backendApi\modules\v1\models\lists\shop\FlowRemainPvList;
- use common\helpers\Cache;
- use common\helpers\Form;
- use common\models\DeclarationPackage;
- use common\models\DecOrder;
- use common\models\forms\BaOrderDeleteForm;
- use common\models\forms\DecPackageForm;
- use common\models\forms\ExcelOrderDecForm;
- use common\models\forms\ExcelOrderShopForm;
- use common\models\forms\ExcelOrderStandardForm;
- use common\models\forms\OrderDeleteForm;
- use common\models\forms\OrderForm;
- use common\models\forms\ShopGoodsForm;
- use common\models\forms\UploadForm;
- use common\models\ShopGoods;
- use yii\web\HttpException;
- use yii\web\UploadedFile;
- use yii\base\Exception;
- class ShopController extends BaseController {
- public $modelClass = DecOrder::class;
- public function behaviors() {
- $behaviors = parent::behaviors();
- //$behaviors['contentNegotiator']['formats']['text/html'] = Response::FORMAT_JSON;
- return $behaviors;
- }
- /**
- * 商品列表
- * @return mixed
- * @throws Exception
- * @throws HttpException
- */
- public function actionIndex() {
- $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',
- 'CATEGORY_TYPE' => 'CATEGORY_TYPE',
- ]);
- $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 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',
- 'CATEGORY_TYPE' => 'CATEGORY_TYPE',
- ]);
- $form = new ShopExportForm();
- $result = $form->run($filter, 'Goods_List'); // 商品列表
- if (!$result) {
- return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
- }
- return static::notice(\Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
- }
- /**
- * 添加商品
- * @return mixed
- * @throws Exception
- * @throws 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('Product add succeeded.');
- } else {
- return static::notice(Form::formatErrorsForApi($formModel->getErrors()),400);
- }
- }
- return static::notice([
- 'sellType' => ShopGoods::SALE_TYPE,
- 'goodsType' => ShopGoods::GOODS_TYPE,
- 'giftType' => ShopGoods::GIFT_TYPE,
- 'categoryType' => ShopGoods::CATEGORY_TYPE,
- ]);
- }
- /**
- * 编辑商品
- * @return mixed
- * @throws Exception
- * @throws 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('Product editing succeeded.');
- } 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']);
- if ($data['TYPE'] == 1 || $data['TYPE'] == 2) {
- $data['SELL_DISCOUNT'] = ShopGoods::GOODS_TYPE[$data['TYPE']]['discount']/100;
- }
- return static::notice(
- [
- 'goodsInfo'=>$data,
- 'sellType' => ShopGoods::SALE_TYPE,
- 'goodsType' => ShopGoods::GOODS_TYPE,
- 'giftType' => ShopGoods::GIFT_TYPE,
- 'categoryType' => ShopGoods::CATEGORY_TYPE,
- ]
- );
- }
- /**
- * 上传图片
- * @return mixed
- * @throws \yii\base\Exception
- * @throws \yii\db\Exception
- * @throws 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('Status setting succeeded'); // 状态设置成功
- } else {
- return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
- }
- }
- }
- /**
- * 删除商品
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionGoodsDelete(){
- $result = static::delete(ShopGoods::class);
- return $result;
- }
- /**
- * 套餐列表
- * @return mixed
- * @throws Exception
- * @throws 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',
- ]);
- $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 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 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'],'amountStandard' => $package['AMOUNT_STANDARD'],'storenums' => $package['STORE_NUMS']]);
- }
- /**
- * 套餐上下架
- * @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('Status setting succeeded'); // 状态设置成功
- } else {
- return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
- }
- }
- }
- /**
- * 删除套餐
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionPackageDelete(){
- $result = static::delete(DeclarationPackage::class);
- return $result;
- }
- /**
- * 报单表
- * @return mixed
- * @throws Exception
- * @throws 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 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(\Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
- }
- // 删除订单
- 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 Exception
- * @throws 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',
- 'ORDER_TYPE'=> 'O.ORDER_TYPE',
- 'STATUS' => 'O.STATUS',
- 'IS_AUTO' => 'O.IS_AUTO'
- ]);
- $condition = ' 1=1 ' . $filter['condition'];
- $params = $filter['params'];
- $condition .= $condition ? ' AND O.IS_DELETE=0' : ' O.IS_DELETE=0';
- $listObj = new OrderList();
- $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
- return static::notice($data);
- }
- /**
- * 订单表导出
- * @return mixed
- * @throws \yii\db\Exception
- * @throws 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',
- 'ORDER_TYPE'=> 'O.ORDER_TYPE',
- 'STATUS' => 'O.STATUS',
- 'IS_AUTO' => 'O.IS_AUTO'
- ]);
- $filter['condition'] = !$filter['condition'] ? '1=1 AND O.IS_DELETE=0' : ('O.IS_DELETE=0 ' . $filter['condition']);
- $form = new ShopExportForm();
- $result = $form->run($filter, 'Order_List'); // 订单列表
- if (!$result) {
- return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
- }
- return static::notice(\Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
- }
- /**
- * 外部商城订单列表
- * @return mixed
- * @throws Exception
- * @throws 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 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('Error:' . $errorMsg, 400);
- }
- }
- }
- /**
- * 导入完成标记
- * @return mixed
- * @throws 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('Error:' . $errorMsg, 400);
- }
- }
- }
- /**
- * 报单订单导入完成标记
- * @return mixed
- * @throws 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 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 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 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 HttpException
- */
- public function actionOrderDelivery() {
- if(\Yii::$app->request->isPost) {
- return parent::edit(OrderForm::class, '发货成功', 'adminDelivery', ['adminDelivery']);
- }
- return static::notice('Illegal request', 400); // 非法请求
- }
- /**
- * 报单表导出
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionOrderListExportPdf()
- {
- $orderSn = \Yii::$app->request->get('orderSn');
- $filter = $this->filterCondition([
- 'SN'=> 'O.SN',
- 'USER_NAME'=> 'U.USER_NAME',
- 'MOBILE'=> 'O.MOBILE',
- 'PERIOD_NUM'=> 'O.PERIOD_NUM',
- 'CREATED_AT'=> 'O.CREATED_AT',
- ]);
- $filter['condition'] = ' O.IS_DELETE=0 AND O.SN=:SN';
- $filter['params'] = [':SN' => $orderSn];
- $form = new ShopExportForm();
- $result = $form->run($filter, '订单列表');
- if (!$result) {
- return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
- }
- return static::notice(\Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
- }
- /**
- * 报单表导出
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionDecOrderListExportPdf()
- {
- $orderSn = \Yii::$app->request->get('orderSn');
- $filter = $this->filterCondition([
- 'SN'=> 'O.SN',
- 'USER_NAME'=> 'U.USER_NAME',
- 'MOBILE'=> 'O.MOBILE',
- 'PERIOD_NUM'=> 'O.PERIOD_NUM',
- 'CREATED_AT'=> 'O.CREATED_AT',
- ]);
- $filter['condition'] = ' 1=1 AND O.IS_DELETE=0 AND O.SN=:SN';
- $filter['params'] = [':SN' => $orderSn];
- $form = new ShopExportForm();
- $result = $form->run($filter, '订单列表');
- if (!$result) {
- return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
- }
- return static::notice(\Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
- }
- /**
- * 管理员订单退款
- * @return mixed
- * @throws HttpException
- */
- public function actionOrderRefund()
- {
- if(\Yii::$app->request->isPost) {
- return parent::edit(OrderForm::class, '退款成功', 'adminRefund', ['adminRefund']);
- }
- return static::notice('Illegal request', 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);
- }
- /**
- * BA订单表
- * @return mixed
- * @throws Exception
- * @throws HttpException
- */
- public function actionBaOrderList() {
- $filter = $this->filterCondition([
- 'SN'=> 'O.SN',
- 'USER_NAME'=> 'U.USER_NAME',
- 'MOBILE'=> 'O.MOBILE',
- 'PERIOD_NUM'=> 'O.PERIOD_NUM',
- 'CREATED_AT'=> 'O.CREATED_AT',
- 'ORDER_TYPE'=> 'O.ORDER_TYPE',
- 'STATUS' => 'O.STATUS',
- ]);
- $condition = ' 1=1 ' . $filter['condition'];
- $params = $filter['params'];
- $condition .= $condition ? ' AND O.IS_DELETE=0' : ' O.IS_DELETE=0';
- $listObj = new BaOrderList();
- $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
- return static::notice($data);
- }
- /**
- * BA订单表导出
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionBaOrderListExport()
- {
- $filter = $this->filterCondition([
- 'SN'=> 'O.SN',
- 'USER_NAME'=> 'U.USER_NAME',
- 'MOBILE'=> 'O.MOBILE',
- 'PERIOD_NUM'=> 'O.PERIOD_NUM',
- 'CREATED_AT'=> 'O.CREATED_AT',
- 'STATUS' => 'O.STATUS',
- ]);
- $filter['condition'] = !$filter['condition'] ? '1=1 AND O.IS_DELETE=0' : ('O.IS_DELETE=0 ' . $filter['condition']);
- $form = new BaShopExportForm();
- $result = $form->run($filter, 'Ba_Order_List'); // 订单列表
- if (!$result) {
- return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
- }
- return static::notice(\Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
- }
- /**
- * 报单表导出
- * @return mixed
- * @throws \yii\db\Exception
- * @throws HttpException
- */
- public function actionBaOrderListExportPdf()
- {
- $orderSn = \Yii::$app->request->get('orderSn');
- $filter = $this->filterCondition([
- 'SN'=> 'O.SN',
- 'USER_NAME'=> 'U.USER_NAME',
- 'MOBILE'=> 'O.MOBILE',
- 'PERIOD_NUM'=> 'O.PERIOD_NUM',
- 'CREATED_AT'=> 'O.CREATED_AT',
- ]);
- $filter['condition'] = ' O.IS_DELETE=0 AND O.SN=:SN';
- $filter['params'] = [':SN' => $orderSn];
- $form = new BaShopExportForm();
- $result = $form->run($filter, 'Brand Ambassador Order');
- if (!$result) {
- return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
- }
- return static::notice(\Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
- }
- }
|