Browse Source

对接易付通

NimaQu 7 năm trước cách đây
mục cha
commit
2b8da2f37a

+ 3 - 1
README.md

@@ -12,6 +12,8 @@ telegram交流群:https://t.me/joinchat/Fjn0HkeqdoovkJgTRnvoNw
 
 **此面板作者为**[galaxychuck](https://github.com/galaxychuck),因某些原因删除仓库,现代为上传
 
+**作者Paypal打賞:[email protected]**
+
 本人不懂编程,不接受功能需求及面板搭建失败之类issus,欢迎dalao提交pr
 
 本面板在[宝塔面板5.6.0](www.bt.cn),宝塔安装版 nginx1.12,php 7.1 ,mysql 5.7 上全部功能测试通过
@@ -70,4 +72,4 @@ Image:
 
 它不会影响美观并可以给开发者很大的支持和动力。~~听说删除staff的网站都会遭遇未知DDOS攻击~~
 
-在这里感谢魔改后花园里所有帮助过我们的人
+在这里感谢魔改后花园里所有帮助过我们的人

+ 19 - 0
app/Controllers/PayConfig.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Controllers;
+
+class PayConfig{
+
+    public $pay_config;
+
+    public function init()
+    {
+        $this->pay_config = [
+            "secret" => "9A30EEBF727DE9A98B6AF916C2BCCA75",
+            "accesskey" => "C390D630A2B48094854048740A3900D9",
+            "notify_url" => "/yft/notify",
+            "return_url" => "/yft/notify",
+            "type" => "aliPay"
+        ];
+    }
+}

+ 107 - 0
app/Controllers/QuickPayFunction.php

@@ -0,0 +1,107 @@
+<?php
+
+namespace App\Controllers;
+
+use app\Utils\YftOrderNumUtil;
+
+class QuickPayFunction{
+    public function md5Verify($p1, $p2,$p3,$p4,$sign) {
+        $preStr = $p1.$p2.$p3.$p4;
+        $mySign = md5($preStr);
+//        echo $mySign;
+        if($mySign == $sign) {
+            return true;
+        }else {
+            return false;
+        }
+    }
+
+    /**
+     * 建立请求,以表单HTML形式构造(默认)
+     * @param $para_temp 请求参数数组
+     *
+     */
+    public function buildRequestForm($para_temp,$ss_order_no,$pay_config) {
+        //待请求参数数组
+        $para = QuickPayFunction::buildRequestPara($para_temp);
+
+
+        $sHtml = "<form id='paysubmit' name='paysubmit' action='https://pay.anypay.me/pay/subOrder/zfb' accept-charset='utf-8' method='POST'>";
+        while (list ($key, $val) = each ($para)) {
+            $sHtml.= "<input type='hidden' name='".$key."' value='".$val."'/>";
+        }
+        if ($pay_config->pay_config["type"] == "aliPay"){
+            $sHtml .= "<input type='hidden' name='subject' value='余额充值'/>";
+        }else{
+            $sHtml .= "<input type='hidden' name='trade_no' value='".$ss_order_no."'/>";
+        }
+        //submit按钮控件请不要含有name属性
+        $sHtml = $sHtml."</form>";
+
+        $sHtml = $sHtml."<script>document.forms['paysubmit'].submit();</script>";
+
+        return $sHtml;
+    }
+    /**
+     * 生成要请求给云通付的参数数组
+     * @param $para_temp 请求前的参数数组
+     * @return 要请求的参数数组
+     */
+    static function buildRequestPara($para_temp) {
+        //除去待签名参数数组中的空值和签名参数
+        $para_filter = QuickPayFunction::paraFilter($para_temp);
+        //生成签名结果
+        $mysign = QuickPayFunction::buildRequestMysign($para_filter);
+
+        //签名结果与签名方式加入请求提交参数组中
+        $para_filter['sign'] = $mysign;
+
+        return $para_filter;
+    }
+    /**
+     * 除去数组中的空值和签名参数
+     * @param $para 签名参数组
+     * return 去掉空值与签名参数后的新签名参数组
+     */
+    static function paraFilter($para) {
+        $para_filter = array();
+        while (list ($key, $val) = each ($para)) {
+            if($key == "sign" || $val == "")continue;
+            else	$para_filter[$key] = $para[$key];
+        }
+        return $para_filter;
+    }
+    /**
+     * 生成签名结果
+     * @param $para_filter 要签名的数组
+     * return 签名结果字符串
+     */
+    static function buildRequestMysign($para_filter) {
+        //把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串
+        $prestr = QuickPayFunction::createLinkstring($para_filter);
+        $mysign = MD5($prestr);
+        return $mysign;
+    }
+    static function md5Sign($prestr) {
+        return md5($prestr);
+    }
+    /**
+     * 把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串
+     * @param $para 需要拼接的数组
+     * return 拼接完成以后的字符串
+     */
+    static function createLinkstring($para) {
+        $arg  = "";
+        while (list ($key, $val) = each ($para)) {
+            $arg.=$key."=".$val."&";
+        }
+        //去掉最后一个&字符
+        $arg = substr($arg,0,count($arg)-2);
+
+        //如果存在转义字符,那么去掉转义
+        if(get_magic_quotes_gpc()){$arg = stripslashes($arg);}
+
+        return $arg;
+    }
+
+}

+ 128 - 0
app/Controllers/YFTPayCallBackController.php

@@ -0,0 +1,128 @@
+<?php
+/**
+ * Created by 傲慢与偏见.
+ * User: Administrator
+ * Date: 2017/11/21
+ * Time: 8:57
+ *
+ *       虽然代码开源,但是请别直接照搬好吗?直接照搬也别改的面目全非好吗?改的面目全非也别删除注释好吗?
+ *
+ *       抄代码之前想想为什么这样写,这样才能有提高。建议你去学学面向对象编程方式。
+ *
+ *       另外,我看了你的代码,真的写的很烂,乱。
+ *
+ */
+
+namespace App\Controllers;
+
+use App\Models\Payback;
+use App\Models\User;
+use App\Models\YftOrder;
+use App\Services\Config;
+use App\Utils\Telegram;
+
+class YFTPayCallBackController
+{
+    public function yft_notify($request)
+    {
+        //价格
+        $total_fee = $request->getQueryParams()["total_fee"];//必填
+        //易付通返回的订单号
+        $yft_order_no = $request->getQueryParams()["trade_no"];
+        //面板生成的订单号
+        $ss_order_no = $request->getQueryParams()["out_trade_no"];//必填
+        //订单说明
+        $subject = $request->getQueryParams()["subject"];//必填
+        //付款状态
+        $trade_status = $request->getQueryParams()["trade_status"];//必填
+        //加密验证字符串
+        $sign = $request->getQueryParams()["sign"];//必填
+
+        $verifyNotify = YFTPayCallBackController::md5Verify(floatval($total_fee), $ss_order_no, $yft_order_no, $trade_status, $sign);
+        if ($verifyNotify) {//验证成功
+            if ($trade_status == 'TRADE_SUCCESS') {
+                /*
+                加入您的入库及判断代码;
+                >>>>>>>!!!为了保证数据传达到回调地址,会请求4次。所以必须要先判断订单状态,然后再插入到数据库,这样后面即使请求3次,也不会造成订单重复!!!!<<<<<<<
+                判断返回金额与实金额是否想同;
+                判断订单当前状态;
+                完成以上才视为支付成功
+                */
+                $orderInfo = new YftOrder();
+                $orderInfo = $orderInfo->where("ss_order", "=", $ss_order_no)->first();
+                if ($orderInfo == "" || $orderInfo == null) {
+                    return "订单不存在!";
+                }
+
+                if ($orderInfo->price != $total_fee) {
+                    return "订单信息异常!";
+                }
+
+                $userInfo = new User();
+                $userInfo = $userInfo->where("id", "=", $orderInfo->user_id)->first();
+
+                if (sizeof($orderInfo) != 0 && $orderInfo->state == 0) {
+                    $oldMoney = $userInfo->money;
+                    $userInfo->money = $total_fee + $oldMoney;
+                    //更新用户余额信息
+                    $userInfo->save();
+                    //更新订单信息
+                    $orderInfo->yft_order = $yft_order_no;
+                    $orderInfo->state = 1;
+                    $orderInfo->save();
+                    //充值返利处理 start
+                    if ($userInfo->ref_by != "" && $userInfo->ref_by != 0 && $userInfo->ref_by != null && Config::get('code_payback') != 0 && Config::get('code_payback') != null) {
+                        $gift_user = User::where("id", "=", $userInfo->ref_by)->first();
+                        $gift_user->money = ($gift_user->money + ($total_fee * (Config::get('code_payback') / 100)));
+                        $gift_user->save();
+
+                        $Payback = new Payback();
+                        $Payback->total = $total_fee;
+                        $Payback->userid = $userInfo->id;
+                        $Payback->ref_by = $userInfo->ref_by;
+                        $Payback->ref_get = $total_fee * (Config::get('code_payback') / 100);
+                        $Payback->datetime = time();
+                        $Payback->save();
+                    }
+                    //充值返利处理 end
+                    //telegram提醒
+                    if (Config::get('enable_donate') == 'true' && Config::get("enable_telegram") == 'true') {
+                        if ($userInfo->is_hide == 1) {
+                            Telegram::Send("感谢!一位不愿透露姓名的大老爷给我们捐了 " . $total_fee . " 元呢~");
+                        } else {
+                            Telegram::Send("感谢!" . $userInfo->user_name . " 大老爷给我们捐了 " . $total_fee . " 元呢~");
+                        }
+                    }
+                } else {
+                    return "订单号异常或交易已完成!";
+                }
+                header("location:" . $request->getUri()->getScheme() . "://" . $request->getUri()->getHost() . "/user/code");
+                return "支付成功";
+            } else {
+                return "支付失败";
+            }
+        } else {
+            //验证失败
+            return "订单信息异常!请联系管理员";
+        }
+    }
+
+    /**
+     * @param $p1
+     * @param $p2
+     * @param $p3
+     * @param $p4
+     * @param $sign 传入要比对的sign
+     * @return boolean 返回比对结果
+     */
+    private static function md5Verify($p1, $p2, $p3, $p4, $sign)
+    {
+        $preStr = $p1 . $p2 . $p3 . $p4 . "yft";
+        $mySign = md5($preStr);
+        if ($mySign == $sign) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+}

+ 193 - 0
app/Controllers/YftPay.php

@@ -0,0 +1,193 @@
+<?php
+/**
+ * Created by 傲慢与偏见.
+ * OSUser: D-L
+ * Date: 2017/10/12
+ * Time: 21:08
+ */
+
+namespace App\Controllers;
+
+
+use App\Models\User;
+use App\Models\YftOrder;
+use App\Services\Auth;
+use App\Utils\YftOrderNumUtil;
+
+class YftPay extends BaseController
+{
+    private $user;
+
+    public function __construct()
+    {
+        $this->user = Auth::getUser();
+    }
+
+    public function yft($request, $response, $args)
+    {
+        $price = $request->getParams()['price'];
+        return $this->view()->assign('price', $price)->display('user/yft.tpl');
+    }
+
+    public function yftPay($request, $response, $args)
+    {
+
+        $yftLib = new QuickPayFunction();
+        $pay_config = new PayConfig();
+        $pay_config->init();
+
+        /**************************请求参数**************************/
+
+        //订单名称
+        $subject = $request->getParams()['subject'];//必填
+
+        //付款金额
+        $total_fee = $request->getParams()['total_fee'];//必填 需为整数
+
+        //服务器异步通知页面路径
+        $notify_url = $request->getUri()->getScheme()."://".$request->getUri()->getHost().$pay_config->pay_config['notify_url'];
+
+        //需http://格式的完整路径,不能加?id=123这类自定义参数
+
+        //页面跳转同步通知页面路径
+        $return_url = $request->getUri()->getScheme()."://".$request->getUri()->getHost().$pay_config->pay_config["return_url"];
+        //需http://格式的完整路径,不能加?id=123这类自定义参数,不能写成http://localhost/
+
+        $secret = $pay_config->pay_config["secret"];
+
+        $accesskey = $pay_config->pay_config["accesskey"];
+
+        //生成订单号
+        $ss_order_no = YftOrderNumUtil::generate_yftOrder(8);
+
+        /************************************************************/
+        //构造要请求的参数数组,无需改动
+        $parameter = [];
+        if ($pay_config->pay_config["type"] == "aliPay") {
+            $parameter = [
+                "total_fee" => $total_fee,
+                "notify_url" => $notify_url,
+                "return_url" => $return_url,
+                "secret" => $secret,
+                "out_trade_no" => $ss_order_no
+            ];
+        } else {
+            $parameter = [
+                "secret" => $secret,
+                "notify_url" => $notify_url,
+                "accesskey" => $accesskey,
+                "return_url" => $return_url,
+                "subject" => $subject,
+                "total_fee" => $total_fee
+            ];
+        }
+
+        //向数据库插入订单信息
+        $yft_order_info = new YftOrder();
+        $yft_order_info->user_id = $this->user->id;
+        $yft_order_info->ss_order = $ss_order_no;
+        $yft_order_info->price = $total_fee;
+        $yft_order_info->state = 0;
+        $yft_order_info->save();
+
+        //建立请求
+        $html_text = $yftLib->buildRequestForm($parameter, $ss_order_no,$pay_config);
+        return $html_text;
+
+    }
+
+    public function yftPayResult($request, $response, $args)
+    {
+        $newResponse = $response->withStatus(302)->withHeader('Location', '/user/code');
+        $yftLib = new QuickPayFunction();
+        $pay_config = new PayConfig();
+        $pay_config->init();
+
+        //价格
+        $total_fee = $request->getParams()['total_fee'];//必填
+        //付款状态
+        $trade_status = $request->getParams()['trade_status'];//必填
+        //加密验证字符串
+        $sign = $request->getParams()['sign'];//必填
+        //易付通返回的订单号
+        $yft_order_no = $request->getParams()['yft_order_no'];
+        //面板生成的订单号
+        $ss_order_no = $request->getParams()['ss_order_no'];//必填
+
+        $verifyNotify = $yftLib->md5Verify(floatval($total_fee), $trade_status, $pay_config->pay_config['secret'], $pay_config->pay_config['accesskey'], $sign);
+        if ($verifyNotify) {//验证成功
+            if ($_REQUEST['trade_status'] == 'success') {
+                /*
+                加入您的入库及判断代码;
+                >>>>>>>!!!为了保证数据传达到回调地址,会请求4次。所以必须要先判断订单状态,然后再插入到数据库,这样后面即使请求3次,也不会造成订单重复!!!!<<<<<<<
+                判断返回金额与实金额是否想同;
+                判断订单当前状态;
+                完成以上才视为支付成功
+                */
+                $price = $request->getParams()['total_fee'];
+                $payInfo = YftOrder::where('ss_order', '=', $ss_order_no)->orderBy('id', 'desc')->first();
+                $user = User::where('id', '=', $payInfo->user_id)->orderBy('id', 'desc')->first();
+                if ($payInfo != null && $payInfo->state == 0) {
+                    $old = $user->money;
+                    $user->money = $price + $old;
+                    $user->save();
+                    $payInfo->yft_order = $yft_order_no;
+                    $payInfo->state = 1;
+                    $payInfo->save();
+                } else {
+                    echo "订单号异常!请联系管理员!";
+                    sleep(2);
+                    return $newResponse;
+                }
+
+                echo "支付成功";
+                return $newResponse;
+            } else {
+                echo "支付失败";
+                return $newResponse;
+            }
+
+        } else {
+            //验证失败
+            echo "订单信息异常!请联系管理员";
+            sleep(2);
+            return $newResponse;
+        }
+    }
+
+    public function yftOrder($request, $response, $args)
+    {
+        $pageNum = 1;
+        if (isset($request->getQueryParams()["page"])) {
+            $pageNum = $request->getQueryParams()["page"];
+        }
+        $orderList = YftOrder::where("user_id", $this->user->id)->orderBy("id", "asc")->paginate(15, ['*'], 'page', $pageNum);
+        $count = sizeof(YftOrder::where("user_id", $this->user->id)->get());
+        $countPage = ceil($count / 15);
+        $orderList->setPath('/user/yftOrder');
+
+        return $this->view()->assign('orderList', $orderList)->assign('countPage', $countPage)->assign('currentPage', $pageNum)->display('user/yftOrder.tpl');
+    }
+
+    /**
+     * @desc 管理员查看所有充值记录
+     * @param $request
+     * @param $response
+     * @param $args
+     * @return mixed
+     */
+    public function yftOrderForAdmin($request, $response, $args)
+    {
+        $pageNum = 1;
+        if (isset($request->getQueryParams()["page"])) {
+            $pageNum = $request->getQueryParams()["page"];
+        }
+        $orderList = YftOrder::where("price",">=", 0)->orderBy("id", "asc")->paginate(15, ['*'], 'page', $pageNum);
+        $count = sizeof(YftOrder::where("price",">=", 0)->get());
+        $countPage = ceil($count / 15);
+        $orderList->setPath('/admin/yftOrder');
+
+        return $this->view()->assign('orderList', $orderList)->assign('countPage', $countPage)->assign('currentPage', $pageNum)->display('admin/yftOrder.tpl');
+    }
+
+}

+ 17 - 0
app/Models/YftOrder.php

@@ -0,0 +1,17 @@
+<?php
+/**
+ * Created by 傲慢与偏见.
+ * OSUser: D-L
+ * Date: 2017/10/22
+ * Time: 21:09
+ */
+
+namespace App\Models;
+
+
+class YftOrder extends Model
+{
+    protected $connection = "default";
+    protected $table = "yft_order_info";
+    protected $primaryKey = 'id';
+}

+ 22 - 1
app/Utils/Pay.php

@@ -18,7 +18,9 @@ class Pay
             case 'zfbjk':
                 return Pay::zfbjk_html($user);
             case 'f2fpay':
-                return Pay::f2fpay_html($user);                
+                return Pay::f2fpay_html($user);
+			case 'yftpay':
+                return Pay::yftpay_html($user); 
             default:
                 return "";
         }
@@ -63,6 +65,25 @@ class Pay
                         <a class="btn btn-flat waves-attach" id="urlChange" ><span class="icon">local_gas_station</span>&nbsp;充值</a>
 ';              
     }
+	private static function yftpay_html($user)
+    {
+        return '
+										<form action="/user/code/yft" method="post" target="_blank">
+										<div class="card-inner">
+											<p class="card-heading">在线充值</p>
+											<div class="form-group form-group-label">
+												<label class="floating-label" for="price">充值金额</label>
+												<input class="form-control" id="price" name="price" type="text">
+											</div>
+										</div>
+										<div class="card-action">
+											<div class="card-action-btn pull-left">
+												<button type="submit" class="btn btn-flat waves-attach" id="yftCoin" ><span class="icon">check</span>&nbsp;充值</button>
+											</div>
+										</div>
+									</form>     
+';
+    } 
     private static function pmw_html($user)
     {
         \Paymentwall_Config::getInstance()->set(array(

+ 28 - 0
app/Utils/YftOrderNumUtil.php

@@ -0,0 +1,28 @@
+<?php
+/**
+ * Created by 傲慢与偏见.
+ * OSUser: D-L
+ * Date: 2017/10/12
+ * Time: 21:08
+ */
+
+namespace App\Utils;
+
+class YftOrderNumUtil
+{
+    public static function generate_yftOrder($length = 8)
+    {
+		// 密码字符集,可任意添加你需要的字符
+        $date = time();
+        $date = "yft".date("YmdHis",$date);
+        $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
+        $password = "";
+        for ($i = 0; $i < $length; $i++) {
+            // 这里提供两种字符获取方式
+            // 第一种是使用 substr 截取$chars中的任意一位字符;
+            // 第二种是取字符数组 $chars 的任意元素
+            $password .= substr($chars, mt_rand(0, strlen($chars) - 1), 1);
+        }
+        return $date.$password;
+    }
+}

+ 9 - 0
config/routes.php

@@ -80,6 +80,8 @@ $app->get('/tos', 'App\Controllers\HomeController:tos');
 $app->get('/staff', 'App\Controllers\HomeController:staff');
 $app->get('/gfwlistjs', 'App\Controllers\LinkController:GetGfwlistJs');
 $app->post('/telegram_callback', 'App\Controllers\HomeController:telegram');
+$app->get('/yft/notify','App\Controllers\YFTPayCallBackController:yft_notify');
+
 
 
 // User Center
@@ -136,6 +138,12 @@ $app->group('/user', function () {
     $this->post('/kill', 'App\Controllers\UserController:handleKill');
     $this->get('/logout', 'App\Controllers\UserController:logout');
     $this->get('/code', 'App\Controllers\UserController:code');
+	//易付通路由定义 start
+    $this->post('/code/yft/pay', 'App\Controllers\YftPay:yftPay');
+    $this->get('/code/yft/pay/result', 'App\Controllers\YftPay:yftPayResult');
+    $this->post('/code/yft', 'App\Controllers\YftPay:yft');
+    $this->get('/yftOrder','App\Controllers\YftPay:yftOrder');
+	//易付通路由定义 end
     $this->get('/alipay', 'App\Controllers\UserController:alipay');
     $this->post('/code/f2fpay', 'App\Controllers\UserController:f2fpay');
     $this->get('/code/f2fpay', 'App\Controllers\UserController:f2fpayget');
@@ -285,6 +293,7 @@ $app->group('/admin', function () {
     $this->get('/sys', 'App\Controllers\AdminController:sys');
     $this->get('/logout', 'App\Controllers\AdminController:logout');
     $this->post('/payback/ajax', 'App\Controllers\AdminController:ajax_payback');
+	$this->get('/yftOrder','App\Controllers\YftPay:yftOrderForAdmin');
 })->add(new Admin());
 
 // API

+ 1 - 1
resources/views/material/admin/main.tpl

@@ -109,7 +109,7 @@
 							<li><a href="/admin/shop"><i class="icon icon-lg">shop</i>&nbsp;商品</a></li>
 							<li><a href="/admin/coupon"><i class="icon icon-lg">card_giftcard</i>&nbsp;优惠码</a></li>
 							<li><a href="/admin/bought"><i class="icon icon-lg">shopping_cart</i>&nbsp;购买记录</a></li>
-                            <li><a href="/user/invite"><i class="icon icon-lg">loyalty</i>&nbsp;邀请码</a></li> 
+							<li><a href="/admin/yftOrder"><i class="icon icon-lg">shopping_cart</i>&nbsp;充值记录</a></li>
 						</ul>
 
 						<li><a href="/user"><i class="icon icon-lg">person</i>&nbsp;用户中心</a></li>

+ 85 - 0
resources/views/material/admin/yftOrder.tpl

@@ -0,0 +1,85 @@
+{include file='admin/main.tpl'}
+
+<main class="content">
+    <div class="content-header ui-content-header">
+        <div class="container">
+            <h1 class="content-heading">充值记录</h1>
+        </div>
+    </div>
+    <div class="container">
+        <div class="col-lg-12 col-sm-12">
+            <section class="content-inner margin-top-no">
+
+                <div class="card">
+                    <div class="card-main">
+                        <div class="card-inner">
+                            <p>系统中充值记录。</p>
+                        </div>
+                    </div>
+                </div>
+
+                <div class="table-responsive">
+                    {$orderList->render()}
+                    <table class="table ">
+                        <tr>
+                            <th>ID</th>
+                            <th>订单号</th>
+                            <th>金额</th>
+                            <th>充值时间</th>
+                            <th>状态</th>
+                        </tr>
+                        {if sizeof($orderList) > 0}
+                            {foreach $orderList as $order}
+                                <tr>
+                                    <td>#{$order->id}</td>
+                                    <td>{$order->yft_order}</td>
+                                    <td>{$order->price} 元</td>
+                                    <td>{$order->create_time}</td>
+                                    {if ($order->state == 1)}<td>已支付</td>{else}<td>未支付</td>{/if}
+                                </tr>
+                            {/foreach}
+                        {else}
+                            <tr>
+                                <td colspan="5">暂无充值记录!</td>
+                            </tr>
+                        {/if}
+                    </table>
+                </div>
+                <span>总共{$countPage}页</span>
+                <input type="hidden" id="countPage" value="{$countPage}">
+                <span>当前第{$currentPage}页</span>
+                <input type="hidden" id="currentPage" value="{$currentPage}">
+                <a class="btn btn-brand" href="/admin/yftOrder">首页</a>
+                <a class="btn btn-brand" href="javascript:void(0)" id="pre" onclick="goto('pre')">上一页</a>
+                <a class="btn btn-brand" href="javascript:void(0)" id="nxt" onclick="goto('next')">下一页</a>
+                <a class="btn btn-brand" href="javascript:void(0)" id="end" onclick="goto('end')">尾页</a>
+                {$orderList->render()}
+        </div>
+    </div>
+</main>
+{include file='admin/footer.tpl'}
+<script>
+    function goto(type) {
+        var countPage = $("#countPage").val();
+        var currentPage = $("#currentPage").val();
+        if ("pre" == type){
+            if (currentPage == 1 || currentPage == ""){
+                $("#pre").removeAttr('onclick');
+            }else {
+                window.location.href = "/admin/yftOrder?page=" + (currentPage - 1);
+            }
+        }else if ("next" == type){
+            if (currentPage == countPage){
+                $("#pre").removeAttr('onclick');
+            }else {
+                window.location.href = "/admin/yftOrder?page=" + (currentPage + 1);
+            }
+        }else if ("end" == type){
+            if (countPage == currentPage){
+                $("#end").removeAttr('onclick');
+            }else {
+                window.location.href = "/admin/yftOrder?page=" + countPage;
+            }
+        }
+    }
+</script>

+ 7 - 0
resources/views/material/user/yft.tpl

@@ -0,0 +1,7 @@
+<form name="paysubmit" action="/user/code/yft/pay" method="post">
+    <input name="subject" type="hidden" value="余额充值" size="35"/>
+    <input name="total_fee" type="hidden" value="{$price}" size="35"/>
+</form>
+<script>
+    document.forms['paysubmit'].submit();
+</script>

+ 85 - 0
resources/views/material/user/yftOrder.tpl

@@ -0,0 +1,85 @@
+{include file='user/main.tpl'}
+
+<main class="content">
+    <div class="content-header ui-content-header">
+        <div class="container">
+            <h1 class="content-heading">充值记录</h1>
+        </div>
+    </div>
+    <div class="container">
+        <div class="col-lg-12 col-sm-12">
+            <section class="content-inner margin-top-no">
+
+                <div class="card">
+                    <div class="card-main">
+                        <div class="card-inner">
+                            <p>系统中您的充值记录。</p>
+                        </div>
+                    </div>
+                </div>
+
+                <div class="table-responsive">
+                    {$orderList->render()}
+                    <table class="table ">
+                        <tr>
+                            <th>ID</th>
+                            <th>订单号</th>
+                            <th>金额</th>
+                            <th>充值时间</th>
+                            <th>状态</th>
+                        </tr>
+                        {if sizeof($orderList) > 0}
+                            {foreach $orderList as $order}
+                                <tr>
+                                    <td>#{$order->id}</td>
+                                    <td>{$order->yft_order}</td>
+                                    <td>{$order->price} 元</td>
+                                    <td>{$order->create_time}</td>
+                                    {if ($order->state == 1)}<td>已支付</td>{else}<td>未支付</td>{/if}
+                                </tr>
+                            {/foreach}
+                        {else}
+                            <tr>
+                                <td colspan="5">暂无充值记录!</td>
+                            </tr>
+                        {/if}
+                    </table>
+                </div>
+                <span>总共{$countPage}页</span>
+                <input type="hidden" id="countPage" value="{$countPage}">
+                <span>当前第{$currentPage}页</span>
+                <input type="hidden" id="currentPage" value="{$currentPage}">
+                <a class="btn btn-brand" href="/user/yftOrder">首页</a>
+                <a class="btn btn-brand" href="javascript:void(0)" id="pre" onclick="goto('pre')">上一页</a>
+                <a class="btn btn-brand" href="javascript:void(0)" id="nxt" onclick="goto('next')">下一页</a>
+                <a class="btn btn-brand" href="javascript:void(0)" id="end" onclick="goto('end')">尾页</a>
+                {$orderList->render()}
+        </div>
+    </div>
+</main>
+{include file='user/footer.tpl'}
+<script>
+    function goto(type) {
+        var countPage = $("#countPage").val();
+        var currentPage = $("#currentPage").val();
+        if ("pre" == type){
+            if (currentPage == 1 || currentPage == ""){
+                $("#pre").removeAttr('onclick');
+            }else {
+                window.location.href = "/user/yftOrder?page=" + currentPage - 1;
+            }
+        }else if ("next" == type){
+            if (currentPage == countPage){
+                $("#pre").removeAttr('onclick');
+            }else {
+                window.location.href = "/user/yftOrder?page=" + currentPage + 1;
+            }
+        }else if ("end" == type){
+            if (countPage == currentPage){
+                $("#end").removeAttr('onclick');
+            }else {
+                window.location.href = "/user/yftOrder?page=" + countPage;
+            }
+        }
+    }
+</script>