| @@ -170,10 +170,15 @@ public class WxUserGrantController extends BaseController { | |||
| } | |||
| WxMall wxMall = mallService.getById(Long.valueOf(wxAuthorizerInfo.getTenantId())); | |||
| resultMap.put("selectedMall", wxMall.getTenantId()); | |||
| // 集团版,获取子集团list | |||
| List<WxMall> mallList = null; | |||
| if(StringUtils.isNotBlank(wxMall.getParentTenantId())){ | |||
| mallList = mallService.getSubByParentTenantId(wxMall.getParentTenantId()); | |||
| resultMap.put("subMalls", JSON.toJSONString(mallList)); | |||
| } | |||
| if (wxAuthorizerInfo.getGroupSupport().equals(EnumGroupSupport.SUPPORT.getCode())) { | |||
| mallList = mallService.getSubByParentTenantId(wxAuthorizerInfo.getTenantId()); | |||
| mallList = mallService.getSubByParentTenantId(wxMall.getTenantId()); | |||
| resultMap.put("subMalls", JSON.toJSONString(mallList)); | |||
| } | |||
| @@ -275,27 +280,27 @@ public class WxUserGrantController extends BaseController { | |||
| } | |||
| // 老用户,给出来已选中的mall | |||
| if (mallList != null) { | |||
| WxMall selectedMall = null; | |||
| if (StringUtils.isNotBlank(oldUser.getParentTenantId())) { | |||
| final String lastSubTenant = oldUser.getTenantId(); | |||
| List<WxMall> selMallList = mallList.stream().filter(ml -> ml.getTenantId().equalsIgnoreCase(lastSubTenant)).collect(Collectors.toList()); | |||
| if (selMallList.size() > 0) { | |||
| selectedMall = selMallList.get(0); | |||
| } | |||
| } | |||
| if (selectedMall == null){ | |||
| WxMall firstMall = mallList.get(0); | |||
| if (firstMall != null) { | |||
| selectedMall = firstMall; | |||
| } | |||
| } | |||
| if (selectedMall != null) { | |||
| request.setAttribute(Constant.TENANT_ID, selectedMall.getTenantId()); | |||
| resultMap.put("selectedMall", selectedMall.getTenantId()); | |||
| // oldUser.setParentTenantId(selectedMall.getParentTenantId()); | |||
| } | |||
| } | |||
| // if (mallList != null) { | |||
| // WxMall selectedMall = null; | |||
| // if (StringUtils.isNotBlank(oldUser.getParentTenantId())) { | |||
| // final String lastSubTenant = oldUser.getTenantId(); | |||
| // List<WxMall> selMallList = mallList.stream().filter(ml -> ml.getTenantId().equalsIgnoreCase(lastSubTenant)).collect(Collectors.toList()); | |||
| // if (selMallList.size() > 0) { | |||
| // selectedMall = selMallList.get(0); | |||
| // } | |||
| // } | |||
| // if (selectedMall == null){ | |||
| // WxMall firstMall = mallList.get(0); | |||
| // if (firstMall != null) { | |||
| // selectedMall = firstMall; | |||
| // } | |||
| // } | |||
| // if (selectedMall != null) { | |||
| // request.setAttribute(Constant.TENANT_ID, selectedMall.getTenantId()); | |||
| // resultMap.put("selectedMall", selectedMall.getTenantId()); | |||
| //// oldUser.setParentTenantId(selectedMall.getParentTenantId()); | |||
| // } | |||
| // } | |||
| oldUser.setRegisterIp(ipaddress); | |||
| oldUser.setSessionKey(session_key); | |||
| @@ -374,15 +379,15 @@ public class WxUserGrantController extends BaseController { | |||
| if(StringUtils.isNotBlank(newUser.getParentTenantId())){ | |||
| request.setAttribute(Constant.PARENT_TENANT_ID, newUser.getParentTenantId()); | |||
| } | |||
| if (mallList != null) { | |||
| WxMall firstMall = mallList.get(0); | |||
| if (firstMall != null) { | |||
| // 默认选中第一个mall, 或者经纬度最近的那个 | |||
| request.setAttribute(Constant.TENANT_ID, firstMall.getTenantId()); | |||
| resultMap.put("selectedMall", firstMall.getTenantId()); | |||
| newUser.setParentTenantId(firstMall.getTenantId()); | |||
| } | |||
| } | |||
| // if (mallList != null) { | |||
| // WxMall firstMall = mallList.get(0); | |||
| // if (firstMall != null) { | |||
| // // 默认选中第一个mall, 或者经纬度最近的那个 | |||
| // request.setAttribute(Constant.TENANT_ID, firstMall.getTenantId()); | |||
| // resultMap.put("selectedMall", firstMall.getTenantId()); | |||
| // newUser.setParentTenantId(firstMall.getTenantId()); | |||
| // } | |||
| // } | |||
| // 登录后处理 | |||
| int score = wxCUserService.actionAfterLogin(newUser, null); | |||
| @@ -7,6 +7,7 @@ import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.mapper.WxMallMapper; | |||
| import com.iformall.service.WxPropertyContractService; | |||
| import com.iformall.service.WxRentContractService; | |||
| import lombok.extern.slf4j.Slf4j; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| @@ -18,11 +19,11 @@ import java.util.List; | |||
| /** | |||
| * @author gongbiao | |||
| */ | |||
| @Slf4j | |||
| @Component | |||
| public class ContractSchedule { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxRentContractService wxRentContractService; | |||
| @@ -37,26 +38,24 @@ public class ContractSchedule { | |||
| * 凌晨5分 | |||
| */ | |||
| @Scheduled(cron = "0 5 0 * * ?") | |||
| public void sendMsg() { | |||
| logger.info("合同状态更新开始"); | |||
| public void updateContractStatus() { | |||
| log.info("合同状态更新开始"); | |||
| List<WxMall> wxMalls = wxMallMapper.findList(null); | |||
| for (WxMall wxMall : wxMalls) { | |||
| TenantEntity tenantEntity = wxMall.getTenantInfo(); | |||
| WxRentContract wxRentContract = new WxRentContract(); | |||
| wxRentContract.updateTenantInfo(tenantEntity); | |||
| logger.info("租赁合同状态更新开始"); | |||
| log.info("租赁合同状态更新开始"); | |||
| wxRentContractService.updateStatus(wxRentContract); | |||
| logger.info("租赁合同状态更新结束"); | |||
| log.info("租赁合同状态更新结束"); | |||
| WxPropertyContract wxPropertyContract = new WxPropertyContract(); | |||
| wxPropertyContract.updateTenantInfo(tenantEntity); | |||
| logger.info("物业合同状态更新开始"); | |||
| log.info("物业合同状态更新开始"); | |||
| wxPropertyContractService.updateStatus(wxPropertyContract); | |||
| logger.info("物业合同状态更新结束"); | |||
| log.info("物业合同状态更新结束"); | |||
| } | |||
| logger.info("合同状态更新结束"); | |||
| log.info("合同状态更新结束"); | |||
| } | |||
| @@ -149,4 +149,5 @@ public interface WxMerchantService { | |||
| List<WxMerchant> getMerchantList(WxMerchant wxMerchant); | |||
| void disableMerchat(Long id); | |||
| } | |||
| @@ -252,23 +252,24 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||
| return; | |||
| } | |||
| //是否有租赁合同 | |||
| //查询该商户下是否有计租中和已签约未计租类型的合同 | |||
| WxRentContract wxRentContract = new WxRentContract(); | |||
| wxRentContract.setMerchantId(id); | |||
| long countRentContract = wxRentContractMapper.selectList(new QueryWrapper<>(wxRentContract)).parallelStream(). | |||
| // filter(c -> c.getStatus().equals(EnumRentContractStatus.READY_FOR_PAING.getCode()) || | |||
| // c.getStatus().equals(EnumRentContractStatus.PAING.getCode()) || | |||
| // c.getStatus().equals(EnumRentContractStatus.CONTRACT_END_SOON.getCode())).count(); | |||
| filter(c -> c.getStatus().equals(EnumRentContractStatus.READY_FOR_PAING.getCode()) || | |||
| c.getStatus().equals(EnumRentContractStatus.PAING.getCode())).count(); | |||
| filter(c -> c.getStatus().equals(EnumRentContractStatus.READY_FOR_PAING.getCode()) || | |||
| c.getStatus().equals(EnumRentContractStatus.PAING.getCode())).count(); | |||
| //是否有物业合同 | |||
| WxPropertyContract wxPropertyContract = new WxPropertyContract(); | |||
| wxPropertyContract.setMerchantId(id); | |||
| long countPropertyContract = wxPropertyContractMapper.selectList(new QueryWrapper<>(wxPropertyContract)).parallelStream(). | |||
| // filter(c -> c.getStatus().equals(EnumRentContractStatus.SIGNED_RENT_UNPAID.getCode()) || | |||
| // c.getStatus().equals(EnumRentContractStatus.RENT_PAID.getCode()) || | |||
| // c.getStatus().equals(EnumRentContractStatus.CONTRACT_END_SOON.getCode())).count(); | |||
| filter(c -> c.getStatus().equals(EnumRentContractStatus.READY_FOR_PAING.getCode()) || | |||
| c.getStatus().equals(EnumRentContractStatus.PAING.getCode())).count(); | |||
| filter(c -> c.getStatus().equals(EnumRentContractStatus.READY_FOR_PAING.getCode()) || | |||
| c.getStatus().equals(EnumRentContractStatus.PAING.getCode())).count(); | |||
| //商户状态停用-没有租赁合同和物业合同才允许停用 | |||
| if (countRentContract == 0 || countPropertyContract == 0){ | |||
| wxMerchant.setStatus(EnumMerchantStatus.NOT_VALID.getCode()); | |||
| wxMerchantMapper.updateById(wxMerchant); | |||
| } | |||
| //解绑商铺-没有租赁合同或物业合同才可以 | |||
| if (countRentContract == 0 || countPropertyContract == 0) { | |||
| wxMerchant.setStatus(EnumMerchantStatus.NOT_VALID.getCode()); | |||
| @@ -812,4 +813,46 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||
| public List<WxMerchant> getMerchantList(WxMerchant wxMerchant) { | |||
| return wxMerchantMapper.getMerchantList(wxMerchant); | |||
| } | |||
| @Override | |||
| public void disableMerchat(Long id) { | |||
| WxMerchant wxMerchant = wxMerchantMapper.selectById(id); | |||
| if (wxMerchant != null){ | |||
| //查询该商户下是否有计租中和已签约未计租类型的合同 | |||
| WxRentContract wxRentContract = new WxRentContract(); | |||
| wxRentContract.setMerchantId(id); | |||
| long countRentContract = wxRentContractMapper.selectList(new QueryWrapper<>(wxRentContract)).parallelStream(). | |||
| filter(c -> c.getStatus().equals(EnumRentContractStatus.READY_FOR_PAING.getCode()) || | |||
| c.getStatus().equals(EnumRentContractStatus.PAING.getCode())).count(); | |||
| //是否有物业合同 | |||
| WxPropertyContract wxPropertyContract = new WxPropertyContract(); | |||
| wxPropertyContract.setMerchantId(id); | |||
| long countPropertyContract = wxPropertyContractMapper.selectList(new QueryWrapper<>(wxPropertyContract)).parallelStream(). | |||
| filter(c -> c.getStatus().equals(EnumRentContractStatus.READY_FOR_PAING.getCode()) || | |||
| c.getStatus().equals(EnumRentContractStatus.PAING.getCode())).count(); | |||
| //没有租赁合同和物业合同才允许停用商户和解绑商铺 | |||
| if (countRentContract == 0 || countPropertyContract == 0){ | |||
| //停用商户 | |||
| wxMerchant.setStatus(EnumMerchantStatus.NOT_VALID.getCode()); | |||
| wxMerchantMapper.updateById(wxMerchant); | |||
| //解绑商铺 | |||
| WxMerchantShop wxMerchantShopQuery = new WxMerchantShop(); | |||
| wxMerchantShopQuery.updateTenantInfo(wxMerchant); | |||
| wxMerchantShopQuery.setMerchantId(wxMerchant.getId()); | |||
| wxMerchantShopQuery.setIsDel(EnumDelStatus.NOT_DEL.getCode()); | |||
| List<WxMerchantShop> wxMerchantShopList = wxMerchantShopMapper.findList(wxMerchantShopQuery); | |||
| for (WxMerchantShop wxMerchantShop : wxMerchantShopList) { | |||
| wxMerchantShop.setIsDel(EnumDelStatus.DEL.getCode()); | |||
| wxMerchantShopMapper.updateById(wxMerchantShop); | |||
| //更新商铺状态 | |||
| WxShop wxShop = new WxShop(); | |||
| wxShop.updateTenantInfo(wxMerchant); | |||
| wxShop.setId(wxMerchantShop.getShopId()); | |||
| wxShop.setStatus(EnumShopStatus.NOT_RENT.getCode()); | |||
| wxShopMapper.updateById(wxShop); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -1593,7 +1593,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| WxMerchant merchant = wxMerchantMapper.selectById((Long) merchantId); | |||
| Integer status = merchant.getStatus(); | |||
| if (status.equals(EnumMerchantStatus.VALID.getCode())) { | |||
| //wxMerchantService.disable((Long) merchantId); | |||
| wxMerchantService.disableMerchat((Long) merchantId); | |||
| } | |||
| } | |||
| } | |||