|
|
@@ -10,6 +10,7 @@ namespace app\common\repositories\movie;
|
|
10
|
10
|
use app\common\dao\movie\order\MovieOrderDao;
|
|
11
|
11
|
use app\common\repositories\BaseRepository;
|
|
12
|
12
|
use app\common\repositories\store\order\StoreOrderRepository;
|
|
|
13
|
+use app\traits\HuiPay;
|
|
13
|
14
|
use crmeb\services\ApiResponseService;
|
|
14
|
15
|
use think\exception\ValidateException;
|
|
15
|
16
|
use think\facade\Db;
|
|
|
@@ -23,6 +24,8 @@ use think\facade\Log;
|
|
23
|
24
|
*/
|
|
24
|
25
|
class MovieRepository extends BaseRepository
|
|
25
|
26
|
{
|
|
|
27
|
+ use HuiPay;
|
|
|
28
|
+
|
|
26
|
29
|
protected $dao;
|
|
27
|
30
|
|
|
28
|
31
|
/**
|
|
|
@@ -151,9 +154,11 @@ class MovieRepository extends BaseRepository
|
|
151
|
154
|
|
|
152
|
155
|
$group = Db::transaction(function () use ($userinfo, $_order) {
|
|
153
|
156
|
$_order = $this->dao->create($_order);
|
|
154
|
|
- if ($_order) return static::pay($_order['pay_type']);
|
|
155
|
|
-
|
|
156
|
|
-
|
|
|
157
|
+ if ($_order) return ['code' => ApiResponseService::DEFAULT_SUCCESS_CODE, 'msg' => '下单成功', 'data' => ['order_sn' => $_order['order_sn']]];
|
|
|
158
|
+// return $this->pay(
|
|
|
159
|
+// $_order['pay_type'], $userinfo->wechat_user_id, $_order, $_order['film_name'], env('APP_URL') . "/api/hf_notify/movie",
|
|
|
160
|
+// 'delay');
|
|
|
161
|
+ throw new ValidateException('下单失败');
|
|
157
|
162
|
});
|
|
158
|
163
|
return $group;
|
|
159
|
164
|
} else {
|
|
|
@@ -161,168 +166,80 @@ class MovieRepository extends BaseRepository
|
|
161
|
166
|
}
|
|
162
|
167
|
}
|
|
163
|
168
|
|
|
164
|
|
- private static function pay($payType, $code, $groupOrder, $title, $notify_url, $pay_mode = null, $appid = '')
|
|
|
169
|
+ /**
|
|
|
170
|
+ * 支付
|
|
|
171
|
+ *
|
|
|
172
|
+ * @param $payType
|
|
|
173
|
+ * @param $openid
|
|
|
174
|
+ * @param $_order
|
|
|
175
|
+ * @param $title
|
|
|
176
|
+ * @param $notify_url
|
|
|
177
|
+ * @param $pay_mode
|
|
|
178
|
+ * @param $appid
|
|
|
179
|
+ * @return array|mixed
|
|
|
180
|
+ */
|
|
|
181
|
+ private function pay($payType, $openid, $_order, $title, $notify_url, $pay_mode = null, $appid = '')
|
|
165
|
182
|
{
|
|
166
|
|
-
|
|
167
|
|
- $order_no = $groupOrder['group_order_sn'] ?? $groupOrder['order_no'];
|
|
168
|
|
-
|
|
169
|
|
-
|
|
170
|
|
- if ($payType == 'wx') {
|
|
171
|
|
-
|
|
172
|
|
- if (!$code || $code == '' || $code == 'undefined')
|
|
173
|
|
- return "授权失败,code为空";
|
|
174
|
|
- if ($appid == '') {
|
|
175
|
|
-
|
|
176
|
|
-
|
|
|
183
|
+ switch ($payType) {
|
|
|
184
|
+ case 'wx':
|
|
177
|
185
|
$pay_wx = systemConfig('pay_wx');
|
|
178
|
|
-
|
|
179
|
186
|
if ($pay_wx == 2) {
|
|
180
|
187
|
$appid = env('WECHAT_MP.APPID');
|
|
181
|
188
|
$new_secret = env('WECHAT_MP.SECRET');
|
|
182
|
189
|
|
|
183
|
190
|
$app_id = 'app_0827b960-b932-45ec-b800-4e850091b419';
|
|
184
|
191
|
$key = 'api_live_90ef02e4-54ac-41ee-adf1-e4927d23d58f';
|
|
185
|
|
-
|
|
186
|
192
|
} elseif ($pay_wx == 3) {
|
|
187
|
193
|
$appid = env('WECHAT_TDYL.APPID');
|
|
188
|
194
|
$new_secret = env('WECHAT_TDYL.SECRET');
|
|
189
|
195
|
|
|
190
|
|
-
|
|
191
|
|
- Db::name('log')->insert(['data' => 'appid---' . $appid]);
|
|
192
|
|
- Db::name('log')->insert(['data' => 'new_secret---' . $new_secret]);
|
|
193
|
196
|
$app_id = 'app_383a75dd-c03d-44ab-8f58-92c60fe9b9d0';
|
|
194
|
197
|
$key = 'api_live_b0a687ec-5450-4ada-a0e4-65bac0f46871';
|
|
195
|
|
-
|
|
196
|
198
|
}
|
|
197
|
199
|
|
|
198
|
|
- } else {
|
|
199
|
|
- $app_id = 'app_0827b960-b932-45ec-b800-4e850091b419';
|
|
200
|
|
- $key = 'api_live_90ef02e4-54ac-41ee-adf1-e4927d23d58f';
|
|
201
|
|
- $new_secret = "c8cbe24fa3b83f77a88b79554b3aeab4";
|
|
202
|
|
- }
|
|
203
|
|
-
|
|
204
|
|
- $url = "https://api.weixin.qq.com/sns/jscode2session?appid=" . $appid . "&secret=" . $new_secret . "&js_code=" . $code . "&grant_type=authorization_code";
|
|
205
|
|
- $get = curlGet($url);
|
|
206
|
|
- Db::name('log')->insert(['data' => 'pay_wx---' . $pay_wx]);
|
|
207
|
|
- Db::name('log')->insert(['data' => 'code---' . $code]);
|
|
208
|
|
- Db::name('log')->insert(['data' => 'url---' . $url]);
|
|
209
|
|
- Db::name('log')->insert(['data' => 'open_id---' . json_encode($get)]);
|
|
210
|
|
- if (!isset($get['openid']) || empty($get['openid'])) {
|
|
211
|
|
- return '授权失败';
|
|
212
|
|
- }
|
|
213
|
|
- $openid = $get['openid'];
|
|
214
|
|
-
|
|
215
|
|
- $member_id = 0;
|
|
216
|
|
- $type = '2';
|
|
217
|
|
- $pay_channel = 'wx_lite';
|
|
218
|
|
-
|
|
219
|
|
- $expend = [
|
|
220
|
|
- 'open_id' => $openid,
|
|
221
|
|
- 'wx_app_id' => $appid
|
|
222
|
|
- ];
|
|
223
|
|
-
|
|
224
|
|
-
|
|
225
|
|
- if ($groupOrder['order_type'] = "marketing") {
|
|
226
|
|
-
|
|
227
|
|
- db::name("test_log")->insert(["note" => "pay_huifu" . json_encode($groupOrder)]);
|
|
228
|
|
- // 创富宝 分账
|
|
229
|
|
- //创富宝
|
|
230
|
|
- $cfb = sprintf("%01.2f", round(bcmul($groupOrder['pay_price'], '0.094', 5), 2));//9.4%的分账
|
|
231
|
|
-
|
|
232
|
|
- $cfb_member = "jsdk_member_1680162243019";
|
|
233
|
|
- // 平台
|
|
234
|
|
- $cxb = sprintf("%01.2f", round(bcsub($groupOrder['pay_price'], $cfb, 5), 2));//剩下的归平台
|
|
235
|
|
-
|
|
236
|
|
- $div_members = [
|
|
237
|
|
- [
|
|
238
|
|
- 'member_id' => $member_id,
|
|
239
|
|
- 'amount' => $cxb,
|
|
240
|
|
- 'fee_flag' => 'Y'
|
|
|
200
|
+ $type = '2';
|
|
|
201
|
+ $params = [
|
|
|
202
|
+ 'order_no' => $_order['order_sn'],
|
|
|
203
|
+ 'app_id' => $app_id,
|
|
|
204
|
+ 'pay_channel' => 'wx_lite',
|
|
|
205
|
+ 'pay_amt' => (string)$_order['order_price'],
|
|
|
206
|
+ 'goods_title' => strlen($title) > 64 ? mb_substr($title, 0, 64, 'utf-8') : $title,// 解决因为太长不能支付问题
|
|
|
207
|
+ 'goods_desc' => strlen($title) > 42 ? mb_substr($title, 0, 127, 'utf-8') : $title,// 解决因为太长不能支付问题
|
|
|
208
|
+ 'device_info' => [
|
|
|
209
|
+ 'device_ip' => app('request')->ip()
|
|
241
|
210
|
],
|
|
242
|
|
- [
|
|
243
|
|
- 'member_id' => $cfb_member,
|
|
244
|
|
- 'amount' => $cfb,
|
|
245
|
|
- 'fee_flag' => 'N'
|
|
246
|
|
- ]
|
|
|
211
|
+ 'expend' => json_encode(['open_id' => $openid, 'wx_app_id' => $appid]),
|
|
|
212
|
+ 'fee_mode' => 'I',
|
|
|
213
|
+ 'notify_url' => $notify_url,
|
|
|
214
|
+ 'pay_mode' => $pay_mode
|
|
247
|
215
|
];
|
|
248
|
|
- } else {
|
|
249
|
|
- $div_members = [
|
|
250
|
|
- [
|
|
251
|
|
- 'member_id' => $member_id,
|
|
252
|
|
- 'amount' => $groupOrder['pay_price'],
|
|
253
|
|
- 'fee_flag' => 'Y'
|
|
254
|
|
- ]
|
|
|
216
|
+ break;
|
|
|
217
|
+ case 'ALI':
|
|
|
218
|
+ $type = '1';
|
|
|
219
|
+ // 天地博爱科技通道
|
|
|
220
|
+ $app_id = 'app_44108546-d27a-48ee-88c1-84b45b75114f';
|
|
|
221
|
+ $key = 'api_live_b23537ed-64b8-45d6-832e-fb228aa9e0a9';
|
|
|
222
|
+
|
|
|
223
|
+ $params = [
|
|
|
224
|
+ 'order_no' => $_order['order_sn'],
|
|
|
225
|
+ 'app_id' => $app_id,
|
|
|
226
|
+ 'pay_channel' => 'alipay_qr',
|
|
|
227
|
+ 'pay_amt' => (string)$_order['order_price'],
|
|
|
228
|
+ 'goods_title' => strlen($title) > 64 ? mb_substr($title, 0, 64, 'utf-8') : $title,// 解决因为太长不能支付问题
|
|
|
229
|
+ 'goods_desc' => strlen($title) > 42 ? mb_substr($title, 0, 127, 'utf-8') : $title,// 解决因为太长不能支付问题
|
|
|
230
|
+ 'device_info' => [
|
|
|
231
|
+ 'device_ip' => app('request')->ip()
|
|
|
232
|
+ ],
|
|
|
233
|
+ 'fee_mode' => 'I',
|
|
|
234
|
+ 'notify_url' => $notify_url
|
|
255
|
235
|
];
|
|
256
|
|
- }
|
|
257
|
|
-
|
|
258
|
|
- $params = [
|
|
259
|
|
- 'order_no' => $order_no . "_" . rand(1000, 9999),
|
|
260
|
|
- 'app_id' => $app_id,
|
|
261
|
|
- 'pay_channel' => $pay_channel,
|
|
262
|
|
- 'pay_amt' => (string)$groupOrder['pay_price'],
|
|
263
|
|
- 'goods_title' => strlen($title) > 64 ? mb_substr($title, 0, 64, 'utf-8') : $title,// 解决因为太长不能支付问题
|
|
264
|
|
- 'goods_desc' => strlen($title) > 42 ? mb_substr($title, 0, 127, 'utf-8') : $title,// 解决因为太长不能支付问题
|
|
265
|
|
- 'device_info' => [
|
|
266
|
|
- 'device_ip' => app('request')->ip()
|
|
267
|
|
-// 'device_ip'=>'115.171.134.68'
|
|
268
|
|
- ],
|
|
269
|
|
-
|
|
270
|
|
- 'expend' => json_encode($expend),
|
|
271
|
|
- 'div_members' => json_encode($div_members),
|
|
272
|
|
- 'fee_mode' => 'I',
|
|
273
|
|
- 'notify_url' => $notify_url
|
|
274
|
|
- ];
|
|
275
|
|
- if ($pay_mode == 'delay') {
|
|
276
|
|
- $params['pay_mode'] = 'delay';
|
|
277
|
|
- unset($params['div_members']);
|
|
278
|
|
- unset($params['fee_mode']);
|
|
279
|
|
- }
|
|
280
|
|
- return $this->Payment_create_traits_b($params, $type, $key);
|
|
281
|
|
- } elseif ($payType == 'ALI') {
|
|
282
|
|
-// throw new AuthException('支付宝正在升级,请使用微信支付');
|
|
283
|
|
- $member_id = 0;
|
|
284
|
|
- $type = '1';
|
|
285
|
|
- $pay_channel = 'alipay_qr';
|
|
286
|
|
- // 天地博爱科技通道
|
|
287
|
|
- $app_id = 'app_44108546-d27a-48ee-88c1-84b45b75114f';
|
|
288
|
|
- $key = 'api_live_b23537ed-64b8-45d6-832e-fb228aa9e0a9';
|
|
289
|
|
- // 天地博爱通道
|
|
290
|
|
-// $app_id='app_0827b960-b932-45ec-b800-4e850091b419';
|
|
291
|
|
-// $key='api_live_90ef02e4-54ac-41ee-adf1-e4927d23d58f';
|
|
292
|
|
-
|
|
293
|
|
- $div_members = [
|
|
294
|
|
- [
|
|
295
|
|
- 'member_id' => $member_id,
|
|
296
|
|
- 'amount' => $groupOrder['pay_price'],
|
|
297
|
|
- 'fee_flag' => 'Y'
|
|
298
|
|
- ]
|
|
299
|
|
- ];
|
|
300
|
|
-
|
|
301
|
|
- $params = [
|
|
302
|
|
- 'order_no' => $order_no . "_" . rand(1000, 9999),
|
|
303
|
|
- 'app_id' => $app_id,
|
|
304
|
|
- 'pay_channel' => $pay_channel,
|
|
305
|
|
- 'pay_amt' => (string)$groupOrder['pay_price'],
|
|
306
|
|
- 'goods_title' => strlen($title) > 64 ? mb_substr($title, 0, 64, 'utf-8') : $title,// 解决因为太长不能支付问题
|
|
307
|
|
- 'goods_desc' => strlen($title) > 42 ? mb_substr($title, 0, 127, 'utf-8') : $title,// 解决因为太长不能支付问题
|
|
308
|
|
- 'device_info' => [
|
|
309
|
|
- 'device_ip' => app('request')->ip()
|
|
310
|
|
-// 'device_ip'=>'115.171.134.68'
|
|
311
|
|
- ],
|
|
312
|
|
-
|
|
313
|
|
-// 'expend'=>json_encode($expend),
|
|
314
|
|
- 'div_members' => json_encode($div_members),
|
|
315
|
|
- 'fee_mode' => 'I',
|
|
316
|
|
- 'notify_url' => $notify_url
|
|
317
|
|
- ];
|
|
318
|
|
- if ($pay_mode == 'delay') {
|
|
319
|
|
- $params['pay_mode'] = 'delay';
|
|
320
|
|
- unset($params['div_members']);
|
|
321
|
|
- unset($params['fee_mode']);
|
|
322
|
|
- }
|
|
323
|
|
- return $this->Payment_create_traits_a($params, $type, $key);
|
|
|
236
|
+ break;
|
|
|
237
|
+ default:
|
|
|
238
|
+ throw new ValidateException('请选择支付方式');
|
|
|
239
|
+ break;
|
|
324
|
240
|
}
|
|
325
|
241
|
|
|
|
242
|
+ return $this->Payment_create_traits_a($params, $type, $key);
|
|
326
|
243
|
}
|
|
327
|
244
|
|
|
328
|
245
|
/**
|