作者 郭文星
@@ -150,6 +150,7 @@ class Client extends Api @@ -150,6 +150,7 @@ class Client extends Api
150 ->where($where) 150 ->where($where)
151 ->paginate($total, false, ['page' => $page]) 151 ->paginate($total, false, ['page' => $page])
152 ->toArray(); 152 ->toArray();
  153 + return $this->success("查询成功",$row);
153 } 154 }
154 155
155 /** 156 /**
@@ -211,7 +211,7 @@ class Wechat extends Api @@ -211,7 +211,7 @@ class Wechat extends Api
211 211
212 212
213 213
214 - /**注册 分销关系 如 https://coupon.cc/index.php/api/v1/wechat/register_relation?store_id=1&activity_id=3&share_id=2 214 + /**注册 分销关系 如 http://coupon.cc/index.php/api/v1/wechat/register_relation?store_id=19&activity_id=3&share_id=3
215 * store_id,activity_id 215 * store_id,activity_id
216 * 关系 user表 id 和 pid 216 * 关系 user表 id 和 pid
217 */ 217 */
@@ -222,7 +222,7 @@ class Wechat extends Api @@ -222,7 +222,7 @@ class Wechat extends Api
222 return $this->error('请求错误'); 222 return $this->error('请求错误');
223 } 223 }
224 $my_user_id = $this->auth->id; 224 $my_user_id = $this->auth->id;
225 - 225 + $my_user_id = 2;
226 if(empty($my_user_id)){return $this->error('用户信息错误');} 226 if(empty($my_user_id)){return $this->error('用户信息错误');}
227 if(empty($param['store_id'])){return $this->error('门店信息错误');} 227 if(empty($param['store_id'])){return $this->error('门店信息错误');}
228 //记录门店浏览统计 228 //记录门店浏览统计
@@ -235,14 +235,15 @@ class Wechat extends Api @@ -235,14 +235,15 @@ class Wechat extends Api
235 $myInfo = Db::name('user')->where($w)->find(); 235 $myInfo = Db::name('user')->where($w)->find();
236 if(empty($myInfo['pid'])){ 236 if(empty($myInfo['pid'])){
237 //更新分销关系 237 //更新分销关系
238 - //本身是自己门店的代理角色,则无效,如果点击别的门店分销,则对于别的门店来说,不是代理,则要统计分销 238 + //自己是代理,则点击链接无效
239 $w1['user_id'] = $my_user_id; 239 $w1['user_id'] = $my_user_id;
240 - $w1['verification_store_id'] = $param['store_id']; 240 + //$w1['verification_store_id'] = $param['store_id'];
241 $role = Db::name('verification_staff')->where($w1)->find(); 241 $role = Db::name('verification_staff')->where($w1)->find();
242 if(in_array($role['type'],['1','3'])){ 242 if(in_array($role['type'],['1','3'])){
243 return $this->error('我是代理不记录'); 243 return $this->error('我是代理不记录');
244 } 244 }
245 - Db::name('user')->where($w)->update(['id'=>$myInfo['pid']]); 245 +
  246 + Db::name('user')->where($w)->update(['pid'=>$param['share_id']]);
246 return $this->success('更新关系'); 247 return $this->success('更新关系');
247 }else{ 248 }else{
248 if($myInfo['pid'] == $param['share_id']){ 249 if($myInfo['pid'] == $param['share_id']){
@@ -327,7 +328,7 @@ class Wechat extends Api @@ -327,7 +328,7 @@ class Wechat extends Api
327 $app = WehcatModule::getInstance()->initWechatPay(); 328 $app = WehcatModule::getInstance()->initWechatPay();
328 $xml = file_get_contents("php://input"); 329 $xml = file_get_contents("php://input");
329 $xmljson= json_encode(simplexml_load_string($xml, 'SimplexmlElement', LIBXML_NOCDATA ));//将对象转换个JSON 330 $xmljson= json_encode(simplexml_load_string($xml, 'SimplexmlElement', LIBXML_NOCDATA ));//将对象转换个JSON
330 - Common::put_file_log('支付回调记录-微信支付回调信息',$xmljson, 'pay_notify', __CLASS__ . __FUNCTION__ . __LINE__); 331 + file_put_contents('1_notify.log',($xmljson),FILE_APPEND);
331 $response = $app->handlePaidNotify(function($message, $fail){ 332 $response = $app->handlePaidNotify(function($message, $fail){
332 // 使用通知里的 "微信支付订单号" 或者 "商户订单号" 去自己的数据库找到订单 333 // 使用通知里的 "微信支付订单号" 或者 "商户订单号" 去自己的数据库找到订单
333 Common::put_file_log('支付成功-微信支付回调信息',json_encode($message), 'pay_notify', __CLASS__ . __FUNCTION__ . __LINE__); 334 Common::put_file_log('支付成功-微信支付回调信息',json_encode($message), 'pay_notify', __CLASS__ . __FUNCTION__ . __LINE__);
@@ -369,9 +370,14 @@ class Wechat extends Api @@ -369,9 +370,14 @@ class Wechat extends Api
369 * $order_info 支付成功后的订单信息 370 * $order_info 支付成功后的订单信息
370 */ 371 */
371 372
372 - public function sales_distribution($order_info){ 373 + public function sales_distribution($order_info=[]){
  374 + //测试
  375 + $order_info = Db::name('verification_order')->where("id='14'")->find();
  376 +
  377 + if(empty($order_info)){ return $this->error('订单信息不存在');}
373 $w['id'] = $order_info['user_id']; 378 $w['id'] = $order_info['user_id'];
374 $myInfo = Db::name('user')->where($w)->find(); 379 $myInfo = Db::name('user')->where($w)->find();
  380 +
375 //是否与上级 381 //是否与上级
376 if(!empty($myInfo['pid'])){ 382 if(!empty($myInfo['pid'])){
377 //上级 383 //上级
@@ -380,11 +386,14 @@ class Wechat extends Api @@ -380,11 +386,14 @@ class Wechat extends Api
380 }catch(\Exception $e){ 386 }catch(\Exception $e){
381 Common::put_file_log('上级-分销异常',json_encode($e->getMessage()), 'sales_distribution', __CLASS__ . __FUNCTION__ . __LINE__); 387 Common::put_file_log('上级-分销异常',json_encode($e->getMessage()), 'sales_distribution', __CLASS__ . __FUNCTION__ . __LINE__);
382 } 388 }
  389 + die;
383 //上级的上级 390 //上级的上级
384 try{ 391 try{
385 $w1['id'] = $myInfo['pid']; 392 $w1['id'] = $myInfo['pid'];
386 $myInfoP = Db::name('user')->where($w1)->find(); 393 $myInfoP = Db::name('user')->where($w1)->find();
387 - $this->getParent($myInfoP['id'],$order_info['verification_store_id'],$order_info['id']); 394 + if(!empty($myInfoP['pid'])){
  395 + $this->getParent($myInfoP['id'],$order_info['verification_store_id'],$order_info['id']);
  396 + }
388 }catch(\Exception $e){ 397 }catch(\Exception $e){
389 Common::put_file_log('上级的上级-分销异常',json_encode($e->getMessage()), 'sales_distribution', __CLASS__ . __FUNCTION__ . __LINE__); 398 Common::put_file_log('上级的上级-分销异常',json_encode($e->getMessage()), 'sales_distribution', __CLASS__ . __FUNCTION__ . __LINE__);
390 } 399 }