| | |
| | | <?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.nq.dao.UserPositionMapper" > |
| | | <resultMap id="BaseResultMap" type="com.nq.pojo.UserPosition" > |
| | | <constructor > |
| | | <idArg column="id" jdbcType="INTEGER" javaType="java.lang.Integer" /> |
| | | <arg column="position_type" jdbcType="INTEGER" javaType="java.lang.Integer" /> |
| | | <arg column="position_sn" jdbcType="VARCHAR" javaType="java.lang.String" /> |
| | | <arg column="user_id" jdbcType="INTEGER" javaType="java.lang.Integer" /> |
| | | <arg column="nick_name" jdbcType="VARCHAR" javaType="java.lang.String" /> |
| | | <arg column="agent_id" jdbcType="INTEGER" javaType="java.lang.Integer" /> |
| | | <arg column="stock_name" jdbcType="VARCHAR" javaType="java.lang.String" /> |
| | | <arg column="stock_code" jdbcType="VARCHAR" javaType="java.lang.String" /> |
| | | <arg column="stock_gid" jdbcType="VARCHAR" javaType="java.lang.String" /> |
| | | <arg column="stock_spell" jdbcType="VARCHAR" javaType="java.lang.String" /> |
| | | <arg column="buy_order_id" jdbcType="VARCHAR" javaType="java.lang.String" /> |
| | | <arg column="buy_order_time" jdbcType="TIMESTAMP" javaType="java.util.Date" /> |
| | | <arg column="buy_order_price" jdbcType="DECIMAL" javaType="java.math.BigDecimal" /> |
| | | <arg column="sell_order_id" jdbcType="VARCHAR" javaType="java.lang.String" /> |
| | | <arg column="sell_order_time" jdbcType="TIMESTAMP" javaType="java.util.Date" /> |
| | | <arg column="sell_order_price" jdbcType="DECIMAL" javaType="java.math.BigDecimal" /> |
| | | <arg column="profit_target_price" jdbcType="DECIMAL" javaType="java.math.BigDecimal" /> |
| | | <arg column="stop_target_price" jdbcType="DECIMAL" javaType="java.math.BigDecimal" /> |
| | | <arg column="order_direction" jdbcType="VARCHAR" javaType="java.lang.String" /> |
| | | <arg column="order_num" jdbcType="INTEGER" javaType="java.lang.Integer" /> |
| | | <arg column="order_lever" jdbcType="INTEGER" javaType="java.lang.Integer" /> |
| | | <arg column="order_total_price" jdbcType="DECIMAL" javaType="java.math.BigDecimal" /> |
| | | <arg column="order_fee" jdbcType="DECIMAL" javaType="java.math.BigDecimal" /> |
| | | <arg column="order_spread" jdbcType="DECIMAL" javaType="java.math.BigDecimal" /> |
| | | <arg column="order_stay_fee" jdbcType="DECIMAL" javaType="java.math.BigDecimal" /> |
| | | <arg column="order_stay_days" jdbcType="INTEGER" javaType="java.lang.Integer" /> |
| | | <arg column="profit_and_lose" jdbcType="DECIMAL" javaType="java.math.BigDecimal" /> |
| | | <arg column="all_profit_and_lose" jdbcType="DECIMAL" javaType="java.math.BigDecimal" /> |
| | | |
| | | <arg column="is_lock" jdbcType="INTEGER" javaType="java.lang.Integer" /> |
| | | <arg column="lock_msg" jdbcType="VARCHAR" javaType="java.lang.String" /> |
| | | |
| | | <arg column="stock_plate" jdbcType="VARCHAR" javaType="java.lang.String" /> |
| | | <arg column="spread_rate_price" jdbcType="DECIMAL" javaType="java.math.BigDecimal" /> |
| | | <arg column="margin_add" jdbcType="DECIMAL" javaType="java.math.BigDecimal" /> |
| | | </constructor> |
| | | </resultMap> |
| | | <sql id="Base_Column_List" > |
| | | id, position_type, position_sn, user_id, nick_name, agent_id, stock_name, stock_code, |
| | | stock_gid, stock_spell, buy_order_id, buy_order_time, buy_order_price, sell_order_id, |
| | | sell_order_time, sell_order_price, profit_target_price, stop_target_price, order_direction, |
| | | order_num, order_lever, order_total_price, order_fee, order_spread, order_stay_fee, |
| | | order_stay_days, profit_and_lose, all_profit_and_lose,is_lock,lock_msg,stock_plate,spread_rate_price,margin_add |
| | | </sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" > |
| | | <select id="selectByPrimaryKey" resultType="com.nq.pojo.UserPosition" parameterType="java.lang.Integer" > |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | * |
| | | from user_position |
| | | where id = #{id,jdbcType=INTEGER} |
| | | </select> |
| | |
| | | delete from user_position |
| | | where id = #{id,jdbcType=INTEGER} |
| | | </delete> |
| | | <insert id="insert" useGeneratedKeys="true" keyColumn="id" keyProperty="id" parameterType="com.nq.pojo.UserPosition" > |
| | | insert into user_position (id, position_type, position_sn, |
| | | user_id, nick_name, agent_id, |
| | | stock_name, stock_code, stock_gid, |
| | | stock_spell, buy_order_id, buy_order_time, |
| | | buy_order_price, sell_order_id, sell_order_time, |
| | | sell_order_price, profit_target_price, stop_target_price, |
| | | order_direction, order_num, order_lever, |
| | | order_total_price, order_fee, order_spread, |
| | | order_stay_fee, order_stay_days, profit_and_lose, |
| | | all_profit_and_lose, is_lock, lock_msg,stock_plate,spread_rate_price) |
| | | values (#{id,jdbcType=INTEGER}, #{positionType,jdbcType=INTEGER}, #{positionSn,jdbcType=VARCHAR}, |
| | | #{userId,jdbcType=INTEGER}, #{nickName,jdbcType=VARCHAR}, #{agentId,jdbcType=INTEGER}, |
| | | #{stockName,jdbcType=VARCHAR}, #{stockCode,jdbcType=VARCHAR}, #{stockGid,jdbcType=VARCHAR}, |
| | | #{stockSpell,jdbcType=VARCHAR}, #{buyOrderId,jdbcType=VARCHAR}, #{buyOrderTime,jdbcType=TIMESTAMP}, |
| | | #{buyOrderPrice,jdbcType=DECIMAL}, #{sellOrderId,jdbcType=VARCHAR}, #{sellOrderTime,jdbcType=TIMESTAMP}, |
| | | #{sellOrderPrice,jdbcType=DECIMAL}, #{profitTargetPrice,jdbcType=DECIMAL}, #{stopTargetPrice,jdbcType=DECIMAL}, |
| | | #{orderDirection,jdbcType=VARCHAR}, #{orderNum,jdbcType=INTEGER}, #{orderLever,jdbcType=INTEGER}, |
| | | #{orderTotalPrice,jdbcType=DECIMAL}, #{orderFee,jdbcType=DECIMAL}, #{orderSpread,jdbcType=DECIMAL}, |
| | | #{orderStayFee,jdbcType=DECIMAL}, #{orderStayDays,jdbcType=INTEGER}, #{profitAndLose,jdbcType=DECIMAL}, |
| | | #{allProfitAndLose,jdbcType=DECIMAL}, #{isLock,jdbcType=INTEGER}, #{lockMsg,jdbcType=VARCHAR}, |
| | | #{stockPlate,jdbcType=VARCHAR},#{spreadRatePrice,jdbcType=DECIMAL} |
| | | ) |
| | | </insert> |
| | | |
| | | <insert id="insertSelective" parameterType="com.nq.pojo.UserPosition" > |
| | | insert into user_position |
| | | <trim prefix="(" suffix=")" suffixOverrides="," > |
| | |
| | | </update> |
| | | |
| | | |
| | | <select id="findPositionBySn" resultMap="BaseResultMap" parameterType="string"> |
| | | <select id="findPositionBySn" resultType="com.nq.pojo.UserPosition" parameterType="string"> |
| | | SELECT |
| | | <include refid="Base_Column_List"/> |
| | | * |
| | | FROM user_position |
| | | WHERE position_sn = #{positionSn} |
| | | </select> |
| | | |
| | | <select id="findMyPositionByCodeAndSpell" parameterType="map" resultMap="BaseResultMap"> |
| | | <select id="findMyPositionByCodeAndSpell" parameterType="map" resultType="com.nq.pojo.UserPosition"> |
| | | SELECT |
| | | <include refid="Base_Column_List"/> |
| | | * |
| | | FROM user_position |
| | | <where> |
| | | user_id = #{uid} |
| | |
| | | ORDER BY id DESC |
| | | </select> |
| | | |
| | | <select id="findPositionByUserIdAndSellIdIsNull" parameterType="integer" resultMap="BaseResultMap"> |
| | | <select id="findPositionByUserIdAndSellIdIsNull" parameterType="integer" resultType="com.nq.pojo.UserPosition"> |
| | | SELECT |
| | | <include refid="Base_Column_List"/> |
| | | * |
| | | FROM user_position |
| | | WHERE user_id = #{userId} and sell_order_id is null |
| | | order by id desc |
| | | </select> |
| | | |
| | | <select id="findPositionByUserIdAndSellId" parameterType="map" resultMap="BaseResultMap"> |
| | | <select id="findPositionByUserIdAndSellId" parameterType="map" resultType="com.nq.pojo.UserPosition"> |
| | | SELECT |
| | | <include refid="Base_Column_List"/> |
| | | * |
| | | FROM user_position |
| | | WHERE user_id = #{userId} and sell_order_id is null and stock_gid = #{stockType} |
| | | order by id desc |
| | | </select> |
| | | |
| | | |
| | | <select id="listByAgent" parameterType="map" resultMap="BaseResultMap"> |
| | | <select id="listByAgent" parameterType="map" resultType="com.nq.pojo.UserPosition"> |
| | | SELECT |
| | | <include refid="Base_Column_List"/> |
| | | * |
| | | FROM user_position |
| | | <where> |
| | | <if test="searchId != null "> |
| | | and agent_id = #{searchId} |
| | | 1=1 |
| | | <if test="ids != null and ids.size > 0"> |
| | | AND agent_id IN |
| | | <foreach item="id" collection="ids" open="(" separator="," close=")"> |
| | | #{id} |
| | | </foreach> |
| | | </if> |
| | | <if test="state != null "> |
| | | <if test="state == 0"> |
| | | and sell_order_id is null |
| | | </if> |
| | | <if test="state == 1"> |
| | | and sell_order_id is not null |
| | | </if> |
| | | <if test="state != null"> |
| | | <choose> |
| | | <when test="state == 0"> |
| | | AND sell_order_id IS NULL |
| | | </when> |
| | | <when test="state == 1"> |
| | | AND sell_order_id IS NOT NULL |
| | | </when> |
| | | </choose> |
| | | </if> |
| | | <if test="userId != null and userId != '' "> |
| | | and user_id = #{userId} |
| | | <if test="userId != null and userId != ''"> |
| | | AND user_id = #{userId} |
| | | </if> |
| | | <if test="positionSn != null and positionSn != '' "> |
| | | and position_sn like CONCAT('%','${positionSn}','%') |
| | | <if test="positionSn != null and positionSn != ''"> |
| | | AND position_sn LIKE CONCAT('%', #{positionSn}, '%') |
| | | </if> |
| | | <if test="positionType != null "> |
| | | and position_type = #{positionType} |
| | | <if test="positionType != null and positionType != ''"> |
| | | AND position_type = #{positionType} |
| | | </if> |
| | | <if test="beginTime != null "> |
| | | and sell_order_time <![CDATA[>=]]> #{beginTime} |
| | | <if test="beginTime != null and beginTime != ''"> |
| | | AND sell_order_time <![CDATA[>=]]> #{beginTime} |
| | | </if> |
| | | <if test="endTime != null "> |
| | | and sell_order_time <![CDATA[<=]]> #{endTime} |
| | | <if test="endTime != null and endTime != ''"> |
| | | AND sell_order_time <![CDATA[<=]]> #{endTime} |
| | | </if> |
| | | <if test="phone != null "> |
| | | and user_id = (select id from user where phone = #{phone}) |
| | | <if test="phone != null and phone != ''"> |
| | | AND user_id = (SELECT id FROM user WHERE phone = #{phone}) |
| | | </if> |
| | | |
| | | </where> |
| | | ORDER BY id DESC |
| | | </select> |
| | | |
| | | |
| | | |
| | | <select id="findAllStayPosition" resultMap="BaseResultMap"> |
| | | <select id="findAllStayPosition" resultType="com.nq.pojo.UserPosition"> |
| | | SELECT |
| | | <include refid="Base_Column_List"/> |
| | | * |
| | | FROM user_position |
| | | WHERE sell_order_id is NULL |
| | | </select> |
| | |
| | | </delete> |
| | | |
| | | |
| | | <select id="findPositionByStockCodeAndTimes" resultMap="BaseResultMap" parameterType="map"> |
| | | <select id="findPositionByStockCodeAndTimes" resultType="com.nq.pojo.UserPosition" parameterType="map"> |
| | | SELECT |
| | | <include refid="Base_Column_List"/> |
| | | * |
| | | FROM user_position |
| | | WHERE stock_code = #{stockCode} and user_id = #{userId} |
| | | and buy_order_time <![CDATA[>=]]> #{minuteTimes} |
| | |
| | | </select> |
| | | |
| | | <!--股票入仓最新top列表--> |
| | | <select id="findPositionTopList" parameterType="map" resultMap="BaseResultMap"> |
| | | <select id="findPositionTopList" parameterType="map" resultType="com.nq.pojo.UserPosition"> |
| | | SELECT |
| | | <include refid="Base_Column_List"/> |
| | | * |
| | | FROM user_position |
| | | <where> |
| | | 1=1 |
| | |
| | | </select> |
| | | |
| | | <!--根据股票代码查询用户最早入仓股票--> |
| | | <select id="findUserPositionByCode" parameterType="integer" resultMap="BaseResultMap"> |
| | | <select id="findUserPositionByCode" parameterType="integer" resultType="com.nq.pojo.UserPosition"> |
| | | SELECT |
| | | <include refid="Base_Column_List"/> |
| | | * |
| | | FROM user_position |
| | | <where> |
| | | user_id = #{userId} |
| | |
| | | ORDER BY id ASC |
| | | limit 1 |
| | | </select> |
| | | |
| | | |
| | | |
| | | </mapper> |