diff --git a/common/models/market/Market_sylive_activity_model.php b/common/models/market/Market_sylive_activity_model.php index 108babe3..858af198 100644 --- a/common/models/market/Market_sylive_activity_model.php +++ b/common/models/market/Market_sylive_activity_model.php @@ -15,4 +15,16 @@ class Market_sylive_activity_model extends HD_Model parent::__construct($this->table_name, 'default'); } + /** + * 支付配置信息 + * @param $mch_id + * @return string|string[] + */ + public function pay_config($mch_id=''){ + $conf_arr = [ + '1614399682' => APPPATH."../api/third_party/WXconfig/dcz_WxPay.Config.php", //东创紫联支付配置 + '1604032585' => APPPATH."../api/third_party/WXconfig/hdy_WxPay.Config.php", //好店云支付配置 + ]; + return $mch_id ? $conf_arr[$mch_id] : $conf_arr; + } } \ No newline at end of file diff --git a/home/controllers/h5/market/sylive/Act.php b/home/controllers/h5/market/sylive/Act.php index c3584686..b78e0333 100644 --- a/home/controllers/h5/market/sylive/Act.php +++ b/home/controllers/h5/market/sylive/Act.php @@ -404,7 +404,10 @@ 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['totalPrice'],$user['openid'],$unpay['itemTitle'],$notify_url,$unpay['expireTime'],['wx_type'=>'dc']); + $other_data = []; + $pay_config = $this->market_sylive_activity_model->pay_config($row['mchId']); + $pay_config && $other_data['pay_config'] = $pay_config; + $result = $this->unorder($unpay['sid'],$unpay['totalPrice'],$user['openid'],$unpay['itemTitle'],$notify_url,$unpay['expireTime'],$other_data); if(!$result['code']){ $this->show_json('',400,$result['msg']); } diff --git a/home/controllers/h5/market/sylive/Common.php b/home/controllers/h5/market/sylive/Common.php index 08e8dcac..1345a01b 100644 --- a/home/controllers/h5/market/sylive/Common.php +++ b/home/controllers/h5/market/sylive/Common.php @@ -136,8 +136,8 @@ abstract class Common extends CI_Controller{ protected function unorder($trade_no,$price,$openid,$body,$notify_url,$expire_time,$other_data=[]){ if(!$body){return false;} 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"; + if($other_data['pay_config'] && file_exists($other_data['pay_config'])){ + require_once $other_data['pay_config']; }else{ require_once APPPATH."../api/third_party/WXconfig/hdy_WxPay.Config.php"; } diff --git a/home/controllers/h5/market/sylive/Item.php b/home/controllers/h5/market/sylive/Item.php index bb4cf389..6a4b51b4 100644 --- a/home/controllers/h5/market/sylive/Item.php +++ b/home/controllers/h5/market/sylive/Item.php @@ -52,19 +52,20 @@ class Item extends Wx{ $stock = $row['stock']; $introduction = $row['descrip'] ? $row['descrip'] : ''; $price = $row['price'] ? $row['price'] : ''; - //是否需要选择门店 - $need_shop = 1; - $ac_user = $this->act_user_model->get(['id'=>$this->act_uid]); - if($ac_user['channelId']){ - $channel_user = $this->act_user_model->get(['userId'=>$ac_user['channelId'],'activityId'=>$a_id]); - if($channel_user['bizId'] && $channel_user['organizationId']){ - $need_shop = 0; - } - } + $need_shop = 0; + //是否需要选择门店 时隐藏 +// $need_shop = 1; +// $ac_user = $this->act_user_model->get(['id'=>$this->act_uid]); +// if($ac_user['channelId']){ +// $channel_user = $this->act_user_model->get(['userId'=>$ac_user['channelId'],'activityId'=>$a_id]); +// if($channel_user['bizId'] && $channel_user['organizationId']){ +// $need_shop = 0; +// } +// } $biz_arr = $city_arr = $province_arr = []; - if($need_shop){ - $province_arr = $this->msa_bizinfo_model->select(['status'=>0,'activityId'=>4],'',0,0,'distinct provinceName as name'); - } +// if($need_shop){ +// $province_arr = $this->msa_bizinfo_model->select(['status'=>0,'activityId'=>4],'',0,0,'distinct provinceName as name'); +// } $user = $this->user_model->get(['userId'=>$this->uid],'unionid,nickname,headimg'); $userid = $user['unionid'] ? $user['unionid'] : $this->uid; $ts = time()*1000; @@ -83,7 +84,9 @@ class Item extends Wx{ 'validity' => $validity, 'introTitle' => '权益说明', 'need_shop' => $need_shop, - 'live_url' => $live_url + 'live_url' => $live_url, + 'a_id' => $a_id, + 'ifAddress' => $row['ifAddress'] ]; $this->data['province_arr'] = $province_arr; $this->data['city_arr'] = $city_arr; @@ -217,7 +220,11 @@ class Item extends Wx{ $this->market_sylive_order_model->update($update,['id'=>$unpay['id']]); } $notify_url = http_host_com('home').'/h5/market/sylive/notify/item'; - $result = $this->unorder($unpay['sid'],$unpay['totalPrice'],$user['openid'],$unpay['itemTitle'],$notify_url,$unpay['expireTime'],['wx_type'=>'dc']); + $other_data = []; + $act = $this->market_sylive_activity_model->get(['activityId'=>$row['activityId']],'mchId'); + $pay_config = $this->market_sylive_activity_model->pay_config($act['mchId']); + $pay_config && $other_data['pay_config'] = $pay_config; + $result = $this->unorder($unpay['sid'],$unpay['totalPrice'],$user['openid'],$unpay['itemTitle'],$notify_url,$unpay['expireTime'],$other_data); if(!$result['code']){ $this->show_json('',400,$result['msg']); } @@ -278,6 +285,13 @@ class Item extends Wx{ } public function agreement(){ + $a_id = $this->input->get('a_id'); + $act = $this->market_sylive_activity_model->get(['activityId'=>$a_id]); + $info = [ + 'title' => $act['protocolTitle'], + 'content' => $act['protocol'] + ]; + $this->data['info'] = $info; $this->show_view('h5/market/sylive/item/agreement'); } diff --git a/home/controllers/h5/market/sylive/Notify.php b/home/controllers/h5/market/sylive/Notify.php index 6f01adaa..4eb0d45a 100644 --- a/home/controllers/h5/market/sylive/Notify.php +++ b/home/controllers/h5/market/sylive/Notify.php @@ -8,6 +8,7 @@ class Notify extends CI_Controller { private $log_dir = 'market/sylive'; private $log_file = 'wx_pay.log'; private $notify; + private $mch_id; public function __construct(){ parent::__construct(); @@ -16,17 +17,21 @@ class Notify extends CI_Controller { $this->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(); + $WxPayNotifyResults = new WxPayNotifyResults(); $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->FromXml($input); + $data = $result->GetValues(); + $this->mch_id = $data['mch_id']; + $config = $this->market_sylive_activity_model->pay_config($this->mch_id); + if($config && file_exists($config)){ + require_once $config; + }else{ + require_once APPPATH."../api/third_party/WXconfig/hdy_WxPay.Config.php"; + } + //验证签名 + $config = new WxPayConfig(); $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); @@ -60,7 +65,7 @@ class Notify extends CI_Controller { 'uid' => $order['userId'], 'cf_uid' => $act_user['channelId'], 'kpi' => 'order', - 'jsondata'=> ['order_id'=>$order['id'],'sid'=>$sid] + 'jsondata'=> ['order_id'=>$order['id'],'sid'=>$sid,'mch_id'=>$this->mch_id] ]; $sy_res = $this->sylive_entity->kpi_log($params); debug_log("[info] ". __FUNCTION__ . ":私域通增加记录-".json_encode($sy_res,JSON_UNESCAPED_UNICODE), $this->log_file,$this->log_dir); @@ -139,7 +144,7 @@ class Notify extends CI_Controller { 'cf_uid' => $act_user['channelId'], 'kpi' => 'order', 'tagId' => $order['id'], - 'jsondata'=> ['order_id'=>$order['id'],'sid'=>$sid] + 'jsondata'=> ['order_id'=>$order['id'],'sid'=>$sid,'mch_id'=>$this->mch_id] ]; $sy_res = $this->sylive_entity->kpi_log($params); debug_log("[info] ". __FUNCTION__ . ":私域通增加记录-".json_encode($sy_res,JSON_UNESCAPED_UNICODE), $this->log_file,$this->log_dir); diff --git a/home/controllers/h5/market/sylive/Ucenter.php b/home/controllers/h5/market/sylive/Ucenter.php index 2949e5e7..244d3fff 100644 --- a/home/controllers/h5/market/sylive/Ucenter.php +++ b/home/controllers/h5/market/sylive/Ucenter.php @@ -24,13 +24,12 @@ class Ucenter extends Wx{ if(!$row){ throw new Hd_exception('参数错误',400); } + $jsondata = json_decode($row['jsondata'],true); $lists = []; $lists[] = ['title'=>'我的权益','url'=>"/h5/market/sylive/ucenter/orders?skey={$params['skey']}"]; $lists[] = ['title'=>'我的抽奖','url'=>"/h5/market/sylive/ucenter/win?skey={$params['skey']}"]; - if($this->a_id!=5){ - $lists[] = ['title'=>'联系客服','url'=>"https://work.weixin.qq.com/kfid/kfc77374393839a9d9b?enc_scene=ENCAEt1rsV7GcticSp5Xyc245thCkz9T6YRm7gShvqffNqW3A89DzkZvzjusx44EinUTe"]; - } + $jsondata['serviceLink'] && $lists[] = ['title'=>'联系客服','url'=>$jsondata['serviceLink']]; $user = $this->user_model->get(['userId'=>$this->uid],'unionid,nickname,headimg'); $info = [ diff --git a/home/views/h5/market/sylive/item/agreement.php b/home/views/h5/market/sylive/item/agreement.php index 21859a82..2ea0ef2c 100644 --- a/home/views/h5/market/sylive/item/agreement.php +++ b/home/views/h5/market/sylive/item/agreement.php @@ -3,49 +3,11 @@