Showing
7 changed files
with
63 additions
and
19 deletions
@@ -40,7 +40,7 @@ const online = (req, res, next) => { | @@ -40,7 +40,7 @@ const online = (req, res, next) => { | ||
40 | order.payment_type = parseInt(order.payment_type, 10); | 40 | order.payment_type = parseInt(order.payment_type, 10); |
41 | 41 | ||
42 | if (amount <= 0 || order.payment_type === 2) { | 42 | if (amount <= 0 || order.payment_type === 2) { |
43 | - PayData.deliveryData(order).then(orderInfo => { | 43 | + PayData.deliveryData(order, PayData.payments.delivery).then(orderInfo => { |
44 | res.render('pay-success', { | 44 | res.render('pay-success', { |
45 | simpleHeader: header, | 45 | simpleHeader: header, |
46 | order: orderInfo, | 46 | order: orderInfo, |
@@ -150,7 +150,7 @@ const Payment = { | @@ -150,7 +150,7 @@ const Payment = { | ||
150 | PayData.sendPayConfirm(payResult.orderCode, payId, user.uid); | 150 | PayData.sendPayConfirm(payResult.orderCode, payId, user.uid); |
151 | } | 151 | } |
152 | 152 | ||
153 | - payData = yield PayData.procOrderData(payResult, user.uid); | 153 | + payData = yield PayData.procOrderData(payResult, user.uid, payId); |
154 | } else { | 154 | } else { |
155 | payData = { | 155 | payData = { |
156 | code: 500, | 156 | code: 500, |
@@ -175,7 +175,7 @@ const Payment = { | @@ -175,7 +175,7 @@ const Payment = { | ||
175 | case PayData.payments.wechat: // 微信支付不须要验证,但前端必须校验sign | 175 | case PayData.payments.wechat: // 微信支付不须要验证,但前端必须校验sign |
176 | delete query.sign; | 176 | delete query.sign; |
177 | if (md5(paySign.raw(Object.assign({tradeStatus: 'Y'}, query))) === sign) { | 177 | if (md5(paySign.raw(Object.assign({tradeStatus: 'Y'}, query))) === sign) { |
178 | - payData = yield PayData.procOrderData(query, user.uid); | 178 | + payData = yield PayData.procOrderData(query, user.uid, payId); |
179 | } | 179 | } |
180 | payData.payName = '微信'; | 180 | payData.payName = '微信'; |
181 | break; | 181 | break; |
@@ -15,9 +15,13 @@ const _ = require('lodash'); | @@ -15,9 +15,13 @@ const _ = require('lodash'); | ||
15 | const helpers = global.yoho.helpers; | 15 | const helpers = global.yoho.helpers; |
16 | const FRAUD_CONTENT_CODE = '78d0fb6c97d691863286edcb4d8abfa9'; | 16 | const FRAUD_CONTENT_CODE = '78d0fb6c97d691863286edcb4d8abfa9'; |
17 | const payments = { | 17 | const payments = { |
18 | - alipay: 2, | ||
19 | - wechat: 21, | ||
20 | - alibank: 12 | 18 | + alipay: 2, // 支付宝 |
19 | + wechat: 21, // 微信支付 | ||
20 | + alibank: 12, // 支付宝支联 | ||
21 | + unionpayweb: 25, // 银联支付 | ||
22 | + chinabank: 4, // 网银在线 | ||
23 | + tenpay: 1, // 财付通 | ||
24 | + delivery: 3 // 货到付款和0元订单 | ||
21 | }; | 25 | }; |
22 | 26 | ||
23 | /** | 27 | /** |
@@ -246,10 +250,18 @@ const sendPayConfirm = (code, payment, uid) => { | @@ -246,10 +250,18 @@ const sendPayConfirm = (code, payment, uid) => { | ||
246 | * [公共支付成功数据处理] | 250 | * [公共支付成功数据处理] |
247 | * @param {[type]} orderInfo [订单信息] | 251 | * @param {[type]} orderInfo [订单信息] |
248 | * @param {[type]} fraudData [资源位数据] | 252 | * @param {[type]} fraudData [资源位数据] |
253 | + * @param {[type]} payId [支付方式ID] | ||
249 | * @return {[type]} [{}] | 254 | * @return {[type]} [{}] |
250 | */ | 255 | */ |
251 | -const _execOrderData = (orderInfo, fraudData) => { | 256 | +const _execOrderData = (orderInfo, fraudData, payId) => { |
252 | let fraud = _.result(_.find(fraudData, {template_name: 'text'}), 'data') || {}; | 257 | let fraud = _.result(_.find(fraudData, {template_name: 'text'}), 'data') || {}; |
258 | + let sknArr = []; | ||
259 | + let skuArr = []; | ||
260 | + | ||
261 | + _.each(orderInfo.order_goods, function(el) { | ||
262 | + sknArr.push(el.product_skn); | ||
263 | + skuArr.push(el.product_sku); | ||
264 | + }); | ||
253 | 265 | ||
254 | return { | 266 | return { |
255 | paymentTypes: (orderInfo.payment_type === 1 ? '在线支付' : '货到付款'), | 267 | paymentTypes: (orderInfo.payment_type === 1 ? '在线支付' : '货到付款'), |
@@ -262,7 +274,20 @@ const _execOrderData = (orderInfo, fraudData) => { | @@ -262,7 +274,20 @@ const _execOrderData = (orderInfo, fraudData) => { | ||
262 | orderCode: orderInfo.order_code | 274 | orderCode: orderInfo.order_code |
263 | }), | 275 | }), |
264 | packageTitle: orderInfo.package_title || '商品需要品牌商调货', | 276 | packageTitle: orderInfo.package_title || '商品需要品牌商调货', |
265 | - fraudTip: fraud.text || '' | 277 | + fraudTip: fraud.text || '', |
278 | + criteo: {// criteo统计代码有关数据 | ||
279 | + order_code: orderInfo.order_code, | ||
280 | + items: orderInfo.order_goods | ||
281 | + }, | ||
282 | + point: { | ||
283 | + order_code: orderInfo.order_code, | ||
284 | + payResult: 1, // 1支付成功,2支付失败 | ||
285 | + amount: orderInfo.payment_amount, | ||
286 | + payStyle: payId, // 支付方式id | ||
287 | + proSkn: sknArr.join(','), | ||
288 | + proSku: skuArr.join(',') | ||
289 | + | ||
290 | + } | ||
266 | }; | 291 | }; |
267 | }; | 292 | }; |
268 | 293 | ||
@@ -271,7 +296,7 @@ const _execOrderData = (orderInfo, fraudData) => { | @@ -271,7 +296,7 @@ const _execOrderData = (orderInfo, fraudData) => { | ||
271 | * @param payResult | 296 | * @param payResult |
272 | * @param uid | 297 | * @param uid |
273 | */ | 298 | */ |
274 | -const procOrderData = (payResult, uid) => { | 299 | +const procOrderData = (payResult, uid, payId) => { |
275 | return co(function *() { | 300 | return co(function *() { |
276 | let orderCode = payResult.orderCode; | 301 | let orderCode = payResult.orderCode; |
277 | let result = {code: 400, message: ''}; | 302 | let result = {code: 400, message: ''}; |
@@ -310,7 +335,10 @@ const procOrderData = (payResult, uid) => { | @@ -310,7 +335,10 @@ const procOrderData = (payResult, uid) => { | ||
310 | code: 200, | 335 | code: 200, |
311 | message: '支付成功,请等待发货', | 336 | message: '支付成功,请等待发货', |
312 | data: { | 337 | data: { |
313 | - order: Object.assign(orderInfo, _execOrderData(orderInfo, procData[1] && procData[1].data || {})) | 338 | + order: Object.assign( |
339 | + orderInfo, | ||
340 | + _execOrderData(orderInfo, procData[1] && procData[1].data || {}, payId) | ||
341 | + ) | ||
314 | } | 342 | } |
315 | }; | 343 | }; |
316 | 344 | ||
@@ -321,11 +349,12 @@ const procOrderData = (payResult, uid) => { | @@ -321,11 +349,12 @@ const procOrderData = (payResult, uid) => { | ||
321 | /** | 349 | /** |
322 | * [0元订单或者货到付款-成功处理] | 350 | * [0元订单或者货到付款-成功处理] |
323 | * @param {[type]} orderInfo [订单详情] | 351 | * @param {[type]} orderInfo [订单详情] |
352 | + * @param {[type]} payId [支付方式ID] | ||
324 | * @return {[type]} [{}] | 353 | * @return {[type]} [{}] |
325 | */ | 354 | */ |
326 | -const deliveryData = (orderInfo) => { | 355 | +const deliveryData = (orderInfo, payId) => { |
327 | return payApi.getResourceData(FRAUD_CONTENT_CODE).then(procData => { | 356 | return payApi.getResourceData(FRAUD_CONTENT_CODE).then(procData => { |
328 | - return Object.assign(orderInfo, _execOrderData(orderInfo, procData && procData.data || {})); | 357 | + return Object.assign(orderInfo, _execOrderData(orderInfo, procData && procData.data || {}, payId)); |
329 | }); | 358 | }); |
330 | }; | 359 | }; |
331 | 360 |
@@ -42,8 +42,8 @@ | @@ -42,8 +42,8 @@ | ||
42 | var __order_amount = '{{payment_amount}}'; | 42 | var __order_amount = '{{payment_amount}}'; |
43 | var __order_user = '{{#if isOldUser}}old{{else}}new{{/if}}'; | 43 | var __order_user = '{{#if isOldUser}}old{{else}}new{{/if}}'; |
44 | var __order_uid = '{{uid}}'; | 44 | var __order_uid = '{{uid}}'; |
45 | - var __order_goods_num = {{ordersGoodsNums}}; | ||
46 | - var __order_goods = {{goodsDatas}}; | 45 | + var __order_goods_num = '{{ordersGoodsNums}}'; |
46 | + var __order_goods = '{{goodsDatas}}'; | ||
47 | </script> | 47 | </script> |
48 | <script type="text/javascript"> | 48 | <script type="text/javascript"> |
49 | var _mvq = window._mvq || []; | 49 | var _mvq = window._mvq || []; |
@@ -2,10 +2,10 @@ | @@ -2,10 +2,10 @@ | ||
2 | <script type="text/javascript" src="//static.criteo.net/js/ld/ld.js" async="true"></script> | 2 | <script type="text/javascript" src="//static.criteo.net/js/ld/ld.js" async="true"></script> |
3 | <script type="text/javascript"> | 3 | <script type="text/javascript"> |
4 | window.criteo_q = window.criteo_q || []; | 4 | window.criteo_q = window.criteo_q || []; |
5 | -window.criteo_q.push( | 5 | +window.criteo_q.push( |
6 | { event: "setAccount", account: [16184] }, | 6 | { event: "setAccount", account: [16184] }, |
7 | { event: "setSiteType", type: "d" }, | 7 | { event: "setSiteType", type: "d" }, |
8 | - { event: "trackTransaction" , id: "{{orderNum}}", item: [ | 8 | + { event: "trackTransaction" , id: "{{order_code}}", item: [ |
9 | {{#each items}} | 9 | {{#each items}} |
10 | { id: "{{product_skn}}", price: "{{goods_price}}", quantity: "{{buy_number}}"} | 10 | { id: "{{product_skn}}", price: "{{goods_price}}", quantity: "{{buy_number}}"} |
11 | {{#unless @last}} | 11 | {{#unless @last}} |
@@ -15,4 +15,4 @@ window.criteo_q.push( | @@ -15,4 +15,4 @@ window.criteo_q.push( | ||
15 | ]} | 15 | ]} |
16 | ); | 16 | ); |
17 | </script> | 17 | </script> |
18 | -{{/ criteo}} | ||
18 | +{{/ criteo}} |
@@ -2,7 +2,18 @@ | @@ -2,7 +2,18 @@ | ||
2 | <script type="text/javascript"> | 2 | <script type="text/javascript"> |
3 | window.onload = function () { | 3 | window.onload = function () { |
4 | // 埋点 | 4 | // 埋点 |
5 | - window.addPoint('YB_SC_PAY_RES', {ORDER_CODE: "{{orderCode}}", PAY_RES: "{{payResult}}", ORDER_AMOUNT: "{{amount}}", PAY_STYLE: "{{payStyle}}", PRD_SKN: "{{proSkn}}", PRD_SKU: "{{proSku}}"}); | 5 | + window._yas && window._yas.sendCustomInfo && window._yas.sendCustomInfo({ |
6 | + op: 'YB_SC_PAY_RES', | ||
7 | + param: JSON.stringify({ | ||
8 | + C_ID: window._ChannelVary[window.cookie('_Channel')] || 1, | ||
9 | + ORDER_CODE: "{{order_code}}", | ||
10 | + PAY_RES: "{{payResult}}", | ||
11 | + ORDER_AMOUNT: "{{amount}}", | ||
12 | + PAY_STYLE: "{{payStyle}}", | ||
13 | + PRD_SKN: "{{proSkn}}", | ||
14 | + PRD_SKU: "{{proSku}}" | ||
15 | + }) | ||
16 | + }, true); | ||
6 | } | 17 | } |
7 | </script> | 18 | </script> |
8 | -{{/ point}} | ||
19 | +{{/ point}} |
-
Please register or login to post a comment