|
|
@@ -23,57 +23,66 @@ class Huafei extends BaseController
|
|
23
|
23
|
|
|
24
|
24
|
//充值话费回调
|
|
25
|
25
|
public function notify(){
|
|
26
|
|
- $param = $this->request->param();
|
|
27
|
|
- Db::name('log')->insert(['data'=>'话费充值回调数据'.json_encode($param)]);
|
|
28
|
|
-
|
|
29
|
|
- $order_no = $param['order_no'];
|
|
30
|
|
- $order_number = $param['order_number'];
|
|
31
|
|
-
|
|
32
|
|
- $huafeiInfo = Db::name('order_huafei')->where("order_number", $order_number)->where("order_sn", $order_no)->find();
|
|
33
|
|
- if(!$huafeiInfo) echo 'error';exit;
|
|
34
|
|
-
|
|
35
|
|
- $updateData = [
|
|
36
|
|
- 'amount_price' => $param['amount'],
|
|
37
|
|
- 'fanli_price' => $param['fanli'],
|
|
38
|
|
- 'cost_price' => $param['cost_price'],
|
|
39
|
|
- 'arrived_amount'=> $param['arrived_amount'],
|
|
40
|
|
- 'status' => $param['status'],
|
|
41
|
|
- 'modify_time' => time(),
|
|
42
|
|
- ];
|
|
43
|
|
- $ret = Db::name("order_huafei")->where("order_number", $order_number)->where("order_sn", $order_no)->update($updateData);
|
|
44
|
|
- if($ret){
|
|
45
|
|
- if($param['status'] == 2) {
|
|
46
|
|
- //判断数据库有无此订单
|
|
47
|
|
- $type_shop = 9;
|
|
48
|
|
- $orderThird = app()->make(UserThirdRepository::class);
|
|
49
|
|
- //预估养老金
|
|
50
|
|
- $orderThird->yuguOrder(
|
|
51
|
|
- $huafeiInfo['order_pdd_id'],
|
|
52
|
|
- $huafeiInfo['commission'],
|
|
53
|
|
- $huafeiInfo['uid'],
|
|
54
|
|
- $huafeiInfo['order_sn'],
|
|
55
|
|
- $type_shop,
|
|
56
|
|
- 'order_huafei');
|
|
57
|
|
- //预估积分
|
|
58
|
|
- $orderThird->yuguJifen(
|
|
59
|
|
- $huafeiInfo['commission'] ,
|
|
60
|
|
- $huafeiInfo['uid'],
|
|
61
|
|
- $huafeiInfo['order_sn'],
|
|
62
|
|
- $type_shop
|
|
63
|
|
- );
|
|
64
|
|
- //复购金
|
|
65
|
|
- $orderThird->yuguFugou(
|
|
66
|
|
- $huafeiInfo['commission'] ,
|
|
67
|
|
- $huafeiInfo['uid'],
|
|
68
|
|
- $huafeiInfo['order_sn'],
|
|
69
|
|
- $type_shop
|
|
70
|
|
- );
|
|
|
26
|
+ try{
|
|
|
27
|
+ $param = $this->request->param();
|
|
|
28
|
+ Db::name('log')->insert(['data'=>'话费充值回调数据'.json_encode($param)]);
|
|
|
29
|
+
|
|
|
30
|
+ $order_no = $param['order_no'];
|
|
|
31
|
+ $order_number = $param['order_number'];
|
|
|
32
|
+
|
|
|
33
|
+ $huafeiInfo = Db::name('order_huafei')->where("order_sn", $order_no)->find();
|
|
|
34
|
+ if(!$huafeiInfo){
|
|
|
35
|
+ return 'error';
|
|
71
|
36
|
}
|
|
72
|
|
-
|
|
73
|
|
- echo 'success';exit;
|
|
74
|
|
- }else{
|
|
75
|
|
- Db::name('log')->insert(['data'=>'话费充值回调数据处理失败']);
|
|
76
|
|
- echo 'error';exit;
|
|
|
37
|
+
|
|
|
38
|
+ $updateData = [
|
|
|
39
|
+ 'amount_price' => $param['amount'],
|
|
|
40
|
+ 'fanli_price' => $param['fanli'],
|
|
|
41
|
+ 'cost_price' => $param['cost_price'],
|
|
|
42
|
+ 'arrived_amount'=> $param['arrived_amount'],
|
|
|
43
|
+ 'status' => $param['status'],
|
|
|
44
|
+ 'modify_time' => date('Y-m-d H:i:s'),
|
|
|
45
|
+ ];
|
|
|
46
|
+ $ret = Db::name("order_huafei")->where("order_sn", $order_no)->update($updateData);
|
|
|
47
|
+ if($ret){
|
|
|
48
|
+ if($param['status'] == 2) {
|
|
|
49
|
+ //判断数据库有无此订单
|
|
|
50
|
+ $type_shop = 9;
|
|
|
51
|
+ $orderThird = app()->make(UserThirdRepository::class);
|
|
|
52
|
+ //预估养老金
|
|
|
53
|
+ $orderThird->yuguOrder(
|
|
|
54
|
+ $huafeiInfo['order_pdd_id'],
|
|
|
55
|
+ $huafeiInfo['commission'],
|
|
|
56
|
+ $huafeiInfo['uid'],
|
|
|
57
|
+ $huafeiInfo['order_sn'],
|
|
|
58
|
+ $type_shop,
|
|
|
59
|
+ 'order_huafei');
|
|
|
60
|
+ //预估积分
|
|
|
61
|
+ $orderThird->yuguJifen(
|
|
|
62
|
+ $huafeiInfo['commission'] ,
|
|
|
63
|
+ $huafeiInfo['uid'],
|
|
|
64
|
+ $huafeiInfo['order_sn'],
|
|
|
65
|
+ $type_shop
|
|
|
66
|
+ );
|
|
|
67
|
+ //复购金
|
|
|
68
|
+ $orderThird->yuguFugou(
|
|
|
69
|
+ $huafeiInfo['commission'] ,
|
|
|
70
|
+ $huafeiInfo['uid'],
|
|
|
71
|
+ $huafeiInfo['order_sn'],
|
|
|
72
|
+ $type_shop
|
|
|
73
|
+ );
|
|
|
74
|
+ }
|
|
|
75
|
+
|
|
|
76
|
+ echo 'success';
|
|
|
77
|
+ return;
|
|
|
78
|
+ }else{
|
|
|
79
|
+ Db::name('log')->insert(['data'=>'话费充值回调数据处理失败']);
|
|
|
80
|
+ echo 'error';
|
|
|
81
|
+ return;
|
|
|
82
|
+ }
|
|
|
83
|
+ }catch (\Exception $e) {
|
|
|
84
|
+ Db::name('log')->insert(['data'=>'充值话费回调错误:'.$e->getFile().':'.$e->getLine().'【'.$e->getMessage().'】']);
|
|
|
85
|
+ return app('json')->fail('充值话费回调错误:'.$e->getFile().':'.$e->getLine().'【'.$e->getMessage().'】');
|
|
77
|
86
|
}
|
|
78
|
87
|
}
|
|
79
|
88
|
|
|
|
@@ -105,14 +114,20 @@ class Huafei extends BaseController
|
|
105
|
114
|
}
|
|
106
|
115
|
|
|
107
|
116
|
return app('json')->success('获取话费面额成功', $data);
|
|
108
|
|
- }
|
|
|
117
|
+ }
|
|
109
|
118
|
|
|
110
|
119
|
|
|
111
|
120
|
//充值话费推送补发
|
|
112
|
121
|
public function bufa(){
|
|
113
|
|
- $order_no = $this->request->param('order_no');
|
|
114
|
|
- $order_data = Db::name('order_huafei_hf') -> where('order_no', $order_no)->find();
|
|
115
|
|
- return $this->pushHf($order_data['uid'], $order_data['order_no'], $order_data['mobile'], $order_data['pay_price']);
|
|
|
122
|
+ try{
|
|
|
123
|
+ $order_no = $this->request->param('order_no');
|
|
|
124
|
+ $order_data = Db::name('order_huafei_hf') -> where('order_no', $order_no)->find();
|
|
|
125
|
+ $RES = $this->pushHf($order_data['uid'], $order_data['order_no'], $order_data['mobile'], $order_data['pay_price']);
|
|
|
126
|
+ return app('json')->success('充值话费推送补发成功', $RES);
|
|
|
127
|
+ }catch (\Exception $e) {
|
|
|
128
|
+ Db::name('log')->insert(['data'=>'充值话费推送补发错误:'.$e->getFile().':'.$e->getLine().'【'.$e->getMessage().'】']);
|
|
|
129
|
+ return app('json')->fail('充值话费推送补发错误:'.$e->getFile().':'.$e->getLine().'【'.$e->getMessage().'】');
|
|
|
130
|
+ }
|
|
116
|
131
|
}
|
|
117
|
132
|
|
|
118
|
133
|
|
|
|
@@ -134,7 +149,7 @@ class Huafei extends BaseController
|
|
134
|
149
|
'order_no' => $order_sn,
|
|
135
|
150
|
'pay_price' => $params['money'],
|
|
136
|
151
|
'status' => 0,
|
|
137
|
|
- 'create_time' => time(),
|
|
|
152
|
+ 'create_time'=> date('Y-m-d H:i:s'),
|
|
138
|
153
|
];
|
|
139
|
154
|
$oid = Db::name('order_huafei_hf')->insertGetId($insertdata);
|
|
140
|
155
|
if($oid){
|
|
|
@@ -143,7 +158,7 @@ class Huafei extends BaseController
|
|
143
|
158
|
return app('json')->fail('创建话费充值预支付订单失败');
|
|
144
|
159
|
}
|
|
145
|
160
|
}else{
|
|
146
|
|
- return app('json')->fail($verify['msg']);
|
|
|
161
|
+ return app('json')->fail($verify['msg'].'MSG');
|
|
147
|
162
|
}
|
|
148
|
163
|
}
|
|
149
|
164
|
|
|
|
@@ -152,11 +167,10 @@ class Huafei extends BaseController
|
|
152
|
167
|
public function pushHf($uid, $order_sn, $phone, $money){
|
|
153
|
168
|
//推送订单
|
|
154
|
169
|
$push = $this->pushOrder($order_sn, $phone, $money);
|
|
|
170
|
+ Db::name('log')->insert(['data'=>'话费充值推送订单返回数据'.json_encode($push)]);
|
|
155
|
171
|
if($push['code'] == '0000'){
|
|
156
|
|
-
|
|
157
|
172
|
$commissionMoney = $money*0.04;
|
|
158
|
|
-
|
|
159
|
|
- //入库记录
|
|
|
173
|
+ //成功入库记录
|
|
160
|
174
|
$insertdata = [
|
|
161
|
175
|
'uid'=> $uid,
|
|
162
|
176
|
'mobile' => $phone,
|
|
|
@@ -168,15 +182,34 @@ class Huafei extends BaseController
|
|
168
|
182
|
'fanli_price' => $push['data']['fanli'],
|
|
169
|
183
|
'cost_price' => $push['data']['cost_price'],
|
|
170
|
184
|
'pay_money' => $money,
|
|
171
|
|
- 'status' => 0,
|
|
172
|
|
- 'create_time' => time(),
|
|
173
|
|
- 'finish_time' => time(),
|
|
174
|
|
- 'modify_time' => time(),
|
|
|
185
|
+ 'status' => 1,
|
|
|
186
|
+ 'create_time' => date('Y-m-d H:i:s'),
|
|
|
187
|
+ 'finish_time' => date('Y-m-d H:i:s'),
|
|
|
188
|
+ 'modify_time' => date('Y-m-d H:i:s'),
|
|
175
|
189
|
];
|
|
176
|
190
|
Db::name('order_huafei')->insert($insertdata);
|
|
177
|
191
|
return $push;
|
|
178
|
192
|
}else{
|
|
179
|
|
- return false;
|
|
|
193
|
+ $commissionMoney = $money*0.04;
|
|
|
194
|
+ //失败入库记录
|
|
|
195
|
+ $insertdata = [
|
|
|
196
|
+ 'uid'=> $uid,
|
|
|
197
|
+ 'mobile' => $phone,
|
|
|
198
|
+ 'commission'=> $commissionMoney,
|
|
|
199
|
+ 'commission_share'=> 0.04,
|
|
|
200
|
+ 'order_number' => '',
|
|
|
201
|
+ 'order_sn' => $order_sn,
|
|
|
202
|
+ 'amount_price' => $money,
|
|
|
203
|
+ 'fanli_price' => 0,
|
|
|
204
|
+ 'cost_price' => 0,
|
|
|
205
|
+ 'pay_money' => $money,
|
|
|
206
|
+ 'status' => 3,
|
|
|
207
|
+ 'create_time' => date('Y-m-d H:i:s'),
|
|
|
208
|
+ 'finish_time' => date('Y-m-d H:i:s'),
|
|
|
209
|
+ 'modify_time' => date('Y-m-d H:i:s'),
|
|
|
210
|
+ ];
|
|
|
211
|
+ Db::name('order_huafei')->insert($insertdata);
|
|
|
212
|
+ return $push;
|
|
180
|
213
|
}
|
|
181
|
214
|
}
|
|
182
|
215
|
|
|
|
@@ -191,8 +224,6 @@ class Huafei extends BaseController
|
|
191
|
224
|
$query = Db::name("order_huafei");
|
|
192
|
225
|
$count = $query->where($where)->count();
|
|
193
|
226
|
$list = $query->page($page, $limit)->where($where)->select()->each(function ($item){
|
|
194
|
|
- $item['create_time'] = date("Y-m-d H:i:s", $item['create_time']);
|
|
195
|
|
- $item['status'] = (int)$item['status'];
|
|
196
|
227
|
return $item;
|
|
197
|
228
|
});
|
|
198
|
229
|
return app('json')->success('获取话费充值记录成功', ['list'=>$list, 'count'=>$count]);
|
|
|
@@ -216,7 +247,7 @@ class Huafei extends BaseController
|
|
216
|
247
|
$request['mobile'] = $phone;
|
|
217
|
248
|
$request['money'] = $money;
|
|
218
|
249
|
$request['recharge_type'] = 1;
|
|
219
|
|
- $request['notify_url'] = 'https://api.gdjbp.com//api/huafei/notify';
|
|
|
250
|
+ $request['notify_url'] = 'https://api.gdjbp.com/api/huafei/notify';
|
|
220
|
251
|
return $this->execute('/rest/Recharge/PushOrder', $request);
|
|
221
|
252
|
}
|
|
222
|
253
|
|