Pointshop.php 1.9 KB

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