| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669 |
- <?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.goafanti.common.dao.TOrderBonusMapper">
- <resultMap id="BaseResultMap" type="com.goafanti.common.model.TOrderBonus">
- <!--
- WARNING - @mbg.generated
- This element is automatically generated by MyBatis Generator, do not modify.
- This element was generated on Tue Nov 27 11:15:28 CST 2018.
- -->
- <id column="id" jdbcType="VARCHAR" property="id" />
- <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
- <result column="order_no" jdbcType="VARCHAR" property="orderNo" />
- <result column="bonus_subject" jdbcType="INTEGER" property="bonusSubject" />
- <result column="grant_status" jdbcType="INTEGER" property="grantStatus" />
- <result column="grant_target" jdbcType="VARCHAR" property="grantTarget" />
- <result column="grant_by" jdbcType="VARCHAR" property="grantBy" />
- <result column="grant_time" jdbcType="DATE" property="grantTime" />
- <result column="grant_type" jdbcType="INTEGER" property="grantType" />
- <result column="task_id" jdbcType="INTEGER" property="taskId" />
- </resultMap>
- <sql id="Example_Where_Clause">
- <!--
- WARNING - @mbg.generated
- This element is automatically generated by MyBatis Generator, do not modify.
- This element was generated on Tue Nov 27 11:15:28 CST 2018.
- -->
- <where>
- <foreach collection="oredCriteria" item="criteria" separator="or">
- <if test="criteria.valid">
- <trim prefix="(" prefixOverrides="and" suffix=")">
- <foreach collection="criteria.criteria" item="criterion">
- <choose>
- <when test="criterion.noValue">
- and ${criterion.condition}
- </when>
- <when test="criterion.singleValue">
- and ${criterion.condition} #{criterion.value}
- </when>
- <when test="criterion.betweenValue">
- and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
- </when>
- <when test="criterion.listValue">
- and ${criterion.condition}
- <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
- #{listItem}
- </foreach>
- </when>
- </choose>
- </foreach>
- </trim>
- </if>
- </foreach>
- </where>
- </sql>
- <sql id="Update_By_Example_Where_Clause">
- <!--
- WARNING - @mbg.generated
- This element is automatically generated by MyBatis Generator, do not modify.
- This element was generated on Tue Nov 27 11:15:28 CST 2018.
- -->
- <where>
- <foreach collection="example.oredCriteria" item="criteria" separator="or">
- <if test="criteria.valid">
- <trim prefix="(" prefixOverrides="and" suffix=")">
- <foreach collection="criteria.criteria" item="criterion">
- <choose>
- <when test="criterion.noValue">
- and ${criterion.condition}
- </when>
- <when test="criterion.singleValue">
- and ${criterion.condition} #{criterion.value}
- </when>
- <when test="criterion.betweenValue">
- and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
- </when>
- <when test="criterion.listValue">
- and ${criterion.condition}
- <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
- #{listItem}
- </foreach>
- </when>
- </choose>
- </foreach>
- </trim>
- </if>
- </foreach>
- </where>
- </sql>
- <sql id="Base_Column_List">
- <!--
- WARNING - @mbg.generated
- This element is automatically generated by MyBatis Generator, do not modify.
- This element was generated on Tue Nov 27 11:15:28 CST 2018.
- -->
- id, create_time, order_no, bonus_subject, grant_status, grant_target, grant_by, grant_time,
- grant_type, task_id
- </sql>
- <select id="selectByExample" parameterType="com.goafanti.common.model.TOrderBonusExample" resultMap="BaseResultMap">
- <!--
- WARNING - @mbg.generated
- This element is automatically generated by MyBatis Generator, do not modify.
- This element was generated on Tue Nov 27 11:15:28 CST 2018.
- -->
- select
- <if test="distinct">
- distinct
- </if>
- <include refid="Base_Column_List" />
- from t_order_bonus
- <if test="_parameter != null">
- <include refid="Example_Where_Clause" />
- </if>
- <if test="orderByClause != null">
- order by ${orderByClause}
- </if>
- </select>
- <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
- <!--
- WARNING - @mbg.generated
- This element is automatically generated by MyBatis Generator, do not modify.
- This element was generated on Tue Nov 27 11:15:28 CST 2018.
- -->
- select
- <include refid="Base_Column_List" />
- from t_order_bonus
- where id = #{id,jdbcType=VARCHAR}
- </select>
- <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
- <!--
- WARNING - @mbg.generated
- This element is automatically generated by MyBatis Generator, do not modify.
- This element was generated on Tue Nov 27 11:15:28 CST 2018.
- -->
- delete from t_order_bonus
- where id = #{id,jdbcType=VARCHAR}
- </delete>
- <delete id="deleteByExample" parameterType="com.goafanti.common.model.TOrderBonusExample">
- <!--
- WARNING - @mbg.generated
- This element is automatically generated by MyBatis Generator, do not modify.
- This element was generated on Tue Nov 27 11:15:28 CST 2018.
- -->
- delete from t_order_bonus
- <if test="_parameter != null">
- <include refid="Example_Where_Clause" />
- </if>
- </delete>
- <insert id="insert" parameterType="com.goafanti.common.model.TOrderBonus">
- <!--
- WARNING - @mbg.generated
- This element is automatically generated by MyBatis Generator, do not modify.
- This element was generated on Tue Nov 27 11:15:28 CST 2018.
- -->
- insert into t_order_bonus (id, create_time, order_no,
- bonus_subject, grant_status, grant_target,
- grant_by, grant_time, grant_type, task_id
- )
- values (#{id,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{orderNo,jdbcType=VARCHAR},
- #{bonusSubject,jdbcType=INTEGER}, #{grantStatus,jdbcType=INTEGER}, #{grantTarget,jdbcType=VARCHAR},
- #{grantBy,jdbcType=VARCHAR}, #{grantTime,jdbcType=DATE}, #{grantType,jdbcType=INTEGER}, #{taskId,jdbcType=INTEGER}
- )
- </insert>
- <insert id="insertSelective" parameterType="com.goafanti.common.model.TOrderBonus">
- <!--
- WARNING - @mbg.generated
- This element is automatically generated by MyBatis Generator, do not modify.
- This element was generated on Tue Nov 27 11:15:28 CST 2018.
- -->
- insert into t_order_bonus
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="id != null">
- id,
- </if>
- <if test="createTime != null">
- create_time,
- </if>
- <if test="orderNo != null">
- order_no,
- </if>
- <if test="bonusSubject != null">
- bonus_subject,
- </if>
- <if test="grantStatus != null">
- grant_status,
- </if>
- <if test="grantTarget != null">
- grant_target,
- </if>
- <if test="grantBy != null">
- grant_by,
- </if>
- <if test="grantTime != null">
- grant_time,
- </if>
- <if test="grantType != null">
- grant_type,
- </if>
- <if test="taskId != null">
- task_id,
- </if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="id != null">
- #{id,jdbcType=VARCHAR},
- </if>
- <if test="createTime != null">
- #{createTime,jdbcType=TIMESTAMP},
- </if>
- <if test="orderNo != null">
- #{orderNo,jdbcType=VARCHAR},
- </if>
- <if test="bonusSubject != null">
- #{bonusSubject,jdbcType=INTEGER},
- </if>
- <if test="grantStatus != null">
- #{grantStatus,jdbcType=INTEGER},
- </if>
- <if test="grantTarget != null">
- #{grantTarget,jdbcType=VARCHAR},
- </if>
- <if test="grantBy != null">
- #{grantBy,jdbcType=VARCHAR},
- </if>
- <if test="grantTime != null">
- #{grantTime,jdbcType=DATE},
- </if>
- <if test="grantType != null">
- #{grantType,jdbcType=INTEGER},
- </if>
- <if test="taskId != null">
- #{taskId,jdbcType=INTEGER},
- </if>
- </trim>
- </insert>
- <select id="countByExample" parameterType="com.goafanti.common.model.TOrderBonusExample" resultType="java.lang.Long">
- <!--
- WARNING - @mbg.generated
- This element is automatically generated by MyBatis Generator, do not modify.
- This element was generated on Tue Nov 27 11:15:28 CST 2018.
- -->
- select count(*) from t_order_bonus
- <if test="_parameter != null">
- <include refid="Example_Where_Clause" />
- </if>
- </select>
- <update id="updateByExampleSelective" parameterType="map">
- <!--
- WARNING - @mbg.generated
- This element is automatically generated by MyBatis Generator, do not modify.
- This element was generated on Tue Nov 27 11:15:28 CST 2018.
- -->
- update t_order_bonus
- <set>
- <if test="record.id != null">
- id = #{record.id,jdbcType=VARCHAR},
- </if>
- <if test="record.createTime != null">
- create_time = #{record.createTime,jdbcType=TIMESTAMP},
- </if>
- <if test="record.orderNo != null">
- order_no = #{record.orderNo,jdbcType=VARCHAR},
- </if>
- <if test="record.bonusSubject != null">
- bonus_subject = #{record.bonusSubject,jdbcType=INTEGER},
- </if>
- <if test="record.grantStatus != null">
- grant_status = #{record.grantStatus,jdbcType=INTEGER},
- </if>
- <if test="record.grantTarget != null">
- grant_target = #{record.grantTarget,jdbcType=VARCHAR},
- </if>
- <if test="record.grantBy != null">
- grant_by = #{record.grantBy,jdbcType=VARCHAR},
- </if>
- <if test="record.grantTime != null">
- grant_time = #{record.grantTime,jdbcType=DATE},
- </if>
- <if test="record.grantType != null">
- grant_type = #{record.grantType,jdbcType=INTEGER},
- </if>
- <if test="record.taskId != null">
- task_id = #{record.taskId,jdbcType=INTEGER},
- </if>
- </set>
- <if test="_parameter != null">
- <include refid="Update_By_Example_Where_Clause" />
- </if>
- </update>
- <update id="updateByExample" parameterType="map">
- <!--
- WARNING - @mbg.generated
- This element is automatically generated by MyBatis Generator, do not modify.
- This element was generated on Tue Nov 27 11:15:28 CST 2018.
- -->
- update t_order_bonus
- set id = #{record.id,jdbcType=VARCHAR},
- create_time = #{record.createTime,jdbcType=TIMESTAMP},
- order_no = #{record.orderNo,jdbcType=VARCHAR},
- bonus_subject = #{record.bonusSubject,jdbcType=INTEGER},
- grant_status = #{record.grantStatus,jdbcType=INTEGER},
- grant_target = #{record.grantTarget,jdbcType=VARCHAR},
- grant_by = #{record.grantBy,jdbcType=VARCHAR},
- grant_time = #{record.grantTime,jdbcType=DATE},
- grant_type = #{record.grantType,jdbcType=INTEGER},
- task_id = #{record.taskId,jdbcType=INTEGER}
- <if test="_parameter != null">
- <include refid="Update_By_Example_Where_Clause" />
- </if>
- </update>
- <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.TOrderBonus">
- <!--
- WARNING - @mbg.generated
- This element is automatically generated by MyBatis Generator, do not modify.
- This element was generated on Tue Nov 27 11:15:28 CST 2018.
- -->
- update t_order_bonus
- <set>
- <if test="createTime != null">
- create_time = #{createTime,jdbcType=TIMESTAMP},
- </if>
- <if test="orderNo != null">
- order_no = #{orderNo,jdbcType=VARCHAR},
- </if>
- <if test="bonusSubject != null">
- bonus_subject = #{bonusSubject,jdbcType=INTEGER},
- </if>
- <if test="grantStatus != null">
- grant_status = #{grantStatus,jdbcType=INTEGER},
- </if>
- <if test="grantTarget != null">
- grant_target = #{grantTarget,jdbcType=VARCHAR},
- </if>
- <if test="grantBy != null">
- grant_by = #{grantBy,jdbcType=VARCHAR},
- </if>
- <if test="grantTime != null">
- grant_time = #{grantTime,jdbcType=DATE},
- </if>
- <if test="grantType != null">
- grant_type = #{grantType,jdbcType=INTEGER},
- </if>
- <if test="taskId != null">
- task_id = #{taskId,jdbcType=INTEGER},
- </if>
- </set>
- where id = #{id,jdbcType=VARCHAR}
- </update>
- <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.TOrderBonus">
- <!--
- WARNING - @mbg.generated
- This element is automatically generated by MyBatis Generator, do not modify.
- This element was generated on Tue Nov 27 11:15:28 CST 2018.
- -->
- update t_order_bonus
- set create_time = #{createTime,jdbcType=TIMESTAMP},
- order_no = #{orderNo,jdbcType=VARCHAR},
- bonus_subject = #{bonusSubject,jdbcType=INTEGER},
- grant_status = #{grantStatus,jdbcType=INTEGER},
- grant_target = #{grantTarget,jdbcType=VARCHAR},
- grant_by = #{grantBy,jdbcType=VARCHAR},
- grant_time = #{grantTime,jdbcType=DATE},
- grant_type = #{grantType,jdbcType=INTEGER},
- task_id = #{taskId,jdbcType=INTEGER}
- where id = #{id,jdbcType=VARCHAR}
- </update>
- <!-- 财务专员统计技术员的奖金 -->
- <select id="technicianBonusList" parameterType="Map" resultType="com.goafanti.order.bo.TOrderBonusBo">
- select b.id, t.id as tid, b.order_no as orderNo, t.task_receiver as taskReceiver, t.task_status as taskStatus,
- t.commodity_quantity as commodityQuantity, t.project_status as projectStatus, t.commodity_name as commodityName,
- accept_time as acceptTime, review_time as reviewTime, licence_time as licenceTime,
- o.liquidation_status as liquidationStatus, ga.name as byName,
- bonus_subject as bonusSubject, grant_status as grantStatus, a.name as targetName
- , b.create_time as startTime1
- from t_order_bonus b
- left join t_order_task t on b.task_id = t.id
- left join t_order_new o on o.order_no = t.order_no
- left join admin a on a.id = t.task_receiver
- left join admin oa on oa.id = o.salesman_id
- left join admin ga on ga.id = b.grant_by
- where b.grant_type = 1
- <if test="b.grantBy != null">
- and b.grant_by = #{b.grantBy,jdbcType=VARCHAR}
- </if>
- <if test='b.targetName != null and b.targetName != ""'>
- <bind name="tn" value="'%' + b.targetName + '%'" />
- and a.name like #{tn,jdbcType=VARCHAR}
- </if>
- <if test='b.salesName != null and b.salesName != ""'>
- <bind name="sn" value="'%' + b.salesName + '%'" />
- and oa.name like #{sn,jdbcType=VARCHAR}
- </if>
- <if test='b.departmentId != null and b.departmentId != ""'>
- and oa.department_id = #{b.departmentId,jdbcType=VARCHAR}
- </if>
- <if test="b.grantStatus != null">
- and b.grant_status = #{b.grantStatus,jdbcType=INTEGER}
- </if>
- <if test='b.orderNo != null and b.orderNo !=""'>
- and b.order_no = #{b.orderNo,jdbcType=VARCHAR}
- </if>
- <if test='b.startTime != null and b.startTime != "" and b.endTime != null and b.endTime != ""'>
- <bind name="a" value="b.startTime +'-01'"/>
- <bind name="e" value="b.endTime +'-31'"/>
- and o.sign_time between #{a,jdbcType=VARCHAR} and #{e,jdbcType=VARCHAR}
- </if>
- <if test='b.startTime1 != null and b.startTime1 != "" and b.endTime1 != null and b.endTime1 != ""'>
- <bind name="a1" value="b.startTime1 +' 00:00:00'"/>
- <bind name="e1" value="b.endTime1 +' 23:59:59'"/>
- and b.create_time between #{a1,jdbcType=VARCHAR} and #{e1,jdbcType=VARCHAR}
- </if>
- order by b.grant_status ,b.create_time
- <if test="page_sql != null">
- ${page_sql}
- </if>
- </select>
- <select id="technicianBonusCount" parameterType="Map" resultType="java.lang.Integer">
- select count(*)
- from t_order_bonus b
- left join t_order_task t on b.task_id = t.id
- left join t_order_new o on o.order_no = t.order_no
- left join admin a on a.id = t.task_receiver
- left join admin oa on oa.id = o.salesman_id
- where b.grant_type = 1
- <if test="b.grantBy != null">
- and b.grant_by = #{b.grantBy,jdbcType=VARCHAR}
- </if>
- <if test='b.targetName != null and b.targetName != ""'>
- <bind name="tn" value="'%' + b.targetName + '%'" />
- and a.name like #{tn,jdbcType=VARCHAR}
- </if>
- <if test='b.salesName != null and b.salesName != ""'>
- <bind name="sn" value="'%' + b.salesName + '%'" />
- and oa.name like #{sn,jdbcType=VARCHAR}
- </if>
- <if test='b.departmentId != null and b.departmentId != ""'>
- and oa.department_id = #{b.departmentId,jdbcType=VARCHAR}
- </if>
- <if test="b.grantStatus != null">
- and b.grant_status = #{b.grantStatus,jdbcType=INTEGER}
- </if>
- <if test='b.orderNo != null and b.orderNo !=""'>
- and b.order_no = #{b.orderNo,jdbcType=VARCHAR}
- </if>
-
- <if test='b.startTime != null and b.startTime != "" and b.endTime != null and b.endTime != ""'>
- <bind name="a" value="b.startTime +'-01'"/>
- <bind name="e" value="b.endTime +'-31'"/>
- and o.sign_time between #{a,jdbcType=VARCHAR} and #{e,jdbcType=VARCHAR}
- </if>
- <if test='b.startTime1 != null and b.startTime1 != "" and b.endTime1 != null and b.endTime1 != ""'>
- <bind name="a1" value="b.startTime1 +' 00:00:00'"/>
- <bind name="e1" value="b.endTime1 +' 23:59:59'"/>
- and b.create_time between #{a1,jdbcType=VARCHAR} and #{e1,jdbcType=VARCHAR}
- </if>
- </select>
- <!-- 财务专员统计营销员奖金 -->
- <select id="saleBonusList" parameterType="Map" resultType="com.goafanti.order.bo.TOrderBonusBo">
- select b.id, o.order_no as orderNo, o.salesman_id as salesmanId, o.sign_time as signTime,
- o.buyer_id as buyerId, u.nickname as buyName, o.total_amount as totalAmount,
- o.first_amount as firstAmount, o.settlement_amount as settlementAmount, o.refund_amount as refundAmount,
- o.order_status as orderStatus, o.project_status as projectStatus, b.bonus_subject as bonusSubject,
- o.proof_count as proofCount, b.grant_status as grantStatus, a.name as salesName, o.proof_status as proofStatus,
- ad.name as byName, b.grant_target as grantTarget, b.create_time as startTime1
- from t_order_bonus b
- left join t_order_new o on o.order_no = b.order_no
- left join admin a on o.salesman_id = a.id
- left join `user` u on o.buyer_id = u.id
- left join admin ad on b.grant_by = ad.id
- where b.grant_type = 0
-
- <if test="b.grantBy != null">
- and b.grant_by = #{b.grantBy,jdbcType=VARCHAR}
- </if>
- <if test='b.salesName != null and b.salesName != ""'>
- <bind name="sn" value="'%' + b.salesName + '%'" />
- and a.name like #{sn,jdbcType=VARCHAR}
- </if>
- <if test='b.departmentId != null and b.departmentId !=""'>
- and a.department_id = #{b.departmentId,jdbcType=VARCHAR}
- </if>
- <if test="b.grantStatus != null">
- and b.grant_status = #{b.grantStatus,jdbcType=INTEGER}
- </if>
- <if test='b.orderNo != null and b.orderNo !=""'>
- and b.order_no = #{b.orderNo,jdbcType=VARCHAR}
- </if>
- <if test='b.startTime != null and b.startTime != "" and b.endTime != null and b.endTime != ""'>
- <bind name="a" value="b.startTime +'-01'"/>
- <bind name="e" value="b.endTime +'-31'"/>
- and o.sign_time between #{a,jdbcType=VARCHAR} and #{e,jdbcType=VARCHAR}
- </if>
- <if test='b.startTime1 != null and b.startTime1 != "" and b.endTime1 != null and b.endTime1 != ""'>
- <bind name="a1" value="b.startTime1 +' 00:00:00'"/>
- <bind name="e1" value="b.endTime1 +' 23:59:59'"/>
- and b.create_time between #{a1,jdbcType=VARCHAR} and #{e1,jdbcType=VARCHAR}
- </if>
- order by b.grant_status , b.create_time desc
- <if test="page_sql != null">
- ${page_sql}
- </if>
- </select>
- <select id="saleBonusCount" parameterType="Map" resultType="java.lang.Integer">
- select count(*)
-
- from t_order_bonus b
- left join t_order_new o on o.order_no = b.order_no
- left join admin a on o.salesman_id = a.id
- left join `user` u on o.buyer_id = u.id
- where b.grant_type = 0
- <if test="b.grantBy != null">
- and b.grant_by = #{b.grantBy,jdbcType=VARCHAR}
- </if>
- <if test='b.salesName != null and b.salesName != ""'>
- <bind name="sn" value="'%' + b.salesName + '%'" />
- and a.name like #{sn,jdbcType=VARCHAR}
- </if>
- <if test='b.departmentId != null and b.departmentId !=""'>
- and a.department_id = #{b.departmentId,jdbcType=VARCHAR}
- </if>
- <if test="b.grantStatus != null">
- and b.grant_status = #{b.grantStatus,jdbcType=INTEGER}
- </if>
- <if test='b.orderNo != null and b.orderNo !=""'>
- and b.order_no = #{b.orderNo,jdbcType=VARCHAR}
- </if>
- <if test='b.startTime != null and b.startTime != "" and b.endTime != null and b.endTime != ""'>
- <bind name="a" value="b.startTime +'-01'"/>
- <bind name="e" value="b.endTime +'-31'"/>
- and o.sign_time between #{a,jdbcType=VARCHAR} and #{e,jdbcType=VARCHAR}
- </if>
- <if test='b.startTime1 != null and b.startTime1 != "" and b.endTime1 != null and b.endTime1 != ""'>
- <bind name="a1" value="b.startTime1 +' 00:00:00'"/>
- <bind name="e1" value="b.endTime1 +' 23:59:59'"/>
- and b.create_time between #{a1,jdbcType=VARCHAR} and #{e1,jdbcType=VARCHAR}
- </if>
- </select>
- <!-- 获得技术员有奖金数据的部门 -->
- <select id="getDeptBySome" parameterType="com.goafanti.order.bo.TOrderBonusBo" resultType="com.goafanti.order.bo.TOrderBonusBo">
- select distinct
- d.id as departmentId, d.name as departmentName
- from t_order_bonus b
- left join t_order_new o on o.order_no = b.order_no
- left join admin a on b.grant_target = a.id
- left join `user` u on o.buyer_id = u.id
- left join department d on d.id = a.department_id
- where b.grant_type = #{grantType,jdbcType=INTEGER}
- <if test="grantBy != null">
- and b.grant_by = #{grantBy,jdbcType=VARCHAR}
- </if>
- <if test='salesName != null and salesName != ""'>
- <bind name="sn" value="'%' + salesName + '%'" />
- and a.name like #{sn,jdbcType=VARCHAR}
- </if>
- <if test='departmentId != null and departmentId != ""'>
- and a.department_id = #{departmentId,jdbcType=VARCHAR}
- </if>
- <if test="grantStatus != null">
- and b.grant_status = #{grantStatus,jdbcType=INTEGER}
- </if>
- <if test='startTime != null and startTime != "" and endTime != null and endTime != ""'>
- <bind name="a" value="startTime +'-01'"/>
- <bind name="e" value="endTime +'-31'"/>
- and o.sign_time between #{a,jdbcType=VARCHAR} and #{e,jdbcType=VARCHAR}
- </if>
- <if test='startTime1 != null and startTime1 != "" and endTime1 != null and endTime1 != ""'>
- <bind name="a1" value="startTime1 +' 00:00:00'"/>
- <bind name="e1" value="endTime1 +' 23:59:59'"/>
- and b.create_time between #{a1,jdbcType=VARCHAR} and #{e1,jdbcType=VARCHAR}
- </if>
- </select>
- <!-- 获得及技术员奖金数据 -->
- <select id="getBonusData" parameterType="com.goafanti.order.bo.TOrderBonusBo" resultType="com.goafanti.order.bo.TOrderBonusBo">
- select b.id, t.id as tid, b.order_no as orderNo, t.task_receiver as taskReceiver, t.task_status as taskStatus,
- t.commodity_quantity as commodityQuantity, t.project_status as projectStatus, t.commodity_name as commodityName,
- accept_time as acceptTime, review_time as reviewTime, licence_time as licenceTime,
- o.liquidation_status as liquidationStatus, ga.name as byName,
- bonus_subject as bonusSubject, grant_status as grantStatus, a.name as targetName
- ,b.create_time as startTime1
- from t_order_bonus b
- left join t_order_task t on b.task_id = t.id
- left join t_order_new o on o.order_no = t.order_no
- left join admin a on a.id = t.task_receiver
- left join admin oa on oa.id = o.salesman_id
- left join admin ga on ga.id = b.grant_by
- where b.grant_type = 1
- <if test="grantBy != null">
- and b.grant_by = #{grantBy,jdbcType=VARCHAR}
- </if>
- <if test='targetName != null and targetName != ""'>
- <bind name="tn" value="'%' + targetName + '%'" />
- and a.name like #{tn,jdbcType=VARCHAR}
- </if>
- <if test='salesName != null and salesName != ""'>
- <bind name="sn" value="'%' + salesName + '%'" />
- and oa.name like #{sn,jdbcType=VARCHAR}
- </if>
- <if test='departmentId != null and departmentId !=""'>
- and a.department_id = #{departmentId,jdbcType=VARCHAR}
- </if>
- <if test="grantStatus != null">
- and b.grant_status = #{grantStatus,jdbcType=INTEGER}
- </if>
- <if test='startTime != null and startTime != "" and endTime != null and endTime != ""'>
- <bind name="a" value="startTime +'-01'"/>
- <bind name="e" value="endTime +'-31'"/>
- and o.sign_time between #{a,jdbcType=VARCHAR} and #{e,jdbcType=VARCHAR}
- </if>
- <if test='startTime1 != null and startTime1 != "" and endTime1 != null and endTime1 != ""'>
- <bind name="a1" value="startTime1 +' 00:00:00'"/>
- <bind name="e1" value="endTime1 +' 23:59:59'"/>
- and b.create_time between #{a1,jdbcType=VARCHAR} and #{e1,jdbcType=VARCHAR}
- </if>
- order by b.grant_status ,b.create_time desc
- </select>
- <!-- 查看营销员的奖金数据 -->
- <select id="getSaleBounsList" parameterType="com.goafanti.order.bo.TOrderBonusBo" resultType="com.goafanti.order.bo.TOrderBonusBo">
- select b.id, o.order_no as orderNo, o.salesman_id as salesmanId, o.sign_time as signTime,
- o.buyer_id as buyerId, u.nickname as buyName, o.total_amount as totalAmount,
- o.first_amount as firstAmount, o.settlement_amount as settlementAmount, o.refund_amount as refundAmount,
- o.order_status as orderStatus, o.project_status as projectStatus, b.bonus_subject as bonusSubject,
- o.proof_count as proofCount, b.grant_status as grantStatus, a.name as salesName
- ,b.create_time as startTime1, b.grant_target as grantTarget
- from t_order_bonus b
- left join t_order_new o on o.order_no = b.order_no
- left join admin a on o.salesman_id = a.id
- left join `user` u on o.buyer_id = u.id
- where b.grant_type = 0
- <if test="grantBy != null">
- and b.grant_by = #{grantBy,jdbcType=VARCHAR}
- </if>
- <if test='salesName != null and salesName != ""'>
- <bind name="sn" value="'%' + salesName + '%'" />
- and a.name like #{sn,jdbcType=VARCHAR}
- </if>
- <if test='departmentId != null and departmentId !=""'>
- and a.department_id = #{departmentId,jdbcType=VARCHAR}
- </if>
- <if test="grantStatus != null">
- and b.grant_status = #{grantStatus,jdbcType=INTEGER}
- </if>
- <if test='startTime != null and startTime != "" and endTime != null and endTime != ""'>
- <bind name="a" value="startTime +'-01'"/>
- <bind name="e" value="endTime +'-31'"/>
- and o.sign_time between #{a,jdbcType=VARCHAR} and #{e,jdbcType=VARCHAR}
- </if>
- <if test='startTime1 != null and startTime1 != "" and endTime1 != null and endTime1 != ""'>
- <bind name="a1" value="startTime1 +' 00:00:00'"/>
- <bind name="e1" value="endTime1 +' 23:59:59'"/>
- and b.create_time between #{a1,jdbcType=VARCHAR} and #{e1,jdbcType=VARCHAR}
- </if>
- </select>
- <!-- 根据订单编号和科目和奖金发放人检查这个奖金是否存在 -->
- <select id="checkByOnoAndSub" parameterType="com.goafanti.common.model.TOrderBonus" resultType="java.lang.Integer">
- select count(*) from t_order_bonus where order_no = #{orderNo,jdbcType=VARCHAR} and bonus_subject = #{bonusSubject,jdbcType=INTEGER}
- and grant_target = #{grantTarget,jdbcType=VARCHAR} and grant_type = #{grantType,jdbcType=INTEGER}
- <if test="taskId != null">
- and task_id = #{taskId,jdbcType=INTEGER}
- </if>
- </select>
- <!-- 判断当前订单中有没有未发放的数据 -->
- <select id="checkNoPay" parameterType="com.goafanti.order.bo.TOrderBonusBo" resultType="java.lang.Integer">
- select bonus_subject from t_order_bonus
- where id = #{id,jdbcType=VARCHAR} and bonus_subject > (
- select min(bonus_subject) from t_order_bonus
- where order_no = #{orderNo,jdbcType=VARCHAR} and grant_status = 0 and grant_type = 0)
- </select>
-
- </mapper>
|