瀏覽代碼

家族卡等修改

lizhen_gitee 1 年之前
父節點
當前提交
78e43cc448

+ 102 - 0
application/api/controller/Relation.php

@@ -0,0 +1,102 @@
+<?php
+
+namespace app\api\controller;
+
+use app\common\controller\Api;
+use think\Db;
+/**
+ * 家族卡
+ */
+class Relation extends Api
+{
+    protected $noNeedLogin = ['*'];
+    protected $noNeedRight = ['*'];
+
+
+    //关系卡列表
+    public function decorate_list(){
+        $list = Db::name('decorate_relation')->select();
+        $list = list_domain_image($list,['base_image']);
+
+        $this->success(1,$list);
+    }
+
+    /**
+     * 购买并加入我的背包
+     */
+    public function buy_one() {
+        $number = input('number',1,'intval'); //数量
+        if(!$number){
+            $this->error();
+        }
+
+        $did = input('did',''); //装扮ID
+        if (!$did) {
+            $this->error();
+        }
+        // 判断用户金币余额是否充足
+        $walletinfo = model('wallet')->getWallet($this->auth->id);
+
+        // 获取购买装扮需要的价格
+        $decorate = Db::name('decorate_relation')->where(['id'=>$did])->find();
+        if(!$decorate) {
+            $this->error("道具信息获取失败!");
+        }
+        $total_price = bcmul($decorate['price'],$number,0);
+        if($walletinfo['jewel'] < $total_price) {
+            $this->error("您的金币不足,请先充值!");
+        }
+        // 进行购买逻辑
+        Db::startTrans();
+
+        // 添加到背包
+        for($i=1;$i<=$number;$i++){
+            $data[] = [
+                'user_id' => $this->auth->id,
+                'decorate_id' => $decorate['id'],
+                'is_using' => 0,
+                'createtime' => time(),
+                'updatetime' => time(),
+            ];
+        }
+
+        $log_id = Db::name('user_decorate_relation')->insertAll($data);
+        if(!$log_id){
+            Db::rollback();
+            $this->error('购买失败');
+        }
+
+        //扣钱
+        $rs = model('wallet')->lockChangeAccountRemain($this->auth->id,$total_price,'-',0,'购买家族卡',32,'jewel');
+        if($rs['status'] === false){
+            Db::rollback();
+            $this->error($rs['msg']);
+        }
+
+
+        Db::commit();
+        $this->success("购买成功!");
+    }
+
+
+    //获取用户装扮
+    public function my_decorate_list()
+    {
+        $uid = $this->auth->id;
+
+        $map = [
+            'a.user_id' => $uid,
+            'a.is_using'=> 0,
+        ];
+
+        $list = Db::name('user_decorate_relation')
+            ->alias('a')
+            ->field('a.id,a.decorate_id,b.name,b.base_image,count(a.decorate_id) as number')
+            ->join('decorate_relation b', 'a.decorate_id = b.id','LEFT')
+            ->where($map)->group('a.decorate_id')->order('a.id desc')->autopage()->select();
+
+        $list = list_domain_image($list,['base_image']);
+
+        $this->success('success',$list);
+    }
+}

+ 9 - 9
application/api/controller/Userdecorate.php

@@ -18,7 +18,7 @@ class Userdecorate extends Api
      */
     public function decorate_list()
     {
-        $type = input_post('type',2); // 类型:1=座驾,2=头饰,3=尾灯,4=气泡,5=关系卡,6=联盟道具
+        $type = input('type',2); // 类型:1=座驾,2=头饰,3=尾灯,4=气泡
 
         // 获取基本信息
         $where = [];
@@ -35,7 +35,7 @@ class Userdecorate extends Api
      * 购买并加入我的背包
      */
     public function buy_one() {
-        $did = input_post('did',''); //装扮ID
+        $did = input('did',''); //装扮ID
         if (!$did) {
             $this->error();
         }
@@ -47,7 +47,7 @@ class Userdecorate extends Api
         if(!$decorate) {
             $this->error("装扮信息获取失败!");
         }
-        if($walletinfo['gold'] < $decorate['price']) {
+        if($walletinfo['jewel'] < $decorate['price']) {
             $this->error("您的金币不足,请先充值!");
         }
         // 进行购买逻辑
@@ -70,7 +70,7 @@ class Userdecorate extends Api
             $this->error('购买失败');
         }
 
-        $rs = model('wallet')->lockChangeAccountRemain($this->auth->id,$decorate['price'],'-',0,'购买装扮',31,'jewel');
+        $rs = model('wallet')->lockChangeAccountRemain($this->auth->id,$decorate['price'],'-',0,'购买装扮',6,'jewel');
         if($rs['status'] === false){
             Db::rollback();
             $this->error($rs['msg']);
@@ -85,7 +85,7 @@ class Userdecorate extends Api
     public function my_decorate_list()
     {
         $uid = $this->auth->id;
-        $type = input_post('type',2);
+        $type = input('type',2);
 
         $map = [
             'a.end_time' => ['gt',time()],
@@ -106,8 +106,8 @@ class Userdecorate extends Api
 
     //获得某用户的某类型正在使用的装扮
     public function get_user_onetype_decorate(){
-        $uid = input_post('uid');
-        $type = input_post('type',2);
+        $uid = input('uid');
+        $type = input('type',2);
 
         if(!$uid){
             $this->error();
@@ -132,7 +132,7 @@ class Userdecorate extends Api
     //设置装扮
     public function set_user_decorate()
     {
-        $did = input_post('did',''); //用户装扮ID
+        $did = input('did',''); //用户装扮ID
         if (!$did) {
             $this->error();
         }
@@ -186,7 +186,7 @@ class Userdecorate extends Api
     //取消装扮
     public function cancel_user_decorate()
     {
-        $did = input_post('did',''); //装扮ID
+        $did = input('did',''); //装扮ID
         if (!$did) {
             $this->error();
         }

+ 3 - 3
application/common/model/Wallet.php

@@ -80,11 +80,11 @@ class Wallet extends Model
         );
 
         //限制权限
-        $power_rs = $this->power_limit_logtype($user_id,$logtype);
+        /*$power_rs = $this->power_limit_logtype($user_id,$logtype);
         if($power_rs !== true){
             $result['msg'] = $power_rs;
             return $result;
-        }
+        }*/
 
         //获取小数点
         $point = $accountType == 'money' ? 2 : 0;
@@ -115,7 +115,7 @@ class Wallet extends Model
 
 
         //检测
-        $wallet = Db::name('user_wallet')->field('money,jewel')->lock(true)->where(['user_id'=>$user_id])->find();
+        $wallet = Db::name('user_wallet')->lock(true)->where(['user_id'=>$user_id])->find();
         if(!$wallet)
         {
             $result['msg'] = '不存在的用户';

+ 2 - 0
application/extra/wallet.php

@@ -25,6 +25,8 @@ return [
         17 => '平台充值',//增加
         18 => '充值退款',//减少                              需要测试
 
+        32 => '购买家族卡', //减少
+
         //money
         101 => '获赠礼物', //增加
         102 => '房间礼物抽成', //增加