package com.kxs.system.biz.service.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.text.StrPool;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kxs.common.core.constant.SecurityConstants;
import com.kxs.common.core.constant.enums.ErrorTypeEnum;
import com.kxs.common.core.exception.GlobalCustomerException;
import com.kxs.common.core.util.R;
import com.kxs.common.core.util.RetOps;
import com.kxs.common.core.util.SysUtils;
import com.kxs.common.security.util.SecurityUtils;
import com.kxs.system.api.dto.kxsapp.camp.CampOpenNumStatDTO;
import com.kxs.system.api.dto.kxsapp.camp.PrizePoolDTO;
import com.kxs.system.api.feign.RemoteOldService;
import com.kxs.system.api.model.KxsCamp;
import com.kxs.system.api.model.KxsCampUser;
import com.kxs.system.api.vo.admin.CampUserExcelVO;
import com.kxs.system.api.vo.kxsapp.camp.CampGetByIdVO;
import com.kxs.system.api.vo.kxsapp.camp.CampPageVO;
import com.kxs.system.biz.constant.enums.CampStatusEnum;
import com.kxs.system.biz.constant.enums.SysErrorTypeEnum;
import com.kxs.system.biz.mapper.KxsCampMapper;
import com.kxs.system.biz.service.KxsCampService;
import com.kxs.system.biz.service.KxsCampUserService;
import com.kxs.user.api.feign.RemoteKxsUserService;
import com.kxs.user.api.model.KxsLeader;
import com.kxs.user.api.model.KxsUser;
import com.pig4cloud.plugin.excel.vo.ErrorMessage;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.BindingResult;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.*;

/**
 * 训练营(KxsCamp)表服务实现类
 *
 * @author 系统
 * @since 2024-04-08 15:44:02
 */
@Service("kxsCampService")
@RequiredArgsConstructor
@Slf4j
public class KxsCampServiceImpl extends ServiceImpl<KxsCampMapper, KxsCamp> implements KxsCampService {

    private final RemoteKxsUserService remoteKxsUserService;


    private final RemoteOldService remoteOldService;


    private final KxsCampUserService kxsCampUserService;


    @Override
    public R addData(KxsCamp param) {

        R<KxsUser> kxsUserR = remoteKxsUserService.loadUserById(param.getCreateUserId(), SecurityConstants.FROM_IN);
        KxsUser user = RetOps.of(kxsUserR)
                .getData()
                .orElseThrow(() -> new GlobalCustomerException(ErrorTypeEnum.USER_NOT_FOUND.getDescription()));

        param.setCreateUsername(user.getUsername());
        param.setCreateCode(user.getUserCode());

        return R.ok(baseMapper.insert(param));
    }

    @Override
    public R updateData(KxsCamp param) {

        if (Objects.isNull(param.getId())) {
            return R.failed(SysErrorTypeEnum.PARAM_ERROR.getDescription());
        }
        KxsCamp kxsCamp = baseMapper.selectById(param.getId());
        Optional.ofNullable(kxsCamp).orElseThrow(()-> new GlobalCustomerException(SysErrorTypeEnum.NOT_DATA.getDescription()));

        R<KxsUser> kxsUserR = remoteKxsUserService.loadUserById(param.getCreateUserId(), SecurityConstants.FROM_IN);
        KxsUser user = RetOps.of(kxsUserR)
                .getData()
                .orElseThrow(() -> new GlobalCustomerException(ErrorTypeEnum.USER_NOT_FOUND.getDescription()));

        param.setCreateUsername(user.getUsername());
        param.setCreateCode(user.getUserCode());

        return R.ok(baseMapper.updateById(param));
    }

    @Override
    public R importUserData(List<CampUserExcelVO> campUserExcelVOList, BindingResult bindingResult) {

        if (campUserExcelVOList.isEmpty()) {
            return R.failed(SysErrorTypeEnum.IMPORT_EMPTY.getDescription());
        }

        // 通用校验获取失败的数据
        List<ErrorMessage> errorMessageList = (List<ErrorMessage>) bindingResult.getTarget();
        // 执行数据插入操作
        for (CampUserExcelVO excel : campUserExcelVOList) {
            Set<String> errorMsg = new HashSet<>();
            //查询用户
            R<KxsUser> kxsUserR = remoteKxsUserService.loadUserByCode(excel.getUserCode(), SecurityConstants.FROM_IN);
            KxsUser user = RetOps.of(kxsUserR)
                    .getData()
                    .orElse(null);
            KxsCamp kxsCamp = baseMapper.selectById(excel.getCampId());
            Optional.ofNullable(kxsCamp).orElseThrow(()-> new GlobalCustomerException(excel.getCampId() + "训练营编号不存在，请重新上传！"));
            if(Objects.equals(kxsCamp.getStatus(), CampStatusEnum.STATUS_END.getType())){
                throw new GlobalCustomerException(excel.getCampId() + "训练营已结束，不允许导入！");
            }

            if (Objects.isNull(user)) {
                errorMsg.add(excel.getUserCode() + "创客未找到！");
            } else {
                if (user.getRealStatus() != 1) {
                    errorMsg.add(excel.getUserCode() + "创客未实名！");
                }
                //判断创客是否已在其他训练营
                KxsCamp camp = baseMapper.selectUserCamp(user.getId());
                if (camp != null) {
                    errorMsg.add(excel.getUserCode() + "已在训练营！");
                }
            }


            // 数据合法情况
            if (CollUtil.isEmpty(errorMsg)) {
                KxsCampUser campUser = new KxsCampUser();
                campUser.setCampId(excel.getCampId());
                campUser.setUserId(user.getId());
                campUser.setUsername(user.getUsername());
                campUser.setUserCode(user.getUserCode());
                kxsCampUserService.save(campUser);
            } else {
                // 数据不合法
                errorMessageList.add(new ErrorMessage(excel.getLineNum(), errorMsg));
            }
        }
        //刷新参与人数
        List<KxsCamp> kxsCamps = baseMapper.selectList(Wrappers.<KxsCamp>lambdaQuery().lt(KxsCamp::getStatus, CampStatusEnum.STATUS_END.getType()));
        for (KxsCamp kxsCamp : kxsCamps) {
            long count = kxsCampUserService.count(Wrappers.<KxsCampUser>lambdaQuery().eq(KxsCampUser::getCampId, kxsCamp.getId()));
            baseMapper.update(null, Wrappers.<KxsCamp>lambdaUpdate().set(KxsCamp::getUserNum, count).eq(KxsCamp::getId, kxsCamp.getId()));
        }
        if (CollUtil.isNotEmpty(errorMessageList)) {
            return R.failed(JSON.toJSONString(errorMessageList));
        }

        return R.ok();
    }

    @Override
    public IPage<CampPageVO> getByPage(Page<CampPageVO> page) {

        Long userId = SecurityUtils.getUser().getId();
        return baseMapper.getByPage(page, userId);
    }

    @Override
    public R getByData(Integer id) {
        KxsCamp kxsCamp = baseMapper.selectById(id);
        Optional.ofNullable(kxsCamp).orElseThrow(() -> new GlobalCustomerException(SysErrorTypeEnum.NOT_DATA.getDescription()));
        CampGetByIdVO campGetByIdVO = new CampGetByIdVO();
        BeanUtil.copyProperties(kxsCamp, campGetByIdVO);
        return R.ok(campGetByIdVO);
    }

    @Override
    @Async
    @Transactional(rollbackFor = Exception.class)
    public void prizePoolIsRefreshed(PrizePoolDTO param) {

        log.info("开始处理兑换券下单订单号:{}统计到训练营奖金池", param.getOrderNo());

        if(param.getProductId() == 27 || param.getProductId() == 28 || param.getProductId() == 39  || param.getProductId() == 40 ){
            //查询此用户是否参加进行中的训练营
            KxsCamp kxsCamp = baseMapper.selectUserCamp(param.getUserId());
            if (kxsCamp != null) {
                //给训练营加金额
                kxsCamp.setOrderNum(kxsCamp.getOrderNum() + 1);
                baseMapper.updateById(kxsCamp);

                //给创客团队加金额
                KxsCampUser kxsCampUser = kxsCampUserService.getOne(Wrappers.<KxsCampUser>lambdaQuery()
                        .eq(KxsCampUser::getCampId, kxsCamp.getId())
                        .eq(KxsCampUser::getUserId, param.getUserId()));
                kxsCampUser.setTeamLeaderNum(kxsCampUser.getTeamLeaderNum() + 1);
                kxsCampUserService.updateById(kxsCampUser);
                log.info("用户{}参加训练营{}，订单ID{}, 订单数{}", param.getUserId(), kxsCamp.getId(), param.getId(), kxsCamp.getOrderNum());
                return;
            }
            //查找此用户上级倒序后参加了训练营，把奖金加入到自己和训练营里
            R<KxsUser> kxsUserR = remoteKxsUserService.loadUserById(param.getUserId(), SecurityConstants.FROM_IN);
            KxsUser user = RetOps.of(kxsUserR)
                    .getData()
                    .orElseThrow(() -> new GlobalCustomerException(ErrorTypeEnum.USER_NOT_FOUND.getDescription()));
            //下单用户的上级路径
            String[] pidPaths = user.getPidPath().split(StrPool.COMMA);
            //翻转上级从最近的开始查询
            Arrays.sort(pidPaths, Collections.reverseOrder());
            KxsCampUser kxsCampUser = baseMapper.selectParentUsersCamp(pidPaths);
            if (kxsCampUser != null) {
                //给训练营加金额
                kxsCamp = baseMapper.selectById(kxsCampUser.getCampId());
                kxsCamp.setOrderNum(kxsCamp.getOrderNum() + 1);
                baseMapper.updateById(kxsCamp);

                //给创客团队加金额
                kxsCampUser.setTeamLeaderNum(kxsCampUser.getTeamLeaderNum() + 1);
                kxsCampUserService.updateById(kxsCampUser);
                log.info("用户{}的上级{}参加训练营{}，订单ID{},订单数{}", param.getUserId(), kxsCampUser.getUserId(), kxsCamp.getId(), param.getId(), kxsCamp.getOrderNum());
            }
            return;
        }


        //下单组数
        BigDecimal number = NumberUtil.div(param.getTotalPrice(), 600);
        //订单奖金
        BigDecimal amount = NumberUtil.mul(number, 60);
        //查询此用户是否参加进行中的训练营
        KxsCamp kxsCamp = baseMapper.selectUserCamp(param.getUserId());
        if (kxsCamp != null) {
            //给训练营加金额
            kxsCamp.setBonusPool(NumberUtil.add(kxsCamp.getBonusPool(), amount));
            kxsCamp.setOrderNum(kxsCamp.getOrderNum() + number.intValue());
            baseMapper.updateById(kxsCamp);

            //给创客团队加金额
            KxsCampUser kxsCampUser = kxsCampUserService.getOne(Wrappers.<KxsCampUser>lambdaQuery()
                    .eq(KxsCampUser::getCampId, kxsCamp.getId())
                    .eq(KxsCampUser::getUserId, param.getUserId()));
            kxsCampUser.setTeamOrderPool(NumberUtil.add(kxsCampUser.getTeamOrderPool(), amount));
            kxsCampUser.setTeamOrderNum(kxsCampUser.getTeamOrderNum() + number.intValue());
            kxsCampUserService.updateById(kxsCampUser);
            log.info("用户{}参加训练营{}，订单ID{}, 奖金池{}，订单数{}", param.getUserId(), kxsCamp.getId(), param.getId(), kxsCamp.getBonusPool(), kxsCamp.getOrderNum());
            return;
        }
        //查找此用户上级倒序后参加了训练营，把奖金加入到自己和训练营里
        R<KxsUser> kxsUserR = remoteKxsUserService.loadUserById(param.getUserId(), SecurityConstants.FROM_IN);
        KxsUser user = RetOps.of(kxsUserR)
                .getData()
                .orElseThrow(() -> new GlobalCustomerException(ErrorTypeEnum.USER_NOT_FOUND.getDescription()));
        //下单用户的上级路径
        String[] pidPaths = user.getPidPath().split(StrPool.COMMA);
        //翻转上级从最近的开始查询
        Arrays.sort(pidPaths, Collections.reverseOrder());
        KxsCampUser kxsCampUser = baseMapper.selectParentUsersCamp(pidPaths);
        if (kxsCampUser != null) {
            //给训练营加金额
            kxsCamp = baseMapper.selectById(kxsCampUser.getCampId());
            kxsCamp.setBonusPool(NumberUtil.add(kxsCamp.getBonusPool(), amount));
            kxsCamp.setOrderNum(kxsCamp.getOrderNum() + number.intValue());
            baseMapper.updateById(kxsCamp);

            //给创客团队加金额
            kxsCampUser.setTeamOrderPool(NumberUtil.add(kxsCampUser.getTeamOrderPool(), amount));
            kxsCampUser.setTeamOrderNum(kxsCampUser.getTeamOrderNum() + number.intValue());
            kxsCampUserService.updateById(kxsCampUser);
            log.info("用户{}的上级{}参加训练营{}，订单ID{},奖金池{},订单数{}", param.getUserId(), kxsCampUser.getUserId(), kxsCamp.getId(), param.getId(), kxsCamp.getBonusPool(), kxsCamp.getOrderNum());
        }

    }

    @Override
    @Async
    @Transactional(rollbackFor = Exception.class)
    public void campOpenNumStat(CampOpenNumStatDTO param) {

        log.info("开始处理激活数据:{}", JSON.toJSONString(param));
        //绑定时间
        LocalDateTime bindTime = LocalDateTimeUtil.parse(param.getBindTime(), DatePattern.UTC_SIMPLE_PATTERN);
        //查询当前用户参加的训练营
        KxsCamp kxsCamp = baseMapper.selectUserCamp(param.getUserId().intValue());
        if (kxsCamp != null) {
            //判断绑定时间
            if(kxsCamp.getStartTime().isAfter(bindTime)){
                return;
            }
            //给训练营加金额
            kxsCamp.setOpenNum(kxsCamp.getOpenNum() + (param.getActType() == 4 ? 2 : 1));
            baseMapper.updateById(kxsCamp);

            //给创客团队加金额
            KxsCampUser kxsCampUser = kxsCampUserService.getOne(Wrappers.<KxsCampUser>lambdaQuery()
                    .eq(KxsCampUser::getCampId, kxsCamp.getId())
                    .eq(KxsCampUser::getUserId, param.getUserId()));

            switch (param.getActType()){
                case 1 -> kxsCampUser.setTeamPosNum(kxsCampUser.getTeamPosNum() + 1);
                case 2 -> kxsCampUser.setTeamGdNum(kxsCampUser.getTeamGdNum() + 1);
                case 3 -> kxsCampUser.setTeamLkbNum(kxsCampUser.getTeamLkbNum() + 1);
                case 4 -> kxsCampUser.setTeamLkbNum(kxsCampUser.getTeamLkbNum() + 2);
            }
            kxsCampUser.setTeamOpenNum(kxsCampUser.getTeamPosNum() + kxsCampUser.getTeamGdNum() + kxsCampUser.getTeamLkbNum());
            kxsCampUserService.updateById(kxsCampUser);
            log.info("用户{}参加训练营{},开机数+1", param.getUserId(), kxsCamp.getId());
            return;
        }
        //查找此用户上级倒序后参加了训练营，把奖金加入到自己和训练营里
        R<KxsUser> kxsUserR = remoteKxsUserService.loadUserById(param.getUserId(), SecurityConstants.FROM_IN);
        KxsUser user = RetOps.of(kxsUserR)
                .getData()
                .orElseThrow(() -> new GlobalCustomerException(ErrorTypeEnum.USER_NOT_FOUND.getDescription()));
        //下单用户的上级路径
        String[] pidPaths = user.getPidPath().split(StrPool.COMMA);
        //翻转上级从最近的开始查询
        Arrays.sort(pidPaths, Collections.reverseOrder());
        KxsCampUser kxsCampUser = baseMapper.selectParentUsersCamp(pidPaths);
        if (kxsCampUser != null) {
            kxsCamp = baseMapper.selectById(kxsCampUser.getCampId());
            //判断绑定时间
            if(kxsCamp.getStartTime().isAfter(bindTime)){
                return;
            }
            kxsCamp.setOpenNum(kxsCamp.getOpenNum() + (param.getActType() == 4 ? 2 : 1));
            baseMapper.updateById(kxsCamp);

            //给创客团队加金额
            switch (param.getActType()){
                case 1 -> kxsCampUser.setTeamPosNum(kxsCampUser.getTeamPosNum() + 1);
                case 2 -> kxsCampUser.setTeamGdNum(kxsCampUser.getTeamGdNum() + 1);
                case 3 -> kxsCampUser.setTeamLkbNum(kxsCampUser.getTeamLkbNum() + 1);
                case 4 -> kxsCampUser.setTeamLkbNum(kxsCampUser.getTeamLkbNum() + 2);
            }
            kxsCampUser.setTeamOpenNum(kxsCampUser.getTeamPosNum() + kxsCampUser.getTeamGdNum() + kxsCampUser.getTeamLkbNum());
            kxsCampUserService.updateById(kxsCampUser);
            log.info("用户{}的上级{}参加训练营{}，开机数+1", param.getUserId(), kxsCampUser.getUserId(), kxsCamp.getId());
        }
    }

    @Override
    public IPage<KxsCamp> getBySysPage(Page<KxsCamp> page, KxsCamp param) {

        return this.page(page, Wrappers.<KxsCamp>lambdaQuery()
                .eq(StrUtil.isNotEmpty(param.getCreateCode()), KxsCamp::getCreateCode, param.getCreateCode())
                .orderByDesc(KxsCamp::getId));
    }


    @Override
    @Async
    public void poweronQuantityStatistics() {
        //查询正在进行中的活动
        List<KxsCamp> list = baseMapper.selectList(Wrappers.<KxsCamp>lambdaQuery().eq(KxsCamp::getStatus, CampStatusEnum.STATUS_NORMAL.getType()));
        //查询活动参与的创客
        for (KxsCamp kxsCamp : list) {

            List<KxsCampUser> campUsers = kxsCampUserService.list(Wrappers.<KxsCampUser>lambdaQuery().eq(KxsCampUser::getCampId, kxsCamp.getId()));
            //清除参与创客的所有统计数据然后封装在map里方便统计
            Map<Integer, KxsCampUser> campUsersMap = new HashMap<>();
            for (KxsCampUser campUser : campUsers) {
                KxsCampUser kxsCampUser = new KxsCampUser();
                BeanUtil.copyProperties(campUser, kxsCampUser);
                kxsCampUser.setTeamLeaderNum(0);
                kxsCampUser.setTeamOpenNum(0);
                campUsersMap.put(campUser.getUserId(), kxsCampUser);
            }

            //转换为userID集合
            List<Integer> userIds = campUsers.stream().map(KxsCampUser::getUserId).toList();

            /*
             * 查询活动区间开通的大盟主添加到奖金池
             */
            R<List<KxsLeader>> leadersR = remoteKxsUserService.getDateBetweenLeaders(LocalDateTimeUtil.format(kxsCamp.getStartTime(), DatePattern.NORM_DATETIME_PATTERN)
                    , SecurityConstants.FROM_IN);
            List<KxsLeader> leaders = RetOps.of(leadersR)
                    .getData()
                    .orElse(Collections.emptyList());
            for (KxsLeader leader : leaders) {
                //如果是参与者自己下的单
                if (userIds.contains(leader.getUserId())) {

                    //刷新参与创客的团队累计
                    KxsCampUser kxsCampUser = campUsersMap.get(leader.getUserId());
                    kxsCampUser.setTeamLeaderNum(kxsCampUser.getTeamLeaderNum() + 1);
                    kxsCampUserService.update(Wrappers.<KxsCampUser>lambdaUpdate().eq(KxsCampUser::getId, kxsCampUser.getId()).set(KxsCampUser::getTeamLeaderNum, kxsCampUser.getTeamLeaderNum()));
                    this.update(Wrappers.<KxsCamp>lambdaUpdate().eq(KxsCamp::getId, kxsCamp.getId()).set(KxsCamp::getOrderNum, kxsCamp.getOrderNum() + 1));
                    log.info("参与者{}自己下单盟主,进入到{}订单统计", leader.getUserId(), kxsCamp.getTitle());
                    continue;
                }
                //查询此盟主的上级
                R<KxsUser> kxsUserR = remoteKxsUserService.loadUserById(leader.getUserId(), SecurityConstants.FROM_IN);
                KxsUser user = RetOps.of(kxsUserR)
                        .getData()
                        .orElseThrow(() -> new GlobalCustomerException(ErrorTypeEnum.USER_NOT_FOUND.getDescription()));
                //下单用户的上级路径
                String[] pidPaths = user.getPidPath().split(",");
                //通过用户的pidPath倒序查找最近所属的上级
                Integer userId = SysUtils.checkUserIsChildren(pidPaths, userIds);
                if (userId != null) {
                    //刷新参与创客的团队累计
                    KxsCampUser kxsCampUser = campUsersMap.get(userId);
                    kxsCampUser.setTeamLeaderNum(kxsCampUser.getTeamLeaderNum() + 1);
                    kxsCampUserService.update(Wrappers.<KxsCampUser>lambdaUpdate().eq(KxsCampUser::getId, kxsCampUser.getId()).set(KxsCampUser::getTeamLeaderNum, kxsCampUser.getTeamLeaderNum()));

                    log.info("创客{}的上级{}参与训练营,进入到{}订单统计", leader.getUserId(), userId, kxsCamp.getTitle());
                }
            }
            //刷新训练营统计
            int leaderNum = 0;
            List<KxsCampUser> users = kxsCampUserService.list(Wrappers.<KxsCampUser>lambdaQuery().eq(KxsCampUser::getCampId, kxsCamp.getId()));
            for (KxsCampUser user : users) {
                leaderNum = leaderNum + user.getTeamLeaderNum();
            }
            kxsCamp.setOrderNum(kxsCamp.getOrderNum() + leaderNum);
            baseMapper.updateById(kxsCamp);
        }

    }

    @Override
    public R changeStatus(KxsCamp param) {

        if(!Objects.equals(param.getStatus(), CampStatusEnum.STATUS_NORMAL.getType()) && !Objects.equals(param.getStatus(), CampStatusEnum.STATUS_END.getType())){
            return R.failed(SysErrorTypeEnum.PARAM_ERROR.getDescription());
        }
        KxsCamp camp = baseMapper.selectById(param.getId());
        Optional.ofNullable(camp).orElseThrow(()-> new GlobalCustomerException("训练营不存在"));

        if(Objects.equals(camp.getStatus(), CampStatusEnum.STATUS_END.getType())){
            return R.failed("已结束的训练营无法再次开启");
        }
        if(Objects.equals(camp.getStatus(), param.getStatus())){
            return R.failed("训练营已开启");
        }

        camp.setStatus(param.getStatus());

        //开启活动刷新实际开始时间
        if(Objects.equals(param.getStatus(), CampStatusEnum.STATUS_NORMAL.getType())){
            camp.setStartTime(LocalDateTime.now());
        }
        //结束活动刷新实际结束时间
        if(Objects.equals(param.getStatus(), CampStatusEnum.STATUS_END.getType())){
            camp.setEndTime(LocalDateTime.now());
        }

        return R.ok(baseMapper.updateById(camp));
    }




//    private <T> void statusChange(T campT, LocalDateTime now) {
//        if (campT instanceof KxsCamp camp) {
//            if (camp.getEndTime().isBefore(now)) {
//                camp.setStatus(CampStatusEnum.STATUS_END.getType());
//            } else if (LocalDateTimeUtil.isIn(now, camp.getStartTime(), camp.getEndTime(), false, false)) {
//                camp.setStatus(CampStatusEnum.STATUS_NORMAL.getType());
//            } else {
//                camp.setStatus(CampStatusEnum.STATUS_CLOSE.getType());
//            }
//        }
//        if (campT instanceof CampPageVO camp) {
//            if (camp.getEndTime().isBefore(now)) {
//                camp.setStatus(CampStatusEnum.STATUS_END.getType());
//            } else if (LocalDateTimeUtil.isIn(now, camp.getStartTime(), camp.getEndTime(), false, false)) {
//                camp.setStatus(CampStatusEnum.STATUS_NORMAL.getType());
//            } else {
//                camp.setStatus(CampStatusEnum.STATUS_CLOSE.getType());
//            }
//        }
//    }

}

