reader.class.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: wangming
  5. * Date: 2019/1/22
  6. * Time: 21:34
  7. */
  8. class Common_guest{
  9. public function __construct()
  10. {
  11. }
  12. static public function getInfoById($id)
  13. {
  14. $Table_common_guest = new Table_common_guest();
  15. return $Table_common_guest->getInfoById($id);
  16. }
  17. static public function getInfoByPhone($phone)
  18. {
  19. $Table_common_guest = new Table_common_guest();
  20. return $Table_common_guest->getInfoByPhone($phone);
  21. }
  22. static public function getInfoByOpenId($openId)
  23. {
  24. $Table_common_guest = new Table_common_guest();
  25. return $Table_common_guest->getInfoByOpenId($openId);
  26. }
  27. static public function generateNewCode($id)
  28. {
  29. $Table_common_guest = new Table_common_guest();
  30. return $Table_common_guest->generateNewCode($id);
  31. }
  32. static public function getPassInfo($id)
  33. {
  34. $guest = self::getInfoById($id);
  35. if (empty($guest)) {
  36. return 0;
  37. }
  38. //没有编号先生成编号
  39. if (empty($guest['code'])) {
  40. $newCode = self::generateNewCode($id);
  41. $updateAttr = array(
  42. 'code' => $newCode,
  43. );
  44. self::update($id, $updateAttr);
  45. }
  46. //增加一次次数
  47. $countAttr = array(
  48. 'count' => $guest['count'] + 1,
  49. );
  50. self::update($id, $countAttr);
  51. //返回是否可以入场标记
  52. $ret['id'] = $id;
  53. $ret['type'] = 1; //1-普通客户 2-经销商客户
  54. $ret['msg'] = '允许入场';
  55. $guest = self::getInfoById($id);
  56. $ret['code'] = $guest['code'];
  57. $ret['addtime'] = GetDateString($guest['addtime'], true);
  58. return $ret;
  59. }
  60. static public function add($attrs)
  61. {
  62. $Table_common_guest = new Table_common_guest();
  63. $id = $Table_common_guest->add($attrs);
  64. return $id;
  65. }
  66. static public function edit($id, $attrs)
  67. {
  68. $Table_common_guest = new Table_common_guest();
  69. return $Table_common_guest->edit($id, $attrs);
  70. }
  71. static public function update($id, $attrs)
  72. {
  73. $Table_common_guest = new Table_common_guest();
  74. return $Table_common_guest->update($id, $attrs);
  75. }
  76. static public function del($id)
  77. {
  78. $Table_common_guest = new Table_common_guest();
  79. return $Table_common_guest->del($id);
  80. }
  81. static public function getList($filter = array(), $count=0, $page=0, $pageSize=0)
  82. {
  83. $Table_common_guest = new Table_common_guest();
  84. return $Table_common_guest->getList($filter, $count, $page, $pageSize);
  85. }
  86. static public function getListByPage($filter = array(), $page=0, $pagesize=0){
  87. $Table_common_guest = new Table_common_guest();
  88. return $Table_common_guest->getList($filter, 0, $page, $pagesize);
  89. }
  90. static public function getCountAll($filter = array()){
  91. $Table_common_guest = new Table_common_guest();
  92. return $Table_common_guest->getList($filter, 1);
  93. }
  94. }