Browse Source

Finished PayJs & Clean Code

兔姬桑 4 years ago
parent
commit
5543fcebd3

+ 2 - 1
app/Http/Controllers/AdminController.php

@@ -1338,8 +1338,9 @@ EOF;
 		$websiteAnalytics = $request->input('website_analytics');
 		$websiteCustomerService = $request->input('website_customer_service');
 
-		DB::beginTransaction();
 		try{
+			DB::beginTransaction();
+
 			// 首页LOGO
 			if($request->hasFile('website_home_logo')){
 				$file = $request->file('website_home_logo');

+ 2 - 7
app/Http/Controllers/Gateway/AbstractPayment.php

@@ -33,13 +33,8 @@ abstract class AbstractPayment {
 
 	abstract public function purchase(Request $request);
 
-
 	abstract public function notify(Request $request);
 
-	abstract public function getReturnHTML(Request $request);
-
-	abstract public function getPurchaseHTML();
-
 	public function postPayment($data, $method) {
 		// 获取需要的信息
 		$payment = Payment::whereTradeNo($data)->first();
@@ -55,6 +50,7 @@ abstract class AbstractPayment {
 
 		//余额充值
 		if($order->goods_id == -1){
+			Order::query()->whereOid($order->oid)->update(['status'=>2]);
 			User::query()->whereId($order->user_id)->increment('credit', $order->amount * 100);
 			// 余额变动记录日志
 			Helpers::addUserCreditLog($order->user_id, $order->oid, $order->user->credit,
@@ -66,8 +62,7 @@ abstract class AbstractPayment {
 		// 商品为流量或者套餐
 		switch($goods->type){
 			case 1:
-				$order->status = 2;
-				$order->save();
+				Order::query()->whereOid($order->oid)->update(['status'=>2]);
 				User::query()->whereId($order->user_id)->increment('transfer_enable', $goods->traffic * MB);
 				Helpers::addUserTrafficModifyLog($order->user_id, $order->oid, $user->transfer_enable,
 					$user->transfer_enable + $goods->traffic * MB, '['.$method.']加上用户购买的套餐流量');

+ 4 - 14
app/Http/Controllers/Gateway/BitpayX.php

@@ -56,11 +56,11 @@ class BitpayX extends AbstractPayment {
 		return Response::json(['status' => 'fail', 'data' => $result, 'message' => '创建订单失败!']);
 	}
 
-	public function sign($data) {
+	private function sign($data) {
 		return strtolower(md5(md5($data).parent::$systemConfig['bitpay_secret']));
 	}
 
-	public function prepareSignId($tradeno) {
+	private function prepareSignId($tradeno) {
 		$data_sign = [
 			'merchant_order_id' => $tradeno,
 			'secret'            => parent::$systemConfig['bitpay_secret'],
@@ -71,7 +71,7 @@ class BitpayX extends AbstractPayment {
 		return http_build_query($data_sign);
 	}
 
-	public function mprequest($data, $type = 'pay') {
+	private function mprequest($data, $type = 'pay') {
 		$headers = ['content-type: application/json', 'token: '.parent::$systemConfig['bitpay_secret']];
 		$curl = curl_init();
 		if($type === 'pay'){
@@ -117,28 +117,18 @@ class BitpayX extends AbstractPayment {
 
 		if($resultVerify && $isPaid){
 			$this->postPayment($inputJSON['merchant_order_id'], 'BitPayX');
-			$return = [];
 			$return['status'] = 200;
 			echo json_encode($return);
 		}else{
-			$return = [];
 			$return['status'] = 400;
 			echo json_encode($return);
 		}
 		exit();
 	}
 
-	public function verify($data, $signature) {
+	private function verify($data, $signature) {
 		$mySign = $this->sign($data);
 
 		return $mySign === $signature;
 	}
-
-	public function getReturnHTML(Request $request) {
-		// TODO: Implement getReturnHTML() method.
-	}
-
-	public function getPurchaseHTML() {
-		// TODO: Implement getPurchaseHTML() method.
-	}
 }

+ 0 - 8
app/Http/Controllers/Gateway/CodePay.php

@@ -77,12 +77,4 @@ class CodePay extends AbstractPayment {
 		}
 		exit('fail');
 	}
-
-	public function getReturnHTML($request) {
-		// TODO: Implement getReturnHTML() method.
-	}
-
-	public function getPurchaseHTML() {
-		// TODO: Implement getReturnHTML() method.
-	}
 }

+ 0 - 8
app/Http/Controllers/Gateway/F2Fpay.php

@@ -101,12 +101,4 @@ class F2Fpay extends AbstractPayment {
 		// 返回验证结果
 		exit($ret);
 	}
-
-	public function getReturnHTML($request) {
-		// TODO: Implement getReturnHTML() method.
-	}
-
-	public function getPurchaseHTML() {
-		// TODO: Implement getReturnHTML() method.
-	}
 }

+ 0 - 8
app/Http/Controllers/Gateway/Local.php

@@ -33,12 +33,4 @@ class Local extends AbstractPayment {
 	public function notify(Request $request) {
 		// TODO: Implement notify() method.
 	}
-
-	public function getReturnHTML(Request $request) {
-		// TODO: Implement getReturnHTML() method.
-	}
-
-	public function getPurchaseHTML() {
-		// TODO: Implement getPurchaseHTML() method.
-	}
 }

+ 3 - 11
app/Http/Controllers/Gateway/PayJs.php

@@ -35,11 +35,11 @@ class PayJs extends AbstractPayment {
 			'notify_url'   => (parent::$systemConfig['website_callback_url']?: parent::$systemConfig['website_url']).'/callback/notify?method=payjs',
 		]);
 
-		if(!$result->return_code){
-			Log::error('PayJs '.$result->return_msg);
+		if($result['return_code'] != 1){
+			Log::error('PayJs '.$result['return_msg']);
 		}
 		// 获取收款二维码内容
-		Payment::whereId($payment->id)->update(['qr_code' => $result->qrcode]);
+		Payment::whereId($payment->id)->update(['qr_code' => $result['qrcode']]);
 
 		return Response::json(['status' => 'success', 'data' => $payment->trade_no, 'message' => '创建订单成功!']);
 	}
@@ -53,12 +53,4 @@ class PayJs extends AbstractPayment {
 		}
 		exit("fail");
 	}
-
-	public function getReturnHTML($request) {
-		// TODO: Implement getReturnHTML() method.
-	}
-
-	public function getPurchaseHTML() {
-		// TODO: Implement getReturnHTML() method.
-	}
 }

+ 0 - 8
app/Http/Controllers/Gateway/PayPal.php

@@ -138,12 +138,4 @@ class PayPal extends AbstractPayment {
 		}
 		exit("fail");
 	}
-
-	public function getReturnHTML(Request $request) {
-		// TODO: Implement getReturnHTML() method.
-	}
-
-	public function getPurchaseHTML() {
-		// TODO: Implement getPurchaseHTML() method.
-	}
 }

File diff suppressed because it is too large
+ 138 - 371
resources/views/admin/config/system.blade.php


+ 2 - 1
resources/views/user/payment.blade.php

@@ -11,7 +11,8 @@
 				<div class="row">
 					<div class="col-2"></div>
 					<div class="alert alert-info col-8 text-center">
-						请使用<strong class="red-600"> 支付宝 </strong>扫描二维码进行支付
+						请扫描二维码进行支付
+{{--						请使用<strong class="red-600"> 支付宝 </strong>扫描二维码进行支付--}}
 					</div>
 					<div class="col-2"></div>
 					<div class="col-2"></div>

Some files were not shown because too many files changed in this diff