提现审核相关接口+支付宝提现统计接口

This commit is contained in:
谭凯凯 2024-12-27 16:55:53 +08:00 committed by Tankaikai
parent 3d263960e8
commit 666a347433
7 changed files with 141 additions and 8 deletions

View File

@ -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<String, Object> data = cashOutService.alipayTransferSummaryQuery(alipayAccountName);
return Result.success().put("data", data);
}
}

View File

@ -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);
}
}

View File

@ -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<CashOut> {
List<CashOut> 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<CashOut> {
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<CashOut> {
List<CashOut> selectCashOutList(@Param("cashOut") CashOut cashOut);
BigDecimal selectSumMoney(@Param("userId") Long userId, @Param("state") Integer state);
}

View File

@ -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;
}

View File

@ -59,4 +59,8 @@ public interface CashOutService {
PageUtils auditPage(Map<String, Object> params);
void audit(CashOut cashOut);
void batchAudit(Long userId, Integer isAgree, String refund);
Map<String,Object> alipayTransferSummaryQuery(String alipayAccountName);
}

View File

@ -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<CashOutDao, CashOut> 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<CashOutDao, CashOut> impleme
// 最低提现金额
CommonInfo one = commonInfoService.findOne(112);
if(one!=null && money<Double.parseDouble(one.getValue())){
if (one != null && money < Double.parseDouble(one.getValue())) {
return Result.error("不满足最低提现金额,请重新输入!");
}
@ -492,7 +499,7 @@ public class CashOutServiceImpl extends ServiceImpl<CashOutDao, CashOut> 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<CashOutDao, CashOut> 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<CashOutDao, CashOut> 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<CashOutDao, CashOut> 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<CashOutDao, CashOut> 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<CashOutDao, CashOut> 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<CashOut> list = baseMapper.selectList(Wrappers.<CashOut>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<String, Object> alipayTransferSummaryQuery(String alipayAccountName) {
if(StrUtil.isBlank(alipayAccountName)){
throw new SqxException("支付宝账号不能为空!");
}
BigDecimal sum = BigDecimal.ZERO;
int count = 0;
Map<String, Object> data = new HashMap<>(8);
data.put("alipayAccountName", alipayAccountName);
data.put("sum", sum);
data.put("count", count);
List<Map<String, Object>> list = new ArrayList<>();
data.put("list", list);
List<UserEntity> userList = userDao.selectList(Wrappers.<UserEntity>lambdaQuery().eq(UserEntity::getZhiFuBaoName, alipayAccountName));
if (CollUtil.isEmpty(userList)) {
return data;
}
for (UserEntity entity : userList) {
Map<String, Object> 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.<CashOut>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;
}
}

View File

@ -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
<where>
<if test="cashOut.userName!=null and cashOut.userName!=''">
and u.user_name like concat("%",#{cashOut.userName},"%")
@ -189,5 +192,8 @@
where user_id=#{userId}
</update>
<select id="selectSumMoney" resultType="java.math.BigDecimal">
select format(sum(money),2) from cash_out where state = #{state} and user_id = #{userId}
</select>
</mapper>