|
|
@ -11,6 +11,7 @@ import com.hfkj.common.utils.RandomUtils; |
|
|
|
import com.hfkj.common.utils.RedisUtil; |
|
|
|
import com.hfkj.common.utils.RedisUtil; |
|
|
|
import com.hfkj.dao.BsOrderMapper; |
|
|
|
import com.hfkj.dao.BsOrderMapper; |
|
|
|
import com.hfkj.entity.*; |
|
|
|
import com.hfkj.entity.*; |
|
|
|
|
|
|
|
import com.hfkj.jd.JdPostService; |
|
|
|
import com.hfkj.jd.JdService; |
|
|
|
import com.hfkj.jd.JdService; |
|
|
|
import com.hfkj.model.order.OrderChildModel; |
|
|
|
import com.hfkj.model.order.OrderChildModel; |
|
|
|
import com.hfkj.model.order.OrderModel; |
|
|
|
import com.hfkj.model.order.OrderModel; |
|
|
@ -20,6 +21,8 @@ import com.hfkj.service.BsProductConfigService; |
|
|
|
import com.hfkj.service.discount.CouponDiscountService; |
|
|
|
import com.hfkj.service.discount.CouponDiscountService; |
|
|
|
import com.hfkj.service.discount.CouponDiscountUserRelService; |
|
|
|
import com.hfkj.service.discount.CouponDiscountUserRelService; |
|
|
|
import com.hfkj.service.goods.BsOrderCinemaService; |
|
|
|
import com.hfkj.service.goods.BsOrderCinemaService; |
|
|
|
|
|
|
|
import com.hfkj.service.goods.GoodsSpecsService; |
|
|
|
|
|
|
|
import com.hfkj.service.goods.GoodsUserAddressService; |
|
|
|
import com.hfkj.service.order.*; |
|
|
|
import com.hfkj.service.order.*; |
|
|
|
import com.hfkj.service.user.UserIntegralService; |
|
|
|
import com.hfkj.service.user.UserIntegralService; |
|
|
|
import com.hfkj.sysenum.UserIntegralRecordOpUserTypeEnum; |
|
|
|
import com.hfkj.sysenum.UserIntegralRecordOpUserTypeEnum; |
|
|
@ -28,6 +31,9 @@ import com.hfkj.sysenum.order.OrderChildProductTypeEnum; |
|
|
|
import com.hfkj.sysenum.order.OrderChildStatusEnum; |
|
|
|
import com.hfkj.sysenum.order.OrderChildStatusEnum; |
|
|
|
import com.hfkj.sysenum.order.OrderPayChannelEnum; |
|
|
|
import com.hfkj.sysenum.order.OrderPayChannelEnum; |
|
|
|
import com.hfkj.sysenum.order.OrderStatusEnum; |
|
|
|
import com.hfkj.sysenum.order.OrderStatusEnum; |
|
|
|
|
|
|
|
import com.jd.open.api.sdk.domain.vopdd.QueryOrderOpenProvider.request.querySkuFreight.SkuInfoOrderOpenReq; |
|
|
|
|
|
|
|
import com.jd.open.api.sdk.domain.vopdd.QueryOrderOpenProvider.response.querySkuFreight.FreightQueryOpenResp; |
|
|
|
|
|
|
|
import com.jd.open.api.sdk.response.vopdd.VopOrderQuerySkuFreightResponse; |
|
|
|
import org.apache.commons.collections4.MapUtils; |
|
|
|
import org.apache.commons.collections4.MapUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.apache.rocketmq.spring.core.RocketMQTemplate; |
|
|
|
import org.apache.rocketmq.spring.core.RocketMQTemplate; |
|
|
@ -91,7 +97,10 @@ public class BsOrderServiceImpl implements BsOrderService { |
|
|
|
private BsProductConfigService productConfigService; |
|
|
|
private BsProductConfigService productConfigService; |
|
|
|
@Resource |
|
|
|
@Resource |
|
|
|
private JdService jdService; |
|
|
|
private JdService jdService; |
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
private GoodsSpecsService goodsSpecsService; |
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
private GoodsUserAddressService goodsUserAddressService; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public BsOrder editData(BsOrder order) { |
|
|
|
public BsOrder editData(BsOrder order) { |
|
|
@ -129,11 +138,17 @@ public class BsOrderServiceImpl implements BsOrderService { |
|
|
|
order.setOrderNo(DateUtil.date2String(new Date(), "yyMMddHHmmss") + RandomUtils.number(6, false)); |
|
|
|
order.setOrderNo(DateUtil.date2String(new Date(), "yyMMddHHmmss") + RandomUtils.number(6, false)); |
|
|
|
editData(order); |
|
|
|
editData(order); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Long addressId = null; |
|
|
|
// 订单总金额
|
|
|
|
// 订单总金额
|
|
|
|
BigDecimal totalPrice = new BigDecimal("0"); |
|
|
|
BigDecimal totalPrice = new BigDecimal("0"); |
|
|
|
// 商品总金额
|
|
|
|
// 商品总金额
|
|
|
|
BigDecimal productTotalPrice = new BigDecimal("0"); |
|
|
|
BigDecimal productTotalPrice = new BigDecimal("0"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 创建京东产品物流
|
|
|
|
|
|
|
|
List<SkuInfoOrderOpenReq> skuInfoList = new ArrayList<>(); |
|
|
|
|
|
|
|
SkuInfoOrderOpenReq skuInfo = new SkuInfoOrderOpenReq(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/************** 处理业务 ***************/ |
|
|
|
/************** 处理业务 ***************/ |
|
|
|
for (OrderChildModel child : order.getOrderChildList()) { |
|
|
|
for (OrderChildModel child : order.getOrderChildList()) { |
|
|
|
child.setOrderNo(order.getOrderNo()); |
|
|
|
child.setOrderNo(order.getOrderNo()); |
|
|
@ -142,6 +157,14 @@ public class BsOrderServiceImpl implements BsOrderService { |
|
|
|
// 提交订单前实物商品处理
|
|
|
|
// 提交订单前实物商品处理
|
|
|
|
if (child.getProductType().equals(OrderChildProductTypeEnum.type1.getCode())) { |
|
|
|
if (child.getProductType().equals(OrderChildProductTypeEnum.type1.getCode())) { |
|
|
|
child = orderCreateService.goods(order, child); |
|
|
|
child = orderCreateService.goods(order, child); |
|
|
|
|
|
|
|
addressId = child.getAddressId(); |
|
|
|
|
|
|
|
// 查询规格
|
|
|
|
|
|
|
|
GoodsSpecs specs = goodsSpecsService.queryDetail(child.getProductSpecId()); |
|
|
|
|
|
|
|
if (specs.getThirdId() != null) { |
|
|
|
|
|
|
|
skuInfo.setSkuId(Long.parseLong(specs.getThirdId())); |
|
|
|
|
|
|
|
skuInfo.setSkuNum(child.getProductCount()); |
|
|
|
|
|
|
|
skuInfoList.add(skuInfo); |
|
|
|
|
|
|
|
} |
|
|
|
// todo 1.0阶段暂时需要返回收货地址使用
|
|
|
|
// todo 1.0阶段暂时需要返回收货地址使用
|
|
|
|
order.setBusiness(child.getBusiness()); |
|
|
|
order.setBusiness(child.getBusiness()); |
|
|
|
} else if (child.getProductType().equals(OrderChildProductTypeEnum.type2.getCode())) { |
|
|
|
} else if (child.getProductType().equals(OrderChildProductTypeEnum.type2.getCode())) { |
|
|
@ -223,6 +246,17 @@ public class BsOrderServiceImpl implements BsOrderService { |
|
|
|
order.setOrderStatus(order.getPayRealPrice().compareTo(new BigDecimal("0")) == 0?OrderStatusEnum.status2.getCode():OrderStatusEnum.status1.getCode()); |
|
|
|
order.setOrderStatus(order.getPayRealPrice().compareTo(new BigDecimal("0")) == 0?OrderStatusEnum.status2.getCode():OrderStatusEnum.status1.getCode()); |
|
|
|
BigDecimal totalChildDiscountPrice = new BigDecimal("0"); |
|
|
|
BigDecimal totalChildDiscountPrice = new BigDecimal("0"); |
|
|
|
Long totalIntegralDiscountPrice = 0L; |
|
|
|
Long totalIntegralDiscountPrice = 0L; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 计算运费
|
|
|
|
|
|
|
|
if (!skuInfoList.isEmpty()) { |
|
|
|
|
|
|
|
FreightQueryOpenResp resp = queryFreight(skuInfoList , addressId); |
|
|
|
|
|
|
|
if (resp != null ) { |
|
|
|
|
|
|
|
order.setFreightPrice(resp.getTotalFreight()); |
|
|
|
|
|
|
|
order.setPayRealPrice(order.getPayRealPrice().add(resp.getTotalFreight())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 订单入库前处理
|
|
|
|
// 订单入库前处理
|
|
|
|
for (int i = 0; i < order.getOrderChildList().size();i++) { |
|
|
|
for (int i = 0; i < order.getOrderChildList().size();i++) { |
|
|
|
OrderChildModel childOrder = order.getOrderChildList().get(i); |
|
|
|
OrderChildModel childOrder = order.getOrderChildList().get(i); |
|
|
@ -684,4 +718,19 @@ public class BsOrderServiceImpl implements BsOrderService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private FreightQueryOpenResp queryFreight(List<SkuInfoOrderOpenReq> skuInfoList , Long addressId) throws Exception { |
|
|
|
|
|
|
|
GoodsUserAddress userAddress = goodsUserAddressService.queryDetail(addressId); |
|
|
|
|
|
|
|
if (userAddress.getProvinceId() != null) { |
|
|
|
|
|
|
|
VopOrderQuerySkuFreightResponse freightResponse = JdPostService.querySkuFreight(jdService.getToken() , skuInfoList , userAddress.getProvinceId() ,userAddress.getCityId() , userAddress.getCountyId() , userAddress.getTownId()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (freightResponse != null && !freightResponse.getOpenRpcResult().getSuccess()) { |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return freightResponse.getOpenRpcResult().getResult(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|