Sfoglia il codice sorgente

新增话费支付和支付完成回调

xialei 1 anno fa
parent
commit
abc5ff6053

+ 11 - 0
app/controller/api/Notify.php

@@ -44,6 +44,17 @@ class Notify
44
                     $pay_type = $post_data_str['pay_channel'];
44
                     $pay_type = $post_data_str['pay_channel'];
45
                     $pay_type = $pay_type == 'wx_lite' ? 1 : 4;
45
                     $pay_type = $pay_type == 'wx_lite' ? 1 : 4;
46
                     switch ($type){
46
                     switch ($type){
47
+                        case 'huafei':
48
+                            //话费充值支付成功推送
49
+                            try{
50
+                                $order_data = Db::name('rrx_order_huafei_hf') -> where('order_no', $requestId[0])->find();
51
+                                if($order_data['status']==1) return false;
52
+                                $pay_type = $pay_type == 1 ? 'wx' : 'al';
53
+                                Db::name('rrx_order_huafei_hf')->where('order_no',$requestId[0])->update(['rand'=>$requestId[1],'pay_type'=>$pay_type,'status'=>1]);
54
+                            }catch (\Exception $e) {
55
+                                Db::name('log')->insert(['data'=>'话费充值支付回调错误:'.$e->getFile().':'.$e->getLine().'【'.$e->getMessage().'】']);
56
+                            }
57
+                            break;
47
                         case 'pay':
58
                         case 'pay':
48
                             //商城集合订单
59
                             //商城集合订单
49
                             Db::name('store_group_order') -> where('group_order_sn',$requestId[0]) -> update(['rand'=>$requestId[1]]);
60
                             Db::name('store_group_order') -> where('group_order_sn',$requestId[0]) -> update(['rand'=>$requestId[1]]);

+ 33 - 0
app/controller/api/merchant/sxy/Access.php

@@ -721,6 +721,37 @@ class Access
721
         return $result;
721
         return $result;
722
     }
722
     }
723
 
723
 
724
+
725
+
726
+    //app小程序话费支付
727
+    public function hf_pay_wechat_mp(){
728
+        try {
729
+            log::info("微信小程序回调");
730
+            Db::name('log')->insert(['data'=>'汇付订单支付pay_wechat_mp-66666666---发起支付']);
731
+            $oid = Request::param('oid','');
732
+            $code = Request::param('code','');
733
+            $type = Request::param('type','');
734
+            if($oid == '') return app('json')->fail("请检查参数是否正确");
735
+
736
+			$groupOrder = Db::name('order_huafei_hf')->where('order_id', (int)$oid)->find();
737
+            if (!$groupOrder) return app('json')->fail('订单不存在或已支付');
738
+ 
739
+            $res = $this->pay_huifu($type,$code,$groupOrder,"储蓄保",env('APP_URL')."/api/hf_notify/huafei",'delay');
740
+            Db::name('log')->insert(['data'=>'汇付话费订单支付--- 返回参数'.json_encode($res)]);
741
+            if (isset($res['id'])) {
742
+                return app('json')->success($res);
743
+            }
744
+            return app('json')->fail($res);
745
+        }catch (Exception $exception){
746
+            log::info("支付异常======");
747
+            log::info($exception);
748
+            Db::name("log")->insert(array('data'=>$exception->getFile().':'.$exception->getLine().'【'.$exception->getMessage().'】'));//日志记录
749
+            return app('json')->fail("异常");
750
+        }
751
+    }
752
+
753
+
754
+
724
     //小程序支付
755
     //小程序支付
725
     public function pay_wechat_mp(StoreGroupOrderRepository $groupOrderRepository){
756
     public function pay_wechat_mp(StoreGroupOrderRepository $groupOrderRepository){
726
         try {
757
         try {
@@ -823,6 +854,7 @@ class Access
823
         }
854
         }
824
 
855
 
825
     }
856
     }
857
+    
826
 
858
 
827
 
859
 
828
     //小程序支付
860
     //小程序支付
@@ -1317,6 +1349,7 @@ class Access
1317
 
1349
 
1318
     }
1350
     }
1319
 
1351
 
1352
+
1320
     //退款
1353
     //退款
1321
     public function refund(){
1354
     public function refund(){
1322
         $data['requestId'] = ShouxinyiApiRequest::getOrderNumber('refund');    //订单号
1355
         $data['requestId'] = ShouxinyiApiRequest::getOrderNumber('refund');    //订单号

+ 40 - 24
app/controller/api/store/service/Huafei.php

@@ -90,32 +90,48 @@ class Huafei extends BaseController
90
 		//验证
90
 		//验证
91
 		$verify = $this->verify($params['phone'], $params['money']);
91
 		$verify = $this->verify($params['phone'], $params['money']);
92
 		if($verify['code'] == '0000'){
92
 		if($verify['code'] == '0000'){
93
-			//推送
94
-			$order_sn = time().$uid;
95
-			$push = $this->pushOrder($order_sn, $params['phone'], $params['money']);
96
-			if($push['code'] == '0000'){
97
-				//入库记录
98
-				$insertdata = [
99
-					'uid'=> $uid,
100
-					'mobile' => $params['phone'],
101
-					'commission'=> 0,
102
-					'commission_share'=> 0.04,
103
-					'order_number' => $push['data']['order_number'],
104
-					'order_sn' => $order_sn,
105
-					'amount_price' => $push['data']['amount'],
106
-					'fanli_price' => $push['data']['fanli'],
107
-					'cost_price' => $push['data']['cost_price'],
108
-					'pay_money' => $params['money'],
109
-					'status' => 0,
110
-					'create_time' => time(),
111
-					'finish_time' => time(),
112
-					'modify_time' => time(),
113
-				];
114
-				Db::name('order_huafei')->insert($insertdata);
115
-				return app('json')->success('话费推送成功', $push);
93
+			$order_sn = time().$uid.mt_rand(1000,9999);
94
+			//创建预支付订单
95
+			$insertdata = [
96
+				'uid'=> $uid,
97
+				'mobile' => $params['phone'],
98
+				'order_no' => $order_sn,
99
+				'pay_price' => $params['money'],
100
+				'status' => 0,
101
+				'create_time' => time(),
102
+			];
103
+			$oid = Db::name('order_huafei_hf')->insertGetId($insertdata);
104
+			if($oid){
105
+				return app('json')->success('订单创建成功', ['oid'=>$oid, 'order_sn'=>$order_sn]);
116
 			}else{
106
 			}else{
117
-				return app('json')->fail($push['msg']);
107
+				return app('json')->fail('创建话费充值预支付订单失败');
118
 			}
108
 			}
109
+
110
+			//推送订单
111
+			// $push = $this->pushOrder($order_sn, $params['phone'], $params['money']);
112
+			// if($push['code'] == '0000'){
113
+			// 	//入库记录
114
+			// 	$insertdata = [
115
+			// 		'uid'=> $uid,
116
+			// 		'mobile' => $params['phone'],
117
+			// 		'commission'=> 0,
118
+			// 		'commission_share'=> 0.04,
119
+			// 		'order_number' => $push['data']['order_number'],
120
+			// 		'order_sn' => $order_sn,
121
+			// 		'amount_price' => $push['data']['amount'],
122
+			// 		'fanli_price' => $push['data']['fanli'],
123
+			// 		'cost_price' => $push['data']['cost_price'],
124
+			// 		'pay_money' => $params['money'],
125
+			// 		'status' => 0,
126
+			// 		'create_time' => time(),
127
+			// 		'finish_time' => time(),
128
+			// 		'modify_time' => time(),
129
+			// 	];
130
+			// 	Db::name('order_huafei')->insert($insertdata);
131
+			// 	return app('json')->success('话费推送成功', $push);
132
+			// }else{
133
+			// 	return app('json')->fail($push['msg']);
134
+			// }
119
 		}else{
135
 		}else{
120
 			return app('json')->fail($verify['msg']);
136
 			return app('json')->fail($verify['msg']);
121
 		}
137
 		}

+ 2 - 0
route/api.php

@@ -1130,6 +1130,8 @@ Route::group('api/', function () {
1130
     Route::any('test1111', 'api.merchant.sxy.Access/test1111');//回调
1130
     Route::any('test1111', 'api.merchant.sxy.Access/test1111');//回调
1131
     //app小程序支付
1131
     //app小程序支付
1132
     Route::get('sxy_pay_wechat_mp', 'api.merchant.sxy.Access/pay_wechat_mp');
1132
     Route::get('sxy_pay_wechat_mp', 'api.merchant.sxy.Access/pay_wechat_mp');
1133
+    //app小程序话费支付
1134
+    Route::get('hf_pay_wechat_mp', 'api.merchant.sxy.Access/hf_pay_wechat_mp');
1133
     //app小程序支付年费
1135
     //app小程序支付年费
1134
     Route::get('pay_annual_cost', 'api.merchant.sxy.Access/pay_annual_cost');
1136
     Route::get('pay_annual_cost', 'api.merchant.sxy.Access/pay_annual_cost');
1135
     //app小程序支付激活码费用
1137
     //app小程序支付激活码费用