MngChangeDao.xml 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.kmall.admin.dao.MngChangeDao">
  4. <resultMap type="com.kmall.admin.entity.MngChangeEntity" id="mngChangeMap">
  5. <result property="id" column="id"/>
  6. <result property="changeNum" column="change_num"/>
  7. <result property="originalNum" column="original_num"/>
  8. <result property="validNum" column="valid_num"/>
  9. <result property="merchSn" column="merch_sn"/>
  10. <result property="thirdPartyMerchCode" column="third_party_merch_code"/>
  11. <result property="goodsId" column="goods_id"/>
  12. <result property="isValid" column="is_valid"/>
  13. <result property="changeType" column="change_type"/>
  14. <result property="changeReason" column="change_reason"/>
  15. <result property="createrSn" column="creater_sn"/>
  16. <result property="createTime" column="create_time"/>
  17. <result property="moderSn" column="moder_sn"/>
  18. <result property="modTime" column="mod_time"/>
  19. <result property="tstm" column="tstm"/>
  20. </resultMap>
  21. <select id="queryObject" resultType="com.kmall.admin.entity.MngChangeEntity">
  22. select
  23. `id`,
  24. `change_num`,
  25. `original_num`,
  26. `valid_num`,
  27. `merch_sn`,
  28. `third_party_merch_code`,
  29. `goods_id`,
  30. `is_valid`,
  31. `change_type`,
  32. `change_reason`,
  33. `creater_sn`,
  34. `create_time`,
  35. `moder_sn`,
  36. `mod_time`,
  37. `tstm`
  38. from mall_mng_change
  39. where id = #{id}
  40. </select>
  41. <select id="queryObjectByGoodsIdAndType" resultType="com.kmall.admin.entity.MngChangeEntity">
  42. select
  43. `id`,
  44. `change_num`,
  45. `original_num`,
  46. `valid_num`,
  47. `merch_sn`,
  48. `third_party_merch_code`,
  49. `goods_id`,
  50. `is_valid`,
  51. `change_type`,
  52. `change_reason`,
  53. `creater_sn`,
  54. `create_time`,
  55. `moder_sn`,
  56. `mod_time`,
  57. `tstm`
  58. from mall_mng_change
  59. where goods_id = #{goodsId} and change_type = #{changeType}
  60. </select>
  61. <select id="queryList" resultType="com.kmall.admin.entity.MngChangeEntity">
  62. select
  63. c.`id`,
  64. c.`change_num`,
  65. c.`original_num`,
  66. c.`valid_num`,
  67. c.`merch_sn`,
  68. c.`third_party_merch_code`,
  69. c.`goods_id`,
  70. c.`is_valid`,
  71. c.`change_type`,
  72. c.`change_reason`,
  73. c.`creater_sn`,
  74. c.`create_time`,
  75. c.`moder_sn`,
  76. c.`mod_time`,
  77. c.`tstm`,
  78. g.name goodsName,
  79. m.merch_name merchName,
  80. mb.third_party_merch_name thirdPartyMerchName
  81. from mall_mng_change c left join mall_merch m on c.merch_sn = m.merch_sn
  82. left join third_merchant_biz mb on c.third_party_merch_code = mb.third_party_merch_code
  83. left join mall_goods g on c.goods_id = g.id
  84. WHERE 1=1
  85. <if test="goodsId != null and goodsId != ''">
  86. AND c.goods_id = #{goodsId}
  87. </if>
  88. <if test="storeId != null and storeId != ''">
  89. AND c.store_id = #{storeId}
  90. </if>
  91. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  92. AND g.third_party_merch_code = #{thirdPartyMerchCode}
  93. </if>
  94. <if test="changeType != null and changeType != ''">
  95. AND c.change_type = #{changeType}
  96. </if>
  97. <choose>
  98. <when test="sidx != null and sidx.trim() != ''">
  99. order by ${sidx} ${order}
  100. </when>
  101. <otherwise>
  102. order by id desc
  103. </otherwise>
  104. </choose>
  105. <if test="offset != null and limit != null">
  106. limit #{offset}, #{limit}
  107. </if>
  108. </select>
  109. <select id="queryTotal" resultType="int">
  110. select count(*) from mall_mng_change c left join mall_merch m on c.merch_sn = m.merch_sn
  111. left join third_merchant_biz mb on c.third_party_merch_code = mb.third_party_merch_code
  112. left join mall_goods g on c.goods_id = g.id
  113. WHERE 1=1
  114. <if test="goodsId != null and goodsId != ''">
  115. AND c.goods_id = #{goodsId}
  116. </if>
  117. <if test="storeId != null and storeId != ''">
  118. AND c.store_id = #{storeId}
  119. </if>
  120. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  121. AND g.third_party_merch_code = #{thirdPartyMerchCode}
  122. </if>
  123. <if test="changeType != null and changeType != ''">
  124. AND c.change_type = #{changeType}
  125. </if>
  126. </select>
  127. <insert id="save" parameterType="com.kmall.admin.entity.MngChangeEntity">
  128. insert into mall_mng_change(
  129. `change_num`,
  130. `original_num`,
  131. `valid_num`,
  132. `merch_sn`,
  133. `third_party_merch_code`,
  134. `goods_id`,
  135. `is_valid`,
  136. `change_type`,
  137. `change_reason`,
  138. `creater_sn`,
  139. `create_time`,
  140. `moder_sn`,
  141. `mod_time`,
  142. `tstm`)
  143. values(
  144. #{changeNum},
  145. #{originalNum},
  146. #{validNum},
  147. #{merchSn},
  148. #{thirdPartyMerchCode},
  149. #{goodsId},
  150. #{isValid},
  151. #{changeType},
  152. #{changeReason},
  153. #{createrSn},
  154. #{createTime},
  155. #{moderSn},
  156. #{modTime},
  157. #{tstm})
  158. </insert>
  159. <update id="update" parameterType="com.kmall.admin.entity.MngChangeEntity">
  160. update mall_mng_change
  161. <set>
  162. <if test="changeNum != null">`change_num` = #{changeNum}, </if>
  163. <if test="originalNum != null">`original_num` = #{originalNum}, </if>
  164. <if test="validNum != null">`valid_num` = #{validNum}, </if>
  165. <if test="merchSn != null">`merch_sn` = #{merchSn}, </if>
  166. <if test="thirdPartyMerchCode != null">`third_party_merch_code` = #{thirdPartyMerchCode}, </if>
  167. <if test="goodsId != null">`goods_id` = #{goodsId}, </if>
  168. <if test="isValid != null">`is_valid` = #{isValid}, </if>
  169. <if test="changeType != null">`change_type` = #{changeType}, </if>
  170. <if test="changeReason != null">`change_reason` = #{changeReason}, </if>
  171. <if test="createrSn != null">`creater_sn` = #{createrSn}, </if>
  172. <if test="createTime != null">`create_time` = #{createTime}, </if>
  173. <if test="moderSn != null">`moder_sn` = #{moderSn}, </if>
  174. <if test="modTime != null">`mod_time` = #{modTime}, </if>
  175. <if test="tstm != null">`tstm` = #{tstm}</if>
  176. </set>
  177. where id = #{id}
  178. </update>
  179. <delete id="delete">
  180. delete from mall_mng_change where id = #{value}
  181. </delete>
  182. <delete id="deleteBatch">
  183. delete from mall_mng_change where id in
  184. <foreach item="id" collection="array" open="(" separator="," close=")">
  185. #{id}
  186. </foreach>
  187. </delete>
  188. </mapper>