format the code and remove the unused import
This commit is contained in:
@@ -1,24 +1,15 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.book.entity.*;
|
||||
import com.peanut.modules.book.service.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -71,8 +71,20 @@ public class BuyOrderController {
|
||||
private PayWechatOrderService payWechatOrderService;
|
||||
@Autowired
|
||||
private PayZfbOrderService payZfbOrderService;
|
||||
// @Autowired
|
||||
// private
|
||||
|
||||
/**
|
||||
* 订单状态 - 待支付
|
||||
*/
|
||||
private static final String ORDER_STATUS_TO_BE_PAID = "0";
|
||||
/**
|
||||
* 订单状态 - 待发货
|
||||
*/
|
||||
private static final String ORDER_STATUS_TO_BE_SHIPPED = "1";
|
||||
/**
|
||||
* 订单状态 - 待收货
|
||||
*/
|
||||
private static final String ORDER_STATUS_TO_BE_RECEIVED = "2";
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@@ -124,23 +136,18 @@ public class BuyOrderController {
|
||||
|
||||
|
||||
/**
|
||||
* 保存
|
||||
* 下单
|
||||
*/
|
||||
@RequestMapping("/buysave")
|
||||
@Transactional
|
||||
// @RequiresPermissions("book:buyorder:save")
|
||||
public R buysave(@RequestBody BuyOrderEntity buyOrder){
|
||||
|
||||
|
||||
BigDecimal realMoney = new BigDecimal(0);
|
||||
|
||||
Lock l = new ReentrantLock();
|
||||
l.lock();
|
||||
try {
|
||||
// 根据订单获取订单详情
|
||||
List<BuyOrderDetailEntity> products = buyOrder.getProducts();
|
||||
|
||||
BigDecimal bigDecimal1 = new BigDecimal(0);
|
||||
|
||||
ArrayList<BuyOrderDetailEntity> list = new ArrayList<>();
|
||||
|
||||
// 遍历商品 查询价格
|
||||
@@ -152,12 +159,13 @@ public class BuyOrderController {
|
||||
BigDecimal big = new BigDecimal(0);
|
||||
BigDecimal price=null;
|
||||
|
||||
//activityPrice等于0,则原价
|
||||
//activityPrice等于 0,则原价
|
||||
if (activityPrice.equals(big)||activityPrice==null) {
|
||||
price = product.getPrice();
|
||||
}else {
|
||||
price = product.getActivityPrice();
|
||||
}
|
||||
|
||||
Integer quantity = buyOrderDetail.getQuantity();
|
||||
BigDecimal bigDecimal = new BigDecimal(price.doubleValue() * quantity);
|
||||
System.out.println("bigDecimal=================bigDecimal======================"+bigDecimal);
|
||||
@@ -170,6 +178,7 @@ public class BuyOrderController {
|
||||
product.setProductStock(product.getProductStock() - buyOrderDetail.getQuantity());
|
||||
product.setSumSales(product.getSumSales() + buyOrderDetail.getQuantity());
|
||||
shopProductService.updateById(product);
|
||||
|
||||
BeanUtils.copyProperties(buyOrderDetail,buyOrderDetailEntity);
|
||||
buyOrderDetailEntity.setProductName(product.getProductName());
|
||||
buyOrderDetailEntity.setProductPrice(product.getPrice());
|
||||
@@ -200,9 +209,8 @@ public class BuyOrderController {
|
||||
String timeId = IdWorker.getTimeId().substring(0,32);
|
||||
buyOrder.setOrderSn(timeId);
|
||||
if("4".equals(buyOrder.getPaymentMethod())){
|
||||
buyOrder.setOrderStatus("1");
|
||||
buyOrder.setOrderStatus(ORDER_STATUS_TO_BE_SHIPPED);
|
||||
}
|
||||
//todo 增加结束时间
|
||||
buyOrder.setPaymentDate(new Date());
|
||||
buyOrderService.save(buyOrder);
|
||||
|
||||
|
||||
@@ -10,101 +10,107 @@ import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.xml.soap.Text;
|
||||
|
||||
/**
|
||||
* 商品订单详情表
|
||||
*
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-08-29 15:27:44
|
||||
* @modify wu chunlei
|
||||
* @date 2023-10-07 13:06:00
|
||||
*/
|
||||
@Data
|
||||
@TableName("buy_order_detail")
|
||||
public class BuyOrderDetailEntity implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 订单详情id
|
||||
*/
|
||||
@TableId
|
||||
private Long allOrderId;
|
||||
/**
|
||||
* 订单表id
|
||||
*/
|
||||
private Integer orderId;
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private Integer userId;
|
||||
/**
|
||||
* 商品id
|
||||
*/
|
||||
private Integer productId;
|
||||
/**
|
||||
* 商品名称
|
||||
*/
|
||||
private String productName;
|
||||
/**
|
||||
* 商品数量
|
||||
*/
|
||||
private Integer quantity;
|
||||
/**
|
||||
* 商品单价
|
||||
*/
|
||||
private BigDecimal productPrice;
|
||||
/**
|
||||
* 商品重量
|
||||
*/
|
||||
private Float weight;
|
||||
/**
|
||||
* 商品类型
|
||||
*/
|
||||
private String productType;
|
||||
|
||||
private String shippingSn;
|
||||
private String orderStatus;
|
||||
private String remark;
|
||||
/**
|
||||
* 下单时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)//创建注解
|
||||
private Date creatTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String image;
|
||||
|
||||
/**
|
||||
* 地址id
|
||||
*/
|
||||
private Integer addressId;
|
||||
|
||||
|
||||
/**
|
||||
* 面单html
|
||||
*/
|
||||
private String fmsHtml;
|
||||
|
||||
/**
|
||||
* 快递公司编码
|
||||
*/
|
||||
private String shipperCode;
|
||||
|
||||
/**
|
||||
* 快递公司名称
|
||||
*/
|
||||
private String shipperName;
|
||||
|
||||
/**
|
||||
* 是否已打印 0: 未打印,1:已打印
|
||||
*/
|
||||
private String isPrint;
|
||||
|
||||
/**
|
||||
* 商品图片地址
|
||||
*/
|
||||
private String productUrl;
|
||||
@TableField("record_id")
|
||||
private Integer recordId;
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**
|
||||
* 订单详情id
|
||||
*/
|
||||
@TableId
|
||||
private Long allOrderId;
|
||||
/**
|
||||
* 订单表id
|
||||
*/
|
||||
private Integer orderId;
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private Integer userId;
|
||||
/**
|
||||
* 商品id
|
||||
*/
|
||||
private Integer productId;
|
||||
/**
|
||||
* 商品名称
|
||||
*/
|
||||
private String productName;
|
||||
/**
|
||||
* 商品数量
|
||||
*/
|
||||
private Integer quantity;
|
||||
/**
|
||||
* 商品单价
|
||||
*/
|
||||
private BigDecimal productPrice;
|
||||
/**
|
||||
* 商品重量
|
||||
*/
|
||||
private Float weight;
|
||||
/**
|
||||
* 商品类型
|
||||
*/
|
||||
private String productType;
|
||||
/**
|
||||
* 物流单号
|
||||
*/
|
||||
private String shippingSn;
|
||||
/**
|
||||
* 订单状态 0-待支付 1-待发货 2-待收货
|
||||
*/
|
||||
private String orderStatus;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
/**
|
||||
* 下单时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Date creatTime;
|
||||
/**
|
||||
* 图片
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String image;
|
||||
/**
|
||||
* 地址id
|
||||
*/
|
||||
private Integer addressId;
|
||||
/**
|
||||
* 面单html
|
||||
*/
|
||||
private String fmsHtml;
|
||||
/**
|
||||
* 快递公司编码
|
||||
*/
|
||||
private String shipperCode;
|
||||
/**
|
||||
* 快递公司名称
|
||||
*/
|
||||
private String shipperName;
|
||||
/**
|
||||
* 是否已打印 0: 未打印,1:已打印
|
||||
*/
|
||||
private String isPrint;
|
||||
/**
|
||||
* 商品图片地址
|
||||
*/
|
||||
private String productUrl;
|
||||
/**
|
||||
* 评价 ID
|
||||
*/
|
||||
@TableField("record_id")
|
||||
private Integer recordId;
|
||||
|
||||
}
|
||||
|
||||
@@ -104,14 +104,11 @@ public class BuyOrderEntity implements Serializable {
|
||||
private Date shippingTime;
|
||||
/**
|
||||
* 订单状态
|
||||
*
|
||||
*
|
||||
* 0: 待付款
|
||||
* 1: 待发货
|
||||
* 2: 已发货
|
||||
* 3:已完成
|
||||
* 4: 交易失败
|
||||
*
|
||||
*/
|
||||
private String orderStatus;
|
||||
/**
|
||||
|
||||
@@ -190,8 +190,6 @@ public class WechatPayConfig implements Serializable {
|
||||
* @return
|
||||
*/
|
||||
@Bean(name = "wxPayClient")
|
||||
|
||||
|
||||
public CloseableHttpClient getWxPayClient(Verifier verifier) {
|
||||
log.info("获取HttpClient");
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@CrossOrigin //跨域
|
||||
@CrossOrigin
|
||||
@RequestMapping("/pay")
|
||||
@Configuration
|
||||
public class WeChatPayController {
|
||||
@@ -254,33 +254,24 @@ public class WeChatPayController {
|
||||
BuyOrderEntity order = this.buyOrderService.getOne(new QueryWrapper<BuyOrderEntity>().eq("order_sn", orderNo));
|
||||
PayWechatOrderEntity wechatEntity = new PayWechatOrderEntity();
|
||||
if(!ObjectUtils.isEmpty(order)){
|
||||
|
||||
wechatEntity = this.payWechatOrderService.getOne(new QueryWrapper<PayWechatOrderEntity>().eq("order_sn", order.getOrderSn()));
|
||||
}else{
|
||||
log.error("无效订单!");
|
||||
return R.error(500,"无效订单!");
|
||||
}
|
||||
// 1.根据订单id获取订单信息
|
||||
|
||||
if("order".equals(order.getOrderType())){
|
||||
|
||||
BuyOrderEntity orderEntity = buyOrderService.getBaseMapper().selectOne(new QueryWrapper<BuyOrderEntity>().eq("order_sn", wechatEntity.getOrderSn()));
|
||||
BigDecimal realMoney = orderEntity.getRealMoney();
|
||||
|
||||
//更新 订单 记录
|
||||
if (wechatEntity.getTotalAmount().compareTo(realMoney) == 0) {
|
||||
buyOrderService.updateOrderStatus(Integer.valueOf(order.getUserId()),order.getOrderSn(),"0");
|
||||
}
|
||||
|
||||
}
|
||||
if("point".equals(order.getOrderType())){
|
||||
// List<BookBuyConfigEntity> bookBuyConfigEntity = bookBuyConfigService.getBaseMapper().selectList(new QueryWrapper<BookBuyConfigEntity>().eq("price_type_id", ""));
|
||||
// 插入花生币 变动记录
|
||||
PayWechatOrderEntity buy_order_id = payWechatOrderService.getBaseMapper().selectOne(new QueryWrapper<PayWechatOrderEntity>().eq("order_sn", order.getOrderSn()));
|
||||
Integer buyorder= buy_order_id.getBuyOrderId();
|
||||
BookBuyConfigEntity bookBuyConfigEntity = bookBuyConfigService.getById(buyorder);
|
||||
|
||||
|
||||
String realMoney =bookBuyConfigEntity.getRealMoney();
|
||||
Integer money = Integer.valueOf(realMoney);
|
||||
userService.rechargeHSPoint(Integer.valueOf(order.getUserId()),money);
|
||||
@@ -288,7 +279,6 @@ public class WeChatPayController {
|
||||
transactionDetailsEntity.setUserId(order.getUserId());
|
||||
transactionDetailsEntity.setChangeAmount(new BigDecimal(money));
|
||||
transactionDetailsEntity.setOrderType("充值");
|
||||
// transactionDetailsEntity.setRelationId(wechatEntity.getId().intValue());
|
||||
transactionDetailsEntity.setRelationId(buy_order_id.getId().intValue());
|
||||
transactionDetailsEntity.setRemark("充值");
|
||||
|
||||
|
||||
@@ -41,7 +41,6 @@ public class SysLogController {
|
||||
@RequiresPermissions("sys:log:list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = sysLogService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user