123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- use think\Db;
- class Gift extends Api
- {
- protected $noNeedLogin = ['getGiftList','getGiftType'];
- protected $noNeedRight = '*';
- public function _initialize()
- {
- parent::_initialize();
- $this->giftModel = new \app\common\model\Gift();
- $this->gifttypeModel = new \app\common\model\GiftType();
- }
-
- public function getGiftList() {
- $type = $this->request->request("type");
- $page = $this->request->request('page',1);
- $pageNum = $this->request->request('pageNum',100);
-
- $pageStart = ($page-1)*$pageNum;
-
- $where = [];
- $type != '' && $where["type"] = $type;
- $giftList = $this->giftModel->where($where)->order("sort","asc")->select();
- $this->success("获取成功!",$giftList);
- }
-
- public function getGiftType() {
-
- $where = [];
- $where["is_show"] = 1;
- $giftList = $this->gifttypeModel->field("id,name")->where($where)->order("weight","desc")->select();
- $this->success("获取成功!",$giftList);
- }
-
- public function getMyBackGift() {
- $userid = $this->request->request("user_id", $this->auth->id);
-
-
-
-
- $list = \app\common\model\GiftBack::field("id,name,image,gif_image,value,sum(number) as number")
- ->where(["user_id"=>$userid,"is_use"=>0])
-
- ->group("name")
- ->select();
- $this->success("获取成功!",$list);
- }
-
- public function getMyGiftWall() {
- $user_id = $this->request->request("user_id", 0);
- $userid = $user_id ? $user_id : $this->auth->id;
- $list = \app\common\model\GiftUserParty::alias('a')->join("hx_gift g", "g.id = a.gift_id", "inner")->field("gift_id,g.name,g.image,sum(number) as number")
- ->where(["user_to_id" => $userid, 'g.type' => ['<>', 6]])
- ->group("gift_id")
- ->order('g.value desc')
- ->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);
- }
- }
|