|
|
@ -2,12 +2,17 @@ package com.hfkj.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
import com.hfkj.channel.ccb.CCBTradeService; |
|
|
|
import com.hfkj.channel.ccb.CCBTradeService; |
|
|
|
import com.hfkj.channel.weixin.WeiXinPayService; |
|
|
|
import com.hfkj.channel.weixin.WeiXinPayService; |
|
|
|
|
|
|
|
import com.hfkj.common.exception.BizException; |
|
|
|
|
|
|
|
import com.hfkj.common.exception.ErrorCode; |
|
|
|
|
|
|
|
import com.hfkj.common.exception.ErrorHelp; |
|
|
|
|
|
|
|
import com.hfkj.common.exception.SysCode; |
|
|
|
import com.hfkj.dao.BsTradeOrderRefundMapper; |
|
|
|
import com.hfkj.dao.BsTradeOrderRefundMapper; |
|
|
|
import com.hfkj.entity.*; |
|
|
|
import com.hfkj.entity.*; |
|
|
|
import com.hfkj.channel.lakala.LaKaLaTradeService; |
|
|
|
import com.hfkj.channel.lakala.LaKaLaTradeService; |
|
|
|
import com.hfkj.service.*; |
|
|
|
import com.hfkj.service.*; |
|
|
|
import com.hfkj.sysenum.PlatformTypeEnum; |
|
|
|
import com.hfkj.sysenum.PlatformTypeEnum; |
|
|
|
import com.hfkj.sysenum.StoreDiscountActivityPartakeWayEnum; |
|
|
|
import com.hfkj.sysenum.StoreDiscountActivityPartakeWayEnum; |
|
|
|
|
|
|
|
import com.hfkj.sysenum.TradeOrderRefundStatusEnum; |
|
|
|
import com.hfkj.sysenum.TradeOrderStatusEnum; |
|
|
|
import com.hfkj.sysenum.TradeOrderStatusEnum; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
@ -58,44 +63,55 @@ public class BsTradeOrderRefundServiceImpl implements BsTradeOrderRefundService |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Map<String, Object> tradeOrderRefund(BsTradeOrderRefund tradeOrderRefund) throws Exception { |
|
|
|
public Map<String, Object> tradeOrderRefund(BsTradeOrderRefund tradeOrderRefund) throws Exception { |
|
|
|
editOrderRefund(tradeOrderRefund); |
|
|
|
try { |
|
|
|
|
|
|
|
editOrderRefund(tradeOrderRefund); |
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> refund = new HashMap<>(); |
|
|
|
Map<String, Object> refund = new HashMap<>(); |
|
|
|
if (tradeOrderRefund.getPlatformType().equals(PlatformTypeEnum.type1.getNumber())) { |
|
|
|
if (tradeOrderRefund.getPlatformType().equals(PlatformTypeEnum.type1.getNumber())) { |
|
|
|
refund = laKaLaTradeService.refund(tradeOrderRefund.getRefundNo(), tradeOrderRefund.getRefundAmount()); |
|
|
|
refund = laKaLaTradeService.refund(tradeOrderRefund.getRefundNo(), tradeOrderRefund.getRefundAmount()); |
|
|
|
|
|
|
|
|
|
|
|
} else if (tradeOrderRefund.getPlatformType().equals(PlatformTypeEnum.type3.getNumber())) { |
|
|
|
} else if (tradeOrderRefund.getPlatformType().equals(PlatformTypeEnum.type3.getNumber())) { |
|
|
|
refund = ccbTradeService.refund(tradeOrderRefund.getRefundNo(), tradeOrderRefund.getRefundAmount()); |
|
|
|
refund = ccbTradeService.refund(tradeOrderRefund.getRefundNo(), tradeOrderRefund.getRefundAmount()); |
|
|
|
|
|
|
|
|
|
|
|
} else if (tradeOrderRefund.getPlatformType().equals(PlatformTypeEnum.type4.getNumber())) { |
|
|
|
} else if (tradeOrderRefund.getPlatformType().equals(PlatformTypeEnum.type4.getNumber())) { |
|
|
|
refund = weiXinPayService.refund(tradeOrderRefund.getRefundNo(), tradeOrderRefund.getRefundAmount()); |
|
|
|
refund = weiXinPayService.refund(tradeOrderRefund.getRefundNo(), tradeOrderRefund.getRefundAmount()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 交易订单
|
|
|
|
// 交易订单
|
|
|
|
BsTradeOrder tradeOrder = tradeOrderService.getOrderByTradeNoId(tradeOrderRefund.getTradeOrderId()); |
|
|
|
BsTradeOrder tradeOrder = tradeOrderService.getOrderByTradeNoId(tradeOrderRefund.getTradeOrderId()); |
|
|
|
if (tradeOrder != null) { |
|
|
|
if (tradeOrder != null) { |
|
|
|
// 退回门店优惠活动
|
|
|
|
// 退回门店优惠活动
|
|
|
|
if (tradeOrder.getStoreDiscountId() != null) { |
|
|
|
if (tradeOrder.getStoreDiscountId() != null) { |
|
|
|
BsStoreDiscountActivity storeDiscountActivity = storeDiscountActivityService.getDetailById(tradeOrder.getStoreDiscountId()); |
|
|
|
BsStoreDiscountActivity storeDiscountActivity = storeDiscountActivityService.getDetailById(tradeOrder.getStoreDiscountId()); |
|
|
|
if (storeDiscountActivity != null |
|
|
|
if (storeDiscountActivity != null |
|
|
|
&& !storeDiscountActivity.getPartakeWay().equals(StoreDiscountActivityPartakeWayEnum.type1.getNumber()) |
|
|
|
&& !storeDiscountActivity.getPartakeWay().equals(StoreDiscountActivityPartakeWayEnum.type1.getNumber()) |
|
|
|
&& StringUtils.isNotBlank(tradeOrder.getUserPhone())) { |
|
|
|
&& StringUtils.isNotBlank(tradeOrder.getUserPhone())) { |
|
|
|
|
|
|
|
|
|
|
|
BsStoreDiscountActivityPartakeUser partakeUser = discountActivityPartakeUserService.getPartakeUser(tradeOrder.getUserPhone(), tradeOrder.getStoreDiscountId()); |
|
|
|
BsStoreDiscountActivityPartakeUser partakeUser = discountActivityPartakeUserService.getPartakeUser(tradeOrder.getUserPhone(), tradeOrder.getStoreDiscountId()); |
|
|
|
if (partakeUser != null) { |
|
|
|
if (partakeUser != null) { |
|
|
|
partakeUser.setPartakeSurplusNum(partakeUser.getPartakeSurplusNum() + 1); |
|
|
|
partakeUser.setPartakeSurplusNum(partakeUser.getPartakeSurplusNum() + 1); |
|
|
|
partakeUser.setPartakeUseNum(partakeUser.getPartakeUseNum() - 1); |
|
|
|
partakeUser.setPartakeUseNum(partakeUser.getPartakeUseNum() - 1); |
|
|
|
discountActivityPartakeUserService.editData(partakeUser); |
|
|
|
discountActivityPartakeUserService.editData(partakeUser); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (tradeOrder.getUserDiscountId() != null) { |
|
|
|
if (tradeOrder.getUserDiscountId() != null) { |
|
|
|
userDiscountService.userDiscountReturn(tradeOrder.getUserDiscountId(), tradeOrder.getUserPhone()); |
|
|
|
userDiscountService.userDiscountReturn(tradeOrder.getUserDiscountId(), tradeOrder.getUserPhone()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return refund; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (BizException e) { |
|
|
|
|
|
|
|
tradeOrderRefund.setStatus(TradeOrderRefundStatusEnum.status0.getNumber()); |
|
|
|
|
|
|
|
editOrderRefund(tradeOrderRefund); |
|
|
|
|
|
|
|
throw e; |
|
|
|
|
|
|
|
|
|
|
|
return refund; |
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
tradeOrderRefund.setStatus(TradeOrderRefundStatusEnum.status0.getNumber()); |
|
|
|
|
|
|
|
editOrderRefund(tradeOrderRefund); |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, e.getMessage()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|