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
be330efd
Commit
be330efd
authored
Apr 24, 2022
by
hangjun83
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复bug
parent
5ea9a62a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
70 additions
and
33 deletions
+70
-33
server/app/Services/BhOrdersService.php
server/app/Services/BhOrdersService.php
+70
-33
No files found.
server/app/Services/BhOrdersService.php
View file @
be330efd
...
...
@@ -16,8 +16,11 @@ use App\Repositories\Contracts\BhPordersRepository;
use
App\Repositories\Contracts\BhSoitemsRepository
;
use
App\Repositories\Contracts\BhSorderRefundRepository
;
use
App\Repositories\Contracts\BhSordersRepository
;
use
App\Repositories\Contracts\SysLogRepository
;
use
App\Repositories\Contracts\ToolsTaskRepository
;
use
App\Repositories\Criteria\BhPordersCriteria
;
use
App\Repositories\Criteria\BhSorderRefundCriteria
;
use
App\Repositories\Criteria\BhSorderRefundTaskLogCriteria
;
use
App\Repositories\Enums\ResponseCodeEnum
;
use
App\Repositories\Models\AdminUsers
;
use
App\Repositories\Models\BhPorders
;
...
...
@@ -237,7 +240,14 @@ class BhOrdersService
throw
new
\LogicException
(
'退货数量大于购买数量'
,
500
);
}
if
(
$orderitem
[
'si_num'
]
==
$refundInfo
->
refund_nums
){
// 统计有多少数量
$sum
=
$dbConnect
->
table
(
'soitems'
)
->
where
(
'so_id'
,
$orderitem
[
'so_id'
])
->
where
(
'si_id'
,
$orderitem
[
'si_id'
])
->
sum
(
'si_num'
);
// 如果是全部退货并且没有手续费的情况
if
(
$sum
==
$refundInfo
->
refund_nums
&&
$refundInfo
->
handle_fee
==
0
){
throw
new
\LogicException
(
'本功能不支持全部退货,如果需要全部退货请移步百化系统后台进行操作!'
,
500
);
}
...
...
@@ -322,6 +332,7 @@ class BhOrdersService
throw
new
\LogicException
(
'手续费异常,处理失败!'
,
500
);
}
}
/*If(isset($refundInfo->handle_fee) && $refundInfo->handle_fee > 0){
$updateArr['si_amount'] = bcadd($updateArr['si_amount'] , $refundInfo->handle_fee,2);
}
...
...
@@ -379,7 +390,7 @@ class BhOrdersService
$updatedItem
[
'total'
]
=
$currentAmount
;
//修改配货单记录
//修改配货单记录
if
(
$dpdetail
){
$maxRecord
=
$minRecord
=
[];
$needUpdate
=
null
;
...
...
@@ -417,31 +428,47 @@ class BhOrdersService
// 如果退货数量跟此明细数量相同,不需要拆分的情况下
if
(
!
is_null
(
$needUpdate
)){
$dpUpdateArr
=
[];
$dpUpdateArr
[
'si_id'
]
=
$updatedItem
[
'create'
][
'si_id'
];
// 如果有手续费,对价格进行更新
if
(
$refundInfo
->
handle_fee
>
0
){
// 如果有手续费,将价格进行修改
foreach
(
$dpdetail
as
$detail
){
if
(
$detail
->
dpd_id
!=
$needUpdate
[
'dpd_id'
]){
$otherUpdate
=
[];
$otherUpdate
[
'dpd_amount'
]
=
bcmul
(
$updatedItem
[
'update'
][
'si_discount'
],
$detail
->
dpd_num
,
2
);
$dbConnect
->
table
(
'dpdetail'
)
->
where
(
'dpd_id'
,
$detail
->
dpd_id
)
->
update
(
$otherUpdate
);
}
// 如果是全部退货
if
(
$refundInfo
->
refund_nums
==
$needUpdate
[
'dpd_num'
]
&&
count
(
$dpdetail
)
==
1
){
// 如果有手续费,将价格进行修改
foreach
(
$dpdetail
as
$detail
){
$otherUpdate
=
[];
$otherUpdate
[
'dpd_amount'
]
=
bcmul
(
$updatedItem
[
'update'
][
'si_discount'
],
$detail
->
dpd_num
,
2
);
$dbConnect
->
table
(
'dpdetail'
)
->
where
(
'dpd_id'
,
$detail
->
dpd_id
)
->
update
(
$otherUpdate
);
}
}
else
{
// 如果有手续费,将价格进行修改
foreach
(
$dpdetail
as
$detail
){
if
(
$detail
->
dpd_id
!=
$needUpdate
[
'dpd_id'
]){
$otherUpdate
=
[];
$otherUpdate
[
'dpd_amount'
]
=
bcmul
(
$updatedItem
[
'update'
][
'si_discount'
],
$detail
->
dpd_num
,
2
);
$dbConnect
->
table
(
'dpdetail'
)
->
where
(
'dpd_id'
,
$detail
->
dpd_id
)
->
update
(
$otherUpdate
);
}
}
$dpUpdateArr
[
'si_id'
]
=
$updatedItem
[
'create'
][
'si_id'
];
//将取消的记录价格进行更新
$dpUpdateArr
[
'dpd_amount'
]
=
bcmul
(
$updatedItem
[
'create'
][
'si_discount'
],
$needUpdate
[
'dpd_num'
],
2
);
$dbConnect
->
table
(
'dpdetail'
)
->
where
(
'dpd_id'
,
$needUpdate
[
'dpd_id'
])
->
update
(
$dpUpdateArr
);
}
//将取消的记录价格进行更新
$dpUpdateArr
[
'dpd_amount'
]
=
bcmul
(
$updatedItem
[
'create'
][
'si_discount'
],
$needUpdate
[
'dpd_num'
],
2
);
$dbConnect
->
table
(
'dpdetail'
)
->
where
(
'dpd_id'
,
$needUpdate
[
'dpd_id'
])
->
update
(
$dpUpdateArr
);
}
// 如果没有手续费,不对价格进行更新
else
{
/*else{
echo "<pre>";
print_r($needUpdate);
exit;
$dbConnect->table('dpdetail')
->where('dpd_id',$needUpdate['dpd_id'])
->update($dpUpdateArr);
}
}
*/
}
else
{
asort
(
$maxRecord
);
...
...
@@ -452,8 +479,24 @@ class BhOrdersService
// minrecord有值,只有退货数量大于此条记录的数量时
$cancelRecord
=
array_merge
(
$cancelRecord
,
$this
->
handleDpdetailInfo
(
$dbConnect
,
$num
,
$minRecord
,
$updatedItem
,
$refundInfo
,
'asort'
));
$cancelRecord
=
array_merge
(
$cancelRecord
,
$this
->
handleDpdetailInfo
(
$dbConnect
,
$num
,
$maxRecord
,
$updatedItem
,
$refundInfo
,
'arsort'
));
}
// 判断是否这次是全部取消
$dpCount
=
$dbConnect
->
table
(
'dpdetail'
)
->
where
(
'si_id'
,
$orderitem
[
'si_id'
])
->
whereIn
(
'dpd_id'
,
$cancelRecord
)
->
sum
(
'dpd_num'
);
if
(
$dpCount
==
0
&&
$sum
==
$refundInfo
->
refund_nums
){
$infos
=
$dbConnect
->
table
(
'dpdetail'
)
->
whereIn
(
'dpd_id'
,
$cancelRecord
)
->
get
();
foreach
(
$infos
->
toArray
()
as
$info
){
$update
=
[];
$update
[
'dpd_amount'
]
=
bcmul
(
$updatedItem
[
'update'
][
'si_discount'
],
$info
->
dpd_num
,
2
);
$update
[
'si_id'
]
=
$orderitem
[
'si_id'
];
$dbConnect
->
table
(
'dpdetail'
)
->
where
(
'dpd_id'
,
$info
->
dpd_id
)
->
update
(
$update
);
}
}
}
// 更新除了取消的记录以外的记录的价格
if
(
count
(
$cancelRecord
)
>
0
){
$dpdetailInfo
=
$dbConnect
->
table
(
'dpdetail'
)
...
...
@@ -639,7 +682,6 @@ class BhOrdersService
$dpCreateArr
[
'dpd_amount'
]
=
bcmul
(
$updatedItem
[
'create'
][
'si_discount'
],
$num
,
2
);
$dpCreateArr
[
'si_id'
]
=
$updatedItem
[
'create'
][
'si_id'
];
$dpId
=
$dbConnect
->
table
(
'dpdetail'
)
->
insertGetId
(
$dpCreateArr
);
$num
=
0
;
$cancelRecord
[]
=
$dpId
;
}
...
...
@@ -975,19 +1017,14 @@ class BhOrdersService
{
$params
=
$this
->
formatKeysfromArray
(
$request
->
all
(),
'toUnderScore'
);
$this
->
bhPordersRepository
->
pushCriteria
(
new
BhPordersCriteria
(
$request
));
$pOrdersList
=
$this
->
bhPordersRepository
->
paginate
(
$params
[
'page_size'
]);
$returnRecord
=
[];
if
(
$pOrdersList
){
$record
=
$this
->
procOrderResponseData
(
$pOrdersList
->
items
());
if
(
!
isset
(
$params
[
'type'
])
||
empty
(
$params
[
'type'
])){
$params
[
'type'
]
=
'sorder_refund'
;
}
// 获取当前角色的所有权限
$returnRecord
[
'data'
]
=
$this
->
formatKeysfromArray
(
$record
);
$returnRecord
[
'current_page'
]
=
$pOrdersList
->
currentPage
();
$returnRecord
[
'total'
]
=
$pOrdersList
->
total
();
return
$returnRecord
;
}
$taskService
=
app
(
ToolsTaskRepository
::
class
);
$taskLogsList
=
$taskService
->
getTaskLogsFromType
(
$params
[
'type'
],
$params
[
'task_id'
]);
return
$taskLogsList
;
}
}
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