PayView.php
2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2019/10/29
* Time: 9:12
*/
namespace app\admin\controller;
use app\common\controller\Backend;
use fast\Random;
use think\Db;
class PayView extends Backend
{
public function test(){
dump(cache('nnn'));
dump(cache('successful'));
}
public function index(){
//商户信息
$admin = Db::name('admin')->where(['id'=>$this->auth->id])->find();
//红包券充值比例
$exp_ratio = Db::name('exp_ratio')->where(['id'=>1])->find();
$this->assign('exp_ratio',$exp_ratio);
$this->assign('admin',$admin);
return $this->fetch();
}
public function create_order(){
$admin_id = $this->request->param('admin_id',0,'intval');
$total = $this->request->param('total',0,'intval');
if(empty($admin_id) || empty($total)){
$this->error('缺少必要参数');
}
//红包券充值比例
$exp_ratio = Db::name('exp_ratio')->where(['id'=>1])->find();
$admin = Db::name('admin')->where(['id'=>$admin_id])->find();
$arr['num'] = date("YmdHis") . Random::alnum(6);
$arr['admin_id'] = $admin_id;
$arr['user_id'] = $admin['user_id'];
$arr['total'] = $total;
$arr['money'] = $exp_ratio['ratio']/0.01*$total;//$total*$exp_ratio['ratio']*0.01;
$arr['create_time'] = time();
$arr['status'] = 1;
$order_id = Db::name('order')->insertGetId($arr);
$this->success('','',['order_id'=>$order_id]);
}
public function pay(){
$order_id = $this->request->param('order_id',0,'intval');
$data = Db::name('order')->where(['id'=>$order_id])->find();
$pay = new Pay();
$code_url = $pay->index($data);
if(empty($code_url)){
$this->error('生成二维码失败');
}
\PHPQRCode\QRcode::png($code_url);
}
public function order_pay(){
$order_id = $this->request->param('order_id',0,'intval');
$data = Db::name('order')->where(['id'=>$order_id])->find();
if($data['status'] != 2){
$this->error('');
}
$this->success();
}
}