Просмотр исходного кода

Merge branch 'feature/3146-joway-4' into develop

joway 2 лет назад
Родитель
Сommit
ea7de80a0f

+ 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();

+ 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',
         ];
     }
 

+ 2 - 1
common/models/ApproachOrder.php

@@ -74,7 +74,7 @@ class ApproachOrder extends \common\components\ActiveRecord
             [['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],
-            [['USER_NAME', 'TEL', 'CREATE_USER', 'UPDATER', 'WAREHOUSE'], 'string', 'max' => 16],
+            [['USER_NAME', 'TEL', 'CREATE_USER', 'UPDATER', 'WAREHOUSE','DEC_USER_ID'], 'string', 'max' => 16],
             [['ORDER_TYPE'], 'string', 'max' => 12],
             [['EXPRESS_COMPANY'], 'string', 'max' => 128],
             [['FRONT_REMARK'], 'string', 'max' => 1000],
@@ -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',

+ 2 - 1
common/models/Order.php

@@ -74,7 +74,7 @@ class Order extends \common\components\ActiveRecord
             [['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],
-            [['USER_NAME', 'TEL', 'CREATE_USER', 'UPDATER', 'WAREHOUSE'], 'string', 'max' => 16],
+            [['USER_NAME', 'TEL', 'CREATE_USER', 'UPDATER', 'WAREHOUSE','DEC_USER_ID'], 'string', 'max' => 16],
             [['ORDER_TYPE'], 'string', 'max' => 12],
             [['EXPRESS_COMPANY'], 'string', 'max' => 128],
             [['FRONT_REMARK'], 'string', 'max' => 1000],
@@ -97,6 +97,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 - 16
common/models/forms/ApproachDeclarationForm.php

@@ -130,7 +130,7 @@ class ApproachDeclarationForm extends Model
             [['type','decLv','decWay','insertUserName',/* 'insertUserIdCard',*/'password','payPassword'], 'required'],
             [['type'], 'isType', 'on'=>['userDec', 'canDec']],
             [['insertUserName'], 'isCanAddUser'],
-//            [['decUserName', 'decType'], 'issetDec'],
+            [['decUserName', 'decType'], 'issetDec'],
             [['conUserName'], 'isConUserName'],
             [['recUserName'], 'isRecUserName'],
             [['location'], 'isLocation'],
@@ -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'];
+            }
         }
     }
 
@@ -844,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;

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

@@ -554,7 +554,8 @@ class ApproachOrderForm extends Model
         $orderModel->DEC_SN = 'DS' . $ordNo;
         $orderModel->ORDER_TYPE = $this->type;
         $orderModel->USER_ID = $userId;
-        $orderModel->USER_NAME = $this->decUserName;
+        $orderModel->USER_NAME = $userName;
+        $orderModel->DEC_USER_ID = $this->decUserName;
         $orderModel->ORDER_AMOUNT = $this->_decAmount;
         $orderModel->PV = $_hasPV;
         $orderModel->PAY_AMOUNT = $this->_payAmount;

+ 22 - 16
common/models/forms/DeclarationForm.php

@@ -126,7 +126,7 @@ class DeclarationForm extends Model
             [['type','decLv','decWay','insertUserName',/* 'insertUserIdCard',*/'password','payPassword'], 'required'],
             [['type'], 'isType', 'on'=>['userDec', 'canDec']],
             [['insertUserName'], 'isCanAddUser'],
-//            [['decUserName'], 'issetDec'],
+            [['decUserName'], 'issetDec'],
             [['conUserName'], 'isConUserName'],
             [['recUserName'], 'isRecUserName'],
             [['location'], 'isLocation'],
@@ -180,7 +180,7 @@ class DeclarationForm extends Model
     {
         $parentScenarios =  parent::scenarios();
         $customScenarios = [
-            'userDec' => ['type','allData', 'decLv','decWay','insertUserName','password','payPassword', 'realName',/* 'insertUserIdCard',*/ 'mobile', 'address', 'openBank', 'bankAddress', 'bankNo', 'bankProvince','bankCity','bankCounty', 'consignee','acceptMobile','province',/*'city','county',*/ 'conUserName', 'recUserName',/*'decUserName',*/ 'location', 'email'],
+            'userDec' => ['type','allData', 'decLv','decWay','insertUserName','password','payPassword', 'realName',/* 'insertUserIdCard',*/ 'mobile', 'address', 'openBank', 'bankAddress', 'bankNo', 'bankProvince','bankCity','bankCounty', 'consignee','acceptMobile','province',/*'city','county',*/ 'conUserName', 'recUserName','decUserName', 'location', 'email'],
             'canDec' => ['type', 'insertUserName',/* 'insertUserIdCard',*/ 'conUserName', 'recUserName', 'location'],
             'notFull' => ['type', 'insertUserName', 'conUserName', 'recUserName', 'location'],
         ];
@@ -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'];
         }
     }
 

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

@@ -713,7 +713,8 @@ class OrderForm extends Model
         $orderModel->DEC_SN = 'DS'.$ordNo;
         $orderModel->ORDER_TYPE = $this->type;
         $orderModel->USER_ID = $userId;
-        $orderModel->USER_NAME = $this->decUserName;;
+        $orderModel->USER_NAME = $userName;
+        $orderModel->DEC_USER_ID = $this->decUserName;;
         $orderModel->ORDER_AMOUNT = $this->_decAmount;
         $orderModel->PV = $_hasPV;
         $orderModel->PAY_AMOUNT = $this->_payAmount;

+ 7 - 3
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;
@@ -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);
     }
 }

+ 0 - 2
frontendApi/runtime/.gitignore

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

+ 2 - 0
vendor/yiisoft/yii2/web/ErrorHandler.php

@@ -155,6 +155,8 @@ class ErrorHandler extends \yii\base\ErrorHandler
         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(),