导粉统计,更新客户手机号时更新下微信用户对应的客户ID

This commit is contained in:
xiezhijun
2021-05-19 19:18:18 +08:00
parent 7cac34799c
commit 574c8b424e
18 changed files with 299 additions and 20 deletions

View File

@ -1,9 +1,13 @@
package com.stdiet.custom.domain;
import java.util.Date;
import java.util.List;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.stdiet.common.annotation.Excel;
import com.stdiet.common.core.domain.BaseEntity;
import lombok.Data;
/**
* 导粉管理对象 sys_import_fan_record
@ -11,6 +15,7 @@ import com.stdiet.common.core.domain.BaseEntity;
* @author xzj
* @date 2021-05-17
*/
@Data
public class SysImportFanRecord extends BaseEntity
{
private static final long serialVersionUID = 1L;
@ -33,4 +38,18 @@ public class SysImportFanRecord extends BaseEntity
/** 删除标识0未删除 1已删除 */
private Long delFlag;
//微信ID
private Long wxAccountId;
//进粉数量
private Long fanNum;
private String importFanChannelName;
private String liveRoomName;
private String liveNutritionistName;
private List<Map<String,Object>> wxAccountList;
}

View File

@ -58,4 +58,11 @@ public interface SysImportFanRecordMapper
* @return 结果
*/
public int deleteSysImportFanRecordByIds(Long[] ids);
/**
* 根据日期渠道、直播间获取进粉记录
* @param sysImportFanRecord
* @return
*/
public SysImportFanRecord getFanRecordByChannelLive(SysImportFanRecord sysImportFanRecord);
}

View File

@ -58,4 +58,11 @@ public interface SysImportFanWxAccountMapper
* @return 结果
*/
public int deleteSysImportFanWxAccountByIds(Long[] ids);
/**
* 根据导粉记录ID、微信ID查询对应微信记录
* @param sysImportFanWxAccount
* @return
*/
public SysImportFanWxAccount getWxAccountByFanRecordId(SysImportFanWxAccount sysImportFanWxAccount);
}

View File

@ -2,6 +2,7 @@ package com.stdiet.custom.mapper;
import java.util.List;
import com.stdiet.custom.domain.SysWxUserInfo;
import org.apache.ibatis.annotations.Param;
/**
* 微信用户Mapper接口
@ -62,4 +63,11 @@ public interface SysWxUserInfoMapper
* @return 结果
*/
public int deleteSysWxUserInfoByIds(String[] openids);
/**
* 根据手机号查询微信用户
* @param phone
* @return
*/
public SysWxUserInfo getSysWxUserInfoByPhone(@Param("phone")String phone);
}

View File

@ -58,4 +58,11 @@ public interface ISysImportFanWxAccountService
* @return 结果
*/
public int deleteSysImportFanWxAccountById(Long id);
/**
* 根据导粉记录ID、微信ID查询对应微信记录
* @param sysImportFanWxAccount
* @return
*/
public SysImportFanWxAccount getWxAccountByFanRecordId(SysImportFanWxAccount sysImportFanWxAccount);
}

View File

@ -63,5 +63,12 @@ public interface ISysWxUserInfoService
*/
public int deleteSysWxUserInfoById(String openid);
/**
* 根据手机号查询微信用户
* @param phone
* @return
*/
public SysWxUserInfo getSysWxUserInfoByPhone(String phone);
}

View File

@ -14,6 +14,7 @@ import com.stdiet.custom.domain.SysCustomer;
import com.stdiet.custom.domain.SysCustomerPhysicalSigns;
import com.stdiet.custom.dto.request.HealthyDetailRequest;
import com.stdiet.custom.dto.response.NutritionalCalories;
import com.stdiet.custom.mapper.SysCustomerMapper;
import com.stdiet.custom.service.ISysCustomerService;
import com.stdiet.custom.utils.NutritionalUtils;
import com.stdiet.custom.utils.PdfUtils;
@ -36,7 +37,7 @@ public class SysCustomerHealthyServiceImpl implements ISysCustomerHealthyService
private SysCustomerHealthyMapper sysCustomerHealthyMapper;
@Autowired
private ISysCustomerService sysCustomerService;
private SysCustomerMapper sysCustomerMapper;
public static final String reportDownFileNameFormat = "%s超重%s斤%s";
@ -78,7 +79,7 @@ public class SysCustomerHealthyServiceImpl implements ISysCustomerHealthyService
return AjaxResult.error("客户不存在");
}
//判断客户是否存在
SysCustomer sysCustomer = sysCustomerService.selectSysCustomerById(Long.parseLong(customerId));
SysCustomer sysCustomer = sysCustomerMapper.selectSysCustomerById(Long.parseLong(customerId));
if(sysCustomer == null){
return AjaxResult.error("客户不存在");
}

View File

@ -6,10 +6,14 @@ import com.stdiet.common.utils.sign.AesUtils;
import com.stdiet.custom.domain.SysCustomer;
import com.stdiet.custom.domain.SysCustomerHealthy;
import com.stdiet.custom.domain.SysCustomerPhysicalSigns;
import com.stdiet.custom.domain.SysWxUserInfo;
import com.stdiet.custom.mapper.SysCustomerMapper;
import com.stdiet.custom.mapper.SysCustomerPhysicalSignsMapper;
import com.stdiet.custom.mapper.SysWxUserInfoMapper;
import com.stdiet.custom.service.ISysCustomerService;
import com.stdiet.custom.service.ISysWxUserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -38,6 +42,9 @@ public class SysCustomerServiceImpl implements ISysCustomerService {
@Autowired
private SysCustomerPhysicalSignsServiceImpl sysCustomerPhysicalSignsService;
@Autowired
private ISysWxUserInfoService sysWxUserInfoService;
/**
* 查询客户信息
*
@ -69,7 +76,11 @@ public class SysCustomerServiceImpl implements ISysCustomerService {
@Override
public int insertSysCustomer(SysCustomer sysCustomer) {
sysCustomer.setCreateTime(DateUtils.getNowDate());
return sysCustomerMapper.insertSysCustomer(sysCustomer);
int row = sysCustomerMapper.insertSysCustomer(sysCustomer);
if(row > 0){
updateWxInfoMessage(sysCustomer);
}
return row;
}
/**
@ -81,7 +92,11 @@ public class SysCustomerServiceImpl implements ISysCustomerService {
@Override
public int updateSysCustomer(SysCustomer sysCustomer) {
sysCustomer.setUpdateTime(DateUtils.getNowDate());
return sysCustomerMapper.updateSysCustomer(sysCustomer);
int row = sysCustomerMapper.updateSysCustomer(sysCustomer);
if(row > 0){
updateWxInfoMessage(sysCustomer);
}
return row;
}
/**
@ -177,4 +192,17 @@ public class SysCustomerServiceImpl implements ISysCustomerService {
public SysCustomer getCustomerByOpenId(String openid){
return sysCustomerMapper.getCustomerByOpenId(openid);
}
@Async
public void updateWxInfoMessage(SysCustomer newCustomer){
if(newCustomer == null || newCustomer.getId() == null || StringUtils.isEmpty(newCustomer.getPhone())){
return;
}
//根据手机号查询微信用户记录
SysWxUserInfo wxUserInfo = sysWxUserInfoService.getSysWxUserInfoByPhone(newCustomer.getPhone());
if(wxUserInfo != null && (wxUserInfo.getCusId() == null || wxUserInfo.getCusId().longValue() != newCustomer.getId())){
wxUserInfo.setCusId(newCustomer.getId());
sysWxUserInfoService.updateSysWxUserInfo(wxUserInfo);
}
}
}

View File

@ -1,7 +1,10 @@
package com.stdiet.custom.service.impl;
import java.util.Date;
import java.util.List;
import com.stdiet.common.utils.DateUtils;
import com.stdiet.custom.domain.SysImportFanWxAccount;
import com.stdiet.custom.service.ISysImportFanWxAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.stdiet.custom.mapper.SysImportFanRecordMapper;
@ -20,6 +23,9 @@ public class SysImportFanRecordServiceImpl implements ISysImportFanRecordService
@Autowired
private SysImportFanRecordMapper sysImportFanRecordMapper;
@Autowired
private ISysImportFanWxAccountService sysImportFanWxAccountService;
/**
* 查询导粉管理
*
@ -54,7 +60,29 @@ public class SysImportFanRecordServiceImpl implements ISysImportFanRecordService
public int insertSysImportFanRecord(SysImportFanRecord sysImportFanRecord)
{
sysImportFanRecord.setCreateTime(DateUtils.getNowDate());
return sysImportFanRecordMapper.insertSysImportFanRecord(sysImportFanRecord);
//根据账号渠道、直播间判断是否已存在该渠道的导粉记录
SysImportFanRecord record = sysImportFanRecordMapper.getFanRecordByChannelLive(sysImportFanRecord);
int row = 0;
if(record == null){
row = sysImportFanRecordMapper.insertSysImportFanRecord(sysImportFanRecord);
}
if(record != null || row > 0){
//添加微信号对应记录
SysImportFanWxAccount sysImportFanWxAccount = new SysImportFanWxAccount();
sysImportFanWxAccount.setImportFanRecordId(record != null ? record.getId() : sysImportFanRecord.getId());
sysImportFanWxAccount.setImportWxAccountId(sysImportFanRecord.getWxAccountId());
sysImportFanWxAccount.setImportFanNum(sysImportFanRecord.getFanNum());
sysImportFanWxAccount.setCreateTime(new Date());
//根据微信号、导粉记录查询是否存在
SysImportFanWxAccount oldFanWxAccount = sysImportFanWxAccountService.getWxAccountByFanRecordId(sysImportFanWxAccount);
if(oldFanWxAccount == null){
row = sysImportFanWxAccountService.insertSysImportFanWxAccount(sysImportFanWxAccount);
}else{
oldFanWxAccount.setImportFanNum((oldFanWxAccount.getImportFanNum() == null ? 0 : oldFanWxAccount.getImportFanNum()) + sysImportFanWxAccount.getImportFanNum());
row = sysImportFanWxAccountService.updateSysImportFanWxAccount(oldFanWxAccount);
}
}
return row;
}
/**

View File

@ -93,4 +93,13 @@ public class SysImportFanWxAccountServiceImpl implements ISysImportFanWxAccountS
{
return sysImportFanWxAccountMapper.deleteSysImportFanWxAccountById(id);
}
/**
* 根据导粉记录ID、微信ID查询对应微信记录
* @param sysImportFanWxAccount
* @return
*/
public SysImportFanWxAccount getWxAccountByFanRecordId(SysImportFanWxAccount sysImportFanWxAccount){
return sysImportFanWxAccountMapper.getWxAccountByFanRecordId(sysImportFanWxAccount);
}
}

View File

@ -97,4 +97,13 @@ public class SysWxUserInfoServiceImpl implements ISysWxUserInfoService {
public int deleteSysWxUserInfoById(String openid) {
return sysWxUserInfoMapper.deleteSysWxUserInfoById(openid);
}
/**
* 根据手机号查询微信用户
* @param phone
* @return
*/
public SysWxUserInfo getSysWxUserInfoByPhone(String phone){
return sysWxUserInfoMapper.getSysWxUserInfoByPhone(phone);
}
}