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
f7931107
Commit
f7931107
authored
Aug 06, 2021
by
jianghaiming
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'tuangou_1' of
https://gitlab.yidian-inc.com/bp/goods
into tuangou_1
parents
dec40ae5
2bc8ea66
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
1 deletion
+60
-1
GoodsException.php
application/exception/custom/GoodsException.php
+2
-0
Marketing.php
application/models/marketing/mysql/Marketing.php
+7
-0
GoodsService.php
application/services/goods/GoodsService.php
+51
-1
No files found.
application/exception/custom/GoodsException.php
View file @
f7931107
...
...
@@ -46,5 +46,7 @@ class GoodsException extends BaseException
32
=>
'当前商品已下单数量不足'
,
33
=>
'售价不能为0'
,
34
=>
'售价不能大于5万元'
,
35
=>
'结算价不能大于售价'
,
36
=>
'结算价不符合标准'
,
];
}
\ No newline at end of file
application/models/marketing/mysql/Marketing.php
View file @
f7931107
...
...
@@ -14,6 +14,13 @@ class Marketing extends MysqlBase
const
MARKETING_TYPE_TUANGOU
=
2
;
const
MARKETING_TYPE_MIAOSHA
=
3
;
const
COMMISSION_MODE_RATE
=
1
;
const
COMMISSION_MODE_FIXED
=
2
;
const
ONLINE_STATUS_OPEN
=
1
;
const
ONLINE_STATUS_STOP
=
2
;
const
ONLINE_STATUS_EXPIRE
=
3
;
public
static
function
getRecord
(
$where
,
$colums
=
[])
{
if
(
empty
(
$colums
))
{
...
...
application/services/goods/GoodsService.php
View file @
f7931107
...
...
@@ -23,6 +23,7 @@ use App\Models\goods\mysql\LifeAccountShopNum;
use
App\Models\goods\mysql\PaySuccessGoodsCallbackRecord
;
use
App\Models\goods\mysql\Shop
;
use
App\Models\marketing\mysql\Distributor
;
use
App\Models\marketing\mysql\Marketing
;
use
App\Models\marketing\mysql\MarketingGoods
;
use
App\Models\shop\mysql\SubShop
;
use
App\Services\marketing\DistributorService
;
...
...
@@ -657,9 +658,15 @@ class GoodsService
"inventory_rest"
=>
$inventoryCount
,
"original_price"
=>
empty
(
$params
[
"original_price"
])
?
0
:
$params
[
"original_price"
]
*
100
,
"price"
=>
$params
[
"price"
]
*
100
,
"clear_price"
=>
empty
(
$params
[
"clear_price"
])
?
0
:
$params
[
"clear_price"
]
*
100
,
"goods_version"
=>
(
int
)
$skuData
[
"goods_version"
]
+
1
,
];
//验证结算价格
if
(
!
empty
(
$params
[
"clear_price"
]))
{
self
::
checkClearPrice
(
$goodsSkuId
,
$skuParams
);
}
if
(
self
::
isInitGoodsStatus
(
$params
,
$skuData
))
{
$skuParams
[
"audit_status"
]
=
GoodsSku
::
STATUS_AUDIT
;
$skuParams
[
"online_status"
]
=
GoodsSku
::
ONLINE_STATUS_NO_ONLINE
;
...
...
@@ -687,6 +694,48 @@ class GoodsService
return
GoodsSku
::
save
(
$skuParams
,
[
"goods_sku_id"
=>
$goodsSkuId
]);
}
/**
* 检查结算价格
* @param $goodsSkuId
* @param $skuParams
* @throws GoodsException
*/
private
static
function
checkClearPrice
(
$goodsSkuId
,
$skuParams
)
{
$clearPrice
=
$skuParams
[
"clear_price"
];
$price
=
$skuParams
[
"price"
];
if
(
$clearPrice
>
0
&&
$clearPrice
>
$price
)
{
throw
new
GoodsException
([
'cus'
=>
35
]);
}
$marketingIds
=
MarketingGoods
::
select
([
"marketing_id"
],
[
"goods_sku_id"
=>
$goodsSkuId
]);
if
(
!
empty
(
$marketingIds
))
{
$marketingIds
=
array_column
(
$marketingIds
,
"marketing_id"
);
$marketings
=
Marketing
::
select
(
"*"
,
[
"marketing_id"
=>
$marketingIds
,
"marketing_type"
=>
Marketing
::
MARKETING_TYPE_FENXIAO
,
"online_status"
=>
Marketing
::
ONLINE_STATUS_OPEN
]
);
if
(
!
empty
(
$marketings
))
{
foreach
(
$marketings
as
$marketing
)
{
if
(
$marketing
[
"commission_mode"
]
==
Marketing
::
COMMISSION_MODE_RATE
)
{
$commissionTotal
=
(
$marketing
[
"first_commission_value"
]
+
$marketing
[
"second_commission_value"
])
/
1000
*
$price
;
if
(
$price
-
$commissionTotal
<
$clearPrice
)
{
throw
new
GoodsException
([
'cus'
=>
36
]);
}
}
if
(
$marketing
[
"commission_mode"
]
==
Marketing
::
COMMISSION_MODE_FIXED
)
{
$commissionTotal
=
(
$marketing
[
"first_commission_value"
]
+
$marketing
[
"second_commission_value"
]);
if
(
$price
-
$commissionTotal
<
$clearPrice
)
{
throw
new
GoodsException
([
'cus'
=>
36
]);
}
}
}
}
}
}
/**
* 是否要初始化状态
* @param $params
...
...
@@ -707,7 +756,8 @@ class GoodsService
||
$params
[
"rule_desc"
]
!=
$sku
[
"rule_desc"
]
||
$params
[
"rule_refund"
]
!=
$sku
[
"rule_refund"
]
||
$params
[
"original_price"
]
!=
$sku
[
"original_price"
]
||
$params
[
"price"
]
!=
$sku
[
"price"
];
||
$params
[
"price"
]
!=
$sku
[
"price"
]
||
$params
[
"clear_price"
]
!=
$sku
[
"clear_price"
];
}
/**
...
...
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