修改全局变量 增加全局异常变量

master
bynt 3 years ago
parent c82c902cfc
commit 14255d650e

@ -42,11 +42,6 @@
<artifactId>alipay-easysdk</artifactId>
</dependency>
<!-- fixme 这里JDBC连接 考虑下是否要进行更换(建议修改) -->
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>sharding-jdbc-spring-boot-starter</artifactId>
</dependency>
</dependencies>
</project>

@ -1,19 +1,28 @@
spring:
shardingsphere:
datasource:
names: taomi
taomi:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/taomi?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai
username: root
password: '012099'
# ds-1:
# type: com.alibaba.druid.pool.DruidDataSource
# driver-class-name: com.mysql.cj.jdbc.Driver
# url: jdbc:mysql://${zlt.datasource.ip}:3306/demo_ds_1?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&zeroDateTimeBehavior=convertToNull
# username: ${zlt.datasource.username}
# password: ${zlt.datasource.password}
datasource:
driverClassName: com.mysql.cj.jdbc.Driver
# 使用 alibaba druid 连接池、监控
type: com.alibaba.druid.pool.DruidDataSource
druid:
url: jdbc:mysql://127.0.0.1:3306/taomi?useUnicode=true&CharSet=utf8mb4&characterEncoding=utf8&characterSetResults=utf8&autoReconnect=true&autoReconnectForPools=true&rewriteBatchedStatements=true&allowMultiQueries=true&useSSL=false&serverTimezone=Asia/Shanghai
username: root
password: '012099'
initial-size: 2
min-idle: 5
max-active: 10
max-wait: 5000
validation-query: SELECT 1
test-on-borrow: false
test-while-idle: true
time-between-eviction-runs-millis: 18800
web-stat-filter:
enabled: true
exclusions: js,gif,jpg,png,css,ico,/druid/*
stat-view-servlet:
enabled: true
login-username: root
login-password: druid2021
alipay:

@ -0,0 +1,27 @@
package com.hchbox.controller;
import com.hchbox.model.param.CommonResult;
import com.hchbox.service.TaoBaoShopService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author Enzo
* @date : 2021/7/26
*/
@Slf4j
@RestController
@RequestMapping("/source")
@RequiredArgsConstructor
public class TestController {
private final TaoBaoShopService taoBaoShopService;
@GetMapping("/info")
public CommonResult<String> saveTemplate() {
return new CommonResult<String>().success(taoBaoShopService.getShopSellerGetResponse("sendTemplate"));
}
}

@ -2,7 +2,7 @@ package com.hchbox.config;
import cn.hutool.core.bean.BeanUtil;
import com.hchbox.annotaion.SellerUser;
import com.hchbox.constant.AuthConstants;
import com.hchbox.constant.DefaultConstants;
import com.hchbox.constant.DefaultNumberConstants;
import com.hchbox.dto.SellerAccountDTO;
import com.hchbox.entity.master.SellerAccount;
import lombok.NonNull;
@ -28,7 +28,7 @@ public class SellerUserHandlerMethodArgumentResolver implements HandlerMethodArg
public Object resolveArgument(@NonNull MethodParameter methodParameter, ModelAndViewContainer container,
NativeWebRequest request, WebDataBinderFactory factory) {
// session解析账号
SellerAccount sellerAccount = (SellerAccount) request.getAttribute(AuthConstants.SELLER_ACCOUNT, DefaultConstants.ZERO_NUMBER);
SellerAccount sellerAccount = (SellerAccount) request.getAttribute(AuthConstants.SELLER_ACCOUNT, DefaultNumberConstants.ZERO_NUMBER);
if (sellerAccount != null){
SellerAccountDTO sellerAccountDTO = new SellerAccountDTO();
BeanUtil.copyProperties(sellerAccount,sellerAccountDTO);

@ -1,6 +1,8 @@
package com.hchbox.api;
import com.hchbox.enums.ResponseCode;
import com.hchbox.config.MiProperties;
import com.hchbox.exception.CheckedAccountException;
import com.taobao.api.*;
import lombok.extern.slf4j.Slf4j;
@ -57,9 +59,13 @@ public class TaoBaoApiClient extends DefaultTaobaoClient {
new ClusterTaobaoClient
(miProperties.getServerUrl(), miProperties.getAppKey(),
miProperties.getAppSecret());
return client.execute(baseTaoBaoRequest, sessionKey);
T execute = client.execute(baseTaoBaoRequest, sessionKey);
if (!execute.isSuccess() && execute.getErrorCode().equals(ResponseCode.USER_INFORMATION_EXPIRED.getCode())) {
log.error("============= check account is abnormal ================");
throw new CheckedAccountException(ResponseCode.USER_INFORMATION_EXPIRED.getDesc());
}
} catch (ApiException e) {
log.info("create default error time {}", LocalTime.now());
log.error("create default error time {}", LocalTime.now());
}
return null;
}

@ -1,6 +1,6 @@
package com.hchbox.config;
import com.hchbox.constant.DefaultConstants;
import com.hchbox.constant.DefaultNumberConstants;
import org.apache.tomcat.util.threads.ThreadPoolExecutor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
@ -39,7 +39,7 @@ public class ThreadConfig {
orderCorePoolSize,
orderMaxPoolSize,
// 设置线程超时15分钟
DefaultConstants.FIFTEEN_NUMBER,
DefaultNumberConstants.FIFTEEN_NUMBER,
TimeUnit.MINUTES,
new LinkedBlockingDeque<>(orderQueueCapacity),
Executors.defaultThreadFactory(),

@ -1,7 +1,7 @@
package com.hchbox.hander;
import cn.hutool.core.date.DateUtil;
import com.hchbox.constant.DefaultConstants;
import com.hchbox.constant.DefaultNumberConstants;
import com.hchbox.hander.message.TaoBaoTradeMessage;
import com.hchbox.service.TopTradeService;
import lombok.RequiredArgsConstructor;
@ -27,7 +27,7 @@ public class TradeInterceptHandler implements TaoBaoHandler<TaoBaoTradeMessage>
return true;
}
// 只对开启了中差评拦截的卖家转发 产生消息时间已经超过30秒也不转发丢弃
if (message.getPubTime() != null && (message.getPubTime().after(DateUtil.offsetSecond(DateUtil.date(), DefaultConstants.THIRTY)))) {
if (message.getPubTime() != null && (message.getPubTime().after(DateUtil.offsetSecond(DateUtil.date(), DefaultNumberConstants.THIRTY)))) {
log.info("create trade tmc delay 30 seconds tid=" + message.getTid());
return true;
}

@ -4,7 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.emoji.EmojiUtil;
import com.hchbox.model.param.CommonResult;
import com.hchbox.constant.DefaultConstants;
import com.hchbox.constant.DefaultNumberConstants;
import com.hchbox.dto.SellerAccountDTO;
import com.hchbox.entity.master.Blacklist;
import com.hchbox.enums.ResponseCode;
@ -36,7 +36,7 @@ public class BlacklistServiceImpl implements BlacklistService {
public CommonResult<Page<Blacklist>> queryAll(SellerAccountDTO sellerAccountDTO, Pageable pageable) {
Page<Blacklist> blacklists = blacklistRepository.queryBlacklist(pageable,
sellerAccountDTO.getParentId() != DefaultConstants.ZERO_NUMBER
sellerAccountDTO.getParentId() != DefaultNumberConstants.ZERO_NUMBER
? sellerAccountDTO.getParentId() : sellerAccountDTO.getId());
blacklists.getContent().forEach(blacklist -> blacklist.setBuyerNick(EmojiUtil.toAlias(blacklist.getBuyerNick())));
// sql 拼接方式
@ -48,7 +48,7 @@ public class BlacklistServiceImpl implements BlacklistService {
Predicate likeNickName = criteriaBuilder.equal(root.get("userId").as(Long.class), sellerAccountDTO.getId());
predicates.add(likeNickName);
}
query.where(predicates.toArray(new Predicate[DefaultConstants.ZERO_NUMBER]));
query.where(predicates.toArray(new Predicate[DefaultNumberConstants.ZERO_NUMBER]));
return null;
}, pageable);*/
}
@ -63,14 +63,14 @@ public class BlacklistServiceImpl implements BlacklistService {
// 设置账号
if (sellerAccountDTO.getNick() != null && sellerAccountDTO.getNick().contains(StrUtil.COLON)){
String[] split = sellerAccountDTO.getNick().split(StrUtil.COLON);
blacklist.setSellerNick(split[DefaultConstants.ZERO_NUMBER]);
blacklist.setSellerNick(split[DefaultNumberConstants.ZERO_NUMBER]);
}
blacklist.setUserId(sellerAccountDTO.getParentId() !=
DefaultConstants.ZERO_NUMBER ? sellerAccountDTO.getParentId() : sellerAccountDTO.getId());
DefaultNumberConstants.ZERO_NUMBER ? sellerAccountDTO.getParentId() : sellerAccountDTO.getId());
blacklist.setBuyerNick(EmojiUtil.toUnicode(blacklist.getBuyerNick()));
blacklist.setStatus(DefaultConstants.ZERO_NUMBER);
blacklist.setStatus(DefaultNumberConstants.ZERO_NUMBER);
});
return blacklistRepository.saveAll(list).size() > DefaultConstants.ZERO_NUMBER ? CommonResult.successfulOperation() :
return blacklistRepository.saveAll(list).size() > DefaultNumberConstants.ZERO_NUMBER ? CommonResult.successfulOperation() :
new CommonResult<String>().failed(ResponseCode.PAYMENT_FAILED.getDesc());
}

@ -2,7 +2,7 @@ package com.hchbox.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.hchbox.constant.DefaultConstants;
import com.hchbox.constant.DefaultNumberConstants;
import com.hchbox.dto.SellerAccountDTO;
import com.hchbox.entity.master.HistoryTrade;
import com.hchbox.enums.HistoryFiledEnum;
@ -46,7 +46,7 @@ public class HistoryTradeServiceImpl implements HistoryTradeService {
try {
String tid = getString(map, HistoryFiledEnum.TID);
int countByTid = historyTradeRepository.countByTid(Long.valueOf(tid));
if (countByTid != DefaultConstants.ZERO_NUMBER) {
if (countByTid != DefaultNumberConstants.ZERO_NUMBER) {
continue;
}
historyTrade.setImportTime(DateUtil.date());
@ -69,15 +69,15 @@ public class HistoryTradeServiceImpl implements HistoryTradeService {
if (address != null) {
historyTrade.setReceiverAddress(address);
int index = address.indexOf(StrUtil.SPACE);
if (index >= DefaultConstants.ZERO_NUMBER) {
if (index >= DefaultNumberConstants.ZERO_NUMBER) {
historyTrade.setReceiverState
(address.substring(DefaultConstants.ZERO_NUMBER, index).trim());
(address.substring(DefaultNumberConstants.ZERO_NUMBER, index).trim());
}
String cityStr = address.substring(index + DefaultConstants.ONE_NUMBER);
String cityStr = address.substring(index + DefaultNumberConstants.ONE_NUMBER);
int cityIndex = cityStr.indexOf(StrUtil.SPACE);
if (cityIndex >= DefaultConstants.ZERO_NUMBER) {
if (cityIndex >= DefaultNumberConstants.ZERO_NUMBER) {
historyTrade.setReceiverCity
(cityStr.substring(DefaultConstants.ZERO_NUMBER, cityIndex).trim());
(cityStr.substring(DefaultNumberConstants.ZERO_NUMBER, cityIndex).trim());
}
}

@ -1,6 +1,6 @@
package com.hchbox.service.impl;
import com.hchbox.constant.DefaultConstants;
import com.hchbox.constant.DefaultNumberConstants;
import com.hchbox.constant.TradeConstants;
import com.hchbox.entity.master.HistoryTrade;
import com.hchbox.entity.master.Member;
@ -53,7 +53,7 @@ public class MemberServiceImpl implements MemberService {
member.setReceiverMobile(trade.getReceiverMobile());
member.setBuyerName(trade.getReceiverName());
member.setAlipayNo(trade.getAlipayNo());
boolean checkEmail = trade.getAlipayNo().indexOf(DefaultConstants.ATTR_DELIMITER) > 0;
boolean checkEmail = trade.getAlipayNo().indexOf(DefaultNumberConstants.ATTR_DELIMITER) > 0;
member.setBuyerEmail(checkEmail ? trade.getAlipayNo() : null);
member.setBuyerMobile(!checkEmail ? trade.getAlipayNo() : null);
}
@ -110,7 +110,7 @@ public class MemberServiceImpl implements MemberService {
member.setReceiverMobile(topTrade.getReceiverMobile());
member.setBuyerName(topTrade.getReceiverName());
member.setAlipayNo(topTrade.getAlipayNo());
boolean checkEmail = topTrade.getAlipayNo().indexOf(DefaultConstants.ATTR_DELIMITER) > 0;
boolean checkEmail = topTrade.getAlipayNo().indexOf(DefaultNumberConstants.ATTR_DELIMITER) > 0;
member.setBuyerEmail(checkEmail ? topTrade.getAlipayNo() : null);
member.setBuyerMobile(!checkEmail ? topTrade.getAlipayNo() : null);
}
@ -141,7 +141,7 @@ public class MemberServiceImpl implements MemberService {
member.setAlipayNo(trade.getAlipayNo());
member.setAvgPrice(payment);
if (trade.getAlipayNo() != null) {
boolean checkEmail = trade.getAlipayNo().indexOf(DefaultConstants.ATTR_DELIMITER) > 0;
boolean checkEmail = trade.getAlipayNo().indexOf(DefaultNumberConstants.ATTR_DELIMITER) > 0;
member.setBuyerEmail(checkEmail ? trade.getAlipayNo() : null);
member.setBuyerMobile(!checkEmail ? trade.getAlipayNo() : null);
}
@ -183,7 +183,7 @@ public class MemberServiceImpl implements MemberService {
member.setLastTradeTime(trade.getCreated());
member.setMobileUsed(trade.getReceiverMobile());
member.setReceiverMobile(trade.getReceiverMobile());
member.setTradeAllCount(DefaultConstants.ONE_NUMBER);
member.setTradeAllCount(DefaultNumberConstants.ONE_NUMBER);
member.setLevelStatus(MemberLevelEnum.ONE.getLevel());
member.setStatus(MemberStatusEnum.NORMAL.getStatus());
member.setLastTradeAmount(Double.valueOf(trade.getPayment()));

@ -11,7 +11,7 @@ import cn.hutool.json.JSONUtil;
import com.hchbox.model.param.CommonResult;
import com.hchbox.config.MiProperties;
import com.hchbox.constant.AuthConstants;
import com.hchbox.constant.DefaultConstants;
import com.hchbox.constant.DefaultNumberConstants;
import com.hchbox.constant.UrlConstants;
import com.hchbox.dto.AuthCodeDTO;
import com.hchbox.dto.AuthTokenDTO;
@ -181,7 +181,7 @@ public class SellerAccountServiceImpl implements SellerAccountService {
// 子账号登录
if (StrUtil.contains(nickname, StrUtil.COLON)) {
String[] split = nickname.split(StrUtil.COLON);
String masterUserName = split[DefaultConstants.ZERO_NUMBER];
String masterUserName = split[DefaultNumberConstants.ZERO_NUMBER];
// 获取店铺名称
Shop shop = taoBaoShopService.getShopSellerGetResponse(loginVo.getAccessToken());
if (shop == null) {
@ -193,7 +193,7 @@ public class SellerAccountServiceImpl implements SellerAccountService {
sellerAccount = new SellerAccount();
sellerAccount.setShopTitle(shop.getTitle());
sellerAccount.setAppKey(miProperties.getAppKey());
sellerAccount.setParentId(NumberUtil.parseLong(String.valueOf(DefaultConstants.ZERO_NUMBER)));
sellerAccount.setParentId(NumberUtil.parseLong(String.valueOf(DefaultNumberConstants.ZERO_NUMBER)));
sellerAccount.setNickname(EmojiUtil.toAlias(masterUserName));
sellerAccount = sellerAccountRepository.save(sellerAccount);
}
@ -232,7 +232,7 @@ public class SellerAccountServiceImpl implements SellerAccountService {
account.setAppKey(miProperties.getAppKey());
account.setSessionKey(loginVo.getAccessToken());
account.setNickname(EmojiUtil.toAlias(loginVo.getUserNick()));
account.setParentId(NumberUtil.parseLong(String.valueOf(DefaultConstants.ZERO_NUMBER)));
account.setParentId(NumberUtil.parseLong(String.valueOf(DefaultNumberConstants.ZERO_NUMBER)));
SellerAccount saveAccount = sellerAccountRepository.save(account);
return getMapCommonResult(request, saveAccount);
}

@ -1,6 +1,6 @@
package com.hchbox.service.impl;
import com.hchbox.constant.DefaultConstants;
import com.hchbox.constant.DefaultNumberConstants;
import com.hchbox.dto.SellerAccountDTO;
import com.hchbox.entity.master.TaskSendMessage;
import com.hchbox.repository.master.TaskSendMessageRepository;
@ -30,8 +30,8 @@ public class TaskSendMessageServiceImpl implements TaskSendMessageService {
sendMessage.setCreateTime(new Date());
sendMessage.setIsSuccess(Boolean.FALSE);
sendMessage.setSellerNick(sellerAccount.getNick());
sendMessage.setSendType(DefaultConstants.ONE_NUMBER);
sendMessage.setStatus(DefaultConstants.ZERO_NUMBER);
sendMessage.setSendType(DefaultNumberConstants.ONE_NUMBER);
sendMessage.setStatus(DefaultNumberConstants.ZERO_NUMBER);
sendMessage.setTaskName(submitSendMessageVo.getTaskName());
sendMessage.setSendMessage(submitSendMessageVo.getTaskInfo());
return taskSendMessageRepository.save(sendMessage).getId() != null;

@ -6,7 +6,7 @@ import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.hchbox.config.MiProperties;
import com.hchbox.constant.DefaultConstants;
import com.hchbox.constant.DefaultNumberConstants;
import com.hchbox.constant.RemindTemplates;
import com.hchbox.util.CommConverter;
import com.hchbox.dto.AutoTaskMessageInfoDTO;
@ -155,7 +155,7 @@ public class TopTradeServiceImpl implements TopTradeService {
cacheManagerUtil.putCache(appSettingTypeEnum.getFieldMeaning(), message.getTid(), message.getTid());
// 1. 查询买家是否开启查询
AppSetting setting = appSettingService.getSetting(sellerNick, appSettingTypeEnum.getType());
if (setting == null || setting.getStatus() == DefaultConstants.ONE_NUMBER) {
if (setting == null || setting.getStatus() == DefaultNumberConstants.ONE_NUMBER) {
log.info(" ==================== the appSetting are not turned on sellerNick as {} ==================== ", message.getSellerNick());
return Boolean.FALSE;
}
@ -173,8 +173,8 @@ public class TopTradeServiceImpl implements TopTradeService {
}
// 黑名单查询
Integer countBlackList = blacklistService.queryBlacklistBySellerNickAndBuyerNick(sellerNick, message.getBuyerNick(),DefaultConstants.ZERO_NUMBER);
if (countBlackList != null && countBlackList > DefaultConstants.ZERO_NUMBER){
Integer countBlackList = blacklistService.queryBlacklistBySellerNickAndBuyerNick(sellerNick, message.getBuyerNick(),DefaultNumberConstants.ZERO_NUMBER);
if (countBlackList != null && countBlackList > DefaultNumberConstants.ZERO_NUMBER){
return Boolean.FALSE;
}
//2 满足发送条件 获取短信模板
@ -230,9 +230,9 @@ public class TopTradeServiceImpl implements TopTradeService {
AutoTaskMessageInfo messageInfo = new AutoTaskMessageInfo();
messageInfo.setTaskId(taskId);
//默认第一个账号去发送,只发送一条消息
messageInfo.setMessageNick(sendNickList.get(DefaultConstants.ZERO_NUMBER));
messageInfo.setStatus(DefaultConstants.ZERO_NUMBER);
messageInfo.setType(DefaultConstants.ZERO_NUMBER);
messageInfo.setMessageNick(sendNickList.get(DefaultNumberConstants.ZERO_NUMBER));
messageInfo.setStatus(DefaultNumberConstants.ZERO_NUMBER);
messageInfo.setType(DefaultNumberConstants.ZERO_NUMBER);
messageInfo.setSellerNick(trade.getSellerNick());
messageInfo.setStartDt(DateUtil.date());
messageInfo.setTid(trade.getTid());
@ -251,7 +251,7 @@ public class TopTradeServiceImpl implements TopTradeService {
}
// 1 发送金额 限定范围
double payment = Double.parseDouble(trade.getPayment());
if (payment > DefaultConstants.ZERO_NUMBER) {
if (payment > DefaultNumberConstants.ZERO_NUMBER) {
// 金额区间为空或者设置为0表示无限制
if (setting.getPaymentFloor() != null && setting.getPaymentFloor() > 0
&& payment < setting.getPaymentFloor()) {
@ -320,8 +320,8 @@ public class TopTradeServiceImpl implements TopTradeService {
message.setIsFinish(Boolean.FALSE);
message.setSendType(setting.getType());
message.setSellerNick(setting.getSellerNick());
message.setStatus(DefaultConstants.ZERO_NUMBER);
message.setSendType(DefaultConstants.ZERO_NUMBER);
message.setStatus(DefaultNumberConstants.ZERO_NUMBER);
message.setSendType(DefaultNumberConstants.ZERO_NUMBER);
message.setTaskName(AppSettingTypeEnum.valueOf(type));
return autoTaskMessageRepository.save(message).getId();
}

@ -7,7 +7,7 @@ import cn.hutool.core.util.StrUtil;
import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;
import com.hchbox.model.param.CommonResult;
import com.hchbox.constant.DefaultConstants;
import com.hchbox.constant.DefaultNumberConstants;
import com.hchbox.dto.SellerAccountDTO;
import com.hchbox.entity.master.UploadRecord;
import com.hchbox.enums.ResponseCode;
@ -58,7 +58,7 @@ public class UploadRecordServiceImpl implements UploadRecordService {
String originalFilename = file.getOriginalFilename();
// 判断文件名是否存在
int byUserIdAndFileName = uploadRecordRepository.countByUserIdAndFileName(accountId, originalFilename);
if (byUserIdAndFileName > DefaultConstants.ZERO_NUMBER) {
if (byUserIdAndFileName > DefaultNumberConstants.ZERO_NUMBER) {
return new CommonResult<String>().failed(ResponseCode.FILE_NAME_ALREADY_EXISTS.getDesc());
}
String extName = FileUtil.extName(originalFilename);

@ -5,8 +5,8 @@ import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.google.common.collect.Lists;
import com.hchbox.config.MiProperties;
import com.hchbox.constant.DefaultConstants;
import com.hchbox.constant.TaoBaoDataMethod;
import com.hchbox.constant.DefaultNumberConstants;
import com.hchbox.constant.TaoBaoDataMethodConstants;
import com.hchbox.entity.master.SellerAccount;
import com.hchbox.entity.master.TopTrade;
import com.hchbox.entity.slaver.JdpTrade;
@ -48,7 +48,7 @@ import java.util.stream.Collectors;
@RequiredArgsConstructor
public class SyncTask {
private AtomicInteger count = new AtomicInteger(DefaultConstants.ZERO_NUMBER);
private AtomicInteger count = new AtomicInteger(DefaultNumberConstants.ZERO_NUMBER);
private final SellerAccountService sellerAccountService;
@ -72,13 +72,13 @@ public class SyncTask {
long startTime = System.currentTimeMillis();
log.info("====== [ the pull order start the time as {} ] ======", startTime);
DateTime date = DateUtil.date();
if (count.get() > DefaultConstants.ZERO_NUMBER) {
if (count.get() > DefaultNumberConstants.ZERO_NUMBER) {
// 超时判断时间
if (lastUpdateTime != null && DateUtil.offsetMinute(date, -DefaultConstants.FIFTEEN_NUMBER).before(lastUpdateTime)) {
if (lastUpdateTime != null && DateUtil.offsetMinute(date, -DefaultNumberConstants.FIFTEEN_NUMBER).before(lastUpdateTime)) {
return;
}
// 初始化参数
count.addAndGet(DefaultConstants.ZERO_NUMBER);
count.addAndGet(DefaultNumberConstants.ZERO_NUMBER);
}
syncOrder(date);
long endTime = System.currentTimeMillis();
@ -94,7 +94,7 @@ public class SyncTask {
Date startTime;
Date endTime = new Date();
// 第一次任务往前10分钟
startTime = lastUpdateTime == null ? DateUtil.offsetMinute(date, -DefaultConstants.TEN_NUMBER) : lastUpdateTime;
startTime = lastUpdateTime == null ? DateUtil.offsetMinute(date, -DefaultNumberConstants.TEN_NUMBER) : lastUpdateTime;
lastUpdateTime = endTime;
List<JdpTrade> jdpOrderList = jdpTradeService.findJdpOrderByTime(startTime, endTime);
if (!CollectionUtils.isEmpty(jdpOrderList)) {
@ -111,10 +111,10 @@ public class SyncTask {
Map<String, List<Trade>> tradeListMap = list.stream().
collect(Collectors.groupingBy(Trade::getSellerNick));
List<String> fieldName = Lists.newArrayList
(TaoBaoDataMethod.BUYER_NICK,
TaoBaoDataMethod.RECEIVER_NAME,
TaoBaoDataMethod.RECEIVER_ADDRESS,
TaoBaoDataMethod.ENCRYPT_ALI_PAY_ID);
(TaoBaoDataMethodConstants.BUYER_NICK,
TaoBaoDataMethodConstants.RECEIVER_NAME,
TaoBaoDataMethodConstants.RECEIVER_ADDRESS,
TaoBaoDataMethodConstants.ENCRYPT_ALI_PAY_ID);
TopTrade syncTask;
for (Map.Entry<String, List<Trade>> stringListEntry : tradeListMap.entrySet()) {
String sellerNick = stringListEntry.getKey();
@ -125,8 +125,8 @@ public class SyncTask {
TaoBaoEncryption.decrypt(miProperties, sellerAccount.getSessionKey(), trades, fieldName);
// 手机号码单独解密
TaoBaoEncryption.decrypt(miProperties, sellerAccount.getSessionKey(), trades, TaoBaoDataMethod.PHONE,
Trade.class.getDeclaredField(TaoBaoDataMethod.RECEIVER_MOBILE));
TaoBaoEncryption.decrypt(miProperties, sellerAccount.getSessionKey(), trades, TaoBaoDataMethodConstants.PHONE,
Trade.class.getDeclaredField(TaoBaoDataMethodConstants.RECEIVER_MOBILE));
log.info(" ========== the analyze the order quantity size as {} ========== ", trades.size());
for (Trade trade : trades) {
syncTask = new TopTrade();

@ -4,8 +4,8 @@ package com.hchbox.uitl;
import com.hchbox.api.TaoBaoApiClient;
import com.hchbox.config.MiProperties;
import com.hchbox.constant.DefaultConstants;
import com.hchbox.constant.TaoBaoDataMethod;
import com.hchbox.constant.DefaultNumberConstants;
import com.hchbox.constant.TaoBaoDataMethodConstants;
import com.taobao.api.*;
import com.taobao.api.security.SecurityClient;
import org.apache.commons.lang3.StringUtils;
@ -37,7 +37,7 @@ public class TaoBaoEncryption {
* @throws IllegalAccessException
*/
public static <T> List<T> decrypt(MiProperties miProperties, String sessionKey, List<T> list, Field field) throws IllegalArgumentException, SecretException, IllegalAccessException {
return decrypt(miProperties, sessionKey, list, TaoBaoDataMethod.SIMPLE, field);
return decrypt(miProperties, sessionKey, list, TaoBaoDataMethodConstants.SIMPLE, field);
}
@ -61,7 +61,7 @@ public class TaoBaoEncryption {
NoSuchFieldException,
IllegalAccessException,
SecretException {
return decrypt(miProperties, sessionKey, list, TaoBaoDataMethod.SIMPLE, fieldNames, null);
return decrypt(miProperties, sessionKey, list, TaoBaoDataMethodConstants.SIMPLE, fieldNames, null);
}
@ -173,7 +173,7 @@ public class TaoBaoEncryption {
if (matchList == null || matchList.isEmpty()) {
return null;
}
Map<String, List<T>> rs = new HashMap<>(DefaultConstants.TWO_NUMBER);
Map<String, List<T>> rs = new HashMap<>(DefaultNumberConstants.TWO_NUMBER);
for (T match : matchList) {
String key = (String) field.get(match);
List<T> list = rs.get(key);

@ -0,0 +1,32 @@
package com.hchbox.exception;
import lombok.NoArgsConstructor;
/**
* @author Enzo
* @date 2021-7-26
*/
@NoArgsConstructor
public class CheckedAccountException extends RuntimeException {
private static final long serialVersionUID = 1751129723237168054L;
public CheckedAccountException(String message) {
super(message);
}
public CheckedAccountException(Throwable cause) {
super(cause);
}
public CheckedAccountException(String message, Throwable cause) {
super(message, cause);
}
public CheckedAccountException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
}

@ -0,0 +1,76 @@
/*
* Copyright (c) 2020 pig4cloud Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.hchbox.handle;
import com.hchbox.exception.CheckedAccountException;
import com.hchbox.model.param.CommonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;
/**
* <p>
* sentinel oauth server https://gitee.com/log4j/pig/issues/I1M2TJ
* </p>
*
* @author lengleng
* @date 2020-06-29
*/
@Slf4j
@RestControllerAdvice
public class GlobalBizExceptionHandler {
/**
*
* @param e e
* @return
*/
@ExceptionHandler(CheckedAccountException.class)
@ResponseStatus(HttpStatus.FORBIDDEN)
public CommonResult<String> handleGlobalException(CheckedAccountException e) {
log.error("全局异常信息 ex={}", e.getMessage(), e);
// 业务异常交由 sentinel 记录 Tracer.trace(e);
return new CommonResult<String>().failed(e.getLocalizedMessage());
}
/**
* {@link Assert}
* @see Assert#hasLength(String, String)
* @see Assert#hasText(String, String)
* @see Assert#isTrue(boolean, String)
* @see Assert#isNull(Object, String)
* @see Assert#notNull(Object, String)
* @param exception
* @return API
*/
@ExceptionHandler(IllegalArgumentException.class)
@ResponseStatus(HttpStatus.OK)
public CommonResult<String> handleIllegalArgumentException(IllegalArgumentException exception) {
log.error("非法参数,ex = {}", exception.getMessage(), exception);
return new CommonResult<String>().failed(exception.getMessage());
}
}

@ -12,7 +12,7 @@ import com.auth0.jwt.exceptions.JWTCreationException;
import com.auth0.jwt.exceptions.JWTVerificationException;
import com.auth0.jwt.interfaces.Claim;
import com.auth0.jwt.interfaces.DecodedJWT;
import com.hchbox.constant.DefaultConstants;
import com.hchbox.constant.DefaultNumberConstants;
import java.util.Date;
import java.util.HashMap;
@ -40,7 +40,7 @@ public class JwtHelper {
public String createToken(String accessToke) {
try {
Algorithm algorithm = Algorithm.HMAC256(SECRET);
Map<String, Object> map = new HashMap<>(DefaultConstants.TWO_NUMBER);
Map<String, Object> map = new HashMap<>(DefaultNumberConstants.TWO_NUMBER);
Date nowDate = new Date();
map.put("alg", "HS256");
map.put("typ", "JWT");

@ -27,6 +27,8 @@ public class AuthProvider {
DEFAULT_SKIP_URL.add("/error/**");
DEFAULT_SKIP_URL.add("/assets/**");
DEFAULT_SKIP_URL.add("/aliPay/**");
DEFAULT_SKIP_URL.add("/source/**");
DEFAULT_SKIP_URL.add("/otherAccount/**");
}
private AuthProvider() {

@ -27,11 +27,7 @@
<scope>compile</scope>
</dependency>
<!-- fixme 这里检查pojo 中是否用到这个依赖,注意删除-->
<!-- <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>-->
</dependencies>

@ -1,6 +1,5 @@
package com.hchbox.dto;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
@ -14,16 +13,16 @@ public class AuthTokenDTO {
@SerializedName("grant_type")
private String grantType;
@JsonProperty("client_id")
@SerializedName("client_id")
private String clientId;
@JsonProperty("client_secret")
@SerializedName("client_secret")
private String clientSecret;
@JsonProperty("redirect_uri")
@SerializedName("redirect_uri")
private String redirectUri;
@JsonProperty("code")
@SerializedName("code")
private String code;
private String view;

@ -1,6 +1,5 @@
package com.hchbox.dto;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
/**

@ -10,40 +10,42 @@ import lombok.Getter;
public enum ResponseCode {
/**成功*/
SUCCESS(1,"成功"),
SUCCESS("1","成功"),
PARAMETER_ERROR(1012,"参数错误"),
PARAMETER_ERROR("1012","参数错误"),
PAYMENT_FAILED(1002,"支付宝,下单失败"),
PAYMENT_FAILED("1002","支付宝,下单失败"),
CALLBACK_FAILED(1003,"支付宝,回调失败"),
CALLBACK_FAILED("1003","支付宝,回调失败"),
LOGIN_FAILED(1001,"登录失败,请稍后重试"),
LOGIN_FAILED("1001","登录失败,请稍后重试"),
SAVE_INFORMATION_FAILED(1004, "保存信息失败"),
SAVE_INFORMATION_FAILED("1004", "保存信息失败"),
TEMPLATE_NAME_CANNOT_BE_EMPTY(1011,"模板不能为空"),
USER_INFORMATION_EXPIRED("29","用户登录已经失效"),
ACCOUNT_HAS_EXPIRED(1005, "当前账号旺旺群发已过期"),
TEMPLATE_NAME_CANNOT_BE_EMPTY("1011","模板不能为空"),
LEVEL_VERIFICATION_FAILED(1006,"不同等级套餐无法直接续费"),
ACCOUNT_HAS_EXPIRED("1005", "当前账号旺旺群发已过期"),
UPLOAD_INFORMATION_CANNOT_BE_EMPTY(1009,"上传信息不能为空"),
LEVEL_VERIFICATION_FAILED("1006","不同等级套餐无法直接续费"),
ACCOUNT_VERIFICATION_FAILED(1007,"账号验证失败,请核实后提交"),
UPLOAD_INFORMATION_CANNOT_BE_EMPTY("1009","上传信息不能为空"),
FILE_NAME_ALREADY_EXISTS(1008,"文件名已存在,请核实后重新上传"),
ACCOUNT_VERIFICATION_FAILED("1007","账号验证失败,请核实后提交"),
ACCOUNT_DOES_NOT_YET_HAVE_STORE(1011,"该账号尚未拥有店铺,请申请后重试"),
FILE_NAME_ALREADY_EXISTS("1008","文件名已存在,请核实后重新上传"),
EXCEEDED_QUANTITY(1010, "提交任务数量超过当日限额,您可以订购提额包或升级套餐")
ACCOUNT_DOES_NOT_YET_HAVE_STORE("1011","该账号尚未拥有店铺,请申请后重试"),
EXCEEDED_QUANTITY("1010", "提交任务数量超过当日限额,您可以订购提额包或升级套餐")
;
private final int code;
private final String code;
private final String desc;
ResponseCode(int code, String desc){
ResponseCode(String code, String desc){
this.code = code;
this.desc = desc;
}

Loading…
Cancel
Save