Authored by 毕凯

Merge branch 'develop' of http://git.dev.yoho.cn/web/yohobuy into develop

... ... @@ -31,9 +31,10 @@ class AbstractAction extends Controller_Abstract
/**
* 用户相关信息
*/
protected $_vip;
protected $_uid = 0;
protected $_uname = '';
protected $_vip;
protected $_usession = '';
protected $_useSession = true;
/**
... ... @@ -299,7 +300,7 @@ class AbstractAction extends Controller_Abstract
$useSession = false;
}
$useSession = false;
if (!$this->_uid) {
$cookie = $this->getCookie('_UID');
if (!empty($cookie)) {
... ... @@ -317,6 +318,7 @@ class AbstractAction extends Controller_Abstract
$this->_uid = $cookieList[1];
}
$this->_uname = $cookieList[0];
$this->_usession = $cookieList[3];
$this->_vip = $cookieList[2];
}
}
... ... @@ -419,7 +421,7 @@ class AbstractAction extends Controller_Abstract
// 默认使用男生的头部
$header['boys'] = true;
$controller = $this->getRequest()->getControllerName();
if ($controller !== 'Home') {
// 根据COOKIE记录的频道进行导航定位
... ...
... ... @@ -91,7 +91,7 @@ class Yohobuy
{
$clientType = self::clientType();
$param = array(
'app_version' => '3.6',
'app_version' => '3.8.2',
'client_type' => $clientType,
'os_version' => 'yohobuy:h5',
'private_key' => self::$privateKeyList[$clientType],
... ...
... ... @@ -19,6 +19,7 @@ class ActivityData
const URI_GET_ACTIVITY_INFO = 'event/api/v1/activity/get';
const URI_GET_NAMED_COUPON = 'event/api/v1/activity/getCoupon';
const URI_GET_ALL_COUPON = 'event/api/v1/activity/getCoupon';
const URI_SEND_MESSAGE = 'inbox/service/v1/inbox';
/**
* 用户获取某个活动指定的单个优惠券
... ... @@ -50,7 +51,7 @@ class ActivityData
$param = array();
$param['uid'] = $uid;
$param['activity_id'] = $activityId;
return Yohobuy::get(Yohobuy::SERVICE_URL . self::URI_GET_ALL_COUPON, $param);
}
... ... @@ -77,7 +78,7 @@ class ActivityData
{
//调用接口发送站内信
return Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URI_SEND_MESSAGE, 'setSingleMessage', array(
$uid, $title, $content, $type, $verify_key, $send_uid, $call_back
$uid, $title, $content, $type, $verify_key, $send_uid, $call_back
));
}
... ...
... ... @@ -6,19 +6,15 @@ use Api\Yohobuy;
use Api\Sign;
/**
* Description of OrderData
*
* @author Administrator
* 订单相关的数据模型
*
*/
class OrderData
{
/*
* 获取订单数据
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
public static function getOrderData($type, $page, $limit, $gender, $yh_channel, $uid)
public static function getOrderData($type, $page, $limit, $gender, $channel, $uid)
{
//构建必传参数
$param = Yohobuy::param();
... ... @@ -28,7 +24,7 @@ class OrderData
$param['page'] = $page;
$param['type'] = $type;
$param['uid'] = $uid;
$param['yh_channel'] = $yh_channel;
$param['yh_channel'] = $channel;
$param['client_secret'] = Sign::getSign($param);
//调用接口获得数据
return Yohobuy::get(Yohobuy::API_URL, $param);
... ... @@ -36,18 +32,15 @@ class OrderData
/*
* 取消订单
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
public static function cancelOrderData($order_code, $uid, $gender, $yh_channel)
public static function cancelOrderData($orderCode, $uid, $gender, $channel)
{
//构建必传参数
$param = Yohobuy::param();
$param['order_code'] = $order_code;
$param['order_code'] = $orderCode;
$param['uid'] = $uid;
$param['gender'] = $gender;
$param['yh_channel'] = $yh_channel;
$param['yh_channel'] = $channel;
$param['method'] = 'app.SpaceOrders.close';
$param['client_secret'] = Sign::getSign($param);
//调用接口获得数据
... ... @@ -56,22 +49,40 @@ class OrderData
/*
* 删除订单
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
public static function deleteOrderData($order_code, $uid, $gender, $yh_channel)
public static function deleteOrderData($orderCode, $uid, $gender, $channel)
{
//构建必传参数
$param = Yohobuy::param();
$param['order_code'] = $order_code;
$param['order_code'] = $orderCode;
$param['uid'] = $uid;
$param['gender'] = $gender;
$param['yh_channel'] = $yh_channel;
$param['yh_channel'] = $channel;
$param['method'] = 'app.SpaceOrders.delOrderByCode';
$param['client_secret'] = Sign::getSign($param);
//调用接口删除订单
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 查看订单详情
*
* @param string $orderCode 订单号
* @param int $uid 用户ID
* @param string $sessionKey 用户会话
* @return array
*/
public static function viewOrderData($orderCode, $uid, $sessionKey)
{
$param = Yohobuy::param();
$param['method'] = 'app.SpaceOrders.info';
$param['order_code'] = $orderCode;
$param['uid'] = $uid;
$param['session_key'] = $sessionKey;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/*
* 我的订单-查看物流
... ...
... ... @@ -215,9 +215,9 @@ class Helpers
$result['salePrice'] && $result['salePrice'] .= '.00';
}
$result['is_soon_sold_out'] = ($productData['is_soon_sold_out'] === 'Y');
$result['url'] = SITE_MAIN . '/product/pro_' . $productData['product_id'] . '_'
$result['url'] = self::url('/product/pro_' . $productData['product_id'] . '_'
. $productData['goods_list'][0]['goods_id']
. '/' . $productData['cn_alphabet'] . '.html';
. '/' . $productData['cn_alphabet'] . '.html');
// APP访问需要加附加的参数
// 备注:如果以后APP的接口太多,可以把这边参数提取出来,变成一个公共的方法来生成,便于以后管理维护
if ($isApp) {
... ... @@ -498,10 +498,15 @@ class Helpers
/**
* 格式化订单商品
*
* @param array $orderGoods 订单
* @param int $count 计订单件数
* @param bool $haveLink 控制是否需要商品链接
*/
public static function formatOrderGoods($orderGoods, &$count = 0)
public static function formatOrderGoods($orderGoods, &$count = 0, $haveLink = false)
{
$arr = array();
foreach ($orderGoods as $key => $vo) {
$arr[$key]['thumb'] = Helpers::getImageUrl($vo['goods_image'], 90, 120);
$arr[$key]['name'] = $vo['product_name'];
... ... @@ -519,9 +524,14 @@ class Helpers
if (!empty($vo['expect_arrival_time'])) {
$arr[$key]['appearDate'] = $vo['expect_arrival_time'];
}
// 商品链接
if ($haveLink && isset($vo['product_id'])) {
$arr[$key]['link'] = self::url('/product/pro_' . $vo['product_id'] . '_' . $vo['goods_id'] . '/' . $vo['cn_alphabet'] . '.html');
}
// 累计购买数
$count += intval($vo['buy_number']);
}
return $arr;
}
... ...
... ... @@ -25,6 +25,7 @@
</p>
</div>
{{#if unreceived}}
{{#if logisticsUrl}}
<a class="logistics sub" href="{{logisticsUrl}}">
<span class="iconfont">&#xe630;</span>
<p class="beside-icon sub-content">
... ... @@ -34,6 +35,7 @@
</p>
<span class="iconfont icon-right">&#xe614;</span>
</a>
{{/if}}
{{/if}}
</section>
... ... @@ -46,23 +48,27 @@
<ul class="cost block">
<li>
商品总金额
<span>¥{{sumPrice}}</span>
<span>{{sumPrice}}</span>
</li>
<li>
活动金额
<span>{{salePrice}}</span>
<span>{{salePrice}}</span>
</li>
<li>
运费
<span>+¥{{freight}}</span>
<span>{{freight}}</span>
</li>
<li>
优惠券
<span>{{coupon}}</span>
</li>
<li>
YOHO币
<span>{{yohoCoin}}</span>
<span>{{yohoCoin}}</span>
</li>
<li>
实付金额
<span>¥{{price}}</span>
<span>{{price}}</span>
</li>
</ul>
... ... @@ -75,9 +81,11 @@
{{#if unpaid}}
<span class="btn btn-cancel">取消订单</span>
{{#if payUrl}}
<a href="{{payUrl}}">
<span class="btn btn-pay">立即付款</span>
</a>
{{/if}}
{{/if}}
{{#if unreceived}}
... ...
<div class="order-good" data-id="{{id}}">
<div class="thumb-wrap">
<img class="thumb lazy" data-original="{{thumb}}">
<p class="tag{{#if gift}} gift-tag{{/if}}{{#if advanceBuy}} advance-buy-tag{{/if}}"></p>
{{#if link}}
<a href="{{link}}"><img class="thumb lazy" data-original="{{thumb}}"></a>
{{else}}
<img class="thumb lazy" data-original="{{thumb}}">
{{/if}}
<p class="tag{{#if gift}} gift-tag{{/if}}{{#if advanceBuy}} advance-buy-tag{{/if}}"></p>
</div>
<div class="deps">
<p class="name row">{{name}}</p>
... ...
... ... @@ -36,9 +36,7 @@ class ChristmasController extends HuodongAction
switch (intval($result['code'])) {
case 200: // 领取成功, 发送站内信消息
$showPopupFlag = '0';
$title = '【优惠券】您有6张潮集圣诞优惠券';
$content = '尊敬的客户:恭喜您成功获得6张潮集圣诞优惠券 !您可以在个人中心的交易管理中查看‘我的优惠券’。';
ActivityData::message($uid, $title, $content);
$this->sendMessage($uid);
break;
case 201: // 已领取过, 提示重复领券
$showPopupFlag = '1';
... ... @@ -53,10 +51,10 @@ class ChristmasController extends HuodongAction
'staticTitle' => '潮集圣诞',
'weixinShare' => $this->_isApp ? false : true, // 是否需要微信分享
'shareLink' => 'http://feature.yoho.cn/1211APPTEST3/index.html',
'shareTitle' => 'YOHO!BUY有货【潮集圣诞】第一弹疯狂来袭!500元优惠券引爆圣诞!',
'shareDesc' => '800+潮牌限时4折起,折上满减,最高直减¥100!',
'shareImg' => 'http://img12.static.yhbimg.com/couponImg/2015/12/10/05/02a7ec01785c8579ed10bdb65a16d60a44.png',
'shareLink' => 'http://feature.yohobuy.com/0/0/675/index.html',
'shareTitle' => 'YOHO!BUY有货【潮集圣诞】第一弹来袭!500元优惠券引爆圣诞!',
'shareDesc' => '万件潮品限时58折封顶,再享折上满减,还有惊喜圣诞礼物等你来挑哦!',
'shareImg' => 'http://img12.static.yhbimg.com/couponImg/2015/12/10/09/029fd41969b67002126ff7a71fe5396b6e.png',
'showPopupFlag' => $showPopupFlag,
'myCouponUrl' => $myCouponUrl,
... ... @@ -70,10 +68,10 @@ class ChristmasController extends HuodongAction
*
* @return int
*/
public function getLoggedUid()
private function getLoggedUid()
{
// 判断是否是应用访问, 拼接APP需要的URL参数
$this->_isApp = null !== $this->get('app_version');
$this->_isApp = (null !== $this->get('app_version') || null !== $this->get('uid'));
$uid = false;
if ($this->_isApp) {
$uid = $this->get('uid');
... ... @@ -83,6 +81,21 @@ class ChristmasController extends HuodongAction
return $uid;
}
/**
* 发送站内信
*
* @param int $uid 用户ID
*/
private function sendMessage($uid)
{
try {
ActivityData::message($uid, '【优惠券】您有6张潮集圣诞优惠券', '尊敬的客户:恭喜您成功获得6张潮集圣诞优惠券 !您可以在个人中心的交易管理中查看‘我的优惠券’。');
}
catch (Exception $e) {
// do nothing
}
}
/**
* 根据环境来获取活动ID
... ...
... ... @@ -48,7 +48,7 @@ class HomeController extends AbstractAction
'showDownloadApp' => true,
'pageFooter' => true,
'cartUrl' => Helpers::url('/cart/index/index', null),
'signinUrl' => Helpers::url('/signin.html', array('refer' => Helpers::url('/home')) ),
'signinUrl' => Helpers::url('/signin.html', array('refer' => Helpers::url('/home'))),
);
$uid = $this->getUid(false);
if ($uid) {
... ... @@ -781,14 +781,14 @@ class HomeController extends AbstractAction
// 审判跳转登录页
$this->auditJumpLogin();
$this->setTitle('支付中心');
$this->setNavHeader('支付中心');
$orderCode = $this->get('order_code');
if (empty($orderCode)) {
$this->error();
}
$this->setTitle('支付中心');
$this->setNavHeader('支付中心');
$this->_view->display('pay', array(
'payCenterPage' => true,
'payAppInfo' => array(
... ... @@ -814,61 +814,26 @@ class HomeController extends AbstractAction
));
}
// /*
// * 我的订单-确认收货
// */
// private function confirmAction(){
// //
// $gender = Helpers::getGenderByCookie();
// $order_code = $this->get('id');
// $order_code = '';
// $yh_channel = $this->get('yh_channel', 1);
// $data = OrderData::confirmData($gender,$order_code,$yh_channel,$this->_uid);
// $this->echoJson($data);
// }
/**
* 订单详情页
*/
public function orderDetailAction()
{
$data = array(
'name' => '毛毛莉Lydia',
'phoneNum' => '18600001133',
'address' => '南京市建邺区嘉陵江东街18号国家广告产业园5栋17楼',
'orderStatus' => '订单取消',
'orderNum' => '418358063',
'orderTime' => '2014-03-10 17:25:10',
'orderCancel' => true,
'goods' => array(
array(
'id' => 1,
'thumb' => 'http://img11.static.yhbimg.com/goodsimg/2015/11/04/05/01ce2aff32fc3c90584f516167cd526d91.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
'name' => 'Adidas Originals ZX FLUXM22508',
'color' => '黄',
'size' => '43',
'price' => '699.00',
'count' => '2'
),
array(
'id' => 1,
'thumb' => 'http://img10.static.yhbimg.com/goodsimg/2015/11/04/05/0188f1aca49ac478a565ec029b5d2d4a6c.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
'name' => 'B.Duck浴室玩伴mini浮水鸭',
'gift' => true,
'color' => '黄',
'size' => '43',
'price' => '0.00',
'count' => '1'
)
),
'sumPrice' => 799,
'salePrice' => 80,
'freight' => 5,
'coupon' => 0,
'yohoCoin' => 5,
'price' => 719
);
$this->_view->display('order-detail', array('orderDetail' => $data, 'orderDetailPage' => true));
// 审判跳转登录页
$this->auditJumpLogin();
$orderCode = $this->get('order_code', 1507880870);
if (empty($orderCode)) {
$this->error();
}
$this->setTitle('订单详情');
$this->setNavHeader('订单详情');
$this->_view->display('order-detail', array(
'orderDetailPage' => true,
'orderDetail' => OrderModel::orderDetail($orderCode, 967016/*$this->_uid*/, 'a3aadd4cce408f8ee062a9add02e8faa'/*$this->_session*/),
));
}
// /**
... ...
... ... @@ -10,100 +10,101 @@ use Plugin\Helpers;
*/
class ShoppingCartController extends AbstractAction
{
protected $_uid;
/**
* 初始化
*/
public function init()
{
// 检查用户是否登录, 未登录则跳转到登录页
$this->_uid = $this->getUid();
if (!$this->_uid) {
$this->go(Helpers::url('/signin.html'));
}
parent::init();
}
/*
* 首页
*/
protected $_uid;
/**
* 通过当前用户审判是否跳到登录
*
* @param int $useSession (true:从服务端session中检查, false:从客户端cookie中检查)
* @return void
*/
protected function auditJumpLogin($useSession = true)
{
$uid = $this->getUid($useSession);
if (!$uid) {
$this->go(Helpers::url('/signin.html', array('refer' => $this->server('HTTP_REFERER', SITE_MAIN))));
}
}
/*
* 首页
*/
public function indexAction()
{
$this->setTitle('购物车');
$this->setNavHeader('购物车');
$this->setTitle('购物车');
$this->setNavHeader('购物车');
$data = array(
'shoppingCartPage' => true,
'shoppingCart' => CartModel::getCartData($this->_uid)
'shoppingCartPage' => true,
'shoppingCart' => CartModel::getCartData($this->_uid)
);
// 渲染模板
$this->_view->display('index', $data);
}
/**
* 移出购物车
*/
public function delAction()
{
$result = array();
if ($this->isAjax()) {
$productId = $this->post('id', 0);
$result = CartModel::removeFromCart($this->_uid, $productId);
}
if (empty($result)) {
echo ' ';
} else {
$this->echoJson($result);
}
}
/**
* 移入收藏夹
*/
public function colAction()
{
$result = array();
if ($this->isAjax()) {
$productId = $this->post('id', 0);
$result = CartModel::addToFav($this->_uid, $productId);
}
if (empty($result)) {
echo ' ';
} else {
$this->echoJson($result);
}
}
/**
* 修改购物车商品数据
*/
public function modifyAction()
{
$result = array();
if ($this->isAjax()) {
$params = array();
$params['old_product_sku']= $this->post('old_product_sku', 0);
$params['new_product_sku']= $this->post('new_product_sku', 0);
$params['buy_number']= $this->post('buy_number', 0);
$params['selected']= $this->post('selected', null);
$result = CartModel::modifyCartProduct($this->_uid, $params);
}
if (empty($result)) {
echo ' ';
} else {
$this->echoJson($result);
}
}
/**
* 移出购物车
*/
public function delAction()
{
$result = array();
if ($this->isAjax()) {
$productId = $this->post('id', 0);
$result = CartModel::removeFromCart($this->_uid, $productId);
}
if (empty($result)) {
echo ' ';
} else {
$this->echoJson($result);
}
}
/**
* 移入收藏夹
*/
public function colAction()
{
$result = array();
if ($this->isAjax()) {
$productId = $this->post('id', 0);
$result = CartModel::addToFav($this->_uid, $productId);
}
if (empty($result)) {
echo ' ';
} else {
$this->echoJson($result);
}
}
/**
* 修改购物车商品数据
*/
public function modifyAction()
{
$result = array();
if ($this->isAjax()) {
$params = array();
$params['old_product_sku'] = $this->post('old_product_sku', 0);
$params['new_product_sku'] = $this->post('new_product_sku', 0);
$params['buy_number'] = $this->post('buy_number', 0);
$params['selected'] = $this->post('selected', null);
$result = CartModel::modifyCartProduct($this->_uid, $params);
}
if (empty($result)) {
echo ' ';
} else {
$this->echoJson($result);
}
}
public function giftAdvanceAction()
{
... ... @@ -147,10 +148,11 @@ class ShoppingCartController extends AbstractAction
);
$this->_view->display('gift-advance', array('giftAdvancePage' => true, 'pageHeader' => array(
'navBack' => true, 'navTitle' => '加价购'), 'shoppingCart' => $data));
'navBack' => true, 'navTitle' => '加价购'), 'shoppingCart' => $data));
}
public function orderEnsureAction() {
public function orderEnsureAction()
{
$data = array(
'orderEnsurePage' => true,
'orderEnsure' => array(
... ... @@ -258,33 +260,22 @@ class ShoppingCartController extends AbstractAction
}
/**
* 读取chose-panel内容
*/
public function tplAction()
{
if($this->isAjax()) {
$data = file_get_contents('../../../template/m.yohobuy.com/partials/shopping-cart/chose-panel.phtml');
echo($data);
}
}
public function goodinfoAction()
{
$result = array();
$result = array();
if ($this->isAjax()) {
$num = $this->get('buy_num', 1);
$skn = $this->get('id', 1);
$result = CartModel::cartProductData($this->_uid, $skn, $num); // 测试skn的ID为51172055
$result['num'] = $num;
$num = $this->get('buy_num', 1);
$skn = $this->get('id', 1);
$result = CartModel::cartProductData($this->_uid, $skn, $num); // 测试skn的ID为51172055
$result['num'] = $num;
}
if (empty($result)) {
echo ' ';
} else {
$this->echoJson($result);
}
if (empty($result)) {
echo ' ';
} else {
$this->echoJson($result);
}
}
}
... ...
... ... @@ -68,86 +68,20 @@ class OrderModel
}
//检查数据返回是否正常,正常则处理数据
if (!empty($data['data']['order_list'])) {
// 订单的状态列表
//$orderStatus = Helpers::getOrderStatus();
$count = 0;
foreach ($data['data']['order_list'] as $key => $vo) {
// if ($vo['payment_status'] == 'Y' && $vo['status'] == 0) {
// $vo['status'] = 1;
// }
// 订单件数清零
$count = 0;
//根据订单status判断订单处于什么状态。
$result[$key] = self::getOrderStatus($vo);
//订单号,支付状态,订单商品数量,订单总价格
$result[$key]['orderNum'] = $vo['order_code'];
//$result[$key]['orderStatus'] = ($vo['is_cancel'] === 'Y') ? '已取消' : $orderStatus[ $vo['payment_type'] ][ $vo['status'] ];
$result[$key]['orderStatus'] = $vo['status_str'];
$result[$key]['sumCost'] = $vo['amount'];
//类内调用格式化订单商品数据方法
$result[$key]['goods'] = Helpers::formatOrderGoods($vo['order_goods'], $count);
$result[$key]['goods'] = Helpers::formatOrderGoods($vo['order_goods'], $count);
$result[$key]['detailUrl'] = Helpers::url('/home/orders/detail', array('order_code' => $vo['order_code'], 't' => time()));
$result[$key]['count'] = $count;
//根据订单status判断订单处于什么状态。
do {
//订单取消状态 = Y 时,跳出判断订单状态循环,并设置订单状态为已取消。
if ($vo['is_cancel'] === 'Y') {
$result[$key]['canceled'] = true;
break;
}
/* 先判断订单付款方式,根据不同的付款方式计算订单状态。(注:货到付款没有待付款状态)
* 付款方式:1 => 在线支付,2 => 货到付款,3 => 现金支付,4 => 抵消支付;
*/
//支付方式为非货到付款时,计算订单状态。
if ($vo['payment_type'] != 2) {
switch ($vo['status']) {
case 0: // 待付款
$result[$key]['unpaid'] = true;
$result[$key]['payUrl'] = Helpers::url('/home/pay', array('order_code' => $vo['order_code']));
break;
//未发货&未收货 状态,统一合并到待收货状态。
case 1:
case 2:
case 3:
//已付款状态不给查看物流URL
$result[$key]['unreceived'] = true;
break;
case 4:
case 5:
//已发货状态,给查看物流URL
$result[$key]['unreceived'] = true;
$result[$key]['logisticsUrl'] = Helpers::url('/home/logistic', array('order_code' => $vo['order_code']));
break;
case 6:
$result[$key]['completed'] = true;
break;
default:
break;
}
break;
}
//订单为货到付款订单时,计算订单状态。(货到付款没有待付款状态)
switch ($vo['status']) {
case 0: // 备货中
$result[$key]['unpaid'] = true;
break;
case 1:
case 2:
case 3:
//备货中、已付款状态不给查看物流链接
$result[$key]['unreceived'] = true;
break;
case 4:
case 5:
//待收货状态,给查看物流url
$result[$key]['unreceived'] = true;
$result[$key]['logisticsUrl'] = Helpers::url('/home/logistic', array('order_code' => $vo['order_code']));
break;
case 6:
$result[$key]['completed'] = true;
break;
default:
break;
}
} while (false);
}
}
... ... @@ -155,16 +89,6 @@ class OrderModel
}
/**
* 获得支付链接
*/
public static function payment($gender, $yh_channel)
{
$code = self::CODE_PAYMENT;
$data = OrderData::paymentData($gender, $yh_channel, $code);
return $data;
}
/**
* 查看物流
*
* @param int $orderCode 订单编号
... ... @@ -196,6 +120,43 @@ class OrderModel
}
/**
* 获取订单详情信息
*
* @param string $orderCode 订单号
* @param int $uid 用户ID
* @param string $sessionKey 用户的会话
* @return array
*/
public static function orderDetail($orderCode, $uid, $sessionKey)
{
$result = array();
if (is_numeric($orderCode) && is_numeric($uid) && is_string($sessionKey)) {
$orderDetail = OrderData::viewOrderData($orderCode, $uid, $sessionKey);
if (isset($orderDetail['data']['order_code'])) {
$count = 0;
$result = self::getOrderStatus($orderDetail['data'], true); // 订单状态
$result['name'] = $orderDetail['data']['user_name'];
$result['phoneNum'] = $orderDetail['data']['mobile'];
$result['address'] = $orderDetail['data']['area'] . $orderDetail['data']['address'];
$result['orderStatus'] = $orderDetail['data']['status_str'];
$result['orderNum'] = $orderDetail['data']['order_code'];
$result['orderTime'] = date('Y-m-d H:i:s', $orderDetail['data']['create_time']);
$result['goods'] = Helpers::formatOrderGoods($orderDetail['data']['order_goods'], $count, true);
$result['sumPrice'] = $orderDetail['data']['goods_total_amount']; // 商品总金额
$result['salePrice'] = $orderDetail['data']['promotion_amount']; // 活动金额
$result['freight'] = $orderDetail['data']['shipping_cost']; // 运费
$result['coupon'] = $orderDetail['data']['coupons_amount']; // 优惠券
$result['yohoCoin'] = $orderDetail['data']['yoho_coin_num']; // YOHO币
$result['price'] = $orderDetail['data']['amount']; // 实付金额
}
}
return $result;
}
/**
* 根据type值设置nav属性
*/
public static function getNavs($type)
... ... @@ -218,4 +179,89 @@ class OrderModel
return $nav;
}
/**
* 获取订单状态
*
* @param array $order 订单
* @param bool $showLogistics 控制是否显示物流信息
* @return array
*/
private static function getOrderStatus($order, $showLogistics = false)
{
$result = array();
//根据订单status判断订单处于什么状态。
do {
//订单取消状态 = Y 时,跳出判断订单状态循环,并设置订单状态为已取消。
if ($order['is_cancel'] === 'Y') {
$result['canceled'] = true;
break;
}
// 先判断订单付款方式,根据不同的付款方式计算订单状态。(注:货到付款没有待付款状态)
// 支付方式为非货到付款时,计算订单状态。
if ($order['payment_type'] != 2) {
switch ($order['status']) {
case 0: // 待付款
$result['unpaid'] = true;
$result['payUrl'] = Helpers::url('/home/pay', array('order_code' => $order['order_code']));
break;
//未发货&未收货 状态,统一合并到待收货状态。
case 1:
case 2:
case 3:
//已付款状态不给查看物流URL
$result['unreceived'] = true;
break;
case 4:
case 5:
//已发货状态,给查看物流URL
$result['unreceived'] = true;
$result['logisticsUrl'] = Helpers::url('/home/logistic', array('order_code' => $order['order_code']));
if ($showLogistics) {
$result['logisticsCompany'] = $order['caption'];
$result['logisticsNum'] = $order['express_number'];
}
break;
case 6:
$result['completed'] = true;
break;
default:
break;
}
break;
}
// 订单为货到付款订单时,计算订单状态。(货到付款没有待付款状态)
switch ($order['status']) {
case 0: // 备货中
$result['unpaid'] = true;
break;
case 1:
case 2:
case 3:
//备货中、已付款状态不给查看物流链接
$result['unreceived'] = true;
break;
case 4:
case 5:
//待收货状态,给查看物流url
$result['unreceived'] = true;
$result['logisticsUrl'] = Helpers::url('/home/logistic', array('order_code' => $order['order_code']));
if ($showLogistics) {
$result['logisticsCompany'] = isset($order['caption']) ? $order['caption'] : '';
$result['logisticsNum'] = isset($order['express_number']) ? $order['express_number'] : '';
}
break;
case 6:
$result['completed'] = true;
break;
default:
break;
}
} while (false);
return $result;
}
}
... ...
... ... @@ -17,213 +17,216 @@ use Plugin\Images;
class CartModel
{
/**
* @param integer $uid 用户ID
* @return array|mixed 处理之后的购物车数据
*/
public static function getCartData($uid)
{
$result = array(
'cartNav' => true,
'showLoginInfo' => true
);
// 调用接口获取购物车的数据
$cartData = CartData::cartData($uid);
// 处理普通购物车和预售购物车的数据
if (isset($cartData['data']) && !empty($cartData['data'])) {
$cart = $cartData['data'];
/* 普通购物车 */
if(isset($cart['ordinary_cart_data'])) {
$result['commonGoodsCount'] = count($cart['ordinary_cart_data']['goods_list']);
$result['commonCart'] = self::procCartData($cart['ordinary_cart_data']);
}
/* 预售购物车 */
if(isset($cart['advance_cart_data'])) {
$result['presellGoodsCount'] = count($cart['advance_cart_data']['goods_list']);
$result['preSellCart'] = self::procCartData($cart['advance_cart_data']);
}
}
return $result;
}
/**
* 移出购物车
*
* @param int $uid 用户ID
* @param string $sku 商品sku列表
* @return array 接口返回的数据
*/
public static function removeFromCart($uid, $sku)
{
$result = array('code' => 400, 'message' => '出错啦~');
// 处理sku
$sku_list = json_encode(array($sku => 1));
$remove = CartData::removeFromCart($uid, $sku_list);
if ($remove && isset($remove['code'])) {
$result['code'] = $remove['code'];
$result['message'] = $remove['message'];
}
return $result;
}
/**
* 移入收藏夹
*
* @param int $uid 用户ID
* @param string $sku 商品sku列表
* @return array 接口返回的数据
*/
public static function addToFav($uid, $sku)
{
$result = array('code' => 400, 'message' => '出错啦~');
// 处理sku
$sku_list = json_encode(array($sku => 1));
$add = CartData::addToFav($uid, $sku_list);
if ($add && isset($add['code'])) {
$result['code'] = $add['code'];
$result['message'] = $add['message'];
}
return $result;
}
/**
* 处理购物车商品数据
*
* @param int $uid 用户ID
* @param int $skn 商品skn
* @param int $num 购买数目
* @return array 接口返回的数据
*/
public static function cartProductData($uid, $skn, $num)
{
$result = array('code' => 400, 'message' => '出错啦~');
$product = CartData::cartProductData($uid, $skn);
if (isset($product['code']) && $product['code'] === 200) {
$result['code'] = 200;
$data = array();
$productData = $product['data'];
// 品牌信息
if (isset($productData['brand_info']) && !empty($productData['brand_info'])) {
$data['thumb'] = Helpers::getImageUrl($productData['brand_info']['brand_ico'], 120, 120);
}
$data['name'] = $productData['product_name'];
$data['price'] = $productData['market_price'];
$data['salePrice'] = $productData['sales_price'];
$data['storage'] = $productData['storage_sum'];
$data['num'] = $num;
// 商品选择
if (isset($productData['goods_list'])) {
$goodsList = $productData['goods_list'];
$colors = array();
$oneColor = array();
$sizes = array();
$oneSize = array();
foreach ($goodsList as $val) {
// 颜色
$oneColor = array();
$oneColor['id'] = $val['color_id'];
$oneColor['name'] = $val['color_name'];
// 尺码
foreach ($val['size_list'] as $one) {
$oneSize = array();
$oneSize['id'] = $one['size_id'];
$oneSize['name'] = $one['size_name'];
}
$sizes[] = $oneSize;
$oneColor['sizes'] = $sizes;
$colors[] = $oneColor;
}
$data['colors'] = $colors;
}
$result['data'] = $data;
}
return $result;
}
/**
* 修改购物车商品数据
*
* @param int $uid 用户ID
* @param string $param 要更改的数据
* @return array 接口返回的数据
*/
public static function modifyCartProduct($uid, $param)
{
$result = array('code' => 400, 'message' => '出错啦~');
// 处理要更改的数据
$swapData = json_encode(array($param));
$modify = CartData::addToFav($uid, $swapData);
if ($modify && isset($modify['code'])) {
$result['code'] = $modify['code'];
$result['message'] = $modify['message'];
}
return $result;
}
/**
* 处理不同类型的购物车数据
*
* @param array $data 不同类型购物车数据
* @return array $result 处理之后的不同类型购物车数据
*/
private static function procCartData($data)
{
$result = array();
$oneGoods = array();
// 购买的商品列表
foreach ($data['goods_list'] as $value) {
$oneGoods['id'] = $value['product_sku'];
$oneGoods['skn'] = $value['product_skn'];
$oneGoods['name'] = $value['product_name'];
$oneGoods['thumb'] = Images::getImageUrl($value['goods_images'], 120, 120);
$oneGoods['color'] = $value['color_name'];
$oneGoods['size'] = $value['size_name'];
$oneGoods['appearDate'] = '12月'; // 目前app接口没有返回该数据
$oneGoods['price'] = $value['real_price'];
$oneGoods['count'] = $value['buy_number'];
$oneGoods['lowStocks'] = true;
$result['goods'][] = $oneGoods;
}
// 赠品
count($data['gift_list']) && $result['freebieOrAdvanceBuy'] = true;
$result['freebie'] = $data['gift_list'];
// 加价购
$result['advanceBuy'] = $data['price_gift'];
// 结算数据
$result['price'] = $data['shopping_cart_data']['order_amount'];
$result['activityPrice'] = $data['shopping_cart_data']['discount_amount'];
$result['count'] = $data['shopping_cart_data']['goods_count'];
$result['sumPrice'] = $data['shopping_cart_data']['order_amount'];
return $result;
}
/**
* 获取购物车数据
*
* @param integer $uid 用户ID
* @return array|mixed 处理之后的购物车数据
*/
public static function getCartData($uid)
{
$result = array();
// 提示登录
if (!$uid) {
$result['showLoginInfo'] = true;
}
// 普通购物车和预售购物车的数据总数
$result['cartNav']['commonGoodsCount'] = '0';
$result['cartNav']['presellGoodsCount'] = '0';
// 调用接口获取购物车的数据
$cartData = CartData::cartData($uid);
// 处理普通购物车和预售购物车的数据
/* 普通购物车 */
if (!empty($cartData['data']['ordinary_cart_data']['goods_list'])) {
$result['cartNav']['commonGoodsCount'] = count($cartData['data']['ordinary_cart_data']['goods_list']);
$result['commonCart'] = self::procCartData($cartData['data']['ordinary_cart_data']);
}
/* 预售购物车 */
if (!empty($cartData['data']['advance_cart_data']['goods_list'])) {
$result['cartNav']['presellGoodsCount'] = count($cartData['data']['advance_cart_data']['goods_list']);
$result['preSellCart'] = self::procCartData($cartData['data']['advance_cart_data']);
}
return $result;
}
/**
* 移出购物车
*
* @param int $uid 用户ID
* @param string $sku 商品sku列表
* @return array 接口返回的数据
*/
public static function removeFromCart($uid, $sku)
{
$result = array('code' => 400, 'message' => '出错啦~');
// 处理sku
$sku_list = json_encode(array($sku => 1));
$remove = CartData::removeFromCart($uid, $sku_list);
if ($remove && isset($remove['code'])) {
$result['code'] = $remove['code'];
$result['message'] = $remove['message'];
}
return $result;
}
/**
* 移入收藏夹
*
* @param int $uid 用户ID
* @param string $sku 商品sku列表
* @return array 接口返回的数据
*/
public static function addToFav($uid, $sku)
{
$result = array('code' => 400, 'message' => '出错啦~');
// 处理sku
$sku_list = json_encode(array($sku => 1));
$add = CartData::addToFav($uid, $sku_list);
if ($add && isset($add['code'])) {
$result['code'] = $add['code'];
$result['message'] = $add['message'];
}
return $result;
}
/**
* 处理购物车商品数据
*
* @param int $uid 用户ID
* @param int $skn 商品skn
* @param int $num 购买数目
* @return array 接口返回的数据
*/
public static function cartProductData($uid, $skn, $num)
{
$result = array('code' => 400, 'message' => '出错啦~');
$product = CartData::cartProductData($uid, $skn);
if (isset($product['code']) && $product['code'] === 200) {
$result['code'] = 200;
$data = array();
$productData = $product['data'];
// 品牌信息
if (isset($productData['brand_info']) && !empty($productData['brand_info'])) {
$data['thumb'] = Helpers::getImageUrl($productData['brand_info']['brand_ico'], 120, 120);
}
$data['name'] = $productData['product_name'];
$data['price'] = $productData['market_price'];
$data['salePrice'] = $productData['sales_price'];
$data['storage'] = $productData['storage_sum'];
$data['num'] = $num;
// 商品选择
if (isset($productData['goods_list'])) {
$goodsList = $productData['goods_list'];
$colors = array();
$oneColor = array();
$sizes = array();
$oneSize = array();
foreach ($goodsList as $val) {
// 颜色
$oneColor = array();
$oneColor['id'] = $val['color_id'];
$oneColor['name'] = $val['color_name'];
// 尺码
foreach ($val['size_list'] as $one) {
$oneSize = array();
$oneSize['id'] = $one['size_id'];
$oneSize['name'] = $one['size_name'];
}
$sizes[] = $oneSize;
$oneColor['sizes'] = $sizes;
$colors[] = $oneColor;
}
$data['colors'] = $colors;
}
$result['data'] = $data;
}
return $result;
}
/**
* 修改购物车商品数据
*
* @param int $uid 用户ID
* @param string $param 要更改的数据
* @return array 接口返回的数据
*/
public static function modifyCartProduct($uid, $param)
{
$result = array('code' => 400, 'message' => '出错啦~');
// 处理要更改的数据
$swapData = json_encode(array($param));
$modify = CartData::addToFav($uid, $swapData);
if ($modify && isset($modify['code'])) {
$result['code'] = $modify['code'];
$result['message'] = $modify['message'];
}
return $result;
}
/**
* 处理不同类型的购物车数据
*
* @param array $data 不同类型购物车数据
* @return array $result 处理之后的不同类型购物车数据
*/
private static function procCartData($data)
{
$result = array();
$oneGoods = array();
// 购买的商品列表
foreach ($data['goods_list'] as $value) {
$oneGoods['id'] = $value['product_sku'];
$oneGoods['skn'] = $value['product_skn'];
$oneGoods['name'] = $value['product_name'];
$oneGoods['thumb'] = Images::getImageUrl($value['goods_images'], 120, 120);
$oneGoods['color'] = $value['color_name'];
$oneGoods['size'] = $value['size_name'];
$oneGoods['appearDate'] = '12月'; // 目前app接口没有返回该数据
$oneGoods['price'] = $value['real_price'];
$oneGoods['count'] = $value['buy_number'];
$oneGoods['lowStocks'] = true;
$result['goods'][] = $oneGoods;
}
// 赠品
count($data['gift_list']) && $result['freebieOrAdvanceBuy'] = true;
$result['freebie'] = $data['gift_list'];
// 加价购
$result['advanceBuy'] = $data['price_gift'];
// 结算数据
$result['price'] = $data['shopping_cart_data']['order_amount'];
$result['activityPrice'] = $data['shopping_cart_data']['discount_amount'];
$result['count'] = $data['shopping_cart_data']['goods_count'];
$result['sumPrice'] = $data['shopping_cart_data']['order_amount'];
return $result;
}
}
... ...
s[common]
[common]
;;默认项目
application.directory = APPLICATION_PATH "/application"
;;website library
... ...