| @@ -60,7 +60,7 @@ public class InvestTaskController extends InvestBaseController { | |||||
| @SystemServiceLog | @SystemServiceLog | ||||
| @PostMapping("/save") | @PostMapping("/save") | ||||
| public InvestResultData save(@RequestBody InvestTaskEntity investTask) { | public InvestResultData save(@RequestBody InvestTaskEntity investTask) { | ||||
| return execute(investTask, p -> investTaskService.save(p)); | |||||
| return execute(investTask, p -> bizService.saveTask(p)); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -69,7 +69,7 @@ public class InvestTaskController extends InvestBaseController { | |||||
| @SystemServiceLog | @SystemServiceLog | ||||
| @PostMapping("/update") | @PostMapping("/update") | ||||
| public InvestResultData update(@RequestBody InvestTaskEntity investTask) { | public InvestResultData update(@RequestBody InvestTaskEntity investTask) { | ||||
| return execute(investTask, p -> investTaskService.updateById(p)); | |||||
| return execute(investTask, p -> bizService.updateTask(p)); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -33,7 +33,7 @@ public class InvestPageResult<T> { | |||||
| public void setRecords(Collection<T> records) { | public void setRecords(Collection<T> records) { | ||||
| this.records = records; | this.records = records; | ||||
| if (total > (records.size() + current * size)) { | |||||
| if (total > (records.size() + (current-1) * size)) { | |||||
| hasNextPage = true; | hasNextPage = true; | ||||
| } | } | ||||
| } | } | ||||
| @@ -60,7 +60,8 @@ public interface WxRentContractMapper extends CommonMapper<WxRentContract, Long> | |||||
| List<WxRentContract> selectRentContractByShopId(WxRentContract record); | List<WxRentContract> selectRentContractByShopId(WxRentContract record); | ||||
| List<WxRentContract> selectRentContractByShopIds(@Param("shopIds") Collection<Long> shopIds, @Param("shopIdsRegexp") String shopIdsRegexp); | |||||
| List<WxRentContract> selectRentContractByShopIds(@Param("shopIds") Collection<Long> shopIds, | |||||
| @Param("shopIdsRegexp") String shopIdsRegexp,@Param("tenantId") String tenantId); | |||||
| int hasContractNumber(WxRentContract wxRentContract); | int hasContractNumber(WxRentContract wxRentContract); | ||||
| @@ -70,6 +71,7 @@ public interface WxRentContractMapper extends CommonMapper<WxRentContract, Long> | |||||
| WxRentContract getByBill(WxBillRent billRent); | WxRentContract getByBill(WxBillRent billRent); | ||||
| int selectContractCountByShopId(WxRentContract wxRentContract); | |||||
| int getShopCountMax(); | int getShopCountMax(); | ||||
| List<Map<String,Object>> queryContractByBus(WxBusiness wxBusiness); | List<Map<String,Object>> queryContractByBus(WxBusiness wxBusiness); | ||||
| @@ -94,6 +94,7 @@ public interface WxRentContractService { | |||||
| WxRentContract getByBill(WxBillRent billRent); | WxRentContract getByBill(WxBillRent billRent); | ||||
| Map<Long,WxRentContract> selectRentContractByShopIds(Collection<Long> shopIds, String shopIdsRegexp); | |||||
| Map<Long,WxRentContract> selectRentContractByShopIds(Collection<Long> shopIds, String shopIdsRegexp,String tenantId); | |||||
| int selectContractCountByShopId(WxRentContract wxRentContract); | |||||
| } | } | ||||
| @@ -2492,8 +2492,8 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public Map<Long, WxRentContract> selectRentContractByShopIds(Collection<Long> shopIds, String shopIdsRegexp) { | |||||
| List<WxRentContract> list = wxRentContractMapper.selectRentContractByShopIds(shopIds, shopIdsRegexp); | |||||
| public Map<Long, WxRentContract> selectRentContractByShopIds(Collection<Long> shopIds, String shopIdsRegexp,String tenantId) { | |||||
| List<WxRentContract> list = wxRentContractMapper.selectRentContractByShopIds(shopIds, shopIdsRegexp,tenantId); | |||||
| List<String> shopIdArr = Arrays.asList(StringUtils.split(shopIdsRegexp,"|")) ; | List<String> shopIdArr = Arrays.asList(StringUtils.split(shopIdsRegexp,"|")) ; | ||||
| Map<Long, WxRentContract> allShopContract = new HashMap<>(); | Map<Long, WxRentContract> allShopContract = new HashMap<>(); | ||||
| for (WxRentContract wxRentContract : list) { | for (WxRentContract wxRentContract : list) { | ||||
| @@ -2522,4 +2522,9 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| } | } | ||||
| return allShopContract; | return allShopContract; | ||||
| } | } | ||||
| @Override | |||||
| public int selectContractCountByShopId(WxRentContract wxRentContract) { | |||||
| return wxRentContractMapper.selectContractCountByShopId(wxRentContract) ; | |||||
| } | |||||
| } | } | ||||
| @@ -3,6 +3,7 @@ package com.iformall.service.invest; | |||||
| import com.iformall.domain.dto.InvestDemandDto; | import com.iformall.domain.dto.InvestDemandDto; | ||||
| import com.iformall.domain.po.MallUserInfo; | import com.iformall.domain.po.MallUserInfo; | ||||
| import com.iformall.domain.po.invest.InvestMessageEntity; | import com.iformall.domain.po.invest.InvestMessageEntity; | ||||
| import com.iformall.domain.po.invest.InvestTaskEntity; | |||||
| import com.iformall.domain.vo.invest.*; | import com.iformall.domain.vo.invest.*; | ||||
| import java.util.Collection; | import java.util.Collection; | ||||
| @@ -31,6 +32,10 @@ public interface InvestBizService { | |||||
| boolean updateCustomerAndDemand(InvestDemandDto customerDto) ; | boolean updateCustomerAndDemand(InvestDemandDto customerDto) ; | ||||
| boolean saveTask(InvestTaskEntity investTaskEntity) ; | |||||
| boolean updateTask(InvestTaskEntity investTaskEntity) ; | |||||
| InvestDemandVo findDemandById(Long id) ; | InvestDemandVo findDemandById(Long id) ; | ||||
| InvestTaskVo findTaskById(Long id) ; | InvestTaskVo findTaskById(Long id) ; | ||||
| @@ -152,7 +152,8 @@ public class InvestBizServiceImpl implements InvestBizService { | |||||
| if (CollectionUtils.isNotEmpty(shops)) { | if (CollectionUtils.isNotEmpty(shops)) { | ||||
| Collection<Long> shopPointIds = buildShopContractQuery(shops, EnumRentShopType.POINT); | Collection<Long> shopPointIds = buildShopContractQuery(shops, EnumRentShopType.POINT); | ||||
| Collection<Long> shopIds = buildShopContractQuery(shops, EnumRentShopType.SHOP); | Collection<Long> shopIds = buildShopContractQuery(shops, EnumRentShopType.SHOP); | ||||
| shopContractMap = rentContractService.selectRentContractByShopIds(shopPointIds, StringUtils.join(shopIds, "|")); | |||||
| shopContractMap = rentContractService.selectRentContractByShopIds(shopPointIds, StringUtils.join(shopIds, "|"), | |||||
| InvestUserContext.getUser().getTenantId()); | |||||
| } | } | ||||
| for (WxShop shop : shops) { | for (WxShop shop : shops) { | ||||
| WxRentContract contract = shopContractMap.get(shop.getId()); | WxRentContract contract = shopContractMap.get(shop.getId()); | ||||
| @@ -367,6 +368,18 @@ public class InvestBizServiceImpl implements InvestBizService { | |||||
| return demandService.updateById(demandEntity); | return demandService.updateById(demandEntity); | ||||
| } | } | ||||
| @Override | |||||
| public boolean saveTask(InvestTaskEntity investTaskEntity) { | |||||
| syncTargetStatus(investTaskEntity); | |||||
| return taskService.save(investTaskEntity); | |||||
| } | |||||
| @Override | |||||
| public boolean updateTask(InvestTaskEntity investTaskEntity) { | |||||
| syncTargetStatus(investTaskEntity); | |||||
| return taskService.updateById(investTaskEntity); | |||||
| } | |||||
| @Override | @Override | ||||
| public InvestDemandVo findDemandById(Long id) { | public InvestDemandVo findDemandById(Long id) { | ||||
| InvestCustomerEntity customerEntity = customerService.getByIdNotNull(id); | InvestCustomerEntity customerEntity = customerService.getByIdNotNull(id); | ||||
| @@ -472,6 +485,21 @@ public class InvestBizServiceImpl implements InvestBizService { | |||||
| return buildFollowRecordItem(usersMap, followRecordEntity, customerEntity, brand); | return buildFollowRecordItem(usersMap, followRecordEntity, customerEntity, brand); | ||||
| } | } | ||||
| 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); | |||||
| } else { | |||||
| if (StringUtils.isNotEmpty(investTaskEntity.getOwner())) { | |||||
| investTaskEntity.setStatus(EnumTaskStatus.NEGOTIATING); | |||||
| } | |||||
| } | |||||
| } | |||||
| private InvestFollowRecordVo buildFollowRecordItem(Map<Long, MallUserInfo> usersMap, InvestFollowRecordEntity item, | private InvestFollowRecordVo buildFollowRecordItem(Map<Long, MallUserInfo> usersMap, InvestFollowRecordEntity item, | ||||
| InvestCustomerEntity customerEntity, WxBrand brand) { | InvestCustomerEntity customerEntity, WxBrand brand) { | ||||
| List<MallUserInfo> ownerInfo = getMallUserInfos(usersMap, item); | List<MallUserInfo> ownerInfo = getMallUserInfos(usersMap, item); | ||||
| @@ -30,6 +30,7 @@ public class InvestTaskServiceImpl extends InvestBaseServiceImpl<InvestTaskDao, | |||||
| public boolean save(InvestTaskEntity entity) { | public boolean save(InvestTaskEntity entity) { | ||||
| super.saveAction(entity, this::checkBeforeSaveOrUpdate); | super.saveAction(entity, this::checkBeforeSaveOrUpdate); | ||||
| saveMessage(entity); | saveMessage(entity); | ||||
| //TODO 同步一下签约状态 | |||||
| return true; | return true; | ||||
| } | } | ||||
| @@ -38,6 +39,7 @@ public class InvestTaskServiceImpl extends InvestBaseServiceImpl<InvestTaskDao, | |||||
| public boolean update(InvestTaskEntity entity, Wrapper<InvestTaskEntity> updateWrapper) { | public boolean update(InvestTaskEntity entity, Wrapper<InvestTaskEntity> updateWrapper) { | ||||
| super.updateActon(entity, updateWrapper, this::checkBeforeSaveOrUpdate); | super.updateActon(entity, updateWrapper, this::checkBeforeSaveOrUpdate); | ||||
| saveMessage(entity); | saveMessage(entity); | ||||
| //TODO 同步一下签约状态 | |||||
| return true; | return true; | ||||
| } | } | ||||
| @@ -435,7 +435,7 @@ | |||||
| <select id="selectRentContractByShopIds" resultType="com.iformall.domain.po.WxRentContract"> | <select id="selectRentContractByShopIds" resultType="com.iformall.domain.po.WxRentContract"> | ||||
| SELECT rc.id,rc.rental_start_date,rc.rental_end_date,rc.`shop_id`,rc.`rent_shop_type`,rc.`rent_info` FROM | SELECT rc.id,rc.rental_start_date,rc.rental_end_date,rc.`shop_id`,rc.`rent_shop_type`,rc.`rent_info` FROM | ||||
| `wx_rent_contract` rc | `wx_rent_contract` rc | ||||
| WHERE rc.`status` IN (2,3,4) | |||||
| WHERE tenant_id = #{tenantId} AND rc.`status` IN (2,3,4) AND status!=7 | |||||
| AND ( (rc.`rent_shop_type`=2 AND rc.`shop_id` IN | AND ( (rc.`rent_shop_type`=2 AND rc.`shop_id` IN | ||||
| <foreach collection="shopIds" index="index" item="idItem" open="(" separator="," close=")"> | <foreach collection="shopIds" index="index" item="idItem" open="(" separator="," close=")"> | ||||
| #{idItem} | #{idItem} | ||||
| @@ -444,5 +444,18 @@ | |||||
| OR (rc.`rent_shop_type`=1 AND rc.`rent_info` REGEXP #{shopIdsRegexp}) | OR (rc.`rent_shop_type`=1 AND rc.`rent_info` REGEXP #{shopIdsRegexp}) | ||||
| ) | ) | ||||
| </select> | </select> | ||||
| <select id="selectContractCountByShopId" parameterType="com.iformall.domain.po.WxRentContract" resultType="int"> | |||||
| SELECT count(*) | |||||
| FROM wx_rent_contract | |||||
| WHERE tenant_id = #{tenantId} | |||||
| AND `status` = #{status} AND status!=7 | |||||
| AND ( | |||||
| `rent_shop_type` = 1 AND | |||||
| json_contains(json_extract(rent_info, '$[*].shopId'), concat('"', #{shopId}, '"')) | |||||
| OR | |||||
| `rent_shop_type` = 2 AND `shop_id` = #{shopId} | |||||
| ) | |||||
| </select> | |||||
| </mapper> | </mapper> | ||||