package com.jeequan.jeepay.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jeequan.jeepay.db.entity.PayOrder;
import com.jeequan.jeepay.db.entity.PayUser;
import com.jeequan.jeepay.service.mapper.PayUserMapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author [mybatis plus generator]
 * @since 2024-01-17
 */
@Service
public class PayUserService extends ServiceImpl<PayUserMapper, PayUser>{

    @Autowired private SysConfigService sysConfigService;
    @Autowired private RedPacketAccountService redPacketAccountService;

    /**
     * 初始化支付用户数据
     * @param payOrder
     */
    public void initResult(PayOrder payOrder){
        if(StringUtils.isEmpty(payOrder.getChannelUser())){
            //订单没有关联付款用户信息
            return;
        }
        PayUser user = baseMapper.selectById(payOrder.getChannelUser());
        if(user == null){
            user = new PayUser(payOrder);
            save(user);
        }
    }
}
