Browse Source

解决营销活动目标商品选择无商品问题

multiwx
dy-hu 7 months ago
parent
commit
af91671a79
  1. 11
      cereshop-business/src/main/java/com/shop/cereshop/business/controller/ShopCouponController.java
  2. 4
      cereshop-business/src/main/java/com/shop/cereshop/business/dao/tool/CereShopCouponDAO.java
  3. 41
      cereshop-business/src/main/java/com/shop/cereshop/business/param/tool/ToolProductNewParam.java
  4. 2
      cereshop-business/src/main/java/com/shop/cereshop/business/param/tool/ToolProductParam.java
  5. 2
      cereshop-business/src/main/java/com/shop/cereshop/business/service/tool/CereShopCouponService.java
  6. 4
      cereshop-business/src/main/java/com/shop/cereshop/business/service/tool/impl/CereShopCouponServiceImpl.java
  7. 30
      cereshop-business/src/main/resources/mybatis/mapper/tool/CereShopCouponDAO.xml

11
cereshop-business/src/main/java/com/shop/cereshop/business/controller/ShopCouponController.java

@ -7,11 +7,13 @@ package com.shop.cereshop.business.controller;
import com.shop.cereshop.business.annotation.NoRepeatSubmit;
import com.shop.cereshop.business.annotation.NoRepeatWebLog;
import com.shop.cereshop.business.page.shop.Shop;
import com.shop.cereshop.business.page.tool.ShopCoupon;
import com.shop.cereshop.business.page.tool.ShopCouponData;
import com.shop.cereshop.business.page.tool.ShopCouponDetail;
import com.shop.cereshop.business.page.tool.ToolProduct;
import com.shop.cereshop.business.param.tool.*;
import com.shop.cereshop.business.service.shop.CerePlatformShopService;
import com.shop.cereshop.business.service.tool.CereShopCouponService;
import com.shop.cereshop.commons.domain.business.CerePlatformBusinessUser;
import com.shop.cereshop.commons.domain.common.Page;
@ -26,6 +28,7 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.stream.Collectors;
/**
* 店铺优惠券管理
@ -42,6 +45,9 @@ public class ShopCouponController {
@Autowired
private CereShopCouponService cereShopCouponService;
@Autowired
private CerePlatformShopService shopService;
/**
* 新增满减券/折扣券
* @param param
@ -152,10 +158,11 @@ public class ShopCouponController {
*/
@PostMapping(value = "getProducts")
@ApiOperation(value = "选择商品查询")
public Result<Page<ToolProduct>> getProducts(@RequestBody ToolProductParam param, HttpServletRequest request) throws CoBusinessException{
public Result<Page<ToolProduct>> getProducts(@RequestBody ToolProductNewParam param, HttpServletRequest request) throws CoBusinessException{
//获取当前登录账户
CerePlatformBusinessUser user = (CerePlatformBusinessUser) request.getAttribute("user");
param.setShopId(user.getBusinessId());
shopService.selectAll(user.getBusinessId());
param.setShopIds(shopService.selectAll(user.getBusinessId()).stream().map(Shop::getShopId).collect(Collectors.toList()));
Page page=cereShopCouponService.getProducts(param);
return new Result(page);
}

4
cereshop-business/src/main/java/com/shop/cereshop/business/dao/tool/CereShopCouponDAO.java

@ -70,4 +70,8 @@ public interface CereShopCouponDAO extends BaseMapper<CereShopCoupon> {
List<CouponProduct> findDataProductsLimitProducts(@Param("shopCouponId") Long shopCouponId,
@Param("orderIdList") List<Long> orderIdList);
List<ToolProduct> getProductsNew(@Param("shopIds") List<Long> shopIds,
@Param("shopCouponId") Long shopCouponId,
@Param("queryType") Integer queryType);
}

41
cereshop-business/src/main/java/com/shop/cereshop/business/param/tool/ToolProductNewParam.java

@ -0,0 +1,41 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.business.param.tool;
import com.shop.cereshop.commons.domain.common.PageParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* 营销活动选择商品请求参数
*/
@Data
@ApiModel(value = "ToolProductParam", description = "营销活动选择商品请求参数")
public class ToolProductNewParam extends PageParam {
/**
* 店铺id集合
*/
@ApiModelProperty(value = "店铺id集合")
private List<Long> shopIds;
/**
* 活动id
*/
@ApiModelProperty(value = "活动id")
private Long activityId;
/**
* 查询类型 2-指定商品可用 3-指定商品不可用
*/
@ApiModelProperty(value = "查询类型")
private Integer queryType;
}

2
cereshop-business/src/main/java/com/shop/cereshop/business/param/tool/ToolProductParam.java

@ -34,4 +34,6 @@ public class ToolProductParam extends PageParam {
*/
@ApiModelProperty(value = "查询类型")
private Integer queryType;
}

2
cereshop-business/src/main/java/com/shop/cereshop/business/service/tool/CereShopCouponService.java

@ -30,7 +30,7 @@ public interface CereShopCouponService {
void stop(Long shopCouponId, CerePlatformBusinessUser user) throws CoBusinessException;
Page getProducts(ToolProductParam param) throws CoBusinessException;
Page getProducts(ToolProductNewParam param) throws CoBusinessException;
List<OperateCoupon> selectCoupon(OperateCouponParam param) throws CoBusinessException;

4
cereshop-business/src/main/java/com/shop/cereshop/business/service/tool/impl/CereShopCouponServiceImpl.java

@ -394,9 +394,9 @@ public class CereShopCouponServiceImpl implements CereShopCouponService {
}
@Override
public Page getProducts(ToolProductParam param) throws CoBusinessException {
public Page getProducts(ToolProductNewParam param) throws CoBusinessException {
PageHelper.startPage(param.getPage(),param.getPageSize());
List<ToolProduct> list=cereShopCouponDAO.getProducts(param.getShopId(), param.getActivityId(), param.getQueryType());
List<ToolProduct> list=cereShopCouponDAO.getProductsNew(param.getShopIds(), param.getActivityId(), param.getQueryType());
PageInfo<ToolProduct> pageInfo=new PageInfo<>(list);
Page page=new Page(pageInfo.getList(),pageInfo.getTotal());
return page;

30
cereshop-business/src/main/resources/mybatis/mapper/tool/CereShopCouponDAO.xml

@ -182,6 +182,36 @@
</if>
</select>
<select id="getProductsNew" parameterType="java.lang.Object" resultType="com.shop.cereshop.business.page.tool.ToolProduct">
SELECT a.product_id,a.product_name,b.minMoney originalPrice,d.product_image image,g.stock_number from cere_shop_product a
<if test="shopCouponId != null and queryType == 2">
join cere_shop_coupon_detail cscd on cscd.product_id = a.product_id
</if>
<if test="shopCouponId != null and queryType == 3">
join cere_shop_coupon_exclude csce on csce.product_id = a.product_id
</if>
LEFT JOIN (SELECT product_id,MIN(price) minMoney from cere_product_sku GROUP BY product_id) b ON a.product_id=b.product_id
LEFT JOIN (SELECT product_id,MAX(price) maxMoney from cere_product_sku GROUP BY product_id) c ON a.product_id=c.product_id
LEFT JOIN (SELECT a.product_id,a.product_image from cere_product_image a,cere_shop_product b where a.product_id=b.product_id GROUP BY a.product_id) d
ON a.product_id=d.product_id
LEFT JOIN cere_product_classify e ON a.classify_id=e.classify_id
LEFT JOIN (SELECT SUM(stock_number) stock_number,product_id from cere_product_sku GROUP BY product_id) g ON b.product_id=g.product_id
where a.shelve_state = 1
<if test="shopIds!=null and shopIds.size()>0">
and a.shop_id in (
<foreach collection="shopIds" item="shopId" index="index" separator=",">
#{shopId}
</foreach>
)
</if>
<if test="shopCouponId != null and queryType == 2">
and cscd.shop_coupon_id = #{shopCouponId}
</if>
<if test="shopCouponId != null and queryType == 3">
and csce.shop_coupon_id = #{shopCouponId}
</if>
</select>
<select id="findCouponName" parameterType="java.lang.Object" resultType="java.lang.String">
SELECT coupon_name FROM cere_shop_coupon where shop_coupon_id=#{shopCouponId}
</select>

Loading…
Cancel
Save