切换导航条
此项目
正在载入...
登录
景龙
/
feifangu
·
提交
转到一个项目
GitLab
转到仪表盘
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
jinglong
5 years ago
提交
4c9da2642576352dc86e8fbfb13005b23653d0e8
1 个父辈
d1738e92
1 个管道 的构建
通过
耗费 0 秒
修改加入购物车判断库存
变更
1
构建
1
隐藏空白字符变更
内嵌
并排对比
正在显示
1 个修改的文件
包含
11 行增加
和
21 行删除
application/api/controller/Cars.php
application/api/controller/Cars.php
查看文件 @
4c9da26
...
...
@@ -52,14 +52,10 @@ class Cars extends Api
$stock_res
=
Common
::
findSoftWhereData
(
'goods'
,[
'id'
=>
$data
[
'goods_id'
]],
'id,stock,style g_style'
);
if
(
$stock_res
){
//查看规格所属索引
$s_index
=
array_search
(
$data
[
'style'
],
Common
::
salePrice
(
$stock_res
[
'g_style'
]));
if
(
$s_index
){
$stock
=
Common
::
salePrice
(
$stock_res
[
'stock'
])[
$s_index
];
if
((
$stock
<=>
$data
[
'goods_number'
])
==
-
1
){
$this
->
error
(
'库存不足'
);
}
}
else
{
$this
->
error
(
'出错了'
);
$s_index
=
array_search
(
$data
[
'style'
],
Common
::
salePrice
(
trim
(
$stock_res
[
'g_style'
])));
$stock
=
Common
::
salePrice
(
$stock_res
[
'stock'
])[
$s_index
];
if
((
$stock
<=>
$data
[
'goods_number'
])
==
-
1
){
$this
->
error
(
'库存不足'
);
}
}
//查询有无记录
...
...
@@ -136,12 +132,10 @@ class Cars extends Api
$total_price
+=
$value
[
'price'
]
*
$value
[
'goods_number'
];
//查看规格所属索引
$s_index
=
array_search
(
$value
[
'style'
],
Common
::
salePrice
(
$value
[
'g_style'
]));
if
(
$s_index
){
$value
[
'stock'
]
=
Common
::
salePrice
(
$value
[
'stock'
])[
$s_index
];
if
((
$value
[
'stock'
]
<=>
$value
[
'goods_number'
])
==
-
1
){
//购物车数量大于库存
$value
[
'goods_number'
]
=
$value
[
'stock'
];
}
$value
[
'stock'
]
=
Common
::
salePrice
(
$value
[
'stock'
])[
$s_index
];
if
((
$value
[
'stock'
]
<=>
$value
[
'goods_number'
])
==
-
1
){
//购物车数量大于库存
$value
[
'goods_number'
]
=
$value
[
'stock'
];
}
}
// $total_price = array_sum(array_map(function ($product_row) {
...
...
@@ -332,13 +326,9 @@ class Cars extends Api
//检测库存
//查看规格所属索引
$s_index
=
array_search
(
$g_value
[
'style'
],
Common
::
salePrice
(
$value
[
'g_style'
]));
if
(
$s_index
){
$stock
=
Common
::
salePrice
(
$value
[
'stock'
])[
$s_index
];
if
((
$stock
<=>
$g_value
[
'goods_number'
])
==
-
1
){
$this
->
error
(
'库存不足'
);
}
}
else
{
$this
->
error
(
'出错了'
);
$stock
=
Common
::
salePrice
(
$value
[
'stock'
])[
$s_index
];
if
((
$stock
<=>
$g_value
[
'goods_number'
])
==
-
1
){
$this
->
error
(
'库存不足'
);
}
$value
[
'goods_number'
]
=
$g_value
[
'goods_number'
];
//商品数量
$value
[
'style'
]
=
$g_value
[
'style'
];
//商品款式
...
...
请
注册
或
登录
后发表评论