57 lines
1.4 KiB
PHP
Executable File
57 lines
1.4 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Http\Controllers\Api\Customer;
|
|
|
|
use App\Enums\BoolEnum;
|
|
use App\Http\Controllers\Controller;
|
|
use App\Model\Customer\Customer;
|
|
use App\Model\Seller\Shop;
|
|
use App\Model\Seller\ShopPayChannel;
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
class BaseController extends Controller
|
|
{
|
|
|
|
/**
|
|
* @return null|Customer
|
|
*/
|
|
public function customer()
|
|
{
|
|
return Auth::guard('customer')->user();
|
|
}
|
|
|
|
public function customerId()
|
|
{
|
|
return $this->customer()->id;
|
|
}
|
|
|
|
public function customerShopId()
|
|
{
|
|
return $this->customer()->shop_id;
|
|
}
|
|
|
|
public function getPayTypes()
|
|
{
|
|
$channel = ShopPayChannel::where('opened', BoolEnum::YES)
|
|
->where('shop_id', $this->customerShopId())
|
|
->where('state', ShopPayChannel::STATE_SUCCESS)
|
|
->orderBy('pay_type', 'asc')
|
|
->get();
|
|
|
|
$result = [];
|
|
foreach ($channel as $item) {
|
|
$result[] = [
|
|
'id' => $item->id,
|
|
'pay_type' => $item->pay_type,
|
|
'pay_channel' => $item->pay_channel,
|
|
'name' => $item->pay_channel_name,
|
|
'wechat_qrcode' => $item->wechat_qrcode_url,
|
|
'alipay_qrcode' => $item->alipay_qrcode_url,
|
|
'remind_after' => $item->remind_after,
|
|
'remind_before' => $item->remind_before,
|
|
];
|
|
}
|
|
return $result;
|
|
}
|
|
}
|