From 9cfe6533b226715b88273452fa398d36ff35540e Mon Sep 17 00:00:00 2001 From: Sum1Dream <418471657@qq.com> Date: Mon, 24 Oct 2022 17:59:08 +0800 Subject: [PATCH] 1 --- .../order/model/CreateOrderChildModel.java | 16 ++ .../service/OrderCreateHandleService.java | 12 +- .../impl/OrderCreateHandleServiceImpl.java | 239 +++++++++++++++++- .../impl/OrderPaySuccessServiceImpl.java | 195 +++++++++++++- .../order/service/impl/OrderServiceImpl.java | 43 +++- 5 files changed, 485 insertions(+), 20 deletions(-) diff --git a/hai-service/src/main/java/com/hai/order/model/CreateOrderChildModel.java b/hai-service/src/main/java/com/hai/order/model/CreateOrderChildModel.java index 4d3f97c7..39f4e68f 100644 --- a/hai-service/src/main/java/com/hai/order/model/CreateOrderChildModel.java +++ b/hai-service/src/main/java/com/hai/order/model/CreateOrderChildModel.java @@ -1,5 +1,6 @@ package com.hai.order.model; +import io.swagger.models.auth.In; import lombok.Data; import java.math.BigDecimal; @@ -57,6 +58,11 @@ public class CreateOrderChildModel { */ private Long storeId; + /** + * 公司ID + */ + private Long companyId; + /** ======================= 油站所需参数 ======================== **/ // 加油员code @@ -68,10 +74,20 @@ public class CreateOrderChildModel { // 代理商价格 private Boolean isTyAgent; /** ======================= 油站所需参数 ======================== **/ + + /** ======================= 肯德基,星巴克,会员充值所需参数 ======================== **/ // 下单电话 private String customerMobile; + // 产品类型 1:星巴克 2:肯德基 3:会员充值 + private Integer productType; + // 平台id 1:小程序 2:H5 3:银联 + private Integer platformId; /** ======================= 肯德基,星巴克,会员充值所需参数 ======================== **/ + /** ======================= 话费充值所需参数 ======================== **/ + // 充值内容 + private String rechargeContent; + /** ======================= 话费充值所需参数 ======================== **/ } diff --git a/hai-service/src/main/java/com/hai/order/service/OrderCreateHandleService.java b/hai-service/src/main/java/com/hai/order/service/OrderCreateHandleService.java index 7b7710fe..0cbb566c 100644 --- a/hai-service/src/main/java/com/hai/order/service/OrderCreateHandleService.java +++ b/hai-service/src/main/java/com/hai/order/service/OrderCreateHandleService.java @@ -1,5 +1,6 @@ package com.hai.order.service; +import com.alibaba.fastjson.JSONObject; import com.hai.entity.HighChildOrder; import com.hai.entity.HighDiscountUserRel; import com.hai.entity.HighOrder; @@ -55,7 +56,14 @@ public interface OrderCreateHandleService { */ ResponseData hltUnionCardRecharge(CreateOrderChildModel createOrderChild); - -// List thirdProduct() + /** + * @Author Sum1Dream + * @Name kfcOrder + * @Description // 肯德基,星巴克,第三方会员充值 订单校验 + * @Date 09:24 2022/10/24 + * @Param [object] + * @Return java.util.List + */ + List thirdPartyOrder(JSONObject object) throws Exception; } diff --git a/hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java b/hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java index 5906878a..55fea965 100644 --- a/hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java +++ b/hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java @@ -1,15 +1,16 @@ package com.hai.order.service.impl; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.security.AESEncodeUtil; import com.hai.common.security.UserCenter; +import com.hai.common.utils.DateUtil; import com.hai.common.utils.IDGenerator; -import com.hai.config.HuiLianTongConfig; -import com.hai.config.HuiLianTongUnionCardConfig; -import com.hai.config.JinZhuJiaYouService; +import com.hai.config.*; import com.hai.entity.*; import com.hai.enum_type.GasClassGroupTaskStatus; import com.hai.enum_type.JinZhuJiaYouOilNo; @@ -35,6 +36,7 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.math.BigDecimal; +import java.math.RoundingMode; import java.net.URLDecoder; import java.util.*; import java.util.stream.Collectors; @@ -101,6 +103,15 @@ public class OrderCreateHandleServiceImpl implements OrderCreateHandleService { @Resource private JinZhuJiaYouService gasJinZhuJiaYouService; + @Resource + private ThirdProductConfig thirdProductConfig; + + @Resource + private HighUserService highUserService; + + @Resource + private ApiMemberProductService apiMemberProductService; + @Override public List couponHandle(HighDiscountUserRel discountUserRel, CreateOrderChildModel createOrderChild) throws Exception { if (createOrderChild.getSaleCount() != 1) { @@ -488,4 +499,226 @@ public class OrderCreateHandleServiceImpl implements OrderCreateHandleService { return null; } + @Override + public List thirdPartyOrder(JSONObject object) throws Exception { + + JSONObject jsonObject = null; + + List childOrderList = new ArrayList<>(); + + // 查询用户 + HighUser user = highUserService.findByUserId(object.getLong("userId")); + + // 实际支付金额 + BigDecimal orderPayPrice = new BigDecimal(0); + // 市场金额 + BigDecimal marketPrice = new BigDecimal(0); + + // 查询详单订单的实际 + JSONObject productDetail = thirdProductConfig.getThirdPartyByDetail(object.getInteger("platformId"), object.getInteger("productType"), object.getLong("companyId") , object.getLong("productId")); + + // 获取token 千猪请求接口token + JSONObject userToken = QianZhuConfig.getTokenV2(user.getId().toString(), user.getName(), user.getPhone()); + + if (!userToken.getBoolean("success")) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, userToken.getString("message")); + } + + // 1 星巴克 2 肯德基 3 会员充值 + if (object.getInteger("productType") == 1) { + + List List = new ArrayList<>(); + + JSONArray array = object.getJSONArray("orderItems"); + + for (Object o : array) { + JSONObject object1 = (JSONObject) o; + Map contentMap = new LinkedHashMap<>(); + if (!object1.getString("productId").equals("")) { + contentMap.put("productId", object1.getString("productId")); + } + if (!object1.getString("cupSize").equals("")) { + contentMap.put("cupSize", object1.getString("cupSize")); + } + if (!object1.getString("temperature").equals("")) { + contentMap.put("temperature", object1.getString("temperature")); + } + if (!object1.getString("cream").equals("")) { + contentMap.put("cream", object1.getString("cream")); + } + if (!object1.getString("espresso").equals("")) { + contentMap.put("espresso", object1.getString("espresso")); + } + if (!object1.getString("milk").equals("")) { + contentMap.put("milk", object1.getString("milk")); + } + if (!object1.getString("milkBubble").equals("")) { + contentMap.put("milkBubble", object1.getString("milkBubble")); + } + if (!"".equals(object1.getString("num"))) { + contentMap.put("num", object1.getString("num")); + } + List.add(JSON.toJSONString(contentMap)); + } + + // 下单 + jsonObject = QianZhuConfig.starbucksOrders(user.getId().toString(), object.getString("storeCode"), List.toString().replace(" ", ""), object.getString("customerMobile")); + + // 判断下单是否成功 + if (!Objects.equals(jsonObject.getString("code"), "200")) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, jsonObject.getString("message")); + } + + if (!jsonObject.getBoolean("success")) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, jsonObject.getString("message")); + } + + // 根据订单号查询订单详情 + JSONObject orderObject = QianZhuConfig.starbucksOrderByOrderNo(jsonObject.getJSONObject("data").getString("orderNo")); + + // 判断是否成功 + if (!orderObject.getBoolean("success")) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, jsonObject.getString("message")); + } + + + // 获取星巴克订单内容 + JSONArray starbucksOrder = orderObject.getJSONObject("data").getJSONArray("orderItems"); + + for (Object starbucksObject : starbucksOrder) { + JSONObject childObject = (JSONObject) starbucksObject; + HighChildOrder childOrder = new HighChildOrder(); + childOrder.setChildOrderStatus(1); + childOrder.setGoodsType(9); + childOrder.setStoreId(object.getLong("storeCode")); + childOrder.setChannelOrderNo(jsonObject.getJSONObject("data").getString("orderNo")); + childOrder.setGoodsId(object.getLong("productId")); + childOrder.setStoreAddress(childObject.getString("storeAddress")); + childOrder.setStoreName(childObject.getString("storeName")); + childOrder.setGoodsName(childObject.getString("productName")); + childOrder.setGoodsImg(childObject.getString("imgUrl")); + childOrder.setSaleCount(childObject.getInteger("quantity")); + childOrder.setGoodsPrice(childObject.getBigDecimal("marketPrice")); + + // 计算利润 + BigDecimal profitPrice = childObject.getBigDecimal("marketPrice").multiply(productDetail.getBigDecimal("priceDiscount").divide(new BigDecimal(100))); + // 计算子订单支付金额 + BigDecimal childPrice = childObject.getBigDecimal("unitPrice").add(profitPrice).setScale(2 , RoundingMode.HALF_UP); + if (childPrice.compareTo(childObject.getBigDecimal("marketPrice")) > 0) { + childPrice = childObject.getBigDecimal("marketPrice"); + } + if (object.getLong("memDiscountId") != null) { + childOrder.setGoodsActualPrice(childObject.getBigDecimal("marketPrice")); + } else { + childOrder.setGoodsActualPrice(childPrice); + } + childPrice = childPrice.multiply(childObject.getBigDecimal("quantity")); + // 计算总订单实际支付金额 + orderPayPrice = orderPayPrice.add(childPrice); + // 计算市场价金额 + marketPrice = marketPrice.add(childObject.getBigDecimal("marketPrice").multiply(childObject.getBigDecimal("quantity"))); + childOrder.setTotalPrice(childPrice); + childOrderList.add(childOrder); + } + + + } else if (object.getInteger("productType") == 2) { + if (object.getInteger("eatType") == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请选择就餐方式!"); + } + // 下单 + jsonObject = QianZhuConfig.createKfcOrder(object.getInteger("eatType"), object.getString("storeCode"), object.getString("customerMobile"), object.getString("orderItems"), object.getString("userId")); + + // 判断下单是否成功 + if (!Objects.equals(jsonObject.getString("code"), "10000")) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, jsonObject.getString("message")); + } + + // 根据订单号查询订单详情 + JSONObject orderObject = QianZhuConfig.getKfcOrderByOrderNo(jsonObject.getJSONObject("data").getString("orderNo")); + // 判断下单是否成功 + if (!orderObject.getBoolean("success")) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, jsonObject.getString("message")); + } + + + + // 获取肯德基订单内容 + JSONArray kfcOrder = orderObject.getJSONObject("data").getJSONObject("kfcPlaceOrder").getJSONArray("items"); + for (Object kfcObject : kfcOrder) { + JSONObject childObject = (JSONObject) kfcObject; + HighChildOrder childOrder = new HighChildOrder(); + childOrder.setChildOrderStatus(1); + childOrder.setGoodsType(4); + childOrder.setGoodsId(object.getLong("productId")); + childOrder.setChannelOrderNo(jsonObject.getJSONObject("data").getString("orderNo")); + childOrder.setStoreAddress(orderObject.getJSONObject("data").getJSONObject("kfcPlaceOrder").getString("storeAddress")); + childOrder.setStoreName(orderObject.getJSONObject("data").getJSONObject("kfcPlaceOrder").getString("storeName")); + childOrder.setGoodsName(childObject.getString("productName")); + childOrder.setGoodsImg(childObject.getString("imageUrl")); + childOrder.setSaleCount(childObject.getInteger("quantity")); + childOrder.setGoodsPrice(childObject.getBigDecimal("originPrice")); + + // 计算利润 + BigDecimal profitPrice = childObject.getBigDecimal("originPrice").multiply(productDetail.getBigDecimal("priceDiscount").divide(new BigDecimal(100))); + // 计算子订单支付金额 + BigDecimal childPrice = childObject.getBigDecimal("price").add(profitPrice).setScale(2 , RoundingMode.HALF_UP); + if (childPrice.compareTo(childObject.getBigDecimal("originPrice")) > 0) { + childPrice = childObject.getBigDecimal("originPrice"); + } + + if (object.getLong("memDiscountId") != null) { + childOrder.setGoodsActualPrice(childObject.getBigDecimal("originPrice")); + } else { + childOrder.setGoodsActualPrice(childPrice); + } + childPrice = childPrice.multiply(childObject.getBigDecimal("quantity")); + // 计算总订单实际支付金额 + orderPayPrice = orderPayPrice.add(childPrice); + // 计算市场价金额 + marketPrice = marketPrice.add(childObject.getBigDecimal("originPrice").multiply(childObject.getBigDecimal("quantity"))); + childOrder.setTotalPrice(childPrice); + childOrderList.add(childOrder); + + } + } else if (object.getInteger("productType") == 3) { + ApiMemberProduct memberProduct = apiMemberProductService.findById(object.getLong("goodsId")); + + if (memberProduct == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前产品不可购买"); + } + object.put("productId", memberProduct.getProductId()); + + + // 计算实际支付金额 + orderPayPrice = memberProduct.getCostPrice().add(memberProduct.getPrice().multiply(productDetail.getBigDecimal("priceDiscount").divide(new BigDecimal(100)))).setScale(2, RoundingMode.HALF_UP); + if (orderPayPrice.compareTo(memberProduct.getPrice()) > 0) { + orderPayPrice = memberProduct.getPrice(); + } + // 计算市场价金额 + marketPrice = memberProduct.getPrice(); + + + HighChildOrder childOrder = new HighChildOrder(); + childOrder.setChildOrderStatus(1); + childOrder.setGoodsType(10); + childOrder.setStoreId(object.getLong("storeCode")); + childOrder.setGoodsId(memberProduct.getId()); + childOrder.setGoodsName(memberProduct.getName()); + childOrder.setSaleCount(1); + childOrder.setGoodsPrice(marketPrice); + if (object.getLong("memDiscountId") != null) { + childOrder.setGoodsActualPrice(marketPrice); + childOrder.setTotalPrice(marketPrice); + } else { + childOrder.setGoodsActualPrice(orderPayPrice); + childOrder.setTotalPrice(orderPayPrice); + } + + childOrderList.add(childOrder); + + } + + return childOrderList; + } } diff --git a/hai-service/src/main/java/com/hai/order/service/impl/OrderPaySuccessServiceImpl.java b/hai-service/src/main/java/com/hai/order/service/impl/OrderPaySuccessServiceImpl.java index 6dfb58fb..bd17f224 100644 --- a/hai-service/src/main/java/com/hai/order/service/impl/OrderPaySuccessServiceImpl.java +++ b/hai-service/src/main/java/com/hai/order/service/impl/OrderPaySuccessServiceImpl.java @@ -1,13 +1,12 @@ package com.hai.order.service.impl; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; -import com.hai.config.CommonSysConst; -import com.hai.config.JinZhuJiaYouService; -import com.hai.config.ShellGroupService; -import com.hai.config.TuanYouConfig; +import com.hai.config.*; +import com.hai.dao.HighGasOrderPushMapper; import com.hai.entity.*; import com.hai.enum_type.*; import com.hai.msg.entity.MsgTopic; @@ -29,10 +28,7 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.math.BigDecimal; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; /** * @className: OrderPaySuccessServiceImpl @@ -75,6 +71,27 @@ public class OrderPaySuccessServiceImpl implements OrderPaySuccessService { @Resource private JinZhuJiaYouService jinZhuJiaYouService; + @Resource + private HighGasOrderPushMapper highGasOrderPushMapper; + + @Resource + private HighDiscountPackageDiscountActualService discountPackageDiscountActualService; + + @Resource + private HighDiscountPackageActualService discountPackageActualService; + + @Resource + private HighDiscountPackageService discountPackageService; + + @Resource + private HighDiscountPackageRecordService discountPackageRecordService; + + @Resource + private HighDiscountUserRelService highDiscountUserRelService; + + @Resource + private ApiMemberProductService apiMemberProductService; + @Override public HighOrder orderPaySuccessHandle(String orderNo, OrderPayType payType, String paySerialNo, BigDecimal payRealPrice, HighUserCard userCard) { HighOrder order = orderService.getOrderDetailByNo(orderNo); @@ -143,19 +160,19 @@ public class OrderPaySuccessServiceImpl implements OrderPaySuccessService { orderService.updateOrderData(order); } else if (childOrder.getGoodsType().equals(OrderChildGoodsType.TYPE4.getNumber())) { - + kfcHandle(order); } else if (childOrder.getGoodsType().equals(OrderChildGoodsType.TYPE5.getNumber())) { } else if (childOrder.getGoodsType().equals(OrderChildGoodsType.TYPE6.getNumber())) { } else if (childOrder.getGoodsType().equals(OrderChildGoodsType.TYPE7.getNumber())) { - + eCouponPackageHandle(order , childOrder); } else if (childOrder.getGoodsType().equals(OrderChildGoodsType.TYPE8.getNumber())) { - + hltUnionCardRechargeHandle(order); } else if (childOrder.getGoodsType().equals(OrderChildGoodsType.TYPE9.getNumber())) { - + starbucksOrderHandle(order); } else if (childOrder.getGoodsType().equals(OrderChildGoodsType.TYPE10.getNumber())) { - + thirdOrderHandle(order); } } } @@ -286,6 +303,158 @@ public class OrderPaySuccessServiceImpl implements OrderPaySuccessService { } } + /** + * @Author Sum1Dream + * @Name kfcHandle + * @Description // 肯德基订单操作 + * @Date 14:59 2022/10/24 + * @Param [order] + * @Return void + */ + private void kfcHandle(HighOrder order) throws Exception { + + // 支付给千猪 + JSONObject object = QianZhuConfig.payKfcOrder(order.getOrderNo()); + + // 推送订单记录 + HighGasOrderPush highGasOrderPush = new HighGasOrderPush(); + highGasOrderPush.setType(OrderPushType.type3.getType()); + highGasOrderPush.setOrderNo(order.getOrderNo()); + highGasOrderPush.setCreateTime(new Date()); + highGasOrderPush.setRequestContent(order.getOrderNo()); + highGasOrderPush.setReturnContent(object.toJSONString()); + highGasOrderPushMapper.insert(highGasOrderPush); + } + + /** + * @Author Sum1Dream + * @Name eCouponPackage + * @Description // 优惠券包订单操作 + * @Date 16:15 2022/10/24 + * @Param [order] + * @Return void + */ + private void eCouponPackageHandle(HighOrder order , HighChildOrder highChildOrder) throws Exception { + HighDiscountPackageActual actual = discountPackageActualService.getDetailByChildOrderId(highChildOrder.getId()); + if (actual != null) { + List discountList = discountPackageDiscountActualService.getHighDiscountPackageDiscountActualList(actual.getId()); + for (HighDiscountPackageDiscountActual discount : discountList) { + highDiscountUserRelService.receiveDiscount(order.getMemId(), discount.getAgentDiscountCodeId()); + } + HighDiscountPackage discountPackage = discountPackageService.findDiscountPackageById(actual.getDiscountPackageId()); + HighDiscountPackageRecord record = new HighDiscountPackageRecord(); + record.setDiscountPackageId(discountPackage.getId()); + record.setDiscountPackageTitle(discountPackage.getTitle()); + record.setUsingAttribution(discountPackage.getUsingAttribution()); + record.setCompanyId(discountPackage.getCompanyId()); + record.setOrderId(order.getId().intValue()); + record.setChildOrderId(highChildOrder.getId().intValue()); + record.setRecordNo(System.currentTimeMillis()+""); + record.setSalesType(1); + record.setPrice(order.getPayPrice()); + record.setUserId(order.getMemId().intValue()); + discountPackageRecordService.insertRecord(record); + actual.setAllocationTime(new Date()); + actual.setStatus(3); // 状态: 1: 待分配 2:预分配(售卖)3:已分配 + discountPackageActualService.updateHighDiscountPackageActual(actual); + } + } + + /** + * @Author Sum1Dream + * @Name hltUnionCardRechargeHandle + * @Description // 汇联通充值订单操作 + * @Date 16:26 2022/10/24 + * @Param [order] + * @Return void + */ + private void hltUnionCardRechargeHandle(HighOrder order) throws Exception { + // 汇联通充值 + String goodsDesc = "汇联通充值"+order.getPayPrice()+"元"; + String tranDesc = ""; + String businessType = "ghk_deposit"; + + // 汇联通卡充值 + JSONObject deposit = HuiLianTongUnionCardConfig.deposit(order.getOrderNo(), order.getMemCardNo(), order.getPayPrice(), businessType, order.getPaySerialNo(), tranDesc); + System.out.println("工会卡支付响应参数" + deposit.toJSONString()); + + JSONObject dataObject = HuiLianTongUnionCardConfig.resolveResponse(deposit.getString("data")); + + Map dataMap = new HashMap<>(); + dataMap.put("orderNo", order.getOrderNo()); + dataMap.put("cardType", "ghk"); + dataMap.put("cardNo", order.getMemCardNo()); + dataMap.put("checkPassword", "N"); + dataMap.put("tranAmount", order.getPayPrice()); + dataMap.put("tranChannel", "HiSen"); + dataMap.put("businessType", businessType); + dataMap.put("goodsDesc", goodsDesc); + dataMap.put("tranDesc", tranDesc); + HighGasOrderPush payPush = new HighGasOrderPush(); + payPush.setType(OrderPushType.type7.getType()); + payPush.setOrderNo(order.getOrderNo()); + payPush.setCreateTime(new Date()); + payPush.setCode(deposit.getString("respCode")); + payPush.setRequestContent(JSON.toJSONString(dataMap)); + payPush.setReturnContent(deposit.toJSONString()); + highGasOrderPushMapper.insert(payPush); + + if (!Objects.equals(deposit.getString("respCode"), "0000")) { + throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , deposit.getString("respMessage")); + } + // 记录回调信息 + if (!dataObject.getBoolean("success")) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, dataObject.getString("message")); + } + } + + /** + * @Author Sum1Dream + * @Name starbucksOrderHandle + * @Description // 星巴克订单操作 + * @Date 17:04 2022/10/24 + * @Param [order] + * @Return void + */ + private void starbucksOrderHandle(HighOrder order) throws Exception { + // 订单支付 + JSONObject requestContent = QianZhuConfig.starbucksOrdersPay(order.getOrderNo()); + + // 推送订单记录 + HighGasOrderPush highGasOrderPush = new HighGasOrderPush(); + highGasOrderPush.setType(OrderPushType.type8.getType()); + highGasOrderPush.setOrderNo(order.getOrderNo()); + highGasOrderPush.setCreateTime(new Date()); + highGasOrderPush.setRequestContent(order.getOrderNo()); + highGasOrderPush.setReturnContent(requestContent.toJSONString()); + highGasOrderPushMapper.insert(highGasOrderPush); + } + + /** + * @Author Sum1Dream + * @Name thirdOrderHandle + * @Description // 第三方会员充值订单操作 + * @Date 17:06 2022/10/24 + * @Param [order] + * @Return void + */ + private void thirdOrderHandle(HighOrder order) throws Exception { + + // 下单 + ApiMemberProduct memberProduct = apiMemberProductService.findById(order.getHighChildOrderList().get(0).getGoodsId()); + + JSONObject object = QianZhuConfig.insertV2(memberProduct.getProductId() , order.getOrderNo() , order.getRemarks()); + + // 推送订单记录 + HighGasOrderPush highGasOrderPush = new HighGasOrderPush(); + highGasOrderPush.setType(OrderPushType.type8.getType()); + highGasOrderPush.setOrderNo(order.getOrderNo()); + highGasOrderPush.setCreateTime(new Date()); + highGasOrderPush.setRequestContent(order.getOrderNo()); + highGasOrderPush.setReturnContent(object.toJSONString()); + highGasOrderPushMapper.insert(highGasOrderPush); + } + } diff --git a/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java b/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java index 3bf4a31a..040bf196 100644 --- a/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java @@ -1,5 +1,6 @@ package com.hai.order.service.impl; +import com.alibaba.fastjson.JSONObject; import com.alicp.jetcache.anno.CacheType; import com.alicp.jetcache.anno.CacheUpdate; import com.alicp.jetcache.anno.Cached; @@ -143,6 +144,9 @@ public class OrderServiceImpl implements OrderService { order.setExceptionStatus(false); order.setCreateTime(new Date()); order.setPayGold(0); + order.setCompanyId(createOrderModel.getCompanyId()); + + /*********** 组装处理子订单 商品业务************/ List childOrderList = new ArrayList<>(); @@ -151,6 +155,14 @@ public class OrderServiceImpl implements OrderService { child.setMemName(order.getMemName()); child.setMemPhone(order.getMemPhone()); + /*********** 组装肯德基,星巴克,第三方会员充值 请求数据************/ + JSONObject object = new JSONObject(); + object.put("customerMobile" , child.getCustomerMobile()); + object.put("productType" , child.getProductType()); + object.put("platformId" , child.getPlatformId()); + object.put("companyId" , order.getCompanyId()); + object.put("userId" , child.getMemId()); + // 购买卡券 if (child.getGoodsType().equals(OrderChildGoodsType.TYPE1.getNumber())) { order.setProductType(OrderProductType.PRODUCT_TYPE5.getNumber()); @@ -184,6 +196,15 @@ public class OrderServiceImpl implements OrderService { } else if (child.getGoodsType().equals(OrderChildGoodsType.TYPE4.getNumber())) { order.setProductType(OrderProductType.PRODUCT_TYPE2.getNumber()); // 创建肯德基订单业务 + List couponOrderList = orderCreateHandleService.thirdPartyOrder(object); + childOrderList = couponOrderList; + for (HighChildOrder childOrder : couponOrderList) { + if (StringUtils.isBlank(order.getSearchTitle())) { + order.setTitle(childOrder.getGoodsName()); + } else { + order.setTitle("+"+childOrder.getGoodsName()); + } + } // 电影票 } else if (child.getGoodsType().equals(OrderChildGoodsType.TYPE5.getNumber())) { @@ -205,11 +226,29 @@ public class OrderServiceImpl implements OrderService { // 星巴克 } else if (child.getGoodsType().equals(OrderChildGoodsType.TYPE9.getNumber())) { order.setProductType(OrderProductType.PRODUCT_TYPE1.getNumber()); - + // 创建星巴克订单业务 + List couponOrderList = orderCreateHandleService.thirdPartyOrder(object); + childOrderList = couponOrderList; + for (HighChildOrder childOrder : couponOrderList) { + if (StringUtils.isBlank(order.getSearchTitle())) { + order.setTitle(childOrder.getGoodsName()); + } else { + order.setTitle("+"+childOrder.getGoodsName()); + } + } // 第三方充值 } else if (child.getGoodsType().equals(OrderChildGoodsType.TYPE10.getNumber())) { order.setProductType(OrderProductType.PRODUCT_TYPE3.getNumber()); - + // 创建第三方充值订单业务 + List couponOrderList = orderCreateHandleService.thirdPartyOrder(object); + childOrderList = couponOrderList; + for (HighChildOrder childOrder : couponOrderList) { + if (StringUtils.isBlank(order.getSearchTitle())) { + order.setTitle(childOrder.getGoodsName()); + } else { + order.setTitle("+"+childOrder.getGoodsName()); + } + } } else { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知业务类型"); }