Commit 48c1b9215d11aec2f31eae0856518c3e196ad765

Authored by fengliang
1 parent 0a1ce7c8

update:运费配置,购物车商品异常显示

etrade-core/src/main/java/com/diligrp/etrade/core/util/MoneyUtil.java
... ... @@ -108,7 +108,7 @@ public class MoneyUtil {
108 108 */
109 109 public static Long getAmountByWeight(Long unitAmount, Long weight) {
110 110 if (unitAmount != null && weight != null) {
111   - return Math.round(unitAmount * weight / 500.0);
  111 + return Math.round(unitAmount * weight / 100.0);
112 112 }
113 113 return 0L;
114 114 }
... ...
etrade-order/src/main/java/com/diligrp/etrade/order/api/OrderController.java
... ... @@ -15,8 +15,12 @@ import com.diligrp.etrade.order.type.OrderOrderType;
15 15 import com.diligrp.etrade.order.type.OrderState;
16 16 import com.diligrp.etrade.order.util.OrderConstant;
17 17 import com.diligrp.etrade.order.util.ParameterDetection;
  18 +import com.diligrp.etrade.rpc.basicdata.BasicDataConfigRpc;
18 19 import com.diligrp.etrade.rpc.dto.WeChatPayFunctionDto;
19 20 import com.diligrp.etrade.rpc.dto.WeChatPayTradeCallBackDto;
  21 +import com.diligrp.etrade.rpc.dto.request.ConfigQueryDto;
  22 +import com.diligrp.etrade.rpc.dto.response.BaseOutput;
  23 +import com.diligrp.etrade.rpc.dto.response.ConfigDto;
20 24 import com.diligrp.etrade.shared.domain.OrderQrCode;
21 25 import com.xxl.job.core.handler.annotation.XxlJob;
22 26 import jakarta.annotation.Resource;
... ... @@ -53,6 +57,9 @@ public class OrderController {
53 57 @Resource
54 58 private RedissonClient redissonClient;
55 59  
  60 + @Resource
  61 + private BasicDataConfigRpc basicDataConfigRpc;
  62 +
56 63 /**
57 64 * 买家创建订单
58 65 * @return
... ... @@ -774,4 +781,38 @@ public class OrderController {
774 781 }
775 782 }
776 783  
  784 + /**
  785 + * 获取市场运费
  786 + * @param order
  787 + * @return
  788 + */
  789 + @RequestMapping(value = "/getTransportFee",method = {RequestMethod.POST},produces="application/json;charset=UTF-8")
  790 + public Message<TransportFeeDto> getTransportFee(@RequestBody OrderDto order){
  791 + try{
  792 + if(order.getMarketId()==null){
  793 + return Message.failure(OrderErrorCode.PARAM_ERROR,"市场不能为空");
  794 + }
  795 + ConfigQueryDto query = new ConfigQueryDto();
  796 + query.setName("甄选运费");
  797 + query.setMarketId(order.getMarketId());
  798 + BaseOutput<List<ConfigDto>> listBaseOutput = basicDataConfigRpc.queryAll(query);
  799 + if("200".equals(listBaseOutput.getCode())){
  800 + List<ConfigDto> configDtos = listBaseOutput.getData();
  801 + if(configDtos!=null&&configDtos.size()>0) {
  802 + ConfigDto configDto = configDtos.get(0);
  803 + TransportFeeDto transportFeeDto = new TransportFeeDto();
  804 + long l = Long.parseLong(configDto.getValue());
  805 + transportFeeDto.setTransportFee(l);
  806 + return Message.success(transportFeeDto);
  807 + }
  808 + }
  809 + return Message.success(new TransportFeeDto());
  810 + }catch (PlatformServiceException pe) {
  811 + LOGGER.warn("服务异常{}:{}",pe.getCode(), pe.getMessage());
  812 + return Message.failure("服务暂时不在线,请稍后");
  813 + }
  814 + }
  815 +
  816 +
  817 +
777 818 }
... ...
etrade-order/src/main/java/com/diligrp/etrade/order/domain/ShopCartMessageVo.java
... ... @@ -158,11 +158,20 @@ public class ShopCartMessageVo implements Serializable {
158 158 * 商品别名
159 159 */
160 160 private String alias;
  161 + /**
  162 + * 商品包装单位
  163 + */
  164 + private Integer saleUnit;
161 165  
162 166 public String getAlias() {
163 167 return alias;
164 168 }
165 169  
  170 + /**
  171 + * 商品状态
  172 + */
  173 + private Integer productState;
  174 +
166 175 public void setAlias(String alias) {
167 176 this.alias = alias;
168 177 }
... ... @@ -333,4 +342,20 @@ public class ShopCartMessageVo implements Serializable {
333 342 public void setCreaterId(Long createrId) {
334 343 this.createrId = createrId;
335 344 }
  345 +
  346 + public Integer getSaleUnit() {
  347 + return saleUnit;
  348 + }
  349 +
  350 + public void setSaleUnit(Integer saleUnit) {
  351 + this.saleUnit = saleUnit;
  352 + }
  353 +
  354 + public Integer getProductState() {
  355 + return productState;
  356 + }
  357 +
  358 + public void setProductState(Integer productState) {
  359 + this.productState = productState;
  360 + }
336 361 }
... ...
etrade-order/src/main/java/com/diligrp/etrade/order/domain/TransportFeeDto.java 0 → 100644
  1 +package com.diligrp.etrade.order.domain;
  2 +
  3 +public class TransportFeeDto {
  4 + private Long transportFee = 0l;
  5 +
  6 + public Long getTransportFee() {
  7 + return transportFee;
  8 + }
  9 +
  10 + public void setTransportFee(Long transportFee) {
  11 + this.transportFee = transportFee;
  12 + }
  13 +}
... ...
etrade-order/src/main/java/com/diligrp/etrade/order/service/impl/OrderGoodsServiceImpl.java
... ... @@ -3,10 +3,7 @@ package com.diligrp.etrade.order.service.impl;
3 3 import com.diligrp.etrade.core.domain.Message;
4 4 import com.diligrp.etrade.core.util.JsonUtils;
5 5 import com.diligrp.etrade.order.dao.OrderGoodsMapper;
6   -import com.diligrp.etrade.order.domain.OrderCreateDto;
7   -import com.diligrp.etrade.order.domain.ProductCheckDto;
8   -import com.diligrp.etrade.order.domain.ProductDto;
9   -import com.diligrp.etrade.order.domain.ProductExtDto;
  6 +import com.diligrp.etrade.order.domain.*;
10 7 import com.diligrp.etrade.order.exception.OrderErrorCode;
11 8 import com.diligrp.etrade.order.exception.OrderException;
12 9 import com.diligrp.etrade.order.model.Order;
... ... @@ -16,6 +13,10 @@ import com.diligrp.etrade.order.type.*;
16 13 import com.diligrp.etrade.order.util.GenericRpcResolver;
17 14 import com.diligrp.etrade.order.util.NumberTransform;
18 15 import com.diligrp.etrade.rpc.CustomerRpc;
  16 +import com.diligrp.etrade.rpc.basicdata.BasicDataConfigRpc;
  17 +import com.diligrp.etrade.rpc.dto.request.ConfigQueryDto;
  18 +import com.diligrp.etrade.rpc.dto.response.BaseOutput;
  19 +import com.diligrp.etrade.rpc.dto.response.ConfigDto;
19 20 import com.diligrp.etrade.rpc.dto.response.CustomerMarket;
20 21 import com.diligrp.etrade.rpc.type.CustomerState;
21 22 import com.diligrp.etrade.shop.domain.request.ShopCo;
... ... @@ -59,6 +60,8 @@ public class OrderGoodsServiceImpl implements OrderGoodsService {
59 60  
60 61 @Resource
61 62 private CustomerRpc customerRpc;
  63 + @Resource
  64 + private BasicDataConfigRpc basicDataConfigRpc;
62 65  
63 66 @Override
64 67 public List<OrderGoods> buildOrderGoods(Order order, List<ProductDto> productDtoList) {
... ... @@ -185,8 +188,24 @@ public class OrderGoodsServiceImpl implements OrderGoodsService {
185 188 waitCouponAmount = waitCouponAmount.subtract(couponAmount);
186 189 }
187 190 }
188   - //TODO 配送情况增加计算运费
  191 + //配送情况增加计算运费
189 192 if(buyerOrderDto.getAchieveType().equals(OrderAchieveType.SELLER_DELIVERY.getCodeInteger())){
  193 + ConfigQueryDto query = new ConfigQueryDto();
  194 + query.setName("甄选运费");
  195 + query.setMarketId(buyerOrderDto.getMarketId());
  196 + BaseOutput<List<ConfigDto>> listBaseOutput = basicDataConfigRpc.queryAll(query);
  197 + Long transportFee = buyerOrderDto.getTransportFee().longValue()*100;
  198 + Long transportFeeConfig = 0L;
  199 + if("200".equals(listBaseOutput.getCode())){
  200 + List<ConfigDto> configDtos = listBaseOutput.getData();
  201 + if(configDtos!=null&&configDtos.size()>0) {
  202 + ConfigDto configDto = configDtos.get(0);
  203 + transportFeeConfig = Long.parseLong(configDto.getValue());
  204 + }
  205 + }
  206 + if(!transportFee.equals(transportFeeConfig)){
  207 + throw new OrderException(OrderErrorCode.PARAM_ERROR,"运费与设置不一致,请刷新后重试");
  208 + }
190 209 allmount.add(buyerOrderDto.getTransportFee());
191 210 }
192 211 //效验库存
... ...
etrade-order/src/main/java/com/diligrp/etrade/order/service/impl/ShopCartImpl.java
... ... @@ -15,6 +15,7 @@ import com.diligrp.etrade.order.model.ShopCartMessage;
15 15 import com.diligrp.etrade.order.service.IShopCartMessageService;
16 16 import com.diligrp.etrade.order.service.IShopCartService;
17 17 import com.diligrp.etrade.order.type.ProductTradeType;
  18 +import com.diligrp.etrade.order.type.ShopCartMessageProductState;
18 19 import com.diligrp.etrade.shop.domain.response.ProductListVo;
19 20 import com.diligrp.etrade.shop.domain.response.ProductPresetVo;
20 21 import com.diligrp.etrade.shop.domain.response.ShopVo;
... ... @@ -130,6 +131,13 @@ public class ShopCartImpl implements IShopCartService {
130 131 ProductPresetVo productPresetVo = map.get(SaleUnitType.PIECE.getCode());
131 132 // AssertUtils.notNull(productPresetVo,
132 133 // "未找到商品按件卖的预售价格,productId:"+shopCartMessageVo.getProductId()+"SaleUnitType:"+SaleUnitType.PIECE.getCode());
  134 + if(productPresetVo == null){
  135 + shopCartMessageVo.setPrePrice(0L);
  136 + shopCartMessageVo.setPieceWeight(0L);
  137 + shopCartMessageVo.setProductState(ShopCartMessageProductState.TYPE_CHANGE.getCodeInteger());
  138 + }
  139 + //商品包装单位
  140 + shopCartMessageVo.setSaleUnit(productPresetVo.getSaleUnit());
133 141 //预设价格分
134 142 shopCartMessageVo.setPrePrice(productPresetVo.getPrePrice() == null ? 0L : productPresetVo.getPrePrice());
135 143 //预设件重克
... ... @@ -140,6 +148,13 @@ public class ShopCartImpl implements IShopCartService {
140 148 // AssertUtils.notNull(productPresetVo,
141 149 // "未找到商品按斤卖的预售价格,productId:"+shopCartMessageVo.getProductId()+"SaleUnitType:"+SaleUnitType.CATTY.getCode());
142 150 //预设价格分
  151 + if(productPresetVo == null){
  152 + shopCartMessageVo.setPrePrice(0L);
  153 + shopCartMessageVo.setProductState(ShopCartMessageProductState.TYPE_CHANGE.getCodeInteger());
  154 + }
  155 + //商品包装单位
  156 + shopCartMessageVo.setSaleUnit(productPresetVo.getSaleUnit());
  157 +
143 158 shopCartMessageVo.setPrePrice(productPresetVo.getPrePrice() == null ? 0L : productPresetVo.getPrePrice());
144 159 }
145 160 }
... ...
etrade-order/src/main/java/com/diligrp/etrade/order/type/ShopCartMessageProductState.java 0 → 100644
  1 +package com.diligrp.etrade.order.type;
  2 +
  3 +import com.diligrp.etrade.core.type.IEnumType;
  4 +
  5 +public enum ShopCartMessageProductState implements IEnumType {
  6 + NORMAL("正常", 1),
  7 + UNIT_CHANGE("单位变更", 2),
  8 + TYPE_CHANGE("类型变更", 3),
  9 + NONE("商品不存在", 4);
  10 +
  11 + private String name;
  12 + private Integer code;
  13 +
  14 + private ShopCartMessageProductState(String name, Integer code) {
  15 + this.name = name;
  16 + this.code = code;
  17 + }
  18 +
  19 + public static ShopCartMessageProductState getByCode(Integer code) {
  20 + for (ShopCartMessageProductState temp : ShopCartMessageProductState.values()) {
  21 + if (temp.getCodeInteger().equals(code)) {
  22 + return temp;
  23 + }
  24 + }
  25 + return null;
  26 + }
  27 +
  28 + public static String getNameByCode(Integer code) {
  29 + for (ShopCartMessageProductState temp : ShopCartMessageProductState.values()) {
  30 + if (temp.getCodeInteger().equals(code)) {
  31 + return temp.getName();
  32 + }
  33 + }
  34 + return null;
  35 + }
  36 +
  37 + public Integer getCodeInteger() {
  38 + return this.code;
  39 + }
  40 +
  41 + public String getName() {
  42 + return this.name;
  43 + }
  44 +
  45 + public int getCode() {
  46 + return this.code;
  47 + }
  48 +
  49 + public String toString() {
  50 + return this.name;
  51 + }
  52 +}
0 53 \ No newline at end of file
... ...
etrade-rpc/src/main/java/com/diligrp/etrade/rpc/basicdata/BasicDataConfigRpc.java 0 → 100644
  1 +package com.diligrp.etrade.rpc.basicdata;
  2 +
  3 +import com.diligrp.etrade.core.authority.SessionContext;
  4 +import com.diligrp.etrade.core.domain.Message;
  5 +import com.diligrp.etrade.rpc.dto.request.ConfigQueryDto;
  6 +import com.diligrp.etrade.rpc.dto.request.CusCategoryQuery;
  7 +import com.diligrp.etrade.rpc.dto.response.BaseOutput;
  8 +import com.diligrp.etrade.rpc.dto.response.ConfigDto;
  9 +import com.diligrp.etrade.rpc.dto.response.CusCategoryDTO;
  10 +import org.springframework.cloud.openfeign.FeignClient;
  11 +import org.springframework.web.bind.annotation.PostMapping;
  12 +
  13 +import java.util.ArrayList;
  14 +import java.util.List;
  15 +import java.util.Objects;
  16 +
  17 +/**
  18 + * @author dengwei
  19 + * @version 1.0.0
  20 + * @ClassName CategoryRpc.java
  21 + * @Description 品类RPC
  22 + * @date 2023-08-29 17:34
  23 + */
  24 +@FeignClient(name = "assets-service",
  25 + contextId = "bdconfig",
  26 + url = "${AssetsRpc.url:}")
  27 +public interface BasicDataConfigRpc {
  28 +
  29 + /**
  30 + * 获取基础数据配置信息
  31 + */
  32 + @PostMapping({"/api/config/queryAll"})
  33 + BaseOutput<List<ConfigDto>> queryAll(ConfigQueryDto query);
  34 +}
... ...
etrade-rpc/src/main/java/com/diligrp/etrade/rpc/dto/request/ConfigQueryDto.java 0 → 100644
  1 +package com.diligrp.etrade.rpc.dto.request;
  2 +
  3 +import java.util.List;
  4 +
  5 +public class ConfigQueryDto {
  6 + private Long marketId;
  7 + private String name;
  8 + private String type;
  9 + private Integer state;
  10 + private List<Long> marketIds;
  11 + private String keyword;
  12 + private String value;
  13 +
  14 + public Long getMarketId() {
  15 + return marketId;
  16 + }
  17 +
  18 + public void setMarketId(Long marketId) {
  19 + this.marketId = marketId;
  20 + }
  21 +
  22 + public String getName() {
  23 + return name;
  24 + }
  25 +
  26 + public void setName(String name) {
  27 + this.name = name;
  28 + }
  29 +
  30 + public String getType() {
  31 + return type;
  32 + }
  33 +
  34 + public void setType(String type) {
  35 + this.type = type;
  36 + }
  37 +
  38 + public Integer getState() {
  39 + return state;
  40 + }
  41 +
  42 + public void setState(Integer state) {
  43 + this.state = state;
  44 + }
  45 +
  46 + public List<Long> getMarketIds() {
  47 + return marketIds;
  48 + }
  49 +
  50 + public void setMarketIds(List<Long> marketIds) {
  51 + this.marketIds = marketIds;
  52 + }
  53 +
  54 + public String getKeyword() {
  55 + return keyword;
  56 + }
  57 +
  58 + public void setKeyword(String keyword) {
  59 + this.keyword = keyword;
  60 + }
  61 +
  62 + public String getValue() {
  63 + return value;
  64 + }
  65 +
  66 + public void setValue(String value) {
  67 + this.value = value;
  68 + }
  69 +}
... ...
etrade-rpc/src/main/java/com/diligrp/etrade/rpc/dto/response/ConfigDto.java 0 → 100644
  1 +package com.diligrp.etrade.rpc.dto.response;
  2 +
  3 +import java.util.Set;
  4 +
  5 +public class ConfigDto {
  6 + private Long id;
  7 + private String name;
  8 + private Integer nameSort;
  9 + private String value;
  10 + private String notes;
  11 + private Integer notesSort;
  12 + private Integer state;
  13 + private Long marketId;
  14 + private Set<Long> marketIds;
  15 + private String type;
  16 +
  17 + public Long getId() {
  18 + return id;
  19 + }
  20 +
  21 + public void setId(Long id) {
  22 + this.id = id;
  23 + }
  24 +
  25 + public String getName() {
  26 + return name;
  27 + }
  28 +
  29 + public void setName(String name) {
  30 + this.name = name;
  31 + }
  32 +
  33 + public Integer getNameSort() {
  34 + return nameSort;
  35 + }
  36 +
  37 + public void setNameSort(Integer nameSort) {
  38 + this.nameSort = nameSort;
  39 + }
  40 +
  41 + public String getValue() {
  42 + return value;
  43 + }
  44 +
  45 + public void setValue(String value) {
  46 + this.value = value;
  47 + }
  48 +
  49 + public String getNotes() {
  50 + return notes;
  51 + }
  52 +
  53 + public void setNotes(String notes) {
  54 + this.notes = notes;
  55 + }
  56 +
  57 + public Integer getNotesSort() {
  58 + return notesSort;
  59 + }
  60 +
  61 + public void setNotesSort(Integer notesSort) {
  62 + this.notesSort = notesSort;
  63 + }
  64 +
  65 + public Integer getState() {
  66 + return state;
  67 + }
  68 +
  69 + public void setState(Integer state) {
  70 + this.state = state;
  71 + }
  72 +
  73 + public Long getMarketId() {
  74 + return marketId;
  75 + }
  76 +
  77 + public void setMarketId(Long marketId) {
  78 + this.marketId = marketId;
  79 + }
  80 +
  81 + public Set<Long> getMarketIds() {
  82 + return marketIds;
  83 + }
  84 +
  85 + public void setMarketIds(Set<Long> marketIds) {
  86 + this.marketIds = marketIds;
  87 + }
  88 +
  89 + public String getType() {
  90 + return type;
  91 + }
  92 +
  93 + public void setType(String type) {
  94 + this.type = type;
  95 + }
  96 +}
... ...