123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?php
- namespace app\api\controller;
- use think\facade\Lang;
- /**
-
- *
-
- *
- * ----------------------------------------------------------------------------
- *
-
- * 分销商品控制器
- */
- class Inviterpro extends MobileMall
- {
- public function initialize()
- {
- parent::initialize();
- }
- /*
- * 获取分销商品列表
- */
- public function index()
- {
- if (!config('ds_config.inviter_open')) {
- $result = array_merge(array('goods_list' => array(),), mobile_page(''));
- } else {
- $goods_model = model('goods');
- $condition = array();
- $condition[] = array('inviter_open', '=', 1);
- if (input('param.keyword')) {
- $condition[] = array('goods_name', 'like', '%' . input('param.keyword') . '%');
- }
- if (input('param.gc_id')) {
- $condition[] = array('gc_id_1', '=', intval(input('param.gc_id')));
- }
- $cache_key = 'api-inviterpro' . md5(serialize($condition)) . '-' . intval(input('param.page'));
- $result = rcache($cache_key);
- if (empty($result)) {
- $goods_list = $goods_model->getGoodsCommonList($condition, '*', 10);
- foreach ($goods_list as $key => $goods) {
- $goods_info = $goods_model->getGoodsInfo(array('goods_commonid' => $goods['goods_commonid']), 'goods_id');
- $goods_list[$key]['goods_id'] = $goods_info['goods_id'];
- $goods_list[$key]['goods_image_url'] = goods_cthumb($goods['goods_image'], 240);
- $goods_list[$key]['inviter_amount'] = 0;
- if (config('ds_config.inviter_show')) {
- $inviter_amount = round($goods['inviter_ratio'] / 100 * $goods['goods_price'] * floatval(config('ds_config.inviter_ratio_1')) / 100, 2);
- if ($inviter_amount > 0) {
- $goods_list[$key]['inviter_amount'] = $inviter_amount;
- }
- }
- }
- $page_count = $goods_model->page_info;
- $result = array_merge(array('goods_list' => $goods_list,), mobile_page($page_count));
- wcache($cache_key, $result);
- }
- }
- ds_json_encode(10000, '', $result);
- }
- }
|