|
@@ -19,6 +19,7 @@ import com.gree.mall.miniapp.enums.*;
|
|
|
import com.gree.mall.miniapp.exception.RemoteServiceException;
|
|
|
import com.gree.mall.miniapp.helper.ResponseHelper;
|
|
|
import com.gree.mall.miniapp.logic.common.CommonLogic;
|
|
|
+import com.gree.mall.miniapp.logic.common.SMSLogic;
|
|
|
import com.gree.mall.miniapp.logic.common.outside.WechatLogic;
|
|
|
import com.gree.mall.miniapp.logic.coupon.CouponLogic;
|
|
|
import com.gree.mall.miniapp.logic.order.ShoppingCartLogic;
|
|
@@ -34,6 +35,7 @@ import org.springframework.integration.redis.util.RedisLockRegistry;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.text.SimpleDateFormat;
|
|
@@ -60,7 +62,7 @@ public class UserLogic {
|
|
|
ShoppingCartLogic shoppingCartLogic;
|
|
|
@Autowired
|
|
|
CouponLogic couponLogic;
|
|
|
-// @Autowired
|
|
|
+ // @Autowired
|
|
|
// WorkWechatLogic workWechatLogic;
|
|
|
@Autowired
|
|
|
RedisLockRegistry redisLockRegistry;
|
|
@@ -74,7 +76,7 @@ public class UserLogic {
|
|
|
OrderShareService orderShareService;
|
|
|
@Autowired
|
|
|
UserVisitService userVisitService;
|
|
|
-// @Autowired
|
|
|
+ // @Autowired
|
|
|
// EnterpriseWechatWorkerService enterpriseWechatWorkerService;
|
|
|
@Autowired
|
|
|
private OrderShareRankMapper orderShareRankMapper;
|
|
@@ -107,6 +109,9 @@ public class UserLogic {
|
|
|
|
|
|
@Autowired
|
|
|
PgOrderWorkerService pgOrderWorkerService;
|
|
|
+ @Resource
|
|
|
+ SMSLogic smsLogic;
|
|
|
+
|
|
|
/**
|
|
|
* 微信小程序授权
|
|
|
*
|
|
@@ -116,7 +121,7 @@ public class UserLogic {
|
|
|
* @throws RemoteServiceException
|
|
|
* @throws InterruptedException
|
|
|
*/
|
|
|
- public UserWxBean addUser(String code,String phoneCode, String serviceId,String mpOpenId,HttpServletRequest request) throws RemoteServiceException, InterruptedException, WxErrorException {
|
|
|
+ public UserWxBean addUser(String code, String phoneCode, String serviceId, String mpOpenId, HttpServletRequest request) throws RemoteServiceException, InterruptedException, WxErrorException {
|
|
|
CurrentCompanyWechat currentCompanyWechat = commonLogic.getCurrentCompanyWechat(request);
|
|
|
//WxMaService maService = wechatLogic.getMaService(currentCompanyWechat.getCurrentCompanyWechatId());
|
|
|
|
|
@@ -145,7 +150,7 @@ public class UserLogic {
|
|
|
//如果用户不存在则新注册
|
|
|
User user = userService.lambdaQuery()
|
|
|
.eq(User::getOpenId, openId)
|
|
|
- .eq(User::getCompanyWechatId,currentCompanyWechat.getCompanyWechatId())
|
|
|
+ .eq(User::getCompanyWechatId, currentCompanyWechat.getCompanyWechatId())
|
|
|
.one();
|
|
|
if (user == null) {
|
|
|
|
|
@@ -154,13 +159,13 @@ public class UserLogic {
|
|
|
user.setLastLoginTime(new Date());
|
|
|
user.setOpenId(openId);
|
|
|
user.setSessionKey(sessionKey);
|
|
|
- if(StringUtils.isNotBlank(serviceId)) {
|
|
|
+ if (StringUtils.isNotBlank(serviceId)) {
|
|
|
user.setServiceId(serviceId);
|
|
|
user.setServiceTime(new Date());
|
|
|
}
|
|
|
user.setLastLoginTime(new Date());
|
|
|
user.setCreateTime(new Date());
|
|
|
- if(StringUtils.isNotBlank(mpOpenId)){
|
|
|
+ if (StringUtils.isNotBlank(mpOpenId)) {
|
|
|
user.setMpOpenId(mpOpenId);
|
|
|
}
|
|
|
//授权手机号
|
|
@@ -171,7 +176,7 @@ public class UserLogic {
|
|
|
user.setCompanyName(currentCompanyWechat.getCompanyName());
|
|
|
userService.save(user);
|
|
|
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
|
|
|
//如果用户存在,则判断是否为业务员,并更新相关信息
|
|
|
if (!user.getStatus()) {
|
|
@@ -184,7 +189,7 @@ public class UserLogic {
|
|
|
user.setServiceId(serviceId);
|
|
|
user.setServiceTime(new Date());
|
|
|
}
|
|
|
- if(StringUtils.isNotBlank(mpOpenId)){
|
|
|
+ if (StringUtils.isNotBlank(mpOpenId)) {
|
|
|
user.setMpOpenId(mpOpenId);
|
|
|
}
|
|
|
//授权手机号
|
|
@@ -196,7 +201,7 @@ public class UserLogic {
|
|
|
}
|
|
|
|
|
|
//授权手机号后检查是否有预设置的师傅身份信息
|
|
|
- if(StringUtils.isNotBlank(mobile)){
|
|
|
+ if (StringUtils.isNotBlank(mobile)) {
|
|
|
userTypeInit(user);
|
|
|
}
|
|
|
|
|
@@ -209,11 +214,12 @@ public class UserLogic {
|
|
|
|
|
|
/**
|
|
|
* 微信公众号授权
|
|
|
+ *
|
|
|
* @param code
|
|
|
* @param serviceId
|
|
|
* @return
|
|
|
*/
|
|
|
- public UserWxBean addUser(String code,String serviceId,HttpServletRequest request) throws InterruptedException {
|
|
|
+ public UserWxBean addUser(String code, String serviceId, HttpServletRequest request) throws InterruptedException {
|
|
|
CurrentCompanyWechat currentCompanyWechat = commonLogic.getCurrentCompanyWechat(request);
|
|
|
String mpOpenId = wechatLogic.getPubAuthOpenId(code, currentCompanyWechat.getPubAppId());
|
|
|
String key = Constant.RedisPrefix.LOCK_AUTH + ":" + mpOpenId;
|
|
@@ -222,13 +228,13 @@ public class UserLogic {
|
|
|
log.error("请勿重复授权");
|
|
|
return null;
|
|
|
}
|
|
|
- try{
|
|
|
+ try {
|
|
|
//如果用户不存在则新注册
|
|
|
User user = userService.lambdaQuery()
|
|
|
- .eq(User::getOpenId,mpOpenId)
|
|
|
- .eq(User::getCompanyWechatId,currentCompanyWechat.getCompanyWechatId())
|
|
|
+ .eq(User::getOpenId, mpOpenId)
|
|
|
+ .eq(User::getCompanyWechatId, currentCompanyWechat.getCompanyWechatId())
|
|
|
.one();
|
|
|
- if(user == null){
|
|
|
+ if (user == null) {
|
|
|
user = new User();
|
|
|
user.setUserId(IdWorker.getIdStr());
|
|
|
user.setLastLoginTime(new Date());
|
|
@@ -238,13 +244,13 @@ public class UserLogic {
|
|
|
user.setServiceTime(new Date());
|
|
|
user.setLastLoginTime(new Date());
|
|
|
user.setCreateTime(new Date());
|
|
|
- if(StringUtils.isNotBlank(mpOpenId)){
|
|
|
+ if (StringUtils.isNotBlank(mpOpenId)) {
|
|
|
user.setMpOpenId(mpOpenId);
|
|
|
}
|
|
|
user.setCompanyWechatId(currentCompanyWechat.getCompanyWechatId());
|
|
|
user.setCompanyName(currentCompanyWechat.getCompanyName());
|
|
|
userService.save(user);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
//如果用户存在,则判断是否为业务员,并更新相关信息
|
|
|
if (!user.getStatus()) {
|
|
|
throw new RemoteServiceException("用户已被冻结");
|
|
@@ -254,19 +260,19 @@ public class UserLogic {
|
|
|
user.setServiceId(serviceId);
|
|
|
user.setServiceTime(new Date());
|
|
|
}
|
|
|
- if(StringUtils.isNotBlank(mpOpenId)){
|
|
|
+ if (StringUtils.isNotBlank(mpOpenId)) {
|
|
|
user.setMpOpenId(mpOpenId);
|
|
|
}
|
|
|
user.setOpenId(mpOpenId);
|
|
|
user.updateById();
|
|
|
}
|
|
|
//授权手机号后检查是否有预设置的师傅身份信息
|
|
|
- if(StringUtils.isNotBlank(user.getMobile())){
|
|
|
+ if (StringUtils.isNotBlank(user.getMobile())) {
|
|
|
userTypeInit(user);
|
|
|
}
|
|
|
|
|
|
return this.supplyUser(user);
|
|
|
- }finally {
|
|
|
+ } finally {
|
|
|
obtain.unlock();
|
|
|
}
|
|
|
}
|
|
@@ -274,41 +280,42 @@ public class UserLogic {
|
|
|
|
|
|
/**
|
|
|
* 根据初始化的师傅分销员待入驻信息,通过手机号生成用户类型
|
|
|
+ *
|
|
|
* @param user
|
|
|
*/
|
|
|
- public void userTypeInit(User user){
|
|
|
+ public void userTypeInit(User user) {
|
|
|
String mobile = user.getMobile();
|
|
|
CurrentCompanyWechat currentCompanyWechat = commonLogic.getCurrentCompanyWechat();
|
|
|
List<UserWait> list = userWaitService.lambdaQuery()
|
|
|
.eq(UserWait::getMobile, mobile)
|
|
|
.eq(UserWait::getCompanyWechatId, currentCompanyWechat.getCurrentCompanyWechatId())
|
|
|
.list();
|
|
|
- if(CollectionUtils.isEmpty(list)){
|
|
|
+ if (CollectionUtils.isEmpty(list)) {
|
|
|
return;
|
|
|
}
|
|
|
long count = list.stream().filter(v -> StringUtils.equals(v.getUserType(), UserTypeEnum.WORKER.getKey())).count();
|
|
|
Boolean hasWorker = count > 0;
|
|
|
|
|
|
UserTypeEnum userTypeEnum = UserTypeEnum.valueOf(user.getType());
|
|
|
- for(UserWait userWait : list){
|
|
|
+ for (UserWait userWait : list) {
|
|
|
user.setWorkerNumber(userWait.getWorkerNumber());
|
|
|
user.setNickName(userWait.getName());
|
|
|
- if(StringUtils.isBlank(user.getIdCard())){
|
|
|
+ if (StringUtils.isBlank(user.getIdCard())) {
|
|
|
user.setIdCard(userWait.getIdcard());
|
|
|
}
|
|
|
//只有普通用户才需要变更为分销员
|
|
|
- if(userWait.getUserType().equals(UserTypeEnum.SERVICE.getKey())
|
|
|
+ if (userWait.getUserType().equals(UserTypeEnum.SERVICE.getKey())
|
|
|
&& !hasWorker
|
|
|
&& user.getType().equals(UserTypeEnum.GENERAL.getKey())
|
|
|
- && userTypeEnum == UserTypeEnum.GENERAL){
|
|
|
+ && userTypeEnum == UserTypeEnum.GENERAL) {
|
|
|
userTypeEnum = UserTypeEnum.SERVICE;
|
|
|
}
|
|
|
//非师傅状态,只有有1个入驻师傅的就是师傅
|
|
|
- if(userWait.getUserType().equals(UserTypeEnum.WORKER.getKey())){
|
|
|
+ if (userWait.getUserType().equals(UserTypeEnum.WORKER.getKey())) {
|
|
|
|
|
|
userTypeEnum = UserTypeEnum.WORKER;
|
|
|
|
|
|
- if(!user.getType().equals(UserTypeEnum.WORKER.getKey())) {
|
|
|
+ if (!user.getType().equals(UserTypeEnum.WORKER.getKey())) {
|
|
|
//新增网点师傅,先删后增
|
|
|
websitUserService.lambdaUpdate()
|
|
|
.eq(WebsitUser::getWebsitId, userWait.getWebsitId())
|
|
@@ -503,30 +510,40 @@ public class UserLogic {
|
|
|
private UserWxBean supplyUser(User user) {
|
|
|
UserWxBean userWxBean = new UserWxBean();
|
|
|
String name = user.getNickName();
|
|
|
- if(StringUtils.isBlank(name)){
|
|
|
+ if (StringUtils.isBlank(name)) {
|
|
|
name = "小程序用户";
|
|
|
}
|
|
|
String token = JwtUtils.createJWT(user.getUserId(), name, 7 * 24 * 60 * 60 * 1000);
|
|
|
BeanUtils.copyProperties(user, userWxBean);
|
|
|
userWxBean.setToken(token);
|
|
|
userWxBean.setShoppingCartNums(shoppingCartLogic.total(userWxBean.getUserId()));
|
|
|
- redisUtil.set(Constant.RedisPrefix.TOKEN_WX+token,userWxBean.getUserId(),7 * 24 * 60 * 60 * 1000);
|
|
|
+ redisUtil.set(Constant.RedisPrefix.TOKEN_WX + token, userWxBean.getUserId(), 7 * 24 * 60 * 60 * 1000);
|
|
|
+ return userWxBean;
|
|
|
+ }
|
|
|
+
|
|
|
+ private UserWxBean appUser(User user) {
|
|
|
+ UserWxBean userWxBean = new UserWxBean();
|
|
|
+ String token = JwtUtils.createJWT(user.getUserId(), user.getNickName(), 7 * 24 * 60 * 60);
|
|
|
+ BeanUtils.copyProperties(user, userWxBean);
|
|
|
+ userWxBean.setToken(token);
|
|
|
+ redisUtil.set(Constant.RedisPrefix.TOKEN_WX + token, userWxBean.getUserId(), 7 * 24 * 60 * 60);
|
|
|
+ redisUtil.set(Constant.RedisPrefix.TOKEN_APP_USER + token, user, 7 * 24 * 60 * 60);
|
|
|
return userWxBean;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 绑定业务员
|
|
|
*/
|
|
|
- public void bind(String userId, String serviceId,String serviceOpenId) {
|
|
|
- if(StringUtils.isBlank(serviceId) && StringUtils.isBlank(serviceOpenId)){
|
|
|
+ public void bind(String userId, String serviceId, String serviceOpenId) {
|
|
|
+ if (StringUtils.isBlank(serviceId) && StringUtils.isBlank(serviceOpenId)) {
|
|
|
return;
|
|
|
}
|
|
|
User user = userService.getById(userId);
|
|
|
User service = null;
|
|
|
- if(StringUtils.isNotBlank(serviceId)) {
|
|
|
+ if (StringUtils.isNotBlank(serviceId)) {
|
|
|
service = userService.getById(serviceId);
|
|
|
- }else{
|
|
|
- service = userService.lambdaQuery().eq(User::getMiniOpenId,serviceOpenId).last("limit 1").one();
|
|
|
+ } else {
|
|
|
+ service = userService.lambdaQuery().eq(User::getMiniOpenId, serviceOpenId).last("limit 1").one();
|
|
|
}
|
|
|
if (service == null) {
|
|
|
return;
|
|
@@ -544,10 +561,10 @@ public class UserLogic {
|
|
|
// }
|
|
|
|
|
|
//判断是否为团长
|
|
|
- if(!user.getPromotionGroupLeader()) {
|
|
|
+ if (!user.getPromotionGroupLeader()) {
|
|
|
if (service.getPromotionGroupLeader()) {
|
|
|
user.setPromotionGroupUserId(serviceId);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
String promotionGroupUserId = service.getPromotionGroupUserId();
|
|
|
user.setPromotionGroupUserId(promotionGroupUserId);
|
|
|
}
|
|
@@ -557,11 +574,11 @@ public class UserLogic {
|
|
|
|
|
|
}
|
|
|
|
|
|
- public User getUserByMobile(String mobile,String companyWechatId){
|
|
|
+ public User getUserByMobile(String mobile, String companyWechatId) {
|
|
|
return userService.lambdaQuery()
|
|
|
- .eq(User::getMobile,mobile)
|
|
|
- .eq(User::getStatus,true)
|
|
|
- .eq(User::getCompanyWechatId,companyWechatId).one();
|
|
|
+ .eq(User::getMobile, mobile)
|
|
|
+ .eq(User::getStatus, true)
|
|
|
+ .eq(User::getCompanyWechatId, companyWechatId).one();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -572,7 +589,7 @@ public class UserLogic {
|
|
|
String userId = CommonUtils.getUserId(request);
|
|
|
User user = userService.lambdaQuery()
|
|
|
.eq(User::getUserId, userId)
|
|
|
- .eq(User::getStatus,true)
|
|
|
+ .eq(User::getStatus, true)
|
|
|
.one();
|
|
|
if (user == null) {
|
|
|
throw new RemoteServiceException("用户不存在");
|
|
@@ -583,7 +600,7 @@ public class UserLogic {
|
|
|
String qrcode = null;
|
|
|
try {
|
|
|
qrcode = wechatLogic.getQrcode(QrCodeEnum.BIND.toString().toLowerCase(Locale.ROOT),
|
|
|
- user.getUserId(), user.getUserId(),currentCompanyWechat.getCompanyWechatId());
|
|
|
+ user.getUserId(), user.getUserId(), currentCompanyWechat.getCompanyWechatId());
|
|
|
if (StringUtils.isNotBlank(qrcode)) {
|
|
|
user.setBindQrcode(qrcode);
|
|
|
userService.updateById(user);
|
|
@@ -601,9 +618,9 @@ public class UserLogic {
|
|
|
String userId = CommonUtils.getUserId(request);
|
|
|
User user = userService.lambdaQuery()
|
|
|
.eq(User::getUserId, userId)
|
|
|
- .eq(User::getStatus,true)
|
|
|
+ .eq(User::getStatus, true)
|
|
|
.one();
|
|
|
- if (user == null || StringUtils.equals(user.getType(),UserTypeEnum.GENERAL.getKey())) {
|
|
|
+ if (user == null || StringUtils.equals(user.getType(), UserTypeEnum.GENERAL.getKey())) {
|
|
|
throw new RemoteServiceException("业务员不存在");
|
|
|
}
|
|
|
|
|
@@ -612,7 +629,7 @@ public class UserLogic {
|
|
|
Date startTime = DateConputeUtils.getLastMonthStart(now);
|
|
|
Date endTimeDay = DateConputeUtils.getCurrentDayStart(now);
|
|
|
RankBean rankBean = new RankBean();
|
|
|
- List<RankItemBean> rankItemBeans = getRankList(orderShareRankMapper.queryRankList(null,endTime, endTimeDay,currentCompanyWechat.getCompanyWechatId()));
|
|
|
+ List<RankItemBean> rankItemBeans = getRankList(orderShareRankMapper.queryRankList(null, endTime, endTimeDay, currentCompanyWechat.getCompanyWechatId()));
|
|
|
|
|
|
List<RankItemBean> myRanks = null;
|
|
|
if (rankItemBeans != null && rankItemBeans.size() > 0) {
|
|
@@ -623,13 +640,13 @@ public class UserLogic {
|
|
|
.limit(1)
|
|
|
.collect(Collectors.toList());
|
|
|
}
|
|
|
- RankItemBean myrank = myRanks != null && myRanks.size() > 0 ? myRanks.get(0) : orderShareRankMapper.queryWorkerInfo(user.getUserId(),currentCompanyWechat.getCompanyWechatId());
|
|
|
+ RankItemBean myrank = myRanks != null && myRanks.size() > 0 ? myRanks.get(0) : orderShareRankMapper.queryWorkerInfo(user.getUserId(), currentCompanyWechat.getCompanyWechatId());
|
|
|
rankBean.setMyRank(myrank);
|
|
|
|
|
|
BigDecimal previousIncome = new BigDecimal("0.00");
|
|
|
BigDecimal currentIncome = new BigDecimal("0.00");
|
|
|
- List<RankItemBean> previous = getRankList(orderShareRankMapper.queryRankList(user.getUserId(), startTime, endTime,currentCompanyWechat.getCompanyWechatId()));
|
|
|
- List<RankItemBean> current = getRankList(orderShareRankMapper.queryRankList(user.getUserId(), endTime, endTimeDay,currentCompanyWechat.getCompanyWechatId()));
|
|
|
+ List<RankItemBean> previous = getRankList(orderShareRankMapper.queryRankList(user.getUserId(), startTime, endTime, currentCompanyWechat.getCompanyWechatId()));
|
|
|
+ List<RankItemBean> current = getRankList(orderShareRankMapper.queryRankList(user.getUserId(), endTime, endTimeDay, currentCompanyWechat.getCompanyWechatId()));
|
|
|
if (previous != null && previous.size() > 0) {
|
|
|
previousIncome = previous.get(0).getTotal();
|
|
|
}
|
|
@@ -650,8 +667,8 @@ public class UserLogic {
|
|
|
}
|
|
|
|
|
|
|
|
|
- public List<RankItemBean> getRankList(List<RankItemBean> list){
|
|
|
- for(int i = 1;i <= list.size(); i ++){
|
|
|
+ public List<RankItemBean> getRankList(List<RankItemBean> list) {
|
|
|
+ for (int i = 1; i <= list.size(); i++) {
|
|
|
list.get(0).setRanking(i);
|
|
|
}
|
|
|
return list;
|
|
@@ -766,14 +783,14 @@ public class UserLogic {
|
|
|
/**
|
|
|
* 个人信息
|
|
|
*/
|
|
|
- public UserWxBean userDetail(String userId,HttpServletRequest request) throws RemoteServiceException {
|
|
|
+ public UserWxBean userDetail(String userId, HttpServletRequest request) throws RemoteServiceException {
|
|
|
CurrentCompanyWechat currentCompanyWechat = commonLogic.getCurrentCompanyWechat();
|
|
|
User user = userService.getById(userId);
|
|
|
if (user == null) {
|
|
|
throw new RemoteServiceException(ResponseHelper.ResponseCode_AUTH_ERROR, "请求不合法");
|
|
|
}
|
|
|
//授权手机号后检查是否有预设置的师傅身份信息
|
|
|
- if(StringUtils.isNotBlank(user.getMobile())){
|
|
|
+ if (StringUtils.isNotBlank(user.getMobile())) {
|
|
|
userTypeInit(user);
|
|
|
}
|
|
|
UserWxBean userWxBean = new UserWxBean();
|
|
@@ -794,18 +811,15 @@ public class UserLogic {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
return userWxBean;
|
|
|
}
|
|
|
|
|
|
public void addUserLog(User user) {
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
- if (userLogService.lambdaQuery().eq(UserLog::getUserId,user.getUserId())
|
|
|
- .between(UserLog::getCreateTime,DateUtil.beginOfDay(new Date()),DateUtil.endOfDay(new Date())).eq(UserLog::getType,"LOGIN").count() < 1
|
|
|
- ){
|
|
|
+ if (userLogService.lambdaQuery().eq(UserLog::getUserId, user.getUserId())
|
|
|
+ .between(UserLog::getCreateTime, DateUtil.beginOfDay(new Date()), DateUtil.endOfDay(new Date())).eq(UserLog::getType, "LOGIN").count() < 1
|
|
|
+ ) {
|
|
|
UserLog userLog = new UserLog();
|
|
|
userLog.setType("LOGIN");
|
|
|
userLog.setCompanyWechatId(user.getCompanyWechatId());
|
|
@@ -818,8 +832,8 @@ public class UserLogic {
|
|
|
}
|
|
|
|
|
|
|
|
|
- if (userLogService.lambdaQuery().eq(UserLog::getUserId,user.getUserId())
|
|
|
- .eq(UserLog::getCreateTime,new Date()).eq(UserLog::getType,"SEE").count() < 1
|
|
|
+ if (userLogService.lambdaQuery().eq(UserLog::getUserId, user.getUserId())
|
|
|
+ .eq(UserLog::getCreateTime, new Date()).eq(UserLog::getType, "SEE").count() < 1
|
|
|
) {
|
|
|
|
|
|
UserLog userLog = new UserLog();
|
|
@@ -858,7 +872,7 @@ public class UserLogic {
|
|
|
//今日收益
|
|
|
BigDecimal today = myProfitMapper.queryProfitSumByTime(user.getUserId(), sdf.format(DateUtil.beginOfDay(new Date())), sdf.format(new Date()));
|
|
|
///本月收益
|
|
|
- BigDecimal toMonth =myProfitMapper.queryProfitSumByTime(user.getUserId(),sdf.format(DateUtil.beginOfMonth(new Date())),sdf.format(new Date()));
|
|
|
+ BigDecimal toMonth = myProfitMapper.queryProfitSumByTime(user.getUserId(), sdf.format(DateUtil.beginOfMonth(new Date())), sdf.format(new Date()));
|
|
|
|
|
|
myProfitBean.setToday(today);
|
|
|
myProfitBean.setToMonth(toMonth);
|
|
@@ -878,7 +892,7 @@ public class UserLogic {
|
|
|
// .eq(OrderShare::getCompanyWechatId,user.getCompanyWechatId())
|
|
|
// .orderByDesc(OrderShare::getCreateTime)
|
|
|
// .page(new Page<>(pageNum, pageSize));
|
|
|
- return myProfitMapper.queryOrderShareList(new Page<>(pageNum,pageSize),user.getUserId(),status);
|
|
|
+ return myProfitMapper.queryOrderShareList(new Page<>(pageNum, pageSize), user.getUserId(), status);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -886,21 +900,21 @@ public class UserLogic {
|
|
|
*/
|
|
|
public BigDecimal totalProfit(String userId) {
|
|
|
User user = userService.getById(userId);
|
|
|
- if (user == null || StringUtils.equals(user.getType(),UserTypeEnum.GENERAL.getKey())) {
|
|
|
+ if (user == null || StringUtils.equals(user.getType(), UserTypeEnum.GENERAL.getKey())) {
|
|
|
return null;
|
|
|
}
|
|
|
//商城商品收益
|
|
|
List<OrderShare> list1 = orderShareService.lambdaQuery()
|
|
|
- .eq(OrderShare::getOpenId,user.getOpenId())
|
|
|
- .eq(OrderShare::getCompanyWechatId,user.getCompanyWechatId())
|
|
|
- .and(v -> v.eq(OrderShare::getWorkUserId,user.getUserId()))
|
|
|
+ .eq(OrderShare::getOpenId, user.getOpenId())
|
|
|
+ .eq(OrderShare::getCompanyWechatId, user.getCompanyWechatId())
|
|
|
+ .and(v -> v.eq(OrderShare::getWorkUserId, user.getUserId()))
|
|
|
.eq(OrderShare::getStatus, OrderShareStatusEnum.OVER.toString())
|
|
|
.list();
|
|
|
//延保订单收益
|
|
|
List<PgIncreOrder> list2 = pgIncreOrderService.lambdaQuery()
|
|
|
.eq(PgIncreOrder::getWorkerId, user.getUserId())
|
|
|
.eq(PgIncreOrder::getSettleStatus, OrderShareStatusEnum.OVER.toString())
|
|
|
- .eq(PgIncreOrder::getPayStatus,PayStatusEnum.PAID.getKey())
|
|
|
+ .eq(PgIncreOrder::getPayStatus, PayStatusEnum.PAID.getKey())
|
|
|
.list();
|
|
|
if (list1.size() == 0 && list2.size() == 0) {
|
|
|
return new BigDecimal(0);
|
|
@@ -951,20 +965,22 @@ public class UserLogic {
|
|
|
|
|
|
/**
|
|
|
* 设置为默认网点
|
|
|
+ *
|
|
|
* @param websitId
|
|
|
*/
|
|
|
- public void defaultWebsit(String websitId){
|
|
|
+ public void defaultWebsit(String websitId) {
|
|
|
CurrentCompanyWechat currentCompanyWechat = commonLogic.getCurrentCompanyWechat();
|
|
|
userService.lambdaUpdate()
|
|
|
- .set(User::getDefaultWebsitId,websitId)
|
|
|
- .eq(User::getUserId,currentCompanyWechat.getUserId()).update();
|
|
|
+ .set(User::getDefaultWebsitId, websitId)
|
|
|
+ .eq(User::getUserId, currentCompanyWechat.getUserId()).update();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 入驻的网点列表
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
- public List<AdminWebsitApplyBean> websitList(Boolean isAll,String increId,Boolean isIncre,String lng,String lat){
|
|
|
+ public List<AdminWebsitApplyBean> websitList(Boolean isAll, String increId, Boolean isIncre, String lng, String lat) {
|
|
|
CurrentCompanyWechat currentCompanyWechat = commonLogic.getCurrentCompanyWechat();
|
|
|
// List<AdminWebsit> list = adminWebsitService.lambdaQuery()
|
|
|
// .eq(AdminWebsit::getCompanyWechatId, currentCompanyWechat.getCurrentCompanyWechatId())
|
|
@@ -979,26 +995,26 @@ public class UserLogic {
|
|
|
.eq(WebsitUser::getUserId, currentCompanyWechat.getUserId())
|
|
|
.list();
|
|
|
|
|
|
- Map<String,WebsitUser> websitUserMap = websitUserList.stream().collect(Collectors.toMap(v -> v.getWebsitId(), Function.identity()));
|
|
|
+ Map<String, WebsitUser> websitUserMap = websitUserList.stream().collect(Collectors.toMap(v -> v.getWebsitId(), Function.identity()));
|
|
|
|
|
|
//非查询所有,只取已入驻成功的网点
|
|
|
List<String> websitIds = null;
|
|
|
- if(isAll == null || !isAll) {
|
|
|
+ if (isAll == null || !isAll) {
|
|
|
websitIds = websitUserList.stream()
|
|
|
.filter(v -> StringUtils.equals(v.getExamineStatus(), ExamineStatusEnum.OK.getKey()))
|
|
|
.map(WebsitUser::getWebsitId).collect(Collectors.toList());
|
|
|
|
|
|
- if(CollectionUtils.isEmpty(websitIds)){
|
|
|
+ if (CollectionUtils.isEmpty(websitIds)) {
|
|
|
return new ArrayList<>();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//延保筛选对应网点
|
|
|
- if (!StringUtil.isEmpty(increId)){
|
|
|
+ if (!StringUtil.isEmpty(increId)) {
|
|
|
List<String> websitIncre = pgIncreWebsitService.lambdaQuery().eq(PgIncreWebsit::getPgIncreId, increId)
|
|
|
.select(PgIncreWebsit::getWebsitId).list().stream().map(PgIncreWebsit::getWebsitId).collect(Collectors.toList());
|
|
|
|
|
|
- if(CollectionUtils.isEmpty(websitIncre) || CollectionUtils.isEmpty(websitIds)){
|
|
|
+ if (CollectionUtils.isEmpty(websitIncre) || CollectionUtils.isEmpty(websitIds)) {
|
|
|
return new ArrayList<>();
|
|
|
}
|
|
|
websitIds = websitIds.stream()
|
|
@@ -1007,18 +1023,18 @@ public class UserLogic {
|
|
|
|
|
|
}
|
|
|
|
|
|
- List<WebsitVO> list = commonMapper.websitList(lng,lat,websitIds,isIncre,currentCompanyWechat.getCompanyWechatId());
|
|
|
+ List<WebsitVO> list = commonMapper.websitList(lng, lat, websitIds, isIncre, currentCompanyWechat.getCompanyWechatId());
|
|
|
|
|
|
List<AdminWebsitApplyBean> adminWebsitApplyBeans = BeanUtil.copyToList(list, AdminWebsitApplyBean.class);
|
|
|
- for(AdminWebsitApplyBean bean : adminWebsitApplyBeans){
|
|
|
+ for (AdminWebsitApplyBean bean : adminWebsitApplyBeans) {
|
|
|
WebsitUser websitUser = websitUserMap.get(bean.getWebsitId());
|
|
|
- if(websitUser == null){
|
|
|
+ if (websitUser == null) {
|
|
|
//未申请也未入驻
|
|
|
bean.setExamineStatus("N");
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
bean.setExamineStatus(websitUser.getExamineStatus());
|
|
|
}
|
|
|
- bean.setIsDefaultWebsit(StringUtils.equals(bean.getWebsitId(),user.getDefaultWebsitId()));
|
|
|
+ bean.setIsDefaultWebsit(StringUtils.equals(bean.getWebsitId(), user.getDefaultWebsitId()));
|
|
|
}
|
|
|
return adminWebsitApplyBeans;
|
|
|
}
|
|
@@ -1026,10 +1042,11 @@ public class UserLogic {
|
|
|
|
|
|
/**
|
|
|
* 入驻
|
|
|
+ *
|
|
|
* @param userApplyBean
|
|
|
*/
|
|
|
@Transactional
|
|
|
- public void apply(UserApplyBean userApplyBean){
|
|
|
+ public void apply(UserApplyBean userApplyBean) {
|
|
|
|
|
|
String name = userApplyBean.getName();
|
|
|
String type = userApplyBean.getType().getKey();
|
|
@@ -1041,16 +1058,16 @@ public class UserLogic {
|
|
|
|
|
|
CurrentCompanyWechat currentCompanyWechat = commonLogic.getCurrentCompanyWechat();
|
|
|
User user = userService.getById(currentCompanyWechat.getUserId());
|
|
|
- if(StringUtils.isAnyBlank(name,type)) {
|
|
|
+ if (StringUtils.isAnyBlank(name, type)) {
|
|
|
throw new RemoteServiceException("缺乏必填的参数");
|
|
|
}
|
|
|
|
|
|
//入驻分销员
|
|
|
- if(type.equals(UserTypeEnum.SERVICE.getKey())){
|
|
|
- if(!user.getType().equals(UserTypeEnum.GENERAL.toString())){
|
|
|
+ if (type.equals(UserTypeEnum.SERVICE.getKey())) {
|
|
|
+ if (!user.getType().equals(UserTypeEnum.GENERAL.toString())) {
|
|
|
throw new RemoteServiceException("当前用户类型不可申请成为分销员");
|
|
|
}
|
|
|
- if(StringUtils.equals(user.getType(),UserTypeEnum.SERVICE.getKey())){
|
|
|
+ if (StringUtils.equals(user.getType(), UserTypeEnum.SERVICE.getKey())) {
|
|
|
throw new RemoteServiceException("请勿重复入驻分销员");
|
|
|
}
|
|
|
//判断是否存在待审批入驻师傅的记录
|
|
@@ -1058,7 +1075,7 @@ public class UserLogic {
|
|
|
.eq(WebsitUser::getUserId, user.getUserId())
|
|
|
.eq(WebsitUser::getExamineStatus, OrderExamineEnum.WAIT.toString())
|
|
|
.count();
|
|
|
- if(count1 > 0){
|
|
|
+ if (count1 > 0) {
|
|
|
throw new RemoteServiceException("已存在入驻师傅待审批的信息,请等待处理");
|
|
|
}
|
|
|
user.setExamineStatus(OrderExamineEnum.WAIT.toString());
|
|
@@ -1066,27 +1083,27 @@ public class UserLogic {
|
|
|
user.setExamineBy("");
|
|
|
}
|
|
|
//入驻师傅
|
|
|
- if(type.equals(UserTypeEnum.WORKER.getKey()) ){
|
|
|
- if(StringUtils.isAnyBlank(idCard,idCardImg)) {
|
|
|
+ if (type.equals(UserTypeEnum.WORKER.getKey())) {
|
|
|
+ if (StringUtils.isAnyBlank(idCard, idCardImg)) {
|
|
|
throw new RemoteServiceException("缺乏必填的参数");
|
|
|
}
|
|
|
- if(StringUtils.isBlank(websitId)){
|
|
|
+ if (StringUtils.isBlank(websitId)) {
|
|
|
throw new RemoteServiceException("请选择网点入驻");
|
|
|
}
|
|
|
- if(user.getExamineStatus().equals(OrderExamineEnum.WAIT.toString())){
|
|
|
+ if (user.getExamineStatus().equals(OrderExamineEnum.WAIT.toString())) {
|
|
|
throw new RemoteServiceException("已存在入驻分销员待审批的信息,请等待处理");
|
|
|
}
|
|
|
//判断是否已入驻
|
|
|
Integer count = websitUserService.lambdaQuery()
|
|
|
.eq(WebsitUser::getUserId, user.getUserId())
|
|
|
.eq(WebsitUser::getWebsitId, websitId)
|
|
|
- .ne(WebsitUser::getExamineStatus,OrderExamineEnum.FAIL.toString())
|
|
|
+ .ne(WebsitUser::getExamineStatus, OrderExamineEnum.FAIL.toString())
|
|
|
.count();
|
|
|
- if(count > 0){
|
|
|
+ if (count > 0) {
|
|
|
throw new RemoteServiceException("您已入驻当前网点");
|
|
|
}
|
|
|
|
|
|
- websitUserService.lambdaUpdate().eq(WebsitUser::getUserId,user.getUserId()).eq(WebsitUser::getWebsitId,websitId).remove();
|
|
|
+ websitUserService.lambdaUpdate().eq(WebsitUser::getUserId, user.getUserId()).eq(WebsitUser::getWebsitId, websitId).remove();
|
|
|
|
|
|
WebsitUser websitUser = new WebsitUser();
|
|
|
websitUser.setWebsitId(websitId);
|
|
@@ -1099,7 +1116,7 @@ public class UserLogic {
|
|
|
websitUser.insert();
|
|
|
}
|
|
|
|
|
|
- if(StringUtils.isNotBlank(idCard) && idCard.length() != 18){
|
|
|
+ if (StringUtils.isNotBlank(idCard) && idCard.length() != 18) {
|
|
|
throw new RemoteServiceException("请输入正确的身份证号");
|
|
|
}
|
|
|
user.setNickName(name);
|
|
@@ -1112,7 +1129,7 @@ public class UserLogic {
|
|
|
user.updateById();
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(workerImgs)) {
|
|
|
- for(WorkerImg workerImg : workerImgs){
|
|
|
+ for (WorkerImg workerImg : workerImgs) {
|
|
|
workerImg.setWebsitId(websitId);
|
|
|
workerImg.setWorkerId(currentCompanyWechat.getUserId());
|
|
|
}
|
|
@@ -1125,7 +1142,7 @@ public class UserLogic {
|
|
|
/**
|
|
|
* 我的统计
|
|
|
*/
|
|
|
- public MyCountBean myCount(String userId){
|
|
|
+ public MyCountBean myCount(String userId) {
|
|
|
//收藏数量
|
|
|
Integer count = goodsFavoriteService.lambdaQuery().eq(GoodsFavorite::getUserId, userId).count();
|
|
|
//我的优惠券
|
|
@@ -1189,4 +1206,72 @@ public class UserLogic {
|
|
|
|
|
|
this.addUserLog(user);
|
|
|
}
|
|
|
+
|
|
|
+ public void sendMessageCode(String mobile) throws Exception {
|
|
|
+// if (StringUtils.isEmpty(mobile) || mobile.length() < 11) {
|
|
|
+// throw new RemoteServiceException("请输入正确手机号");
|
|
|
+// }
|
|
|
+
|
|
|
+ // 查询师傅手机号
|
|
|
+ UserWait userWait = userWaitService.lambdaQuery()
|
|
|
+ .eq(UserWait::getMobile, mobile)
|
|
|
+ .eq(UserWait::getUserType, UserTypeEnum.WORKER.getKey())
|
|
|
+ .last("limit 1")
|
|
|
+ .one();
|
|
|
+ if (Objects.isNull(userWait)) {
|
|
|
+ throw new RemoteServiceException("请输入正确手机号");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 向手机号发送验证码
|
|
|
+ smsLogic.sendSms(mobile);
|
|
|
+ }
|
|
|
+
|
|
|
+ public UserWxBean workerMobileLogin(String mobile, String messageCode) {
|
|
|
+ Object validMessageCode = redisUtil.get(Constant.RedisPrefix.SMS + ":" + mobile);
|
|
|
+ if (Objects.isNull(validMessageCode)) {
|
|
|
+ throw new RemoteServiceException("短信验证码过期");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!messageCode.equals(validMessageCode)) {
|
|
|
+ throw new RemoteServiceException("短信验证码错误");
|
|
|
+ }
|
|
|
+
|
|
|
+ final AdminCompanyWechat wechat = adminCompanyWechatService.lambdaQuery()
|
|
|
+ .last("limit 1")
|
|
|
+ .one();
|
|
|
+
|
|
|
+ User user = this.initAppUser(wechat, mobile);
|
|
|
+
|
|
|
+ return this.appUser(user);
|
|
|
+ }
|
|
|
+
|
|
|
+ private User initAppUser(AdminCompanyWechat wechat, String mobile) {
|
|
|
+ UserWait userWait = userWaitService.lambdaQuery()
|
|
|
+ .eq(UserWait::getMobile, mobile)
|
|
|
+ .eq(UserWait::getUserType, UserTypeEnum.WORKER.getKey())
|
|
|
+ .last("limit 1")
|
|
|
+ .one();
|
|
|
+
|
|
|
+ if (Objects.isNull(userWait)) {
|
|
|
+ throw new RemoteServiceException("无师傅信息");
|
|
|
+ }
|
|
|
+
|
|
|
+ User user = new User();
|
|
|
+ user.setCompanyWechatId(wechat.getCompanyWechatId())
|
|
|
+ .setCompanyName(wechat.getCompanyName())
|
|
|
+ .setNickName(userWait.getName())
|
|
|
+ .setMobile(userWait.getMobile())
|
|
|
+ .setType(UserTypeEnum.WORKER.getKey())
|
|
|
+ .setWorkerNumber(userWait.getWorkerNumber());
|
|
|
+ return user;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void addVisit(UserWxBean userWxBean) {
|
|
|
+ UserVisit userVisit = new UserVisit();
|
|
|
+ userVisit.setUserId(userWxBean.getUserId());
|
|
|
+ userVisit.setVisitTime(new Date());
|
|
|
+ userVisit.setCompanyWechatId(userWxBean.getCompanyWechatId());
|
|
|
+ userVisit.setCompanyName(userWxBean.getCompanyName());
|
|
|
+ userVisit.insert();
|
|
|
+ }
|
|
|
}
|