|
|
@ -1777,19 +1777,89 @@ 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")); |
|
|
|
} else if (object.getInteger("productType") == 2) { |
|
|
|
|
|
|
|
if (object.getInteger("eatType") == null) { |
|
|
|
// 判断下单是否成功
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请选择就餐方式!"); |
|
|
|
if (!jsonObject.getBoolean("success")) { |
|
|
|
} |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR , jsonObject.getString("message")); |
|
|
|
jsonObject = QianZhuConfig.createKfcOrder(object.getInteger("eatType") , object.getString("storeCode") , object.getString("customerMobile") , object.getString("orderItems") , object.getString("userId"), object.getString("userRemark")); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 根据订单号查询订单详情
|
|
|
|
|
|
|
|
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")) { |
|
|
|
if (jsonObject != null && jsonObject.getBoolean("success")) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
highOrder.setOrderNo(jsonObject.getJSONObject("data").getString("orderNo")); |
|
|
|
highOrder.setOrderNo(jsonObject.getJSONObject("data").getString("orderNo")); |
|
|
|
highOrder.setRegionId(object.getString("regionId")); |
|
|
|
highOrder.setRegionId(object.getString("regionId")); |
|
|
|
highOrder.setCreateTime(new Date()); |
|
|
|
highOrder.setCreateTime(new Date()); |
|
|
@ -1798,14 +1868,23 @@ public class HighOrderServiceImpl implements HighOrderService { |
|
|
|
highOrder.setMemPhone(user.getPhone()); |
|
|
|
highOrder.setMemPhone(user.getPhone()); |
|
|
|
highOrder.setOrderStatus(1); |
|
|
|
highOrder.setOrderStatus(1); |
|
|
|
highOrder.setRemarks(object.getString("userRemark")); |
|
|
|
highOrder.setRemarks(object.getString("userRemark")); |
|
|
|
|
|
|
|
|
|
|
|
highOrderMapper.insert(highOrder); |
|
|
|
highOrderMapper.insert(highOrder); |
|
|
|
|
|
|
|
|
|
|
|
return jsonObject.getJSONObject("data"); |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR , jsonObject.getString("message")); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR , jsonObject.getString("message")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else if (object.getInteger("productType") == 2) { |
|
|
|
|
|
|
|
if (object.getInteger("eatType") == null) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请选择就餐方式!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
jsonObject = QianZhuConfig.createKfcOrder(object.getInteger("eatType") , object.getString("storeCode") , object.getString("customerMobile") , object.getString("orderItems") , object.getString("userId"), object.getString("userRemark")); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return jsonObject.getJSONObject("data"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|