|
|
@@ -3,16 +3,27 @@
|
|
|
<mapper namespace="com.sqx.modules.app.dao.UserMoneyDetailsDao">
|
|
|
|
|
|
<select id="selectUserMoneyDetails" resultType="com.sqx.modules.app.entity.UserMoneyDetails">
|
|
|
- select * from user_money_details where user_id = #{userId} and classify = #{classify} order by create_time desc
|
|
|
+ select *
|
|
|
+ from user_money_details
|
|
|
+ where user_id = #{userId}
|
|
|
+ and classify = #{classify}
|
|
|
+ order by create_time desc
|
|
|
</select>
|
|
|
|
|
|
<select id="selectShopCashDeposit" resultType="com.sqx.modules.app.entity.UserMoneyDetails">
|
|
|
- select * from user_money_details where shop_id = #{shopId} and classify = #{classify}
|
|
|
+ select *
|
|
|
+ from user_money_details
|
|
|
+ where shop_id = #{shopId}
|
|
|
+ and classify = #{classify}
|
|
|
order by create_time desc
|
|
|
</select>
|
|
|
|
|
|
<select id="selectShopCashDepositList" resultType="com.sqx.modules.app.entity.UserMoneyDetails">
|
|
|
- select * from user_money_details where shop_id = #{shopId} and classify = 2 order by create_time desc
|
|
|
+ select *
|
|
|
+ from user_money_details
|
|
|
+ where shop_id = #{shopId}
|
|
|
+ and classify = 2
|
|
|
+ order by create_time desc
|
|
|
</select>
|
|
|
|
|
|
<sql id="walletQueryCondition">
|
|
|
@@ -34,43 +45,178 @@
|
|
|
</if>
|
|
|
|
|
|
<if test="query.endTime != null">
|
|
|
- and umd.create_time <![CDATA[<=]]> #{query.endTime}</if>
|
|
|
+ and umd.create_time <![CDATA[<=]]> #{query.endTime}
|
|
|
+ </if>
|
|
|
</where>
|
|
|
</sql>
|
|
|
|
|
|
<select id="walletDetailList" resultType="com.sqx.modules.pay.vo.WalletDetailVO">
|
|
|
select
|
|
|
- umd.id,
|
|
|
- gs.shop_name,
|
|
|
- umd.title,
|
|
|
- umd.content,
|
|
|
- umd.type,
|
|
|
- umd.classify,
|
|
|
- umd.money,
|
|
|
- umd.create_time
|
|
|
+ umd.id,
|
|
|
+ gs.shop_name,
|
|
|
+ umd.title,
|
|
|
+ umd.content,
|
|
|
+ umd.type,
|
|
|
+ umd.classify,
|
|
|
+ umd.money,
|
|
|
+ umd.create_time
|
|
|
from
|
|
|
- user_money_details umd
|
|
|
- left join goods_shop gs on gs.shop_id = umd.shop_id
|
|
|
+ user_money_details umd
|
|
|
+ left join goods_shop gs on gs.shop_id = umd.shop_id
|
|
|
<include refid="walletQueryCondition"></include>
|
|
|
order by umd.create_time desc
|
|
|
</select>
|
|
|
|
|
|
<select id="walletDetailStatistics" resultType="java.math.BigDecimal">
|
|
|
select
|
|
|
- sum(o.amount)
|
|
|
+ sum(o.amount)
|
|
|
+ from
|
|
|
+ (
|
|
|
+ select
|
|
|
+ case
|
|
|
+ when umd.type = 1 then umd.money
|
|
|
+ else -umd.money
|
|
|
+ end as amount
|
|
|
from
|
|
|
- (
|
|
|
- select
|
|
|
- case
|
|
|
- when umd.type = 1 then umd.money
|
|
|
- else -umd.money
|
|
|
- end as amount
|
|
|
- from
|
|
|
- user_money_details umd
|
|
|
- left join goods_shop gs on gs.shop_id = umd.shop_id
|
|
|
- <include refid="walletQueryCondition"></include>
|
|
|
- order by umd.create_time desc
|
|
|
- ) o
|
|
|
+ user_money_details umd
|
|
|
+ left join goods_shop gs on gs.shop_id = umd.shop_id
|
|
|
+ <include refid="walletQueryCondition"></include>
|
|
|
+ order by umd.create_time desc
|
|
|
+ ) o
|
|
|
</select>
|
|
|
|
|
|
+ <select id="accountEntryManagementDetailsList" resultType="com.sqx.modules.app.entity.UserMoneyDetails">
|
|
|
+ SELECT
|
|
|
+ umd2.id,
|
|
|
+ umd2.orderNumber,
|
|
|
+ umd2.user_id as userId,
|
|
|
+ umd2.shop_id as shopId,
|
|
|
+ umd2.title,
|
|
|
+ umd2.content,
|
|
|
+ umd2.type,
|
|
|
+ umd2.classify,
|
|
|
+ umd2.money,
|
|
|
+ umd2.create_time as createTime,
|
|
|
+ umd2.state,
|
|
|
+ tbu.user_name as userName,
|
|
|
+ tbu.phone as userPhone,
|
|
|
+ gs.shop_name as shopName,
|
|
|
+ gs.phone as shopPhone,
|
|
|
+ tcu.coupon_name as couponName,
|
|
|
+ tcu.money as couponMoney,
|
|
|
+ apr.discount_amount as activityDiscountAmount,
|
|
|
+ tbo.errand_money as errandMoney
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ RIGHT( umd.title, 18 ) AS orderNumber,
|
|
|
+ umd.id,
|
|
|
+ umd.user_id,
|
|
|
+ umd.shop_id,
|
|
|
+ umd.title,
|
|
|
+ umd.content,
|
|
|
+ umd.type,
|
|
|
+ umd.classify,
|
|
|
+ umd.money,
|
|
|
+ umd.create_time,
|
|
|
+ umd.state,
|
|
|
+ umd.children_id
|
|
|
+ FROM
|
|
|
+ `user_money_details` umd
|
|
|
+ WHERE
|
|
|
+ umd.type = 1
|
|
|
+ AND umd.classify = 3
|
|
|
+ AND umd.shop_id IS NOT NULL
|
|
|
+ AND umd.state=2
|
|
|
+ AND umd.title LIKE '商户订单收入' '%'
|
|
|
+ ) umd2
|
|
|
+ LEFT JOIN tb_order tbo on tbo.order_number=umd2.orderNumber
|
|
|
+ LEFT JOIN tb_user tbu on tbu.user_id=tbo.user_id
|
|
|
+ LEFT JOIN goods_shop gs on gs.shop_id=tbo.shop_id
|
|
|
+ LEFT JOIN tb_coupon_user tcu on tbo.coupon_id = tcu.id
|
|
|
+ LEFT JOIN activity_part_record apr on apr.order_id = tbo.order_id
|
|
|
+ where 1 = 1
|
|
|
+ <if test="shopName != null and shopName != ''">
|
|
|
+ and gs.shop_name like '%'#{shopName}'%'
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="shopPhone != null and shopPhone != ''">
|
|
|
+ and gs.phone= #{shopPhone}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="userPhone != null and userPhone != ''">
|
|
|
+ and tbu.phone=#{userPhone}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="couponName != null and couponName != ''">
|
|
|
+ and tcu.coupon_name like '%'#{couponName}'%'
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="orderNumber != null and orderNumber != ''">
|
|
|
+ and tbo.order_number = #{orderNumber}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
|
|
|
+ and umd2.create_time >= #{startTime} and #{endTime} >= umd2.create_time
|
|
|
+ </if>
|
|
|
+ ORDER BY tbo.create_time desc
|
|
|
+ LIMIT #{limit} OFFSET #{row}
|
|
|
+ </select>
|
|
|
+ <select id="accountEntryManagementDetailsCount" resultType="java.lang.Integer">
|
|
|
+ SELECT
|
|
|
+ count(*)
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ RIGHT( umd.title, 18 ) AS orderNumber,
|
|
|
+ umd.id,
|
|
|
+ umd.user_id,
|
|
|
+ umd.shop_id,
|
|
|
+ umd.title,
|
|
|
+ umd.content,
|
|
|
+ umd.type,
|
|
|
+ umd.classify,
|
|
|
+ umd.money,
|
|
|
+ umd.create_time,
|
|
|
+ umd.state,
|
|
|
+ umd.children_id
|
|
|
+ FROM
|
|
|
+ `user_money_details` umd
|
|
|
+ WHERE
|
|
|
+ umd.type = 1
|
|
|
+ AND umd.classify = 3
|
|
|
+ AND umd.shop_id IS NOT NULL
|
|
|
+ AND umd.state=2
|
|
|
+ AND umd.title LIKE '商户订单收入' '%'
|
|
|
+ ) umd2
|
|
|
+ LEFT JOIN tb_order tbo on tbo.order_number=umd2.orderNumber
|
|
|
+ LEFT JOIN tb_user tbu on tbu.user_id=tbo.user_id
|
|
|
+ LEFT JOIN goods_shop gs on gs.shop_id=tbo.shop_id
|
|
|
+ LEFT JOIN tb_coupon_user tcu on tbo.coupon_id = tcu.id
|
|
|
+ LEFT JOIN activity_part_record apr on apr.order_id = tbo.order_id
|
|
|
+ where 1 = 1
|
|
|
+ <if test="shopName != null and shopName != ''">
|
|
|
+ and gs.shop_name like '%'#{shopName}'%'
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="shopPhone != null and shopPhone != ''">
|
|
|
+ and gs.phone= #{shopPhone}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="userPhone != null and userPhone != ''">
|
|
|
+ and tbu.phone=#{userPhone}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="couponName != null and couponName != ''">
|
|
|
+ and tcu.coupon_name like '%'#{couponName}'%'
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="orderNumber != null and orderNumber != ''">
|
|
|
+ and tbo.order_number = #{orderNumber}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
|
|
|
+ and umd2.create_time >= #{startTime} and #{endTime} >= umd2.create_time
|
|
|
+ </if>
|
|
|
+ </select>
|
|
|
</mapper>
|