123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- <?php
- /**
- * FinancialController.php UTF-8
- * 财务
- *
- * @date : 2018/8/16 20:57
- *
- * @license 这不是一个自由软件,未经授权不许任何使用和传播。
- * @author : luowei <lw@huosdk.com>
- * @version : HuoMP 1.0
- */
- namespace box\api\controller;
- use box\common\controller\V2ApiBaseController;
- use huo\controller\agent\AgentCache;
- use huo\controller\finance\Settle;
- use huo\controller\member\MemCache;
- use huo\controller\wap\Option;
- use huo\model\finance\SettleModel;
- use huo\model\user\UserModel;
- use huolib\constant\AgentConst;
- use huolib\constant\CommonConst;
- use huolib\constant\DataConst;
- use huolib\constant\MemItgConst;
- use huolib\constant\OptionConst;
- use huolib\constant\PaywayConst;
- use huolib\constant\WalletConst;
- use huolib\status\CommonStatus;
- use huomp\logic\finance\IncomeListLogic;
- use huomp\logic\finance\SettleLogic;
- class FinancialController extends V2ApiBaseController {
- /**
- * 获取提现配置信息
- * http://doc.1tsdk.com/159?page_id=4461
- * 【域名】/financial/withdraw/info
- */
- public function getWithdrawInfo() {
- $this->checkLogin();
- $_agent_id = (new UserModel())->getIdByMemId($this->mem_id);
- $_agent_ext_info = (new AgentCache())->getAgentExtByAgentId($_agent_id);
- if (empty($_agent_ext_info)) {
- $_code = CommonStatus::INVALID_PARAMS;
- $this->error(CommonStatus::getMsg($_code), [], $_code);
- }
- $_withdraw_cnt = (new SettleModel())->getCnt($_agent_id);
- $_option = new Option();
- $_settle_set = OptionConst::NAME_SETTLE_SET;
- $_settle_set_item = $_option->getOptionData($_settle_set);
- $_settle_set_item_value = [];
- if (!empty($_settle_set_item['option_value'])) {
- $_settle_set_item_value = json_decode($_settle_set_item['option_value'], true);
- }
- $_settle_tip = OptionConst::NAME_SETTLE_TIP;
- $_settle_tip_item = $_option->getOptionData($_settle_tip);
- $_settle_tip_item_value = [];
- if (!empty($_settle_tip_item['option_value'])) {
- $_settle_tip_item_value = json_decode($_settle_tip_item['option_value'], true);
- }
- $_data = [
- 'withdraw_cnt' => $_withdraw_cnt,
- 'balance' => !empty($_agent_ext_info) ? $_agent_ext_info['share_remain'] : 0,
- 'amount_mapping' => $_settle_set_item_value,
- 'notice' => $_settle_tip_item_value,
- ];
- $_code = CommonStatus::NO_ERROR;
- $this->success(CommonStatus::getMsg($_code), $_data, $_code);
- }
- /**
- * 申请提现
- * http://doc.1tsdk.com/159?page_id=4462
- * 【域名】/financial/withdraw
- */
- public function withdraw() {
- $this->checkLogin();
- $_agent_id = (new UserModel())->getIdByMemId($this->mem_id);
- $_agent_ext_info = (new AgentCache())->getAgentExtByAgentId($_agent_id);
- if (empty($_agent_ext_info)) {
- $_code = CommonStatus::INVALID_PARAMS;
- $this->error(CommonStatus::getMsg($_code), [], $_code);
- }
- $_amount = get_val($this->rq_data, 'amount');
- $_type = PaywayConst::PAYWAY_WXPAY;
- $_withdraw_cnt = (new SettleModel())->getCnt($_agent_id);
- if (empty($_withdraw_cnt)) {
- //首次提现,提现所有余额
- $_amount = $_agent_ext_info['share_remain'];
- }
- $_rs = (new Settle())->doSettle($_agent_id, $_amount, $_type);
- $this->returnData($_rs);
- }
- /**
- * 提现列表
- * http://doc.1tsdk.com/159?page_id=4405
- * 【域名】/financial/withdraw/list
- */
- public function withdrawList() {
- $this->checkLogin();
- $_agent_id = (new UserModel())->getIdByMemId($this->mem_id);
- $_agent_info = (new AgentCache())->getInfoByAgentId($_agent_id);
- if (empty($_agent_info)) {
- $_code = CommonStatus::INVALID_PARAMS;
- $this->error(CommonStatus::getMsg($_code), [], $_code);
- }
- $_page = get_val($this->rq_data, 'page', 1);
- $_offset = get_val($this->rq_data, 'offset', 10);
- $_param = ['agent_id' => $_agent_info['id']];
- $_page = $_page.','.$_offset;
- $_data = (new SettleLogic())->getWithdrawList($_param, $_page);
- $_code = CommonStatus::NO_ERROR;
- $this->success(CommonStatus::getMsg($_code), $_data, $_code);
- }
- /**
- * 收益列表
- * http://doc.1tsdk.com/159?page_id=4404
- * 【域名】/financial/income/list
- */
- public function incomeList() {
- $this->checkLogin();
- $_agent_id = (new UserModel())->getIdByMemId($this->mem_id);
- $_agent_info = (new AgentCache())->getInfoByAgentId($_agent_id);
- if (empty($_agent_info)) {
- $_code = CommonStatus::INVALID_PARAMS;
- $this->error(CommonStatus::getMsg($_code), [], $_code);
- }
- $_itg_type = get_val($this->rq_data, 'itg_type', MemItgConst::MEM_ITG_ADD);
- $_page = get_val($this->rq_data, 'page', 1);
- $_offset = get_val($this->rq_data, 'offset', 10);
- $_start_time = get_val($this->rq_data, 'start_time', '');
- $_end_time = get_val($this->rq_data, 'end_time', '');
- $_game_rq = $this->setGameData();
- $_param = [
- 'itg_type' => $_itg_type,
- 'mem_id' => $this->mem_id,
- 'start_time' => $_start_time,
- 'end_time' => $_end_time,
- 'app_id' => $_game_rq->getHAppId()
- ];
- $_page = $_page.','.$_offset;
- $_data = (new IncomeListLogic())->incomeList($_param, $_page);
- $_agent_ext_data = (new AgentCache())->getAgentExtByAgentId($_agent_id);
- $_balance = !empty($_agent_ext_data) ? $_agent_ext_data['share_remain'] : 0;
- $_data['sum']['sum_agent_gain'] = $_balance;
- $_me_data = MemCache::ins()->getMeInfoById($this->mem_id);
- $_data['sum']['my_integral'] = !empty($_me_data) ? intval($_me_data['my_integral']) : 0;
- $_code = CommonStatus::NO_ERROR;
- $this->success(CommonStatus::getMsg($_code), $_data, $_code);
- }
- /**
- * 收益排行列表
- * http://doc.1tsdk.com/159?page_id=4406
- * 【域名】/financial/income/rank/list
- */
- public function incomeRankList() {
- $this->checkLogin();
- $_agent_id = (new UserModel())->getIdByMemId($this->mem_id);
- $_agent_info = (new AgentCache())->getInfoByAgentId($_agent_id);
- if (empty($_agent_info)) {
- $_code = CommonStatus::INVALID_PARAMS;
- $this->error(CommonStatus::getMsg($_code), [], $_code);
- }
- $_range = get_val($this->rq_data, 'range', DataConst::RANK_RANGE_WEEK);
- $_page = get_val($this->rq_data, 'page', 1);
- $_offset = get_val($this->rq_data, 'offset', 10);
- if ($_page * $_offset > CommonConst::CONST_MAX_TASK_CNT) { //最多查找100个数据
- $_code = CommonStatus::NO_ERROR;
- $this->success(CommonStatus::getMsg($_code), [], $_code);
- }
- $_type = get_val($this->rq_data, 'type', WalletConst::WALLET_RP);
- $_param = [
- 'range' => $_range,
- 'role_id' => AgentConst::AGENT_ROLE_MP_MEMBER,
- 'type' => $_type
- ];
- $_page = $_page.','.$_offset;
- $_data = (new IncomeListLogic())->incomeRankList($_agent_info['id'], $_param, $_page);
- $_code = CommonStatus::NO_ERROR;
- $this->success(CommonStatus::getMsg($_code), $_data, $_code);
- }
- }
|