Parcourir la source

超级会员商品/优惠价sku前端下单

zhijiezhao il y a 2 ans
Parent
commit
c5a0cf727d

+ 3 - 0
src/main/java/com/caimei/modules/bulkpurchase/dao/PurchaseProductDao.java

@@ -1,5 +1,6 @@
 package com.caimei.modules.bulkpurchase.dao;
 
+import com.caimei.modules.product.entity.CmSku;
 import com.caimei.modules.svip.entity.CmSvipProduct;
 import com.caimei.po.ProductLadderPrice;
 import com.thinkgem.jeesite.common.persistence.CrudDao;
@@ -33,4 +34,6 @@ public interface PurchaseProductDao extends CrudDao<PurchaseProduct> {
     List<ProductLadderPrice> findLadderPriceList(Long productId);
 
     CmSvipProduct getSvipProduct(@Param("productId")Long productId, @Param("userId") Integer userId);
+
+    CmSku findVipSku(Long productId);
 }

+ 9 - 2
src/main/java/com/caimei/modules/bulkpurchase/web/CmRefundsProductController.java

@@ -12,6 +12,7 @@ import com.caimei.modules.order.dao.NewOrderProductDao;
 import com.caimei.modules.order.entity.*;
 import com.caimei.modules.order.service.*;
 import com.caimei.modules.product.dao.CmPromotionDao;
+import com.caimei.modules.product.dao.ProductDao;
 import com.caimei.modules.product.entity.CmPromotion;
 import com.caimei.modules.user.dao.CmUserDao;
 import com.caimei.modules.user.entity.CmUser;
@@ -79,6 +80,8 @@ public class CmRefundsProductController extends BaseController {
     private NewOrderProductDao newOrderProductDao;
     @Resource
     private CmOfflineCollectionService cmOfflineCollectionService;
+    @Resource
+    private ProductDao productDao;
 
     @ModelAttribute
     public CmRefundsProduct get(@RequestParam(required = false) String id) {
@@ -224,7 +227,9 @@ public class CmRefundsProductController extends BaseController {
                                     isPromotions = true;
                                     //单品优惠
                                     if ("1".equals(promotions.getMode())) {
-                                        returnedPurchaseFee -= (orderProduct.getDiscountPrice() - promotions.getTouchPrice()) * number;
+                                        //取对应sku的优惠价
+                                        Double touchPrice = productDao.getTouchPriceBySku(orderProduct.getSkuId());
+                                        returnedPurchaseFee -= (orderProduct.getDiscountPrice() - touchPrice) * number;
                                     }
                                 }
                             }
@@ -397,7 +402,9 @@ public class CmRefundsProductController extends BaseController {
                                     if (promotions != null) {
                                         //单品优惠
                                         if ("1".equals(promotions.getMode())) {
-                                            returnedPurchaseFee -= (orderProduct.getDiscountPrice() - promotions.getTouchPrice()) * number;
+                                            //取对应sku的优惠价
+                                            Double touchPrice = productDao.getTouchPriceBySku(orderProduct.getSkuId());
+                                            returnedPurchaseFee -= (orderProduct.getDiscountPrice() - touchPrice) * number;
                                         }
                                     }
                                 }

+ 37 - 13
src/main/java/com/caimei/modules/bulkpurchase/web/PurchaseProductController.java

@@ -111,6 +111,15 @@ public class PurchaseProductController extends BaseController {
                         s.setLadderPriceList(productDao.findLadderPriceBySku(s.getSkuId()));
                     }
                 });
+                // 超级会员价赋值
+                if (null != skuList.get(0).getPriceType()) {
+                    p.setSvipPriceType(skuList.get(0).getPriceType());
+                    if (1 == skuList.get(0).getPriceType()) {
+                        p.setSvipDiscount(skuList.get(0).getDiscount());
+                    } else {
+                        p.setSvipDiscountPrice(skuList.get(0).getDiscountPrice());
+                    }
+                }
                 p.setSkuId(skuList.get(0).getSkuId());
                 p.setPrice(skuList.get(0).getPrice().toString());
                 if (1 == skuList.get(0).getLadderPriceFlag()) {
@@ -118,8 +127,6 @@ public class PurchaseProductController extends BaseController {
                     p.setLadderPriceList(productDao.findLadderPrice(skuList.get(0).getSkuId()));
                 }
                 p.setSkuList(skuList);
-                long productId = p.getProductId();
-                String discountPrice = p.getPrice();//默认折扣单价
                 if (priceFlag) {
                     p.setPrice(p.getNormalPrice());
                 }
@@ -153,18 +160,22 @@ public class PurchaseProductController extends BaseController {
                 // 初始化超级会员优惠
                 p.setSvipReduction(0d);
                 if (1 == p.getSvipPriceFlag()) {
-//                    if (1 == p.getSvipPriceType()) {
-//                        p.setSvipDiscountPrice(MathUtil.div(MathUtil.mul(new Double(p.getPrice()), p.getSvipDiscount()), 100, 2).doubleValue());
-//                    }
-                    // 商品的超级会员优惠=原价-超级会员优惠价
-//                    p.setSvipReduction(MathUtil.sub(p.getPrice(), p.getSvipDiscountPrice()).doubleValue());
-//                    if ("0".equals(p.getIncludedTax()) && ("1".equals(p.getInvoiceType()) || "2".equals(p.getInvoiceType()))) {
-//                        // 计算优惠的税费
-//                        BigDecimal taxReduction = MathUtil.div(MathUtil.mul(p.getSvipReduction(), p.getTaxRate()), 100);
-//                        p.setSvipReduction(MathUtil.add(p.getSvipReduction(), taxReduction).doubleValue());
-//                        p.setSvipTaxReduction(taxReduction.doubleValue());
-//                    }
+                    if (1 == p.getSvipPriceType()) {
+                        p.setSvipDiscountPrice(MathUtil.div(MathUtil.mul(new Double(p.getPrice()), p.getSvipDiscount()), 100, 2).doubleValue());
+                    }
+//                     商品的超级会员优惠=原价-超级会员优惠价
+                    p.setSvipReduction(MathUtil.sub(p.getPrice(), p.getSvipDiscountPrice()).doubleValue());
+                    if ("0".equals(p.getIncludedTax()) && ("1".equals(p.getInvoiceType()) || "2".equals(p.getInvoiceType()))) {
+                        // 计算优惠的税费
+                        BigDecimal taxReduction = MathUtil.div(MathUtil.mul(p.getSvipReduction(), p.getTaxRate()), 100);
+                        p.setSvipReduction(MathUtil.add(p.getSvipReduction(), taxReduction).doubleValue());
+                        p.setSvipTaxReduction(taxReduction.doubleValue());
+                    }
                 } else if (null != cmPromotion) {
+                    if ("1".equals(cmPromotion.getMode())) {
+                        // 优惠价取sku优惠价
+                        cmPromotion.setTouchPrice(skuList.get(0).getTouchPrice());
+                    }
                     p.setCmPromotion(cmPromotion);
                     p.setLadderPriceFlag(0);
                 }
@@ -347,6 +358,15 @@ public class PurchaseProductController extends BaseController {
                         s.setLadderPriceList(productDao.findLadderPriceBySku(s.getSkuId()));
                     }
                 });
+                // 超级会员价赋值
+                if (null != skus.get(0).getPriceType()) {
+                    purchaseProduct.setPriceType(skus.get(0).getPriceType().toString());
+                    if (1 == skus.get(0).getPriceType()) {
+                        purchaseProduct.setDiscount(skus.get(0).getDiscount().toString());
+                    } else {
+                        purchaseProduct.setDiscountPrice(skus.get(0).getDiscountPrice().toString());
+                    }
+                }
                 purchaseProduct.setSkuList(skus);
                 CmSvipProduct svipProduct = purchaseProductService.getSvipProduct(purchaseProduct.getProductId(), purchaseProduct.getUserId());
                 CmPromotion productPromotion = cmPromotionService.findProductPromotion(product.getShopID().toString(), Long.parseLong(product.getProductID().toString()));
@@ -354,6 +374,10 @@ public class PurchaseProductController extends BaseController {
                     purchaseProduct.setSvipPriceFlag(1);
                     purchaseProduct.setSvipPriceType(svipProduct.getPriceType());
                 } else if (productPromotion != null) {
+                    // 优惠价的时候给赋值优惠价
+                    if("1".equals(productPromotion.getMode())){
+                        productPromotion.setTouchPrice(skus.get(0).getTouchPrice());
+                    }
                     purchaseProduct.setCmPromotion(productPromotion);
                 } else {
                     if (1 == skus.get(0).getLadderPriceFlag()) {

+ 6 - 1
src/main/java/com/caimei/modules/order/service/CmReturnedPurchaseService.java

@@ -11,6 +11,7 @@ import com.caimei.modules.order.entity.*;
 import com.caimei.modules.order.utils.*;
 import com.caimei.modules.product.dao.CmPromotionDao;
 import com.caimei.modules.product.dao.CmSecondHandDetailDao;
+import com.caimei.modules.product.dao.ProductDao;
 import com.caimei.modules.product.entity.CmPromotion;
 import com.caimei.modules.user.dao.*;
 import com.caimei.modules.user.entity.CmUser;
@@ -65,6 +66,8 @@ public class CmReturnedPurchaseService extends CrudService<CmReturnedPurchaseDao
             .readTimeout(20, TimeUnit.SECONDS)
             .build();
 
+    @Resource
+    private ProductDao productDao;
     @Resource
     private CmReturnedPurchaseDao cmReturnedPurchaseDao;
     @Resource
@@ -222,7 +225,9 @@ public class CmReturnedPurchaseService extends CrudService<CmReturnedPurchaseDao
                                 if (promotions != null) {
                                     //单品优惠
                                     if ("1".equals(promotions.getMode())) {
-                                        returnedPurchaseFee -= (orderProduct.getDiscountPrice() - promotions.getTouchPrice()) * number;
+                                        //取对应sku的优惠价
+                                        Double touchPrice = productDao.getTouchPriceBySku(orderProduct.getSkuId());
+                                        returnedPurchaseFee -= (orderProduct.getDiscountPrice() - touchPrice) * number;
                                     }
                                 }
                             }

+ 9 - 4
src/main/java/com/caimei/modules/order/service/NewOrderService.java

@@ -464,7 +464,9 @@ public class NewOrderService extends CrudService<NewOrderDao, NewOrder> {
                                     if ("1".equals(promotion.getType())) {
                                         // 优惠价
                                         if ("1".equals(promotion.getMode())) {
-                                            shopReducedPrice += (orderProduct.getPrice() - promotion.getTouchPrice()) * orderProduct.getNum();
+                                            // 单品优惠价取当前sku的优惠价
+                                            Double touchPrice=productDao.getTouchPriceBySku(orderProduct.getSkuId());
+                                            shopReducedPrice += (orderProduct.getPrice() - touchPrice) * orderProduct.getNum();
                                         }
                                         // 单品满减
                                         if ("2".equals(promotion.getMode())) {
@@ -1092,14 +1094,17 @@ public class NewOrderService extends CrudService<NewOrderDao, NewOrder> {
             if (("0".equals(product.getIncludedTax()) && ("1".equals(product.getInvoiceType()) || "2".equals(product.getInvoiceType()))) || "2".equals(product.getIncludedTax()) || "".equals(product.getIncludedTax())) {
                 BigDecimal addedValueTax = BigDecimal.ZERO;
                 if (promotions != null && "1".equals(promotions.getType()) && "1".equals(promotions.getMode())) {
-                    addedValueTax = MathUtil.div(MathUtil.mul(promotions.getTouchPrice(), o.getTaxRate()), BigDecimal.valueOf(100));
-                    price = MathUtil.add(promotions.getTouchPrice(), addedValueTax).doubleValue();
+                    //取对应sku的优惠价
+                    Double touchPrice = productDao.getTouchPriceBySku(o.getSkuId());
+                    addedValueTax = MathUtil.div(MathUtil.mul(touchPrice, o.getTaxRate()), BigDecimal.valueOf(100));
+                    price = MathUtil.add(touchPrice, addedValueTax).doubleValue();
                 } else {
                     addedValueTax = MathUtil.div(MathUtil.mul(price, o.getTaxRate()), BigDecimal.valueOf(100));
                     price = MathUtil.add(price, addedValueTax).doubleValue();
                 }
             } else if (promotions != null && "1".equals(promotions.getType()) && "1".equals(promotions.getMode())) {
-                price = promotions.getTouchPrice();
+                //取对应sku的优惠价
+                price = productDao.getTouchPriceBySku(o.getSkuId());
             }
             //通过比例成本价计算
             costPrice = MathUtil.mul(MathUtil.div(product.getCostProportional(), 100), price).floatValue();

+ 3 - 1
src/main/java/com/caimei/modules/order/service/NewShopOrderService.java

@@ -107,7 +107,9 @@ public class NewShopOrderService extends CrudService<NewShopOrderDao, NewShopOrd
                 if (bean.getOrderPromotionsId() != null) {
                     CmPromotion promotions = cmPromotionDao.findOrderPromotions(bean.getOrderPromotionsId());
                     if (promotions != null && "1".equals(promotions.getMode())) {
-                        bean.setDiscountPrice(promotions.getTouchPrice());
+                        //取对应sku的优惠价
+                        Double price = productDao.getTouchPriceBySku(bean.getSkuId());
+                        bean.setDiscountPrice(price);
                     }
                 }
                 listAll.add(bean);

+ 8 - 2
src/main/java/com/caimei/modules/order/utils/OrderUtil.java

@@ -4,14 +4,18 @@ package com.caimei.modules.order.utils;
 import com.caimei.modules.order.entity.NewOrder;
 import com.caimei.modules.order.entity.NewOrderProduct;
 import com.caimei.modules.order.entity.NewShopOrder;
+import com.caimei.modules.product.dao.ProductDao;
 import com.caimei.modules.product.entity.CmPromotion;
 import com.caimei.utils.MathUtil;
 
+import javax.annotation.Resource;
 import java.math.BigDecimal;
 import java.util.*;
 
 public class OrderUtil {
 
+    @Resource
+    public static ProductDao productDao;
     /**
      * 获取主订单下的所有商品
      *
@@ -160,8 +164,10 @@ public class OrderUtil {
                     if ("1".equals(promotion.getType())) {
                         // 优惠价
                         if ("1".equals(promotion.getMode())) {
-                            shopReducedPrice += (o.getPrice() - promotion.getTouchPrice()) * o.getNum();
-                            productDiscount += (o.getPrice() - promotion.getTouchPrice()) * o.getNum();
+                            //取对应sku的优惠价
+                            Double price = productDao.getTouchPriceBySku(o.getSkuId());
+                            shopReducedPrice += (o.getPrice() - price) * o.getNum();
+                            productDiscount += (o.getPrice() - price) * o.getNum();
                         }
                         // 单品满减
                         if ("2".equals(promotion.getMode())) {

+ 4 - 1
src/main/java/com/caimei/modules/order/web/NewOrderController.java

@@ -447,6 +447,7 @@ public class NewOrderController extends BaseController {
                         }
                     } else {
                         if(null==o.getSkuId()){
+                            //赠品
                             o.setSkuId(productDao.findSkuIdByPromotionsId(o.getPromotionsId()));
                         }
                         o.setPreferential(0d);
@@ -574,7 +575,9 @@ public class NewOrderController extends BaseController {
                 if (o.getOrderPromotionsId() != null) {
                     CmPromotion promotions = cmPromotionDao.findOrderPromotions(o.getOrderPromotionsId());
                     if (promotions != null && "1".equals(promotions.getMode())) {
-                        o.setDiscountPrice(promotions.getTouchPrice());
+                        //取对应sku的优惠价
+                        Double price = productDao.getTouchPriceBySku(o.getSkuId());
+                        o.setDiscountPrice(price);
                     }
                 }
             });

+ 2 - 0
src/main/java/com/caimei/modules/product/dao/ProductDao.java

@@ -223,4 +223,6 @@ public interface ProductDao extends CrudDao<Product> {
     void deleteProductSkus(@Param("skuIds")List<Integer> skuIds,@Param("productId")Integer productId);
 
     String findProductIdBySku(String productId);
+
+    Double getTouchPriceBySku(Integer skuId);
 }

+ 1 - 1
src/main/java/com/caimei/modules/product/service/CmPromotionService.java

@@ -304,7 +304,7 @@ public class CmPromotionService extends CrudService<CmPromotionDao, CmPromotion>
         cmPromotionDao.deleteAllPromotionProductsAndShops(promotionId);
         cmPromotionDao.deleteAllPromotionGifts(promotionId);
         if ("1".equals(cmPromotion.getType()) && "1".equals(cmPromotion.getMode())){
-            // 单品优惠价的时候,删除优惠商品之前的优惠价
+            // 单品优惠价的时候,删除优惠商品之前的优惠价(新增保存不会删除)
             cmPromotionDao.deleteOldTouchPrice(promotionId);
             // 保存新的sku优惠价
             cmPromotion.getSkus().forEach(s->cmPromotionDao.insertNewTouchPrice(s.getSkuId(),s.getTouchPrice(),promotionId));

+ 10 - 11
src/main/resources/mappings/modules/bulkpurchase/PurchaseProductMapper.xml

@@ -44,18 +44,10 @@
         SELECT b.name shopName ,b.`shopID` shopId,a.name purchaseProductName,
         a.`productID` productId,a.productCode productNo,a.mainImage image,a.includedTax AS includedTax,
         a.invoiceType AS invoiceType, a.taxPoint AS taxRate, a.supplierTaxPoint AS supplierTaxRate, a.commodityType,
-        if(csp.id is not null and csu.id is not null,1,0) as svipPriceFlag,
-        (select priceType from cm_svip_product_sku csps where productId=a.productId) as svipPriceType,
-        cc.discount as svipDiscount,
-        cc.discountPrice as svipDiscountPrice
+        if(csp.id is not null and csu.id is not null and csp.status=0,1,0) as svipPriceFlag
         FROM product a LEFT JOIN shop b ON b.shopID=a.shopID
         left join cm_svip_product csp on a.productID = csp.productId
         left join cm_svip_user csu on csu.userId = #{userId} and csu.delFlag = '0' and now() <![CDATA[ < ]]> csu.endTime
-        LEFT JOIN
-        (SELECT csps.discount,csps.discountPrice,csps.priceType,csps.productId,csps.skuId FROM cm_svip_product_sku csps
-        LEFT JOIN cm_sku cs ON csps.skuId=cs.skuId
-        ORDER BY cs.price ASC
-        LIMIT 1) cc ON cc.productId=a.productId
         <where>
             <if test="purchaseProductName != null and purchaseProductName != ''">
                 AND a.name LIKE concat('%',#{purchaseProductName},'%')
@@ -205,7 +197,7 @@
         ORDER BY ladderNum ASC
     </select>
     <select id="checkSvipProduct" resultType="java.lang.Integer">
-        select if(csp.id is not null and csu.id is not null, 1, 0) as svipPriceFlag
+        select if(csp.id is not null and csu.id is not null and csp.status=0, 1, 0) as svipPriceFlag
         from cm_svip_product csp
                  left join cm_svip_user csu
                            on csu.userId = #{userId} and csu.delFlag = '0' and now() <![CDATA[ < ]]> csu.endTime
@@ -213,7 +205,7 @@
     </select>
     <select id="getSvipProduct" resultType="com.caimei.modules.svip.entity.CmSvipProduct">
         select ccs.priceType,
-               if(csp.id is not null and csu.id is not null, 1, 0) as svipPriceFlag
+               if(csp.id is not null and csu.id is not null and csp.status=0, 1, 0) as svipPriceFlag
         from cm_svip_product csp
                  left join cm_svip_user csu
                            on csu.userId = #{userId} and csu.delFlag = '0' and now() <![CDATA[ < ]]> csu.endTime
@@ -221,4 +213,11 @@
             where csps.productId=#{productId} order by cs.price asc limit 1) ccs on csp.productId=ccs.productId
         where csp.productId = #{productId};
     </select>
+    <select id="findVipSku" resultType="com.caimei.modules.product.entity.CmSku">
+        select discountPrice,discount,priceType
+        from cm_svip_product_sku csps
+        left join cm_sku cs on csps.productId = cs.productId
+        where csps.productId=#{productId}
+        order by cs.price asc limit 1
+    </select>
 </mapper>

+ 15 - 5
src/main/resources/mappings/modules/product/ProductMapper.xml

@@ -2008,8 +2008,8 @@
         where shopId = #{shopID}
     </select>
     <select id="findSkuList" resultType="com.caimei.modules.product.entity.CmSku">
-        select skuId,
-               productId,
+        select cs.skuId,
+               cs.productId,
                unit,
                normalPrice,
                stock,
@@ -2018,9 +2018,15 @@
                costPrice,
                price,
                ladderPriceFlag,
-               minBuyNumber
-        from cm_sku
-        where productId = #{productID}
+               minBuyNumber,
+               cps.touchPrice,
+               csps.discount,
+               csps.discountPrice,
+               csps.priceType
+        from cm_sku cs
+        left join cm_promotion_sku cps on cs.skuId = cps.skuId
+        left join cm_svip_product_sku csps on cs.skuId = csps.skuId
+        where cs.productId = #{productID}
     </select>
     <select id="findLadderPriceBySku" resultType="com.caimei.modules.product.entity.CmLadderPrice">
         select skuId, productId, userType, ladderNum, buyNum, buyPrice, delFlag
@@ -2087,4 +2093,8 @@
         from cm_promotions_gift
         where promotionsId = #{promotionsId}
     </select>
+    <select id="getTouchPriceBySku" resultType="java.lang.Double">
+        select touchPrice from cm_promotion_sku
+        where skuId=#{skuId}
+    </select>
 </mapper>

+ 32 - 0
src/main/webapp/WEB-INF/views/modules/bulkpurchase/orderPurchaseProductForm.jsp

@@ -528,6 +528,38 @@
         $checkItem["totalAddedValueTax"] = tax * num;
         $("#addedValueTax0").val(tax);
         $("#totalAddedValueTax0").val(tax * num);
+        debugger;
+        var flag = $("#svipPriceFlag0").val() * 1;
+        if (1 === flag) {
+            var type = skus[skuIndex].priceType;
+            if (1 === type) {
+                //1折扣,2优惠价
+                var discount = skus[skuIndex].discount;
+                var oldPrice = skus[skuIndex].price;
+                var discountPrice = (discount * oldPrice / 100).toFixed(2);
+                $("#svipDiscountPrice0").html(discountPrice);
+                $("#discountPrice0").val(discountPrice);
+
+                $checkItem["discount"] = discount;
+                $checkItem["discountPrice"] = discountPrice;
+                $checkItem["discountPrice"] = discountPrice;
+                $checkItem["svipReduction"] = oldPrice - discountPrice;
+                $("#svipReduction0").val(oldPrice - discountPrice);
+                base = discountPrice;
+            } else {
+                $("#svipDiscountPrice0").html(skus[skuIndex].discountPrice);
+                $("#discountPrice0").val(skus[skuIndex].discountPrice);
+                $checkItem["discountPrice"] = skus[skuIndex].discountPrice;
+                $checkItem["svipReduction"] = skus[skuIndex].price - skus[skuIndex].discountPrice;
+                $("#svipReduction0").val(skus[skuIndex].price - skus[skuIndex].discountPrice);
+                base = skus[skuIndex].discountPrice;
+            }
+        } else if (skus[skuIndex].touchPrice) {
+            base = skus[skuIndex].touchPrice;
+            $("#touchPrice0").val(skus[skuIndex].touchPrice);
+            $checkItem["touchPrice"] = skus[skuIndex].touchPrice;
+            $checkItem["cmPromotion"]["touchPrice"] = skus[skuIndex].touchPrice;
+        }
         var total = base * num;
         $("#totalFee0").val(total);
         $checkItem["totalFee"] = total;

+ 40 - 9
src/main/webapp/WEB-INF/views/modules/bulkpurchase/orderPurchaseProductList.jsp

@@ -300,13 +300,12 @@
             var totalFee = "#" + "totalFee" + ind;
             var skus = JSON.parse($("#hideSkus").val());
             var skuIndex = skuStr.split("/")[1];
-            debugger;
             console.log(skus[skuIndex].skuId);
-            $checkItem["skuId"] =skus[skuIndex].skuId;
+            $checkItem["skuId"] = skus[skuIndex].skuId;
             $("#skuId" + ind).text(skus[skuIndex].skuId);
             //页面价格赋值
             document.getElementById(price).innerHTML = skus[skuIndex].price;
-            $("#price"+ind).val(skus[skuIndex].price);
+            $("#price" + ind).val(skus[skuIndex].price);
             $(singlePrice).val(skus[skuIndex].price);
             $(totalFee).val(skus[skuIndex].price);
             var discount = $checkItem["discount"];
@@ -320,23 +319,23 @@
             var taxRate = $checkItem["taxRate"];
             var productId = $checkItem["productId"];
             var num = $checkItem["num"];
-            var includedTax=$checkItem["includedTax"];
-            var base =skus[skuIndex].price* discount / 100;
+            var includedTax = $checkItem["includedTax"];
+            var base = skus[skuIndex].price * discount / 100;
             if (productId >= 6060 && productId <= 6069) {
                 tax = 0;
-            } else if ("3"===invoiceType) {
+            } else if ("3" === invoiceType) {
                 tax = "---";
             } else {
                 tax = discountPrice * taxRate / 100;
-                if("0"===includedTax){
+                if ("0" === includedTax) {
                     base += discountPrice * taxRate / 100;
                 }
             }
-            if(1==skus[skuIndex].ladderPriceFlag){
+            if (1 == skus[skuIndex].ladderPriceFlag) {
                 $checkItem["ladderPriceFlag"] = 1;
                 $checkItem["ladderPriceList"] = skus[skuIndex].ladderPriceList;
                 $(".ladderPrice").show();
-            }else{
+            } else {
                 $checkItem["ladderPriceFlag"] = 0;
                 $checkItem["ladderPriceList"] = {};
                 $(".ladderPrice").hide();
@@ -345,6 +344,38 @@
             $checkItem["totalAddedValueTax"] = tax * num;
             $("#addedValueTax" + ind).val(tax);
             $("#totalAddedValueTax" + ind).val(tax * num);
+            debugger;
+            var flag = $("#svipPriceFlag" + ind).val() * 1;
+            if (1 === flag) {
+                var type = skus[skuIndex].priceType;
+                if (1 === type) {
+                    //1折扣,2优惠价
+                    var discount = skus[skuIndex].discount;
+                    var oldPrice = skus[skuIndex].price;
+                    var discountPrice = (discount * oldPrice / 100).toFixed(2);
+                    $("#svipDiscountPrice" + ind).html(discountPrice);
+                    $("#discountPrice" + ind).val(discountPrice);
+
+                    $checkItem["discount"] = discount;
+                    $checkItem["discountPrice"] = discountPrice;
+                    $checkItem["discountPrice"] = discountPrice;
+                    $checkItem["svipReduction"] = oldPrice - discountPrice;
+                    $("#svipReduction" + ind).val(oldPrice - discountPrice);
+                    base = discountPrice;
+                } else {
+                    $("#svipDiscountPrice" + ind).html(skus[skuIndex].discountPrice);
+                    $("#discountPrice" + ind).val(skus[skuIndex].discountPrice);
+                    $checkItem["discountPrice"] = skus[skuIndex].discountPrice;
+                    $checkItem["svipReduction"] = skus[skuIndex].price - skus[skuIndex].discountPrice;
+                    $("#svipReduction" + ind).val(skus[skuIndex].price - skus[skuIndex].discountPrice);
+                    base = skus[skuIndex].discountPrice;
+                }
+            } else if (skus[skuIndex].touchPrice) {
+                base = skus[skuIndex].touchPrice;
+                $("#touchPrice" + ind).val(skus[skuIndex].touchPrice);
+                $checkItem["touchPrice"] = skus[skuIndex].touchPrice;
+                $checkItem["cmPromotion"]["touchPrice"] = skus[skuIndex].touchPrice;
+            }
             var total = base * num;
             $("#totalFee" + ind).val(total);
             $checkItem["totalFee"] = total;

+ 1 - 0
src/main/webapp/static/modules/bulkpurchase/orderForm.js

@@ -871,6 +871,7 @@ function setProductList(data, flag, ind) {
     var ladderPrice = '';
     // 如果存在促销活动
     if (data.cmPromotion) {
+        debugger;
         var tempId = data.cmPromotion.id * 1;
         data.promotionsId = data.cmPromotion.id;
         // 没有折扣,才享受促销优惠