Coupon.php 876 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace Goods\Lib;
  3. use Dever;
  4. class Coupon
  5. {
  6. public function get_api()
  7. {
  8. $level_total = 2;
  9. # 当前联动级别
  10. $level_num = Dever::input('level_num');
  11. # 一般为id
  12. $level_id = Dever::input('level_id');
  13. if ($level_num == 1) {
  14. $method = Dever::db('goods/coupon')->config['method'];
  15. foreach ($method as $k => $v) {
  16. if ($k != 1) {
  17. $data[] = array('value' => $k, 'name' => $v);
  18. }
  19. }
  20. } elseif ($level_num == 2) {
  21. $data = Dever::db('goods/coupon')->getAll(array('method' => $level_id));
  22. }
  23. if (!$data) {
  24. Dever::alert('error');
  25. }
  26. $result['level_total'] = $level_total;
  27. $result['list'] = $data;
  28. return $result;
  29. }
  30. }