自增/自减操作更新

This commit is contained in:
Devil 2021-07-21 16:35:38 +08:00
parent 83d0a98b6a
commit 18372d65d9
10 changed files with 17 additions and 17 deletions

View File

@ -441,7 +441,7 @@ class AnswerService
{
if(!empty($params['answer_id']))
{
return Db::name('Answer')->where(['id'=>intval($params['answer_id'])])->inc('access_count');
return Db::name('Answer')->where(['id'=>intval($params['answer_id'])])->inc('access_count')->update();
}
return false;
}

View File

@ -262,7 +262,7 @@ class ArticleService
{
if(!empty($params['id']))
{
return Db::name('Article')->where(array('id'=>intval($params['id'])))->inc('access_count');
return Db::name('Article')->where(array('id'=>intval($params['id'])))->inc('access_count')->update();
}
return false;
}

View File

@ -1803,7 +1803,7 @@ class BuyService
}
// 扣除操作
if(!Db::name('Goods')->where(['id'=>$v['goods_id']])->dec('inventory', $v['buy_number']))
if(!Db::name('Goods')->where(['id'=>$v['goods_id']])->dec('inventory', $v['buy_number'])->update())
{
return DataReturn('商品库存扣减失败['.$params['order_id'].'-'.$v['id'].'-'.$v['goods_id'].'('.$goods['inventory'].'-'.$v['buy_number'].')]', -10);
}
@ -1820,7 +1820,7 @@ class BuyService
}
// 扣除规格操作
if(!Db::name('GoodsSpecBase')->where(['id'=>$base['data']['spec_base']['id'], 'goods_id'=>$v['goods_id']])->dec('inventory', $v['buy_number']))
if(!Db::name('GoodsSpecBase')->where(['id'=>$base['data']['spec_base']['id'], 'goods_id'=>$v['goods_id']])->dec('inventory', $v['buy_number'])->update())
{
return DataReturn('规格库存扣减失败['.$params['order_id'].'-'.$v['goods_id'].'('.$goods['inventory'].'-'.$v['buy_number'].')]', -10);
}
@ -1923,7 +1923,7 @@ class BuyService
$buy_number = ($appoint_buy_number == 0) ? $v['buy_number'] : $appoint_buy_number;
// 回滚操作
if(!Db::name('Goods')->where(['id'=>$v['goods_id']])->inc('inventory', $buy_number))
if(!Db::name('Goods')->where(['id'=>$v['goods_id']])->inc('inventory', $buy_number)->update())
{
return DataReturn('商品库存回滚失败['.$params['order_id'].'-'.$v['goods_id'].']', -10);
}
@ -1934,7 +1934,7 @@ class BuyService
if($base['code'] == 0)
{
// 回滚规格操作
if(!Db::name('GoodsSpecBase')->where(['id'=>$base['data']['spec_base']['id'], 'goods_id'=>$v['goods_id']])->inc('inventory', $buy_number))
if(!Db::name('GoodsSpecBase')->where(['id'=>$base['data']['spec_base']['id'], 'goods_id'=>$v['goods_id']])->inc('inventory', $buy_number)->update())
{
return DataReturn('规格库存回滚失败['.$params['order_id'].'-'.$v['goods_id'].']', -10);
}

View File

@ -109,7 +109,7 @@ class CustomViewService
{
if(!empty($params['id']))
{
return Db::name('CustomView')->where(array('id'=>intval($params['id'])))->inc('access_count');
return Db::name('CustomView')->where(array('id'=>intval($params['id'])))->inc('access_count')->update();
}
return false;
}

View File

@ -225,7 +225,7 @@ class DesignService
{
if(!empty($params['design_id']))
{
return Db::name('Design')->where(['id'=>intval($params['design_id'])])->inc('access_count');
return Db::name('Design')->where(['id'=>intval($params['design_id'])])->inc('access_count')->update();
}
return false;
}

View File

@ -936,7 +936,7 @@ class GoodsService
{
if(!empty($params['goods_id']))
{
return Db::name('Goods')->where(['id'=>intval($params['goods_id'])])->inc('access_count');
return Db::name('Goods')->where(['id'=>intval($params['goods_id'])])->inc('access_count')->update();
}
return false;
}

View File

@ -229,7 +229,7 @@ class IntegralService
{
// 用户积分添加
$user_integral = Db::name('User')->where(['id'=>$user['id']])->value('integral');
if(!Db::name('User')->where(['id'=>$user['id']])->inc('integral', $give_integral))
if(!Db::name('User')->where(['id'=>$user['id']])->inc('integral', $give_integral)->update())
{
return DataReturn('用户积分赠送失败['.$params['order_id'].'-'.$goods_id.']', -10);
}
@ -316,7 +316,7 @@ class IntegralService
if($refund_integral >= 1)
{
// 用户积分添加
if(!Db::name('User')->where(['id'=>$user['id']])->dec('integral', $refund_integral))
if(!Db::name('User')->where(['id'=>$user['id']])->dec('integral', $refund_integral)->update())
{
return DataReturn('用户积分释放失败['.$order_detail['order_id'].'-'.$order_detail['goods_id'].']', -10);
}

View File

@ -991,7 +991,7 @@ class OrderAftersaleService
$order_status = (MyC('common_goods_sales_count_inc_rules', 1) == 1) ? 4 : 2;
if($order['data']['status'] == $order_status && $aftersale['number'] > 0)
{
if(!Db::name('Goods')->where(['id'=>intval($aftersale['goods_id'])])->dec('sales_count', $aftersale['number']))
if(!Db::name('Goods')->where(['id'=>intval($aftersale['goods_id'])])->dec('sales_count', $aftersale['number'])->update())
{
Db::rollback();
return DataReturn('商品销量释放失败', -1);

View File

@ -2145,7 +2145,7 @@ class OrderService
{
foreach($order_detail as $v)
{
if(Db::name('Goods')->where(['id'=>$v['goods_id']])->inc('sales_count', $v['buy_number']) === false)
if(Db::name('Goods')->where(['id'=>$v['goods_id']])->inc('sales_count', $v['buy_number'])->update() === false)
{
return DataReturn('订单商品销量增加失败['.$v['title'].']', -10);
}

View File

@ -947,7 +947,7 @@ class WarehouseGoodsService
{
return DataReturn('仓库商品规格库存不足['.$warehouse_id.'-'.$goods_id.'('.$inventory.'<'.$buy_number.')]', -11);
}
if(!Db::name('WarehouseGoodsSpec')->where($where)->dec('inventory', $buy_number))
if(!Db::name('WarehouseGoodsSpec')->where($where)->dec('inventory', $buy_number)->update())
{
return DataReturn('仓库商品规格库存扣减失败['.$warehouse_id.'-'.$goods_id.'('.$buy_number.')]', -11);
}
@ -959,7 +959,7 @@ class WarehouseGoodsService
{
return DataReturn('仓库商品库存不足['.$warehouse_id.'-'.$goods_id.'('.$inventory.'<'.$buy_number.')]', -11);
}
if(!Db::name('WarehouseGoods')->where($where)->dec('inventory', $buy_number))
if(!Db::name('WarehouseGoods')->where($where)->dec('inventory', $buy_number)->update())
{
return DataReturn('仓库商品库存扣减失败['.$warehouse_id.'-'.$goods_id.'('.$buy_number.')]', -12);
}
@ -1017,14 +1017,14 @@ class WarehouseGoodsService
// 扣除仓库商品规格库存
$where = ['warehouse_id'=>$warehouse_id, 'goods_id'=>$goods_id, 'md5_key'=>$md5_key];
if(!Db::name('WarehouseGoodsSpec')->where($where)->inc('inventory', $buy_number))
if(!Db::name('WarehouseGoodsSpec')->where($where)->inc('inventory', $buy_number)->update())
{
return DataReturn('仓库商品规格库存回滚失败['.$warehouse_id.'-'.$goods_id.'('.$buy_number.')]', -11);
}
// 扣除仓库商品库存
$where = ['warehouse_id'=>$warehouse_id, 'goods_id'=>$goods_id];
if(!Db::name('WarehouseGoods')->where($where)->inc('inventory', $buy_number))
if(!Db::name('WarehouseGoods')->where($where)->inc('inventory', $buy_number)->update())
{
return DataReturn('仓库商品库存回滚失败['.$warehouse_id.'-'.$goods_id.'('.$buy_number.')]', -12);
}