Manage.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. $product_num = Dever::param('product_num', $param);
  37. $product = Dever::param('product', $param);
  38. //$product_id = Dever::param('product_id', $param);
  39. $seller_id = Dever::param('seller_id', $param);
  40. $cate_id = $product_id = 0;
  41. if ($product && isset($product[0]) && isset($product[1])) {
  42. $cate_id = $product[0];
  43. $product_id = $product[1];
  44. $product = implode(',', $product);
  45. }
  46. if ($cate_id <= 0 || $product_id <= 0){
  47. Dever::alert('生成失败');
  48. }
  49. //$total = Dever::db('code/info')->total(array('product_id' => $product_id, 'type' => 1));
  50. $total = 0;
  51. $core = Dever::load('code/lib/core');
  52. if ($code > 0 && $code > $total) {
  53. $num = $code - $total;
  54. for ($i = 0; $i < $num; $i++) {
  55. $core->createCode($product, $cate_id, $product_id, $seller_id, $product_num);
  56. }
  57. }
  58. }
  59. }