Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
E
ERP_EXAMPLE
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
戚鸿镇
ERP_EXAMPLE
Commits
b8275540
提交
b8275540
authored
2月 14, 2025
作者:
qhz
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
【开发】增加案例
上级
1f1269df
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
215 行增加
和
0 行删除
+215
-0
Application.php
Erp/Jushuitan/Application.php
+0
-0
Base.php
Erp/Jushuitan/Base.php
+0
-0
Route.php
Erp/Jushuitan/Route.php
+0
-0
JushuitanService.php
Service/Erp/Jushuitan/JushuitanService.php
+65
-0
OutSpecialParameterTrait.php
Service/Erp/Jushuitan/OutSpecialParameterTrait.php
+78
-0
orderOutTrait.php
Service/Erp/Jushuitan/orderOutTrait.php
+72
-0
没有找到文件。
Erp/Jushuitan/Application.php
0 → 100644
浏览文件 @
b8275540
Erp/Jushuitan/Base.php
0 → 100644
浏览文件 @
b8275540
Erp/Jushuitan/Route.php
0 → 100644
浏览文件 @
b8275540
Service/Erp/Jushuitan/JushuitanService.php
0 → 100644
浏览文件 @
b8275540
<?php
namespace
app\Erp\Jushuitan\Route
;
use
app\Service\Erp\Jushuitan\OutSpecialParameterTrait
;
use
app\Service\Erp\Jushuitan\orderOutTrait
;
class
JushuitanService
{
use
OutSpecialParameterTrait
;
use
orderOutTrait
;
private
$logger
;
private
$erp
;
private
$sync_out_sn
=
[];
// 全局出货单号,用于过滤
private
$config
=
[];
private
$outOrder
=
[];
// 过滤后的数据
protected
function
syncOrderOut
(
$modified_begin
,
$modified_end
,
$status
,
$params
)
{
$page_index
=
$data_count
=
1
;
$this
->
sync_out_sn
=
[];
try
{
do
{
$request_params
=
[
//status-Confirmed:已出库 WaitConfirm:待出库
'status'
=>
$status
,
'modified_begin'
=>
$modified_begin
,
'modified_end'
=>
$modified_end
,
'page_index'
=>
$page_index
,
'page_size'
=>
50
,
];
// 对参数特殊处理处理
$request_params
=
$this
->
requestParamsHadnle
(
$request_params
);
// 出货处理
$res
=
$this
->
erp
->
sendBizRequest
(
Route
::
QUERY_ORDER_OUT_SIMPLE
,
$request_params
);
$data_count
=
$res
[
'data'
][
'data_count'
];
//没有数据了
if
(
$page_index
>
$res
[
'data'
][
'page_count'
]
&&
empty
(
$res
[
'data'
][
'datas'
])){
break
;
}
// 数据过滤处理
$this
->
outWarehousing
(
$data
);
/**
* 1. 后置数据处理
* 1. 写入经销商
* 2. 写入商品
* 3. 需要更新的数据
*/
$this
->
insertPorduct
();
$page_index
++
;
}
while
(
$page_index
<=
$data_count
);
}
catch
(
\Exception
$e
)
{
$logger
->
error
(
$e
->
getMessage
());
}
}
}
\ No newline at end of file
Service/Erp/Jushuitan/OutSpecialParameterTrait.php
0 → 100644
浏览文件 @
b8275540
<?php
namespace
app\Service\Erp\jushuitan
;
trait
OutSpecialParameterTrait
{
public
$OutFilterFunction
=
[
'waitStatutHandler'
,
// 出库单处理
'OutDiffHandler'
,
// 重复出库单处理
'globalOutOrderHanlder'
// 全局重复出库处理
];
public
function
requestParamsHadnle
(
$requestParams
)
{
if
(
isset
(
$requestParams
[
'is_document'
])
&&
$requestParams
[
'is_document'
]
==
1
){
unset
(
$requestParams
[
'status'
],
$requestParams
[
'modified_begin'
],
$requestParams
[
'modified_end'
]);
}
return
$requestParams
;
}
// 出货商品数据过滤入口
public
function
OutSpecialParameterHandler
(
$args
)
{
$status
=
false
;
foreach
(
$this
->
OutFilterFunction
as
$func
)
{
$res
=
call_user_func_array
([
$this
,
$func
],
$args
);
if
(
$res
)
{
$status
=
true
;
break
;
}
}
return
$status
;
}
// 出库单处理
public
function
waitStatutHandler
(
$array
)
{
$data
=
$array
[
'data'
];
if
(
in_array
(
$data
[
'l_id'
],
$this
->
wait
)){
//只需要写入ydd_fch_out_warehousing表
$this
->
is_wait
=
1
;
//只需要更新出库码表、出库商品表的出库单号
$this
->
update_code_sn
[]
=
[
'out_warehousing_sn'
=>
$data
[
'io_id'
],
'logistics_code'
=>
$data
[
'l_id'
],
];
$this
->
wait_logistics_code
[]
=
$data
[
'l_id'
];
}
}
// 重复出库单处理
public
function
OutDiffHandler
(
$array
)
{
$data
=
$array
[
'data'
];
$diff
=
$array
[
'diff'
];
$status
=
false
;
//校验订单号是否在待写入的单号中
if
(
!
in_array
(
$data
[
'io_id'
],
$diff
)){
$status
=
true
;
}
return
$status
;
}
// 全局出库单重复过滤
public
function
globalOutOrderHanlder
(
$array
)
{
$data
=
$array
[
'data'
];
$status
=
false
;
if
(
in_array
(
$data
[
'io_id'
],
$this
->
sync_out_sn
)){
$data
=
true
;
}
return
$status
;
}
}
\ No newline at end of file
Service/Erp/Jushuitan/orderOutTrait.php
0 → 100644
浏览文件 @
b8275540
<?php
use
app\Service\Erp\Jushuitan
;
trait
orderOutTrait
{
public
$is_wait
=
0
;
public
$wait
=
[];
public
$jst_out
=
[];
public
$dealderData
=
[];
public
$product
=
[];
public
$update_code_sn
=
[];
public
$wait_logistics_code
=
[];
protected
function
outWarehousing
(
$data
)
{
$out_sn
=
array_column
(
$data
,
'io_id'
);
//校验出库单是否已存在
$erp_out
=
ErpJushuitanOutWarehousing
::
query
()
->
where
(
'brand_id'
,
$this
->
brandId
)
->
whereIn
(
'io_id'
,
$out_sn
)
->
pluck
(
'io_id'
,
'id'
)
->
toArray
();
$diff
=
array_diff
(
$out_sn
,
$erp_out
);
if
(
$this
->
brandId
==
Erp
::
ERP_SYNC_OUT_PRODUCT_DESIGNATED
){
$default_product
=
$this
->
getProductByIdAsc
(
$this
->
brandId
);
if
(
!
$default_product
){
throw
new
\Exception
(
"请先添加一个单规格商品brandId:"
.
$this
->
brandId
);
}
}
foreach
(
$data
as
$v
)
{
$continue
=
$this
->
OutSpecialParameterHandler
([
'data'
=>
$v
,
'diff'
=>
$diff
]);
if
(
$continue
)
{
continue
;
}
$out
=
$this
->
jstOutWarehousingAttribute
(
$data
);
$this
->
jst_out
=
$out
;
array_push
(
$sync_out_sn
,
$v
[
'io_id'
]);
}
}
// 原始出库单数据格式
protected
function
jstOutWarehousingAttribute
(
$data
,
$io_source_type
=
1
)
{
$res
=
[];
return
$res
;
}
// 商品数据写入
public
function
insertPorduct
()
{
if
(
$this
->
product
)
{
//产品写入
Db
::
connection
(
'brand'
)
->
transaction
(
function
()
{
foreach
(
$this
->
product
as
$goods
){
$sku
=
$goods
[
'sku_data'
];
unset
(
$goods
[
'sku_data'
]);
$product
=
Product
::
create
(
$goods
);
$sku
[
'product_id'
]
=
$product
->
id
;
ProductSku
::
create
(
$sku
);
}
});
}
}
}
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论