优惠劵相关逻辑的迁移
This commit is contained in:
@@ -1,72 +0,0 @@
|
||||
package cn.iocoder.mall.order.rest.controller.cart;
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("users/cart")
|
||||
public class UsersCartController {
|
||||
|
||||
// @Reference(validation = "true", version = "${dubbo.provider.CartService.version}")
|
||||
// private CartService cartService;
|
||||
//
|
||||
// @Reference(validation = "true", version = "${dubbo.provider.OrderService.version}")
|
||||
// private OrderService orderService;
|
||||
//
|
||||
// @Reference(validation = "true", version = "${dubbo.consumer.CouponService.version}")
|
||||
// private CouponService couponService;
|
||||
//
|
||||
|
||||
|
||||
|
||||
//
|
||||
// @GetMapping("/confirm_create_order")
|
||||
// public CommonResult<UsersOrderConfirmCreateVO> getConfirmCreateOrder(@RequestParam(value = "couponCardId", required = false) Integer couponCardId) {
|
||||
// Integer userId = UserSecurityContextHolder.getContext().getUserId();
|
||||
// // 获得购物车中选中的
|
||||
// List<CartItemBO> cartItems = cartService.list(userId, true);
|
||||
// // 购物车为空时,构造空的 UsersOrderConfirmCreateVO 返回
|
||||
// if (cartItems.isEmpty()) {
|
||||
// UsersOrderConfirmCreateVO result = new UsersOrderConfirmCreateVO();
|
||||
// result.setItemGroups(Collections.emptyList());
|
||||
// result.setFee(new UsersOrderConfirmCreateVO.Fee(0, 0, 0, 0));
|
||||
// return success(result);
|
||||
// }
|
||||
// // 计算商品价格
|
||||
// CalcOrderPriceBO calcOrderPrice = list0(cartItems, couponCardId);
|
||||
// // 获得优惠劵
|
||||
// List<CouponCardAvailableBO> couponCards = couponService.getCouponCardList(userId,
|
||||
// CartConvert.INSTANCE.convertList(calcOrderPrice.getItemGroups()));
|
||||
// // 执行数据拼装
|
||||
// return success(CartConvert.INSTANCE.convert(calcOrderPrice).setCouponCards(couponCards));
|
||||
// }
|
||||
//
|
||||
// private CalcOrderPriceBO list0(List<CartItemBO> cartItems, Integer couponCardId) {
|
||||
// // 创建计算的 DTO
|
||||
// CalcOrderPriceDTO calcOrderPriceDTO = new CalcOrderPriceDTO()
|
||||
// .setUserId(UserSecurityContextHolder.getContext().getUserId())
|
||||
// .setItems(new ArrayList<>(cartItems.size()))
|
||||
// .setCouponCardId(couponCardId);
|
||||
// for (CartItemBO item : cartItems) {
|
||||
// calcOrderPriceDTO.getItems().add(new CalcOrderPriceDTO.Item(item.getSkuId(), item.getQuantity(), item.getSelected()));
|
||||
// }
|
||||
// // 执行计算
|
||||
// return cartService.calcOrderPrice(calcOrderPriceDTO);
|
||||
// }
|
||||
//
|
||||
// @GetMapping("/calc_sku_price")
|
||||
// public CommonResult<UsersCalcSkuPriceVO> calcSkuPrice(@RequestParam("skuId") Integer skuId) {
|
||||
// // 计算 sku 的价格
|
||||
// CalcSkuPriceBO calcSkuPrice = cartService.calcSkuPrice(skuId);
|
||||
// return success(CartConvert.INSTANCE.convert2(calcSkuPrice));
|
||||
// }
|
||||
//
|
||||
// public CommonResult<Object> confirmOrder() {
|
||||
// // 查询购物车列表(选中的)
|
||||
//// cartService.list(userId, true);
|
||||
// // 查询确认订单信息的明细
|
||||
//
|
||||
// return null;
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -76,25 +76,7 @@ public class UsersOrderController {
|
||||
// return createResult;
|
||||
// }
|
||||
//
|
||||
// @GetMapping("confirm_create_order")
|
||||
// @RequiresLogin
|
||||
// @ApiOperation("确认创建订单")
|
||||
// public CommonResult<UsersOrderConfirmCreateVO> getConfirmCreateOrder(@RequestParam("skuId") Integer skuId,
|
||||
// @RequestParam("quantity") Integer quantity,
|
||||
// @RequestParam(value = "couponCardId", required = false) Integer couponCardId) {
|
||||
// Integer userId = UserSecurityContextHolder.getContext().getUserId();
|
||||
// // 创建 CalcOrderPriceDTO 对象,并执行价格计算
|
||||
// CalcOrderPriceDTO calcOrderPriceDTO = new CalcOrderPriceDTO()
|
||||
// .setUserId(userId)
|
||||
// .setItems(Collections.singletonList(new CalcOrderPriceDTO.Item(skuId, quantity, true)))
|
||||
// .setCouponCardId(couponCardId);
|
||||
// CalcOrderPriceBO calcOrderPrice = cartService.calcOrderPrice(calcOrderPriceDTO);
|
||||
// // 获得优惠劵
|
||||
// List<CouponCardAvailableBO> couponCards = couponService.getCouponCardList(userId,
|
||||
// CartConvert.INSTANCE.convertList(calcOrderPrice.getItemGroups()));
|
||||
// // 执行数据拼装
|
||||
// return success(CartConvert.INSTANCE.convert(calcOrderPrice).setCouponCards(couponCards));
|
||||
// }
|
||||
|
||||
//
|
||||
// @PostMapping("confirm_receiving")
|
||||
// @RequiresLogin
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
package cn.iocoder.mall.order.rest.convert;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface CartConvert {
|
||||
|
||||
CartConvert INSTANCE = Mappers.getMapper(CartConvert.class);
|
||||
|
||||
// UsersOrderConfirmCreateVO convert(CalcOrderPriceBO calcOrderPriceBO);
|
||||
//
|
||||
// UsersCartDetailVO convert2(CalcOrderPriceBO calcOrderPriceBO);
|
||||
//
|
||||
// UsersCalcSkuPriceVO convert2(CalcSkuPriceBO calcSkuPriceBO);
|
||||
//
|
||||
// default List<CouponCardSpuDTO> convertList(List<CalcOrderPriceBO.ItemGroup> itemGroups) {
|
||||
// List<CouponCardSpuDTO> items = new ArrayList<>();
|
||||
// itemGroups.forEach(itemGroup -> items.addAll(itemGroup.getItems().stream().map(
|
||||
// item -> new CouponCardSpuDTO()
|
||||
// .setSpuId(item.getSpu().getId())
|
||||
// .setSkuId(item.getId())
|
||||
// .setCategoryId(item.getSpu().getCid())
|
||||
// .setPrice(item.getBuyPrice())
|
||||
// .setQuantity(item.getBuyQuantity()))
|
||||
// .collect(Collectors.toList())));
|
||||
// return items;
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
package cn.iocoder.mall.order.rest.convert;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* application 订单 convert
|
||||
*
|
||||
* TODO 这种方式 文件名不能一样哈!
|
||||
*
|
||||
* @author Sin
|
||||
* @time 2019-03-24 10:45
|
||||
*/
|
||||
@Mapper
|
||||
public interface OrderConvertAPP {
|
||||
|
||||
OrderConvertAPP INSTANCE = Mappers.getMapper(OrderConvertAPP.class);
|
||||
|
||||
// @Mappings({})
|
||||
// OrderQueryDTO convert(OrderPageQueryPO orderPageQueryVO);
|
||||
//
|
||||
// @Mappings({})
|
||||
// OrderLogisticsUpdateDTO convert(OrderLogisticsPO orderLogisticsVO);
|
||||
//
|
||||
// @Mappings({})
|
||||
// OrderItemUpdateDTO convert(OrderItemUpdatePO orderItemUpdateVO);
|
||||
//
|
||||
// @Mappings({})
|
||||
// OrderCreateDTO convert(OrderCreatePO orderCreatePO);
|
||||
//
|
||||
// @Mappings({})
|
||||
// List<OrderCreateDTO.OrderItem> convert(List<CartItemBO> cartItems);
|
||||
//
|
||||
// default OrderCreateDTO createOrderCreateDTO(Integer userId, Integer userAddressId,
|
||||
// String remark, String ip,
|
||||
// List<CartItemBO> cartItems, Integer couponCardId) {
|
||||
// return new OrderCreateDTO()
|
||||
// .setUserId(userId)
|
||||
// .setUserAddressId(userAddressId)
|
||||
// .setRemark(remark)
|
||||
// .setIp(ip)
|
||||
// .setOrderItems(this.convert(cartItems))
|
||||
// .setCouponCardId(couponCardId);
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package cn.iocoder.mall.order.rest.convert;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* @author Sin
|
||||
* @time 2019-04-05 17:00
|
||||
*/
|
||||
@Mapper
|
||||
public interface OrderDeliveryConvert {
|
||||
|
||||
OrderDeliveryConvert INSTANCE = Mappers.getMapper(OrderDeliveryConvert.class);
|
||||
|
||||
// @Mappings({})
|
||||
// OrderDeliveryDTO convert(OrderDeliverPO orderDeliverPO);
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package cn.iocoder.mall.order.rest.convert;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* 订单退货
|
||||
*
|
||||
* @author Sin
|
||||
* @time 2019-04-25 21:54
|
||||
*/
|
||||
@Mapper
|
||||
public interface OrderReturnConvert {
|
||||
|
||||
OrderReturnConvert INSTANCE = Mappers.getMapper(OrderReturnConvert.class);
|
||||
|
||||
// @Mappings({})
|
||||
// OrderReturnApplyDTO convert(OrderReturnApplyPO orderReturnApplyPO);
|
||||
//
|
||||
// @Mappings({})
|
||||
// OrderReturnQueryDTO convert(OrderReturnQueryPO orderReturnQueryPO);
|
||||
}
|
||||
@@ -1,201 +0,0 @@
|
||||
package cn.iocoder.mall.order.rest.response;
|
||||
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class UsersOrderConfirmCreateResponse {
|
||||
|
||||
/**
|
||||
* 商品分组数组
|
||||
*/
|
||||
private List<ItemGroup> itemGroups;
|
||||
/**
|
||||
* 费用
|
||||
*/
|
||||
private Fee fee;
|
||||
/**
|
||||
* 优惠劵列表 TODO 芋艿,后续改改
|
||||
*/
|
||||
// private List<CouponCardAvailableBO> couponCards;
|
||||
/**
|
||||
* 优惠劵优惠金额
|
||||
*/
|
||||
private Integer couponCardDiscountTotal;
|
||||
/**
|
||||
* 商品分组
|
||||
*
|
||||
* 多个商品,参加同一个活动,从而形成分组。
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public static class ItemGroup {
|
||||
|
||||
/**
|
||||
* 优惠活动
|
||||
*/
|
||||
// TODO 芋艿,目前只会有【满减送】的情况,未来有新的促销方式,可能需要改成数组
|
||||
// TODO 芋艿,后面改成 VO
|
||||
// private PromotionActivityBO activity;
|
||||
/**
|
||||
* 商品数组
|
||||
*/
|
||||
private List<Sku> items;
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public static class Sku {
|
||||
|
||||
// SKU 自带信息
|
||||
/**
|
||||
* sku 编号
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* SPU 信息
|
||||
*/
|
||||
private Spu spu;
|
||||
/**
|
||||
* 图片地址
|
||||
*/
|
||||
private String picURL;
|
||||
/**
|
||||
* 规格值数组
|
||||
*/
|
||||
// private List<ProductAttrAndValuePairBO> attrs; // TODO 后面改下
|
||||
/**
|
||||
* 价格,单位:分
|
||||
*/
|
||||
private Integer price;
|
||||
/**
|
||||
* 库存数量
|
||||
*/
|
||||
private Integer quantity;
|
||||
|
||||
// 非 SKU 自带信息
|
||||
|
||||
/**
|
||||
* 购买数量
|
||||
*/
|
||||
private Integer buyQuantity;
|
||||
/**
|
||||
* 原始单价,单位:分。
|
||||
*/
|
||||
private Integer originPrice;
|
||||
/**
|
||||
* 购买单价,单位:分
|
||||
*/
|
||||
private Integer buyPrice;
|
||||
/**
|
||||
* 最终价格,单位:分。
|
||||
*/
|
||||
private Integer presentPrice;
|
||||
/**
|
||||
* 购买总金额,单位:分
|
||||
*
|
||||
* 用途类似 {@link #presentTotal}
|
||||
*/
|
||||
private Integer buyTotal;
|
||||
/**
|
||||
* 优惠总金额,单位:分。
|
||||
*/
|
||||
private Integer discountTotal;
|
||||
/**
|
||||
* 最终总金额,单位:分。
|
||||
*
|
||||
* 注意,presentPrice * quantity 不一定等于 presentTotal 。
|
||||
* 因为,存在无法整除的情况。
|
||||
* 举个例子,presentPrice = 8.33 ,quantity = 3 的情况,presentTotal 有可能是 24.99 ,也可能是 25 。
|
||||
* 所以,需要存储一个该字段。
|
||||
*/
|
||||
private Integer presentTotal;
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public static class Spu {
|
||||
|
||||
/**
|
||||
* SPU 编号
|
||||
*/
|
||||
private Integer id;
|
||||
|
||||
// ========== 基本信息 =========
|
||||
/**
|
||||
* SPU 名字
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 分类编号
|
||||
*/
|
||||
private Integer cid;
|
||||
/**
|
||||
* 商品主图地址
|
||||
*
|
||||
* 数组,以逗号分隔
|
||||
*
|
||||
* 建议尺寸:800*800像素,你可以拖拽图片调整顺序,最多上传15张
|
||||
*/
|
||||
private List<String> picUrls;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 费用(合计)
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public static class Fee {
|
||||
|
||||
/**
|
||||
* 购买总价
|
||||
*/
|
||||
private Integer buyTotal;
|
||||
/**
|
||||
* 优惠总价
|
||||
*
|
||||
* 注意,满多少元包邮,不算在优惠中。
|
||||
*/
|
||||
private Integer discountTotal;
|
||||
/**
|
||||
* 邮费
|
||||
*/
|
||||
private Integer postageTotal;
|
||||
/**
|
||||
* 最终价格
|
||||
*
|
||||
* 计算公式 = 总价 - 优惠总价 + 邮费
|
||||
*/
|
||||
private Integer presentTotal;
|
||||
|
||||
public Fee() {
|
||||
}
|
||||
|
||||
public Fee(Integer buyTotal, Integer discountTotal, Integer postageTotal, Integer presentTotal) {
|
||||
this.buyTotal = buyTotal;
|
||||
this.discountTotal = discountTotal;
|
||||
this.postageTotal = postageTotal;
|
||||
this.presentTotal = presentTotal;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 邮费信息
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public static class Postage {
|
||||
|
||||
/**
|
||||
* 需要满足多少钱,可以包邮。单位:分
|
||||
*/
|
||||
private Integer threshold;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
# 服务器的配置项
|
||||
server:
|
||||
port: 18088
|
||||
servlet:
|
||||
context-path: /order-api/
|
||||
|
||||
# Swagger 配置项
|
||||
swagger:
|
||||
title: 订单子系统
|
||||
description: 订单子系统
|
||||
version: 1.0.0
|
||||
base-package: cn.iocoder.mall.order.rest.controller
|
||||
@@ -1,17 +0,0 @@
|
||||
package cn.iocoder.mall.order.api;
|
||||
|
||||
import cn.iocoder.mall.order.api.bo.CalcSkuPriceBO;
|
||||
|
||||
public interface CartService {
|
||||
|
||||
/**
|
||||
* 计算指定商品 SKU 的金额,并返回计算结果
|
||||
*
|
||||
* TODO 芋艿,此处只会计算,限时折扣带来的价格变化。
|
||||
*
|
||||
* @param skuId 商品 SKU 编号
|
||||
* @return 计算订单金额结果
|
||||
*/
|
||||
CalcSkuPriceBO calcSkuPrice(Integer skuId);
|
||||
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package cn.iocoder.mall.order.api.bo;
|
||||
|
||||
import cn.iocoder.mall.promotion.api.bo.PromotionActivityBO;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 计算商品 SKU 价格结果 BO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class CalcSkuPriceBO implements Serializable {
|
||||
|
||||
/**
|
||||
* 满减送促销活动
|
||||
*/
|
||||
private PromotionActivityBO fullPrivilege;
|
||||
/**
|
||||
* 限时折扣促销活动
|
||||
*/
|
||||
private PromotionActivityBO timeLimitedDiscount;
|
||||
/**
|
||||
* 原价格,单位:分。
|
||||
*/
|
||||
private Integer originalPrice;
|
||||
/**
|
||||
* 购买价格,单位:分。
|
||||
*/
|
||||
private Integer buyPrice;
|
||||
|
||||
}
|
||||
@@ -1,100 +0,0 @@
|
||||
package cn.iocoder.mall.order.api.bo;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 购物车的商品信息 DO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class CartItemBO {
|
||||
|
||||
// ========= 基础字段 BEGIN =========
|
||||
|
||||
/**
|
||||
* 编号,唯一自增。
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* 状态
|
||||
*
|
||||
* 1-正常
|
||||
* 2-主动删除
|
||||
* 3-下单删除
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 是否选中
|
||||
*/
|
||||
private Boolean selected;
|
||||
|
||||
// ========= 基础字段 END =========
|
||||
|
||||
// ========= 买家信息 BEGIN =========
|
||||
|
||||
/**
|
||||
* 用户编号
|
||||
*/
|
||||
private Integer userId;
|
||||
// /**
|
||||
// * 会话 key
|
||||
// */
|
||||
// private String nobody;
|
||||
|
||||
// ========= 买家信息 END =========
|
||||
|
||||
// ========= 商品信息 BEGIN =========
|
||||
|
||||
/**
|
||||
* 商品 SPU 编号
|
||||
*/
|
||||
private Integer spuId;
|
||||
/**
|
||||
* 商品 SKU 编号
|
||||
*/
|
||||
private Integer skuId;
|
||||
/**
|
||||
* 商品购买数量
|
||||
*/
|
||||
private Integer quantity;
|
||||
|
||||
// TODO 冗余字段
|
||||
|
||||
|
||||
// ========= 商品信息 END =========
|
||||
|
||||
// ========= 交易信息 BEGIN =========
|
||||
|
||||
/**
|
||||
* 订单编号
|
||||
*/
|
||||
private Integer orderId;
|
||||
/**
|
||||
* 订单创建时间
|
||||
*/
|
||||
private Date orderCreateTime;
|
||||
|
||||
// ========= 交易信息 BEGIN =========
|
||||
|
||||
// ========= 优惠信息 BEGIN =========
|
||||
|
||||
// /**
|
||||
// * 商品营销活动编号
|
||||
// */
|
||||
// private Integer activityId;
|
||||
// /**
|
||||
// * 商品营销活动类型
|
||||
// */
|
||||
// private Integer activityType;
|
||||
|
||||
// ========= 优惠信息 END =========
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
package cn.iocoder.mall.order.api.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 计算订单价格 DTO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Deprecated
|
||||
public class CalcOrderPriceDTO {
|
||||
|
||||
@NotNull(message = "用户编号不能为空")
|
||||
private Integer userId;
|
||||
|
||||
/**
|
||||
* 优惠劵编号
|
||||
*/
|
||||
private Integer couponCardId;
|
||||
|
||||
@NotNull(message = "商品数组不能为空")
|
||||
private List<Item> items;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public static class Item {
|
||||
|
||||
/**
|
||||
* SKU 编号
|
||||
*/
|
||||
private Integer skuId;
|
||||
/**
|
||||
* 数量
|
||||
*/
|
||||
private Integer quantity;
|
||||
/**
|
||||
* 是否选中
|
||||
*
|
||||
* 注意下,目前只有在购物车的时候,才可能出现该属性为 false 。其它情况下,都会为 true 为主。
|
||||
*/
|
||||
private Boolean selected;
|
||||
|
||||
public Item() {
|
||||
}
|
||||
|
||||
public Item(Integer skuId, Integer quantity, Boolean selected) {
|
||||
this.skuId = skuId;
|
||||
this.quantity = quantity;
|
||||
this.selected = selected;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package cn.iocoder.mall.order.biz.config;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
@Configuration
|
||||
@MapperScan("cn.iocoder.mall.order.biz.dao") // 扫描对应的 Mapper 接口
|
||||
@EnableTransactionManagement(proxyTargetClass = true) // 启动事务管理。为什么使用 proxyTargetClass 参数,参见 https://blog.csdn.net/huang_550/article/details/76492600
|
||||
public class DatabaseConfiguration {
|
||||
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package cn.iocoder.mall.order.biz.config;
|
||||
|
||||
import org.springframework.boot.context.event.ApplicationReadyEvent;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.event.EventListener;
|
||||
|
||||
@Configuration
|
||||
public class ServiceExceptionConfiguration {
|
||||
|
||||
@EventListener(ApplicationReadyEvent.class) // 可参考 https://www.cnblogs.com/ssslinppp/p/7607509.html
|
||||
public void initMessages() {
|
||||
// 从 service_exception_message.properties 加载错误码的方案
|
||||
// Properties properties;
|
||||
// try {
|
||||
// properties = PropertiesLoaderUtils.loadAllProperties("classpath:service_exception_message.properties");
|
||||
// } catch (IOException e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
} // TODO FROM 芋艿 to 小范,这里记得配置下,不然错误提示不出去呀。
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package cn.iocoder.mall.order.biz.convert;
|
||||
|
||||
import cn.iocoder.mall.order.api.bo.CalcOrderPriceBO;
|
||||
import cn.iocoder.mall.order.api.bo.CartItemBO;
|
||||
import cn.iocoder.mall.order.biz.dataobject.CartItemDO;
|
||||
import cn.iocoder.mall.product.api.bo.ProductSkuDetailBO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface CartConvert {
|
||||
|
||||
CartConvert INSTANCE = Mappers.getMapper(CartConvert.class);
|
||||
|
||||
CalcOrderPriceBO.Item convert(ProductSkuDetailBO sku);
|
||||
|
||||
List<CartItemBO> convert(List<CartItemDO> items);
|
||||
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
package cn.iocoder.mall.order.biz.service;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 购物车服务 Service 实现类
|
||||
*/
|
||||
@Service
|
||||
@org.apache.dubbo.config.annotation.Service(validation = "true", version = "${dubbo.provider.CartService.version}")
|
||||
public class CartServiceImpl {
|
||||
|
||||
|
||||
// @Override
|
||||
// @SuppressWarnings("Duplicates")
|
||||
// public CalcSkuPriceBO calcSkuPrice(Integer skuId) {
|
||||
// // 查询 SKU 是否合法
|
||||
// ProductSkuBO sku = productSpuService.getProductSku(skuId);
|
||||
// if (sku == null
|
||||
// || CommonStatusEnum.DISABLE.getValue().equals(sku.getStatus())) { // sku 被禁用
|
||||
// throw ServiceExceptionUtil.exception(OrderErrorCodeEnum.CARD_ITEM_SKU_NOT_FOUND.getCode());
|
||||
// }
|
||||
// // 查询促销活动
|
||||
// List<PromotionActivityBO> activityList = promotionActivityService.getPromotionActivityListBySpuId(sku.getSpuId(),
|
||||
// Arrays.asList(PromotionActivityStatusEnum.WAIT.getValue(), PromotionActivityStatusEnum.RUN.getValue()));
|
||||
// if (activityList.isEmpty()) { // 如果无促销活动,则直接返回默认结果即可
|
||||
// return new CalcSkuPriceBO().setOriginalPrice(sku.getPrice()).setBuyPrice(sku.getPrice());
|
||||
// }
|
||||
// // 如果有促销活动,则开始做计算 TODO 芋艿,因为现在暂时只有限时折扣 + 满减送。所以写的比较简单先
|
||||
// PromotionActivityBO fullPrivilege = findPromotionActivityByType(activityList, PromotionActivityTypeEnum.FULL_PRIVILEGE);
|
||||
// PromotionActivityBO timeLimitedDiscount = findPromotionActivityByType(activityList, PromotionActivityTypeEnum.TIME_LIMITED_DISCOUNT);
|
||||
// Integer presentPrice = calcSkuPriceByTimeLimitDiscount(sku, timeLimitedDiscount);
|
||||
// // 返回结果
|
||||
// return new CalcSkuPriceBO().setFullPrivilege(fullPrivilege).setTimeLimitedDiscount(timeLimitedDiscount)
|
||||
// .setOriginalPrice(sku.getPrice()).setBuyPrice(presentPrice);
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// private PromotionActivityBO findPromotionActivityByType(List<PromotionActivityBO> activityList, PromotionActivityTypeEnum type) {
|
||||
// return activityList.stream()
|
||||
// .filter(activity -> type.getValue().equals(activity.getActivityType()))
|
||||
// .findFirst().orElse(null);
|
||||
// }
|
||||
//
|
||||
// private List<PromotionActivityBO> findPromotionActivityListByType(List<PromotionActivityBO> activityList, PromotionActivityTypeEnum type) {
|
||||
// return activityList.stream()
|
||||
// .filter(activity -> type.getValue().equals(activity.getActivityType()))
|
||||
// .collect(Collectors.toList());
|
||||
// }
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user