| @@ -84,4 +84,10 @@ public class WxBillSettleController extends BaseController { | |||
| wxBillSettleService.exportBill(request, response, wxBillSettle); | |||
| } | |||
| @GetMapping("downloadSettle") | |||
| @SystemControllerLog(description = "账单管理-结算单-下载") | |||
| public void downloadSettle(@ModelAttribute WxBillSettle wxBillSettle, HttpServletRequest request, HttpServletResponse response) { | |||
| wxBillSettle.setTenantId(getTenantId()); | |||
| wxBillSettleService.exportBill(request, response, wxBillSettle); | |||
| } | |||
| } | |||
| @@ -0,0 +1,3 @@ | |||
| alter table wx_merchant_subsidy | |||
| add column `freeze` SMALLINT (1) NULL DEFAULT 0 COMMENT '0正常1冻结'; | |||
| @@ -77,5 +77,7 @@ public class WxBillDeposit extends BaseEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value = "支付方式:见枚举EnumBillPayWay", name = "payWay") | |||
| private Integer payWay; | |||
| @io.swagger.annotations.ApiModelProperty(value = "冻结状态,0正常1冻结", name = "freeze") | |||
| private Integer freeze; | |||
| } | |||
| @@ -1,5 +1,6 @@ | |||
| package com.iformall.domain.po; | |||
| import cn.afterturn.easypoi.excel.annotation.Excel; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| @@ -28,20 +29,30 @@ public class WxBillSettle extends BaseEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") | |||
| private String tenantId; | |||
| @io.swagger.annotations.ApiModelProperty(value="结算单号",name="settleNumber") | |||
| @Excel(name="结算单号",width = 20,orderNum = "1") | |||
| private String settleNumber; | |||
| @Transient | |||
| @Excel(name="结算商户",width = 20,orderNum = "2") | |||
| private String merchantName; | |||
| @io.swagger.annotations.ApiModelProperty(value="商户id",name="merchantId") | |||
| private Long merchantId; | |||
| @io.swagger.annotations.ApiModelProperty(value="0待确认1未清算结余金额2结算完成",name="status") | |||
| @Excel(name="结算状态",width = 20,orderNum = "8") | |||
| private Integer status; | |||
| @io.swagger.annotations.ApiModelProperty(value="审核状态0未审核1审核中2审核完成3驳回4异常终止5撤回",name="applyStatus") | |||
| @Excel(name="审批状态",width = 20,orderNum = "9") | |||
| private Integer applyStatus; | |||
| @Excel(name="收款(元)",width = 20,orderNum = "4") | |||
| @io.swagger.annotations.ApiModelProperty(value="收款",name="receiveMoney") | |||
| private Long receiveMoney; | |||
| @io.swagger.annotations.ApiModelProperty(value="承付",name="payMoney") | |||
| @Excel(name="承付(元)",width = 20,orderNum = "5") | |||
| private Long payMoney; | |||
| @io.swagger.annotations.ApiModelProperty(value="结算时间",name="settletime") | |||
| @Excel(name="结算时间",width = 20,orderNum = "7") | |||
| private Date settletime; | |||
| @Excel(name="创建时间",width = 20,orderNum = "3") | |||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createtime") | |||
| private Date createtime; | |||
| @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updatetime") | |||
| @@ -51,11 +62,25 @@ public class WxBillSettle extends BaseEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value = "审批流参数", name = "flowParams") | |||
| private Map<String, Object> flowParams; | |||
| //结余金额 | |||
| @Transient | |||
| @Excel(name="结算金额(元)",width = 20,orderNum = "6") | |||
| private Long balance; | |||
| @Transient | |||
| @io.swagger.annotations.ApiModelProperty(value = "收款账单列表", name = "receiveBillIds") | |||
| private List<WxBillSettleBill> receiveBillIds; | |||
| @Transient | |||
| @io.swagger.annotations.ApiModelProperty(value = "承付账单列表", name = "payBillIds") | |||
| private List<WxBillSettleBill> payBillIds; | |||
| @Transient | |||
| @io.swagger.annotations.ApiModelProperty(value = "结单记录", name = "settleRecordList") | |||
| private List<WxBillSettleRecord> settleRecordList; | |||
| @Transient | |||
| @io.swagger.annotations.ApiModelProperty(value="开始时间",name="starttime") | |||
| private Date startTime; | |||
| @Transient | |||
| @io.swagger.annotations.ApiModelProperty(value="结束时间",name="endtime") | |||
| private Date endTime; | |||
| } | |||
| @@ -42,6 +42,8 @@ public class WxBillSettleRecord extends BaseEntity { | |||
| private Long balance; | |||
| @io.swagger.annotations.ApiModelProperty(value="明细",name="detail") | |||
| private String detail; | |||
| @io.swagger.annotations.ApiModelProperty(value="描述",name="desc") | |||
| private String desc; | |||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createtime") | |||
| private Date createtime; | |||
| @@ -105,6 +105,9 @@ public class WxMerchantSubsidy extends BaseEntity { | |||
| @Transient | |||
| protected String statusStr; | |||
| @io.swagger.annotations.ApiModelProperty(value="是否冻结",name="freeze") | |||
| private Integer freeze; | |||
| public String getOrderPaymentStr() { | |||
| if(getOrderPayment()!=null) { | |||
| @@ -0,0 +1,44 @@ | |||
| package com.iformall.domain.vo; | |||
| import cn.afterturn.easypoi.excel.annotation.Excel; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| import lombok.ToString; | |||
| /** | |||
| * @author luozukai | |||
| */ | |||
| @Data | |||
| @ToString(callSuper = true) | |||
| public class WxBillSettleVo { | |||
| @Excel(name="结算单号",width = 20,orderNum = "1") | |||
| private String settleNumber; | |||
| @Excel(name="结算商户",width = 20,orderNum = "2") | |||
| private String merchantName; | |||
| @Excel(name="创建时间",width = 20,orderNum = "3") | |||
| private String createtime; | |||
| @Excel(name="收款(元)",width = 20,orderNum = "4") | |||
| private String receiveMoney; | |||
| @Excel(name="承付(元)",width = 20,orderNum = "5") | |||
| private String payMoney; | |||
| @Excel(name="结算金额(元)",width = 20,orderNum = "6") | |||
| private String balance; | |||
| @Excel(name="结算时间",width = 20,orderNum = "7") | |||
| private String settletime; | |||
| @Excel(name="结算状态",width = 20,orderNum = "8") | |||
| private String status; | |||
| @Excel(name="审批状态",width = 20,orderNum = "9") | |||
| private String applyStatus; | |||
| } | |||
| @@ -0,0 +1,37 @@ | |||
| package com.iformall.enums; | |||
| /** | |||
| * luozukai | |||
| */ | |||
| public enum EnumSettleStatus { | |||
| //0待确认1未清算结余金额2结算完成 | |||
| DEF(0, "待确认"), | |||
| NOT_FINISH(1, "未清算结余金额"), | |||
| FINISH(2, "结算完成"), | |||
| ; | |||
| public static EnumSettleStatus getEnum(Integer code) { | |||
| for (EnumSettleStatus value : values()) { | |||
| if (value.getCode().equals(code)) { | |||
| return value; | |||
| } | |||
| } | |||
| return null; | |||
| } | |||
| private Integer code; | |||
| private String message; | |||
| EnumSettleStatus(Integer code, String message) { | |||
| this.code = code; | |||
| this.message = message; | |||
| } | |||
| public Integer getCode() { | |||
| return code; | |||
| } | |||
| public String getMessage() { | |||
| return message; | |||
| } | |||
| } | |||
| @@ -15,5 +15,6 @@ public interface WxBillSettleRecordMapper extends CommonMapper<WxBillSettleRecor | |||
| void update(WxBillSettleRecord record); | |||
| Long getSumMoneyBySettleId(WxBillSettle wxBillSettle); | |||
| } | |||
| @@ -14,7 +14,6 @@ import java.util.List; | |||
| * @author luozukai | |||
| */ | |||
| public interface WxBillSettleService { | |||
| /** | |||
| * 根据实体查询分页列表 | |||
| * | |||
| @@ -40,5 +39,7 @@ public interface WxBillSettleService { | |||
| void exportBill(HttpServletRequest request, HttpServletResponse response, WxBillSettle wxBillSettle); | |||
| void downloadBill(HttpServletRequest request, HttpServletResponse response, WxBillSettle wxBillSettle); | |||
| void updateFreeze(List<WxBillSettleBill> billList, int status); | |||
| } | |||
| @@ -1,6 +1,7 @@ | |||
| package com.iformall.service.impl; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.IdWorker; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.MallUserInfo; | |||
| import com.iformall.domain.po.WxBillSettleRecord; | |||
| @@ -26,8 +27,13 @@ public class WxBillSettleRecordServiceImpl implements WxBillSettleRecordService | |||
| @Override | |||
| public ResultData saveOrUpdate(WxBillSettleRecord record,MallUserInfo mallUserInfo) { | |||
| return null; | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| if (record.getId() == null) { | |||
| record.setId(idWorker.nextId()); | |||
| wxBillSettleRecordMapper.insertSelective(record); | |||
| }else{ | |||
| wxBillSettleRecordMapper.updateByPrimaryKeySelective(record); | |||
| } | |||
| return new ResultData(); | |||
| } | |||
| } | |||
| @@ -5,19 +5,21 @@ import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.IdWorker; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.enums.EnumBillRentStatus; | |||
| import com.iformall.enums.EnumBillType; | |||
| import com.iformall.enums.EnumFreezeType; | |||
| import com.iformall.enums.EnumSettleBillType; | |||
| import com.iformall.domain.vo.WxBillSettleVo; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.mapper.*; | |||
| import com.iformall.service.ExcelService; | |||
| import com.iformall.service.WxBillSettleService; | |||
| import com.iformall.service.WxFlowService; | |||
| import com.iformall.utils.DateUtils; | |||
| import org.checkerframework.checker.units.qual.A; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| 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.List; | |||
| /** | |||
| @@ -46,10 +48,20 @@ public class WxBillSettleServiceImpl implements WxBillSettleService { | |||
| private WxBillPropertyDepositMapper wxBillPropertyDepositMapper; | |||
| @Autowired | |||
| private WxBillOtherDepositMapper wxBillOtherDepositMapper; | |||
| @Autowired | |||
| private WxBillSettleRecordMapper wxBillSettleRecordMapper; | |||
| @Autowired | |||
| private WxMerchantSubsidyMapper wxMerchantSubsidyMapper; | |||
| @Autowired | |||
| private ExcelService excelService; | |||
| @Override | |||
| public PageInfo<WxBillSettle> listAsPage(WxBillSettle record, Integer pageIndex, Integer pageSize) { | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxBillSettleMapper.findList(record)); | |||
| PageInfo<WxBillSettle> pageInfo = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxBillSettleMapper.findList(record)); | |||
| pageInfo.getList().stream().forEach(e->{ | |||
| e.setBalance(e.getReceiveMoney() - e.getPayMoney()); | |||
| }); | |||
| return pageInfo; | |||
| } | |||
| @Override | |||
| @@ -65,6 +77,15 @@ public class WxBillSettleServiceImpl implements WxBillSettleService { | |||
| wxBillSettleBill.setType(EnumSettleBillType.P.getCode()); | |||
| billSettle.setPayBillIds(wxBillSettleBillMapper.findBySettleId(wxBillSettleBill)); | |||
| WxBillSettleRecord wxBillSettleRecord = new WxBillSettleRecord(); | |||
| wxBillSettleRecord.setTenantId(billSettle.getTenantId()); | |||
| wxBillSettleRecord.setSettleId(billSettle.getId()); | |||
| billSettle.setSettleRecordList(wxBillSettleRecordMapper.findList(wxBillSettleRecord)); | |||
| //计算结余金额 | |||
| Long sumSettleMoney = wxBillSettleRecordMapper.getSumMoneyBySettleId(billSettle); | |||
| billSettle.setBalance(billSettle.getReceiveMoney() - (billSettle.getPayMoney()+sumSettleMoney)); | |||
| } | |||
| return billSettle; | |||
| @@ -76,38 +97,48 @@ public class WxBillSettleServiceImpl implements WxBillSettleService { | |||
| if(EnumBillType.RENT.getCode().equals(bill.getBillType())) { | |||
| WxBillRent wxBillRent = new WxBillRent(); | |||
| wxBillRent.setId(bill.getBillId()); | |||
| wxBillRent.setStatus(status); | |||
| wxBillRent.setFreeze(status); | |||
| wxBillRentMapper.updateByPrimaryKeySelective(wxBillRent); | |||
| }else if(EnumBillType.DEPOSIT.getCode().equals(bill.getBillType())) { | |||
| WxBillDeposit wxBillRent = new WxBillDeposit(); | |||
| wxBillRent.setId(bill.getBillId()); | |||
| wxBillRent.setStatus(status); | |||
| wxBillRent.setFreeze(status); | |||
| wxBillDepositMapper.updateByPrimaryKeySelective(wxBillRent); | |||
| }else if(EnumBillType.PROPERTY.getCode().equals(bill.getBillType())) { | |||
| WxBillProperty wxBillRent = new WxBillProperty(); | |||
| wxBillRent.setId(bill.getBillId()); | |||
| wxBillRent.setStatus(status); | |||
| wxBillRent.setFreeze(status); | |||
| wxBillPropertyMapper.updateByPrimaryKeySelective(wxBillRent); | |||
| WxBillPropertyDeposit propertyDeposit = new WxBillPropertyDeposit(); | |||
| propertyDeposit.setId(bill.getBillId()); | |||
| propertyDeposit.setStatus(status); | |||
| propertyDeposit.setFreeze(status); | |||
| wxBillPropertyDepositMapper.updateByPrimaryKeySelective(propertyDeposit); | |||
| }else if(EnumBillType.ROUTINE.getCode().equals(bill.getBillType())) { | |||
| WxBillOther wxBillRent = new WxBillOther(); | |||
| wxBillRent.setId(bill.getBillId()); | |||
| wxBillRent.setStatus(status); | |||
| wxBillRent.setFreeze(status); | |||
| wxBillOtherMapper.updateByPrimaryKeySelective(wxBillRent); | |||
| }else if(EnumBillType.OTHER_DEPOSIT.getCode().equals(bill.getBillType())) { | |||
| WxBillOtherDeposit wxBillRent = new WxBillOtherDeposit(); | |||
| wxBillRent.setId(bill.getBillId()); | |||
| wxBillRent.setStatus(status); | |||
| wxBillRent.setFreeze(status); | |||
| wxBillOtherDepositMapper.updateByPrimaryKeySelective(wxBillRent); | |||
| }else if(EnumBillType.OTHER_DEPOSIT.getCode().equals(bill.getBillType())) { | |||
| WxBillOtherDeposit wxBillRent = new WxBillOtherDeposit(); | |||
| wxBillRent.setId(bill.getBillId()); | |||
| wxBillRent.setFreeze(status); | |||
| wxBillOtherDepositMapper.updateByPrimaryKeySelective(wxBillRent); | |||
| }else{ | |||
| WxBillDaily wxBillRent = new WxBillDaily(); | |||
| wxBillRent.setId(bill.getBillId()); | |||
| wxBillRent.setStatus(status); | |||
| wxBillRent.setFreeze(status); | |||
| wxBillDailyMapper.updateByPrimaryKeySelective(wxBillRent); | |||
| WxMerchantSubsidy wxMerchantSubsidy = new WxMerchantSubsidy(); | |||
| wxMerchantSubsidy.setId(bill.getBillId()); | |||
| wxMerchantSubsidy.setFreeze(status); | |||
| wxMerchantSubsidyMapper.updateByPrimaryKeySelective(wxMerchantSubsidy); | |||
| } | |||
| } | |||
| } | |||
| @@ -129,6 +160,14 @@ public class WxBillSettleServiceImpl implements WxBillSettleService { | |||
| bill.setId(idWorker.nextId()); | |||
| bill.setSettleId(record.getId()); | |||
| bill.setTenantId(record.getTenantId()); | |||
| bill.setType(EnumSettleBillType.R.getCode()); | |||
| wxBillSettleBillMapper.insertSelective(bill); | |||
| } | |||
| for (WxBillSettleBill bill:record.getPayBillIds()) { | |||
| bill.setId(idWorker.nextId()); | |||
| bill.setSettleId(record.getId()); | |||
| bill.setTenantId(record.getTenantId()); | |||
| bill.setType(EnumSettleBillType.P.getCode()); | |||
| wxBillSettleBillMapper.insertSelective(bill); | |||
| } | |||
| @@ -136,18 +175,39 @@ public class WxBillSettleServiceImpl implements WxBillSettleService { | |||
| if (record.getFlowParams() != null && record.getFlowParams().size() > 0) { | |||
| updateFreeze(record.getReceiveBillIds(), EnumFreezeType.YES.getCode()); | |||
| updateFreeze(record.getPayBillIds(),EnumFreezeType.YES.getCode()); | |||
| } | |||
| //启动审批流 | |||
| record.getFlowParams().put("businessId",record.getId()); | |||
| if (record.getFlowParams() != null && record.getFlowParams().size() > 0) { | |||
| wxFlowService.start(record.getFlowParams(), userInfo.getId(), userInfo.getName(), record.getTenantId()); | |||
| //启动审批流 | |||
| record.getFlowParams().put("businessId",record.getId()); | |||
| if (record.getFlowParams() != null && record.getFlowParams().size() > 0) { | |||
| wxFlowService.start(record.getFlowParams(), userInfo.getId(), userInfo.getName(), record.getTenantId()); | |||
| } | |||
| } | |||
| return new ResultData(); | |||
| } | |||
| @Override | |||
| public void exportBill(HttpServletRequest request, HttpServletResponse response, WxBillSettle wxBillSettle) { | |||
| List<WxBillSettle> list = wxBillSettleMapper.findList(wxBillSettle); | |||
| List<WxBillSettleVo> voList = new ArrayList<>(); | |||
| for (WxBillSettle s:list) { | |||
| WxBillSettleVo vo = new WxBillSettleVo(); | |||
| vo.setSettleNumber(s.getSettleNumber()); | |||
| vo.setMerchantName(s.getMerchantName()); | |||
| vo.setCreatetime(DateUtils.formatDateTime(s.getCreatetime())); | |||
| vo.setReceiveMoney(new BigDecimal(s.getReceiveMoney()).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP).toString()); | |||
| vo.setPayMoney(new BigDecimal(s.getPayMoney()).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP).toString()); | |||
| vo.setBalance(new BigDecimal(s.getReceiveMoney()).subtract(new BigDecimal(s.getPayMoney())).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP).toString()); | |||
| vo.setSettletime(DateUtils.formatDateTime(s.getSettletime())); | |||
| vo.setStatus(EnumSettleStatus.getEnum(s.getStatus()).getMessage()); | |||
| vo.setApplyStatus(EnumRentContractAppStatus.getEnum(s.getApplyStatus()).getMessage()); | |||
| voList.add(vo); | |||
| } | |||
| excelService.exportExcel(voList, null, "结算单", WxBillSettleVo.class, "结算单.xlsx", response, false); | |||
| } | |||
| @Override | |||
| public void downloadBill(HttpServletRequest request, HttpServletResponse response, WxBillSettle wxBillSettle) { | |||
| } | |||
| } | |||
| @@ -560,12 +560,16 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| priceD = priceD + priceD * integers.get(i) / 10000.0; | |||
| priceArr[i] = new BigDecimal(priceD).setScale(0, RoundingMode.HALF_EVEN).longValue(); | |||
| } | |||
| } else { | |||
| } else if (wxPropertyContract.getAdjustRatioWay().equals(EnumRentContractAdjustRatioWay.MONEY.getCode())) { | |||
| long priceD = price; | |||
| for (int i = 1; i < size; i++) { | |||
| priceD = priceD + integers.get(i); | |||
| priceArr[i] = new BigDecimal(priceD).setScale(0, RoundingMode.HALF_EVEN).longValue(); | |||
| } | |||
| } else { | |||
| for (int i = 1; i < size; i++) { | |||
| priceArr[i] = new BigDecimal(integers.get(i)).setScale(0, RoundingMode.HALF_EVEN).longValue(); | |||
| } | |||
| } | |||
| int month = 12; | |||
| @@ -373,7 +373,9 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| } | |||
| } | |||
| } | |||
| ratioVo.setUseRatio(ratioVo.getUseRatio().substring(0,ratioVo.getUseRatio().lastIndexOf(","))+"]"); | |||
| if(!"[".equals(ratioVo.getUseRatio())) { | |||
| ratioVo.setUseRatio(ratioVo.getUseRatio().substring(0, ratioVo.getUseRatio().lastIndexOf(",")) + "]"); | |||
| } | |||
| return ratioVo; | |||
| } | |||
| @@ -993,7 +995,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| for (int i = 0; i < arraySize; i++) { | |||
| JSONObject rentInfoObject = rentInfoArray.getJSONObject(i); | |||
| String priceStr = rentInfoObject.getString("price"); | |||
| if(priceStr.equalsIgnoreCase("NaN")) { | |||
| if (priceStr.equalsIgnoreCase("NaN")) { | |||
| priceStr = "0"; | |||
| } | |||
| priceArr[i] = new BigDecimal(priceStr).multiply(new BigDecimal(100)).longValue(); | |||
| @@ -1016,7 +1018,9 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| } | |||
| priceList.add(priceArrs); | |||
| } | |||
| } else { | |||
| return priceList; | |||
| } | |||
| if (wxRentContract.getAdjustRatioWay().equals(EnumRentContractAdjustRatioWay.MONEY.getCode())) { | |||
| for (int i = 0; i < adjustRatioSize; i++) { | |||
| long[] priceArrs = new long[arraySize]; | |||
| for (int j = 0; j < arraySize; j++) { | |||
| @@ -1027,12 +1031,24 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| } | |||
| priceList.add(priceArrs); | |||
| } | |||
| return priceList; | |||
| } | |||
| if (wxRentContract.getAdjustRatioWay().equals(EnumRentContractAdjustRatioWay.CUSTOM.getCode())) { | |||
| for (int i = 0; i < adjustRatioSize; i++) { | |||
| long[] priceArrs = new long[arraySize]; | |||
| for (int j = 0; j < arraySize; j++) { | |||
| rentInfoObject = rentInfoArray.getJSONObject(j); | |||
| adjustRatio = rentInfoObject.getJSONArray("adjustRatio"); | |||
| BigDecimal price = new BigDecimal(adjustRatio.getString(i)).multiply(new BigDecimal(100)); | |||
| priceArrs[j] = price.setScale(0, RoundingMode.HALF_EVEN).longValue(); | |||
| } | |||
| priceList.add(priceArrs); | |||
| } | |||
| } | |||
| return priceList; | |||
| } | |||
| public List<WxBillRent> buildRentMonth(Long userId, WxRentContract wxRentContract, int receivePeriod, Integer lease, Date rentalStartDate, Long price, Integer isPreview,boolean saveDb) { | |||
| public List<WxBillRent> buildRentMonth(Long userId, WxRentContract wxRentContract, int receivePeriod, Integer lease, Date rentalStartDate, Long price, Integer isPreview, boolean saveDb) { | |||
| int size = 0; | |||
| long[] priceArrs = null; | |||
| List<Map<String, Object>> shopInfos = new ArrayList<>(); | |||
| @@ -1077,11 +1093,15 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| priceD = priceD.add(divide); | |||
| priceArrs[i] = priceD.setScale(0, RoundingMode.HALF_EVEN).longValue(); | |||
| } | |||
| } else { | |||
| } else if (wxRentContract.getAdjustRatioWay().equals(EnumRentContractAdjustRatioWay.MONEY.getCode())) { | |||
| for (int i = 1; i < size; i++) { | |||
| priceD = priceD.add(new BigDecimal(integers.get(i))); | |||
| priceArrs[i] = priceD.setScale(0, RoundingMode.HALF_EVEN).longValue(); | |||
| } | |||
| } else { | |||
| for (int i = 1; i < size; i++) { | |||
| priceArrs[i] = new BigDecimal(integers.get(i)).setScale(0, RoundingMode.HALF_EVEN).longValue(); | |||
| } | |||
| } | |||
| } | |||
| @@ -1276,7 +1296,8 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| if (EnumRentContractType.RENT_BY_JOINT.getCode().equals(wxRentContract.getType())) { | |||
| //设置跳点率为年周期 price不变 | |||
| if(EnumMissTimeType.PERIOD.getCode().equals(wxRentContract.getBusDiscountTime())){ | |||
| if (EnumRentContractAdjustRatioWay.CUSTOM.getCode().equals(wxRentContract.getAdjustRatioWay()) || | |||
| EnumMissTimeType.PERIOD.getCode().equals(wxRentContract.getBusDiscountTime())) { | |||
| return priceD.longValue(); | |||
| } | |||
| //年或者设置跳点率为年周期 除12 | |||
| @@ -28,6 +28,11 @@ public class DateUtils { | |||
| return format(date, DATE_PATTERN); | |||
| } | |||
| public static String formatDateTime(Date date) { | |||
| return format(date, DATE_TIME_PATTERN); | |||
| } | |||
| public static String format(Date date, String pattern) { | |||
| if(date != null){ | |||
| SimpleDateFormat df = new SimpleDateFormat(pattern); | |||
| @@ -679,11 +679,11 @@ | |||
| left join wx_c_user cu on cu.id = cs.owner_id | |||
| where ms.order_type in(3,0) and ms.status = 0 | |||
| union all | |||
| select merchant_id id,receive_pay money from wx_bill_rent_deposit where status = 3 | |||
| select receive_pay money,merchant_id id from wx_bill_rent_deposit where status = 3 | |||
| union all | |||
| select merchant_id id,receive_pay money from wx_bill_property_deposit where status = 3 | |||
| select receive_pay money,merchant_id id from wx_bill_property_deposit where status = 3 | |||
| union all | |||
| select merchant_id id,receive_pay money from wx_bill_other_deposit where status = 3 | |||
| select receive_pay money,merchant_id id from wx_bill_other_deposit where status = 3 | |||
| )ss where ss.id = m.id | |||
| )/100,2) payOut, | |||
| @@ -715,11 +715,11 @@ | |||
| left join wx_c_user cu on cu.id = cs.owner_id | |||
| where ms.order_type in(3,0) and ms.status = 0 | |||
| union all | |||
| select merchant_id id,receive_pay money from wx_bill_rent_deposit where status = 3 | |||
| select receive_pay money,merchant_id id from wx_bill_rent_deposit where status = 3 | |||
| union all | |||
| select merchant_id id,receive_pay money from wx_bill_property_deposit where status = 3 | |||
| select receive_pay money,merchant_id id from wx_bill_property_deposit where status = 3 | |||
| union all | |||
| select merchant_id id,receive_pay money from wx_bill_other_deposit where status = 3 | |||
| select receive_pay money,merchant_id id from wx_bill_other_deposit where status = 3 | |||
| )ss where ss.id = m.id | |||
| )/100,2)) balance | |||
| @@ -79,6 +79,7 @@ | |||
| need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_other_deposit | |||
| ) bill | |||
| on(bl.bill_id = bill.id) | |||
| where 1=1 | |||
| <if test=" null != tenantId ">and bl.`tenant_id` = #{tenantId}</if> | |||
| <if test=" null != settleId ">and bl.`settle_id` = #{settleId}</if> | |||
| <if test=" null != type ">and bl.`type` = #{type}</if> | |||
| @@ -8,12 +8,12 @@ | |||
| <result column="merchant_id" property="merchantId"/> | |||
| <result column="status" property="status"/> | |||
| <result column="apply_status" property="applyStatus"/> | |||
| <result column="receive_money" property="receiveMoney"/> | |||
| <result column="pay_money" property="payMoney"/> | |||
| <result column="receiveMoney" property="receiveMoney"/> | |||
| <result column="payMoney" property="payMoney"/> | |||
| <result column="settletime" property="settletime"/> | |||
| <result column="createtime" property="createtime"/> | |||
| <result column="updatetime" property="updatetime"/> | |||
| <result column="merchantName" property="merchantName"/> | |||
| </resultMap> | |||
| @@ -24,22 +24,98 @@ | |||
| <sql id="dynamicWhereConditions"> | |||
| where 1=1 | |||
| <if test=" null != id ">and `id` = #{id}</if> | |||
| <if test=" null != tenantId ">and `tenant_id` = #{tenantId}</if> | |||
| <if test=" null != ids "> | |||
| and id in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||
| #{idItem} | |||
| </foreach> | |||
| <if test=" null != id ">and s.`id` = #{id}</if> | |||
| <if test=" null != tenantId ">and s.`tenant_id` = #{tenantId}</if> | |||
| <if test=" null != merchantName ">and m.name like concat('%', #{merchantName},'%')</if> | |||
| <if test="startTime != null"> | |||
| and createtime >= #{startTime} | |||
| </if> | |||
| <if test="endTime != null"> | |||
| and createtime <= #{endTime} | |||
| </if> | |||
| <if test=" null != settleNumber ">and s.`settle_number` = #{settleNumber}</if> | |||
| <if test=" null != status ">and s.`status` = #{status}</if> | |||
| <if test=" null != applyStatus ">and s.`apply_status` = #{applyStatus}</if> | |||
| <if test=" null != sortColumns">order by ${sortColumns}</if> | |||
| </sql> | |||
| <select id="findList" parameterType="com.iformall.domain.po.WxBillSettle" resultMap="BaseResultMap"> | |||
| select | |||
| <include refid="allColumns"/> | |||
| from wx_bill_settle | |||
| select s.*,m.name merchantName, | |||
| (select IFNULL(sum(bill.receive_pay),0) from wx_bill_settle_bill bb left join | |||
| (select id,merchant_id,shop_id,tenant_id,1 bill_type_value,'租金' | |||
| bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_rent where is_preview = 0 | |||
| union all | |||
| select id,merchant_id,shop_id,tenant_id,2 bill_type_value,'租赁押金' | |||
| bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from | |||
| wx_bill_rent_deposit | |||
| union all | |||
| select id,merchant_id,shop_id,tenant_id,3 bill_type_value,'物业费' | |||
| bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from | |||
| wx_bill_property where is_preview = 0 | |||
| union all | |||
| select id,merchant_id,shop_id,tenant_id,4 bill_type_value,'物业押金' | |||
| bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from | |||
| wx_bill_property_deposit | |||
| union all | |||
| select id,merchant_id,shop_id,tenant_id,5 bill_type_value,'水费' bill_type,0 as | |||
| need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where | |||
| type=1 | |||
| union all | |||
| select id,merchant_id,shop_id,tenant_id,6 bill_type_value,'电费' bill_type,0 as | |||
| need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where | |||
| type=2 | |||
| union all | |||
| select id,merchant_id,shop_id,tenant_id,9 bill_type_value,'空调费' bill_type,0 as | |||
| need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where | |||
| type=3 | |||
| union all | |||
| select id,merchant_id,shop_id,tenant_id,7 bill_type_value,'其他费用' bill_type,0 as | |||
| need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_other | |||
| union all | |||
| select id,merchant_id,shop_id,tenant_id,8 bill_type_value,'其他押金' bill_type,0 as | |||
| need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_other_deposit | |||
| ) bill | |||
| on(bb.bill_id=bill.id) where bb.settle_id = s.id and bb.type=0 | |||
| ) receiveMoney, | |||
| (select IFNULL(sum(bill.receive_pay),0) from wx_bill_settle_bill bb left join | |||
| (select id,merchant_id,shop_id,tenant_id,1 bill_type_value,'租金' | |||
| bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_rent where is_preview = 0 | |||
| union all | |||
| select id,merchant_id,shop_id,tenant_id,2 bill_type_value,'租赁押金' | |||
| bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from | |||
| wx_bill_rent_deposit | |||
| union all | |||
| select id,merchant_id,shop_id,tenant_id,3 bill_type_value,'物业费' | |||
| bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from | |||
| wx_bill_property where is_preview = 0 | |||
| union all | |||
| select id,merchant_id,shop_id,tenant_id,4 bill_type_value,'物业押金' | |||
| bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from | |||
| wx_bill_property_deposit | |||
| union all | |||
| select id,merchant_id,shop_id,tenant_id,5 bill_type_value,'水费' bill_type,0 as | |||
| need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where | |||
| type=1 | |||
| union all | |||
| select id,merchant_id,shop_id,tenant_id,6 bill_type_value,'电费' bill_type,0 as | |||
| need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where | |||
| type=2 | |||
| union all | |||
| select id,merchant_id,shop_id,tenant_id,9 bill_type_value,'空调费' bill_type,0 as | |||
| need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_daily where | |||
| type=3 | |||
| union all | |||
| select id,merchant_id,shop_id,tenant_id,7 bill_type_value,'其他费用' bill_type,0 as | |||
| need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_other | |||
| union all | |||
| select id,merchant_id,shop_id,tenant_id,8 bill_type_value,'其他押金' bill_type,0 as | |||
| need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,rent_shop_type from wx_bill_other_deposit | |||
| ) bill | |||
| on(bb.bill_id=bill.id) where bb.settle_id = s.id and bb.type=1 | |||
| ) payMoney | |||
| from wx_bill_settle s left JOIN wx_merchant m on(s.merchant_id=m.id) | |||
| <include refid="dynamicWhereConditions"/> | |||
| </select> | |||
| @@ -12,7 +12,7 @@ | |||
| <result column="settle_way" property="settleWay"/> | |||
| <result column="balance" property="balance"/> | |||
| <result column="detail" property="detail"/> | |||
| <result column="desc" property="desc"/> | |||
| <result column="createtime" property="createtime"/> | |||
| <result column="updatetime" property="updatetime"/> | |||
| @@ -20,13 +20,14 @@ | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`settle_id`,`userid`,`user_name`,`settle_money`, | |||
| `settle_time`,`settle_way`,`balance`,detail,`createtime`,`updatetime` | |||
| `settle_time`,`settle_way`,`balance`,detail,`createtime`,`updatetime`,`desc` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| where 1=1 | |||
| <if test=" null != id ">and `id` = #{id}</if> | |||
| <if test=" null != tenantId ">and `tenant_id` = #{tenantId}</if> | |||
| <if test=" null != settleId ">and `settle_id` = #{settleId}</if> | |||
| <if test=" null != ids "> | |||
| and id in | |||
| @@ -44,6 +45,10 @@ | |||
| <include refid="dynamicWhereConditions"/> | |||
| </select> | |||
| <select id="getSumMoneyBySettleId" parameterType="com.iformall.domain.po.WxBillSettle" resultType="long"> | |||
| select sum(settle_money) from wx_bill_settle_record where settle_id = #{id} | |||
| </select> | |||
| </mapper> | |||
| @@ -16,10 +16,12 @@ | |||
| <result column="status" jdbcType="INTEGER" property="status" /> | |||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | |||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" /> | |||
| <result column="freeze" property="freeze" /> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`order_id`,`order_type`,`merchant_id`,`coupon_order_id`,`coupon_type`,`order_payment`,`receiver_payment`,`real_payment`,`subsidy`,`real_subsidy`,`status`,`create_date`,`update_date` | |||
| `id`,`order_id`,`order_type`,`merchant_id`,`coupon_order_id`,`coupon_type`,`order_payment`,`receiver_payment`,`real_payment`,`subsidy`,`real_subsidy`,`status`,`create_date`,`update_date`,freeze | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||