| @@ -7,6 +7,7 @@ import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | import com.iformall.controller.base.BaseController; | ||||
| import com.iformall.domain.po.MallUserInfo; | import com.iformall.domain.po.MallUserInfo; | ||||
| import com.iformall.domain.po.WxBillOther; | import com.iformall.domain.po.WxBillOther; | ||||
| import com.iformall.domain.po.WxUserDataRule; | |||||
| import com.iformall.service.WxBillOtherService; | import com.iformall.service.WxBillOtherService; | ||||
| import io.swagger.annotations.ApiImplicitParam; | import io.swagger.annotations.ApiImplicitParam; | ||||
| import io.swagger.annotations.ApiImplicitParams; | import io.swagger.annotations.ApiImplicitParams; | ||||
| @@ -33,12 +34,16 @@ public class WxBillOtherController extends BaseController { | |||||
| @ApiImplicitParams({ | @ApiImplicitParams({ | ||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | ||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | ||||
| @SystemControllerLog(description = "其它账单-列表") | |||||
| public ResultData list(@ModelAttribute WxBillOther wxBillOther, Integer pageNum, Integer pageSize) { | public ResultData list(@ModelAttribute WxBillOther wxBillOther, Integer pageNum, Integer pageSize) { | ||||
| logger.debug("[" + getIpAddr() + "] WxBillOtherController::list"); | logger.debug("[" + getIpAddr() + "] WxBillOtherController::list"); | ||||
| if (null == wxBillOther) { | if (null == wxBillOther) { | ||||
| wxBillOther = new WxBillOther(); | wxBillOther = new WxBillOther(); | ||||
| } | } | ||||
| WxUserDataRule dataRule = this.getCurrentDataFloors(); | |||||
| if (null != dataRule) { | |||||
| wxBillOther.setFloorForRule(dataRule.getFloorForRule()); | |||||
| wxBillOther.setBusinessForRule(dataRule.getBusinessForRule()); | |||||
| } | |||||
| wxBillOther.updateTenantInfo(getTenantInfo()); | wxBillOther.updateTenantInfo(getTenantInfo()); | ||||
| final PageInfo<WxBillOther> page = wxBillOtherService.listAsPage(wxBillOther, pageNum, pageSize); | final PageInfo<WxBillOther> page = wxBillOtherService.listAsPage(wxBillOther, pageNum, pageSize); | ||||
| return new ResultData(page); | return new ResultData(page); | ||||
| @@ -78,7 +83,7 @@ public class WxBillOtherController extends BaseController { | |||||
| @SystemControllerLog(description = "其它账单-查询") | @SystemControllerLog(description = "其它账单-查询") | ||||
| public ResultData findById(Long id) { | public ResultData findById(Long id) { | ||||
| logger.debug("[" + getIpAddr() + "] WxBillOtherController::findById"); | logger.debug("[" + getIpAddr() + "] WxBillOtherController::findById"); | ||||
| return new ResultData(Result.SUCCESS, "查询成功", wxBillOtherService.getById(id)); | |||||
| return new ResultData(Result.SUCCESS, "查询成功", wxBillOtherService.getById(this.getTenantInfo(),id)); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -98,6 +103,11 @@ public class WxBillOtherController extends BaseController { | |||||
| @SystemControllerLog(description = "其它账单-导出") | @SystemControllerLog(description = "其它账单-导出") | ||||
| public void exportBill(@ModelAttribute WxBillOther wxBillOther, HttpServletRequest request, HttpServletResponse response) { | public void exportBill(@ModelAttribute WxBillOther wxBillOther, HttpServletRequest request, HttpServletResponse response) { | ||||
| wxBillOther.updateTenantInfo(getTenantInfo()); | wxBillOther.updateTenantInfo(getTenantInfo()); | ||||
| WxUserDataRule dataRule = this.getCurrentDataFloors(); | |||||
| if (null != dataRule) { | |||||
| wxBillOther.setFloorForRule(dataRule.getFloorForRule()); | |||||
| wxBillOther.setBusinessForRule(dataRule.getBusinessForRule()); | |||||
| } | |||||
| wxBillOtherService.exportBill(request, response, wxBillOther); | wxBillOtherService.exportBill(request, response, wxBillOther); | ||||
| } | } | ||||
| @@ -11,6 +11,7 @@ import lombok.ToString; | |||||
| import java.math.BigDecimal; | import java.math.BigDecimal; | ||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.List; | |||||
| /** | /** | ||||
| * @author gongbiao | * @author gongbiao | ||||
| @@ -159,5 +160,8 @@ public class WxBillOther extends TenantEntity { | |||||
| public String getRealReceivePayStr() { | public String getRealReceivePayStr() { | ||||
| return new BigDecimal(realReceivePay == null ? 0 : realReceivePay).divide(new BigDecimal(100)).toPlainString(); | return new BigDecimal(realReceivePay == null ? 0 : realReceivePay).divide(new BigDecimal(100)).toPlainString(); | ||||
| } | } | ||||
| @TableField(exist = false) | |||||
| private List<Long> merchantIds; | |||||
| } | } | ||||
| @@ -4,6 +4,7 @@ import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.MallUserInfo; | import com.iformall.domain.po.MallUserInfo; | ||||
| import com.iformall.domain.po.WxBillOther; | import com.iformall.domain.po.WxBillOther; | ||||
| import com.iformall.domain.po.base.TenantEntity; | |||||
| import javax.servlet.http.HttpServletRequest; | import javax.servlet.http.HttpServletRequest; | ||||
| import javax.servlet.http.HttpServletResponse; | import javax.servlet.http.HttpServletResponse; | ||||
| @@ -31,7 +32,7 @@ public interface WxBillOtherService { | |||||
| * @param id | * @param id | ||||
| * @return | * @return | ||||
| */ | */ | ||||
| WxBillOther getById(Long id); | |||||
| WxBillOther getById(TenantEntity tenantEntity,Long id); | |||||
| /** | /** | ||||
| * 保存或更新实体 | * 保存或更新实体 | ||||
| @@ -29,6 +29,7 @@ import org.apache.commons.lang3.StringUtils; | |||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.context.annotation.Lazy; | |||||
| import org.springframework.data.redis.core.StringRedisTemplate; | import org.springframework.data.redis.core.StringRedisTemplate; | ||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import org.springframework.transaction.annotation.Transactional; | import org.springframework.transaction.annotation.Transactional; | ||||
| @@ -64,6 +65,7 @@ public class WxBillDailyServiceImpl implements WxBillDailyService { | |||||
| @Autowired | @Autowired | ||||
| WxPayAccountBillService wxPayAccountBillService; | WxPayAccountBillService wxPayAccountBillService; | ||||
| @Lazy | |||||
| @Autowired | @Autowired | ||||
| WxMerchantService wxMerchantService; | WxMerchantService wxMerchantService; | ||||
| @@ -9,8 +9,11 @@ import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.MallUserInfo; | import com.iformall.domain.po.MallUserInfo; | ||||
| import com.iformall.domain.po.WxBillAction; | import com.iformall.domain.po.WxBillAction; | ||||
| import com.iformall.domain.po.WxBillDaily; | |||||
| import com.iformall.domain.po.WxBillOther; | import com.iformall.domain.po.WxBillOther; | ||||
| import com.iformall.domain.po.WxMerchant; | |||||
| import com.iformall.domain.po.WxPayAccountBill; | import com.iformall.domain.po.WxPayAccountBill; | ||||
| import com.iformall.domain.po.base.TenantEntity; | |||||
| import com.iformall.enums.*; | import com.iformall.enums.*; | ||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| import com.iformall.mapper.WxBillOtherMapper; | import com.iformall.mapper.WxBillOtherMapper; | ||||
| @@ -19,17 +22,23 @@ import com.iformall.mapper.WxShopMapper; | |||||
| import com.iformall.service.ExcelService; | import com.iformall.service.ExcelService; | ||||
| import com.iformall.service.WxBillActionService; | import com.iformall.service.WxBillActionService; | ||||
| import com.iformall.service.WxBillOtherService; | import com.iformall.service.WxBillOtherService; | ||||
| import com.iformall.service.WxMerchantService; | |||||
| import com.iformall.service.WxPayAccountBillService; | import com.iformall.service.WxPayAccountBillService; | ||||
| import com.iformall.utils.DateUtils; | import com.iformall.utils.DateUtils; | ||||
| import org.apache.commons.collections.CollectionUtils; | |||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.context.annotation.Lazy; | |||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import org.springframework.transaction.annotation.Transactional; | import org.springframework.transaction.annotation.Transactional; | ||||
| import javax.servlet.http.HttpServletRequest; | import javax.servlet.http.HttpServletRequest; | ||||
| import javax.servlet.http.HttpServletResponse; | import javax.servlet.http.HttpServletResponse; | ||||
| import java.math.BigDecimal; | import java.math.BigDecimal; | ||||
| import java.util.ArrayList; | |||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.HashMap; | import java.util.HashMap; | ||||
| import java.util.List; | import java.util.List; | ||||
| @@ -59,23 +68,75 @@ public class WxBillOtherServiceImpl implements WxBillOtherService { | |||||
| @Autowired | @Autowired | ||||
| WxPayAccountBillService wxPayAccountBillService; | WxPayAccountBillService wxPayAccountBillService; | ||||
| @Lazy | |||||
| @Autowired | |||||
| WxMerchantService wxMerchantService; | |||||
| @Override | @Override | ||||
| public PageInfo<WxBillOther> listAsPage(WxBillOther record, Integer pageIndex, Integer pageSize) { | public PageInfo<WxBillOther> listAsPage(WxBillOther record, Integer pageIndex, Integer pageSize) { | ||||
| WxPayAccountBill wxPayAccountBill = wxPayAccountBillService.getByTenantInfo(record); | 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) { | public void computeTotalMoney(WxPayAccountBill wxPayAccountBill, WxBillOther e) { | ||||
| if (e.getReceivePay() != null) { | if (e.getReceivePay() != null) { | ||||
| @@ -136,12 +197,12 @@ public class WxBillOtherServiceImpl implements WxBillOtherService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public WxBillOther getById(Long id) { | |||||
| public WxBillOther getById(TenantEntity tenantEntity,Long id) { | |||||
| WxPayAccountBill wxPayAccountBill = wxPayAccountBillService.getByTenantInfo(tenantEntity); | |||||
| WxBillOther record = new WxBillOther(); | WxBillOther record = new WxBillOther(); | ||||
| record.setId(id); | 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.setOwe(wxBillOther.getRealReceivePay() - wxBillOther.getPay()); | ||||
| wxBillOther.setMerchant(wxMerchantMapper.selectById(wxBillOther.getMerchantId())); | wxBillOther.setMerchant(wxMerchantMapper.selectById(wxBillOther.getMerchantId())); | ||||
| // if (wxBillOther.getShopId() != null) { | // if (wxBillOther.getShopId() != null) { | ||||
| @@ -289,12 +350,14 @@ public class WxBillOtherServiceImpl implements WxBillOtherService { | |||||
| @Override | @Override | ||||
| public void exportBill(HttpServletRequest request, HttpServletResponse response, WxBillOther wxBillOther) { | public void exportBill(HttpServletRequest request, HttpServletResponse response, WxBillOther wxBillOther) { | ||||
| WxPayAccountBill wxPayAccountBill = wxPayAccountBillService.getByTenantInfo(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); | |||||
| } | } | ||||
| @@ -85,16 +85,14 @@ | |||||
| <select id="queryBillList" parameterType="com.iformall.domain.po.WxBillOther" resultMap="BaseResultMap"> | <select id="queryBillList" parameterType="com.iformall.domain.po.WxBillOther" resultMap="BaseResultMap"> | ||||
| select br.`id`,br.`receive_pay`,br.`pay`,br.`receive_date`, br.`pay_date`,br.`createtime`,br.`expired_day`, | select br.`id`,br.`receive_pay`,br.`pay`,br.`receive_date`, br.`pay_date`,br.`createtime`,br.`expired_day`, | ||||
| case when br.status=1 then br.owe else 0 end owe,br.`status`,m.`name` | |||||
| merchant_name,br.shop_name,br.`updatetime`,br.`apply_status`,br.`apply_pay_img`,br.`apply_update_time`, | |||||
| br.`merchant_id`,br.shop_id,br.name,br.comments,br.`rent_shop_type`,br.pay_way, | |||||
| br.`starttime`,br.`endtime`,br.freeze,br.service_charge_pay | |||||
| from wx_bill_other br left join wx_merchant m on br.merchant_id=m.id | |||||
| case when br.status=1 then br.owe else 0 end owe,br.`status`,br.shop_name,br.`updatetime`,br.`apply_status`, | |||||
| br.`apply_pay_img`,br.`apply_update_time`,br.`merchant_id`,br.shop_id,br.name,br.comments,br.`rent_shop_type`, | |||||
| br.pay_way,br.`starttime`,br.`endtime`,br.freeze,br.service_charge_pay | |||||
| from wx_bill_other br | |||||
| <where> | <where> | ||||
| <if test=" null != id ">and br.`id` = #{id}</if> | <if test=" null != id ">and br.`id` = #{id}</if> | ||||
| <if test=" null != freeze ">and br.`freeze` = #{freeze}</if> | <if test=" null != freeze ">and br.`freeze` = #{freeze}</if> | ||||
| <if test=" null != merchantId ">and br.`merchant_id` = #{merchantId}</if> | <if test=" null != merchantId ">and br.`merchant_id` = #{merchantId}</if> | ||||
| <if test=" null != merchantName and ''!=merchantName ">and m.`name` like concat('%',#{merchantName},'%')</if> | |||||
| <if test=" null != status ">and br.`status` = #{status}</if> | <if test=" null != status ">and br.`status` = #{status}</if> | ||||
| <if test=" null != applyStatus ">and br.`apply_status` = #{applyStatus}</if> | <if test=" null != applyStatus ">and br.`apply_status` = #{applyStatus}</if> | ||||
| <if test=" null != isDel ">and br.`is_del` = #{isDel}</if> | <if test=" null != isDel ">and br.`is_del` = #{isDel}</if> | ||||
| @@ -103,6 +101,12 @@ | |||||
| <if test=" null != payWay ">and br.`pay_way` = #{payWay}</if> | <if test=" null != payWay ">and br.`pay_way` = #{payWay}</if> | ||||
| <if test=" null != starttime and null!=endtime ">and br.`receive_date` between #{starttime} and #{endtime} | <if test=" null != starttime and null!=endtime ">and br.`receive_date` between #{starttime} and #{endtime} | ||||
| </if> | </if> | ||||
| <if test=" null != merchantIds "> | |||||
| and br.`merchant_id` in | |||||
| <foreach collection="merchantIds" index="index" item="midItem" open="(" separator="," close=")"> | |||||
| #{midItem} | |||||
| </foreach> | |||||
| </if> | |||||
| </where> | </where> | ||||