Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
goods
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bp
goods
Commits
aa0ce40f
Commit
aa0ce40f
authored
Aug 12, 2021
by
luhongguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update: 商品取消库存退回
parent
0412d525
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
12 deletions
+68
-12
Tcc.php
application/modules/Tcc/controllers/Tcc.php
+2
-0
Tcc2Service.php
application/services/tcc/Tcc2Service.php
+66
-12
No files found.
application/modules/Tcc/controllers/Tcc.php
View file @
aa0ce40f
...
...
@@ -67,6 +67,8 @@ class TccController extends Base
$res
=
Tcc2Service
::
cancelConfirm
(
$this
->
params
[
"keys"
]);
if
(
$res
)
{
$this
->
success
();
}
else
{
throw
new
GoodsException
([
"cus"
=>
27
]);
}
}
}
\ No newline at end of file
application/services/tcc/Tcc2Service.php
View file @
aa0ce40f
...
...
@@ -2,12 +2,14 @@
namespace
App\Services\tcc
;
use
Api\PhpUtils\Common\GoodsSkuId
;
use
App\Exception\custom\GoodsException
;
use
App\Models\goods\mysql\GoodsSku
;
use
App\Models\goods\mysql\PindanGoodsSku
;
use
App\Models\goods\mysql\Tcc
;
use
App\Models\marketing\mysql\Marketing
;
use
App\Models\marketing\mysql\MarketingPindan
;
use
App\Services\goods\MarketingPindanGoodsService
;
class
Tcc2Service
{
...
...
@@ -478,25 +480,42 @@ class Tcc2Service
return
self
::
TCC_RESULT_FAIL
;
}
$
goodsSkuIds
=
$numList
=
[]
;
$
isPindan
=
false
;
foreach
(
$goodsInfoList
as
$item
)
{
if
(
empty
(
$item
[
"goods_sku_id"
])
||
empty
(
$item
[
"num"
]))
{
return
self
::
TCC_RESULT_FAIL
;
}
$goodsSkuIds
[]
=
$item
[
"goods_sku_id"
];
$numList
[
$item
[
"goods_sku_id"
]]
=
$item
[
"num"
];
$goodsSukParams
=
GoodsSkuId
::
getGoodsSkuIdParams
(
$item
[
"goods_sku_id"
]);
if
(
!
empty
(
$goodsSukParams
))
{
if
(
isset
(
$goodsSukParams
[
"table_tag"
])
&&
(
$goodsSukParams
[
"table_tag"
]
==
GoodsSkuId
::
TABLE_TAG_PINDAN
))
{
$isPindan
=
true
;
}
}
}
$skus
=
GoodsSku
::
getRecords
([
"goods_sku_id"
=>
$goodsSkuIds
]
,
[
"goods_sku_id"
,
"total_amount_order"
,
"inventory_rest"
,
"inventory_lock"
,
"online_status"
]);
if
(
!
empty
(
$skus
))
{
if
(
$isPindan
)
{
return
self
::
pindanCancelConfirm
(
$goodsInfoList
);
}
else
{
return
self
::
generalCancelConfirm
(
$goodsInfoList
);
}
}
/**
* 普通订单退库存
* @param $goodsInfoList
* @return bool
* @throws GoodsException
*/
private
static
function
generalCancelConfirm
(
$goodsInfoList
)
{
if
(
!
empty
(
$goodsInfoList
))
{
GoodsSku
::
beginTransaction
();
foreach
(
$
skus
as
$sku
)
{
$goodsSkuId
=
$
sku
[
"goods_sku_id"
];
if
(
empty
(
$numList
[
$goodsSkuId
]))
{
return
self
::
TCC_RESULT_FAIL
;
}
$num
=
$numList
[
$goodsSkuId
]
;
foreach
(
$
goodsInfoList
as
$item
)
{
$goodsSkuId
=
$
item
[
"goods_sku_id"
];
$num
=
$item
[
"num"
];
$sku
=
GoodsSku
::
getRecord
([
"goods_sku_id"
=>
$goodsSkuId
]
,
[
"goods_sku_id"
,
"total_amount_order"
,
"inventory_rest"
,
"inventory_lock"
,
"online_status"
])
;
$params
=
[
"inventory_rest"
=>
$sku
[
"inventory_rest"
]
+
$num
,
"total_amount_order"
=>
$sku
[
"total_amount_order"
]
-
$num
,
...
...
@@ -515,6 +534,41 @@ class Tcc2Service
return
self
::
TCC_RESULT_SUCCESS
;
}
/**
* 拼单活动取消订单退库存
* @param $goodsInfoList
* @return bool
* @throws GoodsException
*/
private
static
function
pindanCancelConfirm
(
$goodsInfoList
)
{
if
(
!
empty
(
$goodsInfoList
))
{
PindanGoodsSku
::
beginTransaction
();
foreach
(
$goodsInfoList
as
$item
)
{
$goodsSkuId
=
$item
[
"goods_sku_id"
];
$num
=
$item
[
"num"
];
$sku
=
PindanGoodsSku
::
getRecord
([
"goods_sku_id"
=>
$goodsSkuId
]
,
[
"goods_sku_id"
,
"total_amount_order"
,
"inventory_rest"
,
"inventory_lock"
,
"online_status"
]);
$params
=
[
"inventory_rest"
=>
$sku
[
"inventory_rest"
]
+
$num
,
"total_amount_order"
=>
$sku
[
"total_amount_order"
]
-
$num
,
];
$rowCount
=
PindanGoodsSku
::
save
(
$params
,
[
"goods_sku_id"
=>
$goodsSkuId
,
"total_amount_order[>=]"
=>
$num
]);
if
(
$rowCount
<=
0
)
{
PindanGoodsSku
::
rollback
();
throw
new
GoodsException
([
"cus"
=>
32
]);
}
}
if
(
!
PindanGoodsSku
::
commit
())
{
PindanGoodsSku
::
rollback
();
}
}
return
self
::
TCC_RESULT_SUCCESS
;
}
/**
* 获取 tcc 数据记录
* @param $tid
...
...
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