Commit f0e611da by 裴大威

Merge branch 'feat-1002436' into 'master'

勋章优化

See merge request rays/pcloud-book!484
parents 12ca9883 c27d5d2f
......@@ -21,5 +21,11 @@ public interface PersonalMedalBiz {
void receiveStar(Long wechatUserId, StarReceiveTypeEnum starReceiveTypeEnum);
String shareMedal(Long medalId, Long wechatUserId,String robotWxId);
String shareMedal(Long wechatUserId,String robotWxId);
Integer getRanking(Long wechatUserId);
Integer getLoginDays(Long wechatUserId);
Integer getMedalAllDays(Long wechatUserId, Integer medalDays);
}
......@@ -4,17 +4,23 @@ import com.google.common.collect.Lists;
import com.pcloud.book.consumer.reader.ReaderConsr;
import com.pcloud.book.consumer.wechatgroup.WechatGroupConsr;
import com.pcloud.book.pcloudkeyword.biz.PcloudRobotBiz;
import com.pcloud.book.pcloudkeyword.biz.PcloudRobotClassifyBiz;
import com.pcloud.book.pcloudkeyword.entity.PcloudRobot;
import com.pcloud.book.pcloudkeyword.entity.PcloudRobotClassify;
import com.pcloud.book.personal.biz.PersonalMedalBiz;
import com.pcloud.book.personal.constants.MedalContants;
import com.pcloud.book.personal.dao.PersonalMedalDao;
import com.pcloud.book.personal.dao.PersonalMedalRecordDao;
import com.pcloud.book.personal.dao.PersonalStarRecordDao;
import com.pcloud.book.personal.dto.PersonalMedalRecordDto;
import com.pcloud.book.personal.dto.PersonalStarReceiveDto;
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.entity.PersonalStarRecord;
import com.pcloud.book.personal.enums.StarReceiveTypeEnum;
import com.pcloud.book.personal.mapper.PersonalShareTemplateMapper;
import com.pcloud.book.personalstage.dto.PersonalStageProgressDTO;
import com.pcloud.book.util.common.YesOrNoEnums;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.exceptions.BizException;
......@@ -49,6 +55,10 @@ public class PersonalMedalBizImpl implements PersonalMedalBiz {
private PcloudRobotBiz pcloudRobotBiz;
@Autowired
private Htm2ImgService htm2ImgService;
@Autowired
private PcloudRobotClassifyBiz pcloudRobotClassifyBiz;
@Autowired
private PersonalShareTemplateMapper personalShareTemplateMapper;
@Override
@ParamLog("获取基础勋章数据")
......@@ -78,6 +88,18 @@ public class PersonalMedalBizImpl implements PersonalMedalBiz {
String receiveDate = DateUtils.getShortDateStr(date);
// 查询用户今天是否领取过
Integer count = personalStarRecordDao.hasReceive(wechatUserId, receiveDate, StarReceiveTypeEnum.LOGIN.key);
//查询用户是否领取过第一次登陆的30颗星星
Integer countFirstLogin = personalStarRecordDao.hasReceiveFirstLogin(wechatUserId, StarReceiveTypeEnum.FIRST_LOGIN.key);
if(countFirstLogin!=null&&count==0){
PersonalStarRecord starRecord = new PersonalStarRecord();
starRecord.setWechatUserId(wechatUserId);
starRecord.setStarCount(MedalContants.FIRST_LOGIN_RECEIVE_STAR_COUNT);
starRecord.setType(StarReceiveTypeEnum.FIRST_LOGIN.key);
starRecord.setReceiveDate(receiveDate);
starRecord.setCreateTime(date);
personalStarRecordDao.insert(starRecord);
}
if(count != null && count > 0){
return;
}
......@@ -162,25 +184,35 @@ public class PersonalMedalBizImpl implements PersonalMedalBiz {
@Override
@ParamLog("分享")
public String shareMedal(Long medalId, Long wechatUserId, String robotWxId) {
public String shareMedal(Long wechatUserId, String robotWxId) {
// 获取用户基本信息
WechatUser wechatUser = readerConsr.getWechatUser(wechatUserId);
Integer loginDays = getLoginDays(wechatUserId);
// 获取小号信息
PcloudRobot pcloudRobot = pcloudRobotBiz.getPcloudRobotByWxId(robotWxId);
PcloudRobotClassify pcloudRobotClassify = null;
if (null != pcloudRobot){
pcloudRobotClassify = pcloudRobotClassifyBiz.getClassifyById(Long.valueOf(pcloudRobot.getRobotType().toString()));
}
// 获取勋章信息
PersonalMedal medal = personalMedalDao.getById(medalId);
List<PersonalMedalRecordDto> personalMedalRecordDtos = getUserMedalList(wechatUserId);
if(wechatUser == null){
throw new BizException(BizException.DB_DML_FAIL.getCode(), "未找到用户信息");
}
if(pcloudRobot == null){
throw new BizException(BizException.DB_DML_FAIL.getCode(), "未找到小号信息");
}
if(medal == null){
if(ListUtils.isEmpty(personalMedalRecordDtos)){
throw new BizException(BizException.DB_DML_FAIL.getCode(), "未找到勋章信息");
}
// 调用图片生成
String html = buildMedalHtml(medal, wechatUser, pcloudRobot);
String html = null;
if (personalMedalRecordDtos.size() == 1){
//只生成大图
html = buildMedalHtml4Big(personalMedalRecordDtos.get(0), wechatUser, pcloudRobotClassify,loginDays);
}else {
//多个小图
html = buildMedalHtml4Little(personalMedalRecordDtos, wechatUser, pcloudRobotClassify,loginDays);
}
HtmlDto htmlDto=new HtmlDto();
htmlDto.setHeight(1206);
htmlDto.setWidth(750);
......@@ -189,6 +221,64 @@ public class PersonalMedalBizImpl implements PersonalMedalBiz {
return ResponseHandleUtil.parseResponse(htm2ImgService.toJPGByChrome(htmlDto),String.class);
}
private String buildMedalHtml4Little(List<PersonalMedalRecordDto> personalMedalRecordDtos, WechatUser wechatUser, PcloudRobotClassify pcloudRobotClassify, Integer loginDays) {
PersonalShareTemplate personalShareTemplate = personalShareTemplateMapper.selectByPrimaryKey(2);
String html = personalShareTemplate.getContent();
html = html.replace("${headUrl}",wechatUser.getWechatUserHeadurl());
html = html.replace("${nickName}",wechatUser.getWechatUserNickname());
html = html.replace("${loginDays}",loginDays.toString());
html = html.replace("${classifyQrcode}",pcloudRobotClassify.getQrcodeUrl());
html = html.replace("${medalCount}",personalMedalRecordDtos.size()+"");
String medalImg = "";
for(PersonalMedalRecordDto personalMedalRecordDto : personalMedalRecordDtos){
medalImg += "<img src='"+personalMedalRecordDto.getLightImgUrl()+"'class=\"medal\" />";
}
html = html.replace("${medalImgs}",medalImg);
return html;
}
private String buildMedalHtml4Big(PersonalMedalRecordDto personalMedalRecordDto, WechatUser wechatUser, PcloudRobotClassify pcloudRobotClassify, Integer loginDays) {
PersonalShareTemplate personalShareTemplate = personalShareTemplateMapper.selectByPrimaryKey(1);
String html = personalShareTemplate.getContent();
html = html.replace("${headUrl}",wechatUser.getWechatUserHeadurl());
html = html.replace("${nickName}",wechatUser.getWechatUserNickname());
html = html.replace("${loginDays}",loginDays.toString());
html = html.replace("${classifyQrcode}",pcloudRobotClassify.getQrcodeUrl());
return html;
}
@Override
public Integer getRanking(Long wechatUserId) {
Integer ranking=0;
List<PersonalStarReceiveDto> list= personalStarRecordDao.getReceiveStarCountList();
if(list==null||list.size()==0){
return ranking;
}
for (int i=0;i<=list.size()-1;i++){
PersonalStarReceiveDto personalStarReceiveDto = list.get(i);
if(personalStarReceiveDto.getWechatUserId().equals(wechatUserId)){
ranking=i+1;
return ranking;
}
}
return ranking;
}
@Override
public Integer getLoginDays(Long wechatUserId) {
return personalStarRecordDao.getLoginDays(wechatUserId);
}
@Override
public Integer getMedalAllDays(Long wechatUserId, Integer medalDays) {
Integer conut= personalStarRecordDao.getTaskCount(wechatUserId);
Integer medalAllDays=medalDays-(conut*30)-30;
return medalAllDays;
}
private String buildMedalHtml(PersonalMedal medal, WechatUser wechatUser, PcloudRobot pcloudRobot) {
return "<!DOCTYPE html>\n" +
"<html lang=\"en\">\n" +
......
......@@ -6,9 +6,12 @@ public class MedalContants {
public static final Integer LOGIN_RECEIVE_STAR_COUNT = 1;
// 完善基本信息领取星星数
public static final Integer BASE_INFO_RECEIVE_STAR_COUNT = 15;
public static final Integer BASE_INFO_RECEIVE_STAR_COUNT = 30;
// 完善我喜欢的频道领取星星数
public static final Integer LIKE_RECEIVE_STAR_COUNT = 15;
public static final Integer LIKE_RECEIVE_STAR_COUNT = 30;
// 第一次登陆领取30颗星星
public static final Integer FIRST_LOGIN_RECEIVE_STAR_COUNT = 30;
}
package com.pcloud.book.personal.dao;
import com.pcloud.book.personal.dto.PersonalStarReceiveDto;
import com.pcloud.book.personal.entity.PersonalStarRecord;
import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
public interface PersonalStarRecordDao extends BaseDao<PersonalStarRecord> {
Integer hasReceive(Long wechatUserId, String receiveDate, Integer type);
Integer getReceiveStarCount(Long wechatUserId);
Integer insert4Type(PersonalStarRecord personalStarRecord);
Integer hasReceiveFirstLogin(Long wechatUserId, Integer type);
List<PersonalStarReceiveDto> getReceiveStarCountList();
Integer getLoginDays(Long wechatUserId);
Integer getTaskCount(Long wechatUserId);
}
......@@ -2,11 +2,13 @@ package com.pcloud.book.personal.dao.impl;
import com.google.common.collect.Maps;
import com.pcloud.book.personal.dao.PersonalStarRecordDao;
import com.pcloud.book.personal.dto.PersonalStarReceiveDto;
import com.pcloud.book.personal.entity.PersonalStarRecord;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Repository;
import java.util.HashMap;
import java.util.List;
@Repository("personalStarRecordDao")
public class PersonalStarRecordDaoImpl extends BaseDaoImpl<PersonalStarRecord> implements PersonalStarRecordDao {
......@@ -30,4 +32,32 @@ public class PersonalStarRecordDaoImpl extends BaseDaoImpl<PersonalStarRecord> i
public Integer insert4Type(PersonalStarRecord personalStarRecord) {
return super.getSqlSession().insert(getStatement("insert4Type"), personalStarRecord);
}
@Override
public Integer hasReceiveFirstLogin(Long wechatUserId, Integer type) {
HashMap<String, Object> map = Maps.newHashMap();
map.put("wechatUserId", wechatUserId);
map.put("type",type);
return super.getSqlSession().selectOne(getStatement("hasReceive"), map);
}
@Override
public List<PersonalStarReceiveDto> getReceiveStarCountList() {
return getSessionTemplate().selectList(getStatement("getReceiveStarCountList"));
}
@Override
public Integer getLoginDays(Long wechatUserId) {
HashMap<String, Object> map = Maps.newHashMap();
map.put("wechatUserId", wechatUserId);
return super.getSqlSession().selectOne(getStatement("getLoginDays"), map);
}
@Override
public Integer getTaskCount(Long wechatUserId) {
HashMap<String, Object> map = Maps.newHashMap();
map.put("wechatUserId", wechatUserId);
return super.getSqlSession().selectOne(getStatement("getTaskCount"), map);
}
}
......@@ -14,4 +14,6 @@ public class PersonalMedalRecordDto{
private Integer hasShow;
private String bigImgUrl;
private String lightImgUrl;
}
\ No newline at end of file
package com.pcloud.book.personal.dto;
import lombok.Data;
@Data
public class PersonalStarReceiveDto {
private Long wechatUserId;
private Integer startCount;
}
\ No newline at end of file
......@@ -15,6 +15,8 @@ public class PersonalMedal extends BaseEntity {
private String bigImgUrl;
private String bigGreyImgUrl;
private String medalName;
private String content;
......
package com.pcloud.book.personal.entity;
import java.util.Date;
public class PersonalShareTemplate {
private Integer id;
private Byte type;
private Date createTime;
private Date updateTime;
private String content;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Byte getType() {
return type;
}
public void setType(Byte type) {
this.type = type;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content == null ? null : content.trim();
}
}
\ No newline at end of file
......@@ -4,7 +4,8 @@ public enum StarReceiveTypeEnum {
LOGIN(1, "每日登录领取"),
BASE_INFO(2,"完善基础信息"),
LIKE(3,"喜欢的频道");
LIKE(3,"喜欢的频道"),
FIRST_LOGIN(4,"第一次登陆领取30颗星星");
public final Integer key;
public final String desc;
......
......@@ -40,6 +40,16 @@ public class PersonalMedalFacade {
return new ResponseDto<>(personalMedalBiz.getUserMedalList(wechatUserId));
}
@ApiOperation("获取用户已获得的勋章")
@GetMapping("getUserMedalListCount")
public ResponseDto<?> getUserMedalListCount(@CookieValue("userInfo") String userInfo) throws PermissionException {
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
if(!NumberUtil.isNumber(wechatUserId)){
throw new BizException(BizException.PARAM_IS_NULL.getCode(), "wechatUserId 不能为空");
}
return new ResponseDto<>(personalMedalBiz.getUserMedalList(wechatUserId).size());
}
@ApiOperation("登录获取勋章")
@GetMapping("loginReceiveStar")
public ResponseDto<?> loginReceiveStar(@CookieValue("userInfo") String userInfo) throws PermissionException {
......@@ -85,12 +95,45 @@ public class PersonalMedalFacade {
@ApiOperation("分享")
@GetMapping("shareMedal")
public ResponseDto<?> shareMedal(@CookieValue("userInfo") String userInfo,@RequestParam Long medalId, @RequestParam String robotWxId){
public ResponseDto<?> shareMedal(@CookieValue("userInfo") String userInfo, @RequestParam String robotWxId){
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
if(!NumberUtil.isNumber(wechatUserId)){
throw new BizException(BizException.PARAM_IS_NULL.getCode(), "wechatUserId 不能为空");
}
return new ResponseDto<>(personalMedalBiz.shareMedal(wechatUserId, robotWxId));
}
@ApiOperation("获取排名")
@GetMapping("getRanking")
public ResponseDto<?> getRanking(@CookieValue("userInfo") String userInfo){
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
if(!NumberUtil.isNumber(wechatUserId)){
throw new BizException(BizException.PARAM_IS_NULL.getCode(), "wechatUserId 不能为空");
}
return new ResponseDto<>(personalMedalBiz.getRanking(wechatUserId));
}
@ApiOperation("获取陪伴天数")
@GetMapping("getLoginDays")
public ResponseDto<?> getLoginDays(@CookieValue("userInfo") String userInfo){
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
if(!NumberUtil.isNumber(wechatUserId)){
throw new BizException(BizException.PARAM_IS_NULL.getCode(), "wechatUserId 不能为空");
}
return new ResponseDto<>(personalMedalBiz.getLoginDays(wechatUserId));
}
@ApiOperation("获取勋章陪伴总天数")
@GetMapping("getMedalAllDays")
public ResponseDto<?> getMedalAllDays(@CookieValue("userInfo") String userInfo,@RequestParam Integer medalDays){
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
if(!NumberUtil.isNumber(wechatUserId)){
throw new BizException(BizException.PARAM_IS_NULL.getCode(), "wechatUserId 不能为空");
}
return new ResponseDto<>(personalMedalBiz.shareMedal(medalId, wechatUserId, robotWxId));
return new ResponseDto<>(personalMedalBiz.getMedalAllDays(wechatUserId,medalDays));
}
}
package com.pcloud.book.personal.mapper;
import com.pcloud.book.personal.entity.PersonalShareTemplate;
import org.springframework.stereotype.Component;
@Component
public interface PersonalShareTemplateMapper {
int deleteByPrimaryKey(Integer id);
int insert(PersonalShareTemplate record);
int insertSelective(PersonalShareTemplate record);
PersonalShareTemplate selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(PersonalShareTemplate record);
int updateByPrimaryKeyWithBLOBs(PersonalShareTemplate record);
int updateByPrimaryKey(PersonalShareTemplate record);
}
\ No newline at end of file
......@@ -38,7 +38,7 @@
selectByExampleQueryId="false">
</table>-->
<table tableName="pcloud_label" domainObjectName="pcloudLabel"
<table tableName="personal_share_template" domainObjectName="PersonalShareTemplate"
enableCountByExample="false" enableUpdateByExample="false"
enableDeleteByExample="false" enableSelectByExample="false"
selectByExampleQueryId="false">
......
......@@ -6,6 +6,7 @@
<result column="grey_img_url" property="greyImgUrl" jdbcType="VARCHAR" />
<result column="light_img_url" property="lightImgUrl" jdbcType="VARCHAR" />
<result column="big_img_url" property="bigImgUrl" jdbcType="VARCHAR" />
<result column="big_grey_img_url" property="bigGreyImgUrl" jdbcType="VARCHAR" />
<result column="medal_name" property="medalName" jdbcType="VARCHAR" />
<result column="content" property="content" jdbcType="VARCHAR" />
<result column="star_limit_count" property="starLimitCount" jdbcType="INTEGER" />
......@@ -14,7 +15,7 @@
</resultMap>
<sql id="Base_Column_List" >
id, grey_img_url, light_img_url, big_img_url, medal_name, content, star_limit_count, create_time, update_time
id, grey_img_url, light_img_url, big_img_url,big_grey_img_url, medal_name, content, star_limit_count, create_time, update_time
</sql>
<select id="getById" resultMap="BaseResultMap" parameterType="java.lang.Long" >
......@@ -42,10 +43,10 @@
</delete>
<insert id="insert" parameterType="com.pcloud.book.personal.entity.PersonalMedal" >
insert into personal_medal (id, grey_img_url, light_img_url, big_img_url, medal_name, content,
insert into personal_medal (id, grey_img_url, light_img_url, big_img_url,big_grey_img_url, medal_name, content,
star_limit_count, create_time, update_time
)
values (#{id,jdbcType=BIGINT}, #{greyImgUrl,jdbcType=VARCHAR},#{lightImgUrl,jdbcType=VARCHAR},#{bigImgUrl,jdbcType=VARCHAR}, #{medalName,jdbcType=VARCHAR}, #{content,jdbcType=VARCHAR},
values (#{id,jdbcType=BIGINT}, #{greyImgUrl,jdbcType=VARCHAR},#{lightImgUrl,jdbcType=VARCHAR},#{bigImgUrl,jdbcType=VARCHAR},#{bigGreyImgUrl,jdbcType=VARCHAR}, #{medalName,jdbcType=VARCHAR}, #{content,jdbcType=VARCHAR},
#{starLimitCount,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}
)
</insert>
......
......@@ -26,7 +26,8 @@
a.medal_id medalId,
a.wechat_user_id wechatUserId,
a.has_show hasShow,
b.big_img_url bigImgUrl
b.big_img_url bigImgUrl,
b.light_img_url lightImgUrl
from personal_medal_record a,personal_medal b
where a.medal_id = b.id AND a.wechat_user_id = #{wechatUserId,jdbcType=BIGINT}
</select>
......
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.pcloud.book.personal.mapper.PersonalShareTemplateMapper" >
<resultMap id="BaseResultMap" type="com.pcloud.book.personal.entity.PersonalShareTemplate" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="type" property="type" jdbcType="TINYINT" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
</resultMap>
<resultMap id="ResultMapWithBLOBs" type="com.pcloud.book.personal.entity.PersonalShareTemplate" extends="BaseResultMap" >
<result column="content" property="content" jdbcType="LONGVARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
id, type, create_time, update_time
</sql>
<sql id="Blob_Column_List" >
content
</sql>
<select id="selectByPrimaryKey" resultMap="ResultMapWithBLOBs" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from personal_share_template
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from personal_share_template
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.pcloud.book.personal.entity.PersonalShareTemplate" >
insert into personal_share_template (id, type, create_time,
update_time, content)
values (#{id,jdbcType=INTEGER}, #{type,jdbcType=TINYINT}, #{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP}, #{content,jdbcType=LONGVARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.pcloud.book.personal.entity.PersonalShareTemplate" >
insert into personal_share_template
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="type != null" >
type,
</if>
<if test="createTime != null" >
create_time,
</if>
<if test="updateTime != null" >
update_time,
</if>
<if test="content != null" >
content,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=INTEGER},
</if>
<if test="type != null" >
#{type,jdbcType=TINYINT},
</if>
<if test="createTime != null" >
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null" >
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="content != null" >
#{content,jdbcType=LONGVARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.pcloud.book.personal.entity.PersonalShareTemplate" >
update personal_share_template
<set >
<if test="type != null" >
type = #{type,jdbcType=TINYINT},
</if>
<if test="createTime != null" >
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null" >
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="content != null" >
content = #{content,jdbcType=LONGVARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="com.pcloud.book.personal.entity.PersonalShareTemplate" >
update personal_share_template
set type = #{type,jdbcType=TINYINT},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
content = #{content,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.pcloud.book.personal.entity.PersonalShareTemplate" >
update personal_share_template
set type = #{type,jdbcType=TINYINT},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>
\ No newline at end of file
......@@ -36,6 +36,11 @@
WHERE wechat_user_id = #{wechatUserId,jdbcType=BIGINT}
</select>
<select id="getReceiveStarCountList" resultType="com.pcloud.book.personal.dto.PersonalStarReceiveDto">
SELECT wechat_user_id wechatUserId, IFNULL(SUM(star_count),0) startCount
FROM `personal_star_record` GROUP BY wechat_user_id order by startCount desc
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
delete from personal_star_record
where id = #{id,jdbcType=BIGINT}
......@@ -46,7 +51,7 @@
INSERT INTO personal_star_record (wechat_user_id, star_count, type, receive_date, create_time)
SELECT #{wechatUserId,jdbcType=BIGINT}, #{starCount,jdbcType=INTEGER},
#{type,jdbcType=INTEGER}, #{receiveDate,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}
WHERE NOT EXISTS(SELECT 1 FROM `personal_star_record` WHERE wechat_user_id = #{wechatUserId,jdbcType=BIGINT} AND receive_date = #{receiveDate,jdbcType=VARCHAR})
WHERE NOT EXISTS(SELECT 1 FROM `personal_star_record` WHERE wechat_user_id = #{wechatUserId,jdbcType=BIGINT} AND receive_date = #{receiveDate,jdbcType=VARCHAR} and type=#{type})
</insert>
<insert id="insert4Type" parameterType="com.pcloud.book.personal.entity.PersonalStarRecord" useGeneratedKeys="true" keyProperty="id">
......@@ -81,4 +86,12 @@
create_time = #{createTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=BIGINT}
</update>
<select id="getLoginDays" parameterType="map" resultType="int">
select count(1) from personal_star_record where wechat_user_id=#{wechatUserId} and type=1
</select>
<select id="getTaskCount" parameterType="map" resultType="int">
select count(1) from personal_star_record where wechat_user_id=#{wechatUserId} and (type=2 or type=3)
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment