第二次更新
This commit is contained in:
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | 企油通企业模型
|
||||
// +----------------------------------------------------------------------
|
||||
// | 一个接入方 appId 下可挂多个企业(见《企油通接口对接文档.md》7.22)。
|
||||
// | 企业级参数:business_license / passageway / institution_id 等存本表;
|
||||
// | 接入方级参数:appId、RSA 私钥、接口域名仍在 .env,私钥不入库。
|
||||
// +----------------------------------------------------------------------
|
||||
declare (strict_types=1);
|
||||
|
||||
namespace app\common\model\qyt;
|
||||
|
||||
use cores\BaseModel;
|
||||
|
||||
class Enterprise extends BaseModel
|
||||
{
|
||||
protected $name = 'qyt_enterprise';
|
||||
|
||||
protected $pk = 'enterprise_id';
|
||||
|
||||
/** 通道:配置键 => 企油通 passageway 编码 */
|
||||
const PASSAGEWAY_CODE = [
|
||||
'alipay' => 1,
|
||||
'pingan' => 2,
|
||||
];
|
||||
|
||||
/** 通道名称 */
|
||||
const PASSAGEWAY_NAME = [
|
||||
'alipay' => '支付宝企业码',
|
||||
'pingan' => '平安银行',
|
||||
];
|
||||
|
||||
/** 企业状态(文档 2.6) */
|
||||
const STATUS_TEXT = [
|
||||
'pending' => '待完善',
|
||||
'submitted' => '待审核',
|
||||
'approved' => '审核通过',
|
||||
'rejected' => '审核拒绝',
|
||||
'frozen' => '已冻结',
|
||||
];
|
||||
|
||||
/**
|
||||
* 企业详情
|
||||
* @param int|array $where
|
||||
* @return static|null
|
||||
*/
|
||||
public static function detail($where)
|
||||
{
|
||||
!is_array($where) && $where = ['enterprise_id' => (int) $where];
|
||||
return static::get($where);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取默认企业(合作商未绑定时的兜底)
|
||||
* @return static|null
|
||||
*/
|
||||
public static function getDefault()
|
||||
{
|
||||
return static::where('is_enable', 1)->where('is_default', 1)
|
||||
->order('enterprise_id', 'asc')->find();
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析某个合作商本次下单应使用的企业
|
||||
* 优先级:合作商绑定的企业 -> 默认企业;都取不到返回 null,由调用方拒单
|
||||
* @param int $enterpriseId 合作商绑定的企业ID,0 表示未绑定
|
||||
* @return static|null
|
||||
*/
|
||||
public static function resolve(int $enterpriseId = 0)
|
||||
{
|
||||
if ($enterpriseId > 0) {
|
||||
$one = static::where('enterprise_id', $enterpriseId)->where('is_enable', 1)->find();
|
||||
if ($one) {
|
||||
return $one;
|
||||
}
|
||||
}
|
||||
return static::getDefault();
|
||||
}
|
||||
|
||||
/** 当前通道的企油通 passageway 编码 */
|
||||
public function passagewayCode(): int
|
||||
{
|
||||
return self::PASSAGEWAY_CODE[$this->getData('passageway')] ?? self::PASSAGEWAY_CODE['alipay'];
|
||||
}
|
||||
|
||||
/** 当前通道中文名 */
|
||||
public function passagewayName(): string
|
||||
{
|
||||
return self::PASSAGEWAY_NAME[$this->getData('passageway')] ?? '';
|
||||
}
|
||||
|
||||
/** 当前通道是否要求司机身份证号(平安银行要求实名) */
|
||||
public function requireIdCard(): bool
|
||||
{
|
||||
return $this->getData('passageway') === 'pingan';
|
||||
}
|
||||
|
||||
/** 状态中文(访问器,后台列表直接可用) */
|
||||
public function getStatusTextAttr($value, $data): string
|
||||
{
|
||||
return self::STATUS_TEXT[$data['status'] ?? ''] ?? ($data['status'] ?? '');
|
||||
}
|
||||
|
||||
/** 通道中文(访问器) */
|
||||
public function getPassagewayTextAttr($value, $data): string
|
||||
{
|
||||
return self::PASSAGEWAY_NAME[$data['passageway'] ?? ''] ?? '';
|
||||
}
|
||||
}
|
||||
@@ -312,6 +312,25 @@ class Setting extends BaseModel
|
||||
"d) 买家在完成该笔交易(订单状态为“已签收”)后才能得到此笔交易的相应积分,如购买商品参加店铺其他优惠,则优惠的金额部分不享受积分获取;",
|
||||
],
|
||||
],
|
||||
// 企油通对接设置
|
||||
// ⚠️ 只放非敏感项:RSA 私钥与平台公钥始终从 .env 读取,绝不入库,
|
||||
// 避免数据库备份文件等同于资金级密钥副本。见 app\common\service\QytConfig
|
||||
SettingEnum::QYT => [
|
||||
'key' => SettingEnum::QYT,
|
||||
'describe' => '企油通对接设置',
|
||||
// 均为「接入方级」参数。企业级参数(执照号 / 通道 / 机构号)
|
||||
// 在「后台 → 企业管理」里按企业维护,不在这里配。
|
||||
'values' => [
|
||||
'base_url' => '', // 接口域名,不含结尾斜杠
|
||||
'app_id' => '', // 接入方 appId
|
||||
'no_prefix' => 'HM', // 编号前缀默认值(企业可各自覆盖)
|
||||
'voucher_name' => '运单卡', // 7.7 凭证名称默认值(企业可各自覆盖)
|
||||
'h5_base_url' => '', // 7.15 落地页
|
||||
'h5_app_id' => '', // 7.15 免登 appId
|
||||
'consume_notify_url' => '', // 7.10 回调地址(仅记录,实际在企油通后台配)
|
||||
'log' => 1, // 是否记录详细请求/响应日志
|
||||
],
|
||||
],
|
||||
// 分类页模板
|
||||
SettingEnum::PAGE_CATEGORY_TEMPLATE => [
|
||||
'key' => SettingEnum::PAGE_CATEGORY_TEMPLATE,
|
||||
|
||||
Reference in New Issue
Block a user