获取本地生活商品列表
This commit is contained in:
parent
fd054c4393
commit
85babeb3d7
@ -9,6 +9,16 @@ use app\common\server\JsonServer;
|
||||
|
||||
class LocalStoreGoods extends Api
|
||||
{
|
||||
public function lists()
|
||||
{
|
||||
$get = $this->request->get();
|
||||
$get['page_no'] = $get['page_no'] ?? $this->page_no;
|
||||
$get['page_size'] = $get['page_size'] ?? $this->page_size;
|
||||
$get['type'] = $get['type'] ?? 1;
|
||||
$get['user_id'] = $this->user_id;
|
||||
$result = LocalStoreGoodsLogic::lists($get);
|
||||
}
|
||||
|
||||
// 商家添加商品
|
||||
public function addGoods()
|
||||
{
|
||||
|
||||
@ -3,13 +3,45 @@
|
||||
namespace app\api\logic;
|
||||
|
||||
use app\common\basics\Logic;
|
||||
use app\common\model\LocalStore;
|
||||
use app\common\model\localstore\LocalStoreGoods;
|
||||
use app\common\model\localstore\LocalStoreGoodsPic;
|
||||
use think\facade\Db;
|
||||
|
||||
class LocalStoreGoodsLogic extends Logic
|
||||
{
|
||||
private static $SHELVES = 1; // 上架中
|
||||
|
||||
public static function lists($get)
|
||||
{
|
||||
$list = LocalStoreGoods::with('pic')
|
||||
->where([
|
||||
'user_id' => $get['user_id'],
|
||||
'lstore_id' => $get['lstore_id'],
|
||||
'state' => $get['type'],
|
||||
'delete_time' => 0,
|
||||
])
|
||||
->order('id', 'desc')
|
||||
->page($get['page_no'], $get['page_size'])
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
$count = LocalStoreGoods::where([
|
||||
'user_id' => $get['user_id'],
|
||||
'lstore_id' => $get['lstore_id'],
|
||||
'state' => $get['lstore_id'],
|
||||
'delete_time' => 0,
|
||||
])->count();
|
||||
|
||||
$result = [
|
||||
'count' => $count,
|
||||
'lists' => $list,
|
||||
'more' => is_more($count, $get['page_no'], $get['page_size']),
|
||||
'page_no' => $get['page_no'],
|
||||
'page_size' => $get['page_size']
|
||||
];
|
||||
dump($result);die;
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function addGoods($form, $user_id)
|
||||
{
|
||||
try {
|
||||
|
||||
@ -2,9 +2,15 @@
|
||||
|
||||
namespace app\common\model\localstore;
|
||||
|
||||
use app\api\logic\LocalStoreGoodsLogic;
|
||||
use app\common\basics\Models;
|
||||
|
||||
class LocalStoreGoods extends Models
|
||||
{
|
||||
protected $table = 'ls_local_store_goods';
|
||||
|
||||
public function pic()
|
||||
{
|
||||
$this->hasMany(LocalStoreGoodsLogic::class, 'lsg_id');
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user