diff --git a/src/main/java/com/peanut/modules/book/controller/BuyOrderController.java b/src/main/java/com/peanut/modules/book/controller/BuyOrderController.java index e0cd0935..05f19a74 100644 --- a/src/main/java/com/peanut/modules/book/controller/BuyOrderController.java +++ b/src/main/java/com/peanut/modules/book/controller/BuyOrderController.java @@ -184,86 +184,6 @@ public class BuyOrderController { public R buySave(@RequestBody BuyOrder buyOrder) throws IOException { return R.error("app版本太低请升级后再购买!!"); - // 获取订单详情 -// List buyOrderDetails = buyOrder.getProducts(); -// // 订单总金额 -// BigDecimal totalPrice = new BigDecimal(0); -// // 遍历商品总价计算 -// for (BuyOrderDetail buyOrderDetail : buyOrderDetails) { -// Integer productId = buyOrderDetail.getProductId(); -// int quantity = buyOrderDetail.getQuantity(); -// ShopProduct product = shopProductService.getById(productId); -// BigDecimal price = getRealPrice(product); -// if (!handleStock(buyOrderDetail, product)) { -// return R.error(500, "库存不足"); -// } -// totalPrice = totalPrice.add(price.multiply(BigDecimal.valueOf(quantity))); -// buyOrderDetail.setProductName(product.getProductName()); -// buyOrderDetail.setProductPrice(product.getPrice()); -// int originWeight = product.getWeight(); -// int originWeightIntValue = originWeight / 100; -// int originWeightDecimalValue = originWeightIntValue % 100; -// buyOrderDetail.setWeight(BigDecimal.valueOf(originWeightIntValue).add(BigDecimal.valueOf(originWeightDecimalValue).divide(new BigDecimal(100), -// MathContext.DECIMAL64))); -// buyOrderDetail.setProductUrl(product.getProductImages()); -// buyOrderDetail.setOrderStatus(Constants.ORDER_STATUS_TO_BE_PAID); -// } -// -// totalPrice = totalPrice.subtract(useCouponAmount(buyOrder)); -// totalPrice = totalPrice.add(getShoppingAmount(buyOrder)); -// String orderSn = IdWorker.getTimeId().substring(0, 32); -// buyOrder.setOrderSn(orderSn); -// buyOrder.setPaymentDate(new Date()); -// QueryWrapper queryWrapper = new QueryWrapper<>(); -// queryWrapper.eq("id", buyOrder.getAddressId()); -// UserAddress userAddress = userAddressService.getOne(queryWrapper); -// UserAddressVo vo = new UserAddressVo(); -// vo = userAddressService.getAddressName(vo, userAddress.getRegionCode()); -// buyOrder.setProvince(vo.getProvince()); -// buyOrder.setCity(vo.getCity()); -// buyOrder.setDistrict(vo.getCounty()); -// buyOrder.setAddress(vo.getDetailAddress()); -// buyOrderService.save(buyOrder); -// -// for (BuyOrderDetail buyOrderDetail : buyOrderDetails) { -// buyOrderDetail.setOrderId(buyOrder.getOrderId()); -// buyOrderDetail.setUserId(buyOrder.getUserId()); -// if (Constants.BUY_TYPE_CART.equals(buyOrder.getBuyType())) { -// handleBuyCart(buyOrder, buyOrderDetail); -// } -// } -// buyOrderDetailService.saveBatch(buyOrderDetails); -// // 1. 虚拟币支付 -// if (Constants.PAYMENT_METHOD_VIRTUAL.equals(buyOrder.getPaymentMethod())) { -// buyOrder.setOrderStatus(Constants.ORDER_STATUS_TO_BE_SHIPPED); -// MyUserEntity user = this.myUserService.getById(buyOrder.getUserId()); -// if (usePeanutCoin(user, totalPrice)) { -// // 更新订单状态 -// buyOrderService.updateOrderStatus(user.getId(), buyOrder.getOrderSn(), "0"); -// recordTransaction(buyOrder, user, totalPrice); -// addEbookToUser(buyOrderDetails, buyOrder); -// } else { -// return R.error(500, "花生币余额不足!"); -// } -// } -// // 2. 微信支付 -// if (Constants.PAYMENT_METHOD_WECHAT_PAY.equals(buyOrder.getPaymentMethod())) { -// rabbitTemplate.convertAndSend( -// DelayQueueConfig.ORDER_TO_BE_PAY_EXCHANGE, -// DelayQueueConfig.ORDER_TO_BE_PAY_ROUTING_KEY, -// buyOrder.getOrderId(), -// messagePostProcessor() -// ); -// WechatPaymentInfo paymentInfo = new WechatPaymentInfo(); -// paymentInfo.setOrderSn(orderSn); -// paymentInfo.setBuyOrderId(buyOrder.getOrderId()); -// paymentInfo.setTotalAmount(totalPrice); -// wxpayService.prepay(paymentInfo); -// } -// Map result = new HashMap<>(); -// result.put("orderSn", buyOrder.getOrderSn()); -// result.put("money", totalPrice); -// return R.ok(result); } /**