Manage.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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'] . '('.$user['id'].')';
  17. }
  18. if ($uid && $uid > 0) {
  19. $user = Dever::load('passport/user-one', $uid);
  20. if ($user) {
  21. $table['领取人'] = $user['username'] . '('.$user['id'].')';
  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. $core->createCode($product, $cate_id, $product_id, $seller_id, $product_num, -1, false, $score, 1, $num);
  58. }
  59. }
  60. /**
  61. * 作废
  62. *
  63. * @return mixed
  64. */
  65. public function drop_api($id)
  66. {
  67. $update['where_id'] = $id;
  68. $update['type'] = 4;
  69. Dever::db('code/info')->update($update);
  70. return 'ok';
  71. }
  72. public function recovery_api($id)
  73. {
  74. $update['where_id'] = $id;
  75. $update['type'] = 1;
  76. Dever::db('code/info')->update($update);
  77. return 'ok';
  78. }
  79. }