切换导航条
此项目
正在载入...
登录
景龙
/
feifangu
·
提交
转到一个项目
GitLab
转到仪表盘
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
jinglong
5 years ago
提交
d1738e92768a98789e6963f8044df367c7f468d0
1 个父辈
cc84a735
1 个管道 的构建
通过
耗费 1 秒
修改结算判断购物车库存
变更
1
构建
1
隐藏空白字符变更
内嵌
并排对比
正在显示
1 个修改的文件
包含
13 行增加
和
3 行删除
application/api/controller/Cars.php
application/api/controller/Cars.php
查看文件 @
d1738e9
...
...
@@ -320,7 +320,7 @@ class Cars extends Api
$key
=
[
'goods_id'
,
'price'
,
'goods_number'
,
'style'
];
$res_goods
=
Common
::
array_merge_more
(
$key
,
$goods_id_s
,
$price_s
,
$goods_number_s
,
$style_s
);
//查询商品
$res
=
Common
::
selectSoftWhereData
(
'goods'
,[
'id'
=>
[
'in'
,
$goods_id_s
]],
'id,name,image,expense_price,stock,introduce'
);
$res
=
Common
::
selectSoftWhereData
(
'goods'
,[
'id'
=>
[
'in'
,
$goods_id_s
]],
'id,name,image,expense_price,stock,
style g_style,
introduce'
);
$total_price
=
0
;
//总商品费用(不含运费)
$total_expense_price
=
0
;
//总运费
foreach
(
$res
as
&
$value
){
...
...
@@ -328,8 +328,17 @@ class Cars extends Api
foreach
(
$res_goods
as
$g_value
){
if
(
$value
[
'id'
]
==
$g_value
[
'goods_id'
]){
$value
[
'price'
]
=
$g_value
[
'price'
];
//商品价格
if
((
$value
[
'stock'
]
<=>
$g_value
[
'goods_number'
])
==
-
1
){
$this
->
error
(
'商品名称为'
.
$value
[
'name'
]
.
'的库存不足'
);
//检测库存
//查看规格所属索引
$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
(
'出错了'
);
}
$value
[
'goods_number'
]
=
$g_value
[
'goods_number'
];
//商品数量
$value
[
'style'
]
=
$g_value
[
'style'
];
//商品款式
...
...
@@ -339,6 +348,7 @@ class Cars extends Api
}
$total_expense_price
+=
$value
[
'expense_price'
];
unset
(
$value
[
'expense_price'
]);
unset
(
$value
[
'stock'
]);
}
$arr
[
'data'
]
=
$res
;
$arr
[
'total_goods_price'
]
=
$total_price
;
...
...
请
注册
或
登录
后发表评论