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

Commit 3346c4ac authored by jiangxiulong's avatar jiangxiulong

followDoTask

parent d79c1cca
package com.liquidnet.service.feign.platform.task;
import com.liquidnet.service.base.ResponseDto;
import feign.hystrix.FallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
@Component
@FeignClient(
name = "liquidnet-service-platform",
contextId = "FeignPlatformTaskClient",
path = "platform",
url = "${liquidnet.service.platform.url}",
fallback = FallbackFactory.Default.class
)
public interface FeignPlatformTaskClient {
@GetMapping("doTask")
ResponseDto doTask();
}
...@@ -4,6 +4,7 @@ import com.liquidnet.commons.lang.util.JsonUtils; ...@@ -4,6 +4,7 @@ import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.service.base.ResponseDto; import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.feign.kylin.task.FeignPlatformAlipayBackClient; import com.liquidnet.service.feign.kylin.task.FeignPlatformAlipayBackClient;
import com.liquidnet.service.feign.platform.task.FeignPlatformCandyTaskClient; import com.liquidnet.service.feign.platform.task.FeignPlatformCandyTaskClient;
import com.liquidnet.service.feign.platform.task.FeignPlatformTaskClient;
import com.xxl.job.core.biz.model.ReturnT; import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob; import com.xxl.job.core.handler.annotation.XxlJob;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -22,6 +23,8 @@ public class PlatformTaskHandler { ...@@ -22,6 +23,8 @@ public class PlatformTaskHandler {
private FeignPlatformAlipayBackClient feignPlatformAlipayBackClient; private FeignPlatformAlipayBackClient feignPlatformAlipayBackClient;
@Autowired @Autowired
private FeignPlatformCandyTaskClient feignPlatformCandyTaskClient; private FeignPlatformCandyTaskClient feignPlatformCandyTaskClient;
@Autowired
private FeignPlatformTaskClient feignPlatformTaskClient;
@XxlJob(value = "sev-platform:alipayActiveCallbackHandler") @XxlJob(value = "sev-platform:alipayActiveCallbackHandler")
public ReturnT<String> alipayActiveCallbackHandler() { public ReturnT<String> alipayActiveCallbackHandler() {
...@@ -110,4 +113,22 @@ public class PlatformTaskHandler { ...@@ -110,4 +113,22 @@ public class PlatformTaskHandler {
return fail; return fail;
} }
} }
// 关注任务加积分脚本
@XxlJob(value = "sev-platform:followDoTask")
public ReturnT<String> followDoTask() {
try {
ResponseDto<String> dto = feignPlatformTaskClient.doTask();
String dtoStr = JsonUtils.toJson(dto);
log.info("result of handler:{}", dtoStr);
ReturnT<String> success = ReturnT.SUCCESS;
success.setMsg(dtoStr);
return success;
} catch (Exception e) {
log.error("exception of handler:{}", e.getMessage(), e);
ReturnT<String> fail = ReturnT.FAIL;
fail.setMsg(e.getLocalizedMessage());
return fail;
}
}
} }
package com.liquidnet.service.platform.controller.sweet;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.feign.stone.api.FeignStoneIntegralClient;
import com.liquidnet.service.platform.utils.DataUtils;
import com.liquidnet.service.sweet.entity.SweetWechatUsers;
import com.liquidnet.service.sweet.mapper.SweetWechatUsersMapper;
import com.liquidnet.service.sweet.vo.SweetAppletUsersVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDateTime;
import java.util.List;
/**
* <p>
* 关注任务加积分脚本
* </p>
*
* @author jiangxiulong
* @since 2021-12-28
*/
@Api(tags = "关注任务加积分脚本")
@Slf4j
@RestController
@RequestMapping("followDoTask")
public class TaskController {
@Autowired
private SweetWechatUsersMapper usersMapper;
@Autowired
private FeignStoneIntegralClient feignStoneIntegralClient;
@Autowired
private DataUtils dataUtils;
@GetMapping("doTask")
@ApiOperation("退款回调")
public ResponseDto doTask() {
int size = 1000;
LocalDateTime localDateTime = LocalDateTime.now();
LocalDateTime newTime = localDateTime.minusHours(10);
// String timeStr = "2021-12-28 00:00:00";
// DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
// LocalDateTime dateTime = LocalDateTime.parse(timeStr, df);
// 获取总记录数
Integer count = usersMapper.selectCount(
Wrappers.lambdaQuery(SweetWechatUsers.class)
.gt(SweetWechatUsers::getCreatedAt, newTime)
.eq(SweetWechatUsers::getType, 2)
);
// 总page
int countPage = (int) Math.ceil(count / size);
countPage = countPage + 1;
for (int page = 0; page < countPage; page++) {
List<SweetWechatUsers> sweetWechatUsers = usersMapper.selectList(
Wrappers.lambdaQuery(SweetWechatUsers.class).last("limit " + (page * size) + "," + ((page + 1) * size))
);
for (SweetWechatUsers info : sweetWechatUsers) {
try {
SweetAppletUsersVo sweetAppletUsers = dataUtils.getSweetAppletUsersOfUnionId(info.getUnionId());
if (sweetAppletUsers != null) {
if (sweetAppletUsers.getUserId() != null && !sweetAppletUsers.getUserId().isEmpty()) {
log.info("followDoTask userId:{}", sweetAppletUsers.getUserId());
feignStoneIntegralClient.doTask(4, sweetAppletUsers.getUserId());
}
}
} catch (Exception e) {
}
}
}
return ResponseDto.success();
}
}
...@@ -13,6 +13,8 @@ import com.liquidnet.service.kylin.dto.vo.returns.KylinOrderListVo; ...@@ -13,6 +13,8 @@ import com.liquidnet.service.kylin.dto.vo.returns.KylinOrderListVo;
import com.liquidnet.service.kylin.entity.KylinBuyNotice; import com.liquidnet.service.kylin.entity.KylinBuyNotice;
import com.liquidnet.service.kylin.entity.KylinOrderCoupons; import com.liquidnet.service.kylin.entity.KylinOrderCoupons;
import com.liquidnet.service.kylin.mapper.KylinBuyNoticeMapper; import com.liquidnet.service.kylin.mapper.KylinBuyNoticeMapper;
import com.liquidnet.service.sweet.constant.SweetConstant;
import com.liquidnet.service.sweet.vo.SweetAppletUsersVo;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.data.mongodb.core.MongoTemplate;
...@@ -400,4 +402,15 @@ public class DataUtils { ...@@ -400,4 +402,15 @@ public class DataUtils {
return (ArrayList<KylinOrderCoupons>) obj; return (ArrayList<KylinOrderCoupons>) obj;
} }
} }
public SweetAppletUsersVo getSweetAppletUsersOfUnionId(String unionId) {
String redisKey = SweetConstant.REDIS_KEY_SWEET_APPLET_USERS_UNIONID.concat(unionId);
Object obj = redisDataSourceUtil.getRedisSweetUtil().get(redisKey);
if (null == obj) {
return null;
} else {
SweetAppletUsersVo sweetAppletUsersVo = (SweetAppletUsersVo) obj;
return sweetAppletUsersVo;
}
}
} }
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