|
|
|
@@ -9,21 +9,31 @@ import com.iformall.common.Result; |
|
|
|
import com.iformall.common.ResultData; |
|
|
|
import com.iformall.domain.po.MallUserInfo; |
|
|
|
import com.iformall.domain.po.WxBillAction; |
|
|
|
import com.iformall.domain.po.WxBillDeposit; |
|
|
|
import com.iformall.domain.po.WxBillRent; |
|
|
|
import com.iformall.domain.po.WxBillRentManage; |
|
|
|
import com.iformall.domain.po.WxMerchant; |
|
|
|
import com.iformall.domain.po.WxPayAccountBill; |
|
|
|
import com.iformall.domain.po.WxRentContract; |
|
|
|
import com.iformall.domain.po.base.TenantEntity; |
|
|
|
import com.iformall.enums.*; |
|
|
|
import com.iformall.exception.MallinkException; |
|
|
|
import com.iformall.mapper.WxBillActionMapper; |
|
|
|
import com.iformall.mapper.WxBillRentManageMapper; |
|
|
|
import com.iformall.mapper.WxRentContractMapper; |
|
|
|
import com.iformall.service.ExcelService; |
|
|
|
import com.iformall.service.WxBillActionService; |
|
|
|
import com.iformall.service.WxBillRentManageService; |
|
|
|
import com.iformall.service.WxMerchantService; |
|
|
|
import com.iformall.service.WxPayAccountBillService; |
|
|
|
import com.iformall.utils.DateUtils; |
|
|
|
|
|
|
|
import org.apache.commons.collections.CollectionUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.context.annotation.Lazy; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
@@ -54,18 +64,91 @@ public class WxBillRentManageServiceImpl implements WxBillRentManageService { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
ExcelService excelService; |
|
|
|
|
|
|
|
@Lazy |
|
|
|
@Autowired |
|
|
|
WxMerchantService wxMerchantService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
WxRentContractMapper wxRentContractMapper; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageInfo<WxBillRentManage> listAsPage(WxBillRentManage wxBillRentManage, Integer pageIndex, Integer pageSize) { |
|
|
|
WxPayAccountBill wxPayAccountBill = wxPayAccountBillService.getByTenantInfo(wxBillRentManage); |
|
|
|
PageHelper.startPage(pageIndex, pageSize); |
|
|
|
List<WxBillRentManage> billDepositList = wxBillRentManageMapper.queryBillManageList(wxBillRentManage); |
|
|
|
billDepositList.stream().forEach(e->{ |
|
|
|
//手续费 = 合同应收+手续费+滞纳金 |
|
|
|
computeTotalMoney(wxPayAccountBill, e); |
|
|
|
}); |
|
|
|
PageInfo<WxBillRentManage> pageInfo = new PageInfo<>(billDepositList); |
|
|
|
return pageInfo; |
|
|
|
return getBillRentManageList(pageIndex, pageSize, wxBillRentManage, wxPayAccountBill); |
|
|
|
} |
|
|
|
|
|
|
|
private PageInfo<WxBillRentManage> getBillRentManageList(Integer pageIndex, Integer pageSize,WxBillRentManage wxBillRentManage,WxPayAccountBill wxPayAccountBill) { |
|
|
|
if (null != wxBillRentManage.getFloorForRule()) { |
|
|
|
List<Long> merchantIds = wxMerchantService.getFloorBuildMerchantIds(wxBillRentManage, wxBillRentManage.getFloorForRule(), null, null, 0, 0); |
|
|
|
if (null != merchantIds) { |
|
|
|
wxBillRentManage.setMerchantIds(merchantIds); |
|
|
|
}else { |
|
|
|
wxBillRentManage.setId(-1L); |
|
|
|
} |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(wxBillRentManage.getMerchantName())) { |
|
|
|
WxMerchant mq = new WxMerchant(); |
|
|
|
mq.updateTenantInfo(wxBillRentManage); |
|
|
|
mq.setName(StringUtils.trimToNull(wxBillRentManage.getMerchantName())); |
|
|
|
List<Long> mids = wxMerchantService.findIdList(mq); |
|
|
|
if (null != mids && mids.size() > 0 ) { |
|
|
|
if (null != wxBillRentManage.getMerchantIds()) { |
|
|
|
List<Long> _mids = (List<Long>) CollectionUtils.intersection(mids, wxBillRentManage.getMerchantIds()); |
|
|
|
if (null == _mids || _mids.size() <= 0) { |
|
|
|
wxBillRentManage.setId(-1L); |
|
|
|
}else { |
|
|
|
wxBillRentManage.setMerchantIds(_mids); |
|
|
|
} |
|
|
|
}else { |
|
|
|
wxBillRentManage.setMerchantIds(mids); |
|
|
|
} |
|
|
|
}else { |
|
|
|
wxBillRentManage.setId(-1L); |
|
|
|
} |
|
|
|
} |
|
|
|
PageInfo<WxBillRentManage> billRentList = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxBillRentManageMapper.queryBillManageList(wxBillRentManage)); |
|
|
|
if (null == billRentList) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
List<Long> rentContractIdList = wxBillRentManageMapper.queryRentContractIds(wxBillRentManage); |
|
|
|
Map<Long,WxRentContract> rentContractMap = new HashMap<Long,WxRentContract>(); |
|
|
|
if ( null != rentContractIdList && rentContractIdList.size() > 0 ) { |
|
|
|
WxRentContract rcq = new WxRentContract(); |
|
|
|
rcq.updateTenantInfo(wxBillRentManage); |
|
|
|
rcq.setIds(rentContractIdList); |
|
|
|
List<WxRentContract> rlist = wxRentContractMapper.findList(rcq); |
|
|
|
if (null != rlist && rlist.size() > 0 ) { |
|
|
|
for (int i = 0 ; i < rlist.size(); i++) { |
|
|
|
WxRentContract rc = rlist.get(i); |
|
|
|
rentContractMap.put(rc.getId(), rc); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (null != billRentList.getList()) { |
|
|
|
for (int i = 0 ; i < billRentList.getList().size() ; i ++) { |
|
|
|
WxBillRentManage e = billRentList.getList().get(i); |
|
|
|
//手续费 = 合同应收+手续费+滞纳金 |
|
|
|
computeTotalMoney(wxPayAccountBill, e); |
|
|
|
WxRentContract rent = rentContractMap.get(e.getRentContractId()); |
|
|
|
if (null != rent) { |
|
|
|
e.setMerchantName(rent.getMerchantName()); |
|
|
|
//e.setRentType(rent.getType()); |
|
|
|
//if (null != rent.getPayRatio()) { |
|
|
|
// e.setPayRatio(rent.getPayRatio().longValue()); |
|
|
|
//}else { |
|
|
|
// e.setPayRatio(0l); |
|
|
|
//} |
|
|
|
// if (StringUtils.isNoneBlank(rent.getLatePayRatio())) { |
|
|
|
// e.setLatePayRatio(Integer.parseInt(rent.getLatePayRatio())); |
|
|
|
// } |
|
|
|
//e.setLatePayDay(rent.getLatePayDay()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return billRentList; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@@ -161,13 +244,13 @@ public class WxBillRentManageServiceImpl implements WxBillRentManageService { |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public WxBillRentManage getById(Long id) { |
|
|
|
public WxBillRentManage getById(TenantEntity tenantEntity,Long id) { |
|
|
|
WxPayAccountBill wxPayAccountBill = wxPayAccountBillService.getByTenantInfo(tenantEntity); |
|
|
|
WxBillRentManage record = new WxBillRentManage(); |
|
|
|
record.setId(id); |
|
|
|
WxBillRentManage rentManage = wxBillRentManageMapper.queryBillManageList(record).get(0); |
|
|
|
WxPayAccountBill wxPayAccountBill = wxPayAccountBillService.getByTenantInfo(record); |
|
|
|
//手续费 = 合同应收+手续费+滞纳金 |
|
|
|
computeTotalMoney(wxPayAccountBill, rentManage); |
|
|
|
record.updateTenantInfo(tenantEntity); |
|
|
|
PageInfo<WxBillRentManage> page = getBillRentManageList(1, 1, record, wxPayAccountBill); |
|
|
|
WxBillRentManage rentManage = page.getList().get(0); |
|
|
|
rentManage.setOwe(rentManage.getRealReceivePay() - rentManage.getPay()); |
|
|
|
return rentManage; |
|
|
|
} |
|
|
|
@@ -175,14 +258,7 @@ public class WxBillRentManageServiceImpl implements WxBillRentManageService { |
|
|
|
@Override |
|
|
|
public PageInfo<WxBillRentManage> findByRentContractId(WxBillRentManage record, Integer pageIndex, Integer pageSize) { |
|
|
|
WxPayAccountBill wxPayAccountBill = wxPayAccountBillService.getByTenantInfo(record); |
|
|
|
PageHelper.startPage(pageIndex, pageSize); |
|
|
|
List<WxBillRentManage> billRentList = wxBillRentManageMapper.queryBillManageList(record); |
|
|
|
billRentList.stream().forEach(e->{ |
|
|
|
//手续费 = 合同应收+手续费+滞纳金 |
|
|
|
computeTotalMoney(wxPayAccountBill, e); |
|
|
|
}); |
|
|
|
PageInfo<WxBillRentManage> pageInfo = new PageInfo<>(billRentList); |
|
|
|
return pageInfo; |
|
|
|
return getBillRentManageList(pageIndex, pageSize, record, wxPayAccountBill); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@@ -313,33 +389,31 @@ public class WxBillRentManageServiceImpl implements WxBillRentManageService { |
|
|
|
WxPayAccountBill wxPayAccountBill = wxPayAccountBillService.getByTenantInfo(wxBillRentManage); |
|
|
|
|
|
|
|
String billName = wxBillRentManage.getRentShopType().equals(EnumRentShopType.SHOP.getCode()) ? "商铺租金账单" : "多经点位租金账单"; |
|
|
|
List<WxBillRentManage> billRentList = wxBillRentManageMapper.queryBillManageList(wxBillRentManage); |
|
|
|
billRentList.stream().forEach(e->{ |
|
|
|
//手续费 = 合同应收+手续费+滞纳金 |
|
|
|
computeTotalMoney(wxPayAccountBill, e); |
|
|
|
}); |
|
|
|
Map<Long, List<WxBillRentManage>> collect = billRentList.parallelStream() |
|
|
|
.collect(Collectors.groupingBy(WxBillRentManage::getMerchantId)); |
|
|
|
Set<Map.Entry<Long, List<WxBillRentManage>>> entries = collect.entrySet(); |
|
|
|
PageInfo<WxBillRentManage> billRentList = getBillRentManageList(1, 10000, wxBillRentManage, wxPayAccountBill); |
|
|
|
List<WxBillRentManage> datalist = new ArrayList<>(); |
|
|
|
for (Map.Entry<Long, List<WxBillRentManage>> entry : entries) { |
|
|
|
List<WxBillRentManage> list = entry.getValue(); |
|
|
|
for (WxBillRentManage rent : list) { |
|
|
|
String shopNumber = rent.getShopNumber(); |
|
|
|
if (StringUtils.isEmpty(shopNumber)) { |
|
|
|
String shopInfo = rent.getShopInfo(); |
|
|
|
if (StringUtils.isNotEmpty(shopInfo) && !shopInfo.equals("[]")) { |
|
|
|
JSONObject jsonObject = JSONObject.parseObject(shopInfo); |
|
|
|
StringBuffer sb = new StringBuffer(); |
|
|
|
Set<Map.Entry<String, Object>> sets = jsonObject.entrySet(); |
|
|
|
sets.forEach(x -> sb.append(x.getKey()).append(",")); |
|
|
|
if(StringUtils.isNotBlank(sb)){ |
|
|
|
rent.setShopNumber(sb.deleteCharAt(sb.length() - 1).toString()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
datalist.add(rent); |
|
|
|
} |
|
|
|
if (null != billRentList && null != billRentList.getList()) { |
|
|
|
Map<Long, List<WxBillRentManage>> collect = billRentList.getList().parallelStream() |
|
|
|
.collect(Collectors.groupingBy(WxBillRentManage::getMerchantId)); |
|
|
|
Set<Map.Entry<Long, List<WxBillRentManage>>> entries = collect.entrySet(); |
|
|
|
for (Map.Entry<Long, List<WxBillRentManage>> entry : entries) { |
|
|
|
List<WxBillRentManage> list = entry.getValue(); |
|
|
|
for (WxBillRentManage rent : list) { |
|
|
|
String shopNumber = rent.getShopNumber(); |
|
|
|
if (StringUtils.isEmpty(shopNumber)) { |
|
|
|
String shopInfo = rent.getShopInfo(); |
|
|
|
if (StringUtils.isNotEmpty(shopInfo) && !shopInfo.equals("[]")) { |
|
|
|
JSONObject jsonObject = JSONObject.parseObject(shopInfo); |
|
|
|
StringBuffer sb = new StringBuffer(); |
|
|
|
Set<Map.Entry<String, Object>> sets = jsonObject.entrySet(); |
|
|
|
sets.forEach(x -> sb.append(x.getKey()).append(",")); |
|
|
|
if(StringUtils.isNotBlank(sb)){ |
|
|
|
rent.setShopNumber(sb.deleteCharAt(sb.length() - 1).toString()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
datalist.add(rent); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
excelService.exportExcel(datalist, null, billName, WxBillRentManage.class, billName + ".xlsx", response, false); |
|
|
|
|
|
|
|
|