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
745702c5
Commit
745702c5
authored
Aug 09, 2021
by
luhongguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update:退单商品库存处理
parent
453da3a2
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
164 additions
and
0 deletions
+164
-0
RefundGoodsValidate.php
application/library/Validate/RefundGoodsValidate.php
+27
-0
GoodsRefundRecord.php
application/models/goods/mysql/GoodsRefundRecord.php
+48
-0
Goods.php
application/modules/Goods/controllers/Goods.php
+13
-0
GoodsService.php
application/services/goods/GoodsService.php
+20
-0
MarketingPindanGoodsService.php
application/services/goods/MarketingPindanGoodsService.php
+56
-0
No files found.
application/library/Validate/RefundGoodsValidate.php
0 → 100644
View file @
745702c5
<?php
namespace
Validate
;
/**
* Class RefundGoodsValidate
*
* @package Validate
*/
class
RefundGoodsValidate
extends
BaseValidate
{
protected
$rule
=
[
'goods_sku_id'
=>
'require'
,
'order_id'
=>
'require'
,
'order_item_id'
=>
'require'
,
'num'
=>
'require'
,
];
protected
$message
=
[
"goods_sku_id"
=>
"goods_sku_id 不能为空"
,
"order_id"
=>
"order_id 不能为空"
,
"order_item_id"
=>
"order_item_id 不能为空"
,
"num"
=>
"num 不能为空"
,
];
}
\ No newline at end of file
application/models/goods/mysql/GoodsRefundRecord.php
0 → 100644
View file @
745702c5
<?php
namespace
App\Models\goods\mysql
;
use
Api\PhpUtils\Mysql\MysqlBase
;
/**
* Class GoodsRefundRecord
* 商品退款记录
* @package App\Models\goods\mysql
*/
class
GoodsRefundRecord
extends
MysqlBase
{
const
TABLE_NAME
=
'goods_refund_record'
;
const
CONFIG_INDEX
=
'goods'
;
const
OPERATOR_RESULT_FAILURE
=
0
;
const
OPERATOR_RESULT_SUCCESS
=
1
;
public
static
function
getRecord
(
$where
,
$columns
=
[])
{
if
(
empty
(
$columns
))
{
$columns
=
'*'
;
}
return
self
::
get
(
$columns
,
$where
);
}
public
static
function
getRecordMaster
(
$where
,
$columns
=
[])
{
if
(
empty
(
$columns
))
{
$columns
=
'*'
;
}
return
self
::
selectMaster
(
$columns
,
$where
);
}
public
static
function
save
(
$data
,
$where
=
[])
{
if
(
empty
(
$where
))
{
return
self
::
insert
(
$data
);
}
return
self
::
update
(
$data
,
$where
);
}
public
static
function
deleteRecord
(
$where
)
{
return
self
::
delete
(
$where
);
}
}
\ No newline at end of file
application/modules/Goods/controllers/Goods.php
View file @
745702c5
...
...
@@ -11,6 +11,7 @@ use \Validate\GoodsInfoOpValidate;
use
\Validate\GoodsInfoFeValidate
;
use
\Validate\GoodsListCValidate
;
use
\Validate\OrderGoodsValidate
;
use
\Validate\RefundGoodsValidate
;
use
\Validate\GoodsOnlineOfflineValidate
;
use
\Validate\PaySuccessGoodsCallbackValidate
;
use
\Validate\GoodsInitShopValidate
;
...
...
@@ -289,4 +290,16 @@ class GoodsController extends Base
$list
=
MarketingPindanGoodsService
::
getPindanGoodsList
(
$params
);
$this
->
success
([
"result"
=>
$list
]);
}
/**
* 拼单商品退款商品逻辑
* @throws Exception
*/
public
function
refundAction
()
{
(
new
RefundGoodsValidate
())
->
validate
();
$params
=
$this
->
params
;
$res
=
GoodsService
::
refundGoods
(
$params
);
$this
->
success
([
"result"
=>
$res
]);
}
}
\ No newline at end of file
application/services/goods/GoodsService.php
View file @
745702c5
...
...
@@ -1689,4 +1689,24 @@ class GoodsService
return
self
::
addShop
(
$lifeAccount
);
}
/**
* 退款拼单商品,库存调整
* @param $params
* @return bool
* @throws GoodsException
*/
public
static
function
refundGoods
(
$params
)
{
$goodsSukParams
=
GoodsSkuId
::
getGoodsSkuIdParams
(
$params
[
"goods_sku_id"
]);
if
(
!
empty
(
$goodsSukParams
))
{
if
(
isset
(
$goodsSukParams
[
"table_tag"
])
&&
(
$goodsSukParams
[
"table_tag"
]
==
GoodsSkuId
::
TABLE_TAG_PINDAN
||
$goodsSukParams
[
"category_1_id"
]
==
"00"
))
{
return
MarketingPindanGoodsService
::
refundGoods
(
$params
);
}
}
else
{
throw
new
GoodsException
([
"cus"
=>
41
]);
}
return
true
;
}
}
\ No newline at end of file
application/services/goods/MarketingPindanGoodsService.php
View file @
745702c5
...
...
@@ -14,6 +14,7 @@ use Api\PhpUtils\Http\HttpUtil;
use
App\Exception\custom\GoodsException
;
use
App\Models\goods\mysql\Category
;
use
App\Models\goods\mysql\GoodsOperationRecord
;
use
App\Models\goods\mysql\GoodsRefundRecord
;
use
App\Models\goods\mysql\GoodsSku
;
use
App\Models\goods\mysql\GoodsSkuPicRecord
;
use
App\Models\goods\mysql\GoodsSkuSubShop
;
...
...
@@ -452,4 +453,59 @@ class MarketingPindanGoodsService
}
return
$data
;
}
/**
* 退款拼单商品,库存调整
* @param $params
* @return bool
* @throws GoodsException
*/
public
static
function
refundGoods
(
$params
)
{
$sku
=
PindanGoodsSku
::
get
(
"*"
,
[
"goods_sku_id"
=>
$params
[
"goods_sku_id"
]]);
if
(
empty
(
$sku
))
{
throw
new
GoodsException
([
"cus"
=>
15
]);
}
PindanGoodsSku
::
beginTransaction
();
$records
=
GoodsRefundRecord
::
getRecordMaster
([
"goods_sku_id"
=>
$params
[
"goods_sku_id"
],
"order_item_id"
=>
$params
[
"order_item_id"
],
"operator_result"
=>
GoodsRefundRecord
::
OPERATOR_RESULT_SUCCESS
]);
if
(
empty
(
$records
))
{
GoodsRefundRecord
::
save
([
"goods_sku_id"
=>
$params
[
"goods_sku_id"
],
"order_id"
=>
$params
[
"order_id"
],
"order_item_id"
=>
$params
[
"order_item_id"
],
"num"
=>
$params
[
"num"
],
"operator_result"
=>
GoodsRefundRecord
::
OPERATOR_RESULT_SUCCESS
]);
$row
=
PindanGoodsSku
::
save
([
"total_amount_sold"
=>
$sku
[
"total_amount_sold"
]
-
$params
[
"num"
],
"total_amount_order"
=>
$sku
[
"total_amount_order"
]
-
$params
[
"num"
],
"inventory_rest"
=>
$sku
[
"inventory_rest"
]
+
$params
[
"num"
],
],
[
"goods_sku_id"
=>
$sku
[
"goods_sku_id"
],
"total_amount_sold[>=]"
=>
$params
[
"num"
],
"total_amount_order[>=]"
=>
$params
[
"num"
]]);
if
(
$row
<
1
){
PindanGoodsSku
::
rollback
();
GoodsRefundRecord
::
save
([
"goods_sku_id"
=>
$params
[
"goods_sku_id"
],
"order_id"
=>
$params
[
"order_id"
],
"order_item_id"
=>
$params
[
"order_item_id"
],
"num"
=>
$params
[
"num"
],
"operator_result"
=>
GoodsRefundRecord
::
OPERATOR_RESULT_FAILURE
]);
throw
new
GoodsException
([
"cus"
=>
0
]);
}
}
if
(
!
PindanGoodsSku
::
commit
())
{
PindanGoodsSku
::
rollback
();
throw
new
GoodsException
([
"cus"
=>
0
]);
}
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