Manage.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. namespace Code\Lib;
  3. use Dever;
  4. class Manage
  5. {
  6. /**
  7. * 显示用户信息
  8. *
  9. * @return mixed
  10. */
  11. public function showUserInfo($create_uid, $uid, $ldate = false)
  12. {
  13. $table = array();
  14. if ($create_uid && $create_uid > 0) {
  15. $user = Dever::load('passport/user-one', $create_uid);
  16. $table['创建人'] = $user['username'];
  17. }
  18. if ($uid && $uid > 0) {
  19. $user = Dever::load('passport/user-one', $uid);
  20. if ($user) {
  21. $table['领取人'] = $user['username'];
  22. $table['手机号'] = $user['mobile'];
  23. $table['领取时间'] = date('Y-m-d H:i:s', $ldate);
  24. }
  25. }
  26. return Dever::table($table);
  27. }
  28. /**
  29. * 创建兑换码
  30. *
  31. * @return mixed
  32. */
  33. public function create($id, $name, $param)
  34. {
  35. $code = Dever::param('num', $param);
  36. $score = Dever::param('score', $param);
  37. $product_num = Dever::param('product_num', $param);
  38. $product = Dever::param('product', $param);
  39. //$product_id = Dever::param('product_id', $param);
  40. $seller_id = Dever::param('seller_id', $param);
  41. $cate_id = $product_id = 0;
  42. if ($product && isset($product[0])) {
  43. $cate_id = $product[0];
  44. if (isset($product[1])) {
  45. $product_id = $product[1];
  46. }
  47. $product = implode(',', $product);
  48. }
  49. if ($cate_id <= 0){
  50. Dever::alert('生成失败,请选择分类');
  51. }
  52. //$total = Dever::db('code/info')->total(array('product_id' => $product_id, 'type' => 1));
  53. $total = 0;
  54. $core = Dever::load('code/lib/core');
  55. if ($code > 0 && $code > $total) {
  56. $num = $code - $total;
  57. for ($i = 0; $i < $num; $i++) {
  58. $core->createCode($product, $cate_id, $product_id, $seller_id, $product_num, -1, false, $score);
  59. }
  60. }
  61. }
  62. /**
  63. * 作废
  64. *
  65. * @return mixed
  66. */
  67. public function drop_api($id)
  68. {
  69. $update['where_id'] = $id;
  70. $update['type'] = 4;
  71. Dever::db('code/info')->update($update);
  72. return 'ok';
  73. }
  74. public function recovery_api($id)
  75. {
  76. $update['where_id'] = $id;
  77. $update['type'] = 1;
  78. Dever::db('code/info')->update($update);
  79. return 'ok';
  80. }
  81. }