Pointshop.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace app\api\controller;
  3. use think\facade\Lang;
  4. /**
  5. * ============================================================================
  6. *
  7. * ============================================================================
  8. *
  9. * ----------------------------------------------------------------------------
  10. *
  11. * ============================================================================
  12. * 控制器
  13. */
  14. class Pointshop extends MobileMall
  15. {
  16. public function initialize()
  17. {
  18. parent::initialize(); // TODO: Change the autogenerated stub
  19. Lang::load(base_path() . 'home/lang/' . config('lang.default_lang') . '/pointprod.lang.php');
  20. Lang::load(base_path() . 'home/lang/' . config('lang.default_lang') . '/voucher.lang.php');
  21. //判断系统是否开启积分兑换功能
  22. if (config('ds_config.points_isuse') != 1 || config('ds_config.pointprod_isuse') != 1) {
  23. ds_json_encode(10001, lang('pointshop_unavailable'));
  24. }
  25. }
  26. public function index()
  27. {
  28. $result = array();
  29. //开启代金券功能后查询推荐的热门代金券列表
  30. if (config('ds_config.voucher_allow') == 1) {
  31. $recommend_voucher = model('voucher')->getRecommendTemplate(6);
  32. $result['recommend_voucher'] = $recommend_voucher;
  33. //平台代金券
  34. $where = array();
  35. $where[] = array('mallvouchertemplate_startdate', '<', TIMESTAMP);
  36. $where[] = array('mallvouchertemplate_enddate', '>', TIMESTAMP);
  37. $mallvoucherlist = model('mallvouchertemplate')->getMallvouchertemplateList($where, 6);
  38. $result['mall_voucher'] = $mallvoucherlist;
  39. }
  40. //开启积分兑换功能后查询推荐的热门兑换商品列表
  41. if (config('ds_config.pointprod_isuse') == 1) {
  42. //热门积分兑换商品
  43. $recommend_pointsprod = model('pointprod')->getRecommendPointProd(10);
  44. $result['recommend_pointsprod'] = $recommend_pointsprod;
  45. }
  46. ds_json_encode(10000, '', $result);
  47. }
  48. }