Browse Source

[chg]新增合同付款信息和批量修改付款信息

别傲 5 years ago
parent
commit
d285412a29

+ 16 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/contract/controller/ContractController.java

@@ -3,7 +3,9 @@ package cn.com.ty.lift.business.contract.controller;
 import cn.com.ty.lift.business.contract.dao.entity.Contracts;
 import cn.com.ty.lift.business.contract.dao.entity.model.ContractRequest;
 import cn.com.ty.lift.business.contract.dao.entity.model.ContractsHistoryRequest;
+import cn.com.ty.lift.business.contract.dao.entity.model.PaymentRequest;
 import cn.com.ty.lift.business.contract.service.ContractService;
+import cn.com.ty.lift.business.contract.service.PaymentService;
 import cn.com.xwy.boot.web.dto.RestResponse;
 import org.springframework.web.bind.annotation.*;
 
@@ -21,6 +23,9 @@ public class ContractController {
     @Resource
     private ContractService contractService;
 
+    @Resource
+    private PaymentService paymentService;
+
 
     /**
      * @param request 合同列表查询条件
@@ -79,4 +84,15 @@ public class ContractController {
         return contractService.detail(id);
     }
 
+    /**
+     * @param request paymentList 收款信息列表
+     * @return 1.成功, 0.失败, 消息描述
+     * @description 批量修改收款信息
+     * @date 2019/12/11 3:50 PM
+     */
+    @PostMapping("updateBatchPayment")
+    public RestResponse updateBatchPayment(@RequestBody PaymentRequest request) {
+        return paymentService.updateBatchPayment(request);
+    }
+
 }

+ 6 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/contract/dao/entity/Contracts.java

@@ -3,6 +3,7 @@ package cn.com.ty.lift.business.contract.dao.entity;
 import java.io.Serializable;
 import java.math.BigDecimal;
 import java.util.Date;
+import java.util.List;
 
 import lombok.Data;
 
@@ -112,4 +113,9 @@ public class Contracts implements Serializable {
      * 上一个合同编号
      */
     private Long previousId;
+
+    /**
+     * 收款列表
+     */
+    private List<Payment> paymentList;
 }

+ 120 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/contract/dao/entity/Payment.java

@@ -0,0 +1,120 @@
+package cn.com.ty.lift.business.contract.dao.entity;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import lombok.Data;
+
+/**
+ * 实体类 - 表:payment
+ * @author bieao
+ * @since 2019-12-11 14:22:13
+ */
+@Data
+public class Payment {
+
+	/**
+	 * 收付款ID
+	 */
+	@TableId(value = "id",type = IdType.ID_WORKER)
+	private Long id;
+
+	/**
+	 * 合同编号
+	 */
+	private Long contractsId;
+
+	/**
+	 * 收付款事项   1:合同分期费
+	 */
+	private Integer type;
+
+	/**
+	 * 摘要 1服务积分 2贡献积分
+	 */
+	@Deprecated
+	private String summary;
+
+	/**
+	 * 应收金额
+	 */
+	private BigDecimal planMoney;
+
+	/**
+	 * 已收金额
+	 */
+	private BigDecimal workMoney;
+
+	/**
+	 * 应收时间
+	 */
+	private Date planDate;
+
+	/**
+	 * 已收时间
+	 */
+	private Date workDate;
+
+	/**
+	 * 收款人编号
+	 */
+	private Long cashierUser;
+
+	/**
+	 * 是否上传票据
+	 */
+	private Integer isTicket;
+
+	/**
+	 * 是否上传银行回单
+	 */
+	private Integer isCollection;
+
+	/**
+	 * 备注
+	 */
+	private String remarks;
+
+	/**
+	 * 收付款状态
+	 */
+	@Deprecated
+	private Integer status;
+
+	/**
+	 * 票据图片
+	 */
+	private String noteImgUrl;
+
+	/**
+	 * 银行回执单图片
+	 */
+	private String bankImgUrl;
+
+	/**
+	 * 创建时间
+	 */
+	private Date createDate;
+
+	/**
+	 * 收付款编号
+	 */
+	private String code;
+
+	/**
+	 * 开票金额
+	 */
+	private BigDecimal amountInvoice;
+
+	/**
+	 * 开票日期
+	 */
+	private Date billingDate;
+
+	/**
+	 * 期数
+	 */
+	private Integer numberPeriods;
+}

+ 19 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/contract/dao/entity/model/PaymentRequest.java

@@ -0,0 +1,19 @@
+package cn.com.ty.lift.business.contract.dao.entity.model;
+
+import cn.com.ty.lift.business.contract.dao.entity.Payment;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @author bieao
+ * @date 2019/12/11
+ * @description
+ */
+@Data
+public class PaymentRequest {
+    /**
+     * 付款信息列表
+     */
+    private List<Payment> paymentList;
+}

+ 13 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/contract/dao/mapper/PaymentMapper.java

@@ -0,0 +1,13 @@
+package cn.com.ty.lift.business.contract.dao.mapper;
+
+import cn.com.ty.lift.business.contract.dao.entity.Payment;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * MyBatis Mapper 接口 - 表:payment
+ * @author bieao
+ * @since 2019-12-11 14:22:13
+ */
+public interface PaymentMapper extends BaseMapper<Payment> {
+
+}

+ 13 - 1
lift-business-service/src/main/java/cn/com/ty/lift/business/contract/service/ContractService.java

@@ -6,6 +6,7 @@ import cn.com.ty.lift.business.contract.dao.entity.model.ContractRequest;
 import cn.com.ty.lift.business.contract.dao.entity.model.ContractsHistoryRequest;
 import cn.com.ty.lift.business.contract.dao.mapper.ContractsHistoryMapper;
 import cn.com.ty.lift.business.contract.dao.mapper.ContractsMapper;
+import cn.com.ty.lift.business.framework.BusinessBasicException;
 import cn.com.ty.lift.business.framework.util.MessageUtils;
 import cn.com.ty.lift.common.constants.ApiConstants;
 import cn.com.xwy.boot.web.dto.RestResponse;
@@ -13,6 +14,7 @@ import cn.hutool.core.date.DateUtil;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
 import java.util.Date;
@@ -32,6 +34,9 @@ public class ContractService {
     @Resource
     private ContractsHistoryMapper contractsHistoryMapper;
 
+    @Resource
+    private PaymentService paymentService;
+
     /**
      * @param request 合同列表查询条件
      * @return RestResponse 合同分页列表结果
@@ -70,6 +75,7 @@ public class ContractService {
      * @description 新增合同
      * @date 2019/12/7 3:31 PM
      */
+    @Transactional(rollbackFor = Exception.class)
     public RestResponse add(Contracts contracts) {
         if (contracts.getNextId() == null) {
             //按当前日期时间戳自动生成合同编号
@@ -78,7 +84,13 @@ public class ContractService {
         }
         int result = contractsMapper.insert(contracts);
         if (result > 0) {
-            return RestResponse.ok(result, ApiConstants.RESULT_SUCCESS, MessageUtils.get("msg.add.success"));
+            //批量插入收款信息
+            boolean ret = paymentService.insertBatch(contracts);
+            if (ret) {
+                return RestResponse.ok(result, ApiConstants.RESULT_SUCCESS, MessageUtils.get("msg.add.success"));
+            } else {
+                throw new BusinessBasicException("批量插入收款信息失败");
+            }
         }
         return RestResponse.error(ApiConstants.RESULT_ERROR, MessageUtils.get("msg.add.fail"));
     }

+ 52 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/contract/service/PaymentService.java

@@ -0,0 +1,52 @@
+package cn.com.ty.lift.business.contract.service;
+
+import cn.com.ty.lift.business.contract.dao.entity.Contracts;
+import cn.com.ty.lift.business.contract.dao.entity.Payment;
+import cn.com.ty.lift.business.contract.dao.entity.model.PaymentRequest;
+import cn.com.ty.lift.business.contract.dao.mapper.PaymentMapper;
+import cn.com.ty.lift.business.framework.util.MessageUtils;
+import cn.com.ty.lift.common.constants.ApiConstants;
+import cn.com.xwy.boot.web.dto.RestResponse;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * @author bieao
+ * @date 2019/12/11
+ * @description 收款业务层
+ */
+@Service
+public class PaymentService extends ServiceImpl<PaymentMapper, Payment> {
+
+    /**
+     * @param contracts 合同信息
+     * @return  是否成功
+     * @description 批量插入收款信息
+     * @date 2019/12/11 4:34 PM
+     */
+    public boolean insertBatch(Contracts contracts) {
+        List<Payment> payments = contracts.getPaymentList();
+        //设置合同付款的合同编号
+        for (Payment entry : payments) {
+            entry.setContractsId(contracts.getNextId());
+        }
+        //批量插入付款信息
+        return saveBatch(payments);
+    }
+
+    /**
+     * @param request paymentList 收款信息列表
+     * @return 1.成功, 0.失败, 消息描述
+     * @description 批量修改收款信息
+     * @date 2019/12/11 3:50 PM
+     */
+    public RestResponse updateBatchPayment(PaymentRequest request) {
+        boolean result = updateBatchById(request.getPaymentList());
+        if (result) {
+            return RestResponse.ok(result, ApiConstants.RESULT_SUCCESS, MessageUtils.get("msg.modify.batch.success"));
+        }
+        return RestResponse.error(ApiConstants.RESULT_ERROR, MessageUtils.get("msg.modify.batch.fail"));
+    }
+}

+ 33 - 0
lift-business-service/src/main/resources/mapper/contract/PaymentMapper.xml

@@ -0,0 +1,33 @@
+<?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="cn.com.ty.lift.business.contract.dao.mapper.PaymentMapper" >
+	<resultMap id="BaseResultMap" type="cn.com.ty.lift.business.contract.dao.entity.Payment" >
+		<id column="id" property="id" jdbcType="BIGINT" />
+		<result column="contracts_id" property="contractsId" jdbcType="BIGINT" />
+		<result column="type" property="type" jdbcType="INTEGER" />
+		<result column="summary" property="summary" jdbcType="VARCHAR" />
+		<result column="plan_money" property="planMoney" jdbcType="DECIMAL" />
+		<result column="work_money" property="workMoney" jdbcType="DECIMAL" />
+		<result column="plan_date" property="planDate" jdbcType="TIMESTAMP" />
+		<result column="work_date" property="workDate" jdbcType="TIMESTAMP" />
+		<result column="cashier_user" property="cashierUser" jdbcType="BIGINT" />
+		<result column="is_ticket" property="isTicket" jdbcType="INTEGER" />
+		<result column="is_collection" property="isCollection" jdbcType="INTEGER" />
+		<result column="remarks" property="remarks" jdbcType="LONGVARCHAR" />
+		<result column="status" property="status" jdbcType="INTEGER" />
+		<result column="note_img_url" property="noteImgUrl" jdbcType="LONGVARCHAR" />
+		<result column="bank_img_url" property="bankImgUrl" jdbcType="LONGVARCHAR" />
+		<result column="create_date" property="createDate" jdbcType="TIMESTAMP" />
+		<result column="code" property="code" jdbcType="VARCHAR" />
+		<result column="amount_invoice" property="amountInvoice" jdbcType="DECIMAL" />
+		<result column="billing_date" property="billingDate" jdbcType="TIMESTAMP" />
+		<result column="number_periods" property="numberPeriods" jdbcType="INTEGER" />
+	</resultMap>
+
+	<sql id="Base_Column_List" >
+		id, contracts_id, type, summary, plan_money, work_money, plan_date, work_date, cashier_user, 
+		is_ticket, is_collection, remarks, status, note_img_url, bank_img_url, create_date, code, amount_invoice, billing_date,
+		number_periods
+	</sql>
+
+</mapper>