commit message
This commit is contained in:
36
buyer-api/src/main/java/cn/lili/BuyerApiApplication.java
Normal file
36
buyer-api/src/main/java/cn/lili/BuyerApiApplication.java
Normal file
@@ -0,0 +1,36 @@
|
||||
package cn.lili;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.core.task.TaskExecutor;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
|
||||
/**
|
||||
* 买家API
|
||||
*
|
||||
* @author Chopper
|
||||
* @date 2020/11/16 10:03 下午
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@EnableJpaAuditing
|
||||
@EnableCaching
|
||||
@EnableAsync
|
||||
public class BuyerApiApplication {
|
||||
|
||||
|
||||
@Primary
|
||||
@Bean
|
||||
public TaskExecutor primaryTaskExecutor() {
|
||||
return new ThreadPoolTaskExecutor();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.setProperty("es.set.netty.runtime.available.processors", "false");
|
||||
SpringApplication.run(BuyerApiApplication.class, args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package cn.lili.controller;
|
||||
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
import springfox.documentation.spring.web.SpringfoxWebMvcConfiguration;
|
||||
|
||||
/**
|
||||
* SwaggerBootstrapUiDemoApplication
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v1.0
|
||||
* 2020-12-09 20:09
|
||||
*/
|
||||
@ConditionalOnClass(SpringfoxWebMvcConfiguration.class)
|
||||
public class SwaggerBootstrapUiDemoApplication implements WebMvcConfigurer {
|
||||
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
registry.addResourceHandler("doc.html").addResourceLocations("classpath:/META-INF/resources/");
|
||||
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package cn.lili.controller.distribution;
|
||||
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.utils.ResultUtil;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.distribution.entity.dos.Distribution;
|
||||
import cn.lili.modules.distribution.entity.dos.DistributionOrder;
|
||||
import cn.lili.modules.distribution.entity.vos.DistributionOrderSearchParams;
|
||||
import cn.lili.modules.distribution.service.DistributionOrderService;
|
||||
import cn.lili.modules.distribution.service.DistributionService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
||||
/**
|
||||
* 买家端,分销员接口
|
||||
*
|
||||
* @author pikachu
|
||||
* @date: 2020/11/16 10:03 下午
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "买家端,分销员接口")
|
||||
@RequestMapping("/buyer/distribution")
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class DistributionBuyerController {
|
||||
|
||||
/**
|
||||
* 分销员
|
||||
*/
|
||||
private final DistributionService distributionService;
|
||||
/**
|
||||
* 分销员订单
|
||||
*/
|
||||
private final DistributionOrderService distributionOrderService;
|
||||
|
||||
//申请分销员
|
||||
@ApiOperation(value = "申请分销员")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "name", value = "姓名", required = true, paramType = "query", dataType = "String"),
|
||||
@ApiImplicitParam(name = "idNumber", value = "身份证号", required = true, paramType = "query", dataType = "String")
|
||||
})
|
||||
@PostMapping
|
||||
public ResultMessage<Object> applyDistribution(@RequestParam String name, @RequestParam String idNumber) {
|
||||
return ResultUtil.data(distributionService.applyDistribution(name, idNumber));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取分销员分页订单列表")
|
||||
@GetMapping("/distributionOrder")
|
||||
public ResultMessage<IPage<DistributionOrder>> distributionOrderPage(DistributionOrderSearchParams distributionOrderSearchParams) {
|
||||
distributionOrderSearchParams.setDistributionId(UserContext.getCurrentUser().getId());
|
||||
return ResultUtil.data(distributionOrderService.getDistributionOrderPage(distributionOrderSearchParams));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取当前会员的分销员信息", notes = "可根据分销员信息查询待提现金额以及冻结金额等信息")
|
||||
@GetMapping
|
||||
public ResultMessage<Distribution> getDistribution() {
|
||||
//检查分销开关
|
||||
distributionService.checkDistributionSetting();
|
||||
|
||||
return ResultUtil.data(distributionService.getDistribution());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package cn.lili.controller.distribution;
|
||||
|
||||
import cn.lili.common.utils.ResultUtil;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.distribution.entity.dos.DistributionCash;
|
||||
import cn.lili.modules.distribution.service.DistributionCashService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
|
||||
/**
|
||||
* 买家端,分销商品佣金提现接口
|
||||
*
|
||||
* @author pikachu
|
||||
* @date: 2020/11/16 10:03 下午
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "买家端,分销商品佣金提现接口")
|
||||
@RequestMapping("/buyer/distribution/cash")
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class DistributionCashBuyerController {
|
||||
|
||||
/**
|
||||
* 分销佣金
|
||||
*/
|
||||
private final DistributionCashService distributionCashService;
|
||||
/**
|
||||
* 分销员提现
|
||||
*/
|
||||
private final DistributionCashService distributorCashService;
|
||||
|
||||
|
||||
@ApiOperation(value = "分销员提现")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "price", value = "申请金额", required = true, paramType = "query", dataType = "double")
|
||||
})
|
||||
@PostMapping
|
||||
public ResultMessage<Boolean> cash(@NotNull @ApiIgnore Double price) {
|
||||
Boolean result = distributionCashService.cash(price);
|
||||
return ResultUtil.data(result);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "分销员提现历史")
|
||||
@GetMapping
|
||||
public ResultMessage<IPage<DistributionCash>> casHistory(PageVO page) {
|
||||
return ResultUtil.data(distributorCashService.getDistributionCash(page));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package cn.lili.controller.distribution;
|
||||
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.utils.ResultUtil;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.distribution.entity.dto.DistributionGoodsSearchParams;
|
||||
import cn.lili.modules.distribution.entity.vos.DistributionGoodsVO;
|
||||
import cn.lili.modules.distribution.service.DistributionGoodsService;
|
||||
import cn.lili.modules.distribution.service.DistributionSelectedGoodsService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 买家端,分销商品接口
|
||||
*
|
||||
* @author Bulbasaur
|
||||
* @date: 2020/11/16 10:06 下午
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "买家端,分销商品接口")
|
||||
@RequestMapping("/buyer/distributionGoods")
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class DistributionGoodsBuyerController {
|
||||
|
||||
/**
|
||||
* 分销商品
|
||||
*/
|
||||
private final DistributionGoodsService distributionGoodsService;
|
||||
/**
|
||||
* 选择分销商品
|
||||
*/
|
||||
private final DistributionSelectedGoodsService distributionSelectedGoodsService;
|
||||
|
||||
|
||||
@ApiOperation(value = "获取分销商商品列表")
|
||||
@GetMapping
|
||||
public ResultMessage<IPage<DistributionGoodsVO>> distributionGoods(DistributionGoodsSearchParams distributionGoodsSearchParams) {
|
||||
return ResultUtil.data(distributionGoodsService.goodsPage(distributionGoodsSearchParams));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "选择分销商品")
|
||||
@ApiImplicitParam(name = "distributionGoodsId", value = "分销ID", required = true, dataType = "String", paramType = "path")
|
||||
@GetMapping(value = "/checked/{distributionGoodsId}")
|
||||
public ResultMessage<IPage<DistributionGoodsVO>> distributionCheckGoods(
|
||||
@NotNull(message = "分销商品不能为空") @PathVariable("distributionGoodsId") String distributionGoodsId) {
|
||||
if (distributionSelectedGoodsService.add(distributionGoodsId)) {
|
||||
return ResultUtil.success(ResultCode.SUCCESS);
|
||||
}
|
||||
return ResultUtil.error(ResultCode.ERROR);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package cn.lili.controller.distribution;
|
||||
|
||||
import cn.lili.common.utils.ResultUtil;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.distribution.entity.dos.DistributionOrder;
|
||||
import cn.lili.modules.distribution.entity.vos.DistributionOrderSearchParams;
|
||||
import cn.lili.modules.distribution.service.DistributionOrderService;
|
||||
import cn.lili.modules.distribution.service.DistributionService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
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;
|
||||
|
||||
|
||||
/**
|
||||
* 买家端,分销商品佣金提现接口
|
||||
*
|
||||
* @author pikachu
|
||||
* @date: 2020/11/16 10:03 下午
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "买家端,分销订单接口")
|
||||
@RequestMapping("/buyer/distribution/order")
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class DistributionOrderBuyerController {
|
||||
|
||||
/**
|
||||
* 分销订单
|
||||
*/
|
||||
private final DistributionOrderService distributionOrderService;
|
||||
/**
|
||||
* 分销员
|
||||
*/
|
||||
private final DistributionService distributionService;
|
||||
|
||||
|
||||
@ApiOperation(value = "分销员订单")
|
||||
@GetMapping
|
||||
public ResultMessage<IPage<DistributionOrder>> casHistory(DistributionOrderSearchParams distributionOrderSearchParams) {
|
||||
//获取当前登录的分销员
|
||||
distributionOrderSearchParams.setDistributionId(distributionService.getDistribution().getId());
|
||||
return ResultUtil.data(distributionOrderService.getDistributionOrderPage(distributionOrderSearchParams));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package cn.lili.controller.goods;
|
||||
|
||||
import cn.lili.common.utils.ResultUtil;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.goods.entity.vos.CategoryVO;
|
||||
import cn.lili.modules.goods.service.CategoryService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 买家端,商品分类接口
|
||||
*
|
||||
* @author Chopper
|
||||
* @date: 2020/11/16 10:05 下午
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "买家端,商品分类接口")
|
||||
@RequestMapping("/buyer/category")
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class CategoryBuyerController {
|
||||
/**
|
||||
* 商品分类
|
||||
*/
|
||||
private final CategoryService categoryService;
|
||||
|
||||
@ApiOperation(value = "获取商品分类列表")
|
||||
@ApiImplicitParam(name = "parentId", value = "上级分类ID,全部分类为:0", required = true, dataType = "Long", paramType = "path")
|
||||
@GetMapping(value = "/get/{parentId}")
|
||||
public ResultMessage<List<CategoryVO>> list(@NotNull(message = "分类ID不能为空") @PathVariable String parentId) {
|
||||
|
||||
return ResultUtil.data(categoryService.listAllChildren(parentId));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
package cn.lili.controller.goods;
|
||||
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.lili.common.utils.ResultUtil;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.distribution.service.DistributionService;
|
||||
import cn.lili.modules.goods.entity.dos.Goods;
|
||||
import cn.lili.modules.goods.entity.dto.GoodsSearchParams;
|
||||
import cn.lili.modules.goods.entity.vos.GoodsVO;
|
||||
import cn.lili.modules.goods.service.GoodsService;
|
||||
import cn.lili.modules.goods.service.GoodsSkuService;
|
||||
import cn.lili.modules.search.entity.dos.EsGoodsIndex;
|
||||
import cn.lili.modules.search.entity.dos.EsGoodsRelatedInfo;
|
||||
import cn.lili.modules.search.entity.dto.EsGoodsSearchDTO;
|
||||
import cn.lili.modules.search.service.EsGoodsSearchService;
|
||||
import cn.lili.modules.statistics.aop.PageViewPoint;
|
||||
import cn.lili.modules.statistics.aop.enums.PageViewEnum;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 买家端,商品接口
|
||||
*
|
||||
* @author Chopper
|
||||
* @date 2020/11/16 10:06 下午
|
||||
*/
|
||||
@Api(tags = "买家端,商品接口")
|
||||
@RestController
|
||||
@RequestMapping("/buyer/goods")
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class GoodsBuyerController {
|
||||
|
||||
/**
|
||||
* 商品
|
||||
*/
|
||||
private final GoodsService goodsService;
|
||||
/**
|
||||
* 商品SKU
|
||||
*/
|
||||
private final GoodsSkuService goodsSkuService;
|
||||
/**
|
||||
* ES商品搜索
|
||||
*/
|
||||
private final EsGoodsSearchService goodsSearchService;
|
||||
/**
|
||||
* 分销员
|
||||
*/
|
||||
private final DistributionService distributionService;
|
||||
|
||||
|
||||
@ApiOperation(value = "通过id获取商品信息")
|
||||
@ApiImplicitParam(name = "goodsId", value = "商品ID", required = true, paramType = "path", dataType = "Long")
|
||||
@GetMapping(value = "/get/{goodsId}")
|
||||
public ResultMessage<GoodsVO> get(@NotNull(message = "商品ID不能为空") @PathVariable("goodsId") String id) {
|
||||
return ResultUtil.data(goodsService.getGoodsVO(id));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "通过id获取商品信息")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "goodsId", value = "商品ID", required = true, paramType = "path"),
|
||||
@ApiImplicitParam(name = "skuId", value = "skuId", required = true, paramType = "path"),
|
||||
@ApiImplicitParam(name = "distributionId", value = "分销员ID", dataType = "String", paramType = "query")
|
||||
})
|
||||
@GetMapping(value = "/sku/{goodsId}/{skuId}")
|
||||
@PageViewPoint(type = PageViewEnum.SKU, id = "#id")
|
||||
public ResultMessage<Map<String, Object>> getSku(@NotNull(message = "商品ID不能为空") @PathVariable("goodsId") String goodsId,
|
||||
@NotNull(message = "SKU ID不能为空") @PathVariable("skuId") String skuId,
|
||||
String distributionId) {
|
||||
|
||||
Map<String, Object> map = goodsSkuService.getGoodsSkuDetail(goodsId, skuId);
|
||||
|
||||
//判断如果传递分销员则进行记录
|
||||
if (CharSequenceUtil.isNotEmpty(distributionId)) {
|
||||
distributionService.bindingDistribution(distributionId);
|
||||
}
|
||||
|
||||
return ResultUtil.data(map);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取商品分页列表")
|
||||
@GetMapping
|
||||
public ResultMessage<IPage<Goods>> getByPage(GoodsSearchParams goodsSearchParams) {
|
||||
return ResultUtil.data(goodsService.queryByParams(goodsSearchParams));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "从ES中获取商品信息")
|
||||
@GetMapping("/es")
|
||||
public ResultMessage<Page<EsGoodsIndex>> getGoodsByPageFromEs(EsGoodsSearchDTO goodsSearchParams, PageVO pageVO) {
|
||||
pageVO.setNotConvert(true);
|
||||
Page<EsGoodsIndex> esGoodsIndices = goodsSearchService.searchGoods(goodsSearchParams, pageVO);
|
||||
return ResultUtil.data(esGoodsIndices);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "从ES中获取相关商品品牌名称,分类名称及属性")
|
||||
@GetMapping("/es/related")
|
||||
public ResultMessage<EsGoodsRelatedInfo> getGoodsRelatedByPageFromEs(EsGoodsSearchDTO goodsSearchParams, PageVO pageVO) {
|
||||
pageVO.setNotConvert(true);
|
||||
EsGoodsRelatedInfo selector = goodsSearchService.getSelector(goodsSearchParams, pageVO);
|
||||
return ResultUtil.data(selector);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取搜索热词")
|
||||
@GetMapping("/hot-words")
|
||||
public ResultMessage<List<String>> getGoodsHotWords(Integer start, Integer end) {
|
||||
List<String> hotWords = goodsSearchService.getHotWords(start, end);
|
||||
return ResultUtil.data(hotWords);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package cn.lili.controller.member;
|
||||
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.utils.ResultUtil;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.promotion.entity.dos.MemberCoupon;
|
||||
import cn.lili.modules.promotion.entity.vos.CouponSearchParams;
|
||||
import cn.lili.modules.promotion.entity.vos.CouponVO;
|
||||
import cn.lili.modules.promotion.service.CouponService;
|
||||
import cn.lili.modules.promotion.service.MemberCouponService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 买家端,买家优惠券接口
|
||||
*
|
||||
* @author paulG
|
||||
* @date 2020/11/17 3:35 下午
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "买家端,买家优惠券接口")
|
||||
@RequestMapping("/buyer/promotion/coupon")
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class CouponBuyerController {
|
||||
|
||||
/**
|
||||
* 优惠券
|
||||
*/
|
||||
private final CouponService couponService;
|
||||
|
||||
/**
|
||||
* 会员优惠券
|
||||
*/
|
||||
private final MemberCouponService memberCouponService;
|
||||
|
||||
@GetMapping
|
||||
@ApiOperation(value = "获取可领取优惠券列表")
|
||||
public ResultMessage<IPage<CouponVO>> getCouponList(CouponSearchParams queryParam, PageVO page) {
|
||||
IPage<CouponVO> canUseCoupons = couponService.getCanReceiveCoupons(queryParam, page);
|
||||
return ResultUtil.data(canUseCoupons);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取当前会员的优惠券列表")
|
||||
@GetMapping("/getCoupons")
|
||||
public ResultMessage<IPage<MemberCoupon>> getCoupons(CouponSearchParams param, PageVO pageVo) {
|
||||
param.setMemberId(UserContext.getCurrentUser().getId());
|
||||
return ResultUtil.data(memberCouponService.getMemberCoupons(param, pageVo));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取当前会员的对于当前商品可使用的优惠券列表")
|
||||
@GetMapping("/canUse")
|
||||
public ResultMessage<IPage<MemberCoupon>> getCouponsByCanUse(CouponSearchParams param, Double totalPrice, PageVO pageVo) {
|
||||
param.setMemberId(UserContext.getCurrentUser().getId());
|
||||
return ResultUtil.data(memberCouponService.getMemberCouponsByCanUse(param, totalPrice, pageVo));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取当前会员可使用的优惠券数量")
|
||||
@GetMapping("/getCouponsNum")
|
||||
public ResultMessage<Object> getMemberCouponsNum() {
|
||||
return ResultUtil.data(memberCouponService.getMemberCouponsNum());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "会员领取优惠券")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "couponId", value = "优惠券ID", required = true, dataType = "Long", paramType = "path")
|
||||
})
|
||||
@GetMapping("/receive/{couponId}")
|
||||
public ResultMessage<Object> receiveCoupon(@NotNull(message = "优惠券ID不能为空") @PathVariable("couponId") String couponId) {
|
||||
memberCouponService.checkCouponLimit(couponId, UserContext.getCurrentUser().getId());
|
||||
memberCouponService.receiveCoupon(couponId, UserContext.getCurrentUser().getId(), UserContext.getCurrentUser().getNickName());
|
||||
return ResultUtil.success(ResultCode.SUCCESS);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "通过id获取")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "优惠券ID", required = true, dataType = "Long", paramType = "path")
|
||||
})
|
||||
@GetMapping(value = "/get/{id}")
|
||||
public ResultMessage<MemberCoupon> get(@NotNull(message = "优惠券ID不能为空") @PathVariable("id") String id) {
|
||||
MemberCoupon memberCoupon = memberCouponService.getById(id);
|
||||
return ResultUtil.data(memberCoupon);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package cn.lili.controller.member;
|
||||
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.utils.ResultUtil;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.member.service.FootprintService;
|
||||
import cn.lili.modules.search.entity.dos.EsGoodsIndex;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 买家端,浏览历史接口
|
||||
*
|
||||
* @author Chopper
|
||||
* @date: 2020/11/16 10:06 下午
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "买家端,浏览历史接口")
|
||||
@RequestMapping("/buyer/footprint")
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class FootprintController {
|
||||
|
||||
/**
|
||||
* 会员足迹
|
||||
*/
|
||||
private final FootprintService footprintService;
|
||||
|
||||
@ApiOperation(value = "分页获取")
|
||||
@GetMapping
|
||||
public ResultMessage<List<EsGoodsIndex>> getByPage(PageVO page) {
|
||||
return ResultUtil.data(footprintService.footPrintPage(page));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "根据id删除")
|
||||
@ApiImplicitParam(name = "ids", value = "商品ID", required = true, allowMultiple = true, dataType = "String", paramType = "path")
|
||||
@DeleteMapping(value = "/delByIds/{ids}")
|
||||
public ResultMessage<Object> delAllByIds(@NotNull(message = "商品ID不能为空") @PathVariable("ids") List ids) {
|
||||
if (footprintService.deleteByIds(ids)) {
|
||||
return ResultUtil.success(ResultCode.SUCCESS);
|
||||
}
|
||||
return ResultUtil.error(ResultCode.ERROR);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "清空足迹")
|
||||
@DeleteMapping
|
||||
public ResultMessage<Object> deleteAll() {
|
||||
if (footprintService.clean()) {
|
||||
return ResultUtil.success(ResultCode.SUCCESS);
|
||||
}
|
||||
return ResultUtil.error(ResultCode.ERROR);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取当前会员足迹数量")
|
||||
@GetMapping(value = "/getFootprintNum")
|
||||
public ResultMessage<Object> getFootprintNum() {
|
||||
return ResultUtil.data(footprintService.getFootprintNum());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package cn.lili.controller.member;
|
||||
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.utils.ResultUtil;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.base.service.RegionService;
|
||||
import cn.lili.modules.member.entity.dos.MemberAddress;
|
||||
import cn.lili.modules.promotion.service.MemberAddressService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
|
||||
/**
|
||||
* 买家端,会员地址接口
|
||||
*
|
||||
* @author Bulbasaur
|
||||
* @date: 2020/11/16 10:07 下午
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "买家端,会员地址接口")
|
||||
@RequestMapping("/buyer/memberAddress")
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class MemberAddressBuyerController {
|
||||
|
||||
/**
|
||||
* 会员收件地址
|
||||
*/
|
||||
private final MemberAddressService memberAddressService;
|
||||
|
||||
private final RegionService regionService;
|
||||
|
||||
@ApiOperation(value = "获取会员收件地址分页列表")
|
||||
@GetMapping
|
||||
public ResultMessage<IPage<MemberAddress>> page(PageVO page) {
|
||||
return ResultUtil.data(memberAddressService.getAddressByMember(page, UserContext.getCurrentUser().getId()));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "根据ID获取会员收件地址")
|
||||
@ApiImplicitParam(name = "id", value = "会员地址ID", dataType = "String", paramType = "path")
|
||||
@GetMapping(value = "/get/{id}")
|
||||
public ResultMessage<MemberAddress> getShippingAddress(@PathVariable String id) {
|
||||
return ResultUtil.data(memberAddressService.getMemberAddress(id));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取当前会员默认收件地址")
|
||||
@GetMapping(value = "/get/default")
|
||||
public ResultMessage<MemberAddress> getDefaultShippingAddress() {
|
||||
return ResultUtil.data(memberAddressService.getDefaultMemberAddress());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "新增会员收件地址")
|
||||
@PostMapping
|
||||
public ResultMessage<MemberAddress> addShippingAddress(@Valid MemberAddress shippingAddress) {
|
||||
//添加会员地址
|
||||
shippingAddress.setMemberId(UserContext.getCurrentUser().getId());
|
||||
return ResultUtil.data(memberAddressService.saveMemberAddress(shippingAddress));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改会员收件地址")
|
||||
@PutMapping
|
||||
public ResultMessage<MemberAddress> editShippingAddress(@Valid MemberAddress shippingAddress) {
|
||||
//修改会员地址
|
||||
shippingAddress.setMemberId(UserContext.getCurrentUser().getId());
|
||||
return ResultUtil.data(memberAddressService.updateMemberAddress(shippingAddress));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除会员收件地址")
|
||||
@ApiImplicitParam(name = "id", value = "会员地址ID", dataType = "String", paramType = "path")
|
||||
@DeleteMapping(value = "/delById/{id}")
|
||||
public ResultMessage<Object> delShippingAddressById(@PathVariable String id) {
|
||||
if (memberAddressService.removeMemberAddress(id)) {
|
||||
return ResultUtil.success(ResultCode.SUCCESS);
|
||||
}
|
||||
return ResultUtil.error(ResultCode.ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package cn.lili.controller.member;
|
||||
|
||||
import cn.lili.common.utils.ResultUtil;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.member.service.GoodsCollectionService;
|
||||
import cn.lili.modules.member.service.StoreCollectionService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 买家端,会员收藏接口
|
||||
*
|
||||
* @author Chopper
|
||||
* @date: 2020/11/17 2:32 下午
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "买家端,会员收藏接口")
|
||||
@RequestMapping("/buyer/member/collection")
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class MemberCollectionController {
|
||||
|
||||
/**
|
||||
* 会员商品收藏
|
||||
*/
|
||||
private final GoodsCollectionService goodsCollectionService;
|
||||
/**
|
||||
* 会员店铺
|
||||
*/
|
||||
private final StoreCollectionService storeCollectionService;
|
||||
|
||||
@ApiOperation(value = "查询会员收藏列表")
|
||||
@ApiImplicitParam(name = "type", value = "类型", dataType = "String", paramType = "path", example = "GOODS:商品,STORE:店铺")
|
||||
@GetMapping("/{type}")
|
||||
public ResultMessage<Object> goodsList(@PathVariable String type, PageVO page) {
|
||||
if (type.equals("GOODS")) {
|
||||
return ResultUtil.data(goodsCollectionService.goodsCollection(page));
|
||||
}
|
||||
return ResultUtil.data(storeCollectionService.storeCollection(page));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "添加会员收藏")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "type", value = "类型", dataType = "String", paramType = "path", example = "GOODS:商品,STORE:店铺"),
|
||||
@ApiImplicitParam(name = "num", value = "值", dataType = "Long", paramType = "path")
|
||||
})
|
||||
@PostMapping("/add/{type}/{id}")
|
||||
public ResultMessage<Object> addGoodsCollection(@PathVariable String type,
|
||||
@NotNull(message = "值不能为空") @PathVariable String id) {
|
||||
if (type.equals("GOODS")) {
|
||||
return ResultUtil.data(goodsCollectionService.addGoodsCollection(id));
|
||||
}
|
||||
return ResultUtil.data(storeCollectionService.addStoreCollection(id));
|
||||
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除会员收藏")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "type", value = "类型", dataType = "String", paramType = "path", example = "GOODS:商品,STORE:店铺"),
|
||||
@ApiImplicitParam(name = "num", value = "值", dataType = "Long", paramType = "path")
|
||||
})
|
||||
@DeleteMapping(value = "/delete/{type}/{id}")
|
||||
public ResultMessage<Object> deleteGoodsCollection(@PathVariable String type,
|
||||
@NotNull(message = "值不能为空") @PathVariable String id) {
|
||||
if (type.equals("GOODS")) {
|
||||
return ResultUtil.data(goodsCollectionService.deleteGoodsCollection(id));
|
||||
}
|
||||
return ResultUtil.data(storeCollectionService.deleteStoreCollection(id));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查询会员是否收藏")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "type", value = "类型", dataType = "String", paramType = "path", example = "GOODS:商品,STORE:店铺"),
|
||||
@ApiImplicitParam(name = "id", value = "值", dataType = "String", paramType = "path")
|
||||
})
|
||||
@GetMapping(value = "/isCollection/{type}/{id}")
|
||||
public ResultMessage<Boolean> isCollection(@PathVariable String type,
|
||||
@NotNull(message = "值不能为空") @PathVariable String id) {
|
||||
if (type.equals("GOODS")) {
|
||||
return ResultUtil.data(this.goodsCollectionService.isCollection(id));
|
||||
}
|
||||
return ResultUtil.data(this.storeCollectionService.isCollection(id));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package cn.lili.controller.member;
|
||||
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.utils.ResultUtil;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.member.entity.dos.MemberEvaluation;
|
||||
import cn.lili.modules.member.entity.dto.EvaluationQueryParams;
|
||||
import cn.lili.modules.member.entity.dto.MemberEvaluationDTO;
|
||||
import cn.lili.modules.member.entity.vo.EvaluationNumberVO;
|
||||
import cn.lili.modules.member.entity.vo.MemberEvaluationVO;
|
||||
import cn.lili.modules.member.service.MemberEvaluationService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 买家端,会员商品评价接口
|
||||
*
|
||||
* @author Bulbasaur
|
||||
* @date: 2020/11/16 10:08 下午
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "买家端,会员商品评价接口")
|
||||
@RequestMapping("/buyer/memberEvaluation")
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class MemberEvaluationBuyerController {
|
||||
|
||||
/**
|
||||
* 会员商品评价
|
||||
*/
|
||||
private final MemberEvaluationService memberEvaluationService;
|
||||
|
||||
@ApiOperation(value = "添加会员评价")
|
||||
@PostMapping
|
||||
public ResultMessage<MemberEvaluationDTO> save(@Valid MemberEvaluationDTO memberEvaluationDTO) {
|
||||
return ResultUtil.data(memberEvaluationService.addMemberEvaluation(memberEvaluationDTO));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查看会员评价详情")
|
||||
@ApiImplicitParam(name = "id", value = "评价ID", required = true, paramType = "path")
|
||||
@GetMapping(value = "/get/{id}")
|
||||
public ResultMessage<MemberEvaluationVO> save(@NotNull(message = "评价ID不能为空") @PathVariable("id") String id) {
|
||||
return ResultUtil.data(memberEvaluationService.queryById(id));
|
||||
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查看当前会员评价列表")
|
||||
@GetMapping
|
||||
public ResultMessage<IPage<MemberEvaluation>> queryMineEvaluation(EvaluationQueryParams evaluationQueryParams) {
|
||||
//设置当前登录会员
|
||||
evaluationQueryParams.setMemberId(UserContext.getCurrentUser().getId());
|
||||
return ResultUtil.data(memberEvaluationService.queryByParams(evaluationQueryParams));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查看某一个商品的评价列表")
|
||||
@ApiImplicitParam(name = "goodsId", value = "商品ID", required = true, dataType = "Long", paramType = "path")
|
||||
@GetMapping(value = "/{goodsId}/goodsEvaluation")
|
||||
public ResultMessage<IPage<MemberEvaluation>> queryGoodsEvaluation(EvaluationQueryParams evaluationQueryParams,
|
||||
@NotNull @PathVariable("goodsId") String goodsId) {
|
||||
//设置查询查询商品
|
||||
evaluationQueryParams.setGoodsId(goodsId);
|
||||
return ResultUtil.data(memberEvaluationService.queryByParams(evaluationQueryParams));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查看某一个商品的评价数量")
|
||||
@ApiImplicitParam(name = "goodsId", value = "商品ID", required = true, dataType = "Long", paramType = "path")
|
||||
@GetMapping(value = "/{goodsId}/evaluationNumber")
|
||||
public ResultMessage<EvaluationNumberVO> queryEvaluationNumber(@NotNull @PathVariable("goodsId") String goodsId) {
|
||||
return ResultUtil.data(memberEvaluationService.getEvaluationNumber(goodsId));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package cn.lili.controller.member;
|
||||
|
||||
import cn.lili.common.utils.ResultUtil;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.message.entity.enums.MessageStatusEnum;
|
||||
import cn.lili.modules.member.entity.dos.MemberMessage;
|
||||
import cn.lili.modules.member.entity.vo.MemberMessageQueryVO;
|
||||
import cn.lili.modules.member.service.MemberMessageService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 买家端,会员站内消息接口
|
||||
*
|
||||
* @author Bulbasaur
|
||||
* @date: 2020/11/16 10:07 下午
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "买家端,会员站内消息接口")
|
||||
@RequestMapping("/buyer/member/message")
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class MemberMessageBuyerController {
|
||||
|
||||
/**
|
||||
* 会员站内消息
|
||||
*/
|
||||
private final MemberMessageService memberMessageService;
|
||||
|
||||
@ApiOperation(value = "分页获取会员站内消息")
|
||||
@GetMapping
|
||||
public ResultMessage<IPage<MemberMessage>> page(MemberMessageQueryVO memberMessageQueryVO, PageVO page) {
|
||||
return ResultUtil.data(memberMessageService.getPage(memberMessageQueryVO, page));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "消息已读")
|
||||
@ApiImplicitParam(name = "messageId", value = "会员消息id", required = true, paramType = "path")
|
||||
@PutMapping
|
||||
public ResultMessage<Boolean> read(@PathVariable String messageId) {
|
||||
return ResultUtil.data(memberMessageService.editStatus(MessageStatusEnum.ALREADY_READY.name(), messageId));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "消息删除")
|
||||
@ApiImplicitParam(name = "messageId", value = "会员消息id", required = true, paramType = "path")
|
||||
@DeleteMapping
|
||||
public ResultMessage<Boolean> deleteMessage(@PathVariable String messageId) {
|
||||
return ResultUtil.data(memberMessageService.deleteMessage(messageId));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package cn.lili.controller.member;
|
||||
|
||||
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.utils.ResultUtil;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.member.entity.vo.MemberReceiptAddVO;
|
||||
import cn.lili.modules.member.entity.vo.MemberReceiptVO;
|
||||
import cn.lili.modules.member.service.MemberReceiptService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
||||
/**
|
||||
* 买家端,会员发票接口
|
||||
*
|
||||
* @author paulG
|
||||
* @date: 2021-03-29 14:10:16
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "买家端,会员发票接口")
|
||||
@RequestMapping("/buyer/member/receipt")
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class MemberReceiptController {
|
||||
|
||||
private final MemberReceiptService memberReceiptService;
|
||||
|
||||
@ApiOperation(value = "查询会员发票列表")
|
||||
@GetMapping
|
||||
public ResultMessage<Object> page(MemberReceiptVO memberReceiptVO, PageVO page) {
|
||||
return ResultUtil.data(memberReceiptService.getPage(memberReceiptVO, page));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "新增会员发票")
|
||||
@PostMapping
|
||||
public ResultMessage<Object> add(MemberReceiptAddVO memberReceiptAddVO) {
|
||||
return ResultUtil.data(memberReceiptService.addMemberReceipt(memberReceiptAddVO, UserContext.getCurrentUser().getId()));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改会员发票")
|
||||
@ApiImplicitParam(name = "id", value = "会员发票id", required = true, paramType = "path")
|
||||
@PutMapping
|
||||
public ResultMessage<Object> update(@PathVariable String id, MemberReceiptAddVO memberReceiptAddVO) {
|
||||
memberReceiptAddVO.setId(id);
|
||||
return ResultUtil.data(memberReceiptService.editMemberReceipt(memberReceiptAddVO, id));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "会员发票删除")
|
||||
@ApiImplicitParam(name = "id", value = "会员发票id", required = true, paramType = "path")
|
||||
@DeleteMapping
|
||||
public ResultMessage<Boolean> deleteMessage(@PathVariable String id) {
|
||||
return ResultUtil.data(memberReceiptService.deleteMemberReceipt(id));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package cn.lili.controller.member;
|
||||
|
||||
import cn.lili.common.utils.ResultUtil;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.member.entity.dos.MemberSign;
|
||||
import cn.lili.modules.member.service.MemberSignService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 会员签到控制器
|
||||
*
|
||||
* @author pikachu
|
||||
* @date: 2020/11/16 10:07 下午
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "买家端,会员签到API")
|
||||
@RequestMapping("/buyer/members/sign")
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class MemberSignBuyerController {
|
||||
|
||||
private final MemberSignService memberSignService;
|
||||
|
||||
@PostMapping
|
||||
@ApiOperation(value = "会员签到")
|
||||
public ResultMessage<Boolean> memberSign() {
|
||||
return ResultUtil.data(memberSignService.memberSign());
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@ApiOperation(value = "根据时间查询会员签到表,类型是YYYYmm")
|
||||
public ResultMessage<List<MemberSign>> memberSign(String time) {
|
||||
return ResultUtil.data(memberSignService.getMonthSignDay(time));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
package cn.lili.controller.member;
|
||||
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.security.AuthUser;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.utils.ResultUtil;
|
||||
import cn.lili.common.verification.enums.VerificationEnums;
|
||||
import cn.lili.common.verification.service.VerificationService;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.member.entity.dos.Member;
|
||||
import cn.lili.modules.member.entity.dos.MemberWallet;
|
||||
import cn.lili.modules.member.entity.vo.MemberWalletVO;
|
||||
import cn.lili.modules.member.service.MemberService;
|
||||
import cn.lili.modules.member.service.MemberWalletService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.Pattern;
|
||||
|
||||
/**
|
||||
* 买家端,会员余额接口
|
||||
*
|
||||
* @author pikachu
|
||||
* @date: 2020/11/16 10:07 下午
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "买家端,会员余额接口")
|
||||
@RequestMapping("/buyer/members/wallet")
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class MemberWalletBuyerController {
|
||||
|
||||
/**
|
||||
* 会员
|
||||
*/
|
||||
private final MemberService memberService;
|
||||
/**
|
||||
* 会员余额
|
||||
*/
|
||||
private final MemberWalletService memberWalletService;
|
||||
/**
|
||||
* 验证码
|
||||
*/
|
||||
private final VerificationService verificationService;
|
||||
|
||||
@GetMapping
|
||||
@ApiOperation(value = "查询会员预存款余额")
|
||||
public ResultMessage<MemberWalletVO> get() {
|
||||
AuthUser authUser = UserContext.getCurrentUser();
|
||||
if (authUser != null) {
|
||||
return ResultUtil.data(memberWalletService.getMemberWallet(authUser.getId()));
|
||||
}
|
||||
throw new ServiceException(ResultCode.USER_NOT_LOGIN);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/set-password")
|
||||
@ApiOperation(value = "设置支付密码")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "password", value = "支付密码", required = true, dataType = "String", paramType = "query")
|
||||
})
|
||||
public ResultMessage<Object> setPassword(String password, @RequestHeader String uuid) {
|
||||
AuthUser authUser = UserContext.getCurrentUser();
|
||||
//校验当前用户是否存在
|
||||
Member member = memberService.getById(authUser.getId());
|
||||
if (member == null) {
|
||||
throw new ServiceException(ResultCode.USER_NOT_EXIST);
|
||||
}
|
||||
//校验验证码
|
||||
if (verificationService.check(uuid, VerificationEnums.WALLET_PASSWORD)) {
|
||||
memberWalletService.setMemberWalletPassword(member, password);
|
||||
return ResultUtil.error(ResultCode.SUCCESS);
|
||||
} else {
|
||||
return ResultUtil.error(ResultCode.VERIFICATION_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@PostMapping(value = "/update-password/ordinary")
|
||||
@ApiOperation(value = "普通方式进行支付密码的修改")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "oldPassword", value = "旧支付密码", required = true, dataType = "String", paramType = "query"),
|
||||
@ApiImplicitParam(name = "newPassword", value = "新支付密码", required = true, dataType = "String", paramType = "query")
|
||||
})
|
||||
public ResultMessage updatePassword(@RequestParam @Pattern(regexp = "[a-fA-F0-9]{32}", message = "旧密码格式不正确") String oldPassword,
|
||||
@RequestParam @Pattern(regexp = "[a-fA-F0-9]{32}", message = "新密码格式不正确") String newPassword) {
|
||||
AuthUser authUser = UserContext.getCurrentUser();
|
||||
//校验当前用户是否存在
|
||||
Member member = memberService.getById(authUser.getId());
|
||||
if (member == null) {
|
||||
throw new ServiceException(ResultCode.USER_NOT_EXIST);
|
||||
}
|
||||
MemberWallet memberWallet = this.memberWalletService.getOne(new QueryWrapper<MemberWallet>().eq("member_id", member.getId()));
|
||||
//校验新旧密码是否一致
|
||||
if (memberWallet != null) {
|
||||
if (!new BCryptPasswordEncoder().matches(oldPassword, memberWallet.getWalletPassword())) {
|
||||
throw new ServiceException(ResultCode.USER_OLD_PASSWORD_ERROR);
|
||||
}
|
||||
this.memberWalletService.setMemberWalletPassword(member, newPassword);
|
||||
return ResultUtil.data("修改成功");
|
||||
}
|
||||
throw new ServiceException(ResultCode.ERROR);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping(value = "/check")
|
||||
@ApiOperation(value = "检测会员是否设置过支付密码,会员中心设置或者修改密码时使用")
|
||||
public Boolean checkPassword() {
|
||||
return memberWalletService.checkPassword();
|
||||
}
|
||||
|
||||
|
||||
@PostMapping(value = "/withdrawal")
|
||||
@ApiOperation(value = "会员中心余额提现")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "price", value = "提现金额", required = true, dataType = "double", paramType = "query")
|
||||
})
|
||||
public ResultMessage<Boolean> withdrawal(@Max(value = 1000, message = "充值金额单次最多允许提现1000元") @Min(value = 1, message = "充值金额单次最少提现金额为1元") Double price) {
|
||||
return ResultUtil.data(memberWalletService.applyWithdrawal(price));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package cn.lili.controller.member;
|
||||
|
||||
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.utils.ResultUtil;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.member.entity.dos.MemberWithdrawApply;
|
||||
import cn.lili.modules.member.entity.vo.MemberWithdrawApplyQueryVO;
|
||||
import cn.lili.modules.member.service.MemberWithdrawApplyService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
||||
/**
|
||||
* 买家端,余额提现记录接口
|
||||
*
|
||||
* @author pikachu
|
||||
* @date: 2020/11/16 10:07 下午
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "买家端,余额提现记录接口")
|
||||
@RequestMapping("/buyer/member/withdrawApply")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class MemberWithdrawApplyBuyerController {
|
||||
|
||||
private final MemberWithdrawApplyService memberWithdrawApplyService;
|
||||
|
||||
|
||||
@ApiOperation(value = "分页获取提现记录")
|
||||
@GetMapping
|
||||
public ResultMessage<IPage<MemberWithdrawApply>> getByPage(PageVO page, MemberWithdrawApplyQueryVO memberWithdrawApplyQueryVO) {
|
||||
memberWithdrawApplyQueryVO.setMemberId(UserContext.getCurrentUser().getId());
|
||||
//构建查询 返回数据
|
||||
IPage<MemberWithdrawApply> memberWithdrawApplyIPage = memberWithdrawApplyService.getMemberWithdrawPage(page, memberWithdrawApplyQueryVO);
|
||||
return ResultUtil.data(memberWithdrawApplyIPage);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package cn.lili.controller.member;
|
||||
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.utils.PageUtil;
|
||||
import cn.lili.common.utils.ResultUtil;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.member.entity.dos.MemberPointsHistory;
|
||||
import cn.lili.modules.member.entity.vo.MemberPointsHistoryVO;
|
||||
import cn.lili.modules.member.service.MemberPointsHistoryService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 买家端,会员积分历史接口
|
||||
*
|
||||
* @author Bulbasaur
|
||||
* @date 2020-02-25 14:10:16
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "买家端,会员积分历史接口")
|
||||
@RequestMapping("/buyer/member/memberPointsHistory")
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class PointsHistoryBuyerController {
|
||||
|
||||
private final MemberPointsHistoryService memberPointsHistoryService;
|
||||
|
||||
@ApiOperation(value = "分页获取")
|
||||
@GetMapping(value = "/getByPage")
|
||||
public ResultMessage<IPage<MemberPointsHistory>> getByPage(PageVO page) {
|
||||
|
||||
LambdaQueryWrapper<MemberPointsHistory> queryWrapper = Wrappers.lambdaQuery();
|
||||
queryWrapper.eq(MemberPointsHistory::getMemberId, UserContext.getCurrentUser().getId());
|
||||
|
||||
return ResultUtil.data(memberPointsHistoryService.page(PageUtil.initPage(page), queryWrapper));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取会员积分VO")
|
||||
@GetMapping(value = "/getMemberPointsHistoryVO")
|
||||
public ResultMessage<MemberPointsHistoryVO> getMemberPointsHistoryVO() {
|
||||
return ResultUtil.data(memberPointsHistoryService.getMemberPointsHistoryVO(UserContext.getCurrentUser().getId()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package cn.lili.controller.member;
|
||||
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.utils.ResultUtil;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.order.trade.entity.dos.Recharge;
|
||||
import cn.lili.modules.order.trade.entity.vo.RechargeQueryVO;
|
||||
import cn.lili.modules.order.trade.service.RechargeService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 买家端,预存款充值记录接口
|
||||
*
|
||||
* @author pikachu
|
||||
* @date: 2020/11/16 10:07 下午
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "买家端,预存款充值记录接口")
|
||||
@RequestMapping("/buyer/member/recharge")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class RechargeBuyerController {
|
||||
|
||||
@Autowired
|
||||
private RechargeService rechargeService;
|
||||
|
||||
@ApiOperation(value = "分页获取预存款充值记录")
|
||||
@GetMapping
|
||||
public ResultMessage<IPage<Recharge>> getByPage(PageVO page) {
|
||||
//构建查询参数
|
||||
RechargeQueryVO rechargeQueryVO = new RechargeQueryVO();
|
||||
rechargeQueryVO.setMemberId(UserContext.getCurrentUser().getId());
|
||||
//构建查询 返回数据
|
||||
IPage<Recharge> rechargePage = rechargeService.rechargePage(page, rechargeQueryVO);
|
||||
return ResultUtil.data(rechargePage);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package cn.lili.controller.member;
|
||||
|
||||
import cn.lili.common.utils.PageUtil;
|
||||
import cn.lili.common.utils.ResultUtil;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.system.entity.dos.ServiceNotice;
|
||||
import cn.lili.modules.system.service.ServiceNoticeService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
|
||||
/**
|
||||
* 买家端,会员站服务消息接口
|
||||
*
|
||||
* @author Chopper
|
||||
* @date: 2020/11/17 2:31 下午
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/service/notice")
|
||||
@Api(tags = "买家端,会员站服务消息接口")
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class ServiceNoticeBuyerController {
|
||||
|
||||
/**
|
||||
* 服务消息
|
||||
*/
|
||||
private final ServiceNoticeService serviceNoticeService;
|
||||
|
||||
@ApiOperation(value = "获取消息详情")
|
||||
@ApiImplicitParam(name = "id", value = "商品ID", required = true, dataType = "Long", paramType = "path")
|
||||
@GetMapping(value = "/{id}")
|
||||
public ResultMessage<ServiceNotice> get(@PathVariable String id) {
|
||||
ServiceNotice serviceNotice = serviceNoticeService.getById(id);
|
||||
return ResultUtil.data(serviceNotice);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "分页获取服务消息")
|
||||
@GetMapping
|
||||
@ApiImplicitParam(name = "storeId", value = "商家id,默认为-1,代表平台消息,如果查询某商家发布的消息,传递商家id即可", dataType = "int", paramType = "query")
|
||||
public ResultMessage<IPage<ServiceNotice>> getByPage(PageVO page, String storeId) {
|
||||
ServiceNotice serviceNotice = new ServiceNotice();
|
||||
if (storeId == null) {
|
||||
storeId = "-1";
|
||||
}
|
||||
serviceNotice.setStoreId(storeId);
|
||||
IPage<ServiceNotice> data = serviceNoticeService.page(PageUtil.initPage(page));
|
||||
return ResultUtil.data(data);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package cn.lili.controller.other;
|
||||
|
||||
import cn.lili.common.utils.ResultUtil;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.page.entity.dos.Article;
|
||||
import cn.lili.modules.page.entity.dto.ArticleSearchParams;
|
||||
import cn.lili.modules.page.entity.vos.ArticleCategoryVO;
|
||||
import cn.lili.modules.page.entity.vos.ArticleVO;
|
||||
import cn.lili.modules.page.service.ArticleCategoryService;
|
||||
import cn.lili.modules.page.service.ArticleService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 买家端,文章接口
|
||||
*
|
||||
* @author Chopper
|
||||
* @date: 2020/11/16 10:02 下午
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "买家端,文章接口")
|
||||
@RequestMapping("/buyer/article")
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class ArticleBuyerController {
|
||||
|
||||
/**
|
||||
* 文章
|
||||
*/
|
||||
private final ArticleService articleService;
|
||||
|
||||
/**
|
||||
* 文章分类
|
||||
*/
|
||||
private final ArticleCategoryService articleCategoryService;
|
||||
|
||||
@ApiOperation(value = "获取文章分类列表")
|
||||
@GetMapping(value = "/articleCategory/list")
|
||||
public ResultMessage<List<ArticleCategoryVO>> getArticleCategoryList() {
|
||||
return ResultUtil.data(articleCategoryService.allChildren());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "分页获取")
|
||||
@GetMapping
|
||||
public ResultMessage<IPage<ArticleVO>> getByPage(ArticleSearchParams articleSearchParams) {
|
||||
return ResultUtil.data(articleService.articlePage(articleSearchParams));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "通过id获取文章")
|
||||
@ApiImplicitParam(name = "id", value = "文章ID", required = true, paramType = "path")
|
||||
@GetMapping(value = "/get/{id}")
|
||||
public ResultMessage<Article> get(@NotNull(message = "文章ID") @PathVariable("id") String id) {
|
||||
return ResultUtil.data(articleService.customGet(id));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "通过类型获取文章")
|
||||
@ApiImplicitParam(name = "type", value = "文章类型", required = true, paramType = "path")
|
||||
@GetMapping(value = "/type/{type}")
|
||||
public ResultMessage<Article> getByType(@NotNull(message = "文章类型") @PathVariable("type") String type) {
|
||||
return ResultUtil.data(articleService.customGetByType(type));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package cn.lili.controller.other;
|
||||
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.utils.ResultUtil;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.page.entity.dos.Feedback;
|
||||
import cn.lili.modules.page.service.FeedbackService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 买家端,意见反馈接口
|
||||
*
|
||||
* @author Bulbasaur
|
||||
* @date 2020-05-5 15:10:16
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "买家端,意见反馈接口")
|
||||
@RequestMapping("/buyer/feedback")
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class FeedbackBuyerController {
|
||||
|
||||
/**
|
||||
* 意见反馈
|
||||
*/
|
||||
private final FeedbackService feedbackService;
|
||||
|
||||
@ApiOperation(value = "添加意见反馈")
|
||||
@PostMapping()
|
||||
public ResultMessage<Object> save(Feedback feedback) {
|
||||
feedback.setUserName(UserContext.getCurrentUser().getNickName());
|
||||
if (feedbackService.save(feedback)) {
|
||||
return ResultUtil.success(ResultCode.SUCCESS);
|
||||
}
|
||||
return ResultUtil.error(ResultCode.ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package cn.lili.controller.other;
|
||||
|
||||
import cn.lili.common.utils.ResultUtil;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.system.entity.dos.Logistics;
|
||||
import cn.lili.modules.system.service.LogisticsService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
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 Bulbasaur
|
||||
* @date 2020-05-5 15:10:16
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "买家端,物流公司接口")
|
||||
@RequestMapping("/buyer/logistics")
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class LogisticsBuyerController {
|
||||
|
||||
private final LogisticsService logisticsService;
|
||||
|
||||
|
||||
@ApiOperation(value = "分页获取物流公司")
|
||||
@GetMapping
|
||||
public ResultMessage<List<Logistics>> getByPage() {
|
||||
return ResultUtil.data(logisticsService.getOpenLogistics());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package cn.lili.controller.other;
|
||||
|
||||
import cn.lili.common.utils.ResultUtil;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.page.entity.dto.PageDataDTO;
|
||||
import cn.lili.modules.page.entity.enums.PageEnum;
|
||||
import cn.lili.modules.page.entity.vos.PageDataVO;
|
||||
import cn.lili.modules.page.service.PageDataService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
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.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 买家端,页面接口
|
||||
*
|
||||
* @author Chopper
|
||||
* @date 2020/11/16 10:08 下午
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "买家端,页面接口")
|
||||
@RequestMapping("/buyer/pageData")
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class PageBuyerController {
|
||||
|
||||
/**
|
||||
* 页面管理
|
||||
*/
|
||||
private final PageDataService pageService;
|
||||
|
||||
@ApiOperation(value = "获取首页数据")
|
||||
@GetMapping("/getIndex")
|
||||
public ResultMessage<PageDataVO> getIndex(@RequestParam String clientType) {
|
||||
PageDataDTO pageDataDTO = new PageDataDTO(PageEnum.INDEX.name());
|
||||
pageDataDTO.setPageClientType(clientType);
|
||||
return ResultUtil.data(pageService.getPageData(pageDataDTO));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取页面数据")
|
||||
@GetMapping
|
||||
public ResultMessage<PageDataVO> get(PageDataDTO pageDataDTO) {
|
||||
return ResultUtil.data(pageService.getPageData(pageDataDTO));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
package cn.lili.controller.passport;
|
||||
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.sms.SmsUtil;
|
||||
import cn.lili.common.utils.ResultUtil;
|
||||
import cn.lili.common.verification.enums.VerificationEnums;
|
||||
import cn.lili.common.verification.service.VerificationService;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.member.entity.dos.Member;
|
||||
import cn.lili.modules.member.entity.dto.MemberEditDTO;
|
||||
import cn.lili.modules.member.service.MemberService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 买家端,会员接口
|
||||
*
|
||||
* @author Chopper
|
||||
* @date: 2020/11/16 10:07 下午
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "买家端,会员接口")
|
||||
@RequestMapping("/buyer/members")
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class MemberBuyerController {
|
||||
|
||||
/**
|
||||
* 会员
|
||||
*/
|
||||
private final MemberService memberService;
|
||||
|
||||
private final SmsUtil smsUtil;
|
||||
|
||||
private final VerificationService verificationService;
|
||||
|
||||
|
||||
@ApiOperation(value = "登录接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "username", value = "用户名", required = true, paramType = "query"),
|
||||
@ApiImplicitParam(name = "password", value = "密码", required = true, paramType = "query")
|
||||
})
|
||||
@PostMapping("/userLogin")
|
||||
public ResultMessage<Object> userLogin(@NotNull(message = "用户名不能为空") @RequestParam String username,
|
||||
@NotNull(message = "密码不能为空") @RequestParam String password,
|
||||
@RequestHeader String uuid) {
|
||||
if (verificationService.check(uuid, VerificationEnums.LOGIN)) {
|
||||
return ResultUtil.data(this.memberService.usernameLogin(username, password));
|
||||
} else {
|
||||
return ResultUtil.error(ResultCode.VERIFICATION_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "短信登录接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "mobile", value = "手机号", required = true, paramType = "query"),
|
||||
@ApiImplicitParam(name = "code", value = "验证码", required = true, paramType = "query")
|
||||
})
|
||||
@PostMapping("/smsLogin")
|
||||
public ResultMessage<Object> smsLogin(@NotNull(message = "手机号为空") @RequestParam String mobile,
|
||||
@NotNull(message = "验证码为空") @RequestParam String code,
|
||||
@RequestHeader String uuid) {
|
||||
// if(smsUtil.verifyCode(mobile,VerificationEnums.LOGIN,uuid,code)){
|
||||
return ResultUtil.data(memberService.mobilePhoneLogin(mobile));
|
||||
// }else {
|
||||
// return ResultUtil.error("验证码错误");
|
||||
// }
|
||||
}
|
||||
|
||||
@ApiOperation(value = "注册用户")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "username", value = "用户名", required = true, paramType = "query"),
|
||||
@ApiImplicitParam(name = "password", value = "密码", required = true, paramType = "query"),
|
||||
@ApiImplicitParam(name = "mobilePhone", value = "手机号", required = true, paramType = "query"),
|
||||
@ApiImplicitParam(name = "code", value = "验证码", required = true, paramType = "query")
|
||||
})
|
||||
@PostMapping("/register")
|
||||
public ResultMessage<Object> register(@NotNull(message = "用户名不能为空") @RequestParam String username,
|
||||
@NotNull(message = "密码不能为空") @RequestParam String password,
|
||||
@NotNull(message = "手机号为空") @RequestParam String mobilePhone,
|
||||
@RequestHeader String uuid,
|
||||
@NotNull(message = "验证码不能为空") @RequestParam String code) {
|
||||
|
||||
boolean result = smsUtil.verifyCode(mobilePhone, VerificationEnums.REGISTER, uuid, code);
|
||||
if (result) {
|
||||
return ResultUtil.data(memberService.register(username, password, mobilePhone));
|
||||
} else {
|
||||
return ResultUtil.error(ResultCode.VERIFICATION_SMS_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取当前登录用户接口")
|
||||
@GetMapping
|
||||
public ResultMessage<Member> getUserInfo() {
|
||||
|
||||
return ResultUtil.data(memberService.getUserInfo());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "通过短信重置密码")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "mobile", value = "手机号", required = true, paramType = "query"),
|
||||
@ApiImplicitParam(name = "password", value = "是否保存登录", required = true, paramType = "query")
|
||||
})
|
||||
@PostMapping("/resetByMobile")
|
||||
public ResultMessage<Member> resetByMobile(@NotNull(message = "手机号为空") @RequestParam String mobile,
|
||||
@NotNull(message = "验证码为空") @RequestParam String code,
|
||||
@RequestHeader String uuid) {
|
||||
//校验短信验证码是否正确
|
||||
if (smsUtil.verifyCode(mobile, VerificationEnums.FIND_USER, uuid, code)) {
|
||||
//校验是否通过手机号可获取会员,存在则将会员信息存入缓存,有效时间3分钟
|
||||
if (memberService.findByMobile(uuid, mobile)) {
|
||||
return ResultUtil.success(ResultCode.SUCCESS);
|
||||
}
|
||||
}
|
||||
return ResultUtil.error(ResultCode.VERIFICATION_ERROR);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改密码")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "mobile", value = "手机号", required = true, paramType = "query"),
|
||||
@ApiImplicitParam(name = "password", value = "是否保存登录", required = true, paramType = "query")
|
||||
})
|
||||
@PostMapping("/resetPassword")
|
||||
public ResultMessage<Object> resetByMobile(@NotNull(message = "密码为空") @RequestParam String password, @RequestHeader String uuid) {
|
||||
|
||||
return ResultUtil.data(memberService.resetByMobile(uuid, password));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改用户自己资料")
|
||||
@PutMapping("/editOwn")
|
||||
public ResultMessage<Member> editOwn(MemberEditDTO memberEditDTO) {
|
||||
|
||||
return ResultUtil.data(memberService.editOwn(memberEditDTO));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改密码")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "password", value = "旧密码", required = true, paramType = "query"),
|
||||
@ApiImplicitParam(name = "newPassword", value = "新密码", required = true, paramType = "query")
|
||||
})
|
||||
@PutMapping("/modifyPass")
|
||||
public ResultMessage<Member> modifyPass(@NotNull(message = "旧密码不能为空") @RequestParam String password,
|
||||
@NotNull(message = "新密码不能为空") @RequestParam String newPassword) {
|
||||
return ResultUtil.data(memberService.modifyPass(password, newPassword));
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "刷新token")
|
||||
@GetMapping("/refresh/{refreshToken}")
|
||||
public ResultMessage<Object> refreshToken(@NotNull(message = "刷新token不能为空") @PathVariable String refreshToken) {
|
||||
return ResultUtil.data(this.memberService.refreshToken(refreshToken));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package cn.lili.controller.passport.connect;
|
||||
|
||||
|
||||
import cn.lili.common.utils.ResultUtil;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.connect.service.ConnectService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 买家端,app/小程序 联合登录
|
||||
*
|
||||
* @author Chopper
|
||||
* @date 2020-11-25 19:29
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "买家端,app/小程序 联合登录")
|
||||
@RequestMapping("/buyer/connect/bind")
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class ConnectBuyerBindController {
|
||||
|
||||
private final ConnectService connectService;
|
||||
|
||||
@ApiOperation(value = "unionID 绑定")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "unionID", value = "unionID", required = true, paramType = "query"),
|
||||
@ApiImplicitParam(name = "type", value = "type", required = true, paramType = "query")
|
||||
})
|
||||
@PostMapping
|
||||
public void unionIDBind(@RequestParam String unionID, @RequestParam String type) {
|
||||
connectService.bind(unionID, type);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "unionID 解绑")
|
||||
@ApiImplicitParam(name = "type", value = "type", required = true, paramType = "query")
|
||||
@PostMapping("/unbind")
|
||||
public void unionIDBind(@RequestParam String type) {
|
||||
connectService.unbind(type);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/list")
|
||||
@ApiOperation(value = "绑定列表")
|
||||
public ResultMessage<List<String>> bindList() {
|
||||
return ResultUtil.data(connectService.bindList());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package cn.lili.controller.passport.connect;
|
||||
|
||||
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.token.Token;
|
||||
import cn.lili.common.utils.ResultUtil;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.connect.entity.dto.AuthCallback;
|
||||
import cn.lili.modules.connect.entity.dto.ConnectAuthUser;
|
||||
import cn.lili.modules.connect.request.AuthRequest;
|
||||
import cn.lili.modules.connect.service.ConnectService;
|
||||
import cn.lili.modules.connect.util.ConnectUtil;
|
||||
import cn.lili.modules.connect.util.UuidUtils;
|
||||
import cn.lili.modules.member.service.MemberService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* 买家端,web联合登录
|
||||
*
|
||||
* @author Chopper
|
||||
* @date 2020-11-25 19:29
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "买家端,web联合登录")
|
||||
@RequestMapping("/buyer/connect")
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class ConnectBuyerWebController {
|
||||
|
||||
private final ConnectService connectService;
|
||||
|
||||
private final MemberService memberService;
|
||||
|
||||
private final ConnectUtil connectUtil;
|
||||
|
||||
|
||||
@GetMapping("/login/web/{type}")
|
||||
@ApiOperation(value = "WEB信任登录授权")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "type", value = "登录方式:QQ,微信,微信_PC",
|
||||
allowableValues = "QQ,WECHAT,WECHAT_PC", paramType = "path")
|
||||
})
|
||||
public ResultMessage<String> webAuthorize(@PathVariable String type, HttpServletResponse response) throws IOException {
|
||||
AuthRequest authRequest = connectUtil.getAuthRequest(type);
|
||||
String authorizeUrl = authRequest.authorize(UuidUtils.getUUID());
|
||||
response.sendRedirect(authorizeUrl);
|
||||
return ResultUtil.data(authorizeUrl);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "信任登录统一回调地址", hidden = true)
|
||||
@GetMapping("/callback/{type}")
|
||||
public void callBack(@PathVariable String type, AuthCallback callback, HttpServletResponse httpServletResponse) throws IOException {
|
||||
connectUtil.callback(type, callback, httpServletResponse);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "信任登录响应结果获取")
|
||||
@GetMapping("/result")
|
||||
public ResultMessage<Object> callBackResult(String state) {
|
||||
if (state == null) {
|
||||
return ResultUtil.error(ResultCode.USER_CONNECT_LOGIN_ERROR);
|
||||
}
|
||||
return connectUtil.getResult(state);
|
||||
}
|
||||
|
||||
@GetMapping("/register/auto")
|
||||
@ApiOperation(value = "WEB信任登录授权")
|
||||
public ResultMessage<Token> webAuthorize() {
|
||||
Token token = memberService.autoRegister();
|
||||
return ResultUtil.data(token);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "unionID登录")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "openId", value = "openid", required = true, paramType = "query"),
|
||||
@ApiImplicitParam(name = "type", value = "联合类型", required = true,
|
||||
allowableValues = "WECHAT,QQ,ALIPAY,WEIBO,APPLE", paramType = "query"),
|
||||
@ApiImplicitParam(name = "uniAccessToken", value = "联合登陆返回的accessToken", required = true, paramType = "query")
|
||||
})
|
||||
@GetMapping("/app/login")
|
||||
public ResultMessage<Token> unionIDLogin(ConnectAuthUser authUser, @RequestHeader("uuid") String uuid) {
|
||||
try {
|
||||
return ResultUtil.data(connectService.appLoginCallback(authUser, uuid));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package cn.lili.controller.passport.connect;
|
||||
|
||||
import cn.lili.common.token.Token;
|
||||
import cn.lili.common.utils.ResultUtil;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.connect.entity.dto.WechatMPLoginParams;
|
||||
import cn.lili.modules.connect.service.ConnectService;
|
||||
import cn.lili.modules.message.entity.dos.WechatMPMessage;
|
||||
import cn.lili.modules.message.service.ShortLinkService;
|
||||
import cn.lili.modules.message.service.WechatMPMessageService;
|
||||
import cn.lili.modules.message.util.WechatMpCodeUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 买家端,小程序登录接口
|
||||
*
|
||||
* @author Chopper
|
||||
* @date 2021/2/19 09:28
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/buyer/mini-program")
|
||||
@Api(tags = "买家端,小程序登录接口")
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class MiniProgramBuyerController {
|
||||
|
||||
public final ConnectService connectService;
|
||||
public final WechatMpCodeUtil wechatMpCodeUtil;
|
||||
|
||||
public final WechatMPMessageService wechatMPMessageService;
|
||||
public final ShortLinkService shortLinkService;
|
||||
|
||||
@GetMapping("/auto-login")
|
||||
@ApiOperation(value = "小程序自动登录")
|
||||
public ResultMessage<Token> autoLogin(@RequestHeader String uuid, WechatMPLoginParams params) {
|
||||
params.setUuid(uuid);
|
||||
return ResultUtil.data(this.connectService.miniProgramAutoLogin(params));
|
||||
}
|
||||
|
||||
@GetMapping("/subscribeMessage")
|
||||
@ApiOperation(value = "消息订阅")
|
||||
public ResultMessage<List<WechatMPMessage>> autoLogin() {
|
||||
return ResultUtil.data(wechatMPMessageService.list());
|
||||
}
|
||||
|
||||
@GetMapping("/mp/unlimited")
|
||||
@ApiOperation(value = "小程序二维码生成:不限制数量,但是限制长度,只能存放32为长度")
|
||||
public ResultMessage<String> unlimited(String page, String scene) {
|
||||
return ResultUtil.data(wechatMpCodeUtil.createCode(page, scene));
|
||||
}
|
||||
|
||||
@GetMapping("/mp/qrcode")
|
||||
@ApiOperation(value = "小程序二维码生成:只适用于少量场景,多数场景需要unlimited接口实现")
|
||||
public ResultMessage<String> qrcode(String page) {
|
||||
return ResultUtil.data(wechatMpCodeUtil.createQrCode(page));
|
||||
}
|
||||
|
||||
@GetMapping("/mp/unlimited/scene")
|
||||
@ApiOperation(value = "根据shortlink 获取页面参数")
|
||||
public ResultMessage<String> getScene(String id) {
|
||||
return ResultUtil.data(shortLinkService.getById(id).getOriginalParams());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
package cn.lili.controller.payment;
|
||||
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.utils.ResultUtil;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.payment.kit.CashierSupport;
|
||||
import cn.lili.modules.payment.kit.dto.PayParam;
|
||||
import cn.lili.modules.payment.kit.enums.PaymentClientEnum;
|
||||
import cn.lili.modules.payment.kit.enums.PaymentMethodEnum;
|
||||
import cn.lili.modules.payment.kit.params.dto.CashierParam;
|
||||
import cn.lili.modules.payment.service.PaymentService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* 买家端,收银台接口
|
||||
*
|
||||
* @author Chopper
|
||||
* @date 2020-12-18 16:59
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "买家端,收银台接口")
|
||||
@RequestMapping("/buyer/cashier")
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class CashierController {
|
||||
|
||||
|
||||
private final CashierSupport cashierSupport;
|
||||
|
||||
private final PaymentService paymentService;
|
||||
|
||||
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "client", value = "客户端类型", paramType = "path", allowableValues = "PC,H5,WECHAT_MP,APP")
|
||||
})
|
||||
@GetMapping(value = "/tradeDetail")
|
||||
@ApiOperation(value = "获取支付详情")
|
||||
public ResultMessage paymentParams(@Validated PayParam payParam) {
|
||||
CashierParam cashierParam = cashierSupport.cashierParam(payParam);
|
||||
return ResultUtil.data(cashierParam);
|
||||
}
|
||||
|
||||
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "paymentMethod", value = "支付方式", paramType = "path", allowableValues = "WECHAT,ALIPAY"),
|
||||
@ApiImplicitParam(name = "paymentClient", value = "调起方式", paramType = "path", allowableValues = "APP,NATIVE,JSAPI,H5,MP")
|
||||
})
|
||||
@GetMapping(value = "/pay/{paymentMethod}/{paymentClient}")
|
||||
@ApiOperation(value = "支付")
|
||||
public ResultMessage payment(
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response,
|
||||
@PathVariable String paymentMethod,
|
||||
@PathVariable String paymentClient,
|
||||
@Validated PayParam payParam) {
|
||||
PaymentMethodEnum paymentMethodEnum = PaymentMethodEnum.valueOf(paymentMethod);
|
||||
PaymentClientEnum paymentClientEnum = PaymentClientEnum.valueOf(paymentClient);
|
||||
|
||||
try {
|
||||
return cashierSupport.payment(paymentMethodEnum, paymentClientEnum, request, response, payParam);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ApiOperation(value = "支付回调")
|
||||
@RequestMapping(value = "/callback/{paymentMethod}", method = {RequestMethod.GET, RequestMethod.POST})
|
||||
public ResultMessage<Object> callback(HttpServletRequest request, @PathVariable String paymentMethod) {
|
||||
|
||||
PaymentMethodEnum paymentMethodEnum = PaymentMethodEnum.valueOf(paymentMethod);
|
||||
|
||||
cashierSupport.callback(paymentMethodEnum, request);
|
||||
|
||||
return ResultUtil.success(ResultCode.PAY_SUCCESS);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "支付异步通知")
|
||||
@RequestMapping(value = "/notify/{paymentMethod}", method = {RequestMethod.GET, RequestMethod.POST})
|
||||
public void notify(HttpServletRequest request, @PathVariable String paymentMethod) {
|
||||
|
||||
PaymentMethodEnum paymentMethodEnum = PaymentMethodEnum.valueOf(paymentMethod);
|
||||
|
||||
cashierSupport.notify(paymentMethodEnum, request);
|
||||
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查询支付结果")
|
||||
@GetMapping(value = "/result")
|
||||
public ResultMessage<Boolean> paymentResult(PayParam payParam) {
|
||||
return ResultUtil.data(cashierSupport.paymentResult(payParam));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package cn.lili.controller.payment;
|
||||
|
||||
import cn.lili.modules.payment.kit.RefundSupport;
|
||||
import cn.lili.modules.payment.kit.enums.PaymentMethodEnum;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* 买家端,退款回调
|
||||
*
|
||||
* @author Chopper
|
||||
* @date 2020-12-18 16:59
|
||||
*/
|
||||
@Api(tags = "买家端,退款回调")
|
||||
@RestController
|
||||
@RequestMapping("/buyer/cashier/refund")
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class CashierRefundController {
|
||||
|
||||
|
||||
private final RefundSupport refundSupport;
|
||||
|
||||
|
||||
@ApiOperation(value = "退款通知")
|
||||
@RequestMapping(value = "/notify/{paymentMethod}", method = {RequestMethod.GET, RequestMethod.POST})
|
||||
public void notify(HttpServletRequest request, @PathVariable String paymentMethod) {
|
||||
PaymentMethodEnum paymentMethodEnum = PaymentMethodEnum.valueOf(paymentMethod);
|
||||
refundSupport.notify(paymentMethodEnum, request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package cn.lili.controller.promotion;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.lili.common.utils.ResultUtil;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.promotion.entity.dto.PromotionGoodsDTO;
|
||||
import cn.lili.modules.promotion.entity.enums.PromotionStatusEnum;
|
||||
import cn.lili.modules.promotion.entity.enums.PromotionTypeEnum;
|
||||
import cn.lili.modules.promotion.entity.vos.PintuanMemberVO;
|
||||
import cn.lili.modules.promotion.entity.vos.PintuanShareVO;
|
||||
import cn.lili.modules.promotion.entity.vos.PromotionGoodsSearchParams;
|
||||
import cn.lili.modules.promotion.service.PintuanService;
|
||||
import cn.lili.modules.promotion.service.PromotionGoodsService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 买家端,拼团接口
|
||||
*
|
||||
* @author paulG
|
||||
* @date 2021/2/20
|
||||
**/
|
||||
@Api(tags = "买家端,拼团接口")
|
||||
@RestController
|
||||
@RequestMapping("/buyer/promotion/pintuan")
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class PintuanBuyerController {
|
||||
|
||||
private final PromotionGoodsService promotionGoodsService;
|
||||
|
||||
private final PintuanService pintuanService;
|
||||
|
||||
@ApiOperation(value = "获取拼团商品")
|
||||
@GetMapping
|
||||
public ResultMessage<IPage<PromotionGoodsDTO>> getPintuanCategory(String goodsName, String categoryPath, PageVO pageVo) {
|
||||
PromotionGoodsSearchParams searchParams = new PromotionGoodsSearchParams();
|
||||
searchParams.setGoodsName(goodsName);
|
||||
searchParams.setPromotionType(PromotionTypeEnum.PINTUAN.name());
|
||||
searchParams.setPromotionStatus(PromotionStatusEnum.START.name());
|
||||
searchParams.setCategoryPath(categoryPath);
|
||||
searchParams.setEndTime(DateUtil.date().getTime());
|
||||
return ResultUtil.data(promotionGoodsService.getPromotionGoods(searchParams, pageVo));
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "获取当前拼团活动的未成团的会员")
|
||||
@GetMapping("/{pintuanId}/members")
|
||||
public ResultMessage<List<PintuanMemberVO>> getPintuanMember(@PathVariable String pintuanId) {
|
||||
return ResultUtil.data(pintuanService.getPintuanMember(pintuanId));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取当前拼团订单的拼团分享信息")
|
||||
@GetMapping("/share")
|
||||
public ResultMessage<PintuanShareVO> share(String parentOrderSn, String skuId) {
|
||||
return ResultUtil.data(pintuanService.getPintuanShareInfo(parentOrderSn, skuId));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package cn.lili.controller.promotion;
|
||||
|
||||
import cn.lili.common.utils.ResultUtil;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.promotion.entity.dos.PointsGoodsCategory;
|
||||
import cn.lili.modules.promotion.entity.vos.PointsGoodsSearchParams;
|
||||
import cn.lili.modules.promotion.entity.vos.PointsGoodsVO;
|
||||
import cn.lili.modules.promotion.service.PointsGoodsCategoryService;
|
||||
import cn.lili.modules.promotion.service.PointsGoodsService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 买家端,积分商品接口
|
||||
*
|
||||
* @author paulG
|
||||
* @date 2021/1/19
|
||||
**/
|
||||
@RestController
|
||||
@Api(tags = "买家端,积分商品接口")
|
||||
@RequestMapping("/buyer/promotion/pointsGoods")
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class PointsGoodsBuyerController {
|
||||
|
||||
private final PointsGoodsService pointsGoodsService;
|
||||
|
||||
private final PointsGoodsCategoryService pointsGoodsCategoryService;
|
||||
|
||||
@GetMapping
|
||||
@ApiOperation(value = "分页获取积分商品")
|
||||
public ResultMessage<IPage<PointsGoodsVO>> getPointsGoodsPage(PointsGoodsSearchParams searchParams, PageVO page) {
|
||||
IPage<PointsGoodsVO> pointsGoodsByPage = pointsGoodsService.getPointsGoodsByPage(searchParams, page);
|
||||
return ResultUtil.data(pointsGoodsByPage);
|
||||
}
|
||||
|
||||
@GetMapping("/category")
|
||||
@ApiOperation(value = "获取积分商品分类分页")
|
||||
public ResultMessage<IPage<PointsGoodsCategory>> page(String name, PageVO page) {
|
||||
return ResultUtil.data(pointsGoodsCategoryService.getCategoryByPage(name, page));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package cn.lili.controller.promotion;
|
||||
|
||||
import cn.lili.common.utils.ResultUtil;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.promotion.entity.vos.SeckillGoodsVO;
|
||||
import cn.lili.modules.promotion.entity.vos.SeckillTimelineVO;
|
||||
import cn.lili.modules.promotion.service.SeckillApplyService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 买家端,限时抢购接口
|
||||
*
|
||||
* @author paulG
|
||||
* @date 2020/11/17 2:30 下午
|
||||
*/
|
||||
@Api(tags = "买家端,限时抢购接口")
|
||||
@RestController
|
||||
@RequestMapping("/buyer/promotion/seckill")
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class SeckillBuyerController {
|
||||
|
||||
/**
|
||||
* 限时抢购
|
||||
*/
|
||||
private final SeckillApplyService seckillApplyService;
|
||||
|
||||
@ApiOperation(value = "获取当天限时抢购信息")
|
||||
@GetMapping
|
||||
public ResultMessage<List<SeckillTimelineVO>> getSeckillTime() {
|
||||
return ResultUtil.data(seckillApplyService.getSeckillTimeline());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取某个时刻的限时抢购商品信息")
|
||||
@GetMapping("/{timeline}")
|
||||
public ResultMessage<List<SeckillGoodsVO>> getSeckillGoods(@PathVariable Integer timeline) {
|
||||
return ResultUtil.data(seckillApplyService.getSeckillGoods(timeline));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package cn.lili.controller.purchase;
|
||||
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.utils.ResultUtil;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.purchase.entity.dos.PurchaseOrder;
|
||||
import cn.lili.modules.purchase.entity.params.PurchaseOrderSearchParams;
|
||||
import cn.lili.modules.purchase.entity.vos.PurchaseOrderVO;
|
||||
import cn.lili.modules.purchase.service.PurchaseOrderService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 买家端,采购接口
|
||||
*
|
||||
* @author Chopper
|
||||
* @date: 2020/11/16 10:06 下午
|
||||
*/
|
||||
@Api(tags = "买家端,采购接口")
|
||||
@RestController
|
||||
@RequestMapping("/buyer/purchase")
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class PurchaseBuyerController {
|
||||
|
||||
/**
|
||||
* 采购单
|
||||
*/
|
||||
private final PurchaseOrderService purchaseOrderService;
|
||||
|
||||
@ApiOperation(value = "添加采购单")
|
||||
@PostMapping
|
||||
public ResultMessage<PurchaseOrderVO> addPurchaseOrderVO(PurchaseOrderVO purchaseOrderVO) {
|
||||
return ResultUtil.data(purchaseOrderService.addPurchaseOrder(purchaseOrderVO));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "采购单分页")
|
||||
@GetMapping
|
||||
public ResultMessage<IPage<PurchaseOrder>> get(PurchaseOrderSearchParams purchaseOrderSearchParams) {
|
||||
return ResultUtil.data(purchaseOrderService.page(purchaseOrderSearchParams));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "采购单详情")
|
||||
@ApiImplicitParam(name = "id", value = "采购单ID", required = true, dataType = "Long", paramType = "path")
|
||||
@GetMapping("/{id}")
|
||||
public ResultMessage<PurchaseOrderVO> getPurchaseOrder(@NotNull @PathVariable String id) {
|
||||
return ResultUtil.data(purchaseOrderService.getPurchaseOrder(id));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "会员采购单分页")
|
||||
@GetMapping("/getByMember")
|
||||
public ResultMessage<IPage<PurchaseOrder>> getByMember(PurchaseOrderSearchParams purchaseOrderSearchParams) {
|
||||
purchaseOrderSearchParams.setMemberId(UserContext.getCurrentUser().getId());
|
||||
return ResultUtil.data(purchaseOrderService.page(purchaseOrderSearchParams));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "关闭采购单")
|
||||
@ApiImplicitParam(name = "id", value = "采购单ID", required = true, dataType = "Long", paramType = "path")
|
||||
@PutMapping("/{id}")
|
||||
public ResultMessage<Object> close(@NotNull @PathVariable String id) {
|
||||
|
||||
if (purchaseOrderService.close(id)) {
|
||||
return ResultUtil.success(ResultCode.SUCCESS);
|
||||
}
|
||||
return ResultUtil.error(ResultCode.ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package cn.lili.controller.purchase;
|
||||
|
||||
import cn.lili.common.utils.ResultUtil;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.purchase.entity.dos.PurchaseQuoted;
|
||||
import cn.lili.modules.purchase.entity.vos.PurchaseQuotedVO;
|
||||
import cn.lili.modules.purchase.service.PurchaseQuotedService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 买家端,采购报价接口
|
||||
*
|
||||
* @author Bulbasaur
|
||||
* @date: 2020/11/16 10:06 下午
|
||||
*/
|
||||
@Api(tags = "买家端,采购报价接口")
|
||||
@RestController
|
||||
@RequestMapping("/buyer/purchaseQuoted")
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class PurchaseQuotedController {
|
||||
|
||||
/**
|
||||
* 采购单报价
|
||||
*/
|
||||
private final PurchaseQuotedService purchaseQuotedService;
|
||||
|
||||
@ApiOperation(value = "添加采购单报价")
|
||||
@PostMapping
|
||||
public ResultMessage<PurchaseQuoted> addPurchaseOrderVO(PurchaseQuotedVO purchaseQuotedVO) {
|
||||
return ResultUtil.data(purchaseQuotedService.addPurchaseQuoted(purchaseQuotedVO));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "报价列表")
|
||||
@ApiImplicitParam(name = "purchaseOrderId", value = "报价单ID", required = true, dataType = "String", paramType = "path")
|
||||
@GetMapping("/purchaseOrder/{purchaseOrderId}")
|
||||
public ResultMessage<List<PurchaseQuoted>> get(@NotNull @PathVariable String purchaseOrderId) {
|
||||
return ResultUtil.data(purchaseQuotedService.getByPurchaseOrderId(purchaseOrderId));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "报价单详情")
|
||||
@ApiImplicitParam(name = "id", value = "报价单ID", required = true, dataType = "String", paramType = "path")
|
||||
@GetMapping(value = "purchaseQuoted/{id}")
|
||||
public ResultMessage<PurchaseQuotedVO> getPurchaseQuoted(@NotNull @PathVariable String id) {
|
||||
return ResultUtil.data(purchaseQuotedService.getById(id));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
package cn.lili.controller.store;
|
||||
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.utils.ResultUtil;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.statistics.aop.PageViewPoint;
|
||||
import cn.lili.modules.statistics.aop.enums.PageViewEnum;
|
||||
import cn.lili.modules.store.entity.dto.StoreBankDTO;
|
||||
import cn.lili.modules.store.entity.dto.StoreCompanyDTO;
|
||||
import cn.lili.modules.store.entity.dto.StoreOtherInfoDTO;
|
||||
import cn.lili.modules.store.entity.vos.*;
|
||||
import cn.lili.modules.store.service.StoreDetailService;
|
||||
import cn.lili.modules.store.service.StoreGoodsLabelService;
|
||||
import cn.lili.modules.store.service.StoreService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 买家端,店铺接口
|
||||
*
|
||||
* @author Bulbasaur
|
||||
* @date: 2020/11/17 2:32 下午
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/buyer/store")
|
||||
@Api(tags = "买家端,店铺接口")
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class StoreBuyerController {
|
||||
|
||||
/**
|
||||
* 店铺
|
||||
*/
|
||||
private final StoreService storeService;
|
||||
/**
|
||||
* 店铺商品分类
|
||||
*/
|
||||
private final StoreGoodsLabelService storeGoodsLabelService;
|
||||
/**
|
||||
* 店铺详情
|
||||
*/
|
||||
private final StoreDetailService storeDetailService;
|
||||
|
||||
@ApiOperation(value = "获取店铺列表分页")
|
||||
@GetMapping
|
||||
public ResultMessage<IPage<StoreVO>> getByPage(StoreSearchParams entity, PageVO page) {
|
||||
return ResultUtil.data(storeService.findByConditionPage(entity, page));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "通过id获取店铺信息")
|
||||
@ApiImplicitParam(name = "id", value = "店铺ID", required = true, paramType = "path")
|
||||
@GetMapping(value = "/get/detail/{id}")
|
||||
@PageViewPoint(type = PageViewEnum.STORE, id = "#id")
|
||||
public ResultMessage<StoreBasicInfoVO> detail(@NotNull @PathVariable String id) {
|
||||
return ResultUtil.data(storeDetailService.getStoreBasicInfoDTO(id));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "通过id获取店铺商品分类")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "店铺ID", required = true, paramType = "path")
|
||||
})
|
||||
@GetMapping(value = "/label/get/{id}")
|
||||
public ResultMessage<List<StoreGoodsLabelVO>> storeGoodsLabel(@NotNull @PathVariable String id) {
|
||||
return ResultUtil.data(storeGoodsLabelService.listByStoreId(id));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "申请店铺第一步-填写企业信息")
|
||||
@PutMapping(value = "/apply/first")
|
||||
public ResultMessage<Object> applyFirstStep(StoreCompanyDTO storeCompanyDTO) {
|
||||
if (storeService.applyFirstStep(storeCompanyDTO)) {
|
||||
return ResultUtil.success(ResultCode.SUCCESS);
|
||||
}
|
||||
return ResultUtil.error(ResultCode.ERROR);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "申请店铺第二步-填写银行信息")
|
||||
@PutMapping(value = "/apply/second")
|
||||
public ResultMessage<Object> applyFirstStep(StoreBankDTO storeBankDTO) {
|
||||
if (storeService.applySecondStep(storeBankDTO)) {
|
||||
return ResultUtil.success(ResultCode.SUCCESS);
|
||||
}
|
||||
return ResultUtil.error(ResultCode.ERROR);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "申请店铺第三步-填写其他信息")
|
||||
@PutMapping(value = "/apply/third")
|
||||
public ResultMessage<Object> applyFirstStep(StoreOtherInfoDTO storeOtherInfoDTO) {
|
||||
if (storeService.applyThirdStep(storeOtherInfoDTO)) {
|
||||
return ResultUtil.success(ResultCode.SUCCESS);
|
||||
}
|
||||
return ResultUtil.error(ResultCode.ERROR);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取当前登录会员的店铺信息-入驻店铺")
|
||||
@GetMapping(value = "/apply")
|
||||
public ResultMessage<StoreDetailVO> apply() {
|
||||
return ResultUtil.data(storeDetailService.getStoreDetailVOByMemberId(UserContext.getCurrentUser().getId()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
package cn.lili.controller.trade;
|
||||
|
||||
import cn.lili.common.utils.ResultUtil;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.order.order.entity.dos.AfterSale;
|
||||
import cn.lili.modules.order.order.entity.dos.AfterSaleReason;
|
||||
import cn.lili.modules.order.order.entity.dto.AfterSaleDTO;
|
||||
import cn.lili.modules.order.order.entity.vo.AfterSaleApplyVO;
|
||||
import cn.lili.modules.order.order.entity.vo.AfterSaleSearchParams;
|
||||
import cn.lili.modules.order.order.entity.vo.AfterSaleVO;
|
||||
import cn.lili.modules.order.order.service.AfterSaleReasonService;
|
||||
import cn.lili.modules.order.order.service.AfterSaleService;
|
||||
import cn.lili.modules.store.entity.dto.StoreAfterSaleAddressDTO;
|
||||
import cn.lili.modules.order.trade.entity.dos.AfterSaleLog;
|
||||
import cn.lili.modules.order.order.service.AfterSaleLogService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 买家端,售后管理接口
|
||||
*
|
||||
* @author Chopper
|
||||
* @date 2020/11/16 10:02 下午
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "买家端,售后管理接口")
|
||||
@RequestMapping("/buyer/afterSale")
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class AfterSaleBuyerController {
|
||||
|
||||
/**
|
||||
* 售后
|
||||
*/
|
||||
private final AfterSaleService afterSaleService;
|
||||
|
||||
/**
|
||||
* 售后原因
|
||||
*/
|
||||
private final AfterSaleReasonService afterSaleReasonService;
|
||||
|
||||
/**
|
||||
* 售后日志
|
||||
*/
|
||||
private final AfterSaleLogService afterSaleLogService;
|
||||
|
||||
@ApiOperation(value = "查看售后服务详情")
|
||||
@ApiImplicitParam(name = "sn", value = "售后单号", required = true, paramType = "path")
|
||||
@GetMapping(value = "/get/{sn}")
|
||||
public ResultMessage<AfterSaleVO> get(@NotNull(message = "售后单号") @PathVariable("sn") String sn) {
|
||||
return ResultUtil.data(afterSaleService.getAfterSale(sn));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "分页获取售后服务")
|
||||
@GetMapping(value = "/page")
|
||||
public ResultMessage<IPage<AfterSaleVO>> getByPage(AfterSaleSearchParams searchParams) {
|
||||
return ResultUtil.data(afterSaleService.getAfterSalePages(searchParams));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取申请售后页面信息")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "sn", value = "订单货物编号", required = true, dataType = "String", paramType = "path")
|
||||
})
|
||||
@GetMapping(value = "/applyAfterSaleInfo/{sn}")
|
||||
public ResultMessage<AfterSaleApplyVO> applyAfterSaleInfo(@PathVariable String sn) {
|
||||
return ResultUtil.data(afterSaleService.getAfterSaleDTO(sn));
|
||||
}
|
||||
|
||||
@PostMapping(value = "/save/{orderItemSn}")
|
||||
@ApiImplicitParam(name = "orderItemSn", value = "订单货物编号", required = true, paramType = "query")
|
||||
@ApiOperation(value = "申请售后")
|
||||
public ResultMessage<AfterSale> save(AfterSaleDTO afterSaleDTO) {
|
||||
return ResultUtil.data(afterSaleService.saveAfterSale(afterSaleDTO));
|
||||
|
||||
}
|
||||
|
||||
@ApiOperation(value = "买家 退回 物流信息")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "afterSaleSn", value = "售后sn", required = true, dataType = "String", paramType = "path"),
|
||||
@ApiImplicitParam(name = "logisticsNo", value = "发货单号", required = true, dataType = "String", paramType = "query"),
|
||||
@ApiImplicitParam(name = "logisticsId", value = "物流公司id", required = true, dataType = "String", paramType = "query"),
|
||||
@ApiImplicitParam(name = "mDeliverTime", value = "买家发货时间", required = true, dataType = "date", paramType = "query")
|
||||
|
||||
})
|
||||
@PostMapping(value = "/delivery/{afterSaleSn}")
|
||||
public ResultMessage<AfterSale> delivery(@NotNull(message = "售后编号不能为空") @PathVariable("afterSaleSn") String afterSaleSn,
|
||||
@NotNull(message = "发货单号不能为空") @RequestParam String logisticsNo,
|
||||
@NotNull(message = "请选择物流公司") @RequestParam String logisticsId,
|
||||
@NotNull(message = "请选择发货时间") @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") Date mDeliverTime) {
|
||||
return ResultUtil.data(afterSaleService.buyerDelivery(afterSaleSn, logisticsNo, logisticsId, mDeliverTime));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "售后,取消售后")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "afterSaleSn", value = "售后sn", required = true, dataType = "String", paramType = "path")
|
||||
})
|
||||
@PostMapping(value = "/cancel/{afterSaleSn}")
|
||||
public ResultMessage<AfterSale> cancel(@NotNull(message = "参数非法") @PathVariable("afterSaleSn") String afterSaleSn) {
|
||||
return ResultUtil.data(afterSaleService.cancel(afterSaleSn));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取商家售后收件地址")
|
||||
@ApiImplicitParam(name = "sn", value = "售后单号", required = true, paramType = "path")
|
||||
@GetMapping(value = "/getStoreAfterSaleAddress/{sn}")
|
||||
public ResultMessage<StoreAfterSaleAddressDTO> getStoreAfterSaleAddress(@NotNull(message = "售后单号") @PathVariable("sn") String sn) {
|
||||
return ResultUtil.data(afterSaleService.getStoreAfterSaleAddressDTO(sn));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取售后原因")
|
||||
@ApiImplicitParam(name = "serviceType", value = "售后类型", required = true, paramType = "path", allowableValues = "CANCEL,RETURN_GOODS,RETURN_MONEY,COMPLAIN")
|
||||
@GetMapping(value = "/get/afterSaleReason/{serviceType}")
|
||||
public ResultMessage<List<AfterSaleReason>> getAfterSaleReason(@PathVariable String serviceType) {
|
||||
return ResultUtil.data(afterSaleReasonService.afterSaleReasonList(serviceType));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取售后日志")
|
||||
@ApiImplicitParam(name = "sn", value = "售后编号", required = true, paramType = "path")
|
||||
@GetMapping(value = "/get/getAfterSaleLog/{sn}")
|
||||
public ResultMessage<List<AfterSaleLog>> getAfterSaleLog(@PathVariable String sn) {
|
||||
return ResultUtil.data(afterSaleLogService.getAfterSaleLog(sn));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,240 @@
|
||||
package cn.lili.controller.trade;
|
||||
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.utils.ResultUtil;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.order.cart.entity.dto.TradeDTO;
|
||||
import cn.lili.modules.order.cart.entity.enums.CartTypeEnum;
|
||||
import cn.lili.modules.order.cart.entity.vo.TradeParams;
|
||||
import cn.lili.modules.order.cart.service.CartService;
|
||||
import cn.lili.modules.order.order.entity.vo.ReceiptVO;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 买家端,购物车接口
|
||||
*
|
||||
* @author Chopper
|
||||
* @date 2020/11/16 10:04 下午
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@Api(tags = "买家端,购物车接口")
|
||||
@RequestMapping("/buyer/trade/carts")
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class CartController {
|
||||
|
||||
/**
|
||||
* 购物车
|
||||
*/
|
||||
private final CartService cartService;
|
||||
|
||||
|
||||
@ApiOperation(value = "向购物车中添加一个产品")
|
||||
@PostMapping
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "skuId", value = "产品ID", required = true, dataType = "Long", paramType = "query"),
|
||||
@ApiImplicitParam(name = "num", value = "此产品的购买数量", required = true, dataType = "int", paramType = "query"),
|
||||
@ApiImplicitParam(name = "cartType", value = "购物车类型,默认加入购物车", paramType = "query")
|
||||
})
|
||||
public ResultMessage<Object> add(@NotNull(message = "产品id不能为空") String skuId,
|
||||
@NotNull(message = "购买数量不能为空") @Min(value = 1, message = "加入购物车数量必须大于0") Integer num,
|
||||
String cartType) {
|
||||
cartService.add(skuId, num, cartType);
|
||||
return ResultUtil.success(ResultCode.SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "获取购物车页面购物车详情")
|
||||
@GetMapping("/all")
|
||||
public ResultMessage<TradeDTO> cartAll() {
|
||||
return ResultUtil.data(this.cartService.getAllTradeDTO());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取购物车数量")
|
||||
@GetMapping("/count")
|
||||
public ResultMessage<Long> cartCount(@RequestParam(required = false) Boolean checked) {
|
||||
return ResultUtil.data(this.cartService.getCartNum(checked));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取购物车可用优惠券数量")
|
||||
@GetMapping("/coupon/num")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "way", value = "购物车购买:CART/立即购买:BUY_NOW/拼团购买:PINTUAN / 积分购买:POINT ", required = true, paramType = "query")
|
||||
})
|
||||
public ResultMessage<Long> cartCouponNum(String way) {
|
||||
return ResultUtil.data(this.cartService.getCanUseCoupon(CartTypeEnum.valueOf(way)));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "更新购物车中单个产品数量", notes = "更新购物车中的多个产品的数量或选中状态")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "skuId", value = "产品id数组", required = true, dataType = "Long", paramType = "path"),
|
||||
@ApiImplicitParam(name = "num", value = "产品数量", dataType = "int", paramType = "query"),
|
||||
})
|
||||
@PostMapping(value = "/sku/num/{skuId}")
|
||||
public ResultMessage<Object> update(@NotNull(message = "产品id不能为空") @PathVariable(name = "skuId") String skuId,
|
||||
Integer num) {
|
||||
cartService.updateNum(skuId, num);
|
||||
return ResultUtil.success(ResultCode.SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "更新购物车中单个产品", notes = "更新购物车中的多个产品的数量或选中状态")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "skuId", value = "产品id数组", required = true, dataType = "Long", paramType = "path")
|
||||
})
|
||||
@PostMapping(value = "/sku/checked/{skuId}")
|
||||
public ResultMessage<Object> updateChecked(@NotNull(message = "产品id不能为空") @PathVariable(name = "skuId") String skuId,
|
||||
boolean checked) {
|
||||
cartService.checked(skuId, checked);
|
||||
return ResultUtil.success(ResultCode.SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "购物车选中设置")
|
||||
@PostMapping(value = "/sku/checked", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResultMessage<Object> updateAll(boolean checked) {
|
||||
cartService.checkedAll(checked);
|
||||
return ResultUtil.success(ResultCode.SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "批量设置某商家的商品为选中或不选中")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "storeId", value = "卖家id", required = true, dataType = "Long", paramType = "path"),
|
||||
@ApiImplicitParam(name = "checked", value = "是否选中", required = true, dataType = "int", paramType = "query", allowableValues = "0,1")
|
||||
})
|
||||
@ResponseBody
|
||||
@PostMapping(value = "/store/{storeId}", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResultMessage<Object> updateStoreAll(@NotNull(message = "卖家id不能为空") @PathVariable(name = "storeId") String storeId, boolean checked) {
|
||||
cartService.checkedStore(storeId, checked);
|
||||
return ResultUtil.success(ResultCode.SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "清空购物车")
|
||||
@DeleteMapping()
|
||||
public ResultMessage<Object> clean() {
|
||||
cartService.clean();
|
||||
return ResultUtil.success(ResultCode.SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "删除购物车中的一个或多个产品")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "skuIds", value = "产品id", required = true, dataType = "Long", paramType = "path", allowMultiple = true)
|
||||
})
|
||||
@DeleteMapping(value = "/sku/remove")
|
||||
public ResultMessage<Object> delete(String[] skuIds) {
|
||||
cartService.delete(skuIds);
|
||||
return ResultUtil.success(ResultCode.SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "获取结算页面购物车详情")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "way", value = "购物车购买:CART/立即购买:BUY_NOW/拼团购买:PINTUAN / 积分购买:POINT ", required = true, paramType = "query")
|
||||
})
|
||||
@GetMapping("/checked")
|
||||
public ResultMessage<TradeDTO> cartChecked(@NotNull(message = "读取选中列表") String way) {
|
||||
try {
|
||||
// 读取选中的列表
|
||||
return ResultUtil.data(this.cartService.getCheckedTradeDTO(CartTypeEnum.valueOf(way)));
|
||||
} catch (ServiceException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
log.error(ResultCode.CART_ERROR.message(), e);
|
||||
return ResultUtil.error(ResultCode.CART_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "选择收货地址")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "shippingAddressId", value = "收货地址id ", required = true, paramType = "query"),
|
||||
@ApiImplicitParam(name = "way", value = "购物车类型 ", paramType = "query")
|
||||
})
|
||||
@GetMapping("/shippingAddress")
|
||||
public ResultMessage<Object> shippingAddress(@NotNull(message = "收货地址ID不能为空") String shippingAddressId,
|
||||
String way) {
|
||||
try {
|
||||
cartService.shippingAddress(shippingAddressId, way);
|
||||
return ResultUtil.success(ResultCode.SUCCESS);
|
||||
} catch (ServiceException se) {
|
||||
log.error(ResultCode.SHIPPING_NOT_APPLY.message(), se);
|
||||
return ResultUtil.error(ResultCode.SHIPPING_NOT_APPLY);
|
||||
} catch (Exception e) {
|
||||
log.error(ResultCode.CART_ERROR.message(), e);
|
||||
return ResultUtil.error(ResultCode.CART_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "选择配送方式")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "shippingMethod", value = "配送方式:SELF_PICK_UP(自提)," +
|
||||
"LOCAL_TOWN_DELIVERY(同城配送)," +
|
||||
"LOGISTICS(物流) ", required = true, paramType = "query"),
|
||||
@ApiImplicitParam(name = "selleId", value = "店铺id", paramType = "query"),
|
||||
@ApiImplicitParam(name = "way", value = "购物车类型 ", paramType = "query")
|
||||
})
|
||||
@GetMapping("/shippingMethod")
|
||||
public ResultMessage<Object> shippingMethod(@NotNull(message = "配送方式不能为空") String shippingMethod,
|
||||
String selleId,
|
||||
String way) {
|
||||
try {
|
||||
cartService.shippingMethod(selleId, shippingMethod, way);
|
||||
return ResultUtil.success(ResultCode.SUCCESS);
|
||||
} catch (Exception e) {
|
||||
log.error(ResultCode.CART_ERROR.message(), e);
|
||||
return ResultUtil.error(ResultCode.CART_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "选择发票")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "way", value = "购物车购买:CART/立即购买:BUY_NOW/拼团购买:PINTUAN / 积分购买:POINT ", required = true, paramType = "query"),
|
||||
})
|
||||
@GetMapping("/select/receipt")
|
||||
public ResultMessage<Object> selectReceipt(String way, ReceiptVO receiptVO) {
|
||||
this.cartService.shippingReceipt(receiptVO, way);
|
||||
return ResultUtil.success(ResultCode.SUCCESS);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "选择优惠券")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "way", value = "购物车购买:CART/立即购买:BUY_NOW/拼团购买:PINTUAN / 积分购买:POINT ", required = true, paramType = "query"),
|
||||
@ApiImplicitParam(name = "memberCouponId", value = "优惠券id ", required = true, paramType = "query"),
|
||||
@ApiImplicitParam(name = "used", value = "使用true 弃用false ", required = true, paramType = "query")
|
||||
})
|
||||
@GetMapping("/select/coupon")
|
||||
public ResultMessage<Object> selectCoupon(String way, @NotNull(message = "优惠券id不能为空") String memberCouponId, boolean used) {
|
||||
this.cartService.selectCoupon(memberCouponId, way, used);
|
||||
return ResultUtil.success(ResultCode.SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "创建交易")
|
||||
@PostMapping(value = "/create/trade", consumes = "application/json", produces = "application/json")
|
||||
public ResultMessage<Object> crateTrade(@RequestBody TradeParams tradeParams) {
|
||||
try {
|
||||
// 读取选中的列表
|
||||
return ResultUtil.data(this.cartService.createTrade(tradeParams));
|
||||
} catch (Exception e) {
|
||||
log.error(ResultCode.ORDER_ERROR.message(), e);
|
||||
if (e.getMessage().equals(ResultCode.SHIPPING_NOT_APPLY.message())) {
|
||||
return ResultUtil.error(ResultCode.SHIPPING_NOT_APPLY);
|
||||
}
|
||||
return ResultUtil.error(ResultCode.ORDER_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
package cn.lili.controller.trade;
|
||||
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.security.AuthUser;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.utils.ResultUtil;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.order.order.entity.dos.Order;
|
||||
import cn.lili.modules.order.order.entity.dto.OrderSearchParams;
|
||||
import cn.lili.modules.order.order.entity.enums.OrderStatusEnum;
|
||||
import cn.lili.modules.order.order.entity.vo.OrderDetailVO;
|
||||
import cn.lili.modules.order.order.entity.vo.OrderSimpleVO;
|
||||
import cn.lili.modules.order.order.service.OrderService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 买家端,订单接口
|
||||
*
|
||||
* @author Chopper
|
||||
* @date 2020/11/16 10:08 下午
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "买家端,订单接口")
|
||||
@RequestMapping("/buyer/orders")
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class OrderBuyerController {
|
||||
|
||||
/**
|
||||
* 订单
|
||||
*/
|
||||
private final OrderService orderService;
|
||||
|
||||
@ApiOperation(value = "查询会员订单列表")
|
||||
@GetMapping
|
||||
public ResultMessage<IPage<OrderSimpleVO>> queryMineOrder(OrderSearchParams orderSearchParams) {
|
||||
AuthUser currentUser = UserContext.getCurrentUser();
|
||||
orderSearchParams.setMemberId(currentUser.getId());
|
||||
return ResultUtil.data(orderService.queryByParams(orderSearchParams));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "订单明细")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "orderSn", value = "订单编号", required = true, paramType = "path")
|
||||
})
|
||||
@GetMapping(value = "/{orderSn}")
|
||||
public ResultMessage<OrderDetailVO> detail(@NotNull(message = "订单编号不能为空") @PathVariable("orderSn") String orderSn) {
|
||||
return ResultUtil.data(orderService.queryDetail(orderSn));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "确认收货")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "orderSn", value = "订单编号", required = true, paramType = "path")
|
||||
})
|
||||
@PostMapping(value = "/{orderSn}/receiving")
|
||||
public ResultMessage<Object> receiving(@NotNull(message = "订单编号不能为空") @PathVariable("orderSn") String orderSn) {
|
||||
Order order = orderService.getBySn(orderSn);
|
||||
if (order == null) {
|
||||
return ResultUtil.error(ResultCode.ORDER_NOT_EXIST);
|
||||
}
|
||||
//判定是否是待收货状态
|
||||
if (!order.getOrderStatus().equals(OrderStatusEnum.DELIVERED.name())) {
|
||||
return ResultUtil.error(ResultCode.ORDER_DELIVERED_ERROR);
|
||||
}
|
||||
orderService.complete(orderSn);
|
||||
return ResultUtil.success(ResultCode.SUCCESS);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "取消订单")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "orderSn", value = "订单编号", required = true, dataType = "String", paramType = "path"),
|
||||
@ApiImplicitParam(name = "reason", value = "取消原因", required = true, dataType = "String", paramType = "query")
|
||||
})
|
||||
@PostMapping(value = "/{orderSn}/cancel")
|
||||
public ResultMessage<Object> cancel(@ApiIgnore @PathVariable String orderSn, @RequestParam String reason) {
|
||||
orderService.cancel(orderSn, reason);
|
||||
return ResultUtil.success(ResultCode.SUCCESS);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除订单")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "orderSn", value = "订单编号", required = true, dataType = "String", paramType = "path")
|
||||
})
|
||||
@DeleteMapping(value = "/{orderSn}")
|
||||
public ResultMessage<Object> deleteOrder(@PathVariable String orderSn) {
|
||||
orderService.deleteOrder(orderSn);
|
||||
return ResultUtil.success(ResultCode.SUCCESS);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查询物流踪迹")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "orderSn", value = "订单编号", required = true, dataType = "String", paramType = "path")
|
||||
})
|
||||
@PostMapping(value = "/getTraces/{orderSn}")
|
||||
public ResultMessage<Object> getTraces(@NotBlank(message = "订单编号不能为空") @PathVariable String orderSn) {
|
||||
return ResultUtil.data(orderService.getTraces(orderSn));
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "开票")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "orderSn", value = "订单编号", required = true, dataType = "String", paramType = "path")
|
||||
})
|
||||
@PostMapping(value = "/receipt/{orderSn}")
|
||||
public ResultMessage<Object> invoice(@NotBlank(message = "订单编号不能为空") @PathVariable String orderSn) {
|
||||
return ResultUtil.data(orderService.invoice(orderSn));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package cn.lili.controller.trade;
|
||||
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.security.AuthUser;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.utils.ResultUtil;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.order.order.entity.dos.OrderComplaint;
|
||||
import cn.lili.modules.order.order.entity.dto.OrderComplaintDTO;
|
||||
import cn.lili.modules.order.order.entity.enums.CommunicationOwnerEnum;
|
||||
import cn.lili.modules.order.order.entity.vo.OrderComplaintCommunicationVO;
|
||||
import cn.lili.modules.order.order.entity.vo.OrderComplaintSearchParams;
|
||||
import cn.lili.modules.order.order.entity.vo.OrderComplaintVO;
|
||||
import cn.lili.modules.order.order.service.OrderComplaintCommunicationService;
|
||||
import cn.lili.modules.order.order.service.OrderComplaintService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
/**
|
||||
* 买家端,交易投诉接口
|
||||
*
|
||||
* @author paulG
|
||||
* @since 2020/12/7
|
||||
**/
|
||||
@RestController
|
||||
@Api(tags = "买家端,交易投诉接口")
|
||||
@RequestMapping("/buyer/complain")
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class OrderComplaintBuyerController {
|
||||
|
||||
/**
|
||||
* 交易投诉
|
||||
*/
|
||||
private final OrderComplaintService orderComplaintService;
|
||||
|
||||
/**
|
||||
* 交易投诉沟通
|
||||
*/
|
||||
private final OrderComplaintCommunicationService orderComplaintCommunicationService;
|
||||
|
||||
|
||||
@ApiOperation(value = "通过id获取")
|
||||
@ApiImplicitParam(name = "id", value = "投诉单ID", required = true, paramType = "path")
|
||||
@GetMapping(value = "/{id}")
|
||||
public ResultMessage<OrderComplaintVO> get(@PathVariable String id) {
|
||||
return ResultUtil.data(orderComplaintService.getOrderComplainById(id));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "分页获取")
|
||||
@GetMapping
|
||||
public ResultMessage<IPage<OrderComplaint>> get(OrderComplaintSearchParams searchParams, PageVO pageVO) {
|
||||
searchParams.setMemberId(UserContext.getCurrentUser().getId());
|
||||
return ResultUtil.data(orderComplaintService.getOrderComplainByPage(searchParams, pageVO));
|
||||
|
||||
}
|
||||
|
||||
@ApiOperation(value = "添加交易投诉")
|
||||
@PostMapping
|
||||
public ResultMessage<OrderComplaint> add(@Valid OrderComplaintDTO orderComplaintDTO) {
|
||||
return ResultUtil.data(orderComplaintService.addOrderComplain(orderComplaintDTO));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "添加交易投诉对话")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "complainId", value = "投诉单ID", required = true, paramType = "query"),
|
||||
@ApiImplicitParam(name = "content", value = "内容", required = true, paramType = "query")
|
||||
})
|
||||
@PostMapping("/communication")
|
||||
public ResultMessage<OrderComplaintCommunicationVO> addCommunication(@RequestParam String complainId, @RequestParam String content) {
|
||||
AuthUser currentUser = UserContext.getCurrentUser();
|
||||
OrderComplaintCommunicationVO communicationVO = new OrderComplaintCommunicationVO(complainId, content, CommunicationOwnerEnum.BUYER.name(), currentUser.getId(), currentUser.getNickName());
|
||||
if (orderComplaintCommunicationService.addCommunication(communicationVO)) {
|
||||
return ResultUtil.data(communicationVO);
|
||||
|
||||
}
|
||||
return ResultUtil.error(ResultCode.ERROR);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "取消售后")
|
||||
@ApiImplicitParam(name = "id", value = "投诉单ID", required = true, paramType = "path")
|
||||
@PutMapping(value = "/status/{id}")
|
||||
public ResultMessage<Object> cancel(@PathVariable String id) {
|
||||
if (orderComplaintService.cancel(id)) {
|
||||
return ResultUtil.success(ResultCode.SUCCESS);
|
||||
}
|
||||
return ResultUtil.error(ResultCode.ERROR);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package cn.lili.controller.trade;
|
||||
|
||||
import cn.lili.common.utils.ResultUtil;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.order.order.entity.dos.Receipt;
|
||||
import cn.lili.modules.order.order.entity.dto.OrderReceiptDTO;
|
||||
import cn.lili.modules.order.order.entity.dto.ReceiptSearchParams;
|
||||
import cn.lili.modules.order.order.service.ReceiptService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
/**
|
||||
* 买家端,发票接口
|
||||
*
|
||||
* @author paulG
|
||||
* @since 2021/1/12
|
||||
**/
|
||||
@RestController
|
||||
@Api(tags = "买家端,发票接口")
|
||||
@RequestMapping("/buyer/trade/receipt")
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class ReceiptBuyerController {
|
||||
|
||||
private final ReceiptService receiptService;
|
||||
|
||||
@ApiOperation(value = "获取发票详情")
|
||||
@GetMapping("/{id}")
|
||||
public ResultMessage<Receipt> getDetail(@PathVariable String id) {
|
||||
return ResultUtil.data(this.receiptService.getDetail(id));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取发票分页信息")
|
||||
@GetMapping
|
||||
public ResultMessage<IPage<OrderReceiptDTO>> getPage(ReceiptSearchParams searchParams, PageVO pageVO) {
|
||||
return ResultUtil.data(this.receiptService.getReceiptData(searchParams, pageVO));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "保存发票信息")
|
||||
@PostMapping
|
||||
public ResultMessage<Receipt> save(@Valid Receipt receipt) {
|
||||
return ResultUtil.data(receiptService.saveReceipt(receipt));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package cn.lili.controller.trade;
|
||||
|
||||
import cn.lili.common.utils.ResultUtil;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.order.trade.entity.dos.Recharge;
|
||||
import cn.lili.modules.order.trade.service.RechargeService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
|
||||
/**
|
||||
* 买家端,预存款充值记录接口
|
||||
*
|
||||
* @author paulG
|
||||
* @date: 2020/11/16 10:07 下午
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "买家端,预存款充值记录接口")
|
||||
@RequestMapping("/buyer/trade/recharge")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class RechargeTradeBuyerController {
|
||||
|
||||
private final RechargeService rechargeService;
|
||||
|
||||
@PostMapping
|
||||
@ApiOperation(value = "创建余额充值订单")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "price", value = "充值金额", required = true, dataType = "double", paramType = "query")
|
||||
})
|
||||
public ResultMessage<Recharge> create(@Max(value = 10000, message = "充值金额单次最多允许充值10000元") @Min(value = 1, message = "充值金额单次最少充值金额为1元") Double price) {
|
||||
Recharge recharge = this.rechargeService.recharge(price);
|
||||
return ResultUtil.data(recharge);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package cn.lili.controller.trade;
|
||||
|
||||
import cn.lili.common.security.AuthUser;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.utils.PageUtil;
|
||||
import cn.lili.common.utils.ResultUtil;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.order.trade.entity.dos.WalletLog;
|
||||
import cn.lili.modules.order.trade.service.WalletLogService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 买家端,预存款变动日志记录接口
|
||||
*
|
||||
* @author pikachu
|
||||
* @date: 2020/11/16 10:07 下午
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "买家端,预存款变动日志记录接口")
|
||||
@RequestMapping("/buyer/wallet/log")
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class WalletLogBuyerController {
|
||||
|
||||
private final WalletLogService walletLogService;
|
||||
|
||||
@ApiOperation(value = "分页获取预存款变动日志")
|
||||
@GetMapping
|
||||
public ResultMessage<IPage<WalletLog>> getByPage(PageVO page) {
|
||||
//获取当前登录用户
|
||||
AuthUser authUser = UserContext.getCurrentUser();
|
||||
//构建查询 返回数据
|
||||
IPage<WalletLog> depositLogPage = walletLogService.page(PageUtil.initPage(page), new QueryWrapper<WalletLog>().eq("member_id", authUser.getId()));
|
||||
return ResultUtil.data(depositLogPage);
|
||||
}
|
||||
}
|
||||
120
buyer-api/src/main/java/cn/lili/security/BuyerAuthenticationFilter.java
Executable file
120
buyer-api/src/main/java/cn/lili/security/BuyerAuthenticationFilter.java
Executable file
@@ -0,0 +1,120 @@
|
||||
package cn.lili.security;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.lili.common.cache.Cache;
|
||||
import cn.lili.common.cache.CachePrefix;
|
||||
import cn.lili.common.security.AuthUser;
|
||||
import cn.lili.common.security.enums.SecurityEnum;
|
||||
import cn.lili.common.security.enums.UserEnums;
|
||||
import cn.lili.common.token.SecretKeyUtil;
|
||||
import cn.lili.common.utils.ResponseUtil;
|
||||
import com.google.gson.Gson;
|
||||
import io.jsonwebtoken.Claims;
|
||||
import io.jsonwebtoken.ExpiredJwtException;
|
||||
import io.jsonwebtoken.Jwts;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.security.authentication.AuthenticationManager;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.security.web.authentication.www.BasicAuthenticationFilter;
|
||||
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 认证结果过滤器
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v4.1
|
||||
* @date 2020/11/17 3:37 下午
|
||||
* @Description:
|
||||
* @since
|
||||
*/
|
||||
@Slf4j
|
||||
public class BuyerAuthenticationFilter extends BasicAuthenticationFilter {
|
||||
|
||||
|
||||
/**
|
||||
* 缓存
|
||||
*/
|
||||
private final Cache cache;
|
||||
|
||||
/**
|
||||
* 自定义构造器
|
||||
*
|
||||
* @param authenticationManager
|
||||
* @param cache
|
||||
*/
|
||||
public BuyerAuthenticationFilter(AuthenticationManager authenticationManager,
|
||||
Cache cache) {
|
||||
super(authenticationManager);
|
||||
this.cache = cache;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException {
|
||||
|
||||
//从header中获取jwt
|
||||
String jwt = request.getHeader(SecurityEnum.HEADER_TOKEN.getValue());
|
||||
try {
|
||||
// 如果没有token 则return
|
||||
if (StrUtil.isBlank(jwt)) {
|
||||
chain.doFilter(request, response);
|
||||
return;
|
||||
}
|
||||
//获取用户信息,存入context
|
||||
UsernamePasswordAuthenticationToken authentication = getAuthentication(jwt, response);
|
||||
SecurityContextHolder.getContext().setAuthentication(authentication);
|
||||
} catch (Exception e) {
|
||||
log.error("BuyerAuthenticationFilter-> member authentication exception:", e);
|
||||
}
|
||||
chain.doFilter(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析用户
|
||||
*
|
||||
* @param jwt
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
private UsernamePasswordAuthenticationToken getAuthentication(String jwt, HttpServletResponse response) {
|
||||
|
||||
try {
|
||||
Claims claims
|
||||
= Jwts.parser()
|
||||
.setSigningKey(SecretKeyUtil.generalKeyByDecoders())
|
||||
.parseClaimsJws(jwt).getBody();
|
||||
//获取存储在claims中的用户信息
|
||||
String json = claims.get(SecurityEnum.USER_CONTEXT.getValue()).toString();
|
||||
AuthUser authUser = new Gson().fromJson(json, AuthUser.class);
|
||||
|
||||
// 校验redis中是否有权限
|
||||
if (cache.hasKey(CachePrefix.ACCESS_TOKEN.getPrefix(UserEnums.MEMBER) + jwt)) {
|
||||
//构造返回信息
|
||||
List<GrantedAuthority> auths = new ArrayList<>();
|
||||
auths.add(new SimpleGrantedAuthority("ROLE_" + authUser.getRole().name()));
|
||||
UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(authUser.getUsername(), null, auths);
|
||||
authentication.setDetails(authUser);
|
||||
return authentication;
|
||||
}
|
||||
ResponseUtil.output(response, 403, ResponseUtil.resultMap(false, 403, "登录已失效,请重新登录"));
|
||||
return null;
|
||||
} catch (ExpiredJwtException e) {
|
||||
log.debug("user analysis exception:", e);
|
||||
} catch (Exception e) {
|
||||
log.error("user analysis exception:", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
package cn.lili.security;
|
||||
|
||||
import cn.lili.common.cache.Cache;
|
||||
import cn.lili.common.security.CustomAccessDeniedHandler;
|
||||
import cn.lili.common.utils.SpringContextUtil;
|
||||
import cn.lili.config.properties.IgnoredUrlsProperties;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||
import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer;
|
||||
import org.springframework.security.config.http.SessionCreationPolicy;
|
||||
import org.springframework.web.cors.CorsConfigurationSource;
|
||||
|
||||
/**
|
||||
* spring Security 核心配置类 Buyer安全配置中心
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v4.0
|
||||
* @Description:
|
||||
* @since 2020/11/14 16:20
|
||||
*/
|
||||
|
||||
@Slf4j
|
||||
@Configuration
|
||||
@EnableGlobalMethodSecurity(prePostEnabled = true)
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class BuyerSecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
/**
|
||||
* 忽略验权配置
|
||||
*/
|
||||
private final IgnoredUrlsProperties ignoredUrlsProperties;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* spring security -》 权限不足处理
|
||||
*/
|
||||
private final CustomAccessDeniedHandler accessDeniedHandler;
|
||||
|
||||
|
||||
private final Cache<String> cache;
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
|
||||
ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry registry = http
|
||||
.authorizeRequests();
|
||||
// 配置的url 不需要授权
|
||||
for (String url : ignoredUrlsProperties.getUrls()) {
|
||||
registry.antMatchers(url).permitAll();
|
||||
}
|
||||
registry
|
||||
.and()
|
||||
// 禁止网页iframe
|
||||
.headers().frameOptions().disable()
|
||||
.and()
|
||||
.logout()
|
||||
.permitAll()
|
||||
.and()
|
||||
.authorizeRequests()
|
||||
// 任何请求
|
||||
.anyRequest()
|
||||
// 需要身份认证
|
||||
.authenticated()
|
||||
.and()
|
||||
// 允许跨域
|
||||
.cors().configurationSource((CorsConfigurationSource) SpringContextUtil.getBean("corsConfigurationSource")).and()
|
||||
// 关闭跨站请求防护
|
||||
.csrf().disable()
|
||||
// 前后端分离采用JWT 不需要session
|
||||
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
|
||||
.and()
|
||||
// 自定义权限拒绝处理类
|
||||
.exceptionHandling().accessDeniedHandler(accessDeniedHandler)
|
||||
.and()
|
||||
// 添加JWT认证过滤器
|
||||
.addFilter(new BuyerAuthenticationFilter(authenticationManager(), cache));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user