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
f72988bc
Commit
f72988bc
authored
Apr 24, 2022
by
hangjun83
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复bug
parent
8b86c936
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
33 deletions
+31
-33
server/app/Services/BhOrdersService.php
server/app/Services/BhOrdersService.php
+31
-33
No files found.
server/app/Services/BhOrdersService.php
View file @
f72988bc
...
...
@@ -157,18 +157,12 @@ class BhOrdersService
$params
[
'page_size'
]
=
10
;
}
$request
->
attributes
->
add
([
'type'
=>
'sorder_refund'
]);
$repostiroy
=
app
(
BhSorderRefundRepository
::
class
);
$repostiroy
->
pushCriteria
(
new
BhSorderRefundCriteria
(
$request
));
$tasks
=
$repostiroy
->
customPaginate
(
$params
[
'page_size'
]);
$service
=
app
(
BhSorderRefundRepository
::
class
);
$service
->
pushCriteria
(
new
BhSorderRefundCriteria
(
$request
));
$tasks
=
$service
->
paginate
(
$params
[
'page_size'
]);
$returnRecord
=
[];
if
(
$tasks
){
$allItems
=
$tasks
->
items
();
$allItems
=
collect
(
$allItems
)
->
map
(
function
(
$item
){
$item
=
$item
->
toArray
();
$allItems
=
collect
(
$tasks
[
'data'
])
->
map
(
function
(
$item
){
$contentArr
=
[];
$execArr
=
json_decode
(
$item
[
'exec_content'
],
true
);
foreach
(
$execArr
as
$key
=>
$content
){
...
...
@@ -191,17 +185,13 @@ class BhOrdersService
$item
[
'content_string'
]
=
implode
(
' . '
,
$contentArr
);
$item
=
array_merge
(
$item
,
$execArr
);
return
$item
;
});
// 获取当前角色的所有权限
$returnRecord
[
'data'
]
=
$this
->
formatKeysfromArray
(
$allItems
);
$returnRecord
[
'current_page'
]
=
$tasks
->
currentPage
();
$returnRecord
[
'total'
]
=
$tasks
->
total
();
$tasks
[
'data'
]
=
$allItems
->
toArray
();
$tasks
=
$this
->
formatKeysfromArray
(
$tasks
);
}
return
$
returnRecord
;
return
$
tasks
;
}
/**
...
...
@@ -240,8 +230,8 @@ class BhOrdersService
// 先处理源数据
$currentPrice
=
floatval
(
$orderitem
[
'si_discount'
]);
$currentAmount
=
floatval
(
$orderitem
[
'si_amount'
]);
//
减去退货数量,剩余的更新
数量
$num
=
intval
(
$
orderitem
[
'si_num'
])
-
intval
(
$
refundInfo
->
refund_nums
);
//
退货剩余
数量
$num
=
intval
(
$refundInfo
->
refund_nums
);
if
(
$num
<
0
){
throw
new
\LogicException
(
'退货数量大于购买数量'
,
500
);
...
...
@@ -273,7 +263,7 @@ class BhOrdersService
$updatedItem
=
[];
//如果取消的是全部
if
(
$num
==
0
){
if
(
(
$num
-
$orderitem
[
'si_num'
])
==
0
){
// 如果需要手续费
if
(
isset
(
$refundInfo
->
handle_fee
)
&&
$refundInfo
->
handle_fee
>
0
){
...
...
@@ -306,7 +296,7 @@ class BhOrdersService
if
(
isset
(
$refundInfo
->
handle_fee
)
&&
$refundInfo
->
handle_fee
>
0
){
$updateArr
[
'si_amount'
]
=
bcadd
(
$updateArr
[
'si_amount'
]
,
$refundInfo
->
handle_fee
,
2
);
}
$updateArr
[
'si_discount'
]
=
bcdiv
(
$updateArr
[
'si_amount'
]
,
$num
,
2
);
$updateArr
[
'si_discount'
]
=
bcdiv
(
$updateArr
[
'si_amount'
]
,
$updateArr
[
'si_num'
]
,
2
);
// 新增
$createArr
=
$soItem
;
...
...
@@ -346,8 +336,9 @@ class BhOrdersService
//判断是否能除尽
if
(
!
empty
(
$updateArr
)){
if
(
$updateArr
[
'si_amount'
]
!=
$currentAmount
&&
abs
(
bcsub
(
$currentAmount
,
$updateArr
[
'si_amount'
]))
<
1
){
$note
[]
=
$soItem
[
'si_id'
]
.
'金额有小数'
;
$amount
=
bcmul
(
$updateArr
[
'si_discount'
],
$updateArr
[
'si_num'
],
2
);
if
(
$updateArr
[
'si_amount'
]
!=
$amount
){
$note
[]
=
'si_id = '
.
$soItem
[
'si_id'
]
.
'的数据有除不尽的情况,请手工处理'
;
}
}
...
...
@@ -416,25 +407,25 @@ class BhOrdersService
}
$cancelRecord
=
[];
// 如果退货数量跟此明细数量相同
// 如果退货数量跟此明细数量相同
,不需要拆分的情况下
if
(
!
is_null
(
$needUpdate
)){
$dpUpdateArr
=
[];
$dpUpdateArr
[
'si_id'
]
=
$updatedItem
[
'
upd
ate'
][
'si_id'
];
$dpUpdateArr
[
'si_id'
]
=
$updatedItem
[
'
cre
ate'
][
'si_id'
];
// 如果有手续费,对价格进行更新
if
(
$refundInfo
->
handle_fee
>
0
){
// 如果有手续费,将价格进行修改
/*
foreach($dpdetail as $detail){
foreach
(
$dpdetail
as
$detail
){
if
(
$detail
->
dpd_id
!=
$needUpdate
[
'dpd_id'
]){
$otherUpdate
=
[];
$otherUpdate['dpd_amount'] = bcmul($updatedItem['update']['si_discount'], $
needUpdate['dpd_num']
, 2);
$otherUpdate
[
'dpd_amount'
]
=
bcmul
(
$updatedItem
[
'update'
][
'si_discount'
],
$
detail
->
dpd_num
,
2
);
$dbConnect
->
table
(
'dpdetail'
)
->where('dpd_id',$d
pd
etail->dpd_id)
->
where
(
'dpd_id'
,
$detail
->
dpd_id
)
->
update
(
$otherUpdate
);
}
}
*/
}
//将取消的记录价格进行更新
$dpUpdateArr
[
'dpd_amount'
]
=
bcmul
(
$updatedItem
[
'
upd
ate'
][
'si_discount'
],
$needUpdate
[
'dpd_num'
],
2
);
$dpUpdateArr
[
'dpd_amount'
]
=
bcmul
(
$updatedItem
[
'
cre
ate'
][
'si_discount'
],
$needUpdate
[
'dpd_num'
],
2
);
$dbConnect
->
table
(
'dpdetail'
)
->
where
(
'dpd_id'
,
$needUpdate
[
'dpd_id'
])
->
update
(
$dpUpdateArr
);
...
...
@@ -465,7 +456,7 @@ class BhOrdersService
if
(
count
(
$dpdetailInfo
)
>
0
){
foreach
(
$dpdetailInfo
as
$info
){
$otherUpdate
=
[];
$otherUpdate
[
'dpd_amount'
]
=
bcmul
(
$update
Arr
[
'si_discount'
],
$info
->
dpd_num
,
2
);
$otherUpdate
[
'dpd_amount'
]
=
bcmul
(
$update
dItem
[
'update'
]
[
'si_discount'
],
$info
->
dpd_num
,
2
);
$dbConnect
->
table
(
'dpdetail'
)
->
where
(
'dpd_id'
,
$info
->
dpd_id
)
->
update
(
$otherUpdate
);
...
...
@@ -606,7 +597,13 @@ class BhOrdersService
$num
=
$num
-
$re
[
'dpd_num'
];
$dpUpdateArr
=
[];
//$dpUpdateArr['si_id'] = $updatedItem['update']['si_id'];
$dpUpdateArr
[
'dpd_amount'
]
=
bcmul
(
$updatedItem
[
'update'
][
'si_discount'
],
$re
[
'dpd_num'
],
2
);
/*if($num > $re['dpd_num']){
$dpUpdateArr['dpd_amount'] = bcmul($updatedItem['create']['si_discount'], $re['dpd_num'], 2);
}else{
$dpUpdateArr['dpd_amount'] = bcmul($updatedItem['update']['si_discount'], $re['dpd_num'], 2);
}*/
$dpUpdateArr
[
'si_id'
]
=
$updatedItem
[
'create'
][
'si_id'
];
$dpUpdateArr
[
'dpd_amount'
]
=
bcmul
(
$updatedItem
[
'create'
][
'si_discount'
],
$re
[
'dpd_num'
],
2
);
$dbConnect
->
table
(
'dpdetail'
)
->
where
(
'dpd_id'
,
$re
[
'dpd_id'
])
->
update
(
$dpUpdateArr
);
...
...
@@ -619,7 +616,8 @@ class BhOrdersService
// 更新当前记录
$dpUpdateArr
=
[];
$dpUpdateArr
[
'dpd_num'
]
=
$re
[
'dpd_num'
]
-
$num
;
$dpUpdateArr
[
'dpd_amount'
]
=
bcsub
(
$updatedItem
[
'total'
],
$updatedItem
[
'create'
][
'si_amount'
],
2
);
//$dpUpdateArr['dpd_amount'] = bcsub($updatedItem['total'], $updatedItem['update']['si_amount'], 2);
$dpUpdateArr
[
'dpd_amount'
]
=
bcmul
(
$updatedItem
[
'update'
][
'si_discount'
],
$dpUpdateArr
[
'dpd_num'
],
2
);
$dbConnect
->
table
(
'dpdetail'
)
->
where
(
'dpd_id'
,
$re
[
'dpd_id'
])
->
update
(
$dpUpdateArr
);
...
...
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