Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
YOHOBUYWAP
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
周少峰
9 years ago
Commit
3154811682a26d3b5b3341588284e7480725227e
1 parent
3dff7339
coupon id, address id
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
92 additions
and
6 deletions
library/Plugin/DataProcess/CouponFloorProcess.php
library/Plugin/Encryption.php
yohobuy/m.yohobuy.com/application/controllers/Coupon.php
yohobuy/m.yohobuy.com/application/controllers/Home.php
yohobuy/m.yohobuy.com/application/models/Index/User.php
yohobuy/m.yohobuy.com/application/modules/Cart/controllers/Index.php
library/Plugin/DataProcess/CouponFloorProcess.php
View file @
3154811
...
...
@@ -12,6 +12,7 @@ use WebPlugin\Cache;
use
Plugin\Images
;
use
Plugin\Helpers
;
use
WebPlugin\HelperSearch
;
use
Plugin\Encryption
;
class
CouponFloorProcess
{
...
...
@@ -109,6 +110,7 @@ class CouponFloorProcess
$floorTitle
=
(
key_exists
(
'text'
,
$item
)
&&
(
$item
[
'text'
]
!==
''
))
?
$item
[
'text'
]
:
''
;
continue
;
}
$item
[
'couponID'
]
=
Encryption
::
encrypt
(
$item
[
'couponID'
]);
$imageSrc
=
Images
::
getImageUrl
(
$item
[
'image'
][
'src'
],
0
,
0
);
$item
[
'image'
][
'src'
]
=
$imageSrc
;
$item
[
'image'
][
'url'
]
=
$isApp
?
$item
[
'image'
][
'url'
]
:
Helpers
::
getFilterUrl
(
$item
[
'image'
][
'url'
]);
...
...
library/Plugin/Encryption.php
0 → 100644
View file @
3154811
<?php
/**
* 加密解密
*/
namespace
Plugin
;
class
Encryption
{
// 密钥
private
static
$key
=
'123'
;
// 加密
public
static
function
encrypt
(
$data
)
{
$char
=
''
;
$str
=
''
;
$key
=
md5
(
self
::
$key
);
$x
=
0
;
$len
=
strlen
(
$data
);
$l
=
strlen
(
$key
);
for
(
$i
=
0
;
$i
<
$len
;
$i
++
)
{
if
(
$x
==
$l
)
{
$x
=
0
;
}
$char
.=
$key
{
$x
};
$x
++
;
}
for
(
$i
=
0
;
$i
<
$len
;
$i
++
)
{
$str
.=
chr
(
ord
(
$data
{
$i
})
+
(
ord
(
$char
{
$i
}))
%
256
);
}
return
base64_encode
(
$str
);
}
//解密
public
static
function
decrypt
(
$data
)
{
$char
=
''
;
$str
=
''
;
$key
=
md5
(
self
::
$key
);
$x
=
0
;
$data
=
base64_decode
(
$data
);
$len
=
strlen
(
$data
);
$l
=
strlen
(
$key
);
for
(
$i
=
0
;
$i
<
$len
;
$i
++
)
{
if
(
$x
==
$l
)
{
$x
=
+
0
;
}
$char
.=
substr
(
$key
,
$x
,
1
);
$x
++
;
}
for
(
$i
=
0
;
$i
<
$len
;
$i
++
)
{
if
(
ord
(
substr
(
$data
,
$i
,
1
))
<
ord
(
substr
(
$char
,
$i
,
1
)))
{
$str
.=
chr
((
ord
(
substr
(
$data
,
$i
,
1
))
+
256
)
-
ord
(
substr
(
$char
,
$i
,
1
)));
}
else
{
$str
.=
chr
(
ord
(
substr
(
$data
,
$i
,
1
))
-
ord
(
substr
(
$char
,
$i
,
1
)));
}
}
return
$str
;
}
}
\ No newline at end of file
...
...
yohobuy/m.yohobuy.com/application/controllers/Coupon.php
View file @
3154811
...
...
@@ -11,6 +11,7 @@ use Coupon\CouponModel;
use
LibModels\Wap\Coupon\CouponData
;
use
Plugin\DataProcess\CouponFloorProcess
;
use
Plugin\Helpers
;
use
Plugin\Encryption
;
class
CouponController
extends
AbstractAction
...
...
@@ -67,6 +68,9 @@ class CouponController extends AbstractAction
'code'
=>
FILTER_DEFAULT
,
'app_version'
=>
FILTER_DEFAULT
));
if
(
$receiveData
[
'couponID'
])
{
$receiveData
[
'couponID'
]
=
Encryption
::
decrypt
(
$receiveData
[
'couponID'
]);
}
// 跳转 URl
$playUrl
=
Helpers
::
url
(
'/coupon/floor'
);
// 判断用户是否登录
...
...
yohobuy/m.yohobuy.com/application/controllers/Home.php
View file @
3154811
...
...
@@ -11,6 +11,7 @@ use Plugin\Pay\weixin\lib\WxPayUnifiedOrder;
use
Plugin\Pay\weixin\lib\WxPayApi
;
use
Plugin\Pay\weixin\lib\WxPayConfig
;
use
Plugin\UdpLog
;
use
Plugin\Encryption
;
/**
* 个人中心相关的控制器
...
...
@@ -472,7 +473,6 @@ class HomeController extends AbstractAction
'addressActionPage'
=>
true
,
'addressList'
=>
UserModel
::
getAddressListData
(
$uid
)
);
if
(
$id
!==
null
)
{
// 编辑地址
// 设置网站标题
$this
->
setTitle
(
'编辑地址'
);
...
...
@@ -505,6 +505,9 @@ class HomeController extends AbstractAction
$consignee
=
$this
->
post
(
'consignee'
,
''
);
$email
=
$this
->
post
(
'email'
,
''
);
$id
=
$this
->
post
(
'id'
,
null
);
if
(
$id
)
{
$id
=
Encryption
::
decrypt
(
$id
);
}
$mobile
=
$this
->
post
(
'mobile'
,
''
);
$zipCode
=
$this
->
post
(
'zip_code'
,
''
);
...
...
@@ -528,7 +531,10 @@ class HomeController extends AbstractAction
if
(
$this
->
isAjax
())
{
$uid
=
$this
->
getUid
(
true
);
$id
=
$this
->
post
(
'id'
,
''
);
$id
=
$this
->
post
(
'id'
,
''
);
// TODO
if
(
$id
)
{
$id
=
Encryption
::
decrypt
(
$id
);
}
$result
=
UserModel
::
setDefaultAddress
(
$uid
,
$id
);
}
...
...
@@ -550,6 +556,9 @@ class HomeController extends AbstractAction
if
(
$this
->
isAjax
())
{
$uid
=
$this
->
getUid
(
true
);
$id
=
$this
->
post
(
'id'
,
''
);
if
(
$id
)
{
$id
=
Encryption
::
decrypt
(
$id
);
}
$result
=
UserModel
::
deleteAddress
(
$uid
,
$id
);
}
...
...
yohobuy/m.yohobuy.com/application/models/Index/User.php
View file @
3154811
...
...
@@ -9,6 +9,7 @@ use Plugin\Cache;
use
Plugin\Helpers
;
use
Plugin\Images
;
use
Plugin\UdpLog
;
use
Plugin\Encryption
;
/**
*
...
...
@@ -594,6 +595,9 @@ class UserModel
// 处理地址数据
if
(
isset
(
$address
[
'data'
])
&&
!
empty
(
$address
[
'data'
]))
{
foreach
(
$address
[
'data'
]
as
$key
=>
$val
)
{
$address
[
'data'
][
$key
][
'address_id'
]
=
Encryption
::
encrypt
(
$val
[
'address_id'
]);
}
UdpLog
::
info
(
'地址数据校验'
,
'uid'
.
$uid
.
'返回:'
.
json_encode
(
$address
));
$result
=
$address
[
'data'
];
}
...
...
@@ -646,16 +650,14 @@ class UserModel
* 根据用户id和地址id获取地址数据
*
* @param int $uid 用户ID
* @param
int $id
地址ID
* @param
string $id 加密后的
地址ID
* @return array|mixed 地址数据
*/
public
static
function
getAddressDataById
(
$uid
,
$id
)
{
$result
=
array
();
// 调用接口获取地址数据
$address
=
self
::
getAddressData
(
$uid
);
// 处理地址数据
foreach
(
$address
as
$val
)
{
if
(
$val
[
'address_id'
]
==
$id
)
{
...
...
@@ -663,7 +665,6 @@ class UserModel
break
;
}
}
return
$result
;
}
...
...
yohobuy/m.yohobuy.com/application/modules/Cart/controllers/Index.php
View file @
3154811
...
...
@@ -8,6 +8,7 @@ use Plugin\Helpers;
use
Plugin\UnionTrans
;
use
Home\OrderModel
;
use
Plugin\UdpLog
;
use
Plugin\Encryption
;
/**
* 购物车相关的控制器
...
...
@@ -452,6 +453,7 @@ class IndexController extends AbstractAction
if
(
$this
->
isAjax
())
{
$uid
=
$this
->
getUid
(
true
);
$addressId
=
$this
->
post
(
'addressId'
,
null
);
$addressId
=
Encryption
::
decrypt
(
$addressId
);
$cartType
=
$this
->
post
(
'cartType'
,
'ordinary'
);
// 默认普通购物车
$deliveryTime
=
$this
->
post
(
'deliveryTimeId'
,
1
);
// 默认只工作日配送
$deliveryWay
=
$this
->
post
(
'deliveryId'
,
1
);
// 默认普通快递
...
...
Please
register
or
login
to post a comment