浏览代码

Merge remote-tracking branch 'origin/master'

shaoguo 7 月之前
父节点
当前提交
96ee26db25

+ 0 - 0
Modules/Lib/Weixin/JsApiPay.class.php.back → Modules/Lib/Weixin-back/JsApiPay.class.php


+ 217 - 0
Modules/Lib/Weixin-back/JsApiPay.class.php.back

@@ -0,0 +1,217 @@
+<?php
+require_once dirname(__FILE__) ."/lib/WxPay.Api.php";
+require_once dirname(__FILE__) ."/log.php";
+
+$data_path = dirname( dirname(dirname( dirname(__FILE__) )) ).'/Data/wxpaylogs/'.date('Y-m-d')."/";
+
+RecursiveMkdir($data_path);
+
+
+
+/**
+ * 
+ * JSAPI支付实现类
+ * 该类实现了从微信公众平台获取code、通过code获取openid和access_token、
+ * 生成jsapi支付js接口所需的参数、生成获取共享收货地址所需的参数
+ * 
+ * 该类是微信支付提供的样例程序,商户可根据自己的需求修改,或者使用lib中的api自行开发
+ * 
+ * @author widy
+ *
+ */
+class JsApiPay
+{
+	/**
+	 * 
+	 * 网页授权接口微信服务器返回的数据,返回样例如下
+	 * {
+	 *  "access_token":"ACCESS_TOKEN",
+	 *  "expires_in":7200,
+	 *  "refresh_token":"REFRESH_TOKEN",
+	 *  "openid":"OPENID",
+	 *  "scope":"SCOPE",
+	 *  "unionid": "o6_bmasdasdsad6_2sgVt7hMZOPfL"
+	 * }
+	 * 其中access_token可用于获取共享收货地址
+	 * openid是微信支付jsapi支付接口必须的参数
+	 * @var array
+	 */
+	public $data = null;
+	
+	/**
+	 * 
+	 * 通过跳转获取用户的openid,跳转流程如下:
+	 * 1、设置自己需要调回的url及其其他参数,跳转到微信服务器https://open.weixin.qq.com/connect/oauth2/authorize
+	 * 2、微信服务处理完成之后会跳转回用户redirect_uri地址,此时会带上一些参数,如:code
+	 * 
+	 * @return 用户的openid
+	 */
+	public function GetOpenid()
+	{
+		//通过code获得openid
+		if (!isset($_GET['code'])){
+			//触发微信返回code码
+			
+			$baseUrl = urlencode('http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING']);
+			$url = $this->__CreateOauthUrlForCode($baseUrl);
+			Header("Location: $url");
+			exit();
+		} else {
+			//获取code码,以获取openid
+		    $code = $_GET['code'];
+			$openid = $this->getOpenidFromMp($code);
+			return $openid;
+		}
+	}
+	
+	/**
+	 * 
+	 * 获取jsapi支付的参数
+	 * @param array $UnifiedOrderResult 统一支付接口返回的数据
+	 * @throws WxPayException
+	 * 
+	 * @return json数据,可直接填入js函数作为参数
+	 */
+	public function GetJsApiParameters($UnifiedOrderResult)
+	{
+		if(!array_key_exists("appid", $UnifiedOrderResult)
+		|| !array_key_exists("prepay_id", $UnifiedOrderResult)
+		|| $UnifiedOrderResult['prepay_id'] == "")
+		{
+			throw new WxPayException("参数错误");
+		}
+		$jsapi = new WxPayJsApiPay();
+		$jsapi->SetAppid($UnifiedOrderResult["appid"]);
+		$time = time();
+		$timeStamp = "$time";
+		$jsapi->SetTimeStamp($timeStamp);
+		$jsapi->SetNonceStr(WxPayApi::getNonceStr());
+		$jsapi->SetPackage("prepay_id=" . $UnifiedOrderResult['prepay_id']);
+		$jsapi->SetSignType("MD5");
+		$jsapi->SetPaySign($jsapi->MakeSign());
+		$parameters = json_encode($jsapi->GetValues());
+		return $parameters;
+	}
+	
+	/**
+	 * 
+	 * 通过code从工作平台获取openid机器access_token
+	 * @param string $code 微信跳转回来带上的code
+	 * 
+	 * @return openid
+	 */
+	public function GetOpenidFromMp($code)
+	{
+		$url = $this->__CreateOauthUrlForOpenid($code);
+		//初始化curl
+		$ch = curl_init();
+		//设置超时
+		curl_setopt($ch, CURLOP_TIMEOUT, 30);
+		curl_setopt($ch, CURLOPT_URL, $url);
+		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,FALSE);
+		curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,FALSE);
+		curl_setopt($ch, CURLOPT_HEADER, FALSE);
+		curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
+		if(WxPayConfig::CURL_PROXY_HOST != "0.0.0.0" 
+			&& WxPayConfig::CURL_PROXY_PORT != 0){
+			curl_setopt($ch,CURLOPT_PROXY, WxPayConfig::CURL_PROXY_HOST);
+			curl_setopt($ch,CURLOPT_PROXYPORT, WxPayConfig::CURL_PROXY_PORT);
+		}
+		//运行curl,结果以jason形式返回
+		$res = curl_exec($ch);
+		curl_close($ch);
+		//取出openid
+		$data = json_decode($res,true);
+		$this->data = $data;
+		$openid = $data['openid'];
+		return $openid;
+	}
+	
+	/**
+	 * 
+	 * 拼接签名字符串
+	 * @param array $urlObj
+	 * 
+	 * @return 返回已经拼接好的字符串
+	 */
+	private function ToUrlParams($urlObj)
+	{
+		$buff = "";
+		foreach ($urlObj as $k => $v)
+		{
+			if($k != "sign"){
+				$buff .= $k . "=" . $v . "&";
+			}
+		}
+		
+		$buff = trim($buff, "&");
+		return $buff;
+	}
+	
+	/**
+	 * 
+	 * 获取地址js参数
+	 * 
+	 * @return 获取共享收货地址js函数需要的参数,json格式可以直接做参数使用
+	 */
+	public function GetEditAddressParameters()
+	{	
+		$getData = $this->data;
+		$data = array();
+		$data["appid"] = WxPayConfig::APPID;
+		$data["url"] = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
+		$time = time();
+		$data["timestamp"] = "$time";
+		$data["noncestr"] = "1234568";
+		$data["accesstoken"] = $getData["access_token"];
+		ksort($data);
+		$params = $this->ToUrlParams($data);
+		$addrSign = sha1($params);
+		
+		$afterData = array(
+			"addrSign" => $addrSign,
+			"signType" => "sha1",
+			"scope" => "jsapi_address",
+			"appId" => WxPayConfig::APPID,
+			"timeStamp" => $data["timestamp"],
+			"nonceStr" => $data["noncestr"]
+		);
+		$parameters = json_encode($afterData);
+		return $parameters;
+	}
+	
+	/**
+	 * 
+	 * 构造获取code的url连接
+	 * @param string $redirectUrl 微信服务器回跳的url,需要url编码
+	 * 
+	 * @return 返回构造好的url
+	 */
+	private function __CreateOauthUrlForCode($redirectUrl)
+	{
+		$urlObj["appid"] = WxPayConfig::APPID;
+		$urlObj["redirect_uri"] = "$redirectUrl";
+		$urlObj["response_type"] = "code";
+		$urlObj["scope"] = "snsapi_base";
+		$urlObj["state"] = "STATE"."#wechat_redirect";
+		$bizString = $this->ToUrlParams($urlObj);
+		return "https://open.weixin.qq.com/connect/oauth2/authorize?".$bizString;
+	}
+	
+	/**
+	 * 
+	 * 构造获取open和access_toke的url地址
+	 * @param string $code,微信跳转带回的code
+	 * 
+	 * @return 请求的url
+	 */
+	private function __CreateOauthUrlForOpenid($code)
+	{
+		$urlObj["appid"] = WxPayConfig::APPID;
+		$urlObj["secret"] = WxPayConfig::APPSECRET;
+		$urlObj["code"] = $code;
+		$urlObj["grant_type"] = "authorization_code";
+		$bizString = $this->ToUrlParams($urlObj);
+		return "https://api.weixin.qq.com/sns/oauth2/access_token?".$bizString;
+	}
+}

+ 0 - 0
Modules/Lib/Weixin/Jssdk.class.php.back → Modules/Lib/Weixin-back/Jssdk.class.php


文件差异内容过多而无法显示
+ 421 - 0
Modules/Lib/Weixin-back/Jssdk.class.php.back


+ 458 - 0
Modules/Lib/Weixin-back/PayNotifyCallBack.class.php

@@ -0,0 +1,458 @@
+<?php
+require_once dirname(__FILE__) ."/lib/WxPay.Api.php";
+require_once dirname(__FILE__) .'/lib/WxPay.Notify.php';
+require_once dirname(__FILE__) .'/log.php';
+
+
+$lib_path = dirname(dirname( dirname(__FILE__) )).'/Lib/';
+
+$data_path = dirname( dirname(dirname( dirname(__FILE__) )) ).'/Data/wxpaylogs/'.date('Y-m-d')."/";
+
+RecursiveMkdir($data_path);
+
+
+
+
+//初始化日志
+//\Think\Log::record("begin notify222");
+
+class PayNotifyCallBack extends WxPayNotify
+{
+	//查询订单
+	public function Queryorder($transaction_id)
+	{
+		global $INI;
+		$input = new WxPayOrderQuery();
+		$input->SetTransaction_id($transaction_id);
+		$result = WxPayApi::orderQuery($input);
+		
+
+		
+
+		if(array_key_exists("return_code", $result)
+			&& array_key_exists("result_code", $result)
+			&& $result["return_code"] == "SUCCESS"
+			&& $result["result_code"] == "SUCCESS")
+		{
+			//DO
+			return true;
+		}
+		return false;
+	}
+	
+	//重写回调处理函数
+	public function NotifyProcess($data, &$msg)
+	{
+		global $_W;
+		global $_GPC;
+		
+
+		//global $_W;
+		
+		 $out_trade_no_str = $data['out_trade_no'];
+		$out_trade_no_arr =  explode('-',$out_trade_no_str);
+		$out_trade_no = $out_trade_no_arr[0];
+		
+      
+      
+		$data_path = dirname( dirname(dirname( dirname(__FILE__) )) ).'/Data/wxpaylogs/'.date('Y-m-d')."/";
+		
+		RecursiveMkdir($data_path);
+
+		$file = $data_path.date('Y-m-d').'.txt';
+		$handl = fopen($file,'a');
+		fwrite($handl,"Queryorder");
+		fwrite($handl,"call back:" . json_encode($data));
+     	 fwrite($handl,"小程序开始查询支付:");
+		fclose($handl);
+		
+		
+		
+		$notfiyOutput = array();
+		
+		//\Think\Log::record("call back:" . json_encode($data));
+		
+		if(!array_key_exists("transaction_id", $data)){
+			$msg = "输入参数不正确";
+			return false;
+		}
+		//查询订单,判断订单真实性
+		if( false &&  !$this->Queryorder($data["transaction_id"])){
+			
+			
+			
+			
+			$msg = "订单查询失败";
+			return false;
+		}else {
+			/**
+			{
+				"appid":"wx334ca53b2a62661a",
+				"bank_type":"CFT",
+				"cash_fee":"1",
+				"fee_type":"CNY",
+				"is_subscribe":"N",
+				"mch_id":"1246637501",
+				"nonce_str":"eKWYmZBlPgeRUoeyNpOAFuBXvXWVofsD",
+				"openid":"o_57D5DcRw-r6SdRxF98ikhf5dLY",
+				"out_trade_no":"7-1540693614",
+				"result_code":"SUCCESS",
+				"return_code":"SUCCESS",
+				"sign":"2B480C75338FCDE3972DF21AC7CC7596",
+				"time_end":"20181028102711",
+				"total_fee":"1",
+				"trade_type":"JSAPI",
+				"transaction_id":"4200000236201810287313447913"
+			}
+			**/
+			
+			
+			
+			$total_fee = $data['total_fee'];
+			$transaction_id = $data['transaction_id'];
+			$out_trade_no_arr =  explode('-',$data['out_trade_no']);
+			$out_trade_no = $out_trade_no_arr[0];
+			
+			if( isset($out_trade_no_arr[2]) && $out_trade_no_arr[2] == 'charge' )
+			{
+				//暂时屏蔽会员充值代码
+				
+				$member_charge_flow_info = M('lionfish_comshop_member_charge_flow')->where( array('id' => $out_trade_no ) )->find();
+				
+				if(!empty($member_charge_flow_info) && $member_charge_flow_info['state'] == 0)
+				{
+					$charge_flow_data = array();
+					$charge_flow_data['trans_id'] = $transaction_id;
+					$charge_flow_data['state'] = 1;
+					$charge_flow_data['charge_time'] = time();
+					
+					M('lionfish_comshop_member_charge_flow')->where( array('id' => $out_trade_no) )->save( $charge_flow_data );
+					
+					if( !empty($member_charge_flow_info['give_money']) && $member_charge_flow_info['give_money'] > 0 )
+					{
+						$member_charge_flow_info['money'] += $member_charge_flow_info['give_money'];
+					}
+					
+					
+					M('lionfish_comshop_member')->where( array('member_id' => $member_charge_flow_info['member_id'] ) )->setInc('account_money', $member_charge_flow_info['money'] );
+					
+					
+					$mb_info = M('lionfish_comshop_member')->field('account_money')->where( array('member_id' => $member_charge_flow_info['member_id']) )->find();
+					if( empty($mb_info['account_money']) )
+					{
+						$mb_info['account_money'] = 0;
+					}
+					M('lionfish_comshop_member_charge_flow')->where( array('id' => $out_trade_no) )->save(  array('operate_end_yuer' => $mb_info['account_money']) );
+					
+					
+					$mb_info = M('lionfish_comshop_member')->field('account_money')->where( array('member_id' => $member_charge_flow_info['member_id']) )->find();
+					
+					M('lionfish_comshop_member_charge_flow')->where( array('id' => $out_trade_no) )->save( array('operate_end_yuer' => $mb_info['account_money']) );
+					
+					
+					for($i=0;$i<3;$i++)
+					{
+						$member_formid_data = array();
+						$member_formid_data['member_id'] = $member_charge_flow_info['member_id'];
+						$member_formid_data['state'] = 0;
+						$member_formid_data['formid'] = $member_charge_flow_info['formid'];
+						$member_formid_data['addtime'] = time();
+						
+						M('lionfish_comshop_member_formid')->add($member_formid_data);
+					}
+					
+				}	
+				
+			}
+			else if(  isset($out_trade_no_arr[2]) && $out_trade_no_arr[2] == 'buycard' )
+			{
+				//购买会员卡代码	
+				$member_charge_flow_info = M('lionfish_comshop_member_card_order')->where( array('id' => $out_trade_no ) )->find();					
+				
+				$member_info = M('lionfish_comshop_member')->where( array('member_id' => $member_charge_flow_info['member_id'] ) )->find();
+									
+				if(!empty($member_charge_flow_info) && $member_charge_flow_info['state'] == 0)
+				{
+					$begin_time = 0;
+					$end_time = 0;
+					
+					if($member_charge_flow_info['order_type'] == 1)
+					{
+						//首次购买
+						$begin_time = time();
+						$end_time = $begin_time + 86400 * $member_charge_flow_info['expire_day'];
+						
+					}else if($member_charge_flow_info['order_type'] == 2)
+					{
+						//有效期内续期
+						$begin_time = $member_info['card_end_time'];
+						$end_time = $begin_time + 86400 * $member_charge_flow_info['expire_day'];
+					}else if($member_charge_flow_info['order_type'] == 3)
+					{
+						//过期后续费
+						$begin_time = time();
+						$end_time = $begin_time + 86400 * $member_charge_flow_info['expire_day'];
+					}
+					
+					$charge_flow_data = array();
+					$charge_flow_data['trans_id'] = $transaction_id;
+					$charge_flow_data['state'] = 1;
+					$charge_flow_data['pay_time'] = time();
+					$charge_flow_data['begin_time'] = $begin_time;
+					$charge_flow_data['end_time'] = $end_time;
+					$charge_flow_data['state'] = 1;
+					
+					M('lionfish_comshop_member_card_order')->where( array('id' => $out_trade_no ) )->save( $charge_flow_data );
+					
+					$mb_up_data = array();
+					$mb_up_data['card_id'] = $member_charge_flow_info['car_id'];
+					$mb_up_data['card_begin_time'] = $begin_time;
+					$mb_up_data['card_end_time'] = $end_time;
+					
+					M('lionfish_comshop_member')->where( array('member_id' => $member_charge_flow_info['member_id']  ) )->save( $mb_up_data );
+					
+					for($i=0;$i<3;$i++)
+					{
+						$member_formid_data = array();
+						$member_formid_data['member_id'] = $member_charge_flow_info['member_id'];
+						$member_formid_data['state'] = 0;
+						$member_formid_data['formid'] = $member_charge_flow_info['formid'];
+						$member_formid_data['addtime'] = time();
+						
+						M('lionfish_comshop_member_formid')->add($member_formid_data);
+					}
+					
+					
+				}
+			}
+			else{
+				//
+				
+				$order_all = M('lionfish_comshop_order_all')->where( array('id' => $out_trade_no ) )->find();
+				
+				if( in_array($order_all['order_status_id'], array(1,2,15)) ){
+					
+					$stop_pay = false;
+					
+					$order_relate_list = M('lionfish_comshop_order_relate')->where( array('order_all_id' => $order_all['id'] ) )->select();
+					
+					foreach($order_relate_list as $order_relate)
+					{
+						$order = M('lionfish_comshop_order')->where( array('order_id' => $order_relate['order_id'] ) )->find();
+						
+						if( $order && ($order['order_status_id'] != 3 && $order['order_status_id'] == 5) )
+						{
+							$stop_pay = true;
+						}
+					}
+					
+					if( $stop_pay )
+					{
+						$msg = "付款成功";
+						return true;
+					}
+				}
+
+				$o = array();
+				$o['order_status_id'] =  $order_all['is_pin'] == 1 ? 2:1;
+				$o['paytime']=time();
+				$o['transaction_id'] = $transaction_id;
+				
+				M('lionfish_comshop_order_all')->where( array('id' => $out_trade_no) )->save($o);
+				
+				$order_relate_list = M('lionfish_comshop_order_relate')->where( array('order_all_id' => $order_all['id']) )->select();
+				
+				//1
+					$data_path = dirname( dirname(dirname( dirname(__FILE__) )) ).'/Data/wxpaylogs/'.date('Y-m-d')."/";
+					RecursiveMkdir($data_path);
+					
+					$file = $data_path.date('Y-m-d').'.txt';
+					$handl = fopen($file,'a');
+					fwrite($handl,"关联--");
+					fwrite($handl,"关联");
+					fwrite($handl,":".json_encode($order_relate_list));
+					fclose($handl);
+				
+
+				foreach($order_relate_list as $order_relate)
+				{
+					$order = M('lionfish_comshop_order')->where( array('order_id' => $order_relate['order_id'] ) )->find();
+
+                    //检测是否预售
+                    $order_presale_info = M('lionfish_comshop_order_presale')->where(['order_id' => $order_relate['order_id'] ])->find();
+
+                    //检测是否礼品卡
+                    $order_virtualcard_info =  D('Seller/VirtualCard')->getOrderVirtualCardByOrderId( $order_relate['order_id'] );
+
+					if( $order && ($order['order_status_id'] == 3 || $order['order_status_id'] == 5 || $order['order_status_id'] == 15 ) )
+					{
+					    //begin 判断预售第一次还是第二次付款
+					    $order_status_id = $order['is_pin'] == 1 ? 2:1;
+					    if( !empty($order_presale_info) )
+                        {
+                            if( $order_presale_info['state'] == 0 )
+                            {
+                                $order_status_id = 15;//首次付款
+                            }else if( $order_presale_info['state'] == 1 )
+                            {
+                                $order_status_id = 1;//二次付款
+                            }
+                        }
+                        //end
+
+						$o = array();
+						$o['order_status_id'] =  $order_status_id;
+						$o['date_modified']=time();
+						$o['pay_time']=time();
+						$o['payment_code']='weixin';
+						$o['transaction_id'] = $transaction_id;
+
+						if( empty($order_presale_info) || $order_presale_info['state'] == 1 )
+                        {
+                            if($order['delivery'] == 'hexiao'  ){//核销订单 支付完成状态改成  已发货待收货
+                                $o['order_status_id'] =  4;
+                            }
+                        }
+
+						
+						M('lionfish_comshop_order')->where( array('order_id' => $order['order_id'] ) )->save( $o );
+						
+						//暂时屏蔽库存代码
+						
+						$kucun_method =  D('Home/Front')->get_config_by_name('kucun_method');
+						
+						if( empty($kucun_method) )
+						{
+							$kucun_method = 0;
+						}
+						
+						//kucun_method $_W['uniacid']
+						
+						if($kucun_method == 1)
+						{//支付完减库存,增加销量
+							
+							$order_goods_list = M('lionfish_comshop_order_goods')->where( array('order_id' => $order['order_id']) )->select();	
+							
+							foreach($order_goods_list as $order_goods)
+							{
+								D('Home/Pingoods')->del_goods_mult_option_quantity($order['order_id'],$order_goods['rela_goodsoption_valueid'],$order_goods['goods_id'],$order_goods['quantity'],1);
+								
+								
+							}
+						}
+						
+						$oh = array();	
+						$oh['order_id']=$order['order_id'];
+						$oh['uniacid']=$order['uniacid'];
+						$oh['order_status_id']= $order_status_id;
+							
+						$oh['comment']='买家已付款';
+						$oh['date_added']=time();
+						$oh['notify']=1;
+
+						if($order['delivery'] == 'hexiao' && empty($order_presale_info) ){//核销订单 支付完成状态改成  已发货待收货
+							$oh['order_status_id'] =  4;
+						}
+						
+						M('lionfish_comshop_order_history')->add($oh);
+
+						//邀新有礼下单完成领取礼包
+						D('Home/Invitegift')->collectInvitegiftAfterOrder($order, 'orderpay');
+
+                        if( empty($order_presale_info) )
+                        {
+                            //订单自动配送
+                            D('Home/Order')->order_auto_delivery($order);
+                        }
+
+						
+						//$weixin_nofity->orderBuy($order['order_id']);
+				
+						//$hashids = new \Lib\Hashids(C('PWD_KEY'), C('URL_ID'));
+						//$order_id = $hashids->encode($order['order_id']); 
+						//group_order_id
+						
+						if($order['is_pin'] == 1)
+						{
+							$pin_order = M('lionfish_comshop_pin_order')->where( array('order_id' => $order['order_id'] ) )->find();
+							
+							D('Home/Pin')->insertNotifyOrder($order['order_id']);
+							
+							//检测拼团是否已经成功了。如果已经成功了。那么重新开团,并且迁移掉目前的这个拼团订单到新的团去
+							//state
+							
+							$pin_info = M('lionfish_comshop_pin')->where(array('pin_id' => $pin_order['pin_id'])  )->find();//加锁查询
+							
+							$pin_buy_count = D('Home/Pin')->get_tuan_buy_count($pin_order['pin_id']);
+							
+							
+							$res = D('Seller/Redisorder')->add_pintuan_user( $pin_order['pin_id'] );
+							
+							
+							if( $pin_info['state']  == 1 && !$res )
+							{
+							    $order_goods_info = M('lionfish_comshop_order_goods')->where( array('order_id' => $order['order_id']) )->find();
+							    
+							    M('lionfish_comshop_pin_order')->where( array('pin_id' =>$pin_order['pin_id'],'order_id' => $order['order_id'] ) )->delete();
+							    
+							    $newpin_id = D('Home/Pin')->openNewTuan($order['order_id'],$order_goods_info['goods_id'],$order['member_id']);
+							    //插入拼团订单
+							    D('Home/Pin')->insertTuanOrder($newpin_id,$order['order_id']);
+							    unset($pin_info);
+							   
+							    $is_pin_success = D('Home/Pin')->checkPinSuccess($newpin_id);
+							    
+							    if($is_pin_success) {
+							        D('Home/Pin')->updatePintuanSuccess($newpin_id);
+							    }
+							}else{
+							    $is_pin_success = D('Home/Pin')->checkPinSuccess($pin_order['pin_id']);
+							    	
+							    if($is_pin_success) {
+							        D('Home/Pin')->updatePintuanSuccess($pin_order['pin_id']);
+							    } 
+							}
+
+						}
+						//检测预售支付
+						if( !empty($order_presale_info) )
+                        {
+                            D('Home/PresaleGoods')->payBackOrder( $order['order_id'] , $transaction_id );
+                        }
+                        //检测是否礼品卡
+                        if( !empty($order_virtualcard_info) )
+                        {
+                            D('Seller/VirtualCard')->payBackOrder( $order['order_id'] );
+                        }
+
+						//发送购买通知
+						D('Home/Weixinnotify')->orderBuy($order['order_id']);
+
+                        //微信交易组件
+                        if( $order['from_type'] == 'tradecomponts' )
+                        {
+                            D('Seller/MpModifyTradeComponts')->orderPay( $order['order_id'], '1' );
+                        }
+						
+					}
+
+				}		
+				
+				
+			}
+			
+			
+			
+			
+			
+					
+			//$order=M('Order')->getByOrderNumAlias($out_trade_no);
+			
+		    
+			
+			
+			return true;
+		}
+	}
+}
+

+ 0 - 0
Modules/Lib/Weixin/PayNotifyCallBack.class.php.back → Modules/Lib/Weixin-back/PayNotifyCallBack.class.php.back


+ 0 - 0
Modules/Lib/Weixin/WeChatEmoji.class.php.back → Modules/Lib/Weixin-back/WeChatEmoji.class.php


文件差异内容过多而无法显示
+ 49 - 0
Modules/Lib/Weixin-back/WeChatEmoji.class.php.back


+ 0 - 0
Modules/Lib/Weixin/WebController.class.php.back → Modules/Lib/Weixin-back/WebController.class.php


+ 1372 - 0
Modules/Lib/Weixin-back/WebController.class.php.back

@@ -0,0 +1,1372 @@
+<?php
+
+namespace Addons\LuojiangKaoping\Controller;
+use Mp\Controller\AddonsController;
+
+/**
+ * 洛江考评微官网后台管理控制器
+ * @author 大鱼
+ */
+class WebController extends AddonsController {
+	public function test()
+	{
+		//luojiang_achievement 
+		$all_list = M('luojiang_article')->select();
+		Vendor('HyperDown.Parser');
+		$parser = new \Parser();
+		
+		foreach( $all_list as $val )
+		{
+			$content = $parser->makeHtml($val['content']);
+			M('luojiang_article')->where( array('id' => $val['id']) )->save( array('content' => $content) );
+			//id 
+		}
+		var_dump('success');
+		die();
+		//LuojiangKaoping
+	}
+	public function eventreport()
+	{
+		/**
+		Vendor('HyperDown.Parser');
+		$parser = new \Parser();
+		$markdown = $parser->makeHtml("![](http://wx.mnw.cn/Uploads/Pictures/20180411/5acd6d78033a2.jpg)");
+
+
+
+		Vendor('Michelf.Markdown');
+		$html = \Michelf\Markdown::defaultTransform("![](http://wx.mnw.cn/Uploads/Pictures/20180411/5acd6d78033a2.jpg)");
+
+		var_dump($markdown,$html);
+		die();
+		**/
+
+		$custom = array(
+			'options' => array(
+				'lool_to_material' => array(
+					'title' => '处理上报事件',
+					'url' => U('addon/LuojiangKaoping/web/editeventreport', array('id'=>'{id}')),
+					'class' => 'btn btn-primary btn-sm icon-edit'
+				),
+				'edit_fans' => array(
+					'title' => '查看用户信息',
+					'url' => U('Mp/Fans/edit_fans_byid', array('fansid'=>'{fans_id}')),
+					'class' => 'btn btn-primary btn-sm icon-edit'
+				)
+			)
+		);
+		$this->addCrumb('洛江考评微官网', U('addon/LuojiangKaoping/index'), '')
+			 ->addCrumb('业务导航', U('addon/LuojiangKaoping/web/eventreport'), '')
+			 ->addCrumb('事件上报', '', 'active')
+			 ->setModel('luojiang_eventreport')
+			 ->setListOrder('addtime desc')
+			 ->setListMap(array('mpid'=>get_mpid()))
+             ->setTip('<p id="msg_flush">暂无新消息</p>')
+             ->setListSearch(array('nickname' => '会员名称'))
+			 ->addListItem('fans_id', '会员名称', 'callback', array('callback_name'=>'get_fans_name'))
+			 ->addListItem('event_type', '事件类型', 'enum', array('options'=>array('井盖缺失'=>'井盖缺失','道路破损'=>'道路破损','道路淘空'=>'道路淘空','陈年垃圾'=>'陈年垃圾','卫生死角'=>'卫生死角','公共设施'=>'公共设施','市容环境'=>'市容环境','其他情况'=>'其他情况')))
+			 ->addListItem('descript', '事件描述')
+			 ->addListItem('image_list', '图片列表', 'callback', array('callback_name'=>'get_images_str'))
+			 ->addListItem('video_file', '视频', 'callback', array('callback_name'=>'get_video_str'))
+			 ->addListItem('jiangli', '奖励')
+			 ->addListItem('id', '位置', 'callback', array('callback_name'=>'get_message_content'))
+			 ->addListItem('addtime', '创建时间', 'function', array('function_name'=>'date','params'=>'Y-m-d H:i:s,###'))
+			 ->addListItem('reply_info', '处理结果', '', array('placeholder'=>'<font color="red">未处理</font>'))
+			 ->addListItem('id', '操作', 'custom', $custom)
+             ->addButton('导出', U('addon/LuojiangKaoping/web/loadexcel'), 'btn btn-primary')
+             ->common_lists();
+			echo '<script src="/Public/Mp/js/checkflush.js"></script>';
+			echo "<style>.table-striped > tbody > tr:nth-child(odd) > td, .table-striped > tbody > tr:nth-child(odd) > th{border-top:1px solid #000; ;border-bottom:1px solid #000;}</style>";
+
+	}
+	public function get_message_content($id) {
+		$map['id'] = $id;
+		$map['mpid'] = get_mpid();
+		$message = M('luojiang_eventreport')->where($map)->find();
+		if(!empty($message['location_addr'])){
+			return $message['location_addr'].'<br/><button type="button" class="btn btn-sm btn-success"  onclick="lookMap('.$message['lat'].','.$message['lng'].')">查看【位置】</button>';
+		}else{
+			return "未提供";
+		}
+	}
+
+	public function downfile()
+	{
+		//.jpg  mp4
+		//$mp_message_info['msgtype'] == 'video'
+		$file_url = urldecode( I('get.file_url') );
+		$type = urldecode( I('get.type') );
+
+		$file_url = str_replace('/Uploads/','Uploads/',$file_url);
+		$file_name = $file_url.'.'.$type;
+
+		$file_sub_path= "/data/web/wx.mnw.cn/";
+		$file_path=$file_sub_path.$file_name;
+
+		$filectime = filectime($file_path);
+
+		if( strpos($file_name,'jpg') !== false )
+		{
+			$img_arrs = explode('.', $file_name);
+			$file_name = '微信图片_'.date('Ymd',$filectime).'_'.$filectime.'.'.$img_arrs[1];
+		}
+		else if( strpos($file_name,'png') !== false  ){
+			$img_arrs = explode('.', $file_name);
+			$file_name = '微信图片_'.date('Ymd',$filectime).'_'.$filectime.'.'.$img_arrs[1];
+		}
+		else if( strpos($file_name,'gif') !== false  ){
+			$img_arrs = explode('.', $file_name);
+			$file_name = '微信图片_'.date('Ymd',$filectime).'_'.$filectime.'.'.$img_arrs[1];
+		}
+		else if( strpos($file_name,'jpeg') !== false  ){
+			$img_arrs = explode('.', $file_name);
+			$file_name = '微信图片_'.date('Ymd',$filectime).'_'.$filectime.'.'.$img_arrs[1];
+		}
+		else if( strpos($file_name,'mp4') !== false  ){
+			$img_arrs = explode('.', $file_name);
+			$file_name = '微信视频_'.date('Ymd',$filectime).'_'.$filectime.'.'.$img_arrs[1];
+		}
+		else if($mp_message_info['msgtype'] == 'voice' ){
+			$img_arrs = explode('.', $file_name);
+			$file_name = '微信语音_'.date('Ymd',$filectime).'_'.$filectime.'.'.$img_arrs[1];
+		}
+
+		$fp=fopen($file_path,"r");
+        $file_size=filesize($file_path);
+
+		//var_dump($file_size);die();
+        //下载文件需要用到的头
+        Header("Content-type: application/octet-stream");
+        Header("Accept-Ranges: bytes");
+        Header("Accept-Length:".$file_size);
+        Header("Content-Disposition: attachment; filename=".$file_name);
+        $buffer=1024;
+        $file_count=0;
+        //向浏览器返回数据
+        while(!feof($fp) && $file_count<$file_size){
+            $file_con=fread($fp,$buffer);
+            $file_count+=$buffer;
+            echo $file_con;
+        }
+        fclose($fp);
+
+		echo $file_url;
+		die();
+
+	}
+	/**
+     * 获取视频
+     * @author lyf
+     */
+    public function get_video_str($video_file)
+    {
+        if(empty($video_file))
+        {
+            return '暂无';
+        }else{
+            return '<button type="button" class="btn btn-sm btn-warning icon-video" data-src="'.$video_file.'" onclick="lookVideo(this)">查看视频</button><a href="'.U('addon/HuianKaoping/web/downfile', array('type' =>'mp4', 'file_url' => urlencode($video_file) )).'" title="点击下载视频" target=_blank">【下载】</a>';
+        }
+    }
+	/*
+     * 导出
+     */
+    public function loadexcel()
+    {
+        header("content-type:text/html; charset=uft-8");
+
+        if(IS_POST)
+        {
+            //date_added_begin:2017-08-02 0:00:00
+            //date_added_end:2017-08-19 0:00:00
+            $data = I('post.');
+            $where = array();
+
+            if(!empty($data['date_added_begin']))
+            {
+                $where['addtime'] = array('gt',strtotime($data['date_added_begin']) );
+            }
+            if(!empty($data['date_added_end']))
+            {
+                $where['addtime'] = array('lt',strtotime($data['date_added_end']) );
+            }
+
+
+
+            $s_time = strtotime($data['date_added_begin']);
+            $e_time = strtotime($data['date_added_end']);
+
+
+            if($s_time && $e_time)
+            {
+                $where['addtime'] = array('between',array($s_time,$e_time));
+            }
+
+
+            $list = M('luojiang_eventreport')->where($where)->order('id desc')->select();
+
+            //$need_data = array( array('order_sn'=>1,'get_image'=>'http://wx.mnw.cn/Uploads/Pictures/2/2017-08-07/2_oA7ocv8o0sk-tPmG87fjPD25nQWs_1502095440.jpg'),array('order_sn'=>1,'get_image'=>'http://wx.mnw.cn/Uploads/Pictures/2/2017-08-07/2_oA7ocv8o0sk-tPmG87fjPD25nQWs_1502095440.jpg')  );
+
+            $need_data = array();
+
+            $xlsCell  = array(
+                array('id','序号'),
+                array('addtime','日期'),
+                array('fans_id','微信名'),
+				array('mobile','联系人电话'),
+				array('jifen','积分'),
+
+                array('descript','事件描述'),
+                array('image_list','图否'),
+				array('jiangli','奖励'),
+                array('is_reply','反馈情况'),
+                array('reply_info','反馈内容'),
+                array('video_file','视频')
+
+                /*
+
+                array('contact_tel','联系电话'),
+                array('jifen','积分'),
+                array('nickname','微信名'),
+                array('content','问题描述'),
+                array('get_img','图否'),
+                array('fankui','反馈情况'),
+                array('fankui_tu','反馈图片'),
+                */
+            );
+            $i = 1;
+            foreach($list as $val)
+            {
+                $tmp_data = array();
+                $tmp_data['id'] = $i;
+                $tmp_data['addtime'] = date('Y-m-d H:i:s', $val['addtime']);
+				//openid
+                $mp_fans = M('mp_fans')->field('nickname')->where( array('id' => $val['fans_id']) )->find();
+                $tmp_data['fans_id'] = $mp_fans['nickname'];
+				$tmp_data['mobile'] = $mp_fans['mobile'];
+
+				if(  empty($val['reply_info']) ){
+                    $tmp_data['jifen'] = 0;
+                }else{
+                    $tmp_data['jifen'] = 2;
+                }
+
+
+                $tmp_data['jiangli'] = $val['jiangli'];
+                //$tmp_data['title'] = $val['title'];
+                $tmp_data['descript'] = $val['descript'];
+                if(  empty($val['reply_info']) ){
+                    $tmp_data['is_reply'] = '否';
+                }else{
+                    $tmp_data['is_reply'] = '是';
+                }
+                $tmp_data['reply_info'] = $val['reply_info'];
+                if(empty($val['video_file']))
+                {
+                    $tmp_data['video_file'] ='否';
+
+                }else{
+					$tmp_data['video_file'] ='是';
+                    //$tmp_data['video_file'] ='http://'.$_SERVER['SERVER_NAME'].str_replace('./','',$val['video_file']);
+                }
+
+
+
+                //http://wx.mnw.cn/Uploads/Pictures/2/2017-08-07/2_oA7ocv8o0sk-tPmG87fjPD25nQWs_1502095440.jpg
+                if(!empty($val['image_list']))
+                {
+                    $img_arr = explode(',',$val['image_list']);
+                    if($val['image_list'] == ',undefined/undefined' || $val['image_list'] == 'undefined/undefined')
+                    {
+                        $img_url = '';
+						$img_urls = array();
+                    }else{
+						$img_urls = explode(',', $val['image_list']);
+
+						foreach($img_urls as $kk => $vv)
+						{
+							$vv = str_replace('./','/',$vv );
+
+							$vv = '/data/web/wx.mnw.cn'.$vv;
+							$img_urls[$kk] = $vv;
+						}
+
+                        //$img_url = str_replace('./','http://'.$_SERVER['SERVER_NAME'],$val['image_list']);
+                    }
+                    $tmp_data['image_list'] = $img_urls;
+                }
+                $i++;
+                $need_data[] = $tmp_data;
+            }
+            $expTitle = date('Y-m-d H:i:s');
+
+
+            export_excel($expTitle,$xlsCell,$need_data);
+
+        }
+        $this->display();
+    }
+	public function editeventreport()
+	{
+
+		$this->addCrumb('洛江考评微官网', U('addon/LuojiangKaoping/index'), '')
+		 ->addCrumb('业务导航', U('addon/LuojiangKaoping/web/eventreport'), '')
+		 ->addCrumb('处理上报事件', '', 'active')
+
+		 ->setModel('luojiang_eventreport')
+		 ->addFormField('jiangli', '上报奖励', 'text')
+		 ->addFormField('reply_info', '处理意见', 'text')
+
+		 ->setFormData( M('luojiang_eventreport')->find(I('get.id')) )
+		 ->setEditMap( array('id'=>I('get.id')) )
+		 ->setEditSuccessUrl( U('addon/LuojiangKaoping/web/eventreport') )
+		 ->common_edit();
+	}
+	public function opinionsuggestion()
+	{
+		$this->addCrumb('洛江考评微官网', U('addon/LuojiangKaoping/index'), '')
+			 ->addCrumb('业务导航', U('addon/LuojiangKaoping/web/eventreport'), '')
+			 ->addCrumb('意见建议', '', 'active')
+			 ->setModel('luojiang_opinionsuggestion')
+			 ->setListOrder('addtime desc')
+			 ->setListMap(array('mpid'=>get_mpid()))
+			 ->addListItem('fans_id', '会员名称', 'callback', array('callback_name'=>'get_fans_name'))
+			 ->addListItem('opinion_name', '建议人姓名')
+			 ->addListItem('contact', '建议人联系电话')
+			 ->addListItem('email', '邮箱')
+			 ->addListItem('title', '建议标题')
+			 ->addListItem('content', '建议内容')
+			 ->addListItem('image_list', '图片列表', 'callback', array('callback_name'=>'get_images_str'))
+			 ->addListItem('reply_method', '回复方式', 'enum', array('options'=>array('1'=>'网上',2=>'电话',3=>'当面')))
+			 //->addListItem('is_reply', '是否回复', 'enum', array('options'=>array(0=>'未回复',1=>'已回复')))
+			 ->addListItem('addtime', '创建时间', 'function', array('function_name'=>'date','params'=>'Y-m-d H:i:s,###'))
+			->addListItem('id', '操作', 'custom', array('options'=>array('edit_eventreport'=>array('处理意见建议', U('addon/LuojiangKaoping/web/editopinionsuggestion', array('id'=>'{id}')),'btn btn-primary btn-sm icon-edit',''))))
+			//->addListItem('id', '操作', 'custom', array('options'=>array('edit_fans'=>array('编辑粉丝资料', U('Mp/Fans/edit_fans', array('openid'=>'{openid}')),'btn btn-primary btn-sm icon-edit',''))))
+		     ->common_lists();
+	}
+	public function editopinionsuggestion()
+	{
+		$this->addCrumb('洛江考评微官网', U('addon/LuojiangKaoping/index'), '')
+		 ->addCrumb('业务导航', U('addon/LuojiangKaoping/web/eventreport'), '')
+		 ->addCrumb('处理意见建议', '', 'active')
+
+		 ->setModel('luojiang_opinionsuggestion')
+		 ->addFormField('reply_info', '处理意见', 'text')
+
+		 ->setFormData( M('luojiang_opinionsuggestion')->find(I('get.id')) )
+		 ->setEditMap( array('id'=>I('get.id')) )
+		 ->setEditSuccessUrl( U('addon/LuojiangKaoping/web/opinionsuggestion') )
+		 ->common_edit();
+
+	}
+	public function newsnenter_two()
+	{
+		$options = array(
+			'edit_fans'=>array('编辑', U('addon/LuojiangKaoping/web/editarticle', array('id'=>'{id}') )
+			,'btn btn-primary btn-sm icon-edit',''),
+			'delete' =>	array(
+				'title' => '删除',
+				'url' => U('addon/LuojiangKaoping/web/deletearticle', array('id'=>'{id}')),
+				'class' => 'btn btn-danger btn-sm icon-delete'
+			)
+		);
+		$this->addCrumb('洛江考评微官网', U('addon/LuojiangKaoping/index'), '')
+			 ->addCrumb('业务导航', U('addon/LuojiangKaoping/web/eventreport'), '')
+			 ->addCrumb('新闻中心', '', 'active')
+			 ->setModel('luojiang_article')
+			 ->setListMap(array('type'=>2))
+			 ->setListOrder('addtime desc')
+
+			 ->addListItem('title', '标题')
+			// ->addListItem('logo', '图片', 'image', array('attr'=>'width=50 height=50','placeholder'=>__ROOT__ . '/Public/Admin/img/noname.jpg'))
+			 ->addListItem('cate_id', '所属分类', 'callback',array('callback_name'=>'get_cate_name'))
+			 ->addListItem('sendtime', '发布时间')
+			 ->addListItem('addtime', '创建时间', 'function', array('function_name'=>'date','params'=>'Y-m-d H:i:s,###'))
+			 ->addListItem('id', '操作', 'custom', array('options'=>$options))
+			 //->addButton('新增文章分类', U('addon/HuianKaoping/web/addarticlecate'), 'btn btn-primary')
+			 ->addButton('新增文章', U('addon/LuojiangKaoping/web/addarticle_two'), 'btn btn-primary')
+			 ->common_lists();
+	}
+	public function newsnenter()
+	{
+		$options = array(
+			'edit_fans'=>array('编辑', U('addon/LuojiangKaoping/web/editarticle', array('id'=>'{id}') )
+			,'btn btn-primary btn-sm icon-edit',''),
+			'delete' =>	array(
+				'title' => '删除',
+				'url' => U('addon/LuojiangKaoping/web/deletearticle', array('id'=>'{id}')),
+				'class' => 'btn btn-danger btn-sm icon-delete'
+			)
+		);
+		$this->addCrumb('洛江考评微官网', U('addon/LuojiangKaoping/index'), '')
+			 ->addCrumb('业务导航', U('addon/LuojiangKaoping/web/eventreport'), '')
+			 ->addCrumb('新闻中心', '', 'active')
+			 ->setModel('luojiang_article')
+			 ->setListMap(array('type'=>1))
+			 ->setListOrder('addtime desc')
+
+			 ->addListItem('title', '标题')
+			 ->addListItem('logo', '图片', 'image', array('attr'=>'width=50 height=50','placeholder'=>__ROOT__ . '/Public/Admin/img/noname.jpg'))
+			 ->addListItem('cate_id', '所属分类', 'callback',array('callback_name'=>'get_cate_name'))
+			 ->addListItem('sendtime', '发布时间')
+			 ->addListItem('addtime', '创建时间', 'function', array('function_name'=>'date','params'=>'Y-m-d H:i:s,###'))
+			 ->addListItem('id', '操作', 'custom', array('options'=>$options))
+			 //->addButton('新增文章分类', U('addon/HuianKaoping/web/addarticlecate'), 'btn btn-primary')
+			 ->addButton('新增文章', U('addon/LuojiangKaoping/web/addarticle'), 'btn btn-primary')
+			 ->common_lists();
+	}
+
+	/**
+	 * 删除关键词回复
+	 * @author 艾逗笔<765532665@qq.com>
+	 */
+	public function deletearticle() {
+
+		M('luojiang_article')->where( array('id' =>I('get.id') ) )->delete();
+		$this->success('删除成功');
+
+	}
+	public function votecenter()
+	{
+		$this->addCrumb('洛江考评微官网', U('addon/LuojiangKaoping/index'), '')
+			 ->addCrumb('业务导航', U('addon/LuojiangKaoping/web/eventreport'), '')
+			 ->addCrumb('投票专区', '', 'active')
+			 ->setModel('vote')
+
+			 ->addListItem('title', '标题')
+			 ->addListItem('begin_time', '开始时间', 'function', array('function_name'=>'date','params'=>'Y-m-d H:i:s,###'))
+			 ->addListItem('end_time', '结束时间', 'function', array('function_name'=>'date','params'=>'Y-m-d H:i:s,###'))
+			 ->addListItem('addtime', '添加时间', 'function', array('function_name'=>'date','params'=>'Y-m-d H:i:s,###'))
+
+			 ->addListItem('vote_id', '操作', 'custom', array('options'=>array(
+				'edit_fans'=>array('编辑', U('addon/LuojiangKaoping/web/editvote', array('vote_id'=>'{vote_id}') ) ,'btn btn-primary btn-sm icon-edit',''),
+				'add_votesubject'=>array('添加投票选项', U('addon/LuojiangKaoping/web/addvotesubject', array('vote_id'=>'{vote_id}') ) ,'btn btn-primary btn-sm icon-edit',''),
+			 )))
+		     ->addButton('新增投票', U('addon/LuojiangKaoping/web/addvote'), 'btn btn-primary')
+			 ->common_lists();
+	}
+	public function addvote()
+	{
+		if( IS_POST )
+		{
+			$data = I('post.');
+			$vote_data = array();
+			$vote_data['mpid'] = get_mpid();
+			$vote_data['title'] = $data['name'];
+			$vote_data['begin_time'] = strtotime( $data['date_added_begin'] );
+			$vote_data['end_time'] = strtotime( $data['date_added_end'] );
+			$vote_data['addtime'] = time();
+			M('vote')->add($vote_data);
+			$this->success('添加投票成功', U('addon/LuojiangKaoping/web/votecenter'));
+			die();
+		}
+
+		$this->addCrumb('洛江考评微官网', U('addon/LuojiangKaoping/index'), '')
+			 ->addCrumb('业务导航', U('addon/LuojiangKaoping/web/eventreport'), '')
+			 ->addCrumb('新闻中心', '', 'active')
+			 ->display();
+	}
+	public function addvotesubject()
+	{
+		$vote_id = I('get.vote_id');
+		$this->vote_id = $vote_id;
+
+		if( IS_POST )
+		{
+			$data = I('post.');
+
+			if( isset($data['edit_votesubject']) )
+			{
+				$has_key = array();
+				$del_key = array();
+
+				foreach( $data['attr_title'] as $key => $val)
+				{
+					$has_key[] = $key;
+				}
+				$vote_sub_all =  M('vote_subject')->where( array('vote_id' => $data['vote_id']) )->select();
+
+				foreach($vote_sub_all as $vote_sub)
+				{
+					if( !in_array($vote_sub['sub_id'],$has_key ) )
+					{
+						$del_key[] = $vote_sub['sub_id'];
+					}
+				}
+				//删除多余键
+				if( !empty($del_key) )
+				{
+					M('vote_subject')->where( array('sub_id' => array('in', $del_key ) ) )->delete();
+					//删除投票记录
+					M('vote_record')->where( array('sub_id' => array('in', $del_key ) ) )->delete();
+				}
+				//开始更新和新增选项
+
+				foreach($data['attr_title'] as $key => $val)
+				{
+					if( strpos($key, 'new') !== false )
+					{
+						//新增的模块
+						$tmp_vote_subject = array();
+						$tmp_vote_subject['vote_id'] = $data['vote_id'];
+						$tmp_vote_subject['title'] = $val;
+						$tmp_vote_subject['type'] = $data['type'][$key];
+						$tmp_vote_subject['addtime'] = time();
+						M('vote_subject')->add($tmp_vote_subject);
+						$sub_id = M('vote_subject')->getLastInsID();
+
+						$extra = $data['extra'][$key];
+						$extra_arr = explode('|', $extra);
+						foreach($extra_arr as $vv)
+						{
+							$xun_data = array();
+							$xun_data['sub_id'] = $sub_id;
+							$xun_data['titile'] = $vv;
+							$xun_data['addtime'] = time();
+							M('vote_xuan')->add($xun_data);
+						}
+					} else {
+						//需要更新板块
+						$tmp_vote_subject = array();
+						$tmp_vote_subject['title'] = $val;
+						$tmp_vote_subject['type'] = $data['type'][$key];
+						M('vote_subject')->where( array('sub_id' =>$key ) ) ->save($tmp_vote_subject);
+
+						//更新子内容
+						//先判断原来有几个
+						$vote_xuan_list = M('vote_xuan')->where( array('sub_id' => $key) )->order('xu_id asc')->select();
+
+						$extra = array();
+						$extra = $data['extra'][$key];
+						$extra_arr = explode('|', $extra);
+						foreach($vote_xuan_list as $xun_vo)
+						{
+							if( !empty($extra_arr) )
+							{
+								$tmp_xun = array_shift( $extra_arr );
+								M('vote_xuan')->where( array('xu_id' => $xun_vo['xu_id']) )->save( array('titile' => $tmp_xun) );
+							}else {
+								//需要删除的
+								M('vote_xuan')->where( array('xu_id' => $xun_vo['xu_id']) )->delete();
+							}
+						}
+						//判断是否可以新增
+						if( !empty($extra_arr) )
+						{
+							foreach($extra_arr as $vv)
+							{
+								$xun_data = array();
+								$xun_data['sub_id'] = $key;
+								$xun_data['titile'] = $vv;
+								$xun_data['addtime'] = time();
+								M('vote_xuan')->add($xun_data);
+							}
+						}
+					}
+				}
+				$this->success('编辑投票选项成功', U('addon/HuianKaoping/web/votecenter'));
+				die();
+			}
+
+
+
+			foreach($data['attr_title'] as $key => $val)
+			{
+				if( !empty($val) )
+				{
+					$tmp_vote_subject = array();
+					$tmp_vote_subject['vote_id'] = $data['vote_id'];
+					$tmp_vote_subject['title'] = $val;
+					$tmp_vote_subject['type'] = $data['type'][$key];
+					$tmp_vote_subject['addtime'] = time();
+					M('vote_subject')->add($tmp_vote_subject);
+					$sub_id = M('vote_subject')->getLastInsID();
+
+					$extra = $data['extra'][$key];
+					//vote_xuan
+					$extra_arr = explode('|', $extra);
+					foreach($extra_arr as $vv)
+					{
+						$xun_data = array();
+						$xun_data['sub_id'] = $sub_id;
+						$xun_data['titile'] = $vv;
+						$xun_data['addtime'] = time();
+						M('vote_xuan')->add($xun_data);
+					}
+				}
+			}
+
+			$this->success('新增投票选项成功', U('addon/HuianKaoping/web/votecenter'));
+			die();
+
+		}
+
+		$vote_subject = M('vote_subject')->where( array('vote_id' => $vote_id) )->order('sub_id asc')->select();
+
+		if( !empty($vote_subject) )
+		{
+			foreach( $vote_subject as $key=> $val )
+			{
+				$vote_xuan_list = M('vote_xuan')->where( array('sub_id' => $val['sub_id']) )->order('xu_id asc')->select();
+				$xun_arr = array();
+
+				foreach( $vote_xuan_list as $vv )
+				{
+					$xun_arr[] = $vv['titile'];
+				}
+
+				$val['xun_title'] =  implode('|', $xun_arr);
+				$val['vote_xuan_list'] = $vote_xuan_list;
+				$vote_subject[$key] = $val;
+			}
+
+			$this->vote_subject = $vote_subject;
+
+
+
+			$this->addCrumb('洛江考评微官网', U('addon/HuianKaoping/index'), '')
+			 ->addCrumb('业务导航', U('addon/HuianKaoping/web/eventreport'), '')
+			 ->addCrumb('新闻中心', '', 'active')
+			 ->display('editvotesubject');
+		} else {
+			$this->addCrumb('洛江考评微官网', U('addon/HuianKaoping/index'), '')
+			 ->addCrumb('业务导航', U('addon/HuianKaoping/web/eventreport'), '')
+			 ->addCrumb('新闻中心', '', 'active')
+			 ->display();
+		}
+	}
+	public function loadachievement()
+	{
+        $type = I('type');
+		if( IS_POST )
+		{
+            set_time_limit(0);
+			  if(isset($_FILES["file"]) && ($_FILES["file"]["error"] == 0)){
+
+
+				  $excel_dir = './Uploads/Pictures/' . date('Y-m-d') . '/';
+					if (!file_exists($excel_dir)) {
+						$dirs = explode('/', $excel_dir);
+						$dir = $dirs[0] . '/';
+						for ($i=1, $j=count($dirs)-1; $i<$j; $i++) {
+							$dir .= $dirs[$i] . '/';
+							if (!is_dir($dir)) {
+								mkdir($dir, 0777);
+							}
+						}
+					}
+
+				  $extension = pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION);
+
+
+				  $path = $excel_dir.'/'.md5($_FILES['file']['name'].mt_rand(1, 999)).'.'.$extension;
+				  $rs = move_uploaded_file($_FILES["file"]["tmp_name"],$path);
+
+
+
+				$file = $path;
+				$type = pathinfo($file);
+				$type = strtolower($type["extension"]);
+				$type=$type==='csv' ? $type : 'Excel5';
+				ini_set('max_execution_time', '0');
+				vendor("PHPExcel.PHPExcel");
+				// 判断使用哪种格式
+				$objReader = \PHPExcel_IOFactory::createReader($type);
+				$objPHPExcel = $objReader->load($file);
+				$sheet = $objPHPExcel->getSheet(0);
+				// 取得总行数
+				$highestRow = $sheet->getHighestRow();
+				// 取得总列数
+				$highestColumn = $sheet->getHighestColumn();
+				//循环读取excel文件,读取一条,插入一条
+				$data=array();
+				//从第一行开始读取数据
+				for($j=1;$j<=$highestRow;$j++){
+					if($j <=2) {
+						continue;
+					}
+					//从A列读取数据
+					for($k='A';$k<=$highestColumn;$k++){
+						// 读取单元格
+						$data[$j][]=$objPHPExcel->getActiveSheet()->getCell("$k$j")->getValue();
+					}
+				}
+
+				$result = $data;
+				$get_data = array();
+				if(!empty($result)) {
+					foreach($result as $key => $val){
+
+						//array(5) { [0]=> string(6) "村庄" [1]=> string(18) "2017-8月上半月"
+						//[2]=> string(9) "小岞镇" [3]=> string(9) "新桥村" [4]=> float(92.5) }
+						if(empty($val[0]))
+						{
+							continue;
+						}
+						//$val[1] = str_replace('上半月','01',$val[1]);
+						//$val[1] = str_replace('下半月','15',$val[1]);
+
+
+
+						//$val[1] = $val[1]->__toString();
+						$val[1] .= ' 00:00:00';
+						//$val[1] = str_replace('年','-',$val[1]);
+						//$val[1] = str_replace('月','',$val[1]);
+
+						$need_data = array();
+						$need_data['name'] = $val[0];
+						$need_data['kao_time'] = strtotime($val[1]);
+						$need_data['zeren_danwei'] = $val[2];
+						$need_data['stree'] = $val[3];
+						$need_data['kaoping_dian'] = '';
+						$need_data['chengji'] = $val[4];
+                        if(I('type') == 2)
+                        {
+                            $need_data['type'] = 2;
+                        }else{
+                            $need_data['type'] = 1;
+                        }
+						if(empty($need_data['stree']))
+                        {
+                            $need_data['stree'] = '';
+                        }
+						$need_data['paiming'] = 0;
+						$need_data['addtime'] = time();
+						M('luojiang_achievement')->add($need_data);
+					}
+                    if(I('type') == 2){
+                        $this->success('导入成绩成功', U('addon/LuojiangKaoping/web/achievementmanage_two'));
+                    }else{
+                        $this->success('导入成绩成功', U('addon/LuojiangKaoping/web/achievementmanage'));
+                    }
+					die();
+				}
+			  }
+		}
+        $this->assign('type', $type);
+		$this->addCrumb('洛江考评微官网', U('addon/LuojiangKaoping/index'), '')
+			 ->addCrumb('业务导航', U('addon/LuojiangKaoping/web/eventreport'), '')
+			 ->addCrumb('成绩管理', '', 'active')
+			 ->display();
+	}
+
+	public function editvote()
+	{
+		// /vote_id/1
+		$vote_id = I('get.vote_id');
+
+		if( IS_POST )
+		{
+			$data = I('post.');
+
+			$data = I('post.');
+			$vote_data = array();
+			$vote_data['mpid'] = get_mpid();
+			$vote_data['title'] = $data['name'];
+			$vote_data['begin_time'] = strtotime( $data['date_added_begin'] );
+			$vote_data['end_time'] = strtotime( $data['date_added_end'] );
+
+			M('vote')->where( array('vote_id' => $data['vote_id']) )->save($vote_data);
+
+			$this->success('编辑投票成功', U('addon/HuianKaoping/web/votecenter'));
+			die();
+		}
+
+		$vote = M('vote')->where( array('vote_id' => $vote_id) )->find();
+
+		$this->vote = $vote;
+
+		$this->addCrumb('洛江考评微官网', U('addon/HuianKaoping/index'), '')
+			 ->addCrumb('业务导航', U('addon/HuianKaoping/web/eventreport'), '')
+			 ->addCrumb('新闻中心', '', 'active')
+			 ->display('addvote');
+	}
+
+	public function editachievement()
+	{
+		$id = I('get.id');
+		$type = I('get.type');
+		if( IS_POST )
+		{
+			$data = I('post.');
+
+
+			$vote_data = array();
+			$vote_data['name'] = $data['name'];
+			$vote_data['kao_time'] = strtotime( $data['kao_time'] );
+			$vote_data['zeren_danwei'] = $data['zeren_danwei'];
+			$vote_data['stree'] = $data['stree'];
+			$vote_data['content'] = ($data['content']);
+			//$vote_data['kaoping_dian'] = $data['kaoping_dian'];
+			$vote_data['chengji'] = $data['chengji'];
+			//$vote_data['paiming'] = $data['paiming'];
+			M('luojiang_achievement')->where( array('id' => $id) )->save($vote_data);
+
+            if($data['type'] == 2)
+            {
+                $this->success('编辑成功', U('addon/LuojiangKaoping/web/achievementmanage_two'));
+            }else{
+                $this->success('编辑成功', U('addon/LuojiangKaoping/web/achievementmanage'));
+            }
+
+			die();
+		}
+
+        if($type == 2)
+        {
+            $this->setEditSuccessUrl( U('addon/LuojiangKaoping/web/achievementmanage_two') );
+        }else{
+            $this->setEditSuccessUrl( U('addon/LuojiangKaoping/web/achievementmanage') );
+        }
+        $this->assign('type', $type);
+		$this->addCrumb('洛江考评微官网', U('addon/LuojiangKaoping/index'), '')
+		 ->addCrumb('成绩管理', U('addon/LuojiangKaoping/web/achievementmanage'), '')
+		 ->addCrumb('成绩管理', '', 'active')
+		 ->setModel('luojiang_achievement')
+		 ->addFormField('name', '类别', 'text')
+		 ->addFormField('kao_time', '考评时间', 'date')
+		 ->addFormField('zeren_danwei', '街道(乡镇)/责任单位', 'text')
+		 ->addFormField('stree', '抽评点', 'text')
+		 ->addFormField('content', '内容', 'editor')
+		 //->addFormField('kaoping_dian', '考评点', 'text')
+		 ->addFormField('chengji', '成绩', 'text')
+		 //->addFormField('paiming', '排名', 'text')
+
+		 ->setEditMap( array('id'=>I('get.id')))
+		 ->common_edit();
+
+	}
+	public function get_cate_name($cate_id)
+	{
+		$category_info =  M('luojiang_articlecategory')->where( array('id' => $cate_id) )->find();
+		return $category_info['name'];
+	}
+
+	public function editarticle()
+	{
+		$cateinfos = M('luojiang_articlecategory')->where( array('pid' => 0) )->select();
+
+		$cate_arr = array();
+		foreach($cateinfos as $val)
+		{
+			$cate_arr[$val[id]] = $val['name'];
+		}
+
+		$this->addCrumb('洛江考评微官网', U('addon/LuojiangKaoping/index'), '')
+		 ->addCrumb('业务导航', U('addon/LuojiangKaoping/web/eventreport'), '')
+		 ->addCrumb('编辑文章', '', 'active')
+		 ->setModel('huian_article')
+		 ->addFormField('title', '标题', 'text')
+		 ->addFormField('link', '外链', 'text')
+		 ->addFormField('logo', '图片', 'image')
+		 ->addFormField('sendtime', '发布时间', 'time')
+		 ->addFormField('cate_id', '所属分类', 'select', array('options'=>$cate_arr))
+		 ->addFormField('content', '内容', 'editor')
+		 ->setValidate(array(
+				array('name', 'require', '标题不能为空')//,
+				//array('logo', 'require', '请上传图片')
+		   ))
+		 ->setFormData( M('luojiang_article')->find(I('get.id')) )
+		 ->setEditMap( array('id'=>I('get.id')) )
+		 ->setEditSuccessUrl( U('addon/LuojiangKaoping/web/newsnenter') )
+		 ->common_edit();
+
+
+	}
+	public function addarticlecate()
+	{
+		$this->addCrumb('洛江考评微官网', U('addon/LuojiangKaoping/index'), '')
+			 ->addCrumb('业务导航', U('addon/LuojiangKaoping/web/eventreport'), '')
+			 ->addCrumb('添加文章分类', '', 'active')
+			 ->setModel('luojiang_articlecategory')
+			 ->addFormField('name', '名称', 'text')
+			 //->addFormField('type', '类型', 'radio', array('options'=>array(1=>'普通订阅号',2=>'认证订阅号',3=>'普通服务号',4=>'认证服务号',5=>'测试号'),'value'=>4,'is_must'=>1))
+			// ->addFormField('pid', '原始ID', 'text', array('is_must'=>1))
+			 //->addFormField('mp_number', '微信号', 'text')
+			// ->addFormField('appid', 'APPID', 'text')
+			// ->addFormField('appsecret', 'APPSECRET', 'text')
+			 //->addFormField('headimg', '头像', 'image')
+			 //->addFormField('qrcode', '二维码', 'image')
+			 ->setValidate(array(
+					array('name', 'require', '名称不能为空'),
+			   ))
+			 ->setAuto(array(
+					array('pid', '0'),
+					array('addtime', 'time', 1, 'function')
+			 ))
+			 ->setAddSuccessUrl( U('addon/LuojiangKaoping/web/newsnenter') )
+			 ->common_add();
+	}
+
+	public function addarticle_two()
+	{
+		$cateinfos = M('luojiang_articlecategory')->where( array('pid' => 0) )->select();
+
+		$cate_arr = array();
+		foreach($cateinfos as $val)
+		{
+			$cate_arr[$val[id]] = $val['name'];
+		}
+
+		$this->addCrumb('洛江考评微官网', U('addon/LuojiangKaoping/index'), '')
+			 ->addCrumb('业务导航', U('addon/LuojiangKaoping/web/eventreport'), '')
+			 ->addCrumb('添加文章', '', 'active')
+			 ->setModel('luojiang_article')
+			 ->addFormField('title', '标题', 'text')
+			 ->addFormField('type', '1', 'hidden',array('value'=>2))
+			 //->addFormField('link', '外链', 'text')
+			 //->addFormField('logo', '图片', 'image')
+			 ->addFormField('sendtime', '发布时间', 'time')
+			 ->addFormField('cate_id', '1', 'hidden',array('value'=>1))
+			 //->addFormField('cate_id', '所属分类', 'select', array('options'=>$cate_arr))
+			 ->addFormField('content', '内容', 'editor')
+			 ->setValidate(array(
+					array('name', 'require', '标题不能为空'),
+					//array('logo', 'require', '请上传图片')
+			   ))
+			 ->setAuto(array(
+					array('addtime', 'time', 1, 'function')
+			   ))
+			 ->setAddSuccessUrl( U('addon/LuojiangKaoping/web/newsnenter_two') )
+			 ->common_add();
+	}
+
+	public function addarticle()
+	{
+		$cateinfos = M('luojiang_articlecategory')->where( array('pid' => 0) )->select();
+
+		$cate_arr = array();
+		foreach($cateinfos as $val)
+		{
+			$cate_arr[$val[id]] = $val['name'];
+		}
+
+		$this->addCrumb('洛江考评微官网', U('addon/LuojiangKaoping/index'), '')
+			 ->addCrumb('业务导航', U('addon/LuojiangKaoping/web/eventreport'), '')
+			 ->addCrumb('添加文章', '', 'active')
+			 ->setModel('luojiang_article')
+			 ->addFormField('title', '标题', 'text')
+			 ->addFormField('type', '1', 'hidden',array('value'=>1))
+			 ->addFormField('link', '外链', 'text')
+			 ->addFormField('logo', '图片', 'image')
+			 ->addFormField('sendtime', '发布时间', 'time')
+			 ->addFormField('cate_id', '所属分类', 'select', array('options'=>$cate_arr))
+			 ->addFormField('content', '内容', 'editor')
+			 ->setValidate(array(
+					array('name', 'require', '标题不能为空')//,
+					//array('logo', 'require', '请上传图片')
+			   ))
+			 ->setAuto(array(
+					array('addtime', 'time', 1, 'function')
+			   ))
+			 ->setAddSuccessUrl( U('addon/LuojiangKaoping/web/newsnenter') )
+			 ->common_add();
+	}
+	public function achievementmanage()
+	{
+		$this->addCrumb('洛江考评微官网', U('addon/LuojiangKaoping/index'), '')
+			 ->addCrumb('业务导航', U('addon/LuojiangKaoping/web/eventreport'), '')
+			 ->addCrumb('乡镇成绩管理', '', 'active')
+			 ->setModel('luojiang_achievement')
+			 ->setListOrder('addtime desc')
+			 ->addListItem('name', '类别')
+            //->addListItem('kao_time', '考评时间', 'function', array('function_name'=>'date','params'=>'Y-m-d H:i:s,###'))
+             ->setListMap(array('type'=>1))
+             ->addListItem('kao_time', '考评时间', 'callback', array('callback_name'=>'get_date_hui'))
+			 ->addListItem('zeren_danwei', '街道办事处')
+			 ->addListItem('stree', '抽评点')
+			 //->addListItem('kaoping_dian', '考评点')
+			 ->addListItem('chengji', '成绩')
+			 //->addListItem('paiming', '排名')
+			 ->addListItem('addtime', '添加时间', 'function', array('function_name'=>'date','params'=>'Y-m-d H:i:s,###'))
+			 ->addButton('导入考评成绩', U('addon/LuojiangKaoping/web/loadachievement'), 'btn btn-primary')
+			 ->addListItem('id', '操作', 'custom', array('options'=>array('edit_fans'=>array('编辑成绩', U('addon/LuojiangKaoping/web/editachievement', array('id'=>'{id}','type'=>1)),'btn btn-primary btn-sm icon-edit',''))))
+		     ->common_lists();
+
+		$cjcount = M('luojiang_achievement')->where(array('paiming'=>0,'type'=>1))->count();
+		if($cjcount>0)
+		{
+			$paiming = array();
+			$pagecount = M('luojiang_achievement')->field('kao_time')->where(array('type'=>1))->group('kao_time')->order('kao_time desc')->select();
+			foreach($pagecount as $val)
+			{
+				$data = M('luojiang_achievement')->field('id,chengji')->where(array("kao_time"=>$val['kao_time'],"type"=>1))->order('chengji desc, id asc')->select();
+				$chengji = $data[0]['chengji'];
+				$order = 1;$num = 0;
+				foreach($data as $key=>$subval)
+				{
+					if($key != 0){
+						if($subval["chengji"] < $chengji){
+							$order += 1;
+							$chengji = $subval['chengji'];
+							$order += $num;
+							$num = 0;
+						}
+						else {
+							$num++;
+						}
+					}
+					$paiming[] = array('id'=>$subval["id"],'paiming'=>$order);
+				}
+				krsort($data);
+				$chengji = $data[count($data)-1]['chengji'];
+				$order = -5;$num = 0;
+				foreach($data as $key=>$subval)
+				{
+					if($key != count($data)-1){
+						if($subval["chengji"] > $chengji){
+							$order += 1;
+							$chengji = $subval['chengji'];
+							$order += $num;
+							$num = 0;
+						}
+						else {
+							$num++;
+						}
+					}
+					if($order == 0) break;
+					$paiming[] = array('id'=>$subval["id"],'paiming'=>$order);
+				}
+			}
+			foreach($paiming as $val)
+			{
+				$data['paiming'] = $val['paiming'];
+				M('luojiang_achievement')->where(array("id"=>$val['id']))->save($data);
+			}
+		}
+	}
+
+	 public function achievementmanage_two()
+    {
+        $this->addCrumb('洛江考评微官网', U('addon/LuojiangKaoping/index'), '')
+            ->addCrumb('业务导航', U('addon/LuojiangKaoping/web/eventreport'), '')
+            ->addCrumb('部门成绩管理', '', 'active')
+            ->setModel('luojiang_achievement')
+            ->setListOrder('addtime desc')
+            ->setListMap(array('type'=>2))
+            ->addListItem('name', '类别')
+            //->addListItem('kao_time', '考评时间', 'function', array('function_name'=>'date','params'=>'Y-m-d H:i:s,###'))
+            ->addListItem('kao_time', '考评时间', 'callback', array('callback_name'=>'get_date_hui'))
+            ->addListItem('zeren_danwei', '部门')
+            ->addListItem('stree', '考评对象')
+            //->addListItem('kaoping_dian', '考评点')
+            ->addListItem('chengji', '成绩')
+            //->addListItem('paiming', '排名')
+            ->addListItem('addtime', '添加时间', 'function', array('function_name'=>'date','params'=>'Y-m-d H:i:s,###'))
+            ->addButton('导入考评成绩', U('addon/LuojiangKaoping/web/loadachievement',array('type'=>2)), 'btn btn-primary')
+            ->addListItem('id', '操作', 'custom', array('options'=>array('edit_fans'=>array('编辑成绩', U('addon/HuianKaoping/web/editachievement', array('id'=>'{id}','type'=>2)),'btn btn-primary btn-sm icon-edit',''))))
+            ->common_lists();
+
+        $cjcount = M('luojiang_achievement')->where(array('paiming'=>0,'type'=>2))->count();
+        if($cjcount>0)
+        {
+            $paiming = array();
+            $pagecount = M('luojiang_achievement')->field('kao_time')->where(array('type'=>2))->group('kao_time')->order('kao_time desc')->select();
+            foreach($pagecount as $val)
+            {
+                $data = M('luojiang_achievement')->field('id,chengji')->where(array("kao_time"=>$val['kao_time'],'type'=>2))->order('chengji desc, id asc')->select();
+                $chengji = $data[0]['chengji'];
+                $order = 1;$num = 0;
+                foreach($data as $key=>$subval)
+                {
+                    if($key != 0){
+                        if($subval["chengji"] < $chengji){
+                            $order += 1;
+                            $chengji = $subval['chengji'];
+                            $order += $num;
+                            $num = 0;
+                        }
+                        else {
+                            $num++;
+                        }
+                    }
+                    $paiming[] = array('id'=>$subval["id"],'paiming'=>$order);
+                }
+                krsort($data);
+                $chengji = $data[count($data)-1]['chengji'];
+                $order = -5;$num = 0;
+                foreach($data as $key=>$subval)
+                {
+                    if($key != count($data)-1){
+                        if($subval["chengji"] > $chengji){
+                            $order += 1;
+                            $chengji = $subval['chengji'];
+                            $order += $num;
+                            $num = 0;
+                        }
+                        else {
+                            $num++;
+                        }
+                    }
+                    if($order == 0) break;
+                    $paiming[] = array('id'=>$subval["id"],'paiming'=>$order);
+                }
+            }
+            foreach($paiming as $val)
+            {
+                $data['paiming'] = $val['paiming'];
+                M('luojiang_achievement')->where(array("id"=>$val['id']))->save($data);
+            }
+        }
+    }
+
+	public function get_date_hui($kao_time)
+	{
+		$d = date('d',$kao_time);
+		/**
+		if($d == '15')
+		{
+			$kao_time = date('Y-m',$kao_time).'-下半月';
+		} else {
+			$kao_time = date('Y-m',$kao_time).'-上半月';
+
+		}
+		**/
+		$kao_time = date('Y-m-d',$kao_time);
+		return $kao_time;
+	}
+	public function usermanage()
+	{
+
+		//->addListItem('msgid', '消息内容', 'callback', array('callback_name'=>'get_message_content'))
+
+		$this->addCrumb('洛江考评微官网', U('addon/LuojiangKaoping/index'), '')
+			 ->addCrumb('业务导航', U('addon/LuojiangKaoping/web/eventreport'), '')
+			 ->addCrumb('用户管理', '', 'active')
+			 ->setModel('luojiang_eventreport')
+			 ->setListMap(array('mpid'=>get_mpid()))
+			 ->addListItem('fans_id', '会员名称', 'callback', array('callback_name'=>'get_fans_name'))
+			 ->addListItem('event_type', '事件类型', 'enum', array('options'=>array('0'=>'未知',1=>'事件类型1',2=>'事件类型2',3=>'事件类型3')))
+			 ->addListItem('title', '标题')
+			 ->addListItem('descript', '事件描述')
+			 ->addListItem('image_list', '图片列表', 'callback', array('callback_name'=>'get_images_str'))
+			 ->addListItem('is_reply', '是否回复', 'enum', array('options'=>array(0=>'未回复',1=>'已回复')))
+			 ->addListItem('location_addr', '位置', '', array('placeholder'=>'未提供'))
+			 ->addListItem('addtime', '创建时间', 'function', array('function_name'=>'date','params'=>'Y-m-d H:i:s,###'))
+			 ->addListItem('id', '操作', 'custom', array('options'=>array('edit_fans'=>array('编辑粉丝资料', U('Mp/Fans/edit_fans', array('openid'=>'{openid}')),'btn btn-primary btn-sm icon-edit',''))))
+		     ->common_lists();
+	}
+	function get_images_str($image_list)
+	{
+		$image_arr = explode(',', $image_list);
+		$image_str = '';
+		$image_need_arr = array();
+
+		if( !empty($image_arr) )
+		{
+			foreach($image_arr as $img)
+			{
+				$img = str_replace('./Uploads/','/Uploads/',$img);
+				$img = str_replace('//','/',$img);
+				$imgtemp = explode('.',$img);
+				//$thumb_img =  $this->resize($img,100,100);
+				$image_need_arr[] = "<div style='float:left;width:100px;margin-right:5px;'><img src='".$img."' width=100 height=100 'placeholder'= '".__ROOT__ ."/Public/Admin/img/noname.jpg' /><br/>【<a href='".$img."' target='_blank'>预览</a> | <a href='".U('addon/HuianKaoping/web/downfile', array('type' =>$imgtemp[1], 'file_url' => urlencode($img) ))."' target='_blank'>下载】</a></div>";
+			}
+			$image_str = implode(' ', $image_need_arr);
+		}
+		return "<div style='width:220px;'> ".$image_str."</div>";
+
+	}
+	//字符串截取
+function utf8_substr($string, $offset, $length = null) {
+	// generates E_NOTICE
+	// for PHP4 objects, but not PHP5 objects
+	$string = (string)$string;
+	$offset = (int)$offset;
+
+	if (!is_null($length)) {
+		$length = (int)$length;
+	}
+
+	// handle trivial cases
+	if ($length === 0) {
+		return '';
+	}
+
+	if ($offset < 0 && $length < 0 && $length < $offset) {
+		return '';
+	}
+
+	// normalise negative offsets (we could use a tail
+	// anchored pattern, but they are horribly slow!)
+	if ($offset < 0) {
+		$strlen = strlen(utf8_decode($string));
+		$offset = $strlen + $offset;
+
+		if ($offset < 0) {
+			$offset = 0;
+		}
+	}
+
+	$Op = '';
+	$Lp = '';
+
+	// establish a pattern for offset, a
+	// non-captured group equal in length to offset
+	if ($offset > 0) {
+		$Ox = (int)($offset / 65535);
+		$Oy = $offset%65535;
+
+		if ($Ox) {
+			$Op = '(?:.{65535}){' . $Ox . '}';
+		}
+
+		$Op = '^(?:' . $Op . '.{' . $Oy . '})';
+	} else {
+		$Op = '^';
+	}
+
+	// establish a pattern for length
+	if (is_null($length)) {
+		$Lp = '(.*)$';
+	} else {
+		if (!isset($strlen)) {
+			$strlen = strlen(utf8_decode($string));
+		}
+
+		// another trivial case
+		if ($offset > $strlen) {
+			return '';
+		}
+
+		if ($length > 0) {
+			$length = min($strlen - $offset, $length);
+
+			$Lx = (int)($length / 65535);
+			$Ly = $length % 65535;
+
+			// negative length requires a captured group
+			// of length characters
+			if ($Lx) {
+				$Lp = '(?:.{65535}){' . $Lx . '}';
+			}
+
+			$Lp = '(' . $Lp . '.{' . $Ly . '})';
+		} elseif ($length < 0) {
+			if ($length < ($offset - $strlen)) {
+				return '';
+			}
+
+			$Lx = (int)((-$length) / 65535);
+			$Ly = (-$length)%65535;
+
+			// negative length requires ... capture everything
+			// except a group of  -length characters
+			// anchored at the tail-end of the string
+			if ($Lx) {
+				$Lp = '(?:.{65535}){' . $Lx . '}';
+			}
+
+			$Lp = '(.*)(?:' . $Lp . '.{' . $Ly . '})$';
+		}
+	}
+
+	if (!preg_match( '#' . $Op . $Lp . '#us', $string, $match)) {
+		return '';
+	}
+
+	return $match[1];
+
+}
+/**
+ * 递归生成目录
+ */
+function RecursiveMkdir($path) {
+	if (!file_exists($path)) {
+		$this->RecursiveMkdir(dirname($path));
+		@mkdir($path, 0777);
+	}
+}
+
+
+//字符串长度计算
+function utf8_strlen($string) {
+	return strlen(utf8_decode($string));
+}
+
+function utf8_strrpos($string, $needle, $offset = null) {
+	if (is_null($offset)) {
+		$data = explode($needle, $string);
+
+		if (count($data) > 1) {
+			array_pop($data);
+
+			$string = join($needle, $data);
+
+			return $this->utf8_strlen($string);
+		}
+
+		return false;
+	} else {
+		if (!is_int($offset)) {
+			trigger_error('utf8_strrpos expects parameter 3 to be long', E_USER_WARNING);
+
+			return false;
+		}
+
+		$string = $this->utf8_substr($string, $offset);
+
+		if (false !== ($position = utf8_strrpos($string, $needle))) {
+			return $position + $offset;
+		}
+
+		return false;
+	}
+}
+
+	/**
+ * 自动生成新尺寸 的图片
+ */
+	function resize($filename, $width, $height) {
+			define(ROOT_PATH,'/data/web/wx.mnw.cn/');
+			///data/web/wx.mnw.cn/Addons/HuianKaoping/Controller
+
+		$image_dir=ROOT_PATH;
+
+
+		if (!is_file($image_dir . $filename)) {
+			return;
+		}
+
+		$extension = pathinfo($filename, PATHINFO_EXTENSION);
+
+		$old_image = $filename;
+		$new_image = 'cache/' . $this->utf8_substr($filename, 0, utf8_strrpos($filename, '.')) . '-' . $width . 'x' . $height . '.' . $extension;
+
+		if (!is_file($image_dir . $new_image) || (filectime($image_dir . $old_image) > filectime($image_dir . $new_image))) {
+			$path = '';
+
+			$directories = explode('/', dirname(str_replace('../', '', $new_image)));
+
+			foreach ($directories as $directory) {
+				$path = $path . '/' . $directory;
+
+				if (!is_dir($image_dir . $path)) {
+					@mkdir($image_dir . $path, 0777);
+				}
+			}
+
+			list($width_orig, $height_orig) = getimagesize($image_dir . $old_image);
+
+			if ($width_orig != $width || $height_orig != $height) {
+				$image = new \Lib\Image($image_dir . $old_image);
+			$image->resize($width, $height);
+				$image->save($image_dir . $new_image);
+			} else {
+				copy($image_dir . $old_image, $image_dir . $new_image);
+			}
+		}
+
+		return 'Uploads/image/' . $new_image;
+
+		}
+
+	public function get_fans_name($fans_id)
+	{
+		$fans_info = M('mp_fans')->where( array('id' => $fans_id) )->find();
+		return $fans_info['nickname'];
+		//return '<a href="'.U('Mp/Fans/edit_fans', array('openid'=>$fans_info['openid'])).'" target="_blank" title="点击查看用户信息">'.$fans_info['nickname'].'</a>';
+	}
+
+}
+
+?>

+ 0 - 230
Modules/Lib/Weixin/Wxfy.class.php

@@ -1,230 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-
-class Wxfy
-{
-    // private $xml    = null;
-    // public function __construct() {
-    //     $this->xml = new \XmlWriter();
-    // }
-    //订单查询
-    public function queryOrder(array $option = [])
-    {
-        // $xml = new \app\paychannel\model\Fy();
-        $data['ins_cd']   = $option['ins_cd'];  //机构号,接入机构在富友的唯一代码
-        $data['mchnt_cd'] = $option['mchnt_cd'];  //商户号, 富友分配给二级商户的商户号
-        $data['version']  = isset($option['version']) ? $option['version'] : '1';
-        $data['term_id']  = isset($option['term_id']) ? $option['term_id'] : '88888888';  //终端号(没有真实终端号统一填88888888)
-
-        $data['order_type'] = $option['order_type'];  //订单类型:ALIPAY (统一下单、条码支付、服务 窗支付), WECHAT(统一下单、条码支付,公众号 支付),UNIONPAY,BESTPAY(翼支付)
-        $prefix = isset($option['prefix']) && !empty($option['prefix']) ? $option['prefix'] : '1450';
-        $data['mchnt_order_no'] = $prefix . $option['mchnt_order_no'];  //商户订单号, 商户系统内部的订单号(5 到 30 个字符、 只能包含字母数字,区分大小写)
-        $data['random_str'] = strval(time());  //随机字符串,不长于32 位
-
-        //拼装过的需要签名的字符串串
-        ksort($data);
-        $sign = http_build_query($data);
-
-        $file = '/' . $data['ins_cd'] . '.pem';
-
-        $data['sign'] = $this->sign($sign, $file);
-
-        //完整的xml格式
-        $a = "<?xml version=\"1.0\" encoding=\"GBK\" standalone=\"yes\"?><xml>" . $this->toXml($data) . "</xml>";
-
-        //经过两次urlencode()之后的字符串
-        $b = "req=" . urlencode(urlencode($a));
-        //通过curl的post方式发送接口请求
-        $url = "https://spay-mc.fuioupay.com/commonQuery";
-
-        //返回的xml字符串
-        // $resultXml = URLdecode($this->SendDataByCurl($url, $b));
-
-        // $ob = simplexml_load_string($resultXml);
-        // // var_dump($ob);
-        // return json_encode($ob);
-        return $this->SendDataByCurl($url, $b);
-    }
-
-  
-
-    //微信订单创建
-    public function createOrder(array $option = [])
-    {
-        $data['ins_cd'] = "08M0027018"; //机构号,接入机构在富友的唯一代码
-		$data['mchnt_cd'] = '0001000F6549249'; //商户号, 富友分配给二级商户的商户号 0005210F3948471
-
-        $data['version'] = '1';
-        $data['term_id'] = '88888888';  //终端号(没有真实终端号统一填88888888)
-        $data['trade_type'] = "LETPAY"; //订单类型:ALIPAY (统一下单、条码支付、服务 窗支付), WECHAT(统一下单、条码支付,公众号 支付),UNIONPAY,BESTPAY(翼支付)
-       
-        $data['mchnt_order_no'] =  $option['mchnt_order_no'];  //商户订单号, 商户系统内部的订单号(5 到 30 个字符、 只能包含字母数字,区分大小写)
-        $data['random_str'] = $option['random_str'];  //随机字符串,不长于32 位
-        $data['goods_des'] = urldecode($option['goods_des']);
-        $data['term_ip']   = isset($option['term_ip']) ? $option['term_ip'] : '117.29.110.187';
-        $data['order_amt'] = strval($option['order_amt']);
-        $data['notify_url'] = stripslashes($option['notify_url']);
-        $data['txn_begin_ts'] = date('YmdHis');
-        $data['sub_openid'] = $option['sub_openid'];
-        $data['sub_appid'] = $option['sub_appid'];
-        $data['addn_inf'] = '';
-        $data['curr_type'] = 'CNY';
-        // $data['goods_des'] = '';
-        $data['goods_detail'] = '';
-        $data['goods_tag'] = '';
-        $data['limit_pay'] = '';
-        $data['openid'] = '';
-        $data['product_id'] = '';
-        $data=array_filter($data);
-        //拼装过的需要签名的字符串串
-        // ksort($data);
-        // $sign = http_build_query($data); //验签错误
-       // $sign = "addn_inf=&curr_type=CNY&goods_des=" . $data['goods_des'] . "&goods_detail=&goods_tag=&ins_cd=" . $data['ins_cd'] . "&limit_pay=&mchnt_cd=" . $data['mchnt_cd'] . "&mchnt_order_no=" . $data['mchnt_order_no'] . "&notify_url=" . $data['notify_url'] . "&order_amt=" . $data['order_amt'] . "&product_id=&random_str=" . $data['random_str'] . "&sub_appid=" . $data['sub_appid'] . "&sub_openid=" . $data['sub_openid'] . "&term_id=" . $data['term_id'] . "&term_ip=" . $data['term_ip'] . "&trade_type=" . $data['trade_type'] . "&txn_begin_ts=" . $data['txn_begin_ts'] . "&version=1";
-        $sign = "addn_inf=&curr_type=CNY&goods_des=" . $data['goods_des'] . "&goods_detail=&goods_tag=&ins_cd=" . $data['ins_cd'] . "&limit_pay=&mchnt_cd=" . $data['mchnt_cd'] . "&mchnt_order_no=" . $data['mchnt_order_no'] . "&notify_url=" . $data['notify_url'] . "&openid=&order_amt=" . $data['order_amt'] . "&product_id=&random_str=" . $data['random_str'] . "&sub_appid=" . $data['sub_appid'] . "&sub_openid=" . $data['sub_openid'] . "&term_id=" . $data['term_id'] . "&term_ip=" . $data['term_ip'] . "&trade_type=" . $data['trade_type'] . "&txn_begin_ts=" . $data['txn_begin_ts'] . "&version=1";
-        $file = $option['filepath']. $data['ins_cd'] . '.pem';
-
-        $data['sign'] = $this->sign($sign, $file);
-        //完整的xml格式
-        $a = "<?xml version=\"1.0\" encoding=\"GBK\" standalone=\"yes\"?><xml>" . $this->toXml($data) . "</xml>";
-
-        //经过两次urlencode()之后的字符串
-        $b = "req=" . urlencode(urlencode($a));
-        //通过curl的post方式发送接口请求
-        $url = "https://spay-mc.fuioupay.com/wxPreCreate";
-
-        //返回的xml字符串
-        // $resultXml = URLdecode($this->SendDataByCurl($url, $b));
-        // $ob = simplexml_load_string($resultXml);
-        // return json_encode($ob);
-        
-        if ($option['debug'] == true) {
-            var_dump($data);
-            var_dump("==========");
-            var_dump($a);
-            // die(var_dump($data));
-        }
-        return $a;
-        return $this->SendDataByCurl($url, $b);
-    }
-    
-
-    //订单退款normal
-    public function refundOrder(array $option = [])
-    {
-        $data['ins_cd'] = $option['ins_cd'];  //机构号,接入机构在富友的唯一代码
-        $data['mchnt_cd'] = $option['mchnt_cd'];  //商户号, 富友分配给二级商户的商户号
-
-        $data['version'] = isset($option['version']) ? $option['version'] : '1';
-        $data['term_id'] = isset($option['term_id']) ? $option['term_id'] : '117.29.110.187';  //终端号(没有真实终端号统一填88888888)
-        $prefix = isset($option['prefix']) && !empty($option['prefix']) ? $option['prefix'] : 1450;
-        $data['mchnt_order_no'] = $prefix . $option['mchnt_order_no'];  //商户原交易订单号, 商户系统内部的订单号(5 到30 个字符、只能包含字母数字,区分大小写)
-        $data['random_str'] = time();  //随机字符串,不长于32 位
-        $data['order_type'] = $option['order_type'];  //订单类型:ALIPAY (统一下单、条码支付、服务 窗支付), WECHAT(统一下单、条码支付,公众号 支付),UNIONPAY,BESTPAY(翼支付)
-        $data['refund_order_no'] = $prefix . $option['refund_order_no'];  //商户退款单号(5 到30 个字符、 只能包含字母 数字或者下划线,区分大小写)
-        $data['total_amt'] = $option['total_amt'];  //总金额
-        $data['refund_amt'] = $option['refund_amt'];  //退款金额
-        $data['operator_id'] = '';  //操作员
-
-        if ($option['debug'] == true) {
-            // die(var_dump($data));
-        }
-
-        //拼装过的需要签名的字符串串
-        ksort($data);
-        $sign =urldecode(http_build_query($data));
-
-        $lib_path = dirname(dirname( dirname(__FILE__) )).'/Lib/';
-
-        $file = $lib_path."Weixin/cert/". $data['ins_cd'] . '.pem';
-//        return $file;
-        $data['sign'] = $this->sign($sign, $file);
-
-        //完整的xml格式
-        $a = "<?xml version=\"1.0\" encoding=\"GBK\" standalone=\"yes\"?><xml>" . $this->toXml($data) . "</xml>";
-
-        //经过两次urlencode()之后的字符串
-        $b = "req=" . urlencode(urlencode($a));
-        //通过curl的post方式发送接口请求
-        $url = "https://spay-mc.fuioupay.com/commonRefund";
-        //返回的xml字符串
-        // $resultXml = URLdecode();
-        // $ob = simplexml_load_string($resultXml);
-        // var_dump($ob);
-        return $this->SendDataByCurl($url, $b);
-    }
-
-    public function change_utf8($str) {
-        return mb_convert_encoding($str, 'utf-8', 'gbk'); 
-    } 
-    function change_gbk($str) {
-        return mb_convert_encoding($str, 'gbk', 'utf-8'); 
-    }
-
-
-
-
-
-    //数组转xml
-    public function toXml($data, $eIsArray = FALSE)
-    {
-        $xml = new XMLWriter();
-        if (!$eIsArray) {
-            $xml->openMemory();
-        }
-        foreach ($data as $key => $value) {
-            if (is_array($value)) {
-                $xml->startElement($key);
-                $this->toXml($value, TRUE);
-                $xml->endElement();
-                continue;
-            }
-//            dump($key);
-//             dump($value);
-            $xml->writeElement($key,(string)$value);
-        }
-        if (!$eIsArray) {
-            $xml->endElement();
-            return $xml->outputMemory(true);
-        }
-    }
-
-    //签名加密流程
-    public function sign($data, $file = '/keypem.pem')
-    {
-        //读取密钥文件
-        $pem = file_get_contents($file);
-//        dump($file);
-//        if(is_file($file))dump('文件存在');
-        //获取私钥
-        $pkeyid = openssl_pkey_get_private($pem);
-        //MD5WithRSA私钥加密
-        openssl_sign($data, $sign, $pkeyid, OPENSSL_ALGO_MD5);
-        //返回base64加密之后的数据
-        $t = base64_encode($sign);
-        return $t;
-    }
-
-    public function SendDataByCurl($url, $data)
-    {
-        $url = str_replace(' ', '+', $url);
-        $ch = curl_init();
-        curl_setopt($ch, CURLOPT_URL, "$url");
-        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
-        curl_setopt($ch, CURLOPT_HEADER, 0);
-        curl_setopt($ch, CURLOPT_TIMEOUT, 3); //定义超时3秒钟
-        curl_setopt($ch, CURLOPT_POST, 1);
-        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);  //所需传的数组用http_bulid_query()函数处理一下,就ok了
-        $output = curl_exec($ch);
-        $errorCode = curl_errno($ch);
-        curl_close($ch);
-        if (0 !== $errorCode) {
-            return false;
-        }
-        $resultXml = URLdecode($output);
-        $ob = simplexml_load_string($resultXml);
-        $response = json_encode($ob);
-        return $response;
-    }
-}

+ 0 - 7
Modules/Lib/Weixin/cert/08M0027018.pem

@@ -1,7 +0,0 @@
------BEGIN RSA PRIVATE KEY-----
-MIICWwIBAAKBgQChofUYJMFrmd4voorNv12P/snleA/VXK94HhpYe9ZFmwObZEfH89kfLfs+HyEahfBPrK9k60wakB2ug+HJjTOz/MKqTw6JfYF3j25TR/HqoFCPjYoYPLdveQvS3pUNlVGrNjnG2qyoPWnQIdBORMzJPofV9rhoBOMCIc+nJKjG7wIDAQABAoGAfTuZRT2lR5OOXWYZGdU9zwXgtJTT38LSicT5MLmyiXfT0aBfJYPAJLJhyf4gjgZc7b6knxLYgnRLKx4v4RQwi/WUj1U9zxHxihL4Y1FDD8kkei2onObrqIcDIRkAg2qgAl+QW7W+JDdvgjzmbF0hIBO7JddJiq++E2yRJOpz51ECQQDftlZSnn0aSTALVyzASzMMvZyxHiBAzoq7UPxAxdlfE/HZtHFV6HONKdE/Nr0PgVngufNW7a/vK/zTi6D8n1oDAkEAuPXrNqlwmtXOwhQ8K4UdajEOIpifupvUxB/PXbP1ENNaMv6yr57RXzvNfvxLbN2AvtFV+QU4raSxn26OpLNBpQJABe+lrL2N3kOw5awjgNq9+QmS/dQp0O5qGfxVJTbaxL4Xvcoe88OeRVGlvsKqE55AD0l/3n+iGnuVUtuyouFrlwJAbXf/EocOQlWw3WUkh41tb2BBQXCbeNKqBrnc/VR5AtBUXkIod5DD0l2Ork2cRn6CqG01OQFCHmOPTREeE5SUkQJAZuKA9Pq0y/1NwAfzq3EG+vPBSgtAzg2FssmugDwYoZ/BycZZyTBeW+4qtypiHLXv1xZck+I8F4Qn6QtWZfRfgA==
------END RSA PRIVATE KEY-----
-
------BEGIN PUBLIC KEY-----
-MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQChofUYJMFrmd4voorNv12P/snleA/VXK94HhpYe9ZFmwObZEfH89kfLfs+HyEahfBPrK9k60wakB2ug+HJjTOz/MKqTw6JfYF3j25TR/HqoFCPjYoYPLdveQvS3pUNlVGrNjnG2qyoPWnQIdBORMzJPofV9rhoBOMCIc+nJKjG7wIDAQAB
------END PUBLIC KEY-----

+ 0 - 121
Modules/Lib/Weixin/lib/WxFy.Api.php

@@ -1,121 +0,0 @@
-<?php
-require_once "WxPay.Exception.php";
-require_once "WxPay.Config.php";
-require_once "WxPay.Data.php";
-
-/**
- * 
- * 接口访问类,包含所有微信支付API列表的封装,类中方法为static方法,
- * 每个接口有默认超时时间(除提交被扫支付为10s,上报超时时间为1s外,其他均为6s)
- * @author widyhu
- *
- */
-class WxFyApi
-{
-	 	/**
- 	 * 
- 	 * 支付结果通用通知
- 	 * @param function $callback
- 	 * 直接回调函数使用方法: notify(you_function);
- 	 * 回调类成员函数方法:notify(array($this, you_function));
- 	 * $callback  原型为:function function_name($data){}
- 	 */
-	  public static function notify($callback, &$msg,$tyep=false)
-	  {
-		
- //$str='%3C%3Fxml+version%3D%221.0%22+encoding%3D%22GBK%22+standalone%3D%22yes%22%3F%3E%3Cxml%3E%3Ccurr_type%3ECNY%3C%2Fcurr_type%3E%3Cins_cd%3E08M0027018%3C%2Fins_cd%3E%3Cmchnt_cd%3E0005210F3948471%3C%2Fmchnt_cd%3E%3Cmchnt_order_no%3E145031-1698212929%3C%2Fmchnt_order_no%3E%3Corder_amt%3E1%3C%2Forder_amt%3E%3Corder_type%3ELETPAY%3C%2Forder_type%3E%3Crandom_str%3E7CVW0XBUG1I0GNY080V1SWN4XNN22P59%3C%2Frandom_str%3E%3Creserved_addn_inf%3E%3C%2Freserved_addn_inf%3E%3Creserved_bank_type%3EOTHERS%3C%2Freserved_bank_type%3E%3Creserved_buyer_logon_id%3E%3C%2Freserved_buyer_logon_id%3E%3Creserved_channel_order_id%3E145031-1698212929%3C%2Freserved_channel_order_id%3E%3Creserved_coupon_fee%3E0%3C%2Freserved_coupon_fee%3E%3Creserved_discount_goods_detail%3E%3C%2Freserved_discount_goods_detail%3E%3Creserved_fund_bill_list%3E%3C%2Freserved_fund_bill_list%3E%3Creserved_fy_settle_dt%3E20231025%3C%2Freserved_fy_settle_dt%3E%3Creserved_fy_trace_no%3E221197153413%3C%2Freserved_fy_trace_no%3E%3Creserved_is_credit%3E0%3C%2Freserved_is_credit%3E%3Creserved_risk_info%3E%3C%2Freserved_risk_info%3E%3Creserved_settlement_amt%3E1%3C%2Freserved_settlement_amt%3E%3Creserved_sub_mchnt_cd%3E441545829%3C%2Freserved_sub_mchnt_cd%3E%3Creserved_voucher_detail_list%3E%3C%2Freserved_voucher_detail_list%3E%3Cresult_code%3E000000%3C%2Fresult_code%3E%3Cresult_msg%3ESUCCESS%3C%2Fresult_msg%3E%3Csettle_order_amt%3E1%3C%2Fsettle_order_amt%3E%3Csign%3EhvnVjOwW7pWRT2EiOEacLWPS5rSq403L1tKX2XvP2KegVfLfdxufZutyOdN4uGsSgz3lG2PsABUIBwAYMIvIrL%2F1vhgU8V2xNpawcbRK090ioeOINKyBt7iG%2F9ij47vnXu%2FzI6MCaOIT2eGFFhtxaph3UOcQjqOxfYevoxxSuGE%3D%3C%2Fsign%3E%3Cterm_id%3E%3C%2Fterm_id%3E%3Ctransaction_id%3E4200001979202310254797810088%3C%2Ftransaction_id%3E%3Ctxn_fin_ts%3E20231025134904%3C%2Ftxn_fin_ts%3E%3Cuser_id%3Eo9H0g5RCAz9wJgLL0UgoQzPkndUw%3C%2Fuser_id%3E%3C%2Fxml%3E';
-// $res=substr($str,4);
-// echo urldecode(urldecode($str));
-
-		$data_path = dirname( dirname(dirname( dirname(__FILE__) )) ).'/Data/wxpaylogs/fy'.date('Y-m-d')."/";
-		RecursiveMkdir($data_path);
-		//初始化日志
-		$logHandler= new \CLogFileHandler( $data_path.date('Y-m-d').'.log');
-		 \Log::Init($logHandler, 15);
-		  //获取通知的数据		
-		  if( !isset($GLOBALS['HTTP_RAW_POST_DATA']) )
-		  {
-			 $strreq = file_get_contents('php://input');
-		  }else{
-			  $xml = $GLOBALS['HTTP_RAW_POST_DATA'];
-		  }
-		  $str=substr($strreq,4);
-		  $xml = urldecode(urldecode($str));
-		  \Log::INFO("回调数据 xml:".urldecode(urldecode($xml)) );
-
-
-		  //如果返回成功则验证签名
-		  try {
-			  $result = WxPayResults::Init($xml);
-	
-		  } catch (WxPayException $e){
-			  $msg = $e->errorMessage();
-		  
-			  return false;
-		  }
-		  if($tyep){
-			$result['type']=true;//表示富友支付
-		  }
-		  
-			  
-		  return call_user_func($callback, $result);
-	  }
-	
-
-	   // private $xml    = null;
-    // public function __construct() {
-    //     $this->xml = new \XmlWriter();
-    // }
-    //订单查询
-    public function queryOrder(array $option = [])
-    {
-        // $xml = new \app\paychannel\model\Fy();
-        $data['ins_cd']   = $option['ins_cd'];  //机构号,接入机构在富友的唯一代码
-        $data['mchnt_cd'] = $option['mchnt_cd'];  //商户号, 富友分配给二级商户的商户号
-        $data['version']  = isset($option['version']) ? $option['version'] : '1';
-        $data['term_id']  = isset($option['term_id']) ? $option['term_id'] : '88888888';  //终端号(没有真实终端号统一填88888888)
-
-        $data['order_type'] = $option['order_type'];  //订单类型:ALIPAY (统一下单、条码支付、服务 窗支付), WECHAT(统一下单、条码支付,公众号 支付),UNIONPAY,BESTPAY(翼支付)
-        $prefix = isset($option['prefix']) && !empty($option['prefix']) ? $option['prefix'] : '1450';
-        $data['mchnt_order_no'] = $prefix . $option['mchnt_order_no'];  //商户订单号, 商户系统内部的订单号(5 到 30 个字符、 只能包含字母数字,区分大小写)
-        $data['random_str'] = strval(time());  //随机字符串,不长于32 位
-
-        //拼装过的需要签名的字符串串
-        ksort($data);
-        $sign = http_build_query($data);
-
-        $file = '/' . $data['ins_cd'] . '.pem';
-
-        $data['sign'] = $this->sign($sign, $file);
-
-        //完整的xml格式
-        $a = "<?xml version=\"1.0\" encoding=\"GBK\" standalone=\"yes\"?><xml>" . $this->toXml($data) . "</xml>";
-
-        //经过两次urlencode()之后的字符串
-        $b = "req=" . urlencode(urlencode($a));
-        //通过curl的post方式发送接口请求
-        $url = "https://spay-mc.fuioupay.com/commonQuery";
-
-        //返回的xml字符串
-        // $resultXml = URLdecode($this->SendDataByCurl($url, $b));
-
-        // $ob = simplexml_load_string($resultXml);
-        // // var_dump($ob);
-        // return json_encode($ob);
-        return $this->SendDataByCurl($url, $b);
-    }
-	
-	/**
-	 * 获取毫秒级别的时间戳
-	 */
-	private static function getMillisecond()
-	{
-		//获取毫秒的时间戳
-		$time = explode ( " ", microtime () );
-		$time = $time[1] . ($time[0] * 1000);
-		$time2 = explode( ".", $time );
-		$time = $time2[0];
-		return $time;
-	}
-}
-

+ 9 - 29
Modules/Lib/Weixin/lib/WxPay.Notify.php

@@ -12,20 +12,13 @@ class WxPayNotify extends WxPayNotifyReply
 	 * 回调入口
 	 * @param bool $needSign  是否需要签名输出
 	 */
-	final public function Handle($needSign = true,$type=false)
+	final public function Handle($needSign = true)
 	{
-		require_once "WxFy.Api.php";
-		$msg = "1";
+		$msg = "OK";
 		//当返回false的时候,表示notify中调用NotifyCallBack回调失败获取签名校验失败,此时直接回复失败
-		if($type){
-			$result = WxfyApi::notify(array($this, 'NotifyCallBack'), $msg,$type);
-		}else{
-			$result = WxpayApi::notify(array($this, 'NotifyCallBack'), $msg);
-		}
-		
-
+		$result = WxpayApi::notify(array($this, 'NotifyCallBack'), $msg);
 		if($result == false){
-			$this->SetReturn_code("FAILI");
+			$this->SetReturn_code("FAIL");
 			$this->SetReturn_msg($msg);
 			$this->ReplyNotify(false);
 			return;
@@ -61,28 +54,14 @@ class WxPayNotify extends WxPayNotifyReply
 	 */
 	final public function NotifyCallBack($data)
 	{
-		
-		if($data['type']){//富友支付回调的
-			$data['out_trade_no']=substr($data['mchnt_order_no'],4);
-			$data['total_fee']=$data['order_amt'];
-			$msg = "OK";
-			if(!$data['result_code']=='000000'&& !$data['result_msg']=='SUCCESS'){
-				$this->SetReturn_code("FAILL");
-				$this->SetReturn_msg($msg);
-				return false;
-			}
-			
-
-		}
-		
-
+		$msg = "OK";
 		$result = $this->NotifyProcess($data, $msg);
-
+		
 		if($result == true){
 			$this->SetReturn_code("SUCCESS");
 			$this->SetReturn_msg("OK");
 		} else {
-			$this->SetReturn_code("FAILS");
+			$this->SetReturn_code("FAIL");
 			$this->SetReturn_msg($msg);
 		}
 		return $result;
@@ -96,7 +75,8 @@ class WxPayNotify extends WxPayNotifyReply
 	final private function ReplyNotify($needSign = true)
 	{
 		//如果需要签名
-		if($needSign == true && $this->GetReturn_code($return_code) == "SUCCESS")
+		if($needSign == true && 
+			$this->GetReturn_code($return_code) == "SUCCESS")
 		{
 			$this->SetSign();
 		}

部分文件因为文件数量过多而无法显示