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
88f6d9a7
Commit
88f6d9a7
authored
Jun 25, 2021
by
luhongguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update:同步es数据结构调整
parent
adbe898a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
70 additions
and
29 deletions
+70
-29
Code.php
application/exception/custom/Code.php
+5
-4
InterfaceException.php
application/exception/custom/InterfaceException.php
+17
-0
GoodsService.php
application/services/goods/GoodsService.php
+48
-25
No files found.
application/exception/custom/Code.php
View file @
88f6d9a7
...
...
@@ -11,10 +11,11 @@ namespace App\Exception\custom;
*/
class
Code
{
const
PARAM
=
101000
;
const
SIGN
=
102000
;
const
GOODS
=
110000
;
const
SHOP
=
120000
;
const
PARAM
=
101000
;
const
SIGN
=
102000
;
const
INTERFACE
=
103000
;
const
GOODS
=
110000
;
const
SHOP
=
120000
;
const
DISTRIBUTOR
=
130000
;
const
DISTRIBUTION
=
140000
;
const
MARKETING
=
150000
;
...
...
application/exception/custom/InterfaceException.php
0 → 100644
View file @
88f6d9a7
<?php
namespace
App\Exception\custom
;
use
App\Exception\BaseException
;
class
InterfaceException
extends
BaseException
{
protected
$base_code
=
Code
::
INTERFACE
;
protected
$cus
=
[
0
=>
'接口异常'
,
1
=>
'请求地址异常'
,
];
}
application/services/goods/GoodsService.php
View file @
88f6d9a7
...
...
@@ -19,6 +19,8 @@ use App\Models\goods\mysql\GoodsSpu;
use
App\Models\goods\mysql\Shop
;
use
App\Models\shop\mysql\SubShop
;
use
App\Services\shop\ShopService
;
use
Api\PhpUtils\Http\Request
;
use
App\Exception\custom\InterfaceException
;
class
GoodsService
{
...
...
@@ -478,6 +480,11 @@ class GoodsService
GoodsSpu
::
rollback
();
throw
new
GoodsException
([
"cus"
=>
0
]);
}
foreach
(
$goodsSkuList
as
$sku
)
{
self
::
updateGoodsInfoToEs
(
$sku
[
"goods_sku_id"
]);
}
return
true
;
}
...
...
@@ -569,8 +576,6 @@ class GoodsService
if
(
!
empty
(
$params
[
"setmeal"
]))
{
$skuParams
[
"setmeal"
]
=
$params
[
"setmeal"
];
}
//同步到es
self
::
updateGoodsInfoToEs
(
$skuData
,
$skuParams
);
//商品操作记录
$res
=
self
::
getSnowIdgenId
(
"goods"
);
...
...
@@ -843,31 +848,49 @@ class GoodsService
/**
* 更新到es
* @param $skuData
* @param $skuParams
* @param $goodsSkuId
* @return array|callable
* @throws InterfaceException
*/
private
static
function
updateGoodsInfoToEs
(
$
skuData
,
$skuParams
)
private
static
function
updateGoodsInfoToEs
(
$
goodsSkuId
)
{
$nameList
=
Category
::
select
(
"name"
,
[
"category_id"
=>
[
$skuParams
[
"category_1_id"
],
$skuParams
[
"category_2_id"
]]]);
$data
=
[
"doc"
=>
[
"id"
=>
$skuData
[
"goods_sku_id"
],
"goods_desc_pic_url"
=>
$skuParams
[
"desc_pic_url"
],
"goods_name"
=>
$skuParams
[
"goods_name"
],
"inventory_rest"
=>
$skuParams
[
"inventory_rest"
],
"total_amount_sold"
=>
$skuData
[
"total_amount_sold"
],
"original_price"
=>
$skuParams
[
"original_price"
]
/
100
,
"price"
=>
$skuParams
[
"price"
]
/
100
,
"price_sort"
=>
(
int
)
$skuParams
[
"price"
],
"audit_status"
=>
$skuData
[
"audit_status"
],
"online_status"
=>
$skuData
[
"online_status"
],
"desc"
=>
$skuData
[
"desc"
],
"category_1_name"
=>
$nameList
[
0
],
"category_2_name"
=>
$nameList
[
1
],
],
];
return
ElasticGoodService
::
updateDoc
(
$skuData
[
"goods_sku_id"
],
$data
);
$goodsSkuInfoList
=
GoodsSku
::
getRecordMaster
([
"goods_sku_id"
=>
$goodsSkuId
]);
if
(
!
empty
(
$goodsSkuInfoList
))
{
$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'
);
if
(
empty
(
$url
))
{
throw
new
InterfaceException
([
'cus'
=>
0
]);
}
$lifeAccountRes
=
(
new
Request
())
->
get
(
$url
,
[
"life_account_id"
=>
$goodsSkuInfo
[
"life_account_id"
]]);
//门店信息
$subShopList
=
ShopService
::
getRelationShop
(
$goodsSkuId
);
$data
=
[
"doc"
=>
[
"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_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_longitude"
=>
empty
(
$subShopList
[
0
][
"longitude"
])
?
""
:
$subShopList
[
0
][
"longitude"
],
"shop_latitude"
=>
empty
(
$subShopList
[
0
][
"latitude"
])
?
""
:
$subShopList
[
0
][
"latitude"
],
],
];
return
ElasticGoodService
::
updateDoc
(
$goodsSkuId
,
$data
);
}
}
/**
...
...
@@ -1008,7 +1031,7 @@ class GoodsService
return
$data
;
}
/**
* 获取 GoodsSku 列表
* @param $params
...
...
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