1
0

first commit

This commit is contained in:
2020-08-06 14:58:51 +08:00
commit 17096657dc
780 changed files with 92857 additions and 0 deletions

View File

@@ -0,0 +1,67 @@
<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\mobile\controller;
use app\common\service\Score as ScoreService;
use app\common\service\Vip as VipService;
use cjango\Wechat;
class Pay extends _Init
{
public function vip($openid = '')
{
parent::initWechat();
if (!$openid) {
$url = Wechat\Oauth::url(url('Pay/getOpenId', 'callback=' . __SELF__));
$this->redirect($url);
}
$fee = 298;
$res = VipService::createPayOrder(UID, $fee, $openid);
if ($res['code'] != 1) {
return $res['msg'];
exit();
}
$this->orderid = $res['data'];
parent::initWechat();
$this->payParams = Wechat\Pay::unified($this->orderid, '超级助手VIP有效期一年', $fee, 'JSAPI', url('openapi/pay/vip'), $openid);
if ($this->payParams == false) {
echo Wechat::error();
exit();
}
return $this->fetch();
}
public function getOpenId($callback)
{
parent::initWechat();
$token = Wechat\Oauth::token();
if ($token) {
$openid = $token['openid'];
$this->redirect($callback . '?openid=' . $openid);
} else {
echo Wechat::error();
}
}
/**
* 兑换会员
* @param [type] $orderid [description]
* @return [type] [description]
*/
public function exchange($orderid)
{
$res = ScoreService::buyVip(UID, $orderid);
if ($res == 1) {
$res = true;
}
return $this->back($res);
}
}