Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
my-yaf-project
Project
Project
Details
Activity
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
chenchuanwen
my-yaf-project
Commits
0345556b
Commit
0345556b
authored
Sep 26, 2018
by
liuyuzhen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
城市列表修改
parent
349a96c3
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
122 additions
and
8 deletions
+122
-8
Pinyin.php
application/library/Our/Pinyin.php
+67
-0
AddressService.php
application/models/Business/User/AddressService.php
+16
-0
Area.php
application/models/DAO/Area.php
+25
-8
cityPinyin.php
scripts/crontab/store/cityPinyin.php
+14
-0
No files found.
application/library/Our/Pinyin.php
0 → 100644
View file @
0345556b
This source diff could not be displayed because it is too large. You can
view the blob
instead.
application/models/Business/User/AddressService.php
View file @
0345556b
...
...
@@ -413,6 +413,22 @@ class AddressServiceModel extends \Business\AbstractModel {
return
$result
;
}
public
function
createPinyin
(){
$areaDao
=
\DAO\AreaModel
::
getInstance
();
$pageSize
=
1000
;
$pageIndex
=
0
;
for
(
$i
=
$pageIndex
;
$i
<
4
;
$i
++
){
$pageIndex
=
$i
*
$pageSize
;
$limit
=
array
(
$pageIndex
,
$pageSize
);
$areaList
=
$areaDao
->
getList
(
$limit
);
foreach
(
$areaList
as
$area
){
$updateData
=
array
();
$updateData
[
'pinyin'
]
=
ucfirst
(
\Our\Pinyin
::
pinyin
(
$area
[
'area_name'
]));
$areaDao
->
update
(
array
(
'area_id'
=>
$area
[
'area_id'
]),
$updateData
);
}
}
}
/**
* 获取城市列表
* @return bool
...
...
application/models/DAO/Area.php
View file @
0345556b
...
...
@@ -50,6 +50,22 @@ class AreaModel extends \DAO\AbstractModel {
return
$result
;
}
public
function
update
(
$where
,
$data
){
$this
->
setDb
(
\Our\DbNameConst
::
masterDBConnectName
);
return
$this
->
db
->
update
(
$this
->
_tableName
)
->
where
(
$where
)
->
rows
(
$data
)
->
execute
();
}
public
function
getList
(
$limit
){
$this
->
setDb
(
$this
->
dbName
);
$this
->
db
->
select
(
\Our\NameConst
::
allField
)
->
from
(
$this
->
_tableName
);
if
(
$limit
){
$this
->
db
->
limit
(
$limit
[
0
],
$limit
[
1
]);
}
$areaList
=
$this
->
db
->
fetchAll
();
return
$areaList
;
}
public
function
getCityListWithoutCounty
(){
$addressRedis
=
AddressRedisModel
::
getInstance
();
$cityList
=
$addressRedis
->
find
(
'cityListWithoutCounty'
);
...
...
@@ -60,17 +76,19 @@ class AreaModel extends \DAO\AbstractModel {
$addressRedis
->
update
(
'allCityListWithoutCounty'
,
$areaList
);
$cityListInitial
=
array
();
$cityInitialList
=
array
();
$cityPinyinList
=
array
();
foreach
(
$areaList
as
$area
){
if
(
isset
(
$area
[
'initial'
])
&&
$area
[
'initial'
]
&&!
(
$cityInitialList
&&
in_array
(
$area
[
'initial'
],
$cityInitialList
))){
$cityInitialList
[]
=
$area
[
'initial'
];
}
$city
ListInitial
[
$area
[
'initial'
]][]
=
$area
[
'area_name'
]
;
$cityListInitial
[
$area
[
'initial'
]][]
=
$area
[
'area_name'
]
;
$city
PinyinList
[
$area
[
'initial'
]][]
=
array
(
'name'
=>
$area
[
'area_name'
],
'pinyin'
=>
$area
[
'pinyin'
])
;
}
$list
=
array
();
foreach
(
$cityInitialList
as
$inital
){
$initalCity
[
'initial'
]
=
$inital
;
$initalCity
[
'list'
]
=
$cityListInitial
[
$inital
];
$initalCity
[
'pinyinList'
]
=
$cityPinyinList
[
$inital
];
$list
[]
=
$initalCity
;
}
$addressRedis
->
update
(
'cityListWithoutCounty'
,
$list
);
...
...
@@ -93,11 +111,13 @@ class AreaModel extends \DAO\AbstractModel {
}
$cityListInitial
[
$area
[
'initial'
]][]
=
$area
[
'area_name'
];
$cityPinyinList
[
$area
[
'initial'
]][]
=
array
(
'name'
=>
$area
[
'area_name'
],
'pinyin'
=>
$area
[
'pinyin'
]);
}
$list
=
array
();
foreach
(
$cityInitialList
as
$inital
){
$initalCity
[
'initial'
]
=
$inital
;
$initalCity
[
'list'
]
=
$cityListInitial
[
$inital
];
$initalCity
[
'pinyinList'
]
=
$cityPinyinList
[
$inital
];
$list
[]
=
$initalCity
;
}
$addressRedis
->
update
(
'cityList'
,
$list
);
...
...
@@ -106,16 +126,13 @@ class AreaModel extends \DAO\AbstractModel {
public
function
getAllCityList
(
$withoutCounty
=
false
){
$this
->
setDb
(
$this
->
dbName
);
$sql
=
" SELECT t1.area_name, t2.f_py as initial FROM han_area t1 "
;
$sql
.=
" left join han_coslers t2 "
;
$sql
.=
" on CONV(HEX(LEFT(CONVERT(t1.area_name USING gbk ), 1)), 16, 10) BETWEEN t2.cbegin AND t2.cend
where t1.is_city=1 "
;
$sql
=
" SELECT t1.area_name,t1.pinyin, LEFT(t1.pinyin,1) as initial FROM han_area t1 "
;
$sql
.=
" where t1.is_city=1 "
;
if
(
$withoutCounty
){
$sql
.=
" and t1.area_name not like '%县'"
;
}
$sql
.=
" ORDER BY t1.area_deep,
convert(t1.area_name using gbk)
ASC "
;
$sql
.=
" ORDER BY t1.area_deep,
t1.pinyin
ASC "
;
$area_list
=
$this
->
db
->
query
(
$sql
)
->
rows
;
echo
$this
->
db
->
getLastSql
();
return
$area_list
;
}
...
...
scripts/crontab/store/cityPinyin.php
0 → 100644
View file @
0345556b
<?php
/**
* User: liuyuzhen
* Date: 2018/9/26
* Time: 10:15
* Description:
*/
define
(
"APPLICATION_PATH"
,
realpath
(
dirname
(
__FILE__
)
.
'/../../../'
));
//指向public的上一级
require
APPLICATION_PATH
.
'/scripts/crontab/baseCli.php'
;
require
APPLICATION_PATH
.
'/scripts/crontab/common.php'
;
error_reporting
(
E_ALL
^
E_NOTICE
);
\Business\User\AddressServiceModel
::
getInstance
()
->
createPinyin
();
EXIT
;
?>
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