Commit 79337290 authored by pengfei's avatar pengfei

merge master

parents 26f7cb21 a4fa1e3c
......@@ -63,6 +63,7 @@ class MarketingException extends BaseException
self::COLONEL_APPLY_EXIST => '当前用户已提交团长申请',
self::COLONEL_AUDIT_STATUS_USE => '该团长已审核',
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;
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;
......@@ -702,10 +704,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;
......@@ -745,6 +745,9 @@ class GoodsService
$clearPrice = $skuParams["clear_price"];
$price = $skuParams["price"];
$chargeFee = !empty($price) ? (float)bcmul($price , self::CHARGEFEE,2) : 0; //手续费 (分)
if ($chargeFee<1) {
$chargeFee = 0;
}
if ($clearPrice > 0 && $clearPrice > $price) {
throw new GoodsException(['cus' => 39]);
}
......@@ -760,6 +763,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) {
......@@ -773,9 +777,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'=>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{
if (($price - $chargeFee) < $clearPrice) {
if ($clearPrice > 0 && (($price - $chargeFee) < $clearPrice)) {
throw new GoodsException(['cus' => 40]);
}
}
......
......@@ -193,9 +193,6 @@ class DistributorService
}
$jwUserId = '';
// if (empty($distributorCode)) {
// throw new DistributorException(['cus'=>9]);
// }
$info = Distributor::getRecord(['user_id' => $shareUserId]);
if (empty($info)) {
......
......@@ -52,7 +52,8 @@ class MarketingGoodsService
}
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'] : '';
......@@ -114,7 +115,7 @@ class MarketingGoodsService
$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] = $value;
$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
}
}
$result = ['result' => $list ,'last_id' => $lastId];
$hasmore = !empty($list) ? 1 : 0 ;
$result = ['result' => $list ,'last_id' => $lastId, 'hasmore' => $hasmore];
return $result;
}
......
......@@ -94,7 +94,7 @@ class MarketingService
$where = [
'online_status' => 1,
'rule_refund' => 2,
//'rule_refund' => 2,
"expiration_time[>]" => date("Y-m-d"),
];
......@@ -552,7 +552,7 @@ class MarketingService
if ($commissionMode == Marketing::COMMISSION_MODE_RATE) {
$commissionTotal = ($firstCommissionRate + $secondCommissionRate) / 10000 * $price;
if ($price < ($commissionTotal+$chargeFee)) {
throw new MarketingException(['cus'=>23]);
throw new MarketingException(['cus'=>33]);
}
}
......@@ -560,7 +560,7 @@ class MarketingService
if ($commissionMode == Marketing::COMMISSION_MODE_FIXED) {
$commissionTotal = ($firstCommissionRate + $secondCommissionRate);
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