Authored by 郝肖肖

门票添加接口邦定

@@ -54,7 +54,7 @@ @@ -54,7 +54,7 @@
54 </thead> 54 </thead>
55 <tbody> 55 <tbody>
56 {{#each orderProducts}} 56 {{#each orderProducts}}
57 - <tr> 57 + <tr data-sku="{{id}}">
58 <td> 58 <td>
59 <div class="pay-pro"> 59 <div class="pay-pro">
60 <a class="pay-pro-icon" href="{{link}}"> 60 <a class="pay-pro-icon" href="{{link}}">
@@ -68,7 +68,7 @@ @@ -68,7 +68,7 @@
68 </a> 68 </a>
69 <p class="pay-pro-info"> 69 <p class="pay-pro-info">
70 <a href="{{link}}" target="_blank">{{productTitle}}</a> 70 <a href="{{link}}" target="_blank">{{productTitle}}</a>
71 - <span>颜色:{{productColor}} 尺码:{{productSize}}</span> 71 + <span>日期:{{productColor}} 区域:{{productSize}}</span>
72 </p> 72 </p>
73 </div> 73 </div>
74 </td> 74 </td>
@@ -277,11 +277,11 @@ @@ -277,11 +277,11 @@
277 </div> 277 </div>
278 </div> 278 </div>
279 279
280 - <p class="row"> 280 + <div class="row">
281 {{#if isTicket}} 281 {{#if isTicket}}
282 {{!-- 电子门票按钮 --}} 282 {{!-- 电子门票按钮 --}}
283 - <span id="buy-ticket" class="buy-btn buy-now item-buy{{#if dis}} dis{{/if}}" >立即购买</span>  
284 <form name="ticket-form" action="/cart/index/ticketEnsure" method="POST"></form> 283 <form name="ticket-form" action="/cart/index/ticketEnsure" method="POST"></form>
  284 + <span id="buy-ticket" class="buy-btn buy-now item-buy{{#if dis}} dis{{/if}}" >立即购买</span>
285 {{^}} 285 {{^}}
286 {{!-- 各颜色下所有尺码均售罄则只显示售罄按钮 --}} 286 {{!-- 各颜色下所有尺码均售罄则只显示售罄按钮 --}}
287 {{#unless soldOut}} 287 {{#unless soldOut}}
@@ -320,7 +320,7 @@ @@ -320,7 +320,7 @@
320 <em>收藏商品</em> 320 <em>收藏商品</em>
321 {{/if}} 321 {{/if}}
322 </span> 322 </span>
323 - </p> 323 + </div>
324 324
325 <div class="share-row"> 325 <div class="share-row">
326 <span class="title pull-left">分享商品:</span> 326 <span class="title pull-left">分享商品:</span>
@@ -33,6 +33,7 @@ var TicketCat = { @@ -33,6 +33,7 @@ var TicketCat = {
33 $toPay: $('.to-play em'), 33 $toPay: $('.to-play em'),
34 $errorTip: $('.errbitip'), 34 $errorTip: $('.errbitip'),
35 $tbody: $('table tbody', '.pay-wapper'), 35 $tbody: $('table tbody', '.pay-wapper'),
  36 +
36 //门票js 37 //门票js
37 $showTicketMobile: $('.show-ticket-mobile'), 38 $showTicketMobile: $('.show-ticket-mobile'),
38 $ticketMobile: $('.ticket-mobile'), 39 $ticketMobile: $('.ticket-mobile'),
@@ -41,6 +42,10 @@ var TicketCat = { @@ -41,6 +42,10 @@ var TicketCat = {
41 $ticketMobileBtn: $('.ticket-mobile-btn'), 42 $ticketMobileBtn: $('.ticket-mobile-btn'),
42 $ticketMobileInput: $('.ticket-mobile-input') 43 $ticketMobileInput: $('.ticket-mobile-input')
43 }, 44 },
  45 + Data: {
  46 + buyNumber: 0,//购买总数量
  47 + productSku: 0
  48 + },
44 Common: { 49 Common: {
45 enterNUM: function(str1, str2) { 50 enterNUM: function(str1, str2) {
46 str1 = str1.replace(/[^\d]/g, ''); 51 str1 = str1.replace(/[^\d]/g, '');
@@ -80,6 +85,8 @@ var TicketCat = { @@ -80,6 +85,8 @@ var TicketCat = {
80 var len = el.$tbody.find('tr').length; 85 var len = el.$tbody.find('tr').length;
81 var subtotal = parseFloat(td.eq(1).html()) * parseInt(td.eq(3).html()); 86 var subtotal = parseFloat(td.eq(1).html()) * parseInt(td.eq(3).html());
82 87
  88 + _this.Data.productSku = $(this).data('sku');
  89 + _this.Data.buyNumber += parseInt(td.eq(3).html());
83 td.eq(1).html('¥' + td.eq(1).html()); 90 td.eq(1).html('¥' + td.eq(1).html());
84 91
85 if (td.hasClass('xforone')) { 92 if (td.hasClass('xforone')) {
@@ -215,9 +222,9 @@ var TicketCat = { @@ -215,9 +222,9 @@ var TicketCat = {
215 }); 222 });
216 }); 223 });
217 }, 224 },
  225 +
218 //渲染价格明细 226 //渲染价格明细
219 render: function(data) { 227 render: function(data) {
220 - // 下面这段是在服务端算价格  
221 var e = this.el, 228 var e = this.el,
222 i, 229 i,
223 dArr = data.promotion_formula_list, 230 dArr = data.promotion_formula_list,
@@ -263,7 +270,9 @@ var TicketCat = { @@ -263,7 +270,9 @@ var TicketCat = {
263 resultData = { 270 resultData = {
264 cartType: cartType, 271 cartType: cartType,
265 deliveryWay: expressVal, 272 deliveryWay: expressVal,
266 - yohoCoin: biVal 273 + yohoCoin: biVal,
  274 + productSku: this.Data.productSku,
  275 + buyNumber: this.Data.buyNumber
267 }; 276 };
268 return resultData; 277 return resultData;
269 } 278 }
@@ -573,12 +573,26 @@ class CartModel @@ -573,12 +573,26 @@ class CartModel
573 */ 573 */
574 public static function cartPay($uid, $cartType, $isAdvanceCart) 574 public static function cartPay($uid, $cartType, $isAdvanceCart)
575 { 575 {
576 - $result = array(); 576 + /* 调接口订单确认接口 */
  577 + $pay = CartData::cartPay($uid, $cartType);
  578 +
  579 + return self::filterCartPay($pay, $cartType, $isAdvanceCart);
  580 + }
  581 + /**
  582 + * 处理购物车返回
  583 + * @param type $pay 获取商品数据
  584 + * @param string $cartType 购物车类型,ordinary表示普通购物车
  585 + * @param bool $isAdvanceCart 是否是预售商品列表
  586 + * @return type []
  587 + */
  588 + private static function filterCartPay($pay, $cartType, $isAdvanceCart)
  589 + {
577 // 存放分析用的数据 590 // 存放分析用的数据
578 $analysisData = array('ipinyou' => ''); 591 $analysisData = array('ipinyou' => '');
  592 + $result = array();
  593 +
579 do { 594 do {
580 - /* 调接口订单确认接口 */  
581 - $pay = CartData::cartPay($uid, $cartType); 595 +
582 if (!$pay || empty($pay['data']['goods_list'])) { 596 if (!$pay || empty($pay['data']['goods_list'])) {
583 break; 597 break;
584 } 598 }
@@ -775,8 +789,7 @@ class CartModel @@ -775,8 +789,7 @@ class CartModel
775 789
776 //JIT拆单需求 package 790 //JIT拆单需求 package
777 $result['packages'] = self::getPackageInfo($pay['data']['shopping_cart_data']); 791 $result['packages'] = self::getPackageInfo($pay['data']['shopping_cart_data']);
778 - }  
779 - while (false); 792 + } while (false);
780 793
781 return $result; 794 return $result;
782 } 795 }
@@ -1403,11 +1416,23 @@ class CartModel @@ -1403,11 +1416,23 @@ class CartModel
1403 */ 1416 */
1404 public function addTicket($uid, $productSku, $buyNumber, $yohoNum = 0) 1417 public function addTicket($uid, $productSku, $buyNumber, $yohoNum = 0)
1405 { 1418 {
1406 - $data = CartData::addTicket($uid, $productSku, $buyNumber, $yohoNum);  
1407 - if (!empty($data['data'])) {  
1408 - return $data['data'];  
1409 - } 1419 + return CartData::addTicket($uid, $productSku, $buyNumber, $yohoNum);
  1420 + }
  1421 +
  1422 + /**
  1423 + * 订单确认-处理添加商品
  1424 + * @param int $uid 用户ID
  1425 + * @param type int $productSku 产品sku
  1426 + * @param type int $buyNumber 购买数量,范围1-4
  1427 + * @param type int $yohoNum yoho币
  1428 + * @return type
  1429 + */
  1430 + public function filterTicket($uid, $productSku, $buyNumber, $yohoNum = 0)
  1431 + {
  1432 + $cartType = 'advance';
  1433 +
  1434 + $data = self::addTicket($uid, $productSku, $buyNumber, $yohoNum);
1410 1435
1411 - return $data; 1436 + return self::filterCartPay($data, $cartType, false);
1412 } 1437 }
1413 } 1438 }
@@ -574,17 +574,24 @@ class IndexController extends WebAction @@ -574,17 +574,24 @@ class IndexController extends WebAction
574 $this->setTitle('填写订单', true, ' | '); 574 $this->setTitle('填写订单', true, ' | ');
575 $this->setSimpleHeader(); 575 $this->setSimpleHeader();
576 576
577 - $orderEnsure = CartModel::cartPay($uid, 'ordinary', false);  
578 - 577 +// $orderEnsure = CartModel::cartPay($uid, 'ordinary', false);
  578 +// print_r($orderEnsure);exit;
579 //产品sku 579 //产品sku
580 - $productSku = $this->post('productSku'); 580 +// $productSku = $this->post('productSku', 0);
  581 + $productSku = 178284;
581 //购买数量,范围1-4 582 //购买数量,范围1-4
582 $buyNumber = $this->post('buyNumber', 0); 583 $buyNumber = $this->post('buyNumber', 0);
583 //yoho币数量 584 //yoho币数量
584 $yohoNum = $this->post('yohoNum', 0); 585 $yohoNum = $this->post('yohoNum', 0);
585 // 执行加入购物车操作 586 // 执行加入购物车操作
586 -// $result = CartModel::addTicket($uid, $productSku, $buyNumber, $yohoNum);  
587 - 587 + $orderEnsure = CartModel::filterTicket($uid, $productSku, $buyNumber, $yohoNum);
  588 +// if (empty($orderEnsure)) {
  589 +// $this->error();
  590 +// }
  591 +
  592 +// print_r($orderEnsure);
  593 +// print_r($result);
  594 +// exit;
588 $this->_view->display('ticket-ensure', array( 595 $this->_view->display('ticket-ensure', array(
589 'ticketEnsurePage' => true, 596 'ticketEnsurePage' => true,
590 'orderEnsure' => $orderEnsure, 597 'orderEnsure' => $orderEnsure,
@@ -609,14 +616,14 @@ class IndexController extends WebAction @@ -609,14 +616,14 @@ class IndexController extends WebAction
609 break; 616 break;
610 } 617 }
611 //产品sku 618 //产品sku
612 - $productSku = $this->post('productSku'); 619 +// $productSku = $this->post('productSku', 0);
  620 + $productSku = 178284;
613 //购买数量,范围1-4 621 //购买数量,范围1-4
614 $buyNumber = $this->post('buyNumber', 0); 622 $buyNumber = $this->post('buyNumber', 0);
615 //yoho币数量 623 //yoho币数量
616 $yohoNum = $this->post('yohoNum', 0); 624 $yohoNum = $this->post('yohoNum', 0);
617 // 执行加入购物车操作 625 // 执行加入购物车操作
618 $result = CartModel::addTicket($uid, $productSku, $buyNumber, $yohoNum); 626 $result = CartModel::addTicket($uid, $productSku, $buyNumber, $yohoNum);
619 -// print_r($result);exit;  
620 627
621 } while (false); 628 } while (false);
622 629