Commit 6927c7c9 authored by luhongguang's avatar luhongguang

update:商品后台需要的接口

parent 92d4d265
<?php
use App\Base\Base;
use \App\Services\marketing\MarketingForOrderService;
class MarketingfororderController extends Base
{
/**
* 分销活动列表
* @throws Exception
*/
public function marketing_listAction()
{
$params = $this->params;
$data = MarketingForOrderService::getMarketingList($params);
$this->success(["result" => $data]);
}
public function goods_listAction()
{
$params = $this->params;
$data = MarketingForOrderService::getMarketingGoodsList($params);
$this->success(["result" => $data]);
}
public function take_place_listAction()
{
$params = $this->params;
$data = MarketingForOrderService::getMarketingTakePlaceList($params);
$this->success(["result" => $data]);
}
}
\ No newline at end of file
<?php
namespace App\Services\marketing;
use App\Exception\custom\MarketingException;
use App\Models\goods\mysql\GoodsSku;
use App\Models\marketing\mysql\Marketing;
use App\Models\marketing\mysql\MarketingGoods;
use App\Models\marketing\mysql\MarketingTakePlace;
use App\Models\marketing\mysql\TakePlace;
class MarketingForOrderService
{
/**
* 活动列表
* @param $params
* @return \Api\PhpUtils\Mysql\MysqlBase
*/
public static function getMarketingList($params)
{
$where['marketing_type'] = !empty($params['marketing_type']) ? $params['marketing_type'] : Marketing::MARKETING_TYPE_FENXIAO;
return Marketing::select(["marketing_id", "marketing_name", "create_time"], ["marketing_type" => $where['marketing_type']]);
}
/**
* 活动的商品
* @param $params
* @return \Api\PhpUtils\Mysql\MysqlBase|array
* @throws MarketingException
*/
public static function getMarketingGoodsList($params)
{
if (empty($params["marketing_id"])) {
throw new MarketingException(['cus' => 6]);
}
$goodsSkuIdList = MarketingGoods::select(["goods_sku_id"], ["marketing_id" => $params["marketing_id"]]);
$goodsSkuList = [];
if (!empty($goodsSkuIdList)) {
$goodsSkuIdArr = array_column($goodsSkuIdList, "goods_sku_id");
$goodsSkuList = GoodsSku::select(["goods_sku_id", "goods_name", "create_time"], ["goods_sku_id" => $goodsSkuIdArr]);
}
return $goodsSkuList;
}
/**
* 活动的自提点
* @param $params
* @throws MarketingException
*/
public static function getMarketingTakePlaceList($params)
{
if (empty($params["marketing_id"])) {
throw new MarketingException(['cus' => 6]);
}
$takePlaceIdList = MarketingTakePlace::select(["take_place_id"], ["marketing_id" => $params["marketing_id"]]);
$takePlaceList = [];
if (!empty($takePlaceIdList)) {
$takePlaceIdArr = array_column($takePlaceIdList, "take_place_id");
$takePlaceList = TakePlace::select(["take_place_id", "take_place_name", "create_time"], ["take_place_id" => $takePlaceIdArr]);
}
return $takePlaceList;
}
}
\ No newline at end of file
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