package cn.lili.modules.order.order.serviceimpl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.json.JSONUtil;
import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;
import cn.hutool.poi.excel.ExcelWriter;
import cn.lili.common.enums.PromotionTypeEnum;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.event.TransactionCommitSendMQEvent;
import cn.lili.common.exception.ServiceException;
import cn.lili.common.properties.RocketmqCustomProperties;
import cn.lili.common.security.OperationalJudgment;
import cn.lili.common.security.context.UserContext;
import cn.lili.common.security.enums.UserEnums;
import cn.lili.common.utils.SnowFlake;
import cn.lili.modules.goods.entity.dto.GoodsCompleteMessage;
import cn.lili.modules.logistics.entity.enums.LogisticsEnum;
import cn.lili.modules.member.entity.dto.MemberAddressDTO;
import cn.lili.modules.member.service.StoreLogisticsService;
import cn.lili.modules.order.cart.entity.dto.TradeDTO;
import cn.lili.modules.order.cart.entity.enums.DeliveryMethodEnum;
import cn.lili.modules.order.order.aop.OrderLogPoint;
import cn.lili.modules.order.order.entity.dos.*;
import cn.lili.modules.order.order.entity.dto.OrderBatchDeliverDTO;
import cn.lili.modules.order.order.entity.dto.OrderExportDTO;
import cn.lili.modules.order.order.entity.dto.OrderMessage;
import cn.lili.modules.order.order.entity.dto.OrderSearchParams;
import cn.lili.modules.order.order.entity.enums.*;
import cn.lili.modules.order.order.entity.vo.OrderDetailVO;
import cn.lili.modules.order.order.entity.vo.OrderSimpleVO;
import cn.lili.modules.order.order.entity.vo.OrderVO;
import cn.lili.modules.order.order.entity.vo.PaymentLog;
import cn.lili.modules.order.order.mapper.OrderItemMapper;
import cn.lili.modules.order.order.mapper.OrderMapper;
import cn.lili.modules.order.order.service.*;
import cn.lili.modules.order.trade.entity.dos.OrderLog;
import cn.lili.modules.order.trade.service.OrderLogService;
import cn.lili.modules.payment.entity.enums.PaymentMethodEnum;
import cn.lili.modules.promotion.entity.dos.Pintuan;
import cn.lili.modules.promotion.service.PintuanService;
import cn.lili.modules.store.entity.dto.StoreDeliverGoodsAddressDTO;
import cn.lili.modules.store.service.StoreDetailService;
import cn.lili.modules.system.aspect.annotation.SystemLogPoint;
import cn.lili.modules.system.entity.dos.Logistics;
import cn.lili.modules.system.entity.dto.LogisticsSetting;
import cn.lili.modules.system.entity.vo.Traces;
import cn.lili.modules.system.service.LogisticsService;
import cn.lili.mybatis.util.PageUtil;
import cn.lili.rocketmq.RocketmqSendCallbackBuilder;
import cn.lili.rocketmq.tags.GoodsTagsEnum;
import cn.lili.rocketmq.tags.OrderTagsEnum;
import cn.lili.trigger.enums.DelayTypeEnums;
import cn.lili.trigger.interfaces.TimeTrigger;
import cn.lili.trigger.message.PintuanOrderMessage;
import cn.lili.trigger.model.TimeExecuteConstant;
import cn.lili.trigger.model.TimeTriggerMsg;
import cn.lili.trigger.util.DelayQueueTools;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.util.CellRangeAddressList;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.net.URLEncoder;
import java.util.*;
import java.util.stream.Collectors;
/**
* 子订单业务层实现
*
* @author Chopper
* @since 2020/11/17 7:38 下午
*/
@Service
@Slf4j
public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements OrderService {
private static final String ORDER_SN_COLUMN = "order_sn";
/**
* 延时任务
*/
@Autowired
private TimeTrigger timeTrigger;
/**
* 订单货物数据层
*/
@Resource
private OrderItemMapper orderItemMapper;
/**
* 发票
*/
@Autowired
private ReceiptService receiptService;
/**
* 订单货物
*/
@Autowired
private OrderItemService orderItemService;
/**
* 物流公司
*/
@Autowired
private LogisticsService logisticsService;
/**
* 订单日志
*/
@Autowired
private OrderLogService orderLogService;
/**
* RocketMQ
*/
@Autowired
private RocketMQTemplate rocketMQTemplate;
/**
* RocketMQ配置
*/
@Autowired
private RocketmqCustomProperties rocketmqCustomProperties;
/**
* 订单流水
*/
@Autowired
private StoreFlowService storeFlowService;
/**
* 拼团
*/
@Autowired
private PintuanService pintuanService;
@Autowired
private TradeService tradeService;
@Autowired
private ApplicationEventPublisher applicationEventPublisher;
@Autowired
private StoreDetailService storeDetailService;
@Override
@Transactional(rollbackFor = Exception.class)
public void intoDB(TradeDTO tradeDTO) {
//检查TradeDTO信息
checkTradeDTO(tradeDTO);
//存放购物车,即业务中的订单
List<Order> orders = new ArrayList<>(tradeDTO.getCartList().size());
//存放自订单/订单日志
List<OrderItem> orderItems = new ArrayList<>();
List<OrderLog> orderLogs = new ArrayList<>();
//订单集合
List<OrderVO> orderVOS = new ArrayList<>();
//循环购物车
tradeDTO.getCartList().forEach(item -> {
//当前购物车订单子项
List<OrderItem> currentOrderItems = new ArrayList<>();
Order order = new Order(item, tradeDTO);
//构建orderVO对象
OrderVO orderVO = new OrderVO();
BeanUtil.copyProperties(order, orderVO);
//持久化DO
orders.add(order);
String message = "订单[" + item.getSn() + "]创建";
//记录日志
orderLogs.add(new OrderLog(item.getSn(), UserContext.getCurrentUser().getId(), UserContext.getCurrentUser().getRole().getRole(), UserContext.getCurrentUser().getUsername(), message));
item.getCheckedSkuList().forEach(
sku -> {
orderItems.add(new OrderItem(sku, item, tradeDTO));
currentOrderItems.add(new OrderItem(sku, item, tradeDTO));
}
);
//写入子订单信息
orderVO.setOrderItems(currentOrderItems);
//orderVO 记录
orderVOS.add(orderVO);
});
tradeDTO.setOrderVO(orderVOS);
//批量保存订单
this.saveBatch(orders);
//批量保存 子订单
orderItemService.saveBatch(orderItems);
//批量记录订单操作日志
orderLogService.saveBatch(orderLogs);
}
@Override
public IPage<OrderSimpleVO> queryByParams(OrderSearchParams orderSearchParams) {
QueryWrapper queryWrapper = orderSearchParams.queryWrapper();
queryWrapper.groupBy("o.id");
queryWrapper.orderByDesc("o.id");
return this.baseMapper.queryByParams(PageUtil.initPage(orderSearchParams), queryWrapper);
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
lilishop商城基于SpringBoot 全端开源 电商商城系统 支持小程序商城 H5商城 APP商城 PC商城 。支持业务模式包含 O2O商城 B2B商城 多语言商城 跨境电商 B2B2C商城 F2B2C商城 S2B2C商城 分销商城 多用户商城
资源推荐
资源详情
资源评论
收起资源包目录
基于SpringBoot 全端开源 电商商城系统 (1585个子文件)
Dockerfile 377B
.gitignore 423B
.gitignore 395B
xxl-job-admin-2.3.0-SNAPSHOT.jar 37.08MB
maven-wrapper.jar 50KB
SF-CSIM-EXPRESS-SDK-V2.1.7.jar 23KB
OrderServiceImpl.java 44KB
AliPayApi.java 42KB
EsGoodsIndexServiceImpl.java 40KB
WechatApi.java 37KB
WechatPlugin.java 33KB
CartServiceImpl.java 32KB
GoodsSkuServiceImpl.java 31KB
MemberServiceImpl.java 30KB
EsGoodsSearchServiceImpl.java 28KB
AfterSaleServiceImpl.java 28KB
WxPayKit.java 28KB
GoodsServiceImpl.java 26KB
ResultCode.java 25KB
GoodsMessageListener.java 22KB
SeckillApplyServiceImpl.java 20KB
BaseElasticsearchService.java 20KB
WechatApiEnum.java 17KB
PromotionGoodsServiceImpl.java 16KB
KdniaoPlugin.java 16KB
AbstractHttpDelegate.java 16KB
MemberCouponServiceImpl.java 16KB
PayKit.java 16KB
StockUpdateExecute.java 15KB
MemberWalletServiceImpl.java 15KB
ConnectServiceImpl.java 15KB
CouponActivityServiceImpl.java 15KB
StoreServiceImpl.java 15KB
DistributionOrderServiceImpl.java 15KB
TencentSmsPlugin.java 14KB
AliPayPlugin.java 14KB
ClerkServiceImpl.java 14KB
KanjiaActivityGoodsServiceImpl.java 14KB
SkuPromotionRender.java 13KB
CheckDataRender.java 13KB
BillServiceImpl.java 13KB
PriceDetailDTO.java 13KB
CouponServiceImpl.java 13KB
MemberBuyerController.java 13KB
CouponRender.java 13KB
RsaKit.java 13KB
CategoryServiceImpl.java 13KB
CartController.java 12KB
GoodsImportServiceImpl.java 12KB
DateUtil.java 12KB
ShunfengPlugin.java 12KB
PintuanServiceImpl.java 12KB
HuaweiSmsPlugin.java 12KB
PlatformViewServiceImpl.java 12KB
OrderComplaintServiceImpl.java 11KB
StudioServiceImpl.java 11KB
HttpUtils.java 11KB
Order.java 11KB
StoreDetailServiceImpl.java 11KB
KanjiaActivityServiceImpl.java 11KB
EsGoodsIndex.java 11KB
IndexStatisticsServiceImpl.java 11KB
AliSmsPlugin.java 11KB
RegionServiceImpl.java 11KB
GlobalAuthUtils.java 11KB
WechatMessageUtil.java 11KB
AbstractPromotionsServiceImpl.java 11KB
Swagger2Config.java 11KB
FullDiscountExecute.java 10KB
SeckillServiceImpl.java 10KB
PageDataServiceImpl.java 10KB
NoticeMessageExecute.java 10KB
OrderStoreController.java 10KB
PointsGoodsServiceImpl.java 10KB
ConnectUtil.java 10KB
SettingManagerController.java 10KB
MemberEvaluationServiceImpl.java 10KB
PromotionTools.java 10KB
GoodsStoreController.java 9KB
UnionPayPlugin.java 9KB
SkuFreightRender.java 9KB
AdminUserServiceImpl.java 9KB
RedisConfig.java 9KB
StoreFlowStatisticsServiceImpl.java 9KB
FullDiscountServiceImpl.java 9KB
XssHttpServletRequestWrapper.java 9KB
OrderEveryDayTaskExecute.java 9KB
BaseAuthRequest.java 9KB
ImTalkServiceImpl.java 9KB
Goods.java 9KB
RedisCache.java 9KB
StoreFlowServiceImpl.java 9KB
EsTest.java 8KB
SensitiveWordsFilter.java 8KB
WechatMPMessageServiceImpl.java 8KB
TradeServiceImpl.java 8KB
OrderSearchParams.java 8KB
CachePrefix.java 8KB
Kuaidi100Plugin.java 8KB
FullDiscountRender.java 8KB
共 1585 条
- 1
- 2
- 3
- 4
- 5
- 6
- 16
资源评论
Java程序员-张凯
- 粉丝: 1w+
- 资源: 7361
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- (源码)基于Java和MySQL的学生信息管理系统.zip
- (源码)基于ASP.NET Core的零售供应链管理系统.zip
- (源码)基于PythonSpleeter的戏曲音频处理系统.zip
- (源码)基于Spring Boot的监控与日志管理系统.zip
- (源码)基于C++的Unix V6++二级文件系统.zip
- (源码)基于Spring Boot和JPA的皮皮虾图片收集系统.zip
- (源码)基于Arduino和Python的实时歌曲信息液晶显示屏展示系统.zip
- (源码)基于C++和C混合模式的操作系统开发项目.zip
- (源码)基于Arduino的全球天气监控系统.zip
- OpenCVForUnity2.6.0.unitypackage
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功