邀请用户 活动完成后要同步数据
continuous-integration/drone/push Build is passing Details

飞书小程序
YXY 1 year ago
parent 710e0a0d88
commit 0b0117e6b0

@ -2,18 +2,14 @@ package com.ruoyi.flyingbook.controller;
import com.alibaba.excel.EasyExcel; import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.support.ExcelTypeEnum; import com.alibaba.excel.support.ExcelTypeEnum;
import com.lark.oapi.service.authen.v1.model.CreateAccessTokenRespBody;
import com.lark.oapi.service.contact.v3.model.GetUserRespBody; import com.lark.oapi.service.contact.v3.model.GetUserRespBody;
import com.lark.oapi.service.contact.v3.model.User; import com.lark.oapi.service.contact.v3.model.User;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.enums.FlagStatus;
import com.ruoyi.common.enums.LarkUserTypeEnum; import com.ruoyi.common.enums.LarkUserTypeEnum;
import com.ruoyi.common.utils.ExportUtils; import com.ruoyi.common.utils.ExportUtils;
import com.ruoyi.common.utils.excelStrategy.CustomMergeStrategy; import com.ruoyi.common.utils.excelStrategy.CustomMergeStrategy;
import com.ruoyi.flyingbook.CosHelper.CosHelper; import com.ruoyi.flyingbook.CosHelper.CosHelper;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.enums.FlagStatus;
import com.ruoyi.common.enums.LarkActiveInviteStageEnum;
import com.ruoyi.common.enums.LarkActiveStageEnum;
import com.ruoyi.common.utils.file.FileUtils;
import com.ruoyi.flyingbook.LarkHelper.LarkUserHelper; import com.ruoyi.flyingbook.LarkHelper.LarkUserHelper;
import com.ruoyi.flyingbook.domain.LarkActive; import com.ruoyi.flyingbook.domain.LarkActive;
import com.ruoyi.flyingbook.domain.LarkLoginLog; import com.ruoyi.flyingbook.domain.LarkLoginLog;
@ -26,12 +22,12 @@ import com.ruoyi.flyingbook.service.*;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.File; import java.util.Arrays;
import java.util.*; import java.util.Date;
import java.util.List;
import java.util.Map;
@Slf4j @Slf4j
@RestController @RestController
@ -105,14 +101,6 @@ public class LarkActiveController extends BaseController {
return larkUserActiveRelatoinService.commitFile(request); return larkUserActiveRelatoinService.commitFile(request);
} }
/**
*
*/
@PostMapping("/submit")
public ResponseVo<LarkUserActiveRelatoin> submit(@RequestBody LarkActiveUserRelationRequest request) {
return larkUserActiveRelatoinService.commitFile(request);
}
/** /**
* *
*/ */
@ -152,8 +140,12 @@ public class LarkActiveController extends BaseController {
*/ */
@PostMapping("/inviteUser") @PostMapping("/inviteUser")
public ResponseVo<LarkInviteVo> inviteUser(@RequestBody LarkUserActiveInviteRelatoin request) { public ResponseVo<LarkInviteVo> inviteUser(@RequestBody LarkUserActiveInviteRelatoin request) {
ResponseVo responseVo = new ResponseVo();
if (request.getUserName().equals(request.getInviteUserName())){
return responseVo;
}
larkUserActiveInviteRelatoinService.create(request); larkUserActiveInviteRelatoinService.create(request);
return new ResponseVo(); return responseVo;
} }
/** /**

@ -1,6 +1,7 @@
package com.ruoyi.flyingbook.mapper; package com.ruoyi.flyingbook.mapper;
import com.ruoyi.flyingbook.domain.LarkUserActiveInviteRelatoin; import com.ruoyi.flyingbook.domain.LarkUserActiveInviteRelatoin;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
@ -26,7 +27,8 @@ public interface LarkUserActiveInviteRelatoinMapper {
* @return * @return
*/ */
public List<LarkUserActiveInviteRelatoin> selectLarkUserActiveInviteRelatoinList(LarkUserActiveInviteRelatoin larkUserActiveInviteRelatoin); public List<LarkUserActiveInviteRelatoin> selectLarkUserActiveInviteRelatoinList(LarkUserActiveInviteRelatoin larkUserActiveInviteRelatoin);
public List<LarkUserActiveInviteRelatoin> queryByInviteList(@Param("inviteList") List<String> inviteList,@Param("flag") Long flag,@Param("inviteStage") String inviteStage);
public int updateStage(@Param("idList") List<Long> idList,@Param("inviteStage") String inviteStage);
public List<LarkUserActiveInviteRelatoin> queryTopTen(LarkUserActiveInviteRelatoin larkUserActiveInviteRelatoin); public List<LarkUserActiveInviteRelatoin> queryTopTen(LarkUserActiveInviteRelatoin larkUserActiveInviteRelatoin);
/** /**

@ -33,6 +33,8 @@ public interface ILarkUserActiveInviteRelatoinService {
public List<LarkInviteVo> queryMyInviteList(LarkUserActiveInviteRelatoin larkUserActiveInviteRelatoin); public List<LarkInviteVo> queryMyInviteList(LarkUserActiveInviteRelatoin larkUserActiveInviteRelatoin);
public void inviteSuccess(List<String> openId);
/** /**
* *
* *

@ -16,6 +16,7 @@ import com.ruoyi.flyingbook.mapper.LarkUserActiveCommentMapper;
import com.ruoyi.flyingbook.mapper.LarkUserActiveRelatoinMapper; import com.ruoyi.flyingbook.mapper.LarkUserActiveRelatoinMapper;
import com.ruoyi.flyingbook.service.ILarkLoginLogService; import com.ruoyi.flyingbook.service.ILarkLoginLogService;
import com.ruoyi.flyingbook.service.ILarkUserActiveCommentService; import com.ruoyi.flyingbook.service.ILarkUserActiveCommentService;
import com.ruoyi.flyingbook.service.ILarkUserActiveInviteRelatoinService;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
@ -23,10 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.io.File; import java.io.File;
import java.util.Date; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
@ -46,6 +44,8 @@ public class LarkUserActiveCommentServiceImpl implements ILarkUserActiveCommentS
private LarkUserActiveRelatoinMapper larkUserActiveRelatoinMapper; private LarkUserActiveRelatoinMapper larkUserActiveRelatoinMapper;
@Autowired @Autowired
private ILarkLoginLogService larkLoginLogService; private ILarkLoginLogService larkLoginLogService;
@Autowired
private ILarkUserActiveInviteRelatoinService larkUserActiveInviteRelatoinService;
/** /**
* *
@ -131,6 +131,7 @@ public class LarkUserActiveCommentServiceImpl implements ILarkUserActiveCommentS
if (i >= active.getActiveImageCount()) { if (i >= active.getActiveImageCount()) {
relatoin.setActiveStage(LarkActiveStageEnum.ADJUST.getCode()); relatoin.setActiveStage(LarkActiveStageEnum.ADJUST.getCode());
larkUserActiveRelatoinMapper.updateLarkUserActiveRelatoin(relatoin); larkUserActiveRelatoinMapper.updateLarkUserActiveRelatoin(relatoin);
larkUserActiveInviteRelatoinService.inviteSuccess(Arrays.asList(request.getUserName()));
} }
return new ResponseVo(); return new ResponseVo();
} }

@ -74,6 +74,20 @@ public class LarkUserActiveInviteRelatoinServiceImpl implements ILarkUserActiveI
return result; return result;
} }
@Override
public void inviteSuccess(List<String> openId) {
if (CollectionUtils.isEmpty(openId)){
return;
}
List<LarkUserActiveInviteRelatoin> larkUserActiveInviteRelatoins = larkUserActiveInviteRelatoinMapper.queryByInviteList(openId, FlagStatus.OK.getCode(), LarkActiveInviteStageEnum.INVITE.getCode());
List<Long> idList = larkUserActiveInviteRelatoins.stream().map(LarkUserActiveInviteRelatoin::getId).collect(Collectors.toList());
if (CollectionUtils.isEmpty(idList)){
return;
}
larkUserActiveInviteRelatoinMapper.updateStage(idList,LarkActiveInviteStageEnum.ACTIVE.getCode());
}
@Override @Override
public List<LarkInviteVo> queryMyInviteList(LarkUserActiveInviteRelatoin larkUserActiveInviteRelatoin) { public List<LarkInviteVo> queryMyInviteList(LarkUserActiveInviteRelatoin larkUserActiveInviteRelatoin) {
larkUserActiveInviteRelatoin.setFlag(FlagStatus.OK.getCode()); larkUserActiveInviteRelatoin.setFlag(FlagStatus.OK.getCode());

@ -19,6 +19,7 @@ import com.ruoyi.flyingbook.mapper.LarkActiveMapper;
import com.ruoyi.flyingbook.mapper.LarkLoginLogMapper; import com.ruoyi.flyingbook.mapper.LarkLoginLogMapper;
import com.ruoyi.flyingbook.mapper.LarkUserActiveImageMapper; import com.ruoyi.flyingbook.mapper.LarkUserActiveImageMapper;
import com.ruoyi.flyingbook.mapper.LarkUserActiveRelatoinMapper; import com.ruoyi.flyingbook.mapper.LarkUserActiveRelatoinMapper;
import com.ruoyi.flyingbook.service.ILarkUserActiveInviteRelatoinService;
import com.ruoyi.flyingbook.service.ILarkUserActiveRelatoinService; import com.ruoyi.flyingbook.service.ILarkUserActiveRelatoinService;
import org.apache.commons.codec.binary.Base64; import org.apache.commons.codec.binary.Base64;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
@ -31,6 +32,7 @@ import java.io.BufferedOutputStream;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -54,6 +56,8 @@ public class LarkUserActiveRelatoinServiceImpl implements ILarkUserActiveRelatoi
private LarkUserActiveImageMapper larkUserActiveImageMapper; private LarkUserActiveImageMapper larkUserActiveImageMapper;
@Autowired @Autowired
private LarkLoginLogMapper larkLoginLogMapper; private LarkLoginLogMapper larkLoginLogMapper;
@Autowired
private ILarkUserActiveInviteRelatoinService larkUserActiveInviteRelatoinService;
private static final String BUCKET_NAME = "ruoyi-1308275795"; private static final String BUCKET_NAME = "ruoyi-1308275795";
@ -201,7 +205,7 @@ public class LarkUserActiveRelatoinServiceImpl implements ILarkUserActiveRelatoi
if (relatoin == null) { if (relatoin == null) {
return new ResponseVo(); return new ResponseVo();
} }
Integer totalCount = userActiveCount(relatoin) + 1; Integer totalCount = userActiveCount(relatoin,request.getImageBase64()) + 1;
LarkActive larkActive = larkActiveMapper.selectLarkActiveById(relatoin.getActiveId()); LarkActive larkActive = larkActiveMapper.selectLarkActiveById(relatoin.getActiveId());
if (StringUtils.isNotBlank(request.getImageBase64())) { if (StringUtils.isNotBlank(request.getImageBase64())) {
File file = base642File(request.getImageBase64()); File file = base642File(request.getImageBase64());
@ -218,6 +222,7 @@ public class LarkUserActiveRelatoinServiceImpl implements ILarkUserActiveRelatoi
if (totalCount >= larkActive.getActiveImageCount()) { if (totalCount >= larkActive.getActiveImageCount()) {
relatoin.setActiveStage(LarkActiveStageEnum.ADJUST.getCode()); relatoin.setActiveStage(LarkActiveStageEnum.ADJUST.getCode());
larkUserActiveRelatoinMapper.updateLarkUserActiveRelatoin(relatoin); larkUserActiveRelatoinMapper.updateLarkUserActiveRelatoin(relatoin);
larkUserActiveInviteRelatoinService.inviteSuccess(Arrays.asList(request.getUserName()));
} }
return new ResponseVo(); return new ResponseVo();
} }
@ -253,11 +258,22 @@ public class LarkUserActiveRelatoinServiceImpl implements ILarkUserActiveRelatoi
larkUserActiveImageMapper.insertLarkUserActiveImage(larkUserActiveImage); larkUserActiveImageMapper.insertLarkUserActiveImage(larkUserActiveImage);
} }
private Integer userActiveCount(LarkUserActiveRelatoin relatoin) { private Integer userActiveCount(LarkUserActiveRelatoin relatoin,String image) {
LarkUserActiveImage larkUserActiveImage = new LarkUserActiveImage(); LarkUserActiveImage larkUserActiveImage = new LarkUserActiveImage();
larkUserActiveImage.setUserActiveRelatoin(relatoin.getId()); larkUserActiveImage.setUserActiveRelatoin(relatoin.getId());
larkUserActiveImage.setFlag(FlagStatus.OK.getCode()); larkUserActiveImage.setFlag(FlagStatus.OK.getCode());
return larkUserActiveImageMapper.selectLarkUserActiveImageList(larkUserActiveImage).size(); List<LarkUserActiveImage> larkUserActiveImages = larkUserActiveImageMapper.selectLarkUserActiveImageList(larkUserActiveImage);
if (StringUtils.isNotBlank(image)) {
return larkUserActiveImages.size();
}else {
List<String> collect = larkUserActiveImages.stream()
.filter(r -> {
return StringUtils.isNotBlank(r.getRemark());
})
.map(LarkUserActiveImage::getRemark)
.distinct().collect(Collectors.toList());
return collect.size();
}
} }
private LarkUserActiveRelatoin queryUserActiveRelation(String companyName,String userName, Long activeId) { private LarkUserActiveRelatoin queryUserActiveRelation(String companyName,String userName, Long activeId) {

@ -58,6 +58,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectLarkUserActiveInviteRelatoinVo"/> <include refid="selectLarkUserActiveInviteRelatoinVo"/>
where id = #{id} where id = #{id}
</select> </select>
<select id="queryByInviteList" resultType="com.ruoyi.flyingbook.domain.LarkUserActiveInviteRelatoin">
<include refid="selectLarkUserActiveInviteRelatoinVo"/>
WHERE invite_stage = #{inviteStage} and flag = #{flag}
and invite_stage in (<foreach collection="inviteList" open="(" separator="," close=")" item="item">#{item}</foreach>)
</select>
<insert id="insertLarkUserActiveInviteRelatoin" parameterType="com.ruoyi.flyingbook.domain.LarkUserActiveInviteRelatoin" useGeneratedKeys="true" keyProperty="id"> <insert id="insertLarkUserActiveInviteRelatoin" parameterType="com.ruoyi.flyingbook.domain.LarkUserActiveInviteRelatoin" useGeneratedKeys="true" keyProperty="id">
insert into lark_user_active_invite_relatoin insert into lark_user_active_invite_relatoin
@ -106,6 +111,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim> </trim>
where id = #{id} where id = #{id}
</update> </update>
<update id="updateStage">
update lark_user_active_invite_relatoin set invite_stage = #{inviteStage}
where id in (<foreach collection="idList" open="(" separator="," close=")" item="item">#{item}</foreach>)
</update>
<delete id="deleteLarkUserActiveInviteRelatoinById" parameterType="Long"> <delete id="deleteLarkUserActiveInviteRelatoinById" parameterType="Long">
delete from lark_user_active_invite_relatoin where id = #{id} delete from lark_user_active_invite_relatoin where id = #{id}

Loading…
Cancel
Save