Manage.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. namespace Code\Lib;
  3. use Dever;
  4. class Manage
  5. {
  6. /**
  7. * 显示用户信息
  8. *
  9. * @return mixed
  10. */
  11. public function showUserInfo($uid, $ldate = false)
  12. {
  13. if ($uid) {
  14. $user = Dever::db('passport/user')->one($uid);
  15. if ($user) {
  16. $table = array();
  17. $table['用户名'] = $user['username'];
  18. $table['手机号'] = $user['mobile'];
  19. $table['领取时间'] = date('Y-m-d H:i:s', $ldate);
  20. return Dever::table($table);
  21. }
  22. } else {
  23. return '';
  24. }
  25. }
  26. /**
  27. * 创建兑换码
  28. *
  29. * @return mixed
  30. */
  31. public function create($id, $name, $data)
  32. {
  33. $code = Dever::param('code', $data);
  34. $type = Dever::param('type', $data);
  35. $product_id = Dever::param('product_id', $data);
  36. $product_id = $id;
  37. if (!in_array(2, $type)) {
  38. return;
  39. }
  40. $total = Dever::db('code/info')->total(array('product_id' => $product_id,'product_price_id' => $id, 'type' => 1));
  41. if ($code > 0 && $code > $total) {
  42. $num = $code - $total;
  43. for ($i = 0; $i < $num; $i++) {
  44. $this->createCode($product_id, $id);
  45. }
  46. }
  47. }
  48. private function createCode($product_id, $id)
  49. {
  50. $code = Dever::rand(8, 0);
  51. $data['product_id'] = $product_id;
  52. $data['product_price_id'] = $id;
  53. $data['code'] = $code;
  54. $total = Dever::db('code/info')->total($data);
  55. if ($total > 0) {
  56. return $this->createCode($product_id, $id);
  57. }
  58. $data['type'] = 1;
  59. Dever::db('code/info')->insert($data);
  60. return $code;
  61. }
  62. /**
  63. * 资料审核
  64. *
  65. * @return mixed
  66. */
  67. public function info_audit($id, $name, $data)
  68. {
  69. $info = Dever::db('task/user_info')->one($id);
  70. $status = Dever::param('status', $data);
  71. $desc = Dever::param('status_desc', $data);
  72. if ($info && $status == 3) {
  73. $uid = $info['uid'];
  74. $name = '用户认证未通过';
  75. $content = '原因:' . $desc;
  76. Dever::load('message/lib/data.push', -1, $uid, $name, $content, 11);
  77. }
  78. }
  79. }