Commit 48a5508e by 阮思源

Merge branch 'feat-1002438' into 'master'

1002438优化个人号群发

See merge request rays/pcloud-book!470
parents dfee59f3 db47e3bf
package com.pcloud.book.group.enums;
import com.pcloud.common.utils.string.StringUtil;
public enum LargeTempletEnum {
/**
* K12类
......@@ -37,4 +39,19 @@ public enum LargeTempletEnum {
this.name = name;
}
public static String getNameByCode(Integer code) {
if (code==null) {
return null;
}
LargeTempletEnum[] all = values();
int length = all.length;
for (int i = 0; i < length; ++i) {
LargeTempletEnum largeTempletEnum = all[i];
if (largeTempletEnum.code.equals(code)) {
return largeTempletEnum.name;
}
}
return null;
}
}
......@@ -3,6 +3,7 @@ package com.pcloud.book.push.biz;
import com.pcloud.book.group.vo.UserBookInfoVO;
import com.pcloud.book.push.dto.SelfPushAddParamDTO;
import com.pcloud.book.push.dto.SelfPushRecordDTO;
import com.pcloud.book.push.entity.SelfPush;
import com.pcloud.common.page.PageBeanNew;
/**
......@@ -54,4 +55,11 @@ public interface SelfPushBiz {
* @param targetRobot
*/
void copyRobotData(String originRobot, String targetRobot);
/**
* 修改个人号群发
*/
void updateSelfPush(Long partyId, SelfPushAddParamDTO addParamDTO);
SelfPush getSelfPush(Long pushId);
}
......@@ -12,12 +12,14 @@ import com.pcloud.book.group.dto.BookGroupDTO;
import com.pcloud.book.group.dto.SelfRobotBookGroupDTO;
import com.pcloud.book.group.entity.WeixinQrcodeGeneration;
import com.pcloud.book.group.enums.AppAndProductTypeEnum;
import com.pcloud.book.group.enums.LargeTempletEnum;
import com.pcloud.book.group.set.GroupSet;
import com.pcloud.book.group.vo.UserBookInfoVO;
import com.pcloud.book.guide.dto.PcloudGuideMessageDTO;
import com.pcloud.book.keywords.enums.ReplyTypeEnum;
import com.pcloud.book.pcloudKeyword.dto.RobotClassifyDTO;
import com.pcloud.book.pcloudkeyword.biz.PcloudRobotBiz;
import com.pcloud.book.pcloudkeyword.entity.PcloudRobot;
import com.pcloud.book.pcloudkeyword.set.PcloudRobotSet;
import com.pcloud.book.push.biz.SelfPushBiz;
import com.pcloud.book.push.constant.PushConstant;
......@@ -48,6 +50,7 @@ import com.pcloud.resourcecenter.product.dto.ProductDto;
import com.pcloud.usercenter.user.entity.UserLogin;
import com.pcloud.wechatgroup.group.dto.GroupRobotDTO;
import com.pcloud.wechatgroup.group.dto.GroupUserDTO;
import com.pcloud.wechatgroup.selfrobot.dto.RobotBaseInfoDTO;
import com.sdk.wxgroup.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.MapUtils;
......@@ -57,6 +60,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.stream.Collectors;
......@@ -689,4 +693,55 @@ public class SelfPushBizImpl implements SelfPushBiz {
createSelfPush(selfPush.getCreateUser(), addParamDTO);
}
}
@Transactional(rollbackFor = Exception.class)
@ParamLog("修改个人号群发")
@Override
public void updateSelfPush(Long partyId, SelfPushAddParamDTO addParamDTO) {
if (addParamDTO==null||addParamDTO.getPushId()==null){
throw new BookBizException(BookBizException.PARAM_IS_NULL,"参数错误!");
}
//先查询群发状态
Integer status = selfPushItemDao.getStatusByPushId(addParamDTO.getPushId());
if (!PushStatusEnum.WAIT.value.equals(status)){
throw new BookBizException(BookBizException.ERROR,"状态不为待发送,不能修改!");
}
deleteByPushId(addParamDTO.getPushId());
createSelfPush(partyId,addParamDTO);
}
@ParamLog("获取个人号群发")
@Override
public SelfPush getSelfPush(Long pushId) {
if (pushId==null){
throw new BookBizException(BookBizException.PARAM_IS_NULL,"pushId不能为空!");
}
SelfPush selfPush = selfPushDao.getById(pushId);
if (selfPush==null){
throw new BookBizException(BookBizException.ERROR,"未找到!");
}
List<SelfPushItem> pushItems=selfPushItemDao.getByPushId(pushId);
fillItem(pushItems);
selfPush.setPushItems(pushItems);
String altId=selfPush.getAltId();
String altName=null;
String altTypeName=null;
PcloudRobot pcloudRobot = pcloudRobotBiz.getPcloudRobotByWxId(altId);
if (pcloudRobot!=null){
//小睿
altName=pcloudRobot.getNickName();
altTypeName="小睿";
}else {
//不是小睿
Map<String, RobotBaseInfoDTO> mapRobotInfo = wechatGroupConsr.mapRobotInfo(Arrays.asList(altId));
if (mapRobotInfo!=null&&mapRobotInfo.get(altId)!=null){
RobotBaseInfoDTO robotBaseInfoDTO=mapRobotInfo.get(altId);
altName=robotBaseInfoDTO.getNickName();
altTypeName=LargeTempletEnum.getNameByCode(robotBaseInfoDTO.getLargeTemplet());
}
}
selfPush.setAltName(altName);
selfPush.setAltTypeName(altTypeName);
return selfPush;
}
}
......@@ -28,4 +28,6 @@ public interface SelfPushItemDao extends BaseDao<SelfPushItem>{
List<SelfPushItem> getByPushId(Long pushId);
public void deleteByPushId(Long pushId);
Integer getStatusByPushId(Long pushId);
}
......@@ -36,4 +36,11 @@ public class SelfPushItemDaoImpl extends BaseDaoImpl<SelfPushItem> implements Se
public void deleteByPushId(Long pushId) {
getSessionTemplate().delete(getStatement("deleteByPushId"), pushId);
}
@Override
public Integer getStatusByPushId(Long pushId) {
Map<String, Object> map = new HashMap<>();
map.put("pushId", pushId);
return getSessionTemplate().selectOne(getStatement("getStatusByPushId"), map);
}
}
......@@ -18,6 +18,11 @@ import java.util.List;
public class SelfPushAddParamDTO {
/**
* 个人号群发id
*/
private Long pushId;
/**
* 推送小号id
*/
private String altId;
......
......@@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import com.pcloud.common.entity.BaseEntity;
import java.util.Date;
import java.util.List;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
......@@ -15,6 +16,11 @@ public class SelfPush extends BaseEntity{
@ApiModelProperty("群发小号id")
private String altId;
@ApiModelProperty("小号名称")
private String altName;
private String altTypeName;
@ApiModelProperty("创建人")
private Long createUser;
......@@ -61,6 +67,9 @@ public class SelfPush extends BaseEntity{
@ApiModelProperty("是否发送所有好友")
private Boolean sendAll;
@ApiModelProperty("个人号发送项集合")
private List<SelfPushItem> pushItems;
public Date getStartTime() {
return startTime;
}
......@@ -109,6 +118,30 @@ public class SelfPush extends BaseEntity{
this.altId = altId;
}
public String getAltName() {
return altName;
}
public void setAltName(String altName) {
this.altName = altName;
}
public String getAltTypeName() {
return altTypeName;
}
public void setAltTypeName(String altTypeName) {
this.altTypeName = altTypeName;
}
public List<SelfPushItem> getPushItems() {
return pushItems;
}
public void setPushItems(List<SelfPushItem> pushItems) {
this.pushItems = pushItems;
}
public Long getCreateUser() {
return createUser;
}
......
......@@ -107,4 +107,29 @@ public class SelfPushFacade {
selfPushBiz.deleteByPushId(pushId);
return new ResponseDto<>();
}
@ApiOperation("修改个人号群发")
@PostMapping("updateSelfPush")
public ResponseDto<?> updateSelfPush(@RequestHeader("token") String token, @RequestBody @ApiParam SelfPushAddParamDTO addParamDTO) throws PermissionException {
Map<String, Object> map = SessionUtil.getToken4Redis(token);
Long partyId = (Long) map.get(SessionUtil.PARTY_ID);
String systemCode = (String) map.get(SessionUtil.SYSTEM_CODE);
addParamDTO.setSystemCode(systemCode);
pushCheck.selfPushParamCheck(addParamDTO);
if (partyId == 0){
String isSystem = (String) map.get(SessionUtil.IS_SYSTEM);
if ("0".equals(isSystem)) {
partyId = (Long) map.get(SessionUtil.MEMBER_ID);
}
}
selfPushBiz.updateSelfPush(partyId, addParamDTO);
return new ResponseDto<>();
}
@ApiOperation("获取个人号群发")
@GetMapping("getSelfPush")
public ResponseDto<?> getSelfPush(@RequestHeader("token") String token,@RequestParam("pushId") Long pushId) throws PermissionException {
SessionUtil.getInfoToken4Redis(token);
return new ResponseDto<>(selfPushBiz.getSelfPush(pushId));
}
}
......@@ -169,4 +169,10 @@
WHERE push_id = #{pushId}
</delete>
<select id="getStatusByPushId" parameterType="map" resultType="integer">
select push_status from self_push_item
where push_id=#{pushId}
group by push_id
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment