切换导航条
此项目
正在载入...
登录
景龙
/
feifangu
·
提交
转到一个项目
GitLab
转到仪表盘
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
jinglong
5 years ago
提交
a5e84a028e6fdf63cb8c8c321fe3ddc1038252e2
1 个父辈
187bfc50
1 个管道 的构建
通过
耗费 0 秒
修改库存
变更
1
构建
1
隐藏空白字符变更
内嵌
并排对比
正在显示
1 个修改的文件
包含
8 行增加
和
6 行删除
application/api/controller/Common.php
application/api/controller/Common.php
查看文件 @
a5e84a0
...
...
@@ -544,9 +544,9 @@ class Common
* 增销量
* @ApiInternal
*/
public
static
function
incSales
(
$where
){
public
static
function
incSales
(
$where
,
$sale_number
){
$goodsModel
=
new
\app\admin\model\Goods
();
$goodsModel
->
where
(
$where
)
->
setInc
(
'sales'
,
1
);
$goodsModel
->
where
(
$where
)
->
setInc
(
'sales'
,
$sale_number
);
}
/**
...
...
@@ -579,7 +579,7 @@ class Common
//销量增加1
$res
=
self
::
findSoftWhereData
(
'order'
,[
'pay_order_sn'
=>
$out_trade_no
,
'status'
=>
$status
[
2
]],
'id,uid'
);
if
(
$res
){
$res1
=
self
::
selectSoftWhereData
(
'ogoods'
,[
'o_id'
=>
$res
[
'id'
]],
'id,g_id,style'
);
$res1
=
self
::
selectSoftWhereData
(
'ogoods'
,[
'o_id'
=>
$res
[
'id'
]],
'id,g_id,style
,goods_number
'
);
$g_ids
=
array_column
(
$res1
,
'g_id'
);
//减库存
$goodsModel
=
new
\app\admin\model\Goods
();
...
...
@@ -587,19 +587,21 @@ class Common
$res_stock
=
self
::
selectSoftWhereData
(
'goods'
,[
'id'
=>
[
'in'
,
$g_ids
]],
'id,style g_style,stock'
);
foreach
(
$res_stock
as
$g_value
){
$arr_stock
=
explode
(
'|'
,
$g_value
[
'stock'
]);
$sale_number
=
1
;
foreach
(
$res1
as
$value
){
if
(
$g_value
[
'id'
]
==
$value
[
'g_id'
]){
$s_index
=
array_search
(
$value
[
'style'
],
self
::
salePrice
(
$g_value
[
'g_style'
]));
$stock
=
self
::
salePrice
(
$g_value
[
'stock'
])[
$s_index
]
-
1
;
$stock
=
self
::
salePrice
(
$g_value
[
'stock'
])[
$s_index
]
-
$value
[
'goods_number'
]
;
$arr_stock
[
$s_index
]
=
$stock
;
$sale_number
=
$value
[
'goods_number'
];
}
}
//更新库存
$stock1
=
implode
(
'|'
,
$arr_stock
);
$goodsModel
->
where
([
'id'
=>
$g_value
[
'id'
]])
->
update
([
'stock'
=>
$stock1
]);
//增加销售
self
::
incSales
([
'id'
=>
[
'in'
,
$g_ids
]],
$sale_number
);
}
//增加销售
self
::
incSales
([
'id'
=>
[
'in'
,
$g_ids
]]);
//删除购物车
self
::
deleteCar
([
'uid'
=>
$res
[
'uid'
],
'g_id'
=>
[
'in'
,
$g_ids
]]);
}
...
...
请
注册
或
登录
后发表评论