93 lines
2.2 KiB
PHP
Executable File
93 lines
2.2 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Model\Seller;
|
|
|
|
use App\Enums\PayType;
|
|
use App\Model\BaseModel;
|
|
use App\Utils\Helps;
|
|
use Illuminate\Support\Arr;
|
|
use Tymon\JWTAuth\Payload;
|
|
|
|
class ShopPayChannel extends BaseModel
|
|
{
|
|
const STATE_SUCCESS = 1;
|
|
// const STATE_PENDING = 2;
|
|
const STATE_FAIL = 2;
|
|
const STATE_SUBMIT = 3;
|
|
|
|
protected $appends = [
|
|
'wechat_qrcode_url',
|
|
'alipay_qrcode_url',
|
|
'business_site_url',
|
|
'business_door_url',
|
|
'sale_proxy_url',
|
|
'pay_channel_name',
|
|
];
|
|
|
|
public function getWechatQrcodeUrlAttribute()
|
|
{
|
|
if (!$this->wechat_qrcode) {
|
|
return '';
|
|
}
|
|
return Helps::fullUrl($this->wechat_qrcode);
|
|
}
|
|
|
|
public function getAlipayQrcodeUrlAttribute()
|
|
{
|
|
if (!$this->alipay_qrcode) {
|
|
return '';
|
|
}
|
|
return Helps::fullUrl($this->alipay_qrcode);
|
|
}
|
|
public function getBusinessSiteUrlAttribute()
|
|
{
|
|
if (!$this->business_site) {
|
|
return '';
|
|
}
|
|
return Helps::fullUrl($this->business_site);
|
|
}
|
|
public function getBusinessDoorUrlAttribute()
|
|
{
|
|
if (!$this->business_door) {
|
|
return '';
|
|
}
|
|
return Helps::fullUrl($this->business_door);
|
|
}
|
|
public function getSaleProxyUrlAttribute()
|
|
{
|
|
if (!$this->sale_proxy) {
|
|
return '';
|
|
}
|
|
return Helps::fullUrl($this->sale_proxy);
|
|
}
|
|
|
|
public function getPayChannelNameAttribute()
|
|
{
|
|
if ($this->pay_type == PayType::ALIPAY) {
|
|
$channels = self::payChannels();
|
|
return $this->channel_name . '(' . Arr::get($channels, $this->pay_channel) . ')';
|
|
}
|
|
return $this->channel_name;
|
|
}
|
|
|
|
public static function payChannels() {
|
|
return [
|
|
1 => '渠道一',
|
|
2 => '渠道二',
|
|
3 => '渠道三',
|
|
];
|
|
}
|
|
|
|
public function shop() {
|
|
return $this->belongsTo(Shop::class, 'shop_id', 'id');
|
|
}
|
|
|
|
public static function stateAsArray() {
|
|
return [
|
|
self::STATE_SUCCESS => '成功',
|
|
self::STATE_FAIL => '失败',
|
|
self::STATE_SUBMIT => '提交',
|
|
];
|
|
}
|
|
}
|