Commit 75f13301 by 杨树贤

解决冲突

parents 325bebb9 3c1c338a
...@@ -13,53 +13,24 @@ SYSTEM_NAME=商品信息处理服务(开发环境) ...@@ -13,53 +13,24 @@ SYSTEM_NAME=商品信息处理服务(开发环境)
LARAVELS_LISTEN_IP=0.0.0.0 LARAVELS_LISTEN_IP=0.0.0.0
LARAVELS_LISTEN_PORT=62006 LARAVELS_LISTEN_PORT=62006
//基石自营商品主库 //基石自营商品主库
DB_Self_HOST=192.168.1.234 DB_Self_HOST=192.168.2.239
DB_Self_DATABASE=liexin_data DB_Self_DATABASE=lc_footstone
DB_Self_USERNAME=spu DB_Self_USERNAME=root
DB_Self_PASSWORD=spu DB_Self_PASSWORD=root
DB_Self_PORT=3306 DB_Self_PORT=3306
DB_Self_PREFIX=lie_ DB_Self_PREFIX=lie_
//采购系统数据库 //采购系统数据库
DB_PUR_HOST=192.168.2.232 DB_Pur_HOST=192.168.2.239
DB_PUR_DATABASE=liexin_wms DB_Pur_DATABASE=lc_wms
DB_PUR_USERNAME=liexin_wms DB_Pur_USERNAME=root
DB_PUR_PASSWORD=liexin_wms#zsyM DB_Pur_PASSWORD=root
DB_PUR_PORT=3306 DB_Pur_PORT=3306
DB_Pur_PREFIX=lie_ DB_Pur_PREFIX=lie_
//基石联营SPU数据库
DB_SPU_HOST=192.168.1.234
DB_SPU_DATABASE=liexin_spu
DB_SPU_USERNAME=spu
DB_SPU_PASSWORD=spu
DB_SPU_PORT=3306
DB_SPU_PREFIX=lie_
//基石数据库名字配置
SPU_DB_DATABASE=liexin_spu
SKU_0_DB_DATABASE=liexin_sku_0
SKU_1_DB_DATABASE=liexin_sku_1
SKU_2_DB_DATABASE=liexin_sku_2
SKU_3_DB_DATABASE=liexin_sku_3
SKU_4_DB_DATABASE=liexin_sku_4
SKU_5_DB_DATABASE=liexin_sku_5
SKU_6_DB_DATABASE=liexin_sku_6
SKU_7_DB_DATABASE=liexin_sku_7
SKU_8_DB_DATABASE=liexin_sku_8
SKU_9_DB_DATABASE=liexin_sku_9
DB_CONNECTION=mysql
DB_HOST=192.168.2.239
DB_USERNAME=root
DB_PASSWORD=root
DB_PORT=3306
DB_DATABASE=lc_footstone
DB_PREFIX=lie_
REDIS_HOST=192.168.1.235 REDIS_HOST=192.168.1.235
REDIS_PASSWORD=icDb29mLy2s REDIS_PASSWORD=icDb29mLy2s
REDIS_PORT=6379 REDIS_PORT=6379
...@@ -69,10 +40,5 @@ REDIS_READ_HOST=192.168.1.237 ...@@ -69,10 +40,5 @@ REDIS_READ_HOST=192.168.1.237
REDIS_READ_PASSWORD=icDb29mLy2s REDIS_READ_PASSWORD=icDb29mLy2s
REDIS_READ_PORT=6379 REDIS_READ_PORT=6379
MONG_DB_SPU_ATTRS_HOST=192.168.1.237
MONG_DB_SPU_ATTRS_USERNAME=ichunt
MONG_DB_SPU_ATTRS_PASSWORD=huntmon6699
MONG_DB_SPU_ATTRS_DATABASE=ichunt
CACHE_DRIVER=file CACHE_DRIVER=file
QUEUE_DRIVER=sync QUEUE_DRIVER=sync
...@@ -22,22 +22,16 @@ class ServicesController extends Controller ...@@ -22,22 +22,16 @@ class ServicesController extends Controller
$SkuId=$collert['goods_id']; $SkuId=$collert['goods_id'];
$Redis=new RedisModel(); $Redis=new RedisModel();
$GoodsModel=new SelfGoodsModel(); $GoodsModel=new SelfGoodsModel();
$SkuModel=new SkuModel();
$SpuModel=new SpuModel();
if(is_string($SkuId) && stripos($SkuId,',')!==false) $SkuId=explode(',',$SkuId);//兼容逗号方式 if(is_string($SkuId) && stripos($SkuId,',')!==false) $SkuId=explode(',',$SkuId);//兼容逗号方式
$data=[]; $data=[];
if(is_array($SkuId)){ if(is_array($SkuId)){
foreach ($SkuId as $k=>$v){ foreach ($SkuId as $k=>$v){
$data[$v]=false; $data[$v]=false;
if(strlen($v)==19) {//联营或者专卖 $data[$v]=$GoodsModel->WebSelfGoodsDetail($v, $collert['power'], $Redis);
$data[$v] = $SkuModel->combination($v,$collert['power'], $Redis,$SpuModel);
}else $data[$v]=$GoodsModel->WebSelfGoodsDetail($v, $collert['power'], $Redis);
} }
}else{ }else{
$data[$SkuId]=false; $data[$SkuId]=false;
if(strlen($SkuId)==19) {//联营或者专卖 $data[$SkuId]=$GoodsModel->WebSelfGoodsDetail($SkuId, $collert['power'], $Redis);
$data[$SkuId] = $SkuModel->combination($SkuId,$collert['power'], $Redis,$SpuModel);
}else $data[$SkuId]=$GoodsModel->WebSelfGoodsDetail($SkuId, $collert['power'], $Redis);
} }
return $this->Export(0,'success',['data'=>$data]); return $this->Export(0,'success',['data'=>$data]);
} }
......
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
class PoolBrandModel extends Model
{
protected $connection = 'spu';
protected $table = 'brand';
public $timestamps = false;
//从redis获取分类数据
public function HdCacheBrand($BrandID,$Redis=''){
if(empty($BrandID)) return false;
if(empty($Redis)) $Redis=new RedisModel();
$Find=$Redis->hget('brand',$BrandID);
if($Find) return $Find;
$Find=$this->where('brand_id','=',$BrandID)->select('brand_name')->first();
if(!$Find) return false;
$Find=$Find->toArray();
$Redis->hset('brand',$BrandID,$Find['brand_name']);
$Redis->hset('brand_name_all',md5(strtolower($Find['brand_name'])),$BrandID);
ErrorLog('',0000,'SPU品牌缓存丢失,BrandID:'.$BrandID);
return $Find['brand_name'];
}
}
\ No newline at end of file
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
class PoolClassModel extends Model
{
protected $connection = 'spu';
protected $table = 'classify';
public $timestamps = false;
//从redis获取分类数据
public function HdCacheClass($ClassID,$Redis=''){
if(empty($ClassID)) return false;
if(empty($Redis)) $Redis=new RedisModel();
$Find=$Redis->hget('class',$ClassID);
if($Find) return $Find;
$Find=$this->where('class_id','=',$ClassID)->select('class_name')->first();
if(!$Find) return false;
$Find=$Find->toArray();
$Redis->hset('class',$ClassID,$Find['class_name']);
//需要记录一下日志
ErrorLog('',0000,'SPU分类缓存丢失,CLASSID:'.$ClassID);
return $Find['class_name'];
}
}
\ No newline at end of file
...@@ -5,6 +5,7 @@ namespace App\Model; ...@@ -5,6 +5,7 @@ namespace App\Model;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Common\Model\RedisModel;
class SelfClassifyModel extends Model class SelfClassifyModel extends Model
{ {
...@@ -103,4 +104,14 @@ class SelfClassifyModel extends Model ...@@ -103,4 +104,14 @@ class SelfClassifyModel extends Model
return $parentClass; return $parentClass;
} }
//获取分类参数
public function getClassAttr($class_id){
$Redis = new RedisModel();
$Cache = json_decode($Redis->hget('class_attr', $class_id), true);
if(empty($Cache)){
return false;
}
return $Cache;
}
} }
...@@ -16,7 +16,6 @@ class SelfGoodsModel extends Model ...@@ -16,7 +16,6 @@ class SelfGoodsModel extends Model
if(empty($SupplierModel)) $SupplierModel = new SupplierChannelModel(); if(empty($SupplierModel)) $SupplierModel = new SupplierChannelModel();
if(empty($BrandModel)) $BrandModel = new SelfBrandModel(); if(empty($BrandModel)) $BrandModel = new SelfBrandModel();
if(empty($UnitModel)) $UnitModel = new UnitModel(); if(empty($UnitModel)) $UnitModel = new UnitModel();
if(empty($ResourceModel)) $ResourceModel = new ResourceModel();
if(empty($ClassModel)) $ClassModel = new SelfClassifyModel(); if(empty($ClassModel)) $ClassModel = new SelfClassifyModel();
$Find['supplier_name']=$SupplierModel->ObSupplierName($Find['supplier_id']); $Find['supplier_name']=$SupplierModel->ObSupplierName($Find['supplier_id']);
...@@ -25,10 +24,6 @@ class SelfGoodsModel extends Model ...@@ -25,10 +24,6 @@ class SelfGoodsModel extends Model
$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);
$GoodsImages=$ResourceModel->GetResourceInfoById($Find['goods_images'],$Redis);
$Find['goods_images']=$GoodsImages;
$GoodsPdf=$ResourceModel->GetResourceInfoById($Find['pdf'],$Redis);
$Find['pdf']=$GoodsPdf;
if(!empty($Find['class_name'])) unset($Find['class_name']); if(!empty($Find['class_name'])) unset($Find['class_name']);
//处理库存 //处理库存
...@@ -57,13 +52,26 @@ class SelfGoodsModel extends Model ...@@ -57,13 +52,26 @@ class SelfGoodsModel extends Model
if(!empty($Find['class_id2'])){ if(!empty($Find['class_id2'])){
$class_id2=$ClassModel->ProduceClassRedis($Find['class_id2'],false,$Redis); $class_id2=$ClassModel->ProduceClassRedis($Find['class_id2'],false,$Redis);
empty($class_id2['class_name']) || $Find['class_id2_name']=$class_id2['class_name']; empty($class_id2['class_name']) || $Find['class_id2_name']=$class_id2['class_name'];
//处理分类参数重要值
$ClassAttrCache = $ClassModel->getClassAttr($Find['class_id2']);
if($ClassAttrCache && is_array($ClassAttrCache)){
foreach ($ClassAttrCache as $k=>$v){
$ClassAttrCache[md5($v['attr_name'])] = empty($v['is_important']) ? 1 : $v['is_important'];
unset($ClassAttrCache[$k]);
}
if(!empty($Find['attrs']) && is_array($Find['attrs'])){
foreach ($Find['attrs'] as $k=>$v){
$Find['attrs'][$k]['is_important'] = empty($ClassAttrCache[md5($v['attr_name'])]) ? 1 : $ClassAttrCache[md5($v['attr_name'])];
}
}
}
} }
if(is_array($Find['ladder_price'])){ if(is_array($Find['ladder_price'])){
$Find['ladder_price']=arraySequence($Find['ladder_price'],'purchases','SORT_ASC'); $Find['ladder_price']=arraySequence($Find['ladder_price'],'purchases','SORT_ASC');
} }
if($Find['status'] != 1 || !count($Find['ladder_price'])>0 || empty($Find['ladder_price'][0]['purchases'])){ if($Find['status'] != 1 || !count($Find['ladder_price'])>0 || empty($Find['ladder_price'][0]['purchases'])){
$Find['is_buy']=0; $Find['is_buy']=0;
}else{ }else{
...@@ -212,7 +220,7 @@ class SelfGoodsModel extends Model ...@@ -212,7 +220,7 @@ class SelfGoodsModel extends Model
$this->connection='self';//开始连接数据库 $this->connection='self';//开始连接数据库
$fieldArr=['other_attrs', 'goods_id','goods_type','supplier_id','brand_id','class_id1','class_id2','goods_name','status', $fieldArr=['other_attrs', 'goods_id','goods_type','supplier_id','brand_id','class_id1','class_id2','goods_name','status',
'encoded','encap','packing','goods_unit','goods_images','pdf','goods_brief','moq','mpq', 'encoded','encap','packing','goods_unit','goods_images','pdf','goods_brief','moq','mpq',
'ladder_price','update_time','sku_name','mpl','stock','attrs','cost','new_cost']; 'ladder_price','update_time','sku_name','mpl','stock','attrs','cost','new_cost','cn_delivery_time'];
$info=$this->where('goods_id','=',$goods_id)->select($fieldArr)->first(); $info=$this->where('goods_id','=',$goods_id)->select($fieldArr)->first();
if(!$info) return false; if(!$info) return false;
$info=$info->toArray(); $info=$info->toArray();
......
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
use DB;
class SpuAttrsModel extends Model
{
protected $connection = 'mongodb';
protected $table = 'spu_attrs';
public $timestamps = false;
public function HdCacheAttrs($SpuID){
$Find=DB::connection('mongodb')->table('spu_attrs')->where('spu_id','=',(int)$SpuID)->select('attrs')->first();
if(!$Find) return false;
$info=json_decode($Find['attrs'],true);
if(!$info) return false;
$Attrs=false;
foreach ($info as $k=>$v){
$Attrs[]=[
'attr_name'=>$k,
'attr_value'=>$v
];
}
return $Attrs;
}
}
\ No newline at end of file
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
class SpuModel extends Model
{
protected $connection = false;
protected $table = false;
public $timestamps = false;
//生成数据库连接
public function ConnectDB($SpuId)
{
if (strlen($SpuId) !== 19) return false;
$dt = resolve($SpuId);
$this->connection = $dt['db'];
$this->table = $dt['table'];
return true;
}
//从redis获取spu数据
public function HdCacheSpu($SpuID,$Redis=''){
if(empty($SpuID)) return false;
if(empty($Redis)) $Redis=new RedisModel();
$Find=json_decode($Redis->hget('spu',$SpuID),true);
if($Find) return $Find;
$this->ConnectDB($SpuID);
$Find=$this->where('spu_id',$SpuID)
->select('spu_id','class_id1','class_id2','class_id3','spu_name','brand_id','status','update_time','images_l','encap','pdf','spu_brief','attrs','spu_detail')
->first();
if(!$Find) return false;
$Find=$Find->toArray();
$Find['attrs']=json_decode($Find['attrs'],true);
//更新redis
$Redis->hset('spu',$SpuID,json_encode($Find));
//需要记录一下日志
ErrorLog('',0000,'SPU缓存丢失,SPUID:'.$SpuID);
return $Find;
}
}
\ No newline at end of file
...@@ -118,182 +118,6 @@ return [ ...@@ -118,182 +118,6 @@ return [
], ],
], ],
'spu'=>[
'driver' => 'mysql',
'host' => env('DB_SPU_HOST', ''),
'database' => env('DB_SPU_DATABASE', ''),
'username' => env('DB_SPU_USERNAME', ''),
'password' => env('DB_SPU_PASSWORD', ''),
'port' => env('DB_SPU_PORT', 3306),
'charset' => 'utf8',
'collation' => 'utf8_general_ci',
'prefix' => env('DB_SPU_PREFIX', 'lie_'),
'options' => [
// 开启持久连接
\PDO::ATTR_PERSISTENT => true,
],
],
'sku_0' => [
'driver' => 'mysql',
'database' => env('SKU_0_DB_DATABASE', ''),
'host' => env('DB_SPU_HOST', ''),
'username' => env('DB_SPU_USERNAME', ''),
'password' => env('DB_SPU_PASSWORD', ''),
'port' => env('DB_PORT', 3306),
'charset' => 'utf8',
'collation' => 'utf8_general_ci',
'prefix' => env('DB_SPU_PREFIX', 'lie_'),
'options' => [
// 开启持久连接
\PDO::ATTR_PERSISTENT => true,
],
],
'sku_1' => [
'driver' => 'mysql',
'database' => env('SKU_1_DB_DATABASE', ''),
'host' => env('DB_SPU_HOST', ''),
'username' => env('DB_SPU_USERNAME', ''),
'password' => env('DB_SPU_PASSWORD', ''),
'port' => env('DB_PORT', 3306),
'charset' => 'utf8',
'collation' => 'utf8_general_ci',
'prefix' => env('DB_SPU_PREFIX', 'lie_'),
'options' => [
// 开启持久连接
\PDO::ATTR_PERSISTENT => true,
],
],
'sku_2' => [
'driver' => 'mysql',
'database' => env('SKU_2_DB_DATABASE', ''),
'host' => env('DB_SPU_HOST', ''),
'username' => env('DB_SPU_USERNAME', ''),
'password' => env('DB_SPU_PASSWORD', ''),
'port' => env('DB_PORT', 3306),
'charset' => 'utf8',
'collation' => 'utf8_general_ci',
'prefix' => env('DB_SPU_PREFIX', 'lie_'),
'options' => [
// 开启持久连接
\PDO::ATTR_PERSISTENT => true,
],
],
'sku_3' => [
'driver' => 'mysql',
'database' => env('SKU_3_DB_DATABASE', ''),
'host' => env('DB_SPU_HOST', ''),
'username' => env('DB_SPU_USERNAME', ''),
'password' => env('DB_SPU_PASSWORD', ''),
'port' => env('DB_PORT', 3306),
'charset' => 'utf8',
'collation' => 'utf8_general_ci',
'prefix' => env('DB_SPU_PREFIX', 'lie_'),
'options' => [
// 开启持久连接
\PDO::ATTR_PERSISTENT => true,
],
],
'sku_4' => [
'driver' => 'mysql',
'database' => env('SKU_4_DB_DATABASE', ''),
'host' => env('DB_SPU_HOST', ''),
'username' => env('DB_SPU_USERNAME', ''),
'password' => env('DB_SPU_PASSWORD', ''),
'port' => env('DB_PORT', 3306),
'charset' => 'utf8',
'collation' => 'utf8_general_ci',
'prefix' => env('DB_SPU_PREFIX', 'lie_'),
'options' => [
// 开启持久连接
\PDO::ATTR_PERSISTENT => true,
],
],
'sku_5' => [
'driver' => 'mysql',
'database' => env('SKU_5_DB_DATABASE', ''),
'host' => env('DB_SPU_HOST', ''),
'username' => env('DB_SPU_USERNAME', ''),
'password' => env('DB_SPU_PASSWORD', ''),
'port' => env('DB_PORT', 3306),
'charset' => 'utf8',
'collation' => 'utf8_general_ci',
'prefix' => env('DB_SPU_PREFIX', 'lie_'),
'options' => [
// 开启持久连接
\PDO::ATTR_PERSISTENT => true,
],
],
'sku_6' => [
'driver' => 'mysql',
'database' => env('SKU_6_DB_DATABASE', ''),
'host' => env('DB_SPU_HOST', ''),
'username' => env('DB_SPU_USERNAME', ''),
'password' => env('DB_SPU_PASSWORD', ''),
'port' => env('DB_PORT', 3306),
'charset' => 'utf8',
'collation' => 'utf8_general_ci',
'prefix' => env('DB_SPU_PREFIX', 'lie_'),
'options' => [
// 开启持久连接
\PDO::ATTR_PERSISTENT => true,
],
],
'sku_7' => [
'driver' => 'mysql',
'database' => env('SKU_7_DB_DATABASE', ''),
'host' => env('DB_SPU_HOST', ''),
'username' => env('DB_SPU_USERNAME', ''),
'password' => env('DB_SPU_PASSWORD', ''),
'port' => env('DB_PORT', 3306),
'charset' => 'utf8',
'collation' => 'utf8_general_ci',
'prefix' => env('DB_SPU_PREFIX', 'lie_'),
'options' => [
// 开启持久连接
\PDO::ATTR_PERSISTENT => true,
],
],
'sku_8' => [
'driver' => 'mysql',
'database' => env('SKU_8_DB_DATABASE', ''),
'host' => env('DB_SPU_HOST', ''),
'username' => env('DB_SPU_USERNAME', ''),
'password' => env('DB_SPU_PASSWORD', ''),
'port' => env('DB_PORT', 3306),
'charset' => 'utf8',
'collation' => 'utf8_general_ci',
'prefix' => env('DB_SPU_PREFIX', 'lie_'),
'options' => [
// 开启持久连接
\PDO::ATTR_PERSISTENT => true,
],
],
'sku_9' => [
'driver' => 'mysql',
'database' => env('SKU_9_DB_DATABASE', ''),
'host' => env('DB_SPU_HOST', ''),
'username' => env('DB_SPU_USERNAME', ''),
'password' => env('DB_SPU_PASSWORD', ''),
'port' => env('DB_PORT', 3306),
'charset' => 'utf8',
'collation' => 'utf8_general_ci',
'prefix' => env('DB_SPU_PREFIX', 'lie_'),
'options' => [
// 开启持久连接
\PDO::ATTR_PERSISTENT => true,
],
],
'pgsql' => [ 'pgsql' => [
'driver' => 'pgsql', 'driver' => 'pgsql',
'host' => env('DB_HOST', 'localhost'), 'host' => env('DB_HOST', 'localhost'),
...@@ -343,6 +167,8 @@ return [ ...@@ -343,6 +167,8 @@ return [
*/ */
'redis' => [ 'redis' => [
'cluster' => env('REDIS_CLUSTER', false),
'options' => [ 'options' => [
'cluster' => env('REDIS_CLUSTER', false), 'cluster' => env('REDIS_CLUSTER', false),
'prefix' => env('REDIS_PREFIX'), 'prefix' => env('REDIS_PREFIX'),
......
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