|
|
|
@@ -1178,6 +1178,18 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { |
|
|
|
throw new MallinkException(ErrorCode.DB_FAIL); |
|
|
|
} |
|
|
|
|
|
|
|
WxCardSpend cardSpendUpd = new WxCardSpend(); |
|
|
|
cardSpendUpd.setId(cardSend.getId()); |
|
|
|
cardSpendUpd.updateTenantInfo(cardSend); |
|
|
|
cardSpendUpd.setPayStatus(EnumCardSpendStatus.PENDING_REFUND.getCode()); |
|
|
|
cardSpendUpd.setUpdateDate(currentDate); |
|
|
|
try { |
|
|
|
wxCardSpendMapper.updateById(cardSpendUpd); |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("卡退款订单修改出错: " + record.toString()); |
|
|
|
throw new MallinkException(ErrorCode.DB_FAIL); |
|
|
|
} |
|
|
|
|
|
|
|
refundCardOrderSuccess(record,wxOrder); |
|
|
|
|
|
|
|
return new ResultData(); |
|
|
|
@@ -1188,7 +1200,7 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { |
|
|
|
public ResultData refundCardOrderSuccess(WxRefundOrder refundOrder,WxOrder wxOrder) { |
|
|
|
Long cardSpendId = Long.parseLong(refundOrder.getPayOrderNo()); |
|
|
|
WxCardSpend cardSend = wxCardSpendMapper.selectById(cardSpendId); |
|
|
|
if(cardSend == null || EnumPayType.PAY_PAYMENT.getCode().equals(cardSend.getPayType())){ |
|
|
|
if(cardSend == null){ |
|
|
|
logger.error("付款订单未找到, e:"); |
|
|
|
throw new MallinkException(ErrorCode.ORDER_IS_NOT_FIND); |
|
|
|
} |
|
|
|
@@ -1243,7 +1255,7 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { |
|
|
|
record.setCardRemainAmount(remaingAmount); |
|
|
|
record.setCardBeforeRealAmount(cardInfo.getRemainingShareFeeAmount()); |
|
|
|
record.setCardRemainRealAmount(remain_real_pament); |
|
|
|
record.setPayStatus(EnumCardSpendStatus.PS_SHARED.getCode());//已退款 |
|
|
|
record.setPayStatus(EnumCardSpendStatus.REFUND_SUCCESS.getCode());//已退款 |
|
|
|
|
|
|
|
record.setCreateDate(currentDate); |
|
|
|
record.setUpdateDate(currentDate); |
|
|
|
@@ -1276,6 +1288,18 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { |
|
|
|
throw new MallinkException(ErrorCode.ORDER_UPDATE_ERR); |
|
|
|
} |
|
|
|
|
|
|
|
WxCardSpend cardSpendUpd = new WxCardSpend(); |
|
|
|
cardSpendUpd.setId(cardSend.getId()); |
|
|
|
cardSpendUpd.updateTenantInfo(cardSend); |
|
|
|
cardSpendUpd.setPayStatus(EnumCardSpendStatus.REFUND_SUCCESS.getCode()); |
|
|
|
cardSpendUpd.setUpdateDate(currentDate); |
|
|
|
try { |
|
|
|
wxCardSpendMapper.updateById(cardSpendUpd); |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("卡退款订单修改出错: " + record.toString()); |
|
|
|
throw new MallinkException(ErrorCode.DB_FAIL); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
WxCardInfo updateCardInfo = new WxCardInfo(); |
|
|
|
updateCardInfo.setId(cardInfo.getId()); |
|
|
|
@@ -1304,42 +1328,36 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { |
|
|
|
//退补贴 |
|
|
|
Double subsidyD = 1.0 * cardSend.getSubsidy() * refundFee / cardSend.getDeductionAmount(); |
|
|
|
subsidyFee = subsidyD.intValue(); |
|
|
|
if(subsidyFee > 0){ |
|
|
|
int iSubChargeFee = PayUtils.getPayRate(subsidyFee, payAccount.getRealRate(), false); |
|
|
|
Integer realSubsidyFee = subsidyFee - iSubChargeFee; |
|
|
|
|
|
|
|
WxMerchantSubsidy merchantSubsidy = new WxMerchantSubsidy(); |
|
|
|
merchantSubsidy.setId(idWorker.nextId()); |
|
|
|
merchantSubsidy.updateTenantInfo(record); |
|
|
|
merchantSubsidy.setOrderId(wxOrder.getId()); |
|
|
|
merchantSubsidy.setOrderType(EnumOrderType.PREPAIDCARD.getCode()); |
|
|
|
merchantSubsidy.setMerchantId(record.getMerchantId()); |
|
|
|
merchantSubsidy.setBTenantId(record.getTenantId()); |
|
|
|
merchantSubsidy.setCouponOrderId(cardInfo.getId()); |
|
|
|
merchantSubsidy.setCouponType(EnumCouponType.CARD_MULTIMCH.getCode()); |
|
|
|
merchantSubsidy.setOrderPayment(0-record.getDeductionAmount()); |
|
|
|
merchantSubsidy.setReceiverPayment(0-refund); |
|
|
|
merchantSubsidy.setRealPayment(0-real_refund); |
|
|
|
merchantSubsidy.setSubsidy(0-subsidyFee); |
|
|
|
merchantSubsidy.setRealSubsidy(0-realSubsidyFee); |
|
|
|
merchantSubsidy.setStatus(EnumMerchantSubsidyStatus.NOT_SUBSIDY.getCode()); |
|
|
|
|
|
|
|
merchantSubsidy.setType(EnumMerchantSubsidyType.MANUAL.getCode()); |
|
|
|
merchantSubsidy.setSource(EnumMerchantSubsidySource.CARD.getCode()); |
|
|
|
|
|
|
|
//如果是有价卡,并且有补贴,则该记录不能显示在卡消费列表里面 |
|
|
|
if (cardInfo.getSaleAmount()>0 && subsidyFee > 0) { |
|
|
|
merchantSubsidy.setCardSpendListShow(0); |
|
|
|
} |
|
|
|
|
|
|
|
merchantSubsidy.setCreateDate(currentDate); |
|
|
|
merchantSubsidy.setUpdateDate(currentDate); |
|
|
|
WxMerchantSubsidy merchantSubsidy = new WxMerchantSubsidy(); |
|
|
|
merchantSubsidy.updateTenantInfo(record); |
|
|
|
merchantSubsidy.setOrderId(wxOrder.getId()); |
|
|
|
merchantSubsidy.setOrderType(EnumOrderType.PREPAIDCARD.getCode()); |
|
|
|
WxMerchantSubsidy wxMerchantSubsidy = wxMerchantSubsidyMapper.selectOne(new QueryWrapper<>(merchantSubsidy)); |
|
|
|
if(wxMerchantSubsidy == null){ |
|
|
|
logger.error("未找到补贴数据 error"); |
|
|
|
throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "未找到补贴数据 插入出错!"); |
|
|
|
} |
|
|
|
|
|
|
|
Double realSubsidyD = 1.0 * cardSend.getRealPayment() * refundFee / cardSend.getDeductionAmount(); |
|
|
|
Integer realSubsidyFee = realSubsidyD.intValue(); |
|
|
|
|
|
|
|
if(EnumMerchantSubsidyStatus.NOT_SUBSIDY.getCode().equals(wxMerchantSubsidy.getStatus())){ |
|
|
|
wxMerchantSubsidy.setOrderPayment(wxMerchantSubsidy.getOrderPayment()-record.getDeductionAmount()); |
|
|
|
wxMerchantSubsidy.setReceiverPayment(wxMerchantSubsidy.getReceiverPayment()-refund); |
|
|
|
wxMerchantSubsidy.setRealPayment(wxMerchantSubsidy.getRealPayment()-real_refund); |
|
|
|
wxMerchantSubsidy.setSubsidy(wxMerchantSubsidy.getSubsidy()-subsidyFee); |
|
|
|
wxMerchantSubsidy.setRealSubsidy(wxMerchantSubsidy.getRealSubsidy()-realSubsidyFee); |
|
|
|
wxMerchantSubsidy.setUpdateDate(currentDate); |
|
|
|
try { |
|
|
|
wxMerchantSubsidyMapper.insert(merchantSubsidy); |
|
|
|
wxMerchantSubsidyMapper.updateById(wxMerchantSubsidy); |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("merchantSubsidy info insert error"); |
|
|
|
throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "merchantSubsidy info 插入出错!"); |
|
|
|
logger.error("退补贴数据 修改失败info update error"); |
|
|
|
throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "merchantSubsidy info 修改出错!"); |
|
|
|
} |
|
|
|
}else{ |
|
|
|
logger.error("补贴数据已结算 无法退款 error"); |
|
|
|
throw new MallinkException(ErrorCode.SYS_METHOD_NOT_SUPPORT.getCode(), "补贴数据已结算"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|