edit修改保存商品接口

This commit is contained in:
admin 2024-03-01 16:45:27 +08:00
parent 7184da31f2
commit b3a893cd89
3 changed files with 11 additions and 13 deletions

View File

@ -52,7 +52,7 @@ class GoodsAttr extends \yii\db\ActiveRecord
return [
'id' => 'ID',
'cx_mch_id' => '平台商户ID',
'goods_id' => '商品ID',
'goods_idgoods_id' => '商品ID',
'sign_id' => '规格ID标识规格规格值',
'stock' => '库存',
'price' => '价格',

View File

@ -149,11 +149,6 @@ class CommonGoodsEditForm extends Model
//保存商品基础信息
$res1 = $this->saveGoodsCat();
$res2 = $this->saveGoodsAttr();
if ($res2['code'] != 0) {
$t->rollBack();
return $res2;
}
if ($res['code'] != 0) {
$t->rollBack();
@ -163,12 +158,15 @@ class CommonGoodsEditForm extends Model
return $res1;
}
if (!$this->model->save()) {
$t->rollBack();
return $this->getModelError($this->model);
}
$res2 = $this->saveGoodsAttr();
if ($res2['code'] != 0) {
$t->rollBack();
return $res2;
}
$t->commit();
return $this->apiReturnSuccess('保存成功');
}

View File

@ -150,7 +150,7 @@ class GoodsController extends Controller
'is_delete' => 0,
'type' => Cat::TYPE_GOODS,
])
->orderBy(['sort' => SORT_ASC, 'created_at' => SORT_DESC])
->orderBy(['sort' => SORT_ASC, 'id' => SORT_DESC])
->select('id,name')->asArray()->all();
$cat_list1 = Cat1::find()
@ -159,7 +159,7 @@ class GoodsController extends Controller
'is_delete' => 0,
'type' => Cat::TYPE_GOODS,
])
->orderBy(['sort' => SORT_ASC, 'created_at' => SORT_DESC])
->orderBy(['sort' => SORT_ASC, 'id' => SORT_DESC])
->select('id,name')->asArray()->all();
$cat_list2 = Cat2::find()
@ -168,7 +168,7 @@ class GoodsController extends Controller
'is_delete' => 0,
'type' => Cat::TYPE_GOODS,
])
->orderBy(['sort' => SORT_ASC, 'created_at' => SORT_DESC])
->orderBy(['sort' => SORT_ASC, 'id' => SORT_DESC])
->select('id,name')->asArray()->all();
$cat_list3 = Cat3::find()
@ -177,7 +177,7 @@ class GoodsController extends Controller
'is_delete' => 0,
'type' => Cat::TYPE_GOODS,
])
->orderBy(['sort' => SORT_ASC, 'created_at' => SORT_DESC])
->orderBy(['sort' => SORT_ASC, 'id' => SORT_DESC])
->select('id,name')->asArray()->all();
$cat_list4 = Cat4::find()
@ -186,7 +186,7 @@ class GoodsController extends Controller
'is_delete' => 0,
'type' => Cat::TYPE_GOODS,
])
->orderBy(['sort' => SORT_ASC, 'created_at' => SORT_DESC])
->orderBy(['sort' => SORT_ASC, 'id' => SORT_DESC])
->select('id,name')->asArray()->all();