添加获取积分产品列表接口

This commit is contained in:
xuwenbo
2021-01-04 11:23:10 +08:00
parent c1a4f1b3f1
commit d6eab7adff
6 changed files with 64 additions and 4 deletions

View File

@ -4,6 +4,9 @@
-- 字段修改
-- ----------------------------
ALTER TABLE yx_store_product ADD COLUMN is_integral tinyint(1) ZEROFILL NULL DEFAULT 0 COMMENT '是开启积分兑换' AFTER is_del;
ALTER TABLE yx_store_product ADD COLUMN integral tinyint(1) ZEROFILL NULL DEFAULT 0 COMMENT '需要多少积分兑换' AFTER is_integral;
ALTER TABLE yx_store_product_attr_value ADD COLUMN integral INT(10) DEFAULT 0 COMMENT '需要多少积分兑换' AFTER seckill_price;
ALTER TABLE yx_store_order ADD COLUMN `pay_integral` decimal(8, 2) UNSIGNED NOT NULL DEFAULT 0.00 COMMENT '支付积分';

View File

@ -0,0 +1,39 @@
package co.yixiang.modules.activity.rest;
import co.yixiang.api.ApiResult;
import co.yixiang.modules.product.param.YxStoreProductQueryParam;
import co.yixiang.modules.product.service.YxStoreProductService;
import co.yixiang.modules.product.vo.YxStoreProductQueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* 积分兑换前端控制器
* @author yshop
*/
@Slf4j
@RestController
@RequestMapping
@Api(value = "积分兑换", tags = "营销:积分兑换", description = "积分兑换")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class StoreIntegralController {
private final YxStoreProductService storeProductService;
/**
* 获取积分产品列表
*/
@GetMapping("/products")
@ApiOperation(value = "获取积分产品列表",notes = "获取积分产品列表")
public ApiResult<List<YxStoreProductQueryVo>> goodsList(YxStoreProductQueryParam productQueryParam){
return ApiResult.ok(storeProductService.getGoodsList(productQueryParam));
}
}

View File

@ -138,6 +138,11 @@ public class YxStoreProduct extends BaseDomain {
private Integer stock;
/** 需要多少积分兑换 */
@ApiModelProperty(value = "需要多少积分兑换 只在开启积分兑换时生效")
private Integer integral;
/** 状态0未上架1上架 */
@ApiModelProperty(value = "状态0未上架1上架")
private Integer isShow;

View File

@ -29,6 +29,9 @@ public class YxStoreProductQueryParam extends QueryParam {
@ApiModelProperty(value = "是否新品")
private String news;
@ApiModelProperty(value = "是否积分兑换商品")
private Integer isIntegral;
@ApiModelProperty(value = "价格排序")
private String priceOrder;

View File

@ -1,5 +1,6 @@
package co.yixiang.modules.product.service.dto;
import io.swagger.models.auth.In;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
@ -20,4 +21,6 @@ public class ProductResultDto {
private Double minCost;
private Integer stock;
private Integer minIntegral;
}

View File

@ -60,13 +60,11 @@ import co.yixiang.utils.ShopKeyUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.PageInfo;
import com.qiniu.util.StringUtils;
import lombok.val;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
@ -79,8 +77,6 @@ import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
import static co.yixiang.common.utils.QueryHelpPlus.humpToUnderline;
/**
* @author hupeng
@ -237,6 +233,9 @@ public class YxStoreProductServiceImpl extends BaseServiceImpl<StoreProductMappe
wrapper.eq(YxStoreProduct::getIsDel, CommonEnum.DEL_STATUS_0.getValue());
// wrapper.eq(YxStoreProduct::getIsIntegral, CommonEnum.SHOW_STATUS_1.getValue());
if(productQueryParam.getIsIntegral()!=null){
wrapper.eq(YxStoreProduct::getIsIntegral, productQueryParam.getIsIntegral());
}
//多字段模糊查询分类搜索
if (StrUtil.isNotBlank(productQueryParam.getSid()) &&
!ShopConstants.YSHOP_ZERO.equals(productQueryParam.getSid())) {
@ -735,6 +734,13 @@ public class YxStoreProductServiceImpl extends BaseServiceImpl<StoreProductMappe
.min(Comparator.naturalOrder())
.orElse(0d);
//取最小积分
Integer minIntegral = attrs
.stream()
.map(ProductFormatDto::getIntegral)
.min(Comparator.naturalOrder())
.orElse(0);
Double minOtPrice = attrs
.stream()
.map(ProductFormatDto::getOtPrice)
@ -762,6 +768,7 @@ public class YxStoreProductServiceImpl extends BaseServiceImpl<StoreProductMappe
.minOtPrice(minOtPrice)
.minCost(minCost)
.stock(stock)
.minIntegral(minIntegral)
.build();
}