Forráskód Böngészése

用户钱包与充值

lizhen_gitee 2 hónapja
szülő
commit
0a16ec226e
2 módosított fájl, 61 hozzáadás és 184 törlés
  1. 14 183
      application/api/controller/Pay.php
  2. 47 1
      application/api/controller/Userwallet.php

+ 14 - 183
application/api/controller/Pay.php

@@ -13,89 +13,11 @@ class Pay extends Api
     protected $noNeedLogin = [];
     protected $noNeedRight = ['*'];
 
-    //充值金币 创建订单
-    public function money_recharge(){
-
-        $pay_type  = input('pay_type','wechat');
-        $platform  = 'app';
-        $freemoney = input('freemoney',0);
-        $uid = $this->auth->id;
-
-        if(!$freemoney){
-            $this->error('填写充值金额');
-        }
-
-        if(!$this->user_auth_limit()){
-            $this->error('请先完成实名认证');
-        }
-
-        //赋值money
-        /*if($rc_id){
-            $recharge_config = Db::name('paygold_webcon')->where('id',$rc_id)->find();
-            $money = $recharge_config['money'] ?: 0;
-            $gold  = $recharge_config['gold'] ?: 0;
-        }*/
-
-        //自由输入覆盖
-        if(!empty($freemoney)){
-            $rc_id = 0;
-            $money = floatval($freemoney);
-
-        }
-
-        //
-        if($money<=0)
-        {
-            $this->error('支付金额必须大于0');
-        }
-        if($money > 10000){
-            $this->error('支付金额太大');
-        }
-
-        //创建订单
-        $data = [];
-        $data['user_id'] = $uid;
-        $data['out_trade_no'] = createUniqueNo('P',$uid); // 数据库订单号加密
-        $data['order_amount'] = $money;
-        $data['createtime'] = time();
-
-        $data['pay_type'] = $pay_type;
-        $data['platform'] = $platform;
-        $data['order_status'] = 0;
-        $data['table_name'] = 'money_recharge';
-        $data['table_id'] = 0;
-        $data['args'] = '';
-
-        $orderid = Db::name('pay_order')->insertGetId($data);
-
-        $openid = $this->auth->wechat_openid;
-        //下单
-        $params = [
-            'type'         => $pay_type,
-            'orderid'      => $data['out_trade_no'],
-            'title'        => '支付订单',
-            'amount'       => $data['order_amount'],
-            'method'       => $platform,
-            'openid'       => $openid,
-            'notifyurl' => config('pay_notify_url').'/api/notify/recharge_notify_base/paytype/'.$pay_type,
-            'returnurl' => '',
-        ];
-
-        $res = Service::submitOrder($params);
-
-        if($pay_type == 'wechat'){
-            $this->success('success',json_decode($res,true));
-        }else{
-            $this->success('success',$res);
-        }
-    }
-
-///////////////////////////////////////////////////////////////
 
     //金币充值
-    public function gold_config(){
-        $list = Db::name('paygold_webcon')->order('weigh asc,id asc')->select();
-        $data['goldconfig'] = $list;
+    public function money_config(){
+        $list = Db::name('recharge_config')->order('weigh asc,id asc')->select();
+        $data['config'] = $list;
 
         $wallet = model('wallet')->getWallet($this->auth->id);
         $data['wallet'] = $wallet;
@@ -103,37 +25,30 @@ class Pay extends Api
     }
 
     //充值金币 创建订单
-    public function gold_recharge(){
+    public function money_recharge(){
 
         $rc_id     = input('rc_id',0);
-        $pay_type  = input('pay_type','wechat');
-        $platform  = 'app';
-//        $freemoney = input('freemoney',0);
-        $freemoney = 0;
+        $pay_type  = 'wechat';
+        $platform  = 'mini';
+        $freemoney = input('freemoney',0);
         $uid = $this->auth->id;
 
         if(!$rc_id && !$freemoney){
             $this->error('请选择或填写充值金额');
         }
 
-        if(!$this->user_auth_limit()){
-            $this->error('请先完成实名认证');
-        }
 
         //赋值money
         if($rc_id){
-            $recharge_config = Db::name('paygold_webcon')->where('id',$rc_id)->find();
+            $recharge_config = Db::name('recharge_config')->where('id',$rc_id)->find();
             $money = $recharge_config['money'] ?: 0;
-            $gold  = $recharge_config['gold'] ?: 0;
         }
 
         //自由输入覆盖
-        /*if(!empty($freemoney)){
+        if(!empty($freemoney)){
             $rc_id = 0;
             $money = floatval($freemoney);
-            $bili = config('rmb_to_gold') ?: 10;
-            $gold  = bcmul($money,$bili,0);
-        }*/
+        }
 
         //
         if($money<=0)
@@ -144,11 +59,6 @@ class Pay extends Api
             $this->error('支付金额太大');
         }
 
-        //充值上限
-        $limit_rs = $this->limit_gift($money);
-        if($limit_rs !== true){
-            $this->error($limit_rs);
-        }
 
         //创建订单
         $data = [];
@@ -160,18 +70,18 @@ class Pay extends Api
         $data['pay_type'] = $pay_type;
         $data['platform'] = $platform;
         $data['order_status'] = 0;
-        $data['table_name'] = 'gold_recharge';
+        $data['table_name'] = 'money_recharge';
         $data['table_id'] = 0;
-        $data['args'] = json_encode(['gold'=>$gold]);
+        $data['args'] = '';
 
         $orderid = Db::name('pay_order')->insertGetId($data);
 
-        $openid = $this->auth->wechat_openid;
+        $openid = $this->auth->wxmini_openid;
         //下单
         $params = [
             'type'         => $pay_type,
             'orderid'      => $data['out_trade_no'],
-            'title'        => '支付订单',
+            'title'        => '充值余额',
             'amount'       => $data['order_amount'],
             'method'       => $platform,
             'openid'       => $openid,
@@ -190,85 +100,6 @@ class Pay extends Api
 
 
 
-    //vip用的
-    public function vip_config(){
-        $list = Db::name('payvip_config')->order('weigh asc,id asc')->select();
-        $data['vipconfig'] = $list;
-        $data['vip_endtime'] = model('wallet')->getWallet($this->auth->id,'vip_endtime');
-        $data['is_vip'] = $data['vip_endtime'] > time() ? 1 : 0;
-        $data['avatar'] = localpath_to_netpath($this->auth->avatar);
-        $this->success('success',$data);
-    }
-
-    //vip用的,创建订单
-    public function vip_recharge(){
-
-        $rc_id = input('rc_id',0);
-        $pay_type = input('pay_type','wechat');
-        $platform = 'app';
-        $uid = $this->auth->id;
-
-        if(!$rc_id){
-            $this->error('请选择会员套餐');
-        }
-
-        if(!$this->user_auth_limit()){
-            $this->error('请先完成实名认证');
-        }
-
-
-        //赋值money
-        $recharge_config = Db::name('payvip_config')->where('id',$rc_id)->find();
-        $money = $recharge_config['money'];
-
-        if($money<=0)
-        {
-            $this->error('支付金额必须大于0');
-        }
-        if($money > 10000){
-            $this->error('支付金额太大');
-        }
-
-
-        //创建订单
-        $data = [];
-        $data['user_id'] = $uid;
-        $data['out_trade_no'] = createUniqueNo('P',$uid); // 数据库订单号加密
-        $data['order_amount'] = $money;
-        $data['createtime'] = time();
-
-        $data['pay_type'] = $pay_type;
-        $data['platform'] = $platform;
-        $data['order_status'] = 0;
-        $data['table_name'] = 'vip_recharge';
-        $data['table_id'] = 0;
-        $data['args'] = json_encode(['days'=>$recharge_config['days']]);
-
-        $orderid = Db::name('pay_order')->insertGetId($data);
-
-        $openid = $this->auth->wechat_openid;
-        //下单
-        $params = [
-            'type'         => $pay_type,
-            'orderid'      => $data['out_trade_no'],
-            'title'        => '支付订单',
-            'amount'       => $data['order_amount'],
-            'method'       => $platform,
-            'openid'       => $openid,
-            'notifyurl' => config('pay_notify_url').'/api/notify/vip_notify_base/paytype/'.$pay_type,
-            'returnurl' => '',
-        ];
-
-        $res = Service::submitOrder($params);
-
-        if($pay_type == 'wechat'){
-            $this->success('success',json_decode($res,true));
-        }else{
-            $this->success('success',$res);
-        }
-    }
-
-
 
 
 }

+ 47 - 1
application/api/controller/Userwallet.php

@@ -38,7 +38,53 @@ class Userwallet extends Api
         $list = Db::name('user_money_log')
             ->field('id,log_type,before,change_value,remain,remark,createtime')
             ->where($map)->order('id desc')->autopage()->select();
-        $list = $this->list_appen_logtext($list);
+//        $list = $this->list_appen_logtext($list);
+
+        $this->success('success',$list);
+    }
+
+    //我的余额日志
+    public function my_hexiaomoney_log(){
+        $type = input('type',0);
+
+        $map = [
+           'user_id' => $this->auth->id,
+        ];
+
+        if($type == 1){
+            $map['change_value'] = ['gt',0];
+        }
+        if($type == 2){
+            $map['change_value'] = ['lt',0];
+        }
+
+        $list = Db::name('user_money_log')
+            ->field('id,log_type,before,change_value,remain,remark,createtime')
+            ->where($map)->order('id desc')->autopage()->select();
+//        $list = $this->list_appen_logtext($list);
+
+        $this->success('success',$list);
+    }
+
+    //我的余额日志
+    public function my_fenxiaomoney_log(){
+        $type = input('type',0);
+
+        $map = [
+           'user_id' => $this->auth->id,
+        ];
+
+        if($type == 1){
+            $map['change_value'] = ['gt',0];
+        }
+        if($type == 2){
+            $map['change_value'] = ['lt',0];
+        }
+
+        $list = Db::name('user_money_log')
+            ->field('id,log_type,before,change_value,remain,remark,createtime')
+            ->where($map)->order('id desc')->autopage()->select();
+//        $list = $this->list_appen_logtext($list);
 
         $this->success('success',$list);
     }