|
|
@@ -10,6 +10,7 @@ import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
@@ -60,7 +61,10 @@ import com.fs.hisStore.domain.FsUserBillScrm;
|
|
|
import com.fs.hisStore.domain.FsUserScrm;
|
|
|
import com.fs.hisStore.enums.BillDetailEnum;
|
|
|
import com.fs.hisStore.mapper.FsStoreOrderScrmMapper;
|
|
|
+import com.fs.hisStore.mapper.FsUserScrmMapper;
|
|
|
import com.fs.hisStore.service.IFsUserBillScrmService;
|
|
|
+import com.fs.hisStore.service.IFsUserScrmService;
|
|
|
+import com.fs.hisStore.service.impl.FsUserScrmServiceImpl;
|
|
|
import com.fs.hisStore.vo.FsCompanyUserListQueryVO;
|
|
|
import com.fs.qw.cache.IQwExternalContactCacheService;
|
|
|
import com.fs.qw.dto.FsUserTransferParamDTO;
|
|
|
@@ -81,6 +85,7 @@ import com.fs.watch.service.WatchUserService;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
+import org.apache.commons.lang.exception.ExceptionUtils;
|
|
|
import org.apache.http.util.Asserts;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
@@ -169,6 +174,9 @@ public class FsUserServiceImpl implements IFsUserService
|
|
|
@Autowired
|
|
|
private IFsUserWxService fsUserWxService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IFsUserScrmService fsUserScrmService;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 查询用户
|
|
|
@@ -1281,4 +1289,56 @@ public class FsUserServiceImpl implements IFsUserService
|
|
|
return R.ok();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分销门槛:1级分销--下级>50人 或者消费累计满5000元 系统自动升级为1级
|
|
|
+ * 2级分销--下级>10人 或者消费累计满1000元 系统自动升级为2级
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void promoterAutoUpgrade() {
|
|
|
+ List<Long> userIds = null;
|
|
|
+ Long lastUserId = 0L;
|
|
|
+
|
|
|
+ do{
|
|
|
+ userIds = fsUserMapper.selectPromoterAutoUpgradeData(lastUserId);
|
|
|
+ if (userIds == null || userIds.isEmpty()) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (Long userId : userIds) {
|
|
|
+ lastUserId = userId;
|
|
|
+
|
|
|
+ try{
|
|
|
+ Integer userLevel = fsUserScrmService.queryUserLevel(userId);
|
|
|
+
|
|
|
+ if(ObjectUtil.equal(userLevel,1)) {
|
|
|
+ logger.info("用户等级为1,无须升级,直接跳过...");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ Long downLineCount = fsUserMapper.queryDownLineCount(userId);
|
|
|
+ BigDecimal totalMoney = fsUserMapper.queryUserAndUserDownLineMoney(userId);
|
|
|
+
|
|
|
+ logger.info("当前用户:{} 下线数:{} 用户和下级总消费金额:{}",userId,downLineCount,totalMoney);
|
|
|
+ if(ObjectUtil.equal(userLevel,2)){
|
|
|
+ if(downLineCount > 50 || totalMoney.compareTo(BigDecimal.valueOf(5000)) >= 0) {
|
|
|
+ logger.info("当前用户: {} ,当前等级为{} 升级为1级{}",userId,userLevel,totalMoney);
|
|
|
+ fsUserScrmService.upgradeUser(userId);
|
|
|
+ }
|
|
|
+ } else if(ObjectUtil.equal(userLevel,3)) {
|
|
|
+ if(downLineCount > 10 || totalMoney.compareTo(BigDecimal.valueOf(1000)) >= 0) {
|
|
|
+ logger.info("当前用户: {} ,当前等级为{} 升级为2级{}",userId,userLevel,totalMoney);
|
|
|
+ fsUserScrmService.upgradeUser(userId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }catch (Exception e) {
|
|
|
+ logger.error("自动升级用户 {} 失败!原因: {}",userId, ExceptionUtils.getFullStackTrace(e),e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }while (!userIds.isEmpty());
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|