Browse Source

Merge remote-tracking branch 'origin/feature-1.1-dev' into feature-1.1-dev

feature-1.1
wuxicheng 3 years ago
parent
commit
c8ba25be7c
  1. 4
      bnyer-api/bnyer-api-img/src/main/resources/META-INF/spring.factories
  2. 2
      bnyer-api/bnyer-api-order/src/main/resources/META-INF/spring.factories
  3. 5
      bnyer-common/bnyer-common-core/src/main/java/com/bnyer/common/core/constant/RedisKeyConstant.java
  4. 31
      bnyer-common/bnyer-common-core/src/main/java/com/bnyer/common/core/dto/GetGoldDto.java
  5. 6
      bnyer-common/bnyer-common-core/src/main/java/com/bnyer/common/core/dto/checkUserCanDownloadDto.java
  6. 16
      bnyer-common/bnyer-common-core/src/main/java/com/bnyer/common/core/enums/GoldEnum.java
  7. 20
      bnyer-services/bnyer-img/src/main/java/com/bnyer/img/controller/FhMiniController.java
  8. 39
      bnyer-services/bnyer-img/src/main/java/com/bnyer/img/controller/TiktokMiniController.java
  9. 20
      bnyer-services/bnyer-img/src/main/java/com/bnyer/img/controller/WxMiniController.java
  10. 22
      bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/FhUserService.java
  11. 27
      bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/GoldLogService.java
  12. 24
      bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/TiktokUserService.java
  13. 21
      bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/WxUserService.java
  14. 33
      bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/impl/CreatorProfitServiceImpl.java
  15. 69
      bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/impl/FhUserServiceImpl.java
  16. 124
      bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/impl/GoldLogServiceImpl.java
  17. 101
      bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/impl/TiktokUserServiceImpl.java
  18. 69
      bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/impl/WxUserServiceImpl.java
  19. 2
      bnyer-services/bnyer-img/src/main/resources/com/bnyer/img/mapper/GoldLogMapper.xml
  20. 53
      bnyer-services/bnyer-order/src/main/java/com/bnyer/order/config/AlipayConfig.java
  21. 53
      bnyer-services/bnyer-order/src/main/java/com/bnyer/order/config/AlipayOrderConfig.java
  22. 3
      bnyer-services/bnyer-order/src/main/java/com/bnyer/order/config/JsonOrderConfig.java
  23. 2
      bnyer-services/bnyer-order/src/main/java/com/bnyer/order/service/impl/VipOrderServiceImpl.java

4
bnyer-api/bnyer-api-img/src/main/resources/META-INF/spring.factories

@ -1,2 +1,4 @@
org.springframework.boot.autoconfigure.EnableAutoConfiguration = com.bnyer.img.api.factory.RemoteImgFallbackFactory
org.springframework.boot.autoconfigure.EnableAutoConfiguration =\
com.bnyer.img.api.factory.RemoteImgFallbackFactory,\
com.bnyer.img.api.factory.RemoteWxMiniFallbackFactory

2
bnyer-api/bnyer-api-order/src/main/resources/META-INF/spring.factories

@ -0,0 +1,2 @@
org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.bnyer.order.api.factory.RemoteVipOrderFallbackFactory

5
bnyer-common/bnyer-common-core/src/main/java/com/bnyer/common/core/constant/RedisKeyConstant.java

@ -103,6 +103,11 @@ public class RedisKeyConstant {
*/
public static final String PLATFORM_USER_PAINT_REWARD_KEY = "bnyer.img.user.paint.reward:";
/**
* 平台用户签到奖励键
*/
public static final String PLATFORM_USER_SIGN_REWARD_KEY = "bnyer.img.user.sign.reward:";
/**
* 平台用户ai绘画键
*/

31
bnyer-common/bnyer-common-core/src/main/java/com/bnyer/common/core/dto/GetGoldDto.java

@ -0,0 +1,31 @@
package com.bnyer.common.core.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
@Getter
@Setter
@ApiModel("签到获取画意值接收类")
public class GetGoldDto implements Serializable {
private static final long serialVersionUID = -522268377128588554L;
@NotNull(message = "用户id不能为空!")
@ApiModelProperty(value="用户id")
private Long userId;
@NotBlank(message = "应用类型不能为空!")
@ApiModelProperty(value="应用类型(0->次元意境)")
private String appType;
@NotNull(message = "平台渠道不能为空!")
@ApiModelProperty(value="平台(0->Hub;1->抖音;2->快手;3->微信)")
private String source;
}

6
bnyer-common/bnyer-common-core/src/main/java/com/bnyer/common/core/dto/checkUserCanDownloadDto.java

@ -18,14 +18,10 @@ public class checkUserCanDownloadDto implements Serializable {
private Long userId;
@NotNull(message = "平台不能为空!")
@ApiModelProperty(value="平台")
@ApiModelProperty(value="平台(0->抖音;1->快手;2->微信)")
private String platform;
@NotNull(message = "应用不能为空!")
@ApiModelProperty(value="应用")
private String appType;
@NotNull(message = "广告类型不能为空!")
@ApiModelProperty(value="广告类型(0->下载图片;1->绘画奖励)")
private String adType;
}

16
bnyer-common/bnyer-common-core/src/main/java/com/bnyer/common/core/enums/GoldEnum.java

@ -11,18 +11,20 @@ import lombok.Getter;
@Getter
@AllArgsConstructor
public enum GoldEnum {
PAINT("0","AI绘画消耗"),
COUPLE_HEAD("1","情侣头像消耗"),
SIGN("2","签到获得"),
INVITE("3","邀请获得"),
DOWNLOAD_IMG("4","下载图片获得"),
EXCHANGE("5","意心兑换获得"),
BUY_VIP("6","购买会员获得");
PAINT("0","AI绘画消耗",2),
COUPLE_HEAD("1","情侣头像消耗",5),
SIGN("2","签到获得",5),
INVITE("3","邀请获得",30),
WATCH_AD("4","看广告获得",2),
EXCHANGE("5","意心兑换获得",null),
BUY_VIP("6","购买会员获得",300);
private String code;
private String value;
private Integer goldNum;
public static String getValueByCode(String code) {
for (GoldEnum s : GoldEnum.values()) {
if (code.equals(s.code)) {

20
bnyer-services/bnyer-img/src/main/java/com/bnyer/img/controller/FhMiniController.java

@ -238,6 +238,12 @@ public class FhMiniController extends BaseController {
return AjaxResult.success(fhUserService.checkUserCanDownload(dto.getUserId(),dto.getPlatform(),dto.getAppType()));
}
@ApiOperation(value="检查某平台用户当日看广告获取画意值次数是否超标")
@PostMapping(value = "/checkUserCanGetGold")
public AjaxResult checkUserCanGetGold(@Validated @RequestBody @ApiParam("检查超标对象") checkUserCanDownloadDto dto){
return AjaxResult.success(fhUserService.checkUserCanGetGold(dto.getUserId(),dto.getPlatform(),dto.getAppType()));
}
@ApiOperation(value="检查某平台用户当日ai绘画次数是否超标")
@PostMapping(value = "/checkUserCanAiPaint")
public AjaxResult checkUserCanAiPaint(@Validated @RequestBody @ApiParam("检查超标对象") checkUserCanDownloadDto dto){
@ -459,9 +465,15 @@ public class FhMiniController extends BaseController {
return AjaxResult.success(fhUserService.getUserGoldNum(id));
}
@ApiOperation(value="获取某平台用户当日下载/绘画奖励剩余次数")
@PostMapping(value = "/getRestNum")
public AjaxResult getUserDownloadNumOrRewardNum(@Validated @RequestBody @ApiParam("检查超标对象") checkUserCanDownloadDto dto){
return AjaxResult.success(fhUserService.getUserDownloadNumOrRewardNum(dto.getUserId(),dto.getPlatform(),dto.getAppType(),dto.getAdType()));
@ApiOperation(value="获取某平台用户当日下载剩余次数")
@PostMapping(value = "/getRestDownloadNum")
public AjaxResult getUserDownloadNum(@Validated @RequestBody @ApiParam("检查超标对象") checkUserCanDownloadDto dto){
return AjaxResult.success(fhUserService.getUserDownloadNum(dto.getUserId(),dto.getPlatform(),dto.getAppType()));
}
@ApiOperation(value="获取某平台用户当日绘画奖励剩余次数")
@PostMapping(value = "/getRestRewardNum")
public AjaxResult getUserRewardNum(@Validated @RequestBody @ApiParam("检查超标对象") checkUserCanDownloadDto dto){
return AjaxResult.success(fhUserService.getUserRewardNum(dto.getUserId(),dto.getPlatform(),dto.getAppType()));
}
}

39
bnyer-services/bnyer-img/src/main/java/com/bnyer/img/controller/TiktokMiniController.java

@ -240,11 +240,16 @@ public class TiktokMiniController extends BaseController {
}
@ApiOperation(value="检查某平台用户当日下载/绘画奖励次数是否超标")
@ApiOperation(value="检查某平台用户当日下载次数是否超标")
@PostMapping(value = "/checkUserCanDownload")
public AjaxResult checkUserCanDownload(@Validated @RequestBody @ApiParam("检查超标对象") checkUserCanDownloadDto dto){
log.debug("【抖音图文小程序】检查某平台用户当日下载次数是否超标参数为:{}", JSON.toJSONString(dto));
return AjaxResult.success(tiktokUserService.checkUserCanDownload(dto.getUserId(),dto.getPlatform(),dto.getAppType(),dto.getAdType()));
return AjaxResult.success(tiktokUserService.checkUserCanDownload(dto.getUserId(),dto.getPlatform(),dto.getAppType()));
}
@ApiOperation(value="检查某平台用户当日看广告获取画意值次数是否超标")
@PostMapping(value = "/checkUserCanGetGold")
public AjaxResult checkUserCanGetGold(@Validated @RequestBody @ApiParam("检查超标对象") checkUserCanDownloadDto dto){
return AjaxResult.success(tiktokUserService.checkUserCanGetGold(dto.getUserId(),dto.getPlatform(),dto.getAppType()));
}
@ApiOperation(value="检查某平台用户当日ai绘画次数是否超标")
@ -495,10 +500,30 @@ public class TiktokMiniController extends BaseController {
return AjaxResult.success(tiktokUserService.getUserGoldNum(userId));
}
@ApiOperation(value="获取某平台用户当日下载/绘画奖励剩余次数")
@PostMapping(value = "/getRestNum")
public AjaxResult getUserDownloadNumOrRewardNum(@Validated @RequestBody @ApiParam("检查超标对象") checkUserCanDownloadDto dto){
return AjaxResult.success(tiktokUserService.getUserDownloadNumOrRewardNum(dto.getUserId(),dto.getPlatform(),dto.getAppType(),dto.getAdType()));
@ApiOperation(value="获取某平台用户当日下载剩余次数")
@PostMapping(value = "/getRestDownloadNum")
public AjaxResult getUserDownloadNum(@Validated @RequestBody @ApiParam("检查超标对象") checkUserCanDownloadDto dto){
return AjaxResult.success(tiktokUserService.getUserDownloadNum(dto.getUserId(),dto.getPlatform(),dto.getAppType()));
}
@ApiOperation(value="获取某平台用户当日绘画奖励剩余次数")
@PostMapping(value = "/getRestRewardNum")
public AjaxResult getUserRewardNum(@Validated @RequestBody @ApiParam("检查超标对象") checkUserCanDownloadDto dto){
return AjaxResult.success(tiktokUserService.getUserRewardNum(dto.getUserId(),dto.getPlatform(),dto.getAppType()));
}
@ApiOperation(value="会员/用户签到获取画意值")
@PostMapping(value = "/signGetGold")
public AjaxResult signGetGold(@Validated @RequestBody @ApiParam("签到获取画意值对象") GetGoldDto params){
goldLogService.signGetGold(params);
return AjaxResult.success();
}
@ApiOperation(value="会员/用户看广告获取画意值")
@PostMapping(value = "/watchAdGetGold")
public AjaxResult watchAdGetGold(@Validated @RequestBody @ApiParam("看广告获取画意值对象") GetGoldDto params){
goldLogService.watchAdGetGold(params);
return AjaxResult.success();
}
}

20
bnyer-services/bnyer-img/src/main/java/com/bnyer/img/controller/WxMiniController.java

@ -253,6 +253,12 @@ public class WxMiniController extends BaseController {
return AjaxResult.success(wxUserService.checkUserCanDownload(dto.getUserId(),dto.getPlatform(),dto.getAppType()));
}
@ApiOperation(value="检查某平台用户当日看广告获取画意值次数是否超标")
@PostMapping(value = "/checkUserCanGetGold")
public AjaxResult checkUserCanGetGold(@Validated @RequestBody @ApiParam("检查超标对象") checkUserCanDownloadDto dto){
return AjaxResult.success(wxUserService.checkUserCanGetGold(dto.getUserId(),dto.getPlatform(),dto.getAppType()));
}
@ApiOperation(value="检查某平台用户当日ai绘画次数是否超标")
@PostMapping(value = "/checkUserCanAiPaint")
public AjaxResult checkUserCanAiPaint(@Validated @RequestBody @ApiParam("检查超标对象") checkUserCanDownloadDto dto){
@ -485,10 +491,16 @@ public class WxMiniController extends BaseController {
return AjaxResult.success(wxUserService.getUserGoldNum(id));
}
@ApiOperation(value="获取某平台用户当日下载/绘画奖励剩余次数")
@PostMapping(value = "/getRestNum")
public AjaxResult getUserDownloadNumOrRewardNum(@Validated @RequestBody @ApiParam("检查超标对象") checkUserCanDownloadDto dto){
return AjaxResult.success(wxUserService.getUserDownloadNumOrRewardNum(dto.getUserId(),dto.getPlatform(),dto.getAppType(),dto.getAdType()));
@ApiOperation(value="获取某平台用户当日下载剩余次数")
@PostMapping(value = "/getRestDownloadNum")
public AjaxResult getUserDownloadNum(@Validated @RequestBody @ApiParam("检查超标对象") checkUserCanDownloadDto dto){
return AjaxResult.success(wxUserService.getUserDownloadNum(dto.getUserId(),dto.getPlatform(),dto.getAppType()));
}
@ApiOperation(value="获取某平台用户当日绘画奖励剩余次数")
@PostMapping(value = "/getRestRewardNum")
public AjaxResult getUserRewardNum(@Validated @RequestBody @ApiParam("检查超标对象") checkUserCanDownloadDto dto){
return AjaxResult.success(wxUserService.getUserRewardNum(dto.getUserId(),dto.getPlatform(),dto.getAppType()));
}
}

22
bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/FhUserService.java

@ -17,6 +17,15 @@ public interface FhUserService {
*/
boolean checkUserCanDownload(Long userId,String platform,String appType);
/**
* 检查某平台用户当日看广告获取画意值次数是否超标
* @param userId 用户id
* @param platform 平台
* @param appType 应用
* @return -
*/
boolean checkUserCanGetGold(Long userId,String platform,String appType);
/**
* 检查某平台用户当日ai绘画次数是否超标
* @param userId 用户id
@ -53,13 +62,22 @@ public interface FhUserService {
*/
int getUserGoldNum(Long id);
/**
* 获取某平台用户剩余可下载图片/获取画意值奖励次数
* @param userId 用户id
* @param platform 平台
* @param appType 应用
* @param adType 广告类型
* @return -
*/
int getUserDownloadNumOrRewardNum(Long userId,String platform,String appType,String adType);
int getUserDownloadNum(Long userId,String platform,String appType);
/**
* 获取某平台用户剩余可获取画意值奖励次数
* @param userId 用户id
* @param platform 平台
* @param appType 应用
* @return -
*/
int getUserRewardNum(Long userId,String platform,String appType);
}

27
bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/GoldLogService.java

@ -1,6 +1,8 @@
package com.bnyer.img.service;
import com.bnyer.common.core.domain.GoldLog;
import com.bnyer.common.core.dto.GetGoldDto;
import com.bnyer.common.rocketmq.domain.img.GoldRewardMessage;
import com.bnyer.img.vo.GoldLogVo;
import java.util.List;
@ -21,4 +23,29 @@ public interface GoldLogService {
* @return -
*/
List<GoldLogVo> queryPage(Long userId, String source);
/**
* 构建画意值奖励消息体
* @param userId 用户id
* @param goldNum 奖励/消耗画意值
* @param platform 平台
* @param userClientType 用户客户端类型
* @param goldCode 画意值枚举类编码
* @return -
*/
GoldRewardMessage buildGoldRewardMsg(Long userId, int goldNum, String goldCode, String platform, Integer userClientType);
/**
* 签到获取画意值
* @param param 签到数据
*/
void signGetGold(GetGoldDto param);
/**
* 看广告获取画意值
* @param param 看广告参数
*/
void watchAdGetGold(GetGoldDto param);
}

24
bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/TiktokUserService.java

@ -12,10 +12,18 @@ public interface TiktokUserService {
* @param userId 用户id
* @param platform 平台
* @param appType 应用
* @param adType 广告类型
* @return -
*/
boolean checkUserCanDownload(Long userId,String platform,String appType,String adType);
boolean checkUserCanDownload(Long userId,String platform,String appType);
/**
* 检查某平台用户当日看广告获取画意值次数是否超标
* @param userId 用户id
* @param platform 平台
* @param appType 应用
* @return -
*/
boolean checkUserCanGetGold(Long userId,String platform,String appType);
/**
* 检查某平台用户当日ai绘画次数是否超标
@ -58,8 +66,16 @@ public interface TiktokUserService {
* @param userId 用户id
* @param platform 平台
* @param appType 应用
* @param adType 广告类型
* @return -
*/
int getUserDownloadNumOrRewardNum(Long userId,String platform,String appType,String adType);
int getUserDownloadNum(Long userId,String platform,String appType);
/**
* 获取某平台用户剩余可获取画意值奖励次数
* @param userId 用户id
* @param platform 平台
* @param appType 应用
* @return -
*/
int getUserRewardNum(Long userId,String platform,String appType);
}

21
bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/WxUserService.java

@ -16,6 +16,15 @@ public interface WxUserService {
*/
boolean checkUserCanDownload(Long userId,String platform,String appType);
/**
* 检查某平台用户当日看广告获取画意值次数是否超标
* @param userId 用户id
* @param platform 平台
* @param appType 应用
* @return -
*/
boolean checkUserCanGetGold(Long userId,String platform,String appType);
/**
* 检查某平台用户当日ai绘画次数是否超标
* @param userId 用户id
@ -57,8 +66,16 @@ public interface WxUserService {
* @param userId 用户id
* @param platform 平台
* @param appType 应用
* @param adType 广告类型
* @return -
*/
int getUserDownloadNumOrRewardNum(Long userId,String platform,String appType,String adType);
int getUserDownloadNum(Long userId,String platform,String appType);
/**
* 获取某平台用户剩余可获取画意值奖励次数
* @param userId 用户id
* @param platform 平台
* @param appType 应用
* @return -
*/
int getUserRewardNum(Long userId,String platform,String appType);
}

33
bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/impl/CreatorProfitServiceImpl.java

@ -20,6 +20,7 @@ import com.bnyer.common.rocketmq.template.RocketMQEnhanceTemplate;
import com.bnyer.img.mapper.CreatorProfitMapper;
import com.bnyer.img.mapper.InviteLogMapper;
import com.bnyer.img.service.CreatorProfitService;
import com.bnyer.img.service.GoldLogService;
import com.bnyer.img.service.ImgMqMessageRecordService;
import com.bnyer.img.service.TiktokImgService;
import com.bnyer.img.vo.*;
@ -60,6 +61,9 @@ public class CreatorProfitServiceImpl implements CreatorProfitService {
@Resource
private ImgMqMessageRecordService mqMessageRecordService;
@Autowired
private GoldLogService goldLogService;
@Override
public boolean checkCreatorProfitExist(String mark) {
CreatorProfit creatorProfit = creatorProfitMapper.checkCreatorProfitExist(mark);
@ -136,38 +140,9 @@ public class CreatorProfitServiceImpl implements CreatorProfitService {
}
int insert = creatorProfitMapper.insert(creatorProfit);
log.info("新增艺术家【{}】图片【{}】应用【{}】平台【{}】收益记录", creatorProfit.getCreatorId(), creatorProfit.getImgId(), creatorProfit.getAppType(), creatorProfit.getPlatform());
//发送下图画意值奖励并写入记录消息
GoldRewardMessage msg = buildGoldRewardMsg(params.getUserId(), 2, GoldEnum.DOWNLOAD_IMG.getCode(), params.getPlatform(), null);
// rocketMQEnhanceTemplate.sendAsyncMsg(RocketMqTopic.GOLD_REWARD_TOPIC,null,msg);
mqMessageRecordService.sendAsyncMsg(RocketMqTopic.GOLD_REWARD_TOPIC,null,msg);
return insert;
}
/**
* 构建画意值奖励消息体
* @param userId 用户id
* @param goldNum 奖励/消耗画意值
* @param platform 平台
* @param userClientType 用户客户端类型
* @param goldCode 画意值枚举类编码
* @return -
*/
private GoldRewardMessage buildGoldRewardMsg(Long userId, int goldNum, String goldCode, String platform, Integer userClientType) {
GoldRewardMessage message = new GoldRewardMessage();
message.setUserId(userId);
message.setGoldNum(goldNum);
message.setGoldCode(goldCode);
if(StringUtils.isNotNull(platform)){
message.setPlatform(platform);
}
if(StringUtils.isNotNull(userClientType)){
message.setUserClientType(userClientType);
}
return message;
}
@Override
@Transactional(rollbackFor = Exception.class)
public void insertInvitedProfit(CreatorProfit creatorProfit) {

69
bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/impl/FhUserServiceImpl.java

@ -142,6 +142,27 @@ public class FhUserServiceImpl implements FhUserService {
}
}
@Override
public boolean checkUserCanGetGold(Long userId, String platform, String appType) {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
String date = df.format(new Date());
String hashKey = appType+":"+platform+":"+userId;
//看广告获取画意值奖励最多每天5次
String rewardKey = RedisKeyConstant.PLATFORM_USER_PAINT_REWARD_KEY + date;
if(redisService.hasHashKey(rewardKey,hashKey)){
//存在键,判断次数,次数达标则不可再获取奖励
Integer rewardNum = redisService.getCacheMapValue(rewardKey, hashKey);
if(rewardNum >= 5){
return true;
}else{
return false;
}
}else{
//不存在键则可获取奖励
return false;
}
}
@Override
public boolean checkUserCanAiPaint(Long userId, String platform, String appType) {
//查询用户信息
@ -197,32 +218,36 @@ public class FhUserServiceImpl implements FhUserService {
}
@Override
public int getUserDownloadNumOrRewardNum(Long userId, String platform, String appType, String adType) {
public int getUserDownloadNum(Long userId, String platform, String appType) {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
String date = df.format(new Date());
String hashKey = appType+":"+platform+":"+userId;
if(adType.equals("0")){
//下载图片广告最多每天5次
String downloadKey = RedisKeyConstant.PLATFORM_USER_DOWNLOAD_KEY + date;
if(redisService.hasHashKey(downloadKey,hashKey)){
//存在键,判断次数,次数达标则不可下载
Integer downloadNum = redisService.getCacheMapValue(downloadKey, hashKey);
return 5 - downloadNum;
}else{
//不存在键则可下载次数为最大值
return 5;
}
//下载图片广告最多每天5次
String downloadKey = RedisKeyConstant.PLATFORM_USER_DOWNLOAD_KEY + date;
if(redisService.hasHashKey(downloadKey,hashKey)){
//存在键,判断次数,次数达标则不可下载
Integer downloadNum = redisService.getCacheMapValue(downloadKey, hashKey);
return 5 - downloadNum;
}else{
//看广告获取绘画奖励广告最多每天3次
String rewardKey = RedisKeyConstant.PLATFORM_USER_PAINT_REWARD_KEY + date;
if(redisService.hasHashKey(rewardKey,hashKey)){
//存在键,判断次数,次数达标则不可再获取奖励
Integer rewardNum = redisService.getCacheMapValue(rewardKey, hashKey);
return 3 - rewardNum;
}else{
//不存在键则可得到获取奖励最大值
return 3;
}
//不存在键则可下载次数为最大值
return 5;
}
}
@Override
public int getUserRewardNum(Long userId, String platform, String appType) {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
String date = df.format(new Date());
String hashKey = appType+":"+platform+":"+userId;
//看广告获取绘画奖励广告最多每天5次
String rewardKey = RedisKeyConstant.PLATFORM_USER_PAINT_REWARD_KEY + date;
if(redisService.hasHashKey(rewardKey,hashKey)){
//存在键,判断次数,次数达标则不可再获取奖励
Integer rewardNum = redisService.getCacheMapValue(rewardKey, hashKey);
return 5 - rewardNum;
}else{
//不存在键则可得到获取奖励最大值
return 5;
}
}
}

124
bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/impl/GoldLogServiceImpl.java

@ -1,16 +1,25 @@
package com.bnyer.img.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.bnyer.common.core.constant.RedisKeyConstant;
import com.bnyer.common.core.domain.GoldLog;
import com.bnyer.common.core.dto.GoldLogPageDto;
import com.bnyer.common.core.dto.GetGoldDto;
import com.bnyer.common.core.enums.GoldEnum;
import com.bnyer.common.core.exception.ServiceException;
import com.bnyer.common.core.utils.StringUtils;
import com.bnyer.common.redis.service.RedisService;
import com.bnyer.common.rocketmq.constant.RocketMqTopic;
import com.bnyer.common.rocketmq.domain.img.GoldRewardMessage;
import com.bnyer.img.mapper.GoldLogMapper;
import com.bnyer.img.service.GoldLogService;
import com.bnyer.img.service.ImgMqMessageRecordService;
import com.bnyer.img.vo.GoldLogVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
@ -21,6 +30,12 @@ public class GoldLogServiceImpl implements GoldLogService {
@Autowired
private GoldLogMapper goldLogMapper;
@Autowired
private RedisService redisService;
@Resource
private ImgMqMessageRecordService mqMessageRecordService;
@Override
@Transactional(rollbackFor = Exception.class)
public int insert(GoldLog goldLog) {
@ -34,4 +49,109 @@ public class GoldLogServiceImpl implements GoldLogService {
public List<GoldLogVo> queryPage(Long userId, String source) {
return goldLogMapper.queryPage(userId,source);
}
@Override
public void signGetGold(GetGoldDto param) {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
String date = df.format(new Date());
String redisKey = RedisKeyConstant.PLATFORM_USER_SIGN_REWARD_KEY + date;
String hashKey = param.getAppType()+":"+param.getSource()+":"+param.getUserId();
//判断redis中是否存在签到数据,有则提示当日已签到,否则则进行签到,发送mq消息写入缓存,给予奖励,写入奖励记录
if(redisService.hasHashKey(redisKey,hashKey)){
throw new ServiceException("今日已签到,请明日再来!",400);
}else{
//签到
redisService.hashIncr(redisKey,hashKey,1);
//发送签到画意值奖励并写入记录消息(此处0->抖音;1->快手;2->微信)
GoldRewardMessage msg = null;
switch (param.getSource()){
case "1":
//抖音
msg = buildGoldRewardMsg(param.getUserId(),GoldEnum.SIGN.getGoldNum(),GoldEnum.SIGN.getCode(),"0",null);
break;
case "2":
//快手
msg = buildGoldRewardMsg(param.getUserId(),GoldEnum.SIGN.getGoldNum(),GoldEnum.SIGN.getCode(),"1",null);
break;
case "3":
//微信
msg = buildGoldRewardMsg(param.getUserId(),GoldEnum.SIGN.getGoldNum(),GoldEnum.SIGN.getCode(),"2",null);
break;
}
mqMessageRecordService.sendAsyncMsg(RocketMqTopic.GOLD_REWARD_TOPIC,null,msg);
}
}
@Override
public void watchAdGetGold(GetGoldDto param) {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
String date = df.format(new Date());
String redisKey = RedisKeyConstant.PLATFORM_USER_PAINT_REWARD_KEY + date;
String hashKey = param.getAppType()+":"+param.getSource()+":"+param.getUserId();
//判断redis中是否观看广告次数大于等于5,有则提示当日已完成观看任务,否则发送mq消息写入缓存,给予奖励,写入奖励记录
if(redisService.hasHashKey(redisKey,hashKey)){
Integer watchAdNum = redisService.getCacheMapValue(redisKey, hashKey);
if(watchAdNum >= 5){
throw new ServiceException("今日观看任务已完成,请明日再来!",400);
}else{
//写入观看记录
redisService.hashIncr(redisKey,hashKey,1);
//发送观看广告获取画意值奖励并写入记录消息(此处0->抖音;1->快手;2->微信)
GoldRewardMessage msg = null;
switch (param.getSource()){
case "1":
//抖音
msg = buildGoldRewardMsg(param.getUserId(),GoldEnum.WATCH_AD.getGoldNum(),GoldEnum.WATCH_AD.getCode(),"0",null);
break;
case "2":
//快手
msg = buildGoldRewardMsg(param.getUserId(),GoldEnum.WATCH_AD.getGoldNum(),GoldEnum.WATCH_AD.getCode(),"1",null);
break;
case "3":
//微信
msg = buildGoldRewardMsg(param.getUserId(),GoldEnum.WATCH_AD.getGoldNum(),GoldEnum.WATCH_AD.getCode(),"2",null);
break;
}
mqMessageRecordService.sendAsyncMsg(RocketMqTopic.GOLD_REWARD_TOPIC,null,msg);
}
}else{
//不存在,则是第一次观看
//写入观看记录
redisService.hashIncr(redisKey,hashKey,1);
//发送观看广告获取画意值奖励并写入记录消息(此处0->抖音;1->快手;2->微信)
GoldRewardMessage msg = null;
switch (param.getSource()){
case "1":
//抖音
msg = buildGoldRewardMsg(param.getUserId(),GoldEnum.WATCH_AD.getGoldNum(),GoldEnum.WATCH_AD.getCode(),"0",null);
break;
case "2":
//快手
msg = buildGoldRewardMsg(param.getUserId(),GoldEnum.WATCH_AD.getGoldNum(),GoldEnum.WATCH_AD.getCode(),"1",null);
break;
case "3":
//微信
msg = buildGoldRewardMsg(param.getUserId(),GoldEnum.WATCH_AD.getGoldNum(),GoldEnum.WATCH_AD.getCode(),"2",null);
break;
}
mqMessageRecordService.sendAsyncMsg(RocketMqTopic.GOLD_REWARD_TOPIC,null,msg);
}
}
@Override
public GoldRewardMessage buildGoldRewardMsg(Long userId, int goldNum, String goldCode, String platform, Integer userClientType) {
GoldRewardMessage message = new GoldRewardMessage();
message.setUserId(userId);
message.setGoldNum(goldNum);
message.setGoldCode(goldCode);
if(StringUtils.isNotNull(platform)){
message.setPlatform(platform);
}
if(StringUtils.isNotNull(userClientType)){
message.setUserClientType(userClientType);
}
return message;
}
}

101
bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/impl/TiktokUserServiceImpl.java

@ -129,42 +129,45 @@ public class TiktokUserServiceImpl implements TiktokUserService {
}
@Override
public boolean checkUserCanDownload(Long userId, String platform, String appType,String adType) {
public boolean checkUserCanDownload(Long userId, String platform, String appType) {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
String date = df.format(new Date());
String hashKey = appType+":"+platform+":"+userId;
if(adType.equals("0")){
//下载图片广告最多每天5次
String downloadKey = RedisKeyConstant.PLATFORM_USER_DOWNLOAD_KEY + date;
if(redisService.hasHashKey(downloadKey,hashKey)){
//存在键,判断次数,次数达标则不可下载
Integer downloadNum = redisService.getCacheMapValue(downloadKey, hashKey);
if(downloadNum >= 5){
return true;
}else{
return false;
}
//下载图片广告最多每天5次
String downloadKey = RedisKeyConstant.PLATFORM_USER_DOWNLOAD_KEY + date;
if(redisService.hasHashKey(downloadKey,hashKey)){
//存在键,判断次数,次数达标则不可下载
Integer downloadNum = redisService.getCacheMapValue(downloadKey, hashKey);
if(downloadNum >= 5){
return true;
}else{
//不存在键则可下载
return false;
}
}else{
//看广告获取绘画奖励广告最多每天3次
String rewardKey = RedisKeyConstant.PLATFORM_USER_PAINT_REWARD_KEY + date;
if(redisService.hasHashKey(rewardKey,hashKey)){
//存在键,判断次数,次数达标则不可再获取奖励
Integer rewardNum = redisService.getCacheMapValue(rewardKey, hashKey);
if(rewardNum >= 3){
return true;
}else{
return false;
}
//不存在键则可下载
return false;
}
}
@Override
public boolean checkUserCanGetGold(Long userId, String platform, String appType) {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
String date = df.format(new Date());
String hashKey = appType+":"+platform+":"+userId;
//看广告获取画意值奖励最多每天5次
String rewardKey = RedisKeyConstant.PLATFORM_USER_PAINT_REWARD_KEY + date;
if(redisService.hasHashKey(rewardKey,hashKey)){
//存在键,判断次数,次数达标则不可再获取奖励
Integer rewardNum = redisService.getCacheMapValue(rewardKey, hashKey);
if(rewardNum >= 5){
return true;
}else{
//不存在键则可获取奖励
return false;
}
}else{
//不存在键则可获取奖励
return false;
}
}
@Override
@ -222,32 +225,36 @@ public class TiktokUserServiceImpl implements TiktokUserService {
}
@Override
public int getUserDownloadNumOrRewardNum(Long userId, String platform, String appType, String adType) {
public int getUserDownloadNum(Long userId, String platform, String appType) {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
String date = df.format(new Date());
String hashKey = appType+":"+platform+":"+userId;
if(adType.equals("0")){
//下载图片广告最多每天5次
String downloadKey = RedisKeyConstant.PLATFORM_USER_DOWNLOAD_KEY + date;
if(redisService.hasHashKey(downloadKey,hashKey)){
//存在键,判断次数,次数达标则不可下载
Integer downloadNum = redisService.getCacheMapValue(downloadKey, hashKey);
return 5 - downloadNum;
}else{
//不存在键则可下载次数为最大值
return 5;
}
//下载图片广告最多每天5次
String downloadKey = RedisKeyConstant.PLATFORM_USER_DOWNLOAD_KEY + date;
if(redisService.hasHashKey(downloadKey,hashKey)){
//存在键,判断次数,次数达标则不可下载
Integer downloadNum = redisService.getCacheMapValue(downloadKey, hashKey);
return 5 - downloadNum;
}else{
//看广告获取绘画奖励广告最多每天3次
String rewardKey = RedisKeyConstant.PLATFORM_USER_PAINT_REWARD_KEY + date;
if(redisService.hasHashKey(rewardKey,hashKey)){
//存在键,判断次数,次数达标则不可再获取奖励
Integer rewardNum = redisService.getCacheMapValue(rewardKey, hashKey);
return 3 - rewardNum;
}else{
//不存在键则可得到获取奖励最大值
return 3;
}
//不存在键则可下载次数为最大值
return 5;
}
}
@Override
public int getUserRewardNum(Long userId, String platform, String appType) {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
String date = df.format(new Date());
String hashKey = appType+":"+platform+":"+userId;
//看广告获取绘画奖励广告最多每天5次
String rewardKey = RedisKeyConstant.PLATFORM_USER_PAINT_REWARD_KEY + date;
if(redisService.hasHashKey(rewardKey,hashKey)){
//存在键,判断次数,次数达标则不可再获取奖励
Integer rewardNum = redisService.getCacheMapValue(rewardKey, hashKey);
return 5 - rewardNum;
}else{
//不存在键则可得到获取奖励最大值
return 5;
}
}
}

69
bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/impl/WxUserServiceImpl.java

@ -144,6 +144,27 @@ public class WxUserServiceImpl implements WxUserService {
}
}
@Override
public boolean checkUserCanGetGold(Long userId, String platform, String appType) {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
String date = df.format(new Date());
String hashKey = appType+":"+platform+":"+userId;
//看广告获取画意值奖励最多每天5次
String rewardKey = RedisKeyConstant.PLATFORM_USER_PAINT_REWARD_KEY + date;
if(redisService.hasHashKey(rewardKey,hashKey)){
//存在键,判断次数,次数达标则不可再获取奖励
Integer rewardNum = redisService.getCacheMapValue(rewardKey, hashKey);
if(rewardNum >= 5){
return true;
}else{
return false;
}
}else{
//不存在键则可获取奖励
return false;
}
}
@Override
public boolean checkUserCanAiPaint(Long userId, String platform, String appType) {
//查询用户信息
@ -199,32 +220,36 @@ public class WxUserServiceImpl implements WxUserService {
}
@Override
public int getUserDownloadNumOrRewardNum(Long userId, String platform, String appType, String adType) {
public int getUserDownloadNum(Long userId, String platform, String appType) {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
String date = df.format(new Date());
String hashKey = appType+":"+platform+":"+userId;
if(adType.equals("0")){
//下载图片广告最多每天5次
String downloadKey = RedisKeyConstant.PLATFORM_USER_DOWNLOAD_KEY + date;
if(redisService.hasHashKey(downloadKey,hashKey)){
//存在键,判断次数,次数达标则不可下载
Integer downloadNum = redisService.getCacheMapValue(downloadKey, hashKey);
return 5 - downloadNum;
}else{
//不存在键则可下载次数为最大值
return 5;
}
//下载图片广告最多每天5次
String downloadKey = RedisKeyConstant.PLATFORM_USER_DOWNLOAD_KEY + date;
if(redisService.hasHashKey(downloadKey,hashKey)){
//存在键,判断次数,次数达标则不可下载
Integer downloadNum = redisService.getCacheMapValue(downloadKey, hashKey);
return 5 - downloadNum;
}else{
//看广告获取绘画奖励广告最多每天3次
String rewardKey = RedisKeyConstant.PLATFORM_USER_PAINT_REWARD_KEY + date;
if(redisService.hasHashKey(rewardKey,hashKey)){
//存在键,判断次数,次数达标则不可再获取奖励
Integer rewardNum = redisService.getCacheMapValue(rewardKey, hashKey);
return 3 - rewardNum;
}else{
//不存在键则可得到获取奖励最大值
return 3;
}
//不存在键则可下载次数为最大值
return 5;
}
}
@Override
public int getUserRewardNum(Long userId, String platform, String appType) {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
String date = df.format(new Date());
String hashKey = appType+":"+platform+":"+userId;
//看广告获取绘画奖励广告最多每天5次
String rewardKey = RedisKeyConstant.PLATFORM_USER_PAINT_REWARD_KEY + date;
if(redisService.hasHashKey(rewardKey,hashKey)){
//存在键,判断次数,次数达标则不可再获取奖励
Integer rewardNum = redisService.getCacheMapValue(rewardKey, hashKey);
return 5 - rewardNum;
}else{
//不存在键则可得到获取奖励最大值
return 5;
}
}
}

2
bnyer-services/bnyer-img/src/main/resources/com/bnyer/img/mapper/GoldLogMapper.xml

@ -23,7 +23,7 @@
select
id, user_id, gold_num, reason, `source`,create_time
from img_gold_log
where user_id = #{userId} and source = #{source}
where user_id = #{userId} and source = #{source} and is_show = '1'
order by create_time desc
</select>
</mapper>

53
bnyer-services/bnyer-order/src/main/java/com/bnyer/order/config/AlipayConfig.java

@ -1,53 +0,0 @@
package com.bnyer.order.config;
import lombok.Getter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Configuration;
/**
* @author chengkun
* @date 2022/4/21 17:43
*/
@Configuration
@ConfigurationProperties(prefix = "alipay")
@Getter
@RefreshScope
public class AlipayConfig {
@Value("${alipay.gatewayUrl}")
private String gatewayUrl;
@Value("${alipay.appId}")
private String appId;
@Value("${alipay.privateKey}")
private String privateKey;
@Value("${alipay.publicKey}")
private String publicKey;
@Value("${alipay.certPath}")
private String certPath;
@Value("${alipay.alipayPublicCertPath}")
private String alipayPublicCertPath;
@Value("${alipay.rootPath}")
private String rootPath;
@Value("${alipay.notifyUrl}")
private String notifyUrl;
@Value("${alipay.returnUrl}")
private String returnUrl;
@Value("${alipay.signType}")
private String signType;
@Value("${alipay.charset}")
private String charset;
}

53
bnyer-services/bnyer-order/src/main/java/com/bnyer/order/config/AlipayOrderConfig.java

@ -0,0 +1,53 @@
//package com.bnyer.order.config;
//
//
//import lombok.Getter;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.boot.context.properties.ConfigurationProperties;
//import org.springframework.cloud.context.config.annotation.RefreshScope;
//import org.springframework.context.annotation.Configuration;
//
///**
// * @author chengkun
// * @date 2022/4/21 17:43
// */
//@Configuration
//@ConfigurationProperties(prefix = "alipay")
//@Getter
//@RefreshScope
//public class AlipayOrderConfig {
//
// @Value("${alipay.gatewayUrl}")
// private String gatewayUrl;
//
// @Value("${alipay.appId}")
// private String appId;
//
// @Value("${alipay.privateKey}")
// private String privateKey;
//
// @Value("${alipay.publicKey}")
// private String publicKey;
//
// @Value("${alipay.certPath}")
// private String certPath;
//
// @Value("${alipay.alipayPublicCertPath}")
// private String alipayPublicCertPath;
//
// @Value("${alipay.rootPath}")
// private String rootPath;
//
// @Value("${alipay.notifyUrl}")
// private String notifyUrl;
//
// @Value("${alipay.returnUrl}")
// private String returnUrl;
//
// @Value("${alipay.signType}")
// private String signType;
//
// @Value("${alipay.charset}")
// private String charset;
//
//}

3
bnyer-services/bnyer-order/src/main/java/com/bnyer/order/config/JsonConfig.java → bnyer-services/bnyer-order/src/main/java/com/bnyer/order/config/JsonOrderConfig.java

@ -9,12 +9,13 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
import org.springframework.stereotype.Component;
/**
* 解决雪花Id长度超过16位前端传入精度丢失的问题
*/
@Configuration
public class JsonConfig {
public class JsonOrderConfig {
@Bean
@Primary
@ConditionalOnMissingBean(ObjectMapper.class)

2
bnyer-services/bnyer-order/src/main/java/com/bnyer/order/service/impl/VipOrderServiceImpl.java

@ -238,7 +238,7 @@ public class VipOrderServiceImpl implements VipOrderService {
orderMqMessageRecordService.sendAsyncMsg(RocketMqTopic.VIP_RECORD_CREATE_TOPIC,null, addUserVipRecordMessage);
//发送开会员画意值奖励并写入记录消息
GoldRewardMessage goldMsg = buildGoldRewardMsg(vipOrder.getUserId(),300, GoldEnum.BUY_VIP.getCode(),null,vipOrder.getUserClientType());
GoldRewardMessage goldMsg = buildGoldRewardMsg(vipOrder.getUserId(),GoldEnum.BUY_VIP.getGoldNum(), GoldEnum.BUY_VIP.getCode(),null,vipOrder.getUserClientType());
// rocketMQEnhanceTemplate.sendAsyncMsg(RocketMqTopic.GOLD_REWARD_TOPIC,null,goldMsg);
orderMqMessageRecordService.sendAsyncMsg(RocketMqTopic.GOLD_REWARD_TOPIC,null,goldMsg);
}

Loading…
Cancel
Save