mall:完善 cloud 的 api 调用

This commit is contained in:
YunaiV 2023-10-24 12:24:02 +08:00
parent 110b3476a8
commit b133cfa2a8
38 changed files with 239 additions and 136 deletions

View File

@ -46,6 +46,10 @@
<groupId>cn.iocoder.cloud</groupId> <groupId>cn.iocoder.cloud</groupId>
<artifactId>yudao-spring-boot-starter-biz-operatelog</artifactId> <artifactId>yudao-spring-boot-starter-biz-operatelog</artifactId>
</dependency> </dependency>
<dependency>
<groupId>cn.iocoder.cloud</groupId>
<artifactId>yudao-spring-boot-starter-biz-tenant</artifactId>
</dependency>
<dependency> <dependency>
<groupId>cn.iocoder.cloud</groupId> <groupId>cn.iocoder.cloud</groupId>
<artifactId>yudao-spring-boot-starter-biz-dict</artifactId> <artifactId>yudao-spring-boot-starter-biz-dict</artifactId>

View File

@ -2,8 +2,8 @@ package cn.iocoder.yudao.module.product.api.category;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.product.service.category.ProductCategoryService; import cn.iocoder.yudao.module.product.service.category.ProductCategoryService;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Collection; import java.util.Collection;
@ -15,7 +15,7 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
* *
* @author owen * @author owen
*/ */
@Service @RestController // 提供 RESTful API 接口 Feign 调用
@Validated @Validated
public class ProductCategoryApiImpl implements ProductCategoryApi { public class ProductCategoryApiImpl implements ProductCategoryApi {

View File

@ -3,8 +3,8 @@ package cn.iocoder.yudao.module.product.api.comment;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.product.api.comment.dto.ProductCommentCreateReqDTO; import cn.iocoder.yudao.module.product.api.comment.dto.ProductCommentCreateReqDTO;
import cn.iocoder.yudao.module.product.service.comment.ProductCommentService; import cn.iocoder.yudao.module.product.service.comment.ProductCommentService;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -15,7 +15,7 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
* *
* @author HUIHUI * @author HUIHUI
*/ */
@Service @RestController // 提供 RESTful API 接口 Feign 调用
@Validated @Validated
public class ProductCommentApiImpl implements ProductCommentApi { public class ProductCommentApiImpl implements ProductCommentApi {

View File

@ -6,8 +6,8 @@ import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO;
import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert; import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert;
import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO;
import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; import cn.iocoder.yudao.module.product.service.sku.ProductSkuService;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Collection; import java.util.Collection;
@ -21,7 +21,7 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
* @author LeeYan9 * @author LeeYan9
* @since 2022-09-06 * @since 2022-09-06
*/ */
@Service @RestController // 提供 RESTful API 接口 Feign 调用
@Validated @Validated
public class ProductSkuApiImpl implements ProductSkuApi { public class ProductSkuApiImpl implements ProductSkuApi {

View File

@ -4,8 +4,8 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
import cn.iocoder.yudao.module.product.convert.spu.ProductSpuConvert; import cn.iocoder.yudao.module.product.convert.spu.ProductSpuConvert;
import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; import cn.iocoder.yudao.module.product.service.spu.ProductSpuService;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Collection; import java.util.Collection;
@ -19,7 +19,7 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
* @author LeeYan9 * @author LeeYan9
* @since 2022-09-06 * @since 2022-09-06
*/ */
@Service @RestController // 提供 RESTful API 接口 Feign 调用
@Validated @Validated
public class ProductSpuApiImpl implements ProductSpuApi { public class ProductSpuApiImpl implements ProductSpuApi {

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.promotion.api.bargain; package cn.iocoder.yudao.module.promotion.api.bargain;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.promotion.enums.ApiConstants; import cn.iocoder.yudao.module.promotion.enums.ApiConstants;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
@ -9,7 +10,6 @@ import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
// TODO 芋艿commonresult
@FeignClient(name = ApiConstants.NAME) // TODO 芋艿fallbackFactory = @FeignClient(name = ApiConstants.NAME) // TODO 芋艿fallbackFactory =
@Tag(name = "RPC 服务 - 砍价活动") @Tag(name = "RPC 服务 - 砍价活动")
public interface BargainActivityApi { public interface BargainActivityApi {
@ -22,7 +22,7 @@ public interface BargainActivityApi {
@Parameter(name = "id", description = "砍价活动编号", required = true, example = "1024"), @Parameter(name = "id", description = "砍价活动编号", required = true, example = "1024"),
@Parameter(name = "count", description = "购买数量", required = true, example = "1"), @Parameter(name = "count", description = "购买数量", required = true, example = "1"),
}) })
void updateBargainActivityStock(@RequestParam("id") Long id, CommonResult<Boolean> updateBargainActivityStock(@RequestParam("id") Long id,
@RequestParam("count") Integer count); @RequestParam("count") Integer count);
} }

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.promotion.api.bargain; package cn.iocoder.yudao.module.promotion.api.bargain;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.promotion.api.bargain.dto.BargainValidateJoinRespDTO; import cn.iocoder.yudao.module.promotion.api.bargain.dto.BargainValidateJoinRespDTO;
import cn.iocoder.yudao.module.promotion.enums.ApiConstants; import cn.iocoder.yudao.module.promotion.enums.ApiConstants;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
@ -24,9 +25,9 @@ public interface BargainRecordApi {
@Parameter(name = "bargainRecordId", description = "砍价记录编号", required = true, example = "2048"), @Parameter(name = "bargainRecordId", description = "砍价记录编号", required = true, example = "2048"),
@Parameter(name = "skuId", description = "SKU 编号", required = true, example = "4096"), @Parameter(name = "skuId", description = "SKU 编号", required = true, example = "4096"),
}) })
BargainValidateJoinRespDTO validateJoinBargain(@RequestParam("userId") Long userId, CommonResult<BargainValidateJoinRespDTO> validateJoinBargain(@RequestParam("userId") Long userId,
@RequestParam("bargainRecordId") Long bargainRecordId, @RequestParam("bargainRecordId") Long bargainRecordId,
@RequestParam("skuId") Long skuId); @RequestParam("skuId") Long skuId);
@PutMapping(PREFIX + "/update-order-id") @PutMapping(PREFIX + "/update-order-id")
@Operation(summary = "更新砍价记录的订单编号") // 在砍价成功后用户发起订单后会记录该订单编号 @Operation(summary = "更新砍价记录的订单编号") // 在砍价成功后用户发起订单后会记录该订单编号
@ -34,7 +35,7 @@ public interface BargainRecordApi {
@Parameter(name = "id", description = "砍价记录编号", required = true, example = "1024"), @Parameter(name = "id", description = "砍价记录编号", required = true, example = "1024"),
@Parameter(name = "orderId", description = "订单编号", required = true, example = "2048"), @Parameter(name = "orderId", description = "订单编号", required = true, example = "2048"),
}) })
void updateBargainRecordOrderId(@RequestParam("id") Long id, CommonResult<Boolean> updateBargainRecordOrderId(@RequestParam("id") Long id,
@RequestParam("oderId") Long orderId); @RequestParam("oderId") Long orderId);
} }

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.promotion.api.combination; package cn.iocoder.yudao.module.promotion.api.combination;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO; import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO;
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateRespDTO; import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateRespDTO;
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationValidateJoinRespDTO; import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationValidateJoinRespDTO;
@ -31,38 +32,27 @@ public interface CombinationRecordApi {
@Parameter(name = "skuId", description = "SKU 编号", required = true, example = "8192"), @Parameter(name = "skuId", description = "SKU 编号", required = true, example = "8192"),
@Parameter(name = "count", description = "数量", required = true, example = "1"), @Parameter(name = "count", description = "数量", required = true, example = "1"),
}) })
void validateCombinationRecord(@RequestParam("userId") Long userId, CommonResult<Boolean> validateCombinationRecord(@RequestParam("userId") Long userId,
@RequestParam("activityId") Long activityId, @RequestParam("activityId") Long activityId,
@RequestParam("headId") Long headId, @RequestParam("headId") Long headId,
@RequestParam("skuId") Long skuId, @RequestParam("skuId") Long skuId,
@RequestParam("count") Integer count); @RequestParam("count") Integer count);
@PostMapping("/create") @PostMapping(PREFIX + "/create")
@Operation(summary = "创建开团记录") @Operation(summary = "创建开团记录")
CombinationRecordCreateRespDTO createCombinationRecord(@RequestBody @Valid CombinationRecordCreateReqDTO reqDTO); CommonResult<CombinationRecordCreateRespDTO> createCombinationRecord(
@RequestBody @Valid CombinationRecordCreateReqDTO reqDTO);
@GetMapping("/is-success") @GetMapping(PREFIX + "/is-success")
@Operation(summary = "查询拼团记录是否成功") @Operation(summary = "查询拼团记录是否成功")
@Parameters({ @Parameters({
@Parameter(name = "userId", description = "用户编号", required = true, example = "1024"), @Parameter(name = "userId", description = "用户编号", required = true, example = "1024"),
@Parameter(name = "orderId", description = "订单编号", required = true, example = "2048"), @Parameter(name = "orderId", description = "订单编号", required = true, example = "2048"),
}) })
boolean isCombinationRecordSuccess(@RequestParam("userId") Long userId, CommonResult<Boolean> isCombinationRecordSuccess(@RequestParam("userId") Long userId,
@RequestParam("orderId") Long orderId); @RequestParam("orderId") Long orderId);
/** @GetMapping(PREFIX + "/validate-join")
* 下单前校验是否满足拼团活动条件
*
* 如果校验失败则抛出业务异常
*
* @param userId 用户编号
* @param activityId 活动编号
* @param headId 团长编号
* @param skuId sku 编号
* @param count 数量
* @return 拼团信息
*/
@GetMapping("/validate-join")
@Operation(summary = "【下单前】校验是否满足拼团活动条件") // 如果校验失败则抛出业务异常 @Operation(summary = "【下单前】校验是否满足拼团活动条件") // 如果校验失败则抛出业务异常
@Parameters({ @Parameters({
@Parameter(name = "userId", description = "用户编号", required = true, example = "1024"), @Parameter(name = "userId", description = "用户编号", required = true, example = "1024"),
@ -71,10 +61,10 @@ public interface CombinationRecordApi {
@Parameter(name = "skuId", description = "SKU 编号", required = true, example = "8192"), @Parameter(name = "skuId", description = "SKU 编号", required = true, example = "8192"),
@Parameter(name = "count", description = "数量", required = true, example = "1"), @Parameter(name = "count", description = "数量", required = true, example = "1"),
}) })
CombinationValidateJoinRespDTO validateJoinCombination(@RequestParam("userId") Long userId, CommonResult<CombinationValidateJoinRespDTO> validateJoinCombination(@RequestParam("userId") Long userId,
@RequestParam("activityId") Long activityId, @RequestParam("activityId") Long activityId,
@RequestParam("headId") Long headId, @RequestParam("headId") Long headId,
@RequestParam("skuId") Long skuId, @RequestParam("skuId") Long skuId,
@RequestParam("count") Integer count); @RequestParam("count") Integer count);
} }

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.promotion.api.coupon; package cn.iocoder.yudao.module.promotion.api.coupon;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponRespDTO; import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponRespDTO;
import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponUseReqDTO; import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponUseReqDTO;
import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponValidReqDTO; import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponValidReqDTO;
@ -23,14 +24,14 @@ public interface CouponApi {
@PutMapping(PREFIX + "/use") @PutMapping(PREFIX + "/use")
@Operation(summary = "使用优惠劵") @Operation(summary = "使用优惠劵")
void useCoupon(@RequestBody @Valid CouponUseReqDTO useReqDTO); CommonResult<Boolean> useCoupon(@RequestBody @Valid CouponUseReqDTO useReqDTO);
@PutMapping(PREFIX + "/return-used") @PutMapping(PREFIX + "/return-used")
@Parameter(name = "id", description = "优惠券编号", required = true, example = "1") @Parameter(name = "id", description = "优惠券编号", required = true, example = "1")
void returnUsedCoupon(@RequestParam("id") Long id); CommonResult<Boolean> returnUsedCoupon(@RequestParam("id") Long id);
@GetMapping(PREFIX + "/get") @GetMapping(PREFIX + "/validate")
@Operation(summary = "校验优惠劵") @Operation(summary = "校验优惠劵")
CouponRespDTO validateCoupon(@Valid CouponValidReqDTO validReqDTO); CommonResult<CouponRespDTO> validateCoupon(@Valid CouponValidReqDTO validReqDTO);
} }

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.promotion.api.discount; package cn.iocoder.yudao.module.promotion.api.discount;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.promotion.api.discount.dto.DiscountProductRespDTO; import cn.iocoder.yudao.module.promotion.api.discount.dto.DiscountProductRespDTO;
import cn.iocoder.yudao.module.promotion.enums.ApiConstants; import cn.iocoder.yudao.module.promotion.enums.ApiConstants;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
@ -21,6 +22,6 @@ public interface DiscountActivityApi {
@GetMapping(PREFIX + "/list-by-sku-id") @GetMapping(PREFIX + "/list-by-sku-id")
@Operation(summary = "获得商品匹配的的限时折扣信息") @Operation(summary = "获得商品匹配的的限时折扣信息")
@Parameter(name = "skuIds", description = "商品 SKU 编号数组", required = true, example = "[1, 2]") @Parameter(name = "skuIds", description = "商品 SKU 编号数组", required = true, example = "[1, 2]")
List<DiscountProductRespDTO> getMatchDiscountProductList(@RequestParam("skuIds") Collection<Long> skuIds); CommonResult<List<DiscountProductRespDTO>> getMatchDiscountProductList(@RequestParam("skuIds") Collection<Long> skuIds);
} }

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.promotion.api.reward; package cn.iocoder.yudao.module.promotion.api.reward;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.promotion.api.reward.dto.RewardActivityMatchRespDTO; import cn.iocoder.yudao.module.promotion.api.reward.dto.RewardActivityMatchRespDTO;
import cn.iocoder.yudao.module.promotion.enums.ApiConstants; import cn.iocoder.yudao.module.promotion.enums.ApiConstants;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
@ -21,6 +22,6 @@ public interface RewardActivityApi {
@GetMapping(PREFIX + "/list-by-spu-id") @GetMapping(PREFIX + "/list-by-spu-id")
@Operation(summary = "获得商品匹配的的满减送活动信息") @Operation(summary = "获得商品匹配的的满减送活动信息")
@Parameter(name = "spuIds", description = "商品 SPU 编号数组", required = true, example = "[1, 2]") @Parameter(name = "spuIds", description = "商品 SPU 编号数组", required = true, example = "[1, 2]")
List<RewardActivityMatchRespDTO> getMatchRewardActivityList(@RequestParam("spuIds") Collection<Long> spuIds); CommonResult<List<RewardActivityMatchRespDTO>> getMatchRewardActivityList(@RequestParam("spuIds") Collection<Long> spuIds);
} }

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.promotion.api.seckill; package cn.iocoder.yudao.module.promotion.api.seckill;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.promotion.api.seckill.dto.SeckillValidateJoinRespDTO; import cn.iocoder.yudao.module.promotion.api.seckill.dto.SeckillValidateJoinRespDTO;
import cn.iocoder.yudao.module.promotion.enums.ApiConstants; import cn.iocoder.yudao.module.promotion.enums.ApiConstants;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
@ -24,9 +25,9 @@ public interface SeckillActivityApi {
@Parameter(name = "skuId", description = "SKU 编号", required = true, example = "2"), @Parameter(name = "skuId", description = "SKU 编号", required = true, example = "2"),
@Parameter(name = "count", description = "数量", required = true, example = "3"), @Parameter(name = "count", description = "数量", required = true, example = "3"),
}) })
void updateSeckillStockDecr(@RequestParam("id") Long id, CommonResult<Boolean> updateSeckillStockDecr(@RequestParam("id") Long id,
@RequestParam("skuId") Long skuId, @RequestParam("skuId") Long skuId,
@RequestParam("count")Integer count); @RequestParam("count")Integer count);
@PutMapping(PREFIX + "/update-stock-incr") @PutMapping(PREFIX + "/update-stock-incr")
@Operation(summary = "更新秒杀库存(增加)") @Operation(summary = "更新秒杀库存(增加)")
@ -35,9 +36,9 @@ public interface SeckillActivityApi {
@Parameter(name = "skuId", description = "SKU 编号", required = true, example = "2"), @Parameter(name = "skuId", description = "SKU 编号", required = true, example = "2"),
@Parameter(name = "count", description = "数量", required = true, example = "3"), @Parameter(name = "count", description = "数量", required = true, example = "3"),
}) })
void updateSeckillStockIncr(@RequestParam("id") Long id, CommonResult<Boolean> updateSeckillStockIncr(@RequestParam("id") Long id,
@RequestParam("skuId") Long skuId, @RequestParam("skuId") Long skuId,
@RequestParam("count")Integer count); @RequestParam("count")Integer count);
@GetMapping("/validate-join") @GetMapping("/validate-join")
@Operation(summary = "【下单前】校验是否参与秒杀活动") // 如果校验失败则抛出业务异常 @Operation(summary = "【下单前】校验是否参与秒杀活动") // 如果校验失败则抛出业务异常
@ -46,8 +47,8 @@ public interface SeckillActivityApi {
@Parameter(name = "skuId", description = "SKU 编号", required = true, example = "2"), @Parameter(name = "skuId", description = "SKU 编号", required = true, example = "2"),
@Parameter(name = "count", description = "数量", required = true, example = "3"), @Parameter(name = "count", description = "数量", required = true, example = "3"),
}) })
SeckillValidateJoinRespDTO validateJoinSeckill(@RequestParam("activityId") Long activityId, CommonResult<SeckillValidateJoinRespDTO> validateJoinSeckill(@RequestParam("activityId") Long activityId,
@RequestParam("skuId") Long skuId, @RequestParam("skuId") Long skuId,
@RequestParam("count")Integer count); @RequestParam("count")Integer count);
} }

View File

@ -1,24 +1,30 @@
package cn.iocoder.yudao.module.promotion.api.bargain; package cn.iocoder.yudao.module.promotion.api.bargain;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.promotion.service.bargain.BargainActivityService; import cn.iocoder.yudao.module.promotion.service.bargain.BargainActivityService;
import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
/** /**
* 砍价活动 Api 接口实现类 * 砍价活动 Api 接口实现类
* *
* @author HUIHUI * @author HUIHUI
*/ */
@Service @RestController // 提供 RESTful API 接口 Feign 调用
@Validated
public class BargainActivityApiImpl implements BargainActivityApi { public class BargainActivityApiImpl implements BargainActivityApi {
@Resource @Resource
private BargainActivityService bargainActivityService; private BargainActivityService bargainActivityService;
@Override @Override
public void updateBargainActivityStock(Long id, Integer count) { public CommonResult<Boolean> updateBargainActivityStock(Long id, Integer count) {
bargainActivityService.updateBargainActivityStock(id, count); bargainActivityService.updateBargainActivityStock(id, count);
return success(true);
} }
} }

View File

@ -1,30 +1,36 @@
package cn.iocoder.yudao.module.promotion.api.bargain; package cn.iocoder.yudao.module.promotion.api.bargain;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.promotion.api.bargain.dto.BargainValidateJoinRespDTO; import cn.iocoder.yudao.module.promotion.api.bargain.dto.BargainValidateJoinRespDTO;
import cn.iocoder.yudao.module.promotion.service.bargain.BargainRecordService; import cn.iocoder.yudao.module.promotion.service.bargain.BargainRecordService;
import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
/** /**
* 砍价活动 API 实现类 * 砍价活动 API 实现类
* *
* @author HUIHUI * @author HUIHUI
*/ */
@Service @RestController // 提供 RESTful API 接口 Feign 调用
@Validated
public class BargainRecordApiImpl implements BargainRecordApi { public class BargainRecordApiImpl implements BargainRecordApi {
@Resource @Resource
private BargainRecordService bargainRecordService; private BargainRecordService bargainRecordService;
@Override @Override
public BargainValidateJoinRespDTO validateJoinBargain(Long userId, Long bargainRecordId, Long skuId) { public CommonResult<BargainValidateJoinRespDTO> validateJoinBargain(Long userId, Long bargainRecordId, Long skuId) {
return bargainRecordService.validateJoinBargain(userId, bargainRecordId, skuId); return success(bargainRecordService.validateJoinBargain(userId, bargainRecordId, skuId));
} }
@Override @Override
public void updateBargainRecordOrderId(Long id, Long orderId) { public CommonResult<Boolean> updateBargainRecordOrderId(Long id, Long orderId) {
bargainRecordService.updateBargainRecordOrderId(id, orderId); bargainRecordService.updateBargainRecordOrderId(id, orderId);
return success(true);
} }
} }

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.promotion.api.combination; package cn.iocoder.yudao.module.promotion.api.combination;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO; import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO;
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateRespDTO; import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateRespDTO;
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationValidateJoinRespDTO; import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationValidateJoinRespDTO;
@ -7,11 +8,13 @@ import cn.iocoder.yudao.module.promotion.convert.combination.CombinationActivity
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO; import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO;
import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum; import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum;
import cn.iocoder.yudao.module.promotion.service.combination.CombinationRecordService; import cn.iocoder.yudao.module.promotion.service.combination.CombinationRecordService;
import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.COMBINATION_RECORD_NOT_EXISTS; import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.COMBINATION_RECORD_NOT_EXISTS;
/** /**
@ -19,34 +22,37 @@ import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.COMBINA
* *
* @author HUIHUI * @author HUIHUI
*/ */
@Service @RestController // 提供 RESTful API 接口 Feign 调用
@Validated
public class CombinationRecordApiImpl implements CombinationRecordApi { public class CombinationRecordApiImpl implements CombinationRecordApi {
@Resource @Resource
private CombinationRecordService recordService; private CombinationRecordService recordService;
@Override @Override
public void validateCombinationRecord(Long userId, Long activityId, Long headId, Long skuId, Integer count) { public CommonResult<Boolean> validateCombinationRecord(Long userId, Long activityId, Long headId, Long skuId, Integer count) {
recordService.validateCombinationRecord(userId, activityId, headId, skuId, count); recordService.validateCombinationRecord(userId, activityId, headId, skuId, count);
return success(true);
} }
@Override @Override
public CombinationRecordCreateRespDTO createCombinationRecord(CombinationRecordCreateReqDTO reqDTO) { public CommonResult<CombinationRecordCreateRespDTO> createCombinationRecord(CombinationRecordCreateReqDTO reqDTO) {
return CombinationActivityConvert.INSTANCE.convert4(recordService.createCombinationRecord(reqDTO)); return success(CombinationActivityConvert.INSTANCE.convert4(recordService.createCombinationRecord(reqDTO)));
} }
@Override @Override
public boolean isCombinationRecordSuccess(Long userId, Long orderId) { public CommonResult<Boolean> isCombinationRecordSuccess(Long userId, Long orderId) {
CombinationRecordDO record = recordService.getCombinationRecord(userId, orderId); CombinationRecordDO record = recordService.getCombinationRecord(userId, orderId);
if (record == null) { if (record == null) {
throw exception(COMBINATION_RECORD_NOT_EXISTS); throw exception(COMBINATION_RECORD_NOT_EXISTS);
} }
return CombinationRecordStatusEnum.isSuccess(record.getStatus()); return success(CombinationRecordStatusEnum.isSuccess(record.getStatus()));
} }
@Override @Override
public CombinationValidateJoinRespDTO validateJoinCombination(Long userId, Long activityId, Long headId, Long skuId, Integer count) { public CommonResult<CombinationValidateJoinRespDTO> validateJoinCombination(
return recordService.validateJoinCombination(userId, activityId, headId, skuId, count); Long userId, Long activityId, Long headId, Long skuId, Integer count) {
return success(recordService.validateJoinCombination(userId, activityId, headId, skuId, count));
} }
} }

View File

@ -1,42 +1,48 @@
package cn.iocoder.yudao.module.promotion.api.coupon; package cn.iocoder.yudao.module.promotion.api.coupon;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponRespDTO; import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponRespDTO;
import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponUseReqDTO; import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponUseReqDTO;
import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponValidReqDTO; import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponValidReqDTO;
import cn.iocoder.yudao.module.promotion.convert.coupon.CouponConvert; import cn.iocoder.yudao.module.promotion.convert.coupon.CouponConvert;
import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO; import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO;
import cn.iocoder.yudao.module.promotion.service.coupon.CouponService; import cn.iocoder.yudao.module.promotion.service.coupon.CouponService;
import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
/** /**
* 优惠劵 API 实现类 * 优惠劵 API 实现类
* *
* @author 芋道源码 * @author 芋道源码
*/ */
@Service @RestController // 提供 RESTful API 接口 Feign 调用
@Validated
public class CouponApiImpl implements CouponApi { public class CouponApiImpl implements CouponApi {
@Resource @Resource
private CouponService couponService; private CouponService couponService;
@Override @Override
public void useCoupon(CouponUseReqDTO useReqDTO) { public CommonResult<Boolean> useCoupon(CouponUseReqDTO useReqDTO) {
couponService.useCoupon(useReqDTO.getId(), useReqDTO.getUserId(), couponService.useCoupon(useReqDTO.getId(), useReqDTO.getUserId(), useReqDTO.getOrderId());
useReqDTO.getOrderId()); return success(true);
} }
@Override @Override
public void returnUsedCoupon(Long id) { public CommonResult<Boolean> returnUsedCoupon(Long id) {
couponService.returnUsedCoupon(id); couponService.returnUsedCoupon(id);
return success(true);
} }
@Override @Override
public CouponRespDTO validateCoupon(CouponValidReqDTO validReqDTO) { public CommonResult<CouponRespDTO> validateCoupon(CouponValidReqDTO validReqDTO) {
CouponDO coupon = couponService.validCoupon(validReqDTO.getId(), validReqDTO.getUserId()); CouponDO coupon = couponService.validCoupon(validReqDTO.getId(), validReqDTO.getUserId());
return CouponConvert.INSTANCE.convert(coupon); return success(CouponConvert.INSTANCE.convert(coupon));
} }
} }

View File

@ -1,28 +1,33 @@
package cn.iocoder.yudao.module.promotion.api.discount; package cn.iocoder.yudao.module.promotion.api.discount;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.promotion.api.discount.dto.DiscountProductRespDTO; import cn.iocoder.yudao.module.promotion.api.discount.dto.DiscountProductRespDTO;
import cn.iocoder.yudao.module.promotion.convert.discount.DiscountActivityConvert; import cn.iocoder.yudao.module.promotion.convert.discount.DiscountActivityConvert;
import cn.iocoder.yudao.module.promotion.service.discount.DiscountActivityService; import cn.iocoder.yudao.module.promotion.service.discount.DiscountActivityService;
import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
/** /**
* 限时折扣 API 实现类 * 限时折扣 API 实现类
* *
* @author 芋道源码 * @author 芋道源码
*/ */
@Service @RestController // 提供 RESTful API 接口 Feign 调用
@Validated
public class DiscountActivityApiImpl implements DiscountActivityApi { public class DiscountActivityApiImpl implements DiscountActivityApi {
@Resource @Resource
private DiscountActivityService discountActivityService; private DiscountActivityService discountActivityService;
@Override @Override
public List<DiscountProductRespDTO> getMatchDiscountProductList(Collection<Long> skuIds) { public CommonResult<List<DiscountProductRespDTO>> getMatchDiscountProductList(Collection<Long> skuIds) {
return DiscountActivityConvert.INSTANCE.convertList02(discountActivityService.getMatchDiscountProductList(skuIds)); return success(DiscountActivityConvert.INSTANCE.convertList02(discountActivityService.getMatchDiscountProductList(skuIds)));
} }
} }

View File

@ -1,27 +1,32 @@
package cn.iocoder.yudao.module.promotion.api.reward; package cn.iocoder.yudao.module.promotion.api.reward;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.promotion.api.reward.dto.RewardActivityMatchRespDTO; import cn.iocoder.yudao.module.promotion.api.reward.dto.RewardActivityMatchRespDTO;
import cn.iocoder.yudao.module.promotion.service.reward.RewardActivityService; import cn.iocoder.yudao.module.promotion.service.reward.RewardActivityService;
import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
/** /**
* 满减送活动 API 实现类 * 满减送活动 API 实现类
* *
* @author 芋道源码 * @author 芋道源码
*/ */
@Service @RestController // 提供 RESTful API 接口 Feign 调用
@Validated
public class RewardActivityApiImpl implements RewardActivityApi { public class RewardActivityApiImpl implements RewardActivityApi {
@Resource @Resource
private RewardActivityService rewardActivityService; private RewardActivityService rewardActivityService;
@Override @Override
public List<RewardActivityMatchRespDTO> getMatchRewardActivityList(Collection<Long> spuIds) { public CommonResult<List<RewardActivityMatchRespDTO>> getMatchRewardActivityList(Collection<Long> spuIds) {
return rewardActivityService.getMatchRewardActivityList(spuIds); return success(rewardActivityService.getMatchRewardActivityList(spuIds));
} }
} }

View File

@ -1,35 +1,42 @@
package cn.iocoder.yudao.module.promotion.api.seckill; package cn.iocoder.yudao.module.promotion.api.seckill;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.promotion.api.seckill.dto.SeckillValidateJoinRespDTO; import cn.iocoder.yudao.module.promotion.api.seckill.dto.SeckillValidateJoinRespDTO;
import cn.iocoder.yudao.module.promotion.service.seckill.SeckillActivityService; import cn.iocoder.yudao.module.promotion.service.seckill.SeckillActivityService;
import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
/** /**
* 秒杀活动接口 Api 接口实现类 * 秒杀活动接口 Api 接口实现类
* *
* @author HUIHUI * @author HUIHUI
*/ */
@Service @RestController // 提供 RESTful API 接口 Feign 调用
@Validated
public class SeckillActivityApiImpl implements SeckillActivityApi { public class SeckillActivityApiImpl implements SeckillActivityApi {
@Resource @Resource
private SeckillActivityService activityService; private SeckillActivityService activityService;
@Override @Override
public void updateSeckillStockDecr(Long id, Long skuId, Integer count) { public CommonResult<Boolean> updateSeckillStockDecr(Long id, Long skuId, Integer count) {
activityService.updateSeckillStockDecr(id, skuId, count); activityService.updateSeckillStockDecr(id, skuId, count);
return success(true);
} }
@Override @Override
public void updateSeckillStockIncr(Long id, Long skuId, Integer count) { public CommonResult<Boolean> updateSeckillStockIncr(Long id, Long skuId, Integer count) {
activityService.updateSeckillStockIncr(id, skuId, count); activityService.updateSeckillStockIncr(id, skuId, count);
return success(true);
} }
@Override @Override
public SeckillValidateJoinRespDTO validateJoinSeckill(Long activityId, Long skuId, Integer count) { public CommonResult<SeckillValidateJoinRespDTO> validateJoinSeckill(Long activityId, Long skuId, Integer count) {
return activityService.validateJoinSeckill(activityId, skuId, count); return success(activityService.validateJoinSeckill(activityId, skuId, count));
} }
} }

View File

@ -101,7 +101,7 @@ public class AppBargainRecordController {
Integer helpAction = getHelpAction(userId, record, activityId); Integer helpAction = getHelpAction(userId, record, activityId);
// 3. 如果是自己的订单则查询订单信息 // 3. 如果是自己的订单则查询订单信息
TradeOrderRespDTO order = record != null && record.getOrderId() != null && record.getUserId().equals(getLoginUserId()) TradeOrderRespDTO order = record != null && record.getOrderId() != null && record.getUserId().equals(getLoginUserId())
? tradeOrderApi.getOrder(record.getOrderId()) : null; ? tradeOrderApi.getOrder(record.getOrderId()).getCheckedData() : null;
// TODO 继续查询别的字段 // TODO 继续查询别的字段
// 拼接返回 // 拼接返回
@ -147,7 +147,7 @@ public class AppBargainRecordController {
List<ProductSpuRespDTO> spuList = productSpuApi.getSpuList( List<ProductSpuRespDTO> spuList = productSpuApi.getSpuList(
convertSet(pageResult.getList(), BargainRecordDO::getSpuId)).getCheckedData(); convertSet(pageResult.getList(), BargainRecordDO::getSpuId)).getCheckedData();
List<TradeOrderRespDTO> orderList = tradeOrderApi.getOrderList( List<TradeOrderRespDTO> orderList = tradeOrderApi.getOrderList(
convertSet(pageResult.getList(), BargainRecordDO::getOrderId)); convertSet(pageResult.getList(), BargainRecordDO::getOrderId)).getCheckedData();
return success(BargainRecordConvert.INSTANCE.convertPage02(pageResult, activityList, spuList, orderList)); return success(BargainRecordConvert.INSTANCE.convertPage02(pageResult, activityList, spuList, orderList));
} }

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.trade.api.order; package cn.iocoder.yudao.module.trade.api.order;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderRespDTO; import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderRespDTO;
import cn.iocoder.yudao.module.trade.enums.ApiConstants; import cn.iocoder.yudao.module.trade.enums.ApiConstants;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
@ -23,12 +24,12 @@ public interface TradeOrderApi {
@GetMapping(PREFIX + "/list") @GetMapping(PREFIX + "/list")
@Operation(summary = "获得订单列表") @Operation(summary = "获得订单列表")
@Parameter(name = "ids", description = "订单编号数组", required = true) @Parameter(name = "ids", description = "订单编号数组", required = true)
List<TradeOrderRespDTO> getOrderList(@RequestParam("ids") Collection<Long> ids); CommonResult<List<TradeOrderRespDTO>> getOrderList(@RequestParam("ids") Collection<Long> ids);
@GetMapping(PREFIX + "/get") @GetMapping(PREFIX + "/get")
@Operation(summary = "获得订单") @Operation(summary = "获得订单")
@Parameter(name = "id", description = "订单编号", required = true) @Parameter(name = "id", description = "订单编号", required = true)
TradeOrderRespDTO getOrder(@RequestParam("id") Long id); CommonResult<TradeOrderRespDTO> getOrder(@RequestParam("id") Long id);
// TODO 芋艿需要优化下 // TODO 芋艿需要优化下
@PutMapping(PREFIX + "/cancel-paid") @PutMapping(PREFIX + "/cancel-paid")
@ -36,7 +37,7 @@ public interface TradeOrderApi {
@Parameter(name = "userId", description = "用户编号", required = true, example = "1024"), @Parameter(name = "userId", description = "用户编号", required = true, example = "1024"),
@Parameter(name = "orderId", description = "订单编号", required = true, example = "2048"), @Parameter(name = "orderId", description = "订单编号", required = true, example = "2048"),
}) })
void cancelPaidOrder(@RequestParam("userId") Long userId, CommonResult<Boolean> cancelPaidOrder(@RequestParam("userId") Long userId,
@RequestParam("orderId") Long orderId); @RequestParam("orderId") Long orderId);
} }

View File

@ -1,22 +1,25 @@
package cn.iocoder.yudao.module.trade.api.order; package cn.iocoder.yudao.module.trade.api.order;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderRespDTO; import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderRespDTO;
import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert; import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert;
import cn.iocoder.yudao.module.trade.service.order.TradeOrderQueryService; import cn.iocoder.yudao.module.trade.service.order.TradeOrderQueryService;
import cn.iocoder.yudao.module.trade.service.order.TradeOrderUpdateService; import cn.iocoder.yudao.module.trade.service.order.TradeOrderUpdateService;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
/** /**
* 订单 API 接口实现类 * 订单 API 接口实现类
* *
* @author HUIHUI * @author HUIHUI
*/ */
@Service @RestController // 提供 RESTful API 接口 Feign 调用
@Validated @Validated
public class TradeOrderApiImpl implements TradeOrderApi { public class TradeOrderApiImpl implements TradeOrderApi {
@ -26,18 +29,19 @@ public class TradeOrderApiImpl implements TradeOrderApi {
private TradeOrderQueryService tradeOrderQueryService; private TradeOrderQueryService tradeOrderQueryService;
@Override @Override
public List<TradeOrderRespDTO> getOrderList(Collection<Long> ids) { public CommonResult<List<TradeOrderRespDTO>> getOrderList(Collection<Long> ids) {
return TradeOrderConvert.INSTANCE.convertList04(tradeOrderQueryService.getOrderList(ids)); return success(TradeOrderConvert.INSTANCE.convertList04(tradeOrderQueryService.getOrderList(ids)));
} }
@Override @Override
public TradeOrderRespDTO getOrder(Long id) { public CommonResult<TradeOrderRespDTO> getOrder(Long id) {
return TradeOrderConvert.INSTANCE.convert(tradeOrderQueryService.getOrder(id)); return success(TradeOrderConvert.INSTANCE.convert(tradeOrderQueryService.getOrder(id)));
} }
@Override @Override
public void cancelPaidOrder(Long userId, Long orderId) { public CommonResult<Boolean> cancelPaidOrder(Long userId, Long orderId) {
tradeOrderUpdateService.cancelPaidOrder(userId, orderId); tradeOrderUpdateService.cancelPaidOrder(userId, orderId);
return success(true);
} }
} }

View File

@ -67,7 +67,7 @@ public class TradeCombinationOrderHandler implements TradeOrderHandler {
// 2. 创建拼团记录 // 2. 创建拼团记录
TradeOrderItemDO item = orderItems.get(0); TradeOrderItemDO item = orderItems.get(0);
CombinationRecordCreateRespDTO combinationRecord = combinationRecordApi.createCombinationRecord( CombinationRecordCreateRespDTO combinationRecord = combinationRecordApi.createCombinationRecord(
TradeOrderConvert.INSTANCE.convert(order, item)); TradeOrderConvert.INSTANCE.convert(order, item)).getCheckedData();
// 3. 更新拼团相关信息到订单为什么几个字段都要更新 // 3. 更新拼团相关信息到订单为什么几个字段都要更新
// 原因是如果创建订单时自己是团长的情况下 combinationHeadId 是为 null 设置团长编号这个操作时在订单是否后创建拼团记录时才设置的 // 原因是如果创建订单时自己是团长的情况下 combinationHeadId 是为 null 设置团长编号这个操作时在订单是否后创建拼团记录时才设置的
@ -81,7 +81,7 @@ public class TradeCombinationOrderHandler implements TradeOrderHandler {
return; return;
} }
// 校验订单拼团是否成功 // 校验订单拼团是否成功
if (!combinationRecordApi.isCombinationRecordSuccess(order.getUserId(), order.getId())) { if (!combinationRecordApi.isCombinationRecordSuccess(order.getUserId(), order.getId()).getCheckedData()) {
throw exception(ORDER_DELIVERY_FAIL_COMBINATION_RECORD_STATUS_NOT_SUCCESS); throw exception(ORDER_DELIVERY_FAIL_COMBINATION_RECORD_STATUS_NOT_SUCCESS);
} }
} }

View File

@ -38,7 +38,7 @@ public class TradeBargainActivityPriceCalculator implements TradePriceCalculator
// 2. 校验是否可以参与砍价 // 2. 校验是否可以参与砍价
TradePriceCalculateRespBO.OrderItem orderItem = result.getItems().get(0); TradePriceCalculateRespBO.OrderItem orderItem = result.getItems().get(0);
BargainValidateJoinRespDTO bargainActivity = bargainRecordApi.validateJoinBargain( BargainValidateJoinRespDTO bargainActivity = bargainRecordApi.validateJoinBargain(
param.getUserId(), param.getBargainRecordId(), orderItem.getSkuId()); param.getUserId(), param.getBargainRecordId(), orderItem.getSkuId()).getCheckedData();
// 3.1 记录优惠明细 // 3.1 记录优惠明细
Integer discountPrice = orderItem.getPayPrice() - bargainActivity.getBargainPrice() * orderItem.getCount(); Integer discountPrice = orderItem.getPayPrice() - bargainActivity.getBargainPrice() * orderItem.getCount();

View File

@ -37,7 +37,7 @@ public class TradeCombinationActivityPriceCalculator implements TradePriceCalcul
TradePriceCalculateRespBO.OrderItem orderItem = result.getItems().get(0); TradePriceCalculateRespBO.OrderItem orderItem = result.getItems().get(0);
CombinationValidateJoinRespDTO combinationActivity = combinationRecordApi.validateJoinCombination( CombinationValidateJoinRespDTO combinationActivity = combinationRecordApi.validateJoinCombination(
param.getUserId(), param.getCombinationActivityId(), param.getCombinationHeadId(), param.getUserId(), param.getCombinationActivityId(), param.getCombinationHeadId(),
orderItem.getSkuId(), orderItem.getCount()); orderItem.getSkuId(), orderItem.getCount()).getCheckedData();
// 3.1 记录优惠明细 // 3.1 记录优惠明细
Integer discountPrice = orderItem.getPayPrice() - combinationActivity.getCombinationPrice() * orderItem.getCount(); Integer discountPrice = orderItem.getPayPrice() - combinationActivity.getCombinationPrice() * orderItem.getCount();

View File

@ -45,7 +45,7 @@ public class TradeCouponPriceCalculator implements TradePriceCalculator {
return; return;
} }
CouponRespDTO coupon = couponApi.validateCoupon(new CouponValidReqDTO() CouponRespDTO coupon = couponApi.validateCoupon(new CouponValidReqDTO()
.setId(param.getCouponId()).setUserId(param.getUserId())); .setId(param.getCouponId()).setUserId(param.getUserId())).getCheckedData();
Assert.notNull(coupon, "校验通过的优惠劵({}),不能为空", param.getCouponId()); Assert.notNull(coupon, "校验通过的优惠劵({}),不能为空", param.getCouponId());
// 1.2 只有普通订单才允许使用优惠劵 // 1.2 只有普通订单才允许使用优惠劵
if (ObjectUtil.notEqual(result.getType(), TradeOrderTypeEnum.NORMAL.getType())) { if (ObjectUtil.notEqual(result.getType(), TradeOrderTypeEnum.NORMAL.getType())) {

View File

@ -41,7 +41,7 @@ public class TradeDiscountActivityPriceCalculator implements TradePriceCalculato
} }
// 获得 SKU 对应的限时折扣活动 // 获得 SKU 对应的限时折扣活动
List<DiscountProductRespDTO> discountProducts = discountActivityApi.getMatchDiscountProductList( List<DiscountProductRespDTO> discountProducts = discountActivityApi.getMatchDiscountProductList(
convertSet(result.getItems(), TradePriceCalculateRespBO.OrderItem::getSkuId)); convertSet(result.getItems(), TradePriceCalculateRespBO.OrderItem::getSkuId)).getCheckedData();
if (CollUtil.isEmpty(discountProducts)) { if (CollUtil.isEmpty(discountProducts)) {
return; return;
} }

View File

@ -40,7 +40,7 @@ public class TradeRewardActivityPriceCalculator implements TradePriceCalculator
} }
// 获得 SKU 对应的满减送活动 // 获得 SKU 对应的满减送活动
List<RewardActivityMatchRespDTO> rewardActivities = rewardActivityApi.getMatchRewardActivityList( List<RewardActivityMatchRespDTO> rewardActivities = rewardActivityApi.getMatchRewardActivityList(
convertSet(result.getItems(), TradePriceCalculateRespBO.OrderItem::getSpuId)); convertSet(result.getItems(), TradePriceCalculateRespBO.OrderItem::getSpuId)).getCheckedData();
if (CollUtil.isEmpty(rewardActivities)) { if (CollUtil.isEmpty(rewardActivities)) {
return; return;
} }

View File

@ -59,7 +59,7 @@ public class TradeSeckillActivityPriceCalculator implements TradePriceCalculator
private SeckillValidateJoinRespDTO validateJoinSeckill(Long userId, Long activityId, Long skuId, Integer count) { private SeckillValidateJoinRespDTO validateJoinSeckill(Long userId, Long activityId, Long skuId, Integer count) {
// 1. 校验是否可以参与秒杀 // 1. 校验是否可以参与秒杀
SeckillValidateJoinRespDTO seckillActivity = seckillActivityApi.validateJoinSeckill(activityId, skuId, count); SeckillValidateJoinRespDTO seckillActivity = seckillActivityApi.validateJoinSeckill(activityId, skuId, count).getCheckedData();
// 2. 校验总限购数量目前只有 trade 有具体下单的数据需要交给 trade 价格计算使用 // 2. 校验总限购数量目前只有 trade 有具体下单的数据需要交给 trade 价格计算使用
int seckillProductCount = tradeOrderQueryService.getSeckillProductCount(userId, activityId); int seckillProductCount = tradeOrderQueryService.getSeckillProductCount(userId, activityId);
if (seckillProductCount + count > seckillActivity.getTotalLimitCount()) { if (seckillProductCount + count > seckillActivity.getTotalLimitCount()) {

View File

@ -26,12 +26,6 @@ public interface MemberAddressApi {
CommonResult<MemberAddressRespDTO> getAddress(@RequestParam("id") Long id, CommonResult<MemberAddressRespDTO> getAddress(@RequestParam("id") Long id,
@RequestParam("userId") Long userId); @RequestParam("userId") Long userId);
/**
* 获得用户默认收件地址
*
* @param userId 用户编号
* @return 用户收件地址
*/
@GetMapping(PREFIX + "/get-default") @GetMapping(PREFIX + "/get-default")
@Operation(summary = "获得用户默认收件地址") @Operation(summary = "获得用户默认收件地址")
@Parameter(name = "userId", description = "用户编号", required = true, example = "2048") @Parameter(name = "userId", description = "用户编号", required = true, example = "2048")

View File

@ -16,7 +16,7 @@ import org.springframework.web.bind.annotation.RequestParam;
@Tag(name = "RPC 服务 - 会员等级") @Tag(name = "RPC 服务 - 会员等级")
public interface MemberLevelApi { public interface MemberLevelApi {
String PREFIX = ApiConstants.PREFIX + "/address"; String PREFIX = ApiConstants.PREFIX + "/level";
@GetMapping(PREFIX + "/get") @GetMapping(PREFIX + "/get")
@Operation(summary = "获得会员等级") @Operation(summary = "获得会员等级")

View File

@ -4,8 +4,8 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.member.api.address.dto.MemberAddressRespDTO; import cn.iocoder.yudao.module.member.api.address.dto.MemberAddressRespDTO;
import cn.iocoder.yudao.module.member.convert.address.AddressConvert; import cn.iocoder.yudao.module.member.convert.address.AddressConvert;
import cn.iocoder.yudao.module.member.service.address.AddressService; import cn.iocoder.yudao.module.member.service.address.AddressService;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -16,7 +16,7 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
* *
* @author 芋道源码 * @author 芋道源码
*/ */
@Service @RestController // 提供 RESTful API 接口 Feign 调用
@Validated @Validated
public class MemberAddressApiImpl implements MemberAddressApi { public class MemberAddressApiImpl implements MemberAddressApi {

View File

@ -4,8 +4,8 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.member.api.config.dto.MemberConfigRespDTO; import cn.iocoder.yudao.module.member.api.config.dto.MemberConfigRespDTO;
import cn.iocoder.yudao.module.member.convert.config.MemberConfigConvert; import cn.iocoder.yudao.module.member.convert.config.MemberConfigConvert;
import cn.iocoder.yudao.module.member.service.config.MemberConfigService; import cn.iocoder.yudao.module.member.service.config.MemberConfigService;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -16,7 +16,7 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
* *
* @author owen * @author owen
*/ */
@Service @RestController // 提供 RESTful API 接口 Feign 调用
@Validated @Validated
public class MemberConfigApiImpl implements MemberConfigApi { public class MemberConfigApiImpl implements MemberConfigApi {

View File

@ -5,8 +5,8 @@ import cn.iocoder.yudao.module.member.api.level.dto.MemberLevelRespDTO;
import cn.iocoder.yudao.module.member.convert.level.MemberLevelConvert; import cn.iocoder.yudao.module.member.convert.level.MemberLevelConvert;
import cn.iocoder.yudao.module.member.enums.MemberExperienceBizTypeEnum; import cn.iocoder.yudao.module.member.enums.MemberExperienceBizTypeEnum;
import cn.iocoder.yudao.module.member.service.level.MemberLevelService; import cn.iocoder.yudao.module.member.service.level.MemberLevelService;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -19,7 +19,7 @@ import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.EXPERIENCE
* *
* @author owen * @author owen
*/ */
@Service @RestController // 提供 RESTful API 接口 Feign 调用
@Validated @Validated
public class MemberLevelApiImpl implements MemberLevelApi { public class MemberLevelApiImpl implements MemberLevelApi {

View File

@ -4,8 +4,8 @@ import cn.hutool.core.lang.Assert;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.member.enums.point.MemberPointBizTypeEnum; import cn.iocoder.yudao.module.member.enums.point.MemberPointBizTypeEnum;
import cn.iocoder.yudao.module.member.service.point.MemberPointRecordService; import cn.iocoder.yudao.module.member.service.point.MemberPointRecordService;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -18,7 +18,7 @@ import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.POINT_RECO
* *
* @author owen * @author owen
*/ */
@Service @RestController // 提供 RESTful API 接口 Feign 调用
@Validated @Validated
public class MemberPointApiImpl implements MemberPointApi { public class MemberPointApiImpl implements MemberPointApi {

View File

@ -1,7 +1,6 @@
package cn.iocoder.yudao.module.system.api.notify.notify; package cn.iocoder.yudao.module.system.api.notify;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.system.api.notify.NotifyMessageSendApi;
import cn.iocoder.yudao.module.system.api.notify.dto.NotifySendSingleToUserReqDTO; import cn.iocoder.yudao.module.system.api.notify.dto.NotifySendSingleToUserReqDTO;
import cn.iocoder.yudao.module.system.service.notify.NotifySendService; import cn.iocoder.yudao.module.system.service.notify.NotifySendService;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;

View File

@ -0,0 +1,46 @@
package cn.iocoder.yudao.module.system.api.social;
import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.system.api.social.dto.SocialWxJsapiSignatureRespDTO;
import cn.iocoder.yudao.module.system.api.social.dto.SocialWxPhoneNumberInfoRespDTO;
import cn.iocoder.yudao.module.system.convert.social.SocialClientConvert;
import cn.iocoder.yudao.module.system.service.social.SocialClientService;
import me.chanjar.weixin.common.bean.WxJsapiSignature;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
/**
* 社交应用的 API 实现类
*
* @author 芋道源码
*/
@RestController
@Validated
public class SocialClientApiImpl implements SocialClientApi {
@Resource
private SocialClientService socialClientService;
@Override
public CommonResult<String> getAuthorizeUrl(Integer socialType, Integer userType, String redirectUri) {
return success(socialClientService.getAuthorizeUrl(socialType, userType, redirectUri));
}
@Override
public CommonResult<SocialWxJsapiSignatureRespDTO> createWxMpJsapiSignature(Integer userType, String url) {
WxJsapiSignature signature = socialClientService.createWxMpJsapiSignature(userType, url);
return success(SocialClientConvert.INSTANCE.convert(signature));
}
@Override
public CommonResult<SocialWxPhoneNumberInfoRespDTO> getWxMaPhoneNumberInfo(Integer userType, String phoneCode) {
WxMaPhoneNumberInfo info = socialClientService.getWxMaPhoneNumberInfo(userType, phoneCode);
return success(SocialClientConvert.INSTANCE.convert(info));
}
}

View File

@ -0,0 +1,19 @@
package cn.iocoder.yudao.module.system.convert.social;
import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
import cn.iocoder.yudao.module.system.api.social.dto.SocialWxJsapiSignatureRespDTO;
import cn.iocoder.yudao.module.system.api.social.dto.SocialWxPhoneNumberInfoRespDTO;
import me.chanjar.weixin.common.bean.WxJsapiSignature;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
@Mapper
public interface SocialClientConvert {
SocialClientConvert INSTANCE = Mappers.getMapper(SocialClientConvert.class);
SocialWxJsapiSignatureRespDTO convert(WxJsapiSignature bean);
SocialWxPhoneNumberInfoRespDTO convert(WxMaPhoneNumberInfo bean);
}