|
|
@@ -149,6 +149,26 @@
|
|
|
, '%')
|
|
|
)
|
|
|
</if>
|
|
|
+ and (
|
|
|
+ case when klt.status in (1, 6)
|
|
|
+ then
|
|
|
+ klt.create_by in
|
|
|
+ <foreach collection="authList" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item,jdbcType=BIGINT}
|
|
|
+ </foreach>
|
|
|
+ when klt.status in (2, 3, 4, 5) then
|
|
|
+ (
|
|
|
+ klt.create_by in
|
|
|
+ <foreach collection="authList" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item,jdbcType=BIGINT}
|
|
|
+ </foreach>
|
|
|
+ or kltu2.contacts_id in
|
|
|
+ <foreach collection="authList" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item,jdbcType=BIGINT}
|
|
|
+ </foreach>
|
|
|
+ )
|
|
|
+ end
|
|
|
+ )
|
|
|
</where>
|
|
|
order by klt.generate_time desc
|
|
|
</select>
|
|
|
@@ -299,6 +319,31 @@
|
|
|
, '%')
|
|
|
)
|
|
|
</if>
|
|
|
+ and (
|
|
|
+ case
|
|
|
+ when klt.status = 2 then
|
|
|
+ true
|
|
|
+ when klt.status in (3, 4, 5) then
|
|
|
+ (
|
|
|
+ (
|
|
|
+ kltu2.contacts_id in
|
|
|
+ <foreach collection="authList" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item,jdbcType=BIGINT}
|
|
|
+ </foreach>)
|
|
|
+ or
|
|
|
+ (
|
|
|
+ select kllt.id
|
|
|
+ from kwp_ledger_logistics_track kllt where kllt.del_flag = 0
|
|
|
+ and kllt.l_ledger_id = klt.id
|
|
|
+ and kllt.status in (3, 5)
|
|
|
+ and kllt.create_by in
|
|
|
+ <foreach collection="authList" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item,jdbcType=BIGINT}
|
|
|
+ </foreach>
|
|
|
+ )
|
|
|
+ )
|
|
|
+ end
|
|
|
+ )
|
|
|
</where>
|
|
|
order by klt.generate_time desc
|
|
|
</select>
|
|
|
@@ -438,6 +483,138 @@
|
|
|
</if>
|
|
|
</where>
|
|
|
</select>
|
|
|
+ <select id="countSellOrder" resultType="java.util.Map">
|
|
|
+ SELECT count(1) "0",
|
|
|
+ count(IF(klt.status = 1, 1, NULL)) "1",
|
|
|
+ count(IF(klt.status = 2, 1, NULL)) "2",
|
|
|
+ count(IF(klt.status = 3, 1, NULL)) "3",
|
|
|
+ count(IF(klt.status = 4, 1, NULL)) "4",
|
|
|
+ count(IF(klt.status = 5, 1, NULL)) "5",
|
|
|
+ count(IF(klt.status = 6, 1, NULL)) "6"
|
|
|
+ from kwp_ledger_trade klt
|
|
|
+ inner join kwp_ledger_trade_unit kltu
|
|
|
+ on klt.id = kltu.t_ledger_id and kltu.del_flag = 0 and
|
|
|
+ kltu.unit_type = #{tradeReq.unitType,jdbcType=INTEGER}
|
|
|
+ inner join kwp_ledger_trade_unit kltu2
|
|
|
+ on klt.id = kltu2.t_ledger_id and kltu2.del_flag = 0 and kltu2.unit_type =
|
|
|
+ #{tradeReq.unitTypeTwo,jdbcType=INTEGER}
|
|
|
+ <where>
|
|
|
+ klt.del_flag = 0
|
|
|
+ and kltu2.top_ent_id = #{tradeReq.entId,jdbcType=BIGINT}
|
|
|
+ <if test="tradeReq.unitType != null and tradeReq.unitType == 2">
|
|
|
+ and klt.status not in (1, 6)
|
|
|
+ </if>
|
|
|
+ <if test="tradeReq.trading != null">
|
|
|
+ and klt.trading = #{tradeReq.trading,jdbcType=INTEGER}
|
|
|
+ </if>
|
|
|
+ <if test="tradeReq.endCreateTime != null and tradeReq.endCreateTime != '' and tradeReq.startCreateTime != null and tradeReq.startCreateTime != ''">
|
|
|
+ and klt.generate_time between #{tradeReq.startCreateTime,jdbcType=TIMESTAMP}
|
|
|
+ and #{tradeReq.endCreateTime,jdbcType=TIMESTAMP}
|
|
|
+ </if>
|
|
|
+ <if test="tradeReq.keywords != null and tradeReq.keywords != ''">
|
|
|
+ and (
|
|
|
+ klt.t_ledger_no like concat('%'
|
|
|
+ , #{tradeReq.keywords,jdbcType=VARCHAR}
|
|
|
+ , '%')
|
|
|
+ or kltu.firm_name like concat('%'
|
|
|
+ , #{tradeReq.keywords,jdbcType=VARCHAR}
|
|
|
+ , '%')
|
|
|
+ or kltu.contacts like concat('%'
|
|
|
+ , #{tradeReq.keywords,jdbcType=VARCHAR}
|
|
|
+ , '%')
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ and (
|
|
|
+ case when klt.status in (1, 6)
|
|
|
+ then
|
|
|
+ klt.create_by in
|
|
|
+ <foreach collection="authList" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item,jdbcType=BIGINT}
|
|
|
+ </foreach>
|
|
|
+ when klt.status in (2, 3, 4, 5) then
|
|
|
+ (
|
|
|
+ klt.create_by in
|
|
|
+ <foreach collection="authList" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item,jdbcType=BIGINT}
|
|
|
+ </foreach>
|
|
|
+ or kltu2.contacts_id in
|
|
|
+ <foreach collection="authList" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item,jdbcType=BIGINT}
|
|
|
+ </foreach>
|
|
|
+ )
|
|
|
+ end
|
|
|
+ )
|
|
|
+ </where>
|
|
|
+ </select>
|
|
|
+ <select id="countPurchaseOrder" resultType="java.util.Map">
|
|
|
+ SELECT count(1) "0",
|
|
|
+ count(IF(klt.status = 1, 1, NULL)) "1",
|
|
|
+ count(IF(klt.status = 2, 1, NULL)) "2",
|
|
|
+ count(IF(klt.status = 3, 1, NULL)) "3",
|
|
|
+ count(IF(klt.status = 4, 1, NULL)) "4",
|
|
|
+ count(IF(klt.status = 5, 1, NULL)) "5",
|
|
|
+ count(IF(klt.status = 6, 1, NULL)) "6"
|
|
|
+ from kwp_ledger_trade klt
|
|
|
+ inner join kwp_ledger_trade_unit kltu
|
|
|
+ on klt.id = kltu.t_ledger_id and kltu.del_flag = 0 and
|
|
|
+ kltu.unit_type = #{tradeReq.unitType,jdbcType=INTEGER}
|
|
|
+ inner join kwp_ledger_trade_unit kltu2
|
|
|
+ on klt.id = kltu2.t_ledger_id and kltu2.del_flag = 0 and kltu2.unit_type =
|
|
|
+ #{tradeReq.unitTypeTwo,jdbcType=INTEGER}
|
|
|
+ <where>
|
|
|
+ klt.del_flag = 0
|
|
|
+ and kltu2.top_ent_id = #{tradeReq.entId,jdbcType=BIGINT}
|
|
|
+ <if test="tradeReq.unitType != null and tradeReq.unitType == 2">
|
|
|
+ and klt.status not in (1, 6)
|
|
|
+ </if>
|
|
|
+ <if test="tradeReq.trading != null">
|
|
|
+ and klt.trading = #{tradeReq.trading,jdbcType=INTEGER}
|
|
|
+ </if>
|
|
|
+ <if test="tradeReq.endCreateTime != null and tradeReq.endCreateTime != '' and tradeReq.startCreateTime != null and tradeReq.startCreateTime != ''">
|
|
|
+ and klt.generate_time between #{tradeReq.startCreateTime,jdbcType=TIMESTAMP}
|
|
|
+ and #{tradeReq.endCreateTime,jdbcType=TIMESTAMP}
|
|
|
+ </if>
|
|
|
+ <if test="tradeReq.keywords != null and tradeReq.keywords != ''">
|
|
|
+ and (
|
|
|
+ klt.t_ledger_no like concat('%'
|
|
|
+ , #{tradeReq.keywords,jdbcType=VARCHAR}
|
|
|
+ , '%')
|
|
|
+ or kltu.firm_name like concat('%'
|
|
|
+ , #{tradeReq.keywords,jdbcType=VARCHAR}
|
|
|
+ , '%')
|
|
|
+ or kltu.contacts like concat('%'
|
|
|
+ , #{tradeReq.keywords,jdbcType=VARCHAR}
|
|
|
+ , '%')
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ and (
|
|
|
+ case
|
|
|
+ when klt.status = 2 then
|
|
|
+ true
|
|
|
+ when klt.status in (3, 4, 5) then
|
|
|
+ (
|
|
|
+ (
|
|
|
+ kltu2.contacts_id in
|
|
|
+ <foreach collection="authList" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item,jdbcType=BIGINT}
|
|
|
+ </foreach>)
|
|
|
+ or
|
|
|
+ (
|
|
|
+ select kllt.id
|
|
|
+ from kwp_ledger_logistics_track kllt where kllt.del_flag = 0
|
|
|
+ and kllt.l_ledger_id = klt.id
|
|
|
+ and kllt.status in (3, 5)
|
|
|
+ and kllt.create_by in
|
|
|
+ <foreach collection="authList" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item,jdbcType=BIGINT}
|
|
|
+ </foreach>
|
|
|
+ )
|
|
|
+ )
|
|
|
+ end
|
|
|
+ )
|
|
|
+ </where>
|
|
|
+ </select>
|
|
|
+
|
|
|
<select id="countOrder2" resultType="java.util.Map">
|
|
|
SELECT count(1) "0",
|
|
|
count(IF(kll_distinct.status = 1, 1, NULL)) "1",
|
|
|
@@ -676,6 +853,55 @@
|
|
|
, '%')
|
|
|
)
|
|
|
</if>
|
|
|
+ <if test="tradeReq.unitType == 1">
|
|
|
+ and (
|
|
|
+ case when klt.status in (1, 6)
|
|
|
+ then
|
|
|
+ klt.create_by in
|
|
|
+ <foreach collection="authList" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item,jdbcType=BIGINT}
|
|
|
+ </foreach>
|
|
|
+ when klt.status in (2, 3, 4, 5) then
|
|
|
+ (
|
|
|
+ klt.create_by in
|
|
|
+ <foreach collection="authList" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item,jdbcType=BIGINT}
|
|
|
+ </foreach>
|
|
|
+ or kltu2.contacts_id in
|
|
|
+ <foreach collection="authList" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item,jdbcType=BIGINT}
|
|
|
+ </foreach>
|
|
|
+ )
|
|
|
+ end
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ <if test="tradeReq.unitType == 2">
|
|
|
+ and (
|
|
|
+ case
|
|
|
+ when klt.status = 2 then
|
|
|
+ true
|
|
|
+ when klt.status in (3, 4, 5) then
|
|
|
+ (
|
|
|
+ (
|
|
|
+ kltu2.contacts_id in
|
|
|
+ <foreach collection="authList" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item,jdbcType=BIGINT}
|
|
|
+ </foreach>)
|
|
|
+ or
|
|
|
+ (
|
|
|
+ select kllt.id
|
|
|
+ from kwp_ledger_logistics_track kllt where kllt.del_flag = 0
|
|
|
+ and kllt.l_ledger_id = klt.id
|
|
|
+ and kllt.status in (3, 5)
|
|
|
+ and kllt.create_by in
|
|
|
+ <foreach collection="authList" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item,jdbcType=BIGINT}
|
|
|
+ </foreach>
|
|
|
+ )
|
|
|
+ )
|
|
|
+ end
|
|
|
+ )
|
|
|
+ </if>
|
|
|
</otherwise>
|
|
|
</choose>
|
|
|
</where>
|