Authored by 毕凯

Merge remote-tracking branch 'origin/master' into release/6.0.2

@@ -176,10 +176,22 @@ class BuyNowController { @@ -176,10 +176,22 @@ class BuyNowController {
176 176
177 // 是否开发票 177 // 是否开发票
178 if (req.body.invoice && req.body.invoice === 'true') { 178 if (req.body.invoice && req.body.invoice === 'true') {
  179 + let invoicePayableType = _.parseInt(req.body.invoice_payable_type);
  180 + let invoicesTitlePersonal = req.body.invoices_title_personal ? req.body.invoices_title_personal : '个人';
  181 +
179 params.invoice = true; 182 params.invoice = true;
180 params.invoices_type = req.body.invoices_type; // 发票类型:纸质 1,电子 2 183 params.invoices_type = req.body.invoices_type; // 发票类型:纸质 1,电子 2
181 - params.invoices_title = req.body.invoices_title || '个人'; // 发票抬头,个人前端不传此值  
182 params.receiverMobile = req.body.receiverMobile; // 接收人电话 184 params.receiverMobile = req.body.receiverMobile; // 接收人电话
  185 + params.invoice_payable_type = req.body.invoice_payable_type; // 区分个人或企业发票
  186 +
  187 + if (invoicePayableType === 1) {
  188 + // 开个人发票
  189 + params.invoices_title = invoicesTitlePersonal;
  190 + } else {
  191 + // 开公司发票
  192 + params.invoices_title = req.body.invoices_title;
  193 + params.buyerTaxNumber = req.body.buyerTaxNumber;
  194 + }
183 195
184 // 购买方纳税人识别号 196 // 购买方纳税人识别号
185 if (req.body.buyerTaxNumber) { 197 if (req.body.buyerTaxNumber) {
@@ -202,18 +202,24 @@ exports.orderSub = (req, res, next) => { @@ -202,18 +202,24 @@ exports.orderSub = (req, res, next) => {
202 // 电子发票信息数组 202 // 电子发票信息数组
203 let invoices = {}; 203 let invoices = {};
204 204
  205 + // 是否有发票数据
205 if (orderInfo && orderInfo.invoice) { 206 if (orderInfo && orderInfo.invoice) {
206 - let invoices_title_personal = orderInfo.invoices_title_personal ? orderInfo.invoices_title_personal : '个人'; 207 + let invoicePayableType = _.parseInt(orderInfo.invoice_payable_type);
  208 + let invoicesTitlePersonal = orderInfo.invoices_title_personal ? orderInfo.invoices_title_personal : '个人';
207 209
208 invoices = { 210 invoices = {
209 invoices_type_id: 12, // 发票类型写死【明细】 211 invoices_type_id: 12, // 发票类型写死【明细】
210 invoices_type: orderInfo.invoices_type, // 区分电子发票还是纸质发票 212 invoices_type: orderInfo.invoices_type, // 区分电子发票还是纸质发票
211 receiverMobile: orderInfo.receiverMobile, // 电话 213 receiverMobile: orderInfo.receiverMobile, // 电话
212 - invoices_title: orderInfo.invoices_title ? orderInfo.invoices_title : invoices_title_personal 214 + invoice_payable_type: orderInfo.invoice_payable_type // 区分个人或企业发票
213 }; 215 };
214 216
215 - // 购买方纳税人识别号  
216 - if (orderInfo.buyerTaxNumber) { 217 + if (invoicePayableType === 1) {
  218 + // 开个人发票
  219 + invoices.invoices_title = invoicesTitlePersonal;
  220 + } else {
  221 + // 开公司发票
  222 + invoices.invoices_title = orderInfo.invoices_title;
217 invoices.buyerTaxNumber = orderInfo.buyerTaxNumber; 223 invoices.buyerTaxNumber = orderInfo.buyerTaxNumber;
218 } 224 }
219 } 225 }
@@ -137,6 +137,11 @@ class BuyNowModel extends global.yoho.BaseModel { @@ -137,6 +137,11 @@ class BuyNowModel extends global.yoho.BaseModel {
137 finalParams.invoices_type = params.invoices_type; 137 finalParams.invoices_type = params.invoices_type;
138 } 138 }
139 139
  140 + // 发票类型:个人 1, 企业 2
  141 + if (params.invoice_payable_type) {
  142 + finalParams.invoice_payable_type = params.invoice_payable_type;
  143 + }
  144 +
140 // 发票抬头 145 // 发票抬头
141 if (params.invoices_title) { 146 if (params.invoices_title) {
142 finalParams.invoices_title = params.invoices_title; 147 finalParams.invoices_title = params.invoices_title;
@@ -185,6 +185,11 @@ exports.orderSub = (uid, addressId, cartType, deliveryTime, @@ -185,6 +185,11 @@ exports.orderSub = (uid, addressId, cartType, deliveryTime,
185 params.invoices_type = invoices.invoices_type; 185 params.invoices_type = invoices.invoices_type;
186 } 186 }
187 187
  188 + // 发票类型:个人 1, 企业 2
  189 + if (invoices.invoice_payable_type) {
  190 + params.invoice_payable_type = invoices.invoice_payable_type;
  191 + }
  192 +
188 // 收票人手机号码 193 // 收票人手机号码
189 if (invoices.receiverMobile) { 194 if (invoices.receiverMobile) {
190 params.receiverMobile = invoices.receiverMobile; 195 params.receiverMobile = invoices.receiverMobile;
1 { 1 {
2 "name": "m-yohobuy-node", 2 "name": "m-yohobuy-node",
3 - "version": "6.0.12", 3 + "version": "6.0.13",
4 "private": true, 4 "private": true,
5 "description": "A New Yohobuy Project With Express", 5 "description": "A New Yohobuy Project With Express",
6 "repository": { 6 "repository": {
@@ -275,9 +275,16 @@ function submitOrder() { @@ -275,9 +275,16 @@ function submitOrder() {
275 invoice: orderInfo('invoice'), 275 invoice: orderInfo('invoice'),
276 invoices_title: orderInfo('invoices_title'), // 发票抬头 276 invoices_title: orderInfo('invoices_title'), // 发票抬头
277 invoices_type: orderInfo('invoices_type'), // 发票类型 1 纸质 2 电子 277 invoices_type: orderInfo('invoices_type'), // 发票类型 1 纸质 2 电子
  278 + invoice_payable_type: orderInfo('invoice_payable_type'), // 发票类型 1 个人 2 企业
278 receiverMobile: orderInfo('receiverMobile'), // 接收人电话 279 receiverMobile: orderInfo('receiverMobile'), // 接收人电话
279 buyerTaxNumber: orderInfo('buyerTaxNumber') // 购买方纳税人识别号,需要开具 280 buyerTaxNumber: orderInfo('buyerTaxNumber') // 购买方纳税人识别号,需要开具
280 }); 281 });
  282 +
  283 + if (orderInfo('invoices_title_personal')) {
  284 + Object.assign(postData, {
  285 + invoices_title_personal: orderInfo('invoices_title_personal')
  286 + });
  287 + }
281 } 288 }
282 289
283 $.ajax({ 290 $.ajax({
@@ -127,10 +127,18 @@ function confirmAction() { @@ -127,10 +127,18 @@ function confirmAction() {
127 } 127 }
128 }, function() { 128 }, function() {
129 orderInfo('invoices_type', eInvoiceType); 129 orderInfo('invoices_type', eInvoiceType);
130 - orderInfo('invoices_title', title === '单位' ? company : '');  
131 - orderInfo('invoices_title_personal', title === '个人' ? company : '');  
132 orderInfo('receiverMobile', tel); 130 orderInfo('receiverMobile', tel);
133 - orderInfo('buyerTaxNumber', title === '单位' ? buyerTaxNumber : ''); 131 +
  132 + if (title === '单位') {
  133 + orderInfo('invoice_payable_type', 2);
  134 + orderInfo('invoices_title', company);
  135 + orderInfo('invoices_title_personal', null);
  136 + orderInfo('buyerTaxNumber', buyerTaxNumber);
  137 + } else {
  138 + orderInfo('invoice_payable_type', 1);
  139 + orderInfo('invoices_title', null);
  140 + orderInfo('invoices_title_personal', company);
  141 + }
134 142
135 if (isModifyTel && $copyTel !== tel) { 143 if (isModifyTel && $copyTel !== tel) {
136 orderInfo('isModifyTel', true); 144 orderInfo('isModifyTel', true);
@@ -2,7 +2,6 @@ @@ -2,7 +2,6 @@
2 * @Author: Targaryen 2 * @Author: Targaryen
3 * @Date: 2017-06-22 13:51:16 3 * @Date: 2017-06-22 13:51:16
4 * @Last Modified by: Targaryen 4 * @Last Modified by: Targaryen
5 - * @Last Modified time: 2017-06-26 17:47:49  
6 */ 5 */
7 require('common'); 6 require('common');
8 let info = window.cookie('buynow_info'); 7 let info = window.cookie('buynow_info');
@@ -127,10 +127,18 @@ function confirmAction() { @@ -127,10 +127,18 @@ function confirmAction() {
127 } 127 }
128 }, function() { 128 }, function() {
129 orderInfo('invoices_type', eInvoiceType); 129 orderInfo('invoices_type', eInvoiceType);
130 - orderInfo('invoices_title', title === '单位' ? company : '');  
131 - orderInfo('invoices_title_personal', title === '个人' ? company : '');  
132 orderInfo('receiverMobile', tel); 130 orderInfo('receiverMobile', tel);
133 - orderInfo('buyerTaxNumber', title === '单位' ? buyerTaxNumber : ''); 131 +
  132 + if (title === '单位') {
  133 + orderInfo('invoice_payable_type', 2);
  134 + orderInfo('invoices_title', company);
  135 + orderInfo('invoices_title_personal', null);
  136 + orderInfo('buyerTaxNumber', buyerTaxNumber);
  137 + } else {
  138 + orderInfo('invoice_payable_type', 1);
  139 + orderInfo('invoices_title', null);
  140 + orderInfo('invoices_title_personal', company);
  141 + }
134 142
135 if (isModifyTel && $copyTel !== tel) { 143 if (isModifyTel && $copyTel !== tel) {
136 orderInfo('isModifyTel', true); 144 orderInfo('isModifyTel', true);