Commit b450b58c authored by luhongguang's avatar luhongguang

update: 通过goods_sku_id 获取 拼单商品的ota信息

parent 83829666
......@@ -314,4 +314,14 @@ class GoodsController extends Base
$res = GoodsSnapshotsService::pindanGoodsSnapshots($this->params);
$this->success(["result" => $res]);
}
/**
* 通过goods_sku_id 获取 拼单商品的ota信息
* @throws Exception
*/
public function take_place_by_goods_sku_idsAction()
{
$res = GoodsService::getOtaInfoByGoodsSkuIds($this->params);
$this->success(["result" => $res]);
}
}
\ No newline at end of file
......@@ -20,6 +20,7 @@ use App\Models\goods\mysql\GoodsSkuSubShop;
use App\Models\goods\mysql\GoodsSnapshot;
use App\Models\goods\mysql\GoodsSpu;
use App\Models\goods\mysql\LifeAccountShopNum;
use App\Models\goods\mysql\Ota;
use App\Models\goods\mysql\PaySuccessGoodsCallbackRecord;
use App\Models\goods\mysql\PindanGoodsSku;
use App\Models\goods\mysql\Shop;
......@@ -1709,4 +1710,29 @@ class GoodsService
}
return true;
}
/**
* 通过goods_sku_id 获取 拼单商品的ota信息
* @param array $params
* @return array
*/
public static function getOtaInfoByGoodsSkuIds($params = [])
{
$data = [];
$goodsSkuIds = empty($params["goods_sku_ids"]) ? [] : $params["goods_sku_ids"];
if (!empty($goodsSkuIds)) {
$pindanGoodsSkus = PindanGoodsSku::select(["goods_sku_id", "ota_id"], ["goods_sku_id" => $goodsSkuIds]);
$otaIds = array_column($pindanGoodsSkus, "ota_id");
$otaInfos = Ota::select("*", ["ota_id" => $otaIds]);
$otaIds = array_column($otaInfos, "ota_id");
$otaInfos = array_column($otaInfos, null, "ota_id");
foreach ($pindanGoodsSkus as $sku) {
if (in_array($sku["ota_id"], $otaIds)) {
$data[$sku["goods_sku_id"]] = $otaInfos[$sku["ota_id"]];
}
}
}
return $data;
}
}
\ 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