Explorar el Código

不允许给自己转账,由ng

theojeng hace 3 años
padre
commit
68419fd279

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