Przeglądaj źródła

盲票增加券和券包的关联

cup 2 lat temu
rodzic
commit
23137d6e73

+ 22 - 5
mp-service/src/main/resources/mapper/admin/TicketBoxGoodsMapper.xml

@@ -20,13 +20,30 @@
     </sql>
 
     <select id="listByQueryWrapper" resultType="com.qs.mp.admin.domain.vo.TicketBoxGoodsVO">
-        select if(t2.title is not null, t2.title, t1.title)       as title,
-               if(t2.pic_url is not null, t2.pic_url, t1.pic_url) as pic_url,
-               if(t2.value is not null, t2.value, t1.value)       as value,
-               if(t2.cost is not null, t2.cost, 0)                as cost,
-               t1.*
+        select
+            case t1.type
+            when 'goods' then if(t2.title is not null, t2.title, t1.title)
+            when 'coupon' then if(t3.title is not null, t3.title, t1.title)
+            end as title,
+
+            case t1.type
+            when 'goods' then if(t2.pic_url is not null, t2.pic_url, t1.pic_url)
+            when 'coupon' then if(t3.pic_url is not null, t3.pic_url, t1.pic_url)
+            end as pic_url,
+
+            case t1.type
+            when 'goods' then if(t2.value is not null, t2.value, t1.value)
+            when 'coupon' then if(t3.discount is not null, t3.discount, t1.value)
+            end as value,
+
+            case t1.type
+            when 'goods' then if(t2.cost is not null, t2.cost, 0)
+            end as cost,
+
+           t1.*
         from mp_ticket_box_goods t1
         left join mp_goods t2 on t1.ref_id = t2.goods_id
+        left join mp_coupon t3 on t1.ref_id = t3.coupon_id
             ${ew.customSqlSegment}
     </select>
 </mapper>

+ 13 - 2
mp-service/src/main/resources/mapper/admin/TicketBoxMapper.xml

@@ -45,13 +45,24 @@
     </select>
 
     <select id="listTicketGoodsByQueryWrapper" resultType="com.qs.mp.admin.domain.vo.TicketBoxGoodsListVO">
-        select if(t3.title is not null, t3.title, t2.title)       as title,
-               if(t3.pic_url is not null, t3.pic_url, t2.pic_url) as pic_url,
+        select
+                case t2.type
+                when 'goods' then if(t3.title is not null, t3.title, t2.title)
+                when 'coupon' then if(t4.title is not null, t4.title, t2.title)
+                end as title,
+
+                case t2.type
+                when 'goods' then if(t3.pic_url is not null, t3.pic_url, t2.pic_url)
+                when 'coupon' then if(t4.pic_url is not null, t4.pic_url, t2.pic_url)
+                end as pic_url,
+
+                t2.type,
                 t2.ref_id,
                t1.*
         from mp_ticket_box t1
              left join mp_ticket_box_goods t2 on t1.box_id = t2.box_id
              left join mp_goods t3 on t2.ref_id = t3.goods_id
+             left join mp_coupon t4 on t2.ref_id = t4.coupon_id
         ${ew.customSqlSegment}
   </select>
 </mapper>