| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430 |
- <?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.dk.mdm.mapper.sale.OrderMapper">
- <!-- 通用设置 -->
- <!-- 通用查询列 -->
- <sql id="Base_Column_List">
- order_id, order_no, order_type, org_id, staff_id, cus_id, address_area, address_name, address_no, address_gcj02, address_full, contact_name, contact_phone, sales_channel, delivery_date, sum_quantity, sum_standard, sum_amount, sale_discount, order_status, out_status, outing_qty, outing_amt, out_qty, out_amt, return_qty, return_amt, amt_receivable, amt_handle, amt_residue, remarks, annex_paths, make_staff, make_time, flg_valid, cp_id, op_create_time, op_create_user_id, op_update_time, op_update_user_id, op_app_code, op_timestamp, op_db_user
- </sql>
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMap" type="com.dk.mdm.model.response.sale.OrderResponse">
- <id column="order_id" property="orderId"/>
- <result column="order_no" property="orderNo"/>
- <result column="order_type" property="orderType"/>
- <result column="org_id" property="orgId" typeHandler="UuidTypeHandler"/>
- <result column="staff_id" property="staffId" typeHandler="UuidTypeHandler"/>
- <result column="cus_id" property="cusId" typeHandler="UuidTypeHandler"/>
- <result column="address_area" property="addressArea" typeHandler="JsonTypeHandler"/>
- <result column="address_name" property="addressName"/>
- <result column="address_no" property="addressNo"/>
- <result column="address_gcj02" property="addressGcj02" typeHandler="JsonTypeHandler"/>
- <result column="address_full" property="addressFull"/>
- <result column="contact_name" property="contactName"/>
- <result column="contact_phone" property="contactPhone"/>
- <result column="sales_channel" property="salesChannel" typeHandler="UuidTypeHandler"/>
- <result column="delivery_date" property="deliveryDate" typeHandler="TimestampTypeHandler"/>
- <result column="sum_quantity" property="sumQuantity"/>
- <result column="sum_standard" property="sumStandard"/>
- <result column="sum_amount" property="sumAmount"/>
- <result column="sale_discount" property="saleDiscount"/>
- <result column="order_status" property="orderStatus"/>
- <result column="out_status" property="outStatus"/>
- <result column="outing_qty" property="outingQty"/>
- <result column="outing_amt" property="outingAmt"/>
- <result column="out_qty" property="outQty"/>
- <result column="out_amt" property="outAmt"/>
- <result column="return_qty" property="returnQty"/>
- <result column="return_amt" property="returnAmt"/>
- <result column="amt_receivable" property="amtReceivable"/>
- <result column="amt_handle" property="amtHandle"/>
- <result column="amt_residue" property="amtResidue"/>
- <result column="remarks" property="remarks"/>
- <result column="annex_paths" property="annexPaths" typeHandler="JsonTypeHandler"/>
- <result column="make_staff" property="makeStaff" typeHandler="UuidTypeHandler"/>
- <result column="make_time" property="makeTime" typeHandler="TimestampTypeHandler"/>
- <result column="flg_valid" property="flgValid"/>
- <result column="cp_id" property="cpId"/>
- <result column="op_create_time" property="opCreateTime" typeHandler="TimestampTypeHandler"/>
- <result column="op_create_user_id" property="opCreateUserId" typeHandler="UuidTypeHandler"/>
- <result column="op_update_time" property="opUpdateTime" typeHandler="TimestampTypeHandler"/>
- <result column="op_update_user_id" property="opUpdateUserId" typeHandler="UuidTypeHandler"/>
- <result column="op_app_code" property="opAppCode"/>
- <result column="op_timestamp" property="opTimestamp" typeHandler="TimestampTypeHandler"/>
- <result column="op_db_user" property="opDbUser"/>
- </resultMap>
- <!-- 通用条件列 -->
- <sql id="Condition">
- <where>
- <if test="orderNo != null and orderNo != ''">
- AND tpo.order_no = #{orderNo}
- </if>
- <if test="orderType != null and orderType != ''">
- AND tpo.order_type = #{orderType}
- </if>
- <if test="orgId != null and orgId != ''">
- AND tpo.org_id = #{orgId}
- </if>
- <if test="staffId != null and staffId != ''">
- AND tpo.staff_id = #{staffId}
- </if>
- <if test="cusId != null and cusId != ''">
- AND tpo.cus_id = #{cusId}
- </if>
- <if test="addressArea != null and addressArea != ''">
- AND tpo.address_area = #{addressArea}
- </if>
- <if test="addressName != null and addressName != ''">
- AND tpo.address_name = #{addressName}
- </if>
- <if test="addressNo != null and addressNo != ''">
- AND tpo.address_no = #{addressNo}
- </if>
- <if test="addressGcj02 != null and addressGcj02 != ''">
- AND tpo.address_gcj02 = #{addressGcj02}
- </if>
- <if test="addressFull != null and addressFull != ''">
- AND tpo.address_full = #{addressFull}
- </if>
- <if test="contactName != null and contactName != ''">
- AND tpo.contact_name = #{contactName}
- </if>
- <if test="contactPhone != null and contactPhone != ''">
- AND tpo.contact_phone = #{contactPhone}
- </if>
- <if test="salesChannel != null and salesChannel != ''">
- AND tpo.sales_channel = #{salesChannel}
- </if>
- <if test="deliveryDate != null">
- AND tpo.delivery_date = #{deliveryDate}
- </if>
- <if test="sumQuantity != null">
- AND tpo.sum_quantity = #{sumQuantity}
- </if>
- <if test="sumStandard != null">
- AND tpo.sum_standard = #{sumStandard}
- </if>
- <if test="sumAmount != null">
- AND tpo.sum_amount = #{sumAmount}
- </if>
- <if test="saleDiscount != null">
- AND tpo.sale_discount = #{saleDiscount}
- </if>
- <if test="orderStatus != null and orderStatus != ''">
- AND tpo.order_status = #{orderStatus}
- </if>
- <if test="outStatus != null and outStatus != ''">
- AND tpo.out_status = #{outStatus}
- </if>
- <if test="outingQty != null">
- AND tpo.outing_qty = #{outingQty}
- </if>
- <if test="outingAmt != null">
- AND tpo.outing_amt = #{outingAmt}
- </if>
- <if test="outQty != null">
- AND tpo.out_qty = #{outQty}
- </if>
- <if test="outAmt != null">
- AND tpo.out_amt = #{outAmt}
- </if>
- <if test="returnQty != null">
- AND tpo.return_qty = #{returnQty}
- </if>
- <if test="returnAmt != null">
- AND tpo.return_amt = #{returnAmt}
- </if>
- <if test="amtReceivable != null">
- AND tpo.amt_receivable = #{amtReceivable}
- </if>
- <if test="amtHandle != null">
- AND tpo.amt_handle = #{amtHandle}
- </if>
- <if test="amtResidue != null">
- AND tpo.amt_residue = #{amtResidue}
- </if>
- <if test="remarks != null and remarks != ''">
- AND tpo.remarks = #{remarks}
- </if>
- <if test="annexPaths != null and annexPaths != ''">
- AND tpo.annex_paths = #{annexPaths}
- </if>
- <if test="makeStaff != null and makeStaff != ''">
- AND tpo.make_staff = #{makeStaff}
- </if>
- <if test="makeTime != null">
- AND tpo.make_time = #{makeTime}
- </if>
- <if test="flgValid != null">
- AND tpo.flg_valid = #{flgValid}
- </if>
- <if test="cpId != null">
- AND tpo.cp_id = #{cpId}
- </if>
- <if test="orgIdList != null and orgIdList.size() > 0">
- AND tpo.org_id =any(#{orgIdList, typeHandler=uuidListTypeHandler})
- </if>
- <if test="staffIdList != null and staffIdList.size() > 0">
- AND tpo.staff_id =any(#{staffIdList, typeHandler=uuidListTypeHandler})
- </if>
- <if test="outStatusList != null and outStatusList.size() > 0">
- AND tpo.out_status =any(#{outStatusList, typeHandler=StringListTypeHandler})
- </if>
- <if test="makeTimeStart != null and makeTimeEnd != null">
- AND tpo.make_time >= #{makeTimeStart}::timestamp with time zone
- AND tpo.make_time < #{makeTimeEnd}::timestamp with time zone + interval '1 day'
- </if>
- <if test="deliveryDateStart != null and deliveryDateEnd != null">
- AND tpo.delivery_date >= #{deliveryDateStart}::timestamp with time zone
- AND tpo.delivery_date < #{deliveryDateEnd}::timestamp with time zone + interval '1 day'
- </if>
- </where>
- </sql>
- <sql id="idsForeach">
- <!-- 根据主键orderId批量操作 -->
- WHERE order_id in
- <foreach collection="ids" index="index" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- </sql>
- <!-- 查询表t_psi_order,(条件查询+分页)列表 -->
- <select id="selectByCond" resultMap="BaseResultMap">
- SELECT tpo.order_id,
- tpo.order_no,
- tpo.order_type,
- sys.f_get_name_i18n(tdk1.kind_name_i18n, 'zh_CN') as "orderTypeName",
- tpo.org_id,
- tmo.org_name as "orgName",
- tpo.staff_id,
- tms.staff_name as "staffName",
- tpo.cus_id,
- tmc.cus_code as "cusCode",
- tmc.cus_name as "cusName",
- tmc.cus_phone as "cusPhone",
- tmc.cus_from as "cusFrom",
- tmdd.data_value as "cusFromName",
- tpo.address_area,
- tpo.address_name,
- tpo.address_no,
- tpo.address_gcj02,
- tpo.address_full,
- tpo.contact_name,
- tpo.contact_phone,
- tpo.sales_channel,
- tmsc.channel_name as "channelName",
- tpo.delivery_date,
- tpo.sum_quantity,
- tpo.sum_standard,
- tpo.sum_amount,
- tpo.sale_discount,
- tpo.order_status,
- sys.f_get_name_i18n(tdk2.kind_name_i18n, 'zh_CN') as "orderStatusName",
- tpo.out_status,
- sys.f_get_name_i18n(tdk3.kind_name_i18n, 'zh_CN') as "outStatusName",
- tpo.outing_qty,
- tpo.outing_amt,
- tpo.out_qty,
- tpo.out_amt,
- tpo.return_qty,
- tpo.return_amt,
- tpo.amt_receivable,
- tpo.amt_handle,
- tpo.amt_residue,
- tpo.remarks,
- tpo.annex_paths,
- makestaff.staff_name as "makeStaffName",
- tpo.make_time,
- tpo.cp_id
- FROM dkic_b.t_psi_order as tpo
- left join dkic_b.t_mst_sale_channel tmsc on tpo.sales_channel = tmsc.channel_id
- left join dkic_b.t_mst_org tmo on tpo.org_id = tmo.org_id
- left join dkic_b.t_mst_staff tms on tpo.staff_id = tms.staff_id
- left join dkic_b.t_mst_staff as makestaff on tpo.make_staff = makestaff.staff_id
- left join dkic_b.t_mst_customer tmc on tpo.cus_id = tmc.cus_id
- left join dkic_b.t_mst_dictionary_data tmdd on tmc.cus_from = tmdd.data_id
- left join sys.t_data_kind as tdk1 on tpo.order_type = tdk1.kind_code
- left join sys.t_data_kind as tdk2 on tpo.order_status = tdk2.kind_code
- left join sys.t_data_kind as tdk3 on tpo.out_status = tdk3.kind_code
- <include refid="Condition"/>
- order by tpo.op_create_time desc
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!-- 查询表t_psi_order,(条件查询)个数 -->
- <select id="countByCond" resultType="Long">
- SELECT
- count(1)
- FROM dkic_b.t_psi_order as tpo
- <include refid="Condition"/>
- </select>
- <!-- 根据主键查询表t_psi_order的一行数据 -->
- <select id="selectById" resultMap="BaseResultMap">
- SELECT tpo.order_id,
- tpo.order_no,
- tpo.order_type,
- sys.f_get_name_i18n(tdk1.kind_name_i18n, 'zh_CN') as "orderTypeName",
- tpo.org_id,
- tmo.org_name as "orgName",
- tpo.staff_id,
- tms.staff_name as "staffName",
- tpo.cus_id,
- tmc.cus_code as "cusCode",
- tmc.cus_name as "cusName",
- tmc.cus_phone as "cusPhone",
- tmc.cus_from as "cusFrom",
- tmdd.data_value as "cusFromName",
- tpo.address_area,
- tpo.address_name,
- tpo.address_no,
- tpo.address_gcj02,
- tpo.address_full,
- tpo.contact_name,
- tpo.contact_phone,
- tpo.sales_channel,
- tmsc.channel_name as "channelName",
- tpo.delivery_date,
- tpo.sum_quantity,
- tpo.sum_standard,
- tpo.sum_amount,
- tpo.sale_discount,
- tpo.order_status,
- sys.f_get_name_i18n(tdk2.kind_name_i18n, 'zh_CN') as "orderStatusName",
- tpo.out_status,
- sys.f_get_name_i18n(tdk3.kind_name_i18n, 'zh_CN') as "outStatusName",
- tpo.outing_qty,
- tpo.outing_amt,
- tpo.out_qty,
- tpo.out_amt,
- tpo.return_qty,
- tpo.return_amt,
- tpo.amt_receivable,
- tpo.amt_handle,
- tpo.amt_residue,
- tpo.remarks,
- tpo.annex_paths,
- makestaff.staff_name as "makeStaffName",
- tpo.make_time,
- tpo.cp_id
- FROM dkic_b.t_psi_order as tpo
- left join dkic_b.t_mst_sale_channel tmsc on tpo.sales_channel = tmsc.channel_id
- left join dkic_b.t_mst_org tmo on tpo.org_id = tmo.org_id
- left join dkic_b.t_mst_staff tms on tpo.staff_id = tms.staff_id
- left join dkic_b.t_mst_staff as makestaff on tpo.make_staff = makestaff.staff_id
- left join dkic_b.t_mst_customer tmc on tpo.cus_id = tmc.cus_id
- left join dkic_b.t_mst_dictionary_data tmdd on tmc.cus_from = tmdd.data_id
- left join sys.t_data_kind as tdk1 on tpo.order_type = tdk1.kind_code
- left join sys.t_data_kind as tdk2 on tpo.order_status = tdk2.kind_code
- left join sys.t_data_kind as tdk3 on tpo.out_status = tdk3.kind_code
- WHERE tpo.order_id = #{orderId}::uuid
- </select>
- <!-- 根据主键锁定表t_psi_order的一行数据 -->
- <select id="selectByIdForUpdate" resultMap="BaseResultMap">
- SELECT
- <include refid="Base_Column_List"/>
- FROM t_psi_order
- WHERE order_id = #{orderId}
- for update
- </select>
- <!-- 根据主键锁定表t_psi_order的多行数据 -->
- <select id="selectByIdsForUpdate" resultMap="BaseResultMap">
- SELECT
- <include refid="Base_Column_List"/>
- FROM t_psi_order
- <include refid="idsForeach"/>
- for update
- </select>
- <insert id="insertBatch">
- insert into t_psi_order
- (
- <trim suffixOverrides=",">
- order_no,
- order_type,
- org_id,
- staff_id,
- cus_id,
- address_area,
- address_name,
- address_no,
- address_gcj02,
- address_full,
- contact_name,
- contact_phone,
- sales_channel,
- delivery_date,
- sum_quantity,
- sum_standard,
- sum_amount,
- sale_discount,
- order_status,
- out_status,
- outing_qty,
- outing_amt,
- out_qty,
- out_amt,
- return_qty,
- return_amt,
- amt_receivable,
- amt_handle,
- amt_residue,
- remarks,
- annex_paths,
- make_staff,
- make_time,
- cp_id,
- op_app_code,
- </trim>
- )
- values
- <foreach collection="list" index="index" item="item" separator=",">
- (
- <trim suffixOverrides=",">
- #{item.orderNo},
- #{item.orderType},
- #{item.orgId}::uuid,
- #{item.staffId}::uuid,
- #{item.cusId}::uuid,
- #{item.addressArea},
- #{item.addressName},
- #{item.addressNo},
- #{item.addressGcj02},
- #{item.addressFull},
- #{item.contactName},
- #{item.contactPhone},
- #{item.salesChannel}::uuid,
- #{item.deliveryDate},
- #{item.sumQuantity},
- #{item.sumStandard},
- #{item.sumAmount},
- #{item.saleDiscount},
- #{item.orderStatus},
- #{item.outStatus},
- #{item.outingQty},
- #{item.outingAmt},
- #{item.outQty},
- #{item.outAmt},
- #{item.returnQty},
- #{item.returnAmt},
- #{item.amtReceivable},
- #{item.amtHandle},
- #{item.amtResidue},
- #{item.remarks},
- #{item.annexPaths},
- #{item.makeStaff}::uuid,
- #{item.makeTime},
- #{item.cpId},
- #{item.opAppCode},
- </trim>
- )
- </foreach>
- </insert>
- </mapper>
|