This commit is contained in:
Cauchy
2023-10-18 13:02:54 +08:00
parent 113243e918
commit 5dee4b619e
27 changed files with 386 additions and 216 deletions

View File

@@ -13,13 +13,11 @@ import com.peanut.modules.pay.IOSPay.model.entities.IosPayOrderEntity;
import com.peanut.modules.pay.IOSPay.service.IapVerifyReceiptService;
import com.peanut.modules.pay.IOSPay.service.OrderService;
import com.peanut.modules.pay.IOSPay.vo.FailureVo;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
import lombok.experimental.FieldDefaults;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
@@ -88,7 +86,7 @@ public class AppController {
return Result.error("凭证不能为空");
IapResponseDTO receipt = iapVerifyReceiptService.verifyIapReceipt(dto.getReceiptData(), dto.isSandBox());
BuyOrderEntity order2 = this.buyOrderService.getOne(new QueryWrapper<BuyOrderEntity>().eq("order_sn", dto.getOrderId()).eq("del_flag", "0"));
BuyOrder order2 = this.buyOrderService.getOne(new QueryWrapper<BuyOrder>().eq("order_sn", dto.getOrderId()).eq("del_flag", "0"));
order2.setPaymentDate(new Date());

View File

@@ -1,9 +1,6 @@
package com.peanut.modules.pay.IOSPay.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.peanut.common.utils.PageUtils;
import com.peanut.common.utils.R;
import com.peanut.modules.book.entity.BuyOrderEntity;
import com.peanut.modules.pay.IOSPay.model.dto.IapRequestDTO;
import com.peanut.modules.pay.IOSPay.model.entities.IosPayOrderEntity;
import org.springframework.stereotype.Service;

View File

@@ -8,7 +8,7 @@ import com.peanut.common.utils.PageUtils;
import com.peanut.common.utils.Query;
import com.peanut.modules.app.service.UserService;
import com.peanut.modules.book.entity.BookBuyConfigEntity;
import com.peanut.modules.book.entity.BuyOrderEntity;
import com.peanut.modules.book.entity.BuyOrder;
import com.peanut.modules.book.entity.MyUserEntity;
import com.peanut.modules.book.service.BookBuyConfigService;
import com.peanut.modules.book.service.BuyOrderService;
@@ -129,7 +129,7 @@ public class OrderServiceImpl extends ServiceImpl<PayIOSOrderMapper,IosPayOrderE
BookBuyConfigEntity bookBuyConfigEntity = this.bookBuyConfigService.getById(Integer.valueOf(null == order.getProductID() ? "0" : order.getProductID()));
vo.setRealMoney(null == bookBuyConfigEntity ? "0" : bookBuyConfigEntity.getRealMoney());
BuyOrderEntity orderEntity = buyOrderService.getBaseMapper().selectOne(new QueryWrapper<BuyOrderEntity>().eq("order_sn", order.getOrderid()));
BuyOrder orderEntity = buyOrderService.getBaseMapper().selectOne(new QueryWrapper<BuyOrder>().eq("order_sn", order.getOrderid()));
if (null != orderEntity) {
vo.setPaymentMethod(orderEntity.getPaymentMethod());
}

View File

@@ -14,11 +14,9 @@ import com.peanut.modules.pay.alipay.config.AliPayUtil;
import com.peanut.modules.pay.alipay.dto.AlipayDTO;
import com.peanut.modules.pay.alipay.service.AliPayService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
@@ -74,7 +72,7 @@ public class AliPayServiceImpl implements AliPayService {
aliNotifyDto.setCustomerid(payDto.getCustomerId());
aliNotifyDto.setRelevanceoid(payDto.getRelevanceoid());
payZfbOrderService.save(aliNotifyDto);
BuyOrderEntity order = this.buyOrderService.getOne(new QueryWrapper<BuyOrderEntity>().eq("order_sn",payDto.getRelevanceoid()).eq("del_flag","0"));
BuyOrder order = this.buyOrderService.getOne(new QueryWrapper<BuyOrder>().eq("order_sn",payDto.getRelevanceoid()).eq("del_flag","0"));
order.setPaymentDate(new Date());
this.buyOrderService.updateById(order);
@@ -184,7 +182,7 @@ public class AliPayServiceImpl implements AliPayService {
if ("order".equals(subject)) {
System.out.println("=====到order更新字段==================================================================================================================");
BuyOrderEntity orderEntity = buyOrderService.getBaseMapper().selectOne(new QueryWrapper<BuyOrderEntity>().eq("order_sn", oldPayZfbOrderEntity.getRelevanceoid()));
BuyOrder orderEntity = buyOrderService.getBaseMapper().selectOne(new QueryWrapper<BuyOrder>().eq("order_sn", oldPayZfbOrderEntity.getRelevanceoid()));
System.out.println("======orderEntity=========="+orderEntity);
BigDecimal realMoney = orderEntity.getRealMoney();
System.out.println("======realMoney=========="+realMoney);

View File

@@ -137,7 +137,7 @@ public class ApplePayServiceImpl implements ApplePayService {
//如果验证后的订单号与app端传来的订单号一致并且状态为已支付状态则处理自己的业务
if (transactionID.equals(transactionId) && "PURCHASED".equals(in_app_ownership_type)) {
//===================处理自己的业务 ============================
BuyOrderEntity order = this.buyOrderService.getOne(new QueryWrapper<BuyOrderEntity>().eq("order_sn", transactionId ));
BuyOrder order = this.buyOrderService.getOne(new QueryWrapper<BuyOrder>().eq("order_sn", transactionId ));
PayWechatOrderEntity wechat = new PayWechatOrderEntity();
@@ -155,7 +155,7 @@ public class ApplePayServiceImpl implements ApplePayService {
}
if ("order".equals(order.getOrderType())) {
BuyOrderEntity orderEntity = buyOrderService.getBaseMapper().selectOne(new QueryWrapper<BuyOrderEntity>().eq("order_sn", wechat.getOrderId()));
BuyOrder orderEntity = buyOrderService.getBaseMapper().selectOne(new QueryWrapper<BuyOrder>().eq("order_sn", wechat.getOrderId()));
BigDecimal realMoney = orderEntity.getRealMoney();
//更新 订单 记录

View File

@@ -71,9 +71,9 @@ public class WeChatPayController {
@RequestMapping(value = "/placeAnOrder/shoppingPay")
@Transactional(rollbackFor = Exception.class)
public R newShoppingPay(@RequestBody WechatPaymentInfo paymentInfo) {
QueryWrapper<BuyOrderEntity> queryWrapper = new QueryWrapper<>();
QueryWrapper<BuyOrder> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("order_sn", paymentInfo.getOrderSn());
BuyOrderEntity order = buyOrderService.getOne(queryWrapper);
BuyOrder order = buyOrderService.getOne(queryWrapper);
// 判断订单是否已经过期
if (order.getOrderStatus().equals("5")) {
return R.error("订单支付超时");
@@ -121,10 +121,10 @@ public class WeChatPayController {
Map<String, Object> resourceMap = WechatPayValidator.decryptFromResource(resource, wechatPayConfig.getApiV3Key(), 1);
String orderNo = resourceMap.get("out_trade_no").toString();
// 根据订单号,做幂等处理,并且在对业务数据进行状态检查和处理之前,要采用数据锁进行并发控制,以避免函数重入造成的数据混乱
BuyOrderEntity order = this.buyOrderService.getOne(new QueryWrapper<BuyOrderEntity>().eq("order_sn", orderNo));
BuyOrder order = this.buyOrderService.getOne(new QueryWrapper<BuyOrder>().eq("order_sn", orderNo));
// 1.根据订单id获取订单信息
if ("order".equals(order.getOrderType())) {
BuyOrderEntity orderEntity = buyOrderService.getBaseMapper().selectOne(new QueryWrapper<BuyOrderEntity>().eq("order_sn", orderNo));
BuyOrder orderEntity = buyOrderService.getBaseMapper().selectOne(new QueryWrapper<BuyOrder>().eq("order_sn", orderNo));
BigDecimal realMoney = orderEntity.getRealMoney();
// 查询订单的所有 book_id
List<Integer> orderBookIdList = shopProductBookService.getOrderBookId(order.getOrderSn());