上线金柚产品

This commit is contained in:
“wanyongkang”
2024-02-01 17:13:32 +08:00
parent 058b999606
commit 323ae40042
15 changed files with 1407 additions and 3 deletions

View File

@@ -6,6 +6,9 @@ use extend\alipay\Alipay as AlipaySdk;
use app\ros\model\Order as OrderModel; use app\ros\model\Order as OrderModel;
use app\http\model\User as UserModel; use app\http\model\User as UserModel;
use app\http\model\Recharge as RechargeModel; use app\http\model\Recharge as RechargeModel;
use app\jinyou\model\ProductOrder as ProductOrderModel;
use app\jinyou\model\Account as AccountModel;
use app\jinyou\model\Package as PackageModel;
class Alipay { class Alipay {
@@ -106,4 +109,58 @@ class Alipay {
echo 'success'; echo 'success';
} }
public function jinyoualipayverify() {
$ali = new AlipaySdk();
$flag = $ali->payVerify2($_POST);
if($flag){
$status = $_POST['trade_status'];
$flag = false;
if ($status == 'TRADE_SUCCESS') {
$flag = true;
}
if ($flag) {
$order_model = new ProductOrderModel();
$order_no=$_POST['out_trade_no'];
$alipay_no = $_POST['trade_no'];
//获取充值信息
$order_info = $order_model->getOne(['OrderNo'=>$order_no]);
if (!empty($order_info['TradeNo'])) {
die;
}
$update_data = [];
//更新充值订单
$update_data['TradeNo'] = $alipay_no;
$update_data['OrderState'] = 90;
if($order_model->updateOne(['OrderNo'=>$order_no],$update_data)) {
$account_info = json_decode($order_info['remark2']);
$user_model = new UserModel();
$user_info = $user_model->getOne(['Id' => $order_info['UserId']]);
$package_model = new PackageModel;//套餐详情
$package_info = $package_model->getOne(['Id' => $account_info['package_id']]);
$account_model = new AccountModel;
$account_model->open_account($account_info,$user_info,$package_info);
}
}
}
echo 'success';
}
} }

View File

@@ -5,6 +5,9 @@ namespace app\common\controller;
use app\ros\model\Order as OrderModel; use app\ros\model\Order as OrderModel;
use app\http\model\User as UserModel; use app\http\model\User as UserModel;
use app\http\model\Recharge as RechargeModel; use app\http\model\Recharge as RechargeModel;
use app\jinyou\model\ProductOrder as ProductOrderModel;
use app\jinyou\model\Account as AccountModel;
use app\jinyou\model\Package as PackageModel;
class Wxpay { class Wxpay {
@@ -87,6 +90,57 @@ class Wxpay {
$user_model->updateOne(['Id'=>$order_info['user_id']],$user_update); $user_model->updateOne(['Id'=>$order_info['user_id']],$user_update);
//处理完成之后,告诉微信成功结果
echo '<xml>
<return_code><![CDATA[SUCCESS]]></return_code>
<return_msg><![CDATA[OK]]></return_msg>
</xml>';
exit();
}
}
public function jinyouwxpayverify() {
//接收数据
$xmlData = file_get_contents('php://input');
libxml_disable_entity_loader(true);
$data = json_decode(json_encode(simplexml_load_string($xmlData, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
$order_model = new ProductOrderModel();
$order_no = $data['out_trade_no'];
$wx_no = $data['transaction_id'];
//获取充值信息
$order_info = $order_model->getOne(['OrderNo'=>$order_no]);
if (!empty($order_info['TradeNo'])) {
die;
}
//判断算出的签名和通知信息的签名是否一致
if($data['result_code'] == 'SUCCESS' && $data['appid'] == 'wx18e5b4f42773c3ec' && $data['mch_id'] == '1571608411'){
$update_data = [];
//更新充值订单
$update_data['TradeNo'] = $wx_no;
$update_data['OrderState'] = 90;
$order_model->updateOne(['OrderNo'=>$order_no],$update_data);
$account_info = json_decode($order_info['remark2']);
$user_model = new UserModel();
$user_info = $user_model->getOne(['Id' => $order_info['UserId']]);
$package_model = new PackageModel;//套餐详情
$package_info = $package_model->getOne(['Id' => $account_info['package_id']]);
$account_model = new AccountModel;
$account_model->open_account($account_info,$user_info,$package_info);
//处理完成之后,告诉微信成功结果 //处理完成之后,告诉微信成功结果
echo '<xml> echo '<xml>
<return_code><![CDATA[SUCCESS]]></return_code> <return_code><![CDATA[SUCCESS]]></return_code>

View File

@@ -0,0 +1,60 @@
<?php
namespace app\jinyou\controller;
use extend\jinyouapi\Jinyoujingtai;
use app\jinyou\model\Package as PackageModel;
class Api
{
public function test() {
$qilinjt = new Jinyoujingtai;
$data = $qilinjt::productList(0);
dd($data);
}
//获取游戏列表
public function gameList() {
$qilinjt = new Jinyoujingtai;
$data = $qilinjt::gameList();
echo json_encode($data);
}
//获取地区列表
public function regionSurplusOuts() {
$info = $_GET;
$qilinjt = new Jinyoujingtai;
$data = $qilinjt::regionSurplusOuts($info['product_id'],$info['is_unshar'],$info['game_id']);
echo json_encode($data);
}
//获取所有套餐
public function getPackage() {
$info = $_GET;
$package_type = '';
if ($info['type'] == 1) {
$package_type = '静态';
} else if ($info['type'] == 2) {
$package_type = '固态';
}
$package_model = new PackageModel;
$list = $package_model->get_package($package_type);
$data = [
'code' => 1,
'msg' => '',
'data' => $list,
];
echo json_encode($data);
}
}

View File

@@ -0,0 +1,370 @@
<?php
namespace app\jinyou\controller;
use fastphp\base\Controller;
use extend\jinyouapi\Jinyoujingtai;
use app\jinyou\model\User as UserModel;
use app\jinyou\model\Product as ProductModel;
use app\jinyou\model\Package as PackageModel;
use app\jinyou\model\PriceScheme as SchemeModel;
use app\jinyou\model\UserPrice as UserPriceModel;
use app\jinyou\model\ProductOrder as ProductOrderModel;
use enum\order\ProductOrder as OrderEnum;
use app\user\model\UserScore as UserScore;
use app\jinyou\model\Account as AccountModel;
use extend\wechatpay\Wxpay;
use extend\alipay\Alipay;
class Jinyoujt extends Controller
{
//获取所有套餐
public function getPackage() {
$info = $_GET;
$isset_price= false;
$discount = 0;
$user_price = [];
$user_model = new UserModel;
$user_info = $user_model->getOne(['Id' => $this->userinfo['UserId']],'Id,discount_id,RestAmount,TestCountLimit,UseTestCount,is_verify');
if ($user_info['discount_id'] != 0) {
$isset_price = true;
if ($user_info['discount_id'] == -1) {
$user_price_model = new UserPriceModel;
$user_price_list = $user_price_model->getList(['UserId' => $this->userinfo['UserId'],'ProductId' => 28]);
foreach ($user_price_list as $info) {
$user_price[$info['PackageId']] = $info['UserPrice'];
}
} else {
$scheme_model = new SchemeModel;
$discount = $scheme_model->getone(['Id' => $user_info['discount_id']])['discount'];
}
}
$package_type = '';
if ($info['type'] == 1) {
$package_type = '静态';
} else if ($info['type'] == 2) {
$package_type = '固态';
}
$package_model = new PackageModel;
$list = $package_model->get_package($package_type,$isset_price,$discount,$user_price);
$data = [
'code' => 1,
'msg' => '',
'data' => $list,
];
echo json_encode($data);
}
//创建静态订单
public function create_order() {
$request_data = json_decode(file_get_contents("php://input"),true)['order_info'];
$return_data['code'] = 0;
$request_data['price'] = abs($request_data['price']);
$user_model = new UserModel;
$jinyoujingtai = new Jinyoujingtai;
$package_model = new PackageModel;
$user_update_info = [];
$user_info = $user_model->getOne(['Id' => $this->userinfo['UserId']]);
//套餐详情
$package_info = $package_model->getOne(['Id' => $request_data['package_id']]);
$user_price_model = new UserPriceModel;
$package_info['Price'] = $user_price_model->get_user_price($user_info['Id'],$user_info['discount_id'],$package_info);
//判读测试卡是否需要付钱
if ($package_info['IsTest'] == 1 && (($user_info['TestCountLimit']!=0 && $user_info['TestCountLimit']<=$user_info['UseTestCount']) || ($user_info['TestCountLimit'] ==0 && $user_info['UseTestCount']>2))) {
$package_info['Price'] = 1.00;
} else if($package_info['IsTest'] == 1) {
$request_data['buy_num'] = 1;
$account_info['product_info'] = [];
$user_update_info['UseTestCount'] = $user_info['UseTestCount'] + 1;
$user_model->updateOne(['Id'=>$this->userinfo['UserId']],$user_update_info);
}
//计算实际需要支付的金额
$OrderAmount = abs($package_info['Price'] * $request_data['buy_num']);
//判断价格是否正确
if ($OrderAmount != $request_data['price']) {
$return_data['code'] = -1;
$return_data['msg'] = "价格有误,请联系客服!";
}
//判断是否实名
if ($user_info['is_verify'] != 1) {
$return_data['code'] = -1;
$return_data['msg'] = "请前往实名!";
}
//判断余额是否足够支付
if ($request_data['pay_type'] == 1 && $user_info['RestAmount'] < $request_data['price']) {
$return_data['code'] = -1;
$return_data['msg'] = "余额不足!";
}
//判断账号是否存在
$exist = $jinyoujingtai::checkVpnAccountExists($request_data['account'],$request_data['type']);
if($exist->code != 200){
$return_data['code'] = -1;
$return_data['msg'] = "账号已经存在!";
}
//判断连接数
if ($request_data['buy_num'] < 1) {
$return_data['code'] = -1;
$return_data['msg'] = "账号数量至少为1";
}
if ($return_data['code'] == -1) {
echo json_encode($return_data);
die;
}
//获取产品信息
$product_model = new ProductModel;
$product_info = $product_model->getOne(['Id' => $package_info['ProductId']]);
$package_info['ProductName'] = $product_info['Name'];
$order_no = 'xk'.time().rand(100,999);
$order_enum = new OrderEnum;
//判断新开类型
$OrderType = $order_enum::$New;
if ($request_data['buy_num'] > 1) {
$OrderType = $order_enum::$News;
}
$OtherPayAmount = 0;
$AccountPayAmount = 0;
if ($request_data['pay_type'] == $order_enum::$Balance) {
$AccountPayAmount = $OrderAmount;
} else {
$OtherPayAmount = $OrderAmount;
}
$time = date('Y-m-d H:i:s',time());
$endtime = date("Y-m-d H:i:s",strtotime("+30 day"));
$order_info = [
'TenantId' => 0,
'UserId' => $user_info['Id'],
'UserName' => $user_info['LoginCode'],
'ProductId' => $package_info['ProductId'],
'ProductName' => $product_info['Name'],
'PackageId' => $package_info['Id'],
'PackageName' => $package_info['Name'],
'CouponId' => 0,
'OrderName' => $package_info['Name'],
'OrderNo' => $order_no,
'OrderState' => $order_enum::$NoPay,
'OrderType' => $OrderType,
'PayType' => $request_data['pay_type'],
'PayState' => 0,
'ConnectCount' => 1,
'OrderAmount' => $OrderAmount,
'PaymentAmount' => $OrderAmount,
'OtherPayAmount' => $OtherPayAmount,
'AccountPayAmount' => $AccountPayAmount,
'CouponAmount' => 0,
'DayPrice' => $package_info['DayPrice'],
'DayCount' => $package_info['DayCount'],
'RefundCount' => 0,
'RefundAmount' => 0,
'ClientType' => 0,
'ChannelType' => 0,
'CreateTime' => $time,
'UpdateTime' => $time,
'Accounts' => $request_data['account'],
'AccountCount' => $request_data['buy_num'],
'AccountPwd' => $request_data['password'],
'DeleteTag' => 0,
'StartTime' => $time,
'EndTime' => $endtime,
'IsAutoRefund' => $product_info['AutoRefund'],
'BackAmount' => 0,
'remark2' => json_encode($request_data)
];
$order_model = new ProductOrderModel;
//用户余额
$old_balance = $rest_money = $user_info['RestAmount'];
if ($request_data['pay_type'] == $order_enum::$Balance) {
//判断余额是否足够
if ($old_balance < $OrderAmount) {
$return_data['code'] = -1;
$return_data['msg'] = "余额不足!";
echo json_encode($return_data);
die;
} else {
$rest_money -= $OrderAmount;
$rest_data = [
'RestAmount' => $rest_money
];
if ($user_model->updateOne(['Id'=>$this->userinfo['UserId'],'RestAmount'=>$old_balance],$rest_data) || $OrderAmount == 0) {
$score_model = new UserScore;
$score_data = [
'TenantId'=>0,
'UserId' => $this->userinfo['UserId'],
'ScoreType' => '6',
'ScoreTypeName' => '购买水滴',
'ScoreValue' => $OrderAmount,
'UserName' => $user_info['Phone'],
'OperateUserName' => $user_info['LoginCode'],
'RestAmount1' => $old_balance,
'RestAmount2' => $rest_money,
'DeleteTag'=>0,
'CreateTime' => date('Y-m-d H:i:s'),
'UpdateTime' => date('Y-m-d H:i:s'),
];
$score_model->add($score_data);
$order_info['OrderState'] = $order_enum::$Complete;
//添加订单
$order_model->add($order_info);
$account_model = new AccountModel;
$return_data = $account_model->open_account($request_data,$user_info,$package_info);
echo json_encode($return_data);
} else {
$return_data['code'] = -1;
$return_data['msg'] = "余额不足!";
echo json_encode($return_data);
die;
}
}
} else if($request_data['pay_type'] == $order_enum::$Wechat) {
$param = [
'out_trade_no' => $order_model['order_no'],
'total_amount' => $OrderAmount,
'subject' => '购买水滴',
'product_code' => 'FAST_INSTANT_TRADE_PAY',
'timeout_express' => '30m',
];
$pay_html = Alipay::pay_jinyou($param);
$info = [
'code'=>2,
'data' => $pay_html
];
echo json_encode($info);
} else if($request_data['pay_type'] == $order_enum::$Ali) {
//微信支付
$wxpay = new Wxpay();
$param = [
'username' => $this->userinfo['LoginName'],
'money' => $OrderAmount*100,
'order_no' => $order_model['order_no'],
];
$url = $wxpay->http_pay($param);
$info = [
'code'=>3,
'data' => $url
];
echo json_encode($info);
}
}
//获取剩余的节点
public function address_margin(){
$account_id = json_decode(file_get_contents("php://input"),true)['data'];
$account_model = new AccountModel;
$product_shuidi_id = 0;
$game_id = 0;
$is_unshar = 0;
$where = [
'Id' => $account_id,
];
$account_info = $account_model->getOne($where);
$game_id = $account_info['game_id'];
$package_info = explode('-',$account_info['PackageName']);
if ($package_info[0] == "静态") {
$product_shuidi_id = 1;
} else {
$product_shuidi_id = 2;
}
if ($package_info[1] == "线路") {
$is_unshar = 1;
} else {
$is_unshar = 0;
}
$jinyoujingtai = new Jinyoujingtai;
$data = $jinyoujingtai::regionSurplusOuts($product_shuidi_id,$is_unshar,$game_id);
echo json_encode($data);
}
//获取可切换的ip
public function change_ip_list() {
$info = json_decode(file_get_contents("php://input"),true)['data'];
$jinyoujingtai = new Jinyoujingtai;
$data = $jinyoujingtai::switchIpList(121,$info['account'],$info['type']);
echo json_encode($data);
}
//切换的ip
public function change_ip() {
$info = json_decode(file_get_contents("php://input"),true)['data'];
$jinyoujingtai = new Jinyoujingtai;
$account_model = new AccountModel;
$where = [
'ProductId' => 28,
'Account' => $info['chinge_addr']['account'],
'Status' => 1,
'DeleteTag' => 0,
];
if ($info['chinge_addr']['rid'] != 0 ) {
$data = $jinyoujingtai::changeRegion(121,$info['chinge_addr']['province_id'],$info['chinge_addr']['rid'],$info['chinge_addr']['account'],$info['chinge_addr']['type']);
}
if ($info['chinge_ip']['ip_id'] != 0 ) {
$data = $jinyoujingtai::saveSwitchIp(121,$info['chinge_ip']['account'],$info['chinge_ip']['type'],$info['chinge_ip']['ip_id']);
}
$shuidi_account_data = $jinyoujingtai::accountInfo(121,$info['chinge_ip']['account'],$info['chinge_ip']['type']);
$update_data = [
'Remark' => $shuidi_account_data->data->region.$shuidi_account_data->data->address,
'Raw' => $shuidi_account_data->data->inlet_website,
];
$account_model->updateOne($where,$update_data);
echo json_encode(['code' => 1]);
}
}

View File

@@ -0,0 +1,74 @@
<?php
namespace app\jinyou\model;
use fastphp\base\Model;
use extend\jinyouapi\Jinyoujingtai;
use enum\account\ProductAccount as AccountEnum;
class Account extends Model
{
protected $table = 'product_account';
//开通账号
public function open_account($account_info,$user_info,$package_info) {
$jinyou = new Jinyoujingtai;
$return_data = [];
foreach ($account_info['product_info'] as $key=>$add_city) {
if ($add_city == 0) {
unset($account_info['product_info'][$key]);
}
}
$package_origin = explode('-',$package_info['OriginKey']);
$api_data = $jinyou::createStatic($package_origin['3'],$account_info['game_id'],$account_info['account'],$account_info['password'],$account_info['buy_num'],121,$package_origin['0'],$package_origin['1'],$package_origin['2'],'',$account_info['product_info']);
$account_list = [];
if ($api_data->code == 200) {
$account_enum = new AccountEnum;
$account_type = $account_enum::$New;
if ($package_info['IsTest'] == 1) {
$account_type = $account_enum::$Test;
} else if ($account_info['buy_num'] > 1) {
$account_type = $account_enum::$News;
}
foreach ($api_data->data as $account) {
$account = [
'TenantId' => 0,
'UserId' => $user_info['Id'],
'UserCode' => $user_info['LoginCode'],
'ProductId' => $package_info['ProductId'],
'ProductName' => $package_info['ProductName'],
'PackageId' => $package_info['Id'],
'PackageName' => $package_info['Name'],
'AccountType' => $account_type,
'Account' => $account->user,
'Pwd' => $account->passwd,
'ConnectCount' => $account->conn_max,
'StartTime' => date('Y-m-d H:i:s',$account->add_time),
'EndTime' => date('Y-m-d H:i:s',$account->end_time),
'Status' => $account_enum::$Normal,
'ChargeStatus' => $account_enum::$Success,
'CreateTime' => date('Y-m-d H:i:s',time()),
'UpdateTime' => date('Y-m-d H:i:s',time()),
'DeleteTag' => 0,
'Remark' => $account->region.$account->address,
'Raw' => $account->inlet_website,
'game_id' => $account->game_id,
];
$account_list[] = $account;
}
$this->addAll($account_list);
$return_data['code'] = 1;
$return_data['msg'] = "账号开通成功!";
} else {
$return_data['code'] = -1;
$return_data['msg'] = "账号开通失败!请联系客服";
}
return $return_data;
}
}

View File

@@ -0,0 +1,68 @@
<?php
namespace app\jinyou\model;
use fastphp\base\Model;
class Package extends Model
{
protected $table = 'product_package';
/**
* 获取套餐
* @param bool $isset_price 是否使用设置的价格
* @param int $discount 折扣
* @param array $user_price 用户的价格;
*/
public function get_package($origin,$isset_price= false,$discount = 0,$user_price = []) {
$where['OriginName'] = ['like', $origin . '%'];
$where['Status'] = 1;
$where['DeleteTag'] = 0;
$package_list = $this->getList($where,'*', 'id asc');
$list = [];
foreach ($package_list as $package) {
$package_info = explode('-',$package['OriginName']);
//判断价格
if ($isset_price) {
$price = 1000000;
$package_price = $package['Price'];
if ($discount != 0) {
$price = $package['LinePrice'] * $discount / 100;
} else {
if (!empty($user_price)) {
if ($package['Id'] == $user_price['PackageId']) {
$price = $user_price['UserPrice'];
}
}
}
//判读最低价
if ($price < $package['MinPrice']) {
$price = $package['MinPrice'];
}
if ($price < $package_price) {
$package['Price'] = $price;
}
}
if (isset($package_info[3])) {
$package['package_name'] = $package_info[3];
} else {
$package['package_name'] = '1小时';
}
if($package_info[1] == "游戏") {
$package_info[1] = 'game';
}
if($package_info[1] == "线路") {
$package_info[1] = 'line';
}
if ($package_info[2] == '测试') {
$package_info[2] = 'test';
}
$list[$package_info[1]][$package_info[2]][] = $package;
}
return $list;
}
}

View File

@@ -0,0 +1,11 @@
<?php
namespace app\jinyou\model;
use fastphp\base\Model;
class PriceScheme extends Model
{
protected $table = 'product_price_scheme';
}

View File

@@ -0,0 +1,11 @@
<?php
namespace app\jinyou\model;
use fastphp\base\Model;
class Product extends Model
{
protected $table = 'product';
}

View File

@@ -0,0 +1,11 @@
<?php
namespace app\jinyou\model;
use fastphp\base\Model;
class ProductOrder extends Model
{
protected $table = 'product_order';
}

19
app/jinyou/model/User.php Normal file
View File

@@ -0,0 +1,19 @@
<?php
/*
* @Descripttion:
* @version:
* @Author: kangkang
* @Date: 2020-10-16 14:44:02
* @LastEditors: “wanyongkang” “937888580@qq.com”
* @LastEditTime: 2024-01-25 17:33:17
*/
namespace app\jinyou\model;
use fastphp\base\Model;
class User extends Model
{
protected $table = 'user';
}

View File

@@ -0,0 +1,36 @@
<?php
namespace app\jinyou\model;
use fastphp\base\Model;
class UserPrice extends Model
{
protected $table = 'product_user_price';
public function get_user_price($user_id,$discount,$package_info){
$price = 100000;
//根据用户价格
if ($discount != 0) {
if ($discount == -1) {
$price = $$this->getOne(['UserId' => $user_id,'PackageId' => $package_info['Id']])['UserPrice'];
} else {
$scheme_model = new PriceScheme;
$discount = $scheme_model->getone(['Id' => $discount])['discount'];
$price = $package_info['LinePrice'] * $discount / 100;
}
//判读最低价
if ($price < $package_info['MinPrice']) {
$price = $package_info['MinPrice'];
}
if ($price < $package_info['Price']) {
$package_info['Price'] = $price;
}
}
return $package_info['Price'];
}
}

View File

@@ -4,8 +4,8 @@
* @version: * @version:
* @Author: kangkang * @Author: kangkang
* @Date: 2020-10-22 15:35:49 * @Date: 2020-10-22 15:35:49
* @LastEditors: kangkang * @LastEditors: “wanyongkang” “937888580@qq.com”
* @LastEditTime: 2020-11-18 10:41:10 * @LastEditTime: 2024-01-27 14:42:08
*/ */
namespace enum\account; namespace enum\account;
@@ -26,4 +26,25 @@ class ProductAccount
public static $AgainBuys = 4; public static $AgainBuys = 4;
public static $Origin = 100; public static $Origin = 100;
public static $Test = 200; public static $Test = 200;
public static $status = [
1 => '正常',
2 => '退款',
];
public static $Normal = 1;
public static $Refund = 2;
public static $ChargeStatus = [
1 => '成功',
2 => '失败',
3 => '关闭',
4 => '超时',
];
public static $Success = 1;
public static $Fail = 2;
public static $Close = 3;
public static $Outtime = 4;
} }

View File

@@ -2,7 +2,7 @@
/* /*
* @Author: 万永康 * @Author: 万永康
* @Date: 2020-10-11 12:32:50 * @Date: 2020-10-11 12:32:50
* @LastEditTime: 2024-01-13 17:52:59 * @LastEditTime: 2024-01-27 16:19:49
* @LastEditors: “wanyongkang” “937888580@qq.com” * @LastEditors: “wanyongkang” “937888580@qq.com”
* @Description: In User Settings Edit * @Description: In User Settings Edit
* @FilePath: /phptest/alipay/Alipay.php * @FilePath: /phptest/alipay/Alipay.php
@@ -153,6 +153,36 @@ class Alipay
return $result; return $result;
}
public static function pay_jinyou($param)
{
global $config;
$aop = new \AopClient ();
$aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';
$aop->appId = $config['alipay2']['app_id'];;
$aop->rsaPrivateKey = $config['alipay2']['private_key'] ;
$aop->apiVersion = '1.0';
$aop->signType = 'RSA2';
$aop->postCharset='utf-8';
$aop->format='json';
$aop->alipayrsaPublicKey = $config['alipay2']['public_key'];
$request = new \AlipayTradePagePayRequest();
$param = json_encode($param);
$request->setReturnUrl('http://www.juip.com/user/myaccounts');
$notifyUrl="http://php-api.juip.com/common/alipay/jinyoualipayverify";
$request->setNotifyUrl($notifyUrl);
$request->setBizContent($param);
$result = $aop->pageExecute ( $request);
return $result;
} }
/** /**

View File

@@ -0,0 +1,565 @@
<?php
namespace extend\jinyouapi;
/**
* 金柚网络开放平台 SDK
* 通信编码协定 UTF-8
*/
class Jinyoujingtai{
/**
* 金柚域名
*/
private static $ServerUrl = "https://jyip.net/open-api/";
/**
* APP_ID
*/
private static $app_id = '49330ae23dad78f9';
/**
* APP_key
*/
private static $app_key = 'ddb4311a227fb118cacd63cc68416ab5';
/**
* 通用时间戳10位
*/
private static function timestamp()
{
return time();
}
/**
* 通信方法
*/
private static function send_post($method, $post_data)
{
$post_data=self::signAct($post_data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, self::$ServerUrl . $method);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
/**
* key排序签名
*/
private static function signAct($body)
{
$authStr = "";
$body ["st"] = static::timestamp();
$body ["app_id"] = static::$app_id;
ksort($body);
foreach ($body as $item) {
if(!is_object($item) and !is_array($item)) {
$authStr = $authStr . $item;
}
}
$body ["sign"] = md5(md5($authStr). static::$app_key);
return $body;
}
/**
* 测试接口,测试通信
*/
public static function apiTest($data)
{
$res = self::send_post('api-test', $data);
return json_decode($res);
}
/**
* * 创建平台第三方接入账号
* @param $phone *接入方平台用户注册手机号 同应用下手机号码不可重复
* @param $cn_name *用户实名认证后的真实姓名
* @param $cn_id *用户实名认证后的身份证号码
* @param $t_id *接入方平台中客户唯一的身份标识
* @return @json
*/
public static function createUsers($phone, $cn_name, $cn_id, $t_id)
{
$post_data = [
'phone' => $phone,
'cn_name' => $cn_name,
'cn_id' => $cn_id,
't_id' => $t_id,
];
$res = self::send_post('create-third-user', $post_data);
return json_decode($res);
}
/**
* 获取当前账户的可用余额
* @return @json
*/
public static function getMyPoint()
{
$res = self::send_post('get-my-point', []);
return json_decode($res);
}
/**
* 检查VPN账户是否存在
* @param string $user vpn账户
* @param int $type 类型,0:静态;1:专线;
*/
public static function checkVpnAccountExists($user, $type)
{
$data = [
'user' => $user,
'type' => $type
];
$res = self::send_post('check-vpn-account-exists', $data);
return json_decode($res);
}
/**
* 踢线
* @param string $user VPN账户
* @param int $type 类型,0:静态;1:专线;
*/
public static function kickOffLine($user, $type)
{
$data = [
'user' => $user,
'type' => $type
];
$res = self::send_post('kick-off-line', $data);
return json_decode($res);
}
/**
* 上传用户手持身份证照片
* 文件大小限制为不超过3M,支持格式为:jpg,jpeg,bmp,webp,png
* @param $t_id mixed 接入方平台中客户唯一的身份标识
* @param $upload_img mixed 这里是以thinkphp为示例实例的ThinkFile($file_path)对象
* 在CURLFILE(string $filename, string|null $mime_type = '', string|null $posted_filename = '')中你可以直接使用绝对地址,请勿使用网络地址。
* @return @json
*/
public static function uploadExamineFile($t_id, $upload_img)
{
$post_data = array(
't_id' => $t_id,
'upload_img' => new \CURLFile($upload_img->getRealPath(), $upload_img->getMime(), 'up.jpg'),
);
$res = self::send_post('upload-examine-file', $post_data);
return json_decode($res);
}
/**
* * 查询第三方接入用户状态
* @param $t_id 接入方平台中客户唯一的身份标识,整型 数字范围1-999999999
* @return @json
*/
public static function examineStatus($t_id)
{
$post_data = [
't_id' => $t_id,
];
$res = self::send_post('examine-status', $post_data);
return json_decode($res);
}
/**
* 开启白名单,涉及到用户需要使用到娱乐应用软件,例如:微信,抖音,均需要开启白名单
* @param $user string vpn账户
* @param $type int 账户类型,0:静态账户;1:专线账户
* @param $t_id int 接入方平台中客户唯一的身份标识,整型 数字范围1-999999999
* @return @json
*/
public static function setFirewallStatus($user, $type, $t_id)
{
$post_data = [
'user' => $user,
'type' => $type,
't_id' => $t_id
];
$res = self::send_post('set-firewall-status', $post_data);
return json_decode($res);
}
/**
* * 获取VPN账户列表
* @param $page int 当前分页
* @param $page_size int 分页条目数 1-100
* @param $t_id int 接入方客户唯一值UID用于查询客户账号列表、0或缺省则查询当前应用下全部客户账号非必填字段
* @param $user string vpn账户
* @return @json
*/
public static function userList($type, $page, $page_size, $t_id = null, $user = "")
{
$post_data = [
'type' => $type,
't_id' => $t_id,
'user' => $user,
'page' => $page,
'page_size' => $page_size,
];
$res = self::send_post('user-list', $post_data);
return json_decode($res);
}
/**
* 拉取已对接的产品ID
* @param $type int 产品分类 0:静态;1:专线 非必填
* @param $is_unshar int 产品类型 0:游戏独享;1:线路独享 非必填
*/
public static function productList($type = 0, $is_unshar = 0)
{
$post_data = [
'type' => $type
];
$res = self::send_post('product-list', $post_data);
return json_decode($res);
}
/**
* 游戏列表
*/
public static function gameList()
{
$post_data = [
];
$res=self::send_post('game-list', $post_data);
return json_decode($res);
}
/**
* 获取所有静态服务器列表
* @param $area string 区域查询,可为空,例如:"福建"
* @return @json
*/
public static function getStaticNodeList($area = '')
{
$post_data = [
'area' => $area
];
$res = self::send_post('static-node-list', $post_data);
return json_decode($res);
}
/**
* 创建静态VPN账户
* @param int $days 时长,通过已对接产品接口获取
* @param int $game_id 游戏ID通过游戏列表接口获取线路独享时可以传空
* @param string $account 自定义VPN账户,当存在自定义账户时且购买数量大于则账户末尾会追加数量序号例如账号为abc数量为3则会生成abc1-3
* @param string $passwd 自定义VPN密码
* @param string $nums 购买数量
* @param int $t_id 第三方身份唯一标识符号
* @param int $product_id 产品大类ID通过已对接产品接口获取
* @param int $product_sub_id 产品小类ID通过已对接产品接口获取
* @param int $product_item_id 产品ID通过已对接产品接口获取
* @param string $remark 备注
* @param array $product_info
*/
public static function createStatic($days, $game_id, $account, $passwd, $nums, $t_id, $product_id, $product_sub_id, $product_item_id, $remark = '', $product_info = [])
{
$post_data = [
'days' => $days,
'product_item_id' => $product_item_id,
'product_id' => $product_id,
'product_sub_id' => $product_sub_id,
'nums' => $nums,
't_id' => $t_id,
'game_id' => $game_id,
'account' => $account,
'passwd' => $passwd,
'remark' => $remark
];
if (!empty($product_info)) {
$post_data ['product_info'] = json_encode($product_info);
}
$res = self::send_post('create-vpn-user', $post_data);
return json_decode($res);
}
/**
* 创建专线VPN账户
* @param int $days 时长,通过已对接产品接口获取
* @param int $game_id 游戏ID通过游戏列表接口获取线路独享时可以传空
* @param string $account 自定义VPN账户,当存在自定义账户时且购买数量大于则账户末尾会追加数量序号例如账号为abc数量为3则会生成abc1-3
* @param string $passwd 自定义VPN密码
* @param string $nums 购买数量
* @param int $t_id 第三方身份唯一标识符号
* @param int $product_id 产品大类ID通过已对接产品接口获取
* @param int $product_sub_id 产品小类ID通过已对接产品接口获取
* @param int $product_item_id 产品ID通过已对接产品接口获取
* @param string $remark 备注
* @param array $product_info
*/
public static function createFixed($days, $game_id, $account, $passwd, $nums, $t_id, $product_id, $product_sub_id, $product_item_id, $product_info = [])
{
$post_data = [
'days' => $days,
'product_item_id' => $product_item_id,
'product_id' => $product_id,
'product_sub_id' => $product_sub_id,
'nums' => $nums,
't_id' => $t_id,
'game_id' => $game_id,
'account' => $account,
'passwd' => $passwd
];
if (!empty($product_info)) {
$post_data ['product_info'] = json_encode($product_info);
}
$res = self::send_post('create-vpn-user', $post_data);
return json_decode($res);
}
/**
* 静态账户续费
* @param int $t_id 第三方身份唯一标识符号
* @param string $account 要续费的VPN账户
* @param int $product_id 产品大类ID通过已对接产品接口获取
* @param int $product_sub_id 产品小类ID通过已对接产品接口获取
* @param int $product_item_id 产品ID通过已对接产品接口获取
* @param int $days 时长,通过已对接产品接口获取
* @param $type int 账户类型,0:静态账户;1:专线账户
*/
public static function staticAccountRenew($t_id, $account, $product_id, $product_sub_id, $product_item_id, $days, $type = 0)
{
$post_data = [
'days' => $days,
'product_item_id' => $product_item_id,
'product_id' => $product_id,
'product_sub_id' => $product_sub_id,
't_id' => $t_id,
'account' => $account,
'type' => $type
];
$res = self::send_post('account-renew', $post_data);
return json_decode($res);
}
/**
* 专线账户续费
* @param int $t_id 第三方身份唯一标识符号
* @param string $account 要续费的VPN账户
* @param int $product_id 产品大类ID通过已对接产品接口获取
* @param int $product_sub_id 产品小类ID通过已对接产品接口获取
* @param int $product_item_id 产品ID通过已对接产品接口获取
* @param int $days 时长,通过已对接产品接口获取
* @param $type int 账户类型,0:静态账户;1:专线账户
*/
public static function fixedAccountRenew($t_id, $account, $product_id, $product_sub_id, $product_item_id, $days, $type = 1)
{
$post_data = [
'days' => $days,
'product_item_id' => $product_item_id,
'product_id' => $product_id,
'product_sub_id' => $product_sub_id,
't_id' => $t_id,
'account' => $account,
'type' => $type
];
$res = self::send_post('account-renew', $post_data);
return json_decode($res);
}
/**
* 获取地区剩余线路
* @param int $product_id 产品ID
* @param int $is_unshar 游戏独享0,线路独享1
* @param int $game_id 游戏ID
*/
public static function regionSurplusOuts($product_id, $is_unshar, $game_id)
{
$post_data = [
'product_id' => $product_id,
'is_unshar' => $is_unshar,
'game_id' => $game_id
];
$res = self::send_post('region-surplus-outs', $post_data);
return json_decode($res);
}
/**
* 切换地区
* @param int $t_id 第三方身份唯一标识符号
* @param int $province_id 区域ID
* @param int $rid 地区编码
* @param string $account VPN账户
* @param $type int 账户类型,0:静态账户;1:专线账户
*/
public static function changeRegion($t_id, $province_id, $rid, $account, $type = 0)
{
$post_data = [
't_id' => $t_id,
'province_id' => $province_id,
'rid' => $rid,
'account' => $account,
'type' => $type
];
$res = self::send_post('change-region', $post_data);
return json_decode($res);
}
/**
* 修改VPN账户备注
* @param int $t_id 第三方身份唯一标识符号
* @param string $remark 备注
* @param string $account VPN账户
* @param $type int 账户类型,0:静态账户;1:专线账户
*/
public static function editRemark($t_id, $remark, $account, $type = 0)
{
$post_data = [
't_id' => $t_id,
'remark' => $remark,
'account' => $account,
'type' => $type
];
$res = self::send_post('edit-remark', $post_data);
return json_decode($res);
}
/**
* 修改VPN账户密码
* @param int $t_id 第三方身份唯一标识符号
* @param string $new_password 新密码
* @param string $account VPN账户
* @param $type int 账户类型,0:静态账户;1:专线账户
*/
public static function editPassword($t_id, $new_password, $account, $type = 0)
{
$post_data = [
't_id' => $t_id,
'passwd' => $new_password,
'account' => $account,
'type' => $type
];
$res = self::send_post('edit-password', $post_data);
return json_decode($res);
}
/**
* 账户在线状态
* @param string $account VPN账户 多账户以英文状态下逗号连接,例如:account1,account2
* @param $type int 账户类型,0:静态账户;1:专线账户
*/
public static function accountIsOnline($account, $type = 0)
{
$post_data = [
'account' => $account,
'type' => $type
];
$res = self::send_post('account-is-online', $post_data);
return json_decode($res);
}
/**
* 获取可切换IP列表
* @param int $t_id 第三方身份唯一标识符号
* @param string $account VPN账户
* @param $type int 账户类型,0:静态账户;1:专线账户
*/
public static function switchIpList($t_id, $account, $type = 0)
{
$post_data = [
'account' => $account,
'type' => $type,
't_id' => $t_id
];
$res = self::send_post('switch-ip-list', $post_data);
return json_decode($res);
}
/**
* 保存切换的IP
* @param int $t_id 第三方身份唯一标识符号
* @param string $account VPN账户
* @param $type int 账户类型,0:静态账户;1:专线账户
*/
public static function saveSwitchIp($t_id, $account, $type = 0, $ip_id)
{
$post_data = [
'account' => $account,
'type' => $type,
't_id' => $t_id,
'ip_id' => $ip_id
];
$res = self::send_post('save-switch-ip', $post_data);
return json_decode($res);
}
/**
* 获取账号信息
* @param int $t_id 第三方身份唯一标识符号
* @param string $account VPN账户
* @param $type int 账户类型,0:静态账户;1:专线账户
*/
public static function accountInfo($t_id, $account, $type = 0)
{
$post_data = [
'account' => $account,
'type' => $type,
't_id' => $t_id,
];
$res = self::send_post('account-info', $post_data);
return json_decode($res);
}
}

View File

@@ -43,4 +43,21 @@ class Wxpay
$url2 = $result["code_url"]; $url2 = $result["code_url"];
return $url2; return $url2;
} }
public function jinyou_pay($param) {
$notify = new \NativePay();
$input = new \WxPayUnifiedOrder();
$input->SetBody("购买水滴");
$input->SetOut_trade_no($param['order_no']);
$input->SetTotal_fee($param['money']);
$input->SetTime_start(date("YmdHis"));
$input->SetTime_expire(date("YmdHis", time() + 600));
$input->SetNotify_url("http://php-api.juip.com/common/wxpay/jinyouwxpayverify");
$input->SetTrade_type("NATIVE");
$result = $notify->GetPayUrl($input);
$url2 = $result["code_url"];
return $url2;
}
} }