Browse Source

[招商]adjust

release_toaliyun_real
Burce 6 years ago
parent
commit
4d97ca09b2
13 changed files with 339 additions and 18 deletions
  1. +0
    -3
      mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestBaseController.java
  2. +7
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestCustomerController.java
  3. +6
    -2
      mallinkService/src/main/java/com/iformall/domain/po/invest/InvestCustomerEntity.java
  4. +3
    -0
      mallinkService/src/main/java/com/iformall/domain/po/invest/InvestDemandEntity.java
  5. +2
    -1
      mallinkService/src/main/java/com/iformall/domain/po/invest/InvestTaskEntity.java
  6. +4
    -0
      mallinkService/src/main/java/com/iformall/domain/vo/RentEventInfo.java
  7. +6
    -4
      mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestCustomerVo.java
  8. +2
    -0
      mallinkService/src/main/java/com/iformall/service/invest/InvestBizService.java
  9. +15
    -2
      mallinkService/src/main/java/com/iformall/service/invest/InvestHelper.java
  10. +1
    -1
      mallinkService/src/main/java/com/iformall/service/invest/event/InvestListener.java
  11. +291
    -4
      mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBizServiceImpl.java
  12. +1
    -0
      mallinkService/src/main/java/com/iformall/utils/Constant.java
  13. +1
    -1
      mallinkService/src/main/java/com/iformall/utils/EventUtil.java

+ 0
- 3
mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestBaseController.java View File

@@ -46,9 +46,6 @@ public class InvestBaseController extends BaseController {
ErrorCode errorCode = ErrorCode.SYS_NULLPOINTER_ERROR ; ErrorCode errorCode = ErrorCode.SYS_NULLPOINTER_ERROR ;
log.error("execute error {}", errorCode.getMessage()); log.error("execute error {}", errorCode.getMessage());
return new InvestResultData(errorCode); return new InvestResultData(errorCode);
} catch (Exception e) {
log.error("execute error", e);
return new InvestResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),e.getMessage());
} finally { } finally {
InvestUserContext.remove(); InvestUserContext.remove();
} }


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

@@ -94,6 +94,13 @@ public class InvestCustomerController extends InvestBaseController{
exportData(params, response, (p, u) -> investBizService.exportCustomer(p, u)); exportData(params, response, (p, u) -> investBizService.exportCustomer(p, u));
} }


@ApiOperation("导出客户信息模板")
@GetMapping("/exportCustomerTemplate")
@SystemControllerLog(description = "招商管理-导出客户信息模板")
public void exportCustomerTemplate(HttpServletResponse response) {
exportData(null, response, (p, u) -> investBizService.exportCustomerTemplate(u));
}

@ApiOperation("导入客户信息") @ApiOperation("导入客户信息")
@GetMapping("/importCustomer") @GetMapping("/importCustomer")
@SystemControllerLog(description = "招商管理-导入客户信息") @SystemControllerLog(description = "招商管理-导入客户信息")


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

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


import cn.afterturn.easypoi.excel.annotation.Excel; 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; import com.baomidou.mybatisplus.annotation.TableName;




@@ -32,14 +34,14 @@ public class InvestCustomerEntity extends InvestBaseEntity {
*/ */
@LogColumn @LogColumn
@io.swagger.annotations.ApiModelProperty(value = "品牌负责人", name = "name") @io.swagger.annotations.ApiModelProperty(value = "品牌负责人", name = "name")
@Excel(name = "品牌负责人", width = 20, orderNum = "2")
@Excel(name = "品牌负责人*", width = 20, orderNum = "2")
private String name; private String name;
/** /**
* 电话 * 电话
*/ */
@LogColumn @LogColumn
@io.swagger.annotations.ApiModelProperty(value = "电话", name = "phone") @io.swagger.annotations.ApiModelProperty(value = "电话", name = "phone")
@Excel(name = "负责人电话", width = 20, orderNum = "3")
@Excel(name = "负责人电话*", width = 20, orderNum = "3")
private String phone; private String phone;
/** /**
* 经营业态 * 经营业态
@@ -58,12 +60,14 @@ public class InvestCustomerEntity extends InvestBaseEntity {
*/ */
@io.swagger.annotations.ApiModelProperty(value = "客户分类:0-潜在客户;1-意向客户;2-合作客户;3-谈判失败", name = "type") @io.swagger.annotations.ApiModelProperty(value = "客户分类:0-潜在客户;1-意向客户;2-合作客户;3-谈判失败", name = "type")
@LogColumn @LogColumn
@TableField(strategy = FieldStrategy.IGNORED)
private EnumCustomerType type; private EnumCustomerType type;
/** /**
* 客户预评级:0-无;1-主力店;2-次主力店;3-甲;4-乙;5-丙 * 客户预评级:0-无;1-主力店;2-次主力店;3-甲;4-乙;5-丙
*/ */
@io.swagger.annotations.ApiModelProperty(value = "客户预评级:0-无;1-主力店;2-次主力店;3-甲;4-乙;5-丙", name = "rating") @io.swagger.annotations.ApiModelProperty(value = "客户预评级:0-无;1-主力店;2-次主力店;3-甲;4-乙;5-丙", name = "rating")
@LogColumn @LogColumn
@TableField(strategy = FieldStrategy.IGNORED)
private EnumCustomerRatingType rating; private EnumCustomerRatingType rating;


/** /**


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

@@ -1,5 +1,7 @@
package com.iformall.domain.po.invest; package com.iformall.domain.po.invest;


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




@@ -32,6 +34,7 @@ public class InvestDemandEntity extends InvestBaseEntity {
*/ */
@io.swagger.annotations.ApiModelProperty(value = "负责人", name = "owner") @io.swagger.annotations.ApiModelProperty(value = "负责人", name = "owner")
@LogColumn @LogColumn
@TableField(strategy = FieldStrategy.IGNORED)
private Long owner; private Long owner;
/** /**
* 客户ID * 客户ID


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

@@ -23,7 +23,8 @@ import java.util.Date;
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
public class InvestTaskEntity extends InvestBaseEntity { public class InvestTaskEntity extends InvestBaseEntity {


public static final String KEY_CONTRACTID = "contractId" ;
public static final String KEY_CONTRACT_ID = "contractId" ;
public static final String KEY_CONTRACT_TYPE = "ContractType" ;


/** /**
* 负责人 * 负责人


+ 4
- 0
mallinkService/src/main/java/com/iformall/domain/vo/RentEventInfo.java View File

@@ -15,4 +15,8 @@ public class RentEventInfo {
private final Long rentId ; private final Long rentId ;
private final List<Long> targetIds ; private final List<Long> targetIds ;
private final EnumRentContractStatus type ; private final EnumRentContractStatus type ;
/**
* 合同类型
*/
private final Integer ContractType ;
} }

+ 6
- 4
mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestCustomerVo.java View File

@@ -5,6 +5,8 @@ import com.iformall.domain.po.invest.InvestCustomerEntity;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;


import java.util.Date;

@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
public class InvestCustomerVo extends InvestCustomerEntity { public class InvestCustomerVo extends InvestCustomerEntity {
@@ -18,17 +20,17 @@ public class InvestCustomerVo extends InvestCustomerEntity {
@io.swagger.annotations.ApiModelProperty(value = "客户需求负责人", name = "demandOwner") @io.swagger.annotations.ApiModelProperty(value = "客户需求负责人", name = "demandOwner")
private Long demandOwner; private Long demandOwner;


@Excel(name = "品牌", width = 30, orderNum = "1")
@Excel(name = "品牌*", width = 30, orderNum = "1")
private String brandName; private String brandName;
@Excel(name = "经营业态", width = 20, orderNum = "3")
@Excel(name = "经营业态*", width = 20, orderNum = "3")
private String business; private String business;


@Excel(name = "意向租赁面积", width = 20, orderNum = "5") @Excel(name = "意向租赁面积", width = 20, orderNum = "5")
private String rentArea;
private Integer rentArea;


@Excel(name = "预计开业时间", width = 20, orderNum = "6") @Excel(name = "预计开业时间", width = 20, orderNum = "6")
private String openingTime; private String openingTime;


@Excel(name = "意向铺位", width = 20, orderNum = "4")
@Excel(name = "意向铺位*", width = 20, orderNum = "4")
private String shopNumber; private String shopNumber;
} }

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

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


void exportCustomer(InvestDemandQuery params, HttpServletResponse response); void exportCustomer(InvestDemandQuery params, HttpServletResponse response);


void exportCustomerTemplate(HttpServletResponse response);

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


List<InvestDemandVo> queryCustomer(); List<InvestDemandVo> queryCustomer();


+ 15
- 2
mallinkService/src/main/java/com/iformall/service/invest/InvestHelper.java View File

@@ -10,11 +10,14 @@ import com.iformall.domain.po.invest.InvestTaskEntity;
import com.iformall.domain.vo.invest.InvestPageQuery; import com.iformall.domain.vo.invest.InvestPageQuery;
import com.iformall.exception.MallinkException; import com.iformall.exception.MallinkException;
import com.iformall.utils.JsonUtil; import com.iformall.utils.JsonUtil;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.Nullable;


import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.function.Function; import java.util.function.Function;
import java.util.function.Predicate; import java.util.function.Predicate;
@@ -176,9 +179,19 @@ public class InvestHelper {
return dataList.parallelStream().filter(predicate).map(mapper).collect(Collectors.toList()); return dataList.parallelStream().filter(predicate).map(mapper).collect(Collectors.toList());
} }


public static String addContractId(String content,Long rentId) {
public static String addContractId(String content,Long rentId,Integer ContractType) {
Map contentMap = JSON.parseObject(content, Map.class); Map contentMap = JSON.parseObject(content, Map.class);
contentMap.put(InvestTaskEntity.KEY_CONTRACTID, rentId);
if(Objects.nonNull(rentId)) {
contentMap.put(InvestTaskEntity.KEY_CONTRACT_ID, rentId);
}
if(Objects.nonNull(ContractType)) {
contentMap.put(InvestTaskEntity.KEY_CONTRACT_TYPE, ContractType);
}
return JsonUtil.obj2Json(contentMap); return JsonUtil.obj2Json(contentMap);
} }

public static Date parseDate(String dateStr) throws ParseException {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
return sdf.parse(dateStr);
}
} }

+ 1
- 1
mallinkService/src/main/java/com/iformall/service/invest/event/InvestListener.java View File

@@ -56,7 +56,7 @@ public class InvestListener implements ApplicationListener<InvestEvent> {
if (status == EnumTaskStatus.FINISH) { if (status == EnumTaskStatus.FINISH) {
for (InvestTaskEntity task : tasks) { for (InvestTaskEntity task : tasks) {
task.setStatus(status); task.setStatus(status);
task.setContent(InvestHelper.addContractId(task.getContent(),rentEventInfo.getRentId()));
task.setContent(InvestHelper.addContractId(task.getContent(),rentEventInfo.getRentId(),rentEventInfo.getContractType()));
} }
taskService.updateBatchById(tasks); taskService.updateBatchById(tasks);
} }


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

@@ -1,9 +1,16 @@
package com.iformall.service.invest.impl; package com.iformall.service.invest.impl;


import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
import cn.afterturn.easypoi.handler.impl.ExcelDataHandlerDefaultImpl;
import cn.afterturn.easypoi.handler.inter.IExcelDataHandler;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.iformall.common.ErrorCode;
import com.iformall.common.Result;
import com.iformall.domain.dto.InvestDemandDto; import com.iformall.domain.dto.InvestDemandDto;
import com.iformall.domain.dto.InvestTaskDto; import com.iformall.domain.dto.InvestTaskDto;
import com.iformall.domain.po.*; import com.iformall.domain.po.*;
@@ -11,9 +18,12 @@ import com.iformall.domain.po.invest.*;
import com.iformall.domain.vo.WxShopVo; import com.iformall.domain.vo.WxShopVo;
import com.iformall.domain.vo.invest.*; import com.iformall.domain.vo.invest.*;
import com.iformall.enums.*; import com.iformall.enums.*;
import com.iformall.exception.MallinkException;
import com.iformall.service.*; import com.iformall.service.*;
import com.iformall.service.invest.*; import com.iformall.service.invest.*;
import com.iformall.utils.Constant;
import com.iformall.utils.DateUtils; import com.iformall.utils.DateUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils; import org.apache.commons.collections.MapUtils;
import org.apache.commons.compress.utils.Lists; import org.apache.commons.compress.utils.Lists;
@@ -21,15 +31,22 @@ import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;


import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors;


@Slf4j
@Service @Service
public class InvestBizServiceImpl implements InvestBizService { public class InvestBizServiceImpl implements InvestBizService {


@@ -59,6 +76,10 @@ public class InvestBizServiceImpl implements InvestBizService {
private WxRentContractService rentContractService; private WxRentContractService rentContractService;
@Autowired @Autowired
private ExcelService excelService; private ExcelService excelService;
@Autowired
StringRedisTemplate stringRedisTemplate;
@Autowired
private String fmUploadDir;


@Override @Override
public InvestPageResult<InvestDemandVo> queryPageDemand(InvestDemandQuery params) { public InvestPageResult<InvestDemandVo> queryPageDemand(InvestDemandQuery params) {
@@ -123,9 +144,262 @@ public class InvestBizServiceImpl implements InvestBizService {
} }
} }


@Override
public void exportCustomerTemplate(HttpServletResponse response) {
List<InvestCustomerVo> resultList = new ArrayList<>();
InvestCustomerVo item = new InvestCustomerVo();
item.setBusiness("超市");
item.setRentArea(100);
item.setShopNumber("A10092");
item.setBrandName("肯德基");
item.setName("张三");
item.setPhone("1358888888");
item.setOpeningTime("2019-01-01");
resultList.add(item);
excelService.exportExcel(resultList, null, "客户信息模板", InvestCustomerVo.class, "客户信息模板.xlsx", response, true);
}

@Override @Override
public void importCustomer(MultipartFile mFile) { public void importCustomer(MultipartFile mFile) {
if (mFile.isEmpty()) {
throw new MallinkException(Result.ERROR, "上传文件不能为空");
}

String importKey = Constant.importInvestCustomerPrev + InvestUserContext.getUserId();
final String tenantId = InvestUserContext.getUser().getTenantId();

//查询当前用户得到的值是否为空,为空继续,不为空,返回模板正在导入
Boolean allCount = stringRedisTemplate.opsForHash().hasKey(importKey, "allCount");
if (allCount) {
throw new MallinkException(Result.SUCCESS, "模板正在导入");
}
setRedisValueIfAbsent(importKey);

String fpath = fmUploadDir;
File targetFile = new File(fpath);
if (!targetFile.exists()) {
targetFile.mkdirs();
}
String fileName = "invest_1.xlsx";
int dot = mFile.getOriginalFilename().lastIndexOf('.');
fileName = fileName + mFile.getOriginalFilename().substring(dot);

File lFile = new File(fpath + File.separator + fileName);

FileOutputStream fos = null;
BufferedInputStream fs = null;
try {
fos = new FileOutputStream(lFile);
fs = (BufferedInputStream) mFile.getInputStream();
byte[] buffer = new byte[1024];
int len = 0;
while ((len = fs.read(buffer)) != -1) {
fos.write(buffer, 0, len);
}
fos.close();
fs.close();
} catch (Exception e) {
setRedisValueIfError(importKey, "1", "1", e);
throw new MallinkException(ErrorCode.MEM_IMPORT_ERR.getCode(), "模板上传失败");
} finally {
if (fos != null) {
try {
fos.close();
} catch (IOException e) {
setRedisValueIfError(importKey, "1", "1", e);
throw new MallinkException(ErrorCode.MEM_IMPORT_ERR.getCode(), "模板上传失败");
}
}
if (fs != null) {
try {
fs.close();
} catch (IOException e) {
setRedisValueIfError(importKey, "1", "1", e);
throw new MallinkException(ErrorCode.MEM_IMPORT_ERR.getCode(), "模板上传失败");
}
}
}


doImport(lFile, tenantId, importKey);
throw new MallinkException(Result.SUCCESS, "模板正在导入");
}

private void doImport(File file, String tenantId, String importKey) {
ImportParams params = new ImportParams();
// 需要验证
params.setImportFields(new String[]{"品牌*", "品牌负责人*", "负责人电话*", "经营业态*", "意向铺位*", "意向租凭面积", "预计开业时间"});
IExcelDataHandler<InvestCustomerVoT> handler = new ExcelDataHandlerDefaultImpl<InvestCustomerVoT>() {
@Override
public Object importHandler(InvestCustomerVoT obj, String name, Object value) {
if (value == null) {
value = "";
}
System.out.println(name + " + " + value.toString());
return super.importHandler(obj, name, value);
}
};
handler.setNeedHandlerFields(new String[]{"品牌*", "品牌负责人*", "负责人电话*", "经营业态*", "意向铺位*"});
params.setNeedVerify(true);

ExcelImportResult<InvestCustomerVoT> datalist = null;

try {
datalist = ExcelImportUtil.importExcelMore(file, InvestCustomerVoT.class, params);
} catch (Exception e) {
setRedisValue(importKey, "1", "0", "0", "1", true);
log.error(e.getMessage());
// 删除缓存文件
file.delete();
return;
}
// 删除缓存文件
file.delete();

if (datalist == null) {
log.error("导入模板失败: 模板数据解析失败");
setRedisValue(importKey, "1", "0", "0", "1", true);
return;
}

List<InvestCustomerVoT> successList = datalist.getList();
List<InvestCustomerVoT> failList = datalist.getFailList();

log.info("验证通过的数量: " + successList.size());
log.info("验证未通过的数量: " + failList.size());

int total = successList.size() + failList.size();
int all_success = successList.size();
int all_fail = failList.size();

//添加到redis里
setRedisValue(importKey, "" + total, "" + all_success, "0", "" + all_fail, total == all_fail);
if (CollectionUtils.isEmpty(successList)) {
return;
}
//品牌信息
List<WxBrand> brands = brandService.listAsPage(null, 1, Integer.MAX_VALUE).getList();
Map<String, WxBrand> brandMap = getMap(brands, WxBrand::getName);

//业态信息
List<WxBusiness> businesses = businessService.listAsPage(null, 1, Integer.MAX_VALUE).getList();
Map<String, WxBusiness> businesseMap = getMap(businesses, WxBusiness::getTitle);

//商铺信息
List<WxShop> shops = shopService.listAsPage(null, 1, Integer.MAX_VALUE).getList();
Map<String, WxShop> shopMap = getMap(shops, WxShop::getShopNumber);

//商铺信息
LambdaQueryWrapper<InvestCustomerEntity> customerQuery = new LambdaQueryWrapper<>();
customerQuery.in(InvestCustomerEntity::getPhone, getIds(successList, InvestCustomerVoT::getPhone));
List<InvestCustomerEntity> customers = customerService.list(customerQuery);
Map<String, InvestCustomerEntity> customerMap = getMap(customers, InvestCustomerEntity::getPhone);

try {
successList.parallelStream().forEach(customer -> {
if (StringUtils.isBlank(customer.getPhone())) {
stringRedisTemplate.opsForHash().increment(importKey, "processCount", 1);
log.error("负责人电话为空", customer.toString());
return;
}
if (StringUtils.isBlank(customer.getShopNumber())) {
stringRedisTemplate.opsForHash().increment(importKey, "processCount", 1);
log.error("意向铺位为空", customer.toString());
return;
}
if (StringUtils.isBlank(customer.getBrandName())) {
stringRedisTemplate.opsForHash().increment(importKey, "processCount", 1);
log.error("品牌为空", customer.toString());
return;
}
if (StringUtils.isBlank(customer.getName())) {
stringRedisTemplate.opsForHash().increment(importKey, "processCount", 1);
log.error("品牌负责人为空", customer.toString());
return;
}
if (StringUtils.isBlank(customer.getBusiness())) {
stringRedisTemplate.opsForHash().increment(importKey, "processCount", 1);
log.error("经营业态为空", customer.toString());
return;
}
InvestDemandDto customerBase = convetCustomer(customer, brandMap, businesseMap, shopMap, customerMap);
if (customerBase == null) {
stringRedisTemplate.opsForHash().increment(importKey, "processCount", 1);
log.error("userBasenull");
}
saveCustomerAndDemand(customerBase) ;
});
} catch (Exception e) {
setRedisValue(importKey, "1", "0", "0", "1", true);
e.printStackTrace();
log.error("导入模板失败:" + e.getMessage());
}
}

private InvestDemandDto convetCustomer(InvestCustomerVoT customerVoT, Map<String, WxBrand> brandMap, Map<String, WxBusiness> businesseMap, Map<String, WxShop> shopMap, Map<String, InvestCustomerEntity> customerMap) {
InvestCustomerEntity customerEntity = new InvestCustomerEntity();
if (Objects.isNull(brandMap.get(customerVoT.getBrandName()))) {
return null;
}
customerEntity.setBrandId(brandMap.get(customerVoT.getBrandName()).getId());

if (Objects.isNull(businesseMap.get(customerVoT.getBusiness()))) {
return null;
}
customerEntity.setBusinessId(businesseMap.get(customerVoT.getBusiness()).getId());

InvestDemandEntity demandEntity = new InvestDemandEntity();
if (Objects.isNull(shopMap.get(customerVoT.getShopNumber()))) {
return null;
}
demandEntity.setTargetId(shopMap.get(customerVoT.getShopNumber()).getId());
demandEntity.setTargetType(EnumInvestType.RENT);
Map<String, Object> intent = new HashMap<>();
if (Objects.nonNull(customerVoT.getRentArea())) {
intent.put(InvestDemandEntity.KEY_RENT_AREA, customerVoT.getRentArea());
}
if (Objects.nonNull(customerVoT.getOpeningTime())) {
intent.put(InvestDemandEntity.KEY_OPENING_TIME, customerVoT.getOpeningTime());
}

if (!intent.isEmpty()) {
demandEntity.setIntent(JSON.toJSONString(intent));
}

InvestDemandDto demandDto = new InvestDemandDto();
demandDto.setCustomer(customerEntity);
demandDto.setDemand(demandEntity);
if (Objects.isNull(customerMap.get(customerVoT.getPhone()))) {
//TODO insert
} else {
//TODO update
}

return demandDto;
}

private void setRedisValue(String importKey, String allCount, String allSuccessCount, String processCount, String failCount, boolean fail) {
stringRedisTemplate.opsForHash().put(importKey, "allCount", allCount);
stringRedisTemplate.opsForHash().put(importKey, "allSuccessCount", allSuccessCount);
stringRedisTemplate.opsForHash().put(importKey, "processCount", processCount);
stringRedisTemplate.opsForHash().put(importKey, "failCount", failCount);
if (fail) {
stringRedisTemplate.expire(importKey, 10, TimeUnit.SECONDS);
}
}

private void setRedisValueIfAbsent(String importKey) {
stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allCount", 0 + "");
stringRedisTemplate.expire(importKey, 30, TimeUnit.MINUTES);
stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allSuccessCount", 0 + "");
stringRedisTemplate.opsForHash().putIfAbsent(importKey, "processCount", "");
stringRedisTemplate.opsForHash().putIfAbsent(importKey, "failCount", "");
}

private void setRedisValueIfError(String importKey, String allCount, String failCount, Exception e) {
stringRedisTemplate.expire(importKey, 3, TimeUnit.SECONDS);
stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allCount", allCount);
stringRedisTemplate.opsForHash().putIfAbsent(importKey, "failCount", failCount);
log.error(e.getMessage());
} }


@Override @Override
@@ -499,6 +773,12 @@ public class InvestBizServiceImpl implements InvestBizService {
return buildTaskItem(taskEntity, shopVo, usersMap); return buildTaskItem(taskEntity, shopVo, usersMap);
} }


/**
* 获取商铺对应的正式合同信息
*
* @param shop
* @return
*/
private Map<Long, WxRentContract> getWxRentContractMap(WxShop shop) { private Map<Long, WxRentContract> getWxRentContractMap(WxShop shop) {
InvestHelper.notNull(shop, "商铺不存在"); InvestHelper.notNull(shop, "商铺不存在");
return rentContractService.selectRentContractByShopIds(Arrays.asList(shop.getId()), StringUtils.join(shop.getId(), ""), return rentContractService.selectRentContractByShopIds(Arrays.asList(shop.getId()), StringUtils.join(shop.getId(), ""),
@@ -588,12 +868,13 @@ public class InvestBizServiceImpl implements InvestBizService {
Map<Long, WxRentContract> shopContractMap = getWxRentContractMap(shop); Map<Long, WxRentContract> shopContractMap = getWxRentContractMap(shop);
WxRentContract contract = shopContractMap.get(shop.getId()); WxRentContract contract = shopContractMap.get(shop.getId());
if (Objects.nonNull(contract)) { if (Objects.nonNull(contract)) {
InvestHelper.addContractId(investTaskEntity.getContent(), contract.getId());
InvestHelper.addContractId(investTaskEntity.getContent(), contract.getId(), null);
} else { } else {
WxRentContract contractQuery = new WxRentContract(); WxRentContract contractQuery = new WxRentContract();
contractQuery.setTenantId(InvestUserContext.getUser().getTenantId()); contractQuery.setTenantId(InvestUserContext.getUser().getTenantId());
contractQuery.setShopId(investTaskEntity.getTargetId()); contractQuery.setShopId(investTaskEntity.getTargetId());
contractQuery.setStatus(EnumRentContractStatus.INTENTION.getCode()); contractQuery.setStatus(EnumRentContractStatus.INTENTION.getCode());
//获取意向合同
int count = rentContractService.selectContractCountByShopId(contractQuery); int count = rentContractService.selectContractCountByShopId(contractQuery);
if (count > 0) { if (count > 0) {
investTaskEntity.setStatus(EnumTaskStatus.INTENTION); investTaskEntity.setStatus(EnumTaskStatus.INTENTION);
@@ -652,8 +933,14 @@ public class InvestBizServiceImpl implements InvestBizService {
resultItemVo.setDemandOwner(item.getOwner()); resultItemVo.setDemandOwner(item.getOwner());
if (StringUtils.isNotBlank(item.getIntent())) { if (StringUtils.isNotBlank(item.getIntent())) {
Map intentMap = JSON.parseObject(item.getIntent(), Map.class); Map intentMap = JSON.parseObject(item.getIntent(), Map.class);
resultItemVo.setRentArea(String.valueOf(intentMap.get(InvestDemandEntity.KEY_RENT_AREA)));
resultItemVo.setOpeningTime(String.valueOf(intentMap.get(InvestDemandEntity.KEY_OPENING_TIME)));
Object rentArea = intentMap.get(InvestDemandEntity.KEY_RENT_AREA);
Object openingTime = intentMap.get(InvestDemandEntity.KEY_OPENING_TIME);
if (Objects.nonNull(rentArea)) {
resultItemVo.setRentArea(Integer.valueOf(String.valueOf(rentArea)));
}
if (Objects.nonNull(openingTime)) {
resultItemVo.setOpeningTime(String.valueOf(openingTime));
}
} }
} }
//resultItemVo.setBusiness(usersMap.get(item.getOwner())); //resultItemVo.setBusiness(usersMap.get(item.getOwner()));


+ 1
- 0
mallinkService/src/main/java/com/iformall/utils/Constant.java View File

@@ -32,6 +32,7 @@ public class Constant {
public static final String UNDEFINED = "undefined"; public static final String UNDEFINED = "undefined";


public static final String importMemPrev = "importmem:"; public static final String importMemPrev = "importmem:";
public static final String importInvestCustomerPrev = "importinvestcustomer:";
public static final String adminPage = "https://admin.malls.iformall.com"; public static final String adminPage = "https://admin.malls.iformall.com";






+ 1
- 1
mallinkService/src/main/java/com/iformall/utils/EventUtil.java View File

@@ -14,7 +14,7 @@ public class EventUtil {
public static void publistRentEvent(WxRentContractService rentContractService, WxRentContract rentContract) { public static void publistRentEvent(WxRentContractService rentContractService, WxRentContract rentContract) {
try { try {
RentEventInfo rentEventInfo = RentEventInfo RentEventInfo rentEventInfo = RentEventInfo
.of(rentContract.getId(), rentContractService.getShopIds(rentContract), EnumRentContractStatus.getEnum(rentContract.getStatus()));
.of(rentContract.getId(), rentContractService.getShopIds(rentContract), EnumRentContractStatus.getEnum(rentContract.getStatus()),null);
InvestEvent event = new InvestEvent(rentEventInfo); InvestEvent event = new InvestEvent(rentEventInfo);
SpringContextUtils.pulish(event); SpringContextUtils.pulish(event);
} catch (Exception e) { } catch (Exception e) {


Loading…
Cancel
Save