RoleController.php 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. /**
  3. * RoleController.php UTF-8
  4. * 角色上报
  5. *
  6. * @date : 2018/1/16 16:51
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : wuyonghong <wyh@huosdk.com>
  10. * @version : HUOSDK 8.0
  11. */
  12. namespace mini\sdk\controller;
  13. use huo\controller\member\MemCache;
  14. use huo\controller\pay\PayShow;
  15. use huo\controller\pay\PaySwitch;
  16. use huolib\constant\CommonConst;
  17. use huolib\constant\GameConst;
  18. use huolib\constant\MemConst;
  19. use huolib\constant\OrderConst;
  20. use huolib\status\CommonStatus;
  21. use huolib\status\MemberStatus;
  22. use mini\common\controller\V2ApiBaseController;
  23. use huo\controller\member\Role;
  24. use think\Request;
  25. class RoleController extends V2ApiBaseController {
  26. public function __construct(Request $request = null) {
  27. parent::__construct($request);
  28. }
  29. public function _initialize() {
  30. parent::_initialize();
  31. }
  32. /**
  33. * 上传角色信息
  34. * http://doc.1tsdk.com/159?page_id=4833
  35. * 【域名】/mp/user/uprole
  36. */
  37. public function save() {
  38. $this->checkLogin();
  39. $_game_rq = $this->setGameData();
  40. $_role_rq = $this->setRoleData();
  41. $_mem_rq = $this->setMemData();
  42. $_mem_rq->setMemId($this->mem_id);
  43. $_mem_data = MemCache::ins()->getInfoById($this->mem_id);
  44. if (isset($_mem_data['status']) && $_mem_data['status'] == MemConst::STATUS_FORBID) {
  45. $_code = MemberStatus::LOGIN_IS_OUT;
  46. $this->error(lang(MemberStatus::getMsg($_code)), [], $_code);
  47. }
  48. $_device_rq = $this->setDeviceData();
  49. $_role_class = new Role();
  50. $_rs = $_role_class->insertLog($_mem_rq, $_role_rq, $_game_rq, 0.00, $_device_rq);
  51. if (false !== $_rs) {
  52. $this->success(lang('SUCCESS'));
  53. }
  54. $this->error(lang('ERROR'));
  55. }
  56. /**
  57. * 获取角色充值控制
  58. * 【域名】/v8/user/checkpay
  59. * http://doc.1tsdk.com/159?page_id=9036
  60. */
  61. public function checkPay() {
  62. $this->checkLogin();
  63. $_game_rq = $this->setGameData();
  64. $_channel_rq = $this->setChannelData();
  65. $_mem_rq = $this->setMemData();
  66. $_role_rq = $this->setRoleData();
  67. $_order_rq = $this->setOrderData();
  68. $_device_rq = $this->setDeviceData();
  69. $_pay_check = OrderConst::PAY_SWITCH_NO;
  70. /* 判断支付切换 */
  71. if (GameConst::GAME_MP_GAME == $_game_rq->getPkgName()) {
  72. $_pay_switch = new PaySwitch();
  73. $_pay_check = $_pay_switch->getPaySwitch(
  74. $_order_rq, $_role_rq, $_mem_rq, $_game_rq, $_channel_rq, $_device_rq
  75. );
  76. $_pay_check = $_pay_switch->checkShowPay($_pay_check, $_device_rq);
  77. $_pay_show = new PayShow();
  78. $_show_status = $_pay_show->getPayShow(
  79. $_order_rq, $_role_rq, $_mem_rq, $_game_rq, $_channel_rq, $_device_rq
  80. );
  81. if (CommonConst::STATUS_NO == $_show_status) {
  82. $_pay_check = OrderConst::PAY_SWITCH_IOS_NO;
  83. }
  84. }
  85. $_r_data = [
  86. 'check' => $_pay_check
  87. ];
  88. $_code = CommonStatus::NO_ERROR;
  89. $this->success(CommonStatus::getMsg($_code), $_r_data, $_code);
  90. }
  91. }