xhxu 5 лет назад
Родитель
Сommit
8df0b7f19d
5 измененных файлов: 10 добавлений и 129 удалений
  1. +3
    -1
      mallinkMQConsumer/src/main/java/com/iformall/mq/MqBaseConsumer.java
  2. +2
    -2
      mallinkService/src/main/java/com/iformall/service/impl/WxCreditHistoryServiceImpl.java
  3. +4
    -21
      mallinkService/src/main/java/com/iformall/utils/CreditUtil.java
  4. +0
    -1
      mallinkSysAdmin/src/main/java/com/iformall/controller/datafix/DataInitController.java
  5. +1
    -104
      mallinkWebSocketServer/src/main/java/com/iformall/controller/BaseController.java

+ 3
- 1
mallinkMQConsumer/src/main/java/com/iformall/mq/MqBaseConsumer.java Просмотреть файл

@@ -35,6 +35,8 @@ public class MqBaseConsumer {
@Autowired
private FmInsideCouponVerifyMsgServiceImpl fmInsideCouponVerifyMsgService;
@Autowired
private FmInsideCLoginMsgServiceImpl fmInsideCLoginMsgService;
@Autowired
private MqBaseProducer mqBaseProducer;

//@Autowired
@@ -88,7 +90,7 @@ public class MqBaseConsumer {
} else if(EnumMsgRecordType.INSIDE_C_LOGIN.getCode().equals(baseMsg.getMsgType())) {
// 内部消息 - c端登录
FmInsideCLoginMsg msg = (FmInsideCLoginMsg)JsonUtil.readValue(message,FmInsideCLoginMsg.class);
fmInsideCouponVerifyMsgService.send(msg);
fmInsideCLoginMsgService.send(msg);
}
//else if(EnumMsgRecordType.INSIDE_NOTIFY_PAY_SUCCESS.getCode().equals(baseMsg.getMsgType())) {
// 内部消息 - 微信支付通知


+ 2
- 2
mallinkService/src/main/java/com/iformall/service/impl/WxCreditHistoryServiceImpl.java Просмотреть файл

@@ -227,7 +227,7 @@ public class WxCreditHistoryServiceImpl implements WxCreditHistoryService {
if (record.getCreditType().equals(EnumScoreType.CONSUMPTION.getCode()) || record.getCreditType().equals(EnumScoreType.SPEND_CREDIT.getCode())) {
//等级积分配置
try {
creditChangeNum = CreditUtil.calUserCredit(creditChangeNumOrigin, null, wxCUserBasicInfo, wxScoreRulesService,wxLevelConfigMapper);
creditChangeNum = CreditUtil.calUserCredit(creditChangeNumOrigin, wxCUserBasicInfo, wxScoreRulesService,wxLevelConfigMapper);
if (Objects.nonNull(CreditUtil.getIsBirthDayScale())) {
hasBirthDateCredit = true;
}
@@ -327,7 +327,7 @@ public class WxCreditHistoryServiceImpl implements WxCreditHistoryService {
credit = payAddCredit(wxCreditHistory);
if (Objects.nonNull(userId)) {
WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoMapper.selectById(userId);
creditNew = CreditUtil.calUserCredit(credit, null, wxCUserBasicInfo, wxScoreRulesService,wxLevelConfigMapper);
creditNew = CreditUtil.calUserCredit(credit, wxCUserBasicInfo, wxScoreRulesService,wxLevelConfigMapper);
} else {
creditNew = credit;
}


+ 4
- 21
mallinkService/src/main/java/com/iformall/utils/CreditUtil.java Просмотреть файл

@@ -19,33 +19,16 @@ public class CreditUtil {
* 计算用户积分
*
* @param creditOrigin 原始积分
* @param wxCUser C端用户信息
* @param wxCUserBasicInfo C端用户信息
* @param wxScoreRulesService
* @param wxLevelConfigMapper
* @return
*/
public static int calUserCredit(int creditOrigin, WxCUser wxCUser, WxCUserBasicInfo wxCUserBasicInfo, WxScoreRulesService wxScoreRulesService, WxLevelConfigMapper wxLevelConfigMapper) {
Long userId = null;
Integer score = null;
String tenantId = null;
public static int calUserCredit(int creditOrigin, WxCUserBasicInfo wxCUserBasicInfo, WxScoreRulesService wxScoreRulesService, WxLevelConfigMapper wxLevelConfigMapper) {
Long userId = wxCUserBasicInfo.getId();
Integer score = wxCUserBasicInfo.getPoins();
String tenantId = wxCUserBasicInfo.getFinalTenantId();
Integer levelScaleConfig = WxLevelConfig.DEFAULT_SCALE ;
if (Objects.nonNull(wxCUser)) {
userId = wxCUser.getId();
score = wxCUser.getScore();
tenantId = wxCUser.getTenantId();
}
if (Objects.isNull(userId)) {
userId = wxCUserBasicInfo.getId();
}

if (Objects.isNull(score)) {
score = wxCUserBasicInfo.getPoins();
}

if (StringUtils.isBlank(tenantId)) {
tenantId = wxCUserBasicInfo.getTenantId();
}
levelScaleConfig = wxLevelConfigMapper.getScale(tenantId, score) ;
// 获取等级积分倍率,
int levelScale = getLevelScale(score, levelScaleConfig);


+ 0
- 1
mallinkSysAdmin/src/main/java/com/iformall/controller/datafix/DataInitController.java Просмотреть файл

@@ -190,7 +190,6 @@ public class DataInitController extends BaseController {
log.debug(" : {}", ret.getId());
return;
}
// WxCUser cuUser = cUserMapper.selectById(co.getcUserId());
WxCUserBasicInfo userBasicInfo = cUserBasicInfoMapper.selectById(co.getcUserId());
//排查不存在的用户
if (Objects.isNull(userBasicInfo)) {


+ 1
- 104
mallinkWebSocketServer/src/main/java/com/iformall/controller/BaseController.java Просмотреть файл

@@ -1,21 +1,8 @@
package com.iformall.controller;

import cn.binarywang.wx.miniapp.api.WxMaService;
import com.iformall.common.ErrorCode;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.domain.po.WxAppinfo;
import com.iformall.domain.po.WxCUser;
import com.iformall.domain.po.WxCUserBasicInfo;
import com.iformall.exception.MallinkException;
import com.iformall.interceptor.AuthHandshakeInterceptor;
import com.iformall.service.WxAppinfoService;
import com.iformall.service.WxCUserBasicInfoService;
import com.iformall.service.WxCUserService;
import com.iformall.service.wechat.FmOpenService;
import com.iformall.utils.IPUtil;
import com.iformall.utils.MaUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RestController;
@@ -27,24 +14,9 @@ import java.beans.PropertyEditorSupport;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@RestController
public class BaseController {
@Autowired
private boolean isFmOpen;

@Autowired
private WxCUserService wxCUserService;

@Autowired
private WxAppinfoService wxAppinfoService;

@Autowired
private FmOpenService openService;

@Autowired
private WxCUserBasicInfoService wxCUserBasicInfoService;

@InitBinder
public void InitBinder(WebDataBinder dataBinder) {
@@ -69,20 +41,11 @@ public class BaseController {
}

public Long getUserId() {
ServletRequestAttributes ll = (ServletRequestAttributes)RequestContextHolder.getRequestAttributes();
HttpServletRequest request = ll.getRequest();
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
Long cUserId = (Long) request.getAttribute(AuthHandshakeInterceptor.LOGIN_USER_KEY);
return cUserId;
}

public WxCUser getUser() {
Long cUserId = getUserId();
WxCUser user = wxCUserService.getById(cUserId);
if (user == null)
throw new MallinkException(ErrorCode.USER_IS_EMPTY);
return user;
}

@Deprecated
public String getTenantId() {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
@@ -106,72 +69,6 @@ public class BaseController {
return tenantEntity;
}

public WxAppinfo getAppInfo(String appId) {
return wxAppinfoService.getByAppId(appId);
}

public WxMaService getWeappService(String appId) {
if(isFmOpen) {
return openService.getWxOpenComponentService().getWxMaServiceByAppid(appId);
} else {
WxAppinfo appinfo = wxAppinfoService.getByAppId(appId);
if (appinfo == null) {
return null;
}
WxMaService service = MaUtil.getWeappService(appinfo);
return service;
}
}

public WxMaService getWeappServiceByAppInfo(WxAppinfo appinfo) {
if(!isFmOpen) {
WxMaService service = MaUtil.getWeappService(appinfo);
return service;
}
return null;
}


public void saveToBasicInfo(WxCUser user) {
TenantEntity tenantEntity = getTenantInfo();
String phone = user.getPhone();
if (phone != null && phone.contains("*")) {
phone = user.getVerifyCodePhone();
}
if (StringUtils.isBlank(phone))
return;

List<WxCUserBasicInfo> list = wxCUserBasicInfoService.findByPhone(tenantEntity, phone);
if (list.size() > 0) {
WxCUserBasicInfo basicInfo = list.get(0);
// 微信名称
if (basicInfo.getNickName() == null || basicInfo.getNickName().equals(user.getNickName())) {
basicInfo.setNickName(user.getNickName());
}
// 性别
if (basicInfo.getSex() == null) {
basicInfo.setSex(user.getGender());
}
// 成长值
if (basicInfo.getPoins() == null) {
basicInfo.setPoins(user.getScore());
}
wxCUserBasicInfoService.updateObj(basicInfo, user);
} else {
Date cur = new Date();
WxCUserBasicInfo basicInfo = new WxCUserBasicInfo();
basicInfo.setId(user.getId());
basicInfo.updateTenantInfo(tenantEntity);
basicInfo.setPhone(phone);
basicInfo.setNickName(user.getNickName());
basicInfo.setSex(user.getGender());
basicInfo.setPoins(user.getScore());
basicInfo.setCreateDate(cur);
basicInfo.setUpdateDate(cur);
wxCUserBasicInfoService.save(basicInfo);
}
}

public String getIpAddr() {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String ipaddress = IPUtil.getIpAddr(request);


Загрузка…
Отмена
Сохранить