Commit f0a225a7 by 吴博

feat:[1003882] 小程序签到

parent 65dc5284
...@@ -22,4 +22,7 @@ public interface GiftCouponService { ...@@ -22,4 +22,7 @@ public interface GiftCouponService {
ResponseEntity<ResponseDto<GiftCouponVo>> getCouponBaseInfo(@RequestParam("couponId") Long couponId) throws BizException; ResponseEntity<ResponseDto<GiftCouponVo>> getCouponBaseInfo(@RequestParam("couponId") Long couponId) throws BizException;
@ApiOperation(value = "签到奖励获取书币兑换券", httpMethod = "POST")
@RequestMapping(value = "/getCoupon4Sign", method = RequestMethod.GET)
ResponseEntity<ResponseDto<GiftCouponVo>> getCoupon4Sign();
} }
...@@ -5,6 +5,8 @@ import com.pcloud.common.entity.BaseEntity; ...@@ -5,6 +5,8 @@ import com.pcloud.common.entity.BaseEntity;
import lombok.Data; import lombok.Data;
import java.util.List;
/** /**
* 专享礼券包表(GiftCouponPackage)实体类 * 专享礼券包表(GiftCouponPackage)实体类
* *
...@@ -68,5 +70,54 @@ public class GiftCouponVo extends BaseEntity { ...@@ -68,5 +70,54 @@ public class GiftCouponVo extends BaseEntity {
*/ */
private AppletThirdResourcesVo appletThirdResources; private AppletThirdResourcesVo appletThirdResources;
/**
* 资源编号
*/
private String resourceNumber;
/**
* 资源价格
*/
private String price;
/**
* 资源描述
*/
private String resourceDesc;
/**
* 划线价
*/
private String crossedPrice;
/**
* 作品还是应用
*/
private String serveType;
/**
* 应用或者作品id
*/
private Long serveId;
private String linkUrl;
/**
* 第三方资源链接id
*/
private Long thirdResourceId;
/**
* 资源描述返回数组
*/
private List<String> desc;
/**
* 作品或者应用信息
*/
private ServeInfoDTO serveInfoDTO;
} }
\ No newline at end of file
...@@ -54,6 +54,7 @@ import com.pcloud.common.utils.DateUtils; ...@@ -54,6 +54,7 @@ import com.pcloud.common.utils.DateUtils;
import com.pcloud.common.utils.ListUtils; import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.cache.redis.JedisClusterUtils; import com.pcloud.common.utils.cache.redis.JedisClusterUtils;
import com.pcloud.common.utils.string.StringUtil; import com.pcloud.common.utils.string.StringUtil;
import com.pcloud.readercenter.common.enums.YesOrNoNumEnum;
import com.pcloud.usercenter.party.adviser.dto.AdviserBaseInfoDto; import com.pcloud.usercenter.party.adviser.dto.AdviserBaseInfoDto;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.MapUtils; import org.apache.commons.collections.MapUtils;
...@@ -61,6 +62,8 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -61,6 +62,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest; import org.springframework.web.multipart.MultipartHttpServletRequest;
import com.pcloud.readercenter.rmall.service.RmallBookMoneyRecordService;
import com.pcloud.readercenter.rmall.entity.RmallBookMoneyRecord;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
...@@ -78,6 +81,8 @@ import java.util.Optional; ...@@ -78,6 +81,8 @@ import java.util.Optional;
import java.util.Random; import java.util.Random;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.pcloud.book.util.common.ThreadPoolUtils.RMALL_SIGN_IN;
/** /**
* 小程序用户书架 * 小程序用户书架
*/ */
...@@ -116,6 +121,8 @@ public class AppletUserBookcaseBizImpl implements AppletUserBookcaseBiz { ...@@ -116,6 +121,8 @@ public class AppletUserBookcaseBizImpl implements AppletUserBookcaseBiz {
private BookDao bookDao; private BookDao bookDao;
@Autowired @Autowired
private AppletThirdResourcesDao appletThirdResourcesDao; private AppletThirdResourcesDao appletThirdResourcesDao;
@Autowired
private RmallBookMoneyRecordService rmallBookMoneyRecordService;
@Override @Override
@ParamLog("小程序用户添加书架") @ParamLog("小程序用户添加书架")
...@@ -138,6 +145,17 @@ public class AppletUserBookcaseBizImpl implements AppletUserBookcaseBiz { ...@@ -138,6 +145,17 @@ public class AppletUserBookcaseBizImpl implements AppletUserBookcaseBiz {
} }
} }
} }
//查询这本书书架中有没有
AppletUserBookcase userBook = appletUserBookcaseDao.getUserReadType(wechatUserId, appletUserBookcase.getBookId(), appletUserBookcase.getAdviserId(), appletUserBookcase.getChannelId());
if (null == userBook) {
RMALL_SIGN_IN.execute(()->{
//收藏埋点
RmallBookMoneyRecord rmallBookMoneyRecord = new RmallBookMoneyRecord();
rmallBookMoneyRecord.setWechatUserId(serveCollect.getWechatUserId());
rmallBookMoneyRecord.setRecordType(MoneyReceiveTypeEnum.NEW_BOOK.key);
rmallBookMoneyRecordService.insert(rmallBookMoneyRecord);
});
}
//数据库去重 //数据库去重
appletUserBookcaseDao.insert(appletUserBookcase); appletUserBookcaseDao.insert(appletUserBookcase);
JedisClusterUtils.del(AppletConstants.USER_BOOK_CASE + wechatUserId); JedisClusterUtils.del(AppletConstants.USER_BOOK_CASE + wechatUserId);
......
...@@ -37,6 +37,8 @@ import org.slf4j.Logger; ...@@ -37,6 +37,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.pcloud.readercenter.rmall.service.RmallBookMoneyRecordService;
import com.pcloud.readercenter.rmall.entity.RmallBookMoneyRecord;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
...@@ -48,6 +50,8 @@ import java.util.concurrent.ExecutionException; ...@@ -48,6 +50,8 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.pcloud.book.util.common.ThreadPoolUtils.RMALL_SIGN_IN;
/** /**
* (ServeCollect)表服务实现类 * (ServeCollect)表服务实现类
* *
...@@ -69,6 +73,8 @@ public class ServeCollectBizImpl implements ServeCollectBiz { ...@@ -69,6 +73,8 @@ public class ServeCollectBizImpl implements ServeCollectBiz {
private QrcodeSceneConsr qrcodeSceneConsr; private QrcodeSceneConsr qrcodeSceneConsr;
@Autowired @Autowired
private AppletNewsBiz appletNewsBiz; private AppletNewsBiz appletNewsBiz;
@Autowired
private RmallBookMoneyRecordService rmallBookMoneyRecordService;
@Override @Override
...@@ -260,6 +266,15 @@ public class ServeCollectBizImpl implements ServeCollectBiz { ...@@ -260,6 +266,15 @@ public class ServeCollectBizImpl implements ServeCollectBiz {
paramCheck(serveCollect); paramCheck(serveCollect);
fillParam(serveCollect); fillParam(serveCollect);
serveCollectDao.insert(serveCollect); serveCollectDao.insert(serveCollect);
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);
}
});
return serveCollect.getId(); return serveCollect.getId();
} }
......
...@@ -322,7 +322,7 @@ public class CultivateNotifyBizImpl implements CultivateNotifyBiz { ...@@ -322,7 +322,7 @@ public class CultivateNotifyBizImpl implements CultivateNotifyBiz {
tempMap = Maps.newHashMap(); tempMap = Maps.newHashMap();
tempMap.put("thing2", cultivateNotifySend.getTitle()); tempMap.put("thing2", cultivateNotifySend.getTitle());
tempMap.put("time3", DateUtils.getLongDateStr()); tempMap.put("time3", DateUtils.getLongDateStr());
tempMap.put("thing7", "小睿有1条新通知提醒一下小主"); tempMap.put("thing7", "您有一条新未读消息");
appletTemplateMessage.setData(tempMap); appletTemplateMessage.setData(tempMap);
templateConsr.sendAppletMessageQueue(appletTemplateMessage); templateConsr.sendAppletMessageQueue(appletTemplateMessage);
} }
......
...@@ -49,4 +49,10 @@ public interface GiftCouponPackageBiz { ...@@ -49,4 +49,10 @@ public interface GiftCouponPackageBiz {
void batchUpdateGift(BatchUpdateDTO batchUpdateDTO); void batchUpdateGift(BatchUpdateDTO batchUpdateDTO);
List<GiftPackageDTO> listGiftPackage4Wechat(Long wechatUserId); List<GiftPackageDTO> listGiftPackage4Wechat(Long wechatUserId);
/**
* 签到奖励获取书币兑换券
* @return
*/
GiftPackageDTO getCoupon4Sign();
} }
...@@ -582,6 +582,23 @@ public class GiftCouponPackageBizImpl implements GiftCouponPackageBiz { ...@@ -582,6 +582,23 @@ public class GiftCouponPackageBizImpl implements GiftCouponPackageBiz {
return result; return result;
} }
@Override
public GiftPackageDTO getCoupon4Sign() {
GiftPackageDTO coupon4Sign = giftCouponPackageDao.getCoupon4Sign();
if (null == coupon4Sign) {
return new GiftPackageDTO();
}
coupon4Sign.setDesc(StringUtils.isEmpty(coupon4Sign.getResourceDesc()) ? new ArrayList<>() : Arrays.stream(coupon4Sign.getResourceDesc().split(",")).collect(Collectors.toList()));
List<GiftPackageDTO> giftPackageDTOS = Arrays.asList(coupon4Sign);
//设置分类
fillCategory(giftPackageDTOS);
//设置应用作品信息
fillAppProductInfo(giftPackageDTOS);
//设置课程券第三方链接
coupon4Sign.setAppletThirdResources(null == coupon4Sign.getThirdResourceId() ? null : appletThirdResourcesDao.getByResourcesId(coupon4Sign.getThirdResourceId()));
return coupon4Sign;
}
private List<Long> setSelectIds(Map<String, Object> map) { private List<Long> setSelectIds(Map<String, Object> map) {
List<Long> list=giftCategoryDao.getByParams(map); List<Long> list=giftCategoryDao.getByParams(map);
Random index = new Random(); Random index = new Random();
......
...@@ -44,4 +44,6 @@ public interface GiftCouponPackageDao extends BaseDao<GiftCouponPackage> { ...@@ -44,4 +44,6 @@ public interface GiftCouponPackageDao extends BaseDao<GiftCouponPackage> {
Integer getByResourceNumber(String resourceNumber,Long packageId); Integer getByResourceNumber(String resourceNumber,Long packageId);
List<GiftPackageDTO> getGiftByIds(List<Long> packageIds); List<GiftPackageDTO> getGiftByIds(List<Long> packageIds);
GiftPackageDTO getCoupon4Sign();
} }
\ No newline at end of file
...@@ -90,4 +90,9 @@ public class GiftCouponPackageDaoImpl extends BaseDaoImpl<GiftCouponPackage> imp ...@@ -90,4 +90,9 @@ public class GiftCouponPackageDaoImpl extends BaseDaoImpl<GiftCouponPackage> imp
map.put("packageIds", packageIds); map.put("packageIds", packageIds);
return super.getSqlSession().selectList(getStatement("getGiftByIds"),map); return super.getSqlSession().selectList(getStatement("getGiftByIds"),map);
} }
@Override
public GiftPackageDTO getCoupon4Sign() {
return getSqlSession().selectOne(getStatement("getCoupon4Sign"));
}
} }
...@@ -186,4 +186,7 @@ public class GiftPackageDTO{ ...@@ -186,4 +186,7 @@ public class GiftPackageDTO{
private Long agentId; private Long agentId;
@ApiModelProperty("是否作为签到奖励")
private Integer isReward;
} }
...@@ -118,4 +118,7 @@ public class GiftCouponPackage extends BaseEntity { ...@@ -118,4 +118,7 @@ public class GiftCouponPackage extends BaseEntity {
@ApiModelProperty("适用分类") @ApiModelProperty("适用分类")
List<GiftCategory> GiftCategoryList; List<GiftCategory> GiftCategoryList;
@ApiModelProperty("是否作为签到奖励")
private Integer isReward;
} }
\ No newline at end of file
...@@ -39,4 +39,12 @@ public class GiftCouponServiceImpl implements GiftCouponService { ...@@ -39,4 +39,12 @@ public class GiftCouponServiceImpl implements GiftCouponService {
giftCouponVo.setAppletThirdResources(appletThirdResources); giftCouponVo.setAppletThirdResources(appletThirdResources);
return ResponseHandleUtil.toResponse(giftCouponVo); return ResponseHandleUtil.toResponse(giftCouponVo);
} }
@Override
public ResponseEntity<ResponseDto<GiftCouponVo>> getCoupon4Sign() {
GiftPackageDTO giftPackage = giftCouponPackageBiz.getCoupon4Sign();
GiftCouponVo giftCouponVo = new GiftCouponVo();
BeanUtils.copyProperties(giftPackage,giftCouponVo);
return ResponseHandleUtil.toResponse(giftCouponVo);
}
} }
...@@ -60,4 +60,8 @@ public class ThreadPoolUtils { ...@@ -60,4 +60,8 @@ public class ThreadPoolUtils {
public static final ExecutorService FILL_APPLET_RECORD = new ThreadPoolExecutor(8,8,0L, TimeUnit.SECONDS, public static final ExecutorService FILL_APPLET_RECORD = new ThreadPoolExecutor(8,8,0L, TimeUnit.SECONDS,
new LinkedBlockingQueue<>(), new ThreadFactoryBuilder().setNameFormat("fill-applet-record-%d").build(), new ThreadPoolExecutor.CallerRunsPolicy()); new LinkedBlockingQueue<>(), new ThreadFactoryBuilder().setNameFormat("fill-applet-record-%d").build(), new ThreadPoolExecutor.CallerRunsPolicy());
public static final ExecutorService RMALL_SIGN_IN = new ThreadPoolExecutor(8,8,0L, TimeUnit.SECONDS,
new LinkedBlockingQueue<>(), new ThreadFactoryBuilder().setNameFormat("rmall_sign_in-%d").build(), new ThreadPoolExecutor.CallerRunsPolicy());
} }
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
<result property="serveId" column="serve_id" jdbcType="BIGINT" /> <result property="serveId" column="serve_id" jdbcType="BIGINT" />
<result property="thirdResourceId" column="third_resource_id" jdbcType="BIGINT" /> <result property="thirdResourceId" column="third_resource_id" jdbcType="BIGINT" />
<result property="onShelves" column="on_shelves" jdbcType="BOOLEAN" /> <result property="onShelves" column="on_shelves" jdbcType="BOOLEAN" />
<result property="isReward" column="is_reward" jdbcType="TINYINT" />
</resultMap> </resultMap>
<resultMap type="com.pcloud.book.giftcoupon.dto.GiftPackageDTO" id="GiftCouplePackageDtoMap"> <resultMap type="com.pcloud.book.giftcoupon.dto.GiftPackageDTO" id="GiftCouplePackageDtoMap">
...@@ -56,12 +57,13 @@ ...@@ -56,12 +57,13 @@
<result property="serveId" column="serve_id" jdbcType="BIGINT" /> <result property="serveId" column="serve_id" jdbcType="BIGINT" />
<result property="thirdResourceId" column="third_resource_id" jdbcType="BIGINT" /> <result property="thirdResourceId" column="third_resource_id" jdbcType="BIGINT" />
<result property="onShelves" column="on_shelves" jdbcType="BOOLEAN" /> <result property="onShelves" column="on_shelves" jdbcType="BOOLEAN" />
<result property="isReward" column="is_reward" jdbcType="TINYINT" />
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, cover_pic, title, valid_date_begin, valid_date_end, denomination, stock, receive_limit, create_time, update_time, is_delete, id, cover_pic, title, valid_date_begin, valid_date_end, denomination, stock, receive_limit, create_time, update_time, is_delete,
coupon_type,instructions,use_type,exchange_address, url_number, agent_id,resource_number,resource_desc, coupon_type,instructions,use_type,exchange_address, url_number, agent_id,resource_number,resource_desc,
price,crossed_price,rec_to_page,serve_type,serve_id,third_resource_id,link_url,on_shelves price,crossed_price,rec_to_page,serve_type,serve_id,third_resource_id,link_url,on_shelves,is_reward
</sql> </sql>
<!--查询单个--> <!--查询单个-->
...@@ -129,10 +131,10 @@ ...@@ -129,10 +131,10 @@
<insert id="insert" parameterType="com.pcloud.book.giftcoupon.entity.GiftCouponPackage" keyProperty="id" useGeneratedKeys="true"> <insert id="insert" parameterType="com.pcloud.book.giftcoupon.entity.GiftCouponPackage" keyProperty="id" useGeneratedKeys="true">
insert into book.gift_coupon_package(cover_pic, title, valid_date_begin, valid_date_end, denomination, stock, receive_limit, create_time, update_time, is_delete, insert into book.gift_coupon_package(cover_pic, title, valid_date_begin, valid_date_end, denomination, stock, receive_limit, create_time, update_time, is_delete,
coupon_type,instructions,use_type,exchange_address,url_number, agent_id,resource_number,resource_desc, coupon_type,instructions,use_type,exchange_address,url_number, agent_id,resource_number,resource_desc,
price,crossed_price,rec_to_page,serve_type,serve_id,third_resource_id,link_url,on_shelves) price,crossed_price,rec_to_page,serve_type,serve_id,third_resource_id,link_url,on_shelves, is_reward)
values (#{coverPic}, #{title}, #{validDateBegin}, #{validDateEnd}, #{denomination}, #{stock}, #{receiveLimit}, now(), now(), 0, values (#{coverPic}, #{title}, #{validDateBegin}, #{validDateEnd}, #{denomination}, #{stock}, #{receiveLimit}, now(), now(), 0,
#{couponType},#{instructions},#{useType},#{exchangeAddress}, #{urlNumber}, #{agentId},#{resourceNumber},#{resourceDesc},#{price} #{couponType},#{instructions},#{useType},#{exchangeAddress}, #{urlNumber}, #{agentId},#{resourceNumber},#{resourceDesc},#{price}
,#{crossedPrice},#{recToPage},#{serveType},#{serveId},#{thirdResourceId},#{linkUrl},#{onShelves}) ,#{crossedPrice},#{recToPage},#{serveType},#{serveId},#{thirdResourceId},#{linkUrl},#{onShelves}, #{isReward})
</insert> </insert>
<!--通过主键修改数据--> <!--通过主键修改数据-->
...@@ -202,6 +204,9 @@ ...@@ -202,6 +204,9 @@
<if test="onShelves != null"> <if test="onShelves != null">
on_shelves = #{onShelves}, on_shelves = #{onShelves},
</if> </if>
<if test="isReward != null">
is_reward = #{isReward},
</if>
update_time = now() update_time = now()
</set> </set>
where id = #{id} where id = #{id}
...@@ -230,7 +235,8 @@ ...@@ -230,7 +235,8 @@
a.url_number urlNumber, a.url_number urlNumber,
a.resource_number resourceNumber, a.resource_number resourceNumber,
a.rec_to_page recToPage, a.rec_to_page recToPage,
a.on_shelves onShelves a.on_shelves onShelves,
a.is_reward isReward
from from
gift_coupon_package a gift_coupon_package a
where a.is_delete=0 where a.is_delete=0
...@@ -458,7 +464,8 @@ ...@@ -458,7 +464,8 @@
a.resource_desc resourceDesc, a.resource_desc resourceDesc,
a.price price, a.price price,
a.crossed_price crossedPrice, a.crossed_price crossedPrice,
a.on_shelves onShelves a.on_shelves onShelves,
a.is_reward isReward
from from
gift_coupon_package a gift_coupon_package a
where a.id in where a.id in
...@@ -466,5 +473,37 @@ ...@@ -466,5 +473,37 @@
${item} ${item}
</foreach> </foreach>
</select> </select>
<select id="getCoupon4Sign" resultType="com.pcloud.book.giftcoupon.dto.GiftPackageDTO">
select
a.id id,
a.title title,
a.cover_pic coverPic,
a.denomination denomination,
a.receive_limit receiveLimit,
a.stock stock,
a.valid_date_begin validDateBegin,
a.valid_date_end validDateEnd,
a.coupon_type couponType,
a.instructions instructions,
a.use_type useType,
a.exchange_address exchangeAddress,
a.url_number urlNumber,
a.resource_number resourceNumber,
a.rec_to_page recToPage,
a.resource_desc resourceDesc,
a.price price,
a.crossed_price crossedPrice,
a.on_shelves onShelves,
a.is_reward isReward
from
gift_coupon_package a
where
a.is_reward = 1
and
on_shelves = 1
and
NOW() <![CDATA[ < ]]> a.valid_date_end
ORDER BY RAND() LIMIT 1
</select>
</mapper> </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