PosOrderMapper.xml 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  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. <result property="orderCategory" column="order_category" />
  48. <result property="tableId" column="table_id" />
  49. <result property="tableNo" column="table_no" />
  50. <result property="logo" column="logo" />
  51. <result property="posName" column="pos_name" />
  52. <result property="foodAmount" column="food_amount" />
  53. <result property="pickUpNum" column="pick_up_num" />
  54. <result property="pickUpTime" column="pick_up_time" />
  55. <result property="reservePhone" column="reserve_phone" />
  56. <result property="isAccepted" column="is_accepted" />
  57. <result property="isDisplay" column="is_display" />
  58. <result property="displayTime" column="display_time" />
  59. <result property="deliveryStatus" column="delivery_status" />
  60. <result property="payStatus" column="pay_status" />
  61. <result property="afterSaleStatus" column="after_sale_status" />
  62. </resultMap>
  63. <sql id="selectPosOrderVo">
  64. 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,order_category,table_id,table_no,logo,pos_name,food_amount,pick_up_num,pick_up_time,reserve_phone,is_accepted,is_display,display_time,delivery_status,pay_status,after_sale_status from pos_order
  65. </sql>
  66. <select id="selectPosOrderList" parameterType="PosOrder" resultMap="PosOrderResult">
  67. <include refid="selectPosOrderVo"/>
  68. <where>
  69. <if test="ddId != null "> and dd_id = #{ddId}</if>
  70. <if test="shId != null "> and sh_id = #{shId}</if>
  71. <if test="mdId != null "> and md_id = #{mdId}</if>
  72. <if test="cretim != null "> and cretim = #{cretim}</if>
  73. <if test="shdzId != null "> and shdz_id = #{shdzId}</if>
  74. <if test="userId != null "> and user_id = #{userId}</if>
  75. <if test="amount != null "> and amount = #{amount}</if>
  76. <if test="state != null "> and state = #{state}</if>
  77. <if test="type != null "> and type = #{type}</if>
  78. <if test="delryTime != null and delryTime != ''"> and delry_time = #{delryTime}</if>
  79. <if test="cretimStart != null and cretimStart != ''"> and cretim > date_format(#{cretimStart},'%y-%m-%d')</if>
  80. <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>
  81. <if test="collectPayment != null and collectPayment != ''"> and collect_payment = #{collectPayment}</if>
  82. <if test="mdActivity != null"> and md_activity = #{mdActivity}</if>
  83. <if test="yhName != null and yhName != ''"> and yh_name = #{yhName}</if>
  84. <if test="mdYhId != null"> and md_yh_id = #{mdYhId}</if>
  85. <if test="mdYhName != null and mdYhName != ''"> and md_yh_name = #{mdYhName}</if>
  86. <if test="mdDiscountAmount != null"> and md_discount_amount = #{mdDiscountAmount}</if>
  87. <if test="salesName != null and salesName != ''"> and sales_name = #{salesName}</if>
  88. <if test="mdSalesName != null and mdSalesName != ''"> and md_sales_name = #{mdSalesName}</if>
  89. <if test="salesReduction != null"> and sales_reduction = #{salesReduction}</if>
  90. <if test="mdSalesReduction != null"> and md_sales_reduction = #{mdSalesReduction}</if>
  91. <if test="points != null"> and points = #{points}</if>
  92. <if test="pointsReduction != null"> and points_reduction = #{pointsReduction}</if>
  93. <if test="sdTime != null"> and sd_time = #{sdTime}</if>
  94. <if test="payType != null"> and pay_type =#{payType}</if>
  95. <if test="parentDdId != null and parentDdId != ''"> and parent_dd_id = #{parentDdId}</if>
  96. <if test="orderCategory != null and orderCategory != ''"> and order_category = #{orderCategory}</if>
  97. <if test="tableId != null"> and table_id = #{tableId}</if>
  98. <if test="logo != null and logo != ''"> and logo = #{logo}</if>
  99. <if test="posName != null and posName != ''"> and pos_name = #{posName}</if>
  100. <if test="payStatus != null"> and pay_status = #{payStatus}</if>
  101. <if test="deliveryStatus != null"> and delivery_status = #{deliveryStatus}</if>
  102. <if test="afterSaleStatus != null"> and after_sale_status = #{afterSaleStatus}</if>
  103. </where>
  104. order by id desc
  105. </select>
  106. <select id="selectPosOrderShList" parameterType="PosOrder" resultMap="PosOrderResult">
  107. <include refid="selectPosOrderVo"/>
  108. <where>
  109. <if test="ddId != null "> and dd_id = #{ddId}</if>
  110. <if test="shId != null "> and sh_id = #{shId}</if>
  111. <if test="mdId != null "> and md_id = #{mdId}</if>
  112. <if test="cretim != null "> and cretim = #{cretim}</if>
  113. <if test="shdzId != null "> and shdz_id = #{shdzId}</if>
  114. <if test="userId != null "> and user_id = #{userId}</if>
  115. <if test="amount != null "> and amount = #{amount}</if>
  116. <if test="state != null "> and state > #{state} and state &lt; 10</if>
  117. <if test="type != null "> and type = #{type}</if>
  118. <if test="delryTime != null and delryTime != ''"> and delry_time = #{delryTime}</if>
  119. <if test="cretimStart != null and cretimStart != ''"> and cretim > date_format(#{cretimStart},'%y-%m-%d')</if>
  120. <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>
  121. <if test="collectPayment != null and collectPayment != ''"> and collect_payment = #{collectPayment}</if>
  122. <if test="mdActivity != null"> and md_activity = #{mdActivity}</if>
  123. <if test="yhName != null and yhName != ''"> and yh_name = #{yhName}</if>
  124. <if test="mdYhId != null"> and md_yh_id = #{mdYhId}</if>
  125. <if test="mdYhName != null and mdYhName != ''"> and md_yh_name = #{mdYhName}</if>
  126. <if test="mdDiscountAmount != null"> and md_discount_amount = #{mdDiscountAmount}</if>
  127. <if test="salesName != null and salesName != ''"> and sales_name = #{salesName}</if>
  128. <if test="mdSalesName != null and mdSalesName != ''"> and md_sales_name = #{mdSalesName}</if>
  129. <if test="salesReduction != null"> and sales_reduction = #{salesReduction}</if>
  130. <if test="mdSalesReduction != null"> and md_sales_reduction = #{mdSalesReduction}</if>
  131. <if test="points != null"> and points = #{points}</if>
  132. <if test="pointsReduction != null"> and points_reduction = #{pointsReduction}</if>
  133. <if test="sdTime != null"> and sd_time =#{sdTime}</if>
  134. <if test="payType != null"> and pay_type =#{payType}</if>
  135. <if test="parentDdId != null and parentDdId != ''"> and parent_dd_id = #{parentDdId}</if>
  136. <if test="orderCategory != null and orderCategory != ''"> and order_category = #{orderCategory}</if>
  137. <if test="tableId != null"> and table_id = #{tableId}</if>
  138. <if test="logo != null and logo != ''"> and logo = #{logo}</if>
  139. <if test="posName != null and posName != ''"> and pos_name = #{posName}</if>
  140. </where>
  141. order by kefu_state desc,cretim desc
  142. </select>
  143. <select id="selectPosOrderById" parameterType="Long" resultMap="PosOrderResult">
  144. <include refid="selectPosOrderVo"/>
  145. where id = #{id}
  146. </select>
  147. <insert id="insertPosOrder" parameterType="PosOrder" useGeneratedKeys="true" keyProperty="id">
  148. insert into pos_order
  149. <trim prefix="(" suffix=")" suffixOverrides=",">
  150. <if test="ddId != null">dd_id,</if>
  151. <if test="shId != null">sh_id,</if>
  152. <if test="mdId != null">md_id,</if>
  153. <if test="cretim != null">cretim,</if>
  154. <if test="shdzId != null">shdz_id,</if>
  155. <if test="userId != null">user_id,</if>
  156. <if test="amount != null">amount,</if>
  157. <if test="remarks != null">remarks,</if>
  158. <if test="state != null">state,</if>
  159. <if test="type != null">type,</if>
  160. <if test="delryTime != null and delryTime != ''">delry_time,</if>
  161. <if test="collectPayment != null and collectPayment != ''">collect_payment,</if>
  162. <if test="mdActivity != null">md_activity,</if>
  163. <if test="yhName != null and yhName != ''">yh_name,</if>
  164. <if test="mdYhId != null">md_yh_id,</if>
  165. <if test="mdYhName != null and mdYhName != ''">md_yh_name,</if>
  166. <if test="mdDiscountAmount != null">md_discount_amount,</if>
  167. <if test="salesName != null and salesName != ''">sales_name,</if>
  168. <if test="mdSalesName != null and mdSalesName != ''">md_sales_name,</if>
  169. <if test="salesReduction != null">sales_reduction,</if>
  170. <if test="mdSalesReduction != null">md_sales_reduction,</if>
  171. <if test="points != null">points,</if>
  172. <if test="pointsReduction != null">points_reduction,</if>
  173. <if test="sdTime != null">sd_time,</if>
  174. <if test="payType != null">pay_type,</if>
  175. <if test="parentDdId != null and parentDdId != ''">parent_dd_id,</if>
  176. <if test="orderCategory != null and orderCategory != ''">order_category,</if>
  177. <if test="tableId != null">table_id,</if>
  178. <if test="tableNo != null and tableNo != ''">table_no,</if>
  179. <if test="logo != null and logo != ''">logo,</if>
  180. <if test="posName != null and posName != ''">pos_name,</if>
  181. <if test="foodAmount != null">food_amount,</if>
  182. <if test="pickUpNum != null">pick_up_num,</if>
  183. <if test="pickUpTime != null and pickUpTime != ''">pick_up_time,</if>
  184. <if test="reservePhone != null and reservePhone != ''">reserve_phone,</if>
  185. <if test="isAccepted != null">is_accepted,</if>
  186. <if test="isDisplay != null">is_display,</if>
  187. <if test="displayTime != null">display_time,</if>
  188. <if test="deliveryStatus != null">delivery_status,</if>
  189. <if test="payStatus != null">pay_status,</if>
  190. <if test="afterSaleStatus != null">after_sale_status,</if>
  191. </trim>
  192. <trim prefix="values (" suffix=")" suffixOverrides=",">
  193. <if test="ddId != null">#{ddId},</if>
  194. <if test="shId != null">#{shId},</if>
  195. <if test="mdId != null">#{mdId},</if>
  196. <if test="cretim != null">#{cretim},</if>
  197. <if test="shdzId != null">#{shdzId},</if>
  198. <if test="userId != null">#{userId},</if>
  199. <if test="amount != null">#{amount},</if>
  200. <if test="remarks != null">#{remarks},</if>
  201. <if test="state != null">#{state},</if>
  202. <if test="type != null">#{type},</if>
  203. <if test="delryTime != null and delryTime != ''">#{delryTime},</if>
  204. <if test="collectPayment != null and collectPayment != ''">#{collectPayment},</if>
  205. <if test="mdActivity != null">#{mdActivity},</if>
  206. <if test="yhName != null and yhName != ''">#{yhName},</if>
  207. <if test="mdYhId != null">#{mdYhId},</if>
  208. <if test="mdYhName != null and mdYhName != ''">#{mdYhName},</if>
  209. <if test="mdDiscountAmount != null">#{mdDiscountAmount},</if>
  210. <if test="salesName != null and salesName != ''">#{salesName},</if>
  211. <if test="mdSalesName != null and mdSalesName != ''">#{mdSalesName},</if>
  212. <if test="salesReduction != null">#{salesReduction},</if>
  213. <if test="mdSalesReduction != null">#{mdSalesReduction},</if>
  214. <if test="points != null">#{points},</if>
  215. <if test="pointsReduction != null">#{pointsReduction},</if>
  216. <if test="sdTime != null">#{sdTime},</if>
  217. <if test="payType != null">#{payType},</if>
  218. <if test="parentDdId != null and parentDdId != ''">#{parentDdId},</if>
  219. <if test="orderCategory != null and orderCategory != ''">#{orderCategory},</if>
  220. <if test="tableId != null">#{tableId},</if>
  221. <if test="tableNo != null and tableNo != ''">#{tableNo},</if>
  222. <if test="logo != null and logo != ''">#{logo},</if>
  223. <if test="posName != null and posName != ''">#{posName},</if>
  224. <if test="foodAmount != null">#{foodAmount},</if>
  225. <if test="pickUpNum != null">#{pickUpNum},</if>
  226. <if test="pickUpTime != null and pickUpTime != ''">#{pickUpTime},</if>
  227. <if test="reservePhone != null and reservePhone != ''">#{reservePhone},</if>
  228. <if test="isAccepted != null">#{isAccepted},</if>
  229. <if test="isDisplay != null">#{isDisplay},</if>
  230. <if test="displayTime != null">#{displayTime},</if>
  231. <if test="deliveryStatus != null">#{deliveryStatus},</if>
  232. <if test="payStatus != null">#{payStatus},</if>
  233. <if test="afterSaleStatus != null">#{afterSaleStatus},</if>
  234. </trim>
  235. </insert>
  236. <update id="updatePosOrder" parameterType="PosOrder">
  237. update pos_order
  238. <trim prefix="SET" suffixOverrides=",">
  239. <if test="ddId != null">dd_id = #{ddId},</if>
  240. <if test="shId != null">sh_id = #{shId},</if>
  241. <if test="mdId != null">md_id = #{mdId},</if>
  242. <if test="cretim != null">cretim = #{cretim},</if>
  243. <if test="shdzId != null">shdz_id = #{shdzId},</if>
  244. <if test="userId != null">user_id = #{userId},</if>
  245. <if test="amount != null">amount = #{amount},</if>
  246. <if test="remarks != null">remarks = #{remarks},</if>
  247. <if test="state != null">state = #{state},</if>
  248. <if test="type != null">type = #{type},</if>
  249. <if test="kefuState != null">kefu_state = #{kefuState},</if>
  250. <if test="kefuContent != null">kefu_content = #{kefuContent},</if>
  251. <if test="delryTime != null and delryTime != ''">delry_time = #{delryTime},</if>
  252. <if test="collectPayment != null and collectPayment != ''">collect_payment = #{collectPayment},</if>
  253. <if test="mdActivity != null">md_activity = #{mdActivity},</if>
  254. <if test="yhName != null and yhName != ''">yh_name = #{yhName},</if>
  255. <if test="mdYhId != null">md_yh_id = #{mdYhId},</if>
  256. <if test="mdYhName != null and mdYhName != ''">md_yh_name = #{mdYhName},</if>
  257. <if test="mdDiscountAmount != null">md_discount_amount = #{mdDiscountAmount},</if>
  258. <if test="salesName != null and salesName != ''">sales_name = #{salesName},</if>
  259. <if test="mdSalesName != null and mdSalesName != ''">md_sales_name = #{mdSalesName},</if>
  260. <if test="salesReduction != null">sales_reduction = #{salesReduction},</if>
  261. <if test="mdSalesReduction != null">md_sales_reduction = #{mdSalesReduction},</if>
  262. <if test="points != null">points = #{points},</if>
  263. <if test="pointsReduction != null">points_reduction = #{pointsReduction},</if>
  264. <if test="sdTime != null">sd_time = #{sdTime},</if>
  265. <if test="payType != null">pay_type = #{payType},</if>
  266. <if test="parentDdId != null and parentDdId != ''">parent_dd_id = #{parentDdId},</if>
  267. <if test="orderCategory != null and orderCategory != ''">order_category = #{orderCategory},</if>
  268. <if test="tableId != null">table_id = #{tableId},</if>
  269. <if test="tableNo != null and tableNo != ''">table_no = #{tableNo},</if>
  270. <if test="logo != null and logo != ''">logo = #{logo},</if>
  271. <if test="posName != null and posName != ''">pos_name = #{posName},</if>
  272. <if test="foodAmount != null">food_amount = #{foodAmount},</if>
  273. <if test="pickUpNum != null">pick_up_num = #{pickUpNum},</if>
  274. <if test="pickUpTime != null and pickUpTime != ''">pick_up_time = #{pickUpTime},</if>
  275. <if test="reservePhone != null and reservePhone != ''">reserve_phone = #{reservePhone},</if>
  276. <if test="isAccepted != null">is_accepted = #{isAccepted},</if>
  277. <if test="isDisplay != null">is_display = #{isDisplay},</if>
  278. <if test="displayTime != null">display_time = #{displayTime},</if>
  279. <if test="deliveryStatus != null">delivery_status = #{deliveryStatus},</if>
  280. <if test="payStatus != null">pay_status = #{payStatus},</if>
  281. <if test="afterSaleStatus != null">after_sale_status = #{afterSaleStatus},</if>
  282. </trim>
  283. where id = #{id}
  284. </update>
  285. <delete id="deletePosOrderById" parameterType="Long">
  286. delete from pos_order where id = #{id}
  287. </delete>
  288. <delete id="deletePosOrderByIds" parameterType="String">
  289. delete from pos_order where id in
  290. <foreach item="id" collection="array" open="(" separator="," close=")">
  291. #{id}
  292. </foreach>
  293. </delete>
  294. <select id="countOrderByNowYear" resultType="int">
  295. SELECT COUNT(*)
  296. FROM pos_order
  297. <where>
  298. <if test="nowYearFirstDay != null">
  299. cretim &gt;= #{nowYearFirstDay}
  300. </if>
  301. </where>
  302. </select>
  303. <select id="countOrderSuccessByNowYear" resultType="int">
  304. SELECT COUNT(*)
  305. FROM pos_order
  306. <where>
  307. <if test="nowYearFirstDay != null">
  308. cretim &gt;= #{nowYearFirstDay}
  309. </if>
  310. AND state in (5, 11)
  311. </where>
  312. </select>
  313. <select id="countOrderFailByNowYear" resultType="int">
  314. SELECT COUNT(*)
  315. FROM pos_order
  316. <where>
  317. <if test="nowYearFirstDay != null">
  318. cretim &gt;= #{nowYearFirstDay}
  319. </if>
  320. AND state = 10
  321. </where>
  322. </select>
  323. <select id="totalTurnoverByNowYear" resultType="Double">
  324. SELECT sum(amount)
  325. FROM pos_order
  326. <where>
  327. <if test="nowYearFirstDay != null">
  328. cretim &gt;= #{nowYearFirstDay}
  329. </if>
  330. AND state in (5, 11)
  331. </where>
  332. </select>
  333. <select id="getOrderCountByDate" resultType="int">
  334. SELECT IFNULL(COUNT(*),0) as amount FROM pos_order
  335. <where>
  336. <if test="startDate != null and startDate != '' and endDate != null and endDate != ''">
  337. and cretim between #{startDate} and #{endDate}
  338. </if>
  339. <if test="startDate != null and startDate != '' and (endDate == null or endDate == '')">
  340. and cretim >= #{startDate}
  341. </if>
  342. <if test="(startDate == null or startDate == '') and (endDate != null and endDate != '')">
  343. and cretim &lt;= #{endDate}
  344. </if>
  345. </where>
  346. </select>
  347. <select id="getOrderSumByDate" resultType="int">
  348. SELECT IFNULL(SUM(amount),0) as amount FROM pos_order
  349. <where>
  350. <if test="startDate != null and startDate != '' and endDate != null and endDate != ''">
  351. and cretim between #{startDate} and #{endDate}
  352. </if>
  353. <if test="startDate != null and startDate != '' and (endDate == null or endDate == '')">
  354. and cretim >= #{startDate}
  355. </if>
  356. <if test="(startDate == null or startDate == '') and (endDate != null and endDate != '')">
  357. and cretim &lt;= #{endDate}
  358. </if>
  359. </where>
  360. </select>
  361. </mapper>