use of com.paascloud.provider.model.domain.OmcOrderDetail 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.OmcOrderDetail in project paascloud-master by paascloud.
the class OmcOrderServiceImpl method assembleOrderVo.
private OrderVo assembleOrderVo(OmcOrder order, List<OmcOrderDetail> orderItemList) {
OrderVo orderVo = new OrderVo();
orderVo.setOrderNo(order.getOrderNo());
orderVo.setPayment(order.getPayment());
orderVo.setPaymentType(order.getPaymentType());
orderVo.setPaymentTypeDesc(Objects.requireNonNull(GlobalConstant.PaymentTypeEnum.codeOf(order.getPaymentType())).getValue());
orderVo.setPostage(order.getPostage());
orderVo.setStatus(order.getStatus());
orderVo.setStatusDesc(OmcApiConstant.OrderStatusEnum.codeOf(order.getStatus()).getValue());
orderVo.setShippingId(order.getShippingId());
OmcShipping shipping = omcShippingMapper.selectByPrimaryKey(order.getShippingId());
if (shipping != null) {
orderVo.setReceiverName(shipping.getReceiverName());
orderVo.setShippingVo(assembleShippingVo(shipping));
}
orderVo.setPaymentTime(order.getPaymentTime());
orderVo.setSendTime(order.getSendTime());
orderVo.setEndTime(order.getEndTime());
orderVo.setCreateTime(order.getCreatedTime());
orderVo.setCloseTime(order.getCloseTime());
orderVo.setCreator(order.getCreator());
orderVo.setImageHost("");
List<OrderItemVo> orderItemVoList = Lists.newArrayList();
for (OmcOrderDetail orderItem : orderItemList) {
OrderItemVo orderItemVo = assembleOrderItemVo(orderItem);
orderItemVoList.add(orderItemVo);
}
orderVo.setOrderItemVoList(orderItemVoList);
return orderVo;
}
use of com.paascloud.provider.model.domain.OmcOrderDetail 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.OmcOrderDetail in project paascloud-master by paascloud.
the class OmcOrderDetailQueryFeignClient method getListByOrderNoUserId.
@Override
@ApiOperation(httpMethod = "POST", value = "获取用户订单详情")
public Wrapper<List<OrderDetailDto>> getListByOrderNoUserId(@PathVariable("orderNo") String orderNo, @PathVariable("userId") Long userId) {
logger.info("getListByOrderNoUserId - 获取用户订单详情. orderNo={}, userId={}", orderNo, userId);
List<OmcOrderDetail> list = omcOrderDetailService.getListByOrderNoUserId(orderNo, userId);
List<OrderDetailDto> orderDetailDtoList = Lists.newArrayList();
for (OmcOrderDetail orderDetail : list) {
OrderDetailDto orderDetailDto = new OrderDetailDto();
BeanUtils.copyProperties(orderDetail, orderDetailDto);
orderDetailDtoList.add(orderDetailDto);
}
return WrapMapper.ok(orderDetailDtoList);
}
use of com.paascloud.provider.model.domain.OmcOrderDetail in project paascloud-master by paascloud.
the class PtcAlipayServiceImpl method pay.
/**
* Pay wrapper.
*
* @param orderNo the order no
* @param loginAuthDto the login auth dto
*
* @return the wrapper
*/
@Override
public Wrapper pay(String orderNo, LoginAuthDto loginAuthDto) {
Long userId = loginAuthDto.getUserId();
OrderDto order = omcOrderService.queryOrderDtoByUserIdAndOrderNo(userId, orderNo);
if (order == null) {
throw new OmcBizException(ErrorCodeEnum.OMC10031003);
}
// (必填) 商户网站订单系统中唯一订单号, 64个字符以内, 只能包含字母、数字、下划线,
// 需保证商户系统端不能重复, 建议通过数据库sequence生成,
String outTradeNo = order.getOrderNo();
// (必填) 订单标题, 粗略描述用户的支付目的。如“xxx品牌xxx门店当面付扫码消费”
String subject = "PCMall扫码支付,订单号:" + outTradeNo;
// (必填) 订单总金额, 单位为元, 不能超过1亿元
// 如果同时传入了【打折金额】,【不可打折金额】,【订单总金额】三者,则必须满足如下条件:【订单总金额】=【打折金额】+【不可打折金额】
String totalAmount = order.getPayment().toString();
// (可选) 订单不可打折金额, 可以配合商家平台配置折扣活动, 如果酒水不参与打折, 则将对应金额填写至此字段
// 如果该值未传入,但传入了【订单总金额】,【打折金额】,则该值默认为【订单总金额】-【打折金额】
String undiscountableAmount = "0";
// 卖家支付宝账号ID, 用于支持一个签约账号下支持打款到不同的收款账号, (打款到sellerId对应的支付宝账号)
// 如果该字段为空, 则默认为与支付宝签约的商户的PID, 也就是appid对应的PID
String sellerId = "";
// 订单描述, 可以对交易或商品进行一个详细地描述, 比如填写"购买商品2件共15.00元"
String body = "订单" + outTradeNo + "购买商品共" + totalAmount + "元";
// 商户操作员编号, 添加此参数可以为商户操作员做销售统计
String operatorId = "test_operator_id";
// (必填) 商户门店编号, 通过门店号和商家后台可以配置精准到门店的折扣信息, 详询支付宝技术支持
String storeId = "test_store_id";
// 业务扩展参数, 目前可添加由支付宝分配的系统商编号(通过setSysServiceProviderId方法), 详情请咨询支付宝技术支持
ExtendParams extendParams = new ExtendParams();
extendParams.setSysServiceProviderId("2088100200300400500");
// 支付超时, 定义为120分钟
String timeoutExpress = "120m";
// 商品明细列表, 需填写购买商品详细信息,
List<GoodsDetail> goodsDetailList = Lists.newArrayList();
List<OmcOrderDetail> orderItemList = omcOrderDetailService.getListByOrderNoUserId(orderNo, userId);
for (OmcOrderDetail orderItem : orderItemList) {
GoodsDetail goods = GoodsDetail.newInstance(orderItem.getProductId().toString(), orderItem.getProductName(), BigDecimalUtil.mul(orderItem.getCurrentUnitPrice().doubleValue(), 100D).longValue(), orderItem.getQuantity());
goodsDetailList.add(goods);
}
// 创建扫码支付请求builder, 设置请求参数
AlipayTradePrecreateRequestBuilder builder = new AlipayTradePrecreateRequestBuilder().setSubject(subject).setTotalAmount(totalAmount).setOutTradeNo(outTradeNo).setUndiscountableAmount(undiscountableAmount).setSellerId(sellerId).setBody(body).setOperatorId(operatorId).setStoreId(storeId).setExtendParams(extendParams).setTimeoutExpress(timeoutExpress).setNotifyUrl(alipayCallbackUrl).setGoodsDetailList(goodsDetailList);
AlipayF2FPrecreateResult result = tradeService.tradePrecreate(builder);
switch(result.getTradeStatus()) {
case SUCCESS:
log.info("支付宝预下单成功: )");
AlipayTradePrecreateResponse response = result.getResponse();
dumpResponse(response);
// 需要修改为运行机器上的路径
File folder = new File(qrCodePcPath);
if (!folder.exists()) {
folder.setWritable(true);
folder.mkdirs();
}
// 细节细节细节
String qrPath = String.format(qrCodePcPath + "/qr-%s.png", response.getOutTradeNo());
String qrFileName = String.format("qr-%s.png", response.getOutTradeNo());
ZxingUtils.getQRCodeImge(response.getQrCode(), 256, qrPath);
File qrCodeImage = new File(qrPath);
OptUploadFileReqDto optUploadFileReqDto = new OptUploadFileReqDto();
optUploadFileReqDto.setBucketName("paascloud-oss-bucket");
optUploadFileReqDto.setFilePath(qrCodeQiniuPath);
optUploadFileReqDto.setFileType("png");
optUploadFileReqDto.setUserId(loginAuthDto.getUserId());
optUploadFileReqDto.setUserName(loginAuthDto.getUserName());
OptUploadFileByteInfoReqDto optUploadFileByteInfoReqDto = new OptUploadFileByteInfoReqDto();
optUploadFileByteInfoReqDto.setFileName(qrFileName);
byte[] bytes = FileUtil.readBytes(qrCodeImage);
optUploadFileByteInfoReqDto.setFileByteArray(bytes);
optUploadFileReqDto.setUploadFileByteInfoReqDto(optUploadFileByteInfoReqDto);
OptUploadFileRespDto optUploadFileRespDto = null;
try {
optUploadFileRespDto = opcOssService.uploadFile(optUploadFileReqDto);
optUploadFileRespDto.setRefNo(orderNo);
// 获取二维码
final OptGetUrlRequest request = new OptGetUrlRequest();
request.setAttachmentId(optUploadFileRespDto.getAttachmentId());
request.setEncrypt(true);
String fileUrl = opcOssService.getFileUrl(request);
optUploadFileRespDto.setAttachmentUrl(fileUrl);
} catch (Exception e) {
log.error("上传二维码异常", e);
}
return WrapMapper.ok(optUploadFileRespDto);
case FAILED:
log.error("支付宝预下单失败!!!");
return WrapMapper.error("支付宝预下单失败!!!");
case UNKNOWN:
log.error("系统异常, 预下单状态未知!!!");
return WrapMapper.error("系统异常, 预下单状态未知!!!");
default:
log.error("不支持的交易状态, 交易返回异常!!!");
return WrapMapper.error("不支持的交易状态, 交易返回异常!!!");
}
}
Aggregations