Authored by Rock Zhang

Merge branch 'feature/message' into feature/wap4.3

Conflicts:
	library/Api/Yohobuy.php
	template/m.yohobuy.com/partials/layout/use.phtml
... ... @@ -23,15 +23,9 @@ class Yohobuy
// const YOHOBUY_URL = 'http://www.yohobuy.com/';
//java API
// const API_URL = 'http://apih5.yoho.cn/';
// const API_URL2 = 'http://apih5.yoho.cn/';
// const SERVICE_URL = 'http://serviceh5.yoho.cn/';
// const YOHOBUY_URL = 'http://www.yohobuy.com/';
// const API_OLD = 'http://api2.open.yohobuy.com/';
// const API_URL = 'http://api.yoho.cn/';
// const API_URL2 = 'http://api.yoho.cn/';
// const SERVICE_URL = 'http://service.yoho.cn/';
// const API_URL = 'http://api.yoho.yohoops.org/';
// const API_URL2 = 'http://api.yoho.yohoops.org/';
// const SERVICE_URL = 'http://service.yoho.yohoops.org/';
// const YOHOBUY_URL = 'http://www.yohobuy.com/';
// const API_OLD = 'http://api2.open.yohobuy.com/';
... ... @@ -43,18 +37,15 @@ class Yohobuy
// const API_OLD = 'http://api2.open.yohobuy.com/';
/* 测试环境 java API*/
const API_URL = 'http://testapi.yoho.cn:28078/'; // 'http://devapi.yoho.cn:58078/';
// const API_URL = 'http://devapi.yoho.cn:58078/';
const DEV_API_URL = 'http://devapi.yoho.cn:58078/';
const SERVICE_URL = 'http://testservice.yoho.cn:28077/'; // 'http://devservice.yoho.cn:58077/';
const DEV_SERVICE_URL = 'http://devservice.yoho.cn:58077/';
const PRD_SERVICE_URL = 'http://serviceh5.yoho.cn/';
const API_URL = 'http://testapi.yoho.cn:28078/'; // 'http://192.168.102.205:8080/gateway/'
const SERVICE_URL = 'http://testservice.yoho.cn:28077/';
const YOHOBUY_URL = 'http://www.yohobuy.com/';
const API_OLD = 'http://test2.open.yohobuy.com/';
/* 测试环境 php API*/
// const API_URL = 'http://test2.open.yohobuy.com/';
// const SERVICE_URL = 'http://test.service.api.yohobuy.com/';
/* 预览环境 */
// const API_URL = 'http://preapi.yoho.cn/';
// const API_URL2 = 'http://preapi.yoho.cn/';
// const SERVICE_URL = 'http://preservice.yoho.cn/';
// const YOHOBUY_URL = 'http://www.yohobuy.com/';
// const API_OLD = 'http://api2.open.yohobuy.com/';
... ... @@ -78,7 +69,6 @@ class Yohobuy
);
/**
* 取得当前的客户端类型
*/
... ... @@ -87,15 +77,12 @@ class Yohobuy
// 苹果设备
if (strstr($_SERVER['HTTP_USER_AGENT'], 'iPhone')) {
return 'iphone';
}
// 苹果IPAD
} // 苹果IPAD
elseif (strstr($_SERVER['HTTP_USER_AGENT'], 'iPad')) {
return 'ipad';
}
elseif (stristr($_SERVER['HTTP_USER_AGENT'], 'android')) {
} elseif (stristr($_SERVER['HTTP_USER_AGENT'], 'android')) {
return 'android';
}
// 其它
} // 其它
else {
return 'android';
}
... ... @@ -213,8 +200,7 @@ class Yohobuy
// 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
if (empty($result)) {
$result = Cache::get($url, 'slave');
}
// 接口调用成功时,这里会设置一级(master)和二级(slave)的缓存数据.
} // 接口调用成功时,这里会设置一级(master)和二级(slave)的缓存数据.
else {
Cache::set($url, $result, $cache);
}
... ... @@ -354,13 +340,12 @@ class Yohobuy
}
$response = json_decode($data, true);
if(!$isOriginalData) {//只返回data数据
if (!$isOriginalData) {//只返回data数据
if (!isset($response['data'])) {
continue;
}
$result[$name] = $response['data'];
}
else {
} else {
$result[$name] = $response;
}
curl_multi_remove_handle($mh, $ch[$name]);
... ... @@ -373,8 +358,7 @@ class Yohobuy
// 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
if (empty($result[$name])) {
$result = Cache::get($key, 'slave');
}
// 接口调用成功时,这里会设置一级(master)和二级(slave)的缓存数据.
} // 接口调用成功时,这里会设置一级(master)和二级(slave)的缓存数据.
else {
Cache::set($key, $result, $cache);
}
... ... @@ -422,8 +406,7 @@ class Yohobuy
// 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
if (empty($result)) {
$result = Cache::get($key, 'slave');
}
// 接口调用成功时,这里会设置一级(master)和二级(slave)的缓存数据.
} // 接口调用成功时,这里会设置一级(master)和二级(slave)的缓存数据.
else {
Cache::set($key, $result, $cache);
}
... ...
... ... @@ -459,6 +459,57 @@ class UserData
}
/**
* 删除我的消息
*
* @param int $uid 用户id
* @param int $id 消息id
* @return mixed
*/
public static function delMessageData($uid, $id)
{
$param = Yohobuy::param();
$param['method'] = 'app.inbox.delmessage';
$param['uid'] = $uid;
$param['id'] = $id;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 根据用户uid获取生日券id
* @param int $uid 用户id
* @return mixed
*/
public static function getBirthCouponById($uid)
{
$param = Yohobuy::param();
$param['method'] = 'app.promotion.queryBirthCoupon';
$param['uid'] = $uid;
$param['couponType'] = 4;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* vip会员领取生日券
* @param type $uid 用户id
* @param type $couponId 生日券号
* @return type
*/
public static function getBirthCoupon($uid, $couponId)
{
$param = Yohobuy::param();
$param['method'] = 'app.promotion.getCoupon';
$param['uid'] = $uid;
$param['couponId'] = $couponId;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 在线客服接口
*
* @return array 消息接口返回的数据
... ...
... ... @@ -40,6 +40,7 @@ $('.employ span').each(function(index) {
});
});
function scrollHandler() {
if ($(window).scrollTop() + $(window).height() > $('body').height() - 100) {
page++;
... ...
... ... @@ -20,3 +20,4 @@ require('./pay');
require('./personal-details');
require('./currency');
require('./currency-new');
require('./message');
... ...
var $ = require('jquery'),
dialog = require('./dialog');
var $page = $('.massage-page');
var pickBusy = false;
// 领取生日券
$page.on('touchstart', '.pick-coupon-btn', function() {
if (pickBusy) {
return;
}
pickBusy = true;
var $id = $(this).data('id');
$.ajax({
type: 'POST',
url: '/home/pickCoupon',
data: {
id: $id
},
success: function(data) {
if (data.code === 200) {
dialog.showDialog({
dialogText: '领取成功',
autoHide: 2000,
fast: true
});
$(this).removeClass('pick-coupon-btn');
}
pickBusy = false;
dialog.showDialog({
dialogText: data.message,
autoHide: 2000,
fast: true
});
}
});
});
... ...
var $ = require('jquery'),
loading = require('../plugin/loading'),
dialog = require('./dialog');
var $page = $('.massage-page'),
page = 1,
stopLoading = false;
function massageAJAX(page) {
loading.showLoadingMask();
$.ajax({
type: 'POST',
url: '/home/ajaxMessage',
dataType: 'html',
data: {
page: page
},
success: function(data) {
if (data === ' ') {
stopLoading = true;
if (page === 1) {
data = '<p style="text-align:center">您没有消息</p>';
}
}
$('.massage-page').append(data);
window.rePosFooter();
loading.hideLoadingMask();
}
});
}
function scrollHandler() {
if (!stopLoading && ($(window).scrollTop() + $(window).height() > $('body').height() - 100)) {
page++;
massageAJAX(page);
}
}
$(window).scroll(function() {
window.requestAnimationFrame(scrollHandler);
});
// 删除消息
$page.on('touchstart', '.del', function() {
var $good = $(this).closest('.massage-list'),
$id = $good.data('id');
dialog.showDialog({
dialogText: '确定删除这条消息吗?',
hasFooter: {
leftBtnText: '取消',
rightBtnText: '确定'
}
}, function() {
$.ajax({
type: 'POST',
url: '/home/ajaxDelMes',
data: {
id: $id
},
success: function(data) {
if (data.code === 200) {
dialog.showDialog({
dialogText: '删除消息成功',
autoHide: 2000,
fast: true
});
setTimeout(function() {
window.history.go(0);
}, 1200);
}
}
});
});
});
massageAJAX(page);
... ...
$vip: sprite-map("me/vip/*.png", $spacing: 10px);
$fav: sprite-map("me/fav/*.png", $spacing: 5px);
@import "home", "vip-grade", "order", "order-detail", "coupons", "personal-details", "yoho-coin", "fav", "suggest", "address", "online-service", "my-guang", "ihelp", "browse-record", "logistic", "pay","yoho-coin-new", "yoho-coin-detail";
@import "home", "message", "vip-grade", "order", "order-detail", "coupons", "personal-details", "yoho-coin", "fav", "suggest", "address", "online-service", "my-guang", "ihelp", "browse-record", "logistic", "pay","yoho-coin-new", "yoho-coin-detail";
... ...
.massage-page{
margin-top: .4rem;
padding-bottom:.6rem;
.massage-list{
padding: 1em 2em 1em 1.4em;
border-bottom: 1px solid #F8F8F8;
position: relative;
overflow: hidden;
p{
font-size: 1.2em;
color: #222;
}
span{
font-size: 0.9em;
color: #999999;
}
i{
position: absolute;
right: .6rem;
top: .6rem;
color: #cccccc;
}
strong{
width: 8px;
height: 8px;
position: absolute;
left: .4rem;
top: 1rem;
background: #f00;
border-radius:50%;
}
}
.massage-main{
border-bottom: 1px solid #F8F8F8;
padding: 12px;
margin-left: 10px;
margin-bottom: 10px;
h6{
margin-bottom: .2rem;
}
span{
color: #656565;
}
}
.sale-btn{
background-color: #ea2622;
color: #fff;
padding: 5px 10px 5px 10px;
}
.coupon-item{
margin-left: 10px;
padding-bottom: 10px;
border-bottom: 1px solid #F8F8F8;
margin-top: 10px;
.coupon-img{
width: 3.2rem;
height: auto;
overflow: hidden;
float: left;
margin-right: .4rem;
img{
width: 100%;
height: auto;
}
}
.coupon-info{
font-size: .55rem;
span{
color: #f00;
}
}
.coupon-action{
width: 110px;
font-size: 12px;
letter-spacing: 2px;
margin: 3px 0 0 0;
height: 35px;
line-height: 35px;
background: #ed0010;
text-align: center;
margin-left: 3.6rem;
a{
display: block;
color: #fff;
width: 100%;
height:100%;
}
}
}
}
\ No newline at end of file
... ...
{{#list}}
<div class="massage-list" data-id="{{id}}">
{{#if isNotReaded}}
<strong></strong>
{{/if}}
<p><a href="{{url}}">{{title}}</a></p>
<span>{{time}}</span>
<i class="iconfont del">&#xe621;</i>
</div>
{{/list}}
... ...
{{> layout/header}}
<div class="massage-page yoho-page">
<div class="massage-main">
<h6>{{title}}</h6>
<span>{{sender}} 发送于{{time}}</span>
</div>
{{#if text}}
<div class="massage-main">
{{# text}}
<!-- 文本消息 -->
<p>{{{content}}}</p>
{{/ text}}
</div>
{{/if}}
{{#if coupons}}
{{# coupons}}
<!-- 优惠券消息 -->
<div class="coupon-item">
<div class="coupon-img">
<img src="http://static.yohobuy.com/images/v2/activity/default_coupon.jpg">
</div>
<div class="coupon-info">
<p>{{remark}}</p>
{{#if url}}
<p>面值:<span>{{price}}</span></p>
<p>有效期:{{useTime}}</p>
{{^}}
<p>使用时间:{{useTime}}</p>
<p>领取时间:{{pickTime}}</p>
{{/if}}
</div>
<div class="coupon-action">
{{#if url}}
<a href="{{url}}" class="view-coupon-btn">立即查看</a>
{{^}}
<a{{#if canPick}} class="pick-coupon-btn" data-id="{{id}}"{{/if}}>立即领取</a>
{{/if}}
</div>
</div>
{{/ coupons}}
{{/if}}
{{#if sale}}
{{# sale}}
<!-- 促销消息 -->
<div class="sale-img">
<img src="{{image}}">
</div>
<br />
<br />
<p>{{{content}}}</p>
<br />
<br />
<a href="{{btnLink}}" class="sale-btn">{{btnName}}</a>
{{/ sale}}
{{/if}}
</div>
{{> layout/footer}}
\ No newline at end of file
... ...
{{> layout/header}}
<div class="massage-page yoho-page">
</div>
{{> layout/footer}}
\ No newline at end of file
... ...
... ... @@ -368,3 +368,13 @@
</script>
{{/if}}
{{#if messagePage}}
<script>
seajs.use('js/me/message');
</script>
{{/if}}
{{#if messageDetailPage}}
<script>
seajs.use('js/me/message-detail');
</script>
{{/if}}
... ...
... ... @@ -271,6 +271,97 @@ class HomeController extends AbstractAction
}
/**
* 消息
*/
public function messageAction()
{
// 审判跳转登录页
$this->auditJumpLogin();
$this->setTitle('我的消息');
$this->setNavHeader('我的消息', true, false);
$messages['pageFooter'] = true;
$messages['messagePage'] = true;
$this->_view->display('message', $messages);
}
/*
* 异步获取我的消息
*/
public function ajaxMessageAction()
{
$result = array();
if ($this->isAjax()) {
$page = $this->post('page', 1);
$uid = $this->getUid(true);
$result = UserModel::getMessageData($uid, $page, 20);
}
if (empty($result)) {
echo ' ';
} else {
$this->_view->display('message-list', $result);
}
}
/*
* 异步删除我的消息
*/
public function ajaxDelMesAction()
{
$result = array();
if ($this->isAjax()) {
$id = $this->post('id', 0);
$uid = $this->getUid(true);
$result = UserModel::delMessage($uid, $id);
}
$this->echoJson($result);
}
/**
* 消息详情
*/
public function messageDetailAction()
{
$this->setTitle('我的消息');
$this->setNavHeader('我的消息', true, false);
$id = $this->get('id', 0);
$uid = $this->getUid(true);
$data = UserModel::getMessageDetail($uid, $id);
$data['pageFooter'] = true;
$data['messageDetailPage'] = true;
$this->_view->display('message-main', $data);
}
/**
* 我的消息详情中领取生日券
*/
public function pickCouponAction()
{
$result = array('code' => 400, 'message' => '', 'data' => '');
do {
/* 判断是不是AJAX请求 */
if (!$this->isAjax()) {
break;
}
$uid = $this->getUid(true);
$id = $this->post('id', 0);
$result = UserModel::pickBirthCoupon($uid, $id);
}
while (false);
$this->echoJson($result);
}
/**
* 优惠券
*/
public function couponsAction()
... ... @@ -467,7 +558,7 @@ class HomeController extends AbstractAction
$serviceUrl = 'http://chat8.live800.com/live800/chatClient/chatbox.jsp?companyID=620092&configID=149091&jid=8732423409&info=';
if ($uid) {
$time = time() . '000';
$info = 'userId=' . $uid . '&name=' . $this->_uname . '&memo=&hashCode=' . md5( strtoupper( rawurlencode($uid . $this->_uname . $time . '1231') ) ) . '&timestamp=' . $time;
$info = 'userId=' . $uid . '&name=' . $this->_uname . '&memo=&hashCode=' . md5(strtoupper(rawurlencode($uid . $this->_uname . $time . '1231'))) . '&timestamp=' . $time;
$serviceUrl .= rawurlencode($info);
}
... ... @@ -812,7 +903,7 @@ class HomeController extends AbstractAction
/* 判断订单是否已付款, 已付款跳到订单详情页 */
if (!empty($orderDetail['isPay'])) {
$this->go(Helpers::url('/home/orderdetail', array('order_code' => $orderCode)) );
$this->go(Helpers::url('/home/orderdetail', array('order_code' => $orderCode)));
}
$hasWxShare = strpos($this->server('HTTP_USER_AGENT', ''), 'MicroMessenger') !== false;
... ... @@ -892,8 +983,8 @@ class HomeController extends AbstractAction
$input->SetBody('有货订单号:' . $orderCode);
$input->SetOut_trade_no('YOHOBuy_' . $orderCode); // 商户订单号
$input->SetTotal_fee($totalFee);
$input->SetTime_start(date("YmdHis", (int) $orderDetail['data']['create_time']));
$input->SetTime_expire(date("YmdHis", (int) $orderDetail['data']['create_time'] + 7200));
$input->SetTime_start(date("YmdHis", (int)$orderDetail['data']['create_time']));
$input->SetTime_expire(date("YmdHis", (int)$orderDetail['data']['create_time'] + 7200));
$input->SetNotify_url(WxPayConfig::NOTIFY_URL);
$input->SetTrade_type("JSAPI");
$input->SetOpenid($openId);
... ... @@ -1026,5 +1117,4 @@ class HomeController extends AbstractAction
echo ' ';
}
}
}
... ...
... ... @@ -875,10 +875,164 @@ class UserModel
$messageData = UserData::messageData($uid, $page, $size);
// 处理我的消息数据
if (isset($messageData['data']) && !empty($messageData['data'])) {
$result = $messageData['data'];
if (isset($messageData['data']['list']) && !empty($messageData['data']['list'])) {
$messages = $messageData['data']['list'];
$one = array();
foreach ($messages as $message) {
$one = array();
$one['id'] = $message['id'];
$one['title'] = $message['title'];
$one['time'] = date('Y-m-d H:i:s', $message['create_time']);
$one['isNotReaded'] = ($message['is_read'] === 'N');
$one['url'] = Helpers::url('/home/messageDetail', array('id' => $message['id']));
$result['list'][] = $one;
}
}
return $result;
}
/*
* 删除消息
*
* @param int $uid 用户ID
* @param int $id 消息ID
* @return array
*/
public static function delMessage($uid, $id)
{
$result = array('code' => 400, 'message' => '出错啦~');
do {
if (empty($uid) || empty($id)) {
break;
}
$message = UserData::delMessageData($uid, $id);
if (isset($message['code']) && $message['code'] == 200) {
$result['code'] = 200;
}
} while (false);
return $result;
}
/*
* 我的消息中领取生日券
*
* @param int $uid 用户ID
* @param int $id 消息ID
* @return array
*/
public static function pickBirthCoupon($uid, $id)
{
$result = array('code' => 400, 'message' => '出错啦~');
do {
if (empty($uid) || empty($id)) {
break;
}
$coupon = UserData::getBirthCoupon($uid, $id);
if (!isset($coupon['code'])) {
break;
}
$result = $coupon;
} while (false);
return $result;
}
/**
* 处理我的消息详情信息
*
* @param int $uid 用户ID
* @param int $id 消息ID
* @return array
*/
public static function getMessageDetail($uid, $id)
{
$result = array();
do {
// UID或者id为空
if (empty($uid) || empty($id)) {
break;
}
$messageData = UserData::messageData($uid, 1, 1000);
// 接口未正确返回
if (!isset($messageData['data']['list'])) {
break;
}
// 处理我的消息数据
$messages = $messageData['data']['list'];
foreach ($messages as $contentval) {
if ($contentval['id'] != $id) {
continue;
}
//信息过滤
if ($contentval['type'] === 'showGetCoin' || $contentval['type'] === 'notice') {
continue;
}
$result['sender'] = $contentval['from']; //消息发言人
$result['title'] = $contentval['title']; //消息标题
$result['time'] = date('Y-m-d H:i:s', $contentval['create_time']); //消息创建时间
//判断消息类型
switch ($contentval['type']) {
case 'pullCoupon':
//领取生日券消息
$result['coupons'] = array();
$coupondata = UserData::getBirthCouponById($uid); //获取优惠券信息
if (empty($coupondata['data']) || !isset($coupondata['data'])) {
continue;
}
foreach ($coupondata['data'] as $couponval) {
$result['coupons'][] = array(
'id' => isset($couponval['id']) ? $couponval['id'] : '',
'remark' => isset($couponval['couponName']) ? $couponval['couponName'] : '',
'useTime' => isset($contentval['body']['use_time']) ? $contentval['body']['use_time'] : '',
'pickTime' => isset($contentval['body']['collar_time']) ? $contentval['body']['collar_time'] : '',
'canPick' => true
);
}
break;
case 'button':
//促销活动
$result['sale'] = array(
'image' => isset($contentval['body']['image']) ? $contentval['body']['image'] : '',
'content' => isset($contentval['body']['text']) ? $contentval['body']['text'] : '',
'btnLink' => isset($contentval['body']['pc_link']) ? $contentval['body']['pc_link'] : '',
'btnName' => isset($contentval['body']['button_text']) ? $contentval['body']['button_text'] : '',
);
break;
case 'pushCoupon':
//查看优惠券
$result['coupons'] = array();
$result['coupons'][] = array(
'remark' => isset($contentval['body']['coupon_name']) ? $contentval['body']['coupon_name'] : '',
'useTime' => isset($contentval['body']['time']) ? $contentval['body']['time'] : '',
'id' => isset($contentval['body']['inboxId']) ? $contentval['body']['inboxId'] : '',
'price' => isset($contentval['body']['price']) ? $contentval['body']['price'] : '',
'url' => Helpers::url('/home/coupons', array('t' => microtime(true)))
);
break;
default:
//普通文本
$result['text'] = array(
'content' => isset($contentval['body']['content']) ? $contentval['body']['content'] : ''
);
break;
}
}
} while (false);
return $result;
}
... ...