|
|
@@ -103,6 +103,8 @@ public class WxPayServiceImpl implements WxPayService {
|
|
|
|
|
|
private final ActivityService activityService;
|
|
|
|
|
|
+ private final UserRechargeRightsService userRechargeRightsService;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 微信支付专用,支持自动签名验签解密等
|
|
|
@@ -113,7 +115,7 @@ public class WxPayServiceImpl implements WxPayService {
|
|
|
public WxPayServiceImpl(WxPayConfig conf, WxFapiaoConfig fapiaoConfig, WalletDetailService walletDetailService,
|
|
|
PayLogService payLogService, AccountService accountService, ChargeOrderService chargeOrderService,
|
|
|
RefundLogService refundLogService, InvoiceService invoiceService, InvoiceTitleService invoiceTitleService,
|
|
|
- EnPlusService enPlusService, ActivityService activityService) {
|
|
|
+ EnPlusService enPlusService, ActivityService activityService, UserRechargeRightsService userRechargeRightsService) {
|
|
|
this.conf = conf;
|
|
|
this.fapiaoConfig = fapiaoConfig;
|
|
|
this.walletDetailService = walletDetailService;
|
|
|
@@ -125,6 +127,7 @@ public class WxPayServiceImpl implements WxPayService {
|
|
|
this.invoiceTitleService = invoiceTitleService;
|
|
|
this.enPlusService = enPlusService;
|
|
|
this.activityService = activityService;
|
|
|
+ this.userRechargeRightsService = userRechargeRightsService;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -390,6 +393,10 @@ public class WxPayServiceImpl implements WxPayService {
|
|
|
// 将余额转移至冻结余额
|
|
|
accountService.lambdaUpdate().setSql(" frozen_amount = (frozen_amount + balance) ,balance = 0").eq(Account::getUserId, userId).update();
|
|
|
|
|
|
+ // 退款时,充值权益失效(权益余额转入冻结余额,接收退款通知时权益状态设置为失效)
|
|
|
+ userRechargeRightsService.lambdaUpdate().setSql("frozen_balance = rights_balance")
|
|
|
+ .eq(UserRechargeRights::getUserId, userId).eq(UserRechargeRights::getStatus, UserRechargeRights.STATUS_有效).update();
|
|
|
+
|
|
|
// 余减去优惠金额作为退款金额
|
|
|
AtomicInteger refundAmount = new AtomicInteger(account.getBalance() - account.getDiscountAmount());
|
|
|
var originalRefundAmount = refundAmount.get();
|
|
|
@@ -578,6 +585,12 @@ public class WxPayServiceImpl implements WxPayService {
|
|
|
.set(WalletDetail::getTransactionTime, successTime)
|
|
|
.eq(WalletDetail::getId, walletDetail.getId()).update();
|
|
|
LOGGER.info("微信退款回调{}:业务处理结束", notifyRes[2]);
|
|
|
+
|
|
|
+ // 退款时,充值权益失效(权益余额转入冻结余额,接收退款通知时权益状态设置为失效)
|
|
|
+ userRechargeRightsService.lambdaUpdate().set(UserRechargeRights::getStatus,UserRechargeRights.STATUS_无效)
|
|
|
+ .eq(UserRechargeRights::getUserId, walletDetail.getUserId())
|
|
|
+ .eq(UserRechargeRights::getStatus, UserRechargeRights.STATUS_有效).update();
|
|
|
+
|
|
|
return ResponseEntity.status(HttpStatus.OK).build();
|
|
|
} else {
|
|
|
// 退款失败
|
|
|
@@ -765,11 +778,11 @@ public class WxPayServiceImpl implements WxPayService {
|
|
|
public void fapiaoApplication(String invoiceId) {
|
|
|
var invoice = invoiceService.lambdaQuery().eq(Invoice::getId, invoiceId).one();
|
|
|
// 开票状态校验
|
|
|
- if(!invoice.getStatus().equals(Invoice.STATUS_待开票)){
|
|
|
+ if (!invoice.getStatus().equals(Invoice.STATUS_待开票)) {
|
|
|
throw new BusinessException("发票状态为开票中或已开票");
|
|
|
}
|
|
|
// 记录开票人
|
|
|
- invoiceService.lambdaUpdate().set(Invoice::getBiller,StpUtil.getSession().getString("username")).eq(Invoice::getId,invoice.getId()).update();
|
|
|
+ invoiceService.lambdaUpdate().set(Invoice::getBiller, StpUtil.getSession().getString("username")).eq(Invoice::getId, invoice.getId()).update();
|
|
|
|
|
|
// 订单金额+ ,服务费优惠金额- 服务费优惠金额单独一个item,金额为负数
|
|
|
var itemList = new ArrayList<FaPiao.FaPiaoInfomation.IssueItem>();
|