全部
常见问题
产品动态
精选推荐

3.2.7秒杀、砍价、拼团,取消订单库存限量回退问题

管理 管理 编辑 删除
本帖最后由 liusonglin 于 2020-7-28 17:01 编辑

在文件中搜索方法名替

换特别注意:不要点下面的复制代码,不要点下面的复制代码,不要点下面的复制代码,手动选择复制代码

1、app\models\store\StoreOrder.php

方法名:RegressionStock

public static function RegressionStock($order)

{

if ($order['status'] == -2 || $order['is_del']) return true;

$combinationId = $order['combination_id'];

$seckill_id = $order['seckill_id'];

$bargain_id = $order['bargain_id'];

$res5 = true;

$cartInfo = StoreOrderCartInfo::where('cart_id','in', $order['cart_id'])->select();

foreach ($cartInfo as $cart) {

//增库存减销量

if ($combinationId) $res5 = $res5 && StoreCombination::incCombinationStock($cart['cart_info']['cart_num'], $combinationId, isset($cart['cart_info']['productInfo']['attrInfo']) ? $cart['cart_info']['productInfo']['attrInfo']['unique'] : '');

else if ($seckill_id) $res5 = $res5 && StoreSeckill::incSeckillStock($cart['cart_info']['cart_num'], $seckill_id, isset($cart['cart_info']['productInfo']['attrInfo']) ? $cart['cart_info']['productInfo']['attrInfo']['unique'] : '');

else if ($bargain_id) $res5 = $res5 && StoreBargain::incBargainStock($cart['cart_info']['cart_num'], $bargain_id, isset($cart['cart_info']['productInfo']['attrInfo']) ? $cart['cart_info']['productInfo']['attrInfo']['unique'] : '');

else $res5 = $res5 && StoreProduct::incProductStock($cart['cart_info']['cart_num'], $cart['cart_info']['productInfo']['id'], isset($cart['cart_info']['productInfo']['attrInfo']) ? $cart['cart_info']['productInfo']['attrInfo']['unique'] : '');

}

return $res5;

}
5707

2、app\models\store\StoreBargain.php

方法名:IncBargainStock

 public static function IncBargainStock($num, $bargainId, $unique = '')

{

$bargain = self::where('id', $bargainId)->field(['product_id', 'stock', 'sales', 'quota'])->find();

if (!$bargain) return true;

if ($bargain->sales > 0) $bargain->sales = bcsub($bargain->sales, $num, 0);

if ($bargain->sales < 0) $bargain->sales = 0;

$res = true;

if ($unique) {

$res = false !== StoreProductAttrValueModel::incProductAttrStock($bargainId, $unique, $num, 2);

$sku = StoreProductAttrValue::where('product_id',$bargainId)->where('unique',$unique)->where('type',2)->value('suk');

$res = $res && StoreProductAttrValue::where('product_id',$bargain['product_id'])->where('suk',$sku)->where('type',0)->inc('stock',$num)->dec('sales',$num)->update();

}

$bargain->stock = bcadd($bargain->stock, $num, 0);

$bargain->quota = bcadd($bargain->quota, $num, 0);

$res = $res && $bargain->save() && StoreProduct::where('id',$bargain['product_id'])->inc('stock', $num)->dec('sales', $num)->update();

return $res;

}
5708

3、app\models\store\StoreSeckill.php

方法名:incSeckillStock

public static function incSeckillStock($num = 0, $seckillId = 0, $unique = '')

{

$seckill = self::where('id', $seckillId)->field(['product_id', 'stock', 'sales', 'quota'])->find();

if (!$seckill) return true;

if ($seckill->sales > 0) $seckill->sales = bcsub($seckill->sales, $num, 0);

if ($seckill->sales < 0) $seckill->sales = 0;

$res = true;

if ($unique) {

$res = false !== StoreProductAttrValueModel::incProductAttrStock($seckillId, $unique, $num, 1);

$sku = StoreProductAttrValue::where('product_id', $seckillId)->where('unique', $unique)->where('type', 1)->value('suk');

$res = $res && StoreProductAttrValue::where('product_id', $seckill['product_id'])->where('suk', $sku)->where('type', 0)->inc('stock', $num)->dec('sales', $num)->update();

}

$seckill->stock = bcadd($seckill->stock, $num, 0);

$seckill->quota = bcadd($seckill->quota, $num, 0);

$res = $res && $seckill->save() && StoreProduct::where('id', $seckill['product_id'])->inc('stock', $num)->dec('sales', $num)->update();

return $res;

}
5709

4、app\models\store\StoreCombination.php

方法名:incCombinationStock

public static function incCombinationStock($num, $CombinationId, $unique = '')

{

$combination = self::where('id', $CombinationId)->field(['product_id', 'stock', 'sales', 'quota'])->find();

if (!$combination) return true;

if ($combination->sales > 0) $combination->sales = bcsub($combination->sales, $num, 0);

if ($combination->sales < 0) $combination->sales = 0;

$res = true;

if ($unique) {

$res = false !== StoreProductAttrValue::incProductAttrStock($CombinationId, $unique, $num, 3);

$sku = StoreProductAttrValue::where('product_id', $CombinationId)->where('unique', $unique)->where('type', 3)->value('suk');

$res = $res && StoreProductAttrValue::where('product_id', $combination['product_id'])->where('suk', $sku)->where('type', 0)->inc('stock', $num)->dec('sales', $num)->update();

}

$combination->stock = bcadd($combination->stock, $num, 0);

$combination->quota = bcadd($combination->quota, $num, 0);

$res = $res && $combination->save() && StoreProduct::where('id', $combination['product_id'])->inc('stock', $num)->dec('sales', $num)->update();

return $res;

}
5710

3.2.7秒杀、砍价、拼团,取消订单库存限量回退问题 3.2.7秒杀、砍价、拼团,取消订单库存限量回退问题 3.2.7秒杀、砍价、拼团,取消订单库存限量回退问题 3.2.7秒杀、砍价、拼团,取消订单库存限量回退问题 3.2.7秒杀、砍价、拼团,取消订单库存限量回退问题 3.2.7秒杀、砍价、拼团,取消订单库存限量回退问题 3.2.7秒杀、砍价、拼团,取消订单库存限量回退问题 3.2.7秒杀、砍价、拼团,取消订单库存限量回退问题
请登录后查看

CRMEB官方 最后编辑于2021-04-27 15:09:17

快捷回复
回复
回复
回复({{post_count}}) {{!is_user ? '我的回复' :'全部回复'}}
排序 默认正序 回复倒序 点赞倒序

{{item.user_info.nickname ? item.user_info.nickname : item.user_name}} LV.{{ item.user_info.bbs_level }}

作者 管理员 企业

{{item.floor}}# 同步到gitee 已同步到gitee {{item.is_suggest == 1? '取消推荐': '推荐'}}
{{item.is_suggest == 1? '取消推荐': '推荐'}}
沙发 板凳 地板 {{item.floor}}#
{{item.user_info.title || '暂无简介'}}
附件

{{itemf.name}}

{{item.created_at}}  {{item.ip_address}}
{{item.like_count}}
{{item.showReply ? '取消回复' : '回复'}}
删除
回复
回复

{{itemc.user_info.nickname}}

{{itemc.user_name}}

回复 {{itemc.comment_user_info.nickname}}

附件

{{itemf.name}}

{{itemc.created_at}}
{{itemc.like_count}}
{{itemc.showReply ? '取消回复' : '回复'}}
删除
回复
回复
查看更多
2727
{{like_count}}
{{collect_count}}
添加回复 ({{post_count}})

相关推荐

快速安全登录

使用微信扫码登录
{{item.label}} 加精
{{item.label}} {{item.label}} 板块推荐 常见问题 产品动态 精选推荐 首页头条 首页动态 首页推荐
取 消 确 定
回复
回复
问题:
问题自动获取的帖子内容,不准确时需要手动修改. [获取答案]
答案:
提交
bug 需求 取 消 确 定

微信登录/注册

切换手机号登录

{{ bind_phone ? '绑定手机' : '手机登录'}}

{{codeText}}
切换微信登录/注册
暂不绑定
CRMEB客服

CRMEB咨询热线 咨询热线

400-8888-794

微信扫码咨询

CRMEB开源商城下载 源码下载 CRMEB帮助文档 帮助文档
返回顶部 返回顶部
CRMEB客服