14 changed files with 167 additions and 157 deletions
@ -1,14 +1,92 @@ |
|||||
package com.base.springcloud.service.imp; |
package com.base.springcloud.service.imp; |
||||
|
|
||||
|
import com.base.springcloud.aspect.annotation.BusinessException; |
||||
import com.base.springcloud.bo.RefundBO; |
import com.base.springcloud.bo.RefundBO; |
||||
|
import com.base.springcloud.constant.ErrorConstant; |
||||
|
import com.base.springcloud.constant.PaymentConstant; |
||||
|
import com.base.springcloud.dao.RefundMapper; |
||||
|
import com.base.springcloud.entity.Order; |
||||
|
import com.base.springcloud.entity.Refund; |
||||
|
import com.base.springcloud.service.OrderService; |
||||
import com.base.springcloud.service.RefundService; |
import com.base.springcloud.service.RefundService; |
||||
|
import com.base.springcloud.service.WecPaymentService; |
||||
|
import com.base.springcloud.util.DateUtil; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Service; |
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
import java.util.UUID; |
||||
|
|
||||
@Service |
@Service |
||||
public class RefundServiceImp implements RefundService { |
public class RefundServiceImp implements RefundService { |
||||
|
|
||||
|
@Autowired |
||||
|
private OrderService orderService; |
||||
|
|
||||
|
@Autowired |
||||
|
private WecPaymentService wecPaymentService; |
||||
|
|
||||
|
@Autowired |
||||
|
private RefundMapper refundMapper; |
||||
|
|
||||
|
/** |
||||
|
* 退款 |
||||
|
* @param refundBO |
||||
|
*/ |
||||
@Override |
@Override |
||||
public void refund(RefundBO refundBO) { |
public void refund(RefundBO refundBO) { |
||||
|
// RBS-退款金额获取
|
||||
|
|
||||
|
// 退款限制检查
|
||||
|
|
||||
|
// 查询原支付订单
|
||||
|
orderService.origOrderCheck(refundBO); |
||||
|
// 登记退款信息
|
||||
|
registerRfund(refundBO); |
||||
|
// 发送微信退款
|
||||
|
Boolean refundResult = wecPaymentService.wecRefund(refundBO); |
||||
|
// 同步退款信息
|
||||
|
if(refundResult) |
||||
|
updateRefundSuccess(refundBO); |
||||
|
// RBS-业务逻辑处理
|
||||
} |
} |
||||
|
|
||||
|
/** |
||||
|
* 登记退款 |
||||
|
* @param refundBO |
||||
|
*/ |
||||
|
private void registerRfund(RefundBO refundBO) { |
||||
|
Refund refund = new Refund(); |
||||
|
refund.setId(UUID.randomUUID().toString().replace("-", "")); |
||||
|
refund.setCreateId(refundBO.getCreateId()); |
||||
|
refund.setCreateTime(new Date()); |
||||
|
refund.setReason(refundBO.getReason()); |
||||
|
refund.setRefundOrderNo(DateUtil.getDateString(25)); |
||||
|
refund.setRefundTime(new Date()); |
||||
|
refund.setRefundState(PaymentConstant.REFUND_WAIT); |
||||
|
refund.setRefundRetryCount(PaymentConstant.START_REFUND_COUNT); |
||||
|
Order order = refundBO.getOrder(); |
||||
|
refund.setOrigOrderNo(order.getOrderNo()); |
||||
|
refund.setOrigOrderTime(order.getCreateTime()); |
||||
|
// FIXME 原销售单据id
|
||||
|
// refund.setSourceBillId();
|
||||
|
int count = refundMapper.insert(refund); |
||||
|
if(count < 1) |
||||
|
throw new BusinessException(ErrorConstant.REGISTER_REFUND_FAIL); |
||||
|
refundBO.setRefundNo(refund.getRefundOrderNo()); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 同步退款状态 |
||||
|
* @param refundBO |
||||
|
*/ |
||||
|
private void updateRefundSuccess(RefundBO refundBO) { |
||||
|
Refund refund = new Refund(); |
||||
|
refund.setRefundOrderNo(refundBO.getRefundNo()); |
||||
|
refund.setRefundState(PaymentConstant.REFUND_SUCCESS); |
||||
|
int count = refundMapper.updateRefundSuccess(refund); |
||||
|
if(count < 1) |
||||
|
throw new BusinessException(ErrorConstant.SYNC_WEC_REFUND_STATE_FAIL); |
||||
|
} |
||||
|
|
||||
} |
} |
||||
|
|||||
Loading…
Reference in new issue