dcs 3 months ago
parent
commit
ab8a06a86d

+ 13 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/workark/model/OrderInfo.java

@@ -100,6 +100,11 @@ public class OrderInfo {
      */
     private long payOrganizationId;
 
+    /**
+     * 发票
+     */
+    private Invoice invoice;
+
     public Long getId() {
         return id;
     }
@@ -243,4 +248,12 @@ public class OrderInfo {
     public void setPayOrganizationId(long payOrganizationId) {
         this.payOrganizationId = payOrganizationId;
     }
+
+    public Invoice getInvoice() {
+        return invoice;
+    }
+
+    public void setInvoice(Invoice invoice) {
+        this.invoice = invoice;
+    }
 }

+ 2 - 17
virgo.api/src/main/java/com/bosshand/virgo/api/workark/service/InvoiceService.java

@@ -5,8 +5,6 @@ import com.bosshand.virgo.api.workark.dao.InvoiceModelDao;
 import com.bosshand.virgo.api.workark.dao.OrderInfoDao;
 import com.bosshand.virgo.api.workark.model.Invoice;
 import com.bosshand.virgo.api.workark.model.InvoiceModel;
-import com.bosshand.virgo.api.workark.model.OrderInfo;
-import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -49,26 +47,13 @@ public class InvoiceService {
     }
 
     public Invoice save(Invoice invoice) {
-
-        // 发票抬头
-        long invoiceModelId = invoice.getInvoiceModelId();
-
         String orderNo = invoice.getOrderNo();
         Invoice od = invoiceDao.getOrderNo(orderNo);
         if (od != null) {
             return od;
         }
-
-        InvoiceModel invoiceModel = invoiceModelDao.get(invoiceModelId);
-        Invoice invoice1 = new Invoice();
-        BeanUtils.copyProperties(invoiceModel, invoice1);
-        invoice1.setInvoiceModelId(invoiceModelId);
-        OrderInfo o = orderInfoDao.getOrderNo(orderNo);
-        invoice1.setAmount(o.getTotalFee());
-        invoice1.setOrderNo(invoice.getOrderNo());
-        invoice1.setState(0);
-        invoiceDao.save(invoice1);
-        return invoice1;
+        invoiceDao.save(invoice);
+        return invoice;
     }
 
     public void update(Invoice invoice) {

+ 50 - 26
virgo.api/src/main/resources/mapper/OrderInfoMapper.xml

@@ -23,52 +23,76 @@
         <result column="productLevelId" property="productLevelId"/>
         <result column="organizationId" property="organizationId"/>
         <result column="payOrganizationId" property="payOrganizationId"/>
+        <collection property="invoice" ofType="com.bosshand.virgo.api.workark.model.Invoice" resultMap="com.bosshand.virgo.api.workark.dao.InvoiceDao.result" columnPrefix="invoice_"/>
     </resultMap>
 
+    <sql id="query">
+        select a.*,
+               b.id                           as invoice_id,
+               b.invoiceModelId               as invoice_invoiceModelId,
+               b.organizationId               as invoice_organizationId,
+               b.userId                       as invoice_userId,
+               b.createTime                   as invoice_createTime,
+               b.updateTime                   as invoice_updateTime,
+               b.orderNo                      as invoice_orderNo,
+               b.type                         as invoice_type,
+               b.name                         as invoice_name,
+               b.taxpayerIdentificationNumber as invoice_taxpayerIdentificationNumber,
+               b.address                      as invoice_address,
+               b.phone                        as invoice_phone,
+               b.bankAccount                  as invoice_bankAccount,
+               b.bankAccountNumber            as invoice_bankAccountNumber,
+               b.content                      as invoice_content,
+               b.amount                       as invoice_amount,
+               b.file                         as invoice_file,
+               b.state                        as invoice_state
+        from workark_orderInfo a left join workark_invoice b on a.orderNo = b.orderNo
+    </sql>
+
     <select id="get" resultMap="result">
-        select * from workark_orderInfo where id = #{id}
+        <include refid="query" /> where a.id = #{id}
     </select>
 
     <select id="getOrderNo" resultMap="result">
-        select * from workark_orderInfo where orderNo = #{orderNo}
+        <include refid="query" /> where a.orderNo = #{orderNo}
     </select>
 
     <select id="getNoPayOrderByProductId" resultMap="result">
-        select * from workark_orderInfo where productId = #{productId} AND userId =#{userId} AND orderStatus=#{orderStatus}
+        <include refid="query" /> a.productId = #{productId} AND a.userId =#{userId} AND a.orderStatus=#{orderStatus}
     </select>
 
     <select id="getList" resultMap="result">
-        select * from workark_orderInfo
+        <include refid="query" />
         <where>
             <if test="title != null">
-                and title = #{title}
+                and a.title = #{title}
             </if>
             <if test="orderNo != null">
-                and orderNo = #{orderNo}
+                and a.orderNo = #{orderNo}
             </if>
             <if test="userId != null">
-                and userId = #{userId}
+                and a.userId = #{userId}
             </if>
             <if test="productId != null">
-                and productId = #{productId}
+                and a.productId = #{productId}
             </if>
             <if test="orderStatus != null">
-                and orderStatus = #{orderStatus}
+                and a.orderStatus = #{orderStatus}
             </if>
             <if test="status != null">
-                and status = #{status}
+                and a.status = #{status}
             </if>
             <if test="paymentType != null">
-                and paymentType = #{paymentType}
+                and a.paymentType = #{paymentType}
             </if>
             <if test="productLevelId != 0">
-                and productLevelId = #{productLevelId}
+                and a.productLevelId = #{productLevelId}
             </if>
             <if test="organizationId != 0">
-                and organizationId = #{organizationId}
+                and a.organizationId = #{organizationId}
             </if>
             <if test="payOrganizationId != 0">
-                and payOrganizationId = #{payOrganizationId}
+                and a.payOrganizationId = #{payOrganizationId}
             </if>
         </where>
     </select>
@@ -110,40 +134,40 @@
     </select>
 
     <select id="getLimit" resultMap="result">
-        select * from workark_orderInfo
+        <include refid="query" />
         <where>
             <if test="p.title != null">
-                and title = #{p.title}
+                and a.title = #{p.title}
             </if>
             <if test="p.orderNo != null">
-                and orderNo = #{p.orderNo}
+                and a.orderNo = #{p.orderNo}
             </if>
             <if test="p.userId != null">
-                and userId = #{p.userId}
+                and a.userId = #{p.userId}
             </if>
             <if test="p.productId != null">
-                and productId = #{p.productId}
+                and a.productId = #{p.productId}
             </if>
             <if test="p.orderStatus != null">
-                and orderStatus = #{p.orderStatus}
+                and a.orderStatus = #{p.orderStatus}
             </if>
             <if test="p.status != null">
-                and status = #{p.status}
+                and a.status = #{p.status}
             </if>
             <if test="p.paymentType != null">
-                and paymentType = #{p.paymentType}
+                and a.paymentType = #{p.paymentType}
             </if>
             <if test="p.productLevelId != 0">
-                and productLevelId = #{p.productLevelId}
+                and a.productLevelId = #{p.productLevelId}
             </if>
             <if test="p.organizationId != 0">
-                and organizationId = #{p.organizationId}
+                and a.organizationId = #{p.organizationId}
             </if>
             <if test="p.payOrganizationId != 0">
-                and payOrganizationId = #{p.payOrganizationId}
+                and a.payOrganizationId = #{p.payOrganizationId}
             </if>
         </where>
-        order by createTime desc limit #{currIndex} , #{pageSize}
+        order by a.createTime desc limit #{currIndex} , #{pageSize}
     </select>
 
     <insert id="save" useGeneratedKeys="true" keyProperty="id">