查询用户的余额总计

	<!-- 查询用户的余额总计-->
	<select id="sumYongjinBalance" resultType="com.thinkgem.jeesite.modules.taobao.entity.WillpayReport">
SELECT
	(
		SUM(isnull(yongjin_sum, 0)) - isnull(
			(SELECT
				SUM(
					isnull(withdraw_reality_total, 0)
				+ isnull(withdraw_charge, 0))
			FROM
				withdrawal
			WHERE
				(status = '3' or status = '2' or status = '1')
			AND userid = #{loginName}
		),
		0)
	)yongjin_sum

FROM
	dbo.willpay_report
WHERE
	is_leader = '1'
AND is_jiesuan = '1'
AND login_name = #{loginName}
	</select>
</mapper>

  

结算佣金流程:

1、通过存储过程算出应付佣金,这个是按月计算的,但佣金余额不是分月的,是总的;
2、用户提现申请后,佣金余额=sum(应付佣金)-sum(提现申请金额-手续费);
3、提现成功后,佣金余额=sum(应付佣金)-sum(实际提现金额-手续费);
4、提现不成功,佣金余额=应付佣金;
5、数据库表的提现余额在提现申请成功的时候计算一次即可;

posted @ 2019-04-20 11:00  hoge  阅读(250)  评论(0编辑  收藏  举报