活动优惠编写完成
This commit is contained in:
parent
ba828626c8
commit
39d662fce3
@ -7,11 +7,15 @@
|
|||||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||||
<outputRelativeToContentRoot value="true" />
|
<outputRelativeToContentRoot value="true" />
|
||||||
<module name="service-sys" />
|
|
||||||
<module name="common-util" />
|
<module name="common-util" />
|
||||||
|
<module name="service-product-client" />
|
||||||
|
<module name="rabbit_util" />
|
||||||
|
<module name="service-product" />
|
||||||
|
<module name="service-sys" />
|
||||||
|
<module name="service-search" />
|
||||||
<module name="model" />
|
<module name="model" />
|
||||||
<module name="service-util" />
|
<module name="service-util" />
|
||||||
<module name="service-product" />
|
<module name="service-activity" />
|
||||||
<module name="service-acl" />
|
<module name="service-acl" />
|
||||||
</profile>
|
</profile>
|
||||||
</annotationProcessing>
|
</annotationProcessing>
|
||||||
@ -20,9 +24,14 @@
|
|||||||
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
|
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
|
||||||
<module name="common-util" options="-parameters" />
|
<module name="common-util" options="-parameters" />
|
||||||
<module name="model" options="-parameters" />
|
<module name="model" options="-parameters" />
|
||||||
|
<module name="rabbit_util" options="-parameters" />
|
||||||
<module name="service" options="" />
|
<module name="service" options="" />
|
||||||
<module name="service-acl" options="-parameters" />
|
<module name="service-acl" options="-parameters" />
|
||||||
|
<module name="service-activity" options="-parameters" />
|
||||||
|
<module name="service-client" options="" />
|
||||||
<module name="service-product" options="-parameters" />
|
<module name="service-product" options="-parameters" />
|
||||||
|
<module name="service-product-client" options="-parameters" />
|
||||||
|
<module name="service-search" options="-parameters" />
|
||||||
<module name="service-sys" options="-parameters" />
|
<module name="service-sys" options="-parameters" />
|
||||||
<module name="service-util" options="-parameters" />
|
<module name="service-util" options="-parameters" />
|
||||||
</option>
|
</option>
|
||||||
|
@ -9,5 +9,13 @@
|
|||||||
<jdbc-url>jdbc:mysql://82.157.68.223:3306/shequ-sys</jdbc-url>
|
<jdbc-url>jdbc:mysql://82.157.68.223:3306/shequ-sys</jdbc-url>
|
||||||
<working-dir>$ProjectFileDir$</working-dir>
|
<working-dir>$ProjectFileDir$</working-dir>
|
||||||
</data-source>
|
</data-source>
|
||||||
|
<data-source source="LOCAL" name="shequ-activity" uuid="1c34518c-82bb-48b3-b7d8-91da7dfdba8d">
|
||||||
|
<driver-ref>mysql.8</driver-ref>
|
||||||
|
<synchronize>true</synchronize>
|
||||||
|
<remarks>shequ-activity</remarks>
|
||||||
|
<jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
|
||||||
|
<jdbc-url>jdbc:mysql://82.157.68.223:3306/shequ-activity</jdbc-url>
|
||||||
|
<working-dir>$ProjectFileDir$</working-dir>
|
||||||
|
</data-source>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
@ -2,12 +2,18 @@
|
|||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="Encoding">
|
<component name="Encoding">
|
||||||
<file url="file://$PROJECT_DIR$/guigu-ssyx-parent/common/common-util/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/guigu-ssyx-parent/common/common-util/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/guigu-ssyx-parent/common/rabbit_util/src/main/java" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/guigu-ssyx-parent/common/service-util/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/guigu-ssyx-parent/common/service-util/src/main/java" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/guigu-ssyx-parent/common/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/guigu-ssyx-parent/common/src/main/java" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/guigu-ssyx-parent/common/src/main/resources" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/guigu-ssyx-parent/common/src/main/resources" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/guigu-ssyx-parent/model/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/guigu-ssyx-parent/model/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/guigu-ssyx-parent/service-client/service-product-client/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/guigu-ssyx-parent/service-client/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/guigu-ssyx-parent/service-client/src/main/resources" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/guigu-ssyx-parent/service/service-acl/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/guigu-ssyx-parent/service/service-acl/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/guigu-ssyx-parent/service/service-activity/src/main/java" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/guigu-ssyx-parent/service/service-product/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/guigu-ssyx-parent/service/service-product/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/guigu-ssyx-parent/service/service-search/src/main/java" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/guigu-ssyx-parent/service/service-sys/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/guigu-ssyx-parent/service/service-sys/src/main/java" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/guigu-ssyx-parent/service/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/guigu-ssyx-parent/service/src/main/java" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/guigu-ssyx-parent/service/src/main/resources" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/guigu-ssyx-parent/service/src/main/resources" charset="UTF-8" />
|
||||||
|
@ -1,4 +1,9 @@
|
|||||||
<project version="4">
|
<project version="4">
|
||||||
|
<component name="EntryPointsManager">
|
||||||
|
<list size="1">
|
||||||
|
<item index="0" class="java.lang.String" itemvalue="org.springframework.beans.factory.annotation.Autowired" />
|
||||||
|
</list>
|
||||||
|
</component>
|
||||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
<component name="FindBugsConfigurable">
|
<component name="FindBugsConfigurable">
|
||||||
<option name="make" value="true" />
|
<option name="make" value="true" />
|
||||||
|
@ -10,12 +10,11 @@ public enum CouponRangeType {
|
|||||||
CATEGORY(3, "分类");
|
CATEGORY(3, "分类");
|
||||||
|
|
||||||
@EnumValue
|
@EnumValue
|
||||||
private Integer code;
|
private final Integer code;
|
||||||
private String comment;
|
private final String comment;
|
||||||
|
|
||||||
CouponRangeType(Integer code, String comment) {
|
CouponRangeType(Integer code, String comment) {
|
||||||
this.code = code;
|
this.code = code;
|
||||||
this.comment = comment;
|
this.comment = comment;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import com.atguigu.ssyx.model.product.SkuInfo;
|
|||||||
import org.springframework.cloud.openfeign.FeignClient;
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -18,10 +19,22 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
@FeignClient(value = "service-product")
|
@FeignClient(value = "service-product")
|
||||||
public interface ProductFeignClient {
|
public interface ProductFeignClient {
|
||||||
|
/**
|
||||||
|
* 根据分类id获取分类信息
|
||||||
|
* \
|
||||||
|
*
|
||||||
|
* @param categoryId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@GetMapping("/api/product/inner/getCategory/{categoryId}")
|
@GetMapping("/api/product/inner/getCategory/{categoryId}")
|
||||||
Category getCategory(@PathVariable("categoryId") Long categoryId);
|
Category getCategory(@PathVariable("categoryId") Long categoryId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据skuId获取sku信息
|
||||||
|
*
|
||||||
|
* @param skuId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@GetMapping("/api/product/inner/getSkuInfo/{skuId}")
|
@GetMapping("/api/product/inner/getSkuInfo/{skuId}")
|
||||||
SkuInfo getSkuInfo(@PathVariable("skuId") Long skuId);
|
SkuInfo getSkuInfo(@PathVariable("skuId") Long skuId);
|
||||||
|
|
||||||
@ -43,4 +56,12 @@ public interface ProductFeignClient {
|
|||||||
@GetMapping("/api/product/inner/findSkuInfoList")
|
@GetMapping("/api/product/inner/findSkuInfoList")
|
||||||
List<SkuInfo> findSkuInfoList(@RequestBody List<Long> skuIdList);
|
List<SkuInfo> findSkuInfoList(@RequestBody List<Long> skuIdList);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量获取分类信息
|
||||||
|
*
|
||||||
|
* @param categoryIdList
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/api/product/inner/findCategoryList")
|
||||||
|
List<Category> findCategoryList(@RequestBody List<Long> categoryIdList);
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,6 @@ spring:
|
|||||||
cloud:
|
cloud:
|
||||||
nacos:
|
nacos:
|
||||||
discovery:
|
discovery:
|
||||||
server-addr: localhost:8848
|
server-addr: 82.157.68.223:8848
|
||||||
username: nacos
|
username: nacos
|
||||||
password: nacos
|
password: nacos
|
||||||
|
@ -1,8 +1,17 @@
|
|||||||
package com.atguigu.ssyx.activity.controller;
|
package com.atguigu.ssyx.activity.controller;
|
||||||
|
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import com.atguigu.ssyx.activity.service.CouponInfoService;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import com.atguigu.ssyx.common.result.Result;
|
||||||
|
import com.atguigu.ssyx.model.activity.CouponInfo;
|
||||||
|
import com.atguigu.ssyx.vo.activity.CouponRuleVo;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import io.swagger.annotations.ApiParam;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@ -13,8 +22,79 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
* @since 2023-09-17
|
* @since 2023-09-17
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/activity/coupon-info")
|
@CrossOrigin
|
||||||
|
@RequestMapping("/admin/activity/couponInfo")
|
||||||
public class CouponInfoController {
|
public class CouponInfoController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CouponInfoService couponInfoService;
|
||||||
|
|
||||||
|
@ApiOperation(value = "获取分页列表")
|
||||||
|
@GetMapping("{page}/{limit}")
|
||||||
|
public Result index(
|
||||||
|
@ApiParam(name = "page", value = "当前页码", required = true) @PathVariable Long page,
|
||||||
|
@ApiParam(name = "limit", value = "每页记录数", required = true) @PathVariable Long limit) {
|
||||||
|
IPage<CouponInfo> pageModel = couponInfoService.selectPage(page, limit);
|
||||||
|
return Result.ok(pageModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "根据ID查询优惠券")
|
||||||
|
@GetMapping("get/{id}")
|
||||||
|
public Result get(@PathVariable Long id) {
|
||||||
|
CouponInfo couponInfo = couponInfoService.getCouponInfo(id);
|
||||||
|
return Result.ok(couponInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "新增优惠券")
|
||||||
|
@PostMapping("save")
|
||||||
|
public Result save(@RequestBody CouponInfo couponInfo) {
|
||||||
|
couponInfoService.save(couponInfo);
|
||||||
|
return Result.ok(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "修改优惠券")
|
||||||
|
@PutMapping("update")
|
||||||
|
public Result updateById(@RequestBody CouponInfo couponInfo) {
|
||||||
|
couponInfoService.updateById(couponInfo);
|
||||||
|
return Result.ok(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "删除优惠券")
|
||||||
|
@DeleteMapping("remove/{id}")
|
||||||
|
public Result remove(@PathVariable String id) {
|
||||||
|
couponInfoService.removeById(id);
|
||||||
|
return Result.ok(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "根据id列表删除优惠券")
|
||||||
|
@DeleteMapping("batchRemove")
|
||||||
|
public Result batchRemove(@RequestBody List<String> idList) {
|
||||||
|
couponInfoService.removeByIds(idList);
|
||||||
|
return Result.ok(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "获取优惠券信息")
|
||||||
|
@GetMapping("findCouponRuleList/{id}")
|
||||||
|
public Result findActivityRuleList(@PathVariable Long id) {
|
||||||
|
return Result.ok(couponInfoService.findCouponRuleList(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "新增优惠券")
|
||||||
|
@PostMapping("saveCouponRule")
|
||||||
|
public Result saveCouponRule(@RequestBody CouponRuleVo couponRuleVo) {
|
||||||
|
couponInfoService.saveCouponRule(couponRuleVo);
|
||||||
|
return Result.ok(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据关键字获取sku列表,活动使用
|
||||||
|
*
|
||||||
|
* @param keyword
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("findCouponByKeyword/{keyword}")
|
||||||
|
public Result findCouponByKeyword(@PathVariable("keyword") String keyword) {
|
||||||
|
return Result.ok(couponInfoService.findCouponByKeyword(keyword));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package com.atguigu.ssyx.activity.mapper;
|
|||||||
|
|
||||||
import com.atguigu.ssyx.model.activity.CouponRange;
|
import com.atguigu.ssyx.model.activity.CouponRange;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@ -11,6 +12,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||||||
* @author atguigu
|
* @author atguigu
|
||||||
* @since 2023-09-17
|
* @since 2023-09-17
|
||||||
*/
|
*/
|
||||||
|
@Repository
|
||||||
public interface CouponRangeMapper extends BaseMapper<CouponRange> {
|
public interface CouponRangeMapper extends BaseMapper<CouponRange> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,13 @@
|
|||||||
package com.atguigu.ssyx.activity.service;
|
package com.atguigu.ssyx.activity.service;
|
||||||
|
|
||||||
import com.atguigu.ssyx.model.activity.CouponInfo;
|
import com.atguigu.ssyx.model.activity.CouponInfo;
|
||||||
|
import com.atguigu.ssyx.vo.activity.CouponRuleVo;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* 优惠券信息 服务类
|
* 优惠券信息 服务类
|
||||||
@ -13,4 +18,44 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||||||
*/
|
*/
|
||||||
public interface CouponInfoService extends IService<CouponInfo> {
|
public interface CouponInfoService extends IService<CouponInfo> {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取分页列表
|
||||||
|
*
|
||||||
|
* @param page
|
||||||
|
* @param limit
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
IPage<CouponInfo> selectPage(Long page, Long limit);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据ID查询优惠券
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
CouponInfo getCouponInfo(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据优惠卷id获取优惠券规则列表
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Map<String, Object> findCouponRuleList(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增优惠券规则
|
||||||
|
*
|
||||||
|
* @param couponRuleVo
|
||||||
|
*/
|
||||||
|
void saveCouponRule(CouponRuleVo couponRuleVo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据关键字获取sku列表,活动使用
|
||||||
|
*
|
||||||
|
* @param keyword
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<CouponInfo> findCouponByKeyword(String keyword);
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,27 @@
|
|||||||
package com.atguigu.ssyx.activity.service.impl;
|
package com.atguigu.ssyx.activity.service.impl;
|
||||||
|
|
||||||
import com.atguigu.ssyx.activity.mapper.CouponInfoMapper;
|
import com.atguigu.ssyx.activity.mapper.CouponInfoMapper;
|
||||||
|
import com.atguigu.ssyx.activity.mapper.CouponRangeMapper;
|
||||||
import com.atguigu.ssyx.activity.service.CouponInfoService;
|
import com.atguigu.ssyx.activity.service.CouponInfoService;
|
||||||
|
import com.atguigu.ssyx.client.product.ProductFeignClient;
|
||||||
|
import com.atguigu.ssyx.enums.CouponRangeType;
|
||||||
import com.atguigu.ssyx.model.activity.CouponInfo;
|
import com.atguigu.ssyx.model.activity.CouponInfo;
|
||||||
|
import com.atguigu.ssyx.model.activity.CouponRange;
|
||||||
|
import com.atguigu.ssyx.model.product.Category;
|
||||||
|
import com.atguigu.ssyx.model.product.SkuInfo;
|
||||||
|
import com.atguigu.ssyx.vo.activity.CouponRuleVo;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@ -17,4 +34,119 @@ import org.springframework.stereotype.Service;
|
|||||||
@Service
|
@Service
|
||||||
public class CouponInfoServiceImpl extends ServiceImpl<CouponInfoMapper, CouponInfo> implements CouponInfoService {
|
public class CouponInfoServiceImpl extends ServiceImpl<CouponInfoMapper, CouponInfo> implements CouponInfoService {
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
CouponRangeMapper couponRangeMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
ProductFeignClient productFeignClient;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取分页列表
|
||||||
|
*
|
||||||
|
* @param page
|
||||||
|
* @param limit
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public IPage<CouponInfo> selectPage(Long page, Long limit) {
|
||||||
|
Page<CouponInfo> pageParam = new Page<>(page, limit);
|
||||||
|
Page<CouponInfo> couponInfoPage = baseMapper.selectPage(pageParam, null);
|
||||||
|
List<CouponInfo> couponInfoList = couponInfoPage.getRecords();
|
||||||
|
couponInfoList.forEach(item -> {
|
||||||
|
item.setCouponTypeString(item.getCouponType()
|
||||||
|
.getComment());
|
||||||
|
CouponRangeType rangeType = item.getRangeType();
|
||||||
|
if (rangeType != null) {
|
||||||
|
item.setRangeTypeString(rangeType.getComment());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return couponInfoPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据ID查询优惠券
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public CouponInfo getCouponInfo(Long id) {
|
||||||
|
CouponInfo couponInfo = baseMapper.selectById(id);
|
||||||
|
couponInfo.setCouponTypeString(couponInfo.getCouponType()
|
||||||
|
.getComment());
|
||||||
|
if (couponInfo.getRangeType() != null) {
|
||||||
|
couponInfo.setRangeTypeString(couponInfo.getRangeType()
|
||||||
|
.getComment());
|
||||||
|
}
|
||||||
|
return couponInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据优惠卷id获取优惠券规则列表
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> findCouponRuleList(Long id) {
|
||||||
|
//第一步 根据优惠卷id查询优惠卷基本信息 coupon_info表
|
||||||
|
CouponInfo couponInfo = baseMapper.selectById(id);
|
||||||
|
|
||||||
|
//第二步 根据优惠卷id查询coupon_range 查询里面对应range_id
|
||||||
|
List<CouponRange> couponRangeList = couponRangeMapper.selectList(new LambdaQueryWrapper<CouponRange>().eq(CouponRange::getCouponId, id));
|
||||||
|
//couponRangeList获取所有range_id
|
||||||
|
//// 如果规则类型 SKU range_id就是skuId值
|
||||||
|
//// 如果规则类型 CATEGORY range_id就是分类Id值
|
||||||
|
List<Long> randIdList = couponRangeList.stream()
|
||||||
|
.map(CouponRange::getRangeId)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
Map<String, Object> result = new HashMap<>();
|
||||||
|
//第三步 分别判断封装不同数据
|
||||||
|
if (!CollectionUtils.isEmpty(randIdList)) {
|
||||||
|
if (couponInfo.getRangeType() == CouponRangeType.SKU) {
|
||||||
|
//// 如果规则类型是SKU ,得到skuId,
|
||||||
|
// 远程调用根据多个skuId值获取对应sku信息
|
||||||
|
List<SkuInfo> skuInfoList = productFeignClient.findSkuInfoList(randIdList);
|
||||||
|
result.put("skuInfoList", skuInfoList);
|
||||||
|
|
||||||
|
} else if (couponInfo.getRangeType() == CouponRangeType.CATEGORY) {
|
||||||
|
//// 如果规则类型是分类,得到分类Id,远程调用根据多个分类Id值获取对应分类信息
|
||||||
|
List<Category> categoryList = productFeignClient.findCategoryList(randIdList);
|
||||||
|
result.put("categoryList", categoryList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveCouponRule(CouponRuleVo couponRuleVo) {
|
||||||
|
//优惠券couponInfo 与 couponRange 要一起操作:先删除couponRange ,更新couponInfo ,再新增couponRange !
|
||||||
|
|
||||||
|
couponRangeMapper.delete(new LambdaQueryWrapper<CouponRange>().eq(CouponRange::getCouponId, couponRuleVo.getCouponId()));
|
||||||
|
|
||||||
|
//更新优惠卷基本信息
|
||||||
|
CouponInfo couponInfo = baseMapper.selectById(couponRuleVo.getCouponId());
|
||||||
|
couponInfo.setRangeType(couponRuleVo.getRangeType());
|
||||||
|
couponInfo.setConditionAmount(couponRuleVo.getConditionAmount());
|
||||||
|
couponInfo.setAmount(couponRuleVo.getAmount());
|
||||||
|
couponInfo.setConditionAmount(couponRuleVo.getConditionAmount());
|
||||||
|
couponInfo.setRangeDesc(couponRuleVo.getRangeDesc());
|
||||||
|
baseMapper.updateById(couponInfo);
|
||||||
|
|
||||||
|
//添加优惠卷新规则数据
|
||||||
|
List<CouponRange> couponRangeList = couponRuleVo.getCouponRangeList();
|
||||||
|
for (CouponRange couponRange : couponRangeList) {
|
||||||
|
//设置优惠卷id
|
||||||
|
couponRange.setCouponId(couponRuleVo.getCouponId());
|
||||||
|
//添加
|
||||||
|
couponRangeMapper.insert(couponRange);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<CouponInfo> findCouponByKeyword(String keyword) {
|
||||||
|
return baseMapper.selectList(new LambdaQueryWrapper<CouponInfo>().like(CouponInfo::getCouponName, keyword));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,6 @@ spring:
|
|||||||
cloud:
|
cloud:
|
||||||
nacos:
|
nacos:
|
||||||
discovery:
|
discovery:
|
||||||
server-addr: localhost:8848
|
server-addr: 82.157.68.223:8848
|
||||||
username: nacos
|
username: nacos
|
||||||
password: nacos
|
password: nacos
|
||||||
|
@ -45,6 +45,12 @@ public class ProductInnnerController {
|
|||||||
return skuInfoService.findSkuInfoList(skuIdList);
|
return skuInfoService.findSkuInfoList(skuIdList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "批量获取分类信息")
|
||||||
|
@PostMapping("inner/findCategoryList")
|
||||||
|
public List<Category> findCategoryList(@RequestBody List<Long> categoryIdList) {
|
||||||
|
return categoryService.listByIds(categoryIdList);
|
||||||
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "根据关键字获取sku列表")
|
@ApiOperation(value = "根据关键字获取sku列表")
|
||||||
@GetMapping("inner/findSkuInfoByKeyword/{keyword}")
|
@GetMapping("inner/findSkuInfoByKeyword/{keyword}")
|
||||||
public List<SkuInfo> findSkuInfoByKeyword(@PathVariable("keyword") String keyword) {
|
public List<SkuInfo> findSkuInfoByKeyword(@PathVariable("keyword") String keyword) {
|
||||||
|
@ -6,6 +6,4 @@ spring:
|
|||||||
cloud:
|
cloud:
|
||||||
nacos:
|
nacos:
|
||||||
discovery:
|
discovery:
|
||||||
server-addr: localhost:8848
|
server-addr: 82.157.68.223:8848
|
||||||
username: nacos
|
|
||||||
password: nacos
|
|
||||||
|
@ -6,6 +6,4 @@ spring:
|
|||||||
cloud:
|
cloud:
|
||||||
nacos:
|
nacos:
|
||||||
discovery:
|
discovery:
|
||||||
server-addr: localhost:8848
|
server-addr: 82.157.68.223:8848
|
||||||
username: nacos
|
|
||||||
password: nacos
|
|
||||||
|
@ -6,6 +6,4 @@ spring:
|
|||||||
cloud:
|
cloud:
|
||||||
nacos:
|
nacos:
|
||||||
discovery:
|
discovery:
|
||||||
server-addr: localhost:8848
|
server-addr: 82.157.68.223:8848
|
||||||
username: nacos
|
|
||||||
password: nacos
|
|
||||||
|
Loading…
Reference in New Issue
Block a user