Forráskód Böngészése

Merge branch 'bugfix/transaction-self' of http://16.162.42.175:8014/guanli/aklast into bugfix/transaction-self

kevin_zhangl 3 éve
szülő
commit
ffc60cd6ba

+ 16 - 0
common/helpers/Excel.php

@@ -25,6 +25,7 @@ use common\models\forms\RegInfoAuditForm;
 use common\models\forms\WithdrawForm;
 use common\models\Uploads;
 use common\models\UserNetwork;
+use common\models\User;
 use yii\base\BaseObject;
 use yii\base\Exception;
 use yii\base\StaticInstanceTrait;
@@ -829,6 +830,21 @@ class Excel extends BaseObject {
                 'storeFile' => $tempFileName,
                 'dropKeysRow' => $startRow == 1 ? false : true,
             ]);
+            $errUserArray = [];
+            foreach ($data as $u){ // 记录了导入中不存在的会员
+                $u['USER_NAME'] = trim($u['会员编号']);
+                if(!$u['USER_NAME']){
+                    continue;
+                }
+                $userInfo = User::checkUser($u['USER_NAME']);
+                if(!$userInfo){
+                    $errUserArray[] = $u['USER_NAME'];
+                }
+            }
+            if(count($errUserArray)>0){
+                $errUserStr = implode(', ', $errUserArray);
+                throw new Exception(count($errUserArray).'个用户不存在:'.substr($errUserStr,0, 600).'...');
+            }
         } catch (\Exception $e) {
             throw new Exception($e->getMessage());
         }

+ 4 - 0
common/models/User.php

@@ -224,6 +224,10 @@ class User extends \common\components\ActiveRecord
         return $this->hasOne(UserInfo::class, ['USER_ID' => 'ID']);
     }
 
+    public static function checkUser($userName){
+        return self::find()->select('ID')->where('USER_NAME=:USER_NAME', [':USER_NAME'=>$userName])->asArray()->one();
+    }
+
     /**
      * 获取会员基本信息
      * @param $userId

+ 3 - 3
common/models/forms/ExcelOrderShopForm.php

@@ -80,13 +80,13 @@ class ExcelOrderShopForm extends \common\components\ActiveRecord
 
             $formatOrderData = [];
             $formatOrderGoodsData = [];
-            foreach ($everyData as $key => $value) {
+            foreach ($everyData as $key => $value) { // 读取excel内容
                 if(isset(self::EXCEL_ORDER_SHOP_FIELD[$key])) {
-                    $formatOrderData[self::EXCEL_ORDER_SHOP_FIELD[$key]] = $value;
+                    $formatOrderData[self::EXCEL_ORDER_SHOP_FIELD[$key]] = trim($value);
                 }
 
                 if(isset(self::EXCEL_ORDER_SHOP_GOODS_FIELD[$key])) {
-                    $formatOrderGoodsData[self::EXCEL_ORDER_SHOP_GOODS_FIELD[$key]] = $value;
+                    $formatOrderGoodsData[self::EXCEL_ORDER_SHOP_GOODS_FIELD[$key]] = trim($value);
                 }
             }
 

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

@@ -301,7 +301,9 @@ class TransferForm extends Model {
         if (!$this->validate()) {
             return null;
         }
-
+        if ($this->_fromUserInfo['ID']==$this->_toUserInfo['ID']){
+            throw new \Exception('不能给自己转账');
+        }
         $fromData = Balance::getLogData($this->_fromUserInfo['ID']);
         $toData = Balance::getLogData($this->_toUserInfo['ID']);
         $this->userOperateLogger->saveBeforeContent=array_merge($fromData,$toData);

+ 15 - 6
frontendEle/src/views/finance/transfer-add.vue

@@ -58,6 +58,7 @@ import Vue from 'vue'
 import store from '@/utils/vuexStore'
 import network from '@/utils/network'
 import tool from '@/utils/tool'
+import userInfo from '@/utils/userInfo'
 
 export default {
   name: 'finance_withdraw-add',
@@ -96,13 +97,21 @@ export default {
   },
   methods: {
       handleChange() {
-          this.loading = true
-          network.getData('user/full-info', {userName: this.form.toUserName}).then(response => {
-              this.form.toRealName = response.REAL_NAME
-              this.loading = false
-          }).catch(response => {
+          if (this.form.toUserName.trim() != userInfo.userName()){
+              this.loading = true
+              network.getData('user/full-info', {userName: this.form.toUserName}).then(response => {
+                  this.form.toRealName = response.REAL_NAME
                   this.loading = false
-          })
+              }).catch(response => {
+                      this.loading = false
+              })
+          } else {
+            this.form.toUserName = ''
+            this.$message({
+              message: '不能给自己转账',
+              type: 'error'
+            })
+          }
       },
     chkReal(){
       this.realAmount = tool.formatPrice(this.form.amount * (100-this.fee) * 0.01)