diff --git a/bnyer-api/bnyer-api-img/src/main/resources/META-INF/spring.factories b/bnyer-api/bnyer-api-img/src/main/resources/META-INF/spring.factories index d9e7a5e..46324ca 100644 --- a/bnyer-api/bnyer-api-img/src/main/resources/META-INF/spring.factories +++ b/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 diff --git a/bnyer-api/bnyer-api-order/src/main/resources/META-INF/spring.factories b/bnyer-api/bnyer-api-order/src/main/resources/META-INF/spring.factories new file mode 100644 index 0000000..dda980f --- /dev/null +++ b/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 + diff --git a/bnyer-common/bnyer-common-core/src/main/java/com/bnyer/common/core/constant/RedisKeyConstant.java b/bnyer-common/bnyer-common-core/src/main/java/com/bnyer/common/core/constant/RedisKeyConstant.java index 46d906d..cb8d6bc 100644 --- a/bnyer-common/bnyer-common-core/src/main/java/com/bnyer/common/core/constant/RedisKeyConstant.java +++ b/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绘画键 */ diff --git a/bnyer-common/bnyer-common-core/src/main/java/com/bnyer/common/core/dto/GetGoldDto.java b/bnyer-common/bnyer-common-core/src/main/java/com/bnyer/common/core/dto/GetGoldDto.java new file mode 100644 index 0000000..574227c --- /dev/null +++ b/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; +} diff --git a/bnyer-common/bnyer-common-core/src/main/java/com/bnyer/common/core/dto/checkUserCanDownloadDto.java b/bnyer-common/bnyer-common-core/src/main/java/com/bnyer/common/core/dto/checkUserCanDownloadDto.java index c84fb0c..943a113 100644 --- a/bnyer-common/bnyer-common-core/src/main/java/com/bnyer/common/core/dto/checkUserCanDownloadDto.java +++ b/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; } diff --git a/bnyer-common/bnyer-common-core/src/main/java/com/bnyer/common/core/enums/GoldEnum.java b/bnyer-common/bnyer-common-core/src/main/java/com/bnyer/common/core/enums/GoldEnum.java index 623959f..5cbadcd 100644 --- a/bnyer-common/bnyer-common-core/src/main/java/com/bnyer/common/core/enums/GoldEnum.java +++ b/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)) { diff --git a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/controller/FhMiniController.java b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/controller/FhMiniController.java index c8e9316..d27439f 100644 --- a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/controller/FhMiniController.java +++ b/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())); } } diff --git a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/controller/TiktokMiniController.java b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/controller/TiktokMiniController.java index 3e52a9c..7d1a0fc 100644 --- a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/controller/TiktokMiniController.java +++ b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/controller/TiktokMiniController.java @@ -165,7 +165,7 @@ public class TiktokMiniController extends BaseController { return AjaxResult.success(); } - + @ApiOperation(value="取消收藏") @PostMapping(value = "/tiktokUnCollect") public AjaxResult tiktokUnCollect(@Validated @RequestBody @ApiParam("收藏对象") CollectionDto dto){ @@ -174,7 +174,7 @@ public class TiktokMiniController extends BaseController { return AjaxResult.success(); } - + @ApiOperation(value="查询是否收藏过") @PostMapping(value = "/judgeTiktokCollect") public AjaxResult judgeTiktokCollect(@Validated @RequestBody @ApiParam("收藏对象") CollectionDto dto){ @@ -182,7 +182,7 @@ public class TiktokMiniController extends BaseController { return AjaxResult.success(tiktokCollectionService.judgeCollect(dto.getUserId(),dto.getImgId(),"0")); } - + @ApiOperation(value="查看用户收藏分页") @PostMapping(value = "/listTiktokCollection") public TableDataInfo listTiktokCollection(@Validated @RequestBody @ApiParam("用户收藏对象") CollectionUserDto dto){ @@ -191,7 +191,7 @@ public class TiktokMiniController extends BaseController { return getDataTable(tiktokCollectionService.getCollectionByUserId(dto.getUserId(),"0")); } - + @ApiOperation(value="点赞") @PostMapping(value = "/tiktokLike") public AjaxResult tiktokLike(@Validated @RequestBody @ApiParam("点赞对象") CollectionDto dto){ @@ -200,7 +200,7 @@ public class TiktokMiniController extends BaseController { return AjaxResult.success(); } - + @ApiOperation(value="取消点赞") @PostMapping(value = "/tiktokUnLike") public AjaxResult tiktokUnLike(@Validated @RequestBody @ApiParam("点赞对象") CollectionDto dto){ @@ -209,7 +209,7 @@ public class TiktokMiniController extends BaseController { return AjaxResult.success(); } - + @ApiOperation(value="查询是否点赞过") @PostMapping(value = "/judgeTiktokLike") public AjaxResult judgeTiktokLike(@Validated @RequestBody @ApiParam("点赞对象") CollectionDto dto){ @@ -230,7 +230,7 @@ public class TiktokMiniController extends BaseController { return tiktokUserService.getTiktokLoginUserByLoginParam(dto); } - + @ApiOperation(value="查询首页图片列表") @PostMapping(value = "/imgLists") public TableDataInfo imgLists(@RequestBody @ApiParam("分页对象") BasePageDto dto){ @@ -239,12 +239,17 @@ public class TiktokMiniController extends BaseController { return getDataTable(tiktokImgVos); } - - @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绘画次数是否超标") @@ -254,7 +259,7 @@ public class TiktokMiniController extends BaseController { return AjaxResult.success(tiktokUserService.checkUserCanAiPaint(dto.getUserId(),dto.getPlatform(),dto.getAppType())); } - + @ApiOperation(value="新增/更新艺术家即将入账广告收益") @PostMapping(value = "/insertOrUpdatePreAdProfit") public AjaxResult insertOrUpdatePreAdProfit(@Validated @RequestBody @ApiParam("即将入账广告对象") CreatorProfitAdInsertDto dto){ @@ -262,7 +267,7 @@ public class TiktokMiniController extends BaseController { return AjaxResult.success(creatorProfitService.insertCreatorProfit(dto)); } - + @ApiOperation(value="新增/更新艺术家即将入账邀请收益") @PostMapping(value = "/insertOrUpdatePreInviteProfit") public AjaxResult insertOrUpdatePreInviteProfit(@Validated @RequestBody @ApiParam("即将入账邀请对象") CreatorProfitInviteInsertDto dto){ @@ -271,14 +276,14 @@ public class TiktokMiniController extends BaseController { return AjaxResult.success(); } - + @ApiOperation(value="查询热门艺术家列表") @GetMapping(value = "/listHotCreator") public AjaxResult listHotCreator(){ return AjaxResult.success(creatorService.queryHotCreatorList()); } - + @ApiOperation(value="根据艺术家id获取搜索码") @GetMapping(value = "/queryCreatorScanCodeById/{id}") public AjaxResult queryCreatorScanCodeById(@PathVariable @ApiParam("艺术家id") Long id){ @@ -290,7 +295,7 @@ public class TiktokMiniController extends BaseController { } } - + @ApiOperation(value="查询小程序端标签分页") @PostMapping(value = "/signImgList") public TableDataInfo signImgList(@RequestBody @ApiParam("分页对象") SignTypePageDto dto){ @@ -299,7 +304,7 @@ public class TiktokMiniController extends BaseController { return getDataTable(signImgVos); } - + @ApiOperation(value="根据分类id和标签Id查询图片分页") @PostMapping(value = "/querySignImg") public TableDataInfo querySignImg(@RequestBody @ApiParam("分页对象") SignImgPageDto dto){ @@ -308,7 +313,7 @@ public class TiktokMiniController extends BaseController { return getDataTable(tiktokImgs); } - + @ApiOperation(value="根据标签名称查询图片分页") @PostMapping(value = "/querySignImgBySignName") public TableDataInfo querySignImgBySignName(@RequestBody @ApiParam("分页对象") SignImgNamePageDto dto) { @@ -322,7 +327,7 @@ public class TiktokMiniController extends BaseController { } - + @ApiOperation(value = "八字算命") @PostMapping("/getYs") public AjaxResult getYs(@RequestBody @ApiParam("八字运势") BzDto dto) { @@ -333,7 +338,7 @@ public class TiktokMiniController extends BaseController { return AjaxResult.error(); } - + @ApiOperation(value="支付购买用户会员vip") @PostMapping(value = "/payUserVip") public AjaxResult payUserVip(@Validated @RequestBody @ApiParam("购买会员vip对象") PayUserVipDto dto){ @@ -346,21 +351,21 @@ public class TiktokMiniController extends BaseController { } } - + @ApiOperation(value="查询产品列表") @GetMapping(value = "/listProduct") public AjaxResult listProduct(){ return AjaxResult.success(productService.queryFrontList()); } - + @ApiOperation(value="查询产品详情") @GetMapping(value = "/queryProductDetails/{id}") public AjaxResult queryProductDetails(@ApiParam("主键id") @PathVariable("id") Long id){ return AjaxResult.success(productService.queryFrontDetails(id)); } - + @ApiOperation(value="关注") @PostMapping(value = "/tiktokFollow") public AjaxResult tiktokFollow(@Validated @RequestBody @ApiParam("关注对象") FollowDto dto){ @@ -384,7 +389,7 @@ public class TiktokMiniController extends BaseController { return AjaxResult.success(followService.checkFollow(dto.getUserId(),dto.getCreatorId(),"0")); } - + @ApiOperation(value="查询关注的艺术家分页") @PostMapping(value = "/getTiktokFollowCreatorPage") public TableDataInfo getTiktokFollowCreatorPage(@Validated @RequestBody @ApiParam("用户id对象") UserIdDto dto){ @@ -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(); } } diff --git a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/controller/WxMiniController.java b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/controller/WxMiniController.java index 46e8d28..30674f9 100644 --- a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/controller/WxMiniController.java +++ b/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())); } } diff --git a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/FhUserService.java b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/FhUserService.java index 98af7ed..b63f8c7 100644 --- a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/FhUserService.java +++ b/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); } diff --git a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/GoldLogService.java b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/GoldLogService.java index df18464..ffe1c6b 100644 --- a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/GoldLogService.java +++ b/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 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); + + } diff --git a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/TiktokUserService.java b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/TiktokUserService.java index f4d00ff..d38b68e 100644 --- a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/TiktokUserService.java +++ b/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); } diff --git a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/WxUserService.java b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/WxUserService.java index 33b8a5d..456b795 100644 --- a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/WxUserService.java +++ b/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); } diff --git a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/impl/CreatorProfitServiceImpl.java b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/impl/CreatorProfitServiceImpl.java index 47b4b6c..a7f8b2c 100644 --- a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/impl/CreatorProfitServiceImpl.java +++ b/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) { diff --git a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/impl/FhUserServiceImpl.java b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/impl/FhUserServiceImpl.java index 5d39406..174deeb 100644 --- a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/impl/FhUserServiceImpl.java +++ b/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; } } } diff --git a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/impl/GoldLogServiceImpl.java b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/impl/GoldLogServiceImpl.java index 9c3d9d5..ce6077a 100644 --- a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/impl/GoldLogServiceImpl.java +++ b/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 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; + } } diff --git a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/impl/TiktokUserServiceImpl.java b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/impl/TiktokUserServiceImpl.java index 7ef3027..9e1e37f 100644 --- a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/impl/TiktokUserServiceImpl.java +++ b/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; } } } diff --git a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/impl/WxUserServiceImpl.java b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/impl/WxUserServiceImpl.java index e78239c..6d33d79 100644 --- a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/impl/WxUserServiceImpl.java +++ b/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; } } } diff --git a/bnyer-services/bnyer-img/src/main/resources/com/bnyer/img/mapper/GoldLogMapper.xml b/bnyer-services/bnyer-img/src/main/resources/com/bnyer/img/mapper/GoldLogMapper.xml index 77b18fb..84980aa 100644 --- a/bnyer-services/bnyer-img/src/main/resources/com/bnyer/img/mapper/GoldLogMapper.xml +++ b/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 \ No newline at end of file diff --git a/bnyer-services/bnyer-order/src/main/java/com/bnyer/order/config/AlipayConfig.java b/bnyer-services/bnyer-order/src/main/java/com/bnyer/order/config/AlipayConfig.java deleted file mode 100644 index 1a993bc..0000000 --- a/bnyer-services/bnyer-order/src/main/java/com/bnyer/order/config/AlipayConfig.java +++ /dev/null @@ -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; - -} diff --git a/bnyer-services/bnyer-order/src/main/java/com/bnyer/order/config/AlipayOrderConfig.java b/bnyer-services/bnyer-order/src/main/java/com/bnyer/order/config/AlipayOrderConfig.java new file mode 100644 index 0000000..808afcb --- /dev/null +++ b/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; +// +//} diff --git a/bnyer-services/bnyer-order/src/main/java/com/bnyer/order/config/JsonConfig.java b/bnyer-services/bnyer-order/src/main/java/com/bnyer/order/config/JsonOrderConfig.java similarity index 95% rename from bnyer-services/bnyer-order/src/main/java/com/bnyer/order/config/JsonConfig.java rename to bnyer-services/bnyer-order/src/main/java/com/bnyer/order/config/JsonOrderConfig.java index d0386a0..d0e54dc 100644 --- a/bnyer-services/bnyer-order/src/main/java/com/bnyer/order/config/JsonConfig.java +++ b/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) diff --git a/bnyer-services/bnyer-order/src/main/java/com/bnyer/order/service/impl/VipOrderServiceImpl.java b/bnyer-services/bnyer-order/src/main/java/com/bnyer/order/service/impl/VipOrderServiceImpl.java index 8c0a932..e725614 100644 --- a/bnyer-services/bnyer-order/src/main/java/com/bnyer/order/service/impl/VipOrderServiceImpl.java +++ b/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); }