1
This commit is contained in:
parent
f0eb37fe1b
commit
a3880e9767
@ -71,14 +71,14 @@ class CommonGoodsActionForm extends Model
|
||||
} else {
|
||||
$t = \Yii::$app->db->beginTransaction();
|
||||
$model = Goods::findOne([
|
||||
'plugin_sign' => $this->plugin_sign,
|
||||
// 'plugin_sign' => $this->plugin_sign,
|
||||
'id' => $this->goods_id,
|
||||
'is_delete' => 0,
|
||||
'status' => Goods::STATUS_OFFLINE,
|
||||
'cx_mch_id' => $this->cx_mch_id
|
||||
// 'cx_mch_id' => $this->cx_mch_id
|
||||
]);
|
||||
if ($model == null) {
|
||||
return $this->apiReturnError('商品不存在或已经删除');
|
||||
return $this->apiReturnError('冠军不存在或已经删除');
|
||||
}
|
||||
$model->is_delete = 1;
|
||||
//删除之后
|
||||
@ -110,7 +110,7 @@ class CommonGoodsActionForm extends Model
|
||||
if ($model == null)
|
||||
continue;
|
||||
$model->status = Goods::STATUS_ONLINE;
|
||||
//检查商品库存是否充足
|
||||
//检查冠军库存是否充足
|
||||
// $res = $this->checkGoodsStock($model->id, $model->cx_mch_id);
|
||||
// if ($res['code'] != 0) {
|
||||
// $t->rollBack();
|
||||
@ -132,10 +132,10 @@ class CommonGoodsActionForm extends Model
|
||||
'cx_mch_id' => $this->cx_mch_id
|
||||
]);
|
||||
if ($model == null) {
|
||||
return $this->apiReturnError('商品不存在或已经上架');
|
||||
return $this->apiReturnError('冠军不存在或已经上架');
|
||||
}
|
||||
$model->status = Goods::STATUS_ONLINE;
|
||||
//检查商品库存是否充足
|
||||
//检查冠军库存是否充足
|
||||
// $res = $this->checkGoodsStock($model->id, $model->cx_mch_id);
|
||||
// if ($res['code'] != 0) {
|
||||
// $t->rollBack();
|
||||
@ -184,7 +184,7 @@ class CommonGoodsActionForm extends Model
|
||||
'cx_mch_id' => $this->cx_mch_id
|
||||
]);
|
||||
if ($model == null) {
|
||||
return $this->apiReturnError('商品不存在或已经下架');
|
||||
return $this->apiReturnError('冠军不存在或已经下架');
|
||||
}
|
||||
$model->status = Goods::STATUS_OFFLINE;
|
||||
if (!$model->save()) {
|
||||
@ -196,11 +196,11 @@ class CommonGoodsActionForm extends Model
|
||||
return $this->apiReturnSuccess("操作成功");
|
||||
}
|
||||
|
||||
//商品删除之后处理其他
|
||||
//冠军删除之后处理其他
|
||||
private function doDeleteAfter($goods_id, $plugin_sign, $cx_mch_id)
|
||||
{
|
||||
if ($plugin_sign == SysConst::$cxPluginSceneIntegralMall) {
|
||||
//积分商品
|
||||
//积分冠军
|
||||
IntegralMallGoods::updateAll(['is_delete' => 1], [
|
||||
'is_delete' => 0,
|
||||
'goods_id' => $goods_id,
|
||||
@ -209,16 +209,16 @@ class CommonGoodsActionForm extends Model
|
||||
}
|
||||
}
|
||||
|
||||
//检查商品库存是否充足
|
||||
//检查冠军库存是否充足
|
||||
private function checkGoodsStock($goods_id, $cx_mch_id)
|
||||
{
|
||||
$goods = Goods::findOne(['id' => $goods_id, 'is_delete' => 0, 'cx_mch_id' => $cx_mch_id]);
|
||||
if ($goods == null) {
|
||||
return $this->apiReturnError('商品不存在或已经删除');
|
||||
return $this->apiReturnError('冠军不存在或已经删除');
|
||||
}
|
||||
if ($goods->use_attr != 1) {
|
||||
if ($goods->goods_stock == 0) {
|
||||
return $this->apiReturnError('商品库存不足');
|
||||
return $this->apiReturnError('冠军库存不足');
|
||||
}
|
||||
} else {
|
||||
$stock = GoodsAttr::find()
|
||||
@ -229,7 +229,7 @@ class CommonGoodsActionForm extends Model
|
||||
])
|
||||
->sum('stock');
|
||||
if ($stock == 0) {
|
||||
return $this->apiReturnError('商品库存不足');
|
||||
return $this->apiReturnError('冠军库存不足');
|
||||
}
|
||||
}
|
||||
return $this->apiReturnSuccess();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user