فهرست منبع

bugfix: EK-1360: 订单没有报单中心编号.

kevinElken 8 ماه پیش
والد
کامیت
e77125b8eb
2فایلهای تغییر یافته به همراه53 افزوده شده و 17 حذف شده
  1. 40 14
      frontendApi/modules/v1/controllers/ShopController.php
  2. 13 3
      frontendApi/modules/v1/controllers/UserController.php

+ 40 - 14
frontendApi/modules/v1/controllers/ShopController.php

@@ -213,24 +213,27 @@ class ShopController extends BaseController {
             $formModel->remark = 'FX';//复销备注
             $post = \Yii::$app->request->post();
             $post['type'] = DeclarationForm::TYPE_FX;
-            $userInfo = User::getEnCodeInfo(\Yii::$app->user->id);
-            $userName = $post['userName'] ?? '';
-            if($userInfo['IS_DEC'] == 1 && $userName != $userInfo['USER_NAME']){
+            $loginUserInfo = User::getEnCodeInfo(\Yii::$app->user->id);
+            $stockist = $post['userName'] ?? '';
+            if (!$stockist) {
                 return static::notice(Yii::t('app', 'stockistDoesNotExist'), 400);
             }
-            if($userName && $userInfo['IS_DEC'] == 0){
+            if($loginUserInfo['IS_DEC'] == 1 && $stockist != $loginUserInfo['USER_NAME']){
+                return static::notice(Yii::t('app', 'stockistDoesNotExist'), 400);
+            }
+            if($loginUserInfo['IS_DEC'] == 0){
                 //查询报单编号是否存在
-                $userId = Info::getUserIdByUserName($userName);
-                if(!$userId){
+                $stockistId = Info::getUserIdByUserName($stockist);
+                if(!$stockistId){
                     return static::notice(Yii::t('app', 'stockistDoesNotExist'), 400);
                 }
-                $isDec = User::getEnCodeInfo($userId)['IS_DEC'];
+                $isDec = User::getEnCodeInfo($stockistId)['IS_DEC'];
                 if(!$isDec){
                     return static::notice(Yii::t('app', 'decUserNameIsWrong'), 400);
                 }
             }
 
-            $formModel->decUserName = $userName;
+            $formModel->decUserName = $stockist;
             if ($formModel->load($post, '') && $order = $formModel->add()) {
                 return static::notice($order);
             } else {
@@ -262,16 +265,16 @@ class ShopController extends BaseController {
             $formModel->remark = '复销备注';
             $post = \Yii::$app->request->post();
             $post['type'] = DeclarationForm::TYPE_FX;
-            $userInfo = User::getEnCodeInfo(\Yii::$app->user->id);
-            if($userInfo['IS_DEC'] == 1 && !empty($post['userName']) && $post['userName'] != $userInfo['USER_NAME']){
+            $loginUserInfo = User::getEnCodeInfo(\Yii::$app->user->id);
+            $stockist = $post['userName'] ?? '';
+            if (!$stockist) {
                 return static::notice(Yii::t('app', 'stockistDoesNotExist'), 400);
             }
-
-            if(empty($post['userName'])){
-                return static::notice(Yii::t('app', 'decUserNameIsWrong'), 400);
+            if($loginUserInfo['IS_DEC'] == 1 && !empty($post['userName']) && $post['userName'] != $loginUserInfo['USER_NAME']){
+                return static::notice(Yii::t('app', 'stockistDoesNotExist'), 400);
             }
             //查询报单编号是否存在
-            if($post['userName'] && $userInfo['IS_DEC'] == 0){
+            if($loginUserInfo['IS_DEC'] == 0){
                 $userId = Info::getUserIdByUserName($post['userName']);
                 if(!$userId){
                     return static::notice(Yii::t('app', 'stockistDoesNotExist'), 400);
@@ -281,6 +284,7 @@ class ShopController extends BaseController {
                     return static::notice(Yii::t('app', 'decUserNameIsWrong'), 400);
                 }
             }
+
             $formModel->decUserName = $post['userName'];
             if ($formModel->load($post, '') && $order = $formModel->add()) {
                 return static::notice($order);
@@ -300,6 +304,12 @@ class ShopController extends BaseController {
             $formModel->remark = '为用户复消';
             $post = \Yii::$app->request->post();
             $post['type'] = DeclarationForm::TYPE_FX;
+
+            $stockist = $post['userName'] ?? '';
+            if (!$stockist) {
+                return static::notice(Yii::t('app', 'stockistDoesNotExist'), 400);
+            }
+
             if ($formModel->load($post, '') && $order = $formModel->add()) {
                 return static::notice($order);
             } else {
@@ -742,6 +752,12 @@ class ShopController extends BaseController {
             $formModel->remark = Yii::t('app', 'reconsume');
             $post = \Yii::$app->request->post();
             $post['type'] = DeclarationForm::TYPE_FX;
+
+            $stockist = $post['decUserName'] ?? '';
+            if (!$stockist) {
+                return static::notice(Yii::t('app', 'stockistDoesNotExist'), 400);
+            }
+
             if ($formModel->load($post, '') && $formModel->reconsumeAdd()) {
                 return static::notice(Yii::t('app', 'reconsumeSuccessfully'));
             } else {
@@ -1923,6 +1939,11 @@ ORDER;
             $post = \Yii::$app->request->post();
             $post['type'] = DeclarationForm::TYPE_FX;
 
+            $stockist = $post['decUserName'] ?? '';
+            if (!$stockist) {
+                return static::notice(Yii::t('app', 'stockistDoesNotExist'), 400);
+            }
+
             try {
                 if ($formModel->load($post, '') && $formModel->autoMaintenanceSureOrder()) {
                     return static::notice(Yii::t('app', 'successfully'));
@@ -1946,6 +1967,11 @@ ORDER;
             $post = \Yii::$app->request->post();
             $post['type'] = DeclarationForm::TYPE_FX;
 
+            $stockist = $post['decUserName'] ?? '';
+            if (!$stockist) {
+                return static::notice(Yii::t('app', 'stockistDoesNotExist'), 400);
+            }
+
             try {
                 if ($formModel->load($post, '') && $order = $formModel->autoMaintenanceSureOrder()) {
                     return static::notice($order);

+ 13 - 3
frontendApi/modules/v1/controllers/UserController.php

@@ -374,6 +374,11 @@ class UserController extends BaseController {
                 $formModel = new DeclarationUpgradeForm();
             }
 
+            $stockist = $post['decUserName'] ?? '';
+            if (!$stockist) {
+                return static::notice(Yii::t('app', 'stockistDoesNotExist'), 400);
+            }
+
             $post['type'] = DeclarationForm::TYPE_ZC;
             if ($formModel->load($post, '') && $result = $formModel->add($post)) {
                 return static::notice($result);// Upgrade declaration succeeded升级报单成功
@@ -514,11 +519,16 @@ class UserController extends BaseController {
         $redis = \Yii::$app->redis;
         $post = \Yii::$app->request->post();
         if (\Yii::$app->request->isPost) {
-            $userInfo = User::getEnCodeInfo(\Yii::$app->user->id);
-            if($userInfo['IS_DEC'] == 1 && !empty($post['decUserName']) && $post['decUserName'] != $userInfo['USER_NAME']){
+            $stockist = $post['decUserName'] ?? '';
+            if (!$stockist) {
+                return static::notice(Yii::t('app', 'stockistDoesNotExist'), 400);
+            }
+
+            $loginUserInfo = User::getEnCodeInfo(\Yii::$app->user->id);
+            if($loginUserInfo['IS_DEC'] == 1 && !empty($post['decUserName']) && $post['decUserName'] != $loginUserInfo['USER_NAME']){
                 return static::notice(Yii::t('app', 'decUserNameIsWrong'), 400);
             }
-            if($userInfo['IS_DEC'] == 0 && $post['decUserName']){
+            if($loginUserInfo['IS_DEC'] == 0 && $post['decUserName']){
                 //查询报单编号是否存在
                 $userId = Info::getUserIdByUserName($post['decUserName']);
                 if(!$userId){