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
80cad87e
Commit
80cad87e
authored
Aug 10, 2021
by
luhongguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update:goods tcc 提示修改
parent
8fc82418
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
19 deletions
+23
-19
GoodsException.php
application/exception/custom/GoodsException.php
+5
-0
Tcc2Service.php
application/services/tcc/Tcc2Service.php
+18
-19
No files found.
application/exception/custom/GoodsException.php
View file @
80cad87e
...
...
@@ -58,5 +58,10 @@ class GoodsException extends BaseException
39
=>
'结算价不能大于售价'
,
40
=>
'结算价不符合标准'
,
41
=>
'商品id非法'
,
42
=>
'TCC 参数错误'
,
43
=>
'TCC 商品非上架状态'
,
44
=>
'TCC 事务commit失败'
,
45
=>
'TCC 还没有try,就去执行confirm'
,
46
=>
'TCC 已经执行过cancel'
,
];
}
\ No newline at end of file
application/services/tcc/Tcc2Service.php
View file @
80cad87e
...
...
@@ -24,13 +24,13 @@ class Tcc2Service
{
$goodsInfoList
=
json_decode
(
$keys
,
true
);
if
(
empty
(
$goodsInfoList
))
{
return
self
::
TCC_RESULT_FAIL
;
throw
new
GoodsException
([
"cus"
=>
42
])
;
}
$isPindan
=
false
;
foreach
(
$goodsInfoList
as
$item
)
{
if
(
empty
(
$item
[
"goods_sku_id"
])
||
empty
(
$item
[
"num"
]))
{
return
self
::
TCC_RESULT_FAIL
;
throw
new
GoodsException
([
"cus"
=>
42
])
;
}
if
(
!
empty
(
$item
[
"marketing_id"
])
&&
!
empty
(
$item
[
"marketing_type"
])
&&
$item
[
"marketing_type"
]
==
Marketing
::
MARKETING_TYPE_PINDAN
)
{
$isPindan
=
true
;
...
...
@@ -84,7 +84,7 @@ class Tcc2Service
}
}
else
{
GoodsSku
::
rollback
();
return
self
::
TCC_RESULT_FAIL
;
throw
new
GoodsException
([
"cus"
=>
43
])
;
}
}
Tcc
::
save
([
...
...
@@ -95,7 +95,7 @@ class Tcc2Service
if
(
!
GoodsSku
::
commit
())
{
GoodsSku
::
rollback
();
return
self
::
TCC_RESULT_FAIL
;
throw
new
GoodsException
([
"cus"
=>
44
])
;
}
}
...
...
@@ -131,7 +131,7 @@ class Tcc2Service
}
}
else
{
PindanGoodsSku
::
rollback
();
return
self
::
TCC_RESULT_FAIL
;
throw
new
GoodsException
([
"cus"
=>
43
])
;
}
}
Tcc
::
save
([
...
...
@@ -142,7 +142,7 @@ class Tcc2Service
if
(
!
PindanGoodsSku
::
commit
())
{
PindanGoodsSku
::
rollback
();
return
self
::
TCC_RESULT_FAIL
;
throw
new
GoodsException
([
"cus"
=>
44
])
;
}
}
...
...
@@ -161,13 +161,13 @@ class Tcc2Service
{
$goodsInfoList
=
json_decode
(
$keys
,
true
);
if
(
empty
(
$goodsInfoList
))
{
return
self
::
TCC_RESULT_FAIL
;
throw
new
GoodsException
([
"cus"
=>
42
])
;
}
$isPindan
=
false
;
foreach
(
$goodsInfoList
as
$item
)
{
if
(
empty
(
$item
[
"goods_sku_id"
])
||
empty
(
$item
[
"num"
]))
{
return
self
::
TCC_RESULT_FAIL
;
throw
new
GoodsException
([
"cus"
=>
42
])
;
}
if
(
!
empty
(
$item
[
"marketing_id"
])
&&
!
empty
(
$item
[
"marketing_type"
])
&&
$item
[
"marketing_type"
]
==
Marketing
::
MARKETING_TYPE_PINDAN
)
{
$isPindan
=
true
;
...
...
@@ -181,12 +181,12 @@ class Tcc2Service
}
//在confirm时候必须已经有try,如果没有就直接返回fail
if
(
!
empty
(
$tccInfo
[
"status"
])
&&
!
in_array
(
$tccInfo
[
"status"
],
[
Tcc
::
STATUS_T_SUCCESS
]))
{
return
self
::
TCC_RESULT_FAIL
;
throw
new
GoodsException
([
"cus"
=>
45
])
;
}
//如果已经 cancel 成功, 则失败
if
(
!
empty
(
$tccInfo
[
"status"
])
&&
in_array
(
$tccInfo
[
"status"
],
[
Tcc
::
STATUS_C2_SUCCESS
]))
{
return
self
::
TCC_RESULT_FAIL
;
throw
new
GoodsException
([
"cus"
=>
46
])
;
}
if
(
$isPindan
)
{
...
...
@@ -226,14 +226,14 @@ class Tcc2Service
}
}
else
{
GoodsSku
::
rollback
();
return
self
::
TCC_RESULT_FAIL
;
throw
new
GoodsException
([
"cus"
=>
43
])
;
}
}
Tcc
::
save
([
"status"
=>
Tcc
::
STATUS_C1_SUCCESS
,],
[
"tid"
=>
$tid
]);
if
(
!
GoodsSku
::
commit
())
{
GoodsSku
::
rollback
();
return
self
::
TCC_RESULT_FAIL
;
throw
new
GoodsException
([
"cus"
=>
44
])
;
}
}
...
...
@@ -258,7 +258,6 @@ class Tcc2Service
,
[
"goods_sku_id"
,
"inventory_rest"
,
"total_amount_order"
,
"inventory_lock"
,
"online_status"
]);
if
(
!
empty
(
$sku
[
"inventory_lock"
])
&&
$sku
[
"online_status"
]
==
PindanGoodsSku
::
ONLINE_STATUS_ONLINE
)
{
//条件加上乐观锁
$rowCount
=
PindanGoodsSku
::
save
([
"inventory_lock"
=>
$sku
[
"inventory_lock"
]
-
$num
,
...
...
@@ -270,14 +269,14 @@ class Tcc2Service
}
}
else
{
PindanGoodsSku
::
rollback
();
return
self
::
TCC_RESULT_FAIL
;
throw
new
GoodsException
([
"cus"
=>
43
])
;
}
}
Tcc
::
save
([
"status"
=>
Tcc
::
STATUS_C1_SUCCESS
,],
[
"tid"
=>
$tid
]);
if
(
!
PindanGoodsSku
::
commit
())
{
PindanGoodsSku
::
rollback
();
return
self
::
TCC_RESULT_FAIL
;
throw
new
GoodsException
([
"cus"
=>
44
])
;
}
}
...
...
@@ -295,13 +294,13 @@ class Tcc2Service
{
$goodsInfoList
=
json_decode
(
$keys
,
true
);
if
(
empty
(
$goodsInfoList
))
{
return
self
::
TCC_RESULT_FAIL
;
throw
new
GoodsException
([
"cus"
=>
42
])
;
}
$isPindan
=
false
;
foreach
(
$goodsInfoList
as
$item
)
{
if
(
empty
(
$item
[
"goods_sku_id"
])
||
empty
(
$item
[
"num"
]))
{
return
self
::
TCC_RESULT_FAIL
;
throw
new
GoodsException
([
"cus"
=>
42
])
;
}
if
(
!
empty
(
$item
[
"marketing_id"
])
&&
!
empty
(
$item
[
"marketing_type"
])
&&
$item
[
"marketing_type"
]
==
Marketing
::
MARKETING_TYPE_PINDAN
)
{
$isPindan
=
true
;
...
...
@@ -379,7 +378,7 @@ class Tcc2Service
if
(
!
GoodsSku
::
commit
())
{
GoodsSku
::
rollback
();
return
self
::
TCC_RESULT_FAIL
;
throw
new
GoodsException
([
"cus"
=>
44
])
;
}
}
...
...
@@ -433,7 +432,7 @@ class Tcc2Service
if
(
!
PindanGoodsSku
::
commit
())
{
PindanGoodsSku
::
rollback
();
return
self
::
TCC_RESULT_FAIL
;
throw
new
GoodsException
([
"cus"
=>
44
])
;
}
}
...
...
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