Account.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?php
  2. /**
  3. *------Create thems Model------
  4. *------SCWPHP Version 1.0.0------
  5. *------Dev Model Jions------
  6. *------Create Time 2017-06-06 07:45:06------
  7. */
  8. namespace App\Api\Model;
  9. use App\Commons\Model\Money_recharge;
  10. use Biz\Account\AccountManager;
  11. use \System\Model;
  12. class Account extends Model
  13. {
  14. protected $table = 'account';
  15. protected function getMoneyRechargeRec(string $account_identity, $activeId, string $type = '')
  16. {
  17. $m = new Money_recharge();
  18. $where = [
  19. 'account_identity' => $account_identity,
  20. 'status' => 1
  21. ];
  22. $betTime = '';
  23. switch ($type) {
  24. case 'month':
  25. $where[] = ['complete_time', '>=', $betTime = date ('Y-m-1')];
  26. break;
  27. case 'week':
  28. $time = date ('Y-m-d');
  29. $t = strtotime ($time . ' Sunday');
  30. $where[] = ['complete_time', '>=', $betTime = date ('Y-m-d H:i:s', $t - 86400 * 6)];
  31. break;
  32. default:
  33. $where[] = ['complete_time', '>=', $betTime = '2018-01-01 00:00:00'];
  34. }
  35. self::chkBettingRecord ($account_identity, $betTime);
  36. return $m->where ($where)->whereIn ('recharge_type', ['后台充值', '汇款', '在线充值'])->orderBy ('apply_time')->first (['money', 'order_id', 'complete_time']);
  37. }
  38. public static function chkFirstRecharge($account_identity, $activeId, $type = '')
  39. {
  40. $active = Lottery_money::where ('id', $activeId)->first ();
  41. // dd($activeId,$active);
  42. if (!$active)
  43. Render ('', -50016); //找不到该彩金活动
  44. $ret1 = self::getMoneyRechargeRec ($account_identity, $activeId, $type);
  45. if (!$ret1)
  46. Render ('', -50031);//没找到首充记录
  47. $content = json_decode ($active->conent, 1);
  48. $timeout = $content['fr_time'] ?? 0;
  49. $timeouted = strtotime ($ret1->complete_time) >= time () - $timeout * 3600;
  50. if (!$timeouted && $timeout)
  51. Render ('', -50032);//过期
  52. $ret2 = Lottery_money_log::where ('order_id', $ret1->order_id)->first ();
  53. if ($ret2) {
  54. if ($ret2->status = 0)
  55. Render ('', -50035);//申请审核中
  56. elseif ($ret2->status = 0)
  57. Render ('', -50034);//该订单已参加过活动
  58. }
  59. //验证是否有下注
  60. return $ret1;
  61. }
  62. protected function chkBettingRecord($account_identity, $time)
  63. {
  64. $mb = MoneyBuy::where ('account_identity', $account_identity)->where ('money_time', '>=', $time)->first ();
  65. $mb6 = SixmoneyBuy::where ('account_identity', $account_identity)->where ('money_time', '>=', $time)->first ();
  66. if ($mb || $mb6)
  67. Render ('', -50033);//有下注
  68. return 1;
  69. }
  70. public function getAccount($account_identity)
  71. {
  72. return self::where('identity', $account_identity)->pluck('account');
  73. }
  74. /**
  75. * @param string $token
  76. * @param string $payPass
  77. * @return bool
  78. * @throws \Exception
  79. */
  80. public static function checkPayPwd(string $token, string $payPass): int
  81. {
  82. $accountManager = new AccountManager();
  83. $userId = $accountManager->getCurrentUser()->account_identity;
  84. $res = lm('account_bank', 'Commons')->where(['account_identity' => $userId])->first();
  85. if (!$res) {
  86. // Render('', -2046, lang()->get('missing bankCard'));
  87. return -2046;
  88. }
  89. $return = $accountManager->repository->checkOldPayPassword($token, $payPass);
  90. return $status = $return['status'];
  91. }
  92. }