Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
openApi
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hj
openApi
Commits
40c47280
Commit
40c47280
authored
Jun 08, 2022
by
hangjun83
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
罗恩工具类更新
parent
36251951
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
171 additions
and
143 deletions
+171
-143
server/app/Services/RhawnOrdersService.php
server/app/Services/RhawnOrdersService.php
+171
-143
No files found.
server/app/Services/RhawnOrdersService.php
View file @
40c47280
...
@@ -340,7 +340,7 @@ class RhawnOrdersService
...
@@ -340,7 +340,7 @@ class RhawnOrdersService
$pstk_ids
[]
=
$pstkArr
[
0
];
$pstk_ids
[]
=
$pstkArr
[
0
];
}
}
//分组查询发货数量
//分组查询发货数量
$dpdSum
=
$dbConnect
->
table
(
'dpdetail'
)
/*
$dpdSum = $dbConnect->table('dpdetail')
->whereIn('pstk_id', $pstk_ids)
->whereIn('pstk_id', $pstk_ids)
->where('dpd_invoiced', '=', 0)
->where('dpd_invoiced', '=', 0)
->groupBy('pstk_id')
->groupBy('pstk_id')
...
@@ -359,11 +359,11 @@ class RhawnOrdersService
...
@@ -359,11 +359,11 @@ class RhawnOrdersService
throw new \LogicException('退货数量大于购买数量', 500);
throw new \LogicException('退货数量大于购买数量', 500);
}
}
}
}
});
});
*/
}
}
// 如果是期货,强行初始一个数组执行一次
// 如果是期货,强行初始一个数组执行一次
if
(
$futuresNum
>
0
){
if
(
$futuresNum
>
0
&&
empty
(
$refundNums
)
){
$refundNums
[
0
]
=
$futuresNum
;
$refundNums
[
0
]
=
$futuresNum
;
}
}
...
@@ -371,12 +371,7 @@ class RhawnOrdersService
...
@@ -371,12 +371,7 @@ class RhawnOrdersService
foreach
(
$refundNums
as
$pstk_id
=>
$num
)
{
foreach
(
$refundNums
as
$pstk_id
=>
$num
)
{
$currentProcessNums
=
$num
;
while
(
true
)
{
// 如果有期货数量优先处理
if
(
$futuresNum
>
0
)
{
$currentProcessNums
=
$futuresNum
;
}
//修改item数据项
//修改item数据项
$service
=
app
(
RhawnSoitemsRepository
::
class
);
$service
=
app
(
RhawnSoitemsRepository
::
class
);
...
@@ -386,14 +381,48 @@ class RhawnOrdersService
...
@@ -386,14 +381,48 @@ class RhawnOrdersService
throw
new
\LogicException
(
'购买项数据id:'
.
$orderitem
[
'si_id'
]
.
'数据不存在或已取消!'
,
500
);
throw
new
\LogicException
(
'购买项数据id:'
.
$orderitem
[
'si_id'
]
.
'数据不存在或已取消!'
,
500
);
}
}
// 判断有期货的时候退货数量是否大于soitem的数量
//如果有退货期货,检查退货期货数量是否大于当前期货数量
if
(
$futuresNum
>
0
&&
$futuresNum
>
$soItem
[
'si_assigned_num'
]){
if
(
$futuresNum
>
0
)
{
throw
new
\LogicException
(
'期货退货数量大于已分配数量'
,
500
);
if
(
$pstk_id
>
0
){
$dpdSum
=
$dbConnect
->
table
(
'dpdetail'
)
->
where
(
'pstk_id'
,
$pstk_id
)
->
where
(
'si_id'
,
$refundInfo
->
item_id
)
->
where
(
'dpd_invoiced'
,
'='
,
0
)
->
groupBy
(
'pstk_id'
)
->
select
(
DB
::
raw
(
"sum(dpd_num) as num"
),)
->
get
()
->
first
();
}
else
{
$dpdSum
=
$dbConnect
->
table
(
'dpdetail'
)
->
where
(
'si_id'
,
$refundInfo
->
item_id
)
->
where
(
'dpd_invoiced'
,
'='
,
0
)
->
select
(
DB
::
raw
(
"sum(dpd_num) as num"
),)
->
get
()
->
first
();
}
if
((
$soItem
[
'si_num'
]
-
$dpdSum
->
num
)
==
0
){
$futuresNum
=
0
;
if
(
$pstk_id
==
0
){
throw
new
\LogicException
(
'当前数据不存在期货,无法对期货进行退货'
,
500
);
}
}
if
(
$futuresNum
>
0
)
{
if
(
$futuresNum
>
(
$soItem
[
'si_num'
]
-
$dpdSum
->
num
))
{
throw
new
\LogicException
(
'期货退货数量大于可退货数量'
,
500
);
}
}
}
}
// 判断现货退货数量是否大于soitem的数量
// 判断现货退货数量是否大于soitem的数量
if
(
$num
>
(
$soItem
[
'si_num'
]
-
$soItem
[
'si_assigned_num'
])){
if
(
$num
>
$soItem
[
'si_num'
])
{
throw
new
\LogicException
(
'现货退货数量大于已分配数量'
,
500
);
throw
new
\LogicException
(
'现货退货数量大于可退货数量'
,
500
);
}
// 如果有期货数量优先处理
if
(
$futuresNum
>
0
)
{
$currentProcessNums
=
$futuresNum
;
}
else
{
$currentProcessNums
=
$num
;
}
}
//更新原本数据
//更新原本数据
...
@@ -427,10 +456,10 @@ class RhawnOrdersService
...
@@ -427,10 +456,10 @@ class RhawnOrdersService
if
(
$futuresNum
>
0
)
{
if
(
$futuresNum
>
0
)
{
$updateArr
[
'si_num'
]
=
$orderitem
[
'si_num'
]
-
$futuresNum
;
$updateArr
[
'si_num'
]
=
$orderitem
[
'si_num'
]
-
$futuresNum
;
$updateArr
[
'si_assigned_num'
]
=
$orderitem
[
'si_assigned_num'
]
-
$futuresNum
;
//
$updateArr['si_assigned_num'] = $orderitem['si_assigned_num'] - $futuresNum;
}
else
{
}
else
{
$updateArr
[
'si_num'
]
=
bcsub
(
$orderitem
[
'si_num'
],
$currentProcessNums
);
// 如果数量只有1,且退货数量相等
$updateArr
[
'si_num'
]
=
bcsub
(
$orderitem
[
'si_num'
],
$currentProcessNums
);
// 如果数量只有1,且退货数量相等
//
$updateArr['si_assigned_num'] = $updateArr['si_num'];
$updateArr
[
'si_assigned_num'
]
=
$updateArr
[
'si_num'
];
}
}
$updateArr
[
'si_amount'
]
=
bcmul
(
$updateArr
[
'si_amount'
]
=
bcmul
(
...
@@ -507,13 +536,13 @@ class RhawnOrdersService
...
@@ -507,13 +536,13 @@ class RhawnOrdersService
->
get
()
->
first
();
->
get
()
->
first
();
//$dpdDetail = $dpdDetail->toArray();
//$dpdDetail = $dpdDetail->toArray();
if
(
$dpdDetail
)
{
if
(
$dpdDetail
)
{
// 更新当前记录
// 更新当前记录
$dpUpdateArr
=
[];
$dpUpdateArr
=
[];
$dpUpdateArr
[
'dpd_num'
]
=
$dpdDetail
->
dpd_num
-
$currentProcessNums
;
$dpUpdateArr
[
'dpd_num'
]
=
$dpdDetail
->
dpd_num
-
$currentProcessNums
;
$dpUpdateArr
[
'dpd_amount'
]
=
bcmul
(
$updatedItem
[
'update'
][
'si_discount'
],
$dpUpdateArr
[
'dpd_num'
],
2
);
$dpUpdateArr
[
'dpd_amount'
]
=
bcmul
(
$updatedItem
[
'update'
][
'si_discount'
],
$dpUpdateArr
[
'dpd_num'
],
2
);
$dbConnect
->
table
(
'dpdetail'
)
$dbConnect
->
table
(
'dpdetail'
)
->
where
(
'dpd_id'
,
$dpdDetail
->
dpd_id
)
->
where
(
'dpd_id'
,
$dpdDetail
->
dpd_id
)
->
update
(
$dpUpdateArr
);
->
update
(
$dpUpdateArr
);
// 如果是部分退货
// 如果是部分退货
if
(
$currentProcessNums
<
$dpdDetail
->
dpd_num
)
{
if
(
$currentProcessNums
<
$dpdDetail
->
dpd_num
)
{
...
@@ -531,12 +560,10 @@ class RhawnOrdersService
...
@@ -531,12 +560,10 @@ class RhawnOrdersService
//预存款和退款处理
//预存款和退款处理
$this
->
cancelAndTransPrePay
(
$dbConnect
,
$updatedItem
[
'cancel_si_id'
],
$refundInfo
);
$this
->
cancelAndTransPrePay
(
$dbConnect
,
$updatedItem
[
'cancel_si_id'
],
$refundInfo
);
if
(
$currentProcessNums
>
0
)
{
if
(
$futuresNum
>
0
)
{
if
(
$futuresNum
>
0
)
{
$futuresNum
=
0
;
$futuresNum
=
0
;
}
$currentProcessNums
=
0
;
$currentProcessNums
=
0
;
if
(
empty
(
$numArr
))
break
;
}
else
{
}
else
{
break
;
break
;
}
}
...
@@ -544,6 +571,7 @@ class RhawnOrdersService
...
@@ -544,6 +571,7 @@ class RhawnOrdersService
}
}
}
}
}
}
}
$dbConnect
->
commit
();
$dbConnect
->
commit
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment