paypal订单调试
This commit is contained in:
@@ -79,7 +79,7 @@ public class HomeController {
|
||||
List<BookEntity> noBooks = bookService.list(new LambdaQueryWrapper<BookEntity>()
|
||||
.eq(BookEntity::getState,1)
|
||||
.eq(BookEntity::getBookType,0)
|
||||
.notIn(BookEntity::getId,bookIds)
|
||||
.notIn(BookEntity::getId,bookIds.size()==0?0:bookIds)
|
||||
.last("limit 2"));
|
||||
Set<BookEntity> books = new HashSet<>();
|
||||
//查询阅读进度
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
package com.peanut.modules.bookAbroad.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.github.promeg.pinyinhelper.Pinyin;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.common.utils.ShiroUtils;
|
||||
import com.peanut.config.Constants;
|
||||
import com.peanut.config.DelayQueueConfig;
|
||||
import com.peanut.modules.book.service.BuyOrderService;
|
||||
import com.peanut.modules.common.entity.BookEntity;
|
||||
import com.peanut.modules.common.entity.BuyOrder;
|
||||
import com.peanut.modules.common.service.BookService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.core.MessagePostProcessor;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
@@ -13,35 +18,50 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Slf4j
|
||||
@RestController("bookAbroadOrder")
|
||||
@RequestMapping("bookAbroad/order")
|
||||
public class OrderController {
|
||||
|
||||
@Autowired
|
||||
private BookService bookService;
|
||||
@Autowired
|
||||
private BuyOrderService buyOrderService;
|
||||
@Autowired
|
||||
private RabbitTemplate rabbitTemplate;
|
||||
|
||||
/**
|
||||
* 充值专用订单生成接口
|
||||
*/
|
||||
@RequestMapping("/rechargeSave")
|
||||
public R rechargeSave(@RequestBody BuyOrder buyOrder){
|
||||
@RequestMapping("/placeOrder")
|
||||
public R createOrder(@RequestBody BuyOrder buyOrder){
|
||||
buyOrder.setUserId(ShiroUtils.getUId());
|
||||
buyOrder.setCome(3);//3 海外读书
|
||||
buyOrder.setPaymentMethod("5"); //5 paypal
|
||||
BookEntity bookEntity = bookService.getById(buyOrder.getAbroadBookId());
|
||||
BigDecimal orderMoney = buyOrder.getOrderMoney();
|
||||
//校验价格
|
||||
if (orderMoney.compareTo(bookEntity.getAbroadPrice())!=0){
|
||||
return R.error("订单价格异常");
|
||||
}
|
||||
buyOrder.setRealMoney(orderMoney);
|
||||
buyOrder.setRemark("Purchase the e-book '"+ Pinyin.toPinyin(bookEntity.getName(), " ").toLowerCase()+"'");
|
||||
buyOrder.setOrderStatus("0");
|
||||
buyOrder.setOrderType("abroadBook");
|
||||
String timeId = IdWorker.getTimeId().substring(0, 32);
|
||||
buyOrder.setOrderSn(timeId);
|
||||
buyOrderService.save(buyOrder);
|
||||
// 1. 虚拟币支付
|
||||
if (Constants.PAYMENT_METHOD_VIRTUAL.equals(buyOrder.getPaymentMethod())) {
|
||||
|
||||
}
|
||||
rabbitTemplate.convertAndSend(
|
||||
DelayQueueConfig.ORDER_TO_BE_PAY_EXCHANGE,
|
||||
DelayQueueConfig.ORDER_TO_BE_PAY_ROUTING_KEY,
|
||||
buyOrder.getOrderId(),
|
||||
messagePostProcessor()
|
||||
);
|
||||
return R.ok().put("orderSn", timeId);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
private MessagePostProcessor messagePostProcessor() {
|
||||
return message -> {
|
||||
//设置有效期30分钟
|
||||
|
||||
Reference in New Issue
Block a user