人人商城

coupon.ctrl.php 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /**
  3. * [WeEngine System] Copyright (c) 2014 WE7.CC
  4. * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
  5. */
  6. defined('IN_IA') or exit('Access Denied');
  7. error_reporting(0);
  8. global $_W;
  9. load()->func('file');
  10. load()->model('activity');
  11. activity_coupon_type_init();
  12. if (!in_array($do, array('local', 'wechat'))) {
  13. exit('Access Denied');
  14. }
  15. if ($do == 'wechat') {
  16. $condition = ' WHERE uniacid = :uniacid AND is_display = 1 AND status = 3 AND source = :source AND quantity > 0';
  17. $param = array(
  18. ':uniacid' => $_W['uniacid'],
  19. ':source' => COUPON_TYPE,
  20. );
  21. $pindex = max(1, intval($_GPC['page']));
  22. $psize = 15;
  23. $total = pdo_fetchcolumn('SELECT COUNT(*) FROM '. tablename('coupon') . $condition, $param);
  24. $data = pdo_fetchall('SELECT * FROM ' . tablename('coupon') . $condition . ' ORDER BY id DESC LIMIT ' . ($pindex - 1) * $psize . ', ' . $psize, $param, 'id');
  25. if(!empty($data)) {
  26. foreach($data as $key => &$da) {
  27. $da['date_info'] = iunserializer($da['date_info']);
  28. $da['media_id'] = $da['card_id'];
  29. $da['logo_url'] = url('utility/wxcode/image', array('attach' => $da['logo_url']));
  30. $da['ctype'] = $da['type'];
  31. $da['extra'] = iunserializer($da['extra']);
  32. if ($da['type'] == '1') {
  33. $da['extra']['discount'] = $da['extra']['discount'] * 0.1;
  34. } elseif ($da['type'] == '2') {
  35. $da['extra']['reduce_cost'] = $da['extra']['reduce_cost'] * 0.01;
  36. }
  37. if ($da['date_info']['time_type'] == '1') {
  38. $starttime = strtotime(str_replace('.', '-', $da['date_info']['time_limit_start']));
  39. $endtime = strtotime(str_replace('.', '-', $da['date_info']['time_limit_end']));
  40. if ($starttime > strtotime(date('Y-m-d')) || $endtime < strtotime(date('Y-m-d'))) {
  41. unset($data[$key]);
  42. }
  43. }
  44. }
  45. }
  46. message(array('page'=> pagination($total, $pindex, $psize, '', array('before' => '2', 'after' => '2', 'ajaxcallback'=>'null')), 'items' => $data), '', 'ajax');
  47. }