From 851c75b37076791cae9408d16936900a3b1b976a Mon Sep 17 00:00:00 2001 From: lccsw <805383944@qq.com> Date: Fri, 21 Oct 2022 15:02:11 +0800 Subject: [PATCH] edit-sylive-wxapp --- api/controllers/plan/Syt.php | 6 ++-- api/third_party/WXconfig/dcz_WxPay.Config.php | 29 +++++++++++++++++++ api/third_party/WXconfig/hdy_WxPay.Config.php | 4 +-- home/config/wechat.php | 6 +++- home/controllers/h5/market/sylive/Act.php | 14 ++++----- home/controllers/h5/market/sylive/Common.php | 22 +++++++++----- home/controllers/h5/market/sylive/Login.php | 8 ++--- home/controllers/h5/market/sylive/Notify.php | 9 +++++- www/home/MP_verify_2aipsVecS0wZZCED.txt | 1 + 9 files changed, 72 insertions(+), 27 deletions(-) create mode 100755 api/third_party/WXconfig/dcz_WxPay.Config.php create mode 100644 www/home/MP_verify_2aipsVecS0wZZCED.txt diff --git a/api/controllers/plan/Syt.php b/api/controllers/plan/Syt.php index 81db3e37..7dab23e1 100644 --- a/api/controllers/plan/Syt.php +++ b/api/controllers/plan/Syt.php @@ -18,8 +18,8 @@ class Syt extends CI_Controller parent::__construct(); $this->options = [ 'token' => '', - 'appid' => 'wxe66f905683582780', - 'appsecret' => '9546cd4de877be13ce203f3e6140633f', + 'appid' => 'wxbdec8558931efffd', + 'appsecret' => '583b3cd0d8e145009eda61ece003ca14', 'encodingaeskey' => '', 'debug' => false ]; @@ -39,7 +39,7 @@ class Syt extends CI_Controller public function subscribemsg() { $this->load->model('market/market_sylive_subscribemsg_model', 'mdSytSubscribemsg'); - $date = date('Y-m-d H:i:s', strtotime('+2 minute'));//提前2分钟发送 + $date = date('Y-m-d H:i:s', strtotime('+10 minute'));//提前10分钟发送 $where['s_time<='] = $date; $where['status'] = 0; $res = $this->mdSytSubscribemsg->select($where, 'id asc', 1, 200); diff --git a/api/third_party/WXconfig/dcz_WxPay.Config.php b/api/third_party/WXconfig/dcz_WxPay.Config.php new file mode 100755 index 00000000..4c58ead2 --- /dev/null +++ b/api/third_party/WXconfig/dcz_WxPay.Config.php @@ -0,0 +1,29 @@ +load->config('wechat'); - $config = $this->config->item('liche'); + $config = $this->config->item('hdy'); $sub_redirect_url = urlencode(http_host_com('home') . '/h5/market/sylive/act/subscribemsg?skey=' . $skey . '&s_time=' . $row['timeStart']); - $subscribemsg = "https://mp.weixin.qq.com/mp/subscribemsg?action=get_confirm&appid={$config['appid']}&scene=0&template_id=sdJ4eXXA3OdMZVkJdOrzusYLGr0Jpz9I7WiZurgGLBs&redirect_url={$sub_redirect_url}&reserved=test#wechat_redirect"; + $subscribemsg = "https://mp.weixin.qq.com/mp/subscribemsg?action=get_confirm&appid={$config['appid']}&scene=0&template_id=DO0B9IYYub1d0oNvy9czzGbe6_1EU8PQmnLEoDOcmXA&redirect_url={$sub_redirect_url}&reserved=test#wechat_redirect"; } } //浏览 @@ -85,14 +85,14 @@ class Act extends Wx { $info['statisticsurl'] = '/h5/market/sylive/stic?skey='.$info['skey']; } $info['channelImg'] = build_qiniu_image_url($row['channelImg']); -// $info['live_url'] = 'https://live.liche.cn/watch/'.$row['channelId']; +// $info['live_url'] = 'https://live.haodian.cn/watch/'.$row['channelId']; $userid = $user['unionid'] ? $user['unionid'] : $this->uid; $ts = time()*1000; $sign = md5($this->secretkey.$userid.$this->secretkey.$ts); if(!$user['nickname'] && !$user['headimg']){ $info['live_url'] = http_host_com('home').'/h5/market/sylive/act/userinfo?skey='.$skey; }else{ - $info['live_url'] = "https://live.liche.cn/watch/{$row['channelId']}?userid={$userid}&ts={$ts}&sign={$sign}"; + $info['live_url'] = "https://live.haodian.cn/watch/{$row['channelId']}?userid={$userid}&ts={$ts}&sign={$sign}"; } //判断是否支付商品 $is_pay = $this->market_sylive_order_model->count(['item_id'=>$a_id,'status'=>1,'uid'=>$this->uid]); @@ -322,7 +322,7 @@ class Act extends Wx { } $user = $this->user_model->get(['userId'=>$this->uid]); $notify_url = http_host_com('home').'/h5/market/sylive/notify'; - $result = $this->unorder($unpay['sid'],$unpay['total_price'],$user['openid'],$unpay['item_title'],$notify_url,$unpay['expire_time']); + $result = $this->unorder($unpay['sid'],$unpay['total_price'],$user['openid'],$unpay['item_title'],$notify_url,$unpay['expire_time'],['wx_type'=>'dc']); if(!$result['code']){ $this->show_json('',400,$result['msg']); } @@ -430,7 +430,7 @@ class Act extends Wx { } if($type=='sub'){ //订阅跳转 $this->load->config('wechat'); - $config = $this->config->item('liche'); + $config = $this->config->item('hdy'); $sub_redirect_url = urlencode(http_host_com('home') . '/h5/market/sylive/act/subscribemsg?skey=' . $skey . '&s_time=' . $row['timeStart']); $subscribemsg = "https://mp.weixin.qq.com/mp/subscribemsg?action=get_confirm&appid={$config['appid']}&scene=0&template_id=sdJ4eXXA3OdMZVkJdOrzusYLGr0Jpz9I7WiZurgGLBs&redirect_url={$sub_redirect_url}&reserved=test#wechat_redirect"; @@ -440,7 +440,7 @@ class Act extends Wx { $userid = $user['unionid'] ? $user['unionid'] : $this->uid; $ts = time()*1000; $sign = md5($this->secretkey.$userid.$this->secretkey.$ts); - $live_url = "https://live.liche.cn/watch/{$row['channelId']}?userid={$userid}&ts={$ts}&sign={$sign}"; + $live_url = "https://live.haodian.cn/watch/{$row['channelId']}?userid={$userid}&ts={$ts}&sign={$sign}"; redirect($live_url); } } diff --git a/home/controllers/h5/market/sylive/Common.php b/home/controllers/h5/market/sylive/Common.php index c46631d5..4d874a24 100644 --- a/home/controllers/h5/market/sylive/Common.php +++ b/home/controllers/h5/market/sylive/Common.php @@ -63,7 +63,7 @@ abstract class Common extends CI_Controller{ protected function set_auth($url='',$auth=0){ $this->load->helper('url'); $this->load->config('wechat'); - $config = $this->config->item('liche'); + $config = $this->config->item('hdy'); $code = $this->input->get('code'); !$url && $url = http_host_com('home').$_SERVER['REQUEST_URI']; $auth && $url = $_SERVER['QUERY_STRING'] ? $url."&auth={$auth}" : $url."?auth={$auth}"; @@ -117,26 +117,32 @@ abstract class Common extends CI_Controller{ } /** - * 支付 + * 微信下单 * @param $trade_no * @param $price * @param $openid * @param $body - * @param $notify_url 异步通知 - * @param $expire_time 过期时间 + * @param $notify_url + * @param $expire_time * @param $attach - * @return bool|json数据,可直接填入js函数作为参数|mixed + * @param $wx_type + * @param $other_data + * @return array|false * @throws WxPayException */ - protected function unorder($trade_no,$price,$openid,$body,$notify_url,$expire_time,$attach=''){ + protected function unorder($trade_no,$price,$openid,$body,$notify_url,$expire_time,$other_data=[]){ if(!$body){return false;} - require_once APPPATH."../api/third_party/WXconfig/hdy_WxPay.Config.php"; require_once APPPATH."../api/third_party/WXpay/WxPay.Api.php"; + if($other_data['wx_type']=='dc'){ + require_once APPPATH."../api/third_party/WXconfig/dcz_WxPay.Config.php"; + }else{ + require_once APPPATH."../api/third_party/WXconfig/hdy_WxPay.Config.php"; + } $config = new WxPayConfig(); $wxpay = new WxPayUnifiedOrder(); $wxpay->SetVersion('1.0'); $wxpay->SetBody($body); //简单描述 - $attach && $wxpay->SetAttach($attach); //附加信息 + $other_data['attach'] && $wxpay->SetAttach($other_data['attach']); //附加信息 $wxpay->SetNotify_url($notify_url); $wxpay->SetOut_trade_no($trade_no); //订单号 $wxpay->SetTotal_fee($price * 100); //支付价格 diff --git a/home/controllers/h5/market/sylive/Login.php b/home/controllers/h5/market/sylive/Login.php index da0582aa..b686b63e 100644 --- a/home/controllers/h5/market/sylive/Login.php +++ b/home/controllers/h5/market/sylive/Login.php @@ -78,11 +78,9 @@ class Login extends CI_Controller{ $this->load->helper('string'); $code = random_string('numeric', 4); $redis->save($key, $code, 60*5); - }else{ - $code = $redis->get($key); + $content = "【好店云】您的验证码为: {$code},请勿泄露于他人!"; + b2m_send_sms($mobile,$content); } - echo $code; -// send_sms($mobile, $code); $this->show_json('',200, '验证码已发送'); } @@ -119,7 +117,7 @@ class Login extends CI_Controller{ protected function set_auth($url='',$auth=0){ $this->load->helper('url'); $this->load->config('wechat'); - $config = $this->config->item('liche'); + $config = $this->config->item('hdy'); $code = $this->input->get('code'); !$url && $url = http_host_com('home').$_SERVER['REQUEST_URI']; $auth && $url = $_SERVER['QUERY_STRING'] ? $url."&auth={$auth}" : $url."?auth={$auth}"; diff --git a/home/controllers/h5/market/sylive/Notify.php b/home/controllers/h5/market/sylive/Notify.php index 96bd5046..0c8b2fb6 100644 --- a/home/controllers/h5/market/sylive/Notify.php +++ b/home/controllers/h5/market/sylive/Notify.php @@ -1,7 +1,7 @@ load->model('market/market_sylive_activity_model'); $this->load->model('market/market_sylive_activity_orders_model','mdSytActivityOrders'); $this->load->library('market/sylive_entity'); + $method = $this->router->fetch_method(); + if($method=='biz'){ //好店云 + require_once APPPATH."../api/third_party/WXconfig/hdy_WxPay.Config.php"; + }else{ //默认东创紫联 + require_once APPPATH."../api/third_party/WXconfig/dcz_WxPay.Config.php"; + } try{ //如果返回成功则验证签名 $config = new WxPayConfig(); $input = file_get_contents("php://input"); + debug_log("[input] ". __FUNCTION__ . "# $input:" . json_encode($input,JSON_UNESCAPED_UNICODE), $this->log_file,$this->log_dir); $result = WxPayNotifyResults::Init($config, $input); $this->notify = $result->GetValues(); debug_log("[info] ". __FUNCTION__ . "# notify:" . json_encode($this->notify,JSON_UNESCAPED_UNICODE), $this->log_file,$this->log_dir); diff --git a/www/home/MP_verify_2aipsVecS0wZZCED.txt b/www/home/MP_verify_2aipsVecS0wZZCED.txt new file mode 100644 index 00000000..71688ddd --- /dev/null +++ b/www/home/MP_verify_2aipsVecS0wZZCED.txt @@ -0,0 +1 @@ +2aipsVecS0wZZCED \ No newline at end of file