|
@@ -2142,33 +2142,80 @@ public class OrderServiceImpl implements OrderService {
|
|
|
// e.printStackTrace();
|
|
|
LOGGER.error("decode machine code failed! error message : ", e);
|
|
|
}
|
|
|
+ Integer storeId = user.getStoreId();
|
|
|
+ // 根据商品条码、sku、门店id查询相对应的商品信息,并组装成对象
|
|
|
+ List<QueryGoodsVO> queryGoodsVOList = new ArrayList<>();
|
|
|
+ Map<String, GoodsEntity> goodsEntityMap;
|
|
|
+ List<GoodsEntity> goodsEntityList;
|
|
|
+ try {
|
|
|
+ goodsList.forEach(map -> {
|
|
|
+ QueryGoodsVO queryGoodsVo = new QueryGoodsVO();
|
|
|
+ queryGoodsVo.setProdBarcode((String) map.get("prodBarcode"));
|
|
|
+ queryGoodsVo.setSku((String) map.get("goodsSn"));
|
|
|
+ queryGoodsVo.setStoreId(storeId.longValue());
|
|
|
+ queryGoodsVo.setSellVolume((Integer) map.get("sellVolume"));
|
|
|
+ queryGoodsVo.setRetailPrice(new BigDecimal(String.valueOf(map.get("retailPrice"))));
|
|
|
+ queryGoodsVo.setGoodsTaxes(new BigDecimal(String.valueOf(map.get("goodstaxes"))));
|
|
|
+ queryGoodsVo.setDisCountedPrice(new BigDecimal(String.valueOf(map.get("discountedPrice"))));
|
|
|
+ queryGoodsVo.setTotalPrice(new BigDecimal(String.valueOf(map.get("actualPaymentAmount"))));
|
|
|
+ queryGoodsVo.setActivity((String) map.get("activity"));
|
|
|
+ queryGoodsVo.setDeductionScore((Integer) map.get("deductionScore"));
|
|
|
+ queryGoodsVOList.add(queryGoodsVo);
|
|
|
+ });
|
|
|
+ // 将在循环中查询数据库改为一次性查询
|
|
|
+ goodsEntityList = goodsService.queryGoodsStockByQueryGoodsVoList(queryGoodsVOList);
|
|
|
+ goodsEntityMap = goodsEntityList.stream().collect(Collectors.toMap(GoodsEntity::getSku, Function.identity(), (k1, k2) -> k2));
|
|
|
+ } catch (Exception e){
|
|
|
+ LOGGER.error("组装查询商品数据或查询商品数据时出现异常!", e);
|
|
|
+ throw new ServiceException(e);
|
|
|
+ }
|
|
|
|
|
|
Map resultObj = Maps.newHashMap();
|
|
|
// 海控需求,下单流程修改,收银端接收会员码,付款码,用户信息,订单数据
|
|
|
// 1. 校验库存:保税仓库存 + 展销店库存 - 出区数 >= 购买数
|
|
|
// TODO 获取保税仓库存,测试时注释
|
|
|
-// String queryWarehouseStockResponse = haiKongWarehouseTemplate.queryWarehouseStock(null);
|
|
|
-// if (org.springframework.util.StringUtils.isEmpty(queryWarehouseStockResponse)) {
|
|
|
-// LOGGER.error("调用库存系统接口出现错误!返回结果为空!");
|
|
|
-// throw new ServiceException("调用库存系统接口出现错误!");
|
|
|
-// }
|
|
|
-// WareQueryStockResponseDTO wareQueryStockResponseDTO = JacksonUtil.fromStringJson(queryWarehouseStockResponse, WareQueryStockResponseDTO.class);
|
|
|
-// if (Objects.isNull(wareQueryStockResponseDTO)) {
|
|
|
-// throw new ServiceException("解析一步达库存系统响应数据出现错误!");
|
|
|
-// }
|
|
|
-// List<WareQueryStockResponseDTO.WareQueryStockResponseItemDTO> items = wareQueryStockResponseDTO.getItems();
|
|
|
-// // 解析xml,组装成map key=>sku value=>库存
|
|
|
-// Map<String, Integer> stockMap = new HashMap<>(16);
|
|
|
-// items.forEach(item -> {
|
|
|
-// String itemCode = item.getItemCode();
|
|
|
-// Integer quantity = item.getQuantity();
|
|
|
-// if (stockMap.containsKey(itemCode)) {
|
|
|
-// // 避免出现sku相同情况
|
|
|
-// stockMap.put(itemCode, stockMap.get(itemCode) + quantity);
|
|
|
-// } else {
|
|
|
-// stockMap.put(itemCode, quantity);
|
|
|
-// }
|
|
|
-// });
|
|
|
+ /*WareQueryStockParamDTO wareQueryStockParamDTO = new WareQueryStockParamDTO();
|
|
|
+ List<Criteria> criteriaList = new ArrayList<>();
|
|
|
+ goodsList.forEach(goods -> {
|
|
|
+ Criteria criteria = new Criteria();
|
|
|
+ String sku = (String) goods.get("goodsSn");
|
|
|
+ criteria.setItemCode(sku);
|
|
|
+ GoodsEntity goodsEntity = goodsEntityMap.get(sku);
|
|
|
+ criteria.setItemId(goodsEntity.getWarehousSysGoodId());
|
|
|
+ criteria.setWarehouseCode(goodsEntity.getWarehouseSn());
|
|
|
+ criteria.setOwnerCode(goodsEntity.getConsignorSn());
|
|
|
+ criteria.setInventoryType(Constants.InventoryType.ZP.getType());
|
|
|
+ criteriaList.add(criteria);
|
|
|
+ });
|
|
|
+ wareQueryStockParamDTO.setCriteriaList(criteriaList);
|
|
|
+ String queryWarehouseStockResponse = null;
|
|
|
+ try {
|
|
|
+ queryWarehouseStockResponse = haiKongWarehouseTemplate.queryWarehouseStock(wareQueryStockParamDTO);
|
|
|
+ } catch (Exception e) {
|
|
|
+ LOGGER.error("下单调用海控仓库系统查询库存出现异常!", e);
|
|
|
+ throw new ServiceException(String.format("下单调用海控仓库系统查询库存出现异常!"));
|
|
|
+ }
|
|
|
+ if (org.springframework.util.StringUtils.isEmpty(queryWarehouseStockResponse)) {
|
|
|
+ LOGGER.error("调用库存系统接口出现错误!返回结果为空!");
|
|
|
+ throw new ServiceException("调用库存系统接口出现错误!");
|
|
|
+ }
|
|
|
+ WareQueryStockResponseDTO wareQueryStockResponseDTO = JacksonUtil.fromStringJson(queryWarehouseStockResponse, WareQueryStockResponseDTO.class);
|
|
|
+ if (Objects.isNull(wareQueryStockResponseDTO)) {
|
|
|
+ throw new ServiceException("解析一步达库存系统响应数据出现错误!");
|
|
|
+ }
|
|
|
+ List<WareQueryStockResponseDTO.WareQueryStockResponseItemDTO> items = wareQueryStockResponseDTO.getItems();
|
|
|
+ // 解析xml,组装成map key=>sku value=>库存
|
|
|
+ Map<String, Integer> stockMap = new HashMap<>(16);
|
|
|
+ items.forEach(item -> {
|
|
|
+ String itemCode = item.getItemCode();
|
|
|
+ Integer quantity = item.getQuantity();
|
|
|
+ if (stockMap.containsKey(itemCode)) {
|
|
|
+ // 避免出现sku相同情况
|
|
|
+ stockMap.put(itemCode, stockMap.get(itemCode) + quantity);
|
|
|
+ } else {
|
|
|
+ stockMap.put(itemCode, quantity);
|
|
|
+ }
|
|
|
+ });*/
|
|
|
|
|
|
// TODO 上生产时注释,模拟仓库系统(sku最大库存为3)返回
|
|
|
Map<String, Integer> stockMap = new HashMap<>(16);
|
|
@@ -2199,30 +2246,11 @@ public class OrderServiceImpl implements OrderService {
|
|
|
return resultObj;
|
|
|
}
|
|
|
Long userId = user.getUserId();
|
|
|
- Integer storeId = user.getStoreId();
|
|
|
|
|
|
List<GoodsEntity> goodsEntities = new ArrayList<>();
|
|
|
|
|
|
BigDecimal totalTax = new BigDecimal(0);
|
|
|
- // 根据商品条码、sku、门店id查询相对应的商品信息,并组装成对象
|
|
|
- List<QueryGoodsVO> queryGoodsVOList = new ArrayList<>();
|
|
|
- goodsList.forEach(map -> {
|
|
|
- QueryGoodsVO queryGoodsVo = new QueryGoodsVO();
|
|
|
- queryGoodsVo.setProdBarcode((String) map.get("prodBarcode"));
|
|
|
- queryGoodsVo.setSku((String) map.get("goodsSn"));
|
|
|
- queryGoodsVo.setStoreId(storeId.longValue());
|
|
|
- queryGoodsVo.setSellVolume((Integer) map.get("sellVolume"));
|
|
|
- queryGoodsVo.setRetailPrice(new BigDecimal(String.valueOf(map.get("retailPrice"))));
|
|
|
- queryGoodsVo.setGoodsTaxes(new BigDecimal(String.valueOf(map.get("goodstaxes"))));
|
|
|
- queryGoodsVo.setDisCountedPrice(new BigDecimal(String.valueOf(map.get("discountedPrice"))));
|
|
|
- queryGoodsVo.setTotalPrice(new BigDecimal(String.valueOf(map.get("actualPaymentAmount"))));
|
|
|
- queryGoodsVo.setActivity((String) map.get("activity"));
|
|
|
- queryGoodsVo.setDeductionScore((Integer) map.get("deductionScore"));
|
|
|
- queryGoodsVOList.add(queryGoodsVo);
|
|
|
- });
|
|
|
- // 将在循环中查询数据库改为一次性查询
|
|
|
- List<GoodsEntity> goodsEntityList = goodsService.queryGoodsStockByQueryGoodsVoList(queryGoodsVOList);
|
|
|
- Map<String, GoodsEntity> goodsEntityMap = goodsEntityList.stream().collect(Collectors.toMap(GoodsEntity::getSku, Function.identity(), (k1, k2) -> k2));
|
|
|
+
|
|
|
// 复制集合数据
|
|
|
ListUtils listUtils = BeanUtils.instantiate(ListUtils.class);
|
|
|
listUtils.copyList(goodsEntityList, queryGoodsVOList);
|
|
@@ -2751,6 +2779,11 @@ public class OrderServiceImpl implements OrderService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 组装推送订单数据:跨境数据
|
|
|
+ * @param order 订单数据
|
|
|
+ * @return 跨境数据
|
|
|
+ */
|
|
|
private SeaportInfoDTO wrapSeaportInfo(OrderVo order) {
|
|
|
SeaportInfoDTO seaportInfoDTO = new SeaportInfoDTO();
|
|
|
seaportInfoDTO.setSeaportCode("4600");
|
|
@@ -2761,6 +2794,11 @@ public class OrderServiceImpl implements OrderService {
|
|
|
return seaportInfoDTO;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 组装推送订单数据:支付数据
|
|
|
+ * @param order 订单数据
|
|
|
+ * @return 支付数据
|
|
|
+ */
|
|
|
private PayInfoDTO wrapPayInfo(OrderVo order) {
|
|
|
PayInfoDTO payInfoDTO = new PayInfoDTO();
|
|
|
payInfoDTO.setMoney(order.getActual_price());
|
|
@@ -2771,6 +2809,11 @@ public class OrderServiceImpl implements OrderService {
|
|
|
return payInfoDTO;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 组装推送订单数据:订单详情数据
|
|
|
+ * @param orderGoodsVo 订单详情
|
|
|
+ * @return 订单详情数据
|
|
|
+ */
|
|
|
private OrderInfoItemDTO wrapOrderInfoItem(OrderGoodsVo orderGoodsVo) {
|
|
|
OrderInfoItemDTO orderInfoItemDTO = new OrderInfoItemDTO();
|
|
|
orderInfoItemDTO.setOrderId(orderGoodsVo.getOrderSn());
|
|
@@ -2788,6 +2831,11 @@ public class OrderServiceImpl implements OrderService {
|
|
|
return orderInfoItemDTO;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 组装推送订单数据:跨境数据
|
|
|
+ * @param order 订单数据
|
|
|
+ * @return 订单数据
|
|
|
+ */
|
|
|
private OrderInfoDTO wrapOrderInfo(OrderVo order) {
|
|
|
OrderInfoDTO orderInfoDTO = new OrderInfoDTO();
|
|
|
orderInfoDTO.setOuterOrderNo(order.getOrder_sn());
|
|
@@ -2822,6 +2870,9 @@ public class OrderServiceImpl implements OrderService {
|
|
|
return orderProductInfoDTO;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 支付宝支付
|
|
|
+ */
|
|
|
private void AliPay(SysUserEntity user, String parCode, OrderVo order, OrderProcessRecordEntity processRecordEntity, OrderWXPayRecordEntity orderWXPayRecordCurrent, StoreEntity store) throws Exception {
|
|
|
|
|
|
AliPayRequestParams params = new AliPayRequestParams();
|
|
@@ -2948,6 +2999,9 @@ public class OrderServiceImpl implements OrderService {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 微信支付
|
|
|
+ */
|
|
|
private void wxPay(SysUserEntity user, String parCode, Map resultObj, OrderVo order, OrderProcessRecordEntity processRecordEntity, OrderWXPayRecordEntity orderWXPayRecordCurrent, StoreEntity store) throws ParseException {
|
|
|
R r;
|
|
|
|