12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <?php
- /**
- * RateOut.php UTF-8
- * 优惠折扣对外
- *
- * @date : 2019/4/24 17:29
- *
- * @license 这不是一个自由软件,未经授权不许任何使用和传播。
- * @author : wuyonghong <wyh@huosdk.com>
- * @version : HUOSDK 8.5
- */
- namespace huoRate\controller;
- use huo\controller\common\Base;
- use huolib\status\RateStatus;
- use huoRate\model\AgentGameRateModel;
- class RateOut extends Base {
- /**
- * 添加渠道游戏优惠信息
- *
- * @param int $app_id 应用ID
- * @param int $agent_id 渠道ID
- *
- * @return array
- */
- public function addAgRate($app_id, $agent_id = 0) {
- $_rate_class = new Rate($app_id, $agent_id);
- $_rate_data = $_rate_class->getRate();
- $_rate_data['promote_switch'] = $_rate_class->getPromoteSwitch();
- $_rate_data['app_id'] = $app_id;
- $_rate_data['agent_id'] = $agent_id;
- $_rs = (new AgentGameRateModel())->addData($_rate_data);
- if (false !== $_rs) {
- $_code = RateStatus::NO_ERROR;
- return $this->huoSuccess($_code, RateStatus::getMsg($_code));
- }
- $_code = RateStatus::INNER_ERROR;
- return $this->huoSuccess($_code, RateStatus::getMsg($_code));
- }
- /**
- * 添加渠道游戏优惠信息
- *
- * @param array $data 数据
- * @param int $id ID
- *
- * @return array
- */
- public function editAgRate($data, $id) {
- if (empty($id)) {
- $_code = RateStatus::INVALID_PARAMS;
- return $this->huoSuccess($_code, RateStatus::getMsg($_code));
- }
- $_agr_model = new AgentGameRateModel();
- $_app_id = $_agr_model->getAppIdById($id);
- $_agent_id = $_agr_model->getAgentIdById($id);
- if (empty($_app_id) && empty($_agent_id)) {
- $_code = RateStatus::INVALID_PARAMS;
- return $this->huoError($_code, RateStatus::getMsg($_code).'1');
- }
- if ((isset($data['app_id']) && $data['app_id'] != $_app_id)
- || (isset($data['agent_id']) && $data['agent_id'] != $_agent_id)) {
- $_code = RateStatus::INVALID_PARAMS;
- return $this->huoError($_code, RateStatus::getMsg($_code).'2');
- }
- // $_rc_class = new RateCheck();
- // $_rdata = $_rc_class->checkParam($_app_id, $_agent_id, $data);
- // if (RateStatus::NO_ERROR != $_rdata['code']) {
- // return $this->huoReturn($_rdata);
- // }
- $_rs = $_agr_model->updateData($data, $id);
- if (false === $_rs) {
- $_code = RateStatus::INNER_ERROR;
- return $this->huoError($_code, RateStatus::getMsg($_code));
- }
- $_code = RateStatus::NO_ERROR;
- return $this->huoSuccess($_code, RateStatus::getMsg($_code));
- }
- }
|