1.新增-店铺列表淘宝类型商铺新增和修改token和userID选项 , 淘宝类型授权状态默认为2099-12-31。from:邵迎新 20260702

This commit is contained in:
Administrator 2026-07-02 14:34:47 +08:00
parent 129ea0e597
commit b3eff758bf
5 changed files with 155 additions and 99 deletions

View File

@ -93,6 +93,8 @@ public class ServiceController {
InterfaceUtils.postForm(UrlUtil.getServiceGoUrl(),"/api/orders/orderForPay",orderForPay); InterfaceUtils.postForm(UrlUtil.getServiceGoUrl(),"/api/orders/orderForPay",orderForPay);
shopService.refreshShopSubscriptionStatus(Long.parseLong(shopId));
return R.ok(); return R.ok();
} }

View File

@ -10,15 +10,15 @@ public class DllInitializer {
@PostConstruct @PostConstruct
public void init() { public void init() {
try { // try {
System.out.println("正在加载 erp DLL库"); // System.out.println("正在加载 erp DLL库");
ErpSimpleDllLoader.loadDLL(); // ErpSimpleDllLoader.loadDLL();
initialized = true; // initialized = true;
System.out.println("erp DLL 库加载成功"); // System.out.println("erp DLL 库加载成功");
} catch (Exception e) { // } catch (Exception e) {
System.err.println("Native 库加载失败: " + e.getMessage()); // System.err.println("Native 库加载失败: " + e.getMessage());
throw new RuntimeException("Native 库加载失败", e); // throw new RuntimeException("Native 库加载失败", e);
} // }
} }
public static boolean isInitialized() { public static boolean isInitialized() {

View File

@ -103,6 +103,11 @@ public interface IShopService {
*/ */
Boolean updateByBo(ShopBo bo); Boolean updateByBo(ShopBo bo);
/**
* 订阅支付成功后刷新店铺订阅到期时间
*/
void refreshShopSubscriptionStatus(Long shopId);
/** /**
* 校验并批量删除店铺主表信息 * 校验并批量删除店铺主表信息
* *

View File

@ -209,55 +209,20 @@ public class ShopServiceImpl implements IShopService {
if (shopVo.getExpirationTime() != null if (shopVo.getExpirationTime() != null
&& currentTime > shopVo.getExpirationTime().getTime() && currentTime > shopVo.getExpirationTime().getTime()
&& shopVo.getShopType().equals("1")) { && shopVo.getShopType().equals("1")) {
// 如果当前时间超过到期时间则修改店铺授权状态
shopVo.setShopAuthorize("2"); shopVo.setShopAuthorize("2");
// 修改数据库 shopVo.setIsExpiration("2");
ShopBo shopBo = new ShopBo(); updateShopSubscribeStatusQuietly(shopVo.getId(), null, "2", null);
shopBo.setId(shopVo.getId());
shopBo.setIsExpiration("2");
updateByBo(shopBo);
} }
else if(!shopVo.getShopType().equals("1")){ else if(!shopVo.getShopType().equals("1")){
if(shopVo.getExpirationTime() != null if (!isTaobaoShopType(shopVo.getShopType())
&& currentTime > shopVo.getExpirationTime().getTime()){ && shopVo.getExpirationTime() != null
&& currentTime > shopVo.getExpirationTime().getTime()) {
// 如果当前时间超过到期时间则修改店铺授权状态 // 如果当前时间超过到期时间则修改店铺授权状态
shopVo.setShopAuthorize("2"); shopVo.setShopAuthorize("2");
// 修改数据库 shopVo.setIsExpiration("2");
ShopBo shopBo = new ShopBo(); updateShopSubscribeStatusQuietly(shopVo.getId(), "2", "2", null);
shopBo.setId(shopVo.getId());
shopBo.setIsExpiration("2");
updateByBo(shopBo);
}
//校验是否过期
String result2 = InterfaceUtils.getInterface(UrlUtil.getServiceGoUrl(),"/api/user/getKfzUserRecbusiness?userId="+shopVo.getId());
Map resultMap = JSONObject.parseObject(result2, Map.class);
if(resultMap.get("message").equals("success")){
//成功
Map data = (Map) resultMap.get("data");
// shopVo.setExpirationTime(new Date((Long) data.get("expirationDate")));
shopVo.setShopExpirationTime(new Date((Long) data.get("expirationDate")));
if(!(Boolean) data.get("isVip")){
//过期修改店铺设置
ShopBo shopBo = new ShopBo();
shopBo.setId(shopVo.getId());
shopBo.setIsExpiration("2");
updateByBo(shopBo);
} else {
//已过期续费后修改店铺设置
ShopBo shopBo = new ShopBo();
shopBo.setId(shopVo.getId());
shopBo.setIsExpiration("1");
updateByBo(shopBo);
}
}else{
if(StringUtils.isEmpty(shopVo.getIsExpiration())){
//为空赋值0
ShopBo shopBo = new ShopBo();
shopBo.setId(shopVo.getId());
shopBo.setIsExpiration("0");
updateByBo(shopBo);
}
} }
syncShopSubscriptionStatus(shopVo);
} }
} }
@ -326,48 +291,18 @@ public class ShopServiceImpl implements IShopService {
&& !shopVo.getShopAuthorize().equals("2") && shopVo.getShopType().equals("1")) { && !shopVo.getShopAuthorize().equals("2") && shopVo.getShopType().equals("1")) {
// 如果当前时间超过到期时间则修改店铺授权状态 // 如果当前时间超过到期时间则修改店铺授权状态
shopVo.setShopAuthorize("2"); shopVo.setShopAuthorize("2");
// 修改数据库 updateShopSubscribeStatusQuietly(shopVo.getId(), "2", null, null);
ShopBo shopBo = new ShopBo();
shopBo.setId(shopVo.getId());
shopBo.setShopAuthorize("2");
updateByBo(shopBo);
} }
else if(!shopVo.getShopType().equals("1")){ else if(!shopVo.getShopType().equals("1")){
if(shopVo.getExpirationTime() != null if (!isTaobaoShopType(shopVo.getShopType())
&& currentTime > shopVo.getExpirationTime().getTime() && shopVo.getExpirationTime() != null
&&shopVo.getShopType().equals("5")){ && currentTime > shopVo.getExpirationTime().getTime()
&& shopVo.getShopType().equals("5")) {
// 如果当前时间超过到期时间则修改店铺授权状态 // 如果当前时间超过到期时间则修改店铺授权状态
shopVo.setShopAuthorize("2"); shopVo.setShopAuthorize("2");
// 修改数据库 updateShopSubscribeStatusQuietly(shopVo.getId(), "2", null, null);
ShopBo shopBo = new ShopBo();
shopBo.setId(shopVo.getId());
shopBo.setShopAuthorize("2");
updateByBo(shopBo);
}
//校验是否过期
String result2 = InterfaceUtils.getInterface(UrlUtil.getServiceGoUrl(),"/api/user/getKfzUserRecbusiness?userId="+shopVo.getId());
Map resultMap = JSONObject.parseObject(result2, Map.class);
if(resultMap.get("message").equals("success")){
//成功
Map data = (Map) resultMap.get("data");
// shopVo.setExpirationTime(new Date((Long) data.get("expirationDate")));
shopVo.setShopExpirationTime(new Date((Long) data.get("expirationDate")));
if(!(Boolean) data.get("isVip")){
//过期修改店铺设置
ShopBo shopBo = new ShopBo();
shopBo.setId(shopVo.getId());
shopBo.setIsExpiration("2");
updateByBo(shopBo);
}
}else{
if(StringUtils.isEmpty(shopVo.getIsExpiration())){
//为空赋值0
ShopBo shopBo = new ShopBo();
shopBo.setId(shopVo.getId());
shopBo.setIsExpiration("0");
updateByBo(shopBo);
}
} }
syncShopSubscriptionStatus(shopVo);
} }
} }
@ -406,11 +341,7 @@ public class ShopServiceImpl implements IShopService {
shopVo.setShopExpirationTime(new Date((Long) data.get("expirationDate"))); shopVo.setShopExpirationTime(new Date((Long) data.get("expirationDate")));
shopList.add(shopVo); shopList.add(shopVo);
}else{ }else{
//过期修改店铺设置 updateShopSubscribeStatusQuietly(shopVo.getId(), null, "2", null);
ShopBo shopBo = new ShopBo();
shopBo.setId(shopVo.getId());
shopBo.setIsExpiration("2");
updateByBo(shopBo);
} }
} }
} }
@ -453,9 +384,7 @@ public class ShopServiceImpl implements IShopService {
bo.setIsSynOrder(1); bo.setIsSynOrder(1);
bo.setUpdateTime(DateUtils.getNowDate()); bo.setUpdateTime(DateUtils.getNowDate());
bo.setUpdateBy(LoginHelper.getUserId()); bo.setUpdateBy(LoginHelper.getUserId());
if(StringUtils.isEmpty(bo.getShopAuthorize())){ applyManualAuthorizeStatus(bo);
bo.setShopAuthorize("0");
}
bo.setAddTime(DateUtils.getNowDate()); bo.setAddTime(DateUtils.getNowDate());
if (StringUtils.isEmpty(bo.getShopGroup())) { if (StringUtils.isEmpty(bo.getShopGroup())) {
bo.setShopGroup("默认分组"); bo.setShopGroup("默认分组");
@ -547,6 +476,7 @@ public class ShopServiceImpl implements IShopService {
*/ */
@Override @Override
public Boolean updateByBo(ShopBo bo) { public Boolean updateByBo(ShopBo bo) {
applyManualAuthorizeStatus(bo);
Shop update = MapstructUtils.convert(bo, Shop.class); Shop update = MapstructUtils.convert(bo, Shop.class);
validEntityBeforeSave(update); validEntityBeforeSave(update);
boolean flag = baseMapper.updateById(update) > 0; boolean flag = baseMapper.updateById(update) > 0;
@ -573,8 +503,7 @@ public class ShopServiceImpl implements IShopService {
String response = HttpUtils.sendPost(url, headers, jsonBody); String response = HttpUtils.sendPost(url, headers, jsonBody);
System.out.println("调用updateShopHandler接口成功响应: " + response); System.out.println("调用updateShopHandler接口成功响应: " + response);
} catch (Exception e) { } catch (Exception e) {
System.err.println("调用updateShopHandler接口失败: " + e.getMessage()); log.warn("调用updateShopHandler接口失败, shopId={}: {}", bo.getId(), e.getMessage());
e.printStackTrace();
} }
// insertShopIntoRedis(bo); // insertShopIntoRedis(bo);
@ -589,6 +518,123 @@ public class ShopServiceImpl implements IShopService {
// TODO 做一些数据校验,如唯一约束 // TODO 做一些数据校验,如唯一约束
} }
private static final String PERMANENT_EXPIRATION_TIME = "2099-12-31 12:00:00";
/** 淘宝店铺类型 */
private static final String TB_SHOP_TYPE = "6";
/**
* 淘宝店铺新增/修改 Token+UserID默认永久授权订阅默认未开通
*/
private void applyManualAuthorizeStatus(ShopBo bo) {
if (!isTaobaoShopType(bo.getShopType())) {
if (bo.getId() == null && StringUtils.isEmpty(bo.getShopAuthorize())) {
bo.setShopAuthorize("0");
}
return;
}
if (bo.getId() == null) {
bo.setShopAuthorize("1");
if (bo.getExpirationTime() == null) {
bo.setExpirationTime(DateUtils.parseDate(PERMANENT_EXPIRATION_TIME));
}
bo.setIsExpiration("0");
return;
}
if (StringUtils.isNotBlank(bo.getToken()) && bo.getMallId() != null) {
bo.setShopAuthorize("1");
}
}
private boolean isTaobaoShopType(String shopType) {
return TB_SHOP_TYPE.equals(shopType);
}
/**
* 列表查询同步订阅状态时仅更新数据库不触发 Redis 同步
*/
private void updateShopSubscribeStatusQuietly(Long shopId, String shopAuthorize, String isExpiration, Date shopExpirationTime) {
if (shopId == null) {
return;
}
LambdaUpdateChainWrapper<Shop> update = new LambdaUpdateChainWrapper<>(baseMapper);
update.eq(Shop::getId, shopId);
boolean hasField = false;
if (StringUtils.isNotBlank(shopAuthorize)) {
update.set(Shop::getShopAuthorize, shopAuthorize);
hasField = true;
}
if (StringUtils.isNotBlank(isExpiration)) {
update.set(Shop::getIsExpiration, isExpiration);
hasField = true;
}
if (shopExpirationTime != null) {
update.set(Shop::getShopExpirationTime, shopExpirationTime);
hasField = true;
}
if (hasField) {
update.update();
}
}
private Date parseExpirationDate(Object expirationDate) {
if (expirationDate == null) {
return null;
}
if (expirationDate instanceof Date) {
return (Date) expirationDate;
}
if (expirationDate instanceof Number) {
return new Date(((Number) expirationDate).longValue());
}
if (expirationDate instanceof String && StringUtils.isNotBlank((String) expirationDate)) {
return new Date(Long.parseLong((String) expirationDate));
}
return null;
}
/**
* 同步孔夫子/闲鱼/淘宝等店铺的订阅状态统一走 Go 接口
*/
private void syncShopSubscriptionStatus(ShopVo shopVo) {
String result2 = InterfaceUtils.getInterface(UrlUtil.getServiceGoUrl(),
"/api/user/getKfzUserRecbusiness?userId=" + shopVo.getId());
Map resultMap = JSONObject.parseObject(result2, Map.class);
if (resultMap != null && "success".equals(String.valueOf(resultMap.get("message")))) {
Map data = (Map) resultMap.get("data");
if (data != null) {
Date expiration = parseExpirationDate(data.get("expirationDate"));
String targetStatus = Boolean.TRUE.equals(data.get("isVip")) ? "1" : "2";
Date dbExpiration = shopVo.getShopExpirationTime();
boolean statusChanged = !targetStatus.equals(shopVo.getIsExpiration());
boolean expirationChanged = expiration != null
&& (dbExpiration == null || expiration.getTime() != dbExpiration.getTime());
if (statusChanged || expirationChanged) {
updateShopSubscribeStatusQuietly(shopVo.getId(), null,
statusChanged ? targetStatus : shopVo.getIsExpiration(), expiration);
}
if (expiration != null) {
shopVo.setShopExpirationTime(expiration);
}
shopVo.setIsExpiration(targetStatus);
}
} else if (StringUtils.isEmpty(shopVo.getIsExpiration())) {
updateShopSubscribeStatusQuietly(shopVo.getId(), null, "0", null);
shopVo.setIsExpiration("0");
}
}
@Override
public void refreshShopSubscriptionStatus(Long shopId) {
if (shopId == null) {
return;
}
ShopVo shopVo = queryById(shopId);
if (shopVo != null && !"1".equals(shopVo.getShopType())) {
syncShopSubscriptionStatus(shopVo);
}
}
/** /**
* 校验并批量删除店铺主表信息 * 校验并批量删除店铺主表信息
* *

View File

@ -222,6 +222,9 @@ public class UserRechargeServiceImpl implements IUserRechargeService {
case 1: case 1:
logTxt = "孔夫子店铺订阅;"; logTxt = "孔夫子店铺订阅;";
break; break;
case 2:
logTxt = "淘宝店铺订阅;";
break;
case 3: case 3:
logTxt = "闲鱼店铺订阅;"; logTxt = "闲鱼店铺订阅;";
break; break;