WalletRequest.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651
  1. <?php
  2. /**
  3. * WalletRequest.php UTF-8
  4. *
  5. *
  6. * @date : 2018/5/16 22:04
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : wuyonghong <wyh@huosdk.com>
  10. * @version : HUOSDK 8.0
  11. */
  12. namespace huo\controller\wallet;
  13. use huo\controller\common\CommonFunc;
  14. use huo\model\finance\GmBackModel;
  15. use huo\model\finance\PtbBackModel;
  16. use huolib\constant\WalletConst;
  17. class WalletRequest {
  18. private $order_id = ''; /* 订单号 */
  19. private $type = 1; /* 1 充值 */
  20. private $agent_id = 1; /* 渠道ID */
  21. private $from_id = 0; /* 发放ID */
  22. private $mem_id = 0; /* 玩家 */
  23. private $amount = 0.00; /* 人民币数额 */
  24. private $real_amount = 0.00; /* 实际支付金额 */
  25. private $ptb_cnt = 0.00; /* 平台币数量 */
  26. private $rebate_cnt = 0.00; /* 返利数量 默认为0 */
  27. private $discount = 1.00; /* 折扣 */
  28. private $payway = ''; /* 充值方式 */
  29. private $ip = ''; /* 用户充值时使用的网络终端IP */
  30. private $status = 1; /* 1 待支付 2 支付完成 3 支付失败 */
  31. private $create_time = 0; /* 创建时间 */
  32. private $update_time = 0; /* 更新时间 */
  33. private $remark = '';/* 备注 */
  34. private $cost_ptb_cnt = 0;/* 消耗的平台币 */
  35. private $to_agent_id = 0;/* 发放给渠道ID */
  36. private $app_id = 0;/* 游戏ID */
  37. private $back_ptb_cnt = 0.00;/* 扣回订单平台币数量 */
  38. private $gm_cnt = 0.00; /* 游戏币数量 */
  39. private $cost_gm_cnt = 0.00; /* 花费游戏币数量 */
  40. private $back_gm_cnt = 0.00;/* 扣回订单游戏币数量 */
  41. public function __construct() {
  42. $this->ip = request()->ip();
  43. }
  44. /**
  45. * 从SDK订单中转换平台币订单
  46. *
  47. * @param $data
  48. */
  49. public function setDataFromSdkOrder($data) {
  50. if (empty($data)) {
  51. return;
  52. }
  53. $_ptb_rmb_rate = CommonFunc::getPtbRmbRate();
  54. $_gm_rmb_rate = CommonFunc::getGmRmbRate();
  55. $this->setOrderId(get_val($data, 'order_id', $this->order_id));
  56. $this->setType(WalletConst::WALLET_FROM_COST);
  57. $this->setAppId(get_val($data, 'app_id', $this->app_id));
  58. $this->setMemId(get_val($data, 'mem_id', $this->mem_id));
  59. $this->setAmount(get_val($data, 'amount', $this->amount));
  60. $this->setRealAmount(get_val($data, 'real_amount', $this->real_amount));
  61. $this->setRebateCnt(get_val($data, 'rebate_amount', $this->rebate_cnt));
  62. $this->setDiscount(get_val($data, 'rate', $this->discount));
  63. $this->setPayway(get_val($data, 'payway', ''));
  64. $this->setIp(get_val($data, 'ip', request()->ip()));
  65. $this->setStatus(get_val($data, 'status', $this->status));
  66. $this->setPtbCnt($_ptb_rmb_rate * get_val($data, 'ptb_amount', $this->ptb_cnt));
  67. $this->setCostPtbCnt($_ptb_rmb_rate * get_val($data, 'ptb_amount', $this->ptb_cnt));
  68. $this->setGmCnt($_gm_rmb_rate * get_val($data, 'gm_amount', $this->ptb_cnt));
  69. $this->setCostGmCnt($_gm_rmb_rate * get_val($data, 'gm_amount', $this->ptb_cnt));
  70. }
  71. /**
  72. * 设置订单数据
  73. *
  74. * @param array $data
  75. */
  76. public function setPtbChargeData($data = []) {
  77. if (empty($data)) {
  78. return;
  79. }
  80. $this->setOrderId(get_val($data, 'order_id', $this->order_id));
  81. $this->setType(get_val($data, 'type', $this->type));
  82. $this->setFromId(get_val($data, 'from_id', $this->from_id));
  83. $this->setMemId(get_val($data, 'mem_id', $this->mem_id));
  84. $this->setAmount(get_val($data, 'amount', $this->amount));
  85. $this->setRealAmount(get_val($data, 'real_amount', $this->real_amount));
  86. $this->setPtbCnt(get_val($data, 'ptb_cnt', $this->ptb_cnt));
  87. $this->setRebateCnt(get_val($data, 'rebate_cnt', $this->rebate_cnt));
  88. $this->setDiscount(get_val($data, 'discount', $this->discount));
  89. $this->setPayway(get_val($data, 'payway', ''));
  90. $this->setIp(get_val($data, 'ip', request()->ip()));
  91. $this->setStatus(get_val($data, 'status', $this->status));
  92. }
  93. /**
  94. * 设置游戏币充值订单数据
  95. *
  96. * @param array $data
  97. */
  98. public function setGmChargeData($data = []) {
  99. if (empty($data)) {
  100. return;
  101. }
  102. $this->setOrderId(get_val($data, 'order_id', $this->order_id));
  103. $this->setMemId(get_val($data, 'mem_id', $this->mem_id));
  104. $this->setAppId(get_val($data, 'app_id', $this->app_id));
  105. $this->setFromId(get_val($data, 'from_id', $this->from_id));
  106. $this->setType(get_val($data, 'type', $this->type));
  107. $this->setAmount(get_val($data, 'amount', $this->amount));
  108. $this->setRealAmount(get_val($data, 'real_amount', $this->real_amount));
  109. $this->setGmCnt(get_val($data, 'gm_cnt', $this->gm_cnt));
  110. $this->setRebateCnt(get_val($data, 'rebate_cnt', $this->rebate_cnt));
  111. $this->setDiscount(get_val($data, 'discount', $this->discount));
  112. $this->setPayway(get_val($data, 'payway', ''));
  113. $this->setIp(get_val($data, 'ip', request()->ip()));
  114. $this->setStatus(get_val($data, 'status', $this->status));
  115. }
  116. /**
  117. * 获取玩家平台币收入输入
  118. *
  119. * @return array
  120. */
  121. public function getPtbChargeData() {
  122. $_data['order_id'] = $this->order_id;
  123. $_data['mem_id'] = $this->mem_id;
  124. $_data['from_id'] = $this->agent_id;
  125. $_data['type'] = $this->type;
  126. $_data['amount'] = $this->amount;
  127. $_data['real_amount'] = $this->real_amount;
  128. $_data['ptb_cnt'] = $this->ptb_cnt;
  129. $_data['rebate_cnt'] = $this->rebate_cnt;
  130. $_data['discount'] = $this->discount;
  131. $_data['payway'] = $this->payway;
  132. $_data['ip'] = $this->ip;
  133. $_data['status'] = $this->status;
  134. return $_data;
  135. }
  136. /**
  137. * 获取玩家游戏币收入
  138. *
  139. * @return array
  140. */
  141. public function getGmChargeData() {
  142. $_data['order_id'] = $this->order_id;
  143. $_data['mem_id'] = $this->mem_id;
  144. $_data['app_id'] = $this->app_id;
  145. $_data['from_id'] = $this->agent_id;
  146. $_data['type'] = $this->type;
  147. $_data['amount'] = $this->amount;
  148. $_data['real_amount'] = $this->real_amount;
  149. $_data['gm_cnt'] = $this->gm_cnt;
  150. $_data['rebate_cnt'] = $this->rebate_cnt;
  151. $_data['discount'] = $this->discount;
  152. $_data['payway'] = $this->payway;
  153. $_data['ip'] = $this->ip;
  154. $_data['status'] = $this->status;
  155. return $_data;
  156. }
  157. /**
  158. * 设置渠道平台币订单数据
  159. *
  160. * @param array $data
  161. */
  162. public function setPtbAgentChargeData($data = []) {
  163. if (empty($data)) {
  164. return;
  165. }
  166. $this->setOrderId(get_val($data, 'order_id', $this->order_id));
  167. $this->setType(get_val($data, 'type', $this->type));
  168. $this->setFromId(get_val($data, 'from_id', $this->from_id));
  169. $this->setAgentId(get_val($data, 'agent_id', $this->agent_id));
  170. $this->setAmount(get_val($data, 'amount', $this->amount));
  171. $this->setRealAmount(get_val($data, 'real_amount', $this->real_amount));
  172. $this->setPtbCnt(get_val($data, 'ptb_cnt', $this->ptb_cnt));
  173. $this->setRebateCnt(get_val($data, 'rebate_cnt', $this->rebate_cnt));
  174. $this->setDiscount(get_val($data, 'discount', $this->discount));
  175. $this->setPayway(get_val($data, 'payway', ''));
  176. $this->setIp(get_val($data, 'ip', request()->ip()));
  177. $this->setStatus(get_val($data, 'status', $this->status));
  178. }
  179. /**
  180. * 获取渠道平台币充值数据
  181. *
  182. * @return array
  183. */
  184. public function getPtbAgentChargeData() {
  185. $_data['order_id'] = $this->order_id;
  186. $_data['agent_id'] = $this->to_agent_id;
  187. $_data['from_id'] = $this->agent_id;
  188. $_data['type'] = $this->type;
  189. $_data['amount'] = $this->amount;
  190. $_data['real_amount'] = $this->real_amount;
  191. $_data['ptb_cnt'] = $this->ptb_cnt;
  192. $_data['rebate_cnt'] = $this->rebate_cnt;
  193. $_data['discount'] = $this->discount;
  194. $_data['payway'] = $this->payway;
  195. $_data['ip'] = $this->ip;
  196. $_data['status'] = $this->status;
  197. return $_data;
  198. }
  199. /**
  200. * 获取渠道平台币扣除数据
  201. */
  202. public function getPtbAgentDeductData() {
  203. $_data['app_id'] = $this->app_id;
  204. $_data['back_order_id'] = $this->order_id;
  205. $_data['user_type'] = PtbBackModel::USER_TYPE_AGENT;
  206. $_data['agent_id'] = $this->to_agent_id;
  207. $_data['ptb_cnt'] = $this->ptb_cnt;
  208. $_data['back_ptb_cnt'] = $this->back_ptb_cnt;
  209. $_data['status'] = $this->status;
  210. $_data['remark'] = $this->remark;
  211. return $_data;
  212. }
  213. /**
  214. * 获取玩家平台币扣除数据
  215. */
  216. public function getPtbPlayerDeductData() {
  217. $_data['app_id'] = $this->app_id;
  218. $_data['back_order_id'] = $this->order_id;
  219. $_data['user_type'] = PtbBackModel::USER_TYPE_MEM;
  220. $_data['mem_id'] = $this->mem_id;
  221. $_data['ptb_cnt'] = $this->ptb_cnt;
  222. $_data['back_ptb_cnt'] = $this->back_ptb_cnt;
  223. $_data['status'] = $this->status;
  224. $_data['remark'] = $this->remark;
  225. return $_data;
  226. }
  227. /**
  228. * 获取玩家游戏币扣除数据
  229. */
  230. public function getGmPlayerDeductData() {
  231. $_data['app_id'] = $this->app_id;
  232. $_data['back_order_id'] = $this->order_id;
  233. $_data['user_type'] = GmBackModel::USER_TYPE_MEM;
  234. $_data['mem_id'] = $this->mem_id;
  235. $_data['gm_cnt'] = $this->gm_cnt;
  236. $_data['back_gm_cnt'] = $this->back_gm_cnt;
  237. $_data['status'] = $this->status;
  238. $_data['remark'] = $this->remark;
  239. return $_data;
  240. }
  241. /**
  242. * 获取渠道平台币充值数据
  243. *
  244. * @return array
  245. */
  246. public function getPtbAgentOrderData() {
  247. $_data['order_id'] = $this->order_id;
  248. $_data['agent_id'] = $this->agent_id;
  249. $_data['to_mem_id'] = $this->mem_id;
  250. $_data['to_agent_id'] = $this->to_agent_id;
  251. $_data['app_id'] = $this->app_id;
  252. $_data['amount'] = $this->amount;
  253. $_data['real_amount'] = $this->real_amount;
  254. $_data['rebate_cnt'] = $this->rebate_cnt;
  255. $_data['ptb_cnt'] = $this->ptb_cnt;
  256. $_data['gm_cnt'] = $this->gm_cnt;
  257. $_data['cost_ptb_cnt'] = $this->cost_ptb_cnt;
  258. $_data['discount'] = $this->discount;
  259. $_data['payway'] = $this->payway;
  260. $_data['ip'] = $this->ip;
  261. $_data['status'] = $this->status;
  262. return $_data;
  263. }
  264. /**
  265. * 获取玩家平台币充值数据
  266. *
  267. * @return array
  268. */
  269. public function getPtbOrderData() {
  270. $_data['order_id'] = $this->order_id;
  271. $_data['type'] = $this->type;
  272. $_data['app_id'] = $this->app_id;
  273. $_data['mem_id'] = $this->mem_id;
  274. $_data['amount'] = $this->amount;
  275. $_data['real_amount'] = $this->real_amount;
  276. $_data['rebate_cnt'] = $this->rebate_cnt;
  277. $_data['ptb_cnt'] = $this->cost_ptb_cnt;
  278. $_data['discount'] = $this->discount;
  279. $_data['payway'] = $this->payway;
  280. $_data['ip'] = $this->ip;
  281. $_data['status'] = $this->status;
  282. return $_data;
  283. }
  284. /**
  285. * 获取玩家游戏币消费数据
  286. *
  287. * @return array
  288. */
  289. public function getGmOrderData() {
  290. $_data['order_id'] = $this->order_id;
  291. $_data['type'] = $this->type;
  292. $_data['app_id'] = $this->app_id;
  293. $_data['mem_id'] = $this->mem_id;
  294. $_data['amount'] = $this->amount;
  295. $_data['real_amount'] = $this->real_amount;
  296. $_data['rebate_cnt'] = $this->rebate_cnt;
  297. $_data['gm_cnt'] = $this->cost_gm_cnt;
  298. $_data['discount'] = $this->discount;
  299. $_data['payway'] = $this->payway;
  300. $_data['ip'] = $this->ip;
  301. $_data['status'] = $this->status;
  302. return $_data;
  303. }
  304. /**
  305. * @return string
  306. */
  307. public function getOrderId() {
  308. return $this->order_id;
  309. }
  310. /**
  311. * @param string $order_id
  312. */
  313. public function setOrderId($order_id) {
  314. $this->order_id = $order_id;
  315. }
  316. /**
  317. * @return int
  318. */
  319. public function getFromId() {
  320. return $this->from_id;
  321. }
  322. /**
  323. * @param int $from_id
  324. */
  325. public function setFromId($from_id) {
  326. $this->from_id = $from_id;
  327. }
  328. /**
  329. * @return int
  330. */
  331. public function getMemId() {
  332. return $this->mem_id;
  333. }
  334. /**
  335. * @param int $mem_id
  336. */
  337. public function setMemId($mem_id) {
  338. $this->mem_id = $mem_id;
  339. }
  340. /**
  341. * @return float
  342. */
  343. public function getAmount() {
  344. return $this->amount;
  345. }
  346. /**
  347. * @param float $amount
  348. */
  349. public function setAmount($amount) {
  350. $this->amount = $amount;
  351. }
  352. /**
  353. * @return float
  354. */
  355. public function getRealAmount() {
  356. return $this->real_amount;
  357. }
  358. /**
  359. * @param float $real_amount
  360. */
  361. public function setRealAmount($real_amount) {
  362. $this->real_amount = $real_amount;
  363. }
  364. /**
  365. * @return float
  366. */
  367. public function getPtbCnt() {
  368. return $this->ptb_cnt;
  369. }
  370. /**
  371. * @param float $ptb_cnt
  372. */
  373. public function setPtbCnt($ptb_cnt) {
  374. $this->ptb_cnt = $ptb_cnt;
  375. }
  376. /**
  377. * @return float
  378. */
  379. public function getRebateCnt() {
  380. return $this->rebate_cnt;
  381. }
  382. /**
  383. * @param float $rebate_cnt
  384. */
  385. public function setRebateCnt($rebate_cnt) {
  386. $this->rebate_cnt = $rebate_cnt;
  387. }
  388. /**
  389. * @return float
  390. */
  391. public function getDiscount() {
  392. return $this->discount;
  393. }
  394. /**
  395. * @param float $discount
  396. */
  397. public function setDiscount($discount) {
  398. $this->discount = $discount;
  399. }
  400. /**
  401. * @return string
  402. */
  403. public function getPayway() {
  404. return $this->payway;
  405. }
  406. /**
  407. * @param string $payway
  408. */
  409. public function setPayway($payway) {
  410. $this->payway = $payway;
  411. }
  412. /**
  413. * @return string
  414. */
  415. public function getIp() {
  416. return $this->ip;
  417. }
  418. /**
  419. * @param string $ip
  420. */
  421. public function setIp($ip) {
  422. $this->ip = $ip;
  423. }
  424. /**
  425. * @return int
  426. */
  427. public function getStatus() {
  428. return $this->status;
  429. }
  430. /**
  431. * @param int $status
  432. */
  433. public function setStatus($status) {
  434. $this->status = $status;
  435. }
  436. /**
  437. * @return int
  438. */
  439. public function getCreateTime() {
  440. return $this->create_time;
  441. }
  442. /**
  443. * @param int $create_time
  444. */
  445. public function setCreateTime($create_time) {
  446. $this->create_time = $create_time;
  447. }
  448. /**
  449. * @return int
  450. */
  451. public function getUpdateTime() {
  452. return $this->update_time;
  453. }
  454. /**
  455. * @param int $update_time
  456. */
  457. public function setUpdateTime($update_time) {
  458. $this->update_time = $update_time;
  459. }
  460. /**
  461. * @return string
  462. */
  463. public function getRemark() {
  464. return $this->remark;
  465. }
  466. /**
  467. * @param string $remark
  468. */
  469. public function setRemark($remark) {
  470. $this->remark = $remark;
  471. }
  472. /**
  473. * @return int
  474. */
  475. public function getType() {
  476. return $this->type;
  477. }
  478. /**
  479. * @param int $type
  480. */
  481. public function setType($type) {
  482. $this->type = $type;
  483. }
  484. /**
  485. * @return int
  486. */
  487. public function getAgentId() {
  488. return $this->agent_id;
  489. }
  490. /**
  491. * @param int $agent_id
  492. */
  493. public function setAgentId($agent_id) {
  494. $this->agent_id = $agent_id;
  495. }
  496. /**
  497. * @return int
  498. */
  499. public function getCostPtbCnt() {
  500. return $this->cost_ptb_cnt;
  501. }
  502. /**
  503. * @param int $cost_ptb_cnt
  504. */
  505. public function setCostPtbCnt($cost_ptb_cnt) {
  506. $this->cost_ptb_cnt = $cost_ptb_cnt;
  507. }
  508. /**
  509. * @return int
  510. */
  511. public function getToAgentId() {
  512. return $this->to_agent_id;
  513. }
  514. /**
  515. * @param int $to_agent_id
  516. */
  517. public function setToAgentId($to_agent_id) {
  518. $this->to_agent_id = $to_agent_id;
  519. }
  520. /**
  521. * @return int
  522. */
  523. public function getAppId() {
  524. return $this->app_id;
  525. }
  526. /**
  527. * @param int $app_id
  528. */
  529. public function setAppId($app_id) {
  530. $this->app_id = $app_id;
  531. }
  532. /**
  533. * @return float
  534. */
  535. public function getBackPtbCnt() {
  536. return $this->back_ptb_cnt;
  537. }
  538. /**
  539. * @param float $back_ptb_cnt
  540. */
  541. public function setBackPtbCnt($back_ptb_cnt) {
  542. $this->back_ptb_cnt = $back_ptb_cnt;
  543. }
  544. /**
  545. * @return float
  546. */
  547. public function getGmCnt() {
  548. return $this->gm_cnt;
  549. }
  550. /**
  551. * @param float $gm_cnt
  552. */
  553. public function setGmCnt($gm_cnt) {
  554. $this->gm_cnt = $gm_cnt;
  555. }
  556. /**
  557. * @return float
  558. */
  559. public function getCostGmCnt() {
  560. return $this->cost_gm_cnt;
  561. }
  562. /**
  563. * @param float $cost_gm_cnt
  564. */
  565. public function setCostGmCnt($cost_gm_cnt) {
  566. $this->cost_gm_cnt = $cost_gm_cnt;
  567. }
  568. /**
  569. * @return float
  570. */
  571. public function getBackGmCnt() {
  572. return $this->back_gm_cnt;
  573. }
  574. /**
  575. * @param float $back_gm_cnt
  576. */
  577. public function setBackGmCnt($back_gm_cnt) {
  578. $this->back_gm_cnt = $back_gm_cnt;
  579. }
  580. }