first commit
This commit is contained in:
20
application/openapi/config.php
Normal file
20
application/openapi/config.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
// +------------------------------------------------+
|
||||
// |http://www.cjango.com |
|
||||
// +------------------------------------------------+
|
||||
// | 修复BUG不是一朝一夕的事情,等我喝醉了再说吧! |
|
||||
// +------------------------------------------------+
|
||||
// | Author: 小陈叔叔 <Jason.Chen> |
|
||||
// +------------------------------------------------+
|
||||
|
||||
return [
|
||||
// +----------------------------------------------------------------------
|
||||
// | 日志设置
|
||||
// +----------------------------------------------------------------------
|
||||
'log' => [
|
||||
'type' => 'file',
|
||||
'path' => LOG_PATH . 'openapi/',
|
||||
'time_format' => ' c ',
|
||||
'file_size' => 2097152,
|
||||
],
|
||||
];
|
||||
37
application/openapi/controller/Pay.php
Normal file
37
application/openapi/controller/Pay.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
// +------------------------------------------------+
|
||||
// |http://www.cjango.com |
|
||||
// +------------------------------------------------+
|
||||
// | 修复BUG不是一朝一夕的事情,等我喝醉了再说吧! |
|
||||
// +------------------------------------------------+
|
||||
// | Author: 小陈叔叔 <Jason.Chen> |
|
||||
// +------------------------------------------------+
|
||||
namespace app\openapi\controller;
|
||||
|
||||
use app\common\model\MemberInfo;
|
||||
use app\common\model\VipOrder;
|
||||
use app\common\service\Score as ScoreService;
|
||||
use cjango\Wechat;
|
||||
use think\Config;
|
||||
|
||||
class Pay
|
||||
{
|
||||
|
||||
public function vip()
|
||||
{
|
||||
$config = Config::get('wechat');
|
||||
Wechat::instance($config);
|
||||
$res = Wechat\Pay::parsePayRequest();
|
||||
if ($res) {
|
||||
$order = VipOrder::where('orderid', $res['out_trade_no'])->find();
|
||||
$order->save(['status' => 20, 'model' => 'weixin']);
|
||||
$MemberInfo = MemberInfo::get($order->uid);
|
||||
$time = ($MemberInfo->is_vip == 1) ? $MemberInfo->vip_end_time : time();
|
||||
MemberInfo::update(['is_vip' => 1, 'vip_time' => $time + 31536000], ['uid' => $order->uid]);
|
||||
ScoreService::vip($order->uid);
|
||||
Wechat\Pay::returnNotify();
|
||||
} else {
|
||||
Wechat\Pay::returnNotify('处理失败');
|
||||
}
|
||||
}
|
||||
}
|
||||
32
application/openapi/controller/Wechat.php
Normal file
32
application/openapi/controller/Wechat.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
// +------------------------------------------------+
|
||||
// |http://www.cjango.com |
|
||||
// +------------------------------------------------+
|
||||
// | 修复BUG不是一朝一夕的事情,等我喝醉了再说吧! |
|
||||
// +------------------------------------------------+
|
||||
// | Author: 小陈叔叔 <Jason.Chen> |
|
||||
// +------------------------------------------------+
|
||||
namespace app\openapi\controller;
|
||||
|
||||
use cjango\Wechat as Wx;
|
||||
use think\Config;
|
||||
use think\Request;
|
||||
|
||||
class Wechat
|
||||
{
|
||||
|
||||
private $request;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$config = Config::get('wechat');
|
||||
Wx::instance($config);
|
||||
Wx::valid();
|
||||
$this->request = Wx\Reply::request();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
Wx\Reply::response($this->request['content']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user