From 666a3474336539bbcdd342641cdd8678687f30db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=AD=E5=87=AF=E5=87=AF?= Date: Fri, 27 Dec 2024 16:55:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E7=8E=B0=E5=AE=A1=E6=A0=B8=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E6=8E=A5=E5=8F=A3+=E6=94=AF=E4=BB=98=E5=AE=9D?= =?UTF-8?q?=E6=8F=90=E7=8E=B0=E7=BB=9F=E8=AE=A1=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/CashOutController.java | 17 ++++ .../sqx/modules/job/task/TempCashOutTask.java | 1 + .../com/sqx/modules/pay/dao/CashOutDao.java | 9 +- .../com/sqx/modules/pay/entity/CashOut.java | 11 +++ .../modules/pay/service/CashOutService.java | 4 + .../pay/service/impl/CashOutServiceImpl.java | 99 ++++++++++++++++++- src/main/resources/mapper/pay/CashDao.xml | 8 +- 7 files changed, 141 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/sqx/modules/discSpinning/controller/CashOutController.java b/src/main/java/com/sqx/modules/discSpinning/controller/CashOutController.java index 179eeb96..042cbe22 100644 --- a/src/main/java/com/sqx/modules/discSpinning/controller/CashOutController.java +++ b/src/main/java/com/sqx/modules/discSpinning/controller/CashOutController.java @@ -48,4 +48,21 @@ public class CashOutController { cashOutService.audit(cashOut); return Result.success(); } + + @PostMapping("/batchAudit") + @ApiOperation("批量审核") + public Result batchAudit(@RequestBody CashOut cashOut) { + cashOutService.batchAudit(cashOut.getUserId(), cashOut.getIsAgree(), cashOut.getRefund()); + return Result.success(); + } + + @GetMapping("/alipay/transfer/summary/query") + @ApiOperation("支付宝提现查询") + @ApiImplicitParams({ + @ApiImplicitParam(name = "alipayAccountName", value = "支付宝账户名", paramType = "query", required = true, dataType = "String"), + }) + public Result alipayTransferSummaryQuery(String alipayAccountName) { + Map data = cashOutService.alipayTransferSummaryQuery(alipayAccountName); + return Result.success().put("data", data); + } } diff --git a/src/main/java/com/sqx/modules/job/task/TempCashOutTask.java b/src/main/java/com/sqx/modules/job/task/TempCashOutTask.java index d7c99104..a7a9adc2 100644 --- a/src/main/java/com/sqx/modules/job/task/TempCashOutTask.java +++ b/src/main/java/com/sqx/modules/job/task/TempCashOutTask.java @@ -39,6 +39,7 @@ public class TempCashOutTask implements ITask { cashOut.setState(1); cashOut.setOutAt(DateUtil.now()); cashOut.setRefund(null); + cashOut.setOutAt(DateUtil.now()); cashOutDao.updateById(cashOut); } } diff --git a/src/main/java/com/sqx/modules/pay/dao/CashOutDao.java b/src/main/java/com/sqx/modules/pay/dao/CashOutDao.java index c3a7ae1e..fd4e8cb8 100644 --- a/src/main/java/com/sqx/modules/pay/dao/CashOutDao.java +++ b/src/main/java/com/sqx/modules/pay/dao/CashOutDao.java @@ -7,6 +7,7 @@ import com.sqx.modules.pay.entity.CashOut; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; +import java.math.BigDecimal; import java.util.Date; import java.util.List; @@ -24,8 +25,10 @@ public interface CashOutDao extends BaseMapper { List selectTemp(); Double selectCashOutSum(@Param("userId") Long userId, @Param("startTime") Date startTime, @Param("endTime") Date endTime); + Integer selectTodayCashCount(@Param("userId") Long userId, @Param("state") Integer state); - Double selectSysUserCashOutSum(@Param("sysUserId") Long sysUserId, @Param("time") String time); + + Double selectSysUserCashOutSum(@Param("sysUserId") Long sysUserId, @Param("time") String time); Double sumMoney(@Param("time") String time, @Param("flag") Integer flag); @@ -33,7 +36,7 @@ public interface CashOutDao extends BaseMapper { Integer stayMoney(@Param("time") String time, @Param("flag") Integer flag); - void updateMayMoney(@Param("type") Integer type,@Param("userId")Long userId,@Param("money") Double money); + void updateMayMoney(@Param("type") Integer type, @Param("userId") Long userId, @Param("money") Double money); Double selectMayMoney(@Param("userId") Long userId); @@ -41,4 +44,6 @@ public interface CashOutDao extends BaseMapper { List selectCashOutList(@Param("cashOut") CashOut cashOut); + BigDecimal selectSumMoney(@Param("userId") Long userId, @Param("state") Integer state); + } diff --git a/src/main/java/com/sqx/modules/pay/entity/CashOut.java b/src/main/java/com/sqx/modules/pay/entity/CashOut.java index 818fd6c6..8c1e1d5b 100644 --- a/src/main/java/com/sqx/modules/pay/entity/CashOut.java +++ b/src/main/java/com/sqx/modules/pay/entity/CashOut.java @@ -125,6 +125,17 @@ public class CashOut implements Serializable { */ @TableField(exist = false) private Long count; + /** + * 待复审金额 + */ + @TableField(exist = false) + private BigDecimal verifyTotal; + + /** + * 待复审笔数 + */ + @TableField(exist = false) + private Long verifyCount; private Integer withdrawType; } diff --git a/src/main/java/com/sqx/modules/pay/service/CashOutService.java b/src/main/java/com/sqx/modules/pay/service/CashOutService.java index ef2ad8bb..2f62eae4 100644 --- a/src/main/java/com/sqx/modules/pay/service/CashOutService.java +++ b/src/main/java/com/sqx/modules/pay/service/CashOutService.java @@ -59,4 +59,8 @@ public interface CashOutService { PageUtils auditPage(Map params); void audit(CashOut cashOut); + + void batchAudit(Long userId, Integer isAgree, String refund); + + Map alipayTransferSummaryQuery(String alipayAccountName); } diff --git a/src/main/java/com/sqx/modules/pay/service/impl/CashOutServiceImpl.java b/src/main/java/com/sqx/modules/pay/service/impl/CashOutServiceImpl.java index 7ae63251..59820572 100644 --- a/src/main/java/com/sqx/modules/pay/service/impl/CashOutServiceImpl.java +++ b/src/main/java/com/sqx/modules/pay/service/impl/CashOutServiceImpl.java @@ -1,11 +1,14 @@ package com.sqx.modules.pay.service.impl; import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.convert.Convert; import cn.hutool.core.date.DateUtil; import cn.hutool.core.map.MapProxy; +import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.sqx.common.exception.SqxException; @@ -13,6 +16,7 @@ import com.sqx.common.utils.Constant; import com.sqx.common.utils.PageUtils; import com.sqx.common.utils.Result; import com.sqx.modules.app.dao.MsgDao; +import com.sqx.modules.app.dao.UserDao; import com.sqx.modules.app.entity.Msg; import com.sqx.modules.app.entity.UserEntity; import com.sqx.modules.app.entity.UserMoney; @@ -86,6 +90,9 @@ public class CashOutServiceImpl extends ServiceImpl impleme @Autowired private MsgDao msgDao; + @Autowired + private UserDao userDao; + @Override public PageUtils selectCashOutList(Integer page, Integer limit, CashOut cashOut) { return new PageUtils(baseMapper.selectCashOutPage(new Page<>(page, limit), cashOut)); @@ -444,7 +451,7 @@ public class CashOutServiceImpl extends ServiceImpl impleme // 最低提现金额 CommonInfo one = commonInfoService.findOne(112); - if(one!=null && money impleme if (WuyouPay.checkCanCash(userId, WithdrawTypeEnum.MANUAL, new BigDecimal(money.toString()))) { cashOut.setStatus(4); BaseResp baseResp = WuyouPay.extractOrder(outOrderNo, cashOut.getMoney(), cashOut.getZhifubao(), cashOut.getZhifubaoName()); - if (baseResp.getStatus() != null && (baseResp.getStatus().equals(2) || baseResp.getStatus().equals(10000))){ + if (baseResp.getStatus() != null && (baseResp.getStatus().equals(2) || baseResp.getStatus().equals(10000))) { userMoneyDetails.setContent("成功提现:" + money); cashOut.setState(1); } @@ -500,7 +507,7 @@ public class CashOutServiceImpl extends ServiceImpl impleme if (baseResp.getErrorMsg() != null) { return Result.error(baseResp.getErrorMsg()); } - }else { + } else { userMoneyDetails.setContent("成功提现:" + money); cashOut.setState(3); } @@ -541,7 +548,7 @@ public class CashOutServiceImpl extends ServiceImpl impleme if (entity == null) { throw new SqxException("提现申请不存在!"); } - if(entity.getState() != 3){ + if (entity.getState() != 3) { throw new SqxException("提现申请状态无效,请刷新后重试!"); } if (isAgree == 1) { @@ -551,7 +558,7 @@ public class CashOutServiceImpl extends ServiceImpl impleme entity.setRefund(cashOut.getRefund()); } UserEntity userEntity = userService.selectUserById(entity.getUserId()); - if(userEntity == null){ + if (userEntity == null) { throw new SqxException("提现用户信息不存在!"); } if (isAgree == 0) { @@ -564,6 +571,8 @@ public class CashOutServiceImpl extends ServiceImpl impleme userMoneyService.updateAmount(1, entity.getUserId(), Convert.toDouble(entity.getMoney())); return; } + entity.setState(4); + baseMapper.updateById(entity); if (StrUtil.isBlank(entity.getOrderNumber())) { String outOrderNo = AliPayOrderUtil.createOrderId(); entity.setOrderNumber(outOrderNo); @@ -586,4 +595,84 @@ public class CashOutServiceImpl extends ServiceImpl impleme baseMapper.updateById(entity); } + /** + * 批量审核 + * + * @param userId 用户id + * @param isAgree 1-同意 0-拒绝 + * @param refund 拒绝愿意 + */ + + @Override + public void batchAudit(Long userId, Integer isAgree, String refund) { + if (userId == null) { + throw new SqxException("用户id不能为空!"); + } + if (isAgree == null) { + throw new SqxException("请选择同意或者拒绝!"); + } + if (isAgree == 0 && StrUtil.isBlank(refund)) { + throw new SqxException("请输入拒绝原因!"); + } + List list = baseMapper.selectList(Wrappers.lambdaQuery().eq(CashOut::getUserId, userId).eq(CashOut::getState, 3).orderByAsc(CashOut::getCreateAt).orderByAsc(CashOut::getId)); + for (CashOut cashOut : list) { + cashOut.setIsAgree(isAgree); + cashOut.setRefund(refund); + queueAudit(cashOut); + } + } + + /** + * 排队提现审核 + * + * @param cashOut + */ + + public synchronized void queueAudit(CashOut cashOut) { + audit(cashOut); + } + + @Override + public Map alipayTransferSummaryQuery(String alipayAccountName) { + if(StrUtil.isBlank(alipayAccountName)){ + throw new SqxException("支付宝账号不能为空!"); + } + BigDecimal sum = BigDecimal.ZERO; + int count = 0; + Map data = new HashMap<>(8); + data.put("alipayAccountName", alipayAccountName); + data.put("sum", sum); + data.put("count", count); + List> list = new ArrayList<>(); + data.put("list", list); + List userList = userDao.selectList(Wrappers.lambdaQuery().eq(UserEntity::getZhiFuBaoName, alipayAccountName)); + if (CollUtil.isEmpty(userList)) { + return data; + } + + for (UserEntity entity : userList) { + Map record = new HashMap<>(); + record.put("userId", entity.getUserId()); + record.put("userName", entity.getUserName()); + record.put("inviterCode", entity.getInviterCode()); + record.put("phone", entity.getPhone()); + record.put("zhiFuBaoName", entity.getZhiFuBaoName()); + record.put("zhiFuBao", entity.getZhiFuBao()); + // 累计提现金额 + BigDecimal subSum = baseMapper.selectSumMoney(entity.getUserId(), 1); + record.put("subTotal", NumberUtil.null2Zero(subSum)); + // 累计提现次数 + Integer subCount = baseMapper.selectCount(Wrappers.lambdaQuery().eq(CashOut::getUserId, entity.getUserId()).eq(CashOut::getState, 1)); + record.put("subCount", subCount == null ? 0 : subCount); + list.add(record); + sum = NumberUtil.add(sum, NumberUtil.null2Zero(subSum)); + count = count + subCount; + } + data.put("sum", sum); + data.put("count", count); + data.put("list", list); + return data; + } + + } diff --git a/src/main/resources/mapper/pay/CashDao.xml b/src/main/resources/mapper/pay/CashDao.xml index 86e59598..07cd4311 100644 --- a/src/main/resources/mapper/pay/CashDao.xml +++ b/src/main/resources/mapper/pay/CashDao.xml @@ -78,11 +78,14 @@ ifnull(u.user_name,"用户不存在") as userName, s.username as sysUserName, ifnull(t.total,0.00) as total, - ifnull(t.count,0) as count + ifnull(t.count,0) as count, + ifnull(t1.total,0.00) as verifyTotal, + ifnull(t1.count,0) as verifyCount FROM cash_out c left join tb_user u on c.user_id = u.user_id left join sys_user s on s.user_id= c.sys_user_id left join (select user_id,format(sum(money),2) as total,count(*) as count from cash_out where state = 1 GROUP BY user_id) t on c.user_id = t.user_id + left join (select user_id,format(sum(money),2) as total,count(*) as count from cash_out where state = 3 GROUP BY user_id) t1 on c.user_id = t1.user_id and u.user_name like concat("%",#{cashOut.userName},"%") @@ -189,5 +192,8 @@ where user_id=#{userId} +