|
|
|
|
@ -1,25 +1,30 @@
|
|
|
|
|
package com.flossom.system.service.impl;
|
|
|
|
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Iterator;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
import com.flossom.common.core.constant.IntegralChangTextConstants;
|
|
|
|
|
import com.flossom.common.core.domain.entity.*;
|
|
|
|
|
import com.flossom.common.core.domain.req.WxUserIntegralVm;
|
|
|
|
|
import com.flossom.common.core.domain.req.WxUserMemberReq;
|
|
|
|
|
import com.flossom.common.core.domain.req.WxUserMemberVm;
|
|
|
|
|
import com.flossom.common.core.domain.ret.WxUserMemberRet;
|
|
|
|
|
import com.flossom.common.core.domain.shuyun.ShuYunPointChange;
|
|
|
|
|
import com.flossom.common.core.domain.vo.WxUserMemberVo;
|
|
|
|
|
import com.flossom.common.core.enums.BindingStatusEnums;
|
|
|
|
|
import com.flossom.common.core.enums.IntegralChangeTypeEnum;
|
|
|
|
|
import com.flossom.common.core.enums.Status;
|
|
|
|
|
import com.flossom.common.core.enums.TagTypeStatusEnum;
|
|
|
|
|
import com.flossom.common.core.enums.*;
|
|
|
|
|
import com.flossom.common.core.exception.ServiceException;
|
|
|
|
|
import com.flossom.common.core.mapper.*;
|
|
|
|
|
import com.flossom.common.core.utils.DateUtils;
|
|
|
|
|
import com.flossom.common.core.utils.StringUtils;
|
|
|
|
|
import com.flossom.common.core.utils.uuid.IdUtils;
|
|
|
|
|
import com.flossom.common.security.utils.SecurityUtils;
|
|
|
|
|
import com.flossom.system.service.ISysUserService;
|
|
|
|
|
import com.flossom.system.utils.shuyun.ShuYunApiUtils;
|
|
|
|
|
import com.flossom.system.utils.shuyun.ShuYunConfig;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@ -73,6 +78,9 @@ public class WxUserMemberServiceImpl implements IWxUserMemberService {
|
|
|
|
|
@Autowired
|
|
|
|
|
private WxInstrumentMapper wxInstrumentMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private ShuYunConfig shuYunConfig;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询用户
|
|
|
|
|
*
|
|
|
|
|
@ -371,7 +379,58 @@ public class WxUserMemberServiceImpl implements IWxUserMemberService {
|
|
|
|
|
changeUserMember.setUpdateBy(SecurityUtils.getUsername());
|
|
|
|
|
wxUserMemberMapper.updateWxUserMember(changeUserMember);
|
|
|
|
|
}
|
|
|
|
|
// TODO: 对接数赢:批量积分操作
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 增加/减少 积分
|
|
|
|
|
*
|
|
|
|
|
* @param wxUserIntegralVm
|
|
|
|
|
* @param userId
|
|
|
|
|
*/
|
|
|
|
|
@Transactional
|
|
|
|
|
@Override
|
|
|
|
|
public void changIntegral(WxUserIntegralVm wxUserIntegralVm, Long userId) {
|
|
|
|
|
// 1、记录积分操作日志
|
|
|
|
|
WxUserMember wxUserMember = wxUserMemberMapper.selectWxUserMemberById(userId);
|
|
|
|
|
if (wxUserMember != null) {
|
|
|
|
|
WxUserIntegralLog wxUserIntegralLog = new WxUserIntegralLog();
|
|
|
|
|
wxUserIntegralLog.setUserId(userId);
|
|
|
|
|
wxUserIntegralLog.setUserName(wxUserMember.getNickname());
|
|
|
|
|
wxUserIntegralLog.setUserPhone(wxUserMember.getMobile());
|
|
|
|
|
BeanUtils.copyProperties(wxUserIntegralVm, wxUserIntegralLog);
|
|
|
|
|
wxUserIntegralLog.setCreateTime(DateUtils.getNowDate());
|
|
|
|
|
wxUserIntegralLog.setCreateBy(SecurityUtils.getUsername());
|
|
|
|
|
wxUserIntegralLogMapper.insertWxUserIntegralLog(wxUserIntegralLog);
|
|
|
|
|
}
|
|
|
|
|
// 2、变更总积分
|
|
|
|
|
WxUserMember changeUserMember = new WxUserMember();
|
|
|
|
|
if (wxUserIntegralVm.getSource().equals(IntegralChangeTypeEnum.INCREASE.getCode())) {
|
|
|
|
|
changeUserMember.setCredit(wxUserMember.getCredit() + wxUserIntegralVm.getFloatScore().intValue());
|
|
|
|
|
} else if (wxUserIntegralVm.getSource().equals(IntegralChangeTypeEnum.REDUCE.getCode())) {
|
|
|
|
|
if (wxUserMember.getCredit() >= wxUserIntegralVm.getFloatScore().intValue()) {
|
|
|
|
|
changeUserMember.setCredit(wxUserMember.getCredit() - wxUserIntegralVm.getFloatScore().intValue());
|
|
|
|
|
} else {
|
|
|
|
|
changeUserMember.setCredit(0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
changeUserMember.setId(wxUserMember.getId());
|
|
|
|
|
changeUserMember.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
|
changeUserMember.setUpdateBy(SecurityUtils.getUsername());
|
|
|
|
|
wxUserMemberMapper.updateWxUserMember(changeUserMember);
|
|
|
|
|
/**
|
|
|
|
|
* TODO:批量积分操作,同步数云(已完成,未保存操作)
|
|
|
|
|
*/
|
|
|
|
|
Integer credit;
|
|
|
|
|
if (StringUtils.equals(IntegralChangeTypeEnum.INCREASE.getCode(), wxUserIntegralVm.getSource())) {
|
|
|
|
|
credit = wxUserIntegralVm.getFloatScore().intValue();
|
|
|
|
|
} else {
|
|
|
|
|
credit = -wxUserIntegralVm.getFloatScore().intValue();
|
|
|
|
|
}
|
|
|
|
|
ShuYunPointChange shuYunPointChange = new ShuYunPointChange(wxUserMember.getUnionid(), shuYunConfig.getPlatCode(), shuYunConfig.getShopId(),
|
|
|
|
|
IdUtils.generateSequence(), ShuYunPointSourceEnum.OTHER.getSource(), credit,
|
|
|
|
|
LocalDateTime.now().format(DateTimeFormatter.ofPattern(DateUtils.YYYY_MM_DD_HH_MM_SS)), IntegralChangTextConstants.DAILY_CLOCK);
|
|
|
|
|
ShuYunApiUtils.pointChange(shuYunPointChange);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@ -428,10 +487,10 @@ public class WxUserMemberServiceImpl implements IWxUserMemberService {
|
|
|
|
|
wxUserInstrument.setBindingStatus(BindingStatusEnums.BINDED.getCode());
|
|
|
|
|
wxUserInstrument.setStatus(Status.OK.getCode().longValue());
|
|
|
|
|
List<WxUserInstrument> userInstrumentList = wxUserInstrumentMapper.selectWxUserInstrumentList(wxUserInstrument);
|
|
|
|
|
if(userInstrumentList != null && userInstrumentList.size() > 0) {
|
|
|
|
|
if (userInstrumentList != null && userInstrumentList.size() > 0) {
|
|
|
|
|
userInstrumentList.forEach(ui -> {
|
|
|
|
|
WxInstrument wxInstrument = wxInstrumentMapper.selectWxInstrumentById(ui.getInstrumentId());
|
|
|
|
|
if(wxInstrument != null) {
|
|
|
|
|
if (wxInstrument != null) {
|
|
|
|
|
ui.setInstrumentName(wxInstrument.getName());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|