<?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.duowenlvshi.duowenlszp.model.Order.dao.OrderMapper" >
  <resultMap id="BaseResultMap" type="com.duowenlvshi.duowenlszp.model.Order.entity.Order" >
    <id column="id" property="id" jdbcType="VARCHAR" />
    <result column="meal_id" property="mealId" jdbcType="VARCHAR" />
    <result column="lawyer_id" property="lawyerId" jdbcType="VARCHAR" />
    <result column="orderState" property="orderstate" jdbcType="VARCHAR" />
    <result column="payState" property="paystate" jdbcType="VARCHAR" />
    <result column="city" property="city" jdbcType="VARCHAR" />
    <result column="mealName" property="mealname" jdbcType="VARCHAR" />
    <result column="postSize" property="postsize" jdbcType="INTEGER" />
    <result column="pushSize" property="pushsize" jdbcType="INTEGER" />
    <result column="candidateSize" property="candidatesize" jdbcType="INTEGER" />
    <result column="duration" property="duration" jdbcType="INTEGER" />
    <result column="endTime" property="endTime" jdbcType="TIMESTAMP" />
    <result column="price" property="price" jdbcType="DOUBLE" />
    <result column="payType" property="paytype" jdbcType="VARCHAR" />
    <result column="remake" property="remake" jdbcType="VARCHAR" />
    <result column="wxtradNo" property="wxtradNo" jdbcType="VARCHAR" />
    <result column="tradeNo" property="tradeNo" jdbcType="VARCHAR" />
    <result column="createDate" property="createdate" jdbcType="TIMESTAMP" />
    <result column="payDate" property="paydate" jdbcType="TIMESTAMP" />
    <result column="isValid" property="isValid" jdbcType="CHAR" />
    <result column="orderType" property="orderType" jdbcType="CHAR" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, meal_id, lawyer_id, orderState, payState, city, mealName, postSize, pushSize, 
    candidateSize,duration, endTime, price, payType, remake, wxtradNo,tradeNo,createDate, payDate,isValid,orderType
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
    select 
    <include refid="Base_Column_List" />
    from lszp_order
    where id = #{id,jdbcType=VARCHAR}
  </select>
  <insert id="insertSelective" parameterType="com.duowenlvshi.duowenlszp.model.Order.entity.Order" >
    insert into lszp_order
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="mealId != null" >
        meal_id,
      </if>
      <if test="lawyerId != null" >
        lawyer_id,
      </if>
      <if test="orderstate != null" >
        orderState,
      </if>
      <if test="paystate != null" >
        payState,
      </if>
      <if test="city != null" >
        city,
      </if>
      <if test="mealname != null" >
        mealName,
      </if>
      <if test="postsize != null" >
        postSize,
      </if>
      <if test="pushsize != null" >
        pushSize,
      </if>
      <if test="candidatesize != null" >
        candidateSize,
      </if>
      <if test="duration != null" >
        duration,
      </if>
      <if test="endTime != null" >
        endTime,
      </if>
      <if test="price != null" >
        price,
      </if>
      <if test="paytype != null" >
        payType,
      </if>
      <if test="remake != null" >
        remake,
      </if>
      <if test="createdate != null" >
        createDate,
      </if>
      <if test="paydate != null" >
        payDate,
      </if>
      <if test="isValid != null" >
        isValid,
      </if>
      <if test="orderType != null" >
        orderType,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=VARCHAR},
      </if>
      <if test="mealId != null" >
        #{mealId,jdbcType=VARCHAR},
      </if>
      <if test="lawyerId != null" >
        #{lawyerId,jdbcType=VARCHAR},
      </if>
      <if test="orderstate != null" >
        #{orderstate,jdbcType=VARCHAR},
      </if>
      <if test="paystate != null" >
        #{paystate,jdbcType=VARCHAR},
      </if>
      <if test="city != null" >
        #{city,jdbcType=VARCHAR},
      </if>
      <if test="mealname != null" >
        #{mealname,jdbcType=VARCHAR},
      </if>
      <if test="postsize != null" >
        #{postsize,jdbcType=INTEGER},
      </if>
      <if test="pushsize != null" >
        #{pushsize,jdbcType=INTEGER},
      </if>
      <if test="candidatesize != null" >
        #{candidatesize,jdbcType=INTEGER},
      </if>
      <if test="duration != null" >
        #{duration,jdbcType=INTEGER},
      </if>
      <if test="endTime != null" >
        #{endTime,jdbcType=TIMESTAMP},
      </if>
      <if test="price != null" >
        #{price,jdbcType=DOUBLE},
      </if>
      <if test="paytype != null" >
        #{paytype,jdbcType=VARCHAR},
      </if>
      <if test="remake != null" >
        #{remake,jdbcType=VARCHAR},
      </if>
      <if test="createdate != null" >
        #{createdate,jdbcType=TIMESTAMP},
      </if>
      <if test="paydate != null" >
        #{paydate,jdbcType=TIMESTAMP},
      </if>
      <if test="isValid != null" >
        #{isValid,jdbcType=CHAR},
      </if>
      <if test="orderType != null" >
        #{orderType,jdbcType=CHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.duowenlvshi.duowenlszp.model.Order.entity.Order" >
    update lszp_order
    <set >
      <if test="mealId != null" >
        meal_id = #{mealId,jdbcType=VARCHAR},
      </if>
      <if test="lawyerId != null" >
        lawyer_id = #{lawyerId,jdbcType=VARCHAR},
      </if>
      <if test="orderstate != null" >
        orderState = #{orderstate,jdbcType=VARCHAR},
      </if>
      <if test="paystate != null" >
        payState = #{paystate,jdbcType=VARCHAR},
      </if>
      <if test="city != null" >
        city = #{city,jdbcType=VARCHAR},
      </if>
      <if test="mealname != null" >
        mealName = #{mealname,jdbcType=VARCHAR},
      </if>
      <if test="postsize != null" >
        postSize = #{postsize,jdbcType=INTEGER},
      </if>
      <if test="pushsize != null" >
        pushSize = #{pushsize,jdbcType=INTEGER},
      </if>
      <if test="candidatesize != null" >
        candidateSize = #{candidatesize,jdbcType=INTEGER},
      </if>
      <if test="duration != null" >
        duration = #{duration,jdbcType=INTEGER},
      </if>
      <if test="endTime != null" >
        endTime = #{endTime,jdbcType=TIMESTAMP},
      </if>
      <if test="price != null" >
        price = #{price,jdbcType=DOUBLE},
      </if>
      <if test="paytype != null" >
        payType = #{paytype,jdbcType=VARCHAR},
      </if>
      <if test="remake != null" >
        remake = #{remake,jdbcType=VARCHAR},
      </if>
      <if test="wxtradNo != null" >
        wxtradNo = #{wxtradNo,jdbcType=VARCHAR},
      </if>
      <if test="tradeNo != null" >
        tradeNo = #{tradeNo,jdbcType=VARCHAR},
      </if>
      <if test="createdate != null" >
        createDate = #{createdate,jdbcType=TIMESTAMP},
      </if>
      <if test="paydate != null" >
        payDate = #{paydate,jdbcType=TIMESTAMP},
      </if>
      <if test="isValid != null" >
        isValid = #{isValid,jdbcType=CHAR},
      </if>
      <if test="orderType != null" >
        orderType = #{orderType,jdbcType=CHAR},
      </if>
    </set>
    where id = #{id,jdbcType=VARCHAR}
  </update>
  <!--查询用户购买套餐详情-->
  <select id="selectMeal" resultType="java.util.Map" parameterType="String">
    SELECT meal_id as mealId,endTime,(SELECT COUNT(*) FROM lszp_job WHERE lawyer_id=#{id} AND upperOrLower="upperOrLower1" AND isValid="1" ) jobNum,city,
    (SELECT COUNT(*) FROM lszp_push WHERE lawyer_idA=#{id} ) pushNum
    FROM lszp_order   WHERE lawyer_id=#{id} AND orderState="1" AND isValid="1" AND endTime>NOW()
  </select>

</mapper>