作者 郭文星
... ... @@ -150,6 +150,7 @@ class Client extends Api
->where($where)
->paginate($total, false, ['page' => $page])
->toArray();
return $this->success("查询成功",$row);
}
/**
... ...
... ... @@ -211,7 +211,7 @@ class Wechat extends Api
/**注册 分销关系 如 https://coupon.cc/index.php/api/v1/wechat/register_relation?store_id=1&activity_id=3&share_id=2
/**注册 分销关系 如 http://coupon.cc/index.php/api/v1/wechat/register_relation?store_id=19&activity_id=3&share_id=3
* store_id,activity_id
* 关系 user表 id 和 pid
*/
... ... @@ -222,7 +222,7 @@ class Wechat extends Api
return $this->error('请求错误');
}
$my_user_id = $this->auth->id;
$my_user_id = 2;
if(empty($my_user_id)){return $this->error('用户信息错误');}
if(empty($param['store_id'])){return $this->error('门店信息错误');}
//记录门店浏览统计
... ... @@ -235,14 +235,15 @@ class Wechat extends Api
$myInfo = Db::name('user')->where($w)->find();
if(empty($myInfo['pid'])){
//更新分销关系
//本身是自己门店的代理角色,则无效,如果点击别的门店分销,则对于别的门店来说,不是代理,则要统计分销
//自己是代理,则点击链接无效
$w1['user_id'] = $my_user_id;
$w1['verification_store_id'] = $param['store_id'];
//$w1['verification_store_id'] = $param['store_id'];
$role = Db::name('verification_staff')->where($w1)->find();
if(in_array($role['type'],['1','3'])){
return $this->error('我是代理不记录');
}
Db::name('user')->where($w)->update(['id'=>$myInfo['pid']]);
Db::name('user')->where($w)->update(['pid'=>$param['share_id']]);
return $this->success('更新关系');
}else{
if($myInfo['pid'] == $param['share_id']){
... ... @@ -327,7 +328,7 @@ class Wechat extends Api
$app = WehcatModule::getInstance()->initWechatPay();
$xml = file_get_contents("php://input");
$xmljson= json_encode(simplexml_load_string($xml, 'SimplexmlElement', LIBXML_NOCDATA ));//将对象转换个JSON
Common::put_file_log('支付回调记录-微信支付回调信息',$xmljson, 'pay_notify', __CLASS__ . __FUNCTION__ . __LINE__);
file_put_contents('1_notify.log',($xmljson),FILE_APPEND);
$response = $app->handlePaidNotify(function($message, $fail){
// 使用通知里的 "微信支付订单号" 或者 "商户订单号" 去自己的数据库找到订单
Common::put_file_log('支付成功-微信支付回调信息',json_encode($message), 'pay_notify', __CLASS__ . __FUNCTION__ . __LINE__);
... ... @@ -369,9 +370,14 @@ class Wechat extends Api
* $order_info 支付成功后的订单信息
*/
public function sales_distribution($order_info){
public function sales_distribution($order_info=[]){
//测试
$order_info = Db::name('verification_order')->where("id='14'")->find();
if(empty($order_info)){ return $this->error('订单信息不存在');}
$w['id'] = $order_info['user_id'];
$myInfo = Db::name('user')->where($w)->find();
//是否与上级
if(!empty($myInfo['pid'])){
//上级
... ... @@ -380,11 +386,14 @@ class Wechat extends Api
}catch(\Exception $e){
Common::put_file_log('上级-分销异常',json_encode($e->getMessage()), 'sales_distribution', __CLASS__ . __FUNCTION__ . __LINE__);
}
die;
//上级的上级
try{
$w1['id'] = $myInfo['pid'];
$myInfoP = Db::name('user')->where($w1)->find();
$this->getParent($myInfoP['id'],$order_info['verification_store_id'],$order_info['id']);
if(!empty($myInfoP['pid'])){
$this->getParent($myInfoP['id'],$order_info['verification_store_id'],$order_info['id']);
}
}catch(\Exception $e){
Common::put_file_log('上级的上级-分销异常',json_encode($e->getMessage()), 'sales_distribution', __CLASS__ . __FUNCTION__ . __LINE__);
}
... ...