@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model\shopro\partner;
|
||||
|
||||
use app\admin\model\shopro\Common;
|
||||
use app\admin\model\shopro\user\User as UserModel;
|
||||
use app\admin\model\shopro\order\Order as OrderModel;
|
||||
use addons\shopro\service\partner\PartnerConfig;
|
||||
|
||||
class Reward extends Common
|
||||
{
|
||||
protected $name = 'shopro_partner_reward';
|
||||
|
||||
protected $type = [
|
||||
'ext' => 'json',
|
||||
];
|
||||
|
||||
protected $append = [
|
||||
'status_text',
|
||||
'reward_type_text',
|
||||
'role_text',
|
||||
'skip_reason',
|
||||
'skip_reason_text',
|
||||
'formula',
|
||||
];
|
||||
|
||||
public function statusList()
|
||||
{
|
||||
return [
|
||||
-2 => '已退回',
|
||||
-1 => '已取消',
|
||||
0 => '待入账',
|
||||
1 => '已入账',
|
||||
];
|
||||
}
|
||||
|
||||
public function rewardTypeList()
|
||||
{
|
||||
return PartnerConfig::rewardTypeMap();
|
||||
}
|
||||
|
||||
public function roleList()
|
||||
{
|
||||
return [
|
||||
'taster' => '品酒师',
|
||||
'maker' => '创客',
|
||||
'venue' => '酒道馆',
|
||||
'county' => '区县',
|
||||
'system' => '平台',
|
||||
];
|
||||
}
|
||||
|
||||
public function getRewardTypeTextAttr($value, $data)
|
||||
{
|
||||
return PartnerConfig::rewardTypeText($data['reward_type'] ?? '');
|
||||
}
|
||||
|
||||
public function getRoleTextAttr($value, $data)
|
||||
{
|
||||
$role = $data['role'] ?? '';
|
||||
$list = $this->roleList();
|
||||
return $list[$role] ?? $role;
|
||||
}
|
||||
|
||||
public function getSkipReasonAttr($value, $data)
|
||||
{
|
||||
$ext = $data['ext'] ?? [];
|
||||
if (is_string($ext)) {
|
||||
$ext = json_decode($ext, true) ?: [];
|
||||
}
|
||||
return $ext['skip_reason'] ?? '';
|
||||
}
|
||||
|
||||
public function getSkipReasonTextAttr($value, $data)
|
||||
{
|
||||
$reason = $this->getSkipReasonAttr(null, $data);
|
||||
return $reason ? PartnerConfig::skipReasonText($reason) : '';
|
||||
}
|
||||
|
||||
public function getFormulaAttr($value, $data)
|
||||
{
|
||||
$ext = $data['ext'] ?? [];
|
||||
if (is_string($ext)) {
|
||||
$ext = json_decode($ext, true) ?: [];
|
||||
}
|
||||
return $ext['formula'] ?? '';
|
||||
}
|
||||
|
||||
public function buyer()
|
||||
{
|
||||
return $this->belongsTo(UserModel::class, 'buyer_id', 'id')->field('id, nickname, avatar, mobile');
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(UserModel::class, 'user_id', 'id')->field('id, nickname, avatar, mobile');
|
||||
}
|
||||
|
||||
public function order()
|
||||
{
|
||||
return $this->belongsTo(OrderModel::class, 'order_id', 'id');
|
||||
}
|
||||
}
|
||||
在新工单中引用
屏蔽一个用户