|
|
@@ -3,6 +3,7 @@
|
|
3
|
3
|
namespace app\controller\api\store\service;
|
|
4
|
4
|
|
|
5
|
5
|
use think\App;
|
|
|
6
|
+use think\facade\Db;
|
|
6
|
7
|
use crmeb\basic\BaseController;
|
|
7
|
8
|
|
|
8
|
9
|
class Huafei extends BaseController
|
|
|
@@ -12,8 +13,6 @@ class Huafei extends BaseController
|
|
12
|
13
|
public $secretKey = 'f154a106d56d804fcc640d9da4844b0c';
|
|
13
|
14
|
// 生产
|
|
14
|
15
|
public $gatewayUrl = "https://router.wikeyun.cn";
|
|
15
|
|
- // 备用
|
|
16
|
|
-// public $gatewayUrl = "https://router.wikeyun.cn/rest";
|
|
17
|
16
|
|
|
18
|
17
|
public $format = "json";
|
|
19
|
18
|
/** 是否打开入参check**/
|
|
|
@@ -26,17 +25,124 @@ class Huafei extends BaseController
|
|
26
|
25
|
parent::__construct($app);
|
|
27
|
26
|
}
|
|
28
|
27
|
|
|
|
28
|
+
|
|
|
29
|
+ //充值话费回调
|
|
|
30
|
+ public function notify(){
|
|
|
31
|
+ $param = $this->request->param();
|
|
|
32
|
+ Db::name('log')->insert(['data'=>'话费充值回调数据'.json_encode($param)]);
|
|
|
33
|
+
|
|
|
34
|
+ $order_no = $param['order_no'];
|
|
|
35
|
+ $order_number = $param['order_number'];
|
|
|
36
|
+ $updateData = [
|
|
|
37
|
+ 'amount_price' => $param['amount'],
|
|
|
38
|
+ 'fanli_price' => $param['fanli'],
|
|
|
39
|
+ 'cost_price' => $param['cost_price'],
|
|
|
40
|
+ 'arrived_amount'=> $param['arrived_amount'],
|
|
|
41
|
+ 'status' => $param['status'],
|
|
|
42
|
+ 'modify_time' => time(),
|
|
|
43
|
+ ];
|
|
|
44
|
+ $ret = Db::name("order_huafei")->where("order_number", $order_number)->where("order_sn", $order_no)->update($updateData);
|
|
|
45
|
+ if($ret){
|
|
|
46
|
+ echo 'success';exit;
|
|
|
47
|
+ }else{
|
|
|
48
|
+ Db::name('log')->insert(['data'=>'话费充值回调数据处理失败']);
|
|
|
49
|
+ echo 'error';exit;
|
|
|
50
|
+ }
|
|
|
51
|
+ }
|
|
|
52
|
+
|
|
|
53
|
+
|
|
|
54
|
+
|
|
|
55
|
+
|
|
|
56
|
+ //充值话费面额
|
|
|
57
|
+ public function denomination(){
|
|
|
58
|
+ $data = [
|
|
|
59
|
+ ['money'=>50, 'name'=>'50元'],
|
|
|
60
|
+ ['money'=>100, 'name'=>'100元'],
|
|
|
61
|
+ ['money'=>200, 'name'=>'200元'],
|
|
|
62
|
+ ];
|
|
|
63
|
+ return app('json')->success('获取话费面额成功', $data);
|
|
|
64
|
+ }
|
|
|
65
|
+
|
|
|
66
|
+
|
|
29
|
67
|
//充值话费推送
|
|
30
|
68
|
public function recharge(){
|
|
|
69
|
+ $uid = $this->request->uid();
|
|
|
70
|
+ $params = $this->request->params(['phone', 'money']);
|
|
|
71
|
+ if(!$params['phone']) return app('json')->fail('请提交电话号码');
|
|
|
72
|
+ if(!$params['money']) return app('json')->fail('请提交充值金额');
|
|
|
73
|
+ //验证
|
|
|
74
|
+ $verify = $this->verify($params['phone'], $params['money']);
|
|
|
75
|
+ if($verify['code'] == '0000'){
|
|
|
76
|
+ //推送
|
|
|
77
|
+ $order_sn = time().$uid;
|
|
|
78
|
+ $push = $this->pushOrder($order_sn, $params['phone'], $params['money']);
|
|
|
79
|
+ if($push['code'] == '0000'){
|
|
|
80
|
+ //入库记录
|
|
|
81
|
+ $insertdata = [
|
|
|
82
|
+ 'uid'=> $uid,
|
|
|
83
|
+ 'mobile' => $params['phone'],
|
|
|
84
|
+ 'commission'=> 0,
|
|
|
85
|
+ 'commission_share'=> 0,
|
|
|
86
|
+ 'order_number' => $push['data']['order_number'],
|
|
|
87
|
+ 'order_sn' => $order_sn,
|
|
|
88
|
+ 'amount_price' => $push['data']['amount'],
|
|
|
89
|
+ 'fanli_price' => $push['data']['fanli'],
|
|
|
90
|
+ 'cost_price' => $push['data']['cost_price'],
|
|
|
91
|
+ 'pay_money' => $params['money'],
|
|
|
92
|
+ 'status' => 0,
|
|
|
93
|
+ 'create_time' => time(),
|
|
|
94
|
+ 'finish_time' => time(),
|
|
|
95
|
+ 'modify_time' => time(),
|
|
|
96
|
+ ];
|
|
|
97
|
+ Db::name('order_huafei')->insert($insertdata);
|
|
|
98
|
+ return app('json')->success('话费推送成功', $push);
|
|
|
99
|
+ }else{
|
|
|
100
|
+ return app('json')->fail($push['msg']);
|
|
|
101
|
+ }
|
|
|
102
|
+ }else{
|
|
|
103
|
+ return app('json')->fail($verify['msg']);
|
|
|
104
|
+ }
|
|
|
105
|
+ }
|
|
|
106
|
+
|
|
|
107
|
+
|
|
|
108
|
+ //话费充值验证
|
|
|
109
|
+ public function verify($order_number, $money){
|
|
|
110
|
+ $request['mobile'] = $order_number;
|
|
|
111
|
+ $request['amount'] = $money;
|
|
|
112
|
+ $request['recharge_type'] = 1;
|
|
|
113
|
+ return $this->execute('/rest/Recharge/verify', $request);
|
|
|
114
|
+ }
|
|
|
115
|
+
|
|
|
116
|
+
|
|
|
117
|
+ //话费订单充值推送
|
|
|
118
|
+ public function pushOrder($order_sn, $phone, $money){
|
|
|
119
|
+ $request['store_id'] = '9189';
|
|
|
120
|
+ $request['order_no'] = $order_sn;
|
|
|
121
|
+ $request['mobile'] = $phone;
|
|
|
122
|
+ $request['money'] = $money;
|
|
|
123
|
+ $request['recharge_type'] = 1;
|
|
|
124
|
+ $request['notify_url'] = 'https://api.gdjbp.com//api/huafei/notify';
|
|
|
125
|
+ return $this->execute('/rest/Recharge/PushOrder', $request);
|
|
|
126
|
+ }
|
|
|
127
|
+
|
|
|
128
|
+
|
|
|
129
|
+ //话费订单查询
|
|
|
130
|
+ public function query($order_number){
|
|
31
|
131
|
$request['store_id'] = '9189';
|
|
32
|
|
- $request['mobile'] = '18973958920';
|
|
33
|
|
- $request['money'] = 100;
|
|
34
|
|
- $request['recharge_type'] = 1;
|
|
35
|
|
- $request['notify_url'] = 'https://api.gdjbp.com//api/huafei/notify';
|
|
36
|
|
- $arr = $this->execute('/rest/Recharge/PushOrder', $request);
|
|
37
|
|
- return app('json')->success('话费推送成功', $arr);
|
|
|
132
|
+ $request['order_number'] = $order_number;
|
|
|
133
|
+ return $this->execute('/rest/Recharge/query', $request);
|
|
38
|
134
|
}
|
|
39
|
135
|
|
|
|
136
|
+
|
|
|
137
|
+ //话费订单取消
|
|
|
138
|
+ public function cancel($order_number){
|
|
|
139
|
+ $request['order_number'] = $order_number;
|
|
|
140
|
+ return $this->execute('/rest/Recharge/cancel', $request);
|
|
|
141
|
+ }
|
|
|
142
|
+
|
|
|
143
|
+
|
|
|
144
|
+
|
|
|
145
|
+
|
|
40
|
146
|
protected function generateSign($params){
|
|
41
|
147
|
ksort($params);
|
|
42
|
148
|
$stringToBeSigned = $this->secretKey;
|