| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279 |
- <?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.kxs.product.biz.mapper.KxsMachineMapper">
- <resultMap type="com.kxs.product.api.model.KxsMachine" id="KxsMachineMap">
- <result column="id" property="id"/>
- <result column="create_time" property="createTime"/>
- <result column="update_time" property="updateTime"/>
- <result column="del_flag" property="delFlag"/>
- <result column="version" property="version"/>
- <result column="pos_sn" property="posSn"/>
- <result column="warehouse_id" property="warehouseId"/>
- <result column="warehouse_name" property="warehouseName"/>
- <result column="user_id" property="userId"/>
- <result column="merchant_id" property="merchantId"/>
- <result column="brand_id" property="brandId"/>
- <result column="recycle_status" property="recycleStatus"/>
- <result column="recycle_end_time" property="recycleEndTime"/>
- <result column="machine_type" property="machineType"/>
- <result column="cash_pledge" property="cashPledge"/>
- <result column="source_pledge" property="sourcePledge"/>
- <result column="allot_path" property="allotPath"/>
- <result column="bind_time" property="bindTime"/>
- <result column="act_time" property="actTime"/>
- <result column="delivery_time" property="deliveryTime"/>
- <result column="box_sn" property="boxSn"/>
- <result column="machine_ratio" property="machineRatio"/>
- <result column="is_act" property="isAct"/>
- <result column="bind_status" property="bindStatus"/>
- <result column="status" property="status"/>
- <result column="is_first" property="isFirst"/>
- <result column="up_fee_flag" property="upFeeFlag"/>
- <result column="down_fee_flag" property="downFeeFlag"/>
- <result column="is_supply" property="isSupply"/>
- <result column="is_op_act" property="isOpAct"/>
- <result column="return_status" property="returnStatus"/>
- <result column="pre_user_id" property="preUserId"/>
- <result column="batch_no" property="batchNo"/>
- <result column="credit_trade" property="creditTrade"/>
- <result column="debit_card_trade" property="debitCardTrade"/>
- <result column="scan_qr_trade" property="scanQrTrade"/>
- <result column="source_pos_sn" property="sourcePosSn"/>
- <result column="dev_location" property="devLocation"/>
- <result column="second_fee" property="secondFee"/>
- </resultMap>
- <select id="machineStoreList" resultType="com.kxs.product.api.vo.kxsapp.machine.MachineStoreListVO">
- select create_time, pos_sn from kxs_machine
- <where>
- and del_flag = 0
- and status = 0
- and pre_user_id = 0
- <if test="query.warehouseId != null">
- and warehouse_id = #{query.warehouseId}
- </if>
- <if test="query.brandId != null">
- and brand_id = #{query.brandId}
- </if>
- <if test="query.boxSn != null and query.boxSn != ''">
- and box_sn = #{query.boxSn}
- </if>
- <if test="query.posSn != null and query.posSn != ''">
- and pos_sn like concat('%', #{query.posSn}, '%')
- </if>
- </where>
- </select>
- <select id="recycleMachinesPage" resultType="com.kxs.product.api.vo.kxsapp.machine.RecycleMachinesVO">
- select id,create_time, pos_sn, machine_type, recycle_end_time from kxs_machine
- <where>
- and del_flag = 0
- and recycle_status = 1
- and user_id = #{userId}
- AND brand_id IN
- <foreach collection="brandIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </where>
- </select>
- <select id="machineUnBindListPage" resultType="com.kxs.product.api.vo.kxsapp.machine.MachineUnBindListVO">
- select id,cash_pledge, pos_sn, machine_type, recycle_end_time from kxs_machine
- <where>
- and del_flag = 0
- and bind_status = 0
- and user_id = #{query.userId}
- <if test="query.brandId != null">
- and brand_id = #{query.brandId}
- </if>
- <if test="query.keyword != null and query.keyword != ''">
- and pos_sn like concat('%', #{query.keyword}, '%')
- </if>
- </where>
- </select>
- <select id="machineBindList" resultType="com.kxs.product.api.vo.kxsapp.machine.MachineBindListVO">
- select is_act, pos_sn, machine_type, cash_pledge from kxs_machine
- <where>
- and del_flag = 0
- and bind_status = 1
- and user_id = #{query.userId}
- <if test="query.brandId != null">
- and brand_id = #{query.brandId}
- </if>
- <if test="query.keyword != null and query.keyword != ''">
- and pos_sn like concat('%', #{query.keyword}, '%')
- </if>
- </where>
- </select>
- <select id="getByPage" resultType="com.kxs.product.api.vo.kxsapp.machine.MachineUserListVO">
- select a.is_act, a.pos_sn, a.machine_type, a.cash_pledge, a.delivery_time, a.warehouse_name,
- b.name as brand
- from kxs_machine a
- left join kxs_brand b on a.brand_id = b.id
- <where>
- and a.del_flag = 0
- and a.user_id = #{query.userId}
- <if test="query.brandId != null">
- and a.brand_id = #{query.brandId}
- </if>
- <if test="query.keyword != null and query.keyword != ''">
- and a.pos_sn like concat('%', #{query.keyword}, '%')
- </if>
- </where>
- </select>
- <select id="searchUserMachine" resultType="com.kxs.product.api.vo.kxsapp.machine.SearchUserMachineVO">
- select create_time, pos_sn from kxs_machine
- <where>
- <if test="query.userId != null">
- and user_id = #{query.userId}
- </if>
- <if test="query.boxSn != null and query.boxSn != ''">
- and box_sn = #{query.boxSn}
- </if>
- <if test="query.posSn != null and query.posSn != ''">
- and pos_sn like concat('%', #{query.posSn}, '%')
- </if>
- </where>
- </select>
- <select id="recyclePageList" resultType="com.kxs.product.api.vo.kxsapp.machine.MachineRecycleListVO">
- select recycle_end_time, pos_sn, brand_id from kxs_machine
- where del_flag = 0
- and bind_status = 0
- and is_act = 0
- and recycle_end_time < #{query.endDay}
- and user_id = #{query.userId}
- <if test="query.posSn != null and query.posSn != ''">
- and pos_sn like concat('%', #{query.posSn}, '%')
- </if>
- <if test="query.brandId != null and query.brandId != ''">
- and brand_id = #{query.brandId}
- </if>
- <if test="query.sns != null and query.sns.size() > 0">
- and pos_sn not in
- <foreach collection="query.sns" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- order by recycle_end_time desc
- </select>
- <select id="selectDeductList" resultMap="KxsMachineMap">
- select a.id, a.user_id, a.pos_sn, a.brand_id, a.recycle_end_time
- from kxs_machine a
- left join kxs_machine_deduct b on a.pos_sn = b.pos_sn
- where b.pos_sn is null
- and a.del_flag = 0
- and a.user_id = #{query.userId}
- and a.status = #{query.status}
- and a.bind_status = #{query.bindStatus}
- and a.recycle_end_time < #{query.recycleEndTime}
- </select>
- <select id="selectExpireDeductList" resultMap="KxsMachineMap">
- select a.id, a.pos_sn, recycle_end_time
- from kxs_machine a
- left join kxs_machine_deduct b on a.pos_sn = b.pos_sn
- where b.pos_sn is null
- and a.del_flag = 0
- and a.status = 1
- and a.user_id > 0
- and a.bind_status = 0
- and a.recycle_end_time < #{endDay}
- order by recycle_end_time desc limit 1000
- </select>
- <select id="recycleBrandList" resultType="com.kxs.system.api.vo.kxsapp.RecycleBrandListVO">
- select DISTINCT kb.id, kb.name
- from kxs_machine km
- left join kxs_brand kb on km.brand_id = kb.id
- where km.del_flag = 0
- and km.is_act = 0
- and km.bind_status = 0
- and km.recycle_end_time < #{endDay}
- and km.user_id = #{userId}
- <if test="sns != null and sns.size() > 0">
- and km.pos_sn not in
- <foreach collection="sns" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- </select>
- <select id="getActivityMachineByIdAndTime" resultType="java.lang.Integer">
- select
- count(id) as number
- from kxs_machine
- where del_flag != 1
- and bind_time between #{param.startTime} and #{param.endTime}
- and act_time between #{param.startTime} and #{param.endTime}
- and user_id = #{param.userId}
- <if test="brandId == 14">
- and brand_id = 14
- </if>
- <if test="brandId == 0">
- and brand_id != 14
- </if>
- </select>
- <select id="machinePage" resultMap="KxsMachineMap">
- SELECT
- km.*
- FROM
- kxs_machine km
- <where>
- and km.del_flag = 0
- <if test="query.posSn != null and query.posSn != ''">
- <bind name="posSnLike" value="'%'+query.posSn+'%'"/>
- AND km.pos_sn LIKE #{posSnLike}
- </if>
- <if test="query.brandId != null and query.brandId != ''">
- <bind name="brandIdLike" value="'%'+query.brandId+'%'"/>
- AND km.brand_id LIKE #{brandIdLike}
- </if>
- <if test="query.isAct != null">
- AND km.is_act = #{query.isAct}
- </if>
- <if test="query.bindStatus != null">
- AND km.bind_status = #{query.bindStatus}
- </if>
- <if test="query.status != null">
- AND km.status = #{query.status}
- </if>
- <if test="query.userIds != null and query.userIds.size()>0">
- and km.user_id in
- <foreach collection="query.userIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="query.warehouseIds != null and query.warehouseIds.size()>0">
- and km.warehouse_id in
- <foreach collection="query.warehouseIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="query.bindTime != null and query.bindTime.length > 1">
- and (
- DATE_FORMAT(km.bind_time,'%Y-%m-%d') >= DATE_FORMAT(#{query.bindTime.[0]},'%Y-%m-%d') and
- DATE_FORMAT(#{query.bindTime.[1]},'%Y-%m-%d') >= DATE_FORMAT(km.bind_time,'%Y-%m-%d')
- )
- </if>
- <if test="query.actTime != null and query.actTime.length > 1">
- and (
- DATE_FORMAT(km.act_time,'%Y-%m-%d') >= DATE_FORMAT(#{query.actTime.[0]},'%Y-%m-%d') and
- DATE_FORMAT(#{query.actTime.[1]},'%Y-%m-%d') >= DATE_FORMAT(km.act_time,'%Y-%m-%d')
- )
- </if>
- <if test="query.deliveryTime != null and query.deliveryTime.length > 1">
- and (
- DATE_FORMAT(km.delivery_time,'%Y-%m-%d') >= DATE_FORMAT(#{query.deliveryTime.[0]},'%Y-%m-%d') and
- DATE_FORMAT(#{query.deliveryTime.[1]},'%Y-%m-%d') >= DATE_FORMAT(km.delivery_time,'%Y-%m-%d')
- )
- </if>
- </where>
- order by km.create_time desc
- </select>
- </mapper>
|