|
@@ -110,6 +110,7 @@ import java.util.*;
|
|
|
import java.util.concurrent.*;
|
|
|
import java.util.concurrent.atomic.AtomicBoolean;
|
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
+import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
@@ -2141,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);
|
|
@@ -2198,32 +2246,17 @@ 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);
|
|
|
+
|
|
|
// 复制集合数据
|
|
|
ListUtils listUtils = BeanUtils.instantiate(ListUtils.class);
|
|
|
listUtils.copyList(goodsEntityList, queryGoodsVOList);
|
|
|
+
|
|
|
+ // 商品总重量
|
|
|
+ BigDecimal weight = new BigDecimal(0);
|
|
|
// 检查库存和更新库存
|
|
|
for (QueryGoodsVO goodsDto : queryGoodsVOList) {
|
|
|
// 要购买的数量
|
|
@@ -2316,6 +2349,17 @@ public class OrderServiceImpl implements OrderService {
|
|
|
goodsEntity.setSellVolume(goodsDto.getSellVolume());
|
|
|
goodsEntity.setActivity(goodsDto.getActivity());
|
|
|
goodsEntity.setStoreId(storeId);
|
|
|
+ goodsEntity.setListPicUrl(goodsDto.getListPicUrl());
|
|
|
+ GoodsEntity goodsEntity1 = goodsEntityMap.get(sku);
|
|
|
+ if (Objects.nonNull(goodsEntity1)) {
|
|
|
+ goodsEntity.setNetWeight(goodsEntity1.getNetWeight());
|
|
|
+ goodsEntity.setWarehouseSn(goodsEntity1.getWarehouseSn());
|
|
|
+ goodsEntity.setConsignorSn(goodsEntity1.getConsignorSn());
|
|
|
+ goodsEntity.setWarehousSysGoodId(goodsEntity1.getWarehousSysGoodId());
|
|
|
+ goodsEntity.setInventoryType(goodsEntity1.getInventoryType());
|
|
|
+ goodsEntity.setDefectiveProductsGrade(goodsEntity1.getDefectiveProductsGrade());
|
|
|
+ weight = weight.add(goodsEntity1.getNetWeight().multiply(new BigDecimal(goodsEntity.getSellVolume())));
|
|
|
+ }
|
|
|
goodsEntities.add(goodsEntity);
|
|
|
} else {
|
|
|
// sku不存在
|
|
@@ -2390,6 +2434,7 @@ public class OrderServiceImpl implements OrderService {
|
|
|
order.setMerchOrderSn(merchOrderSn);
|
|
|
order.setCoupon_name(couponSn); // 借用这个字段来记录是否使用优惠券
|
|
|
order.setIdCard(userEntity.getIdNo());
|
|
|
+ order.setWeight(weight);
|
|
|
//插入订单信息和订单商品
|
|
|
orderDao.saveOrderVo(order);
|
|
|
|
|
@@ -2734,6 +2779,11 @@ public class OrderServiceImpl implements OrderService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 组装推送订单数据:跨境数据
|
|
|
+ * @param order 订单数据
|
|
|
+ * @return 跨境数据
|
|
|
+ */
|
|
|
private SeaportInfoDTO wrapSeaportInfo(OrderVo order) {
|
|
|
SeaportInfoDTO seaportInfoDTO = new SeaportInfoDTO();
|
|
|
seaportInfoDTO.setSeaportCode("4600");
|
|
@@ -2744,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());
|
|
@@ -2754,11 +2809,16 @@ public class OrderServiceImpl implements OrderService {
|
|
|
return payInfoDTO;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 组装推送订单数据:订单详情数据
|
|
|
+ * @param orderGoodsVo 订单详情
|
|
|
+ * @return 订单详情数据
|
|
|
+ */
|
|
|
private OrderInfoItemDTO wrapOrderInfoItem(OrderGoodsVo orderGoodsVo) {
|
|
|
OrderInfoItemDTO orderInfoItemDTO = new OrderInfoItemDTO();
|
|
|
orderInfoItemDTO.setOrderId(orderGoodsVo.getOrderSn());
|
|
|
orderInfoItemDTO.setImageUrl(orderGoodsVo.getList_pic_url());
|
|
|
- orderInfoItemDTO.setBn("11111111");
|
|
|
+ orderInfoItemDTO.setBn(orderGoodsVo.getSku());
|
|
|
orderInfoItemDTO.setBarcode(orderGoodsVo.getBarcode());
|
|
|
orderInfoItemDTO.setName(orderGoodsVo.getGoods_name());
|
|
|
orderInfoItemDTO.setCost(orderGoodsVo.getMarket_price());
|
|
@@ -2771,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());
|
|
@@ -2785,7 +2850,12 @@ public class OrderServiceImpl implements OrderService {
|
|
|
orderInfoDTO.setConsigneeTel("0756-8800000");
|
|
|
orderInfoDTO.setConsigneeEmail("hk@greedc.com");
|
|
|
orderInfoDTO.setConsigneeMobile(order.getMobile());
|
|
|
- orderInfoDTO.setWeight("?");
|
|
|
+ BigDecimal weight = order.getWeight();
|
|
|
+ if (Objects.nonNull(weight)) {
|
|
|
+ orderInfoDTO.setWeight(weight.toString());
|
|
|
+ } else {
|
|
|
+ orderInfoDTO.setWeight("0");
|
|
|
+ }
|
|
|
orderInfoDTO.setQuantity(order.getNumber());
|
|
|
orderInfoDTO.setOrderTotal(order.getActual_price());
|
|
|
orderInfoDTO.setPlatform("store");
|
|
@@ -2800,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();
|
|
@@ -2843,6 +2916,7 @@ public class OrderServiceImpl implements OrderService {
|
|
|
// 组装支付单信息
|
|
|
Map<String, Object> orderSendCusParams = new HashMap<>();
|
|
|
orderSendCusParams.put("merchSn", order.getMerchSn());
|
|
|
+ orderSendCusParams.put("orderSn", order.getOrder_sn());
|
|
|
orderSendCusParams.put("merchName", order.getMerchName());
|
|
|
orderSendCusParams.put("thirdPartyMerchCode", store.getThirdPartyMerchCode());
|
|
|
orderSendCusParams.put("thirdPartyMerchName", store.getThirdPartyMerchName());
|
|
@@ -2925,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;
|
|
|
|
|
@@ -2971,6 +3048,7 @@ public class OrderServiceImpl implements OrderService {
|
|
|
// 组装支付单信息
|
|
|
Map<String, Object> orderSendCusParams = new HashMap<>();
|
|
|
orderSendCusParams.put("merchSn", order.getMerchSn());
|
|
|
+ orderSendCusParams.put("orderSn", order.getOrder_sn());
|
|
|
orderSendCusParams.put("merchName", order.getMerchName());
|
|
|
orderSendCusParams.put("thirdPartyMerchCode", store.getThirdPartyMerchCode());
|
|
|
orderSendCusParams.put("thirdPartyMerchName", store.getThirdPartyMerchName());
|
|
@@ -4842,6 +4920,12 @@ public class OrderServiceImpl implements OrderService {
|
|
|
orderGoodsVo.setGoodsRate(goodsDto.getGoodsRate());
|
|
|
orderGoodsVo.setSku(goodsDto.getSku());
|
|
|
|
|
|
+ orderGoodsVo.setNetWeight(goodsDto.getNetWeight());
|
|
|
+ orderGoodsVo.setWarehouseSn(goodsDto.getWarehouseSn());
|
|
|
+ orderGoodsVo.setConsignorSn(goodsDto.getConsignorSn());
|
|
|
+ orderGoodsVo.setWarehouseSysGoodId(goodsDto.getWarehousSysGoodId());
|
|
|
+ orderGoodsVo.setInventoryType(goodsDto.getInventoryType());
|
|
|
+ orderGoodsVo.setDefectiveProductsGrade(goodsDto.getDefectiveProductsGrade());
|
|
|
|
|
|
BigDecimal number = new BigDecimal(Long.valueOf(goodsDto.getSellVolume()));
|
|
|
BigDecimal goodsTotal = goodsDto.getRetailPrice().multiply(number);//单商品总价
|
|
@@ -4873,7 +4957,6 @@ public class OrderServiceImpl implements OrderService {
|
|
|
orderGoodsVo.setSettlePrice(settlePrice);//商品结算平摊价格
|
|
|
}
|
|
|
|
|
|
-
|
|
|
// 计算税费
|
|
|
GoodsEntity goodsEntity = goodsService.queryObject(goodsDto.getId().intValue());
|
|
|
BigDecimal goodsTax = CalculateTax.calculateFinalTax(goodsEntity, goodsDto.getStoreRetailPrice(), goodsService).setScale(3, RoundingMode.HALF_UP);
|
|
@@ -4883,4 +4966,15 @@ public class OrderServiceImpl implements OrderService {
|
|
|
return orderGoodsVo;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 支付单凭证回传更新 buyer_pay_check
|
|
|
+ *
|
|
|
+ * @param wxMap 更新数据
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public int updateBuyerPayCheck(Map<String, Object> wxMap) {
|
|
|
+ return orderDao.updateBuyerPayCheck(wxMap);
|
|
|
+ }
|
|
|
}
|