huanghongfa
2021-07-22 02f18587bd8860b305e2c688e20465be166bb48c
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActEasyPhotoServiceImpl.java
@@ -11,17 +11,13 @@
import com.panzhihua.common.model.vos.community.ComActEasyPhotoCommentVO;
import com.panzhihua.common.model.vos.community.ComActEasyPhotoVO;
import com.panzhihua.common.model.vos.community.TodoEventsVO;
import com.panzhihua.common.utlis.DateUtils;
import com.panzhihua.common.utlis.SensitiveUtil;
import com.panzhihua.common.utlis.StringUtils;
import com.panzhihua.service_community.dao.ComActEasyPhotoCommentDAO;
import com.panzhihua.service_community.dao.ComActEasyPhotoCommentUserDAO;
import com.panzhihua.service_community.dao.ComActEasyPhotoDAO;
import com.panzhihua.service_community.dao.ComActEasyPhotoUserDAO;
import com.panzhihua.service_community.model.dos.ComActEasyPhotoCommentDO;
import com.panzhihua.service_community.model.dos.ComActEasyPhotoCommentUserDO;
import com.panzhihua.service_community.model.dos.ComActEasyPhotoDO;
import com.panzhihua.service_community.model.dos.ComActEasyPhotoUserDO;
import com.panzhihua.service_community.dao.*;
import com.panzhihua.service_community.model.dos.*;
import com.panzhihua.service_community.service.ComActEasyPhotoService;
import com.panzhihua.service_community.service.ComActUserWalletService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
@@ -47,6 +43,10 @@
    private ComActEasyPhotoCommentDAO comActEasyPhotoCommentDAO ;
    @Resource
    private ComActEasyPhotoCommentUserDAO comActEasyPhotoCommentUserDAO ;
    @Resource
    private ComActEasyPhotoActivityMapper comActEasyPhotoActivityMapper;
    @Resource
    private ComActUserWalletService comActUserWalletService;
    /**
     * 分页查询随手拍
     *
@@ -129,6 +129,18 @@
    public R addEasyPhoto(ComActEasyPhotoVO comActEasyPhotoVO) {
        ComActEasyPhotoDO comActEasyPhotoDO=new ComActEasyPhotoDO();
        BeanUtils.copyProperties(comActEasyPhotoVO,comActEasyPhotoDO);
        //查询是否在活动时间内
        Date nowDate = DateUtils.getCurrentDate(DateUtils.ymdhms_format);
        List<ComActEasyPhotoActivityDO> photoActivityDOS = comActEasyPhotoActivityMapper.selectList(
                new QueryWrapper<ComActEasyPhotoActivityDO>().lambda().eq(ComActEasyPhotoActivityDO::getCommunityId,comActEasyPhotoVO.getCommunityId())
                        .le(ComActEasyPhotoActivityDO::getActivityStartAt,nowDate).ge(ComActEasyPhotoActivityDO::getActivityEndAt,nowDate)
                        .eq(ComActEasyPhotoActivityDO::getStatus,ComActEasyPhotoActivityDO.status.jxz));
        if(!photoActivityDOS.isEmpty()){
            ComActEasyPhotoActivityDO photoActivityDO = photoActivityDOS.get(0);
            photoActivityDO.setCount(photoActivityDO.getCount() + 1);
            comActEasyPhotoDO.setActivityId(photoActivityDO.getId());
            comActEasyPhotoActivityMapper.updateById(photoActivityDO);
        }
        int insert = comActEasyPhotoDAO.insert(comActEasyPhotoDO);
        if (insert>0) {
            return R.ok();
@@ -185,10 +197,15 @@
        ComActEasyPhotoDO cmActEasyPhotoDO=new ComActEasyPhotoDO();
        cmActEasyPhotoDO.setId(comActEasyPhotoVO.getId());
        cmActEasyPhotoDO.setHandlerId(comActEasyPhotoVO.getUserId());
//        cmActEasyPhotoDO.setActivityType(comActEasyPhotoVO.getActivityType());
        Date date = new Date();
        switch (type){
            case 1:
                int isNeedFeedBack = comActEasyPhotoVO.getIsNeedFeedBack().intValue();
                cmActEasyPhotoDO = this.comActEasyPhotoDAO.selectById(comActEasyPhotoVO.getId());
                if(!cmActEasyPhotoDO.getStatus().equals(ComActEasyPhotoDO.status.dsh)){
                    return R.fail("该随手拍已审核,不可重复操作");
                }
                Integer isNeedFeedBack = comActEasyPhotoVO.getIsNeedFeedBack();
                if (isNeedFeedBack==1) {
                    cmActEasyPhotoDO.setStatus(2);//进行中
                    cmActEasyPhotoDO.setIsNeedFeedBack(1);
@@ -196,13 +213,23 @@
                    cmActEasyPhotoDO.setStatus(4);//已完成
                }
                cmActEasyPhotoDO.setExamineAt(date);
                //审核通过判断随手拍是否有活动并计算用户收益
                comActUserWalletService.examineAddMoney(comActEasyPhotoVO.getActivityType(),comActEasyPhotoVO.getId(),comActEasyPhotoVO.getUserId());
                break;
            case 2:
                cmActEasyPhotoDO = this.comActEasyPhotoDAO.selectById(comActEasyPhotoVO.getId());
                if(!cmActEasyPhotoDO.getStatus().equals(ComActEasyPhotoDO.status.dsh)){
                    return R.fail("该随手拍已审核,不可重复操作");
                }
                cmActEasyPhotoDO.setStatus(3);//已驳回
                cmActEasyPhotoDO.setExamineAt(date);
                cmActEasyPhotoDO.setRejectReason(comActEasyPhotoVO.getRejectReason());
                break;
            case 3:
                cmActEasyPhotoDO = this.comActEasyPhotoDAO.selectById(comActEasyPhotoVO.getId());
                if(!cmActEasyPhotoDO.getStatus().equals(ComActEasyPhotoDO.status.dfk)){
                    return R.fail("该随手拍不是待反馈状态,不可进行反馈");
                }
                cmActEasyPhotoDO.setHandleResult(comActEasyPhotoVO.getHandleResult());
                cmActEasyPhotoDO.setHandlePhotoList(comActEasyPhotoVO.getHandlePhotoList());
                cmActEasyPhotoDO.setStatus(4);//已完成
@@ -370,7 +397,15 @@
        return R.fail();
    }
    /**
     * 社区随手拍列表统计
     * @param communityId   社区id
     * @return  统计结果
     */
    @Override
    public R easyPhotoStatistics(Long communityId){
        return R.ok(this.baseMapper.getEasyPhotoStatistics(communityId));
    }
}