Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
goods
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bp
goods
Commits
1d702964
Commit
1d702964
authored
Jul 04, 2021
by
luhongguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update:es 调整
parent
f1ca2c0e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
32 deletions
+39
-32
GoodsToEs.php
application/modules/Cli/controllers/GoodsToEs.php
+29
-25
GoodsService.php
application/services/goods/GoodsService.php
+10
-7
No files found.
application/modules/Cli/controllers/GoodsToEs.php
View file @
1d702964
...
...
@@ -62,7 +62,7 @@ class GoodsToEsController extends Cli
$goodsSkuInfo
=
$goodsSkuInfoList
[
0
];
$nameList
=
Category
::
select
(
"name"
,
[
"category_id"
=>
[
$goodsSkuInfo
[
"category_1_id"
],
$goodsSkuInfo
[
"category_2_id"
]]]);
//生活号信息
$url
=
config
(
'interface'
,
'
goods.public
.get_life_account_by_id'
);
$url
=
config
(
'interface'
,
'
merchant.lifeaccount
.get_life_account_by_id'
);
if
(
empty
(
$url
))
{
throw
new
InterfaceException
([
'cus'
=>
0
]);
}
...
...
@@ -72,30 +72,34 @@ class GoodsToEsController extends Cli
$latitude
=
empty
(
$subShopList
[
0
][
"latitude"
])
?
""
:
$subShopList
[
0
][
"latitude"
];
$longitude
=
empty
(
$subShopList
[
0
][
"longitude"
])
?
""
:
$subShopList
[
0
][
"longitude"
];
if
(
!
empty
(
$longitude
)
||
!
empty
(
$latitude
))
{
$data
=
[
"goods_sku_id"
=>
$goodsSkuInfo
[
"goods_sku_id"
],
"goods_desc_pic_url"
=>
$goodsSkuInfo
[
"desc_pic_url"
],
"goods_name"
=>
$goodsSkuInfo
[
"goods_name"
],
"inventory_rest"
=>
$goodsSkuInfo
[
"inventory_rest"
],
"total_amount_sold"
=>
$goodsSkuInfo
[
"total_amount_sold"
],
"original_price"
=>
$goodsSkuInfo
[
"original_price"
]
/
100
,
"price"
=>
$goodsSkuInfo
[
"price"
]
/
100
,
"price_sort"
=>
(
int
)
$goodsSkuInfo
[
"price"
],
"audit_status"
=>
$goodsSkuInfo
[
"audit_status"
],
"online_status"
=>
$goodsSkuInfo
[
"online_status"
],
"desc"
=>
$goodsSkuInfo
[
"desc"
],
"category_1_id"
=>
$goodsSkuInfo
[
"category_1_id"
],
"category_2_id"
=>
$goodsSkuInfo
[
"category_2_id"
],
"category_1_name"
=>
$nameList
[
0
],
"category_2_name"
=>
$nameList
[
1
],
"life_account_name"
=>
empty
(
$lifeAccountRes
[
"response"
][
"result"
][
"life_account_name"
])
?
""
:
$lifeAccountRes
[
"response"
][
"result"
][
"life_account_name"
],
"life_account_icon"
=>
empty
(
$lifeAccountRes
[
"response"
][
"result"
][
"life_account_icon"
])
?
""
:
$lifeAccountRes
[
"response"
][
"result"
][
"life_account_icon"
],
"shop_name"
=>
empty
(
$subShopList
[
0
][
"shop_name"
])
?
""
:
$subShopList
[
0
][
"shop_name"
],
"shop_location"
=>
$latitude
.
","
.
$longitude
,
"update_time"
=>
strtotime
(
$goodsSkuInfo
[
"update_time"
]),
];
return
ElasticGoodService
::
indexDoc
(
$goodsSkuId
,
$data
);
if
(
!
empty
(
$longitude
)
&&
!
empty
(
$latitude
)
&&
!
empty
(
$subShopList
))
{
foreach
(
$subShopList
as
$subShop
)
{
$esId
=
$goodsSkuId
.
"_"
.
$subShop
[
"sub_shop_id"
];
$data
=
[
"goods_sku_id"
=>
$goodsSkuInfo
[
"goods_sku_id"
],
"goods_desc_pic_url"
=>
$goodsSkuInfo
[
"desc_pic_url"
],
"goods_name"
=>
$goodsSkuInfo
[
"goods_name"
],
"inventory_rest"
=>
$goodsSkuInfo
[
"inventory_rest"
],
"total_amount_sold"
=>
$goodsSkuInfo
[
"total_amount_sold"
],
"original_price"
=>
$goodsSkuInfo
[
"original_price"
]
/
100
,
"price"
=>
$goodsSkuInfo
[
"price"
]
/
100
,
"price_sort"
=>
(
int
)
$goodsSkuInfo
[
"price"
],
"audit_status"
=>
$goodsSkuInfo
[
"audit_status"
],
"online_status"
=>
$goodsSkuInfo
[
"online_status"
],
"desc"
=>
$goodsSkuInfo
[
"desc"
],
"category_1_id"
=>
$goodsSkuInfo
[
"category_1_id"
],
"category_2_id"
=>
$goodsSkuInfo
[
"category_2_id"
],
"category_1_name"
=>
$nameList
[
0
],
"category_2_name"
=>
$nameList
[
1
],
"life_account_name"
=>
empty
(
$lifeAccountRes
[
"response"
][
"result"
][
"life_account_name"
])
?
""
:
$lifeAccountRes
[
"response"
][
"result"
][
"life_account_name"
],
"life_account_icon"
=>
empty
(
$lifeAccountRes
[
"response"
][
"result"
][
"life_account_icon"
])
?
""
:
$lifeAccountRes
[
"response"
][
"result"
][
"life_account_icon"
],
"shop_name"
=>
$subShop
[
"shop_name"
],
"shop_location"
=>
$latitude
.
","
.
$longitude
,
"update_time"
=>
strtotime
(
$goodsSkuInfo
[
"update_time"
]),
];
return
ElasticGoodService
::
indexDoc
(
$esId
,
$data
);
}
}
}
}
...
...
application/services/goods/GoodsService.php
View file @
1d702964
...
...
@@ -212,7 +212,6 @@ class GoodsService
if
(
!
empty
(
$skuData
[
"setmeal"
]))
{
$skuParams
[
"setmeal"
]
=
$skuData
[
"setmeal"
];
}
self
::
addGoodsInfoToEs
(
$skuParams
);
GoodsSku
::
save
(
$skuParams
);
return
$skuId
;
...
...
@@ -338,7 +337,6 @@ class GoodsService
"rejected_reason"
=>
$rejectedReason
],
[
"goods_sku_id"
=>
$sku
[
"goods_sku_id"
]]);
//todo:: info to es
//商品操作记录
$res
=
self
::
getSnowIdgenId
(
"goods"
);
if
(
empty
(
$res
))
{
...
...
@@ -357,6 +355,8 @@ class GoodsService
"note"
=>
$rejectedReason
,
];
GoodsOperationRecord
::
insertRecord
(
$record
);
self
::
updateGoodsInfoToEs
(
$goodsSkuId
);
}
}
if
(
!
GoodsSku
::
commit
())
{
...
...
@@ -423,6 +423,8 @@ class GoodsService
if
(
GoodsSku
::
ONLINE_STATUS_ONLINE
==
$onlineStatus
)
{
self
::
addGoodsSnapshot
(
$sku
);
}
self
::
updateGoodsInfoToEs
(
$goodsSkuId
);
}
}
if
(
!
GoodsSku
::
commit
())
{
...
...
@@ -923,7 +925,7 @@ class GoodsService
$goodsSkuInfo
=
$goodsSkuInfoList
[
0
];
$nameList
=
Category
::
select
(
"name"
,
[
"category_id"
=>
[
$goodsSkuInfo
[
"category_1_id"
],
$goodsSkuInfo
[
"category_2_id"
]]]);
//生活号信息
$url
=
config
(
'interface'
,
'
goods.public
.get_life_account_by_id'
);
$url
=
config
(
'interface'
,
'
merchant.lifeaccount
.get_life_account_by_id'
);
if
(
empty
(
$url
))
{
throw
new
InterfaceException
([
'cus'
=>
0
]);
}
...
...
@@ -934,6 +936,7 @@ class GoodsService
if
(
!
empty
(
$subShopList
))
{
foreach
(
$subShopList
as
$subShop
)
{
if
(
!
empty
(
$subShop
[
"latitude"
])
&&
!
empty
(
$subShop
[
"longitude"
]))
{
$esId
=
$goodsSkuInfo
[
"goods_sku_id"
]
.
"_"
.
$subShop
[
"sub_shop_id"
];
$data
=
[
"doc"
=>
[
"goods_sku_id"
=>
$goodsSkuInfo
[
"goods_sku_id"
],
...
...
@@ -953,17 +956,17 @@ class GoodsService
"category_2_name"
=>
$nameList
[
1
],
"life_account_name"
=>
empty
(
$lifeAccountRes
[
"response"
][
"result"
][
"life_account_name"
])
?
""
:
$lifeAccountRes
[
"response"
][
"result"
][
"life_account_name"
],
"life_account_icon"
=>
empty
(
$lifeAccountRes
[
"response"
][
"result"
][
"life_account_icon"
])
?
""
:
$lifeAccountRes
[
"response"
][
"result"
][
"life_account_icon"
],
"shop_name"
=>
empty
(
$subShopList
[
0
][
"shop_name"
])
?
""
:
$subShopList
[
0
]
[
"shop_name"
],
"shop_name"
=>
$subShop
[
"shop_name"
],
"shop_location"
=>
$subShop
[
"latitude"
]
.
","
.
$subShop
[
"longitude"
],
"update_time"
=>
strtotime
(
$goodsSkuInfo
[
"update_time"
]),
],
];
$isHaveId
=
ElasticGoodService
::
isHaveById
(
$goodsSkuId
);
if
(
$isHaveId
)
{
ElasticGoodService
::
updateDoc
(
$
goodsSku
Id
,
$data
);
ElasticGoodService
::
updateDoc
(
$
es
Id
,
$data
);
}
else
{
$data
=
$data
[
"doc"
];
ElasticGoodService
::
indexDoc
(
$
goodsSku
Id
,
$data
);
ElasticGoodService
::
indexDoc
(
$
es
Id
,
$data
);
}
}
}
...
...
@@ -980,7 +983,7 @@ class GoodsService
{
$nameList
=
Category
::
select
(
"name"
,
[
"category_id"
=>
[
$skuParams
[
"category_1_id"
],
$skuParams
[
"category_2_id"
]]]);
//生活号信息
$url
=
config
(
'interface'
,
'
goods.public
.get_life_account_by_id'
);
$url
=
config
(
'interface'
,
'
merchant.lifeaccount
.get_life_account_by_id'
);
if
(
empty
(
$url
))
{
throw
new
InterfaceException
([
'cus'
=>
0
]);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment