where($condition) ->where('(2 * 6378.137* ASIN(SQRT(POW(SIN(PI()*(' . $lat . '-chain_latitude)/360),2)+COS(PI()*' . $lat . '/180)* COS(chain_latitude * PI()/180)*POW(SIN(PI()*(' . $lng . '-chain_longitude)/360),2)))) < 100000') ->fieldRaw('chain_id,store_id,chain_addressname,chain_area_info,chain_address,(2 * 6378.137* ASIN(SQRT(POW(SIN(PI()*(' . $lat . '-chain_latitude)/360),2)+COS(PI()*' . $lat . '/180)* COS(chain_latitude * PI()/180)*POW(SIN(PI()*(' . $lng . '-chain_longitude)/360),2)))) as distance') ->order($order) ->paginate(['list_rows' => $this->pagesize, 'query' => request()->param()], false); $chain = $chain_object->items(); $store_model = model('store'); $goods_model = model('goods'); foreach ($chain as $key => $value) { $store_info = $store_model->getStoreInfoByID($value['store_id']); $chain[$key]['distance'] = round($value['distance'], 2); $chain[$key]['chain_avatar'] = get_store_logo($store_info['store_avatar'], 'store_avatar'); $condition = array(); $condition[] = array('chain_id', '=', $value['chain_id']); $condition[] = array('goods_storage', '>', 0); $chain_goods_commonid = Db::name('chain_goods')->where($condition)->column('goods_commonid'); if (!empty($chain_goods_commonid)) { $chain[$key]['goods_list'] = $goods_model->getGoodsListByColorDistinct(array(array('store_id', '=', $value['store_id']), array('goods_commend', '=', 1), array('goods_commonid', 'in', $chain_goods_commonid)), 'goods_image,goods_id,goods_price', 'goods_id desc', 0, 4); foreach ($chain[$key]['goods_list'] as $k => $v) { $chain[$key]['goods_list'][$k]['goods_image_url'] = goods_cthumb($v['goods_image'], 480, $value['chain_id']); } } else { $chain[$key]['goods_list'] = array(); } } $result = array_merge(array('chain_list' => $chain), mobile_page($chain_object)); ds_json_encode(10000, '', $result); } }