郑永安
2023-06-19 59e91a4e9ddaf23cebb12993c774aa899ab22d16
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
<?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.gk.firework.Mapper.ContractDetailInfoMapper" >
  <resultMap id="BaseResultMap" type="com.gk.firework.Domain.ContractDetailInfo" >
    <!--          -->
    <id column="id" property="id" jdbcType="BIGINT" />
    <result column="ordercode" property="ordercode" jdbcType="VARCHAR" />
    <result column="directioncode" property="directioncode" jdbcType="VARCHAR" />
    <result column="name" property="name" jdbcType="VARCHAR" />
    <result column="num" property="num" jdbcType="INTEGER" />
  </resultMap>
  <sql id="Base_Column_List" >
    <!--          -->
    id, ordercode, directioncode, name, num
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
    <!--          -->
    select
    <include refid="Base_Column_List" />
    from contractdetail
    where id = #{id,jdbcType=BIGINT}
  </select>
  <select id="selectByOrder" resultType="com.gk.firework.Domain.Vo.ProductVo">
    SELECT
    contractdetail.id,
    contractdetail.directioncode,
    contractdetail.num,
    contractdetail.price,
    contractdetail.changenum,
    product.`name`,
    product.purchaseprice,
    product.saleprice,
    product.specification,
    product.explosivecontent,
    product.type,
    product.`level`,
    product.productdate,
    product.boxnumber,
    product.packing,
    product.manufacturer
    FROM
     contractdetail
    LEFT JOIN product on product.directioncode = contractdetail.directioncode and product.isdel = 0
    where
     contractdetail.ordercode = #{ordercode}
  </select>
    <select id="selectAllDetailAtSpecificDate" resultType="com.gk.firework.Domain.ContractDetailInfo">
        select  detail.*
        from contractorder as co
        left join contractdetail as detail on detail.ordercode = co.ordercode
        where
        detail.directioncode = #{productCode}
        and DATE(co.producedate) = DATE(#{producedate})
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
    <!--          -->
    delete from contractdetail
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <delete id="deleteByOrder">
    delete from contractdetail
    where ordercode = #{ordercode}
  </delete>
  <update id="updateByPrimaryKeySelective" parameterType="com.gk.firework.Domain.ContractDetailInfo" >
    <!--          -->
    update contractdetail
    <set >
      <if test="ordercode != null" >
        ordercode = #{ordercode,jdbcType=VARCHAR},
      </if>
      <if test="directioncode != null" >
        directioncode = #{directioncode,jdbcType=VARCHAR},
      </if>
      <if test="name != null" >
        name = #{name,jdbcType=VARCHAR},
      </if>
      <if test="num != null" >
        num = #{num,jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.gk.firework.Domain.ContractDetailInfo" >
    <!--          -->
    update contractdetail
    set ordercode = #{ordercode,jdbcType=VARCHAR},
      directioncode = #{directioncode,jdbcType=VARCHAR},
      name = #{name,jdbcType=VARCHAR},
      num = #{num,jdbcType=INTEGER}
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateChangNum">
    update contractdetail
    set changenum = changenum + #{returnNum}
    where ordercode = #{ordercode}
    and directioncode = #{productCode}
 
  </update>
</mapper>