增加自媒体渠道

This commit is contained in:
2026-04-23 15:43:22 +08:00
parent 366b005d78
commit 54431cbeb1
19 changed files with 737 additions and 47 deletions
@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace app\adminapi\validate\finance;
use app\common\model\finance\AccountCost;
use app\common\service\qywx\MediaChannelService;
use app\common\validate\BaseValidate;
class AccountCostValidate extends BaseValidate
@@ -12,6 +13,7 @@ class AccountCostValidate extends BaseValidate
protected $rule = [
'id' => 'require|checkExists',
'cost_date' => 'require|dateFormat:Y-m-d',
'media_channel_code' => 'require|checkMediaChannelCode',
'amount' => 'require|float|egt:0',
'remark' => 'max:255',
];
@@ -20,6 +22,7 @@ class AccountCostValidate extends BaseValidate
'id.require' => '参数缺失',
'cost_date.require' => '请选择日期',
'cost_date.dateFormat' => '日期格式错误',
'media_channel_code.require' => '请选择自媒体渠道',
'amount.require' => '请输入账户消耗金额',
'amount.float' => '账户消耗金额格式错误',
'amount.egt' => '账户消耗金额不能小于0',
@@ -41,6 +44,11 @@ class AccountCostValidate extends BaseValidate
return $this->only(['id']);
}
public function sceneDelete()
{
return $this->only(['id']);
}
public function checkExists($value)
{
$model = AccountCost::find($value);
@@ -50,4 +58,13 @@ class AccountCostValidate extends BaseValidate
return true;
}
public function checkMediaChannelCode($value)
{
if (!MediaChannelService::isValidCode((string) $value)) {
return '自媒体渠道不合法';
}
return true;
}
}