PosOrderMapper.xml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  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.system.mapper.PosOrderMapper">
  6. <resultMap type="PosOrder" id="PosOrderResult">
  7. <result property="id" column="id" />
  8. <result property="ddId" column="dd_id" />
  9. <result property="shId" column="sh_id" />
  10. <result property="mdId" column="md_id" />
  11. <result property="cretim" column="cretim" />
  12. <result property="shdzId" column="shdz_id" />
  13. <result property="userId" column="user_id" />
  14. <result property="amount" column="amount" />
  15. <result property="remarks" column="remarks" />
  16. <result property="food" column="food" />
  17. <result property="state" column="state" />
  18. <result property="type" column="type" />
  19. <result property="delryTime" column="delry_time" />
  20. <result property="yhId" column="yh_id" />
  21. <result property="jvli" column="jvli" />
  22. <result property="freight" column="freight" />
  23. <result property="diningStatus" column="dining_status" />
  24. <result property="qsId" column="qs_id" />
  25. <result property="payUrl" column="pay_url" />
  26. <result property="collectPayment" column="collect_payment" />
  27. <result property="activity" column="activity" />
  28. <result property="kefuState" column="kefu_state" />
  29. <result property="kefuContent" column="kefu_content" />
  30. <result property="kefuRepeat" column="kefu_repeat" />
  31. <result property="repeatDdId" column="repeat_dd_id" />
  32. <result property="shAddress" column="sh_address" />
  33. <result property="mdActivity" column="md_activity" />
  34. <result property="yhName" column="yh_name" />
  35. <result property="mdYhId" column="md_yh_id" />
  36. <result property="mdYhName" column="md_yh_name" />
  37. <result property="mdDiscountAmount" column="md_discount_amount" />
  38. <result property="salesName" column="sales_name" />
  39. <result property="mdSalesName" column="md_sales_name" />
  40. <result property="salesReduction" column="sales_reduction" />
  41. <result property="mdSalesReduction" column="md_sales_reduction" />
  42. <result property="points" column="points" />
  43. <result property="pointsReduction" column="points_reduction" />
  44. <result property="sdTime" column="sd_time" />
  45. <result property="payType" column="pay_type" />
  46. <result property="parentDdId" column="parent_dd_id" />
  47. </resultMap>
  48. <sql id="selectPosOrderVo">
  49. select id, dd_id, sh_id, md_id, cretim, shdz_id, user_id,sh_address, amount, remarks, state, type, delry_time,food,yh_id,yh_name,md_yh_id,md_yh_name,md_discount_amount,jvli,freight,dining_status,qs_id,pay_url,collect_payment,activity,md_activity,kefu_state,kefu_content,kefu_repeat,repeat_dd_id,sales_name,md_sales_name,sales_reduction,md_sales_reduction,points,points_reduction,sd_time,pay_type,parent_dd_id from pos_order
  50. </sql>
  51. <select id="selectPosOrderList" parameterType="PosOrder" resultMap="PosOrderResult">
  52. <include refid="selectPosOrderVo"/>
  53. <where>
  54. <if test="ddId != null "> and dd_id = #{ddId}</if>
  55. <if test="shId != null "> and sh_id = #{shId}</if>
  56. <if test="mdId != null "> and md_id = #{mdId}</if>
  57. <if test="cretim != null "> and cretim = #{cretim}</if>
  58. <if test="shdzId != null "> and shdz_id = #{shdzId}</if>
  59. <if test="userId != null "> and user_id = #{userId}</if>
  60. <if test="amount != null "> and amount = #{amount}</if>
  61. <if test="state != null "> and state = #{state}</if>
  62. <if test="type != null "> and type = #{type}</if>
  63. <if test="delryTime != null and delryTime != ''"> and delry_time = #{delryTime}</if>
  64. <if test="cretimStart != null and cretimStart != ''"> and cretim > date_format(#{cretimStart},'%y-%m-%d')</if>
  65. <if test="cretimEnd != null and cretimEnd != ''"> and cretim &lt; DATE_FORMAT(DATE_ADD(date_format(#{cretimEnd},'%y-%m-%d'),INTERVAL 1 DAY),'%Y-%m-%d')</if>
  66. <if test="collectPayment != null and collectPayment != ''"> and collect_payment = #{collectPayment}</if>
  67. <if test="mdActivity != null"> and md_activity = #{mdActivity}</if>
  68. <if test="yhName != null and yhName != ''"> and yh_name = #{yhName}</if>
  69. <if test="mdYhId != null"> and md_yh_id = #{mdYhId}</if>
  70. <if test="mdYhName != null and mdYhName != ''"> and md_yh_name = #{mdYhName}</if>
  71. <if test="mdDiscountAmount != null"> and md_discount_amount = #{mdDiscountAmount}</if>
  72. <if test="salesName != null and salesName != ''"> and sales_name = #{salesName}</if>
  73. <if test="mdSalesName != null and mdSalesName != ''"> and md_sales_name = #{mdSalesName}</if>
  74. <if test="salesReduction != null"> and sales_reduction = #{salesReduction}</if>
  75. <if test="mdSalesReduction != null"> and md_sales_reduction = #{mdSalesReduction}</if>
  76. <if test="points != null"> and points = #{points}</if>
  77. <if test="pointsReduction != null"> and points_reduction = #{pointsReduction}</if>
  78. <if test="sdTime != null"> and sd_time = #{sdTime}</if>
  79. <if test="payType != null"> and pay_type =#{payType}</if>
  80. <if test="parentDdId != null and parentDdId != ''"> and parent_dd_id = #{parentDdId}</if>
  81. and not (state=0 and collect_payment=0)
  82. </where>
  83. order by id desc
  84. </select>
  85. <select id="selectPosOrderShList" parameterType="PosOrder" resultMap="PosOrderResult">
  86. <include refid="selectPosOrderVo"/>
  87. <where>
  88. <if test="ddId != null "> and dd_id = #{ddId}</if>
  89. <if test="shId != null "> and sh_id = #{shId}</if>
  90. <if test="mdId != null "> and md_id = #{mdId}</if>
  91. <if test="cretim != null "> and cretim = #{cretim}</if>
  92. <if test="shdzId != null "> and shdz_id = #{shdzId}</if>
  93. <if test="userId != null "> and user_id = #{userId}</if>
  94. <if test="amount != null "> and amount = #{amount}</if>
  95. <if test="state != null "> and state > #{state} and state &lt; 10</if>
  96. <if test="type != null "> and type = #{type}</if>
  97. <if test="delryTime != null and delryTime != ''"> and delry_time = #{delryTime}</if>
  98. <if test="cretimStart != null and cretimStart != ''"> and cretim > date_format(#{cretimStart},'%y-%m-%d')</if>
  99. <if test="cretimEnd != null and cretimEnd != ''"> and cretim &lt; DATE_FORMAT(DATE_ADD(date_format(#{cretimEnd},'%y-%m-%d'),INTERVAL 1 DAY),'%Y-%m-%d')</if>
  100. <if test="collectPayment != null and collectPayment != ''"> and collect_payment = #{collectPayment}</if>
  101. <if test="mdActivity != null"> and md_activity = #{mdActivity}</if>
  102. <if test="yhName != null and yhName != ''"> and yh_name = #{yhName}</if>
  103. <if test="mdYhId != null"> and md_yh_id = #{mdYhId}</if>
  104. <if test="mdYhName != null and mdYhName != ''"> and md_yh_name = #{mdYhName}</if>
  105. <if test="mdDiscountAmount != null"> and md_discount_amount = #{mdDiscountAmount}</if>
  106. <if test="salesName != null and salesName != ''"> and sales_name = #{salesName}</if>
  107. <if test="mdSalesName != null and mdSalesName != ''"> and md_sales_name = #{mdSalesName}</if>
  108. <if test="salesReduction != null"> and sales_reduction = #{salesReduction}</if>
  109. <if test="mdSalesReduction != null"> and md_sales_reduction = #{mdSalesReduction}</if>
  110. <if test="points != null"> and points = #{points}</if>
  111. <if test="pointsReduction != null"> and points_reduction = #{pointsReduction}</if>
  112. <if test="sdTime != null"> and sd_time =#{sdTime}</if>
  113. <if test="payType != null"> and pay_type =#{payType}</if>
  114. <if test="parentDdId != null and parentDdId != ''"> and parent_dd_id = #{parentDdId}</if>
  115. </where>
  116. order by kefu_state desc,cretim desc
  117. </select>
  118. <select id="selectPosOrderById" parameterType="Long" resultMap="PosOrderResult">
  119. <include refid="selectPosOrderVo"/>
  120. where id = #{id}
  121. </select>
  122. <insert id="insertPosOrder" parameterType="PosOrder" useGeneratedKeys="true" keyProperty="id">
  123. insert into pos_order
  124. <trim prefix="(" suffix=")" suffixOverrides=",">
  125. <if test="ddId != null">dd_id,</if>
  126. <if test="shId != null">sh_id,</if>
  127. <if test="mdId != null">md_id,</if>
  128. <if test="cretim != null">cretim,</if>
  129. <if test="shdzId != null">shdz_id,</if>
  130. <if test="userId != null">user_id,</if>
  131. <if test="amount != null">amount,</if>
  132. <if test="remarks != null">remarks,</if>
  133. <if test="state != null">state,</if>
  134. <if test="type != null">type,</if>
  135. <if test="delryTime != null and delryTime != ''">delry_time,</if>
  136. <if test="collectPayment != null and collectPayment != ''">collect_payment,</if>
  137. <if test="mdActivity != null">md_activity,</if>
  138. <if test="yhName != null and yhName != ''">yh_name,</if>
  139. <if test="mdYhId != null">md_yh_id,</if>
  140. <if test="mdYhName != null and mdYhName != ''">md_yh_name,</if>
  141. <if test="mdDiscountAmount != null">md_discount_amount,</if>
  142. <if test="salesName != null and salesName != ''">sales_name,</if>
  143. <if test="mdSalesName != null and mdSalesName != ''">md_sales_name,</if>
  144. <if test="salesReduction != null">sales_reduction,</if>
  145. <if test="mdSalesReduction != null">md_sales_reduction,</if>
  146. <if test="points != null">points,</if>
  147. <if test="pointsReduction != null">points_reduction,</if>
  148. <if test="sdTime != null">sd_time,</if>
  149. <if test="payType != null">pay_type,</if>
  150. <if test="parentDdId != null and parentDdId != ''">parent_dd_id,</if>
  151. </trim>
  152. <trim prefix="values (" suffix=")" suffixOverrides=",">
  153. <if test="ddId != null">#{ddId},</if>
  154. <if test="shId != null">#{shId},</if>
  155. <if test="mdId != null">#{mdId},</if>
  156. <if test="cretim != null">#{cretim},</if>
  157. <if test="shdzId != null">#{shdzId},</if>
  158. <if test="userId != null">#{userId},</if>
  159. <if test="amount != null">#{amount},</if>
  160. <if test="remarks != null">#{remarks},</if>
  161. <if test="state != null">#{state},</if>
  162. <if test="type != null">#{type},</if>
  163. <if test="delryTime != null and delryTime != ''">#{delryTime},</if>
  164. <if test="collectPayment != null and collectPayment != ''">#{collectPayment},</if>
  165. <if test="mdActivity != null">#{mdActivity},</if>
  166. <if test="yhName != null and yhName != ''">#{yhName},</if>
  167. <if test="mdYhId != null">#{mdYhId},</if>
  168. <if test="mdYhName != null and mdYhName != ''">#{mdYhName},</if>
  169. <if test="mdDiscountAmount != null">#{mdDiscountAmount},</if>
  170. <if test="salesName != null and salesName != ''">#{salesName},</if>
  171. <if test="mdSalesName != null and mdSalesName != ''">#{mdSalesName},</if>
  172. <if test="salesReduction != null">#{salesReduction},</if>
  173. <if test="mdSalesReduction != null">#{mdSalesReduction},</if>
  174. <if test="points != null">#{points},</if>
  175. <if test="pointsReduction != null">#{pointsReduction},</if>
  176. <if test="sdTime != null">#{sdTime},</if>
  177. <if test="payType != null">#{payType},</if>
  178. <if test="parentDdId != null and parentDdId != ''">#{parentDdId},</if>
  179. </trim>
  180. </insert>
  181. <update id="updatePosOrder" parameterType="PosOrder">
  182. update pos_order
  183. <trim prefix="SET" suffixOverrides=",">
  184. <if test="ddId != null">dd_id = #{ddId},</if>
  185. <if test="shId != null">sh_id = #{shId},</if>
  186. <if test="mdId != null">md_id = #{mdId},</if>
  187. <if test="cretim != null">cretim = #{cretim},</if>
  188. <if test="shdzId != null">shdz_id = #{shdzId},</if>
  189. <if test="userId != null">user_id = #{userId},</if>
  190. <if test="amount != null">amount = #{amount},</if>
  191. <if test="remarks != null">remarks = #{remarks},</if>
  192. <if test="state != null">state = #{state},</if>
  193. <if test="type != null">type = #{type},</if>
  194. <if test="kefuState != null">kefu_state = #{kefuState},</if>
  195. <if test="kefuContent != null">kefu_content = #{kefuContent},</if>
  196. <if test="delryTime != null and delryTime != ''">delry_time = #{delryTime},</if>
  197. <if test="collectPayment != null and collectPayment != ''">collect_payment = #{collectPayment},</if>
  198. <if test="mdActivity != null">md_activity = #{mdActivity},</if>
  199. <if test="yhName != null and yhName != ''">yh_name = #{yhName},</if>
  200. <if test="mdYhId != null">md_yh_id = #{mdYhId},</if>
  201. <if test="mdYhName != null and mdYhName != ''">md_yh_name = #{mdYhName},</if>
  202. <if test="mdDiscountAmount != null">md_discount_amount = #{mdDiscountAmount},</if>
  203. <if test="salesName != null and salesName != ''">sales_name = #{salesName},</if>
  204. <if test="mdSalesName != null and mdSalesName != ''">md_sales_name = #{mdSalesName},</if>
  205. <if test="salesReduction != null">sales_reduction = #{salesReduction},</if>
  206. <if test="mdSalesReduction != null">md_sales_reduction = #{mdSalesReduction},</if>
  207. <if test="points != null">points = #{points},</if>
  208. <if test="pointsReduction != null">points_reduction = #{pointsReduction},</if>
  209. <if test="sdTime != null">sd_time = #{sdTime},</if>
  210. <if test="payType != null">pay_type = #{payType},</if>
  211. <if test="parentDdId != null and parentDdId != ''">parent_dd_id = #{parentDdId},</if>
  212. </trim>
  213. where id = #{id}
  214. </update>
  215. <delete id="deletePosOrderById" parameterType="Long">
  216. delete from pos_order where id = #{id}
  217. </delete>
  218. <delete id="deletePosOrderByIds" parameterType="String">
  219. delete from pos_order where id in
  220. <foreach item="id" collection="array" open="(" separator="," close=")">
  221. #{id}
  222. </foreach>
  223. </delete>
  224. <select id="countOrderByNowYear" resultType="int">
  225. SELECT COUNT(*)
  226. FROM pos_order
  227. <where>
  228. <if test="nowYearFirstDay != null">
  229. cretim &gt;= #{nowYearFirstDay}
  230. </if>
  231. </where>
  232. </select>
  233. <select id="countOrderSuccessByNowYear" resultType="int">
  234. SELECT COUNT(*)
  235. FROM pos_order
  236. <where>
  237. <if test="nowYearFirstDay != null">
  238. cretim &gt;= #{nowYearFirstDay}
  239. </if>
  240. AND state in (5, 11)
  241. </where>
  242. </select>
  243. <select id="countOrderFailByNowYear" resultType="int">
  244. SELECT COUNT(*)
  245. FROM pos_order
  246. <where>
  247. <if test="nowYearFirstDay != null">
  248. cretim &gt;= #{nowYearFirstDay}
  249. </if>
  250. AND state = 10
  251. </where>
  252. </select>
  253. <select id="totalTurnoverByNowYear" resultType="Double">
  254. SELECT sum(amount)
  255. FROM pos_order
  256. <where>
  257. <if test="nowYearFirstDay != null">
  258. cretim &gt;= #{nowYearFirstDay}
  259. </if>
  260. AND state in (5, 11)
  261. </where>
  262. </select>
  263. <select id="getOrderCountByDate" resultType="int">
  264. SELECT IFNULL(COUNT(*),0) as amount FROM pos_order
  265. <where>
  266. <if test="startDate != null and startDate != '' and endDate != null and endDate != ''">
  267. and cretim between #{startDate} and #{endDate}
  268. </if>
  269. <if test="startDate != null and startDate != '' and (endDate == null or endDate == '')">
  270. and cretim >= #{startDate}
  271. </if>
  272. <if test="(startDate == null or startDate == '') and (endDate != null and endDate != '')">
  273. and cretim &lt;= #{endDate}
  274. </if>
  275. </where>
  276. </select>
  277. <select id="getOrderSumByDate" resultType="int">
  278. SELECT IFNULL(SUM(amount),0) as amount FROM pos_order
  279. <where>
  280. <if test="startDate != null and startDate != '' and endDate != null and endDate != ''">
  281. and cretim between #{startDate} and #{endDate}
  282. </if>
  283. <if test="startDate != null and startDate != '' and (endDate == null or endDate == '')">
  284. and cretim >= #{startDate}
  285. </if>
  286. <if test="(startDate == null or startDate == '') and (endDate != null and endDate != '')">
  287. and cretim &lt;= #{endDate}
  288. </if>
  289. </where>
  290. </select>
  291. </mapper>