Authored by hf

do add union code and fixes bug to weixin pay

... ... @@ -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
... ...
... ... @@ -51,6 +51,8 @@ class UnionTrans
*/
public static function set($uid, $order_code, $order_amount)
{
$debug = false;
do {
/* 判断是否是友盟过来的用户 */
if (empty($_COOKIE['_QYH_UNION'])) {
... ... @@ -63,7 +65,7 @@ class UnionTrans
}
/* 解密客户端联盟信息 */
$unionKey = AuthCode::decode($_COOKIE['_QYH_UNION'], 'q_union_yohobuy');
$unionKey = AuthCode::decode($_COOKIE['_QYH_UNION'], 'q_union_yohobuy');
if (empty($unionKey)) {
break;
}
... ... @@ -73,11 +75,14 @@ class UnionTrans
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, 10, '1,2,3', 1, $uid);
$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;
}
... ... @@ -94,7 +99,7 @@ class UnionTrans
/* 加入联盟订单库 */
$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;
Yohobuy::get('http://union.yohobuy.com/order', array(
$result = Yohobuy::get('http://union.yohobuy.com/order', array(
'client_id' => $unionInfo['client_id'],
'order_code' => $order_code,
'orders_price' => $order_amount,
... ... @@ -106,22 +111,28 @@ class UnionTrans
'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) */
Yohobuy::post('http://portal.admin.yohobuy.com/api/orderunion/updateunion', array(
$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;
Yohobuy::get('http://o.yiqifa.com/adv/yoho.jsp', array(
$result = Yohobuy::get('http://o.yiqifa.com/adv/yoho.jsp', array(
'client_id' => $unionInfo['client_id'],
'orders_id' => $order_code,
'orders_price' => $order_amount,
... ... @@ -131,13 +142,16 @@ class UnionTrans
'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;
Yohobuy::get('http://o.yiqifa.com/adv/yoho.jsp', array(
$result = Yohobuy::get('http://o.yiqifa.com/adv/yoho.jsp', array(
'client_id' => $unionInfo['client_id'],
'orders_id' => $order_code,
'orders_price' => $order_amount,
... ... @@ -148,6 +162,9 @@ class UnionTrans
'dt' => 'm',
'verify_code' => md5($keyStr)
));
if ($debug) {
var_dump('yiqifa wap:', $result, '++');
}
break;
}
... ... @@ -158,10 +175,13 @@ class UnionTrans
3057 => 'http://www.duomai.com/api/push/yohobuyroi.php',
);
if (array_key_exists($clientId, $clientUrls)) {
$urldata = self::getMaiDuoSplitData($order_code, $unionInfo['client_id'], $mbr_name);
Yohobuy::post($clientUrls[$clientId], array(
$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;
}
... ... @@ -169,11 +189,14 @@ class UnionTrans
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';
Yohobuy::post('http://union.fanli.com/dingdan/push?shopid=690', array(
$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;
}
... ... @@ -185,7 +208,7 @@ class UnionTrans
3001 => 'http://union.fanli.com/dingdan/push?shopid=690',
);
if (array_key_exists($clientId, $clientUrls)) {
Yohobuy::post($clientUrls[$clientId], array(
$result = Yohobuy::post($clientUrls[$clientId], array(
'client_id' => $unionInfo['client_id'],
'order_id' => $order_code,
'create_time' => $create_times,
... ... @@ -195,6 +218,9 @@ class UnionTrans
'UID' => $u_id,
'is_old_user' => $is_old_user,
));
if ($debug) {
var_dump('other: ', $result);
}
break;
}
} while (false);
... ... @@ -215,18 +241,18 @@ class UnionTrans
$orderDetail = $orderDetail['data'];
$amount = self::filterPrice($orderDetail['amount']) - self::filterPrice($orderDetail['shipping_cost']);
if (!empty($orderDetail['order_goods'])) {
if (empty($orderDetail['order_goods'])) {
break;
}
$goodsAmount = $orderDetail['goods_total_amount'];
$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'],
'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'],
... ... @@ -251,7 +277,7 @@ class UnionTrans
'locked' => '',
'lastmod' => '',
'is_newbuyer' => '',
'platform' => $client_type == 'h5' ? 2 : 1,
'platform' => ($client_type == 'h5') ? 2 : 1,
'code' => '',
'remark' => '',
'products' => $goodsData,
... ... @@ -318,7 +344,7 @@ class UnionTrans
'euid' => $mbr_name,
'order_sn' => $order_code,
'order_time' => date('Y-m-d H:i:s', $orderDetail['create_time']),
'orders_price' => sprintf('%.2f', $orderDetail['goods_total_amount']),
'orders_price' => sprintf('%.2f', self::filterPrice($orderDetail['goods_total_amount'])),
'promotion_code' => 0,
'is_new_custom' => $is_old_user ? 0 : 1,
'channel' => $channel,
... ...
... ... @@ -32,5 +32,8 @@
{{/ payAppInfo}}
</div>
</div>
{{#if oldWeixinAuthUrl}}
<iframe height="0" width="0" src="{{oldWeixinAuthUrl}}" style="display:none"></iframe>
{{/if}}
{{> layout/footer}}
... ...
... ... @@ -788,6 +788,8 @@ class HomeController extends AbstractAction
$this->error();
}
$hasWxShare = strpos($this->server('HTTP_USER_AGENT', ''), 'MicroMessenger') !== false;
$this->_view->display('pay', array(
'payCenterPage' => true,
'payAppInfo' => array(
... ... @@ -809,7 +811,8 @@ class HomeController extends AbstractAction
),
),
'orderCode' => $orderCode,
'hasWxShare' => strpos($this->server('HTTP_USER_AGENT', ''), 'MicroMessenger') !== false
'hasWxShare' => $hasWxShare,
'oldWeixinAuthUrl' => Helpers::url('/home/orders/tickets', array('order_code' => 0)), // 解决老站微信支付很坑的问题
));
}
... ...
... ... @@ -39,7 +39,6 @@ class DetailModel
elseif (is_numeric($productSkn)) {
$baseInfo = DetailData::baseInfo(null, $uid, $productSkn);
}
// 商品名称
if (empty($baseInfo['productName'])) {
return $result;
... ...
... ... @@ -429,12 +429,16 @@ class IndexController extends AbstractAction
} else {
// 提交成功清除Cookie
$this->setCookie('order-info', null);
// if ($uid && !empty($result['data'])) {
// UnionTrans::set($uid, $result['data']['order_code'], $result['data']['order_amount']);
// }
$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
}
}
}
}
... ...
... ... @@ -156,7 +156,7 @@ 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
... ...