Hit_code.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?php
  2. namespace App\Models;
  3. /**
  4. *
  5. */
  6. class Hit_code extends BaseModel {
  7. protected $table = "hit_code";
  8. public $timestamps = false;
  9. //获取打码量详情
  10. function getHitcodeDetails($value, $type = 2) {
  11. $key = $this->getFeild($type);
  12. $data = $this->where($key, $value)->first();
  13. if (!$data) {
  14. return -7012000102; //没有详情信息
  15. }
  16. return $data->toArray();
  17. }
  18. //字段对应值
  19. private function getFeild($num) {
  20. $data = array(
  21. '1' => 'id',
  22. '2' => 'account_identity',
  23. '3' => 'account_name',
  24. '4' => 'hitcode_game',
  25. '5' => 'hitcode_count',
  26. '6' => 'star_time',
  27. '7' => 'sort',
  28. );
  29. return $data[$num];
  30. }
  31. //插入数据
  32. function saveData($data) {
  33. if(!$this->checkInfo($data['account_identity'])){
  34. $res = $this->updateInfo($data,'account_identity',$data['account_identity']);
  35. return $res;
  36. }
  37. $this->account_name = $data['account_name'];
  38. $this->account_identity = $data['account_identity'];
  39. $this->star_time = $data['star_time'];
  40. $this->add_time = $data['add_time'];
  41. $res = $this->save();
  42. if (!$res) {
  43. return -7012000202; //更新失败
  44. }
  45. return $this->order_id;
  46. }
  47. /**
  48. * 通过用户ID选择入款初始时间
  49. * 'user description'
  50. * @return 'type' 'description'
  51. */
  52. function selectHitcodetimeById($value,$hitcode_time) {
  53. $account = new \App\Models\Account;
  54. $info = $account->getinfo($value,1);
  55. if($info<0){
  56. return $info; //用户暂无记录
  57. }
  58. $data = array(
  59. 'account_identity' => $info['identity'],
  60. 'account_name' => $info['account'],
  61. 'star_time' => $hitcode_time,
  62. 'add_time' => date('Y-m-d H:i:s',time()),
  63. );
  64. $res = $this->saveData($data);
  65. return $res;
  66. }
  67. /**
  68. * 通过用户identity选择入款初始时间
  69. * 'user description'
  70. * @return 'type' 'description'
  71. */
  72. function selectHitcodetimeByIdentity($value,$hitcode_time) {
  73. $account = new \App\Models\Account;
  74. $info = $account->getinfo($value,2);
  75. if($info<0){
  76. return $info; //用户暂无记录
  77. }
  78. $data = array(
  79. 'account_identity' => $info['identity'],
  80. 'account_name' => $info['account'],
  81. 'star_time' => $hitcode_time,
  82. 'add_time' => date('Y-m-d H:i:s',time()),
  83. );
  84. $res = $this->saveData($data);
  85. return $res;
  86. }
  87. //修改信息
  88. function updateInfo($data,$field,$value){
  89. $res = $this->where($field,$value)->update($data);
  90. if($res<0){
  91. return -7012000302; //操作失败
  92. }
  93. return 1;
  94. }
  95. //检测订单号
  96. function checkInfo($account_identity){
  97. $res=$this->where('account_identity',$account_identity)->first();
  98. if(!$res){
  99. return true;
  100. }
  101. return false;
  102. }
  103. }
  104. ?>