From c29f27225e928d0e7ebdd3d083507a8a16426986 Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Mon, 29 Apr 2024 16:50:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cweb/controller/HighTestController.java | 2 +- .../cweb/controller/QzOrderController.java | 108 ++++++++++++ .../com/cweb/controller/tPigController.java | 2 +- .../web/controller/OrderPayController.java | 34 ++++ .../service/OrderCreateHandleService.java | 8 + .../impl/OrderCreateHandleServiceImpl.java | 51 ++++++ .../order/service/impl/OrderServiceImpl.java | 8 +- .../service/impl/HighQzOrderServiceImpl.java | 157 +++++------------- 8 files changed, 250 insertions(+), 120 deletions(-) create mode 100644 hai-cweb/src/main/java/com/cweb/controller/QzOrderController.java diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighTestController.java b/hai-cweb/src/main/java/com/cweb/controller/HighTestController.java index ba3cad3b..64289b57 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighTestController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighTestController.java @@ -1 +1 @@ -package com.cweb.controller; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.cweb.config.SysConst; import com.hai.common.Base64Util; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.pay.util.XmlUtil; import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.security.SessionObject; import com.hai.common.security.UserCenter; import com.hai.common.utils.*; import com.hai.config.*; import com.hai.dao.HighGasOrderPushMapper; import com.hai.entity.*; import com.hai.enum_type.LoginPlatform; import com.hai.enum_type.MerchantStoreSourceType; import com.hai.model.*; import com.hai.pay.channel.huift.TradeService; import com.hai.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpPost; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.ssl.SSLContexts; import org.apache.http.util.EntityUtils; import org.bouncycastle.util.encoders.UrlBase64; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.util.IdGenerator; import org.springframework.web.bind.annotation.*; import sun.nio.cs.StreamEncoder; import javax.annotation.Resource; import javax.net.ssl.SSLContext; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.*; import java.math.BigDecimal; import java.nio.charset.StandardCharsets; import java.security.KeyStore; import java.util.*; /** * @Auther: 胡锐 * @Description: * @Date: 2021/3/26 23:08 */ @Controller @RequestMapping(value = "/test") @Api(value = "订单接口") public class HighTestController { private static Logger log = LoggerFactory.getLogger(HighTestController.class); @Resource private PayloService payloService; @Resource private HighGasService gasService; @Resource private HighUserService userService; @Resource private HighOrderService orderService; @Resource private HighMerchantStoreService merchantStoreService; @RequestMapping(value = "/invalidCoupon", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "重庆CNPC电子券作废") public ResponseData invalidCoupon(@RequestParam(name = "couponNo", required = true) String couponNo, @RequestParam(name = "random", required = false) String random) { try { return ResponseMsgUtil.success(ChongQingCNPCService.invalidCoupon(couponNo, null)); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/ycShellPageQueryAllStation", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "订单退款") public ResponseData ycShellPageQueryAllStation() { try { return ResponseMsgUtil.success(payloService.ycShellPageQueryAllStation(1, 50)); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/HuiLianTongConfigPayOrderByCouNo", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "") public ResponseData HuiLianTongConfigPayOrderByCouNo(@RequestParam(name = "couNo", required = true) String couNo) { try { JSONObject jsonObject = HuiLianTongConfig.getPayOrderByCouNo(couNo); if (jsonObject.getString("respCode").equals("0000")) { JSONObject data = HuiLianTongUnionCardConfig.resolveResponse(jsonObject.getString("data")); return ResponseMsgUtil.success(data); } else { log.error("getRechargeProduct error!", "查询失败!"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR , "查询失败"); } } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getPayloAllStation", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "paylo油站") public ResponseData getPayloAllStation(HttpServletRequest request) { try { gasService.getPayloAllStation(); return ResponseMsgUtil.success(""); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } @Resource private TradeService tradeService; @RequestMapping(value = "/huiftTrade", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "huiftTrade") public ResponseData huiftTrade(HttpServletRequest request) { try { // return ResponseMsgUtil.success(tradeService.thirdPreOrder(orderService.getOrderByOrderNo("2024040215535447310"))); return ResponseMsgUtil.success(tradeService.thirdPayResult("P17124793186600955280")); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/loginBySilence", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "【H5】根据手机号登录") public ResponseData loginBySilence(@RequestParam(value = "phone", required = true) String phone , HttpServletRequest request, HttpServletResponse response) { try { // 客户端 LoginPlatform platform = LoginPlatform.getDataByType("H5"); if (platform == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知客户端"); } return ResponseMsgUtil.success(userService.loginAndRegister(platform, phone, null, new HashMap<>(), request, response)); } catch (Exception e) { return ResponseMsgUtil.exception(e); } } } \ No newline at end of file +package com.cweb.controller; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.cweb.config.SysConst; import com.hai.common.Base64Util; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.pay.util.XmlUtil; import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.security.SessionObject; import com.hai.common.security.UserCenter; import com.hai.common.utils.*; import com.hai.config.*; import com.hai.dao.HighGasOrderPushMapper; import com.hai.entity.*; import com.hai.enum_type.LoginPlatform; import com.hai.enum_type.MerchantStoreSourceType; import com.hai.model.*; import com.hai.pay.channel.huift.TradeService; import com.hai.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpPost; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.ssl.SSLContexts; import org.apache.http.util.EntityUtils; import org.bouncycastle.util.encoders.UrlBase64; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.util.IdGenerator; import org.springframework.web.bind.annotation.*; import sun.nio.cs.StreamEncoder; import javax.annotation.Resource; import javax.net.ssl.SSLContext; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.*; import java.math.BigDecimal; import java.nio.charset.StandardCharsets; import java.security.KeyStore; import java.util.*; /** * @Auther: 胡锐 * @Description: * @Date: 2021/3/26 23:08 */ @Controller @RequestMapping(value = "/test") @Api(value = "订单接口") public class HighTestController { private static Logger log = LoggerFactory.getLogger(HighTestController.class); @Resource private PayloService payloService; @Resource private HighGasService gasService; @Resource private HighUserService userService; @Resource private HighOrderService orderService; @Resource private HighMerchantStoreService merchantStoreService; @RequestMapping(value = "/invalidCoupon", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "重庆CNPC电子券作废") public ResponseData invalidCoupon(@RequestParam(name = "couponNo", required = true) String couponNo, @RequestParam(name = "random", required = false) String random) { try { return ResponseMsgUtil.success(ChongQingCNPCService.invalidCoupon(couponNo, null)); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/ycShellPageQueryAllStation", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "订单退款") public ResponseData ycShellPageQueryAllStation() { try { return ResponseMsgUtil.success(payloService.ycShellPageQueryAllStation(1, 50)); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/HuiLianTongConfigPayOrderByCouNo", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "") public ResponseData HuiLianTongConfigPayOrderByCouNo(@RequestParam(name = "couNo", required = true) String couNo) { try { JSONObject jsonObject = HuiLianTongConfig.getPayOrderByCouNo(couNo); if (jsonObject.getString("respCode").equals("0000")) { JSONObject data = HuiLianTongUnionCardConfig.resolveResponse(jsonObject.getString("data")); return ResponseMsgUtil.success(data); } else { log.error("getRechargeProduct error!", "查询失败!"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR , "查询失败"); } } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getPayloAllStation", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "paylo油站") public ResponseData getPayloAllStation(HttpServletRequest request) { try { gasService.getPayloAllStation(); return ResponseMsgUtil.success(""); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } @Resource private TradeService tradeService; @RequestMapping(value = "/huiftTrade", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "huiftTrade") public ResponseData huiftTrade(HttpServletRequest request) { try { // return ResponseMsgUtil.success(tradeService.thirdPreOrder(orderService.getOrderByOrderNo("2024040215535447310"))); return ResponseMsgUtil.success(tradeService.thirdPayResult("P17124793186600955280")); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/loginBySilence", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "【H5】根据手机号登录") public ResponseData loginBySilence(@RequestParam(value = "phone", required = true) String phone , HttpServletRequest request, HttpServletResponse response) { try { // 客户端 LoginPlatform platform = LoginPlatform.getDataByType("H5"); if (platform == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知客户端"); } return ResponseMsgUtil.success(userService.loginAndRegister(platform, phone, null, new HashMap<>(), request, response)); } catch (Exception e) { return ResponseMsgUtil.exception(e); } } @Resource private HighQzOrderService highQzOrderService; @RequestMapping(value = "/getCinemaOrderByOrderNo", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "getCinemaOrderByOrderNo") public ResponseData getCinemaOrderByOrderNo(HttpServletRequest request, HttpServletResponse response) { try { return ResponseMsgUtil.success(highQzOrderService.assemblyQzOrder("20240429103010139871001", "CINEMA")); } catch (Exception e) { return ResponseMsgUtil.exception(e); } } } \ No newline at end of file diff --git a/hai-cweb/src/main/java/com/cweb/controller/QzOrderController.java b/hai-cweb/src/main/java/com/cweb/controller/QzOrderController.java new file mode 100644 index 00000000..116990ed --- /dev/null +++ b/hai-cweb/src/main/java/com/cweb/controller/QzOrderController.java @@ -0,0 +1,108 @@ +package com.cweb.controller; + +import com.alibaba.fastjson.JSONObject; +import com.hai.common.security.AESEncodeUtil; +import com.hai.config.CommonSysConst; +import com.hai.config.WxOrderConfig; +import com.hai.dao.HighGasOrderRefundMapper; +import com.hai.entity.HighChildOrder; +import com.hai.entity.HighGasOrderRefund; +import com.hai.entity.HighOrder; +import com.hai.model.OrderRefundModel; +import com.hai.service.HighOrderService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.PrintWriter; +import java.util.Date; + +@Controller +@RequestMapping(value = "/qianzhu") +@Api(value = "千猪回调") +public class QzOrderController { + + private static Logger log = LoggerFactory.getLogger(QzOrderController.class); + + @Resource + private HighOrderService highOrderService; + + + @RequestMapping(value = "/orderNotify", method = RequestMethod.POST) + @ApiOperation(value = "千猪订单回调") + public void orderNotify(@RequestBody String reqBodyStr,HttpServletRequest request, HttpServletResponse response) { + try { + log.info(reqBodyStr); + JSONObject dataObject = JSONObject.parseObject(reqBodyStr, JSONObject.class); + HighOrder order = highOrderService.getOrderByOrderNo(dataObject.getString("orderNo")); + if (order != null) { + JSONObject data = dataObject.getJSONObject("data"); + for (HighChildOrder childOrder : order.getHighChildOrderList()) { + // 4:KFC肯德基 5:电影票 + if (childOrder.getGoodsType() == 4) { + // 10:已出票 -5:已取消 -3:部分取消 -10:退款 + if (dataObject.getInteger("eventType") == -5) { + // 微信退款 + OrderRefundModel orderRefundModel = WxOrderConfig.orderToRefund(order.getPaySerialNo(), data.getBigDecimal("cancelReason"), data.getBigDecimal("cancelReason")); + if(orderRefundModel.getResult_code().equals("SUCCESS")) { + childOrder.setChildOrderStatus(5); + order.setOrderStatus(5); + order.setCancelTime(new Date()); + order.setCancelRemarks(data.getString("cancelReason")); + highOrderService.updateOrderDetail(order); + } + } + + if (dataObject.getInteger("eventType") == -10) { + // 微信退款 + OrderRefundModel orderRefundModel = WxOrderConfig.orderToRefund(order.getPaySerialNo(), data.getBigDecimal("refundAmount"), data.getBigDecimal("refundAmount")); + if(orderRefundModel.getResult_code().equals("SUCCESS")) { + childOrder.setChildOrderStatus(4); + order.setOrderStatus(4); + //order.setRefundTime(new Date()); + //order.setRefundPrice(data.getBigDecimal("refundAmount")); + highOrderService.updateOrderDetail(order); + } + } + } + + if (childOrder.getGoodsType() == 5) { + + // 5:已支付(默认不发) 10:已出票 -5:已取消 15:交易成功 + if (dataObject.getInteger("eventType") == -5) { + childOrder.setChildOrderStatus(5); + order.setOrderStatus(5); + order.setCancelTime(new Date()); + order.setCancelRemarks(data.getString("cancelReason")); + } + + if (dataObject.getInteger("eventType") == 15) { + childOrder.setChildOrderStatus(3); + order.setOrderStatus(3); + order.setFinishTime(new Date()); + } + } + } + + highOrderService.updateOrder(order); + + response.setCharacterEncoding("UTF-8"); + response.setContentType("text/html;charset=utf-8"); + PrintWriter writer= response.getWriter(); + writer.write("success"); + } + } catch (Exception e) { + log.error("WechatPayController --> wechatNotify() error!", e); + } + } + +} diff --git a/hai-cweb/src/main/java/com/cweb/controller/tPigController.java b/hai-cweb/src/main/java/com/cweb/controller/tPigController.java index 5c0d6a21..74481b18 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/tPigController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/tPigController.java @@ -58,7 +58,7 @@ public class tPigController { } } - @RequestMapping(value = "/getTPigCinemaToken", method = RequestMethod.GET) + @RequestMapping(value = "/queryCinemaUrl", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "【小程序】电影票获取千猪Token") public ResponseData queryCinemaUrl() { diff --git a/hai-order/src/main/java/com/web/controller/OrderPayController.java b/hai-order/src/main/java/com/web/controller/OrderPayController.java index b147122e..5f5f5914 100644 --- a/hai-order/src/main/java/com/web/controller/OrderPayController.java +++ b/hai-order/src/main/java/com/web/controller/OrderPayController.java @@ -108,6 +108,8 @@ public class OrderPayController { @Resource private SecConfigService secConfigService; + @Resource + private HighQzOrderService qzOrderService; @Resource private HuiConfig huiConfig; @@ -778,6 +780,38 @@ public class OrderPayController { } } + + @RequestMapping(value = "/huiftPayQz", method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "贵行V家园小程序支付千猪【电影票】") + public ResponseData huiftPayQz(@RequestBody JSONObject body, HttpServletRequest request) { + try { + if (body == null || StringUtils.isBlank(body.getString("orderNo"))) { + log.error("orderToPay error!", "参数错误"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + + // 组装订单 + HighOrder order = qzOrderService.assemblyQzOrder(body.getString("orderNo"), "CINEMA"); + if (order == null) { + log.error("orderToPay error!", "创建订单失败"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "创建订单失败"); + } + + JSONObject thirdPreOrder = huiftTradeService.thirdPreOrder(order); + order.setPayChannel(3); + order.setPayChannelOrderNo(thirdPreOrder.getString("preOrderNo")); + order.setProfitSharingStatus(false); + orderService.updateOrderData(order); + + return ResponseMsgUtil.success(thirdPreOrder); + + } catch (Exception e) { + log.error("orderToPay error!", e); + return ResponseMsgUtil.exception(e); + } + } + @RequestMapping(value = "wechatCombinePay" , method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "微信合单支付") 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 04de6481..ab396ae2 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 @@ -66,6 +66,14 @@ public interface OrderCreateHandleService { */ List thirdPartyOrder(HighOrder order, JSONObject object) throws Exception; + /** + * 电影票订单组装 + * @param order + * @return + * @throws Exception + */ + HighChildOrder cinemaRecharge(HighOrder order) throws Exception; + /** * @Author Sum1Dream * @Name prepaidRecharge 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 7e9cff9c..3570fdcd 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 @@ -934,6 +934,57 @@ public class OrderCreateHandleServiceImpl implements OrderCreateHandleService { return childOrderList; } + @Override + public HighChildOrder cinemaRecharge(HighOrder order) throws Exception { + // 查询电影票订单 + JSONObject orderDetail = QianZhuConfig.getCinemaOrderByOrderNo(order.getOrderNo()); + if (orderDetail == null || !orderDetail.getBoolean("success")) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "电影票订单创建失败"); + } + JSONObject data = orderDetail.getJSONObject("data"); + + HighChildOrder highChildOrder = new HighChildOrder(); + highChildOrder.setGoodsType(GoodsType.goodsType5.getType()); + highChildOrder.setOrderNo(order.getOrderNo()); + + highChildOrder.setMemId(order.getMemId()); + highChildOrder.setMemName(order.getMemName()); + highChildOrder.setMemPhone(order.getMemPhone()); + highChildOrder.setChildOrderNo(System.currentTimeMillis()+""); + highChildOrder.setStoreId(data.getLong("hallId")); + highChildOrder.setStoreName(data.getString("cinemaName")); + highChildOrder.setStoreAddress(data.getString("cinemaAddr")); + highChildOrder.setGoodsId(data.getLong("filmId")); + highChildOrder.setGoodsName(data.getString("filmName")); + highChildOrder.setGoodsDesc(data.getString("seatsDesc")); + highChildOrder.setGoodsImg(data.getString("pic")); + highChildOrder.setGoodsSpecName(StringUtils.isBlank(data.getString("versionTypes"))?"默认":data.getString("versionTypes")); + highChildOrder.setGoodsPrice(new BigDecimal(data.getString("unitPrice"))); + highChildOrder.setGoodsActualPrice(new BigDecimal(data.getString("unitPrice"))); + highChildOrder.setSaleCount(data.getInteger("seatsCount")); + highChildOrder.setTotalPrice(new BigDecimal(highChildOrder.getSaleCount().toString()).multiply(highChildOrder.getGoodsPrice())); + highChildOrder.setTotalActualPrice(new BigDecimal(highChildOrder.getSaleCount().toString()).multiply(highChildOrder.getGoodsActualPrice())); + highChildOrder.setTotalDeductionPrice(new BigDecimal("0")); + highChildOrder.setGiveawayType(false); + highChildOrder.setChildOrderStatus(OrderChildStatus.STATUS1.getNumber()); + highChildOrder.setPraiseStatus(0); + highChildOrder.setCreateTime(order.getCreateTime()); + + // 观看时间 + JSONObject showTimeObject = new JSONObject(); + showTimeObject.put("showTime", data.getString("showTime")); + showTimeObject.put("showEndTime", data.getString("showEndTime")); + highChildOrder.setExt1(showTimeObject.toJSONString()); + + // 影厅名称 + highChildOrder.setExt2(data.getString("hallName")); + + // 影片语言 + highChildOrder.setExt3(data.getString("language")); + + return highChildOrder; + } + @Override public HighChildOrder mobileRecharge(HighOrder order , JSONObject object) throws Exception { // 初始化话费订单对象 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 4e1ead96..3836b147 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 @@ -246,8 +246,12 @@ public class OrderServiceImpl implements OrderService { // 电影票 } else if (child.getGoodsType().equals(OrderChildGoodsType.TYPE5.getNumber())) { + HighChildOrder childOrder = orderCreateHandleService.cinemaRecharge(order); + childOrderList.add(childOrder); + order.setTitle(childOrder.getGoodsName()); + order.setProductType(OrderProductType.PRODUCT_TYPE10.getNumber()); - // 话费充值 + // 话费充值 } else if (child.getGoodsType().equals(OrderChildGoodsType.TYPE6.getNumber())) { /*********** 组装肯德基,星巴克,第三方会员充值 话费 请求数据************/ JSONObject object = thirdProductConfig.assembleOrder(order , child); @@ -622,7 +626,7 @@ public class OrderServiceImpl implements OrderService { if (orderData.getOrderStatus().equals(OrderStatus.STATUS1.getNumber())) { // 10分钟内未支付,自动取消订单 Message rocketMsg = MessageBuilder.withPayload(order).build(); - rocketMQTemplate.syncSend(OrderTopic.ORDER_TOPIC_CANCEL.getTopic(), rocketMsg,1000,14); + // rocketMQTemplate.syncSend(OrderTopic.ORDER_TOPIC_CANCEL.getTopic(), rocketMsg,1000,14); } else if (orderData.getOrderStatus().equals(OrderStatus.STATUS2.getNumber())) { // 支付校验 diff --git a/hai-service/src/main/java/com/hai/service/impl/HighQzOrderServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighQzOrderServiceImpl.java index 73276a8b..d04a47d6 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighQzOrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighQzOrderServiceImpl.java @@ -9,154 +9,79 @@ import com.hai.config.QianZhuConfig; import com.hai.entity.HighChildOrder; import com.hai.entity.HighOrder; import com.hai.entity.HighUser; +import com.hai.enum_type.GoodsType; +import com.hai.order.model.CreateOrderChildModel; +import com.hai.order.model.CreateOrderModel; +import com.hai.order.service.OrderService; +import com.hai.order.type.OrderChildStatus; +import com.hai.order.type.OrderProductType; +import com.hai.order.type.OrderStatus; import com.hai.service.HighOrderService; import com.hai.service.HighQzOrderService; import com.hai.service.HighUserService; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.math.BigDecimal; import java.util.ArrayList; +import java.util.List; @Service("highQzOrderService") public class HighQzOrderServiceImpl implements HighQzOrderService { @Resource private HighUserService highUserService; - @Resource private HighOrderService highOrderService; + @Resource + private OrderService orderService; @Override + @Transactional(rollbackFor=Exception.class,propagation= Propagation.REQUIRES_NEW) public HighOrder assemblyQzOrder(String orderNo,String orderType) throws Exception { + // 查询订单 已存在返回订单,未存在创建订单 + HighOrder order = highOrderService.getOrderByOrderNo(orderNo); + if (order != null) { + return order; + } HighOrder highOrder = null; JSONObject orderDetail = null; - if (orderType.equals("KFC")) { - orderDetail = QianZhuConfig.getKfcOrderByOrderNo(orderNo); - } - if (orderType.equals("CINEMA")) { orderDetail = QianZhuConfig.getCinemaOrderByOrderNo(orderNo); } - - if (orderType.equals("MOBILE")) { + /* if (orderType.equals("KFC")) { + orderDetail = QianZhuConfig.getKfcOrderByOrderNo(orderNo); + }*/ + /*if (orderType.equals("MOBILE")) { orderDetail = QianZhuConfig.getMobileOrderByOrderNo(orderNo); - } - + }*/ if (orderDetail != null && orderDetail.getBoolean("success") == true) { highOrder = new HighOrder(); JSONObject data = orderDetail.getJSONObject("data"); - HighOrder order = highOrderService.getOrderByOrderNo(orderNo); - if (order != null) { - return order; - } - HighUser highUser = highUserService.findByUnionId(data.getString("platformUniqueId")); + + // 查询用户信息 + HighUser highUser = highUserService.findByPhone(data.getString("userMobile")); if (highUser == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到用户"); } - highOrder.setHighChildOrderList(new ArrayList<>()); - highOrder.setOrderNo(orderNo); - highOrder.setMemId(highUser.getId()); - highOrder.setMemName(data.getString("userName")); - highOrder.setMemPhone(data.getString("userMobile")); - //highOrder.setPayModel(2); - highOrder.setPayType(2); - highOrder.setPayPrice(data.getBigDecimal("totalPrice")); - highOrder.setTotalPrice(data.getBigDecimal("totalPrice")); - highOrder.setTotalDeductionPrice(new BigDecimal("0")); - highOrder.setOrderStatus(1); - highOrder.setCreateTime(data.getDate("createTime")); - - HighChildOrder highChildOrder; - if (orderType.equals("KFC")) { - // 商品信息 - JSONObject kfcPlaceOrder = data.getJSONObject("kfcPlaceOrder"); - JSONArray items = kfcPlaceOrder.getJSONArray("items"); - for (Object goodsObject : items) { - JSONObject object = JSONObject.parseObject(JSONObject.toJSONString(goodsObject), JSONObject.class); - highChildOrder = new HighChildOrder(); - highChildOrder.setMemId(highOrder.getMemId()); - highChildOrder.setGoodsType(4); - highChildOrder.setStoreName(kfcPlaceOrder.getString("storeName")); - highChildOrder.setStoreAddress(kfcPlaceOrder.getString("storeAddress")); - highChildOrder.setGoodsName(object.getString("productName")); - highChildOrder.setGoodsImg(object.getString("imageUrl")); - highChildOrder.setGoodsSpecName("默认"); - highChildOrder.setGoodsPrice(new BigDecimal(object.getString("originPrice"))); - highChildOrder.setGoodsActualPrice(new BigDecimal(object.getString("price"))); - highChildOrder.setSaleCount(object.getInteger("quantity")); - highChildOrder.setTotalPrice(new BigDecimal(highChildOrder.getSaleCount().toString()).multiply(highChildOrder.getGoodsPrice())); - highChildOrder.setGiveawayType(false); - highChildOrder.setChildOrderStatus(1); - highChildOrder.setPraiseStatus(0); - - /* // 计算原始价格 - highChildOrder.getGoodsPrice().multiply(new BigDecimal(highChildOrder.getSaleCount().toString())); - highOrder.setTotalPrice();*/ - - // 1:堂食 2:外带 3:外卖 - highChildOrder.setExt1(kfcPlaceOrder.getString("eatType")); - highOrder.getHighChildOrderList().add(highChildOrder); - } - } - - if (orderType.equals("CINEMA")) { - highChildOrder = new HighChildOrder(); - highChildOrder.setMemId(highOrder.getMemId()); - highChildOrder.setGoodsType(5); - //highChildOrder.setStoreId(data.getLong("hallId")); - highChildOrder.setStoreName(data.getString("cinemaName")); - highChildOrder.setStoreAddress(data.getString("cinemaAddr")); - //highChildOrder.setGoodsId(data.getLong("filmId")); - highChildOrder.setGoodsName(data.getString("filmName")); - highChildOrder.setGoodsDesc(data.getString("seatsDesc")); - highChildOrder.setGoodsImg(data.getString("pic")); - highChildOrder.setGoodsSpecName("默认"); - highChildOrder.setGoodsPrice(new BigDecimal(data.getString("marketUnitPrice"))); - highChildOrder.setGoodsActualPrice(new BigDecimal(data.getString("unitPrice"))); - highChildOrder.setSaleCount(data.getInteger("seatsCount")); - highChildOrder.setTotalPrice(new BigDecimal(highChildOrder.getSaleCount().toString()).multiply(highChildOrder.getGoodsPrice())); - highChildOrder.setGiveawayType(false); - highChildOrder.setChildOrderStatus(1); - highChildOrder.setPraiseStatus(0); - - /*// 计算原始价格 - highOrder.setTotalPrice(highChildOrder.getGoodsPrice().multiply(new BigDecimal(highChildOrder.getSaleCount().toString())));*/ - - // 观看时间 - JSONObject showTimeObject = new JSONObject(); - showTimeObject.put("showTime", data.getString("showTime")); - showTimeObject.put("showEndTime", data.getString("showEndTime")); - highChildOrder.setExt1(showTimeObject.toJSONString()); - - // 影厅名称 - highChildOrder.setExt2(data.getString("hallName")); - - // 影片语言 - highChildOrder.setExt3(data.getString("language")); - - highOrder.getHighChildOrderList().add(highChildOrder); - } - - if (orderType.equals("MOBILE")) { - highChildOrder = new HighChildOrder(); - highChildOrder.setMemId(highOrder.getMemId()); - highChildOrder.setGoodsType(6); - highChildOrder.setGoodsName("手机充值"+data.getString("rechargeDenomination")+"元"); - highChildOrder.setGoodsSpecName(data.getString("rechargeMobile")); - highChildOrder.setGoodsPrice(new BigDecimal(data.getString("rechargeDenomination"))); - highChildOrder.setGoodsActualPrice(new BigDecimal(data.getString("unitPrice"))); - highChildOrder.setSaleCount(data.getInteger("quantity")); - highChildOrder.setTotalPrice(new BigDecimal(highChildOrder.getSaleCount().toString()).multiply(highChildOrder.getGoodsPrice())); - highChildOrder.setGiveawayType(false); - highChildOrder.setChildOrderStatus(1); - highChildOrder.setPraiseStatus(0); - /* // 计算原始价格 - highOrder.setTotalPrice(highChildOrder.getGoodsPrice().multiply(new BigDecimal(highChildOrder.getSaleCount().toString())));*/ - highOrder.getHighChildOrderList().add(highChildOrder); - } - highOrderService.insertOrder(highOrder); + CreateOrderModel createOrderModel = new CreateOrderModel(); + createOrderModel.setCompanyId(58L); + createOrderModel.setProductType(OrderProductType.PRODUCT_TYPE10.getNumber()); + createOrderModel.setOrderNo(orderNo); + createOrderModel.setMemId(highUser.getId()); + createOrderModel.setMemName(highUser.getName()); + createOrderModel.setMemPhone(highUser.getPhone()); + + List orderChildList = new ArrayList<>(); + CreateOrderChildModel orderChild = new CreateOrderChildModel(); + orderChild.setGoodsType(GoodsType.goodsType5.getType()); + orderChildList.add(orderChild); + createOrderModel.setChildOrderList(orderChildList); + return orderService.createOrder(createOrderModel); } return highOrder; }