添加商品价格修改
This commit is contained in:
parent
87de2eca52
commit
d86673a589
@ -38,6 +38,16 @@ class LocalStoreGoods extends Api
|
||||
return JsonServer::success('提交成功', [], 1, 1);
|
||||
}
|
||||
|
||||
public function editPrice()
|
||||
{
|
||||
$form = $this->request->post();
|
||||
$result = LocalStoreGoodsLogic::editPrice($form, $this->user_id);
|
||||
if ($result === false) {
|
||||
return JsonServer::error('修改失败');
|
||||
}
|
||||
return JsonServer::success('修改成功', [], 1, 1);
|
||||
}
|
||||
|
||||
public function shopDetails()
|
||||
{
|
||||
$get = $this->request->get();
|
||||
|
||||
@ -87,7 +87,7 @@ class LocalStoreGoodsLogic extends Logic
|
||||
'create_time' => time(),
|
||||
]);
|
||||
} else if ($form['type'] === 'edit') {
|
||||
LocalStoreGoods::where(['id' => $form['id']])->update([
|
||||
LocalStoreGoods::where(['id' => $form['id'], 'user_id' => $user_id])->update([
|
||||
'title' => $form['title'],
|
||||
'price' => $form['price'],
|
||||
'desc' => $form['desc'] ?? '',
|
||||
@ -98,22 +98,15 @@ class LocalStoreGoodsLogic extends Logic
|
||||
|
||||
LocalStoreGoodsPic::where(['lsg_id' => $form['id']])->delete();
|
||||
$id = $form['id'];
|
||||
} else if ($form['type'] === 'price') {
|
||||
LocalStoreGoods::where(['id' => $form['id']])->update([
|
||||
'price' => $form['price'],
|
||||
'update_time' => time(),
|
||||
]);
|
||||
}
|
||||
|
||||
if ($form['type'] != 'price') {
|
||||
// 处理图片
|
||||
$data = [];
|
||||
foreach ($form['url'] as $k => &$v) {
|
||||
$data[$k]['lsg_id'] = $id;
|
||||
$data[$k]['url'] = substr($v, $len, strlen($v));
|
||||
}
|
||||
LocalStoreGoodsPic::insertAll($data);
|
||||
// 处理图片
|
||||
$data = [];
|
||||
foreach ($form['url'] as $k => &$v) {
|
||||
$data[$k]['lsg_id'] = $id;
|
||||
$data[$k]['url'] = substr($v, $len, strlen($v));
|
||||
}
|
||||
LocalStoreGoodsPic::insertAll($data);
|
||||
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
@ -122,6 +115,15 @@ class LocalStoreGoodsLogic extends Logic
|
||||
}
|
||||
}
|
||||
|
||||
public static function editPrice($form, $user_id)
|
||||
{
|
||||
LocalStoreGoods::where(['id' => $form['id'], 'user_id' => $user_id])->update([
|
||||
'price' => $form['price'],
|
||||
'update_time' => time(),
|
||||
]);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function editGoods($form, $user_id)
|
||||
{
|
||||
try {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user