<?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.yeshi.fanli.dao.mybatis.order.OrderHongBaoMapMapper">
|
<resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.order.OrderHongBaoMap">
|
<id column="ohm_id" property="id" jdbcType="BIGINT" />
|
<result column="ohm_create_time" property="createTime"
|
jdbcType="TIMESTAMP" />
|
<association property="order" column="ohm_order_id"
|
javaType="com.yeshi.fanli.entity.bus.user.Order">
|
<id column="ohm_order_id" property="id" jdbcType="BIGINT" />
|
</association>
|
<association property="hongBao" column="ohm_hongbao_id"
|
javaType="com.yeshi.fanli.entity.bus.user.HongBaoV2">
|
<id column="ohm_hongbao_id" property="id" jdbcType="BIGINT" />
|
</association>
|
|
</resultMap>
|
<sql id="Base_Column_List">ohm_id,ohm_order_id,ohm_hongbao_id,ohm_create_time</sql>
|
<select id="selectByPrimaryKey" resultMap="BaseResultMap"
|
parameterType="java.lang.Long">
|
select
|
<include refid="Base_Column_List" />
|
from yeshi_ec_order_hongbaov2_map where ohm_id = #{id,jdbcType=BIGINT}
|
</select>
|
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
|
yeshi_ec_order_hongbaov2_map where ohm_id = #{id,jdbcType=BIGINT}
|
</delete>
|
<insert id="insert" parameterType="com.yeshi.fanli.entity.order.OrderHongBaoMap"
|
useGeneratedKeys="true" keyProperty="id">insert into
|
yeshi_ec_order_hongbaov2_map
|
(ohm_id,ohm_order_id,ohm_hongbao_id,ohm_create_time) values
|
(#{id,jdbcType=BIGINT},#{order.id,jdbcType=BIGINT},#{hongBao.id,jdbcType=BIGINT},#{createTime,jdbcType=TIMESTAMP})
|
</insert>
|
<insert id="insertSelective" parameterType="com.yeshi.fanli.entity.order.OrderHongBaoMap"
|
useGeneratedKeys="true" keyProperty="id">
|
insert into yeshi_ec_order_hongbaov2_map
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="id != null">ohm_id,</if>
|
<if test="order != null">ohm_order_id,</if>
|
<if test="hongBao != null">ohm_hongbao_id,</if>
|
<if test="createTime != null">ohm_create_time,</if>
|
</trim>
|
values
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="id != null">#{id,jdbcType=BIGINT},</if>
|
<if test="order != null">#{order.id,jdbcType=BIGINT},</if>
|
<if test="hongBao != null">#{hongBao.id,jdbcType=BIGINT},</if>
|
<if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
|
</trim>
|
</insert>
|
<update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.order.OrderHongBaoMap">update
|
yeshi_ec_order_hongbaov2_map set ohm_order_id =
|
#{order.id,jdbcType=BIGINT},ohm_hongbao_id =
|
#{hongBao.id,jdbcType=BIGINT},ohm_create_time =
|
#{createTime,jdbcType=TIMESTAMP} where ohm_id = #{id,jdbcType=BIGINT}
|
</update>
|
<update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.order.OrderHongBaoMap">
|
update yeshi_ec_order_hongbaov2_map
|
<set>
|
<if test="order != null">ohm_order_id=#{order.id,jdbcType=BIGINT},</if>
|
<if test="hongBao != null">ohm_hongbao_id=#{hongBao.id,jdbcType=BIGINT},</if>
|
<if test="createTime != null">ohm_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
|
</set>
|
where ohm_id = #{id,jdbcType=BIGINT}
|
</update>
|
|
|
<select id="getCouponHongbaoByOrderNo" resultType="java.math.BigDecimal">
|
SELECT
|
COALESCE(SUM(hb.`hb_money`),0)AS couponMoney
|
FROM `yeshi_ec_order_hongbaov2_map` hm
|
LEFT JOIN `yeshi_ec_order` o ON
|
o.`id` = hm.`ohm_order_id`
|
LEFT JOIN (SELECT v2.`hb_money`,v2.`hb_id`
|
FROM yeshi_ec_hongbao_v2 v2
|
WHERE v2.`hb_uid`= #{uid} AND v2.`hb_type` = 10 )hb ON hb.hb_id =
|
hm.`ohm_hongbao_id`
|
WHERE hb.hb_id IS NOT NULL AND o.`orderid` =
|
#{orderNo}
|
</select>
|
|
<select id="listByOrderId" resultMap="BaseResultMap">
|
select * from yeshi_ec_order_hongbaov2_map where ohm_order_id=#{0}
|
</select>
|
|
|
|
</mapper>
|