package com.sqx.modules.pay.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sqx.modules.coupon.entity.Coupon;
import com.sqx.modules.coupon.service.CouponService;
import com.sqx.modules.pay.dao.PayClassifyDetailDao;
import com.sqx.modules.pay.entity.PayClassifyDetail;
import com.sqx.modules.pay.service.PayClassifyDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 充值分类子表
 */
@Service
public class PayClassifyServiceDetailImpl extends ServiceImpl<PayClassifyDetailDao, PayClassifyDetail> implements PayClassifyDetailService {

    @Autowired
    private CouponService couponService;

    @Override
    public List<PayClassifyDetail> findList(Long payClassifyId){
        List<PayClassifyDetail> list = baseMapper.findList(payClassifyId);
        for(int i=0;i<list.size();i++){
            PayClassifyDetail pcd = list.get(i);
            Coupon coupon = couponService.getById(pcd.getCouponId());
            pcd.setCoupon(coupon);
        }
        return list;
    }

    @Override
    public int updatePayClassifyDetailCouponId(Long payClassifyDetailId){
        return baseMapper.updatePayClassifyDetailCouponId(payClassifyDetailId);
    }

}
