学习培训订单支付业务逻辑修改
This commit is contained in:
parent
8789793dd5
commit
8bc6eea4be
@ -83,7 +83,6 @@ public class WeChatPayNotifyServiceImpl implements WeChatPayNotifyService {
|
|||||||
private RedisTemplate<String, Object> redisTemplate;
|
private RedisTemplate<String, Object> redisTemplate;
|
||||||
@Resource
|
@Resource
|
||||||
private PatientCouponReceiveMapper patientCouponReceiveMapper;
|
private PatientCouponReceiveMapper patientCouponReceiveMapper;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private TrainingOrderMapper trainingOrderMapper;
|
private TrainingOrderMapper trainingOrderMapper;
|
||||||
|
|
||||||
@ -222,7 +221,7 @@ public class WeChatPayNotifyServiceImpl implements WeChatPayNotifyService {
|
|||||||
//商品订单信息
|
//商品订单信息
|
||||||
GoodsOrder goodsOrderInfo = goodsOrderMapper.getGoodsOrderByOrderNo(notifyPlaintext.getOutTradeNo());
|
GoodsOrder goodsOrderInfo = goodsOrderMapper.getGoodsOrderByOrderNo(notifyPlaintext.getOutTradeNo());
|
||||||
if (Objects.nonNull(goodsOrderInfo)) {
|
if (Objects.nonNull(goodsOrderInfo)) {
|
||||||
insertPaymentInfo(notifyPlaintext, goodsOrderInfo, null,null, plainText);
|
insertPaymentInfo(notifyPlaintext, goodsOrderInfo, null, null, plainText);
|
||||||
if (WeChatTradeStateEnum.SUCCESS.getInfo().equals(notifyPlaintext.getTradeState())) {
|
if (WeChatTradeStateEnum.SUCCESS.getInfo().equals(notifyPlaintext.getTradeState())) {
|
||||||
goodsOrderMapper.updateGoodsOrderStatus(GooodsOrderStatusEnum.WAIT_RECEIVED_GOODS.getInfo(), goodsOrderInfo.getOrderNo());
|
goodsOrderMapper.updateGoodsOrderStatus(GooodsOrderStatusEnum.WAIT_RECEIVED_GOODS.getInfo(), goodsOrderInfo.getOrderNo());
|
||||||
} else {
|
} else {
|
||||||
@ -236,7 +235,7 @@ public class WeChatPayNotifyServiceImpl implements WeChatPayNotifyService {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//预约服务订单信息
|
//预约服务订单信息
|
||||||
insertPaymentInfo(notifyPlaintext, null, appointmentOrderInfo,null, plainText);
|
insertPaymentInfo(notifyPlaintext, null, appointmentOrderInfo, null, plainText);
|
||||||
if (WeChatTradeStateEnum.SUCCESS.getInfo().equals(notifyPlaintext.getTradeState())) {
|
if (WeChatTradeStateEnum.SUCCESS.getInfo().equals(notifyPlaintext.getTradeState())) {
|
||||||
appointmentOrderMapper.updateAppointmentOrderStatus(OrderStatusEnum.WAIT_DISPATCH.getInfo(), appointmentOrderInfo.getOrderNo());
|
appointmentOrderMapper.updateAppointmentOrderStatus(OrderStatusEnum.WAIT_DISPATCH.getInfo(), appointmentOrderInfo.getOrderNo());
|
||||||
} else {
|
} else {
|
||||||
@ -262,10 +261,10 @@ public class WeChatPayNotifyServiceImpl implements WeChatPayNotifyService {
|
|||||||
* @param plainText 回调明文
|
* @param plainText 回调明文
|
||||||
*/
|
*/
|
||||||
private void insertPaymentInfo(WeChatPayNotifyPlaintextVO notifyPlaintext, GoodsOrder goodsOrderInfo,
|
private void insertPaymentInfo(WeChatPayNotifyPlaintextVO notifyPlaintext, GoodsOrder goodsOrderInfo,
|
||||||
AppointmentOrder appointmentOrder,TrainingOrder trainingOrderInfo, String plainText) {
|
AppointmentOrder appointmentOrder, TrainingOrder trainingOrderInfo, String plainText) {
|
||||||
int paymentInfoCount = paymentInfoMapper.getPaymentInfoByOrderNo(notifyPlaintext.getOutTradeNo());
|
int paymentInfoCount = paymentInfoMapper.getPaymentInfoByOrderNo(notifyPlaintext.getOutTradeNo());
|
||||||
if (paymentInfoCount <= 0) {
|
if (paymentInfoCount <= 0) {
|
||||||
PaymentInfo paymentInfo = buildPaymentInfo(notifyPlaintext, goodsOrderInfo, appointmentOrder,trainingOrderInfo, plainText);
|
PaymentInfo paymentInfo = buildPaymentInfo(notifyPlaintext, goodsOrderInfo, appointmentOrder, trainingOrderInfo, plainText);
|
||||||
int insertCount = paymentInfoMapper.insertPaymentInfo(paymentInfo);
|
int insertCount = paymentInfoMapper.insertPaymentInfo(paymentInfo);
|
||||||
if (insertCount <= 0) {
|
if (insertCount <= 0) {
|
||||||
log.error("记录支付日志出错,参数为 ====> [{}]", paymentInfo);
|
log.error("记录支付日志出错,参数为 ====> [{}]", paymentInfo);
|
||||||
@ -282,7 +281,7 @@ public class WeChatPayNotifyServiceImpl implements WeChatPayNotifyService {
|
|||||||
* @param appointmentOrderInfo 预约订单信息
|
* @param appointmentOrderInfo 预约订单信息
|
||||||
*/
|
*/
|
||||||
private PaymentInfo buildPaymentInfo(WeChatPayNotifyPlaintextVO notifyPlaintext, GoodsOrder goodsOrderInfo,
|
private PaymentInfo buildPaymentInfo(WeChatPayNotifyPlaintextVO notifyPlaintext, GoodsOrder goodsOrderInfo,
|
||||||
AppointmentOrder appointmentOrderInfo,TrainingOrder trainingOrder, String plainText) {
|
AppointmentOrder appointmentOrderInfo, TrainingOrder trainingOrder, String plainText) {
|
||||||
PaymentInfo paymentInfo = new PaymentInfo();
|
PaymentInfo paymentInfo = new PaymentInfo();
|
||||||
if (Objects.nonNull(goodsOrderInfo)) {
|
if (Objects.nonNull(goodsOrderInfo)) {
|
||||||
paymentInfo.setPatientId(Objects.isNull(goodsOrderInfo.getPatientId()) ? null : goodsOrderInfo.getPatientId());
|
paymentInfo.setPatientId(Objects.isNull(goodsOrderInfo.getPatientId()) ? null : goodsOrderInfo.getPatientId());
|
||||||
@ -327,7 +326,6 @@ public class WeChatPayNotifyServiceImpl implements WeChatPayNotifyService {
|
|||||||
TransactionStatus transactionStatus = transactionManager.getTransaction(new DefaultTransactionDefinition());
|
TransactionStatus transactionStatus = transactionManager.getTransaction(new DefaultTransactionDefinition());
|
||||||
RedisAtomicLong redisAtomicLong = null;
|
RedisAtomicLong redisAtomicLong = null;
|
||||||
try {
|
try {
|
||||||
|
|
||||||
//处理学习培训订单退款信息
|
//处理学习培训订单退款信息
|
||||||
TrainingOrder trainingOrderInfo = trainingOrderMapper.getTrainingOrderInfoByOrderNo(refundNotifyVO.getOutTradeNo());
|
TrainingOrder trainingOrderInfo = trainingOrderMapper.getTrainingOrderInfoByOrderNo(refundNotifyVO.getOutTradeNo());
|
||||||
if (Objects.nonNull(trainingOrderInfo)) {
|
if (Objects.nonNull(trainingOrderInfo)) {
|
||||||
@ -463,6 +461,7 @@ public class WeChatPayNotifyServiceImpl implements WeChatPayNotifyService {
|
|||||||
refundInfo.setOutRefundNo(StringUtils.isBlank(refundNotifyVO.getOutRefundNo()) ? "" : refundNotifyVO.getOutRefundNo());
|
refundInfo.setOutRefundNo(StringUtils.isBlank(refundNotifyVO.getOutRefundNo()) ? "" : refundNotifyVO.getOutRefundNo());
|
||||||
return refundInfo;
|
return refundInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理学习培训订单回调信息
|
* 处理学习培训订单回调信息
|
||||||
*
|
*
|
||||||
|
|||||||
@ -110,7 +110,6 @@ public class WeChatRefundServiceImpl implements WeChatRefundService {
|
|||||||
if (StringUtils.isNotBlank(refundDTO.getOrderType()) && StringUtils.equals(OrderTypeEnum.INTEGRAL_EXCHANGE.getInfo(), refundDTO.getOrderType())) {
|
if (StringUtils.isNotBlank(refundDTO.getOrderType()) && StringUtils.equals(OrderTypeEnum.INTEGRAL_EXCHANGE.getInfo(), refundDTO.getOrderType())) {
|
||||||
return refundPointsRedemption(refundDTO);
|
return refundPointsRedemption(refundDTO);
|
||||||
}
|
}
|
||||||
|
|
||||||
//学习培训订单状态退款处理
|
//学习培训订单状态退款处理
|
||||||
if (StringUtils.isNotBlank(refundDTO.getTrainingOrderFlag()) && StringUtils.equals(BuySourceEnum.TRAINING.getInfo(), refundDTO.getTrainingOrderFlag())) {
|
if (StringUtils.isNotBlank(refundDTO.getTrainingOrderFlag()) && StringUtils.equals(BuySourceEnum.TRAINING.getInfo(), refundDTO.getTrainingOrderFlag())) {
|
||||||
return refundTrainingOrder(refundDTO);
|
return refundTrainingOrder(refundDTO);
|
||||||
@ -132,9 +131,9 @@ public class WeChatRefundServiceImpl implements WeChatRefundService {
|
|||||||
}
|
}
|
||||||
Long patientId = Objects.isNull(appointmentOrderInfo.getPatientId()) ? 0 : appointmentOrderInfo.getPatientId();
|
Long patientId = Objects.isNull(appointmentOrderInfo.getPatientId()) ? 0 : appointmentOrderInfo.getPatientId();
|
||||||
String outRefundNo = com.xinelu.common.utils.StringUtils.fillZeroByPatientId(patientId, 5) + System.nanoTime();
|
String outRefundNo = com.xinelu.common.utils.StringUtils.fillZeroByPatientId(patientId, 5) + System.nanoTime();
|
||||||
String refundParam = buildRefundParam(null, appointmentOrderInfo,null, refundDTO, outRefundNo);
|
String refundParam = buildRefundParam(null, appointmentOrderInfo, null, refundDTO, outRefundNo);
|
||||||
String refundReason = StringUtils.isBlank(refundDTO.getRefundReason()) ? "" : refundDTO.getRefundReason();
|
String refundReason = StringUtils.isBlank(refundDTO.getRefundReason()) ? "" : refundDTO.getRefundReason();
|
||||||
this.applyWeRefund(refundParam, appointmentOrderInfo, null,null, patientId, refundReason);
|
this.applyWeRefund(refundParam, appointmentOrderInfo, null, null, patientId, refundReason);
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
GoodsOrder goodsOrderInfo = goodsOrderMapper.getGoodsOrderByOrderNo(refundDTO.getOrderNo());
|
GoodsOrder goodsOrderInfo = goodsOrderMapper.getGoodsOrderByOrderNo(refundDTO.getOrderNo());
|
||||||
@ -154,9 +153,9 @@ public class WeChatRefundServiceImpl implements WeChatRefundService {
|
|||||||
}
|
}
|
||||||
Long patientId = Objects.isNull(goodsOrderInfo.getPatientId()) ? 0 : goodsOrderInfo.getPatientId();
|
Long patientId = Objects.isNull(goodsOrderInfo.getPatientId()) ? 0 : goodsOrderInfo.getPatientId();
|
||||||
String outRefundNo = com.xinelu.common.utils.StringUtils.fillZeroByPatientId(patientId, 5) + System.nanoTime();
|
String outRefundNo = com.xinelu.common.utils.StringUtils.fillZeroByPatientId(patientId, 5) + System.nanoTime();
|
||||||
String refundParam = buildRefundParam(goodsOrderInfo, null,null, refundDTO, outRefundNo);
|
String refundParam = buildRefundParam(goodsOrderInfo, null, null, refundDTO, outRefundNo);
|
||||||
String refundReason = StringUtils.isBlank(refundDTO.getRefundReason()) ? "" : refundDTO.getRefundReason();
|
String refundReason = StringUtils.isBlank(refundDTO.getRefundReason()) ? "" : refundDTO.getRefundReason();
|
||||||
this.applyWeRefund(refundParam, null, goodsOrderInfo,null, patientId, refundReason);
|
this.applyWeRefund(refundParam, null, goodsOrderInfo, null, patientId, refundReason);
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
@ -254,7 +253,7 @@ public class WeChatRefundServiceImpl implements WeChatRefundService {
|
|||||||
String outRefundNo = com.xinelu.common.utils.StringUtils.fillZeroByPatientId(patientId, 5) + System.nanoTime();
|
String outRefundNo = com.xinelu.common.utils.StringUtils.fillZeroByPatientId(patientId, 5) + System.nanoTime();
|
||||||
String refundParam = this.buildHealthConsultationRefundParam(goodsOrderInfo, outRefundNo);
|
String refundParam = this.buildHealthConsultationRefundParam(goodsOrderInfo, outRefundNo);
|
||||||
String refundReason = StringUtils.isBlank(closeOrderDTO.getRemark()) ? "" : closeOrderDTO.getRemark();
|
String refundReason = StringUtils.isBlank(closeOrderDTO.getRemark()) ? "" : closeOrderDTO.getRemark();
|
||||||
this.applyWeRefund(refundParam, null, goodsOrderInfo,null, patientId, refundReason);
|
this.applyWeRefund(refundParam, null, goodsOrderInfo, null, patientId, refundReason);
|
||||||
// 查询是否为专家咨询订单,修改时间段的可预约状态
|
// 查询是否为专家咨询订单,修改时间段的可预约状态
|
||||||
if (goodsOrderInfo.getConsultationInfoId() != null) {
|
if (goodsOrderInfo.getConsultationInfoId() != null) {
|
||||||
ConsultationInfoDTO consultationInfo = consultationInfoService.selectConsultationInfoById(goodsOrderInfo.getConsultationInfoId());
|
ConsultationInfoDTO consultationInfo = consultationInfoService.selectConsultationInfoById(goodsOrderInfo.getConsultationInfoId());
|
||||||
@ -296,7 +295,7 @@ public class WeChatRefundServiceImpl implements WeChatRefundService {
|
|||||||
* @param refundDTO 退款参数信息
|
* @param refundDTO 退款参数信息
|
||||||
* @return 退款申请Json串
|
* @return 退款申请Json串
|
||||||
*/
|
*/
|
||||||
private String buildRefundParam(GoodsOrder goodsOrderInfo, AppointmentOrder appointmentOrderInfo,TrainingOrder trainingOrder,
|
private String buildRefundParam(GoodsOrder goodsOrderInfo, AppointmentOrder appointmentOrderInfo, TrainingOrder trainingOrder,
|
||||||
RefundDTO refundDTO, String outRefundNo) {
|
RefundDTO refundDTO, String outRefundNo) {
|
||||||
Map<String, Object> paramMap = new LinkedHashMap<>();
|
Map<String, Object> paramMap = new LinkedHashMap<>();
|
||||||
paramMap.put("out_trade_no", refundDTO.getOrderNo());
|
paramMap.put("out_trade_no", refundDTO.getOrderNo());
|
||||||
@ -310,13 +309,8 @@ public class WeChatRefundServiceImpl implements WeChatRefundService {
|
|||||||
if (Objects.nonNull(goodsOrderInfo) && Objects.isNull(appointmentOrderInfo)) {
|
if (Objects.nonNull(goodsOrderInfo) && Objects.isNull(appointmentOrderInfo)) {
|
||||||
amountMap.put("total", goodsOrderInfo.getTotalPrice().multiply(BigDecimal.valueOf(100)).intValue());
|
amountMap.put("total", goodsOrderInfo.getTotalPrice().multiply(BigDecimal.valueOf(100)).intValue());
|
||||||
}
|
}
|
||||||
//学习培训订单使用医路优品账户
|
|
||||||
if (Objects.nonNull(trainingOrder) && Objects.isNull(goodsOrderInfo) && Objects.isNull(appointmentOrderInfo)) {
|
if (Objects.nonNull(trainingOrder) && Objects.isNull(goodsOrderInfo) && Objects.isNull(appointmentOrderInfo)) {
|
||||||
//退款回调地址
|
|
||||||
// paramMap.put("notify_url", ylypWeChatPaymentConfig.getYlypWeChatNotifyUrl() + YINLUYOUPIN_WE_CHAT_REFUND_URL);
|
|
||||||
//退款金额
|
|
||||||
amountMap.put("refund", refundDTO.getRefundPrice().multiply(BigDecimal.valueOf(100)).intValue());
|
amountMap.put("refund", refundDTO.getRefundPrice().multiply(BigDecimal.valueOf(100)).intValue());
|
||||||
//原始订单金额
|
|
||||||
amountMap.put("total", trainingOrder.getTrainingOrderAmount().multiply(BigDecimal.valueOf(100)).intValue());
|
amountMap.put("total", trainingOrder.getTrainingOrderAmount().multiply(BigDecimal.valueOf(100)).intValue());
|
||||||
}
|
}
|
||||||
amountMap.put("currency", "CNY");
|
amountMap.put("currency", "CNY");
|
||||||
@ -334,7 +328,7 @@ public class WeChatRefundServiceImpl implements WeChatRefundService {
|
|||||||
* @param refundReason 退款原因
|
* @param refundReason 退款原因
|
||||||
*/
|
*/
|
||||||
public void applyWeRefund(String refundParam, AppointmentOrder appointmentOrderInfo,
|
public void applyWeRefund(String refundParam, AppointmentOrder appointmentOrderInfo,
|
||||||
GoodsOrder goodsOrderInfo,TrainingOrder trainingOrderInfo, Long patientId, String refundReason) {
|
GoodsOrder goodsOrderInfo, TrainingOrder trainingOrderInfo, Long patientId, String refundReason) {
|
||||||
String requestUrl = weChatPaymentUrlConfig.getRefundApplyUrl();
|
String requestUrl = weChatPaymentUrlConfig.getRefundApplyUrl();
|
||||||
HttpPost httpPost = new HttpPost(requestUrl);
|
HttpPost httpPost = new HttpPost(requestUrl);
|
||||||
StringEntity entity = new StringEntity(refundParam, "utf-8");
|
StringEntity entity = new StringEntity(refundParam, "utf-8");
|
||||||
@ -342,11 +336,10 @@ public class WeChatRefundServiceImpl implements WeChatRefundService {
|
|||||||
httpPost.setEntity(entity);
|
httpPost.setEntity(entity);
|
||||||
httpPost.setHeader("Accept", "application/json");
|
httpPost.setHeader("Accept", "application/json");
|
||||||
String refundMerchantType = PaymentMerchantTypeEnum.XINYILU.getInfo();
|
String refundMerchantType = PaymentMerchantTypeEnum.XINYILU.getInfo();
|
||||||
|
Long nursePersonId = null;
|
||||||
//学习培训订单使用医路优品账户
|
if (Objects.nonNull(trainingOrderInfo)) {
|
||||||
Long nursePersonId = Objects.isNull(trainingOrderInfo.getNurseStationPersonId()) ? null : trainingOrderInfo.getNurseStationPersonId();
|
nursePersonId = Objects.isNull(trainingOrderInfo.getNurseStationPersonId()) ? null : trainingOrderInfo.getNurseStationPersonId();
|
||||||
|
}
|
||||||
|
|
||||||
try (CloseableHttpResponse response = xinYiLuWeChatPayClient.execute(httpPost)) {
|
try (CloseableHttpResponse response = xinYiLuWeChatPayClient.execute(httpPost)) {
|
||||||
if (Objects.isNull(response)) {
|
if (Objects.isNull(response)) {
|
||||||
throw new ServiceException("获取httpclient对象失败!");
|
throw new ServiceException("获取httpclient对象失败!");
|
||||||
@ -365,7 +358,7 @@ public class WeChatRefundServiceImpl implements WeChatRefundService {
|
|||||||
WeChatRefundInfoVO weChatRefundInfoVO = JSONObject.parseObject(body, WeChatRefundInfoVO.class);
|
WeChatRefundInfoVO weChatRefundInfoVO = JSONObject.parseObject(body, WeChatRefundInfoVO.class);
|
||||||
int refundInfoCount = refundInfoMapper.getRefundInfoByOrderNo(weChatRefundInfoVO.getOutTradeNo());
|
int refundInfoCount = refundInfoMapper.getRefundInfoByOrderNo(weChatRefundInfoVO.getOutTradeNo());
|
||||||
if (refundInfoCount <= 0) {
|
if (refundInfoCount <= 0) {
|
||||||
RefundInfo refundInfo = buildRefundInfo(patientId, weChatRefundInfoVO, refundReason, body, refundMerchantType,nursePersonId);
|
RefundInfo refundInfo = buildRefundInfo(patientId, weChatRefundInfoVO, refundReason, body, refundMerchantType, nursePersonId);
|
||||||
int insertCunt = refundInfoMapper.insertRefundInfo(refundInfo);
|
int insertCunt = refundInfoMapper.insertRefundInfo(refundInfo);
|
||||||
if (insertCunt <= 0) {
|
if (insertCunt <= 0) {
|
||||||
throw new ServiceException("记录退款信息失败,请联系管理员!");
|
throw new ServiceException("记录退款信息失败,请联系管理员!");
|
||||||
@ -386,7 +379,7 @@ public class WeChatRefundServiceImpl implements WeChatRefundService {
|
|||||||
* @param refundMerchantType 退款账户类型,新医路或者医路优品
|
* @param refundMerchantType 退款账户类型,新医路或者医路优品
|
||||||
*/
|
*/
|
||||||
private RefundInfo buildRefundInfo(Long patientId, WeChatRefundInfoVO refundInfoVO,
|
private RefundInfo buildRefundInfo(Long patientId, WeChatRefundInfoVO refundInfoVO,
|
||||||
String refundReason, String refundBody, String refundMerchantType,Long nursePersonId) {
|
String refundReason, String refundBody, String refundMerchantType, Long nursePersonId) {
|
||||||
RefundInfo refundInfo = new RefundInfo();
|
RefundInfo refundInfo = new RefundInfo();
|
||||||
refundInfo.setPatientId(patientId);
|
refundInfo.setPatientId(patientId);
|
||||||
refundInfo.setNurseStationPersonId(nursePersonId);
|
refundInfo.setNurseStationPersonId(nursePersonId);
|
||||||
@ -493,19 +486,19 @@ public class WeChatRefundServiceImpl implements WeChatRefundService {
|
|||||||
paramMap.put("amount", amountMap);
|
paramMap.put("amount", amountMap);
|
||||||
return JSON.toJSONString(paramMap);
|
return JSON.toJSONString(paramMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 学习培训订单退款处理
|
* 学习培训订单退款处理
|
||||||
*
|
*
|
||||||
* @param refundDTO 退款信息
|
* @param refundDTO 退款信息
|
||||||
* @return 退款结果
|
* @return 退款结果
|
||||||
*/
|
*/
|
||||||
public AjaxResult refundTrainingOrder(RefundDTO refundDTO){
|
public AjaxResult refundTrainingOrder(RefundDTO refundDTO) {
|
||||||
//查询学习培训订单信息
|
//查询学习培训订单信息
|
||||||
TrainingOrder trainingOrderInfo = trainingOrderMapper.getTrainingOrderInfoByOrderNo(refundDTO.getOrderNo());
|
TrainingOrder trainingOrderInfo = trainingOrderMapper.getTrainingOrderInfoByOrderNo(refundDTO.getOrderNo());
|
||||||
if (Objects.isNull(trainingOrderInfo)) {
|
if (Objects.isNull(trainingOrderInfo)) {
|
||||||
return AjaxResult.error("当前订单信息不存在,无法进行退款!");
|
return AjaxResult.error("当前订单信息不存在,无法进行退款!");
|
||||||
}
|
}
|
||||||
//判断订单状态是否为已支付,只有支付的订单才能进行退款
|
|
||||||
if (StringUtils.isBlank(trainingOrderInfo.getTrainingOrderStatus())
|
if (StringUtils.isBlank(trainingOrderInfo.getTrainingOrderStatus())
|
||||||
|| !(StringUtils.equals(TrainingOrderStatusEnum.PAY.getInfo(), trainingOrderInfo.getTrainingOrderStatus()))) {
|
|| !(StringUtils.equals(TrainingOrderStatusEnum.PAY.getInfo(), trainingOrderInfo.getTrainingOrderStatus()))) {
|
||||||
return AjaxResult.error("当前订单状态不正确,无法进行退款!");
|
return AjaxResult.error("当前订单状态不正确,无法进行退款!");
|
||||||
@ -519,7 +512,6 @@ public class WeChatRefundServiceImpl implements WeChatRefundService {
|
|||||||
log.info("零元购退款信息,无需走微信退款逻辑!");
|
log.info("零元购退款信息,无需走微信退款逻辑!");
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
//校验订单时间和订单金额
|
|
||||||
AjaxResult checkResult = judgeRefundInfo(trainingOrderInfo.getTrainingOrderTime(), refundDTO.getRefundPrice(), trainingOrderInfo.getTrainingOrderAmount());
|
AjaxResult checkResult = judgeRefundInfo(trainingOrderInfo.getTrainingOrderTime(), refundDTO.getRefundPrice(), trainingOrderInfo.getTrainingOrderAmount());
|
||||||
if (Objects.nonNull(checkResult)) {
|
if (Objects.nonNull(checkResult)) {
|
||||||
return checkResult;
|
return checkResult;
|
||||||
|
|||||||
@ -89,7 +89,6 @@ public class PaymentInfoTaskServiceImpl implements PaymentInfoTaskService {
|
|||||||
LocalDateTime localDateTime = LocalDateTime.now().minusHours(2);
|
LocalDateTime localDateTime = LocalDateTime.now().minusHours(2);
|
||||||
List<AppointOrderAndDetailsInfo> appointmentOrderList = appointmentOrderMapper.getWaitPayAppointmentOrderList(localDateTime);
|
List<AppointOrderAndDetailsInfo> appointmentOrderList = appointmentOrderMapper.getWaitPayAppointmentOrderList(localDateTime);
|
||||||
List<GoodsOrderAndDetailsInfo> goodsOrderList = goodsOrderMapper.getWaitPayGoodsOrderList(localDateTime);
|
List<GoodsOrderAndDetailsInfo> goodsOrderList = goodsOrderMapper.getWaitPayGoodsOrderList(localDateTime);
|
||||||
//查询学习培训订单信息
|
|
||||||
List<TrainingOrder> waitPayTrainingOrderList = trainingOrderMapper.getWaitPayTrainingOrderListByTime(localDateTime, TrainingOrderStatusEnum.WAIT_PAY.getInfo());
|
List<TrainingOrder> waitPayTrainingOrderList = trainingOrderMapper.getWaitPayTrainingOrderListByTime(localDateTime, TrainingOrderStatusEnum.WAIT_PAY.getInfo());
|
||||||
if (CollectionUtils.isEmpty(appointmentOrderList) && CollectionUtils.isEmpty(goodsOrderList) && CollectionUtils.isEmpty(waitPayTrainingOrderList)) {
|
if (CollectionUtils.isEmpty(appointmentOrderList) && CollectionUtils.isEmpty(goodsOrderList) && CollectionUtils.isEmpty(waitPayTrainingOrderList)) {
|
||||||
return;
|
return;
|
||||||
@ -103,7 +102,6 @@ public class PaymentInfoTaskServiceImpl implements PaymentInfoTaskService {
|
|||||||
if (CollectionUtils.isNotEmpty(goodsOrderList)) {
|
if (CollectionUtils.isNotEmpty(goodsOrderList)) {
|
||||||
processGoodsOrderInfo(goodsOrderList);
|
processGoodsOrderInfo(goodsOrderList);
|
||||||
}
|
}
|
||||||
//处理学习培训订单信息
|
|
||||||
if (CollectionUtils.isNotEmpty(waitPayTrainingOrderList)) {
|
if (CollectionUtils.isNotEmpty(waitPayTrainingOrderList)) {
|
||||||
handleWaitPayTrainingOrderInfo(waitPayTrainingOrderList);
|
handleWaitPayTrainingOrderInfo(waitPayTrainingOrderList);
|
||||||
}
|
}
|
||||||
@ -133,7 +131,6 @@ public class PaymentInfoTaskServiceImpl implements PaymentInfoTaskService {
|
|||||||
public void automaticUpdateOrderStatusTask() throws Exception {
|
public void automaticUpdateOrderStatusTask() throws Exception {
|
||||||
List<AppointmentOrder> appointmentOrderList = appointmentOrderMapper.getWaitPayStatusAppointmentOrderList(OrderStatusEnum.WAIT_PAY.getInfo());
|
List<AppointmentOrder> appointmentOrderList = appointmentOrderMapper.getWaitPayStatusAppointmentOrderList(OrderStatusEnum.WAIT_PAY.getInfo());
|
||||||
List<GoodsOrder> goodsOrderList = goodsOrderMapper.getWaitPayStatusGoodsOrderList(GooodsOrderStatusEnum.WAIT_PAY.getInfo());
|
List<GoodsOrder> goodsOrderList = goodsOrderMapper.getWaitPayStatusGoodsOrderList(GooodsOrderStatusEnum.WAIT_PAY.getInfo());
|
||||||
//查询未支付的学习培训订单信息
|
|
||||||
List<TrainingOrder> waitPayTrainingOrderList = trainingOrderMapper.getWaitPayTrainingOrderList(TrainingOrderStatusEnum.WAIT_PAY.getInfo(), null);
|
List<TrainingOrder> waitPayTrainingOrderList = trainingOrderMapper.getWaitPayTrainingOrderList(TrainingOrderStatusEnum.WAIT_PAY.getInfo(), null);
|
||||||
if (CollectionUtils.isEmpty(appointmentOrderList) && CollectionUtils.isEmpty(goodsOrderList) && CollectionUtils.isEmpty(waitPayTrainingOrderList)) {
|
if (CollectionUtils.isEmpty(appointmentOrderList) && CollectionUtils.isEmpty(goodsOrderList) && CollectionUtils.isEmpty(waitPayTrainingOrderList)) {
|
||||||
return;
|
return;
|
||||||
@ -146,7 +143,6 @@ public class PaymentInfoTaskServiceImpl implements PaymentInfoTaskService {
|
|||||||
if (CollectionUtils.isNotEmpty(goodsOrderList)) {
|
if (CollectionUtils.isNotEmpty(goodsOrderList)) {
|
||||||
updateGoodsPaymentInfo(goodsOrderList);
|
updateGoodsPaymentInfo(goodsOrderList);
|
||||||
}
|
}
|
||||||
//修改学习培训订单状态以及记录支付信息
|
|
||||||
if (CollectionUtils.isNotEmpty(waitPayTrainingOrderList)) {
|
if (CollectionUtils.isNotEmpty(waitPayTrainingOrderList)) {
|
||||||
handleWaitPayTrainingOrder(waitPayTrainingOrderList);
|
handleWaitPayTrainingOrder(waitPayTrainingOrderList);
|
||||||
}
|
}
|
||||||
@ -426,9 +422,7 @@ public class PaymentInfoTaskServiceImpl implements PaymentInfoTaskService {
|
|||||||
* @throws Exception 异常信息
|
* @throws Exception 异常信息
|
||||||
*/
|
*/
|
||||||
private void handleWaitPayTrainingOrderInfo(List<TrainingOrder> trainingOrderList) throws Exception {
|
private void handleWaitPayTrainingOrderInfo(List<TrainingOrder> trainingOrderList) throws Exception {
|
||||||
//本地系统中超过两小时未支付的订单集合
|
|
||||||
List<String> orderList = Lists.newArrayList();
|
List<String> orderList = Lists.newArrayList();
|
||||||
//微信系统已经关闭状态的订单集合
|
|
||||||
List<String> closedOrderList = Lists.newArrayList();
|
List<String> closedOrderList = Lists.newArrayList();
|
||||||
for (TrainingOrder trainingOrder : trainingOrderList) {
|
for (TrainingOrder trainingOrder : trainingOrderList) {
|
||||||
if (Objects.isNull(trainingOrder) || StringUtils.isBlank(trainingOrder.getTrainingOrderNo())) {
|
if (Objects.isNull(trainingOrder) || StringUtils.isBlank(trainingOrder.getTrainingOrderNo())) {
|
||||||
|
|||||||
@ -9,7 +9,9 @@ import com.xinelu.manage.mapper.appointmentorder.AppointmentOrderMapper;
|
|||||||
import com.xinelu.manage.mapper.goodsOrder.GoodsOrderMapper;
|
import com.xinelu.manage.mapper.goodsOrder.GoodsOrderMapper;
|
||||||
import com.xinelu.manage.mapper.patientcouponreceive.PatientCouponReceiveMapper;
|
import com.xinelu.manage.mapper.patientcouponreceive.PatientCouponReceiveMapper;
|
||||||
import com.xinelu.manage.mapper.refundinfo.RefundInfoMapper;
|
import com.xinelu.manage.mapper.refundinfo.RefundInfoMapper;
|
||||||
|
import com.xinelu.manage.mapper.trainingorder.TrainingOrderMapper;
|
||||||
import com.xinelu.manage.vo.RefundOrderInfoVO;
|
import com.xinelu.manage.vo.RefundOrderInfoVO;
|
||||||
|
import com.xinelu.manage.vo.TrainingRefundOrderVO;
|
||||||
import com.xinelu.quartz.service.RefundInfoTaskService;
|
import com.xinelu.quartz.service.RefundInfoTaskService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
@ -55,6 +57,8 @@ public class RefundInfoTaskServiceImpl implements RefundInfoTaskService {
|
|||||||
private RedisTemplate<String, Objects> redisTemplate;
|
private RedisTemplate<String, Objects> redisTemplate;
|
||||||
@Resource
|
@Resource
|
||||||
private PatientCouponReceiveMapper patientCouponReceiveMapper;
|
private PatientCouponReceiveMapper patientCouponReceiveMapper;
|
||||||
|
@Resource
|
||||||
|
private TrainingOrderMapper trainingOrderMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 自动处理退款状态定时任务,每15分钟执行一次
|
* 自动处理退款状态定时任务,每15分钟执行一次
|
||||||
@ -64,7 +68,8 @@ public class RefundInfoTaskServiceImpl implements RefundInfoTaskService {
|
|||||||
public void automaticProcessRefundInfo() {
|
public void automaticProcessRefundInfo() {
|
||||||
List<RefundOrderInfoVO> appointmentOrderList = appointmentOrderMapper.getRefundAppointmentOrderInfo(OrderStatusEnum.WAIT_REFUND.getInfo(), RefundStatusEnum.PROCESSING.getInfo(), ConfirmRefundStatusEnum.CONFIRMED.getInfo());
|
List<RefundOrderInfoVO> appointmentOrderList = appointmentOrderMapper.getRefundAppointmentOrderInfo(OrderStatusEnum.WAIT_REFUND.getInfo(), RefundStatusEnum.PROCESSING.getInfo(), ConfirmRefundStatusEnum.CONFIRMED.getInfo());
|
||||||
List<RefundOrderInfoVO> refundGoodsOrderLit = goodsOrderMapper.getRefundGoodsOrderInfo(GooodsOrderStatusEnum.WAIT_REFUND.getInfo(), RefundStatusEnum.PROCESSING.getInfo(), ConfirmRefundStatusEnum.CONFIRMED.getInfo());
|
List<RefundOrderInfoVO> refundGoodsOrderLit = goodsOrderMapper.getRefundGoodsOrderInfo(GooodsOrderStatusEnum.WAIT_REFUND.getInfo(), RefundStatusEnum.PROCESSING.getInfo(), ConfirmRefundStatusEnum.CONFIRMED.getInfo());
|
||||||
if (CollectionUtils.isEmpty(appointmentOrderList) && CollectionUtils.isEmpty(refundGoodsOrderLit)) {
|
List<TrainingRefundOrderVO> trainingRefundOrderList = trainingOrderMapper.getTrainingRefundOrderList(TrainingOrderStatusEnum.PAY.getInfo(), RefundStatusEnum.PROCESSING.getInfo());
|
||||||
|
if (CollectionUtils.isEmpty(appointmentOrderList) && CollectionUtils.isEmpty(refundGoodsOrderLit) && CollectionUtils.isEmpty(trainingRefundOrderList)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
TransactionStatus transactionStatus = transactionManager.getTransaction(new DefaultTransactionDefinition());
|
TransactionStatus transactionStatus = transactionManager.getTransaction(new DefaultTransactionDefinition());
|
||||||
@ -76,6 +81,9 @@ public class RefundInfoTaskServiceImpl implements RefundInfoTaskService {
|
|||||||
if (CollectionUtils.isNotEmpty(refundGoodsOrderLit)) {
|
if (CollectionUtils.isNotEmpty(refundGoodsOrderLit)) {
|
||||||
processGoodsRefundInfo(refundGoodsOrderLit);
|
processGoodsRefundInfo(refundGoodsOrderLit);
|
||||||
}
|
}
|
||||||
|
if (CollectionUtils.isNotEmpty(trainingRefundOrderList)) {
|
||||||
|
handleRefundTrainingOrderInfo(trainingRefundOrderList);
|
||||||
|
}
|
||||||
transactionManager.commit(transactionStatus);
|
transactionManager.commit(transactionStatus);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
transactionManager.rollback(transactionStatus);
|
transactionManager.rollback(transactionStatus);
|
||||||
@ -202,4 +210,29 @@ public class RefundInfoTaskServiceImpl implements RefundInfoTaskService {
|
|||||||
goodsOrderMapper.updateBatchGoodsOrderStatus(orderNoList, OrderStatusEnum.REFUNDED.getInfo());
|
goodsOrderMapper.updateBatchGoodsOrderStatus(orderNoList, OrderStatusEnum.REFUNDED.getInfo());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理退款成功的学习培训订单信息
|
||||||
|
*
|
||||||
|
* @param trainingRefundOrderList 学习培训订单集合
|
||||||
|
*/
|
||||||
|
private void handleRefundTrainingOrderInfo(List<TrainingRefundOrderVO> trainingRefundOrderList) {
|
||||||
|
List<String> orderNoList = Lists.newArrayList();
|
||||||
|
for (TrainingRefundOrderVO refundOrderVO : trainingRefundOrderList) {
|
||||||
|
if (StringUtils.isBlank(refundOrderVO.getTrainingOrderNo()) || StringUtils.isBlank(refundOrderVO.getOutRefundNo())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
WeChatRefundInfoVO weChatRefundInfoVO = weChatRefundService.queryGoodsOrderRefundStatus(refundOrderVO.getOutRefundNo(), BuySourceEnum.TRAINING.getInfo());
|
||||||
|
if (StringUtils.isNotBlank(weChatRefundInfoVO.getStatus())
|
||||||
|
&& RefundStatusEnum.SUCCESS.getInfo().equals(weChatRefundInfoVO.getStatus())) {
|
||||||
|
orderNoList.add(refundOrderVO.getTrainingOrderNo());
|
||||||
|
}
|
||||||
|
log.info("修改学习培训订单微信退款状态和本地订单状态,订单编号=====> {}, 退款单号======> {}", refundOrderVO.getTrainingOrderNo(), refundOrderVO.getOutRefundNo());
|
||||||
|
LocalDateTime successTime = StringUtils.isBlank(weChatRefundInfoVO.getSuccessTime()) ? LocalDateTime.now() : LocalDateTime.parse(weChatRefundInfoVO.getSuccessTime(), DateTimeFormatter.ISO_DATE_TIME);
|
||||||
|
refundInfoMapper.updateBatchRefundStatus(refundOrderVO.getTrainingOrderNo(), successTime, weChatRefundInfoVO.getStatus());
|
||||||
|
}
|
||||||
|
if (CollectionUtils.isNotEmpty(orderNoList)) {
|
||||||
|
trainingOrderMapper.updateBatchTrainingOrderStatus(orderNoList, TrainingOrderStatusEnum.REFUNDED.getInfo());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user