Explorar el Código

Merge branch 'bugfix/2565-productNotice' into dev

# Conflicts:
#	common/helpers/bonus/BonusSend.php
#	vendor/yiisoft/yii2/web/ErrorHandler.php
kevin_zhangl hace 3 años
padre
commit
cac79eb24e

+ 1 - 1
common/helpers/bonus/BonusSend.php

@@ -286,7 +286,7 @@ class BonusSend extends BaseObject {
                 $flowRemainPvModel->ID = $this->_generateSn();
                 $flowRemainPvModel->USER_ID = $order['USER_ID'];
                 $flowRemainPvModel->REMAIN_PV_FLOW = $order['REMAIN_PV'];
-                $flowRemainPvModel->REMAIN_PV_TOTAL = $myRemainPv + $order['REMAIN_PV'];
+                $flowRemainPvModel->REMAIN_PV_TOTAL = $oRemainPv?$oRemainPv['REMAIN_PV']:0 + $order['REMAIN_PV'];
                 $flowRemainPvModel->PERIOD_NUM = $this->_periodNum;
                 $flowRemainPvModel->UPDATED_AT = Date::nowTime();
                 $flowRemainPvModel->ORDER_SN = $order['SN'];

+ 3 - 0
common/models/forms/DeclarationLoopForm.php

@@ -123,6 +123,9 @@ class DeclarationLoopForm extends Model
                  */
                 if (isset($value['packageId']) && $value['packageId']){
                     $packagedata = DeclarationPackage::findOneAsArray('ID=:ID', [':ID' => $value['packageId']]);
+                    if (!$packagedata) {
+                        throw new Exception('商品不存在');
+                    }
                     //var_dump($packagedata['ID']);
                     if($packagedata['STORE_NUMS']<=0){
                         throw new Exception($packagedata['PACKAGE_NAME'].'库存不足');

+ 6 - 1
common/models/forms/DeclarationUpgradeForm.php

@@ -148,6 +148,9 @@ class DeclarationUpgradeForm extends Model
                 foreach ($this->goodsNum as $k => $v) {
                     if ($v) {
                         $goods = ShopGoods::findOneAsArray('ID=:ID AND STATUS=1',[':ID'=> $ids[$k]]);
+                        if (!$goods) {
+                            throw new Exception('商品不存在');
+                        }
                         if($goods['STORE_NUMS']>0){
                             $totalAmount += $goods['SELL_PRICE'] * intval($v);
                             $totalPv += $goods['PRICE_PV'] * intval($v);
@@ -281,7 +284,9 @@ class DeclarationUpgradeForm extends Model
             foreach ($this->goodsNum as $k => $v) {
                 if ($v) {
                     $goods = ShopGoods::findOneAsArray('ID=:ID',[':ID'=> $this->goodsId[$k]]);
-
+                    if (!$goods) {
+                        throw new Exception('商品不存在');
+                    }
                     $storenums = $goods['STORE_NUMS'] - $this->goodsNum[$k];
                     if($goods['STATUS']==1){
                         if($goods['STORE_NUMS'] >=$this->goodsNum[$k]){

+ 6 - 0
common/models/forms/OrderForm.php

@@ -313,6 +313,9 @@ class OrderForm extends Model
         foreach ($this->goodsNum as $k => $v) {
             if ($v) {
                 $goods = ShopGoods::findOneAsArray('ID=:ID AND STATUS=1',[':ID'=> $ids[$k]]);
+                if (!$goods) {
+                    throw new Exception('商品不存在');
+                }
                 if($goods['STORE_NUMS']>0){
                     $discount = $goods['SELL_DISCOUNT'];
                     $realPrice = $goods['SELL_PRICE'] * $discount;
@@ -381,6 +384,9 @@ class OrderForm extends Model
             foreach ($this->goodsNum as $k => $v){
                 if ($v){
                     $goods = ShopGoods::findOneAsArray('ID=:ID AND STATUS=1',[':ID'=> $ids[$k]]);
+                    if (!$goods) {
+                        throw new Exception('商品不存在');
+                    }
                     if ($goods['STORE_NUMS'] >= $this->goodsNum[$k]){
                         $data = ShopGoods::find()->where(['ID' => $ids[$k]])->one();
                         $goods_store_nums = $data->STORE_NUMS - $this->goodsNum[$k];

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

@@ -150,6 +150,51 @@ 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'];
+        foreach ($errorOutline as $item) {
+            if (false !== strpos($exception->getMessage(), $item)) {
+                $it = [
+                    'name' => ($exception instanceof Exception || $exception instanceof ErrorException) ? $exception->getName() : 'Exception',
+                    'message' => '(NC)提醒:' . $exception->getMessage(),
+                    'code' => $exception->getCode(),
+                ];
+                if ($exception instanceof HttpException) {
+                    $it['status'] = $exception->statusCode;
+                }
+                if (YII_DEBUG) {
+                    $it['type'] = get_class($exception);
+                    if (!$exception instanceof UserException) {
+                        $it['file'] = $exception->getFile();
+                        $it['line'] = $exception->getLine();
+                        $it['stack-trace'] = explode("\n", $exception->getTraceAsString());
+                        if ($exception instanceof \yii\db\Exception) {
+                            $it['error-info'] = $exception->errorInfo;
+                        }
+                    }
+                }
+                if (($prev = $exception->getPrevious()) !== null) {
+                    $it['previous'] = $this->convertExceptionToArray($prev);
+                }
+
+                // 错误日志写入
+                $it['trace-id'] = Tool::generateId();
+                LoggerTool::error($it);
+
+                // 提醒只报出基本错误
+                unset($it['stack-trace']);
+                // 发送钉钉提醒
+                DingTalk::sendNotice($it);
+
+                $array = [
+                    'name' => ($exception instanceof Exception || $exception instanceof ErrorException) ? $exception->getName() : 'Exception',
+                    'message' => '请求错误.请联系客服人员',
+                    'code' => $exception->getCode(),
+                ];
+
+                return $array;
+            }
+        }
+
         $array = [
             'name' => ($exception instanceof Exception || $exception instanceof ErrorException) ? $exception->getName() : 'Exception',
             'message' => $exception->getMessage(),