1. 迁移交易订单的查询接口

2. 支付服务,重新初始化结构
This commit is contained in:
YunaiV 2020-11-27 18:38:39 +08:00
parent db4ee1ed7e
commit fdc83d4550
100 changed files with 1241 additions and 3604 deletions

View File

@ -34,6 +34,11 @@ public class CollectionUtils {
return from.stream().collect(Collectors.toMap(keyFunc, valueFunc));
}
public static <T, K> Map<K, List<T>> convertMultiMap(List<T> from, Function<T, K> keyFunc) {
return from.stream().collect(Collectors.groupingBy(keyFunc,
Collectors.mapping(t -> t, Collectors.toList())));
}
public static <T, K, V> Map<K, List<V>> convertMultiMap(List<T> from, Function<T, K> keyFunc, Function<T, V> valueFunc) {
return from.stream().collect(Collectors.groupingBy(keyFunc,
Collectors.mapping(valueFunc, Collectors.toList())));

View File

@ -39,8 +39,8 @@ public class PageParam implements Serializable {
return this;
}
public final int getOffset() {
return (pageNo - 1) * pageSize;
}
// public final int getOffset() {
// return (pageNo - 1) * pageSize;
// }
}

View File

@ -9,6 +9,15 @@ import java.io.Serializable;
*/
public class SortingField implements Serializable {
/**
* 顺序 - 升序
*/
public static final String ORDER_ASC = "asc";
/**
* 顺序 - 降序
*/
public static final String ORDER_DESC = "desc";
/**
* 字段
*/

View File

@ -12,6 +12,12 @@
<artifactId>mall-spring-boot-starter-mybatis</artifactId>
<dependencies>
<!-- 通用相关 -->
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>common-framework</artifactId>
</dependency>
<!-- DB 相关 -->
<dependency>
<groupId>org.mybatis</groupId>

View File

@ -0,0 +1,35 @@
package cn.iocoder.mall.mybatis.core.util;
import cn.iocoder.common.framework.util.CollectionUtils;
import cn.iocoder.common.framework.vo.PageParam;
import cn.iocoder.common.framework.vo.SortingField;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.Collection;
import java.util.stream.Collectors;
/**
* 分页工具里
*
* 目前主要用于 {@link Page} 的构建
*/
public class PageUtil {
public static <T> Page<T> build(PageParam pageParam) {
return build(pageParam, null);
}
public static <T> Page<T> build(PageParam pageParam, Collection<SortingField> sortingFields) {
// 页码 + 数量
Page<T> page = new Page<>(pageParam.getPageNo(), pageParam.getPageSize());
// 排序字段
if (!CollectionUtils.isEmpty(sortingFields)) {
page.addOrder(sortingFields.stream().map(sortingField -> SortingField.ORDER_ASC.equals(sortingField.getOrder()) ?
OrderItem.asc(sortingField.getField()) : OrderItem.desc(sortingField.getField()))
.collect(Collectors.toList()));
}
return page;
}
}

View File

@ -1,28 +0,0 @@
package cn.iocoder.mall.order.biz.convert;
import cn.iocoder.mall.order.api.bo.OrderBO;
import cn.iocoder.mall.order.api.bo.OrderInfoBO;
import cn.iocoder.mall.order.biz.dataobject.OrderDO;
import org.mapstruct.Mapper;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;
import java.util.List;
/**
* 订单 convert
*
* @author Sin
* @time 2019-03-17 10:14
*/
@Mapper
public interface OrderConvert {
OrderConvert INSTANCE = Mappers.getMapper(OrderConvert.class);
@Mappings({})
List<OrderBO> convertPageBO(List<OrderDO> orderDOList);
@Mappings({})
OrderInfoBO convert(OrderDO orderDO);
}

View File

@ -48,117 +48,6 @@ public class OrderServiceImpl implements OrderService {
*/
public static final int PAY_EXPIRE_TIME = 120;
@Autowired
private OrderMapper orderMapper;
@Autowired
private OrderItemMapper orderItemMapper;
@Autowired
private OrderLogisticsMapper orderLogisticsMapper;
@Autowired
private OrderLogisticsDetailMapper orderLogisticsDetailMapper;
@Autowired
private OrderRecipientMapper orderRecipientMapper;
@Autowired
private OrderCancelMapper orderCancelMapper;
@Autowired
private OrderReturnMapper orderReturnMapper;
@Autowired
private CartServiceImpl cartService;
@Reference(validation = "true", version = "${dubbo.consumer.PromotionActivityService.version}")
private ProductSpuService productSpuService;
@Reference(validation = "true", version = "${dubbo.consumer.UserAddressService.version}")
private UserAddressService userAddressService;
@Reference(validation = "true", version = "${dubbo.consumer.PayTransactionService.version}")
private PayTransactionService payTransactionService;
@Reference(validation = "true", version = "${dubbo.consumer.CouponService.version}")
private CouponService couponService;
@Override
public CommonResult<OrderPageBO> getOrderPage(OrderQueryDTO orderQueryDTO) {
int totalCount = orderMapper.selectPageCount(orderQueryDTO);
if (totalCount == 0) { // TODO FROM 芋艿 TO 小范 Collections.EMPTY_LIST 改成 Collections.emptyList()
return CommonResult.success(new OrderPageBO().setOrders(Collections.EMPTY_LIST).setTotal(0));
}
// 获取订单数据
List<OrderDO> orderDOList = orderMapper.selectPage(orderQueryDTO);
if (CollectionUtils.isEmpty(orderDOList)) {
return CommonResult.success(new OrderPageBO().setOrders(Collections.EMPTY_LIST).setTotal(totalCount));
}
// 获取订单 id
Set<Integer> orderIds = orderDOList.stream()
.map(orderDO -> orderDO.getId()) // TODO FROM 芋艿 to 小范记得用 Lambda
.collect(Collectors.toSet());
// 获取配送信息
List<OrderRecipientDO> orderRecipientDOList = orderRecipientMapper.selectByOrderIds(orderIds);
List<OrderRecipientBO> orderRecipientBOList = OrderRecipientConvert.INSTANCE.convert(orderRecipientDOList);
Map<Integer, OrderRecipientBO> orderRecipientBOMap
= orderRecipientBOList.stream().collect(Collectors.toMap(OrderRecipientBO::getOrderId, obj -> obj));
// 获取 订单的 items
List<OrderItemDO> orderItemDOList = orderItemMapper
.selectByDeletedAndOrderIds(orderIds, DeletedStatusEnum.DELETED_NO.getValue());
List<OrderItemBO> orderItemBOList = OrderItemConvert.INSTANCE.convertOrderItemDO(orderItemDOList);
Map<Integer, List<OrderItemBO>> orderItemBOMultimap = orderItemBOList.stream().collect(
Collectors.toMap(
OrderItemBO::getOrderId,
item -> Lists.newArrayList(item),
(oldVal, newVal) -> {
oldVal.addAll(newVal);
return oldVal;
}
)
);
// 转换 orderDO OrderBO并设置 item
List<OrderBO> orderPageBOList = OrderConvert.INSTANCE.convertPageBO(orderDOList);
List<OrderBO> result = orderPageBOList.stream().map(orderBO -> {
if (orderItemBOMultimap.containsKey(orderBO.getId())) {
orderBO.setOrderItems(orderItemBOMultimap.get(orderBO.getId()));
}
if (orderRecipientBOMap.containsKey(orderBO.getId())) {
orderBO.setOrderRecipient(orderRecipientBOMap.get(orderBO.getId()));
}
return orderBO;
}).collect(Collectors.toList());
return CommonResult.success(
new OrderPageBO()
.setTotal(totalCount)
.setOrders(result)
);
}
@Override
public CommonResult<List<OrderItemBO>> getOrderItems(Integer orderId) {
if (orderMapper.selectById(orderId) == null) {
return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_NOT_EXISTENT.getCode());
}
List<OrderItemDO> orderItemDOList = orderItemMapper
.selectByDeletedAndOrderId(DeletedStatusEnum.DELETED_NO.getValue(), orderId);
List<OrderItemBO> orderItemBOList = OrderItemConvert.INSTANCE.convertOrderItemBO(orderItemDOList);
return CommonResult.success(orderItemBOList);
}
@Override
public CommonResult<OrderRecipientBO> getOrderRecipientBO(Integer orderId) {
if (orderMapper.selectById(orderId) == null) {
return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_NOT_EXISTENT.getCode());
}
OrderRecipientDO orderRecipientDO = orderRecipientMapper.selectByOrderId(orderId);
OrderRecipientBO orderRecipientBO = OrderRecipientConvert.INSTANCE.convert(orderRecipientDO);
return CommonResult.success(orderRecipientBO);
}
@Override
public CommonResult<OrderInfoBO> info(Integer userId, Integer orderId) {
OrderDO orderDO = orderMapper.selectById(orderId);

View File

@ -1,93 +0,0 @@
spring:
# datasource
datasource:
url: jdbc:mysql://s1.iocoder.cn:3306/mall_order?useSSL=false&useUnicode=true&characterEncoding=UTF-8
driver-class-name: com.mysql.jdbc.Driver
username: root
password: 3WLiVUBEwTbvAfsh
# Spring Cloud 配置项
cloud:
nacos:
# Spring Cloud Nacos Discovery 配置项
discovery:
server-addr: s1.iocoder.cn:8848 # Nacos 服务器地址
# mybatis-plus
mybatis-plus:
configuration:
map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。
global-config:
db-config:
id-type: auto
mapper-locations: classpath*:mapper/*.xml
type-aliases-package: cn.iocoder.mall.order.biz.dataobject
# Dubbo 配置项
dubbo:
# Dubbo 注册中心
registry:
address: spring-cloud://s1.iocoder.cn:8848 # 指定 Dubbo 服务注册中心的地址
# Spring Cloud Alibaba Dubbo 专属配置
cloud:
subscribed-services: admin-application, user-application, product-application, promotion-application, pay-application # 设置订阅的应用列表,默认为 * 订阅所有应用
# Dubbo 提供者的协议
protocol:
name: dubbo
port: -1
# Dubbo 提供服务的扫描基础包
scan:
base-packages: cn.iocoder.mall.order.biz.service
# Dubbo 服务提供者的配置
provider:
filter: -exception
CartService:
version: 1.0.0
OrderService:
version: 1.0.0
OrderReturnService:
version: 1.0.0
OrderLogisticsService:
version: 1.0.0
OrderCommentService:
version: 1.0.0
OrderCommentReplyService:
version: 1.0.0
consumer:
timeout: 120000 # 设置长一点,方便调试代码
ProductSpuService:
version: 1.0.0
PromotionActivityService:
version: 1.0.0
CouponService:
version: 1.0.0
PayRefundService:
version: 1.0.0
UserAddressService:
version: 1.0.0
PayTransactionService:
version: 1.0.0
DataDictService:
version: 1.0.0
# logging
logging:
level:
# dao 开启 debug 模式 mybatis 输入 sql
cn.iocoder.mall.order.biz.dao: debug
# Seata 配置项
seata:
tx-service-group: default # Seata 事务组编号,用于 TC 集群名
# 服务配置项,对应 ServiceProperties 类
service:
# 虚拟组和分组的映射
vgroup-mapping:
default: default
# Seata 注册中心配置项
registry:
type: nacos # 注册中心类型
nacos:
serverAddr: ${spring.cloud.nacos.discovery.server-addr} # Nacos 服务地址
namespace: # Nacos 命名空间
cluster: default # 使用的 Seata 分组

View File

@ -1,176 +0,0 @@
package cn.iocoder.mall.order.biz.bo;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* 计算订单价格结果 BO
*/
@Data
@Accessors(chain = true)
public class CalcOrderPriceBO {
// /**
// * 商品分组数组
// */
// private List<ItemGroup> itemGroups;
// /**
// * 优惠劵编号
// */
// private Integer couponCardId;
// /**
// * 优惠劵减少的金额
// *
// * 1. 若未使用优惠劵返回 null
// * 2. 该金额已经分摊到每个 Item discountTotal 需要注意
// */
// private Integer couponCardDiscountTotal;
// /**
// * 邮费信息
// *
// * TODO 芋艿暂时未弄
// */
// private Postage postage;
// /**
// * 费用
// */
// private Fee fee;
//
// /**
// * 商品分组
// *
// * 多个商品参加同一个活动从而形成分组
// */
// @Data
// @Accessors(chain = true)
// public static class ItemGroup {
//
// /**
// * 优惠活动
// */
// // TODO 芋艿目前只会有满减送的情况未来有新的促销方式可能需要改成数组
// private PromotionActivityBO activity;
// /**
// * 促销减少的金额
// *
// * 1. 若未参与促销活动或不满足促销条件返回 null
// * 2. 该金额已经分摊到每个 Item discountTotal 需要注意
// */
// private Integer activityDiscountTotal;
// /**
// * 商品数组
// */
// private List<Item> items;
//// /**
//// * 费用
//// *
//// * TODO 芋艿这里先偷懒postageTotal 字段用不到
//// */
//// private Fee fee; // 注释原因不用这里了
//
// }
//
// @Data
// @Accessors(chain = true)
// public static class Item extends ProductSkuDetailBO { // TODO 芋艿此处先偷懒继承
//
// /**
// * 是否选中
// */
// private Boolean selected;
// /**
// * 购买数量
// */
// private Integer buyQuantity;
// /**
// * 优惠活动
// */
// private PromotionActivityBO activity;
// /**
// * 原始单价单位
// */
// 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 Fee {
//
// /**
// * 购买总价
// */
// private Integer buyTotal;
// /**
// * 优惠总价
// *
// * 注意满多少元包邮不算在优惠中
// */
// private Integer discountTotal;
// /**
// * 邮费 TODO 芋艿 postage 改成 logistics
// */
// 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;
//
// }
}

View File

@ -1,31 +0,0 @@
package cn.iocoder.mall.order.biz.bo;
import java.io.Serializable;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* 计算商品 SKU 价格结果 BO
*/
@Data
@Accessors(chain = true)
public class CalcSkuPriceBO implements Serializable {
// /**
// * 满减送促销活动
// */
// private PromotionActivityBO fullPrivilege;
// /**
// * 限时折扣促销活动
// */
// private PromotionActivityBO timeLimitedDiscount;
// /**
// * 原价格单位
// */
// private Integer originalPrice;
// /**
// * 购买价格单位
// */
// private Integer buyPrice;
}

View File

@ -1,100 +0,0 @@
package cn.iocoder.mall.order.biz.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;
}

View File

@ -1,115 +0,0 @@
package cn.iocoder.mall.order.biz.bo;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* 订单 page
*
* @author Sin
* @time 2019-03-23 14:30
*/
@Data
@Accessors(chain = true)
public class OrderBO implements Serializable {
/**
* id
*/
private Integer id;
/**
* 用户编号
*/
private Integer userId;
/**
* 订单编号
*/
private String orderNo;
/**
* 购买商品总金额单位
*/
private Integer buyPrice;
/**
* 优惠总金额单位
*/
private Integer discountPrice;
/**
* 物流金额 ()
*/
private Integer logisticsPrice;
/**
* 最终金额单位
*
* buyPrice + logisticsPrice - discountPrice = presentPrice
*/
private Integer presentPrice;
/**
* 实际已支付金额单位
*
* 初始时金额为 0 等到支付成功后会进行更新
*/
private Integer payAmount;
///
/// 时间信息
/**
* 付款时间待发货
*/
private Date paymentTime;
/**
* 发货时间待收货
*/
private Date deliveryTime;
/**
* 收货时间已签收
*/
private Date receiverTime;
/**
* 成交时间用户确认收货 -> status = 已完成
*/
private Date closingTime;
///
/// 其他
/**
* 是否退货
*
* - 0没有
* - 1换货
* - 2退货
* - 3换货 + 退货
*/
private Integer hasReturnExchange;
/**
* 状态(如果有多个商品分开发货需要全部商品发完才会改变状态)
*
* - 0待付款
* - 1待发货
* - 2待收获
* - 3已完成
* - 4已关闭
*/
private Integer status;
/**
* 备注
*/
private String remark;
///
/// 关联信息
/**
* orderItem
*/
private List<OrderItemBO> orderItems;
/**
* 订单物流信息
*/
private OrderRecipientBO orderRecipient;
}

View File

@ -1,30 +0,0 @@
package cn.iocoder.mall.order.biz.bo;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
* 订单创建 BO
*
* @author Sin
* @time 2019-03-16 14:38
*/
@Data
@Accessors(chain = true)
public class OrderCreateBO implements Serializable {
/**
* 编号
*/
private Integer id;
/**
* 订单编号
*/
private String orderNo;
/**
* 订单金额
*/
private Integer payAmount;
}

View File

@ -1,233 +0,0 @@
package cn.iocoder.mall.order.biz.bo;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* 订单 info
*
* @author Sin
* @time 2019-04-14 15:36
*/
@Data
@Accessors(chain = true)
public class OrderInfoBO implements Serializable {
/**
* id
*/
private Integer id;
/**
* 订单编号
*/
private String orderNo;
/**
* 购买商品总金额单位
*/
private Integer buyPrice;
/**
* 优惠总金额单位
*/
private Integer discountPrice;
/**
* 物流金额 ()
*/
private Integer logisticsPrice;
/**
* 最终金额单位
*
* buyPrice + logisticsPrice - discountPrice = presentPrice
*/
private Integer presentPrice;
/**
* 实际已支付金额单位
*
* 初始时金额为 0 等到支付成功后会进行更新
*/
private Integer payAmount;
/**
* 付款时间待发货
*/
private Date paymentTime;
/**
* 发货时间待收货
*/
private Date deliveryTime;
/**
* 收货时间已签收
*/
private Date receiverTime;
/**
* 成交时间用户确认收货 -> status = 已完成
*/
private Date closingTime;
/**
* 是否退货
*
* - 1没有
* - 2换货
* - 3退货
* - 4换货 + 退货
*/
private Integer hasReturnExchange;
/**
* 状态(如果有多个商品分开发货需要全部商品发完才会改变状态)
*
* - 1待付款
* - 2待发货
* - 3待收获
* - 4已完成
* - 5已关闭
*/
private Integer status;
/**
* 转换的字典值
*/
private String statusText;
/**
* 备注
*/
private String remark;
///
/// 其他信息
/**
* 手机人信息
*/
private Recipient recipient;
/**
* 最新物流信息
*/
private LogisticsDetail latestLogisticsDetail;
/**
* 订单 item
*/
private List<OrderItem> orderItems;
///
/// 其他字段
/**
* 是否退货
*/
private Integer hasOrderReturn;
@Data
@Accessors(chain = true)
public static class OrderItem {
/**
* 商品编号
*/
private Integer skuId;
/**
* 商品名称
*/
private String skuName;
/**
* 商品图片
*/
private String skuImage;
/**
* 数量
*/
private Integer quantity;
/**
* 原始单价单位
*/
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 Recipient {
/**
* 编号
*/
private Integer id;
/**
* 订单id
*/
private Integer orderId;
/**
* 收件区域编号
*/
private String areaNo;
/**
* 收件人名称
*/
private String name;
/**
* 收件手机号
*/
private String mobile;
/**
* 配送类型
*
* - 1 快递
*/
private Integer type;
/**
* 收件详细地址
*/
private String address;
}
@Data
@Accessors(chain = true)
public static class LogisticsDetail {
/**
* id
*/
private Integer id;
/**
* 物流id
*/
private Integer orderLogisticsId;
/**
* 物流时间
*/
private Date logisticsTime;
/**
* 物流信息
*/
private String logisticsInformation;
}
}

View File

@ -1,143 +0,0 @@
package cn.iocoder.mall.order.biz.bo;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
/**
* 订单 item
*
* @author Sin
* @time 2019-03-28 21:11
*/
@Data
@Accessors(chain = true)
public class OrderItemBO implements Serializable {
/**
* 编号
*/
private Integer id;
/**
* 订单编号
*/
private Integer orderId;
/**
* 订单号
*/
private String orderNo;
/**
* 商品编号
*/
private Integer skuId;
/**
* 商品名称
*/
private String skuName;
/**
* 商品图片
*/
private String skuImage;
/**
* 数量
*/
private Integer quantity;
/**
* 原始单价单位
*/
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;
///
/// 时间信息
/**
* 付款时间
*/
private Date paymentTime;
/**
* 发货时间
*/
private Date deliveryTime;
/**
* 收货时间
*/
private Date receiverTime;
/**
* 成交时间
*/
private Date closingTime;
///
/// 其他
/**
* 是否退货
*
* - 1没有
* - 2换货
* - 3退货
* - 4换货 + 退货
*/
private Integer hasReturnExchange;
/**
* 发货方式
*
* - 1 未选择
* - 2 在线下单
* - 3 自己联系快递
* - 4 无物流
*/
private Integer deliveryType;
/**
* 状态
*
* - 1待付款
* - 2待发货
* - 3已发货
* - 4已完成
* - 5已关闭
*/
private Integer status;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
/**
* 删除状态
*/
private Integer deleted;
}

View File

@ -1,28 +0,0 @@
package cn.iocoder.mall.order.biz.bo;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.List;
/**
* 订单分页
*
* @author Sin
* @time 2019-03-27 21:27
*/
@Data
@Accessors(chain = true)
public class OrderPageBO implements Serializable {
/**
* 总条数
*/
private Integer total;
/**
* 订单列表
*/
private List<OrderBO> orders;
}

View File

@ -1,12 +0,0 @@
package cn.iocoder.mall.order.biz.bo;
import java.io.Serializable;
/**
* 订单支付信息返回
*
* @author Sin
* @time 2019-04-08 19:39
*/
public class OrderPayBO implements Serializable {
}

View File

@ -1,45 +0,0 @@
package cn.iocoder.mall.order.biz.bo;
import cn.iocoder.mall.mybatis.core.dataobject.BaseDO;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* 订单收件人信息 order_recipient
*
* @author Sin
* @time 2019-03-31 11:37
*/
@Data
@Accessors(chain = true)
public class OrderRecipientBO extends BaseDO { // TODO FROM 芋艿 TO 小范不要继承 BaseDO
/**
* 编号
*/
private Integer id;
/**
* 订单id
*/
private Integer orderId;
/**
* 收件区域编号
*/
private String areaNo;
/**
* 收件人名称
*/
private String name;
/**
* 收件手机号
*/
private String mobile;
/**
* 手机方式
*/
private Integer type;
/**
* 收件详细地址
*/
private String address;
}

View File

@ -1,14 +0,0 @@
package cn.iocoder.mall.order.biz.bo;
public class PostageDetailBO {
// "description": "有品甄选商品即有品配送和第三方商家发货的商品2018年1月1日起单笔订单满99元免运费不满99元收10元运费。",
// "leftTotal": "0.00",
// "merchantName": "有品配送",
// "postFee": "0.00",
// "postage": "10.00",
// "postageType": 0,
// "selCount": 14,
// "threshold": "99.00"
}

View File

@ -1,176 +0,0 @@
package cn.iocoder.mall.order.biz.bo.order;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* 计算订单价格结果 BO
*/
@Data
@Accessors(chain = true)
public class CalcOrderPriceBO {
// /**
// * 商品分组数组
// */
// private List<ItemGroup> itemGroups;
// /**
// * 优惠劵编号
// */
// private Integer couponCardId;
// /**
// * 优惠劵减少的金额
// *
// * 1. 若未使用优惠劵返回 null
// * 2. 该金额已经分摊到每个 Item discountTotal 需要注意
// */
// private Integer couponCardDiscountTotal;
// /**
// * 邮费信息
// *
// * TODO 芋艿暂时未弄
// */
// private Postage postage;
// /**
// * 费用
// */
// private Fee fee;
//
// /**
// * 商品分组
// *
// * 多个商品参加同一个活动从而形成分组
// */
// @Data
// @Accessors(chain = true)
// public static class ItemGroup {
//
// /**
// * 优惠活动
// */
// // TODO 芋艿目前只会有满减送的情况未来有新的促销方式可能需要改成数组
// private PromotionActivityBO activity;
// /**
// * 促销减少的金额
// *
// * 1. 若未参与促销活动或不满足促销条件返回 null
// * 2. 该金额已经分摊到每个 Item discountTotal 需要注意
// */
// private Integer activityDiscountTotal;
// /**
// * 商品数组
// */
// private List<Item> items;
//// /**
//// * 费用
//// *
//// * TODO 芋艿这里先偷懒postageTotal 字段用不到
//// */
//// private Fee fee; // 注释原因不用这里了
//
// }
//
// @Data
// @Accessors(chain = true)
// public static class Item extends ProductSkuDetailBO { // TODO 芋艿此处先偷懒继承
//
// /**
// * 是否选中
// */
// private Boolean selected;
// /**
// * 购买数量
// */
// private Integer buyQuantity;
// /**
// * 优惠活动
// */
// private PromotionActivityBO activity;
// /**
// * 原始单价单位
// */
// 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 Fee {
//
// /**
// * 购买总价
// */
// private Integer buyTotal;
// /**
// * 优惠总价
// *
// * 注意满多少元包邮不算在优惠中
// */
// private Integer discountTotal;
// /**
// * 邮费 TODO 芋艿 postage 改成 logistics
// */
// 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;
//
// }
}

View File

@ -1,31 +0,0 @@
package cn.iocoder.mall.order.biz.bo.order;
import java.io.Serializable;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* 计算商品 SKU 价格结果 BO
*/
@Data
@Accessors(chain = true)
public class CalcSkuPriceBO implements Serializable {
// /**
// * 满减送促销活动
// */
// private PromotionActivityBO fullPrivilege;
// /**
// * 限时折扣促销活动
// */
// private PromotionActivityBO timeLimitedDiscount;
// /**
// * 原价格单位
// */
// private Integer originalPrice;
// /**
// * 购买价格单位
// */
// private Integer buyPrice;
}

View File

@ -1,100 +0,0 @@
package cn.iocoder.mall.order.biz.bo.order;
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;
}

View File

@ -1,115 +0,0 @@
package cn.iocoder.mall.order.biz.bo.order;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* 订单 page
*
* @author Sin
* @time 2019-03-23 14:30
*/
@Data
@Accessors(chain = true)
public class OrderBO implements Serializable {
/**
* id
*/
private Integer id;
/**
* 用户编号
*/
private Integer userId;
/**
* 订单编号
*/
private String orderNo;
/**
* 购买商品总金额单位
*/
private Integer buyPrice;
/**
* 优惠总金额单位
*/
private Integer discountPrice;
/**
* 物流金额 ()
*/
private Integer logisticsPrice;
/**
* 最终金额单位
*
* buyPrice + logisticsPrice - discountPrice = presentPrice
*/
private Integer presentPrice;
/**
* 实际已支付金额单位
*
* 初始时金额为 0 等到支付成功后会进行更新
*/
private Integer payAmount;
///
/// 时间信息
/**
* 付款时间待发货
*/
private Date paymentTime;
/**
* 发货时间待收货
*/
private Date deliveryTime;
/**
* 收货时间已签收
*/
private Date receiverTime;
/**
* 成交时间用户确认收货 -> status = 已完成
*/
private Date closingTime;
///
/// 其他
/**
* 是否退货
*
* - 0没有
* - 1换货
* - 2退货
* - 3换货 + 退货
*/
private Integer hasReturnExchange;
/**
* 状态(如果有多个商品分开发货需要全部商品发完才会改变状态)
*
* - 0待付款
* - 1待发货
* - 2待收获
* - 3已完成
* - 4已关闭
*/
private Integer status;
/**
* 备注
*/
private String remark;
///
/// 关联信息
/**
* orderItem
*/
private List<OrderItemBO> orderItems;
/**
* 订单物流信息
*/
private OrderRecipientBO orderRecipient;
}

View File

@ -1,30 +0,0 @@
package cn.iocoder.mall.order.biz.bo.order;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
* 订单创建 BO
*
* @author Sin
* @time 2019-03-16 14:38
*/
@Data
@Accessors(chain = true)
public class OrderCreateBO implements Serializable {
/**
* 编号
*/
private Integer id;
/**
* 订单编号
*/
private String orderNo;
/**
* 订单金额
*/
private Integer payAmount;
}

View File

@ -1,233 +0,0 @@
package cn.iocoder.mall.order.biz.bo.order;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* 订单 info
*
* @author Sin
* @time 2019-04-14 15:36
*/
@Data
@Accessors(chain = true)
public class OrderInfoBO implements Serializable {
/**
* id
*/
private Integer id;
/**
* 订单编号
*/
private String orderNo;
/**
* 购买商品总金额单位
*/
private Integer buyPrice;
/**
* 优惠总金额单位
*/
private Integer discountPrice;
/**
* 物流金额 ()
*/
private Integer logisticsPrice;
/**
* 最终金额单位
*
* buyPrice + logisticsPrice - discountPrice = presentPrice
*/
private Integer presentPrice;
/**
* 实际已支付金额单位
*
* 初始时金额为 0 等到支付成功后会进行更新
*/
private Integer payAmount;
/**
* 付款时间待发货
*/
private Date paymentTime;
/**
* 发货时间待收货
*/
private Date deliveryTime;
/**
* 收货时间已签收
*/
private Date receiverTime;
/**
* 成交时间用户确认收货 -> status = 已完成
*/
private Date closingTime;
/**
* 是否退货
*
* - 1没有
* - 2换货
* - 3退货
* - 4换货 + 退货
*/
private Integer hasReturnExchange;
/**
* 状态(如果有多个商品分开发货需要全部商品发完才会改变状态)
*
* - 1待付款
* - 2待发货
* - 3待收获
* - 4已完成
* - 5已关闭
*/
private Integer status;
/**
* 转换的字典值
*/
private String statusText;
/**
* 备注
*/
private String remark;
///
/// 其他信息
/**
* 手机人信息
*/
private Recipient recipient;
/**
* 最新物流信息
*/
private LogisticsDetail latestLogisticsDetail;
/**
* 订单 item
*/
private List<OrderItem> orderItems;
///
/// 其他字段
/**
* 是否退货
*/
private Integer hasOrderReturn;
@Data
@Accessors(chain = true)
public static class OrderItem {
/**
* 商品编号
*/
private Integer skuId;
/**
* 商品名称
*/
private String skuName;
/**
* 商品图片
*/
private String skuImage;
/**
* 数量
*/
private Integer quantity;
/**
* 原始单价单位
*/
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 Recipient {
/**
* 编号
*/
private Integer id;
/**
* 订单id
*/
private Integer orderId;
/**
* 收件区域编号
*/
private String areaNo;
/**
* 收件人名称
*/
private String name;
/**
* 收件手机号
*/
private String mobile;
/**
* 配送类型
*
* - 1 快递
*/
private Integer type;
/**
* 收件详细地址
*/
private String address;
}
@Data
@Accessors(chain = true)
public static class LogisticsDetail {
/**
* id
*/
private Integer id;
/**
* 物流id
*/
private Integer orderLogisticsId;
/**
* 物流时间
*/
private Date logisticsTime;
/**
* 物流信息
*/
private String logisticsInformation;
}
}

View File

@ -1,143 +0,0 @@
package cn.iocoder.mall.order.biz.bo.order;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
/**
* 订单 item
*
* @author Sin
* @time 2019-03-28 21:11
*/
@Data
@Accessors(chain = true)
public class OrderItemBO implements Serializable {
/**
* 编号
*/
private Integer id;
/**
* 订单编号
*/
private Integer orderId;
/**
* 订单号
*/
private String orderNo;
/**
* 商品编号
*/
private Integer skuId;
/**
* 商品名称
*/
private String skuName;
/**
* 商品图片
*/
private String skuImage;
/**
* 数量
*/
private Integer quantity;
/**
* 原始单价单位
*/
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;
///
/// 时间信息
/**
* 付款时间
*/
private Date paymentTime;
/**
* 发货时间
*/
private Date deliveryTime;
/**
* 收货时间
*/
private Date receiverTime;
/**
* 成交时间
*/
private Date closingTime;
///
/// 其他
/**
* 是否退货
*
* - 1没有
* - 2换货
* - 3退货
* - 4换货 + 退货
*/
private Integer hasReturnExchange;
/**
* 发货方式
*
* - 1 未选择
* - 2 在线下单
* - 3 自己联系快递
* - 4 无物流
*/
private Integer deliveryType;
/**
* 状态
*
* - 1待付款
* - 2待发货
* - 3已发货
* - 4已完成
* - 5已关闭
*/
private Integer status;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
/**
* 删除状态
*/
private Integer deleted;
}

View File

@ -1,28 +0,0 @@
package cn.iocoder.mall.order.biz.bo.order;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.List;
/**
* 订单分页
*
* @author Sin
* @time 2019-03-27 21:27
*/
@Data
@Accessors(chain = true)
public class OrderPageBO implements Serializable {
/**
* 总条数
*/
private Integer total;
/**
* 订单列表
*/
private List<OrderBO> orders;
}

View File

@ -1,12 +0,0 @@
package cn.iocoder.mall.order.biz.bo.order;
import java.io.Serializable;
/**
* 订单支付信息返回
*
* @author Sin
* @time 2019-04-08 19:39
*/
public class OrderPayBO implements Serializable {
}

View File

@ -1,45 +0,0 @@
package cn.iocoder.mall.order.biz.bo.order;
import cn.iocoder.mall.mybatis.core.dataobject.BaseDO;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* 订单收件人信息 order_recipient
*
* @author Sin
* @time 2019-03-31 11:37
*/
@Data
@Accessors(chain = true)
public class OrderRecipientBO extends BaseDO { // TODO FROM 芋艿 TO 小范不要继承 BaseDO
/**
* 编号
*/
private Integer id;
/**
* 订单id
*/
private Integer orderId;
/**
* 收件区域编号
*/
private String areaNo;
/**
* 收件人名称
*/
private String name;
/**
* 收件手机号
*/
private String mobile;
/**
* 手机方式
*/
private Integer type;
/**
* 收件详细地址
*/
private String address;
}

View File

@ -1,14 +0,0 @@
package cn.iocoder.mall.order.biz.bo.order;
public class PostageDetailBO {
// "description": "有品甄选商品即有品配送和第三方商家发货的商品2018年1月1日起单笔订单满99元免运费不满99元收10元运费。",
// "leftTotal": "0.00",
// "merchantName": "有品配送",
// "postFee": "0.00",
// "postage": "10.00",
// "postageType": 0,
// "selCount": 14,
// "threshold": "99.00"
}

View File

@ -1,15 +0,0 @@
package cn.iocoder.mall.order.biz.convert;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
@Mapper
public interface CartConvert {
CartConvert INSTANCE = Mappers.getMapper(CartConvert.class);
// CalcOrderPriceBO.Item convert(ProductSkuDetailBO sku);
//
// List<CartItemBO> convert(List<CartItemDO> items);
}

View File

@ -1,22 +0,0 @@
package cn.iocoder.mall.order.biz.convert;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
/**
* 订单 convert
*
* @author Sin
* @time 2019-03-17 10:14
*/
@Mapper
public interface OrderConvert {
OrderConvert INSTANCE = Mappers.getMapper(OrderConvert.class);
// @Mappings({})
// List<OrderBO> convertPageBO(List<OrderDO> orderDOList);
//
// @Mappings({})
// OrderInfoBO convert(OrderDO orderDO);
}

View File

@ -1,31 +0,0 @@
package cn.iocoder.mall.order.biz.convert;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
/**
* 订单 item convert
*
* @author Sin
* @time 2019-03-23 14:34
*/
@Mapper
public interface OrderItemConvert {
OrderItemConvert INSTANCE = Mappers.getMapper(OrderItemConvert.class);
// @Mappings({})
// OrderItemDO convert(OrderItemUpdateDTO orderItemUpdateDTO);
//
// @Mappings({})
// List<OrderItemBO> convertOrderItemBO(List<OrderItemDO> orderItemDOList);
//
// @Mappings({})
// List<OrderItemDO> convert(List<OrderCreateDTO.OrderItem> orderCreateItemDTOList);
//
// @Mappings({})
// List<OrderItemBO> convertOrderItemDO(List<OrderItemDO> orderItemDOList);
//
// @Mappings({})
// List<OrderInfoBO.OrderItem> convertOrderInfoWithOrderItem(List<OrderItemDO> orderItemDOList);
}

View File

@ -1,41 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>order</artifactId>
<groupId>cn.iocoder.mall</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>order-rest</artifactId>
<description>提供 order 服务的 Rest 接口的实现,提供对外调用</description>
<dependencies>
<!-- Mall 相关 -->
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>order-biz</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<!-- Web 相关 -->
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>mall-spring-boot-starter-web</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>mall-spring-boot-starter-security</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>mall-spring-boot-starter-swagger</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>

View File

@ -16,38 +16,7 @@ import org.springframework.web.bind.annotation.RestController;
@Api(description = "用户订单") // TODO FROM 芋艿 to 小范description 已经废弃啦
public class UsersOrderController {
// @Reference(validation = "true", version = "${dubbo.provider.OrderReturnService.version}")
// private OrderService orderService;
//
// @Reference(validation = "true", version = "${dubbo.provider.CartService.version}")
// private CartService cartService;
//
// @Reference(validation = "true", version = "${dubbo.consumer.DataDictService.version}")
// private DataDictService dataDictService;
//
// @Reference(validation = "true", version = "${dubbo.consumer.CouponService.version}")
// private CouponService couponService;
//
// @GetMapping("order_page")
// @RequiresLogin
// @ApiOperation("订单分页")
// public CommonResult<OrderPageBO> getOrderPage(@Validated OrderQueryDTO orderQueryDTO) {
// Integer userId = UserSecurityContextHolder.getContext().getUserId();
// orderQueryDTO.setUserId(userId);
// return orderService.getOrderPage(orderQueryDTO);
// }
//
// @PostMapping("create_order")
// @RequiresLogin
// @ApiOperation("创建订单")
// public CommonResult<OrderCreateBO> createOrder(@RequestBody @Validated OrderCreatePO orderCreatePO,
// HttpServletRequest request) {
// Integer userId = UserSecurityContextHolder.getContext().getUserId();
// OrderCreateDTO orderCreateDTO = OrderConvertAPP.INSTANCE.convert(orderCreatePO);
// orderCreateDTO.setUserId(userId).setIp(HttpUtil.getIp(request));
// return orderService.createOrder(orderCreateDTO);
// }
//
// @PostMapping("create_order_from_cart")
// @RequiresLogin
// @ApiOperation("创建订单购物车")
@ -85,21 +54,5 @@ public class UsersOrderController {
// Integer userId = UserSecurityContextHolder.getContext().getUserId();
// return orderService.confirmReceiving(userId, orderId);
// }
//
// @GetMapping("info")
// @RequiresLogin
// @ApiOperation("订单详情")
// public CommonResult<OrderInfoBO> orderInfo(@RequestParam("orderId") Integer orderId) {
// Integer userId = UserSecurityContextHolder.getContext().getUserId();
// CommonResult<OrderInfoBO> commonResult = orderService.info(userId, orderId);
//
// OrderInfoBO orderInfoBO = commonResult.getData();
// if (orderInfoBO != null) {
// CommonResult<DataDictBO> dictResult = dataDictService
// .getDataDict(DictKeyConstants.ORDER_STATUS, orderInfoBO.getStatus());
// orderInfoBO.setStatusText(dictResult.getData().getDisplayName());
// }
// return commonResult;
// }
}

View File

@ -14,30 +14,6 @@ import java.util.List;
*/
public interface OrderService {
/**
* 订单 page
*
* @param orderQueryDTO
* @return
*/
CommonResult<OrderPageBO> getOrderPage(OrderQueryDTO orderQueryDTO);
/**
* 获取订单items
*
* @param orderId
* @return
*/
CommonResult<List<OrderItemBO>> getOrderItems(Integer orderId);
/**
* 订单收件人信息
*
* @param orderId
* @return
*/
CommonResult<OrderRecipientBO> getOrderRecipientBO(Integer orderId);
/**
* 订单info
*
@ -47,14 +23,6 @@ public interface OrderService {
*/
CommonResult<OrderInfoBO> info(Integer userId, Integer orderId);
/**
* 订单 - 创建
*
* @param orderCreateDTO
* @return
*/
CommonResult<OrderCreateBO> createOrder(OrderCreateDTO orderCreateDTO);
/**
* 订单item - 更新
*

View File

@ -1,115 +0,0 @@
package cn.iocoder.mall.order.api.bo;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* 订单 page
*
* @author Sin
* @time 2019-03-23 14:30
*/
@Data
@Accessors(chain = true)
public class OrderBO implements Serializable {
/**
* id
*/
private Integer id;
/**
* 用户编号
*/
private Integer userId;
/**
* 订单编号
*/
private String orderNo;
/**
* 购买商品总金额单位
*/
private Integer buyPrice;
/**
* 优惠总金额单位
*/
private Integer discountPrice;
/**
* 物流金额 ()
*/
private Integer logisticsPrice;
/**
* 最终金额单位
*
* buyPrice + logisticsPrice - discountPrice = presentPrice
*/
private Integer presentPrice;
/**
* 实际已支付金额单位
*
* 初始时金额为 0 等到支付成功后会进行更新
*/
private Integer payAmount;
///
/// 时间信息
/**
* 付款时间待发货
*/
private Date paymentTime;
/**
* 发货时间待收货
*/
private Date deliveryTime;
/**
* 收货时间已签收
*/
private Date receiverTime;
/**
* 成交时间用户确认收货 -> status = 已完成
*/
private Date closingTime;
///
/// 其他
/**
* 是否退货
*
* - 0没有
* - 1换货
* - 2退货
* - 3换货 + 退货
*/
private Integer hasReturnExchange;
/**
* 状态(如果有多个商品分开发货需要全部商品发完才会改变状态)
*
* - 0待付款
* - 1待发货
* - 2待收获
* - 3已完成
* - 4已关闭
*/
private Integer status;
/**
* 备注
*/
private String remark;
///
/// 关联信息
/**
* orderItem
*/
private List<OrderItemBO> orderItems;
/**
* 订单物流信息
*/
private OrderRecipientBO orderRecipient;
}

View File

@ -1,30 +0,0 @@
package cn.iocoder.mall.order.api.bo;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
* 订单创建 BO
*
* @author Sin
* @time 2019-03-16 14:38
*/
@Data
@Accessors(chain = true)
public class OrderCreateBO implements Serializable {
/**
* 编号
*/
private Integer id;
/**
* 订单编号
*/
private String orderNo;
/**
* 订单金额
*/
private Integer payAmount;
}

View File

@ -1,233 +0,0 @@
package cn.iocoder.mall.order.api.bo;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* 订单 info
*
* @author Sin
* @time 2019-04-14 15:36
*/
@Data
@Accessors(chain = true)
public class OrderInfoBO implements Serializable {
/**
* id
*/
private Integer id;
/**
* 订单编号
*/
private String orderNo;
/**
* 购买商品总金额单位
*/
private Integer buyPrice;
/**
* 优惠总金额单位
*/
private Integer discountPrice;
/**
* 物流金额 ()
*/
private Integer logisticsPrice;
/**
* 最终金额单位
*
* buyPrice + logisticsPrice - discountPrice = presentPrice
*/
private Integer presentPrice;
/**
* 实际已支付金额单位
*
* 初始时金额为 0 等到支付成功后会进行更新
*/
private Integer payAmount;
/**
* 付款时间待发货
*/
private Date paymentTime;
/**
* 发货时间待收货
*/
private Date deliveryTime;
/**
* 收货时间已签收
*/
private Date receiverTime;
/**
* 成交时间用户确认收货 -> status = 已完成
*/
private Date closingTime;
/**
* 是否退货
*
* - 1没有
* - 2换货
* - 3退货
* - 4换货 + 退货
*/
private Integer hasReturnExchange;
/**
* 状态(如果有多个商品分开发货需要全部商品发完才会改变状态)
*
* - 1待付款
* - 2待发货
* - 3待收获
* - 4已完成
* - 5已关闭
*/
private Integer status;
/**
* 转换的字典值
*/
private String statusText;
/**
* 备注
*/
private String remark;
///
/// 其他信息
/**
* 手机人信息
*/
private Recipient recipient;
/**
* 最新物流信息
*/
private LogisticsDetail latestLogisticsDetail;
/**
* 订单 item
*/
private List<OrderItem> orderItems;
///
/// 其他字段
/**
* 是否退货
*/
private Integer hasOrderReturn;
@Data
@Accessors(chain = true)
public static class OrderItem {
/**
* 商品编号
*/
private Integer skuId;
/**
* 商品名称
*/
private String skuName;
/**
* 商品图片
*/
private String skuImage;
/**
* 数量
*/
private Integer quantity;
/**
* 原始单价单位
*/
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 Recipient {
/**
* 编号
*/
private Integer id;
/**
* 订单id
*/
private Integer orderId;
/**
* 收件区域编号
*/
private String areaNo;
/**
* 收件人名称
*/
private String name;
/**
* 收件手机号
*/
private String mobile;
/**
* 配送类型
*
* - 1 快递
*/
private Integer type;
/**
* 收件详细地址
*/
private String address;
}
@Data
@Accessors(chain = true)
public static class LogisticsDetail {
/**
* id
*/
private Integer id;
/**
* 物流id
*/
private Integer orderLogisticsId;
/**
* 物流时间
*/
private Date logisticsTime;
/**
* 物流信息
*/
private String logisticsInformation;
}
}

View File

@ -1,143 +0,0 @@
package cn.iocoder.mall.order.api.bo;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
/**
* 订单 item
*
* @author Sin
* @time 2019-03-28 21:11
*/
@Data
@Accessors(chain = true)
public class OrderItemBO implements Serializable {
/**
* 编号
*/
private Integer id;
/**
* 订单编号
*/
private Integer orderId;
/**
* 订单号
*/
private String orderNo;
/**
* 商品编号
*/
private Integer skuId;
/**
* 商品名称
*/
private String skuName;
/**
* 商品图片
*/
private String skuImage;
/**
* 数量
*/
private Integer quantity;
/**
* 原始单价单位
*/
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;
///
/// 时间信息
/**
* 付款时间
*/
private Date paymentTime;
/**
* 发货时间
*/
private Date deliveryTime;
/**
* 收货时间
*/
private Date receiverTime;
/**
* 成交时间
*/
private Date closingTime;
///
/// 其他
/**
* 是否退货
*
* - 1没有
* - 2换货
* - 3退货
* - 4换货 + 退货
*/
private Integer hasReturnExchange;
/**
* 发货方式
*
* - 1 未选择
* - 2 在线下单
* - 3 自己联系快递
* - 4 无物流
*/
private Integer deliveryType;
/**
* 状态
*
* - 1待付款
* - 2待发货
* - 3已发货
* - 4已完成
* - 5已关闭
*/
private Integer status;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
/**
* 删除状态
*/
private Integer deleted;
}

View File

@ -1,28 +0,0 @@
package cn.iocoder.mall.order.api.bo;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.List;
/**
* 订单分页
*
* @author Sin
* @time 2019-03-27 21:27
*/
@Data
@Accessors(chain = true)
public class OrderPageBO implements Serializable {
/**
* 总条数
*/
private Integer total;
/**
* 订单列表
*/
private List<OrderBO> orders;
}

View File

@ -1,12 +0,0 @@
package cn.iocoder.mall.order.api.bo;
import java.io.Serializable;
/**
* 订单支付信息返回
*
* @author Sin
* @time 2019-04-08 19:39
*/
public class OrderPayBO implements Serializable {
}

View File

@ -1,45 +0,0 @@
package cn.iocoder.mall.order.api.bo;
import cn.iocoder.common.framework.dataobject.BaseDO;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* 订单收件人信息 order_recipient
*
* @author Sin
* @time 2019-03-31 11:37
*/
@Data
@Accessors(chain = true)
public class OrderRecipientBO extends BaseDO { // TODO FROM 芋艿 TO 小范不要继承 BaseDO
/**
* 编号
*/
private Integer id;
/**
* 订单id
*/
private Integer orderId;
/**
* 收件区域编号
*/
private String areaNo;
/**
* 收件人名称
*/
private String name;
/**
* 收件手机号
*/
private String mobile;
/**
* 手机方式
*/
private Integer type;
/**
* 收件详细地址
*/
private String address;
}

View File

@ -1,14 +0,0 @@
package cn.iocoder.mall.order.api.bo;
public class PostageDetailBO {
// "description": "有品甄选商品即有品配送和第三方商家发货的商品2018年1月1日起单笔订单满99元免运费不满99元收10元运费。",
// "leftTotal": "0.00",
// "merchantName": "有品配送",
// "postFee": "0.00",
// "postage": "10.00",
// "postageType": 0,
// "selCount": 14,
// "threshold": "99.00"
}

View File

@ -12,11 +12,21 @@
<artifactId>pay-service-api</artifactId>
<dependencies>
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>common-framework</artifactId>
</dependency>
<!-- 工具类相关 -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>

View File

@ -1,4 +1,4 @@
package cn.iocoder.mall.pay.api.constant;
package cn.iocoder.mall.payservice.enums;
import cn.iocoder.common.framework.core.IntArrayValuable;

View File

@ -0,0 +1,7 @@
package cn.iocoder.mall.payservice.rpc.app;
/**
* 支付应用 RPC 接口
*/
public interface PayAppRpc {
}

View File

@ -1,15 +1,16 @@
package cn.iocoder.mall.pay.biz.dataobject;
package cn.iocoder.mall.payservice.rpc.app.dto;
import cn.iocoder.common.framework.dataobject.DeletableDO;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
* 支付应用业务线DO
* 支付应用 Response DTO
*/
@Data
@Accessors(chain = true)
public class PayAppDO extends DeletableDO {
public class PayAppRespDTO implements Serializable {
/**
* 应用编号
@ -21,9 +22,8 @@ public class PayAppDO extends DeletableDO {
private String name;
/**
* 异步通知地址
* TODO 芋艿修改成 payNotifyUrl
*/
private String notifyUrl;
private String payNotifyUrl;
/**
* 退款异步通知地址
*/

View File

@ -0,0 +1 @@
package cn.iocoder.mall.payservice.rpc;

View File

@ -0,0 +1,10 @@
package cn.iocoder.mall.payservice.rpc.transaction;
/**
* 支付交易单 RPC 接口
*/
public interface PayTransactionRpc {
}

View File

@ -1,7 +1,5 @@
package cn.iocoder.mall.pay.api.dto.transaction;
package cn.iocoder.mall.payservice.rpc.transaction.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;
@ -12,43 +10,56 @@ import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
@ApiModel("支付交易创建 DTO")
/**
* 支付交易单创建 DTO
*/
@Data
@Accessors(chain = true)
public class PayTransactionCreateDTO implements Serializable {
public class PayTransactionCreateReqDTO implements Serializable {
@ApiModelProperty(value = "应用编号", required = true, example = "POd4RC6a")
/**
* 应用编号
*/
@NotEmpty(message = "应用编号不能为空")
private String appId;
@ApiModelProperty(value = "发起交易的 IP", required = true, example = "192.168.10.1")
/**
* 发起交易的 IP
*/
@NotEmpty(message = "IP 不能为空")
private String createIp;
@ApiModelProperty(value = "订单号不能为空", required = true, example = "1024")
/**
* 订单号
*/
@NotEmpty(message = "订单号不能为空")
private String orderId;
@ApiModelProperty(value = "商品名", required = true, example = "芋道源码")
/**
* 商品名
*/
@NotEmpty(message = "商品名不能为空")
@Length(max = 32, message = "商品名不能超过32")
private String orderSubject;
@ApiModelProperty(value = "订单商品描述", required = true, example = "绵啾啾的")
/**
* 订单商品描述
*/
@NotEmpty(message = "商品描述不能为空")
@Length(max = 128, message = "商品描述长度不能超过128")
private String orderDescription;
@ApiModelProperty(value = "订单商品备注", example = "绵啾啾的")
/**
* 订单商品备注
*/
@Length(max = 256, message = "商品备注长度不能超过256")
private String orderMemo;
@ApiModelProperty(value = "支付金额,单位:分。", required = true, example = "10")
/**
* 支付金额单位
*/
@NotNull(message = "金额不能为空")
@DecimalMin(value = "0", inclusive = false, message = "金额必须大于零")
private Integer price;
@ApiModelProperty(value = "交易过期时间", required = true)
/**
* 交易过期时间
*/
@NotNull(message = "交易过期时间不能为空")
private Date expireTime;

View File

@ -11,13 +11,26 @@
<artifactId>pay-service-app</artifactId>
<dependencies>
<!-- RPC 相关 -->
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>mall-spring-boot-starter-dubbo</artifactId>
</dependency>
<dependency>
<!-- 支付服务 -->
<groupId>cn.iocoder.mall</groupId>
<artifactId>product-service-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<!-- Web 相关 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <!-- 需要开启 Web 容器,因为 Actuator 需要使用到 -->
</dependency>
<!-- Registry 和 Config 相关 -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
@ -30,14 +43,6 @@
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
@ -48,6 +53,19 @@
<artifactId>mall-spring-boot-starter-mybatis</artifactId>
</dependency>
<!-- 监控相关 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- Test 相关 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- 工具类相关 -->
<dependency>
<groupId>org.springframework.boot</groupId>
@ -68,5 +86,23 @@
<artifactId>mapstruct-jdk8</artifactId>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.9.6</version>
</dependency>
</dependencies>
<build>
<!-- 设置构建的 jar 包名 -->
<finalName>${project.artifactId}</finalName>
<!-- 使用 spring-boot-maven-plugin 插件打包 -->
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

View File

@ -1,4 +1,13 @@
package cn.iocoder.mall.payservice;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class PayServiceApplication {
public static void main(String[] args) {
SpringApplication.run(PayServiceApplication.class, args);
}
}

View File

@ -0,0 +1,28 @@
package cn.iocoder.mall.payservice.config;
import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector;
import com.baomidou.mybatisplus.core.injector.ISqlInjector;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@Configuration
@MapperScan("cn.iocoder.mall.payservice.dal.mysql.mapper") // 扫描对应的 Mapper 接口
@EnableTransactionManagement(proxyTargetClass = true) // 启动事务管理
public class DatabaseConfiguration {
// 数据库连接池 Druid
@Bean
public ISqlInjector sqlInjector() {
return new DefaultSqlInjector(); // MyBatis Plus 逻辑删除
}
@Bean
public PaginationInterceptor paginationInterceptor() {
return new PaginationInterceptor(); // MyBatis Plus 分页插件
}
}

View File

@ -1,31 +1,12 @@
package cn.iocoder.mall.payservice.convert.transaction;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.payservice.dal.mysql.dataobject.transaction.TransactionDO;
import cn.iocoder.mall.payservice.service.transaction.bo.TransactionBO;
import cn.iocoder.mall.payservice.service.transaction.bo.TransactionCreateBO;
import cn.iocoder.mall.payservice.service.transaction.bo.TransactionUpdateBO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.mapstruct.Mapper;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;
import java.util.List;
@Mapper
public interface TransactionConvert {
TransactionConvert INSTANCE = Mappers.getMapper(TransactionConvert.class);
TransactionDO convert(TransactionUpdateBO updateBO);
List<TransactionBO> convertList(List<TransactionDO> transactionDOs);
PageResult<TransactionBO> convertPage(IPage<TransactionDO> transactionDOPage);
TransactionDO convert(TransactionCreateBO createBO);
TransactionBO convert(TransactionDO transactionDO);
}

View File

@ -0,0 +1,41 @@
package cn.iocoder.mall.payservice.dal.mysql.dataobject.app;
import cn.iocoder.mall.mybatis.core.dataobject.DeletableDO;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* 支付应用
*
* 每个接入的业务都是一个应用进行个性化的配置
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class PayAppDO extends DeletableDO {
/**
* 应用编号
*/
private String id;
/**
* 应用名
*/
private String name;
/**
* 异步通知地址
*/
private String payNotifyUrl;
/**
* 退款异步通知地址
*/
private String refundNotifyUrl;
/**
* 状态
*
* 枚举 {@link cn.iocoder.common.framework.enums.CommonStatusEnum}
*/
private Integer status;
}

View File

@ -1,20 +1,22 @@
package cn.iocoder.mall.payservice.dal.mysql.dataobject.transaction;
import cn.iocoder.mall.mybatis.core.dataobject.BaseDO;
import cn.iocoder.mall.mybatis.core.dataobject.DeletableDO;
import com.baomidou.mybatisplus.annotation.*;
import lombok.*;
import lombok.experimental.*;
import java.util.*;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.Date;
/**
* pay_transaction
* 支付交易表
*/
@TableName("transaction")
@TableName("pay_transaction")
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class TransactionDO extends DeletableDO {
public class PayTransactionDO extends DeletableDO {
/**
* 编号自增

View File

@ -0,0 +1,15 @@
package cn.iocoder.mall.payservice.dal.mysql.mapper.transaction;
import cn.iocoder.mall.payservice.dal.mysql.dataobject.transaction.PayTransactionDO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.stereotype.Repository;
@Repository
public interface PayTransactionMapper extends BaseMapper<PayTransactionDO> {
// default IPage<PayTransactionDO> selectPage(TransactionPageBO pageBO) {
// return selectPage(new Page<>(pageBO.getPageNo(), pageBO.getPageSize()),
// new QueryWrapperX<PayTransactionDO>());
// }
}

View File

@ -1,19 +0,0 @@
package cn.iocoder.mall.payservice.dal.mysql.mapper.transaction;
import cn.iocoder.mall.mybatis.core.query.QueryWrapperX;
import cn.iocoder.mall.payservice.dal.mysql.dataobject.transaction.TransactionDO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Repository;
@Repository
public interface TransactionMapper extends BaseMapper<TransactionDO> {
default IPage<TransactionDO> selectPage(TransactionPageBO pageBO) {
return selectPage(new Page<>(pageBO.getPageNo(), pageBO.getPageSize()),
new QueryWrapperX<TransactionDO>());
}
}

View File

@ -1,4 +0,0 @@
package cn.iocoder.mall.payservice.manager.transaction;
public class TransactionManager {
}

View File

@ -0,0 +1,10 @@
package cn.iocoder.mall.payservice.service.app;
/**
* 支付应用 Service 接口
*/
public interface PayAppService {
}

View File

@ -0,0 +1,25 @@
package cn.iocoder.mall.payservice.service.app.impl;
import cn.iocoder.mall.payservice.service.app.PayAppService;
/**
* 支付应用 Service 实现类
*/
public class PayAppServiceImpl implements PayAppService {
// public PayAppDO validPayApp(String appId) {
// PayAppDO payAppDO = payAppMapper.selectById(appId);
// // 校验是否存在
// if (payAppDO == null) {
// throw ServiceExceptionUtil.exception(PayErrorCodeEnum.PAY_APP_NOT_FOUND.getCode());
// }
// // 校验是否禁用
// if (CommonStatusEnum.DISABLE.getValue().equals(payAppDO.getStatus())) {
// throw ServiceExceptionUtil.exception(PayErrorCodeEnum.PAY_APP_IS_DISABLE.getCode());
// }
// return payAppDO;
// }
}

View File

@ -0,0 +1,10 @@
package cn.iocoder.mall.payservice.service.transaction;
/**
* 支付交易单 Service 接口
*/
public interface PayTransactionService {
}

View File

@ -1,107 +0,0 @@
package cn.iocoder.mall.payservice.service.transaction;
import cn.iocoder.common.framework.exception.util.ServiceExceptionUtil;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.payservice.convert.transaction.TransactionConvert;
import cn.iocoder.mall.payservice.dal.mysql.dataobject.transaction.TransactionDO;
import cn.iocoder.mall.payservice.dal.mysql.mapper.transaction.TransactionMapper;
import cn.iocoder.mall.payservice.service.transaction.bo.TransactionBO;
import cn.iocoder.mall.payservice.service.transaction.bo.TransactionCreateBO;
import cn.iocoder.mall.payservice.service.transaction.bo.TransactionPageBO;
import cn.iocoder.mall.payservice.service.transaction.bo.TransactionUpdateBO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.validation.*;
import java.util.*;
/**
* pay_transaction Service
*/
@Service
@Validated
public class TransactionService {
@Autowired
private TransactionMapper transactionMapper;
/**
* 创建pay_transaction
*
* @param createBO 创建pay_transaction BO
* @return pay_transaction
*/
public TransactionBO createTransaction(@Valid TransactionCreateBO createBO) {
// 插入到数据库
TransactionDO transactionDO = TransactionConvert.INSTANCE.convert(createBO);
transactionMapper.insert(transactionDO);
// 返回
return TransactionConvert.INSTANCE.convert(transactionDO);
}
/**
* 更新pay_transaction
*
* @param updateBO 更新pay_transaction BO
*/
public void updateTransaction(@Valid TransactionUpdateBO updateBO) {
// 校验更新的pay_transaction是否存在
if (transactionMapper.selectById(updateBO.getId()) == null) {
throw ServiceExceptionUtil.exception(AuthErrorCodeConstants.TRANSACTION_NOT_FOUND);
}
// 更新到数据库
TransactionDO updateObject = TransactionConvert.INSTANCE.convert(updateBO);
transactionMapper.updateById(updateObject);
}
/**
* 删除pay_transaction
*
* @param transactionId pay_transaction编号
*/
public void deleteTransaction(Integer transactionId) {
// 校验删除的pay_transaction是否存在
if (transactionMapper.selectById(transactionId) == null) {
throw ServiceExceptionHelper.exception(AuthErrorCodeConstants.TRANSACTION_NOT_FOUND);
}
// 标记删除
transactionMapper.deleteById(transactionId);
}
/**
* 获得pay_transaction
*
* @param transactionId pay_transaction编号
* @return pay_transaction
*/
public TransactionBO getTransaction(Integer transactionId) {
TransactionDO transactionDO = transactionMapper.selectById(transactionId);
return TransactionConvert.INSTANCE.convert(transactionDO);
}
/**
* 获得pay_transaction列表
*
* @param transactionIds pay_transaction编号列表
* @return pay_transaction列表
*/
public List<TransactionBO> listTransactions(List<Integer> transactionIds) {
List<TransactionDO> transactionDOs = transactionMapper.selectBatchIds(transactionIds);
return TransactionConvert.INSTANCE.convertList(transactionDOs);
}
/**
* 获得pay_transaction分页
*
* @param pageBO pay_transaction分页查询
* @return pay_transaction分页结果
*/
public PageResult<TransactionBO> pageTransaction(TransactionPageBO pageBO) {
IPage<TransactionDO> transactionDOPage = transactionMapper.selectPage(pageBO);
return TransactionConvert.INSTANCE.convertPage(transactionDOPage);
}
}

View File

@ -1,96 +0,0 @@
package cn.iocoder.mall.payservice.service.transaction.bo;
import lombok.*;
import lombok.experimental.*;
import io.swagger.annotations.*;
import java.util.*;
/**
* pay_transaction BO
*/
@Data
@Accessors(chain = true)
public class TransactionBO {
/**
* 编号自增
*/
private Integer id;
/**
* 应用编号
*/
private String appId;
/**
* 发起交易的 IP
*/
private String createIp;
/**
* 业务线的订单编号
*/
private String orderId;
/**
* 订单商品名
*/
private String orderSubject;
/**
* 订单商品描述
*/
private String orderDescription;
/**
* 订单备注
*/
private String orderMemo;
/**
* 支付金额单位
*/
private Integer price;
/**
* 订单状态
*/
private Integer status;
/**
* 交易过期时间
*/
private Date expireTime;
/**
* 回调业务线完成时间
*/
private Date finishTime;
/**
* 异步通知地址
*/
private String notifyUrl;
/**
* 成功支付的交易拓展编号
*/
private Integer extensionId;
/**
* 支付成功的支付渠道
*/
private Integer payChannel;
/**
* 第三方支付成功的时间
*/
private Date paymentTime;
/**
* 收到第三方系统通知的时间
*/
private Date notifyTime;
/**
* 第三方的流水号
*/
private String tradeNo;
/**
* 退款总金额
*/
private Integer refundTotal;
/**
* 创建时间
*/
private Date createTime;
/**
* 最后更新时间
*/
private Date updateTime;
}

View File

@ -1,93 +0,0 @@
package cn.iocoder.mall.payservice.service.transaction.bo;
import lombok.*;
import lombok.experimental.*;
import io.swagger.annotations.*;
import java.util.*;
import javax.validation.constraints.*;
/**
* pay_transaction创建 BO
*/
@Data
@Accessors(chain = true)
public class TransactionCreateBO {
/**
* 应用编号
*/
@NotEmpty(message = "应用编号不能为空")
private String appId;
/**
* 发起交易的 IP
*/
@NotEmpty(message = "发起交易的 IP不能为空")
private String createIp;
/**
* 业务线的订单编号
*/
@NotEmpty(message = "业务线的订单编号不能为空")
private String orderId;
/**
* 订单商品名
*/
@NotEmpty(message = "订单商品名不能为空")
private String orderSubject;
/**
* 订单商品描述
*/
@NotEmpty(message = "订单商品描述不能为空")
private String orderDescription;
/**
* 订单备注
*/
private String orderMemo;
/**
* 支付金额单位
*/
@NotNull(message = "支付金额,单位:分。不能为空")
private Integer price;
/**
* 订单状态
*/
@NotNull(message = "订单状态不能为空")
private Integer status;
/**
* 交易过期时间
*/
private Date expireTime;
/**
* 回调业务线完成时间
*/
private Date finishTime;
/**
* 异步通知地址
*/
@NotEmpty(message = "异步通知地址不能为空")
private String notifyUrl;
/**
* 成功支付的交易拓展编号
*/
private Integer extensionId;
/**
* 支付成功的支付渠道
*/
private Integer payChannel;
/**
* 第三方支付成功的时间
*/
private Date paymentTime;
/**
* 收到第三方系统通知的时间
*/
private Date notifyTime;
/**
* 第三方的流水号
*/
private String tradeNo;
/**
* 退款总金额
*/
private Integer refundTotal;
}

View File

@ -1,99 +0,0 @@
package cn.iocoder.mall.payservice.service.transaction.bo;
import cn.iocoder.common.framework.vo.PageParam;
import lombok.*;
import lombok.experimental.*;
import io.swagger.annotations.*;
import java.util.*;
import javax.validation.constraints.*;
/**
* pay_transaction分页 BO
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class TransactionPageBO extends PageParam {
/**
* 编号自增
*/
private Integer id;
/**
* 应用编号
*/
private String appId;
/**
* 发起交易的 IP
*/
private String createIp;
/**
* 业务线的订单编号
*/
private String orderId;
/**
* 订单商品名
*/
private String orderSubject;
/**
* 订单商品描述
*/
private String orderDescription;
/**
* 订单备注
*/
private String orderMemo;
/**
* 支付金额单位
*/
private Integer price;
/**
* 订单状态
*/
private Integer status;
/**
* 交易过期时间
*/
private Date expireTime;
/**
* 回调业务线完成时间
*/
private Date finishTime;
/**
* 异步通知地址
*/
private String notifyUrl;
/**
* 成功支付的交易拓展编号
*/
private Integer extensionId;
/**
* 支付成功的支付渠道
*/
private Integer payChannel;
/**
* 第三方支付成功的时间
*/
private Date paymentTime;
/**
* 收到第三方系统通知的时间
*/
private Date notifyTime;
/**
* 第三方的流水号
*/
private String tradeNo;
/**
* 退款总金额
*/
private Integer refundTotal;
/**
* 创建时间
*/
private Date createTime;
/**
* 最后更新时间
*/
private Date updateTime;
}

View File

@ -1,98 +0,0 @@
package cn.iocoder.mall.payservice.service.transaction.bo;
import lombok.*;
import lombok.experimental.*;
import io.swagger.annotations.*;
import java.util.*;
import javax.validation.constraints.*;
/**
* pay_transaction更新 BO
*/
@Data
@Accessors(chain = true)
public class TransactionUpdateBO {
/**
* 编号自增
*/
@NotNull(message = "编号,自增不能为空")
private Integer id;
/**
* 应用编号
*/
@NotEmpty(message = "应用编号不能为空")
private String appId;
/**
* 发起交易的 IP
*/
@NotEmpty(message = "发起交易的 IP不能为空")
private String createIp;
/**
* 业务线的订单编号
*/
@NotEmpty(message = "业务线的订单编号不能为空")
private String orderId;
/**
* 订单商品名
*/
@NotEmpty(message = "订单商品名不能为空")
private String orderSubject;
/**
* 订单商品描述
*/
@NotEmpty(message = "订单商品描述不能为空")
private String orderDescription;
/**
* 订单备注
*/
private String orderMemo;
/**
* 支付金额单位
*/
@NotNull(message = "支付金额,单位:分。不能为空")
private Integer price;
/**
* 订单状态
*/
@NotNull(message = "订单状态不能为空")
private Integer status;
/**
* 交易过期时间
*/
private Date expireTime;
/**
* 回调业务线完成时间
*/
private Date finishTime;
/**
* 异步通知地址
*/
@NotEmpty(message = "异步通知地址不能为空")
private String notifyUrl;
/**
* 成功支付的交易拓展编号
*/
private Integer extensionId;
/**
* 支付成功的支付渠道
*/
private Integer payChannel;
/**
* 第三方支付成功的时间
*/
private Date paymentTime;
/**
* 收到第三方系统通知的时间
*/
private Date notifyTime;
/**
* 第三方的流水号
*/
private String tradeNo;
/**
* 退款总金额
*/
private Integer refundTotal;
}

View File

@ -0,0 +1,97 @@
package cn.iocoder.mall.payservice.service.transaction.impl;
import cn.iocoder.mall.payservice.dal.mysql.mapper.transaction.PayTransactionMapper;
import cn.iocoder.mall.payservice.service.transaction.PayTransactionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
/**
* 支付交易单 Service 实现类
*/
@Service
@Validated
public class PayTransactionServiceImpl implements PayTransactionService {
@Autowired
private PayTransactionMapper transactionMapper;
// /**
// * 创建pay_transaction
// *
// * @param createBO 创建pay_transaction BO
// * @return pay_transaction
// */
// public TransactionBO createTransaction(@Valid TransactionCreateBO createBO) {
// // 插入到数据库
// PayTransactionDO transactionDO = TransactionConvert.INSTANCE.convert(createBO);
// transactionMapper.insert(transactionDO);
// // 返回
// return TransactionConvert.INSTANCE.convert(transactionDO);
// }
//
// /**
// * 更新pay_transaction
// *
// * @param updateBO 更新pay_transaction BO
// */
// public void updateTransaction(@Valid TransactionUpdateBO updateBO) {
// // 校验更新的pay_transaction是否存在
// if (transactionMapper.selectById(updateBO.getId()) == null) {
// throw ServiceExceptionUtil.exception(AuthErrorCodeConstants.TRANSACTION_NOT_FOUND);
// }
// // 更新到数据库
// PayTransactionDO updateObject = TransactionConvert.INSTANCE.convert(updateBO);
// transactionMapper.updateById(updateObject);
// }
//
// /**
// * 删除pay_transaction
// *
// * @param transactionId pay_transaction编号
// */
// public void deleteTransaction(Integer transactionId) {
// // 校验删除的pay_transaction是否存在
// if (transactionMapper.selectById(transactionId) == null) {
// throw ServiceExceptionHelper.exception(AuthErrorCodeConstants.TRANSACTION_NOT_FOUND);
// }
// // 标记删除
// transactionMapper.deleteById(transactionId);
// }
//
// /**
// * 获得pay_transaction
// *
// * @param transactionId pay_transaction编号
// * @return pay_transaction
// */
// public TransactionBO getTransaction(Integer transactionId) {
// PayTransactionDO transactionDO = transactionMapper.selectById(transactionId);
// return TransactionConvert.INSTANCE.convert(transactionDO);
// }
//
// /**
// * 获得pay_transaction列表
// *
// * @param transactionIds pay_transaction编号列表
// * @return pay_transaction列表
// */
// public List<TransactionBO> listTransactions(List<Integer> transactionIds) {
// List<PayTransactionDO> transactionDOs = transactionMapper.selectBatchIds(transactionIds);
// return TransactionConvert.INSTANCE.convertList(transactionDOs);
// }
//
// /**
// * 获得pay_transaction分页
// *
// * @param pageBO pay_transaction分页查询
// * @return pay_transaction分页结果
// */
// public PageResult<TransactionBO> pageTransaction(TransactionPageBO pageBO) {
// IPage<PayTransactionDO> transactionDOPage = transactionMapper.selectPage(pageBO);
// return TransactionConvert.INSTANCE.convertPage(transactionDOPage);
// }
}

View File

@ -0,0 +1,21 @@
spring:
# 数据源配置项
datasource:
url: jdbc:mysql://400-infra.server.iocoder.cn:3306/mall_pay?useSSL=false&useUnicode=true&characterEncoding=UTF-8
driver-class-name: com.mysql.jdbc.Driver
username: root
password: 3WLiVUBEwTbvAfsh
# Spring Cloud 配置项
cloud:
nacos:
# Spring Cloud Nacos Discovery 配置项
discovery:
server-addr: 400-infra.server.iocoder.cn:8848 # Nacos 服务器地址
namespace: dev # Nacos 命名空间
# Dubbo 配置项
dubbo:
# Dubbo 注册中心
registry:
# address: spring-cloud://400-infra.server.iocoder.cn:8848 # 指定 Dubbo 服务注册中心的地址
address: nacos://400-infra.server.iocoder.cn:8848?namespace=dev # 指定 Dubbo 服务注册中心的地址

View File

@ -0,0 +1,24 @@
spring:
# 数据源配置项
datasource:
url: jdbc:mysql://400-infra.server.iocoder.cn:3306/mall_pay?useSSL=false&useUnicode=true&characterEncoding=UTF-8
driver-class-name: com.mysql.jdbc.Driver
username: root
password: 3WLiVUBEwTbvAfsh
# Spring Cloud 配置项
cloud:
nacos:
# Spring Cloud Nacos Discovery 配置项
discovery:
server-addr: 400-infra.server.iocoder.cn:8848 # Nacos 服务器地址
namespace: dev # Nacos 命名空间
# Dubbo 配置项
dubbo:
# Dubbo 注册中心
registry:
# address: spring-cloud://400-infra.server.iocoder.cn:8848 # 指定 Dubbo 服务注册中心的地址
address: nacos://400-infra.server.iocoder.cn:8848?namespace=dev # 指定 Dubbo 服务注册中心的地址
# Dubbo 服务提供者的配置
provider:
tag: ${DUBBO_TAG} # Dubbo 路由分组

View File

@ -0,0 +1,64 @@
spring:
# Application 的配置项
application:
name: pay-service
# Profile 的配置项
profiles:
active: local
# MyBatis Plus 配置项
mybatis-plus:
configuration:
map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。
global-config:
db-config:
id-type: auto
logic-delete-value: 1 # 逻辑已删除值(默认为 1)
logic-not-delete-value: 0 # 逻辑未删除值(默认为 0)
mapper-locations: classpath*:mapper/*.xml
type-aliases-package: cn.iocoder.mall.payservice.dal.mysql.dataobject
# Dubbo 配置项
dubbo:
# Spring Cloud Alibaba Dubbo 专属配置
cloud:
subscribed-services: '' # 设置订阅的应用列表,默认为 * 订阅所有应用
# Dubbo 提供者的协议
protocol:
name: dubbo
port: -1
# Dubbo 提供服务的扫描基础包
scan:
base-packages: cn.iocoder.mall.payservice.rpc
# Dubbo 服务提供者的配置
provider:
filter: -exception
validation: true # 开启 Provider 参数校验
version: 1.0.0 # 服务的版本号
# Dubbo 服务消费者的配置
consumer:
ErrorCodeRpc:
version: 1.0.0
ProductSkuRpc:
version: 1.0.0
ProductSpuRpc:
version: 1.0.0
# RocketMQ 配置项
rocketmq:
name-server: 400-infra.server.iocoder.cn:9876
producer:
group: ${spring.application.name}-producer-group
# Actuator 监控配置项
management:
server.port: 38089 # 独立端口,避免被暴露出去
endpoints.web.exposure.include: '*' # 暴露所有监控端点
server.port: ${management.server.port} # 设置使用 Actuator 的服务器端口,因为 RPC 服务不需要 Web 端口
# Mall 配置项
mall:
# 错误码配置项对应 ErrorCodeProperties 配置类
error-code:
group: ${spring.application.name}
constants-class: cn.iocoder.mall.payservice.enums.PayErrorCodeConstants

View File

@ -35,6 +35,12 @@
<version>1.0-SNAPSHOT</version>
</dependency>
<!-- 自身项目 -->
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>pay-service-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</dependencyManagement>

View File

@ -1,15 +0,0 @@
package cn.iocoder.mall.pay.application;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableAsync;
@SpringBootApplication(scanBasePackages = {"cn.iocoder.mall.pay"})
@EnableAsync(proxyTargetClass = true)
public class PayApplication {
public static void main(String[] args) {
SpringApplication.run(PayApplication.class, args);
}
}

View File

@ -1,19 +0,0 @@
package cn.iocoder.mall.pay.application.convert;
import cn.iocoder.mall.pay.api.bo.refund.PayRefundBO;
import cn.iocoder.mall.pay.application.vo.admins.AdminsPayRefundDetailVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;
import java.util.List;
@Mapper
public interface PayRefundConvert {
PayRefundConvert INSTANCE = Mappers.getMapper(PayRefundConvert.class);
@Mappings({})
List<AdminsPayRefundDetailVO> convertList(List<PayRefundBO> refunds);
}

View File

@ -16,8 +16,6 @@ public interface PayTransactionService {
PayTransactionBO getTransaction(PayTransactionGetDTO payTransactionGetDTO);
PayTransactionBO createTransaction(PayTransactionCreateDTO payTransactionCreateDTO);
PayTransactionSubmitBO submitTransaction(PayTransactionSubmitDTO payTransactionSubmitDTO);
/**

View File

@ -1,12 +0,0 @@
package cn.iocoder.mall.pay.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.pay.biz.dao") // 扫描对应的 Mapper 接口
@EnableTransactionManagement(proxyTargetClass = true) // 启动事务管理为什么使用 proxyTargetClass 参数参见 https://blog.csdn.net/huang_550/article/details/76492600
public class DatabaseConfiguration {
}

View File

@ -1,19 +0,0 @@
package cn.iocoder.mall.pay.biz.config;
import cn.iocoder.common.framework.util.ServiceExceptionUtil;
import cn.iocoder.mall.pay.api.constant.PayErrorCodeEnum;
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() {
for (PayErrorCodeEnum item : PayErrorCodeEnum.values()) {
ServiceExceptionUtil.put(item.getCode(), item.getMessage());
}
}
}

View File

@ -1,12 +0,0 @@
package cn.iocoder.mall.pay.biz.dao;
import cn.iocoder.mall.pay.biz.dataobject.PayAppDO;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
@Repository
public interface PayAppMapper {
PayAppDO selectById(@Param("id") String id);
}

View File

@ -1,30 +0,0 @@
package cn.iocoder.mall.pay.biz.service;
import cn.iocoder.common.framework.enums.CommonStatusEnum;
import cn.iocoder.common.framework.util.ServiceExceptionUtil;
import cn.iocoder.mall.pay.api.constant.PayErrorCodeEnum;
import cn.iocoder.mall.pay.biz.dao.PayAppMapper;
import cn.iocoder.mall.pay.biz.dataobject.PayAppDO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class PayAppServiceImpl {
@Autowired
private PayAppMapper payAppMapper;
public PayAppDO validPayApp(String appId) {
PayAppDO payAppDO = payAppMapper.selectById(appId);
// 校验是否存在
if (payAppDO == null) {
throw ServiceExceptionUtil.exception(PayErrorCodeEnum.PAY_APP_NOT_FOUND.getCode());
}
// 校验是否禁用
if (CommonStatusEnum.DISABLE.getValue().equals(payAppDO.getStatus())) {
throw ServiceExceptionUtil.exception(PayErrorCodeEnum.PAY_APP_IS_DISABLE.getCode());
}
return payAppDO;
}
}

View File

@ -1,11 +1,16 @@
package cn.iocoder.mall.shopweb.client.trade;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.tradeservice.rpc.order.TradeOrderRpc;
import cn.iocoder.mall.tradeservice.rpc.order.dto.TradeOrderCreateReqDTO;
import cn.iocoder.mall.tradeservice.rpc.order.dto.TradeOrderPageReqDTO;
import cn.iocoder.mall.tradeservice.rpc.order.dto.TradeOrderRespDTO;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;
import java.util.Arrays;
@Service
public class TradeOrderClient {
@ -18,4 +23,16 @@ public class TradeOrderClient {
return createTradeOrderResult.getData();
}
public PageResult<TradeOrderRespDTO> pageTradeOrder(TradeOrderPageReqDTO pageReqDTO) {
CommonResult<PageResult<TradeOrderRespDTO>> pageTradeOrderResult = tradeOrderRpc.pageTradeOrder(pageReqDTO);
pageTradeOrderResult.checkError();
return pageTradeOrderResult.getData();
}
public TradeOrderRespDTO getTradeOrder(Integer tradeOrderId, String... fields) {
CommonResult<TradeOrderRespDTO> getTradeOrderResult = tradeOrderRpc.getTradeOrder(tradeOrderId, Arrays.asList(fields));
getTradeOrderResult.checkError();
return getTradeOrderResult.getData();
}
}

View File

@ -10,9 +10,22 @@ Authorization: Bearer {{user-access-token}}
### /trade-order/confirm-create-order-info-from-cart 基于商品,创建订单
POST {{shop-api-base-url}}/trade-order/create
Content-Type: application/x-www-form-urlencoded
Content-Type: application/json
Authorization: Bearer {{user-access-token}}
userAddressId=19&remark=我是备注&orderItems[0].skuId=3&orderItems[0].quantity=1
{
"userAddressId": 19,
"remark": "我是备注",
"orderItems": [
{
"skuId": 3,
"quantity": 1
}
]
}
### /trade-order/page 获得订单交易分页
GET {{shop-api-base-url}}/trade-order/page?status=1&pageNo=1&pageSize=10
Content-Type: application/x-www-form-urlencoded
###

View File

@ -2,10 +2,9 @@ package cn.iocoder.mall.shopweb.controller.trade;
import cn.iocoder.common.framework.util.HttpUtil;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.security.user.core.context.UserSecurityContextHolder;
import cn.iocoder.mall.shopweb.controller.trade.vo.order.TradeOrderConfirmCreateInfoRespVO;
import cn.iocoder.mall.shopweb.controller.trade.vo.order.TradeOrderCreateFromCartReqVO;
import cn.iocoder.mall.shopweb.controller.trade.vo.order.TradeOrderCreateReqVO;
import cn.iocoder.mall.shopweb.controller.trade.vo.order.*;
import cn.iocoder.mall.shopweb.service.trade.TradeOrderService;
import cn.iocoder.security.annotations.RequiresAuthenticate;
import io.swagger.annotations.Api;
@ -56,7 +55,7 @@ public class TradeOrderController {
@PostMapping("create")
@ApiOperation("基于商品,创建订单")
@RequiresAuthenticate
public CommonResult<Integer> createTradeOrder(TradeOrderCreateReqVO createReqVO,
public CommonResult<Integer> createTradeOrder(@RequestBody TradeOrderCreateReqVO createReqVO,
HttpServletRequest servletRequest) {
return success(tradeOrderService.createTradeOrder(UserSecurityContextHolder.getUserId(),
HttpUtil.getIp(servletRequest), createReqVO));
@ -69,4 +68,17 @@ public class TradeOrderController {
return null;
}
@GetMapping("/get")
@ApiOperation("获得交易订单")
@ApiImplicitParam(name = "tradeOrderId", value = "交易订单编号", required = true)
public CommonResult<TradeOrderRespVO> getTradeOrder(@RequestParam("tradeOrderId") Integer tradeOrderId) {
return success(tradeOrderService.getTradeOrder(tradeOrderId));
}
@GetMapping("/page")
@ApiOperation("获得订单交易分页")
public CommonResult<PageResult<TradeOrderRespVO>> pageTradeOrder(TradeOrderPageReqVO pageVO) {
return success(tradeOrderService.pageTradeOrder(UserSecurityContextHolder.getUserId(), pageVO));
}
}

View File

@ -0,0 +1,53 @@
package cn.iocoder.mall.shopweb.controller.trade.vo.order;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
@ApiModel("交易订单项 Response VO")
@Data
public class TradeOrderItemRespVO {
@ApiModelProperty(value = "id自增长", required = true)
private Integer id;
@ApiModelProperty(value = "订单编号", required = true)
private Integer orderId;
@ApiModelProperty(value = "订单项状态", required = true)
private Integer status;
@ApiModelProperty(value = "商品 SKU 编号", required = true)
private Integer skuId;
@ApiModelProperty(value = "商品 SPU 编号", required = true)
private Integer spuId;
@ApiModelProperty(value = "商品名字", required = true)
private String skuName;
@ApiModelProperty(value = "图片名字", required = true)
private String skuImage;
@ApiModelProperty(value = "商品数量", required = true)
private Integer quantity;
@ApiModelProperty(value = "原始单价,单位:分", required = true)
private Integer originPrice;
@ApiModelProperty(value = "购买单价,单位:分", required = true)
private Integer buyPrice;
@ApiModelProperty(value = "最终价格,单位:分", required = true)
private Integer presentPrice;
@ApiModelProperty(value = "购买总金额,单位:分", required = true)
private Integer buyTotal;
@ApiModelProperty(value = "优惠总金额,单位:分", required = true)
private Integer discountTotal;
@ApiModelProperty(value = "最终总金额,单位:分", required = true)
private Integer presentTotal;
@ApiModelProperty(value = "退款总金额,单位:分", required = true)
private Integer refundTotal;
@ApiModelProperty(value = "物流id")
private Integer logisticsId;
@ApiModelProperty(value = "售后状态", required = true)
private Integer afterSaleStatus;
@ApiModelProperty(value = "售后订单编号")
private Integer afterSaleOrderId;
@ApiModelProperty(value = "创建时间", required = true)
private Date createTime;
}

View File

@ -0,0 +1,17 @@
package cn.iocoder.mall.shopweb.controller.trade.vo.order;
import cn.iocoder.common.framework.vo.PageParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ApiModel("交易订单分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
public class TradeOrderPageReqVO extends PageParam {
@ApiModelProperty(value = "订单状态", example = "1", notes = "参见 TradeOrderStatusEnum 枚举")
private Integer orderStatus;
}

View File

@ -0,0 +1,70 @@
package cn.iocoder.mall.shopweb.controller.trade.vo.order;
import lombok.*;
import io.swagger.annotations.*;
import java.util.*;
@ApiModel("订单交易 Response VO")
@Data
public class TradeOrderRespVO {
@ApiModelProperty(value = "订单编号", required = true)
private Integer id;
@ApiModelProperty(value = "用户编号", required = true)
private Integer userId;
@ApiModelProperty(value = "订单单号", required = true)
private String orderNo;
@ApiModelProperty(value = "订单状态", required = true)
private Integer orderStatus;
@ApiModelProperty(value = "备注")
private String remark;
@ApiModelProperty(value = "订单结束时间")
private Date endTime;
@ApiModelProperty(value = "订单金额(总金额),单位:分", required = true)
private Integer buyPrice;
@ApiModelProperty(value = "优惠总金额,单位:分", required = true)
private Integer discountPrice;
@ApiModelProperty(value = "物流金额,单位:分", required = true)
private Integer logisticsPrice;
@ApiModelProperty(value = "最终金额,单位:分", required = true)
private Integer presentPrice;
@ApiModelProperty(value = "支付金额,单位:分", required = true)
private Integer payPrice;
@ApiModelProperty(value = "退款金额,单位:分", required = true)
private Integer refundPrice;
@ApiModelProperty(value = "付款时间")
private Date payTime;
@ApiModelProperty(value = "支付订单编号")
private Integer payTransactionId;
@ApiModelProperty(value = "支付渠道")
private Integer payChannel;
@ApiModelProperty(value = "配送类型", required = true)
private Integer deliveryType;
@ApiModelProperty(value = "发货时间")
private Date deliveryTime;
@ApiModelProperty(value = "收货时间")
private Date receiveTime;
@ApiModelProperty(value = "收件人名称", required = true)
private String receiverName;
@ApiModelProperty(value = "手机号", required = true)
private String receiverMobile;
@ApiModelProperty(value = "地区编码", required = true)
private Integer receiverAreaCode;
@ApiModelProperty(value = "收件详细地址", required = true)
private String receiverDetailAddress;
@ApiModelProperty(value = "售后状态", required = true)
private Integer afterSaleStatus;
@ApiModelProperty(value = "优惠劵编号")
private Integer couponCardId;
@ApiModelProperty(value = "创建时间", required = true)
private Date createTime;
/**
* 订单项数组
*
* // TODO 芋艿后续考虑怎么优化下目前是内嵌了别的 dto
*/
private List<TradeOrderItemRespVO> orderItems;
}

View File

@ -1,10 +1,15 @@
package cn.iocoder.mall.shopweb.convert.trade;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.promotion.api.rpc.coupon.dto.card.CouponCardAvailableListReqDTO;
import cn.iocoder.mall.promotion.api.rpc.price.dto.PriceProductCalcRespDTO;
import cn.iocoder.mall.shopweb.controller.trade.vo.order.TradeOrderConfirmCreateInfoRespVO;
import cn.iocoder.mall.shopweb.controller.trade.vo.order.TradeOrderCreateReqVO;
import cn.iocoder.mall.shopweb.controller.trade.vo.order.TradeOrderPageReqVO;
import cn.iocoder.mall.shopweb.controller.trade.vo.order.TradeOrderRespVO;
import cn.iocoder.mall.tradeservice.rpc.order.dto.TradeOrderCreateReqDTO;
import cn.iocoder.mall.tradeservice.rpc.order.dto.TradeOrderPageReqDTO;
import cn.iocoder.mall.tradeservice.rpc.order.dto.TradeOrderRespDTO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
@ -34,4 +39,10 @@ public interface TradeOrderConvert {
TradeOrderCreateReqDTO convert(TradeOrderCreateReqVO bean);
TradeOrderPageReqDTO convert(TradeOrderPageReqVO bean);
PageResult<TradeOrderRespVO> convertPage(PageResult<TradeOrderRespDTO> page);
TradeOrderRespVO convert(TradeOrderRespDTO bean);
}

View File

@ -4,13 +4,7 @@ import cn.iocoder.common.framework.enums.CommonStatusEnum;
import cn.iocoder.common.framework.exception.util.ServiceExceptionUtil;
import cn.iocoder.common.framework.util.CollectionUtils;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.shopweb.client.trade.TradeOrderClient;
import cn.iocoder.mall.shopweb.controller.trade.vo.order.TradeOrderConfirmCreateInfoRespVO;
import cn.iocoder.mall.shopweb.controller.trade.vo.order.TradeOrderCreateReqVO;
import cn.iocoder.mall.shopweb.convert.trade.TradeOrderConvert;
import cn.iocoder.mall.tradeservice.rpc.cart.CartRpc;
import cn.iocoder.mall.tradeservice.rpc.cart.dto.CartItemListReqDTO;
import cn.iocoder.mall.tradeservice.rpc.cart.dto.CartItemRespDTO;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.productservice.enums.sku.ProductSkuDetailFieldEnum;
import cn.iocoder.mall.productservice.rpc.sku.ProductSkuRpc;
import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuListQueryReqDTO;
@ -24,7 +18,19 @@ import cn.iocoder.mall.promotion.api.rpc.coupon.dto.card.CouponCardAvailableResp
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.PriceProductCalcRespDTO;
import cn.iocoder.mall.shopweb.client.trade.TradeOrderClient;
import cn.iocoder.mall.shopweb.controller.trade.vo.order.TradeOrderConfirmCreateInfoRespVO;
import cn.iocoder.mall.shopweb.controller.trade.vo.order.TradeOrderCreateReqVO;
import cn.iocoder.mall.shopweb.controller.trade.vo.order.TradeOrderPageReqVO;
import cn.iocoder.mall.shopweb.controller.trade.vo.order.TradeOrderRespVO;
import cn.iocoder.mall.shopweb.convert.trade.CartConvert;
import cn.iocoder.mall.shopweb.convert.trade.TradeOrderConvert;
import cn.iocoder.mall.tradeservice.enums.order.TradeOrderDetailFieldEnum;
import cn.iocoder.mall.tradeservice.rpc.cart.CartRpc;
import cn.iocoder.mall.tradeservice.rpc.cart.dto.CartItemListReqDTO;
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.TradeOrderRespDTO;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -168,4 +174,30 @@ public class TradeOrderService {
.setUserId(userId).setIp(ip));
}
/**
* 获得交易订单
*
* @param tradeOrderId 交易订单编号
* @return 交易订单
*/
public TradeOrderRespVO getTradeOrder(Integer tradeOrderId) {
return TradeOrderConvert.INSTANCE.convert(tradeOrderClient.getTradeOrder(tradeOrderId,
TradeOrderDetailFieldEnum.ITEM.getField()));
}
/**
* 获得交易订单分页
*
* @param pageVO 订单交易分页查询
* @return 订单交易分页结果
*/
public PageResult<TradeOrderRespVO> pageTradeOrder(Integer userId, TradeOrderPageReqVO pageVO) {
PageResult<TradeOrderRespDTO> pageTradeOrderResult = tradeOrderClient.pageTradeOrder(
TradeOrderConvert.INSTANCE.convert(pageVO).setUserId(userId)
.setFields(Collections.singleton(TradeOrderDetailFieldEnum.ITEM.getField()))
.setSorts(Collections.singletonList(TradeOrderPageReqDTO.ID_DESC)));
return TradeOrderConvert.INSTANCE.convertPage(pageTradeOrderResult);
}
}

View File

@ -0,0 +1,30 @@
package cn.iocoder.mall.tradeservice.enums.order;
import cn.iocoder.mall.tradeservice.rpc.order.dto.TradeOrderRespDTO;
/**
* 交易订单的明细的字段枚举
*
* @see TradeOrderRespDTO
*/
public enum TradeOrderDetailFieldEnum {
/**
* 交易订单项
*/
ITEM("item");
/**
* 字段
*/
private final String field;
TradeOrderDetailFieldEnum(String field) {
this.field = field;
}
public String getField() {
return field;
}
}

View File

@ -1,7 +1,12 @@
package cn.iocoder.mall.tradeservice.rpc.order;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.tradeservice.rpc.order.dto.TradeOrderCreateReqDTO;
import cn.iocoder.mall.tradeservice.rpc.order.dto.TradeOrderPageReqDTO;
import cn.iocoder.mall.tradeservice.rpc.order.dto.TradeOrderRespDTO;
import java.util.Collection;
/**
* 交易订单 Rpc 接口
@ -16,4 +21,23 @@ public interface TradeOrderRpc {
*/
CommonResult<Integer> createTradeOrder(TradeOrderCreateReqDTO createReqDTO);
/**
* 获得订单交易
*
* @param tradeOrderId 订单交易编号
* @param fields 额外返回字段可见 {@link cn.iocoder.mall.tradeservice.enums.order.TradeOrderDetailFieldEnum}
* @return 订单交易
*/
CommonResult<TradeOrderRespDTO> getTradeOrder(Integer tradeOrderId, Collection<String> fields);
/**
* 获得交易订单分页
*
* @param pageDTO 订单交易分页查询
* @return 订单交易分页结果
*/
CommonResult<PageResult<TradeOrderRespDTO>> pageTradeOrder(TradeOrderPageReqDTO pageDTO);
}

View File

@ -0,0 +1,101 @@
package cn.iocoder.mall.tradeservice.rpc.order.dto;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
/**
* 交易订单项 Response DTO
*/
@Data
@Accessors(chain = true)
public class TradeOrderItemRespDTO implements Serializable {
/**
* id自增长
*/
private Integer id;
/**
* 订单编号
*/
private Integer orderId;
/**
* 订单项状态
*/
private Integer status;
/**
* 商品 SKU 编号
*/
private Integer skuId;
/**
* 商品 SPU 编号
*/
private Integer spuId;
/**
* 商品名字
*/
private String skuName;
/**
* 图片名字
*/
private String skuImage;
/**
* 商品数量
*/
private Integer quantity;
/**
* 原始单价单位
*/
private Integer originPrice;
/**
* 购买单价单位
*/
private Integer buyPrice;
/**
* 最终价格单位
*/
private Integer presentPrice;
/**
* 购买总金额单位
*/
private Integer buyTotal;
/**
* 优惠总金额单位
*/
private Integer discountTotal;
/**
* 最终总金额单位
*/
private Integer presentTotal;
/**
* 退款总金额单位
*/
private Integer refundTotal;
/**
* 物流id
*/
private Integer logisticsId;
/**
* 售后状态
*/
private Integer afterSaleStatus;
/**
* 售后订单编号
*/
private Integer afterSaleOrderId;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
/**
* 删除状态
*/
private Integer deleted;
}

View File

@ -0,0 +1,45 @@
package cn.iocoder.mall.tradeservice.rpc.order.dto;
import cn.iocoder.common.framework.vo.PageParam;
import cn.iocoder.common.framework.vo.SortingField;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
/**
* 交易订单分页 Request DTO
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class TradeOrderPageReqDTO extends PageParam {
public static final SortingField ID_ASC = new SortingField("id", "asc");
public static final SortingField ID_DESC = new SortingField("id", "desc");
/**
* 用户编号
*/
private Integer userId;
/**
* 订单状态
*/
private Integer orderStatus;
/**
* 排序字段数组
*/
private List<SortingField> sorts;
/**
* 额外返回字段
*
* @see cn.iocoder.mall.tradeservice.enums.order.TradeOrderDetailFieldEnum
*/
private Collection<String> fields = Collections.emptySet();
}

View File

@ -0,0 +1,139 @@
package cn.iocoder.mall.tradeservice.rpc.order.dto;
import cn.iocoder.mall.tradeservice.enums.order.TradeOrderDetailFieldEnum;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* 交易订单 Response DTO
*/
@Data
@Accessors(chain = true)
public class TradeOrderRespDTO implements Serializable {
// ========== 订单基本信息 ==========
/**
* 订单编号
*/
private Integer id;
/**
* 用户编号
*/
private Integer userId;
/**
* 订单单号
*/
private String orderNo;
/**
* 订单状态
*/
private Integer orderStatus;
/**
* 备注
*/
private String remark;
/**
* 创建时间
*/
private Date createTime;
// ========== 价格 + 支付基本信息 ==========
/**
* 订单结束时间
*/
private Date endTime;
/**
* 订单金额(总金额)单位
*/
private Integer buyPrice;
/**
* 优惠总金额单位
*/
private Integer discountPrice;
/**
* 物流金额单位
*/
private Integer logisticsPrice;
/**
* 最终金额单位
*/
private Integer presentPrice;
/**
* 支付金额单位
*/
private Integer payPrice;
/**
* 退款金额单位
*/
private Integer refundPrice;
/**
* 付款时间
*/
private Date payTime;
/**
* 支付订单编号
*/
private Integer payTransactionId;
/**
* 支付渠道
*/
private Integer payChannel;
// ========== 收件 + 物流基本信息 ==========
/**
* 配送类型
*/
private Integer deliveryType;
/**
* 发货时间
*/
private Date deliveryTime;
/**
* 收货时间
*/
private Date receiveTime;
/**
* 收件人名称
*/
private String receiverName;
/**
* 手机号
*/
private String receiverMobile;
/**
* 地区编码
*/
private Integer receiverAreaCode;
/**
* 收件详细地址
*/
private String receiverDetailAddress;
// ========== 售后基本信息 ==========
/**
* 售后状态
*/
private Integer afterSaleStatus;
// ========== 营销基本信息 ==========
/**
* 优惠劵编号
*/
private Integer couponCardId;
// ========== 商品基本信息 ==========
/**
* 订单项数组
*
* 需要设置 {@link TradeOrderDetailFieldEnum#ITEM} 才返回
*
* // TODO 芋艿后续考虑怎么优化下目前是内嵌了别的 dto
*/
private List<TradeOrderItemRespDTO> orderItems;
}

View File

@ -0,0 +1,29 @@
package cn.iocoder.mall.tradeservice.convert.order;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.tradeservice.dal.mysql.dataobject.order.TradeOrderDO;
import cn.iocoder.mall.tradeservice.dal.mysql.dataobject.order.TradeOrderItemDO;
import cn.iocoder.mall.tradeservice.rpc.order.dto.TradeOrderItemRespDTO;
import cn.iocoder.mall.tradeservice.rpc.order.dto.TradeOrderRespDTO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
import java.util.List;
@Mapper
public interface TradeOrderConvert {
TradeOrderConvert INSTANCE = Mappers.getMapper(TradeOrderConvert.class);
TradeOrderRespDTO convert(TradeOrderDO bean);
@Mapping(source = "records", target = "list")
PageResult<TradeOrderRespDTO> convertPage(IPage<TradeOrderDO> page);
List<TradeOrderItemRespDTO> convertList(List<TradeOrderItemDO> list);
TradeOrderItemRespDTO convert(TradeOrderItemDO bean);
}

View File

@ -1,9 +1,11 @@
package cn.iocoder.mall.tradeservice.dal.mysql.mapper.order;
import cn.iocoder.mall.tradeservice.dal.mysql.dataobject.order.TradeOrderItemDO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.stereotype.Repository;
import java.util.Collection;
import java.util.List;
@Repository
@ -14,4 +16,8 @@ public interface TradeOrderItemMapper extends BaseMapper<TradeOrderItemDO> {
entities.forEach(this::insert);
}
default List<TradeOrderItemDO> selectListByOrderIds(Collection<Integer> orderIds) {
return selectList(new QueryWrapper<TradeOrderItemDO>().in("order_id", orderIds));
}
}

View File

@ -1,9 +1,20 @@
package cn.iocoder.mall.tradeservice.dal.mysql.mapper.order;
import cn.iocoder.mall.mybatis.core.query.QueryWrapperX;
import cn.iocoder.mall.mybatis.core.util.PageUtil;
import cn.iocoder.mall.tradeservice.dal.mysql.dataobject.order.TradeOrderDO;
import cn.iocoder.mall.tradeservice.rpc.order.dto.TradeOrderPageReqDTO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.stereotype.Repository;
@Repository
public interface TradeOrderMapper extends BaseMapper<TradeOrderDO> {
default IPage<TradeOrderDO> selectPage(TradeOrderPageReqDTO pageReqDTO) {
return selectPage(PageUtil.build(pageReqDTO, pageReqDTO.getSorts()),
new QueryWrapperX<TradeOrderDO>().eqIfPresent("user_id", pageReqDTO.getUserId())
.eqIfPresent("status", pageReqDTO.getOrderStatus()));
}
}

View File

@ -1,11 +1,16 @@
package cn.iocoder.mall.tradeservice.rpc.order;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.tradeservice.rpc.order.dto.TradeOrderCreateReqDTO;
import cn.iocoder.mall.tradeservice.rpc.order.dto.TradeOrderPageReqDTO;
import cn.iocoder.mall.tradeservice.rpc.order.dto.TradeOrderRespDTO;
import cn.iocoder.mall.tradeservice.service.order.TradeOrderService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Collection;
import static cn.iocoder.common.framework.vo.CommonResult.success;
/**
@ -22,4 +27,14 @@ public class TradeOrderRpcImpl implements TradeOrderRpc {
return success(tradeOrderService.createTradeOrder(createReqDTO));
}
@Override
public CommonResult<TradeOrderRespDTO> getTradeOrder(Integer tradeOrderId, Collection<String> fields) {
return success(tradeOrderService.getTradeOrder(tradeOrderId, fields));
}
@Override
public CommonResult<PageResult<TradeOrderRespDTO>> pageTradeOrder(TradeOrderPageReqDTO pageDTO) {
return success(tradeOrderService.pageTradeOrder(pageDTO));
}
}

View File

@ -1,6 +1,11 @@
package cn.iocoder.mall.tradeservice.service.order;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.tradeservice.rpc.order.dto.TradeOrderCreateReqDTO;
import cn.iocoder.mall.tradeservice.rpc.order.dto.TradeOrderPageReqDTO;
import cn.iocoder.mall.tradeservice.rpc.order.dto.TradeOrderRespDTO;
import java.util.Collection;
/**
* 交易订单 Service 接口
@ -15,4 +20,21 @@ public interface TradeOrderService {
*/
Integer createTradeOrder(TradeOrderCreateReqDTO createReqDTO);
/**
* 获得订单交易
*
* @param tradeOrderId 订单交易编号
* @param fields 额外返回字段可见 {@link cn.iocoder.mall.tradeservice.enums.order.TradeOrderDetailFieldEnum}
* @return 订单交易
*/
TradeOrderRespDTO getTradeOrder(Integer tradeOrderId, Collection<String> fields);
/**
* 获得订单交易分页
*
* @param pageReqDTO 订单交易分页查询
* @return 订单交易分页结果
*/
PageResult<TradeOrderRespDTO> pageTradeOrder(TradeOrderPageReqDTO pageReqDTO);
}

View File

@ -4,6 +4,7 @@ import cn.iocoder.common.framework.exception.util.ServiceExceptionUtil;
import cn.iocoder.common.framework.util.CollectionUtils;
import cn.iocoder.common.framework.util.DateUtil;
import cn.iocoder.common.framework.util.MathUtil;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.productservice.enums.sku.ProductSkuDetailFieldEnum;
import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuRespDTO;
import cn.iocoder.mall.promotion.api.rpc.price.dto.PriceProductCalcReqDTO;
@ -12,16 +13,21 @@ import cn.iocoder.mall.tradeservice.client.product.ProductSkuClient;
import cn.iocoder.mall.tradeservice.client.promotion.CouponCardClient;
import cn.iocoder.mall.tradeservice.client.promotion.PriceClient;
import cn.iocoder.mall.tradeservice.client.user.UserAddressClient;
import cn.iocoder.mall.tradeservice.convert.order.TradeOrderConvert;
import cn.iocoder.mall.tradeservice.dal.mysql.dataobject.order.TradeOrderDO;
import cn.iocoder.mall.tradeservice.dal.mysql.dataobject.order.TradeOrderItemDO;
import cn.iocoder.mall.tradeservice.dal.mysql.mapper.order.TradeOrderItemMapper;
import cn.iocoder.mall.tradeservice.dal.mysql.mapper.order.TradeOrderMapper;
import cn.iocoder.mall.tradeservice.enums.logistics.LogisticsDeliveryTypeEnum;
import cn.iocoder.mall.tradeservice.enums.order.TradeOrderAfterSaleStatusEnum;
import cn.iocoder.mall.tradeservice.enums.order.TradeOrderDetailFieldEnum;
import cn.iocoder.mall.tradeservice.enums.order.TradeOrderStatusEnum;
import cn.iocoder.mall.tradeservice.rpc.order.dto.TradeOrderCreateReqDTO;
import cn.iocoder.mall.tradeservice.rpc.order.dto.TradeOrderPageReqDTO;
import cn.iocoder.mall.tradeservice.rpc.order.dto.TradeOrderRespDTO;
import cn.iocoder.mall.tradeservice.service.order.TradeOrderService;
import cn.iocoder.mall.userservice.rpc.address.dto.UserAddressRespDTO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -29,8 +35,9 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.stream.Collectors;
import static cn.iocoder.mall.tradeservice.enums.OrderErrorCodeConstants.*;
import static cn.iocoder.mall.userservice.enums.UserErrorCodeConstants.*;
import static cn.iocoder.common.framework.util.CollectionUtils.convertSet;
import static cn.iocoder.mall.tradeservice.enums.OrderErrorCodeConstants.ORDER_GET_GOODS_INFO_INCORRECT;
import static cn.iocoder.mall.userservice.enums.UserErrorCodeConstants.USER_ADDRESS_NOT_FOUND;
/**
* 交易订单 Service 实现
@ -66,7 +73,7 @@ public class TradeOrderServiceImpl implements TradeOrderService {
}
// 获得商品信息
List<ProductSkuRespDTO> listProductSkus = productSkuClient.listProductSkus(
CollectionUtils.convertSet(createReqDTO.getOrderItems(), TradeOrderCreateReqDTO.OrderItem::getSkuId),
convertSet(createReqDTO.getOrderItems(), TradeOrderCreateReqDTO.OrderItem::getSkuId),
ProductSkuDetailFieldEnum.SPU.getField());
if (listProductSkus.size() != createReqDTO.getOrderItems().size()) { // 校验获得的数量是否匹配
throw ServiceExceptionUtil.exception(ORDER_GET_GOODS_INFO_INCORRECT);
@ -172,4 +179,43 @@ public class TradeOrderServiceImpl implements TradeOrderService {
;
}
@Override
public TradeOrderRespDTO getTradeOrder(Integer tradeOrderId, Collection<String> fields) {
// 查询交易订单
TradeOrderDO tradeOrderDO = tradeOrderMapper.selectById(tradeOrderId);
if (tradeOrderDO == null) {
return null;
}
TradeOrderRespDTO tradeOrderRespDTO = TradeOrderConvert.INSTANCE.convert(tradeOrderDO);
// 查询交易订单项
if (fields.contains(TradeOrderDetailFieldEnum.ITEM.getField())) {
List<TradeOrderItemDO> tradeOrderItemDOs = tradeOrderItemMapper.selectListByOrderIds(
Collections.singleton(tradeOrderDO.getId()));
tradeOrderRespDTO.setOrderItems(TradeOrderConvert.INSTANCE.convertList(tradeOrderItemDOs));
}
// 返回
return tradeOrderRespDTO;
}
@Override
public PageResult<TradeOrderRespDTO> pageTradeOrder(TradeOrderPageReqDTO pageReqDTO) {
// 查询交易订单分页
IPage<TradeOrderDO> tradeOrderDOPage = tradeOrderMapper.selectPage(pageReqDTO);
PageResult<TradeOrderRespDTO> pageResult = TradeOrderConvert.INSTANCE.convertPage(tradeOrderDOPage);
if (CollectionUtils.isEmpty(pageResult.getList())) {
return pageResult;
}
// 查询交易订单项们
if (pageReqDTO.getFields().contains(TradeOrderDetailFieldEnum.ITEM.getField())) {
List<TradeOrderItemDO> tradeOrderItemDOs = tradeOrderItemMapper.selectListByOrderIds(
convertSet(tradeOrderDOPage.getRecords(), TradeOrderDO::getId));
Map<Integer, List<TradeOrderItemDO>> tradeOrderItemDOMultiMap = CollectionUtils.convertMultiMap(
tradeOrderItemDOs, TradeOrderItemDO::getOrderId);
pageResult.getList().forEach(tradeOrderRespDTO -> tradeOrderRespDTO.setOrderItems(
TradeOrderConvert.INSTANCE.convertList(tradeOrderItemDOMultiMap.get(tradeOrderRespDTO.getId()))));
}
// 返回
return pageResult;
}
}