Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
LC_api_news
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
eeb76392
authored
Dec 06, 2019
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
优化接口
parent
d8e4e4b1
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
22 additions
and
107 deletions
app/Http/Controllers/CaseController.php
app/Http/Controllers/CodesController.php
app/Http/Controllers/FaqController.php
app/Http/Controllers/NoticeController.php
app/Model/ArticleModel.php
app/Services/CaseService.php
app/Services/FaqService.php
app/Http/Controllers/CaseController.php
View file @
eeb76392
...
...
@@ -20,7 +20,7 @@ class CaseController extends Controller
public
function
show
(
Request
$request
,
CaseService
$service
)
{
$id
=
$request
->
get
(
'id'
);
$id
=
$request
->
get
(
'
art_
id'
);
$case
=
$service
->
getCase
(
$id
);
return
$this
->
Export
(
0
,
'ok'
,
[
'data'
=>
$case
]);
...
...
app/Http/Controllers/CodesController.php
deleted
100644 → 0
View file @
d8e4e4b1
<?php
namespace
App\Http\Controllers
;
use
App\Services\CodeService
;
use
Common\Model\RedisModel
;
use
Illuminate\Http\Request
;
/**
* 红包码
* Class CodesController
* @package App\Http\Controllers
*/
class
CodesController
extends
Controller
{
const
INTEGRAL_TYPE_CODE
=
3
;
/**
* 兑换红包码
* @param Request $request
* @param CodeService $service
* @return array
*/
public
function
store
(
Request
$request
,
CodeService
$service
)
{
$userId
=
$request
->
user
->
user_id
;
$code
=
$request
->
get
(
'code'
);
if
(
empty
(
$code
))
{
return
$this
->
Export
(
self
::
INVALID_PARAMETER
);
}
elseif
(
!
$this
->
checkCode
(
$code
,
$userId
))
{
return
$this
->
Export
(
self
::
INVALID_CODE
);
}
$data
=
[
'user_id'
=>
$userId
,
'code'
=>
$request
->
get
(
'code'
),
];
$result
=
$service
->
addCode
(
$data
);
if
(
$result
[
'errcode'
]
===
self
::
SUCCESS
)
{
//成功之后还要返回红包码
$res
[
'data'
][
'code'
]
=
$code
;
//返回红包码能获取对应的金额
$redis
=
new
RedisModel
();
$integral
=
$redis
->
hget
(
'ic_welfare_integrals'
,
self
::
INTEGRAL_TYPE_CODE
);
$integral
=
json_decode
(
$integral
,
true
);
$amount
=
array_get
(
$integral
,
'amount'
);
$res
[
'data'
][
'amount'
]
=
$amount
;
return
$this
->
Export
(
0
,
'ok'
,
$res
);
}
elseif
(
$result
[
'errcode'
]
===
self
::
EXCHANGED_CODE
)
{
return
$this
->
Export
(
self
::
EXCHANGED_CODE
);
}
else
{
return
$this
->
Export
(
self
::
EXCHANGE_CODE_FAIL
);
}
}
//检查红包码是否正确
private
function
checkCode
(
$code
,
$userId
=
0
)
{
//检查是不是自己,自己不能兑换自己的红包码
if
(
$userId
==
substr
(
$code
,
3
))
{
return
false
;
}
//先检查是否是RDD开头
if
(
substr
(
$code
,
0
,
3
)
!==
'RDD'
)
{
return
false
;
}
//然后去redis里面取出user_id,判断是否有对应的用户
$userId
=
substr
(
$code
,
3
);
$redis
=
new
RedisModel
();
$exists
=
$redis
->
hexists
(
'ic_user'
,
$userId
);
if
(
!
$exists
)
{
return
false
;
}
return
true
;
}
}
\ No newline at end of file
app/Http/Controllers/FaqController.php
View file @
eeb76392
...
...
@@ -21,7 +21,7 @@ class FaqController extends Controller
public
function
show
(
Request
$request
,
FaqService
$service
)
{
$faq
=
$service
->
getFaq
(
$request
->
get
(
'id'
));
$faq
=
$service
->
getFaq
(
$request
->
get
(
'
art_
id'
));
return
$faq
;
}
...
...
app/Http/Controllers/NoticeController.php
View file @
eeb76392
...
...
@@ -22,7 +22,7 @@ class NoticeController extends Controller
public
function
show
(
Request
$request
,
NoticeService
$service
)
{
$faq
=
$service
->
getNotice
(
$request
->
get
(
'id'
));
$faq
=
$service
->
getNotice
(
$request
->
get
(
'
art_
id'
));
return
$faq
;
}
...
...
app/Model/ArticleModel.php
View file @
eeb76392
...
...
@@ -34,7 +34,6 @@ class ArticleModel extends BaseModel
//获取案例列表
public
function
getCaseList
(
$map
,
$page
,
$pageSize
)
{
$field
=
[
'art_id'
,
'title'
,
...
...
@@ -53,10 +52,10 @@ class ArticleModel extends BaseModel
'article_tag'
=>
function
(
$query
)
{
$query
->
select
([
'id'
,
'art_id'
,
'tag'
,
'url'
]);
},
'type'
=>
function
(
$query
)
{
'type'
=>
function
(
$query
)
{
$query
->
select
([
'type_id'
,
'type_name'
]);
},
'top_type'
=>
function
(
$query
)
{
'top_type'
=>
function
(
$query
)
{
$query
->
select
([
'type_id'
,
'type_name'
]);
},
])
...
...
@@ -88,17 +87,19 @@ class ArticleModel extends BaseModel
'article_tag'
=>
function
(
$query
)
{
$query
->
select
([
'id'
,
'art_id'
,
'tag'
,
'url'
]);
},
'type'
=>
function
(
$query
)
{
'type'
=>
function
(
$query
)
{
$query
->
select
([
'type_id'
,
'type_name'
]);
},
'top_type'
=>
function
(
$query
)
{
'top_type'
=>
function
(
$query
)
{
$query
->
select
([
'type_id'
,
'type_name'
]);
},
'article_addon'
,
])
->
where
(
'art_id'
,
$id
)
->
first
()
->
toArray
();
->
first
();
if
(
!
empty
(
$data
))
{
$data
=
$data
->
toArray
();
}
return
$data
;
}
...
...
app/Services/CaseService.php
View file @
eeb76392
...
...
@@ -47,14 +47,17 @@ class CaseService extends BaseService
private
function
caseTransform
(
$item
)
{
$item
[
'type'
]
=
array_get
(
$item
[
'type'
],
'type_name'
,
''
);
$item
[
'top_type'
]
=
array_get
(
$item
[
'top_type'
],
'type_name'
,
''
);
$item
[
'publish_time'
]
=
$item
[
'publish_time'
]
?
date
(
'Y-m-d H:i:s'
,
$item
[
'publish_time'
])
:
0
;
$item
[
'brand'
]
=
$item
[
'writer'
];
unset
(
$item
[
'writer'
]);
$item
[
'tags'
]
=
array_column
(
$item
[
'article_tag'
],
'tag'
);
unset
(
$item
[
'article_tag'
]);
#todo 要从商品的服务那里根据goods_id去获取商品基础信息
if
(
!
empty
(
$item
))
{
$item
[
'type'
]
=
array_get
(
$item
[
'type'
],
'type_name'
,
''
);
$item
[
'top_type'
]
=
array_get
(
$item
[
'top_type'
],
'type_name'
,
''
);
$item
[
'publish_time'
]
=
$item
[
'publish_time'
]
?
date
(
'Y-m-d H:i:s'
,
$item
[
'publish_time'
])
:
0
;
$item
[
'brand'
]
=
$item
[
'writer'
];
unset
(
$item
[
'writer'
]);
$item
[
'tags'
]
=
array_column
(
$item
[
'article_tag'
],
'tag'
);
unset
(
$item
[
'article_tag'
]);
#todo 要从商品的服务那里根据goods_id去获取商品基础信息
}
return
$item
;
}
...
...
app/Services/FaqService.php
View file @
eeb76392
...
...
@@ -25,13 +25,6 @@ class FaqService extends BaseService
private
function
transform
(
$data
)
{
foreach
(
$data
as
$key
=>
&
$item
)
{
foreach
(
$item
[
'articles'
]
as
$k
=>
$v
)
{
$v
[
'url'
]
=
url
()
.
'/faq/info?id='
.
$v
[
'art_id'
];
}
}
unset
(
$item
);
return
$data
;
}
...
...
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