Commit 17e973e3 authored by jianghaiming's avatar jianghaiming

Merge branch 'marketing_20210824' into test

parents f247dc8f 57c2512d
......@@ -12,6 +12,7 @@ use Api\PhpUtils\Common\BaseConvert;
use Api\PhpUtils\Common\GoodsSkuId;
use Api\PhpUtils\Http\HttpUtil;
use App\Exception\custom\GoodsException;
use App\Exception\custom\MarketingException;
use App\Models\goods\mysql\Category;
use App\Models\goods\mysql\GoodsOperationRecord;
use App\Models\goods\mysql\GoodsSku;
......@@ -37,6 +38,7 @@ use App\Services\common\CommonService;
use Api\PhpUtils\Http\Request;
use App\Exception\custom\InterfaceException;
class GoodsService
{
const CHARGEFEE = 0.006;
......@@ -781,10 +783,8 @@ class GoodsService
"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;
......@@ -851,6 +851,7 @@ class GoodsService
if (!empty($marketings)) {
foreach ($marketings as $marketing) {
if ($clearPrice > 0) {
if ($marketing["commission_mode"] == Marketing::COMMISSION_MODE_RATE) {
$commissionTotal = ($marketing["first_commission_value"] + $marketing["second_commission_value"]) / 10000 * $price;
if (($price - $commissionTotal - $chargeFee) < $clearPrice) {
......@@ -864,9 +865,27 @@ class GoodsService
throw new GoodsException(['cus' => 40]);
}
}
}else{
//比例计算
if ($marketing["commission_mode"] == Marketing::COMMISSION_MODE_RATE) {
$commissionTotal = ($marketing["first_commission_value"] + $marketing["second_commission_value"]) / 10000 * $price;
if ($price < ($commissionTotal+$chargeFee)) {
throw new MarketingException(['cus'=>23]);
}
}
//固定金额
if ($marketing["commission_mode"] == Marketing::COMMISSION_MODE_FIXED) {
$commissionTotal = ($marketing["first_commission_value"] + $marketing["second_commission_value"]);
if ($price < ($commissionTotal+$chargeFee)) {
throw new MarketingException(['cus'=>23]);
}
}
}
}
}else{
if (($price - $chargeFee) < $clearPrice) {
if ($clearPrice > 0 && (($price - $chargeFee) < $clearPrice)) {
throw new GoodsException(['cus' => 40]);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment