This commit is contained in:
parent
f3d3268f7b
commit
e3dfcb0e1d
|
|
@ -19,4 +19,6 @@ public interface AccSubService {
|
|||
AccBatchOperationWalletPreCheckVO batchOperationWalletAddCheck(AccSubsidyParam param);
|
||||
|
||||
AccBatchOperationWalletPreCheckVO batchOperationWalletClearCheck(AccSubsidyParam param);
|
||||
|
||||
public void addAccWalletBalance(BigDecimal amount, Long userId, Integer walletId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -204,9 +204,15 @@ public class AccSubServiceImpl implements AccSubService {
|
|||
operation.setUserId(userId);
|
||||
operation.setWalletId(walletId);
|
||||
operation.setOperationType(WalletBalanceOperationEnum.ADD_BAL.getKey());
|
||||
if (AccWalletIdEnum.SUBSIDY.getKey().equals(walletId)) {
|
||||
operation.setTradeType(AccTradeTypeEnum.SUBSIDY.getKey());
|
||||
operation.setPayChannel(PayChannelEnum.GW_SYSTEM.getKey());
|
||||
operation.setPayType(PayTypeEnum.SUB_GRANT.getKey());
|
||||
} else if (AccWalletIdEnum.WALLET.getKey().equals(walletId)) {
|
||||
operation.setTradeType(AccTradeTypeEnum.RECHARGE.getKey());
|
||||
operation.setPayChannel(PayChannelEnum.ALI.getKey());
|
||||
operation.setPayType(PayTypeEnum.ALI_H5_PAY.getKey());
|
||||
}
|
||||
accWalletInfoService.acWalletBalanceOperation(operation);
|
||||
log.info("新增补贴结束");
|
||||
} finally {
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import com.bonus.canteen.core.account.domain.vo.AccTradeVo;
|
|||
import com.bonus.canteen.core.account.mapper.AccOperationHistoryMapper;
|
||||
import com.bonus.common.core.exception.ServiceException;
|
||||
import com.bonus.common.core.utils.DateUtils;
|
||||
import com.bonus.common.houqin.utils.id.Id;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
|
@ -66,6 +67,7 @@ public class AccTradeServiceImpl implements IAccTradeService {
|
|||
try {
|
||||
AccTrade accTrade = new AccTrade();
|
||||
BeanUtils.copyProperties(accTradeVo, accTrade);
|
||||
accTrade.setTradeId(Id.next());
|
||||
return accTradeMapper.insertAccTrade(accTrade);
|
||||
} catch (Exception e) {
|
||||
throw new ServiceException("错误信息描述" + e.getMessage());
|
||||
|
|
|
|||
|
|
@ -3,11 +3,14 @@ package com.bonus.canteen.core.pay.controller;
|
|||
import com.alipay.api.AlipayApiException;
|
||||
import com.alipay.api.internal.util.AlipaySignature;
|
||||
import com.bonus.canteen.core.account.constants.AccTradeStateEnum;
|
||||
import com.bonus.canteen.core.account.constants.AccWalletIdEnum;
|
||||
import com.bonus.canteen.core.account.service.AccSubService;
|
||||
import com.bonus.canteen.core.account.service.IAccTradeService;
|
||||
import com.bonus.canteen.core.pay.constants.AliPayTradeStatusEnum;
|
||||
import com.bonus.canteen.core.pay.constants.PayStateEnum;
|
||||
import com.bonus.canteen.core.account.domain.vo.AccTradeVo;
|
||||
import com.bonus.canteen.core.pay.util.AlipayConfig;
|
||||
import com.bonus.common.security.utils.SecurityUtils;
|
||||
import io.swagger.annotations.Api;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -17,6 +20,7 @@ import javax.servlet.http.HttpServletRequest;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
|
@ -29,6 +33,8 @@ public class NotifyCotroller {
|
|||
|
||||
@Autowired
|
||||
IAccTradeService accTradeService;
|
||||
@Autowired
|
||||
AccSubService accSubService;
|
||||
|
||||
@RequestMapping("getnotify")
|
||||
public void getNotify(HttpServletRequest request, HttpServletResponse response) throws AlipayApiException, IOException {
|
||||
|
|
@ -55,6 +61,7 @@ public class NotifyCotroller {
|
|||
String order_no = request.getParameter("out_trade_no");
|
||||
//金额
|
||||
String total_amount = request.getParameter("total_amount");
|
||||
BigDecimal totalAmount = new BigDecimal(total_amount);
|
||||
//支付宝交易号
|
||||
String third_trade_no = request.getParameter("trade_no");
|
||||
//交易状态
|
||||
|
|
@ -71,6 +78,7 @@ public class NotifyCotroller {
|
|||
updateTrade.setTradeState(AccTradeStateEnum.TAKE_EFFECT.getKey().longValue());
|
||||
updateTrade.setFailReason(trade_status);
|
||||
this.accTradeService.updateAccTradeVoByOrderNo(updateTrade);
|
||||
this.accSubService.addAccWalletBalance(totalAmount, SecurityUtils.getUserId(), AccWalletIdEnum.WALLET.getKey());
|
||||
} else if (AliPayTradeStatusEnum.TRADE_STATUS_SUCCESS.getKey().equals(trade_status)) {
|
||||
//判断该笔订单是否已经做过处理
|
||||
//如果没做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详情,判断金额是否等于 total_amount,并执行商户的业务程序
|
||||
|
|
@ -83,8 +91,7 @@ public class NotifyCotroller {
|
|||
updateTrade.setTradeState(AccTradeStateEnum.TAKE_EFFECT.getKey().longValue());
|
||||
updateTrade.setFailReason(trade_status);
|
||||
this.accTradeService.updateAccTradeVoByOrderNo(updateTrade);
|
||||
//TODO 增加用户的个人钱包 acc_wallet_info
|
||||
|
||||
this.accSubService.addAccWalletBalance(totalAmount, SecurityUtils.getUserId(), AccWalletIdEnum.WALLET.getKey());
|
||||
} else {
|
||||
AccTradeVo updateTrade = new AccTradeVo();
|
||||
updateTrade.setOrderNo(order_no);
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ import com.alipay.api.response.AlipayTradePagePayResponse;
|
|||
import com.alipay.api.response.AlipayTradeQueryResponse;
|
||||
import com.bonus.canteen.core.account.constants.AccTradeStateEnum;
|
||||
import com.bonus.canteen.core.account.constants.AccTradeTypeEnum;
|
||||
import com.bonus.canteen.core.account.constants.AccWalletIdEnum;
|
||||
import com.bonus.canteen.core.account.service.AccSubService;
|
||||
import com.bonus.canteen.core.account.service.IAccTradeService;
|
||||
import com.bonus.canteen.core.pay.constants.AliPayTradeStatusEnum;
|
||||
import com.bonus.canteen.core.pay.constants.PayStateEnum;
|
||||
|
|
@ -43,6 +45,8 @@ public class PayController {
|
|||
AlipayTradePagePayRequest alipayRequest;
|
||||
@Autowired
|
||||
IAccTradeService accTradeService;
|
||||
@Autowired
|
||||
AccSubService accSubService;
|
||||
|
||||
@PostMapping("pay")
|
||||
public void pay(@RequestBody AccTradeVo accTradeVo, HttpServletResponse response) throws AlipayApiException, IOException {
|
||||
|
|
@ -107,8 +111,8 @@ public class PayController {
|
|||
updateTrade.setTradeState(AccTradeStateEnum.TAKE_EFFECT.getKey().longValue());
|
||||
updateTrade.setFailReason(trade_status);
|
||||
this.accTradeService.updateAccTradeVoByOrderNo(updateTrade);
|
||||
//TODO 增加用户的个人钱包 acc_wallet_info
|
||||
|
||||
BigDecimal totalAmount = new BigDecimal(response.getTotalAmount());
|
||||
accSubService.addAccWalletBalance(totalAmount, accTradeVo.getUserId(), AccWalletIdEnum.WALLET.getKey());
|
||||
}
|
||||
return response;
|
||||
} catch (AlipayApiException e) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue