<?php
defined("IN_IA") or exit("Access Denied");
class yzxc_sunModuleWxapp extends WeModuleWxapp
{
public function doPageUrl()
{
global $_W;
$url = $_W["attachurl"];
$this->return_msg(1, $url, "success");
}
function return_msg($code = 1, $data = array(), $msg = "success")
{
$res["code"] = $code;
$res["data"] = $data;
$res["msg"] = $msg;
exit(json_encode($res));
}
public function wxPay($options = array())
{
$data["appid"] = $options["appid"];
$data["mch_id"] = $options["mch_id"];
$data["openid"] = $options["openid"];
$data["nonce_str"] = $this->randstr();
$data["body"] = $options["body"];
$data["attach"] = $options["attach"];
$data["out_trade_no"] = $options["out_trade_no"];
$data["notify_url"] = $options["notify_url"];
$data["total_fee"] = $options["total_fee"] * 100;
$data["spbill_create_ip"] = $_SERVER["REMOTE_ADDR"];
$data["trade_type"] = "JSAPI";
$data["time_start"] = $options["time_start"];
$data["time_expire"] = $options["time_expire"];
ksort($data, SORT_STRING);
$string = '';
foreach ($data as $key => $v) {
if (!empty($v)) {
$string .= "{$key}={$v}&";
}
}
$string .= "key=" . $options["pay_key"] . '';
$data["sign"] = strtoupper(md5($string));
$xmlData = array2xml($data);
$response = $this->https_request("https://api.mch.weixin.qq.com/pay/unifiedorder", $xmlData);
$result = json_decode(json_encode(simplexml_load_string($response, "SimpleXMLElement", LIBXML_NOCDATA)), true);
if ($result["return_code"] == "SUCCESS") {
$payData["appId"] = $data["appid"];
$payData["timeStamp"] = (string) time();
$payData["nonceStr"] = $this->randstr();
$payData["package"] = "prepay_id=" . $result["prepay_id"];
$payData["signType"] = "MD5";
$payString = '';
ksort($payData, SORT_STRING);
foreach ($payData as $key => $v) {
$payString .= "{$key}={$v}&";
}
$payString .= "key=" . $options["pay_key"] . '';
$payData["paySign"] = strtoupper(md5($payString));
$payData["return_code"] = $result["return_code"];
} else {
$payData["return_code"] = $result["return_code"];
$payData["return_msg"] = $result["return_msg"];
}
return $payData;
}
public function testpay()
{
$appid = '';
$mch_id = '';
$options = array("body" => "测试", "appid" => $appid, "mch_id" => $mch_id, "out_trade_no" => time(), "attach" => json_encode(array("a" => 1)), "notify_url" => "http://" . $_SERVER["HTTP_HOST"] . "/ticket/Appletpay/notify", "total_fee" => 0.01, "spbill_create_ip" => $_SERVER["REMOTE_ADDR"], "openid" => "oLWoc0X0guzZ89lxWdL57Z7mz4r4");
$data = $this->wxPay($options);
return common_json("success", 0, $data);
}
public function notify()
{
$json = $_POST;
$xml = file_get_contents("php://input");
$data = json_decode(json_encode(simplexml_load_string($xml, "SimpleXMLElement", LIBXML_NOCDATA)), true);
$arraySign = $data["sign"];
unset($data["sign"]);
ksort($data, SORT_STRING);
$string = '';
foreach ($data as $key => $v) {
$string .= "{$key}={$v}&";
}
$arr = json_decode($data["attach"], true);
$pay_key = '';
$string .= "key=" . $pay_key;
$sign = strtoupper(md5($string));
if ($arraySign == $sign) {
exit("SUCCESS");
} else {
exit("FAIL");
}
}
function randstr($length = 20)
{
$chars = "abcdefghijklmnopqrstuvwxyz0123456789";
$str = '';
$i = 0;
while ($i < $length) {
$str .= substr($chars, mt_rand(0, strlen($chars) - 1), 1);
$i++;
}
return $str;
}
function https_request($url, $data = null)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
if (!empty($data)) {
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
}
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt($curl, CURLOPT_SSLVERSION, 4);
$output = curl_exec($curl);
curl_close($curl);
return $output;
}
public function doPageOpenid()
{
global $_W, $_GPC;
$res = pdo_get("yzxc_sun_system", array("uniacid" => $_W["uniacid"]));
$code = $_GPC["code"];
$appid = $res["appid"];
$secret = $res["appsecret"];
$url = "https://api.weixin.qq.com/sns/jscode2session?appid=" . $appid . "&secret=" . $secret . "&js_code=" . $code . "&grant_type=authorization_code";
function httpRequest($url, $data = null)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
if (!empty($data)) {
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
}
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($curl);
curl_close($curl);
return $output;
}
$re = httpRequest($url);
$this->return_msg(1, $re, "success");
}
public function doPageLogin()
{
global $_GPC, $_W;
$openid = $_GPC["openid"];
$res = pdo_get("yzxc_sun_user", array("openid" => $openid, "uniacid" => $_W["uniacid"]));
if ($openid and $openid != "undefined") {
if ($res) {
$this->return_msg(1, $res);
} else {
$data["openid"] = $_GPC["openid"];
$data["headurl"] = $_GPC["headurl"];
$data["username"] = $_GPC["username"];
$data["uniacid"] = $_W["uniacid"];
$data["time"] = time();
pdo_insert("yzxc_sun_user", $data);
$user = pdo_get("yzxc_sun_user", array("openid" => $openid, "uniacid" => $_W["uniacid"]));
$this->return_msg(1, $user);
}
}
}
public function doPageUploadPic()
{
global $_W, $_GPC;
if (!is_uploaded_file($_FILES["file"]["tmp_name"])) {
$this->return_msg(-1, array(), "图片不存在");
} else {
$file = $_FILES["file"];
require_once IA_ROOT . "/addons/yzxc_sun/class/UploadFile.class.php";
$upload = new UploadFile();
$upload->maxSize = 30292200;
$upload->allowExts = explode(",", "png,gif,jpeg,pjpeg,bmp,x-png,jpg");
$upload->savePath = IA_ROOT . "/attachment/";
$upload->saveRule = uniqid;
$uploadList = $upload->uploadOne($file);
if (!$uploadList) {
$this->return_msg(-1, array(), $upload->getErrorMsg());
}
$newimg = $uploadList["0"]["savename"];
@(require_once IA_ROOT . "/framework/function/file.func.php");
@($filename = $newimg);
@file_remote_upload($filename);
$this->return_msg(1, $newimg);
}
}
public function doPageqrcode($code = '')
{
require_once IA_ROOT . "/framework/library/qrcode/phpqrcode.php";
$errorCorrectionLevel = "L";
$matrixPointSize = 5;
$newpath = IA_ROOT . "/attachment/qrcode/";
if (!file_exists($newpath)) {
mkdir($newpath);
没有合适的资源?快使用搜索试试~ 我知道了~
柚子洗车小程序 yzxc_sun 1.0.7安装更新一体包.rar
共814个文件
js:157个
png:144个
wxss:98个
需积分: 5 0 下载量 170 浏览量
2023-06-09
10:43:36
上传
评论
收藏 4.19MB RAR 举报
温馨提示
本资料仅供学习参考
资源推荐
资源详情
资源评论
收起资源包目录
柚子洗车小程序 yzxc_sun 1.0.7安装更新一体包.rar (814个子文件)
module.cer 50B
layui.css 52KB
layer.css 14KB
layui.mobile.css 10KB
laydate.css 7KB
ygcss.css 5KB
ygcsslist.css 4KB
code.css 1KB
iconfont.eot 38KB
ZipViewer.exe 44KB
59.gif 10KB
22.gif 10KB
24.gif 8KB
13.gif 7KB
16.gif 7KB
39.gif 6KB
64.gif 6KB
stick.gif 6KB
63.gif 6KB
50.gif 6KB
loading-0.gif 6KB
4.gif 6KB
1.gif 5KB
42.gif 5KB
71.gif 5KB
21.gif 5KB
20.gif 5KB
29.gif 5KB
70.gif 4KB
5.gif 4KB
17.gif 4KB
27.gif 4KB
9.gif 4KB
44.gif 4KB
11.gif 4KB
8.gif 4KB
3.gif 4KB
23.gif 4KB
34.gif 4KB
41.gif 4KB
38.gif 4KB
65.gif 3KB
32.gif 3KB
45.gif 3KB
7.gif 3KB
12.gif 3KB
26.gif 3KB
60.gif 3KB
2.gif 3KB
40.gif 3KB
25.gif 3KB
19.gif 3KB
66.gif 3KB
18.gif 3KB
46.gif 3KB
10.gif 3KB
28.gif 3KB
51.gif 3KB
57.gif 3KB
67.gif 3KB
0.gif 3KB
48.gif 3KB
43.gif 3KB
30.gif 2KB
61.gif 2KB
33.gif 2KB
69.gif 2KB
14.gif 2KB
47.gif 2KB
36.gif 2KB
49.gif 2KB
58.gif 2KB
6.gif 2KB
54.gif 2KB
53.gif 2KB
56.gif 2KB
62.gif 2KB
31.gif 2KB
55.gif 2KB
35.gif 2KB
15.gif 2KB
loading-2.gif 2KB
37.gif 1KB
68.gif 1KB
52.gif 777B
loading-1.gif 701B
addshop.html 16KB
txlog.html 14KB
header.html 13KB
shoplist.html 12KB
couponlist.html 11KB
maintain.html 11KB
header.html 11KB
order.html 10KB
index.html 8KB
shopadminlist.html 8KB
login.html 8KB
noticelist.html 8KB
footnav.html 8KB
adpic_list.html 8KB
共 814 条
- 1
- 2
- 3
- 4
- 5
- 6
- 9
资源评论
2301_78600126
- 粉丝: 1
- 资源: 686
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功