Jason 1 жил өмнө
parent
commit
adf862f584

+ 2 - 2
application/admin/controller/Ajax.php

@@ -120,12 +120,12 @@ class Ajax extends Backend
                 // $attachment = $upload->upload();
                 // $attachment = $upload->upload();
            
            
                 $filename = $file->getInfo();
                 $filename = $file->getInfo();
+
                 //获取oss实例
                 //获取oss实例
                 $ossClient = new OssClient(Env::get('oss.key_id'), Env::get('oss.key_secret'), Env::get('oss.endpoint'));
                 $ossClient = new OssClient(Env::get('oss.key_id'), Env::get('oss.key_secret'), Env::get('oss.endpoint'));
-                $bucket    = Env::get('oss.dbucket'); 
+                $bucket    = Env::get('oss.bucket');
                 $uploadpath = "tou-biao/" . date("Ym") . "/" . $filename['name'];
                 $uploadpath = "tou-biao/" . date("Ym") . "/" . $filename['name'];
                 $rs = $ossClient->uploadFile($bucket, $uploadpath, $file->getRealPath());
                 $rs = $ossClient->uploadFile($bucket, $uploadpath, $file->getRealPath());
-  
             } catch (UploadException $e) {
             } catch (UploadException $e) {
                 $this->error($e->getMessage());
                 $this->error($e->getMessage());
             }
             }

+ 2 - 2
application/admin/controller/trade/Mongyin.php → application/admin/controller/trade/MoneyIn.php

@@ -9,7 +9,7 @@ use app\common\controller\Backend;
  *
  *
  * @icon fa fa-circle-o
  * @icon fa fa-circle-o
  */
  */
-class Mongyin extends Backend
+class MoneyIn extends Backend
 {
 {
 
 
     /**
     /**
@@ -24,7 +24,7 @@ class Mongyin extends Backend
     {
     {
         parent::_initialize();
         parent::_initialize();
         $this->mapType  = array();
         $this->mapType  = array();
-        $this->model    = new \app\common\model\MongyIn;
+        $this->model    = new \app\common\model\MoneyIn;
         $this->assign('typeList', $this->model->getTypeList());
         $this->assign('typeList', $this->model->getTypeList());
     }
     }
 
 

+ 1 - 1
application/admin/controller/trade/Moneylog.php → application/admin/controller/trade/MoneyLog.php

@@ -9,7 +9,7 @@ use app\common\controller\Backend;
  *
  *
  * @icon fa fa-circle-o
  * @icon fa fa-circle-o
  */
  */
-class Moneylog extends Backend
+class MoneyLog extends Backend
 {
 {
 
 
     /**
     /**

+ 2 - 2
application/admin/controller/trade/Mongyout.php → application/admin/controller/trade/MoneyOut.php

@@ -14,7 +14,7 @@ use think\exception\ValidateException;
  *
  *
  * @icon fa fa-circle-o
  * @icon fa fa-circle-o
  */
  */
-class Mongyout extends Backend
+class MoneyOut extends Backend
 {
 {
 
 
     /**
     /**
@@ -29,7 +29,7 @@ class Mongyout extends Backend
     {
     {
         parent::_initialize();
         parent::_initialize();
         $this->mapType  = array();
         $this->mapType  = array();
-        $this->model = new \app\common\model\MongyOut;
+        $this->model = new \app\common\model\MoneyOut;
         $this->assign('typeList', $this->model->getTypeList());
         $this->assign('typeList', $this->model->getTypeList());
     }
     }
 
 

+ 2 - 2
application/admin/controller/user/User.php

@@ -58,8 +58,8 @@ class User extends Backend
                 ->paginate($limit);
                 ->paginate($limit);
 
 
    
    
-            $in  = model('Mongyin');
-            $out = model('Mongyout');
+            $in  = model('MoneyIn');
+            $out = model('MoneyOut');
             $path= model('UserPath');
             $path= model('UserPath');
             foreach ($list as &$item) {
             foreach ($list as &$item) {
                 $item->agent = $this->model->where('id', '=',  
                 $item->agent = $this->model->where('id', '=',  

+ 0 - 2
application/admin/lang/zh-cn.php

@@ -217,6 +217,4 @@ return [
 
 
     'Product management'                                    => '商品管理',
     'Product management'                                    => '商品管理',
     'Product list'                                          => '商品列表',
     'Product list'                                          => '商品列表',
-
-
 ];
 ];

+ 4 - 3
application/admin/lang/zh-cn/trade/mongyin.php → application/admin/lang/zh-cn/trade/money_in.php

@@ -17,7 +17,8 @@ return [
     'Update_time'  => '更新时间',
     'Update_time'  => '更新时间',
     'Confirm review'=> '确定执行该操作吗?',
     'Confirm review'=> '确定执行该操作吗?',
 
 
-    'Pending'       => '待处理',
-    'Success'       => '成功',
-    'Fail'          => '失败',
+    '待支付'           => '待支付',
+    '待处理'           => '待处理',
+    '成功'             => '成功',
+    '取消'             => '失败',
 ];
 ];

+ 0 - 0
application/admin/lang/zh-cn/trade/moneylog.php → application/admin/lang/zh-cn/trade/money_log.php


+ 0 - 0
application/admin/lang/zh-cn/trade/mongyout.php → application/admin/lang/zh-cn/trade/money_out.php


+ 0 - 0
application/admin/view/trade/mongyin/edit.html → application/admin/view/trade/money_in/edit.html


+ 0 - 0
application/admin/view/trade/mongyin/index.html → application/admin/view/trade/money_in/index.html


+ 0 - 0
application/admin/view/trade/mongyout/add.html → application/admin/view/trade/money_out/add.html


+ 0 - 0
application/admin/view/trade/mongyout/edit.html → application/admin/view/trade/money_out/edit.html


+ 0 - 0
application/admin/view/trade/mongyout/index.html → application/admin/view/trade/money_out/index.html


+ 85 - 21
application/api/controller/Money.php

@@ -4,7 +4,7 @@ namespace app\api\controller;
 
 
 use app\common\controller\Api;
 use app\common\controller\Api;
 use app\common\model\Config;
 use app\common\model\Config;
-use app\common\model\MongyIn;
+use app\common\model\MoneyIn;
 use app\common\model\Order AS OrderModel;
 use app\common\model\Order AS OrderModel;
 use app\common\model\User AS UserModel;
 use app\common\model\User AS UserModel;
 use think\Db;
 use think\Db;
@@ -93,7 +93,7 @@ class Money extends Api
         //写入
         //写入
         Db::startTrans();
         Db::startTrans();
         try {
         try {
-            (new MongyIn())->save($insert_data);
+            (new MoneyIn())->save($insert_data);
             Db::commit();
             Db::commit();
         } catch (Exception $e) {
         } catch (Exception $e) {
             $this->error($e->getMessage());
             $this->error($e->getMessage());
@@ -102,38 +102,102 @@ class Money extends Api
     }
     }
 
 
     /**
     /**
-     * 订单列表
+     * 上传图片
      * @return void
      * @return void
      * @throws \think\exception\DbException
      * @throws \think\exception\DbException
      */
      */
-    public function list()
+    public function recharge_upload()
     {
     {
         $user = $this->auth->getUser();
         $user = $this->auth->getUser();
-        $paginator = OrderModel::where('user_id', $user['id'])
-            ->field('order_no,amount,bonus,status,create_time')
-            ->order('id DESC')
-            ->paginate($this->pageSize);
-        foreach ($paginator as $k => $v) {
-            $paginator[$k]['status_name'] = (new OrderModel())->getStatusNames($v['status']);
-        }
-        $res_data = $this->buildResp($paginator->total(), $paginator->currentPage(), $paginator->items());
-        $res_data['bonus_sum'] = $user['bonus_sum'];
-        $this->success('', $res_data);
-    }
 
 
+        $order_no = $this->request->post('order_no');
+        if (empty($order_no)) {
+            $this->error(__('参数有误'));
+        }
+
+        $order_info = (new MoneyIn())
+            ->where('user_id', $user['id'])
+            ->where('order_no', $order_no)
+            ->find();
+        if (empty($order_no)) {
+            $this->error(__('参数有误'));
+        }
+
+        $file_info = ali_oss_upload($this->request, 'recharge', $order_no);
+        if($file_info['code'] == 0){
+            $this->error($file_info['msg']);
+        }
+
+        $this->success('', $file_info['data']);
+    }
     /**
     /**
-     * 获取订单
+     * 提交充值信息
      * @return void
      * @return void
      * @throws \think\exception\DbException
      * @throws \think\exception\DbException
      */
      */
-    public function get()
+    public function recharge_submit()
+    {
+        $user = $this->auth->getUser();
+
+        $order_no = $this->request->post('order_no');
+        $img_url = $this->request->post('img_url');
+
+        if (empty($order_no)) {
+            $this->error(__('参数有误'));
+        }
+
+        if (empty($img_url)) {
+            $this->error(__('参数有误'));
+        }
+
+        $order_info = (new MoneyIn())
+            ->where('user_id', $user['id'])
+            ->where('order_no', $order_no)
+            ->find();
+        if (empty($order_info)) {
+            $this->error(__('参数有误'));
+        }
+
+        if ($order_info['status'] != 0) {
+            if (empty($order_info['img_url'])) {
+                (new MoneyIn())
+                    ->where('order_no', $order_no)
+                    ->update([
+                        'img_url' => $img_url
+                    ]);
+            }
+            $this->success(__('提交成功'));
+        }
+
+        (new MoneyIn())
+            ->where('order_no', $order_no)
+            ->update([
+                'img_url' => $img_url,
+                'status'  => 1,
+            ]);
+        $this->success(__('提交成功'));
+    }
+
+    /**
+     * 提现
+     * @return void
+     */
+    public function withdraw()
     {
     {
         $user = $this->auth->getUser();
         $user = $this->auth->getUser();
 
 
-        $data['order_no']   = 'sn45784545';
-        $data['title']      = '商品标题111';
-        $data['amount']     = 4545;
-        $data['bonus']      = $user['bonus_sum'];
+        $data['balance']    = $user['balance'];
+        $data['usdt'] = $data['bank'] = 1;
+        $recharge_info = UserModel::getAgentInfoByAgentId($user['agent_id']);
+        if(empty($recharge_info)){
+            $this->error(__('无充值信息'));
+        }
+        if(empty($recharge_info['usdt'])){
+            $data['usdt'] = 0;
+        }
+        if(empty($recharge_info['bank'])){
+            $data['bank'] = 0;
+        }
 
 
         $this->success('', $data);
         $this->success('', $data);
     }
     }

+ 1 - 0
application/api/lang/zh-cn.php

@@ -5,4 +5,5 @@ return [
     '全部状态'                                         => '全部',
     '全部状态'                                         => '全部',
     '未定义'                                           => '未定义',
     '未定义'                                           => '未定义',
     '参数有误'                                         => '参数有误',
     '参数有误'                                         => '参数有误',
+    '提交成功'                                         => '提交成功,请等待处理',
 ];
 ];

+ 55 - 0
application/common.php

@@ -2,6 +2,9 @@
 
 
 // 公共助手函数
 // 公共助手函数
 
 
+use app\common\exception\UploadException;
+use OSS\OssClient;
+use think\Env;
 use think\exception\HttpResponseException;
 use think\exception\HttpResponseException;
 use think\Response;
 use think\Response;
 
 
@@ -561,6 +564,58 @@ EOT;
     }
     }
 }
 }
 
 
+if (!function_exists('ali_oss_upload')) {
+    /**
+     * 阿里云OSS上传
+     * @param string $suffix 后缀
+     * @param null   $background
+     * @return array
+     */
+    function ali_oss_upload(\think\Request $request, $file_path = null, $file_name = '')
+    {
+        //$file = $this->request->file('file');
+        $file = $request->file('file');
+        try {
+            $filename = $file->getInfo();
+            //获取oss实例
+            $ossClient = new OssClient(Env::get('oss.key_id'), Env::get('oss.key_secret'), Env::get('oss.endpoint'));
+            $bucket    = Env::get('oss.bucket');
+
+            $upload_path = Env::get('oss.directory') . "/" . $file_path . "/" . date("Ym") . "/";
+            //自定义文件名
+            if(empty($file_name)){
+                $upload_path .= $file->getInfo();
+            }else{
+                $extension = strtolower(pathinfo($file->getInfo('name'), PATHINFO_EXTENSION));  //扩展名
+                $upload_path .= $file_name . '.' . $extension;
+            }
+            $rs = $ossClient->uploadFile($bucket, $upload_path, $file->getRealPath());
+        } catch (UploadException $e) {
+            return _error($e->getMessage());
+        }
+        return _success(['full_url' => $rs['info']['url']]);
+    }
+}
+
+if (!function_exists('_success')) {
+    /**
+     * 返回成功标记信息
+     */
+    function _success($data = [])
+    {
+        return ['code' => 1, 'data' => $data];
+    }
+}
+
+if (!function_exists('_error')) {
+    /**
+     * 返回错误标记信息
+     */
+    function _error($msg = '', $data = [])
+    {
+        return ['code' => 0, 'msg' => $msg, 'data' => $data];
+    }
+}
 
 
 
 
 /**
 /**

+ 7 - 0
application/common/lang/zh-cn/money.php

@@ -0,0 +1,7 @@
+<?php
+
+return [
+    '待支付'           => '待支付zh-cn',
+    '成功'             => '成功',
+    '取消'             => '失败',
+];

+ 4 - 9
application/common/model/MongyOut.php → application/common/model/MoneyIn.php

@@ -5,15 +5,10 @@ namespace app\common\model;
 use think\Model;
 use think\Model;
 
 
 
 
-class MongyOut extends Model
+class MoneyIn extends Model
 {
 {
-
-    
-
-    
-
     // 表名
     // 表名
-    protected $name = 'mongy_out';
+    protected $name = 'money_in';
     
     
     // 自动写入时间戳字段
     // 自动写入时间戳字段
     protected $autoWriteTimestamp = 'int';
     protected $autoWriteTimestamp = 'int';
@@ -30,12 +25,12 @@ class MongyOut extends Model
     ];
     ];
     
     
 
 
-    
     //操作列表
     //操作列表
     public function getTypeList()
     public function getTypeList()
     {
     {
         return [1 => __('Usdt'), 2 => __('Bank')];
         return [1 => __('Usdt'), 2 => __('Bank')];
     }
     }
+    
 
 
     public function users()
     public function users()
     {
     {
@@ -46,7 +41,7 @@ class MongyOut extends Model
     {
     {
         return $this->hasOne('\app\admin\model\Admin','id','admin_id',[],'LEFT')->setEagerlyType(0);
         return $this->hasOne('\app\admin\model\Admin','id','admin_id',[],'LEFT')->setEagerlyType(0);
     }
     }
-    
+
     public function getCreateTimeTextAttr($value, $data)
     public function getCreateTimeTextAttr($value, $data)
     {
     {
         $value = $value ? $value : (isset($data['create_time']) ? $data['create_time'] : '');
         $value = $value ? $value : (isset($data['create_time']) ? $data['create_time'] : '');

+ 4 - 9
application/common/model/MongyIn.php → application/common/model/MoneyOut.php

@@ -5,15 +5,10 @@ namespace app\common\model;
 use think\Model;
 use think\Model;
 
 
 
 
-class MongyIn extends Model
+class MoneyOut extends Model
 {
 {
-
-    
-
-    
-
     // 表名
     // 表名
-    protected $name = 'mongy_in';
+    protected $name = 'money_out';
     
     
     // 自动写入时间戳字段
     // 自动写入时间戳字段
     protected $autoWriteTimestamp = 'int';
     protected $autoWriteTimestamp = 'int';
@@ -30,12 +25,12 @@ class MongyIn extends Model
     ];
     ];
     
     
 
 
+    
     //操作列表
     //操作列表
     public function getTypeList()
     public function getTypeList()
     {
     {
         return [1 => __('Usdt'), 2 => __('Bank')];
         return [1 => __('Usdt'), 2 => __('Bank')];
     }
     }
-    
 
 
     public function users()
     public function users()
     {
     {
@@ -46,7 +41,7 @@ class MongyIn extends Model
     {
     {
         return $this->hasOne('\app\admin\model\Admin','id','admin_id',[],'LEFT')->setEagerlyType(0);
         return $this->hasOne('\app\admin\model\Admin','id','admin_id',[],'LEFT')->setEagerlyType(0);
     }
     }
-
+    
     public function getCreateTimeTextAttr($value, $data)
     public function getCreateTimeTextAttr($value, $data)
     {
     {
         $value = $value ? $value : (isset($data['create_time']) ? $data['create_time'] : '');
         $value = $value ? $value : (isset($data['create_time']) ? $data['create_time'] : '');

+ 4 - 4
public/assets/js/backend/trade/mongyin.js → public/assets/js/backend/trade/money_in.js

@@ -5,8 +5,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
             // 初始化表格参数配置
             // 初始化表格参数配置
             Table.api.init({
             Table.api.init({
                 extend: {
                 extend: {
-                    index_url: 'trade/mongyin/index' + location.search,
-                    table: 'mongy_in',
+                    index_url: 'trade/money_in/index' + location.search,
+                    table: 'money_in',
                 }
                 }
             });
             });
 
 
@@ -34,7 +34,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         {field: 'account_name', title: __('Account_name'), operate: 'LIKE'},
                         {field: 'account_name', title: __('Account_name'), operate: 'LIKE'},
                         {field: 'amount', title: __('Amount'), operate:'BETWEEN'},
                         {field: 'amount', title: __('Amount'), operate:'BETWEEN'},
                         {field: 'status', title: __("Status"), 
                         {field: 'status', title: __("Status"), 
-                            searchList: {0:__('Pending'), 1:__('Success'), 2:__('Fail')}, 
+                            searchList: {0:__('待支付'), 1:__('待处理'), 3:__('成功'), 2:__('取消')},
                             formatter: Table.api.formatter.status
                             formatter: Table.api.formatter.status
                         },
                         },
                         {field: 'admins.nickname', title: __('Admin_id')},
                         {field: 'admins.nickname', title: __('Admin_id')},
@@ -47,7 +47,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                                 text:  __('Review'),
                                 text:  __('Review'),
                                 classname: 'btn btn-xs btn-danger btn-magic btn-ajax',
                                 classname: 'btn btn-xs btn-danger btn-magic btn-ajax',
                                 confirm: __('Confirm review'),
                                 confirm: __('Confirm review'),
-                                url: 'trade/mongin/review',
+                                url: 'trade/money_in/review',
                                 visible: function (row) {
                                 visible: function (row) {
                                     //if(row.status == 0 && parseFloat(row.users.balance) >= parseFloat(row.amount)){
                                     //if(row.status == 0 && parseFloat(row.users.balance) >= parseFloat(row.amount)){
                                         return true;
                                         return true;

+ 1 - 1
public/assets/js/backend/trade/moneylog.js → public/assets/js/backend/trade/money_log.js

@@ -5,7 +5,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
             // 初始化表格参数配置
             // 初始化表格参数配置
             Table.api.init({
             Table.api.init({
                 extend: {
                 extend: {
-                    index_url: 'trade/moneylog/index' + location.search +'&user_id='+Config.user_id,
+                    index_url: 'trade/money_log/index' + location.search +'&user_id='+Config.user_id,
                     table: 'money_log',
                     table: 'money_log',
                 }
                 }
             });
             });

+ 4 - 4
public/assets/js/backend/trade/mongyout.js → public/assets/js/backend/trade/money_out.js

@@ -5,8 +5,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
             // 初始化表格参数配置
             // 初始化表格参数配置
             Table.api.init({
             Table.api.init({
                 extend: {
                 extend: {
-                    index_url: 'trade/mongyout/index' + location.search,
-                    table: 'mongy_out',
+                    index_url: 'trade/money_out/index' + location.search,
+                    table: 'money_out',
                 }
                 }
             });
             });
 
 
@@ -50,7 +50,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                                 text:  __('Success'),
                                 text:  __('Success'),
                                 classname: 'btn btn-xs btn-success btn-magic btn-ajax',
                                 classname: 'btn btn-xs btn-success btn-magic btn-ajax',
                                 confirm: __('Confirm review'),
                                 confirm: __('Confirm review'),
-                                url: 'trade/mongyout/review/status/1',
+                                url: 'trade/money_out/review/status/1',
                                 visible: function (row) {
                                 visible: function (row) {
                                     if(row.status == 0) return true;
                                     if(row.status == 0) return true;
                                     return false;
                                     return false;
@@ -62,7 +62,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                                 text:  __('Fail'),
                                 text:  __('Fail'),
                                 classname: 'btn btn-xs btn-danger btn-magic btn-ajax',
                                 classname: 'btn btn-xs btn-danger btn-magic btn-ajax',
                                 confirm: __('Confirm review'),
                                 confirm: __('Confirm review'),
-                                url: 'trade/mongyout/review/status/2',
+                                url: 'trade/money_out/review/status/2',
                                 visible: function (row) {
                                 visible: function (row) {
                                     if(row.status == 0) return true;
                                     if(row.status == 0) return true;
                                     return false;
                                     return false;

+ 1 - 0
public/eUmZFWDnVH.php

@@ -35,3 +35,4 @@ require __DIR__ . '/../thinkphp/base.php';
 
 
 // 执行应用
 // 执行应用
 \think\App::run()->send();
 \think\App::run()->send();
+