jiangqs
2023-08-06 431dde90aa20f7652092fc0bfa9e6a1a28b06b9f
ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/account/OrderPaymentServiceImpl.java
@@ -1,10 +1,16 @@
package com.ruoyi.order.service.impl.account;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.common.core.utils.uuid.IdUtils;
import com.ruoyi.order.domain.pojo.account.OrderPayment;
import com.ruoyi.order.mapper.account.OrderPaymentMapper;
import com.ruoyi.order.service.account.OrderPaymentService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.Date;
/**
 * <p>
@@ -17,4 +23,34 @@
@Service
public class OrderPaymentServiceImpl extends ServiceImpl<OrderPaymentMapper, OrderPayment> implements OrderPaymentService {
    @Override
    public void saveOrderPayment(Long userId, Long shopId, String subMchId, String orderId, BigDecimal payMoney, Date endTime,
                                 String profitSharing, String openid, String goodsNames, String prepayId) {
        OrderPayment payment = new OrderPayment();
        payment.setPaymentId(IdUtils.simpleUUID());
        payment.setUserId(userId);
        payment.setShopId(shopId);
        payment.setOrderId(orderId);
        payment.setPayMoney(payMoney);
        payment.setTimeExpire(endTime);
        payment.setSubMchId(subMchId);
        // 0 否 1、是
        payment.setProfitSharing("Y".equals(profitSharing) ? 1 : 0);
        payment.setUserOpenId(openid);
        payment.setGoodsNames(goodsNames);
        payment.setPrepayId(prepayId);
        payment.setCreateTime(new Date());
        payment.setDelFlag(0);
        this.saveOrUpdate(payment);
    }
    @Override
    public OrderPayment getByOrderId(String orderId) {
        LambdaQueryWrapper<OrderPayment> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(OrderPayment::getOrderId, orderId)
                .eq(OrderPayment::getDelFlag, 0)
                .eq(OrderPayment::getPayStatus, 2)
                .last(" limit 1 ");
        return this.getOne(queryWrapper);
    }
}