UnusualMemModel.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?php
  2. /**
  3. * UnusualMemModel.php UTF-8
  4. * 异常玩家记录
  5. *
  6. * @date : 2018/10/23 18:04
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : chenbingling <cbl@huosdk.com>
  10. * @version : HuoMP 1.0
  11. */
  12. namespace huomp\model\member;
  13. use huo\controller\member\MemCache;
  14. use huolib\constant\MemConst;
  15. use huomp\model\common\CommonModel;
  16. class UnusualMemModel extends CommonModel {
  17. protected $table = 'mp_unusual_mem';
  18. // 开启自动写入时间戳字段
  19. protected $autoWriteTimestamp = true;
  20. /**
  21. * 添加数据
  22. *
  23. * @param $data
  24. *
  25. * @return bool
  26. */
  27. public function addData($data) {
  28. if (empty($data)) {
  29. return false;
  30. }
  31. $_data = $data;
  32. $_obj = self::create($_data, true);
  33. if ($_obj) {
  34. return true;
  35. }
  36. return false;
  37. }
  38. /**
  39. * 更新数据
  40. *
  41. * @param array $data 数据
  42. * @param int $id ID
  43. *
  44. * @return bool
  45. */
  46. public function updateData($data, $id) {
  47. $_map['id'] = $id;
  48. $_data = $data;
  49. $_rs = self::update($_data, $_map, true);
  50. if (false == $_rs) {
  51. return false;
  52. }
  53. return true;
  54. }
  55. /**
  56. * 更新数据
  57. *
  58. * @param array $data 数据
  59. * @param int $agent_id 渠道id
  60. *
  61. * @return bool
  62. */
  63. public function updateDataByAgentId($data, $agent_id) {
  64. $_map['agent_id'] = $agent_id;
  65. $_data = $data;
  66. $_rs = self::update($_data, $_map, true);
  67. if (false == $_rs) {
  68. return false;
  69. }
  70. return true;
  71. }
  72. /**
  73. * 通过agent_id 获取信息
  74. *
  75. * @param $agent_id
  76. *
  77. * @return array
  78. */
  79. public function getDataByAgentId($agent_id) {
  80. $_rdata = $this->where(['agent_id' => $agent_id])->find();
  81. if (!empty($_rdata)) {
  82. $_rdata = $_rdata->toArray();
  83. }
  84. return $_rdata;
  85. }
  86. /**
  87. * 删除记录
  88. *
  89. * @param $agent_id
  90. */
  91. public function deleteByAgentId($agent_id) {
  92. /* 获取标记信息 */
  93. $_odata = $this->getDataByAgentId($agent_id);
  94. if (MemConst::UNUSUAL_MEN_TYPE_3 == $_odata['type']) {
  95. if (!empty($_odata['mem_id'])) {
  96. $_mem_data['status'] = MemConst::STATUS_NORMAL;
  97. MemCache::ins()->updateMem($_odata['mem_id'], $_mem_data);
  98. }
  99. }
  100. return $this->where(['agent_id' => $agent_id])->delete();
  101. }
  102. }