ShareProfitRecordMapper.xml 2.2 KB
<?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.sibu.orderHelper.integral.dao.ShareProfitRecordDao">

	<sql id="shareProfitRecordSql">
		share_user_id, buyer_user_id, order_id, order_code, profit_money, profit_status, product_id, product_price,product_share_percentage, product_amount,profit_dt,order_dt,create_dt
	</sql>

	<!-- 添加收货地址 -->
	<insert id="addShareProfitRecord" parameterType="com.sibu.orderHelper.integral.model.IMShareProfitRecord" >
		insert into t_share_profit_record (share_user_id, buyer_user_id, order_id, order_code, profit_money, profit_status, product_id, product_price,
				product_share_percentage, product_amount,create_dt
		)
		values (#{shareUserId,jdbcType=VARCHAR}, #{buyerUserId,jdbcType=VARCHAR},
		#{orderId,jdbcType=VARCHAR}, #{orderCode,jdbcType=VARCHAR}, #{profitMoney},
		#{profitStatus,jdbcType=INTEGER}, #{productId,jdbcType=VARCHAR}, #{productPrice}, #{productSharePercentage},
		#{productAmount},
		now()
		)
	</insert>

	<!--更新分享收益记录-->
	<update id="updateShareProfitRecordStatus" parameterType="java.util.Map">
		update t_share_profit_record set profit_status = #{shareProfitStatus}, order_dt=now(), update_dt=now() where order_code = #{orderCode} limit 1
	</update>

	<!--更新分享收益生效日期-->
	<update id="updateShareProfitRecordEffectDate" parameterType="java.util.Map">
		update t_share_profit_record set profit_dt = #{profitDate}, update_dt=now() where order_code = #{orderCode} limit 1
	</update>

	<!--查询收益总额-->
	<select id="selectTotalProfitAmount" parameterType="java.util.Map" resultType="java.math.BigDecimal">
		select sum(profit_money-refund_money) from `t_share_profit_record` WHERE share_user_id =#{memberId} and profit_status =1 AND settlement_dt is not null;
	</select>

	<!--查询某月收益总额-->
	<select id="selectMonthProfitAmount" parameterType="java.util.Map" resultType="java.math.BigDecimal">
		select sum(profit_money-refund_money) from `t_share_profit_record` WHERE share_user_id =#{memberId} and profit_status =1 AND create_dt BETWEEN #{startDt} and #{endDt};
	</select>

</mapper>