136 lines
5.1 KiB
PHP
Executable File
136 lines
5.1 KiB
PHP
Executable File
<?php
|
||
// +----------------------------------------------------------------------
|
||
// | likeshop开源商城系统
|
||
// +----------------------------------------------------------------------
|
||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||
// | github下载:https://github.com/likeshop-github
|
||
// | 访问官网:https://www.likeshop.cn
|
||
// | 访问社区:https://home.likeshop.cn
|
||
// | 访问手册:http://doc.likeshop.cn
|
||
// | 微信公众号:likeshop技术社区
|
||
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
|
||
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
|
||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||
// | likeshop团队版权所有并拥有最终解释权
|
||
// +----------------------------------------------------------------------
|
||
// | author: likeshop.cn.team
|
||
// +----------------------------------------------------------------------
|
||
namespace app\index\controller;
|
||
|
||
|
||
|
||
use app\api\logic\BillionsLogic;
|
||
use app\common\basics\IndexBase;
|
||
use app\common\server\WeChatPayServer;
|
||
use app\common\server\WeChatServer;
|
||
use think\Exception;
|
||
use think\facade\Db;
|
||
class Index extends IndexBase
|
||
{
|
||
public function index()
|
||
{
|
||
$template = app()->getRootPath() . 'public/pc/index.html';
|
||
if (is_mobile()) {
|
||
$template = app()->getRootPath() . 'public/mobile/index.html';
|
||
}
|
||
if (file_exists($template)) {
|
||
return view($template);
|
||
}
|
||
return '';
|
||
}
|
||
|
||
|
||
public function app()
|
||
{
|
||
if (strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone') || strpos($_SERVER['HTTP_USER_AGENT'], 'iPad')) {
|
||
$url = ConfigServer::get('app', 'line_ios', '');
|
||
} else {
|
||
$url = ConfigServer::get('app', 'line_android', '');
|
||
}
|
||
|
||
if (empty($url)) {
|
||
echo '未设置app下载链接';
|
||
exit;
|
||
}
|
||
if (!preg_match("/^http(s)?:\\/\\/.+/", $url)) {
|
||
$url = "http://".$url;
|
||
}
|
||
|
||
$this->redirect($url);
|
||
}
|
||
|
||
public function localReturn(){
|
||
$re = $_REQUEST;
|
||
$data['content'] = $re;
|
||
$data['dtime'] = date("Y-m-d H:i:s");
|
||
Db::name("local_return")->save($data);
|
||
// if (gettype($re) == "string") {
|
||
// $data['content'] = $re;
|
||
// $data['dtime'] = date("Y-m-d H:i:s");
|
||
// Db::name("local_return")->save($data);
|
||
// } else {
|
||
// $data['content'] = var_export($re, true);
|
||
// $data['dtime'] = date("Y-m-d H:i:s");
|
||
// Db::name("local_return")->save($data);
|
||
// }
|
||
}
|
||
|
||
public function billions(){
|
||
$result = Db::name("user_billions_surplus")
|
||
->where("residue_price",">","0")
|
||
->where("user_start_price",">","0")
|
||
->find();
|
||
if($result != null){
|
||
$r = Db::name("user_billions")->alias("a")
|
||
->join("user_billions_surplus_log b","a.billions_id = b.billions_id","left")
|
||
->where("a.billions_id","<=",$result['billions_id'])
|
||
->where("b.surplus_id IS NULL")
|
||
->limit(1000)
|
||
->select()->toArray();
|
||
foreach($r as $key=>$value){
|
||
|
||
$ranking = BillionsLogic::getRanking($value['billions_id']);
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
public function retund(){
|
||
$config = WeChatServer::getPayConfigBySource(1)['config'];
|
||
if (empty($config)) {
|
||
throw new Exception('请联系管理员设置微信相关配置!');
|
||
}
|
||
if (!isset($config['cert_path']) || !isset($config['key_path'])) {
|
||
throw new Exception('请联系管理员设置微信证书!');
|
||
}
|
||
if (!file_exists($config['cert_path']) || !file_exists($config['key_path'])) {
|
||
throw new Exception('微信证书不存在,请联系管理员!');
|
||
}
|
||
|
||
$result = WeChatPayServer::refund($config, [
|
||
'transaction_id' => "4200002417202409298999399108",
|
||
'refund_sn' => "202409291431067057",
|
||
'total_fee' => intval(strval(650 * 100)),//订单金额,单位为分
|
||
'refund_fee' => intval(strval(650 * 100)),//退款金额
|
||
]);
|
||
var_dump($result);
|
||
if (isset($result['return_code']) && $result['return_code'] == 'FAIL') {
|
||
throw new Exception($result['return_msg']);
|
||
}
|
||
if (isset($result['err_code_des'])) {
|
||
throw new Exception($result['err_code_des']);
|
||
}
|
||
if ($result['return_code'] == 'SUCCESS' && $result['result_code'] == 'SUCCESS') {
|
||
//更新退款日志记录
|
||
$dat['wechat_refund_id'] = $result['refund_id'] ?? 0;
|
||
$dat['refund_msg'] = json_encode($result, JSON_UNESCAPED_UNICODE);
|
||
$dat['dtime'] = date("Y-m-d H:i:s");
|
||
Db::name("local_pay_return")->save($dat);
|
||
} else {
|
||
throw new Exception('微信支付退款失败');
|
||
}
|
||
}
|
||
}
|