货运账户列表修改
This commit is contained in:
parent
379ec8a77e
commit
675b5ebc65
@ -140,4 +140,10 @@ public interface FreightGoldClientApi {
|
||||
*/
|
||||
@PostMapping("/updateFreightBalanceInfo")
|
||||
ResultResponse<Boolean> updateFreightBalanceInfo(@RequestBody @Validated UpdateFreightBalanceInfoCmd cmd);
|
||||
|
||||
/**
|
||||
* 批量查询用户交易次数(type=1的记录数).
|
||||
*/
|
||||
@PostMapping("/mapTransactionCountByUserIds")
|
||||
ResultResponse<Map<Long, Long>> mapTransactionCountByUserIds(@RequestBody Set<Long> userIds);
|
||||
}
|
||||
|
||||
@ -107,6 +107,16 @@ public class UserFreightBalanceDTO implements Serializable {
|
||||
*/
|
||||
private Long realSellerQuantity;
|
||||
|
||||
/**
|
||||
* 成为代理天数(根据createTime计算).
|
||||
*/
|
||||
private Integer becomeDays;
|
||||
|
||||
/**
|
||||
* 交易数量(出货次数,type=1).
|
||||
*/
|
||||
private Long transactionCount;
|
||||
|
||||
public BigDecimal getBalance() {
|
||||
return earnPoints.subtract(consumptionPoints).setScale(2, RoundingMode.DOWN);
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.red.circle.other.adapter.app.user.user;
|
||||
|
||||
import com.red.circle.common.business.dto.cmd.AppExtCommand;
|
||||
import com.red.circle.framework.dto.PageResult;
|
||||
import com.red.circle.framework.web.controller.BaseController;
|
||||
import com.red.circle.other.app.dto.clientobject.user.UserFreightBalanceCO;
|
||||
@ -38,8 +39,8 @@ public class UserFreightBalanceRestController extends BaseController {
|
||||
* @eo.request-type formdata
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
public PageResult<UserFreightBalanceCO> pageFreight(UserFreightBalancePageQryCmd cmd) {
|
||||
return userFreightBalanceRestService.pageFreight(cmd);
|
||||
public PageResult<UserFreightBalanceCO> pageFreight(UserFreightBalancePageQryCmd cmd, AppExtCommand appExtCommand) {
|
||||
return userFreightBalanceRestService.pageFreight(cmd, appExtCommand);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,18 +1,23 @@
|
||||
package com.red.circle.other.app.service.user.impl;
|
||||
|
||||
import com.red.circle.common.business.dto.cmd.AppExtCommand;
|
||||
import com.red.circle.framework.core.asserts.ResponseAssert;
|
||||
import com.red.circle.framework.dto.PageResult;
|
||||
import com.red.circle.other.app.convertor.UserFreightBalanceConvertor;
|
||||
import com.red.circle.other.app.dto.clientobject.user.UserFreightBalanceCO;
|
||||
import com.red.circle.other.app.service.user.UserFreightBalanceRestService;
|
||||
import com.red.circle.other.domain.gateway.user.UserProfileGateway;
|
||||
import com.red.circle.other.inner.endpoint.user.user.UserProfileClient;
|
||||
import com.red.circle.other.inner.model.dto.user.UserProfileDTO;
|
||||
import com.red.circle.wallet.inner.endpoint.freight.FreightBalanceClient;
|
||||
import com.red.circle.wallet.inner.endpoint.freight.FreightGoldClient;
|
||||
import com.red.circle.wallet.inner.model.cmd.UserFreightBalancePageQryCmd;
|
||||
import com.red.circle.wallet.inner.model.dto.UserFreightBalanceDTO;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -31,10 +36,11 @@ public class UserFreightBalanceRestServiceImpl implements UserFreightBalanceRest
|
||||
|
||||
private final FreightGoldClient freightGoldClient;
|
||||
private final UserProfileClient userProfileClient;
|
||||
private final UserProfileGateway userProfileGateway;
|
||||
private final UserFreightBalanceConvertor userFreightBalanceConvertor;
|
||||
|
||||
@Override
|
||||
public PageResult<UserFreightBalanceCO> pageFreight(UserFreightBalancePageQryCmd cmd) {
|
||||
public PageResult<UserFreightBalanceCO> pageFreight(UserFreightBalancePageQryCmd cmd, AppExtCommand appExtCommand) {
|
||||
// 写死默认查询条件:H5开启且未关闭
|
||||
cmd.setH5Display(true);
|
||||
cmd.setClose(false);
|
||||
@ -46,20 +52,39 @@ public class UserFreightBalanceRestServiceImpl implements UserFreightBalanceRest
|
||||
return freightPageResult.emptyRecords();
|
||||
}
|
||||
|
||||
// 2. 查询用户ID集合
|
||||
Set<Long> userIds = freightPageResult.getRecords().stream()
|
||||
.map(UserFreightBalanceDTO::getUserId)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
// 3. 查询用户基本信息
|
||||
Map<Long, UserProfileDTO> userBaseInfoMap = ResponseAssert.requiredSuccess(
|
||||
userProfileClient.mapByUserIds(
|
||||
freightPageResult.getRecords().stream()
|
||||
.map(UserFreightBalanceDTO::getUserId)
|
||||
.collect(Collectors.toSet())
|
||||
)
|
||||
userProfileClient.mapByUserIds(userIds)
|
||||
);
|
||||
|
||||
// 4. 转换并组装数据
|
||||
// 4. 查询交易次数(type=1)
|
||||
Map<Long, Long> transactionCountMap = freightGoldClient.mapTransactionCountByUserIds(userIds).getBody();
|
||||
|
||||
// 5. 转换并组装数据
|
||||
return freightPageResult.convert(dto -> {
|
||||
UserFreightBalanceCO co = userFreightBalanceConvertor.toUserFreightBalanceCO(dto);
|
||||
co.setBalance(dto.getBalance());
|
||||
co.setIsFollow(userProfileGateway.checkFollow(appExtCommand.getReqUserId(), dto.getUserId()));
|
||||
co.setUserBaseInfo(userBaseInfoMap.get(dto.getUserId()));
|
||||
|
||||
// 计算成为代理天数
|
||||
if (dto.getCreateTime() != null) {
|
||||
LocalDateTime createTime = dto.getCreateTime().toLocalDateTime();
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
long days = ChronoUnit.DAYS.between(createTime, now);
|
||||
co.setBecomeDays((int) days);
|
||||
}
|
||||
|
||||
// 设置交易次数
|
||||
co.setTransactionCount(
|
||||
Optional.ofNullable(transactionCountMap.get(dto.getUserId())).orElse(0L)
|
||||
);
|
||||
|
||||
return co;
|
||||
});
|
||||
}
|
||||
|
||||
@ -88,6 +88,11 @@ public class UserFreightBalanceCO extends ClientObject {
|
||||
*/
|
||||
private String supportedCountries;
|
||||
|
||||
/**
|
||||
* 是否关注
|
||||
*/
|
||||
private Boolean isFollow;
|
||||
|
||||
/**
|
||||
* 联系方式.
|
||||
*/
|
||||
@ -108,6 +113,16 @@ public class UserFreightBalanceCO extends ClientObject {
|
||||
*/
|
||||
private Long realSellerQuantity;
|
||||
|
||||
/**
|
||||
* 成为代理天数(根据createTime计算).
|
||||
*/
|
||||
private Integer becomeDays;
|
||||
|
||||
/**
|
||||
* 交易数量(出货次数,type=1).
|
||||
*/
|
||||
private Long transactionCount;
|
||||
|
||||
/**
|
||||
* 用户基本信息.
|
||||
*/
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.red.circle.other.app.service.user;
|
||||
|
||||
import com.red.circle.common.business.dto.cmd.AppExtCommand;
|
||||
import com.red.circle.framework.dto.PageResult;
|
||||
import com.red.circle.other.app.dto.clientobject.user.UserFreightBalanceCO;
|
||||
import com.red.circle.wallet.inner.model.cmd.UserFreightBalancePageQryCmd;
|
||||
@ -15,6 +16,6 @@ public interface UserFreightBalanceRestService {
|
||||
/**
|
||||
* 分页查询用户货运账户.
|
||||
*/
|
||||
PageResult<UserFreightBalanceCO> pageFreight(UserFreightBalancePageQryCmd cmd);
|
||||
PageResult<UserFreightBalanceCO> pageFreight(UserFreightBalancePageQryCmd cmd, AppExtCommand appExtCommand);
|
||||
|
||||
}
|
||||
|
||||
@ -7,6 +7,8 @@ import com.red.circle.wallet.inner.model.cmd.UserFreightBalanceRunningWaterExpor
|
||||
import com.red.circle.wallet.inner.model.cmd.UserFreightBalanceRunningWaterPageQryCmd;
|
||||
import com.red.circle.wallet.inner.model.cmd.UserFreightSellerRunningWaterPageQryCmd;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@ -61,4 +63,12 @@ public interface FreightBalanceRunningWaterService extends BaseService<FreightBa
|
||||
|
||||
List<FreightBalanceRunningWater> listExportBalanceRunningWater(
|
||||
UserFreightBalanceRunningWaterExportQryCmd query);
|
||||
|
||||
/**
|
||||
* 批量统计用户交易次数(type=1的记录数).
|
||||
*
|
||||
* @param userIds 用户ID集合
|
||||
* @return 用户ID -> 交易次数
|
||||
*/
|
||||
Map<Long, Long> countTransactionsByUserIds(Set<Long> userIds);
|
||||
}
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
package com.red.circle.wallet.infra.database.rds.service.freight.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.red.circle.framework.dto.PageResult;
|
||||
import com.red.circle.framework.mybatis.constant.PageConstant;
|
||||
import com.red.circle.framework.mybatis.service.impl.BaseServiceImpl;
|
||||
import com.red.circle.tool.core.collection.CollectionUtils;
|
||||
import com.red.circle.tool.core.date.TimestampUtils;
|
||||
import com.red.circle.tool.core.text.StringUtils;
|
||||
import com.red.circle.wallet.infra.database.rds.dao.FreightBalanceRunningWaterDAO;
|
||||
@ -12,8 +14,13 @@ import com.red.circle.wallet.inner.model.cmd.UserFreightBalanceRunningWaterExpor
|
||||
import com.red.circle.wallet.inner.model.cmd.UserFreightBalanceRunningWaterPageQryCmd;
|
||||
import com.red.circle.wallet.inner.model.cmd.UserFreightSellerRunningWaterPageQryCmd;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
@ -115,4 +122,18 @@ public class FreightBalanceRunningWaterServiceImpl extends
|
||||
.apply("DATE_FORMAT(create_time,'%Y%m')={0}", query.getMonthDate())
|
||||
.list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Long, Long> countTransactionsByUserIds(Set<Long> userIds) {
|
||||
if (CollectionUtils.isEmpty(userIds)) {
|
||||
return new HashMap<>();
|
||||
}
|
||||
|
||||
List<FreightBalanceRunningWater> list = query()
|
||||
.select(FreightBalanceRunningWater::getUserId)
|
||||
.in(FreightBalanceRunningWater::getUserId, userIds)
|
||||
.eq(FreightBalanceRunningWater::getType, 1)
|
||||
.list();
|
||||
return list.stream().collect(Collectors.groupingBy(FreightBalanceRunningWater::getUserId, Collectors.counting()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -184,4 +184,9 @@ public class FreightGoldClientEndpoint implements FreightGoldClientApi {
|
||||
public ResultResponse<Boolean> updateFreightBalanceInfo(UpdateFreightBalanceInfoCmd cmd) {
|
||||
return ResultResponse.success(freightGoldClientService.updateFreightBalanceInfo(cmd));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultResponse<Map<Long, Long>> mapTransactionCountByUserIds(Set<Long> userIds) {
|
||||
return ResultResponse.success(freightGoldClientService.mapTransactionCountByUserIds(userIds));
|
||||
}
|
||||
}
|
||||
|
||||
@ -111,4 +111,9 @@ public interface FreightGoldClientService {
|
||||
* 更新货运代理账户信息(国家和联系方式).
|
||||
*/
|
||||
Boolean updateFreightBalanceInfo(UpdateFreightBalanceInfoCmd cmd);
|
||||
|
||||
/**
|
||||
* 批量查询用户交易次数(type=1的记录数).
|
||||
*/
|
||||
Map<Long, Long> mapTransactionCountByUserIds(Set<Long> userIds);
|
||||
}
|
||||
|
||||
@ -255,4 +255,9 @@ public class FreightGoldClientServiceImpl implements FreightGoldClientService {
|
||||
.set(FreightBalance::getContactInfo, cmd.getContactInfo())
|
||||
.execute();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Long, Long> mapTransactionCountByUserIds(Set<Long> userIds) {
|
||||
return freightBalanceRunningWaterService.countTransactionsByUserIds(userIds);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user