xiaoyong931011
2021-11-10 fc1773400e95b39a7acd97074dd41a3fe9c302d4
20211108
7 files modified
67 ■■■■■ changed files
gc-shop/src/main/java/com/xzx/gc/shop/dto/AddGoodsDto.java 3 ●●●●● patch | view | raw | blame | history
gc-shop/src/main/java/com/xzx/gc/shop/dto/UpdateGoodsDto.java 3 ●●●●● patch | view | raw | blame | history
gc-shop/src/main/java/com/xzx/gc/shop/mapper/ScoreOrderMapper.java 4 ●●●● patch | view | raw | blame | history
gc-shop/src/main/java/com/xzx/gc/shop/service/OrderService.java 28 ●●●●● patch | view | raw | blame | history
gc-shop/src/main/java/com/xzx/gc/shop/vo/ViewGoodsVo.java 3 ●●●●● patch | view | raw | blame | history
gc-shop/src/main/resources/mapper/shop/ScoreOrderMapper.xml 15 ●●●●● patch | view | raw | blame | history
gc-shop/src/main/resources/sql 11 ●●●●● patch | view | raw | blame | history
gc-shop/src/main/java/com/xzx/gc/shop/dto/AddGoodsDto.java
@@ -67,6 +67,9 @@
    @ApiModelProperty(value="碳排放量",required=true)
    private Integer carbonEmissions;
    @ApiModelProperty(value="限购次数")
    private Integer quotaTime;
    @ApiModelProperty(value="主图")
    private List<String> goodsImages;
gc-shop/src/main/java/com/xzx/gc/shop/dto/UpdateGoodsDto.java
@@ -64,6 +64,9 @@
    @ApiModelProperty(value="碳排放量",required=true)
    private Integer carbonEmissions;
    @ApiModelProperty(value="限购次数")
    private Integer quotaTime;
    @ApiModelProperty(value="积分商品轮播图")
    private List<String> goodsImages;
gc-shop/src/main/java/com/xzx/gc/shop/mapper/ScoreOrderMapper.java
@@ -33,4 +33,8 @@
    Integer selectScoreOrderCnt(@Param("userId") String userId);
    Integer selectGoodsQuotaTime(@Param("userId")String userId,
                                 @Param("goodsId")Long id,
                                 @Param("qgStartTime")Date qgStartTime,
                                 @Param("qgEndTime")Date qgEndTime);
}
gc-shop/src/main/java/com/xzx/gc/shop/service/OrderService.java
@@ -229,7 +229,33 @@
            throw new RestException(-3, "积分不足");
        }
        BigDecimal totalPrice = sku.getPresentPrice().multiply(BigDecimal.valueOf(addGoodsOrderDto.getCnt()));
        BigDecimal totalPrice = BigDecimal.ZERO;
        if (ScoreGoods.ISQG_YES.equals(goods.getIsQg())) {
            //限购数量
            Integer quotaTime = goods.getQuotaTime() == null ? 0:goods.getQuotaTime();
            //抢购时间内,用户购买该商品的数量
            Integer sumCnt = scoreOrderMapper.selectGoodsQuotaTime(addGoodsOrderDto.getUserId(),goods.getId(),goods.getQgStartTime(),goods.getQgEndTime());
            //剩余限购数量
            quotaTime = quotaTime-sumCnt;
            if(goods.getQgStartTime().before(new Date()) && goods.getQgEndTime().after(new Date())){
                if(addGoodsOrderDto.getCnt() <= quotaTime){
                    totalPrice = sku.getPresentPrice().multiply(BigDecimal.valueOf(quotaTime));
                }else{
                    if(quotaTime > 0){
                        totalPrice = sku.getPresentPrice().multiply(BigDecimal.valueOf(quotaTime)).add(
                                sku.getOriginalPrice().multiply(BigDecimal.valueOf(addGoodsOrderDto.getCnt()-quotaTime)));
                    }else{
                        totalPrice = sku.getOriginalPrice().multiply(BigDecimal.valueOf(addGoodsOrderDto.getCnt()));
                    }
                }
            }else{
                //开启抢购,不再时间内,直接原价* 数量
                totalPrice = sku.getOriginalPrice().multiply(BigDecimal.valueOf(addGoodsOrderDto.getCnt()));
            }
        }else{
            //没有开启抢购,直接现价* 数量
            totalPrice = sku.getPresentPrice().multiply(BigDecimal.valueOf(addGoodsOrderDto.getCnt()));
        }
        BigDecimal score = new BigDecimal(accountInfo.getCollectScore());
        if (score.compareTo(totalPrice) < 0) {
            throw new RestException(-3, "积分不足");
gc-shop/src/main/java/com/xzx/gc/shop/vo/ViewGoodsVo.java
@@ -68,6 +68,9 @@
    @ApiModelProperty(value="碳排放量",required=true)
    private Integer carbonEmissions;
    @ApiModelProperty(value="限购次数")
    private Integer quotaTime;
    @ApiModelProperty(value="积分商品轮播图")
    private List<String> goodsImages;
gc-shop/src/main/resources/mapper/shop/ScoreOrderMapper.xml
@@ -127,4 +127,19 @@
            and user_id=#{userId}
        </if>
    </select>
    <select id="selectGoodsQuotaTime" resultType="java.lang.Integer">
        SELECT
            IFNULL(SUM(a.cnt), 0)
        FROM
            xzx_score_order a
                LEFT JOIN xzx_score_order_details b ON b.order_id = a.id
        WHERE
            a. STATUS IN (1, 2, 3, 4, 5)
          and a.user_id = #{userId}
          AND b.goods_id = #{goodsId}
          and a.CREATED_TIME &gt;= qgStartTime
          and a.CREATED_TIME &lt;= qgEndTime
    </select>
</mapper>
gc-shop/src/main/resources/sql
@@ -95,6 +95,17 @@
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COMMENT='首页弹窗表';
ALTER TABLE `xzx_score_goods`
ADD COLUMN `quota_time`  int(11) NULL COMMENT '限购次数' AFTER `present_price`;
ALTER TABLE `xzx_jhy_order`
ADD COLUMN `unit_name`  varchar(32) NULL COMMENT '单元栋' AFTER `username`;
ALTER TABLE `xzx_jhy_order`
ADD COLUMN `house_number`  varchar(32) NULL COMMENT '门牌号' AFTER `unit_name`;