Browse Source

呵呵sku bugfix

zhijiezhao 2 năm trước cách đây
mục cha
commit
e0b461cb21

+ 2 - 2
src/main/java/com/caimei/mapper/OrderSubmitMapper.java

@@ -121,10 +121,10 @@ public interface OrderSubmitMapper {
     /**
      * 根据商品id查询供应商信息
      *
-     * @param productId
+     * @param skuId
      * @return
      */
-    ShopVo findShopByProductId(Integer productId);
+    ShopVo findShopByProductId(Integer skuId);
 
     /**
      * 查询商品信息

+ 3 - 0
src/main/java/com/caimei/model/po/CmHeheCollagePo.java

@@ -14,6 +14,9 @@ import java.util.Date;
  */
 @Data
 public class CmHeheCollagePo implements Serializable {
+
+    private Integer skuId;
+
     private Integer id;
     /**
      * 拼团商品id

+ 3 - 2
src/main/java/com/caimei/service/impl/OrderSubmitServiceImpl.java

@@ -60,9 +60,9 @@ public class OrderSubmitServiceImpl implements OrderSubmitService {
         List<ShopVo> shopList = new ArrayList<>();
         List<String> productIdList = new ArrayList<>();
         Integer onlinePay = 0;
-        if (productId != null && productId > 0) {
+        if (skuId != null && skuId > 0) {
             //立即购买
-            ShopVo shop = orderSubmitMapper.findShopByProductId(productId);
+            ShopVo shop = orderSubmitMapper.findShopByProductId(skuId);
             if (StringUtils.isEmpty(shop.getSplitCode())) {
                 // 商品未填写分账号,不支持线上支付
                 onlinePay = -1;
@@ -712,6 +712,7 @@ public class OrderSubmitServiceImpl implements OrderSubmitService {
                     TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                     return ResponseJson.error("拼团商品异常", null);
                 }
+                collage.setSkuId(orderProductPo.getSkuId());
                 collage.setProductId(collageProduct.getProductId());
                 collage.setMemberNum(collageProduct.getMemberNum());
                 collage.setPrice(collageProduct.getPrice());

+ 68 - 31
src/main/resources/mapper/CollageMapper.xml

@@ -17,69 +17,106 @@
         where id = #{id}
     </update>
 
-    <insert id="insertCollage" useGeneratedKeys="true" keyProperty="id" keyColumn="id" parameterType="com.caimei.model.po.CmHeheCollagePo">
-        insert into cm_hehe_collage (productId, price, memberNum, status, startTime, completeTime, endTime)
-        values (#{productId}, #{price}, #{memberNum}, #{status}, #{startTime}, null, #{endTime})
+    <insert id="insertCollage" useGeneratedKeys="true" keyProperty="id" keyColumn="id"
+            parameterType="com.caimei.model.po.CmHeheCollagePo">
+        insert into cm_hehe_collage (productId, price, memberNum, status, startTime, completeTime, endTime, skuId)
+        values (#{productId}, #{price}, #{memberNum}, #{status}, #{startTime}, null, #{endTime}, #{skuId})
     </insert>
     <insert id="insertCollageMember">
-        insert into cm_hehe_collage_member (collageId, userId, orderId, launchFlag) values (#{collageId}, #{userId}, #{orderId}, #{launchFlag})
+        insert into cm_hehe_collage_member (collageId, userId, orderId, launchFlag)
+        values (#{collageId}, #{userId}, #{orderId}, #{launchFlag})
     </insert>
 
     <select id="findCollageProduct" resultType="com.caimei.model.po.CmHeheCollageProductPo">
-        select chcp.productid, chcs.collagePrice as price, chcp.limitednum, chcp.unlimitedflag, chcp.membernum, chcp.status
+        select chcp.productid,
+               chcs.collagePrice as price,
+               chcp.limitednum,
+               chcp.unlimitedflag,
+               chcp.membernum,
+               chcp.status
         from cm_hehe_collage_product chcp
-        left join cm_hehe_collage_sku chcs on chcp.productId = chcs.productId
-        where chcs.skuId = #{skuId} and chcp.status = 1
+                 left join cm_hehe_collage_sku chcs on chcp.productId = chcs.productId
+        where chcs.skuId = #{skuId}
+          and chcp.status = 1
     </select>
     <select id="findCollage" resultType="com.caimei.model.po.CmHeheCollagePo">
-        select id, productId, price, memberNum, status, startTime, completeTime, endTime
-        from cm_hehe_collage where id = #{collageId} and status = 1
+        select id,
+               productId,
+               price,
+               memberNum,
+               status,
+               startTime,
+               completeTime,
+               endTime
+        from cm_hehe_collage
+        where id = #{collageId}
+          and status = 1
     </select>
     <select id="findCollageMemberNum" resultType="java.lang.Integer">
-        select count(*) from cm_hehe_collage_member chcm left join cm_order co on chcm.orderId = co.orderID
-        where collageId = #{collageId} and co.receiptStatus = 3
+        select count(*)
+        from cm_hehe_collage_member chcm
+                 left join cm_order co on chcm.orderId = co.orderID
+        where collageId = #{collageId}
+          and co.receiptStatus = 3
     </select>
     <select id="getCollageByOrderId" resultType="com.caimei.model.po.CmHeheCollagePo">
-        select chc.id,chcm.launchFlag,chc.memberNum from cm_hehe_collage chc left join cm_hehe_collage_member chcm on chc.id = chcm.collageId
+        select chc.id, chcm.launchFlag, chc.memberNum
+        from cm_hehe_collage chc
+                 left join cm_hehe_collage_member chcm on chc.id = chcm.collageId
         where chcm.orderId = #{orderId}
     </select>
     <select id="getCollageDetails" resultType="com.caimei.model.vo.CollageDetailsVo">
         select chc.skuId,
-               chc.id                           as collageId,
+               chc.id                                                                                     as collageId,
                chc.productId,
-               p.mainImage                      as productImage,
-               p.name                           as productName,
-               chc.price                        as price,
-               (select price from cm_hehe_sku where productId=chc.productId order by price asc limit 1) as normalPrice,
+               p.mainImage                                                                                as productImage,
+               p.name                                                                                     as productName,
+               chc.price                                                                                  as price,
+               (select price
+                from cm_hehe_sku
+                where productId = chc.productId
+                order by price asc
+                limit 1)                                                                                  as normalPrice,
                chc.memberNum,
-               count(chcm.id)                   as existNum,
-               (chc.memberNum - count(chcm.id)) as needNum,
+               count(chcm.id)                                                                             as existNum,
+               (chc.memberNum - count(chcm.id))                                                           as needNum,
                chc.endTime,
                chc.status,
                limitedNum,
                unlimitedFlag
         from cm_hehe_collage chc
-        left join cm_hehe_collage_member chcm on chc.id = chcm.collageId
-        left join cm_order co on chcm.orderId = co.orderID
-            left join cm_hehe_collage_product chcp on chc.productId = chcp.productId
-        left join product p on chcp.productId = p.productID
+                 left join cm_hehe_collage_member chcm on chc.id = chcm.collageId
+                 left join cm_order co on chcm.orderId = co.orderID
+                 left join cm_hehe_collage_product chcp on chc.productId = chcp.productId
+                 left join product p on chcp.productId = p.productID
         where chc.id = #{collageId}
           and co.receiptStatus = 3
     </select>
     <select id="findNoPayCollageOrderIds" resultType="java.lang.Integer">
-        select co.orderID from cm_hehe_collage_member chcm left join cm_order co on chcm.orderId = co.orderID
-        where co.receiptStatus = 1 and chcm.collageId = #{collageId}
+        select co.orderID
+        from cm_hehe_collage_member chcm
+                 left join cm_order co on chcm.orderId = co.orderID
+        where co.receiptStatus = 1
+          and chcm.collageId = #{collageId}
     </select>
     <select id="getMemberOrderId" resultType="java.lang.Integer">
-        select orderId from cm_hehe_collage_member where collageId = #{collageId} and userId = #{userId}
+        select orderId
+        from cm_hehe_collage_member
+        where collageId = #{collageId}
+          and userId = #{userId}
     </select>
     <select id="getUserMobileByOrderId" resultType="java.lang.String">
-        select u.mobile from cm_hehe_user u left join cm_order co on u.userId = co.userID where co.orderID = #{orderId}
+        select u.mobile
+        from cm_hehe_user u
+                 left join cm_order co on u.userId = co.userID
+        where co.orderID = #{orderId}
     </select>
     <select id="getMobilesByCollageId" resultType="java.lang.String">
-        select chu.mobile from cm_hehe_collage_member chcm
-            left join cm_order co on chcm.orderId = co.orderID
-            left join cm_hehe_user chu on chcm.userId = chu.userId
-        where collageId = #{collageId} and co.receiptStatus = 3
+        select chu.mobile
+        from cm_hehe_collage_member chcm
+                 left join cm_order co on chcm.orderId = co.orderID
+                 left join cm_hehe_user chu on chcm.userId = chu.userId
+        where collageId = #{collageId}
+          and co.receiptStatus = 3
     </select>
 </mapper>

+ 1 - 1
src/main/resources/mapper/OrderSubmitMapper.xml

@@ -1584,7 +1584,7 @@
         FROM cm_hehe_product chp
                  LEFT JOIN product p ON chp.productId = p.productID
                  LEFT JOIN shop s ON p.shopID = s.shopID
-        WHERE chp.productId = #{productId}
+        WHERE chp.productId =  (SELECT productId FROM cm_hehe_sku WHERE skuId=#{skuId})
           AND chp.validFlag = 1
     </select>