库存扣除同步仓库
parent
f3f1441316
commit
d85c957b15
|
|
@ -41,6 +41,14 @@
|
|||
</div>
|
||||
<div class="am-panel-bd">
|
||||
<div class="am-form-group">
|
||||
<label>{{$data.common_app_is_poster_share.name}}<span class="am-form-group-label-tips">{{$data.common_app_is_poster_share.describe}}</span></label>
|
||||
<select name="{{$data.common_app_is_poster_share.only_tag}}" class="am-radius chosen-select" data-validation-message="{{$data.common_app_is_poster_share.error_tips}}" required>
|
||||
{{foreach $common_is_text_list as $v}}
|
||||
<option value="{{$v.id}}" {{if isset($data['common_app_is_poster_share']['value']) and $data['common_app_is_poster_share']['value'] eq $v['id']}}selected{{/if}}>{{$v.name}}</option>
|
||||
{{/foreach}}
|
||||
</select>
|
||||
</div>
|
||||
<div class="am-form-group">
|
||||
<label>{{$data.common_app_is_good_thing.name}}<span class="am-form-group-label-tips">{{$data.common_app_is_good_thing.describe}}</span></label>
|
||||
<select name="{{$data.common_app_is_good_thing.only_tag}}" class="am-radius chosen-select" data-validation-message="{{$data.common_app_is_good_thing.error_tips}}" required>
|
||||
{{foreach $common_is_text_list as $v}}
|
||||
|
|
@ -77,15 +85,6 @@
|
|||
</div>
|
||||
<input type="text" name="{{$data.common_app_weixin_liveplayer_ver.only_tag}}" placeholder="{{$data.common_app_weixin_liveplayer_ver.name}}" data-validation-message="{{$data.common_app_weixin_liveplayer_ver.error_tips}}" class="am-radius am-margin-top-xs" {{if !empty($data)}}value="{{$data.common_app_weixin_liveplayer_ver.value}}"{{/if}} />
|
||||
</div>
|
||||
|
||||
<div class="am-form-group">
|
||||
<label>{{$data.common_app_is_poster_share.name}}<span class="am-form-group-label-tips">{{$data.common_app_is_poster_share.describe}}</span></label>
|
||||
<select name="{{$data.common_app_is_poster_share.only_tag}}" class="am-radius chosen-select" data-validation-message="{{$data.common_app_is_poster_share.error_tips}}" required>
|
||||
{{foreach $common_is_text_list as $v}}
|
||||
<option value="{{$v.id}}" {{if isset($data['common_app_is_poster_share']['value']) and $data['common_app_is_poster_share']['value'] eq $v['id']}}selected{{/if}}>{{$v.name}}</option>
|
||||
{{/foreach}}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{/case}}
|
||||
|
|
|
|||
|
|
@ -363,7 +363,7 @@
|
|||
{{/if}}
|
||||
{{php}}
|
||||
$hook_name = 'plugins_view_buy_group_goods_inside_bottom';
|
||||
$hook_data = Hook::listen($hook_name, ['hook_name'=>$hook_name, 'is_backend'=>false, 'data'=>$v]);
|
||||
$hook_data = Hook::listen($hook_name, ['hook_name'=>$hook_name, 'is_backend'=>false, 'data'=>$v, 'params'=>$params]);
|
||||
if(!empty($hook_data) && is_array($hook_data))
|
||||
{
|
||||
foreach($hook_data as $hook)
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ use app\service\ResourcesService;
|
|||
use app\service\PaymentService;
|
||||
use app\service\ConfigService;
|
||||
use app\service\OrderSplitService;
|
||||
use app\service\WarehouseGoodsService;
|
||||
|
||||
/**
|
||||
* 购买服务层
|
||||
|
|
@ -997,7 +998,6 @@ class BuyService
|
|||
return $buy;
|
||||
}
|
||||
|
||||
|
||||
// 用户留言
|
||||
$user_note = empty($params['user_note']) ? '' : str_replace(['"', "'"], '', strip_tags($params['user_note']));
|
||||
|
||||
|
|
@ -1085,10 +1085,10 @@ class BuyService
|
|||
$order_id = Db::name('Order')->insertGetId($order);
|
||||
if($order_id > 0)
|
||||
{
|
||||
foreach($v['goods_items'] as $k=>$v)
|
||||
foreach($v['goods_items'] as $k=>$vs)
|
||||
{
|
||||
// 添加订单详情数据,data返回自增id
|
||||
$detail_ret = self::OrderDetailInsert($order_id, $params['user']['id'], $v);
|
||||
$detail_ret = self::OrderDetailInsert($order_id, $params['user']['id'], $vs);
|
||||
if($detail_ret['code'] == 0)
|
||||
{
|
||||
$v['goods_items'][$k]['id'] = $detail_ret['data'];
|
||||
|
|
@ -1100,7 +1100,7 @@ class BuyService
|
|||
// 订单模式 - 虚拟信息添加
|
||||
if($site_model == 3)
|
||||
{
|
||||
$ret = self::OrderFictitiousValueInsert($order_id, $detail_ret['data'], $params['user']['id'], $v['goods_id']);
|
||||
$ret = self::OrderFictitiousValueInsert($order_id, $detail_ret['data'], $params['user']['id'], $vs['goods_id']);
|
||||
if($ret['code'] != 0)
|
||||
{
|
||||
Db::rollback();
|
||||
|
|
@ -1683,6 +1683,13 @@ class BuyService
|
|||
return $base;
|
||||
}
|
||||
|
||||
// 仓库库存扣除
|
||||
$we_ret = WarehouseGoodsService::WarehouseGoodsInventoryDeduct($params['order_id'], $v['goods_id'], $spec, $v['buy_number']);
|
||||
if($we_ret['code'] != 0)
|
||||
{
|
||||
return $we_ret;
|
||||
}
|
||||
|
||||
// 扣除日志添加
|
||||
$log_data = [
|
||||
'order_id' => $params['order_id'],
|
||||
|
|
|
|||
|
|
@ -799,5 +799,53 @@ class WarehouseGoodsService
|
|||
];
|
||||
return (int) Db::name('WarehouseGoodsSpec')->where($where)->sum('inventory');
|
||||
}
|
||||
|
||||
/**
|
||||
* 仓库库存扣减
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2020-08-02
|
||||
* @desc description
|
||||
* @param [int] $order_id [订单id]
|
||||
* @param [int] $goods_id [商品id]
|
||||
* @param [string] $spec [商品规格]
|
||||
* @param [int] $buy_number [扣除库存数量]
|
||||
*/
|
||||
public static function WarehouseGoodsInventoryDeduct($order_id, $goods_id, $spec, $buy_number)
|
||||
{
|
||||
// 获取仓库id
|
||||
$warehouse_id = Db::name('Order')->where(['id'=>$order_id])->value('warehouse_id');
|
||||
if(empty($warehouse_id))
|
||||
{
|
||||
return DataReturn('订单仓库id有误', -1);
|
||||
}
|
||||
|
||||
// 规格key,空则默认default
|
||||
$md5_key = 'default';
|
||||
if(!empty($spec))
|
||||
{
|
||||
if(!is_array($spec))
|
||||
{
|
||||
$spec = json_decode($spec, true);
|
||||
}
|
||||
$md5_key = implode('', array_column($spec, 'value'));
|
||||
}
|
||||
$md5_key = md5($md5_key);
|
||||
|
||||
// 扣除仓库商品规格库存
|
||||
if(!Db::name('WarehouseGoodsSpec')->where(['warehouse_id'=>$warehouse_id, 'goods_id'=>$goods_id, 'md5_key'=>$md5_key])->setDec('inventory', $buy_number))
|
||||
{
|
||||
return DataReturn('仓库商品规格库存扣减失败['.$warehouse_id.'-'.$goods_id.'('.$buy_number.')]', -11);
|
||||
}
|
||||
|
||||
// 扣除仓库商品库存
|
||||
if(!Db::name('WarehouseGoods')->where(['warehouse_id'=>$warehouse_id, 'goods_id'=>$goods_id])->setDec('inventory', $buy_number))
|
||||
{
|
||||
return DataReturn('仓库商品库存扣减失败['.$warehouse_id.'-'.$goods_id.'('.$buy_number.')]', -12);
|
||||
}
|
||||
|
||||
return DataReturn('扣除成功', 0);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -34,12 +34,65 @@ return array (
|
|||
),
|
||||
'plugins_css' =>
|
||||
array (
|
||||
0 => 'app\\plugins\\freightfee\\Hook',
|
||||
0 => 'app\\plugins\\distribution\\Hook',
|
||||
1 => 'app\\plugins\\freightfee\\Hook',
|
||||
2 => 'app\\plugins\\coupon\\Hook',
|
||||
),
|
||||
'plugins_service_users_center_left_menu_handle' =>
|
||||
array (
|
||||
0 => 'app\\plugins\\distribution\\Hook',
|
||||
1 => 'app\\plugins\\coupon\\Hook',
|
||||
),
|
||||
'plugins_service_header_navigation_top_right_handle' =>
|
||||
array (
|
||||
0 => 'app\\plugins\\distribution\\Hook',
|
||||
1 => 'app\\plugins\\coupon\\Hook',
|
||||
),
|
||||
'plugins_service_order_status_change_history_success_handle' =>
|
||||
array (
|
||||
0 => 'app\\plugins\\distribution\\Hook',
|
||||
1 => 'app\\plugins\\coupon\\Hook',
|
||||
),
|
||||
'plugins_service_order_aftersale_audit_handle_end' =>
|
||||
array (
|
||||
0 => 'app\\plugins\\distribution\\Hook',
|
||||
),
|
||||
'plugins_service_site_extraction_address_list' =>
|
||||
array (
|
||||
0 => 'app\\plugins\\distribution\\Hook',
|
||||
),
|
||||
'plugins_service_buy_order_insert_end' =>
|
||||
array (
|
||||
0 => 'app\\plugins\\distribution\\Hook',
|
||||
),
|
||||
'plugins_service_goods_spec_extends_handle' =>
|
||||
array (
|
||||
0 => 'app\\plugins\\distribution\\Hook',
|
||||
),
|
||||
'plugins_view_admin_user_save' =>
|
||||
array (
|
||||
0 => 'app\\plugins\\distribution\\Hook',
|
||||
),
|
||||
'plugins_service_user_save_handle' =>
|
||||
array (
|
||||
0 => 'app\\plugins\\distribution\\Hook',
|
||||
),
|
||||
'plugins_view_goods_detail_base_buy_nav_min_inside' =>
|
||||
array (
|
||||
0 => 'app\\plugins\\distribution\\Hook',
|
||||
),
|
||||
'plugins_view_goods_detail_photo_within' =>
|
||||
array (
|
||||
0 => 'app\\plugins\\distribution\\Hook',
|
||||
),
|
||||
'plugins_view_goods_detail_base_bottom' =>
|
||||
array (
|
||||
0 => 'app\\plugins\\distribution\\Hook',
|
||||
),
|
||||
'plugins_service_buy_group_goods_handle' =>
|
||||
array (
|
||||
0 => 'app\\plugins\\freightfee\\Hook',
|
||||
1 => 'app\\plugins\\coupon\\Hook',
|
||||
),
|
||||
'plugins_view_goods_detail_title' =>
|
||||
array (
|
||||
|
|
@ -53,23 +106,11 @@ return array (
|
|||
array (
|
||||
0 => 'app\\plugins\\coupon\\Hook',
|
||||
),
|
||||
'plugins_service_users_center_left_menu_handle' =>
|
||||
array (
|
||||
0 => 'app\\plugins\\coupon\\Hook',
|
||||
),
|
||||
'plugins_service_header_navigation_top_right_handle' =>
|
||||
array (
|
||||
0 => 'app\\plugins\\coupon\\Hook',
|
||||
),
|
||||
'plugins_view_goods_detail_panel_bottom' =>
|
||||
array (
|
||||
0 => 'app\\plugins\\coupon\\Hook',
|
||||
),
|
||||
'plugins_view_buy_goods_bottom' =>
|
||||
array (
|
||||
0 => 'app\\plugins\\coupon\\Hook',
|
||||
),
|
||||
'plugins_service_buy_handle' =>
|
||||
'plugins_view_buy_group_goods_inside_bottom' =>
|
||||
array (
|
||||
0 => 'app\\plugins\\coupon\\Hook',
|
||||
),
|
||||
|
|
@ -81,10 +122,6 @@ return array (
|
|||
array (
|
||||
0 => 'app\\plugins\\coupon\\Hook',
|
||||
),
|
||||
'plugins_service_order_status_change_history_success_handle' =>
|
||||
array (
|
||||
0 => 'app\\plugins\\coupon\\Hook',
|
||||
),
|
||||
'plugins_service_user_register_end' =>
|
||||
array (
|
||||
0 => 'app\\plugins\\coupon\\Hook',
|
||||
|
|
|
|||
Loading…
Reference in New Issue