Commit 325bebb9 by 杨树贤

修改接口数据

parent 2f26e091
...@@ -4,14 +4,14 @@ APP_KEY= ...@@ -4,14 +4,14 @@ APP_KEY=
APP_TIMEZONE=PRC APP_TIMEZONE=PRC
//系统编码,用于生成错误码 //系统编码,用于生成错误码
SYSTEM_CODE=02 SYSTEM_CODE=06
//系统名称,用于告警识别 //系统名称,用于告警识别
SYSTEM_NAME=商品信息处理服务(开发环境) SYSTEM_NAME=商品信息处理服务(开发环境)
//laravels监听IP和端口 //laravels监听IP和端口
LARAVELS_LISTEN_IP=0.0.0.0 LARAVELS_LISTEN_IP=0.0.0.0
LARAVELS_LISTEN_PORT=62002 LARAVELS_LISTEN_PORT=62006
//基石自营商品主库 //基石自营商品主库
DB_Self_HOST=192.168.1.234 DB_Self_HOST=192.168.1.234
......
...@@ -11,7 +11,7 @@ class BrandController extends Controller ...@@ -11,7 +11,7 @@ class BrandController extends Controller
//获取品牌列表 //获取品牌列表
public function index(Request $request, SelfBrandModel $model) public function index(Request $request, SelfBrandModel $model)
{ {
$map = $request->only(['brand_area']); $map = $request->only(['brand_area','brand_id']);
$list = $model->getBrandList($map); $list = $model->getBrandList($map);
return $this->Export(0, 'ok', ['data' => $list]); return $this->Export(0, 'ok', ['data' => $list]);
......
...@@ -34,6 +34,29 @@ class SelfBrandModel extends Model ...@@ -34,6 +34,29 @@ class SelfBrandModel extends Model
} }
} }
public function HDBrandLogo($BrandID = '', $Redis = '')
{
if (empty($BrandID)) {
return false;
}
if (empty($Redis)) {
$Redis = new RedisModel();
}
$BrandName = $Redis->hget('Self_Brand', $BrandID);
if (!$BrandName) {
$result = $this->ToRedis($BrandID, $Redis);
if (!$result) {
return false;
}
return $result['brand_logo'];
} else {
$BrandName = json_decode($BrandName, true);
return $BrandName['brand_logo'];
}
}
public function ToRedis($BrandID, $Redis = '') public function ToRedis($BrandID, $Redis = '')
{ {
if (empty($BrandID)) { if (empty($BrandID)) {
...@@ -97,6 +120,18 @@ class SelfBrandModel extends Model ...@@ -97,6 +120,18 @@ class SelfBrandModel extends Model
return $brandListByArea; return $brandListByArea;
} }
//如果有id筛选,就要做数据处理
if (!empty($map['brand_id'])&&!empty($brandList)) {
$brandListByBrandId = [];
$brandIds = explode(',', $map['brand_id']);
foreach ($brandList as $key => $brand) {
if (in_array($brand['brand_id'], $brandIds)) {
$brandListByBrandId[] = $brand;
}
}
return $brandListByBrandId;
}
//没有就去数据库里面取 //没有就去数据库里面取
if (!$brandList) { if (!$brandList) {
......
...@@ -58,7 +58,7 @@ class SelfClassifyModel extends Model ...@@ -58,7 +58,7 @@ class SelfClassifyModel extends Model
$classList = array_map(function ($value) { $classList = array_map(function ($value) {
return json_decode($value, true); return json_decode($value, true);
}, $classList); }, $classList);
$classList = $this->transform($classList);
if (!$classList) { if (!$classList) {
return Cache::remember('classList', $classificationsExpireMinute, function () { return Cache::remember('classList', $classificationsExpireMinute, function () {
$field = [ $field = [
...@@ -78,5 +78,29 @@ class SelfClassifyModel extends Model ...@@ -78,5 +78,29 @@ class SelfClassifyModel extends Model
}); });
} }
return $classList;
}
private function transform($data)
{
//将子分类放到父分类下面
$parentClass = [];
foreach ($data as $key => $item) {
//先获取所有父分类
if ($item['parent_id'] == 0) {
$item['sub_class'] = [];
$parentClass[] = $item;
unset($data[$key]);
}
}
foreach ($parentClass as $key => $value) {
foreach ($data as $k => $v) {
if ($v['parent_id'] == $value['class_id']) {
$parentClass[$key]['sub_class'][] = $v;
}
}
}
return $parentClass;
} }
} }
...@@ -21,6 +21,7 @@ class SelfGoodsModel extends Model ...@@ -21,6 +21,7 @@ class SelfGoodsModel extends Model
$Find['supplier_name']=$SupplierModel->ObSupplierName($Find['supplier_id']); $Find['supplier_name']=$SupplierModel->ObSupplierName($Find['supplier_id']);
$Find['brand_name']=$BrandModel->HDBrandName($Find['brand_id'],$Redis); $Find['brand_name']=$BrandModel->HDBrandName($Find['brand_id'],$Redis);
$Find['brand_logo']=$BrandModel->HDBrandLogo($Find['brand_id'],$Redis);
$Find['goods_unit_name']=$UnitModel->OBUnitInfo($Find['goods_unit'],$Redis); $Find['goods_unit_name']=$UnitModel->OBUnitInfo($Find['goods_unit'],$Redis);
$Find['packing_name']=$UnitModel->OBUnitInfo($Find['packing'],$Redis); $Find['packing_name']=$UnitModel->OBUnitInfo($Find['packing'],$Redis);
$Find['mpq_unit_name']=$UnitModel->OBUnitInfoAlias($Find['packing'],$Redis); $Find['mpq_unit_name']=$UnitModel->OBUnitInfoAlias($Find['packing'],$Redis);
......
1575964153a:6:{s:8:"brand_id";i:1;s:10:"brand_name";s:7:"ALLEGRO";s:10:"brand_logo";s:0:"";s:10:"brand_desc";s:0:"";s:11:"brand_brief";s:0:"";s:10:"brand_area";i:1;}
\ No newline at end of file
1575532911a:6:{s:8:"brand_id";i:5290;s:10:"brand_name";s:20:"CJIANG(长江微电)";s:10:"brand_logo";s:0:"";s:10:"brand_desc";s:0:"";s:11:"brand_brief";s:0:"";s:10:"brand_area";i:4;} 1576033942a:6:{s:8:"brand_id";i:5290;s:10:"brand_name";s:20:"CJIANG(长江微电)";s:10:"brand_logo";s:83:"//img.sensorhunt.com/test/images/cms/201912/09/1b65e9e4ad5ad5d568c623dd6eec4581.png";s:10:"brand_desc";s:0:"";s:11:"brand_brief";s:0:"";s:10:"brand_area";i:4;}
\ No newline at end of file \ No newline at end of file
1575860787a:6:{s:8:"brand_id";i:1;s:10:"brand_name";s:7:"ALLEGRO";s:10:"brand_logo";s:0:"";s:10:"brand_desc";s:0:"";s:11:"brand_brief";s:0:"";s:10:"brand_area";i:1;}
\ No newline at end of file
1575860782a:6:{s:8:"brand_id";i:1;s:10:"brand_name";s:7:"ALLEGRO";s:10:"brand_logo";s:0:"";s:10:"brand_desc";s:0:"";s:11:"brand_brief";s:0:"";s:10:"brand_area";i:1;}
\ No newline at end of file
1575860792a:6:{s:8:"brand_id";i:1;s:10:"brand_name";s:7:"ALLEGRO";s:10:"brand_logo";s:0:"";s:10:"brand_desc";s:0:"";s:11:"brand_brief";s:0:"";s:10:"brand_area";i:1;}
\ 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 sign in to comment