<?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.hzya.frame.seeyon.makeinvoice.dao.impl.MakeInvoiceDaoImpl">
	<resultMap id="get-MakeInvoiceEntity-result" type="com.hzya.frame.seeyon.makeinvoice.entity.MakeInvoiceEntity">
		<result property="sourceFlowNumber" column="sourceFlowNumber" />
		

	</resultMap>

	<sql id="MakeInvoiceEntity_Base_Column_List">
		 id

	</sql>



	<select id="getMakeInvoiceByState" resultMap="get-MakeInvoiceEntity-result" parameterType="com.hzya.frame.seeyon.makeinvoice.entity.MakeInvoiceEntity">
		select
			main.id as id,
			field0163 as sellerTaxNo,-- 销方税号
			'等待客户提供' as templateId, -- 模版ID
			field0117 as businessNo,-- 申请单单号
			field0106 as buyerName,-- 客户名称
			field0105 as buyerTaxNo,-- 客户税号
			field0100 + ' ' + field0101 as buyerAddrPhone,-- 地址和电话中间用空格隔开
			field0103 + ' ' + field0102 as buyerBankAccount,-- 开户行名称和开户行银行账户中间用空格隔开
			field0115 as applyPerson,-- 制单人
			0  as applyEmailNotice,-- 是否邮件通知申请人
			0 as buyerEmailNotice,-- 是否邮件通知购买方
			field0111 as otherEmail,-- 收件人邮箱
			field0126 as buyerRecvAddress,-- 邮寄地址
			'00' as specialInvoiceMark ,-- 临时默认00 后续确认 field0167建筑服务传03， 不动产租赁传06, 其他传00
			field0108 as sellerName, -- 销售方名称
			field0109 as invoiceType,-- 专票：21  普票：22
			'否' as isPerson, -- 是否自然人
			0 as levyTaxType,-- 征税方式
			field0090 as remark,-- 备注
			field0080 as itemName,-- 上网电费
			'1100101010600000000' as taxCateCode,-- 税收分类编码
			field0083 as spec,-- 规格型号
			field0084 as quantity,-- 电量
			field0168 as unitPrice,-- 单价(不含税)
			field0086 as price,-- 金额(不含税)
			field0118 as taxRate,-- 默认0.13
			field0169 as tax,-- 税额
			field0169 as includeTaxTag,-- 税额
			1 as detailType,-- 含税标识
			0 as detailType,-- 明细行性质
			0 as enjoyPreferentialFlag,-- 是否享受优惠
			field0167
		from formmain_0331 main
				 left join formson_0332 body on main.id = body.formmain_id
				 left join COL_SUMMARY summary on main.id = summary.form_recordid
		where summary.state = '3'
		  and field0154 ='-8073674727882144390' -- 蓝字发票条件 是否红冲为是
		  and  field0206 is null
	</select>
	<select id="getMakeInvoiceByFormson_0700" resultMap="get-MakeInvoiceEntity-result" parameterType="com.hzya.frame.seeyon.makeinvoice.entity.MakeInvoiceEntity">
		
	</select>
	<select id="getMakeInvoiceByFormson_0701" resultMap="get-MakeInvoiceEntity-result" parameterType="com.hzya.frame.seeyon.makeinvoice.entity.MakeInvoiceEntity">

	</select>
	<!--通过主键修改方法-->
	<update id="updatePushStatus" parameterType = "com.hzya.frame.seeyon.makeinvoice.entity.MakeInvoiceEntity" >
		update ${tabName} set ${pushStatusField} =#{pushStatus} where id=#{dataId}
	</update>

</mapper>

