Authored by whb

解决冲突问题

@@ -68,7 +68,7 @@ class AbstractAction extends Controller_Abstract @@ -68,7 +68,7 @@ class AbstractAction extends Controller_Abstract
68 case 'develop': // 开发 68 case 'develop': // 开发
69 default: 69 default:
70 $this->_view->assign('devEnv', true); 70 $this->_view->assign('devEnv', true);
71 - $this->_useSession = false; 71 + $this->_useSession = true;
72 break; 72 break;
73 } 73 }
74 } 74 }
@@ -317,7 +317,7 @@ class AbstractAction extends Controller_Abstract @@ -317,7 +317,7 @@ class AbstractAction extends Controller_Abstract
317 } 317 }
318 } 318 }
319 319
320 - /** 320 + /**
321 * 获取当前登录的用户ID 321 * 获取当前登录的用户ID
322 * 322 *
323 * @param bool $useSession (true:从服务端session中检查, false:从客户端cookie中检查) 323 * @param bool $useSession (true:从服务端session中检查, false:从客户端cookie中检查)
@@ -329,10 +329,11 @@ class AbstractAction extends Controller_Abstract @@ -329,10 +329,11 @@ class AbstractAction extends Controller_Abstract
329 if (!$this->_useSession) { 329 if (!$this->_useSession) {
330 $useSession = false; 330 $useSession = false;
331 } 331 }
332 - $useSession = false; 332 + //$useSession = false;
333 333
334 if (!$this->_uid) { 334 if (!$this->_uid) {
335 $cookie = $this->getCookie('_UID'); 335 $cookie = $this->getCookie('_UID');
  336 + // 兼容老的
336 if (!empty($cookie)) { 337 if (!empty($cookie)) {
337 $cookieList = explode('::', $cookie); 338 $cookieList = explode('::', $cookie);
338 if (isset($cookieList[1]) && is_numeric($cookieList[1])) { 339 if (isset($cookieList[1]) && is_numeric($cookieList[1])) {
@@ -351,11 +352,18 @@ class AbstractAction extends Controller_Abstract @@ -351,11 +352,18 @@ class AbstractAction extends Controller_Abstract
351 $this->_usession = $cookieList[3]; 352 $this->_usession = $cookieList[3];
352 $this->_vip = $cookieList[2]; 353 $this->_vip = $cookieList[2];
353 } 354 }
  355 + }
  356 + // 新的, 如果老站没有同步成功,再尝试从SESSION获取
  357 + elseif ($useSession) {
  358 + $uid = $this->getSession('_LOGIN_UID');
  359 + if (!empty($uid)) {
  360 + $this->_uid = $uid;
  361 + }
354 } 362 }
355 } 363 }
356 return $this->_uid; 364 return $this->_uid;
357 } 365 }
358 - 366 +
359 /** 367 /**
360 * 获取客户端唯一标识 368 * 获取客户端唯一标识
361 * 369 *
@@ -67,7 +67,7 @@ class WebAction extends Controller_Abstract @@ -67,7 +67,7 @@ class WebAction extends Controller_Abstract
67 case 'develop': // 开发 67 case 'develop': // 开发
68 default: 68 default:
69 $this->_view->assign('devEnv', true); 69 $this->_view->assign('devEnv', true);
70 - $this->_useSession = false; 70 + $this->_useSession = true;
71 break; 71 break;
72 } 72 }
73 } 73 }
@@ -333,9 +333,11 @@ class WebAction extends Controller_Abstract @@ -333,9 +333,11 @@ class WebAction extends Controller_Abstract
333 if (!$this->_useSession) { 333 if (!$this->_useSession) {
334 $useSession = false; 334 $useSession = false;
335 } 335 }
  336 + //$useSession = false;
336 337
337 if (!$this->_uid) { 338 if (!$this->_uid) {
338 $cookie = $this->getCookie('_UID'); 339 $cookie = $this->getCookie('_UID');
  340 + // 兼容老的
339 if (!empty($cookie)) { 341 if (!empty($cookie)) {
340 $cookieList = explode('::', $cookie); 342 $cookieList = explode('::', $cookie);
341 if (isset($cookieList[1]) && is_numeric($cookieList[1])) { 343 if (isset($cookieList[1]) && is_numeric($cookieList[1])) {
@@ -354,6 +356,13 @@ class WebAction extends Controller_Abstract @@ -354,6 +356,13 @@ class WebAction extends Controller_Abstract
354 $this->_usession = $cookieList[3]; 356 $this->_usession = $cookieList[3];
355 $this->_vip = $cookieList[2]; 357 $this->_vip = $cookieList[2];
356 } 358 }
  359 + }
  360 + // 新的, 如果老站没有同步成功,再尝试从SESSION获取
  361 + elseif ($useSession) {
  362 + $uid = $this->getSession('_LOGIN_UID');
  363 + if (!empty($uid)) {
  364 + $this->_uid = $uid;
  365 + }
357 } 366 }
358 } 367 }
359 return $this->_uid; 368 return $this->_uid;
@@ -208,7 +208,7 @@ class FloorProcess @@ -208,7 +208,7 @@ class FloorProcess
208 foreach ($data['list'] as &$one) { 208 foreach ($data['list'] as &$one) {
209 if (isset($one['url'])) { 209 if (isset($one['url'])) {
210 $one['url'] = Helpers::getFilterUrl($one['url']); 210 $one['url'] = Helpers::getFilterUrl($one['url']);
211 -// isset(self::$channel[$type]) && $one['url'] .= '?gender=' . self::$channel[$type]; 211 + isset(self::$channel[$type]) && $one['url'] .= '?gender=' . self::$channel[$type];
212 } 212 }
213 $one['img'] = Helpers::getImageUrl($one['src'], 158, 174); 213 $one['img'] = Helpers::getImageUrl($one['src'], 158, 174);
214 unset($one['src']); 214 unset($one['src']);
@@ -190,7 +190,7 @@ class Helpers @@ -190,7 +190,7 @@ class Helpers
190 */ 190 */
191 public static function transPrice($price) 191 public static function transPrice($price)
192 { 192 {
193 - return (!empty($price) && !is_float($price)) ? $price . '.00' : number_format($price, 2, '.', ''); 193 + return number_format($price, 2, '.', '');
194 } 194 }
195 195
196 /** 196 /**
@@ -566,8 +566,8 @@ class Helpers @@ -566,8 +566,8 @@ class Helpers
566 $arr[$key]['appearDate'] = $vo['expect_arrival_time']; 566 $arr[$key]['appearDate'] = $vo['expect_arrival_time'];
567 } 567 }
568 // 商品链接 568 // 商品链接
569 - if ($haveLink && isset($vo['product_id'])) {  
570 - $arr[$key]['link'] = self::url('/product/pro_' . $vo['product_id'] . '_' . $vo['goods_id'] . '/' . $vo['cn_alphabet'] . '.html'); 569 + if ($haveLink && isset($vo['product_skn'])) {
  570 + $arr[$key]['link'] = self::url('/product/show_' . $vo['product_skn'] . '.html');
571 } 571 }
572 // 累计购买数 572 // 累计购买数
573 $count += intval($vo['buy_number']); 573 $count += intval($vo['buy_number']);
@@ -576,52 +576,70 @@ class Helpers @@ -576,52 +576,70 @@ class Helpers
576 return $arr; 576 return $arr;
577 } 577 }
578 578
579 - /** 579 +/**
580 * 格式化购物车商品 580 * 格式化购物车商品
581 * 581 *
582 * @param array $cartGoods 购物车商品列表 582 * @param array $cartGoods 购物车商品列表
  583 + * @param boolean $isValid 是否是可用商品(非失效商品),默认是
  584 + * @param bool $isAdvanceCart 是否是预售购物车(和上市期有关)
583 * @return array 处理之后的购物车商品数据 585 * @return array 处理之后的购物车商品数据
584 */ 586 */
585 - public static function formatCartGoods($cartGoods) 587 + public static function formatCartGoods($cartGoods, $isAdvanceCart, $isValid = true)
586 { 588 {
587 $arr = array(); 589 $arr = array();
588 590
589 - $oneGoods = array();  
590 - foreach ($cartGoods as $key => $value) {  
591 - $oneGoods['id'] = $value['product_sku'];  
592 - $oneGoods['skn'] = $value['product_skn'];  
593 - $oneGoods['name'] = $value['product_name'];  
594 - $oneGoods['thumb'] = !empty($value['goods_images']) ? Images::getImageUrl($value['goods_images'], 120, 120) : '';  
595 - $oneGoods['color'] = $value['color_name'];  
596 - $oneGoods['size'] = $value['size_name'];  
597 - $oneGoods['price'] = self::transPrice($value['sales_price']);  
598 - $oneGoods['count'] = $value['buy_number'];  
599 - $oneGoods['lowStocks'] = ($value['buy_number'] < $value['storage_number']);  
600 - //gift=>是否赠品,advanceBuy=>是否加价购,soldOut=>失效商品;  
601 - if (!isset($value['goods_type'])) {  
602 - $oneGoods['isSoldOut'] = true;  
603 - } elseif ($value['goods_type'] == 'gift' && !isset($value['isAdvanceBuy'])) {  
604 - $oneGoods['isGift'] = true;  
605 - } elseif ($value['goods_type'] == 'price_gift') {  
606 - $oneGoods['isAdvanceBuy'] = true;  
607 - }  
608 - // 上市期  
609 - if (!empty($value['expect_arrival_time'])) {  
610 - $oneGoods['appearDate'] = $value['expect_arrival_time'];  
611 - }  
612 - // 商品链接  
613 - if (isset($value['cn_alphabet']) ) {  
614 - $oneGoods['url'] = self::url('/product/pro_' . $value['product_id'] . '_' . $value['goods_id'] . '/' . $value['cn_alphabet'] . '.html');  
615 - }  
616 -  
617 - $arr[$key] = $oneGoods;  
618 - } 591 + $oneGoods = array();
  592 + foreach ($cartGoods as $key => $value) {
  593 + $oneGoods = array();
  594 + $oneGoods['id'] = $value['product_sku'];
  595 + $oneGoods['skn'] = $value['product_skn'];
  596 + $oneGoods['name'] = $value['product_name'];
  597 + $oneGoods['thumb'] = !empty($value['goods_images']) ? Images::getImageUrl($value['goods_images'], 120, 160) : '';
  598 + $oneGoods['color'] = $value['color_name'];
  599 + $oneGoods['size'] = $value['size_name'];
  600 + $oneGoods['checked'] = $value['selected'] === 'Y';
  601 + $oneGoods['price'] = self::transPrice($value['last_vip_price']);
  602 + $oneGoods['isVipPrice'] = $value['sales_price'] !== $value['last_vip_price'];
  603 + $oneGoods['count'] = $value['buy_number'];
  604 +
  605 + if ($isValid) {
  606 + // 库存不足
  607 + $oneGoods['lowStocks'] = ($value['buy_number'] > $value['storage_number']);
  608 + } else { // 失效商品
  609 + $oneGoods['inValid'] = true;
  610 + }
  611 +
  612 + //gift=>是否赠品,advanceBuy=>是否加价购,soldOut=>失效商品;
  613 + if (!isset($value['goods_type'])) {
  614 + $oneGoods['inValid'] = true;
  615 + } elseif ($value['goods_type'] == 'gift' && !isset($value['isAdvanceBuy'])) {
  616 + $oneGoods['isGift'] = true;
  617 + $oneGoods['salesPrice'] = self::transPrice($value['sales_price']);
  618 + $oneGoods['price'] = self::transPrice($value['last_price']);
  619 + } elseif ($value['goods_type'] == 'price_gift') {
  620 + $oneGoods['showCheckbox'] = true;
  621 + $oneGoods['isAdvanceBuy'] = true;
  622 + $oneGoods['salesPrice'] = self::transPrice($value['sales_price']);
  623 + $oneGoods['price'] = self::transPrice($value['last_price']);
  624 + } else {
  625 + $oneGoods['showCheckbox'] = true;
  626 + }
  627 +
  628 + // 上市期
  629 + if ($isAdvanceCart && !empty($value['expect_arrival_time'])) {
  630 + $oneGoods['appearDate'] = $value['expect_arrival_time'];
  631 + }
  632 + // 商品链接
  633 + $oneGoods['link'] = self::url('/product/show_' . $value['product_skn'] . '.html');
  634 +
  635 + $arr[$key] = $oneGoods;
  636 + }
619 637
620 return $arr; 638 return $arr;
621 } 639 }
622 640
623 /** 641 /**
624 - * 格式化加价购商品 642 + * 格式化加价购和赠品商品
625 * 643 *
626 * @param array $advanceGoods 加价购商品列表 644 * @param array $advanceGoods 加价购商品列表
627 * @param int $count 计商品件数 645 * @param int $count 计商品件数
@@ -631,33 +649,38 @@ class Helpers @@ -631,33 +649,38 @@ class Helpers
631 { 649 {
632 $arr = array(); 650 $arr = array();
633 651
634 - $gift = array();  
635 - $oneGoods = array();  
636 - foreach ($advanceGoods as $value) {  
637 - $gift = array();  
638 - $gift['promotionTitle'] = $value['promotion_title'];  
639 -  
640 - foreach ($value['goods_list'] as $single) {  
641 - $oneGoods['id'] = $single['product_skn'];  
642 - $oneGoods['name'] = $single['product_name'];  
643 - $oneGoods['thumb'] = !empty($single['goods_images']) ? Images::getImageUrl($single['goods_images'], 120, 120) : '';  
644 - $oneGoods['appearDate'] = '12月'; // 目前app接口没有返回该数据  
645 - $oneGoods['price'] = $single['last_price'];  
646 - $oneGoods['marketPrice'] = $single['market_price'];  
647 - $oneGoods['count'] = $single['storage_number'];  
648 -  
649 - $gift['goods'][] = $oneGoods;  
650 - } 652 + $gift = array();
  653 + $oneGoods = array();
  654 + $number = 0;
  655 + foreach ($advanceGoods as $value) {
  656 + $gift = array();
  657 + $gift['promotionId'] = $value['promotion_id'];
  658 + $gift['promotionTitle'] = $value['promotion_title'];
  659 +
  660 + $number = 0;
  661 + foreach ($value['goods_list'] as $single) {
  662 + $oneGoods = array();
  663 + $oneGoods['id'] = $single['product_skn'];
  664 + $oneGoods['name'] = $single['product_name'];
  665 + $oneGoods['thumb'] = !empty($single['goods_images']) ? Images::getImageUrl($single['goods_images'], 120, 160) : '';
  666 + $oneGoods['price'] = self::transPrice($single['last_price']);
  667 + $oneGoods['marketPrice'] = self::transPrice($single['market_price']);
  668 + $oneGoods['count'] = $single['storage_number'];
  669 +
  670 + $gift['goods'][] = $oneGoods;
  671 + $number ++;
  672 + }
651 673
652 - $arr[] = $gift; 674 + $arr[] = $gift;
653 675
654 - // 计算加价购商品数目  
655 - $count += count($value['goods_list']);  
656 - } 676 + // 计算加价购商品数目
  677 + //$count += count($value['goods_list']);
  678 + $count += $number;
  679 + }
657 680
658 return $arr; 681 return $arr;
659 } 682 }
660 - 683 +
661 /** 684 /**
662 * 订单状态,按订单支付类型和订单状态 685 * 订单状态,按订单支付类型和订单状态
663 * @var array 686 * @var array
@@ -38,35 +38,36 @@ class AlipayNotify { @@ -38,35 +38,36 @@ class AlipayNotify {
38 * @return 验证结果 38 * @return 验证结果
39 */ 39 */
40 function verifyNotify(){ 40 function verifyNotify(){
41 - if (empty($_POST)) { //判断POST来的数组是否为空  
42 - return false;  
43 - } else {  
44 - //生成签名结果  
45 - $isSign = $this->getSignVeryfy($_POST, $_POST["sign"]);  
46 - //获取支付宝远程服务器ATN结果(验证是否是支付宝发来的消息)  
47 - $responseTxt = 'true';  
48 - if (! empty($_POST["notify_id"])) {$responseTxt = $this->getResponse($_POST["notify_id"]);}  
49 -  
50 - //写日志记录  
51 - //if ($isSign) {  
52 - // $isSignStr = 'true';  
53 - //}  
54 - //else {  
55 - // $isSignStr = 'false';  
56 - //}  
57 - //$log_text = "responseTxt=".$responseTxt."\n notify_url_log:isSign=".$isSignStr.",";  
58 - //$log_text = $log_text.createLinkString($_POST);  
59 - //logResult($log_text);  
60 -  
61 - //验证  
62 - //$responsetTxt的结果不是true,与服务器设置问题、合作身份者ID、notify_id一分钟失效有关  
63 - //isSign的结果不是true,与安全校验码、请求时的参数格式(如:带自定义参数等)、编码格式有关  
64 - if (preg_match("/true$/i",$responseTxt) && $isSign) {  
65 - return true;  
66 - } else {  
67 - return false;  
68 - }  
69 - } 41 + if (empty($_POST)) { //判断POST来的数组是否为空
  42 + return false;
  43 + } else {
  44 + //生成签名结果
  45 + $isSign = $this->getSignVeryfy($_POST, $_POST["sign"]);
  46 + //获取支付宝远程服务器ATN结果(验证是否是支付宝发来的消息)
  47 + $responseTxt = 'true';
  48 + if (!empty($_POST["notify_id"])) {
  49 + $responseTxt = $this->getResponse($_POST["notify_id"]);
  50 + }
  51 +
  52 + //写日志记录
  53 + //if ($isSign) {
  54 + // $isSignStr = 'true';
  55 + //}
  56 + //else {
  57 + // $isSignStr = 'false';
  58 + //}
  59 + //$log_text = "responseTxt=".$responseTxt."\n notify_url_log:isSign=".$isSignStr.",";
  60 + //$log_text = $log_text.createLinkString($_POST);
  61 + //logResult($log_text);
  62 + //验证
  63 + //$responsetTxt的结果不是true,与服务器设置问题、合作身份者ID、notify_id一分钟失效有关
  64 + //isSign的结果不是true,与安全校验码、请求时的参数格式(如:带自定义参数等)、编码格式有关
  65 + if (preg_match("/true$/i", $responseTxt) && $isSign) {
  66 + return true;
  67 + } else {
  68 + return false;
  69 + }
  70 + }
70 } 71 }
71 72
72 /** 73 /**
@@ -74,36 +75,36 @@ class AlipayNotify { @@ -74,36 +75,36 @@ class AlipayNotify {
74 * @return 验证结果 75 * @return 验证结果
75 */ 76 */
76 function verifyReturn(){ 77 function verifyReturn(){
77 - if(empty($_GET)) {//判断POST来的数组是否为空  
78 - return false;  
79 - }  
80 - else {  
81 - //生成签名结果  
82 - $isSign = $this->getSignVeryfy($_GET, $_GET["sign"]);  
83 - //获取支付宝远程服务器ATN结果(验证是否是支付宝发来的消息)  
84 - $responseTxt = 'true';  
85 - if (! empty($_GET["notify_id"])) {$responseTxt = $this->getResponse($_GET["notify_id"]);}  
86 -  
87 - //写日志记录  
88 - //if ($isSign) {  
89 - // $isSignStr = 'true';  
90 - //}  
91 - //else {  
92 - // $isSignStr = 'false';  
93 - //}  
94 - //$log_text = "responseTxt=".$responseTxt."\n return_url_log:isSign=".$isSignStr.",";  
95 - //$log_text = $log_text.createLinkString($_GET);  
96 - //logResult($log_text);  
97 -  
98 - //验证  
99 - //$responsetTxt的结果不是true,与服务器设置问题、合作身份者ID、notify_id一分钟失效有关  
100 - //isSign的结果不是true,与安全校验码、请求时的参数格式(如:带自定义参数等)、编码格式有关  
101 - if (preg_match("/true$/i",$responseTxt) && $isSign) {  
102 - return true;  
103 - } else {  
104 - return false;  
105 - }  
106 - } 78 + if (empty($_GET)) {//判断POST来的数组是否为空
  79 + return false;
  80 + } else {
  81 + //生成签名结果
  82 + $isSign = $this->getSignVeryfy($_GET, $_GET["sign"]);
  83 + //获取支付宝远程服务器ATN结果(验证是否是支付宝发来的消息)
  84 + $responseTxt = 'true';
  85 + if (!empty($_GET["notify_id"])) {
  86 + $responseTxt = $this->getResponse($_GET["notify_id"]);
  87 + }
  88 +
  89 + //写日志记录
  90 + //if ($isSign) {
  91 + // $isSignStr = 'true';
  92 + //}
  93 + //else {
  94 + // $isSignStr = 'false';
  95 + //}
  96 + //$log_text = "responseTxt=".$responseTxt."\n return_url_log:isSign=".$isSignStr.",";
  97 + //$log_text = $log_text.createLinkString($_GET);
  98 + //logResult($log_text);
  99 + //验证
  100 + //$responsetTxt的结果不是true,与服务器设置问题、合作身份者ID、notify_id一分钟失效有关
  101 + //isSign的结果不是true,与安全校验码、请求时的参数格式(如:带自定义参数等)、编码格式有关
  102 + if (preg_match("/true$/i", $responseTxt) && $isSign) {
  103 + return true;
  104 + } else {
  105 + return false;
  106 + }
  107 + }
107 } 108 }
108 109
109 /** 110 /**