Browse Source

充值列表

zhangxiaobin 1 year ago
parent
commit
6e3873990b
1 changed files with 10 additions and 7 deletions
  1. 10 7
      application/api/controller/Recharge.php

+ 10 - 7
application/api/controller/Recharge.php

@@ -23,24 +23,27 @@ class Recharge extends Api
         $list = Db::name('recharge_config')->field($field)->where($where)->order('id desc')->select();
 
         //追加赠送
-        /*if(!empty($list)){
+        if(!empty($list)){
             $config_ids = array_column($list,'id');
-            $gift = Db::name('recharge_gift')->alias('gift')
-                ->field('gift.*,coupons.name,coupons.info,coupons.days')
-                ->join('coupons','gift.coupon_id = coupons.id','LEFT')
-                ->where('gift.config_id','IN',$config_ids)
-                ->where('coupons.status',1)
+            $g = 'gift';
+            $c = 'coupons';
+            $gift = Db::name('recharge_gift')->alias($g)
+                ->field($g.'.config_id,'.$g.'.coupon_id,'.$g.'.number,coupons.name,coupons.info,coupons.days')
+                ->join($c,$c.'.id = '.$g.'.coupon_id' ,'LEFT')
+                ->where($g.'.config_id','IN',$config_ids)
+                ->where($c.'.status',1)
                 ->select();
 
             foreach($list as $key => &$val){
                 $val['gift'] = [];
                 foreach($gift as $k => $v){
                     if($val['id'] == $v['config_id']){
+                        unset($v['config_id']);
                         $val['gift'][] = $v;
                     }
                 }
             }
-        }*/
+        }
         $this->success(1,$list);
     }