Эх сурвалжийг харах

Merge branch 'dev' of Teapay/RWACha-API into master

小董 1 сар өмнө
parent
commit
30c9a5629f

+ 1 - 1
.env.sample

@@ -1,5 +1,5 @@
 [app]
-debug = true
+debug = false
 trace = false
 
 [database]

+ 71 - 3
application/admin/controller/offline/OfflineRecharge.php

@@ -31,7 +31,7 @@ class OfflineRecharge extends Backend
      * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
      * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
      */
-       /**
+    /**
      * 查看
      *
      * @return string|Json
@@ -42,6 +42,14 @@ class OfflineRecharge extends Backend
     {
         //设置过滤方法
         $this->request->filter(['strip_tags', 'trim']);
+        $filter = $this->request->get('filter');
+        $filter = json_decode($filter, true);
+        $data=$filter;
+        // 统一计算统计值
+        $amount = $this->get($filter,'amount');
+        $cha_bao = $this->get($filter,'cha_bao');
+
+
         if (false === $this->request->isAjax()) {
             return $this->view->fetch();
         }
@@ -54,9 +62,69 @@ class OfflineRecharge extends Backend
             ->where($where)
             ->order($sort, $order)
             ->paginate($limit);
-  
-        $result = ['total' => $list->total(), 'rows' => $list->items(), 'total_revenue'=> 669];
+
+        
+
+        $result = ['total' => $list->total(), 'rows' => $list->items(), 'amount' => $amount, 'cha_bao' => $cha_bao, 'total_revenue' => 669];
         return json($result);
     }
+    private function get($filter,$key){
+        
+
+
+        // 统一时间范围解析
+        $createTimeRange = $this->parseTimeRange('create_time', $filter);
+        $updateTimeRange = $this->parseTimeRange('update_time', $filter);
+        $amountRange = $this->parseAmountRange('amount', $filter);
+
+        // 构建基础查询
+        $query = $this->model->where($filter);
+
+        // 添加时间条件
+        if (!empty($createTimeRange)) {
+            $query->whereTime('create_time', $createTimeRange);
+        }
+        if (!empty($updateTimeRange)) {
+            $query->whereTime('update_time', $updateTimeRange);
+        }
+
+        if (!empty($amountRange)) {
+            $query->whereBetween('amount', $amountRange);
+        }
+        
+
+
+        // 统一计算统计值
+        return $query->sum($key);
+
+        
+    }
+    private function parseTimeRange($key, &$filter)
+    {
+
+        if (isset($filter[$key])) {
+            list($startTime, $endTime) = explode(' - ', $filter[$key]);
+            $time = [
+                trim($startTime), // 去除可能存在的空格
+                trim($endTime)
+            ];
+            unset($filter[$key]);
+            return $time;
+        }
+        return [];
+    }
+    private function parseAmountRange($key, &$filter)
+    {
 
+        if (isset($filter[$key])) {
+            list($startTime, $endTime) = explode(',', $filter[$key]);
+            $time = [
+                trim($startTime), // 去除可能存在的空格
+                trim($endTime)
+            ];
+            unset($filter[$key]);
+            return $time;
+        }
+        return [];
+    }
 }

+ 65 - 20
application/admin/controller/user/Userpledge.php

@@ -13,7 +13,7 @@ use think\Loader;
 use app\common\model\LedgerTeacChangeModel;
 use think\exception\PDOException;
 use think\exception\ValidateException;
-
+use think\Request;
 /**
  * 用户存储列表 TeamRewards
  *
@@ -27,12 +27,12 @@ class Userpledge extends Backend
      * @var \app\admin\model\TeamRewards
      */
     protected $model = null;
-
+    protected $product_order_model = null;
     public function _initialize()
     {
         parent::_initialize();
         $this->model = new \app\common\model\UserPledge;
-
+        $this->product_order_model = new \app\common\model\ProductOrder;
     }
 
 
@@ -57,10 +57,10 @@ class Userpledge extends Backend
         }
         [$where, $sort, $order, $offset, $limit] = $this->buildparams();
         $list     = $this->model->with('users,pledges')
-                 ->where($where)
-                 ->order($sort, $order)
-                 ->paginate($limit);
-      
+            ->where($where)
+            ->order($sort, $order)
+            ->paginate($limit);
+
         $result = ['total' => $list->total(), 'rows' => $list->items()];
         return json($result);
     }
@@ -71,19 +71,65 @@ class Userpledge extends Backend
      */
     public function detail($ids)
     {
+
         $row = $this->model->get(['id' => $ids]);
         if (!$row) {
             $this->error(__('No Results were found'));
         }
+
         if ($this->request->isAjax()) {
             $this->success("Ajax请求成功", null, ['id' => $ids]);
         }
+
         $details = json_decode($row->details, true);
+ 
+        // 提取所有id,返回一个包含id的一维数组
+        $order_no = array_column($details, 'order_no');
+
+        $orderData = $this->product_order_model
+            ->where('order_no', 'in', $order_no)
+            ->field('order_no, status') // 指定字段
+            ->select();
+        $status_txt=['已下单','支付','转让','提货','取消','关闭','存储中'];
+        // 合并 status 到主数据
+        foreach ($details as &$item_outside) {
+            foreach ($orderData as &$item_inside) {
+                if($item_outside['order_no']==$item_inside['order_no']){
+                    $status=$item_inside['status'];
+                    $item_outside['status']=$status;
+                    $item_outside['status_txt']=$status_txt[$status];
+                }
+            }
+            
+        }
+        $userpledge_status=$row['status'];
+        
+        $this->view->assign("userpledge_status", $userpledge_status);
+        $this->view->assign("userpledge_id", $ids);
         $this->view->assign("row", $details);
         return $this->view->fetch();
     }
 
-
+    /**
+     * 取消存储
+     */
+    public function cancelStorage(){
+        $id = $this->request->param('id');
+        $userpledgeId = $this->request->param('userpledgeId');
+        $row = $this->model->get(['id' => $userpledgeId]);
+        $userpledge_status=$row['status'];
+        if($userpledge_status==0){
+            $resp=$this->product_order_model->where('id', $id)->update(['status' => 0]);
+            if($resp){
+                $this->success(__('取消成功'), '');
+            }
+            
+        }
+        $this->error(__('操作失败'));
+        
+       
+        
+    }
     /**
      * 编辑
      *
@@ -117,29 +163,29 @@ class Userpledge extends Backend
             }
 
             $rows   = $this->model::alias('a')
-                    ->join('product_pledge b', 'a.pledge_id = b.id', 'left')
-                    ->where('a.id', $ids)->where('a.status', UserPledgeModel::Ongoing)
-                    ->field('a.*,b.day_num')
-                    ->find();
-            if(empty($rows))  throw new Exception('暂无质押订单');
+                ->join('product_pledge b', 'a.pledge_id = b.id', 'left')
+                ->where('a.id', $ids)->where('a.status', UserPledgeModel::Ongoing)
+                ->field('a.*,b.day_num')
+                ->find();
+            if (empty($rows))  throw new Exception('暂无质押订单');
             $day   = 86400;
             $total = 0; //当前累计收益
             $time  = time();
             $reta  = bcdiv($rows->day_num, $day, 6); //天数
-            $inter = ($rows->last_time == 0) ? $time - $rows->create_time: $time - $rows->last_time; //最后收取时间
+            $inter = ($rows->last_time == 0) ? $time - $rows->create_time : $time - $rows->last_time; //最后收取时间
             $total = bcmul($reta, $inter, 6) * $rows->num; //累计收益
-            $rows->total_self= bcadd($total, $rows->total_self, 6);
-    
+            $rows->total_self = bcadd($total, $rows->total_self, 6);
+
             //修改状态
-            $detail =json_decode($rows->details, true);
+            $detail = json_decode($rows->details, true);
             ProductOrder::whereIn('id', array_column($detail, 'id'))->setField('status', ProductOrder::Paid);
 
-            Loader::model('LedgerWalletModel')->changeWalletAccount($rows->user_id, Asset::TEAC, $total, LedgerTeacChangeModel::Pledge, 0); 
+            Loader::model('LedgerWalletModel')->changeWalletAccount($rows->user_id, Asset::TEAC, $total, LedgerTeacChangeModel::Pledge, 0);
             $rows->last_time = $time;
             $rows->status = UserPledgeModel::Close;
             $result = $rows->save();
             Db::commit();
-        } catch (ValidateException|PDOException|Exception $e) {
+        } catch (ValidateException | PDOException | Exception $e) {
             Db::rollback();
             $this->error($e->getMessage());
         }
@@ -148,5 +194,4 @@ class Userpledge extends Backend
         }
         $this->success();
     }
-
 }

+ 2 - 1
application/admin/lang/zh-cn/user/userpledge.php

@@ -11,5 +11,6 @@ return [
     'Status'          => '状态',
     'End_time'        => '到期时间',
     'Create_time'     => '创建时间',
-    'Update_time'     => '更新时间'
+    'Update_time'     => '更新时间',
+    'Cancel storage'  => '取消存储',
 ];

+ 13 - 1
application/admin/view/offline/offline_recharge/index.html

@@ -7,11 +7,23 @@
 
     <div class="panel-body">
         <div id="myTabContent" class="tab-content">
+
             <div class="tab-pane fade active in" id="one">
                 <div class="widget-body no-padding">
                     <div id="toolbar" class="toolbar">
                         <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
-                     
+                        <a href="javascript:;" class="btn btn-default" style="font-size:14px;color:#23b7e5;">
+                            <!-- <i class="fa fa-dollar"></i> -->
+                            <span class="extend">
+                                USDT:<span id="amount">0</span>
+                            </span>
+                        </a>
+                        <a href="javascript:;" class="btn btn-default" style="font-size:14px;color:#27C24C;">
+                            <!-- <i class="fa fa-dollar"></i> -->
+                            <span class="extend">
+                                茶宝:<span id="cha_bao">0</span>
+                            </span>
+                        </a>
                     </div>
                     <table id="table" class="table table-striped table-bordered table-hover table-nowrap"
                            data-operate-edit=""

+ 108 - 6
application/admin/view/user/userpledge/detail.html

@@ -1,27 +1,129 @@
+<!-- <link href="__CDN__/assets/libs/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet"> -->
+<script src="__CDN__/assets/libs/jquery/dist/jquery.min.js"></script>
+<script src="__CDN__/assets/libs/bootstrap/dist/js/bootstrap.min.js"></script>
+
+<script src="__CDN__/assets/libs/sweetalert/sweetalert.min.js"></script>
+<style>
+    .confirm-btn {
+        background-color: #f75444 !important;
+        color: white !important;
+    }
+</style>
+
 <table class="table table-striped">
+
     <thead>
         <tr>
             <th>{:__('订单ID')}</th>
             <th>{:__('订单号')}</th>
             <th>{:__('商品')}</th>
             <th>{:__('图片')}</th>
+            <th>{:__('状态')}</th>
         </tr>
     </thead>
     <tbody>
-        {volist name="row" id="vo"  }
+        {volist name="row" id="vo" }
         <tr>
             <td>{$vo.id}</td>
             <td>{$vo.order_no}</td>
-            <td >{$vo.zh_name|htmlentities}</td>
-            <td ><img src="{$vo.thum|htmlentities}" width="100px" height="80px"></td>
+            <td>{$vo.zh_name|htmlentities}</td>
+            <td><img src="{$vo.thum|htmlentities}" width="100px" height="80px"></td>
+            <td>
+
+                {switch name="vo.status"}
+                {case value="0"}
+                <span class="label label-success">{$vo.status_txt}</span>
+                {/case}
+                {case value="1"}
+                <span class="label label-success">{$vo.status_txt}</span>
+                {/case}
+                {case value="2"}
+                <span class="label label-success">{$vo.status_txt}</span>
+                {/case}
+                {case value="3"}
+                <span class="label label-success">{$vo.status_txt}</span>
+                {/case}
+                {case value="4"}
+                <span class="label label-danger">{$vo.status_txt}</span>
+                {/case}
+                {case value="5"}
+                <span class="label label-default">{$vo.status_txt}</span>
+                {/case}
+                {case value="6"}
+                <span class="label label-success">{$vo.status_txt}</span>
+                {eq name="userpledge_status" value="0"}
+                <a href="javascript:;" class="btn btn-xs btn-danger cancelStorage" data-id="{$vo.id}"
+                    data-userpledge_id="{$userpledge_id}">{:__('Cancel storage')}</a>
+                
+                {/eq}
+
+                {/case}
+                {default /}
+                {/switch}
+            </td>
         </tr>
         {/volist}
-     
+
     </tbody>
 </table>
 <div class="hide layer-footer">
     <label class="control-label col-xs-12 col-sm-2"></label>
     <div class="col-xs-12 col-sm-8">
-        <button type="reset" class="btn btn-primary btn-embossed btn-close" onclick="Layer.closeAll();">{:__('Close')}</button>
+        <button type="reset" class="btn btn-primary btn-embossed btn-close"
+            onclick="Layer.closeAll();">{:__('Close')}</button>
     </div>
-</div>
+</div>
+<script>
+    $(function () {
+        $(".cancelStorage").click(function () {
+            var id = $(this).data('id');
+            var userpledgeId = $(this).data('userpledge_id');
+
+            swal({
+                title: "取消存储",
+                icon: "warning",
+                buttons: {
+                    cancel: "取消",
+                    catch: {
+                        text: "确认",
+                        value: "catch",
+                        className: "confirm-btn"
+                    }
+                },
+                dangerMode: true,
+            }
+
+            )
+                .then((willDelete) => {
+                    if (willDelete) {
+                        $.ajax({
+                        url: "user/Userpledge/cancelStorage",
+                        type: "POST",
+                        data: { id: id, userpledgeId: userpledgeId },
+                        dataType: "json",
+                        success: function (response) {
+                            let code = response.code;
+                            if (code == 1) {
+                                window.location.reload(); // 刷新父页面
+                            }
+                        },
+                        error: function (xhr, status, error) {
+                            console.error("请求失败", error);
+                        },
+                        complete: function () {
+                            console.log("请求完成(无论成功/失败)");
+                        }
+                    });
+                    } else {
+                        // console.log("取消")
+                    }
+                });
+            
+        })
+
+
+
+    })
+
+
+</script>

+ 1 - 1
application/admin/view/user/userpledge/index.html

@@ -1,6 +1,6 @@
 <div class="panel panel-default panel-intro">
     {:build_heading()}
-
+    
     <div class="panel-body">
         <div id="myTabContent" class="tab-content">
             <div class="tab-pane fade active in" id="one">

+ 8 - 6
application/api/common.php

@@ -2,7 +2,6 @@
 
 use app\common\library\EthSign;
 use fast\Random;
-
 /**
  * 生成随机hash值
  * @param int $uid
@@ -22,7 +21,7 @@ function randTxHash(int $uid): string
  */
 function checkSign(string $msg, $sign, $address): bool
 {
-//        return true; // 调试
+    //        return true; // 调试
     if (empty($msg) || empty($sign) || empty($address)) {
         return false;
     }
@@ -56,13 +55,14 @@ function getConfig(string $name): string
 }
 
 //获取语言
-function getLangKey( $lan = 'zh'): int
+function getLangKey($lan = 'zh'): int
 {
     $toLang = ['zh' => 0, 'en' => 1];
     return $toLang[$lan];
 }
 //判断是否是erc20地址
-function isErc20AddressValid($address) {
+function isErc20AddressValid($address)
+{
     // 去掉地址的 "0x" 前缀
     $address = trim($address);
     if (substr($address, 0, 2) == '0x') {
@@ -74,6 +74,8 @@ function isErc20AddressValid($address) {
 }
 
 //判断绝对路径
-function isHttpOrHttps($url) {
+function isHttpOrHttps($url)
+{
     return strpos($url, 'http://') === 0 || strpos($url, 'https://') === 0;
-}
+}
+

+ 2 - 0
application/common/lang/zh-cn/addon.php

@@ -94,4 +94,6 @@ return [
     'You have no permission'                      => '你没有权限访问',
     'An unexpected error occurred'                => '发生了一个意外错误,程序猿正在紧急处理中',
     'This page will be re-directed in %s seconds' => '页面将在 %s 秒后自动跳转',
+  
+    
 ];

+ 17 - 11
application/extra/site.php

@@ -1,10 +1,10 @@
 <?php
 
 return array (
-  'name' => '掘金路',
+  'name' => 'RWA茶',
   'beian' => '',
   'cdnurl' => '',
-  'version' => '1.0.7',
+  'version' => '1.0.40',
   'timezone' => 'Asia/Shanghai',
   'forbiddenip' => '',
   'languages' => 
@@ -38,17 +38,23 @@ return array (
     'custom' => '自定义',
   ),
   'direct_income' => '10',
-  'transfer_fee' => '0.8',
-  'transfes_txt' => '收取交易百分之五',
-  'recharge_txt' => 'xxddddss',
-  'chabao_rate' => '0.7',
+  'transfer_fee' => '0.045',
+  'recharge_txt' => '1.仅支持本钱包地址上的USDT 充值,充值前请确认余额充足。</br>2.到账时间约 5~10 分钟。</br>3.USDT 和茶宝的充值比例为 1:1。',
+  'chabao_rate' => '1',
   'withdrawal_next_fee' => '3',
-  'withdrawal_up_fee' => '0.1',
   'withdraw_min_amount' => '100',
-  'convert_rate' => '7.2',
+  'convert_rate' => '1',
+  'withdrawal_up_fee' => '0.01',
+  'giveaway_txt' => '1.通过平台向其它地址赠送商品或资产时,将收取 4.5% 网络费。<br />2.网络费按该产品市场地板价(无地板价按起售价)为基数计算。<br />3.请务必核实接收方信息及赠送内容,赠送操作一旦完成不可撤回。',
   'pv_rate' => '0.1',
-  'chabao_giveaway' => '0.03',
-  'chabao_giveaway_txt' => '标记茶宝转账',
+  'chabao_giveaway' => '0.01',
+  'chabao_giveaway_txt' => '1.请务必核实接收方的地址,转账操作一旦完成不可撤回。</br>2.转账收取 1% 网络费,对方将收到你转账数额的 99%。',
+  'transfes_txt' => '1.寄售商品未经售出前,可取消寄售订单。取消寄售后 3 分钟禁止寄售,一经售出,无法取消寄售。<br />2.您将获得除综合服务费(4.5%)之外的所有寄售收入。<br />3.寄售成功后,寄售收入将默认进入茶宝账户余额。',
+  'logistics_freight' => '6',
   'frozen_transfer' => '0.03',
-  'frozen_transfer_txt' => '标记茶宝转账4xxxxx',
+  'frozen_transfer_txt' => '1. 手续费账户的茶宝可用于支付交易手续费使用,支持转账到其他手续费账户,不可消费和提现。 
+<br>2.转账收取 3% 网络费。',
+  'withdraw_desc' => '1.茶宝提现指的是将茶宝转化为 USDT,并提到本账户钱包地址,请确保转出地址正常和数额无误。</br>
+2.提现后由平台管理员审核,如无异常将于48小时之内完成审核并转入提现地址,您可在右上角明细中查看订单进度。</br>
+3.提现手续费:300 茶宝以内每笔 3 茶宝,300 茶宝以上(含) 1%。',
 );

+ 13 - 0
public/assets/js/backend/offline/offline_recharge.js

@@ -47,6 +47,19 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
 
             // 为表格绑定事件
             Table.api.bindevent(table);
+
+            //当表格数据加载完成时
+            table.on('load-success.bs.table', function (e, data) {
+                //这里可以获取从服务端获取的JSON数据
+                
+                let amount=data['amount'];
+                let cha_bao=data['cha_bao']
+                //手动设置底部的值
+                $("#amount").text(amount);
+                
+                $("#cha_bao").text(cha_bao);
+            });
+
         },
         add: function () {
             Controller.api.bindevent();

+ 3 - 0
public/assets/js/backend/user/userpledge.js

@@ -74,8 +74,11 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
         },
         api: {
             bindevent: function () {
+                // 原有表单绑定
                 Form.api.bindevent($("form[role=form]"));
+                
             }
+            
         }
     };
     return Controller;

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 0
public/assets/libs/sweetalert/sweetalert.min.js


Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно