Authored by 毕凯

Merge branch 'develop' of http://git.dev.yoho.cn/web/yohobuy into develop

Showing 41 changed files with 644 additions and 181 deletions
... ... @@ -303,6 +303,7 @@ class AbstractAction extends Controller_Abstract
if (!$this->_uid) {
$cookie = $this->getCookie('_UID');
// 兼容老的
if (!empty($cookie)) {
$cookieList = explode('::', $cookie);
if (isset($cookieList[1]) && is_numeric($cookieList[1])) {
... ... @@ -321,6 +322,13 @@ class AbstractAction extends Controller_Abstract
$this->_usession = $cookieList[3];
$this->_vip = $cookieList[2];
}
}
// 新的, 如果老站没有同步成功,再尝试从SESSION获取
elseif ($useSession) {
$uid = $this->getSession('_LOGIN_UID');
if (!empty($uid)) {
$this->_uid = $uid;
}
}
}
return $this->_uid;
... ...
... ... @@ -22,7 +22,6 @@ class Yohobuy
// const API_URL2 = 'http://api.open.yohobuy.com/';
// const SERVICE_URL = 'http://service.api.yohobuy.com/';
// const YOHOBUY_URL = 'http://www.yohobuy.com/';
const API_URL = 'http://apih5.yoho.cn/';
const API_URL2 = 'http://apih5.yoho.cn/';
const SERVICE_URL = 'http://serviceh5.yoho.cn/';
... ... @@ -161,6 +160,7 @@ class Yohobuy
if (!$returnJson && !empty($result)) {
$result = json_decode($result, true);
}
curl_close($ch);
$data = array();
... ...
... ... @@ -258,7 +258,7 @@ class CartData
$param['uid'] = $uid;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
... ... @@ -349,6 +349,8 @@ class CartData
public static function orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin)
{
$param = Yohobuy::param();
$param['debug'] = 'Y';
$param['client_type'] = 'h5';
$param['method'] = 'app.Shopping.submit';
$param['address_id'] = $addressId;
$param['cart_type'] = $cartType;
... ...
... ... @@ -746,7 +746,7 @@ class Helpers
public static function syncUserSession($uid, $refer = '', $callback = 'call')
{
return 'http://mapi.yohobuy.com/Passport/session/index?callback=' . $callback
. '&sign=' .md5(md5($uid . 'Js8Yn0!EwPM45-ws')) . '&uid=' . $uid . '&go=' . $refer;
. '&sign=' . md5(md5($uid . 'Js8Yn0!EwPM45-ws')) . '&uid=' . $uid . '&go=' . $refer;
}
/**
... ...
<?php
namespace Plugin\Pay\Weixin;
namespace Plugin\Pay\weixin;
use Plugin\Pay\Weixin\Lib\WxPayApi;
use Plugin\Pay\Weixin\Lib\WxPayConfig;
use Plugin\Pay\Weixin\Lib\WxPayException;
use Plugin\Pay\Weixin\Lib\WxPayJsApiPay;
use Plugin\Pay\weixin\lib\WxPayApi;
use Plugin\Pay\weixin\lib\WxPayConfig;
use Plugin\Pay\weixin\lib\WxPayException;
use Plugin\Pay\weixin\lib\WxPayJsApiPay;
/**
*
... ...
<?php
namespace Plugin\Pay\Weixin;
namespace Plugin\Pay\weixin;
use Plugin\Pay\Weixin\Lib\WxPayApi;
use Plugin\Pay\Weixin\Lib\WxPayNotify;
use Plugin\Pay\weixin\lib\WxPayApi;
use Plugin\Pay\weixin\Lib\WxPayNotify;
class PayNotifyCallBack extends WxPayNotify
{
... ...
<?php
namespace Plugin\Pay\Weixin\Lib;
namespace Plugin\Pay\weixin\lib;
/**
*
... ...
... ... @@ -6,7 +6,7 @@
* Time: 17:58
*/
namespace Plugin\Pay\Weixin\Lib;
namespace Plugin\Pay\weixin\lib;
/**
... ...
... ... @@ -6,7 +6,7 @@
* Time: 17:54
*/
namespace Plugin\Pay\Weixin\Lib;
namespace Plugin\Pay\weixin\lib;
/**
... ...
<?php
namespace Plugin\Pay\Weixin\Lib;
/**
* 配置账号信息
*/
namespace Plugin\Pay\weixin\lib;
/**
* 配置账号信息
*/
class WxPayConfig
{
//=======【基本信息设置】=====================================
//
/**
* TODO: 修改这里配置为您自己申请的商户信息
* 微信公众号信息配置
*
* APPID:绑定支付的APPID(必须配置,开户邮件中可查看)
*
* MCHID:商户号(必须配置,开户邮件中可查看)
*
* KEY:商户支付密钥,参考开户邮件设置(必须配置,登录商户平台自行设置)
* 设置地址:https://pay.weixin.qq.com/index.php/account/api_cert
*
* APPSECRET:公众帐号secert(仅JSAPI支付的时候需要配置, 登录公众平台,进入开发者中心可设置),
* 获取地址:https://mp.weixin.qq.com/advanced/advanced?action=dev&t=advanced/dev&token=2005451881&lang=zh_CN
* @var string
*/
const APPID = 'wx75e5a7c0c88e45c2';
const MCHID = '1227694201';
const KEY = '7e6f3307b64cc87c79c472814b88f7fb';
const APPSECRET = 'ce21ae4a3f93852279175a167e54509b';
//=======【基本信息设置】=====================================
//
/**
* TODO: 修改这里配置为您自己申请的商户信息
* 微信公众号信息配置
*
* APPID:绑定支付的APPID(必须配置,开户邮件中可查看)
*
* MCHID:商户号(必须配置,开户邮件中可查看)
*
* KEY:商户支付密钥,参考开户邮件设置(必须配置,登录商户平台自行设置)
* 设置地址:https://pay.weixin.qq.com/index.php/account/api_cert
*
* APPSECRET:公众帐号secert(仅JSAPI支付的时候需要配置, 登录公众平台,进入开发者中心可设置),
* 获取地址:https://mp.weixin.qq.com/advanced/advanced?action=dev&t=advanced/dev&token=2005451881&lang=zh_CN
* @var string
*/
const APPID = 'wx75e5a7c0c88e45c2';
const MCHID = '1227694201';
const KEY = '7e6f3307b64cc87c79c472814b88f7fb';
const APPSECRET = 'ce21ae4a3f93852279175a167e54509b';
//=======【JSAPI路径设置】===================================
//获取access_token过程中的跳转uri,通过跳转将code传入jsapi支付页面
const JS_API_CALL_URL = 'http://m.dev.yohobuy.com/home/wechatnotify';
const JS_API_CALL_URL = 'http://m.yohobuy.com/shopping/pay/wechatwap';
//=======【异步通知url设置】===================================
//异步通知url,商户根据实际开发过程设定
const NOTIFY_URL = 'http://m.dev.yohobuy.com/home/wechatnotify';
const NOTIFY_URL = 'http://pay.yohobuy.com/notify/wechatwap';
//=======【证书路径设置】=====================================
/**
* TODO:设置商户证书路径
* 证书路径,注意应该填写绝对路径(仅退款、撤销订单时需要,可登录商户平台下载,
* API证书下载地址:https://pay.weixin.qq.com/index.php/account/api_cert,下载之前需要安装商户操作证书)
* @var path
*/
const SSLCERT_PATH = '../cert/apiclient_cert.pem';
const SSLKEY_PATH = '../cert/apiclient_key.pem';
//=======【curl代理设置】===================================
/**
* TODO:这里设置代理机器,只有需要代理的时候才设置,不需要代理,请设置为0.0.0.0和0
* 本例程通过curl使用HTTP POST方法,此处可修改代理服务器,
* 默认CURL_PROXY_HOST=0.0.0.0和CURL_PROXY_PORT=0,此时不开启代理(如有需要才设置)
* @var unknown_type
*/
const CURL_PROXY_HOST = "0.0.0.0";//"10.152.18.220";
const CURL_PROXY_PORT = 0;//8080;
//=======【上报信息配置】===================================
/**
* TODO:接口调用上报等级,默认紧错误上报(注意:上报超时间为【1s】,上报无论成败【永不抛出异常】,
* 不会影响接口调用流程),开启上报之后,方便微信监控请求调用的质量,建议至少
* 开启错误上报。
* 上报等级,0.关闭上报; 1.仅错误出错上报; 2.全量上报
* @var int
*/
const REPORT_LEVENL = 1;
/**
* TODO:设置商户证书路径
* 证书路径,注意应该填写绝对路径(仅退款、撤销订单时需要,可登录商户平台下载,
* API证书下载地址:https://pay.weixin.qq.com/index.php/account/api_cert,下载之前需要安装商户操作证书)
* @var path
*/
const SSLCERT_PATH = '../cert/apiclient_cert.pem';
const SSLKEY_PATH = '../cert/apiclient_key.pem';
//=======【curl代理设置】===================================
/**
* TODO:这里设置代理机器,只有需要代理的时候才设置,不需要代理,请设置为0.0.0.0和0
* 本例程通过curl使用HTTP POST方法,此处可修改代理服务器,
* 默认CURL_PROXY_HOST=0.0.0.0和CURL_PROXY_PORT=0,此时不开启代理(如有需要才设置)
* @var unknown_type
*/
const CURL_PROXY_HOST = "0.0.0.0"; //"10.152.18.220";
const CURL_PROXY_PORT = 0; //8080;
//=======【上报信息配置】===================================
/**
* TODO:接口调用上报等级,默认紧错误上报(注意:上报超时间为【1s】,上报无论成败【永不抛出异常】,
* 不会影响接口调用流程),开启上报之后,方便微信监控请求调用的质量,建议至少
* 开启错误上报。
* 上报等级,0.关闭上报; 1.仅错误出错上报; 2.全量上报
* @var int
*/
const REPORT_LEVENL = 1;
}
... ...
<?php
namespace Plugin\Pay\Weixin\Lib;
namespace Plugin\Pay\weixin\lib;
/**
* 2015-06-29 修复签名问题
... ...
... ... @@ -6,7 +6,7 @@
* Time: 17:56
*/
namespace Plugin\Pay\Weixin\Lib;
namespace Plugin\Pay\weixin\lib;
/**
... ...
<?php
namespace Plugin\Pay\Weixin\Lib;
namespace Plugin\Pay\weixin\lib;
use Exception;
/**
... ...
... ... @@ -6,7 +6,7 @@
* Time: 17:58
*/
namespace Plugin\Pay\Weixin\Lib;
namespace Plugin\Pay\weixin\lib;
/**
... ...
... ... @@ -6,7 +6,7 @@
* Time: 17:57
*/
namespace Plugin\Pay\Weixin\Lib;
namespace Plugin\Pay\weixin\lib;
/**
... ...
<?php
namespace Plugin\Pay\Weixin\Lib;
namespace Plugin\Pay\weixin\lib;
/**
*
... ...
... ... @@ -6,7 +6,7 @@
* Time: 17:52
*/
namespace Plugin\Pay\Weixin\Lib;
namespace Plugin\Pay\weixin\lib;
/**
*
... ...
... ... @@ -6,7 +6,7 @@
* Time: 17:53
*/
namespace Plugin\Pay\Weixin\Lib;
namespace Plugin\Pay\weixin\lib;
/**
... ...
... ... @@ -6,7 +6,7 @@
* Time: 17:54
*/
namespace Plugin\Pay\Weixin\Lib;
namespace Plugin\Pay\weixin\lib;
/**
... ...
... ... @@ -6,7 +6,7 @@
* Time: 17:56
*/
namespace Plugin\Pay\Weixin\Lib;
namespace Plugin\Pay\weixin\lib;
/**
... ...
... ... @@ -5,8 +5,7 @@
* Date: 2015/12/23
* Time: 17:56
*/
namespace Plugin\Pay\Weixin\Lib;
namespace Plugin\Pay\weixin\lib;
/**
... ...
... ... @@ -6,7 +6,7 @@
* Time: 17:51
*/
namespace Plugin\Pay\Weixin\Lib;
namespace Plugin\Pay\weixin\lib;
/**
*
... ...
... ... @@ -6,7 +6,7 @@
* Time: 17:57
*/
namespace Plugin\Pay\Weixin\Lib;
namespace Plugin\Pay\weixin\lib;
/**
... ...
... ... @@ -6,7 +6,7 @@
* Time: 17:57
*/
namespace Plugin\Pay\Weixin\Lib;
namespace Plugin\Pay\weixin\lib;
/**
... ...
... ... @@ -6,7 +6,7 @@
* Time: 17:52
*/
namespace Plugin\Pay\Weixin\Lib;
namespace Plugin\Pay\weixin\lib;
/**
... ...
... ... @@ -156,7 +156,7 @@ class TemplateLayout implements View_Interface
$template = file_get_contents($viewName, false, null);
$phpStr = LightnCandy::compile($template, array(
// DEBUG: LightnCandy::FLAG_RENDER_DEBUG | LightnCandy::FLAG_ERROR_EXCEPTION
'flags' => LightnCandy::FLAG_RENDER_DEBUG | LightnCandy::FLAG_ERROR_EXCEPTION | LightnCandy::FLAG_MUSTACHE | LightnCandy::FLAG_HANDLEBARS, // 使用MUSTACHE和HANDLEBARS的模板格式
'flags' => LightnCandy::FLAG_MUSTACHE | LightnCandy::FLAG_HANDLEBARS, // 使用MUSTACHE和HANDLEBARS的模板格式
'basedir' => array($config->template->partials), // 模板里使用 {{> partial_name}} 时查找的目录
'fileext' => array($tplExt), // 允许查找文件的后缀
'lcrun' => 'Plugin\LCRun3', // 指定编译模板的runtime
... ...
<?php
/**
* 联盟数据转换
*/
namespace Plugin;
use Hood\Core\Security\AuthCode;
use Api\Yohobuy;
use LibModels\Wap\Home\OrderData;
class UnionTrans
{
/**
* 第三方联盟名称
*
* @var array
*/
private static $unionNames = array(
1001 => '亿起发',
1010 => '领科特',
1009 => '成果网',
2995 => '亿起发wap',
2997 => '领科特wap',
3001 => '51fanli',
3017 => '多麦web',
3019 => '多麦wap',
3057 => '多麦优质',
);
/**
* 过滤人民币
*
* @param string $price
* @return array
*/
private static function filterPrice($price)
{
return strtr($price, array('-' => '', '+' => '', '¥' => ''));
}
/**
* 添加成交记录
*
* @param String $order_code
* @param Integer $pay_time
* @param Integer $ip
* @return bool
*/
public static function set($uid, $order_code, $order_amount)
{
$debug = false;
do {
/* 判断是否是友盟过来的用户 */
if (empty($_COOKIE['_QYH_UNION'])) {
break;
}
/* 判断参数是否有效 */
if (empty($uid) || empty($order_code) || empty($order_amount)) {
break;
}
/* 解密客户端联盟信息 */
$unionKey = AuthCode::decode($_COOKIE['_QYH_UNION'], 'q_union_yohobuy');
if (empty($unionKey)) {
break;
}
/* 检查联盟参数是否有效 */
$unionInfo = json_decode($unionKey, true);
if (empty($unionInfo['client_id'])) {
break;
}
if ($debug) {
var_dump('union info: ', $unionInfo);
}
/* 通过用户下单量判断新老客户 (有下单1, 没有0) */
$is_old_user = 0;
try {
$orderList = OrderData::getOrderData(1, 1, 2, '1,2,3', 1, $uid);
if (!empty($orderList['data']['total']) && intval($orderList['data']['total']) > 1) {
$is_old_user = 1;
}
} catch (Exception $e) {
// do nothing
}
$clientId = intval($unionInfo['client_id']);
$append = isset($unionInfo['append']) ? $unionInfo['append'] : '';
$channel_code = isset($unionInfo['channel_code']) ? $unionInfo['channel_code'] : '';
$mbr_name = isset($unionInfo['mbr_name']) ? $unionInfo['mbr_name'] : '';
$u_id = isset($unionInfo['u_id']) ? $unionInfo['u_id'] : '';
$create_times = time();
/* 加入联盟订单库 */
$keyStr = 'client_id=' . $unionInfo['client_id'] . '&order_code=' . $order_code . '&orders_price=' . $order_amount . '&create_time=' . $create_times . '&channel_code=' . $channel_code . '&append=' . $append . '&mbr_name=' . $mbr_name . '&u_id=' . $u_id;
$result = Yohobuy::get('http://union.yohobuy.com/order', array(
'client_id' => $unionInfo['client_id'],
'order_code' => $order_code,
'orders_price' => $order_amount,
'buy_time' => $create_times,
'channel_code' => $channel_code,
'append' => $append,
'mbr_name' => $mbr_name,
'u_id' => $u_id,
'is_old_user' => $is_old_user,
'verify_code' => md5($keyStr)
));
if ($debug) {
var_dump('union:', $result, "++");
}
/* 通知新ERP (老的ERP http://192.168.200.102/CreateOrderUnion.aspx) */
$result = Yohobuy::post('http://portal.admin.yohobuy.com/api/orderunion/updateunion', array(
'data' => json_encode(array(
'order_code' => $order_code,
'unionid' => $unionInfo['client_id'],
'union_name' => isset(self::$unionNames[$clientId]) ? self::$unionNames[$clientId] : '',
))
));
if ($debug) {
var_dump('erp:', $result, '++');
}
/* 对接第三方联盟 */
// 亿起发
if ($unionInfo['client_id'] == 1001) {
$keyStr = 'client_id=' . $unionInfo['client_id'] . '&orders_id=' . $order_code . '&orders_price=' . $order_amount . '&create_time=' . $create_times . '&channel_code=' . $channel_code . '&append=' . $append . '&is_old_user=' . $is_old_user;
$result = Yohobuy::get('http://o.yiqifa.com/adv/yoho.jsp', array(
'client_id' => $unionInfo['client_id'],
'orders_id' => $order_code,
'orders_price' => $order_amount,
'create_time' => $create_times,
'channel_code' => $channel_code,
'append' => $append,
'is_old_user' => $is_old_user,
'verify_code' => md5($keyStr)
));
if ($debug) {
var_dump('yiqifa:', $result, '++');
}
break;
}
// 亿起发wap
if ($unionInfo['client_id'] == 2995) {
$keyStr = 'client_id=' . $unionInfo['client_id'] . '&orders_id=' . $order_code . '&orders_price=' . $order_amount . '&create_time=' . $create_times . '&channel_code=' . $channel_code . '&append=' . $append . '&is_old_user=' . $is_old_user;
$result = Yohobuy::get('http://o.yiqifa.com/adv/yoho.jsp', array(
'client_id' => $unionInfo['client_id'],
'orders_id' => $order_code,
'orders_price' => $order_amount,
'create_time' => $create_times,
'channel_code' => $channel_code,
'append' => $append,
'is_old_user' => $is_old_user,
'dt' => 'm',
'verify_code' => md5($keyStr)
));
if ($debug) {
var_dump('yiqifa wap:', $result, '++');
}
break;
}
// 多麦
$clientUrls = array(
3017 => 'http://www.duomai.com/api/push/yohobuy.php',
3019 => 'http://www.duomai.com/api/push/myohobuy.php',
3057 => 'http://www.duomai.com/api/push/yohobuyroi.php',
);
if (array_key_exists($clientId, $clientUrls)) {
$urldata = self::getMaiDuoSplitData($order_code, $uid, $unionInfo['client_id'], $mbr_name, $is_old_user);
$result = Yohobuy::post($clientUrls[$clientId], array(
'content' => $urldata,
));
if ($debug) {
var_dump('duomai: ', $urldata, '++', $result);
}
break;
}
// 51fanli
if ($unionInfo['client_id'] == 3001) {
$xmldata = self::getOrderXmlData($order_code, $uid, $unionInfo['client_id'], $u_id, $mbr_name, $channel_code);
$keyStr = 'content=' . $xmldata . '&shopid=690';
$result = Yohobuy::post('http://union.fanli.com/dingdan/push?shopid=690', array(
'content' => $xmldata,
'shopid' => 690,
'verify_code' => md5($keyStr)
));
if ($debug) {
var_dump('fanli: ', $xmldata, '++', $result);
}
break;
}
// 领科特wap 成果 51fanli
$clientUrls = array(
1010 => 'http://service.linktech.cn/purchase_cps.php',
1009 => 'http://count.chanet.com.cn/add_action_ec.cgi',
2997 => 'http://service.linktech.cn/purchase_cps.php',
3001 => 'http://union.fanli.com/dingdan/push?shopid=690',
);
if (array_key_exists($clientId, $clientUrls)) {
$result = Yohobuy::post($clientUrls[$clientId], array(
'client_id' => $unionInfo['client_id'],
'order_id' => $order_code,
'create_time' => $create_times,
'channel_code' => $channel_code,
'append' => $append,
'mbr_name' => $mbr_name,
'UID' => $u_id,
'is_old_user' => $is_old_user,
));
if ($debug) {
var_dump('other: ', $result);
}
break;
}
} while (false);
}
/**
* 根据用户id和订单号, 返回xml数据
*/
public static function getOrderXmlData($order_id, $uid, $client_id, $u_id, $mbr_name, $channel_code, $client_type = 'web')
{
$xmlData = '';
do {
$orderDetail = OrderData::viewOrderData($order_id, $uid, '');
if (empty($orderDetail['data'])) {
break;
}
$orderDetail = $orderDetail['data'];
$amount = self::filterPrice($orderDetail['amount']) - self::filterPrice($orderDetail['shipping_cost']);
if (empty($orderDetail['order_goods'])) {
break;
}
$goodsAmount = self::filterPrice($orderDetail['goods_total_amount']);
$goodsData = array();
foreach ($orderDetail['order_goods'] as $key => $val) {
$goodsData['goods' . $key] = array(
'pid' => $val['product_skn'],
'title' => '',//$val['product_name'],
'category' => '', //$val['color_name'],
'category_title' => '',
'url' => 'http://item.m.yohobuy.com/product/show_' . $val['product_skn'] . '.html',
'num' => $val['buy_number'],
'price' => $val['goods_price'],
'real_pay_fee' => round($amount * ($val['goods_amount'] / $goodsAmount), 2),
'refund_num' => '',
'commission' => round($amount * ($val['goods_amount'] / $goodsAmount) * 0.05, 2),
'comm_type' => 'A',
);
}
$orderData[] = array(
's_id' => 690,
'order_id_parent' => $orderDetail['order_code'],
'order_id' => $orderDetail['order_code'],
'order_time' => date('Y-m-d H:i:s', $orderDetail['create_time']),
'uid' => $u_id,
'uname' => $mbr_name,
'tc' => $channel_code,
'pay_time' => '',
'status' => $orderDetail['status'],
'locked' => '',
'lastmod' => '',
'is_newbuyer' => '',
'platform' => ($client_type == 'h5') ? 2 : 1,
'code' => '',
'remark' => '',
'products' => $goodsData,
);
$xmlData = strtr(self::toXml($orderData), array('<![CDATA[", "]]>' => ''));
} while (false);
return $xmlData;
}
/**
* 麦多联盟
*/
public static function getMaiDuoSplitData($order_code, $uid, $client_id, $mbr_name, $is_old_user)
{
$result = '';
do {
$orderDetail = OrderData::viewOrderData($order_code, $uid, '');
if (empty($orderDetail['data']['order_goods'])) {
break;
}
$orderDetail = $orderDetail['data'];
if ($client_id == '3017') {
$hash = '96613bf38393aa3d16451218f22344a8';
$channel = 0;
} elseif ($client_id == '3019') {
$hash = 'd54be2dbc75753eb863ba6139950656b';
$channel = 1;
} elseif ($client_id == '3057') {
$hash = 'bbf70bcaf5c52947ad26853f7cc1176d';
$channel = 0;
} else {
break;
}
$goodsName = '';
$goodsIds = '';
$goodsPrice = '';
$goodsTotalPrice = '';
$goodsNum = '';
foreach ($orderDetail['order_goods'] as $val) {
$goodsName .= str_replace(array("&", "<", ">", "'", '"', " ", "|"), array("&amp;", "&lt;", "&gt;", "&quot;", "&apos;", "%20", "%20"), $val['product_name']) . '|';
$goodsIds = $val['product_sku'] . '|';
$goodsPrice = $val['goods_price'] . '|';
$goodsTotalPrice = $val['goods_amount'] . '|';
$goodsNum = $val['buy_number'] . '|';
}
$orderStatus = $orderDetail['status_str'];
if ($orderDetail['is_cancel'] == 'Y') {
$orderStatus = -1;
} elseif ($orderDetail['payment_status'] == 'N' && $orderDetail['status'] == 0) {
$orderStatus = 0;
}
$orderData = array(
'hash' => $hash,
'euid' => $mbr_name,
'order_sn' => $order_code,
'order_time' => date('Y-m-d H:i:s', $orderDetail['create_time']),
'orders_price' => sprintf('%.2f', self::filterPrice($orderDetail['goods_total_amount'])),
'promotion_code' => 0,
'is_new_custom' => $is_old_user ? 0 : 1,
'channel' => $channel,
'status' => $orderStatus,
'goods_id' => rtrim($goodsIds, '|'), //商品id,
'goods_name' => rtrim($goodsName, '|'), //商品名称,
'goods_price' => rtrim($goodsPrice, '|'), //商品单价,
'goods_ta' => rtrim($goodsNum, '|'), //商品数量,
'goods_cate' => '', //商品分类
'goods_cate_name' => 0,
'totalPrice' => rtrim($goodsTotalPrice, '|'), //商品总净金额,
'rate' => 0,
'commission' => '', //佣金,
'commission_type' => 0,
'coupon' => sprintf('%.2f', self::filterPrice($orderDetail['coupons_amount']))
);
$result = http_build_query($orderData);
} while (false);
return $result;
}
/**
* @param array $data
* @param string $rootNodeName - what you want the root node to be - defaultsto data.
* @param SimpleXMLElement $xml - should only be used recursively
* @return string XML
*/
public static function toXml($data, $rootNodeName = 'data', $xml = null)
{
// turn off compatibility mode as simple xml throws a wobbly if you don't.
if (ini_get('zend.ze1_compatibility_mode') == 1) {
ini_set('zend.ze1_compatibility_mode', 0);
}
if ($xml == null) {
$xml = simplexml_load_string("<?xml version='1.0' encoding='utf-8'?><$rootNodeName />");
}
// loop through the data passed in.
foreach ($data as $key => $value) {
// no numeric keys in our xml please!
if (is_numeric($key)) {
// make string key...
$key = "unknownNode_" . (string) $key;
}
// if there is another array found recrusively call this function
if (is_array($value)) {
$node = $xml->addChild($key);
// recrusive call.
self::toXml($value, $rootNodeName, $node);
} else {
// add single node.
$value = htmlentities($value);
$xml->addChild($key, $value);
}
}
// pass back as string. or simple xml object if you want!
return $xml->asXML();
}
}
... ...
... ... @@ -363,6 +363,15 @@ server
proxy_set_header Accept-Encoding "gzip";
}
location ^~ /shopping/pay/wechatwapapi {
proxy_redirect off;
proxy_pass http://yohobuy;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Encoding "gzip";
}
location / {
proxy_redirect off;
proxy_pass http://119.254.81.245;
... ...
{
"name": "yohobuy",
"version": "1.2.6",
"version": "1.2.7",
"description": "yohobuy statics",
"keywords": [],
"homepage": "",
... ...
... ... @@ -30,6 +30,7 @@ var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "http://static.yohobuy.com/js/analytics/analysis.js";
hm.async = 1;
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
... ... @@ -37,4 +38,40 @@ var _hmt = _hmt || [];
window.addEventListener('load', async_load, false);
})();
</script>
<<<<<<< HEAD
<!-- End Google Tag Manager -->
<script type="text/javascript">
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "//hm.baidu.com/hm.js?c6ee7218b8321cb65fb2e98f284d8311";
hm.async = 1;
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
<script>
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "//hm.baidu.com/hm.js?65dd99e0435a55177ffda862198ce841";
hm.async = 1;
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
<script>
window._py = window._py||[];
window._py.push(['a', 'MC..o8vMMWxEXDCiqYckD81lUX']);
window._py.push(['domain','stats.ipinyou.com']);
if(typeof _goodsData!='undefined')
window._py.push(['pi',_goodsData]);
window._py.push(['e','']);
-function(d){
var f = 'https:' == d.location.protocol;var c = d.createElement('script');c.type='text/javascript';c.async=1;
c.src=(f ? 'https' : 'http') + '://'+(f?'fm.ipinyou.com':'fm.p0y.cn')+'/j/t/adv.js';
var h = d.getElementsByTagName("script")[0];h.parentNode.insertBefore(c, h);
}(document);
</script>
<script src="http://static.yohobuy.com/js/analytics/analysis.js" async="async"></script>
<script src="http://static.yohobuy.com/m/v1/js/om_code.js" async="async"></script>
\ No newline at end of file
... ...
... ... @@ -18,8 +18,8 @@
{{#if devEnv}}
<script src="http://localhost:8000/static/js/sea.js?nowrap"></script>
<script>seajs.config({base: 'http://localhost:8000/'});</script>
{{/if}}
{{> layout/use}}
{{/if}}
{{> layout/use}}
{{> layout/analysis}}
</body>
</html>
\ No newline at end of file
... ...
... ... @@ -6,11 +6,10 @@ use Home\OrderModel;
use Plugin\Helpers;
use LibModels\Wap\Home\OrderData;
use Index\UserModel as UserModel;
use Plugin\Pay\Weixin\JsApiPay;
use Plugin\Pay\Weixin\Lib\WxPayApi;
use Plugin\Pay\Weixin\Lib\WxPayUnifiedOrder;
use Plugin\Pay\Weixin\PayNotifyCallBack;
use Plugin\Pay\Weixin\Lib\WxPayConfig;
use Plugin\Pay\weixin\JsApiPay;
use Plugin\Pay\weixin\lib\WxPayUnifiedOrder;
use Plugin\Pay\weixin\lib\WxPayApi;
use Plugin\Pay\weixin\lib\WxPayConfig;
/**
* 个人中心相关的控制器
... ... @@ -56,7 +55,7 @@ class HomeController extends AbstractAction
'cartUrl' => Helpers::url('/cart/index/index', null),
'signinUrl' => Helpers::url('/signin.html', array('refer' => Helpers::url('/home'))),
);
$uid = $this->getUid(false);
$uid = $this->getUid(true);
if ($uid) {
$data['isLogin'] = true;
$udid = $this->getUdid();
... ... @@ -645,13 +644,14 @@ class HomeController extends AbstractAction
* 我的订单页面,获得nav导航条焦点。并且异步请求订单详情列表页(getOrders)
*
*/
public function ordersAction()
{
// 审判跳转登录页
$this->auditJumpLogin();
$this->setTitle('我的订单');
$this->setNavHeader('我的订单', Helpers::url('/home') );
$this->setNavHeader('我的订单', Helpers::url('/home'));
$order = array();
//获得type值,type:1=>全部,2=>待付款,3=>待发货,4=>待收货,5=>待评论
... ... @@ -780,6 +780,7 @@ class HomeController extends AbstractAction
/*
* 我的订单-付款跳转页
*/
public function payAction()
{
// 审判跳转登录页
... ... @@ -793,6 +794,15 @@ class HomeController extends AbstractAction
$this->error();
}
$hasWxShare = strpos($this->server('HTTP_USER_AGENT', ''), 'MicroMessenger') !== false;
if ($hasWxShare) {
$tools = new JsApiPay();
$openId = $tools->GetOpenid();
if ($openId) {
$this->setSession('weixinOpenId', $openId);
}
}
$this->_view->display('pay', array(
'payCenterPage' => true,
'payAppInfo' => array(
... ... @@ -814,94 +824,59 @@ class HomeController extends AbstractAction
),
),
'orderCode' => $orderCode,
'hasWxShare' => strpos($this->server('HTTP_USER_AGENT', ''), 'MicroMessenger') !== false
'hasWxShare' => $hasWxShare,
));
}
/*
* 微信支付
*/
public function wechatpayAction()
{
// 审判跳转登录页
$this->auditJumpLogin();
$orderCode = $this->get('order_code');
if (empty($orderCode)) {
$this->error();
}
/* 订单信息不存在 */
$orderDetail = OrderModel::orderDetail($orderCode, $this->_uid, $this->_usession);
if (empty($orderDetail)) {
$this->error();
}
//①、获取用户openid
$tools = new JsApiPay();
$openId = $tools->GetOpenid();
//②、统一下单
$input = new WxPayUnifiedOrder();
$input->SetBody("test");
$input->SetAttach("test");
$input->SetOut_trade_no(WxPayConfig::MCHID.date("YmdHis"));
$input->SetTotal_fee("1");
$input->SetTime_start(date("YmdHis"));
$input->SetTime_expire(date("YmdHis", time() + 600));
$input->SetGoods_tag("test");
$input->SetNotify_url(WxPayConfig::NOTIFY_URL);
$input->SetTrade_type("JSAPI");
$input->SetOpenid($openId);
$order = WxPayApi::unifiedOrder($input);
$jsApiParameters = $tools->GetJsApiParameters($order);
$this->echoJson(array('code' => 200, 'data' => array('jsApiParameters' => $jsApiParameters)));
}
/*
* 微信支付notify页面
*/
public function wechatnotifyAction()
{
$notify = new PayNotifyCallBack();
$notify->Handle(false);
}
/**
* 微信支付 API
*/
public function weixinapiAction()
{
do {
// if (!$this->isAjax()) {
// break;
// }
//
// $uid = $this->getUid(true);
// if (!$uid) {
// break;
// }
if (!$this->isAjax()) {
break;
}
$uid = $this->getUid(true);
if (!$uid) {
break;
}
$orderCode = $this->get('order_code');
if (empty($orderCode)) {
break;
}
$result = OrderData::weixinPaySign($orderCode);
if (empty($result['data'])) {
/* 判断订单信息不存在 */
$orderDetail = OrderData::viewOrderData($orderCode, $uid, $this->_usession);
if (empty($orderDetail['data'])) {
break;
}
$result['data'] = isset($result['data']['prePayData']) ? $result['data']['prePayData'] : array();
$result['data']['appId'] = 'wx049fdaa3ba9cdd7a'; //'wx75e5a7c0c88e45c2';
$result['data']['signType'] = 'MD5';
$result['data']['package'] = isset($result['data']['prepayId']) ? 'prepay_id=' . $result['data']['prepayId'] : '';
$result['data']['paySign'] = isset($result['data']['sign']) ? strtoupper($result['data']['sign']) : '';
$this->echoJson(array('code' => 200, 'data' => array('jsApiParameters' => $result['data'])) );
}
while (false);
$totalFee = intval(strtr($orderDetail['data']['amount'], array('¥' => ''))) * 100;
$openId = $this->getSession('weixinOpenId');
if (empty($openId)) {
break;
}
//统一下单
$tools = new JsApiPay();
$input = new WxPayUnifiedOrder();
$input->SetBody('有货订单号:' . $orderCode);
$input->SetOut_trade_no('YOHOBuy_' . $orderCode); // 商户订单号
$input->SetTotal_fee($totalFee);
$input->SetTime_start(date("YmdHis", (int) $orderDetail['data']['create_time']));
$input->SetTime_expire(date("YmdHis", (int) $orderDetail['data']['create_time'] + 7200));
$input->SetNotify_url(WxPayConfig::NOTIFY_URL);
$input->SetTrade_type("JSAPI");
$input->SetOpenid($openId);
$order = WxPayApi::unifiedOrder($input);
$jsApiParameters = $tools->GetJsApiParameters($order);
$this->echoJson(array('code' => 200, 'data' => array('jsApiParameters' => json_decode($jsApiParameters) )) );
} while (false);
}
// /*
... ...
... ... @@ -89,7 +89,7 @@ class CartModel
}
// 普通购物车空,则显示预售购物车
if ($ordinaryCount === '0' && $ordinaryCount) {
if ($ordinaryCount === '0' && $ordinarySoldOut) {
$result['cartNav'] = false;
$result['cartType'] = 'advance';
}
... ... @@ -322,7 +322,7 @@ class CartModel
{
$result = array();
$pay = CartData::cartPay($uid, $cartType);
$pay = CartData::cartPay($uid, $cartType);
// 商品为空返回
if (!$pay || (isset($pay['data']['goods_list']) && empty($pay['data']['goods_list']))) {
... ...
... ... @@ -39,7 +39,6 @@ class DetailModel
elseif (is_numeric($productSkn)) {
$baseInfo = DetailData::baseInfo(null, $uid, $productSkn);
}
// 商品名称
if (empty($baseInfo['productName'])) {
return $result;
... ...
... ... @@ -4,6 +4,7 @@ use Action\AbstractAction;
use Index\CartModel;
use Index\UserModel;
use Plugin\Helpers;
use Plugin\UnionTrans;
/**
* 购物车相关的控制器
... ... @@ -423,8 +424,16 @@ class IndexController extends AbstractAction
} else {
// 提交成功清除Cookie
$this->setCookie('order-info', null);
$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
}
}
}
}
... ...
... ... @@ -44,6 +44,9 @@ class LoginController extends AbstractAction
// 渲染模板
$this->_view->display('index', $data);
// 设置登录有效时间30分钟, 防机器刷
$this->setSession('_LOGIN_EXPIRE', time() + 1800);
}
/**
... ... @@ -67,6 +70,9 @@ class LoginController extends AbstractAction
$data['countrys'] = RegData::getAreasData(); // 地区信息列表
// 渲染模板
$this->_view->display('international', $data);
// 设置登录有效时间30分钟, 防机器刷
$this->setSession('_LOGIN_EXPIRE', time() + 1800);
}
/**
... ... @@ -80,6 +86,7 @@ class LoginController extends AbstractAction
$this->setCookie('_SPK', '');
// 清除服务端会话
$this->setSession('_TOKEN', '');
$this->setSession('_LOGIN_UID', '');
$refer = $this->server('HTTP_REFERER', SITE_MAIN);
$token = $this->get('token');
... ... @@ -122,7 +129,13 @@ class LoginController extends AbstractAction
if (!$verifyEmail && !$verifyMobile) {
break;
}
/* 设置登录有效时间30分钟, 防机器刷 */
$expire = $this->getSession('_LOGIN_EXPIRE');
if (empty($expire) || $expire < time()) {
break;
}
/* 调用登录接口进行登录 */
// 获取未登录时的唯一识别码
$shoppingKey = Helpers::getShoppingKeyByCookie();
... ... @@ -143,6 +156,8 @@ class LoginController extends AbstractAction
$token = Helpers::makeToken($data['data']['uid']);
$this->setCookie('_TOKEN', $token);
$this->setSession('_TOKEN', $token);
$this->setSession('_LOGIN_UID', $data['data']['uid']);
} while (false);
$this->echoJson($data);
... ... @@ -213,6 +228,7 @@ class LoginController extends AbstractAction
$token = Helpers::makeToken($result['data']['uid']);
$this->setCookie('_TOKEN', $token);
$this->setSession('_TOKEN', $token);
$this->setSession('_LOGIN_UID', $result['data']['uid']);
$this->go(Helpers::syncUserSession($result['data']['uid'], $refer));
} else {
$this->go($refer);
... ... @@ -250,6 +266,7 @@ class LoginController extends AbstractAction
$token = Helpers::makeToken($result['data']['uid']);
$this->setCookie('_TOKEN', $token);
$this->setSession('_TOKEN', $token);
$this->setSession('_LOGIN_UID', $result['data']['uid']);
$this->go(Helpers::syncUserSession($result['data']['uid'], $refer));
} else {
$this->go($refer);
... ... @@ -287,6 +304,7 @@ class LoginController extends AbstractAction
$token = Helpers::makeToken($result['data']['uid']);
$this->setCookie('_TOKEN', $token);
$this->setSession('_TOKEN', $token);
$this->setSession('_LOGIN_UID', $result['data']['uid']);
$this->go(Helpers::syncUserSession($result['data']['uid'], $refer));
} else {
$this->go($refer);
... ...
... ... @@ -50,7 +50,7 @@ application.template.ext = ".phtml"
application.assets.path = ROOT_PATH "/assets"
; 应用的版本号
application.version = "1.2.6"
application.version = "1.2.7"
; 网站SEO信息
application.seo.title = "Yoho!Buy有货 | 潮流购物逛不停"
... ...
... ... @@ -50,7 +50,7 @@ application.template.ext = ".phtml"
application.assets.path = ROOT_PATH "/assets"
; 应用的版本号
application.version = "1.2.6"
application.version = "1.2.7"
; 网站SEO信息
application.seo.title = "Yoho!Buy有货 | 潮流购物逛不停"
... ...
... ... @@ -50,7 +50,7 @@ application.template.ext = ".phtml"
application.assets.path = ROOT_PATH "/assets"
; 应用的版本号
application.version = "1.2.6"
application.version = "1.2.7"
; 网站SEO信息
application.seo.title = "Yoho!Buy有货 | 潮流购物逛不停"
... ...
... ... @@ -50,7 +50,7 @@ application.template.ext = ".phtml"
application.assets.path = ROOT_PATH "/assets"
; 应用的版本号
application.version = "1.2.6"
application.version = "1.2.7"
; 网站SEO信息
application.seo.title = "Yoho!Buy有货 | 潮流购物逛不停"
... ...
... ... @@ -156,10 +156,10 @@ routes.productskn.map.1 = productSkn
; 订单相关
routes.cart.type = "rewrite"
routes.cart.match = "/home/order/detail$"
routes.cart.match = "/home/orders/detail$"
routes.cart.route.module = Index
routes.cart.route.controller = Home
routes.cart.route.action = homedetail
routes.cart.route.action = Orderdetail
; 微信支付接口
routes.weixinapi.type = "rewrite"
... ...