Commit 02372220 authored by suntengda's avatar suntengda

add 拼单小程序活动列表新版接口 并发获取图片

parent 984dd218
......@@ -174,6 +174,7 @@ class MarketingController extends Base
/**
* 正在进行中的活动简单信息列表
* @throws \App\Exception\custom\InterfaceException
*/
public function pindan_active_basic_listAction()
{
......
......@@ -26,6 +26,7 @@ use Daemon\Goods;
use App\Exception\custom\GoodsException;
use Api\PhpUtils\Redis\RedisUtil;
use Api\PhpUtils\Log\FileLog;
use Helpers\DebugLog;
class MarketingService
{
......@@ -56,7 +57,7 @@ class MarketingService
$lifeAccountId = !empty($params['life_account_id']) ? $params['life_account_id'] : '';
if (empty($startTime)) {
throw new MarketingException(['cus'=>8]);
throw new MarketingException(['cus'=>8]);
}
if (empty($endTime)) {
......@@ -74,7 +75,7 @@ class MarketingService
if ($startTime >= $endTime) {
throw new MarketingException(['cus'=>14]);
}
$goodsData = [
"OR" => [
"start_time[>=]" => $startTime,
......@@ -113,7 +114,7 @@ class MarketingService
if (!empty($lifeAccountId)) {
$where['life_account_id'] = $lifeAccountId;
}
$goodsSkuList = GoodsSku::select('*', $where);
$lifeAccountIds = [];
......@@ -127,7 +128,7 @@ class MarketingService
$list[$key]['goods_spu_id'] = $value['goods_spu_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'] : '';
$list[$key]['life_account_name'] = !empty($lifeAccountList[$value['life_account_id']]['life_account_name']) ? $lifeAccountList[$value['life_account_id']]['life_account_name'] : '';
}
return $list;
}
......@@ -302,14 +303,11 @@ class MarketingService
$where += self::getStartEndTimeFilter($params['activity_status'],$params['from']);
$where['life_account_id'] = self::getPublicLifeAccountId();
$where['ORDER'] = [$sortField => $sortType];
$where['LIMIT'] = [$page, $limit];
$list = Marketing::select(["marketing_id", "marketing_name", "start_time", "end_time",
"online_status", "update_time", "create_time"]
, $where);
$lists = [];
if (!empty($list)) {
$marketingIds = [];
......@@ -322,20 +320,27 @@ class MarketingService
}else {
$userCount = [];
}
$marketingPindanData = MarketingPindan::select(["marketing_id", "publish_life_account_id",
"min_price", "max_price", "pindan_desc","participate_number", "pindan_pic"]
, ["marketing_id" => $marketingIds]);
$priceData = [];
if (!empty($marketingPindanData)) {
foreach ($marketingPindanData as $item) {
$priceData[$item["marketing_id"]] = $item;
}
if(empty($marketingPindanData)) {
return ['result' => [],'count' => 0];
}
$priceData = $picIds = [];
foreach ($marketingPindanData as $item) {
$priceData[$item["marketing_id"]] = $item;
$priceData[$item["marketing_id"]]['pindan_pic'] = $item['pindan_pic'] ? explode(',',$item['pindan_pic']) : [];
$picIds = array_merge($picIds,$priceData[$item["marketing_id"]]['pindan_pic']);
}
//获取图片
$picUrl = Ks3Api::concurrencyPicEncryptUrl($picIds);
//获取生活号信息
$publishLifeAccountIds = array_unique(array_column($marketingPindanData, "publish_life_account_id"));
$lifeAccountList = CommonService::getlifeAccountList(['life_account_id' => $publishLifeAccountIds]);
$defaultPic = "SHQ_goods_0_012Xh1AQcMqu";
foreach ($list as $key => $value) {
$lists[$key] = $value;
$lists[$key]["online_status_desc"] = Marketing::$onlineStatusDesc[$value["online_status"]];
......@@ -348,10 +353,16 @@ class MarketingService
$lists[$key]["life_account_name"] = $lifeAccountList[$currentLifeAccountId]["life_account_name"];
}
$picUrl = GoodsService::getUrlList($priceData[$value["marketing_id"]]["pindan_pic"]);
$lists[$key]["min_price"] = sprintf("%.2f", $priceData[$value["marketing_id"]]["min_price"] / 100);
$lists[$key]["max_price"] = sprintf("%.2f", $priceData[$value["marketing_id"]]["max_price"] / 100);
$lists[$key]["pindan_pic_url"] = $picUrl;
if($priceData[$value["marketing_id"]]['pindan_pic']) {
foreach($priceData[$value["marketing_id"]]["pindan_pic"] as $picId) {
$lists[$key]["pindan_pic_url"][] = $picUrl[$picId];
}
}else {
$lists[$key]["pindan_pic_url"] = [];
}
$lists[$key]["pindan_desc"] = $priceData[$value["marketing_id"]]["pindan_desc"];
$lists[$key]["participate_number"] = empty($userCount[$value['marketing_id']]) ? 0 : $userCount[$value['marketing_id']];
......@@ -368,6 +379,7 @@ class MarketingService
unset($where['LIMIT']);
unset($where['ORDER']);
$count = Marketing::count("*", $where);
return ['result' => $lists,'count' => $count];
}
......@@ -425,7 +437,7 @@ class MarketingService
}
//获取活动sku列表
if($needSkuList) {
$skuList = self::getGoodsSkuListByMarketingIds(array_keys($list));
$skuList = self::getGoodsSkuListByMarketingIds(array_keys($list),false);
foreach ($list as $marketingId => &$value) {
$value['sku_list'] = $skuList[$marketingId] ?? [];
......@@ -595,7 +607,7 @@ class MarketingService
$rate = $firstCommissionRate + $secondCommissionRate;
if ($rate > 5000) {
throw new MarketingException(['cus'=>15]);
}
}
}
if (empty($goodsSkuId)) {
......@@ -742,7 +754,7 @@ class MarketingService
throw new MarketingException(['cus'=>33]);
}
}
//固定金额
if ($commissionMode == Marketing::COMMISSION_MODE_FIXED) {
$commissionTotal = ($firstCommissionRate + $secondCommissionRate);
......@@ -751,8 +763,8 @@ class MarketingService
}
}
}
$colums[$key]['marketing_id'] = $marketingId;
$colums[$key]['goods_spu_id'] = $value['goods_spu_id'];
......@@ -1400,7 +1412,7 @@ class MarketingService
$list[$value['marketing_id']][$key]["desc_pic_url_list"] = GoodsService::getUrlList($item["desc_pic_url"]);
$list[$value['marketing_id']][$key]["original_price"] = empty($item["original_price"]) ? '' : sprintf("%.2f", (int)$item["original_price"] / 100);
$list[$value['marketing_id']][$key]["price"] = sprintf("%.2f", $item["price"] / 100);
$list[$value['marketing_id']][$key]["all_have_buy_goods_count"] = $soldNum[$value["goods_sku_id"]] ?? 0;
$needSoldNum && $list[$value['marketing_id']][$key]["all_have_buy_goods_count"] = $soldNum[$value["goods_sku_id"]] ?? 0;
$list[$value['marketing_id']][$key]['inventory_rest'] = $item['inventory_rest'];
}
......@@ -1439,17 +1451,17 @@ class MarketingService
return $data;
}
/**
*判断长度
*
*/
/**
*判断长度
*
*/
public static function utf8Strlen($string = null) {
// 将字符串分解为单元
preg_match_all("/./us", $string, $match);
// // 返回单元个数
return count($match[0]);
}
/**
* 通过发号器拿 id (非雪花)
* number,获取店铺shop_id用生活号id后两位,商品相关的这里是shop_id的后两位
......
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