Commit 36e6eda8 authored by luhongguang's avatar luhongguang

update:获取指定商品分销活动的分成比例

parent 3b0a3191
......@@ -10,6 +10,10 @@ class Marketing extends MysqlBase
const CONFIG_INDEX = 'marketing';
const PRIMARY_KEY = 'marketing_id';
const MARKETING_TYPE_FENXIAO = 1;
const MARKETING_TYPE_TUANGOU = 2;
const MARKETING_TYPE_MIAOSHA = 3;
public static function getRecord($where, $colums = [])
{
if (empty($colums)) {
......
......@@ -3,6 +3,8 @@
use App\Base\Base;
use App\Services\marketing\MarketingService;
use App\Exception\custom\MarketingException;
use App\Services\marketing\MarketingGoodsService;
class MarketingController extends Base
{
......@@ -92,6 +94,17 @@ class MarketingController extends Base
$marketingInfo = MarketingService::marketingInfo($params);
$this->success(['result' => $marketingInfo]);
}
/**
* 获取指定商品分销活动的分成比例(第一分销人的分成比例)
* @throws Exception
*/
public function marketing_goods_infoAction()
{
$params = $this->params;
$goodsSkuIds = explode(",", $params["goods_sku_ids"]);
$marketingInfo = MarketingGoodsService::getRunningMarketing($goodsSkuIds);
$this->success(['result' => $marketingInfo]);
}
}
\ No newline at end of file
......@@ -703,9 +703,6 @@ class GoodsService
$subShopList = SubShop::select("*", ["sub_shop_id" => $subShopIds]);
$data["goods_info"]["sub_shop"] = $subShopList;
}
// $marketingGoodsList = MarketingGoodsService::getRunningMarketing([$sku["goods_sku_id"]]);
// var_dump($marketingGoodsList);exit;
}
}
$recordList = GoodsOperationRecord::select("*", ["goods_spu_id" => $goodsSpuId]);
......
......@@ -71,14 +71,35 @@ class MarketingGoodsService
return $result;
}
/**
* 获取指定商品分销活动的分成比例(第一分销人的分成比例)
* @param $goodsSkuIds
* @return array
*/
public static function getRunningMarketing($goodsSkuIds)
{
$goodsSkuIds = ["awPYXhAUBJ4HCT6k", "awPZqLl5KtXQZh6k"];
$marketingIds = MarketingGoods::select("marketing_id", ["goods_sku_id" => $goodsSkuIds]);
if (!empty($marketingIds)) {
$marketingInfoList = MarketingGoods::select(["marketing_id", "goods_sku_id"], ["goods_sku_id" => $goodsSkuIds]);
if (!empty($marketingInfoList)) {
foreach ($marketingInfoList as $marketingInfo) {
$marketingInfoIds[$marketingInfo["goods_sku_id"]] = $marketingInfo["marketing_id"];
}
$marketingIds = array_values($marketingInfoIds);
$now = date("Y-m-d H:i:s");
$marketingList = Marketing::select("*", ["start_time[<]"=>$now, "end_time[>]"=>$now, "marketing_id"=>$goodsSkuIds]);
var_dump($marketingList);exit;
$resMarketingList = Marketing::select("*", ["start_time[<]" => $now, "end_time[>]" => $now, "marketing_id" => $marketingIds, "marketing_type" => Marketing::MARKETING_TYPE_FENXIAO]);
if (!empty($resMarketingList)) {
foreach ($resMarketingList as $res) {
$marketingList[$res["marketing_id"]] = $res;
}
}
$data = [];
foreach ($marketingInfoIds as $goodsSkuId => $marketingId) {
if (!empty($marketingList[$marketingId]["second_commission_value"])) {
$data[$goodsSkuId] = $marketingList[$marketingId]["second_commission_value"] / 100;
}
}
return $data;
}
}
}
......
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