Commit b2f343c1d3c8bdfb11ec401f2c032e3c69d82f11
1 parent
6de38ca7
update:商品交易类型去除
Showing
2 changed files
with
20 additions
and
51 deletions
etrade-order/src/main/java/com/diligrp/etrade/order/service/impl/OrderGoodsServiceImpl.java
@@ -114,56 +114,28 @@ public class OrderGoodsServiceImpl implements OrderGoodsService { | @@ -114,56 +114,28 @@ public class OrderGoodsServiceImpl implements OrderGoodsService { | ||
114 | //效验商品状态 与店铺关系 | 114 | //效验商品状态 与店铺关系 |
115 | checkProductDto(buyerOrderDto.getShopId(),productDto,productDto.getProductName()); | 115 | checkProductDto(buyerOrderDto.getShopId(),productDto,productDto.getProductName()); |
116 | if(productDto.getSalesMode().equals(ProductSalesMode.UNIT_PRICE.getCodeInteger())){ | 116 | if(productDto.getSalesMode().equals(ProductSalesMode.UNIT_PRICE.getCodeInteger())){ |
117 | - //效验商品总价 | ||
118 | - if(productDto.getProductTradeType().equals(ProductTradeType.WEIGHT_TYPE.getCodeInteger())){ | ||
119 | - if(!productDto.getProductTotalPrice().setScale(2, RoundingMode.HALF_UP).equals( | ||
120 | - productDto.getProductPrice().multiply(productDto.getProductWeight()).setScale(2, RoundingMode.HALF_UP))){ | ||
121 | - throw new OrderException(OrderErrorCode.PARAM_ERROR,productDto.getProductName()+"商品价格小计异常"); | ||
122 | - } | ||
123 | - allWeight = allWeight.add(productDto.getProductWeight()); | ||
124 | - productDto.setProductPieces(null); | ||
125 | - productDto.setProductPiecePrice(null); | ||
126 | - productDto.setProductPieceWeight(null); | ||
127 | - }else if(productDto.getProductTradeType().equals(ProductTradeType.PIECES_TYPE.getCodeInteger())){ | ||
128 | - if(productDto.getProductPiecePrice()==null||productDto.getProductPieces()==null|| | ||
129 | - productDto.getProductTotalPrice().setScale(2, RoundingMode.HALF_UP).compareTo( | ||
130 | - productDto.getProductPiecePrice().multiply(productDto.getProductPieces()).setScale(2, RoundingMode.HALF_UP))!=0){ | ||
131 | - throw new OrderException(OrderErrorCode.PARAM_ERROR,productDto.getProductName()+"商品价格小计异常"); | ||
132 | - } | ||
133 | - BigDecimal productWeight = productDto.getProductPieceWeight().multiply(productDto.getProductPieces()).setScale(2,RoundingMode.HALF_UP); | ||
134 | - allWeight = allWeight.add(productWeight); | ||
135 | - productDto.setProductWeight(productWeight); | ||
136 | - productDto.setProductPrice(productDto.getProductTotalPrice().divide(productWeight,RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_UP)); | ||
137 | - }else{ | ||
138 | - throw new OrderException(OrderErrorCode.PARAM_ERROR,"商品交易类型异常"); | 117 | + if(!productDto.getProductTotalPrice().setScale(2, RoundingMode.HALF_UP).equals( |
118 | + productDto.getProductPrice().multiply(productDto.getProductWeight()).setScale(2, RoundingMode.HALF_UP))){ | ||
119 | + throw new OrderException(OrderErrorCode.PARAM_ERROR,productDto.getProductName()+"商品价格小计异常"); | ||
139 | } | 120 | } |
121 | + allWeight = allWeight.add(productDto.getProductWeight()); | ||
122 | + productDto.setProductPieces(null); | ||
123 | + productDto.setProductPiecePrice(null); | ||
124 | + productDto.setProductPieceWeight(null); | ||
140 | }else if(productDto.getSalesMode().equals(ProductSalesMode.TOTAL_PRICE.getCodeInteger())){ | 125 | }else if(productDto.getSalesMode().equals(ProductSalesMode.TOTAL_PRICE.getCodeInteger())){ |
141 | //效验商品单价 | 126 | //效验商品单价 |
142 | - if(productDto.getProductTradeType().equals(ProductTradeType.WEIGHT_TYPE.getCodeInteger())){ | ||
143 | - if(productDto.getProductWeight()==null||productDto.getProductWeight().compareTo(NumberTransform.ZERO)==0){ | ||
144 | - throw new OrderException(OrderErrorCode.PARAM_ERROR,productDto.getProductName()+"按重计算,重量不能为0"); | ||
145 | - } | ||
146 | - if(!productDto.getProductPrice().setScale(2, RoundingMode.HALF_UP).equals( | ||
147 | - productDto.getProductTotalPrice().divide(productDto.getProductWeight(),RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_UP))){ | ||
148 | - throw new OrderException(OrderErrorCode.PARAM_ERROR,productDto.getProductName()+"商品单价异常"); | ||
149 | - } | ||
150 | - allWeight = allWeight.add(productDto.getProductWeight()); | ||
151 | - productDto.setProductPieces(null); | ||
152 | - productDto.setProductPiecePrice(null); | ||
153 | - productDto.setProductPieceWeight(null); | ||
154 | - }else if(productDto.getProductTradeType().equals(ProductTradeType.PIECES_TYPE.getCodeInteger())){ | ||
155 | - if(productDto.getProductPiecePrice()==null||productDto.getProductPieces()==null||productDto.getProductPieces().compareTo(NumberTransform.ZERO)==0|| | ||
156 | - productDto.getProductPiecePrice().setScale(2, RoundingMode.HALF_UP).compareTo( | ||
157 | - productDto.getProductTotalPrice().divide(productDto.getProductPieces(),RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_UP))!=0){ | ||
158 | - throw new OrderException(OrderErrorCode.PARAM_ERROR,productDto.getProductName()+"商品单价异常"); | ||
159 | - } | ||
160 | - BigDecimal productWeight = productDto.getProductPieceWeight().multiply(productDto.getProductPieces()).setScale(2,RoundingMode.HALF_UP); | ||
161 | - allWeight = allWeight.add(productWeight); | ||
162 | - productDto.setProductWeight(productWeight); | ||
163 | - productDto.setProductPrice(productDto.getProductTotalPrice().divide(productWeight,RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_UP)); | ||
164 | - }else{ | ||
165 | - throw new OrderException(OrderErrorCode.PARAM_ERROR,"商品交易类型异常"); | 127 | + if(productDto.getProductWeight()==null||productDto.getProductWeight().compareTo(NumberTransform.ZERO)==0){ |
128 | + throw new OrderException(OrderErrorCode.PARAM_ERROR,productDto.getProductName()+"按重计算,重量不能为0"); | ||
166 | } | 129 | } |
130 | + if(!productDto.getProductPrice().setScale(2, RoundingMode.HALF_UP).equals( | ||
131 | + productDto.getProductTotalPrice().divide(productDto.getProductWeight(),RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_UP))){ | ||
132 | + throw new OrderException(OrderErrorCode.PARAM_ERROR,productDto.getProductName()+"商品单价异常"); | ||
133 | + } | ||
134 | + allWeight = allWeight.add(productDto.getProductWeight()); | ||
135 | + productDto.setProductPieces(null); | ||
136 | + productDto.setProductPiecePrice(null); | ||
137 | + productDto.setProductPieceWeight(null); | ||
138 | + | ||
167 | }else{ | 139 | }else{ |
168 | throw new OrderException(OrderErrorCode.PARAM_ERROR,"商品交易类型异常"); | 140 | throw new OrderException(OrderErrorCode.PARAM_ERROR,"商品交易类型异常"); |
169 | } | 141 | } |
etrade-order/src/main/java/com/diligrp/etrade/order/service/impl/OrderServiceImpl.java
@@ -1526,11 +1526,8 @@ public class OrderServiceImpl implements OrderService { | @@ -1526,11 +1526,8 @@ public class OrderServiceImpl implements OrderService { | ||
1526 | orderCreateDto.setTotleAmount(orderCreateDto.getTotlePayAmount().add(productDto.getProductTotalPrice())); | 1526 | orderCreateDto.setTotleAmount(orderCreateDto.getTotlePayAmount().add(productDto.getProductTotalPrice())); |
1527 | orderCreateDto.setTotlePayAmount(orderCreateDto.getTotlePayAmount().add(productDto.getProductTotalPrice())); | 1527 | orderCreateDto.setTotlePayAmount(orderCreateDto.getTotlePayAmount().add(productDto.getProductTotalPrice())); |
1528 | totleAmount = totleAmount.add(productDto.getProductTotalPrice()); | 1528 | totleAmount = totleAmount.add(productDto.getProductTotalPrice()); |
1529 | - if (productDto.getProductTradeType().equals(ProductTradeType.WEIGHT_TYPE.getCodeInteger())){ | ||
1530 | - orderCreateDto.setTotleWeight(orderCreateDto.getTotleWeight().add(productDto.getProductWeight())); | ||
1531 | - }else if (productDto.getProductTradeType().equals(ProductTradeType.PIECES_TYPE.getCodeInteger())){ | ||
1532 | - orderCreateDto.setTotleWeight(orderCreateDto.getTotleWeight().add(productDto.getProductPieces().multiply(productDto.getProductPieceWeight()))); | ||
1533 | - } | 1529 | + orderCreateDto.setTotleWeight(orderCreateDto.getTotleWeight().add(productDto.getProductWeight())); |
1530 | + | ||
1534 | tempShopid = productDto.getShopId(); | 1531 | tempShopid = productDto.getShopId(); |
1535 | } | 1532 | } |
1536 | //订单总价,与订单总重效验 | 1533 | //订单总价,与订单总重效验 |