UnionShareOrdersMapper.xml 17.3 KB
1 2 3 4 5 6 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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 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 153 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 227 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 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472
<?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.UnionShareOrdersMapper" >
  <resultMap id="BaseResultMap" type="com.yoho.unions.dal.model.UnionShareOrders" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="order_code" property="orderCode" jdbcType="VARCHAR" />
    <result column="settlement_code" property="settlementCode" jdbcType="VARCHAR" />
    <result column="promote_uid" property="promoteUid" jdbcType="INTEGER" />
    <result column="order_uid" property="orderUid" jdbcType="INTEGER" />
    <result column="status" property="status" jdbcType="VARCHAR" />
    <result column="last_order_amount" property="lastOrderAmount" jdbcType="DECIMAL" />
    <result column="order_time" property="orderTime" jdbcType="INTEGER" />
    <result column="is_new" property="isNew" jdbcType="TINYINT" />
    <result column="amount" property="amount" jdbcType="DECIMAL" />
    <result column="create_time" property="createTime" jdbcType="INTEGER" />
    <result column="update_time" property="updateTime" jdbcType="INTEGER" />
    <result column="extra_activity_id" property="extraActivityId" jdbcType="INTEGER" />
    <result column="activity_id" property="activityId" jdbcType="INTEGER" />
    <result column="extra_amount" property="extraAmount" jdbcType="DECIMAL" />
    <result column="order_amount" property="orderAmount" jdbcType="DECIMAL" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, order_code,settlement_code, promote_uid,order_uid, status, last_order_amount, order_time, is_new, amount, create_time,
    update_time,extra_activity_id,activity_id,extra_amount,order_amount
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    from union_share_orders
    where id = #{id,jdbcType=INTEGER}
  </select>
  <select id="selectByCode" resultMap="BaseResultMap" >
    select
    <include refid="Base_Column_List" />
    from union_share_orders
    where order_code = #{orderCode,jdbcType=VARCHAR}
    limit 1
  </select>
  <select id="selectCountByCondition" resultType="java.lang.Integer" >
    select count(1) from union_share_orders
    where promote_uid = #{promoteUid,jdbcType=INTEGER} and status = #{status,jdbcType=VARCHAR}
  </select>
  <select id="selectAmountByStatus" resultType="java.math.BigDecimal" >
    select IFNULL(sum(amount),0) from union_share_orders
    where promote_uid = #{promoteUid,jdbcType=INTEGER} and status in
    <foreach collection="statusList" item="item" separator="," index="index" open="(" close=")">
      #{item}
    </foreach>
  </select>
  <select id="selectAmountBySettleCode" resultType="java.math.BigDecimal" >
    select IFNULL(sum(amount),0) from union_share_orders
    where promote_uid = #{promoteUid,jdbcType=INTEGER} and settlement_code = #{settlementCode,jdbcType=VARCHAR}
  </select>
  <select id="selectListByCondition" resultMap="BaseResultMap" >
    select
    <include refid="Base_Column_List" />
    from union_share_orders
    where promote_uid = #{promoteUid,jdbcType=INTEGER} and status = #{status,jdbcType=VARCHAR}
    limit #{offset}, #{rows}
  </select>
  <select id="selectListByIds" resultMap="BaseResultMap" >
    select
    <include refid="Base_Column_List" />
    from union_share_orders
    where id in
    <foreach collection="ids" open="(" close=")" item="id" separator=",">
      #{id}
    </foreach>
  </select>
  <select id="selectListByOrderCodesForActivity" resultMap="BaseResultMap" >
    select
    <include refid="Base_Column_List" />
    from union_share_orders
    where status in (10,20,30,40) and order_code in
    <foreach collection="orderCodes" open="(" close=")" item="ordercode" separator=",">
      #{ordercode}
    </foreach>
  </select>
  <select id="selectOrderCodesByCondition" resultType="java.lang.String" >
    select order_code from union_share_orders
    where settlement_code = #{settlementCode,jdbcType=VARCHAR} and order_code is not null
    limit #{offset}, #{rows}
  </select>
  <select id="selectOrderByCondition" resultMap="BaseResultMap">
    select
      <include refid="Base_Column_List" />
    from union_share_orders
    where settlement_code = #{settlementCode,jdbcType=VARCHAR} and order_code is not null
    limit #{offset}, #{rows}
  </select>
  <select id="selectIdForActivity" resultType="java.lang.Integer">
    select id from union_share_orders
    where settlement_code = #{settlementCode,jdbcType=VARCHAR} and order_code is null
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from union_share_orders
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" useGeneratedKeys="true" keyProperty="id" parameterType="com.yoho.unions.dal.model.UnionShareOrders" >
    insert into union_share_orders (id, order_code, promote_uid,
    order_uid, settlement_code, status,
    last_order_amount, order_time, is_new,
    amount, create_time, update_time,
    extra_activity_id, activity_id, extra_amount,
    order_amount)
    values (#{id,jdbcType=INTEGER}, #{orderCode,jdbcType=VARCHAR}, #{promoteUid,jdbcType=INTEGER},
    #{orderUid,jdbcType=INTEGER}, #{settlementCode,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR},
    #{lastOrderAmount,jdbcType=DECIMAL}, #{orderTime,jdbcType=INTEGER}, #{isNew,jdbcType=TINYINT},
    #{amount,jdbcType=DECIMAL}, #{createTime,jdbcType=INTEGER}, #{updateTime,jdbcType=INTEGER},
    #{extraActivityId,jdbcType=INTEGER}, #{activityId,jdbcType=INTEGER}, #{extraAmount,jdbcType=DECIMAL},
    #{orderAmount,jdbcType=DECIMAL})
  </insert>
  <insert id="insertSelective" useGeneratedKeys="true" keyProperty="id"  parameterType="com.yoho.unions.dal.model.UnionShareOrders" >
    insert into union_share_orders
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="orderCode != null" >
        order_code,
      </if>
      <if test="promoteUid != null" >
        promote_uid,
      </if>
      <if test="orderUid != null" >
        order_uid,
      </if>
      <if test="settlementCode != null" >
        settlement_code,
      </if>
      <if test="status != null" >
        status,
      </if>
      <if test="lastOrderAmount != null" >
        last_order_amount,
      </if>
      <if test="orderTime != null" >
        order_time,
      </if>
      <if test="isNew != null" >
        is_new,
      </if>
      <if test="amount != null" >
        amount,
      </if>
      <if test="createTime != null" >
        create_time,
      </if>
      <if test="updateTime != null" >
        update_time,
      </if>
      <if test="extraActivityId != null" >
        extra_activity_id,
      </if>
      <if test="activityId != null" >
        activity_id,
      </if>
      <if test="extraAmount != null" >
        extra_amount,
      </if>
      <if test="orderAmount != null" >
        order_amount,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=INTEGER},
      </if>
      <if test="orderCode != null" >
        #{orderCode,jdbcType=VARCHAR},
      </if>
      <if test="promoteUid != null" >
        #{promoteUid,jdbcType=INTEGER},
      </if>
      <if test="orderUid != null" >
        #{orderUid,jdbcType=INTEGER},
      </if>
      <if test="settlementCode != null" >
        #{settlementCode,jdbcType=VARCHAR},
      </if>
      <if test="status != null" >
        #{status,jdbcType=VARCHAR},
      </if>
      <if test="lastOrderAmount != null" >
        #{lastOrderAmount,jdbcType=DECIMAL},
      </if>
      <if test="orderTime != null" >
        #{orderTime,jdbcType=INTEGER},
      </if>
      <if test="isNew != null" >
        #{isNew,jdbcType=TINYINT},
      </if>
      <if test="amount != null" >
        #{amount,jdbcType=DECIMAL},
      </if>
      <if test="createTime != null" >
        #{createTime,jdbcType=INTEGER},
      </if>
      <if test="updateTime != null" >
        #{updateTime,jdbcType=INTEGER},
      </if>
      <if test="extraActivityId != null" >
        #{extraActivityId,jdbcType=INTEGER},
      </if>
      <if test="activityId != null" >
        #{activityId,jdbcType=INTEGER},
      </if>
      <if test="extraAmount != null" >
        #{extraAmount,jdbcType=DECIMAL},
      </if>
      <if test="orderAmount != null" >
        #{orderAmount,jdbcType=DECIMAL},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.yoho.unions.dal.model.UnionShareOrders" >
    update union_share_orders
    <set >
      <if test="orderCode != null" >
        order_code = #{orderCode,jdbcType=VARCHAR},
      </if>
      <if test="promoteUid != null" >
        promote_uid = #{promoteUid,jdbcType=INTEGER},
      </if>
      <if test="orderUid != null" >
        order_uid = #{orderUid,jdbcType=INTEGER},
      </if>
      <if test="settlementCode != null" >
        settlement_code = #{settlementCode,jdbcType=VARCHAR},
      </if>
      <if test="status != null" >
        status = #{status,jdbcType=VARCHAR},
      </if>
      <if test="lastOrderAmount != null" >
        last_order_amount = #{lastOrderAmount,jdbcType=DECIMAL},
      </if>
      <if test="orderTime != null" >
        order_time = #{orderTime,jdbcType=INTEGER},
      </if>
      <if test="isNew != null" >
        is_new = #{isNew,jdbcType=TINYINT},
      </if>
      <if test="amount != null" >
        amount = #{amount,jdbcType=DECIMAL},
      </if>
      <if test="createTime != null" >
        create_time = #{createTime,jdbcType=INTEGER},
      </if>
      <if test="updateTime != null" >
        update_time = #{updateTime,jdbcType=INTEGER},
      </if>
      <if test="extraActivityId != null" >
        extra_activity_id = #{extraActivityId,jdbcType=INTEGER},
      </if>
      <if test="activityId != null" >
        activity_id = #{activityId,jdbcType=INTEGER},
      </if>
      <if test="extraAmount != null" >
        extra_amount = #{extraAmount,jdbcType=DECIMAL},
      </if>
      <if test="orderAmount != null" >
        order_amount = #{orderAmount,jdbcType=DECIMAL},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByIdsForExtraActivity" >
    update union_share_orders
    set update_time = #{updateTime,jdbcType=INTEGER},
        extra_activity_id = #{extraActivityId,jdbcType=INTEGER}
    where id in
    <foreach collection="ids" separator="," item="item" index="index" close=")" open="(">
      #{item}
    </foreach>
  </update>
  <update id="updateByPrimaryKey" parameterType="com.yoho.unions.dal.model.UnionShareOrders" >
    update union_share_orders
    set order_code = #{orderCode,jdbcType=VARCHAR},
      promote_uid = #{promoteUid,jdbcType=INTEGER},
      order_uid = #{orderUid,jdbcType=INTEGER},
      settlement_code = #{settlementCode,jdbcType=VARCHAR},
      status = #{status,jdbcType=VARCHAR},
      last_order_amount = #{lastOrderAmount,jdbcType=DECIMAL},
      order_time = #{orderTime,jdbcType=INTEGER},
      is_new = #{isNew,jdbcType=TINYINT},
      amount = #{amount,jdbcType=DECIMAL},
      create_time = #{createTime,jdbcType=INTEGER},
      update_time = #{updateTime,jdbcType=INTEGER},
      extra_activity_id = #{extraActivityId,jdbcType=INTEGER},
      activity_id = #{activityId,jdbcType=INTEGER},
      extra_amount = #{extraAmount,jdbcType=DECIMAL},
      order_amount = #{orderAmount,jdbcType=DECIMAL}
    where id = #{id,jdbcType=INTEGER}
  </update>
  <select id="selectCountBySearchCodition" resultType="int">
    select count(*) from union_share_orders where 1=1
    <if test="uid!=null">
      and promote_uid = #{uid}
    </if>
    <if test="orderCode != null" >
      and order_code = #{orderCode}
    </if>
    <if test="beginTime != 0" >
      and create_time &gt; #{beginTime}
    </if>
    <if test="endTime != 0" >
      and create_time &lt;#{endTime}
    </if>
  </select>
  <select id="selectAllListByUids" resultMap="BaseResultMap">
    select <include refid="Base_Column_List" /> from union_share_orders where 1=1
    <if test="uid!=null">
      and promote_uid = #{uid}
    </if>
    <if test="orderCode != null" >
      and order_code = #{orderCode}
    </if>
    <if test="beginTime != 0" >
      and create_time &gt; #{beginTime}
    </if>
    <if test="endTime != 0" >
      and create_time &lt;#{endTime}
    </if>
    order BY  create_time desc
  </select>
  <select id="selectListByOrderUidForActivity" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from union_share_orders where status in (10,20,30,40)
      and order_uid = #{orderUid} and promote_uid = #{promoteUid}
    <if test="beginTime != 0" >
      and order_time &gt; #{beginTime}
    </if>
    <if test="endTime != 0" >
      and order_time &lt;#{endTime}
    </if>
  </select>
  <select id="selectListBySearchCodition" resultMap="BaseResultMap">
    select <include refid="Base_Column_List" /> from union_share_orders where 1=1
    <if test="uid!=null">
      and promote_uid =#{uid}
    </if>
    <if test="orderCode != null" >
      and order_code = #{orderCode}
    </if>
    <if test="beginTime != 0" >
      and create_time &gt; #{beginTime}
    </if>
    <if test="endTime != 0" >
      and create_time &lt;#{endTime}
    </if>
    order BY  create_time desc
    limit #{startIndex},#{pageSize}
  </select>
  <update id="updateStatusById" >
    update union_share_orders
    set status = #{newStatus,jdbcType=VARCHAR},
      update_time = #{updateTime,jdbcType=INTEGER}
    where id = #{id,jdbcType=INTEGER} and status = #{oldStatus,jdbcType=VARCHAR}
  </update>
  <update id="updateStatusByUid" >
    update union_share_orders
    set status = #{newStatus,jdbcType=VARCHAR},
    <if test="settlementCode != null">
      settlement_code = #{settlementCode,jdbcType=VARCHAR},
    </if>
      update_time = #{updateTime,jdbcType=INTEGER}
    where promote_uid = #{promoteUid,jdbcType=INTEGER} and status = #{oldStatus,jdbcType=VARCHAR}
  </update>
  <update id="updateStatusByCode" >
    update union_share_orders
    set status = #{newStatus,jdbcType=VARCHAR},
      update_time = #{updateTime,jdbcType=INTEGER}
    where settlement_code = #{settlementCode,jdbcType=VARCHAR} and status = #{oldStatus,jdbcType=VARCHAR}
  </update>

  <select id="selectRecentlyOrderLimitTen" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from union_share_orders
    where promote_uid = #{uid,jdbcType=INTEGER}
    AND status != 100
    order by order_time desc
    limit 0,10
  </select>

  <select id="selectOrderList" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from union_share_orders
    where promote_uid = #{params.uid,jdbcType=INTEGER}
    <if test="params.tab1 != null and params.tab1 == 1 and params.tab2 == 0">
        AND status != 100
    </if>
    <if test="params.tab1 != null and params.tab1 == 1 and params.tab2 == 1">
        AND status = 10
    </if>
    <if test="params.tab1 != null and params.tab1 == 1 and params.tab2 == 2">
        AND status IN (20,30)
    </if>
    <if test="params.tab1 != null and params.tab1 == 1 and params.tab2 == 3">
        AND status = 40
    </if>
    <if test="params.tab1 != null and params.tab1 == 2 and params.tab2 == 0">
        AND status IN (10,20,30,40)
    </if>
    <if test="params.tab1 != null and params.tab1 == 2 and params.tab2 == 1">
        AND status = 10
    </if>
    <if test="params.tab1 != null and params.tab1 == 2 and params.tab2 == 2">
        AND status IN (20,30)
    </if>
    <if test="params.tab1 != null and params.tab1 == 2 and params.tab2 == 3">
        AND status = 40
    </if>
    <if test="params.tab1 != null and params.tab1 == 3">
        AND status IN (91,92,93)
    </if>
    order by order_time desc
    limit #{params.start,jdbcType=INTEGER}, #{params.size,jdbcType=INTEGER}
  </select>

  <select id="selectOrderListCount" resultType="java.lang.Integer">
    select
    count(1)
    from union_share_orders
    where promote_uid = #{params.uid,jdbcType=INTEGER}
    <if test="params.tab1 != null and params.tab1 == 1 and params.tab2 == 0">
      AND status != 100
    </if>
    <if test="params.tab1 != null and params.tab1 == 1 and params.tab2 == 1">
      AND status = 10
    </if>
    <if test="params.tab1 != null and params.tab1 == 1 and params.tab2 == 2">
      AND status IN (20,30)
    </if>
    <if test="params.tab1 != null and params.tab1 == 1 and params.tab2 == 3">
      AND status = 40
    </if>
    <if test="params.tab1 != null and params.tab1 == 2 and params.tab2 == 0">
      AND status IN (10,20,30,40)
    </if>
    <if test="params.tab1 != null and params.tab1 == 2 and params.tab2 == 1">
      AND status = 10
    </if>
    <if test="params.tab1 != null and params.tab1 == 2 and params.tab2 == 2">
      AND status IN (20,30)
    </if>
    <if test="params.tab1 != null and params.tab1 == 2 and params.tab2 == 3">
      AND status = 40
    </if>
    <if test="params.tab1 != null and params.tab1 == 3">
      AND status IN (91,92,93)
    </if>
  </select>
  
  <select id="selectListForStatistics" resultMap="BaseResultMap">
    select <include refid="Base_Column_List" /> 
    from union_share_orders 
    where status in (10,20,30,40)
    <if test="uid!=null">
      and promote_uid =#{uid}
    </if>
    <if test="beginTime != null and beginTime != 0" >
      and order_time &gt; #{beginTime}
    </if>
    <if test="endTime != null and endTime != 0" >
      and order_time &lt;#{endTime}
    </if>
  </select>
  
</mapper>