jyy
2021-03-19 c16b9ffceac828840ef7ebc4827612d17906704a
积分商城9
10 files modified
224 ■■■■ changed files
zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShoppingCartAction.java 2 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/ShoppingCartService.java 58 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WXShopOrderServiceImpl.java 1 ●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/shopXcx/api/vo/ShopCartBillVo.java 12 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/shopXcx/api/vo/ShopCartVo.java 12 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/shopXcx/bean/ShopOrderDetails.java 59 ●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/shopXcx/bean/ShopShoppingCart.java 26 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/resources/config/db/increment/推广员.sql 6 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/resources/mybatis/mapper/xcxShop/ShopOrderDetailsDao.xml 46 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/resources/mybatis/mapper/xcxShop/ShopShoppingCartDao.xml 2 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShoppingCartAction.java
@@ -8,6 +8,7 @@
import com.matrix.core.pojo.AjaxResult;
import com.matrix.core.tools.StringUtils;
import com.matrix.system.common.constance.AppConstance;
import com.matrix.system.common.interceptor.HostInterceptor;
import com.matrix.system.shopXcx.api.service.ShoppingCartService;
import com.matrix.system.shopXcx.api.service.WxShopCouponService;
import com.matrix.system.shopXcx.api.vo.ShopCartBillVo;
@@ -129,6 +130,7 @@
        shoppingCart.setCreateBy(loginUser.getOpenId());
        shoppingCart.setUpdateBy(loginUser.getOpenId());
        shoppingCart.setCartUserId(loginUser.getOpenId());
        shoppingCart.setCompanyId(HostInterceptor.getCompanyId());
        ShopShoppingCart shoppCartLimt = shoppingCartDao.selectBuyLimit(shoppingCart.getCartProductId(),
                shoppingCart.getCartSkuId());
        // Integer buyLimitNum = 0;
zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/ShoppingCartService.java
@@ -2,6 +2,7 @@
import com.matrix.biz.bean.BizUser;
import com.matrix.component.redis.RedisUserLoginUtils;
import com.matrix.core.exception.GlobleException;
import com.matrix.core.tools.LogUtil;
import com.matrix.system.common.dao.BusParameterSettingsDao;
import com.matrix.system.shopXcx.api.vo.ShopCartBillVo;
@@ -36,11 +37,7 @@
    public ShopCartBillVo buildShopCartBillVo(List<ShopCartVo> cartList) {
        ShopCartBillVo shopCartBillVo = new ShopCartBillVo();
        //计算购车选中项总价以及优惠金额
        BigDecimal billTotal = BigDecimal.ZERO;
        BigDecimal billCouponTotal = BigDecimal.ZERO;
        //未优惠之前的金额
        BigDecimal srcTotal = BigDecimal.ZERO;
        //计算是否存在选中的产品
        Integer selectCount = 0;
@@ -68,6 +65,7 @@
        }
        shopCartBillVo.setCartCount(cartCount);
        shopCartBillVo.setSelectCount(selectCount);
        return shopCartBillVo;
    }
@@ -114,19 +112,23 @@
        //查询购物车中的产品匹配上的所有优惠活动
        for (ShopShoppingCart shoppingCart : list) {
            List<ShopCoupon> shopCoupons = shopCouponService.getHdListByProductId(shoppingCart.getCartProductId());
            if (CollectionUtils.isNotEmpty(shopCoupons)) {
                // 把所有的优惠券和购物车条目先关联一下,后续可以计算优惠升级的情况
                shoppingCart.setShopCoupons(shopCoupons);
                for (ShopCoupon shopCoupon : shopCoupons) {
                    shopCouponMap.put(shopCoupon.getId(), shopCoupon);
                }
            } else {
                // 该产品没有参加优惠券
            if(shoppingCart.getCartType()==ShopShoppingCart.CAR_TYPE_SCORE){
                // 积分兑换产品不参加优惠
                def.getCartList().add(shoppingCart);
            }else{
                List<ShopCoupon> shopCoupons = shopCouponService.getHdListByProductId(shoppingCart.getCartProductId());
                if (CollectionUtils.isNotEmpty(shopCoupons)) {
                    // 把所有的优惠券和购物车条目先关联一下,后续可以计算优惠升级的情况
                    shoppingCart.setShopCoupons(shopCoupons);
                    for (ShopCoupon shopCoupon : shopCoupons) {
                        shopCouponMap.put(shopCoupon.getId(), shopCoupon);
                    }
                } else {
                    // 该产品没有参加优惠券
                    def.getCartList().add(shoppingCart);
                }
            }
        }
        //计算没有优惠组的价格
@@ -268,13 +270,28 @@
        List<ShopShoppingCart> cartList = shopCartVo.getCartList();
        // 计算总价
        BigDecimal sum = BigDecimal.ZERO;
        //抵扣总积分
        BigDecimal scoreSum = BigDecimal.ZERO;
        // 选中项总价
        BigDecimal selectSum = BigDecimal.ZERO;
        for (ShopShoppingCart shopShoppingCart : cartList) {
            sum = sum.add(shopShoppingCart.getPrice().multiply(BigDecimal.valueOf(shopShoppingCart.getCartNumber())));
            if (shopShoppingCart.getIsSelected() == 1) {
                selectSum = selectSum
                        .add(shopShoppingCart.getPrice().multiply(BigDecimal.valueOf(shopShoppingCart.getCartNumber())));
            if(ShopShoppingCart.CAR_TYPE_MICRO==shopShoppingCart.getCartType()){
                //直接购买
                sum = sum.add(shopShoppingCart.getPrice().multiply(BigDecimal.valueOf(shopShoppingCart.getCartNumber())));
                if (shopShoppingCart.getIsSelected() == 1) {
                    selectSum = selectSum
                            .add(shopShoppingCart.getPrice().multiply(BigDecimal.valueOf(shopShoppingCart.getCartNumber())));
                }
            }else if(ShopShoppingCart.CAR_TYPE_SCORE==shopShoppingCart.getCartType()){
                //积分兑换
                sum = sum.add(shopShoppingCart.getScorePrice().multiply(BigDecimal.valueOf(shopShoppingCart.getCartNumber())));
                if (shopShoppingCart.getIsSelected() == 1) {
                    selectSum = selectSum
                            .add(shopShoppingCart.getScorePrice().multiply(BigDecimal.valueOf(shopShoppingCart.getCartNumber())));
                    scoreSum = scoreSum.add(new BigDecimal(shopShoppingCart.getScoreCount() * shopShoppingCart.getCartNumber()));
                }
            }else{
                throw new GlobleException("参数错误");
            }
        }
@@ -309,5 +326,6 @@
                shopCartVo.setSrcPrice(selectSum);
                shopCartVo.setSatisfactionCoupon(true);
        }
        shopCartVo.setScorePay(scoreSum);
    }
}
zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WXShopOrderServiceImpl.java
@@ -175,6 +175,7 @@
            shopOrderDetails.setpId(shopShoppingCart.getCartProductId());
            shopOrderDetails.setsId(shopShoppingCart.getCartSkuId());
            shopOrderDetails.setPrice(shopShoppingCart.getPrice());
            shopOrderDetails.setPayType(shopShoppingCart.getCartType());
            shopOrderDetails.setCount(shopShoppingCart.getCartNumber());
            shopOrderDetails.setsTitle(shopShoppingCart.getTitle() + shopShoppingCart.getName());
            shopOrderDetails.setDiscountAmount(BigDecimal.ZERO);
zq-erp/src/main/java/com/matrix/system/shopXcx/api/vo/ShopCartBillVo.java
@@ -26,6 +26,18 @@
     * 未优惠之前的总金额
     */
    private BigDecimal srcTotal = BigDecimal.ZERO;
    /**
     * 抵用积分
     */
    private BigDecimal scorePay = BigDecimal.ZERO;
    public BigDecimal getScorePay() {
        return scorePay;
    }
    public void setScorePay(BigDecimal scorePay) {
        this.scorePay = scorePay;
    }
    public BigDecimal getBillTotal() {
        return billTotal;
zq-erp/src/main/java/com/matrix/system/shopXcx/api/vo/ShopCartVo.java
@@ -39,6 +39,10 @@
    //优惠金额
    private BigDecimal  couponPrice=BigDecimal.ZERO;
    /**
     * 抵用积分
     */
    private BigDecimal scorePay = BigDecimal.ZERO;
    public ShopCoupon getCoupon() {
        return coupon;
@@ -92,6 +96,14 @@
        return couponPrice;
    }
    public BigDecimal getScorePay() {
        return scorePay;
    }
    public void setScorePay(BigDecimal scorePay) {
        this.scorePay = scorePay;
    }
    public void setCouponPrice(BigDecimal couponPrice) {
        this.couponPrice = couponPrice;
    }
zq-erp/src/main/java/com/matrix/system/shopXcx/bean/ShopOrderDetails.java
@@ -1,7 +1,7 @@
package com.matrix.system.shopXcx.bean;
import com.matrix.core.pojo.EntityDTO;
import com.matrix.core.anotations.Extend;
import com.matrix.core.pojo.EntityDTO;
import java.math.BigDecimal;
@@ -10,6 +10,7 @@
 * @author jyy
 * @date 2019-06-10 10:58
 */
public class ShopOrderDetails  extends EntityDTO{
    @Extend
    private static final long serialVersionUID = 1L;
@@ -51,7 +52,22 @@
     * 单价
     */
    private BigDecimal price;
    /**
     * 总价
     */
    private BigDecimal  totalPrice;
    /**
     * 支付积分单价
     */
    private BigDecimal scoreCount;
    /**
     * 支付总积分
     */
    private BigDecimal totalScoreCount;
    
    /**
     * 数量
@@ -62,12 +78,7 @@
     */
    private Integer  payType;
    /**
     * 总价
     */
    private BigDecimal  totalPrice;
    
    /**
     * 规格标题
@@ -144,12 +155,28 @@
        this.price = price;
    }
    public Integer getPayType() {
        return payType;
    public BigDecimal getTotalPrice() {
        return totalPrice;
    }
    public void setPayType(Integer payType) {
        this.payType = payType;
    public void setTotalPrice(BigDecimal totalPrice) {
        this.totalPrice = totalPrice;
    }
    public BigDecimal getScoreCount() {
        return scoreCount;
    }
    public void setScoreCount(BigDecimal scoreCount) {
        this.scoreCount = scoreCount;
    }
    public BigDecimal getTotalScoreCount() {
        return totalScoreCount;
    }
    public void setTotalScoreCount(BigDecimal totalScoreCount) {
        this.totalScoreCount = totalScoreCount;
    }
    public Integer getCount() {
@@ -160,12 +187,12 @@
        this.count = count;
    }
    public BigDecimal getTotalPrice() {
        return totalPrice;
    public Integer getPayType() {
        return payType;
    }
    public void setTotalPrice(BigDecimal totalPrice) {
        this.totalPrice = totalPrice;
    public void setPayType(Integer payType) {
        this.payType = payType;
    }
    public String getsTitle() {
zq-erp/src/main/java/com/matrix/system/shopXcx/bean/ShopShoppingCart.java
@@ -82,6 +82,16 @@
     */
    @Extend
    private BigDecimal price;
    /**
     * 积分兑换所需支付金额
     */
    @Extend
    private BigDecimal scorePrice;
    /**
     * 积分兑换所需支付积分
     */
    @Extend
    private Integer scoreCount;
    /**
     * 产品手机端封面地址
@@ -180,6 +190,22 @@
        this.increaseAndDecrease = increaseAndDecrease;
    }
    public BigDecimal getScorePrice() {
        return scorePrice;
    }
    public void setScorePrice(BigDecimal scorePrice) {
        this.scorePrice = scorePrice;
    }
    public Integer getScoreCount() {
        return scoreCount;
    }
    public void setScoreCount(Integer scoreCount) {
        this.scoreCount = scoreCount;
    }
    public Integer getModifyCartNumber() {
        return modifyCartNumber;
    }
zq-erp/src/main/resources/config/db/increment/推广员.sql
@@ -193,8 +193,6 @@
ALTER TABLE `shop_shopping_cart`
    ADD COLUMN `cart_type` int(2) NOT NULL COMMENT '购物车类型 1微商城  2积分商城' AFTER `company_id`;
ALTER TABLE `shop_sku`
    ADD COLUMN `pay_type` int(2) NULL COMMENT '支付方式1 直接购买 2,积分兑换' AFTER `score_count`;
update shop_product set able_score_pay=1;
update shop_product set able_sales=2;
@@ -203,3 +201,7 @@
    MODIFY COLUMN `score_price` decimal(10, 2) NULL DEFAULT NULL COMMENT '兑换所需支付价格' AFTER `invitation_price`,
    ADD COLUMN `score_count` decimal(10, 2) NULL COMMENT '兑换所需积分数量' AFTER `score_price`;
ALTER TABLE `shop_order_details`
    ADD COLUMN `pay_type` int(2) NULL COMMENT '支付方式1 直接购买 2,积分兑换' AFTER `company_id`,
ADD COLUMN `score_count` decimal(20, 2) NULL COMMENT '支付积分单价' AFTER `pay_type`,
ADD COLUMN `total_score_count` decimal(20, 2) NULL COMMENT '支付总积分' AFTER `score_count`;
zq-erp/src/main/resources/mybatis/mapper/xcxShop/ShopOrderDetailsDao.xml
@@ -20,6 +20,8 @@
            <result property="discountExplain" column="discount_explain" />
            <result property="discountAmount" column="discount_amount" />
            <result property="payType" column="pay_type" />
            <result property="scoreCount" column="score_count" />
            <result property="totalScoreCount" column="total_score_count" />
    </resultMap>
    <!-- 定义ShopOrderDetails 的复杂map -->
@@ -39,6 +41,9 @@
            <result property="discountExplain" column="discount_explain" />
            <result property="discountAmount" column="discount_amount" />
        <result property="payType" column="pay_type" />
        <result property="scoreCount" column="score_count" />
        <result property="totalScoreCount" column="total_score_count" />
        <!--产品信息-->
        <association property="shopProduct" column="p_id"
            select="com.matrix.system.shopXcx.dao.ShopProductDao.selectById"/>
@@ -67,7 +72,9 @@
            s_title,
            discount_explain,
            discount_amount,
            pay_type
            pay_type,
        score_count,
        total_score_count
    </sql>
    
    <!-- 属性sql -->
@@ -86,7 +93,9 @@
            #{item.sTitle},
            #{item.discountExplain},
            #{item.discountAmount},
            #{item.payType}
            #{item.payType},
            #{item.scoreCount},
            #{item.totalScoreCount}
    </sql>
    
    <!-- where sql -->
@@ -125,6 +134,14 @@
            </if>
            <if test="(record.payType!=null and record.payType!='') or  (record.payType!='' and record.payType==0)  ">
                and pay_type  = #{record.payType}
            </if>
            <if test="(record.scoreCount!=null and record.scoreCount!='') or  (record.scoreCount!='' and record.scoreCount==0)  ">
                and score_count  = #{record.scoreCount}
            </if>
            <if test="(record.totalScoreCount!=null and record.totalScoreCount!='') or  (record.totalScoreCount!='' and record.totalScoreCount==0)  ">
                and total_score_count  = #{record.totalScoreCount}
            </if>
        </if>
         
@@ -188,7 +205,20 @@
                </if>        
            <if test="_parameter.containsKey('discountAmount')">
                    discount_amount = #{discountAmount},
                </if>
                </if>
            <if test="_parameter.containsKey('payType')">
                pay_type = #{payType},
                </if>
            <if test="_parameter.containsKey('scoreCount')">
                score_count = #{scoreCount},
                </if>
            <if test="_parameter.containsKey('totalScoreCount')">
                total_score_count = #{totalScoreCount},
                </if>
        </set>
        WHERE id=#{id} 
    </update> 
@@ -225,10 +255,18 @@
            <if test="record.discountAmount != null ">
                discount_amount  = #{record.discountAmount}, 
            </if>
            <if test="record.payType != null ">
                pay_type  = #{record.payType},
            </if>
            <if test="record.scoreCount != null ">
                score_count  = #{record.scoreCount},
            </if>
            <if test="record.totalScoreCount != null ">
                total_score_count  = #{record.totalScoreCount},
            </if>
        </set>
        WHERE id=#{record.id} 
    </update>
    <!-- 批量删除 -->
    <delete id="deleteByIds" parameterType="java.util.List">
        delete from shop_order_details where  id in
zq-erp/src/main/resources/mybatis/mapper/xcxShop/ShopShoppingCartDao.xml
@@ -335,6 +335,8 @@
            p.buy_limit,
            s.NAME,
            s.stock,
            s.score_count,
            s.score_price,
               c.cart_type
        from shop_shopping_cart c
        LEFT JOIN shop_product p ON c.cart_product_id = p.id