瀏覽代碼

呵呵商城拼团/分享减免part3

Aslee 3 年之前
父節點
當前提交
73bb155674

+ 10 - 0
src/main/java/com/caimei/model/po/ReductionUserPo.java

@@ -33,5 +33,15 @@ public class ReductionUserPo implements Serializable {
      */
      */
     private Integer reductionUserId;
     private Integer reductionUserId;
 
 
+    /**
+     * 减免金额
+     */
+    private BigDecimal reducedAmount;
+
+    /**
+     * 减免条件
+     */
+    private BigDecimal touchPrice;
+
     private static final long serialVersionUID = 1L;
     private static final long serialVersionUID = 1L;
 }
 }

+ 15 - 0
src/main/java/com/caimei/model/vo/CollageDetailsVo.java

@@ -73,4 +73,19 @@ public class CollageDetailsVo implements Serializable {
      * 规格
      * 规格
      */
      */
     private String unit;
     private String unit;
+
+    /**
+     * 拼团状态:0拼团中(拼主未支付) 1拼团中,2已拼成
+     */
+    private Integer status;
+
+    /**
+     * 单人限购量
+     */
+    private Integer limitedNum;
+
+    /**
+     * 不限购买量标识:1不限制,0限制
+     */
+    private Integer unlimitedFlag;
 }
 }

+ 8 - 2
src/main/java/com/caimei/model/vo/OrderVo.java

@@ -5,6 +5,7 @@ import lombok.Data;
 
 
 import java.io.Serializable;
 import java.io.Serializable;
 import java.math.BigDecimal;
 import java.math.BigDecimal;
+import java.util.Date;
 import java.util.List;
 import java.util.List;
 
 
 /**
 /**
@@ -242,7 +243,7 @@ public class OrderVo implements Serializable {
     /**
     /**
      * 是否为拼团订单
      * 是否为拼团订单
      */
      */
-    private boolean collageFlag = false;
+    private Boolean collageFlag = false;
 
 
     /**
     /**
      * 拼团id
      * 拼团id
@@ -250,10 +251,15 @@ public class OrderVo implements Serializable {
     private Integer collageId;
     private Integer collageId;
 
 
     /**
     /**
-     * 拼团状态:1拼团中,2已拼成
+     * 拼团状态:0拼团中(拼主未支付)1拼团中,2已拼成
      */
      */
     private Integer collageStatus;
     private Integer collageStatus;
 
 
+    /**
+     * 拼团状态:拼团结束时间
+     */
+    private Date collageEndTime;
+
     /**
     /**
      * 分享减免金额
      * 分享减免金额
      */
      */

+ 3 - 3
src/main/java/com/caimei/model/vo/UserInfoVo.java

@@ -32,17 +32,17 @@ public class UserInfoVo implements Serializable {
     /**
     /**
      * 省、直辖市
      * 省、直辖市
      */
      */
-    private String province;
+    private String provinceName;
 
 
     /**
     /**
      * 市
      * 市
      */
      */
-    private String city;
+    private String cityName;
 
 
     /**
     /**
      * 县、区
      * 县、区
      */
      */
-    private String town;
+    private String townName;
 
 
     /**
     /**
      * 收货地址
      * 收货地址

+ 63 - 36
src/main/java/com/caimei/service/impl/OrderServiceImpl.java

@@ -61,29 +61,7 @@ public class OrderServiceImpl implements OrderService {
     private void getOrderData(List<OrderVo> orderList) {
     private void getOrderData(List<OrderVo> orderList) {
         for (OrderVo order : orderList) {
         for (OrderVo order : orderList) {
             //111,待付待收待发
             //111,待付待收待发
-            if ("11".equals(order.getStatus()) && "1".equals(order.getPayStatus())) {
-                order.setStatus("111");
-            }
-            //判断交易全退情况下,是否发过货,77,交易全退可以查看物流
-            List<LogisticsBatchVo> batchList = orderMapper.findLogistics(order.getOrderId());
-            if ("7".equals(order.getStatus()) && batchList != null && batchList.size() > 0) {
-                order.setStatus("77");
-            }
-            //部分付款/已付款订单,设置拼团状态
-            if ((order.getStatus().startsWith("2") || order.getStatus().startsWith("3")) && null != order.getCollageStatus()) {
-                if (1 == order.getCollageStatus()) {
-                    // 拼团中
-                    order.setStatus("81");
-                } else if (2 == order.getCollageStatus()) {
-                    if (order.getStatus().endsWith("1") || order.getStatus().endsWith("2")) {
-                        // 拼团成功,待发货
-                        order.setStatus("82");
-                    } else if (order.getStatus().endsWith("3")) {
-                        // 拼团成功,已发货
-                        order.setStatus("83");
-                    }
-                }
-            }
+            setOrderStatus(order);
             List<ShopOrderVo> shopOrderList = orderMapper.findAllShopOrder(order.getOrderId());
             List<ShopOrderVo> shopOrderList = orderMapper.findAllShopOrder(order.getOrderId());
             for (ShopOrderVo shopOrder : shopOrderList) {
             for (ShopOrderVo shopOrder : shopOrderList) {
                 List<OrderProductVo> orderProductList = orderMapper.findOrderProduct(shopOrder.getShopOrderId());
                 List<OrderProductVo> orderProductList = orderMapper.findOrderProduct(shopOrder.getShopOrderId());
@@ -95,7 +73,7 @@ public class OrderServiceImpl implements OrderService {
                         orderProduct.setPrice(MathUtil.add(orderProduct.getPrice(), valueTax));
                         orderProduct.setPrice(MathUtil.add(orderProduct.getPrice(), valueTax));
                         orderProduct.setDiscountPrice(MathUtil.add(orderProduct.getPrice(), orderProduct.getAddedValueTax()));
                         orderProduct.setDiscountPrice(MathUtil.add(orderProduct.getPrice(), orderProduct.getAddedValueTax()));
                     }
                     }
-                    if (order.getStatus().startsWith("8")) {
+                    if (order.getCollageFlag()) {
                         orderProduct.setCollagePriceFlag(1);
                         orderProduct.setCollagePriceFlag(1);
                     }
                     }
                 }
                 }
@@ -121,15 +99,7 @@ public class OrderServiceImpl implements OrderService {
             return ResponseJson.error("该订单已删除", null);
             return ResponseJson.error("该订单已删除", null);
         }
         }
         order.setOrderMark("#" + order.getOrderId() + "#");
         order.setOrderMark("#" + order.getOrderId() + "#");
-        //111,待付待收待发
-        if ("11".equals(order.getStatus()) && "1".equals(order.getPayStatus())) {
-            order.setStatus("111");
-        }
-        //判断交易全退情况下,是否发过货,77,交易全退可以查看物流
-        List<LogisticsBatchVo> batchList = orderMapper.findLogistics(orderId);
-        if ("7".equals(order.getStatus()) && batchList != null && batchList.size() > 0) {
-            order.setStatus("77");
-        }
+        setOrderStatus(order);
         //商品信息
         //商品信息
         List<ShopOrderVo> shopOrderList = orderMapper.findAllShopOrder(orderId);
         List<ShopOrderVo> shopOrderList = orderMapper.findAllShopOrder(orderId);
         BigDecimal expensesOfTaxation = new BigDecimal(0);
         BigDecimal expensesOfTaxation = new BigDecimal(0);
@@ -172,6 +142,10 @@ public class OrderServiceImpl implements OrderService {
                     orderProduct.setPrice(MathUtil.add(orderProduct.getPrice(), valueTax));
                     orderProduct.setPrice(MathUtil.add(orderProduct.getPrice(), valueTax));
                     orderProduct.setDiscountPrice(MathUtil.add(orderProduct.getDiscountPrice(), orderProduct.getAddedValueTax()));
                     orderProduct.setDiscountPrice(MathUtil.add(orderProduct.getDiscountPrice(), orderProduct.getAddedValueTax()));
                 }
                 }
+                // 拼团价标识
+                if (order.getCollageFlag()) {
+                    orderProduct.setCollagePriceFlag(1);
+                }
             }
             }
             shopOrder.setOrderProductList(orderProductList);
             shopOrder.setOrderProductList(orderProductList);
             shopOrder.setShopLogo(ProductUtils.getImageURL("shopLogo", shopOrder.getShopLogo(), 0, domain));
             shopOrder.setShopLogo(ProductUtils.getImageURL("shopLogo", shopOrder.getShopLogo(), 0, domain));
@@ -192,6 +166,37 @@ public class OrderServiceImpl implements OrderService {
         return ResponseJson.success(map);
         return ResponseJson.success(map);
     }
     }
 
 
+    private void setOrderStatus(OrderVo order) {
+        Integer orderId = order.getOrderId();
+        //111,待付待收待发
+        if ("11".equals(order.getStatus()) && "1".equals(order.getPayStatus())) {
+            order.setStatus("111");
+        }
+        //判断交易全退情况下,是否发过货,77,交易全退可以查看物流
+        List<LogisticsBatchVo> batchList = orderMapper.findLogistics(orderId);
+        if ("7".equals(order.getStatus()) && batchList != null && batchList.size() > 0) {
+            order.setStatus("77");
+        }
+        //部分付款/已付款订单,设置拼团状态
+        if ((order.getStatus().startsWith("2") || order.getStatus().startsWith("3")) && null != order.getCollageStatus()) {
+            if (1 == order.getCollageStatus()) {
+                // 拼团中
+                order.setStatus("81");
+            } else if (2 == order.getCollageStatus()) {
+                if (order.getStatus().endsWith("1") || order.getStatus().endsWith("2")) {
+                    // 拼团成功,待发货
+                    order.setStatus("82");
+                } else if (order.getStatus().endsWith("3")) {
+                    // 拼团成功,已发货
+                    order.setStatus("83");
+                }
+            } else if (0 == order.getCollageStatus() && new Date().compareTo(order.getCollageEndTime()) > 0) {
+                // 拼团结束,关闭订单
+                order.setStatus("6");
+            }
+        }
+    }
+
     @Override
     @Override
     public ResponseJson<List<LogisticsBatchVo>> logistics(Integer orderId) {
     public ResponseJson<List<LogisticsBatchVo>> logistics(Integer orderId) {
         OrderVo order = orderMapper.findOrder(orderId);
         OrderVo order = orderMapper.findOrder(orderId);
@@ -405,13 +410,35 @@ public class OrderServiceImpl implements OrderService {
     @Override
     @Override
     public ResponseJson<CollageDetailsVo> collageDetails(Integer collageId, Integer userId) {
     public ResponseJson<CollageDetailsVo> collageDetails(Integer collageId, Integer userId) {
         CollageDetailsVo collageDetails = collageMapper.getCollageDetails(collageId);
         CollageDetailsVo collageDetails = collageMapper.getCollageDetails(collageId);
+        ProductDetailsVo product = productMapper.findProductByProductId(collageDetails.getProductId());
+        // 拼团价
+        product.setPrice(collageDetails.getPrice());
+        collageDetails.setUnit(product.getUnit());
         if (null != userId && userId > 0) {
         if (null != userId && userId > 0) {
             Integer orderId = collageMapper.getMemberOrderId(collageId, userId);
             Integer orderId = collageMapper.getMemberOrderId(collageId, userId);
             collageDetails.setOrderId(orderId);
             collageDetails.setOrderId(orderId);
-            ProductDetailsVo product = productMapper.findProductByProductId(collageDetails.getProductId());
-            productService.setProductDetails(product, userId);
+            // 内部优惠
+            Integer discount = productMapper.findProductDiscount(product.getProductId(), userId);
+            if (null != discount && discount > 0) {
+                product.setPrice(MathUtil.div(MathUtil.mul(product.getPrice(), discount), 100));
+                if (null != product.getNormalPrice()) {
+                    product.setNormalPrice(MathUtil.div(MathUtil.mul(product.getNormalPrice(), discount), 100));
+                }
+            }
+            //税费
+            boolean addTaxFlag = ("0".equals(product.getIncludedTax()) && ("1".equals(product.getInvoiceType()) || "2".equals(product.getInvoiceType())));
+            if (addTaxFlag) {
+                BigDecimal addedValueTax = MathUtil.div(MathUtil.mul(product.getPrice(), product.getClubTaxPoint()), BigDecimal.valueOf(100), 2);
+                BigDecimal price = MathUtil.add(product.getPrice(), addedValueTax);
+                product.setPrice(price);
+                if (null != product.getNormalPrice()) {
+                    addedValueTax = MathUtil.div(MathUtil.mul(product.getNormalPrice(), product.getClubTaxPoint()), BigDecimal.valueOf(100), 2);
+                    price = MathUtil.add(product.getNormalPrice(), addedValueTax);
+                    product.setNormalPrice(price);
+                }
+            }
             collageDetails.setPrice(product.getPrice());
             collageDetails.setPrice(product.getPrice());
-            collageDetails.setUnit(product.getUnit());
+            collageDetails.setNormalPrice(product.getNormalPrice());
         }
         }
         return ResponseJson.success(collageDetails);
         return ResponseJson.success(collageDetails);
     }
     }

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

@@ -132,8 +132,8 @@ public class OrderSubmitServiceImpl implements OrderSubmitService {
         if (null != currentReduction) {
         if (null != currentReduction) {
             // 查询已分享次数
             // 查询已分享次数
             Integer shareNum = orderSubmitMapper.findShareNum(userId, currentReduction.getReductionId());
             Integer shareNum = orderSubmitMapper.findShareNum(userId, currentReduction.getReductionId());
-            if ((null == collageFlag || 0 == collageFlag) && shareNum < currentReduction.getShareNum() && MathUtil.compare(totalPrice.get(), currentReduction.getTouchPrice()) > 0) {
-                // 有剩余分享次数且订单金额大于分享条件金额
+            if ((null == collageFlag || 0 == collageFlag) && shareNum < currentReduction.getShareNum() && MathUtil.compare(totalPrice.get(), currentReduction.getTouchPrice()) >= 0) {
+                // 有剩余分享次数且订单金额大于等于分享条件金额
                 confirmData.put("reduction", currentReduction);
                 confirmData.put("reduction", currentReduction);
             }
             }
         }
         }
@@ -326,7 +326,10 @@ public class OrderSubmitServiceImpl implements OrderSubmitService {
         Integer couponShareId = (Integer) discountInfo.get("couponShareId");
         Integer couponShareId = (Integer) discountInfo.get("couponShareId");
         if (null != couponId && couponId > 0) {
         if (null != couponId && couponId > 0) {
             receiveCouponId = couponMapper.findReceiveCouponId(userId, couponId, couponShareId);
             receiveCouponId = couponMapper.findReceiveCouponId(userId, couponId, couponShareId);
-            List<CouponVo> receiveCouponList = couponMapper.findReceiveCouponList(userId, null, receiveCouponId, 1);
+            List<CouponVo> receiveCouponList = null;
+            if (null != receiveCouponId) {
+                receiveCouponList = couponMapper.findReceiveCouponList(userId, null, receiveCouponId, 1);
+            }
             if (receiveCouponList == null || receiveCouponList.size() <= 0) {
             if (receiveCouponList == null || receiveCouponList.size() <= 0) {
                 // 设置手动回滚事务
                 // 设置手动回滚事务
                 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
@@ -335,6 +338,7 @@ public class OrderSubmitServiceImpl implements OrderSubmitService {
                 coupon = receiveCouponList.get(0);
                 coupon = receiveCouponList.get(0);
             }
             }
             couponAmount = coupon.getCouponAmount();
             couponAmount = coupon.getCouponAmount();
+            log.info("优惠券抵扣金额:" + couponAmount);
         }
         }
         order.setCouponAmount(couponAmount);
         order.setCouponAmount(couponAmount);
         // 处理分享减免
         // 处理分享减免
@@ -514,6 +518,7 @@ public class OrderSubmitServiceImpl implements OrderSubmitService {
          */
          */
         if (null != receiveCouponId && receiveCouponId > 0) {
         if (null != receiveCouponId && receiveCouponId > 0) {
             // 修改优惠券使用情况
             // 修改优惠券使用情况
+            log.info("保存优惠券使用情况:" + receiveCouponId + ":" + order.getOrderID());
             orderSubmitMapper.updateReceiveCouponStatus(receiveCouponId, order.getOrderID());
             orderSubmitMapper.updateReceiveCouponStatus(receiveCouponId, order.getOrderID());
             CouponOrderRecordPo orderRecord = new CouponOrderRecordPo();
             CouponOrderRecordPo orderRecord = new CouponOrderRecordPo();
             orderRecord.setOrderId(order.getOrderID().intValue());
             orderRecord.setOrderId(order.getOrderID().intValue());
@@ -548,6 +553,12 @@ public class OrderSubmitServiceImpl implements OrderSubmitService {
                 collage.setMemberNum(collageProduct.getMemberNum());
                 collage.setMemberNum(collageProduct.getMemberNum());
                 collage.setPrice(collageProduct.getPrice());
                 collage.setPrice(collageProduct.getPrice());
                 collage.setStatus(0);
                 collage.setStatus(0);
+                Date startTime = new Date();
+                collage.setStartTime(startTime);
+                Calendar calendar = Calendar.getInstance();
+                calendar.setTime(startTime);
+                calendar.add(Calendar.DAY_OF_MONTH, 1);
+                collage.setEndTime(calendar.getTime());
                 collageMapper.insertCollage(collage);
                 collageMapper.insertCollage(collage);
                 collageId = collage.getId();
                 collageId = collage.getId();
                 collageMember.setLaunchFlag(1);
                 collageMember.setLaunchFlag(1);
@@ -587,6 +598,8 @@ public class OrderSubmitServiceImpl implements OrderSubmitService {
         info.put("payTotalFee", String.valueOf(order.getPayTotalFee()));
         info.put("payTotalFee", String.valueOf(order.getPayTotalFee()));
         //真实需要付款金额
         //真实需要付款金额
         info.put("payableAmount", String.valueOf(order.getPayableAmount()));
         info.put("payableAmount", String.valueOf(order.getPayableAmount()));
+        //拼团id
+        info.put("collageId", String.valueOf(collageId));
         return ResponseJson.success(info);
         return ResponseJson.success(info);
     }
     }
 
 
@@ -601,6 +614,9 @@ public class OrderSubmitServiceImpl implements OrderSubmitService {
                 ReductionUserPo reductionUserPo = new ReductionUserPo();
                 ReductionUserPo reductionUserPo = new ReductionUserPo();
                 reductionUserPo.setUserId(userId);
                 reductionUserPo.setUserId(userId);
                 reductionUserPo.setReductionId(reductionId);
                 reductionUserPo.setReductionId(reductionId);
+                reductionUserPo.setReducedAmount(currentReduction.getReducedAmount());
+                reductionUserPo.setTouchPrice(currentReduction.getTouchPrice());
+                reductionUserPo.setReductionId(reductionId);
                 reductionUserPo.setShareType(shareType);
                 reductionUserPo.setShareType(shareType);
                 orderSubmitMapper.insertReductionUser(reductionUserPo);
                 orderSubmitMapper.insertReductionUser(reductionUserPo);
                 return ResponseJson.success("分享成功", reductionUserPo.getReductionUserId());
                 return ResponseJson.success("分享成功", reductionUserPo.getReductionUserId());

+ 2 - 6
src/main/java/com/caimei/service/impl/ProductServiceImpl.java

@@ -67,7 +67,7 @@ public class ProductServiceImpl implements ProductService {
     public void setProductDetails(ProductVo product, Integer userId) {
     public void setProductDetails(ProductVo product, Integer userId) {
         product.setMainImage(ProductUtils.getImageURL("product", product.getMainImage(), 0, domain));
         product.setMainImage(ProductUtils.getImageURL("product", product.getMainImage(), 0, domain));
         Integer activityId = productMapper.findActivityByProductId(product.getProductId());
         Integer activityId = productMapper.findActivityByProductId(product.getProductId());
-        // 拼团
+        // 拼团商品
         CmHeheCollageProductPo collageProduct = productMapper.findCollageProduct(product.getProductId());
         CmHeheCollageProductPo collageProduct = productMapper.findCollageProduct(product.getProductId());
         if (activityId != null && activityId > 0) {
         if (activityId != null && activityId > 0) {
             product.setActiveStatus(1);
             product.setActiveStatus(1);
@@ -79,15 +79,11 @@ public class ProductServiceImpl implements ProductService {
                 product.setPrice(1 == ladder.getBuyNum() ? ladder.getBuyPrice() : product.getPrice());
                 product.setPrice(1 == ladder.getBuyNum() ? ladder.getBuyPrice() : product.getPrice());
             }
             }
         } else if (collageProduct != null) {
         } else if (collageProduct != null) {
+            // 拼团价
             product.setNormalPrice(product.getPrice());
             product.setNormalPrice(product.getPrice());
             product.setPrice(collageProduct.getPrice());
             product.setPrice(collageProduct.getPrice());
             product.setCollageStatus(1);
             product.setCollageStatus(1);
             product.setCollageProduct(collageProduct);
             product.setCollageProduct(collageProduct);
-            if (collageProduct.getUnlimitedFlag() == 0) {
-                // 设置拼团商品可购买数量
-                Integer productBuyNum = productMapper.findProductBuyNum(product.getProductId(), userId);
-                collageProduct.setLimitedNum(collageProduct.getLimitedNum() - productBuyNum);
-            }
         }
         }
         Integer discount = productMapper.findProductDiscount(product.getProductId(), userId);
         Integer discount = productMapper.findProductDiscount(product.getProductId(), userId);
         if (null != discount && discount > 0) {
         if (null != discount && discount > 0) {

+ 16 - 4
src/main/resources/mapper/CollageMapper.xml

@@ -19,7 +19,7 @@
 
 
     <insert id="insertCollage" useGeneratedKeys="true" keyProperty="id" keyColumn="id" parameterType="com.caimei.model.po.CmHeheCollagePo">
     <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)
         insert into cm_hehe_collage (productId, price, memberNum, status, startTime, completeTime, endTime)
-        values (#{productId}, #{price}, #{memberNum}, #{status}, null, null, null)
+        values (#{productId}, #{price}, #{memberNum}, #{status}, #{startTime}, null, #{endTime})
     </insert>
     </insert>
     <insert id="insertCollageMember">
     <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})
@@ -43,15 +43,27 @@
         where chcm.orderId = #{orderId}
         where chcm.orderId = #{orderId}
     </select>
     </select>
     <select id="getCollageDetails" resultType="com.caimei.model.vo.CollageDetailsVo">
     <select id="getCollageDetails" resultType="com.caimei.model.vo.CollageDetailsVo">
-        select chc.id as collageId,chc.productId, p.mainImage as productImage,p.name as productName,chc.price,chp.price as normalPrice,
-               chc.memberNum,count(chcm.id) as existNum,(chc.memberNum-count(chcm.id)) as needNum,
-               chc.endTime
+        select chc.id                           as collageId,
+               chc.productId,
+               p.mainImage                      as productImage,
+               p.name                           as productName,
+               chc.price,
+               chp.price                        as normalPrice,
+               chc.memberNum,
+               count(chcm.id)                   as existNum,
+               (chc.memberNum - count(chcm.id)) as needNum,
+               chc.endTime,
+               chc.status,
+               limitedNum,
+               unlimitedFlag
         from cm_hehe_collage chc
         from cm_hehe_collage chc
                  left join cm_hehe_collage_member chcm on chc.id = chcm.collageId
                  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 cm_hehe_collage_product chcp on chc.productId = chcp.productId
                  left join product p on chcp.productId = p.productID
                  left join product p on chcp.productId = p.productID
                  left join cm_hehe_product chp on p.productID = chp.productId
                  left join cm_hehe_product chp on p.productID = chp.productId
         where chc.id = #{collageId}
         where chc.id = #{collageId}
+          and co.receiptStatus = 3
     </select>
     </select>
     <select id="findNoPayCollageOrderIds" resultType="java.lang.Integer">
     <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
         select co.orderID from cm_hehe_collage_member chcm left join cm_order co on chcm.orderId = co.orderID

+ 2 - 2
src/main/resources/mapper/CouponMapper.xml

@@ -130,7 +130,7 @@
                 from cm_hehe_coupon_product
                 from cm_hehe_coupon_product
                 group by couponId) chcp on chrc.couponId = chcp.couponId
                 group by couponId) chcp on chrc.couponId = chcp.couponId
         where chrc.delFlag = 0 and chc.delFlag = 0 and chrc.userId = #{userId}
         where chrc.delFlag = 0 and chc.delFlag = 0 and chrc.userId = #{userId}
-        <if test="receiveCouponId != null and receiveCouponId>0">
+        <if test="receiveCouponId != null and receiveCouponId > 0">
             and chrc.id = #{receiveCouponId}
             and chrc.id = #{receiveCouponId}
         </if>
         </if>
         <if test="productIdArr != null and productIdArr.length > 0">
         <if test="productIdArr != null and productIdArr.length > 0">
@@ -203,7 +203,7 @@
         from cm_hehe_receive_coupon
         from cm_hehe_receive_coupon
         where userId = #{userId}
         where userId = #{userId}
         and couponId = #{couponId}
         and couponId = #{couponId}
-        <if test="couponShareId != null">
+        <if test="couponShareId != null and couponShareId > 0">
             and couponShareId = #{couponShareId}
             and couponShareId = #{couponShareId}
         </if>
         </if>
     </select>
     </select>

+ 24 - 18
src/main/resources/mapper/OrderMapper.xml

@@ -39,7 +39,8 @@
           co.reductionAmount,
           co.reductionAmount,
           if(chcm.id is not null,true,false) as collageFlag,
           if(chcm.id is not null,true,false) as collageFlag,
           chc.id as collageId,
           chc.id as collageId,
-          chc.status as collageStatus
+          chc.status as collageStatus,
+          chc.endTime as collageEndTime
     </sql>
     </sql>
     <select id="findOrderList" resultType="com.caimei.model.vo.OrderVo">
     <select id="findOrderList" resultType="com.caimei.model.vo.OrderVo">
         select
         select
@@ -65,7 +66,7 @@
             AND co.refundType IN(1,2)
             AND co.refundType IN(1,2)
         </if>
         </if>
         <if test="orderState == 5">
         <if test="orderState == 5">
-            AND chcm.id is not null and chc.status = 1
+            AND chcm.id is not null and co.refundType not in (1,2) and chc.status = 1
         </if>
         </if>
         ORDER BY co.orderTime DESC
         ORDER BY co.orderTime DESC
     </select>
     </select>
@@ -172,9 +173,9 @@
           name,
           name,
           shouHuoRen,
           shouHuoRen,
           mobile,
           mobile,
-          province,
-          city,
-          town,
+          province as provinceName,
+          city as cityName,
+          town as townName,
           address
           address
         FROM
         FROM
           bp_order_userinfo
           bp_order_userinfo
@@ -467,24 +468,29 @@
         SELECT
         SELECT
         COUNT(*)
         COUNT(*)
         FROM
         FROM
-        cm_order
+        cm_order co
+        left join cm_hehe_collage_member chcm on co.orderID = chcm.orderId
+        left join cm_hehe_collage chc on chcm.collageId = chc.id
         WHERE
         WHERE
-        userId = #{userId}
-        AND delFlag = '0'
+        co.userId = #{userId}
+        AND co.delFlag = '0'
         <if test="status == 0">
         <if test="status == 0">
-            AND status = '0'
+            AND co.status = '0'
         </if>
         </if>
-        <if test="status == 1">
-            AND status IN(11,12,13,21,22,23)
+        <if test="status == 1 ">
+            AND co.status IN(11,12,13,21,22,23)
         </if>
         </if>
-        <if test="status == 2">
-            AND status IN(11,12,21,22,31,32)
+        <if test="status == 2 ">
+            AND co.status IN(11,12,21,22,31,32)
         </if>
         </if>
-        <if test="status == 3">
-            AND status IN(12,13,22,23,32,33)
+        <if test="status == 3 ">
+            AND co.status IN(12,13,22,23,32,33)
+        </if>
+        <if test="status == 4 ">
+            AND co.refundType IN(1,2)
         </if>
         </if>
-        <if test="status == 4">
-            AND refundType IN(1,2)
+        <if test="status == 5">
+            AND chcm.id is not null and co.refundType not in (1,2) and chc.status = 1
         </if>
         </if>
     </select>
     </select>
 
 
@@ -525,7 +531,7 @@
             AND co.refundType IN(1,2)
             AND co.refundType IN(1,2)
         </if>
         </if>
         <if test="orderState == 5">
         <if test="orderState == 5">
-            AND chcm.id is not null and chc.status = 1
+            AND chcm.id is not null and co.refundType not in (1,2) and chc.status = 1
         </if>
         </if>
         <if test="searchWord != null and searchWord != ''">
         <if test="searchWord != null and searchWord != ''">
             AND cop.name LIKE CONCAT('%',#{searchWord},'%')
             AND cop.name LIKE CONCAT('%',#{searchWord},'%')

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

@@ -1531,8 +1531,8 @@
         VALUES (#{orderId}, #{receiveCouponId}, #{couponType}, #{couponAmount}, #{touchPrice}, #{createDate})
         VALUES (#{orderId}, #{receiveCouponId}, #{couponType}, #{couponAmount}, #{touchPrice}, #{createDate})
     </insert>
     </insert>
     <insert id="insertReductionUser" keyColumn="id" keyProperty="reductionUserId" parameterType="com.caimei.model.po.ReductionUserPo" useGeneratedKeys="true">
     <insert id="insertReductionUser" keyColumn="id" keyProperty="reductionUserId" parameterType="com.caimei.model.po.ReductionUserPo" useGeneratedKeys="true">
-        insert into cm_hehe_reduction_user (userId, reductionId, shareType, shareTime)
-        values (#{userId}, #{reductionId}, #{shareType}, NOW())
+        insert into cm_hehe_reduction_user (userId, reductionId, shareType, touchPrice, reductionAmount, shareTime)
+        values (#{userId}, #{reductionId}, #{shareType}, #{touchPrice}, #{reducedAmount}, NOW())
     </insert>
     </insert>
 
 
     <select id="findShopByProductId" resultType="com.caimei.model.vo.ShopVo">
     <select id="findShopByProductId" resultType="com.caimei.model.vo.ShopVo">
@@ -1603,7 +1603,7 @@
           and reductionId = #{reductionId}
           and reductionId = #{reductionId}
     </select>
     </select>
     <select id="findReduction" resultType="com.caimei.model.vo.ReductionVo">
     <select id="findReduction" resultType="com.caimei.model.vo.ReductionVo">
-        select chr.id as reductionId, reducedAmount, chhtouchPrice from cm_hehe_reduction chr
+        select chr.id as reductionId, reducedAmount, chr.touchPrice from cm_hehe_reduction chr
             left join cm_hehe_reduction_user chru on chr.id = chru.reductionId
             left join cm_hehe_reduction_user chru on chr.id = chru.reductionId
         where chru.id = #{reductionUserId} and chru.orderId is null
         where chru.id = #{reductionUserId} and chru.orderId is null
     </select>
     </select>

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

@@ -317,7 +317,7 @@
         where chcp.productId = #{productID} and chcp.status = 1
         where chcp.productId = #{productID} and chcp.status = 1
     </select>
     </select>
     <select id="findProductBuyNum" resultType="java.lang.Integer">
     <select id="findProductBuyNum" resultType="java.lang.Integer">
-        select count(cop.num) from cm_hehe_collage_member chcm
+        select ifnull(sum(cop.num),0) from cm_hehe_collage_member chcm
             left join cm_hehe_collage chc on chcm.collageId = chc.id
             left join cm_hehe_collage chc on chcm.collageId = chc.id
             left join cm_order_product cop on chcm.orderId = cop.orderID
             left join cm_order_product cop on chcm.orderId = cop.orderID
         where chc.productId = #{productId} and chcm.userId = #{userId}
         where chc.productId = #{productId} and chcm.userId = #{userId}