edit修改保存商品接口
This commit is contained in:
parent
7184da31f2
commit
b3a893cd89
@ -52,7 +52,7 @@ class GoodsAttr extends \yii\db\ActiveRecord
|
|||||||
return [
|
return [
|
||||||
'id' => 'ID',
|
'id' => 'ID',
|
||||||
'cx_mch_id' => '平台商户ID',
|
'cx_mch_id' => '平台商户ID',
|
||||||
'goods_id' => '商品ID',
|
'goods_idgoods_id' => '商品ID',
|
||||||
'sign_id' => '规格ID标识,规格:规格值',
|
'sign_id' => '规格ID标识,规格:规格值',
|
||||||
'stock' => '库存',
|
'stock' => '库存',
|
||||||
'price' => '价格',
|
'price' => '价格',
|
||||||
|
|||||||
@ -149,11 +149,6 @@ class CommonGoodsEditForm extends Model
|
|||||||
|
|
||||||
//保存商品基础信息
|
//保存商品基础信息
|
||||||
$res1 = $this->saveGoodsCat();
|
$res1 = $this->saveGoodsCat();
|
||||||
$res2 = $this->saveGoodsAttr();
|
|
||||||
if ($res2['code'] != 0) {
|
|
||||||
$t->rollBack();
|
|
||||||
return $res2;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($res['code'] != 0) {
|
if ($res['code'] != 0) {
|
||||||
$t->rollBack();
|
$t->rollBack();
|
||||||
@ -163,12 +158,15 @@ class CommonGoodsEditForm extends Model
|
|||||||
return $res1;
|
return $res1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!$this->model->save()) {
|
if (!$this->model->save()) {
|
||||||
$t->rollBack();
|
$t->rollBack();
|
||||||
return $this->getModelError($this->model);
|
return $this->getModelError($this->model);
|
||||||
}
|
}
|
||||||
|
$res2 = $this->saveGoodsAttr();
|
||||||
|
if ($res2['code'] != 0) {
|
||||||
|
$t->rollBack();
|
||||||
|
return $res2;
|
||||||
|
}
|
||||||
$t->commit();
|
$t->commit();
|
||||||
return $this->apiReturnSuccess('保存成功');
|
return $this->apiReturnSuccess('保存成功');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -150,7 +150,7 @@ class GoodsController extends Controller
|
|||||||
'is_delete' => 0,
|
'is_delete' => 0,
|
||||||
'type' => Cat::TYPE_GOODS,
|
'type' => Cat::TYPE_GOODS,
|
||||||
])
|
])
|
||||||
->orderBy(['sort' => SORT_ASC, 'created_at' => SORT_DESC])
|
->orderBy(['sort' => SORT_ASC, 'id' => SORT_DESC])
|
||||||
->select('id,name')->asArray()->all();
|
->select('id,name')->asArray()->all();
|
||||||
|
|
||||||
$cat_list1 = Cat1::find()
|
$cat_list1 = Cat1::find()
|
||||||
@ -159,7 +159,7 @@ class GoodsController extends Controller
|
|||||||
'is_delete' => 0,
|
'is_delete' => 0,
|
||||||
'type' => Cat::TYPE_GOODS,
|
'type' => Cat::TYPE_GOODS,
|
||||||
])
|
])
|
||||||
->orderBy(['sort' => SORT_ASC, 'created_at' => SORT_DESC])
|
->orderBy(['sort' => SORT_ASC, 'id' => SORT_DESC])
|
||||||
->select('id,name')->asArray()->all();
|
->select('id,name')->asArray()->all();
|
||||||
|
|
||||||
$cat_list2 = Cat2::find()
|
$cat_list2 = Cat2::find()
|
||||||
@ -168,7 +168,7 @@ class GoodsController extends Controller
|
|||||||
'is_delete' => 0,
|
'is_delete' => 0,
|
||||||
'type' => Cat::TYPE_GOODS,
|
'type' => Cat::TYPE_GOODS,
|
||||||
])
|
])
|
||||||
->orderBy(['sort' => SORT_ASC, 'created_at' => SORT_DESC])
|
->orderBy(['sort' => SORT_ASC, 'id' => SORT_DESC])
|
||||||
->select('id,name')->asArray()->all();
|
->select('id,name')->asArray()->all();
|
||||||
|
|
||||||
$cat_list3 = Cat3::find()
|
$cat_list3 = Cat3::find()
|
||||||
@ -177,7 +177,7 @@ class GoodsController extends Controller
|
|||||||
'is_delete' => 0,
|
'is_delete' => 0,
|
||||||
'type' => Cat::TYPE_GOODS,
|
'type' => Cat::TYPE_GOODS,
|
||||||
])
|
])
|
||||||
->orderBy(['sort' => SORT_ASC, 'created_at' => SORT_DESC])
|
->orderBy(['sort' => SORT_ASC, 'id' => SORT_DESC])
|
||||||
->select('id,name')->asArray()->all();
|
->select('id,name')->asArray()->all();
|
||||||
|
|
||||||
$cat_list4 = Cat4::find()
|
$cat_list4 = Cat4::find()
|
||||||
@ -186,7 +186,7 @@ class GoodsController extends Controller
|
|||||||
'is_delete' => 0,
|
'is_delete' => 0,
|
||||||
'type' => Cat::TYPE_GOODS,
|
'type' => Cat::TYPE_GOODS,
|
||||||
])
|
])
|
||||||
->orderBy(['sort' => SORT_ASC, 'created_at' => SORT_DESC])
|
->orderBy(['sort' => SORT_ASC, 'id' => SORT_DESC])
|
||||||
->select('id,name')->asArray()->all();
|
->select('id,name')->asArray()->all();
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user