Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
starsw001
ShopXO
提交
19b23190
ShopXO
项目概览
starsw001
/
ShopXO
与 Fork 源项目一致
Fork自
纵之格 / ShopXO
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
ShopXO
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
19b23190
编写于
12月 01, 2020
作者:
D
Devil
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
商品编辑库存出错修复
上级
7a18b447
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
55 addition
and
38 deletion
+55
-38
application/service/WarehouseGoodsService.php
application/service/WarehouseGoodsService.php
+53
-37
changelog.txt
changelog.txt
+2
-1
未找到文件。
application/service/WarehouseGoodsService.php
浏览文件 @
19b23190
...
...
@@ -690,41 +690,49 @@ class WarehouseGoodsService
// 启动事务
Db
::
startTrans
();
// 捕获异常
try
{
// 删除原始数据
$where
=
[
'warehouse_id'
=>
$warehouse_goods
[
'warehouse_id'
],
'goods_id'
=>
$warehouse_goods
[
'goods_id'
],
];
Db
::
name
(
'WarehouseGoodsSpec'
)
->
where
(
$where
)
->
delete
();
// 删除原始数据
$where
=
[
'warehouse_id'
=>
$warehouse_goods
[
'warehouse_id'
],
'goods_id'
=>
$warehouse_goods
[
'goods_id'
],
];
Db
::
name
(
'WarehouseGoodsSpec'
)
->
where
(
$where
)
->
delete
();
// 仓库商品更新
Db
::
name
(
'WarehouseGoods'
)
->
where
([
'id'
=>
$warehouse_goods
[
'id'
]])
->
update
([
'inventory'
=>
array_sum
(
array_column
(
$data
,
'inventory'
)),
'upd_time'
=>
time
(),
]);
// 添加数据
if
(
!
empty
(
$data
))
{
if
(
Db
::
name
(
'WarehouseGoodsSpec'
)
->
insertAll
(
$data
)
<
count
(
$data
))
{
throw
new
\
Exception
(
'规格库存添加失败'
);
}
}
// 添加数据
if
(
!
empty
(
$data
))
{
if
(
Db
::
name
(
'WarehouseGoodsSpec'
)
->
insertAll
(
$data
)
<
count
(
$data
))
// 仓库商品更新
if
(
!
Db
::
name
(
'WarehouseGoods'
)
->
where
([
'id'
=>
$warehouse_goods
[
'id'
]])
->
update
([
'inventory'
=>
array_sum
(
array_column
(
$data
,
'inventory'
)),
'upd_time'
=>
time
(),
]))
{
Db
::
rollback
();
return
DataReturn
(
'规格库存添加失败'
,
-
100
);
throw
new
\
Exception
(
'库存商品更新失败'
);
}
}
// 同步商品库存
$ret
=
self
::
GoodsSpecInventorySync
(
$warehouse_goods
[
'goods_id'
]);
if
(
$ret
[
'code'
]
!=
0
)
{
// 同步商品库存
$ret
=
self
::
GoodsSpecInventorySync
(
$warehouse_goods
[
'goods_id'
]);
if
(
$ret
[
'code'
]
!=
0
)
{
throw
new
\
Exception
(
$ret
[
'msg'
]);
}
// 完成
Db
::
commit
();
return
DataReturn
(
'操作成功'
,
0
);
}
catch
(
\
Exception
$e
)
{
Db
::
rollback
();
return
$ret
;
return
DataReturn
(
$e
->
getMessage
(),
-
1
)
;
}
// 提交事务
Db
::
commit
();
return
DataReturn
(
'更新成功'
,
0
);
}
/**
...
...
@@ -760,7 +768,11 @@ class WarehouseGoodsService
foreach
(
$res
[
'value'
]
as
$v
)
{
$md5_key
=
md5
(
empty
(
$v
[
'value'
])
?
'default'
:
str_replace
(
GoodsService
::
$goods_spec_to_string_separator
,
''
,
$v
[
'value'
]));
$inventory
=
(
int
)
Db
::
name
(
'WarehouseGoodsSpec'
)
->
where
([
'warehouse_id'
=>
$wg
[
'warehouse_id'
],
'md5_key'
=>
$md5_key
])
->
value
(
'inventory'
);
$inventory
=
(
int
)
Db
::
name
(
'WarehouseGoodsSpec'
)
->
where
([
'warehouse_id'
=>
$wg
[
'warehouse_id'
],
'goods_id'
=>
$wg
[
'goods_id'
],
'md5_key'
=>
$md5_key
,
])
->
value
(
'inventory'
);
$data
[]
=
[
'warehouse_goods_id'
=>
$wg
[
'id'
],
'warehouse_id'
=>
$wg
[
'warehouse_id'
],
...
...
@@ -774,26 +786,30 @@ class WarehouseGoodsService
// 删除原始数据
$where
=
[
'warehouse_id'
=>
$wg
[
'warehouse_id'
],
'goods_id'
=>
$wg
[
'goods_id'
],
'warehouse_id'
=>
$wg
[
'warehouse_id'
],
'goods_id'
=>
$wg
[
'goods_id'
],
];
Db
::
name
(
'WarehouseGoodsSpec'
)
->
where
(
$where
)
->
delete
();
// 仓库商品更新
Db
::
name
(
'WarehouseGoods'
)
->
where
([
'id'
=>
$wg
[
'id'
]])
->
update
([
'inventory'
=>
array_sum
(
array_column
(
$data
,
'inventory'
)),
'upd_time'
=>
time
(),
]);
// 添加数据
if
(
Db
::
name
(
'WarehouseGoodsSpec'
)
->
insertAll
(
$data
)
<
count
(
$data
))
{
return
DataReturn
(
'规格库存添加失败'
,
-
1
);
}
// 仓库商品更新
if
(
!
Db
::
name
(
'WarehouseGoods'
)
->
where
([
'id'
=>
$wg
[
'id'
]])
->
update
([
'inventory'
=>
array_sum
(
array_column
(
$data
,
'inventory'
)),
'upd_time'
=>
time
(),
]))
{
return
DataReturn
(
'库存商品更新失败'
,
-
1
);
}
}
}
return
DataReturn
(
'操作成功'
,
0
);
// 商品库存同步
return
self
::
GoodsSpecInventorySync
(
$goods_id
);
}
/**
...
...
changelog.txt
浏览文件 @
19b23190
...
...
@@ -15,15 +15,16 @@ web端
5. 分页组件新增自定义页码跳转
6. 后端动态表格数据列表组件优化高度固定
7. 首页轮播左侧商品分类和右侧聚合内容新增开关控制
8. 商品列表支持库存快捷配置
小程序
1. 支付订单0金额错误修复
2. 小程序规格图片支持放大查看
3. 微信小程序商品/直播分享支持封面图片
4. 小程序分享优化、微信小程序分享朋友圈支持自定义图片+参数
插件
1. 新增订单商品表单插件(下单商品详情页面动态配置表单让用户填写数据方可下单)
2. 商品批量修改插件新增在商品列表支持库存快捷配置
+=========================================================+
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录