Commit 52791976 by 李传峰

Merge remote-tracking branch 'remotes/origin/master' into 3.x

parents b90b9f47 4c760c87
package com.pcloud.book.applet.enums;
public enum SubscribeRecordTypeEnum {
ADD_SUBSCRIBE(1, "消息未读提醒"),
SUB_SUBSCRIBE(2, "主人召回提醒");
public Integer value;
public String desc;
SubscribeRecordTypeEnum(Integer value, String desc) {
this.value = value;
this.desc = desc;
}
}
......@@ -154,4 +154,9 @@ public interface AppletService {
@GetMapping("getLatest10Books4Clock")
ResponseEntity<ResponseDto<List<BookDto>>> getLatest10Books4Clock(@RequestParam("wechatUserId") Long wechatUserId,
@RequestParam("officialAccountsId") Long officialAccountsId);
@ApiOperation("小程序订阅消息次数更新")
@GetMapping("subAppletSubscribeCount")
void subAppletSubscribeCount(@RequestParam("wechatUserId") Long wechatUserId,
@RequestParam("recordType") Integer recordType);
}
......@@ -832,6 +832,64 @@ public class BookDto extends BaseDto {
//是否开启手机号登录
private Integer bookPhoneAuth;
/**
* 科目
*/
private String label1;
/**
* 年级
*/
private String label2;
/**
* 版本
*/
private String label3;
/**
* 上下册
*/
private String label4;
public String getLabel1() {
return label1;
}
public void setLabel1(String label1) {
this.label1 = label1;
}
public String getLabel2() {
return label2;
}
public void setLabel2(String label2) {
this.label2 = label2;
}
public String getLabel3() {
return label3;
}
public void setLabel3(String label3) {
this.label3 = label3;
}
public String getLabel4() {
return label4;
}
public void setLabel4(String label4) {
this.label4 = label4;
}
private Integer isWechatAuth;
public Integer getIsWechatAuth() {
return isWechatAuth;
}
public void setIsWechatAuth(Integer isWechatAuth) {
this.isWechatAuth = isWechatAuth;
}
public Integer getUploadUserId() {
return uploadUserId;
......
......@@ -3,6 +3,7 @@ package com.pcloud.book.book.dto;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
......@@ -10,6 +11,7 @@ import java.io.Serializable;
* @author lily
* @date 2018/12/5 20:51
*/
@Data
@ApiModel
@JsonInclude(JsonInclude.Include.NON_NULL)
public class BookInfoAndAuthStatusDTO implements Serializable {
......@@ -35,71 +37,6 @@ public class BookInfoAndAuthStatusDTO implements Serializable {
@ApiModelProperty("书刊作者")
private String author;
public Integer getIsDelete() {
return isDelete;
}
public void setIsDelete(Integer isDelete) {
this.isDelete = isDelete;
}
public Long getBookId() {
return bookId;
}
public void setBookId(Long bookId) {
this.bookId = bookId;
}
public String getBookName() {
return bookName;
}
public void setBookName(String bookName) {
this.bookName = bookName;
}
public String getCoverImg() {
return coverImg;
}
public void setCoverImg(String coverImg) {
this.coverImg = coverImg;
}
public Integer getBookStatus() {
return bookStatus;
}
public void setBookStatus(Integer bookStatus) {
this.bookStatus = bookStatus;
}
public String getPublish() {
return publish;
}
public void setPublish(String publish) {
this.publish = publish;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
@Override
public String toString() {
return "BookInfoAndAuthStatusDTO{" +
"bookId=" + bookId +
", bookName='" + bookName + '\'' +
", coverImg='" + coverImg + '\'' +
", bookStatus=" + bookStatus +
", publish='" + publish + '\'' +
", isDelete=" + isDelete +
'}';
}
@ApiModelProperty("授权后还需付费")
private Integer isAuthorizedPay;
}
......@@ -40,4 +40,9 @@ public interface BookAuthServeService {
ResponseEntity<ResponseDto<Map<String, Boolean>>> listIsOpen4ServeIdsAndBookId(@RequestBody BookAuthServerDTO bookAuthServerDTO)
throws BizException;
@ApiOperation(value = "获取应用是否开启授权后仍需付费", httpMethod = "POST")
@PostMapping("listIsOpen4AuthorizedFree")
ResponseEntity<ResponseDto<Map<String, Boolean>>> listIsOpen4AuthorizedPay(@RequestBody BookAuthServerDTO bookAuthServerDTO)
throws BizException;
}
......@@ -33,26 +33,18 @@ public class CultivateNotifySend extends BaseEntity {
@ApiModelProperty("是否已读1-是,0-否")
private Boolean isRead;
@JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss",
timezone = "GMT+8"
)
@ApiModelProperty("阅读时间")
private Date readTime;
@ApiModelProperty("标题")
private String title;
@JSONField(
format = "yyyy-MM-dd HH:mm:ss"
)
@JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss",
timezone = "GMT+8"
)
@XmlElement
public Date getReadTime() {
return this.createTime;
}
public void setReadTime(Date readTime) {
this.readTime = readTime;
}
@ApiModelProperty("是否首页展示")
private Integer showHome;
}
......@@ -3,12 +3,13 @@ package com.pcloud.book.cultivate.enums;
public enum NotifyMessageType {
//消息类型(1-系统消息,2-通知消息,3-提醒消息,4-活动消息
SYSTEM(1,"系统消息"),
NOTICE(2, "通知消息"),
REMEMBER(3,"提醒消息"),
ACTIVITY(4,"活动消息"),
SYSTEM(1,"小睿新鲜事"),
NOTICE(2, "互动提醒"),
REMEMBER(3,"系统消息"),
ACTIVITY(4,"优惠活动"),
MORE(5,"更多消息");
public Integer code;
public String desc;
......
......@@ -5,6 +5,10 @@ public enum NotifySendTypeEnum {
/**
* 指定用户
*/
OTHER(0),
/**
* 指定用户
*/
APPOINT_USER(1),
/**
* 分类用户
......@@ -24,9 +28,10 @@ public enum NotifySendTypeEnum {
USER_PROFILE(5),
/**
* 提出问题
* 用户学龄段
*/
RAISE_QUESTIOIN(6);
USER_GRADE(6),
RAISE_QUESTIOIN(7);
public final Integer value;
......
......@@ -327,4 +327,11 @@ public interface AppletNewsBiz {
* * @param null
*/
Map<Long, Integer> getStayOnlineAppClickCount();
/**
* 批量获取资讯详情
* @param newsIds
* @return
*/
List<AppletNews> getListByIds(List<Long> newsIds);
}
......@@ -119,4 +119,12 @@ public interface AppletRecordBiz {
* @param trackDTO 埋点信息
*/
void track(Long wechatUserId, Long officialAccountsId, AppletTrackDTO trackDTO);
/**
* 最近一条足迹
* @author:zhuyajie
* @date:2021/8/4 10:42
* * @param null
*/
AppletRecordDTO getLatestAppletRecord(Long wechatUserId, Long officialAccountsId);
}
package com.pcloud.book.applet.biz;
import com.pcloud.book.applet.entity.AppletSubscribeCount;
import com.pcloud.common.page.PageBeanNew;
/**
* (AppletSubscribeCount)表服务接口
*
* @author wubo
* @since 2021-08-03 09:37:45
*/
public interface AppletSubscribeCountBiz {
/**
* 通过ID查询单条数据
*
* @param id 主键
* @return 实例对象
*/
AppletSubscribeCount getById(Long id);
/**
* 分页查询
*/
PageBeanNew getList(Integer currentPage, Integer numPerPage);
/**
* 新增数据
*
* @param appletSubscribeCount 实例对象
* @return 主键
*/
Long insert(AppletSubscribeCount appletSubscribeCount);
/**
* 修改数据
*
* @param appletSubscribeCount 实例对象
*/
void update(AppletSubscribeCount appletSubscribeCount);
/**
* 通过主键删除数据
*
* @param id 主键
* @return 是否成功
*/
void deleteById(Long id);
/**
* 通过主键软删除数据
*
* @param id 主键
* @return 是否成功
*/
void softDeleteById(Long id);
/**
* 获取用户订阅次数
* @param wechatUserId
* @param recordType
* @return
*/
AppletSubscribeCount getByUserId(Long wechatUserId, Integer recordType);
/**
* 清除用户次数
* @param wechatUserId
* @param recordType
*/
void clearSubscribeCount(Long wechatUserId, Integer recordType);
}
\ No newline at end of file
package com.pcloud.book.applet.biz;
import com.pcloud.book.applet.entity.AppletSubscribeRecord;
import com.pcloud.common.page.PageBeanNew;
/**
* (AppletSubscribeRecord)表服务接口
*
* @author wubo
* @since 2021-08-03 09:37:00
*/
public interface AppletSubscribeRecordBiz {
/**
* 通过ID查询单条数据
*
* @param id 主键
* @return 实例对象
*/
AppletSubscribeRecord getById(Long id);
/**
* 分页查询
*/
PageBeanNew getList(Integer currentPage, Integer numPerPage);
/**
* 新增数据
*
* @param appletSubscribeRecord 实例对象
* @return 主键
*/
Long insert(AppletSubscribeRecord appletSubscribeRecord);
/**
* 修改数据
*
* @param appletSubscribeRecord 实例对象
*/
void update(AppletSubscribeRecord appletSubscribeRecord);
/**
* 通过主键删除数据
*
* @param id 主键
* @return 是否成功
*/
void deleteById(Long id);
/**
* 通过主键软删除数据
*
* @param id 主键
* @return 是否成功
*/
void softDeleteById(Long id);
}
\ No newline at end of file
......@@ -36,7 +36,7 @@ public interface ServeCollectBiz {
* @param serveCollect 实例对象
* @return 主键
*/
AppletTaskDTO insert(ServeCollect serveCollect);
String insert(ServeCollect serveCollect);
/**
* 修改数据
......@@ -123,4 +123,18 @@ public interface ServeCollectBiz {
*/
void processingData2TypeCode();
/**
* 取消收藏
* @param serveCollect
*/
void cancel(ServeCollect serveCollect);
/**
* 获取收藏状态 true 收藏 false 未收藏
* @param wechatUserId
* @param serverId
* @param serveType
* @return
*/
Boolean getCollectState(Long wechatUserId, Long serverId, Integer serveType);
}
\ No newline at end of file
......@@ -152,8 +152,9 @@ public class AnswerSubscribeBizImpl implements AnswerSubscribeBiz {
//资源有新增,发送消息
Long accountSettingId=answerSubscribeUser.getAccountSettingId();
if (BookProps.getMiniOfficialAccountsId().equals(accountSettingId)){
//小程序消息
this.sendAppletTemplateMsg(wechatUserId, accountSettingId,bookName);
/* //小程序消息
this.sendAppletTemplateMsg(wechatUserId, accountSettingId,bookName);*/
continue;
} else {
//公众号消息
String url = getResourcePageUrl(bookId, adviserId, channelId);
......
......@@ -610,9 +610,6 @@ public class AppletBooklistBizImpl implements AppletBooklistBiz {
if (StringUtil.isEmpty(appletOuterBooklistDTO.getUserName())){
throw new BookBizException(BookBizException.PARAM_IS_NULL, "缺少创建者名称");
}
if (StringUtil.isEmpty(appletOuterBooklistDTO.getDisplayPic())){
throw new BookBizException(BookBizException.PARAM_IS_NULL, "缺少展示图");
}
if (StringUtil.isEmpty(appletOuterBooklistDTO.getPublish())){
throw new BookBizException(BookBizException.PARAM_IS_NULL, "缺少出版社");
}
......
......@@ -1362,4 +1362,9 @@ public class AppletNewsBizImpl implements AppletNewsBiz {
}
return map;
}
@Override
public List<AppletNews> getListByIds(List<Long> newsIds) {
return appletNewsDao.getListByIds(newsIds);
}
}
......@@ -76,6 +76,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
......@@ -896,4 +897,24 @@ public class AppletRecordBizImpl implements AppletRecordBiz {
JedisClusterUtils.set(HANDLE_APPLET_RECORD_TYPE_CODE_STATUS_KEY, "stop", 3600);
}
@Override
public AppletRecordDTO getLatestAppletRecord(Long wechatUserId, Long officialAccountsId) {
List<Long> wechatUserIds = readerConsr.getRelateUserIdList(wechatUserId, officialAccountsId);
Map<String, Object> paramMap = new HashMap<>();
List<Integer> recordTypes = Arrays.asList(AppletRecordTypeEnum.APP.value,AppletRecordTypeEnum.PRODUCT.value,AppletRecordTypeEnum.BOOK.value);
paramMap.put("wechatUserIds", wechatUserIds);
paramMap.put("recordTypes", recordTypes);
paramMap.put("limit", 10);
List<AppletRecordDTO> recordList = appletRecordServeDao.listAppletRecordLimit(paramMap);
if (ListUtils.isEmpty(recordList)) {
return new AppletRecordDTO();
}
fillAppletRecord(recordList, YesOrNoNumEnum.NO.getValue());
recordList = recordList.stream().filter(x -> x.getSourceDelete() == 0).collect(Collectors.toList());
if (ListUtils.isEmpty(recordList)) {
return new AppletRecordDTO();
}
return recordList.get(0);
}
}
package com.pcloud.book.applet.biz.impl;
import com.pcloud.book.applet.biz.AppletSubscribeCountBiz;
import com.pcloud.book.applet.dao.AppletSubscribeCountDao;
import com.pcloud.book.applet.entity.AppletSubscribeCount;
import com.pcloud.book.applet.enums.SubscribeCountTypeEnum;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.page.PageParam;
import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.NumberUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* (AppletSubscribeCount)表服务实现类
*
* @author wubo
* @since 2021-08-03 09:37:45
*/
@Service("appletSubscribeCountBiz")
public class AppletSubscribeCountBizImpl implements AppletSubscribeCountBiz {
private static final Logger LOGGER = LoggerFactory.getLogger(AppletSubscribeCountBizImpl.class);
@Autowired
private AppletSubscribeCountDao appletSubscribeCountDao;
@Override
@ParamLog("通过ID查询单条数据")
public AppletSubscribeCount getById(Long id) {
return appletSubscribeCountDao.getById(id);
}
@Override
@ParamLog("查询多条数据")
public PageBeanNew getList(Integer currentPage, Integer numPerPage) {
PageBeanNew pageBeanNew = appletSubscribeCountDao.listPageNew(new PageParam(currentPage, numPerPage), null, "getList");
List recordList = pageBeanNew.getRecordList();
if (ListUtils.isEmpty(recordList)) {
return pageBeanNew;
}
// 加载其它数据
return pageBeanNew;
}
@Override
@ParamLog("新增")
public Long insert(AppletSubscribeCount appletSubscribeCount) {
appletSubscribeCountDao.insert(appletSubscribeCount);
return appletSubscribeCount.getId();
}
@Override
@ParamLog("修改")
public void update(AppletSubscribeCount appletSubscribeCount) {
if (appletSubscribeCount == null || !NumberUtil.isNumber(appletSubscribeCount.getId())) {
throw BizException.PARAM_IS_NULL;
}
appletSubscribeCountDao.update(appletSubscribeCount);
}
@Override
@ParamLog("删除")
public void deleteById(Long id) {
appletSubscribeCountDao.deleteById(id);
}
@Override
@ParamLog("软删除")
public void softDeleteById(Long id) {
appletSubscribeCountDao.softDeleteById(id);
}
@Override
@ParamLog("获取用户订阅次数")
public AppletSubscribeCount getByUserId(Long wechatUserId, Integer recordType) {
return appletSubscribeCountDao.getByUserId(wechatUserId, recordType);
}
@Override
@ParamLog("清零用户次数")
public void clearSubscribeCount(Long wechatUserId, Integer recordType) {
appletSubscribeCountDao.clearSubscribeCount(wechatUserId, recordType);
}
}
\ No newline at end of file
package com.pcloud.book.applet.biz.impl;
import com.pcloud.book.applet.biz.AppletSubscribeCountBiz;
import com.pcloud.book.applet.biz.AppletSubscribeRecordBiz;
import com.pcloud.book.applet.dao.AppletSubscribeRecordDao;
import com.pcloud.book.applet.entity.AppletSubscribeCount;
import com.pcloud.book.applet.entity.AppletSubscribeRecord;
import com.pcloud.book.applet.enums.SubscribeCountTypeEnum;
import com.pcloud.book.util.common.YesOrNoEnums;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.page.PageParam;
import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.NumberUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* (AppletSubscribeRecord)表服务实现类
*
* @author wubo
* @since 2021-08-03 09:37:01
*/
@Service("appletSubscribeRecordBiz")
public class AppletSubscribeRecordBizImpl implements AppletSubscribeRecordBiz {
private static final Logger LOGGER = LoggerFactory.getLogger(AppletSubscribeRecordBizImpl.class);
@Autowired
private AppletSubscribeRecordDao appletSubscribeRecordDao;
@Autowired
private AppletSubscribeCountBiz appletSubscribeCountBiz;
@Override
@ParamLog("通过ID查询单条数据")
public AppletSubscribeRecord getById(Long id) {
return appletSubscribeRecordDao.getById(id);
}
@Override
@ParamLog("查询多条数据")
public PageBeanNew getList(Integer currentPage, Integer numPerPage) {
PageBeanNew pageBeanNew = appletSubscribeRecordDao.listPageNew(new PageParam(currentPage, numPerPage), null, "getList");
List recordList = pageBeanNew.getRecordList();
if (ListUtils.isEmpty(recordList)) {
return pageBeanNew;
}
// 加载其它数据
return pageBeanNew;
}
@Override
@ParamLog("新增")
@Transactional(rollbackFor = Exception.class)
public Long insert(AppletSubscribeRecord appletSubscribeRecord) {
if (null == appletSubscribeRecord || null == appletSubscribeRecord.getRecordType()) {
throw new BizException(BizException.PARAM_IS_NULL.getCode(), "新增消息授权失败");
}
appletSubscribeRecordDao.insert(appletSubscribeRecord);
//查询用户订阅次数
Integer subscribeRecordCount = SubscribeCountTypeEnum.getCountByValue(appletSubscribeRecord.getCountType());
AppletSubscribeCount subscribeCount = appletSubscribeCountBiz.getByUserId(appletSubscribeRecord.getWechatUserId(), appletSubscribeRecord.getRecordType());
if (null == subscribeCount && subscribeRecordCount > 0) {
subscribeCount = new AppletSubscribeCount();
subscribeCount.setWechatUserId(appletSubscribeRecord.getWechatUserId());
subscribeCount.setValidCount(YesOrNoEnums.YES.getValue());
subscribeCount.setRecordType(appletSubscribeRecord.getRecordType());
appletSubscribeCountBiz.insert(subscribeCount);
} else if (null != subscribeCount){
subscribeCount.setValidCount(subscribeCount.getValidCount() + subscribeRecordCount);
if (subscribeCount.getValidCount() < 0) {
subscribeCount.setValidCount(0);
}
appletSubscribeCountBiz.update(subscribeCount);
}
return appletSubscribeRecord.getId();
}
@Override
@ParamLog("修改")
public void update(AppletSubscribeRecord appletSubscribeRecord) {
if (appletSubscribeRecord == null || !NumberUtil.isNumber(appletSubscribeRecord.getId())) {
throw BizException.PARAM_IS_NULL;
}
appletSubscribeRecordDao.update(appletSubscribeRecord);
}
@Override
@ParamLog("删除")
public void deleteById(Long id) {
appletSubscribeRecordDao.deleteById(id);
}
@Override
@ParamLog("软删除")
public void softDeleteById(Long id) {
appletSubscribeRecordDao.softDeleteById(id);
}
}
\ No newline at end of file
......@@ -170,11 +170,14 @@ public class AppletUserBookcaseBizImpl implements AppletUserBookcaseBiz {
}
private void updateUserGradeLabel(AppletUserBookcase appletUserBookcase) {
//用户没有标签,更新用户年级标签
//如果书刊能匹配到,更新用户年级标签
//用户是否有年级标签
Boolean hasLabel = false;
UserGradeLabelIdDTO labelIdDTO = readerConsr.getUserGrade(appletUserBookcase.getWechatUserId(), appletUserBookcase.getOfficialAccountsId());
if (null != labelIdDTO && null != labelIdDTO.getLabelId()) {
return;
hasLabel = true;
}
//获取书刊匹配的年级标签
BookAdviserDto bookAdviserDto = bookAdviserBiz.getBase(appletUserBookcase.getBookId(), appletUserBookcase.getChannelId(), appletUserBookcase.getAdviserId());
if (null == bookAdviserDto) {
return;
......@@ -186,9 +189,14 @@ public class AppletUserBookcaseBizImpl implements AppletUserBookcaseBiz {
if (null != bookAdviserDto.getDepLabelId()) {
gradeId = resourcePageBiz.getGradeByDepLabelId(bookAdviserDto.getDepLabelId());
}
//匹配不到,取已工作年龄段
gradeId = null == gradeId ? 29L : gradeId;
readerConsr.addUserGradeLabel(appletUserBookcase.getWechatUserId(), appletUserBookcase.getOfficialAccountsId(), gradeId);
//书刊匹配不到且用户当前没有标签,取已工作年龄段
if (null == gradeId && !hasLabel) {
gradeId = 29L;
}
//更新用户年级标签
if (null != gradeId) {
readerConsr.addUserGradeLabel(appletUserBookcase.getWechatUserId(), appletUserBookcase.getOfficialAccountsId(), gradeId);
}
//更新用户书籍标签
if (null != bookAdviserDto.getTempletId()) {
try {
......
......@@ -28,11 +28,14 @@ import com.pcloud.book.group.enums.AppAndProductTypeEnum;
import com.pcloud.book.group.tools.SendWeixinRequestTools;
import com.pcloud.book.util.common.ThreadPoolUtils;
import com.pcloud.book.util.common.YesOrNoEnums;
import com.pcloud.channelcenter.qrcode.dto.GroupQrcodeVO;
import com.pcloud.channelcenter.wechat.dto.AccountSettingDto;
import com.pcloud.channelcenter.wechat.entity.AccountSetting;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.page.PageParam;
import com.pcloud.common.utils.BeanUtils;
import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.NumberUtil;
import com.pcloud.common.utils.string.StringUtil;
......@@ -46,6 +49,7 @@ import com.pcloud.resourcecenter.product.dto.ProductTypeDto;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.HashMap;
......@@ -88,6 +92,8 @@ public class ServeCollectBizImpl implements ServeCollectBiz {
private ReaderConsr readerConsr;
@Autowired
private BookDao bookDao;
@Value("${operate_official_id}")
private Long operateOfficialId;
@Override
......@@ -100,7 +106,7 @@ public class ServeCollectBizImpl implements ServeCollectBiz {
@ParamLog("查询多条数据")
public PageBeanNew getList(Long wechatUserId, Integer currentPage, Integer numPerPage, String typeCode,
Long officialAccountsId) {
List<Long> wechatUserIds = readerConsr.getRelateUserIdList(wechatUserId, officialAccountsId);
List<Long> wechatUserIds = readerConsr.getAllUnionUser(wechatUserId);
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("wechatUserIds", wechatUserIds);
paramMap.put("typeCode",typeCode);
......@@ -308,31 +314,26 @@ public class ServeCollectBizImpl implements ServeCollectBiz {
@Override
@ParamLog("新增收藏")
public AppletTaskDTO insert(ServeCollect serveCollect) {
public String insert(ServeCollect serveCollect) {
paramCheck(serveCollect);
fillParam(serveCollect);
AppletTaskDTO appletTaskDTO = new AppletTaskDTO();
if (StringUtil.isEmpty(serveCollect.getServeTypeName())) {
fillTypeCodeAndTypeName(Lists.newArrayList(serveCollect));
}
serveCollectDao.insert(serveCollect);
Integer taskCount = readerConsr.getTaskCount(serveCollect.getWechatUserId(), MoneyReceiveTypeEnum.COLLECTION.key);
Integer subtractTaskCount = RmallContants.COLLECTION_MONEY_TIMES - 1;
Integer isFinish = 0;
if (null != taskCount && subtractTaskCount.equals(taskCount)) {
isFinish = 1;
}
appletTaskDTO.setIsFinishTask(isFinish);
RMALL_SIGN_IN.execute(()->{
//收藏埋点
if (null == serveCollect.getIsDelete() || YesOrNoNumEnum.NO.getValue().equals(serveCollect.getIsDelete())){
RmallBookMoneyRecord rmallBookMoneyRecord = new RmallBookMoneyRecord();
rmallBookMoneyRecord.setWechatUserId(serveCollect.getWechatUserId());
rmallBookMoneyRecord.setRecordType(MoneyReceiveTypeEnum.COLLECTION.key);
rmallBookMoneyRecordService.insert(rmallBookMoneyRecord);
List<Long> allUnionUserIds = readerConsr.getAllUnionUser(serveCollect.getWechatUserId());
ServeCollect collected = serveCollectDao.getCollectByUser(allUnionUserIds, serveCollect.getServeId(), serveCollect.getServeType());
if (null != collected) {
if (YesOrNoNumEnum.YES.getValue().equals(collected.getIsDelete())) {
//删除状态,则更新状态为收藏
collected.setIsDelete(YesOrNoNumEnum.NO.getValue());
serveCollectDao.update(collected);
}
} else {
//不存在则新增
if (StringUtil.isEmpty(serveCollect.getServeTypeName())) {
fillTypeCodeAndTypeName(Lists.newArrayList(serveCollect));
}
});
return appletTaskDTO;
serveCollectDao.insert(serveCollect);
}
AccountSetting appInfo = qrcodeSceneConsr.getAppInfo(operateOfficialId);
return null != appInfo ? appInfo.getQrcodeUrl() : "https://oss.5rs.me/oss/uploadfe/jpg/5962646df4abeb5ece0b7037be4f3e6a.jpg";
}
private void fillParam(ServeCollect serveCollect) {
......@@ -414,7 +415,7 @@ public class ServeCollectBizImpl implements ServeCollectBiz {
LOGGER.error("[ServeCollectBizImpl.isCollected]参数为空,wechatUserId:{} serverId:{}",wechatUserId,serverId);
throw BizException.PARAM_IS_NULL;
}
ServeCollectDTO collected = serveCollectDao.isCollected(wechatUserId, serverId);
ServeCollectDTO collected = serveCollectDao.isCollected(wechatUserId, serverId, AppletRecordTypeEnum.NEWS.value);
if (null == collected){
ServeCollectDTO serveCollectDTO = new ServeCollectDTO();
serveCollectDTO.setIsCollected(0);
......@@ -545,6 +546,26 @@ public class ServeCollectBizImpl implements ServeCollectBiz {
}
}
@Override
@ParamLog("取消收藏")
public void cancel(ServeCollect serveCollect) {
paramCheck(serveCollect);
List<Long> allUnionUserIds = readerConsr.getAllUnionUser(serveCollect.getWechatUserId());
List<ServeCollect> serveCollects = serveCollectDao.getCollectList(allUnionUserIds, serveCollect.getServeId(), serveCollect.getServeType(), null);
if (ListUtils.isEmpty(serveCollects)) {
return;
}
List<Long> ids = serveCollects.stream().map(e -> e.getId()).collect(Collectors.toList());
serveCollectDao.cancelCollect(ids);
}
@Override
public Boolean getCollectState(Long wechatUserId, Long serverId, Integer serveType) {
List<Long> allUnionUserIds = readerConsr.getAllUnionUser(wechatUserId);
List<ServeCollect> collectList = serveCollectDao.getCollectList(allUnionUserIds, serverId, serveType, YesOrNoNumEnum.NO.getValue());
return ListUtils.isEmpty(collectList) ? Boolean.FALSE : Boolean.TRUE;
}
private void fillTypeCodeAndTypeName(List<ServeCollect> recordList){
List<Long> newsIdList = recordList.stream().filter(serveCollect -> AppletRecordTypeEnum.NEWS.value.equals(serveCollect.getServeType())).
map(serveCollect -> serveCollect.getServeId()).collect(Collectors.toList());
......
......@@ -186,4 +186,11 @@ public interface AppletNewsDao extends BaseDao<AppletNews> {
* @return
*/
Map<Long, AppletNewsDTO> getByIds4Record(List<Long> newsIds);
/**
* 批量获取资讯详情
* @param newsIds
* @return
*/
List<AppletNews> getListByIds(List<Long> newsIds);
}
......@@ -25,4 +25,6 @@ public interface AppletRecordServeDao extends BaseDao<AppletRecordServe> {
void batchUpdate(List<AppletRecordDTO> recordList);
List<AppletRecordServe> getUserRecordListByType(Long wechatUserId, Integer recordType);
List<AppletRecordDTO> listAppletRecordLimit(Map<String, Object> map);
}
\ No newline at end of file
package com.pcloud.book.applet.dao;
import com.pcloud.book.applet.entity.AppletSubscribeCount;
import com.pcloud.common.core.dao.BaseDao;
/**
* (AppletSubscribeCount)表数据库访问层
*
* @author wubo
* @since 2021-08-03 09:37:45
*/
public interface AppletSubscribeCountDao extends BaseDao<AppletSubscribeCount> {
int softDeleteById(Long id);
/**
* 获取用户订阅次数
* @param wechatUserId
* @param recordType
* @return
*/
AppletSubscribeCount getByUserId(Long wechatUserId, Integer recordType);
void clearSubscribeCount(Long wechatUserId, Integer recordType);
}
\ No newline at end of file
package com.pcloud.book.applet.dao;
import com.pcloud.book.applet.entity.AppletSubscribeRecord;
import com.pcloud.common.core.dao.BaseDao;
/**
* (AppletSubscribeRecord)表数据库访问层
*
* @author wubo
* @since 2021-08-03 09:37:00
*/
public interface AppletSubscribeRecordDao extends BaseDao<AppletSubscribeRecord> {
int softDeleteById(Long id);
}
\ No newline at end of file
......@@ -31,7 +31,7 @@ public interface ServeCollectDao extends BaseDao<ServeCollect> {
List<CollectionTypeNameAndCountDTO> getTypeNameAndCountByWechatId(List<Long> wechatUserIds );
ServeCollectDTO isCollected(Long wechatUserId,Long serveId );
ServeCollectDTO isCollected(Long wechatUserId, Long serveId, Integer serveType);
List<CollectionTypeNameCodeClassifyVO> getDistinctTypeCode();
......@@ -40,4 +40,8 @@ public interface ServeCollectDao extends BaseDao<ServeCollect> {
List<ServeCollect> List2ProcessedData();
void batchUpdate(List<ServeCollect> serveCollectList);
ServeCollect getCollectByUser(List<Long> wechatUserId, Long serveId, Integer serveType);
List<ServeCollect> getCollectList(List<Long> allUnionUserIds, Long serveId, Integer serveType, Integer isDelete);
}
\ No newline at end of file
......@@ -247,6 +247,11 @@ public class AppletNewsDaoImpl extends BaseDaoImpl<AppletNews> implements Applet
}
@Override
public List<AppletNews> getListByIds(List<Long> newsIds) {
return this.getSqlSession().selectList(getStatement("getListByIds"), newsIds);
}
@Override
public Integer listAppletNews4WechatCount(Map<String, Object> paramMap) {
return getSessionTemplate().selectOne(getStatement("listAppletNews4WechatCount"), paramMap);
}
......
......@@ -51,4 +51,9 @@ public class AppletRecordServeDaoImpl extends BaseDaoImpl<AppletRecordServe> imp
paramMap.put("recordType", recordType);
return getSessionTemplate().selectList(getStatement("getUserRecordListByType"), paramMap);
}
@Override
public List<AppletRecordDTO> listAppletRecordLimit(Map<String, Object> map) {
return getSessionTemplate().selectList(getStatement("listAppletRecordLimit"), map);
}
}
\ No newline at end of file
package com.pcloud.book.applet.dao.impl;
import com.pcloud.book.applet.dao.AppletSubscribeCountDao;
import com.pcloud.book.applet.entity.AppletSubscribeCount;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Repository;
import java.util.HashMap;
import java.util.Map;
/**
* (AppletSubscribeCount)表数据库访问层
*
* @author wubo
* @since 2021-08-03 09:37:45
*/
@Repository("appletSubscribeCountDaoImpl")
public class AppletSubscribeCountDaoImpl extends BaseDaoImpl<AppletSubscribeCount> implements AppletSubscribeCountDao {
public int softDeleteById(Long id) {
return getSessionTemplate().update(getStatement("softDeleteById"), id);
}
@Override
public AppletSubscribeCount getByUserId(Long wechatUserId, Integer recordType) {
Map<String, Object> params = new HashMap<>();
params.put("wechatUserId", wechatUserId);
params.put("recordType", recordType);
return getSessionTemplate().selectOne(getStatement("getByUserId"), params);
}
@Override
public void clearSubscribeCount(Long wechatUserId, Integer recordType) {
Map<String, Object> params = new HashMap<>();
params.put("wechatUserId", wechatUserId);
params.put("recordType", recordType);
getSessionTemplate().update(getStatement("clearSubscribeCount"), params);
}
}
\ No newline at end of file
package com.pcloud.book.applet.dao.impl;
import com.pcloud.book.applet.dao.AppletSubscribeRecordDao;
import com.pcloud.book.applet.entity.AppletSubscribeRecord;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Repository;
/**
* (AppletSubscribeRecord)表数据库访问层
*
* @author wubo
* @since 2021-08-03 09:37:00
*/
@Repository("appletSubscribeRecordDaoImpl")
public class AppletSubscribeRecordDaoImpl extends BaseDaoImpl<AppletSubscribeRecord> implements AppletSubscribeRecordDao {
public int softDeleteById(Long id) {
return getSessionTemplate().update(getStatement("softDeleteById"), id);
}
}
\ No newline at end of file
......@@ -48,10 +48,11 @@ public class ServeCollectDaoImpl extends BaseDaoImpl<ServeCollect> implements Se
}
@Override
public ServeCollectDTO isCollected(Long wechatUserId, Long serveId) {
public ServeCollectDTO isCollected(Long wechatUserId, Long serveId, Integer serveType) {
Map<String, Object> paraMap = new HashMap<>();
paraMap.put("wechatUserId",wechatUserId);
paraMap.put("serveId",serveId);
paraMap.put("serveType",serveType);
return getSessionTemplate().selectOne(getStatement("isCollected"),paraMap);
}
......@@ -76,6 +77,25 @@ public class ServeCollectDaoImpl extends BaseDaoImpl<ServeCollect> implements Se
}
@Override
public ServeCollect getCollectByUser(List<Long> wechatUserIds, Long serveId, Integer serveType) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("wechatUserIds", wechatUserIds);
paramMap.put("serveId", serveId);
paramMap.put("serveType", serveType);
return getSessionTemplate().selectOne(getStatement("getCollectByUser"), paramMap);
}
@Override
public List<ServeCollect> getCollectList(List<Long> wechatUserIds, Long serveId, Integer serveType, Integer isDelete) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("wechatUserIds", wechatUserIds);
paramMap.put("serveId", serveId);
paramMap.put("serveType", serveType);
paramMap.put("isDelete", isDelete);
return getSessionTemplate().selectList(getStatement("getCollectList"), paramMap);
}
@Override
public List<Long> getAllCollect(List<Long> wechatUserIds,String typeCode) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("wechatUserIds",wechatUserIds);
......
package com.pcloud.book.applet.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* (AppletSubscribeCount)实体类
*
* @author wubo
* @since 2021-08-09 10:54:38
*/
@Data
public class AppletSubscribeCount extends BaseEntity {
private static final long serialVersionUID = -91920484989934172L;
@ApiModelProperty("主键id")
private Long id;
@ApiModelProperty("用户id")
private Long wechatUserId;
@ApiModelProperty("记录类型 1 消息未读提醒 2 主人召回提醒")
private Integer recordType;
@ApiModelProperty("可用次数")
private Integer validCount;
@ApiModelProperty("创建时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
@ApiModelProperty("更新时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateTime;
}
\ No newline at end of file
package com.pcloud.book.applet.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* (AppletSubscribeRecord)实体类
*
* @author wubo
* @since 2021-08-09 10:51:15
*/
@Data
public class AppletSubscribeRecord extends BaseEntity {
private static final long serialVersionUID = 190586377697572581L;
@ApiModelProperty("主键id")
private Long id;
@ApiModelProperty("用户id")
private Long wechatUserId;
@ApiModelProperty("记录类型 1 消息未读提醒 2 主人召回提醒")
private Integer recordType;
@ApiModelProperty("记录类型 1 小程序服务消息+1 2 小程序服务消息-1 ")
private Integer countType;
@ApiModelProperty("创建时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
@ApiModelProperty("更新时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateTime;
}
\ No newline at end of file
package com.pcloud.book.applet.enums;
public enum SubscribeCountTypeEnum {
ADD_SUBSCRIBE(1, "增加订阅次数", 1),
SUB_SUBSCRIBE(2, "减少订阅次数", -1);
public Integer value;
public String desc;
public Integer subscribeCount;
SubscribeCountTypeEnum(Integer value, String desc, Integer subscribeCount) {
this.value = value;
this.desc = desc;
this.subscribeCount = subscribeCount;
}
public static Integer getCountByValue(Integer value){
SubscribeCountTypeEnum[] subscribeRecordTypeEnums = values();
for (int i = 0; i < subscribeRecordTypeEnums.length; i++) {
SubscribeCountTypeEnum subscribeRecordTypeEnum = subscribeRecordTypeEnums[i];
if (subscribeRecordTypeEnum.value.equals(value)){
return subscribeRecordTypeEnum.subscribeCount;
}
}
return null;
}
}
......@@ -162,4 +162,12 @@ public class AppletRecordFacade {
return new ResponseDto<>();
}
@ApiOperation("最近一条足迹")
@GetMapping("getLatestAppletRecord")
public ResponseDto<?> getLatestAppletRecord(@CookieValue("userInfo") String userInfo){
Long wechatUserId = Cookie.getId(userInfo,Cookie._WECHAT_USER_ID);
Long officialAccountsId = Cookie.getId(userInfo, Cookie._OFFICIAL_ACCOUNTS_ID);
return new ResponseDto<>(appletRecordBiz.getLatestAppletRecord(wechatUserId, officialAccountsId));
}
}
\ No newline at end of file
package com.pcloud.book.applet.facade;
import com.pcloud.book.applet.biz.AppletSubscribeCountBiz;
import com.pcloud.book.applet.entity.AppletSubscribeCount;
import com.pcloud.book.applet.entity.AppletSubscribeRecord;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.dto.ResponseDto;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.permission.PermissionException;
import com.pcloud.common.utils.cookie.Cookie;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
* (AppletSubscribeCount)表控制层
*
* @author wubo
* @since 2021-08-03 09:37:46
*/
@RestController("appletSubscribeCountFacade")
@RequestMapping("appletSubscribeCount")
public class AppletSubscribeCountFacade {
@Autowired
private AppletSubscribeCountBiz appletSubscribeCountBiz;
@ApiOperation("通过主键查询单条数据")
@GetMapping("getById")
public ResponseDto<?> getById(@CookieValue("userInfo") String userInfo,
@RequestParam Long id) throws BizException, PermissionException {
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
return new ResponseDto<>(appletSubscribeCountBiz.getById(id));
}
@ApiOperation("分页查询")
@GetMapping("getList")
public ResponseDto<?> getList(@CookieValue("userInfo") String userInfo,
@RequestParam(value = "currentPage", defaultValue = "0") Integer currentPage,
@RequestParam(value = "numPerPage", defaultValue = "10") Integer numPerPage)
throws BizException, PermissionException {
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
return new ResponseDto<>(appletSubscribeCountBiz.getList(currentPage, numPerPage));
}
@ApiOperation("新增")
@PostMapping("insert")
public ResponseDto<?> insert(@CookieValue("userInfo") String userInfo,
@RequestBody AppletSubscribeCount appletSubscribeCount)
throws BizException, PermissionException {
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
return new ResponseDto<>(appletSubscribeCountBiz.insert(appletSubscribeCount));
}
@ApiOperation("更新")
@PostMapping("update")
public ResponseDto<?> update(@CookieValue("userInfo") String userInfo,
@RequestBody AppletSubscribeCount appletSubscribeCount) throws BizException, PermissionException {
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
appletSubscribeCountBiz.update(appletSubscribeCount);
return new ResponseDto<>();
}
@ApiOperation("删除")
@GetMapping("deleteById")
public ResponseDto<?> deleteById(@CookieValue("userInfo") String userInfo,
@RequestParam Long id) throws BizException, PermissionException {
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
if (null == id) {
throw BizException.PARAM_DELETION;
}
appletSubscribeCountBiz.deleteById(id);
return new ResponseDto<>();
}
@ApiOperation("软删除")
@GetMapping("softDeleteById")
public ResponseDto<?> softDeleteById(@CookieValue("userInfo") String userInfo,
@RequestParam Long id) throws BizException, PermissionException {
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
if (null == id) {
throw BizException.PARAM_DELETION;
}
appletSubscribeCountBiz.softDeleteById(id);
return new ResponseDto<>();
}
@ApiOperation("通过用户id查询单条数据")
@GetMapping("getByUserId")
public ResponseDto<?> getByUserId(@CookieValue("userInfo") String userInfo,
@RequestParam(value = "recordType", required = false) Integer recordType) throws BizException, PermissionException {
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
AppletSubscribeCount byUserId = appletSubscribeCountBiz.getByUserId(wechatUserId, recordType);
return new ResponseDto<>(null == byUserId ? 0L : byUserId.getValidCount());
}
@ApiOperation("清零用户次数")
@GetMapping("clearSubsribeCount")
public ResponseDto<?> clearSubscribeCount(@CookieValue("userInfo") String userInfo,
@RequestParam(value = "recordType", required = false) Integer recordType) throws BizException, PermissionException {
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
appletSubscribeCountBiz.clearSubscribeCount(wechatUserId, recordType);
return new ResponseDto<>();
}
}
\ No newline at end of file
package com.pcloud.book.applet.facade;
import com.pcloud.book.applet.biz.AppletSubscribeRecordBiz;
import com.pcloud.book.applet.entity.AppletSubscribeRecord;
import com.pcloud.book.applet.enums.SubscribeCountTypeEnum;
import com.pcloud.book.applet.enums.SubscribeRecordTypeEnum;
import com.pcloud.common.dto.ResponseDto;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.permission.PermissionException;
import com.pcloud.common.utils.cookie.Cookie;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
* (AppletSubscribeRecord)表控制层
*
* @author wubo
* @since 2021-08-03 09:37:01
*/
@RestController("appletSubscribeRecordFacade")
@RequestMapping("appletSubscribeRecord")
public class AppletSubscribeRecordFacade {
@Autowired
private AppletSubscribeRecordBiz appletSubscribeRecordBiz;
@ApiOperation("通过主键查询单条数据")
@GetMapping("getById")
public ResponseDto<?> getById(@CookieValue("userInfo") String userInfo,
@RequestParam Long id) throws BizException, PermissionException {
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
return new ResponseDto<>(appletSubscribeRecordBiz.getById(id));
}
@ApiOperation("分页查询")
@GetMapping("getList")
public ResponseDto<?> getList(@CookieValue("userInfo") String userInfo,
@RequestParam(value = "currentPage", defaultValue = "0") Integer currentPage,
@RequestParam(value = "numPerPage", defaultValue = "10") Integer numPerPage)
throws BizException, PermissionException {
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
return new ResponseDto<>(appletSubscribeRecordBiz.getList(currentPage, numPerPage));
}
@ApiOperation("新增")
@PostMapping("insert")
public ResponseDto<?> insert(@CookieValue("userInfo") String userInfo,
@RequestBody AppletSubscribeRecord appletSubscribeRecord)
throws BizException, PermissionException {
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
appletSubscribeRecord.setWechatUserId(wechatUserId);
appletSubscribeRecord.setCountType(SubscribeCountTypeEnum.ADD_SUBSCRIBE.value);
return new ResponseDto<>(appletSubscribeRecordBiz.insert(appletSubscribeRecord));
}
@ApiOperation("更新")
@PostMapping("update")
public ResponseDto<?> update(@CookieValue("userInfo") String userInfo,
@RequestBody AppletSubscribeRecord appletSubscribeRecord) throws BizException, PermissionException {
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
appletSubscribeRecordBiz.update(appletSubscribeRecord);
return new ResponseDto<>();
}
@ApiOperation("删除")
@GetMapping("deleteById")
public ResponseDto<?> deleteById(@CookieValue("userInfo") String userInfo,
@RequestParam Long id) throws BizException, PermissionException {
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
if (null == id) {
throw BizException.PARAM_DELETION;
}
appletSubscribeRecordBiz.deleteById(id);
return new ResponseDto<>();
}
@ApiOperation("软删除")
@GetMapping("softDeleteById")
public ResponseDto<?> softDeleteById(@CookieValue("userInfo") String userInfo,
@RequestParam Long id) throws BizException, PermissionException {
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
if (null == id) {
throw BizException.PARAM_DELETION;
}
appletSubscribeRecordBiz.softDeleteById(id);
return new ResponseDto<>();
}
}
\ No newline at end of file
......@@ -75,6 +75,17 @@ public class ServeCollectFacade {
return new ResponseDto<>(serveCollectBiz.insert(serveCollect));
}
@ApiOperation("取消收藏")
@PostMapping("cancel")
public ResponseDto<?> cancel(@CookieValue("userInfo") String userInfo, @RequestBody ServeCollect serveCollect)
throws BizException, PermissionException {
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
serveCollect.setWechatUserId(wechatUserId);
serveCollectBiz.cancel(serveCollect);
return new ResponseDto<>();
}
@ApiOperation("更新")
@PostMapping("update")
public ResponseDto<?> update(@CookieValue("userInfo") String userInfo, @RequestBody ServeCollect serveCollect) throws BizException, PermissionException {
......@@ -158,4 +169,13 @@ public class ServeCollectFacade {
serveCollectBiz.processingData2TypeCode();
return new ResponseDto<>();
}
@ApiOperation("查询应用作品收藏状态")
@GetMapping("getCollectState")
public ResponseDto<?> getCollectState(@CookieValue("userInfo") String userInfo,
@RequestParam("serverId") Long serverId,
@RequestParam("serveType") Integer serveType) {
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
return new ResponseDto<>(serveCollectBiz.getCollectState(wechatUserId, serverId, serveType));
}
}
\ No newline at end of file
......@@ -8,6 +8,7 @@ import com.pcloud.book.applet.biz.AppletNewsBiz;
import com.pcloud.book.applet.biz.AppletRecordBiz;
import com.pcloud.book.applet.biz.AppletRecordStatisBiz;
import com.pcloud.book.applet.biz.AppletRecordAggrStatisBiz;
import com.pcloud.book.applet.biz.AppletSubscribeRecordBiz;
import com.pcloud.book.applet.biz.AppletThirdResourcesStaticBiz;
import com.pcloud.book.applet.biz.AppletUserBookcaseBiz;
import com.pcloud.book.applet.biz.ReadBookRecordBiz;
......@@ -22,7 +23,9 @@ import com.pcloud.book.applet.dto.AppletThirdResourcesDTO;
import com.pcloud.book.applet.dto.BaseTempletClassifyDTO;
import com.pcloud.book.applet.dto.PcloudGroupActivityDTO;
import com.pcloud.book.applet.dto.ServeCollectDTO;
import com.pcloud.book.applet.entity.AppletSubscribeRecord;
import com.pcloud.book.applet.entity.ServeCollect;
import com.pcloud.book.applet.enums.SubscribeCountTypeEnum;
import com.pcloud.book.applet.service.AppletService;
import com.pcloud.book.book.dto.BookDto;
import com.pcloud.book.group.biz.ResourcePageBiz;
......@@ -94,6 +97,8 @@ public class AppletServiceImpl implements AppletService {
private AppletUserBookcaseBiz appletUserBookcaseBiz;
@Autowired
private ResourcePageBiz resourcePageBiz;
@Autowired
private AppletSubscribeRecordBiz subscribeRecordBiz;
@Override
......@@ -278,4 +283,15 @@ public class AppletServiceImpl implements AppletService {
@RequestParam("officialAccountsId") Long officialAccountsId) {
return ResponseHandleUtil.toResponse(appletUserBookcaseBiz.getLatest10Books4Clock(wechatUserId, officialAccountsId));
}
@Override
@GetMapping({"subAppletSubscribeCount"})
public void subAppletSubscribeCount(@RequestParam("wechatUserId") Long wechatUserId,
@RequestParam("recordType") Integer recordType) {
AppletSubscribeRecord record = new AppletSubscribeRecord();
record.setWechatUserId(wechatUserId);
record.setRecordType(recordType);
record.setCountType(SubscribeCountTypeEnum.SUB_SUBSCRIBE.value);
subscribeRecordBiz.insert(record);
}
}
......@@ -459,4 +459,8 @@ public interface BookAdviserBiz {
* @return
*/
Integer getBookPhoneAuth(Long sceneId, Long bookId, Long adviserId, Long channelId);
void updateBookWechatAuth(Long bookId, Long adviserId, Long channelId, Integer isWechatAuth);
Integer getBookWechatAuth(Long sceneId, Long bookId, Long adviserId, Long channelId);
}
......@@ -804,4 +804,6 @@ public interface BookBiz {
* * @param null
*/
PageBean listAdviserBook(AviserBookInfoParam aviserBookInfoParam);
void exportListPage4Agent(Map<String, Object> paramMap, Long agentId, Long partyId, String systemCode);
}
package com.pcloud.book.book.biz;
import com.pcloud.book.book.entity.BookLabel;
import com.pcloud.book.book.entity.BookLabelTrim;
import com.pcloud.book.book.entity.BookLabelTrimRelate;
import com.pcloud.book.book.vo.BookLabelVO;
import com.pcloud.common.page.PageBeanNew;
......@@ -72,4 +74,37 @@ public interface BookLabelBiz {
* @return
*/
List<BookLabel> getBookLabelsByType(Integer labelType);
/**
* 添加书刊新标签
* @author:zhuyajie
* @date:2021/8/5 16:47
* * @param null
*/
void addBookNewLabel(List<Long> bookIds);
/**
* 查标签
* @author:zhuyajie
* @date:2021/7/27 14:44
* * @param null
*/
Map<Long, BookLabelTrimRelate> mapBookTrimLabel(List<Long> bookIds);
/**
* 整理后的标签
* @author:zhuyajie
* @date:2021/7/27 15:46
* * @param null
*/
List<BookLabelTrim> getBookLabelTrimList(Integer type);
/**
* 更新昨日修改过的书刊的标签
* @author:zhuyajie
* @date:2021/8/5 16:53
* * @param null
*/
void updateYesterdayBookNewLabel();
}
......@@ -130,6 +130,7 @@ import com.pcloud.resourcecenter.product.dto.ProductLabelDto;
import com.pcloud.resourcecenter.product.dto.ProductTypeDto;
import com.pcloud.usercenter.party.adviser.dto.AdviserBaseInfoDto;
import com.pcloud.usercenter.user.entity.UserLogin;
import com.pcloud.wechatgroup.group.dto.BookGroupScanStatisticsDTO;
import com.pcloud.wechatgroup.group.dto.GroupScanUserStatsDTO;
import com.pcloud.wechatgroup.group.dto.GroupUserCountDTO;
import org.apache.commons.collections.MapUtils;
......@@ -2018,9 +2019,27 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
});
// 分析引擎获取非社群书统计结果
List<BookBrowseAndScanStatsDTO> browseAndScanStats = browseRecordConsr.getBookBrowseAndScanStats(dtos);
Integer maxCount = 100;
Integer pageCount = 0;
List<GroupScanUserStatsDTO> bookGroupScanStats = new ArrayList<>();
// 微信群获取社群书统计结果
List<GroupScanUserStatsDTO> bookGroupScanStats = wechatGroupConsr.getBookGroupScanStats(adviserIds);
if (adviserIds.size() > maxCount) {
//超过500, 则分批查询
while (true) {
Integer endCount = maxCount * (pageCount + 1);
List<Long> subList = adviserIds.subList(pageCount * maxCount, adviserIds.size() < endCount ? adviserIds.size() : endCount);
List<GroupScanUserStatsDTO> subBookGroupScanStats = wechatGroupConsr.getBookGroupScanStats(subList);
if (!ListUtils.isEmpty(subBookGroupScanStats)) {
bookGroupScanStats.addAll(subBookGroupScanStats);
}
if (subList.size() < maxCount){
break;
}
pageCount++;
}
} else {
bookGroupScanStats = wechatGroupConsr.getBookGroupScanStats(adviserIds);
}
// 查询印册量
List<ERPPublishNumDTO> finalPublishNumDto = new ArrayList<>();
......@@ -2510,7 +2529,7 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
@Override
public List<BookServeDTO> getAnswerServesByBook(Long bookId, Long adviserId, Long channelId) {
List<BookServeDTO> answerList = new ArrayList<>();
List<BookServeDTO> bookServeVOS = bookGroupBiz.getBookAndBookGroupServeIds(adviserId, bookId, channelId);
List<BookServeDTO> bookServeVOS = resourcePageBiz.getBookAllServeIdsIncludeUrl(adviserId, bookId, channelId);
bookGroupBiz.fillBookServe(bookServeVOS);
bookGroupBiz.removeCanNotBuy(bookServeVOS);
if (!ListUtils.isEmpty(bookServeVOS)) {
......@@ -3296,4 +3315,37 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
return bookPhoneAuth;
}
@Override
@Transactional(rollbackFor = Exception.class)
public void updateBookWechatAuth(Long bookId, Long adviserId, Long channelId, Integer isWechatAuth) {
if (null == bookId || null == adviserId || null == channelId || null == isWechatAuth) {
throw new BizException(BizException.PARAM_IS_NULL.getCode(), "参数为空请确认");
}
bookAdviserDao.updateBookWechatAuth(bookId, adviserId, channelId, isWechatAuth);
}
@Override
public Integer getBookWechatAuth(Long sceneId, Long bookId, Long adviserId, Long channelId) {
Integer isWechatAuth = YesOrNoEnums.YES.getValue();
if(null == sceneId && null == bookId && null == adviserId && null == channelId) {
return isWechatAuth;
}
if (null != bookId) {
isWechatAuth = bookAdviserDao.getBookWechatAuth(bookId, adviserId, channelId);
} else if (null != sceneId) {
//根据sceneId获取二维码信息
Map<Long, QrcodeSceneDto> qrcodeSceneDtoMap = qrcodeSceneConsr.listBaseInfoByIds(Lists.newArrayList(sceneId));
if (MapUtils.isEmpty(qrcodeSceneDtoMap) || null == qrcodeSceneDtoMap.get(sceneId)) {
return isWechatAuth;
}
QrcodeSceneDto qrcodeSceneDto = qrcodeSceneDtoMap.get(sceneId);
if (null == qrcodeSceneDto || null == qrcodeSceneDto.getAdviserBookId()) {
return isWechatAuth;
}
isWechatAuth = bookAdviserDao.getBookPhoneAuth(qrcodeSceneDto.getAdviserBookId(), qrcodeSceneDto.getCreatedByUserLogin(),qrcodeSceneDto.getChannelPartyId());
}
return isWechatAuth;
}
}
......@@ -63,6 +63,7 @@ import com.pcloud.book.copyright.vo.BookAuthInfoVO;
import com.pcloud.book.es.biz.ESBookAndAdviserBiz;
import com.pcloud.book.es.entity.ESBookAndAdviser;
import com.pcloud.book.group.biz.BookGroupBiz;
import com.pcloud.book.group.biz.ResourcePageBiz;
import com.pcloud.book.group.dao.BookAppletSceneDao;
import com.pcloud.book.group.dao.BookGroupDao;
import com.pcloud.book.group.dao.BookGroupServeDao;
......@@ -197,9 +198,6 @@ public class BookBizImpl implements BookBiz {
private BookGroupBiz bookGroupBiz;
@Autowired
private BookLabelDao bookLabelDao;
@Autowired
private ExportService exportService;
@Autowired
private ExportConsr exportConsr;
@Autowired
......@@ -216,6 +214,8 @@ public class BookBizImpl implements BookBiz {
@Autowired
private BookAdviserDao bookAdviserDao;
@Autowired
private ResourcePageBiz resourcePageBiz;
@Autowired
......@@ -1308,6 +1308,49 @@ public class BookBizImpl implements BookBiz {
return pageBean;
}
@Override
public void exportListPage4Agent(Map<String, Object> paramMap, Long agentId, Long partyId, String systemCode) {
LOGGER.info("书刊列表-出版端,<START>.[paramMap]=" + paramMap + ",agentId" + agentId);
List<Long> adviserIds = adviserConsr.getIdsByNameAndAgentId(agentId, (String) paramMap.get("bookName"));
List<Long> agent4AdviserIds = adviserConsr.getIdsByNameAndAgentId(agentId, null);
paramMap.put("adviserIds", adviserIds);
paramMap.put("agent4AdviserIds", agent4AdviserIds);
if (ListUtils.isEmpty(agent4AdviserIds)) {
throw new BookBizException(BookBizException.PARAM_IS_NULL, "列表为空!");
}
List<BookDto> list = bookDao.listPage4Agent(paramMap);
if(CollUtil.isEmpty(list)){
throw new BookBizException(BookBizException.PARAM_IS_NULL, "列表为空!");
}
if(list.size()>1500){
throw new ExportException(ExportException.OPERATE_ERROR, "数量超过限制,请添加条件再导出!");
}
ThreadPoolUtils.EXPORT_THREAD_POOL.execute(() -> {
try{
List<Object[]> dataList = new ArrayList<>();
for (int i = 0, size = list.size(); i < size; i++) {
BookDto bookDto = list.get(i);
Object[] obj = new Object[5];
obj[0] = i + 1;
obj[1] = bookDto.getBookName();
obj[2] = bookDto.getIsbn();
obj[3] = bookDto.getBookId();
obj[4] = null!=bookDto.getCreatedDate() ? DateUtils.getStrFormTime("yyyy-MM-dd HH:mm:ss", bookDto.getCreatedDate()) : null;
dataList.add(obj);
}
Date date = new Date();
String[] rowsName = {"序号", "书刊名称", "书刊号", "书刊ID", "创建时间"};
String fileName = "书刊管理书刊列表--" + DateUtils.getStrFormTime("yyyyMMdd", date);
String fileUrl = exportConsr.exportExcel(fileName, rowsName, dataList);
String letterType = "book_download";
String content = String.format("{\"commitTime\":\"%s\",\"type\":\"%s\"}", DateUtils.formatDate(date), fileName);
messageConsr.sendLetter(partyId, partyId, content, systemCode, letterType, fileUrl, fileName);
}catch (Exception e) {
LOGGER.error("exportListPage4Agent+++paramMap=" + paramMap.toString() + "systemCode=" + systemCode + "partyId=" + partyId);
}
});
}
/**
* 获取应用关联图书
*/
......@@ -3634,17 +3677,9 @@ public class BookBizImpl implements BookBiz {
@Override
public PageBeanNew<BookDto> getESAdviserBooks4Answer(Long wechatUserId, BookSearchParamVO bookSearchParamVO) {
Long graLabelId = bookSearchParamVO.getGraLabelId();
Long subLabelId = bookSearchParamVO.getSubLabelId();
Long verLabelId = bookSearchParamVO.getVerLabelId();
Integer currentPage = bookSearchParamVO.getCurrentPage() == null?0:bookSearchParamVO.getCurrentPage();
Integer numPerPage = bookSearchParamVO.getNumPerPage() == null?10:bookSearchParamVO.getNumPerPage();
List<Long> templetIds = new ArrayList<>();
if (null != graLabelId || null != subLabelId || null != verLabelId){
templetIds = Arrays.asList(RightsSettingConstant.K12_TEMPLET_ID_NEW);
}
Page<ESBookAndAdviser> esPage = esBookAndAdviserBiz.getESAdviserBooks4Answer(bookSearchParamVO.getGrayStatus(), bookSearchParamVO.getKeyword(),
graLabelId, subLabelId, verLabelId, currentPage, numPerPage, templetIds);
Page<ESBookAndAdviser> esPage = esBookAndAdviserBiz.getESAdviserBooks4Answer(bookSearchParamVO);
List<ESBookAndAdviser> esBookAndAdvisers = esPage.getContent();
if (ListUtils.isEmpty(esBookAndAdvisers)) {
return new PageBeanNew<>(currentPage, numPerPage, (int) esPage.getTotalElements(),new ArrayList<>());
......@@ -3654,7 +3689,7 @@ public class BookBizImpl implements BookBiz {
for (BookDto bookDto : bookDtos) {
bookDto.setHasAnswer(false);
//标记是否有答案
List<BookServeDTO> bookServeVOS = bookGroupBiz.getBookAndBookGroupServeIds(bookDto.getAdviserId(), bookDto.getBookId(), bookDto.getChannelId());
List<BookServeDTO> bookServeVOS = resourcePageBiz.getBookAllServeIdsIncludeUrl(bookDto.getAdviserId(), bookDto.getBookId(), bookDto.getChannelId());
bookGroupBiz.fillBookServe(bookServeVOS);
bookGroupBiz.removeCanNotBuy(bookServeVOS);
if (!ListUtils.isEmpty(bookServeVOS)) {
......@@ -3677,7 +3712,6 @@ public class BookBizImpl implements BookBiz {
}
bookDto.setSubscribeState(subscribeState);
}
bookSet.setLabelNames(bookDtos);
PageBeanNew<BookDto> page = new PageBeanNew<>(currentPage, numPerPage, (int) esPage.getTotalElements(), bookDtos);
return page;
}
......
package com.pcloud.book.book.biz.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.book.biz.BookLabelBiz;
import com.pcloud.book.book.constant.BookConstant;
import com.pcloud.book.book.dao.BookAdviserDao;
import com.pcloud.book.book.dao.BookDao;
import com.pcloud.book.book.dao.BookLabelDao;
import com.pcloud.book.book.dao.BookLabelTrimDao;
import com.pcloud.book.book.dao.BookLabelTrimRelateDao;
import com.pcloud.book.book.dto.BookDto;
import com.pcloud.book.book.entity.BookLabel;
import com.pcloud.book.book.entity.BookLabelTrim;
import com.pcloud.book.book.entity.BookLabelTrimRelate;
import com.pcloud.book.book.enums.BookLabelAuditState;
import com.pcloud.book.book.vo.BookLabelVO;
import com.pcloud.book.consumer.user.AdviserConsr;
import com.pcloud.book.es.biz.ESBookAndAdviserBiz;
import com.pcloud.book.util.properties.BookProps;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.core.constant.SystemCode;
import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.page.PageParam;
import com.pcloud.common.utils.DateUtils;
import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.cache.redis.JedisClusterUtils;
import com.pcloud.common.utils.string.StringUtil;
......@@ -25,21 +38,36 @@ import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import cn.hutool.http.HttpUtil;
import lombok.extern.slf4j.Slf4j;
import static com.pcloud.book.book.constant.BookConstant.BOOK_CACHE_SECOUND;
@Component("bookLabelBiz")
@Slf4j
public class BookLabelBizImpl implements BookLabelBiz {
@Autowired
private BookLabelDao bookLabelDao;
@Autowired
private AdviserConsr adviserConsr;
@Autowired
private BookLabelTrimRelateDao bookLabelTrimRelateDao;
@Autowired
private BookDao bookDao;
@Autowired
private BookLabelTrimDao bookLabelTrimDao;
@Autowired
private ESBookAndAdviserBiz esBookAndAdviserBiz;
@Autowired
private BookAdviserDao bookAdviserDao;
@Override
public void applyBookLabel(BookLabel bookLabel, String systemCode) {
......@@ -191,4 +219,101 @@ public class BookLabelBizImpl implements BookLabelBiz {
}
return ListUtils.isEmpty(bookLabels) ? new ArrayList<>() : bookLabels;
}
/**
* 整理后的标签查询,只支持生产环境
* @author:zhuyajie
* @date:2021/8/5 16:43
* * @param null
*/
private Map<String, Object> getLabel(Long bookId, String bookName) {
if (!"pro".equals(BookProps.getSystemEnv())) {
return new HashMap<>();
}
Map<String, Object> labelMap = new HashMap<>();
try {
JSONObject dataJsonObj = new JSONObject();
dataJsonObj.put(bookId.toString(), bookName);
JSONObject jsonObject = new JSONObject();
jsonObject.put("data", dataJsonObj);
jsonObject.put("type", "book");
String response = HttpUtil.post("http://192.168.92.168:8000/getLabels", jsonObject.toString());
// 解析结果
JSONObject object = JSONObject.parseObject(response);
log.info("标签解析结果==" + object.toString());
if (!"success".equals(object.getString("info")) || StringUtil.isEmpty(object.getString("data"))) {
return null;
}
Map<String, Object> stringObjectMap = JSON.parseObject(object.getString("data"), new TypeReference<Map<String, Object>>() {
});
if (null == stringObjectMap.get(bookId.toString())) {
return null;
}
labelMap = (Map<String, Object>) stringObjectMap.get(bookId.toString());
} catch (Exception e) {
log.error("调用查标签失败" + e.getMessage(), e);
}
return labelMap;
}
@Override
public void addBookNewLabel(List<Long> bookIds) {
if(ListUtils.isEmpty(bookIds)) {
return;
}
if (!"pro".equals(BookProps.getSystemEnv())) {
//只支持查生产环境
return;
}
Map<Long,BookDto> bookDtoMap = bookDao.getMapByBookIds(bookIds);
if (MapUtils.isEmpty(bookDtoMap)) {
return;
}
//已有标签
Map<Long,BookLabelTrimRelate> labelTrimRelateMap = bookLabelTrimRelateDao.mapBookTrimLabel(bookIds);
for (BookDto bookDto : bookDtoMap.values()) {
Map<String, Object> labelMap = this.getLabel(bookDto.getBookId(), bookDto.getBookName());
BookLabelTrimRelate labelTrimRelate = new BookLabelTrimRelate();
labelTrimRelate.setBookId(bookDto.getBookId());
labelTrimRelate.setLabel1((String) labelMap.get("label1"));
labelTrimRelate.setLabel2((String) labelMap.get("label2"));
labelTrimRelate.setLabel3((String) labelMap.get("label3"));
labelTrimRelate.setLabel4((String) labelMap.get("label4"));
if (!MapUtils.isEmpty(labelTrimRelateMap) && labelTrimRelateMap.containsKey(bookDto.getBookId())) {
//修改
BookLabelTrimRelate relate = labelTrimRelateMap.get(bookDto.getBookId());
labelTrimRelate.setId(relate.getId());
bookLabelTrimRelateDao.update(labelTrimRelate);
} else {
//新增
bookLabelTrimRelateDao.insert(labelTrimRelate);
}
}
esBookAndAdviserBiz.updateBookAndAdviserToES(bookIds);
}
@Override
public Map<Long, BookLabelTrimRelate> mapBookTrimLabel(List<Long> bookIds) {
if (ListUtils.isEmpty(bookIds)) {
return new HashMap<>();
}
return bookLabelTrimRelateDao.mapBookTrimLabel(bookIds);
}
@Override
public List<BookLabelTrim> getBookLabelTrimList(Integer type) {
return bookLabelTrimDao.getBookLabelTrimList(type);
}
@Override
public void updateYesterdayBookNewLabel() {
Date yesterday = DateUtils.addDay(new Date(),-1);
String startTime = DateUtils.formatDate(DateUtils.getDayStart(yesterday), DateUtils.DATE_FORMAT_DATETIME);
String endTime = DateUtils.formatDate(DateUtils.getDayEnd(yesterday), DateUtils.DATE_FORMAT_DATETIME);
List<Long> bookIds = bookAdviserDao.getYesterdayUpdateBookIds(startTime, endTime);
if (!ListUtils.isEmpty(bookIds)) {
this.addBookNewLabel(bookIds);
}
}
}
......@@ -335,4 +335,10 @@ public interface BookAdviserDao extends BaseDao<BookAdviser> {
void updateBookPhoneAuth(Long bookId, Long adviserId, Long channelId, Integer bookPhoneAuth);
Integer getBookPhoneAuth(Long bookId, Long adviserId, Long channelId);
void updateBookWechatAuth(Long bookId, Long adviserId, Long channelId, Integer isWechatAuth);
Integer getBookWechatAuth(Long bookId, Long adviserId, Long channelId);
List<Long> getYesterdayUpdateBookIds(String startTime, String endTime);
}
......@@ -384,4 +384,6 @@ public interface BookDao extends BaseDao<Book> {
Integer getBookCountByAdviserId(Long adviserId);
boolean checkIsBookId(Long isbnNumber);
List<BookDto> listPage4Agent(Map<String, Object> paramMap);
}
package com.pcloud.book.book.dao;
import com.pcloud.book.book.entity.BookLabelTrim;
import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
/**
* 书刊标签(整理后)(BookLabelTrim)表数据库访问层
*
* @author makejava
* @since 2021-07-27 11:17:51
*/
public interface BookLabelTrimDao extends BaseDao<BookLabelTrim>{
List<BookLabelTrim> getBookLabelTrimList(Integer type);
}
\ No newline at end of file
package com.pcloud.book.book.dao;
import com.pcloud.book.book.entity.BookLabelTrimRelate;
import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
import java.util.Map;
/**
* 书刊对应整理后的标签(BookLabelTrimRelate)表数据库访问层
*
* @author makejava
* @since 2021-07-27 11:18:24
*/
public interface BookLabelTrimRelateDao extends BaseDao<BookLabelTrimRelate> {
/**
* 批量查标签
* @author:zhuyajie
* @date:2021/7/27 14:46
* * @param null
*/
Map<Long,BookLabelTrimRelate> mapBookTrimLabel(List<Long> bookIds);
}
\ No newline at end of file
......@@ -466,4 +466,31 @@ public class BookAdviserDaoImpl extends BaseDaoImpl<BookAdviser> implements Book
paramMap.put("adviserId", adviserId);
return getSessionTemplate().selectOne(getStatement("getBookPhoneAuth"), paramMap);
}
@Override
public void updateBookWechatAuth(Long bookId, Long adviserId, Long channelId, Integer isWechatAuth) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("bookId",bookId);
paramMap.put("channelId", channelId);
paramMap.put("adviserId", adviserId);
paramMap.put("isWechatAuth", isWechatAuth);
getSessionTemplate().update(getStatement("updateBookWechatAuth"), paramMap);
}
@Override
public Integer getBookWechatAuth(Long bookId, Long adviserId, Long channelId) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("bookId",bookId);
paramMap.put("channelId", channelId);
paramMap.put("adviserId", adviserId);
return getSessionTemplate().selectOne(getStatement("getBookWechatAuth"), paramMap);
}
@Override
public List<Long> getYesterdayUpdateBookIds(String startTime, String endTime) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("startTime",startTime);
paramMap.put("endTime", endTime);
return getSessionTemplate().selectList(getStatement("getYesterdayUpdateBookIds"), paramMap);
}
}
......@@ -465,4 +465,9 @@ public class BookDaoImpl extends BaseDaoImpl<Book> implements BookDao {
public boolean checkIsBookId(Long isbnNumber) {
return getSessionTemplate().selectOne(getStatement("checkIsBookId"), isbnNumber);
}
@Override
public List<BookDto> listPage4Agent(Map<String, Object> paramMap) {
return getSessionTemplate().selectList(getStatement("listPage4Agent"), paramMap);
}
}
package com.pcloud.book.book.dao.impl;
import com.pcloud.book.book.dao.BookLabelTrimDao;
import com.pcloud.book.book.entity.BookLabelTrim;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @ClassName com.pcloud.book.book.dao.impl.BookLabelTrimDaoImpl
* @Author zhuyajie
* @Description 新标签
* @Date 2021/7/27 11:26
* @Version 1.0
**/
@Component
public class BookLabelTrimDaoImpl extends BaseDaoImpl<BookLabelTrim> implements BookLabelTrimDao {
@Override
public List<BookLabelTrim> getBookLabelTrimList(Integer type) {
Map<String, Object> map = new HashMap<>();
map.put("type", type);
return getSessionTemplate().selectList(getStatement("getBookLabelTrimList"), map);
}
}
package com.pcloud.book.book.dao.impl;
import com.pcloud.book.book.dao.BookLabelTrimRelateDao;
import com.pcloud.book.book.entity.BookLabelTrimRelate;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @ClassName com.pcloud.book.book.dao.impl.BookLabelTrimRelateDaoImpl
* @Author zhuyajie
* @Description 新标签
* @Date 2021/7/27 11:27
* @Version 1.0
**/
@Component
public class BookLabelTrimRelateDaoImpl extends BaseDaoImpl<BookLabelTrimRelate> implements BookLabelTrimRelateDao {
@Override
public Map<Long, BookLabelTrimRelate> mapBookTrimLabel(List<Long> bookIds) {
Map<String, Object> map = new HashMap<>();
map.put("bookIds", bookIds);
return getSessionTemplate().selectMap(getStatement("mapBookTrimLabel"), map ,"bookId");
}
}
package com.pcloud.book.book.entity;
import com.pcloud.common.entity.BaseEntity;
import lombok.Data;
/**
* 书刊标签(整理后)(BookLabelTrim)实体类
*
* @author makejava
* @since 2021-07-27 11:17:51
*/
@Data
public class BookLabelTrim extends BaseEntity {
private static final long serialVersionUID = 155647419272841884L;
/**
* 主键
*/
private Long id;
/**
* 标签名称
*/
private String name;
/**
* 类型:1科目,2年级,3版本,4上下册
*/
private Integer type;
}
\ No newline at end of file
package com.pcloud.book.book.entity;
import com.pcloud.common.entity.BaseEntity;
import lombok.Data;
/**
* 书刊对应整理后的标签(BookLabelTrimRelate)实体类
*
* @author makejava
* @since 2021-07-27 11:18:24
*/
@Data
public class BookLabelTrimRelate extends BaseEntity {
private static final long serialVersionUID = -59204152090408165L;
/**
* 主键
*/
private Long id;
/**
* 书刊id
*/
private Long bookId;
/**
* 科目
*/
private String label1;
/**
* 年级
*/
private String label2;
/**
* 版本
*/
private String label3;
/**
* 上下册
*/
private String label4;
}
\ No newline at end of file
......@@ -422,7 +422,9 @@ public interface BookFacade {
@RequestParam(value = "secondTempletId", required = false) Long secondTempletId,
@RequestParam(value = "thirdTempletId", required = false) Long thirdTempletId,
@RequestParam(value = "isPrint", required = false) Boolean isPrint,
@RequestParam(value = "minimumSupport", required = false) Integer minimumSupport)
@RequestParam(value = "minimumSupport", required = false) Integer minimumSupport,
@RequestParam(value = "startTime", required = false) String startTime,
@RequestParam(value = "endTime", required = false) String endTime)
throws BizException, PermissionException, JsonParseException;
/**
......
......@@ -468,4 +468,29 @@ public class BookAdviserFacadeImpl implements BookAdviserFacade {
Cookie.getUserInfo(userInfo);
return new ResponseDto<Integer>(bookAdviserBiz.getBookPhoneAuth(sceneId,bookId, adviserId, channelId));
}
/**
* 设置书刊二维码进入是否需要授权用户信息
*/
@RequestMapping(value = "updateBookWechatAuth", method = RequestMethod.GET)
public ResponseDto<?> updateBookWechatAuth(@RequestHeader("token") String token,
@RequestParam(value = "bookId") Long bookId,
@RequestParam(value = "channelId") Long channelId,
@RequestParam(value = "isWechatAuth") Integer isWechatAuth) throws PermissionException {
Long adviserId = (Long)SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
bookAdviserBiz.updateBookWechatAuth(bookId, adviserId, channelId, isWechatAuth);
return new ResponseDto<>();
}
/**
* 获取书刊二维码进入是否需要授权用户信息
*/
@RequestMapping(value = "getBookWechatAuth", method = RequestMethod.GET)
public ResponseDto<?> getBookWechatAuth(
@RequestParam(value = "sceneId",required = false) Long sceneId,
@RequestParam(value = "bookId",required = false) Long bookId,
@RequestParam(value = "adviserId",required = false) Long adviserId,
@RequestParam(value = "channelId", required = false) Long channelId) throws PermissionException {
return new ResponseDto<Integer>(bookAdviserBiz.getBookWechatAuth(sceneId,bookId, adviserId, channelId));
}
}
......@@ -561,7 +561,9 @@ public class BookFacadeImpl implements BookFacade {
@RequestParam(value = "secondTempletId", required = false) Long secondTempletId,
@RequestParam(value = "thirdTempletId", required = false) Long thirdTempletId,
@RequestParam(value = "isPrint", required = false) Boolean isPrint,
@RequestParam(value = "minimumSupport", required = false) Integer minimumSupport)
@RequestParam(value = "minimumSupport", required = false) Integer minimumSupport,
@RequestParam(value = "startTime", required = false) String startTime,
@RequestParam(value = "endTime", required = false) String endTime)
throws BizException, PermissionException {
Long agentId = (Long) SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
if (currentPage < 0 || numPerPage < 0) {
......@@ -586,11 +588,66 @@ public class BookFacadeImpl implements BookFacade {
paramMap.put("thirdTempletIds", Optional.ofNullable(paramMap.get("thirdTempletId")).map(Lists::newArrayList).orElse(Lists.newArrayList()));
paramMap.put("isPrint", isPrint);
paramMap.put("minimumSupport", minimumSupport);
paramMap.put("startTime", StringUtil.isBlank(startTime) ? null : startTime);
paramMap.put("endTime", StringUtil.isBlank(endTime) ? null : endTime);
return new ResponseDto<>(
bookBiz.listPage4Agent(new PageParam(currentPage, numPerPage), paramMap, agentId));
}
/**
* 书刊列表导出-出版端
*/
@RequestMapping(value = "exportListPage4Agent", method = RequestMethod.GET)
public ResponseDto<PageBean> exportListPage4Agent( @RequestHeader("token") String token,
@RequestParam(value = "bookName", required = false) String bookName,
@RequestParam(value = "channelId", required = false) Long channelId,
@RequestParam(value = "typeCode", required = false) String typeCode,
@RequestParam(value = "mainEditorName", required = false) String mainEditorName,
@RequestParam(value = "isFundSupport", required = false) Integer isFundSupport,
@RequestParam(value = "isbn", required = false) String isbn,
@RequestParam(value = "templetId", required = false) Long templetId,
@RequestParam(value = "secondTempletId", required = false) Long secondTempletId,
@RequestParam(value = "thirdTempletId", required = false) Long thirdTempletId,
@RequestParam(value = "isPrint", required = false) Boolean isPrint,
@RequestParam(value = "minimumSupport", required = false) Integer minimumSupport,
@RequestParam(value = "startTime", required = false) String startTime,
@RequestParam(value = "endTime", required = false) String endTime)
throws BizException, PermissionException {
Long agentId = (Long) SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
Map<String, Object> map = SessionUtil.getToken4Redis(token);
String isSystem = (String) map.get(SessionUtil.IS_SYSTEM);
Long partyId = (Long) map.get(SessionUtil.PARTY_ID);
if (IsSystem.NOT_SYSTEM.code.equals(isSystem)) {
partyId = (Long) map.get(SessionUtil.MEMBER_ID);
}
String systemCode = (String) SessionUtil.getVlaue(token, SessionUtil.SYSTEM_CODE);
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("bookName", bookName != null && "".equals(bookName.trim()) ? null : bookName);
if(!StringUtil.isEmpty(bookName)){
String [] nameList = bookName.trim().split("[\u00A0|\u3000|\u0020]");
paramMap.put("nameList", Lists.newArrayList(nameList));
}
paramMap.put("channelId", channelId);
paramMap.put("typeCode", typeCode != null && "".equals(typeCode.trim()) ? null : typeCode);
paramMap.put("mainEditorName",
mainEditorName != null && "".equals(mainEditorName.trim()) ? null : mainEditorName);
paramMap.put("isFundSupport", isFundSupport);
paramMap.put("isbn", isbn);
paramMap.put("templetId", templetId);
paramMap.put("secondTempletId", secondTempletId);
paramMap.put("secondTempletIds", Optional.ofNullable(paramMap.get("secondTempletId")).map(Lists::newArrayList).orElse(Lists.newArrayList()));
paramMap.put("thirdTempletId", thirdTempletId);
paramMap.put("thirdTempletIds", Optional.ofNullable(paramMap.get("thirdTempletId")).map(Lists::newArrayList).orElse(Lists.newArrayList()));
paramMap.put("isPrint", isPrint);
paramMap.put("minimumSupport", minimumSupport);
paramMap.put("startTime", StringUtil.isBlank(startTime) ? null : startTime);
paramMap.put("endTime", StringUtil.isBlank(endTime) ? null : endTime);
bookBiz.exportListPage4Agent(paramMap, agentId,partyId,systemCode);
return new ResponseDto<>();
}
/**
* 获取编辑书刊列表-(APP编辑)
*/
@Override
......
......@@ -140,4 +140,25 @@ public class BookLabelFacadeImpl {
return new ResponseDto<>(bookLabels);
}
@ApiOperation("添加书刊标签")
@PostMapping("addBookNewLabel")
public ResponseDto<?> addBookNewLabel(@RequestBody List<Long> bookIds) {
bookLabelBiz.addBookNewLabel(bookIds);
return new ResponseDto<>();
}
@ApiOperation("整理后的书刊标签")
@GetMapping("getBookLabelTrimList")
public ResponseDto<?> getBookLabelTrimList(
@RequestParam(value = "type", required = false) Integer type) {
return new ResponseDto<>(bookLabelBiz.getBookLabelTrimList(type));
}
@ApiOperation("更新昨日修改过的书刊的标签")
@GetMapping("updateYesterdayBookNewLabel")
public ResponseDto<?> updateYesterdayBookNewLabel() {
bookLabelBiz.updateYesterdayBookNewLabel();
return new ResponseDto<>();
}
}
......@@ -40,4 +40,16 @@ public class BookSearchParamVO {
private List<Long> choseBookIdList;
/**
* 科目
*/
private String label1;
/**
* 年级
*/
private String label2;
/**
* 版本
*/
private String label3;
}
......@@ -3,19 +3,33 @@
*/
package com.pcloud.book.consumer.message;
import com.pcloud.book.book.constant.BookConstant;
import com.pcloud.book.consumer.reader.ReaderConsr;
import com.pcloud.book.consumer.user.ChannelConsr;
import com.pcloud.channelcenter.wechat.entity.AccountSetting;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.core.biz.TemplateQueueBiz;
import com.pcloud.common.core.constant.SceneCode;
import com.pcloud.common.core.constant.SendType;
import com.pcloud.common.core.constant.WechatCode;
import com.pcloud.common.core.dto.AppletTemplateMessageDto;
import com.pcloud.common.core.dto.TemplateMessageDto;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.utils.ListUtils;
import com.pcloud.readercenter.common.utils.ReaderConstants;
import com.pcloud.readercenter.wechat.entity.WechatUserOfficialAccounts;
import org.apache.commons.collections.MapUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @描述:发送模板消息
......@@ -33,6 +47,12 @@ public class TemplateConsr {
@Autowired
private TemplateQueueBiz templateQueueBiz;
@Autowired
private ReaderConsr readerConsr;
@Value("${operate_official_id}")
private Long operateOfficalId;
@Autowired
private ChannelConsr channelConsr;
/**
* 发送模板消息topic(管理公众号)
......@@ -86,4 +106,45 @@ public class TemplateConsr {
LOGGER.error("【小程序模板消息(消)】发送小程序模板消息topic,<ERROR>.[sendAppletMessageQueue]:" + e.getMessage(), e);
}
}
public void sendTempletMessage4Project(String keyword1, String keyword2, Long wechatUserId, String pagepath) {
LOGGER.info("小睿宠物发送模板消息业务进度提醒keyword1:{},keyword2:{}, wechatUserId:{},pagepath:{},",
keyword1, keyword2,wechatUserId, pagepath);
Map<String, String> temParam = new HashMap<>();
temParam.put("first", "主人召回提醒");
temParam.put("keyword1", keyword1);
temParam.put("keyword2", keyword2);
temParam.put("remark", "点击查看详情");
List<Long> allUserIds = readerConsr.getAllUserIds(wechatUserId);
if (ListUtils.isEmpty(allUserIds)) {
return;
}
Map<Long, WechatUserOfficialAccounts> userOfficalAccountMap = readerConsr.getUserOfficalAccountMap(allUserIds);
if (MapUtils.isEmpty(userOfficalAccountMap)) {
return;
}
List<WechatUserOfficialAccounts> wechatUserOfficialAccounts = userOfficalAccountMap.values().stream().filter(e -> operateOfficalId.equals(e.getOfficialAccountsId())).collect(Collectors.toList());
if (ListUtils.isEmpty(wechatUserOfficialAccounts)) {
return;
}
//公众号用户id
wechatUserId = wechatUserOfficialAccounts.get(0).getWechatUserId();
// 组装参数对象
TemplateMessageDto templateMessageDto = new TemplateMessageDto();
templateMessageDto.setSceneCode(SceneCode.PROJECT_TASK_SCENE.value);
templateMessageDto.setAccountSettingId(operateOfficalId);
AccountSetting officialAccountsInfo = channelConsr.getAppInfo(ReaderConstants.MINI_OFFICIAL_ID);
templateMessageDto.setMiniprogramAppid(officialAccountsInfo.getDeveloperAppId());
templateMessageDto.setMiniprogramPagepath(pagepath);
templateMessageDto.setTemParam(temParam);
templateMessageDto.setSendType( SendType.SEND_BY_WECHAT.value);
templateMessageDto.setWechatUserId(wechatUserId);
templateMessageDto.setIsApp(false);
try {
templateQueueBiz.sendMessageQueue(templateMessageDto);
} catch (Exception e) {
LOGGER.error("【模板消息(消)】发送模板消息-业务进度提醒小睿宠物发送模板消息,<ERROR>.[sendMessageQueue]:" + e.getMessage(), e);
}
LOGGER.info("小小睿宠物发送模板消息业务进度提醒[END]");
}
}
......@@ -6,6 +6,7 @@ import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.channelcenter.base.exceptions.ChannelBizException;
import com.pcloud.readercenter.applet.entity.AppletQuestion;
import com.pcloud.readercenter.applet.service.AppletUserService;
import com.pcloud.readercenter.rmall.dto.RmallUserBookMoneyDTO;
import com.pcloud.readercenter.rmall.entity.RmallBookMoneyRecord;
import com.pcloud.readercenter.rmall.service.RmallBookMoneyRecordService;
import com.pcloud.readercenter.unionuser.service.RaysUnionUserService;
......@@ -467,6 +468,55 @@ public class ReaderConsr {
}
return list;
}
public RmallUserBookMoneyDTO getBookMoneyCount(Long wechatUserId) {
try {
return ResponseHandleUtil.parseResponse(rmallBookMoneyRecordService.getBookMoneyCount(wechatUserId), RmallUserBookMoneyDTO.class);
} catch (Exception e) {
LOGGER.error("调用rmallBookMoneyRecordService.getBookMoneyCount失败" +e.getMessage());
}
return null;
}
public List<Long> getWechatUserIdsByGradeIds(List<Long> userGradeLabelIds) {
LOGGER.info("根据年级标签获取小程序用户id");
List<Long> list = new ArrayList<>();
if (ListUtils.isEmpty(userGradeLabelIds)) {
return list;
}
try {
list = ResponseHandleUtil.parseList(userLabelService.getWechatUserIdsByGradeIds(userGradeLabelIds), Long.class);
} catch (Exception e) {
LOGGER.error("调用wechatUserService.getWechatUserIdsByGradeIds失败"+e.getMessage(), e);
}
return list;
}
public List<Long> getAllUserIds(Long wechatUserId) {
List<Long> allUserIds = new ArrayList<>();
try {
allUserIds = ResponseHandleUtil.parseList(raysUnionUserService.getAllUnionUser(wechatUserId), Long.class);
} catch (Exception e) {
LOGGER.error("raysUnionUserService.getAllUserIds" + e.getMessage(), e); }
return allUserIds;
}
public Map<Long, WechatUserOfficialAccounts> getUserOfficalAccountMap(List<Long> allUserIds) {
if (ListUtils.isEmpty(allUserIds)) {
return null;
}
LOGGER.info("【微信用户(消)】批量获取用户公众号 ,<START>.[wechatUserIds]=" + allUserIds);
Map<Long, WechatUserOfficialAccounts> wechatUserOfficialAccountsMap = null;
try {
wechatUserOfficialAccountsMap = ResponseHandleUtil.parseMap(wechatUserService.getUserOfficalAccountMap(allUserIds), Long.class,
WechatUserOfficialAccounts.class);
} catch (Exception e) {
LOGGER.error("【微信用户(消)】批量获取用户公众号.[getUserOfficalAccountMap]:" + e.getMessage(), e);
}
LOGGER.info("【微信用户(消)】批量获取用户公众号,<END>");
return wechatUserOfficialAccountsMap;
}
}
......@@ -28,6 +28,11 @@ public interface BookAuthInfoBiz {
void setBookAuthOpen(SetAuthOpenParam setAuthOpenParam, Long adviserId);
/**
* 设置授权后付费查看
*/
void setBookAuthPay(SetAuthStatusParam setAuthStatusParam, Long adviserId);
/**
* 设置图书版权状态
*/
void setAuthStatus(SetAuthStatusParam setAuthStatusParam, Long adviserId);
......
......@@ -23,6 +23,12 @@ public interface BookAuthServeBiz {
Map<String, Boolean> isSetServeAuth(Long bookId, Long channelId, Long adviserId, List<Long> serveIds) ;
/**
* 服务是否开启版权保护,以及授权后仍付费
* @return
*/
Map<String, Boolean> isSetServeAuthPay(Long bookId, Long channelId, Long adviserId, List<Long> serveIds) ;
/**
* 获取图书配置得服务
* @return
*/
......@@ -44,4 +50,9 @@ public interface BookAuthServeBiz {
* 获取图书是否开启版权保护
*/
Map<String,Boolean> listIsOpen4ServeIdsAndBookId(Long bookId, Long adviserId, Long channelId, List<Long> serveIds);
/**
* 获取图书是否开启授权后仍需付费
*/
Map<String, Boolean> listIsOpen4AuthorizedPay(Long bookId, Long adviserId, Long channelId, List<Long> serveIds);
}
......@@ -362,6 +362,28 @@ public class BookAuthInfoBizImpl implements BookAuthInfoBiz {
// return zipUrlInfo != null ? zipUrlInfo.getUrl() : null;
// }
@Override
@ParamLog("设置授权后付费查看")
public void setBookAuthPay(SetAuthStatusParam setAuthStatusParam, Long adviserId) {
Long bookId = setAuthStatusParam.getBookId();
Long channelId = setAuthStatusParam.getChannelId();
Integer isAuthorizedPay = setAuthStatusParam.getIsAuthorizedPay();
Integer authBookType = setAuthStatusParam.getAuthBookType();
if (bookId == null || channelId == null || adviserId == null) {
throw new BookBizException(BookBizException.PARAM_IS_NULL, "图书不存在");
}
BookAuthInfoVO bookAuthInfo = bookAuthInfoDao.getInfoByBook(bookId, channelId, adviserId, authBookType);
if (bookAuthInfo == null) {
throw new BookBizException(BookBizException.PARAM_IS_NULL, "图书未开启版权保护");
}
bookAuthInfo.setIsAuthorizedPay(isAuthorizedPay);
bookAuthInfoDao.updateAuthorizedPay(bookAuthInfo.getId(), isAuthorizedPay, adviserId);
if(authBookType == null) {
authBookType = 0;
}
String key = CopyrightConstants.BOOK_AUTH_INFO + bookAuthInfo.getBookId() + "-" + bookAuthInfo.getChannelId() + "-" + adviserId + "-" + authBookType;
JedisClusterUtils.setJson(key, bookAuthInfo);
}
@Override
@ParamLog("设置版权保护状态")
......
package com.pcloud.book.copyright.biz.impl;
import cn.hutool.core.collection.CollUtil;
import com.pcloud.book.base.enums.BookStatusEnum;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.book.biz.BookBiz;
import com.pcloud.book.book.dto.BookInfoAndAuthStatusDTO;
import com.pcloud.book.consumer.app.AppConsr;
import com.pcloud.book.consumer.channel.QrcodeSceneConsr;
import com.pcloud.book.consumer.resource.ProductConsr;
import com.pcloud.book.copyright.biz.BookAuthServeBiz;
import com.pcloud.book.copyright.dao.BookAuthServeDao;
import com.pcloud.book.copyright.dto.ServeDTO;
......@@ -14,6 +17,8 @@ import com.pcloud.channelcenter.qrcode.dto.QrcodeSceneDto;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.utils.ListUtils;
import com.pcloud.message.common.enums.YesNoEnums;
import com.pcloud.resourcecenter.product.dto.ProductDto;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
......@@ -35,6 +40,10 @@ public class BookAuthServeBizImpl implements BookAuthServeBiz {
private QrcodeSceneConsr qrcodeSceneConsr;
@Autowired
private BookBiz bookBiz;
@Autowired
private AppConsr appConsr;
@Autowired
private ProductConsr productConsr;
@Override
@ParamLog("设置图书授权服务")
......@@ -70,6 +79,36 @@ public class BookAuthServeBizImpl implements BookAuthServeBiz {
}
@Override
@ParamLog("服务是否开启版权保护,以及授权后仍付费")
public Map<String, Boolean> isSetServeAuthPay(Long bookId, Long channelId, Long adviserId, List<Long> serveIds) {
if (bookId == null || channelId == null || adviserId == null || ListUtils.isEmpty(serveIds)) {
return null;
}
List<ServeDTO> serveDTOS = bookAuthServeDao.isSetServeAuth(bookId, channelId, adviserId, serveIds);
if (ListUtils.isEmpty(serveDTOS)) {
return null;
}
Map<String, Boolean> isSetServesMap = new HashMap<>();
List<Long> productIds = CollUtil.toList();
for (ServeDTO serveDTO : serveDTOS) {
if(serveDTO.getServeType().equalsIgnoreCase("product")){
productIds.add(serveDTO.getServeId());
}
}
// TAPD:1005196 目前只支持视频、题库等作品
List<String> openAuthPayProductTypeCodeList = CollUtil.toList("VIDEO", "PRETEST");
Map<Long, ProductDto> productMap = productConsr.getProBasesByIds(productIds);
if(CollUtil.isNotEmpty(productMap)){
for (ProductDto productDto : productMap.values()) {
if(productDto.getProductTypeDto() != null && openAuthPayProductTypeCodeList.contains(productDto.getProductTypeDto().getTypeCode())){
isSetServesMap.put("PRODUCT" + productDto.getProductId(), true);
}
}
}
return isSetServesMap;
}
@Override
public List<ServeVO> listServesByBook(Long bookId, Long channelId, Long adviserId) {
return bookAuthServeDao.listServesByBook(bookId, channelId, adviserId);
}
......@@ -132,4 +171,15 @@ public class BookAuthServeBizImpl implements BookAuthServeBiz {
bookAuthServeDao.deleteServes(ids);
}
@Override
public Map<String, Boolean> listIsOpen4AuthorizedPay(Long bookId, Long adviserId, Long channelId, List<Long> serveIds) {
BookInfoAndAuthStatusDTO baseAndAuthStatus = bookBiz.getBaseAndAuthStatus(bookId, channelId, adviserId);
final boolean boo = baseAndAuthStatus != null && BookStatusEnum.PROTECT.value.equals(baseAndAuthStatus.getBookStatus())
&& BookStatusEnum.BookDeleteStatus.NOT_DELETE.value.equals(baseAndAuthStatus.getIsDelete())
&& YesNoEnums.YES.code.equals(baseAndAuthStatus.getIsAuthorizedPay());
if (boo) {
return isSetServeAuthPay(bookId, channelId, adviserId, serveIds);
}
return null;
}
}
package com.pcloud.book.copyright.biz.impl;
import cn.hutool.core.collection.CollUtil;
import com.google.common.collect.Lists;
import com.pcloud.book.base.exception.BookBizException;
......@@ -7,6 +8,7 @@ import com.pcloud.book.consumer.channel.QrcodeSceneConsr;
import com.pcloud.book.consumer.live.LiveCons;
import com.pcloud.book.consumer.reader.ReaderConsr;
import com.pcloud.book.consumer.resource.ProductConsr;
import com.pcloud.book.copyright.biz.BookAuthServeBiz;
import com.pcloud.book.copyright.biz.BookAuthUserBiz;
import com.pcloud.book.copyright.dao.BookAuthServeDao;
import com.pcloud.book.copyright.dao.BookAuthUserDao;
......@@ -70,6 +72,8 @@ public class BookAuthUserBizImpl implements BookAuthUserBiz {
private ProductConsr productConsr;
@Autowired
private ReaderConsr readerConsr;
@Autowired
private BookAuthServeBiz bookAuthServeBiz;
@ParamLog(value = "获取授权用户数量")
......@@ -217,13 +221,23 @@ public class BookAuthUserBizImpl implements BookAuthUserBiz {
List<Long> serverIds = new ArrayList<>();
serverIds.add(serverId);
List<ServeDTO> serveDTOS = bookAuthServeDao.isSetServeAuth(bookId, channelId, adviserId, serverIds);
// 用户被授权, 且指定的应用也被版权保护时, 返回true
return !ListUtils.isEmpty(serveDTOS);
// 获取授权后是否仍需付费
Boolean isAuthorizedPay = checkIsAuthorizedPay(bookId, channelId, adviserId, serverId);
// 用户被授权, 指定的应用也被版权保护,且授权后不需要付费,则返回true
return !ListUtils.isEmpty(serveDTOS) && !isAuthorizedPay;
}
// 其余情况都是false
return false;
}
private Boolean checkIsAuthorizedPay(Long bookId, Long channelId, Long adviserId, Long serverId) {
Map<String, Boolean> authorizedPayMap = bookAuthServeBiz.listIsOpen4AuthorizedPay(bookId, adviserId, channelId, CollUtil.toList(serverId));
if(CollUtil.isEmpty(authorizedPayMap)){
return false;
}
return authorizedPayMap.getOrDefault("PRODUCT" + serverId, false);
}
// 判断是否为超级作者的商品
private Boolean checkIsSuperProduct(Long serverId) {
Map<Long, Boolean> map = productConsr.getIsSuperByProductIdList(Lists.newArrayList(serverId));
......
......@@ -38,6 +38,11 @@ public interface BookAuthInfoDao extends BaseDao<BookAuthInfo> {
void updateBookStatus(Long id, Integer bookStatus, Long adviserId);
/**
* 更新图书授权付费
*/
void updateAuthorizedPay(Long id, Integer isAuthorizedPay, Long adviserId);
/**
* 更新图书版权基本信息
*/
void updateBaseInfo(BookAuthInfo bookAuthInfo);
......
......@@ -66,6 +66,15 @@ public class BookAuthInfoDaoImpl extends BaseDaoImpl<BookAuthInfo> implements Bo
}
@Override
public void updateAuthorizedPay(Long id, Integer isAuthorizedPay, Long adviserId) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("id", id);
paramMap.put("isAuthorizedPay", isAuthorizedPay);
paramMap.put("adviserId", adviserId);
this.getSqlSession().update(this.getStatement("updateAuthorizedPay"), paramMap);
}
@Override
public void updateBaseInfo(BookAuthInfo bookAuthInfo) {
this.getSqlSession().update(this.getStatement("updateBaseInfo"), bookAuthInfo);
}
......
......@@ -3,6 +3,7 @@ package com.pcloud.book.copyright.entity;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
......@@ -11,6 +12,7 @@ import java.util.Date;
* @author lily
* @date 2018/12/3 11:14
*/
@Data
@ApiModel
public class BookAuthInfo extends BaseEntity {
@ApiModelProperty("图书授权信息标识")
......@@ -67,173 +69,7 @@ public class BookAuthInfo extends BaseEntity {
@ApiModelProperty("是否是社群书")
private Integer isGroupBook;
@Override
public Long getId() {
return id;
}
@ApiModelProperty("授权后仍需付费")
private Integer isAuthorizedPay;
@Override
public void setId(Long id) {
this.id = id;
}
public Long getBookId() {
return bookId;
}
public void setBookId(Long bookId) {
this.bookId = bookId;
}
public Long getChannelId() {
return channelId;
}
public void setChannelId(Long channelId) {
this.channelId = channelId;
}
public Long getAdviserId() {
return adviserId;
}
public void setAdviserId(Long adviserId) {
this.adviserId = adviserId;
}
public BigDecimal getPrice() {
return price;
}
public void setPrice(BigDecimal price) {
this.price = price;
}
public Integer getCodeUseCount() {
return codeUseCount;
}
public void setCodeUseCount(Integer codeUseCount) {
this.codeUseCount = codeUseCount;
}
public String getBuyUrl() {
return buyUrl;
}
public void setBuyUrl(String buyUrl) {
this.buyUrl = buyUrl;
}
public Integer getBookStatus() {
return bookStatus;
}
public void setBookStatus(Integer bookStatus) {
this.bookStatus = bookStatus;
}
public String getLocationDesc() {
return locationDesc;
}
public void setLocationDesc(String locationDesc) {
this.locationDesc = locationDesc;
}
public Long getCreatedUser() {
return createdUser;
}
public void setCreatedUser(Long createdUser) {
this.createdUser = createdUser;
}
public Date getCreatedDate() {
return createdDate;
}
public void setCreatedDate(Date createdDate) {
this.createdDate = createdDate;
}
public Long getLastModifiedUser() {
return lastModifiedUser;
}
public void setLastModifiedUser(Long lastModifiedUser) {
this.lastModifiedUser = lastModifiedUser;
}
public Date getLastModifiedDate() {
return lastModifiedDate;
}
public void setLastModifiedDate(Date lastModifiedDate) {
this.lastModifiedDate = lastModifiedDate;
}
public Integer getCheckType() {
return checkType;
}
public void setCheckType(Integer checkType) {
this.checkType = checkType;
}
public Date getOpenTime() {
return openTime;
}
public void setOpenTime(Date openTime) {
this.openTime = openTime;
}
public Date getCloseTime() {
return closeTime;
}
public void setCloseTime(Date closeTime) {
this.closeTime = closeTime;
}
public Integer getIsPaperBook() {
return isPaperBook;
}
public void setIsPaperBook(Integer isPaperBook) {
this.isPaperBook = isPaperBook;
}
public Integer getIsGroupBook() {
return isGroupBook;
}
public void setIsGroupBook(Integer isGroupBook) {
this.isGroupBook = isGroupBook;
}
@Override
public String toString() {
return "BookAuthInfo{" +
"id=" + id +
", bookId=" + bookId +
", channelId=" + channelId +
", adviserId=" + adviserId +
", price=" + price +
", codeUseCount=" + codeUseCount +
", buyUrl='" + buyUrl + '\'' +
", bookStatus=" + bookStatus +
", locationDesc='" + locationDesc + '\'' +
", checkType=" + checkType +
", createdUser=" + createdUser +
", createdDate=" + createdDate +
", lastModifiedUser=" + lastModifiedUser +
", lastModifiedDate=" + lastModifiedDate +
", openTime=" + openTime +
", closeTime=" + closeTime +
", isPaperBook=" + isPaperBook +
", isGroupBook=" + isGroupBook +
'}';
}
}
......@@ -17,6 +17,7 @@ import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.permission.PermissionException;
import com.pcloud.common.utils.SessionUtil;
import com.pcloud.common.utils.cookie.Cookie;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.GetMapping;
......@@ -47,6 +48,14 @@ public class BookAuthInfoFacadeImpl implements BookAuthInfoFacade {
return new ResponseDto<>();
}
@ApiOperation("设置授权后付费查看")
@PostMapping("setBookAuthPay")
public ResponseDto<?> setBookAuthPay(@RequestHeader("token") String token, @RequestBody SetAuthStatusParam setAuthStatusParam) throws PermissionException, BizException {
Long adviserId = (Long) SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
bookAuthInfoBiz.setBookAuthPay(setAuthStatusParam, adviserId);
return new ResponseDto<>();
}
@Override
@PostMapping("setAuthStatus")
public ResponseDto<?> setAuthStatus(@RequestHeader("token") String token, @RequestBody SetAuthStatusParam setAuthStatusParam) throws PermissionException, BizException {
......
......@@ -58,4 +58,14 @@ public class BookAuthServeServiceImpl implements BookAuthServeService {
}
return ResponseHandleUtil.toResponse(isOpen4ServeIds);
}
@Override
@PostMapping("listIsOpen4AuthorizedPay")
public ResponseEntity<ResponseDto<Map<String, Boolean>>> listIsOpen4AuthorizedPay(@RequestBody BookAuthServerDTO bookAuthServerDTO) throws BizException {
Map<String, Boolean> isOpen4ServeIds = null;
if (bookAuthServerDTO != null && !bookAuthServerDTO.check()) {
isOpen4ServeIds = bookAuthServeBiz.listIsOpen4AuthorizedPay(bookAuthServerDTO.getBookId(), bookAuthServerDTO.getAdviserId(), bookAuthServerDTO.getChannelId(), bookAuthServerDTO.getServeIds());
}
return ResponseHandleUtil.toResponse(isOpen4ServeIds);
}
}
......@@ -52,6 +52,9 @@ public class BookAuthInfoAndServesVO implements Serializable {
@ApiModelProperty("是否有使用过的授权码")
private Boolean haveUsedAuthCode;
@ApiModelProperty("授权后仍需付费")
private Integer isAuthorizedPay;
public Long getId() {
return id;
......@@ -149,6 +152,14 @@ public class BookAuthInfoAndServesVO implements Serializable {
this.haveUsedAuthCode = haveUsedAuthCode;
}
public Integer getIsAuthorizedPay() {
return isAuthorizedPay;
}
public void setIsAuthorizedPay(Integer isAuthorizedPay) {
this.isAuthorizedPay = isAuthorizedPay;
}
@Override
public String toString() {
return "BookAuthInfoAndServesVO{" +
......
......@@ -3,6 +3,7 @@ package com.pcloud.book.copyright.vo;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
......@@ -11,6 +12,7 @@ import java.math.BigDecimal;
* @author lily
* @date 2018/12/4 11:50
*/
@Data
@ApiModel
@JsonInclude(JsonInclude.Include.NON_NULL)
public class BookAuthInfoVO implements Serializable {
......@@ -45,100 +47,7 @@ public class BookAuthInfoVO implements Serializable {
@ApiModelProperty("位置描述")
private String locationDesc;
@ApiModelProperty("授权后仍需付费")
private Integer isAuthorizedPay;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getBookId() {
return bookId;
}
public void setBookId(Long bookId) {
this.bookId = bookId;
}
public Long getChannelId() {
return channelId;
}
public void setChannelId(Long channelId) {
this.channelId = channelId;
}
public Long getAdviserId() {
return adviserId;
}
public void setAdviserId(Long adviserId) {
this.adviserId = adviserId;
}
public BigDecimal getPrice() {
return price;
}
public void setPrice(BigDecimal price) {
this.price = price;
}
public Integer getCodeUseCount() {
return codeUseCount;
}
public void setCodeUseCount(Integer codeUseCount) {
this.codeUseCount = codeUseCount;
}
public String getBuyUrl() {
return buyUrl;
}
public void setBuyUrl(String buyUrl) {
this.buyUrl = buyUrl;
}
public Integer getBookStatus() {
return bookStatus;
}
public void setBookStatus(Integer bookStatus) {
this.bookStatus = bookStatus;
}
public Integer getCheckType() {
return checkType;
}
public void setCheckType(Integer checkType) {
this.checkType = checkType;
}
public String getLocationDesc() {
return locationDesc;
}
public void setLocationDesc(String locationDesc) {
this.locationDesc = locationDesc;
}
@Override
public String toString() {
return "BookAuthInfoVO{" +
"id=" + id +
", bookId=" + bookId +
", channelId=" + channelId +
", adviserId=" + adviserId +
", price=" + price +
", codeUseCount=" + codeUseCount +
", buyUrl='" + buyUrl + '\'' +
", bookStatus=" + bookStatus +
", checkType=" + checkType +
", locationDesc='" + locationDesc + '\'' +
'}';
}
}
......@@ -3,6 +3,7 @@ package com.pcloud.book.copyright.vo;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
......@@ -12,6 +13,7 @@ import java.util.List;
* @author lily
* @date 2018/12/3 11:26
*/
@Data
@ApiModel
@JsonInclude(JsonInclude.Include.NON_NULL)
public class SetAuthOpenParam implements Serializable {
......@@ -49,108 +51,7 @@ public class SetAuthOpenParam implements Serializable {
@ApiModelProperty("书刊类型:0-现代纸书 1-社群书")
private Integer authBookType;
public List<ServeVO> getServes() {
return serves;
}
public void setServes(List<ServeVO> serves) {
this.serves = serves;
}
public Long getBookId() {
return bookId;
}
public void setBookId(Long bookId) {
this.bookId = bookId;
}
public Long getChannelId() {
return channelId;
}
public void setChannelId(Long channelId) {
this.channelId = channelId;
}
public Integer getBookStatus() {
return bookStatus;
}
public void setBookStatus(Integer bookStatus) {
this.bookStatus = bookStatus;
}
public BigDecimal getPrice() {
return price;
}
public void setPrice(BigDecimal price) {
this.price = price;
}
public Integer getCodeUseCount() {
return codeUseCount;
}
public void setCodeUseCount(Integer codeUseCount) {
this.codeUseCount = codeUseCount;
}
public Integer getCodeCount() {
return codeCount;
}
public void setCodeCount(Integer codeCount) {
this.codeCount = codeCount;
}
public String getBuyUrl() {
return buyUrl;
}
public void setBuyUrl(String buyUrl) {
this.buyUrl = buyUrl;
}
public Integer getCheckType() {
return checkType;
}
public void setCheckType(Integer checkType) {
this.checkType = checkType;
}
public Integer getIsHaveBarCode() {
return isHaveBarCode;
}
public void setIsHaveBarCode(Integer isHaveBarCode) {
this.isHaveBarCode = isHaveBarCode;
}
public Integer getAuthBookType() {
return authBookType;
}
public void setAuthBookType(Integer authBookType) {
this.authBookType = authBookType;
}
@Override
public String toString() {
return "SetAuthOpenParam{" +
"bookId=" + bookId +
", channelId=" + channelId +
", price=" + price +
", codeUseCount=" + codeUseCount +
", codeCount=" + codeCount +
", buyUrl='" + buyUrl + '\'' +
", bookStatus=" + bookStatus +
", checkType=" + checkType +
", serves=" + serves +
", isHaveBarCode=" + isHaveBarCode +
", authBookType=" + authBookType +
'}';
}
@ApiModelProperty("授权后仍需付费")
private Integer isAuthorizedPay;
}
......@@ -28,6 +28,9 @@ public class SetAuthStatusParam implements Serializable {
@ApiModelProperty("书刊类型:0-现代纸书 1-社群书")
private Integer authBookType;
@ApiModelProperty("授权后仍需付费")
private Integer isAuthorizedPay;
public Integer getBookStatus() {
return bookStatus;
}
......@@ -60,6 +63,14 @@ public class SetAuthStatusParam implements Serializable {
this.authBookType = authBookType;
}
public Integer getIsAuthorizedPay() {
return isAuthorizedPay;
}
public void setIsAuthorizedPay(Integer isAuthorizedPay) {
this.isAuthorizedPay = isAuthorizedPay;
}
@Override
public String toString() {
return "SetAuthStatusParam{" +
......
package com.pcloud.book.cultivate.biz;
import com.pcloud.book.book.vo.SearchBookVO;
import com.pcloud.book.cultivate.dto.CreateCultivateDTO;
import com.pcloud.book.cultivate.dto.CultivateDTO;
import com.pcloud.book.cultivate.dto.EnergyConsumptionDTO;
import com.pcloud.book.cultivate.dto.FishBallConversionDTO;
import com.pcloud.book.cultivate.dto.FishBallPickDTO;
import com.pcloud.book.cultivate.dto.FriendDTO;
import com.pcloud.book.cultivate.dto.GiveEnergyDTO;
import com.pcloud.book.cultivate.dto.HoldSeatDTO;
import com.pcloud.book.cultivate.dto.SkillUseDTO;
import com.pcloud.book.cultivate.entity.Cultivate;
import com.pcloud.book.cultivate.entity.CultivateBookUser;
import com.pcloud.book.cultivate.entity.CultivateRecord;
import com.pcloud.book.cultivate.entity.CultivateRobotClassify;
import com.pcloud.book.personal.dto.PersonalMedalRecordDto;
import com.pcloud.common.core.mq.DelayQueueDTO;
import com.pcloud.common.page.PageBeanNew;
import java.util.List;
package com.pcloud.book.cultivate.biz;
public interface CultivateBiz {
Long createCultivate(CreateCultivateDTO createCultivateDTO);
/* Long createCultivate(CreateCultivateDTO createCultivateDTO);
Cultivate getCultivate(Long wechatUserId);
......@@ -82,4 +63,6 @@ public interface CultivateBiz {
Boolean beforeHoldSeat(Long cultivateId);
CultivateDTO getCultivateBaseInfo(Long cultivateId);
*/
}
......@@ -6,7 +6,6 @@ import com.pcloud.book.cultivate.dto.CultivateNotifyPageDTO;
import com.pcloud.book.cultivate.dto.NotifySendDTO;
import com.pcloud.book.cultivate.dto.SearchNotifyDTO;
import com.pcloud.book.cultivate.dto.SearchSendUserDTO;
import com.pcloud.book.cultivate.dto.SendUserDetailDto;
import com.pcloud.book.cultivate.entity.AppletNotifySendDTO;
import com.pcloud.book.cultivate.entity.CultivateNotifySend;
import com.pcloud.common.page.PageBeanNew;
......@@ -20,7 +19,7 @@ public interface CultivateNotifyBiz {
void createNotify(CultivateNotifyDTO cultivateNotifyDTO);
void sendAppletTemplateMessage(List<CultivateNotifySend> list, Long agnetId);
void sendAppletTemplateMessage(List<CultivateNotifySend> list, Long agentId, Long miniOfficialAccountsId);
PageBeanNew<CultivateNotifyPageDTO> listPage4CultivateNotify(SearchNotifyDTO searchNotifyDTO);
......@@ -47,4 +46,6 @@ public interface CultivateNotifyBiz {
void clearExpireNotifies();
Long sendNotifyToUser(NotifySendDTO notifySendDTO);
List<CultivateNotifyDTO> getLastNoReadNotify(Long wechatUserId);
}
package com.pcloud.book.cultivate.biz;
import com.pcloud.book.cultivate.dto.CultivateRaysConversionDTO;
import com.pcloud.book.cultivate.dto.CultivateRaysDTO;
import com.pcloud.common.core.mq.DelayQueueDTO;
public interface CultivateRaysBiz {
/**
* 新增养成
* @author:zhuyajie
* @date:2021/7/16 14:13
* * @param null
*/
Long createCultivate(Long wechatUserId, Long officialAccountsId);
/**
* 获取养成
* @author:zhuyajie
* @date:2021/7/16 14:14
* * @param null
*/
CultivateRaysDTO getCultivate(Long wechatUserId, Long officialAccountsId);
/**
* 书币兑换
* @author:zhuyajie
* @date:2021/7/16 14:14
* * @param null
*/
void rmallMoneyConversion(CultivateRaysConversionDTO cultivateRaysConversionDTO);
/**
* 投喂兑换时间
* @author:zhuyajie
* @date:2021/7/16 14:14
* * @param null
*/
void gainsConversion(CultivateRaysConversionDTO cultivateRaysConversionDTO);
/**
* 时间消耗完
* @author:zhuyajie
* @date:2021/7/16 18:29
* * @param null
*/
void dealHoursConsumption(DelayQueueDTO delayQueueDTO);
}
package com.pcloud.book.cultivate.biz.impl;
import com.google.common.collect.Lists;
import com.pcloud.appcenter.assist.dto.AssistTempletDTO;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.book.vo.SearchBookVO;
import com.pcloud.book.consumer.app.AssistTempletConsr;
import com.pcloud.book.consumer.reader.ReaderConsr;
import com.pcloud.book.consumer.user.AdviserConsr;
import com.pcloud.book.cultivate.biz.CultivateBiz;
import com.pcloud.book.cultivate.constant.CultivateConstant;
import com.pcloud.book.cultivate.dao.CultivateBookUserDao;
import com.pcloud.book.cultivate.dao.CultivateDao;
import com.pcloud.book.cultivate.dao.CultivateHoldSeatDao;
import com.pcloud.book.cultivate.dao.CultivateRecordDao;
import com.pcloud.book.cultivate.dao.CultivateRobotClassifyDao;
import com.pcloud.book.cultivate.dto.CreateCultivateDTO;
import com.pcloud.book.cultivate.dto.CultivateDTO;
import com.pcloud.book.cultivate.dto.DealHoldSeatFriendFishBallDTO;
import com.pcloud.book.cultivate.dto.EnergyConsumptionDTO;
import com.pcloud.book.cultivate.dto.EnergyConsumptionDelayDTO;
import com.pcloud.book.cultivate.dto.FishBallConversionDTO;
import com.pcloud.book.cultivate.dto.FishBallPickDTO;
import com.pcloud.book.cultivate.dto.FriendDTO;
import com.pcloud.book.cultivate.dto.GiveEnergyDTO;
import com.pcloud.book.cultivate.dto.HoldSeatDTO;
import com.pcloud.book.cultivate.dto.HoldTimeDTO;
import com.pcloud.book.cultivate.dto.SkillUseDTO;
import com.pcloud.book.cultivate.entity.Cultivate;
import com.pcloud.book.cultivate.entity.CultivateBookUser;
import com.pcloud.book.cultivate.entity.CultivateHoldSeat;
import com.pcloud.book.cultivate.entity.CultivateRecord;
import com.pcloud.book.cultivate.entity.CultivateRobotClassify;
import com.pcloud.book.cultivate.enums.CultivateChangeTypeEnum;
import com.pcloud.book.cultivate.enums.CultivateSkillTypeEnum;
import com.pcloud.book.cultivate.enums.FishBallChangeTypeEnum;
import com.pcloud.book.mq.delay.DelayMessageSender;
import com.pcloud.book.pcloudkeyword.biz.PcloudRobotBiz;
import com.pcloud.book.pcloudkeyword.biz.PcloudRobotClassifyBiz;
import com.pcloud.book.personal.biz.PersonalMedalBiz;
import com.pcloud.book.personal.dao.PersonalMedalDao;
import com.pcloud.book.personal.dao.PersonalMedalRecordDao;
import com.pcloud.book.personal.dto.PersonalMedalRecordDto;
import com.pcloud.book.personal.entity.PersonalMedal;
import com.pcloud.book.personal.entity.PersonalMedalRecord;
import com.pcloud.book.personal.entity.PersonalShareTemplate;
import com.pcloud.book.personal.mapper.PersonalShareTemplateMapper;
import com.pcloud.book.util.common.ThreadPoolUtils;
import com.pcloud.book.util.common.YesOrNoEnums;
import com.pcloud.common.constant.CacheConstant;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.core.mq.DelayQueueDTO;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.page.PageParam;
import com.pcloud.common.utils.DateUtils;
import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.ResponseHandleUtil;
import com.pcloud.common.utils.cache.redis.JedisClusterUtils;
import com.pcloud.common.utils.string.StringUtil;
import com.pcloud.facade.shareimage.dto.HtmlDto;
import com.pcloud.facade.shareimage.facade.Htm2ImgService;
import com.pcloud.readercenter.wechat.entity.WechatUser;
import com.pcloud.usercenter.party.adviser.dto.AdviserBaseInfoDto;
import org.apache.commons.collections.MapUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
@Component("cultivateBiz")
public class CultivateBizImpl implements CultivateBiz {
/*
@Autowired
private CultivateDao cultivateDao;
@Autowired
......@@ -1411,5 +1338,6 @@ public class CultivateBizImpl implements CultivateBiz {
WechatUser wechatUser = readerConsr.getWechatUser(cultivate.getWechatUserId());
cultivateDTO.setPicUrl(null!=wechatUser?wechatUser.getWechatUserHeadurl():null);
return cultivateDTO;
}
}*/
}
package com.pcloud.book.cultivate.constant;
/**
* @ClassName com.pcloud.book.cultivate.constant.CultivateRaysConstants
* @Author zhuyajie
* @Description 新版宠物小睿
* @Date 2021/7/16 14:22
* @Version 1.0
**/
public class CultivateRaysConstants {
/**
* 宠物状态 0饥饿1进食
* @author:zhuyajie
* @date:2021/7/16 14:24
* * @param null
*/
public enum CultivateRaysState{
HUNGRY(0),
EATING(1);
private Integer code;
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
CultivateRaysState(Integer code) {
this.code = code;
}
}
/**
* 收入类型及兑换
* @author:zhuyajie
* @date:2021/7/16 14:40
* * @param null
*/
public enum GainsConversionEnum {
/**
* 类型,名称,可兑换x时长,x书币兑换1个
*/
GAINS1(1,"小鱼干", 5,3),
GAINS2(2,"面包",10,5),
GAINS3(3,"大餐",24,10);
private Integer type;
private String typeName;
private Integer hours;
private Integer cost;
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public String getTypeName() {
return typeName;
}
public void setTypeName(String typeName) {
this.typeName = typeName;
}
public Integer getHours() {
return hours;
}
public void setHours(Integer hours) {
this.hours = hours;
}
public Integer getCost() {
return cost;
}
public void setCost(Integer cost) {
this.cost = cost;
}
GainsConversionEnum(Integer type, String typeName, Integer hours, Integer cost) {
this.type = type;
this.typeName = typeName;
this.hours = hours;
this.cost = cost;
}
public static Integer getHoursByType(Integer type) {
for (GainsConversionEnum conversionEnum:GainsConversionEnum.values()) {
if (conversionEnum.type.equals(type)){
return conversionEnum.hours;
}
}
return null;
}
public static Integer getCostByType(Integer type) {
for (GainsConversionEnum conversionEnum:GainsConversionEnum.values()) {
if (conversionEnum.type.equals(type)){
return conversionEnum.cost;
}
}
return null;
}
public static String getNameByType(Integer type) {
for (GainsConversionEnum conversionEnum:GainsConversionEnum.values()) {
if (conversionEnum.type.equals(type)){
return conversionEnum.typeName;
}
}
return null;
}
}
/**
* 变化类型
* @author:zhuyajie
* @date:2021/7/16 18:15
* * @param null
*/
public enum ChangeTypeEnum{
RMALL_MONEY_CONVERSION(1),
GAINS_CONVERSION(2);
private Integer code;
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
ChangeTypeEnum(Integer code) {
this.code = code;
}
}
//延时队列-时间消耗
public static final String HOURS_CONSUMPTION_DELAY="HOURS_CONSUMPTION_DELAY";
//缓存-指引
public static final String GUIDE_REDIS ="book:cultivate_guide";
}
package com.pcloud.book.cultivate.dao;
import com.pcloud.book.cultivate.entity.CultivateBookUser;
import com.pcloud.common.core.dao.BaseDao;
public interface CultivateBookUserDao extends BaseDao<CultivateBookUser> {
CultivateBookUser getLastCultivateBookUser(Long wechatUserId);
}
package com.pcloud.book.cultivate.dao;
import com.pcloud.book.cultivate.entity.CultivateHoldSeat;
import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
public interface CultivateHoldSeatDao extends BaseDao<CultivateHoldSeat> {
void deleteById(Long cultivateId,Long friendCultivateId);
List<Long> getCultivateIdByFriendId(Long friendCultivateId);
Long getFriendCultivateIdById(Long cultivateId);
CultivateHoldSeat getById(Long cultivateId,Long friendCultivateId);
}
......@@ -26,4 +26,8 @@ public interface CultivateNotifySendDao extends BaseDao<CultivateNotifySend> {
Integer getSendUserCount(Long messageId);
void clearExpireNotifies();
List<Long> getLastNoReadNotify(Long wechatUserId);
void updateIsRead(Long wechatUserId, List<Long> messageIds);
}
package com.pcloud.book.cultivate.dao;
import com.pcloud.book.cultivate.entity.CultivateRays;
import com.pcloud.common.core.dao.BaseDao;
/**
* 宠物小睿基本信息(CultivateRays)表数据库访问层
*
* @author makejava
* @since 2021-07-16 13:52:47
*/
public interface CultivateRaysDao extends BaseDao <CultivateRays>{
CultivateRays getByWechatUserId(Long wechatUserId);
}
\ No newline at end of file
package com.pcloud.book.cultivate.dao;
import com.pcloud.book.cultivate.entity.CultivateRaysRecord;
import com.pcloud.common.core.dao.BaseDao;
/**
* 宠物小睿喂养记录(CultivateRaysRecord)表数据库访问层
*
* @author makejava
* @since 2021-07-16 13:53:12
*/
public interface CultivateRaysRecordDao extends BaseDao<CultivateRaysRecord>{
CultivateRaysRecord getLastRecord(Long cultivateId, Integer changeType);
}
\ No newline at end of file
package com.pcloud.book.cultivate.dao;
import com.pcloud.book.cultivate.entity.CultivateRobotClassify;
import com.pcloud.common.core.dao.BaseDao;
public interface CultivateRobotClassifyDao extends BaseDao<CultivateRobotClassify> {
CultivateRobotClassify getByCondition(Long wechatUserId, Long cultivateId, Long robotClassifyId);
}
package com.pcloud.book.cultivate.dao.impl;
import com.pcloud.book.cultivate.dao.CultivateBookUserDao;
import com.pcloud.book.cultivate.entity.CultivateBookUser;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Component;
@Component("cultivateBookUserDao")
public class CultivateBookUserDaoImpl extends BaseDaoImpl<CultivateBookUser> implements CultivateBookUserDao {
@Override
public CultivateBookUser getLastCultivateBookUser(Long wechatUserId) {
return super.getSqlSession().selectOne(getStatement("getLastCultivateBookUser"),wechatUserId);
}
}
package com.pcloud.book.cultivate.dao.impl;
import com.pcloud.book.cultivate.dao.CultivateHoldSeatDao;
import com.pcloud.book.cultivate.entity.CultivateHoldSeat;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Component("cultivateHoldSeatDao")
public class CultivateHoldSeatDaoImpl extends BaseDaoImpl<CultivateHoldSeat> implements CultivateHoldSeatDao {
@Override
public void deleteById(Long cultivateId,Long friendCultivateId) {
Map<String,Object> map=new HashMap<>();
map.put("cultivateId",cultivateId);
map.put("friendCultivateId",friendCultivateId);
super.getSqlSession().update(getStatement("deleteById"), map);
}
@Override
public List<Long> getCultivateIdByFriendId(Long friendCultivateId) {
Map<String,Object> map=new HashMap<>();
map.put("friendCultivateId",friendCultivateId);
return super.getSqlSession().selectList(getStatement("getCultivateIdByFriendId"), map);
}
@Override
public Long getFriendCultivateIdById(Long cultivateId) {
Map<String,Object> map=new HashMap<>();
map.put("cultivateId",cultivateId);
return super.getSqlSession().selectOne(getStatement("getFriendCultivateIdById"), map);
}
@Override
public CultivateHoldSeat getById(Long cultivateId, Long friendCultivateId) {
Map<String,Object> map=new HashMap<>();
map.put("cultivateId",cultivateId);
map.put("friendCultivateId",friendCultivateId);
return super.getSqlSession().selectOne(getStatement("getById"), map);
}
}
......@@ -76,4 +76,17 @@ public class CultivateNotifySendDaoImpl extends BaseDaoImpl<CultivateNotifySend>
public void clearExpireNotifies() {
getSessionTemplate().delete(getStatement("clearExpireNotifies"));
}
@Override
public List<Long> getLastNoReadNotify(Long wechatUserId) {
return super.getSessionTemplate().selectList(getStatement("getLastNoReadNotify"), wechatUserId);
}
@Override
public void updateIsRead(Long wechatUserId, List<Long> messageIds) {
Map<String,Object> map=new HashMap<>();
map.put("wechatUserId",wechatUserId);
map.put("messageIds",messageIds);
super.getSessionTemplate().update(getStatement("batchUpdateIsRead"),map);
}
}
package com.pcloud.book.cultivate.dao.impl;
import com.pcloud.book.cultivate.dao.CultivateRaysDao;
import com.pcloud.book.cultivate.entity.CultivateRays;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Component;
/**
* @ClassName com.pcloud.book.cultivate.dao.impl.CultivateRaysDaoImpl
* @Author zhuyajie
* @Description 宠物小睿
* @Date 2021/7/16 13:56
* @Version 1.0
**/
@Component
public class CultivateRaysDaoImpl extends BaseDaoImpl<CultivateRays> implements CultivateRaysDao {
@Override
public CultivateRays getByWechatUserId(Long wechatUserId) {
return getSessionTemplate().selectOne(getStatement("getByWechatUserId"), wechatUserId);
}
}
package com.pcloud.book.cultivate.dao.impl;
import com.pcloud.book.cultivate.dao.CultivateRaysRecordDao;
import com.pcloud.book.cultivate.entity.CultivateRaysRecord;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
/**
* @ClassName com.pcloud.book.cultivate.dao.impl.CultivateRaysRecordDaoImpl
* @Author zhuyajie
* @Description 记录
* @Date 2021/7/16 13:58
* @Version 1.0
**/
@Component
public class CultivateRaysRecordDaoImpl extends BaseDaoImpl<CultivateRaysRecord> implements CultivateRaysRecordDao {
@Override
public CultivateRaysRecord getLastRecord(Long cultivateId, Integer changeType) {
Map<String,Object> map = new HashMap<>();
map.put("cultivateId", cultivateId);
map.put("changeType", changeType);
return getSessionTemplate().selectOne(getStatement("getLastRecord"), map);
}
}
package com.pcloud.book.cultivate.dao.impl;
import com.pcloud.book.cultivate.dao.CultivateRobotClassifyDao;
import com.pcloud.book.cultivate.entity.CultivateRobotClassify;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
@Component("cultivateRobotClassifyDao")
public class CultivateRobotClassifyDaoImpl extends BaseDaoImpl<CultivateRobotClassify> implements CultivateRobotClassifyDao {
@Override
public CultivateRobotClassify getByCondition(Long wechatUserId, Long cultivateId, Long robotClassifyId) {
Map<String,Object> map=new HashMap<>();
map.put("wechatUserId",wechatUserId);
map.put("cultivateId",cultivateId);
map.put("robotClassifyId",robotClassifyId);
return super.getSqlSession().selectOne(getStatement("getByCondition"), map);
}
}
......@@ -58,4 +58,10 @@ public class CultivateNotifyDTO {
@ApiModelProperty("注册结束时间")
private String endTime;
@ApiModelProperty("用户学龄段标签id")
private List<Long> userGradeLabelIds;
@ApiModelProperty("是否首页弹窗")
private Integer showHome;
}
......@@ -30,4 +30,7 @@ public class CultivateNotifyPageDTO {
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date sendTime;
@ApiModelProperty("是否首页弹窗")
private Integer showHome;
}
package com.pcloud.book.cultivate.dto;
import lombok.Data;
/**
* @ClassName com.pcloud.book.cultivate.dto.CultivateRaysConversionDTO
* @Author zhuyajie
* @Description 兑换
* @Date 2021/7/16 14:12
* @Version 1.0
**/
@Data
public class CultivateRaysConversionDTO {
private Long wechatUserId;
private Integer gainsType;
}
package com.pcloud.book.cultivate.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.pcloud.common.dto.BaseDto;
import java.util.Date;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 宠物小睿基本信息(CultivateRays)实体类
*
* @author makejava
* @since 2021-07-16 13:52:47
*/
@Data
public class CultivateRaysDTO extends BaseDto {
private static final long serialVersionUID = 703145616367143769L;
/**
* 主键
*/
private Long id;
/**
* 用户id
*/
private Long wechatUserId;
/**
* 公众号id
*/
private Long officialAccountsId;
/**
* 收入1数量
*/
private Integer gains1;
/**
* 收入2数量
*/
private Integer gains2;
/**
* 收入3数量
*/
private Integer gains3;
/**
* 当前状态(0饥饿1进食)
*/
private Integer state;
@ApiModelProperty("头像")
private String headPic;
@ApiModelProperty("昵称")
private String nickName;
@ApiModelProperty("上次食物兑换时间")
private String lastConversionTime;
@ApiModelProperty("兑换时长")
private Integer hours;
/**
* 进食结束时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date endTime;
@ApiModelProperty("是否有宠物")
private Boolean hasPet;
}
\ No newline at end of file
package com.pcloud.book.cultivate.dto;
import java.io.Serializable;
import lombok.Data;
/**
* @ClassName com.pcloud.book.cultivate.dto.CultivateRaysDelayDTO
* @Author zhuyajie
* @Description 小睿耗时
* @Date 2021/7/16 18:25
* @Version 1.0
**/
@Data
public class CultivateRaysDelayDTO implements Serializable {
private Long cultivateId;
}
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