Files
addons
app_download_files
extend
hyhproject
admin
app
common
conf
controller
Alipays.php
Appport.php
Areas.php
Articles.php
Auth.php
Base.php
Brands.php
Carts.php
Cashconfigs.php
Cashdraws.php
Chain3.php
Chain3base.php
Ect.php
Ectwallets.php
Error.php
Favorites.php
Goods.php
Goodsappraises.php
Goodscats.php
Goodsconsult.php
Index.php
Invoices.php
Juhui.php
Logmoneys.php
Messages.php
News.php
Note.php
Ordercomplains.php
Orderrefunds.php
Orders.php
Position.php
Qlgpay.php
Shoporders.php
Shopping.php
Shops.php
Switchs.php
Tag.php
Tags.php
Tmp.php
TradeRule.php
Unionpays.php
UserLevel.php
Useraddress.php
Users.php
Userscores.php
Uservouchers.php
Wallets.php
Weixinpays.php
model
validate
common
home
home2
mobile2
wechat2
.htaccess
command.php
mobile
oss
static
thinkphp
upload
vendor
wxtmp
.gitignore
.htaccess
.user.ini
404.html
H5436787D.wgt
admin.php
app-release.apk
app_download.html
cash.lock
demo.php
get_startup.php
get_version.php
get_version_new.php
index.html
index.php
reg.lock
robots.txt
qlg.tsgz.moe/hyhproject/app/controller/Ect.php
2019-09-06 23:53:10 +08:00

149 lines
4.8 KiB
PHP
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace wstmart\app\controller;
use wstmart\common\model\Orders as OM;
use wstmart\app\model\EctElevenPay as M;
/**
* ============================================================================
* 默认控制器
*/
class Ect extends Base{
/**
* 跳去支付页面
*/
public function payment(){
$data = [];
$data['orderNo'] = input('orderNo');
$data['isBatch'] = (int)input('isBatch');
$data['userId'] = (int)session('WST_USER.userId');
$m = new OM();
$rs = $m->getOrderPayInfo($data);//获取订单金额以及用户钱包金额
$pay['list'] = $m->getByUnique();// 根据订单唯一流水获取订单信息
if(empty($rs)){//已支付或者找不到此订单
exit(jsonReturn('读取失败',-1));
}else{
$pay['needPay'] = $rs['needPay'];//需付款
//获取用户钱包
$user = model('users')->getFieldsById($data['userId'],'userECT,payPwd');
$pay['userECT'] = $user['userECT'];
$payPwd = $user['payPwd'];
$payPwd = empty($payPwd)?0:1;
$pay['payPwd'] = $payPwd;//1有密码0没设置密码
}
exit(jsonReturn('',1,$pay));
}
private function getHTTPS($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_REFERER, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
public function getDollerPrice(){
$now_doller = db('doller')->where('id=1')->cache(true)->value('doller');
exit(jsonReturn('',1,['now_doller'=>$now_doller]));
}
public function getToEctNum(){
try{
$url ='https://api.tokencan.net/exchange-open-api/open/api/get_ticker?symbol=ectusdt';
$t_info = $this->getHTTPS($url);
$t_info = json_decode($t_info);
if(is_object($t_info)){
$total_money = input('total_money');
$t_usdt_price = $t_info->data->last;
$now_doller = db('doller')->where('id=1')->value('doller');
$now_rmb = round($t_usdt_price*$now_doller,2);
$to_ect_num = round($total_money/$now_rmb,2);
$ect_discount = Model('payments')->getPaymentDiscount('ect');
$ect_msg='';
if($ect_discount >= 0.9 && $ect_discount <1){
$ect_msg='ECT支付'.($ect_discount*10).'折';
$to_ect_num *= $ect_discount;
}
$msg='当前ECT价格'.$now_rmb.',订单价格:'.$total_money.$ect_msg.',共需:'.round($to_ect_num,2).' ECT';
session('ect_rmb_price',$now_rmb);
exit(jsonReturn($msg,1,['ect_num'=>$to_ect_num]));
}
}catch (\Exception $e) {
exit(jsonReturn('获取价格失败!',-1));
}
}
/**
* 返回获取双11优惠券所需的ect数量和价格
* @return [type] [description]
*/
public function getEctNum(){
$m = new M();
$result = $m->getEctNum();
exit(json_decode($result));
}
/**
* 支付双十一优惠券的ect价格
*/
public function payElevenEct(){
$m = new M();
$result = $m->payElevenEct();
exit(json_decode($result));
}
/**
* 当前用户的ECT数量
* @return [type] [description]
*/
public function userECT(){
$data['ectNum'] = model('Ectwallet')->getEctNum();
// $data['eAddressInfo'] = model('Ectwallet')->getDefaultAddress();
// return WSTReturn('',1,$data);
exit(jsonReturn('',1,$data));
}
/**
* ECT支付
*/
public function payByEct(){
$m = new OM();
exit(json_encode($m->payByEct()));
}
///**
// *查询ect余额
// *
// * @return void
// */
// public function get_balance(){
// $ect_model = Model('Ect');
// $address = $ect_model->getCoinbase();//trim(input('post.address'));
// if(strlen($address)<=40){
// exit(jsonReturn('地址不正确'));
// }
// dump($ect_model->getBalance($address));
// }
// public function get_mc_Balance(){
// $address = $this->getCoinbase();//trim(input('post.address'));
// $this->web3->eth->getBalance($address , function ($err, $balance) {
// if ($err !== null) {
// exit(jsonReturn($err->getMessage()));
// // echo 'Error: ' . $err->getMessage();
// //return;
// }else{
// $my_balance = $balance->toString();
// $my_balance = $my_balance/pow(10,$this->wei);
// $data['balance'] = $my_balance;
// exit(jsonReturn('',1,$data));
// }
// });
// }
}