Browse Source

我的收送礼物明细

lizhen_gitee 1 năm trước cách đây
mục cha
commit
9403285503
1 tập tin đã thay đổi với 42 bổ sung0 xóa
  1. 42 0
      application/api/controller/Gift.php

+ 42 - 0
application/api/controller/Gift.php

@@ -82,4 +82,46 @@ class Gift extends Api
             ->select();
         $this->success("获取成功!", $list);
     }
+
+    /**
+     * 获取我的收送礼明细
+     */
+    public function my_gift_log(){
+        $user_id = $this->auth->id;
+        $type    = input('type',1);
+
+        $where = [];
+        if($type == 1){
+            $where['user_id'] = $user_id;//我送出
+            $joinstr = 'gup.user_to_id = user.id';
+        }else{
+            $where['user_to_id'] = $user_id;//我收到
+            $joinstr = 'gup.user_id = user.id';
+        }
+
+        $list = Db::name('gift_user_party')->alias('gup')
+            ->join('user',$joinstr,'LEFT')->field('gup.*,user.nickname')
+            ->where($where)->order('id desc')->autopage()->select();
+        $list = list_domain_image($list,['gift_gif_image']);
+
+        $rs = [];
+        if(empty($list)){
+            $this->success(1,$rs);
+        }
+
+        foreach($list as $key => $val){
+            if($type == 1){
+                $remark = '赠送'.$val['nickname'].','.$val['gift_name'].'*'.$val['number'].',价值'.$val['value'].'钻石';
+            }else{
+                $remark = $val['nickname'].'赠送,'.$val['gift_name'].'*'.$val['number'].',价值'.$val['value'].'钻石';
+            }
+            $rs[] = [
+                'id'         => $val['id'],
+                'gift_image' => $val['gift_gif_image'],
+                'createtime' => $val['createtime'],
+                'remark'     => $remark
+            ];
+        }
+        $this->success(1,$rs);
+    }
 }