| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- <?php
- namespace app\v1\logic\advert;
- use app\v1\logic\center\GameLogic;
- use plugin\saiadmin\basic\BaseLogic;
- use plugin\saiadmin\exception\ApiException;
- use plugin\saiadmin\utils\Helper;
- use app\v1\model\advert\MediaCost;
- use plugin\saiadmin\app\logic\system\SystemUserLogic;
- /**
- * 媒体消耗逻辑层
- */
- class MediaCostLogic extends BaseLogic
- {
- protected $agentSiteLogic;
- protected $agentListLogic;
- protected $gameLogic;
- protected $systemUserLogic;
-
- /**
- * 构造函数
- */
- public function __construct()
- {
- $this->model = new MediaCost();
- $this->agentSiteLogic = new AgentSiteLogic();
- $this->agentListLogic = new AgentListLogic();
- $this->gameLogic = new GameLogic();
- $this->systemUserLogic = new SystemUserLogic();
- $this->setOrderField('tdate');
- $this->setOrderType('desc');
- }
- /**
- * 添加数据
- * @param $data
- * @return mixed
- */
- public function add($data): mixed
- {
- $site_id = $data['site_id'];
- $site_info = $this->agentSiteLogic->read($site_id);
- $data['media_id'] = $site_info['media_id'];
- $data['agent_id'] = $site_info['agent_id'];
- $data['auth_id'] = $site_info['auth_id'];
- $this->model->save($data);
- return $this->model->getKey();
- }
- /**
- * 修改数据
- * @param $id
- * @param $data
- * @return mixed
- */
- public function edit($id, $data): mixed
- {
- $model = $this->model->findOrEmpty($id);
- if ($model->isEmpty()) {
- throw new ApiException('数据不存在');
- }
- $site_id = $data['site_id'];
- $site_info = $this->agentSiteLogic->read($site_id);
- $data['media_id'] = $site_info['media_id'];
- $data['agent_id'] = $site_info['agent_id'];
- $data['auth_id'] = $site_info['auth_id'];
- return $model->save($data);
- }
- }
|