浏览代码

Merge remote-tracking branch 'origin/saas' into saas

yanite 3 年之前
父节点
当前提交
81cfb5564c
共有 1 个文件被更改,包括 45 次插入33 次删除
  1. 45 33
      mec-biz/src/main/resources/config/mybatis/SysCouponIssueRecordMapper.xml

+ 45 - 33
mec-biz/src/main/resources/config/mybatis/SysCouponIssueRecordMapper.xml

@@ -128,39 +128,51 @@
     </resultMap>
 
     <select id="queryUserCanGetCoupon" resultMap="SysCoupon">
-        select id_,
-               name_,
-               description_,
-               status_,
-               issuance_type_,
-               type_,
-               type_detail_,
-               face_value_,
-               full_amount_,
-               limit_exchange_num_,
-               effective_type_,
-               deadline_,
-               effective_start_time_,
-               effective_expire_time_,
-               end_date_,
-               start_date_,
-               stock_count_,
-               consume_num_,
-               warning_stock_num_,
-               warning_status_,
-               create_time_,
-               update_time_,
-               tenant_id_
-        from sys_coupon
-        where issuance_type_ = 0
-          and status_ = 1
-          and (effective_expire_time_ > now() or deadline_ > 0)
-          and (stock_count_ >= consume_num_ or stock_count_ = -1)
-          and id_ not in (
-            select distinct coupon_id_
-            from sys_coupon_code
-            where user_id_ = #{userId}
-        )
+        SELECT
+            id_,
+            name_,
+            description_,
+            status_,
+            issuance_type_,
+            type_,
+            type_detail_,
+            face_value_,
+            full_amount_,
+            limit_exchange_num_,
+            effective_type_,
+            deadline_,
+            effective_start_time_,
+            effective_expire_time_,
+            end_date_,
+            start_date_,
+            stock_count_,
+            consume_num_,
+            warning_stock_num_,
+            warning_status_,
+            create_time_,
+            update_time_,
+            a.tenant_id_
+        FROM
+            sys_coupon AS a
+                JOIN
+            (SELECT DISTINCT
+                 coupon_id_,
+                 tenant_id_
+             FROM
+                 sys_coupon_code
+             WHERE user_id_ = #{userId}) AS b
+            ON a.`id_` NOT IN (b.coupon_id_)
+                AND a.tenant_id_ = b.tenant_id_
+        WHERE issuance_type_ = 0
+          AND status_ = 1
+          AND (
+                    effective_expire_time_ > NOW()
+                OR deadline_ > 0
+            )
+          AND (
+                    stock_count_ >= consume_num_
+                OR stock_count_ = - 1
+            )
     </select>
 
 </mapper>