提交 4b79ef1d 编写于 作者: T Terry

add trace info

上级 d9fcdc6a
......@@ -177,6 +177,7 @@ appserver(手机app服务),appapi(erp,或者其他接口对接),
| 捐赠人 | 金额 | 时间 | 方式 | 账户 | 捐助者留言 |
| --------------| ----------| ------------- | ----------- | ----------------------| ----------|
| (*) | ¥166.00 | 2018-04-03 | 微信 | - | 为开源打call! |
| *仲春 | ¥66.66 | 2018-03-19 | 支付宝 | - | 加油加油,准备学习学习 |
| (*) | ¥10.00 | 2018-03-19 | 微信 | - | - |
| (*) | ¥8.88 | 2018-03-18 | 微信 | - | 为作者坚持和耐心点赞 |
......
......@@ -66,17 +66,18 @@ class Index
$this->_productCount = $productCollInfo['count'];
//echo $this->_productCount;
return [
'title' => $this->_title,
'name' => Yii::$service->store->getStoreAttrVal($this->_category['name'], 'name'),
'image' => $this->_category['image'] ? Yii::$service->category->image->getUrl($this->_category['image']) : '',
'description' => Yii::$service->store->getStoreAttrVal($this->_category['description'], 'description'),
'products' => $products,
'query_item' => $this->getQueryItem(),
'product_page' => $this->getProductPage(),
'refine_by_info'=> $this->getRefineByInfo(),
'filter_info' => $this->getFilterInfo(),
'filter_price' => $this->getFilterPrice(),
'filter_category'=> $this->getFilterCategoryHtml(),
'title' => $this->_title,
'name' => Yii::$service->store->getStoreAttrVal($this->_category['name'], 'name'),
'name_default_lang' => Yii::$service->fecshoplang->getDefaultLangAttrVal($this->_category['name'], 'name'),
'image' => $this->_category['image'] ? Yii::$service->category->image->getUrl($this->_category['image']) : '',
'description' => Yii::$service->store->getStoreAttrVal($this->_category['description'], 'description'),
'products' => $products,
'query_item' => $this->getQueryItem(),
'product_page' => $this->getProductPage(),
'refine_by_info' => $this->getRefineByInfo(),
'filter_info' => $this->getFilterInfo(),
'filter_price' => $this->getFilterPrice(),
'filter_category' => $this->getFilterCategoryHtml(),
//'content' => Yii::$service->store->getStoreAttrVal($this->_category['content'],'content'),
//'created_at' => $this->_category['created_at'],
];
......
......@@ -53,18 +53,31 @@ class Index
//echo $this->_productCount;
return [
'searchText' => $this->_searchText,
'title' => $this->_title,
'name' => Yii::$service->store->getStoreAttrVal($this->_category['name'], 'name'),
'image' => $this->_category['image'] ? Yii::$service->category->image->getUrl($this->_category['image']) : '',
'description' => Yii::$service->store->getStoreAttrVal($this->_category['description'], 'description'),
'products' => $products,
'query_item' => $this->getQueryItem(),
'product_page' => $this->getProductPage(),
'refine_by_info'=> $this->getRefineByInfo(),
'filter_info' => $this->getFilterInfo(),
'filter_price' => $this->getFilterPrice(),
'title' => $this->_title,
'name' => Yii::$service->store->getStoreAttrVal($this->_category['name'], 'name'),
'image' => $this->_category['image'] ? Yii::$service->category->image->getUrl($this->_category['image']) : '',
'description' => Yii::$service->store->getStoreAttrVal($this->_category['description'], 'description'),
'products' => $products,
'query_item' => $this->getQueryItem(),
'product_page' => $this->getProductPage(),
'refine_by_info' => $this->getRefineByInfo(),
'filter_info' => $this->getFilterInfo(),
'filter_price' => $this->getFilterPrice(),
'traceSearchData' => $this->getTraceSearchData(),
];
}
protected function getTraceSearchData(){
if (Yii::$service->page->trace->traceJsEnable && $this->_searchText && $this->_productCount){
$arr = [
'text' => $this->_searchText,
'result_qty' => $this->_productCount,
];
return json_encode($arr);
} else {
return '';
}
}
/**
* 得到toolbar的分页部分
*/
......
......@@ -21,12 +21,55 @@ class Index
{
$this->initHead();
$currency_info = Yii::$service->page->currency->getCurrencyInfo();
//var_dump($this->getCartInfo());
$cart_info = $this->getCartInfo(false);
//var_dump($cart_info );
return [
'cart_info' => $this->getCartInfo(false),
'currency_info' => $currency_info,
'cart_info' => $cart_info,
'currency_info' => $currency_info,
'trace_cart_info' => $this->getTraceCartInfo($cart_info),
];
}
/**
* @property $cart_info | Array, example data:
[
{
"sku":"grxjy56002622",
"qty":1,
"price":35.52,
"currency":"RMB",
"currency_rate":6.2
},
{
"sku":"grxjy5606622",
"qty":4,
"price":75.11,
"currency":"RMB",
"currency_rate":6.2
}
]
* @return string , json数组字符串
* 通过$cart_info,得到用于追踪的字符串。
*/
public function getTraceCartInfo($cart_info){
if (Yii::$service->page->trace->traceJsEnable) {
if (is_array($cart_info['products']) && !empty($cart_info['products'])) {
$arr = [];
foreach ($cart_info['products'] as $product) {
$arr[] = [
'sku' => $product['sku'],
'qty' => (int)$product['qty'],
'price' => $product['base_product_price'],
];
}
if (!empty($arr)) {
return json_encode($arr);
}
}
}
return '';
}
/** @return data example
* [
......
......@@ -155,3 +155,4 @@ $(document).ready(function(){
<?php $this->endBlock(); ?>
</script>
<?php $this->registerJs($this->blocks['category_product_filter'],\yii\web\View::POS_END);//将编写的js代码注册到页面底部 ?>
<?= Yii::$service->page->trace->getTraceCategoryJsCode($name_default_lang) ?>
\ No newline at end of file
......@@ -409,5 +409,5 @@
<?php $this->endBlock(); ?>
<?php $this->registerJs($this->blocks['product_info_tab'],\yii\web\View::POS_END);//将编写的js代码注册到页面底部 ?>
</script>
<?= Yii::$service->page->trace->getTraceProductJsCode($sku) ?>
\ No newline at end of file
......@@ -145,3 +145,6 @@ $(document).ready(function(){
<?php $this->endBlock(); ?>
</script>
<?php $this->registerJs($this->blocks['category_product_filter'],\yii\web\View::POS_END);//将编写的js代码注册到页面底部 ?>
<?= Yii::$service->page->trace->getTraceSearchJsCode($traceSearchData) ?>
<?php Yii::$service->page->trace->sendTraceLoginInfoByApi() ?>
......@@ -468,4 +468,6 @@ $(document).ready(function(){
<?php $this->endBlock(); ?>
<?php $this->registerJs($this->blocks['changeCartInfo'],\yii\web\View::POS_END);//将编写的js代码注册到页面底部 ?>
</script>
\ No newline at end of file
</script>
<?= Yii::$service->page->trace->getTraceCartJsCode($trace_cart_info) ?>
......@@ -37,5 +37,6 @@
<div class="footer-bottom">
<?= Yii::$service->cms->staticblock->getStoreContentByIdentify('copy_right','appfront') ?>
</div>
<?= Yii::$service->page->trace->getTraceCommonJsCode() ?>
</footer>
\ No newline at end of file
......@@ -202,6 +202,10 @@ return [
'class' => 'fecshop\services\page\Message',
],
'trace' => [
'class' => 'fecshop\services\page\Trace',
],
],
],
......
......@@ -13,14 +13,17 @@ return [
// 说的更明确点就是:这些参数的设置是给无状态api使用的。
// 实现了一个类似session的功能,供appserver端使用
// 【对phpsession 无效】设置session过期时间,
// 对于 appfront apphtml5部分的session的设置,您需要到 @app/config/main.php 中设置 session 组件 的timeout时间
'timeout' => 3600,
// 【对phpsession 无效】当过期时间+session创建时间 - 当前事件 < $updateTimeLimit ,则更新session创建时间
// 【对phpsession 无效】更新access_token_created_at值的阈值
// 当满足条件:`access_token_created_at`(token创建时间)`timeout(过期时间)` <= `time`(当前时间) < updateTimeLimit (更新access_token_created_at值的阈值)
// 则会将用户在数据库表中的 `access_token_created_at` 的值设置成当前时间,这样可以在access_token快要过期的时候,更新 `access_token_created_at`,
// 同时避免了每次访问都更新 `access_token_created_at` 的开销。
'updateTimeLimit' => 600,
// 【不可以设置phpsession】默认为php session,只有当 \Yii::$app->user->enableSession == false时,下面的设置才有效。
// 存储引擎 mongodb mysqldb redis
'storage' => 'SessionRedis', //'SessionMysqldb',
//'childService' => [
// 'session' => [
// 'class' => 'fecshop\services\session\Session',
......
......@@ -93,6 +93,8 @@ class Customer extends Service
if (empty($errors)) {
// 合并购物车数据
Yii::$service->cart->mergeCartAfterUserLogin();
// 发送登录信息到trace系统
Yii::$service->page->trace->sendTraceLoginInfoByApi($data['email']);
} else {
Yii::$service->helper->errors->addByModelErrors($errors);
}
......@@ -119,6 +121,8 @@ class Customer extends Service
$model->updated_at = time();
$model->save();
// 发送注册信息到trace系统
Yii::$service->page->trace->sendTraceRegisterInfoByApi($model->email);
return true;
} else {
$errors = $model->errors;
......@@ -602,6 +606,7 @@ class Customer extends Service
$identity->access_token_created_at = time();
$identity->save();
}
return $identity;
}else{
$this->logoutByAccessToken();
......
......@@ -576,7 +576,8 @@ class Order extends Service
Yii::$service->event->trigger($afterEventName, $myOrder);
if ($myOrder[$this->getPrimaryKey()]) {
Yii::$service->order->item->saveOrderItems($cartInfo['products'], $order_id, $cartInfo['store']);
// 订单生成成功,通过api传递数据给trace系统
$this->sendTracePaymentPendingOrder($myOrder, $cartInfo['products']);
// 有token的,代表是更新类型,譬如购物车点击paypal express支付的方式
// 这种类型要进行检查,不能多次执行。该函数必须在订单操作完成的情况下执行。
/*
......@@ -604,6 +605,126 @@ class Order extends Service
return false;
}
}
/**
* @property $order_increment_id | string,订单编号 increment_id
* 订单支付成功后,执行的代码,该代码只会在接收到支付成功信息后,才会执行。
* 在调用该函数前,会对IPN支付成功消息做验证,一次,无论发送多少次ipn消息,该函数只会执行一次。
* 您可以把订单支付成功需要做的事情都在这个函数里面完成。
**/
public function orderPaymentCompleteEvent($order_increment_id){
if (!$order_increment_id) {
Yii::$service->helper->errors->add('order increment id is empty');
return false;
}
$orderInfo = Yii::$service->order->getOrderInfoByIncrementId($order_increment_id);
if ($orderInfo['increment_id']) {
Yii::$service->helper->errors->add('get order by increment_id:'.$order_increment_id.' fail, order is not exist ');
return false;
}
// 发送订单支付成功邮件
Yii::$service->email->order->sendCreateEmail($orderInfo);
Yii::$service->order->sendTracePaymentSuccessOrder($orderInfo);
}
/**
* @property $orderInfo | Object, 订单对象
* @property $cartInfo | Object,购物车对象
* 根据传递的参数,得出trace系统的要求的order参数格式数组
* 执行page trace services,将支付完成订单的数据传递给trace系统
*/
protected function sendTracePaymentSuccessOrder($orderInfo){
if (Yii::$service->page->trace->traceJsEnable) {
$arr = [];
$arr['invoice'] = $orderInfo['increment_id'];
$arr['order_type'] = $orderInfo['checkout_method'];
$arr['payment_status'] = $orderInfo['order_status'];
$arr['payment_type'] = $orderInfo['payment_method'];
$arr['amount'] = $orderInfo['base_grand_total'];
$arr['shipping'] = $orderInfo['base_shipping_total'];
$arr['discount_amount'] = $orderInfo['base_subtotal_with_discount'];
$arr['coupon'] = $orderInfo['coupon_code'];
$arr['city'] = $orderInfo['customer_address_city'];
$arr['email'] = $orderInfo['customer_email'];
$arr['first_name'] = $orderInfo['customer_firstname'];
$arr['last_name'] = $orderInfo['customer_lastname'];
$arr['zip'] = $orderInfo['customer_address_zip'];
$arr['address1'] = $orderInfo['customer_address_street1'];
$arr['address2'] = $orderInfo['customer_address_street2'];
$arr['country_code'] = $orderInfo['customer_address_country'];
$arr['state_code'] = $orderInfo['customer_address_state'];
$arr['state_name'] = Yii::$service->helper->country->getStateByContryCode($orderInfo['customer_address_country'], $orderInfo['customer_address_state']);
$arr['country_name'] = Yii::$service->helper->country->getCountryNameByKey($orderInfo['customer_address_country']);
$product_arr = [];
$products = $orderInfo['products'];
if (is_array($products)) {
foreach ($products as $product) {
$product_arr[] = [
'sku' => $product['sku'],
'name' => $product['name'],
'qty' => $product['qty'],
'price' => $product['base_product_price'],
];
}
}
$arr['products'] = $product_arr;
Yii::$service->page->trace->sendTracePaymentSuccessOrderByApi($arr);
return true;
}
return false;
}
/**
* @property $myOrder | Object, 订单对象
* @property $products | Array,购物车产品数组
* 根据传递的参数,得出trace系统的要求的order参数格式数组,
* 执行page trace services,将等待支付订单(刚刚生成的订单)的数据传递给trace系统
*/
protected function sendTracePaymentPendingOrder($myOrder, $products){
if (Yii::$service->page->trace->traceJsEnable) {
$arr = [];
$arr['invoice'] = $myOrder['increment_id'];
$arr['order_type'] = $myOrder['checkout_method'];
$arr['payment_status'] = $myOrder['order_status'];
$arr['payment_type'] = $myOrder['payment_method'];
$arr['amount'] = $myOrder['base_grand_total'];
$arr['shipping'] = $myOrder['base_shipping_total'];
$arr['discount_amount'] = $myOrder['base_subtotal_with_discount'];
$arr['coupon'] = $myOrder['coupon_code'];
$arr['city'] = $myOrder['customer_address_city'];
$arr['email'] = $myOrder['customer_email'];
$arr['first_name'] = $myOrder['customer_firstname'];
$arr['last_name'] = $myOrder['customer_lastname'];
$arr['zip'] = $myOrder['customer_address_zip'];
$arr['address1'] = $myOrder['customer_address_street1'];
$arr['address2'] = $myOrder['customer_address_street2'];
$arr['country_code'] = $myOrder['customer_address_country'];
$arr['state_code'] = $myOrder['customer_address_state'];
$arr['state_name'] = Yii::$service->helper->country->getStateByContryCode($myOrder['customer_address_country'], $myOrder['customer_address_state']);
$arr['country_name'] = Yii::$service->helper->country->getCountryNameByKey($myOrder['customer_address_country']);
$product_arr = [];
// $products = $cartInfo['products'];
if (is_array($products)) {
foreach ($products as $product) {
$product_arr[] = [
'sku' => $product['sku'],
'name' => $product['name'],
'qty' => $product['qty'],
'price' => $product['base_product_price'],
];
}
}
$arr['products'] = $product_arr;
Yii::$service->page->trace->sendTracePaymentPendingOrderByApi($arr);
return true;
}
return false;
}
/**
* @property $increment_id | String 每执行一次,version都会+1 (version默认为0)
......@@ -620,13 +741,13 @@ class Order extends Service
'increment_id' => $increment_id,
])->one();
# 如果版本号不等于1,则回滚
if($myOrder['version'] > 1){
if ($myOrder['version'] > 1) {
Yii::$service->helper->errors->add('Your order has been paid');
return false;
}else if($myOrder['version'] < 1){
} else if($myOrder['version'] < 1) {
Yii::$service->helper->errors->add('Your order is error');
return false;
}else{
} else {
return true;
}
}
......@@ -654,7 +775,7 @@ class Order extends Service
*/
protected function actionUpdateTokenByIncrementId($increment_id,$token){
$myOrder = Yii::$service->order->getByIncrementId($increment_id);
if($myOrder){
if ($myOrder) {
$myOrder->payment_token = $token;
$myOrder->save();
}
......
<?php
/**
* FecShop file.
*
* @link http://www.fecshop.com/
* @copyright Copyright (c) 2016 FecShop Software LLC
* @license http://www.fecshop.com/license/
*/
namespace fecshop\services\page;
use fecshop\services\Service;
use Yii;
/**
* page Footer services.
* @author Terry Zhao <2358269014@qq.com>
* @since 1.0
*/
class Trace extends Service
{
public $traceJsEnable = false; // 是否打开js追踪
public $website_id; // 网站的id,在trace系统中获取
public $trace_url; // trace系统接收数据的url,在trace系统中获取
// 通过trace系统得到的token
public $access_token;
// api发送数据给trace系统的最大等待时间,超过这个时间将不继续等待
public $api_time_out = 1.5;
protected $_fta;
protected $_ftactivity;
protected $_ftactivity_child;
protected $_fto;
protected $_ftreferdomain;
protected $_ftreferurl;
protected $_ftreturn;
protected $_fta_site_id; // website_id
const LOGIN_EMAIL = 'loginEmail';
const REGISTER_EMAIL = 'registerEmail';
const PAYMENT_PENDING_ORDER = 'paymentPendingOrder';
const PAYMENT_SUCCESS_ORDER = 'paymentSuccessOrder';
/**
* @return String, 通用的js部分,需要先设置 website_id 和 trace_url
*/
public function getTraceCommonJsCode(){
if ($this->traceJsEnable) {
return "<script type=\"text/javascript\">
var _maq = _maq || [];
_maq.push(['website_id', '" . $this->website_id . "']);
(function() {
var ma = document.createElement('script'); ma.type = 'text/javascript'; ma.async = true;
ma.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + '".$this->trace_url."';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ma, s);
})();
</script>";
} else {
return '';
}
}
/**
* @property $categoryName | String , 填写分类的name,如果是多语言网站,那么这里填写默认语言的分类name
* @return String, 分类页面的js Code
*/
public function getTraceCategoryJsCode($categoryName){
if ($this->traceJsEnable && $categoryName) {
return "<script type=\"text/javascript\">
var _maq = _maq || [];
_maq.push(['category', '".$categoryName."']);
</script>";
} else {
return '';
}
}
/**
* @property $sku | String , 产品页面的sku编码
* @return String, 产品页面的js Code
* <?= Yii::$service->page->trace->getTraceProductJsCode($sku) ?>
*/
public function getTraceProductJsCode($sku){
if ($this->traceJsEnable && $sku) {
return "<script type=\"text/javascript\">
var _maq = _maq || [];
_maq.push(['sku', '".$sku."']);
</script>";
} else {
return '';
}
}
/**
* @property $cart | String , 购物车数据,示例JSON数据:
[
{
"sku":"grxjy56002622",
"qty":1,
"price":35.52,
"currency":"RMB",
"currency_rate":6.2
},
{
"sku":"grxjy5606622",
"qty":4,
"price":75.11,
"currency":"RMB",
"currency_rate":6.2
}
]
*
* @return String, 购物车页面的js Code
*/
public function getTraceCartJsCode($cart){
if ($this->traceJsEnable && $cart) {
return "<script type=\"text/javascript\">
var _maq = _maq || [];
_maq.push(['cart', ".$cart."]);
</script>";
} else {
return '';
}
}
/**
* @property $search | String ,搜索的json格式如下:
{
"text": "fashion handbag", // 搜索词
"result_qty":5 // 搜索的产品个数
}
* @return String, 注册页面的js Code
*/
public function getTraceSearchJsCode($search){
if ($this->traceJsEnable && $search) {
return "<script type=\"text/javascript\">
var _maq = _maq || [];
_maq.push(['search', ".$search." ]);
</script>";
} else {
return '';
}
}
public function initCookie(){
$this->_fta = $_COOKIE['_fta'];
$this->_ftactivity = $_COOKIE['_ftactivity'];
$this->_ftactivity_child = $_COOKIE['_ftactivity_child'];
$this->_fto = $_COOKIE['_fto'];
$this->_ftreferdomain = $_COOKIE['_ftreferdomain'];
$this->_ftreferurl = $_COOKIE['_ftreferurl'];
$this->_ftreturn = $_COOKIE['_ftreturn'];
$this->_fta_site_id = $_COOKIE['_fta_site_id'];
}
// 登录账户,通过api传递数据给trace系统 【已经部署到customer service login函数里面】
public function sendTraceLoginInfoByApi($login_email){
if ($this->traceJsEnable && $login_email) {
$this->apiSendTrace([
self::LOGIN_EMAIL => $login_email,
]);
}
}
// 注册账户,通过api传递数据给trace系统【已经部署到customer service register函数里面】
public function sendTraceRegisterInfoByApi($register_email){
if ($this->traceJsEnable && $register_email) {
$this->apiSendTrace([
self::REGISTER_EMAIL => $register_email,
]);
}
}
// 订单生成成功,通过api传递数据给trace系统
public function sendTracePaymentPendingOrderByApi($order){
if ($this->traceJsEnable && $order) {
$this->apiSendTrace([
self::PAYMENT_PENDING_ORDER => $order,
]);
}
}
// 订单支付成功,通过api传递数据给trace系统
public function sendTracePaymentSuccessOrderByApi($order){
if ($this->traceJsEnable && $order) {
$this->apiSendTrace([
self::PAYMENT_SUCCESS_ORDER => $order,
]);
}
}
/**
* @property $data | Array,目前分类四类:loginEmail, registerEmail, paymentPendingOrder, paymentSuccessOrder,
*
*
*/
public function apiSendTrace($data){
// 发送的数据
$this->initCookie();
// 进行条件判断
if ($this->_fta) {
$data['_fta'] = $this->_fta;
$data['_ftactivity'] = $this->_ftactivity;
$data['_ftactivity_child'] = $this->_ftactivity_child;
$data['_fto'] = $this->_fto;
$data['_ftreferdomain'] = $this->_ftreferdomain;
$data['_ftreferurl'] = $this->_ftreferurl;
$data['_ftreturn'] = $this->_ftreturn;
$data['_fta_site_id'] = $this->_fta_site_id;
// 加入验证access_token
// curl 发送数据
// 完成
return true;
}
}
/**
* @property $order | String , 订单数据,示例JSON数据:
{
"invoice": "500023149", // 订单号
"order_type": "standard or express", // standard(标准支付流程类型)express(基于api的支付类型,譬如paypal快捷支付。)
"payment_status":"pending", // pending(未支付成功)
"payment_type":"paypal", // 支付渠道,譬如是paypal还是西联等支付渠道
"currency":"RMB", // 当前货币
"currency_rate":6.2, // 公式:当前金额 * 汇率 = 美元金额
"amount":35.52, // 订单总金额
"shipping":0.00, // 运费金额
"discount_amount":0.00, // 折扣金额
"coupon":"xxxxx", // 优惠券,没有则为空
"city":"fdasfds", // 城市
"email":"2358269014@qq.com", // 下单填写的email
"first_name":"terry", //
"last_name":"water", //
"zip":"266326", // 邮编
"country_code":"US", // 国家简码
"state_code":"CT", // 省或州
"country_name":"Unit states", // 国家简码
"state_name":"ctrssf", // 省或州
"address1":"address street 1", // 详细地址1
"address2":"address street 2", // 详细地址2
"products":[ // 产品详情
{
"sku":"xxxxyr", // sku
"name":"Fashion Solid Color Warm Coat", // 产品名称
"qty":1, // 个数
"price":25.92 // 产品单价
},
{
"sku":"yyyy", // sku
"name":"Fashion Waist Warm Coat", // 产品名称
"qty":1, // 个数
"price":34.16 // 产品单价
}
]
}
*
* @return String, 未支付订单页面的js Code
*/
/* 改成api发送数据
public function getTraceOrderJsCode($order){
if ($this->traceJsEnable && $order) {
return "<script type=\"text/javascript\">
var _maq = _maq || [];
_maq.push(['order', ".$order."]);
</script>";
} else {
return '';
}
}
*/
/**
* @property $order | String , 订单数据,示例JSON数据:
{
"invoice": "500023149", // 订单号
"order_type": "standard or express", // standard(标准支付流程类型)express(基于api的支付类型,譬如paypal快捷支付。)
"payment_status":"pending", // pending(未支付成功)
"payment_type":"paypal", // 支付渠道,譬如是paypal还是西联等支付渠道
"currency":"RMB", // 当前货币
"currency_rate":6.2, // 公式:当前金额 * 汇率 = 美元金额
"amount":35.52, // 订单总金额
"shipping":0.00, // 运费金额
"discount_amount":0.00, // 折扣金额
"coupon":"xxxxx", // 优惠券,没有则为空
"city":"fdasfds", // 城市
"email":"2358269014@qq.com", // 下单填写的email
"first_name":"terry", //
"last_name":"water", //
"zip":"266326", // 邮编
"country_code":"US", // 国家简码
"state_code":"CT", // 省或州
"country_name":"Unit states", // 国家简码
"state_name":"ctrssf", // 省或州
"address1":"address street 1", // 详细地址1
"address2":"address street 2", // 详细地址2
"products":[ // 产品详情
{
"sku":"xxxxyr", // sku
"name":"Fashion Solid Color Warm Coat", // 产品名称
"qty":1, // 个数
"price":25.92 // 产品单价
},
{
"sku":"yyyy", // sku
"name":"Fashion Waist Warm Coat", // 产品名称
"qty":1, // 个数
"price":34.16 // 产品单价
}
]
}
*
* @return String, 支付成功订单页面的js Code
*/
/* 改成api发送数据
public function getTraceSuccessOrderJsCode($successOrder){
if ($this->traceJsEnable && $successOrder) {
return "<script type=\"text/javascript\">
var _maq = _maq || [];
_maq.push(['successOrder', ".$successOrder."]);
</script>";
} else {
return '';
}
}
*/
/**
* @property $login_email | String , 登录的email
* @return String, 登录页面的js Code
*/
/* 改成api发送数据
public function getTraceLoginJsCode($login_email){
if ($this->traceJsEnable && $login_email) {
return "<script type=\"text/javascript\">
var _maq = _maq || [];
_maq.push(['login_email', '".$login_email."']);
</script>";
} else {
return '';
}
}
*/
/**
* @property $register_email | String , 注册的email
* @return String, 注册页面的js Code
*/
/* 改成api发送数据
public function getTraceRegisterJsCode($register_email){
if ($this->traceJsEnable && $register_email) {
return "<script type=\"text/javascript\">
var _maq = _maq || [];
_maq.push(['register_email', '".$register_email."']);
</script>";
} else {
return '';
}
}
*/
}
......@@ -248,10 +248,12 @@ class Alipay extends Service
$order->txn_id = $trade_no; // 支付宝的交易号
// 更新订单信息
$order->save();
Yii::$service->order->orderPaymentCompleteEvent($order['increment_id']);
// 上面的函数已经执行下面的代码,因此注释掉。
// 得到当前的订单信息
$orderInfo = Yii::$service->order->getOrderInfoByIncrementId($order['increment_id']);
//$orderInfo = Yii::$service->order->getOrderInfoByIncrementId($order['increment_id']);
// 发送新订单邮件
Yii::$service->email->order->sendCreateEmail($orderInfo);
//Yii::$service->email->order->sendCreateEmail($orderInfo);
return true;
}
......
......@@ -341,9 +341,11 @@ class Paypal extends Service
// 因为IPN消息可能不止发送一次,但是这里只允许一次,
// 如果重复发送,$updateColumn 的更新返回值将为0
if (!empty($updateColumn)) {
$orderInfo = Yii::$service->order->getOrderInfoByIncrementId($this->_order['increment_id']);
Yii::$service->order->orderPaymentCompleteEvent($this->_order['increment_id']);
// 上面的函数已经执行下面的代码,因此注释掉。
// $orderInfo = Yii::$service->order->getOrderInfoByIncrementId($this->_order['increment_id']);
// 发送新订单邮件
Yii::$service->email->order->sendCreateEmail($orderInfo);
// Yii::$service->email->order->sendCreateEmail($orderInfo);
}
} elseif ($payment_status == $this->payment_status_pending) {
// pending 代表信用卡预付方式,需要等待paypal从信用卡中把钱扣除,因此订单状态是processing
......@@ -791,9 +793,11 @@ class Paypal extends Service
// 因为IPN消息可能不止发送一次,但是这里只允许一次,
// 如果重复发送,$updateColumn 的更新返回值将为0
if (!empty($updateColumn)) {
$orderInfo = Yii::$service->order->getOrderInfoByIncrementId($order['increment_id']);
// 发送新订单邮件
Yii::$service->email->order->sendCreateEmail($orderInfo);
// 执行订单支付成功后的事情。
Yii::$service->order->orderPaymentCompleteEvent($order['increment_id']);
// 上面的函数已经执行下面的代码,因此注释掉。
// $orderInfo = Yii::$service->order->getOrderInfoByIncrementId($order['increment_id']);
// Yii::$service->email->order->sendCreateEmail($orderInfo);
}
return true;
} else {
......@@ -824,7 +828,8 @@ class Paypal extends Service
['order_status' => Yii::$service->order->payment_status_pending]
]
);
// 这种情况不发送订单。
// 这种情况并没有接收到paypal的钱,只是一种支付等待状态,
// 因此,对于这种支付状态,视为正常订单,但是没有支付成功,需要延迟等待,如果支付成功,paypal会继续发送IPN消息。
return true;
} else {
// 金额不一致,判定为欺诈
......
......@@ -381,10 +381,11 @@ class Wxpay extends Service
$order->txn_id = $trade_no; // 微信的交易号
// 更新订单信息
$order->save();
Yii::$service->order->orderPaymentCompleteEvent($order['increment_id']);
// 得到当前的订单信息
$orderInfo = Yii::$service->order->getOrderInfoByIncrementId($order['increment_id']);
// $orderInfo = Yii::$service->order->getOrderInfoByIncrementId($order['increment_id']);
// 发送新订单邮件
Yii::$service->email->order->sendCreateEmail($orderInfo);
// Yii::$service->email->order->sendCreateEmail($orderInfo);
return true;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册