Commit df468118 authored by luhongguang's avatar luhongguang

Merge branch 'develop' of https://git.yidian-inc.com:8021/bp/goods into develop

parents 2cfc1e9c 0d55d1b9
......@@ -43,9 +43,7 @@ class MarketingController extends Base
{
$params = $this->params;
$goodsList = MarketingService::marketingGooodsList($params);
if (!empty($goodsList)) {
$this->success($goodsList);
}
$this->success(['result' => $goodsList]);
}
......
<?php
namespace App\Services\common;
use App\Models\goods\mysql\GoodsSkuSubShop;
use App\Models\shop\mysql\Shop;
use App\Models\shop\mysql\SubShop;
use Api\PhpUtils\Validate\Validate;
use Api\PhpServices\Idgen\Idgen;
// use Validate\ShopValidate;
use App\Exception\custom\ShopException;
use Api\PhpServices\Sensitive\Sensitive;
use App\Exception\custom\InterfaceException;
use Api\PhpUtils\Http\Request;
class CommonService
{
/**
* 通过生活号id获取生活号信息
* life_account_id = [] 数组形式传递
*
*/
public static function getlifeAccountList($params)
{
$lifeAccountId = !empty($params['life_account_id']) ? $params['life_account_id'] : '';
$url = config('interface', 'merchant.lifeaccount.get_life_account_by_ids');
if (empty($url)) {
throw new InterfaceException(['cus' => 1]);
}
if (empty( $lifeAccountId )) {
return [];
}
$params['life_account_ids'] = implode(',', $lifeAccountId);
$res = (new Request())->get($url, $params);
if ($res['code'] == 0 && isset($res['response'])) {
return $res['response']['result'];
}
return [];
}
}
\ No newline at end of file
......@@ -10,6 +10,8 @@ use Api\PhpUtils\Validate\Validate;
use Api\PhpServices\Idgen\Idgen;
use App\Exception\custom\MarketingException;
use Api\PhpServices\Sensitive\Sensitive;
use App\Services\common\CommonService;
class MarketingService
{
......@@ -23,19 +25,22 @@ class MarketingService
{
$startTime = !empty($params['start_time']) ? $params['start_time'] : '';
$endTime = !empty($params['end_time']) ? $params['end_time'] : '';
$goodsSkuId = !empty($params['goods_sku_id']) ? $params['goods_sku_id'] : '';
$lifeAccountId = !empty($params['life_account_id']) ? $params['life_account_id'] : '';
$goodsData = [
"OR" => [
"start_time[>=]" => $startTime,
"end_time[>=]" => $startTime,
],
];
//已存在的活动
$tmpMarketingList = Marketing::getMarketingList($goodsData);
if (!empty($tmpMarketingList)) {
$tmpMarketingId = array_column($tmpMarketingList, 'marketing_id');
}
//已加入活动的商品
$marketingGoodsList = MarketingGoods::marketingGoodsList(['marketing_id' => $tmpMarketingId]);
if (!empty($marketingGoodsList)) {
$tmpGoodsSkuId = array_column($marketingGoodsList, 'goods_sku_id');
}
......@@ -44,16 +49,32 @@ class MarketingService
'online_status' => 1,
];
// $goodsSkuList = GoodsSku::select('*', $where);
//$goodsSkuList =GoodsSku::getRecordMaster($where);
$goodsSkuList =GoodsSku::getRecord($where);
print_r($goodsSkuList);
if (!empty($tmpGoodsSkuId)) {
$where['goods_sku_id[!=]'] = $tmpGoodsSkuId;
}
if (!empty($goodsSkuId)) {
$where['goods_sku_id'] = $goodsSkuId;
}
if (!empty($lifeAccountId)) {
$where['life_account_id'] = $lifeAccountId;
}
$goodsSkuList = GoodsSku::select('*', $where);
$lifeAccountIds = [];
if (!empty($goodsSkuList)) {
$lifeAccountIds = array_column($goodsSkuList, 'life_account_id');
}
$lifeAccountList = CommonService::getlifeAccountList(['life_account_id' => $lifeAccountIds]);
$list = [];
foreach ($goodsSkuList as $key => $value) {
$list[$key]['goods_sku_id'] = $value['goods_sku_id'];
$list[$key]['life_account_id'] = $value['life_account_id'];
$list[$key]['goods_name'] = $value['goods_name'];
$list[$key]['life_account_name'] = !empty($lifeAccountList[$value['life_account_id']]['life_account_name']) ? $lifeAccountList[$value['life_account_id']]['life_account_name'] : '';
}
return $list;
}
/**
......
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