From 5419d81a9cda298424a40b62373d0bca0cc04df0 Mon Sep 17 00:00:00 2001 From: cgx <2606784146@qq.com> Date: Fri, 13 Dec 2024 02:33:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/org/jeecg/common/api/vo/Result.java | 9 +- .../java/org/jeecg/common/constant/RedisKey.java | 133 +-------------------- .../controller/TbRechargeInfoLogController.java | 30 ++++- .../service/ITbRechargeInfoLogService.java | 6 +- .../service/impl/TbRechargeInfoLogServiceImpl.java | 77 ++++++++++++ .../modules/userCode/controller/PayController.java | 24 ++-- .../modules/userCode/model/req/WithawalReq.java | 24 ++++ .../modules/userCode/service/IPayService.java | 4 +- .../userCode/service/impl/PayServiceImpl.java | 77 +++++++++++- .../java/org/jeecg/modules/utils/SubmitUtil.java | 32 +++++ 10 files changed, 268 insertions(+), 148 deletions(-) create mode 100644 jeecg-boot-module-system/src/main/java/org/jeecg/modules/userCode/model/req/WithawalReq.java create mode 100644 jeecg-boot-module-system/src/main/java/org/jeecg/modules/utils/SubmitUtil.java diff --git a/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/api/vo/Result.java b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/api/vo/Result.java index 53b2397..ba5b518 100644 --- a/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/api/vo/Result.java +++ b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/api/vo/Result.java @@ -1,5 +1,6 @@ package org.jeecg.common.api.vo; +import com.alibaba.fastjson.JSONObject; import com.fasterxml.jackson.annotation.JsonIgnore; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -76,7 +77,13 @@ public class Result implements Serializable { r.setCode(CommonConstant.SC_OK_200); return r; } - + public static Result OKMsg() { + Result r = new Result(); + r.setSuccess(true); + r.setMessage("操作成功"); + r.setCode(CommonConstant.SC_OK_200); + return r; + } public static Result ok(String msg) { Result r = new Result(); r.setSuccess(true); diff --git a/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/RedisKey.java b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/RedisKey.java index cab2476..b7a06de 100644 --- a/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/RedisKey.java +++ b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/RedisKey.java @@ -2,148 +2,19 @@ package org.jeecg.common.constant; public class RedisKey { - /** - * redis分布式锁-订单支付 - */ - public final static String LOCK_KEY = "ORDER_LOCK:"; - public final static String ORDER_LOCK_OUTBOUND = "ORDER_LOCK_OUTBOUND:"; - - public final static String LOCK_KEY_GZHCOUPON = "LOCK_KEY_GZHCOUPON:"; - public final static String LOCK_KEY_COUPON = "LOCK_KEY_COUPON:"; - - /** - * redis分布式锁-订单完工 - */ - public final static String ORDER_END_LOCK_KEY = "ORDER_END_LOCK"; - - /** - * redis分布式锁-订单分账 - */ - public final static String ORDER_LEDGER_LOCK_KEY = "ORDER_LEDGER_LOCK:"; /** * redis防表单重复提交- */ public final static String RECHARGE_LOCK_KEY = "RECHARGE_LOCK:"; - /** - * redis防表单重复提交-领取赠送券 - */ - public final static String RECHARGE_SEND_COUPON_LOCK_KEY = "RECHARGE_SEND_COUPON_LOCK:"; - - /** - * redis防表单重复提交-超级vip充值 - */ - public final static String SUPER_RECHARGE_LOCK_KEY = "SUPER_RECHARGE_LOCK:"; - - /** - * redis防表单重复提交-保存车辆信息 - */ - public final static String SAVE_CAR_NUM_KEY = "SAVE_CAR_NUM:"; - - /** - * redis昉表单重复提交-登录注册 - */ - public final static String LOGIN_SUBMIT = "LOGIN_SUBMIT:"; - - //用戶上報的位置 - public final static String USER_ADDRESS = "SYSTEM:USER:ADDRESS:"; - //用戶据門店距離 - public final static String ZDISTANCE_SET = "SYSTEM:USER:ZDISTANCE:"; - //工位情况 - public final static String SYSTEM_STATION = "SYSTEM:STATION:"; - //门店情况 - public final static String SYSTEM_STORE = "SYSTEM:STORE:"; - - //在綫用戶 - public final static String USER_ONLINE = "SYSTEM:USER:STATUS:ONLINE:"; - //在綫用戶查詢語句 - public final static String USER_ONLINE_QL = "SYSTEM:USER:STATUS:ONLINE:*"; - - //纬度 - public final static String LONGITUDE = "longitude"; - //经度 - public final static String LATITUDE = "latitude"; - - public final static String ADDRESS = "address"; - //分割 - public final static String KEY_SPLIT = ":"; - - /** - * 门店基础信息 - */ - public static final String MERCHANT_INFO = "MERCHANT:INFO"; - - //派单系统情况 - public static final String SYSTEM_DELIVERY_ORDER_STATE = "SYSTEM:DELIVERY:ORDER:STATE"; - //失败订单原因 - public static final String SYSTEM_DELIVERY_ORDER_BAD = "SYSTEM:DELIVERY:ORDER:BAD"; - //技师取消订单补偿 - public static final String SYSTEM_DELIVERY_ORDER_CANCAL = "SYSTEM:DELIVERY:TECHNICIAN:CANCAL"; - //技师转单已派 - public static final String SYSTEM_DELIVERY_ORDER_TRANSFERD = "SYSTEM:DELIVERY:TECHNICIAN:TRANSFERD"; - - - //系统游标情况 按门店区分 key - int - public static final String SYSTEM_DELIVERY_TECHNICIAN_STATE = "SYSTEM:DELIVERY:TECHNICIAN:"; - //系统技师轮询情况 按门店区分 key - keys - in - public static final String SYSTEM_DELIVERY_TECHNICIAN_ONLINE = "SYSTEM:DELIVERY:TECHNICIAN:ONLINE:"; - - - public static final String SYSTEM_DELIVERY_TECHNICIAN_MERCHANT = "SYSTEM_DELIVERY_TECHNICIAN_MERCHANT"; - - - public static final String ORDER_TRANSFERD = "order_transferd"; - - - /** - * 订单编号信息 (目前用于 60分钟过期 触发取消订单用) - */ - public static final String ORDER_INFO_PAY = "ORDER_INFO_PAY:"; - - public static final String ORDER_CANCEL_TIME = "ORDER_CANCEL_TIME:"; - - /** - * 订单评价信息 (目前技师完工操作后, 用户不评价, 24小时后 触发默认评价和分账操作) - */ - public static final String ORDER_INFO_EVALUATE = "ORDER_INFO_EVALUATE:"; - - /** - * 技师接单记录 - */ - public static final String TECHNICIAN_ORDER_INFO = "TECHNICIAN:ORDER:INFO"; - - /** - * 技师转单 - */ - public static final String TECHNICIAN_TRANSFER_ORDER = "TECHNICIAN:TRANSFER:ORDER"; - - //评论开关,小程序审核时开启,不给评论成功 - public final static String COMMENT = "comment"; - - //门店接单团队的接单顺序 - public static final String MERCHANT_ORDER_INDEX = "merchant_order_index:"; - - - //接单团队的在线列表 zset - public static final String MERCHANT_ORDER_OPERATOR_ONLINE = "merchant_order_operator_online:"; - - public final static String ORDER_START_CHECK = "order_start_check:"; - - public final static String ORDER_START_CHECK_TIME = "order_start_check_time"; - - public final static String ADVANCE_ORDER_START_CHECK = "advance_order_start_check:"; - public final static String CHECK_NAME = "check_name"; - public final static String AUTO_CHECK_ORDER = "auto_check_order"; - public final static String AUTO_CHECK_ADVANCE_ORDER = "auto_check_advance_order"; + /**后台提现审核防表单重复提交*/ + public static final String MER_WITHDRAWAL_AUDIT = "MER_WITHDRAWAL:AUDIT"; - public final static String MERCHAT_ACTIVITY_TIME = "merchat_activity_time"; - public static final String MER_MEMBER_INFO = "mer_member_info:"; - public static final String MER_MERCHANT_INFO = "mer_merchant_info:"; } diff --git a/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/rechargeInfoLog/controller/TbRechargeInfoLogController.java b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/rechargeInfoLog/controller/TbRechargeInfoLogController.java index fdafd39..bd6c581 100644 --- a/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/rechargeInfoLog/controller/TbRechargeInfoLogController.java +++ b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/rechargeInfoLog/controller/TbRechargeInfoLogController.java @@ -1,10 +1,20 @@ package org.jeecg.modules.rechargeInfoLog.controller; +import java.math.BigDecimal; import java.util.Arrays; +import java.util.Date; +import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.lang.StringUtils; import org.jeecg.common.api.vo.Result; +import org.jeecg.common.constant.RedisKey; +import org.jeecg.common.exception.JeecgBootException; import org.jeecg.common.system.query.QueryGenerator; +import org.jeecg.common.util.RedisUtil; +import org.jeecg.modules.hanHaiMember.entity.HanHaiMember; +import org.jeecg.modules.hanHaiMember.service.IHanHaiMemberService; import org.jeecg.modules.rechargeInfoLog.entity.TbRechargeInfoLog; import org.jeecg.modules.rechargeInfoLog.service.ITbRechargeInfoLogService; @@ -15,6 +25,7 @@ import lombok.extern.slf4j.Slf4j; import org.jeecg.common.system.base.controller.JeecgController; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import org.springframework.web.servlet.ModelAndView; import io.swagger.annotations.Api; @@ -34,7 +45,7 @@ import org.jeecg.common.aspect.annotation.AutoLog; public class TbRechargeInfoLogController extends JeecgController { @Autowired private ITbRechargeInfoLogService tbRechargeInfoLogService; - + /** * 分页列表查询 * @@ -56,8 +67,21 @@ public class TbRechargeInfoLogController extends JeecgController pageList = tbRechargeInfoLogService.page(page, queryWrapper); return Result.OK(pageList); } - - /** + + /** + * 提现审核 + * @param id + * @return + */ + @Transactional(rollbackFor = {Exception.class}) + @GetMapping(value = "/audit") + public Result audit(@RequestParam(name="id",required=true) String id,@RequestParam(name = "status") boolean status,@RequestParam(name = "checkInfo",required = false) String checkInfo){ + Result audit = tbRechargeInfoLogService.audit(id, status, checkInfo); + return Result.OKMsg(); + } + + + /** * 添加 * * @param tbRechargeInfoLog diff --git a/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/rechargeInfoLog/service/ITbRechargeInfoLogService.java b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/rechargeInfoLog/service/ITbRechargeInfoLogService.java index 65ca353..a816498 100644 --- a/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/rechargeInfoLog/service/ITbRechargeInfoLogService.java +++ b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/rechargeInfoLog/service/ITbRechargeInfoLogService.java @@ -1,14 +1,18 @@ package org.jeecg.modules.rechargeInfoLog.service; +import org.jeecg.common.api.vo.Result; import org.jeecg.modules.rechargeInfoLog.entity.TbRechargeInfoLog; import com.baomidou.mybatisplus.extension.service.IService; +import org.springframework.web.bind.annotation.RequestParam; /** * @Description: tb_recharge_info_log * @Author: jeecg-boot - * @Date: 2024-12-12 + * @Date: 2024-12-12 * @Version: V1.0 */ public interface ITbRechargeInfoLogService extends IService { + Result audit(String id, boolean status, String checkInfo); + } diff --git a/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/rechargeInfoLog/service/impl/TbRechargeInfoLogServiceImpl.java b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/rechargeInfoLog/service/impl/TbRechargeInfoLogServiceImpl.java index 978d87f..f9ca198 100644 --- a/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/rechargeInfoLog/service/impl/TbRechargeInfoLogServiceImpl.java +++ b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/rechargeInfoLog/service/impl/TbRechargeInfoLogServiceImpl.java @@ -1,11 +1,22 @@ package org.jeecg.modules.rechargeInfoLog.service.impl; +import org.jeecg.common.api.vo.Result; +import org.jeecg.common.constant.RedisKey; +import org.jeecg.common.exception.JeecgBootException; +import org.jeecg.common.util.RedisUtil; +import org.jeecg.modules.hanHaiMember.entity.HanHaiMember; +import org.jeecg.modules.hanHaiMember.service.IHanHaiMemberService; import org.jeecg.modules.rechargeInfoLog.entity.TbRechargeInfoLog; import org.jeecg.modules.rechargeInfoLog.mapper.TbRechargeInfoLogMapper; import org.jeecg.modules.rechargeInfoLog.service.ITbRechargeInfoLogService; import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.util.Date; /** * @Description: tb_recharge_info_log @@ -16,4 +27,70 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @Service public class TbRechargeInfoLogServiceImpl extends ServiceImpl implements ITbRechargeInfoLogService { + @Resource + private RedisUtil redisUtil; + @Resource + private IHanHaiMemberService hanHaiMemberService; + + + @Transactional + @Override + public Result audit(String id, boolean status, String checkInfo) { + Integer n = (Integer) redisUtil.get(RedisKey.MER_WITHDRAWAL_AUDIT + id); + if(n != null){ + throw new JeecgBootException("请勿重复点击!"); + } + redisUtil.set(RedisKey.MER_WITHDRAWAL_AUDIT + id,1,5); + TbRechargeInfoLog rechargeInfoLog = this.getById(id); + if(rechargeInfoLog==null) { + throw new JeecgBootException("未找到数据"); + } + + Long count = this.lambdaQuery() + .eq(TbRechargeInfoLog::getWithdrawalId, rechargeInfoLog.getId()) + .count(); + if(count != null && count > 0){ + throw new JeecgBootException("此提现已处理过不通过,请勿重新点击"); + } + + HanHaiMember account = hanHaiMemberService.getById(rechargeInfoLog.getMemberId()); + TbRechargeInfoLog rechargeInfoLog1 = new TbRechargeInfoLog(); + rechargeInfoLog1.setId(rechargeInfoLog.getId()); + rechargeInfoLog1.setState(1); + if(!status){ + //审核不通过退回余额 + rechargeInfoLog1.setState(3); + rechargeInfoLog1.setCheckInfo(checkInfo); + + BigDecimal money = rechargeInfoLog.getMoney().add(rechargeInfoLog.getServiceCharge()); + HanHaiMember cmMemberAccount2 = new HanHaiMember(); + cmMemberAccount2.setId(account.getId()); + cmMemberAccount2.setPrice(account.getPrice().add(money)); + boolean b = hanHaiMemberService.updateById(cmMemberAccount2); + if(!b){ + throw new JeecgBootException("操作失败,请稍后重试"); + } + TbRechargeInfoLog merRechargeInfoLog = new TbRechargeInfoLog(); + merRechargeInfoLog.setTitle("提现未通过退款"); + merRechargeInfoLog.setMoney(money); + merRechargeInfoLog.setUserMoney(account.getPrice()); + merRechargeInfoLog.setIsPay(1); + merRechargeInfoLog.setDelFlag(0); + merRechargeInfoLog.setPayTime(new Date()); + merRechargeInfoLog.setMemberId(rechargeInfoLog.getMemberId()); + merRechargeInfoLog.setType(1); + merRechargeInfoLog.setCheckInfo(checkInfo); + merRechargeInfoLog.setWithdrawalId(rechargeInfoLog.getId()); + boolean save = this.save(merRechargeInfoLog); + if(!save){ + throw new JeecgBootException("操作失败"); + } + } + boolean b = this.updateById(rechargeInfoLog1); + if(!b){ + throw new JeecgBootException("操作失败,请稍后重试"); + } + return null; + + } } diff --git a/jeecg-boot-module-system/src/main/java/org/jeecg/modules/userCode/controller/PayController.java b/jeecg-boot-module-system/src/main/java/org/jeecg/modules/userCode/controller/PayController.java index 1c81124..32d3319 100644 --- a/jeecg-boot-module-system/src/main/java/org/jeecg/modules/userCode/controller/PayController.java +++ b/jeecg-boot-module-system/src/main/java/org/jeecg/modules/userCode/controller/PayController.java @@ -12,6 +12,7 @@ import org.jeecg.modules.bean.RechargeReq; import org.jeecg.modules.hanHaiMember.entity.HanHaiMember; import org.jeecg.modules.userCode.model.req.OrderPayReq; import org.jeecg.modules.userCode.model.req.RechargeInfoLogReq; +import org.jeecg.modules.userCode.model.req.WithawalReq; import org.jeecg.modules.userCode.service.IPayService; import org.jeecg.modules.utils.ValidateTool; import org.springframework.web.bind.annotation.*; @@ -80,7 +81,6 @@ public class PayController { } - //TODO 充值支付 交接改动 /** @@ -113,24 +113,34 @@ public class PayController { } - - - /** * 余额日志 + * * @param token * @param rechargeInfoLogReq * @return */ @ApiOperation("余额日志") @PostMapping("/log") - public Result rechargeLog(@RequestHeader("X-Access-Token") String token,@RequestBody(required = false) RechargeInfoLogReq rechargeInfoLogReq){ - return payService.rechargeLog(token,rechargeInfoLogReq); + public Result rechargeLog(@RequestHeader("X-Access-Token") String token, @RequestBody(required = false) RechargeInfoLogReq rechargeInfoLogReq) { + return payService.rechargeLog(token, rechargeInfoLogReq); } + /** + * 提现 + * + * @param token + * @param withawalReq + * @return + */ + @ApiOperation("提现") + @PostMapping("/withdrawal") + public Result withdrawal(@RequestHeader("X-Access-Token") String token, + WithawalReq withawalReq) { - + return payService.withdrawal(token, withawalReq); + } } diff --git a/jeecg-boot-module-system/src/main/java/org/jeecg/modules/userCode/model/req/WithawalReq.java b/jeecg-boot-module-system/src/main/java/org/jeecg/modules/userCode/model/req/WithawalReq.java new file mode 100644 index 0000000..23bc83f --- /dev/null +++ b/jeecg-boot-module-system/src/main/java/org/jeecg/modules/userCode/model/req/WithawalReq.java @@ -0,0 +1,24 @@ +package org.jeecg.modules.userCode.model.req; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @author java996.icu + * @title: WithawalReq + * @projectName merchant + * @description: TODO + * @date 2021/12/13 10:52 + * @Version V1.0 + */ +@Data +public class WithawalReq { + + /**提现金额*/ + @ApiModelProperty(value = "提现金额",required = true) + private BigDecimal money; + + +} diff --git a/jeecg-boot-module-system/src/main/java/org/jeecg/modules/userCode/service/IPayService.java b/jeecg-boot-module-system/src/main/java/org/jeecg/modules/userCode/service/IPayService.java index 0319fbf..e81e648 100644 --- a/jeecg-boot-module-system/src/main/java/org/jeecg/modules/userCode/service/IPayService.java +++ b/jeecg-boot-module-system/src/main/java/org/jeecg/modules/userCode/service/IPayService.java @@ -6,6 +6,8 @@ import org.jeecg.common.bestpay.model.PayResponse; import org.jeecg.modules.bean.RechargeReq; import org.jeecg.modules.userCode.model.req.OrderPayReq; import org.jeecg.modules.userCode.model.req.RechargeInfoLogReq; +import org.jeecg.modules.userCode.model.req.WithawalReq; +import org.springframework.web.bind.annotation.RequestHeader; /** * @author java996.icu @@ -59,7 +61,7 @@ public interface IPayService { */ Result rechargeLog(String token, RechargeInfoLogReq rechargeInfoLogReq); - + Result withdrawal(String token,WithawalReq withawalReq); } diff --git a/jeecg-boot-module-system/src/main/java/org/jeecg/modules/userCode/service/impl/PayServiceImpl.java b/jeecg-boot-module-system/src/main/java/org/jeecg/modules/userCode/service/impl/PayServiceImpl.java index 78f85cb..f37c71f 100644 --- a/jeecg-boot-module-system/src/main/java/org/jeecg/modules/userCode/service/impl/PayServiceImpl.java +++ b/jeecg-boot-module-system/src/main/java/org/jeecg/modules/userCode/service/impl/PayServiceImpl.java @@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import io.swagger.annotations.ApiOperation; import lombok.extern.log4j.Log4j2; import org.apache.commons.lang3.StringUtils; import org.jeecg.common.api.vo.Result; @@ -21,17 +22,24 @@ import org.jeecg.modules.hanHaiMember.entity.HanHaiMember; import org.jeecg.modules.hanHaiMember.service.IHanHaiMemberService; import org.jeecg.modules.rechargeInfoLog.entity.TbRechargeInfoLog; import org.jeecg.modules.rechargeInfoLog.service.ITbRechargeInfoLogService; +import org.jeecg.modules.tbConf.entity.TbConf; +import org.jeecg.modules.tbConf.service.ITbConfService; import org.jeecg.modules.tbOrder.entity.TbOrder; import org.jeecg.modules.tbOrder.service.ITbOrderService; import org.jeecg.modules.userCode.mapper.RechargeInfoLogMapper; import org.jeecg.modules.userCode.model.req.OrderPayReq; import org.jeecg.modules.userCode.model.req.PayBean; import org.jeecg.modules.userCode.model.req.RechargeInfoLogReq; +import org.jeecg.modules.userCode.model.req.WithawalReq; import org.jeecg.modules.userCode.service.IPayService; +import org.jeecg.modules.userRole.service.ITbUserRoleService; +import org.jeecg.modules.utils.SubmitUtil; import org.jeecg.modules.utils.ValidateTool; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestHeader; import javax.annotation.Resource; import java.math.BigDecimal; @@ -73,13 +81,17 @@ public class PayServiceImpl implements IPayService { private RechargeInfoLogMapper rechargeInfoLogMapper; - ExecutorService cachedThreadPool = new ThreadPoolExecutor(32, 32, - 0L, TimeUnit.MILLISECONDS, - new LinkedBlockingQueue()); - @Resource private ITbOrderService tbOrderService; + @Resource + private RedisUtil redisUtil; + + @Resource + private ITbConfService tbConfService; + + @Resource + private ITbRechargeInfoLogService tbRechargeInfoLogService; /** * 订单支付 @@ -289,6 +301,7 @@ public class PayServiceImpl implements IPayService { * * @return */ + @Transactional @Override public Result rechargeLog(String token, RechargeInfoLogReq rechargeInfoLogReq) { HanHaiMember hanHaiMember = shiroRealm.checkUserTokenIsEffectHanHaiAccount(token); @@ -317,4 +330,60 @@ public class PayServiceImpl implements IPayService { } + @Transactional + @Override + public Result withdrawal(String token, WithawalReq withawalReq) { + HanHaiMember account = shiroRealm.checkUserTokenIsEffectHanHaiAccount(token); + SubmitUtil.submit(account, "withdrawal", redisUtil); + + + QueryWrapper objectQueryWrapper = new QueryWrapper<>(); + objectQueryWrapper.eq("name", "withdrawal_min_money"); + TbConf one = tbConfService.getOne(objectQueryWrapper); + + QueryWrapper withdrawalRate = new QueryWrapper<>(); + withdrawalRate.eq("name", "withdrawal_rate"); + TbConf withdrawalRates = tbConfService.getOne(withdrawalRate); + + + //提现最低余额 + BigDecimal withawalMinMoney = new BigDecimal(one.getValue()); + if (withawalReq.getMoney().compareTo(withawalMinMoney) < 0) { + throw new JeecgBootException("提现金额不能小于" + withawalMinMoney); + } + + //获取提现手续费率 + BigDecimal withawalServiceRate = new BigDecimal(withdrawalRates.getValue()); + + BigDecimal serviceCharge = withawalReq.getMoney().multiply(withawalServiceRate); + BigDecimal money = withawalReq.getMoney().subtract(serviceCharge); + + if (withawalReq.getMoney().compareTo(account.getPrice()) == 1) { + throw new JeecgBootException("提现金额不可以大于金额"); + } + //写入提现日志 + TbRechargeInfoLog merRechargeInfoLog = new TbRechargeInfoLog(); + merRechargeInfoLog.setTitle("提现"); + merRechargeInfoLog.setMoney(money); + merRechargeInfoLog.setUserMoney(account.getPrice()); + merRechargeInfoLog.setIsPay(1); + merRechargeInfoLog.setPayTime(new Date()); + merRechargeInfoLog.setMemberId(account.getId()); + merRechargeInfoLog.setType(0); + merRechargeInfoLog.setServiceCharge(serviceCharge); + merRechargeInfoLog.setRealName(account.getName()); + merRechargeInfoLog.setState(0); + boolean save = tbRechargeInfoLogService.save(merRechargeInfoLog); + if (!save) { + throw new JeecgBootException("操作失败,请稍后重试"); + } + HanHaiMember hanHaiMember = new HanHaiMember(); + hanHaiMember.setId(account.getId()); + hanHaiMember.setPrice(account.getPrice().subtract(withawalReq.getMoney())); + boolean b = hanHaiMemberService.updateById(hanHaiMember); + if (!b) { + throw new JeecgBootException("操作失败,请稍后重试"); + } + return Result.OKMsg(); + } } diff --git a/jeecg-boot-module-system/src/main/java/org/jeecg/modules/utils/SubmitUtil.java b/jeecg-boot-module-system/src/main/java/org/jeecg/modules/utils/SubmitUtil.java new file mode 100644 index 0000000..d8da09d --- /dev/null +++ b/jeecg-boot-module-system/src/main/java/org/jeecg/modules/utils/SubmitUtil.java @@ -0,0 +1,32 @@ +package org.jeecg.modules.utils; + +import org.jeecg.common.exception.JeecgBootException; +import org.jeecg.common.util.RedisUtil; +import org.jeecg.modules.hanHaiMember.entity.HanHaiMember; + +/** + * @author java996.icu + * @title: SubmitUtil + * @projectName blind-box-api + * @description: TODO + * @date 2021/11/23 16:18 + * @Version V1.0 + */ +public class SubmitUtil { + + public static void submit(HanHaiMember member, String name, RedisUtil redisUtil) { + Long time = (Long) redisUtil.get("submit::" + member.getId() + "::" + name); + if (time != null) { + throw new JeecgBootException("请勿重复点击"); + } + redisUtil.set("submit::" + member.getId() + "::" + name, System.currentTimeMillis(), 10); + } + + public static void loginSubmit(String phone, String name, RedisUtil redisUtil) { + Long time = (Long) redisUtil.get("submit::" + phone + "::" + name); + if (time != null) { + throw new JeecgBootException("请勿重复点击"); + } + redisUtil.set("submit::" + phone + "::" + name, System.currentTimeMillis(), 10); + } +}