本地生活添加商品
This commit is contained in:
parent
a5d75d1ed0
commit
746c751c9d
@ -269,6 +269,11 @@ class LocalStore extends Api
|
||||
{
|
||||
$form = $this->request->post();
|
||||
(new LocalStoreGoodsValidate())->goCheck();
|
||||
LocalStoreLogic::addGoods($form, $this->user_id);
|
||||
$result = LocalStoreLogic::addGoods($form, $this->user_id);
|
||||
if ($result === false) {
|
||||
$error = LocalStoreLogic::getError() ?: '提交失败';
|
||||
return JsonServer::error($error);
|
||||
}
|
||||
return JsonServer::success('提交成功', [], 1, 1);
|
||||
}
|
||||
}
|
||||
@ -127,18 +127,25 @@ class LocalStoreLogic extends Logic
|
||||
|
||||
public static function addGoods($form, $user_id)
|
||||
{
|
||||
$form['user_id'] = $user_id;
|
||||
$form['create_time'] = time();
|
||||
$pic = $form['url'];
|
||||
unset($form['url']);
|
||||
$id = LocalStoreGoods::insertGetId($form);
|
||||
try {
|
||||
$form['user_id'] = $user_id;
|
||||
$form['create_time'] = time();
|
||||
$pic = $form['url'];
|
||||
unset($form['url']);
|
||||
$id = LocalStoreGoods::insertGetId($form);
|
||||
|
||||
$arr = [];
|
||||
foreach ($pic as &$v) {
|
||||
$arr[]['lsg_id'] = $id;
|
||||
$arr['url'] = $v;
|
||||
$data = [];
|
||||
foreach ($pic as &$v) {
|
||||
$data[]['lsg_id'] = $id;
|
||||
$data[]['url'] = $v;
|
||||
}
|
||||
|
||||
LocalStoreGoodsPic::insertAll($data);
|
||||
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
self::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
dump($arr);
|
||||
die;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user