新增用户是否同意折扣
This commit is contained in:
parent
f641935623
commit
4409f59c7b
@ -513,24 +513,21 @@ class Community extends BaseController
|
||||
*/
|
||||
public function deleteResale($id)
|
||||
{
|
||||
$communityInfo = Db::name('community')->where('uid', $this->request->uid())->where('community_id', $id)->find();
|
||||
$communityInfo = Db::name('community')->where('uid', $this->request->uid())->where('community_id', $id)->where('is_del', 0)->find();
|
||||
if (!$communityInfo) {
|
||||
app('json')->fail('转售商品不存在');
|
||||
}
|
||||
// 启动事务
|
||||
Db::startTrans();
|
||||
try {
|
||||
Db::name('community')->where('uid', $this->request->uid())->where('community_id', $id)->update(['is_del' => 1]);
|
||||
Db::name('resale')->where('community_id', $id)->update(['is_del' => 1]);
|
||||
try {
|
||||
$list = Db::name('resale')->where('community_id', $id)->where('is_del', 0)->where('status', 0)->select();
|
||||
foreach($list as $prod) {
|
||||
Db::name('store_product')->where('product_id', $prod['product_id'])->inc('stock', $prod['number'])->update();
|
||||
Db::name('store_product_attr_value')->where('product_id', $prod['product_id'])->where('unique', $prod['product_attr_unique'])->inc('stock', $prod['number'])->update();
|
||||
}
|
||||
// 提交事务
|
||||
Db::name('resale')->where('community_id', $id)->where('status', 0)->update(['is_del' => 1]);
|
||||
Db::name('community')->where('uid', $this->request->uid())->where('community_id', $id)->update(['is_del' => 1]);
|
||||
Db::commit();
|
||||
} catch (\Exception $e) {
|
||||
// 回滚事务
|
||||
Db::rollback();
|
||||
return app('json')->fail('删除转售商品失败');
|
||||
}
|
||||
@ -543,10 +540,37 @@ class Community extends BaseController
|
||||
*/
|
||||
public function checkResale($id)
|
||||
{
|
||||
$communityInfo = Db::name('community')->where('uid', $this->request->uid())->where('community_id', $id)->find();
|
||||
$communityInfo = Db::name('community')->where('uid', $this->request->uid())->where('community_id', $id)->where('is_del', 0)->find();
|
||||
if (!$communityInfo) {
|
||||
app('json')->fail('转售商品不存在');
|
||||
}
|
||||
$status = $this->request->param('status');
|
||||
if (!$status) {
|
||||
app('json')->fail('请设置审核状态');
|
||||
}
|
||||
if ($status == 1) {
|
||||
$res = Db::name('community')->where('uid', $this->request->uid())->where('community_id', $id)->where('is_del', 0)->update(['status' => $status]);
|
||||
if (!$res) {
|
||||
return app('json')->fail('审核操作失败');
|
||||
}
|
||||
}
|
||||
if ($status == 2) {
|
||||
Db::startTrans();
|
||||
try {
|
||||
$list = Db::name('resale')->where('community_id', $id)->where('is_del', 0)->where('status', 0)->select();
|
||||
foreach($list as $prod) {
|
||||
Db::name('store_product')->where('product_id', $prod['product_id'])->inc('stock', $prod['number'])->update();
|
||||
Db::name('store_product_attr_value')->where('product_id', $prod['product_id'])->where('unique', $prod['product_attr_unique'])->inc('stock', $prod['number'])->update();
|
||||
}
|
||||
Db::name('resale')->where('community_id', $id)->where('status', 0)->update(['is_del' => 1]);
|
||||
Db::name('community')->where('uid', $this->request->uid())->where('community_id', $id)->where('is_del', 0)->update(['is_del' => 1, 'status' => $status]);
|
||||
Db::commit();
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
return app('json')->fail('审核转售商品折扣价失败');
|
||||
}
|
||||
}
|
||||
return app('json')->fail('审核操作成功');
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user