优惠改造

This commit is contained in:
zhuyang 2021-10-09 22:56:43 +08:00
parent af8f9745e9
commit 341404eafa
37 changed files with 486 additions and 497 deletions

View File

@ -7,7 +7,8 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
@SpringBootApplication @SpringBootApplication
@EnableDiscoveryClient @EnableDiscoveryClient
@EnableFeignClients(basePackages = {"cn.iocoder.mall.productservice.rpc","cn.iocoder.mall.payservice.rpc"}) @EnableFeignClients(basePackages = {"cn.iocoder.mall.productservice.rpc","cn.iocoder.mall.payservice.rpc"
,"cn.iocoder.mall.promotion.api.rpc"})
public class ManagementWebApplication { public class ManagementWebApplication {
public static void main(String[] args) { public static void main(String[] args) {

View File

@ -4,9 +4,9 @@ import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.common.framework.vo.PageResult; import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.managementweb.controller.promotion.activity.vo.PromotionActivityPageReqVO; import cn.iocoder.mall.managementweb.controller.promotion.activity.vo.PromotionActivityPageReqVO;
import cn.iocoder.mall.managementweb.convert.promotion.PromotionActivityConvert; import cn.iocoder.mall.managementweb.convert.promotion.PromotionActivityConvert;
import cn.iocoder.mall.promotion.api.rpc.activity.PromotionActivityRpc; import cn.iocoder.mall.promotion.api.rpc.activity.PromotionActivityFeign;
import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityRespDTO; import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityRespDTO;
import org.apache.dubbo.config.annotation.DubboReference; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -17,11 +17,12 @@ import org.springframework.validation.annotation.Validated;
@Validated @Validated
public class PromotionActivityManager { public class PromotionActivityManager {
@DubboReference(version = "${dubbo.consumer.PromotionActivityRpc.version}")
private PromotionActivityRpc promotionActivityRpc; @Autowired
private PromotionActivityFeign promotionActivityFeign;
public PageResult<PromotionActivityRespDTO> pagePromotionActivity(PromotionActivityPageReqVO pageReqVO) { public PageResult<PromotionActivityRespDTO> pagePromotionActivity(PromotionActivityPageReqVO pageReqVO) {
CommonResult<PageResult<PromotionActivityRespDTO>> pagePromotionActivityResult = promotionActivityRpc.pagePromotionActivity( CommonResult<PageResult<PromotionActivityRespDTO>> pagePromotionActivityResult = promotionActivityFeign.pagePromotionActivity(
PromotionActivityConvert.INSTANCE.convert(pageReqVO)); PromotionActivityConvert.INSTANCE.convert(pageReqVO));
pagePromotionActivityResult.checkError(); pagePromotionActivityResult.checkError();
return pagePromotionActivityResult.getData(); return pagePromotionActivityResult.getData();

View File

@ -7,9 +7,9 @@ import cn.iocoder.mall.managementweb.controller.promotion.brand.vo.BannerPageReq
import cn.iocoder.mall.managementweb.controller.promotion.brand.vo.BannerRespVO; import cn.iocoder.mall.managementweb.controller.promotion.brand.vo.BannerRespVO;
import cn.iocoder.mall.managementweb.controller.promotion.brand.vo.BannerUpdateReqVO; import cn.iocoder.mall.managementweb.controller.promotion.brand.vo.BannerUpdateReqVO;
import cn.iocoder.mall.managementweb.convert.promotion.BannerConvert; import cn.iocoder.mall.managementweb.convert.promotion.BannerConvert;
import cn.iocoder.mall.promotion.api.rpc.banner.BannerRpc; import cn.iocoder.mall.promotion.api.rpc.banner.BannerFeign;
import cn.iocoder.mall.promotion.api.rpc.banner.dto.BannerRespDTO; import cn.iocoder.mall.promotion.api.rpc.banner.dto.BannerRespDTO;
import org.apache.dubbo.config.annotation.DubboReference; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
/** /**
@ -18,8 +18,8 @@ import org.springframework.stereotype.Service;
@Service @Service
public class BannerManager { public class BannerManager {
@DubboReference(version = "${dubbo.consumer.BannerRpc.version}") @Autowired
private BannerRpc bannerRpc; private BannerFeign bannerFeign;
/** /**
* 创建 Banner * 创建 Banner
@ -28,7 +28,7 @@ public class BannerManager {
* @return Banner * @return Banner
*/ */
public Integer createBanner(BannerCreateReqVO createVO) { public Integer createBanner(BannerCreateReqVO createVO) {
CommonResult<Integer> createBannerResult = bannerRpc.createBanner(BannerConvert.INSTANCE.convert(createVO)); CommonResult<Integer> createBannerResult = bannerFeign.createBanner(BannerConvert.INSTANCE.convert(createVO));
createBannerResult.checkError(); createBannerResult.checkError();
return createBannerResult.getData(); return createBannerResult.getData();
} }
@ -39,7 +39,7 @@ public class BannerManager {
* @param updateVO 更新 Banner VO * @param updateVO 更新 Banner VO
*/ */
public void updateBanner(BannerUpdateReqVO updateVO) { public void updateBanner(BannerUpdateReqVO updateVO) {
CommonResult<Boolean> updateBannerResult = bannerRpc.updateBanner(BannerConvert.INSTANCE.convert(updateVO)); CommonResult<Boolean> updateBannerResult = bannerFeign.updateBanner(BannerConvert.INSTANCE.convert(updateVO));
updateBannerResult.checkError(); updateBannerResult.checkError();
} }
@ -49,7 +49,7 @@ public class BannerManager {
* @param bannerId Banner 编号 * @param bannerId Banner 编号
*/ */
public void deleteBanner(Integer bannerId) { public void deleteBanner(Integer bannerId) {
CommonResult<Boolean> deleteBannerResult = bannerRpc.deleteBanner(bannerId); CommonResult<Boolean> deleteBannerResult = bannerFeign.deleteBanner(bannerId);
deleteBannerResult.checkError(); deleteBannerResult.checkError();
} }
@ -60,7 +60,7 @@ public class BannerManager {
* @return Banner 分页结果 * @return Banner 分页结果
*/ */
public PageResult<BannerRespVO> pageBanner(BannerPageReqVO pageVO) { public PageResult<BannerRespVO> pageBanner(BannerPageReqVO pageVO) {
CommonResult<PageResult<BannerRespDTO>> pageBannerResult = bannerRpc.pageBanner(BannerConvert.INSTANCE.convert(pageVO)); CommonResult<PageResult<BannerRespDTO>> pageBannerResult = bannerFeign.pageBanner(BannerConvert.INSTANCE.convert(pageVO));
pageBannerResult.checkError(); pageBannerResult.checkError();
return BannerConvert.INSTANCE.convertPage(pageBannerResult.getData()); return BannerConvert.INSTANCE.convertPage(pageBannerResult.getData());
} }

View File

@ -7,10 +7,10 @@ import cn.iocoder.mall.managementweb.controller.promotion.coupon.vo.template.Cou
import cn.iocoder.mall.managementweb.controller.promotion.coupon.vo.template.CouponTemplatePageReqVO; import cn.iocoder.mall.managementweb.controller.promotion.coupon.vo.template.CouponTemplatePageReqVO;
import cn.iocoder.mall.managementweb.controller.promotion.coupon.vo.template.CouponTemplateRespVO; import cn.iocoder.mall.managementweb.controller.promotion.coupon.vo.template.CouponTemplateRespVO;
import cn.iocoder.mall.managementweb.convert.promotion.CouponTemplateConvert; import cn.iocoder.mall.managementweb.convert.promotion.CouponTemplateConvert;
import cn.iocoder.mall.promotion.api.rpc.coupon.CouponTemplateRpc; import cn.iocoder.mall.promotion.api.rpc.coupon.CouponTemplateFeign;
import cn.iocoder.mall.promotion.api.rpc.coupon.dto.template.CouponCardTemplateUpdateStatusReqDTO; import cn.iocoder.mall.promotion.api.rpc.coupon.dto.template.CouponCardTemplateUpdateStatusReqDTO;
import cn.iocoder.mall.promotion.api.rpc.coupon.dto.template.CouponTemplateRespDTO; import cn.iocoder.mall.promotion.api.rpc.coupon.dto.template.CouponTemplateRespDTO;
import org.apache.dubbo.config.annotation.DubboReference; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -18,20 +18,20 @@ import org.springframework.validation.annotation.Validated;
@Validated @Validated
public class CouponTemplateManager { public class CouponTemplateManager {
@DubboReference(version = "${dubbo.consumer.CouponTemplateRpc.version}")
private CouponTemplateRpc couponTemplateRpc;
@Autowired
private CouponTemplateFeign couponTemplateFeign;
// ========== 通用逻辑 ========= // ========== 通用逻辑 =========
public PageResult<CouponTemplateRespVO> pageCouponTemplate(CouponTemplatePageReqVO pageVO) { public PageResult<CouponTemplateRespVO> pageCouponTemplate(CouponTemplatePageReqVO pageVO) {
CommonResult<PageResult<CouponTemplateRespDTO>> pageCouponTemplateResult = CommonResult<PageResult<CouponTemplateRespDTO>> pageCouponTemplateResult =
couponTemplateRpc.pageCouponTemplate(CouponTemplateConvert.INSTANCE.convert(pageVO)); couponTemplateFeign.pageCouponTemplate(CouponTemplateConvert.INSTANCE.convert(pageVO));
pageCouponTemplateResult.checkError(); pageCouponTemplateResult.checkError();
return CouponTemplateConvert.INSTANCE.convertPage(pageCouponTemplateResult.getData()); return CouponTemplateConvert.INSTANCE.convertPage(pageCouponTemplateResult.getData());
} }
public void updateCouponTemplateStatus(Integer id, Integer status) { public void updateCouponTemplateStatus(Integer id, Integer status) {
CommonResult<Boolean> updateCouponTemplateStatusResult = couponTemplateRpc.updateCouponTemplateStatus( CommonResult<Boolean> updateCouponTemplateStatusResult = couponTemplateFeign.updateCouponTemplateStatus(
new CouponCardTemplateUpdateStatusReqDTO().setId(id).setStatus(status)); new CouponCardTemplateUpdateStatusReqDTO().setId(id).setStatus(status));
updateCouponTemplateStatusResult.checkError(); updateCouponTemplateStatusResult.checkError();
} }
@ -39,14 +39,14 @@ public class CouponTemplateManager {
// ========== 优惠劵模板 ========== // ========== 优惠劵模板 ==========
public Integer createCouponCardTemplate(CouponTemplateCardCreateReqVO createVO) { public Integer createCouponCardTemplate(CouponTemplateCardCreateReqVO createVO) {
CommonResult<Integer> createCouponCardTemplateResult = couponTemplateRpc.createCouponCardTemplate( CommonResult<Integer> createCouponCardTemplateResult = couponTemplateFeign.createCouponCardTemplate(
CouponTemplateConvert.INSTANCE.convert(createVO)); CouponTemplateConvert.INSTANCE.convert(createVO));
createCouponCardTemplateResult.checkError(); createCouponCardTemplateResult.checkError();
return createCouponCardTemplateResult.getData(); return createCouponCardTemplateResult.getData();
} }
public void updateCouponCardTemplate(CouponTemplateCardUpdateReqVO updateVO) { public void updateCouponCardTemplate(CouponTemplateCardUpdateReqVO updateVO) {
CommonResult<Boolean> updateCouponCardTemplateResult = couponTemplateRpc.updateCouponCardTemplate( CommonResult<Boolean> updateCouponCardTemplateResult = couponTemplateFeign.updateCouponCardTemplate(
CouponTemplateConvert.INSTANCE.convert(updateVO)); CouponTemplateConvert.INSTANCE.convert(updateVO));
updateCouponCardTemplateResult.checkError(); updateCouponCardTemplateResult.checkError();
} }

View File

@ -10,9 +10,8 @@ import cn.iocoder.mall.managementweb.controller.promotion.recommend.vo.ProductRe
import cn.iocoder.mall.managementweb.convert.promotion.ProductRecommendConvert; import cn.iocoder.mall.managementweb.convert.promotion.ProductRecommendConvert;
import cn.iocoder.mall.productservice.rpc.spu.ProductSpuFeign; import cn.iocoder.mall.productservice.rpc.spu.ProductSpuFeign;
import cn.iocoder.mall.productservice.rpc.spu.dto.ProductSpuRespDTO; import cn.iocoder.mall.productservice.rpc.spu.dto.ProductSpuRespDTO;
import cn.iocoder.mall.promotion.api.rpc.recommend.ProductRecommendRpc; import cn.iocoder.mall.promotion.api.rpc.recommend.ProductRecommendFeign;
import cn.iocoder.mall.promotion.api.rpc.recommend.dto.ProductRecommendRespDTO; import cn.iocoder.mall.promotion.api.rpc.recommend.dto.ProductRecommendRespDTO;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -27,8 +26,8 @@ import java.util.Map;
@Validated @Validated
public class ProductRecommendManager { public class ProductRecommendManager {
@DubboReference(version = "${dubbo.consumer.ProductRecommendRpc.version}") @Autowired
private ProductRecommendRpc productRecommendRpc; private ProductRecommendFeign productRecommendFeign;
@Autowired @Autowired
private ProductSpuFeign productSpuFeign; private ProductSpuFeign productSpuFeign;
/** /**
@ -38,7 +37,7 @@ public class ProductRecommendManager {
* @return 商品推荐 * @return 商品推荐
*/ */
public Integer createProductRecommend(ProductRecommendCreateReqVO createVO) { public Integer createProductRecommend(ProductRecommendCreateReqVO createVO) {
CommonResult<Integer> createProductRecommendResult = productRecommendRpc.createProductRecommend( CommonResult<Integer> createProductRecommendResult = productRecommendFeign.createProductRecommend(
ProductRecommendConvert.INSTANCE.convert(createVO)); ProductRecommendConvert.INSTANCE.convert(createVO));
createProductRecommendResult.checkError(); createProductRecommendResult.checkError();
return createProductRecommendResult.getData(); return createProductRecommendResult.getData();
@ -50,7 +49,7 @@ public class ProductRecommendManager {
* @param updateVO 更新商品推荐 VO * @param updateVO 更新商品推荐 VO
*/ */
public void updateProductRecommend(ProductRecommendUpdateReqVO updateVO) { public void updateProductRecommend(ProductRecommendUpdateReqVO updateVO) {
CommonResult<Boolean> updateProductRecommendResult = productRecommendRpc.updateProductRecommend( CommonResult<Boolean> updateProductRecommendResult = productRecommendFeign.updateProductRecommend(
ProductRecommendConvert.INSTANCE.convert(updateVO)); ProductRecommendConvert.INSTANCE.convert(updateVO));
updateProductRecommendResult.checkError(); updateProductRecommendResult.checkError();
} }
@ -61,7 +60,7 @@ public class ProductRecommendManager {
* @param productRecommendId 商品推荐编号 * @param productRecommendId 商品推荐编号
*/ */
public void deleteProductRecommend(Integer productRecommendId) { public void deleteProductRecommend(Integer productRecommendId) {
CommonResult<Boolean> deleteProductRecommendResult = productRecommendRpc.deleteProductRecommend(productRecommendId); CommonResult<Boolean> deleteProductRecommendResult = productRecommendFeign.deleteProductRecommend(productRecommendId);
deleteProductRecommendResult.checkError(); deleteProductRecommendResult.checkError();
} }
@ -72,7 +71,7 @@ public class ProductRecommendManager {
* @return 商品推荐分页结果 * @return 商品推荐分页结果
*/ */
public PageResult<ProductRecommendDetailVO> pageProductRecommend(ProductRecommendPageReqVO pageVO) { public PageResult<ProductRecommendDetailVO> pageProductRecommend(ProductRecommendPageReqVO pageVO) {
CommonResult<PageResult<ProductRecommendRespDTO>> pageProductRecommendResult = productRecommendRpc.pageProductRecommend(ProductRecommendConvert.INSTANCE.convert(pageVO)); CommonResult<PageResult<ProductRecommendRespDTO>> pageProductRecommendResult = productRecommendFeign.pageProductRecommend(ProductRecommendConvert.INSTANCE.convert(pageVO));
pageProductRecommendResult.checkError(); pageProductRecommendResult.checkError();
// 拼接结果 // 拼接结果
PageResult<ProductRecommendDetailVO> pageResult = ProductRecommendConvert.INSTANCE.convertPage(pageProductRecommendResult.getData()); PageResult<ProductRecommendDetailVO> pageResult = ProductRecommendConvert.INSTANCE.convertPage(pageProductRecommendResult.getData());

View File

@ -44,6 +44,10 @@
<artifactId>hibernate-validator</artifactId> <artifactId>hibernate-validator</artifactId>
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-openfeign-core</artifactId>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@ -0,0 +1,28 @@
package cn.iocoder.mall.promotion.api.rpc.activity;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityListReqDTO;
import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityPageReqDTO;
import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityRespDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
/**
* Title:
* Description:
*
* @author zhuyang
* @version 1.0 2021/10/9
*/
@FeignClient("promotion-service")
public interface PromotionActivityFeign {
@PostMapping("/promotion/activity/pagePromotionActivity")
CommonResult<PageResult<PromotionActivityRespDTO>> pagePromotionActivity(@RequestBody PromotionActivityPageReqDTO pageReqDTO) ;
@PostMapping("/promotion/activity/listPromotionActivities")
CommonResult<List<PromotionActivityRespDTO>> listPromotionActivities(@RequestBody PromotionActivityListReqDTO listReqDTO) ;
}

View File

@ -1,20 +0,0 @@
package cn.iocoder.mall.promotion.api.rpc.activity;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityListReqDTO;
import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityPageReqDTO;
import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityRespDTO;
import java.util.List;
/**
* 促销活动 Rpc 接口
*/
public interface PromotionActivityRpc {
CommonResult<PageResult<PromotionActivityRespDTO>> pagePromotionActivity(PromotionActivityPageReqDTO pageReqDTO);
CommonResult<List<PromotionActivityRespDTO>> listPromotionActivities(PromotionActivityListReqDTO listReqDTO);
}

View File

@ -0,0 +1,35 @@
package cn.iocoder.mall.promotion.api.rpc.banner;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.promotion.api.rpc.banner.dto.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
/**
* Title:
* Description:
*
* @author zhuyang
* @version 1.0 2021/10/9
*/
@FeignClient("promotion-service")
public interface BannerFeign {
@PostMapping("/promotion/banner/createBanner")
public CommonResult<Integer> createBanner(@RequestBody BannerCreateReqDTO createDTO) ;
@PostMapping("/promotion/banner/updateBanner")
public CommonResult<Boolean> updateBanner(@RequestBody BannerUpdateReqDTO updateDTO) ;
@PostMapping("/promotion/banner/deleteBanner")
public CommonResult<Boolean> deleteBanner(@RequestBody Integer bannerId) ;
@PostMapping("/promotion/banner/listBanners")
public CommonResult<List<BannerRespDTO>> listBanners(@RequestBody BannerListReqDTO listDTO) ;
@PostMapping("/promotion/banner/pageBanner")
public CommonResult<PageResult<BannerRespDTO>> pageBanner(@RequestBody BannerPageReqDTO pageDTO);
}

View File

@ -1,52 +0,0 @@
package cn.iocoder.mall.promotion.api.rpc.banner;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.promotion.api.rpc.banner.dto.*;
import java.util.List;
/**
* Banner Rpc 接口
*/
public interface BannerRpc {
/**
* 创建 Banner
*
* @param createDTO 创建 Banner DTO
* @return Banner 编号
*/
CommonResult<Integer> createBanner(BannerCreateReqDTO createDTO);
/**
* 更新 Banner
*
* @param updateDTO 更新 Banner DTO
*/
CommonResult<Boolean> updateBanner(BannerUpdateReqDTO updateDTO);
/**
* 删除 Banner
*
* @param bannerId Banner 编号
*/
CommonResult<Boolean> deleteBanner(Integer bannerId);
/**
* 获得 Banner 列表
*
* @param listDTO Banner 列表查询 DTO
* @return Banner 列表
*/
CommonResult<List<BannerRespDTO>> listBanners(BannerListReqDTO listDTO);
/**
* 获得 Banner 分页
*
* @param pageDTO Banner 分页查询
* @return Banner 分页结果
*/
CommonResult<PageResult<BannerRespDTO>> pageBanner(BannerPageReqDTO pageDTO);
}

View File

@ -0,0 +1,35 @@
package cn.iocoder.mall.promotion.api.rpc.coupon;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.promotion.api.rpc.coupon.dto.card.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
/**
* Title:
* Description:
*
* @author zhuyang
* @version 1.0 2021/10/9
*/
@FeignClient("promotion-service")
public interface CouponCardFeign {
@PostMapping("/coupon/card/pageCouponCard")
public CommonResult<PageResult<CouponCardRespDTO>> pageCouponCard(@RequestBody CouponCardPageReqDTO pageReqDTO) ;
@PostMapping("/coupon/card/createCouponCard")
public CommonResult<Integer> createCouponCard(@RequestBody CouponCardCreateReqDTO createReqDTO);
@PostMapping("/coupon/card/useCouponCard")
public CommonResult<Boolean> useCouponCard(@RequestBody CouponCardUseReqDTO useReqDTO) ;
@PostMapping("/coupon/card/cancelUseCouponCard")
public CommonResult<Boolean> cancelUseCouponCard(@RequestBody CouponCardCancelUseReqDTO cancelUseReqDTO) ;
@PostMapping("/coupon/card/listAvailableCouponCards")
public CommonResult<List<CouponCardAvailableRespDTO>> listAvailableCouponCards(@RequestBody CouponCardAvailableListReqDTO listReqDTO);
}

View File

@ -1,54 +0,0 @@
package cn.iocoder.mall.promotion.api.rpc.coupon;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.promotion.api.rpc.coupon.dto.card.*;
import java.util.List;
/**
* 优惠劵 Rpc 接口
*/
public interface CouponCardRpc {
/**
* 获得优惠劵分页
*
* @param pageReqDTO 优惠劵分页查询
* @return 优惠劵分页结果
*/
CommonResult<PageResult<CouponCardRespDTO>> pageCouponCard(CouponCardPageReqDTO pageReqDTO);
/**
* 给用户添加优惠劵
*
* @param createReqDTO 创建信息
* @return 优惠劵编号
*/
CommonResult<Integer> createCouponCard(CouponCardCreateReqDTO createReqDTO);
/**
* 用户使用优惠劵
*
* @param useReqDTO 使用信息
* @return 成功
*/
CommonResult<Boolean> useCouponCard(CouponCardUseReqDTO useReqDTO);
/**
* 用户取消使用优惠劵
*
* @param cancelUseReqDTO 取消使用信息
* @return 成功
*/
CommonResult<Boolean> cancelUseCouponCard(CouponCardCancelUseReqDTO cancelUseReqDTO);
/**
* 获得用户优惠劵的可用信息列表
*
* @param listReqDTO 查询信息
* @return 优惠劵的可用信息列表
*/
CommonResult<List<CouponCardAvailableRespDTO>> listAvailableCouponCards(CouponCardAvailableListReqDTO listReqDTO);
}

View File

@ -0,0 +1,39 @@
package cn.iocoder.mall.promotion.api.rpc.coupon;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.promotion.api.rpc.coupon.dto.template.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
/**
* Title:
* Description:
*
* @author zhuyang
* @version 1.0 2021/10/9
*/
@FeignClient("promotion-service")
public interface CouponTemplateFeign {
// ========== 通用逻辑 =========
@GetMapping("/coupon/template/getCouponTemplate")
public CommonResult<CouponTemplateRespDTO> getCouponTemplate(@RequestParam("couponTemplateId") Integer couponTemplateId);
@PostMapping("/coupon/template/pageCouponTemplate")
public CommonResult<PageResult<CouponTemplateRespDTO>> pageCouponTemplate(@RequestBody CouponTemplatePageReqDTO pageDTO);
@PostMapping("/coupon/template/updateCouponTemplateStatus")
public CommonResult<Boolean> updateCouponTemplateStatus(@RequestBody CouponCardTemplateUpdateStatusReqDTO updateStatusReqDTO) ;
// ========== 优惠劵模板 ==========
@PostMapping("/coupon/template/createCouponCardTemplate")
public CommonResult<Integer> createCouponCardTemplate(@RequestBody CouponCardTemplateCreateReqDTO createDTO) ;
@PostMapping("/coupon/template/updateCouponCardTemplate")
public CommonResult<Boolean> updateCouponCardTemplate(@RequestBody CouponCardTemplateUpdateReqDTO updateDTO) ;
}

View File

@ -1,57 +0,0 @@
package cn.iocoder.mall.promotion.api.rpc.coupon;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.promotion.api.rpc.coupon.dto.template.*;
/**
* 优惠劵模板 Rpc 接口
*/
public interface CouponTemplateRpc {
// ========== 通用逻辑 =========
/**
* 获得优惠劵模板
*
* @param couponTemplateId 优惠劵模板编号
* @return 优惠劵模板
*/
CommonResult<CouponTemplateRespDTO> getCouponTemplate(Integer couponTemplateId);
/**
* 获得优惠劵模板分页
*
* @param pageDTO 优惠劵模板分页查询
* @return 优惠劵模板分页结果
*/
CommonResult<PageResult<CouponTemplateRespDTO>> pageCouponTemplate(CouponTemplatePageReqDTO pageDTO);
/**
* 更新优惠劵模板的状态
*
* @param updateStatusReqDTO 更新状态 DTO
*/
CommonResult<Boolean> updateCouponTemplateStatus(CouponCardTemplateUpdateStatusReqDTO updateStatusReqDTO);
// ========== 优惠劵模板 ==========
/**
* 创建优惠劵模板
*
* @param createDTO 创建优惠劵模板 DTO
* @return 优惠劵模板编号
*/
CommonResult<Integer> createCouponCardTemplate(CouponCardTemplateCreateReqDTO createDTO);
/**
* 更新优惠劵模板
*
* @param updateDTO 更新优惠劵模板 DTO
*/
CommonResult<Boolean> updateCouponCardTemplate(CouponCardTemplateUpdateReqDTO updateDTO);
// ========== 优惠码模板 ==========
}

View File

@ -0,0 +1,21 @@
package cn.iocoder.mall.promotion.api.rpc.price;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.promotion.api.rpc.price.dto.PriceProductCalcReqDTO;
import cn.iocoder.mall.promotion.api.rpc.price.dto.PriceProductCalcRespDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
/**
* Title:
* Description:
*
* @author zhuyang
* @version 1.0 2021/10/9
*/
@FeignClient("promotion-service")
public interface PriceFeign {
@PostMapping("/promotion/price/calcProductPrice")
public CommonResult<PriceProductCalcRespDTO> calcProductPrice(@RequestBody PriceProductCalcReqDTO calcReqDTO) ;
}

View File

@ -1,14 +0,0 @@
package cn.iocoder.mall.promotion.api.rpc.price;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.promotion.api.rpc.price.dto.PriceProductCalcReqDTO;
import cn.iocoder.mall.promotion.api.rpc.price.dto.PriceProductCalcRespDTO;
/**
* 价格 Rpc 接口提供价格计算的功能
*/
public interface PriceRpc {
CommonResult<PriceProductCalcRespDTO> calcProductPrice(PriceProductCalcReqDTO calcReqDTO);
}

View File

@ -0,0 +1,38 @@
package cn.iocoder.mall.promotion.api.rpc.recommend;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.promotion.api.rpc.recommend.dto.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
/**
* Title:
* Description:
*
* @author zhuyang
* @version 1.0 2021/10/9
*/
@FeignClient("promotion-service")
public interface ProductRecommendFeign {
@PostMapping("/promotion/prod/recommend/createProductRecommend")
public CommonResult<Integer> createProductRecommend(@RequestBody ProductRecommendCreateReqDTO createDTO) ;
@PostMapping("/promotion/prod/recommend/updateProductRecommend")
public CommonResult<Boolean> updateProductRecommend(@RequestBody ProductRecommendUpdateReqDTO updateDTO);
@GetMapping("/promotion/prod/recommend/deleteProductRecommend")
public CommonResult<Boolean> deleteProductRecommend(@RequestParam("productRecommendId") Integer productRecommendId) ;
@PostMapping("/promotion/prod/recommend/listProductRecommends")
public CommonResult<List<ProductRecommendRespDTO>> listProductRecommends(@RequestBody ProductRecommendListReqDTO listReqDTO) ;
@PostMapping("/promotion/prod/recommend/pageProductRecommend")
public CommonResult<PageResult<ProductRecommendRespDTO>> pageProductRecommend(@RequestBody ProductRecommendPageReqDTO pageDTO) ;
}

View File

@ -1,52 +0,0 @@
package cn.iocoder.mall.promotion.api.rpc.recommend;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.promotion.api.rpc.recommend.dto.*;
import java.util.List;
/**
* 商品推荐 Rpc 接口
*/
public interface ProductRecommendRpc {
/**
* 创建商品推荐
*
* @param createDTO 创建商品推荐 DTO
* @return 商品推荐编号
*/
CommonResult<Integer> createProductRecommend(ProductRecommendCreateReqDTO createDTO);
/**
* 更新商品推荐
*
* @param updateDTO 更新商品推荐 DTO
*/
CommonResult<Boolean> updateProductRecommend(ProductRecommendUpdateReqDTO updateDTO);
/**
* 删除商品推荐
*
* @param productRecommendId 商品推荐编号
*/
CommonResult<Boolean> deleteProductRecommend(Integer productRecommendId);
/**
* 获得商品推荐列表
*
* @param listReqDTO 商品推荐列表查询 DTO
* @return 商品推荐列表
*/
CommonResult<List<ProductRecommendRespDTO>> listProductRecommends(ProductRecommendListReqDTO listReqDTO);
/**
* 获得商品推荐分页
*
* @param pageDTO 商品推荐分页查询
* @return 商品推荐分页结果
*/
CommonResult<PageResult<ProductRecommendRespDTO>> pageProductRecommend(ProductRecommendPageReqDTO pageDTO);
}

View File

@ -0,0 +1,57 @@
package cn.iocoder.mall.promotionservice.controller;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.promotion.api.rpc.banner.dto.*;
import cn.iocoder.mall.promotionservice.manager.banner.BannerManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import static cn.iocoder.common.framework.vo.CommonResult.success;
/**
* Title:
* Description:
*
* @author zhuyang
* @version 1.0 2021/10/9
*/
@RestController
@RequestMapping("/promotion/banner")
public class BannerController {
@Autowired
private BannerManager bannerManager;
@PostMapping("createBanner")
public CommonResult<Integer> createBanner(@RequestBody BannerCreateReqDTO createDTO) {
return success(bannerManager.createBanner(createDTO));
}
@PostMapping("updateBanner")
public CommonResult<Boolean> updateBanner(@RequestBody BannerUpdateReqDTO updateDTO) {
bannerManager.updateBanner(updateDTO);
return success(true);
}
@PostMapping("deleteBanner")
public CommonResult<Boolean> deleteBanner(@RequestBody Integer bannerId) {
bannerManager.deleteBanner(bannerId);
return success(true);
}
@PostMapping("listBanners")
public CommonResult<List<BannerRespDTO>> listBanners(@RequestBody BannerListReqDTO listDTO) {
return success(bannerManager.listBanners(listDTO));
}
@PostMapping("pageBanner")
public CommonResult<PageResult<BannerRespDTO>> pageBanner(@RequestBody BannerPageReqDTO pageDTO) {
return success(bannerManager.pageBanner(pageDTO));
}
}

View File

@ -0,0 +1,55 @@
package cn.iocoder.mall.promotionservice.controller;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.promotion.api.rpc.coupon.dto.card.*;
import cn.iocoder.mall.promotionservice.manager.coupon.CouponCardManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import static cn.iocoder.common.framework.vo.CommonResult.success;
/**
* Title:
* Description:
*
* @author zhuyang
* @version 1.0 2021/10/9
*/
@RestController
@RequestMapping("/coupon/card")
public class CouponCardController {
@Autowired
private CouponCardManager couponCardManager;
@PostMapping("pageCouponCard")
public CommonResult<PageResult<CouponCardRespDTO>> pageCouponCard(@RequestBody CouponCardPageReqDTO pageReqDTO) {
return success(couponCardManager.pageCouponCard(pageReqDTO));
}
@PostMapping("createCouponCard")
public CommonResult<Integer> createCouponCard(@RequestBody CouponCardCreateReqDTO createReqDTO) {
return success(couponCardManager.createCouponCard(createReqDTO));
}
@PostMapping("useCouponCard")
public CommonResult<Boolean> useCouponCard(@RequestBody CouponCardUseReqDTO useReqDTO) {
return success(couponCardManager.useCouponCard(useReqDTO));
}
@PostMapping("cancelUseCouponCard")
public CommonResult<Boolean> cancelUseCouponCard(@RequestBody CouponCardCancelUseReqDTO cancelUseReqDTO) {
return success(couponCardManager.cancelUseCouponCard(cancelUseReqDTO));
}
@PostMapping("listAvailableCouponCards")
public CommonResult<List<CouponCardAvailableRespDTO>> listAvailableCouponCards(@RequestBody CouponCardAvailableListReqDTO listReqDTO) {
return success(couponCardManager.listAvailableCouponCards(listReqDTO));
}
}

View File

@ -1,50 +1,56 @@
package cn.iocoder.mall.promotionservice.rpc.coupon; package cn.iocoder.mall.promotionservice.controller;
import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.common.framework.vo.PageResult; import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.promotion.api.rpc.coupon.CouponTemplateRpc;
import cn.iocoder.mall.promotion.api.rpc.coupon.dto.template.*; import cn.iocoder.mall.promotion.api.rpc.coupon.dto.template.*;
import cn.iocoder.mall.promotionservice.manager.coupon.CouponTemplateManager; import cn.iocoder.mall.promotionservice.manager.coupon.CouponTemplateManager;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import static cn.iocoder.common.framework.vo.CommonResult.success; import static cn.iocoder.common.framework.vo.CommonResult.success;
@DubboService /**
public class CouponTemplateRpcImpl implements CouponTemplateRpc { * Title:
* Description:
*
* @author zhuyang
* @version 1.0 2021/10/9
*/
@RestController
@RequestMapping("/coupon/template")
public class CouponTemplateController {
@Autowired @Autowired
private CouponTemplateManager couponTemplateManager; private CouponTemplateManager couponTemplateManager;
// ========== 通用逻辑 ========= // ========== 通用逻辑 =========
@Override @GetMapping("getCouponTemplate")
public CommonResult<CouponTemplateRespDTO> getCouponTemplate(Integer couponTemplateId) { public CommonResult<CouponTemplateRespDTO> getCouponTemplate(@RequestParam("couponTemplateId") Integer couponTemplateId) {
return success(couponTemplateManager.getCouponTemplate(couponTemplateId)); return success(couponTemplateManager.getCouponTemplate(couponTemplateId));
} }
@Override @PostMapping("pageCouponTemplate")
public CommonResult<PageResult<CouponTemplateRespDTO>> pageCouponTemplate(CouponTemplatePageReqDTO pageDTO) { public CommonResult<PageResult<CouponTemplateRespDTO>> pageCouponTemplate(@RequestBody CouponTemplatePageReqDTO pageDTO) {
return success(couponTemplateManager.pageCouponTemplate(pageDTO)); return success(couponTemplateManager.pageCouponTemplate(pageDTO));
} }
@Override @PostMapping("updateCouponTemplateStatus")
public CommonResult<Boolean> updateCouponTemplateStatus(CouponCardTemplateUpdateStatusReqDTO updateStatusReqDTO) { public CommonResult<Boolean> updateCouponTemplateStatus(@RequestBody CouponCardTemplateUpdateStatusReqDTO updateStatusReqDTO) {
couponTemplateManager.updateCouponTemplateStatus(updateStatusReqDTO); couponTemplateManager.updateCouponTemplateStatus(updateStatusReqDTO);
return success(true); return success(true);
} }
// ========== 优惠劵模板 ========== // ========== 优惠劵模板 ==========
@Override @PostMapping("createCouponCardTemplate")
public CommonResult<Integer> createCouponCardTemplate(CouponCardTemplateCreateReqDTO createDTO) { public CommonResult<Integer> createCouponCardTemplate(@RequestBody CouponCardTemplateCreateReqDTO createDTO) {
return success(couponTemplateManager.createCouponCardTemplate(createDTO)); return success(couponTemplateManager.createCouponCardTemplate(createDTO));
} }
@Override @PostMapping("updateCouponCardTemplate")
public CommonResult<Boolean> updateCouponCardTemplate(CouponCardTemplateUpdateReqDTO updateDTO) { public CommonResult<Boolean> updateCouponCardTemplate(@RequestBody CouponCardTemplateUpdateReqDTO updateDTO) {
couponTemplateManager.updateCouponCardTemplate(updateDTO); couponTemplateManager.updateCouponCardTemplate(updateDTO);
return success(true); return success(true);
} }
} }

View File

@ -1,24 +1,33 @@
package cn.iocoder.mall.promotionservice.rpc.price; package cn.iocoder.mall.promotionservice.controller;
import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.promotion.api.rpc.price.PriceRpc;
import cn.iocoder.mall.promotion.api.rpc.price.dto.PriceProductCalcReqDTO; import cn.iocoder.mall.promotion.api.rpc.price.dto.PriceProductCalcReqDTO;
import cn.iocoder.mall.promotion.api.rpc.price.dto.PriceProductCalcRespDTO; import cn.iocoder.mall.promotion.api.rpc.price.dto.PriceProductCalcRespDTO;
import cn.iocoder.mall.promotionservice.manager.price.PriceManager; import cn.iocoder.mall.promotionservice.manager.price.PriceManager;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import static cn.iocoder.common.framework.vo.CommonResult.success; import static cn.iocoder.common.framework.vo.CommonResult.success;
@DubboService /**
public class PriceRpcImpl implements PriceRpc { * Title:
* Description:
*
* @author zhuyang
* @version 1.0 2021/10/9
*/
@RestController
@RequestMapping("/promotion/price")
public class PriceController {
@Autowired @Autowired
private PriceManager priceManager; private PriceManager priceManager;
@Override @PostMapping("calcProductPrice")
public CommonResult<PriceProductCalcRespDTO> calcProductPrice(PriceProductCalcReqDTO calcReqDTO) { public CommonResult<PriceProductCalcRespDTO> calcProductPrice(@RequestBody PriceProductCalcReqDTO calcReqDTO) {
return success(priceManager.calcProductPrice(calcReqDTO)); return success(priceManager.calcProductPrice(calcReqDTO));
} }
} }

View File

@ -1,48 +1,55 @@
package cn.iocoder.mall.promotionservice.rpc.recommend; package cn.iocoder.mall.promotionservice.controller;
import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.common.framework.vo.PageResult; import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.promotion.api.rpc.recommend.ProductRecommendRpc;
import cn.iocoder.mall.promotion.api.rpc.recommend.dto.*; import cn.iocoder.mall.promotion.api.rpc.recommend.dto.*;
import cn.iocoder.mall.promotionservice.manager.recommend.ProductRecommendManager; import cn.iocoder.mall.promotionservice.manager.recommend.ProductRecommendManager;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
import static cn.iocoder.common.framework.vo.CommonResult.success; import static cn.iocoder.common.framework.vo.CommonResult.success;
@DubboService /**
public class ProductRecommendRpcImpl implements ProductRecommendRpc { * Title:
* Description:
*
* @author zhuyang
* @version 1.0 2021/10/9
*/
@RestController
@RequestMapping("/promotion/prod/recommend")
public class ProductRecommendController {
@Autowired @Autowired
private ProductRecommendManager productRecommendManager; private ProductRecommendManager productRecommendManager;
@Override
public CommonResult<Integer> createProductRecommend(ProductRecommendCreateReqDTO createDTO) { @PostMapping("createProductRecommend")
public CommonResult<Integer> createProductRecommend(@RequestBody ProductRecommendCreateReqDTO createDTO) {
return success(productRecommendManager.createProductRecommend(createDTO)); return success(productRecommendManager.createProductRecommend(createDTO));
} }
@Override @PostMapping("updateProductRecommend")
public CommonResult<Boolean> updateProductRecommend(ProductRecommendUpdateReqDTO updateDTO) { public CommonResult<Boolean> updateProductRecommend(@RequestBody ProductRecommendUpdateReqDTO updateDTO) {
productRecommendManager.updateProductRecommend(updateDTO); productRecommendManager.updateProductRecommend(updateDTO);
return success(true); return success(true);
} }
@Override @GetMapping("deleteProductRecommend")
public CommonResult<Boolean> deleteProductRecommend(Integer productRecommendId) { public CommonResult<Boolean> deleteProductRecommend(@RequestParam("productRecommendId") Integer productRecommendId) {
productRecommendManager.deleteProductRecommend(productRecommendId); productRecommendManager.deleteProductRecommend(productRecommendId);
return success(true); return success(true);
} }
@Override @PostMapping("listProductRecommends")
public CommonResult<List<ProductRecommendRespDTO>> listProductRecommends(ProductRecommendListReqDTO listReqDTO) { public CommonResult<List<ProductRecommendRespDTO>> listProductRecommends(@RequestBody ProductRecommendListReqDTO listReqDTO) {
return success(productRecommendManager.listProductRecommends(listReqDTO)); return success(productRecommendManager.listProductRecommends(listReqDTO));
} }
@Override @PostMapping("pageProductRecommend")
public CommonResult<PageResult<ProductRecommendRespDTO>> pageProductRecommend(ProductRecommendPageReqDTO pageDTO) { public CommonResult<PageResult<ProductRecommendRespDTO>> pageProductRecommend(@RequestBody ProductRecommendPageReqDTO pageDTO) {
return success(productRecommendManager.pageProductRecommend(pageDTO)); return success(productRecommendManager.pageProductRecommend(pageDTO));
} }
} }

View File

@ -1,33 +1,40 @@
package cn.iocoder.mall.promotionservice.rpc.activity; package cn.iocoder.mall.promotionservice.controller;
import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.common.framework.vo.PageResult; import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.promotion.api.rpc.activity.PromotionActivityRpc;
import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityListReqDTO; import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityListReqDTO;
import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityPageReqDTO; import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityPageReqDTO;
import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityRespDTO; import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityRespDTO;
import cn.iocoder.mall.promotionservice.manager.activity.PromotionActivityManager; import cn.iocoder.mall.promotionservice.manager.activity.PromotionActivityManager;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List; import java.util.List;
import static cn.iocoder.common.framework.vo.CommonResult.success; import static cn.iocoder.common.framework.vo.CommonResult.success;
@DubboService /**
public class PromotionActivityRpcImpl implements PromotionActivityRpc { * Title:
* Description:
*
* @author zhuyang
* @version 1.0 2021/10/9
*/
@RestController
@RequestMapping("/promotion/activity")
public class PromotionActivityController {
@Autowired @Autowired
private PromotionActivityManager promotionActivityManager; private PromotionActivityManager promotionActivityManager;
@Override @PostMapping("pagePromotionActivity")
public CommonResult<PageResult<PromotionActivityRespDTO>> pagePromotionActivity(PromotionActivityPageReqDTO pageReqDTO) { public CommonResult<PageResult<PromotionActivityRespDTO>> pagePromotionActivity(@RequestBody PromotionActivityPageReqDTO pageReqDTO) {
return success(promotionActivityManager.pagePromotionActivity(pageReqDTO)); return success(promotionActivityManager.pagePromotionActivity(pageReqDTO));
} }
@PostMapping("listPromotionActivities")
@Override public CommonResult<List<PromotionActivityRespDTO>> listPromotionActivities(@RequestBody PromotionActivityListReqDTO listReqDTO) {
public CommonResult<List<PromotionActivityRespDTO>> listPromotionActivities(PromotionActivityListReqDTO listReqDTO) {
return success(promotionActivityManager.listPromotionActivities(listReqDTO)); return success(promotionActivityManager.listPromotionActivities(listReqDTO));
} }
} }

View File

@ -1,48 +0,0 @@
package cn.iocoder.mall.promotionservice.rpc.banner;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.promotion.api.rpc.banner.BannerRpc;
import cn.iocoder.mall.promotion.api.rpc.banner.dto.*;
import cn.iocoder.mall.promotionservice.manager.banner.BannerManager;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
import static cn.iocoder.common.framework.vo.CommonResult.success;
@DubboService
public class BannerRpcImpl implements BannerRpc {
@Autowired
private BannerManager bannerManager;
@Override
public CommonResult<Integer> createBanner(BannerCreateReqDTO createDTO) {
return success(bannerManager.createBanner(createDTO));
}
@Override
public CommonResult<Boolean> updateBanner(BannerUpdateReqDTO updateDTO) {
bannerManager.updateBanner(updateDTO);
return success(true);
}
@Override
public CommonResult<Boolean> deleteBanner(Integer bannerId) {
bannerManager.deleteBanner(bannerId);
return success(true);
}
@Override
public CommonResult<List<BannerRespDTO>> listBanners(BannerListReqDTO listDTO) {
return success(bannerManager.listBanners(listDTO));
}
@Override
public CommonResult<PageResult<BannerRespDTO>> pageBanner(BannerPageReqDTO pageDTO) {
return success(bannerManager.pageBanner(pageDTO));
}
}

View File

@ -1,46 +0,0 @@
package cn.iocoder.mall.promotionservice.rpc.coupon;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.promotion.api.rpc.coupon.CouponCardRpc;
import cn.iocoder.mall.promotion.api.rpc.coupon.dto.card.*;
import cn.iocoder.mall.promotionservice.manager.coupon.CouponCardManager;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
import static cn.iocoder.common.framework.vo.CommonResult.success;
@DubboService
public class CouponCardRpcImpl implements CouponCardRpc {
@Autowired
private CouponCardManager couponCardManager;
@Override
public CommonResult<PageResult<CouponCardRespDTO>> pageCouponCard(CouponCardPageReqDTO pageReqDTO) {
return success(couponCardManager.pageCouponCard(pageReqDTO));
}
@Override
public CommonResult<Integer> createCouponCard(CouponCardCreateReqDTO createReqDTO) {
return success(couponCardManager.createCouponCard(createReqDTO));
}
@Override
public CommonResult<Boolean> useCouponCard(CouponCardUseReqDTO useReqDTO) {
return success(couponCardManager.useCouponCard(useReqDTO));
}
@Override
public CommonResult<Boolean> cancelUseCouponCard(CouponCardCancelUseReqDTO cancelUseReqDTO) {
return success(couponCardManager.cancelUseCouponCard(cancelUseReqDTO));
}
@Override
public CommonResult<List<CouponCardAvailableRespDTO>> listAvailableCouponCards(CouponCardAvailableListReqDTO listReqDTO) {
return success(couponCardManager.listAvailableCouponCards(listReqDTO));
}
}

View File

@ -8,7 +8,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
@SpringBootApplication @SpringBootApplication
@EnableDiscoveryClient @EnableDiscoveryClient
@EnableFeignClients(basePackages = {"cn.iocoder.mall.productservice.rpc","cn.iocoder.mall.searchservice.rpc", @EnableFeignClients(basePackages = {"cn.iocoder.mall.productservice.rpc","cn.iocoder.mall.searchservice.rpc",
"cn.iocoder.mall.tradeservice.rpc","cn.iocoder.mall.payservice.rpc"}) "cn.iocoder.mall.tradeservice.rpc","cn.iocoder.mall.payservice.rpc","cn.iocoder.mall.promotion.api.rpc"})
public class ShopWebApplication { public class ShopWebApplication {
public static void main(String[] args) { public static void main(String[] args) {

View File

@ -1,15 +1,15 @@
package cn.iocoder.mall.shopweb.service.product; package cn.iocoder.mall.shopweb.service.product;
import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.promotion.api.rpc.activity.PromotionActivityRpc; import cn.iocoder.mall.promotion.api.rpc.activity.PromotionActivityFeign;
import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityListReqDTO; import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityListReqDTO;
import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityRespDTO; import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityRespDTO;
import cn.iocoder.mall.promotion.api.rpc.price.PriceRpc; import cn.iocoder.mall.promotion.api.rpc.price.PriceFeign;
import cn.iocoder.mall.promotion.api.rpc.price.dto.PriceProductCalcReqDTO; import cn.iocoder.mall.promotion.api.rpc.price.dto.PriceProductCalcReqDTO;
import cn.iocoder.mall.promotion.api.rpc.price.dto.PriceProductCalcRespDTO; import cn.iocoder.mall.promotion.api.rpc.price.dto.PriceProductCalcRespDTO;
import cn.iocoder.mall.shopweb.controller.product.vo.sku.ProductSkuCalcPriceRespVO; import cn.iocoder.mall.shopweb.controller.product.vo.sku.ProductSkuCalcPriceRespVO;
import cn.iocoder.mall.shopweb.convert.product.ProductSkuConvert; import cn.iocoder.mall.shopweb.convert.product.ProductSkuConvert;
import org.apache.dubbo.config.annotation.DubboReference; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -23,11 +23,11 @@ import java.util.List;
@Validated @Validated
public class ProductSkuManager { public class ProductSkuManager {
@DubboReference(version = "${dubbo.consumer.PriceRpc.version}")
private PriceRpc priceRpc;
@DubboReference(version = "${dubbo.consumer.PromotionActivityRpc.version}")
private PromotionActivityRpc promotionActivityRpc;
@Autowired
private PriceFeign priceFeign;
@Autowired
private PromotionActivityFeign promotionActivityFeign;
/** /**
* 计算商品 SKU 价格 * 计算商品 SKU 价格
* *
@ -36,7 +36,7 @@ public class ProductSkuManager {
* @return SKU 价格明细 * @return SKU 价格明细
*/ */
public ProductSkuCalcPriceRespVO calcProductSkuPrice(Integer userId, Integer skuId) { public ProductSkuCalcPriceRespVO calcProductSkuPrice(Integer userId, Integer skuId) {
CommonResult<PriceProductCalcRespDTO> calcProductPriceResult = priceRpc.calcProductPrice(new PriceProductCalcReqDTO().setUserId(userId) CommonResult<PriceProductCalcRespDTO> calcProductPriceResult = priceFeign.calcProductPrice(new PriceProductCalcReqDTO().setUserId(userId)
.setItems(Collections.singletonList(new PriceProductCalcReqDTO.Item(skuId, 1, true)))); .setItems(Collections.singletonList(new PriceProductCalcReqDTO.Item(skuId, 1, true))));
calcProductPriceResult.checkError(); calcProductPriceResult.checkError();
// 拼接结果 // 拼接结果
@ -51,7 +51,7 @@ public class ProductSkuManager {
} }
private PromotionActivityRespDTO getPromotionActivity(Integer activityId) { private PromotionActivityRespDTO getPromotionActivity(Integer activityId) {
CommonResult<List<PromotionActivityRespDTO>> listPromotionActivitiesResult = promotionActivityRpc.listPromotionActivities( CommonResult<List<PromotionActivityRespDTO>> listPromotionActivitiesResult = promotionActivityFeign.listPromotionActivities(
new PromotionActivityListReqDTO().setActiveIds(Collections.singleton(activityId))); new PromotionActivityListReqDTO().setActiveIds(Collections.singleton(activityId)));
listPromotionActivitiesResult.checkError(); listPromotionActivitiesResult.checkError();
return listPromotionActivitiesResult.getData().get(0); return listPromotionActivitiesResult.getData().get(0);

View File

@ -2,12 +2,12 @@ package cn.iocoder.mall.shopweb.service.promotion;
import cn.iocoder.common.framework.enums.CommonStatusEnum; import cn.iocoder.common.framework.enums.CommonStatusEnum;
import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.promotion.api.rpc.banner.BannerRpc; import cn.iocoder.mall.promotion.api.rpc.banner.BannerFeign;
import cn.iocoder.mall.promotion.api.rpc.banner.dto.BannerListReqDTO; import cn.iocoder.mall.promotion.api.rpc.banner.dto.BannerListReqDTO;
import cn.iocoder.mall.promotion.api.rpc.banner.dto.BannerRespDTO; import cn.iocoder.mall.promotion.api.rpc.banner.dto.BannerRespDTO;
import cn.iocoder.mall.shopweb.controller.promotion.vo.brand.BannerRespVO; import cn.iocoder.mall.shopweb.controller.promotion.vo.brand.BannerRespVO;
import cn.iocoder.mall.shopweb.convert.promotion.BannerConvert; import cn.iocoder.mall.shopweb.convert.promotion.BannerConvert;
import org.apache.dubbo.config.annotation.DubboReference; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -20,13 +20,11 @@ import java.util.List;
@Service @Service
@Validated @Validated
public class BannerManager { public class BannerManager {
@Autowired
@DubboReference(version = "${dubbo.consumer.BannerRpc.version}") private BannerFeign bannerFeign;
private BannerRpc bannerRpc;
public List<BannerRespVO> listBanners() { public List<BannerRespVO> listBanners() {
// 获取 Banner 列表 // 获取 Banner 列表
CommonResult<List<BannerRespDTO>> listBannersResult = bannerRpc.listBanners( CommonResult<List<BannerRespDTO>> listBannersResult = bannerFeign.listBanners(
new BannerListReqDTO().setStatus(CommonStatusEnum.ENABLE.getValue())); new BannerListReqDTO().setStatus(CommonStatusEnum.ENABLE.getValue()));
listBannersResult.checkError(); listBannersResult.checkError();
// 排序返回 // 排序返回

View File

@ -2,13 +2,13 @@ package cn.iocoder.mall.shopweb.service.promotion;
import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.common.framework.vo.PageResult; import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.promotion.api.rpc.coupon.CouponCardRpc; import cn.iocoder.mall.promotion.api.rpc.coupon.CouponCardFeign;
import cn.iocoder.mall.promotion.api.rpc.coupon.dto.card.CouponCardCreateReqDTO; import cn.iocoder.mall.promotion.api.rpc.coupon.dto.card.CouponCardCreateReqDTO;
import cn.iocoder.mall.promotion.api.rpc.coupon.dto.card.CouponCardRespDTO; import cn.iocoder.mall.promotion.api.rpc.coupon.dto.card.CouponCardRespDTO;
import cn.iocoder.mall.shopweb.controller.promotion.vo.coupon.card.CouponCardPageReqVO; import cn.iocoder.mall.shopweb.controller.promotion.vo.coupon.card.CouponCardPageReqVO;
import cn.iocoder.mall.shopweb.controller.promotion.vo.coupon.card.CouponCardRespVO; import cn.iocoder.mall.shopweb.controller.promotion.vo.coupon.card.CouponCardRespVO;
import cn.iocoder.mall.shopweb.convert.promotion.CouponCardConvert; import cn.iocoder.mall.shopweb.convert.promotion.CouponCardConvert;
import org.apache.dubbo.config.annotation.DubboReference; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
/** /**
@ -17,9 +17,8 @@ import org.springframework.stereotype.Service;
@Service @Service
public class CouponCardManager { public class CouponCardManager {
@DubboReference(version = "${dubbo.consumer.CouponCardRpc.version}") @Autowired
private CouponCardRpc couponCardRpc; private CouponCardFeign couponCardFeign;
/** /**
* 获得优惠劵分页 * 获得优惠劵分页
* *
@ -28,7 +27,7 @@ public class CouponCardManager {
* @return 优惠劵分页结果 * @return 优惠劵分页结果
*/ */
public PageResult<CouponCardRespVO> pageCouponCard(Integer userId, CouponCardPageReqVO pageVO) { public PageResult<CouponCardRespVO> pageCouponCard(Integer userId, CouponCardPageReqVO pageVO) {
CommonResult<PageResult<CouponCardRespDTO>> pageCouponCardResult = couponCardRpc.pageCouponCard( CommonResult<PageResult<CouponCardRespDTO>> pageCouponCardResult = couponCardFeign.pageCouponCard(
CouponCardConvert.INSTANCE.convert(pageVO).setUserId(userId)); CouponCardConvert.INSTANCE.convert(pageVO).setUserId(userId));
pageCouponCardResult.checkError(); pageCouponCardResult.checkError();
return CouponCardConvert.INSTANCE.convertPage(pageCouponCardResult.getData()); return CouponCardConvert.INSTANCE.convertPage(pageCouponCardResult.getData());
@ -42,7 +41,7 @@ public class CouponCardManager {
* @return 优惠劵编号 * @return 优惠劵编号
*/ */
public Integer createCouponCard(Integer userId, Integer couponTemplateId) { public Integer createCouponCard(Integer userId, Integer couponTemplateId) {
CommonResult<Integer> createCouponCardResult = couponCardRpc.createCouponCard( CommonResult<Integer> createCouponCardResult = couponCardFeign.createCouponCard(
new CouponCardCreateReqDTO().setUserId(userId).setCouponTemplateId(couponTemplateId)); new CouponCardCreateReqDTO().setUserId(userId).setCouponTemplateId(couponTemplateId));
createCouponCardResult.checkError(); createCouponCardResult.checkError();
return createCouponCardResult.getData(); return createCouponCardResult.getData();

View File

@ -1,11 +1,11 @@
package cn.iocoder.mall.shopweb.service.promotion; package cn.iocoder.mall.shopweb.service.promotion;
import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.promotion.api.rpc.coupon.CouponTemplateRpc; import cn.iocoder.mall.promotion.api.rpc.coupon.CouponTemplateFeign;
import cn.iocoder.mall.promotion.api.rpc.coupon.dto.template.CouponTemplateRespDTO; import cn.iocoder.mall.promotion.api.rpc.coupon.dto.template.CouponTemplateRespDTO;
import cn.iocoder.mall.shopweb.controller.promotion.vo.coupon.template.CouponTemplateRespVO; import cn.iocoder.mall.shopweb.controller.promotion.vo.coupon.template.CouponTemplateRespVO;
import cn.iocoder.mall.shopweb.convert.promotion.CouponTemplateConvert; import cn.iocoder.mall.shopweb.convert.promotion.CouponTemplateConvert;
import org.apache.dubbo.config.annotation.DubboReference; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
/** /**
@ -13,12 +13,10 @@ import org.springframework.stereotype.Service;
*/ */
@Service @Service
public class CouponTemplateManager { public class CouponTemplateManager {
@Autowired
@DubboReference(version = "${dubbo.consumer.CouponTemplateRpc.version}") private CouponTemplateFeign couponTemplateFeign;
private CouponTemplateRpc couponTemplateRpc;
public CouponTemplateRespVO getCouponTemplate(Integer id) { public CouponTemplateRespVO getCouponTemplate(Integer id) {
CommonResult<CouponTemplateRespDTO> getCouponTemplateResult = couponTemplateRpc.getCouponTemplate(id); CommonResult<CouponTemplateRespDTO> getCouponTemplateResult = couponTemplateFeign.getCouponTemplate(id);
getCouponTemplateResult.checkError(); getCouponTemplateResult.checkError();
return CouponTemplateConvert.INSTANCE.convert(getCouponTemplateResult.getData()); return CouponTemplateConvert.INSTANCE.convert(getCouponTemplateResult.getData());
} }

View File

@ -5,14 +5,13 @@ import cn.iocoder.common.framework.util.CollectionUtils;
import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.productservice.rpc.spu.ProductSpuFeign; import cn.iocoder.mall.productservice.rpc.spu.ProductSpuFeign;
import cn.iocoder.mall.productservice.rpc.spu.dto.ProductSpuRespDTO; import cn.iocoder.mall.productservice.rpc.spu.dto.ProductSpuRespDTO;
import cn.iocoder.mall.promotion.api.rpc.recommend.ProductRecommendRpc; import cn.iocoder.mall.promotion.api.rpc.recommend.ProductRecommendFeign;
import cn.iocoder.mall.promotion.api.rpc.recommend.dto.ProductRecommendListReqDTO; import cn.iocoder.mall.promotion.api.rpc.recommend.dto.ProductRecommendListReqDTO;
import cn.iocoder.mall.promotion.api.rpc.recommend.dto.ProductRecommendRespDTO; import cn.iocoder.mall.promotion.api.rpc.recommend.dto.ProductRecommendRespDTO;
import cn.iocoder.mall.shopweb.controller.product.vo.product.ProductSpuRespVO; import cn.iocoder.mall.shopweb.controller.product.vo.product.ProductSpuRespVO;
import cn.iocoder.mall.shopweb.convert.promotion.ProductRecommendConvert; import cn.iocoder.mall.shopweb.convert.promotion.ProductRecommendConvert;
import com.google.common.collect.HashMultimap; import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap; import com.google.common.collect.Multimap;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -28,15 +27,14 @@ import java.util.Map;
@Service @Service
@Validated @Validated
public class ProductRecommendManager { public class ProductRecommendManager {
@Autowired
@DubboReference(version = "${dubbo.consumer.ProductRecommendRpc.version}") private ProductRecommendFeign productRecommendFeign;
private ProductRecommendRpc productRecommendRpc;
@Autowired @Autowired
private ProductSpuFeign productSpuFeign; private ProductSpuFeign productSpuFeign;
public Map<Integer, Collection<ProductSpuRespVO>> listProductRecommends() { public Map<Integer, Collection<ProductSpuRespVO>> listProductRecommends() {
// 查询商品推荐列表 // 查询商品推荐列表
CommonResult<List<ProductRecommendRespDTO>> listProductRecommendsResult = productRecommendRpc.listProductRecommends( CommonResult<List<ProductRecommendRespDTO>> listProductRecommendsResult = productRecommendFeign.listProductRecommends(
new ProductRecommendListReqDTO().setStatus(CommonStatusEnum.ENABLE.getValue())); new ProductRecommendListReqDTO().setStatus(CommonStatusEnum.ENABLE.getValue()));
listProductRecommendsResult.checkError(); listProductRecommendsResult.checkError();
listProductRecommendsResult.getData().sort(Comparator.comparing(ProductRecommendRespDTO::getSort)); // 排序按照 sort 升序 listProductRecommendsResult.getData().sort(Comparator.comparing(ProductRecommendRespDTO::getSort)); // 排序按照 sort 升序

View File

@ -6,17 +6,16 @@ import cn.iocoder.mall.productservice.enums.sku.ProductSkuDetailFieldEnum;
import cn.iocoder.mall.productservice.rpc.sku.ProductSkuFeign; import cn.iocoder.mall.productservice.rpc.sku.ProductSkuFeign;
import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuListQueryReqDTO; import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuListQueryReqDTO;
import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuRespDTO; import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuRespDTO;
import cn.iocoder.mall.promotion.api.rpc.activity.PromotionActivityRpc; import cn.iocoder.mall.promotion.api.rpc.activity.PromotionActivityFeign;
import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityListReqDTO; import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityListReqDTO;
import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityRespDTO; import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityRespDTO;
import cn.iocoder.mall.promotion.api.rpc.price.PriceRpc; import cn.iocoder.mall.promotion.api.rpc.price.PriceFeign;
import cn.iocoder.mall.promotion.api.rpc.price.dto.PriceProductCalcReqDTO; import cn.iocoder.mall.promotion.api.rpc.price.dto.PriceProductCalcReqDTO;
import cn.iocoder.mall.promotion.api.rpc.price.dto.PriceProductCalcRespDTO; import cn.iocoder.mall.promotion.api.rpc.price.dto.PriceProductCalcRespDTO;
import cn.iocoder.mall.shopweb.controller.trade.vo.cart.CartDetailVO; import cn.iocoder.mall.shopweb.controller.trade.vo.cart.CartDetailVO;
import cn.iocoder.mall.shopweb.convert.trade.CartConvert; import cn.iocoder.mall.shopweb.convert.trade.CartConvert;
import cn.iocoder.mall.tradeservice.rpc.cart.CartFeign; import cn.iocoder.mall.tradeservice.rpc.cart.CartFeign;
import cn.iocoder.mall.tradeservice.rpc.cart.dto.*; import cn.iocoder.mall.tradeservice.rpc.cart.dto.*;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -31,10 +30,11 @@ public class CartManager {
@Autowired @Autowired
private CartFeign cartFeign; private CartFeign cartFeign;
@DubboReference(version = "${dubbo.consumer.PriceRpc.version}") @Autowired
private PriceRpc priceRpc; private PriceFeign priceFeign;
@DubboReference(version = "${dubbo.consumer.PromotionActivityRpc.version}")
private PromotionActivityRpc promotionActivityRpc; @Autowired
private PromotionActivityFeign promotionActivityFeign;
@Autowired @Autowired
private ProductSkuFeign productSkuFeign; private ProductSkuFeign productSkuFeign;
@ -107,7 +107,7 @@ public class CartManager {
return result; return result;
} }
// 计算商品价格 // 计算商品价格
CommonResult<PriceProductCalcRespDTO> calcProductPriceResult = priceRpc.calcProductPrice(new PriceProductCalcReqDTO().setUserId(userId) CommonResult<PriceProductCalcRespDTO> calcProductPriceResult = priceFeign.calcProductPrice(new PriceProductCalcReqDTO().setUserId(userId)
.setItems(listCartItemsResult.getData().stream() .setItems(listCartItemsResult.getData().stream()
.map(cartItem -> new PriceProductCalcReqDTO.Item(cartItem.getSkuId(), cartItem.getQuantity(), cartItem.getSelected())) .map(cartItem -> new PriceProductCalcReqDTO.Item(cartItem.getSkuId(), cartItem.getQuantity(), cartItem.getSelected()))
.collect(Collectors.toList()))); .collect(Collectors.toList())));
@ -154,7 +154,7 @@ public class CartManager {
} }
// 查询促销活动列表 // 查询促销活动列表
CommonResult<List<PromotionActivityRespDTO>> listPromotionActivitiesResult = CommonResult<List<PromotionActivityRespDTO>> listPromotionActivitiesResult =
promotionActivityRpc.listPromotionActivities(new PromotionActivityListReqDTO().setActiveIds(activeIds)); promotionActivityFeign.listPromotionActivities(new PromotionActivityListReqDTO().setActiveIds(activeIds));
listPromotionActivitiesResult.checkError(); listPromotionActivitiesResult.checkError();
return CollectionUtils.convertMap(listPromotionActivitiesResult.getData(), PromotionActivityRespDTO::getId); return CollectionUtils.convertMap(listPromotionActivitiesResult.getData(), PromotionActivityRespDTO::getId);
} }

View File

@ -9,13 +9,13 @@ import cn.iocoder.mall.productservice.enums.sku.ProductSkuDetailFieldEnum;
import cn.iocoder.mall.productservice.rpc.sku.ProductSkuFeign; import cn.iocoder.mall.productservice.rpc.sku.ProductSkuFeign;
import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuListQueryReqDTO; import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuListQueryReqDTO;
import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuRespDTO; import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuRespDTO;
import cn.iocoder.mall.promotion.api.rpc.activity.PromotionActivityRpc; import cn.iocoder.mall.promotion.api.rpc.activity.PromotionActivityFeign;
import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityListReqDTO; import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityListReqDTO;
import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityRespDTO; import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityRespDTO;
import cn.iocoder.mall.promotion.api.rpc.coupon.CouponCardRpc; import cn.iocoder.mall.promotion.api.rpc.coupon.CouponCardFeign;
import cn.iocoder.mall.promotion.api.rpc.coupon.dto.card.CouponCardAvailableListReqDTO; import cn.iocoder.mall.promotion.api.rpc.coupon.dto.card.CouponCardAvailableListReqDTO;
import cn.iocoder.mall.promotion.api.rpc.coupon.dto.card.CouponCardAvailableRespDTO; import cn.iocoder.mall.promotion.api.rpc.coupon.dto.card.CouponCardAvailableRespDTO;
import cn.iocoder.mall.promotion.api.rpc.price.PriceRpc; import cn.iocoder.mall.promotion.api.rpc.price.PriceFeign;
import cn.iocoder.mall.promotion.api.rpc.price.dto.PriceProductCalcReqDTO; import cn.iocoder.mall.promotion.api.rpc.price.dto.PriceProductCalcReqDTO;
import cn.iocoder.mall.promotion.api.rpc.price.dto.PriceProductCalcRespDTO; import cn.iocoder.mall.promotion.api.rpc.price.dto.PriceProductCalcRespDTO;
import cn.iocoder.mall.shopweb.client.trade.TradeOrderClient; import cn.iocoder.mall.shopweb.client.trade.TradeOrderClient;
@ -31,7 +31,6 @@ import cn.iocoder.mall.tradeservice.rpc.cart.dto.CartItemListReqDTO;
import cn.iocoder.mall.tradeservice.rpc.cart.dto.CartItemRespDTO; import cn.iocoder.mall.tradeservice.rpc.cart.dto.CartItemRespDTO;
import cn.iocoder.mall.tradeservice.rpc.order.dto.TradeOrderPageReqDTO; import cn.iocoder.mall.tradeservice.rpc.order.dto.TradeOrderPageReqDTO;
import cn.iocoder.mall.tradeservice.rpc.order.dto.TradeOrderRespDTO; import cn.iocoder.mall.tradeservice.rpc.order.dto.TradeOrderRespDTO;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -49,15 +48,15 @@ import static cn.iocoder.mall.shopweb.enums.ShopWebErrorCodeConstants.ORDER_PROD
@Validated @Validated
public class TradeOrderService { public class TradeOrderService {
@DubboReference(version = "${dubbo.consumer.PriceRpc.version}") @Autowired
private PriceRpc priceRpc; private PriceFeign priceFeign;
@DubboReference(version = "${dubbo.consumer.PromotionActivityRpc.version}") @Autowired
private PromotionActivityRpc promotionActivityRpc; private PromotionActivityFeign promotionActivityFeign;
@Autowired @Autowired
private CartFeign cartFeign; private CartFeign cartFeign;
private CouponCardRpc couponCardRpc; @Autowired
private CouponCardFeign couponCardFeign;
@Autowired @Autowired
private ProductSkuFeign productSkuFeign; private ProductSkuFeign productSkuFeign;
@ -94,7 +93,7 @@ public class TradeOrderService {
// 获得商品 SKU 信息 // 获得商品 SKU 信息
Map<Integer, ProductSkuRespDTO> productSkuMap = this.checkProductSkus(skuMap); Map<Integer, ProductSkuRespDTO> productSkuMap = this.checkProductSkus(skuMap);
// 计算商品价格 // 计算商品价格
CommonResult<PriceProductCalcRespDTO> calcProductPriceResult = priceRpc.calcProductPrice(new PriceProductCalcReqDTO() CommonResult<PriceProductCalcRespDTO> calcProductPriceResult = priceFeign.calcProductPrice(new PriceProductCalcReqDTO()
.setUserId(userId).setCouponCardId(couponCardId) .setUserId(userId).setCouponCardId(couponCardId)
.setItems(skuMap.entrySet().stream().map(entry -> new PriceProductCalcReqDTO.Item(entry.getKey(), entry.getValue(), true)) .setItems(skuMap.entrySet().stream().map(entry -> new PriceProductCalcReqDTO.Item(entry.getKey(), entry.getValue(), true))
.collect(Collectors.toList()))); .collect(Collectors.toList())));
@ -119,7 +118,7 @@ public class TradeOrderService {
productSkuMap.get(item.getSkuId()), promotionActivityMap.get(item.getActivityId())))); productSkuMap.get(item.getSkuId()), promotionActivityMap.get(item.getActivityId()))));
} }
// 查询可用优惠劵信息 // 查询可用优惠劵信息
CommonResult<List<CouponCardAvailableRespDTO>> listAvailableCouponCardsResult = couponCardRpc.listAvailableCouponCards( CommonResult<List<CouponCardAvailableRespDTO>> listAvailableCouponCardsResult = couponCardFeign.listAvailableCouponCards(
new CouponCardAvailableListReqDTO().setUserId(userId) new CouponCardAvailableListReqDTO().setUserId(userId)
.setItems(TradeOrderConvert.INSTANCE.convertList(calcProductPriceResult.getData().getItemGroups()))); .setItems(TradeOrderConvert.INSTANCE.convertList(calcProductPriceResult.getData().getItemGroups())));
listAvailableCouponCardsResult.checkError(); listAvailableCouponCardsResult.checkError();
@ -165,7 +164,7 @@ public class TradeOrderService {
} }
// 查询促销活动列表 // 查询促销活动列表
CommonResult<List<PromotionActivityRespDTO>> listPromotionActivitiesResult = CommonResult<List<PromotionActivityRespDTO>> listPromotionActivitiesResult =
promotionActivityRpc.listPromotionActivities(new PromotionActivityListReqDTO().setActiveIds(activeIds)); promotionActivityFeign.listPromotionActivities(new PromotionActivityListReqDTO().setActiveIds(activeIds));
listPromotionActivitiesResult.checkError(); listPromotionActivitiesResult.checkError();
return CollectionUtils.convertMap(listPromotionActivitiesResult.getData(), PromotionActivityRespDTO::getId); return CollectionUtils.convertMap(listPromotionActivitiesResult.getData(), PromotionActivityRespDTO::getId);
} }

View File

@ -7,7 +7,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
@SpringBootApplication @SpringBootApplication
@EnableDiscoveryClient @EnableDiscoveryClient
@EnableFeignClients(basePackages = {"cn.iocoder.mall.productservice.rpc"}) @EnableFeignClients(basePackages = {"cn.iocoder.mall.productservice.rpc","cn.iocoder.mall.promotion.api.rpc"})
public class TradeServiceApplication { public class TradeServiceApplication {
public static void main(String[] args) { public static void main(String[] args) {

View File

@ -1,19 +1,18 @@
package cn.iocoder.mall.tradeservice.client.promotion; package cn.iocoder.mall.tradeservice.client.promotion;
import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.promotion.api.rpc.coupon.CouponCardRpc; import cn.iocoder.mall.promotion.api.rpc.coupon.CouponCardFeign;
import cn.iocoder.mall.promotion.api.rpc.coupon.dto.card.CouponCardUseReqDTO; import cn.iocoder.mall.promotion.api.rpc.coupon.dto.card.CouponCardUseReqDTO;
import org.apache.dubbo.config.annotation.DubboReference; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@Service @Service
public class CouponCardClient { public class CouponCardClient {
@DubboReference(version = "${dubbo.consumer.CouponCardRpc.version}") @Autowired
private CouponCardRpc couponCardRpc; private CouponCardFeign couponCardFeign;
public void useCouponCard(Integer userId, Integer couponCardId) { public void useCouponCard(Integer userId, Integer couponCardId) {
CommonResult<Boolean> useCouponCardResult = couponCardRpc.useCouponCard(new CouponCardUseReqDTO() CommonResult<Boolean> useCouponCardResult = couponCardFeign.useCouponCard(new CouponCardUseReqDTO()
.setUserId(userId).setCouponCardId(couponCardId)); .setUserId(userId).setCouponCardId(couponCardId));
useCouponCardResult.checkError(); useCouponCardResult.checkError();
} }

View File

@ -1,10 +1,10 @@
package cn.iocoder.mall.tradeservice.client.promotion; package cn.iocoder.mall.tradeservice.client.promotion;
import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.promotion.api.rpc.price.PriceRpc; import cn.iocoder.mall.promotion.api.rpc.price.PriceFeign;
import cn.iocoder.mall.promotion.api.rpc.price.dto.PriceProductCalcReqDTO; import cn.iocoder.mall.promotion.api.rpc.price.dto.PriceProductCalcReqDTO;
import cn.iocoder.mall.promotion.api.rpc.price.dto.PriceProductCalcRespDTO; import cn.iocoder.mall.promotion.api.rpc.price.dto.PriceProductCalcRespDTO;
import org.apache.dubbo.config.annotation.DubboReference; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
@ -12,9 +12,8 @@ import java.util.List;
@Service @Service
public class PriceClient { public class PriceClient {
@DubboReference(version = "${dubbo.consumer.PriceRpc.version}") @Autowired
private PriceRpc priceRpc; private PriceFeign priceFeign;
/** /**
* 计算商品们的价格 * 计算商品们的价格
* *
@ -25,7 +24,7 @@ public class PriceClient {
*/ */
public PriceProductCalcRespDTO calcProductPrice(Integer userId, List<PriceProductCalcReqDTO.Item> items, public PriceProductCalcRespDTO calcProductPrice(Integer userId, List<PriceProductCalcReqDTO.Item> items,
Integer couponCardId) { Integer couponCardId) {
CommonResult<PriceProductCalcRespDTO> calcProductPriceResult = priceRpc.calcProductPrice( CommonResult<PriceProductCalcRespDTO> calcProductPriceResult = priceFeign.calcProductPrice(
new PriceProductCalcReqDTO().setUserId(userId).setItems(items).setCouponCardId(couponCardId)); new PriceProductCalcReqDTO().setUserId(userId).setItems(items).setCouponCardId(couponCardId));
calcProductPriceResult.checkError(); calcProductPriceResult.checkError();
return calcProductPriceResult.getData(); return calcProductPriceResult.getData();