diff --git a/mallinkService/src/main/java/com/iformall/domain/po/invest/InvestTaskEntity.java b/mallinkService/src/main/java/com/iformall/domain/po/invest/InvestTaskEntity.java index d9edb8df0..489ea781f 100755 --- a/mallinkService/src/main/java/com/iformall/domain/po/invest/InvestTaskEntity.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/invest/InvestTaskEntity.java @@ -50,10 +50,13 @@ public class InvestTaskEntity extends InvestBaseEntity { */ @io.swagger.annotations.ApiModelProperty(value = "任务设定条件", name = "content",example = "{" + "\"business\": 1," + - " \"lastDate\": \"2018-10-01 12:18:48\",\"contractId\":222222222222" + + "\"contractId\":222222222222" + "}") private String content; + @io.swagger.annotations.ApiModelProperty(value = "最晚出租时间", name = "lastTime", example = "2018-10-01",readOnly = true) + private Date lastTime; + /** * 更新时间 */ diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxRentContractMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxRentContractMapper.java index 910827642..c0d007443 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxRentContractMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxRentContractMapper.java @@ -5,7 +5,9 @@ import com.iformall.domain.po.WxBillRent; import com.iformall.domain.po.WxBusiness; import com.iformall.domain.po.WxRentContract; import com.iformall.domain.vo.WxRentPropertyContractVo; +import org.apache.ibatis.annotations.Param; +import java.util.Collection; import java.util.List; import java.util.Map; @@ -58,6 +60,8 @@ public interface WxRentContractMapper extends CommonMapper List selectRentContractByShopId(WxRentContract record); + List selectRentContractByShopIds(@Param("shopIds") Collection shopIds, @Param("shopIdsRegexp") String shopIdsRegexp); + int hasContractNumber(WxRentContract wxRentContract); Integer getShopType(WxRentContract wxRentContract); diff --git a/mallinkService/src/main/java/com/iformall/service/WxRentContractService.java b/mallinkService/src/main/java/com/iformall/service/WxRentContractService.java index db4c718bc..ebe2ada4e 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxRentContractService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxRentContractService.java @@ -1,13 +1,11 @@ package com.iformall.service; -import com.github.pagehelper.PageInfo; import com.iformall.common.ResultData; import com.iformall.domain.po.*; -import com.iformall.domain.vo.WxRentPropertyContractVo; -import io.swagger.models.auth.In; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.util.Collection; import java.util.Date; import java.util.List; import java.util.Map; @@ -96,4 +94,6 @@ public interface WxRentContractService { WxRentContract getByBill(WxBillRent billRent); + Map selectRentContractByShopIds(Collection shopIds, String shopIdsRegexp); + } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java index 3e4c8a263..eedcc1c67 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java @@ -2488,4 +2488,34 @@ public class WxRentContractServiceImpl implements WxRentContractService { public WxRentContract getByBill(WxBillRent billRent) { return wxRentContractMapper.getByBill(billRent); } + + @Override + public Map selectRentContractByShopIds(Collection shopIds, String shopIdsRegexp) { + List list = wxRentContractMapper.selectRentContractByShopIds(shopIds, shopIdsRegexp); + Map allShopContract = new HashMap<>(); + for (WxRentContract wxRentContract : list) { + if (wxRentContract.getRentShopType().equals(EnumRentShopType.SHOP.getCode())) { + String rentInfo = wxRentContract.getRentInfo(); + JSONArray rentInfoArray = JSONArray.parseArray(rentInfo); + int size = rentInfoArray.size(); + //查询rent_info 包括 shopId + for (int i = 0; i < size; i++) { + JSONObject rentInfoObject = rentInfoArray.getJSONObject(i); + WxRentContract rentContract = new WxRentContract(); + rentContract.setRentalStartDate(wxRentContract.getRentalStartDate()); + rentContract.setRentalEndDate(wxRentContract.getRentalEndDate()); + Long shopId = rentInfoObject.getLong("shopId"); + if (Objects.isNull(shopId) || !shopIdsRegexp.contains(String.valueOf(shopId))) { + continue; + } + rentContract.setShopId(shopId); + allShopContract.put(shopId, rentContract); + } + } + if (shopIds.contains(wxRentContract.getShopId())) { + allShopContract.put(wxRentContract.getShopId(), wxRentContract); + } + } + return allShopContract; + } } diff --git a/mallinkService/src/main/java/com/iformall/service/invest/InvestHelper.java b/mallinkService/src/main/java/com/iformall/service/invest/InvestHelper.java index 7625e2d30..c159b5eb5 100644 --- a/mallinkService/src/main/java/com/iformall/service/invest/InvestHelper.java +++ b/mallinkService/src/main/java/com/iformall/service/invest/InvestHelper.java @@ -19,6 +19,7 @@ import java.util.List; import java.util.Map; import java.util.Objects; import java.util.function.Function; +import java.util.function.Predicate; import java.util.stream.Collectors; public class InvestHelper { @@ -174,4 +175,8 @@ public class InvestHelper { public static Collection getIds(Collection dataList, Function mapper) { return dataList.parallelStream().map(mapper).collect(Collectors.toList()); } + + public static Collection getIds(Collection dataList, Predicate predicate,Function mapper) { + return dataList.parallelStream().filter(predicate).map(mapper).collect(Collectors.toList()); + } } diff --git a/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBizServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBizServiceImpl.java index 403c62abe..98e4207cf 100644 --- a/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBizServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBizServiceImpl.java @@ -9,11 +9,10 @@ import com.iformall.domain.dto.InvestTaskDto; import com.iformall.domain.po.*; import com.iformall.domain.po.invest.*; import com.iformall.domain.vo.invest.*; -import com.iformall.enums.EnumFollowType; -import com.iformall.enums.EnumInvestUserType; -import com.iformall.enums.EnumNegotiationType; +import com.iformall.enums.*; import com.iformall.service.MallUserInfoService; import com.iformall.service.WxBrandService; +import com.iformall.service.WxRentContractService; import com.iformall.service.WxShopService; import com.iformall.service.invest.*; import org.apache.commons.collections.CollectionUtils; @@ -53,6 +52,8 @@ public class InvestBizServiceImpl implements InvestBizService { private WxBrandService brandService; @Autowired private MallUserInfoService userInfoService; + @Autowired + private WxRentContractService rentContractService; @Override public InvestPageResult queryPageDemand(InvestDemandQuery params) { @@ -140,9 +141,24 @@ public class InvestBizServiceImpl implements InvestBizService { Collection taskList = taskPage.getRecords(); //2、目标信息 Collection shops = shopService.getByIds(getIds(taskList, InvestTaskEntity::getTargetId)); + //3、商品合同信息 + Map shopContractMap = new HashMap<>(); + if (CollectionUtils.isNotEmpty(shops)) { + Collection shopPointIds = buildShopContractQuery(shops, EnumRentShopType.POINT); + Collection shopIds = buildShopContractQuery(shops, EnumRentShopType.SHOP); + shopContractMap = rentContractService.selectRentContractByShopIds(shopPointIds, StringUtils.join(shopIds, "|")); + } + for (WxShop shop : shops) { + WxRentContract contract = shopContractMap.get(shop.getId()); + if (Objects.nonNull(contract)) { + shop.setStartdate(contract.getRentalStartDate()); + shop.setEnddate(contract.getEndDate()); + } + } + Map shopsMap = getMap(shops, WxShop::getId); - //3、用户信息 - Map usersMap = getMap(this.queryUserList(), MallUserInfo::getId); + //4、用户信息 + Map usersMap = getMap(this.queryUserList(null), MallUserInfo::getId); List resultList = new ArrayList<>(); for (InvestTaskEntity item : taskList) { WxShop shop = shopsMap.get(item.getTargetId()); @@ -153,6 +169,17 @@ public class InvestBizServiceImpl implements InvestBizService { return investPage; } + private Collection buildShopContractQuery(Collection shops, EnumRentShopType shopType) { + Collection shopIds = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(shops)) { + shopIds = InvestHelper.getIds(shops, wxShop -> Objects.equals(wxShop.getType(), shopType.getCode()), WxShop::getId); + } + if (CollectionUtils.isEmpty(shopIds)) { + shopIds.add(00L); + } + return shopIds; + } + private InvestTaskDto doConvertTask(InvestTaskQuery params) { InvestTaskEntity task = new InvestTaskEntity(); @@ -195,7 +222,7 @@ public class InvestBizServiceImpl implements InvestBizService { Collection recordList = recordPage.getRecords(); //2、用户信息 - Map usersMap = getMap(this.queryUserList(), MallUserInfo::getId); + Map usersMap = getMap(this.queryUserList(null), MallUserInfo::getId); //3、客户 Collection customers = customerService.listByIds(getIds(recordList, InvestFollowRecordEntity::getCustomerId)); @@ -292,8 +319,14 @@ public class InvestBizServiceImpl implements InvestBizService { @Override public List queryUserList() { + return queryUserList(EnumInvestUserType.USER); + } + + public List queryUserList(EnumInvestUserType userType) { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.eq(MallUserInfo::getInvestRule, EnumInvestUserType.USER.getCode()); + if (Objects.nonNull(userType)) { + queryWrapper.eq(MallUserInfo::getInvestRule, userType.getCode()); + } return userInfoService.selectList(queryWrapper); } @@ -329,7 +362,7 @@ public class InvestBizServiceImpl implements InvestBizService { InvestDemandEntity demandEntity = demandService.getByCustomerId(customerEntity.getId()); WxBrand brand = brandService.getById(customerEntity.getBrandId()); WxShop shop = shopService.getById(demandEntity.getTargetId()); - Map usersMap = getMap(this.queryUserList(), MallUserInfo::getId); + Map usersMap = getMap(this.queryUserList(null), MallUserInfo::getId); return buildDemindItem(demandEntity, customerEntity, brand, shop, usersMap); } @@ -337,7 +370,7 @@ public class InvestBizServiceImpl implements InvestBizService { public InvestTaskVo findTaskById(Long id) { InvestTaskEntity taskEntity = taskService.getByIdNotNull(id); WxShop shop = shopService.getById(taskEntity.getTargetId()); - Map usersMap = getMap(this.queryUserList(), MallUserInfo::getId); + Map usersMap = getMap(this.queryUserList(null), MallUserInfo::getId); return buildTaskItem(taskEntity, shop, usersMap); } @@ -422,7 +455,7 @@ public class InvestBizServiceImpl implements InvestBizService { @Override public InvestFollowRecordVo findFollowRecordById(Long id) { InvestFollowRecordEntity followRecordEntity = followRecordService.getByIdNotNull(id); - Map usersMap = getMap(this.queryUserList(), MallUserInfo::getId); + Map usersMap = getMap(this.queryUserList(null), MallUserInfo::getId); InvestCustomerEntity customerEntity = customerService.getByIdNotNull(followRecordEntity.getCustomerId()); WxBrand brand = brandService.getById(customerEntity.getBrandId()); return buildFollowRecordItem(usersMap, followRecordEntity, customerEntity, brand); diff --git a/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml b/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml index 058cc0eaa..7b1031bc5 100644 --- a/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml @@ -432,5 +432,17 @@ select 2 type,c.`rental_start_date`,c.`rental_end_date`,c.id id from wx_merchant m left join wx_property_contract c on(m.id = c.merchant_id) where m.business_id = #{id} and c.price is not null and c.`rental_start_date` is not null and c.`rental_end_date` is not null +