Przeglądaj źródła

[招商]adjust

release_toaliyun_real
Burce 6 lat temu
rodzic
commit
37bb58d165
3 zmienionych plików z 49 dodań i 23 usunięć
  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 Wyświetl plik

@@ -6,8 +6,10 @@ import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.Multimaps; import com.google.common.collect.Multimaps;
import com.iformall.common.ErrorCode; import com.iformall.common.ErrorCode;
import com.iformall.domain.po.invest.InvestBaseEntity; import com.iformall.domain.po.invest.InvestBaseEntity;
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 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;


@@ -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) { 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()); 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 Wyświetl plik

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

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


//3、商品合同信息 //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()); WxRentContract contract = shopContractMap.get(shop.getId());
if (Objects.nonNull(contract)) { if (Objects.nonNull(contract)) {
shopVo.setStartdate(contract.getRentalStartDate()); shopVo.setStartdate(contract.getRentalStartDate());
@@ -498,6 +497,12 @@ public class InvestBizServiceImpl implements InvestBizService {
return buildTaskItem(taskEntity, shopVo, usersMap); 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 @Override
public InvestRemindVo findRemindById(Long id) { public InvestRemindVo findRemindById(Long id) {
InvestRemindEntity remindEntity = remindService.getByIdNotNull(id); InvestRemindEntity remindEntity = remindService.getByIdNotNull(id);
@@ -574,16 +579,26 @@ public class InvestBizServiceImpl implements InvestBizService {
} }


private void syncTargetStatus(InvestTaskEntity investTaskEntity) { 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 { } 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、品牌 //4、品牌
Map<Long, WxBrand> brandMap = getMap(brandService.getByIds(getIds(customers, InvestCustomerEntity::getBrandId)), WxBrand::getId); Map<Long, WxBrand> brandMap = getMap(brandService.getByIds(getIds(customers, InvestCustomerEntity::getBrandId)), WxBrand::getId);
//5、用户 //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<>(); List<InvestDemandVo> resultList = new ArrayList<>();
for (InvestCustomerEntity costomerItem : customers) { 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) { 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); return InvestHelper.getMap(dataList, keyMapper);
} }


Ładowanie…
Anuluj
Zapisz