diff --git a/order/src/main/java/com/order/controller/business/OrderCouponController.java b/order/src/main/java/com/order/controller/business/OrderCouponController.java index d77e689..1b452f9 100644 --- a/order/src/main/java/com/order/controller/business/OrderCouponController.java +++ b/order/src/main/java/com/order/controller/business/OrderCouponController.java @@ -36,11 +36,14 @@ public class OrderCouponController { @RequestMapping(value="/queryDetail",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询交易订单详情") - public ResponseData queryDetail(@RequestParam(value = "orderChildOrderNo" , required = true) String orderChildOrderNo) { + public ResponseData queryDetail(@RequestParam(value = "orderChildNo" , required = true) String orderChildNo) { try { Map param = new HashMap<>(); - param.put("orderNo", orderCouponService.getListByChildOrderNo(orderChildOrderNo)); - param.put("goods", null); + param.put("order", orderCouponService.getDetailByChildOrderNo(orderChildNo)); + + Map goodsParam = new HashMap<>(); + goodsParam.put("orderChildNo", orderChildNo); + param.put("goods", orderCouponService.getOrderList(goodsParam)); return ResponseMsgUtil.success(param); diff --git a/service/src/main/java/com/hfkj/dao/BsOrderCouponMapperExt.java b/service/src/main/java/com/hfkj/dao/BsOrderCouponMapperExt.java index f1274f1..7054385 100644 --- a/service/src/main/java/com/hfkj/dao/BsOrderCouponMapperExt.java +++ b/service/src/main/java/com/hfkj/dao/BsOrderCouponMapperExt.java @@ -44,6 +44,7 @@ public interface BsOrderCouponMapperExt { " LEFT JOIN bs_order_coupon b on a.coupon_order_id = b.id" + " WHERE 1 = 1" + " and b.order_no like concat('%',#{param.orderNo},'%') " + + " and b.child_order_no = #{param.orderChildNo} " + " and b.user_phone like concat('%',#{param.userPhone},'%') " + " and b.pay_type = #{param.payType}" + " and b.status = #{param.tradeStatus}" + diff --git a/service/src/main/java/com/hfkj/service/coupon/BsOrderCouponService.java b/service/src/main/java/com/hfkj/service/coupon/BsOrderCouponService.java index 4c90d55..9b97cdb 100644 --- a/service/src/main/java/com/hfkj/service/coupon/BsOrderCouponService.java +++ b/service/src/main/java/com/hfkj/service/coupon/BsOrderCouponService.java @@ -22,10 +22,10 @@ public interface BsOrderCouponService { /** * 查询卡券订单 - * @param orderChildOrderNo 子订单号 + * @param orderChildNo 子订单号 * @return */ - List getListByChildOrderNo(String orderChildOrderNo); + BsOrderCoupon getDetailByChildOrderNo(String orderChildNo); /** * 查询卡券订单 diff --git a/service/src/main/java/com/hfkj/service/coupon/impl/BsOrderCouponServiceImpl.java b/service/src/main/java/com/hfkj/service/coupon/impl/BsOrderCouponServiceImpl.java index 5e8c500..5d83914 100644 --- a/service/src/main/java/com/hfkj/service/coupon/impl/BsOrderCouponServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/coupon/impl/BsOrderCouponServiceImpl.java @@ -37,10 +37,14 @@ public class BsOrderCouponServiceImpl implements BsOrderCouponService { } @Override - public List getListByChildOrderNo(String orderChildOrderNo) { + public BsOrderCoupon getDetailByChildOrderNo(String orderChildNo) { BsOrderCouponExample example = new BsOrderCouponExample(); - example.createCriteria().andChildOrderNoEqualTo(orderChildOrderNo); - return orderCouponMapper.selectByExample(example); + example.createCriteria().andChildOrderNoEqualTo(orderChildNo); + List list = orderCouponMapper.selectByExample(example); + if (!list.isEmpty()) { + return list.get(0); + } + return null; } @Override diff --git a/service/src/main/java/com/hfkj/service/order/OrderCancelService.java b/service/src/main/java/com/hfkj/service/order/OrderCancelService.java index deb4644..eb6b89f 100644 --- a/service/src/main/java/com/hfkj/service/order/OrderCancelService.java +++ b/service/src/main/java/com/hfkj/service/order/OrderCancelService.java @@ -66,12 +66,10 @@ public class OrderCancelService { // 实物 } else if (goodsMsg.getType() == 2) { // 虚拟 - List orderCouponList = orderCouponService.getListByChildOrderNo(orderChild.getChildOrderNo()); - for(BsOrderCoupon orderCoupon : orderCouponList) { - orderCoupon.setCancelTime(new Date()); - orderCoupon.setStatus(OrderChildStatusEnum.status5.getCode()); - orderCouponService.editData(orderCoupon); - } + BsOrderCoupon orderCoupon = orderCouponService.getDetailByChildOrderNo(orderChild.getChildOrderNo()); + orderCoupon.setCancelTime(new Date()); + orderCoupon.setStatus(OrderChildStatusEnum.status5.getCode()); + orderCouponService.editData(orderCoupon); } } diff --git a/service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java b/service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java index 9c49fa7..8ad234c 100644 --- a/service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java +++ b/service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java @@ -90,112 +90,108 @@ public class OrderPaySuccessService { */ public void productVpd(OrderModel order, BsOrderChild childOrder) throws Exception { // 查询卡券订单 - List orderCouponList = orderCouponService.getListByChildOrderNo(childOrder.getChildOrderNo()); - for (BsOrderCoupon orderCoupon : orderCouponList) { - // 查询卡券订单的卡密 - List couponNoList = orderCouponNoService.getListByCouponOrderId(orderCoupon.getId()); - for (BsOrderCouponNo couponNo : couponNoList) { - try { - // 虚拟商品 - GoodsVpd vpd = goodsVpdService.queryDetail(childOrder.getProductSpecId()); - if (vpd.getSource() == GoodsVpdSourceEnum.type1.getCode()) { - - } else if (vpd.getSource() == GoodsVpdSourceEnum.type4.getCode()) { - // 推送给汇联通 - JSONObject returnParam = HuiLianTongCouponService.costRechargeOrder(couponNo.getChannelOrderNo()); - if (returnParam.getString("respCode").equals("0000")) { - // 解密 - JSONObject jsonObject = HuiLianTongUnionCardService.resolveResponse(returnParam.getString("data")); - JSONArray dataArray = JSONObject.parseObject(jsonObject.getString("data"), JSONArray.class); - for (Object data : dataArray) { - JSONObject dataObject = (JSONObject) data; - couponNo.setExpireTime(dataObject.getDate("validEndDate")); - couponNo.setGoodsVpdSourceCouNo(dataObject.getString("couNo")); - orderCouponNoService.editData(couponNo); - } + BsOrderCoupon orderCoupon = orderCouponService.getDetailByChildOrderNo(childOrder.getChildOrderNo()); + // 查询卡券订单的卡密 + List couponNoList = orderCouponNoService.getListByCouponOrderId(orderCoupon.getId()); + for (BsOrderCouponNo couponNo : couponNoList) { + try { + // 虚拟商品 + GoodsVpd vpd = goodsVpdService.queryDetail(childOrder.getProductSpecId()); + if (vpd.getSource() == GoodsVpdSourceEnum.type1.getCode()) { + + } else if (vpd.getSource() == GoodsVpdSourceEnum.type4.getCode()) { + // 推送给汇联通 + JSONObject returnParam = HuiLianTongCouponService.costRechargeOrder(couponNo.getChannelOrderNo()); + if (returnParam.getString("respCode").equals("0000")) { + // 解密 + JSONObject jsonObject = HuiLianTongUnionCardService.resolveResponse(returnParam.getString("data")); + JSONArray dataArray = JSONObject.parseObject(jsonObject.getString("data"), JSONArray.class); + for (Object data : dataArray) { + JSONObject dataObject = (JSONObject) data; + couponNo.setExpireTime(dataObject.getDate("validEndDate")); + couponNo.setGoodsVpdSourceCouNo(dataObject.getString("couNo")); + orderCouponNoService.editData(couponNo); } + } - } else if (vpd.getSource() == GoodsVpdSourceEnum.type5.getCode()) { - // 预发码 - JSONObject preSendCoupon = ChongQingCNPCCouponService.preSendCoupon(orderCoupon.getGoodsVpdKey(), orderCoupon.getOrderNo(), 1, orderCoupon.getUserPhone()); - if (preSendCoupon.getInteger("status").equals(1)) { - // 给用户发码 - JSONObject response = ChongQingCNPCCouponService.sendCNPCTicket(orderCoupon.getGoodsVpdKey(), orderCoupon.getOrderNo(), 1, orderCoupon.getUserPhone()); - JSONObject couponDetail = response.getJSONObject("ticketDetail"); - JSONArray codeList = response.getJSONArray("codeList"); - for (Object data : codeList) { - couponNo.setExpireTime(DateUtil.format(couponDetail.getString("expiredDate"), "yyyy-MM-dd")); - couponNo.setGoodsVpdSourceCouNo(ChongQingCNPCCouponService.decryptCouponCode(String.valueOf(data))); - orderCouponNoService.editData(couponNo); - } + } else if (vpd.getSource() == GoodsVpdSourceEnum.type5.getCode()) { + // 预发码 + JSONObject preSendCoupon = ChongQingCNPCCouponService.preSendCoupon(orderCoupon.getGoodsVpdKey(), orderCoupon.getOrderNo(), 1, orderCoupon.getUserPhone()); + if (preSendCoupon.getInteger("status").equals(1)) { + // 给用户发码 + JSONObject response = ChongQingCNPCCouponService.sendCNPCTicket(orderCoupon.getGoodsVpdKey(), orderCoupon.getOrderNo(), 1, orderCoupon.getUserPhone()); + JSONObject couponDetail = response.getJSONObject("ticketDetail"); + JSONArray codeList = response.getJSONArray("codeList"); + for (Object data : codeList) { + couponNo.setExpireTime(DateUtil.format(couponDetail.getString("expiredDate"), "yyyy-MM-dd")); + couponNo.setGoodsVpdSourceCouNo(ChongQingCNPCCouponService.decryptCouponCode(String.valueOf(data))); + orderCouponNoService.editData(couponNo); } + } - } else if (vpd.getSource() == GoodsVpdSourceEnum.type6.getCode()) { - /* // 派发停车券 - ApiBlxCoupon apiBlxCoupon = apiBlxCouponService.findBlxCoupon(coupon.getCouponKey()); - if (apiBlxCoupon == null || apiBlxCoupon.getCouponStatus() != 1) { - throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "当前卡券不可购买"); + } else if (vpd.getSource() == GoodsVpdSourceEnum.type6.getCode()) { +/* // 派发停车券 + ApiBlxCoupon apiBlxCoupon = apiBlxCouponService.findBlxCoupon(coupon.getCouponKey()); + if (apiBlxCoupon == null || apiBlxCoupon.getCouponStatus() != 1) { + throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "当前卡券不可购买"); + } + // 计算上送卡券数量 + int num = coupon.getSalesPrice().divide(new BigDecimal(apiBlxCoupon.getDenomination())).intValue(); + if (num > 0) { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("couponCode" , coupon.getCouponKey()); + jsonObject.put("receiverPhone" , order.getMemPhone()); + jsonObject.put("receiverCount" , num); + + JSONObject object = blxConfig.sendCoupon(jsonObject); + + if (object.getInteger("code") == 1) { + order.setOrderStatus(OrderStatus.STATUS3.getNumber()); + order.setFinishTime(new Date()); + orderService.updateOrderData(order); + highUserCardService.getBlxCouponBalance(order.getMemPhone()); + } else { + throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , object.getString("msg")); } - // 计算上送卡券数量 - int num = coupon.getSalesPrice().divide(new BigDecimal(apiBlxCoupon.getDenomination())).intValue(); - if (num > 0) { - JSONObject jsonObject = new JSONObject(); - jsonObject.put("couponCode" , coupon.getCouponKey()); - jsonObject.put("receiverPhone" , order.getMemPhone()); - jsonObject.put("receiverCount" , num); - - JSONObject object = blxConfig.sendCoupon(jsonObject); - - if (object.getInteger("code") == 1) { - order.setOrderStatus(OrderStatus.STATUS3.getNumber()); - order.setFinishTime(new Date()); - orderService.updateOrderData(order); - highUserCardService.getBlxCouponBalance(order.getMemPhone()); - } else { - throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , object.getString("msg")); - } - }*/ + }*/ - } else if (vpd.getSource() == GoodsVpdSourceEnum.type7.getCode()) { - /* // 发放卡券 - JSONObject jsonObject = petroConfig.getCoupon(orderCoupon.getGoodsVpdKey(), orderCoupon.getUserPhone()); - if (!jsonObject.getString("resultCode").equals("0000")) { + } else if (vpd.getSource() == GoodsVpdSourceEnum.type7.getCode()) { + /* // 发放卡券 + JSONObject jsonObject = petroConfig.getCoupon(orderCoupon.getGoodsVpdKey(), orderCoupon.getUserPhone()); + if (!jsonObject.getString("resultCode").equals("0000")) { + throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , jsonObject.getString("errMsg")); + } + String data = PetroConfig.decrypt(jsonObject.getString("jsonResult")); + JSONObject object = JSONObject.parseObject(data); + orderCoupon.setExpireTime(vpd.getSalesEndTime()); + orderCoupon.setGoodsVpdSourceCouNo(object.getString("voucher")); + orderCouponService.editData(orderCoupon);*/ + + } else if (vpd.getSource() == GoodsVpdSourceEnum.type10.getCode()) { + // 发放卡券 + JSONObject jsonObject = PcytCNPCCouponService.getCoupon(orderCoupon.getOrderNo() , orderCoupon.getUserPhone() , orderCoupon.getGoodsVpdKey()); + if (!jsonObject.getString("code").equals("200")) { throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , jsonObject.getString("errMsg")); } - String data = PetroConfig.decrypt(jsonObject.getString("jsonResult")); - JSONObject object = JSONObject.parseObject(data); - orderCoupon.setExpireTime(vpd.getSalesEndTime()); - orderCoupon.setGoodsVpdSourceCouNo(object.getString("voucher")); - orderCouponService.editData(orderCoupon);*/ - - } else if (vpd.getSource() == GoodsVpdSourceEnum.type10.getCode()) { - // 发放卡券 - JSONObject jsonObject = PcytCNPCCouponService.getCoupon(orderCoupon.getOrderNo() , orderCoupon.getUserPhone() , orderCoupon.getGoodsVpdKey()); - if (!jsonObject.getString("code").equals("200")) { - throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , jsonObject.getString("errMsg")); - } - JSONObject object = jsonObject.getJSONObject("data"); - couponNo.setExpireTime(vpd.getSalesEndTime()); - couponNo.setGoodsVpdSourceCouNo(object.getString("couponCode")); - orderCouponNoService.editData(couponNo); - } - } catch (Exception e) { - couponNo.setExceptionStatus(true); - orderCouponService.editData(orderCoupon); + JSONObject object = jsonObject.getJSONObject("data"); + couponNo.setExpireTime(vpd.getSalesEndTime()); + couponNo.setGoodsVpdSourceCouNo(object.getString("couponCode")); + orderCouponNoService.editData(couponNo); } + } catch (Exception e) { + couponNo.setExceptionStatus(true); + orderCouponService.editData(orderCoupon); } - - orderCoupon.setTotalPrice(childOrder.getProductTotalPrice()); - orderCoupon.setTotalDeductionPrice(childOrder.getTotalDeductionPrice()); - orderCoupon.setCouponDiscountPrice(childOrder.getCouponDiscountPrice()); - orderCoupon.setIntegralDiscountPrice(childOrder.getIntegralDiscountPrice()); - orderCoupon.setPayRealPrice(childOrder.getSurplusRefundPrice()); - orderCoupon.setPayChannel(order.getPayChannel()); - orderCoupon.setPayType(order.getPayType()); - orderCoupon.setPaySerialNo(order.getPaySerialNo()); - orderCouponService.editData(orderCoupon); } + orderCoupon.setTotalPrice(childOrder.getProductTotalPrice()); + orderCoupon.setTotalDeductionPrice(childOrder.getTotalDeductionPrice()); + orderCoupon.setCouponDiscountPrice(childOrder.getCouponDiscountPrice()); + orderCoupon.setIntegralDiscountPrice(childOrder.getIntegralDiscountPrice()); + orderCoupon.setPayRealPrice(childOrder.getSurplusRefundPrice()); + orderCoupon.setPayChannel(order.getPayChannel()); + orderCoupon.setPayType(order.getPayType()); + orderCoupon.setPaySerialNo(order.getPaySerialNo()); + orderCouponService.editData(orderCoupon); } - }