|
@@ -68,7 +68,7 @@ public class OrderServiceImpl implements OrderService {
|
|
String apiOrganizeOrderId;
|
|
String apiOrganizeOrderId;
|
|
Map<String, Object> addressInfo;
|
|
Map<String, Object> addressInfo;
|
|
Map<String, Object> productInfo;
|
|
Map<String, Object> productInfo;
|
|
- Map<String, Object> payInfo;
|
|
|
|
|
|
+ BigDecimal orderShouldPayFee;
|
|
Map<String, Object> invoiceInfo;
|
|
Map<String, Object> invoiceInfo;
|
|
String notifyUrl;
|
|
String notifyUrl;
|
|
try {
|
|
try {
|
|
@@ -87,8 +87,8 @@ public class OrderServiceImpl implements OrderService {
|
|
if (null == productInfo) {
|
|
if (null == productInfo) {
|
|
return ResponseJson.error("订单商品数据异常");
|
|
return ResponseJson.error("订单商品数据异常");
|
|
}
|
|
}
|
|
- payInfo = orderInfo.getJSONObject("payInfo");
|
|
|
|
- if (null == payInfo) {
|
|
|
|
|
|
+ orderShouldPayFee = orderInfo.getBigDecimal("orderShouldPayFee");
|
|
|
|
+ if (null == orderShouldPayFee) {
|
|
return ResponseJson.error("订单金额数据异常");
|
|
return ResponseJson.error("订单金额数据异常");
|
|
}
|
|
}
|
|
invoiceInfo = orderInfo.getJSONObject("invoiceInfo");
|
|
invoiceInfo = orderInfo.getJSONObject("invoiceInfo");
|
|
@@ -123,12 +123,6 @@ public class OrderServiceImpl implements OrderService {
|
|
BigDecimal payTotalFee = BigDecimal.ZERO;
|
|
BigDecimal payTotalFee = BigDecimal.ZERO;
|
|
// 真实支付金额(订单总额减去抵扣的账户余额)
|
|
// 真实支付金额(订单总额减去抵扣的账户余额)
|
|
BigDecimal payableAmount = BigDecimal.ZERO;
|
|
BigDecimal payableAmount = BigDecimal.ZERO;
|
|
- // 运费
|
|
|
|
- if (null == payInfo.get("freePostFlag") || null == payInfo.get("freight")) {
|
|
|
|
- return ResponseJson.error("运费数据异常");
|
|
|
|
- }
|
|
|
|
- Integer freePostFlag = (Integer) payInfo.get("freePostFlag");
|
|
|
|
- BigDecimal freight = new BigDecimal(payInfo.get("freight").toString());
|
|
|
|
/*
|
|
/*
|
|
* 发票信息获取
|
|
* 发票信息获取
|
|
*/
|
|
*/
|
|
@@ -163,20 +157,6 @@ public class OrderServiceImpl implements OrderService {
|
|
if (null == provinceId || null == cityId || null == townId) {
|
|
if (null == provinceId || null == cityId || null == townId) {
|
|
return ResponseJson.error("地址信息异常");
|
|
return ResponseJson.error("地址信息异常");
|
|
}
|
|
}
|
|
- // 验证运费是否正确
|
|
|
|
- if (1 == freePostFlag) {
|
|
|
|
- if (19 != provinceId) {
|
|
|
|
- return ResponseJson.error("广东省外地址只能到付");
|
|
|
|
- } else if (202 != cityId) {
|
|
|
|
- if (0 != freight.compareTo(new BigDecimal(15))) {
|
|
|
|
- return ResponseJson.error("深圳市外运费应为15元");
|
|
|
|
- }
|
|
|
|
- } else if (0 != freight.compareTo(new BigDecimal(10))) {
|
|
|
|
- return ResponseJson.error("深圳室内运费应为10元");
|
|
|
|
- }
|
|
|
|
- } else if (0 != freight.compareTo(BigDecimal.ZERO)) {
|
|
|
|
- return ResponseJson.error("运费应为0元");
|
|
|
|
- }
|
|
|
|
/*
|
|
/*
|
|
* 初始化主订单参数
|
|
* 初始化主订单参数
|
|
*/
|
|
*/
|
|
@@ -235,6 +215,9 @@ public class OrderServiceImpl implements OrderService {
|
|
productCount += productNum;
|
|
productCount += productNum;
|
|
// 获取商品信息
|
|
// 获取商品信息
|
|
CmApiOrganizeProductPo organizeProduct = productMapper.getProductByProductId(productId);
|
|
CmApiOrganizeProductPo organizeProduct = productMapper.getProductByProductId(productId);
|
|
|
|
+ if (productNum < organizeProduct.getMinBuyNumber()) {
|
|
|
|
+ return ResponseJson.error("商品购买数量不能少于最小起订量");
|
|
|
|
+ }
|
|
if (null == organizeProduct) {
|
|
if (null == organizeProduct) {
|
|
return ResponseJson.error("订单商品数据异常");
|
|
return ResponseJson.error("订单商品数据异常");
|
|
}
|
|
}
|
|
@@ -311,20 +294,12 @@ public class OrderServiceImpl implements OrderService {
|
|
//促销赠品数量
|
|
//促销赠品数量
|
|
order.setPromotionalGiftsCount(0);
|
|
order.setPromotionalGiftsCount(0);
|
|
// 0包邮 -1到付 1 有运费
|
|
// 0包邮 -1到付 1 有运费
|
|
- order.setFreePostFlag(freePostFlag.toString());
|
|
|
|
- order.setFreight(freight);
|
|
|
|
|
|
+ order.setFreePostFlag("-1");
|
|
|
|
+ order.setFreight(BigDecimal.ZERO);
|
|
// 商品总额
|
|
// 商品总额
|
|
order.setProductTotalFee(productTotalFee);
|
|
order.setProductTotalFee(productTotalFee);
|
|
// 订单总额(商品金额+运费)
|
|
// 订单总额(商品金额+运费)
|
|
- if (1 == freePostFlag) {
|
|
|
|
- // 机构用户 计算商品运费
|
|
|
|
- Double freightFee = computedPostageFee(provinceId, cityId);
|
|
|
|
- freight = BigDecimal.valueOf(freightFee);
|
|
|
|
- order.setFreight(freight);
|
|
|
|
- payTotalFee = MathUtil.add(productTotalFee, freight);
|
|
|
|
- } else {
|
|
|
|
- payTotalFee = productTotalFee;
|
|
|
|
- }
|
|
|
|
|
|
+ payTotalFee = productTotalFee;
|
|
orderTotalFee = productTotalFee;
|
|
orderTotalFee = productTotalFee;
|
|
order.setOrderTotalFee(orderTotalFee);
|
|
order.setOrderTotalFee(orderTotalFee);
|
|
order.setPayTotalFee(payTotalFee);
|
|
order.setPayTotalFee(payTotalFee);
|
|
@@ -344,7 +319,6 @@ public class OrderServiceImpl implements OrderService {
|
|
// 是否返佣订单
|
|
// 是否返佣订单
|
|
order.setRebateFlag("0");
|
|
order.setRebateFlag("0");
|
|
// 判断前端传入orderShouldPayFee订单应付金额,和后台计算应付金额对比
|
|
// 判断前端传入orderShouldPayFee订单应付金额,和后台计算应付金额对比
|
|
- BigDecimal orderShouldPayFee = new BigDecimal(payInfo.get("orderShouldPayFee").toString());
|
|
|
|
double v = MathUtil.sub(payableAmount, orderShouldPayFee).doubleValue();
|
|
double v = MathUtil.sub(payableAmount, orderShouldPayFee).doubleValue();
|
|
log.info(">>>>>payableAmount:" + payableAmount + " ,orderShouldPayFee:" + orderShouldPayFee);
|
|
log.info(">>>>>payableAmount:" + payableAmount + " ,orderShouldPayFee:" + orderShouldPayFee);
|
|
// 考虑前端计算不精确
|
|
// 考虑前端计算不精确
|
|
@@ -532,11 +506,8 @@ public class OrderServiceImpl implements OrderService {
|
|
//退款总金额
|
|
//退款总金额
|
|
cmOrderVo.setReturnedPurchaseFee(returnedPurchaseFee);
|
|
cmOrderVo.setReturnedPurchaseFee(returnedPurchaseFee);
|
|
}
|
|
}
|
|
- // 运费信息
|
|
|
|
- cmOrderVo.setFreePostFlag(order.getFreePostFlag());
|
|
|
|
- cmOrderVo.setFreight(order.getFreight());
|
|
|
|
// 发票信息
|
|
// 发票信息
|
|
- BpOrderInvoicePo invoiceInfo = orderMapper.getOrderInvoice(order.getOrderID());
|
|
|
|
|
|
+ BpOrderInvoiceVo invoiceInfo = orderMapper.getOrderInvoiceVo(order.getOrderID());
|
|
// 商品信息
|
|
// 商品信息
|
|
List<OrderProductVo> dbProductList = productMapper.getOrderProduct(order.getOrderID());
|
|
List<OrderProductVo> dbProductList = productMapper.getOrderProduct(order.getOrderID());
|
|
List<DisplayOrderProductVo> orderProductList = new ArrayList<>();
|
|
List<DisplayOrderProductVo> orderProductList = new ArrayList<>();
|
|
@@ -580,6 +551,7 @@ public class OrderServiceImpl implements OrderService {
|
|
orderProductList.add(product);
|
|
orderProductList.add(product);
|
|
}
|
|
}
|
|
HashMap<String, Object> orderDetail = new HashMap<>();
|
|
HashMap<String, Object> orderDetail = new HashMap<>();
|
|
|
|
+ orderDetail.put("orderId", apiOrganizeOrderId);
|
|
orderDetail.put("addressInfo", addressInfo);
|
|
orderDetail.put("addressInfo", addressInfo);
|
|
orderDetail.put("orderInfo", cmOrderVo);
|
|
orderDetail.put("orderInfo", cmOrderVo);
|
|
orderDetail.put("productInfo", orderProductList);
|
|
orderDetail.put("productInfo", orderProductList);
|
|
@@ -626,7 +598,7 @@ public class OrderServiceImpl implements OrderService {
|
|
order.setCloseReason("协销或用户主动取消订单");
|
|
order.setCloseReason("协销或用户主动取消订单");
|
|
order.setCloseTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
|
order.setCloseTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
|
orderMapper.updateOrder(order);
|
|
orderMapper.updateOrder(order);
|
|
- return ResponseJson.success("取消订单成功");
|
|
|
|
|
|
+ return ResponseJson.success();
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|