|
|
@@ -96,6 +96,7 @@ class StoreProduct extends AuthController
|
|
|
'add_time' => time(),
|
|
|
]);
|
|
|
if ($res) {
|
|
|
+ event('StoreProductOnOffShelf', ['is_show'=>$is_show, 'ids'=>[$id],]);
|
|
|
return Json::successful($is_show == 1 ? '上架成功' : '下架成功');
|
|
|
} else {
|
|
|
return Json::fail($is_show == 1 ? '上架失败' : '下架失败');
|
|
|
@@ -110,10 +111,12 @@ class StoreProduct extends AuthController
|
|
|
public function set_product($field = '', $id = '', $value = '')
|
|
|
{
|
|
|
$field == '' || $id == '' || $value == '' && Json::fail('缺少参数');
|
|
|
- if (ProductModel::where(['id' => $id])->update([$field => $value]))
|
|
|
+ if (ProductModel::where(['id' => $id])->update([$field => $value])) {
|
|
|
+ event('StoreEditProduct', ['productId' => $id]);
|
|
|
return Json::successful('保存成功');
|
|
|
- else
|
|
|
+ } else {
|
|
|
return Json::fail('保存失败');
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -133,10 +136,12 @@ class StoreProduct extends AuthController
|
|
|
'is_show' => 1,
|
|
|
'add_time' => time(),
|
|
|
]);
|
|
|
- if ($res)
|
|
|
+ if ($res) {
|
|
|
+ event('StoreProductOnOffShelf', ['is_show'=>1, 'ids'=>$post['ids'],]);
|
|
|
return Json::successful('上架成功');
|
|
|
- else
|
|
|
+ } else {
|
|
|
return Json::fail('上架失败');
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -365,6 +370,7 @@ class StoreProduct extends AuthController
|
|
|
$attr_res = StoreProductAttr::createProductAttr($attr, $detail, $id);
|
|
|
if ($attr_res) {
|
|
|
ProductModel::commitTrans();
|
|
|
+ event('StoreEditProduct', ['productId'=>$id,]);
|
|
|
return Json::success('修改成功!');
|
|
|
} else {
|
|
|
ProductModel::rollbackTrans();
|
|
|
@@ -406,6 +412,7 @@ class StoreProduct extends AuthController
|
|
|
if ($attr_res) {
|
|
|
ProductModel::commitTrans();
|
|
|
event('AdminAddStoreProduct', ['product'=>$res, 'admin'=>$this->adminInfo]);
|
|
|
+ event('StoreProductCreated', ['product'=>$res,]);
|
|
|
return Json::success('添加产品成功!');
|
|
|
} else {
|
|
|
ProductModel::rollbackTrans();
|
|
|
@@ -675,13 +682,15 @@ class StoreProduct extends AuthController
|
|
|
|
|
|
if (!$id) return $this->failed('数据不存在');
|
|
|
if (!ProductModel::be(['id' => $id])) return $this->failed('产品数据不存在');
|
|
|
- if (ProductModel::be(['id' => $id, 'is_del' => 1])) {
|
|
|
+ if (ProductModel::be(['id' => $id, 'is_del' => 1])) { // 恢復
|
|
|
$data['is_del'] = 0;
|
|
|
- if (!ProductModel::edit($data, $id))
|
|
|
+ if (!ProductModel::edit($data, $id)) {
|
|
|
return Json::fail(ProductModel::getErrorInfo('恢复失败,请稍候再试!'));
|
|
|
- else
|
|
|
+ } else {
|
|
|
+ event('StoreProductOnOffShelf', ['is_show'=>1, 'ids'=>[$id],]);
|
|
|
return Json::successful('成功恢复产品!');
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ } else { // 刪除
|
|
|
$res1 = StoreSeckill::where('product_id', $id)->where('is_del', 0)->find();
|
|
|
$res2 = StoreBargain::where('product_id', $id)->where('is_del', 0)->find();
|
|
|
$res3 = StoreCombination::where('product_id', $id)->where('is_del', 0)->find();
|
|
|
@@ -689,10 +698,12 @@ class StoreProduct extends AuthController
|
|
|
return Json::fail(ProductModel::getErrorInfo('该商品已参加活动,无法删除!'));
|
|
|
} else {
|
|
|
$data['is_del'] = 1;
|
|
|
- if (!ProductModel::edit($data, $id))
|
|
|
+ if (!ProductModel::edit($data, $id)) {
|
|
|
return Json::fail(ProductModel::getErrorInfo('删除失败,请稍候再试!'));
|
|
|
- else
|
|
|
+ } else {
|
|
|
+ event('StoreProductOnOffShelf', ['is_show'=>0, 'ids'=>[$id],]);
|
|
|
return Json::successful('成功移到回收站!');
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|