|
@@ -14,6 +14,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.github.pagehelper.Page;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
+import com.google.common.base.Strings;
|
|
|
import com.zbkj.common.constants.*;
|
|
|
import com.zbkj.common.exception.CrmebException;
|
|
|
import com.zbkj.common.model.admin.SystemAdmin;
|
|
@@ -23,7 +24,6 @@ import com.zbkj.common.model.merchant.MerchantSmsTemplate;
|
|
|
import com.zbkj.common.model.merchant.MerchantSmsTiming;
|
|
|
import com.zbkj.common.model.order.*;
|
|
|
import com.zbkj.common.model.system.SystemNotification;
|
|
|
-import com.zbkj.common.model.system.TaskMessage;
|
|
|
import com.zbkj.common.model.user.User;
|
|
|
import com.zbkj.common.model.user.UserBypassAccount;
|
|
|
import com.zbkj.common.model.user.UserEnterprise;
|
|
@@ -31,7 +31,6 @@ import com.zbkj.common.model.user.UserToken;
|
|
|
import com.zbkj.common.page.CommonPage;
|
|
|
import com.zbkj.common.request.*;
|
|
|
import com.zbkj.common.response.*;
|
|
|
-import com.zbkj.common.result.CommonResult;
|
|
|
import com.zbkj.common.utils.CrmebDateUtil;
|
|
|
import com.zbkj.common.utils.RedisUtil;
|
|
|
import com.zbkj.common.utils.SecurityUtil;
|
|
@@ -39,9 +38,7 @@ import com.zbkj.common.vo.DateLimitUtilVo;
|
|
|
import com.zbkj.common.vo.LogisticsResultVo;
|
|
|
import com.zbkj.common.vo.MyRecord;
|
|
|
import com.zbkj.service.dao.OrderDao;
|
|
|
-import com.zbkj.service.dao.UserDao;
|
|
|
import com.zbkj.service.service.*;
|
|
|
-import io.swagger.models.auth.In;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -52,6 +49,7 @@ import javax.annotation.Resource;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.ConcurrentHashMap;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -110,6 +108,9 @@ public class OrderServiceImpl extends ServiceImpl<OrderDao, Order> implements Or
|
|
|
@Autowired
|
|
|
private UserBypassAccountService userBypassAccountService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private UserEnterpriseService userEnterpriseService;
|
|
|
+
|
|
|
/**
|
|
|
* 根据订单编号获取订单
|
|
|
*
|
|
@@ -336,7 +337,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderDao, Order> implements Or
|
|
|
LambdaQueryWrapper<Order> lqw = Wrappers.lambdaQuery();
|
|
|
lqw.select(Order::getOrderNo, Order::getUid, Order::getPayPrice, Order::getPayType, Order::getPaid, Order::getStatus, Order::getRefundStatus,
|
|
|
Order::getIsUserDel, Order::getCancelStatus, Order::getType, Order::getCreateTime, Order::getLevel,
|
|
|
- Order::getIsRemit, Order::getAccount, Order::getQyName, Order::getProcureUnit, Order::getQyId);
|
|
|
+ Order::getIsRemit, Order::getAccount, Order::getQyName, Order::getProcureUnit, Order::getQyId, Order::getMerId);
|
|
|
lqw.eq(Order::getMerId, systemAdmin.getMerId());
|
|
|
//这个方法查询不是属于积分支付的订单 不是
|
|
|
// lqw.ne(Order::getIsIntegral, 1).or().isNull(Order::getIsIntegral);
|
|
@@ -356,7 +357,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderDao, Order> implements Or
|
|
|
lqw.like(Order::getOrderNo, URLUtil.decode(request.getOrderNo()));
|
|
|
}
|
|
|
if (StrUtil.isNotBlank(request.getQyName())) {
|
|
|
- lqw.like(Order::getQyId, request.getQyName());
|
|
|
+ lqw.eq(Order::getQyId, request.getQyName());
|
|
|
}
|
|
|
if (ObjectUtil.isNotNull(request.getType())) {
|
|
|
lqw.eq(Order::getType, request.getType());
|
|
@@ -374,6 +375,8 @@ public class OrderServiceImpl extends ServiceImpl<OrderDao, Order> implements Or
|
|
|
}
|
|
|
List<Integer> uidList = orderList.stream().map(Order::getUid).distinct().collect(Collectors.toList());
|
|
|
Map<Integer, User> userMap = userService.getUidMapList(uidList);
|
|
|
+ Map<Integer, UserBypassAccount> userBypassAccountCache = new ConcurrentHashMap<>();
|
|
|
+ Map<Integer, UserEnterprise> userEnterpriseCache = new ConcurrentHashMap<>();
|
|
|
List<MerchantOrderPageResponse> pageResponses = orderList.stream().map(e -> {
|
|
|
|
|
|
MerchantOrderPageResponse pageResponse = new MerchantOrderPageResponse();
|
|
@@ -388,30 +391,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderDao, Order> implements Or
|
|
|
pageResponse.setIsRemit(e.getIsRemit());
|
|
|
pageResponse.setQyName(e.getProcureUnit());
|
|
|
pageResponse.setQyId(e.getQyId());
|
|
|
-// if (e.getIsLineOfCredit()!=null){
|
|
|
-// if (e.getIsLineOfCredit()==1){
|
|
|
- //换个判断
|
|
|
-// if (e.getPayType().equals( "信用额度" )){
|
|
|
-// UserEnterprise one = new UserEnterprise();
|
|
|
-// LambdaQueryWrapper<UserEnterprise> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
-// queryWrapper.eq( UserEnterprise::getUserId, e.getUid() );
|
|
|
-// queryWrapper.eq( UserEnterprise::getIsDelete, 0 );
|
|
|
-// one = userEnterpriseService.getOne( queryWrapper,false );
|
|
|
-// if (one == null) {
|
|
|
-// LambdaQueryWrapper<UserBypassAccount> queryWrapper2 = new LambdaQueryWrapper<>();
|
|
|
-// queryWrapper2.eq( UserBypassAccount::getUserId, e.getUid() );
|
|
|
-// queryWrapper2.eq( UserBypassAccount::getIsDelete, 0 );
|
|
|
-// UserBypassAccount one1 = userBypassAccountService.getOne( queryWrapper2 ,false);
|
|
|
-// if (one1 != null) {
|
|
|
-// one = userEnterpriseService.getById( one1.getEnterpriseId() );
|
|
|
-// }
|
|
|
-// }
|
|
|
-// if (one!=null){
|
|
|
-// pageResponse.setAccount( one.getAccount() );
|
|
|
-// pageResponse.setQyName( one.getEnterpriseName() );
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
+ setUserRealName(userBypassAccountCache, userEnterpriseCache, e, pageResponse, user);
|
|
|
return pageResponse;
|
|
|
}).collect(Collectors.toList());
|
|
|
return CommonPage.copyPageInfo(startPage, pageResponses);
|
|
@@ -681,6 +661,8 @@ public class OrderServiceImpl extends ServiceImpl<OrderDao, Order> implements Or
|
|
|
Map<Integer, User> userMap = userService.getUidMapList(uidList);
|
|
|
List<Integer> merIdList = orderList.stream().map(Order::getMerId).distinct().collect(Collectors.toList());
|
|
|
Map<Integer, Merchant> merchantMap = merchantService.getMerIdMapByIdList(merIdList);
|
|
|
+ Map<Integer, UserBypassAccount> userBypassAccountCache = new ConcurrentHashMap<>();
|
|
|
+ Map<Integer, UserEnterprise> userEnterpriseCache = new ConcurrentHashMap<>();
|
|
|
List<PlatformOrderPageResponse> pageResponses = orderList.stream().map(e -> {
|
|
|
PlatformOrderPageResponse pageResponse = new PlatformOrderPageResponse();
|
|
|
BeanUtils.copyProperties(e, pageResponse);
|
|
@@ -688,17 +670,133 @@ public class OrderServiceImpl extends ServiceImpl<OrderDao, Order> implements Or
|
|
|
pageResponse.setShippingType(merchantOrder.getShippingType());
|
|
|
pageResponse.setUserRemark(merchantOrder.getUserRemark());
|
|
|
pageResponse.setMerRemark(merchantOrder.getMerchantRemark());
|
|
|
- pageResponse.setNickName(userMap.get(e.getUid()).getNickname());
|
|
|
- pageResponse.setIsLogoff(userMap.get(e.getUid()).getIsLogoff());
|
|
|
+ User user = userMap.get(e.getUid());
|
|
|
+ pageResponse.setNickName(user == null ? "" : user.getNickname());
|
|
|
+ pageResponse.setIsLogoff(user == null || user.getIsLogoff());
|
|
|
if (e.getMerId() > 0) {
|
|
|
pageResponse.setMerName(merchantMap.get(e.getMerId()).getName());
|
|
|
}
|
|
|
+ setUserRealName(userBypassAccountCache,userEnterpriseCache,e,pageResponse,user);
|
|
|
+ //if (user!=null){
|
|
|
+ // if (Strings.isNullOrEmpty(user.getRealName()) && 3 == user.getIsEnterpriseUser()){
|
|
|
+ // // 用户表中的真实姓名为空同时是企业用户
|
|
|
+ // if (userBypassAccountCache.get(user.getId()) != null) {
|
|
|
+ // pageResponse.setRealName(userBypassAccountCache.get(user.getId()).getRealName());
|
|
|
+ // } else {
|
|
|
+ // UserBypassAccount one = getUserBypassAccount(user,e.getMerId());
|
|
|
+ // if (one !=null){
|
|
|
+ // userBypassAccountCache.put(one.getId(),one);
|
|
|
+ // pageResponse.setRealName(one.getRealName());
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // } else {
|
|
|
+ // pageResponse.setRealName(user.getRealName());
|
|
|
+ // }
|
|
|
+ //}
|
|
|
return pageResponse;
|
|
|
}).collect(Collectors.toList());
|
|
|
return CommonPage.copyPageInfo(startPage, pageResponses);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 获取企业子账户
|
|
|
+ *
|
|
|
+ * @param user 用户
|
|
|
+ * @param merId 商户
|
|
|
+ * @return 企业子账户
|
|
|
+ */
|
|
|
+ private UserBypassAccount getUserBypassAccount(User user, Integer merId) {
|
|
|
+ LambdaQueryWrapper<UserBypassAccount> userBypassAccountLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ userBypassAccountLambdaQueryWrapper.select(UserBypassAccount::getId,UserBypassAccount::getRealName);
|
|
|
+ userBypassAccountLambdaQueryWrapper.eq(UserBypassAccount::getUserId, user.getId());
|
|
|
+ userBypassAccountLambdaQueryWrapper.eq(UserBypassAccount::getMerchantId, merId);
|
|
|
+ UserBypassAccount one = userBypassAccountService.getOne(userBypassAccountLambdaQueryWrapper,false);
|
|
|
+ return one;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取企业主账户
|
|
|
+ * @param user 用户
|
|
|
+ * @param merId 商户
|
|
|
+ * @return 企业主账户
|
|
|
+ */
|
|
|
+ private UserEnterprise getEnterpriseUser(User user, Integer merId) {
|
|
|
+ LambdaQueryWrapper<UserEnterprise> userEnterpriseLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ userEnterpriseLambdaQueryWrapper.select(UserEnterprise::getId,UserEnterprise::getRealName);
|
|
|
+ userEnterpriseLambdaQueryWrapper.eq(UserEnterprise::getUserId, user.getId());
|
|
|
+ userEnterpriseLambdaQueryWrapper.eq(UserEnterprise::getMerchantId, merId);
|
|
|
+ UserEnterprise one = userEnterpriseService.getOne(userEnterpriseLambdaQueryWrapper,false);
|
|
|
+ return one;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置用户真实姓名
|
|
|
+ * @param userBypassAccountCache 企业子用户缓存
|
|
|
+ * @param userEnterpriseCache 企业主用户缓存
|
|
|
+ * @param e 订单
|
|
|
+ * @param pageResponse 页面返回内容
|
|
|
+ * @param user 用户
|
|
|
+ */
|
|
|
+ private void setUserRealName(Map<Integer, UserBypassAccount> userBypassAccountCache, Map<Integer, UserEnterprise> userEnterpriseCache, Order e, Object pageResponse, User user) {
|
|
|
+ String realName = getRealName(userBypassAccountCache, userEnterpriseCache, e, user);
|
|
|
+ if (pageResponse instanceof MerchantOrderPageResponse) {
|
|
|
+ MerchantOrderPageResponse response = (MerchantOrderPageResponse)pageResponse;
|
|
|
+ response.setRealName(realName);
|
|
|
+ } else if (pageResponse instanceof PlatformOrderPageResponse) {
|
|
|
+ PlatformOrderPageResponse response = (PlatformOrderPageResponse)pageResponse;
|
|
|
+ response.setRealName(realName);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getRealName(Map<Integer, UserBypassAccount> userBypassAccountCache, Map<Integer, UserEnterprise> userEnterpriseCache, Order e, User user) {
|
|
|
+ String none = "-";
|
|
|
+ if (user != null) {
|
|
|
+ if(user.getIsEnterpriseUser() != null && user.getIsEnterpriseUser() != 0) {
|
|
|
+ switch (user.getIsEnterpriseUser()) {
|
|
|
+ case 1:
|
|
|
+ // 普通用户
|
|
|
+ return user.getRealName();
|
|
|
+ case 2:
|
|
|
+ // 企业主用户
|
|
|
+ UserEnterprise userEnterprise = userEnterpriseCache.get(user.getId());
|
|
|
+ if (userEnterprise == null) {
|
|
|
+ userEnterprise = getEnterpriseUser(user, e.getMerId());
|
|
|
+ if(userEnterprise != null) {
|
|
|
+ userEnterpriseCache.put(user.getId(), userEnterprise);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (userEnterprise != null) {
|
|
|
+ return userEnterprise.getRealName();
|
|
|
+ } else {
|
|
|
+ return none;
|
|
|
+ }
|
|
|
+ case 3:
|
|
|
+ // 企业子用户
|
|
|
+ UserBypassAccount userBypassAccount = userBypassAccountCache.get(user.getId());
|
|
|
+ if(userBypassAccount == null) {
|
|
|
+ userBypassAccount = getUserBypassAccount(user, e.getMerId());
|
|
|
+ if(userBypassAccount != null) {
|
|
|
+ userBypassAccountCache.put(user.getId(), userBypassAccount);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (userBypassAccount != null) {
|
|
|
+ return userBypassAccount.getRealName();
|
|
|
+ } else {
|
|
|
+ return none;
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ return none;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return none;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return none;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 获取平台端订单各状态数量
|
|
|
*
|
|
|
* @param dateLimit 时间参数
|