|
|
@@ -66,6 +66,8 @@ public class CommonLogic {
|
|
|
OrderInfoService orderInfoService;
|
|
|
@Resource
|
|
|
AdminPlatformService adminPlatformService;
|
|
|
+ @Resource
|
|
|
+ StorageService storageService;
|
|
|
@Value("${spring.profiles.active}")
|
|
|
private String profiles;
|
|
|
@Value("${inf.url}")
|
|
|
@@ -88,66 +90,72 @@ public class CommonLogic {
|
|
|
*/
|
|
|
public CurrentCompanyWechat getCurrentCompanyWechat(HttpServletRequest request) {
|
|
|
|
|
|
- String userId = CommonUtils.getUserId(request);
|
|
|
+ final String userId = CommonUtils.getUserId(request);
|
|
|
+ final String storageId = CommonUtils.getStorageId(request);
|
|
|
+ final String source = CommonUtils.getSource(request);
|
|
|
String token = CommonUtils.getToken(request);
|
|
|
- String storageId = CommonUtils.getStorageId(request);
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(source)) {
|
|
|
+ throw new RemoteServiceException("非法请求, 来源不明");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(storageId)) {
|
|
|
+ throw new RemoteServiceException("缺少仓库信息");
|
|
|
+ }
|
|
|
|
|
|
if (StringUtils.isBlank(token)) {
|
|
|
token = request.getParameter("x-token");
|
|
|
}
|
|
|
|
|
|
+ final AdminPlatform adminPlatform = adminPlatformService.getById(1);
|
|
|
+
|
|
|
AdminCompanyWechat adminCompanyWechat;
|
|
|
User user = null;
|
|
|
|
|
|
- // TODO 处理逻辑修改
|
|
|
- adminCompanyWechat = adminCompanyWechatService.lambdaQuery()
|
|
|
- .last("limit 1")
|
|
|
- .one();
|
|
|
|
|
|
- final AdminPlatform adminPlatform = adminPlatformService.getById(1);
|
|
|
- if (StringUtils.isNotBlank(token)) {
|
|
|
+ final Storage storage = storageService.getById(storageId);
|
|
|
+ adminCompanyWechat = adminCompanyWechatService.getById(storage.getCompanyWechatId());
|
|
|
+ CurrentCompanyWechat currentCompanyWechat = new CurrentCompanyWechat();
|
|
|
+ BeanUtils.copyProperties(adminCompanyWechat, currentCompanyWechat);
|
|
|
+
|
|
|
+ currentCompanyWechat.setCurrentCompanyWechatId(currentCompanyWechat.getCompanyWechatId());
|
|
|
+ currentCompanyWechat.setCurrentCompanyName(currentCompanyWechat.getCompanyName());
|
|
|
+
|
|
|
+ if (StringUtils.isNotBlank(token) && source.equals("APP")) {
|
|
|
Object result = redisUtil.get(Constant.RedisPrefix.TOKEN_APP_USER + token);
|
|
|
if (Objects.isNull(result)) {
|
|
|
throw new RemoteServiceException("非法请求,登录信息不存在");
|
|
|
}
|
|
|
user = (User) result;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- CurrentCompanyWechat currentCompanyWechat = new CurrentCompanyWechat();
|
|
|
- BeanUtils.copyProperties(adminCompanyWechat, currentCompanyWechat);
|
|
|
- if (Objects.nonNull(user)) {
|
|
|
- currentCompanyWechat.setCurrentCompanyWechatId(adminCompanyWechat.getCompanyWechatId());
|
|
|
- currentCompanyWechat.setCurrentCompanyName(adminCompanyWechat.getCompanyName());
|
|
|
- currentCompanyWechat.setAppModuleJson(adminPlatform.getAppModuleJson());
|
|
|
- currentCompanyWechat.setUserId(user.getUserId());
|
|
|
currentCompanyWechat.setUser(user);
|
|
|
+ currentCompanyWechat.setUserId(user.getUserId());
|
|
|
+ currentCompanyWechat.setAppModuleJson(adminPlatform.getAppModuleJson());
|
|
|
}
|
|
|
|
|
|
- // 商户授信用户记录
|
|
|
- final UserCompanyCredit userCompanyCredit = userCompanyCreditService.lambdaQuery()
|
|
|
- .eq(UserCompanyCredit::getUserId, userId)
|
|
|
- .eq(UserCompanyCredit::getCompanyWechatId, currentCompanyWechat.getCompanyWechatId())
|
|
|
- .one();
|
|
|
-
|
|
|
- // 是否配送员记录
|
|
|
- final Integer existDelivery = userCompanyDeliveryService.lambdaQuery()
|
|
|
- .eq(UserCompanyDelivery::getUserId, userId)
|
|
|
- .eq(UserCompanyDelivery::getCompanyWechatId, currentCompanyWechat.getCompanyWechatId())
|
|
|
- .count();
|
|
|
-
|
|
|
- currentCompanyWechat.setIsDelivery(existDelivery > 0);
|
|
|
-
|
|
|
- if (Objects.nonNull(userCompanyCredit)) {
|
|
|
- currentCompanyWechat.setCreditLimit(userCompanyCredit.getCreditLimit());
|
|
|
- currentCompanyWechat.setAvailableCredit(userCompanyCredit.getAvailableCredit());
|
|
|
- currentCompanyWechat.setIsCreditEnabled(userCompanyCredit.getIsCreditEnabled());
|
|
|
- currentCompanyWechat.setBillingDay(userCompanyCredit.getBillingDay());
|
|
|
- currentCompanyWechat.setPaymentGracePeriod(userCompanyCredit.getPaymentGracePeriod());
|
|
|
+ if (Objects.nonNull(user)) {
|
|
|
+ // 商户授信用户记录
|
|
|
+ final UserCompanyCredit userCompanyCredit = userCompanyCreditService.lambdaQuery()
|
|
|
+ .eq(UserCompanyCredit::getUserId, userId)
|
|
|
+ .eq(UserCompanyCredit::getCompanyWechatId, currentCompanyWechat.getCompanyWechatId())
|
|
|
+ .one();
|
|
|
+
|
|
|
+ // 是否配送员记录
|
|
|
+ final Integer existDelivery = userCompanyDeliveryService.lambdaQuery()
|
|
|
+ .eq(UserCompanyDelivery::getUserId, userId)
|
|
|
+ .eq(UserCompanyDelivery::getCompanyWechatId, currentCompanyWechat.getCompanyWechatId())
|
|
|
+ .count();
|
|
|
+
|
|
|
+ currentCompanyWechat.setIsDelivery(existDelivery > 0);
|
|
|
+
|
|
|
+ if (Objects.nonNull(userCompanyCredit)) {
|
|
|
+ currentCompanyWechat.setCreditLimit(userCompanyCredit.getCreditLimit());
|
|
|
+ currentCompanyWechat.setAvailableCredit(userCompanyCredit.getAvailableCredit());
|
|
|
+ currentCompanyWechat.setIsCreditEnabled(userCompanyCredit.getIsCreditEnabled());
|
|
|
+ currentCompanyWechat.setBillingDay(userCompanyCredit.getBillingDay());
|
|
|
+ currentCompanyWechat.setPaymentGracePeriod(userCompanyCredit.getPaymentGracePeriod());
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
return currentCompanyWechat;
|
|
|
-
|
|
|
}
|
|
|
|
|
|
/**
|