You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
120 lines
3.9 KiB
120 lines
3.9 KiB
<?php
|
|
|
|
namespace app\api\controller;
|
|
|
|
use app\Request;
|
|
use app\service\Goods\GoodsService;
|
|
use think\cache\driver\Redis;
|
|
use think\facade\Db;
|
|
|
|
class Goods extends Base
|
|
{
|
|
|
|
protected $noNeedCheck = ['getApiGoods'];
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->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(env('APP.HOST').'/index.php/api/goods/getTypeGoods', $params);
|
|
return $result;
|
|
}catch(\Exception $e){
|
|
return _error($e->getMessage(), $e->getCode() ?: 400, $e);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* @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 被请求委托查询 接口
|
|
$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);
|
|
return _success('成功', $result);
|
|
}catch(\Exception $e){
|
|
return _error($e->getMessage(), $e->getCode() ?: 400, $e);
|
|
}
|
|
}
|
|
/**
|
|
* 排行榜统计
|
|
* @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();
|
|
}
|
|
|
|
}
|