入驻代理商的增强
This commit is contained in:
parent
a81711fa25
commit
0bd5297ea7
@ -29,7 +29,7 @@ import java.util.Date;
|
||||
public class EsignPlatformInfo implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.INPUT)
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
@ApiModelProperty(value = "自增ID")
|
||||
private Long id;
|
||||
|
||||
@ -108,7 +108,7 @@ public class EsignPlatformInfo implements Serializable {
|
||||
@ApiModelProperty(value = "平台方公司维度")
|
||||
private String latitude;
|
||||
|
||||
@ApiModelProperty(value = "代理商等级:0-平台方(只能一条记录);1-一级代理;2-二级代理;3-三级代理;4-四级代理;")
|
||||
@ApiModelProperty(value = "代理商等级:0-平台方(只能一条记录);1-一级代理;2-二级代理;")
|
||||
private Integer level;
|
||||
|
||||
@ApiModelProperty(value = "邀请码,后期跟收益有关")
|
||||
|
||||
@ -29,7 +29,7 @@ import java.util.Date;
|
||||
public class LklLedgerMerReceiverBind implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.INPUT)
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
@ApiModelProperty(value = "自增ID")
|
||||
private Long id;
|
||||
private String order_no;
|
||||
|
||||
@ -29,7 +29,7 @@ import java.util.Date;
|
||||
public class LklLedgerReceiver implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.INPUT)
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
@ApiModelProperty(value = "自增ID")
|
||||
private Long id;
|
||||
private String order_no;
|
||||
|
||||
@ -27,6 +27,8 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@ -71,28 +73,38 @@ public class EsignPlatformInfoServiceImpl extends BaseServiceImpl<EsignPlatformI
|
||||
*/
|
||||
@Override
|
||||
public List<EsignPlatformInfo> selectAgentAndPlatformByMchId(Long mchId) {
|
||||
List<EsignPlatformInfo> esignPlatformInfos = new ArrayList<>();
|
||||
|
||||
log.debug("[获取平台和代理商信息] 开始查询平台方和代理商信息,商户ID: {}", mchId);
|
||||
|
||||
// 获取平台方记录
|
||||
QueryWrapper<EsignPlatformInfo> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("level", 0)
|
||||
.eq("status", CommonConstant.Enable)
|
||||
.orderByAsc("level");
|
||||
.orderByAsc("id");
|
||||
|
||||
List<EsignPlatformInfo> esignPlatformInfos = list(queryWrapper);
|
||||
if (CollectionUtil.isEmpty(esignPlatformInfos)) {
|
||||
log.error("[获取平台和代理商信息] 未找到平台方记录");
|
||||
return null;
|
||||
EsignPlatformInfo esignPlatformInfo = findOne(queryWrapper);
|
||||
if (esignPlatformInfo == null || esignPlatformInfo.getId() == null || esignPlatformInfo.getId() <= 0) {
|
||||
log.error("[获取平台和代理商信息] 未找到有效的平台方记录");
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
esignPlatformInfos.add(esignPlatformInfo);
|
||||
log.debug("[获取平台和代理商信息] 成功获取平台方信息,ID: {}", esignPlatformInfo.getId());
|
||||
|
||||
// 获取商户的二级代理
|
||||
EsignPlatformInfo agent2nd = getMch2ndAgent(mchId);
|
||||
if (agent2nd == null) {
|
||||
log.debug("[获取平台和代理商信息] 未找到二级代理,仅返回平台方信息");
|
||||
return esignPlatformInfos;
|
||||
}
|
||||
|
||||
esignPlatformInfos.add(agent2nd);
|
||||
log.debug("[获取平台和代理商信息] 成功获取二级代理信息,ID: {}", agent2nd.getId());
|
||||
|
||||
// 获取一级代理(如果存在)
|
||||
if (CheckUtil.isEmpty(agent2nd.getParent_id())) {
|
||||
if (agent2nd.getParent_id() == null || agent2nd.getParent_id() <= 0) {
|
||||
log.debug("[获取平台和代理商信息] 二级代理无有效父级ID,返回平台方和二级代理信息");
|
||||
return esignPlatformInfos;
|
||||
}
|
||||
|
||||
@ -100,11 +112,15 @@ public class EsignPlatformInfoServiceImpl extends BaseServiceImpl<EsignPlatformI
|
||||
EsignPlatformInfo agent1st = get(agent2nd.getParent_id());
|
||||
if (agent1st != null) {
|
||||
esignPlatformInfos.add(agent1st);
|
||||
log.debug("[获取平台和代理商信息] 成功获取一级代理信息,ID: {}", agent1st.getId());
|
||||
} else {
|
||||
log.debug("[获取平台和代理商信息] 未找到一级代理,parent_id: {}", agent2nd.getParent_id());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("[获取平台和代理商信息] 获取一级代理商时发生异常,parent_id: {}", agent2nd.getParent_id(), e);
|
||||
}
|
||||
|
||||
log.debug("[获取平台和代理商信息] 查询完成,共获取 {} 条记录", esignPlatformInfos.size());
|
||||
return esignPlatformInfos;
|
||||
}
|
||||
|
||||
@ -188,12 +204,14 @@ public class EsignPlatformInfoServiceImpl extends BaseServiceImpl<EsignPlatformI
|
||||
@Override
|
||||
public EsignPlatformInfo getMch2ndAgent(Long mchId) {
|
||||
// 参数校验
|
||||
if (CheckUtil.isEmpty(mchId)) {
|
||||
log.warn("[获取二级代理] 参数校验失败:商户入驻编号为空");
|
||||
if (mchId == null || mchId <= 0) {
|
||||
log.warn("[获取二级代理] 参数校验失败:商户入驻编号为空或无效,mchId={}", mchId);
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
log.debug("[获取二级代理] 开始查询二级代理信息,mchId={}", mchId);
|
||||
|
||||
// 获取商户入驻信息
|
||||
ShopMchEntry shopMchEntry = shopMchEntryService.shopMerchEntryById(mchId);
|
||||
if (shopMchEntry == null) {
|
||||
@ -202,7 +220,8 @@ public class EsignPlatformInfoServiceImpl extends BaseServiceImpl<EsignPlatformI
|
||||
}
|
||||
|
||||
// 检查是否有指定的分销商ID或区域信息
|
||||
if (CheckUtil.isEmpty(shopMchEntry.getDistributor_id()) && StrUtil.isBlank(shopMchEntry.getStore_district())) {
|
||||
if ((shopMchEntry.getDistributor_id() == null || shopMchEntry.getDistributor_id() <= 0)
|
||||
&& StrUtil.isBlank(shopMchEntry.getStore_district())) {
|
||||
log.debug("[获取二级代理] 商户未指定分销商且无区域信息,mchId={}", mchId);
|
||||
return null;
|
||||
}
|
||||
@ -214,27 +233,20 @@ public class EsignPlatformInfoServiceImpl extends BaseServiceImpl<EsignPlatformI
|
||||
.orderByAsc("id");
|
||||
|
||||
// 优先使用指定的分销商ID查询,否则使用区域信息查询
|
||||
if (CheckUtil.isNotEmpty(shopMchEntry.getDistributor_id())) {
|
||||
if (shopMchEntry.getDistributor_id() != null && shopMchEntry.getDistributor_id() > 0) {
|
||||
queryWrapper.eq("id", shopMchEntry.getDistributor_id());
|
||||
log.debug("[获取二级代理] 使用指定分销商ID查询,distributorId={}", shopMchEntry.getDistributor_id());
|
||||
} else if (StrUtil.isNotBlank(shopMchEntry.getStore_district())) {
|
||||
// 运费代理商
|
||||
queryWrapper.eq("license_district_id", shopMchEntry.getStore_district())
|
||||
.gt("shipping_fee", 0).ne("supplier_id", "")
|
||||
.orderByAsc("id");
|
||||
log.debug("[获取二级代理] 使用区域信息查询,districtId={}", shopMchEntry.getStore_district());
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
EsignPlatformInfo result = findOne(queryWrapper);
|
||||
if (result == null) {
|
||||
if (StrUtil.isNotBlank(shopMchEntry.getStore_district())) {
|
||||
// 运费代理商
|
||||
queryWrapper.clear();
|
||||
queryWrapper.eq("level", CommonConstant.Agent_Level_2nd)
|
||||
.eq("status", CommonConstant.Enable)
|
||||
.eq("license_district_id", shopMchEntry.getStore_district())
|
||||
.gt("shipping_fee", 0).ne("supplier_id", "")
|
||||
.orderByAsc("id");
|
||||
log.debug("[获取二级代理] 使用区域信息查询,districtId={}", shopMchEntry.getStore_district());
|
||||
|
||||
result = findOne(queryWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
if (result == null) {
|
||||
log.info("[获取二级代理] 未找到匹配的二级代理信息,mchId={}", mchId);
|
||||
} else {
|
||||
|
||||
@ -34,6 +34,7 @@ import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@ -374,17 +375,24 @@ public class LklLedgerReceiverServiceImpl extends BaseServiceImpl<LklLedgerRecei
|
||||
*/
|
||||
@Override
|
||||
public List<LklLedgerReceiver> selectAgentAndPlatformByMchId(Long mchId) {
|
||||
List<LklLedgerReceiver> list = new ArrayList<>();
|
||||
|
||||
log.debug("[获取平台和代理商信息] 开始查询平台方和代理商接收方信息,商户ID: {}", mchId);
|
||||
|
||||
// 获取平台方记录
|
||||
QueryWrapper<LklLedgerReceiver> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("level", 0)
|
||||
.eq("status", CommonConstant.Enable).orderByAsc("id");
|
||||
|
||||
List<LklLedgerReceiver> list = list(queryWrapper);
|
||||
if (CollectionUtil.isEmpty(list)) {
|
||||
log.error("[获取平台和代理商信息] 未找到平台方记录, mchId={}", mchId);
|
||||
LklLedgerReceiver platformInfo = findOne(queryWrapper);
|
||||
if (platformInfo == null || platformInfo.getId() == null || platformInfo.getId() <= 0) {
|
||||
log.error("[获取平台和代理商信息] 未找到有效的平台方记录, mchId={}", mchId);
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
list.add(platformInfo);
|
||||
log.debug("[获取平台和代理商信息] 成功获取平台方信息,ID: {}", platformInfo.getId());
|
||||
|
||||
// 获取商户的二级代理
|
||||
LklLedgerReceiver agent2nd = getMch2ndAgent(mchId);
|
||||
if (agent2nd == null) {
|
||||
@ -393,10 +401,11 @@ public class LklLedgerReceiverServiceImpl extends BaseServiceImpl<LklLedgerRecei
|
||||
}
|
||||
|
||||
list.add(agent2nd);
|
||||
log.debug("[获取平台和代理商信息] 成功获取二级代理信息,ID: {}", agent2nd.getId());
|
||||
|
||||
// 获取一级代理(如果存在)
|
||||
if (CheckUtil.isEmpty(agent2nd.getParent_id())) {
|
||||
log.debug("[获取平台和代理商信息] 二级代理商无上级代理, mchId={}", mchId);
|
||||
if (agent2nd.getParent_id() == null || agent2nd.getParent_id() <= 0) {
|
||||
log.debug("[获取平台和代理商信息] 二级代理商无有效上级代理, mchId={}", mchId);
|
||||
return list;
|
||||
}
|
||||
|
||||
@ -408,6 +417,7 @@ public class LklLedgerReceiverServiceImpl extends BaseServiceImpl<LklLedgerRecei
|
||||
LklLedgerReceiver agent1st = findOne(queryWrapper);
|
||||
if (agent1st != null) {
|
||||
list.add(agent1st);
|
||||
log.debug("[获取平台和代理商信息] 成功获取一级代理信息,ID: {}", agent1st.getId());
|
||||
} else {
|
||||
log.warn("[获取平台和代理商信息] 未找到一级代理商, parent_id: {}, mchId: {}", agent2nd.getParent_id(), mchId);
|
||||
}
|
||||
@ -415,6 +425,7 @@ public class LklLedgerReceiverServiceImpl extends BaseServiceImpl<LklLedgerRecei
|
||||
log.error("[获取平台和代理商信息] 获取一级代理商时发生异常,parent_id: {}, mchId: {}", agent2nd.getParent_id(), mchId, e);
|
||||
}
|
||||
|
||||
log.debug("[获取平台和代理商信息] 查询完成,共获取 {} 条记录", list.size());
|
||||
return list;
|
||||
}
|
||||
|
||||
@ -427,12 +438,14 @@ public class LklLedgerReceiverServiceImpl extends BaseServiceImpl<LklLedgerRecei
|
||||
@Override
|
||||
public LklLedgerReceiver getMch2ndAgent(Long mchId) {
|
||||
// 参数校验
|
||||
if (CheckUtil.isEmpty(mchId)) {
|
||||
log.warn("[获取二级代理] 参数校验失败:商户入驻编号为空");
|
||||
if (mchId == null || mchId <= 0) {
|
||||
log.warn("[获取二级代理] 参数校验失败:商户入驻编号为空或无效,mchId={}", mchId);
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
log.debug("[获取二级代理] 开始查询二级代理接收方信息,mchId={}", mchId);
|
||||
|
||||
// 获取商户入驻信息
|
||||
ShopMchEntry shopMchEntry = shopMchEntryService.shopMerchEntryById(mchId);
|
||||
if (shopMchEntry == null) {
|
||||
@ -441,7 +454,8 @@ public class LklLedgerReceiverServiceImpl extends BaseServiceImpl<LklLedgerRecei
|
||||
}
|
||||
|
||||
// 检查是否有指定的分销商ID或区域信息
|
||||
if (CheckUtil.isEmpty(shopMchEntry.getDistributor_id()) && StrUtil.isBlank(shopMchEntry.getStore_district())) {
|
||||
if ((shopMchEntry.getDistributor_id() == null || shopMchEntry.getDistributor_id() <= 0)
|
||||
&& StrUtil.isBlank(shopMchEntry.getStore_district())) {
|
||||
log.debug("[获取二级代理] 商户未指定分销商且无区域信息,mchId={}", mchId);
|
||||
return null;
|
||||
}
|
||||
@ -453,22 +467,21 @@ public class LklLedgerReceiverServiceImpl extends BaseServiceImpl<LklLedgerRecei
|
||||
.orderByAsc("id");
|
||||
|
||||
// 优先使用指定的分销商ID查询,否则使用区域信息查询
|
||||
if (CheckUtil.isNotEmpty(shopMchEntry.getDistributor_id())) {
|
||||
if (shopMchEntry.getDistributor_id() != null && shopMchEntry.getDistributor_id() > 0) {
|
||||
queryWrapper.eq("platform_id", shopMchEntry.getDistributor_id());
|
||||
log.debug("[获取二级代理] 使用指定分销商ID查询,distributorId={}", shopMchEntry.getDistributor_id());
|
||||
} else if (StrUtil.isNotBlank(shopMchEntry.getStore_district())) {
|
||||
// 运费代理商
|
||||
queryWrapper.clear();
|
||||
queryWrapper.eq("level", CommonConstant.Agent_Level_2nd)
|
||||
.eq("status", CommonConstant.Enable)
|
||||
.eq("license_district_id", shopMchEntry.getStore_district())
|
||||
queryWrapper.eq("license_district_id", shopMchEntry.getStore_district())
|
||||
.gt("shipping_fee", 0).ne("supplier_id", "")
|
||||
.orderByAsc("id");
|
||||
log.debug("[获取二级代理] 使用区域信息查询,districtId={}", shopMchEntry.getStore_district());
|
||||
} else {
|
||||
log.warn("[获取二级代理] 未指定分销商ID或区域信息,mchId={}", mchId);
|
||||
return null;
|
||||
}
|
||||
|
||||
LklLedgerReceiver result = findOne(queryWrapper);
|
||||
|
||||
if (result == null) {
|
||||
log.info("[获取二级代理] 未找到匹配的二级代理信息,mchId={}", mchId);
|
||||
} else {
|
||||
@ -478,7 +491,7 @@ public class LklLedgerReceiverServiceImpl extends BaseServiceImpl<LklLedgerRecei
|
||||
return result;
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("[获取二级代理] 查询过程中发生异常,mchId=" + mchId, e);
|
||||
log.error("[获取二级代理] 查询过程中发生异常,mchId={}", mchId, e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user