Authored by 周少峰

Merge branch 'feature/students' into release/4.9.1.0

... ... @@ -21,6 +21,7 @@ use WebPlugin\Mobile;
use Api\Yohobuy;
use LibModels\Web\Passport\LoginData;
use WebPlugin\UdpLog;
use WebPlugin\Encryption;
class WebAction extends Controller_Abstract
{
... ... @@ -382,6 +383,7 @@ class WebAction extends Controller_Abstract
$userInfo = LoginData::profile($uid);
if (isset($userInfo['data']) && $userInfo['data']) {
$token = Helpers::makeToken($uid);
$userInfo['data']['uid'] = Encryption::encrypt($userInfo['data']['uid']);
$uidCookie = $userInfo['data']['profile_name'] . '::' . $userInfo['data']['uid'] . '::' . $userInfo['data']['vip_info']['title'] . '::' . $token;
$this->setCookie('_UID',$uidCookie,time() + 86400 * 360);
UdpLog::info('syncUserCookie :',$uidCookie);
... ... @@ -411,7 +413,8 @@ class WebAction extends Controller_Abstract
// 兼容老的
if (!empty($cookie)) {
$cookieList = explode('::', $cookie);
if (isset($cookieList[1]) && is_numeric($cookieList[1])) {
$cookieList[1] = Encryption::decrypt($cookieList[1]);
if (isset($cookieList[1]) && $cookieList[1]) {
if ($useSession) {
$token = $this->getSession('_TOKEN');
if (empty($token)) {
... ... @@ -437,7 +440,7 @@ class WebAction extends Controller_Abstract
}
}
}
return $this->_uid;
return intval($this->_uid);
}
/**
... ...
<?php
/**
* AES, 128 ECB模式加密数据
* 原有的填充方法没用到,否则与java、node不一致,暂时保留
*/
namespace WebPlugin;
... ... @@ -10,20 +11,18 @@ class Encryption {
//密钥
private static $_secretKey = 'yoho9646abcdefgh';
//前面补8位0
private static $_preString = '00000000';
/**
* 加密方法
* @param string $str
* @param string $str 加密字符
* @param string $key 密钥
* @return string
*/
public static function encrypt($str){
$str = self::$_preString.$str;
public static function encrypt($str, $key = ''){
//AES, 128 ECB模式加密数据
$secretKey = self::$_secretKey;
$secretKey = $key ? $key : self::$_secretKey;
$str = trim($str);
$str = self::addPKCS7Padding($str);
// $str = self::addPKCS7Padding($str);
$iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128,MCRYPT_MODE_ECB),MCRYPT_RAND);
$encrypt_str = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $secretKey, $str, MCRYPT_MODE_ECB, $iv);
return base64_encode($encrypt_str);
... ... @@ -31,18 +30,18 @@ class Encryption {
/**
* 解密方法
* @param string $str
* @param string $str 解密字符
* @param string $key 密钥
* @return string
*/
public static function decrypt($str){
public static function decrypt($str, $key = ''){
//AES, 128 ECB模式加密数据
$secretKey = self::$_secretKey;
$secretKey = $key ? $key : self::$_secretKey;
$str = base64_decode($str);
$iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128,MCRYPT_MODE_ECB),MCRYPT_RAND);
$encrypt_str = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $secretKey, $str, MCRYPT_MODE_ECB, $iv);
$encrypt_str = trim($encrypt_str);
$encrypt_str = self::stripPKSC7Padding($encrypt_str);
$encrypt_str = ltrim($encrypt_str, self::$_preString);
// $encrypt_str = self::stripPKSC7Padding($encrypt_str);
return $encrypt_str;
}
... ...
... ... @@ -711,7 +711,8 @@ class Helpers
$oneGoods['productSize'] = $value['size_name'];
$oneGoods['productPrice'] = self::transPrice($value['last_vip_price']); //self::transPrice($value['real_price']);
$oneGoods['productNum'] = $value['buy_number'];
$oneGoods['isVipPrice'] = $value['sales_price'] !== $value['last_vip_price'];
$oneGoods['isVipPrice'] = $value['sales_price'] !== $value['last_vip_price'] && $value['discount_tag'] === 'V';
$oneGoods['isStuPrice'] = $value['sales_price'] !== $value['last_vip_price'] && $value['discount_tag'] === 'S';
$oneGoods['yohoIcon'] = isset($value['get_yoho_coin']) ? $value['get_yoho_coin'] : 0;
$oneGoods['productSubtotal'] = self::transPrice( floatval($value['last_vip_price']) * intval($value['buy_number']) );
$oneGoods['promotionId'] = empty($value['promotion_id']) ? '0' : $value['promotion_id'];
... ...
... ... @@ -162,6 +162,10 @@
{{#isVipPrice}}
<span class="vipPrice">(VIP)</span>
{{/isVipPrice}}
{{#isStuPrice}}
<span class="vipPrice">(学生价)</span>
{{/isStuPrice}}
</td>
<td>{{yohoIcon}}个</td>
<td class="adjust-cart-num">
... ...
... ... @@ -15,6 +15,9 @@
<b>({{count}})</b>
{{/ messages}}
{{#if certifiedName}}
<a href="{{certifiedUrl}}" target="_blank">{{certifiedName}}</a>
{{/if}}
<span id="close-message" class="close iconfont">&#xe602;</span>
</p>
{{/if}}
... ...
... ... @@ -3,6 +3,15 @@
<h2 class="sub-title">
<div class="more"><a class="btn-edit" title="修改"></a></div>
{{subTitle}}
{{#if certified}}
<span class="sub-tips">学生身份已验证通过啦,赶紧去体验下<a class="tips-url" href="{{tipsUrl}}" target="_blank">我们的专属特权</a>吧!</span>
{{else}}
<span class="sub-tips"> 校园潮流季-我们的专属特权,进行学生身份验证即有惊喜哦,</span>
<a class="tips-url" href="{{tipsUrl}}" target="_blank">立即进行身份验证</a>
{{/if}}
</h2>
<form action="" {{# firstBox}}class="first" {{/firstBox}}>
<div class="box">
... ...
... ... @@ -268,7 +268,7 @@
</li>
</ul>
<div class="myyoho-info-footer">
<a href="//www.yohobuy.com/home/user?t=\{\{timestamp\}\}">完善资料</a>
<a href="//www.yohobuy.com/home/user?t=\{\{timestamp\}\}">完善资料 <span>(学生认证)</span></a>
</div>
</script>
</div>
... ...
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
... ... @@ -298,6 +298,10 @@
a {
color: black;
font-size: 14px;
span {
color: #d0021b;
}
}
}
... ...
... ... @@ -283,7 +283,6 @@
font-size: 12px;
color: #333;
font-weight: normal;
cursor: pointer;
margin-bottom: 2px;
.more {
... ... @@ -298,6 +297,7 @@
display: inline-block;
overflow: hidden;
border: 0px;
cursor: pointer;
}
}
... ... @@ -320,6 +320,15 @@
margin-bottom: 10px;
}
}
.sub-tips {
color: #e52828;
}
.tips-url {
color: #e52828;
text-decoration: underline;
}
}
... ...
... ... @@ -153,6 +153,9 @@ class UserModel
public static function getUserInfo($uid)
{
$userInfo = UserData::getUserInfo($uid);
// print_r($userInfo); exit;
// 学生认证
$res['is_student'] = isset($userInfo['data']['vip_info']['is_student']) ? $userInfo['data']['vip_info']['is_student'] : 0;
//头像
$res['headIco'] = empty($userInfo['data']['head_ico']) ? ChannelConfig::$headDefaultImgIco : Images::getImageUrl($userInfo['data']['head_ico'], 100, 100, 2);
$res['email'] = isset($userInfo['data']['email']) ? $userInfo['data']['email'] : '';
... ...
... ... @@ -55,6 +55,7 @@ class CartModel
// 调用接口,获取购物车数据
$cartData = CartData::cartData($uid, $shoppingKey);
// print_r($cartData); exit;
// 接口异常时,购物车置为空
if (empty($cartData['data'])) {
$result['isEmpty'] = true;
... ... @@ -1393,17 +1394,23 @@ class CartModel
private static function genProductAmount($promotionList, $default)
{
$result = $default;
// VIP价格
$vipAmount = null;
// 学生价
$stuAmount = null;
foreach ($promotionList as $value) {
if ($value['promotion'] === 'VIP优惠') {
$vipAmount = strtr($value['promotion_amount'], array('¥' => '', '-' => '', '+' => ''));
break;
} elseif ($value['promotion'] === '学生优惠') {
$stuAmount = strtr($value['promotion_amount'], array('¥' => '', '-' => '', '+' => ''));
}
}
if (null !== $vipAmount) {
$result = floatval($default) - floatval($vipAmount);
}
if (null !== $stuAmount) {
$result = floatval($default) - floatval($stuAmount);
}
$result = Helpers::transPrice($result);
return $result;
... ...
... ... @@ -58,11 +58,15 @@ class IndexController extends WebAction
//取消订单原因列表
$resons = OrderData::closeReasons();
$cancelReason = isset($resons['data']) ? $resons['data'] : '';
$useInfo = UserModel::getUserInfo($uid);
$data = array(
'path' => $path,
'userThumb' => UserModel::getUserHeadImg($uid),
'homeNav' => $leftNav,
'cancelReason' => $cancelReason,
'certifiedName' => $useInfo['is_student'] ? '学生身份已验证' : '身份验证',
'certifiedUrl' => Helpers::url('/product/students/'),
'content' => array(
array(
//消息提示
... ...
... ... @@ -40,6 +40,8 @@ class UserController extends WebAction
'isShowTip' => intval($configInfo['data']['config']['sn']),
'userPersonalInfo' => array(
'subTitle' => '会员信息',
'certified' => $userInfo['is_student'] === 1,
'tipsUrl' => $userInfo['is_students'] === 1 ? Helpers::url('/', '', 'list') : Helpers::url('/product/students'),
'firstBox' => true,
'submitId' => 'base-info',
'profileSrc' => $userInfo['headIco'],
... ...