Inviterpro.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. namespace app\api\controller;
  3. use think\facade\Lang;
  4. /**
  5. * ============================================================================
  6. * DSMall多用户商城
  7. * ============================================================================
  8. * 版权所有 2014-2028 长沙德尚网络科技有限公司,并保留所有权利。
  9. * 网站地址: http://www.csdeshang.com
  10. * ----------------------------------------------------------------------------
  11. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
  12. * 不允许对程序代码以任何形式任何目的的再发布。
  13. * ============================================================================
  14. * 分销商品控制器
  15. */
  16. class Inviterpro extends MobileMall {
  17. public function initialize() {
  18. parent::initialize();
  19. }
  20. /*
  21. * 获取分销商品列表
  22. */
  23. public function index() {
  24. if (!config('ds_config.inviter_open')) {
  25. $result = array_merge(array('goods_list' => array(),), mobile_page(''));
  26. } else {
  27. $goods_model = model('goods');
  28. $condition = array();
  29. $condition[] = array('inviter_open', '=', 1);
  30. if (input('param.keyword')) {
  31. $condition[] = array('goods_name', 'like', '%' . input('param.keyword') . '%');
  32. }
  33. if (input('param.gc_id')) {
  34. $condition[] = array('gc_id_1', '=', intval(input('param.gc_id')));
  35. }
  36. $cache_key = 'api-inviterpro' . md5(serialize($condition)) . '-' . intval(input('param.page'));
  37. $result = rcache($cache_key);
  38. if (empty($result)) {
  39. $goods_list = $goods_model->getGoodsCommonList($condition, '*', 10);
  40. foreach ($goods_list as $key => $goods) {
  41. $goods_info = $goods_model->getGoodsInfo(array('goods_commonid' => $goods['goods_commonid']), 'goods_id');
  42. $goods_list[$key]['goods_id'] = $goods_info['goods_id'];
  43. $goods_list[$key]['goods_image_url'] = goods_cthumb($goods['goods_image'], 240);
  44. $goods_list[$key]['inviter_amount'] = 0;
  45. if (config('ds_config.inviter_show')) {
  46. $inviter_amount = round($goods['inviter_ratio'] / 100 * $goods['goods_price'] * floatval(config('ds_config.inviter_ratio_1')) / 100, 2);
  47. if ($inviter_amount > 0) {
  48. $goods_list[$key]['inviter_amount'] = $inviter_amount;
  49. }
  50. }
  51. }
  52. $page_count = $goods_model->page_info;
  53. $result = array_merge(array('goods_list' => $goods_list,), mobile_page($page_count));
  54. wcache($cache_key, $result);
  55. }
  56. }
  57. ds_json_encode(10000, '', $result);
  58. }
  59. }