|
@@ -565,71 +565,6 @@ public class OrderSubmitServiceImpl implements OrderSubmitService {
|
|
|
return ResponseJson.success(info);
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public ResponseJson<Map<String, Object>> orderPostage(String productIds, Double totalPrice, Integer townId, Integer userId) {
|
|
|
- List<String> productIdList = new ArrayList<>();
|
|
|
- if (productIds.contains(",")) {
|
|
|
- productIdList = Arrays.asList(productIds.split(","));
|
|
|
- } else {
|
|
|
- productIdList.add(productIds);
|
|
|
- }
|
|
|
- if (productIdList.size() == 0 || null == totalPrice || null == townId || null == userId) {
|
|
|
- return ResponseJson.error("参数错误", null);
|
|
|
- }
|
|
|
- log.info("<<<<<<<<<<<<<<<<<<<<<<<<计算运费>>>>>>>>>>>>>>>>>>>>>>>>");
|
|
|
- // 默认运费到付
|
|
|
- Map<String, Object> postageFeeMap = new HashMap<>(2);
|
|
|
- postageFeeMap.put("freePostFlag", -1);
|
|
|
- postageFeeMap.put("freight", 0);
|
|
|
- //商品是否全部设置为包邮
|
|
|
- boolean isFreeShipping = true;
|
|
|
- // 是否包含仪器(1001:轻光电,1002:重光电)
|
|
|
- for (String s : productIdList) {
|
|
|
- if ("".equals(s) || "undefined".equals(s) || null == s) {
|
|
|
- return ResponseJson.error("参数错误", null);
|
|
|
- }
|
|
|
- ProductPo product = orderSubmitMapper.findProductById(Integer.parseInt(s));
|
|
|
- //商品是否设置到付
|
|
|
- boolean isToPay = product.getFreePostFlag() != null && "1".equals(product.getFreePostFlag());
|
|
|
- if ("2".equals(product.getCommodityType()) || isToPay) {
|
|
|
- // 仪器运费到付
|
|
|
- postageFeeMap.put("freePostFlag", -1);
|
|
|
- postageFeeMap.put("freight", 0);
|
|
|
- log.info("<<<<<<<<<<<<<<<<<<<<<<<<运费到付");
|
|
|
- return ResponseJson.success("运费到付", postageFeeMap);
|
|
|
- }
|
|
|
- //商品是否全部设置为包邮
|
|
|
- if (StringUtils.isBlank(product.getFreePostFlag()) || "2".equals(product.getFreePostFlag())) {
|
|
|
- isFreeShipping = false;
|
|
|
- }
|
|
|
- }
|
|
|
- // 是否首单(订单数)
|
|
|
- Integer count = orderSubmitMapper.countUserOrder(userId);
|
|
|
- if (Integer.valueOf(0).equals(count) || isFreeShipping) {
|
|
|
- postageFeeMap.put("freePostFlag", 0);
|
|
|
- postageFeeMap.put("freight", 0);
|
|
|
- // 除含有仪器类外 首单,全国包邮
|
|
|
- log.info("<<<<<<<<<<<<<<<<<<<<<<<<包邮");
|
|
|
- return ResponseJson.success("包邮", postageFeeMap);
|
|
|
- }
|
|
|
- // 总运费计算
|
|
|
- CityVo city = orderSubmitMapper.findCityByTownId(townId);
|
|
|
- Double totalPostageFee = computedPostageFee(city.getProvinceId(), city.getCityId());
|
|
|
- if (totalPostageFee == 0d) {
|
|
|
- postageFeeMap.put("freePostFlag", 0);
|
|
|
- postageFeeMap.put("freight", 0);
|
|
|
- log.info("<<<<<<<<<<<<<<<<<<<<<<<<包邮");
|
|
|
- return ResponseJson.success("包邮", postageFeeMap);
|
|
|
- } else if (totalPostageFee != -1d) {
|
|
|
- postageFeeMap.put("freePostFlag", 1);
|
|
|
- postageFeeMap.put("freight", totalPostageFee);
|
|
|
- log.info("<<<<<<<<<<<<<<<<<<<<<<<<运费金额:" + totalPostageFee);
|
|
|
- return ResponseJson.success("运费金额", postageFeeMap);
|
|
|
- }
|
|
|
- log.info("<<<<<<<<<<<<<<<<<<<<<<<<运费到付");
|
|
|
- return ResponseJson.success("运费到付", postageFeeMap);
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 设置订单发票
|
|
|
*
|