提交代码

master
胡锐 6 months ago committed by yuanye
parent 3c4ef583df
commit 9d0ed68c01
  1. 9
      order/src/main/java/com/order/controller/business/OrderCouponController.java
  2. 1
      service/src/main/java/com/hfkj/dao/BsOrderCouponMapperExt.java
  3. 4
      service/src/main/java/com/hfkj/service/coupon/BsOrderCouponService.java
  4. 10
      service/src/main/java/com/hfkj/service/coupon/impl/BsOrderCouponServiceImpl.java
  5. 10
      service/src/main/java/com/hfkj/service/order/OrderCancelService.java
  6. 186
      service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.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<String,Object> param = new HashMap<>();
param.put("orderNo", orderCouponService.getListByChildOrderNo(orderChildOrderNo));
param.put("goods", null);
param.put("order", orderCouponService.getDetailByChildOrderNo(orderChildNo));
Map<String,Object> goodsParam = new HashMap<>();
goodsParam.put("orderChildNo", orderChildNo);
param.put("goods", orderCouponService.getOrderList(goodsParam));
return ResponseMsgUtil.success(param);

@ -44,6 +44,7 @@ public interface BsOrderCouponMapperExt {
" LEFT JOIN bs_order_coupon b on a.coupon_order_id = b.id" +
" WHERE 1 = 1" +
" <if test='param.orderNo != null'> and b.order_no like concat('%',#{param.orderNo},'%') </if>" +
" <if test='param.orderChildNo != null'> and b.child_order_no = #{param.orderChildNo} </if>" +
" <if test='param.userPhone != null'> and b.user_phone like concat('%',#{param.userPhone},'%') </if>" +
" <if test='param.payType != null'> and b.pay_type = #{param.payType}</if>" +
" <if test='param.tradeStatus != null'> and b.status = #{param.tradeStatus}</if>" +

@ -22,10 +22,10 @@ public interface BsOrderCouponService {
/**
* 查询卡券订单
* @param orderChildOrderNo 子订单号
* @param orderChildNo 子订单号
* @return
*/
List<BsOrderCoupon> getListByChildOrderNo(String orderChildOrderNo);
BsOrderCoupon getDetailByChildOrderNo(String orderChildNo);
/**
* 查询卡券订单

@ -37,10 +37,14 @@ public class BsOrderCouponServiceImpl implements BsOrderCouponService {
}
@Override
public List<BsOrderCoupon> 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<BsOrderCoupon> list = orderCouponMapper.selectByExample(example);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
@Override

@ -66,12 +66,10 @@ public class OrderCancelService {
// 实物
} else if (goodsMsg.getType() == 2) {
// 虚拟
List<BsOrderCoupon> 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);
}
}

@ -90,112 +90,108 @@ public class OrderPaySuccessService {
*/
public void productVpd(OrderModel order, BsOrderChild childOrder) throws Exception {
// 查询卡券订单
List<BsOrderCoupon> orderCouponList = orderCouponService.getListByChildOrderNo(childOrder.getChildOrderNo());
for (BsOrderCoupon orderCoupon : orderCouponList) {
// 查询卡券订单的卡密
List<BsOrderCouponNo> 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<BsOrderCouponNo> 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);
}
}

Loading…
Cancel
Save