IdentifyOrderModel.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <?php
  2. /**
  3. * IdentifyOrderModel.php UTF-8
  4. *
  5. * @date : 2021/3/20 15:38
  6. *
  7. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  8. * @author : chenbingling <cbl@huosdk.com>
  9. * @version : HUOSDK-9.0
  10. */
  11. namespace huoIdentify\model;
  12. use huo\model\common\CommonModel;
  13. use huolib\constant\CacheConst;
  14. class IdentifyOrderModel extends CommonModel {
  15. protected $name = 'identify_order';
  16. protected $pk = 'id';
  17. /* 开启自动写入时间戳字段 */
  18. protected $autoWriteTimestamp = true;
  19. protected $cache_key_prefix = CacheConst::CACHE_IDENTIFY_ORDER_PREFIX;
  20. protected $type
  21. = [
  22. 'id' => 'integer',
  23. 'ai' => 'string',
  24. 'mem_id' => 'integer',
  25. 'biz_id' => 'string',
  26. 'real_name' => 'string',
  27. 'id_card' => 'string',
  28. 'status' => 'integer',
  29. 'create_time' => 'timestamp',
  30. 'update_time' => 'timestamp',
  31. ];
  32. /**
  33. * 获取单条记录缓存key
  34. *
  35. * @param int $id ID
  36. *
  37. * @return string :string
  38. */
  39. protected function getSingleCacheKey($id) {
  40. return $this->cache_key_prefix.$id;
  41. }
  42. /**
  43. * 通过ID获取信息
  44. *
  45. * @param int $id 主键ID
  46. *
  47. * @return array
  48. */
  49. public function getInfoById($id) {
  50. $_data = parent::getInfoById($id);
  51. return $_data;
  52. }
  53. /**
  54. * 加入数据库
  55. *
  56. * @param array $data
  57. *
  58. * @return bool|int
  59. */
  60. public function addData($data) {
  61. $_data = $data;
  62. $_rs = parent::addData($_data);
  63. if (empty($_rs)) {
  64. return false;
  65. }
  66. return $_rs;
  67. }
  68. /**
  69. * 更新单条数据
  70. *
  71. * @param array $data 数据
  72. * @param int $id ID
  73. *
  74. * @return bool
  75. */
  76. public function updateData($data, $id) {
  77. $_data = $data;
  78. $_rs = parent::updateData($_data, $id);
  79. if (false === $_rs) {
  80. return false;
  81. }
  82. return true;
  83. }
  84. /**
  85. * 获取认证中的ai
  86. *
  87. * @param $biz_id
  88. * @param $mem_id
  89. *
  90. * @return array|false
  91. */
  92. public function getLastInfoByBizIdMem($biz_id, $mem_id) {
  93. $_map = [
  94. 'biz_id' => $biz_id,
  95. 'mem_id' => $mem_id,
  96. ];
  97. $_field = ['ai', 'real_name', 'id_card','status'];
  98. $_info = $this->where($_map)->order('id desc')->field($_field)->find();
  99. if (is_object($_info)) {
  100. $_info = $_info->toArray();
  101. }
  102. return $_info;
  103. }
  104. /**
  105. * 关联玩家
  106. */
  107. public function mem() {
  108. $_field = [
  109. 'id',
  110. 'username'
  111. ];
  112. return $this->belongsTo('\huo\model\member\MemberModel', 'mem_id', 'id')->field($_field);
  113. }
  114. }