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
eacb5cd3
Commit
eacb5cd3
authored
Jun 26, 2021
by
luhongguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update:支付回调商品接口
parent
b6253f2e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
169 additions
and
0 deletions
+169
-0
PaySuccessGoodsCallbackValidate.php
...tion/library/Validate/PaySuccessGoodsCallbackValidate.php
+25
-0
PaySuccessGoodsCallbackRecord.php
...tion/models/goods/mysql/PaySuccessGoodsCallbackRecord.php
+40
-0
InitGoodsToEs.php
application/modules/Cli/controllers/InitGoodsToEs.php
+36
-0
Goods.php
application/modules/Goods/controllers/Goods.php
+15
-0
GoodsService.php
application/services/goods/GoodsService.php
+53
-0
No files found.
application/library/Validate/PaySuccessGoodsCallbackValidate.php
0 → 100644
View file @
eacb5cd3
<?php
namespace
Validate
;
/**
* Class PaySuccessGoodsCallbackValidate
*
* @package Validate
*/
class
PaySuccessGoodsCallbackValidate
extends
BaseValidate
{
protected
$rule
=
[
'pay_order_id'
=>
'require'
,
'goods_sku_id'
=>
'require'
,
'num'
=>
'require'
,
];
protected
$message
=
[
"pay_order_id"
=>
"pay_order_id 不能为空"
,
"goods_sku_id"
=>
"goods_sku_id 不能为空"
,
"num"
=>
"商品数量不能为空"
,
];
}
\ No newline at end of file
application/models/goods/mysql/PaySuccessGoodsCallbackRecord.php
0 → 100644
View file @
eacb5cd3
<?php
namespace
App\Models\goods\mysql
;
use
Api\PhpUtils\Mysql\MysqlBase
;
/**
* Class PaySuccessGoodsCallbackRecord
* 订单支付成功后商品回调记录
* @package App\Models\goods\mysql
*/
class
PaySuccessGoodsCallbackRecord
extends
MysqlBase
{
const
TABLE_NAME
=
'pay_success_goods_callback_record'
;
const
CONFIG_INDEX
=
'goods'
;
const
OPERATOR_RESULT_FAIL
=
0
;
const
OPERATOR_RESULT_SUCCESS
=
1
;
public
static
function
getRecord
(
$where
,
$colums
=
[])
{
if
(
empty
(
$colums
))
{
$colums
=
'*'
;
}
return
self
::
get
(
$colums
,
$where
);
}
public
static
function
getRecordMaster
(
$where
,
$colums
=
[])
{
if
(
empty
(
$colums
))
{
$colums
=
'*'
;
}
return
self
::
selectMaster
(
$colums
,
$where
);
}
public
static
function
insertRecord
(
$colums
)
{
return
self
::
insert
(
$colums
);
}
}
\ No newline at end of file
application/modules/Cli/controllers/InitGoodsToEs.php
0 → 100644
View file @
eacb5cd3
<?php
use
App\Base\Cli
;
use
\App\Models\goods\mysql\GoodsSku
;
class
InitGoodsToEsController
extends
Cli
{
/**
* php public/cli.php InitGoodsToEs index
*/
public
function
IndexAction
()
{
$goodsSkuIds
=
GoodsSku
::
select
(
"goods_sku_id"
,
[
"goods_status"
=>
1
]);
$request
=
$this
->
getRequest
();
$params
=
$request
->
getParams
();
$res
=
[
"data"
=>
$params
,
"code"
=>
0
];
$response
=
$this
->
getResponse
();
$response
->
setBody
(
json_encode
(
$res
));
var_dump
(
$goodsSkuIds
);
// $this->getAllGoodsSkuId();
}
public
function
getAllGoodsSkuId
()
{
$goodsSkuIds
=
GoodsSku
::
select
(
"goods_sku_id"
,
[
"goods_status"
=>
1
]);
var_dump
(
$goodsSkuIds
);
exit
;
}
}
\ No newline at end of file
application/modules/Goods/controllers/Goods.php
View file @
eacb5cd3
...
...
@@ -12,6 +12,7 @@ use \Validate\GoodsInfoFeValidate;
use
\Validate\GoodsListCValidate
;
use
\Validate\OrderGoodsValidate
;
use
\Validate\GoodsOnlineOfflineValidate
;
use
\Validate\PaySuccessGoodsCallbackValidate
;
use
\App\Services\goods\ElasticGoodService
;
...
...
@@ -205,4 +206,18 @@ class GoodsController extends Base
$this
->
success
([
"result"
=>
$data
]);
}
/**
* 支付回调商品接口
* @throws \App\Exception\custom\GoodsException
* @throws \App\Exception\custom\InterfaceException
* @throws \App\Exception\custom\ParamException
*/
public
function
pay_success_callbackAction
()
{
(
new
PaySuccessGoodsCallbackValidate
())
->
validate
();
$res
=
GoodsService
::
paySuccessGoodsCallback
(
$this
->
params
);
$this
->
success
([
"result"
=>
$res
]);
}
}
\ No newline at end of file
application/services/goods/GoodsService.php
View file @
eacb5cd3
...
...
@@ -16,6 +16,7 @@ use App\Models\goods\mysql\GoodsSku;
use
App\Models\goods\mysql\GoodsSkuSubShop
;
use
App\Models\goods\mysql\GoodsSnapshot
;
use
App\Models\goods\mysql\GoodsSpu
;
use
App\Models\goods\mysql\PaySuccessGoodsCallbackRecord
;
use
App\Models\goods\mysql\Shop
;
use
App\Models\shop\mysql\SubShop
;
use
App\Services\shop\ShopService
;
...
...
@@ -1094,4 +1095,56 @@ class GoodsService
}
return
$data
;
}
/**
* 支付成功后回调
* @param array $params
* @return bool
* @throws GoodsException
* @throws InterfaceException
*/
public
static
function
paySuccessGoodsCallback
(
$params
=
[])
{
$payOrderId
=
$params
[
"pay_order_id"
];
$goodsSkuId
=
$params
[
"goods_sku_id"
];
$num
=
$params
[
"num"
];
$record
=
PaySuccessGoodsCallbackRecord
::
getRecord
([
"pay_order_id"
=>
$payOrderId
,
"goods_sku_id"
=>
$goodsSkuId
,
"operator_result"
=>
PaySuccessGoodsCallbackRecord
::
OPERATOR_RESULT_SUCCESS
]
);
if
(
empty
(
$record
))
{
GoodsSku
::
beginTransaction
();
$goodsSku
=
GoodsSku
::
getRecord
([
"goods_sku_id"
=>
$goodsSkuId
]);
if
(
empty
(
$goodsSku
))
{
throw
new
GoodsException
([
"cus"
=>
15
]);
}
GoodsSku
::
save
([
"total_amount_sold"
=>
$goodsSku
[
"total_amount_sold"
]
+
$num
]
,
[
"goods_sku_id"
=>
$goodsSkuId
]);
PaySuccessGoodsCallbackRecord
::
insertRecord
([
"pay_order_id"
=>
$payOrderId
,
"goods_sku_id"
=>
$goodsSkuId
,
"operator_result"
=>
PaySuccessGoodsCallbackRecord
::
OPERATOR_RESULT_SUCCESS
]
);
if
(
!
GoodsSku
::
commit
())
{
GoodsSku
::
rollback
();
PaySuccessGoodsCallbackRecord
::
insertRecord
([
"pay_order_id"
=>
$payOrderId
,
"goods_sku_id"
=>
$goodsSkuId
,
"operator_result"
=>
PaySuccessGoodsCallbackRecord
::
OPERATOR_RESULT_FAIL
]
);
return
false
;
}
//同步到es
self
::
updateGoodsInfoToEs
(
$goodsSkuId
);
}
return
true
;
}
}
\ No newline at end of file
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