转账到零钱参数完善

This commit is contained in:
张松 2025-10-29 17:03:00 +08:00
parent 0c3d5a0fcc
commit e19457de26
5 changed files with 54 additions and 4 deletions

View File

@ -72,6 +72,23 @@ public class NotifyController {
return SUCCESS;
}
@RequestMapping("/native/wx/transfer")
public String nativeTransferNotify(HttpServletRequest request) throws IOException {
log.info("接收到微信转账回调");
JSONObject jsonObject = wxService.verifySignature(request);
log.info("参数信息: {}", jsonObject.toJSONString());
String outBillNo = jsonObject.getString("out_bill_no");
String state = jsonObject.getString("state");
try {
distributionUserService.withdrawNotify(outBillNo, state);
}catch (Exception e) {
log.warn("转账回调失败", e);
}
return "SUCCESS";
}
@RequestMapping("/native/wx/pay/distributionRecharge")
public String nativeNotify(HttpServletRequest request) throws IOException {
String timestamp = request.getHeader("Wechatpay-Timestamp");

View File

@ -131,4 +131,18 @@ public interface MkDistributionUserService extends IService<MkDistributionUser>
Boolean withdraw(long userId, MkDistributionWithdrawFlowDTO withdrawFlowDTO);
Map<String, Object> withdrawDetail(long userId, Long id);
/**
* 微信转账回调
* @param outBillNo 转账单号
* @param state ACCEPTED单据已受理
* PROCESSING单据处理中转账结果尚未明确如一直处于此状态建议检查账户余额是否足够
* WAIT_USER_CONFIRM待收款用户确认可拉起微信收款确认页面进行收款确认
* TRANSFERING转账中转账结果尚未明确可拉起微信收款确认页面再次重试确认收款
* SUCCESS 转账成功
* FAIL 转账失败
* CANCELING 撤销中
* CANCELLED 已撤销
*/
void withdrawNotify(String outBillNo, String state);
}

View File

@ -64,10 +64,11 @@ public interface TableValueConstant {
@Getter
enum Status {
PENDING("pending", "提现中"),
REFUND("refund", "提现中"),
SUB("sub", "系统扣减"),
OPEN("open", "分销员购买"),
FINISH("finish", "已提现"),
SELF_RECHARGE("self_recharge", "自助充值");
SELF_RECHARGE("self_recharge", "自助充值"), FAIL("fail", "失败");
private final String code;
private final String msg;

View File

@ -159,8 +159,6 @@ public abstract class BaseWx {
}
public JSONObject verifySignature(HttpServletRequest request) {
try {
log.info("开始校验签名并解密");
String timestamp = request.getHeader("Wechatpay-Timestamp");

View File

@ -663,7 +663,7 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
JSONObject jsonObject = appWxService.transferBalance(userInfo.getWechatOpenId(), userInfo.getRealName(), finalAmount, "提现", withdrawFlow.getBillNo());
withdrawFlow.setPackageInfo(jsonObject.getString("package_info"));
// 扣减余额
userInfoService.updateDistributionAmount(userId, withdrawFlow.getAmount().negate());
userInfoService.updateDistributionAmount(userId, withdrawFlowDTO.getAmount().negate());
return withdrawFlowService.save(withdrawFlow);
}
@ -679,4 +679,24 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
"package", flow.getPackageInfo()
);
}
@Override
public void withdrawNotify(String outBillNo, String state) {
MkDistributionWithdrawFlow flow = withdrawFlowService.getOne(new QueryWrapper().eq(MkDistributionWithdrawFlow::getBillNo, outBillNo));
AssertUtil.isNull(flow, "提现记录不存在");
switch (state) {
case "SUCCESS":
flow.setStatus(TableValueConstant.DistributionWithdrawFlow.Status.FINISH.getCode());
break;
case "FAIL":
flow.setStatus(TableValueConstant.DistributionWithdrawFlow.Status.FAIL.getCode());
case "CANCELLED":
flow.setStatus(TableValueConstant.DistributionWithdrawFlow.Status.FAIL.getCode());
// 扣减余额
userInfoService.updateDistributionAmount(flow.getUserId(), flow.getAmount().add(flow.getServiceFee()));
break;
}
withdrawFlowService.updateById(flow);
}
}