| | |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.PhoneUtil; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.xiaopeng.api.dto.account.UcUserInfo; |
| | | import com.xiaopeng.api.feignClient.account.UserResourcesClient; |
| | | import com.xiaopeng.api.model.account.SysUser; |
| | | import com.xiaopeng.api.model.operation.XpWhitelist; |
| | | import com.xiaopeng.api.model.operation.XpWhitelistOperlog; |
| | |
| | | import com.xiaopeng.operation.mapper.XpWhitelistOperlogMapper; |
| | | import com.xiaopeng.operation.query.WhitelistPageListQuery; |
| | | import com.xiaopeng.operation.service.IXpWhitelistService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.apache.shardingsphere.transaction.annotation.ShardingSphereTransactionType; |
| | | import org.apache.shardingsphere.transaction.core.TransactionType; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Comparator; |
| | | import java.util.HashMap; |
| | | import java.util.HashSet; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | |
| | | @Autowired |
| | | private XpWhitelistOperlogMapper xpWhitelistOperlogMapper; |
| | | @Autowired |
| | | private UserResourcesClient userResourcesClient; |
| | | |
| | | |
| | | @Override |
| | | public PageInfo<XpWhitelist> pageList(WhitelistPageListQuery query) { |
| | | PageInfo<XpWhitelist> pageInfo = new PageInfo<>(query.getPageNum(),query.getPageSize()); |
| | |
| | | public List<XpWhitelist> exportList(WhitelistPageListQuery query) { |
| | | List<XpWhitelist> list = this.baseMapper.exportList(query); |
| | | return list; |
| | | } |
| | | |
| | | //根据用户账号 通过接口获取用户id |
| | | public UcUserInfo getUserByAccount (String account){ |
| | | UcUserInfo userByMobile = userResourcesClient.getUserByMobile(account); |
| | | if(userByMobile == null){ |
| | | throw new ServiceException(account+"未获取到用户信息"); |
| | | } |
| | | return userByMobile; |
| | | } |
| | | |
| | | @Override |
| | |
| | | Map<String, Long> reasonCountMap = new HashMap<>(); |
| | | Map<String, LinkedHashSet<String>> reasonSampleMap = new HashMap<>(); |
| | | |
| | | Map<String, UcUserInfo> userMap = new HashMap<>(); |
| | | Set<String> seenAccounts = new HashSet<>(); |
| | | List<String> candidates = new ArrayList<>(); |
| | | for (String account : accounts) { |
| | |
| | | recordFail(reasonCountMap, reasonSampleMap, "文件内重复", account, sampleLimitPerReason); |
| | | continue; |
| | | } |
| | | candidates.add(account); |
| | | //根据用户账号 通过接口获取用户id |
| | | UcUserInfo userByAccount = this.getUserByAccount(account); |
| | | if(userByAccount != null){ |
| | | candidates.add(account); |
| | | userMap.put(account, userByAccount); |
| | | } |
| | | } |
| | | if (CollUtil.isEmpty(candidates)) { |
| | | return R.fail("所有帐号添加失败,请检查帐号格式或唯一性"); |
| | |
| | | } |
| | | XpWhitelist xpWhitelist = new XpWhitelist(); |
| | | xpWhitelist.setAccount(account); |
| | | xpWhitelist.setNickName(userMap.get(account).getNickName()); |
| | | xpWhitelist.setAppUserId(userMap.get(account).getUid()); |
| | | xpWhitelist.setStatus(true); |
| | | xpWhitelist.setIsPriorityDispatch(dto.getIsPriorityDispatch()); |
| | | xpWhitelist.setWhitelistSource(1); |
| | |
| | | if (!PhoneUtil.isMobile(dto.getAccount())) { |
| | | throw new ServiceException("以下帐号格式不正确:", I18nKeyConstant.ACCOUNT_FORMAT_ERROR, new Object[]{dto.getAccount()}); |
| | | } |
| | | UcUserInfo userByAccount = this.getUserByAccount(dto.getAccount()); |
| | | XpWhitelist old = this.lambdaQuery() |
| | | .eq(XpWhitelist::getAccount, dto.getAccount()) |
| | | .ne(XpWhitelist::getId, dto.getId()) |
| | |
| | | } |
| | | XpWhitelist whitelist = this.getById(dto.getId()); |
| | | |
| | | whitelist.setAppUserId(userByAccount.getUid()); |
| | | |
| | | StringBuilder operationContent = new StringBuilder("编辑账号:"); |
| | | StringBuilder accountBuilder = new StringBuilder(); |
| | | if (!whitelist.getAccount().equals(dto.getAccount())) { |
| | | accountBuilder.append("白名单账号" + "\"" + whitelist.getAccount() + "\"" + "为" + "\"" + dto.getAccount() + "\""); |
| | | } |
| | | if (StringUtils.hasLength(whitelist.getNickName()) || StringUtils.hasLength(dto.getNickName())) { |
| | | if (!StringUtils.hasLength(whitelist.getNickName())) { |
| | | if (StringUtils.hasLength(whitelist.getNickName())) { |
| | | if (!whitelist.getNickName().equals(dto.getNickName())) { |
| | | accountBuilder.append("用户名称" + "\"" + whitelist.getNickName() + "\"" + "为" + "\"" + dto.getNickName() + "\""); |
| | | } |
| | |
| | | if (whitelist.getIsPriorityDispatch() != dto.getIsPriorityDispatch()) { |
| | | accountBuilder.append("优先派单" + "\"" + (whitelist.getIsPriorityDispatch() ? "是" : "否") + "\"" + "为" + "\"" + (dto.getIsPriorityDispatch() ? "是" : "否") + "\""); |
| | | } |
| | | if ( !dto.getMaxOrderNum().equals(whitelist.getMaxOrderNum()) ) { |
| | | accountBuilder.append("最大下单数量" + "\"" + whitelist.getMaxOrderNum() + "\"" + "为" + "\"" + dto.getMaxOrderNum() + "\""); |
| | | whitelist.setMaxOrderNum(dto.getMaxOrderNum()); |
| | | } |
| | | if (!whitelist.getExpireTime().isEqual(dto.getExpireTime())) { |
| | | accountBuilder.append("有限期" + "\"" + whitelist.getExpireTime() + "\"" + "为" + "\"" + dto.getExpireTime() + "\""); |
| | | whitelist.setExpireTime(dto.getExpireTime()); |
| | | } |
| | | |
| | | XpWhitelistOperlog xpWhitelistOperlog = new XpWhitelistOperlog(); |
| | | xpWhitelistOperlog.setOperationName(sysUser.getNickName()); |
| | | xpWhitelistOperlog.setOperationAccount(sysUser.getPhoneNumber()); |