修改话费定时任务问题

袁野 2 years ago
parent 06e2a1402e
commit dab3fa0453
  1. 111
      hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java

@ -1777,10 +1777,104 @@ public class HighOrderServiceImpl implements HighOrderService {
HighOrder highOrder = new HighOrder(); HighOrder highOrder = new HighOrder();
HighUser user = highUserService.findByUserId(object.getLong("userId")); HighUser user = highUserService.findByUserId(object.getLong("userId"));
JSONObject productDetail = thirdProductConfig.getThirdPartyByDetail(object.getInteger("platformId") , object.getInteger("productType") , object.getLong("companyId"));
// 积分抵扣金额
BigDecimal integralPrice = new BigDecimal(0);
// 优惠券抵扣金额
BigDecimal discountPrice = new BigDecimal(0);
// 定义优惠券
HighDiscountUserRel highDiscountUserRel = null;
// 判断是否有优惠券
if (object.getLong("memDiscountId") != null) {
// 优惠券信息
highDiscountUserRel = highDiscountUserRelService.getRelById(object.getLong("memDiscountId"));
highOrder.setMemDiscountId(object.getLong("memDiscountId"));
if (highDiscountUserRel == null || highDiscountUserRel.getStatus() != 1) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "优惠券状态错误");
}
if (!highDiscountUserRel.getHighDiscount().getUseScope().equals(DiscountUseScope.type1.getType())
&& !highDiscountUserRel.getHighDiscount().getUseScope().equals(DiscountUseScope.type3.getType())) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法使用此优惠券");
}
}
// 使用优惠券
// 优惠券抵扣
// if (highDiscountUserRel != null) {
// highOrder.setMemDiscountName(highDiscountUserRel.getHighDiscount().getDiscountName());
// // 卡卷类型 1:满减 2:抵扣 3:折扣
// if (highDiscountUserRel.getHighDiscount().getDiscountType() == 1) {
// // 如果商品支付总额 小于 满减价格
// if (outRechargePrice.getRechargePrice().compareTo(highDiscountUserRel.getHighDiscount().getDiscountCondition()) < 0) {
// throw ErrorHelp.genException(SysCode.System, ErrorCode.UN_MEMBER_ERROR, "订单未达到" + highDiscountUserRel.getHighDiscount().getDiscountCondition() + "元,无法使用此优惠券");
// }
// // 计算支付金额 = 商品充值总额 - 满减额度
// payPrice = outRechargePrice.getRechargePrice().subtract(highDiscountUserRel.getHighDiscount().getDiscountPrice());
// outRechargeOrder.setDiscountDeductionPrice(highDiscountUserRel.getHighDiscount().getDiscountPrice());
//
// }
//
// // 卡卷类型 1:满减 2:抵扣 3:折扣
// if (highDiscountUserRel.getHighDiscount().getDiscountType() == 2) {
// // 计算支付金额 = 商品充值总额 - 满减额度
// payPrice = outRechargePrice.getRechargePrice().subtract(highDiscountUserRel.getHighDiscount().getDiscountPrice());
// outRechargeOrder.setDiscountDeductionPrice(highDiscountUserRel.getHighDiscount().getDiscountPrice());
//
// }
//
// // 卡卷类型 1:满减 2:抵扣 3:折扣
// if (highDiscountUserRel.getHighDiscount().getDiscountType() == 3) {
// BigDecimal discountPrice = highDiscountUserRel.getHighDiscount().getDiscountPrice();
// // 订单总额 * 折扣
// payPrice = outRechargePrice.getRechargePrice().multiply(discountPrice);
// outRechargeOrder.setDiscountDeductionPrice(outRechargePrice.getRechargePrice().subtract(payPrice));
// outRechargeOrder.setPayRealPrice(payPrice);
// }
// }
JSONObject jsonObject = null; JSONObject jsonObject = null;
// 1 星巴克 2 肯德基 // 1 星巴克 2 肯德基
if (object.getInteger("productType") == 1) { if (object.getInteger("productType") == 1) {
// 下单
jsonObject = QianZhuConfig.starbucksOrders(object.getLong("userId") , object.getString("storeCode") , object.getString("orderItems") , object.getString("customerMobile")); jsonObject = QianZhuConfig.starbucksOrders(object.getLong("userId") , object.getString("storeCode") , object.getString("orderItems") , object.getString("customerMobile"));
// 判断下单是否成功
if (!jsonObject.getBoolean("success")) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR , jsonObject.getString("message"));
}
// 根据订单号查询订单详情
JSONObject orderObject = QianZhuConfig.starbucksOrderByOrderNo(jsonObject.getJSONObject("data").getString("orderNo"));
// 判断下单是否成功
if (!orderObject.getBoolean("success")) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR , jsonObject.getString("message"));
}
JSONArray starbucksOrder = orderObject.getJSONArray("");
// 根据订单号查询订单内容并插入数据
if (jsonObject != null && jsonObject.getBoolean("success")) {
highOrder.setOrderNo(jsonObject.getJSONObject("data").getString("orderNo"));
highOrder.setRegionId(object.getString("regionId"));
highOrder.setCreateTime(new Date());
highOrder.setMemId(user.getId());
highOrder.setMemName(user.getName());
highOrder.setMemPhone(user.getPhone());
highOrder.setOrderStatus(1);
highOrder.setRemarks(object.getString("userRemark"));
highOrderMapper.insert(highOrder);
} else {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR , jsonObject.getString("message"));
}
} else if (object.getInteger("productType") == 2) { } else if (object.getInteger("productType") == 2) {
if (object.getInteger("eatType") == null) { if (object.getInteger("eatType") == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请选择就餐方式!"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请选择就餐方式!");
@ -1788,24 +1882,9 @@ public class HighOrderServiceImpl implements HighOrderService {
jsonObject = QianZhuConfig.createKfcOrder(object.getInteger("eatType") , object.getString("storeCode") , object.getString("customerMobile") , object.getString("orderItems") , object.getString("userId"), object.getString("userRemark")); jsonObject = QianZhuConfig.createKfcOrder(object.getInteger("eatType") , object.getString("storeCode") , object.getString("customerMobile") , object.getString("orderItems") , object.getString("userId"), object.getString("userRemark"));
} }
if (jsonObject != null && jsonObject.getBoolean("success")) {
highOrder.setOrderNo(jsonObject.getJSONObject("data").getString("orderNo"));
highOrder.setRegionId(object.getString("regionId"));
highOrder.setCreateTime(new Date());
highOrder.setMemId(user.getId());
highOrder.setMemName(user.getName());
highOrder.setMemPhone(user.getPhone());
highOrder.setOrderStatus(1);
highOrder.setRemarks(object.getString("userRemark"));
highOrderMapper.insert(highOrder);
return jsonObject.getJSONObject("data");
} else {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR , jsonObject.getString("message"));
}
return jsonObject.getJSONObject("data");
} }
} }

Loading…
Cancel
Save