Blame view

dal/src/main/resources/META-INF/mybatis/UserOrdersMapper.xml 13.9 KB
zhouxiang authored
1 2 3 4 5
<?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.yoho.unions.dal.IUserOrdersDAO" >
  <resultMap id="BaseResultMap" type="com.yoho.unions.dal.model.UserOrders" >
    <id column="id" property="id" jdbcType="INTEGER" />
zhengwen.ge authored
6
    <result column="uid" property="uid" jdbcType="VARCHAR" />
zhouxiang authored
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
    <result column="order_code" property="orderCode" jdbcType="VARCHAR" />
    <result column="order_amount" property="orderAmount" jdbcType="DECIMAL" />
    <result column="amount" property="amount" jdbcType="DECIMAL" />
    <result column="yoho_coin" property="yohoCoin" jdbcType="SMALLINT" />
    <result column="coupons_num" property="couponsNum" jdbcType="SMALLINT" />
    <result column="create_time" property="createTime" jdbcType="INTEGER" />
    <result column="order_status" property="orderStatus" jdbcType="TINYINT" />
    <result column="channel_code" property="channelCode" jdbcType="VARCHAR" />
    <result column="append" property="append" jdbcType="VARCHAR" />
    <result column="is_valid" property="isValid" jdbcType="CHAR" />
    <result column="remark" property="remark" jdbcType="VARCHAR" />
    <result column="user_id" property="userId" jdbcType="VARCHAR" />
    <result column="mbr_name" property="mbrName" jdbcType="VARCHAR" />
    <result column="is_settle_accounts" property="isSettleAccounts" jdbcType="TINYINT" />
    <result column="settle_amount" property="settleAmount" jdbcType="DECIMAL" />
    <result column="settle_accounts_time" property="settleAccountsTime" jdbcType="INTEGER" />
    <result column="campaign_id" property="campaignId" jdbcType="INTEGER" />
    <result column="source" property="source" jdbcType="VARCHAR" />
    <result column="tracking_code" property="trackingCode" jdbcType="VARCHAR" />
    <result column="u_id" property="uId" jdbcType="INTEGER" />
    <result column="order_time" property="orderTime" jdbcType="INTEGER" />
    <result column="is_push" property="isPush" jdbcType="INTEGER" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, uid, order_code, order_amount, amount, yoho_coin, coupons_num, create_time, order_status, 
    channel_code, append, is_valid, remark, user_id, mbr_name, is_settle_accounts, settle_amount, 
    settle_accounts_time, campaign_id, source, tracking_code, u_id, order_time, is_push
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    from user_orders
    where id = #{id,jdbcType=INTEGER}
  </select>
unknown authored
41 42 43 44
  <select id="selectByOrderCode" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from user_orders
unknown authored
45
    where order_code = #{orderCode} limit 1
unknown authored
46
  </select>
unknown authored
47
zhouxiang authored
48 49 50 51 52
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from user_orders
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.yoho.unions.dal.model.UserOrders" >
zhouxiang authored
53 54 55 56 57 58 59
    insert into user_orders (id, uid, order_code,
      order_amount, amount, yoho_coin,
      coupons_num, create_time, order_status,
      channel_code, append, is_valid,
      remark, user_id, mbr_name,
      is_settle_accounts, settle_amount, settle_accounts_time,
      campaign_id, source, tracking_code,
zhouxiang authored
60 61
      u_id, order_time, is_push
      )
zhengwen.ge authored
62
    values (#{id,jdbcType=INTEGER}, #{uid,jdbcType=VARCHAR}, #{orderCode,jdbcType=VARCHAR},
zhouxiang authored
63 64 65 66 67 68
      #{orderAmount,jdbcType=DECIMAL}, #{amount,jdbcType=DECIMAL}, #{yohoCoin,jdbcType=SMALLINT},
      #{couponsNum,jdbcType=SMALLINT}, #{createTime,jdbcType=INTEGER}, #{orderStatus,jdbcType=TINYINT},
      #{channelCode,jdbcType=VARCHAR}, #{append,jdbcType=VARCHAR}, #{isValid,jdbcType=CHAR},
      #{remark,jdbcType=VARCHAR}, #{userId,jdbcType=VARCHAR}, #{mbrName,jdbcType=VARCHAR},
      #{isSettleAccounts,jdbcType=TINYINT}, #{settleAmount,jdbcType=DECIMAL}, #{settleAccountsTime,jdbcType=INTEGER},
      #{campaignId,jdbcType=INTEGER}, #{source,jdbcType=VARCHAR}, #{trackingCode,jdbcType=VARCHAR},
zhouxiang authored
69 70 71
      #{uId,jdbcType=INTEGER}, #{orderTime,jdbcType=INTEGER}, #{isPush,jdbcType=INTEGER}
      )
  </insert>
tanling authored
72
  <insert id="insertSelective" useGeneratedKeys="true" keyProperty="id" parameterType="com.yoho.unions.dal.model.UserOrders" >
zhouxiang authored
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
    insert into user_orders
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="uid != null" >
        uid,
      </if>
      <if test="orderCode != null" >
        order_code,
      </if>
      <if test="orderAmount != null" >
        order_amount,
      </if>
      <if test="amount != null" >
        amount,
      </if>
      <if test="yohoCoin != null" >
        yoho_coin,
      </if>
      <if test="couponsNum != null" >
        coupons_num,
      </if>
      <if test="createTime != null" >
        create_time,
      </if>
      <if test="orderStatus != null" >
        order_status,
      </if>
      <if test="channelCode != null" >
        channel_code,
      </if>
      <if test="append != null" >
        append,
      </if>
      <if test="isValid != null" >
        is_valid,
      </if>
      <if test="remark != null" >
        remark,
      </if>
      <if test="userId != null" >
        user_id,
      </if>
      <if test="mbrName != null" >
        mbr_name,
      </if>
      <if test="isSettleAccounts != null" >
        is_settle_accounts,
      </if>
      <if test="settleAmount != null" >
        settle_amount,
      </if>
      <if test="settleAccountsTime != null" >
        settle_accounts_time,
      </if>
      <if test="campaignId != null" >
        campaign_id,
      </if>
      <if test="source != null" >
        source,
      </if>
      <if test="trackingCode != null" >
        tracking_code,
      </if>
      <if test="uId != null" >
        u_id,
      </if>
      <if test="orderTime != null" >
        order_time,
      </if>
      <if test="isPush != null" >
        is_push,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=INTEGER},
      </if>
      <if test="uid != null" >
zhengwen.ge authored
153
        #{uid,jdbcType=VARCHAR},
zhouxiang authored
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226
      </if>
      <if test="orderCode != null" >
        #{orderCode,jdbcType=VARCHAR},
      </if>
      <if test="orderAmount != null" >
        #{orderAmount,jdbcType=DECIMAL},
      </if>
      <if test="amount != null" >
        #{amount,jdbcType=DECIMAL},
      </if>
      <if test="yohoCoin != null" >
        #{yohoCoin,jdbcType=SMALLINT},
      </if>
      <if test="couponsNum != null" >
        #{couponsNum,jdbcType=SMALLINT},
      </if>
      <if test="createTime != null" >
        #{createTime,jdbcType=INTEGER},
      </if>
      <if test="orderStatus != null" >
        #{orderStatus,jdbcType=TINYINT},
      </if>
      <if test="channelCode != null" >
        #{channelCode,jdbcType=VARCHAR},
      </if>
      <if test="append != null" >
        #{append,jdbcType=VARCHAR},
      </if>
      <if test="isValid != null" >
        #{isValid,jdbcType=CHAR},
      </if>
      <if test="remark != null" >
        #{remark,jdbcType=VARCHAR},
      </if>
      <if test="userId != null" >
        #{userId,jdbcType=VARCHAR},
      </if>
      <if test="mbrName != null" >
        #{mbrName,jdbcType=VARCHAR},
      </if>
      <if test="isSettleAccounts != null" >
        #{isSettleAccounts,jdbcType=TINYINT},
      </if>
      <if test="settleAmount != null" >
        #{settleAmount,jdbcType=DECIMAL},
      </if>
      <if test="settleAccountsTime != null" >
        #{settleAccountsTime,jdbcType=INTEGER},
      </if>
      <if test="campaignId != null" >
        #{campaignId,jdbcType=INTEGER},
      </if>
      <if test="source != null" >
        #{source,jdbcType=VARCHAR},
      </if>
      <if test="trackingCode != null" >
        #{trackingCode,jdbcType=VARCHAR},
      </if>
      <if test="uId != null" >
        #{uId,jdbcType=INTEGER},
      </if>
      <if test="orderTime != null" >
        #{orderTime,jdbcType=INTEGER},
      </if>
      <if test="isPush != null" >
        #{isPush,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.yoho.unions.dal.model.UserOrders" >
    update user_orders
    <set >
      <if test="uid != null" >
zhengwen.ge authored
227
        uid = #{uid,jdbcType=VARCHAR},
zhouxiang authored
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299
      </if>
      <if test="orderCode != null" >
        order_code = #{orderCode,jdbcType=VARCHAR},
      </if>
      <if test="orderAmount != null" >
        order_amount = #{orderAmount,jdbcType=DECIMAL},
      </if>
      <if test="amount != null" >
        amount = #{amount,jdbcType=DECIMAL},
      </if>
      <if test="yohoCoin != null" >
        yoho_coin = #{yohoCoin,jdbcType=SMALLINT},
      </if>
      <if test="couponsNum != null" >
        coupons_num = #{couponsNum,jdbcType=SMALLINT},
      </if>
      <if test="createTime != null" >
        create_time = #{createTime,jdbcType=INTEGER},
      </if>
      <if test="orderStatus != null" >
        order_status = #{orderStatus,jdbcType=TINYINT},
      </if>
      <if test="channelCode != null" >
        channel_code = #{channelCode,jdbcType=VARCHAR},
      </if>
      <if test="append != null" >
        append = #{append,jdbcType=VARCHAR},
      </if>
      <if test="isValid != null" >
        is_valid = #{isValid,jdbcType=CHAR},
      </if>
      <if test="remark != null" >
        remark = #{remark,jdbcType=VARCHAR},
      </if>
      <if test="userId != null" >
        user_id = #{userId,jdbcType=VARCHAR},
      </if>
      <if test="mbrName != null" >
        mbr_name = #{mbrName,jdbcType=VARCHAR},
      </if>
      <if test="isSettleAccounts != null" >
        is_settle_accounts = #{isSettleAccounts,jdbcType=TINYINT},
      </if>
      <if test="settleAmount != null" >
        settle_amount = #{settleAmount,jdbcType=DECIMAL},
      </if>
      <if test="settleAccountsTime != null" >
        settle_accounts_time = #{settleAccountsTime,jdbcType=INTEGER},
      </if>
      <if test="campaignId != null" >
        campaign_id = #{campaignId,jdbcType=INTEGER},
      </if>
      <if test="source != null" >
        source = #{source,jdbcType=VARCHAR},
      </if>
      <if test="trackingCode != null" >
        tracking_code = #{trackingCode,jdbcType=VARCHAR},
      </if>
      <if test="uId != null" >
        u_id = #{uId,jdbcType=INTEGER},
      </if>
      <if test="orderTime != null" >
        order_time = #{orderTime,jdbcType=INTEGER},
      </if>
      <if test="isPush != null" >
        is_push = #{isPush,jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.yoho.unions.dal.model.UserOrders" >
    update user_orders
zhengwen.ge authored
300
    set uid = #{uid,jdbcType=VARCHAR},
zhouxiang authored
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324
      order_code = #{orderCode,jdbcType=VARCHAR},
      order_amount = #{orderAmount,jdbcType=DECIMAL},
      amount = #{amount,jdbcType=DECIMAL},
      yoho_coin = #{yohoCoin,jdbcType=SMALLINT},
      coupons_num = #{couponsNum,jdbcType=SMALLINT},
      create_time = #{createTime,jdbcType=INTEGER},
      order_status = #{orderStatus,jdbcType=TINYINT},
      channel_code = #{channelCode,jdbcType=VARCHAR},
      append = #{append,jdbcType=VARCHAR},
      is_valid = #{isValid,jdbcType=CHAR},
      remark = #{remark,jdbcType=VARCHAR},
      user_id = #{userId,jdbcType=VARCHAR},
      mbr_name = #{mbrName,jdbcType=VARCHAR},
      is_settle_accounts = #{isSettleAccounts,jdbcType=TINYINT},
      settle_amount = #{settleAmount,jdbcType=DECIMAL},
      settle_accounts_time = #{settleAccountsTime,jdbcType=INTEGER},
      campaign_id = #{campaignId,jdbcType=INTEGER},
      source = #{source,jdbcType=VARCHAR},
      tracking_code = #{trackingCode,jdbcType=VARCHAR},
      u_id = #{uId,jdbcType=INTEGER},
      order_time = #{orderTime,jdbcType=INTEGER},
      is_push = #{isPush,jdbcType=INTEGER}
    where id = #{id,jdbcType=INTEGER}
  </update>
linlong authored
325 326 327 328 329 330 331 332 333 334 335 336 337 338
  <update id="batchUpdatePush">
    update user_orders
    <trim prefix="set" suffixOverrides=",">
      <trim prefix="is_push =case" suffix="end,">
        <foreach collection="list" item="item" index="index">
          when order_code=#{item,jdbcType=VARCHAR} then 1
        </foreach>
      </trim>
    </trim>
    where
    <foreach collection="list" separator="or" item="item" index="index" >
      order_code=#{item,jdbcType=VARCHAR}
    </foreach>
  </update>
linlong authored
339
  <select id="getExistOrderCodes" resultMap="BaseResultMap" parameterType="java.util.Set">
linlong authored
340
    select
linlong authored
341
    <include refid="Base_Column_List" />
linlong authored
342
    from user_orders
linlong authored
343
    where is_push=0 and
linlong authored
344 345 346 347 348
    order_code in
    <foreach collection="list" index="index" item="code" open="(" separator="," close=")">
      #{code}
    </foreach>
  </select>
zhengwen.ge authored
349 350 351 352 353 354

  <select id="selectCount" resultType="java.lang.Integer">
     select count(1) from user_orders where 1 = 1
    <if test="orderCode != 0" >
       and order_code = #{orderCode}
    </if>
zhengwen.ge authored
355
    <if test="unionId != null" >
zhengwen.ge authored
356 357 358 359 360 361 362 363
      and uid = #{unionId}
    </if>
    <if test="beginTime != 0" >
      and create_time &gt; #{beginTime}
    </if>
    <if test="endTime != 0" >
      and create_time &lt;#{endTime}
    </if>
zhengwen.ge authored
364 365 366 367 368 369
    <if test="idList !=null and idList.size>0">
      and id in
      <foreach item="item" index="index" collection="idList" open="(" separator="," close=")">
        #{item}
      </foreach>
    </if>
zhengwen.ge authored
370 371 372 373 374 375 376 377 378 379
  </select>

  <select id="selectUserOrderList" resultMap="BaseResultMap" >
    select
    <include refid="Base_Column_List" />
    from user_orders
    where 1=1
    <if test="orderCode != 0" >
      and order_code = #{orderCode}
    </if>
zhengwen.ge authored
380
    <if test="unionId != null" >
zhengwen.ge authored
381 382 383 384 385 386 387 388
      and uid = #{unionId}
    </if>
    <if test="beginTime != 0" >
      and create_time &gt; #{beginTime}
    </if>
    <if test="endTime != 0" >
      and create_time &lt;#{endTime}
    </if>
zhengwen.ge authored
389 390 391 392 393
    <if test="idList !=null and idList.size>0">
    and id in
    <foreach item="item" index="index" collection="idList" open="(" separator="," close=")">
      #{item}
    </foreach>
zhengwen.ge authored
394
    </if> order BY  create_time desc
zhengwen.ge authored
395 396
    limit #{startIndex},#{pageSize}
  </select>
zhouxiang authored
397
</mapper>