切换导航条
此项目
正在载入...
登录
景龙
/
feifangu
·
提交
转到一个项目
GitLab
转到仪表盘
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
jinglong
5 years ago
提交
cc84a735f87577f4c298e1fb27f5620e28a6599a
1 个父辈
400a91e8
1 个管道 的构建
通过
耗费 1 秒
修改加入购物车
变更
5
构建
1
隐藏空白字符变更
内嵌
并排对比
正在显示
5 个修改的文件
包含
21 行增加
和
12 行删除
application/admin/view/ggoods/add.html
application/admin/view/ggoods/edit.html
application/admin/view/goods/add.html
application/admin/view/goods/edit.html
application/api/controller/Cars.php
application/admin/view/ggoods/add.html
查看文件 @
cc84a73
...
...
@@ -85,7 +85,7 @@
<div
class=
"form-group"
>
<label
class=
"control-label col-xs-12 col-sm-2"
>
{:__('Stock')}:
</label>
<div
class=
"col-xs-12 col-sm-8"
>
<input
id=
"c-stock"
data-rule=
"required
range(0~)"
class=
"form-control"
name=
"row[stock]"
type=
"number"
value=
"0
"
>
<input
id=
"c-stock"
data-rule=
"required
"
class=
"form-control"
name=
"row[stock]"
type=
"text"
placeholder=
"请输入商品库存(多个以'|'隔开)
"
>
</div>
</div>
<div
class=
"form-group"
>
...
...
application/admin/view/ggoods/edit.html
查看文件 @
cc84a73
...
...
@@ -85,7 +85,7 @@
<div
class=
"form-group"
>
<label
class=
"control-label col-xs-12 col-sm-2"
>
{:__('Stock')}:
</label>
<div
class=
"col-xs-12 col-sm-8"
>
<input
id=
"c-stock"
data-rule=
"required"
class=
"form-control"
name=
"row[stock]"
type=
"
number"
value=
"{$row.stock|htmlentities}
"
>
<input
id=
"c-stock"
data-rule=
"required"
class=
"form-control"
name=
"row[stock]"
type=
"
text"
value=
"{$row.stock|htmlentities}"
placeholder=
"请输入商品库存(多个以'|'隔开)
"
>
</div>
</div>
<div
class=
"form-group"
>
...
...
application/admin/view/goods/add.html
查看文件 @
cc84a73
...
...
@@ -85,7 +85,7 @@
<div
class=
"form-group"
>
<label
class=
"control-label col-xs-12 col-sm-2"
>
{:__('Stock')}:
</label>
<div
class=
"col-xs-12 col-sm-8"
>
<input
id=
"c-stock"
data-rule=
"required
range(0~)"
class=
"form-control"
name=
"row[stock]"
type=
"number"
value=
"0
"
>
<input
id=
"c-stock"
data-rule=
"required
"
class=
"form-control"
name=
"row[stock]"
type=
"text"
placeholder=
"请输入商品库存(多个以'|'隔开)
"
>
</div>
</div>
<div
class=
"form-group"
>
...
...
application/admin/view/goods/edit.html
查看文件 @
cc84a73
...
...
@@ -85,7 +85,7 @@
<div
class=
"form-group"
>
<label
class=
"control-label col-xs-12 col-sm-2"
>
{:__('Stock')}:
</label>
<div
class=
"col-xs-12 col-sm-8"
>
<input
id=
"c-stock"
data-rule=
"required"
class=
"form-control"
name=
"row[stock]"
type=
"
number"
value=
"{$row.stock|htmlentities}
"
>
<input
id=
"c-stock"
data-rule=
"required"
class=
"form-control"
name=
"row[stock]"
type=
"
text"
value=
"{$row.stock|htmlentities}"
placeholder=
"请输入商品库存(多个以'|'隔开)
"
>
</div>
</div>
<div
class=
"form-group"
>
...
...
application/api/controller/Cars.php
查看文件 @
cc84a73
...
...
@@ -49,10 +49,17 @@ class Cars extends Api
}
//检测库存
$stock
=
Common
::
findSoftWhereData
(
'goods'
,[
'id'
=>
$data
[
'goods_id'
]],
'id,stock'
);
if
(
$stock
){
if
((
$stock
[
'stock'
]
<=>
$data
[
'goods_number'
])
==
-
1
){
$this
->
error
(
'库存不足'
);
$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
(
'出错了'
);
}
}
//查询有无记录
...
...
@@ -129,10 +136,12 @@ class Cars extends Api
$total_price
+=
$value
[
'price'
]
*
$value
[
'goods_number'
];
//查看规格所属索引
$s_index
=
array_search
(
$value
[
'style'
],
Common
::
salePrice
(
$value
[
'g_style'
]));
$value
[
'stock'
]
=
Common
::
salePrice
(
$value
[
'stock'
][
$s_index
]);
if
((
$value
[
'stock'
]
<=>
$value
[
'goods_number'
])
==
-
1
){
//购物车数量大于库存
$value
[
'goods_number'
]
=
$value
[
'stock'
];
if
(
$s_index
){
$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) {
...
...
请
注册
或
登录
后发表评论