lsw 11 maanden geleden
bovenliggende
commit
f2358f8b86

+ 3 - 6
admin-ui/src/views/work/pay/cash_out.vue

@@ -24,10 +24,10 @@
       <el-table-column label="提现状态" align="center" width="110">
         <template slot-scope="scope">
           <el-tag type="info" v-if="scope.row.state == 0">待确认</el-tag>
-          <el-tag type="danger" v-if="scope.row.state == 1">提现成功</el-tag>
+          <el-tag type="success" v-if="scope.row.state == 1">提现成功</el-tag>
           <el-popover placement="top-start" v-if="scope.row.state == 2" title="原因" width="200" trigger="hover" :content="scope.row.msg">
             <div slot="reference">
-              <el-tag type="info">驳回</el-tag>
+              <el-tag type="danger">驳回</el-tag>
               <i class="el-icon-warning"></i>
             </div>
           </el-popover>
@@ -88,12 +88,9 @@ export default {
       this.ids = rows.map((item) => item.id);
     },
     op(tag, row) {
-      if (tag == 'add') {
-        this.iframe({ obj: edit, param: {}, title: '新增', width: '45%', height: '55%' });
-      }
       if (tag == 'edit') {
         const id = row.id || this.ids[0];
-        this.iframe({ obj: edit, param: { id: id }, title: '编辑', width: '50%', height: '50%' });
+        this.iframe({ obj: edit, param: { id: id }, title: '提现确认', width: '40%', height: '60%' });
       }
     },
     del(row) {

+ 54 - 57
admin-ui/src/views/work/pay/edit.vue

@@ -1,61 +1,50 @@
 <template>
   <div class="cmain">
-      <el-form ref="form" :model="form" :rules="rules" label-width="100px">
-        <el-form-item label="充值人id" prop="userId">
-          <el-input v-model="form.userId" placeholder="请输入充值人id" clearable/>
+    <div class="bos">
+      <el-form ref="user" disabled :model="user" label-width="120px">
+        <el-form-item label="用户姓名">
+          <span class="pon" @click="info()">{{ user.name }}</span>
         </el-form-item>
-        <el-form-item label="充值编号" prop="nums">
-          <el-input v-model="form.nums" placeholder="请输入充值编号" clearable/>
+        <el-form-item label="手机号">
+          <el-input v-model="user.phone" />
         </el-form-item>
-        <el-form-item label="充值金额" prop="money">
-          <el-input v-model="form.money" placeholder="请输入充值金额" clearable/>
+        <el-form-item label="开户行">
+          <el-input v-model="user.bankName" />
         </el-form-item>
-        <el-form-item label="状态" prop="state">
-          <el-input v-model="form.state" placeholder="请输入状态" clearable/>
+        <el-form-item label="银行卡号">
+          <el-input v-model="user.bankAccount" />
         </el-form-item>
-        <el-form-item label="充值无效原因" prop="msg">
-          <el-input v-model="form.msg" placeholder="请输入充值无效原因" clearable/>
-        </el-form-item>
-        <el-form-item label="乐观锁" prop="version">
-          <el-input v-model="form.version" placeholder="请输入乐观锁" clearable/>
-        </el-form-item>
-        <el-form-item label="创建时间" prop="createTime">
-          <el-date-picker clearable
-            v-model="form.createTime"
-            type="date"
-            value-format="yyyy-MM-dd"
-            placeholder="请选择创建时间">
-          </el-date-picker>
-        </el-form-item>
-        <el-form-item label="更新者" prop="updateBy">
-          <el-input v-model="form.updateBy" placeholder="请输入更新者" clearable/>
-        </el-form-item>
-        <el-form-item label="更新时间" prop="updateTime">
-          <el-date-picker clearable
-            v-model="form.updateTime"
-            type="date"
-            value-format="yyyy-MM-dd"
-            placeholder="请选择更新时间">
-          </el-date-picker>
+      </el-form>
+      <el-form ref="form" disabled :model="form" :rules="rules" label-width="120px">
+        <el-form-item label="提现金额" prop="money">
+          <el-input type="number" v-model="form.money">
+            <template slot="append">元</template>
+          </el-input>
         </el-form-item>
+        <div class="opp" v-if="form.updateTime">
+          <span>操作人:{{ form.updateBy }},</span>
+          <span>操作时间:{{ form.updateTime }}</span>
+        </div>
       </el-form>
-    <div class="mfooter">
-      <el-button type="primary" @click="submitForm">确 定</el-button>
+      <el-alert title="充值成功" type="success" show-icon class="cg" v-if="form.state === 1"></el-alert>
+      <el-alert title="充值失败" :description="form.msg" type="error" show-icon class="cg" v-if="form.state === 2" :closable="false"></el-alert>
+    </div>
+    <div class="mfooter" v-if="!param.detail">
+      <el-button type="primary" @click="submitForm(1)">确认转账</el-button>
+      <el-button type="danger" @click="submitForm(2)">不通过</el-button>
       <el-button @click="$layer.close(layerid)">取 消</el-button>
     </div>
   </div>
 </template>
 
 <script>
+import info from '@/views/work/user/edit';
 export default {
   data() {
     return {
+      user: {},
       form: {},
-      rules: {
-        money: [
-          { required: true, message: "充值金额不能为空", trigger: "blur" }
-        ],
-      }
+      rules: {}
     };
   },
   props: {
@@ -71,28 +60,36 @@ export default {
   },
   mounted() {
     if (this.param.id) {
-      this.ajax({ url: '/work/pay/detail/' + this.param.id }).then(response => {
-        this.form = response.data;
+      this.ajax({ url: '/work/pay/detail/' + this.param.id }).then((response) => {
+        this.form = response.data.pay;
+        this.user = response.data.user;
       });
     }
   },
   methods: {
-    submitForm() {
-      this.$refs["form"].validate(valid => {
+    info() {
+      this.iframe({ obj: info, param: { id: this.user.id, detail: true }, title: '用户详情', width: '55%', height: '65%' });
+    },
+    submitForm(state) {
+      this.$refs['form'].validate((valid) => {
         if (valid) {
-          if (this.form.id) {
-              this.ajax({method: 'post',url: '/work/pay/edit', data: this.form }).then(response => {
-                  this.$modal.msgSuccess("修改成功");
-                  this.$layer.close(this.layerid);
-                  this.$parent.getList();
-              });
-          } else {
-              this.ajax({method: 'post',url: '/work/pay/add', data: this.form }).then(response => {
-                  this.$modal.msgSuccess("新增成功");
-                  this.$layer.close(this.layerid);
-                  this.$parent.getList();
-               });
-          }
+          this.$prompt(state == 1 ? '确认已转账到 ' + this.user.bankAccount + ' 银行账户? 该操作不可撤销!' : '确认驳回提现', {
+            type: 'warning',
+            showInput: state == 1 ? false : true,
+            inputType: 'textarea',
+            inputPlaceholder: '充值失败',
+            inputValidator: (value) => {
+              if (!value && state == 2) {
+                return '请输入充值失败原因';
+              }
+            }
+          }).then(({ value }) => {
+            this.post({ url: '/work/pay/audit', data: { id: this.form.id, state: state, msg: value } }).then((response) => {
+              this.$modal.msgSuccess('操作成功');
+              this.$layer.close(this.layerid);
+              this.$parent.getList();
+            });
+          });
         }
       });
     }

+ 13 - 3
app/pages/user/money/index.vue

@@ -30,12 +30,19 @@
 					<text v-if="item.state == 1 && item.type == 1" style="color: #4caf50">兼职支出</text>
 					<text v-if="item.state == 0 && item.type == 2" style="color: #f44336">提现审核中...</text>
 					<text v-if="item.state == 1 && item.type == 2" style="color: #4caf50">提现成功</text>
+					<text v-if="item.state == 2 && item.type == 2" style="color: #f44336" @click="popup(item.msg)">
+						<text class="icon" style="padding-right: 5px">&#xe610;</text>
+						<text>提现失败,退回余额</text>
+					</text>
 					<text v-if="item.state == 1 && item.type == 4" style="color: #4caf50">退款成功</text>
 					<text>{{ item.createTime }}</text>
 				</view>
 				<view class="price">
-					<text v-if="item.type == 0" style="color: orangered">+{{ item.money }}¥</text>
-					<text v-if="item.type == 1 || item.type == 4 || item.type == 2" style="color: darkgray">-{{ item.money }}¥</text>
+					<text v-if="item.type == 0" style="color: orangered">+{{ item.money }}元</text>
+					<text v-if="item.type == 1 || item.type == 4" style="color: darkgray">-{{ item.money }}元</text>
+					<text v-if="item.type == 2 && item.state == 0" style="color: darkgray">-{{ item.money }}元</text>
+					<text v-if="item.type == 2 && item.state == 1" style="color: darkgray">-{{ item.money }}元</text>
+					<text v-if="item.type == 2 && item.state == 2" style="color: #f44336">+{{ item.money }}元</text>
 				</view>
 			</view>
 			<view class="loading" v-if="loadMore"><u-loadmore :status="loadMore ? 'loading' : 'nomore'" /></view>
@@ -96,6 +103,9 @@ export default {
 			this.param.type = e.value;
 			this.refresh();
 		},
+		popup(msg) {
+			uni.showModal({ title: '提示', content: msg, showCancel: false });
+		},
 		go(url) {
 			uni.navigateTo({ url: url });
 		},
@@ -153,7 +163,7 @@ export default {
 		}
 		.price {
 			float: right;
-			margin-top: -35px;
+			margin-top: -45px;
 		}
 	}
 }

+ 19 - 22
ruoyi-admin/src/main/java/com/ruoyi/web/work/controller/PayController.java

@@ -6,16 +6,21 @@ import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.page.TableDataInfo;
 import com.ruoyi.common.enums.BusinessType;
 import com.ruoyi.web.work.domain.Pay;
+import com.ruoyi.web.work.domain.User;
+import com.ruoyi.web.work.domain.dto.PayAuditDto;
 import com.ruoyi.web.work.service.IPayService;
+import com.ruoyi.web.work.service.IUserService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
-import java.util.Arrays;
+import java.rmi.ServerException;
 import java.util.List;
 
 /**
  * 微信在线充值记录
+ *
  * @author lsw
  * @date 2024-07-01
  */
@@ -25,9 +30,12 @@ public class PayController extends BaseController {
     @Autowired
     private IPayService payService;
 
+    @Autowired
+    private IUserService userService;
+
     @PreAuthorize("@ss.hasPermi('work:pay:list')")
     @GetMapping("/list")
-    public TableDataInfo list(Pay pay){
+    public TableDataInfo list(Pay pay) {
         startPage();
         List<Pay> list = payService.selectList(pay);
         return getDataTable(list);
@@ -35,28 +43,17 @@ public class PayController extends BaseController {
 
     @PreAuthorize("@ss.hasPermi('work:pay:query')")
     @GetMapping(value = "/detail/{id}")
-    public AjaxResult detail(@PathVariable("id") Long id){
-        return AjaxResult.success(payService.getById(id));
+    public AjaxResult detail(@PathVariable("id") Long id) {
+        Pay pay = payService.getById(id);
+        User user = userService.getById(pay.getUserId());
+        return AjaxResult.success(new AjaxResult().put("pay", pay).put("user", user));
     }
 
-    @PreAuthorize("@ss.hasPermi('work:pay:add')")
-    @Log(title = "微信在线充值记录", businessType = BusinessType.INSERT)
-    @PostMapping("/add")
-    public AjaxResult add(@RequestBody Pay pay){
-        return toAjax(payService.save(pay));
+    @PreAuthorize("@ss.hasPermi('work:pay:audit')")
+    @Log(title = "余额提现", businessType = BusinessType.UPDATE)
+    @PostMapping("/audit")
+    public AjaxResult audit(@Validated @RequestBody PayAuditDto dto) throws ServerException {
+        return payService.audit(dto);
     }
 
-    @PreAuthorize("@ss.hasPermi('work:pay:edit')")
-    @Log(title = "微信在线充值记录", businessType = BusinessType.UPDATE)
-    @PostMapping("/edit")
-    public AjaxResult edit(@RequestBody Pay pay){
-        return toAjax(payService.updateById(pay));
-    }
-
-    @PreAuthorize("@ss.hasPermi('work:pay:remove')")
-    @Log(title = "微信在线充值记录", businessType = BusinessType.DELETE)
-    @GetMapping("/remove/{ids}")
-    public AjaxResult remove(@PathVariable Long[] ids){
-        return toAjax(payService.removeByIds(Arrays.asList(ids)));
-    }
 }

+ 21 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/work/domain/dto/PayAuditDto.java

@@ -0,0 +1,21 @@
+package com.ruoyi.web.work.domain.dto;
+
+import lombok.Data;
+
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotNull;
+
+@Data
+public class PayAuditDto {
+
+    @NotNull(message = "参数错误")
+    private Long id;
+
+    @NotNull(message = "参数错误")
+    @Min(value = 0, message = "参数错误")
+    @Max(value = 2, message = "参数错误")
+    private Integer state;
+
+    private String msg;
+}

+ 2 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/work/domain/dto/PayDto.java

@@ -2,6 +2,7 @@ package com.ruoyi.web.work.domain.dto;
 
 import lombok.Data;
 
+import javax.validation.constraints.DecimalMin;
 import javax.validation.constraints.Digits;
 import javax.validation.constraints.NotNull;
 import java.math.BigDecimal;
@@ -11,5 +12,6 @@ public class PayDto {
 
     @NotNull(message = "充值金额不能为空")
     @Digits(integer = 10, fraction = 2, message = "充值金额只能包含最多两位小数")
+    @DecimalMin(value = "0.01", message = "金额必须大于0")
     private BigDecimal money;
 }

+ 12 - 2
ruoyi-admin/src/main/java/com/ruoyi/web/work/service/IPayService.java

@@ -3,6 +3,7 @@ package com.ruoyi.web.work.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.web.work.domain.Pay;
+import com.ruoyi.web.work.domain.dto.PayAuditDto;
 import com.ruoyi.web.work.domain.dto.PayDto;
 
 import java.rmi.ServerException;
@@ -12,15 +13,24 @@ import java.util.List;
  * @author lsw
  * @date 2024-07-01
  */
-public interface IPayService extends IService<Pay>{
+public interface IPayService extends IService<Pay> {
     List<Pay> selectList(Pay pay);
 
     Pay selectByNums(String nums);
 
     /**
-     * 余额提现
+     * 余额提现申请
+     *
      * @param dto
      * @return
      */
     AjaxResult cashOut(PayDto dto) throws ServerException;
+
+    /**
+     * 余额提现确认
+     *
+     * @param dto
+     * @return
+     */
+    AjaxResult audit(PayAuditDto dto) throws ServerException;
 }

+ 28 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/work/service/impl/PayServiceImpl.java

@@ -6,12 +6,14 @@ import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.web.work.api.util.AppUtil;
 import com.ruoyi.web.work.domain.Pay;
 import com.ruoyi.web.work.domain.User;
+import com.ruoyi.web.work.domain.dto.PayAuditDto;
 import com.ruoyi.web.work.domain.dto.PayDto;
 import com.ruoyi.web.work.mapper.PayMapper;
 import com.ruoyi.web.work.service.IPayService;
 import com.ruoyi.web.work.service.IUserService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.rmi.ServerException;
 import java.util.List;
@@ -66,4 +68,30 @@ public class PayServiceImpl extends ServiceImpl<PayMapper, Pay> implements IPayS
         }
         return AjaxResult.success();
     }
+
+    @Transactional
+    @Override
+    public AjaxResult audit(PayAuditDto dto) throws ServerException {
+        Pay pay = getById(dto.getId());
+        if (pay == null) {
+            return AjaxResult.error("提现信息不存在");
+        }
+        if (pay.getState() == 1) {
+            return AjaxResult.error("不能重复操作");
+        }
+        pay.setState(dto.getState());
+        pay.setMsg(dto.getMsg());
+        if (!updateById(pay)) {
+            throw new ServerException("提现失败,请联系平台");
+        }
+        //提现驳回需要退回到用户账户余额
+        if (dto.getState() == 2) {
+            User user =userService.getById(pay.getUserId());
+            user.setMoney(user.getMoney().add(pay.getMoney()));
+            if (!userService.updateById(user)) {
+                throw new ServerException("更新用户账户余额失败,请联系平台");
+            }
+        }
+        return AjaxResult.success();
+    }
 }

+ 3 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/work/service/impl/PositionServiceImpl.java

@@ -105,6 +105,9 @@ public class PositionServiceImpl extends ServiceImpl<PositionMapper, Position> i
         }
         //兼职
         if (dto.getType() == 1) {
+            if (new BigDecimal(dto.getSalary()).compareTo(BigDecimal.ZERO) <= 0) {
+                return AjaxResult.error("兼职金额必须大于0");
+            }
             if (new BigDecimal(dto.getSalary()).compareTo(user.getMoney()) > 0) {
                 return AjaxResult.error(8080, "余额不足请先充值");
             }