对接3方系统,开通同事特权
This commit is contained in:
@@ -109,7 +109,7 @@ public class LbPurchaseApplyController {
|
|||||||
@GetMapping("/syncHxrAdminUserVip")
|
@GetMapping("/syncHxrAdminUserVip")
|
||||||
@Operation(summary = "按申请日期与租户同步 hxrd 用户 VIP 字段",
|
@Operation(summary = "按申请日期与租户同步 hxrd 用户 VIP 字段",
|
||||||
description = "根据 lb_purchase_apply 的申请日期区间与 tenant_id 逐条处理记录,"
|
description = "根据 lb_purchase_apply 的申请日期区间与 tenant_id 逐条处理记录,"
|
||||||
+ "以每条记录的 apply_date 为起算日计算 viptime(周末先对齐到下一工作日,再顺延 2 个工作日),"
|
+ "以每条记录的 apply_date 为起算日计算 viptime(周末先对齐到下一工作日,再顺延 3 个工作日),"
|
||||||
+ "再 GET /app/admin/user/select、POST /app/admin/user/update(max_order、is_vip=1 等)。"
|
+ "再 GET /app/admin/user/select、POST /app/admin/user/update(max_order、is_vip=1 等)。"
|
||||||
+ "需配置 hxr.admin.cookie 或 hxr.admin.phpsid。")
|
+ "需配置 hxr.admin.cookie 或 hxr.admin.phpsid。")
|
||||||
public ResponseEntity<Map<String, Object>> syncHxrAdminUserVip(
|
public ResponseEntity<Map<String, Object>> syncHxrAdminUserVip(
|
||||||
@@ -133,8 +133,9 @@ public class LbPurchaseApplyController {
|
|||||||
@GetMapping("/syncHxrAdminColleagueVip")
|
@GetMapping("/syncHxrAdminColleagueVip")
|
||||||
@Operation(summary = "按申请日期与租户同步同事 hxrd 用户 VIP",
|
@Operation(summary = "按申请日期与租户同步同事 hxrd 用户 VIP",
|
||||||
description = "根据 lb_purchase_apply 的申请日期区间与 tenant_id 逐条处理,"
|
description = "根据 lb_purchase_apply 的申请日期区间与 tenant_id 逐条处理,"
|
||||||
|
+ "仅当 colleague_name 能在 lb_daily_user_trade(同租户 nickname)中查到时才开通;"
|
||||||
+ "以 colleague_phone 查询 /app/admin/user/select,"
|
+ "以 colleague_phone 查询 /app/admin/user/select,"
|
||||||
+ "以每条记录的 apply_date 为起算日顺延 2 个自然日计算 viptime,"
|
+ "以每条记录的 apply_date 为起算日计算 viptime(周末先对齐到下一工作日,再顺延 2 个工作日),"
|
||||||
+ "再 POST /app/admin/user/update(max_order 使用 select 返回的 HxrUserRow.max_order)。"
|
+ "再 POST /app/admin/user/update(max_order 使用 select 返回的 HxrUserRow.max_order)。"
|
||||||
+ "需配置 hxr.admin.cookie 或 hxr.admin.phpsid。")
|
+ "需配置 hxr.admin.cookie 或 hxr.admin.phpsid。")
|
||||||
public ResponseEntity<Map<String, Object>> syncHxrAdminColleagueVip(
|
public ResponseEntity<Map<String, Object>> syncHxrAdminColleagueVip(
|
||||||
|
|||||||
@@ -44,18 +44,29 @@ public class HxrAdminUserService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* VIP 到期时间:以 {@code applyDate} 为起算日,若当天为周六、周日则先顺延到下一工作日,再顺延 2 个工作日;
|
* VIP 到期时间:以 {@code applyDate} 为起算日,若当天为周六、周日则先顺延到下一工作日,再顺延 2 个工作日;
|
||||||
* 时刻与调用时「当前时刻」的时分秒相同(仅调整日期)。
|
* 时刻与调用时「当前时刻」的时分秒相同(仅调整日期)。用于开通同事特权。
|
||||||
*/
|
*/
|
||||||
public static LocalDateTime computeVipExpireTime(LocalDate applyDate) {
|
public static LocalDateTime computeVipExpireTime(LocalDate applyDate) {
|
||||||
|
return computeVipExpireTime(applyDate, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* VIP 到期时间:以 {@code applyDate} 为起算日,若当天为周六、周日则先顺延到下一工作日,
|
||||||
|
* 再顺延 {@code workdaysAfterAlign} 个工作日;时刻与当前时分秒一致。
|
||||||
|
*/
|
||||||
|
public static LocalDateTime computeVipExpireTime(LocalDate applyDate, int workdaysAfterAlign) {
|
||||||
if (applyDate == null) {
|
if (applyDate == null) {
|
||||||
throw new IllegalArgumentException("applyDate不能为空");
|
throw new IllegalArgumentException("applyDate不能为空");
|
||||||
}
|
}
|
||||||
|
if (workdaysAfterAlign < 0) {
|
||||||
|
throw new IllegalArgumentException("workdaysAfterAlign不能为负");
|
||||||
|
}
|
||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
LocalDate d = applyDate;
|
LocalDate d = applyDate;
|
||||||
while (IsoWorkdayUtils.isWeekend(d)) {
|
while (IsoWorkdayUtils.isWeekend(d)) {
|
||||||
d = d.plusDays(1);
|
d = d.plusDays(1);
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 2; i++) {
|
for (int i = 0; i < workdaysAfterAlign; i++) {
|
||||||
d = d.plusDays(1);
|
d = d.plusDays(1);
|
||||||
while (IsoWorkdayUtils.isWeekend(d)) {
|
while (IsoWorkdayUtils.isWeekend(d)) {
|
||||||
d = d.plusDays(1);
|
d = d.plusDays(1);
|
||||||
|
|||||||
@@ -28,14 +28,15 @@ public interface ILbPurchaseApplyService extends IService<LbPurchaseApply> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 按申请日期区间与租户筛选进货申请,对不重复的 {@code apply_phone} 调用 hxrd 用户查询与更新接口,
|
* 按申请日期区间与租户筛选进货申请,对不重复的 {@code apply_phone} 调用 hxrd 用户查询与更新接口,
|
||||||
* 写入 {@code max_order}、VIP/转卖/状态 及 {@code viptime}(当前时间 +2 天,若落在周末则顺延至下周一)。
|
* 写入 {@code max_order}、VIP/转卖/状态 及 {@code viptime}(周末先对齐到下一工作日,再顺延 3 个工作日)。
|
||||||
*/
|
*/
|
||||||
Map<String, Object> syncHxrAdminUserVipByApplyDateRange(
|
Map<String, Object> syncHxrAdminUserVipByApplyDateRange(
|
||||||
LocalDate applyDateStart, LocalDate applyDateEnd, String tenantId, Integer maxOrder);
|
LocalDate applyDateStart, LocalDate applyDateEnd, String tenantId, Integer maxOrder);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 按申请日期区间与租户筛选进货申请,对每条记录的 {@code colleague_phone} 调用 hxrd 用户查询与更新,
|
* 按申请日期区间与租户筛选进货申请,对每条记录的 {@code colleague_phone} 调用 hxrd 用户查询与更新,
|
||||||
* 以 {@code apply_date} 为起算日顺延 2 个自然日写入 {@code viptime} 等 VIP 字段。
|
* 仅当 {@code colleague_name} 能在 {@code lb_daily_user_trade}(同租户、按 nickname)中查到时才开通;
|
||||||
|
* 以 {@code apply_date} 为起算日计算 {@code viptime}(周末先对齐到下一工作日,再顺延 2 个工作日)。
|
||||||
*/
|
*/
|
||||||
Map<String, Object> syncHxrAdminColleagueVipByApplyDateRange(
|
Map<String, Object> syncHxrAdminColleagueVipByApplyDateRange(
|
||||||
LocalDate applyDateStart, LocalDate applyDateEnd, String tenantId);
|
LocalDate applyDateStart, LocalDate applyDateEnd, String tenantId);
|
||||||
|
|||||||
@@ -12,9 +12,11 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.rj.dto.hxr.HxrUserRow;
|
import com.rj.dto.hxr.HxrUserRow;
|
||||||
|
import com.rj.entity.LbDailyUserTrade;
|
||||||
import com.rj.entity.LbDailyUserTradeReport;
|
import com.rj.entity.LbDailyUserTradeReport;
|
||||||
import com.rj.entity.LbPurchaseApply;
|
import com.rj.entity.LbPurchaseApply;
|
||||||
import com.rj.util.IsoWorkdayUtils;
|
import com.rj.util.IsoWorkdayUtils;
|
||||||
|
import com.rj.mapper.LbDailyUserTradeMapper;
|
||||||
import com.rj.mapper.LbDailyUserTradeReportMapper;
|
import com.rj.mapper.LbDailyUserTradeReportMapper;
|
||||||
import com.rj.mapper.LbPurchaseApplyMapper;
|
import com.rj.mapper.LbPurchaseApplyMapper;
|
||||||
import com.rj.service.HxrAdminUserService;
|
import com.rj.service.HxrAdminUserService;
|
||||||
@@ -45,6 +47,9 @@ public class LbPurchaseApplyServiceImpl
|
|||||||
@Autowired
|
@Autowired
|
||||||
private LbDailyUserTradeReportMapper lbDailyUserTradeReportMapper;
|
private LbDailyUserTradeReportMapper lbDailyUserTradeReportMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private LbDailyUserTradeMapper lbDailyUserTradeMapper;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private HxrAdminUserService hxrAdminUserService;
|
private HxrAdminUserService hxrAdminUserService;
|
||||||
|
|
||||||
@@ -575,7 +580,7 @@ public class LbPurchaseApplyServiceImpl
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
LocalDateTime vipTime = HxrAdminUserService.computeVipExpireTime(row.getApplyDate());
|
LocalDateTime vipTime = HxrAdminUserService.computeVipExpireTime(row.getApplyDate(), 3);
|
||||||
String vipTimeStr = HxrAdminUserService.formatVipTime(vipTime);
|
String vipTimeStr = HxrAdminUserService.formatVipTime(vipTime);
|
||||||
one.put("viptime", vipTimeStr);
|
one.put("viptime", vipTimeStr);
|
||||||
|
|
||||||
@@ -663,6 +668,26 @@ public class LbPurchaseApplyServiceImpl
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Set<String> ApplyUserNames = new HashSet<>();
|
||||||
|
for (LbPurchaseApply row : rows) {
|
||||||
|
if (row.getColleagueName() != null && !row.getColleagueName().trim().isEmpty()) {
|
||||||
|
ApplyUserNames.add(row.getApplyUser().trim());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Set<String> tradeMatchedNicknames = new HashSet<>();
|
||||||
|
if (!ApplyUserNames.isEmpty()) {
|
||||||
|
LambdaQueryWrapper<LbDailyUserTrade> tradeQuery = new LambdaQueryWrapper<>();
|
||||||
|
tradeQuery.eq(LbDailyUserTrade::getTenantId, tenantId.trim())
|
||||||
|
.in(LbDailyUserTrade::getNickname, ApplyUserNames)
|
||||||
|
.select(LbDailyUserTrade::getNickname);
|
||||||
|
List<LbDailyUserTrade> matchedTrades = lbDailyUserTradeMapper.selectList(tradeQuery);
|
||||||
|
for (LbDailyUserTrade trade : matchedTrades) {
|
||||||
|
if (trade.getNickname() != null && !trade.getNickname().trim().isEmpty()) {
|
||||||
|
tradeMatchedNicknames.add(trade.getNickname().trim());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
List<Map<String, Object>> details = new ArrayList<>();
|
List<Map<String, Object>> details = new ArrayList<>();
|
||||||
int ok = 0;
|
int ok = 0;
|
||||||
int fail = 0;
|
int fail = 0;
|
||||||
@@ -670,9 +695,24 @@ public class LbPurchaseApplyServiceImpl
|
|||||||
Map<String, Object> one = new HashMap<>();
|
Map<String, Object> one = new HashMap<>();
|
||||||
one.put("applyId", row.getId());
|
one.put("applyId", row.getId());
|
||||||
one.put("applyDate", row.getApplyDate());
|
one.put("applyDate", row.getApplyDate());
|
||||||
one.put("colleagueName", row.getColleagueName());
|
String applyUserName = row.getApplyUser() != null ? row.getApplyUser().trim() : "";
|
||||||
|
one.put("applyUserName", applyUserName);
|
||||||
String phone = row.getColleaguePhone() != null ? row.getColleaguePhone().trim() : "";
|
String phone = row.getColleaguePhone() != null ? row.getColleaguePhone().trim() : "";
|
||||||
one.put("colleaguePhone", phone);
|
one.put("colleaguePhone", phone);
|
||||||
|
if (applyUserName.isEmpty()) {
|
||||||
|
one.put("success", false);
|
||||||
|
one.put("message", "colleague_name 为空,跳过");
|
||||||
|
fail++;
|
||||||
|
details.add(one);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!tradeMatchedNicknames.contains(applyUserName)) {
|
||||||
|
one.put("success", false);
|
||||||
|
one.put("message", "申请人姓名在 lb_daily_user_trade 中未找到 ,说明今天没进货 ,推荐人不能享受特权,跳过开通特权");
|
||||||
|
fail++;
|
||||||
|
details.add(one);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (phone.isEmpty()) {
|
if (phone.isEmpty()) {
|
||||||
one.put("success", false);
|
one.put("success", false);
|
||||||
one.put("message", "colleague_phone 为空,跳过");
|
one.put("message", "colleague_phone 为空,跳过");
|
||||||
@@ -688,8 +728,7 @@ public class LbPurchaseApplyServiceImpl
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
LocalDateTime vipTime =
|
LocalDateTime vipTime = HxrAdminUserService.computeVipExpireTime(row.getApplyDate());
|
||||||
HxrAdminUserService.computeVipExpireTimePlusCalendarDays(row.getApplyDate(), 2);
|
|
||||||
String vipTimeStr = HxrAdminUserService.formatVipTime(vipTime);
|
String vipTimeStr = HxrAdminUserService.formatVipTime(vipTime);
|
||||||
one.put("viptime", vipTimeStr);
|
one.put("viptime", vipTimeStr);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user