diff --git a/rc-service/rc-inner-api/wallet-inner/wallet-inner-api/src/main/java/com/red/circle/wallet/inner/endpoint/freight/api/FreightGoldClientApi.java b/rc-service/rc-inner-api/wallet-inner/wallet-inner-api/src/main/java/com/red/circle/wallet/inner/endpoint/freight/api/FreightGoldClientApi.java index af4e2583..6983efc9 100644 --- a/rc-service/rc-inner-api/wallet-inner/wallet-inner-api/src/main/java/com/red/circle/wallet/inner/endpoint/freight/api/FreightGoldClientApi.java +++ b/rc-service/rc-inner-api/wallet-inner/wallet-inner-api/src/main/java/com/red/circle/wallet/inner/endpoint/freight/api/FreightGoldClientApi.java @@ -7,6 +7,7 @@ import com.red.circle.wallet.inner.model.cmd.AddFreightBalanceRunningWaterCmd; import com.red.circle.wallet.inner.model.cmd.FreightAgentReviewCmd; import com.red.circle.wallet.inner.model.cmd.FreightBalanceCmd; import com.red.circle.wallet.inner.model.cmd.FreightBalanceRunningWaterCmd; +import com.red.circle.wallet.inner.model.cmd.FreightSubSellerUnbindCmd; import com.red.circle.wallet.inner.model.cmd.UpdateFreightBalanceInfoCmd; import com.red.circle.wallet.inner.model.cmd.UserFreightBalancePageQryCmd; import com.red.circle.wallet.inner.model.cmd.UserFreightBalanceRunningWaterExportQryCmd; @@ -17,6 +18,7 @@ import com.red.circle.wallet.inner.model.cmd.UserFreightSellerRunningWaterPageQr import com.red.circle.wallet.inner.model.dto.UserFreightBalanceDTO; import com.red.circle.wallet.inner.model.dto.UserFreightBalanceRunningWaterDTO; import com.red.circle.wallet.inner.model.dto.UserFreightSellerDTO; +import com.red.circle.wallet.inner.model.dto.FreightSubSellerRelationDTO; import java.math.BigDecimal; import java.util.List; import java.util.Map; @@ -138,6 +140,21 @@ public interface FreightGoldClientApi { @GetMapping("/removeFreightSeller") ResultResponse removeFreightSeller(@RequestParam("id") Long id); + /** + * 查询子 coin seller 当前绑定的超级经销商关系. + */ + @GetMapping("/getFreightSubSellerRelation") + ResultResponse getFreightSubSellerRelation( + @RequestParam("sysOrigin") String sysOrigin, + @RequestParam("childUserId") Long childUserId); + + /** + * 后台解绑子 coin seller 的上级超级经销商. + */ + @PostMapping("/unbindFreightSubSellerRelation") + ResultResponse unbindFreightSubSellerRelation( + @RequestBody @Validated FreightSubSellerUnbindCmd cmd); + /** * 更新货运代理账户信息(国家和联系方式). */ diff --git a/rc-service/rc-inner-api/wallet-inner/wallet-inner-model/src/main/java/com/red/circle/wallet/inner/model/cmd/FreightSubSellerUnbindCmd.java b/rc-service/rc-inner-api/wallet-inner/wallet-inner-model/src/main/java/com/red/circle/wallet/inner/model/cmd/FreightSubSellerUnbindCmd.java new file mode 100644 index 00000000..36fae1da --- /dev/null +++ b/rc-service/rc-inner-api/wallet-inner/wallet-inner-model/src/main/java/com/red/circle/wallet/inner/model/cmd/FreightSubSellerUnbindCmd.java @@ -0,0 +1,37 @@ +package com.red.circle.wallet.inner.model.cmd; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import java.io.Serial; +import java.io.Serializable; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 后台解绑超级经销商与子 coin seller 的关系. + */ +@Data +@Accessors(chain = true) +public class FreightSubSellerUnbindCmd implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + /** + * 当前绑定关系 id,用于避免并发换绑时误删新关系. + */ + @NotNull(message = "relationId required.") + private Long relationId; + + /** + * 来源系统. + */ + @NotBlank(message = "sysOrigin required.") + private String sysOrigin; + + /** + * 子 coin seller 用户 id. + */ + @NotNull(message = "childUserId required.") + private Long childUserId; +} diff --git a/rc-service/rc-inner-api/wallet-inner/wallet-inner-model/src/main/java/com/red/circle/wallet/inner/model/dto/FreightSubSellerRelationDTO.java b/rc-service/rc-inner-api/wallet-inner/wallet-inner-model/src/main/java/com/red/circle/wallet/inner/model/dto/FreightSubSellerRelationDTO.java new file mode 100644 index 00000000..9c139d4e --- /dev/null +++ b/rc-service/rc-inner-api/wallet-inner/wallet-inner-model/src/main/java/com/red/circle/wallet/inner/model/dto/FreightSubSellerRelationDTO.java @@ -0,0 +1,54 @@ +package com.red.circle.wallet.inner.model.dto; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import java.io.Serial; +import java.io.Serializable; +import java.sql.Timestamp; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 超级经销商与子 coin seller 的绑定关系. + */ +@Data +@Accessors(chain = true) +public class FreightSubSellerRelationDTO implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + /** + * 绑定关系 id. + */ + @JsonSerialize(using = ToStringSerializer.class) + private Long relationId; + + /** + * 来源系统. + */ + private String sysOrigin; + + /** + * 超级经销商 freight balance id. + */ + @JsonSerialize(using = ToStringSerializer.class) + private Long parentFreightId; + + /** + * 超级经销商用户 id. + */ + @JsonSerialize(using = ToStringSerializer.class) + private Long parentUserId; + + /** + * 子 coin seller 用户 id. + */ + @JsonSerialize(using = ToStringSerializer.class) + private Long childUserId; + + /** + * 绑定时间. + */ + private Timestamp createTime; +} diff --git a/rc-service/rc-service-console/console-adapter/src/main/java/com/red/circle/console/adapter/app/user/UserFreightRestController.java b/rc-service/rc-service-console/console-adapter/src/main/java/com/red/circle/console/adapter/app/user/UserFreightRestController.java index fd1296ad..c085f605 100644 --- a/rc-service/rc-service-console/console-adapter/src/main/java/com/red/circle/console/adapter/app/user/UserFreightRestController.java +++ b/rc-service/rc-service-console/console-adapter/src/main/java/com/red/circle/console/adapter/app/user/UserFreightRestController.java @@ -4,6 +4,7 @@ package com.red.circle.console.adapter.app.user; import com.alibaba.excel.EasyExcel; import com.red.circle.console.app.dto.clienobject.user.UserFreightBalanceCO; import com.red.circle.console.app.dto.clienobject.user.UserFreightBalanceRunningWaterCO; +import com.red.circle.console.app.dto.clienobject.user.FreightSubSellerParentCO; import com.red.circle.console.app.excel.model.freight.UserFreightBalanceRunningWaterExportModel; import com.red.circle.console.app.service.admin.UserAccountService; import com.red.circle.console.app.service.app.user.UserFreightService; @@ -14,6 +15,7 @@ import com.red.circle.framework.dto.PageResult; import com.red.circle.framework.web.controller.BaseController; import com.red.circle.other.inner.model.cmd.user.UserFreightBalanceCmd; import com.red.circle.wallet.inner.model.cmd.UpdateFreightBalanceInfoCmd; +import com.red.circle.wallet.inner.model.cmd.FreightSubSellerUnbindCmd; import com.red.circle.wallet.inner.model.cmd.UserFreightBalancePageQryCmd; import com.red.circle.wallet.inner.model.cmd.UserFreightBalanceRunningWaterExportQryCmd; import com.red.circle.wallet.inner.model.cmd.UserFreightBalanceRunningWaterPageQryCmd; @@ -30,6 +32,7 @@ import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; /** @@ -179,4 +182,24 @@ public class UserFreightRestController extends BaseController { userFreightService.updateFreightBalanceInfo(cmd); } + /** + * 查询币商当前绑定的上级经理. + */ + @GetMapping("/sub-seller-parent") + public FreightSubSellerParentCO getFreightSubSellerParent( + @RequestParam("sysOrigin") String sysOrigin, + @RequestParam("childUserId") Long childUserId) { + return userFreightService.getFreightSubSellerParent(sysOrigin, childUserId); + } + + /** + * 解绑币商当前绑定的上级经理. + */ + @OpsOperationReqLog("货运代理-解绑币商上级") + @PostMapping("/sub-seller-parent/unbind") + public void unbindFreightSubSellerParent( + @RequestBody @Validated FreightSubSellerUnbindCmd cmd) { + userFreightService.unbindFreightSubSellerParent(cmd); + } + } diff --git a/rc-service/rc-service-console/console-application/src/main/java/com/red/circle/console/app/service/app/user/UserFreightBalanceServiceImpl.java b/rc-service/rc-service-console/console-application/src/main/java/com/red/circle/console/app/service/app/user/UserFreightBalanceServiceImpl.java index aa21e9b1..eb830c33 100644 --- a/rc-service/rc-service-console/console-application/src/main/java/com/red/circle/console/app/service/app/user/UserFreightBalanceServiceImpl.java +++ b/rc-service/rc-service-console/console-application/src/main/java/com/red/circle/console/app/service/app/user/UserFreightBalanceServiceImpl.java @@ -4,6 +4,7 @@ import com.alibaba.nacos.shaded.com.google.common.collect.Lists; import com.red.circle.common.business.core.enums.SysOriginPlatformEnum; import com.red.circle.component.redis.service.RedisService; import com.red.circle.console.app.convertor.WalletAppConvertor; +import com.red.circle.console.app.dto.clienobject.user.FreightSubSellerParentCO; import com.red.circle.console.app.dto.clienobject.user.UserFreightBalanceCO; import com.red.circle.console.app.dto.clienobject.user.UserFreightBalanceRunningWaterCO; import com.red.circle.console.app.excel.model.freight.UserFreightBalanceRunningWaterExportModel; @@ -31,6 +32,7 @@ import com.red.circle.wallet.inner.endpoint.freight.FreightGoldClient; import com.red.circle.wallet.inner.error.WalletErrorCode; import com.red.circle.wallet.inner.model.cmd.AddFreightBalanceRunningWaterCmd; import com.red.circle.wallet.inner.model.cmd.FreightAgentReviewCmd; +import com.red.circle.wallet.inner.model.cmd.FreightSubSellerUnbindCmd; import com.red.circle.wallet.inner.model.cmd.UpdateFreightBalanceInfoCmd; import com.red.circle.wallet.inner.model.cmd.UserFreightBalancePageQryCmd; import com.red.circle.wallet.inner.model.cmd.UserFreightBalanceRunningWaterExportQryCmd; @@ -39,6 +41,7 @@ import com.red.circle.wallet.inner.model.cmd.UserFreightSellerCmd; import com.red.circle.wallet.inner.model.cmd.UserFreightSellerRunningWaterPageQryCmd; import com.red.circle.wallet.inner.model.dto.UserFreightBalanceDTO; import com.red.circle.wallet.inner.model.dto.UserFreightBalanceRunningWaterDTO; +import com.red.circle.wallet.inner.model.dto.FreightSubSellerRelationDTO; import com.red.circle.wallet.inner.model.enums.FreightBalanceOrigin; import java.math.BigDecimal; import java.math.RoundingMode; @@ -547,4 +550,29 @@ public class UserFreightBalanceServiceImpl implements ResponseAssert.requiredSuccess(freightGoldClient.updateFreightBalanceInfo(cmd)); } + @Override + public FreightSubSellerParentCO getFreightSubSellerParent(String sysOrigin, Long childUserId) { + FreightSubSellerRelationDTO relation = ResponseAssert.requiredSuccess( + freightGoldClient.getFreightSubSellerRelation(sysOrigin, childUserId)); + if (Objects.isNull(relation)) { + return null; + } + + UserProfileDTO parentUser = ResponseAssert.requiredSuccess( + userProfileClient.getByUserId(relation.getParentUserId())); + return new FreightSubSellerParentCO() + .setRelationId(relation.getRelationId()) + .setSysOrigin(relation.getSysOrigin()) + .setParentFreightId(relation.getParentFreightId()) + .setParentUserId(relation.getParentUserId()) + .setChildUserId(relation.getChildUserId()) + .setCreateTime(relation.getCreateTime()) + .setParentUserBaseInfo(parentUser); + } + + @Override + public void unbindFreightSubSellerParent(FreightSubSellerUnbindCmd cmd) { + ResponseAssert.requiredSuccess(freightGoldClient.unbindFreightSubSellerRelation(cmd)); + } + } diff --git a/rc-service/rc-service-console/console-client/src/main/java/com/red/circle/console/app/dto/clienobject/user/FreightSubSellerParentCO.java b/rc-service/rc-service-console/console-client/src/main/java/com/red/circle/console/app/dto/clienobject/user/FreightSubSellerParentCO.java new file mode 100644 index 00000000..e6ea5751 --- /dev/null +++ b/rc-service/rc-service-console/console-client/src/main/java/com/red/circle/console/app/dto/clienobject/user/FreightSubSellerParentCO.java @@ -0,0 +1,42 @@ +package com.red.circle.console.app.dto.clienobject.user; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import com.red.circle.other.inner.model.dto.user.UserProfileDTO; +import java.io.Serial; +import java.io.Serializable; +import java.sql.Timestamp; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 后台展示的子 coin seller 上级绑定信息. + */ +@Data +@Accessors(chain = true) +public class FreightSubSellerParentCO implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + @JsonSerialize(using = ToStringSerializer.class) + private Long relationId; + + private String sysOrigin; + + @JsonSerialize(using = ToStringSerializer.class) + private Long parentFreightId; + + @JsonSerialize(using = ToStringSerializer.class) + private Long parentUserId; + + @JsonSerialize(using = ToStringSerializer.class) + private Long childUserId; + + private Timestamp createTime; + + /** + * 原上级经理的用户资料,便于后台操作前核对目标. + */ + private UserProfileDTO parentUserBaseInfo; +} diff --git a/rc-service/rc-service-console/console-client/src/main/java/com/red/circle/console/app/service/app/user/UserFreightService.java b/rc-service/rc-service-console/console-client/src/main/java/com/red/circle/console/app/service/app/user/UserFreightService.java index 339ccbf7..1bbef62a 100644 --- a/rc-service/rc-service-console/console-client/src/main/java/com/red/circle/console/app/service/app/user/UserFreightService.java +++ b/rc-service/rc-service-console/console-client/src/main/java/com/red/circle/console/app/service/app/user/UserFreightService.java @@ -2,9 +2,11 @@ package com.red.circle.console.app.service.app.user; import com.red.circle.console.app.dto.clienobject.user.UserFreightBalanceCO; import com.red.circle.console.app.dto.clienobject.user.UserFreightBalanceRunningWaterCO; +import com.red.circle.console.app.dto.clienobject.user.FreightSubSellerParentCO; import com.red.circle.framework.dto.PageResult; import com.red.circle.other.inner.model.cmd.user.UserFreightBalanceCmd; import com.red.circle.wallet.inner.model.cmd.UpdateFreightBalanceInfoCmd; +import com.red.circle.wallet.inner.model.cmd.FreightSubSellerUnbindCmd; import com.red.circle.wallet.inner.model.cmd.UserFreightBalancePageQryCmd; import com.red.circle.wallet.inner.model.cmd.UserFreightBalanceRunningWaterExportQryCmd; import com.red.circle.wallet.inner.model.cmd.UserFreightBalanceRunningWaterPageQryCmd; @@ -117,4 +119,14 @@ public interface UserFreightService { * 更新货运代理账户信息(国家和联系方式). */ void updateFreightBalanceInfo(UpdateFreightBalanceInfoCmd cmd); + + /** + * 查询子 coin seller 当前绑定的上级超级经销商. + */ + FreightSubSellerParentCO getFreightSubSellerParent(String sysOrigin, Long childUserId); + + /** + * 解绑子 coin seller 当前的上级超级经销商. + */ + void unbindFreightSubSellerParent(FreightSubSellerUnbindCmd cmd); } diff --git a/rc-service/rc-service-wallet/wallet-infrastructure/src/main/java/com/red/circle/wallet/infra/database/rds/service/freight/FreightSubSellerRelationService.java b/rc-service/rc-service-wallet/wallet-infrastructure/src/main/java/com/red/circle/wallet/infra/database/rds/service/freight/FreightSubSellerRelationService.java index b525e418..64620e7f 100644 --- a/rc-service/rc-service-wallet/wallet-infrastructure/src/main/java/com/red/circle/wallet/infra/database/rds/service/freight/FreightSubSellerRelationService.java +++ b/rc-service/rc-service-wallet/wallet-infrastructure/src/main/java/com/red/circle/wallet/infra/database/rds/service/freight/FreightSubSellerRelationService.java @@ -11,9 +11,13 @@ public interface FreightSubSellerRelationService extends BaseService listByParentUserId(String sysOrigin, Long parentUserId, Long parentFreightId); + + boolean removeBinding(String sysOrigin, Long childUserId, Long relationId); } diff --git a/rc-service/rc-service-wallet/wallet-infrastructure/src/main/java/com/red/circle/wallet/infra/database/rds/service/freight/impl/FreightSubSellerRelationServiceImpl.java b/rc-service/rc-service-wallet/wallet-infrastructure/src/main/java/com/red/circle/wallet/infra/database/rds/service/freight/impl/FreightSubSellerRelationServiceImpl.java index e10c3240..34eef85b 100644 --- a/rc-service/rc-service-wallet/wallet-infrastructure/src/main/java/com/red/circle/wallet/infra/database/rds/service/freight/impl/FreightSubSellerRelationServiceImpl.java +++ b/rc-service/rc-service-wallet/wallet-infrastructure/src/main/java/com/red/circle/wallet/infra/database/rds/service/freight/impl/FreightSubSellerRelationServiceImpl.java @@ -30,6 +30,15 @@ public class FreightSubSellerRelationServiceImpl extends .getOne()).isPresent(); } + @Override + public FreightSubSellerRelation getByChildUserId(String sysOrigin, Long childUserId) { + return query() + .eq(FreightSubSellerRelation::getSysOrigin, sysOrigin) + .eq(FreightSubSellerRelation::getChildUserId, childUserId) + .last(PageConstant.LIMIT_ONE) + .getOne(); + } + @Override public FreightSubSellerRelation getByParentAndChild(String sysOrigin, Long parentUserId, Long parentFreightId, Long childUserId) { @@ -54,4 +63,15 @@ public class FreightSubSellerRelationServiceImpl extends .list()) .orElseGet(CollectionUtils::newArrayList); } + + @Override + public boolean removeBinding(String sysOrigin, Long childUserId, Long relationId) { + // 同时匹配关系 id、平台和子币商,避免管理员查看后发生换绑时误删新关系. + return delete() + .eq(FreightSubSellerRelation::getId, relationId) + .eq(FreightSubSellerRelation::getSysOrigin, sysOrigin) + .eq(FreightSubSellerRelation::getChildUserId, childUserId) + .last(PageConstant.LIMIT_ONE) + .execute(); + } } diff --git a/rc-service/rc-service-wallet/wallet-inner-endpoint/src/main/java/com/red/circle/wallet/inner/convertor/WalletInnerConvertor.java b/rc-service/rc-service-wallet/wallet-inner-endpoint/src/main/java/com/red/circle/wallet/inner/convertor/WalletInnerConvertor.java index 18f27717..6e6ec46a 100644 --- a/rc-service/rc-service-wallet/wallet-inner-endpoint/src/main/java/com/red/circle/wallet/inner/convertor/WalletInnerConvertor.java +++ b/rc-service/rc-service-wallet/wallet-inner-endpoint/src/main/java/com/red/circle/wallet/inner/convertor/WalletInnerConvertor.java @@ -18,6 +18,7 @@ import com.red.circle.wallet.infra.database.rds.entity.freight.FreightAgentRevie import com.red.circle.wallet.infra.database.rds.entity.freight.FreightBalance; import com.red.circle.wallet.infra.database.rds.entity.freight.FreightBalanceRunningWater; import com.red.circle.wallet.infra.database.rds.entity.freight.FreightSeller; +import com.red.circle.wallet.infra.database.rds.entity.freight.FreightSubSellerRelation; import com.red.circle.wallet.inner.model.tmp.AssetRecordRunningWaterCO; import com.red.circle.wallet.inner.model.tmp.UserGoldRunningWaterClsTmpCO; import com.red.circle.wallet.inner.model.tmp.UserGoldRunningWaterTmpCO; @@ -40,6 +41,7 @@ import com.red.circle.wallet.inner.model.dto.UserDiamondRunWaterDTO; import com.red.circle.wallet.inner.model.dto.UserFreightBalanceDTO; import com.red.circle.wallet.inner.model.dto.UserFreightBalanceRunningWaterDTO; import com.red.circle.wallet.inner.model.dto.UserFreightSellerDTO; +import com.red.circle.wallet.inner.model.dto.FreightSubSellerRelationDTO; import com.red.circle.wallet.inner.model.dto.UserGoldRunningWaterClsHistoryDTO; import com.red.circle.wallet.inner.model.dto.UserGoldRunningWaterHistoryDTO; import com.red.circle.wallet.inner.model.dto.WalletGoldAssetRecordDTO; @@ -47,6 +49,7 @@ import com.red.circle.wallet.inner.model.dto.WalletReceiptDTO; import com.red.circle.wallet.inner.model.dto.WalletReceiptResDTO; import java.util.List; import org.mapstruct.Mapper; +import org.mapstruct.Mapping; /** * @author pengliang on 2023/12/25 @@ -108,6 +111,10 @@ public interface WalletInnerConvertor { UserFreightSellerDTO toUserFreightSellerDTO(FreightSeller freightSeller); + @Mapping(source = "id", target = "relationId") + FreightSubSellerRelationDTO toFreightSubSellerRelationDTO( + FreightSubSellerRelation relation); + UserDiamondOriginDTO toUserDiamondOriginDTO(DiamondRunningWater diamondRunningWater); diff --git a/rc-service/rc-service-wallet/wallet-inner-endpoint/src/main/java/com/red/circle/wallet/inner/endpoint/freight/FreightGoldClientEndpoint.java b/rc-service/rc-service-wallet/wallet-inner-endpoint/src/main/java/com/red/circle/wallet/inner/endpoint/freight/FreightGoldClientEndpoint.java index 3cc7c347..e4d67060 100644 --- a/rc-service/rc-service-wallet/wallet-inner-endpoint/src/main/java/com/red/circle/wallet/inner/endpoint/freight/FreightGoldClientEndpoint.java +++ b/rc-service/rc-service-wallet/wallet-inner-endpoint/src/main/java/com/red/circle/wallet/inner/endpoint/freight/FreightGoldClientEndpoint.java @@ -8,6 +8,7 @@ import com.red.circle.wallet.inner.model.cmd.AddFreightBalanceRunningWaterCmd; import com.red.circle.wallet.inner.model.cmd.FreightAgentReviewCmd; import com.red.circle.wallet.inner.model.cmd.FreightBalanceCmd; import com.red.circle.wallet.inner.model.cmd.FreightBalanceRunningWaterCmd; +import com.red.circle.wallet.inner.model.cmd.FreightSubSellerUnbindCmd; import com.red.circle.wallet.inner.model.cmd.UpdateFreightBalanceInfoCmd; import com.red.circle.wallet.inner.model.cmd.UserFreightBalancePageQryCmd; import com.red.circle.wallet.inner.model.cmd.UserFreightBalanceRunningWaterExportQryCmd; @@ -18,6 +19,7 @@ import com.red.circle.wallet.inner.model.cmd.UserFreightSellerRunningWaterPageQr import com.red.circle.wallet.inner.model.dto.UserFreightBalanceDTO; import com.red.circle.wallet.inner.model.dto.UserFreightBalanceRunningWaterDTO; import com.red.circle.wallet.inner.model.dto.UserFreightSellerDTO; +import com.red.circle.wallet.inner.model.dto.FreightSubSellerRelationDTO; import com.red.circle.wallet.inner.service.freight.FreightGoldClientService; import java.math.BigDecimal; import java.util.List; @@ -185,6 +187,19 @@ public class FreightGoldClientEndpoint implements FreightGoldClientApi { return ResultResponse.success(); } + @Override + public ResultResponse getFreightSubSellerRelation(String sysOrigin, + Long childUserId) { + return ResultResponse.success( + freightGoldClientService.getFreightSubSellerRelation(sysOrigin, childUserId)); + } + + @Override + public ResultResponse unbindFreightSubSellerRelation(FreightSubSellerUnbindCmd cmd) { + freightGoldClientService.unbindFreightSubSellerRelation(cmd); + return ResultResponse.success(); + } + @Override public ResultResponse updateFreightBalanceInfo(UpdateFreightBalanceInfoCmd cmd) { return ResultResponse.success(freightGoldClientService.updateFreightBalanceInfo(cmd)); diff --git a/rc-service/rc-service-wallet/wallet-inner-endpoint/src/main/java/com/red/circle/wallet/inner/service/freight/FreightGoldClientService.java b/rc-service/rc-service-wallet/wallet-inner-endpoint/src/main/java/com/red/circle/wallet/inner/service/freight/FreightGoldClientService.java index 47688400..dfcce288 100644 --- a/rc-service/rc-service-wallet/wallet-inner-endpoint/src/main/java/com/red/circle/wallet/inner/service/freight/FreightGoldClientService.java +++ b/rc-service/rc-service-wallet/wallet-inner-endpoint/src/main/java/com/red/circle/wallet/inner/service/freight/FreightGoldClientService.java @@ -6,6 +6,7 @@ import com.red.circle.wallet.inner.model.cmd.AddFreightBalanceRunningWaterCmd; import com.red.circle.wallet.inner.model.cmd.FreightAgentReviewCmd; import com.red.circle.wallet.inner.model.cmd.FreightBalanceCmd; import com.red.circle.wallet.inner.model.cmd.FreightBalanceRunningWaterCmd; +import com.red.circle.wallet.inner.model.cmd.FreightSubSellerUnbindCmd; import com.red.circle.wallet.inner.model.cmd.UpdateFreightBalanceInfoCmd; import com.red.circle.wallet.inner.model.cmd.UserFreightBalancePageQryCmd; import com.red.circle.wallet.inner.model.cmd.UserFreightBalanceRunningWaterExportQryCmd; @@ -16,6 +17,7 @@ import com.red.circle.wallet.inner.model.cmd.UserFreightSellerRunningWaterPageQr import com.red.circle.wallet.inner.model.dto.UserFreightBalanceDTO; import com.red.circle.wallet.inner.model.dto.UserFreightBalanceRunningWaterDTO; import com.red.circle.wallet.inner.model.dto.UserFreightSellerDTO; +import com.red.circle.wallet.inner.model.dto.FreightSubSellerRelationDTO; import java.math.BigDecimal; import java.util.List; import java.util.Map; @@ -109,6 +111,10 @@ public interface FreightGoldClientService { void removeFreightSeller(Long id); + FreightSubSellerRelationDTO getFreightSubSellerRelation(String sysOrigin, Long childUserId); + + void unbindFreightSubSellerRelation(FreightSubSellerUnbindCmd cmd); + /** * 更新货运代理账户信息(国家和联系方式). */ diff --git a/rc-service/rc-service-wallet/wallet-inner-endpoint/src/main/java/com/red/circle/wallet/inner/service/freight/impl/FreightGoldClientServiceImpl.java b/rc-service/rc-service-wallet/wallet-inner-endpoint/src/main/java/com/red/circle/wallet/inner/service/freight/impl/FreightGoldClientServiceImpl.java index 1a87a06d..8a69c6cd 100644 --- a/rc-service/rc-service-wallet/wallet-inner-endpoint/src/main/java/com/red/circle/wallet/inner/service/freight/impl/FreightGoldClientServiceImpl.java +++ b/rc-service/rc-service-wallet/wallet-inner-endpoint/src/main/java/com/red/circle/wallet/inner/service/freight/impl/FreightGoldClientServiceImpl.java @@ -10,15 +10,19 @@ import com.red.circle.wallet.domain.gateway.FreightShipGateway; import com.red.circle.wallet.infra.database.rds.entity.freight.FreightAgentReview; import com.red.circle.wallet.infra.database.rds.entity.freight.FreightBalance; import com.red.circle.wallet.infra.database.rds.entity.freight.FreightBalanceRunningWater; +import com.red.circle.wallet.infra.database.rds.entity.freight.FreightSubSellerRelation; import com.red.circle.wallet.infra.database.rds.service.freight.FreightBalanceRunningWaterService; import com.red.circle.wallet.infra.database.rds.service.freight.FreightBalanceService; import com.red.circle.wallet.infra.database.rds.service.freight.FreightSellerService; +import com.red.circle.wallet.infra.database.rds.service.freight.FreightSubSellerRelationService; import com.red.circle.wallet.infra.database.rds.service.freight.UserFreightAgentReviewService; import com.red.circle.wallet.inner.convertor.WalletInnerConvertor; +import com.red.circle.wallet.inner.error.FreightErrorCode; import com.red.circle.wallet.inner.model.cmd.AddFreightBalanceRunningWaterCmd; import com.red.circle.wallet.inner.model.cmd.FreightAgentReviewCmd; import com.red.circle.wallet.inner.model.cmd.FreightBalanceCmd; import com.red.circle.wallet.inner.model.cmd.FreightBalanceRunningWaterCmd; +import com.red.circle.wallet.inner.model.cmd.FreightSubSellerUnbindCmd; import com.red.circle.wallet.inner.model.cmd.UpdateFreightBalanceInfoCmd; import com.red.circle.wallet.inner.model.cmd.UserFreightBalancePageQryCmd; import com.red.circle.wallet.inner.model.cmd.UserFreightBalanceRunningWaterExportQryCmd; @@ -29,6 +33,7 @@ import com.red.circle.wallet.inner.model.cmd.UserFreightSellerRunningWaterPageQr import com.red.circle.wallet.inner.model.dto.UserFreightBalanceDTO; import com.red.circle.wallet.inner.model.dto.UserFreightBalanceRunningWaterDTO; import com.red.circle.wallet.inner.model.dto.UserFreightSellerDTO; +import com.red.circle.wallet.inner.model.dto.FreightSubSellerRelationDTO; import com.red.circle.wallet.inner.service.freight.FreightGoldClientService; import java.math.BigDecimal; import java.util.List; @@ -52,6 +57,7 @@ public class FreightGoldClientServiceImpl implements FreightGoldClientService { private final FreightShipGateway freightShipGateway; private final WalletInnerConvertor walletInnerConvertor; private final FreightSellerService freightSellerService; + private final FreightSubSellerRelationService freightSubSellerRelationService; private final FreightBalanceService freightBalanceService; private final UserFreightAgentReviewService freightAgentReviewService; private final UserFreightRechargeRecordClient userFreightRechargeRecordClient; @@ -252,6 +258,23 @@ public class FreightGoldClientServiceImpl implements FreightGoldClientService { freightSellerService.removeFreightSeller(id); } + @Override + public FreightSubSellerRelationDTO getFreightSubSellerRelation(String sysOrigin, + Long childUserId) { + FreightSubSellerRelation relation = + freightSubSellerRelationService.getByChildUserId(sysOrigin, childUserId); + return Objects.isNull(relation) ? null + : walletInnerConvertor.toFreightSubSellerRelationDTO(relation); + } + + @Override + public void unbindFreightSubSellerRelation(FreightSubSellerUnbindCmd cmd) { + // 只删除管理员刚刚查看到的关系,关系已变化时明确拒绝本次解绑. + ResponseAssert.isTrue(FreightErrorCode.NOT_SUB_FREIGHT_SELLER, + freightSubSellerRelationService.removeBinding(cmd.getSysOrigin(), cmd.getChildUserId(), + cmd.getRelationId())); + } + @Override public Boolean updateFreightBalanceInfo(UpdateFreightBalanceInfoCmd cmd) { return freightBalanceService.update()