dcs 1 年之前
父節點
當前提交
3639b6d784

+ 33 - 5
virgo.api/src/main/java/com/bosshand/virgo/api/controller/PaymentController.java

@@ -1,11 +1,10 @@
 package com.bosshand.virgo.api.controller;
 
-import com.bosshand.virgo.api.model.Payment;
-import com.bosshand.virgo.api.model.PaymentInvoice;
-import com.bosshand.virgo.api.model.PaymentOrdinary;
-import com.bosshand.virgo.api.model.PaymentRecord;
+import com.bosshand.virgo.api.model.*;
 import com.bosshand.virgo.api.service.PaymentService;
+import com.bosshand.virgo.api.service.ProjectItemTargetRoomService;
 import com.bosshand.virgo.core.response.Response;
+import com.bosshand.virgo.core.utils.StringUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -24,6 +23,9 @@ public class PaymentController {
     @Autowired
     PaymentService paymentService;
 
+    @Autowired
+    ProjectItemTargetRoomService projectItemTargetRoomService;
+
     @ApiOperation("分页获取")
     @RequestMapping(value = "/{currPage}/{pageSize}", method = RequestMethod.POST)
     public Response list(@RequestBody Payment payment, @PathVariable int currPage, @PathVariable int pageSize) {
@@ -66,7 +68,12 @@ public class PaymentController {
     @ApiOperation("发票记录详情")
     @RequestMapping(value = "/invoice/{id}", method = RequestMethod.GET)
     public Response getInvoice(@PathVariable long id) {
-        return Response.ok(paymentService.getInvoice(id));
+        PaymentInvoice invoice = paymentService.getInvoice(id);
+        Map<Long, String> rooms = new HashMap();
+        if (StringUtil.notBlank(invoice.getProjectItemTargetRoomIds())) {
+            invoice.setRoomMap(projectItemTargetRoomService.getRoomLevel(rooms, invoice.getProjectItemTargetRoomIds()));
+        }
+        return Response.ok(invoice);
     }
 
     @ApiOperation("保存发票记录")
@@ -76,6 +83,18 @@ public class PaymentController {
         return Response.ok();
     }
 
+    @ApiOperation("分页获取发票记录")
+    @RequestMapping(value = "/invoice/{currPage}/{pageSize}", method = RequestMethod.POST)
+    public Response list(@RequestBody PaymentInvoice paymentInvoice, @PathVariable int currPage, @PathVariable int pageSize) {
+        int totalCount = paymentService.getPaymentInvoiceTotalCount(paymentInvoice);
+        List<PaymentInvoice> dataList = paymentService.getPaymentInvoiceLimit(paymentInvoice, currPage, pageSize);
+        rooms(dataList);
+        Map<String, Object> result = new HashMap<>();
+        result.put("dataList", dataList);
+        result.put("totalCount", totalCount);
+        return Response.ok(result);
+    }
+
     @ApiOperation("获取发票记录")
     @RequestMapping(value = "/invoice/query", method = RequestMethod.POST)
     public Response getInvoiceList(@RequestBody PaymentInvoice paymentInvoice) {
@@ -96,6 +115,15 @@ public class PaymentController {
         return Response.ok();
     }
 
+    private void rooms(List<PaymentInvoice> list) {
+        for (PaymentInvoice data : list) {
+            Map<Long, String> rooms = new HashMap();
+            if (StringUtil.notBlank(data.getProjectItemTargetRoomIds())) {
+                data.setRoomMap(projectItemTargetRoomService.getRoomLevel(rooms, data.getProjectItemTargetRoomIds()));
+            }
+        }
+    }
+
     /**
      * 付款记录
      */

+ 5 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/dao/PaymentInvoiceDao.java

@@ -2,6 +2,7 @@ package com.bosshand.virgo.api.dao;
 
 import com.bosshand.virgo.api.model.PaymentInvoice;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -16,6 +17,10 @@ public interface PaymentInvoiceDao {
 
     List<PaymentInvoice> getList(PaymentInvoice paymentInvoice);
 
+    int getTotalCount(PaymentInvoice paymentInvoice);
+
+    List<PaymentInvoice> getLimit(@Param("p") PaymentInvoice p, @Param("currIndex") int currIndex, @Param("pageSize") int pageSize);
+
     List<PaymentInvoice> getPaymentId(long paymentId);
 
     PaymentInvoice get(long id);

+ 149 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/model/PaymentInvoice.java

@@ -1,5 +1,7 @@
 package com.bosshand.virgo.api.model;
 
+import java.util.Map;
+
 /**
  * 发票记录
  */
@@ -17,6 +19,57 @@ public class PaymentInvoice {
      */
     private long paymentId;
 
+    /**
+     * 项目id
+     */
+    private long projectId;
+
+    /**
+     * 房源ids
+     */
+    private String projectItemTargetRoomIds;
+
+    private Map<Long, String> roomMap;
+
+    /**
+     * 发票类型
+     */
+    private Integer type;
+
+    /**
+     * 发票状态
+     */
+    private Integer status;
+
+    /**
+     * 发票代码
+     */
+    private String code;
+
+    /**
+     * 发票号码
+     */
+    private String number;
+
+    /**
+     * 付款企业id
+     */
+    private long payMerchantId;
+
+    private String payMerchantName;
+
+    /**
+     * 付款客户id
+     */
+    private long payClientId;
+
+    private String payClientName;
+
+    /**
+     * 货物名称
+     */
+    private String cargoName;
+
     /**
      * 名称
      */
@@ -61,6 +114,102 @@ public class PaymentInvoice {
         this.paymentId = paymentId;
     }
 
+    public long getProjectId() {
+        return projectId;
+    }
+
+    public void setProjectId(long projectId) {
+        this.projectId = projectId;
+    }
+
+    public String getProjectItemTargetRoomIds() {
+        return projectItemTargetRoomIds;
+    }
+
+    public void setProjectItemTargetRoomIds(String projectItemTargetRoomIds) {
+        this.projectItemTargetRoomIds = projectItemTargetRoomIds;
+    }
+
+    public Map<Long, String> getRoomMap() {
+        return roomMap;
+    }
+
+    public void setRoomMap(Map<Long, String> roomMap) {
+        this.roomMap = roomMap;
+    }
+
+    public Integer getType() {
+        return type;
+    }
+
+    public void setType(Integer type) {
+        this.type = type;
+    }
+
+    public Integer getStatus() {
+        return status;
+    }
+
+    public void setStatus(Integer status) {
+        this.status = status;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public String getNumber() {
+        return number;
+    }
+
+    public void setNumber(String number) {
+        this.number = number;
+    }
+
+    public long getPayMerchantId() {
+        return payMerchantId;
+    }
+
+    public void setPayMerchantId(long payMerchantId) {
+        this.payMerchantId = payMerchantId;
+    }
+
+    public String getPayMerchantName() {
+        return payMerchantName;
+    }
+
+    public void setPayMerchantName(String payMerchantName) {
+        this.payMerchantName = payMerchantName;
+    }
+
+    public long getPayClientId() {
+        return payClientId;
+    }
+
+    public void setPayClientId(long payClientId) {
+        this.payClientId = payClientId;
+    }
+
+    public String getPayClientName() {
+        return payClientName;
+    }
+
+    public void setPayClientName(String payClientName) {
+        this.payClientName = payClientName;
+    }
+
+    public String getCargoName() {
+        return cargoName;
+    }
+
+    public void setCargoName(String cargoName) {
+        this.cargoName = cargoName;
+    }
+
     public String getName() {
         return name;
     }

+ 25 - 2
virgo.api/src/main/java/com/bosshand/virgo/api/service/PaymentService.java

@@ -174,8 +174,31 @@ public class PaymentService {
         return paymentInvoiceDao.get(id);
     }
 
-    public int insertInvoice(PaymentInvoice paymentInvoice) {
-        return paymentInvoiceDao.insert(paymentInvoice);
+    public void insertInvoice(PaymentInvoice paymentInvoice) {
+        if (paymentInvoice.getPaymentId() != 0) {
+            Payment payment = paymentDao.get(paymentInvoice.getPaymentId());
+            Contract contract = contractDao.get(payment.getContractId());
+            paymentInvoice.setProjectId(payment.getProjectId());
+            paymentInvoice.setProjectItemTargetRoomIds(contract.getProjectItemTargetRoomIds());
+            paymentInvoice.setPayClientId(payment.getPayClientId());
+            paymentInvoice.setPayMerchantId(payment.getPayMerchantId());
+        }
+        if (paymentInvoice.getPaymentOrdinaryId() != 0) {
+            PaymentOrdinary paymentOrdinary = paymentOrdinaryDao.get(paymentInvoice.getPaymentOrdinaryId());
+            paymentInvoice.setProjectId(paymentOrdinary.getProjectId());
+            paymentInvoice.setPayClientId(paymentOrdinary.getPayClientId());
+            paymentInvoice.setPayMerchantId(paymentOrdinary.getPayMerchantId());
+        }
+        paymentInvoiceDao.insert(paymentInvoice);
+    }
+
+    public int getPaymentInvoiceTotalCount(PaymentInvoice paymentInvoice) {
+        return paymentInvoiceDao.getTotalCount(paymentInvoice);
+    }
+
+    public List<PaymentInvoice> getPaymentInvoiceLimit(PaymentInvoice paymentInvoice, int currPage, int pageSize) {
+        int currIndex = (currPage - 1) * pageSize;
+        return paymentInvoiceDao.getLimit(paymentInvoice, currIndex, pageSize);
     }
 
     public List<PaymentInvoice> getInvoiceList(PaymentInvoice paymentInvoice) {

+ 118 - 3
virgo.api/src/main/resources/mapper/PaymentInvoiceMapper.xml

@@ -8,6 +8,40 @@
         <id column="id" property="id"/>
         <result column="paymentOrdinaryId" property="paymentOrdinaryId"/>
         <result column="paymentId" property="paymentId"/>
+
+        <result column="projectId" property="projectId"/>
+        <result column="projectItemTargetRoomIds" property="projectItemTargetRoomIds"/>
+        <result column="type" property="type"/>
+        <result column="status" property="status"/>
+        <result column="code" property="code"/>
+        <result column="number" property="number"/>
+        <result column="payMerchantId" property="payMerchantId"/>
+        <result column="payClientId" property="payClientId"/>
+        <result column="cargoName" property="cargoName"/>
+
+        <result column="name" property="name"/>
+        <result column="date" property="date"/>
+        <result column="attachment" property="attachment"/>
+        <result column="data" property="data"/>
+    </resultMap>
+
+    <resultMap type="com.bosshand.virgo.api.model.PaymentInvoice" id="paymentInvoiceResult">
+        <id column="id" property="id"/>
+        <result column="paymentOrdinaryId" property="paymentOrdinaryId"/>
+        <result column="paymentId" property="paymentId"/>
+
+        <result column="projectId" property="projectId"/>
+        <result column="projectItemTargetRoomIds" property="projectItemTargetRoomIds"/>
+        <result column="type" property="type"/>
+        <result column="status" property="status"/>
+        <result column="code" property="code"/>
+        <result column="number" property="number"/>
+        <result column="payMerchantId" property="payMerchantId"/>
+        <result column="payMerchantName" property="payMerchantName"/>
+        <result column="payClientId" property="payClientId"/>
+        <result column="payClientName" property="payClientName"/>
+        <result column="cargoName" property="cargoName"/>
+
         <result column="name" property="name"/>
         <result column="date" property="date"/>
         <result column="attachment" property="attachment"/>
@@ -15,8 +49,12 @@
     </resultMap>
 
     <insert id="insert" parameterType="com.bosshand.virgo.api.model.PaymentInvoice" useGeneratedKeys="true" keyProperty="id">
-        INSERT INTO  payment_invoice (`paymentOrdinaryId`, `paymentId`, `name`, `date`, `attachment`, `data`)
-        VALUES (#{paymentOrdinaryId}, #{paymentId}, #{name}, #{date}, #{attachment}, #{data})
+        INSERT INTO  payment_invoice (`paymentOrdinaryId`, `paymentId`,
+                                      `projectId`, `projectItemTargetRoomIds`, `type`, `status`, `code`, `number`, `payMerchantId`, `payClientId`, `cargoName`,
+                                      `name`, `date`, `attachment`, `data`)
+        VALUES (#{paymentOrdinaryId}, #{paymentId},
+                #{projectId}, #{projectItemTargetRoomIds}, #{type}, #{status}, #{code}, #{number}, #{payMerchantId}, #{payClientId}, #{cargoName},
+                #{name}, #{date}, #{attachment}, #{data})
     </insert>
 
     <delete id="delete">
@@ -29,6 +67,18 @@
         <trim prefix="set" suffixOverrides=",">
             <if test="paymentOrdinaryId!=0">paymentOrdinaryId=#{paymentOrdinaryId},</if>
             <if test="paymentId!=0">paymentId=#{paymentId},</if>
+
+            <if test="projectId!=0">projectId=#{projectId},</if>
+            <if test="projectItemTargetRoomIds!=null">projectItemTargetRoomIds=#{projectItemTargetRoomIds},</if>
+            <if test="type!=null">type=#{type},</if>
+            <if test="status!=null">status=#{status},</if>
+            <if test="code!=null">code=#{code},</if>
+            <if test="number!=null">number=#{number},</if>
+            <if test="payMerchantId!=0">payMerchantId=#{payMerchantId},</if>
+            <if test="payClientId!=0">payClientId=#{payClientId},</if>
+            <if test="cargoName!=null">cargoName=#{cargoName},</if>
+
+
             <if test="name!=null">name=#{name},</if>
             <if test="date!=null">date=#{date},</if>
             <if test="attachment!=null">attachment=#{attachment},</if>
@@ -37,11 +87,75 @@
         WHERE id=#{id}
     </update>
 
+    <select id="getTotalCount" parameterType="com.bosshand.virgo.api.model.PaymentInvoice" resultType="Integer">
+        SELECT count(*) FROM payment_invoice
+        <where>
+            <if test="paymentOrdinaryId!=0">and paymentOrdinaryId=#{paymentOrdinaryId}</if>
+            <if test="paymentId!=0">and paymentId=#{paymentId}</if>
+
+            <if test="projectId!=0">and projectId=#{projectId}</if>
+            <if test="projectItemTargetRoomIds!=null">and projectItemTargetRoomIds=#{projectItemTargetRoomIds}</if>
+            <if test="type!=null">and type=#{type}</if>
+            <if test="status!=null">and status=#{status}</if>
+            <if test="code!=null">and code=#{code}</if>
+            <if test="number!=null">and number=#{number},</if>
+            <if test="payMerchantId!=0">and payMerchantId=#{payMerchantId}</if>
+            <if test="payClientId!=0">and payClientId=#{payClientId}</if>
+            <if test="cargoName!=null">and cargoName=#{cargoName}</if>
+
+            <if test="name!=null">and name=#{name}</if>
+            <if test="date!=null">and date=#{date}</if>
+            <if test="attachment!=null">and attachment=#{attachment}</if>
+            <if test="data!=null">and data=#{data}</if>
+        </where>
+    </select>
+
+    <sql id="query">
+        SELECT a.*, c.name as payMerchantName, d.name as payClientName FROM payment_invoice a
+        LEFT JOIN merchant c ON a.payMerchantId = c.id
+        LEFT JOIN mgr_client d ON a.payClientId = d.id
+    </sql>
+
+    <select id="getLimit" resultMap="paymentInvoiceResult">
+        <include refid="query"/>
+        <where>
+            <if test="p.paymentOrdinaryId!=0">and a.paymentOrdinaryId=#{p.paymentOrdinaryId}</if>
+            <if test="p.paymentId!=0">and a.paymentId=#{p.paymentId}</if>
+
+            <if test="p.projectId!=0">and a.projectId=#{p.projectId}</if>
+            <if test="p.projectItemTargetRoomIds!=null">and a.projectItemTargetRoomIds=#{p.projectItemTargetRoomIds}</if>
+            <if test="p.type!=null">and a.type=#{p.type}</if>
+            <if test="p.status!=null">and a.status=#{p.status}</if>
+            <if test="p.code!=null">and a.code=#{p.code}</if>
+            <if test="p.number!=null">and a.number=#{p.number},</if>
+            <if test="p.payMerchantId!=0">and a.payMerchantId=#{p.payMerchantId}</if>
+            <if test="p.payClientId!=0">and a.payClientId=#{p.payClientId}</if>
+            <if test="p.cargoName!=null">and a.cargoName=#{p.cargoName}</if>
+
+            <if test="p.name!=null">and a.name=#{p.name}</if>
+            <if test="p.date!=null">and a.date=#{p.date}</if>
+            <if test="p.attachment!=null">and a.attachment=#{p.attachment}</if>
+            <if test="p.data!=null">and a.data=#{p.data}</if>
+        </where>
+        limit #{currIndex} , #{pageSize}
+    </select>
+
     <select id="getList" resultMap="result">
         SELECT * FROM  payment_invoice
         <where>
             <if test="paymentOrdinaryId!=0">and paymentOrdinaryId=#{paymentOrdinaryId}</if>
             <if test="paymentId!=0">and paymentId=#{paymentId}</if>
+
+            <if test="projectId!=0">and projectId=#{projectId}</if>
+            <if test="projectItemTargetRoomIds!=null">and projectItemTargetRoomIds=#{projectItemTargetRoomIds}</if>
+            <if test="type!=null">and type=#{type}</if>
+            <if test="status!=null">and status=#{status}</if>
+            <if test="code!=null">and code=#{code}</if>
+            <if test="number!=null">and number=#{number},</if>
+            <if test="payMerchantId!=0">and payMerchantId=#{payMerchantId}</if>
+            <if test="payClientId!=0">and payClientId=#{payClientId}</if>
+            <if test="cargoName!=null">and cargoName=#{cargoName}</if>
+
             <if test="name!=null">and name=#{name}</if>
             <if test="date!=null">and date=#{date}</if>
             <if test="attachment!=null">and attachment=#{attachment}</if>
@@ -58,7 +172,8 @@
     </select>
 
     <select id="get" resultMap="result">
-        SELECT * FROM  payment_invoice where id = #{id}
+        <include refid="query"/>
+        where a.id = #{id}
     </select>
 
 </mapper>