|
|
@ -90,112 +90,108 @@ public class OrderPaySuccessService { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void productVpd(OrderModel order, BsOrderChild childOrder) throws Exception { |
|
|
|
public void productVpd(OrderModel order, BsOrderChild childOrder) throws Exception { |
|
|
|
// 查询卡券订单
|
|
|
|
// 查询卡券订单
|
|
|
|
List<BsOrderCoupon> orderCouponList = orderCouponService.getListByChildOrderNo(childOrder.getChildOrderNo()); |
|
|
|
BsOrderCoupon orderCoupon = orderCouponService.getDetailByChildOrderNo(childOrder.getChildOrderNo()); |
|
|
|
for (BsOrderCoupon orderCoupon : orderCouponList) { |
|
|
|
// 查询卡券订单的卡密
|
|
|
|
// 查询卡券订单的卡密
|
|
|
|
List<BsOrderCouponNo> couponNoList = orderCouponNoService.getListByCouponOrderId(orderCoupon.getId()); |
|
|
|
List<BsOrderCouponNo> couponNoList = orderCouponNoService.getListByCouponOrderId(orderCoupon.getId()); |
|
|
|
for (BsOrderCouponNo couponNo : couponNoList) { |
|
|
|
for (BsOrderCouponNo couponNo : couponNoList) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
// 虚拟商品
|
|
|
|
// 虚拟商品
|
|
|
|
GoodsVpd vpd = goodsVpdService.queryDetail(childOrder.getProductSpecId()); |
|
|
|
GoodsVpd vpd = goodsVpdService.queryDetail(childOrder.getProductSpecId()); |
|
|
|
if (vpd.getSource() == GoodsVpdSourceEnum.type1.getCode()) { |
|
|
|
if (vpd.getSource() == GoodsVpdSourceEnum.type1.getCode()) { |
|
|
|
|
|
|
|
|
|
|
|
} else if (vpd.getSource() == GoodsVpdSourceEnum.type4.getCode()) { |
|
|
|
} else if (vpd.getSource() == GoodsVpdSourceEnum.type4.getCode()) { |
|
|
|
// 推送给汇联通
|
|
|
|
// 推送给汇联通
|
|
|
|
JSONObject returnParam = HuiLianTongCouponService.costRechargeOrder(couponNo.getChannelOrderNo()); |
|
|
|
JSONObject returnParam = HuiLianTongCouponService.costRechargeOrder(couponNo.getChannelOrderNo()); |
|
|
|
if (returnParam.getString("respCode").equals("0000")) { |
|
|
|
if (returnParam.getString("respCode").equals("0000")) { |
|
|
|
// 解密
|
|
|
|
// 解密
|
|
|
|
JSONObject jsonObject = HuiLianTongUnionCardService.resolveResponse(returnParam.getString("data")); |
|
|
|
JSONObject jsonObject = HuiLianTongUnionCardService.resolveResponse(returnParam.getString("data")); |
|
|
|
JSONArray dataArray = JSONObject.parseObject(jsonObject.getString("data"), JSONArray.class); |
|
|
|
JSONArray dataArray = JSONObject.parseObject(jsonObject.getString("data"), JSONArray.class); |
|
|
|
for (Object data : dataArray) { |
|
|
|
for (Object data : dataArray) { |
|
|
|
JSONObject dataObject = (JSONObject) data; |
|
|
|
JSONObject dataObject = (JSONObject) data; |
|
|
|
couponNo.setExpireTime(dataObject.getDate("validEndDate")); |
|
|
|
couponNo.setExpireTime(dataObject.getDate("validEndDate")); |
|
|
|
couponNo.setGoodsVpdSourceCouNo(dataObject.getString("couNo")); |
|
|
|
couponNo.setGoodsVpdSourceCouNo(dataObject.getString("couNo")); |
|
|
|
orderCouponNoService.editData(couponNo); |
|
|
|
orderCouponNoService.editData(couponNo); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} else if (vpd.getSource() == GoodsVpdSourceEnum.type5.getCode()) { |
|
|
|
} else if (vpd.getSource() == GoodsVpdSourceEnum.type5.getCode()) { |
|
|
|
// 预发码
|
|
|
|
// 预发码
|
|
|
|
JSONObject preSendCoupon = ChongQingCNPCCouponService.preSendCoupon(orderCoupon.getGoodsVpdKey(), orderCoupon.getOrderNo(), 1, orderCoupon.getUserPhone()); |
|
|
|
JSONObject preSendCoupon = ChongQingCNPCCouponService.preSendCoupon(orderCoupon.getGoodsVpdKey(), orderCoupon.getOrderNo(), 1, orderCoupon.getUserPhone()); |
|
|
|
if (preSendCoupon.getInteger("status").equals(1)) { |
|
|
|
if (preSendCoupon.getInteger("status").equals(1)) { |
|
|
|
// 给用户发码
|
|
|
|
// 给用户发码
|
|
|
|
JSONObject response = ChongQingCNPCCouponService.sendCNPCTicket(orderCoupon.getGoodsVpdKey(), orderCoupon.getOrderNo(), 1, orderCoupon.getUserPhone()); |
|
|
|
JSONObject response = ChongQingCNPCCouponService.sendCNPCTicket(orderCoupon.getGoodsVpdKey(), orderCoupon.getOrderNo(), 1, orderCoupon.getUserPhone()); |
|
|
|
JSONObject couponDetail = response.getJSONObject("ticketDetail"); |
|
|
|
JSONObject couponDetail = response.getJSONObject("ticketDetail"); |
|
|
|
JSONArray codeList = response.getJSONArray("codeList"); |
|
|
|
JSONArray codeList = response.getJSONArray("codeList"); |
|
|
|
for (Object data : codeList) { |
|
|
|
for (Object data : codeList) { |
|
|
|
couponNo.setExpireTime(DateUtil.format(couponDetail.getString("expiredDate"), "yyyy-MM-dd")); |
|
|
|
couponNo.setExpireTime(DateUtil.format(couponDetail.getString("expiredDate"), "yyyy-MM-dd")); |
|
|
|
couponNo.setGoodsVpdSourceCouNo(ChongQingCNPCCouponService.decryptCouponCode(String.valueOf(data))); |
|
|
|
couponNo.setGoodsVpdSourceCouNo(ChongQingCNPCCouponService.decryptCouponCode(String.valueOf(data))); |
|
|
|
orderCouponNoService.editData(couponNo); |
|
|
|
orderCouponNoService.editData(couponNo); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} else if (vpd.getSource() == GoodsVpdSourceEnum.type6.getCode()) { |
|
|
|
} else if (vpd.getSource() == GoodsVpdSourceEnum.type6.getCode()) { |
|
|
|
/* // 派发停车券
|
|
|
|
/* // 派发停车券
|
|
|
|
ApiBlxCoupon apiBlxCoupon = apiBlxCouponService.findBlxCoupon(coupon.getCouponKey()); |
|
|
|
ApiBlxCoupon apiBlxCoupon = apiBlxCouponService.findBlxCoupon(coupon.getCouponKey()); |
|
|
|
if (apiBlxCoupon == null || apiBlxCoupon.getCouponStatus() != 1) { |
|
|
|
if (apiBlxCoupon == null || apiBlxCoupon.getCouponStatus() != 1) { |
|
|
|
throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "当前卡券不可购买"); |
|
|
|
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()) { |
|
|
|
} else if (vpd.getSource() == GoodsVpdSourceEnum.type7.getCode()) { |
|
|
|
/* // 发放卡券
|
|
|
|
/* // 发放卡券
|
|
|
|
JSONObject jsonObject = petroConfig.getCoupon(orderCoupon.getGoodsVpdKey(), orderCoupon.getUserPhone()); |
|
|
|
JSONObject jsonObject = petroConfig.getCoupon(orderCoupon.getGoodsVpdKey(), orderCoupon.getUserPhone()); |
|
|
|
if (!jsonObject.getString("resultCode").equals("0000")) { |
|
|
|
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")); |
|
|
|
throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , jsonObject.getString("errMsg")); |
|
|
|
} |
|
|
|
} |
|
|
|
String data = PetroConfig.decrypt(jsonObject.getString("jsonResult")); |
|
|
|
JSONObject object = jsonObject.getJSONObject("data"); |
|
|
|
JSONObject object = JSONObject.parseObject(data); |
|
|
|
couponNo.setExpireTime(vpd.getSalesEndTime()); |
|
|
|
orderCoupon.setExpireTime(vpd.getSalesEndTime()); |
|
|
|
couponNo.setGoodsVpdSourceCouNo(object.getString("couponCode")); |
|
|
|
orderCoupon.setGoodsVpdSourceCouNo(object.getString("voucher")); |
|
|
|
orderCouponNoService.editData(couponNo); |
|
|
|
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); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} 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); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|