Forráskód Böngészése

超级会员提交订单

Aslee 3 éve
szülő
commit
d33526b75b

+ 2 - 1
src/main/java/com/caimei/modules/bulkpurchase/dao/PurchaseProductDao.java

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

+ 3 - 2
src/main/java/com/caimei/modules/bulkpurchase/service/PurchaseProductService.java

@@ -2,6 +2,7 @@ package com.caimei.modules.bulkpurchase.service;
 
 import java.util.List;
 
+import com.caimei.modules.svip.entity.CmSvipProduct;
 import com.caimei.po.ProductLadderPrice;
 import com.thinkgem.jeesite.common.utils.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -81,7 +82,7 @@ public class PurchaseProductService extends CrudService<PurchaseProductDao, Purc
 	    return purchaseProductDao.findLadderPriceList(productId);
 	}
 
-    public Integer checkSvipProduct(Long productId, Integer userId) {
-        return purchaseProductDao.checkSvipProduct(productId, userId);
+    public CmSvipProduct getSvipProduct(Long productId, Integer userId) {
+        return purchaseProductDao.getSvipProduct(productId, userId);
     }
 }

+ 5 - 3
src/main/java/com/caimei/modules/bulkpurchase/web/PurchaseProductController.java

@@ -17,6 +17,7 @@ import com.caimei.modules.product.service.CmPromotionService;
 import com.caimei.modules.product.service.RepeatPurchasePriceService;
 import com.caimei.modules.project.dao.ClubDao;
 import com.caimei.modules.project.model.ClubModel;
+import com.caimei.modules.svip.entity.CmSvipProduct;
 import com.caimei.modules.sys.utils.MailUtils;
 import com.caimei.po.ProductLadderPrice;
 import com.caimei.utils.MathUtil;
@@ -136,7 +137,7 @@ public class PurchaseProductController extends BaseController {
                         p.setSvipDiscountPrice(MathUtil.div(MathUtil.mul(new Double(p.getPrice()), p.getSvipDiscount()), 100, 2).doubleValue());
                     }
                     // 商品的超级会员优惠=原价-超级会员优惠价
-                    p.setSvipReduction(MathUtil.sub(p.getPrice(), new Double(p.getPrice())).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);
@@ -325,10 +326,11 @@ public class PurchaseProductController extends BaseController {
             purchaseProduct.setLadderPriceFlag(0);
             Product product = productDao.get(purchaseProduct.getProductId().toString());
             if (product != null) {
-                Integer svipPriceFlag = purchaseProductService.checkSvipProduct(purchaseProduct.getProductId(), purchaseProduct.getUserId());
+                CmSvipProduct svipProduct = purchaseProductService.getSvipProduct(purchaseProduct.getProductId(), purchaseProduct.getUserId());
                 CmPromotion productPromotion = cmPromotionService.findProductPromotion(product.getShopID().toString(), Long.parseLong(product.getProductID().toString()));
-                if (null != svipPriceFlag && 1 == svipPriceFlag) {
+                if (null != svipProduct && 1 == svipProduct.getSvipPriceFlag()) {
                     purchaseProduct.setSvipPriceFlag(1);
+                    purchaseProduct.setSvipPriceType(svipProduct.getPriceType());
                 } else if (productPromotion != null) {
                     purchaseProduct.setCmPromotion(productPromotion);
                 } else {

+ 12 - 3
src/main/java/com/caimei/modules/order/entity/NewOrderProduct.java

@@ -78,6 +78,9 @@ public class NewOrderProduct extends DataEntity<NewOrderProduct> {
     private String shopFee1; // 单个应付供应商金额
     private String otherFee1; // 单个应付第三方金额
     private String cmFee1; // 单个应付采美金额
+    private Integer svipPriceFlag;//超级会员优惠价格标识:0不是,1是
+    private Integer svipPriceType;//超级会员优惠价类型:1折扣价,2直接优惠价
+    private Double svipDiscount;//超级会员折扣
     // *****************  虚拟字段
     private Integer deliveryNum; // 发货数量
     private Integer outStoreTimes;  // 发货批次
@@ -113,9 +116,7 @@ public class NewOrderProduct extends DataEntity<NewOrderProduct> {
     private Integer ladderPriceFlag;        // 启用阶梯价格标识 0否 1是
     private Integer couponsLogo;        //显示优惠券查看: 1不显示 2显示
     private String commodityType;//商品属性:1产品,2仪器
-    private Integer svipPriceFlag;//超级会员优惠价格标识:0不是,1是
-    private Integer svipPriceType;//超级会员优惠价类型:1折扣价,2直接优惠价
-    private Double svipDiscount;//超级会员折扣
+    private Double svipReduction;//超级会员优惠
 
     public Integer getLadderPriceFlag() {
         return ladderPriceFlag;
@@ -989,4 +990,12 @@ public class NewOrderProduct extends DataEntity<NewOrderProduct> {
     public void setSvipDiscount(Double svipDiscount) {
         this.svipDiscount = svipDiscount;
     }
+
+    public Double getSvipReduction() {
+        return svipReduction;
+    }
+
+    public void setSvipReduction(Double svipReduction) {
+        this.svipReduction = svipReduction;
+    }
 }

+ 0 - 2
src/main/java/com/caimei/modules/order/service/NewOrderService.java

@@ -448,8 +448,6 @@ public class NewOrderService extends CrudService<NewOrderDao, NewOrder> {
                                 }
                             }
                         }
-                        // 保存超级会员优惠信息
-
                         orderProduct.setOrderID(newOrder.getOrderID());
                         orderProduct.setOrderNo(newOrder.getOrderNo());
                         orderProduct.setShopOrderID(shopOrder.getShopOrderID());

+ 16 - 1
src/main/java/com/caimei/modules/order/utils/OrderUtil.java

@@ -5,7 +5,9 @@ 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.entity.CmPromotion;
+import com.caimei.utils.MathUtil;
 
+import java.math.BigDecimal;
 import java.util.*;
 
 public class OrderUtil {
@@ -54,6 +56,11 @@ public class OrderUtil {
                 shopOrder.setNeedPayAmount(shopOrder.getNeedPayAmount() + o.getShouldPayFee());
                 shopOrder.setTotalAddedValueTax(shopOrder.getTotalAddedValueTax() + o.getTotalAddedValueTax()); //税费
                 shopOrder.setBrokerage(shopOrder.getBrokerage() + o.getCmFee()); //佣金 =  应付采美
+                // 计算超级会员优惠
+                if (1 == o.getSvipPriceFlag()) {
+                    BigDecimal productTotalReduction = MathUtil.mul(o.getSvipReduction(), o.getNum(), 2);
+                    shopOrder.setSvipShopReduction(MathUtil.add(shopOrder.getSvipShopReduction(), productTotalReduction).doubleValue());
+                }
             } else {
                 // 子订单如果不存在 实例化shopOrder
                 NewShopOrder shopOrder = new NewShopOrder();
@@ -93,7 +100,8 @@ public class OrderUtil {
                 shopOrder.setOutStoreNum(0);
                 // 计算超级会员优惠
                 if (1 == o.getSvipPriceFlag()) {
-
+                    BigDecimal productTotalReduction = MathUtil.mul(o.getSvipReduction(), o.getNum(), 2);
+                    shopOrder.setSvipShopReduction(MathUtil.add(shopOrder.getSvipShopReduction(), productTotalReduction).doubleValue());
                 } else {
                     shopOrder.setSvipShopReduction(0d);
                 }
@@ -130,6 +138,7 @@ public class OrderUtil {
         double shopTouchPrice = 0d;
         double shopReducedPrice = 0d;
         double productDiscount = 0d;
+        double svipShopReduction = 0d;
         for (NewOrderProduct o : orderProducts) {
             // 没有折扣时促销才生效
             if (o.getDiscount() == 100d) {
@@ -158,6 +167,11 @@ public class OrderUtil {
                     }
                 }
             }
+            // 计算超级会员优惠
+            if (1 == o.getSvipPriceFlag()) {
+                BigDecimal productTotalReduction = MathUtil.mul(o.getSvipReduction(), o.getNum(), 2);
+                svipShopReduction = MathUtil.add(shopOrder.getSvipShopReduction(), productTotalReduction).doubleValue();
+            }
             if (shopOrderNo == null) shopOrderNo = o.getShopOrderNo();
             if (shopID == null) shopID = o.getShopID();
             itemCount += (o.getNum() == null ? 0 : o.getNum());
@@ -198,6 +212,7 @@ public class OrderUtil {
         shopOrder.setShouldPayShopAmount(shopProductAmount + shopTaxFee);
         shopOrder.setPayedShopAmount(0D);
         shopOrder.setShopOtherFee(0D);
+        shopOrder.setSvipShopReduction(svipShopReduction);
         if (presentNum == 0 && itemCount == 0)
             shopOrder.setDelFlag("1");// 这个子订单里面的商品全部被拆分走了   这个子订单就没有意义了
     }

+ 9 - 0
src/main/java/com/caimei/modules/svip/entity/CmSvipProduct.java

@@ -32,6 +32,7 @@ public class CmSvipProduct extends DataEntity<CmSvipProduct> {
 	private String costPrice;        // 成本价
 	private String costProportional;        // 比例成本百分比
 	private String costCheckFlag;        // 成本价选中标志:1固定成本 2比例成
+	private Integer svipPriceFlag;		//超级会员价标识
 	
 	public CmSvipProduct() {
 		super();
@@ -177,4 +178,12 @@ public class CmSvipProduct extends DataEntity<CmSvipProduct> {
 	public void setCostCheckFlag(String costCheckFlag) {
 		this.costCheckFlag = costCheckFlag;
 	}
+
+	public Integer getSvipPriceFlag() {
+		return svipPriceFlag;
+	}
+
+	public void setSvipPriceFlag(Integer svipPriceFlag) {
+		this.svipPriceFlag = svipPriceFlag;
+	}
 }

+ 9 - 0
src/main/resources/mappings/modules/bulkpurchase/PurchaseProductMapper.xml

@@ -202,4 +202,13 @@
 						   on csu.userId = #{userId} and csu.delFlag = '0' and now() <![CDATA[ < ]]> csu.endTime
 		where csp.productId = #{productId};
 	</select>
+    <select id="getSvipProduct" resultType="com.caimei.modules.svip.entity.CmSvipProduct">
+		select csp.priceType,
+			   if(csp.id is not null and csu.id is not null, 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
+		where csp.productId = #{productId};
+
+	</select>
 </mapper>

+ 10 - 4
src/main/resources/mappings/modules/order/OrderMapper.xml

@@ -59,7 +59,8 @@
 		a.rebateFlag AS rebateFlag,
 		a.zeroCostFlag AS zeroCostFlag,
 		a.organizeStoreId as organizeStoreId,
-		a.couponAmount as couponAmount
+		a.couponAmount as couponAmount,
+        a.svipFullReduction as svipFullReduction
 	</sql>
 
     <select id="get" resultType="newOrder">
@@ -375,7 +376,8 @@
 			rebateFlag,
 			payStatus,
 			zeroCostFlag,
-			couponAmount
+			couponAmount,
+			svipFullReduction
 		) VALUES (
 			#{orderNo},
 			#{userID},
@@ -426,7 +428,8 @@
 			#{rebateFlag},
 			#{payStatus},
 			#{zeroCostFlag},
-			#{couponAmount}
+			#{couponAmount},
+		    #{svipFullReduction}
 		)
 	</insert>
 
@@ -596,7 +599,10 @@
 				zeroCostFlag = #{zeroCostFlag},
 			</if>
 			<if test="couponAmount != null">
-				couponAmount = #{couponAmount}
+				couponAmount = #{couponAmount},
+			</if>
+			<if test="svipFullReduction != null">
+				svipFullReduction = #{svipFullReduction}
 			</if>
 		</set>
 		where orderID = #{orderID,jdbcType=BIGINT}

+ 15 - 3
src/main/resources/mappings/modules/order/OrderProductMapper.xml

@@ -94,7 +94,11 @@
 		  p.aliasName AS aliasName,
 		  a.singleShouldPayTotalTax AS singleShouldPayTotalTax,
 		  a.heUserId AS heUserId,
-		  p.productCategory as "productCategory"
+		  p.productCategory as "productCategory",
+          a.svipPriceFlag,
+		  a.svipPriceType,
+		  a.svipDiscount,
+		  a.svipReduction
 	</sql>
 
     <sql id="orderProductJoins">
@@ -262,7 +266,11 @@
 		  	status,
 		  	singleShouldPayTotalTax,
 		  	orderPromotionsId,
-		  	ladderPriceFlag
+		  	ladderPriceFlag,
+			svipPriceFlag,
+			svipPriceType,
+			svipDiscount,
+		    svipReduction
 		) VALUES (
 			#{productType},
 			#{orderID},
@@ -322,7 +330,11 @@
 		  	#{status},
 		  	#{singleShouldPayTotalTax},
 		  	#{orderPromotionsId},
-		  	#{ladderPriceFlag}
+		  	#{ladderPriceFlag},
+			#{svipPriceFlag},
+			#{svipPriceType},
+			#{svipDiscount},
+			#{svipReduction}
 			)
 	</insert>
 

+ 8 - 3
src/main/resources/mappings/modules/order/ShopOrderMapper.xml

@@ -139,7 +139,8 @@
     		costType,
     		orderPromotionsId,
 			promotionFullReduction,
-			zeroCostFlag
+			zeroCostFlag,
+		    svipShopReduction
 		) VALUES (
 			#{orderID},
 			#{shopOrderNo},
@@ -194,7 +195,8 @@
     		#{costType},
     		#{orderPromotionsId},
     		#{promotionFullReduction},
-    		#{zeroCostFlag}
+    		#{zeroCostFlag},
+		    #{svipShopReduction}
 		)
 	</insert>
 
@@ -454,7 +456,10 @@
 				promotionFullReduction = #{promotionFullReduction},
 			</if>
 			<if test="zeroCostFlag != null" >
-				zeroCostFlag = #{zeroCostFlag}
+				zeroCostFlag = #{zeroCostFlag},
+			</if>
+			<if test="svipShopReduction != null" >
+                svipShopReduction = #{svipShopReduction}
 			</if>
 		</set>
 		<where>

+ 12 - 5
src/main/webapp/WEB-INF/views/modules/bulkpurchase/orderPurchaseProductForm.jsp

@@ -123,7 +123,8 @@
             <td id="productNo">${purchaseProduct.productNo}</td>
             <td id="shopName" title="${purchaseProduct.shopName}">${fns:abbr(purchaseProduct.shopName,10)}</td>
             <td><label id="priceLabel0"
-                       style="text-decoration: ${purchaseProduct.cmPromotion.mode eq 1?'line-through':''}">${purchaseProduct.price}</label>
+                       style="text-decoration: ${purchaseProduct.svipPriceFlag eq 1 or purchaseProduct.cmPromotion.mode eq 1?'line-through':''}">${purchaseProduct.price}</label>
+                <label id="svipDiscountPrice0"  style="display:none">${purchaseProduct.svipDiscountPrice}</label>
                 <label style="color: red">
                     <c:if test="${(purchaseProduct.includedTax != null and purchaseProduct.includedTax != '' and purchaseProduct.includedTax ne 2)
                          or purchaseProduct.svipPriceFlag eq 1}">
@@ -150,7 +151,7 @@
                        style="width: 50px">%
             </td>
             <td><input name="discountPrice" id="discountPrice0"
-                       value="${empty purchaseProduct.discount ?(purchaseProduct.price):(purchaseProduct.discount)}"
+                       value="${empty purchaseProduct.discount ?(purchaseProduct.svipPriceFlag eq 1?purchaseProduct.svipDiscountPrice: purchaseProduct.price):(purchaseProduct.discount)}"
                        onchange="countDiscount(0)"
                         ${(purchaseProduct.productId ge 6060 and purchaseProduct.productId le 6069)
                         or purchaseProduct.ladderPriceFlag eq 1
@@ -304,13 +305,16 @@
         <td style="display: none">
             <input name="ctx"  id="ctx0" value="${ctx}" readonly  style="width: 80px">
         </td>
+        <td>
+            <input type="text" name="svipReduction" id="svipReduction0" >
+        </td>
         <td style="display: none">
-            <input name="originalPrice" id="originalPrice0" value="${purchaseProduct.originalPrice ne null?purchaseProduct.originalPrice:'0'}">
+            <input name="svipPriceFlag" id="svipPriceFlag0" value="${purchaseProduct.svipPriceFlag ne null?purchaseProduct.svipPriceFlag:'0'}">
         </td>
         <td style="display: none">
-            <input name="svipReduction" id="svipReduction0" value="${purchaseProduct.svipReduction ne null?purchaseProduct.svipReduction:'0'}">
+            <input name="svipPriceType" id="svipPriceType0" value="${purchaseProduct.svipPriceType ne null?purchaseProduct.svipPriceType:'0'}">
         </td>
-        <%--成本价--%>
+<%--        成本价--%>
         <td style="display: none">
             <input name="costPrice"  id="costPrice${state.index}" value="${purchaseProduct.costPrice}" readonly  style="width: 80px">
         </td>
@@ -352,6 +356,7 @@
         $("#price0").val(obj.price);
         $("#discount0").val(obj.discount);
         $("#discountPrice0").val(obj.discountPrice);
+        $("#svipDiscountPrice0").text(obj.discountPrice);
         $("#num0").val(obj.num);
         $("#presentNum0").val(obj.presentNum);
         $("#taxRate0").val(obj.taxRate);
@@ -361,6 +366,8 @@
         $("#totalFee0").val(obj.totalFee);
         $("#otherFee10").val(obj.otherFee1);
         $("#cmFee10").val(obj.cmFee1);
+        $("#svipReduction0").val(obj.svipReduction);
+        $("#svipReduction0").text(obj.svipReduction);
         var buyAgainFlag = obj.buyAgainFlag;
         if (null != buyAgainFlag && 1 == buyAgainFlag) {//表示可以复购
 //                 $("#buyAgainFlag0").val(1);

+ 5 - 2
src/main/webapp/WEB-INF/views/modules/bulkpurchase/orderPurchaseProductList.jsp

@@ -298,8 +298,8 @@
                 <td>${purchaseProduct.productNo}</td>
                 <td title="${purchaseProduct.shopName}">${fns:abbr(purchaseProduct.shopName,10)}</td>
                 <td>
-                    <label id="priceLabel${state.index}" style="text-decoration: ${purchaseProduct.svipPriceFlag eq 1 or purchaseProduct.cmPromotion.mode eq 1?'line-through':'' }">${purchaseProduct.price}</label>
-                    <label id="svipDiscountPrice${state.index}"  style="display:${purchaseProduct.svipPriceFlag eq 1?'':none}">${purchaseProduct.svipDiscountPrice}</label>
+                    <label id="priceLabel${state.index}" style=" ${purchaseProduct.svipPriceFlag eq 1 or purchaseProduct.cmPromotion.mode eq 1?'text-decoration:line-through':'' }">${purchaseProduct.price}</label>
+                    <label id="svipDiscountPrice${state.index}"  style="display:none">${purchaseProduct.svipDiscountPrice}</label>
                     <label style="color: red">
                         <c:if test="${(purchaseProduct.includedTax != null and purchaseProduct.includedTax != '' and purchaseProduct.includedTax ne 2)
                          or purchaseProduct.svipPriceFlag eq 1}">
@@ -495,6 +495,9 @@
                 <td style="display: none">
                     <input name="svipPriceFlag" id="svipPriceFlag${state.index}" value="${purchaseProduct.svipPriceFlag}">
                 </td>
+                <td style="display: none">
+                    <input name="svipPriceType" id="svipPriceType${state.index}" value="${purchaseProduct.svipPriceType}">
+                </td>
                 <td>
                     <c:if test="${purchaseProduct.couponsLogo eq 1}">
                         ----

+ 12 - 3
src/main/webapp/WEB-INF/views/modules/order/orderDetail.jsp

@@ -409,6 +409,11 @@
             </div>
         </td>
     </tr>
+    <c:if test="${order.svipFullReduction gt 0}">
+        <tr>
+            <td>超级会员优惠:¥${order.svipFullReduction}</td>
+        </tr>
+    </c:if>
     <c:if test="${order.promotionFullReduction gt 0 || order.promotionalGiftsCount gt 0}">
         <tr>
             <c:if test="${order.promotionFullReduction gt 0}">
@@ -530,12 +535,16 @@
                     <c:if test="${op.productID ne 999}">
                         <div class="supplier-product-info" >
                             <span>单价:
-                                <c:if test="${op.productPromotion.mode eq 1}">
-                                    <label style="text-decoration: line-through"><fmt:formatNumber value="${op.price}" type="currency"/></label></span>
+                                <c:if test="${op.svipPriceFlag eq 1 or op.productPromotion.mode eq 1}">
+                                    <label style="text-decoration: line-through"><fmt:formatNumber value="${op.price}" type="currency"/></label>
                                 </c:if>
-                                <c:if test="${op.productPromotion.mode ne 1}">
+                                <c:if test="${op.svipPriceFlag ne 1 and op.productPromotion.mode ne 1}">
                                     <fmt:formatNumber value="${op.price}" type="currency"/>
                                 </c:if>
+                                <c:if test="${op.svipPriceFlag eq 1}">
+                                    <label style="margin-left:5px"><fmt:formatNumber value="${op.discountPrice}" type="currency"/></label>
+                                    <font color="red">(超级会员价)</font></span>
+                                </c:if>
                                 <c:if test="${op.ladderPriceFlag eq 1 || op.isActProduct eq 2}">
                                     <a href="javascript:;" class="ladderPrice"><span> (阶梯价格)</span>
                                         <c:if test="${not empty op.orderProductLadderPriceList}">

+ 41 - 8
src/main/webapp/static/modules/bulkpurchase/orderForm.js

@@ -886,8 +886,9 @@ function setProductList(data) {
         "<td class='fix-width'>" + data.name + "</td><td hidden></td>" +
         (data.productCategory == 2 ? "" : ("<td>" + data.shopName + "</td>")) +
         "<td>" + data.num + (data.presentNum > 0 ? "(" + data.presentNum + ")" : "") + "</td>" +
+        (data.svipPriceFlag == 1?"<td>"+data.discountPrice:
         (data.discount * 1 === 100 && data.cmPromotion && data.cmPromotion.mode == 1 ? ("<td><del>" + data.price +
-            "</del>") : ("<td>" + data.price)) +
+            "</del>") : ("<td>" + data.price))) +
         ((data.svipPriceFlag == 1 || (data.includedTax != null && data.includedTax != '' && data.includedTax != 2))?"<label style='color: red'>(":"")+
         (data.svipPriceFlag == 1?"超级会员价":"")+
         ((data.svipPriceFlag == 1 && (data.includedTax != null && data.includedTax != '' && data.includedTax != 2))?",":"")+
@@ -1236,7 +1237,8 @@ function setOrderFee() { //不考虑经理折扣、运费,此时 商品总金
         presentCount = Number(presentCount) + Number(obj.presentNum);
         orderTotalFee = ((Number(orderTotalFee) * 100 + Number(obj.totalFee) * 100) / 100).toFixed(2);
         payTotalFee = ((Number(payTotalFee) * 100 + Number(obj.totalFee) * 100) / 100).toFixed(2);
-        svipFullReduction = ((Number(svipFullReduction) * 100 + Number(obj.svipReduction) * 100) / 100).toFixed(2);
+        debugger
+        svipFullReduction = ((Number(svipFullReduction) * 100 + Number(obj.svipReduction) * obj.num * 100) / 100).toFixed(2);
     });
     $('.productTable tbody tr.promotions').each(function(index, element) {
         var obj = JSON.parse($(this).attr("data-value"));
@@ -1373,8 +1375,13 @@ function discountPriceVal(index) {
             $("#discount" + index).val(obj["discount"]);
             alertx("输入的折扣有误")
         } else {
-            var price = $("#price" + index).val(); //当前价格
-            price = Number(price);
+            var svipPriceFlag = $("#svipPriceFlag" + index).val();
+            var price;
+            if (1 == svipPriceFlag) {
+                price = Number($("#svipDiscountPrice" + index).text());// 拿到超级会员价
+            } else {
+                price = Number($("#price" + index).val()); //拿到单价
+            }
             //折后单价=折扣*当前价格/100
             var discountPrice = ((discount * 100000 * price) / (100 * 100000)).toFixed(2);
             $("#discountPrice" + index).val(discountPrice);
@@ -1401,7 +1408,7 @@ function countDiscount(index) {
     var svipPriceFlag = $("#svipPriceFlag" + index).val(); //是否使用超级会员价
     var price;
     if (1 == svipPriceFlag) {
-        price = Number($("#svipDiscountPrice" + index).val());// 拿到超级会员价
+        price = Number($("#svipDiscountPrice" + index).text());// 拿到超级会员价
     } else {
         price = Number($("#price" + index).val()); //拿到单价
     }
@@ -1475,7 +1482,9 @@ function taxRateVal(index) {
     var obj1 = document.getElementById("priceLabel" + index); //选择商品页面商品单价
     var obj2 = document.getElementById("price"); //设置商品页面商品单价
     var price = obj1 != null ? obj1 : obj2 != null ? obj2 : null;
-    var svipReduction = $("#svipReduction" + index).val() * numVal;
+    var svipDiscountPriceObj = document.getElementById("svipDiscountPrice" + index);
+    var svipReduction = $("#svipReduction" + index).val();
+    var svipPriceFlag = $("#svipPriceFlag" + index).val();
 
     if (includedTax != '' && includedTax == 0 && invoiceType == 3) {
         //不含税不能开票商品,税率置为0
@@ -1558,6 +1567,7 @@ function taxRateVal(index) {
         $checkItem["payTotalFee"] = totalFee + ""; //重新设置应付
         $checkItem["costPrice"] = costPrice + ""; //重新设置成本
         $checkItem["svipReduction"] = svipReduction + ""; //重新设置超级会员优惠
+        $("#svipReduction0").val(svipReduction);
         // console.log("data" + index + ":" + JSON.stringify($checkItem));
         $("#check-item" + index).val(JSON.stringify($checkItem));
     } else {
@@ -1650,10 +1660,17 @@ function taxRateVal(index) {
             $checkItem["totalFee"] = totalFee + ""; //重新设置总价
             $checkItem["payTotalFee"] = totalFee + ""; //重新设置应付
             $checkItem["costPrice"] = costPrice + ""; //重新设置成本
-            $checkItem["svipReduction"] = svipReduction + ""; //重新设置超级会员优惠
             $("#taxRateLabel").val(taxRate);
             $("#addedValueTaxLabel").val(0)
             $("#totalAddedValueTaxLabel").val(0)
+            if (svipPriceFlag == 1) {
+                // 折扣价重新计算超级会员优惠
+                var svipDiscountPrice = $("#svipDiscountPrice" + index).text();
+                var originalPrice = $("#price" + index).val();
+                svipReduction = originalPrice - svipDiscountPrice;
+            }
+            $checkItem["svipReduction"] = svipReduction + ""; //重新设置超级会员优惠
+            $("#svipReduction0").val(svipReduction);
             // console.log("data" + index + ":" + JSON.stringify($checkItem));
             $("#check-item" + index).val(JSON.stringify($checkItem));
         } else if (taxRate > 100) {
@@ -1756,6 +1773,15 @@ function taxRateVal(index) {
                     //供应商税费(总) = 供应商税费(单)*数量
                     shouldPayTotalTax = (singleShouldPayTotalTax * numVal).toFixed(2);
                 }
+                if (svipPriceFlag == 1) {
+                    // 折扣价重新计算超级会员优惠
+                    var svipDiscountPrice = $("#svipDiscountPrice" + index).text();
+                    var originalPrice = $("#price" + index).val();
+                    svipReduction = ((originalPrice - svipDiscountPrice) + (originalPrice - svipDiscountPrice) * taxRate / 100).toFixed(2);
+                }
+                $checkItem["svipReduction"] = svipReduction + ""; //重新设置超级会员优惠
+                $("#svipReduction0").val(svipReduction);
+
                 $("#addedValueTax" + index).val(addedValueTax);
                 $("#totalAddedValueTax" + index).val(totalAddedValueTax);
                 $("#totalFee" + index).val(totalFee);
@@ -1770,7 +1796,6 @@ function taxRateVal(index) {
                 $checkItem["totalFee"] = totalFee + ""; //重新设置总价
                 $checkItem["payTotalFee"] = totalFee + ""; //重新设置应付
                 $checkItem["costPrice"] = costPrice + ""; //重新设置成本
-                $checkItem["svipReduction"] = svipReduction + ""; //重新设置超级会员优惠
                 $("#taxRateLabel").val(taxRate);
                 $("#addedValueTaxLabel").val(addedValueTax)
                 $("#totalAddedValueTaxLabel").val(totalAddedValueTax)
@@ -1784,9 +1809,17 @@ function taxRateVal(index) {
         }
     }
 
+    if (svipPriceFlag == 1) {
+        if (price != null) {
+            price.style.cssText = "text-decoration: line-through";
+            svipDiscountPriceObj.style.cssText = "display:''";
+        }
+    }
+
     singeGiveNum(index);
     shopFee(index); //优化功能开启刷新应付供应商
     otherFee(index);
+
 }
 
 // 添加赠品数