|
|
@@ -230,12 +230,12 @@ class MovieRepository extends BaseRepository
|
|
230
|
230
|
'sched_seat' => $params['sched_seat'], // 场次座位
|
|
231
|
231
|
'create_time' => time()
|
|
232
|
232
|
];
|
|
233
|
|
- $order_sn = Db::transaction(function () use ($userinfo, $_order) {
|
|
234
|
|
- $_order = $this->dao->create($_order);
|
|
235
|
|
- if ($_order) return $_order['order_sn'];
|
|
|
233
|
+ $order_id = Db::transaction(function () use ($userinfo, $_order) {
|
|
|
234
|
+ $orderModel = $this->dao->create($_order);
|
|
|
235
|
+ if ($orderModel) return $orderModel['order_id'];
|
|
236
|
236
|
throw new ValidateException('锁座下单失败');
|
|
237
|
237
|
});
|
|
238
|
|
- return $order_sn;
|
|
|
238
|
+ return $order_id;
|
|
239
|
239
|
} else {
|
|
240
|
240
|
throw new ValidateException($submitOrder['msg']);
|
|
241
|
241
|
}
|
|
|
@@ -250,15 +250,15 @@ class MovieRepository extends BaseRepository
|
|
250
|
250
|
* @throws \think\db\exception\DbException
|
|
251
|
251
|
* @throws \think\db\exception\ModelNotFoundException
|
|
252
|
252
|
*/
|
|
253
|
|
- public function confirmOrder($userinfo, $order_sn, $pay_type)
|
|
|
253
|
+ public function confirmOrder($userinfo, $order_id, $pay_type, $code)
|
|
254
|
254
|
{
|
|
255
|
|
- $orderinfo = $this->dao->search(['order_sn' => $order_sn, 'uid' => $userinfo['uid']])->find();
|
|
|
255
|
+ $orderinfo = $this->dao->search(['order_id' => $order_id])->find();
|
|
256
|
256
|
if (empty($orderinfo)) throw new ValidateException('订单不存在');
|
|
257
|
257
|
if ($orderinfo['paid'] == 0 && $orderinfo['status'] == 2) throw new ValidateException('订单已超时');
|
|
258
|
258
|
if ($orderinfo['paid'] == 0 && $orderinfo['status'] == 3) throw new ValidateException('订单已取消');
|
|
259
|
259
|
if ($orderinfo['paid'] == 1) throw new ValidateException('订单已支付');
|
|
260
|
260
|
|
|
261
|
|
- $res = $this->pay($pay_type, $userinfo['wechat_user_id'], $orderinfo, $orderinfo['film_name'], env('APP_URL') . "/api/hf_notify/movie", 'delay');
|
|
|
261
|
+ $res = $this->movie_pay($pay_type, $code, $userinfo['wechat_user_id'], $orderinfo, $orderinfo['film_name'], env('APP_URL') . "/api/hf_notify/movie", 'delay');
|
|
262
|
262
|
Db::name('log')->insert(['data' => '汇付电影票订单支付--- 返回参数' . json_encode($res)]);
|
|
263
|
263
|
if (isset($res['id'])) {
|
|
264
|
264
|
$type = 0;
|
|
|
@@ -352,6 +352,150 @@ class MovieRepository extends BaseRepository
|
|
352
|
352
|
}
|
|
353
|
353
|
|
|
354
|
354
|
/**
|
|
|
355
|
+ * 电影票支付
|
|
|
356
|
+ *
|
|
|
357
|
+ * @param $payType
|
|
|
358
|
+ * @param $code
|
|
|
359
|
+ * @param $wechat_user_id
|
|
|
360
|
+ * @param $orderinfo
|
|
|
361
|
+ * @param $title
|
|
|
362
|
+ * @param $notify_url
|
|
|
363
|
+ * @param $pay_mode
|
|
|
364
|
+ * @param $appid
|
|
|
365
|
+ * @return array|mixed|void
|
|
|
366
|
+ */
|
|
|
367
|
+ private function movie_pay($payType, $code, $wechat_user_id, $orderinfo, $title, $notify_url, $pay_mode = null, $appid = '')
|
|
|
368
|
+ {
|
|
|
369
|
+ if ($payType == 'wx') {
|
|
|
370
|
+ if (!$code || $code == '' || $code == 'undefined') {
|
|
|
371
|
+ throw new ValidateException('授权失败,code为空');
|
|
|
372
|
+ }
|
|
|
373
|
+ if ($appid == '') {
|
|
|
374
|
+ $pay_wx = systemConfig('pay_wx');
|
|
|
375
|
+ if ($pay_wx == 2) {
|
|
|
376
|
+ $appid = env('WECHAT_MP.APPID');
|
|
|
377
|
+ $new_secret = env('WECHAT_MP.SECRET');
|
|
|
378
|
+
|
|
|
379
|
+ $app_id = 'app_0827b960-b932-45ec-b800-4e850091b419';
|
|
|
380
|
+ $key = 'api_live_90ef02e4-54ac-41ee-adf1-e4927d23d58f';
|
|
|
381
|
+ } elseif ($pay_wx == 3) {
|
|
|
382
|
+ $appid = env('WECHAT_TDYL.APPID');
|
|
|
383
|
+ $new_secret = env('WECHAT_TDYL.SECRET');
|
|
|
384
|
+
|
|
|
385
|
+ Db::name('log')->insert(['data' => 'appid---' . $appid]);
|
|
|
386
|
+ Db::name('log')->insert(['data' => 'new_secret---' . $new_secret]);
|
|
|
387
|
+ $app_id = 'app_383a75dd-c03d-44ab-8f58-92c60fe9b9d0';
|
|
|
388
|
+ $key = 'api_live_b0a687ec-5450-4ada-a0e4-65bac0f46871';
|
|
|
389
|
+ }
|
|
|
390
|
+ } else {
|
|
|
391
|
+ $app_id = 'app_0827b960-b932-45ec-b800-4e850091b419';
|
|
|
392
|
+ $key = 'api_live_90ef02e4-54ac-41ee-adf1-e4927d23d58f';
|
|
|
393
|
+ $new_secret = "c8cbe24fa3b83f77a88b79554b3aeab4";
|
|
|
394
|
+ }
|
|
|
395
|
+
|
|
|
396
|
+ $url = "https://api.weixin.qq.com/sns/jscode2session?appid=" . $appid . "&secret=" . $new_secret . "&js_code=" . $code . "&grant_type=authorization_code";
|
|
|
397
|
+ $get = curlGet($url);
|
|
|
398
|
+ Db::name('log')->insert(['data' => 'open_id---' . json_encode($get)]);
|
|
|
399
|
+ if (!isset($get['openid']) || empty($get['openid'])) {
|
|
|
400
|
+ throw new ValidateException('授权失败');
|
|
|
401
|
+ }
|
|
|
402
|
+ $member_id = 0;
|
|
|
403
|
+ $type = '2';
|
|
|
404
|
+ $pay_channel = 'wx_lite';
|
|
|
405
|
+
|
|
|
406
|
+ $expend = ['open_id' => $get['openid'], 'wx_app_id' => $appid];
|
|
|
407
|
+ if (false) {
|
|
|
408
|
+// if ($orderinfo['order_type'] = "movie") {
|
|
|
409
|
+ $cfb = sprintf("%01.2f", round(bcmul($orderinfo['order_price'], '0.094', 5), 2));//9.4%的分账
|
|
|
410
|
+ $cfb_member = "jsdk_member_1680162243019";
|
|
|
411
|
+ // 平台
|
|
|
412
|
+ $cxb = sprintf("%01.2f", round(bcsub($orderinfo['order_price'], $cfb, 5), 2));//剩下的归平台
|
|
|
413
|
+ $div_members = [
|
|
|
414
|
+// [
|
|
|
415
|
+// 'member_id' => $member_id,
|
|
|
416
|
+// 'amount' => $cxb,
|
|
|
417
|
+// 'fee_flag' => 'Y'
|
|
|
418
|
+// ],
|
|
|
419
|
+// [
|
|
|
420
|
+// 'member_id' => $cfb_member,
|
|
|
421
|
+// 'amount' => $cfb,
|
|
|
422
|
+// 'fee_flag' => 'N'
|
|
|
423
|
+// ]
|
|
|
424
|
+ ];
|
|
|
425
|
+ } else {
|
|
|
426
|
+ $div_members = [
|
|
|
427
|
+ [
|
|
|
428
|
+ 'member_id' => $member_id,
|
|
|
429
|
+ 'amount' => $orderinfo['order_price'],
|
|
|
430
|
+ 'fee_flag' => 'Y'
|
|
|
431
|
+ ]
|
|
|
432
|
+ ];
|
|
|
433
|
+ }
|
|
|
434
|
+
|
|
|
435
|
+ $params = [
|
|
|
436
|
+ 'order_no' => $orderinfo['order_sn'],
|
|
|
437
|
+ 'app_id' => $app_id,
|
|
|
438
|
+ 'pay_channel' => $pay_channel,
|
|
|
439
|
+ 'pay_amt' => (string)$orderinfo['order_price'],
|
|
|
440
|
+ 'goods_title' => strlen($title) > 64 ? mb_substr($title, 0, 64, 'utf-8') : $title,// 解决因为太长不能支付问题
|
|
|
441
|
+ 'goods_desc' => strlen($title) > 42 ? mb_substr($title, 0, 127, 'utf-8') : $title,// 解决因为太长不能支付问题
|
|
|
442
|
+ 'device_info' => [
|
|
|
443
|
+ 'device_ip' => app('request')->ip()
|
|
|
444
|
+ ],
|
|
|
445
|
+ 'expend' => json_encode($expend),
|
|
|
446
|
+ 'div_members' => json_encode($div_members),
|
|
|
447
|
+ 'fee_mode' => 'I',
|
|
|
448
|
+ 'notify_url' => $notify_url
|
|
|
449
|
+ ];
|
|
|
450
|
+ if ($pay_mode == 'delay') {
|
|
|
451
|
+ $params['pay_mode'] = 'delay';
|
|
|
452
|
+ unset($params['div_members']);
|
|
|
453
|
+ unset($params['fee_mode']);
|
|
|
454
|
+ }
|
|
|
455
|
+ return $this->Payment_create_traits_b($params, $type, $key);
|
|
|
456
|
+ } elseif ($payType == 'ALI') {
|
|
|
457
|
+ $member_id = 0;
|
|
|
458
|
+ $type = '1';
|
|
|
459
|
+ $pay_channel = 'alipay_qr';
|
|
|
460
|
+ // 天地博爱科技通道
|
|
|
461
|
+ $app_id = 'app_44108546-d27a-48ee-88c1-84b45b75114f';
|
|
|
462
|
+ $key = 'api_live_b23537ed-64b8-45d6-832e-fb228aa9e0a9';
|
|
|
463
|
+ // 天地博爱通道
|
|
|
464
|
+// $app_id='app_0827b960-b932-45ec-b800-4e850091b419';
|
|
|
465
|
+// $key='api_live_90ef02e4-54ac-41ee-adf1-e4927d23d58f';
|
|
|
466
|
+
|
|
|
467
|
+ $div_members = [
|
|
|
468
|
+ [
|
|
|
469
|
+ 'member_id' => $member_id,
|
|
|
470
|
+ 'amount' => $orderinfo['order_price'],
|
|
|
471
|
+ 'fee_flag' => 'Y'
|
|
|
472
|
+ ]
|
|
|
473
|
+ ];
|
|
|
474
|
+
|
|
|
475
|
+ $params = [
|
|
|
476
|
+ 'order_no' => $orderinfo['order_sn'],
|
|
|
477
|
+ 'app_id' => $app_id,
|
|
|
478
|
+ 'pay_channel' => $pay_channel,
|
|
|
479
|
+ 'pay_amt' => (string)$orderinfo['order_price'],
|
|
|
480
|
+ 'goods_title' => strlen($title) > 64 ? mb_substr($title, 0, 64, 'utf-8') : $title,// 解决因为太长不能支付问题
|
|
|
481
|
+ 'goods_desc' => strlen($title) > 42 ? mb_substr($title, 0, 127, 'utf-8') : $title,// 解决因为太长不能支付问题
|
|
|
482
|
+ 'device_info' => [
|
|
|
483
|
+ 'device_ip' => app('request')->ip()
|
|
|
484
|
+ ],
|
|
|
485
|
+ 'div_members' => json_encode($div_members),
|
|
|
486
|
+ 'fee_mode' => 'I',
|
|
|
487
|
+ 'notify_url' => $notify_url
|
|
|
488
|
+ ];
|
|
|
489
|
+ if ($pay_mode == 'delay') {
|
|
|
490
|
+ $params['pay_mode'] = 'delay';
|
|
|
491
|
+ unset($params['div_members']);
|
|
|
492
|
+ unset($params['fee_mode']);
|
|
|
493
|
+ }
|
|
|
494
|
+ return $this->Payment_create_traits_a($params, $type, $key);
|
|
|
495
|
+ }
|
|
|
496
|
+ }
|
|
|
497
|
+
|
|
|
498
|
+ /**
|
|
355
|
499
|
* @param $userinfo
|
|
356
|
500
|
* @param $order_sn
|
|
357
|
501
|
* @return mixed|string
|