Authored by hf

code review by fei.hong: do merge yangyang and huanbao codes

... ... @@ -371,7 +371,6 @@ class CartData
}
$param['payment_id'] = $paymentId;
$param['payment_type'] = $paymentType;
$param['remark'] = $remark;
if (!empty($couponCode)) {
$param['coupon_code'] = $couponCode;
}
... ... @@ -384,9 +383,10 @@ class CartData
if (!empty($isPrintPrice)) {
$param['is_print_price'] = 'Y';
}
$param['remark'] = $remark;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param, false, false, 10, $userAgent);
return Yohobuy::post(Yohobuy::API_URL, $param, false, false, 10, $userAgent);
}
/**
... ...
... ... @@ -501,11 +501,15 @@ class HelperSearch
foreach ($v['sub'] as $sortKey => $sort) {
$selfMisort[$sortKey]['name'] = $sort['sort_name'];
$selfMisort[$sortKey]['checked'] = isset(self::$params['sort']) && self::$params['sort'] == $sort['sort_id'] ? true : false;
$selfMisort[$sortKey]['href'] = self::buildUrl(array(
'msort' => $val['sort_id'],
'misort' => $v['sort_id'],
'sort' => $sort['sort_id'],
));
$selfMisort[$sortKey]['href'] = self::buildUrl(array_merge(self::$params,array('sort' => $sort['sort_id'])));
if (isset(self::$params['sort']) && self::$params['sort'] == $sort['sort_id']) {
$sortParam = self::$params;
unset($sortParam['sort']);
self::$selected['sort'] = array(
'name' => $sort['sort_name'],
'href' => self::buildUrl($sortParam)
);
}
}
}
self::$misort = $selfMisort;
... ... @@ -899,14 +903,13 @@ class HelperSearch
);
}
//设置已选中,风格筛选条件设为空
if (isset(self::$params['style']) && !empty(self::$params['style'])) {
if (isset(self::$params['style']) && !empty(self::$params['style']) && !empty($styleName)) {
self::$selected['style'] = array(
'name' => implode('、', $styleName),
'href' => self::buildUrl($params)
);
return array();
}
if ($result) {
$data[0] = array(
'attr' => 'style',
... ... @@ -924,6 +927,9 @@ class HelperSearch
*/
public static function seniorChose($filter)
{
if (self::$total == 0) {
return array();
}
$style = self::style($filter);
$other = self::standard($filter);
$result = array_merge($style, $other);
... ... @@ -1250,6 +1256,7 @@ class HelperSearch
*/
public static function recentShelve($list = array())
{
$gender = array();
if (empty($list)) {
return array();
}
... ... @@ -1264,7 +1271,9 @@ class HelperSearch
self::$misortParam = array(
'misort' => isset(self::$params['misort']) ? self::$params['misort'] : ''
);
if (isset(self::$params['gender'])) {
$gender['gender'] = self::$params['gender'];
}
foreach ($list as $k => $v) {
$star_time = strtotime($k);
$end_time = $star_time + 60 * 60 * 24;
... ... @@ -1274,7 +1283,7 @@ class HelperSearch
$data[$i]['active'] = true;
self::$selectedShelveTime = date('m月d日', strtotime($k));
}
$data[$i]['href'] = self::buildUrl(array_merge($query, self::$msortParam, self::$misortParam));
$data[$i]['href'] = self::buildUrl(array_merge($query, self::$msortParam, self::$misortParam, $gender));
$data[$i]['name'] = date('m月d日', strtotime($k));
$i++;
}
... ... @@ -1404,25 +1413,34 @@ class HelperSearch
//组织静态资源数据格式
public static function getNodeContent($code)
{
$result = array();
$nodeContent = BrandData::getByNodeContent($code); //TODO异步
if (isset($nodeContent['code']) && $nodeContent['code'] === 200) {
$result = array();
//print_r($nodeContent['data']);
$arr = explode('<br />', $nodeContent['data']);
$arr = array_values($arr);
$string = $nodeContent['data'];
$hrefPatten = "/<a href=[\'\"]?([^\'\" ]+).*?>/";
preg_match_all($hrefPatten, $string, $href);
$pattern = "/[img|IMG].*?src=['|\"](.*?(?:[.gif|.jpg]))['|\"].*?[\/]?>/";
preg_match_all($pattern, $string, $img);
foreach ($img[1] as $key => $vo) {
if (strrchr($vo, '.swf') == '.swf') {
$result[$key]['isVedio'] = true;
$result[$key]['src'] = $vo;
} else {
$result[$key]['href'] = isset($href[1][$key]) ? str_replace('&amp;', '&', $href[1][$key]) : '';
$result[$key]['src'] = $vo;
foreach($arr as $key => $value){
preg_match($hrefPatten, $value, $href);
preg_match($pattern, $value, $img);
if (isset($href[1])) {
$result[$key]['href'] = str_replace('&amp;', '&', $href[1]);
}
if (isset($img[1])) {
if (strrchr($img[1], '.swf') == '.swf') {
$result[$key]['isVedio'] = true;
$result[$key]['src'] = $img[1];
}else{
$result[$key]['src'] = $img[1];
}
}
}
return $result;
}
}
... ... @@ -1855,36 +1873,50 @@ class HelperSearch
$selectedShelveTime = !empty(self::$selectedShelveTime) ? self::$selectedShelveTime : '';//当前新品到着时间
//新品到着页seo
if ($options['controller'] == 'List' && $options['action'] == 'new') {
$new = $channelCnName . $selectedShelveTime;
return array(
'title' => $channelCnName . $selectedShelveTime . '新品上架-YOHO!有货 100%正品保证',
'keywords' => $channelCnName . $selectedShelveTime . '新品上架',
'description' => $channelCnName . $selectedShelveTime . '新品上架,正品网购,官方授权!YOHO! 有货中国最大的潮流商品购物网站。100%品牌正品保证,支持货到付款。'
'title' => (!empty($new) ? $new : '') . '新品上架-YOHO!有货 100%正品保证',
'keywords' => (!empty($new) ? $new : '') . '新品上架',
'description' => (!empty($new) ? $new : '') . '新品上架,正品网购,官方授权!YOHO! 有货中国最大的潮流商品购物网站。100%品牌正品保证,支持货到付款。'
);
}
//sale折扣页seo
if ($options['controller'] == 'List' && $options['action'] == 'sale') {
$BPP = $selectedBrand . $selectedP_d . $selectedPrice;
$C = $channelCnName;
$BP = $selectedBrand . $selectedP_d;
return array(
'title' => $selectedBrand . $selectedP_d . $selectedPrice . '|' . $channelCnName . '全部折扣' . '|YOHO!有货 100%正品保证',
'keywords' => $selectedBrand . $selectedP_d . ',' . $selectedBrand . $selectedP_d . $selectedPrice . ',' . $channelCnName . '全部折扣' . $selectedBrand . $selectedP_d,
'description' => $selectedBrand . $selectedP_d . $selectedPrice. '正品网购。' . $channelCnName . '全部折扣,' . $selectedBrand . $selectedP_d . '官方授权!YOHO! 有货中国最大的潮流商品购物网站。100%品牌正品保证,支持货到付款。'
'title' => (!empty($BPP)?$BPP.'|': '') . (!empty($C) ? $C : '') . '全部折扣' . '|YOHO!有货 100%正品保证',
'keywords' => (!empty($BP)?$BP.',':'') . (!empty($BPP)?$BPP.',':'') . (!empty($C)?$C:'') . '全部折扣' . (!empty($BP)?$BP:''),
'description' => (!empty($BPP)?$BPP:''). '正品网购。' . $channelCnName . '全部折扣,' . (!empty($BP)?$BP:'') . '官方授权!YOHO! 有货中国最大的潮流商品购物网站。100%品牌正品保证,支持货到付款。'
);
}
//品牌页seo
if ($options['controller'] == 'Index' && $options['action'] == 'brand') {
$selectedBrandCn = isset($options['brandNameCn']) ? $options['brandNameCn'] : '';//当前选中的品牌中文名(只有品牌页有此参数)
$selectedBrand = isset($options['brandNameEn']) ? $options['brandNameEn'] : '';//当前选中的品牌中文名(只有品牌页有此参数)
$B = $selectedBrand;
$BB = $selectedBrand . ' ' . $selectedBrandCn;
$C = $channelCnName;
$BC = $selectedBrand . $channelCnName;
$BBC = $selectedBrand . $selectedBrandCn . $channelCnName;
return array(
'title' => $selectedBrand . '|' . $selectedBrand . ' ' . $selectedBrandCn . '|' . $channelCnName . '品牌' . '|YOHO!有货 100%正品保证',
'keywords' => $selectedBrand . ',' . $selectedBrand . ' ' . $selectedBrandCn . ',' . $selectedBrand . $channelCnName . '品牌',
'description' => $selectedBrand . '正品网购。' . $selectedBrand . $selectedBrandCn . $channelCnName . '品牌' . '官方授权!YOHO! 有货中国最大的潮流商品购物网站。100%品牌正品保证,支持货到付款。'
'title' => (!empty($B)?$B.'|':'') . (!empty($selectedBrand)&&!empty($selectedBrandCn)?$BB.'|':''). $channelCnName . '品牌' . '|YOHO!有货 100%正品保证',
'keywords' => (!empty($B)?$B.',':'') . (!empty($selectedBrand)&&!empty($selectedBrandCn)?$BB.',':'') . (!empty($BC)?$BC:'') . '品牌',
'description' => $selectedBrand . '正品网购。' . (!empty($BBC)?$BBC:'') . '品牌' . '官方授权!YOHO! 有货中国最大的潮流商品购物网站。100%品牌正品保证,支持货到付款。'
);
}
//list页seo
if ($options['controller'] == 'List' && $options['action'] == 'index') {
$BMPCM = $selectedBrand . $selectedMisort . $selectedPrice . $channelCnName . $selectedMsort;
$BM = $selectedBrand . $selectedMisort;
$BMP = $selectedBrand . $selectedMisort . $selectedPrice;
$CMBM = $channelCnName . $selectedMsort . $selectedBrand . $selectedMisort;
$CM = $channelCnName . $selectedMsort;
return array(
'title' => $selectedBrand . $selectedMisort . $selectedPrice . $channelCnName . $selectedMsort . '|YOHO!有货 100%正品保证',
'keywords' => $selectedBrand . $selectedMisort . ',' . $selectedBrand . $selectedMisort . $selectedPrice . ',' . $channelCnName . $selectedMsort . $selectedBrand . $selectedMisort,
'description' => $selectedBrand . $selectedMisort . $selectedPrice . '正品网购。' . $channelCnName . $selectedMsort . ',' . $selectedBrand . $selectedMisort . '官方授权!YOHO! 有货中国最大的潮流商品购物网站。100%品牌正品保证,支持货到付款。'
'title' => (!empty($BMPCM)?$BMPCM.'|':''). 'YOHO!有货 100%正品保证',
'keywords' => (!empty($BM)?$BM.',':'') . (!empty($BMP)?$BMP.',':''). $CMBM,
'description' => $BMP . '正品网购。' . (!empty($CM)?$CM.',':''). $BM . '官方授权!YOHO! 有货中国最大的潮流商品购物网站。100%品牌正品保证,支持货到付款。'
);
}
return array();
... ...
... ... @@ -151,6 +151,18 @@
<td>
<a class="thumb-link" href="{{url}}">
<img class="thumb" src="{{img}}">
{{#if freebie}}
<span class="freebie-tag">赠品</span>
{{/if}}
{{#if advanceBuy}}
<span class="advance-buy-tag">加价购</span>
{{/if}}
{{#if virtualGood}}
<span class="virtual-good-tag">虚拟商品</span>
{{/if}}
{{#if preSallGood}}
<span class="presall-tag">预售</span>
{{/if}}
</a>
<p class="name-color-size">
<a class="name" href="{{url}}">{{name}}</a>
... ... @@ -180,7 +192,7 @@
{{#if freight}}
<p>运费:{{freight}}元</p>
{{/if}}
<p>YOHO币抵扣:{{yohoCoin}}元</p>
<p> {{yohoCoin}}</p>
{{#if coupons}}
<p>抵用券抵扣:{{coupons}}元</p>
{{/if}}
... ...
... ... @@ -125,18 +125,30 @@
<div id="foot-mobile">
<ul class="mobile clearfix">
<li>
<a href="http://app.yohoshow.com/" target="_blank">
<img class="lazy" data-original="http://img13.static.yhbimg.com/adpic/2014/07/21/15/02d5e1cbc15ab59856f4a758fa860462ed.jpg">
<a href="http://www.yohomars.com/" target="_blank">
{{#if devEnv}}
<img class="lazy" data-original="http://webstatic.dev.yohobuy.com/img/index/mars.png">
{{^}}
<img class="lazy" data-original="http://cdn.yoho.cn/yohobuy/assets/img/index/mars.png">
{{/if}}
</a>
</li>
<li>
<a href="http://www.yohoboys.com/" target="_blank">
<img class="lazy" data-original="http://img13.static.yhbimg.com/adpic/2014/07/21/15/0210a3490eae2aad6ef8bf3b8133a49ca9.jpg">
<a href="http://app.yohoshow.com/" target="_blank">
{{#if devEnv}}
<img class="lazy" data-original="http://webstatic.dev.yohobuy.com/img/index/show.png">
{{^}}
<img class="lazy" data-original="http://cdn.yoho.cn/yohobuy/assets/img/index/show.png">
{{/if}}
</a>
</li>
<li>
<a href="http://www.yohogirls.com/" target="_blank">
<img class="lazy" data-original="http://img11.static.yhbimg.com/adpic/2014/07/21/15/018be2a193424658b5201240ef8c7729e6.jpg">
<a href="http://www.yoho.cn/product#yoho" target="_blank">
{{#if devEnv}}
<img class="lazy" data-original="http://webstatic.dev.yohobuy.com/img/index/yoho.png">
{{^}}
<img class="lazy" data-original="http://cdn.yoho.cn/yohobuy/assets/img/index/yoho.png">
{{/if}}
</a>
</li>
</ul>
... ...
... ... @@ -35,8 +35,8 @@ class ErrorController extends WebAction
// @todo debug
// echo $exception->getMessage();
// 生成HTML (error.html)
//$this->_view->html('error_'.$channel);
// 生成HTML (error.html)
$this->_view->html('error_'.$channel);
// 渲染模板
$this->_view->display('index', array('errorPage' => true,'newProductLink'=> Helpers::url('/product/new')));
}
... ...
... ... @@ -186,20 +186,47 @@ class OrderModel
$detail['goods'][$gok]['coin'] = $gov['yoho_give_coin'];
$detail['goods'][$gok]['num'] = $gov['buy_number'];
$detail['goods'][$gok]['sum'] = $gov['goods_amount'];
$detail['goods'][$gok]['sku'] = $gov['product_sku'];
$goodsTagName = self::getGoodsTag($orderDetail['attribute'], $gov['goods_type']);
if ($goodsTagName) {
$detail['goods'][$gok][$goodsTagName] = TRUE;
}
}
}
$detail['sumPrice'] = $orderDetail['goods_total_amount'];
$detail['freight'] = $orderDetail['shipping_cost'];
$detail['yohoCoin'] = $orderDetail['yoho_coin_num'];
if (!strstr($orderDetail['shipping_cost'], '0.00')) {
$detail['freight'] = $orderDetail['shipping_cost'];
}
if ($orderDetail['attribute'] == 3) {
$detail['yohoCoin'] = 'YOHO币使用:' . floatval(substr($orderDetail['yoho_coin_num'], 3)) * 100;
$detail['yohoCoin'].='个';
}
else {
$detail['yohoCoin'] = 'YOHO币抵扣:' . $orderDetail['yoho_coin_num'] . '元';
}
$detail['yohoCoinUrl'] = Helpers::url('/help', array('category_id' => 87)); //什么是yoho币介绍
$detail['coupons'] = $orderDetail['coupons_amount'];
if (!strstr($orderDetail['coupons_amount'], '0.00')) {
$detail['coupons'] = $orderDetail['coupons_amount'];
}
$detail['payment'] = $orderDetail['amount'];
$detail['remark'] = '';//$orderDetail['remark']
$detail['operation'] = self::getOrderDetailOp($orderDetail['order_code'], $orderDetail['payment'], $orderDetail['status'], $orderDetail['is_cancel'], $orderDetail['payment_status'], $orderDetail['payment_type'], 1, $orderDetail['attribute']); //,$orderDetail['order_type_value']
$detail['remark'] = ''; //$orderDetail['remark']
$detail['operation'] = self::getOrderDetailOp($orderDetail['order_code'], $orderDetail['payment'], $orderDetail['status'], $orderDetail['is_cancel'], $orderDetail['payment_status'], $orderDetail['payment_type'], 1, $orderDetail['attribute'], 'N'); //,$orderDetail['order_type_value']
}
return $detail;
}
/**
* 获取虚拟商品二维码图片
* @param type $uid
* @param type $sku
*/
public static function getTicketImgs($uid,$sku)
{
$data = OrderData::getYohoodTicket($uid, $sku);
// var_dump($data);
// die();
}
/**
* 订单详情页物流
*
... ... @@ -240,7 +267,7 @@ class OrderModel
/**
* 订单详情页操作步骤
*/
protected static function getOrderDetailOp($orderCode, $payment, $status, $isCancel, $paymentStatus, $paymentType, $orderType, $attribute)
protected static function getOrderDetailOp($orderCode, $payment, $status, $isCancel, $paymentStatus, $paymentType, $orderType, $attribute, $refundStatus)
{
$operation = array();
//立刻付款
... ... @@ -256,6 +283,9 @@ class OrderModel
$operation +=array('paid' => TRUE);
}
//确认收货
if ($status >= 4 && $status < 6 && $refundStatus == 0 && $attribute != 3 && $isCancel == 'N') {
$operation[] += array('shipped' => TRUE);
}
//订单已取消
if ($isCancel == 'Y') {
$operation +=array('cancel' => TRUE);
... ...
... ... @@ -122,7 +122,7 @@ class ItemModel
$goodsInfo['fashionTopGoods'] = array(
'getLimitedCode' => $fashTopGoods['getLimitedCode'],//限购码状态
'hasLimitedCode' => $fashTopGoods['hasLimitedCode'],//是否已经获取限购码
'LimitedCodeSoldOut'=> $fashTopGoods['limitedCodeSoldOut'],//限购码是否已经抢光
'limitedCodeSoldOut'=> $fashTopGoods['limitedCodeSoldOut'],//限购码是否已经抢光
'getLimitedCodeDis' => $fashTopGoods['getLimitedCodeDis'],//限购码是否失效
);
if($fashTopGoods['soldOut']) {
... ... @@ -1124,7 +1124,6 @@ class ItemModel
$result['dis'] = true;
} else {
$result['openSoon'] = true;
$result['limitedCodeSoldOut'] = true;
$result['hasLimitedCode'] = false;
}
break;
... ... @@ -1132,6 +1131,7 @@ class ItemModel
$result['buyNow'] = true;
$result['dis'] = true;
$result['limitedCodeSoldOut'] = true;
$result['getLimitedCode'] = false;
$result['hasLimitedCode'] = false;
break;
case 3: // 开售后,商品已经售罄
... ... @@ -1142,7 +1142,6 @@ class ItemModel
$result['buyNow'] = true;
$result['dis'] = false;
$result['hasLimitedCode'] = true;
$result['limitedCodeSoldOut'] = true;
if(!empty($uid)) {//限购码失效
$result['getLimitedCodeDis'] = true;
}
... ... @@ -1151,12 +1150,12 @@ class ItemModel
$result['openSoon'] = true;
$result['hasLimitedCode'] = true;
$result['limitedCodeSoldOut'] = true;
$result['getLimitedCode'] = false;
break;
case 6: // 开售前,即将开售(用户已领取限购码)
$result['openSoon'] = true;
$result['hasLimitedCode'] = true;
$result['limitedCodeSoldOut'] = true;
if(!empty($uid)) {//限购码失效
$result['getLimitedCodeDis'] = true;
}
... ...
... ... @@ -34,21 +34,7 @@ class SaleModel
//获取$condition和$option 筛选条件和排序条件
$searchCondition = SearchModel::searchCondition($customCondition, $customOptions);
if (USE_CACHE) {
$key = WebCacheConfig::KEY_WEB_PRODUCT_SALE_INDEX;
if (!empty($searchCondition['userInput'])) {
$key .= http_build_query($searchCondition['userInput'], null, '&');
}
$channel = HomeModel::getSwitchChannel();
//key加上性别参数
$key .= $channel;
// 先尝试获取一级缓存(master), 有数据则直接返回.
$result = Cache::get($key, 'master');
if (!empty($result)) {
return $result;
}
}
// 组合搜索商品url
$urlList['product'] = SearchData::getProductUrl($searchCondition['condition']);
... ... @@ -89,16 +75,6 @@ class SaleModel
$result['leftContent'][]['picLink']['list'] = $nodeContent;
}
if (USE_CACHE) {
// 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
if (empty($result)) {
$result = Cache::get($key, 'slave');
}
// 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
elseif(isset($data['product']) && !empty($data['product']['product_list']) && isset($data['sort']) && !empty($data['sort'])) {
Cache::set($key, $result, 1800); // 缓存30分钟
}
}
return $result;
}
... ...
<?php
use Action\WebAction;
use WebPlugin\Helpers;
use Shopping\CartModel;
use Product\ItemModel;
/**
* 购物车相关的控制器
*
* @name IndexController
* @package Cart
* @copyright yoho.inc
* @version 1.0 (2016-2-17 15:43:19)
* @author fei.hong <fei.hong@yoho.cn>
*/
class IndexController extends WebAction
{
/**
* 通过当前用户审判是否跳到登录
*
* @param boolean $useSession (true:从服务端session中检查, false:从客户端cookie中检查)
* @pram string $refer 指定的来源地址
* @return void
*/
protected function auditJumpLogin($useSession = true, $refer = '')
{
$uid = $this->getUid($useSession);
if (!$uid) {
if (empty($refer)) {
$refer = $this->server('HTTP_REFERER', SITE_MAIN);
}
$this->go(Helpers::url('/signin.html', array('refer' => $refer)));
}
}
/**
* 我的购物车
*/
public function indexAction()
{
$uid = $this->getUid(true);
$shoppingKey = Helpers::getShoppingKeyByCookie();
// 显示一次并清除已删除的COOKIE记录
$cartDelList = $this->getCookie('cart-del-list');
if (!empty($cartDelList)) {
$this->setCookie('cart-del-list', '');
}
$this->setTitle('购物车', true, ' | ');
$this->setSimpleHeader();
$this->_view->display('cart', array(
'cartEnsurePage' => true,
'cartEnsure' => CartModel::myCartData($uid, $shoppingKey, $cartDelList),
));
}
/**
* 购物车商品选择与取消
*
* @param string skuList 商品sku列表,json格式,如{"744403":1,"777777":3}
* @return json
*/
public function selectAction()
{
$result = array();
if ($this->isAjax()) {
$productId = $this->post('skuList', 0);
$uid = $this->getUid(true);
$shoppingKey = Helpers::getShoppingKeyByCookie();
$result = CartModel::selectGoods($uid, $productId, $shoppingKey);
}
$this->echoJson($result);
}
/**
* 修改购物车商品数量
*
* @param int sku
* @param int increaseNum
* @param int decreaseNum
* @return json
*/
public function modifyAction()
{
$result = array();
if ($this->isAjax()) {
$shoppingKey = Helpers::getShoppingKeyByCookie();
$uid = $this->getUid(true);
$sku = $this->post('sku', 0);
$increaseNum = $this->post('increaseNum', null);
$decreaseNum = $this->post('decreaseNum', null);
$result = CartModel::modifyProductNum($uid, $sku, $increaseNum, $decreaseNum, $shoppingKey);
if (!empty($result['code']) && $result['code'] == 200) {
$this->setShoppingCookie($uid);
}
}
$this->echoJson($result);
}
/**
* 移出购物车
*
* @param string skuList 商品sku列表,json格式,如{"744403":1,"777777":3}
* @return json
*/
public function removeAction()
{
$result = array();
if ($this->isAjax()) {
$skuList = $this->post('skuList', 0);
$uid = $this->getUid(true);
$shoppingKey = Helpers::getShoppingKeyByCookie();
$result = CartModel::removeFromCart($uid, $skuList, $shoppingKey);
if (!empty($result['code']) && $result['code'] == 200) {
$this->setShoppingCookie($uid);
}
}
$this->echoJson($result);
}
/**
* 移入收藏夹
*
* 支持批量移入收藏夹
*
* @param string 商品sku列表,json格式,如{"744403":1,"777777":3}
* @return json
*/
public function favAction()
{
$result = array();
if ($this->isAjax()) {
$skuList = $this->post('skuList');
$uid = $this->getUid(true);
$result = CartModel::addToFav($uid, $skuList);
if (!empty($result['code']) && $result['code'] == 200) {
$this->setShoppingCookie($uid);
}
}
$this->echoJson($result);
}
/**
* 检查是否收藏
*
* @param string sknList 商品productId列表,如["123123","123412"]
*/
public function checkFavAction()
{
$result = array('code' => 200, 'message' => '是否收藏', 'data' => array());
if ($this->isAjax()) {
$uid = $this->getUid(false);
$pidList = $this->post('pidList', '');
$result['data'] = CartModel::checkUserIsFav($uid, $pidList);
}
$this->echoJson($result);
}
/**
* 凑单商品异步请求
*/
public function getTogetherProductAction()
{
$result = array('code' => 200, 'data' => array(), 'message' => '凑单商品');
if ($this->isAjax()) {
$page = $this->get('page', 1);
$result = CartModel::getTogetherProduct($page);
}
$this->echoJson($result);
}
/**
* 最近浏览的商品异步请求
*/
public function getHistroyProductAction()
{
$result = array('code' => 200, 'data' => array(), 'message' => '浏览记录');
do {
if (!$this->isAjax()) {
break;
}
$page = $this->get('page', 1);
// $uid = $this->getUid(false);
// if ($uid) {
// $udid = $this->getUdid();
// $result = CartModel::getBrowseProduct($uid, $udid, $page);
// break;
// }
$sknList = $this->getCookie('_browseskn');
if (empty($sknList)) {
break;
}
$sknList = explode(',', rawurldecode($sknList));
$result = CartModel::getNamedBrowseProduct($page, 6, $sknList);
}
while (false);
$this->echoJson($result);
}
/**
* 确认订单
*/
public function orderEnsureAction()
{
$type = $this->get('type', 1);
$refer = Helpers::url('/cart/index/orderEnsure', array('type' => $type));
// 审判用户是否已登录
$this->auditJumpLogin(true, $refer);
$this->setTitle('填写订单', true, ' | ');
$this->setSimpleHeader();
$cartType = ($type == 2) ? 'advance' : 'ordinary';
$isAdvanceCart = ($type == 2) ? true : false;
$uid = $this->getUid(true);
$orderEnsure = CartModel::cartPay($uid, $cartType, $isAdvanceCart);
if (empty($orderEnsure)) {
$this->go(Helpers::url('/shopping/cart'));
}
$this->_view->display('order-ensure', array(
'orderEnsurePage' => true,
'orderEnsure' => $orderEnsure,
));
}
/**
* 异步获取地址信息
*
* @return json
*/
public function getAddressAction()
{
$result = array('code' => 200, 'data' => array(), 'message' => '地址信息');
if ($this->isAjax()) {
$uid = $this->getUid(true);
$result['data'] = CartModel::userAddressList($uid);
}
$this->echoJson($result);
}
/**
* 设置为默认的地址
*
* @param int id 地址ID
* @return json
*/
public function setDefaultAddressAction()
{
$result = array();
if ($this->isAjax()) {
$uid = $this->getUid(true);
$addressId = $this->post('id');
$result = CartModel::setDefaultAddress($uid, $addressId);
}
$this->echoJson($result);
}
/**
* 保存地址信息
*
* @param int $id 地址ID ,当修改操作的时候需要传,添加时候不需要传
* @param string $address 地址信息
* @param int $areaCode 城市码
* @param string $consignee 收货人
* @param string $email 邮箱地址
* @param string $mobile 手机号码
* @param string $zipCode 邮编
* @return json
*/
public function saveAddressAction()
{
$result = array();
if ($this->isAjax()) {
$uid = $this->getUid(true);
$id = $this->post('id', null);
$address = $this->post('address', '');
$areaCode = $this->post('areaCode', '');
$consignee = $this->post('consignee', '');
$email = $this->post('email', '');
$mobile = $this->post('mobile', '');
$zipCode = $this->post('zipCode', '');
$result = CartModel::saveAddressData($uid, $address, $areaCode, $consignee, $email, $id, $mobile, $zipCode);
}
$this->echoJson($result);
}
/**
* 删除地址
*
* @param int id 地址ID
*/
public function delAddressAction()
{
$result = array();
if ($this->isAjax()) {
$uid = $this->getUid(true);
$addressId = $this->post('id');
$result = CartModel::delAddress($uid, $addressId);
}
$this->echoJson($result);
}
/**
* 获取省市区县信息列表
*
* @param int id
* @return json
*/
public function getAreaListAction()
{
$result = array('code' => 200, 'message' => '地区信息', 'data' => array());
if ($this->isAjax()) {
$id = $this->get('id', 0);
$result['data'] = CartModel::getAreaList($id);
}
$this->echoJson($result);
}
/**
* 获取优惠券列表
*
* @return json
*/
public function getCouponListAction()
{
$result = array('code' => 200, 'message' => '优惠券信息', 'data' => array());
if ($this->isAjax()) {
$uid = $this->getUid(true);
$result['data'] = CartModel::getCouponList($uid);
}
$this->echoJson($result);
}
/**
* 购物车选择改变字段,重新运算订单数据
*
* @param string $cartType 购物车类型,ordinary表示普通, advance表示预售
* @param int $deliveryWay 配送方式,1表示普通快递,2表示顺丰速运
* @param int $paymentType 支付方式,1表示在线支付,2表示货到付款
* @param string $couponCode 优惠券码
* @param mixed $yohoCoin 使用的YOHO币数量
* @param int $redEnvelopes 红包
* @return json
*/
public function orderComputeAction()
{
$result = array();
if ($this->isAjax()) {
$cartType = $this->post('cartType', 'ordinary');
$deliveryWay = $this->post('deliveryWay', 1);
$paymentType = $this->post('paymentType', 1);
$couponCode = $this->post('couponCode', null);
$yohoCoin = $this->post('yohoCoin', null);
$redEnvelopes = $this->post('redEnvelopes', null);
$uid = $this->getUid(true);
$result = CartModel::orderCompute($uid, $cartType, $deliveryWay, $paymentType, $couponCode, $yohoCoin, $redEnvelopes);
}
$this->echoJson($result);
}
/**
* 确认结算订单
*
* @param int $addressId 地址ID
* @param int $cartType 购物车类型ID
* @param int $deliveryTimeId 寄送时间ID
* @param int $deliveryWayId 寄送方式ID
* @param string $invoiceTitle 发票抬头
* @param int $invoiceId 发票类型ID
* @param int $paymentId 支付方式ID
* @param int $paymentType 支付类型ID
* @param string $remark 留言
* @param string $couponCode 优惠券码
* @param mixed $yohoCoin 使用的YOHO币数量或为空
* @param int $isPreContact 送货前是否联系 true:是, false:否
* @param int $isPrintPrice 是否打印价格 true:是, false:否
* @param int $redEnvelopes 红包
* @return json
*/
public function orderSubAction()
{
$result = array('code' => 400, 'data' => array(), 'message' => CartModel::ERROR_400_MESSAGE);
do {
// 判断是否是AJAX请求
if (!$this->isAjax()) {
break;
}
// 判断用户是否登录
$uid = $this->getUid(true);
if (!$uid) {
$result['message'] = '请先登录';
break;
}
$addressId = $this->post('addressId', null);
$cartType = $this->post('cartType', 'ordinary'); // 默认普通购物车
$deliveryTimeId = $this->post('deliveryTimeId', 1); // 默认只工作日配送
$deliveryWayId = $this->post('deliveryWayId', 1); // 默认普通快递
$invoiceTitle = $this->post('invoiceTitle', null); // 发票抬头
$invoiceId = $this->post('invoiceId', null); // 发票类型
$paymentId = $this->post('paymentId', 15); // 支付ID
$paymentType = $this->post('paymentType', 1); // 默认在线支付
$remark = $this->post('remark', ''); // 备注信息
$couponCode = $this->post('couponCode', null); // 优惠码
$yohoCoin = $this->post('yohoCoin', 1); // YOHO币
$isPreContact = $this->post('isPreContact', false); // 送货前是否联系
$isPrintPrice = $this->post('isPrintPrice', true); // 是否打印价格
$redEnvelopes = $this->post('redEnvelopes', null);
// 调用下单接口
$result = CartModel::orderSub($uid, $addressId, $cartType, $deliveryTimeId, $deliveryWayId, $invoiceTitle, $invoiceId,
$paymentId, $paymentType, $remark, $couponCode, $yohoCoin, $isPreContact, $isPrintPrice, $redEnvelopes);
// 判断是否下单成功
if (empty($result['data']['order_code'])) {
break;
}
// 跳转到支付的URL链接
$result['data']['payUrl'] = Helpers::url('/shopping/pay', array('ordercode' => $result['data']['order_code']));
}
while (false);
// $result = CartModel::orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin);
//
// // 记录下单异常的数据
// if (empty($result)) {
// $message = 'uid:' . $uid . ',addressId:' . $addressId . ',cartType:' . $cartType . ',deliveryTime:' . $deliveryTime
// . ',deliveryWay:' . $deliveryWay . 'invoiceTitle:' . $invoiceTitle . ',invoiceId:' . $invoiceId . ',yohoCoin:' . $yohoCoin
// . ',paymentId:' . $paymentId . ',paymentType:' . $paymentType . ',remark:' . $remark . ',couponCode:' . $couponCode . "\n";
// error_log($message, 3, '/Data/logs/php/pc_error/order.' . date('Ym') . '.log');
// }
// // 返回数据
// else {
// // 提交成功清除Cookie
// $this->setCookie('order-info', null);
//
// $this->echoJson($result);
// }
//
// if ($uid && !empty($result['data'])) {
// try {
// UnionTrans::set($uid, $result['data']['order_code'], $result['data']['order_amount']);
// } catch (Exception $e) {
// // do nothing
// }
// }
$this->echoJson($result);
}
/**
* 加入购物车
*
* @param string productSku 商品的SKU
* @param int buyNumber 购买数量
* @param int promotionId 促销ID, 加价购有关
* @param int goodsType 商品类型,0表示普通商品,1表示加价购商品
* @param int isEdit 是否是编辑商品SKU,0表示不是编辑
* @return json
*/
public function addAction()
{
$result = array();
if ($this->isAjax()) {
$shoppingKey = Helpers::getShoppingKeyByCookie();
$productSku = $this->post('productSku');
$buyNumber = $this->post('buyNumber', 1);
$goodsType = $this->post('goodsType', 0);
$promotionId = $this->post('promotionId', 0);
$isEdit = $this->post('isEdit', 0);
$uid = $this->getUid(true);
// 执行加入购物车操作
$result = CartModel::addToCart($productSku, $buyNumber, $goodsType, $isEdit, $promotionId, $uid, $shoppingKey);
// 设置加入购物车凭证到客户端浏览器
if (empty($shoppingKey) && isset($result['data']['shopping_key'])) {
$this->setCookie('_SPK', $result['data']['shopping_key'], time() + 86400 * 360);
}
// 老站购物车需要的COOKIE
if (isset($result['data']['shopping_key'])) {
$this->setCookie('_g', json_encode(array(
'_k' => $result['data']['shopping_key'],
'_nac' => $result['data']['goods_count'],
'_ac' => 0,
'_r' => 1
)));
}
}
$this->echoJson($result);
}
/**
* 获取商品信息
*/
public function getProductInfoAction()
{
$productId = $this->get('productId');
$uid = $this->getUid();
$vipLevel = -1;
$data = array();
if(!empty($this->_vip)) {
$vipLevel = Helpers::getVipLevel($this->_vip);
}
if(!empty($productId)) {
$data = ItemModel::getCartProductInfo($productId, $uid, $vipLevel);
}
$this->_view->display('goods-detail', $data);
}
/**
* 获取购物车商品总数
*
* @return jsonp
*/
public function countAction()
{
$callback = $this->get('callback', 'callback');
$uid = $this->getUid(false);
$shoppingKey = Helpers::getShoppingKeyByCookie();
$result = CartModel::getCartCount($uid, $shoppingKey);
$this->helpJsonCallbackResult($callback, 200, '总数', $result);
}
/**
* 设置购物车COOKIE信息
*/
private function setShoppingCookie($uid = null)
{
($uid === null) ? $uid = $this->getUid(false) : true;
$shoppingKey = Helpers::getShoppingKeyByCookie();
$cartCount = CartModel::getCartCount($uid, $shoppingKey);
if (!empty($cartCount['data']['cart_goods_count'])) {
$this->setCookie('_g', json_encode(array(
'_k' => $shoppingKey,
'_nac' => $cartCount['data']['cart_goods_count'],
'_ac' => 0,
'_r' => 1
)));
}
}
}
\ No newline at end of file
<?php
use Action\WebAction;
use WebPlugin\Helpers;
use Shopping\CartModel;
use Product\ItemModel;
/**
* 购物车相关的控制器
*
* @name IndexController
* @package Cart
* @copyright yoho.inc
* @version 1.0 (2016-2-17 15:43:19)
* @author fei.hong <fei.hong@yoho.cn>
*/
class IndexController extends WebAction
{
/**
* 通过当前用户审判是否跳到登录
*
* @param boolean $useSession (true:从服务端session中检查, false:从客户端cookie中检查)
* @pram string $refer 指定的来源地址
* @return void
*/
protected function auditJumpLogin($useSession = true, $refer = '')
{
$uid = $this->getUid($useSession);
if (!$uid) {
if (empty($refer)) {
$refer = $this->server('HTTP_REFERER', SITE_MAIN);
}
$this->go(Helpers::url('/signin.html', array('refer' => $refer)));
}
}
/**
* 我的购物车
*/
public function indexAction()
{
$uid = $this->getUid(true);
$shoppingKey = Helpers::getShoppingKeyByCookie();
// 显示一次并清除已删除的COOKIE记录
$cartDelList = $this->getCookie('cart-del-list');
if (!empty($cartDelList)) {
$this->setCookie('cart-del-list', '');
}
$this->setTitle('购物车', true, ' | ');
$this->setSimpleHeader();
$this->_view->display('cart', array(
'cartEnsurePage' => true,
'cartEnsure' => CartModel::myCartData($uid, $shoppingKey, $cartDelList),
));
}
/**
* 购物车商品选择与取消
*
* @param string skuList 商品sku列表,json格式,如{"744403":1,"777777":3}
* @return json
*/
public function selectAction()
{
$result = array();
if ($this->isAjax()) {
$productId = $this->post('skuList', 0);
$uid = $this->getUid(true);
$shoppingKey = Helpers::getShoppingKeyByCookie();
$result = CartModel::selectGoods($uid, $productId, $shoppingKey);
}
$this->echoJson($result);
}
/**
* 修改购物车商品数量
*
* @param int sku
* @param int increaseNum
* @param int decreaseNum
* @return json
*/
public function modifyAction()
{
$result = array();
if ($this->isAjax()) {
$shoppingKey = Helpers::getShoppingKeyByCookie();
$uid = $this->getUid(true);
$sku = $this->post('sku', 0);
$increaseNum = $this->post('increaseNum', null);
$decreaseNum = $this->post('decreaseNum', null);
$result = CartModel::modifyProductNum($uid, $sku, $increaseNum, $decreaseNum, $shoppingKey);
if (!empty($result['code']) && $result['code'] == 200) {
$this->setShoppingCookie($uid);
}
}
$this->echoJson($result);
}
/**
* 移出购物车
*
* @param string skuList 商品sku列表,json格式,如{"744403":1,"777777":3}
* @return json
*/
public function removeAction()
{
$result = array();
if ($this->isAjax()) {
$skuList = $this->post('skuList', 0);
$uid = $this->getUid(true);
$shoppingKey = Helpers::getShoppingKeyByCookie();
$result = CartModel::removeFromCart($uid, $skuList, $shoppingKey);
if (!empty($result['code']) && $result['code'] == 200) {
$this->setShoppingCookie($uid);
}
}
$this->echoJson($result);
}
/**
* 移入收藏夹
*
* 支持批量移入收藏夹
*
* @param string 商品sku列表,json格式,如{"744403":1,"777777":3}
* @return json
*/
public function favAction()
{
$result = array();
if ($this->isAjax()) {
$skuList = $this->post('skuList');
$uid = $this->getUid(true);
$result = CartModel::addToFav($uid, $skuList);
if (!empty($result['code']) && $result['code'] == 200) {
$this->setShoppingCookie($uid);
}
}
$this->echoJson($result);
}
/**
* 检查是否收藏
*
* @param string sknList 商品productId列表,如["123123","123412"]
*/
public function checkFavAction()
{
$result = array('code' => 200, 'message' => '是否收藏', 'data' => array());
if ($this->isAjax()) {
$uid = $this->getUid(false);
$pidList = $this->post('pidList', '');
$result['data'] = CartModel::checkUserIsFav($uid, $pidList);
}
$this->echoJson($result);
}
/**
* 凑单商品异步请求
*/
public function getTogetherProductAction()
{
$result = array('code' => 200, 'data' => array(), 'message' => '凑单商品');
if ($this->isAjax()) {
$page = $this->get('page', 1);
$result = CartModel::getTogetherProduct($page);
}
$this->echoJson($result);
}
/**
* 最近浏览的商品异步请求
*/
public function getHistroyProductAction()
{
$result = array('code' => 200, 'data' => array(), 'message' => '浏览记录');
do {
if (!$this->isAjax()) {
break;
}
$page = $this->get('page', 1);
// $uid = $this->getUid(false);
// if ($uid) {
// $udid = $this->getUdid();
// $result = CartModel::getBrowseProduct($uid, $udid, $page);
// break;
// }
$sknList = $this->getCookie('_browseskn');
if (empty($sknList)) {
break;
}
$sknList = explode(',', rawurldecode($sknList));
$result = CartModel::getNamedBrowseProduct($page, 6, $sknList);
}
while (false);
$this->echoJson($result);
}
/**
* 确认订单
*/
public function orderEnsureAction()
{
$type = $this->get('type', 1);
$refer = Helpers::url('/cart/index/orderEnsure', array('type' => $type));
// 审判用户是否已登录
$this->auditJumpLogin(true, $refer);
$this->setTitle('填写订单', true, ' | ');
$this->setSimpleHeader();
$cartType = ($type == 2) ? 'advance' : 'ordinary';
$isAdvanceCart = ($type == 2) ? true : false;
$uid = $this->getUid(true);
$orderEnsure = CartModel::cartPay($uid, $cartType, $isAdvanceCart);
if (empty($orderEnsure)) {
$this->go(Helpers::url('/shopping/cart'));
}
$this->_view->display('order-ensure', array(
'orderEnsurePage' => true,
'orderEnsure' => $orderEnsure,
));
}
/**
* 异步获取地址信息
*
* @return json
*/
public function getAddressAction()
{
$result = array('code' => 200, 'data' => array(), 'message' => '地址信息');
if ($this->isAjax()) {
$uid = $this->getUid(true);
$result['data'] = CartModel::userAddressList($uid);
}
$this->echoJson($result);
}
/**
* 设置为默认的地址
*
* @param int id 地址ID
* @return json
*/
public function setDefaultAddressAction()
{
$result = array();
if ($this->isAjax()) {
$uid = $this->getUid(true);
$addressId = $this->post('id');
$result = CartModel::setDefaultAddress($uid, $addressId);
}
$this->echoJson($result);
}
/**
* 保存地址信息
*
* @param int $id 地址ID ,当修改操作的时候需要传,添加时候不需要传
* @param string $address 地址信息
* @param int $areaCode 城市码
* @param string $consignee 收货人
* @param string $email 邮箱地址
* @param string $mobile 手机号码
* @param string $zipCode 邮编
* @return json
*/
public function saveAddressAction()
{
$result = array();
if ($this->isAjax()) {
$uid = $this->getUid(true);
$id = $this->post('id', null);
$address = $this->post('address', '');
$areaCode = $this->post('areaCode', '');
$consignee = $this->post('consignee', '');
$email = $this->post('email', '');
$mobile = $this->post('mobile', '');
$zipCode = $this->post('zipCode', '');
$result = CartModel::saveAddressData($uid, $address, $areaCode, $consignee, $email, $id, $mobile, $zipCode);
}
$this->echoJson($result);
}
/**
* 删除地址
*
* @param int id 地址ID
*/
public function delAddressAction()
{
$result = array();
if ($this->isAjax()) {
$uid = $this->getUid(true);
$addressId = $this->post('id');
$result = CartModel::delAddress($uid, $addressId);
}
$this->echoJson($result);
}
/**
* 获取省市区县信息列表
*
* @param int id
* @return json
*/
public function getAreaListAction()
{
$result = array('code' => 200, 'message' => '地区信息', 'data' => array());
if ($this->isAjax()) {
$id = $this->get('id', 0);
$result['data'] = CartModel::getAreaList($id);
}
$this->echoJson($result);
}
/**
* 获取优惠券列表
*
* @return json
*/
public function getCouponListAction()
{
$result = array('code' => 200, 'message' => '优惠券信息', 'data' => array());
if ($this->isAjax()) {
$uid = $this->getUid(true);
$result['data'] = CartModel::getCouponList($uid);
}
$this->echoJson($result);
}
/**
* 购物车选择改变字段,重新运算订单数据
*
* @param string $cartType 购物车类型,ordinary表示普通, advance表示预售
* @param int $deliveryWay 配送方式,1表示普通快递,2表示顺丰速运
* @param int $paymentType 支付方式,1表示在线支付,2表示货到付款
* @param string $couponCode 优惠券码
* @param mixed $yohoCoin 使用的YOHO币数量
* @param int $redEnvelopes 红包
* @return json
*/
public function orderComputeAction()
{
$result = array();
if ($this->isAjax()) {
$cartType = $this->post('cartType', 'ordinary');
$deliveryWay = $this->post('deliveryWay', 1);
$paymentType = $this->post('paymentType', 1);
$couponCode = $this->post('couponCode', null);
$yohoCoin = $this->post('yohoCoin', null);
$redEnvelopes = $this->post('redEnvelopes', null);
$uid = $this->getUid(true);
$result = CartModel::orderCompute($uid, $cartType, $deliveryWay, $paymentType, $couponCode, $yohoCoin, $redEnvelopes);
}
$this->echoJson($result);
}
/**
* 确认结算订单
*
* @param int $addressId 地址ID
* @param int $cartType 购物车类型ID
* @param int $deliveryTimeId 寄送时间ID
* @param int $deliveryWayId 寄送方式ID
* @param string $invoiceTitle 发票抬头
* @param int $invoiceId 发票类型ID
* @param int $paymentId 支付方式ID
* @param int $paymentType 支付类型ID
* @param string $remark 留言
* @param string $couponCode 优惠券码
* @param mixed $yohoCoin 使用的YOHO币数量或为空
* @param int $isPreContact 送货前是否联系 true:是, false:否
* @param int $isPrintPrice 是否打印价格 true:是, false:否
* @param int $redEnvelopes 红包
* @return json
*/
public function orderSubAction()
{
$result = array('code' => 400, 'data' => array(), 'message' => CartModel::ERROR_400_MESSAGE);
do {
// 判断是否是AJAX请求
if (!$this->isAjax()) {
break;
}
// 判断用户是否登录
$uid = $this->getUid(true);
if (!$uid) {
$result['message'] = '请先登录';
break;
}
$addressId = $this->post('addressId', null);
$cartType = $this->post('cartType', 'ordinary'); // 默认普通购物车
$deliveryTimeId = $this->post('deliveryTimeId', 1); // 默认只工作日配送
$deliveryWayId = $this->post('deliveryWayId', 1); // 默认普通快递
$invoiceTitle = $this->post('invoiceTitle', null); // 发票抬头
$invoiceId = $this->post('invoiceId', null); // 发票类型
$paymentId = $this->post('paymentId', 15); // 支付ID
$paymentType = $this->post('paymentType', 1); // 默认在线支付
$remark = $this->post('remark', ''); // 备注信息
$couponCode = $this->post('couponCode', null); // 优惠码
$yohoCoin = $this->post('yohoCoin', 1); // YOHO币
$isPreContact = $this->post('isPreContact', false); // 送货前是否联系
$isPrintPrice = $this->post('isPrintPrice', true); // 是否打印价格
$redEnvelopes = $this->post('redEnvelopes', null);
// 调用下单接口
$result = CartModel::orderSub($uid, $addressId, $cartType, $deliveryTimeId, $deliveryWayId, $invoiceTitle, $invoiceId,
$paymentId, $paymentType, $remark, $couponCode, $yohoCoin, $isPreContact, $isPrintPrice, $redEnvelopes);
// 判断是否下单成功
if (empty($result['data']['order_code'])) {
break;
}
// 跳转到支付的URL链接
$result['data']['payUrl'] = Helpers::url('/shopping/pay', array('ordercode' => $result['data']['order_code']));
}
while (false);
// $result = CartModel::orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin);
//
// // 记录下单异常的数据
// if (empty($result)) {
// $message = 'uid:' . $uid . ',addressId:' . $addressId . ',cartType:' . $cartType . ',deliveryTime:' . $deliveryTime
// . ',deliveryWay:' . $deliveryWay . 'invoiceTitle:' . $invoiceTitle . ',invoiceId:' . $invoiceId . ',yohoCoin:' . $yohoCoin
// . ',paymentId:' . $paymentId . ',paymentType:' . $paymentType . ',remark:' . $remark . ',couponCode:' . $couponCode . "\n";
// error_log($message, 3, '/Data/logs/php/pc_error/order.' . date('Ym') . '.log');
// }
// // 返回数据
// else {
// // 提交成功清除Cookie
// $this->setCookie('order-info', null);
//
// $this->echoJson($result);
// }
//
// if ($uid && !empty($result['data'])) {
// try {
// UnionTrans::set($uid, $result['data']['order_code'], $result['data']['order_amount']);
// } catch (Exception $e) {
// // do nothing
// }
// }
$this->echoJson($result);
}
/**
* 加入购物车
*
* @param string productSku 商品的SKU
* @param int buyNumber 购买数量
* @param int promotionId 促销ID, 加价购有关
* @param int goodsType 商品类型,0表示普通商品,1表示加价购商品
* @param int isEdit 是否是编辑商品SKU,0表示不是编辑
* @return json
*/
public function addAction()
{
$result = array();
if ($this->isAjax()) {
$shoppingKey = Helpers::getShoppingKeyByCookie();
$productSku = $this->post('productSku');
$buyNumber = $this->post('buyNumber', 1);
$goodsType = $this->post('goodsType', 0);
$promotionId = $this->post('promotionId', 0);
$isEdit = $this->post('isEdit', 0);
$uid = $this->getUid(true);
// 执行加入购物车操作
$result = CartModel::addToCart($productSku, $buyNumber, $goodsType, $isEdit, $promotionId, $uid, $shoppingKey);
// 设置加入购物车凭证到客户端浏览器
if (empty($shoppingKey) && isset($result['data']['shopping_key'])) {
$this->setCookie('_SPK', $result['data']['shopping_key'], time() + 86400 * 360);
}
// 老站购物车需要的COOKIE
if (isset($result['data']['shopping_key'])) {
$this->setCookie('_g', json_encode(array(
'_k' => $result['data']['shopping_key'],
'_nac' => $result['data']['goods_count'],
'_ac' => 0,
'_r' => 1
)));
}
}
$this->echoJson($result);
}
/**
* 获取商品信息
*/
public function getProductInfoAction()
{
$productId = $this->get('productId');
$uid = $this->getUid();
$vipLevel = -1;
$data = array();
if(!empty($this->_vip)) {
$vipLevel = Helpers::getVipLevel($this->_vip);
}
if(!empty($productId)) {
$data = ItemModel::getCartProductInfo($productId, $uid, $vipLevel);
}
$this->_view->display('goods-detail', $data);
}
/**
* 获取购物车商品总数
*
* @return jsonp
*/
public function countAction()
{
$callback = $this->get('callback', 'callback');
$uid = $this->getUid(false);
$shoppingKey = Helpers::getShoppingKeyByCookie();
$result = CartModel::getCartCount($uid, $shoppingKey);
$this->helpJsonCallbackResult($callback, 200, '总数', $result);
}
/**
* 设置购物车COOKIE信息
*/
private function setShoppingCookie($uid = null)
{
($uid === null) ? $uid = $this->getUid(false) : true;
$shoppingKey = Helpers::getShoppingKeyByCookie();
$cartCount = CartModel::getCartCount($uid, $shoppingKey);
if (!empty($cartCount['data']['cart_goods_count'])) {
$this->setCookie('_g', json_encode(array(
'_k' => $shoppingKey,
'_nac' => $cartCount['data']['cart_goods_count'],
'_ac' => 0,
'_r' => 1
)));
}
}
}
\ No newline at end of file
... ... @@ -112,10 +112,10 @@ class OrdersController extends WebAction
'remark' => $detail['remark'],
'goods' => $detail['goods'],
'sumPrice' => $detail['sumPrice'],
'freight' => $detail['freight'],
'freight' => isset($detail['freight']) ? $detail['freight'] : 0,
'yohoCoin' => $detail['yohoCoin'],
'yohoCoinUrl' => $detail['yohoCoinUrl'],
'coupons' => $detail['coupons'],
'coupons' => isset($detail['coupons']) ? $detail['coupons'] : 0,
'payment' => $detail['payment'],
'operation' => $detail['operation']
);
... ... @@ -195,29 +195,34 @@ class OrdersController extends WebAction
$path = UserModel::getCenterCrumb('查看二维码', array('url' => Helpers::url('/home/orders'), 'name' => '订单中心'));
$leftNav = UserModel::getCenterLeftNav('我的订单');
$data = array(
'path' => $path,
'userThumb' => UserModel::getUserHeadImg($uid),
'homeNav' => $leftNav,
'name' => 'JIT预售虚拟商品Yohood票',
'num' => 1,
'orderNum' => '160169853',
'myOrdersUrl' => '',
'tickets' => array(
array(
'img' => 'http://static.yohobuy.com/images/v2/common/2dcode_disabled.png',
'desc' => 'Hello world'
),
array(
'img' => 'http://static.yohobuy.com/images/v2/common/2dcode_disabled.png',
'desc' => 'Hello world'
),
array(
'img' => 'http://static.yohobuy.com/images/v2/common/2dcode_disabled.png',
'desc' => 'Hello world'
$orderCode = $this->get('orderCode', '');
$detail = OrderModel::getOrderDetail($uid, $orderCode);
if (isset($detail) && $detail) {
$tickets = OrderModel::getTicketImgs($uid, $detail['goods'][0]['sku']);
$data = array(
'path' => $path,
'userThumb' => UserModel::getUserHeadImg($uid),
'homeNav' => $leftNav,
'name' => $detail['goods'][0]['name'],
'num' => $detail['goods'][0]['num'],
'orderNum' => $detail['orderNum'],
'myOrdersUrl' => Helpers::url('/home/orders'),
'tickets' => array(
array(
'img' => 'http://static.yohobuy.com/images/v2/common/2dcode_disabled.png',
'desc' => 'Hello world'
),
array(
'img' => 'http://static.yohobuy.com/images/v2/common/2dcode_disabled.png',
'desc' => 'Hello world'
),
array(
'img' => 'http://static.yohobuy.com/images/v2/common/2dcode_disabled.png',
'desc' => 'Hello world'
)
)
)
);
);
}
$this->_view->display('ticket', array('meOrderTicket' => $data));
}
... ...
... ... @@ -214,17 +214,24 @@ class ItemController extends WebAction
if(!empty($browseSknList)) {
$goodsSknList = explode(',', $browseSknList);
}
//处理存在
if(in_array($goodsId, $goodsList) || in_array($skn . '-' . $goodsId, $goodsSknList)) {
return;
} else {
array_unshift($goodsList, $goodsId);
array_unshift($goodsSknList, $skn . '-' . $goodsId);
$browse = implode(',', array_slice($goodsList, 0, 30));
$browseSkn = implode(',', array_slice($goodsSknList, 0, 30));
$this->setCookie('_browse', $browse, 2000000000);
$this->setCookie('_browseskn', $browseSkn, 2000000000);
$key = array_search($goodsId, $goodsList);
if($key !== false) {
unset($goodsList[$key]);
}
$key = array_search($skn . '-' . $goodsId, $goodsSknList);
if($key !== false) {
unset($goodsSknList[$key]);
}
}
array_unshift($goodsList, $goodsId);
array_unshift($goodsSknList, $skn . '-' . $goodsId);
$browse = implode(',', array_slice($goodsList, 0, 30));
$browseSkn = implode(',', array_slice($goodsSknList, 0, 30));
$this->setCookie('_browse', $browse, 2000000000);
$this->setCookie('_browseskn', $browseSkn, 2000000000);
}
}
\ No newline at end of file
... ...
... ... @@ -50,7 +50,7 @@ application.template.ext = ".phtml"
application.assets.path = ROOT_PATH "/assets/web"
; 应用的版本号
application.version = "0.0.9"
application.version = "0.0.10"
; 网站SEO信息
application.seo.title = "YOHO!有货 | 年轻人潮流购物中心,中国潮流购物风向标,官方授权正品保证"
... ...
... ... @@ -50,7 +50,7 @@ application.template.ext = ".phtml"
application.assets.path = ROOT_PATH "/assets/web"
; 应用的版本号
application.version = "0.0.9"
application.version = "0.0.10"
; 网站SEO信息
application.seo.title = "YOHO!有货 | 年轻人潮流购物中心,中国潮流购物风向标,官方授权正品保证"
... ...
... ... @@ -50,7 +50,7 @@ application.template.ext = ".phtml"
application.assets.path = ROOT_PATH "/assets/web"
; 应用的版本号
application.version = "0.0.9"
application.version = "0.0.10"
; 网站SEO信息
application.seo.title = "YOHO!有货 | 年轻人潮流购物中心,中国潮流购物风向标,官方授权正品保证"
... ...
... ... @@ -50,7 +50,7 @@ application.template.ext = ".phtml"
application.assets.path = ROOT_PATH "/assets/web"
; 应用的版本号
application.version = "0.0.9"
application.version = "0.0.10"
; 网站SEO信息
application.seo.title = "YOHO!有货 | 年轻人潮流购物中心,中国潮流购物风向标,官方授权正品保证"
... ...
... ... @@ -4,7 +4,7 @@ define('SITE_MAIN', 'http://web.dev.yohobuy.com'); // 网站主域名
define('OLD_MAIN', 'http://www.yohobuy.com'); // 网站旧域名
define('COOKIE_DOMAIN', '.yohobuy.com'); // COOKIE作用域
define('SUB_DOMAIN', '.yohobuy.com'); // 子域名后缀
define('USE_CACHE', false); // 缓存的开关
define('USE_CACHE', true); // 缓存的开关
define('APPLICATION_PATH', dirname(__DIR__)); // 应用目录
define('ROOT_PATH', dirname(dirname(APPLICATION_PATH))); // 根目录
defined('APPLICATION_ENV') || define('APPLICATION_ENV', 'developer');
... ...