| @@ -0,0 +1,73 @@ | |||||
| package com.iformall.controller; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.domain.po.WxBillDeposit; | |||||
| import com.iformall.service.WxBillDepositService; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import java.util.Map; | |||||
| /** | |||||
| * @author gongbiao | |||||
| */ | |||||
| @RestController | |||||
| @RequestMapping("wxBillDeposit") | |||||
| public class WxBillDepositController extends BaseController | |||||
| { | |||||
| @Autowired | |||||
| private WxBillDepositService wxBillDepositService; | |||||
| private Logger logger = LoggerFactory.getLogger(WxBillDepositController.class); | |||||
| @GetMapping("list") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name="pageNum",value="页数",dataType="int", paramType = "query",required=true), | |||||
| @ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)}) | |||||
| public ResultData list(@ModelAttribute WxBillDeposit wxBillDeposit, Integer pageNum, Integer pageSize) { | |||||
| if (null == wxBillDeposit) wxBillDeposit = new WxBillDeposit(); | |||||
| wxBillDeposit.setTenantId(getTenantId()); | |||||
| final PageInfo<Map<String, Object>> page = wxBillDepositService.listAsPage(wxBillDeposit, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @PostMapping("add") | |||||
| public ResultData add(@RequestBody WxBillDeposit wxBillDeposit) { | |||||
| wxBillDeposit.setTenantId(getTenantId()); | |||||
| return wxBillDepositService.saveOrUpdate(wxBillDeposit); | |||||
| } | |||||
| @PostMapping("update") | |||||
| public ResultData update(@RequestBody WxBillDeposit wxBillDeposit) { | |||||
| return wxBillDepositService.saveOrUpdate(wxBillDeposit); | |||||
| } | |||||
| @GetMapping("/del") | |||||
| @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) | |||||
| public ResultData delete(Long id) { | |||||
| wxBillDepositService.deleteById(id); | |||||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||||
| } | |||||
| @GetMapping("/findById") | |||||
| @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) | |||||
| public ResultData findById(Long id) { | |||||
| return new ResultData(Result.SUCCESS,"查询成功",wxBillDepositService.getById(id)); | |||||
| } | |||||
| @GetMapping("/updatePaid") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| public ResultData updatePaid(Long id) { | |||||
| return wxBillDepositService.updatePaid(id); | |||||
| } | |||||
| } | |||||
| @@ -84,4 +84,10 @@ public class WxRentContractController extends BaseController { | |||||
| return wxRentContractService.updateMerchant(wxRentContract); | return wxRentContractService.updateMerchant(wxRentContract); | ||||
| } | } | ||||
| @GetMapping("/getRentContractList") | |||||
| public ResultData getRentContractList() { | |||||
| return new ResultData(Result.SUCCESS, "查询成功", wxRentContractService.getRentContractList(getTenantId())); | |||||
| } | |||||
| } | } | ||||
| @@ -0,0 +1,262 @@ | |||||
| package com.iformall.domain.po; | |||||
| import javax.persistence.Id; | |||||
| import javax.persistence.Table; | |||||
| import javax.persistence.Transient; | |||||
| import java.io.Serializable; | |||||
| import java.util.ArrayList; | |||||
| import java.util.Date; | |||||
| import java.util.List; | |||||
| /** | |||||
| * @author gongbiao | |||||
| */ | |||||
| @Table(name = "wx_bill_deposit") | |||||
| public class WxBillDeposit implements Serializable { | |||||
| private static final long serialVersionUID = 1L; | |||||
| @Id | |||||
| protected Long id; | |||||
| @Transient | |||||
| protected List<Long> ids; | |||||
| @Transient | |||||
| protected String sortColumns; | |||||
| public Long getId() { | |||||
| return id; | |||||
| } | |||||
| public void setId(Long id) { | |||||
| this.id = id; | |||||
| } | |||||
| public String getSortColumns() { | |||||
| return sortColumns; | |||||
| } | |||||
| public List<Long> getIds() { | |||||
| return ids; | |||||
| } | |||||
| public void setIds(List<Long> ids) { | |||||
| this.ids = ids; | |||||
| } | |||||
| /*租金合同ID**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="租金合同ID",name="rentContractId") | |||||
| private Long rentContractId; | |||||
| /*实际应收金额**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="实际应收金额",name="receivePay") | |||||
| private Integer receivePay; | |||||
| /*实收金额**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="实收金额",name="pay") | |||||
| private Integer pay; | |||||
| /*收款日期**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="收款日期",name="receiveDate") | |||||
| private Date receiveDate; | |||||
| /*到账日期**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="到账日期",name="payDate") | |||||
| private Date payDate; | |||||
| /*创建时间**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createtime") | |||||
| private Date createtime; | |||||
| /*逾期天数**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="逾期天数",name="expiredDay") | |||||
| private Long expiredDay; | |||||
| /*租户**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="租户",name="tenantId") | |||||
| private String tenantId; | |||||
| /*欠缴**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="欠缴",name="owe") | |||||
| private Integer owe; | |||||
| /*账单状态1未到期2待缴3欠缴4已结清**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="账单状态1未到期2待缴3欠缴4已结清",name="status") | |||||
| private Integer status; | |||||
| /*是否删除 是1否0 未到期不显示**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="是否删除 是1否0 未到期不显示",name="isDel") | |||||
| private Integer isDel; | |||||
| /*应收金额**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="应收金额",name="needPay") | |||||
| private Integer needPay; | |||||
| /*商户ID**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="商户ID",name="merchantId") | |||||
| private Long merchantId; | |||||
| /*账号ID**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="账号ID",name="userId") | |||||
| private Long userId; | |||||
| /*商铺ID**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="商铺ID",name="shopId") | |||||
| private Long shopId; | |||||
| /*更新时间**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updatetime") | |||||
| private Date updatetime; | |||||
| public Long getRentContractId() { | |||||
| return rentContractId; | |||||
| } | |||||
| public void setRentContractId(Long _rentContractId) { | |||||
| rentContractId = _rentContractId; | |||||
| } | |||||
| public Integer getReceivePay() { | |||||
| return receivePay; | |||||
| } | |||||
| public void setReceivePay(Integer _receivePay) { | |||||
| receivePay = _receivePay; | |||||
| } | |||||
| public Integer getPay() { | |||||
| return pay; | |||||
| } | |||||
| public void setPay(Integer _pay) { | |||||
| pay = _pay; | |||||
| } | |||||
| public Date getReceiveDate() { | |||||
| return receiveDate; | |||||
| } | |||||
| public void setReceiveDate(Date _receiveDate) { | |||||
| receiveDate = _receiveDate; | |||||
| } | |||||
| public Date getPayDate() { | |||||
| return payDate; | |||||
| } | |||||
| public void setPayDate(Date _payDate) { | |||||
| payDate = _payDate; | |||||
| } | |||||
| public Date getCreatetime() { | |||||
| return createtime; | |||||
| } | |||||
| public void setCreatetime(Date _createtime) { | |||||
| createtime = _createtime; | |||||
| } | |||||
| public Long getExpiredDay() { | |||||
| return expiredDay; | |||||
| } | |||||
| public void setExpiredDay(Long _expiredDay) { | |||||
| expiredDay = _expiredDay; | |||||
| } | |||||
| public String getTenantId() { | |||||
| return tenantId; | |||||
| } | |||||
| public void setTenantId(String _tenantId) { | |||||
| tenantId = _tenantId; | |||||
| } | |||||
| public Integer getOwe() { | |||||
| return owe; | |||||
| } | |||||
| public void setOwe(Integer _owe) { | |||||
| owe = _owe; | |||||
| } | |||||
| public Integer getStatus() { | |||||
| return status; | |||||
| } | |||||
| public void setStatus(Integer _status) { | |||||
| status = _status; | |||||
| } | |||||
| public Integer getIsDel() { | |||||
| return isDel; | |||||
| } | |||||
| public void setIsDel(Integer _isDel) { | |||||
| isDel = _isDel; | |||||
| } | |||||
| public Integer getNeedPay() { | |||||
| return needPay; | |||||
| } | |||||
| public void setNeedPay(Integer _needPay) { | |||||
| needPay = _needPay; | |||||
| } | |||||
| public Long getMerchantId() { | |||||
| return merchantId; | |||||
| } | |||||
| public void setMerchantId(Long _merchantId) { | |||||
| merchantId = _merchantId; | |||||
| } | |||||
| public Long getUserId() { | |||||
| return userId; | |||||
| } | |||||
| public void setUserId(Long _userId) { | |||||
| userId = _userId; | |||||
| } | |||||
| public Long getShopId() { | |||||
| return shopId; | |||||
| } | |||||
| public void setShopId(Long _shopId) { | |||||
| shopId = _shopId; | |||||
| } | |||||
| public Date getUpdatetime() { | |||||
| return updatetime; | |||||
| } | |||||
| public void setUpdatetime(Date _updatetime) { | |||||
| updatetime = _updatetime; | |||||
| } | |||||
| public static enum Field | |||||
| { | |||||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | |||||
| ,RentContractId_ASC("`rentContractId` ASC"),RentContractId_DESC("`rentContractId` DESC") | |||||
| ,ReceivePay_ASC("`receivePay` ASC"),ReceivePay_DESC("`receivePay` DESC") | |||||
| ,Pay_ASC("`pay` ASC"),Pay_DESC("`pay` DESC") | |||||
| ,ReceiveDate_ASC("`receiveDate` ASC"),ReceiveDate_DESC("`receiveDate` DESC") | |||||
| ,PayDate_ASC("`payDate` ASC"),PayDate_DESC("`payDate` DESC") | |||||
| ,Createtime_ASC("`createtime` ASC"),Createtime_DESC("`createtime` DESC") | |||||
| ,ExpiredDay_ASC("`expiredDay` ASC"),ExpiredDay_DESC("`expiredDay` DESC") | |||||
| ,TenantId_ASC("`tenantId` ASC"),TenantId_DESC("`tenantId` DESC") | |||||
| ,Owe_ASC("`owe` ASC"),Owe_DESC("`owe` DESC") | |||||
| ,Status_ASC("`status` ASC"),Status_DESC("`status` DESC") | |||||
| ,IsDel_ASC("`isDel` ASC"),IsDel_DESC("`isDel` DESC") | |||||
| ,NeedPay_ASC("`needPay` ASC"),NeedPay_DESC("`needPay` DESC") | |||||
| ,MerchantId_ASC("`merchantId` ASC"),MerchantId_DESC("`merchantId` DESC") | |||||
| ,UserId_ASC("`userId` ASC"),UserId_DESC("`userId` DESC") | |||||
| ,ShopId_ASC("`shopId` ASC"),ShopId_DESC("`shopId` DESC") | |||||
| ,Updatetime_ASC("`updatetime` ASC"),Updatetime_DESC("`updatetime` DESC") | |||||
| ; | |||||
| private String value; | |||||
| Field(String value){ | |||||
| this.value = value; | |||||
| } | |||||
| public String getValue() { | |||||
| return value; | |||||
| } | |||||
| public void setCol(String value) { | |||||
| this.value = value; | |||||
| } | |||||
| @Override | |||||
| public String toString() { | |||||
| return this.getValue(); | |||||
| } | |||||
| } | |||||
| public void setSortColumns(Field... fields) | |||||
| { | |||||
| if (fields == null || fields.length == 0) { | |||||
| return; | |||||
| } | |||||
| for (int k = 0; k < fields.length; k++) { | |||||
| if (fields[k] == null) { | |||||
| return; | |||||
| } | |||||
| } | |||||
| StringBuilder sb = new StringBuilder(fields[0].toString()); | |||||
| for (int k = 1; k < fields.length; k++) { | |||||
| sb.append(","); | |||||
| sb.append(fields[k].toString()); | |||||
| } | |||||
| } | |||||
| public void setSortColumns(String sortColumns) | |||||
| { | |||||
| if (sortColumns == null || "".equals(sortColumns.trim())) { | |||||
| return; | |||||
| } | |||||
| if (sortColumns.contains(",")) { | |||||
| String[] cols = sortColumns.split(","); | |||||
| List<Field> fList = new ArrayList(); | |||||
| for (int k = 0; k < cols.length; k++) { | |||||
| fList.add(Field.valueOf(cols[k])); | |||||
| } | |||||
| this.setSortColumns(fList.toArray(new Field[fList.size()])); | |||||
| } else { | |||||
| this.setSortColumns(Field.valueOf(sortColumns)); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -86,7 +86,7 @@ public class WxRentContract implements Serializable { | |||||
| private String contractNumber; | private String contractNumber; | ||||
| /*押金**/ | /*押金**/ | ||||
| @io.swagger.annotations.ApiModelProperty(value = "押金", name = "deposit") | @io.swagger.annotations.ApiModelProperty(value = "押金", name = "deposit") | ||||
| private String deposit; | |||||
| private Integer deposit; | |||||
| /*交租日 计租开始时间减去交租日的天数为基数 提前多少日交租**/ | /*交租日 计租开始时间减去交租日的天数为基数 提前多少日交租**/ | ||||
| @io.swagger.annotations.ApiModelProperty(value = "交租日 计租开始时间减去交租日的天数为基数 提前多少日交租", name = "payDate") | @io.swagger.annotations.ApiModelProperty(value = "交租日 计租开始时间减去交租日的天数为基数 提前多少日交租", name = "payDate") | ||||
| @@ -215,11 +215,11 @@ public class WxRentContract implements Serializable { | |||||
| contractNumber = _contractNumber; | contractNumber = _contractNumber; | ||||
| } | } | ||||
| public String getDeposit() { | |||||
| public Integer getDeposit() { | |||||
| return deposit; | return deposit; | ||||
| } | } | ||||
| public void setDeposit(String _deposit) { | |||||
| public void setDeposit(Integer _deposit) { | |||||
| deposit = _deposit; | deposit = _deposit; | ||||
| } | } | ||||
| @@ -0,0 +1,28 @@ | |||||
| package com.iformall.mapper; | |||||
| import com.iformall.common.CommonMapper; | |||||
| import com.iformall.domain.po.WxBillDeposit; | |||||
| import java.util.List; | |||||
| import java.util.Map; | |||||
| /** | |||||
| * @author gongbiao | |||||
| */ | |||||
| public interface WxBillDepositMapper extends CommonMapper<WxBillDeposit, String> { | |||||
| List<WxBillDeposit> findList(WxBillDeposit wxBillDeposit); | |||||
| List<Map<String,Object>> queryBillDepositList(WxBillDeposit record); | |||||
| Map<String,Object> queryPayInfo(Map<String,Object> params); | |||||
| void updateNotPaidStatus(Map<String,Object> params); | |||||
| void updateWaitPayStatus(Map<String,Object> params); | |||||
| } | |||||
| @@ -33,4 +33,5 @@ public interface WxRentContractMapper extends CommonMapper<WxRentContract, Strin | |||||
| void updateRentInvalidStatus(WxRentContract wxRentContract); | void updateRentInvalidStatus(WxRentContract wxRentContract); | ||||
| List<WxRentContract> getRentContractList(String tenantId); | |||||
| } | } | ||||
| @@ -0,0 +1,50 @@ | |||||
| package com.iformall.service; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.domain.po.WxBillDeposit; | |||||
| import java.util.Map; | |||||
| public interface WxBillDepositService { | |||||
| /** | |||||
| * 根据实体查询分页列表 | |||||
| * | |||||
| * @param offset | |||||
| * @param limit | |||||
| * @param record | |||||
| * @return | |||||
| */ | |||||
| PageInfo<Map<String, Object>> listAsPage(WxBillDeposit record, Integer pageIndex, Integer pageSize); | |||||
| /** | |||||
| * 根据Id获得实体 | |||||
| * | |||||
| * @param id | |||||
| * @return | |||||
| */ | |||||
| Map<String, Object> getById(Long id); | |||||
| /** | |||||
| * 保存或更新实体 | |||||
| * | |||||
| * @param record | |||||
| */ | |||||
| ResultData saveOrUpdate(WxBillDeposit record); | |||||
| /** | |||||
| * 根据Id删除实体 | |||||
| * | |||||
| * @param id | |||||
| */ | |||||
| void deleteById(Long id); | |||||
| ResultData updatePaid(Long id); | |||||
| } | |||||
| @@ -53,4 +53,6 @@ public interface WxRentContractService { | |||||
| ResultData updateMerchant(WxRentContract wxRentContract); | ResultData updateMerchant(WxRentContract wxRentContract); | ||||
| Object getRentContractList(String tenantId); | |||||
| } | } | ||||
| @@ -0,0 +1,145 @@ | |||||
| package com.iformall.service.impl; | |||||
| import com.github.pagehelper.PageHelper; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.IdWorker; | |||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.domain.po.WxBillDeposit; | |||||
| import com.iformall.domain.po.WxBillRent; | |||||
| import com.iformall.enums.EnumBillRentStatus; | |||||
| import com.iformall.exception.MallinkException; | |||||
| import com.iformall.mapper.WxBillDepositMapper; | |||||
| import com.iformall.service.WxBillDepositService; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Service; | |||||
| import org.springframework.transaction.annotation.Transactional; | |||||
| import java.util.*; | |||||
| /** | |||||
| * @author gongbiao | |||||
| */ | |||||
| @Service | |||||
| public class WxBillDepositServiceImpl implements WxBillDepositService { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| WxBillDepositMapper wxBillDepositMapper; | |||||
| @Override | |||||
| public PageInfo<Map<String, Object>> listAsPage(WxBillDeposit record, Integer pageIndex, Integer pageSize) { | |||||
| //更新逾期天数及状态 | |||||
| updateNotPaidStatus(record); | |||||
| //更新待缴的状态 | |||||
| updateWaidPayStatus(record); | |||||
| PageHelper.startPage(pageIndex, pageSize); | |||||
| List<Map<String, Object>> billDepositList = wxBillDepositMapper.queryBillDepositList(record); | |||||
| PageInfo<Map<String, Object>> pageInfo = new PageInfo<>(billDepositList); | |||||
| return pageInfo; | |||||
| } | |||||
| @Transactional(rollbackFor = {Exception.class}) | |||||
| public void updateWaidPayStatus(WxBillDeposit record) { | |||||
| Map<String, Object> params = new HashMap<>(); | |||||
| params.put("tenantId", record.getTenantId()); | |||||
| params.put("waitPay", EnumBillRentStatus.WAIT_PAY.getCode()); | |||||
| params.put("paid", EnumBillRentStatus.PAID.getCode()); | |||||
| try { | |||||
| wxBillDepositMapper.updateWaitPayStatus(params); | |||||
| } catch (Exception e) { | |||||
| logger.error("更新租赁待缴账单状态失败,e:" + e.getMessage()); | |||||
| throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); | |||||
| } | |||||
| } | |||||
| @Transactional(rollbackFor = {Exception.class}) | |||||
| public void updateNotPaidStatus(WxBillDeposit record) { | |||||
| Map<String, Object> params = new HashMap<>(); | |||||
| params.put("tenantId", record.getTenantId()); | |||||
| params.put("notPaid", EnumBillRentStatus.NOT_PAID.getCode()); | |||||
| params.put("paid", EnumBillRentStatus.PAID.getCode()); | |||||
| try { | |||||
| wxBillDepositMapper.updateNotPaidStatus(params); | |||||
| } catch (Exception e) { | |||||
| logger.error("更新租赁欠缴账单状态失败,e:" + e.getMessage()); | |||||
| throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public Map<String, Object> getById(Long id) { | |||||
| WxBillDeposit record = new WxBillDeposit(); | |||||
| record.setId(id); | |||||
| return wxBillDepositMapper.queryBillDepositList(record).get(0); | |||||
| } | |||||
| @Override | |||||
| public ResultData saveOrUpdate(WxBillDeposit record) { | |||||
| if (record.getId() == null) { | |||||
| logger.info("新增押金账单"); | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| record.setId(idWorker.nextId()); | |||||
| Date date = new Date(); | |||||
| record.setCreatetime(date); | |||||
| record.setUpdatetime(date); | |||||
| try { | |||||
| wxBillDepositMapper.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, "保存押金账单成功"); | |||||
| } else { | |||||
| logger.info("更新押金账单"); | |||||
| WxBillDeposit wxBillDeposit = wxBillDepositMapper.selectByPrimaryKey(record.getId()); | |||||
| wxBillDeposit.setPayDate(record.getPayDate()); | |||||
| wxBillDeposit.setPay(record.getPay()*100); | |||||
| wxBillDeposit.setReceivePay(record.getReceivePay()*100); | |||||
| wxBillDeposit.setOwe(record.getOwe()*100); | |||||
| wxBillDeposit.setStatus(record.getPay().equals(record.getReceivePay())?EnumBillRentStatus.PAID.getCode():wxBillDeposit.getStatus()); | |||||
| wxBillDeposit.setUpdatetime(new Date()); | |||||
| try { | |||||
| wxBillDepositMapper.updateByPrimaryKeySelective(wxBillDeposit); | |||||
| } catch (Exception e) { | |||||
| logger.error("更新押金账单失败,e:" + e.getMessage()); | |||||
| throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); | |||||
| } | |||||
| return new ResultData(Result.SUCCESS, "更新押金账单成功"); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void deleteById(Long id) { | |||||
| wxBillDepositMapper.deleteByPrimaryKey(id); | |||||
| } | |||||
| @Transactional(rollbackFor = {Exception.class}) | |||||
| @Override | |||||
| public ResultData updatePaid(Long id) { | |||||
| WxBillDeposit wxBillDeposit = wxBillDepositMapper.selectByPrimaryKey(id); | |||||
| wxBillDeposit.setStatus(EnumBillRentStatus.PAID.getCode()); | |||||
| try { | |||||
| wxBillDepositMapper.updateByPrimaryKeySelective(wxBillDeposit); | |||||
| } catch (Exception e) { | |||||
| logger.error("押金结单失败,e:" + e.getMessage()); | |||||
| throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); | |||||
| } | |||||
| return new ResultData(Result.SUCCESS, "押金结单成功"); | |||||
| } | |||||
| } | |||||
| @@ -58,6 +58,9 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||||
| @Autowired | @Autowired | ||||
| WxProfitSharingReceiverService wxProfitSharingReceiverService; | WxProfitSharingReceiverService wxProfitSharingReceiverService; | ||||
| @Autowired | |||||
| WxBillDepositMapper wxBillDepositMapper; | |||||
| @Override | @Override | ||||
| public PageInfo<WxMerchant> listAsPage(WxMerchant record, Integer pageIndex, Integer pageSize) { | public PageInfo<WxMerchant> listAsPage(WxMerchant record, Integer pageIndex, Integer pageSize) { | ||||
| @@ -261,6 +264,8 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||||
| wxRentContractMapper.updateByPrimaryKeySelective(wxRentContract); | wxRentContractMapper.updateByPrimaryKeySelective(wxRentContract); | ||||
| //创建账单 | //创建账单 | ||||
| buildRent(wxRentContract); | buildRent(wxRentContract); | ||||
| //创建押金 | |||||
| buildDeposit(wxMerchant); | |||||
| } | } | ||||
| } else { | } else { | ||||
| @@ -369,6 +374,58 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||||
| } | } | ||||
| @Transactional(rollbackFor = {Exception.class}) | |||||
| public void buildDeposit(WxMerchant wxMerchant) { | |||||
| MallUserInfo user = (MallUserInfo) SecurityUtils.getSubject().getSession().getAttribute("userSession"); | |||||
| WxRentContract wxRentContract = new WxRentContract(); | |||||
| wxRentContract.setMerchantId(wxMerchant.getId()); | |||||
| List<WxRentContract> list = wxRentContractMapper.findList(wxRentContract); | |||||
| if (list.size() > 0) { | |||||
| wxRentContract = list.get(0); | |||||
| Integer receivePeriod = wxRentContract.getReceivePeriod(); | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| WxBillDeposit wxBillDeposit = new WxBillDeposit(); | |||||
| wxBillDeposit.setId(idWorker.nextId()); | |||||
| wxBillDeposit.setRentContractId(wxRentContract.getId()); | |||||
| wxBillDeposit.setReceivePay(0); | |||||
| wxBillDeposit.setPay(0); | |||||
| int needpay = wxRentContract.getDeposit(); | |||||
| wxBillDeposit.setNeedPay(needpay); | |||||
| wxBillDeposit.setOwe(needpay); | |||||
| Date date = new Date(); | |||||
| Calendar instance = Calendar.getInstance(); | |||||
| instance.setTime(wxRentContract.getRentalStartDate()); | |||||
| instance.add(Calendar.DAY_OF_MONTH, -1); | |||||
| Date time = instance.getTime(); | |||||
| wxBillDeposit.setReceiveDate(time); | |||||
| //截止收租日在当前时间之前 | |||||
| if (wxBillDeposit.getReceiveDate().before(date)) { | |||||
| long day = (time.getTime() - date.getTime()) / (24 * 60 * 60 * 1000); | |||||
| wxBillDeposit.setStatus(EnumBillRentStatus.NOT_PAID.getCode()); | |||||
| wxBillDeposit.setExpiredDay(day); | |||||
| wxBillDeposit.setReceiveDate(time); | |||||
| } else { | |||||
| wxBillDeposit.setStatus(EnumBillRentStatus.WAIT_PAY.getCode()); | |||||
| wxBillDeposit.setExpiredDay(0L); | |||||
| wxBillDeposit.setReceiveDate(time); | |||||
| } | |||||
| wxBillDeposit.setTenantId(wxMerchant.getTenantId()); | |||||
| wxBillDeposit.setIsDel(0); | |||||
| wxBillDeposit.setMerchantId(wxMerchant.getId()); | |||||
| wxBillDeposit.setUserId(user.getId()); | |||||
| wxBillDeposit.setShopId(wxRentContract.getShopId()); | |||||
| wxBillDeposit.setCreatetime(date); | |||||
| wxBillDeposit.setUpdatetime(date); | |||||
| try { | |||||
| wxBillDepositMapper.insertSelective(wxBillDeposit); | |||||
| } catch (Exception e) { | |||||
| logger.error("添加押金账单失败,e:" + e.getMessage()); | |||||
| throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); | |||||
| } | |||||
| } | |||||
| } | |||||
| @Transactional(rollbackFor = {Exception.class}) | @Transactional(rollbackFor = {Exception.class}) | ||||
| public void buildRent(WxRentContract wxRentContract) { | public void buildRent(WxRentContract wxRentContract) { | ||||
| @@ -11,6 +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.WxBillDepositMapper; | |||||
| import com.iformall.mapper.WxBillRentMapper; | import com.iformall.mapper.WxBillRentMapper; | ||||
| import com.iformall.mapper.WxRentContractMapper; | import com.iformall.mapper.WxRentContractMapper; | ||||
| import com.iformall.mapper.WxShopMapper; | import com.iformall.mapper.WxShopMapper; | ||||
| @@ -50,42 +51,46 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| @Autowired | @Autowired | ||||
| WxBillRentMapper wxBillRentMapper; | WxBillRentMapper wxBillRentMapper; | ||||
| @Autowired | |||||
| WxBillDepositMapper wxBillDepositMapper; | |||||
| @Override | @Override | ||||
| public Map<String, Object> listAsPage(WxRentContract record, Integer pageIndex, Integer pageSize) { | public Map<String, Object> listAsPage(WxRentContract 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 = wxRentContractMapper.queryRentContractData(record); | List<Map<String, Object>> rentContractData = wxRentContractMapper.queryRentContractData(record); | ||||
| PageInfo<Map<String, Object>> pageInfo = new PageInfo<>(rentContractData); | PageInfo<Map<String, Object>> pageInfo = new PageInfo<>(rentContractData); | ||||
| Map<String,Object> result =new HashMap<>(); | |||||
| result.put("rentContractStatusInfo",rentContractStatusInfo); | |||||
| result.put("pageInfo",pageInfo); | |||||
| Map<String, Object> result = new HashMap<>(); | |||||
| result.put("rentContractStatusInfo", rentContractStatusInfo); | |||||
| result.put("pageInfo", pageInfo); | |||||
| return result; | return result; | ||||
| //return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxRentContractMapper.findList(record)); | |||||
| } | } | ||||
| @Override | @Override | ||||
| public ResultData getById(Long id) { | public ResultData getById(Long id) { | ||||
| Map<String,Object> result=new HashMap<>(); | |||||
| Map<String, Object> result = new HashMap<>(); | |||||
| WxRentContract wxRentContract = wxRentContractMapper.selectByPrimaryKey(id); | WxRentContract wxRentContract = wxRentContractMapper.selectByPrimaryKey(id); | ||||
| wxRentContract.setPrice(wxRentContract.getPrice()!=null?wxRentContract.getPrice()/100:0); | |||||
| result.put("wxRentContract",wxRentContract); | |||||
| wxRentContract.setPrice(wxRentContract.getPrice() != null ? wxRentContract.getPrice() / 100 : 0); | |||||
| wxRentContract.setDeposit(wxRentContract.getDeposit() != null ? wxRentContract.getDeposit() * 100 : 0); | |||||
| result.put("wxRentContract", wxRentContract); | |||||
| //关联的商户 | //关联的商户 | ||||
| if(wxRentContract.getMerchantId()!=null){ | |||||
| if (wxRentContract.getMerchantId() != null) { | |||||
| WxMerchant wxMerchant = wxMerchantService.getById(wxRentContract.getMerchantId()); | WxMerchant wxMerchant = wxMerchantService.getById(wxRentContract.getMerchantId()); | ||||
| result.put("wxMerchant",wxMerchant); | |||||
| }else{ | |||||
| result.put("wxMerchant",null); | |||||
| result.put("wxMerchant", wxMerchant); | |||||
| } else { | |||||
| result.put("wxMerchant", null); | |||||
| } | } | ||||
| //关联的店铺 | //关联的店铺 | ||||
| if(wxRentContract.getShopId()!=null){ | |||||
| List<WxShop> list=new ArrayList<>(); | |||||
| if (wxRentContract.getShopId() != null) { | |||||
| List<WxShop> list = new ArrayList<>(); | |||||
| WxShop wxShop = wxShopMapper.selectByPrimaryKey(wxRentContract.getShopId()); | WxShop wxShop = wxShopMapper.selectByPrimaryKey(wxRentContract.getShopId()); | ||||
| list.add(wxShop); | list.add(wxShop); | ||||
| result.put("wxShops",list); | |||||
| }else{ | |||||
| result.put("wxShops",Collections.EMPTY_LIST); | |||||
| result.put("wxShops", list); | |||||
| } else { | |||||
| result.put("wxShops", Collections.EMPTY_LIST); | |||||
| } | } | ||||
| return new ResultData(Result.SUCCESS, "查询成功",result); | |||||
| return new ResultData(Result.SUCCESS, "查询成功", result); | |||||
| } | } | ||||
| @Transactional(rollbackFor = {Exception.class}) | @Transactional(rollbackFor = {Exception.class}) | ||||
| @@ -97,8 +102,8 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| record.setId(idWorker.nextId()); | record.setId(idWorker.nextId()); | ||||
| Calendar instance = Calendar.getInstance(); | Calendar instance = Calendar.getInstance(); | ||||
| instance.setTime(record.getRentalStartDate()); | instance.setTime(record.getRentalStartDate()); | ||||
| instance.add(Calendar.MONTH,record.getLease()); | |||||
| instance.add(Calendar.DAY_OF_MONTH,-1); | |||||
| instance.add(Calendar.MONTH, record.getLease()); | |||||
| instance.add(Calendar.DAY_OF_MONTH, -1); | |||||
| record.setRentalEndDate(instance.getTime()); | record.setRentalEndDate(instance.getTime()); | ||||
| Date date = new Date(); | Date date = new Date(); | ||||
| record.setCreatetime(date); | record.setCreatetime(date); | ||||
| @@ -109,29 +114,33 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| logger.error("保存租赁合同信息失败,e:" + e.getMessage()); | logger.error("保存租赁合同信息失败,e:" + e.getMessage()); | ||||
| throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); | throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); | ||||
| } | } | ||||
| return new ResultData(Result.SUCCESS, "保存租赁合同信息成功",record); | |||||
| return new ResultData(Result.SUCCESS, "保存租赁合同信息成功", record); | |||||
| } else {//更新租赁合同信息 | } else {//更新租赁合同信息 | ||||
| Calendar instance = Calendar.getInstance(); | Calendar instance = Calendar.getInstance(); | ||||
| instance.setTime(record.getRentalStartDate()); | instance.setTime(record.getRentalStartDate()); | ||||
| instance.add(Calendar.MONTH,record.getLease()); | |||||
| instance.add(Calendar.DAY_OF_MONTH,-1); | |||||
| instance.add(Calendar.MONTH, record.getLease()); | |||||
| instance.add(Calendar.DAY_OF_MONTH, -1); | |||||
| record.setRentalEndDate(instance.getTime()); | record.setRentalEndDate(instance.getTime()); | ||||
| record.setPrice(record.getPrice()!=null?record.getPrice()*100:0); | |||||
| record.setPrice(record.getPrice() != null ? record.getPrice() * 100 : 0); | |||||
| record.setDeposit(record.getDeposit() != null ? record.getDeposit() * 100 : 0); | |||||
| record.setUpdatetime(new Date()); | record.setUpdatetime(new Date()); | ||||
| try { | try { | ||||
| wxRentContractMapper.updateByPrimaryKeySelective(record); | wxRentContractMapper.updateByPrimaryKeySelective(record); | ||||
| //建立账单 | //建立账单 | ||||
| if(record.getMerchantId()!=null && record.getStatus().equals(EnumRentContractStatus.SIGNED_RENT_UNPAID.getCode()) | |||||
| && record.getReceivePeriod()!=null){ | |||||
| if (record.getMerchantId() != null && record.getStatus().equals(EnumRentContractStatus.SIGNED_RENT_UNPAID.getCode()) | |||||
| && record.getReceivePeriod() != null) { | |||||
| WxBillRent wxBillRent = new WxBillRent(); | WxBillRent wxBillRent = new WxBillRent(); | ||||
| wxBillRent.setMerchantId(record.getMerchantId()); | wxBillRent.setMerchantId(record.getMerchantId()); | ||||
| List<Map<String, Object>> billRentList = wxBillRentMapper.queryBillRentList(wxBillRent); | List<Map<String, Object>> billRentList = wxBillRentMapper.queryBillRentList(wxBillRent); | ||||
| if(billRentList.size()==0){ | |||||
| if (billRentList.size() == 0) { | |||||
| WxMerchant wxMerchant = new WxMerchant(); | WxMerchant wxMerchant = new WxMerchant(); | ||||
| wxMerchant.setId(record.getMerchantId()); | wxMerchant.setId(record.getMerchantId()); | ||||
| wxMerchant.setTenantId(record.getTenantId()); | wxMerchant.setTenantId(record.getTenantId()); | ||||
| //租金 | |||||
| buildRent(wxMerchant); | buildRent(wxMerchant); | ||||
| //押金 | |||||
| buildDeposit(wxMerchant); | |||||
| } | } | ||||
| } | } | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| @@ -143,6 +152,60 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| } | } | ||||
| @Transactional(rollbackFor = {Exception.class}) | |||||
| public void buildDeposit(WxMerchant wxMerchant) { | |||||
| MallUserInfo user = (MallUserInfo) SecurityUtils.getSubject().getSession().getAttribute("userSession"); | |||||
| WxRentContract wxRentContract = new WxRentContract(); | |||||
| wxRentContract.setMerchantId(wxMerchant.getId()); | |||||
| List<WxRentContract> list = wxRentContractMapper.findList(wxRentContract); | |||||
| if (list.size() > 0) { | |||||
| wxRentContract = list.get(0); | |||||
| Integer receivePeriod = wxRentContract.getReceivePeriod(); | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| WxBillDeposit wxBillDeposit = new WxBillDeposit(); | |||||
| wxBillDeposit.setId(idWorker.nextId()); | |||||
| wxBillDeposit.setRentContractId(wxRentContract.getId()); | |||||
| wxBillDeposit.setReceivePay(0); | |||||
| wxBillDeposit.setPay(0); | |||||
| int needpay = wxRentContract.getDeposit(); | |||||
| wxBillDeposit.setNeedPay(needpay); | |||||
| wxBillDeposit.setOwe(needpay); | |||||
| Date date = new Date(); | |||||
| Calendar instance = Calendar.getInstance(); | |||||
| instance.setTime(wxRentContract.getRentalStartDate()); | |||||
| instance.add(Calendar.MONTH, receivePeriod.intValue()); | |||||
| instance.add(Calendar.DAY_OF_MONTH, -1); | |||||
| Date time = instance.getTime(); | |||||
| wxBillDeposit.setReceiveDate(time); | |||||
| //截止收租日在当前时间之前 | |||||
| if (wxBillDeposit.getReceiveDate().before(date)) { | |||||
| long day = (time.getTime() - date.getTime()) / (24 * 60 * 60 * 1000); | |||||
| wxBillDeposit.setStatus(EnumBillRentStatus.NOT_PAID.getCode()); | |||||
| wxBillDeposit.setExpiredDay(day); | |||||
| wxBillDeposit.setReceiveDate(time); | |||||
| } else { | |||||
| wxBillDeposit.setStatus(EnumBillRentStatus.WAIT_PAY.getCode()); | |||||
| wxBillDeposit.setExpiredDay(0L); | |||||
| wxBillDeposit.setReceiveDate(time); | |||||
| } | |||||
| wxBillDeposit.setTenantId(wxMerchant.getTenantId()); | |||||
| wxBillDeposit.setIsDel(0); | |||||
| wxBillDeposit.setMerchantId(wxMerchant.getId()); | |||||
| wxBillDeposit.setUserId(user.getId()); | |||||
| wxBillDeposit.setShopId(wxRentContract.getShopId()); | |||||
| wxBillDeposit.setCreatetime(date); | |||||
| wxBillDeposit.setUpdatetime(date); | |||||
| try { | |||||
| wxBillDepositMapper.insertSelective(wxBillDeposit); | |||||
| } catch (Exception e) { | |||||
| logger.error("添加押金账单失败,e:" + e.getMessage()); | |||||
| throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); | |||||
| } | |||||
| } | |||||
| } | |||||
| @Transactional(rollbackFor = {Exception.class}) | @Transactional(rollbackFor = {Exception.class}) | ||||
| public void buildRent(WxMerchant wxMerchant) { | public void buildRent(WxMerchant wxMerchant) { | ||||
| @@ -186,11 +249,11 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| now.add(Calendar.MONTH, receivePeriod.intValue()); | now.add(Calendar.MONTH, receivePeriod.intValue()); | ||||
| Date currenttime = now.getTime(); | Date currenttime = now.getTime(); | ||||
| //当前日期加上周期后小于截止收租日就是没有到期,否则当前待缴 | //当前日期加上周期后小于截止收租日就是没有到期,否则当前待缴 | ||||
| if(currenttime.before(wxBillRent.getReceiveDate())){ | |||||
| if (currenttime.before(wxBillRent.getReceiveDate())) { | |||||
| wxBillRent.setStatus(EnumBillRentStatus.NOT_EXPIRED.getCode()); | wxBillRent.setStatus(EnumBillRentStatus.NOT_EXPIRED.getCode()); | ||||
| wxBillRent.setExpiredDay(0L); | wxBillRent.setExpiredDay(0L); | ||||
| wxBillRent.setReceiveDate(time); | wxBillRent.setReceiveDate(time); | ||||
| }else{ | |||||
| } else { | |||||
| wxBillRent.setStatus(EnumBillRentStatus.WAIT_PAY.getCode()); | wxBillRent.setStatus(EnumBillRentStatus.WAIT_PAY.getCode()); | ||||
| wxBillRent.setExpiredDay(0L); | wxBillRent.setExpiredDay(0L); | ||||
| wxBillRent.setReceiveDate(time); | wxBillRent.setReceiveDate(time); | ||||
| @@ -204,9 +267,9 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| wxBillRent.setShopId(wxRentContract.getShopId()); | wxBillRent.setShopId(wxRentContract.getShopId()); | ||||
| wxBillRent.setCreatetime(date); | wxBillRent.setCreatetime(date); | ||||
| wxBillRent.setUpdatetime(date); | wxBillRent.setUpdatetime(date); | ||||
| try{ | |||||
| try { | |||||
| wxBillRentMapper.insertSelective(wxBillRent); | wxBillRentMapper.insertSelective(wxBillRent); | ||||
| }catch (Exception e){ | |||||
| } catch (Exception e) { | |||||
| logger.error("添加租赁账单失败,e:" + e.getMessage()); | logger.error("添加租赁账单失败,e:" + e.getMessage()); | ||||
| throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); | throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); | ||||
| } | } | ||||
| @@ -216,7 +279,6 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| } | } | ||||
| @Transactional(rollbackFor = {Exception.class}) | @Transactional(rollbackFor = {Exception.class}) | ||||
| @Override | @Override | ||||
| public ResultData deleteById(String id) { | public ResultData deleteById(String id) { | ||||
| @@ -230,7 +292,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| WxRentContract wxRentContract = wxRentContractMapper.selectByPrimaryKey(id); | WxRentContract wxRentContract = wxRentContractMapper.selectByPrimaryKey(id); | ||||
| String filesuffix = wxRentContract.getFilepath().substring(wxRentContract.getFilepath().lastIndexOf(".")); | String filesuffix = wxRentContract.getFilepath().substring(wxRentContract.getFilepath().lastIndexOf(".")); | ||||
| String filename=UUID.randomUUID()+filesuffix; | |||||
| String filename = UUID.randomUUID() + filesuffix; | |||||
| String filepath = Constant.fileDirectory; | String filepath = Constant.fileDirectory; | ||||
| String destPath = filepath + filename; | String destPath = filepath + filename; | ||||
| File dest = new File(destPath); | File dest = new File(destPath); | ||||
| @@ -239,11 +301,11 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| pDest.mkdirs(); | pDest.mkdirs(); | ||||
| } | } | ||||
| try { | try { | ||||
| downLoadFromUrl(wxRentContract.getFilepath(),filename,filepath); | |||||
| downLoadFromUrl(wxRentContract.getFilepath(), filename, filepath); | |||||
| downFile(destPath, wxRentContract.getFilename(), response, request); | downFile(destPath, wxRentContract.getFilename(), response, request); | ||||
| org.apache.commons.io.FileUtils.forceDelete(dest); | org.apache.commons.io.FileUtils.forceDelete(dest); | ||||
| } catch (IOException e) { | } catch (IOException e) { | ||||
| logger.info("创建本地文件失败"+e.getMessage()); | |||||
| logger.info("创建本地文件失败" + e.getMessage()); | |||||
| } | } | ||||
| } | } | ||||
| @@ -251,13 +313,13 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| @Override | @Override | ||||
| public Object getRentContractStatusInfo(String tenantId) { | public Object getRentContractStatusInfo(String tenantId) { | ||||
| Map<String,Object> resultData=new HashMap(); | |||||
| Map<String, Object> resultData = new HashMap(); | |||||
| //商铺信息 | //商铺信息 | ||||
| Map<String,Object> shopparams=new HashMap<>(); | |||||
| shopparams.put("tenantId",tenantId); | |||||
| shopparams.put("status",EnumShopStatus.NOT_RENT.getCode()); | |||||
| Map<String,Object> shopLeftInfo=wxShopMapper.queryShopLeftInfo(shopparams); | |||||
| resultData.put("shopLeftInfo",shopLeftInfo); | |||||
| Map<String, Object> shopparams = new HashMap<>(); | |||||
| shopparams.put("tenantId", tenantId); | |||||
| shopparams.put("status", EnumShopStatus.NOT_RENT.getCode()); | |||||
| Map<String, Object> shopLeftInfo = wxShopMapper.queryShopLeftInfo(shopparams); | |||||
| resultData.put("shopLeftInfo", shopLeftInfo); | |||||
| //需要更新的状态 | //需要更新的状态 | ||||
| resultData.putAll(updateStatus(tenantId)); | resultData.putAll(updateStatus(tenantId)); | ||||
| @@ -274,8 +336,8 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| wxRentContractMapper.updateByPrimaryKeySelective(wxRentContract); | wxRentContractMapper.updateByPrimaryKeySelective(wxRentContract); | ||||
| //停用商户 | //停用商户 | ||||
| wxMerchantService.disable(wxRentContract.getMerchantId()); | wxMerchantService.disable(wxRentContract.getMerchantId()); | ||||
| }catch (MallinkException e){ | |||||
| logger.info("终止合同失败:"+e.getMessage()); | |||||
| } catch (MallinkException e) { | |||||
| logger.info("终止合同失败:" + e.getMessage()); | |||||
| throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); | throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); | ||||
| } | } | ||||
| return new ResultData(Result.SUCCESS, "操作成功"); | return new ResultData(Result.SUCCESS, "操作成功"); | ||||
| @@ -284,19 +346,25 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| @Transactional(rollbackFor = {Exception.class}) | @Transactional(rollbackFor = {Exception.class}) | ||||
| @Override | @Override | ||||
| public ResultData updateMerchant(WxRentContract wxRentContract) { | public ResultData updateMerchant(WxRentContract wxRentContract) { | ||||
| WxRentContract record =wxRentContractMapper.selectByPrimaryKey(wxRentContract); | |||||
| WxRentContract record = wxRentContractMapper.selectByPrimaryKey(wxRentContract); | |||||
| record.setMerchantId(wxRentContract.getMerchantId()); | record.setMerchantId(wxRentContract.getMerchantId()); | ||||
| try{ | |||||
| try { | |||||
| wxRentContractMapper.updateByPrimaryKeySelective(record); | wxRentContractMapper.updateByPrimaryKeySelective(record); | ||||
| }catch (MallinkException e){ | |||||
| logger.info("关联合同商户失败:"+e.getMessage()); | |||||
| } catch (MallinkException e) { | |||||
| logger.info("关联合同商户失败:" + e.getMessage()); | |||||
| throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); | throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); | ||||
| } | } | ||||
| return new ResultData(Result.SUCCESS, "操作成功"); | return new ResultData(Result.SUCCESS, "操作成功"); | ||||
| } | } | ||||
| public Map<String,Object> updateStatus(String tenantId){ | |||||
| Map<String,Object> resultData=new HashMap(); | |||||
| @Override | |||||
| public Object getRentContractList(String tenantId) { | |||||
| return wxRentContractMapper.getRentContractList(tenantId); | |||||
| } | |||||
| public Map<String, Object> updateStatus(String tenantId) { | |||||
| Map<String, Object> resultData = new HashMap(); | |||||
| WxRentContract wxRentContract = new WxRentContract(); | WxRentContract wxRentContract = new WxRentContract(); | ||||
| wxRentContract.setTenantId(tenantId); | wxRentContract.setTenantId(tenantId); | ||||
| @@ -307,35 +375,35 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| //待签约 | //待签约 | ||||
| wxRentContract.setStatus(EnumRentContractStatus.WAIT_SIGN.getCode()); | wxRentContract.setStatus(EnumRentContractStatus.WAIT_SIGN.getCode()); | ||||
| wxRentContractMapper.updateRentWaitSignStatus(wxRentContract); | wxRentContractMapper.updateRentWaitSignStatus(wxRentContract); | ||||
| int waitSignCount=wxRentContractMapper.queryRentContractWaitSignStatus(wxRentContract); | |||||
| resultData.put("waitSignCount",waitSignCount); | |||||
| int waitSignCount = wxRentContractMapper.queryRentContractWaitSignStatus(wxRentContract); | |||||
| resultData.put("waitSignCount", waitSignCount); | |||||
| //计租中 | //计租中 | ||||
| wxRentContract.setStatus(EnumRentContractStatus.RENT_PAID.getCode()); | wxRentContract.setStatus(EnumRentContractStatus.RENT_PAID.getCode()); | ||||
| int rendPaidCount =wxRentContractMapper.queryRentContractPaidStatus(wxRentContract); | |||||
| int rendPaidCount = wxRentContractMapper.queryRentContractPaidStatus(wxRentContract); | |||||
| wxRentContractMapper.updateRentContractPaidStatus(wxRentContract); | wxRentContractMapper.updateRentContractPaidStatus(wxRentContract); | ||||
| resultData.put("rendPaidCount",rendPaidCount); | |||||
| resultData.put("rendPaidCount", rendPaidCount); | |||||
| //将到期 | //将到期 | ||||
| wxRentContract.setStatus(EnumRentContractStatus.CONTRACT_END_SOON.getCode()); | wxRentContract.setStatus(EnumRentContractStatus.CONTRACT_END_SOON.getCode()); | ||||
| int endSoonCount=wxRentContractMapper.queryRentContractEndSoonStatus(wxRentContract); | |||||
| int endSoonCount = wxRentContractMapper.queryRentContractEndSoonStatus(wxRentContract); | |||||
| wxRentContractMapper.updateRentContractEndSoonStatus(wxRentContract); | wxRentContractMapper.updateRentContractEndSoonStatus(wxRentContract); | ||||
| resultData.put("endSoonCount",endSoonCount); | |||||
| resultData.put("endSoonCount", endSoonCount); | |||||
| //到期 | //到期 | ||||
| wxRentContract.setStatus(EnumRentContractStatus.CONTRACT_END.getCode()); | wxRentContract.setStatus(EnumRentContractStatus.CONTRACT_END.getCode()); | ||||
| int endCount=wxRentContractMapper.queryRentContractEndStatus(wxRentContract); | |||||
| int endCount = wxRentContractMapper.queryRentContractEndStatus(wxRentContract); | |||||
| wxRentContractMapper.updateRentContractEndStatus(wxRentContract); | wxRentContractMapper.updateRentContractEndStatus(wxRentContract); | ||||
| resultData.put("endCount",endCount); | |||||
| resultData.put("endCount", endCount); | |||||
| return resultData; | return resultData; | ||||
| } | } | ||||
| public static void downLoadFromUrl(String urlStr,String fileName,String savePath) throws IOException{ | |||||
| public static void downLoadFromUrl(String urlStr, String fileName, String savePath) throws IOException { | |||||
| URL url = new URL(urlStr); | URL url = new URL(urlStr); | ||||
| HttpURLConnection conn = (HttpURLConnection)url.openConnection(); | |||||
| HttpURLConnection conn = (HttpURLConnection) url.openConnection(); | |||||
| //设置超时间为3秒 | //设置超时间为3秒 | ||||
| conn.setConnectTimeout(3*1000); | |||||
| conn.setConnectTimeout(3 * 1000); | |||||
| //防止屏蔽程序抓取而返回403错误 | //防止屏蔽程序抓取而返回403错误 | ||||
| conn.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)"); | conn.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)"); | ||||
| @@ -346,29 +414,29 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| //文件保存位置 | //文件保存位置 | ||||
| File saveDir = new File(savePath); | File saveDir = new File(savePath); | ||||
| if(!saveDir.exists()){ | |||||
| if (!saveDir.exists()) { | |||||
| saveDir.mkdir(); | saveDir.mkdir(); | ||||
| } | } | ||||
| File file = new File(saveDir+File.separator+fileName); | |||||
| File file = new File(saveDir + File.separator + fileName); | |||||
| FileOutputStream fos = new FileOutputStream(file); | FileOutputStream fos = new FileOutputStream(file); | ||||
| fos.write(getData); | fos.write(getData); | ||||
| if(fos!=null){ | |||||
| if (fos != null) { | |||||
| fos.close(); | fos.close(); | ||||
| } | } | ||||
| if(inputStream!=null){ | |||||
| if (inputStream != null) { | |||||
| inputStream.close(); | inputStream.close(); | ||||
| } | } | ||||
| System.out.println("info:"+url+" download success"); | |||||
| System.out.println("info:" + url + " download success"); | |||||
| } | } | ||||
| public static byte[] readInputStream(InputStream inputStream) throws IOException { | |||||
| public static byte[] readInputStream(InputStream inputStream) throws IOException { | |||||
| byte[] buffer = new byte[1024]; | byte[] buffer = new byte[1024]; | ||||
| int len = 0; | int len = 0; | ||||
| ByteArrayOutputStream bos = new ByteArrayOutputStream(); | ByteArrayOutputStream bos = new ByteArrayOutputStream(); | ||||
| while((len = inputStream.read(buffer)) != -1) { | |||||
| while ((len = inputStream.read(buffer)) != -1) { | |||||
| bos.write(buffer, 0, len); | bos.write(buffer, 0, len); | ||||
| } | } | ||||
| bos.close(); | bos.close(); | ||||
| @@ -382,9 +450,9 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| response.setContentType("bin"); | response.setContentType("bin"); | ||||
| String agent = req.getHeader("user-agent"); | String agent = req.getHeader("user-agent"); | ||||
| if (agent.contains("Firefox")) { | if (agent.contains("Firefox")) { | ||||
| response.setHeader("Content-disposition", "attachment; filename=" + new String(filename.getBytes("GB2312"),"ISO-8859-1")); | |||||
| response.setHeader("Content-disposition", "attachment; filename=" + new String(filename.getBytes("GB2312"), "ISO-8859-1")); | |||||
| } else { | } else { | ||||
| response.setHeader("Content-disposition","attachment; filename=" + java.net.URLEncoder.encode(filename,"UTF-8")); | |||||
| response.setHeader("Content-disposition", "attachment; filename=" + java.net.URLEncoder.encode(filename, "UTF-8")); | |||||
| } | } | ||||
| // 循环取出流中的数据 | // 循环取出流中的数据 | ||||
| byte[] b = new byte[1024]; | byte[] b = new byte[1024]; | ||||
| @@ -0,0 +1,102 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | |||||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||||
| <mapper namespace="com.iformall.mapper.WxBillDepositMapper"> | |||||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxBillDeposit"> | |||||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||||
| <result column="rent_contract_id" jdbcType="BIGINT" property="rentContractId" /> | |||||
| <result column="receive_pay" jdbcType="INTEGER" property="receivePay" /> | |||||
| <result column="pay" jdbcType="INTEGER" property="pay" /> | |||||
| <result column="receive_date" jdbcType="TIMESTAMP" property="receiveDate" /> | |||||
| <result column="pay_date" jdbcType="TIMESTAMP" property="payDate" /> | |||||
| <result column="createtime" jdbcType="TIMESTAMP" property="createtime" /> | |||||
| <result column="expired_day" jdbcType="BIGINT" property="expiredDay" /> | |||||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" /> | |||||
| <result column="owe" jdbcType="INTEGER" property="owe" /> | |||||
| <result column="status" jdbcType="INTEGER" property="status" /> | |||||
| <result column="is_del" jdbcType="INTEGER" property="isDel" /> | |||||
| <result column="need_pay" jdbcType="INTEGER" property="needPay" /> | |||||
| <result column="merchant_id" jdbcType="BIGINT" property="merchantId" /> | |||||
| <result column="user_id" jdbcType="BIGINT" property="userId" /> | |||||
| <result column="shop_id" jdbcType="BIGINT" property="shopId" /> | |||||
| <result column="updatetime" jdbcType="TIMESTAMP" property="updatetime" /> | |||||
| </resultMap> | |||||
| <sql id="allColumns"> | |||||
| `id`,`rent_contract_id`,`receive_pay`,`pay`,`receive_date`,`pay_date`,`createtime`,`expired_day`,`tenant_id`,`owe`,`status`,`is_del`,`need_pay`,`merchant_id`,`user_id`,`shop_id`,`updatetime` | |||||
| </sql> | |||||
| <sql id="dynamicWhereConditions"> | |||||
| where 1 = 1 | |||||
| <if test=" null != id "> and `id` = #{id} </if> | |||||
| <if test=" null != rentContractId "> and `rent_contract_id` = #{rentContractId} </if> | |||||
| <if test=" null != receivePay "> and `receive_pay` = #{receivePay} </if> | |||||
| <if test=" null != pay "> and `pay` = #{pay} </if> | |||||
| <if test=" null != receiveDate "> and `receive_date` = #{receiveDate} </if> | |||||
| <if test=" null != payDate "> and `pay_date` = #{payDate} </if> | |||||
| <if test=" null != createtime "> and `createtime` = #{createtime} </if> | |||||
| <if test=" null != expiredDay "> and `expired_day` = #{expiredDay} </if> | |||||
| <if test=" null != tenantId "> and `tenant_id` = #{tenantId} </if> | |||||
| <if test=" null != owe "> and `owe` = #{owe} </if> | |||||
| <if test=" null != status "> and `status` = #{status} </if> | |||||
| <if test=" null != isDel "> and `is_del` = #{isDel} </if> | |||||
| <if test=" null != needPay "> and `need_pay` = #{needPay} </if> | |||||
| <if test=" null != merchantId "> and `merchant_id` = #{merchantId} </if> | |||||
| <if test=" null != userId "> and `user_id` = #{userId} </if> | |||||
| <if test=" null != shopId "> and `shop_id` = #{shopId} </if> | |||||
| <if test=" null != updatetime "> and `updatetime` = #{updatetime} </if> | |||||
| <if test=" null != ids "> | |||||
| and id in | |||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||||
| #{idItem} | |||||
| </foreach> | |||||
| </if> | |||||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||||
| </sql> | |||||
| <select id="findList" parameterType="com.iformall.domain.po.WxBillDeposit" resultMap="BaseResultMap"> | |||||
| select <include refid="allColumns" /> from wx_bill_deposit | |||||
| <include refid="dynamicWhereConditions" /> | |||||
| </select> | |||||
| <select id="queryBillDepositList" parameterType="com.iformall.domain.po.WxRentContract" resultType="hashmap"> | |||||
| select br.`id`,br.`receive_pay` receivePay,br.`pay`,br.`receive_date` receiveDate, | |||||
| br.`pay_date` payDate,br.`createtime`,br.`expired_day` expiredDay,br.`owe`,br.`status`, | |||||
| br.`need_pay` needPay,m.`name` merchantName,s.shop_number shopNumber,br.`updatetime`, | |||||
| br.`merchant_id` merchantId | |||||
| from wx_bill_deposit br left join wx_merchant m on br.merchant_id=m.id | |||||
| left join wx_shop s on br.shop_id=s.id | |||||
| <where> | |||||
| <if test=" null != id ">and br.`id` = #{id}</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 != tenantId ">and br.`tenant_id` = #{tenantId}</if> | |||||
| <if test=" null != status ">and br.`status` = #{status}</if> | |||||
| <if test=" null != isDel ">and br.`is_del` = #{isDel}</if> | |||||
| </where> | |||||
| order by id | |||||
| </select> | |||||
| <select id="queryPayInfo" resultType="hashmap" parameterType="hashmap"> | |||||
| select sum(receive_pay) receivepay,sum(pay) pay,tenant_id from wx_bill_deposit | |||||
| where tenant_id=#{tenantId} and date_format(receive_date,'%Y-%m')=#{receiveDate} | |||||
| group by tenant_id | |||||
| </select> | |||||
| <update id="updateNotPaidStatus" parameterType="hashmap"> | |||||
| update wx_bill_deposit set status=#{notPaid},expired_day=DATEDIFF(now(),receive_date) | |||||
| where tenant_id=#{tenantId} and status!=#{paid} and DATEDIFF(now(),receive_date)>0 | |||||
| </update> | |||||
| <update id="updateWaitPayStatus" parameterType="hashmap"> | |||||
| update wx_bill_deposit set status=#{waitPay} where id in( | |||||
| select a.id from (select br.id,rc.receive_period,br.rent_contract_id,br.receive_date from wx_bill_deposit br | |||||
| left join wx_rent_contract rc on br.rent_contract_id=rc.id | |||||
| where br.tenant_id=#{tenantId} and br.status!=#{paid} and now() < br.receive_date | |||||
| and DATE_ADD(now(),INTERVAL 1 MONTH)>br.receive_date) a) | |||||
| </update> | |||||
| </mapper> | |||||
| @@ -13,7 +13,7 @@ | |||||
| <result column="filepath" jdbcType="VARCHAR" property="filepath"/> | <result column="filepath" jdbcType="VARCHAR" property="filepath"/> | ||||
| <result column="status" jdbcType="INTEGER" property="status"/> | <result column="status" jdbcType="INTEGER" property="status"/> | ||||
| <result column="contract_number" jdbcType="VARCHAR" property="contractNumber"/> | <result column="contract_number" jdbcType="VARCHAR" property="contractNumber"/> | ||||
| <result column="deposit" jdbcType="VARCHAR" property="deposit"/> | |||||
| <result column="deposit" jdbcType="INTEGER" property="deposit"/> | |||||
| <result column="pay_date" jdbcType="INTEGER" property="payDate"/> | <result column="pay_date" jdbcType="INTEGER" property="payDate"/> | ||||
| <result column="is_del" jdbcType="INTEGER" property="isDel"/> | <result column="is_del" jdbcType="INTEGER" property="isDel"/> | ||||
| <result column="merchant_name" jdbcType="VARCHAR" property="merchantName"/> | <result column="merchant_name" jdbcType="VARCHAR" property="merchantName"/> | ||||
| @@ -136,5 +136,9 @@ | |||||
| )s) and merchant_id is null and tenant_id=#{tenantId} | )s) and merchant_id is null and tenant_id=#{tenantId} | ||||
| </update> | </update> | ||||
| <select id="getRentContractList" parameterType="String" resultType="com.iformall.domain.po.WxRentContract"> | |||||
| select rc.*,s.shop_number from wx_rent_contract rc left join wx_shop s on rc.shop_id=s.id | |||||
| where rc.status not in(1,6,7) and rc.tenant_id=#{tenantId} | |||||
| </select> | |||||
| </mapper> | </mapper> | ||||