AdminOrderController.php
7.3 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<?php
// +----------------------------------------------------------------------
// | bronet [ 以客户为中心 以奋斗者为本 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2017 http://www.bronet.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 老猫 <bronet@126.com>
// +----------------------------------------------------------------------
namespace app\portal\controller;
use app\portal\service\ToolsService;
use cmf\controller\AdminBaseController;
use EasyWeChat\Foundation\Application;
use think\Db;
class AdminOrderController extends AdminBaseController
{
public function index()
{
$param = $this->request->param();
$where = [];
$keywordComplex = [];
if (!empty($param['keyword'])) {
$keywordComplex['o.mobile|u.user_nickname'] = ['like', "%" . $param['keyword'] . "%"];
}
if (!empty($param['status'])) {
$where['o.status'] = $param['status'];
}
$startTime = empty($param['start_time']) ? 0 : strtotime($param['start_time']);
$endTime = empty($param['end_time']) ? 0 : strtotime($param['end_time']);
if (!empty($startTime) && !empty($endTime)) {
$where['o.create_time'] = [['>= time', $startTime], ['<= time', $endTime]];
} else {
if (!empty($startTime)) {
$where['o.create_time'] = ['>= time', $startTime];
}
if (!empty($endTime)) {
$where['o.create_time'] = ['<= time', $endTime];
}
}
$data = Db::name('order')
->alias('o')
->join('user u', 'o.user_id=u.id')
->join('post p', 'o.post_id=p.id')
->join('skill s', 'o.skill_id=s.id')
->join('category c', 's.category_id=c.id')
->join('user u2', 'p.user_id=u2.id')
->whereOr($keywordComplex)
->where($where)
->order('o.create_time', 'desc')
->field('o.*,u.user_nickname,p.user_id as puser_id,u2.user_nickname as puser_nickname,s.price,c.name,p.mobile as pmobile')
->paginate(10);
var_dump($data);
$data->appends($param);
//111
$this->assign('start_time', isset($param['start_time']) ? $param['start_time'] : '');
$this->assign('end_time', isset($param['end_time']) ? $param['end_time'] : '');
$this->assign('keyword', isset($param['keyword']) ? $param['keyword'] : '');
$this->assign('status', isset($param['status']) ? $param['status'] : '');
$this->assign('page', $data->render());
$this->assign('list', $data);
return $this->fetch('index');
}
public function check()
{
$param = $this->request->param();
$data = Db::name('order')->where('id', $param['id'])->find();
$data['proof'] = json_decode($data['proof'], true);
$this->assign('list', $data);
return $this->fetch('check');
}
public function checkPost()
{
$param = $this->request->param();
$order = Db::name('order')->where('id', $param['id'])->find();
if ($param['status'] == 1) {
Db::name('order')->where('id', $param['id'])->update(['status' => 7, 'to_user_status' => 4, 'to_post_status' => 4, 'remark' => $param['remark']]);
$post_id = $order['post_id'];
$mobile = Db::name('post')->where('id', $post_id)->find()['mobile'];
$curl = curl_init();
$url = 'https://api.zhuanxinyun.com/api/v2/sendSms.json?appKey=1luqgyqudbfwkjp64ge7cg5v0fscenir&appSecret=813ff35dc46bfd193d44d85499e7273c3834&phones='.$mobile.'&content=【达人组局】你所提交的订单完成申请已通过审核,可以在待提现中提现';
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 60);
curl_setopt($curl, CURLOPT_URL, $url);
$re=curl_exec($curl);
// var_dump($re);
// exit();
}
if ($param['status'] == 2 && $order['status'] == 3) {
Db::name('order')->where('id', $param['id'])->update(['status' => 4, 'to_post_status' => 6, 'remark' => $param['remark']]);
$post_id = $order['post_id'];
$mobile = Db::name('post')->where('id', $post_id)->find()['mobile'];
$curl = curl_init();
$url = 'https://api.zhuanxinyun.com/api/v2/sendSms.json?appKey=1luqgyqudbfwkjp64ge7cg5v0fscenir&appSecret=813ff35dc46bfd193d44d85499e7273c3834&phones='.$mobile.'&content=【达人组局】你提交的订单完成申请未通过审核,请按照要求再次提交证据审核,第二次提交驳回订单费用将退还下单者';
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 60);
curl_setopt($curl, CURLOPT_URL, $url);
curl_exec($curl);
}
if ($param['status'] == 2 && $order['status'] == 5) {
$options = [
'app_id' => config('app_id'),
'secret' => config('app_secret'),
'payment' => [
'merchant_id' => '1365052302',
'key' => 'ebfe7fba8f7a0fba3e19efcc547b956d',
'cert_path' => 'wechat/cert/apiclient_cert.pem', // XXX: 绝对路径!!!!
'key_path' => 'wechat/cert/apiclient_key.pem', // XXX: 绝对路径!!!!
// 'device_info' => '013467007045764',
// 'sub_app_id' => '',
// 'sub_merchant_id' => '',
// ...
],
];
$app = new Application($options);
$payment = $app->payment;
//使用商户订单号退款 PS.其他形式参考文档
$orderNo = $order['order_sn'];//商户系统内部的订单号(out_trade_no)
$refundNo = cmf_get_order_sn();//退款单号
$result = $payment->refund($orderNo, $refundNo, $order['total_price'] * 100, $order['total_price'] * 100); // 总金额 100, 退款 80,refundFee可选(为空时全额退款)
Db::name('refund')->insert(['type' => 1, 'order_sn' => $orderNo, 'create_time' => time(), 'money' => $order['total_price'], 'user_id' => $order['user_id']]);
Db::name('order')->where('id', $param['id'])->update(['status' => 6, 'to_user_status' => 3, 'to_post_status' => 3, 'remark' => $param['remark']]);
}
$this->success('审核成功', url('AdminOrder/index'));
}
public function delete()
{
$param = $this->request->param();
Db::name('order')->where('id', $param['id'])->delete();
$this->success('删除成功');
}
public function mark()
{
$param = $this->request->param();
$data = Db::name('order')->where('id', $param['id'])->find();
$this->assign('list', $data);
return $this->fetch();
}
public function markPost()
{
$param = $this->request->param();
$data = Db::name('order')->where('id', $param['id'])->update($param);
$this->success('备注成功', url('AdminOrder/index'));
}
}