This commit is contained in:
parent
b27cbe1189
commit
2cbcc0565d
|
|
@ -0,0 +1,41 @@
|
|||
package com.bonus.canteen.core.order.business;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.bonus.canteen.core.account.domain.vo.AccInfoDetailsVO;
|
||||
import com.bonus.canteen.core.account.service.IAccInfoService;
|
||||
import com.bonus.canteen.core.order.domain.OrderDetail;
|
||||
import com.bonus.canteen.core.order.domain.OrderInfo;
|
||||
import com.bonus.canteen.core.order.domain.param.OrderAddParam;
|
||||
import com.bonus.canteen.core.order.mapper.OrderInfoMapper;
|
||||
import com.bonus.canteen.core.order.service.IOrderDetailService;
|
||||
import com.bonus.common.core.exception.ServiceException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public class OrderBusiness {
|
||||
@Autowired
|
||||
private IAccInfoService accInfoService;
|
||||
@Autowired
|
||||
private IOrderDetailService orderDetailService;
|
||||
@Autowired
|
||||
private OrderInfoMapper orderInfoMapper;
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public List<OrderInfo> orderPlaceHandler(OrderAddParam orderAddParam) {
|
||||
AccInfoDetailsVO accInfoVO = this.accInfoService.queryAccInfoByUserId(orderAddParam.getUserId());
|
||||
accInfoService.checkAccStatus(accInfoVO);
|
||||
List<OrderInfo> orderInfoList = new OrderInfo().of(orderAddParam);
|
||||
if(CollUtil.isEmpty(orderInfoList) || CollUtil.isEmpty(orderInfoList.get(0).getOrderDetailList())) {
|
||||
throw new ServiceException("订单明细不能为空");
|
||||
}
|
||||
orderInfoMapper.batchInsertOrderInfo(orderInfoList);
|
||||
orderInfoList.forEach(orderInfo -> {
|
||||
List<OrderDetail> orderDetailList = orderInfo.getOrderDetailList();
|
||||
orderDetailService.batchInsertOrderDetail(orderDetailList);
|
||||
});
|
||||
return orderInfoList;
|
||||
}
|
||||
}
|
||||
|
|
@ -176,6 +176,9 @@ public class OrderInfo extends BaseEntity
|
|||
for(OrderInfoAddParam orderInfoAddParam : orderList) {
|
||||
OrderInfo orderInfo = new OrderInfo();
|
||||
orderInfo.setOrderId(Id.next());
|
||||
orderInfo.setDeviceOrderId(orderInfoAddParam.getDeviceOrderId());
|
||||
orderInfo.setDeviceSn(orderInfoAddParam.getDeviceSn());
|
||||
orderInfo.setDeviceNum(orderInfoAddParam.getDeviceNum());
|
||||
orderInfo.setUserId(param.getUserId());
|
||||
orderInfo.setPayableAmount(param.getPayableAmount());
|
||||
orderInfo.setRealAmount(param.getRealAmount());
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.bonus.canteen.core.order.domain.param;
|
||||
|
||||
import com.bonus.common.core.annotation.Excel;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
|
|
@ -25,5 +26,8 @@ public class OrderInfoAddParam {
|
|||
private Date orderDate;
|
||||
@NotNull(message = "订单类型不能为空")
|
||||
private Integer orderType;
|
||||
private String deviceOrderId;
|
||||
private String deviceSn;
|
||||
private String deviceNum;
|
||||
List<OrderDetailInfoAddParam> orderDetailList;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import com.bonus.canteen.core.account.service.IAccTradeService;
|
|||
import com.bonus.canteen.core.account.service.IAccWalletInfoService;
|
||||
import com.bonus.canteen.core.common.utils.MqUtil;
|
||||
import com.bonus.canteen.core.common.utils.RedisUtil;
|
||||
import com.bonus.canteen.core.order.business.OrderBusiness;
|
||||
import com.bonus.canteen.core.order.constants.OrderDetailStateEnum;
|
||||
import com.bonus.canteen.core.order.constants.OrderRefundStateEnum;
|
||||
import com.bonus.canteen.core.order.constants.OrderStateEnum;
|
||||
|
|
@ -64,6 +65,8 @@ public class OrderInfoServiceImpl implements IOrderInfoService
|
|||
private IAccInfoService accInfoService;
|
||||
@Autowired
|
||||
private IOrderDetailService orderDetailService;
|
||||
@Autowired
|
||||
private OrderBusiness orderBusiness;
|
||||
|
||||
/**
|
||||
* 查询订单
|
||||
|
|
@ -103,17 +106,7 @@ public class OrderInfoServiceImpl implements IOrderInfoService
|
|||
log.info("[下单]重复提交:{}", paramMd5);
|
||||
throw new ServiceException("请勿重复提交订单");
|
||||
}
|
||||
AccInfoDetailsVO accInfoVO = this.accInfoService.queryAccInfoByUserId(orderAddParam.getUserId());
|
||||
accInfoService.checkAccStatus(accInfoVO);
|
||||
List<OrderInfo> orderInfoList = new OrderInfo().of(orderAddParam);
|
||||
if(CollUtil.isEmpty(orderInfoList) || CollUtil.isEmpty(orderInfoList.get(0).getOrderDetailList())) {
|
||||
throw new ServiceException("订单明细不能为空");
|
||||
}
|
||||
orderInfoMapper.batchInsertOrderInfo(orderInfoList);
|
||||
orderInfoList.forEach(orderInfo -> {
|
||||
List<OrderDetail> orderDetailList = orderInfo.getOrderDetailList();
|
||||
orderDetailService.batchInsertOrderDetail(orderDetailList);
|
||||
});
|
||||
List<OrderInfo> orderInfoList = orderBusiness.orderPlaceHandler(orderAddParam);
|
||||
OrderPayDTO orderPayDTO = buildOrderPayDTO(orderInfoList);
|
||||
try {
|
||||
List<AccWalletInfo> walletInfoList = accWalletInfoService.selectAccWalletInfoByUserId(orderPayDTO.getUserId());
|
||||
|
|
|
|||
Loading…
Reference in New Issue