Pay.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <?php
  2. /**
  3. * Pay.php UTF-8
  4. * 支付校验
  5. *
  6. * @date : 2019/12/2 10:22
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : chenbingling <cbl@huosdk.com>
  10. * @version : HUOSDK 8.5
  11. */
  12. namespace huoIdentify\controller;
  13. use huo\controller\common\Base;
  14. use huo\model\game\GameModel;
  15. use huo\model\member\MemberModel;
  16. use huoIdentify\logic\IdentifyDayIdotLogic;
  17. use huoIdentify\logic\IdentifyIdotLogic;
  18. use huoIdentify\model\IdentifyMemModel;
  19. use huolib\constant\CommonConst;
  20. use huolib\constant\GameConst;
  21. use huolib\constant\IdentifyConst;
  22. use huolib\constant\MemConst;
  23. use huolib\status\IdentifyStatus;
  24. use huolib\utils\IdentifyUtils;
  25. class Pay extends Base {
  26. /**
  27. * 支付校验
  28. *
  29. * @param int $mem_id 玩家id
  30. * @param int $app_id 游戏id
  31. * @param float $amount 订单金额
  32. * @param string $token token
  33. *
  34. * @return string|array url 实名认证地址或提示信息地址
  35. */
  36. public function checkLimit($mem_id, $app_id, $amount, $token = '') {
  37. $_token = empty($token) ? session_id() : $token;
  38. $_game_auth = (new GameModel())->getIsAuthById($app_id);
  39. /* 不需要实名不做任何处理 */
  40. if (GameConst::GAME_IDENTIFY_IS_NO == $_game_auth) {
  41. return '';
  42. }
  43. $_identify_conf = (new IdentifyConf())->getConf();
  44. $_id_card = (new IdentifyMemModel())->getIdCardByMemId($mem_id);
  45. if (empty($_id_card)) {
  46. $_is_allow_charge = $_identify_conf['unnamed']['is_allow_charge'];
  47. /* 如果未实名允许充值则不做任何处理 */
  48. if (CommonConst::STATUS_YES == $_is_allow_charge) {
  49. return '';
  50. }
  51. /* Modified by chenbingling BEGIN 2021/9/3 ISSUES:#15622 产品需求 已输入过实名的用户用没有说明认证不成功,点击充值的时候不用再输入姓名等信息*/
  52. $_in_progress_data = (new Identify())->getInProgressDataByMemApp($mem_id, $app_id);
  53. if (!empty($_in_progress_data)) {
  54. $_code = IdentifyStatus::MEM_IDENTIFY_IN_PROGRESS;
  55. return $this->huoError($_code, IdentifyStatus::getMsg($_code));
  56. }
  57. /* END 2021/9/3 ISSUES:#15622 */
  58. $_param = [
  59. 'app_id' => $app_id,
  60. 'token' => $_token
  61. ];
  62. $_identify_url = IdentifyConst::getIdentifyUrl($_param);
  63. $_mem_model = new MemberModel();
  64. $_status = $_mem_model->getStatus($mem_id);
  65. $_mobile = $_mem_model->getMobileById($mem_id);
  66. if (empty($_mobile) && MemConst::STATUS_TRY == $_status) {
  67. $_identify_url = IdentifyConst::getBindMobileUrl($_param);
  68. }
  69. return $_identify_url;
  70. }
  71. $_age = IdentifyUtils::getAgeById($_id_card);
  72. if ($_age >= 18) {
  73. return '';
  74. }
  75. // 校验未成年玩家限制
  76. $_online_class = new Online($app_id, $mem_id, '');
  77. $_online_class->setToken($_token);
  78. $_url = $_online_class->checkUnderageLimitOnTheHour();
  79. if (!empty($_url)) {
  80. return $_url;
  81. }
  82. $_type = CommonConst::CONST_ZERO;
  83. $_idot_data = (new IdentifyIdotLogic())->getInfoByIdCard($_id_card);
  84. $_week_money = get_val($_idot_data, 'week_money', 0.00) + $amount;
  85. $_month_money = get_val($_idot_data, 'month_money', 0.00) + $amount;
  86. $_charge_limit = $_identify_conf['underage']['charge_limit'];
  87. foreach ($_charge_limit as $_k => $_v) {
  88. if ($_v['min_age'] <= $_age && $_age <= $_v['max_age']
  89. && ($_week_money > $_v['week_money']
  90. || $_month_money > $_v['month_money'])) {
  91. switch ($_k) {
  92. case 0:
  93. $_type = IdentifyConst::UNDERAGE_AGE_8_CHARGE_LIMIT;
  94. break;
  95. case 1:
  96. $_type = IdentifyConst::UNDERAGE_AGE_8_16_CHARGE_LIMIT;
  97. break;
  98. case 2:
  99. $_type = IdentifyConst::UNDERAGE_AGE_16_18_CHARGE_LIMIT;
  100. break;
  101. default:
  102. }
  103. break;
  104. }
  105. }
  106. $_param = [
  107. 'app_id' => $app_id,
  108. 'token' => $token
  109. ];
  110. return IdentifyConst::getUnderageLimitMsgUrl($_type, $_param);
  111. }
  112. /**
  113. * 更新支付金额
  114. *
  115. * @param int $mem_id 玩家id
  116. * @param float $money 支付金额
  117. *
  118. * @return bool
  119. */
  120. public function updateMoney($mem_id, $money) {
  121. $_id_card = (new IdentifyMemModel())->getIdCardByMemId($mem_id);
  122. if (!empty($_id_card)) {
  123. (new IdentifyDayIdotLogic())->updateSumMoneyByIdCard($money, $_id_card, $mem_id);
  124. (new IdentifyIdotLogic())->updateSumMoneyByIdCard($money, $_id_card);
  125. }
  126. return true;
  127. }
  128. }