|
|
@@ -1,19 +1,28 @@
|
|
|
package io.renren.modules.qyh.api;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import io.renren.common.annotation.RepeatSubmit;
|
|
|
+import io.renren.common.enums.WithdrawAuditStateEnum;
|
|
|
+import io.renren.common.enums.WithdrawPaymentTermEnum;
|
|
|
import io.renren.common.utils.Constant;
|
|
|
import io.renren.common.utils.PageUtils;
|
|
|
import io.renren.common.utils.R;
|
|
|
+import io.renren.modules.qmgj.wxpayutil.NewWxPayUtil;
|
|
|
import io.renren.modules.qyh.entity.WithdrawInfoEntity;
|
|
|
import io.renren.modules.qyh.model.vo.MyWalletVO;
|
|
|
import io.renren.modules.qyh.service.MemberWalletService;
|
|
|
import io.renren.modules.qyh.service.WithdrawInfoService;
|
|
|
+import io.renren.modules.wechat.entity.TransferNotification;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.http.MediaType;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
@@ -30,6 +39,9 @@ public class ApiWithdrawController {
|
|
|
@Autowired
|
|
|
private MemberWalletService memberWalletService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private NewWxPayUtil wxPayUtil;
|
|
|
+
|
|
|
/**
|
|
|
* 我的钱包
|
|
|
*/
|
|
|
@@ -61,4 +73,41 @@ public class ApiWithdrawController {
|
|
|
return R.ok().put("page", page);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 转账回调
|
|
|
+ */
|
|
|
+ @PostMapping(value = "transferCallback", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
+ @ResponseBody
|
|
|
+ @RepeatSubmit()
|
|
|
+ public String transferCallback(HttpServletRequest request) {
|
|
|
+ try {
|
|
|
+ // 1. 验签并解析通知
|
|
|
+ TransferNotification notification = wxPayUtil.transferNotify(request);
|
|
|
+ // 2. 根据业务单号查询提现记录
|
|
|
+ String outBatchNo = notification.getOutBatchNo();
|
|
|
+ WithdrawInfoEntity entity = withdrawInfoService.getOne(
|
|
|
+ new LambdaQueryWrapper<WithdrawInfoEntity>()
|
|
|
+ .eq(WithdrawInfoEntity::getBusinessCode, outBatchNo));
|
|
|
+ if (entity == null) {
|
|
|
+ return "{\"code\":\"FAIL\",\"message\":\"订单不存在\"}";
|
|
|
+ }
|
|
|
+ if (!entity.getPaymentTerm().equals(WithdrawPaymentTermEnum.WECHAT.value())) {
|
|
|
+ return "{\"code\":\"FAIL\",\"message\":\"订单类型不是微信支付\"}";
|
|
|
+ }
|
|
|
+ if (!entity.getAuditState().equals(WithdrawAuditStateEnum.AUDIT_PASS.value())) {
|
|
|
+ return "{\"code\":\"FAIL\",\"message\":\"订单状态不是审核通过\"}";
|
|
|
+ }
|
|
|
+ // 微信回调返回的金额单位是分,需要转换为元后比较
|
|
|
+ BigDecimal successAmountYuan = new BigDecimal(notification.getSuccessAmount())
|
|
|
+ .divide(new BigDecimal("100"), 2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ if (entity.getMoney().compareTo(successAmountYuan) != 0) {
|
|
|
+ return "{\"code\":\"FAIL\",\"message\":\"金额不一致\"}";
|
|
|
+ }
|
|
|
+ // 处理提现状态
|
|
|
+ withdrawInfoService.handleTransferStatus(entity, notification.getBatchStatus(), notification.getBatchId());
|
|
|
+ return "{\"code\":\"SUCCESS\",\"message\":\"成功\"}";
|
|
|
+ } catch (Exception e) {
|
|
|
+ return "{\"code\":\"FAIL\",\"message\":\"处理失败\"}";
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|