123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476 |
- <?php
- /**
- * AoRequest.php UTF-8
- * Agent
- *
- * @date : 2018/5/26 14:05
- *
- * @license 这不是一个自由软件,未经授权不许任何使用和传播。
- * @author : wuyonghong <wyh@huosdk.com>
- * @version : HUOSDK 8.0
- */
- namespace huo\controller\finance;
- use huo\controller\common\CommonFunc;
- use huo\controller\member\MemCache;
- use huolib\constant\OrderConst;
- use huolib\tool\StrUtils;
- class AoRequest {
- const FLAG_MEM_SDK = 1; /* 玩家游戏充值 */
- const FLAG_MEM_PTB = 2; /* 玩家平台币充值 */
- const FLAG_MEM_GM = 3; /* 玩家游戏币充值 */
- const FLAG_AGENT_PTB = 4; /* 下级渠道平台币充值 */
- const FLAG_REGISTER = 5; /* 新用户奖励 */
- const FLAG_OPEN_GAME = 6; /* 打开游戏奖励 */
- const FLAG_INVITE_REGISTER = 7; /* 被邀请的用户确认授权 */
- const FLAG_INVITE_OPEN_GAME = 8; /* 被邀请的用户打开游戏 */
- const FLAG_AGENT_CPA = 9; /* CPA */
- const FLAG_MEM_MEM_SDK = 11; /* 玩家下级玩家游戏充值 */
- const FLAG_FAVORITE = 12; /* 收藏奖励 */
- const FLAG_EXCHANGE = 13; /* 积分兑换 */
- const FLAG_LOTTERY = 14; /* 积分抽奖 */
- private $order_id = ''; /* 订单号 */
- private $mem_id = 0; /* 玩家 */
- private $from_id = 0; /* 充值人员ID 渠道有 玩家充值无 */
- private $app_id = 0;/* 游戏ID */
- private $amount = 0.00; /* 人民币数额 */
- private $real_amount = 0.00; /* 实际支付金额 */
- private $rebate_cnt = 0.00; /* 返利数量 默认为0 */
- private $agent_id = 0; /* 渠道ID */
- private $agent_rate = 1.00; /* 折扣 */
- private $agent_rebate = 0.00; /* 渠道返点 */
- private $agent_gain = 0.00; /* 二级收益 */
- private $parent_id = 0; /* 一级ID */
- private $parent_rate = 1.00; /* 一级折扣 */
- private $parent_rebate = 0.00; /* 一级返点 */
- private $parent_gain = 0.00; /* 一级收益 */
- private $flag = 1; /* 1 */
- private $status = 1; /* 结算标志,1为待结算,2为成功,3为失败 */
- private $payway = ''; /* 充值方式 */
- private $remark = '';/* 备注 */
- private $no_coin_fee = 0.00;/* 无平台币金额 */
- /**
- * 玩家游戏充值 设置收益数据
- *
- * @param $data
- */
- public function setDataFromSdkOrder($data) {
- if (empty($data)) {
- return;
- }
- if (empty($data['status']) && OrderConst::PAY_STATUS_SUC != $data['status']) {
- return;
- }
- $this->setOrderId(get_val($data, 'order_id', $this->order_id));
- $this->setMemId(get_val($data, 'mem_id', $this->mem_id));
- $this->setFromId(get_val($data, 'from_id', $this->from_id));
- $this->setAppId(get_val($data, 'app_id', $this->app_id));
- $this->setAmount(get_val($data, 'amount', $this->amount));
- $this->setRealAmount(get_val($data, 'real_amount', $this->real_amount));
- $this->setRebateCnt(get_val($data, 'rebate_amount', $this->rebate_cnt));
- /* 设置无平台币游戏币支付金额 */
- $_ptb_rate = CommonFunc::getPtbRmbRate();
- $_gm_rate = CommonFunc::getGmRmbRate();
- $_no_coin_fee = $data['amount'] - $data['ptb_amount'] / $_ptb_rate - $data['gm_amount'] / $_gm_rate;
- $this->setNoCoinFee(StrUtils::formatNumber($_no_coin_fee, 2));
- $this->setAgentId(get_val($data, 'agent_id', $this->agent_id));
- $this->setFlag(self::FLAG_MEM_SDK);
- $this->setStatus(1);
- $this->setPayway(get_val($data, 'payway', $this->payway));
- $this->setRemark(get_val($data, 'remark', $this->remark));
- }
- /**
- * 玩家平台币充值 设置收益数据
- *
- * @param $data
- */
- public function setDataFromPcOrder($data) {
- if (empty($data)) {
- return;
- }
- if (0 < $data['from_id']) {
- return;
- }
- if (empty($data['status']) && OrderConst::PAY_STATUS_SUC != $data['status']) {
- return;
- }
- $this->setOrderId(get_val($data, 'order_id', $this->order_id));
- $this->setMemId(get_val($data, 'mem_id', $this->mem_id));
- $this->setFromId(get_val($data, 'from_id', $this->from_id));
- $this->setAmount(get_val($data, 'amount', $this->amount));
- $this->setRealAmount(get_val($data, 'real_amount', $this->real_amount));
- $this->setRebateCnt(get_val($data, 'rebate_cnt', $this->rebate_cnt));
- /* 设置无平台币游戏币支付金额 */
- $this->setNoCoinFee(get_val($data, 'amount', $this->no_coin_fee));
- $_agent_id = MemCache::ins()->getAgentIdByMemId($this->mem_id);
- $this->setAgentId($_agent_id);
- $this->setFlag(self::FLAG_MEM_PTB);
- $this->setStatus(1);
- $this->setPayway(get_val($data, 'payway', $this->payway));
- $this->setRemark(get_val($data, 'remark', $this->remark));
- }
- /**
- * 渠道平台币充值 设置收益数据
- *
- * @param $data
- */
- public function setDataFromPacOrder($data) {
- if (empty($data)) {
- return;
- }
- if (empty($data['status']) && OrderConst::PAY_STATUS_SUC != $data['status']) {
- return;
- }
- $this->setOrderId(get_val($data, 'order_id', $this->order_id));
- $this->setAgentId(get_val($data, 'agent_id', $this->agent_id));
- $this->setFromId(get_val($data, 'agent_id', $this->from_id));
- $this->setAmount(get_val($data, 'amount', $this->amount));
- $this->setRealAmount(get_val($data, 'real_amount', $this->real_amount));
- $this->setRebateCnt(get_val($data, 'rebate_cnt', $this->rebate_cnt));
- /* 设置无平台币游戏币支付金额 */
- $this->setNoCoinFee(get_val($data, 'amount', $this->no_coin_fee));
- $this->setFlag(self::FLAG_MEM_SDK);
- $this->setStatus(1);
- $this->setPayway(get_val($data, 'payway', $this->payway));
- $this->setRemark(get_val($data, 'remark', $this->remark));
- }
- /**
- * 渠道代充玩家游戏币 设置收益数据
- *
- * @param $data
- */
- public function setDataFromGmcOrder($data) {
- if (empty($data)) {
- return;
- }
- if (empty($data['status']) && OrderConst::PAY_STATUS_SUC != $data['status']) {
- return;
- }
- $this->setOrderId(get_val($data, 'order_id', $this->order_id));
- $this->setMemId(get_val($data, 'mem_id', $this->mem_id));
- $this->setFromId(get_val($data, 'from_id', $this->agent_id));
- $this->setAppId(get_val($data, 'app_id', $this->app_id));
- $this->setAmount(get_val($data, 'amount', $this->amount));
- $this->setRealAmount(get_val($data, 'real_amount', $this->real_amount));
- $this->setAgentRate(get_val($data, 'agent_rate', $this->agent_rate));
- $this->setAgentId(get_val($data, 'from_id', $this->agent_id));
- $this->setFlag(self::FLAG_MEM_GM);
- $this->setStatus(1);
- $this->setPayway(get_val($data, 'payway', $this->payway));
- $this->setRemark(get_val($data, 'remark', $this->remark));
- }
- /**
- * 对象转数组
- *
- * @return mixed
- */
- public function toArray() {
- $_data['order_id'] = $this->order_id;
- $_data['mem_id'] = $this->mem_id;
- $_data['from_id'] = $this->from_id;
- $_data['app_id'] = $this->app_id;
- $_data['amount'] = $this->amount;
- $_data['real_amount'] = $this->real_amount;
- $_data['rebate_cnt'] = $this->rebate_cnt;
- $_data['agent_id'] = $this->agent_id;
- $_data['agent_rate'] = $this->agent_rate;
- $_data['agent_rebate'] = $this->agent_rebate;
- $_data['agent_gain'] = $this->agent_gain;
- $_data['parent_id'] = $this->parent_id;
- $_data['parent_rate'] = $this->parent_rate;
- $_data['parent_rebate'] = $this->parent_rebate;
- $_data['parent_gain'] = $this->parent_gain;
- $_data['flag'] = $this->flag;
- $_data['status'] = $this->status;
- $_data['payway'] = $this->payway;
- $_data['remark'] = $this->remark;
- return $_data;
- }
- /**
- * @return string
- */
- public function getOrderId() {
- return $this->order_id;
- }
- /**
- * @param string $order_id
- */
- public function setOrderId($order_id) {
- $this->order_id = $order_id;
- }
- /**
- * @return int
- */
- public function getMemId() {
- return $this->mem_id;
- }
- /**
- * @param int $mem_id
- */
- public function setMemId($mem_id) {
- $this->mem_id = $mem_id;
- }
- /**
- * @return int
- */
- public function getFromId() {
- return $this->from_id;
- }
- /**
- * @param int $from_id
- */
- public function setFromId($from_id) {
- $this->from_id = $from_id;
- }
- /**
- * @return int
- */
- public function getAppId() {
- return $this->app_id;
- }
- /**
- * @param int $app_id
- */
- public function setAppId($app_id) {
- $this->app_id = $app_id;
- }
- /**
- * @return float
- */
- public function getAmount() {
- return $this->amount;
- }
- /**
- * @param float $amount
- */
- public function setAmount($amount) {
- $this->amount = $amount;
- }
- /**
- * @return float
- */
- public function getRealAmount() {
- return $this->real_amount;
- }
- /**
- * @param float $real_amount
- */
- public function setRealAmount($real_amount) {
- $this->real_amount = $real_amount;
- }
- /**
- * @return float
- */
- public function getRebateCnt() {
- return $this->rebate_cnt;
- }
- /**
- * @param float $rebate_cnt
- */
- public function setRebateCnt($rebate_cnt) {
- $this->rebate_cnt = $rebate_cnt;
- }
- /**
- * @return int
- */
- public function getAgentId() {
- return $this->agent_id;
- }
- /**
- * @param int $agent_id
- */
- public function setAgentId($agent_id) {
- $this->agent_id = $agent_id;
- }
- /**
- * @return float
- */
- public function getAgentRate() {
- return $this->agent_rate;
- }
- /**
- * @param float $agent_rate
- */
- public function setAgentRate($agent_rate) {
- $this->agent_rate = $agent_rate;
- }
- /**
- * @return float
- */
- public function getAgentRebate() {
- return $this->agent_rebate;
- }
- /**
- * @param float $agent_rebate
- */
- public function setAgentRebate($agent_rebate) {
- $this->agent_rebate = $agent_rebate;
- }
- /**
- * @return float
- */
- public function getAgentGain() {
- return $this->agent_gain;
- }
- /**
- * @param float $agent_gain
- */
- public function setAgentGain($agent_gain) {
- $this->agent_gain = $agent_gain;
- }
- /**
- * @return int
- */
- public function getParentId() {
- return $this->parent_id;
- }
- /**
- * @param int $parent_id
- */
- public function setParentId($parent_id) {
- $this->parent_id = $parent_id;
- }
- /**
- * @return float
- */
- public function getParentRate() {
- return $this->parent_rate;
- }
- /**
- * @param float $parent_rate
- */
- public function setParentRate($parent_rate) {
- $this->parent_rate = $parent_rate;
- }
- /**
- * @return float
- */
- public function getParentRebate() {
- return $this->parent_rebate;
- }
- /**
- * @param float $parent_rebate
- */
- public function setParentRebate($parent_rebate) {
- $this->parent_rebate = $parent_rebate;
- }
- /**
- * @return float
- */
- public function getParentGain() {
- return $this->parent_gain;
- }
- /**
- * @param float $parent_gain
- */
- public function setParentGain($parent_gain) {
- $this->parent_gain = $parent_gain;
- }
- /**
- * @return int
- */
- public function getFlag() {
- return $this->flag;
- }
- /**
- * @param int $flag
- */
- public function setFlag($flag) {
- $this->flag = $flag;
- }
- /**
- * @return int
- */
- public function getStatus() {
- return $this->status;
- }
- /**
- * @param int $status
- */
- public function setStatus($status) {
- $this->status = $status;
- }
- /**
- * @return string
- */
- public function getPayway() {
- return $this->payway;
- }
- /**
- * @param string $payway
- */
- public function setPayway($payway) {
- $this->payway = $payway;
- }
- /**
- * @return string
- */
- public function getRemark() {
- return $this->remark;
- }
- /**
- * @param string $remark
- */
- public function setRemark($remark) {
- $this->remark = $remark;
- }
- /**
- * @return int
- */
- public function getNoCoinFee() {
- return $this->no_coin_fee;
- }
- /**
- * @param float $no_coin_fee
- */
- public function setNoCoinFee($no_coin_fee) {
- $this->no_coin_fee = $no_coin_fee;
- }
- }
|