package com.ssm.controller;

import com.github.pagehelper.PageInfo;
import com.ssm.core.bean.GenericResponse;
import com.ssm.core.bean.PageResponse;
import com.ssm.core.util.SessionHelp;
import com.ssm.core.utils.ChuangLanBeanSmsUtil;
import com.ssm.core.utils.FtpUtils;
import com.ssm.manage.entity.*;
import com.ssm.manage.query.*;
import com.ssm.manage.response.*;
import com.ssm.manage.service.*;
import com.ssm.manage.utils.Constant;
import com.ssm.util.RedisClient;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang.StringUtils;
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.multipart.MultipartFile;

import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;


@Api(value="门店会员controller",tags={"门店会员controller相关接口"})
@RestController
@RequestMapping("/demay/ssm/memberCs")
@Slf4j
public class SsmMemberController {
    @Autowired
    private SsmMemberCsService ssmMemberCsService;

    @Autowired
    private ChuangLanBeanSmsUtil chuangLanBeanSmsUtil;

    @Autowired
    private SsmMemberAgreementService ssmMemberAgreementService;

    @Autowired
    private SsmCashService ssmCashService;

    @Autowired
    private SsmProjectProgressService ssmProjectProgressService;

    @Autowired
    private SsmStoreMemberService ssmStoreMemberService;

    @Autowired
    private SsmMemberOrderService ssmMemberOrderService;

    @Autowired
    private SsmProjectService ssmProjectService;

    @Autowired
    private SsmRepayService ssmRepayService;

    @Autowired
    private SsmDebtService ssmDebtService;

    @Autowired
    private RedisClient<MemberResponse> redisClient;

    @Autowired
    private SsmBaseStoreService ssmBaseStoreService;

    @Autowired
    private SsmStoreMemberPhoneService ssmStoreMemberPhoneService;

    @Autowired
    private SsmStoreMemberFileService ssmStoreMemberFileService;

    @ApiOperation(value = "查询门店会员最近会员未评价记录list  会员微信小程序-查询门店会员最近会员未评价记录list",httpMethod = "POST",response = GenericResponse.class)
    @RequestMapping("/selectRecentRecord")
    public GenericResponse selectRecentRecord(@RequestBody MemberCsRequest memberCsRequest){
        GenericResponse<MemberCs> genericResponse = new GenericResponse<>();
        List<MemberCs> lists = new ArrayList<>();
        try {
            lists = ssmMemberCsService.selectRecentRecord(memberCsRequest);
        }catch (SmsException e){
            genericResponse.setCodeAndMsg(e);
            return genericResponse;
        }catch (Exception e){
            log.error("SsmMemberController.selectRecentRecord:",e);
            genericResponse.setCodeAndMsg(ResponseCode.FAILED);
            return genericResponse;
        }
        genericResponse.setCodeAndMsg(ResponseCode.OK);
        genericResponse.setRows(lists);
        return genericResponse;
    }

    @ApiOperation(value = "门店会员评价  会员微信小程序-门店会员评价",httpMethod = "POST",response = GenericResponse.class)
    @RequestMapping("/appraise")
    public GenericResponse appraise(@RequestBody MemberCsRequest memberCsRequest){
        GenericResponse<MemberCs> genericResponse = new GenericResponse<>();
        int i = 0;
        try {
            i = ssmMemberCsService.appraise(memberCsRequest);
        }catch (Exception e){
            log.error("SsmMemberController.appraise:",e);
            genericResponse.setCodeAndMsg(ResponseCode.FAILED);
            return genericResponse;
        }
        genericResponse.setCodeAndMsg(ResponseCode.OK);
        return genericResponse;
    }

    @ApiOperation(value = "查询门店员工会员评价记录list  会员微信小程序-查询门店员工会员评价记录list",httpMethod = "POST",response = GenericResponse.class)
    @RequestMapping("/selectMemberCsByStaff")
    public GenericResponse selectMemberCsByStaff(@RequestBody MemberCsRequest memberCsRequest){
        GenericResponse<MemberCs> genericResponse = new GenericResponse<>();
        List<MemberCs> lists = new ArrayList<>();
        try {
            lists = ssmMemberCsService.selectMemberCsByStaff(memberCsRequest);
        }catch (SmsException e){
            genericResponse.setCodeAndMsg(e);
            return genericResponse;
        }catch (Exception e){
            log.error("SsmMemberController.selectMemberCsByStaff:",e);
            genericResponse.setCodeAndMsg(ResponseCode.FAILED);
            return genericResponse;
        }
        genericResponse.setCodeAndMsg(ResponseCode.OK);
        genericResponse.setRows(lists);
        return genericResponse;
    }


    @ApiOperation(value = "门店通用文件上传  小程序 app-门店通用文件上传",httpMethod = "POST",response = GenericResponse.class)
    @RequestMapping("/addFile")
    public GenericResponse addProjectProgressFile(MultipartFile fileList, ProjectProgressRequest progressRequest){
        GenericResponse<ProjectProgressFile> genericResponse = new GenericResponse<>();
        if (null == fileList) {
            genericResponse.setCodeAndMsg(ResponseCode.PARAMETER_NOT_EXIST_S, "文件");
            return genericResponse;
        }

        //上传文件 保存文件信息list
//        List<ProjectProgressFile> uploadFilesInfo = new ArrayList<>();
        FtpUtils ftp = new FtpUtils();

        ProjectProgressFile projectProgressFile = new ProjectProgressFile();
        String fileName = fileList.getOriginalFilename();//获取文件名
        String suffix = fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length());//获取文件后缀
        String saveName = UUID.randomUUID() + "." + suffix;//将文件名用时间重命名
        String path = Constant.filePath + "/" + progressRequest.getStoreId();//文件上传路径
        projectProgressFile.setFileName(saveName);
        projectProgressFile.setFilePath(path);

//            projectProgressFile.setType(progressRequest.getType());
//        uploadFilesInfo.add(projectProgressFile);

        InputStream inputStream = null;
        try {
            inputStream = fileList.getInputStream();
            ftp.uploadFile(path, saveName, inputStream);
        } catch (IOException e) {
            log.error("SsmMemberController.addFile:", e);
            genericResponse.setCodeAndMsg(ResponseCode.FILE_UPLOAD_FAILED);
            return genericResponse;
        }

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

    @ApiOperation(value = "门店通用文件删除  小程序 app-门店通用文件删除",httpMethod = "POST",response = GenericResponse.class)
    @RequestMapping("/deleteFile")
    public GenericResponse deleteFile( ProjectProgressFile projectProgressFile){
        GenericResponse<ProjectProgressFile> genericResponse = new GenericResponse<>();
        if (StringUtils.isNotBlank(projectProgressFile.getFilePath())) {
            genericResponse.setCodeAndMsg(ResponseCode.PARAMETER_NOT_EXIST_S, "文件路径");
            return genericResponse;
        }
        if (StringUtils.isNotBlank(projectProgressFile.getFileName())) {
            genericResponse.setCodeAndMsg(ResponseCode.PARAMETER_NOT_EXIST_S, "文件名称");
            return genericResponse;
        }
        FtpUtils ftp = new FtpUtils();
        try {

            ftp.deleteFile(projectProgressFile.getFilePath(), projectProgressFile.getFileName());
        } catch (IOException e) {
            log.error("SsmMemberController.deleteFile:", e);
            genericResponse.setCodeAndMsg(ResponseCode.FILE_UPLOAD_FAILED);
            return genericResponse;
        }

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



    @ApiOperation(value = "门店会员跟踪反馈添加  会员微信小程序-门店会员跟踪反馈添加",httpMethod = "POST",response = GenericResponse.class)
    @RequestMapping("/addProjectProgress")
    public GenericResponse addProjectProgress(@RequestBody ProjectProgressRequest progressRequest){
        GenericResponse<ProjectProgress> genericResponse = new GenericResponse<>();
        if (null == progressRequest.getUploadFiles() || progressRequest.getUploadFiles().isEmpty()) {
            genericResponse.setCodeAndMsg(ResponseCode.PARAMETER_NOT_EXIST_S, "文件");
            return genericResponse;
        }
        int i = 0;
        try {
            i = ssmProjectProgressService.add(progressRequest);
        }catch (Exception e){
            log.error("SsmMemberController.addProjectProgress:",e);
            genericResponse.setCodeAndMsg(ResponseCode.FAILED);
            return genericResponse;
        }
        genericResponse.setCodeAndMsg(ResponseCode.OK);
        return genericResponse;
    }


//    @ApiOperation(value = "门店会员跟踪反馈添加 (护理前)  会员微信小程序-门店会员跟踪反馈添加(护理前)",httpMethod = "POST",response = GenericResponse.class)
//    @RequestMapping("/addProjectProgress")
//    public GenericResponse addProjectProgress(List<MultipartFile> fileList, ProjectProgressRequest progressRequest){
//        GenericResponse<MemberCs> genericResponse = new GenericResponse<>();
//        if (null == fileList || fileList.size() == 0) {
//            genericResponse.setCodeAndMsg(ResponseCode.PARAMETER_NOT_EXIST_S, "文件");
//            return genericResponse;
//        }
////        if (null == after || after.size() == 0) {
////            genericResponse.setCodeAndMsg(ResponseCode.PARAMETER_NOT_EXIST_S, "护理后文件");
////            return genericResponse;
////        }
//        //上传文件 保存文件信息list
//        List<ProjectProgressFile> uploadFilesInfo = new ArrayList<>();
//        FtpUtils ftp = new FtpUtils();
//        for (MultipartFile multipartFile : fileList) {
//            ProjectProgressFile projectProgressFile = new ProjectProgressFile();
//            String fileName = multipartFile.getOriginalFilename();//获取文件名
//            String suffix = fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length());//获取文件后缀
//            String saveName = UUID.randomUUID() + "." + suffix;//将文件名用时间重命名
//            String path = Constant.filePath + "/" + progressRequest.getStoreId();//文件上传路径
//            projectProgressFile.setFileName(saveName);
//            projectProgressFile.setFilePath(path);
////            if (progressRequest.getType() == 0) {
////                projectProgressFile.setType(0);
////            }else {
////                progressRequest.setType(1);
////            }
//            projectProgressFile.setType(progressRequest.getType());
//            uploadFilesInfo.add(projectProgressFile);
//
//            InputStream inputStream = null;
//            try {
//                inputStream = multipartFile.getInputStream();
//                ftp.uploadFile(path, saveName, inputStream);
//            } catch (IOException e) {
//                log.error("SsmMemberController.addProjectProgress:", e);
//                genericResponse.setCodeAndMsg(ResponseCode.FILE_UPLOAD_FAILED);
//                return genericResponse;
//            }
//        }
////        for (MultipartFile multipartFile : after) {
////            ProjectProgressFile projectProgressFile = new ProjectProgressFile();
////            String fileName = multipartFile.getOriginalFilename();//获取文件名
////            String suffix = fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length());//获取文件后缀
////            String saveName = UUID.randomUUID() + "." + suffix;//将文件名用时间重命名
////            String path = Constant.filePath + "/" + progressRequest.getStoreId();//文件上传路径
////            projectProgressFile.setFileName(saveName);
////            projectProgressFile.setFilePath(path);
////            projectProgressFile.setType(1);
////            uploadFilesInfo.add(projectProgressFile);
////            InputStream inputStream = null;
////            try {
////                inputStream = multipartFile.getInputStream();
////                ftp.uploadFile(path, saveName, inputStream);
////            } catch (IOException e) {
////                log.error("SsmMemberCsController.addProjectProgress:", e);
////                genericResponse.setCodeAndMsg(ResponseCode.FILE_UPLOAD_FAILED);
////                return genericResponse;
////            }
////        }
//        progressRequest.setUploadFiles(uploadFilesInfo);
//        int i = 0;
//        try {
//            i = ssmProjectProgressService.add(progressRequest);
//        }catch (Exception e){
//            log.error("SsmMemberController.addProjectProgress:",e);
//            genericResponse.setCodeAndMsg(ResponseCode.FAILED);
//            return genericResponse;
//        }
//        genericResponse.setCodeAndMsg(ResponseCode.OK);
//        return genericResponse;
//    }

    @ApiOperation(value = "门店会员跟踪反馈更新 (护理后)  会员微信小程序-门店会员跟踪反馈更新(护理后)",httpMethod = "POST",response = GenericResponse.class)
    @RequestMapping("/updateProjectProgress")
    public GenericResponse updateProjectProgress(List<MultipartFile> fileList, ProjectProgressRequest progressRequest){
        GenericResponse<MemberCs> genericResponse = new GenericResponse<>();
        if (null == fileList || fileList.size() == 0) {
            genericResponse.setCodeAndMsg(ResponseCode.PARAMETER_NOT_EXIST_S, "文件");
            return genericResponse;
        }
        //上传文件 保存文件信息list
        List<ProjectProgressFile> uploadFilesInfo = new ArrayList<>();
        FtpUtils ftp = new FtpUtils();
        for (MultipartFile multipartFile : fileList) {
            ProjectProgressFile projectProgressFile = new ProjectProgressFile();
            String fileName = multipartFile.getOriginalFilename();//获取文件名
            String suffix = fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length());//获取文件后缀
            String saveName = UUID.randomUUID() + "." + suffix;//将文件名用时间重命名
            String path = Constant.filePath + "/" + progressRequest.getStoreId();//文件上传路径
            projectProgressFile.setFileName(saveName);
            projectProgressFile.setFilePath(path);

            projectProgressFile.setType(progressRequest.getType());
            uploadFilesInfo.add(projectProgressFile);

            InputStream inputStream = null;
            try {
                inputStream = multipartFile.getInputStream();
                ftp.uploadFile(path, saveName, inputStream);
            } catch (IOException e) {
                log.error("SsmMemberController.updateProjectProgress:", e);
                genericResponse.setCodeAndMsg(ResponseCode.FILE_UPLOAD_FAILED);
                return genericResponse;
            }
        }

        progressRequest.setUploadFiles(uploadFilesInfo);
        int i = 0;
        try {
            i = ssmProjectProgressService.updateProjectProgress(progressRequest);
        }catch (Exception e){
            log.error("SsmMemberController.addProjectProgress:",e);
            genericResponse.setCodeAndMsg(ResponseCode.FAILED);
            return genericResponse;
        }
        genericResponse.setCodeAndMsg(ResponseCode.OK);
        return genericResponse;
    }


//    @ApiOperation(value = "会员查询消费记录 (会员小程序-会员查询消费记录)",httpMethod = "POST",response = GenericResponse.class)
//    @RequestMapping("/selectByMember")
//    public PageResponse selectByMember(@RequestBody CashListRequest cashListRequest){
//        PageResponse<CashListResponse> pageResponse = new PageResponse<>();
//        PageInfo<CashListResponse> pageInfo = new PageInfo<>();
//
//        try {
//            pageInfo = ssmCashService.selectByMember(cashListRequest);
//        }catch (SmsException e){
//            pageResponse.setCodeAndMsg(e);
//            return pageResponse;
//        }catch (Exception e){
//            log.error("SsmMemberController.selectByMember:",e);
//            pageResponse.setCodeAndMsg(ResponseCode.FAILED);
//            return pageResponse;
//        }
//
//        pageResponse.setCodeAndMsg(ResponseCode.OK);
//        pageResponse.setPageInfo(pageInfo);
//        return pageResponse;
//    }

    @ApiOperation(value = "会员查询消费记录进行疗程跟踪反馈 (会员小程序-会员查询消费记录进行疗程跟踪反馈)",httpMethod = "POST",response = GenericResponse.class)
    @RequestMapping("/selectProgress")
    public PageResponse selectProgress(@RequestBody CashListRequest cashListRequest){
        PageResponse<CashListResponse> pageResponse = new PageResponse<>();
        PageInfo<CashListResponse> pageInfo = new PageInfo<>();

        try {
            pageInfo = ssmCashService.selectProgress(cashListRequest);
        }catch (SmsException e){
            pageResponse.setCodeAndMsg(e);
            return pageResponse;
        }catch (Exception e){
            log.error("SsmMemberController.selectProgress:",e);
            pageResponse.setCodeAndMsg(ResponseCode.FAILED);
            return pageResponse;
        }

        pageResponse.setCodeAndMsg(ResponseCode.OK);
        pageResponse.setPageInfo(pageInfo);
        return pageResponse;
    }

    @ApiOperation(value = "门店会员修改信息  会员端-门店会员修改信息",httpMethod = "POST",response = GenericResponse.class)
    @RequestMapping("/update")
    public GenericResponse updateMember(@RequestBody MemberRequest memberRequest, HttpSession session){
        GenericResponse<StoreMemberList> genericResponse = new GenericResponse<>();
        String phone = SessionHelp.getLoginAccount(session);
        int i = 0;
        try {
            i = ssmStoreMemberService.updateStoreMember(memberRequest,phone);
        }catch (SmsException e){
            genericResponse.setCodeAndMsg(e);
            return genericResponse;
        }catch (Exception e){
            log.error("SsmMemberController.updateMember:",e);
            genericResponse.setCodeAndMsg(ResponseCode.FAILED);
            return genericResponse;
        }
        if (i > 0) {
            genericResponse.setCodeAndMsg(ResponseCode.OK);
        }
        return genericResponse;
    }

    @ApiOperation(value = "查询单个门店会员  会员端-查询单个门店会员",httpMethod = "POST",response = GenericResponse.class)
    @RequestMapping("/one")
    public GenericResponse selectOne(@RequestBody MemberRequest memberRequest){
        GenericResponse<MemberResponse> genericResponse = new GenericResponse<>();

        MemberResponse memberResponse = new MemberResponse();
        try {
            memberResponse = ssmStoreMemberService.selectOne(memberRequest);
        }catch (SmsException e){
            genericResponse.setCodeAndMsg(e);
            return genericResponse;
        }catch (Exception e){
            log.error("SsmMemberController.selectOne:",e);
            genericResponse.setCodeAndMsg(ResponseCode.FAILED);
            return genericResponse;
        }
        genericResponse.setCodeAndMsg(ResponseCode.OK);
        genericResponse.setData(memberResponse);
        return genericResponse;
    }

    @ApiOperation(value = "通过手机号和密码查询会员所属门店  会员端-通过手机号和密码查询会员所属门店",httpMethod = "POST",response = GenericResponse.class)
    @RequestMapping("/list")
    public GenericResponse list(@RequestBody MemberRequest memberRequest){
        GenericResponse<StoreMemberList> genericResponse = new GenericResponse<>();
        List<StoreMemberList> lists = new ArrayList<>();
        try {
            lists = ssmStoreMemberService.selectList(memberRequest);
        }catch (Exception e){
            log.error("SsmMemberController.list:",e);
            genericResponse.setCodeAndMsg(ResponseCode.FAILED);
            return genericResponse;
        }
        genericResponse.setCodeAndMsg(ResponseCode.OK);
        genericResponse.setRows(lists);
        return genericResponse;
    }

    @ApiOperation(value = "门店会员修改手机号  会员端-门店会员修改手机号",httpMethod = "POST",response = GenericResponse.class)
    @RequestMapping("/updatePhone")
    public GenericResponse updatePhone(@RequestBody MemberRequest memberRequest){
        GenericResponse<StoreMemberList> genericResponse = new GenericResponse<>();

        int i = 0;
        try {
            i = ssmStoreMemberService.updatePhone(memberRequest,memberRequest.getOldPhone());
        }catch (SmsException e){
            genericResponse.setCodeAndMsg(e);
            return genericResponse;
        }catch (Exception e){
            log.error("SsmMemberController.updatePhone:",e);
            genericResponse.setCodeAndMsg(ResponseCode.FAILED);
            return genericResponse;
        }
        if (i > 0) {
            genericResponse.setCodeAndMsg(ResponseCode.OK);
        }
        return genericResponse;
    }

    @ApiOperation(value = "门店会员预约  会员微信小程序-门店会员预约",httpMethod = "POST",response = GenericResponse.class)
    @RequestMapping("/addOrder")
    public GenericResponse addOrder(@RequestBody MemberOrderRequest memberOrderRequest){
        GenericResponse<MemberCs> genericResponse = new GenericResponse<>();
        int i = 0;
        try {
            i = ssmMemberOrderService.addOrder(memberOrderRequest);
        }catch (Exception e){
            log.error("SsmMemberController.addOrder:",e);
            genericResponse.setCodeAndMsg(ResponseCode.FAILED);
            return genericResponse;
        }
        if (i > 0) {
            genericResponse.setCodeAndMsg(ResponseCode.OK);
        }
        return genericResponse;
    }

    @ApiOperation(value = "门店会员预约信息修改  会员微信小程序-门店会员预约信息修改",httpMethod = "POST",response = GenericResponse.class)
    @RequestMapping("/updateOrder")
    public GenericResponse updateOrder(@RequestBody MemberOrderRequest memberOrderRequest){
        GenericResponse<MemberCs> genericResponse = new GenericResponse<>();
        int i = 0;
        try {
            i = ssmMemberOrderService.updateOrder(memberOrderRequest);
        }catch (Exception e){
            log.error("SsmMemberController.updateOrder:",e);
            genericResponse.setCodeAndMsg(ResponseCode.FAILED);
            return genericResponse;
        }
        if (i > 0) {
            genericResponse.setCodeAndMsg(ResponseCode.OK);
        }
        return genericResponse;
    }

    @ApiOperation(value = "门店会员取消预约信息  会员微信小程序-门店会员取消预约信息",httpMethod = "POST",response = GenericResponse.class)
    @RequestMapping("/deleteOrder")
    public GenericResponse deleteOrder(@RequestBody MemberOrderRequest memberOrderRequest){
        GenericResponse<MemberCs> genericResponse = new GenericResponse<>();
        int i = 0;
        try {
            i = ssmMemberOrderService.deleteOrder(memberOrderRequest);
        }catch (Exception e){
            log.error("SsmMemberController.updateOrder:",e);
            genericResponse.setCodeAndMsg(ResponseCode.FAILED);
            return genericResponse;
        }
        if (i > 0) {
            genericResponse.setCodeAndMsg(ResponseCode.OK);
        }
        return genericResponse;
    }

    @ApiOperation(value = "分页查询会员预约列表  (会员端-分页查询会员预约列表)",httpMethod = "POST",response = GenericResponse.class)
    @RequestMapping("/orderPage")
    public PageResponse orderPage(@RequestBody MemberOrderRequest memberOrderRequest){
        PageResponse<MemberOrder> pageResponse = new PageResponse<>();
        PageInfo<MemberOrder> pageInfo = new PageInfo<>();
//        Long storeId = SessionHelp.getStoreId(session);
//        String storeName = SessionHelp.getStoreName(session);
//        memberOrderRequest.setStoreId(storeId);
//        memberOrderRequest.setStoreName(storeName);
        try {
            pageInfo = ssmMemberOrderService.selectPage(memberOrderRequest);
        }catch (Exception e){
            log.error("SsmCallNumberController.orderPage:",e);
            pageResponse.setCodeAndMsg(ResponseCode.FAILED);
            return pageResponse;
        }
        pageResponse.setCodeAndMsg(ResponseCode.OK);
        pageResponse.setPageInfo(pageInfo);
        return pageResponse;
    }

    @ApiOperation(value = "分页查询项目 会员端-分页查询项目", httpMethod = "POST", response = PageResponse.class)
    @RequestMapping("/projectPage")
    public PageResponse projectPage(@RequestBody ProjectRequest projectRequest) {
        PageResponse<BaseProject> pageResponse = new PageResponse<>();
        PageInfo<BaseProject> pageInfo = new PageInfo<>();
//        projectRequest.setStoreId(SessionHelp.getStoreId(session));
        try {
            pageInfo = ssmProjectService.selectPage(projectRequest);
        } catch (Exception e) {
            log.error("SsmMemberController.projectPage", e);
            pageResponse.setCodeAndMsg(ResponseCode.FAILED);
            return pageResponse;
        }
        pageResponse.setPageInfo(pageInfo);
        pageResponse.setCodeAndMsg(ResponseCode.OK);
        return pageResponse;
    }

    @ApiOperation(value = "分页查询  会员端-还款-分页查询还款单",httpMethod = "POST",response = PageResponse.class)
    @RequestMapping("/repayPage")
    public PageResponse repayPage(@RequestBody RepayListRequest repayListRequest){
        PageResponse<RepayListResponse> pageResponse = new PageResponse<>();
        PageInfo<RepayListResponse> pageInfo = new PageInfo<>();
        try {
            pageInfo = ssmRepayService.selectPage(repayListRequest);
        }catch (Exception e){
            log.error("SsmMemberController.repayPage",e);
            pageResponse.setCodeAndMsg(ResponseCode.FAILED);
            return pageResponse;
        }
        pageResponse.setCodeAndMsg(ResponseCode.OK);
        pageResponse.setPageInfo(pageInfo);
        return pageResponse;
    }

//    @ApiOperation(value = "查询充值卡包对应消费记录  会员微信小程序-查询充值卡包对应消费记录",httpMethod = "POST",response = PageResponse.class)
//    @RequestMapping("/selectByRecharge")
//    public PageResponse selectByRecharge(@RequestBody AccountTradeRecordRequest accountTradeRecordRequest){
//        PageResponse<CashListResponse> pageResponse = new PageResponse<>();
//        PageInfo<CashListResponse> pageInfo = new PageInfo<>();
//        try {
//            pageInfo = ssmCashService.selectByRecharge(accountTradeRecordRequest);
//        }catch (Exception e){
//            log.error("SsmMemberController.selectByRecharge:",e);
//            pageResponse.setCodeAndMsg(ResponseCode.FAILED);
//            return pageResponse;
//        }
//        pageResponse.setCodeAndMsg(ResponseCode.OK);
//        pageResponse.setPageInfo(pageInfo);
//        return pageResponse;
//    }

    @ApiOperation(value = "欠款单分页查询  小程序-欠款单分页查询",httpMethod = "POST",response = PageResponse.class)
    @RequestMapping("/debtPage")
    public PageResponse selectPage(@RequestBody DebtListRequest debtListRequest){
        PageResponse<DebtListResponse> pageResponse = new PageResponse<>();
        PageInfo<DebtListResponse> pageInfo = new PageInfo<>();
//        debtListRequest.setStoreId(SessionHelp.getStoreId(session));
        try {
            pageInfo = ssmDebtService.selectPage(debtListRequest);
        }catch (Exception e){
            log.error("SsmMemberController.debtPage",e);
            pageResponse.setCodeAndMsg(ResponseCode.FAILED);
            return pageResponse;
        }
        pageResponse.setCodeAndMsg(ResponseCode.OK);
        pageResponse.setPageInfo(pageInfo);
        return pageResponse;
    }

    @ApiOperation(value = "分页查询门店会员信息   门店端-会员清单-分页查询门店会员信息",httpMethod = "POST",response = PageResponse.class)
    @RequestMapping("/memberPage")
    public PageResponse selectPage(@RequestBody MemberRequest memberRequest){
        PageResponse<StoreMemberList> pageResponse = new PageResponse<>();
        PageInfo<StoreMemberList> pageInfo = new PageInfo<>();
//        memberRequest.setStoreId(SessionHelp.getStoreId(session));
        try {
            pageInfo = ssmStoreMemberService.selectPage(memberRequest);
        }catch (Exception e){
            log.error("SsmMemberController.memberPage:",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")
    public GenericResponse addMember(@RequestBody MemberRequest memberRequest){
        GenericResponse<StoreMemberList> genericResponse = new GenericResponse<>();
//        memberRequest.setStoreId(SessionHelp.getStoreId(session));
//        memberRequest.setStoreName(SessionHelp.getStoreName(session));
        String phone = memberRequest.getStaffPhone();
        String password = ObjectUtils.toString((int)((Math.random()*9+1)*1000));
        memberRequest.setPassword(password);
        int i = 0;
        try {
            i = ssmStoreMemberService.addStoreMember(memberRequest, phone);
        }catch (SmsException e){
            genericResponse.setCodeAndMsg(e);
            return genericResponse;
        }catch (Exception e){
            log.error("SsmMemberController.addMember:",e);
            genericResponse.setCodeAndMsg(ResponseCode.FAILED);
            return genericResponse;
        }
        if (i > 0) {
            genericResponse.setCodeAndMsg(ResponseCode.OK);
            BaseStore baseStore = ssmBaseStoreService.selectByPrimaryKey(memberRequest.getStoreId());
            //设置短信账户 发送 否则不发送
            if (StringUtils.isNotBlank(baseStore.getSmsAccount())) {
                try {
                    chuangLanBeanSmsUtil.sendMemberInitPwdSms(baseStore, memberRequest.getMemberName(), memberRequest.getMobilePhone(), Integer.parseInt(password));
                } catch (IOException e) {
                    log.error("SsmMemberController.addMember:", e);
                } catch (SmsException e) {
                    log.error("SsmMemberController.addMember:", e);
                }
            }
        }
        return genericResponse;
    }

    @ApiOperation(value = "门店会员停用启用  门店端-会员清单-门店会员停用启用",httpMethod = "POST",response = GenericResponse.class)
    @RequestMapping("/updateState")
    public GenericResponse updateState(@RequestBody MemberRequest memberRequest){
        GenericResponse<StoreMemberList> genericResponse = new GenericResponse<>();
//        memberRequest.setStoreId(SessionHelp.getStoreId(session));
//        memberRequest.setStoreName(SessionHelp.getStoreName(session));
        String phone = memberRequest.getStaffPhone();
        if (memberRequest.getState() != 0) {
            if (StringUtils.isBlank(memberRequest.getPassword()) && StringUtils.isBlank(memberRequest.getPassCode())) {
                genericResponse.setCodeAndMsg(ResponseCode.PARAMETER_NOT_EXIST_S, "密码和验证码");
                return genericResponse;
            }
        }
        int i = 0;
        try {
            i = ssmStoreMemberService.updateState(memberRequest,phone);
        }catch (SmsException e){
            genericResponse.setCodeAndMsg(e);
            return genericResponse;
        }catch (Exception e){
            log.error("SsmMemberController.updateState:",e);
            genericResponse.setCodeAndMsg(ResponseCode.FAILED);
            return genericResponse;
        }
        if (i > 0) {
            genericResponse.setCodeAndMsg(ResponseCode.OK);
        }
        return genericResponse;
    }

    @ApiOperation(value = "门店会员分派  门店端-会员分派-分派",httpMethod = "POST",response = GenericResponse.class)
    @RequestMapping("/assign")
    public GenericResponse assign(@RequestBody MemberRequest memberRequest){
        GenericResponse<StoreMemberList> genericResponse = new GenericResponse<>();
        int i = 0;
        try {
            i = ssmStoreMemberService.assignStoreMember(memberRequest);
        }catch (Exception e){
            log.error("SsmMemberController.assign:",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("/listByStaff")
    public GenericResponse listByStaff(@RequestBody MemberRequest memberRequest){
        GenericResponse<StoreMemberList> genericResponse = new GenericResponse<>();
//        memberRequest.setStoreId(SessionHelp.getStoreId(session));
        List<StoreMemberList> lists = new ArrayList<>();
        try {
            lists = ssmStoreMemberService.listByStaff(memberRequest);
        }catch (Exception e){
            log.error("SsmMemberController.listByStaff:",e);
            genericResponse.setCodeAndMsg(ResponseCode.FAILED);
            return genericResponse;
        }
        genericResponse.setCodeAndMsg(ResponseCode.OK);
        genericResponse.setRows(lists);
        return genericResponse;
    }


    @ApiOperation(value = "校验门店会员收银密码  门店端-门店所有付款页面-校验门店会员收银密码",httpMethod = "POST",response = GenericResponse.class)
    @RequestMapping("/checkCashWord")
    public GenericResponse checkCashWord(@RequestBody MemberRequest memberRequest){
        GenericResponse genericResponse = new GenericResponse<>();
//        memberRequest.setStoreId(SessionHelp.getStoreId(session));
        boolean flag = true;
        try {
            flag = ssmStoreMemberService.checkCashWord(memberRequest);
        }catch (SmsException e){
            genericResponse.setCodeAndMsg(e);
            return genericResponse;
        }catch (Exception e){
            log.error("SsmMemberController.checkCashWord:",e);
            genericResponse.setCodeAndMsg(ResponseCode.FAILED);
            return genericResponse;
        }
        genericResponse.setCodeAndMsg(ResponseCode.OK);
        genericResponse.setData(flag);
        return genericResponse;
    }



    @ApiOperation(value = "会员换号启用  (门店端-会员-会员换号启用)", httpMethod = "POST", response = GenericResponse.class)
    @RequestMapping("/changePhoneToUpdateState")
    public GenericResponse changePhoneToUpdateState(@RequestBody MemberRequest memberRequest) {
        GenericResponse genericResponse = new GenericResponse();

        if (null == memberRequest.getUploadFiles() || memberRequest.getUploadFiles().isEmpty()) {
            genericResponse.setCodeAndMsg(ResponseCode.PARAMETER_NOT_EXIST_S, "文件");
            return genericResponse;
        }

        String staffPhone = memberRequest.getStaffPhone();

        int i = 0;
        try {
            i = ssmStoreMemberService.changePhoneToUpdateState(memberRequest, staffPhone);
        } catch (SmsException e) {
            genericResponse.setCodeAndMsg(e);
            return genericResponse;
        } catch (Exception e) {
            log.error("SsmMemberController.changePhoneToUpdateState:", e);
            genericResponse.setCodeAndMsg(ResponseCode.FAILED);
            return genericResponse;
        }
        if (i > 0) {
            genericResponse.setCodeAndMsg(ResponseCode.OK);
        }
        return genericResponse;
    }


    @ApiOperation(value = "门店会员启用  门店端-会员激活-门店会员启用",httpMethod = "POST",response = GenericResponse.class)
    @RequestMapping("/start")
    public GenericResponse start(@RequestBody MemberRequest memberRequest){
        GenericResponse<StoreMemberList> genericResponse = new GenericResponse<>();
//        memberRequest.setStoreId(SessionHelp.getStoreId(session));
//        memberRequest.setStoreName(SessionHelp.getStoreName(session));
        String phone = memberRequest.getStaffPhone();

        int i = 0;
        try {
            i = ssmStoreMemberService.start(memberRequest,phone);
        }catch (SmsException e){
            genericResponse.setCodeAndMsg(e);
            return genericResponse;
        }catch (Exception e){
            log.error("SsmMemberController.start:",e);
            genericResponse.setCodeAndMsg(ResponseCode.FAILED);
            return genericResponse;
        }
        if (i > 0) {
            genericResponse.setCodeAndMsg(ResponseCode.OK);
        }
        return genericResponse;
    }


    @ApiOperation(value = "门店会员启用时一个启用 同手机号的另一个停用  门店端-会员激活-门店会员启用时一个启用 同手机号的另一个停用",httpMethod = "POST",response = GenericResponse.class)
    @RequestMapping("/bothOperation")
    public GenericResponse bothOperation(@RequestBody List<MemberRequest> list){
        GenericResponse<StoreMemberList> genericResponse = new GenericResponse<>();

        String phone = list.get(0).getStaffPhone();

        int i = 0;
        try {
            i = ssmStoreMemberService.bothOperation(list,phone);
        }catch (SmsException e){
            genericResponse.setCodeAndMsg(e);
            return genericResponse;
        }catch (Exception e){
            log.error("SsmMemberController.bothOperation:",e);
            genericResponse.setCodeAndMsg(ResponseCode.FAILED);
            return genericResponse;
        }
        if (i > 0) {
            genericResponse.setCodeAndMsg(ResponseCode.OK);
        }
        return genericResponse;
    }


    @ApiOperation(value = "分页查询门店会员修改手机号 换号激活记录   门店端-会员激活-分页查询门店会员修改手机号 换号激活记录",httpMethod = "POST",response = PageResponse.class)
    @RequestMapping("/phonePage")
    public PageResponse phonePage(@RequestBody StoreMemberPhoneRequest memberPhoneRequest){
        PageResponse<StoreMemberPhone> pageResponse = new PageResponse<>();
        PageInfo<StoreMemberPhone> pageInfo = new PageInfo<>();
//        memberPhoneRequest.setStoreId(SessionHelp.getStoreId(session));
        try {
            pageInfo = ssmStoreMemberPhoneService.selectPage(memberPhoneRequest);
        }catch (Exception e){
            log.error("SsmMemberController.phonePage:",e);
            pageResponse.setCodeAndMsg(ResponseCode.FAILED);
            return pageResponse;
        }
        pageResponse.setCodeAndMsg(ResponseCode.OK);
        pageResponse.setPageInfo(pageInfo);
        return pageResponse;
    }

    @ApiOperation(value = "门店会员激活记录 文件查询  门店端-会员激活-门店会员激活记录 文件查询",httpMethod = "POST",response = GenericResponse.class)
    @RequestMapping("/selectFile")
    public GenericResponse selectFile(@RequestBody StoreMemberFile storeMemberFile){
        GenericResponse<StoreMemberFile> genericResponse = new GenericResponse<>();
        List<StoreMemberFile> lists = new ArrayList<>();
        if (null == storeMemberFile.getDocId()){
            genericResponse.setCodeAndMsg(ResponseCode.PARAMETER_NOT_EXIST_S,"记录ID");
            return genericResponse;
        }
        try {
            lists = ssmStoreMemberFileService.select(storeMemberFile);
        }catch (Exception e){
            log.error("SsmMemberController.selectFile:",e);
            genericResponse.setCodeAndMsg(ResponseCode.FAILED);
            return genericResponse;
        }
        genericResponse.setCodeAndMsg(ResponseCode.OK);
        genericResponse.setRows(lists);
        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 = "member";
//            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/member.xlsx");
//
//            List<ExcelStoreMemberList> 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("SsmMemberController.download:",e);
//        } finally {
//            //destFile.delete();
//            // 别忘记关闭流
//            excelWriter.finish();
//        }
//    }
//
//    @ApiOperation(value = "门店会员批量导出  门店端-会员-门店会员批量导出", httpMethod = "POST", response = GenericResponse.class)
//    @RequestMapping("/export")
//    public void export(@RequestBody MemberRequest memberRequest) {
//        // 模板注意 用{} 来表示你要用的变量 如果本来就有"{","}" 特殊字符 用"\{","\}"代替
//        // {} 代表普通变量 {.} 代表是list的变量 {前缀.} 前缀可以区分不同的list
//        ExcelWriter excelWriter = null;
//        OutputStream out = null;
////        memberRequest.setStoreId(SessionHelp.getStoreId(session));
////        memberRequest.setStoreName(SessionHelp.getStoreName(session));
//        StoreMemberList storeMemberList = new StoreMemberList();
//        try {
//            String fileName = "member";
//            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/member.xlsx");
////            BeanUtils.copyProperties(memberRequest, storeMemberList);
////            List<StoreMemberList> list = ssmStoreMemberService.select(storeMemberList);
//            Example example = new Example(StoreMemberList.class);
//            Example.Criteria criteria = example.createCriteria();
//            example.setOrderByClause("member_num desc");
//            if (memberRequest.getState() != null){
//                criteria.andEqualTo("state",memberRequest.getState());
//            }
//            if (memberRequest.getAssignState() != null){
//                criteria.andEqualTo("assignState",memberRequest.getAssignState());
//            }
//            if (memberRequest.getMemberName() != null){
//                criteria.andLike("memberName","%" + memberRequest.getMemberName() + "%");
//            }
//            if (memberRequest.getMobilePhone() != null){
//                criteria.andEqualTo("mobilePhone", memberRequest.getMobilePhone());
//            }
//            criteria.andEqualTo("storeId",memberRequest.getStoreId());
//            List<StoreMemberList> list = ssmStoreMemberService.selectByExample(example);
//            List<ExcelStoreMemberList> excelStoreMemberLists = new ArrayList<>();
//            for (StoreMemberList memberList : list) {
//                ExcelStoreMemberList excelStoreMemberList = new ExcelStoreMemberList();
//                BeanUtils.copyProperties(memberList, excelStoreMemberList);
//                if (memberList.getSex() == 1){
//                    excelStoreMemberList.setSex("男");
//                }else if (memberList.getSex() == 0){
//                    excelStoreMemberList.setSex("女");
//                }
//                if (memberList.getState() == 1){
//                    excelStoreMemberList.setState("启用");
//                }else if (memberList.getState() == 0){
//                    excelStoreMemberList.setState("停用");
//                }else if (memberList.getState() == 2){
//                    excelStoreMemberList.setState("启用中");
//                }
//                if (null != memberList.getHairLong() && memberList.getHairLong() == 1){
//                    excelStoreMemberList.setHairLong("长");
//                }else if (null != memberList.getHairLong() && memberList.getHairLong() == 2){
//                    excelStoreMemberList.setHairLong("中");
//                }else if (null != memberList.getHairLong() && memberList.getHairLong() == 3){
//                    excelStoreMemberList.setHairLong("短");
//                }
//                if (null != memberList.getSkinType() && memberList.getSkinType() == 1){
//                    excelStoreMemberList.setSkinType("油性");
//                }else if (null != memberList.getSkinType() && memberList.getSkinType() == 2){
//                    excelStoreMemberList.setSkinType("中性");
//                }else if (null != memberList.getSkinType() && memberList.getSkinType() == 3){
//                    excelStoreMemberList.setSkinType("干性");
//                }
//                excelStoreMemberList.setMobilePhone(null);
//                excelStoreMemberList.setPassword(null);
//                excelStoreMemberList.setCashPassword(null);
//                excelStoreMemberLists.add(excelStoreMemberList);
//            }
//            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(excelStoreMemberLists, writeSheet);
//            out.flush();
//        } catch (Exception e) {
//            log.error("SsmMemberController.export:",e);
//        } finally {
//            //destFile.delete();
//            // 别忘记关闭流
//            excelWriter.finish();
//        }
//    }
//
//
//    @ApiOperation(value = "门店会员批量导入  门店端-会员-门店会员批量导入", httpMethod = "POST", response = GenericResponse.class)
//    @RequestMapping("/import")
//    public GenericResponse memImport(@RequestParam MultipartFile multipartFile, @RequestParam String phone, @RequestParam Long storeId, @RequestParam String storeName) {
//        GenericResponse genericResponse = new GenericResponse();
////        Long storeId = SessionHelp.getStoreId(session);
////        String storeName = SessionHelp.getStoreName(session);
//        String key = phone;
//        List<ExcelStoreMemberList> list = null;
//        try {
//            list = EasyExcelUtil.simpleWrite(multipartFile, ExcelStoreMemberList.class);
//        } catch (SmsException e) {
//            log.error("SsmMemberController.memImport:",e);
//            return genericResponse;
//        }
//
//        List<StoreMemberList> memberLists = new ArrayList<>();
//        for (ExcelStoreMemberList excelStoreMemberList : list) {
//            StoreMemberList memberList = new StoreMemberList();
//            BeanUtils.copyProperties(excelStoreMemberList, memberList);
//            if (excelStoreMemberList.getSex().equals("男")){
//                memberList.setSex(1);
//            }else if (excelStoreMemberList.getSex().equals("女")){
//                memberList.setSex(0);
//            }
//            if (excelStoreMemberList.getState().equals("启用")){
//                memberList.setState(1);
//            }else if (excelStoreMemberList.getState().equals("停用")){
//                memberList.setState(0);
//            }else if (excelStoreMemberList.getState().equals("启用中")){
//                memberList.setState(2);
//            }
//            if (StringUtils.isNotBlank(excelStoreMemberList.getHairLong()) && excelStoreMemberList.getHairLong().equals("长")){
//                memberList.setHairLong(1);
//            }else if (StringUtils.isNotBlank(excelStoreMemberList.getHairLong()) && excelStoreMemberList.getHairLong().equals("中")){
//                memberList.setHairLong(2);
//            }else if (StringUtils.isNotBlank(excelStoreMemberList.getHairLong()) && excelStoreMemberList.getHairLong().equals("短")){
//                memberList.setHairLong(3);
//            }
//            if (StringUtils.isNotBlank(excelStoreMemberList.getSkinType()) && excelStoreMemberList.getSkinType().equals("油性")){
//                memberList.setSkinType(1);
//            }else if (StringUtils.isNotBlank(excelStoreMemberList.getSkinType()) && excelStoreMemberList.getSkinType().equals("中性")){
//                memberList.setSkinType(2);
//            }else if (StringUtils.isNotBlank(excelStoreMemberList.getSkinType()) && excelStoreMemberList.getSkinType().equals("干性")){
//                memberList.setSkinType(3);
//            }
//            memberLists.add(memberList);
//        }
//        List<StoreMemberList> list1 = new ArrayList<>();
//        try {
//            list1 = ssmStoreMemberService.insertBatch(memberLists,storeId, storeName, key);
//        }catch (SmsException e){
//            genericResponse.setCodeAndMsg(e);
//            return genericResponse;
//        }catch (Exception e){
//            genericResponse.setCodeAndMsg(ResponseCode.FAILED);
//            return genericResponse;
//        }
//        if (!list1.isEmpty()){
//            genericResponse.setRows(list1);
//        }
//        return genericResponse;
//
//    }
        @ApiOperation(value = "会员协议分页查询",httpMethod = "POST",response = GenericResponse.class)
        @RequestMapping("/selectByMember")
        public GenericResponse<MemberAgreement> selectPage(@RequestBody MemberAgreementRequest memberFileRequest, HttpSession session) throws IOException, SmsException {
            GenericResponse<MemberAgreement> pageResponse = new GenericResponse<>();
            MemberAgreement memberAgreement;
            try {
                memberAgreement = ssmMemberAgreementService.selectByMember();
            } catch (Exception e) {
                log.error("SsmMemberAgreementController.selectPage", e);
                pageResponse.setCodeAndMsg(ResponseCode.FAILED);
                return pageResponse;
            }
            pageResponse.setCodeAndMsg(ResponseCode.OK);
            pageResponse.setData(memberAgreement);
            return pageResponse;
        }
}
