瀏覽代碼

收益兑换金币

lizhen_gitee 4 月之前
父節點
當前提交
64e48fff6e
共有 2 個文件被更改,包括 18 次插入89 次删除
  1. 18 29
      application/api/controller/Exchange.php
  2. 0 60
      application/api/controller/Userwallet.php

+ 18 - 29
application/api/controller/Recharge.php → application/api/controller/Exchange.php

@@ -6,9 +6,9 @@ use app\common\controller\Api;
 use \think\Db;
 
 /*
- * 公众号搜索用户进行充值
+ * 收益兑换金币
  * */
-class Recharge extends Api
+class Exchange extends Api
 {
 
     protected $noNeedLogin = ['*'];
@@ -21,9 +21,9 @@ class Recharge extends Api
 
 
 
-    //金币兑换配置列表
+    //兑换配置
     public function config(){
-        $rs = Db::name('paygold_webcon')->field('id,money,gold')->order('id asc')->select();
+        $rs = Db::name('exchange')->order('id asc')->select();
         if ($rs) {
             foreach ($rs as &$v) {
                 $v['money_to_gold'] = config('site.money_to_gold');
@@ -38,45 +38,34 @@ class Recharge extends Api
             array_push($rs, $arr);
         }
 
-        $this->success('success',$rs);
-    }
-
-    //根据uid检索人
-    public function check_user()
-    {
-        $mobile = input('mobile');
-        if(!$mobile){
-            $this->error('请输入用户手机号');
-        }
-
-        //填充0
-        $map = [
-            'mobile'=>$mobile,
+        $result = [
+            'config' => $rs,
+            'money'   => model('wallet')->getWallet($this->auth->id,'money'),
         ];
 
-        $user_info = Db::name('user')->field('username,nickname')->where($map)->find();
-        if (empty($user_info)) {
-            $this->error('用户信息不存在');
-        }
-        $this->success('success',$user_info);
+        $this->success('success',$result);
     }
 
 
 
     //兑换金币
     public function exchangegold() {
-        $id = input('id', 0, 'intval');
+        $id        = input('id', 0, 'intval');
         $freemoney = input_post('freemoney', 0, 'intval'); //自定义
         $uid = $this->auth->id;
+
         if(!$id && !$freemoney){
             $this->error('请选择或填写兑换金额');
         }
 
         if ($id) {
             //赋值money
-            $paygold_webcon = Db::name('paygold_webcon')->where('id', $id)->find();
-            $money = $paygold_webcon ? $paygold_webcon['money'] : 0;
-            $gold = $paygold_webcon ? $paygold_webcon['gold'] : 0;
+            $exchange = Db::name('exchange')->where('id', $id)->find();
+            if(!$exchange){
+                $this->error('请选择或填写兑换金额');
+            }
+            $money = $exchange ? $exchange['money'] : 0;
+            $gold = $exchange ? $exchange['gold'] : 0;
         }
         if ($freemoney) {
             $money = $freemoney;
@@ -85,10 +74,10 @@ class Recharge extends Api
         }
 
         if($money<=0) {
-            $this->error('支付金额必须大于0');
+            $this->error('收益金额必须大于0');
         }
         if($money > 10000){
-            $this->error('支付金额太大');
+            $this->error('收益金额太大,请分批进行');
         }
         //验证余额
         $user_info = model('wallet')->getWallet($this->auth->id);

+ 0 - 60
application/api/controller/Userwallet.php

@@ -118,29 +118,6 @@ class Userwallet extends Api
 
         $this->success('success',$list);
     }
-    //钻石日志
-    public function my_jewel_log(){
-        $type = input_post('type',0);
-
-        $map = [
-            'user_id' => $this->auth->id,
-        ];
-//        if($type){
-//            $map['log_type'] = $type;
-//        }
-
-        $list = Db::name('user_jewel_log')
-            ->field('id,log_type,change_value,remain,remark,createtime, remark log_text')
-            ->where($map)->order('id desc')->autopage()->select();
-//        $list = $this->list_appen_logtext($list);
-        if(!empty($list)){
-            foreach($list as $key => $val){
-                $list[$key]['createtime'] = date('Y.m.d H:i', $val['createtime']);
-            }
-        }
-
-        $this->success('success',$list);
-    }
 
 
     //提现记录
@@ -425,42 +402,5 @@ class Userwallet extends Api
         $this->success('success', $list);
     }
 
-    //用户之间钻石转赠
-    public function jewel_transfer(){
-        $jewel = input('jewel',0,'intval');
-        $user_id = input('user_id',0,'trim');
-
-        if(!$jewel || !$user_id){
-            $this->error();
-        }
-
-        if($jewel < 0){
-            $this->error('输入数量为0');
-        }
-
-        $find_user = Db::name('user')->where('id|mobile',$user_id)->find();
-        if(!$find_user){
-            $this->error('不存在的用户');
-        }
-        $user_id = $find_user['id'];
 
-        Db::startTrans();
-
-        $wallet_rs = model('wallet')->lockChangeAccountRemain($this->auth->id,0,'jewel',-$jewel,36,'钻石转赠');
-        if($wallet_rs['status'] === false){
-            Db::rollback();
-            $this->error($wallet_rs['msg']);
-        }
-
-        $wallet_rs = model('wallet')->lockChangeAccountRemain($user_id,0,'jewel',$jewel,37,'钻石获赠');
-        if($wallet_rs['status'] === false){
-            Db::rollback();
-            $this->error($wallet_rs['msg']);
-        }
-
-        Db::commit();
-
-        $this->success();
-
-    }
 }