优惠改造
This commit is contained in:
@@ -7,7 +7,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
|
||||
@SpringBootApplication
|
||||
@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 static void main(String[] args) {
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
package cn.iocoder.mall.tradeservice.client.promotion;
|
||||
|
||||
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 org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class CouponCardClient {
|
||||
|
||||
@DubboReference(version = "${dubbo.consumer.CouponCardRpc.version}")
|
||||
private CouponCardRpc couponCardRpc;
|
||||
|
||||
@Autowired
|
||||
private CouponCardFeign couponCardFeign;
|
||||
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));
|
||||
useCouponCardResult.checkError();
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package cn.iocoder.mall.tradeservice.client.promotion;
|
||||
|
||||
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.PriceProductCalcRespDTO;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
@@ -12,9 +12,8 @@ import java.util.List;
|
||||
@Service
|
||||
public class PriceClient {
|
||||
|
||||
@DubboReference(version = "${dubbo.consumer.PriceRpc.version}")
|
||||
private PriceRpc priceRpc;
|
||||
|
||||
@Autowired
|
||||
private PriceFeign priceFeign;
|
||||
/**
|
||||
* 计算商品们的价格
|
||||
*
|
||||
@@ -25,7 +24,7 @@ public class PriceClient {
|
||||
*/
|
||||
public PriceProductCalcRespDTO calcProductPrice(Integer userId, List<PriceProductCalcReqDTO.Item> items,
|
||||
Integer couponCardId) {
|
||||
CommonResult<PriceProductCalcRespDTO> calcProductPriceResult = priceRpc.calcProductPrice(
|
||||
CommonResult<PriceProductCalcRespDTO> calcProductPriceResult = priceFeign.calcProductPrice(
|
||||
new PriceProductCalcReqDTO().setUserId(userId).setItems(items).setCouponCardId(couponCardId));
|
||||
calcProductPriceResult.checkError();
|
||||
return calcProductPriceResult.getData();
|
||||
|
||||
Reference in New Issue
Block a user