Authored by hf

do add union code and fixes bug to weixin pay

@@ -156,7 +156,7 @@ class TemplateLayout implements View_Interface @@ -156,7 +156,7 @@ class TemplateLayout implements View_Interface
156 $template = file_get_contents($viewName, false, null); 156 $template = file_get_contents($viewName, false, null);
157 $phpStr = LightnCandy::compile($template, array( 157 $phpStr = LightnCandy::compile($template, array(
158 // DEBUG: LightnCandy::FLAG_RENDER_DEBUG | LightnCandy::FLAG_ERROR_EXCEPTION 158 // DEBUG: LightnCandy::FLAG_RENDER_DEBUG | LightnCandy::FLAG_ERROR_EXCEPTION
159 - 'flags' => LightnCandy::FLAG_RENDER_DEBUG | LightnCandy::FLAG_ERROR_EXCEPTION | LightnCandy::FLAG_MUSTACHE | LightnCandy::FLAG_HANDLEBARS, // 使用MUSTACHE和HANDLEBARS的模板格式 159 + 'flags' => LightnCandy::FLAG_MUSTACHE | LightnCandy::FLAG_HANDLEBARS, // 使用MUSTACHE和HANDLEBARS的模板格式
160 'basedir' => array($config->template->partials), // 模板里使用 {{> partial_name}} 时查找的目录 160 'basedir' => array($config->template->partials), // 模板里使用 {{> partial_name}} 时查找的目录
161 'fileext' => array($tplExt), // 允许查找文件的后缀 161 'fileext' => array($tplExt), // 允许查找文件的后缀
162 'lcrun' => 'Plugin\LCRun3', // 指定编译模板的runtime 162 'lcrun' => 'Plugin\LCRun3', // 指定编译模板的runtime
@@ -51,6 +51,8 @@ class UnionTrans @@ -51,6 +51,8 @@ class UnionTrans
51 */ 51 */
52 public static function set($uid, $order_code, $order_amount) 52 public static function set($uid, $order_code, $order_amount)
53 { 53 {
  54 + $debug = false;
  55 +
54 do { 56 do {
55 /* 判断是否是友盟过来的用户 */ 57 /* 判断是否是友盟过来的用户 */
56 if (empty($_COOKIE['_QYH_UNION'])) { 58 if (empty($_COOKIE['_QYH_UNION'])) {
@@ -63,7 +65,7 @@ class UnionTrans @@ -63,7 +65,7 @@ class UnionTrans
63 } 65 }
64 66
65 /* 解密客户端联盟信息 */ 67 /* 解密客户端联盟信息 */
66 - $unionKey = AuthCode::decode($_COOKIE['_QYH_UNION'], 'q_union_yohobuy'); 68 + $unionKey = AuthCode::decode($_COOKIE['_QYH_UNION'], 'q_union_yohobuy');
67 if (empty($unionKey)) { 69 if (empty($unionKey)) {
68 break; 70 break;
69 } 71 }
@@ -73,11 +75,14 @@ class UnionTrans @@ -73,11 +75,14 @@ class UnionTrans
73 if (empty($unionInfo['client_id'])) { 75 if (empty($unionInfo['client_id'])) {
74 break; 76 break;
75 } 77 }
  78 + if ($debug) {
  79 + var_dump('union info: ', $unionInfo);
  80 + }
76 81
77 /* 通过用户下单量判断新老客户 (有下单1, 没有0) */ 82 /* 通过用户下单量判断新老客户 (有下单1, 没有0) */
78 $is_old_user = 0; 83 $is_old_user = 0;
79 try { 84 try {
80 - $orderList = OrderData::getOrderData(1, 1, 10, '1,2,3', 1, $uid); 85 + $orderList = OrderData::getOrderData(1, 1, 2, '1,2,3', 1, $uid);
81 if (!empty($orderList['data']['total']) && intval($orderList['data']['total']) > 1) { 86 if (!empty($orderList['data']['total']) && intval($orderList['data']['total']) > 1) {
82 $is_old_user = 1; 87 $is_old_user = 1;
83 } 88 }
@@ -94,7 +99,7 @@ class UnionTrans @@ -94,7 +99,7 @@ class UnionTrans
94 99
95 /* 加入联盟订单库 */ 100 /* 加入联盟订单库 */
96 $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; 101 $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;
97 - Yohobuy::get('http://union.yohobuy.com/order', array( 102 + $result = Yohobuy::get('http://union.yohobuy.com/order', array(
98 'client_id' => $unionInfo['client_id'], 103 'client_id' => $unionInfo['client_id'],
99 'order_code' => $order_code, 104 'order_code' => $order_code,
100 'orders_price' => $order_amount, 105 'orders_price' => $order_amount,
@@ -106,22 +111,28 @@ class UnionTrans @@ -106,22 +111,28 @@ class UnionTrans
106 'is_old_user' => $is_old_user, 111 'is_old_user' => $is_old_user,
107 'verify_code' => md5($keyStr) 112 'verify_code' => md5($keyStr)
108 )); 113 ));
  114 + if ($debug) {
  115 + var_dump('union:', $result, "++");
  116 + }
109 117
110 /* 通知新ERP (老的ERP http://192.168.200.102/CreateOrderUnion.aspx) */ 118 /* 通知新ERP (老的ERP http://192.168.200.102/CreateOrderUnion.aspx) */
111 - Yohobuy::post('http://portal.admin.yohobuy.com/api/orderunion/updateunion', array( 119 + $result = Yohobuy::post('http://portal.admin.yohobuy.com/api/orderunion/updateunion', array(
112 'data' => json_encode(array( 120 'data' => json_encode(array(
113 'order_code' => $order_code, 121 'order_code' => $order_code,
114 'unionid' => $unionInfo['client_id'], 122 'unionid' => $unionInfo['client_id'],
115 'union_name' => isset(self::$unionNames[$clientId]) ? self::$unionNames[$clientId] : '', 123 'union_name' => isset(self::$unionNames[$clientId]) ? self::$unionNames[$clientId] : '',
116 )) 124 ))
117 )); 125 ));
  126 + if ($debug) {
  127 + var_dump('erp:', $result, '++');
  128 + }
118 129
119 /* 对接第三方联盟 */ 130 /* 对接第三方联盟 */
120 131
121 // 亿起发 132 // 亿起发
122 if ($unionInfo['client_id'] == 1001) { 133 if ($unionInfo['client_id'] == 1001) {
123 $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; 134 $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;
124 - Yohobuy::get('http://o.yiqifa.com/adv/yoho.jsp', array( 135 + $result = Yohobuy::get('http://o.yiqifa.com/adv/yoho.jsp', array(
125 'client_id' => $unionInfo['client_id'], 136 'client_id' => $unionInfo['client_id'],
126 'orders_id' => $order_code, 137 'orders_id' => $order_code,
127 'orders_price' => $order_amount, 138 'orders_price' => $order_amount,
@@ -131,13 +142,16 @@ class UnionTrans @@ -131,13 +142,16 @@ class UnionTrans
131 'is_old_user' => $is_old_user, 142 'is_old_user' => $is_old_user,
132 'verify_code' => md5($keyStr) 143 'verify_code' => md5($keyStr)
133 )); 144 ));
  145 + if ($debug) {
  146 + var_dump('yiqifa:', $result, '++');
  147 + }
134 break; 148 break;
135 } 149 }
136 150
137 // 亿起发wap 151 // 亿起发wap
138 if ($unionInfo['client_id'] == 2995) { 152 if ($unionInfo['client_id'] == 2995) {
139 $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; 153 $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;
140 - Yohobuy::get('http://o.yiqifa.com/adv/yoho.jsp', array( 154 + $result = Yohobuy::get('http://o.yiqifa.com/adv/yoho.jsp', array(
141 'client_id' => $unionInfo['client_id'], 155 'client_id' => $unionInfo['client_id'],
142 'orders_id' => $order_code, 156 'orders_id' => $order_code,
143 'orders_price' => $order_amount, 157 'orders_price' => $order_amount,
@@ -148,6 +162,9 @@ class UnionTrans @@ -148,6 +162,9 @@ class UnionTrans
148 'dt' => 'm', 162 'dt' => 'm',
149 'verify_code' => md5($keyStr) 163 'verify_code' => md5($keyStr)
150 )); 164 ));
  165 + if ($debug) {
  166 + var_dump('yiqifa wap:', $result, '++');
  167 + }
151 break; 168 break;
152 } 169 }
153 170
@@ -158,10 +175,13 @@ class UnionTrans @@ -158,10 +175,13 @@ class UnionTrans
158 3057 => 'http://www.duomai.com/api/push/yohobuyroi.php', 175 3057 => 'http://www.duomai.com/api/push/yohobuyroi.php',
159 ); 176 );
160 if (array_key_exists($clientId, $clientUrls)) { 177 if (array_key_exists($clientId, $clientUrls)) {
161 - $urldata = self::getMaiDuoSplitData($order_code, $unionInfo['client_id'], $mbr_name);  
162 - Yohobuy::post($clientUrls[$clientId], array( 178 + $urldata = self::getMaiDuoSplitData($order_code, $uid, $unionInfo['client_id'], $mbr_name, $is_old_user);
  179 + $result = Yohobuy::post($clientUrls[$clientId], array(
163 'content' => $urldata, 180 'content' => $urldata,
164 )); 181 ));
  182 + if ($debug) {
  183 + var_dump('duomai: ', $urldata, '++', $result);
  184 + }
165 break; 185 break;
166 } 186 }
167 187
@@ -169,11 +189,14 @@ class UnionTrans @@ -169,11 +189,14 @@ class UnionTrans
169 if ($unionInfo['client_id'] == 3001) { 189 if ($unionInfo['client_id'] == 3001) {
170 $xmldata = self::getOrderXmlData($order_code, $uid, $unionInfo['client_id'], $u_id, $mbr_name, $channel_code); 190 $xmldata = self::getOrderXmlData($order_code, $uid, $unionInfo['client_id'], $u_id, $mbr_name, $channel_code);
171 $keyStr = 'content=' . $xmldata . '&shopid=690'; 191 $keyStr = 'content=' . $xmldata . '&shopid=690';
172 - Yohobuy::post('http://union.fanli.com/dingdan/push?shopid=690', array( 192 + $result = Yohobuy::post('http://union.fanli.com/dingdan/push?shopid=690', array(
173 'content' => $xmldata, 193 'content' => $xmldata,
174 'shopid' => 690, 194 'shopid' => 690,
175 'verify_code' => md5($keyStr) 195 'verify_code' => md5($keyStr)
176 )); 196 ));
  197 + if ($debug) {
  198 + var_dump('fanli: ', $xmldata, '++', $result);
  199 + }
177 break; 200 break;
178 } 201 }
179 202
@@ -185,7 +208,7 @@ class UnionTrans @@ -185,7 +208,7 @@ class UnionTrans
185 3001 => 'http://union.fanli.com/dingdan/push?shopid=690', 208 3001 => 'http://union.fanli.com/dingdan/push?shopid=690',
186 ); 209 );
187 if (array_key_exists($clientId, $clientUrls)) { 210 if (array_key_exists($clientId, $clientUrls)) {
188 - Yohobuy::post($clientUrls[$clientId], array( 211 + $result = Yohobuy::post($clientUrls[$clientId], array(
189 'client_id' => $unionInfo['client_id'], 212 'client_id' => $unionInfo['client_id'],
190 'order_id' => $order_code, 213 'order_id' => $order_code,
191 'create_time' => $create_times, 214 'create_time' => $create_times,
@@ -195,6 +218,9 @@ class UnionTrans @@ -195,6 +218,9 @@ class UnionTrans
195 'UID' => $u_id, 218 'UID' => $u_id,
196 'is_old_user' => $is_old_user, 219 'is_old_user' => $is_old_user,
197 )); 220 ));
  221 + if ($debug) {
  222 + var_dump('other: ', $result);
  223 + }
198 break; 224 break;
199 } 225 }
200 } while (false); 226 } while (false);
@@ -215,18 +241,18 @@ class UnionTrans @@ -215,18 +241,18 @@ class UnionTrans
215 241
216 $orderDetail = $orderDetail['data']; 242 $orderDetail = $orderDetail['data'];
217 $amount = self::filterPrice($orderDetail['amount']) - self::filterPrice($orderDetail['shipping_cost']); 243 $amount = self::filterPrice($orderDetail['amount']) - self::filterPrice($orderDetail['shipping_cost']);
218 - if (!empty($orderDetail['order_goods'])) { 244 + if (empty($orderDetail['order_goods'])) {
219 break; 245 break;
220 } 246 }
221 247
222 - $goodsAmount = $orderDetail['goods_total_amount']; 248 + $goodsAmount = self::filterPrice($orderDetail['goods_total_amount']);
223 $goodsData = array(); 249 $goodsData = array();
224 - 250 +
225 foreach ($orderDetail['order_goods'] as $key => $val) { 251 foreach ($orderDetail['order_goods'] as $key => $val) {
226 $goodsData['goods' . $key] = array( 252 $goodsData['goods' . $key] = array(
227 'pid' => $val['product_skn'], 253 'pid' => $val['product_skn'],
228 - 'title' => $val['product_name'],  
229 - 'category' => $val['color_name'], 254 + 'title' => '',//$val['product_name'],
  255 + 'category' => '', //$val['color_name'],
230 'category_title' => '', 256 'category_title' => '',
231 'url' => 'http://item.m.yohobuy.com/product/show_' . $val['product_skn'] . '.html', 257 'url' => 'http://item.m.yohobuy.com/product/show_' . $val['product_skn'] . '.html',
232 'num' => $val['buy_number'], 258 'num' => $val['buy_number'],
@@ -251,7 +277,7 @@ class UnionTrans @@ -251,7 +277,7 @@ class UnionTrans
251 'locked' => '', 277 'locked' => '',
252 'lastmod' => '', 278 'lastmod' => '',
253 'is_newbuyer' => '', 279 'is_newbuyer' => '',
254 - 'platform' => $client_type == 'h5' ? 2 : 1, 280 + 'platform' => ($client_type == 'h5') ? 2 : 1,
255 'code' => '', 281 'code' => '',
256 'remark' => '', 282 'remark' => '',
257 'products' => $goodsData, 283 'products' => $goodsData,
@@ -318,7 +344,7 @@ class UnionTrans @@ -318,7 +344,7 @@ class UnionTrans
318 'euid' => $mbr_name, 344 'euid' => $mbr_name,
319 'order_sn' => $order_code, 345 'order_sn' => $order_code,
320 'order_time' => date('Y-m-d H:i:s', $orderDetail['create_time']), 346 'order_time' => date('Y-m-d H:i:s', $orderDetail['create_time']),
321 - 'orders_price' => sprintf('%.2f', $orderDetail['goods_total_amount']), 347 + 'orders_price' => sprintf('%.2f', self::filterPrice($orderDetail['goods_total_amount'])),
322 'promotion_code' => 0, 348 'promotion_code' => 0,
323 'is_new_custom' => $is_old_user ? 0 : 1, 349 'is_new_custom' => $is_old_user ? 0 : 1,
324 'channel' => $channel, 350 'channel' => $channel,
@@ -32,5 +32,8 @@ @@ -32,5 +32,8 @@
32 {{/ payAppInfo}} 32 {{/ payAppInfo}}
33 </div> 33 </div>
34 </div> 34 </div>
  35 +{{#if oldWeixinAuthUrl}}
  36 +<iframe height="0" width="0" src="{{oldWeixinAuthUrl}}" style="display:none"></iframe>
  37 +{{/if}}
35 {{> layout/footer}} 38 {{> layout/footer}}
36 39
@@ -788,6 +788,8 @@ class HomeController extends AbstractAction @@ -788,6 +788,8 @@ class HomeController extends AbstractAction
788 $this->error(); 788 $this->error();
789 } 789 }
790 790
  791 + $hasWxShare = strpos($this->server('HTTP_USER_AGENT', ''), 'MicroMessenger') !== false;
  792 +
791 $this->_view->display('pay', array( 793 $this->_view->display('pay', array(
792 'payCenterPage' => true, 794 'payCenterPage' => true,
793 'payAppInfo' => array( 795 'payAppInfo' => array(
@@ -809,7 +811,8 @@ class HomeController extends AbstractAction @@ -809,7 +811,8 @@ class HomeController extends AbstractAction
809 ), 811 ),
810 ), 812 ),
811 'orderCode' => $orderCode, 813 'orderCode' => $orderCode,
812 - 'hasWxShare' => strpos($this->server('HTTP_USER_AGENT', ''), 'MicroMessenger') !== false 814 + 'hasWxShare' => $hasWxShare,
  815 + 'oldWeixinAuthUrl' => Helpers::url('/home/orders/tickets', array('order_code' => 0)), // 解决老站微信支付很坑的问题
813 )); 816 ));
814 } 817 }
815 818
@@ -39,7 +39,6 @@ class DetailModel @@ -39,7 +39,6 @@ class DetailModel
39 elseif (is_numeric($productSkn)) { 39 elseif (is_numeric($productSkn)) {
40 $baseInfo = DetailData::baseInfo(null, $uid, $productSkn); 40 $baseInfo = DetailData::baseInfo(null, $uid, $productSkn);
41 } 41 }
42 -  
43 // 商品名称 42 // 商品名称
44 if (empty($baseInfo['productName'])) { 43 if (empty($baseInfo['productName'])) {
45 return $result; 44 return $result;
@@ -429,12 +429,16 @@ class IndexController extends AbstractAction @@ -429,12 +429,16 @@ class IndexController extends AbstractAction
429 } else { 429 } else {
430 // 提交成功清除Cookie 430 // 提交成功清除Cookie
431 $this->setCookie('order-info', null); 431 $this->setCookie('order-info', null);
432 -  
433 -// if ($uid && !empty($result['data'])) {  
434 -// UnionTrans::set($uid, $result['data']['order_code'], $result['data']['order_amount']);  
435 -// }  
436 432
437 $this->echoJson($result); 433 $this->echoJson($result);
  434 +
  435 + if ($uid && !empty($result['data'])) {
  436 + try {
  437 + UnionTrans::set($uid, $result['data']['order_code'], $result['data']['order_amount']);
  438 + } catch (Exception $e) {
  439 + // do nothing
  440 + }
  441 + }
438 } 442 }
439 } 443 }
440 444
@@ -156,7 +156,7 @@ routes.productskn.map.1 = productSkn @@ -156,7 +156,7 @@ routes.productskn.map.1 = productSkn
156 156
157 ; 订单相关 157 ; 订单相关
158 routes.cart.type = "rewrite" 158 routes.cart.type = "rewrite"
159 -routes.cart.match = "/home/order/detail$" 159 +routes.cart.match = "/home/orders/detail$"
160 routes.cart.route.module = Index 160 routes.cart.route.module = Index
161 routes.cart.route.controller = Home 161 routes.cart.route.controller = Home
162 routes.cart.route.action = homedetail 162 routes.cart.route.action = homedetail