소스 검색

Merge branch 'master' into feature/3398-stageGoodAdjust

kevin_zhangl 2 년 전
부모
커밋
580f225f75

+ 9 - 1
common/helpers/Alarm.php

@@ -19,8 +19,14 @@ class Alarm
         $reportAlarmOpen = Cache::getSystemConfig()['reportAlarmOpen']['VALUE'];
         // 业务平台token
         $message['platform-id'] = \Yii::$app->params['alarmAccessToken'];
+        // 堆栈ID
+        $message['trace-id'] = $message['trace-id'] ?? Tool::generateId();
+        // 级别
+        $message['stance'] = $message['stance'] ?? 2;
+        // 类型
+        $message['brand'] = $message['brand'] ?? 'OTA';
         // 日志入库
-        Tool::alarmCall($message);
+//        Tool::alarmCall($message);
         // 日志写文件
         LoggerTool::error($message);
 
@@ -32,8 +38,10 @@ class Alarm
                 $result = self::curl(json_encode($message));
                 if ($result['code'] != 200) {
                     LoggerTool::error(['预警信息上报平台失败. traceId【' . $message['trace-id'] . '】', $result]);
+                    return false;
                 }
             }
+            LoggerTool::notice(['信息推送预警平台成功.',  'platformID: .' . $message['platform-id'], 'traceID: . ' . $message['trace-id']]);
         } else {
             $reason = '';
             if ($reportAlarmOpen == '0') {

+ 2 - 0
common/helpers/Tool.php

@@ -578,6 +578,8 @@ class Tool {
     {
         try {
             $model = new AlarmCall();
+            $model->brand = $call['brand'];
+            $model->stance = $call['stance'];
             $model->trace_id = $call['trace-id'];
             $model->content = $call;
             $model->insert();

+ 2 - 0
common/messages/en-US/app.php

@@ -215,6 +215,8 @@ return [
     'brandAmbassadorUpgradeError' => 'Brand Ambassador upgrade error',
     'changeUserStatusError' => 'change user status error',
     'dataFormatError' => 'Data format error',
+    'decUserNameDoesNotExist' => '请输入报单中心编号',
+    'decUserNameIsWrong' => '报单中心编号输入错误',
 
 
 

+ 3 - 1
common/messages/zh-CN/app.php

@@ -219,6 +219,8 @@ return [
     'membersExchangePointPayment' => '会员复销积分兑换',
     'brandAmbassadorUpgradeError' => 'BA会员升级错误',
     'changeUserStatusError' => '修改会员状态错误',
+    'decUserNameDoesNotExist' => '请输入报单中心编号',
+    'decUserNameIsWrong' => '报单中心编号输入错误',
 
 
     # 奖金
@@ -311,4 +313,4 @@ return [
     'invalidParameter' => '无效参数',
     'dataDoesNotExists' => '数据不存在',
 
-];
+];

+ 6 - 1
common/models/AlarmCall.php

@@ -12,7 +12,8 @@ use yii\base\InvalidConfigException;
  * @property \MongoDB\BSON\ObjectID|string $_id
  * @property string $trace_id 堆栈ID
  * @property mixed $content 内容
-
+ * @property string $brand 类型
+ * @property string $stance 级别
  */
 class AlarmCall extends MongoActiveRecord
 {
@@ -48,6 +49,8 @@ class AlarmCall extends MongoActiveRecord
         return [
             '_id',
             'trace_id',
+            'brand',
+            'stance',
             'content',
         ];
     }
@@ -61,6 +64,8 @@ class AlarmCall extends MongoActiveRecord
             '_id' => 'objectID',
             'trace_id' => 'trace_id',
             'content' => 'content',
+            'brand' => 'brand',
+            'stance' => 'stance',
         ];
     }
 

+ 3 - 2
common/models/ApproachOrder.php

@@ -70,10 +70,10 @@ class ApproachOrder extends \common\components\ActiveRecord
     public function rules()
     {
         return [
-            [['USER_ID', 'USER_NAME', 'ORDER_TYPE', 'CREATE_USER'], 'required'],
+            [['USER_ID',  'ORDER_TYPE', 'CREATE_USER'], 'required'],
             [['ORDER_AMOUNT', 'PV', 'PAY_AMOUNT', 'PAY_PV', 'FREIGHT', 'PAY_FREIGHT'], 'number'],
             [['PAY_AT', 'DELIVERY_STATUS', 'DELIVERY_PERIOD', 'DELIVERY_AT', 'EXPRESS_TYPE', 'PERIOD_NUM', 'STATUS', 'PROVINCE', 'CITY', 'COUNTY', 'CREATED_AT', 'UPDATED_AT', 'IS_DELETE', 'DELETED_AT'], 'integer'],
-            [['ID','SN', 'DEC_SN', 'USER_ID', 'ORDER_TRACK_NO','PAY_TYPE'], 'string', 'max' => 32],
+            [['ID','SN', 'DEC_SN', 'USER_ID', 'ORDER_TRACK_NO','PAY_TYPE','DEC_USER_ID'], 'string', 'max' => 32],
             [['USER_NAME', 'TEL', 'CREATE_USER', 'UPDATER', 'WAREHOUSE'], 'string', 'max' => 16],
             [['ORDER_TYPE'], 'string', 'max' => 12],
             [['EXPRESS_COMPANY'], 'string', 'max' => 128],
@@ -97,6 +97,7 @@ class ApproachOrder extends \common\components\ActiveRecord
             'DEC_SN' => '报单编号',
             'USER_ID' => '用户ID',
             'USER_NAME' => '会员编号',
+            'DEC_USER_ID' => '报单中心编号',
             'ORDER_TYPE' => '订货类型',
             'ORDER_AMOUNT' => '订单总价格',
             'PV' => '订货BV',

+ 1 - 1
common/models/DecOrder.php

@@ -47,7 +47,7 @@ class DecOrder extends \common\components\ActiveRecord
     public function rules()
     {
         return [
-            [['USER_ID', 'TO_USER_ID','REC_USER_ID','CON_USER_ID','DEC_ID', 'TYPE', 'PAID_WALLET', 'PERIOD_NUM', 'P_CALC_MONTH', 'CREATED_AT'], 'required'],
+            [['USER_ID', 'TO_USER_ID','REC_USER_ID','CON_USER_ID',/*'DEC_ID',*/ 'TYPE', 'PAID_WALLET', 'PERIOD_NUM', 'P_CALC_MONTH', 'CREATED_AT'], 'required'],
             [['IS_ADMIN', 'IS_BATCH', 'PERIOD_NUM', 'CALC_MONTH', 'CREATED_AT', 'IS_DEL', 'DELETED_AT'], 'integer'],
             [['DEC_AMOUNT', 'DEC_PV'], 'number'],
             [['ID', 'DEC_SN', 'ORDER_SN', 'USER_ID', 'TO_USER_ID','REC_USER_ID','CON_USER_ID','DEC_ID', 'TYPE', 'UPDATER', 'UPDATED_AT'], 'string', 'max' => 32],

+ 4 - 2
common/models/Order.php

@@ -12,6 +12,7 @@ use Yii;
  * @property string $DEC_SN 报单编号
  * @property string $USER_ID 用户ID
  * @property string $USER_NAME 会员编号
+ * @property string $DEC_USER_ID  会员编号
  * @property string $ORDER_TYPE 订货类型
  * @property string $ORDER_AMOUNT 订单总价格(n)
  * @property string $ORDER_AMOUNT_STANDARD 订单总价格($)
@@ -70,10 +71,10 @@ class Order extends \common\components\ActiveRecord
     public function rules()
     {
         return [
-            [['USER_ID', 'USER_NAME', 'ORDER_TYPE', 'CREATE_USER'/*, 'EMAIL'*/], 'required'],
+            [['USER_ID', 'ORDER_TYPE', 'CREATE_USER'/*, 'EMAIL'*/], 'required'],
             [['ORDER_AMOUNT', 'PV', 'PAY_AMOUNT', 'PAY_PV', 'FREIGHT', 'PAY_FREIGHT', 'ORDER_AMOUNT_STANDARD', 'PAY_AMOUNT_STANDARD', 'EXCHANGE_RATE'], 'number'],
             [['PAY_AT', 'DELIVERY_STATUS', 'DELIVERY_PERIOD', 'DELIVERY_AT', 'EXPRESS_TYPE', 'PERIOD_NUM', 'STATUS', 'PROVINCE', /*'CITY', 'COUNTY', */'CREATED_AT', 'UPDATED_AT', 'IS_DELETE', 'DELETED_AT'], 'integer'],
-            [['ID','SN', 'DEC_SN', 'USER_ID', 'ORDER_TRACK_NO','PAY_TYPE'], 'string', 'max' => 32],
+            [['ID','SN', 'DEC_SN', 'USER_ID', 'ORDER_TRACK_NO','PAY_TYPE','DEC_USER_ID'], 'string', 'max' => 32],
             [['USER_NAME', 'TEL', 'CREATE_USER', 'UPDATER', 'WAREHOUSE'], 'string', 'max' => 16],
             [['ORDER_TYPE'], 'string', 'max' => 12],
             [['EXPRESS_COMPANY'], 'string', 'max' => 128],
@@ -97,6 +98,7 @@ class Order extends \common\components\ActiveRecord
             'DEC_SN' => '报单编号',
             'USER_ID' => '用户ID',
             'USER_NAME' => '会员编号',
+            'DEC_USER_ID' => '报单中心编号',
             'ORDER_TYPE' => '订货类型',
             'ORDER_AMOUNT' => '订单总价格',
             'PV' => '订货BV',

+ 2 - 1
common/models/Period.php

@@ -183,7 +183,8 @@ class Period extends \common\components\ActiveRecord
     }
 
     public function getTeamsPeriodNum(){
-        $this->nowPeriodArr = static::find()->where('IS_CLOSED=1 AND IS_SENT=0')->orderBy('PERIOD_NUM ASC')->asArray()->one();
+//        $this->nowPeriodArr = static::find()->where('IS_CLOSED=1 AND IS_SENT=0')->orderBy('PERIOD_NUM ASC')->asArray()->one();
+        $this->nowPeriodArr = static::find()->where('IS_SENT=0')->orderBy('PERIOD_NUM ASC')->asArray()->one();
         if($this->nowPeriodArr){
             $this->setPeriodNum($this->nowPeriodArr['PERIOD_NUM']);
             return $this->nowPeriodArr['PERIOD_NUM'];

+ 21 - 18
common/models/forms/ApproachDeclarationForm.php

@@ -127,7 +127,7 @@ class ApproachDeclarationForm extends Model
     {
         return [
             [['type','decLv','decWay','packageId', 'insertUserName', 'realName',/* 'insertUserIdCard',*/ 'mobile', 'address', 'openBank', 'bankAddress', 'bankNo','bankProvince','bankCity','bankCounty','consignee','acceptMobile','province','city','county','cityName','lgaName','decUserName', 'conUserName', 'recUserName', 'location'], 'trim'],
-            [['type','decLv','decWay','insertUserName',/* 'insertUserIdCard',*/'password','payPassword','decUserName'], 'required'],
+            [['type','decLv','decWay','insertUserName',/* 'insertUserIdCard',*/'password','payPassword'], 'required'],
             [['type'], 'isType', 'on'=>['userDec', 'canDec']],
             [['insertUserName'], 'isCanAddUser'],
             [['decUserName', 'decType'], 'issetDec'],
@@ -196,24 +196,28 @@ class ApproachDeclarationForm extends Model
      * @param $attribute
      */
     public function issetDec($attribute){
-        if (!$decUser = User::find()->select('ID')->where('IS_DEC=1 AND USER_NAME=:USER_NAME', [':USER_NAME' => $this->decUserName])->asArray()->one()) {
-            $this->addError($attribute, Yii::t('app', 'stockistDoesNotExist'));
-            return false;
+        if(!$this->decUserName){
+            $this->_decId = '';
         } else {
-            if ($this->decType !== 'ba') {
-                // 判断报单中心是否在新加入会员的安置网上级中
-                $this->loopFindParentToNetwork($this->insertUserName);
-                //反转数组,in_array搜索错误
-                //in_array($this->decUserName, $this->_tempNetworkParentUser[$this->insertUserName]);
-                $flipParent = array_flip(array_filter($this->_tempNetworkParentUser[$this->insertUserName]));
-                if (!isset($flipParent[$this->decUserName])) {
-                    //$this->addError($attribute, '为' . $this->insertUserName . '报单,报单中心' . $this->decUserName . '不在' . $this->insertUserName . '的安置网上级中');
-                    $this->addError($attribute, 'To' . $this->insertUserName . 'Entry, Stockist' . $this->decUserName . 'not in exist' . $this->insertUserName . 'in the placement superiors');
-                    return ;
+            if (!$decUser = User::find()->select('ID')->where('IS_DEC=1 AND USER_NAME=:USER_NAME', [':USER_NAME' => $this->decUserName])->asArray()->one()) {
+                $this->addError($attribute, Yii::t('app', 'stockistDoesNotExist'));
+                return false;
+            } else {
+                if ($this->decType !== 'ba') {
+                    // 判断报单中心是否在新加入会员的安置网上级中
+                    $this->loopFindParentToNetwork($this->insertUserName);
+                    //反转数组,in_array搜索错误
+                    //in_array($this->decUserName, $this->_tempNetworkParentUser[$this->insertUserName]);
+                    $flipParent = array_flip(array_filter($this->_tempNetworkParentUser[$this->insertUserName]));
+//                    if (!isset($flipParent[$this->decUserName])) {
+//                        //$this->addError($attribute, '为' . $this->insertUserName . '报单,报单中心' . $this->decUserName . '不在' . $this->insertUserName . '的安置网上级中');
+//                        $this->addError($attribute, 'To' . $this->insertUserName . 'Entry, Stockist' . $this->decUserName . 'not in exist' . $this->insertUserName . 'in the placement superiors');
+//                        return ;
+//                    }
                 }
-            }
 
-            $this->_decId = $decUser['ID'];
+                $this->_decId = $decUser['ID'];
+            }
         }
     }
 
@@ -770,11 +774,9 @@ class ApproachDeclarationForm extends Model
         $user->VERIFIED = 1;
         $user->VERIFIED_AT = Date::nowTime();
         $user->IS_RECHARGE = 1;
-
         if (!$user->save()) {
             throw new Exception(Form::formatErrorsForApi($user->getErrors()));
         }
-
         $this->_insertUserId = $user->ID;
         $userForm = new UserForm();
         $this->_userForm = $userForm;
@@ -846,6 +848,7 @@ class ApproachDeclarationForm extends Model
         $orderModel = new ApproachOrder();
         $orderModel->SN = 'OS' . $ord;
         $orderModel->DEC_SN = 'DS' . $ord;
+        $orderModel->DEC_USER_ID = $this->_decId;
         $orderModel->ORDER_TYPE = $this->type;
         $orderModel->USER_ID = $this->_insertUserId;
         $orderModel->USER_NAME = $this->insertUserName;

+ 1 - 3
common/models/forms/ApproachDeclarationLoopForm.php

@@ -177,7 +177,6 @@ class ApproachDeclarationLoopForm extends Model
                     }
 
                 }
-				
                 if (is_array($value)) {
                     foreach($value as $key=>$decFormData){
                         $model->$key = $decFormData;
@@ -194,6 +193,7 @@ class ApproachDeclarationLoopForm extends Model
                     }
 
                     $result = $model->add($this->data);
+                    
                     if(!$result){
                         throw new Exception(Form::formatErrorsForApi($model->getErrors()));
                     }
@@ -201,9 +201,7 @@ class ApproachDeclarationLoopForm extends Model
                     throw new Exception(Yii::t('app', 'reportFormatIncorrect'));
                 }
             }
-
             $transaction->commit();
-
             return $result;
         } catch (\Exception $e){
             $transaction->rollBack();

+ 4 - 1
common/models/forms/ApproachOrderForm.php

@@ -1,6 +1,7 @@
 <?php
 namespace common\models\forms;
 
+use Codeception\Module\Db;
 use common\helpers\Cache;
 use common\helpers\Date;
 use common\components\Model;
@@ -51,6 +52,7 @@ class ApproachOrderForm extends Model
     public $email;
 
     public $userName;
+    public $decUserName;
     public $consignee;
     public $acceptMobile;
     public $province;
@@ -68,6 +70,7 @@ class ApproachOrderForm extends Model
     private $_orderGoods;
     private $_standardAmount;
     private $_decAmountStandard;
+    private $_userName;
 
     /**
      * @var ApproachOrder
@@ -405,7 +408,6 @@ class ApproachOrderForm extends Model
         if(!$this->validate()){
             return null;
         }
-
         $ids = $this->goodsId;
         $totalAmount = 0;
         $totalPv = 0;
@@ -556,6 +558,7 @@ class ApproachOrderForm extends Model
         $orderModel->ORDER_TYPE = $this->type;
         $orderModel->USER_ID = $userId;
         $orderModel->USER_NAME = $userName;
+        $orderModel->DEC_USER_ID = $this->decUserName;
         $orderModel->ORDER_AMOUNT = $this->_decAmount;
         $orderModel->PV = $_hasPV;
         $orderModel->PAY_AMOUNT = $this->_payAmount;

+ 21 - 15
common/models/forms/DeclarationForm.php

@@ -123,7 +123,7 @@ class DeclarationForm extends Model
     {
         return [
             [['type','decLv','decWay','packageId', 'insertUserName', 'realName',/* 'insertUserIdCard',*/ 'mobile', 'address', 'openBank', 'bankAddress', 'bankNo','bankProvince','bankCity','bankCounty','consignee','acceptMobile','province','city','county','cityName','lgaName','decUserName', 'conUserName', 'recUserName', 'location'], 'trim'],
-            [['type','decLv','decWay','insertUserName',/* 'insertUserIdCard',*/'password','payPassword','decUserName'], 'required'],
+            [['type','decLv','decWay','insertUserName',/* 'insertUserIdCard',*/'password','payPassword'], 'required'],
             [['type'], 'isType', 'on'=>['userDec', 'canDec']],
             [['insertUserName'], 'isCanAddUser'],
             [['decUserName'], 'issetDec'],
@@ -192,26 +192,32 @@ class DeclarationForm extends Model
      * @param $attribute
      */
     public function issetDec($attribute){
-        if (!$decUser = User::find()->select('ID')->where('IS_DEC=1 AND USER_NAME=:USER_NAME', [':USER_NAME' => $this->decUserName])->asArray()->one()) {
-            $this->addError($attribute, Yii::t('app', 'stockistDoesNotExist'));
-            return false;
+        if(!$this->decUserName){
+            $this->_decId = '';
         } else {
-            if ($this->decType !== 'ba') {
-                // 判断报单中心是否在新加入会员的安置网上级中
-                $this->loopFindParentToNetwork($this->insertUserName);
-                //反转数组,in_array搜索错误
-                //in_array($this->decUserName, $this->_tempNetworkParentUser[$this->insertUserName]);
-                $flipParent = array_flip(array_filter($this->_tempNetworkParentUser[$this->insertUserName]));
+
+
+            if (!$decUser = User::find()->select('ID')->where('IS_DEC=1 AND USER_NAME=:USER_NAME', [':USER_NAME' => $this->decUserName])->asArray()->one()) {
+                $this->addError($attribute, Yii::t('app', 'stockistDoesNotExist'));
+                return false;
+            } else {
+                if ($this->decType !== 'ba') {
+                    // 判断报单中心是否在新加入会员的安置网上级中
+                    $this->loopFindParentToNetwork($this->insertUserName);
+                    //反转数组,in_array搜索错误
+                    //in_array($this->decUserName, $this->_tempNetworkParentUser[$this->insertUserName]);
+                    $flipParent = array_flip(array_filter($this->_tempNetworkParentUser[$this->insertUserName]));
 //            var_dump($flipParent);
 //            echo $this->insertUserName.'=='.$this->decUserName;
 //            exit;
-                if (!isset($flipParent[$this->decUserName])) {
-                    //$this->addError($attribute, '为' . $this->insertUserName . '报单,报单中心' . $this->decUserName . '不在' . $this->insertUserName . '的安置网上级中');
-                    $this->addError($attribute, 'To' . $this->insertUserName . 'Entry, Stockist' . $this->decUserName . 'not in exist' . $this->insertUserName . 'in the placement superiors');
-                    return ;
+//                    if (!isset($flipParent[$this->decUserName])) {
+//                        //$this->addError($attribute, '为' . $this->insertUserName . '报单,报单中心' . $this->decUserName . '不在' . $this->insertUserName . '的安置网上级中');
+//                        $this->addError($attribute, 'To' . $this->insertUserName . 'Entry, Stockist' . $this->decUserName . 'not in exist' . $this->insertUserName . 'in the placement superiors');
+//                        return;
+//                    }
                 }
+                $this->_decId = $decUser['ID'];
             }
-            $this->_decId = $decUser['ID'];
         }
     }
 

+ 14 - 2
common/models/forms/OrderForm.php

@@ -46,6 +46,7 @@ class OrderForm extends Model
     public $email;
 
     public $userName;
+    public $decUserName;
     public $consignee;
     public $acceptMobile;
     public $province;
@@ -86,7 +87,7 @@ class OrderForm extends Model
     {
         return [
             [['sn', 'expressCompany', 'orderTrackNo', 'status', 'remark','type','addressId','payType','goodsId','goodsNum', 'payPassword','userName','consignee','acceptMobile','province'/*,'city','county'*/,'cityName','lgaName','detailaddress','email'], 'trim'],
-            [['sn', 'expressCompany', 'orderTrackNo', 'status', 'remark','type','addressId','payType','goodsId','goodsNum', 'payPassword','userName','consignee','acceptMobile','province','city','county','detailaddress'/*,'email'*/], 'required'],
+            [['sn', 'expressCompany', 'orderTrackNo', 'status', 'remark','type','addressId','payType','goodsId','goodsNum', 'payPassword','consignee','acceptMobile','province','city','county','detailaddress'/*,'email'*/], 'required'],
             [['status'], 'isStatus'],
             [['addressId'], 'isAddress'],
             [['payType'], 'isPayType'],
@@ -716,6 +717,7 @@ class OrderForm extends Model
         $orderModel->ORDER_TYPE = $this->type;
         $orderModel->USER_ID = $userId;
         $orderModel->USER_NAME = $userName;
+        $orderModel->DEC_USER_ID = $this->decUserName;;
         $orderModel->ORDER_AMOUNT = $this->_decAmount;
         $orderModel->PV = $_hasPV;
         $orderModel->PAY_AMOUNT = $this->_payAmount;
@@ -844,6 +846,7 @@ class OrderForm extends Model
         $goodsType = ShopGoods::getGoodType();
         $hasInstalment = 0;
         $userId = Info::getUserIdByUserName($this->userName);
+        $exchangeRate = floatval(Cache::getSystemConfig()['exchangeRate']['VALUE'] ?? 0); // 汇率
         foreach ($this->goodsNum as $k => $v) {
             if ($v) {
                 $goods = ShopGoods::findOneAsArray('ID=:ID AND STATUS=1',[':ID'=> $ids[$k]]);
@@ -855,10 +858,12 @@ class OrderForm extends Model
                         $discount = $goodsType[$goods['TYPE']]['discount'];
                         $realPrice = $goods['SELL_PRICE'] * $discount/100;
                         $realPv = $goods['PRICE_PV'] * $discount/100;
+                        $realPriceStandard = $goods['SELL_PRICE_STANDARD'] * $discount/100;
                     } else {
                         $discount = $goods['SELL_DISCOUNT'];
                         $realPrice = $goods['SELL_PRICE'] * $discount;
                         $realPv = $goods['PRICE_PV'] * $discount;
+                        $realPriceStandard = $goods['SELL_PRICE_STANDARD'] * $discount;
                     }
                     $totalAmount += $realPrice * intval($v);
                     $totalPv += $realPv * intval($v);
@@ -871,7 +876,14 @@ class OrderForm extends Model
                         'POINT' => $goods['POINT'],
                         'BUY_NUMS' => intval($v),
                         'SKU_CODE' => $goods['GOODS_NO'],
-                        'GOODS_TITLE' => $goods['GOODS_NAME']
+                        'GOODS_TITLE' => $goods['GOODS_NAME'],
+                        'STANDARD_PRICE' => $goods['SELL_PRICE_STANDARD'],
+                        'TAX_RATE' => $goods['TAX_RATE'],
+                        'CATEGORY_TYPE' => $goods['CATEGORY_TYPE'],
+                        'PAY_TYPE' => $this->payType ?? '',
+                        'EMAIL' => $this->email ?? '',
+                        'REAL_STANDARD_PRICE' => $realPriceStandard,
+                        'EXCHANGE_RATE' => $exchangeRate,
                     ];
                 }
                 if($goods['INSTALMENT']>0){ // 如果有分期付款商品,检查用户的分期付款状态

+ 1 - 1
common/models/forms/OrderPeriodAdjustForm.php

@@ -148,7 +148,7 @@ class OrderPeriodAdjustForm extends Model
             // 写入调整记录
             $orderModel = new OrderPeriodAdjust();
             $orderModel->ORDER_SN = $this->orderSn;
-            $orderModel->DEC_SN = $this->order->DEC_SN ?? '';
+            //$orderModel->DEC_SN = $this->order->DEC_SN ?? '';
             $orderModel->ORIGIN_PERIOD = $this->order->PERIOD_NUM;
             $orderModel->MODERN_PERIOD = $this->modernPeriod;
             $orderModel->ADMIN_ID = Admin::getAdminNameById(\Yii::$app->user->id);

+ 2 - 2
frontendApi/config/menu.php

@@ -39,7 +39,7 @@ return [
         'show'=>1,
         'wiki' => 'memberManagement',
         'child'=>[
-            ['name'=>'Member Welcome Pack', 'class'=>'', 'icon'=>'', 'controller'=>'user', 'action'=>'dec', 'routePath'=>'user/dec', 'show'=>1, 'allow'=>'declarer', 'wiki' => 'welcomePack',], // 会员报单
+            ['name'=>'Member Welcome Pack', 'class'=>'', 'icon'=>'', 'controller'=>'user', 'action'=>'dec', 'routePath'=>'user/dec', 'show'=>1,  'wiki' => 'welcomePack',], // 会员报单
             ['name'=>'Member Repeat Purchase', 'class'=>'', 'icon'=>'', 'controller'=>'user', 'action'=>'reconsume', 'routePath'=>'shop/reconsume', 'show'=>1, 'allow'=>'declarer','wiki' => 'memberRepeatPurchase',],//会员复消
             ['name'=>'Member Upgrade', 'class'=>'', 'icon'=>'', 'controller'=>'user', 'action'=>'dec', 'routePath'=>'user/upgrade', 'show'=>1,'allow'=>'declarer', 'wiki' => 'memberUpgrade',],//会员升级
             ['name'=>'Member Order', 'class'=>'', 'icon'=>'', 'controller'=>'user', 'action'=>'member-order', 'routePath'=>'shop/member-order', 'show'=>1, 'wiki' => 'memberOrder',],//会员订单
@@ -113,4 +113,4 @@ return [
 //            ['name'=>'Reset Password', 'class'=>'', 'icon'=>'', 'controller'=>'user', 'action'=>'password', 'routePath'=>'user/password', 'show'=>1, 'wiki' => 'resetPassword',],//重设密码
         ]
     ],
-];
+];

+ 6 - 6
frontendApi/modules/v1/controllers/BaController.php

@@ -232,7 +232,7 @@ class BaController extends BaseController {
         // 获取系统中的DEC 报单级别配置
         $decConfig = Cache::getDecLevelConfig();
         $userDecInfo = $decConfig[$userDecId]; // 会员的级别具体信息
-        $maxPerfInfo = DeclarationLevel::getMaxDecPref(); 
+        $maxPerfInfo = DeclarationLevel::getMaxDecPref();
         $maxDecId = $maxPerfInfo['ID']; // 级别配置中最高级别ID
         $observe = Config::getConfigByType('observe'); // 获取观察期配置信息
         $observeLimit = $observe['observePeriodLimit']['value']; // 月份限制
@@ -251,7 +251,7 @@ class BaController extends BaseController {
             'IS_OBSERVE' => $isObserve, // 是否是观察期  true为是观察期
             'IS_MAX' => $isMax, // 是否已是最大级别 最大级别不需要判断报单总PV是多少 只展示基本信息
         ];
-        
+
         // 如果是最高级别了,则无需升级
         if ($isMax) {
             return static::notice(['baseInfo' => $userInfo]);
@@ -282,12 +282,12 @@ class BaController extends BaseController {
             // 循环列表,补充升级所需要的补差
             foreach ($userInfo['LEVEL_LIST'] as &$v) {
                 $v['REPAIR_PV'] = $isObserve ? $v['PERF'] - $userInfo['NOW_PERF'] : $v['PERF'];
-            }   
+            }
         }
-        
+
         return static::notice(['baseInfo' => $userInfo]);
     }
-    
+
     // 会员升级管理
     public function actionUpgrade() {
         $isSwitchUpgrade = Config::find()
@@ -576,4 +576,4 @@ class BaController extends BaseController {
 
         return static::notice(Yii::t('app', 'illegalRequest'), 400);
     }
-}
+}

+ 36 - 1
frontendApi/modules/v1/controllers/ShopController.php

@@ -135,7 +135,7 @@ class ShopController extends BaseController {
         $freight = floatval(Cache::getSystemConfig()['freight']['VALUE'] ?? 0);
         // 普通商品免运费阈值.奈拉
         $freeShipping = floatval(Cache::getSystemConfig()['freeShipping']['VALUE'] ?? 0);
-
+        $isDec = User::getEnCodeInfo(\Yii::$app->user->id)['IS_DEC'];
         return static::notice(
             [
                 'payList'=>$payList,
@@ -144,6 +144,7 @@ class ShopController extends BaseController {
                 'sellType' => ShopGoods::getCategoryType(),
                 'freight' => $freight,
                 'freeShipping' => $freeShipping,
+                'isDec' => $isDec,
             ]);
     }
 
@@ -157,6 +158,24 @@ 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']){
+                return static::notice(Yii::t('app', 'stockistDoesNotExist'), 400);
+            }
+            if($userName && $userInfo['IS_DEC'] == 0){
+                //查询报单编号是否存在
+                $userId = Info::getUserIdByUserName($userName);
+                if(!$userId){
+                    return static::notice(Yii::t('app', 'stockistDoesNotExist'), 400);
+                }
+                $isDec = User::getEnCodeInfo($userId)['IS_DEC'];
+                if(!$isDec){
+                    return static::notice(Yii::t('app', 'decUserNameIsWrong'), 400);
+                }
+            }
+
+            $formModel->decUserName = $userName;
             if ($formModel->load($post, '') && $order = $formModel->add()) {
                 return static::notice($order);
             } else {
@@ -188,6 +207,22 @@ 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']){
+                return static::notice(Yii::t('app', 'stockistDoesNotExist'), 400);
+            }
+            //查询报单编号是否存在
+            if($post['userName'] && $userInfo['IS_DEC'] == 0){
+                $userId = Info::getUserIdByUserName($post['userName']);
+                if(!$userId){
+                    return static::notice(Yii::t('app', 'stockistDoesNotExist'), 400);
+                }
+                $isDec = User::getEnCodeInfo($userId)['IS_DEC'];
+                if(!$isDec){
+                    return static::notice(Yii::t('app', 'decUserNameIsWrong'), 400);
+                }
+            }
+            $formModel->decUserName = $post['userName'];
             if ($formModel->load($post, '') && $order = $formModel->add()) {
                 return static::notice($order);
             } else {

+ 13 - 9
frontendApi/modules/v1/controllers/SiteController.php

@@ -7,6 +7,7 @@
  */
 namespace frontendApi\modules\v1\controllers;
 
+use common\helpers\Alarm;
 use common\helpers\Cache;
 use common\helpers\LoggerTool;
 use common\helpers\snowflake\PageSnowFake;
@@ -246,16 +247,16 @@ class SiteController extends BaseController
         }
 
         if($menu['allow']=='pastBonusSwitch'){
-            $pastBonusSwitch = isset(Cache::getSystemConfig()['pastBonusSwitch']) 
-                ? Cache::getSystemConfig()['pastBonusSwitch']['VALUE'] 
+            $pastBonusSwitch = isset(Cache::getSystemConfig()['pastBonusSwitch'])
+                ? Cache::getSystemConfig()['pastBonusSwitch']['VALUE']
                 : '';
             if($pastBonusSwitch) return false;
         }
 
         if($menu['allow']=='newBonusSwitch'){
-            // ??? 
-            $newBonusSwitch = isset(Cache::getSystemConfig()['newBonusSwitch']) 
-                ? Cache::getSystemConfig()['newBonusSwitch']['VALUE'] 
+            // ???
+            $newBonusSwitch = isset(Cache::getSystemConfig()['newBonusSwitch'])
+                ? Cache::getSystemConfig()['newBonusSwitch']['VALUE']
                 : '';
             if($newBonusSwitch) return false;
         }
@@ -373,9 +374,12 @@ class SiteController extends BaseController
 
     public function actionSendNotify()
     {
-        $message = Yii::$app->request->get('message', '收到信息了');
-        $data = ['message' => $message];
+        Alarm::reportAlarm([
+            'stance' => 1,
+            'brand' => 'OTA',
+            'message' => '预警信息测试',
+        ]);
 
-        return static::notice($data);
+        return static::notice('成功', 0);
     }
-}
+}

+ 17 - 2
frontendApi/modules/v1/controllers/UserController.php

@@ -385,8 +385,22 @@ class UserController extends BaseController {
         $userName = Info::generateWebUserName('NG',9);
         $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']){
+                return static::notice(Yii::t('app', 'decUserNameIsWrong'), 400);
+            }
+            if($userInfo['IS_DEC'] == 0 && $post['decUserName']){
+                //查询报单编号是否存在
+                $userId = Info::getUserIdByUserName($post['decUserName']);
+                if(!$userId){
+                    return static::notice(Yii::t('app', 'decUserNameIsWrong'), 400);
+                }
+                $isDec = User::getEnCodeInfo($userId)['IS_DEC'];
+                if(!$isDec){
+                    return static::notice(Yii::t('app', 'decUserNameIsWrong'), 400);
+                }
+            }
             // 根据支付方式区分逻辑
             $payMethod = \Yii::$app->request->post('payType', '');
 
@@ -458,7 +472,7 @@ class UserController extends BaseController {
         // 所有开户行
         $allOpenBank = OpenBank::find()->where('STATUS=1')->orderBy('LIST_ORDER ASC')->asArray()->all();
         if (!$userName) {
-            return static::notice(Yii::t('app', 'failedToGenerateMemberNumber'), 400);
+            return static::notice(Yii::t('app',  'failedToGenerateMemberNumber'), 400);
         }
         //随机码保存在redis中方便进行比对
         $redis->setex('key_'.$userName , 3600 , $userName);
@@ -479,6 +493,7 @@ class UserController extends BaseController {
             'sellType' => ShopGoods::getCategoryType(),
             'categoryType' => ShopGoods::getCategoryType()[0]['id'],
             'userBalance' => $userBalance,
+            'isDec' => $isDec,
         ]);
     }
 

+ 0 - 2
frontendApi/runtime/.gitignore

@@ -1,2 +0,0 @@
-*
-!.gitignore

+ 3 - 1
vendor/yiisoft/yii2/web/ErrorHandler.php

@@ -151,10 +151,12 @@ class ErrorHandler extends \yii\base\ErrorHandler
             $exception = new HttpException(500, Yii::t('yii', 'An internal server error occurred.'));
         }
 
-        $errorOutline = ['AR_', 'PHP', 'Undefined', 'Undefined index', 'SQLSTATE', 'Trying to access array offset on value of type null'];
+        $errorOutline = ['AR_', 'PHP', 'Undefined', 'Undefined index', 'SQLSTATE', 'Trying to access array offset on value of type null', 'unknown property'];
         foreach ($errorOutline as $item) {
             if (false !== strpos($exception->getMessage(), $item)) {
                 $it = [
+                    'stance' => 4,
+                    'brand' => in_array($item, ['AR_', 'SQLSTATE']) ? 'SQL' : 'API',
                     'name' => ($exception instanceof Exception || $exception instanceof ErrorException) ? $exception->getName() : 'Exception',
                     'message' => '(NG)提醒:' . $exception->getMessage(),
                     'code' => $exception->getCode(),