|
|
|
@@ -9,8 +9,11 @@ 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.WxBillDaily; |
|
|
|
import com.iformall.domain.po.WxBillOther; |
|
|
|
import com.iformall.domain.po.WxMerchant; |
|
|
|
import com.iformall.domain.po.WxPayAccountBill; |
|
|
|
import com.iformall.domain.po.base.TenantEntity; |
|
|
|
import com.iformall.enums.*; |
|
|
|
import com.iformall.exception.MallinkException; |
|
|
|
import com.iformall.mapper.WxBillOtherMapper; |
|
|
|
@@ -19,17 +22,23 @@ import com.iformall.mapper.WxShopMapper; |
|
|
|
import com.iformall.service.ExcelService; |
|
|
|
import com.iformall.service.WxBillActionService; |
|
|
|
import com.iformall.service.WxBillOtherService; |
|
|
|
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; |
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
@@ -59,23 +68,75 @@ public class WxBillOtherServiceImpl implements WxBillOtherService { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
WxPayAccountBillService wxPayAccountBillService; |
|
|
|
|
|
|
|
@Lazy |
|
|
|
@Autowired |
|
|
|
WxMerchantService wxMerchantService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageInfo<WxBillOther> listAsPage(WxBillOther record, Integer pageIndex, Integer pageSize) { |
|
|
|
WxPayAccountBill wxPayAccountBill = wxPayAccountBillService.getByTenantInfo(record); |
|
|
|
//分页对象设置页数和条数 |
|
|
|
PageHelper.startPage(pageIndex, pageSize); |
|
|
|
//查询 |
|
|
|
List<WxBillOther> billList = wxBillOtherMapper.queryBillList(record); |
|
|
|
billList.stream().forEach(e->{ |
|
|
|
//手续费 = 合同应收+手续费+滞纳金 |
|
|
|
computeTotalMoney(wxPayAccountBill, e); |
|
|
|
}); |
|
|
|
//结果放入分页对象 |
|
|
|
PageInfo<WxBillOther> pageInfo = new PageInfo<>(billList); |
|
|
|
return pageInfo; |
|
|
|
return getBillOtherPropertyList(pageIndex, pageSize, record, wxPayAccountBill); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private PageInfo<WxBillOther> getBillOtherPropertyList(Integer pageIndex, Integer pageSize,WxBillOther record,WxPayAccountBill wxPayAccountBill) { |
|
|
|
if (null != record.getFloorForRule()) { |
|
|
|
List<Long> merchantIds = wxMerchantService.getFloorBuildMerchantIds(record, record.getFloorForRule(), null, null, 0, 0); |
|
|
|
if (null != merchantIds) { |
|
|
|
record.setMerchantIds(merchantIds); |
|
|
|
}else { |
|
|
|
record.setId(-1L); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(record.getMerchantName())) { |
|
|
|
WxMerchant mq = new WxMerchant(); |
|
|
|
mq.updateTenantInfo(record); |
|
|
|
mq.setName(StringUtils.trimToNull(record.getMerchantName())); |
|
|
|
List<Long> mids = wxMerchantService.findIdList(mq); |
|
|
|
if (null != mids && mids.size() > 0 ) { |
|
|
|
if (null != record.getMerchantIds()) { |
|
|
|
List<Long> _mids = (List<Long>) CollectionUtils.intersection(mids, record.getMerchantIds()); |
|
|
|
if (null == _mids || _mids.size() <= 0) { |
|
|
|
record.setId(-1L); |
|
|
|
}else { |
|
|
|
record.setMerchantIds(_mids); |
|
|
|
} |
|
|
|
}else { |
|
|
|
record.setMerchantIds(mids); |
|
|
|
} |
|
|
|
}else { |
|
|
|
record.setId(-1L); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
PageInfo<WxBillOther> page = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxBillOtherMapper.queryBillList(record)); |
|
|
|
if (null == page) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
WxMerchant wq = new WxMerchant(); |
|
|
|
wq.updateTenantInfo(record); |
|
|
|
Map<Long,WxMerchant> merchantMap = wxMerchantService.findMerchantMap(wq); |
|
|
|
|
|
|
|
if (null != page.getList()) { |
|
|
|
for (int i = 0 ; i < page.getList().size() ; i ++) { |
|
|
|
WxBillOther e = page.getList().get(i); |
|
|
|
//手续费 = 合同应收+手续费+滞纳金 |
|
|
|
computeTotalMoney(wxPayAccountBill, e); |
|
|
|
|
|
|
|
if (null != e.getMerchantId()) { |
|
|
|
WxMerchant m = merchantMap.get(e.getMerchantId()); |
|
|
|
if (null != m ) { |
|
|
|
e.setMerchantName(m.getName()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return page; |
|
|
|
} |
|
|
|
|
|
|
|
public void computeTotalMoney(WxPayAccountBill wxPayAccountBill, WxBillOther e) { |
|
|
|
if (e.getReceivePay() != null) { |
|
|
|
@@ -136,12 +197,12 @@ public class WxBillOtherServiceImpl implements WxBillOtherService { |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public WxBillOther getById(Long id) { |
|
|
|
public WxBillOther getById(TenantEntity tenantEntity,Long id) { |
|
|
|
WxPayAccountBill wxPayAccountBill = wxPayAccountBillService.getByTenantInfo(tenantEntity); |
|
|
|
WxBillOther record = new WxBillOther(); |
|
|
|
record.setId(id); |
|
|
|
WxBillOther wxBillOther = wxBillOtherMapper.queryBillList(record).get(0); |
|
|
|
WxPayAccountBill wxPayAccountBill = wxPayAccountBillService.getByTenantInfo(wxBillOther); |
|
|
|
computeTotalMoney(wxPayAccountBill, wxBillOther); |
|
|
|
record.updateTenantInfo(tenantEntity); |
|
|
|
WxBillOther wxBillOther = getBillOtherPropertyList(1, 1, record, wxPayAccountBill).getList().get(0); |
|
|
|
wxBillOther.setOwe(wxBillOther.getRealReceivePay() - wxBillOther.getPay()); |
|
|
|
wxBillOther.setMerchant(wxMerchantMapper.selectById(wxBillOther.getMerchantId())); |
|
|
|
// if (wxBillOther.getShopId() != null) { |
|
|
|
@@ -289,12 +350,14 @@ public class WxBillOtherServiceImpl implements WxBillOtherService { |
|
|
|
@Override |
|
|
|
public void exportBill(HttpServletRequest request, HttpServletResponse response, WxBillOther wxBillOther) { |
|
|
|
WxPayAccountBill wxPayAccountBill = wxPayAccountBillService.getByTenantInfo(wxBillOther); |
|
|
|
List<WxBillOther> datalist = wxBillOtherMapper.queryBillList(wxBillOther); |
|
|
|
datalist.stream().forEach(e->{ |
|
|
|
//手续费 = 合同应收+手续费+滞纳金 |
|
|
|
computeTotalMoney(wxPayAccountBill, e); |
|
|
|
}); |
|
|
|
excelService.exportExcel(datalist, null, "其他费用账单", WxBillOther.class, "其他费用账单.xlsx", response, false); |
|
|
|
PageInfo<WxBillOther> datalist = getBillOtherPropertyList(1, 10000, wxBillOther, wxPayAccountBill); |
|
|
|
List<WxBillOther> list = null; |
|
|
|
if (null != datalist && null != datalist.getList()) { |
|
|
|
list = datalist.getList(); |
|
|
|
}else { |
|
|
|
list = new ArrayList<WxBillOther>(); |
|
|
|
} |
|
|
|
excelService.exportExcel(list, null, "其他费用账单", WxBillOther.class, "其他费用账单.xlsx", response, false); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|