提交代码

dev-discount
胡锐 2 years ago
parent 3ddcaff3ca
commit a0d2ad940d
  1. 2
      hai-cweb/src/main/java/com/cweb/controller/HighTestController.java
  2. 7
      hai-cweb/src/main/java/com/cweb/controller/NotifyController.java
  3. 8
      hai-schedule/src/main/java/com/hai/schedule/HighGasSchedule.java
  4. 16
      hai-service/src/main/java/com/hai/config/ChongQingCNPCService.java
  5. 2
      hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java
  6. 2
      hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java
  7. 6
      hai-service/src/main/java/com/hai/service/impl/HighCouponAgentServiceImpl.java
  8. 38
      hai-service/src/main/java/com/hai/service/impl/HighCouponCodeServiceImpl.java
  9. 5
      hai-service/src/main/java/com/hai/service/impl/HighDiscountAgentCodeServiceImpl.java

File diff suppressed because one or more lines are too long

@ -54,7 +54,8 @@ public class NotifyController {
@ApiOperation(value = "重庆中石油通知")
public Object cqCnpcNotify(@RequestBody String paramsStr) {
System.out.println(paramsStr);
log.info(paramsStr);
log.info("重庆中石油核销通知");
log.info("通知参数:" + paramsStr);
try {
if (StringUtils.isNotBlank(paramsStr)) {
@ -64,7 +65,7 @@ public class NotifyController {
HighGasOrderPush highGasOrderPush = new HighGasOrderPush();
highGasOrderPush.setType(OrderPushType.type10.getType());
highGasOrderPush.setOrderNo(body.getString("tradeId"));
highGasOrderPush.setOrderNo(body.getString("tradeIsendMessage = {JSONObject@14276} size = 2d"));
highGasOrderPush.setCreateTime(new Date());
highGasOrderPush.setRequestContent("核销回调");
highGasOrderPush.setReturnContent(paramsStr);
@ -104,8 +105,8 @@ public class NotifyController {
returnContent.put("postMessage", returnPostMessage);
return returnContent;
}
} catch (Exception e) {
log.info("重庆中石油核销通知业务出现异常", e);
return null;
// return ResponseMsgUtil.exception(e);
}

@ -84,11 +84,11 @@ public class HighGasSchedule {
for (Object oilPrice : oilPriceList) {
JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice));
// 查询门店油号
highGasOilPrice = highGasOilPriceService.getGasOilPriceByStoreAndOilNo(store.getId(), oilPriceObject.getInteger("oilNo"));
highGasOilPrice = highGasOilPriceService.getGasOilPriceByStoreAndOilNo(store.getId(), oilPriceObject.getString("oilNo"));
if (highGasOilPrice == null) {
highGasOilPrice = new HighGasOilPrice();
highGasOilPrice.setMerchantStoreId(store.getId());
highGasOilPrice.setOilNo(oilPriceObject.getInteger("oilNo"));
highGasOilPrice.setOilNo(oilPriceObject.getString("oilNo"));
highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName"));
highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip"));
highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun"));
@ -98,7 +98,7 @@ public class HighGasSchedule {
highGasOilPrice.setStatus(GasOilPriceStatusEnum.status1.getStatus());
} else {
highGasOilPrice.setMerchantStoreId(store.getId());
highGasOilPrice.setOilNo(oilPriceObject.getInteger("oilNo"));
highGasOilPrice.setOilNo(oilPriceObject.getString("oilNo"));
highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName"));
highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip"));
highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun"));
@ -137,7 +137,7 @@ public class HighGasSchedule {
JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice));
highGasOilPrice = new HighGasOilPrice();
highGasOilPrice.setMerchantStoreId(merchantStoreModel.getId());
highGasOilPrice.setOilNo(oilPriceObject.getInteger("oilNo"));
highGasOilPrice.setOilNo(oilPriceObject.getString("oilNo"));
highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName"));
highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip"));
highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun"));

@ -22,6 +22,22 @@ public class ChongQingCNPCService {
private static Logger log = LoggerFactory.getLogger(ChongQingCNPCService.class);
/**
* 电子券预发放接口
* @param requestCode
* @param tradeId
* @param ticketSum
* @param phone
*/
public static JSONObject preSendCoupon(String requestCode, String tradeId, Integer ticketSum, String phone) throws Exception {
Map<String, Object> map = new HashMap<>();
map.put("requestCode", requestCode);
map.put("tradeId", tradeId);
map.put("ticketSum", ticketSum);
map.put("phone", phone);
return request("preSendCoupon", map);
}
/**
* 发放电子券
* @param requestCode

@ -163,7 +163,7 @@ public class OrderCreateHandleServiceImpl implements OrderCreateHandleService {
String childOrderNo = OrderUtil.generateChildOrderNo();
// 如果不是来源不是贵州中石化,需要校验库存
if (!coupon.getCouponSource().equals(4)) {
if (!coupon.getCouponSource().equals(4) || !coupon.getCouponSource().equals(5)) {
if (couponService.assignOrderStock(coupon.getId(), childOrderNo) == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "库存不足");
}

@ -172,7 +172,7 @@ public class OrderServiceImpl implements OrderService {
// 购买卡券
if (child.getGoodsType().equals(OrderChildGoodsType.TYPE1.getNumber())) {
order.setProductType(OrderProductType.PRODUCT_TYPE5.getNumber());
// 创建积分充值订单业务
// 创建购买卡券业务
List<HighChildOrder> couponOrderList = orderCreateHandleService.couponHandle(discountUserRel, child);
childOrderList = couponOrderList;
for (HighChildOrder childOrder : couponOrderList) {

@ -337,6 +337,12 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "手机号格式错误");
}
// 预发码
JSONObject preSendCoupon = ChongQingCNPCService.preSendCoupon(coupon.getCouponKey(), couponAgentCode.getConvertCode(), 1, phone);
if (!preSendCoupon.getInteger("status").equals(1)) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "发码失败,请稍后重试!");
}
// 给用户发码
JSONObject response = ChongQingCNPCService.sendCNPCTicket(coupon.getCouponKey(), couponAgentCode.getConvertCode(), 1, phone);
JSONObject couponDetail = response.getJSONObject("ticketDetail");

@ -8,12 +8,14 @@ import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode;
import com.hai.common.utils.DateUtil;
import com.hai.common.utils.IDGenerator;
import com.hai.config.ChongQingCNPCService;
import com.hai.config.HuiLianTongConfig;
import com.hai.config.HuiLianTongUnionCardConfig;
import com.hai.dao.HighChildOrderMapper;
import com.hai.dao.HighCouponCodeMapper;
import com.hai.dao.HighCouponCodeMapperExt;
import com.hai.entity.*;
import com.hai.enum_type.OrderPushType;
import com.hai.model.GzSinopecModel;
import com.hai.model.UserInfoModel;
import com.hai.service.*;
@ -358,6 +360,42 @@ public class HighCouponCodeServiceImpl implements HighCouponCodeService {
highUserCouponService.insertUserCoupon(highUserCoupon);
}
}
} else if (coupon.getCouponSource().equals(5)) {
// 预发码
JSONObject preSendCoupon = ChongQingCNPCService.preSendCoupon(coupon.getCouponKey(), order.getOrderNo(), childOrder.getSaleCount(), order.getMemPhone());
if (preSendCoupon.getInteger("status").equals(1)) {
// 给用户发码
JSONObject response = ChongQingCNPCService.sendCNPCTicket(coupon.getCouponKey(), order.getOrderNo(), childOrder.getSaleCount(), order.getMemPhone());
JSONObject couponDetail = response.getJSONObject("ticketDetail");
JSONArray codeList = response.getJSONArray("codeList");
for (Object data : codeList) {
HighCouponCodeOther couponCodeOther = new HighCouponCodeOther();
couponCodeOther.setType(2);
couponCodeOther.setOrderId(order.getId());
couponCodeOther.setChildOrderId(childOrder.getId());
couponCodeOther.setCouTypeCode(couponDetail.getString("requestCode"));
couponCodeOther.setCouNo(ChongQingCNPCService.decryptCouponCode(String.valueOf(data)));
couponCodeOther.setActiveTime(DateUtil.format(couponDetail.getString("effectiveTime"), "yyyy-MM-dd"));
couponCodeOther.setValidStartDate(DateUtil.format(couponDetail.getString("effectiveTime"), "yyyy-MM-dd"));
couponCodeOther.setValidEndDate(DateUtil.format(couponDetail.getString("expiredDate"), "yyyy-MM-dd"));
couponCodeOther.setStatus(20);
couponCodeOther.setCreateTime(new Date());
couponCodeOtherService.insertCouponCodeOther(couponCodeOther);
// 卡卷关联用户
HighUserCoupon highUserCoupon = new HighUserCoupon();
highUserCoupon.setMerchantId(coupon.getMerchantId());
highUserCoupon.setCouponId(coupon.getId());
highUserCoupon.setOrderId(order.getId());
highUserCoupon.setChildOrderId(childOrder.getId());
highUserCoupon.setUserId(order.getMemId());
highUserCoupon.setCreateTime(new Date());
highUserCoupon.setQrCodeImg(couponCodeOther.getCouNo());
highUserCoupon.setUseEndTime(couponCodeOther.getValidEndDate());
highUserCoupon.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用
highUserCouponService.insertUserCoupon(highUserCoupon);
}
}
} else {
// 查询子订单的兑换码
HighCouponCode code = getCodeByChildOrderNo(childOrder.getChildOrderNo());

@ -231,6 +231,11 @@ public class HighDiscountAgentCodeServiceImpl implements HighDiscountAgentCodeSe
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "优惠券未配置重庆中石油卡券");
}
String tradeId = discountAgentCode.getId()+""+System.currentTimeMillis()+"";
// 预发码
JSONObject preSendCoupon = ChongQingCNPCService.preSendCoupon(couponList.get(0).getHighCoupon().getCouponKey(), tradeId, 1, userModel.getHighUser().getPhone());
if (!preSendCoupon.getInteger("status").equals(1)) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "领取优惠券失败,请稍后重试");
}
// 给用户发码
JSONObject response = ChongQingCNPCService.sendCNPCTicket(
couponList.get(0).getHighCoupon().getCouponKey(),

Loading…
Cancel
Save