Browse Source

[招商]adjust

release_toaliyun_real
Burce 6 years ago
parent
commit
37bb58d165
3 changed files with 49 additions and 23 deletions
  1. +8
    -0
      mallinkService/src/main/java/com/iformall/service/invest/InvestHelper.java
  2. +10
    -7
      mallinkService/src/main/java/com/iformall/service/invest/event/InvestListener.java
  3. +31
    -16
      mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBizServiceImpl.java

+ 8
- 0
mallinkService/src/main/java/com/iformall/service/invest/InvestHelper.java View File

@@ -6,8 +6,10 @@ import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.Multimaps;
import com.iformall.common.ErrorCode;
import com.iformall.domain.po.invest.InvestBaseEntity;
import com.iformall.domain.po.invest.InvestTaskEntity;
import com.iformall.domain.vo.invest.InvestPageQuery;
import com.iformall.exception.MallinkException;
import com.iformall.utils.JsonUtil;
import org.apache.commons.lang3.StringUtils;
import org.checkerframework.checker.nullness.qual.Nullable;

@@ -173,4 +175,10 @@ public class InvestHelper {
public static <T, R> Collection<R> getIds(Collection<T> dataList, Predicate<T> predicate,Function<? super T, R> mapper) {
return dataList.parallelStream().filter(predicate).map(mapper).collect(Collectors.toList());
}

public static String addContractId(String content,Long rentId) {
Map contentMap = JSON.parseObject(content, Map.class);
contentMap.put(InvestTaskEntity.KEY_CONTRACTID, rentId);
return JsonUtil.obj2Json(contentMap);
}
}

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

@@ -7,6 +7,7 @@ import com.iformall.domain.vo.RentEventInfo;
import com.iformall.enums.EnumInvestType;
import com.iformall.enums.EnumRentContractStatus;
import com.iformall.enums.EnumTaskStatus;
import com.iformall.service.invest.InvestHelper;
import com.iformall.service.invest.InvestTaskService;
import com.iformall.utils.JsonUtil;
import lombok.extern.slf4j.Slf4j;
@@ -48,15 +49,17 @@ public class InvestListener implements ApplicationListener<InvestEvent> {
status = EnumTaskStatus.FINISH;
} else if (Objects.equals(EnumRentContractStatus.RENT_PAID, rentContractStatus)) {
status = EnumTaskStatus.FINISH;
} else if (Objects.equals(EnumRentContractStatus.CONTRACT_END_SOON, rentContractStatus)) {
status = EnumTaskStatus.FINISH;
}

for (InvestTaskEntity task : tasks) {
task.setStatus(status);
String content = task.getContent();
Map contentMap = JSON.parseObject(content, Map.class);
contentMap.put(InvestTaskEntity.KEY_CONTRACTID, rentEventInfo.getRentId());
task.setContent(JsonUtil.obj2Json(contentMap));
if (status == EnumTaskStatus.FINISH) {
for (InvestTaskEntity task : tasks) {
task.setStatus(status);
task.setContent(InvestHelper.addContractId(task.getContent(),rentEventInfo.getRentId()));
}
taskService.updateBatchById(tasks);
}
taskService.updateBatchById(tasks);
}
}

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

@@ -76,7 +76,7 @@ public class InvestBizServiceImpl implements InvestBizService {
queryWrapperCustomer.in(ObjectUtils.allNotNull(params.getDemandOwner()),
InvestCustomerEntity::getId, getIds(demandList, InvestDemandEntity::getCustomerId));
} else {
if(CollectionUtils.isEmpty(demandList)) {
if (CollectionUtils.isEmpty(demandList)) {
return investPage;
} else {
queryWrapperCustomer.in(InvestCustomerEntity::getId, getIds(demandList, InvestDemandEntity::getCustomerId));
@@ -399,7 +399,7 @@ public class InvestBizServiceImpl implements InvestBizService {
@Override
public boolean saveCustomerAndDemand(InvestDemandDto demandDto) {
InvestHelper.notNull(demandDto, demandDto.getCustomer(), demandDto.getDemand());
InvestCustomerEntity customerEntity = demandDto.getCustomer() ;
InvestCustomerEntity customerEntity = demandDto.getCustomer();
customerService.save(customerEntity);
InvestDemandEntity demandEntity = demandDto.getDemand();
demandEntity.setCustomerId(customerEntity.getId());
@@ -485,8 +485,7 @@ public class InvestBizServiceImpl implements InvestBizService {
}

//3、商品合同信息
Map<Long, WxRentContract> shopContractMap = rentContractService.selectRentContractByShopIds(Arrays.asList(shop.getId()), StringUtils.join(shop.getId(), "|"),
InvestUserContext.getUser().getTenantId());
Map<Long, WxRentContract> shopContractMap = getWxRentContractMap(shop);
WxRentContract contract = shopContractMap.get(shop.getId());
if (Objects.nonNull(contract)) {
shopVo.setStartdate(contract.getRentalStartDate());
@@ -498,6 +497,12 @@ public class InvestBizServiceImpl implements InvestBizService {
return buildTaskItem(taskEntity, shopVo, usersMap);
}

private Map<Long, WxRentContract> getWxRentContractMap(WxShop shop) {
InvestHelper.notNull(shop, "商铺不存在");
return rentContractService.selectRentContractByShopIds(Arrays.asList(shop.getId()), StringUtils.join(shop.getId(), "|"),
InvestUserContext.getUser().getTenantId());
}

@Override
public InvestRemindVo findRemindById(Long id) {
InvestRemindEntity remindEntity = remindService.getByIdNotNull(id);
@@ -574,16 +579,26 @@ public class InvestBizServiceImpl implements InvestBizService {
}

private void syncTargetStatus(InvestTaskEntity investTaskEntity) {
WxRentContract contractQuery = new WxRentContract();
contractQuery.setTenantId(InvestUserContext.getUser().getTenantId());
contractQuery.setShopId(investTaskEntity.getTargetId());
contractQuery.setStatus(EnumRentContractStatus.INTENTION.getCode());
int count = rentContractService.selectContractCountByShopId(contractQuery);
if (count > 0) {
investTaskEntity.setStatus(EnumTaskStatus.INTENTION);
if (!Objects.equals(investTaskEntity.getTargetType(), EnumInvestType.RENT)) {
return;
}
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());
} else {
if (StringUtils.isNotBlank(investTaskEntity.getOwner())) {
investTaskEntity.setStatus(EnumTaskStatus.NEGOTIATING);
WxRentContract contractQuery = new WxRentContract();
contractQuery.setTenantId(InvestUserContext.getUser().getTenantId());
contractQuery.setShopId(investTaskEntity.getTargetId());
contractQuery.setStatus(EnumRentContractStatus.INTENTION.getCode());
int count = rentContractService.selectContractCountByShopId(contractQuery);
if (count > 0) {
investTaskEntity.setStatus(EnumTaskStatus.INTENTION);
} else {
if (StringUtils.isNotBlank(investTaskEntity.getOwner())) {
investTaskEntity.setStatus(EnumTaskStatus.NEGOTIATING);
}
}
}
}
@@ -723,7 +738,7 @@ public class InvestBizServiceImpl implements InvestBizService {
//4、品牌
Map<Long, WxBrand> brandMap = getMap(brandService.getByIds(getIds(customers, InvestCustomerEntity::getBrandId)), WxBrand::getId);
//5、用户
Map<Long, MallUserInfo> usersMap = getMap(userInfoService.getByIds(getIds(demandList,InvestDemandEntity::getOwner)), MallUserInfo::getId);
Map<Long, MallUserInfo> usersMap = getMap(userInfoService.getByIds(getIds(demandList, InvestDemandEntity::getOwner)), MallUserInfo::getId);

List<InvestDemandVo> resultList = new ArrayList<>();
for (InvestCustomerEntity costomerItem : customers) {
@@ -753,8 +768,8 @@ public class InvestBizServiceImpl implements InvestBizService {
}

private <T, R> Map<R, T> getMap(Collection<T> dataList, Function<T, R> keyMapper) {
if(CollectionUtils.isEmpty(dataList)) {
return new HashMap<>() ;
if (CollectionUtils.isEmpty(dataList)) {
return new HashMap<>();
}
return InvestHelper.getMap(dataList, keyMapper);
}


Loading…
Cancel
Save