挂账需求
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
<?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.czg.service.order.mapper.CreditBuyerMapper">
|
||||
|
||||
<sql id="view_credit_buyer_order_count">
|
||||
(SELECT
|
||||
credit_buyer_id AS credit_buyer_id,
|
||||
status AS status,
|
||||
count( 0 ) AS count
|
||||
FROM
|
||||
<include refid="view_credit_buyer_order"/>
|
||||
GROUP BY credit_buyer_id,status)
|
||||
</sql>
|
||||
|
||||
<sql id="view_credit_buyer_order">
|
||||
(SELECT t1.id AS id,
|
||||
t1.credit_buyer_id AS credit_buyer_id,
|
||||
t1.order_id AS order_id,
|
||||
t2.pay_amount - t2.refund_amount AS pay_amount,
|
||||
t1.paid_amount AS paid_amount,
|
||||
(t2.pay_amount - t2.refund_amount) - t1.paid_amount AS unpaid_amount,
|
||||
t1.status AS status,
|
||||
t2.create_time AS create_time,
|
||||
t1.last_payment_time AS last_payment_time,
|
||||
t1.last_payment_method AS last_payment_method,
|
||||
t1.remark AS remark
|
||||
FROM tb_credit_buyer_order t1
|
||||
LEFT JOIN tb_order_info t2 ON t1.order_id = t2.id)
|
||||
</sql>
|
||||
|
||||
<select id="findCreditBuyerList" resultType="com.czg.order.dto.CreditBuyerDTO">
|
||||
select x1.*,
|
||||
x2.shop_name,
|
||||
x3.owed_amount,
|
||||
x3.accumulate_amount
|
||||
from tb_credit_buyer x1
|
||||
left join tb_shop_info t2 on x1.shop_id = x2.id
|
||||
left join (select credit_buyer_id,ifnull(sum(unpaid_amount),0) as owed_amount,ifnull(sum(pay_amount),0) as
|
||||
accumulate_amount from
|
||||
<include refid="view_credit_buyer_order"/>
|
||||
group by credit_buyer_id) x3 on x1.id = x3.credit_buyer_id
|
||||
<where>
|
||||
and x1.is_del = 0
|
||||
and x1.shop_id = #{shopId}
|
||||
<if test="id !=null and id != ''">
|
||||
and x1.id = #{id}
|
||||
</if>
|
||||
<if test="responsiblePerson !=null and responsiblePerson != ''">
|
||||
and x1.responsible_person like concat('%',#{responsiblePerson},'%')
|
||||
</if>
|
||||
<if test="status !=null">
|
||||
and x1.status = #{status}
|
||||
</if>
|
||||
<if test="keywords !=null and keywords != ''">
|
||||
and (x1.debtor like concat('%',#{keywords},'%') or x1.mobile like concat('%',#{keywords},'%'))
|
||||
</if>
|
||||
<if test="repaymentStatus !=null and repaymentStatus != ''">
|
||||
<if test="repaymentStatus == 'unpaid'">
|
||||
and 0 < ifnull((select x.count from
|
||||
<include refid="view_credit_buyer_order_count"/>
|
||||
x where x.credit_buyer_id = tb_credit_buyer.id and x.status = 'unpaid'),0)
|
||||
and 0 = ifnull((select x.count from
|
||||
<include refid="view_credit_buyer_order_count"/>
|
||||
x where x.credit_buyer_id = tb_credit_buyer.id and x.status = 'partial'),0)
|
||||
</if>
|
||||
<if test="repaymentStatus == 'partial'">
|
||||
and 0 < ifnull((select x.count from
|
||||
<include refid="view_credit_buyer_order_count"/>
|
||||
x where x.credit_buyer_id = tb_credit_buyer.id and x.status = 'partial'),0)
|
||||
</if>
|
||||
<if test="repaymentStatus == 'paid'">
|
||||
and 0 = ifnull((select sum(x.count) from
|
||||
<include refid="view_credit_buyer_order_count"/>
|
||||
x where x.credit_buyer_id = tb_credit_buyer.id and x.status in ('unpaid','partial')),0)
|
||||
</if>
|
||||
</if>
|
||||
</where>
|
||||
order by x1.status desc,x1.id desc
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,94 @@
|
||||
<?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.czg.service.order.mapper.CreditBuyerOrderMapper">
|
||||
|
||||
<sql id="view_credit_buyer_order">
|
||||
(SELECT t1.id AS id,
|
||||
t1.credit_buyer_id AS credit_buyer_id,
|
||||
t1.order_id AS order_id,
|
||||
t2.pay_amount - t2.refund_amount AS pay_amount,
|
||||
t1.paid_amount AS paid_amount,
|
||||
(t2.pay_amount - t2.refund_amount) - t1.paid_amount AS unpaid_amount,
|
||||
t1.status AS status,
|
||||
t2.create_time AS create_time,
|
||||
t1.last_payment_time AS last_payment_time,
|
||||
t1.last_payment_method AS last_payment_method,
|
||||
t1.remark AS remark
|
||||
FROM tb_credit_buyer_order t1
|
||||
LEFT JOIN tb_order_info t2 ON t1.order_id = t2.id)
|
||||
</sql>
|
||||
|
||||
<sql id="commonWhere">
|
||||
<where>
|
||||
and x1.credit_buyer_id = #{creditBuyerId}
|
||||
<if test="orderId != null and orderId != ''">
|
||||
and x1.order_id = #{orderId}
|
||||
</if>
|
||||
<if test="beginDate != null and beginDate != ''">
|
||||
and x1.create_time >= str_to_date(concat(#{beginDate},' 00:00:00'), '%Y-%m-%d %H:%i:%s')
|
||||
</if>
|
||||
<if test="endDate != null and endDate != ''">
|
||||
<![CDATA[
|
||||
and x1.create_time <= str_to_date(concat(#{endDate},' 23:59:59'), '%Y-%m-%d %H:%i:%s')
|
||||
]]>
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
and x1.status = #{status}
|
||||
</if>
|
||||
<if test="statusList != null">
|
||||
and x1.status in
|
||||
<foreach item="status" collection="statusList" open="(" separator="," close=")">
|
||||
#{status}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="id != null">
|
||||
and x1.id = #{id}
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<select id="findCreditBuyerOrderList" resultType="com.czg.order.dto.CreditBuyerOrderDTO">
|
||||
select * from
|
||||
<include refid="view_credit_buyer_order"/>
|
||||
x1
|
||||
<include refid="commonWhere"/>
|
||||
order by x1.order_id desc
|
||||
</select>
|
||||
<select id="getCreditBuyerOrderCount" resultType="java.lang.Long">
|
||||
select count(*) from
|
||||
<include refid="view_credit_buyer_order"/>
|
||||
x1
|
||||
<include refid="commonWhere"/>
|
||||
order by x1.order_id desc
|
||||
</select>
|
||||
<select id="getSumPayAmount" resultType="java.math.BigDecimal">
|
||||
select ifnull(sum(t1.pay_amount),0) from
|
||||
<include refid="view_credit_buyer_order"/>
|
||||
x1
|
||||
<include refid="commonWhere"/>
|
||||
order by x1.order_id desc
|
||||
</select>
|
||||
<select id="getSumPaidAmount" resultType="java.math.BigDecimal">
|
||||
select ifnull(sum(t1.paid_amount),0) from
|
||||
<include refid="view_credit_buyer_order"/>
|
||||
x1
|
||||
<include refid="commonWhere"/>
|
||||
order by x1.order_id desc
|
||||
</select>
|
||||
<select id="getSumUnpaidAmount" resultType="java.math.BigDecimal">
|
||||
select ifnull(sum(t1.unpaid_amount),0) from
|
||||
<include refid="view_credit_buyer_order"/>
|
||||
x1
|
||||
<include refid="commonWhere"/>
|
||||
order by x1.order_id desc
|
||||
</select>
|
||||
<select id="getOne" resultType="com.czg.order.dto.CreditBuyerOrderDTO">
|
||||
select * from
|
||||
<include refid="view_credit_buyer_order"/>
|
||||
x1
|
||||
<include refid="commonWhere"/>
|
||||
order by x1.order_id desc
|
||||
limit 1
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?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.czg.service.order.mapper.CreditPaymentRecordMapper">
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user