package com.bohuikeji.delivery.backstage.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bohuikeji.delivery.backstage.constants.discountConst;
import com.bohuikeji.delivery.backstage.entity.TCustomer;
import com.bohuikeji.delivery.backstage.entity.discount.TDiscountMall;
import com.bohuikeji.delivery.backstage.mapper.TDiscountMallMapper;
import com.bohuikeji.delivery.backstage.service.ITDiscountMallService;
import com.bohuikeji.delivery.backstage.service.ITDiscountRecordService;
import com.bohuikeji.frame.module.admin.utils.FileUtil;
import com.bohuikeji.frame.module.admin.utils.MinioUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;


/**
 * <p>
 * 创建代金券批次 服务实现类
 * </p>
 *
 * @author zhouliwu
 * @since 2021-03-29
 */
@Service
public class TDiscountMallServiceImpl extends ServiceImpl<TDiscountMallMapper, TDiscountMall> implements ITDiscountMallService {

    @Autowired
    ITDiscountMallService discountMallService;
    @Autowired
    ITDiscountRecordService discountRecordService;

    @Override
    public void updateDisMall(List<TDiscountMall> discountMalls,TCustomer customer) {
        for(TDiscountMall discountMall : discountMalls){
            if(discountRecordService.saveRecord(discountMall,customer)){
                discountMall.setReceiveNum(discountMall.getReceiveNum()+1);
                discountMallService.updateById(discountMall);
            }
        }
    }

}
