AoRequest.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476
  1. <?php
  2. /**
  3. * AoRequest.php UTF-8
  4. * Agent
  5. *
  6. * @date : 2018/5/26 14:05
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : wuyonghong <wyh@huosdk.com>
  10. * @version : HUOSDK 8.0
  11. */
  12. namespace huo\controller\finance;
  13. use huo\controller\common\CommonFunc;
  14. use huo\controller\member\MemCache;
  15. use huolib\constant\OrderConst;
  16. use huolib\tool\StrUtils;
  17. class AoRequest {
  18. const FLAG_MEM_SDK = 1; /* 玩家游戏充值 */
  19. const FLAG_MEM_PTB = 2; /* 玩家平台币充值 */
  20. const FLAG_MEM_GM = 3; /* 玩家游戏币充值 */
  21. const FLAG_AGENT_PTB = 4; /* 下级渠道平台币充值 */
  22. const FLAG_REGISTER = 5; /* 新用户奖励 */
  23. const FLAG_OPEN_GAME = 6; /* 打开游戏奖励 */
  24. const FLAG_INVITE_REGISTER = 7; /* 被邀请的用户确认授权 */
  25. const FLAG_INVITE_OPEN_GAME = 8; /* 被邀请的用户打开游戏 */
  26. const FLAG_AGENT_CPA = 9; /* CPA */
  27. const FLAG_MEM_MEM_SDK = 11; /* 玩家下级玩家游戏充值 */
  28. const FLAG_FAVORITE = 12; /* 收藏奖励 */
  29. const FLAG_EXCHANGE = 13; /* 积分兑换 */
  30. const FLAG_LOTTERY = 14; /* 积分抽奖 */
  31. private $order_id = ''; /* 订单号 */
  32. private $mem_id = 0; /* 玩家 */
  33. private $from_id = 0; /* 充值人员ID 渠道有 玩家充值无 */
  34. private $app_id = 0;/* 游戏ID */
  35. private $amount = 0.00; /* 人民币数额 */
  36. private $real_amount = 0.00; /* 实际支付金额 */
  37. private $rebate_cnt = 0.00; /* 返利数量 默认为0 */
  38. private $agent_id = 0; /* 渠道ID */
  39. private $agent_rate = 1.00; /* 折扣 */
  40. private $agent_rebate = 0.00; /* 渠道返点 */
  41. private $agent_gain = 0.00; /* 二级收益 */
  42. private $parent_id = 0; /* 一级ID */
  43. private $parent_rate = 1.00; /* 一级折扣 */
  44. private $parent_rebate = 0.00; /* 一级返点 */
  45. private $parent_gain = 0.00; /* 一级收益 */
  46. private $flag = 1; /* 1 */
  47. private $status = 1; /* 结算标志,1为待结算,2为成功,3为失败 */
  48. private $payway = ''; /* 充值方式 */
  49. private $remark = '';/* 备注 */
  50. private $no_coin_fee = 0.00;/* 无平台币金额 */
  51. /**
  52. * 玩家游戏充值 设置收益数据
  53. *
  54. * @param $data
  55. */
  56. public function setDataFromSdkOrder($data) {
  57. if (empty($data)) {
  58. return;
  59. }
  60. if (empty($data['status']) && OrderConst::PAY_STATUS_SUC != $data['status']) {
  61. return;
  62. }
  63. $this->setOrderId(get_val($data, 'order_id', $this->order_id));
  64. $this->setMemId(get_val($data, 'mem_id', $this->mem_id));
  65. $this->setFromId(get_val($data, 'from_id', $this->from_id));
  66. $this->setAppId(get_val($data, 'app_id', $this->app_id));
  67. $this->setAmount(get_val($data, 'amount', $this->amount));
  68. $this->setRealAmount(get_val($data, 'real_amount', $this->real_amount));
  69. $this->setRebateCnt(get_val($data, 'rebate_amount', $this->rebate_cnt));
  70. /* 设置无平台币游戏币支付金额 */
  71. $_ptb_rate = CommonFunc::getPtbRmbRate();
  72. $_gm_rate = CommonFunc::getGmRmbRate();
  73. $_no_coin_fee = $data['amount'] - $data['ptb_amount'] / $_ptb_rate - $data['gm_amount'] / $_gm_rate;
  74. $this->setNoCoinFee(StrUtils::formatNumber($_no_coin_fee, 2));
  75. $this->setAgentId(get_val($data, 'agent_id', $this->agent_id));
  76. $this->setFlag(self::FLAG_MEM_SDK);
  77. $this->setStatus(1);
  78. $this->setPayway(get_val($data, 'payway', $this->payway));
  79. $this->setRemark(get_val($data, 'remark', $this->remark));
  80. }
  81. /**
  82. * 玩家平台币充值 设置收益数据
  83. *
  84. * @param $data
  85. */
  86. public function setDataFromPcOrder($data) {
  87. if (empty($data)) {
  88. return;
  89. }
  90. if (0 < $data['from_id']) {
  91. return;
  92. }
  93. if (empty($data['status']) && OrderConst::PAY_STATUS_SUC != $data['status']) {
  94. return;
  95. }
  96. $this->setOrderId(get_val($data, 'order_id', $this->order_id));
  97. $this->setMemId(get_val($data, 'mem_id', $this->mem_id));
  98. $this->setFromId(get_val($data, 'from_id', $this->from_id));
  99. $this->setAmount(get_val($data, 'amount', $this->amount));
  100. $this->setRealAmount(get_val($data, 'real_amount', $this->real_amount));
  101. $this->setRebateCnt(get_val($data, 'rebate_cnt', $this->rebate_cnt));
  102. /* 设置无平台币游戏币支付金额 */
  103. $this->setNoCoinFee(get_val($data, 'amount', $this->no_coin_fee));
  104. $_agent_id = MemCache::ins()->getAgentIdByMemId($this->mem_id);
  105. $this->setAgentId($_agent_id);
  106. $this->setFlag(self::FLAG_MEM_PTB);
  107. $this->setStatus(1);
  108. $this->setPayway(get_val($data, 'payway', $this->payway));
  109. $this->setRemark(get_val($data, 'remark', $this->remark));
  110. }
  111. /**
  112. * 渠道平台币充值 设置收益数据
  113. *
  114. * @param $data
  115. */
  116. public function setDataFromPacOrder($data) {
  117. if (empty($data)) {
  118. return;
  119. }
  120. if (empty($data['status']) && OrderConst::PAY_STATUS_SUC != $data['status']) {
  121. return;
  122. }
  123. $this->setOrderId(get_val($data, 'order_id', $this->order_id));
  124. $this->setAgentId(get_val($data, 'agent_id', $this->agent_id));
  125. $this->setFromId(get_val($data, 'agent_id', $this->from_id));
  126. $this->setAmount(get_val($data, 'amount', $this->amount));
  127. $this->setRealAmount(get_val($data, 'real_amount', $this->real_amount));
  128. $this->setRebateCnt(get_val($data, 'rebate_cnt', $this->rebate_cnt));
  129. /* 设置无平台币游戏币支付金额 */
  130. $this->setNoCoinFee(get_val($data, 'amount', $this->no_coin_fee));
  131. $this->setFlag(self::FLAG_MEM_SDK);
  132. $this->setStatus(1);
  133. $this->setPayway(get_val($data, 'payway', $this->payway));
  134. $this->setRemark(get_val($data, 'remark', $this->remark));
  135. }
  136. /**
  137. * 渠道代充玩家游戏币 设置收益数据
  138. *
  139. * @param $data
  140. */
  141. public function setDataFromGmcOrder($data) {
  142. if (empty($data)) {
  143. return;
  144. }
  145. if (empty($data['status']) && OrderConst::PAY_STATUS_SUC != $data['status']) {
  146. return;
  147. }
  148. $this->setOrderId(get_val($data, 'order_id', $this->order_id));
  149. $this->setMemId(get_val($data, 'mem_id', $this->mem_id));
  150. $this->setFromId(get_val($data, 'from_id', $this->agent_id));
  151. $this->setAppId(get_val($data, 'app_id', $this->app_id));
  152. $this->setAmount(get_val($data, 'amount', $this->amount));
  153. $this->setRealAmount(get_val($data, 'real_amount', $this->real_amount));
  154. $this->setAgentRate(get_val($data, 'agent_rate', $this->agent_rate));
  155. $this->setAgentId(get_val($data, 'from_id', $this->agent_id));
  156. $this->setFlag(self::FLAG_MEM_GM);
  157. $this->setStatus(1);
  158. $this->setPayway(get_val($data, 'payway', $this->payway));
  159. $this->setRemark(get_val($data, 'remark', $this->remark));
  160. }
  161. /**
  162. * 对象转数组
  163. *
  164. * @return mixed
  165. */
  166. public function toArray() {
  167. $_data['order_id'] = $this->order_id;
  168. $_data['mem_id'] = $this->mem_id;
  169. $_data['from_id'] = $this->from_id;
  170. $_data['app_id'] = $this->app_id;
  171. $_data['amount'] = $this->amount;
  172. $_data['real_amount'] = $this->real_amount;
  173. $_data['rebate_cnt'] = $this->rebate_cnt;
  174. $_data['agent_id'] = $this->agent_id;
  175. $_data['agent_rate'] = $this->agent_rate;
  176. $_data['agent_rebate'] = $this->agent_rebate;
  177. $_data['agent_gain'] = $this->agent_gain;
  178. $_data['parent_id'] = $this->parent_id;
  179. $_data['parent_rate'] = $this->parent_rate;
  180. $_data['parent_rebate'] = $this->parent_rebate;
  181. $_data['parent_gain'] = $this->parent_gain;
  182. $_data['flag'] = $this->flag;
  183. $_data['status'] = $this->status;
  184. $_data['payway'] = $this->payway;
  185. $_data['remark'] = $this->remark;
  186. return $_data;
  187. }
  188. /**
  189. * @return string
  190. */
  191. public function getOrderId() {
  192. return $this->order_id;
  193. }
  194. /**
  195. * @param string $order_id
  196. */
  197. public function setOrderId($order_id) {
  198. $this->order_id = $order_id;
  199. }
  200. /**
  201. * @return int
  202. */
  203. public function getMemId() {
  204. return $this->mem_id;
  205. }
  206. /**
  207. * @param int $mem_id
  208. */
  209. public function setMemId($mem_id) {
  210. $this->mem_id = $mem_id;
  211. }
  212. /**
  213. * @return int
  214. */
  215. public function getFromId() {
  216. return $this->from_id;
  217. }
  218. /**
  219. * @param int $from_id
  220. */
  221. public function setFromId($from_id) {
  222. $this->from_id = $from_id;
  223. }
  224. /**
  225. * @return int
  226. */
  227. public function getAppId() {
  228. return $this->app_id;
  229. }
  230. /**
  231. * @param int $app_id
  232. */
  233. public function setAppId($app_id) {
  234. $this->app_id = $app_id;
  235. }
  236. /**
  237. * @return float
  238. */
  239. public function getAmount() {
  240. return $this->amount;
  241. }
  242. /**
  243. * @param float $amount
  244. */
  245. public function setAmount($amount) {
  246. $this->amount = $amount;
  247. }
  248. /**
  249. * @return float
  250. */
  251. public function getRealAmount() {
  252. return $this->real_amount;
  253. }
  254. /**
  255. * @param float $real_amount
  256. */
  257. public function setRealAmount($real_amount) {
  258. $this->real_amount = $real_amount;
  259. }
  260. /**
  261. * @return float
  262. */
  263. public function getRebateCnt() {
  264. return $this->rebate_cnt;
  265. }
  266. /**
  267. * @param float $rebate_cnt
  268. */
  269. public function setRebateCnt($rebate_cnt) {
  270. $this->rebate_cnt = $rebate_cnt;
  271. }
  272. /**
  273. * @return int
  274. */
  275. public function getAgentId() {
  276. return $this->agent_id;
  277. }
  278. /**
  279. * @param int $agent_id
  280. */
  281. public function setAgentId($agent_id) {
  282. $this->agent_id = $agent_id;
  283. }
  284. /**
  285. * @return float
  286. */
  287. public function getAgentRate() {
  288. return $this->agent_rate;
  289. }
  290. /**
  291. * @param float $agent_rate
  292. */
  293. public function setAgentRate($agent_rate) {
  294. $this->agent_rate = $agent_rate;
  295. }
  296. /**
  297. * @return float
  298. */
  299. public function getAgentRebate() {
  300. return $this->agent_rebate;
  301. }
  302. /**
  303. * @param float $agent_rebate
  304. */
  305. public function setAgentRebate($agent_rebate) {
  306. $this->agent_rebate = $agent_rebate;
  307. }
  308. /**
  309. * @return float
  310. */
  311. public function getAgentGain() {
  312. return $this->agent_gain;
  313. }
  314. /**
  315. * @param float $agent_gain
  316. */
  317. public function setAgentGain($agent_gain) {
  318. $this->agent_gain = $agent_gain;
  319. }
  320. /**
  321. * @return int
  322. */
  323. public function getParentId() {
  324. return $this->parent_id;
  325. }
  326. /**
  327. * @param int $parent_id
  328. */
  329. public function setParentId($parent_id) {
  330. $this->parent_id = $parent_id;
  331. }
  332. /**
  333. * @return float
  334. */
  335. public function getParentRate() {
  336. return $this->parent_rate;
  337. }
  338. /**
  339. * @param float $parent_rate
  340. */
  341. public function setParentRate($parent_rate) {
  342. $this->parent_rate = $parent_rate;
  343. }
  344. /**
  345. * @return float
  346. */
  347. public function getParentRebate() {
  348. return $this->parent_rebate;
  349. }
  350. /**
  351. * @param float $parent_rebate
  352. */
  353. public function setParentRebate($parent_rebate) {
  354. $this->parent_rebate = $parent_rebate;
  355. }
  356. /**
  357. * @return float
  358. */
  359. public function getParentGain() {
  360. return $this->parent_gain;
  361. }
  362. /**
  363. * @param float $parent_gain
  364. */
  365. public function setParentGain($parent_gain) {
  366. $this->parent_gain = $parent_gain;
  367. }
  368. /**
  369. * @return int
  370. */
  371. public function getFlag() {
  372. return $this->flag;
  373. }
  374. /**
  375. * @param int $flag
  376. */
  377. public function setFlag($flag) {
  378. $this->flag = $flag;
  379. }
  380. /**
  381. * @return int
  382. */
  383. public function getStatus() {
  384. return $this->status;
  385. }
  386. /**
  387. * @param int $status
  388. */
  389. public function setStatus($status) {
  390. $this->status = $status;
  391. }
  392. /**
  393. * @return string
  394. */
  395. public function getPayway() {
  396. return $this->payway;
  397. }
  398. /**
  399. * @param string $payway
  400. */
  401. public function setPayway($payway) {
  402. $this->payway = $payway;
  403. }
  404. /**
  405. * @return string
  406. */
  407. public function getRemark() {
  408. return $this->remark;
  409. }
  410. /**
  411. * @param string $remark
  412. */
  413. public function setRemark($remark) {
  414. $this->remark = $remark;
  415. }
  416. /**
  417. * @return int
  418. */
  419. public function getNoCoinFee() {
  420. return $this->no_coin_fee;
  421. }
  422. /**
  423. * @param float $no_coin_fee
  424. */
  425. public function setNoCoinFee($no_coin_fee) {
  426. $this->no_coin_fee = $no_coin_fee;
  427. }
  428. }