软路由产品
This commit is contained in:
79
app/common/Alipay.php
Normal file
79
app/common/Alipay.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace app\common;
|
||||
|
||||
use extend\alipay\Alipay as AlipaySdk;
|
||||
|
||||
|
||||
class Alipay {
|
||||
|
||||
/**
|
||||
* @description: 获取支付宝是否支付成功
|
||||
* @param {*}
|
||||
* @return {*}
|
||||
*/
|
||||
public function alipayVerify() {
|
||||
|
||||
$ali = new AlipaySdk();
|
||||
|
||||
$flag = $ali->payVerify($_POST);
|
||||
|
||||
if($flag){
|
||||
|
||||
$status = $_POST['trade_status'];
|
||||
|
||||
$flag = false;
|
||||
|
||||
if ($status == 'TRADE_SUCCESS' && $_POST['auth_app_id'] == '2021002102631089' && $_POST['seller_id'] = '2088431603383955') {
|
||||
$flag = true;
|
||||
}
|
||||
|
||||
if ($flag) {
|
||||
|
||||
$invest_service = new InvestModel();
|
||||
$update_data = [];
|
||||
$order_no=$_POST['out_trade_no'];
|
||||
$alipay_no = $_POST['trade_no'];
|
||||
|
||||
|
||||
|
||||
//获取充值信息
|
||||
$invest_info = $invest_service->getOne(['order_no'=>$order_no]);
|
||||
|
||||
//更新余额
|
||||
$user_model = new UserModel();
|
||||
|
||||
$money = abs($invest_info['money']);
|
||||
$userid = $invest_info['user_id'];
|
||||
|
||||
$balance = $user_model->getOne(['id'=>$userid],'balance')['balance'];
|
||||
$old_balance= $balance;
|
||||
|
||||
$balance += $money;
|
||||
|
||||
$data = [
|
||||
'balance' => $balance
|
||||
];
|
||||
|
||||
$user_model->updateOne(['id'=>$userid,'balance'=>$old_balance],$data);
|
||||
$balance_model = new BalanceModel();
|
||||
$balance_data = [
|
||||
'user_id' => $userid,
|
||||
'money' => $money,
|
||||
'old_balance' => $old_balance,
|
||||
'new_balance' => $balance,
|
||||
'type' => 1,
|
||||
];
|
||||
$balance_model->add($balance_data);
|
||||
//更新充值订单
|
||||
$update_data['alipay_no'] = $alipay_no;
|
||||
$update_data['status'] = 1;
|
||||
$update_data['old_money'] = $old_balance;
|
||||
$update_data['new_money'] = $balance;
|
||||
$invest_service->updateOne(['order_no'=>$order_no],$update_data);
|
||||
}
|
||||
}
|
||||
|
||||
echo 'success';
|
||||
}
|
||||
}
|
||||
48
app/ros/controller/Buyer.php
Normal file
48
app/ros/controller/Buyer.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace app\ros\controller;
|
||||
|
||||
use app\ros\model\Product as ProductModel;
|
||||
use app\ros\model\Buyer as BuyerModel;
|
||||
use fastphp\base\Controller;
|
||||
|
||||
class Buyer extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('','');
|
||||
if (empty($this->userinfo['UserId'])) {
|
||||
die;
|
||||
}
|
||||
}
|
||||
|
||||
//获取产品列表
|
||||
public function getBuyerInfo() {
|
||||
$buyer_model = new BuyerModel();
|
||||
|
||||
$info = $buyer_model->getOne(['user_id'=>$this->userinfo['UserId']]);
|
||||
echo json_encode($info);
|
||||
}
|
||||
|
||||
public function updateBuyerInfo() {
|
||||
$userinfo = json_decode(file_get_contents("php://input"),true)['user_info'];
|
||||
$userinfo['user_id'] = $this->userinfo['UserId'];
|
||||
|
||||
if (empty($userinfo['name']) || empty($userinfo['phone']) || empty($userinfo['address'])) {
|
||||
echo json_encode(['code' => -1]);
|
||||
die;
|
||||
}
|
||||
|
||||
$buyer_model = new BuyerModel();
|
||||
|
||||
$info = $buyer_model->getOne(['user_id'=>$this->userinfo['UserId']]);
|
||||
|
||||
$flag = false;
|
||||
if (empty($info)) {
|
||||
$flag = $buyer_model->add($userinfo);
|
||||
} else {
|
||||
$flag = $buyer_model->updateOne(['user_id'=>$this->userinfo['UserId']],$userinfo);
|
||||
}
|
||||
echo json_encode(['code' => 1]);
|
||||
}
|
||||
}
|
||||
16
app/ros/controller/Index.php
Normal file
16
app/ros/controller/Index.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace app\ros\controller;
|
||||
|
||||
use app\ros\model\Product as ProductModel;
|
||||
|
||||
class Index
|
||||
{
|
||||
//获取产品列表
|
||||
public function getList() {
|
||||
$product_model = new ProductModel();
|
||||
|
||||
$list = $product_model->getList([],'*','id asc');
|
||||
echo json_encode($list);
|
||||
}
|
||||
}
|
||||
18
app/ros/controller/Product.php
Normal file
18
app/ros/controller/Product.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace app\ros\controller;
|
||||
|
||||
use app\ros\model\Product as ProductModel;
|
||||
use app\ros\model\Buyer as BuyerModel;
|
||||
use fastphp\base\Controller;
|
||||
|
||||
class Product extends Controller
|
||||
{
|
||||
//获取产品列表
|
||||
public function getBuyerInfo() {
|
||||
$buyer_model = new BuyerModel();
|
||||
|
||||
$info = $buyer_model->getOne(['user_id'=>$this->userinfo['UserId']]);
|
||||
echo json_encode($info);
|
||||
}
|
||||
}
|
||||
9
app/ros/model/Buyer.php
Normal file
9
app/ros/model/Buyer.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
namespace app\ros\model;
|
||||
|
||||
use fastphp\base\Model;
|
||||
|
||||
class Buyer extends Model
|
||||
{
|
||||
protected $table = 'ros_buyer';
|
||||
}
|
||||
9
app/ros/model/Product.php
Normal file
9
app/ros/model/Product.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
namespace app\ros\model;
|
||||
|
||||
use fastphp\base\Model;
|
||||
|
||||
class Product extends Model
|
||||
{
|
||||
protected $table = 'ros_product';
|
||||
}
|
||||
Reference in New Issue
Block a user