记得上下班打卡 | git大法好,push需谨慎

Commit cc6afdc1 authored by anjiabin's avatar anjiabin

Merge remote-tracking branch 'origin/master' into ajb_dev_zxinchain_tranfer

parents f5c7522d cf7ccaed
......@@ -280,7 +280,7 @@ create table candy_user_coupon
mcoupon_id varchar(64) comment '~candy_mgt_coupon.mcoupon_id',
uid varchar(64) not null comment '~adam_user.uid',
coupon_id varchar(64) not null comment '~candy_coupon.coupon_id',
state tinyint comment '用户券状态[1-可用|2-无效|3-已过期|5-已使用]',
state tinyint comment '用户券状态[1-可用|2-无效|3-已过期|5-已使用|9-移除不展示(过期或已使用)]',
ccode varchar(64) comment '券码~candy_coupon_code.ccode',
bind_at datetime(3) comment '激活时间',
......@@ -306,7 +306,7 @@ create table candy_common_coupon
ccoupon_id varchar(64) not null,
mcoupon_id varchar(64) not null comment '~candy_mgt_coupon.mcoupon_id',
coupon_id varchar(64) not null comment '~candy_coupon.coupon_id',
state tinyint comment '公有券状态[1-可用|2-无效|3-已过期]',
state tinyint comment '公有券状态[1-可用|2-无效|3-已过期|9-移除不展示(过期)]',
ranged tinyint comment '公有券范围(~candy_mgt_coupon.event_type)',
operator varchar(64) not null comment '操作人',
......
......@@ -136,9 +136,11 @@ public class AdamMemberOrderVo implements Serializable, Cloneable {
this.setState(source.getState());
this.setMemberNo(source.getMemberNo());
this.setBirthday(source.getBirthday());
this.setArea(source.getArea());
this.setDeviceFrom(source.getDeviceFrom());
this.setPayType(source.getPayType());
this.setPayNo(source.getPayNo());
this.setPaymentId(source.getPaymentId());
this.setPaymentAt(source.getPaymentAt());
this.setCreatedAt(source.getCreatedAt());
this.setUpdatedAt(source.getUpdatedAt());
......
......@@ -72,7 +72,7 @@ public class CandyMgtCouponBuildParam {
@Min(value = 1, message = "发放量不能小于1")
@ApiModelProperty(required = true, value = "发放量", example = "1")
private Integer eventAmt;
@ApiModelProperty(required = false, value = "发放类型[0-保留|1-会员|2-手机号|10-全体用户]", allowableValues = "0,1,2,10")
@ApiModelProperty(required = false, value = "发放类型[0-保留|1-会员|2-手机号|10-全体用户]", allowableValues = "0,1,2,10")
private Integer eventType;
@ApiModelProperty(required = false, value = "`发放类型`为2-手机号时发放手机号以,分隔", example = "18510957291,17701223310")
private String eventLimit;
......
......@@ -315,6 +315,9 @@ public class CandyMgtCouponAdminController extends BaseController {
break;
case 3:// 新增券领取类型(3-发放需领取)处理逻辑同(1-发放至用户)
case 1:
if (!Arrays.asList(1, 2, 10).contains(buildParam.getEventType())) {
return AjaxResult.warn("发送类型无效");
}
if (buildParam.getEventType() == 2) {// 指定用户手机号
if (StringUtils.isBlank(buildParam.getEventLimit())) {
return AjaxResult.warn("请指定手机号");
......
......@@ -205,7 +205,7 @@
<span class="labelName">发送类型:</span>
<div class="layui-input-block" style="display: flex">
<!-- <input type="radio" value="10" class="sendType" name="sendType" checked><span>全体用户</span>-->
<input type="radio" value="1" class="sendType" name="sendType"><span>会员</span>
<input type="radio" value="1" class="sendType" name="sendType" checked><span>会员</span>
<input type="radio" value="2" class="sendType" name="sendType"><span>手机号</span>
</div>
</div>
......@@ -254,7 +254,7 @@
let prefix = ctx;
let typeOne = '0'; // 类别
let typeTwo = '0'; // 类型
let sendType = '10'; // 发送类型
let sendType = '1'; // 发送类型
let searchVal = ''; // 输入框内数据
let searchData = []; // 搜索总数据
let showId = ''; // 选中演出id
......
......@@ -201,7 +201,7 @@
<span class="labelName">发送类型:</span>
<div class="layui-input-block" style="display: flex">
<!-- <input type="radio" value="10" class="sendType" name="sendType" checked><span>全体用户</span>-->
<input type="radio" value="1" class="sendType" name="sendType"><span>会员</span>
<input type="radio" value="1" class="sendType" name="sendType" checked><span>会员</span>
<input type="radio" value="2" class="sendType" name="sendType"><span>手机号</span>
</div>
</div>
......@@ -249,7 +249,7 @@
let prefix = ctx;
let typeOne = '3'; // 类别
let typeTwo = '0'; // 类型
let sendType = '10'; // 发送类型
let sendType = '1'; // 发送类型
let searchVal = ''; // 输入框内数据
let searchData = []; // 搜索总数据
let showId = ''; // 选中演出id
......
......@@ -208,7 +208,7 @@
<span class="labelName">发送类型:</span>
<div class="layui-input-block" style="display: flex">
<!-- <input type="radio" value="10" class="sendType" name="sendType" checked><span>全体用户</span>-->
<input type="radio" value="1" class="sendType" name="sendType"><span>会员</span>
<input type="radio" value="1" class="sendType" name="sendType" checked><span>会员</span>
<input type="radio" value="2" class="sendType" name="sendType"><span>手机号</span>
</div>
</div>
......@@ -257,7 +257,7 @@
let prefix = ctx;
let typeOne = '0'; // 类别
let typeTwo = '0'; // 类型
let sendType = '10'; // 发送类型
let sendType = '1'; // 发送类型
let searchVal = ''; // 输入框内数据
let searchData = []; // 搜索总数据
let showId = ''; // 选中演出id
......
......@@ -198,7 +198,7 @@
<span class="labelName">发送类型:</span>
<div class="layui-input-block" style="display: flex">
<!-- <input type="radio" value="10" class="sendType" name="sendType" checked><span>全体用户</span>-->
<input type="radio" value="1" class="sendType" name="sendType"><span>会员</span>
<input type="radio" value="1" class="sendType" name="sendType" checked><span>会员</span>
<input type="radio" value="2" class="sendType" name="sendType"><span>手机号</span>
</div>
</div>
......@@ -230,7 +230,7 @@
let prefix = ctx;
let typeOne = '2'; // 类别
let typeTwo = '0'; // 类型
let sendType = '10'; // 发送类型
let sendType = '1'; // 发送类型
let searchVal = ''; // 输入框内数据
let searchData = []; // 搜索总数据
let showId = ''; // 选中演出id
......
......@@ -36,9 +36,13 @@
</div>
<div class="form-group">
<label class="col-sm-3 control-label">类型:</label>
<div class="form-control-static col-sm-9">
<div class="form-control-static col-sm-2">
[[${@dict.getLabel('zhengzai_coupon_bind_type', mgtCouponInfoDto?.bindType)}]]
</div>
<label class="col-sm-3 control-label" th:if="${mgtCouponInfoDto?.bindType == 1 || mgtCouponInfoDto?.bindType == 3}">发送类型:</label>
<div class="form-control-static col-sm-4" th:if="${mgtCouponInfoDto?.bindType == 1 || mgtCouponInfoDto?.bindType == 3}">
[[${@dict.getLabel('zhengzai_coupon_event_type', mgtCouponInfoDto?.eventType)}]]
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">金额:</label>
......
......@@ -36,9 +36,13 @@
</div>
<div class="form-group">
<label class="col-sm-3 control-label">类型:</label>
<div class="form-control-static col-sm-9">
<div class="form-control-static col-sm-2">
[[${@dict.getLabel('zhengzai_coupon_bind_type', mgtCouponInfoDto?.bindType)}]]
</div>
<label class="col-sm-3 control-label" th:if="${mgtCouponInfoDto?.bindType == 1 || mgtCouponInfoDto?.bindType == 3}">发送类型:</label>
<div class="form-control-static col-sm-4" th:if="${mgtCouponInfoDto?.bindType == 1 || mgtCouponInfoDto?.bindType == 3}">
[[${@dict.getLabel('zhengzai_coupon_event_type', mgtCouponInfoDto?.eventType)}]]
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">数量:</label>
......
......@@ -36,9 +36,13 @@
</div>
<div class="form-group">
<label class="col-sm-3 control-label">类型:</label>
<div class="form-control-static col-sm-9">
<div class="form-control-static col-sm-2">
[[${@dict.getLabel('zhengzai_coupon_bind_type', mgtCouponInfoDto?.bindType)}]]
</div>
<label class="col-sm-3 control-label" th:if="${mgtCouponInfoDto?.bindType == 1 || mgtCouponInfoDto?.bindType == 3}">发送类型:</label>
<div class="form-control-static col-sm-4" th:if="${mgtCouponInfoDto?.bindType == 1 || mgtCouponInfoDto?.bindType == 3}">
[[${@dict.getLabel('zhengzai_coupon_event_type', mgtCouponInfoDto?.eventType)}]]
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">金额:</label>
......
......@@ -36,9 +36,13 @@
</div>
<div class="form-group">
<label class="col-sm-3 control-label">类型:</label>
<div class="form-control-static col-sm-9">
<div class="form-control-static col-sm-2">
[[${@dict.getLabel('zhengzai_coupon_bind_type', mgtCouponInfoDto?.bindType)}]]
</div>
<label class="col-sm-3 control-label" th:if="${mgtCouponInfoDto?.bindType == 1 || mgtCouponInfoDto?.bindType == 3}">发送类型:</label>
<div class="form-control-static col-sm-4" th:if="${mgtCouponInfoDto?.bindType == 1 || mgtCouponInfoDto?.bindType == 3}">
[[${@dict.getLabel('zhengzai_coupon_event_type', mgtCouponInfoDto?.eventType)}]]
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">折扣:</label>
......
......@@ -50,7 +50,7 @@ public class CandyCommonCoupon implements Serializable {
private Integer exclusive;
/**
* 公有券状态[1-可用|2-无效|3-已过期]
* 公有券状态[1-可用|2-无效|3-已过期|9-移除不展示(过期)]
*/
private Integer state;
......
......@@ -56,7 +56,7 @@ public class CandyUserCoupon implements Serializable,Cloneable {
private Integer exclusive;
/**
* 用户券状态[1-可用|2-无效|3-已过期|5-已使用]
* 用户券状态[1-可用|2-无效|3-已过期|5-已使用|9-移除不展示(过期或已使用)]
*/
private Integer state;
......
......@@ -116,7 +116,7 @@ create table candy_user_coupon
mcoupon_id varchar(64) comment '~candy_mgt_coupon.mcoupon_id',
uid varchar(64) not null comment '~adam_user.uid',
coupon_id varchar(64) not null comment '~candy_coupon.coupon_id',
state tinyint comment '用户券状态[1-可用|2-无效|3-已过期|5-已使用]',
state tinyint comment '用户券状态[1-可用|2-无效|3-已过期|5-已使用|9-移除不展示(过期或已使用)]',
ccode varchar(64) comment '券码~candy_coupon_code.ccode',
bind_at datetime(3) comment '激活时间',
......@@ -142,7 +142,7 @@ create table candy_common_coupon
ccoupon_id varchar(64) not null,
mcoupon_id varchar(64) not null comment '~candy_mgt_coupon.mcoupon_id',
coupon_id varchar(64) not null comment '~candy_coupon.coupon_id',
state tinyint comment '公有券状态[1-可用|2-无效|3-已过期]',
state tinyint comment '公有券状态[1-可用|2-无效|3-已过期|9-移除不展示(过期)]',
ranged tinyint comment '公有券范围(~candy_mgt_coupon.event_type)',
operator varchar(64) not null comment '操作人',
......
......@@ -576,7 +576,7 @@ public class CandyCouponServiceImpl implements ICandyCouponService {
params.add("uid", uid);
MultiValueMap<String, String> headers = CollectionUtil.linkedMultiValueMapStringString();
headers.add("Accept", "application/json;charset=UTF-8");
String returnData = HttpUtil.post(adamUrl.concat("/adam/rsc/inquire/createdAt"), params, headers);
String returnData = HttpUtil.get(adamUrl.concat("/adam/rsc/inquire/createdAt"), params, headers);
return JsonUtils.fromJson(returnData, new TypeReference<ResponseDto<LocalDateTime>>() {
}).getData();
}
......
......@@ -12,6 +12,7 @@ import com.liquidnet.service.candy.dto.CandyUserCouponBasicDto;
import com.liquidnet.service.feign.platform.api.FeignPlatformCandyDemoteClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
......@@ -26,6 +27,7 @@ public class RedisDataUtils {
@Autowired
RedisUtil redisUtil;
@Autowired
@Lazy
FeignPlatformCandyDemoteClient feignPlatformCandyDemoteClient;
// 获取 CandyUserCouponBasicDto数组 根据用户id
......@@ -63,24 +65,36 @@ public class RedisDataUtils {
pubDto = (List<CandyCommonCouponBasicDto>) obj2;
}
boolean needSet = false;
// boolean needSet = false;
// if (userCreateTime == null) {
// userCreateTime = LocalDateTime.of(2222,1,1,0,0,0);
// }
// List<String> userCcouponIdList = userDto.stream().map(CandyUserCouponBasicDto::getCcouponId).collect(Collectors.toList());
// if (userCcouponIdList.size() > 0) {
// for (CandyCommonCouponBasicDto item : pubDto) {
// if (userCcouponIdList.contains(item.getCcouponId()) || userCreateTime.isAfter(item.getCreatedAt())) {
// continue;
// } else {
// CandyUserCouponBasicDto userCouponBasicDto = CandyUserCouponBasicDto.getNew().copyToRedisCommonBaseCoupon(IDGenerator.get32UUID(), uid, item);
// userDto.add(userCouponBasicDto);
// needSet = true;
// }
// }
// }
// if (needSet) {
// setCouponByUid(uid, userDto);
// }
if (userCreateTime == null) {
userCreateTime = LocalDateTime.of(2222,1,1,0,0,0);
userCreateTime = LocalDateTime.of(2222, 1, 1, 0, 0, 0);
}
List<String> userIds = userDto.stream().map(CandyUserCouponBasicDto::getCcouponId).collect(Collectors.toList());
if (userIds!=null && userIds.size() > 0) {
for (CandyCommonCouponBasicDto item : pubDto) {
if (userIds.contains(item.getCcouponId()) || userCreateTime.isAfter(item.getCreatedAt())) {
continue;
} else {
CandyUserCouponBasicDto userCouponBasicDto = CandyUserCouponBasicDto.getNew().copyToRedisCommonBaseCoupon(IDGenerator.get32UUID(), uid, item);
userDto.add(userCouponBasicDto);
needSet = true;
}
List<String> userCcouponIdList = userDto.stream().map(CandyUserCouponBasicDto::getCcouponId).collect(Collectors.toList());
for (CandyCommonCouponBasicDto item : pubDto) {
if (userCcouponIdList.contains(item.getCcouponId()) || userCreateTime.isAfter(item.getCreatedAt())) {
continue;
}
}
if (needSet) {
setCouponByUid(uid, userDto);
String ucouponId = item.getCcouponId().concat("-").concat(uid);
CandyUserCouponBasicDto userCouponBasicDto = CandyUserCouponBasicDto.getNew().copyToRedisCommonBaseCoupon(ucouponId, uid, item);
userDto.add(userCouponBasicDto);
}
return userDto;
}
......
......@@ -58,32 +58,32 @@
<artifactId>liquidnet-common-sms</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.liquidnet</groupId>
<artifactId>liquidnet-common-third-zxlnft</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.liquidnet</groupId>
<artifactId>liquidnet-common-third-antchain</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.liquidnet</groupId>
<artifactId>liquidnet-service-galaxy-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.liquidnet</groupId>
<artifactId>liquidnet-service-goblin-common</artifactId>
<version>1.0-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>com.liquidnet</groupId>
<artifactId>liquidnet-common-web</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.liquidnet</groupId>-->
<!-- <artifactId>liquidnet-common-third-zxlnft</artifactId>-->
<!-- <version>1.0-SNAPSHOT</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>com.liquidnet</groupId>-->
<!-- <artifactId>liquidnet-common-third-antchain</artifactId>-->
<!-- <version>1.0-SNAPSHOT</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>com.liquidnet</groupId>-->
<!-- <artifactId>liquidnet-service-galaxy-api</artifactId>-->
<!-- <version>1.0-SNAPSHOT</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>com.liquidnet</groupId>-->
<!-- <artifactId>liquidnet-service-goblin-common</artifactId>-->
<!-- <version>1.0-SNAPSHOT</version>-->
<!-- <exclusions>-->
<!-- <exclusion>-->
<!-- <groupId>com.liquidnet</groupId>-->
<!-- <artifactId>liquidnet-common-web</artifactId>-->
<!-- </exclusion>-->
<!-- </exclusions>-->
<!-- </dependency>-->
</dependencies>
<build>
......
......@@ -228,7 +228,7 @@ public class KylinOrderUtils {
param.setUid(uid);
MultiValueMap<String, String> header = CollectionUtil.linkedMultiValueMapStringString();
header.add("Authorization", "Bearer " + CurrentUtil.getToken());
// header.add("Authorization", "Bearer " + CurrentUtil.getToken());
ArrayList<BackCouponParam> params = new ArrayList();
params.add(param);
......
package com.liquidnet.service.executor.main.handler;
import com.liquidnet.commons.lang.util.CollectionUtil;
import com.liquidnet.commons.lang.util.DESUtils;
import com.liquidnet.commons.lang.util.HttpUtil;
import com.liquidnet.service.feign.kylin.task.FeignPlatformAlipayBackClient;
import com.liquidnet.service.feign.platform.api.FeignPlatformApiClient;
import com.liquidnet.service.feign.platform.kylin.FeignPlatformFreightClient;
import com.liquidnet.service.feign.platform.task.FeignPlatformCandyTaskClient;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.util.LinkedMultiValueMap;
/**
* Platform
*/
@Component
public class PlatformTaskHandler {
@Value("${liquidnet.service.platform.url}")
private String sevPlatformUrl;
@Autowired
private FeignPlatformAlipayBackClient feignPlatformAlipayBackClient;
@Autowired
......@@ -106,6 +116,24 @@ public class PlatformTaskHandler {
}
}
@XxlJob(value = "sev-platform:candyUserCouponRmvProcessing")
public void candyUserCouponRmvProcessing() {// 券中心:券移除处理
try {
String url = sevPlatformUrl.concat("/platform/ccoupon/task/due/rmv");
LinkedMultiValueMap<String, String> paramsMap = CollectionUtil.linkedMultiValueMapStringString();
String jobParam = XxlJobHelper.getJobParam();
paramsMap.add("displaySeconds", DESUtils.DES().encrypt(StringUtils.isNotBlank(jobParam) ? jobParam : "2678400"));
LinkedMultiValueMap<String, String> headersMap = CollectionUtil.linkedMultiValueMapStringString();
headersMap.add("Accept", MediaType.APPLICATION_JSON_UTF8_VALUE);
headersMap.add("Content-Type", MediaType.APPLICATION_FORM_URLENCODED_VALUE);
XxlJobHelper.handleSuccess("结果:" + HttpUtil.post(url, paramsMap, headersMap));
} catch (Exception e) {
XxlJobHelper.log(e);
XxlJobHelper.handleFail();
}
}
@XxlJob(value = "sev-platform:getFreightChargeHandler")
public void getFreightChargeHandler() {//运费
try {
......
......@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.liquidnet.common.cache.redis.util.AbstractRedisUtil;
import com.liquidnet.common.cache.redis.util.RedisDataSourceUtil;
import com.liquidnet.common.exception.LiquidnetServiceException;
import com.liquidnet.common.exception.constant.ErrorCode;
import com.liquidnet.commons.lang.util.DESUtils;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.candy.constant.CandyRedisConst;
import com.liquidnet.service.candy.dto.CandyCommonCouponBasicDto;
......@@ -19,12 +21,12 @@ import com.liquidnet.service.platform.service.impl.candy.PlatformCandyCouponCode
import com.liquidnet.service.platform.service.impl.candy.PlatformCandyCouponService;
import com.liquidnet.service.platform.service.impl.candy.PlatformCandyUserCouponService;
import com.liquidnet.service.platform.utils.ObjectUtil;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDateTime;
import java.util.ArrayList;
......@@ -80,7 +82,7 @@ public class CandyCouponDueTaskController {
// 查取状态可用的到期兑换码
LambdaQueryWrapper<CandyCouponCode> couponCodeQueryWrapper = Wrappers.lambdaQuery(CandyCouponCode.class);
couponCodeQueryWrapper.eq(CandyCouponCode::getState, 0);
couponCodeQueryWrapper.le(CandyCouponCode::getRedeemStop, now);
couponCodeQueryWrapper.le(CandyCouponCode::getRedeemStop, now.minusSeconds(30));
int totalCount = platformCandyCouponCodeService.count(couponCodeQueryWrapper);
AtomicInteger pl = new AtomicInteger();
int remainCount = totalCount;
......@@ -172,7 +174,7 @@ public class CandyCouponDueTaskController {
// 查取状态可用的公有券 - 对应的到期券列表
LambdaQueryWrapper<CandyCoupon> couponQueryWrapper = Wrappers.lambdaQuery(CandyCoupon.class);
couponQueryWrapper.in(CandyCoupon::getCouponId, commonCouponIdArr);
couponQueryWrapper.le(CandyCoupon::getExpireAt, now);
couponQueryWrapper.le(CandyCoupon::getExpireAt, now.minusSeconds(30));
int totalCount = platformCandyCouponService.count(couponQueryWrapper), remainCount = totalCount, num = 0, pSize = 1000;
log.info("券到期检查处理:公有券[可用券总数:{},其中到期券ID数:{}]", commonCouponList.size(), totalCount);
......@@ -245,7 +247,7 @@ public class CandyCouponDueTaskController {
// 查取状态可用的到期券
LambdaQueryWrapper<CandyUserCoupon> userCouponQueryWrapper = Wrappers.lambdaQuery(CandyUserCoupon.class);
userCouponQueryWrapper.eq(CandyUserCoupon::getState, 1);
userCouponQueryWrapper.le(CandyUserCoupon::getDuedAt, now);
userCouponQueryWrapper.le(CandyUserCoupon::getDuedAt, now.minusSeconds(30));
int totalCount = platformCandyUserCouponService.count(userCouponQueryWrapper);
AtomicInteger pl = new AtomicInteger();
int remainCount = totalCount;
......@@ -311,4 +313,44 @@ public class CandyCouponDueTaskController {
log.info("券到期检查处理:私有券[到期总记录数:{},处理总数:{}] >>> END END END", totalCount, pl.get());
return ResponseDto.success();
}
/**
* 券移除-`过期券/已用券`超过指定时长移除不展示
* - 过期券:更新MySQL用户券状态,删除Redis用户指定过期时段的券
* - 已用券:暂不处理
* 同步REDIS.DTO
*
* @param displaySeconds 有效展示秒数,例如:"2678400,31622400",其中2678400为过期券对应有效展示秒数(31天),31622400为已用券对应有效展示秒数(366天),其中31622400可以不传即不处理已用券,2678400必传,否则执行无效
* @return ResponseDto<String>
*/
@PostMapping("rmv")
public ResponseDto<String> processForRmv(@RequestParam String displaySeconds) {
int displayDaysIntVal1 = 31, displayDaysIntVal2 = 0;
ErrorCode paramError = ErrorCode.HTTP_PARAM_ERROR;
if (StringUtils.isNotBlank(displaySeconds)) {
try {
String decrypt = DESUtils.DES().decrypt(displaySeconds);
String[] decryptArr = decrypt.split(",");
displayDaysIntVal1 = Integer.parseInt(decryptArr[0]);
displayDaysIntVal2 = decryptArr.length > 1 && StringUtils.isNotBlank(decryptArr[1]) ? Integer.parseInt(decryptArr[1]) : 0;
} catch (NumberFormatException ignored) {
} catch (Exception e) {
return ResponseDto.failure(paramError.getCode(), paramError.getMessage());
}
if (displayDaysIntVal1 <= 0) {
return ResponseDto.failure(paramError.getCode(), paramError.getMessage());
}
} else {
return ResponseDto.failure(paramError.getCode(), paramError.getMessage());
}
LocalDateTime currentDateTime = LocalDateTime.now();
int plCommonCoupon = platformCandyCommonCouponService.rmvForCommonCouponProcessing(currentDateTime, displayDaysIntVal1);
int plUserCouponDue = platformCandyUserCouponService.rmvForUserCouponProcessing(currentDateTime, displayDaysIntVal1, false);
int plUserCouponUse = 0;
if (displayDaysIntVal2 > 31536000) {// 31536000秒对应365天
plUserCouponUse = platformCandyUserCouponService.rmvForUserCouponProcessing(currentDateTime, displayDaysIntVal2, true);
}
return ResponseDto.success(String.format("结果[%s,%d,%d,过期公有券:%d,过期私有券:%d,已用券:%d", currentDateTime, displayDaysIntVal1, displayDaysIntVal2, plCommonCoupon, plUserCouponDue, plUserCouponUse));
}
}
package com.liquidnet.service.platform.service.impl.candy;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.liquidnet.common.cache.redis.util.AbstractRedisUtil;
import com.liquidnet.common.cache.redis.util.RedisDataSourceUtil;
import com.liquidnet.common.exception.LiquidnetServiceException;
import com.liquidnet.service.candy.constant.CandyRedisConst;
import com.liquidnet.service.candy.dto.CandyCommonCouponBasicDto;
import com.liquidnet.service.candy.entity.CandyCommonCoupon;
import com.liquidnet.service.candy.mapper.CandyCommonCouponMapper;
import com.liquidnet.service.platform.utils.ObjectUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
@Slf4j
@Service
public class PlatformCandyCommonCouponService extends ServiceImpl<CandyCommonCouponMapper, CandyCommonCoupon> {
@Autowired
private RedisDataSourceUtil redisDataSourceUtil;
/**
* 移除公有券
* - 处理已过期且过期天数超过`displayDays`的券
*
* @param currentDateTime 当前时间
* @param displayDays 展示天数
*/
public int rmvForCommonCouponProcessing(LocalDateTime currentDateTime, int displayDays) {
AtomicInteger pl = new AtomicInteger();
try {
LambdaQueryWrapper<CandyCommonCoupon> commonCouponQueryWrapper = Wrappers.lambdaQuery(CandyCommonCoupon.class);
commonCouponQueryWrapper.eq(CandyCommonCoupon::getState, 3);
commonCouponQueryWrapper.le(CandyCommonCoupon::getUpdatedAt, currentDateTime.minusSeconds(displayDays));
int totalCount = this.count(commonCouponQueryWrapper);
int remainCount = totalCount, pSize = 1000;
if (totalCount > 0) {
log.info("券移除处理:公有券[总数:{},AT:{} - {} = {}] >>> BEGIN BEGIN BEGIN", totalCount, currentDateTime, displayDays, currentDateTime.minusDays(displayDays));
}
ArrayList<CandyCommonCoupon> updateCommonCouponList = ObjectUtil.getCandyCommonCouponArrayList();
commonCouponQueryWrapper.select(CandyCommonCoupon::getMid, CandyCommonCoupon::getCcouponId);
commonCouponQueryWrapper.orderByAsc(CandyCommonCoupon::getMid);
while (remainCount > 0) {
updateCommonCouponList.clear();
LambdaQueryWrapper<CandyCommonCoupon> commonCouponLambdaQueryWrapper = commonCouponQueryWrapper.clone();
String lastLimitSql = "LIMIT " + 0 + "," + pSize;
commonCouponLambdaQueryWrapper.last(lastLimitSql);
List<CandyCommonCoupon> commonCouponList = this.list(commonCouponLambdaQueryWrapper);
for (int i = 0, listSize = CollectionUtils.isEmpty(commonCouponList) ? -1 : commonCouponList.size(); i < listSize; i++) {
CandyCommonCoupon commonCoupon = commonCouponList.get(i);
commonCoupon.setState(9);
commonCoupon.setOperator("RMV-DUED");
commonCoupon.setUpdatedAt(currentDateTime);
updateCommonCouponList.add(commonCoupon);
}
if (!CollectionUtils.isEmpty(updateCommonCouponList)) {
if (this.updateBatchById(updateCommonCouponList, updateCommonCouponList.size())) {
AbstractRedisUtil redisCandyUtil = redisDataSourceUtil.getRedisCandyUtil();
List<CandyCommonCouponBasicDto> vos = (List<CandyCommonCouponBasicDto>) redisCandyUtil.get(CandyRedisConst.BASIC_COMMON_COUPON);
if (!CollectionUtils.isEmpty(vos)) {
List<String> updateCommonCouponIdList = updateCommonCouponList.stream().map(CandyCommonCoupon::getCcouponId).collect(Collectors.toList());
int beforeSizeVos = vos.size();
vos.removeIf(r -> updateCommonCouponIdList.contains(r.getCcouponId()));
if (beforeSizeVos - vos.size() > 0) {
pl.getAndAdd(beforeSizeVos - vos.size());
if (vos.size() > 0) {
redisCandyUtil.set(CandyRedisConst.BASIC_COMMON_COUPON, vos);
} else {
redisCandyUtil.del(CandyRedisConst.BASIC_COMMON_COUPON);
}
}
}
} else {
throw new LiquidnetServiceException("-1", "券移除数据更新失败");
}
}
remainCount = Math.max(remainCount - pSize, 0);
log.info("券移除处理中:公有券[总数:{},单次处理:{}|{},剩余:{}]", totalCount, lastLimitSql, pl.get(), remainCount);
}
if (totalCount > 0) {
log.info("券移除处理:公有券[总数:{},处理总数:{}] >>> END END END", totalCount, pl.get());
}
} catch (Exception e) {
log.error("Ex.券移除处理异常:公有券[currentDateTime={},displayDays={}]", currentDateTime, displayDays, e);
}
return pl.get();
}
}
package com.liquidnet.service.platform.service.impl.candy;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.liquidnet.common.cache.redis.util.AbstractRedisUtil;
import com.liquidnet.common.cache.redis.util.RedisDataSourceUtil;
import com.liquidnet.common.exception.LiquidnetServiceException;
import com.liquidnet.service.adam.constant.AdamRedisConst;
import com.liquidnet.service.base.OrderCloseMapping;
import com.liquidnet.service.base.constant.MQConst;
......@@ -15,7 +18,9 @@ import com.liquidnet.service.candy.entity.CandyUserCoupon;
import com.liquidnet.service.candy.mapper.CandyCommonCouponMapper;
import com.liquidnet.service.candy.mapper.CandyCouponRuleMapper;
import com.liquidnet.service.candy.mapper.CandyUserCouponMapper;
import com.liquidnet.service.platform.utils.ObjectUtil;
import com.liquidnet.service.platform.utils.QueueUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
......@@ -25,8 +30,10 @@ import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
@Slf4j
@Service
public class PlatformCandyUserCouponService extends ServiceImpl<CandyUserCouponMapper, CandyUserCoupon> {
@Autowired
......@@ -35,8 +42,7 @@ public class PlatformCandyUserCouponService extends ServiceImpl<CandyUserCouponM
private CandyCouponRuleMapper candyCouponRuleMapper;
@Autowired
private CandyCommonCouponMapper candyCommonCouponMapper;
@Autowired
private PlatformCandyUserCouponService platformCandyUserCouponService;
@Autowired
private QueueUtils queueUtils;
@Autowired
......@@ -51,7 +57,7 @@ public class PlatformCandyUserCouponService extends ServiceImpl<CandyUserCouponM
//修改数据库
CandyUserCoupon userCoupon = CandyUserCoupon.getNew();
userCoupon.setState(1);
platformCandyUserCouponService.update(userCoupon, new UpdateWrapper<CandyUserCoupon>().in("ucoupon_id", uCouponIdList));
this.update(userCoupon, new UpdateWrapper<CandyUserCoupon>().in("ucoupon_id", uCouponIdList));
//sendRedis
int forSize = 500;
int forCount = uCouponUidList.size() % forSize == 0 ? uCouponUidList.size() / forSize : (uCouponUidList.size() / forSize) + 1;
......@@ -112,4 +118,91 @@ public class PlatformCandyUserCouponService extends ServiceImpl<CandyUserCouponM
}
return basicDtoList;
}
/**
* 移除私有券
* - 处理已过期且过期天数超过`displayDays`的券
*
* @param currentDateTime 当前时间
* @param displayDays 展示天数
* @param usedDisplayFlg 已使用券逻辑处理
*/
public int rmvForUserCouponProcessing(LocalDateTime currentDateTime, int displayDays, boolean usedDisplayFlg) {
AtomicInteger pl = new AtomicInteger();
try {
LambdaQueryWrapper<CandyUserCoupon> userCouponQueryWrapper = Wrappers.lambdaQuery(CandyUserCoupon.class);
if (usedDisplayFlg) {
userCouponQueryWrapper.eq(CandyUserCoupon::getState, 5);
userCouponQueryWrapper.le(CandyUserCoupon::getUsedAt, currentDateTime.minusSeconds(displayDays));
} else {
userCouponQueryWrapper.eq(CandyUserCoupon::getState, 3);
userCouponQueryWrapper.le(CandyUserCoupon::getDuedAt, currentDateTime.minusSeconds(displayDays));
}
int totalCount = this.count(userCouponQueryWrapper);
int remainCount = totalCount, pSize = 1000;
if (totalCount > 0) {
log.info("券移除处理:私有券[总数:{},AT:{} - {} = {}] >>> BEGIN BEGIN BEGIN", totalCount, currentDateTime, displayDays, currentDateTime.minusDays(displayDays));
}
ArrayList<CandyUserCoupon> updateUserCouponList = ObjectUtil.getCandyUserCouponArrayList();
userCouponQueryWrapper.select(CandyUserCoupon::getMid, CandyUserCoupon::getUcouponId, CandyUserCoupon::getUid);
userCouponQueryWrapper.orderByAsc(CandyUserCoupon::getMid);
String operator = usedDisplayFlg ? "RMV-USED" : "RMV-DUED";
while (remainCount > 0) {
updateUserCouponList.clear();
LambdaQueryWrapper<CandyUserCoupon> userCouponLambdaQueryWrapper = userCouponQueryWrapper.clone();
String lastLimitSql = "LIMIT " + 0 + "," + pSize;
userCouponLambdaQueryWrapper.last(lastLimitSql);
List<CandyUserCoupon> userCouponList = this.list(userCouponLambdaQueryWrapper);
for (int i = 0, listSize = CollectionUtils.isEmpty(userCouponList) ? -1 : userCouponList.size(); i < listSize; i++) {
CandyUserCoupon userCoupon = userCouponList.get(i);
userCoupon.setState(9);
userCoupon.setOperator(operator);
userCoupon.setUpdatedAt(currentDateTime);
updateUserCouponList.add(userCoupon);
}
if (!CollectionUtils.isEmpty(updateUserCouponList)) {
if (this.updateBatchById(updateUserCouponList, updateUserCouponList.size())) {
AbstractRedisUtil redisCandyUtil = redisDataSourceUtil.getRedisCandyUtil();
// 需要更新的用户券记录按UID分组处理
Map<String, List<CandyUserCoupon>> userCouponListByUidMap = updateUserCouponList.stream().collect(Collectors.groupingBy(CandyUserCoupon::getUid));
userCouponListByUidMap.forEach((uid, updateUserCouponListByUid) -> {
String uckey = CandyRedisConst.BASIC_USER_COUPON.concat(uid);
List<CandyUserCouponBasicDto> vos = (List<CandyUserCouponBasicDto>) redisCandyUtil.get(uckey);
if (!CollectionUtils.isEmpty(vos)) {
List<String> updateUserCouponIdListByUid = updateUserCouponListByUid.stream().map(CandyUserCoupon::getUcouponId).collect(Collectors.toList());
int beforeSizeVos = vos.size();
vos.removeIf(r -> updateUserCouponIdListByUid.contains(r.getUcouponId()));
if (beforeSizeVos - vos.size() > 0) {
pl.getAndAdd(beforeSizeVos - vos.size());
if (vos.size() > 0) {
redisCandyUtil.set(uckey, vos);
} else {
redisCandyUtil.del(uckey);
}
}
}
});
} else {
throw new LiquidnetServiceException("-1", "券移除数据更新失败");
}
}
remainCount = Math.max(remainCount - pSize, 0);
log.info("券移除处理中:私有券[总数:{},单次处理:{}|{},剩余:{}]", totalCount, lastLimitSql, pl.get(), remainCount);
}
if (totalCount > 0) {
log.info("券移除处理:私有券[总数:{},处理总数:{}] >>> END END END", totalCount, pl.get());
}
} catch (Exception e) {
log.error("Ex.券移除处理异常:私有券[currentDateTime={},displayDays={},usedDisplayFlg={}]", currentDateTime, displayDays, usedDisplayFlg, e);
}
return pl.get();
}
}
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