use of com.paascloud.provider.model.domain.OmcOrder in project paascloud-master by paascloud.
the class OmcOrderServiceImpl method createOrderDoc.
@Override
@Transactional(rollbackFor = Exception.class)
public OrderVo createOrderDoc(LoginAuthDto loginAuthDto, Long shippingId) {
Long userId = loginAuthDto.getUserId();
// 从购物车中获取数据
List<OmcCart> cartList = omcCartMapper.selectCheckedCartByUserId(userId);
if (CollectionUtils.isEmpty(cartList)) {
throw new OmcBizException(ErrorCodeEnum.OMC10031001, userId);
}
// 计算这个订单的总价
List<OmcOrderDetail> omcOrderDetailList = omcCartService.getCartOrderItem(userId, cartList);
if (CollectionUtils.isEmpty(omcOrderDetailList)) {
throw new OmcBizException(ErrorCodeEnum.OMC10031001, userId);
}
BigDecimal payment = this.getOrderTotalPrice(omcOrderDetailList);
// 生成订单
OmcOrder order = this.assembleOrder(userId, shippingId, payment);
if (order == null) {
logger.error("生成订单失败, userId={}, shippingId={}, payment={}", userId, shippingId, payment);
throw new OmcBizException(ErrorCodeEnum.OMC10031002);
}
order.setUpdateInfo(loginAuthDto);
for (OmcOrderDetail orderDetail : omcOrderDetailList) {
orderDetail.setUpdateInfo(loginAuthDto);
orderDetail.setOrderNo(order.getOrderNo());
orderDetail.setId(super.generateId());
orderDetail.setUpdateInfo(loginAuthDto);
}
// mybatis 批量插入
omcOrderDetailService.batchInsertOrderDetail(omcOrderDetailList);
// 生成成功,我们要减少我们产品的库存
this.reduceProductStock(omcOrderDetailList);
// 清空一下购物车
this.cleanCart(cartList);
return assembleOrderVo(order, omcOrderDetailList);
}
use of com.paascloud.provider.model.domain.OmcOrder in project paascloud-master by paascloud.
the class OmcOrderServiceImpl method queryOrderDtoByUserIdAndOrderNo.
@Override
public OrderDto queryOrderDtoByUserIdAndOrderNo(Long userId, String orderNo) {
OmcOrder omcOrder = this.queryByUserIdAndOrderNo(userId, orderNo);
if (omcOrder == null) {
throw new OmcBizException(ErrorCodeEnum.OMC10031005, orderNo);
}
ModelMapper modelMapper = new ModelMapper();
return modelMapper.map(omcOrder, OrderDto.class);
}
use of com.paascloud.provider.model.domain.OmcOrder in project paascloud-master by paascloud.
the class OmcOrderServiceImpl method getOrderDetail.
@Override
public OrderVo getOrderDetail(final String orderNo) {
logger.info("获取订单明细, orderNo={}", orderNo);
OmcOrder order = omcOrderMapper.selectByOrderNo(orderNo);
if (null == order) {
throw new OmcBizException(ErrorCodeEnum.OMC10031005, orderNo);
}
List<OmcOrderDetail> orderItemList = omcOrderDetailService.getListByOrderNo(orderNo);
return assembleOrderVo(order, orderItemList);
}
use of com.paascloud.provider.model.domain.OmcOrder in project paascloud-master by paascloud.
the class PtcAlipayServiceImpl method aliPayCallback.
@Override
public Wrapper aliPayCallback(Map<String, String> params) {
log.info("支付宝回调. - aliPayCallback. params={}", params);
String orderNo = params.get("out_trade_no");
String tradeNo = params.get("trade_no");
String tradeStatus = params.get("trade_status");
OrderDto order = omcOrderService.queryOrderDtoByOrderNo(orderNo);
if (order == null) {
throw new OmcBizException(ErrorCodeEnum.OMC10031010);
}
if (order.getStatus() >= OmcApiConstant.OrderStatusEnum.PAID.getCode()) {
throw new OmcBizException(ErrorCodeEnum.OMC10031011);
}
if (PtcApiConstant.AlipayCallback.TRADE_STATUS_TRADE_SUCCESS.equals(tradeStatus)) {
order.setPaymentTime(DateUtil.parseDate(params.get("gmt_payment")));
order.setStatus(OmcApiConstant.OrderStatusEnum.PAID.getCode());
ModelMapper modelMapper = new ModelMapper();
OmcOrder omcOrder = modelMapper.map(order, OmcOrder.class);
omcOrderService.update(omcOrder);
}
PtcPayInfo payInfo = new PtcPayInfo();
payInfo.setUserId(order.getUserId());
payInfo.setOrderNo(order.getOrderNo());
payInfo.setPayPlatform(PtcApiConstant.PayPlatformEnum.ALIPAY.getCode());
payInfo.setPlatformNumber(tradeNo);
payInfo.setPlatformStatus(tradeStatus);
payInfo.setUpdateTime(new Date());
payInfo.setCreatedTime(new Date());
payInfo.setCreator(order.getCreator());
payInfo.setCreatorId(order.getUserId());
payInfo.setLastOperator(order.getLastOperator());
payInfo.setLastOperatorId(order.getLastOperatorId());
payInfo.setId(UniqueIdGenerator.generateId());
ptcPayInfoMapper.insertSelective(payInfo);
return WrapMapper.ok();
}
use of com.paascloud.provider.model.domain.OmcOrder in project paascloud-master by paascloud.
the class OmcOrderFeignClient method updateOrderById.
@Override
@ApiOperation(httpMethod = "POST", value = "更新订单信息")
public Wrapper updateOrderById(@RequestBody OrderDto orderDto) {
logger.info("updateOrderById - 更新订单信息. orderDto={}", orderDto);
ModelMapper modelMapper = new ModelMapper();
OmcOrder omcOrder = modelMapper.map(orderDto, OmcOrder.class);
int updateResult = omcOrderService.update(omcOrder);
return handleResult(updateResult);
}
Aggregations