Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jamesyang1999
ShopXO
提交
3e814ebd
ShopXO
项目概览
jamesyang1999
/
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,发现更多精彩内容 >>
提交
3e814ebd
编写于
11月 09, 2018
作者:
D
devil_gong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
库存扣除
上级
2a628b66
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
144 addition
and
14 deletion
+144
-14
service/Application/Admin/View/Default/Config/Index.html
service/Application/Admin/View/Default/Config/Index.html
+1
-1
service/Application/Common/Lang/zh-cn.php
service/Application/Common/Lang/zh-cn.php
+2
-2
service/Application/Service/BuyService.class.php
service/Application/Service/BuyService.class.php
+104
-0
service/Application/Service/OrderService.class.php
service/Application/Service/OrderService.class.php
+10
-2
shopxo.sql
shopxo.sql
+27
-9
未找到文件。
service/Application/Admin/View/Default/Config/Index.html
浏览文件 @
3e814ebd
...
...
@@ -18,7 +18,7 @@
<input
type=
"number"
name=
"{{$data.admin_page_number.only_tag}}"
placeholder=
"{{$data.admin_page_number.name}}"
pattern=
"{{:L('common_regex_page_number')}}"
data-validation-message=
"{{$data.admin_page_number.error_tips}}"
class=
"am-radius"
<
present
name=
"data"
>
value="{{$data.admin_page_number.value}}"
</present>
required />
</div>
<div
class=
"am-form-group"
>
<label>
{{$data.common_is_deduction_inventory.name}}
</label>
<label>
{{$data.common_is_deduction_inventory.name}}
<
span
class=
"fs-12 fw-100 cr-999"
>
({{$data.common_is_deduction_inventory.describe}})
</span><
/label>
<select
name=
"{{$data.common_is_deduction_inventory.only_tag}}"
class=
"am-radius chosen-select c-p"
data-validation-message=
"{{$data.common_is_deduction_inventory.error_tips}}"
required
>
<foreach
name=
"common_is_text_list"
item=
"v"
>
<option
value=
"{{$v.id}}"
<
if
condition=
"isset($data['common_is_deduction_inventory']['value']) and $data['common_is_deduction_inventory']['value'] eq $v['id']"
>
selected
</if>
>{{$v.name}}
</option>
...
...
service/Application/Common/Lang/zh-cn.php
浏览文件 @
3e814ebd
...
...
@@ -418,9 +418,9 @@ return array(
// 扣除库存规则
'common_deduction_inventory_rules_list'
=>
array
(
0
=>
array
(
'id'
=>
0
,
'name'
=>
'订单
提交
成功'
,
'checked'
=>
true
),
0
=>
array
(
'id'
=>
0
,
'name'
=>
'订单
确认
成功'
,
'checked'
=>
true
),
1
=>
array
(
'id'
=>
1
,
'name'
=>
'订单支付成功'
),
2
=>
array
(
'id'
=>
2
,
'name'
=>
'订单
已
发货'
),
2
=>
array
(
'id'
=>
2
,
'name'
=>
'订单发货'
),
),
// 是否已读
...
...
service/Application/Service/BuyService.class.php
浏览文件 @
3e814ebd
...
...
@@ -715,5 +715,109 @@ class BuyService
}
return
self
::
CartTotal
([
'user_id'
=>
$params
[
'user'
][
'id'
]]);
}
/**
* 库存扣除
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-11-09
* @desc description
* @param [array] $params [输入参数]
*/
public
static
function
OrderInventoryDeduct
(
$params
=
[])
{
// 请求参数
$p
=
[
[
'checked_type'
=>
'empty'
,
'key_name'
=>
'order_id'
,
'error_msg'
=>
'订单id有误'
,
],
[
'checked_type'
=>
'empty'
,
'key_name'
=>
'order_data'
,
'error_msg'
=>
'订单更新数据不能为空'
,
],
[
'checked_type'
=>
'is_array'
,
'key_name'
=>
'order_data'
,
'error_msg'
=>
'订单更新数据有误'
,
]
];
$ret
=
params_checked
(
$params
,
$p
);
if
(
$ret
!==
true
)
{
return
DataReturn
(
$ret
,
-
1
);
}
// 是否扣除库存
$common_is_deduction_inventory
=
MyC
(
'common_is_deduction_inventory'
,
0
);
if
(
$common_is_deduction_inventory
!=
1
)
{
return
DataReturn
(
'未开启扣除库存'
,
0
);
}
// 扣除库存规则
$common_deduction_inventory_rules
=
MyC
(
'common_deduction_inventory_rules'
,
1
);
switch
(
$common_deduction_inventory_rules
)
{
// 订单确认成功
case
0
:
if
(
$params
[
'order_data'
][
'status'
]
!=
1
)
{
return
DataReturn
(
'当前订单状态未操作确认不扣除库存['
.
$params
[
'order_id'
]
.
']'
,
0
);
}
break
;
// 订单支付成功
case
1
:
if
(
$params
[
'order_data'
][
'status'
]
!=
2
)
{
return
DataReturn
(
'当前订单状态未操作支付不扣除库存['
.
$params
[
'order_id'
]
.
']'
,
0
);
}
break
;
// 订单发货
case
2
:
if
(
$params
[
'order_data'
][
'status'
]
!=
3
)
{
return
DataReturn
(
'当前订单状态未操作发货不扣除库存['
.
$params
[
'order_id'
]
.
']'
,
0
);
}
break
;
}
// 获取订单商品
$order_detail
=
M
(
'OrderDetail'
)
->
field
(
'goods_id,buy_number'
)
->
where
([
'order_id'
=>
$params
[
'order_id'
]])
->
select
();
if
(
!
empty
(
$order_detail
))
{
$goods_m
=
M
(
'Goods'
);
$log_m
=
M
(
'OrderGoodsInventoryLog'
);
foreach
(
$order_detail
as
$v
)
{
$goods
=
$goods_m
->
field
(
'is_deduction_inventory,inventory'
)
->
find
();
if
(
isset
(
$goods
[
'is_deduction_inventory'
])
&&
$goods
[
'is_deduction_inventory'
]
==
1
)
{
// 扣除操作
if
(
!
$goods_m
->
where
([
'id'
=>
$v
[
'goods_id'
]])
->
setDec
(
'inventory'
,
$v
[
'buy_number'
]))
{
return
DataReturn
(
'库存扣减失败['
.
$params
[
'order_id'
]
.
'-'
.
$v
[
'goods_id'
]
.
']'
,
-
10
);
}
// 扣除日志添加
$log_data
=
[
'order_id'
=>
$params
[
'order_id'
],
'goods_id'
=>
$v
[
'goods_id'
],
'order_status'
=>
$params
[
'order_data'
][
'status'
],
'original_inventory'
=>
$goods
[
'inventory'
],
'new_inventory'
=>
$goods
[
'inventory'
]
+
$v
[
'buy_number'
],
'add_time'
=>
time
(),
];
$log_m
->
add
(
$log_data
);
}
}
}
}
}
?>
\ No newline at end of file
service/Application/Service/OrderService.class.php
浏览文件 @
3e814ebd
...
...
@@ -4,6 +4,7 @@ namespace Service;
use
Service\GoodsService
;
use
Service\ResourcesService
;
use
Service\BuyService
;
/**
* 订单服务层
...
...
@@ -356,10 +357,17 @@ class OrderService
// 添加状态日志
if
(
self
::
OrderHistoryAdd
(
$params
[
'order'
][
'id'
],
2
,
$params
[
'order'
][
'status'
],
'支付'
,
0
,
'系统'
))
{
// 库存扣除
$ret
=
BuyService
::
OrderInventoryDeduct
([
'order_id'
=>
$params
[
'order'
][
'id'
],
'order_data'
=>
$upd_data
]);
if
(
$ret
[
'status'
]
!=
0
)
{
// 事务回滚
$m
->
rollback
();
return
DataReturn
(
$ret
[
'msg'
],
-
10
);
}
// 提交事务
$m
->
commit
();
// 成功
return
DataReturn
(
'支付成功'
,
0
);
}
}
...
...
shopxo.sql
浏览文件 @
3e814ebd
因为 它太大了无法显示 source diff 。你可以改为
查看blob
。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录