Inviterpro.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace app\api\controller;
  3. use think\facade\Lang;
  4. /**
  5. * ============================================================================
  6. *
  7. * ============================================================================
  8. * 版权所有 2014-2028 浙江惠利玛产业互联网有限公司,并保留所有权利。
  9. * 网站地址: https://www.valimart.net/
  10. * ----------------------------------------------------------------------------
  11. *
  12. * ============================================================================
  13. * 分销商品控制器
  14. */
  15. class Inviterpro extends MobileMall {
  16. public function initialize() {
  17. parent::initialize();
  18. }
  19. /*
  20. * 获取分销商品列表
  21. */
  22. public function index() {
  23. if (!config('ds_config.inviter_open')) {
  24. $result = array_merge(array('goods_list' => array(),), mobile_page(''));
  25. } else {
  26. $goods_model = model('goods');
  27. $condition = array();
  28. $condition[] = array('inviter_open', '=', 1);
  29. if (input('param.keyword')) {
  30. $condition[] = array('goods_name', 'like', '%' . input('param.keyword') . '%');
  31. }
  32. if (input('param.gc_id')) {
  33. $condition[] = array('gc_id_1', '=', intval(input('param.gc_id')));
  34. }
  35. $cache_key = 'api-inviterpro' . md5(serialize($condition)) . '-' . intval(input('param.page'));
  36. $result = rcache($cache_key);
  37. if (empty($result)) {
  38. $goods_list = $goods_model->getGoodsCommonList($condition, '*', 10);
  39. foreach ($goods_list as $key => $goods) {
  40. $goods_info = $goods_model->getGoodsInfo(array('goods_commonid' => $goods['goods_commonid']), 'goods_id');
  41. $goods_list[$key]['goods_id'] = $goods_info['goods_id'];
  42. $goods_list[$key]['goods_image_url'] = goods_cthumb($goods['goods_image'], 240);
  43. $goods_list[$key]['inviter_amount'] = 0;
  44. if (config('ds_config.inviter_show')) {
  45. $inviter_amount = round($goods['inviter_ratio'] / 100 * $goods['goods_price'] * floatval(config('ds_config.inviter_ratio_1')) / 100, 2);
  46. if ($inviter_amount > 0) {
  47. $goods_list[$key]['inviter_amount'] = $inviter_amount;
  48. }
  49. }
  50. }
  51. $page_count = $goods_model->page_info;
  52. $result = array_merge(array('goods_list' => $goods_list,), mobile_page($page_count));
  53. wcache($cache_key, $result);
  54. }
  55. }
  56. ds_json_encode(10000, '', $result);
  57. }
  58. }