增加自媒体渠道
This commit is contained in:
@@ -6,6 +6,7 @@ namespace app\adminapi\logic\finance;
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\finance\AccountCost;
|
||||
use app\common\service\qywx\MediaChannelService;
|
||||
|
||||
class AccountCostLogic extends BaseLogic
|
||||
{
|
||||
@@ -13,14 +14,19 @@ class AccountCostLogic extends BaseLogic
|
||||
{
|
||||
try {
|
||||
$costDate = (string) $params['cost_date'];
|
||||
if (AccountCost::where('cost_date', $costDate)->count() > 0) {
|
||||
self::setError('该日期的账户消耗已存在,请直接编辑');
|
||||
$mediaChannelCode = trim((string) ($params['media_channel_code'] ?? ''));
|
||||
$mediaChannelName = MediaChannelService::getNameByCode($mediaChannelCode);
|
||||
|
||||
if (AccountCost::where('cost_date', $costDate)->where('media_channel_code', $mediaChannelCode)->count() > 0) {
|
||||
self::setError('该日期下所选渠道的账户消耗已存在,请直接编辑');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
AccountCost::create([
|
||||
'cost_date' => $costDate,
|
||||
'media_channel_code' => $mediaChannelCode,
|
||||
'media_channel_name' => $mediaChannelName,
|
||||
'amount' => round((float) $params['amount'], 2),
|
||||
'remark' => (string) ($params['remark'] ?? ''),
|
||||
'creator_id' => $adminId,
|
||||
@@ -65,4 +71,24 @@ class AccountCostLogic extends BaseLogic
|
||||
{
|
||||
return AccountCost::findOrEmpty($id)->toArray();
|
||||
}
|
||||
|
||||
public static function delete(int $id): bool
|
||||
{
|
||||
try {
|
||||
$model = AccountCost::find($id);
|
||||
if (!$model) {
|
||||
self::setError('记录不存在');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$model->delete();
|
||||
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
self::setError($e->getMessage());
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user