优惠劵模板相关逻辑的迁移

This commit is contained in:
YunaiV
2020-08-22 18:33:57 +08:00
parent 60b0043a78
commit 42c6389023
62 changed files with 154 additions and 224 deletions

View File

@@ -0,0 +1,136 @@
<?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-service-impl</artifactId>
<dependencies>
<!-- Mall 相关 -->
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>user-sdk</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>product-service-api</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>pay-service-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>order-service-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>system-service-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>user-service-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>promotion-service-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<!-- DB 相关 -->
<dependency>
<groupId>mysql</groupId>
<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>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
</dependency>
<!-- RPC 相关 -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-dubbo</artifactId>
</dependency>
<!-- Registry 和 Config 相关 -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<!-- Transaction 相关 -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-seata</artifactId>
</dependency>
<dependency>
<groupId>io.seata</groupId>
<artifactId>seata-spring-boot-starter</artifactId>
</dependency>
<!-- MQ 相关 -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-stream-rocketmq</artifactId>
</dependency>
<!-- Job 相关 -->
<dependency>
<groupId>com.xuxueli</groupId>
<artifactId>xxl-job-core</artifactId>
</dependency>
<!-- 工具类相关 -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<!-- 测试相关 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<!-- 提供给 mapstruct 使用 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,41 @@
package cn.iocoder.mall.order.biz.constants;
/**
* 发货类型/发货方式
*
* @author Sin
* @time 2019-04-05 16:03
*/
public enum OrderDeliveryTypeEnum {
NONE(1, "未选择"),
ORDER_ONLINE(2, "快递"),
CONTACT_YOURSELF(3, "自己联系"),
NO_DELIVERY(4, "无物流信息"),
;
private Integer value;
private String name;
OrderDeliveryTypeEnum(Integer value, String name) {
this.value = value;
this.name = name;
}
@Override
public String toString() {
return "OrderRecipientTypeEnum{" +
"value=" + value +
", name='" + name + '\'' +
'}';
}
public Integer getValue() {
return value;
}
public String getName() {
return name;
}
}

View File

@@ -0,0 +1,40 @@
package cn.iocoder.mall.order.biz.constants;
/**
* 订单换货原因
*
* @author Sin
* @time 2019-03-20 21:17
*/
public enum OrderExchangeReasonEnum {
REASON_000(0, "其他"),
REASON_001(1, "尺码不合适"),
REASON_002(2, "质量问题"),
REASON_003(3, "不喜欢"),
;
private Integer value;
private String name;
OrderExchangeReasonEnum(Integer value, String name) {
this.value = value;
this.name = name;
}
@Override
public String toString() {
return "OrderCommonReasonEnum{" +
"value=" + value +
", name=" + name +
'}';
}
public Integer getValue() {
return value;
}
public String getName() {
return name;
}}

View File

@@ -0,0 +1,39 @@
package cn.iocoder.mall.order.biz.constants;
/**
* 订单收件信息 type配送信息
*
* @author Sin
* @time 2019-04-05 16:03
*/
public enum OrderRecipientTypeEnum {
EXPRESS(1, "快递")
;
private Integer value;
private String name;
OrderRecipientTypeEnum(Integer value, String name) {
this.value = value;
this.name = name;
}
@Override
public String toString() {
return "OrderRecipientTypeEnum{" +
"value=" + value +
", name='" + name + '\'' +
'}';
}
public Integer getValue() {
return value;
}
public String getName() {
return name;
}
}

View File

@@ -0,0 +1,52 @@
package cn.iocoder.mall.order.biz.constants;
/**
* 订单退货原因
*
* @author Sin
* @time 2019-03-20 21:17
*/
public enum OrderReturnReasonEnum {
///
/// 未发货情况
REASON_000(0, "其他"),
REASON_001(1, "拍错/勿拍/多拍"),
REASON_002(2, "缺货"),
///
/// 已发货情况
REASON_020(20, "七天无理由"),
REASON_021(21, "质量问题"),
REASON_022(22, "不想要了"),
;
// TODO: 2019-03-20 Sin 已发货情况 补全,需要对照一下 淘宝
private Integer value;
private String name;
OrderReturnReasonEnum(Integer value, String name) {
this.value = value;
this.name = name;
}
@Override
public String toString() {
return "OrderCommonReasonEnum{" +
"value=" + value +
", name=" + name +
'}';
}
public Integer getValue() {
return value;
}
public String getName() {
return name;
}}

View File

@@ -0,0 +1,50 @@
package cn.iocoder.mall.order.biz.convert;
import cn.iocoder.mall.order.api.bo.OrderCommentCreateBO;
import cn.iocoder.mall.order.api.bo.OrderCommentInfoBO;
import cn.iocoder.mall.order.api.bo.OrderCommentStateInfoPageBO;
import cn.iocoder.mall.order.api.bo.OrderCommentTimeOutBO;
import cn.iocoder.mall.order.api.dto.OrderCommentCreateDTO;
import cn.iocoder.mall.order.biz.dataobject.OrderCommentDO;
import org.mapstruct.Mapper;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;
import java.util.List;
/**
*
* 订单评论 convert
*
* @author wtz
* @time 2019-05-31 18:30
*/
@Mapper
public interface OrderCommentConvert {
OrderCommentConvert INSTANCE = Mappers.getMapper(OrderCommentConvert.class);
@Mappings({})
OrderCommentStateInfoPageBO.OrderCommentStateInfoItem convertOrderCommentStateInfoItem(OrderCommentDO orderCommentDO);
@Mappings({})
List<OrderCommentStateInfoPageBO.OrderCommentStateInfoItem> convertOrderCommentStateInfoItems(List<OrderCommentDO> orderCommentDOList);
@Mappings({})
OrderCommentDO convertOrderCommentDO(OrderCommentCreateDTO orderCommentCreateDTO);
@Mappings({})
OrderCommentCreateBO convertOrderCommentCreateBO(OrderCommentDO orderCommentDO);
@Mappings({})
OrderCommentInfoBO convertOrderCommentInfoBO(OrderCommentDO orderCommentDO);
@Mappings({})
OrderCommentTimeOutBO convertOrderCommentTimeOutBO(OrderCommentDO orderCommentDO);
@Mappings({})
List<OrderCommentTimeOutBO> convertOrderCommentTimeOutBOList(List<OrderCommentDO> orderCommentDOList);
}

View File

@@ -0,0 +1,37 @@
package cn.iocoder.mall.order.biz.convert;
import cn.iocoder.mall.order.api.bo.OrderCommentMerchantReplyBO;
import cn.iocoder.mall.order.api.bo.OrderCommentReplyCreateBO;
import cn.iocoder.mall.order.api.bo.OrderCommentReplyPageBO;
import cn.iocoder.mall.order.api.dto.OrderCommentReplyCreateDTO;
import cn.iocoder.mall.order.biz.dataobject.OrderCommentReplyDO;
import org.mapstruct.Mapper;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;
import java.util.List;
/**
*
* 评论回复 convert
*
* @author wtz
* @time 2019-05-31 18:30
*/
@Mapper
public interface OrderCommentReplyConvert {
OrderCommentReplyConvert INSTANCE = Mappers.getMapper(OrderCommentReplyConvert.class);
@Mappings({})
OrderCommentReplyDO convert(OrderCommentReplyCreateDTO orderCommentReplyCreateDTO);
@Mappings({})
OrderCommentReplyCreateBO convert(OrderCommentReplyDO orderCommentReplyDO);
@Mappings({})
List<OrderCommentMerchantReplyBO> convert(List<OrderCommentReplyDO> orderCommentReplyDOList);
@Mappings({})
List<OrderCommentReplyPageBO.OrderCommentReplayItem> convertOrderCommentReplayItem(List<OrderCommentReplyDO> orderCommentReplyDOList);
}

View File

@@ -0,0 +1,28 @@
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

@@ -0,0 +1,39 @@
package cn.iocoder.mall.order.biz.convert;
import cn.iocoder.mall.order.api.bo.OrderInfoBO;
import cn.iocoder.mall.order.api.bo.OrderItemBO;
import cn.iocoder.mall.order.api.dto.OrderCreateDTO;
import cn.iocoder.mall.order.api.dto.OrderItemUpdateDTO;
import cn.iocoder.mall.order.biz.dataobject.OrderItemDO;
import org.mapstruct.Mapper;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;
import java.util.List;
/**
* 订单 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

@@ -0,0 +1,56 @@
package cn.iocoder.mall.order.biz.convert;
import cn.iocoder.mall.order.api.bo.OrderLastLogisticsInfoBO;
import cn.iocoder.mall.order.api.bo.OrderLogisticsInfoBO;
import cn.iocoder.mall.order.api.bo.OrderLogisticsInfoWithOrderBO;
import cn.iocoder.mall.order.api.dto.OrderDeliveryDTO;
import cn.iocoder.mall.order.api.dto.OrderLogisticsUpdateDTO;
import cn.iocoder.mall.order.biz.dataobject.OrderLogisticsDO;
import cn.iocoder.mall.order.biz.dataobject.OrderLogisticsDetailDO;
import cn.iocoder.mall.order.biz.dataobject.OrderRecipientDO;
import org.mapstruct.Mapper;
import org.mapstruct.Mappings;
import org.mapstruct.Named;
import org.mapstruct.factory.Mappers;
import java.util.List;
/**
* 订单物流 convert
*
* @author Sin
* @time 2019-03-23 14:39
*/
@Mapper
public interface OrderLogisticsConvert {
OrderLogisticsConvert INSTANCE = Mappers.getMapper(OrderLogisticsConvert.class);
@Mappings({})
OrderLogisticsDO convert(OrderDeliveryDTO orderDelivery);
@Mappings({})
OrderLogisticsDO convert(OrderLogisticsUpdateDTO orderLogisticsDTO);
@Mappings({})
OrderLogisticsDO convert(OrderRecipientDO orderRecipientDO);
@Mappings({})
List<OrderLogisticsInfoWithOrderBO.Logistics> convertLogistics(List<OrderLogisticsDO> orderLogisticsDOList);
@Mappings({})
List<OrderLogisticsInfoWithOrderBO.LogisticsDetail> convertLogisticsDetail(List<OrderLogisticsDetailDO> orderLogisticsDOList);
@Mappings({})
OrderLogisticsInfoBO convert(OrderLogisticsDO orderLogisticsDO);
@Mappings({})
List<OrderLogisticsInfoBO.LogisticsDetail> convert(List<OrderLogisticsDetailDO> orderLogisticsDetailDOList);
@Mappings({})
@Named(value = "orderLastLogisticsInfoBO")
OrderLastLogisticsInfoBO convertOrderLastLogisticsInfoBO(OrderLogisticsDO orderLogisticsDO);
@Mappings({})
OrderLastLogisticsInfoBO.LogisticsDetail convertLastLogisticsDetail(OrderLogisticsDetailDO orderLogisticsDetailDO);
}

View File

@@ -0,0 +1,25 @@
package cn.iocoder.mall.order.biz.convert;
import cn.iocoder.mall.order.api.bo.OrderInfoBO;
import cn.iocoder.mall.order.api.bo.OrderLogisticsInfoWithOrderBO;
import cn.iocoder.mall.order.biz.dataobject.OrderLogisticsDetailDO;
import org.mapstruct.Mapper;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;
import java.util.List;
/**
* 订单物流 convert
*
* @author Sin
* @time 2019-03-23 14:39
*/
@Mapper
public interface OrderLogisticsDetailConvert {
OrderLogisticsDetailConvert INSTANCE = Mappers.getMapper(OrderLogisticsDetailConvert.class);
@Mappings({})
OrderInfoBO.LogisticsDetail convertLogisticsDetail(OrderLogisticsDetailDO orderLogisticsDetailDO);
}

View File

@@ -0,0 +1,39 @@
package cn.iocoder.mall.order.biz.convert;
import cn.iocoder.mall.order.api.bo.OrderInfoBO;
import cn.iocoder.mall.order.api.bo.OrderRecipientBO;
import cn.iocoder.mall.order.api.dto.OrderCreateDTO;
import cn.iocoder.mall.order.biz.dataobject.OrderRecipientDO;
import cn.iocoder.mall.user.api.bo.UserAddressBO;
import org.mapstruct.Mapper;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;
import java.util.List;
/**
* 订单收件人信息
*
* @author Sin
* @time 2019-03-31 12:50
*/
@Mapper
public interface OrderRecipientConvert {
OrderRecipientConvert INSTANCE = Mappers.getMapper(OrderRecipientConvert.class);
@Mappings({})
OrderRecipientDO convert(OrderCreateDTO orderCreateDTO);
@Mappings({})
OrderRecipientDO convert(UserAddressBO userAddressBO);
@Mappings({})
OrderRecipientBO convert(OrderRecipientDO orderRecipientDO);
@Mappings({})
List<OrderRecipientBO> convert(List<OrderRecipientDO> orderRecipientDOList);
@Mappings({})
OrderInfoBO.Recipient convertOrderInfoRecipient(OrderRecipientDO orderRecipientDO);
}

View File

@@ -0,0 +1,40 @@
package cn.iocoder.mall.order.biz.convert;
import cn.iocoder.mall.order.api.bo.OrderReturnInfoBO;
import cn.iocoder.mall.order.api.bo.OrderReturnListBO;
import cn.iocoder.mall.order.api.dto.OrderReturnApplyDTO;
import cn.iocoder.mall.order.api.dto.OrderReturnCreateDTO;
import cn.iocoder.mall.order.biz.dataobject.OrderItemDO;
import cn.iocoder.mall.order.biz.dataobject.OrderReturnDO;
import org.mapstruct.Mapper;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;
import java.util.List;
/**
* 订单 return
*
* @author Sin
* @time 2019-03-30 15:46
*/
@Mapper
public interface OrderReturnConvert {
OrderReturnConvert INSTANCE = Mappers.getMapper(OrderReturnConvert.class);
@Mappings({})
OrderReturnDO convert(OrderReturnCreateDTO orderReturnCreate);
@Mappings({})
OrderReturnDO convert(OrderReturnApplyDTO orderReturnApplyDTO);
@Mappings({})
OrderReturnInfoBO.ReturnInfo convert(OrderReturnDO orderReturnDO);
@Mappings({})
List<OrderReturnInfoBO.OrderItem> convert(List<OrderItemDO> orderItemDOList);
@Mappings({})
List<OrderReturnListBO.OrderReturn> convertListBO(List<OrderReturnDO> orderReturnDOList);
}

View File

@@ -0,0 +1,17 @@
package cn.iocoder.mall.order.biz.dao;
import cn.iocoder.mall.order.biz.dataobject.OrderCancelDO;
import org.springframework.stereotype.Repository;
/**
* 订单取消 mapper
*
* @author Sin
* @time 2019-03-30 16:27
*/
@Repository
public interface OrderCancelMapper {
int insert(OrderCancelDO orderCancelDO);
}

View File

@@ -0,0 +1,92 @@
package cn.iocoder.mall.order.biz.dao;
import cn.iocoder.mall.order.api.bo.OrderCommentTimeOutBO;
import cn.iocoder.mall.order.api.dto.OrderCommentPageDTO;
import cn.iocoder.mall.order.api.dto.OrderCommentStateInfoPageDTO;
import cn.iocoder.mall.order.api.dto.OrderCommentTimeOutPageDTO;
import cn.iocoder.mall.order.biz.dataobject.OrderCommentDO;
import cn.iocoder.mall.order.biz.dataobject.OrderItemDO;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.Collection;
import java.util.List;
/**
*
* 订单评论 mapper
*
* @author wtz
* @time 2019-05-16 20:52
*/
@Repository
public interface OrderCommentMapper{
/**
* 插入订单评论
* @param orderCommentDO
* @return
*/
void insert(OrderCommentDO orderCommentDO);
/**
* 根据 sku id 查询评论总条数
* @param productSkuId
* @return
*/
int selectCommentTotalCountByProductSkuId(@Param("productSkuId") Integer productSkuId);
/**
* 分页获取评论
* @param orderCommentPageDTO
* @return
*/
List<OrderCommentDO> selectCommentPage(OrderCommentPageDTO orderCommentPageDTO);
/**
* 根据评论 id 查询评论详情
* @param id
* @return
*/
OrderCommentDO selectCommentInfoByCommentId(@Param("id") Integer id);
/**
* 订单评论状态信息详情
* @param orderCommentStateInfoPageDTO
* @return
*/
List<OrderCommentDO> selectOrderCommentStateInfoPage(OrderCommentStateInfoPageDTO orderCommentStateInfoPageDTO);
/**
* 订单评论状态总数
* @param userId,commentState
* @return
*/
int selectOrderCommentStateInfoTotal(@Param("userId") Integer userId,
@Param("commentState") Integer commentState);
/**
* 订单评论超时分页
* @param orderCommentTimeOutPageDTO
* @return
*/
List<OrderCommentDO> selectOrderCommentTimeOutPage(@Param("commentTimeOut") OrderCommentTimeOutPageDTO orderCommentTimeOutPageDTO);
/**
* 批量更新订单评论状态
* @param orderCommentTimeOutBOList
* @param commentState
*/
void updateBatchOrderCommentState(@Param("commentState") Integer commentState,
@Param("list") List<OrderCommentTimeOutBO> orderCommentTimeOutBOList);
}

View File

@@ -0,0 +1,63 @@
package cn.iocoder.mall.order.biz.dao;
import cn.iocoder.mall.order.api.bo.OrderCommentBO;
import cn.iocoder.mall.order.api.dto.OrderCommentReplyCreateDTO;
import cn.iocoder.mall.order.api.dto.OrderCommentReplyPageDTO;
import cn.iocoder.mall.order.biz.dataobject.OrderCommentReplyDO;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.Collection;
import java.util.List;
/**
* 订单评论回复 mapper
*
* @author wtz
* @time 2019-05-16 21:33
*/
@Repository
public interface OrderCommentReplayMapper {
/**
* 插入订单评论回复
* @param orderCommentReplyDO
* @return
*/
void insert(OrderCommentReplyDO orderCommentReplyDO);
/**
* 根据评论 id 和用户类型获取商家回复
* @param commentId,userType
* @return
*/
List<OrderCommentReplyDO> selectCommentMerchantReplyByCommentIdAndUserType(@Param("commentId") Integer commentId,
@Param("userType") Integer userType);
/**
* 分页获取评论回复
* @param orderCommentReplyPageDTO
* @return
*/
List<OrderCommentReplyDO> selectCommentReplyPage(OrderCommentReplyPageDTO orderCommentReplyPageDTO);
/**
* 根据评论 id 和用户类型获取评论回复总数
* @param commentId,userType
* @return
*/
int selectCommentReplyTotalCountByCommentId(@Param("commentId") Integer commentId,
@Param("userType") Integer userType);
/**
* 根据评论 id 查询最新的商家回复
* @param commentIds
* @return
*/
List<OrderCommentReplyDO> selectCommentNewMerchantReplyByCommentIds(@Param("commentIds") Collection<Integer> commentIds,
@Param("userType") Integer userType);
}

View File

@@ -0,0 +1,84 @@
package cn.iocoder.mall.order.biz.dao;
import cn.iocoder.mall.order.biz.dataobject.OrderItemDO;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.Collection;
import java.util.List;
/**
* 订单 item mapper
*
* @author Sin
* @time 2019-03-16 15:09
*/
@Repository
public interface OrderItemMapper {
/**
* 插入数据
*
* @param orderItemDOList
*/
void insert(@Param("list") List<OrderItemDO> orderItemDOList);
/**
* 更新 - 根据Id
*
* @param orderItemDO
*/
void updateById(@Param("orderItemDO") OrderItemDO orderItemDO);
/**
* 更新 - 根据 orderId
* @param orderId
* @param orderItemDO
*/
void updateByOrderId(
@Param("orderId") Integer orderId,
@Param("orderItemDO") OrderItemDO orderItemDO
);
/**
* 更新 - 根据Ids
*
* @param ids
* @param orderItemDO
*/
void updateByIds(
@Param("ids") List<Integer> ids,
@Param("orderItemDO") OrderItemDO orderItemDO
);
/**
* 获取 - 根据 ids 查询
*
* @param ids
* @return
*/
List<OrderItemDO> selectByIds(@Param("ids") Collection<Integer> ids);
/**
* 查询 - 根据 orderIds 和 status
*
* @param orderIds
* @param deleted
* @return
*/
List<OrderItemDO> selectByDeletedAndOrderIds(
@Param("orderIds") Collection<Integer> orderIds,
@Param("deleted") Integer deleted
);
/**
* 查询 - 根据 orderId 下的 item
*
* @param orderId
* @return
*/
List<OrderItemDO> selectByDeletedAndOrderId(
@Param("deleted") Integer deleted,
@Param("orderId") Integer orderId
);
}

View File

@@ -0,0 +1,66 @@
package cn.iocoder.mall.order.biz.dao;
import cn.iocoder.mall.order.biz.dataobject.OrderLogisticsDetailDO;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.Collection;
import java.util.List;
/**
* 订单物流 - 物流详细信息
*
* @author Sin
* @time 2019-04-12 21:35
*/
@Repository
public interface OrderLogisticsDetailMapper {
/**
* 插入
*
* @param orderLogisticsDetailDO
* @return
*/
int insert(OrderLogisticsDetailDO orderLogisticsDetailDO);
/**
* 查询 - 根据 物流id
*
* @param orderLogisticsId
* @return
*/
List<OrderLogisticsDetailDO> selectByOrderLogisticsId(
@Param("orderLogisticsId") Integer orderLogisticsId
);
/**
* 查询 - 根据 物流ids
*
* @param orderLogisticsIds
* @return
*/
List<OrderLogisticsDetailDO> selectByOrderLogisticsIds(
@Param("orderLogisticsIds") Collection<Integer> orderLogisticsIds
);
/**
* 查询 - 获取最新的物流信息
*
* @param orderLogisticsIds
* @return
*/
OrderLogisticsDetailDO selectLast(
@Param("orderLogisticsIds") Collection<Integer> orderLogisticsIds
);
/**
* 查询 - 根据 last 根据物理id
*
* @param orderLogisticsId
* @return
*/
OrderLogisticsDetailDO selectLastByLogisticsId(
@Param("orderLogisticsId") Integer orderLogisticsId
);
}

View File

@@ -0,0 +1,53 @@
package cn.iocoder.mall.order.biz.dao;
import cn.iocoder.mall.order.biz.dataobject.OrderLogisticsDO;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.Collection;
import java.util.List;
/**
* 订单 item mapper
*
* @author Sin
* @time 2019-03-16 15:09
*/
@Repository
public interface OrderLogisticsMapper {
/**
* 插入数据
*
* @param orderLogisticsDO
*/
void insert(OrderLogisticsDO orderLogisticsDO);
/**
* 更新 - 根据id
*
* @param orderLogisticsDO
*/
void updateById(OrderLogisticsDO orderLogisticsDO);
/**
* 查询 - 根据 ids
*
* @param id
* @return
*/
OrderLogisticsDO selectById(
@Param("id") Integer id
);
/**
* 查询 - 根据 ids
*
* @param ids
* @return
*/
List<OrderLogisticsDO> selectByIds(
@Param("ids") Collection<Integer> ids
);
}

View File

@@ -0,0 +1,57 @@
package cn.iocoder.mall.order.biz.dao;
import cn.iocoder.mall.order.api.dto.OrderQueryDTO;
import cn.iocoder.mall.order.biz.dataobject.OrderDO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* 订单 mapper
*
* @author Sin
* @time 2019-03-16 15:09
*/
@Repository
public interface OrderMapper extends BaseMapper<OrderDO> {
/**
* 更新 - 根据 id 更新
*
* @param orderDO
* @return
*/
int updateById(OrderDO orderDO);
int updateByIdAndStatus(@Param("id") Integer id,
@Param("status") Integer status,
@Param("updateObj") OrderDO updateObj);
/**
* 查询 - 根据id 查询
*
* @param id
* @return
*/
OrderDO selectById(
@Param("id") Integer id
);
/**
* 查询 - 后台分页page
*
* @param orderQueryDTO
* @return
*/
int selectPageCount(OrderQueryDTO orderQueryDTO);
/**
* 查询 - 后台分页page
*
* @param orderQueryDTO
* @return
*/
List<OrderDO> selectPage(OrderQueryDTO orderQueryDTO);
}

View File

@@ -0,0 +1,47 @@
package cn.iocoder.mall.order.biz.dao;
import cn.iocoder.mall.order.biz.dataobject.OrderRecipientDO;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.Collection;
import java.util.List;
/**
* 订单收件人 信息
*
* @author Sin
* @time 2019-03-31 12:16
*/
@Repository
public interface OrderRecipientMapper {
/**
* 插入 - 订单收件人
*
* @param orderRecipient
* @return
*/
int insert(OrderRecipientDO orderRecipient);
/**
* 查询 - 根据 orderId
*
* @param orderId
* @return
*/
OrderRecipientDO selectByOrderId(
@Param("orderId") Integer orderId
);
/**
* 查询 - 根据 orderIds
*
* @param orderIds
* @return
*/
List<OrderRecipientDO> selectByOrderIds(
@Param("orderIds")Collection<Integer> orderIds
);
}

View File

@@ -0,0 +1,68 @@
package cn.iocoder.mall.order.biz.dao;
import cn.iocoder.mall.order.api.dto.OrderReturnQueryDTO;
import cn.iocoder.mall.order.biz.dataobject.OrderReturnDO;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* 订单退货 mapper
*
* @author Sin
* @time 2019-03-30 15:36
*/
@Repository
public interface OrderReturnMapper {
/**
* 插入 - 退货信息
*
* @param orderReturnDO
* @return
*/
int insert(OrderReturnDO orderReturnDO);
/**
* 更新 - 根据 orderId
*
* @param orderReturnDO
* @return
*/
int updateById(OrderReturnDO orderReturnDO);
/**
* 查询 - 根据 orderId
*
* @param orderId
* @return
*/
OrderReturnDO selectByOrderId(
@Param("orderId") Integer orderId
);
/**
* 列表查询 - queryDTO
*
* @param queryDTO
* @return
*/
int selectListCount(OrderReturnQueryDTO queryDTO);
/**
* 列表查询 - queryDTO
*
* @param queryDTO
* @return
*/
List<OrderReturnDO> selectList(OrderReturnQueryDTO queryDTO);
/**
* 查询 - 根据 id 查询
*
* @param id
* @return
*/
OrderReturnDO selectById(Integer id);
}

View File

@@ -0,0 +1,41 @@
package cn.iocoder.mall.order.biz.dataobject;
import cn.iocoder.common.framework.dataobject.BaseDO;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* 订单关闭
*
* - 注意:订单只有在用户为付款前取消。
*
* - 取消订单,这里是取消整个订单,不能对订单 item 单独做取消
*
* @author Sin
* @time 2019-03-30 16:20
*/
@Data
@Accessors(chain = true)
public class OrderCancelDO extends BaseDO {
/**
* id
*/
private Integer id;
/**
* 订单id
*/
private Integer orderId;
/**
* 订单编号
*/
private String orderNo;
/**
* 关闭订单原因(字典)
*/
private Integer reason;
/**
* 原因(如果选择其他,原因保存在这)
*/
private String otherReason;
}

View File

@@ -0,0 +1,125 @@
package cn.iocoder.mall.order.biz.dataobject;
import cn.iocoder.common.framework.dataobject.BaseDO;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* 订单评论表
*
* @author wtz
* @time 2019-05-14 20:48
*
*/
@Data
@Accessors(chain = true)
@TableName(value = "order_comment")
public class OrderCommentDO extends BaseDO {
/**
* 评论 id // TODO FROM 芋艿 TO wtz 中英文之间,要有空格
*/
private Integer id;
/**
* 订单 id
*/
private Integer orderId;
/**
* 订单编号
*/
private String orderNo;
/**
* 商品 id
*/
private Integer productSpuId;
/**
* 商品名称
*/
private String productSpuName;
/**
* 商品 sku id
*/
private Integer productSkuId;
/**
* 商品 sku 属性
*/
private String productSkuAttrs;
/**
* 商品 sku 价格
*/
private Integer productSkuPrice;
/**
* 商品 sku url
*/
private String productSkuPicUrl;
/**
* 用户id
*/
private Integer userId;
/**
* 用户头像
*/
private String userAvatar;
/**
* 用户的真实姓名
*/
private String userNickName;
/**
* 评价星
*/
private Integer star;
/**
* 商品描述
*/
private Integer productDescriptionStar;
/**
* 物流评价
*/
private Integer logisticsStar;
/**
* 商家评价
*/
private Integer merchantStar;
/**
* 回复条数
*/
private Integer replayCount;
/**
* 点赞数 // TODO FROM 芋艿 TO wtz collect 是收藏的意思,最好换个单词噢。
*/
private Integer likeCount;
/**
* 评论的内容
*/
private String commentContent;
/**
* 评论的图片地址
*/
private String commentPics;
/**
* 订单评论状态
*/
private Integer commentState;
}

View File

@@ -0,0 +1,87 @@
package cn.iocoder.mall.order.biz.dataobject;
import cn.iocoder.common.framework.dataobject.BaseDO;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* 商品评价回复表
*
* // TODO FROM 芋艿 TO wtz 商品评价回复表 =》订单评论回复表
*
* @author wtz
* @time 2019-05-14 21:00
*
*/
@Data
@Accessors(chain = true)
@TableName(value = "order_comment_replay")
public class OrderCommentReplyDO extends BaseDO {
/**
* 回复 id
*/
private Integer id;
/**
* 评论 id
*/
private Integer commentId;
/**
* 回复的类型 // TODO FROM 芋艿 TO wtz 记得加下枚举类
*/
private Integer replyType;
/**
* 父 id
*/
private Integer parentId;
/**
* 回复目标用户 id
*/
private Integer parentUserId;
/**
* 回复目标用户昵称
*/
private String parentUserNickName;
/**
* 回复目标用户头像
*/
private String parentUserAvatar;
/**
* 回复的内容
*/
private String replyContent;
/**
* 回复用户 id
*/
private Integer replyUserId;
/**
* 回复用户昵称
*/
private String replyUserNickName;
/**
* 回复用户头像
*/
private String replyUserAvatar;
/**
* 回复用户身份 // TODO FROM 芋艿 TO wtz 【提示】userType 和 UserTypeEnum 记录保持一致。
*/
private Integer userType;
/**
* 回复点赞数
*/
private Integer replyLikeCount;
}

View File

@@ -0,0 +1,105 @@
package cn.iocoder.mall.order.biz.dataobject;
import cn.iocoder.common.framework.dataobject.DeletableDO;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Date;
/**
* 订单
*
* @author Sin
* @time 2019-03-16 13:49
*/
@Data
@Accessors(chain = true)
@TableName(value = "orders")
public class OrderDO extends DeletableDO {
/**
* 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;
///
/// 其他
/**
* 是否退货
*
* - 1、没有
* - 2、换货
* - 3、退货
* - 4、换货 + 退货
*/
private Integer hasReturnExchange;
/**
* 状态(如果有多个商品分开发货需要全部商品发完才会改变状态)
*
* - 1、待付款
* - 2、待发货
* - 3、待收获
* - 4、已完成
* - 5、已关闭
*/
private Integer status;
/**
* 备注
*/
private String remark;
}

View File

@@ -0,0 +1,114 @@
package cn.iocoder.mall.order.biz.dataobject;
import cn.iocoder.common.framework.dataobject.DeletableDO;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Date;
/**
* 换货订单
*
* @author Sin
* @time 2019-03-19 19:48
*/
@Data
@Accessors(chain = true)
public class OrderExchangeDO extends DeletableDO {
/**
* id
*/
private Integer id;
/**
* 订单id
*/
private Integer orderId;
/**
* 订单编号
*/
private String orderNo;
/**
* 订单 item 编号
*/
private Integer orderItemId;
/**
* 商品id保存一个冗余如果一个订单下存在多个商品会有很大的作用
*/
private String skuId;
/**
* 换货商品id
*/
private String exchangeSkuId;
/**
* 换货物流id
*/
private Integer exchangeOrderLogisticsId;
/**
* 收件物流id
*/
private Integer receiverOrderLogisticsId;
///
/// 原因
/**
* 原因 (关联字典)
*
* {@link cn.iocoder.mall.order.biz.constants.OrderExchangeReasonEnum}
*/
private Integer orderReasonId;
/**
* 原因(如果选择其他,原因保存在这)
*
* {@link cn.iocoder.mall.order.biz.constants.OrderExchangeReasonEnum#REASON_000}
*/
private String reason;
///
/// 时间信息
/**
* 创建时间
* supper baseDO
*/
// private Date createTime;
/**
* 付款时间
*/
private Date paymentTime;
/**
* 发货时间
*/
private Date deliveryTime;
/**
* 收货时间
*/
private Date receiverTime;
/**
* 成交时间
*/
private Date closingTime;
///
/// 其他
/**
* 订单类型
*
* - 0、为 Order 订单 (对整个订单退货)
* - 1、为 OrderItem 订单 (对订单某一个商品退货)
*/
private Integer orderType;
/**
* 状态
*
* - 申请换货
* - 申请成功
* - 申请失败
* - 换货中
* - 换货成功
*/
private Integer status;
}

View File

@@ -0,0 +1,144 @@
package cn.iocoder.mall.order.biz.dataobject;
import cn.iocoder.common.framework.dataobject.DeletableDO;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Date;
/**
* 订单 item
*
* @author Sin
* @time 2019-03-16 14:03
*/
@Data
@Accessors(chain = true)
public class OrderItemDO extends DeletableDO {
/**
* 编号
*/
private Integer id;
/**
* 订单编号
*/
private Integer orderId;
/**
* 订单号
*/
private String orderNo;
/**
* 商品编号
*/
private Integer skuId;
/**
* 物流id
*/
private Integer orderLogisticsId;
/**
* 商品名称
*/
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;
// 如上字段,举个例子:
// 假设购买三个,即 quantity = 3 。
// originPrice = 15
// 使用限时折扣单品优惠8 折buyPrice = 12
// 开始算总的价格
// buyTotal = buyPrice * quantity = 12 * 3 = 36
// discountTotal ,假设有满减送(分组优惠)满 20 减 10 ,并且使用优惠劵满 1.01 减 1 ,则 discountTotal = 10 + 1 = 11
// presentTotal = buyTotal - discountTotal = 24 - 11 = 13
// 最终 presentPrice = presentTotal / quantity = 13 / 3 = 4.33
///
/// 时间信息
/**
* 付款时间
*/
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;
}

View File

@@ -0,0 +1,46 @@
package cn.iocoder.mall.order.biz.dataobject;
import cn.iocoder.common.framework.dataobject.BaseDO;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* 订单物流信息
*
* @author Sin
* @time 2019-03-19 20:47
*/
@Data
@Accessors(chain = true)
public class OrderLogisticsDO extends BaseDO {
/**
* id
*/
private Integer id;
/**
* 收件区域编号
*/
private String areaNo;
/**
* 收件人名称
*/
private String name;
/**
* 收件手机号
*/
private String mobile;
/**
* 收件详细地址
*/
private String address;
/**
* 物流 (字典)
*/
private Integer logistics;
/**
* 物流编号
*/
private String logisticsNo;
}

View File

@@ -0,0 +1,38 @@
package cn.iocoder.mall.order.biz.dataobject;
import cn.iocoder.common.framework.dataobject.DeletableDO;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Date;
/**
* 订单物流 - 详细信息
*
* - 同步第三方物流信息
*
* @author Sin
* @time 2019-03-19 20:48
*/
@Data
@Accessors(chain = true)
public class OrderLogisticsDetailDO extends DeletableDO {
/**
* id
*/
private Integer id;
/**
* 物流id
*/
private Integer orderLogisticsId;
/**
* 物流时间
*/
private Date logisticsTime;
/**
* 物流信息
*/
private String logisticsInformation;
}

View File

@@ -0,0 +1,46 @@
package cn.iocoder.mall.order.biz.dataobject;
/**
* 订单优惠明细
*/
// TODO 芋艿 后续在完善
public class OrderPreferentialDO {
/**
* 编号
*/
private Integer id;
/**
* 类型
*
* 1 - 促销活动
* 2 - 优惠劵
*/
private Integer type;
// TODO 芋艿 优惠劵编号 or 促销活动编号
/**
* 订单编号
*/
private Integer orderId;
/**
* 商品 SPU 编号
*/
private Integer spuId;
/**
* 商品 SKU 编号
*/
private Integer skuId;
/**
* 商品数量
*/
private Integer quantity;
/**
* 传入时的价格
*/
private Integer originTotal;
/**
* 总优惠价格
*/
private Integer discountTotal;
}

View File

@@ -0,0 +1,48 @@
package cn.iocoder.mall.order.biz.dataobject;
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 OrderRecipientDO extends BaseDO {
/**
* 编号
*/
private Integer id;
/**
* 订单id
*/
private Integer orderId;
/**
* 收件区域编号
*/
private String areaNo;
/**
* 收件人名称
*/
private String name;
/**
* 收件手机号
*/
private String mobile;
/**
* 配送类型
*
* - 1 快递
*/
private Integer type;
/**
* 收件详细地址
*/
private String address;
}

View File

@@ -0,0 +1,103 @@
package cn.iocoder.mall.order.biz.dataobject;
import cn.iocoder.common.framework.dataobject.BaseDO;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Date;
/**
* 退货订单
*
* @author Sin
* @time 2019-03-19 19:48
*/
@Data
@Accessors(chain = true)
public class OrderReturnDO extends BaseDO {
// TODO FROM 芋艿 TO 小范,存储下支付中心的退款单号
/**
* 编号自动增长
*/
private Integer id;
/**
* 服务号
*/
// TODO FROM 芋艿 to 小范,换个名字,看着怪怪的 哈哈哈哈。
private String serviceNumber;
/**
* 订单编号
*/
private Integer orderId;
/**
* 订单号 (保存一个冗余)
*/
private String orderNo;
/**
* 物流id
*/
private Integer orderLogisticsId;
///
/// 退货原因
/**
* 退货金额
*/
private Integer refundPrice;
/**
* 退货原因(字典值)
*
* {@link cn.iocoder.mall.order.biz.constants.OrderReturnReasonEnum}
*/
private Integer reason;
/**
* 问题描述
*/
// TODO FROM 芋艿 to 小范describe 是动词,换成名词 description
private String describe;
///
/// 时间信息
/**
* 同意时间
*/
private Date approvalTime;
/**
* 拒绝时间
*/
private Date refuseTime;
/**
* 物流时间(填写物流单号时间)
*/
private Date logisticsTime;
/**
* 收货时间
*/
private Date receiverTime;
/**
* 成交时间(确认时间)
*/
private Date closingTime;
/**
* 服务类型
*
* - 1、退货退款
* - 2、退款
*/
private Integer serviceType;
/**
* 状态
*
* - 1、退货申请
* - 2、申请成功
* - 3、申请失败
* - 4、退货中
* - 5、已收货
* - 6、退货成功
*/
private Integer status;
}

View File

@@ -0,0 +1,21 @@
## 订单
TODO
**退货**
1. 商家未发货,退货原因
- 拍错/勿拍/多拍
- 缺货
2. 商家已发货,退货原因
- 七天无理由
- 质量问题
- 不想要了
- 其他

View File

@@ -0,0 +1,67 @@
package cn.iocoder.mall.order.biz.job;
import cn.iocoder.mall.order.api.OrderCommentService;
import cn.iocoder.mall.order.api.bo.OrderCommentTimeOutBO;
import cn.iocoder.mall.order.api.constant.OrderCommentStatusEnum;
import cn.iocoder.mall.order.api.dto.OrderCommentTimeOutPageDTO;
import cn.iocoder.mall.order.biz.dao.OrderCommentMapper;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.IJobHandler;
import com.xxl.job.core.handler.annotation.JobHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.stream.Collectors;
/**
* 超时以后自动生成评论
*
* @author wtz
* @time 2019-06-15 10:26
*/
@Component
@JobHandler("automaticCommentJob")
public class AutomaticCommentJob extends IJobHandler {
/**
* 默认生成订单7天以后的自动生成订单评论
*/
private static final Integer OVERDAYCOUNT=7;
private static final Integer PAGESIZE=1000;
@Autowired
private OrderCommentService orderCommentService;
@Override
public ReturnT<String> execute(String param) throws Exception {
Integer overDayCount=OVERDAYCOUNT;
if (param.isEmpty()){
overDayCount=Integer.parseInt(param);
}
for (int i=0;;i++){
OrderCommentTimeOutPageDTO orderCommentTimeOutPageDTO=new OrderCommentTimeOutPageDTO();
orderCommentTimeOutPageDTO.setOverDay(overDayCount);
orderCommentTimeOutPageDTO.setCommentState(OrderCommentStatusEnum.WAIT_COMMENT.getValue());
orderCommentTimeOutPageDTO.setPageNo(i);
orderCommentTimeOutPageDTO.setPageSize(PAGESIZE);
List<OrderCommentTimeOutBO> orderCommentTimeOutBOList=orderCommentService.getOrderCommentTimeOutPage(orderCommentTimeOutPageDTO);
//为空时候跳出循环
if (orderCommentTimeOutBOList.isEmpty()){
break;
}
//批量更新
orderCommentService.updateBatchOrderCommentState(orderCommentTimeOutBOList);
}
return null;
}
}

View File

@@ -0,0 +1,85 @@
package cn.iocoder.mall.order.biz.service;
import cn.iocoder.mall.order.api.OrderCommentReplyService;
import cn.iocoder.mall.order.api.bo.OrderCommentMerchantReplyBO;
import cn.iocoder.mall.order.api.bo.OrderCommentReplyCreateBO;
import cn.iocoder.mall.order.api.bo.OrderCommentReplyPageBO;
import cn.iocoder.mall.order.api.constant.OrderCommentRelpyTypeEnum;
import cn.iocoder.mall.order.api.constant.OrderReplyUserTypeEnum;
import cn.iocoder.mall.order.api.dto.OrderCommentReplyCreateDTO;
import cn.iocoder.mall.order.api.dto.OrderCommentReplyPageDTO;
import cn.iocoder.mall.order.biz.convert.OrderCommentReplyConvert;
import cn.iocoder.mall.order.biz.dao.OrderCommentReplayMapper;
import cn.iocoder.mall.order.biz.dataobject.OrderCommentReplyDO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
*
* 订单评论回复 service impl
*
* @author wtz
* @time 2019-05-31 18:30
*/
@Service
@org.apache.dubbo.config.annotation.Service(validation = "true",version = "${dubbo.provider.OrderCommentReplyService.version}")
public class OrderCommentReplyServiceImpl implements OrderCommentReplyService {
@Autowired
private OrderCommentReplayMapper orderCommentReplayMapper;
/**
* 分页获取评论回复
* @param orderCommentReplyPageDTO
* @return
*/
@Override
public OrderCommentReplyPageBO getOrderCommentReplyPage(OrderCommentReplyPageDTO orderCommentReplyPageDTO) {
OrderCommentReplyPageBO orderCommentReplyPageBO=new OrderCommentReplyPageBO();
//评论回复总数
Integer totalCount=orderCommentReplayMapper.selectCommentReplyTotalCountByCommentId(orderCommentReplyPageDTO.getCommentId(),
orderCommentReplyPageDTO.getUserType());
//分页获取评论回复
List<OrderCommentReplyDO> orderCommentReplyDOList=orderCommentReplayMapper.selectCommentReplyPage(orderCommentReplyPageDTO);
orderCommentReplyPageBO.setTotal(totalCount);
orderCommentReplyPageBO.setOrderCommentReplayItems(OrderCommentReplyConvert.INSTANCE.convertOrderCommentReplayItem(orderCommentReplyDOList));
return orderCommentReplyPageBO;
}
/**
* 创建评论回复
* @param orderCommentReplyCreateDTO
* @return
*/
@Override
public OrderCommentReplyCreateBO createOrderCommentReply(OrderCommentReplyCreateDTO orderCommentReplyCreateDTO) {
OrderCommentReplyDO orderCommentReplyDO=OrderCommentReplyConvert.INSTANCE.convert(orderCommentReplyCreateDTO);
orderCommentReplyDO.setCreateTime(new Date());
Integer replyType=orderCommentReplyCreateDTO.getCommentId()==orderCommentReplyCreateDTO.getParentId()?
OrderCommentRelpyTypeEnum.COMMENT_REPLY.getValue():OrderCommentRelpyTypeEnum.REPLY_REPLY.getValue();
orderCommentReplyDO.setReplyType(replyType);
orderCommentReplayMapper.insert(orderCommentReplyDO);
return OrderCommentReplyConvert.INSTANCE.convert(orderCommentReplyDO);
}
/**
* 获取商家评论回复
* @param commentId
* @return
*/
@Override
public List<OrderCommentMerchantReplyBO> getOrderCommentMerchantReply(Integer commentId) {
List<OrderCommentReplyDO> orderCommentReplyDOList=orderCommentReplayMapper.selectCommentMerchantReplyByCommentIdAndUserType(commentId,
OrderReplyUserTypeEnum.MERCHANT.getValue());
return OrderCommentReplyConvert.INSTANCE.convert(orderCommentReplyDOList);
}
}

View File

@@ -0,0 +1,110 @@
package cn.iocoder.mall.order.biz.service;
import cn.iocoder.mall.order.api.OrderCommentService;
import cn.iocoder.mall.order.api.bo.*;
import cn.iocoder.mall.order.api.constant.OrderCommentStatusEnum;
import cn.iocoder.mall.order.api.constant.OrderReplyUserTypeEnum;
import cn.iocoder.mall.order.api.dto.OrderCommentCreateDTO;
import cn.iocoder.mall.order.api.dto.OrderCommentPageDTO;
import cn.iocoder.mall.order.api.dto.OrderCommentStateInfoPageDTO;
import cn.iocoder.mall.order.api.dto.OrderCommentTimeOutPageDTO;
import cn.iocoder.mall.order.biz.convert.OrderCommentConvert;
import cn.iocoder.mall.order.biz.dao.OrderCommentMapper;
import cn.iocoder.mall.order.biz.dao.OrderCommentReplayMapper;
import cn.iocoder.mall.order.biz.dataobject.OrderCommentDO;
import cn.iocoder.mall.order.biz.dataobject.OrderCommentReplyDO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
*
* 订单评论 service impl
*
* @author wtz
* @time 2019
*/
@Service
@org.apache.dubbo.config.annotation.Service(validation = "true", version = "${dubbo.provider.OrderCommentService.version}")
public class OrderCommentServiceImpl implements OrderCommentService {
@Autowired
private OrderCommentMapper orderCommentMapper;
@Autowired
private OrderCommentReplayMapper orderCommentReplayMapper;
@Override
public OrderCommentCreateBO createOrderComment(OrderCommentCreateDTO orderCommentCreateDTO) {
OrderCommentDO orderCommentDO=OrderCommentConvert.INSTANCE.convertOrderCommentDO(orderCommentCreateDTO);
orderCommentDO.setCreateTime(new Date());
orderCommentMapper.insert(orderCommentDO);
return OrderCommentConvert.INSTANCE.convertOrderCommentCreateBO(orderCommentDO);
}
@Override
public OrderCommentPageBO getOrderCommentPage(OrderCommentPageDTO orderCommentPageDTO) {
OrderCommentPageBO orderCommentPageBO=new OrderCommentPageBO();
//分页内容
List<OrderCommentDO> orderCommentDOList=orderCommentMapper.selectCommentPage(orderCommentPageDTO);
//分页评论的 id
List<Integer> commentIds=orderCommentDOList.stream().map(x->x.getId()).collect(Collectors.toList());
//获取商家最新的评论回复
List<OrderCommentReplyDO> orderCommentReplyDOList=orderCommentReplayMapper.selectCommentNewMerchantReplyByCommentIds(commentIds,
OrderReplyUserTypeEnum.MERCHANT.getValue());
//评论组装
List<OrderCommentPageBO.OrderCommentItem> orderCommentItemList=orderCommentDOList.stream()
.flatMap(x->orderCommentReplyDOList.stream()
.filter(y->x.getId()==y.getCommentId())
.map(y->new OrderCommentPageBO.OrderCommentItem(x.getId(),x.getUserAvatar(),x.getUserNickName(),x.getStar(),
x.getCommentContent(),x.getCommentPics(),x.getReplayCount(),x.getLikeCount(),x.getCreateTime(),y.getReplyContent()))
).collect(Collectors.toList());
//总数
int totalCount=orderCommentMapper.selectCommentTotalCountByProductSkuId(orderCommentPageDTO.getProductSkuId());
orderCommentPageBO.setOrderCommentItems(orderCommentItemList);
orderCommentPageBO.setTotal(totalCount);
return orderCommentPageBO;
}
@Override
public OrderCommentInfoBO getOrderCommentInfo(Integer commentId) {
//查询评论详情
OrderCommentDO orderCommentDO=orderCommentMapper.selectCommentInfoByCommentId(commentId);
return OrderCommentConvert.INSTANCE.convertOrderCommentInfoBO(orderCommentDO);
}
@Override
public OrderCommentStateInfoPageBO getOrderCommentStateInfoPage(OrderCommentStateInfoPageDTO orderCommentStateInfoPageDTO) {
OrderCommentStateInfoPageBO orderCommentStateInfoPageBO=new OrderCommentStateInfoPageBO();
//总数
int total=orderCommentMapper.selectOrderCommentStateInfoTotal(orderCommentStateInfoPageDTO.getUserId(),
orderCommentStateInfoPageDTO.getCommentState());
//查询评论状态详情
List<OrderCommentDO> orderCommentDOList=orderCommentMapper.selectOrderCommentStateInfoPage(orderCommentStateInfoPageDTO);
//转化评论状态详情
List<OrderCommentStateInfoPageBO.OrderCommentStateInfoItem> orderCommentStateInfoItemList=
OrderCommentConvert.INSTANCE.convertOrderCommentStateInfoItems(orderCommentDOList);
orderCommentStateInfoPageBO.setTotal(total);
orderCommentStateInfoPageBO.setOrderCommentStateInfoItems(orderCommentStateInfoItemList);
return orderCommentStateInfoPageBO;
}
@Override
public List<OrderCommentTimeOutBO> getOrderCommentTimeOutPage(OrderCommentTimeOutPageDTO orderCommentTimeOutPageDTO) {
List<OrderCommentDO> orderCommentDOList=orderCommentMapper.selectOrderCommentTimeOutPage(orderCommentTimeOutPageDTO);
return OrderCommentConvert.INSTANCE.convertOrderCommentTimeOutBOList(orderCommentDOList);
}
@Override
public void updateBatchOrderCommentState(List<OrderCommentTimeOutBO> orderCommentTimeOutBOList) {
orderCommentMapper.updateBatchOrderCommentState(OrderCommentStatusEnum.SUCCESS_COMMENT.getValue(),orderCommentTimeOutBOList);
}
}

View File

@@ -0,0 +1,154 @@
package cn.iocoder.mall.order.biz.service;
import cn.iocoder.common.framework.enums.DeletedStatusEnum;
import cn.iocoder.common.framework.util.DateUtil;
import cn.iocoder.common.framework.util.ServiceExceptionUtil;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.order.api.OrderLogisticsService;
import cn.iocoder.mall.order.api.bo.OrderLastLogisticsInfoBO;
import cn.iocoder.mall.order.api.bo.OrderLogisticsInfoBO;
import cn.iocoder.mall.order.api.bo.OrderLogisticsInfoWithOrderBO;
import cn.iocoder.mall.order.api.constant.OrderErrorCodeEnum;
import cn.iocoder.mall.order.biz.convert.OrderLogisticsConvert;
import cn.iocoder.mall.order.biz.dao.OrderItemMapper;
import cn.iocoder.mall.order.biz.dao.OrderLogisticsDetailMapper;
import cn.iocoder.mall.order.biz.dao.OrderLogisticsMapper;
import cn.iocoder.mall.order.biz.dao.OrderMapper;
import cn.iocoder.mall.order.biz.dataobject.OrderDO;
import cn.iocoder.mall.order.biz.dataobject.OrderItemDO;
import cn.iocoder.mall.order.biz.dataobject.OrderLogisticsDO;
import cn.iocoder.mall.order.biz.dataobject.OrderLogisticsDetailDO;
import com.google.common.collect.Lists;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.*;
import java.util.stream.Collectors;
/**
* 订单物流
*
* @author Sin
* @time 2019-04-12 21:32
*/
@Service
@org.apache.dubbo.config.annotation.Service(validation = "true", version = "${dubbo.provider.OrderLogisticsService.version}")
public class OrderLogisticsServiceImpl implements OrderLogisticsService {
@Autowired
private OrderMapper orderMapper;
@Autowired
private OrderItemMapper orderItemMapper;
@Autowired
private OrderLogisticsMapper orderLogisticsMapper;
@Autowired
private OrderLogisticsDetailMapper orderLogisticsDetailMapper;
@Override
public CommonResult<OrderLogisticsInfoBO> getLogisticsInfo(Integer id) {
OrderLogisticsDO orderLogisticsDO = orderLogisticsMapper.selectById(id);
if (orderLogisticsDO == null) {
return CommonResult.success(null);
}
List<OrderLogisticsDetailDO> orderLogisticsDetailDOList = orderLogisticsDetailMapper
.selectByOrderLogisticsId(orderLogisticsDO.getId());
// 转换数据结构
List<OrderLogisticsInfoBO.LogisticsDetail> logisticsDetails
= OrderLogisticsConvert.INSTANCE.convert(orderLogisticsDetailDOList);
OrderLogisticsInfoBO orderLogisticsInfo2BO = OrderLogisticsConvert.INSTANCE.convert(orderLogisticsDO);
orderLogisticsInfo2BO.setDetails(logisticsDetails);
return CommonResult.success(orderLogisticsInfo2BO);
}
@Override
public CommonResult<OrderLastLogisticsInfoBO> getLastLogisticsInfo(Integer id) {
OrderLogisticsDO orderLogisticsDO = orderLogisticsMapper.selectById(id);
if (orderLogisticsDO == null) {
return CommonResult.success(null);
}
OrderLogisticsDetailDO orderLastLogisticsDetailDO = orderLogisticsDetailMapper.selectLastByLogisticsId(id);
// 转换数据结构
OrderLastLogisticsInfoBO.LogisticsDetail lastLogisticsDetail
= OrderLogisticsConvert.INSTANCE.convertLastLogisticsDetail(orderLastLogisticsDetailDO);
OrderLastLogisticsInfoBO lastLogisticsInfoBO = OrderLogisticsConvert
.INSTANCE.convertOrderLastLogisticsInfoBO(orderLogisticsDO);
lastLogisticsInfoBO.setLastLogisticsDetail(lastLogisticsDetail);
return CommonResult.success(lastLogisticsInfoBO);
}
@Override
public CommonResult<OrderLogisticsInfoWithOrderBO> getOrderLogisticsInfo(Integer userId, Integer orderId) {
OrderDO orderDO = orderMapper.selectById(orderId);
if (orderDO == null) {
return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_NOT_EXISTENT.getCode());
}
if (!userId.equals(orderDO.getUserId())) {
return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_NOT_USER_ORDER.getCode());
}
// 获取订单所发货的订单 id
List<OrderItemDO> orderItemDOList = orderItemMapper.selectByDeletedAndOrderId(
DeletedStatusEnum.DELETED_NO.getValue(), orderId);
// 获取物流 信息
Set<Integer> orderLogisticsIds = orderItemDOList.stream()
.filter(o -> o.getOrderLogisticsId() != null)
.map(o -> o.getOrderLogisticsId())
.collect(Collectors.toSet());
List<OrderLogisticsDO> orderLogisticsDOList = Collections.emptyList();
List<OrderLogisticsDetailDO> orderLogisticsDetailDOList = Collections.emptyList();
if (!CollectionUtils.isEmpty(orderLogisticsIds)) {
orderLogisticsDOList = orderLogisticsMapper.selectByIds(orderLogisticsIds);
orderLogisticsDetailDOList = orderLogisticsDetailMapper.selectByOrderLogisticsIds(orderLogisticsIds);
}
// 转换 return 的数据
List<OrderLogisticsInfoWithOrderBO.Logistics> logistics
= OrderLogisticsConvert.INSTANCE.convertLogistics(orderLogisticsDOList);
List<OrderLogisticsInfoWithOrderBO.LogisticsDetail> logisticsDetails
= OrderLogisticsConvert.INSTANCE.convertLogisticsDetail(orderLogisticsDetailDOList);
logisticsDetails.stream().map(o -> {
o.setLogisticsTimeText(DateUtil.format(o.getLogisticsTime(), "yyyy-MM-dd HH:mm"));
return o;
}).collect(Collectors.toList());
Map<Integer, List<OrderLogisticsInfoWithOrderBO.LogisticsDetail>> logisticsDetailMultimap
= logisticsDetails.stream().collect(
Collectors.toMap(
o -> o.getOrderLogisticsId(),
item -> Lists.newArrayList(item),
(oldVal, newVal) -> {
oldVal.addAll(newVal);
return oldVal;
}
)
);
logistics.stream().map(o -> {
if (logisticsDetailMultimap.containsKey(o.getId())) {
o.setDetails(logisticsDetailMultimap.get(o.getId()));
}
return o;
}).collect(Collectors.toList());
return CommonResult.success(
new OrderLogisticsInfoWithOrderBO()
.setOrderId(orderId)
.setOrderNo(orderDO.getOrderNo())
.setLogistics(logistics)
);
}
}

View File

@@ -0,0 +1,265 @@
package cn.iocoder.mall.order.biz.service;
import cn.iocoder.common.framework.enums.DeletedStatusEnum;
import cn.iocoder.common.framework.util.ServiceExceptionUtil;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.system.api.DataDictService;
import cn.iocoder.mall.system.api.bo.datadict.DataDictBO;
import cn.iocoder.mall.order.api.OrderLogisticsService;
import cn.iocoder.mall.order.api.OrderReturnService;
import cn.iocoder.mall.order.api.bo.OrderLastLogisticsInfoBO;
import cn.iocoder.mall.order.api.bo.OrderReturnInfoBO;
import cn.iocoder.mall.order.api.bo.OrderReturnListBO;
import cn.iocoder.mall.order.api.constant.*;
import cn.iocoder.mall.order.api.dto.OrderReturnApplyDTO;
import cn.iocoder.mall.order.api.dto.OrderReturnQueryDTO;
import cn.iocoder.mall.order.biz.convert.OrderReturnConvert;
import cn.iocoder.mall.order.biz.dao.OrderItemMapper;
import cn.iocoder.mall.order.biz.dao.OrderMapper;
import cn.iocoder.mall.order.biz.dao.OrderReturnMapper;
import cn.iocoder.mall.order.biz.dataobject.OrderDO;
import cn.iocoder.mall.order.biz.dataobject.OrderItemDO;
import cn.iocoder.mall.order.biz.dataobject.OrderReturnDO;
import cn.iocoder.mall.pay.api.PayRefundService;
import cn.iocoder.mall.pay.api.dto.refund.PayRefundSubmitDTO;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.UUID;
/**
* 订单退货 service
*
* @author Sin
* @time 2019-03-30 15:35
*/
@Service
@org.apache.dubbo.config.annotation.Service(validation = "true", version = "${dubbo.provider.OrderReturnService.version}")
public class OrderReturnServiceImpl implements OrderReturnService {
@Autowired
private OrderMapper orderMapper;
@Autowired
private OrderItemMapper orderItemMapper;
@Autowired
private OrderReturnMapper orderReturnMapper;
@Autowired
private OrderLogisticsService orderLogisticsService;
@Reference(validation = "true", version = "${dubbo.consumer.PayRefundService.version}")
private PayRefundService payRefundService;
@Reference(validation = "true", version = "${dubbo.consumer.DataDictService.version}")
private DataDictService dataDictService;
@Override
public CommonResult orderReturnApply(OrderReturnApplyDTO orderReturnDTO) {
OrderDO checkOrder = orderMapper.selectById(orderReturnDTO.getOrderId());
// 检查订单是否 存在
if (checkOrder == null) {
return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_NOT_EXISTENT.getCode());
}
// 转换 DO
OrderReturnDO orderReturnDO = OrderReturnConvert.INSTANCE.convert(orderReturnDTO);
orderReturnDO
.setOrderId(checkOrder.getId())
// TODO: 2019-04-27 Sin 服务号生成规则
.setServiceNumber(UUID.randomUUID().toString().replaceAll("-", "").substring(0, 16))
.setOrderNo(checkOrder.getOrderNo())
.setStatus(OrderReturnStatusEnum.RETURN_APPLICATION.getValue())
.setCreateTime(new Date());
// 保存申请信息
orderReturnMapper.insert(orderReturnDO);
return CommonResult.success(null);
}
@Override
public String updateRefundSuccess(String orderId, Integer refundPrice) {
return "success";
}
@Override
public CommonResult<OrderReturnInfoBO> orderApplyInfo(Integer orderId) {
// 检查订单是否退货
OrderReturnDO orderReturnDO = orderReturnMapper.selectByOrderId(orderId);
if (orderReturnDO == null) {
return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_RETURN_NO_RETURN_APPLY.getCode());
}
List<OrderItemDO> orderItemDOList = orderItemMapper
.selectByDeletedAndOrderId(DeletedStatusEnum.DELETED_NO.getValue(), orderId);
// 订单不存在
if (CollectionUtils.isEmpty(orderItemDOList)) {
return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_NOT_EXISTENT.getCode());
}
// 转换 returnInfo
OrderReturnInfoBO.ReturnInfo returnInfo = OrderReturnConvert.INSTANCE.convert(orderReturnDO);
List<OrderReturnInfoBO.OrderItem> itemList = OrderReturnConvert.INSTANCE.convert(orderItemDOList);
// 物流信息
CommonResult<OrderLastLogisticsInfoBO> lastLogisticsCommonResult = orderLogisticsService
.getLastLogisticsInfo(orderReturnDO.getOrderLogisticsId());
if (lastLogisticsCommonResult.isError()) {
return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_LOGISTICS_INVOKING_FAIL.getCode());
}
OrderLastLogisticsInfoBO lastLogisticsInfoBO = lastLogisticsCommonResult.getData();
OrderReturnInfoBO orderReturnInfoBO = new OrderReturnInfoBO()
.setOrderItems(itemList)
.setReturnInfo(returnInfo)
.setLastLogisticsInfo(lastLogisticsInfoBO);
return CommonResult.success(orderReturnInfoBO);
}
@Override
public CommonResult<OrderReturnListBO> orderReturnList(OrderReturnQueryDTO queryDTO) {
int totalCount = orderReturnMapper.selectListCount(queryDTO);
if (totalCount <= 0) {
return CommonResult.success(
new OrderReturnListBO()
.setData(Collections.EMPTY_LIST)
.setIndex(queryDTO.getIndex())
.setPageSize(queryDTO.getPageSize())
.setTotalCount(0)
);
}
List<OrderReturnDO> orderReturnDOList = orderReturnMapper.selectList(queryDTO);
List<OrderReturnListBO.OrderReturn> orderReturnListBOList
= OrderReturnConvert.INSTANCE.convertListBO(orderReturnDOList);
return CommonResult.success(
new OrderReturnListBO()
.setData(orderReturnListBOList)
.setIndex(queryDTO.getIndex())
.setPageSize(queryDTO.getPageSize())
.setTotalCount(totalCount)
);
}
@Override
public CommonResult orderReturnAgree(Integer id) {
OrderReturnDO orderReturnDO = orderReturnMapper.selectById(id);
if (orderReturnDO == null) {
return ServiceExceptionUtil
.error(OrderErrorCodeEnum.ORDER_RETURN_NOT_EXISTENT.getCode());
}
orderReturnMapper.updateById(
new OrderReturnDO()
.setId(id)
.setApprovalTime(new Date())
.setStatus(OrderReturnStatusEnum.APPLICATION_SUCCESSFUL.getValue())
);
return CommonResult.success(null);
}
@Override
public CommonResult orderReturnRefuse(Integer id) {
OrderReturnDO orderReturnDO = orderReturnMapper.selectById(id);
if (orderReturnDO == null) {
return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_RETURN_NOT_EXISTENT.getCode());
}
orderReturnMapper.updateById(
new OrderReturnDO()
.setId(id)
.setRefuseTime(new Date())
.setStatus(OrderReturnStatusEnum.APPLICATION_FAIL.getValue())
);
return CommonResult.success(null);
}
@Override
public CommonResult confirmReceipt(Integer id) {
OrderReturnDO orderReturnDO = orderReturnMapper.selectById(id);
if (orderReturnDO == null) {
return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_RETURN_NOT_EXISTENT.getCode());
}
orderReturnMapper.updateById(
new OrderReturnDO()
.setId(id)
.setReceiverTime(new Date())
.setStatus(OrderReturnStatusEnum.ORDER_RECEIPT.getValue())
);
return CommonResult.success(null);
}
@Override
@Transactional
public CommonResult refund(Integer id, String ip) {
OrderReturnDO orderReturnDO = orderReturnMapper.selectById(id);
if (orderReturnDO == null) {
return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_RETURN_NOT_EXISTENT.getCode());
}
// TODO: 2019/5/8 sin, 发送 MQ 消息,申请退货成功!
// TODO: 2019/5/8 sin 退款:支付系统退款
// TODO: 2019/5/8 sin 退货+退款:退回商品签收后,支付系统退款
// TODO: 2019/5/8 sin 事务一致性 [重要]
CommonResult<DataDictBO> dataDictResult = dataDictService
.getDataDict(DictKeyConstants.ORDER_RETURN_REASON, orderReturnDO.getReason());
if (dataDictResult.isError()) {
return ServiceExceptionUtil.error(OrderErrorCodeEnum.DICT_SERVER_INVOKING_FAIL.getCode());
}
// 支付退款
String orderDescription = dataDictResult.getData()
.getDisplayName() + "(" + orderReturnDO.getDescribe() + ")";
CommonResult payResult = payRefundService.submitRefund(
new PayRefundSubmitDTO()
.setAppId(PayAppId.APP_ID_SHOP_ORDER)
.setOrderId(String.valueOf(orderReturnDO.getOrderId()))
.setPrice(orderReturnDO.getRefundPrice())
.setOrderDescription(orderDescription)
.setCreateIp(ip)
);
if (!payResult.isSuccess()) {
return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_RETURN_REFUND_FAILED.getCode());
}
// 更新 订单退货 信息
orderReturnMapper.updateById(
new OrderReturnDO()
.setId(id)
.setClosingTime(new Date())
.setStatus(OrderReturnStatusEnum.RETURN_SUCCESS.getValue())
);
// 更新订单
orderMapper.updateById(
new OrderDO()
.setId(orderReturnDO.getOrderId())
.setClosingTime(new Date())
.setStatus(OrderStatusEnum.COMPLETED.getValue())
);
// 更新订单
orderItemMapper.updateByOrderId(
orderReturnDO.getOrderId(),
new OrderItemDO()
.setClosingTime(new Date())
.setStatus(OrderStatusEnum.COMPLETED.getValue())
);
return CommonResult.success(null);
}
}

View File

@@ -0,0 +1,634 @@
package cn.iocoder.mall.order.biz.service;
import cn.iocoder.common.framework.enums.DeletedStatusEnum;
import cn.iocoder.common.framework.util.DateUtil;
import cn.iocoder.common.framework.util.ServiceExceptionUtil;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.order.api.OrderService;
import cn.iocoder.mall.order.api.bo.*;
import cn.iocoder.mall.order.api.constant.*;
import cn.iocoder.mall.order.api.dto.*;
import cn.iocoder.mall.order.biz.constants.OrderDeliveryTypeEnum;
import cn.iocoder.mall.order.biz.constants.OrderRecipientTypeEnum;
import cn.iocoder.mall.order.biz.convert.*;
import cn.iocoder.mall.order.biz.dao.*;
import cn.iocoder.mall.order.biz.dataobject.*;
import cn.iocoder.mall.pay.api.PayTransactionService;
import cn.iocoder.mall.pay.api.bo.transaction.PayTransactionBO;
import cn.iocoder.mall.pay.api.dto.transaction.PayTransactionCreateDTO;
import cn.iocoder.mall.product.api.ProductSpuService;
import cn.iocoder.mall.product.api.bo.ProductSkuDetailBO;
import cn.iocoder.mall.promotion.api.CouponService;
import cn.iocoder.mall.user.api.UserAddressService;
import cn.iocoder.mall.user.api.bo.UserAddressBO;
import io.seata.spring.annotation.GlobalTransactional;
import org.apache.dubbo.config.annotation.Reference;
import com.google.common.collect.Lists;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import java.util.*;
import java.util.stream.Collectors;
/**
* 订单 service impl
*
* @author Sin
* @time 2019-03-16 15:08
*/
@Service
@org.apache.dubbo.config.annotation.Service(validation = "true", version = "${dubbo.provider.OrderService.version}")
public class OrderServiceImpl implements OrderService {
/**
* 支付过期时间 120 分钟
*/
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);
if (orderDO == null) {
return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_NOT_EXISTENT.getCode());
}
List<OrderItemDO> itemDOList = orderItemMapper
.selectByDeletedAndOrderId(DeletedStatusEnum.DELETED_NO.getValue(), orderId);
List<OrderInfoBO.OrderItem> orderItems
= OrderItemConvert.INSTANCE.convertOrderInfoWithOrderItem(itemDOList);
Set<Integer> orderLogisticsIds = itemDOList.stream()
.filter(o -> o.getOrderLogisticsId() != null)
.map(o -> o.getOrderLogisticsId())
.collect(Collectors.toSet());
// 收件人信息
OrderRecipientDO orderRecipientDO = orderRecipientMapper.selectByOrderId(orderId);
// 订单物流信息
OrderLogisticsDetailDO orderLogisticsDetailDO = null;
if (!CollectionUtils.isEmpty(orderLogisticsIds)) {
orderLogisticsDetailDO = orderLogisticsDetailMapper.selectLast(orderLogisticsIds);
}
// 检查是否申请退货
OrderReturnDO orderReturnDO = orderReturnMapper.selectByOrderId(orderId);
// convert 信息
OrderInfoBO.LogisticsDetail logisticsDetail
= OrderLogisticsDetailConvert.INSTANCE.convertLogisticsDetail(orderLogisticsDetailDO);
OrderInfoBO.Recipient recipient = OrderRecipientConvert.INSTANCE.convertOrderInfoRecipient(orderRecipientDO);
OrderInfoBO orderInfoBO = OrderConvert.INSTANCE.convert(orderDO);
orderInfoBO.setRecipient(recipient);
orderInfoBO.setOrderItems(orderItems);
orderInfoBO.setLatestLogisticsDetail(logisticsDetail);
// 是否退货
if (orderReturnDO != null) {
orderInfoBO.setHasOrderReturn(orderReturnDO.getStatus());
} else {
orderInfoBO.setHasOrderReturn(-1);
}
return CommonResult.success(orderInfoBO);
}
@Override
@GlobalTransactional
// @Transactional // 使用 Seata 分布事务后,无需在使用 @Transactional 注解。
public CommonResult<OrderCreateBO> createOrder(OrderCreateDTO orderCreateDTO) {
Integer userId = orderCreateDTO.getUserId();
List<OrderCreateDTO.OrderItem> orderItemDTOList = orderCreateDTO.getOrderItems();
List<OrderItemDO> orderItemDOList = OrderItemConvert.INSTANCE.convert(orderItemDTOList);
// 获取商品信息
Set<Integer> skuIds = orderItemDOList.stream().map(OrderItemDO::getSkuId).collect(Collectors.toSet());
List<ProductSkuDetailBO> productList = productSpuService.getProductSkuDetailList(skuIds);
if (orderItemDTOList.size() != productList.size()) { // 校验获得的数量,是否匹配
return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_GET_GOODS_INFO_INCORRECT.getCode());
}
// 价格计算
CalcOrderPriceBO calcOrderPrice = calcOrderPrice(productList, orderCreateDTO);
// 设置 orderItem
Map<Integer, ProductSkuDetailBO> productSpuBOMap = productList
.stream().collect(Collectors.toMap(ProductSkuDetailBO::getId, o -> o)); // 商品 SKU 信息的集合
Map<Integer, CalcOrderPriceBO.Item> priceItemMap = new HashMap<>(); // 商品 SKU 价格的映射
calcOrderPrice.getItemGroups().forEach(itemGroup ->
itemGroup.getItems().forEach(item -> priceItemMap.put(item.getId(), item)));
// 遍历 orderItemDOList 数组,将商品信息、商品价格,设置到其中
for (OrderItemDO orderItemDO : orderItemDOList) {
ProductSkuDetailBO productSkuDetailBO = productSpuBOMap.get(orderItemDO.getSkuId());
if (productSkuDetailBO.getQuantity() <= 0) {
return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_INSUFFICIENT_INVENTORY.getCode());
}
if (productSkuDetailBO.getPrice() <= 0) {
return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_GOODS_AMOUNT_INCORRECT.getCode());
}
// 设置 SKU 信息
orderItemDO.setSkuImage(Optional.ofNullable(productSkuDetailBO.getSpu().getPicUrls().get(0)).get());
orderItemDO.setSkuName(productSkuDetailBO.getSpu().getName());
// 设置价格信息
CalcOrderPriceBO.Item priceItem = priceItemMap.get(orderItemDO.getSkuId());
Assert.notNull(priceItem, "商品计算价格为空");
orderItemDO.setOriginPrice(priceItem.getOriginPrice())
.setBuyPrice(priceItem.getBuyPrice())
.setPresentPrice(priceItem.getPresentPrice())
.setBuyTotal(priceItem.getBuyTotal())
.setDiscountTotal(priceItem.getDiscountTotal())
.setPresentTotal(priceItem.getPresentTotal());
}
// 标记优惠劵已使用
if (orderCreateDTO.getCouponCardId() != null) {
couponService.useCouponCard(userId, orderCreateDTO.getCouponCardId());
}
// TODO 芋艿,扣除库存
// order
// TODO: 2019-04-11 Sin 订单号需要生成规则
// TODO FROM 芋艿 to 小范:可以考虑抽象成一个方法,下面几个也是。
String orderNo = UUID.randomUUID().toString().replace("-", "").substring(0, 16);
// Integer totalAmount = orderCommon.calculatedAmount(orderItemDOList);
// Integer totalPrice = orderCommon.calculatedPrice(orderItemDOList);
// Integer totalLogisticsPrice = orderCommon.calculatedLogisticsPrice(orderItemDOList);
OrderDO orderDO = new OrderDO()
.setUserId(userId)
.setOrderNo(orderNo)
.setBuyPrice(calcOrderPrice.getFee().getBuyTotal())
.setDiscountPrice(calcOrderPrice.getFee().getDiscountTotal())
.setLogisticsPrice(calcOrderPrice.getFee().getPostageTotal())
.setPresentPrice(calcOrderPrice.getFee().getPresentTotal())
.setPayAmount(0)
.setClosingTime(null)
.setDeliveryTime(null)
.setPaymentTime(null)
.setStatus(OrderStatusEnum.WAITING_PAYMENT.getValue())
.setHasReturnExchange(OrderHasReturnExchangeEnum.NO.getValue())
.setRemark(Optional.ofNullable(orderCreateDTO.getRemark()).orElse(""));
orderDO.setDeleted(DeletedStatusEnum.DELETED_NO.getValue());
// orderDO.setCreateTime(new Date());
// orderDO.setUpdateTime(null);
orderMapper.insert(orderDO);
// 收件人信息
CommonResult<UserAddressBO> userAddressResult = userAddressService.getAddress(userId, orderCreateDTO.getUserAddressId());
if (userAddressResult.isError()) {
return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_GET_USER_ADDRESS_FAIL.getCode());
}
UserAddressBO userAddressBO = userAddressResult.getData();
OrderRecipientDO orderRecipientDO = OrderRecipientConvert.INSTANCE.convert(userAddressBO);
orderRecipientDO
.setOrderId(orderDO.getId())
.setType(OrderRecipientTypeEnum.EXPRESS.getValue())
.setCreateTime(new Date())
.setUpdateTime(null);
orderRecipientMapper.insert(orderRecipientDO);
// order item
orderItemDOList.forEach(orderItemDO -> {
orderItemDO
.setOrderId(orderDO.getId())
.setOrderNo(orderDO.getOrderNo())
.setPaymentTime(null)
.setDeliveryTime(null)
.setReceiverTime(null)
.setClosingTime(null)
.setHasReturnExchange(OrderStatusEnum.WAITING_PAYMENT.getValue())
.setDeliveryType(OrderDeliveryTypeEnum.NONE.getValue())
.setStatus(OrderStatusEnum.WAITING_PAYMENT.getValue())
.setDeleted(DeletedStatusEnum.DELETED_NO.getValue())
.setCreateTime(new Date())
.setUpdateTime(null);
});
// 一次性插入
orderItemMapper.insert(orderItemDOList);
// 创建预订单
createPayTransaction(orderDO, orderItemDOList, orderCreateDTO.getIp());
// if (commonResult.isError()) {
// //手动开启事务回滚
// TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
// return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_GET_PAY_FAIL.getValue());
// }
// TODO: 2019-03-17 Sin 需要发送 创建成果 MQ 消息,业务扩展和统计
return CommonResult.success(
new OrderCreateBO()
.setId(orderDO.getId())
.setOrderNo(orderDO.getOrderNo())
.setPayAmount(orderDO.getPayAmount())
);
}
private CalcOrderPriceBO calcOrderPrice(List<ProductSkuDetailBO> skus, OrderCreateDTO orderCreateDTO) {
// 创建计算的 DTO
CalcOrderPriceDTO calcOrderPriceDTO = new CalcOrderPriceDTO()
.setUserId(orderCreateDTO.getUserId())
.setItems(new ArrayList<>(skus.size()))
.setCouponCardId(orderCreateDTO.getCouponCardId());
for (OrderCreateDTO.OrderItem item : orderCreateDTO.getOrderItems()) {
calcOrderPriceDTO.getItems().add(new CalcOrderPriceDTO.Item(item.getSkuId(), item.getQuantity(), true));
}
// 执行计算
return cartService.calcOrderPrice(calcOrderPriceDTO);
}
private PayTransactionBO createPayTransaction(OrderDO order, List<OrderItemDO> orderItems, String ip) {
// TODO sin 支付订单 orderSubject 暂时取第一个子订单商品信息
String orderSubject = orderItems.get(0).getSkuName();
Date expireTime = DateUtil.addDate(Calendar.MINUTE, PAY_EXPIRE_TIME);
return payTransactionService.createTransaction(
new PayTransactionCreateDTO()
.setCreateIp(ip)
.setAppId(PayAppId.APP_ID_SHOP_ORDER)
.setOrderId(order.getId().toString())
.setExpireTime(expireTime)
.setPrice(order.getPresentPrice())
.setOrderSubject(orderSubject)
.setOrderMemo("测试备注") // TODO 芋艿,后面补充
.setOrderDescription("测试描述") // TODO 芋艿,后面补充
);
}
@Override // TODO 芋艿,需要确认下这个方法的用途。因为涉及修改价格和数量。
public CommonResult updateOrderItem(OrderItemUpdateDTO orderUpdateDTO) {
OrderItemDO orderItemDO = OrderItemConvert.INSTANCE.convert(orderUpdateDTO);
orderItemMapper.updateById(orderItemDO);
// TODO: 2019-03-24 sin 需要重新计算金额
// TODO: 2019-03-24 sin 需要记录日志
return CommonResult.success(null);
}
@Override
@Transactional
public CommonResult updateOrderItemPayAmount(Integer orderId, Integer orderItemId, Integer payAmount) {
OrderDO orderDO = orderMapper.selectById(orderId);
if (orderDO == null) {
return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_NOT_EXISTENT.getCode());
}
if (payAmount < 0) {
return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_PAY_AMOUNT_NOT_NEGATIVE.getCode());
}
// 先更新金额
orderItemMapper.updateById(new OrderItemDO().setId(orderItemId)
// .setPayAmount(payAmount) TODO 芋艿,这里要修改
);
// 再重新计算订单金额
List<OrderItemDO> orderItemDOList = orderItemMapper
.selectByDeletedAndOrderId(DeletedStatusEnum.DELETED_NO.getValue(), orderId);
// Integer price = orderCommon.calculatedPrice(orderItemDOList);
// Integer amount = orderCommon.calculatedAmount(orderItemDOList);
Integer price = -1; // TODO 芋艿,这里要修改,价格
Integer amount = -1;
orderMapper.updateById(
new OrderDO()
.setId(orderId)
// .setPrice(price) TODO 芋艿,这里要修改
.setPayAmount(amount)
);
return CommonResult.success(null);
}
@Override
@Transactional // TODO 芋艿,要校验下 userId 。不然可以取消任何用户的订单列。
public CommonResult cancelOrder(Integer orderId, Integer reason, String otherReason) {
// 关闭订单,在用户还未付款的时候可操作
OrderDO orderDO = orderMapper.selectById(orderId);
if (orderDO == null) {
return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_NOT_EXISTENT.getCode());
}
// 检查专题,只有待付款状态才能操作
if (!orderDO.getStatus().equals(OrderStatusEnum.WAITING_PAYMENT.getValue())) {
return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_STATUS_NOT_CANCEL.getCode());
}
OrderCancelDO orderCancelDO
= (OrderCancelDO) new OrderCancelDO()
.setOrderId(orderDO.getId())
.setOrderNo(orderDO.getOrderNo())
.setReason(reason)
.setOtherReason(otherReason)
.setCreateTime(new Date())
.setUpdateTime(null);
// 关闭订单,修改状态 item
// TODO FROM 芋艿 TO 小范更新的时候where 里面带下 status 避免并发的问题
orderItemMapper.updateByOrderId(
orderId,
new OrderItemDO().setStatus(OrderStatusEnum.CLOSED.getValue())
);
// 关闭订单,修改状态 order
orderMapper.updateById(new OrderDO().setId(orderId).setStatus(OrderStatusEnum.CLOSED.getValue()));
// 保存取消订单原因
orderCancelMapper.insert(orderCancelDO);
return CommonResult.success(null);
}
@Override
@Transactional // TODO FROM 芋艿 TO 小范:泛型,一定要明确哈。
public CommonResult orderDelivery(OrderDeliveryDTO orderDelivery) {
List<Integer> orderItemIds = orderDelivery.getOrderItemIds();
// 获取所有订单 items // TODO FROM 芋艿 TO 小范deleted 是默认条件,所以 by 里面可以不带哈
List<OrderItemDO> allOrderItems = orderItemMapper.selectByDeletedAndOrderId(orderDelivery.getOrderId(), DeletedStatusEnum.DELETED_NO.getValue());
// 当前需要发货订单,检查 id 和 status
List<OrderItemDO> needDeliveryOrderItems = allOrderItems.stream()
.filter(orderItemDO -> orderItemIds.contains(orderItemDO.getId())
&& OrderStatusEnum.WAIT_SHIPMENT.getValue() == orderItemDO.getStatus())
.collect(Collectors.toList()); // TODO 芋艿,如果这里只是比对数字,可以用 Lambda 求和,不需要弄成一个集合的
// 发货订单,检查
if (needDeliveryOrderItems.size() != orderItemIds.size()) {
return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_DELIVERY_INCORRECT_DATA.getCode());
}
OrderRecipientDO orderRecipientDO = orderRecipientMapper.selectByOrderId(orderDelivery.getOrderId());
OrderLogisticsDO orderLogisticsDO = OrderLogisticsConvert.INSTANCE.convert(orderRecipientDO);
// 保存物流信息
orderLogisticsDO
.setLogisticsNo(orderDelivery.getLogisticsNo())
.setLogistics(orderDelivery.getLogistics())
.setCreateTime(new Date())
.setUpdateTime(null);
orderLogisticsMapper.insert(orderLogisticsDO);
// 关联订单item 和 物流信息
// TODO FROM 芋艿 TO 小范更新的时候where 里面带下 status 避免并发的问题,然后判断下更新数量,不对,就抛出异常。
orderItemMapper.updateByIds(
orderItemIds,
new OrderItemDO()
.setOrderLogisticsId(orderLogisticsDO.getId())
.setStatus(OrderStatusEnum.ALREADY_SHIPMENT.getValue())
);
// 子订单是否全部发货,如果发完,就更新 order
List<OrderItemDO> unShippedOrderItems = allOrderItems.stream()
.filter(orderItemDO -> OrderStatusEnum.WAIT_SHIPMENT.getValue() == orderItemDO.getStatus()
&& !orderItemIds.contains(orderItemDO.getId()))
.collect(Collectors.toList());
if (unShippedOrderItems.size() <= 0) {
// TODO FROM 芋艿 TO 小范更新的时候where 里面带下 status 避免并发的问题
orderMapper.updateById(
new OrderDO()
.setId(orderDelivery.getOrderId())
.setStatus(OrderStatusEnum.ALREADY_SHIPMENT.getValue())
);
}
// 返回成功
return CommonResult.success(null);
}
@Override
public CommonResult updateOrderRemake(Integer orderId, String remake) {
// 此处不做订单校验,直接设置备注即可
orderMapper.updateById(new OrderDO().setId(orderId).setRemark(remake));
return CommonResult.success(null);
}
@Override
@Transactional // TODO FROM 芋艿 to 小范,先不做这个功能,电商一班不存在这个功能哈。
public CommonResult deleteOrderItem(OrderItemDeletedDTO orderItemDeletedDTO) {
Integer orderId = orderItemDeletedDTO.getOrderId();
List<Integer> orderItemIds = orderItemDeletedDTO.getOrderItemIds();
// 获取当前有效的订单 item
List<OrderItemDO> orderItemDOList = orderItemMapper
.selectByDeletedAndOrderId(DeletedStatusEnum.DELETED_NO.getValue(), orderId);
List<OrderItemDO> effectiveOrderItems = orderItemDOList.stream()
.filter(orderItemDO -> !orderItemIds.contains(orderItemDO.getId()))
.collect(Collectors.toList());
// 检查订单 item必须要有一个 item
if (CollectionUtils.isEmpty(effectiveOrderItems)) {
return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_ITEM_ONLY_ONE.getCode());
}
// 更新订单 item
orderItemMapper.updateByIds(
orderItemIds,
(OrderItemDO) new OrderItemDO()
.setDeleted(DeletedStatusEnum.DELETED_YES.getValue())
);
// 更新订单 amount
// Integer totalAmount = orderCommon.calculatedAmount(effectiveOrderItems);
Integer totalAmount = -1; // TODO 芋艿,需要修改下,价格相关
orderMapper.updateById(
new OrderDO()
.setId(orderId)
.setPayAmount(totalAmount)
);
return CommonResult.success(null);
}
@Override
public CommonResult confirmReceiving(Integer userId, Integer orderId) {
OrderDO orderDO = orderMapper.selectById(orderId);
// 是否该用户的订单
if (!userId.equals(orderDO.getUserId())) {
return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_NOT_USER_ORDER.getCode());
}
if (OrderStatusEnum.ALREADY_SHIPMENT.getValue() != orderDO.getStatus()) {
return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_UNABLE_CONFIRM_ORDER.getCode());
}
// TODO FROM 芋艿 TO 小范更新的时候where 里面带下 status 避免并发的问题
orderMapper.updateById(
new OrderDO()
.setId(orderId)
.setReceiverTime(new Date())
.setStatus(OrderStatusEnum.COMPLETED.getValue())
);
orderItemMapper.updateByOrderId(
orderId,
new OrderItemDO()
.setStatus(OrderStatusEnum.COMPLETED.getValue())
.setReceiverTime(new Date())
);
return CommonResult.success(null);
}
@Override
public CommonResult updateLogistics(OrderLogisticsUpdateDTO orderLogisticsDTO) {
OrderLogisticsDO orderLogisticsDO = OrderLogisticsConvert.INSTANCE.convert(orderLogisticsDTO);
orderLogisticsMapper.updateById(orderLogisticsDO);
return CommonResult.success(null);
}
@Override
public CommonResult deleteOrder(Integer id) {
// 删除订单操作,一般用于 用户端删除,是否存在检查可以过掉
orderMapper.updateById((OrderDO) new OrderDO()
.setId(id)
.setDeleted(DeletedStatusEnum.DELETED_YES.getValue())
);
return CommonResult.success(null);
}
@Override
public String updatePaySuccess(String orderId, Integer payAmount) {
OrderDO order = orderMapper.selectById(Integer.valueOf(orderId));
if (order == null) { // 订单不存在
return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_NOT_EXISTENT.getCode()).getMessage();
}
if (!order.getStatus().equals(OrderStatusEnum.WAITING_PAYMENT.getValue())) { // 状态不处于等待支付
return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_STATUS_NOT_WAITING_PAYMENT.getCode()).getMessage();
}
if (!order.getPresentPrice().equals(payAmount)) { // 支付金额不正确
return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_PAY_AMOUNT_ERROR.getCode()).getMessage();
}
// 更新 OrderDO 状态为已支付,等待发货
OrderDO updateOrderObj = new OrderDO()
.setStatus(OrderStatusEnum.WAIT_SHIPMENT.getValue())
.setPayAmount(payAmount)
.setPaymentTime(new Date());
int updateCount = orderMapper.updateByIdAndStatus(order.getId(), order.getStatus(), updateOrderObj);
if (updateCount <= 0) {
return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_STATUS_NOT_WAITING_PAYMENT.getCode()).getMessage();
}
// TODO FROM 芋艿 to 小范,把更新 OrderItem 给补全。
return "success";
}
@Override
public CommonResult listenerConfirmGoods() {
return null;
}
@Override
public CommonResult listenerExchangeGoods() {
return null;
}
}

View File

@@ -0,0 +1,93 @@
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

@@ -0,0 +1,129 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.mall.order.biz.dao.cart.CartMapper">
<sql id="FIELDS">
id, status, delete_time, selected, user_id,
spu_id, sku_id, quantity, order_id, order_create_time,
create_time
</sql>
<select id="selectById" parameterType="Integer" resultType="CartItemDO">
SELECT
<include refid="FIELDS" />
FROM cart_item
WHERE id = #{id}
-- AND deleted = 0
</select>
<select id="selectByIds" resultType="CartItemDO">
SELECT
<include refid="FIELDS" />
FROM cart_item
WHERE id IN
<foreach item="id" collection="ids" separator="," open="(" close=")" index="">
#{id}
</foreach>
-- AND deleted = 0
</select>
<select id="selectByUserIdAndSkuIdAndStatus" resultType="CartItemDO">
SELECT
<include refid="FIELDS" />
FROM cart_item
WHERE user_id = #{userId}
AND sku_id = #{skuId}
AND status = #{status}
-- AND deleted = 0
LIMIT 1
</select>
<select id="selectByUserIdAndStatusAndSelected" resultType="CartItemDO">
SELECT
<include refid="FIELDS" />
FROM cart_item
WHERE user_id = #{userId}
AND status = #{status}
<if test="selected != null">
AND selected = #{selected}
</if>
-- AND deleted = 0
</select>
<select id="selectQuantitySumByUserIdAndStatus" resultType="Integer">
SELECT
SUM(quantity)
FROM cart_item
WHERE user_id = #{userId}
AND status = #{status}
-- AND deleted = 0
</select>
<insert id="insert" parameterType="CartItemDO" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
INSERT INTO cart_item (
status, delete_time, selected, user_id,
spu_id, sku_id, quantity, order_id, order_create_time,
create_time
) VALUES (
#{status}, #{deleteTime}, #{selected}, #{userId},
#{spuId}, #{skuId}, #{quantity}, #{orderId}, #{orderCreateTime},
#{createTime}
)
</insert>
<update id="update" parameterType="CartItemDO">
UPDATE cart_item
<set>
<if test="status != null">
status = #{status},
</if>
<if test="deleteTime != null">
delete_time = #{deleteTime},
</if>
<if test="selected != null">
selected = #{selected},
</if>
<if test="quantity != null">
quantity = #{quantity},
</if>
<if test="orderId != null">
order_id = #{orderId},
</if>
<if test="orderCreateTime != null">
order_create_time = #{orderCreateTime},
</if>
<if test="price != null">
price = #{price},
</if>
<if test="quantity != null">
quantity = #{quantity},
</if>
</set>
WHERE id = #{id}
</update>
<update id="updateQuantity" parameterType="CartItemDO">
UPDATE cart_item
SET quantity = quantity + #{quantityIncr}
WHERE id = #{id}
</update>
<update id="updateListByUserIdAndSkuId">
UPDATE cart_item
<set>
<if test="selected != null">
selected = #{selected},
</if>
<if test="status != null">
status = #{status},
</if>
</set>
WHERE user_id = #{userId}
AND sku_id IN
<foreach item="skuId" collection="skuIds" separator="," open="(" close=")" index="">
#{skuId}
</foreach>
-- AND deleted = 0
</update>
</mapper>

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.mall.order.biz.dao.order.OrderCancelMapper">
<sql id="FIELDS">
id, order_id, order_no, reason, other_reason,
create_time, update_time
</sql>
<!--
插入数据
-->
<insert id="insert" parameterType="OrderCancelDO" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
INSERT INTO `order_cancel` (
order_id, order_no, reason, other_reason,
create_time, update_time
) VALUES (
#{orderId}, #{orderNo}, #{reason}, #{otherReason},
#{createTime}, #{updateTime}
)
</insert>
</mapper>

View File

@@ -0,0 +1,104 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.mall.order.biz.dao.comment.OrderCommentMapper">
<sql id="FIELDS">
id,order_id,order_no,product_spu_id,product_spu_name,product_sku_id,product_sku_attrs,product_sku_price,product_sku_pic_url,
user_id,user_avatar,user_nick_name,star,product_description_star,logistics_star,merchant_star,replay_count,like_count,comment_content,
comment_pics,comment_state,create_time,update_time
</sql>
<!--插入-->
<insert id="insert" parameterType="OrderCommentDO" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
INSERT INTO order_comment(order_id,order_no,product_spu_id,product_spu_name,product_sku_id,
product_sku_attrs,product_sku_price,product_sku_pic_url,user_id,user_avatar,user_nick_name,star,
product_description_star,logistics_star,merchant_star,comment_content,comment_pics,comment_state,create_time,update_time)
VALUES (#{orderId},#{orderNo},#{productSpuId},#{productSpuName},#{productSkuId},#{productSkuAttrs},
#{productSkuPrice},#{productSkuPicUrl},#{userId},#{userAvatar},#{userNickName},#{star},
#{productDescriptionStar},#{logisticsStar},#{merchantStar},#{commentContent},#{commentPics},#{commentState},#{createTime}, #{updateTime});
</insert>
<!--根据 sku id 获取评论总数-->
<select id="selectCommentTotalCountByProductSkuId" parameterType="Integer" resultType="java.lang.Integer">
SELECT
COUNT(*)
FROM order_comment
WHERE
product_sku_id = #{productSkuId}
</select>
<!--分页获取评论分页-->
<select id="selectCommentPage" resultType="cn.iocoder.mall.order.biz.dataobject.OrderCommentDO">
SELECT
<include refid="FIELDS" />
FROM order_comment
WHERE
product_sku_id = #{productSkuId}
ORDER BY create_time DESC
LIMIT ${pageNo*pageSize},${pageSize}
</select>
<!--根据评论 id 获取用户详情-->
<select id="selectCommentInfoByCommentId" parameterType="Integer" resultType="cn.iocoder.mall.order.biz.dataobject.OrderCommentDO">
SELECT
<include refid="FIELDS" />
FROM order_comment
WHERE
id = #{id}
</select>
<!--分页获取订单评论状态信息详情-->
<select id="selectOrderCommentStateInfoPage" resultType="cn.iocoder.mall.order.biz.dataobject.OrderCommentDO">
SELECT
<include refid="FIELDS" />
FROM order_comment
WHERE
user_id = #{userId}
AND
comment_state = #{commentState}
ORDER BY create_time DESC
LIMIT ${pageNo*pageSize},${pageSize}
</select>
<!--获取订单评论状态信息详情总数-->
<select id="selectOrderCommentStateInfoTotal" resultType="java.lang.Integer">
SELECT
COUNT(*)
FROM order_comment
WHERE
user_id = #{userId}
AND
comment_state = #{commentState}
</select>
<!--订单评论超时分页-->
<select id="selectOrderCommentTimeOutPage" parameterType="cn.iocoder.mall.order.api.dto.OrderCommentTimeOutPageDTO" resultType="cn.iocoder.mall.order.biz.dataobject.OrderCommentDO">
SELECT
<include refid="FIELDS" />
FROM order_comment
WHERE
comment_state = #{commentTimeOut.commentState}
HAVING
TIMESTAMPDIFF(DAY,create_time,NOW()) > #{commentTimeOut.overDay}
LIMIT ${commentTimeOut.pageNo*commentTimeOut.pageSize},${commentTimeOut.pageSize}
</select>
<!--批量更新订单评论-->
<update id="updateBatchOrderCommentState">
UPDATE order_comment
SET
comment_state = #{commentState}
WHERE
id
IN
<if test="list !=null">
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
#{item.id}
</foreach>
</if>
</update>
</mapper>

View File

@@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.mall.order.biz.dao.comment.OrderCommentReplayMapper">
<sql id="FIELDS">
id,comment_id,reply_type,parent_id,parent_user_id,parent_user_nick_name,parent_user_avatar,reply_content,
reply_user_id,reply_user_nick_name,reply_user_avatar,user_type,reply_like_count,create_time,update_time
</sql>
<!--插入-->
<insert id="insert" parameterType="OrderCommentReplyDO" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
INSERT INTO order_comment_replay(comment_id,reply_type,parent_id,parent_user_id,parent_user_nick_name,parent_user_avatar,reply_content,reply_user_id,
reply_user_nick_name,reply_user_avatar,user_type,create_time,update_time)
VALUES (#{commentId},#{replyType},#{parentId},#{parentUserId},#{parentUserNickName},#{parentUserAvatar},#{replyContent},#{replyUserId},
#{replyUserNickName},#{replyUserAvatar},#{userType},#{createTime},#{updateTime})
</insert>
<!--根据评论 id 和用户类型获取商家回复列表-->
<select id="selectCommentMerchantReplyByCommentIdAndUserType" resultType="cn.iocoder.mall.order.biz.dataobject.OrderCommentReplyDO">
SELECT
<include refid="FIELDS" />
FROM order_comment_replay
WHERE
comment_id = #{commentId}
AND
user_type = #{userType}
ORDER BY create_time DESC
</select>
<!--根据评论 id 和用户类型获取评论总数-->
<select id="selectCommentReplyTotalCountByCommentId" parameterType="Integer" resultType="java.lang.Integer">
SELECT
COUNT(*)
FROM order_comment_replay
WHERE
comment_id = #{commentId}
AND
user_type = #{userType}
</select>
<!--分页用户回复-->
<select id="selectCommentReplyPage" resultType="cn.iocoder.mall.order.biz.dataobject.OrderCommentReplyDO">
SELECT
<include refid="FIELDS" />
FROM order_comment_replay
WHERE
comment_id = #{commentId}
AND
user_type = #{userType}
ORDER BY create_time DESC
LIMIT ${pageNo*pageSize},${pageSize}
</select>
<!--根据评论 id 查询商家最新的评论列表-->
<select id="selectCommentNewMerchantReplyByCommentIds" resultType="cn.iocoder.mall.order.biz.dataobject.OrderCommentReplyDO">
SELECT
<include refid="FIELDS" />
FROM order_comment_replay
WHERE
create_time=(SELECT
a.maxtime
FROM
(SELECT
MAX(create_time) AS maxtime,comment_id
FROM order_comment_replay
WHERE
comment_id IN
<foreach collection="commentIds" item="commentId" separator="," open="(" close=")">
#{commentId}
</foreach>
GROUP BY comment_id ) AS a)
AND
comment_id IN
<foreach collection="commentIds" item="commentId" separator="," open="(" close=")">
#{commentId}
</foreach>
AND
user_type = #{userType}
</select>
</mapper>

View File

@@ -0,0 +1,172 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.mall.order.biz.dao.order.OrderItemMapper">
<sql id="FIELDS">
id, order_id, order_no, sku_id, sku_name, sku_image, order_logistics_id,
quantity, origin_price, buy_price, present_price, buy_total, discount_total, present_total,
payment_time, delivery_time, receiver_time, closing_time,
has_return_exchange, delivery_type, status,
create_time, update_time, deleted
</sql>
<!--
插入数据
-->
<insert id="insert" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
INSERT INTO `order_item` (
order_id, order_no, sku_id, sku_name, sku_image, order_logistics_id,
quantity, origin_price, buy_price, present_price, buy_total, discount_total, present_total,
payment_time, delivery_time, receiver_time, closing_time,
has_return_exchange, delivery_type, status,
create_time, update_time, deleted
) VALUES
<foreach collection="list" item="item" separator=",">
(#{item.orderId}, #{item.orderNo}, #{item.skuId}, #{item.skuName}, #{item.skuImage}, #{item.orderLogisticsId},
#{item.quantity}, #{item.originPrice}, #{item.buyPrice}, #{item.presentPrice}, #{item.buyTotal}, #{item.discountTotal}, #{item.presentTotal},
#{item.paymentTime}, #{item.deliveryTime}, #{item.receiverTime}, #{item.closingTime},
#{item.hasReturnExchange}, #{item.deliveryType}, #{item.status},
#{item.createTime}, #{item.updateTime}, #{item.deleted})
</foreach>
</insert>
<!--
更新 - 可更新的字段
-->
<sql id="updateFieldSql" >
<set>
<if test="orderItemDO.orderId != null">
, order_id = #{orderItemDO.orderId}
</if>
<if test="orderItemDO.orderNo != null">
, order_no = #{orderItemDO.orderNo}
</if>
<if test="orderItemDO.orderLogisticsId != null">
, order_logistics_id = #{orderItemDO.orderLogisticsId}
</if>
<if test="orderItemDO.skuId != null">
, sku_id = #{orderItemDO.skuId}
</if>
<if test="orderItemDO.skuName != null">
, sku_name = #{orderItemDO.skuName}
</if>
<if test="orderItemDO.skuImage != null">
, sku_image = #{orderItemDO.skuImage}
</if>
<if test="orderItemDO.quantity != null">
, quantity = #{orderItemDO.quantity}
</if>
<!-- TODO 芋艿 需要改 -->
<!-- <if test="orderItemDO.price != null">-->
<!-- , price = #{orderItemDO.price}-->
<!-- </if>-->
<!-- <if test="orderItemDO.payAmount != null">-->
<!-- , pay_amount = #{orderItemDO.payAmount}-->
<!-- </if>-->
<if test="orderItemDO.paymentTime != null">
, payment_time = #{orderItemDO.paymentTime}
</if>
<if test="orderItemDO.deliveryTime != null">
, delivery_time = #{orderItemDO.deliveryTime}
</if>
<if test="orderItemDO.receiverTime != null">
, receiver_time = #{orderItemDO.receiverTime}
</if>
<if test="orderItemDO.closingTime != null">
, closing_time = #{orderItemDO.closingTime}
</if>
<if test="orderItemDO.hasReturnExchange != null">
, has_return_exchange = #{orderItemDO.hasReturnExchange}
</if>
<if test="orderItemDO.status != null">
, status = #{orderItemDO.status}
</if>
<if test="orderItemDO.deliveryType != null">
, delivery_type = #{orderItemDO.deliveryType}
</if>
<if test="orderItemDO.deleted != null">
, `deleted` = #{orderItemDO.deleted}
</if>
<if test="orderItemDO.createTime != null">
, create_time = #{orderItemDO.createTime}
</if>
<if test="orderItemDO.updateTime != null">
, update_time = #{orderItemDO.updateTime}
</if>
</set>
</sql>
<!--
更新 - 根据 id 更新
-->
<update id="updateById" parameterType="OrderDO">
UPDATE `order_item`
<include refid="updateFieldSql" />
WHERE id = #{orderItemDO.id}
</update>
<!--
更新 - 根据 ids 更新
-->
<update id="updateByIds">
UPDATE `order_item`
<include refid="updateFieldSql" />
WHERE id IN
<foreach collection="ids" item="id" separator="," open="(" close=")">
#{id}
</foreach>
</update>
<!--
更新 - 根据 orderId
-->
<update id="updateByOrderId">
UPDATE `order_item`
<include refid="updateFieldSql" />
WHERE order_id = #{orderId}
</update>
<!--
获取 - 根据 ids 查询
-->
<select id="selectByIds" resultType="cn.iocoder.mall.order.biz.dataobject.OrderItemDO">
SELECT
<include refid="FIELDS" />
FROM order_item
WHERE `id` IN
<foreach collection="ids" item="id" separator="," open="(" close=")">
#{id}
</foreach>
</select>
<!--
查询 - 根据 orderId 下的 item
-->
<select id="selectByDeletedAndOrderId" resultType="cn.iocoder.mall.order.biz.dataobject.OrderItemDO">
SELECT * FROM `order_item`
WHERE 1=1
<if test="deleted != null">
AND deleted = #{deleted}
</if>
<if test="orderId != null">
AND order_id = #{orderId}
</if>
</select>
<!--
查询 - 根据 orderIds 和 status
-->
<select id="selectByDeletedAndOrderIds" resultType="cn.iocoder.mall.order.biz.dataobject.OrderItemDO">
SELECT
<include refid="FIELDS" />
FROM `order_item`
WHERE `deleted` = #{deleted}
AND `order_id`
IN
<foreach collection="orderIds" item="orderId" open="(" close=")" separator=",">
#{orderId}
</foreach>
</select>
</mapper>

View File

@@ -0,0 +1,76 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.mall.order.biz.dao.order.OrderLogisticsDetailMapper">
<sql id="FIELDS">
id,
order_logistics_id,
logistics_time,
logistics_information,
create_time,
update_time
</sql>
<!--
插入
-->
<insert id="insert" parameterType="CartItemDO" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
INSERT INTO cart_item (order_logistics_id, logistics_time, logistics_information,
create_time, update_time)
VALUES (#{orderLogisticsId}, #{logisticsTime}, #{logisticsInformation},
#{createTime}, #{updateTime})
</insert>
<!--
查询 - 根据 物流id
-->
<select id="selectByOrderLogisticsId"
resultType="cn.iocoder.mall.order.biz.dataobject.OrderLogisticsDetailDO">
SELECT
<include refid="FIELDS"/>
FROM order_logistics_detail
WHERE order_logistics_id = #{orderLogisticsId}
</select>
<!--
查询 - 根据 物流ids
-->
<select id="selectByOrderLogisticsIds"
resultType="cn.iocoder.mall.order.biz.dataobject.OrderLogisticsDetailDO">
SELECT
<include refid="FIELDS"/>
FROM order_logistics_detail
WHERE order_logistics_id IN
<foreach collection="orderLogisticsIds" item="orderLogisticsId" separator="," open="(" close=")">
#{orderLogisticsId}
</foreach>
</select>
<!--
查询 - 最新的物流信息
-->
<select id="selectLast" resultType="cn.iocoder.mall.order.biz.dataobject.OrderLogisticsDetailDO">
SELECT
<include refid="FIELDS"/>
FROM order_logistics_detail
WHERE order_logistics_id IN
<foreach collection="orderLogisticsIds" item="orderLogisticsId" separator="," open="(" close=")">
#{orderLogisticsId}
</foreach>
ORDER BY create_time DESC
LIMIT 0, 1
</select>
<!--
查询 - 根据 last 根据物理id
-->
<select id="selectLastByLogisticsId"
resultType="cn.iocoder.mall.order.biz.dataobject.OrderLogisticsDetailDO">
SELECT
<include refid="FIELDS"/>
FROM order_logistics_detail
WHERE order_logistics_id = #{orderLogisticsId}
ORDER BY create_time DESC
LIMIT 1
</select>
</mapper>

View File

@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.mall.order.biz.dao.order.OrderLogisticsMapper">
<sql id="FIELDS">
id, area_no, `name`, mobile, address, logistics, logistics_no, create_time, update_time
</sql>
<!--
插入数据
-->
<insert id="insert" parameterType="OrderLogisticsDO" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
INSERT INTO `order_logistics` (
area_no, `name`, mobile, address, logistics, logistics_no, create_time, update_time
) VALUES (
#{areaNo}, #{name}, #{mobile}, #{address},
#{logistics}, #{logisticsNo}, #{createTime}, #{updateTime}
)
</insert>
<!--
可更新字段
-->
<sql id="updateFieldSql" >
<set>
<if test="areaNo != null">
, area_no = #{areaNo}
</if>
<if test="name != null">
, `name` = #{name}
</if>
<if test="mobile != null">
, mobile = #{mobile}
</if>
<if test="address != null">
, address = #{address}
</if>
<if test="logistics != null">
, logistics = #{logistics}
</if>
<if test="logisticsNo != null">
, logistics_no = #{logisticsNo}
</if>
</set>
</sql>
<!--
更新 - 根据id
-->
<update id="updateById">
UPDATE `order_logistics`
<include refid="updateFieldSql" />
WHERE id = #{id}
</update>
<!--
查询 - 根据 ids
-->
<select id="selectByIds" resultType="cn.iocoder.mall.order.biz.dataobject.OrderLogisticsDO">
SELECT
<include refid="FIELDS" />
FROM `order_logistics`
WHERE `id`
IN
<foreach collection="ids" item="id" separator="," open="(" close=")">
#{id}
</foreach>
</select>
<!--
查询 - 根据 ids
-->
<select id="selectById" resultType="cn.iocoder.mall.order.biz.dataobject.OrderLogisticsDO">
SELECT
<include refid="FIELDS" />
FROM `order_logistics`
WHERE `id` = #{id}
LIMIT 1
</select>
</mapper>

View File

@@ -0,0 +1,141 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.mall.order.biz.dao.order.OrderMapper">
<sql id="FIELDS">
id, user_id, order_no, buy_price, discount_price, logistics_price, present_price, pay_amount,
payment_time, delivery_time, receiver_time, closing_time,
has_return_exchange,
status, remark, create_time, update_time, `deleted`
</sql>
<sql id="updateFieldSql" >
<set>
<if test="orderNo != null">
, order_no = #{orderNo}
</if>
<if test="buyPrice != null">
, buy_price = #{buyPrice}
</if>
<if test="discountPrice != null">
, discount_price = #{discountPrice}
</if>
<if test="logisticsPrice != null">
, logistics_price = #{logisticsPrice}
</if>
<if test="logisticsPrice != null">
, logistics_price = #{logisticsPrice}
</if>
<if test="presentPrice != null">
, present_price = #{presentPrice}
</if>
<if test="payAmount != null">
, pay_amount = #{payAmount}
</if>
<if test="deliveryTime != null">
, delivery_time = #{deliveryTime}
</if>
<if test="paymentTime != null">
, payment_time = #{paymentTime}
</if>
<if test="receiverTime != null">
, receiver_time = #{receiverTime}
</if>
<if test="closingTime != null">
, closing_time = #{closingTime}
</if>
<if test="hasReturnExchange != null">
, has_return_exchange = #{hasReturnExchange}
</if>
<if test="status != null">
, status = #{status}
</if>
<if test="remark != null">
, remark = #{remark}
</if>
<if test="deleted != null">
, `deleted` = #{deleted}
</if>
<if test="createTime != null">
, create_time = #{createTime}
</if>
<if test="updateTime != null">
, update_time = #{updateTime}
</if>
</set>
</sql>
<update id="updateById" parameterType="OrderDO">
UPDATE `orders`
<include refid="updateFieldSql" />
WHERE id = #{id}
</update>
<update id="updateByIdAndStatus">
UPDATE `orders`
<set>
<if test="updateObj.payAmount != null">
, pay_amount = #{updateObj.payAmount}
</if>
<if test="updateObj.paymentTime != null">
, payment_time = #{updateObj.paymentTime}
</if>
<if test="updateObj.status != null">
, status = #{updateObj.status}
</if>
</set>
WHERE id = #{id}
AND status = #{status}
</update>
<select id="selectById" resultType="cn.iocoder.mall.order.biz.dataobject.OrderDO">
SELECT
<include refid="FIELDS" />
FROM `orders`
WHERE id = #{id}
</select>
<sql id="selectWhere">
<if test="status != null">
AND `status` = #{status}
</if>
<if test="userId != null">
AND `user_id` = #{userId}
</if>
<if test="id != null">
AND `id` = #{id}
</if>
<if test="orderNo != null">
AND `order_no` = #{orderNo}
</if>
<if test="hasReturnExchange != null">
AND `has_return_exchange` = #{hasReturnExchange}
</if>
<if test="startCreateTime != null and endCreateTime != null">
AND `create_time` &gt;= #{startCreateTime}
AND `create_time` &lt;= #{endCreateTime}
</if>
</sql>
<select id="selectPageCount" resultType="java.lang.Integer">
SELECT
COUNT(*)
FROM `orders`
<where>
<include refid="selectWhere" />
</where>
</select>
<select id="selectPage" resultType="cn.iocoder.mall.order.biz.dataobject.OrderDO">
SELECT
<include refid="FIELDS" />
FROM `orders`
<where>
<include refid="selectWhere" />
</where>
LIMIT ${pageNo * pageSize}, ${pageSize}
</select>
</mapper>

View File

@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.mall.order.biz.dao.order.OrderRecipientMapper">
<sql id="FIELDS">
id, order_id, `area_no`, `name`, mobile, address, `type`,
create_time, update_time
</sql>
<!--
插入数据
-->
<insert id="insert" parameterType="OrderRecipientDO" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
INSERT INTO `order_recipient` (
order_id, `area_no`, `name`, mobile, address,
`type`, create_time, update_time
) VALUES (
#{orderId}, #{areaNo}, #{name}, #{mobile}, #{address},
#{type}, #{createTime,jdbcType=TIMESTAMP} , #{updateTime}
)
</insert>
<!--
查询 - 根据 orderId
-->
<select id="selectByOrderId" resultType="cn.iocoder.mall.order.biz.dataobject.OrderRecipientDO">
SELECT
<include refid="FIELDS" />
FROM `order_recipient`
WHERE order_id = #{orderId}
</select>
<!--
查询 - 根据 orderIds
-->
<select id="selectByOrderIds" resultType="cn.iocoder.mall.order.biz.dataobject.OrderRecipientDO">
SELECT
<include refid="FIELDS" />
FROM `order_recipient`
WHERE order_id IN
<foreach collection="orderIds" item="orderId" separator="," open="(" close=")">
#{orderId}
</foreach>
</select>
</mapper>

View File

@@ -0,0 +1,165 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.mall.order.biz.dao.order.OrderReturnMapper">
<sql id="FIELDS">
id,
service_number,
order_id,
order_no,
order_logistics_id,
refund_price,
reason,
`describe`,
approval_time,
refuse_time,
logistics_time,
receiver_time,
closing_time,
service_type,
status,
create_time,
update_time
</sql>
<!--
插入数据
-->
<insert id="insert" parameterType="OrderReturnDO" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
INSERT INTO `order_return` (
service_number, order_id, order_no, order_logistics_id,
refund_price, reason, `describe`,
approval_time, refuse_time, logistics_time, receiver_time, closing_time,
service_type, status,
create_time, update_time)
VALUES (
#{serviceNumber}, #{orderId}, #{orderNo}, #{orderLogisticsId},
${refundPrice}, #{reason}, #{describe},
#{approvalTime}, #{refuse_time}, #{logisticsTime}, #{receiverTime}, #{closingTime},
#{serviceType}, #{status}, #{createTime}, #{updateTime})
</insert>
<!--
更新 - 可更新的字段
-->
<sql id="updateFieldSql">
<set>
<if test="orderLogisticsId != null">
, order_logistics_id = #{orderLogisticsId}
</if>
<if test="refundPrice != null">
, refund_price = #{refundPrice}
</if>
<if test="reason != null">
, reason = #{reason}
</if>
<if test="describe != null">
, `describe` = #{describe}
</if>
<if test="approvalTime != null">
, approval_time = #{approvalTime}
</if>
<if test="refuseTime != null">
, refuse_time = #{refuseTime}
</if>
<if test="logisticsTime != null">
, logistics_time = #{logisticsTime}
</if>
<if test="receiverTime != null">
, receiver_time = #{receiverTime}
</if>
<if test="closingTime != null">
, closing_time = #{closingTime}
</if>
<if test="serviceType != null">
, service_type = #{serviceType}
</if>
<if test="status != null">
, status = #{status}
</if>
<if test="createTime != null">
, create_time = #{createTime}
</if>
<if test="updateTime != null">
, update_time = #{updateTime}
</if>
</set>
</sql>
<!--
更新 - 根据 id 更新
-->
<update id="updateById" parameterType="OrderReturnDO">
UPDATE `order_return`
<include refid="updateFieldSql"/>
WHERE id = #{id}
</update>
<!--
查询 - 根据id 查询
-->
<select id="selectByOrderId" resultType="cn.iocoder.mall.order.biz.dataobject.OrderReturnDO">
SELECT
<include refid="FIELDS"/>
FROM `order_return`
WHERE order_id = #{orderId}
LIMIT 1
</select>
<!--
列表查询 - where
-->
<sql id="selectListWhere">
<if test="status != null">
AND status = #{status}
</if>
<if test="serviceNumber != null">
AND service_number = #{serviceNumber}
</if>
<if test="orderId != null">
AND order_id = #{orderId}
</if>
<if test="orderId != null">
AND order_no = #{orderNo}
</if>
<if test="startCreateTime != null and endCreateTime != null">
AND create_time &gt;= #{startCreateTime}
AND create_time &lt;= #{endCreateTime}
</if>
</sql>
<!--
列表查询 - count
-->
<select id="selectListCount" resultType="java.lang.Integer">
SELECT
COUNT(*)
FROM `order_return`
WHERE 1 = 1
<include refid="selectListWhere" />
</select>
<!--
列表查询 - queryDTO
-->
<select id="selectList" resultType="cn.iocoder.mall.order.biz.dataobject.OrderReturnDO">
SELECT
<include refid="FIELDS"/>
FROM `order_return`
WHERE 1 = 1
<include refid="selectListWhere" />
<bind name="limitIndex" value="pageSize * (index - 1)"/>
LIMIT #{limitIndex}, #{pageSize}
</select>
<!--
查询 - 根据 id 查询
-->
<select id="selectById" resultType="cn.iocoder.mall.order.biz.dataobject.OrderReturnDO">
SELECT
<include refid="FIELDS"/>
FROM `order_return`
WHERE id = #{id}
</select>
</mapper>

View File

@@ -0,0 +1,121 @@
DROP TABLE `order`;
DROP TABLE `order_item`;
DROP TABLE `order_exchange`;
DROP TABLE `order_return`;
DROP TABLE `order_logistics`;
DROP TABLE `order_logistics_detail`;
CREATE TABLE `order` (
`id` int NOT NULL AUTO_INCREMENT COMMENT 'Id自增长',
`order_logistics_id` int NOT NULL COMMENT '物流id',
`order_no` varchar(50) NOT NULL COMMENT '订单单号',
`price` int(10) NULL COMMENT '金额(分)',
`payment_time` datetime NULL COMMENT '付款时间',
`delivery_time` datetime NULL COMMENT '发货时间',
`receiver_time` datetime NULL COMMENT '收货时间',
`closing_time` datetime NULL COMMENT '成交时间',
`has_return_exchange` smallint NULL COMMENT '是否退换货',
`remark` varchar(255) NULL COMMENT '备注',
`status` smallint(2) NULL COMMENT '状态(如果有多个商品分开发货需要全部商品发完才会改变状态) 0、待付款 1、待发货 2、待收货 3、已完成 4、已关闭',
`create_time` datetime NULL COMMENT '订单创建时间',
`update_time` datetime NULL COMMENT '更新时间',
`deleted` smallint NULL COMMENT '删除状态',
PRIMARY KEY (`id`)
);
CREATE TABLE `order_item` (
`id` int NOT NULL AUTO_INCREMENT COMMENT 'id自增长',
`order_id` int NOT NULL COMMENT '订单编号',
`order_no` varchar(50) NOT NULL COMMENT '订单号',
`sku_id` int NOT NULL COMMENT '商品编号',
`quantity` int(3) NOT NULL COMMENT '商品数量',
`price` int(255) NOT NULL COMMENT '金额',
`payment_time` datetime NULL COMMENT '付款时间',
`delivery_time` datetime NULL COMMENT '发货时间',
`receiver_time` datetime NULL COMMENT '收货时间',
`closing_time` datetime NULL,
`has_return_exchange` int NULL COMMENT '是否退换货',
`create_time` datetime NULL COMMENT '创建时间',
`update_time` datetime NULL COMMENT '更新时间',
`status` smallint(2) NOT NULL COMMENT '状态0、代发货 1、已发货 2、已收货 20、换货中 21、换货成功 40、退货中 41、已退货',
`delete` smallint(2) NOT NULL COMMENT '删除状态',
PRIMARY KEY (`id`)
);
CREATE TABLE `order_exchange` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`order_id` int(11) NOT NULL,
`order_no` varchar(50) NOT NULL,
`sku_id` int(11) NOT NULL,
`exchange_sku_id` int(11) NOT NULL COMMENT '换货商品id',
`exchange_order_logistics_id` int(11) NOT NULL COMMENT '换货物流id',
`receiver_order_logistics_id` int(11) NOT NULL COMMENT '收件地址',
`order_reason_id` int(11) NULL COMMENT '换货原因',
`reason` varchar(255) NULL COMMENT '换货原因 (其他的时候)',
`payment_time` datetime NULL COMMENT '付款时间',
`delivery_time` datetime NULL COMMENT '发货时间',
`receiver_time` datetime NULL COMMENT '收货时间',
`closing_time` datetime NULL COMMENT '成交时间',
`create_time` datetime NULL COMMENT '创建时间',
`update_time` datetime NULL COMMENT '更新时间',
`delete` smallint(2) NULL COMMENT '删除状态',
`order_type` int(2) NULL COMMENT '订单类型 0、为 Order 订单 1、为 OrderItem 订单',
`status` int(2) NULL COMMENT '状态 申请换货、申请成功、申请失败、换货中、换货成功',
PRIMARY KEY (`id`)
);
CREATE TABLE `order_return` (
`id` int NOT NULL AUTO_INCREMENT COMMENT 'id自增长',
`order_id` int NOT NULL COMMENT '订单编号',
`order_no` varchar(50) NOT NULL COMMENT '订单号',
`sku_id` int NOT NULL COMMENT '商品编号',
`order_item_id` int(11) NOT NULL COMMENT '订单item id',
`order_logistics_id` int(11) NOT NULL COMMENT '物流 id',
`order_reason_id` int(11) NULL COMMENT '退货原因',
`reason` varchar(255) NULL COMMENT '换货原因 (其他的时候)',
`create_time` datetime NULL COMMENT '创建时间',
`approval_time` datetime NULL COMMENT '同意时间',
`logistics_time` datetime NULL COMMENT '物流时间(填写物流单号时间)',
`receiver_time` datetime NULL COMMENT '收货时间',
`closing_time` datetime NULL COMMENT '成交时间',
`order_type` int(2) NULL COMMENT '订单类型 0、为 Order 订单 1、为 OrderItem 订单',
`update_time` datetime NULL COMMENT '更新时间',
`delete` smallint(2) NULL COMMENT '删除状态',
`status` int(2) NULL COMMENT '状态 申请换货、申请成功、申请失败、退货中、退货成功',
PRIMARY KEY (`id`)
);
CREATE TABLE `order_logistics` (
`id` int NOT NULL AUTO_INCREMENT COMMENT 'id自增长',
`area_no` int NOT NULL COMMENT '订单编号',
`name` VARCHAR(20) NOT NULL COMMENT '名称',
`mobile` VARCHAR(20) NOT NULL COMMENT '手机号',
`address` VARCHAR(255) NOT NULL COMMENT '详细地址',
`logistics_no` VARCHAR(20) NOT NULL COMMENT '物流单号',
PRIMARY KEY (`id`)
);
CREATE TABLE `order_logistics_detail` (
`id` int NOT NULL AUTO_INCREMENT COMMENT 'id自增长',
`order_logistics_id` int NOT NULL COMMENT '物流编号',
`logistics_time` datetime NOT NULL COMMENT '物流时间',
`logistics_information` VARCHAR(20) NOT NULL COMMENT '物流信息',
PRIMARY KEY (`id`)
);

View File

@@ -0,0 +1,45 @@
package cn.iocoder.mall.order.biz.service;
import cn.iocoder.mall.order.api.OrderCommentService;
import cn.iocoder.mall.order.api.bo.OrderCommentTimeOutBO;
import cn.iocoder.mall.order.api.dto.OrderCommentTimeOutPageDTO;
import cn.iocoder.mall.order.biz.OrderApplicationTest;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.List;
import java.util.stream.Collectors;
/**
* 订单评论自动好评任务测试
*
* @author wtz
* @time 2019-06-17 19:09
*/
@RunWith(SpringRunner.class)
@SpringBootTest(classes = OrderApplicationTest.class)
@ActiveProfiles("dev")
public class OrderCommentJobTest {
@Autowired
private OrderCommentService orderCommentService;
@Test
public void createOrderCommentJob(){
OrderCommentTimeOutPageDTO orderCommentTimeOutPageDTO=new OrderCommentTimeOutPageDTO();
orderCommentTimeOutPageDTO.setCommentState(0);
orderCommentTimeOutPageDTO.setPageNo(0);
orderCommentTimeOutPageDTO.setPageSize(10);
orderCommentTimeOutPageDTO.setOverDay(7);
List<OrderCommentTimeOutBO> orderCommentTimeOutBOList = orderCommentService.getOrderCommentTimeOutPage(orderCommentTimeOutPageDTO);
orderCommentService.updateBatchOrderCommentState(orderCommentTimeOutBOList);
}
}