Commit 0e998885 authored by 卢洪光's avatar 卢洪光

Merge branch 'feature_jielong_native' into 'pre_release'

Feature jielong native

See merge request bp/goods!56
parents b0f541db bd87fc3e
<?php
namespace App\Services\common;
use Api\PhpUtils\Kafka\KafkaUtil;
use Api\PhpUtils\Log\FileLog;
class KafkaService
{
/**
* marketing 广播
*/
public static function productMarketingUpdate(array $marketingInfo) : void
{
$msg = json_encode([
'marketingInfo' => $marketingInfo,
'time' => time(),
], JSON_FORCE_OBJECT);
$serverName = 'goods.publish';
$kafka = KafkaUtil::getInstance($serverName);
if ($kafka->produce($msg, $marketingInfo['activityId'])) {
FileLog::info(sprintf('kafka produce success serverName %s msg = %s', $serverName, $msg));
}
else {
FileLog::error(sprintf('kafka produce failure serverName %s msg = %s', $serverName, $msg));
}
}
}
\ No newline at end of file
......@@ -6,6 +6,7 @@ namespace App\Services\marketing;
use Api\PhpServices\Ksy\Ks3Api;
use Api\PhpUtils\Http\Request;
use Api\PhpUtils\Http\HttpUtil;
use App\Exception\BaseException;
use App\Exception\custom\InterfaceException;
use App\Models\goods\mysql\Ota;
use App\Models\goods\mysql\PindanGoodsSku;
......@@ -19,6 +20,7 @@ use App\Models\marketing\mysql\MarketingPindan;
use App\Models\marketing\mysql\MarketingTakePlace;
use App\Models\marketing\mysql\TakePlace;
use App\Services\common\CommonService;
use App\Services\common\KafkaService;
use App\Services\goods\GoodsService;
use Daemon\Goods;
use App\Exception\custom\GoodsException;
......@@ -740,6 +742,19 @@ class MarketingService
throw new MarketingException(["cus" => 5]);
}
$picList = GoodsService::getUrlList($pindanPic);
KafkaService::productMarketingUpdate([
'activityId' => $marketingId,
'startDate' => $startTime,
'endDate' => $endTime,
'userId' => $lifeAccountId,
'activityName' => $marketingName,
'text' => $pindanDesc,
'imageId' => $picList[0] ?? '',
'createTime' => date('Y-m-d H:i:s'),
'onlineStatus' => Marketing::ONLINE_STATUS_QIDONG,
]);
return $pindanId;
}
......@@ -895,6 +910,20 @@ class MarketingService
throw new MarketingException(["cus" => 5]);
}
$picList = GoodsService::getUrlList($marketingPindan['pindan_pic']);
KafkaService::productMarketingUpdate([
'activityId' => $marketingId,
'startDate' => $startTime,
'endDate' => $endTime,
'userId' => config('lifeaccount','life_account_id'),
'activityName' => $marketingName,
'text' => $pindanDesc,
'imageId' => $picList[0] ?? '',
'createTime' => $marketing['create_time'],
'onlineStatus' => Marketing::ONLINE_STATUS_QIDONG,
]);
return true;
}
......@@ -921,6 +950,26 @@ class MarketingService
'online_status' => $onlineStatus,
'end_time' => $endTime,
];
if ($marketingType == Marketing::MARKETING_TYPE_PINDAN) {
$marketing = Marketing::getRecord(["marketing_id" => $marketingId]);
$marketingPindan = MarketingPindan::getRecord(["marketing_id" => $marketingId]);
$picList = GoodsService::getUrlList($marketingPindan['pindan_pic']);
KafkaService::productMarketingUpdate([
'activityId' => $marketingId,
'startDate' => $marketing['start_time'],
'endDate' => $endTime,
'userId' => config('lifeaccount','life_account_id'),
'activityName' => $marketing['marketing_name'],
'text' => $marketingPindan['pindan_desc'],
'imageId' => $picList[0] ?? '',
'createTime' => $marketing['create_time'],
'onlineStatus' => $onlineStatus,
]);
}
Marketing::updateRecord($marketingParams, ["marketing_id" => $marketingId, "marketing_type" => $marketingType]);
}
......
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