Commit aaa7a155 authored by luhongguang's avatar luhongguang

update:C端商家商品列表

parent 90f7f75b
<?php
namespace Validate;
/**
* Class GoodsListCValidate
*
* @package Validate
*/
class GoodsListCValidate extends BaseValidate
{
protected $rule = [
'life_account_id' => 'require',
];
protected $message = [
"life_account_id" => "生活号id不能为空",
];
}
\ No newline at end of file
......@@ -9,6 +9,7 @@ use \Validate\GoodsAddValidate;
use \Validate\GoodsEditValidate;
use \Validate\GoodsInfoOpValidate;
use \Validate\GoodsInfoFeValidate;
use \Validate\GoodsListCValidate;
use \App\Services\goods\ElasticGoodService;
......@@ -132,11 +133,25 @@ class GoodsController extends Base
* c端 es:商品列表 (sku list)
* @throws Exception
*/
public function goods_list_cAction()
public function goods_list_esAction()
{
$params = $this->params;
$data = ElasticGoodService::searchDoc($params);
$this->success(["result" => $data]);
}
/**
* 商家 - 商品列表 (sku list)
* @throws Exception
*/
public function goods_list_cAction()
{
(new GoodsListCValidate())->validate();
$params = $this->params;
$data = GoodsService::getCGoodsSkuList($params["life_account_id"]);
$this->success(["result" => $data]);
}
}
\ No newline at end of file
......@@ -533,9 +533,47 @@ class GoodsService
}
public static function getCGoodsSpuList($params = [])
/**
* 商家 c端商品列表
* @param $lifeAccountId
* @return array
*/
public static function getCGoodsSkuList($lifeAccountId)
{
$statusList = [
["type" => "online", "name" => "上架中"],
["type" => "auditing", "name" => "审核中"],
["type" => "rejected", "name" => "被驳回"],
["type" => "offline", "name" => "已下架"],
];
$list = GoodsSku::select(["goods_sku_id", "name", "url", "total_amount_sold", "inventory_rest", "original_price",
"price", "status", "online_status"],
["life_account_id" => $lifeAccountId]);
$data = [
"online" => [],
"auditing" => [],
"rejected" => [],
"offline" => [],
];
if (!empty($list)) {
foreach ($list as $sku) {
if ($sku["status"] == GoodsSku::STATUS_PASS && $sku["online_status"] == GoodsSku::ONLINE_STATUS_ONLINE) {
$data["online"][] = $sku;
}
if ($sku["status"] == GoodsSku::STATUS_AUDIT) {
$data["auditing"][] = $sku;
}
if ($sku["status"] == GoodsSku::STATUS_REJECT) {
$data["rejected"][] = $sku;
}
if ($sku["online_status"] == GoodsSku::ONLINE_STATUS_OFFLINE) {
$data["offline"][] = $sku;
}
}
}
return ["status_list" => $statusList, "data" => $data];
}
/**
......
......@@ -24,7 +24,7 @@ exception.sys.code = -1
exception.sys.msg = "system error"
[product : common : exception]
[prod : common : exception]
[pre : common : exception]
[test : common : exception]
[dev : common : exception]
\ 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