diff --git a/service/src/main/java/com/hfkj/service/UserDiscountService.java b/service/src/main/java/com/hfkj/service/UserDiscountService.java new file mode 100644 index 0000000..4bcf318 --- /dev/null +++ b/service/src/main/java/com/hfkj/service/UserDiscountService.java @@ -0,0 +1,24 @@ +package com.hfkj.service; + +/** + * @className: UserDiscountService + * @author: HuRui + * @date: 2023/3/29 + **/ +public interface UserDiscountService { + + /** + * 用户优惠券使用 + * @param userDiscountId + * @param userPhone + */ + void userDiscountUse(Long userDiscountId,String userPhone); + + /** + * 用户优惠券退回 + * @param userDiscountId + * @param userPhone + */ + void userDiscountReturn(Long userDiscountId,String userPhone); + +} diff --git a/service/src/main/java/com/hfkj/service/impl/BsTradeOrderRefundServiceImpl.java b/service/src/main/java/com/hfkj/service/impl/BsTradeOrderRefundServiceImpl.java index c9c23a1..617a750 100644 --- a/service/src/main/java/com/hfkj/service/impl/BsTradeOrderRefundServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/impl/BsTradeOrderRefundServiceImpl.java @@ -5,10 +5,7 @@ import com.hfkj.channel.weixin.WeiXinPayService; import com.hfkj.dao.BsTradeOrderRefundMapper; import com.hfkj.entity.*; import com.hfkj.channel.lakala.LaKaLaTradeService; -import com.hfkj.service.BsStoreDiscountActivityPartakeUserService; -import com.hfkj.service.BsStoreDiscountActivityService; -import com.hfkj.service.BsTradeOrderRefundService; -import com.hfkj.service.BsTradeOrderService; +import com.hfkj.service.*; import com.hfkj.sysenum.PlatformTypeEnum; import com.hfkj.sysenum.StoreDiscountActivityPartakeWayEnum; import com.hfkj.sysenum.TradeOrderStatusEnum; @@ -41,6 +38,9 @@ public class BsTradeOrderRefundServiceImpl implements BsTradeOrderRefundService @Resource private CCBTradeService ccbTradeService; + @Resource + private UserDiscountService userDiscountService; + @Resource private WeiXinPayService weiXinPayService; @@ -89,6 +89,10 @@ public class BsTradeOrderRefundServiceImpl implements BsTradeOrderRefundService } } } + + if (tradeOrder.getUserDiscountId() != null) { + userDiscountService.userDiscountReturn(tradeOrder.getUserDiscountId(), tradeOrder.getUserPhone()); + } } return refund; diff --git a/service/src/main/java/com/hfkj/service/impl/BsTradeOrderServiceImpl.java b/service/src/main/java/com/hfkj/service/impl/BsTradeOrderServiceImpl.java index 0bd80fb..2ac6f7b 100644 --- a/service/src/main/java/com/hfkj/service/impl/BsTradeOrderServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/impl/BsTradeOrderServiceImpl.java @@ -1,5 +1,6 @@ package com.hfkj.service.impl; +import com.alibaba.fastjson.JSONObject; import com.hfkj.common.exception.ErrorCode; import com.hfkj.common.exception.ErrorHelp; import com.hfkj.common.exception.SysCode; @@ -51,6 +52,9 @@ public class BsTradeOrderServiceImpl implements BsTradeOrderService { @Resource private SoundService soundService; + @Resource + private UserDiscountService userDiscountService; + @Override public void editOrder(BsTradeOrder tradeOrder) { if (tradeOrder.getId() == null) { @@ -215,6 +219,10 @@ public class BsTradeOrderServiceImpl implements BsTradeOrderService { } } + if (tradeOrder.getUserDiscountId() != null && StringUtils.isNotBlank(tradeOrder.getUserPhone())) { + userDiscountService.userDiscountUse(tradeOrder.getUserDiscountId(), tradeOrder.getUserPhone()); + } + // 创建分账 if (tradeOrder.getProfitSharingStatus().equals(true)) { tradeOrderProfitSharingService.createProfitSharing(tradeOrder); diff --git a/service/src/main/java/com/hfkj/service/impl/UserDiscountServiceImpl.java b/service/src/main/java/com/hfkj/service/impl/UserDiscountServiceImpl.java new file mode 100644 index 0000000..deb4d86 --- /dev/null +++ b/service/src/main/java/com/hfkj/service/impl/UserDiscountServiceImpl.java @@ -0,0 +1,51 @@ +package com.hfkj.service.impl; + +import com.alibaba.fastjson.JSONObject; +import com.hfkj.common.exception.ErrorCode; +import com.hfkj.common.exception.ErrorHelp; +import com.hfkj.common.exception.SysCode; +import com.hfkj.common.utils.HttpsUtils; +import com.hfkj.config.CommonSysConst; +import com.hfkj.service.UserDiscountService; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.Map; + +/** + * @className: UserDiscountServiceImpl + * @author: HuRui + * @date: 2023/3/29 + **/ +@Service("userDiscountService") +public class UserDiscountServiceImpl implements UserDiscountService { + @Override + public void userDiscountUse(Long userDiscountId, String userPhone) { + try { + Map param = new HashMap<>(); + param.put("userDiscountId", userDiscountId); + param.put("userPhone", userPhone); + JSONObject jsonObject = HttpsUtils.doGet(CommonSysConst.getSysConfig().getHsg_domain_name() + "user/discount/hzfUserDiscountUse", param); + if (!jsonObject.getString("return_code").equals("000000")) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, jsonObject.getString("return_data")); + } + } catch (Exception e) { + System.out.println(e); + } + } + + @Override + public void userDiscountReturn(Long userDiscountId, String userPhone) { + try { + Map param = new HashMap<>(); + param.put("userDiscountId", userDiscountId); + param.put("userPhone", userPhone); + JSONObject jsonObject = HttpsUtils.doGet(CommonSysConst.getSysConfig().getHsg_domain_name() + "user/discount/hzfUserDiscountReturn", param); + if (!jsonObject.getString("return_code").equals("000000")) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, jsonObject.getString("return_data")); + } + } catch (Exception e) { + System.out.println(e); + } + } +}