Browse Source

alipay支付完成

lizhen_gitee 3 years ago
parent
commit
7fcb350a00

+ 0 - 83
application/api/controller/Recharge.php

@@ -103,63 +103,6 @@ class Recharge extends Api
 
         $this->success('success',$return);
     }
-    //创建订单
-    public function recharge_pc(){
-
-        $rc_id = input('rc_id',0);
-        $pay_type  = input('pay_type','wechat');
-        $username = input('username',0);
-
-
-        if(!$rc_id){
-            $this->error('请选择充值金额');
-        }
-
-        if(!$username){
-            $this->error('请输入用户手机号并选择');
-        }
-
-        //查找用户
-        $user_info = Db::name('user')->field('id')->where('username',$username)->find();
-        if (empty($user_info)) {
-            $this->error('用户信息不存在');
-        }
-
-        //赋值money
-        $recharge_config = Db::name('paygold_webcon')->where('id',$rc_id)->find();
-        $money = $recharge_config['money'];
-        $gold = $recharge_config['gold'];
-
-        //创建订单
-        $data = [];
-        $data['status'] = 0;
-        $pay_no = createUniqueNo('P',$user_info['id']);
-        $data['pay_no'] = $pay_no;
-        $data['money'] = $money;
-        $data['payment_class'] = $pay_type;
-        $data['user_id'] = $user_info['id'];
-        $data['ext_info'] =  json_encode(['subject'=>'充值金币支付']);
-        $data['memo'] =  '充值金币支付';
-        $data['createtime'] = time();
-        $data['payment'] = $pay_type == 'alipay' ? 'web' : 'scan';
-        $orderid = Db::name('pay_order')->insertGetId($data);
-
-        //创建回调
-        $data = [];
-        $data['event'] = 'success';
-        $data['class'] = 'app\common\model\Recharge';
-        $data['method'] = 'rechargepaysucc';
-        $data['args'] = json_encode(['user_id'=>$user_info['id'],'gold'=>$gold,'money'=>$money,'pg_id'=>$rc_id]);
-        $data['pay_no'] = $pay_no;
-        Db::name('pay_event')->insertGetId($data);
-
-        $return = [
-            'pay_no'=>$pay_no,
-            'title' => '充值金币支付',
-        ];
-
-        $this->success('success',$return);
-    }
 
     //公众号
     public function topay(){
@@ -183,32 +126,6 @@ class Recharge extends Api
         $res = Service::submitOrder($params);
         $this->success('请求成功',json_decode($res,true));
     }
-    //pc支付
-    public function topay_pc(){
 
-        $openid = input('openid');
-        $pay_no = input('pay_no');
-        $pay_type  = input_post('pay_type','wechat');
-        $orderInfo = Db::name('pay_order')->where('pay_no',$pay_no)->find();
-        //下单
-        $params = [
-            'type'         => $pay_type,
-            'orderid'      => $pay_no,
-            'title'        => $orderInfo['memo'],
-            'amount'       => $orderInfo['money'],
-            // 'amount'       => 0.01,
-            'method'       => $pay_type == 'alipay' ? 'web' : 'scan',
-            'openid'       => $openid,
-            'notifyurl' => $this->request->root(true) . '/notify.php/paytype/'.$pay_type,
-//            'returnurl' => $this->request->root(true) . '/index/index/paysuccess',
-        ];
-        $res = Service::submitOrder($params);
-
-        if($pay_type == 'wechat'){
-            exit;
-        }else{
-            return $res;
-        }
-    }
 
 }

+ 95 - 0
application/index/controller/Recharge.php

@@ -0,0 +1,95 @@
+<?php
+
+namespace app\index\controller;
+
+use app\common\controller\Frontend;
+use think\Db;
+use addons\epay\library\Service;
+class Recharge extends Frontend
+{
+
+    protected $noNeedLogin = '*';
+    protected $noNeedRight = '*';
+    protected $layout = '';
+
+
+
+    public function index()
+    {
+        return $this->view->fetch();
+    }
+
+    //创建订单
+    public function recharge_pc(){
+
+        $rc_id = input('rc_id',0);
+        $pay_type  = input('pay_type','alipay');
+        $mobile = input('mobile',0);
+
+
+        if(!$rc_id){
+            $this->error('请选择充值金额');
+        }
+
+        if(!$mobile){
+            $this->error('请输入用户手机号');
+        }
+
+        //查找用户
+        $user_info = Db::name('user')->field('id')->where('mobile',$mobile)->find();
+        if (empty($user_info)) {
+            $this->error('用户信息不存在');
+        }
+
+        //赋值money
+        $recharge_config = Db::name('paygold_webcon')->where('id',$rc_id)->find();
+        $money = $recharge_config['money'];
+        $gold = $recharge_config['gold'];
+
+        //创建订单
+        $data = [];
+        $data['status'] = 0;
+        $pay_no = createUniqueNo('P',$user_info['id']);
+        $data['pay_no'] = $pay_no;
+        $data['money'] = $money;
+        $data['payment_class'] = $pay_type;
+        $data['user_id'] = $user_info['id'];
+        $data['ext_info'] =  json_encode(['subject'=>'充值金币支付']);
+        $data['memo'] =  '充值金币支付';
+        $data['createtime'] = time();
+        $data['payment'] = $pay_type == 'alipay' ? 'web' : 'scan';
+        $orderid = Db::name('pay_order')->insertGetId($data);
+
+        //创建回调
+        $even_data = [];
+        $even_data['event'] = 'success';
+        $even_data['class'] = 'app\common\model\Recharge';
+        $even_data['method'] = 'rechargepaysucc';
+        $even_data['args'] = json_encode(['user_id'=>$user_info['id'],'gold'=>$gold,'money'=>$money,'pg_id'=>$rc_id]);
+        $even_data['pay_no'] = $pay_no;
+        Db::name('pay_event')->insertGetId($even_data);
+
+
+        //下单
+        $params = [
+            'type'         => $pay_type,
+            'orderid'      => $pay_no,
+            'title'        => $data['memo'],
+            'amount'       => $data['money'],
+            // 'amount'       => 0.01,
+            'method'       => $pay_type == 'alipay' ? 'web' : 'scan',
+            'notifyurl' => $this->request->root(true) . '/notify.php/paytype/'.$pay_type,
+//            'returnurl' => $this->request->root(true) . '/index/index/paysuccess',
+        ];
+        $res = Service::submitOrder($params);
+
+        if($pay_type == 'wechat'){
+            exit;
+        }else{
+            return $res;
+        }
+    }
+
+
+
+}

+ 290 - 0
application/index/view/recharge/index.html

@@ -0,0 +1,290 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge">
+    <meta name="divport" content="width=device-width, initial-scale=1.0">
+    <link rel="stylesheet" href="/assets/frontend/recharge/reset.css">
+    <link rel="stylesheet" href="/assets/frontend/recharge/icon.css">
+    <title>充值</title>
+    <style>
+        .page {
+             height: 100vh;
+        }
+        .content{
+            padding-top: 0.10rem;
+            display: flex;
+            flex-direction: column;
+            align-items: center;
+            height: 100%;
+            margin:0 auto;
+            width: 8.00rem;
+            background-color: #f8f8f8;
+        }
+        .phone-wrap {
+            width: 7.50rem;
+            padding:0 0.15rem 0.15rem;
+        }
+        .phone-item {
+            width: 100%;
+            height: 0.35rem;
+            border-bottom: 1px solid #F1F1F1;
+            justify-content: space-between;
+          
+        }
+        .phone-item input {
+            flex:1;
+            font-size: 0.14rem;
+            background-color: #f8f8f8;
+        }
+        .phone-item .phone-nick{
+            color:#999999;
+            font-size: 0.13rem;
+        }
+        .recharge-wrap {
+            width: 7.50rem;
+            padding: 0.15rem;
+            padding-top: 0rpx;
+            padding-bottom: 0rpx;
+
+        }
+        .recharge-title {
+            font-size: 0.16rem;
+            font-weight: bold;
+        }        
+
+        .exchange-section {
+            margin-top: 0.10rem;
+            display: flex;
+            flex-wrap: wrap;
+            /* justify-content: space-between; */
+        }
+        .exchange-box {
+            width: 1.25rem;
+            height: 0.71rem;
+            border: 0.01rem solid #7D73DC;
+            border-radius: 0.10rem;
+            margin-bottom: 0.15rem;
+            color: #999999;
+            align-items: center;
+            justify-content: center;
+            cursor: pointer;
+            margin-right: 0.40rem;
+        }
+        .exchange-box:nth-child(4n){
+            margin-right: 0;
+        }
+
+        .exchange-top {
+            display: flex;
+            align-items: center;
+        }
+
+        .exchange-pic {
+            height: auto;
+            width: 0.18rem;
+            margin-right: 0.07rem;
+        }
+
+        .diamonds-num {
+            font-size: 0.16rem;
+            color: #261A00;
+        }
+        
+
+        /* .actvie {
+            color: #FFFFFF;
+        } */
+
+        .diamonds-name {
+            font-size: 0.12rem;
+            margin-left: 0.04rem;
+        }
+
+        .exchange-price {
+            font-size: 0.12rem;
+            margin-top: 0.10rem;
+        }
+
+        .current {
+            background: linear-gradient(90deg, #629CFF, #7870F1);
+            box-shadow: 0px 3px 5px 0px rgba(126, 114, 220, 0.59);
+            color: #FFFFFF !important;
+        }
+        .current .diamonds-num{
+            color: #FFFFFF;
+        }
+        .mode-wrap{
+            width: 7.50rem;
+            height: 1.15rem;
+            padding: 0.15rem;
+            padding-top:0rpx;
+           
+        }
+        .mode-wrap .mode-title{
+            font-size: 0.16rem;
+            font-weight: bold;
+        }
+        .mode-item{
+            width: 7.50rem;
+            height: 0.20rem;
+            justify-content: space-between;
+            margin-top: 0.10rem;
+          
+        }
+        .mode-left{
+            font-size: 0.14rem;
+           
+        }
+        .mode-left  .zicon-weixin{
+            font-size: 0.27rem;
+            color: #46BB36;
+            margin-right: 0.07rem;
+        }
+        .mode-left  .zicon-alipay{
+            color:#02A9F1;
+            font-size: 0.27rem;
+            margin-right: 0.07rem;
+        }
+        .zicon-xuanze{
+            font-size: 0.20rem;
+            color: #46BB36;
+        }
+        .zicon-xuanze1{
+            font-size: 0.20rem;
+        }
+        .mode-tips{
+            width: 7.50rem;
+            align-items: flex-start;
+            margin-top: 0.20rem;
+           
+        }
+        .mode-tips .zicon-tishi{
+                font-size: 0.14rem;
+                color: #FFCE00;
+                margin-top: 8rpx;
+            }
+        .mode-tips    .mode-txt{
+            /* width: 2.25rem; */
+            margin-left: 0.05rem;
+            color: #999999;
+            font-size: 0.12rem;
+        }
+
+        .recharge-btn{
+            width: 2.90rem;
+            height: 0.40rem;
+            background: #EEEEEE;
+            border-radius: 0.20rem;
+            margin: 0.50rem auto 0.10rem;
+            font-size: 0.15rem;
+            font-family: PingFang SC;
+            font-weight: 500;
+            cursor: pointer;
+        }
+        .recharge-btn.active{
+            background: linear-gradient(90deg, #629CFF, #7870F1);
+            color: #FFFFFF;
+        }
+    
+
+
+    </style>
+    <script>
+        !(function(win, doc) {
+            function setFontSize() {
+            var docEl = doc.documentElement;
+            var winWidth = docEl.clientWidth;
+            doc.documentElement.style.fontSize = (winWidth / 1920) * 100 + "px";
+            }
+            var userAgent = navigator.userAgent;
+            win.addEventListener("resize", function() {
+            if (navigator.userAgent !== userAgent) {
+                location.reload();
+            }
+            });
+            setFontSize();
+        })(window, document);
+    </script>
+</head>
+<body>
+    <div class="page">
+        <form method="post" action="/index/recharge/recharge_pc">
+        <div class="content">
+            <div class="phone-wrap row">
+                <div class="phone-item row">
+                    <input type="text" name="mobile" placeholder="请输入注册手机号" autofocus="true"/>
+                    <!--<span class="phone-nick" >昵称: 李大娃</span>-->
+                </div>
+            </div>
+            <div class="recharge-wrap">
+                <div class="recharge-title">充值金额</div>
+                <select name="rc_id" class="exchange-section">
+                    <option value="1">充¥100.00得1000金币</option>
+                    <option value="2">充¥300.00得3000金币</option>
+                    <option value="3">充¥500.00得5000金币</option>
+                    <option value="4">充¥0.01得1金币</option>
+                </select>
+                <!--<div class="exchange-section">
+                    &lt;!&ndash; current为激活状态 @click="clickBox(index)"&ndash;&gt;
+                    <div class="exchange-box column current" >
+                        <div class="exchange-top">
+                            <img class="exchange-pic" src="/assets/frontend/recharge/images/b-b.png"></img>
+                            <div class="diamonds-num" >1000</div>
+                            <div class="diamonds-name">金币</div>
+                        </div>
+                        <div class="exchange-price">¥100.00</div>
+                    </div>
+
+                    <div class="exchange-box column" >
+                        <div class="exchange-top">
+                            <img class="exchange-pic" src="/assets/frontend/recharge/images/b-b.png"></img>
+                            <div class="diamonds-num actvie" >3000</div>
+                            <div class="diamonds-name">金币</div>
+                        </div>
+                        <div class="exchange-price">¥300.00</div>
+                    </div>
+
+
+                    <div class="exchange-box column" >
+                        <div class="exchange-top">
+                            <img class="exchange-pic" src="/assets/frontend/recharge/images/b-b.png"></img>
+                            <div class="diamonds-num actvie" >5000</div>
+                            <div class="diamonds-name">金币</div>
+                        </div>
+                        <div class="exchange-price">¥500.00</div>
+                    </div>
+
+                </div>-->
+            </div>
+            <div class="mode-wrap">
+                <div class="mode-title">充值方式</div>
+                <!--  
+                <div class="mode-item row">
+                    <div class="mode-left row">
+                        <div class="zicon zicon-weixin"></div>
+                        <div>微信充值</div>
+                    </div>
+                    <div class="zicon zicon-xuanze"></div>
+                </div>
+                -->
+                <div class="mode-item row">
+                    <div class="mode-left row">
+                        <div class="zicon zicon-alipay"></div>
+                        <div>支付宝充值</div>
+                    </div>
+                    <!-- <div class="zicon" :class="choosed ? 'zicon-xuanze' : 'zicon-xuanze1'" @click="changeIcon"></div> -->
+                    <div class="zicon zicon-xuanze"></div>
+                </div>
+                <div class="mode-tips row">
+                    <div class="zicon zicon-tishi"></div>
+                    <div class="mode-txt">说明:充值前请确认您已满18周岁,金币充值成功后无法退款,不可提现。</div>
+                </div>
+            </div>
+            <input type="submit" class="recharge-btn center active" value="立即充值" />
+            <!--<div class="recharge-btn center active">立即充值</div>-->
+        </div>
+        </form>
+	</div>
+</body>
+</html>

+ 41 - 0
public/assets/frontend/recharge/icon.css

@@ -0,0 +1,41 @@
+@font-face {
+	font-family: zicon;
+	font-weight: normal;
+	font-style: normal;
+	/* src:url('https://at.alicdn.com/t/font_2032652_g189q6e704s.ttf') format('truetype'); */
+	src:url('https://at.alicdn.com/t/font_3263746_4k45o1671tt.ttf?t=1647841376589') format('truetype');
+}
+
+.zicon {
+	font-family: "zicon" !important;
+	font-size: 16px;
+	font-style: normal;
+	-webkit-font-smoothing: antialiased;
+	-moz-osx-font-smoothing: grayscale;
+	vertical-align: middle;
+}
+.zicon-xuanze1:before{
+	content: "\e633";
+}
+.zicon-weixin:before{
+	content: "\e659";
+}
+.zicon-xuanze:before{
+	content: "\e656";
+}
+.zicon-tishi:before{
+	content: "\e631";
+}
+.zicon-youjiantou:before{
+	content: "\e608";
+}
+.zicon-alipay:before{
+	content: "\e618";
+}
+
+
+
+
+
+
+

BIN
public/assets/frontend/recharge/images/b-b.png


BIN
public/assets/frontend/recharge/images/logo.png


+ 124 - 0
public/assets/frontend/recharge/reset.css

@@ -0,0 +1,124 @@
+/* http://meyerweb.com/eric/tools/css/reset/ 
+   v2.0 | 20110126
+   License: none (public domain)
+*/
+
+html, body, div, span, applet, object, iframe,
+h1, h2, h3, h4, h5, h6, p, blockquote, pre,
+a, abbr, acronym, address, big, cite, code,
+del, dfn, em, img, ins, kbd, q, s, samp,
+small, strike, strong, sub, sup, tt, var,
+b, u, i, center,
+dl, dt, dd, ol, ul, li,
+fieldset, form, label, legend,
+table, caption, tbody, tfoot, thead, tr, th, td,
+article, aside, canvas, details, embed, 
+figure, figcaption, footer, header, hgroup, 
+menu, nav, output, ruby, section, summary,
+time, mark, audio, video {
+	margin: 0;
+	padding: 0;
+	border: 0;
+	font-size: 100%;
+	font: inherit;
+	vertical-align: baseline;
+	box-sizing: border-box;
+	font-family: Source Han Sans CN;
+}
+
+/* HTML5 display-role reset for older browsers */
+article, aside, details, figcaption, figure, 
+footer, header, hgroup, menu, nav, section {
+	display: block;
+}
+input{
+	outline: none;
+	-webkit-appearance: button;
+	-webkit-appearance: none;
+	border-radius: 0;
+	border:none;
+	padding:0;
+	margin:0;
+	box-sizing: border-box;
+}
+textarea{
+	box-sizing: border-box;
+	resize: none;
+	outline: none;
+	padding:0;
+	margin:0;
+}
+a{
+    text-decoration: none;
+	color: inherit;
+}
+
+body {
+	line-height: 1;
+}
+ol, ul {
+	list-style: none;
+}
+blockquote, q {
+	quotes: none;
+}
+blockquote:before, blockquote:after,
+q:before, q:after {
+	content: '';
+	content: none;
+}
+table {
+	border-collapse: collapse;
+	border-spacing: 0;
+}
+
+.clamp {
+	overflow: hidden;
+	text-overflow: ellipsis;
+	white-space: nowrap;
+	display: block;
+}
+.clamp2 {
+	display: -webkit-box;
+	-webkit-box-orient: vertical;
+	-webkit-line-clamp: 2;
+	overflow: hidden;
+}
+.clamp3 {
+	display: -webkit-box;
+	-webkit-box-orient: vertical;
+	-webkit-line-clamp: 3;
+	overflow: hidden;
+}
+.clamp4 {
+	display: -webkit-box;
+	-webkit-box-orient: vertical;
+	-webkit-line-clamp: 3;
+	overflow: hidden;
+}
+/* 布局 */
+.row{
+	/* #ifndef APP-PLUS-NVUE */
+	display:flex;
+	/* #endif */
+	flex-direction:row;
+	align-items: center;
+}
+.column{
+	/* #ifndef APP-PLUS-NVUE */
+	display:flex;
+	/* #endif */
+	flex-direction: column;
+}
+.center{
+	/* #ifndef APP-PLUS-NVUE */
+	display:flex;
+	/* #endif */
+	align-items: center;
+	justify-content: center;
+}
+.fill{
+	flex: 1;
+}
+ ::-webkit-scrollbar{ width: 0; height: 0; color: transparent; }
+