You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
233 lines
11 KiB
233 lines
11 KiB
<?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.example.demo.mapper.cash.CashCollectionMapper">
|
|
|
|
|
|
<insert id="add" parameterType="com.example.demo.domain.entity.CashRecord"
|
|
useGeneratedKeys="true" keyProperty="id">
|
|
insert into
|
|
cash_record(order_type,jwcode,name,market,activity,
|
|
order_code,goods_name,good_num,permanent_gold,free_gold,
|
|
payment_currency,payment_amount,received_market,
|
|
pay_type,pay_time,status,submitter_id,submitter_market,
|
|
voucher,remark)
|
|
values(#{orderType},#{jwcode},#{name},#{market},#{activity},
|
|
#{orderCode},#{goodsName},#{goodNum},#{permanentGold},#{freeGold},#{paymentCurrency},
|
|
#{paymentAmount},#{receivedMarket},#{payType},#{payTime},
|
|
#{status},#{submitterId},#{submitterMarket},#{voucher},#{remark})
|
|
</insert>
|
|
<!-- <insert id="syncToCashRecord">
|
|
insert into cash_record(order_type,jwcode,name,market,activity,
|
|
order_code,goods_name,good_num,permanent_gold,free_gold,
|
|
payment_currency,payment_amount,received_market,
|
|
pay_type,pay_time,status,submitter_id,
|
|
voucher,remark)
|
|
values(1,#{jwcode},#{name},#{market},#{activity},
|
|
#{order_code},#{goods_name},#{good_num},#{permanent}
|
|
)
|
|
</insert>-->
|
|
|
|
<!--更新订单状态-->
|
|
<update id="updateStatus">
|
|
update cash_record
|
|
set status=#{status}
|
|
where order_code=#{orderCode}
|
|
</update>
|
|
<!--更新订单-->
|
|
<update id="updateByOrderCode">
|
|
UPDATE cash_record
|
|
<set>
|
|
jwcode = #{cashRecord.jwcode},
|
|
name = #{cashRecord.name},
|
|
market = #{cashRecord.market},
|
|
activity = #{cashRecord.activity},
|
|
goods_name = #{cashRecord.goodsName},
|
|
good_num = #{cashRecord.goodNum},
|
|
payment_currency = #{cashRecord.paymentCurrency},
|
|
payment_amount = #{cashRecord.paymentAmount},
|
|
received_market = #{cashRecord.receivedMarket},
|
|
pay_type = #{cashRecord.payType},
|
|
pay_time = #{cashRecord.payTime},
|
|
voucher = #{cashRecord.voucher},
|
|
remark = #{cashRecord.remark},
|
|
status = 0,
|
|
</set>
|
|
WHERE order_code = #{cashRecord.orderCode}
|
|
AND status = 5
|
|
</update>
|
|
<!--补全手续费等字段-->
|
|
<update id="complete">
|
|
UPDATE cash_record
|
|
<set>
|
|
<if test="cashRecord.handlingCharge != null and cashRecord.handlingCharge!=''">
|
|
handling_charge = #{cashRecord.handlingCharge},
|
|
</if>
|
|
<if test="cashRecord.receivedCurrency != null and cashRecord.receivedCurrency != ''">
|
|
received_currency = #{cashRecord.receivedCurrency},
|
|
</if>
|
|
<if test="cashRecord.receivedAmount != null">
|
|
received_amount = #{cashRecord.receivedAmount},
|
|
</if>
|
|
<if test="cashRecord.receivedTime != null">
|
|
received_time = #{cashRecord.receivedTime},
|
|
</if>
|
|
<if test="cashRecord.paymentCurrency != null and cashRecord.paymentCurrency != ''">
|
|
payment_currency = #{cashRecord.paymentCurrency},
|
|
</if>
|
|
<!-- 关键:null 就不拼这一列 -->
|
|
<if test="cashRecord.paymentAmount != null">
|
|
payment_amount = #{cashRecord.paymentAmount},
|
|
</if>
|
|
<!-- 只有 这些字段全部非空才更新状态 -->
|
|
status = CASE
|
|
WHEN
|
|
handling_charge IS NOT NULL
|
|
AND received_currency IS NOT NULL AND received_currency != ''
|
|
AND received_amount IS NOT NULL
|
|
AND received_time IS NOT NULL
|
|
AND payment_currency IS NOT NULL AND payment_currency != ''
|
|
AND payment_amount IS NOT NULL
|
|
THEN 4
|
|
ELSE status
|
|
END
|
|
</set>
|
|
WHERE order_code = #{cashRecord.orderCode}
|
|
AND status IN (1, 3)
|
|
</update>
|
|
<!--设置gOrder订单为已同步-->
|
|
<update id="markSynced">
|
|
update g_order
|
|
set is_synced = 1
|
|
where id = #{orderId}
|
|
</update>
|
|
<!--根据jwcode获取所属地区-->
|
|
<select id="getMarketByJwcode" resultType="java.lang.String">
|
|
select market from user where jwcode=#{jwcode}
|
|
</select>
|
|
<!--根据订单号获取订单id与状态-->
|
|
<select id="selectByOrderCode" resultType="com.example.demo.domain.entity.CashRecord">
|
|
select id ,status
|
|
from cash_record
|
|
where order_code=#{orderCode}
|
|
</select>
|
|
<!--多条件查询收款订单列表-->
|
|
<select id="selectCollection1" resultType="com.example.demo.domain.vo.cash.CashCollection">
|
|
select cr.id,cr.jwcode,cr.name,cr.market,
|
|
m1.name as marketName,
|
|
cr.activity,cr.order_code,cr.bank_code,
|
|
cr.goods_name,cr.good_num,cr.permanent_gold/100,cr.free_gold/100,cr.payment_amount/100 as paymentAmount,
|
|
r1.rate_name as paymentCurrency,
|
|
r2.rate_name as receivedCurrency,
|
|
m2.name as receivedMarket,
|
|
cr.received_amount/100 as receivedAmount,cr.handling_charge/100 as handlingCharge,
|
|
cr.pay_type,cr.pay_time,cr.received_time,
|
|
cr.status,cr.submitter_id,cr.submitter_market,cr.voucher,cr.remark,cr.reject_reason,
|
|
cr.audit_id,cr.create_time,cr.update_time,cr.audit_time,
|
|
a1.admin_name as submitterName,
|
|
a2.admin_name as auditName
|
|
from cash_record cr
|
|
left join admin a1 on cr.submitter_id = a1.id
|
|
left join admin a2 on cr.audit_id = a2.id
|
|
left join market m1 on m1.id = cr.market
|
|
left join market m2 on m2.id = cr.received_market
|
|
left join rate r1 on r1.id = cr.payment_currency
|
|
left join rate r2 on r2.id = cr.received_currency
|
|
<where>
|
|
1 = 1
|
|
<if test="cashCollection.market != null and cashCollection.market != ''">
|
|
AND cr.market = #{cashCollection.market}
|
|
</if>
|
|
<if test="cashCollection.jwcode != null and cashCollection.jwcode!=''">
|
|
AND cr.jwcode = #{cashCollection.jwcode}
|
|
</if>
|
|
<if test="cashCollection.name!=null and cashCollection.name !=''">
|
|
AND cr.name like concat('%',#{cashCollection.name},'%')
|
|
</if>
|
|
<if test="cashCollection.submitterId!=null and cashCollection.submitterId !=''">
|
|
AND cr.submitter_id = #{cashCollection.submitterId}
|
|
</if>
|
|
<!-- 其他原有条件不变 -->
|
|
<choose>
|
|
<when test="cashCollection.status != null and cashCollection.status == 46">
|
|
<if test="cashCollection.receivedMarket != null and cashCollection.receivedMarket != ''">
|
|
AND (cr.received_market = #{cashCollection.receivedMarket}
|
|
<if test="cashCollection.submitterMarket != null and cashCollection.submitterMarket != ''">
|
|
OR cr.submitter_market = #{cashCollection.submitterMarket}
|
|
</if>
|
|
)
|
|
</if>
|
|
<if test="(cashCollection.receivedMarket == null or cashCollection.receivedMarket == '')
|
|
and cashCollection.submitterMarket != null and cashCollection.submitterMarket != ''">
|
|
AND cr.submitter_market = #{cashCollection.submitterMarket}
|
|
</if>
|
|
</when>
|
|
|
|
<!-- 非 status=46 保持原逻辑:同时满足 -->
|
|
<otherwise>
|
|
<if test="cashCollection.receivedMarket != null and cashCollection.receivedMarket != ''">
|
|
AND cr.received_market = #{cashCollection.receivedMarket}
|
|
</if>
|
|
<if test="cashCollection.submitterMarket != null and cashCollection.submitterMarket != ''">
|
|
AND cr.submitter_market = #{cashCollection.submitterMarket}
|
|
</if>
|
|
</otherwise>
|
|
</choose>
|
|
<if test="cashCollection.activity!=null and cashCollection.activity!=''">
|
|
AND cr.activity like concat('%',#{cashCollection.activity},'%')
|
|
</if>
|
|
<if test="cashCollection.paymentCurrency!=null and cashCollection.paymentCurrency!=''">
|
|
AND cr.payment_currency like concat('%',#{cashCollection.paymentCurrency},'%')
|
|
</if>
|
|
|
|
<if test="cashCollection.goodsName!=null and cashCollection.goodsName!=''">
|
|
AND cr.goods_name like concat('%',#{cashCollection.goodsName},'%')
|
|
</if>
|
|
<if test="cashCollection.payType!=null and cashCollection.payType!=''">
|
|
AND cr.pay_type = #{cashCollection.payType}
|
|
</if>
|
|
<if test="cashCollection.status != null">
|
|
AND cr.status IN
|
|
<foreach collection="cashCollection.status.toString().toCharArray()" item="digit" open="(" separator="," close=")">
|
|
#{digit}
|
|
</foreach>
|
|
</if>
|
|
<if test="cashCollection.startTime!=null and cashCollection.endTime!=null">
|
|
AND cr.pay_time between #{cashCollection.startTime} and #{cashCollection.endTime}
|
|
</if>
|
|
and cr.order_type=1
|
|
</where>
|
|
<choose>
|
|
<when test="cashCollection.sortField != null and cashCollection.sortField.length > 0 or cashCollection.sortOrder != null and cashCollection.sortOrder.length > 0">
|
|
ORDER BY ${cashCollection.sortField} ${cashCollection.sortOrder}
|
|
</when>
|
|
<otherwise>
|
|
ORDER BY update_time DESC
|
|
</otherwise>
|
|
</choose>
|
|
</select>
|
|
<select id="selectAuditByOrderCode" resultType="com.example.demo.domain.entity.CashRecord">
|
|
select id, status,jwcode,name,market,activity,
|
|
order_code,bank_code,goods_name,good_num,permanent_gold,free_gold,
|
|
payment_currency,payment_amount,pay_type,pay_time,status,submitter_id,
|
|
voucher,remark from cash_record where order_code=#{orderCode}
|
|
</select>
|
|
<!--根据精网号获取姓名-->
|
|
<select id="getNameByJwcode" resultType="java.lang.String">
|
|
select name from user where jwcode=#{jwcode}
|
|
</select>
|
|
<select id="getMarketNameByJwcode" resultType="java.lang.String">
|
|
select m.name from user u left join market m on u.market=m.id
|
|
where u.jwcode=#{jwcode}</select>
|
|
<select id="getActivityList" resultType="java.lang.String">
|
|
select distinct activity from cash_record
|
|
</select>
|
|
<!--查找未同步的订单-->
|
|
<select id="getUnSync" resultType="com.example.demo.domain.entity.GOrder">
|
|
select id,jwcode,order_no,type,price,count,pay_style,state,
|
|
success_time,ios_environment,ios_transaction_id,ios_receipt_data,
|
|
add_time,is_synced
|
|
from g_order
|
|
where is_synced=0 and state=1 and type='gold_coin' and pay_style in(3,5,6,7,9)
|
|
limit #{size}
|
|
</select>
|
|
</mapper>
|