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
523222ef
Commit
523222ef
authored
Jul 02, 2021
by
luhongguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update:tcc cancel逻辑调整
parent
c37e14a6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
8 deletions
+53
-8
GoodsTccCancelValidate.php
application/library/Validate/GoodsTccCancelValidate.php
+25
-0
Tcc.php
application/modules/Tcc/controllers/Tcc.php
+3
-2
TccService.php
application/services/tcc/TccService.php
+25
-6
No files found.
application/library/Validate/GoodsTccCancelValidate.php
0 → 100644
View file @
523222ef
<?php
namespace
Validate
;
/**
* Class GoodsTccCancelValidate
*
* @package Validate
*/
class
GoodsTccCancelValidate
extends
BaseValidate
{
protected
$rule
=
[
'tid'
=>
'require'
,
'keys'
=>
'require'
,
'type'
=>
'require'
,
];
protected
$message
=
[
"tid"
=>
"tcc事务id不能为空"
,
"keys"
=>
"商品信息不能为空"
,
"type"
=>
"类型字段不能为空"
,
];
}
\ No newline at end of file
application/modules/Tcc/controllers/Tcc.php
View file @
523222ef
...
...
@@ -4,6 +4,7 @@ use App\Base\Base;
use
App\Exception\custom\GoodsException
;
use
\Validate\GoodsTccValidate
;
use
\Validate\GoodsTccIsFinishValidate
;
use
\Validate\GoodsTccCancelValidate
;
use
\App\Services\tcc\TccService
;
...
...
@@ -84,9 +85,9 @@ class TccController extends Base
*/
public
function
cancel_order_confirmAction
()
{
(
new
GoodsTccValidate
())
->
validate
();
(
new
GoodsTcc
Cancel
Validate
())
->
validate
();
$res
=
TccService
::
cancelOrderConfirm
(
$this
->
params
[
"keys"
],
$this
->
params
[
"tid"
]);
$res
=
TccService
::
cancelOrderConfirm
(
$this
->
params
[
"keys"
],
$this
->
params
[
"tid"
]
,
$this
->
params
[
"type"
]
);
if
(
$res
)
{
$this
->
success
();
}
else
{
...
...
application/services/tcc/TccService.php
View file @
523222ef
...
...
@@ -14,6 +14,9 @@ class TccService
const
TCC_RESULT_FAIL
=
false
;
const
TCC_RESULT_SUCCESS
=
true
;
const
TYPE_CANCEL_ORDER
=
1
;
const
TYPE_BACK_ORDER
=
2
;
/**
* 下单 商品tcc try
* @param $keys
...
...
@@ -482,9 +485,10 @@ class TccService
* 取消订单单 商品tcc confirm
* @param $keys
* @param $tid
* @param $type
* @return int
*/
public
static
function
cancelOrderConfirm
(
$keys
,
$tid
)
public
static
function
cancelOrderConfirm
(
$keys
,
$tid
,
$type
)
{
$goodsInfoList
=
json_decode
(
$keys
,
true
);
if
(
empty
(
$goodsInfoList
))
{
...
...
@@ -546,7 +550,7 @@ class TccService
}
$skus
=
GoodsSku
::
getRecords
([
"goods_sku_id"
=>
$goodsSkuIds
]
,
[
"goods_sku_id"
,
"inventory_rest"
,
"inventory_lock"
,
"online_status"
]);
,
[
"goods_sku_id"
,
"
total_amount_sold"
,
"
inventory_rest"
,
"inventory_lock"
,
"online_status"
]);
if
(
!
empty
(
$skus
))
{
GoodsSku
::
beginTransaction
();
foreach
(
$skus
as
$sku
)
{
...
...
@@ -563,10 +567,25 @@ class TccService
return
self
::
TCC_RESULT_FAIL
;
}
GoodsSku
::
save
([
"inventory_lock"
=>
$sku
[
"inventory_lock"
]
-
$num
,
"inventory_rest"
=>
$sku
[
"inventory_rest"
]
+
$num
,
],
[
"goods_sku_id"
=>
$goodsSkuId
]);
if
(
$type
==
self
::
TYPE_CANCEL_ORDER
)
{
$params
=
[
"inventory_lock"
=>
$sku
[
"inventory_lock"
]
-
$num
,
"inventory_rest"
=>
$sku
[
"inventory_rest"
]
+
$num
,
];
}
if
(
$type
==
self
::
TYPE_BACK_ORDER
)
{
if
(
$sku
[
"total_amount_sold"
]
<
$num
)
{
GoodsSku
::
rollback
();
return
self
::
TCC_RESULT_FAIL
;
}
$params
=
[
"inventory_lock"
=>
$sku
[
"inventory_lock"
]
-
$num
,
"inventory_rest"
=>
$sku
[
"inventory_rest"
]
+
$num
,
"total_amount_sold"
=>
$sku
[
"total_amount_sold"
]
-
$num
,
];
}
GoodsSku
::
save
(
$params
,
[
"goods_sku_id"
=>
$goodsSkuId
]);
Tcc
::
save
([
"tid"
=>
$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