Browse Source

Merge tag 'jenkins-back-end-3120' into release

develop
release_toaliyun_real
Burce 6 years ago
parent
commit
db6d72d60e
24 changed files with 393 additions and 70 deletions
  1. +7
    -1
      mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestCustomerController.java
  2. +3
    -0
      mallinkAdmin/src/main/resources/db/migration/V201910231900__W_INVEST_CREATE.sql
  3. +121
    -18
      mallinkSchedule/src/main/java/com/iformall/schedule/InvestSchedule.java
  4. +0
    -3
      mallinkService/src/main/java/com/iformall/domain/po/invest/InvestCustomerEntity.java
  5. +21
    -1
      mallinkService/src/main/java/com/iformall/domain/po/invest/InvestRemindEntity.java
  6. +3
    -3
      mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestDemandQuery.java
  7. +0
    -8
      mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestRemindVo.java
  8. +40
    -0
      mallinkService/src/main/java/com/iformall/enums/EnumInvestRemindStatus.java
  9. +2
    -0
      mallinkService/src/main/java/com/iformall/enums/EnumMsgModel.java
  10. +4
    -0
      mallinkService/src/main/java/com/iformall/enums/EnumMsgModelReplace.java
  11. +1
    -1
      mallinkService/src/main/java/com/iformall/enums/EnumNegotiationType.java
  12. +3
    -3
      mallinkService/src/main/java/com/iformall/service/impl/WxBillAllServiceImpl.java
  13. +4
    -0
      mallinkService/src/main/java/com/iformall/service/invest/InvestBizService.java
  14. +4
    -2
      mallinkService/src/main/java/com/iformall/service/invest/InvestRemindService.java
  15. +112
    -19
      mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBizServiceImpl.java
  16. +1
    -0
      mallinkService/src/main/java/com/iformall/service/invest/impl/InvestCustomerServiceImpl.java
  17. +4
    -3
      mallinkService/src/main/java/com/iformall/service/invest/impl/InvestDemandServiceImpl.java
  18. +1
    -1
      mallinkService/src/main/java/com/iformall/service/invest/impl/InvestFollowRecordServiceImpl.java
  19. +1
    -1
      mallinkService/src/main/java/com/iformall/service/invest/impl/InvestMessageServiceImpl.java
  20. +23
    -0
      mallinkService/src/main/java/com/iformall/service/invest/impl/InvestRemindServiceImpl.java
  21. +4
    -5
      mallinkService/src/main/resources/mapper/InvestCustomerMapper.xml
  22. +3
    -0
      mallinkService/src/main/resources/mapper/InvestRemindMapper.xml
  23. +1
    -1
      mallinkService/src/main/resources/mapper/WxBillAllMapper.xml
  24. +30
    -0
      mallinkSysAdmin/src/main/java/com/iformall/controller/sys/DataInitController.java

+ 7
- 1
mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestCustomerController.java View File

@@ -95,7 +95,7 @@ public class InvestCustomerController extends InvestBaseController{

@ApiOperation("导出客户信息模板")
@GetMapping("/exportCustomerTemplate")
@SystemControllerLog(description = "招商管理-导出客户信息模板")
@SystemControllerLog(description = "导出客户信息模板")
public void exportCustomerTemplate(HttpServletResponse response) {
exportData(null, response, (p, u) -> investBizService.exportCustomerTemplate(u));
}
@@ -107,4 +107,10 @@ public class InvestCustomerController extends InvestBaseController{
return importData(file, p -> investBizService.importCustomer(p));
}

@GetMapping("/queryTemplateCount")
@SystemControllerLog(description = "查询导入数据")
public InvestResultData queryTemplateCount() {
return execute(null, p -> investBizService.queryCustomerImportCount());
}

}

+ 3
- 0
mallinkAdmin/src/main/resources/db/migration/V201910231900__W_INVEST_CREATE.sql View File

@@ -56,6 +56,9 @@ CREATE TABLE `invest_remind` (
`minute` BIGINT(6) NOT NULL COMMENT '提醒时间',
`begin_date` DATETIME NOT NULL COMMENT '开始时间',
`end_date` DATETIME NOT NULL COMMENT '结束时间',
`customer_id` BIGINT(20) NOT NULL DEFAULT '0' COMMENT '客户ID',
`negotiation_type` TINYINT(6) NOT NULL DEFAULT '0' COMMENT '拜访方式:0-拜访;1-来访;2-电话;3-短信、微信或其它',
`status` TINYINT(6) NOT NULL DEFAULT '0' COMMENT '是否提醒:0-未提醒;1-已提醒',
`create_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (`id`),


+ 121
- 18
mallinkSchedule/src/main/java/com/iformall/schedule/InvestSchedule.java View File

@@ -3,9 +3,15 @@ package com.iformall.schedule;
import com.alibaba.fastjson.JSONArray;
import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.Multimaps;
import com.iformall.domain.po.MallUserInfo;
import com.iformall.domain.po.WxMall;
import com.iformall.domain.po.invest.*;
import com.iformall.domain.po.msg.WxMsgRecord;
import com.iformall.domain.vo.invest.InvestCustomerVo;
import com.iformall.enums.*;
import com.iformall.mapper.WxMallMapper;
import com.iformall.mq.MqBaseProducer;
import com.iformall.service.MallUserInfoService;
import com.iformall.service.invest.*;
import com.iformall.utils.DateUtils;
import lombok.extern.slf4j.Slf4j;
@@ -16,6 +22,7 @@ import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.*;


@@ -36,22 +43,85 @@ public class InvestSchedule {
InvestCustomerService customerService;
@Autowired
InvestFollowRecordService followRecordService;
@Autowired
InvestRemindService remindService;
@Resource
WxMallMapper mallMapper;
@Autowired
MallUserInfoService userInfoService;
@Autowired
private MqBaseProducer mqBaseProducer;

@Autowired
Environment environment;

private static final String PREFIX = "招商定时任务";
private static final String TAG_MESSAGE = "招商定时任务-消息";
private static final String TAG_REMIND = "招商定时任务-提醒";


//@Scheduled(cron = "0 0 14 * * ?") // 每天下午两点执行定时任务
@Scheduled(cron = "0 */30 * * * *?") // 测试,每5分钟执行
@Scheduled(cron = "0 */30 * * * *?") // 测试,每30分钟执行
public void messageSchedule() {
log.info("{}: 开始", PREFIX);
log.info("{}: 开始", TAG_MESSAGE);
//一个月内未完成提醒
taskMonthMessage();
//一周内未跟踪提醒
demandWeekMessage();
log.info("{}: 结束", PREFIX);
log.info("{}: 结束", TAG_MESSAGE);
}

@Scheduled(cron = "0 */5 * * * *?")
public void remindSchedule() {
log.info("{}: 开始", TAG_REMIND);
// 提醒新
List<InvestRemindEntity> reminds = remindService.findUnRemindList();
log.info("{}:提醒数 :{}", TAG_REMIND, reminds.size());
if (CollectionUtils.isEmpty(reminds)) {
return;
}

// mall 信息
List<WxMall> mallList = mallMapper.findList(new WxMall());
if (mallList.size() == 0) {
log.info("{}: No Mall info found", TAG_REMIND);
return;
}
Map<String, WxMall> mallMap = InvestHelper.getMap(mallList, WxMall::getTenantId);
// 用户信息
List<MallUserInfo> userList = userInfoService.findList(new MallUserInfo());
if (userList.size() == 0) {
log.info("{}: No user info found", TAG_REMIND);
return;
}
Map<Long, MallUserInfo> userMap = InvestHelper.getMap(userList, MallUserInfo::getId);

Collection<InvestCustomerEntity> customs = customerService.listByIds(InvestHelper.getIds(reminds, InvestRemindEntity::getCustomerId));
Map<Long, InvestCustomerEntity> customerMap = InvestHelper.getMap(customs, InvestCustomerEntity::getId);

Calendar now = Calendar.getInstance();
for (InvestRemindEntity remind : reminds) {
if (Objects.equals(remind.getMinute(), 0L)) {
log.warn("{}:remindID:{} 不提醒, 跳过", TAG_REMIND, remind.getId());
continue;
}

Calendar begin = Calendar.getInstance();
begin.setTime(remind.getBeginDate());
if (getRemindMinute(now, begin) > remind.getMinute()) {
boolean sended = sendSMS(userMap.get(remind.getOwner()), mallMap.get(remind.getTenantId()), remind, customerMap.get(remind.getCustomerId()));
if (sended) {
remind.setStatus(EnumInvestRemindStatus.REMINDED);
remindService.updateById(remind);
}
}
}
log.info("{}: 结束", TAG_REMIND);
}

private long getRemindMinute(Calendar c1, Calendar c2) {
long beginTime = c1.getTime().getTime();
long endTime = c2.getTime().getTime();
return (endTime - beginTime) / (1000 * 60);
}

private void taskMonthMessage() {
@@ -69,14 +139,14 @@ public class InvestSchedule {
}
//查询满足条件
List<InvestTaskEntity> tasks = taskService.listByStatusAndTime(Arrays.asList(EnumTaskStatus.INTENTION, EnumTaskStatus.NEGOTIATING), start.getTime(), end.getTime());
log.info("{}:{} - {} 的任务数 :{}", PREFIX, start, end, tasks.size());
log.info("{}:{} - {} 的任务数 :{}", TAG_MESSAGE, start, end, tasks.size());
if (tasks.isEmpty()) {
return;
}
for (InvestTaskEntity task : tasks) {
String owner = task.getOwner();
if (StringUtils.isEmpty(owner)) {
log.warn("{}:taskID:{} owner不存在:{}, 跳过", PREFIX, task.getId(), task.getOwner());
log.warn("{}:taskID:{} owner不存在:{}, 跳过", TAG_MESSAGE, task.getId(), task.getOwner());
continue;
}
List<Long> ownerArray = JSONArray.parseArray(owner, Long.class);
@@ -85,7 +155,7 @@ public class InvestSchedule {
if (CollectionUtils.isNotEmpty(messageList)) {
for (InvestMessageEntity messageEntity : messageList) {
if (messageEntity.getTid().equals(task.getId())) {
log.info("{}:taskID:{} 提醒已存在:{}, 跳过", PREFIX, task.getId(), messageEntity.getId());
log.info("{}:taskID:{} 提醒已存在:{}, 跳过", TAG_MESSAGE, task.getId(), messageEntity.getId());
continue;
}
addTaskMessage(task, ownerArray);
@@ -100,7 +170,7 @@ public class InvestSchedule {
private void addTaskMessage(InvestTaskEntity task, List<Long> ownerArray) {
String message = String.format(EnumInvestMessageType.TASK_REMIND.getInfo(), task.getId(), DateUtils.format(task.getLastTime()));
messageService.saveBatchMessage(ownerArray, message, EnumInvestMessageTag.TASK_MONTH, EnumFollowType.TASK, task.getId(),task.getTenantId());
log.info("{}:taskID:{} 为用户{}创建消息提醒", PREFIX, task.getId(), task.getOwner());
log.info("{}:taskID:{} 为用户{}创建消息提醒", TAG_MESSAGE, task.getId(), task.getOwner());
}

private void demandWeekMessage() {
@@ -111,9 +181,9 @@ public class InvestSchedule {
//初始化时间条件
Calendar start = Calendar.getInstance();
if (environment.acceptsProfiles(ENV_STR)) {
start.add(Calendar.DAY_OF_YEAR, 1); //测试
start.add(Calendar.DAY_OF_YEAR, -1); //测试
} else {
start.add(Calendar.DAY_OF_YEAR, 7);
start.add(Calendar.DAY_OF_YEAR, -7);
}

//查询跟踪列表
@@ -122,14 +192,12 @@ public class InvestSchedule {
List<InvestCustomerVo> demands = customerService.listByIds(InvestHelper.getIds(follows, InvestFollowRecordEntity::getFollowId),
Arrays.asList(EnumCustomerType.INTENTIONAL, EnumCustomerType.POTENTIAL));

/**
* 已经已经提醒过的用户
*/
// 已经提醒过的用户
List<String> userDemandFlag = new ArrayList<>();
for (InvestCustomerVo customerVo : demands) {
Long owner = customerVo.getDemandOwner();
if (Objects.isNull(owner)) {
log.warn("{}:customerID:{} owner不存在:{}, 跳过", PREFIX, customerVo.getId(), customerVo.getDemandOwner());
log.warn("{}:customerID:{} owner不存在:{}, 跳过", TAG_MESSAGE, customerVo.getId(), customerVo.getDemandOwner());
continue;
}
List<InvestMessageEntity> messageList = demandMessageUserIdMap.get(owner);
@@ -138,13 +206,13 @@ public class InvestSchedule {
}
for (InvestMessageEntity messageEntity : messageList) {
if (messageEntity.getTid().equals(messageEntity.getId())) {
log.info("{}:taskID:{} 提醒已存在:{}, 跳过", PREFIX, customerVo.getId(), messageEntity.getId());
log.info("{}:taskID:{} 提醒已存在:{}, 跳过", TAG_MESSAGE, customerVo.getId(), messageEntity.getId());
continue;
}
String userDemandFlagItem = StringUtils.join(messageEntity.getOwner(), messageEntity.getId());
//已经提醒过的用户不在提醒
if (userDemandFlag.contains(userDemandFlagItem)) {
log.info("{}:taskID:{} 提醒已存在:{}, 跳过", PREFIX, customerVo.getId(), userDemandFlagItem);
log.info("{}:taskID:{} 提醒已存在:{}, 跳过", TAG_MESSAGE, customerVo.getId(), userDemandFlagItem);
continue;
}
addCustomerMessage(customerVo, owner);
@@ -155,7 +223,42 @@ public class InvestSchedule {

private void addCustomerMessage(InvestCustomerVo customerVo, Long owner) {
String message = String.format(EnumInvestMessageType.COSTOMER_REMIND.getInfo(), customerVo.getId());
messageService.saveBatchMessage(Arrays.asList(owner), message, EnumInvestMessageTag.CUSTOMER_WEEK, EnumFollowType.DEMAND, customerVo.getId(),customerVo.getTenantId());
log.info("{}:customerID:{} 为用户{}创建消息提醒", PREFIX, customerVo.getId(), customerVo.getDemandOwner());
messageService.saveBatchMessage(Collections.singletonList(owner), message, EnumInvestMessageTag.CUSTOMER_WEEK, EnumFollowType.DEMAND, customerVo.getId(), customerVo.getTenantId());
log.info("{}:customerID:{} 为用户{}创建消息提醒", TAG_MESSAGE, customerVo.getId(), customerVo.getDemandOwner());
}

private boolean sendSMS(MallUserInfo userInfo, WxMall mall, InvestRemindEntity remind, InvestCustomerEntity customer) {
if (Objects.isNull(userInfo) || Objects.isNull(mall) || Objects.isNull(customer)) {
log.warn("{}: 参数为空 : userInfo: {}, mall: {} ,customer:{}", TAG_REMIND, userInfo, mall, customer);
return false;
}
WxMsgRecord wxMsgRecord = new WxMsgRecord();
wxMsgRecord.setMsgType(EnumMsgRecordType.SMS.getCode());
wxMsgRecord.setReceiver(userInfo.getPhone());
wxMsgRecord.setTenantId(mall.getTenantId());
Map<String, String> dynamicContentMap = new HashMap<>();
wxMsgRecord.setModelType(EnumMsgModel.INVEST_REMIND.getCode());
dynamicContentMap.put("mallName", mall.getName());
dynamicContentMap.put("beginDate", DateUtils.formatDateTime(remind.getBeginDate()));
dynamicContentMap.put("negotiationType", convet(remind.getNegotiationType()));
dynamicContentMap.put("customerName", customer.getName());
wxMsgRecord.setDynamicContentMap(dynamicContentMap);
mqBaseProducer.sendMessage(wxMsgRecord, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode());
return true;
}

private String convet(EnumNegotiationType type) {
String message = "";
if (Objects.equals(type, EnumNegotiationType.TO_VISIT)) {
message = "预约拜访";
} else if (Objects.equals(type, EnumNegotiationType.COME_VISIT)) {
message = "需接待来访";
} else if (Objects.equals(type, EnumNegotiationType.TELEPHONE)) {
message = "需电话联系";
} else if (Objects.equals(type, EnumNegotiationType.MESSAGE)) {
message = "需短信、微信或其他方式联系";
}

return message;
}
}

+ 0
- 3
mallinkService/src/main/java/com/iformall/domain/po/invest/InvestCustomerEntity.java View File

@@ -1,8 +1,6 @@
package com.iformall.domain.po.invest;

import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;


@@ -11,7 +9,6 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.iformall.common.LogColumn;
import com.iformall.enums.EnumCustomerRatingType;
import com.iformall.enums.EnumCustomerType;
import com.iformall.enums.EnumInvestChannel;
import lombok.Data;
import lombok.EqualsAndHashCode;



+ 21
- 1
mallinkService/src/main/java/com/iformall/domain/po/invest/InvestRemindEntity.java View File

@@ -1,10 +1,13 @@
package com.iformall.domain.po.invest;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;

import java.util.Date;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.iformall.enums.EnumInvestRemindStatus;
import com.iformall.enums.EnumNegotiationType;
import lombok.Data;
import lombok.EqualsAndHashCode;

@@ -57,4 +60,21 @@ public class InvestRemindEntity extends InvestBaseEntity {
*/
@io.swagger.annotations.ApiModelProperty(value = "结束时间", name = "endDate" ,example = "2018-10-01")
private Date endDate;

/**
* 是否提醒:0-未提醒;1-已提醒
*/
//@io.swagger.annotations.ApiModelProperty(value = "结束时间", name = "status")
@JsonIgnore
@TableField(value = "`status`")
private EnumInvestRemindStatus status;

/**
* 提醒用户InvestRemindEntity
*/
@io.swagger.annotations.ApiModelProperty(value = "customerId", name = "customerId")
private Long customerId;

@io.swagger.annotations.ApiModelProperty(value = "拜访方式:0-拜访;1-来访;2-电话;3-短信、微信或其它", name = "negotiationType")
private EnumNegotiationType negotiationType;
}

+ 3
- 3
mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestDemandQuery.java View File

@@ -9,10 +9,10 @@ import lombok.EqualsAndHashCode;
public class InvestDemandQuery extends InvestPageQuery {

/**
* 客户
* 客户手机
*/
@io.swagger.annotations.ApiModelProperty(value = "客户编号", name = "customerNo")
private String customerNo;
@io.swagger.annotations.ApiModelProperty(value = "客户手机号", name = "phone")
private String phone;

/**
* 客户分类:0-潜在客户;1-意向客户;2-合作客户;3-谈判失败


+ 0
- 8
mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestRemindVo.java View File

@@ -15,18 +15,10 @@ public class InvestRemindVo extends InvestRemindEntity {
@io.swagger.annotations.ApiModelProperty(value = "ownerInfo", name = "ownerInfo")
private MallUserInfo ownerInfo;

/**
* 提醒用户InvestRemindEntity
*/
@io.swagger.annotations.ApiModelProperty(value = "customerId", name = "customerId")
private Long customerId;

@io.swagger.annotations.ApiModelProperty(value = "customer", name = "customer")
private InvestCustomerEntity customer;

@io.swagger.annotations.ApiModelProperty(value = "brand", name = "brand")
private WxBrand brand;

@io.swagger.annotations.ApiModelProperty(value = "拜访方式:0-拜访;1-来访;2-电话;3-短信、微信或其它", name = "negotiationType")
private EnumNegotiationType negotiationType;
}

+ 40
- 0
mallinkService/src/main/java/com/iformall/enums/EnumInvestRemindStatus.java View File

@@ -0,0 +1,40 @@
package com.iformall.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;

/**
* 是否提醒:0-未提醒;1-已提醒
*/
public enum EnumInvestRemindStatus {
UN_REMINDED(0, "未提醒"),
REMINDED(1, "已提醒"),
;

public static EnumInvestRemindStatus getEnum(Integer code) {
for (EnumInvestRemindStatus value : values()) {
if (value.getCode().equals(code)) {
return value;
}
}
return null;
}

@EnumValue
private final Integer code;
private final String info;

EnumInvestRemindStatus(Integer code, String info) {
this.code = code;
this.info = info;
}

@JsonValue
public Integer getCode() {
return code;
}

public String getInfo() {
return info;
}
}

+ 2
- 0
mallinkService/src/main/java/com/iformall/enums/EnumMsgModel.java View File

@@ -36,6 +36,8 @@ public enum EnumMsgModel {
COUPON_BIRTHDAY_OPENED_NO(29, "会员生日券倍率未开启"),

COUPON_CARD_SEND(30, "系统发卡"),

INVEST_REMIND(31, "招商预约提醒"),
;

public static EnumMsgModel getEnum(Integer code) {


+ 4
- 0
mallinkService/src/main/java/com/iformall/enums/EnumMsgModelReplace.java View File

@@ -22,6 +22,10 @@ public enum EnumMsgModelReplace {
R14("{page}", "【管理端】"),
R15("{bustype}", "【任务类型】"),
R16("{contract}", "【合同编号】"),
R17("{mallName}", "【商户名称】"),
R18("{beginDate}", "【开始时间】"),
R19("{negotiationType}", "【洽谈方式】"),
R20("{customerName}", "【客户负责人】"),
;

public static EnumMsgModelReplace getEnum(Integer code) {


+ 1
- 1
mallinkService/src/main/java/com/iformall/enums/EnumNegotiationType.java View File

@@ -22,8 +22,8 @@ public enum EnumNegotiationType {
return null;
}

private final Integer code;
@EnumValue
private final Integer code;
private final String info;

EnumNegotiationType(Integer code, String info) {


+ 3
- 3
mallinkService/src/main/java/com/iformall/service/impl/WxBillAllServiceImpl.java View File

@@ -1292,15 +1292,15 @@ public class WxBillAllServiceImpl implements WxBillAllService {
JSONArray priceDetals = new JSONArray();
JSONObject priceDetal = new JSONObject();
priceDetal.put("key", "price");
priceDetal.put("value", 0);
priceDetal.put("value", 1);
priceDetals.add(priceDetal);
priceDetal = new JSONObject();
priceDetal.put("key", "way");
priceDetal.put("value", 0);
priceDetal.put("value", 1);
priceDetals.add(priceDetal);
priceDetal = new JSONObject();
priceDetal.put("key", "unit");
priceDetal.put("value", 0);
priceDetal.put("value", 1);
priceDetals.add(priceDetal);
daily.setPriceDetail(JSONArray.toJSONString(priceDetals));
wxBillDailyMapper.insert(daily);


+ 4
- 0
mallinkService/src/main/java/com/iformall/service/invest/InvestBizService.java View File

@@ -23,6 +23,8 @@ public interface InvestBizService {

void importCustomer(@RequestParam("file") MultipartFile mFile);

Map queryCustomerImportCount() ;

List<InvestDemandVo> queryCustomer();

InvestPageResult<InvestTaskVo> queryPageTask(InvestTaskQuery params);
@@ -61,4 +63,6 @@ public interface InvestBizService {

InvestFollowRecordVo findFollowRecordById(Long id) ;

Map<String, Object> statistics();

}

+ 4
- 2
mallinkService/src/main/java/com/iformall/service/invest/InvestRemindService.java View File

@@ -2,8 +2,8 @@ package com.iformall.service.invest;

import com.baomidou.mybatisplus.extension.service.IService;
import com.iformall.domain.po.invest.InvestRemindEntity;
import com.iformall.domain.vo.invest.InvestPageQuery;
import com.iformall.domain.vo.invest.InvestPageResult;
import java.util.List;

/**
* 招商提醒
@@ -17,5 +17,7 @@ public interface InvestRemindService extends IService<InvestRemindEntity>,Invest
//InvestPageResult<InvestRemindEntity> queryPage(InvestPageQuery<InvestRemindEntity> params);

boolean removeAll() ;

List<InvestRemindEntity> findUnRemindList();
}


+ 112
- 19
mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBizServiceImpl.java View File

@@ -38,7 +38,6 @@ import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.time.temporal.TemporalAmount;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
@@ -90,7 +89,7 @@ public class InvestBizServiceImpl implements InvestBizService {
}
List<InvestDemandEntity> demandList = demandService.list(new LambdaQueryWrapper<>(demandParams));
LambdaQueryWrapper<InvestCustomerEntity> queryWrapperCustomer = new LambdaQueryWrapper<>(customerParams);
queryWrapperCustomer.like(StringUtils.isNotBlank(params.getCustomerNo()), InvestCustomerEntity::getCustomerNo, params.getCustomerNo());
queryWrapperCustomer.like(StringUtils.isNotBlank(params.getPhone()), InvestCustomerEntity::getPhone, params.getPhone());

if (Objects.isNull(InvestUserContext.getDataUser())) {
if (CollectionUtils.isEmpty(demandList) && Objects.nonNull(params.getDemandOwner())) {
@@ -227,10 +226,44 @@ public class InvestBizServiceImpl implements InvestBizService {
}
}

doImport(lFile, tenantId, importKey);
doImport(lFile, importKey);
}

private void doImport(File file, String tenantId, String importKey) {
@Override
public Map queryCustomerImportCount() {
String importKey = Constant.importInvestCustomerPrev + InvestUserContext.getUserId();
Map<Object, Object> entries = stringRedisTemplate.opsForHash().entries(importKey);
log.info(JSONArray.toJSONString(entries) + ">>>>>>>>>>>>>>>>>>>>>1");
if (entries.size() < 4) {
entries.clear();
return entries;
}
String allCount = entries.get("allCount").toString();
String allSuccessCount = entries.get("allSuccessCount").toString();
String processCount = entries.get("processCount").toString();
String failCount = entries.get("failCount").toString();

if (StringUtils.isNotBlank(failCount) && allCount.equals(failCount)) {//stringRedisTemplate.expire(userId,1,TimeUnit.SECONDS);
log.info(JSONArray.toJSONString(entries) + ">>>>>>>>>>>>>>>>>>>>>2");
//完全失败
stringRedisTemplate.opsForHash().delete(importKey, "allCount");
stringRedisTemplate.opsForHash().delete(importKey, "allSuccessCount");
stringRedisTemplate.opsForHash().delete(importKey, "processCount");
stringRedisTemplate.opsForHash().delete(importKey, "failCount");
throw new MallinkException(ErrorCode.MEM_IMPORT_ERR);
}
//导入完成
if (StringUtils.isNotBlank(allSuccessCount) && allSuccessCount.equals(processCount)) {
stringRedisTemplate.opsForHash().delete(importKey, "allCount");
stringRedisTemplate.opsForHash().delete(importKey, "allSuccessCount");
stringRedisTemplate.opsForHash().delete(importKey, "processCount");
stringRedisTemplate.opsForHash().delete(importKey, "failCount");
return entries;
}
return entries;
}

private void doImport(File file, String importKey) {
ImportParams params = new ImportParams();
// 需要验证
params.setImportFields(new String[]{"品牌*", "品牌负责人*", "负责人电话*", "经营业态*", "意向铺位*", "意向租凭面积", "预计开业时间"});
@@ -335,7 +368,7 @@ public class InvestBizServiceImpl implements InvestBizService {
log.error("经营业态为空", customer.toString());
return;
}
InvestDemandDto toImportCustomer = convetCustomer(customer, brandMap, businesseMap, shopMap, customerMap.get(customer.getPhone()), demandMap);
InvestDemandDto toImportCustomer = convetCustomer(importKey, customer, brandMap, businesseMap, shopMap, customerMap.get(customer.getPhone()), demandMap);
if (toImportCustomer == null) {
stringRedisTemplate.opsForHash().increment(importKey, "processCount", 1);
log.error("customerBase null");
@@ -347,13 +380,14 @@ public class InvestBizServiceImpl implements InvestBizService {
toImportCustomer.getCustomer().setId(customerMap.get(customer.getPhone()).getId());
updateCustomerAndDemand(toImportCustomer);
}
//记数
stringRedisTemplate.opsForHash().increment(importKey,"processCount",1);
stringRedisTemplate.expire(importKey,10, TimeUnit.SECONDS);
});
} catch (Exception e) {
setRedisValue(importKey, "1", "0", "0", "1", true);
log.error("导入模板失败", e);
throw new MallinkException(ErrorCode.MEM_IMPORT_ERR.getCode(), "导入模板失败");
} finally {
stringRedisTemplate.expire(importKey, 3, TimeUnit.SECONDS);
}
}

@@ -367,7 +401,7 @@ public class InvestBizServiceImpl implements InvestBizService {
return getMap(brands, WxBrand::getName);
}

private InvestDemandDto convetCustomer(InvestCustomerVo importCustomerVo, Map<String, WxBrand> brandMap, Map<String, WxBusiness> businesseMap, Map<String, WxShop> shopMap, InvestCustomerEntity dbCustomer, Map<Long, InvestDemandEntity> demandMap) {
private InvestDemandDto convetCustomer(String importKey, InvestCustomerVo importCustomerVo, Map<String, WxBrand> brandMap, Map<String, WxBusiness> businesseMap, Map<String, WxShop> shopMap, InvestCustomerEntity dbCustomer, Map<Long, InvestDemandEntity> demandMap) {
InvestCustomerEntity customerEntity = null;
InvestDemandEntity demandEntity = null;
if (Objects.isNull(dbCustomer)) {
@@ -380,16 +414,19 @@ public class InvestBizServiceImpl implements InvestBizService {
demandEntity = new InvestDemandEntity();
}
if (Objects.isNull(brandMap.get(importCustomerVo.getBrandName()))) {
log.warn("品牌:{} 不存在", importCustomerVo.getBrandName());
return null;
}
customerEntity.setBrandId(brandMap.get(importCustomerVo.getBrandName()).getId());

if (Objects.isNull(businesseMap.get(importCustomerVo.getBusiness()))) {
log.warn("业态:{} 不存在", importCustomerVo.getBusiness());
return null;
}
customerEntity.setBusinessId(businesseMap.get(importCustomerVo.getBusiness()).getId());

if (Objects.isNull(shopMap.get(importCustomerVo.getShopNumber()))) {
log.warn("意向铺位:{} 不存在", importCustomerVo.getShopNumber());
return null;
}
customerEntity.setName(importCustomerVo.getName());
@@ -620,7 +657,7 @@ public class InvestBizServiceImpl implements InvestBizService {
LambdaQueryWrapper<InvestRemindEntity> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(InvestRemindEntity::getTenantId,InvestUserContext.getUser().getTenantId());
queryWrapper.apply(Objects.nonNull(params.getRemindDate()),
"date_format(begin_date,'%Y-%m-%d') >= {0} AND date_format(end_date,'%Y-%m-%d') <= {1}"
"date_format(begin_date,'%Y-%m-%d') >= {0} AND date_format(end_date,'%Y-%m-%d') < {1}"
, getDayStart(params.getRemindDate())
, getDayEnd(params.getRemindDate()));
queryWrapper.orderByDesc(InvestRemindEntity::getCreateDate);
@@ -888,6 +925,10 @@ public class InvestBizServiceImpl implements InvestBizService {
List<WxBusiness> businesses = businessService.listAsPage(null, 1, Integer.MAX_VALUE).getList();
Map<Integer, WxBusiness> businesseMap = getMap(businesses, WxBusiness::getId);

//业态信息
List<WxShop> shopList = shopService.listAsPage(null, 1, Integer.MAX_VALUE).getList();
Map<Long, WxShop> shopMap = getMap(shopList, WxShop::getId);

List<InvestOperateRecordVo> resultList = new ArrayList<>();
for (InvestOperateRecordEntity recordEntity : recordList) {
InvestOperateRecordVo itemVo = new InvestOperateRecordVo();
@@ -926,6 +967,15 @@ public class InvestBizServiceImpl implements InvestBizService {
if (Objects.nonNull(userAfter)) {
tableTriple.setAfter(userAfter.getName());
}
} else if (Objects.equals(column, "targetId")) {
WxShop shopBefore = shopMap.get(tableTriple.getBefore());
WxShop shopAfter = shopMap.get(tableTriple.getAfter());
if (Objects.nonNull(shopBefore)) {
tableTriple.setBefore(shopBefore.getShopNumber());
}
if (Objects.nonNull(shopAfter)) {
tableTriple.setAfter(shopAfter.getShopNumber());
}
}
return tableTriple;
}));
@@ -962,19 +1012,52 @@ public class InvestBizServiceImpl implements InvestBizService {
return buildFollowRecordItem(usersMap, followRecordEntity, customerEntity, brand);
}

@Override
public Map<String, Object> statistics() {
Map<String, Object> result = new HashMap<>();
if (Objects.isNull(InvestUserContext.getDataUser())) {
result.put("taskTotal", taskService.count(new LambdaQueryWrapper<InvestTaskEntity>()
.ge(InvestTaskEntity::getStatus, EnumTaskStatus.CREATED)
.eq(InvestTaskEntity::getTenantId, InvestUserContext.getUser().getTenantId())));
result.put("customerTotal", customerService.count(new LambdaQueryWrapper<InvestCustomerEntity>()
.ge(InvestCustomerEntity::getTenantId, InvestUserContext.getUser().getTenantId())));
result.put("taskToday", customerService.count(new LambdaQueryWrapper<InvestCustomerEntity>()
.apply("date_format(create_date,'%Y-%m-%d') = {0}", DateUtils.format(new Date()))
.eq(InvestCustomerEntity::getTenantId, InvestUserContext.getUser().getTenantId())));
result.put("customerImport", customerService.count(new LambdaQueryWrapper<InvestCustomerEntity>()
.eq(InvestCustomerEntity::getType, EnumCustomerType.INTENTIONAL)
.eq(InvestCustomerEntity::getTenantId, InvestUserContext.getUser().getTenantId())));
result.put("remindCount", remindService.count(new LambdaQueryWrapper<InvestRemindEntity>()
.ge(InvestRemindEntity::getTenantId, InvestUserContext.getUser().getTenantId())));
result.put("taskCreate", taskService.count(new LambdaQueryWrapper<InvestTaskEntity>()
.eq(InvestTaskEntity::getStatus, EnumTaskStatus.CREATED)
.eq(InvestTaskEntity::getTenantId, InvestUserContext.getUser().getTenantId())));
//result.put("customerCreate", customerService.count(new LambdaQueryWrapper<InvestCustomerEntity>()
// .eq(InvestCustomerEntity::getStatus, EnumTaskStatus.CREATED)));
} else {
result.put("taskTotal", taskService.count(new LambdaQueryWrapper<InvestTaskEntity>()
.ge(InvestTaskEntity::getStatus, EnumTaskStatus.CREATED)
.apply("`owner` REGEXP {0}", InvestUserContext.getUserId())));
result.put("customerTotal", demandService.count(new LambdaQueryWrapper<InvestDemandEntity>()
.ge(InvestDemandEntity::getOwner, InvestUserContext.getUser().getTenantId())));
}
return result;
}

private void syncTargetStatus(InvestTaskEntity investTaskEntity) {
//if (!Objects.equals(investTaskEntity.getTargetType(), EnumInvestType.RENT)) {
// return;
//}

if (StringUtils.isNotBlank(investTaskEntity.getOwner())) {
investTaskEntity.setStatus(EnumTaskStatus.NEGOTIATING);
if (StringUtils.isBlank(investTaskEntity.getOwner())) {
investTaskEntity.setStatus(EnumTaskStatus.CREATED);
} else {
WxShop shop = shopService.getById(investTaskEntity.getTargetId());
Map<Long, WxRentContract> shopContractMap = getWxRentContractMap(shop);
WxRentContract contract = shopContractMap.get(shop.getId());
if (Objects.nonNull(contract)) {
InvestHelper.addContractId(investTaskEntity.getContent(), contract.getId(), null);
investTaskEntity.setStatus(EnumTaskStatus.FINISH);
} else {
WxRentContract contractQuery = new WxRentContract();
contractQuery.setTenantId(InvestUserContext.getUser().getTenantId());
@@ -984,6 +1067,8 @@ public class InvestBizServiceImpl implements InvestBizService {
int count = rentContractService.selectContractCountByShopId(contractQuery);
if (count > 0) {
investTaskEntity.setStatus(EnumTaskStatus.INTENTION);
} else {
investTaskEntity.setStatus(EnumTaskStatus.NEGOTIATING);
}
}
}
@@ -1115,10 +1200,14 @@ public class InvestBizServiceImpl implements InvestBizService {
Map<Integer, WxBusiness> bussinessMap = getMap(businessService.getByIds(getIds(customers, InvestCustomerEntity::getBusinessId)), WxBusiness::getId);
List<InvestCustomerVo> resultList = new ArrayList<>();
for (InvestCustomerEntity costomerItem : customers) {
Optional<InvestDemandEntity> demandItem = Optional.ofNullable(demindsMap.get(costomerItem.getId()));
WxShop shop = shopsMap.get(demandItem.orElse(null));
WxBrand brand = brandMap.get(costomerItem.getBrandId());
resultList.add(buildCustomerItem(demandItem.orElse(null), costomerItem, brand, shop, bussinessMap.get(costomerItem.getBusinessId())));
InvestDemandEntity demandItem = demindsMap.get(costomerItem.getId());
WxShop shop = null;
WxBrand brand = null ;
if (Objects.nonNull(demandItem)) {
shop = shopsMap.get(demandItem.getTargetId());
brand = brandMap.get(costomerItem.getBrandId());
}
resultList.add(buildCustomerItem(demandItem, costomerItem, brand, shop, bussinessMap.get(costomerItem.getBusinessId())));
}
return resultList;
}
@@ -1137,10 +1226,14 @@ public class InvestBizServiceImpl implements InvestBizService {

List<InvestDemandVo> resultList = new ArrayList<>();
for (InvestCustomerEntity costomerItem : customers) {
Optional<InvestDemandEntity> demandItem = Optional.ofNullable(demindsMap.get(costomerItem.getId()));
WxShop shop = shopsMap.get(demandItem.orElse(null));
WxBrand brand = brandMap.get(costomerItem.getBrandId());
resultList.add(buildDemindItem(demandItem.orElse(null), costomerItem, brand, shop, usersMap));
InvestDemandEntity demandItem = demindsMap.get(costomerItem.getId());
WxShop shop = null;
WxBrand brand = null ;
if (Objects.nonNull(demandItem)) {
shop = shopsMap.get(demandItem.getTargetId());
brand = brandMap.get(costomerItem.getBrandId());
}
resultList.add(buildDemindItem(demandItem, costomerItem, brand, shop, usersMap));
}
return resultList;
}


+ 1
- 0
mallinkService/src/main/java/com/iformall/service/invest/impl/InvestCustomerServiceImpl.java View File

@@ -44,6 +44,7 @@ public class InvestCustomerServiceImpl extends InvestBaseServiceImpl<InvestCusto
@TableLog
@Override
public boolean updateById(InvestCustomerEntity entity) {

return super.updateByIdAction(entity, this::checkBeforeSaveOrUpdate);
}



+ 4
- 3
mallinkService/src/main/java/com/iformall/service/invest/impl/InvestDemandServiceImpl.java View File

@@ -44,13 +44,14 @@ public class InvestDemandServiceImpl extends InvestBaseServiceImpl<InvestDemandM

private void checkBeforeSaveOrUpdate(InvestDemandEntity entity) {
checkCustomerExit(customerService, entity.getCustomerId());
checkUserExit(userInfoService, entity.getOwner());
checkShop(shopService, entity);
if(Objects.nonNull(entity.getIntent())) {
if (Objects.nonNull(entity.getIntent())) {
entity.setIntent(stringToJson(entity.getIntent()));
}
if(Objects.isNull(entity.getOwner())) {
if (Objects.isNull(entity.getOwner()) || Objects.equals(entity.getOwner(), 0L)) {
entity.setOwner(0L);
} else {
checkUserExit(userInfoService, entity.getOwner());
}
}



+ 1
- 1
mallinkService/src/main/java/com/iformall/service/invest/impl/InvestFollowRecordServiceImpl.java View File

@@ -41,7 +41,7 @@ public class InvestFollowRecordServiceImpl extends InvestBaseServiceImpl<InvestF
public List<InvestFollowRecordEntity> listByTime(EnumFollowType followType, Date start) {
LambdaUpdateWrapper<InvestFollowRecordEntity> query = new LambdaUpdateWrapper<>() ;
query.eq(InvestFollowRecordEntity::getType,followType) ;
query.ge(InvestFollowRecordEntity::getCreateDate, start);
query.le(InvestFollowRecordEntity::getCreateDate, start);
return list(query);
}



+ 1
- 1
mallinkService/src/main/java/com/iformall/service/invest/impl/InvestMessageServiceImpl.java View File

@@ -66,7 +66,7 @@ public class InvestMessageServiceImpl extends InvestBaseServiceImpl<InvestMessag
public List<InvestMessageEntity> listByTypeAndTag(EnumFollowType type, EnumInvestMessageTag tag) {
LambdaQueryWrapper<InvestMessageEntity> messageQueryWrapper = new LambdaQueryWrapper<>();
messageQueryWrapper.eq(InvestMessageEntity::getType, type);
messageQueryWrapper.ge(InvestMessageEntity::getTag, tag);
messageQueryWrapper.eq(InvestMessageEntity::getTag, tag);
return list(messageQueryWrapper);
}
}

+ 23
- 0
mallinkService/src/main/java/com/iformall/service/invest/impl/InvestRemindServiceImpl.java View File

@@ -1,13 +1,21 @@
package com.iformall.service.invest.impl;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.iformall.domain.po.invest.InvestRemindEntity;
import com.iformall.domain.vo.invest.InvestUserContext;
import com.iformall.enums.EnumInvestRemindStatus;
import com.iformall.enums.EnumNegotiationType;
import com.iformall.mapper.InvestRemindMapper;
import com.iformall.service.invest.InvestRemindService;
import com.iformall.utils.DateUtils;
import org.apache.commons.collections.MapUtils;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Objects;


@@ -42,10 +50,25 @@ public class InvestRemindServiceImpl extends InvestBaseServiceImpl<InvestRemindM
return super.remove(wrapper);
}

@Override
public List<InvestRemindEntity> findUnRemindList() {
LambdaUpdateWrapper<InvestRemindEntity> wrapper = new LambdaUpdateWrapper<>();
wrapper.eq(InvestRemindEntity::getStatus, EnumInvestRemindStatus.UN_REMINDED);
wrapper.gt(InvestRemindEntity::getBeginDate, DateUtils.formatDateTime(new Date()));
return this.list(wrapper);
}

private void checkBeforeSaveOrUpdate(InvestRemindEntity input) {
input.setOwner(InvestUserContext.getUserId());
if (Objects.nonNull(input.getContent())) {
input.setContent(stringToJson(input.getContent()));
}
Map contentMap = JSON.parseObject(input.getContent(), Map.class);
if (MapUtils.isNotEmpty(contentMap)) {
Object customerId = contentMap.get(InvestRemindEntity.KEY_CUSTOMER);
input.setCustomerId(Objects.isNull(customerId) ? null : Long.parseLong((String) customerId));
Object negotiationType = contentMap.get(InvestRemindEntity.KEY_NEGOTIATIONTYPE);
input.setNegotiationType(EnumNegotiationType.getEnum(Integer.valueOf((String) negotiationType)));
}
}
}

+ 4
- 5
mallinkService/src/main/resources/mapper/InvestCustomerMapper.xml View File

@@ -20,10 +20,9 @@
</resultMap>

<select id="listByIds" resultType="com.iformall.domain.vo.invest.InvestCustomerVo">
select c.*,d.`id` as demandId,d.`owner` as demandOwner
from `invest_follow_record` f
LEFT JOIN `invest_demand` d ON d.id = f.`follow_id`
LEFT JOIN invest_customer c ON d.`customer_id` = c.id
SELECT c.*,d.`id` AS demandId,d.`owner` AS demandOwner FROM `invest_follow_record` f
INNER JOIN `invest_customer` c ON c.id=f.`follow_id`
INNER JOIN `invest_demand` d ON d.`customer_id`=c.id
where 1=1
<if test=" null != type and type.size()>0">
AND c.type in
@@ -32,7 +31,7 @@
</foreach>
</if>
<if test=" null != ids and ids.size()>0">
AND d.id in
AND c.id in
<foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
#{idItem}
</foreach>


+ 3
- 0
mallinkService/src/main/resources/mapper/InvestRemindMapper.xml View File

@@ -10,6 +10,9 @@
<result property="owner" column="owner"/>
<result property="content" column="content"/>
<result property="minute" column="minute"/>
<result property="status" column="status"/>
<result property="customerId" column="customer_id"/>
<result property="negotiationType" column="negotiation_type"/>
<result property="beginDate" column="begin_date"/>
<result property="endDate" column="end_date"/>
<result property="createDate" column="create_date"/>


+ 1
- 1
mallinkService/src/main/resources/mapper/WxBillAllMapper.xml View File

@@ -835,7 +835,7 @@
left join wx_merchant mm on mm.id = ms.merchant_id
left join wx_card_spend cs on cs.order_id = ms.order_id
left join wx_c_user cu on cu.id = cs.owner_id
where ms.order_type in(3,0) and ms.status = 0
where ms.status = 0
union all
select receive_pay money,merchant_id id from wx_bill_rent_deposit where status = 3
union all


+ 30
- 0
mallinkSysAdmin/src/main/java/com/iformall/controller/sys/DataInitController.java View File

@@ -111,6 +111,27 @@ public class DataInitController extends BaseController {
return new ResultData();
}

/**
* 核销积分数据修复
*
* @return
*/
@GetMapping("/addInvestMsgModel")
public ResultData addInvestMsgModel() {
try {
MallUserInfo userInfo = getUser();
if(userInfo.isFmSuperAdmin()) {
addInvestRemind();
return new ResultData();
}
} catch (Exception e) {
log.error("DataInitController::fixCredit error ", e);
return new ResultData(ErrorCode.MSG_METHOD_REQUEST_ERROR, e.getMessage());
}

return new ResultData();
}

@Transactional(rollbackFor = Exception.class)
public void doFixVerifyCredit() {
// 1 获取券码
@@ -180,6 +201,15 @@ public class DataInitController extends BaseController {
addBirthDayMsgModelToMall(EnumMsgModel.COUPON_BIRTHDAY_OPENED_NO, idWorker, "亲到的{userName},在您的生日到来之际,我们精心的为您准备了一份生日礼物,赶快打开{mallName}微信小程序领取您的专属生日礼物吧!");
}

/**
* 增加招商语音提醒短信模板
*/
@Transactional(rollbackFor = Exception.class)
public void addInvestRemind() {
IdWorker idWorker = IdWorker.get();
addBirthDayMsgModelToMall(EnumMsgModel.INVEST_REMIND, idWorker, "{mallName}您于{beginDate}{negotiationType}{customerName},请知悉!");
}

private void addBirthDayMsgModelToMall(EnumMsgModel type, IdWorker idWorker, String content) {
//查找已经添加过的接口列表
WxMsgValidationcodeModel query = new WxMsgValidationcodeModel();


Loading…
Cancel
Save