suochencheng 7 年 前
コミット
6c1d1ef5d6

+ 2 - 2
src/main/java/com/izouma/awesomeadmin/dao/ProductImageMapper.xml

@@ -258,7 +258,7 @@
             </trim>
             </trim>
             ,
             ,
         </if>
         </if>
-        rank desc, id desc
+        rank desc, id
     </select>
     </select>
     <select id="queryAllProductImage" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.ProductImage">
     <select id="queryAllProductImage" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.ProductImage">
         select <include refid="Base_Column_List"/> from product_image
         select <include refid="Base_Column_List"/> from product_image
@@ -355,7 +355,7 @@
             ,
             ,
         </if>
         </if>
 
 
-        rank desc,id desc
+        rank desc,id
     </select>
     </select>
     <select id="queryProductImage" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.ProductImage">
     <select id="queryProductImage" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.ProductImage">
         select <include refid="Base_Column_List"/> from product_image
         select <include refid="Base_Column_List"/> from product_image

+ 60 - 20
src/main/java/com/izouma/awesomeadmin/service/impl/UserOrderServiceImpl.java

@@ -73,6 +73,9 @@ public class UserOrderServiceImpl implements UserOrderService {
     @Autowired
     @Autowired
     private OrderRepairMapper orderRepairMapper;
     private OrderRepairMapper orderRepairMapper;
 
 
+    @Autowired
+    private ProductInfoMapper productInfoMapper;
+
 
 
     @Override
     @Override
     public List<UserOrder> getUserOrderList(UserOrder record) {
     public List<UserOrder> getUserOrderList(UserOrder record) {
@@ -141,41 +144,78 @@ public class UserOrderServiceImpl implements UserOrderService {
         try {
         try {
             record.setOrderCode(MbappUtil.getOrderIdByUUId());
             record.setOrderCode(MbappUtil.getOrderIdByUUId());
             if (record.getQuantity() != null && record.getUnitPrice() != null) {
             if (record.getQuantity() != null && record.getUnitPrice() != null) {
-                BigDecimal totlePrice = record.getUnitPrice().multiply(BigDecimal.valueOf(record.getQuantity()));
+                BigDecimal unitPrice = record.getUnitPrice();
+
+                /**
+                 * 计算价格开始
+                 */
+                ProductInfo productInfo = new ProductInfo();
+                productInfo.setId(record.getProductId());
+
+                productInfo = productInfoMapper.queryProductInfo(productInfo);
+
+                if (productInfo != null) {
+                    unitPrice = productInfo.getPrice();
+
+                    if (productInfo.getProductPriceList() != null && productInfo.getProductPriceList().size() > 0) {
+                        for (ProductPrice productPrice : productInfo.getProductPriceList()) {
+                            if (productPrice.getMaxCounts() != null
+                                    && productPrice.getMinCounts() != null
+                                    && record.getQuantity() <= productPrice.getMaxCounts()
+                                    && record.getQuantity() >= productPrice.getMinCounts()) {
+                                unitPrice = productPrice.getPrice();
+                            } else if (productPrice.getMaxCounts() == null
+                                    && productPrice.getMinCounts() != null
+                                    && record.getQuantity() >= productPrice.getMinCounts()) {
+                                unitPrice = productPrice.getPrice();
+                            } else if (productPrice.getMinCounts() == null
+                                    && productPrice.getMaxCounts() != null
+                                    && record.getQuantity() < productPrice.getMinCounts()) {
+                                unitPrice = productPrice.getPrice();
+                            }
+                        }
+                    }
+
+                }
+                /**
+                 * 计算价格结束
+                 */
+
+                BigDecimal totlePrice = unitPrice.multiply(BigDecimal.valueOf(record.getQuantity()));
                 record.setTotlePrice(totlePrice);
                 record.setTotlePrice(totlePrice);
                 BigDecimal dealPrice = totlePrice;
                 BigDecimal dealPrice = totlePrice;
                 record.setDealPrice(dealPrice);
                 record.setDealPrice(dealPrice);
                 record.setOffPrice(totlePrice.subtract(dealPrice));
                 record.setOffPrice(totlePrice.subtract(dealPrice));
-            }
 
 
 
 
-            int updates = userOrderMapper.insertSelective(record);
+                int updates = userOrderMapper.insertSelective(record);
 
 
 
 
-            if (StringUtils.isNotEmpty(record.getUserAddressId())) {
-                UserAddress userAddress = userAddressMapper.selectByPrimaryKey(Integer.valueOf(record.getUserAddressId()));
+                if (StringUtils.isNotEmpty(record.getUserAddressId())) {
+                    UserAddress userAddress = userAddressMapper.selectByPrimaryKey(Integer.valueOf(record.getUserAddressId()));
 
 
-                if (userAddress != null) {
-                    OrderAddress orderAddress = new OrderAddress();
+                    if (userAddress != null) {
+                        OrderAddress orderAddress = new OrderAddress();
 
 
-                    orderAddress.setOrderId(record.getId());
-                    orderAddress.setUserId(record.getUserId());
-                    orderAddress.setRealName(userAddress.getRealName());
-                    orderAddress.setTelephone(userAddress.getTelephone());
-                    orderAddress.setPostcode(userAddress.getPostcode());
-                    orderAddress.setAddress(userAddress.getAddress());
-                    orderAddress.setAddressDetail(userAddress.getAddressDetail());
-                    orderAddress.setUserAddressId(record.getUserAddressId());
+                        orderAddress.setOrderId(record.getId());
+                        orderAddress.setUserId(record.getUserId());
+                        orderAddress.setRealName(userAddress.getRealName());
+                        orderAddress.setTelephone(userAddress.getTelephone());
+                        orderAddress.setPostcode(userAddress.getPostcode());
+                        orderAddress.setAddress(userAddress.getAddress());
+                        orderAddress.setAddressDetail(userAddress.getAddressDetail());
+                        orderAddress.setUserAddressId(record.getUserAddressId());
 
 
-                    orderAddressMapper.insertSelective(orderAddress);
+                        orderAddressMapper.insertSelective(orderAddress);
 
 
 
 
-                }
+                    }
 
 
-            }
+                }
 
 
-            if (updates > 0) {
-                return true;
+                if (updates > 0) {
+                    return true;
+                }
             }
             }
         } catch (Exception e) {
         } catch (Exception e) {
             logger.error("createUserOrder", e);
             logger.error("createUserOrder", e);