liuyao 1 год назад
Родитель
Сommit
c4b4e99182
1 измененных файлов с 23 добавлено и 3 удалено
  1. 23 3
      src/main/java/com/dk/oauth/mapper/integral/CouponSendMapper.xml

+ 23 - 3
src/main/java/com/dk/oauth/mapper/integral/CouponSendMapper.xml

@@ -189,10 +189,30 @@
     </select>
 
     <select id="selectCouponSendItem" resultType="java.util.Map">
-        select *,
-        COUNT (*)
+        select
+            tmcs.send_id as "sendId",
+            tmcs.cp_id as "cpId",
+            tmcs.coupon_id as "couponId",
+            tmcs.send_date as "sendDate",
+            tmcs.end_date as "endDate",
+            tmcs.user_num as "userNum",
+            tmcs.send_staff as "sendStaff",
+            tmcs.send_user as "sendUser",
+            ( select COUNT (1) from dkic_a.t_mst_coupon_receive tmcr
+              where tmcr.send_id = tmcs.send_id
+            ) as "userHelpNum",
+            now() as "nowTime"
         from dkic_a.t_mst_coupon_send tmcs
-        where tmcs.send_user = #{sendUser}
+        left join dkic_a.t_mst_coupon tmc
+            on tmc.coupon_id = tmcs.coupon_id
+        where tmcs.send_user = #{sendUser}::uuid
+        and ( select COUNT (1) from dkic_a.t_mst_coupon_receive tmcr
+        where tmcr.send_id = tmcs.send_id
+        ) &lt; tmc.user_num
+        and tmcs.cp_id = #{cpId}
+        and tmcs.end_date > now()
+        ORDER BY tmcs.send_date desc
+        limit 1
     </select>