valid = \app\api\validate\Goods::class; } /** * @title 获取购物车 * @url /api/Goods/getShoppingCar * @method POST * @param string user_isli 用户isli标识码 * @return string msg 返回信息 * @return int code 状态码 200:成功;>=400:失败 */ public function getShoppingCar(){ try { // todo 被请求获取购物车 接口 $this->checkVaild($this->valid, 'getShoppingCar', 'post'); $user_isli = $this->request->post('user_isli'); $goodsService = new GoodsService(); $this->apilog->info("获取购物车", Request()->param()); $result = $goodsService->getShoppingCar($user_isli); return _success('成功', $result); }catch(\Exception $e){ return _error($e->getMessage(), $e->getCode() ?: 400, $e); } } /** * @title 根据类型获取委托信息 * @url /api/Goods/getTypeGoods * @method POST * @param string type 类型;1:点击;2:销售;3:推荐 * @param string hot 热门展示 * @param string hotsale 热卖展示 * @return string msg 返回信息 * @return int code 状态码 200:成功;>=400:失败 */ public function getTypeGoods(){ try { $params = ['type'=> 1]; $result = $this->curl_request_post('http://www.wenhuayun.com/index.php/api/goods/getTypeGoods', $params); return $result; }catch(\Exception $e){ echo json_encode(['code'=> 'failure', $e, 'msg'=> '请求失败']); exit(); } } /** * @title 查询委托信息 * @url /api/Goods/searchGoods * @method POST * @param string entrust_time 委托时间(时间戳) * @param string record_type 数据类型 * @param string entrust_user_name 委托方名称 * @param string authorization 授权方式 * @param string pay_type 付费类型 * @param string entrust_name 委托数据名称 * @param string entrust_islicode 委托数据isli标识码 * @param string goods_islicode 商品isli标识码 * @return string msg 返回信息 * @return int code 状态码 200:成功;>=400:失败 */ public function searchGoods(){ try { // todo 被请求委托查询 接口 $start_time = microtime(true); //响应式开始计时 $this->checkVaild($this->valid, 'searchGoods', 'post'); $post = $this->request->post(['entrust_time', 'record_type', 'entrust_user_name', 'authorization', 'pay_type', 'entrust_name', 'entrust_islicode', 'goods_islicode', 'source_type', 'order_type', 'order', 'goods_status', 'page', 'limit']); $goodsService = new GoodsService(); $this->apilog->info("查询委托信息接口", $post); $result = $goodsService->searchGoods($post); $end_time = microtime(true); //响应式结束计时 $userTime = $end_time-$start_time.'s'; echo json_encode(['code'=>'success', 'msg'=>'成功', 'useTime'=>$userTime, 'data'=>$result]); exit(); }catch(\Exception $e){ echo json_encode(['code'=>'failure', 'msg'=>'请求失败']); exit(); } } /** * 排行榜统计 * @url /api/Goods/incrRanking * @method POST */ public function incrRanking() { $params = $this->request->post('id'); if (empty($params['id'])){ return _error('params error'); } try { $goods = \app\model\Goods::find($params['id']); $goods->recommend_sort = $goods['recommend_sort']+1; $goods->save(); return _success('成功'); }catch (\Exception $e){ return _error('失败'); } } public function test(){ $goodsService = new GoodsService(); $goodsService->test(); } }