|
|
@@ -11,10 +11,7 @@ import com.iformall.enums.EnumBillRentStatus; |
|
|
import com.iformall.enums.EnumRentContractStatus; |
|
|
import com.iformall.enums.EnumRentContractStatus; |
|
|
import com.iformall.enums.EnumShopStatus; |
|
|
import com.iformall.enums.EnumShopStatus; |
|
|
import com.iformall.exception.MallinkException; |
|
|
import com.iformall.exception.MallinkException; |
|
|
import com.iformall.mapper.WxBillPropertyDepositMapper; |
|
|
|
|
|
import com.iformall.mapper.WxBillPropertyMapper; |
|
|
|
|
|
import com.iformall.mapper.WxPropertyContractMapper; |
|
|
|
|
|
import com.iformall.mapper.WxShopMapper; |
|
|
|
|
|
|
|
|
import com.iformall.mapper.*; |
|
|
import com.iformall.service.WxPropertyContractService; |
|
|
import com.iformall.service.WxPropertyContractService; |
|
|
import com.iformall.utils.Constant; |
|
|
import com.iformall.utils.Constant; |
|
|
import org.apache.shiro.SecurityUtils; |
|
|
import org.apache.shiro.SecurityUtils; |
|
|
@@ -50,11 +47,14 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService |
|
|
@Autowired |
|
|
@Autowired |
|
|
WxBillPropertyDepositMapper wxBillPropertyDepositMapper; |
|
|
WxBillPropertyDepositMapper wxBillPropertyDepositMapper; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
WxMerchantMapper wxMerchantMapper; |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public Map<String, Object> listAsPage(WxPropertyContract record, Integer pageIndex, Integer pageSize) { |
|
|
public Map<String, Object> listAsPage(WxPropertyContract record, Integer pageIndex, Integer pageSize) { |
|
|
Object rentContractStatusInfo = getRentContractStatusInfo(record.getTenantId()); |
|
|
Object rentContractStatusInfo = getRentContractStatusInfo(record.getTenantId()); |
|
|
PageHelper.startPage(pageIndex, pageSize); |
|
|
PageHelper.startPage(pageIndex, pageSize); |
|
|
List<Map<String, Object>> rentContractData = wxPropertyContractMapper.queryRentContractData(record); |
|
|
|
|
|
|
|
|
List<Map<String, Object>> rentContractData = wxPropertyContractMapper.queryPropertyContractData(record); |
|
|
PageInfo<Map<String, Object>> pageInfo = new PageInfo<>(rentContractData); |
|
|
PageInfo<Map<String, Object>> pageInfo = new PageInfo<>(rentContractData); |
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
result.put("rentContractStatusInfo", rentContractStatusInfo); |
|
|
result.put("rentContractStatusInfo", rentContractStatusInfo); |
|
|
@@ -64,14 +64,89 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public WxPropertyContract getById(Long id) { |
|
|
|
|
|
return wxPropertyContractMapper.selectByPrimaryKey(id); |
|
|
|
|
|
|
|
|
public ResultData getById(Long id){ |
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
|
|
WxPropertyContract wxPropertyContract = wxPropertyContractMapper.selectByPrimaryKey(id); |
|
|
|
|
|
wxPropertyContract.setPrice(wxPropertyContract.getPrice() != null ? wxPropertyContract.getPrice() / 100 : 0); |
|
|
|
|
|
wxPropertyContract.setDeposit(wxPropertyContract.getDeposit() != null ? wxPropertyContract.getDeposit() / 100 : 0); |
|
|
|
|
|
|
|
|
|
|
|
result.put("wxPropertyContract", wxPropertyContract); |
|
|
|
|
|
//关联的商户 |
|
|
|
|
|
if (wxPropertyContract.getMerchantId() != null) { |
|
|
|
|
|
WxMerchant wxMerchant = wxMerchantMapper.selectByPrimaryKey(wxPropertyContract.getMerchantId()); |
|
|
|
|
|
result.put("wxMerchant", wxMerchant); |
|
|
|
|
|
} else { |
|
|
|
|
|
result.put("wxMerchant", null); |
|
|
|
|
|
} |
|
|
|
|
|
//关联的店铺 |
|
|
|
|
|
if (wxPropertyContract.getShopId() != null) { |
|
|
|
|
|
List<WxShop> list = new ArrayList<>(); |
|
|
|
|
|
WxShop wxShop = wxShopMapper.selectByPrimaryKey(wxPropertyContract.getShopId()); |
|
|
|
|
|
list.add(wxShop); |
|
|
|
|
|
result.put("wxShops", list); |
|
|
|
|
|
} else { |
|
|
|
|
|
result.put("wxShops", Collections.EMPTY_LIST); |
|
|
|
|
|
} |
|
|
|
|
|
return new ResultData(Result.SUCCESS, "查询成功", result); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public ResultData saveOrUpdate(WxPropertyContract record) { |
|
|
public ResultData saveOrUpdate(WxPropertyContract record) { |
|
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
|
//保存租赁合同信息 |
|
|
|
|
|
if (record.getId() == null) { |
|
|
|
|
|
final IdWorker idWorker = IdWorker.get(); |
|
|
|
|
|
record.setId(idWorker.nextId()); |
|
|
|
|
|
Calendar instance = Calendar.getInstance(); |
|
|
|
|
|
instance.setTime(record.getRentalStartDate()); |
|
|
|
|
|
instance.add(Calendar.MONTH, record.getLease()); |
|
|
|
|
|
instance.add(Calendar.DAY_OF_MONTH, -1); |
|
|
|
|
|
record.setRentalEndDate(instance.getTime()); |
|
|
|
|
|
Date date = new Date(); |
|
|
|
|
|
record.setCreatetime(date); |
|
|
|
|
|
record.setUpdatetime(date); |
|
|
|
|
|
try { |
|
|
|
|
|
wxPropertyContractMapper.insertSelective(record); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
logger.error("保存物业合同信息失败,e:" + e.getMessage()); |
|
|
|
|
|
throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); |
|
|
|
|
|
} |
|
|
|
|
|
return new ResultData(Result.SUCCESS, "保存物业合同信息成功", record); |
|
|
|
|
|
} else {//更新租赁合同信息 |
|
|
|
|
|
Calendar instance = Calendar.getInstance(); |
|
|
|
|
|
instance.setTime(record.getRentalStartDate()); |
|
|
|
|
|
instance.add(Calendar.MONTH, record.getLease()); |
|
|
|
|
|
instance.add(Calendar.DAY_OF_MONTH, -1); |
|
|
|
|
|
record.setRentalEndDate(instance.getTime()); |
|
|
|
|
|
record.setPrice(record.getPrice() != null ? record.getPrice() * 100 : 0); |
|
|
|
|
|
record.setDeposit(record.getDeposit() != null ? record.getDeposit() * 100 : 0); |
|
|
|
|
|
record.setUpdatetime(new Date()); |
|
|
|
|
|
try { |
|
|
|
|
|
wxPropertyContractMapper.updateByPrimaryKeySelective(record); |
|
|
|
|
|
|
|
|
|
|
|
//建立账单 |
|
|
|
|
|
if (record.getMerchantId() != null && record.getStatus().equals(EnumRentContractStatus.SIGNED_RENT_UNPAID.getCode()) |
|
|
|
|
|
&& record.getReceivePeriod() != null) { |
|
|
|
|
|
WxBillProperty wxBillProperty = new WxBillProperty(); |
|
|
|
|
|
wxBillProperty.setMerchantId(record.getMerchantId()); |
|
|
|
|
|
List<Map<String, Object>> billPropertyList = wxBillPropertyMapper.queryBillPropertyList(wxBillProperty); |
|
|
|
|
|
if (billPropertyList.size() == 0) { |
|
|
|
|
|
WxMerchant wxMerchant = new WxMerchant(); |
|
|
|
|
|
wxMerchant.setId(record.getMerchantId()); |
|
|
|
|
|
wxMerchant.setTenantId(record.getTenantId()); |
|
|
|
|
|
//物业账单 |
|
|
|
|
|
buildProperty(wxMerchant); |
|
|
|
|
|
//物业押金账单 |
|
|
|
|
|
buildDeposit(wxMerchant); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
logger.error("更新租赁合同信息失败,e:" + e.getMessage()); |
|
|
|
|
|
throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); |
|
|
|
|
|
} |
|
|
|
|
|
return new ResultData(Result.SUCCESS, "更新租赁合同信息成功"); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = {Exception.class}) |
|
|
@Transactional(rollbackFor = {Exception.class}) |
|
|
@@ -86,7 +161,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService |
|
|
final IdWorker idWorker = IdWorker.get(); |
|
|
final IdWorker idWorker = IdWorker.get(); |
|
|
WxBillPropertyDeposit wxBillDeposit = new WxBillPropertyDeposit(); |
|
|
WxBillPropertyDeposit wxBillDeposit = new WxBillPropertyDeposit(); |
|
|
wxBillDeposit.setId(idWorker.nextId()); |
|
|
wxBillDeposit.setId(idWorker.nextId()); |
|
|
wxBillDeposit.setRentContractId(wxPropertyContract.getId()); |
|
|
|
|
|
|
|
|
wxBillDeposit.setPropertyContractId(wxPropertyContract.getId()); |
|
|
wxBillDeposit.setReceivePay(0); |
|
|
wxBillDeposit.setReceivePay(0); |
|
|
wxBillDeposit.setPay(0); |
|
|
wxBillDeposit.setPay(0); |
|
|
int needpay = wxPropertyContract.getDeposit(); |
|
|
int needpay = wxPropertyContract.getDeposit(); |
|
|
@@ -129,7 +204,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = {Exception.class}) |
|
|
@Transactional(rollbackFor = {Exception.class}) |
|
|
public void buildRent(WxMerchant wxMerchant) { |
|
|
|
|
|
|
|
|
public void buildProperty(WxMerchant wxMerchant) { |
|
|
|
|
|
|
|
|
//获取用户 |
|
|
//获取用户 |
|
|
MallUserInfo user = (MallUserInfo) SecurityUtils.getSubject().getSession().getAttribute("userSession"); |
|
|
MallUserInfo user = (MallUserInfo) SecurityUtils.getSubject().getSession().getAttribute("userSession"); |
|
|
@@ -146,7 +221,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService |
|
|
for (int i = 0; i < paycount; i++) { |
|
|
for (int i = 0; i < paycount; i++) { |
|
|
WxBillProperty wxBillRent = new WxBillProperty(); |
|
|
WxBillProperty wxBillRent = new WxBillProperty(); |
|
|
wxBillRent.setId(idWorker.nextId()); |
|
|
wxBillRent.setId(idWorker.nextId()); |
|
|
wxBillRent.setRentContractId(wxPropertyContract.getId()); |
|
|
|
|
|
|
|
|
wxBillRent.setPropertyContractId(wxPropertyContract.getId()); |
|
|
wxBillRent.setReceivePay(0); |
|
|
wxBillRent.setReceivePay(0); |
|
|
wxBillRent.setPay(0); |
|
|
wxBillRent.setPay(0); |
|
|
int needpay = wxPropertyContract.getPrice(); |
|
|
int needpay = wxPropertyContract.getPrice(); |
|
|
|