|
|
|
@@ -1,40 +1,45 @@ |
|
|
|
package com.iformall.service.impl; |
|
|
|
|
|
|
|
import java.util.*; |
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
import com.iformall.common.IdWorker; |
|
|
|
import com.iformall.domain.dto.WxCUserBasicInfoDto; |
|
|
|
import com.iformall.domain.po.WxCUser; |
|
|
|
import com.iformall.domain.po.WxCouponOrder; |
|
|
|
import com.iformall.domain.po.WxScoreRules; |
|
|
|
import com.iformall.domain.po.WxScoreHistory; |
|
|
|
import com.iformall.enums.EnumScoreType; |
|
|
|
import com.iformall.mapper.WxCUserMapper; |
|
|
|
import com.iformall.mapper.WxCouponOrderMapper; |
|
|
|
import com.iformall.mapper.WxScoreHistoryMapper; |
|
|
|
import com.iformall.mapper.WxScoreRulesMapper; |
|
|
|
import com.iformall.service.WxCUserService; |
|
|
|
import com.iformall.service.WxScoreRulesService; |
|
|
|
import org.apache.commons.lang3.time.DateUtils; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import com.iformall.common.IdWorker; |
|
|
|
|
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
@Service |
|
|
|
public class WxCUserServiceImpl implements WxCUserService { |
|
|
|
private final Logger logger = LoggerFactory.getLogger(this.getClass()); |
|
|
|
|
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
WxCUserMapper wxCUserMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
WxCouponOrderMapper wxCouponOrderMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
WxScoreRulesMapper wxScoreRulesMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
WxScoreRulesService wxScoreRulesService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
WxScoreHistoryMapper wxScoreHistoryMapper; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public PageInfo<WxCUser> listAsPage(WxCUser record, Integer pageIndex, Integer pageSize) { |
|
|
|
@@ -71,7 +76,7 @@ public class WxCUserServiceImpl implements WxCUserService { |
|
|
|
} else { |
|
|
|
user.setLoginCount(user.getLoginCount() + 1); |
|
|
|
user.setUpdateDate(curr); |
|
|
|
ret =wxCUserMapper.updateByPrimaryKeySelective(user); |
|
|
|
ret = wxCUserMapper.updateByPrimaryKeySelective(user); |
|
|
|
} |
|
|
|
|
|
|
|
return ret; |
|
|
|
@@ -82,28 +87,34 @@ public class WxCUserServiceImpl implements WxCUserService { |
|
|
|
wxCUserMapper.deleteByPrimaryKey(id); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public long findCount(WxCUserBasicInfoDto dto) { |
|
|
|
return wxCUserMapper.findCount(dto); |
|
|
|
} |
|
|
|
@Override |
|
|
|
public long findCount(WxCUserBasicInfoDto dto) { |
|
|
|
return wxCUserMapper.findCount(dto); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageInfo<WxCUser> listByChannel(String tenantId, List<String> sceneList, Integer pageIndex, Integer pageSize) { |
|
|
|
return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCUserMapper.listByChannel(sceneList, tenantId)); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageInfo<WxCUser> listByChannel(String tenantId, List<String> sceneList, Integer pageIndex, Integer pageSize) { |
|
|
|
return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCUserMapper.listByChannel(sceneList, tenantId)); |
|
|
|
} |
|
|
|
private int checkTodayLoginScoreCount(WxCUser cUser) { |
|
|
|
WxScoreHistory scoreHistory = new WxScoreHistory(); |
|
|
|
scoreHistory.setTenantId(cUser.getTenantId()); |
|
|
|
scoreHistory.setCUserId(cUser.getId()); |
|
|
|
scoreHistory.setScoreType(EnumScoreType.LOGIN.getCode()); |
|
|
|
return wxScoreHistoryMapper.countList(scoreHistory); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void scoreCalculate(WxCUser user, boolean isNew) { |
|
|
|
if (isNew) { |
|
|
|
wxScoreRulesService.loginAddScore(user); |
|
|
|
} else { |
|
|
|
WxCUser oldUser = getById(user.getId()); |
|
|
|
if (!DateUtils.isSameDay(user.getUpdateDate(), oldUser.getUpdateDate())) { |
|
|
|
if (checkTodayLoginScoreCount(user) <= 0) { |
|
|
|
wxScoreRulesService.loginAddScore(user); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |