... ... @@ -30,9 +30,15 @@ class Yohobuy
// const API_OLD = 'http://api2.open.yohobuy.com/';
// 测试环境 */
const API_URL = 'http://testapi.yoho.cn:28078/'; // 'http://192.168.102.205:8080/gateway/'
const SERVICE_URL = 'http://testservice.yoho.cn:28077/';
const YOHOBUY_URL = 'http://www.yohobuy.com/';
// const API_URL = 'http://testapi.yoho.cn:28078/'; // 'http://192.168.102.205:8080/gateway/'
// const SERVICE_URL = 'http://testservice.yoho.cn:28077/';
// const YOHOBUY_URL = 'http://www.yohobuy.com/';
#dev环境
const API_URL = 'http://devapi.yoho.cn:58078/'; // 'http://192.168.102.205:8080/gateway/'
const SERVICE_URL = 'http://devservice.yoho.cn:58077/';
const YOHOBUY_URL = 'http://www.yohobuy.com/';
const API_OLD = 'http://test2.open.yohobuy.com/';
/* 预览环境 */
// const API_URL = 'http://preapi.yoho.cn/';
... ...
... ... @@ -365,8 +365,7 @@ class CartData
* @param int $cartType 购物车类型ID
* @param int $deliveryTime 寄送时间ID
* @param int $deliveryWay 寄送方式ID
* @param string $invoiceTitle 发票说明
* @param int $invoiceId 发票类型ID
* @param array $invoices 发票参数数组
* @param int $paymentId 支付方式ID
* @param int $paymentType 支付类型ID
* @param string $remark 留言
... ... @@ -377,7 +376,7 @@ class CartData
* @param string|null $userAgent 联盟过来用户下单时需要的User-Agent信息
* @return array 接口返回的数据
*/
public static function orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin, $skuList, $qhyUnion, $userAgent)
public static function orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoices, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin, $skuList, $qhyUnion, $userAgent)
{
$param = Yohobuy::param();
$param['debug'] = 'Y';
... ... @@ -388,13 +387,22 @@ class CartData
$param['cart_type'] = $cartType;
$param['delivery_time'] = $deliveryTime;
$param['delivery_way'] = $deliveryWay;
if (!empty($invoiceTitle)) {
$param['invoices_title'] = $invoiceTitle;
if (!empty($invoices['invoices_type_id'])) {
//发票内容id--图书:1
$param['invoices_type_id'] = $invoices['invoices_type_id'];
}
if (!empty($invoiceId)) {
$param['invoices_type_id'] = $invoiceId;
if (!empty($invoices['invoices_type'])) {
//数字类型 发票类型 /**纸质 1 ,电子 2 */
$param['invoices_type'] = $invoices['invoices_type'];
}
if (!empty($invoices['receiverMobile'])) {
//发票人手机
$param['receiverMobile'] = $invoices['receiverMobile'];
}
if (!empty($invoices['invoices_title'])) {
//发票抬头 OR 填写单位名称,这二个是一个意思,只是叫法不一样
$param['invoices_title'] = $invoices['invoices_title'];
}
$param['payment_id'] = $paymentId;
$param['payment_type'] = $paymentType;
$param['remark'] = $remark;
... ...
... ... @@ -7,5 +7,6 @@
require('./cart');
require('./gift-advance');
require('./order-ensure');
require('./invoice-info');
require('./select-coupon');
require('./select-address');
... ...
/**
* 发票信息
* @author: wsl<shuiling.wang@yoho.cn>
* @date: 2016/6/14
*/
var $ = require('jquery'),
tip = require('../plugin/tip'),
dialog = require('../me/dialog'),
order = require('./order-info');
var $invoiceNotice = $('.invoice-notice'),
$companyArea = $('.company-area'),
$editFlag = $('.edit-flag'),
$chooseCont = $('.choose-cont'),
$invoiceType = $('.invoice-type'),
$tel = $('.tel'),
orderInfo = order.orderInfo,
$chooseContLi = $('.invoice-cont').find('.icon-cb-radio').parent();
var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/,
linkUrl = '/cart/index/orderEnsure?cartType=ordinary';
// var orderCont = window.cookie('order-info') && JSON.parse(window.cookie('order-info'));
// var invoiceCont = {
// 1: '服装',
// 2: '图书',
// 3: '配件',
// 4: '日用品',
// 5: '办公用品',
// 6: '体育用品',
// 7: '数码产品'
// },
// invoicesType = {
// 1: '电子',
// 2: '纸质'
// };
require('../common');
if (window.getUid() !== orderInfo('uid')) {
order.init();
window.location.reload();
}
//单选效果
function chooseAction(pDom, dom) {
if (dom.hasClass('icon-cb-radio')) {
return;
} else {
pDom.find('.choose').removeClass('icon-cb-radio icon-radio').addClass('icon-radio');
dom.removeClass('icon-radio').addClass('icon-cb-radio');
dom.parent().addClass('on');
dom.parent().siblings().removeClass('on');
$editFlag.val('true');
}
}
// 初始化页面数据
// function initData() {
// if (orderCont.invoicesType !== null) {
// $invoiceType.find('span').each(function() {
// if (parseInt($(this).data('id')) === orderCont.invoicesType) {
// $(this).addClass('on');
// } else {
// $(this).removeClass('on');
// }
// });
// }
// if (orderCont.invoiceType !== null) {
// chooseAction($invoiceCont, $invoiceCont.find('span').eq(orderCont.invoiceType-1))
// // $invoiceCont.find('span').each(function() {
// // if (parseInt($(this).data('id')) === orderCont.invoiceType) {
// // $(this).addClass('on');
// // } else {
// // $(this).removeClass('on');
// // }
// // });
// }
// }
// 确认表单事件
function confirmAction() {
var type = $invoiceType.find('.on').data('id'),
title = $('.invoice-top').find('.on').text(),
tel = $tel.data('tel'),
company = $('.company').val(),
cont = $chooseCont.data('id');
if ($editFlag.val() === 'true') {
if (!myreg.test($tel.data('tel'))) {
tip.show('请输入正确手机号');
$tel.focus();
return false;
} else {
dialog.showDialog({
dialogText: '确认保存修改内容?',
hasFooter: {
leftBtnText: '取消',
rightBtnText: '确定'
}
}, function() {
orderInfo('invoiceText', (title === '单位' ? company : ''));
orderInfo('invoiceType', cont);
orderInfo('receiverMobile', tel);
orderInfo('invoicesType', type);
orderInfo('invoiceTitle', title);
dialog.showDialog({
dialogText: '保存成功',
autoHide: true,
fast: true
});
window.location.href = linkUrl;
}, function() {
window.location.href = linkUrl;
});
}
} else {
window.location.href = linkUrl;
}
}
$chooseCont.html($chooseContLi.text()).attr('data-id', $chooseContLi.find('span').data('id'));
// 发票抬头、发票内容选择
$('.invoice-top span, .invoice-cont li').not('.invoice-cont .cont-title').on('touchstart', function(e) {
chooseAction($(this).parent(), $(this).find('.choose'));
if ($(this).parent().hasClass('invoice-cont')) {
$chooseCont.html($(this).text()).attr('data-id', $(this).find('span').data('id'));
}
if ($(this).text() === '单位') {
$companyArea.slideDown();
}
if ($(this).text() === '个人') {
$companyArea.slideUp();
}
});
// 发票类型选择
$('.invoice-type span').on('touchstart', function() {
if ($(this).hasClass('on')) {
return;
} else {
$(this).addClass('on').siblings().removeClass('on');
$editFlag.val('true');
}
});
// 发票须知
$('.invoice-btn').on('touchstart', function() {
$invoiceNotice.fadeIn();
return false;
});
// 关闭发票须知弹框
$('.think-ok, .mask-bg').on('touchstart', function() {
$invoiceNotice.fadeOut();
});
// 电话清空
$('.istel').one('input', function() {
$(this).val('').removeClass('istel');
});
$tel.on('input', function() {
$(this).attr('data-tel', $(this).val());
$editFlag.val('true');
});
$('.company').on('input', function() {
$editFlag.val('true');
});
// 确认及返回事件
$('.confirm-btn, .nav-back').on('touchstart', function(e) {
e.preventDefault();
confirmAction();
});
// initData();
\ No newline at end of file
... ...
... ... @@ -23,6 +23,21 @@ var $invoice = $('.invoice'),
dispatchInfo,
total;
var orderCont = window.cookie('order-info') && JSON.parse(window.cookie('order-info'));
var invoiceCont = {
1: '服装',
2: '图书',
3: '配件',
4: '日用品',
5: '办公用品',
6: '体育用品',
7: '数码产品'
},
invoicesType = {
1: '纸质',
2: '电子',
};
require('../common');
lazyLoad();
... ... @@ -107,9 +122,19 @@ $invoice.on('touchend', '.checkbox', function() {
if ($this.hasClass('icon-cb-radio')) {
$invoice.addClass('focus');
orderInfo('invoiceText', '');
orderInfo('invoiceType', '1');
orderInfo('receiverMobile', $('.user-mobile').val());
orderInfo('invoicesType', '2');
orderInfo('invoiceTitle', '个人');
}
if ($this.hasClass('icon-radio')) {
$invoice.removeClass('focus');
orderInfo('invoiceText', null);
orderInfo('invoiceType', null);
orderInfo('receiverMobile', null);
orderInfo('invoicesType', null);
orderInfo('invoiceTitle', null);
}
});
... ... @@ -189,16 +214,18 @@ function submitOrder() {
if (isSubmiting) {
return false;
}
if (orderInfo('invoice')) {
if (!invoiceText) {
tip.show('请输入发票抬头');
return;
}
if (invoiceText.length > 30) {
tip.show('发票抬头不得超过30个汉字');
return;
}
}
// if (orderInfo('invoice')) {
// if (!invoiceText) {
// tip.show('请输入发票抬头');
// return;
// }
// if (invoiceText.length > 30) {
// tip.show('发票抬头不得超过30个汉字');
// return;
// }
// }
if (msg) {
if (msg.length > 40) {
tip.show('留言不得超过40个汉字');
... ... @@ -373,3 +400,9 @@ if (orderInfo('address') && orderInfo('address').is_support === 'N') {
orderInfo('deliveryId', $('.delivery-id .icon-cb-radio').data('id'));
orderCompute();
}
if (orderCont.invoiceType) {
$('.invoice-type').text(invoiceCont[orderCont.invoiceType] + '(' + invoicesType[orderCont.invoicesType] + ')');
} else {
$('.invoice-type').text('服装(电子)');
}
\ No newline at end of file
... ...
... ... @@ -21,6 +21,9 @@ function init() {
invoice: null,
invoiceText: null,
invoiceType: null,
invoiceTitle: null,
receiverMobile: null,
invoicesType: null,
msg: null,
cartType: 'ordinary'
};
... ...
... ... @@ -2,6 +2,7 @@
@import "chose-panel";
@import "gift-advance-good";
@import "order-ensure";
@import "invoice-info";
@import "select-coupon";
@import "select-address";
... ...
.invoice-info-page {
background: #f0f0f0;
.invoice-btn {
position: absolute;
right: 30px;
width: auto;
font-size: 28px;
}
.title {
color: #444;
font-size: 28px;
float: left;
}
.invoice-form {
background: #fff;
border-bottom: 1px solid #e0e0e0;
padding: 0 30px;
box-sizing: border-box;
overflow: hidden;
li {
width: 100%;
clear: both;
margin-top: 15px;
line-height: 60px;
float: left;
}
li:first-child {
margin-bottom: 15px;
}
li:last-child {
margin-bottom: 10px;
}
.company {
width: 100%;
height: 88px;
line-height: 88px;
border-radius: 8px;
border: 1px solid #e0e0e0;
font-size: 28px;
color: #b0b0b0;
padding: 0 20px;
margin-bottom: 15px;
}
.tel {
border: none;
font-size: 28px;
line-height: 60px;
}
.invoice-type {
float: left;
span {
width: 120px;
height: 60px;
line-height: 60px;
text-align: center;
font-size: 24px;
color: #b0b0b0;
border-radius: 5px;
border: 1px solid #b0b0b0;
display: inline-block;
background: #fff;
margin-right: 20px;
}
.on {
background: #444;
border-color: #444;
color: #fff;
}
}
.invoice-top {
float: left;
span {
color: #444;
font-size: 28px;
margin-right: 55px;
}
}
.phone {
color: #b0b0b0;
font-size: 28px;
}
}
.invoice-cont {
background: #fff;
margin-top: 30px;
border-top: 1px solid #e0e0e0;
padding: 0 30px;
box-sizing: border-box;
color: #444;
font-size: 28px;
line-height: 48px;
overflow: hidden;
padding-bottom: 20px;
li {
width: 100%;
margin-top: 28px;
float: left;
}
.choose-cont {
float: right;
}
}
.choose {
font-size: 44px;
display: inline-block;
vertical-align: top;
margin-right: 20px;
}
.icon-radio {
color: #b0b0b0;
}
.btn-area {
width: 100%;
border-top: 1px solid #e0e0e0;
background: #fff;
.confirm-btn {
width: 259px;
height: 88px;
line-height: 88px;
text-align: center;
background: #d0021b;
color: #fff;
display: block;
margin: 0 auto;
border-radius: 8px;
font-size: 28px;
margin-top: 18px;
}
}
.invoice-notice {
position: fixed;
left: 0;
right: 0;
top: 0;
bottom: 0;
display: none;
z-index: 9;
.mask-bg {
background: rgba(0,0,0,0.4);
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
.notice-area {
width: 540px;
height: 400px;
background: #fafafa;
border-radius: 10px;
transform: translate(-50%, -50%);
position: absolute;
top: 50%;
left: 50%;
.notice-cont {
padding: 40px;
}
h2 {
text-align: center;
font-size: 28px;
color: #444;
padding-bottom: 4px;
}
p {
font-size: 24px;
color: #444;
line-height: 38px;
}
.think-ok {
width: 100%;
border-top: 1px solid #c5c5c5;
height: 90px;
line-height: 90px;
box-sizing: border-box;
text-align: center;
color: #d1021c;
font-size: 34px;
}
}
}
}
\ No newline at end of file
... ...
... ... @@ -495,6 +495,12 @@
#invoice {
border-top: 1px solid #f7f7f7;
.invoice-type {
float: right;
font-size: 28px;
color: #444;
}
label {
display: block;
border-top: 1px solid #f7f7f7;
... ...
... ... @@ -263,4 +263,28 @@
}
}
}
.invoice-info {
margin: 20px 0;
border-top: 1px solid #e0e0e0;
border-bottom: 1px solid #e0e0e0;
background: #fff;
padding: 30px;
box-sizing: border-box;
overflow: hidden;
span {
font-size: 28px;
color: #444;
line-height: 40px;
}
.invoice-fr {
float: right;
}
.invoice-see {
color: #d0021b;
}
}
}
... ...
<div class="invoice-info-page yoho-page">
{{> layout/header}}
<ul class="invoice-form">
<li>
<span class="title">发票类型:</span>
<div class="invoice-type">
{{#invoicesType}}
<span {{#if choosed}}class="on"{{/if}} data-id="{{id}}">{{type}}</span>
{{/invoicesType}}
</div>
</li>
<li>
<span class="title">发票抬头:</span>
<div class="invoice-top">
{{#invoiceTitle}}
<span {{#if choosed}}class="on"{{/if}}><i class="iconfont choose {{#if choosed}}icon-cb-radio{{else}}icon-radio{{/if}}"></i>{{type}}</span>
{{/invoiceTitle}}
</div>
</li>
<li>
<span class="title">*发票人手机:</span>
<span class="phone">
<input type="text" name="tel" data-tel="{{completeTel}}" class="tel {{#phone}}istel{{/phone}}" value="{{phone}}" placeholder="可通过手机号在发票服务平台查询">
</span>
</li>
<li class="company-area" {{#isCompany}}style="display: none;"{{/isCompany}}><input type="text" name="company" class="company" value="{{companyName}}" placeholder="填写单位名称"></li>
</ul>
<ul class="invoice-cont">
<li class="cont-title">
<span>发票内容:</span>
<span class="choose-cont" data-id=""></span>
</li>
{{#each content}}
<li><span class="iconfont choose {{#if choosed}}icon-cb-radio{{else}}icon-radio{{/if}}" data-id="{{id}}"></span>{{text}}</li>
{{/each}}
</ul>
<div class="btn-area"><span class="confirm-btn">确认</span></div>
<div class="invoice-notice">
<div class="mask-bg"></div>
<div class="notice-area">
<div class="notice-cont">
<h2>发票须知</h2>
<p>1、发票金额不含优惠券/YOHO币/红包/优惠码/运费,只包含商品实付金额</p>
<p>2、电子发票:是税局认可的有效收付款凭证,其法律效力、基本用途及使用规定同纸质发票,如需纸质发票可自行下载打印</p>
</div>
<div class="think-ok">我知道了</div>
</div>
</div>
<input type="hidden" class="edit-flag" value="false" />
{{> layout/footer}}
</div>
... ...
... ... @@ -141,9 +141,14 @@
{{#if invoice}}
<li class="invoice {{#if needInvoice}}focus{{/if}}">
<input type="hidden" class="user-mobile" value="{{userMobile}}" />
<span class="title">发票</span>
<span class="iconfont checkbox {{#if needInvoice}}icon-cb-radio{{else}}icon-radio{{/if}}"></span>
<form id="invoice">
<a id="invoice" class="invoice-info" href="invoiceInfo">
<span class="title">发票信息</span>
<span class="invoice-type"><i class="iconfont">&#xe614;</i></span>
</a>
<!-- <form id="invoice">
<input type="text" name="invoice-title" value="{{invoiceText}}" maxlength="30" placeholder="发票抬头">
<label>
发票类型
... ... @@ -153,7 +158,7 @@
{{/ invoice}}
</select>
</label>
</form>
</form> -->
</li>
{{/if}}
</ul>
... ...
... ... @@ -92,6 +92,28 @@
</p>
{{/if}}
{{#invoice}}
<ul class="invoice-info">
<li>
<span>发票信息</span>
<span class="invoice-fr">{{#if type}}电子发票{{else}}纸质发票{{/if}}</span>
</li>
<li>
<span>发票抬头</span>
<span class="invoice-fr">{{title}}</span>
</li>
<li>
<span>发票内容</span>
<span class="invoice-fr">{{contentValue}}</span>
</li>
{{#if pdfUrl}}
<li>
<a href="{{pdfUrl}}"><span class="invoice-fr invoice-see">点击下载PDF发票</span></a>
</li>
{{/if}}
</ul>
{{/invoice}}
<div class="opt block">
{{#unless unreceived}}
{{#unless unpaid}}
... ...
... ... @@ -27,6 +27,9 @@
{{#orderDetail}}
<a href="{{serviceUrl}}" target="_blank" class="iconfont nav-home">&#xe63c;</a>
{{/orderDetail}}
{{#invoiceNotice}}
<span class="invoice-btn">{{.}}</span>
{{/invoiceNotice}}
</header>
{{#navBtn}}
<div class="homebuttom hide {{#if ../boys}} boys{{/if}}{{#if ../girls}} girls{{/if}}{{#if ../kids}} kids{{/if}}{{#if ../lifeStyle}} life-style{{/if}}">
... ...
... ... @@ -251,6 +251,11 @@
seajs.use('js/cart/order-ensure');
</script>
{{/if}}
{{#if invoiceInfoPage}}
<script>
seajs.use('js/cart/invoice-info');
</script>
{{/if}}
{{#if selectAddressPage}}
<script>
seajs.use('js/me/address');
... ...
... ... @@ -1073,6 +1073,7 @@ class HomeController extends AbstractAction
$this->_view->display('order-detail', array(
'orderDetailPage' => true,
'invoice' => empty($orderDetail['invoice']) ? array() : $orderDetail['invoice'],
'serviceUrl' => 'http://chat8.live800.com/live800/chatClient/chatbox.jsp?companyID=620092&configID=149091&jid=8732423409&info=',
'orderDetail' => $orderDetail,
'orderCode' => $orderCode,
... ...
... ... @@ -240,6 +240,33 @@ class OrderModel
$result['isJit'] = true;
$result['jitDetailUrl'] = Helpers::url('/cart/index/jitDetail', array('orderCode' => $orderCode, 'sessionKey' => $sessionKey));
}
$result['invoice'] = array();
//电子发票
do{
if(empty($orderDetail['data']['invoice']) || !isset($orderDetail['data']['invoice'])){
break;
}
//判断是否显示电子发票
if($orderDetail['data']['invoice']['showInvoice'] == false || empty($orderDetail['data']['invoice']['showInvoice'])){
break;
}
//pdf下载地址
if(empty($orderDetail['data']['invoice']['pdfUrl']) || !isset($orderDetail['data']['invoice']['pdfUrl'])){
break;
}
$result['invoice'] = $orderDetail['data']['invoice'];
//纸质 1,电子 2
$result['invoice']['type'] = $result['invoice']['type'] * 1 === 2 ? true : false;
}
while(false);
// $result['invoice'] = array(
// 'type' => true,//-- 纸质 false,电子 true
// 'title' => '发票抬头',// --发票抬头
// 'contentValue' => '服饰',//-- 发票内容
// 'mobilePhone' => '13651898702',//--电话
// 'pdfUrl' => 'http://redmine.yoho.cn/attachments/download/2732/%E7%94%B5%E5%AD%90%E5%8F%91%E7%A5%A8-wap%E7%AB%AF.pdf',//--pdf下载地址
// );
}
//取消订单原因列表
$resons = OrderData::closeReasons();
... ...
... ... @@ -571,14 +571,11 @@ class CartModel
// 发票有关数据
if (isset($payReturn['invoices']) && !empty($payReturn['invoices'])) {
$one = array();
foreach ($payReturn['invoices']['invoices_type_list'] as $inv) {
$one = array();
$one['id'] = $inv['invoices_type_id'];
$one['name'] = $inv['invoices_type_name'];
isset($orderInfo['invoiceType']) && $one['id'] == $orderInfo['invoiceType'] && $one['isSelected'] = true;
$result['invoice'][] = $one;
foreach ($payReturn['invoices']['invoiceContentList'] as $inv) {
$result['invoice'][] = array(
'id' => $inv['invoices_type_id'],
'name' => $inv['invoices_type_name'],
);
}
// 发票信息需要记录
... ... @@ -739,8 +736,7 @@ class CartModel
* @param int $cartType 购物车类型ID
* @param int $deliveryTime 寄送时间ID
* @param int $deliveryWay 寄送方式ID
* @param string $invoiceTitle 发票说明
* @param int $invoiceId 发票类型ID
* @param array $invoices 发票参数数组
* @param int $paymentId 支付方式ID
* @param int $paymentType 支付类型ID
* @param string $remark 留言
... ... @@ -751,7 +747,7 @@ class CartModel
* @param string|null $userAgent 联盟过来用户下单时需要的User-Agent信息
* @return array 接口返回的数据
*/
public static function orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin, $skuList, $qhyUnio = '', $userAgent = null)
public static function orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoices, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin, $skuList, $qhyUnio = '', $userAgent = null)
{
$result = array('code' => 400, 'message' => '出错啦');
... ... @@ -769,7 +765,7 @@ class CartModel
$result['message'] = '请选择配送方式';
}
else {
$orderSubRes = CartData::orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin, $skuList, $qhyUnio, $userAgent);
$orderSubRes = CartData::orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoices, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin, $skuList, $qhyUnio, $userAgent);
UdpLog::info('【结算信息】接口返回','orderSubRes'.json_encode($orderSubRes));
if ($orderSubRes && isset($orderSubRes['code'])) {
$result = $orderSubRes;
... ...
... ... @@ -5,9 +5,8 @@ use Hood\Core\Security\AuthCode;
use Index\CartModel;
use Index\UserModel;
use Plugin\Helpers;
use Plugin\UnionTrans;
use Home\OrderModel;
use Plugin\UdpLog;
use LibModels\Wap\Home\UserData;
/**
* 购物车相关的控制器
... ... @@ -332,11 +331,13 @@ class IndexController extends AbstractAction
$this->echoJson($order);
return;
}
$userData = UserData::userData($uid);
$mobile = empty($userData['data']) || empty($userData['data']['mobile']) ? '' : $userData['data']['mobile']; //发票人手机
$data = array(
'orderEnsurePage' => true,
'isOrdinaryCart' => ($cartType !== 'advance'),
'orderEnsure' => $order
'orderEnsure' => $order,
'userMobile' => $mobile
);
$this->setTitle('确认订单');
... ... @@ -346,6 +347,108 @@ class IndexController extends AbstractAction
}
/**
* 发票信息
*/
public function invoiceInfoAction()
{
$uid = $this->getUid();
if (!$uid) {
$this->go(Helpers::url('/signin.html', array('refer' => $this->server('HTTP_REFERER', SITE_MAIN))));
}
$cookieData = $this->getCookie('order-info', null); //从缓存中获取电子发票信息
$userData = UserData::userData($uid);
$userMobile = empty($userData['data']) || empty($userData['data']['mobile']) ? '' : $userData['data']['mobile']; //发票人手机
if (!empty($cookieData)) {
$orderInfo = json_decode($cookieData, true);
$invoiceType = $orderInfo['invoiceType']; //发票类型ID
$invoices_type = $orderInfo['invoicesType'] * 1; //发票类型 /**纸质 1 ,电子 2 */
$mobile = isset($orderInfo['receiverMobile']) && !empty($orderInfo['receiverMobile']) ? $orderInfo['receiverMobile'] : $userMobile; //发票人手机
$invoices_title = $orderInfo['invoiceText']; //发票抬头
$invoice_Top = $orderInfo['invoiceTitle'];
}
else {
$userData = UserData::userData($uid);
$mobile = $userMobile; //发票人手机
$invoiceType = '1'; //发票类型ID
$invoices_type = '2'; //发票类型 /**纸质 1 ,电子 2 */
$invoice_Top = '个人';
}
$data = array(
'invoiceInfoPage' => true,
'invoiceNotice' => '发票须知',
'phone' => $mobile ? substr_replace($mobile, '****', 3, 4) : '',
'completeTel' => $mobile,
'isCompany' => $invoice_Top ? false : true,
'companyName' => $invoices_title,
'invoicesType' => array(
array(
'id' => '2',
'type' => '电子发票',
'choosed' => empty($invoices_type) || $invoices_type == 2 ? true : false,
),
array(
'id' => '1',
'type' => '纸质发票',
'choosed' => $invoices_type == 1 ? true : false,
)
),
'invoiceTitle' => array(
array(
'type' => '个人',
'choosed' => !isset($invoices_title) ? true : false,
),
array(
'type' => '单位',
'choosed' => isset($invoices_title) ? true : false,
)
),
'content' => array(
array(
'choosed' => $invoiceType == 3 ? true : false,
'id' => 3,
'text' => '配件'
),
array(
'choosed' => $invoiceType == 2 ? true : false,
'id' => 2,
'text' => '图书'
),
array(
'choosed' => empty($invoices_type) || $invoiceType == 1 ? true : false,
'id' => 1,
'text' => '服装'
),
array(
'choosed' => $invoiceType == 4 ? true : false,
'id' => 4,
'text' => '日用品'
),
array(
'choosed' => $invoiceType == 7 ? true : false,
'id' => 7,
'text' => '数码产品'
),
array(
'choosed' => $invoiceType == 6 ? true : false,
'id' => 6,
'text' => '体育用品'
),
array(
'choosed' => $invoiceType == 5 ? true : false,
'id' => 5,
'text' => '办公用品'
)
)
);
$this->setTitle('发票信息');
$this->setNavHeader('发票信息', true, false); // 不显示右上角home按钮
$this->_view->display('invoice-info', $data);
}
/**
* 购物车选择改变字段,重新运算订单数据
*/
public function orderComputeAction()
... ... @@ -454,14 +557,22 @@ class IndexController extends AbstractAction
$cartType = $this->post('cartType', 'ordinary'); // 默认普通购物车
$deliveryTime = $this->post('deliveryTimeId', 1); // 默认只工作日配送
$deliveryWay = $this->post('deliveryId', 1); // 默认普通快递
$invoiceTitle = $this->post('invoiceText', null);
$invoiceId = $this->post('invoiceType', null);
$paymentId = $this->post('paymentTypeId', 15);
$paymentType = $this->post('paymentType', 1); // 默认在线支付
$remark = $this->post('msg', null);
$couponCode = $this->post('couponCode', null);
$yohoCoin = $this->post('yohoCoin', 1);
$skuList = $this->post('skuList', '');
$cookieData = $this->getCookie('order-info', null); //获取电子发票信息
//电子发票信息数组
$invoices = array();
if (!empty($cookieData)) {
$orderInfo = json_decode($cookieData, true);
$invoices['invoices_type_id'] = $orderInfo['invoiceType']; //发票类型ID
$invoices['invoices_type'] = $orderInfo['invoicesType']; //发票类型 /**纸质 1 ,电子 2 */
$invoices['receiverMobile'] = $orderInfo['receiverMobile']; //发票人手机
$invoices['invoices_title'] = empty($orderInfo['invoiceText']) ? '个人' : $orderInfo['invoiceText']; //发票抬头
}
/* 判断是否是友盟过来的用户 */
$userAgent = null;
... ... @@ -474,16 +585,14 @@ class IndexController extends AbstractAction
/* 模拟APP的User-Agent */
$userAgent = isset($unionInfo['client_id']) ? 'YOHO!Buy/3.8.2.259(Model/PC;Channel/' . $unionInfo['client_id'] . ';uid/' . $uid . ')' : null;
}
$result = CartModel::orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin, $skuList, $unionKey, $userAgent);
$result = CartModel::orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoices, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin, $skuList, $unionKey, $userAgent);
// 记录下单异常的数据
if (empty($result)) {
$message = 'uid:' . $uid . ',addressId:' . $addressId . ',cartType:' . $cartType . ',deliveryTime:' . $deliveryTime
. ',deliveryWay:' . $deliveryWay . 'invoiceTitle:' . $invoiceTitle . ',invoiceId:' . $invoiceId . ',yohoCoin:' . $yohoCoin
. ',deliveryWay:' . $deliveryWay . ',yohoCoin:' . $yohoCoin
. ',paymentId:' . $paymentId . ',paymentType:' . $paymentType . ',remark:' . $remark . ',couponCode:' . $couponCode . "\n";
error_log($message, 3, '/Data/logs/php/h5_error/order.' . date('Ym') . '.log');
UdpLog::info('【下单】下单异常数据','message:'.$message,'返回:'.json_encode($result));
UdpLog::info('【下单】下单异常数据', 'message:' . $message, '返回:' . json_encode($result));
}
// 返回数据
else {
... ... @@ -492,14 +601,6 @@ class IndexController extends AbstractAction
$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
}
} */
}
else {
echo ' ';
... ...