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
1adadaea
Commit
1adadaea
authored
Jun 22, 2021
by
luhongguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update:支持订单需要的接口
parent
12bb3643
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
152 additions
and
10 deletions
+152
-10
GoodsException.php
application/exception/custom/GoodsException.php
+1
-0
OrderGoodsValidate.php
application/library/Validate/OrderGoodsValidate.php
+23
-0
GoodsSnapshot.php
application/models/goods/mysql/GoodsSnapshot.php
+0
-8
Goods.php
application/modules/Goods/controllers/Goods.php
+41
-0
GoodsService.php
application/services/goods/GoodsService.php
+87
-2
No files found.
application/exception/custom/GoodsException.php
View file @
1adadaea
...
@@ -34,5 +34,6 @@ class GoodsException extends BaseException
...
@@ -34,5 +34,6 @@ class GoodsException extends BaseException
20
=>
'商品说明存在敏感词,请修改后提交'
,
20
=>
'商品说明存在敏感词,请修改后提交'
,
21
=>
'商品介绍存在敏感词,请修改后提交'
,
21
=>
'商品介绍存在敏感词,请修改后提交'
,
22
=>
'规则说明存在敏感词,请修改后提交'
,
22
=>
'规则说明存在敏感词,请修改后提交'
,
23
=>
'商品快照数据不存在'
,
];
];
}
}
\ No newline at end of file
application/library/Validate/OrderGoodsValidate.php
0 → 100644
View file @
1adadaea
<?php
namespace
Validate
;
/**
* Class OrderGoodsValidate
*
* @package Validate
*/
class
OrderGoodsValidate
extends
BaseValidate
{
protected
$rule
=
[
'id'
=>
'require'
,
'version'
=>
'require'
,
];
protected
$message
=
[
"id"
=>
"商品id不能为空"
,
"version"
=>
"商品版本号不能为空"
,
];
}
\ No newline at end of file
application/models/goods/mysql/GoodsSnapshot.php
View file @
1adadaea
...
@@ -22,14 +22,6 @@ class GoodsSnapshot extends MysqlBase
...
@@ -22,14 +22,6 @@ class GoodsSnapshot extends MysqlBase
return
self
::
get
(
$colums
,
$where
);
return
self
::
get
(
$colums
,
$where
);
}
}
public
static
function
getRecordMaster
(
$where
,
$colums
=
[])
{
if
(
empty
(
$colums
))
{
$colums
=
'*'
;
}
return
self
::
selectMaster
(
$colums
,
$where
);
}
public
static
function
insertRecord
(
$colums
)
public
static
function
insertRecord
(
$colums
)
{
{
return
self
::
insert
(
$colums
);
return
self
::
insert
(
$colums
);
...
...
application/modules/Goods/controllers/Goods.php
View file @
1adadaea
...
@@ -10,6 +10,7 @@ use \Validate\GoodsEditValidate;
...
@@ -10,6 +10,7 @@ use \Validate\GoodsEditValidate;
use
\Validate\GoodsInfoOpValidate
;
use
\Validate\GoodsInfoOpValidate
;
use
\Validate\GoodsInfoFeValidate
;
use
\Validate\GoodsInfoFeValidate
;
use
\Validate\GoodsListCValidate
;
use
\Validate\GoodsListCValidate
;
use
\Validate\OrderGoodsValidate
;
use
\Validate\GoodsOnlineOfflineValidate
;
use
\Validate\GoodsOnlineOfflineValidate
;
use
\App\Services\goods\ElasticGoodService
;
use
\App\Services\goods\ElasticGoodService
;
...
@@ -155,4 +156,44 @@ class GoodsController extends Base
...
@@ -155,4 +156,44 @@ class GoodsController extends Base
$data
=
GoodsService
::
getCGoodsSkuList
(
$params
[
"life_account_id"
]);
$data
=
GoodsService
::
getCGoodsSkuList
(
$params
[
"life_account_id"
]);
$this
->
success
([
"result"
=>
$data
]);
$this
->
success
([
"result"
=>
$data
]);
}
}
/**
* 商品实时信息
*/
public
function
goods_real_time_infoAction
()
{
(
new
OrderGoodsValidate
())
->
validate
();
$params
=
$this
->
params
;
$params
[
"goods_sku_id"
]
=
$params
[
"id"
];
$data
=
GoodsService
::
getGoodsRealTimeInfo
(
$params
);
$this
->
success
([
"result"
=>
$data
]);
}
/**
* 商品快照
* @throws \App\Exception\custom\ParamException
*/
public
function
goods_snapshot_infoAction
()
{
(
new
OrderGoodsValidate
())
->
validate
();
$params
=
$this
->
params
;
$params
[
"goods_sku_id"
]
=
$params
[
"id"
];
$data
=
GoodsService
::
getGoodsSnapshotInfo
(
$params
);
$this
->
success
([
"result"
=>
$data
]);
}
/**
* 商品营销活动
*/
public
function
goods_marketingAction
()
{
(
new
OrderGoodsValidate
())
->
validate
();
$params
=
$this
->
params
;
$params
[
"goods_sku_id"
]
=
$params
[
"id"
];
$data
=
GoodsService
::
checkGoodsMarketing
(
$params
);
$this
->
success
([
"result"
=>
$data
]);
}
}
}
\ No newline at end of file
application/services/goods/GoodsService.php
View file @
1adadaea
...
@@ -583,13 +583,13 @@ class GoodsService
...
@@ -583,13 +583,13 @@ class GoodsService
$data
[
"goods_info"
][
"url_list"
]
=
[];
$data
[
"goods_info"
][
"url_list"
]
=
[];
if
(
!
empty
(
$sku
[
"url"
]))
{
if
(
!
empty
(
$sku
[
"url"
]))
{
$image
=
explode
(
","
,
$sku
[
"url"
]);
$image
=
explode
(
","
,
$sku
[
"url"
]);
$ksyun
=
Ksyun
::
getDownUrl
(
$image
,
'merchant-b'
,
'bp-yidian'
,
60
);
$ksyun
=
Ksyun
::
getDownUrl
(
$image
,
'merchant-b'
,
'bp-yidian'
,
60
);
$data
[
"goods_info"
][
"url_list"
]
=
array_values
(
$ksyun
);
$data
[
"goods_info"
][
"url_list"
]
=
array_values
(
$ksyun
);
}
}
$data
[
"goods_info"
][
"introduce_pic_url_list"
]
=
[];
$data
[
"goods_info"
][
"introduce_pic_url_list"
]
=
[];
if
(
!
empty
(
$sku
[
"introduce_pic_url"
]))
{
if
(
!
empty
(
$sku
[
"introduce_pic_url"
]))
{
$image
=
explode
(
","
,
$sku
[
"introduce_pic_url"
]);
$image
=
explode
(
","
,
$sku
[
"introduce_pic_url"
]);
$ksyun
=
Ksyun
::
getDownUrl
(
$image
,
'merchant-b'
,
'bp-yidian'
,
60
);
$ksyun
=
Ksyun
::
getDownUrl
(
$image
,
'merchant-b'
,
'bp-yidian'
,
60
);
$data
[
"goods_info"
][
"introduce_pic_url_list"
]
=
array_values
(
$ksyun
);
$data
[
"goods_info"
][
"introduce_pic_url_list"
]
=
array_values
(
$ksyun
);
}
}
...
@@ -826,4 +826,89 @@ class GoodsService
...
@@ -826,4 +826,89 @@ class GoodsService
}
}
return
true
;
return
true
;
}
}
/**
* 通过sku_id 和 version 获取实时商品信息
* @param $params
* @return array
* @throws GoodsException
*/
public
static
function
getGoodsRealTimeInfo
(
$params
)
{
$data
=
[];
$goodsSkuId
=
BaseConvert
::
otherToDec
(
$params
[
"goods_sku_id"
]);
$goodsSku
=
GoodsSku
::
get
(
"*"
,
[
"goods_sku_id"
=>
$goodsSkuId
,
"version"
=>
$params
[
"version"
]]);
if
(
empty
(
$goodsSku
))
{
throw
new
GoodsException
([
"cus"
=>
15
]);
}
$data
[
"online_status"
]
=
$goodsSku
[
"online_status"
];
$data
[
"rule_limit"
]
=
$goodsSku
[
"rule_limit"
];
$data
[
"rule_refund"
]
=
$goodsSku
[
"rule_refund"
];
return
$data
;
}
/**
* 商品快照数据
* @param $params
* @return array
* @throws GoodsException
*/
public
static
function
getGoodsSnapshotInfo
(
$params
)
{
$data
=
[];
$goodsSkuId
=
BaseConvert
::
otherToDec
(
$params
[
"goods_sku_id"
]);
$goodsSnapshot
=
GoodsSnapshot
::
getRecord
([
"goods_sku_id"
=>
$goodsSkuId
,
"version"
=>
$params
[
"version"
]]);
if
(
empty
(
$goodsSnapshot
))
{
throw
new
GoodsException
([
"cus"
=>
23
]);
}
$data
[
"name"
]
=
$goodsSnapshot
[
"name"
];
$nameList
=
Category
::
select
(
"name"
,
[
"category_id"
=>
[
$goodsSnapshot
[
"category_1_id"
],
$goodsSnapshot
[
"category_2_id"
]]]);
$data
[
"category_1_name"
]
=
$nameList
[
0
];
$data
[
"category_2_name"
]
=
$nameList
[
1
];
$data
[
"url_list"
]
=
[];
if
(
!
empty
(
$goodsSnapshot
[
"url"
]))
{
$image
=
explode
(
","
,
$goodsSnapshot
[
"url"
]);
$ksyun
=
Ksyun
::
getDownUrl
(
$image
,
'merchant-b'
,
'bp-yidian'
,
60
);
$data
[
"url_list"
]
=
array_values
(
$ksyun
);
}
$data
[
"introduce_pic_url_list"
]
=
[];
if
(
!
empty
(
$goodsSnapshot
[
"introduce_pic_url"
]))
{
$image
=
explode
(
","
,
$goodsSnapshot
[
"introduce_pic_url"
]);
$ksyun
=
Ksyun
::
getDownUrl
(
$image
,
'merchant-b'
,
'bp-yidian'
,
60
);
$data
[
"introduce_pic_url_list"
]
=
array_values
(
$ksyun
);
}
$data
[
"desc"
]
=
$goodsSnapshot
[
"desc"
];
$data
[
"introduce"
]
=
$goodsSnapshot
[
"introduce"
];
$data
[
"expiration_time"
]
=
$goodsSnapshot
[
"expiration_time"
];
$data
[
"rule_limit"
]
=
$goodsSnapshot
[
"rule_limit"
];
$data
[
"rule_desc"
]
=
$goodsSnapshot
[
"rule_desc"
];
$data
[
"rule_refund"
]
=
$goodsSnapshot
[
"rule_refund"
];
$data
[
"original_price"
]
=
$goodsSnapshot
[
"original_price"
]
/
100
;
$data
[
"price"
]
=
$goodsSnapshot
[
"price"
]
/
100
;
$data
[
"sub_shop"
]
=
json_decode
(
$goodsSnapshot
[
"sub_shop"
],
true
);
$data
[
"setmeal"
]
=
empty
(
$goodsSnapshot
[
"setmeal"
])
?
[]
:
json_decode
(
$goodsSnapshot
[
"sub_shop"
],
true
);
return
$data
;
}
/**
* 检查商品是否有营销活动
* @param $params
* @return array
* @throws GoodsException
*/
public
static
function
checkGoodsMarketing
(
$params
)
{
$data
=
[];
$goodsSkuId
=
BaseConvert
::
otherToDec
(
$params
[
"goods_sku_id"
]);
$goodsSku
=
GoodsSku
::
get
(
"*"
,
[
"goods_sku_id"
=>
$goodsSkuId
,
"version"
=>
$params
[
"version"
]]);
if
(
empty
(
$goodsSku
))
{
throw
new
GoodsException
([
"cus"
=>
15
]);
}
//todo
return
$data
;
}
}
}
\ No newline at end of file
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