package com.ssm.controller;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.excel.write.metadata.style.WriteCellStyle;
import com.github.pagehelper.PageInfo;
import com.ssm.manage.response.GenericResponse;
import com.ssm.manage.response.PageResponse;
import com.ssm.core.util.EasyExcelUtil;
import com.ssm.manage.service.SsmRechargeTypeStoreService;
import com.ssm.manage.utils.SessionHelp;
import com.ssm.core.utils.BigDecimalUtils;
import com.ssm.manage.entity.*;
import com.ssm.manage.excelEntity.ExcelRechargeType;
import com.ssm.manage.query.RechargeTypeRequest;
import com.ssm.manage.response.ResponseCode;
import com.ssm.manage.service.SsmBaseStoreService;
import com.ssm.manage.service.SsmRechargeAccountService;
import com.ssm.manage.service.SsmRechargeTypeSevice;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.multipart.MultipartFile;
import tk.mybatis.mapper.entity.Example;

import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.InputStream;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

@Api(value="充值类别controller",tags={"充值类别相关接口"})
@RestController
@RequestMapping("/demay/ssm/recType")
@Slf4j
public class SsmRechargeTypeController {
    @Autowired
    private SsmRechargeTypeSevice rechargeTypeSevice;

    @Autowired
    SsmBaseStoreService ssmBaseStoreService;
    @Autowired
    private SsmRechargeTypeStoreService ssmRechargeTypeStoreService;

    @Autowired
    private SsmRechargeAccountService ssmRechargeAccountService;

    @ApiOperation(value = "分页查询充值类别  门店端-充值类别-分页查询充值类别",httpMethod = "POST",response = PageResponse.class)
    @RequestMapping("/page")
    public PageResponse selectPage(@RequestBody RechargeTypeRequest rechargeTypeRequest, HttpSession session){
        PageResponse<RechargeType> pageResponse = new PageResponse<>();
        PageInfo<RechargeType> pageInfo = new PageInfo<>();
        rechargeTypeRequest.setStoreId(SessionHelp.getStoreId(session));
        try {
            pageInfo = rechargeTypeSevice.selectPage(rechargeTypeRequest);
        }catch (Exception e){
            log.error("SsmRechargeTypeController.selectPage",e);
            pageResponse.setCodeAndMsg(ResponseCode.FAILED);
            return pageResponse;
        }
        pageResponse.setCodeAndMsg(ResponseCode.OK);
        pageResponse.setPageInfo(pageInfo);
        return pageResponse;
    }

    @ApiOperation(value = "分页查询充值类别  门店端-充值类别-分页查询充值类别(只查询折扣卡和赠送卡)",httpMethod = "POST",response = PageResponse.class)
    @RequestMapping("/newpage")
    public PageResponse selectnewPage(@RequestBody RechargeTypeRequest rechargeTypeRequest, HttpSession session){
        PageResponse<RechargeType> pageResponse = new PageResponse<>();
        PageInfo<RechargeType> pageInfo = new PageInfo<>();
//        rechargeTypeRequest.setStoreId(SessionHelp.getStoreId(session));
        try {
            pageInfo = rechargeTypeSevice.selectnewPage(rechargeTypeRequest);
        }catch (Exception e){
            log.error("SsmRechargeTypeController.selectPage",e);
            pageResponse.setCodeAndMsg(ResponseCode.FAILED);
            return pageResponse;
        }
        pageResponse.setCodeAndMsg(ResponseCode.OK);
        pageResponse.setPageInfo(pageInfo);
        return pageResponse;
    }

    @ApiOperation(value = "分页查询充值类别  门店端-充值类别-分页查询充值类别(只查询促销卡)",httpMethod = "POST",response = PageResponse.class)
    @RequestMapping("/newpages")
    public PageResponse selectnewPages(@RequestBody RechargeTypeRequest rechargeTypeRequest, HttpSession session){
        PageResponse<RechargeType> pageResponse = new PageResponse<>();
        PageInfo<RechargeType> pageInfo = new PageInfo<>();
        rechargeTypeRequest.setStoreId(SessionHelp.getStoreId(session));
        try {
            pageInfo = rechargeTypeSevice.selectnewPages(rechargeTypeRequest);
        }catch (Exception e){
            log.error("SsmRechargeTypeController.selectPage",e);
            pageResponse.setCodeAndMsg(ResponseCode.FAILED);
            return pageResponse;
        }
        pageResponse.setCodeAndMsg(ResponseCode.OK);
        pageResponse.setPageInfo(pageInfo);
        return pageResponse;
    }


    @ApiOperation(value = "分页查询充值类别  门店端-充值类别-分页查询充值类别(只查询促销卡)",httpMethod = "POST",response = PageResponse.class)
    @RequestMapping("/selectpromotionPage")
    public PageResponse selectpromotionPage(@RequestBody RechargeTypeRequest rechargeTypeRequest, HttpSession session){
        PageResponse<RechargeType> pageResponse = new PageResponse<>();
        PageInfo<RechargeType> pageInfo = new PageInfo<>();
//        rechargeTypeRequest.setStoreId(SessionHelp.getStoreId(session));
        try {
            pageInfo = rechargeTypeSevice.selectpromotionPage(rechargeTypeRequest);
        }catch (Exception e){
            log.error("SsmRechargeTypeController.selectPage",e);
            pageResponse.setCodeAndMsg(ResponseCode.FAILED);
            return pageResponse;
        }
        pageResponse.setCodeAndMsg(ResponseCode.OK);
        pageResponse.setPageInfo(pageInfo);
        return pageResponse;
    }

    @ApiOperation(value = "充值类别添加  门店端-充值类别-充值类别添加",httpMethod = "POST",response = GenericResponse.class)
//    @RequestMapping("/add")
    @RequestMapping("/addPromotionCourse")
    public GenericResponse add(@RequestBody RechargeTypeRequest rechargeTypeRequest, HttpSession session){
        GenericResponse<RechargeType> genericResponse = new GenericResponse<>();
//        if (StringUtils.isBlank(rechargeTypeRequest.getRechargeTypeNum())){
//            genericResponse.setCodeAndMsg(ResponseCode.PARAMETER_NOT_EXIST_S,"充值类别编码");
//            return genericResponse;
//        }
        if (StringUtils.isBlank(rechargeTypeRequest.getRechargeTypeName())){
            genericResponse.setCodeAndMsg(ResponseCode.PARAMETER_NOT_EXIST_S,"充值类别名称");
            return genericResponse;
        }
        if (BigDecimalUtils.compareTo(rechargeTypeRequest.getTypeRatio(), rechargeTypeRequest.getRechargeMoney()) != -1){
            genericResponse.setCodeAndMsg(ResponseCode.NOT_MEET_REQUIREMENTS_S,"充值类别提成");
            return genericResponse;
        }
        Long storeId = SessionHelp.getStoreId(session);
        String storeName = SessionHelp.getStoreName(session);
        BaseStore baseStore = ssmBaseStoreService.selectByPrimaryKey(storeId);
        if(baseStore.getParentId()!=null){
            storeId = baseStore.getParentId();
            baseStore = ssmBaseStoreService.selectByPrimaryKey(storeId);
            storeName = baseStore.getStoreName();
        }

//        rechargeTypeRequest.setStoreId(Long.valueOf("265309505575694336"));
        rechargeTypeRequest.setStoreId(storeId);
        rechargeTypeRequest.setStoreName(storeName);
        String phone = SessionHelp.getLoginAccount(session);
        int i = 0;
        try {
            if(rechargeTypeRequest.getType()==1){
                if(rechargeTypeRequest.getDiscount().longValue()<0||rechargeTypeRequest.getTypeRatio().longValue()<0||rechargeTypeRequest.getFirstAmount().doubleValue()<0||rechargeTypeRequest.getRechargeMoney().doubleValue()<0){
                    throw new SmsException("010000","操作失败，不能输入负数");
                }
            }else{
                if(rechargeTypeRequest.getGiftMoney()==null)
                    rechargeTypeRequest.setGiftMoney(new BigDecimal("0"));
                if(rechargeTypeRequest.getDiscount().longValue()<0||rechargeTypeRequest.getGiftMoney().longValue()<0||rechargeTypeRequest.getTypeRatio().longValue()<0||rechargeTypeRequest.getFirstAmount().doubleValue()<0||rechargeTypeRequest.getRechargeMoney().doubleValue()<0){
                    throw new SmsException("010000","操作失败，不能输入负数");
                }
            }

            i = rechargeTypeSevice.addRecharge(rechargeTypeRequest, phone);
        }catch (SmsException e){
            genericResponse.setCodeAndMsg(e);
            return genericResponse;
        }catch (Exception e){
            log.error("SsmRechargeTypeController.add",e);
            genericResponse.setCodeAndMsg(ResponseCode.FAILED);
            return genericResponse;
        }
        if (i > 0){
            genericResponse.setCodeAndMsg(ResponseCode.OK);
        }
        return genericResponse;
    }

    @ApiOperation(value = "充值类别添加  门店端-充值类别-充值类别添加",httpMethod = "POST",response = GenericResponse.class)
    @RequestMapping("/add")
//    @RequestMapping("/addPromotionCourse")
    public GenericResponse addPromotionCourse(@RequestBody RechargeTypeRequest rechargeTypeRequest, HttpSession session){
        GenericResponse<RechargeType> genericResponse = new GenericResponse<>();
//        if (StringUtils.isBlank(rechargeTypeRequest.getRechargeTypeNum())){
//            genericResponse.setCodeAndMsg(ResponseCode.PARAMETER_NOT_EXIST_S,"充值类别编码");
//            return genericResponse;
//        }
        if (StringUtils.isBlank(rechargeTypeRequest.getRechargeTypeName())){
            genericResponse.setCodeAndMsg(ResponseCode.PARAMETER_NOT_EXIST_S,"充值类别名称");
            return genericResponse;
        }
        if (BigDecimalUtils.compareTo(rechargeTypeRequest.getTypeRatio(), rechargeTypeRequest.getRechargeMoney()) != -1){
            genericResponse.setCodeAndMsg(ResponseCode.NOT_MEET_REQUIREMENTS_S,"充值类别提成");
            return genericResponse;
        }
        Long storeId = SessionHelp.getStoreId(session);
        String storeName = SessionHelp.getStoreName(session);
        BaseStore baseStore = ssmBaseStoreService.selectByPrimaryKey(storeId);
        if(baseStore.getParentId()!=null){
            storeId = baseStore.getParentId();
            baseStore = ssmBaseStoreService.selectByPrimaryKey(storeId);
            storeName = baseStore.getStoreName();
        }

//        rechargeTypeRequest.setStoreId(Long.valueOf("265309505575694336"));
        rechargeTypeRequest.setStoreId(storeId);
        rechargeTypeRequest.setStoreName(storeName);
        String phone = SessionHelp.getLoginAccount(session);
        int i = 0;
        try {
            if(rechargeTypeRequest.getType()==1){
                if(rechargeTypeRequest.getDiscount().longValue()<0||rechargeTypeRequest.getTypeRatio().longValue()<0||rechargeTypeRequest.getFirstAmount().doubleValue()<0||rechargeTypeRequest.getRechargeMoney().doubleValue()<0){
                    throw new SmsException("010000","操作失败，不能输入负数");
                }
            }else{
                if(rechargeTypeRequest.getGiftMoney()==null)
                    rechargeTypeRequest.setGiftMoney(new BigDecimal("0"));
                if(rechargeTypeRequest.getDiscount().longValue()<0||rechargeTypeRequest.getGiftMoney().longValue()<0||rechargeTypeRequest.getTypeRatio().longValue()<0||rechargeTypeRequest.getFirstAmount().doubleValue()<0||rechargeTypeRequest.getRechargeMoney().doubleValue()<0){
                    throw new SmsException("010000","操作失败，不能输入负数");
                }
            }

            i = rechargeTypeSevice.addPromotionCourse(rechargeTypeRequest, phone);
        }catch (SmsException e){
            genericResponse.setCodeAndMsg(e);
            return genericResponse;
        }catch (Exception e){
            log.error("SsmRechargeTypeController.add",e);
            genericResponse.setCodeAndMsg(ResponseCode.FAILED);
            return genericResponse;
        }
        if (i > 0){
            genericResponse.setCodeAndMsg(ResponseCode.OK);
        }
        return genericResponse;
    }



    @ApiOperation(value = "充值类别修改   门店端-充值类别-充值类别修改",httpMethod = "POST",response = GenericResponse.class)
//    @RequestMapping("/update")
    @RequestMapping("/updatePromotionRecharge")
    public GenericResponse update(@RequestBody RechargeTypeRequest rechargeTypeRequest,HttpSession session){
        GenericResponse<RechargeType> genericResponse = new GenericResponse<>();
        if (BigDecimalUtils.compareTo(rechargeTypeRequest.getTypeRatio(), rechargeTypeRequest.getRechargeMoney()) != -1){
            genericResponse.setCodeAndMsg(ResponseCode.NOT_MEET_REQUIREMENTS_S,"充值类别提成");
            return genericResponse;
        }
        rechargeTypeRequest.setStoreId(SessionHelp.getStoreId(session));
        String phone = SessionHelp.getLoginAccount(session);
        int i = 0;
        try {
            if(rechargeTypeRequest.getType()==1){
                if(rechargeTypeRequest.getDiscount().longValue()<0||rechargeTypeRequest.getTypeRatio().longValue()<0||rechargeTypeRequest.getFirstAmount().doubleValue()<0||rechargeTypeRequest.getRechargeMoney().doubleValue()<0){
                    throw new SmsException("010000","操作失败，不能输入负数");
                }
            }else{
                if(rechargeTypeRequest.getGiftMoney()==null)
                    rechargeTypeRequest.setGiftMoney(new BigDecimal("0"));
                if(rechargeTypeRequest.getDiscount().longValue()<0||rechargeTypeRequest.getGiftMoney().longValue()<0||rechargeTypeRequest.getTypeRatio().longValue()<0||rechargeTypeRequest.getFirstAmount().doubleValue()<0||rechargeTypeRequest.getRechargeMoney().doubleValue()<0){
                    throw new SmsException("010000","操作失败，不能输入负数");
                }
            }
            RechargeType rechargeType = new RechargeType();
            rechargeType.setId(rechargeTypeRequest.getId());
            RechargeType rechargeType1 = rechargeTypeSevice.selectOne(rechargeType);
            if(rechargeType1.getType() != rechargeTypeRequest.getType()){
                RechargeAccount rechargeAccount = new RechargeAccount();
                rechargeAccount.setRechargeTypeId(rechargeTypeRequest.getId());
                int rechargeAccounts = ssmRechargeAccountService.selectCount(rechargeAccount);
                if(rechargeAccounts >0){
                    genericResponse.setCodeAndMsg(ResponseCode.DATA_ALREADY_EXISTS_SSSS);
                    return genericResponse;
                }else{
                    i = rechargeTypeSevice.updateRecharge(rechargeTypeRequest, phone);
                }
            }else{
                i = rechargeTypeSevice.updateRecharge(rechargeTypeRequest, phone);
            }
        }catch (SmsException e){
            genericResponse.setCodeAndMsg(e);
            return genericResponse;
        }catch (Exception e){
            log.error("SsmRechargeTypeController.update",e);
            genericResponse.setCodeAndMsg(ResponseCode.FAILED);
            return genericResponse;
        }
        if (i > 0){
            genericResponse.setCodeAndMsg(ResponseCode.OK);
        }
        return genericResponse;
    }


    @ApiOperation(value = "充值类别修改   门店端-充值类别-充值类别修改",httpMethod = "POST",response = GenericResponse.class)
    @RequestMapping("/update")
//    @RequestMapping("/updatePromotionRecharge")
    public GenericResponse updatePromotionRecharge(@RequestBody RechargeTypeRequest rechargeTypeRequest,HttpSession session){
        GenericResponse<RechargeType> genericResponse = new GenericResponse<>();
        if (BigDecimalUtils.compareTo(rechargeTypeRequest.getTypeRatio(), rechargeTypeRequest.getRechargeMoney()) != -1){
            genericResponse.setCodeAndMsg(ResponseCode.NOT_MEET_REQUIREMENTS_S,"充值类别提成");
            return genericResponse;
        }
        rechargeTypeRequest.setStoreId(SessionHelp.getStoreId(session));
        String phone = SessionHelp.getLoginAccount(session);
        int i = 0;
        if(rechargeTypeRequest.getType()==1){
            if(rechargeTypeRequest.getDiscount().longValue()<0||rechargeTypeRequest.getTypeRatio().longValue()<0||rechargeTypeRequest.getFirstAmount().doubleValue()<0||rechargeTypeRequest.getRechargeMoney().doubleValue()<0){
                genericResponse.setCodeAndMsg(ResponseCode.MSG,"操作失败，不能输入负数");
                return genericResponse;
            }
        }else{
            if(rechargeTypeRequest.getGiftMoney()==null)
                rechargeTypeRequest.setGiftMoney(new BigDecimal("0"));
            if(rechargeTypeRequest.getDiscount().longValue()<0||rechargeTypeRequest.getGiftMoney().longValue()<0||rechargeTypeRequest.getTypeRatio().longValue()<0||rechargeTypeRequest.getFirstAmount().doubleValue()<0||rechargeTypeRequest.getRechargeMoney().doubleValue()<0){
                genericResponse.setCodeAndMsg(ResponseCode.MSG,"操作失败，不能输入负数");
                return genericResponse;
            }
        }
        try {
            RechargeType rechargeType = new RechargeType();
            rechargeType.setId(rechargeTypeRequest.getId());
            RechargeType rechargeType1 = rechargeTypeSevice.selectOne(rechargeType);
            //这个是判断前后类型是否一致
            if(rechargeType1.getType() != rechargeTypeRequest.getType()){
                RechargeAccount rechargeAccount = new RechargeAccount();
                rechargeAccount.setRechargeTypeId(rechargeTypeRequest.getId());
                int rechargeAccounts = ssmRechargeAccountService.selectCount(rechargeAccount);
                //查询当前的充值卡有无发生交易，有则不允许进行修改
                if(rechargeAccounts >0){
                    genericResponse.setCodeAndMsg(ResponseCode.DATA_ALREADY_EXISTS_SSSS);
                    return genericResponse;
                }else{
                    i = rechargeTypeSevice.updatePromotionRecharge(rechargeTypeRequest, phone);
                }
            }else{
                i = rechargeTypeSevice.updatePromotionRecharge(rechargeTypeRequest, phone);
            }
        }catch (SmsException e){
            genericResponse.setCodeAndMsg(e);
            return genericResponse;
        }
        catch (Exception e){
            System.out.println("e.getMessage() = " + e.getMessage());
            log.error("SsmRechargeTypeController.update",e);
            genericResponse.setCodeAndMsg(ResponseCode.FAILED);
            return genericResponse;
        }

        if (i > 0){
            genericResponse.setCodeAndMsg(ResponseCode.OK);
        }
        return genericResponse;
    }


    @ApiOperation(value = "充值类别删除  门店端-充值类别-充值类别删除",httpMethod = "POST",response = GenericResponse.class)
    @RequestMapping("/delete")
    public GenericResponse delete(@RequestBody RechargeTypeRequest rechargeTypeRequest,HttpSession session){
        GenericResponse<RechargeType> genericResponse = new GenericResponse<>();
        rechargeTypeRequest.setStoreId(SessionHelp.getStoreId(session));
        int i = 0;
        try {
            RechargeAccount rechargeAccount = new RechargeAccount();
            rechargeAccount.setRechargeTypeId(rechargeTypeRequest.getId());
            int rechargeAccounts = ssmRechargeAccountService.selectCount(rechargeAccount);
            if(rechargeAccounts >0){
                genericResponse.setCodeAndMsg(ResponseCode.DATA_ALREADY_EXISTS_SSS);
                return genericResponse;
            }else{
                i = rechargeTypeSevice.deleteRecharge(rechargeTypeRequest);
            }

        }catch (Exception e){
            log.error("SsmRechargeTypeController.delete",e);
            genericResponse.setCodeAndMsg(ResponseCode.FAILED);
            return genericResponse;
        }
        if (i > 0){
            genericResponse.setCodeAndMsg(ResponseCode.OK);
        }
        return genericResponse;
    }


    @ApiOperation(value = "充值类别启用停用   门店端-充值类别-充值类别启用停用",httpMethod = "POST",response = GenericResponse.class)
    @RequestMapping("/updateStates")
    public GenericResponse updateStates(@RequestBody RechargeTypeRequest rechargeTypeRequest,HttpSession session){
        GenericResponse<RechargeType> genericResponse = new GenericResponse<>();
        rechargeTypeRequest.setStoreId(SessionHelp.getStoreId(session));
        int i = 0;
        try {
            i = rechargeTypeSevice.updateStates(rechargeTypeRequest);
        }catch (Exception e){
            log.error("SsmRechargeTypeController.updateStates",e);
            genericResponse.setCodeAndMsg(ResponseCode.FAILED);
            return genericResponse;
        }
        if (i > 0){
            genericResponse.setCodeAndMsg(ResponseCode.OK);
        }
        return genericResponse;
    }

    @ApiOperation(value = "查询充值类别List  门店端-充值单据-充值类别查询List",httpMethod = "POST",response = GenericResponse.class)
    @RequestMapping("/list")
    public GenericResponse selectList(@RequestBody RechargeTypeRequest rechargeTypeRequest,HttpSession session){
        GenericResponse<RechargeType> genericResponse = new GenericResponse<>();
        Long storeId = SessionHelp.getStoreId(session);
        if(null==rechargeTypeRequest.getStoreId()){
            rechargeTypeRequest.setStoreId(storeId);
        }
        List<RechargeType> list = new ArrayList<>();
        try {
            list = rechargeTypeSevice.selectList(rechargeTypeRequest,storeId);
        }catch (Exception e){
            log.error("SsmRechargeTypeController.selectList:",e);
            genericResponse.setCodeAndMsg(ResponseCode.FAILED);
            return genericResponse;
        }
        genericResponse.setCodeAndMsg(ResponseCode.OK);
        genericResponse.setRows(list);
        return genericResponse;
    }

    @ApiOperation(value = "门店充值类别模板下载  门店端-充值类别列表-门店充值类别模板下载", httpMethod = "POST", response = GenericResponse.class)
    @RequestMapping("/download")
    public void download(HttpSession session, HttpServletResponse response) {

        // 模板注意 用{} 来表示你要用的变量 如果本来就有"{","}" 特殊字符 用"\{","\}"代替
        // {} 代表普通变量 {.} 代表是list的变量 {前缀.} 前缀可以区分不同的list
        ExcelWriter excelWriter = null;
        OutputStream out = null;
        try {
            String fileName = "recType";
            response = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getResponse();
            response.setContentType("application/vnd.ms-excel;charset=utf-8");
            response.setHeader("Content-Disposition",
                    "attachment;filename=" + new String(fileName.getBytes("utf-8"), "ISO8859-1") + ".xlsx");
            out = response.getOutputStream();
            //ClassPathResource classPathResource = new ClassPathResource("static/live_room_data3.xls");
            //InputStream inputStream = classPathResource.getInputStream();
            InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("config/recType.xlsx");

            List<ExcelRechargeType> list = new ArrayList<>();
            WriteCellStyle headWriteCellStyle = new WriteCellStyle();
            // 这里 需要指定写用哪个class去写，然后写到第一个sheet，名字为模板 然后文件流会自动关闭
            //EasyExcel.write(out, LiveRoomData.class).sheet("模板").doWrite(list);
            excelWriter = EasyExcel.write(out).withTemplate(inputStream).build();
            //FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();
            WriteSheet writeSheet = EasyExcel.writerSheet().build();
            excelWriter.fill(list, writeSheet);
            out.flush();
        } catch (Exception e) {
            log.error("SsmRechargeTypeController.download:",e);
        } finally {
            //destFile.delete();
            // 别忘记关闭流
            excelWriter.finish();
        }
    }

    @ApiOperation(value = "门店充值类别模板下载  门店端-充值类别列表-门店充值类别模板下载(促销卡)", httpMethod = "POST", response = GenericResponse.class)
    @RequestMapping("/downloads")
    public void downloads(HttpSession session, HttpServletResponse response) {

        // 模板注意 用{} 来表示你要用的变量 如果本来就有"{","}" 特殊字符 用"\{","\}"代替
        // {} 代表普通变量 {.} 代表是list的变量 {前缀.} 前缀可以区分不同的list
        ExcelWriter excelWriter = null;
        OutputStream out = null;
        try {
            String fileName = "recType";
            response = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getResponse();
            response.setContentType("application/vnd.ms-excel;charset=utf-8");
            response.setHeader("Content-Disposition",
                    "attachment;filename=" + new String(fileName.getBytes("utf-8"), "ISO8859-1") + ".xlsx");
            out = response.getOutputStream();
            //ClassPathResource classPathResource = new ClassPathResource("static/live_room_data3.xls");
            //InputStream inputStream = classPathResource.getInputStream();
            InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("config/recTypes.xlsx");

            List<ExcelRechargeType> list = new ArrayList<>();
            WriteCellStyle headWriteCellStyle = new WriteCellStyle();
            // 这里 需要指定写用哪个class去写，然后写到第一个sheet，名字为模板 然后文件流会自动关闭
            //EasyExcel.write(out, LiveRoomData.class).sheet("模板").doWrite(list);
            excelWriter = EasyExcel.write(out).withTemplate(inputStream).build();
            //FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();
            WriteSheet writeSheet = EasyExcel.writerSheet().build();
            excelWriter.fill(list, writeSheet);
            out.flush();
        } catch (Exception e) {
            log.error("SsmRechargeTypeController.download:",e);
        } finally {
            //destFile.delete();
            // 别忘记关闭流
            excelWriter.finish();
        }
    }

    @ApiOperation(value = "门店充值类别批量导出  门店端-充值类别列表-门店充值类别批量导出", httpMethod = "POST", response = GenericResponse.class)
    @RequestMapping("/export")
    public void export(@RequestBody RechargeTypeRequest rechargeTypeRequest, HttpSession session) {
        // 模板注意 用{} 来表示你要用的变量 如果本来就有"{","}" 特殊字符 用"\{","\}"代替
        // {} 代表普通变量 {.} 代表是list的变量 {前缀.} 前缀可以区分不同的list
        ExcelWriter excelWriter = null;
        OutputStream out = null;
        rechargeTypeRequest.setStoreId(SessionHelp.getStoreId(session));
        rechargeTypeRequest.setStoreName(SessionHelp.getStoreName(session));
        RechargeType rechargeType = new RechargeType();
        try {
            String fileName = "recType";
            HttpServletResponse response = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getResponse();
            response.setContentType("application/vnd.ms-excel;charset=utf-8");
            response.setHeader("Content-Disposition",
                    "attachment;filename=" + new String(fileName.getBytes("utf-8"), "ISO8859-1") + ".xlsx");
            out = response.getOutputStream();
            //ClassPathResource classPathResource = new ClassPathResource("static/live_room_data3.xls");
            //InputStream inputStream = classPathResource.getInputStream();
            InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("config/recType.xlsx");
//            BeanUtils.copyProperties(rechargeTypeRequest, rechargeType);
//            List<RechargeType> list = rechargeTypeSevice.select(rechargeType);
            Example example = new Example(RechargeType.class);
            Example.Criteria criteria = example.createCriteria();
            example.setOrderByClause("recharge_type_num desc");
            if (StringUtils.isNotBlank(rechargeTypeRequest.getRechargeTypeName())){
                criteria.andLike("rechargeTypeName","%" + rechargeTypeRequest.getRechargeTypeName() + "%");
            }
            if (rechargeTypeRequest.getState() != null){
                criteria.andEqualTo("state",rechargeTypeRequest.getState());
            }
            List<Integer> objects = new ArrayList<>();
            objects.add(0);
            objects.add(1);

            criteria.andEqualTo("storeId",rechargeTypeRequest.getStoreId());
            criteria.andEqualTo("cardType",0);
            criteria.andIn("type",objects);
            List<RechargeType> list = rechargeTypeSevice.selectByExample(example);
            List<ExcelRechargeType> excelRechargeTypeList = new ArrayList<>();
            for (RechargeType type : list) {
                ExcelRechargeType excelRechargeType = new ExcelRechargeType();
                BeanUtils.copyProperties(type, excelRechargeType);
                if (type.getState() == 1){
                    excelRechargeType.setState("启用");
                }else if (type.getState() == 0){
                    excelRechargeType.setState("禁用");
                }
                if (type.getType() == 1){
                    excelRechargeType.setType("折扣卡");
                }else if (type.getType() == 0){
                    excelRechargeType.setType("赠送卡");
                }
                if(null != type.getDonateType()){
                    if (type.getDonateType() == 0){
                        excelRechargeType.setDonateType("固定赠送");
                    }else if (type.getDonateType() == 1){
                        excelRechargeType.setDonateType("比例赠送");
                    }
                }else{
                    excelRechargeType.setDonateType("非赠送卡");
                }
                excelRechargeTypeList.add(excelRechargeType);
            }
            WriteCellStyle headWriteCellStyle = new WriteCellStyle();
            // 这里 需要指定写用哪个class去写，然后写到第一个sheet，名字为模板 然后文件流会自动关闭
            //EasyExcel.write(out, LiveRoomData.class).sheet("模板").doWrite(list);
            excelWriter = EasyExcel.write(out).withTemplate(inputStream).build();
            //FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();
            WriteSheet writeSheet = EasyExcel.writerSheet().build();
            excelWriter.fill(excelRechargeTypeList, writeSheet);
            out.flush();
        } catch (Exception e) {
            log.error("SsmRechargeTypeController.export:",e);
        } finally {
            //destFile.delete();
            // 别忘记关闭流
            excelWriter.finish();
        }
    }

    @ApiOperation(value = "门店充值类别批量导出  门店端-充值类别列表-门店充值类别批量导出(促销)", httpMethod = "POST", response = GenericResponse.class)
    @RequestMapping("/exports")
    public void exports(@RequestBody RechargeTypeRequest rechargeTypeRequest, HttpSession session) {
        // 模板注意 用{} 来表示你要用的变量 如果本来就有"{","}" 特殊字符 用"\{","\}"代替
        // {} 代表普通变量 {.} 代表是list的变量 {前缀.} 前缀可以区分不同的list
        ExcelWriter excelWriter = null;
        OutputStream out = null;
        rechargeTypeRequest.setStoreId(SessionHelp.getStoreId(session));
        rechargeTypeRequest.setStoreName(SessionHelp.getStoreName(session));
        RechargeType rechargeType = new RechargeType();
        try {
            String fileName = "recType";
            HttpServletResponse response = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getResponse();
            response.setContentType("application/vnd.ms-excel;charset=utf-8");
            response.setHeader("Content-Disposition",
                    "attachment;filename=" + new String(fileName.getBytes("utf-8"), "ISO8859-1") + ".xlsx");
            out = response.getOutputStream();
            //ClassPathResource classPathResource = new ClassPathResource("static/live_room_data3.xls");
            //InputStream inputStream = classPathResource.getInputStream();
            InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("config/recTypes.xlsx");
//            BeanUtils.copyProperties(rechargeTypeRequest, rechargeType);
//            List<RechargeType> list = rechargeTypeSevice.select(rechargeType);
            Example example = new Example(RechargeType.class);
            Example.Criteria criteria = example.createCriteria();
            example.setOrderByClause("recharge_type_num desc");
            if (StringUtils.isNotBlank(rechargeTypeRequest.getRechargeTypeName())){
                criteria.andLike("rechargeTypeName","%" + rechargeTypeRequest.getRechargeTypeName() + "%");
            }
            if (rechargeTypeRequest.getState() != null){
                criteria.andEqualTo("state",rechargeTypeRequest.getState());
            }

            criteria.andEqualTo("storeId",rechargeTypeRequest.getStoreId());
            criteria.andEqualTo("cardType",0);
            criteria.andEqualTo("type",2);
            List<RechargeType> list = rechargeTypeSevice.selectByExample(example);
            List<ExcelRechargeType> excelRechargeTypeList = new ArrayList<>();
            for (RechargeType type : list) {
                ExcelRechargeType excelRechargeType = new ExcelRechargeType();
                BeanUtils.copyProperties(type, excelRechargeType);
                if (type.getState() == 1){
                    excelRechargeType.setState("启用");
                }else if (type.getState() == 0){
                    excelRechargeType.setState("禁用");
                }
                if (type.getType() == 1){
                    excelRechargeType.setType("折扣卡");
                }else if (type.getType() == 0){
                    excelRechargeType.setType("赠送卡");
                }else if (type.getType() == 2){
                    excelRechargeType.setType("促销卡");
                }
                if(null != type.getDonateType()){
                    if (type.getDonateType() == 0){
                        excelRechargeType.setDonateType("固定赠送");
                    }else if (type.getDonateType() == 1){
                        excelRechargeType.setDonateType("比例赠送");
                    }
                }else{
                    excelRechargeType.setDonateType("非赠送卡");
                }
                if(type.getStoreType()==1){
                    RechargeTypeStore rechargeTypeStore = new RechargeTypeStore();
                    rechargeTypeStore.setRechargeId(type.getId());
                    List<RechargeTypeStore> select = ssmRechargeTypeStoreService.select(rechargeTypeStore);
                    String storeName = "";
                    for (RechargeTypeStore typeStore : select) {
                        storeName = storeName + typeStore.getStoreName()+"—";
                    }
                    excelRechargeType.setStoreNum(storeName);
                }else {
                    excelRechargeType.setStoreNum("所有门店");
                }
                if(type.getGiveType()==1){

                    excelRechargeType.setIsStoreUse("是");
                }else {
                    excelRechargeType.setIsStoreUse("否");

                }
                excelRechargeTypeList.add(excelRechargeType);
            }
            WriteCellStyle headWriteCellStyle = new WriteCellStyle();
            // 这里 需要指定写用哪个class去写，然后写到第一个sheet，名字为模板 然后文件流会自动关闭
            //EasyExcel.write(out, LiveRoomData.class).sheet("模板").doWrite(list);
            excelWriter = EasyExcel.write(out).withTemplate(inputStream).build();
            //FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();
            WriteSheet writeSheet = EasyExcel.writerSheet().build();
            excelWriter.fill(excelRechargeTypeList, writeSheet);
            out.flush();
        } catch (Exception e) {
            log.error("SsmRechargeTypeController.export:",e);
        } finally {
            //destFile.delete();
            // 别忘记关闭流
            excelWriter.finish();
        }
    }


    @ApiOperation(value = "门店充值类别批量导入  门店端-充值类别列表-门店充值类别批量导入", httpMethod = "POST", response = GenericResponse.class)
    @RequestMapping("/import")
    public GenericResponse recTypeImport(MultipartFile multipartFile, HttpSession session) {
        GenericResponse genericResponse = new GenericResponse();
        Long storeId = SessionHelp.getStoreId(session);
        String storeName = SessionHelp.getStoreName(session);
        String key = SessionHelp.getLoginAccount(session);
        List<ExcelRechargeType> list = null;
        try {
            list = EasyExcelUtil.simpleWrite(multipartFile, ExcelRechargeType.class);
        } catch (SmsException e) {
            log.error("SsmRechargeTypeController.recTypeImport:",e);
            return genericResponse;
        }

        List<RechargeType> rechargeTypeList = new ArrayList<>();
        for (ExcelRechargeType excelRechargeType : list) {
            RechargeType rechargeType = new RechargeType();
            BeanUtils.copyProperties(excelRechargeType, rechargeType);
            if (excelRechargeType.getState().equals("启用")){
                rechargeType.setState(1);
            }else if (excelRechargeType.getState().equals("禁用")){
                rechargeType.setState(0);
            }
            if(excelRechargeType.getType().equals("折扣卡")){
                rechargeType.setType(1);
            }else if (excelRechargeType.getType().equals("赠送卡")){
                rechargeType.setType(0);
            }
            if(excelRechargeType.getDonateType().equals("固定赠送")){
                rechargeType.setDonateType(0);
            }else if (excelRechargeType.getDonateType().equals("比例赠送")){
                rechargeType.setDonateType(1);
            }
            rechargeTypeList.add(rechargeType);
        }
        List<RechargeType> unusualList = new ArrayList<>();
        try {
            unusualList = rechargeTypeSevice.insertBatch(rechargeTypeList,storeId, storeName, key);
        }catch (SmsException e){
            genericResponse.setCodeAndMsg(e);
            return genericResponse;
        }catch (Exception e){
            log.error("SsmRechargeTypeController.recTypeImport:",e);
            genericResponse.setCodeAndMsg(ResponseCode.FAILED);
            return genericResponse;
        }

        if (!unusualList.isEmpty()) {
           genericResponse.setRows(unusualList);
        }

        return genericResponse;

    }

    @ApiOperation(value = "门店充值类别批量导入  门店端-充值类别列表-门店充值类别批量导入(促销)", httpMethod = "POST", response = GenericResponse.class)
    @RequestMapping("/imports")
    public GenericResponse recTypeImports(MultipartFile multipartFile, HttpSession session) {
        GenericResponse genericResponse = new GenericResponse();
        Long storeId = SessionHelp.getStoreId(session);
        String storeName = SessionHelp.getStoreName(session);
        String key = SessionHelp.getLoginAccount(session);
        List<ExcelRechargeType> list = null;
        try {
            list = EasyExcelUtil.simpleWrite(multipartFile, ExcelRechargeType.class);
        } catch (SmsException e) {
            log.error("SsmRechargeTypeController.recTypeImport:",e);
            return genericResponse;
        }

        List<RechargeType> rechargeTypeList = new ArrayList<>();
        for (ExcelRechargeType excelRechargeType : list) {
            RechargeType rechargeType = new RechargeType();
            BeanUtils.copyProperties(excelRechargeType, rechargeType);
            if (excelRechargeType.getState().equals("启用")){
                rechargeType.setState(1);
            }else if (excelRechargeType.getState().equals("禁用")){
                rechargeType.setState(0);
            }
            if(excelRechargeType.getType().equals("折扣卡")){
                rechargeType.setType(1);
            }else if (excelRechargeType.getType().equals("赠送卡")){
                rechargeType.setType(0);
            }else if (excelRechargeType.getType().equals("促销卡")){
                rechargeType.setType(2);
            }
            if(null != excelRechargeType.getDonateType()){
                if(excelRechargeType.getDonateType().equals("固定赠送")){
                    rechargeType.setDonateType(0);
                }else if (excelRechargeType.getDonateType().equals("比例赠送")){
                    rechargeType.setDonateType(1);
                }
            }
            rechargeTypeList.add(rechargeType);
        }
        List<RechargeType> unusualList = new ArrayList<>();
        try {
            unusualList = rechargeTypeSevice.insertBatch(rechargeTypeList,storeId, storeName, key);
        }catch (SmsException e){
            genericResponse.setCodeAndMsg(e);
            return genericResponse;
        }catch (Exception e){
            log.error("SsmRechargeTypeController.recTypeImport:",e);
            genericResponse.setCodeAndMsg(ResponseCode.FAILED);
            return genericResponse;
        }

        if (!unusualList.isEmpty()) {
            genericResponse.setRows(unusualList);
        }

        return genericResponse;

    }

    @ApiOperation(value = "查询充值类别可升降级优惠",httpMethod = "POST",response = GenericResponse.class)
    @RequestMapping("/sjianjiList")
    public GenericResponse selectsjianjiList(@RequestBody RechargeTypeRequest rechargeTypeRequest,HttpSession session){
        GenericResponse<RechargeType> genericResponse = new GenericResponse<>();
        Long storeId = SessionHelp.getStoreId(session);
        rechargeTypeRequest.setStoreId(storeId);
        List<RechargeType> list = new ArrayList<>();
        try {
            list = rechargeTypeSevice.selectsjianjiList(rechargeTypeRequest);
        }catch (Exception e){
            log.error("SsmRechargeTypeController.selectList:",e);
            genericResponse.setCodeAndMsg(ResponseCode.FAILED);
            return genericResponse;
        }

        genericResponse.setCodeAndMsg(ResponseCode.OK);
        genericResponse.setRows(list);
        return genericResponse;
    }



    @ApiOperation(value = "查询充值类别明细",httpMethod = "POST",response = GenericResponse.class)
    @RequestMapping("/one")
    public GenericResponse one(@RequestBody RechargeTypeRequest rechargeTypeRequest,HttpSession session){
        GenericResponse<RechargeType> genericResponse = new GenericResponse<>();
        RechargeType list = new RechargeType();
        try {
            list = rechargeTypeSevice.one(rechargeTypeRequest);
        }catch (Exception e){
            log.error("SsmRechargeTypeController.selectList:",e);
            genericResponse.setCodeAndMsg(ResponseCode.FAILED);
            return genericResponse;
        }

        genericResponse.setCodeAndMsg(ResponseCode.OK);
        genericResponse.setData(list);
        return genericResponse;
    }

    @ApiOperation(value = "复制其他门店的充值类别",httpMethod = "POST",response = GenericResponse.class)
    @RequestMapping("/adds")
    public GenericResponse adds(@RequestBody List<RechargeTypeRequest> rechargeTypeRequest, HttpSession session){
        GenericResponse<RechargeType> genericResponse = new GenericResponse<>();
//        if (StringUtils.isBlank(rechargeTypeRequest.getRechargeTypeNum())){
//            genericResponse.setCodeAndMsg(ResponseCode.PARAMETER_NOT_EXIST_S,"充值类别编码");
//            return genericResponse;
//        }
        String phone = "";
        for (RechargeTypeRequest typeRequest : rechargeTypeRequest) {
            if (StringUtils.isBlank(typeRequest.getRechargeTypeName())){
                genericResponse.setCodeAndMsg(ResponseCode.PARAMETER_NOT_EXIST_S,"充值类别名称");
                return genericResponse;
            }
            if (BigDecimalUtils.compareTo(typeRequest.getTypeRatio(), typeRequest.getRechargeMoney()) != -1){
                genericResponse.setCodeAndMsg(ResponseCode.NOT_MEET_REQUIREMENTS_S,"充值类别提成");
                return genericResponse;
            }
            Long storeId = SessionHelp.getStoreId(session);
            String storeName = SessionHelp.getStoreName(session);
            typeRequest.setStoreId(storeId);
            typeRequest.setStoreName(storeName);
            SessionHelp.getLoginAccount(session);
        }
        int i = 0;
        try {
            i = rechargeTypeSevice.addRecharges(rechargeTypeRequest, phone);
        }catch (SmsException e){
            genericResponse.setCodeAndMsg(e);
            return genericResponse;
        }catch (Exception e){
            log.error("SsmRechargeTypeController.add",e);
            genericResponse.setCodeAndMsg(ResponseCode.FAILED);
            return genericResponse;
        }
        if (i > 0){
            genericResponse.setCodeAndMsg(ResponseCode.OK);
        }
        return genericResponse;
    }

    /**
     * 升降级
     */
    @ApiOperation(value = "充值类别添加  门店端-充值类别-充值类别添加(升降级)",httpMethod = "POST",response = GenericResponse.class)
    @RequestMapping("/addss")
    public GenericResponse addss(@RequestBody RechargeTypeRequest rechargeTypeRequest, HttpSession session){
        GenericResponse<RechargeType> genericResponse = new GenericResponse<>();
//        if (StringUtils.isBlank(rechargeTypeRequest.getRechargeTypeNum())){
//            genericResponse.setCodeAndMsg(ResponseCode.PARAMETER_NOT_EXIST_S,"充值类别编码");
//            return genericResponse;
//        }
        if (StringUtils.isBlank(rechargeTypeRequest.getRechargeTypeName())){
            genericResponse.setCodeAndMsg(ResponseCode.PARAMETER_NOT_EXIST_S,"充值类别名称");
            return genericResponse;
        }
        if (BigDecimalUtils.compareTo(rechargeTypeRequest.getTypeRatio(), rechargeTypeRequest.getRechargeMoney()) != -1){
            genericResponse.setCodeAndMsg(ResponseCode.NOT_MEET_REQUIREMENTS_S,"充值类别提成");
            return genericResponse;
        }
        Long storeId = SessionHelp.getStoreId(session);
        String storeName = SessionHelp.getStoreName(session);
        rechargeTypeRequest.setStoreId(storeId);
        rechargeTypeRequest.setStoreName(storeName);
        String phone = SessionHelp.getLoginAccount(session);
        int i = 0;
        try {
            i = rechargeTypeSevice.addRecharges(rechargeTypeRequest, phone);
        }catch (SmsException e){
            genericResponse.setCodeAndMsg(e);
            return genericResponse;
        }catch (Exception e){
            log.error("SsmRechargeTypeController.add",e);
            genericResponse.setCodeAndMsg(ResponseCode.FAILED);
            return genericResponse;
        }
        if (i > 0){
            genericResponse.setCodeAndMsg(ResponseCode.OK);
        }
        return genericResponse;
    }

    @ApiOperation(value = "充值类别修改   门店端-充值类别-充值类别修改(升降级)",httpMethod = "POST",response = GenericResponse.class)
    @RequestMapping("/updates")
    public GenericResponse updates(@RequestBody RechargeTypeRequest rechargeTypeRequest,HttpSession session){
        GenericResponse<RechargeType> genericResponse = new GenericResponse<>();
        if (BigDecimalUtils.compareTo(rechargeTypeRequest.getTypeRatio(), rechargeTypeRequest.getRechargeMoney()) != -1){
            genericResponse.setCodeAndMsg(ResponseCode.NOT_MEET_REQUIREMENTS_S,"充值类别提成");
            return genericResponse;
        }
        rechargeTypeRequest.setStoreId(SessionHelp.getStoreId(session));
        String phone = SessionHelp.getLoginAccount(session);
        int i = 0;
        try {
            i = rechargeTypeSevice.updateRecharges(rechargeTypeRequest, phone);
        }catch (SmsException e){
            genericResponse.setCodeAndMsg(e);
            return genericResponse;
        }catch (Exception e){
            log.error("SsmRechargeTypeController.update",e);
            genericResponse.setCodeAndMsg(ResponseCode.FAILED);
            return genericResponse;
        }
        if (i > 0){
            genericResponse.setCodeAndMsg(ResponseCode.OK);
        }
        return genericResponse;
    }

    @ApiOperation(value = "充值类别删除  门店端-充值类别-充值类别删除(升降级)",httpMethod = "POST",response = GenericResponse.class)
    @RequestMapping("/deletes")
    public GenericResponse deletes(@RequestBody RechargeTypeRequest rechargeTypeRequest,HttpSession session){
        GenericResponse<RechargeType> genericResponse = new GenericResponse<>();
        rechargeTypeRequest.setStoreId(SessionHelp.getStoreId(session));
        int i = 0;
        try {
            i = rechargeTypeSevice.deleteRecharges(rechargeTypeRequest);
        }catch (Exception e){
            log.error("SsmRechargeTypeController.delete",e);
            genericResponse.setCodeAndMsg(ResponseCode.FAILED);
            return genericResponse;
        }
        if (i > 0){
            genericResponse.setCodeAndMsg(ResponseCode.OK);
        }
        return genericResponse;
    }

    @ApiOperation(value = "分页查询充值类别  门店端-充值类别-分页查询充值类别(升降级)",httpMethod = "POST",response = PageResponse.class)
    @RequestMapping("/pagess")
    public PageResponse selectPagess(@RequestBody RechargeTypeRequest rechargeTypeRequest, HttpSession session){
        PageResponse<RechargeType> pageResponse = new PageResponse<>();
        PageInfo<RechargeType> pageInfo = new PageInfo<>();
        //rechargeTypeRequest.setStoreId(SessionHelp.getStoreId(session));
        try {
            pageInfo = rechargeTypeSevice.selectPagess(rechargeTypeRequest);
        }catch (Exception e){
            log.error("SsmRechargeTypeController.selectPage",e);
            pageResponse.setCodeAndMsg(ResponseCode.FAILED);
            return pageResponse;
        }
        pageResponse.setCodeAndMsg(ResponseCode.OK);
        pageResponse.setPageInfo(pageInfo);
        return pageResponse;
    }

    @ApiOperation(value = "查询充值类别可升降级对应卡类",httpMethod = "POST",response = GenericResponse.class)
    @RequestMapping("/sjianjiLists")
    public GenericResponse selectsjianjiLists(@RequestBody RechargeTypeRequest rechargeTypeRequest,HttpSession session){
        GenericResponse<RechargeType> genericResponse = new GenericResponse<>();
        Long storeId = SessionHelp.getStoreId(session);
        rechargeTypeRequest.setStoreId(storeId);
        List<RechargeType> list = new ArrayList<>();
        try {
            list = rechargeTypeSevice.selectsjianjiLists(rechargeTypeRequest);
        }catch (Exception e){
            log.error("SsmRechargeTypeController.selectList:",e);
            genericResponse.setCodeAndMsg(ResponseCode.FAILED);
            return genericResponse;
        }

        genericResponse.setCodeAndMsg(ResponseCode.OK);
        genericResponse.setRows(list);
        return genericResponse;
    }
}
