TCommodityManageMapper.xml 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.ruoyi.web.pcApi.mapper.TCommodityManageMapper">
  6. <resultMap type="TCommodityManage" id="TCommodityManageResult">
  7. <result property="id" column="id" />
  8. <result property="typeId" column="type_id" />
  9. <result property="typeSelected" column="type_selected" />
  10. <result property="commodityName" column="commodity_name" />
  11. <result property="departurePlace" column="departure_place" />
  12. <result property="adultPrice" column="adult_price" />
  13. <result property="childPrice" column="child_price" />
  14. <result property="stock" column="stock" />
  15. <result property="childPriceExplain" column="child_price_explain" />
  16. <result property="faceImg" column="face_img" />
  17. <result property="commodityImg" column="commodity_img" />
  18. <result property="isCoupon" column="is_coupon" />
  19. <result property="periodStart" column="period_start" />
  20. <result property="periodEnd" column="period_end" />
  21. <result property="periodWeek" column="period_week" />
  22. <result property="targetPeopleNum" column="target_people_num" />
  23. <result property="advancePeriod" column="advance_period" />
  24. <result property="attention" column="attention" />
  25. <result property="specification" column="specification" />
  26. <result property="saleNum" column="sale_num" />
  27. <result property="isRecommend" column="is_recommend" />
  28. <result property="isPreferred" column="is_preferred" />
  29. <result property="status" column="status" />
  30. <result property="deptId" column="dept_id" />
  31. <result property="delFlag" column="del_flag" />
  32. <result property="createBy" column="create_by" />
  33. <result property="createTime" column="create_time" />
  34. <result property="updateBy" column="update_by" />
  35. <result property="updateTime" column="update_time" />
  36. <result property="remark" column="remark" />
  37. <result property="typeName" column="type_name" />
  38. </resultMap>
  39. <resultMap id="TCommodityManageTCommodityJourneyInformationResult" type="TCommodityManage" extends="TCommodityManageResult">
  40. <collection property="commodityJourneyInformationList" notNullColumn="sub_id" javaType="java.util.List" resultMap="TCommodityJourneyInformationResult" />
  41. </resultMap>
  42. <resultMap type="TCommodityJourneyInformation" id="TCommodityJourneyInformationResult">
  43. <result property="id" column="sub_id" />
  44. <result property="commodityId" column="sub_commodity_id" />
  45. <result property="journeyTime" column="sub_journey_time" />
  46. <result property="detail" column="sub_detail" />
  47. <result property="createBy" column="sub_create_by" />
  48. <result property="createTime" column="sub_create_time" />
  49. <result property="updateBy" column="sub_update_by" />
  50. <result property="updateTime" column="sub_update_time" />
  51. <result property="remark" column="sub_remark" />
  52. </resultMap>
  53. <sql id="selectTCommodityManageVo">
  54. SELECT
  55. a.id,
  56. a.type_id,
  57. a.type_selected,
  58. a.commodity_name,
  59. a.departure_place,
  60. a.adult_price,
  61. a.child_price,
  62. a.stock,
  63. a.child_price_explain,
  64. a.face_img,
  65. a.commodity_img,
  66. a.is_coupon,
  67. a.period_start,
  68. a.period_end,
  69. a.period_week,
  70. a.target_people_num,
  71. a.advance_period,
  72. a.attention,
  73. a.specification,
  74. a.sale_num,
  75. a.is_recommend,
  76. a.is_preferred,
  77. a.STATUS,
  78. a.dept_id,
  79. a.del_flag,
  80. a.create_by,
  81. a.create_time,
  82. a.update_by,
  83. a.update_time,
  84. a.remark,
  85. b.type_name
  86. FROM
  87. t_commodity_manage a
  88. INNER JOIN sys_dept c on c.dept_id = a.dept_id
  89. <if test="liffId != null "> and c.liff_id = #{liffId}</if>
  90. LEFT JOIN t_commodity_type b on a.type_id = b.id
  91. </sql>
  92. <select id="selectTCommodityManageList" parameterType="TCommodityManage" resultMap="TCommodityManageResult">
  93. <include refid="selectTCommodityManageVo"/>
  94. where a.del_flag = '0'
  95. <if test="typeId != null "> and a.type_id = #{typeId}</if>
  96. <if test="typeSelected != null "> and a.type_selected = #{typeSelected}</if>
  97. <if test="commodityName != null and commodityName != ''"> and a.commodity_name like concat('%', #{commodityName}, '%')</if>
  98. <if test="departurePlace != null and departurePlace != ''"> and a.departure_place = #{departurePlace}</if>
  99. <if test="adultPrice != null "> and a.adult_price = #{adultPrice}</if>
  100. <if test="childPrice != null "> and a.child_price = #{childPrice}</if>
  101. <if test="stock != null "> and a.stock = #{stock}</if>
  102. <if test="childPriceExplain != null and childPriceExplain != ''"> and a.child_price_explain = #{childPriceExplain}</if>
  103. <if test="faceImg != null and faceImg != ''"> and a.face_img = #{faceImg}</if>
  104. <if test="commodityImg != null and commodityImg != ''"> and a.commodity_img = #{commodityImg}</if>
  105. <if test="isCoupon != null and isCoupon != ''"> and a.is_coupon = #{isCoupon}</if>
  106. <if test="periodStart != null and periodStart != ''"> and a.period_start = #{periodStart}</if>
  107. <if test="periodEnd != null and periodEnd != ''"> and a.period_end = #{periodEnd}</if>
  108. <if test="periodWeek != null and periodWeek != ''"> and a.period_week = #{periodWeek}</if>
  109. <if test="targetPeopleNum != null "> and a.target_people_num = #{targetPeopleNum}</if>
  110. <if test="advancePeriod != null "> and a.advance_period = #{advancePeriod}</if>
  111. <if test="attention != null and attention != ''"> and a.attention = #{attention}</if>
  112. <if test="specification != null and specification != ''"> and a.specification = #{specification}</if>
  113. <if test="saleNum != null "> and a.sale_num = #{saleNum}</if>
  114. <if test="isRecommend != null and isRecommend != ''"> and a.is_recommend = #{isRecommend}</if>
  115. <if test="isPreferred != null and isPreferred != ''"> and a.is_preferred = #{isPreferred}</if>
  116. <if test="status != null and status != ''"> and a.status = #{status}</if>
  117. <if test="deptId != null "> and a.dept_id = #{deptId}</if>
  118. <if test="params.beginDate != null and params.beginDate != ''"><!-- 开始时间检索 -->
  119. and date_format(a.period_start,'%y%m%d') &gt;= date_format(#{params.beginDate},'%y%m%d')
  120. </if>
  121. <if test="params.endDate != null and params.endDate != ''"><!-- 结束时间检索 -->
  122. and date_format(a.period_end,'%y%m%d') &lt;= date_format(#{params.endDate},'%y%m%d')
  123. </if>
  124. <!-- 数据范围过滤 -->
  125. ${params.dataScope}
  126. order by a.create_time desc
  127. </select>
  128. <select id="selectTCommodityManageList4H5" parameterType="TCommodityManage" resultMap="TCommodityManageResult">
  129. <include refid="selectTCommodityManageVo"/>
  130. where a.del_flag = '0' and date_format(now(),'%Y-%m-%d') &lt;= a.period_end
  131. <if test="typeId != null "> and a.type_selected like concat('%', #{typeId},'%')</if>
  132. <if test="commodityName != null and commodityName != ''"> and a.commodity_name like concat('%', #{commodityName}, '%')</if>
  133. <if test="departurePlace != null and departurePlace != ''"> and a.departure_place = #{departurePlace}</if>
  134. <if test="adultPrice != null "> and a.adult_price = #{adultPrice}</if>
  135. <if test="childPrice != null "> and a.child_price = #{childPrice}</if>
  136. <if test="stock != null "> and a.stock = #{stock}</if>
  137. <if test="childPriceExplain != null and childPriceExplain != ''"> and a.child_price_explain = #{childPriceExplain}</if>
  138. <if test="faceImg != null and faceImg != ''"> and a.face_img = #{faceImg}</if>
  139. <if test="commodityImg != null and commodityImg != ''"> and a.commodity_img = #{commodityImg}</if>
  140. <if test="isCoupon != null and isCoupon != ''"> and a.is_coupon = #{isCoupon}</if>
  141. <if test="periodStart != null and periodStart != ''"> and a.period_start = #{periodStart}</if>
  142. <if test="periodEnd != null and periodEnd != ''"> and a.period_end = #{periodEnd}</if>
  143. <if test="periodWeek != null and periodWeek != ''"> and a.period_week = #{periodWeek}</if>
  144. <if test="targetPeopleNum != null "> and a.target_people_num = #{targetPeopleNum}</if>
  145. <if test="advancePeriod != null "> and a.advance_period = #{advancePeriod}</if>
  146. <if test="attention != null and attention != ''"> and a.attention = #{attention}</if>
  147. <if test="specification != null and specification != ''"> and a.specification = #{specification}</if>
  148. <if test="saleNum != null "> and a.sale_num = #{saleNum}</if>
  149. <if test="isRecommend != null and isRecommend != ''"> and a.is_recommend = #{isRecommend}</if>
  150. <if test="isPreferred != null and isPreferred != ''"> and a.is_preferred = #{isPreferred}</if>
  151. <if test="status != null and status != ''"> and a.status = #{status}</if>
  152. <if test="deptId != null "> and a.dept_id = #{deptId}</if>
  153. <if test="params.beginDate != null and params.beginDate != ''"><!-- 开始时间检索 -->
  154. and date_format(a.create_time,'%y%m%d') &gt;= date_format(#{params.beginDate},'%y%m%d')
  155. </if>
  156. <if test="params.endDate != null and params.endDate != ''"><!-- 结束时间检索 -->
  157. and date_format(a.create_time,'%y%m%d') &lt;= date_format(#{params.endDate},'%y%m%d')
  158. </if>
  159. order by a.create_time desc
  160. </select>
  161. <select id="selectTCommodityManageById" parameterType="Long" resultMap="TCommodityManageTCommodityJourneyInformationResult">
  162. select a.id, a.type_id, a.type_selected, a.commodity_name, a.departure_place, a.adult_price, a.child_price, a.stock, a.child_price_explain, a.face_img, a.commodity_img, a.is_coupon, a.period_start, a.period_end, a.period_week, a.target_people_num, a.advance_period, a.attention, a.specification, a.sale_num, a.is_recommend, a.is_preferred, a.status, a.dept_id, a.del_flag, a.create_by, a.create_time, a.update_by, a.update_time, a.remark,
  163. b.id as sub_id, b.commodity_id as sub_commodity_id, b.journey_time as sub_journey_time, b.detail as sub_detail, b.create_by as sub_create_by, b.create_time as sub_create_time, b.update_by as sub_update_by, b.update_time as sub_update_time, b.remark as sub_remark
  164. from t_commodity_manage a
  165. left join t_commodity_journey_information b on b.commodity_id = a.id
  166. where a.id = #{id}
  167. </select>
  168. <insert id="insertTCommodityManage" parameterType="TCommodityManage" useGeneratedKeys="true" keyProperty="id">
  169. insert into t_commodity_manage
  170. <trim prefix="(" suffix=")" suffixOverrides=",">
  171. <if test="typeId != null">type_id,</if>
  172. <if test="typeSelected != null">type_selected,</if>
  173. <if test="commodityName != null and commodityName != ''">commodity_name,</if>
  174. <if test="departurePlace != null and departurePlace != ''">departure_place,</if>
  175. <if test="adultPrice != null">adult_price,</if>
  176. <if test="childPrice != null">child_price,</if>
  177. <if test="stock != null">stock,</if>
  178. <if test="childPriceExplain != null and childPriceExplain != ''">child_price_explain,</if>
  179. <if test="faceImg != null and faceImg != ''">face_img,</if>
  180. <if test="commodityImg != null and commodityImg != ''">commodity_img,</if>
  181. <if test="isCoupon != null and isCoupon != ''">is_coupon,</if>
  182. <if test="periodStart != null and periodStart != ''">period_start,</if>
  183. <if test="periodEnd != null and periodEnd != ''">period_end,</if>
  184. <if test="periodWeek != null and periodWeek != ''">period_week,</if>
  185. <if test="targetPeopleNum != null">target_people_num,</if>
  186. <if test="advancePeriod != null">advance_period,</if>
  187. <if test="attention != null and attention != ''">attention,</if>
  188. <if test="specification != null and specification != ''">specification,</if>
  189. <if test="saleNum != null">sale_num,</if>
  190. <if test="isRecommend != null">is_recommend,</if>
  191. <if test="isPreferred != null">is_preferred,</if>
  192. <if test="status != null">status,</if>
  193. <if test="deptId != null">dept_id,</if>
  194. <if test="delFlag != null">del_flag,</if>
  195. <if test="createBy != null">create_by,</if>
  196. <if test="createTime != null">create_time,</if>
  197. <if test="updateBy != null">update_by,</if>
  198. <if test="updateTime != null">update_time,</if>
  199. <if test="remark != null">remark,</if>
  200. </trim>
  201. <trim prefix="values (" suffix=")" suffixOverrides=",">
  202. <if test="typeId != null">#{typeId},</if>
  203. <if test="typeSelected != null">#{typeSelected},</if>
  204. <if test="commodityName != null and commodityName != ''">#{commodityName},</if>
  205. <if test="departurePlace != null and departurePlace != ''">#{departurePlace},</if>
  206. <if test="adultPrice != null">#{adultPrice},</if>
  207. <if test="childPrice != null">#{childPrice},</if>
  208. <if test="stock != null">#{stock},</if>
  209. <if test="childPriceExplain != null and childPriceExplain != ''">#{childPriceExplain},</if>
  210. <if test="faceImg != null and faceImg != ''">#{faceImg},</if>
  211. <if test="commodityImg != null and commodityImg != ''">#{commodityImg},</if>
  212. <if test="isCoupon != null and isCoupon != ''">#{isCoupon},</if>
  213. <if test="periodStart != null and periodStart != ''">#{periodStart},</if>
  214. <if test="periodEnd != null and periodEnd != ''">#{periodEnd},</if>
  215. <if test="periodWeek != null and periodWeek != ''">#{periodWeek},</if>
  216. <if test="targetPeopleNum != null">#{targetPeopleNum},</if>
  217. <if test="advancePeriod != null">#{advancePeriod},</if>
  218. <if test="attention != null and attention != ''">#{attention},</if>
  219. <if test="specification != null and specification != ''">#{specification},</if>
  220. <if test="saleNum != null">#{saleNum},</if>
  221. <if test="isRecommend != null">#{isRecommend},</if>
  222. <if test="isPreferred != null">#{isPreferred},</if>
  223. <if test="status != null">#{status},</if>
  224. <if test="deptId != null">#{deptId},</if>
  225. <if test="delFlag != null">#{delFlag},</if>
  226. <if test="createBy != null">#{createBy},</if>
  227. <if test="createTime != null">#{createTime},</if>
  228. <if test="updateBy != null">#{updateBy},</if>
  229. <if test="updateTime != null">#{updateTime},</if>
  230. <if test="remark != null">#{remark},</if>
  231. </trim>
  232. </insert>
  233. <update id="updateTCommodityManage" parameterType="TCommodityManage">
  234. update t_commodity_manage
  235. <trim prefix="SET" suffixOverrides=",">
  236. <if test="typeId != null">type_id = #{typeId},</if>
  237. <if test="typeSelected != null">type_selected = #{typeSelected},</if>
  238. <if test="commodityName != null and commodityName != ''">commodity_name = #{commodityName},</if>
  239. <if test="departurePlace != null and departurePlace != ''">departure_place = #{departurePlace},</if>
  240. <if test="adultPrice != null">adult_price = #{adultPrice},</if>
  241. <if test="childPrice != null">child_price = #{childPrice},</if>
  242. <if test="stock != null">stock = #{stock},</if>
  243. <if test="childPriceExplain != null and childPriceExplain != ''">child_price_explain = #{childPriceExplain},</if>
  244. <if test="faceImg != null and faceImg != ''">face_img = #{faceImg},</if>
  245. <if test="commodityImg != null and commodityImg != ''">commodity_img = #{commodityImg},</if>
  246. <if test="isCoupon != null and isCoupon != ''">is_coupon = #{isCoupon},</if>
  247. <if test="periodStart != null and periodStart != ''">period_start = #{periodStart},</if>
  248. <if test="periodEnd != null and periodEnd != ''">period_end = #{periodEnd},</if>
  249. <if test="periodWeek != null and periodWeek != ''">period_week = #{periodWeek},</if>
  250. <if test="targetPeopleNum != null">target_people_num = #{targetPeopleNum},</if>
  251. <if test="advancePeriod != null">advance_period = #{advancePeriod},</if>
  252. <if test="attention != null and attention != ''">attention = #{attention},</if>
  253. <if test="specification != null and specification != ''">specification = #{specification},</if>
  254. <if test="saleNum != null">sale_num = #{saleNum},</if>
  255. <if test="isRecommend != null">is_recommend = #{isRecommend},</if>
  256. <if test="isPreferred != null">is_preferred = #{isPreferred},</if>
  257. <if test="status != null">status = #{status},</if>
  258. <if test="deptId != null">dept_id = #{deptId},</if>
  259. <if test="delFlag != null">del_flag = #{delFlag},</if>
  260. <if test="createBy != null">create_by = #{createBy},</if>
  261. <if test="createTime != null">create_time = #{createTime},</if>
  262. <if test="updateBy != null">update_by = #{updateBy},</if>
  263. <if test="updateTime != null">update_time = #{updateTime},</if>
  264. <if test="remark != null">remark = #{remark},</if>
  265. </trim>
  266. where id = #{id}
  267. </update>
  268. <delete id="deleteTCommodityManageById" parameterType="Long">
  269. delete from t_commodity_manage where id = #{id}
  270. </delete>
  271. <delete id="deleteTCommodityManageByIds" parameterType="String">
  272. delete from t_commodity_manage where id in
  273. <foreach item="id" collection="array" open="(" separator="," close=")">
  274. #{id}
  275. </foreach>
  276. </delete>
  277. <delete id="deleteTCommodityJourneyInformationByCommodityIds" parameterType="String">
  278. delete from t_commodity_journey_information where commodity_id in
  279. <foreach item="commodityId" collection="array" open="(" separator="," close=")">
  280. #{commodityId}
  281. </foreach>
  282. </delete>
  283. <delete id="deleteTCommodityJourneyInformationByCommodityId" parameterType="Long">
  284. delete from t_commodity_journey_information where commodity_id = #{commodityId}
  285. </delete>
  286. <delete id="deleteTCommoditySchedulByCommodityId" parameterType="Long">
  287. delete from t_commodity_schedul where commodity_id = #{commodityId}
  288. </delete>
  289. <insert id="batchTCommodityJourneyInformation">
  290. insert into t_commodity_journey_information( id, commodity_id, journey_time, detail, create_by, create_time, update_by, update_time, remark) values
  291. <foreach item="item" index="index" collection="list" separator=",">
  292. ( #{item.id}, #{item.commodityId}, #{item.journeyTime}, #{item.detail}, #{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime}, #{item.remark})
  293. </foreach>
  294. </insert>
  295. <insert id="batchTCommoditySchedul">
  296. insert into t_commodity_schedul( commodity_id, departure_date, dept_id, create_by, create_time, update_by, update_time, remark,seat_num) values
  297. <foreach item="item" index="index" collection="list" separator=",">
  298. ( #{item.commodityId}, #{item.departureDate}, #{item.deptId}, #{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime}, #{item.remark}, #{item.seatNum})
  299. </foreach>
  300. </insert>
  301. <select id="selectSameTypeCommodityTop5" resultMap="TCommodityManageResult">
  302. <include refid="selectTCommodityManageVo"/>
  303. where a.status = '0'
  304. <if test="id != null"> and a.id != #{id}</if>
  305. <if test="typeId != null"> and a.type_id = #{typeId}</if>
  306. <if test="deptId != null"> and a.dept_id = #{deptId}</if>
  307. order by a.sale_num ASC
  308. limit 5
  309. </select>
  310. <select id="selectSalesTop10" parameterType="tCommodityManage" resultMap="TCommodityManageResult">
  311. <include refid="selectTCommodityManageVo"/>
  312. where a.del_flag = '0'
  313. <if test="typeId != null "> and a.type_id = #{typeId}</if>
  314. <if test="typeSelected != null "> and a.type_selected = #{typeSelected}</if>
  315. <if test="commodityName != null and commodityName != ''"> and a.commodity_name like concat('%', #{commodityName}, '%')</if>
  316. <if test="departurePlace != null and departurePlace != ''"> and a.departure_place = #{departurePlace}</if>
  317. <if test="adultPrice != null "> and a.adult_price = #{adultPrice}</if>
  318. <if test="childPrice != null "> and a.child_price = #{childPrice}</if>
  319. <if test="stock != null "> and a.stock = #{stock}</if>
  320. <if test="childPriceExplain != null and childPriceExplain != ''"> and a.child_price_explain = #{childPriceExplain}</if>
  321. <if test="faceImg != null and faceImg != ''"> and a.face_img = #{faceImg}</if>
  322. <if test="commodityImg != null and commodityImg != ''"> and a.commodity_img = #{commodityImg}</if>
  323. <if test="isCoupon != null and isCoupon != ''"> and a.is_coupon = #{isCoupon}</if>
  324. <if test="periodStart != null and periodStart != ''"> and a.period_start = #{periodStart}</if>
  325. <if test="periodEnd != null and periodEnd != ''"> and a.period_end = #{periodEnd}</if>
  326. <if test="periodWeek != null and periodWeek != ''"> and a.period_week = #{periodWeek}</if>
  327. <if test="targetPeopleNum != null "> and a.target_people_num = #{targetPeopleNum}</if>
  328. <if test="advancePeriod != null "> and a.advance_period = #{advancePeriod}</if>
  329. <if test="attention != null and attention != ''"> and a.attention = #{attention}</if>
  330. <if test="specification != null and specification != ''"> and a.specification = #{specification}</if>
  331. <if test="saleNum != null "> and a.sale_num = #{saleNum}</if>
  332. <if test="isRecommend != null and isRecommend != ''"> and a.is_recommend = #{isRecommend}</if>
  333. <if test="isPreferred != null and isPreferred != ''"> and a.is_preferred = #{isPreferred}</if>
  334. <if test="status != null and status != ''"> and a.status = #{status}</if>
  335. <if test="deptId != null "> and a.dept_id = #{deptId}</if>
  336. <if test="params.beginDate != null and params.beginDate != ''"><!-- 开始时间检索 -->
  337. and date_format(a.create_time,'%y%m%d') &gt;= date_format(#{params.beginDate},'%y%m%d')
  338. </if>
  339. <if test="params.endDate != null and params.endDate != ''"><!-- 结束时间检索 -->
  340. and date_format(a.create_time,'%y%m%d') &lt;= date_format(#{params.endDate},'%y%m%d')
  341. </if>
  342. order by a.sale_num DESC
  343. limit 10
  344. </select>
  345. </mapper>