Authored by 郝肖肖

支付成功界面 埋点

... ... @@ -40,7 +40,7 @@ const online = (req, res, next) => {
order.payment_type = parseInt(order.payment_type, 10);
if (amount <= 0 || order.payment_type === 2) {
PayData.deliveryData(order).then(orderInfo => {
PayData.deliveryData(order, PayData.payments.delivery).then(orderInfo => {
res.render('pay-success', {
simpleHeader: header,
order: orderInfo,
... ...
... ... @@ -150,7 +150,7 @@ const Payment = {
PayData.sendPayConfirm(payResult.orderCode, payId, user.uid);
}
payData = yield PayData.procOrderData(payResult, user.uid);
payData = yield PayData.procOrderData(payResult, user.uid, payId);
} else {
payData = {
code: 500,
... ... @@ -175,7 +175,7 @@ const Payment = {
case PayData.payments.wechat: // 微信支付不须要验证,但前端必须校验sign
delete query.sign;
if (md5(paySign.raw(Object.assign({tradeStatus: 'Y'}, query))) === sign) {
payData = yield PayData.procOrderData(query, user.uid);
payData = yield PayData.procOrderData(query, user.uid, payId);
}
payData.payName = '微信';
break;
... ...
... ... @@ -15,9 +15,13 @@ const _ = require('lodash');
const helpers = global.yoho.helpers;
const FRAUD_CONTENT_CODE = '78d0fb6c97d691863286edcb4d8abfa9';
const payments = {
alipay: 2,
wechat: 21,
alibank: 12
alipay: 2, // 支付宝
wechat: 21, // 微信支付
alibank: 12, // 支付宝支联
unionpayweb: 25, // 银联支付
chinabank: 4, // 网银在线
tenpay: 1, // 财付通
delivery: 3 // 货到付款和0元订单
};
/**
... ... @@ -246,10 +250,18 @@ const sendPayConfirm = (code, payment, uid) => {
* [公共支付成功数据处理]
* @param {[type]} orderInfo [订单信息]
* @param {[type]} fraudData [资源位数据]
* @param {[type]} payId [支付方式ID]
* @return {[type]} [{}]
*/
const _execOrderData = (orderInfo, fraudData) => {
const _execOrderData = (orderInfo, fraudData, payId) => {
let fraud = _.result(_.find(fraudData, {template_name: 'text'}), 'data') || {};
let sknArr = [];
let skuArr = [];
_.each(orderInfo.order_goods, function(el) {
sknArr.push(el.product_skn);
skuArr.push(el.product_sku);
});
return {
paymentTypes: (orderInfo.payment_type === 1 ? '在线支付' : '货到付款'),
... ... @@ -262,7 +274,20 @@ const _execOrderData = (orderInfo, fraudData) => {
orderCode: orderInfo.order_code
}),
packageTitle: orderInfo.package_title || '商品需要品牌商调货',
fraudTip: fraud.text || ''
fraudTip: fraud.text || '',
criteo: {// criteo统计代码有关数据
order_code: orderInfo.order_code,
items: orderInfo.order_goods
},
point: {
order_code: orderInfo.order_code,
payResult: 1, // 1支付成功,2支付失败
amount: orderInfo.payment_amount,
payStyle: payId, // 支付方式id
proSkn: sknArr.join(','),
proSku: skuArr.join(',')
}
};
};
... ... @@ -271,7 +296,7 @@ const _execOrderData = (orderInfo, fraudData) => {
* @param payResult
* @param uid
*/
const procOrderData = (payResult, uid) => {
const procOrderData = (payResult, uid, payId) => {
return co(function *() {
let orderCode = payResult.orderCode;
let result = {code: 400, message: ''};
... ... @@ -310,7 +335,10 @@ const procOrderData = (payResult, uid) => {
code: 200,
message: '支付成功,请等待发货',
data: {
order: Object.assign(orderInfo, _execOrderData(orderInfo, procData[1] && procData[1].data || {}))
order: Object.assign(
orderInfo,
_execOrderData(orderInfo, procData[1] && procData[1].data || {}, payId)
)
}
};
... ... @@ -321,11 +349,12 @@ const procOrderData = (payResult, uid) => {
/**
* [0元订单或者货到付款-成功处理]
* @param {[type]} orderInfo [订单详情]
* @param {[type]} payId [支付方式ID]
* @return {[type]} [{}]
*/
const deliveryData = (orderInfo) => {
const deliveryData = (orderInfo, payId) => {
return payApi.getResourceData(FRAUD_CONTENT_CODE).then(procData => {
return Object.assign(orderInfo, _execOrderData(orderInfo, procData && procData.data || {}));
return Object.assign(orderInfo, _execOrderData(orderInfo, procData && procData.data || {}, payId));
});
};
... ...
... ... @@ -54,5 +54,9 @@
</p>
{{/if}}
</div>
{{> pay/pay-analysis}}
{{> pay/point}}
{{/order}}
</div>
... ...
... ... @@ -42,8 +42,8 @@
var __order_amount = '{{payment_amount}}';
var __order_user = '{{#if isOldUser}}old{{else}}new{{/if}}';
var __order_uid = '{{uid}}';
var __order_goods_num = {{ordersGoodsNums}};
var __order_goods = {{goodsDatas}};
var __order_goods_num = '{{ordersGoodsNums}}';
var __order_goods = '{{goodsDatas}}';
</script>
<script type="text/javascript">
var _mvq = window._mvq || [];
... ...
... ... @@ -2,10 +2,10 @@
<script type="text/javascript" src="//static.criteo.net/js/ld/ld.js" async="true"></script>
<script type="text/javascript">
window.criteo_q = window.criteo_q || [];
window.criteo_q.push(
window.criteo_q.push(
{ event: "setAccount", account: [16184] },
{ event: "setSiteType", type: "d" },
{ event: "trackTransaction" , id: "{{orderNum}}", item: [
{ event: "trackTransaction" , id: "{{order_code}}", item: [
{{#each items}}
{ id: "{{product_skn}}", price: "{{goods_price}}", quantity: "{{buy_number}}"}
{{#unless @last}}
... ... @@ -15,4 +15,4 @@ window.criteo_q.push(
]}
);
</script>
{{/ criteo}}
\ No newline at end of file
{{/ criteo}}
... ...
... ... @@ -2,7 +2,18 @@
<script type="text/javascript">
window.onload = function () {
// 埋点
window.addPoint('YB_SC_PAY_RES', {ORDER_CODE: "{{orderCode}}", PAY_RES: "{{payResult}}", ORDER_AMOUNT: "{{amount}}", PAY_STYLE: "{{payStyle}}", PRD_SKN: "{{proSkn}}", PRD_SKU: "{{proSku}}"});
window._yas && window._yas.sendCustomInfo && window._yas.sendCustomInfo({
op: 'YB_SC_PAY_RES',
param: JSON.stringify({
C_ID: window._ChannelVary[window.cookie('_Channel')] || 1,
ORDER_CODE: "{{order_code}}",
PAY_RES: "{{payResult}}",
ORDER_AMOUNT: "{{amount}}",
PAY_STYLE: "{{payStyle}}",
PRD_SKN: "{{proSkn}}",
PRD_SKU: "{{proSku}}"
})
}, true);
}
</script>
{{/ point}}
\ No newline at end of file
{{/ point}}
... ...