Commit 79337290 authored by pengfei's avatar pengfei

merge master

parents 26f7cb21 a4fa1e3c
...@@ -63,6 +63,7 @@ class MarketingException extends BaseException ...@@ -63,6 +63,7 @@ class MarketingException extends BaseException
self::COLONEL_APPLY_EXIST => '当前用户已提交团长申请', self::COLONEL_APPLY_EXIST => '当前用户已提交团长申请',
self::COLONEL_AUDIT_STATUS_USE => '该团长已审核', self::COLONEL_AUDIT_STATUS_USE => '该团长已审核',
self::COLONEL_ADD_FAILED => '团长入库失败', self::COLONEL_ADD_FAILED => '团长入库失败',
self::COLONEL_TAKE_PLACE_EDIT_FAILED => '修改团长自提点失败' self::COLONEL_TAKE_PLACE_EDIT_FAILED => '修改团长自提点失败',
33 => '分润金额+手续费不能大于售价金额',
]; ];
} }
...@@ -12,6 +12,7 @@ use Api\PhpUtils\Common\BaseConvert; ...@@ -12,6 +12,7 @@ use Api\PhpUtils\Common\BaseConvert;
use Api\PhpUtils\Common\GoodsSkuId; use Api\PhpUtils\Common\GoodsSkuId;
use Api\PhpUtils\Http\HttpUtil; use Api\PhpUtils\Http\HttpUtil;
use App\Exception\custom\GoodsException; use App\Exception\custom\GoodsException;
use App\Exception\custom\MarketingException;
use App\Models\goods\mysql\Category; use App\Models\goods\mysql\Category;
use App\Models\goods\mysql\GoodsOperationRecord; use App\Models\goods\mysql\GoodsOperationRecord;
use App\Models\goods\mysql\GoodsSku; use App\Models\goods\mysql\GoodsSku;
...@@ -37,6 +38,7 @@ use App\Services\common\CommonService; ...@@ -37,6 +38,7 @@ use App\Services\common\CommonService;
use Api\PhpUtils\Http\Request; use Api\PhpUtils\Http\Request;
use App\Exception\custom\InterfaceException; use App\Exception\custom\InterfaceException;
class GoodsService class GoodsService
{ {
const CHARGEFEE = 0.006; const CHARGEFEE = 0.006;
...@@ -702,10 +704,8 @@ class GoodsService ...@@ -702,10 +704,8 @@ class GoodsService
"goods_version" => (int)$skuData["goods_version"] + 1, "goods_version" => (int)$skuData["goods_version"] + 1,
]; ];
//验证结算价格 //验证结算价格/分销金额
if (!empty($params["clear_price"])) {
self::checkClearPrice($goodsSkuId, $skuParams); self::checkClearPrice($goodsSkuId, $skuParams);
}
if (self::isInitGoodsStatus($params, $skuData)) { if (self::isInitGoodsStatus($params, $skuData)) {
$skuParams["audit_status"] = GoodsSku::STATUS_AUDIT; $skuParams["audit_status"] = GoodsSku::STATUS_AUDIT;
...@@ -745,6 +745,9 @@ class GoodsService ...@@ -745,6 +745,9 @@ class GoodsService
$clearPrice = $skuParams["clear_price"]; $clearPrice = $skuParams["clear_price"];
$price = $skuParams["price"]; $price = $skuParams["price"];
$chargeFee = !empty($price) ? (float)bcmul($price , self::CHARGEFEE,2) : 0; //手续费 (分) $chargeFee = !empty($price) ? (float)bcmul($price , self::CHARGEFEE,2) : 0; //手续费 (分)
if ($chargeFee<1) {
$chargeFee = 0;
}
if ($clearPrice > 0 && $clearPrice > $price) { if ($clearPrice > 0 && $clearPrice > $price) {
throw new GoodsException(['cus' => 39]); throw new GoodsException(['cus' => 39]);
} }
...@@ -760,6 +763,7 @@ class GoodsService ...@@ -760,6 +763,7 @@ class GoodsService
if (!empty($marketings)) { if (!empty($marketings)) {
foreach ($marketings as $marketing) { foreach ($marketings as $marketing) {
if ($clearPrice > 0) {
if ($marketing["commission_mode"] == Marketing::COMMISSION_MODE_RATE) { if ($marketing["commission_mode"] == Marketing::COMMISSION_MODE_RATE) {
$commissionTotal = ($marketing["first_commission_value"] + $marketing["second_commission_value"]) / 10000 * $price; $commissionTotal = ($marketing["first_commission_value"] + $marketing["second_commission_value"]) / 10000 * $price;
if (($price - $commissionTotal - $chargeFee) < $clearPrice) { if (($price - $commissionTotal - $chargeFee) < $clearPrice) {
...@@ -773,9 +777,27 @@ class GoodsService ...@@ -773,9 +777,27 @@ class GoodsService
throw new GoodsException(['cus' => 40]); 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'=>33]);
}
}
//固定金额
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'=>33]);
}
}
}
} }
}else{ }else{
if (($price - $chargeFee) < $clearPrice) { if ($clearPrice > 0 && (($price - $chargeFee) < $clearPrice)) {
throw new GoodsException(['cus' => 40]); throw new GoodsException(['cus' => 40]);
} }
} }
......
...@@ -193,9 +193,6 @@ class DistributorService ...@@ -193,9 +193,6 @@ class DistributorService
} }
$jwUserId = ''; $jwUserId = '';
// if (empty($distributorCode)) {
// throw new DistributorException(['cus'=>9]);
// }
$info = Distributor::getRecord(['user_id' => $shareUserId]); $info = Distributor::getRecord(['user_id' => $shareUserId]);
if (empty($info)) { if (empty($info)) {
......
...@@ -52,7 +52,8 @@ class MarketingGoodsService ...@@ -52,7 +52,8 @@ class MarketingGoodsService
} }
public static function marketingGoodsList($params) public static function marketingGoodsList($params)
{ {
$limit = !empty($params['num']) ? $params['num'] : 20; //@todo 分页放大100倍,主要解决商品到期和商品库存为零的过滤场景
$limit = !empty($params['num']) ? $params['num']*100 : 1000;
$userId = !empty($params['user_id']) ? $params['user_id'] : ''; $userId = !empty($params['user_id']) ? $params['user_id'] : '';
...@@ -114,7 +115,7 @@ class MarketingGoodsService ...@@ -114,7 +115,7 @@ class MarketingGoodsService
$onlineStatus = !empty($goodsSkuList[$value['goods_sku_id']]['online_status']) ? $goodsSkuList[$value['goods_sku_id']]['online_status'] : ''; $onlineStatus = !empty($goodsSkuList[$value['goods_sku_id']]['online_status']) ? $goodsSkuList[$value['goods_sku_id']]['online_status'] : '';
if (!empty($inventoryRest) && $expirationTime> date("Y-m-d H:i:s") && $onlineStatus == 1 ) { if (!empty($inventoryRest) && $expirationTime > date("Y-m-d H:i:s") && $onlineStatus == 1 ) {
$list[$i]['inventory_rest'] = !empty($goodsSkuList[$value['goods_sku_id']]['inventory_rest']) ? $goodsSkuList[$value['goods_sku_id']]['inventory_rest'] : ''; $list[$i]['inventory_rest'] = !empty($goodsSkuList[$value['goods_sku_id']]['inventory_rest']) ? $goodsSkuList[$value['goods_sku_id']]['inventory_rest'] : '';
$list[$i] = $value; $list[$i] = $value;
$list[$i]['life_account_id'] = !empty($goodsSkuList[$value['goods_sku_id']]['life_account_id']) ? $goodsSkuList[$value['goods_sku_id']]['life_account_id'] : ''; $list[$i]['life_account_id'] = !empty($goodsSkuList[$value['goods_sku_id']]['life_account_id']) ? $goodsSkuList[$value['goods_sku_id']]['life_account_id'] : '';
...@@ -171,7 +172,8 @@ class MarketingGoodsService ...@@ -171,7 +172,8 @@ class MarketingGoodsService
} }
} }
$result = ['result' => $list ,'last_id' => $lastId]; $hasmore = !empty($list) ? 1 : 0 ;
$result = ['result' => $list ,'last_id' => $lastId, 'hasmore' => $hasmore];
return $result; return $result;
} }
......
...@@ -94,7 +94,7 @@ class MarketingService ...@@ -94,7 +94,7 @@ class MarketingService
$where = [ $where = [
'online_status' => 1, 'online_status' => 1,
'rule_refund' => 2, //'rule_refund' => 2,
"expiration_time[>]" => date("Y-m-d"), "expiration_time[>]" => date("Y-m-d"),
]; ];
...@@ -552,7 +552,7 @@ class MarketingService ...@@ -552,7 +552,7 @@ class MarketingService
if ($commissionMode == Marketing::COMMISSION_MODE_RATE) { if ($commissionMode == Marketing::COMMISSION_MODE_RATE) {
$commissionTotal = ($firstCommissionRate + $secondCommissionRate) / 10000 * $price; $commissionTotal = ($firstCommissionRate + $secondCommissionRate) / 10000 * $price;
if ($price < ($commissionTotal+$chargeFee)) { if ($price < ($commissionTotal+$chargeFee)) {
throw new MarketingException(['cus'=>23]); throw new MarketingException(['cus'=>33]);
} }
} }
...@@ -560,7 +560,7 @@ class MarketingService ...@@ -560,7 +560,7 @@ class MarketingService
if ($commissionMode == Marketing::COMMISSION_MODE_FIXED) { if ($commissionMode == Marketing::COMMISSION_MODE_FIXED) {
$commissionTotal = ($firstCommissionRate + $secondCommissionRate); $commissionTotal = ($firstCommissionRate + $secondCommissionRate);
if ($price < ($commissionTotal+$chargeFee)) { if ($price < ($commissionTotal+$chargeFee)) {
throw new MarketingException(['cus'=>23]); throw new MarketingException(['cus'=>33]);
} }
} }
} }
......
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