70 lines
1.9 KiB
PHP
70 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace app\api\logic;
|
|
|
|
use app\common\basics\Logic;
|
|
use app\common\model\localstore\LocalStoreGoods;
|
|
use app\common\model\localstore\LocalStoreGoodsPic;
|
|
|
|
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 {
|
|
$form['user_id'] = $user_id;
|
|
$form['create_time'] = time();
|
|
$form['state'] = 1;
|
|
|
|
$pic = $form['url'];
|
|
unset($form['url']);
|
|
$id = LocalStoreGoods::insertGetId($form);
|
|
|
|
$data = [];
|
|
foreach ($pic as $k => &$v) {
|
|
$data[$k]['lsg_id'] = $id;
|
|
$data[$k]['url'] = basename($v);
|
|
}
|
|
|
|
LocalStoreGoodsPic::insertAll($data);
|
|
|
|
return true;
|
|
} catch (\Exception $e) {
|
|
self::$error = $e->getMessage();
|
|
return false;
|
|
}
|
|
}
|
|
} |