Pārlūkot izejas kodu

采美sku bugfix

zhijiezhao 2 gadi atpakaļ
vecāks
revīzija
86d08ebfee

+ 21 - 20
src/main/java/com/caimei/modules/bulkpurchase/web/PurchaseProductController.java

@@ -106,8 +106,17 @@ public class PurchaseProductController extends BaseController {
                     p.setCouponsLogo(1);
                 }
                 List<CmSku> skuList = productDao.findSkuList(p.getProductId().intValue());
+                skuList.forEach(s -> {
+                    if (1 == s.getLadderPriceFlag()) {
+                        s.setLadderPriceList(productDao.findLadderPriceBySku(s.getSkuId()));
+                    }
+                });
                 p.setSkuId(skuList.get(0).getSkuId());
                 p.setPrice(skuList.get(0).getPrice().toString());
+                if (1 == skuList.get(0).getLadderPriceFlag()) {
+                    p.setLadderPriceFlag(1);
+                    p.setLadderPriceList(productDao.findLadderPrice(skuList.get(0).getSkuId()));
+                }
                 p.setSkuList(skuList);
                 long productId = p.getProductId();
                 String discountPrice = p.getPrice();//默认折扣单价
@@ -333,6 +342,11 @@ public class PurchaseProductController extends BaseController {
                 List<CmSku> skus = productDao.findSkuList(product.getProductID());
                 purchaseProduct.setSkuId(skus.get(0).getSkuId());
                 purchaseProduct.setPrice(skus.get(0).getPrice().toString());
+                skus.forEach(s -> {
+                    if (1 == s.getLadderPriceFlag()) {
+                        s.setLadderPriceList(productDao.findLadderPriceBySku(s.getSkuId()));
+                    }
+                });
                 purchaseProduct.setSkuList(skus);
                 CmSvipProduct svipProduct = purchaseProductService.getSvipProduct(purchaseProduct.getProductId(), purchaseProduct.getUserId());
                 CmPromotion productPromotion = cmPromotionService.findProductPromotion(product.getShopID().toString(), Long.parseLong(product.getProductID().toString()));
@@ -342,29 +356,16 @@ public class PurchaseProductController extends BaseController {
                 } else if (productPromotion != null) {
                     purchaseProduct.setCmPromotion(productPromotion);
                 } else {
-//                    if ("1".equals(product.getLadderPriceFlag())) {
-//                        purchaseProduct.setLadderPriceFlag(1);
-//                        // 查询阶梯价格
-//                        List<ProductLadderPrice> ladderPriceList = purchaseProductService.findLadderPriceList(purchaseProduct.getProductId());
-//                        if (null != ladderPriceList && ladderPriceList.size() > 0) {
-//                            purchaseProduct.setPrice(ladderPriceList.get(0).getBuyPrice().toString());
-//                            purchaseProduct.setNum(ladderPriceList.get(0).getBuyNum().toString());
-//                            IntStream.range(0, ladderPriceList.size()).forEach(i -> {
-//                                if (i == ladderPriceList.size() - 1) {
-//                                    ladderPriceList.get(i).setBuyNumRangeShow("≥" + ladderPriceList.get(i).getBuyNum());
-//                                } else {
-//                                    String buyNumRangeShow = ladderPriceList.get(i).getBuyNum() + "~" + (ladderPriceList.get(i + 1).getBuyNum() - 1);
-//                                    ladderPriceList.get(i).setBuyNumRangeShow(buyNumRangeShow);
-//                                }
-//                            });
-//                            purchaseProduct.setLadderPriceList(ladderPriceList);
-//                        } else {
-                            purchaseProduct.setLadderPriceFlag(0);
-//                        }
-//                    }
+                    if (1 == skus.get(0).getLadderPriceFlag()) {
+                        purchaseProduct.setLadderPriceFlag(1);
+                        purchaseProduct.setLadderPriceList(productDao.findLadderPrice(skus.get(0).getSkuId()));
+                    } else {
+                        purchaseProduct.setLadderPriceFlag(0);
+                    }
                 }
             }
         }
+
         model.addAttribute("purchaseProduct", purchaseProduct);
         return "modules/bulkpurchase/orderPurchaseProductForm";
     }

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

@@ -963,7 +963,6 @@ public class NewOrderService extends CrudService<NewOrderDao, NewOrder> {
                 orderProductLadderPrice.setBuyNum(ladderPrice.getBuyNum());
                 orderProductLadderPrice.setBuyPrice(new BigDecimal(ladderPrice.getBuyPrice()));
                 orderProductLadderPrice.setCreateDate(new Date());
-                orderProductLadderPrice.setLadderNum(ladderPrice.getLadderNum().intValue());
                 orderProductLadderPriceList.add(orderProductLadderPrice);
             });
         }

+ 3 - 1
src/main/java/com/caimei/modules/product/dao/ProductDao.java

@@ -202,7 +202,9 @@ public interface ProductDao extends CrudDao<Product> {
 
     List<CmSku> findSkuList(Integer productID);
 
-    List<CmLadderPrice> findLadderPriceBySku(@Param("skuId") Integer skuId, @Param("productId") Integer productId);
+    List<CmLadderPrice> findLadderPriceBySku(Integer skuId);
+
+    List<ProductLadderPrice> findLadderPrice(Integer skuId);
 
     Product getBySku(String skuId);
 

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

@@ -640,7 +640,7 @@ public class ProductService extends CrudService<ProductDao, Product> {
     public List<CmSku> findSkuList(Integer productID) {
         List<CmSku> skus = productDao.findSkuList(productID);
         skus.forEach(s -> {
-            s.ladderPriceList(productDao.findLadderPriceBySku(s.skuId(), s.productId()));
+            s.ladderPriceList(productDao.findLadderPriceBySku(s.skuId()));
         });
         return skus;
     }

+ 2 - 1
src/main/resources/mappings/modules/hehe/CmHeheActivityProductMapper.xml

@@ -185,9 +185,10 @@
     </select>
 
     <select id="findDiscountSku" resultType="com.caimei.modules.product.entity.CmSku">
-        select chds.discountPrice, chds.productId, chds.skuId, chs.price
+        select chds.discountPrice, chds.productId, chds.skuId, chs.price, cs.unit
         from cm_hehe_discount_activity_sku chds
                  left join cm_hehe_sku chs on chds.skuId = chs.skuId
+                 left join cm_sku cs on chs.skuId = cs.skuId
         where chds.productId = #{productId}
     </select>
 

+ 12 - 3
src/main/resources/mappings/modules/product/ProductMapper.xml

@@ -2020,13 +2020,22 @@
     <select id="findLadderPriceBySku" resultType="com.caimei.modules.product.entity.CmLadderPrice">
         select skuId, productId, userType, ladderNum, buyNum, buyPrice, delFlag
         FROM product_ladder_price
-        WHERE productId = #{productId}
-          AND userType = 3
+        WHERE userType = 3
           AND skuId = #{skuId}
           AND buyNum is NOT null
           AND buyPrice is NOT null
           AND delFlag = 0
-        ORDER BY ladderNum ASC
+        ORDER BY buyNum ASC
+    </select>
+    <select id="findLadderPrice" resultType="com.caimei.po.ProductLadderPrice">
+        select skuId, productId, userType, ladderNum, buyNum, buyPrice, delFlag
+        FROM product_ladder_price
+        WHERE userType = 3
+          AND skuId = #{skuId}
+          AND buyNum is NOT null
+          AND buyPrice is NOT null
+          AND delFlag = 0
+        ORDER BY buyNum ASC
     </select>
     <select id="getBySku" resultType="com.caimei.modules.product.entity.Product">
         SELECT

+ 14 - 4
src/main/webapp/WEB-INF/views/modules/bulkpurchase/orderPurchaseProductForm.jsp

@@ -161,7 +161,8 @@
                     or purchaseProduct.svipPriceFlag eq 1?'readonly="readonly"':''}
                        style="width: 50px">%
             </td>
-            <td><input name="discountPrice" id="discountPrice0"
+            <td><input id="oldPrice0" type="hidden" value="${purchaseProduct.price}">
+                <input name="discountPrice" id="discountPrice0"
                        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)
@@ -173,7 +174,7 @@
                         <div class="list">
                             <p><span>起订量</span><span>价格</span></p>
                             <c:forEach items="${purchaseProduct.ladderPriceList}" var="ladderPrice">
-                                <p data-num="${ladderPrice.buyNum}"><span>${ladderPrice.buyNumRangeShow}</span><span
+                                <p data-num="${ladderPrice.buyNum}"><span>${ladderPrice.buyNum}</span><span
                                         class="price">${ladderPrice.buyPrice}</span></p>
                             </c:forEach>
                         </div>
@@ -186,8 +187,8 @@
                     <button class="decrease" onclick="presentNum('0','del')">-</button>
                     <input type="text" name="num" id="num0" class="input-mini" style="width: 25px"
                            onchange="changenum(0)"
-                           min="${purchaseProduct.ladderPriceFlag eq 1?purchaseProduct.ladderPriceList[0].buyNum:1}"
-                           value="${(not empty orderProduct.num)?(orderProduct.num):(purchaseProduct.ladderPriceFlag eq 1?purchaseProduct.ladderPriceList[0].buyNum:1)}">
+                           min="1"
+                           value="${(not empty orderProduct.num)?(orderProduct.num):1}">
                     <button class="increase" onclick="presentNum('0','add')">+</button>
                 </c:if>
                 <c:if test="${purchaseProduct.secondHandType eq 1 }">
@@ -514,6 +515,15 @@
                 base += discountPrice * taxRate / 100;
             }
         }
+        if(1==skus[skuIndex].ladderPriceFlag){
+            $checkItem["ladderPriceFlag"] = 1;
+            $checkItem["ladderPriceList"] = skus[skuIndex].ladderPriceList;
+            $(".ladderPrice").show();
+        }else{
+            $checkItem["ladderPriceFlag"] = 0;
+            $checkItem["ladderPriceList"] = {};
+            $(".ladderPrice").hide();
+        }
         $checkItem["addedValueTax"] = tax;
         $checkItem["totalAddedValueTax"] = tax * num;
         $("#addedValueTax0").val(tax);

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

@@ -332,6 +332,15 @@
                     base += discountPrice * taxRate / 100;
                 }
             }
+            if(1==skus[skuIndex].ladderPriceFlag){
+                $checkItem["ladderPriceFlag"] = 1;
+                $checkItem["ladderPriceList"] = skus[skuIndex].ladderPriceList;
+                $(".ladderPrice").show();
+            }else{
+                $checkItem["ladderPriceFlag"] = 0;
+                $checkItem["ladderPriceList"] = {};
+                $(".ladderPrice").hide();
+            }
             $checkItem["addedValueTax"] = tax;
             $checkItem["totalAddedValueTax"] = tax * num;
             $("#addedValueTax" + ind).val(tax);
@@ -460,6 +469,7 @@
                            style="width: 50px">%
                 </td>
                 <td>
+                    <input id="oldPrice${state.index}" type="hidden" value="${purchaseProduct.price}">
                     <input name="discountPrice" id="discountPrice${state.index}"
                            value="${empty purchaseProduct.discount ?(purchaseProduct.svipPriceFlag eq 1?purchaseProduct.svipDiscountPrice: purchaseProduct.price):(purchaseProduct.discount)}"
                            onchange="countDiscount(${state.index})"
@@ -472,7 +482,7 @@
                             <div class="list">
                                 <p><span>起订量</span><span>价格</span></p>
                                 <c:forEach items="${purchaseProduct.ladderPriceList}" var="ladderPrice">
-                                    <p data-num="${ladderPrice.buyNum}"><span>${ladderPrice.buyNumRangeShow}</span><span
+                                    <p data-num="${ladderPrice.buyNum}"><span>${ladderPrice.buyNum}</span><span
                                             class="price">${ladderPrice.buyPrice}</span></p>
                                 </c:forEach>
                             </div>
@@ -484,7 +494,7 @@
                     <input type="number" name="num" id="num${state.index}" style="width: 25px"
                            min="${purchaseProduct.ladderPriceFlag eq 1?purchaseProduct.ladderPriceList[0].buyNum:1}"
                            onchange="changenum(${state.index})"
-                           value="${(not empty purchaseProduct.num)?(purchaseProduct.num):(purchaseProduct.ladderPriceFlag eq 1?purchaseProduct.ladderPriceList[0].buyNum:1)}">
+                           value="${(not empty purchaseProduct.num)?(purchaseProduct.num):1}">
                     <button class="increase" onclick="presentNum('${state.index}','add')">+</button>
                 </td>
                 <c:choose>

+ 4 - 1
src/main/webapp/WEB-INF/views/modules/hehe/cmHeheActivityProductList.jsp

@@ -156,7 +156,10 @@
                     var params = $jboxFrame[0].contentWindow.onclickSave();
                     console.log(params);
                     if (params != false) {
-                        $.get("${ctx}/hehe/cmHeheActivityProduct/saveActivityLadder?params=" + params + "&id=" + id, function (data) {
+                        $.post("${ctx}/hehe/cmHeheActivityProduct/saveActivityLadder", {
+                            'params': params,
+                            'id': id
+                        }, function (data) {
                             if (true == data.success) {
                                 $.jBox.tip(data.info, 'info');
                                 setTimeout(function () {

+ 1 - 1
src/main/webapp/WEB-INF/views/modules/hehe/heheDiscountActivityProductForm.jsp

@@ -73,7 +73,7 @@
         <c:forEach items="${heheDiscountActivityProduct.skus}" var="sku" varStatus="index">
             <div class="control-group" style="display:flex">
                 <input type="hidden" value="${sku.skuId}" name="sku[${index.index}].skuId">
-                <label class="control-label"><font color="red">*</font>规格:规格${index.index+1}</label>
+                <label class="control-label"><font color="red">*</font>规格:${sku.unit}</label>
                 <label class="control-label"><font color="red">*</font>售价:</label>
                 <input type="number" style="width:100px;" disabled="true" min="0" id="price"
                        name="sku[${index.index}].price"

+ 1 - 1
src/main/webapp/WEB-INF/views/modules/order/orderForm.jsp

@@ -427,7 +427,7 @@
                                         <p><span>起订量</span><span>价格</span></p>
                                         <c:forEach items="${orderProduct.ladderPriceList}" var="ladderPrice">
                                             <p data-num="${ladderPrice.buyNum}">
-                                                <span>${ladderPrice.buyNumRangeShow}</span><span
+                                                <span>${ladderPrice.buyNum}</span><span
                                                     class="price">${ladderPrice.buyPrice}</span></p>
                                         </c:forEach>
                                     </div>

+ 1 - 1
src/main/webapp/WEB-INF/views/modules/order/printOrder.jsp

@@ -118,7 +118,7 @@
                 </td>
                 <td class=xl65>${orderProduct.discountPrice}</td>
                 <td class=xl65>${orderProduct.num}(${orderProduct.presentNum})</td>
-                <td class=xl65>${orderProduct.unit}</td>
+                <td class=xl65>${orderProduct.productUnit}</td>
                 <td class=xl65>${orderProduct.preferential}</td>
                 <td class=xl65>${orderProduct.totalAddedValueTax}</td>
                 <td class=xl65>${orderProduct.totalFee}</td>

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

@@ -930,7 +930,7 @@ function setProductList(data, flag, ind) {
                 var ladder = '<p><span>起订量</span><span>价格</span></p>';
                 for (var i = 0; i < data.ladderPriceList.length; i++) {
                     ladder += '<p data-num="' + data.ladderPriceList[i].buyNum + '"><span>' + data.ladderPriceList[i]
-                            .buyNumRangeShow + '</span><span class="price">' + data.ladderPriceList[i].buyPrice +
+                            .buyNum + '</span><span class="price">' + data.ladderPriceList[i].buyPrice +
                         '</span></p>';
                 }
                 ladderPrice = '<br><a href="javascript:;" class="ladderPrice"><span>阶梯价格</span><div class="list">' +
@@ -1448,6 +1448,7 @@ function presentNum(index, type) {
 
 function setLadderPrice(obj, numVal, index) {
     if (obj["ladderPriceFlag"] * 1 === 1) {
+        debugger;
         var ladderList = obj["ladderPriceList"];
         var resultLadder = 0;
         for (var i = 0; i < ladderList.length; i++) {
@@ -1460,6 +1461,12 @@ function setLadderPrice(obj, numVal, index) {
         $("#check-item" + index).parents("tr").find("#price" + index).val(ladderList[resultLadder]["buyPrice"]);
         $("#check-item" + index).parents("tr").find("#priceLabel" + index).text(ladderList[resultLadder]["buyPrice"]);
         $("#check-item" + index).parents("tr").find("#discountPrice" + index).val(ladderList[resultLadder]["buyPrice"]);
+        if(numVal<ladderList[0]["buyNum"]){
+            var old=$("#oldPrice"+index).val();
+            $("#check-item" + index).parents("tr").find("#price" + index).val(old);
+            $("#check-item" + index).parents("tr").find("#priceLabel" + index).text(old);
+            $("#check-item" + index).parents("tr").find("#discountPrice" + index).val(old);
+        }
     }
 }