1
0

提交代码

This commit is contained in:
2020-08-06 14:45:56 +08:00
commit 9d0d5f4be9
361 changed files with 36445 additions and 0 deletions

View File

@@ -0,0 +1,66 @@
<?php
namespace App\Agent\Controllers;
use App\Models\CardOrder;
use App\Models\CardPayment;
use Illuminate\Http\Request;
class PayController extends Controller
{
private function getpayOrder(CardOrder $order, $type)
{
$payOrder = CardPayment::create([
'card_order_id' => $order->id,
'type' => $type,
'amount' => $order->price,
]);
return $payOrder;
}
public function order(Request $request, $orderid)
{
$order = CardOrder::where('order_id', $orderid)->first();
return view('Agent::pay.order', compact('order'));
}
/**
* 微信支付
* @param Request $request [description]
* @param [type] $orderid [description]
* @return [type] [description]
*/
public function wechat(Request $request, $orderid)
{
$order = CardOrder::where('order_id', $orderid)->first();
$openid = $order->user->openid;
$amount = $order->price;
$payOrder = $this->getpayOrder($order, 'WECHAT');
if ($amount != $payOrder->amount) {
$payOrder->amount = $amount;
$payOrder->save();
}
$app = app('wechat.payment');
$amount = $payOrder->amount;
$result = $app->order->unify([
'body' => '商城订单-进货卡',
'out_trade_no' => $payOrder->trade_no,
// 'total_fee' => $amount * 100,
'total_fee' => 1,
'notify_url' => route('Agent.notify.payment'),
'trade_type' => 'JSAPI',
'openid' => $openid,
]);
if ($result['return_code'] == 'SUCCESS' && isset($result['prepay_id'])) {
$json = $app->jssdk->bridgeConfig($result['prepay_id']);
return $this->success($json);
} else {
return $this->error($result['return_msg']);
}
}
}