This commit is contained in:
wanyongkang
2020-10-13 09:38:55 +08:00
parent 517b026891
commit 7d7d8f09ad
5 changed files with 245 additions and 102 deletions

View File

@@ -1,4 +1,12 @@
<?php <?php
/*
* @Author: 万永康
* @Date: 2020-10-11 12:32:50
* @LastEditTime: 2020-10-12 10:29:34
* @LastEditors: Please set LastEditors
* @Description: In User Settings Edit
* @FilePath: /phptest/alipay/Alipay.php
*/
namespace alipay; namespace alipay;
@@ -6,8 +14,7 @@ require_once APP_PATH.'aop/AopClient.php';
require_once APP_PATH . 'aop/AopCertification.php'; require_once APP_PATH . 'aop/AopCertification.php';
require_once APP_PATH . 'aop/request/AlipayTradeQueryRequest.php'; require_once APP_PATH . 'aop/request/AlipayTradeQueryRequest.php';
require_once APP_PATH . 'aop/request/AlipayTradePagePayRequest.php'; require_once APP_PATH . 'aop/request/AlipayTradePagePayRequest.php';
require_once APP_PATH.'aop/request/AlipayTradeAppPayRequest.php'; require_once APP_PATH . 'aop/request/AlipayFundTransUniTransferRequest.php';
/** /**
* 证书类型AopClient功能方法使用测试 * 证书类型AopClient功能方法使用测试
@@ -16,7 +23,8 @@ require_once APP_PATH.'aop/request/AlipayTradeAppPayRequest.php';
* 3、pageExecute 调用示例 * 3、pageExecute 调用示例
*/ */
class Alipay { class Alipay
{
//配置内容 //配置内容
protected static $config = []; protected static $config = [];
@@ -40,8 +48,8 @@ require_once APP_PATH.'aop/request/AlipayTradeAppPayRequest.php';
* *
* *
*/ */
public static function pay($param){ public static function pay($param)
//1、execute 使用 {
$aop = new \AopClient(); $aop = new \AopClient();
$aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do'; $aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';
@@ -62,4 +70,48 @@ require_once APP_PATH.'aop/request/AlipayTradeAppPayRequest.php';
echo $result; echo $result;
} }
/**
* @description: 转帐到支付宝账户
* @param {type}$param
* [
* 'out_biz_no'=>'201806300001',
* 'trans_amount' => '0.01',
* 'product_code' => 'TRANS_ACCOUNT_NO_PWD',
* 'payee_info' => {
* 'identity' => '208812*****41234',
* 'identity_type' => 'ALIPAY_LOGON_ID',
* 'name' => 'peter'
* },
* 'remark' => '提现-单笔转帐'
* ]
* @return {type}
*/
public static function transfer()
{
$aop = new \AopClient();
$aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';
$aop->appId = self::$config['alipay']['app_id'];
$aop->rsaPrivateKey = self::$config['alipay']['private_key'];
$aop->alipayrsaPublicKey = self::$config['alipay']['public_key'];
$aop->apiVersion = '1.0';
$aop->signType = 'RSA2';
$aop->postCharset = 'utf-8';
$aop->format = 'json';
$request = new \AlipayFundTransUniTransferRequest();
$param = json_encode($param);
$request->setBizContent($param);
$result = $aop->execute ( $request);
$responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
$resultCode = $result->$responseNode->code;
if(!empty($resultCode)&&$resultCode == 10000){
return true;
} else {
return false;
}
}
} }

View File

@@ -1,10 +1,17 @@
<?php <?php
/*
* @Descripttion:
* @version:
* @Author: kangkang
* @Date: 2020-10-11 11:22:56
* @LastEditors: kangkang
* @LastEditTime: 2020-10-12 12:06:20
*/
namespace app\order\controller; namespace app\order\controller;
use app\order\model\CashOut as CashMoedl; use app\order\model\CashOut as CashMoedl;
use fastphp\base\Controller; use fastphp\base\Controller;
use alipay\Alipay;
class Admin extends Controller class Admin extends Controller
{ {
@@ -36,7 +43,13 @@ class Admin extends Controller
} }
$page = ($_GET['page'] - 1) * 50; $page = ($_GET['page'] - 1) * 50;
$cash = new CashMoedl; $cash = new CashMoedl;
$list = $cash->getListPage('*', 'id desc', "$page,50"); $list = $cash->getListPage([], '*', 'id desc', "$page,50");
//提现状态
$status = ['待处理', '同意', '拒绝'];
foreach ($list as &$v) {
$v['status'] = $status[$v['status']];
$v['alipay_account'] = substr($v['alipay_account'], 0, 3) . '***' . substr($v['alipay_account'], -3);
}
$data = [ $data = [
'Code' => 10000, 'Code' => 10000,
'data' => $list, 'data' => $list,
@@ -44,7 +57,11 @@ class Admin extends Controller
echo json_encode($data); echo json_encode($data);
} }
//处理提现申请 /**
* @description: 订单搜索
* @param {type} 搜索会员账号
* @return {type} 该会员所有的订单信息 按照id倒序
*/
public function handle() public function handle()
{ {
$data = json_decode(file_get_contents("php://input"), true)['info']; $data = json_decode(file_get_contents("php://input"), true)['info'];
@@ -67,5 +84,29 @@ class Admin extends Controller
echo json_encode($return_info); echo json_encode($return_info);
} }
//获取记录
public function search()
{
$username = json_decode(file_get_contents("php://input"), true)['username'];
$cash = new CashMoedl;
if ($username) {
$list = $cash->getListPage(['username' => $username], '*', 'id desc', '100');
} else {
$list = $cash->getListPage();
$count = $cash->getCount();
}
//提现状态
$status = ['待处理', '同意', '拒绝'];
foreach ($list as &$v) {
$v['status'] = $status[$v['status']];
$v['alipay_account'] = substr($v['alipay_account'], 0, 3) . '***' . substr($v['alipay_account'], -3);
}
$data = [
'Code' => 10000,
'count' => $count['count'] ?? 0,
'data' => $list,
];
echo json_encode($data);
}
} }

View File

@@ -1,4 +1,12 @@
<?php <?php
/*
* @Author: your name
* @Date: 2020-10-10 13:58:14
* @LastEditTime: 2020-10-12 11:15:09
* @LastEditors: your name
* @Description: In User Settings Edit
* @FilePath: /phptest/app/order/controller/Index.php
*/
namespace app\order\controller; namespace app\order\controller;
@@ -26,4 +34,24 @@ class Index extends Controller
} }
} }
//获取记录
public function getData()
{
$cash = new CashMoedl;
$list = $cash->getListPage([],'username,money,apply_reason,alipay_account,status,create_time');
//提现状态
$status = ['待处理', '提现成功', '提现未成功'];
foreach ($list as &$v) {
$v['status'] = $status[$v['status']];
$v['alipay_account'] = substr($v['alipay_account'], 0, 3) . '***' . substr($v['alipay_account'], -5);
}
$count = $cash->getCount();
$data = [
'Code' => 10000,
'count' => $count['count'],
'data' => $list,
];
echo json_encode($data);
}
} }

View File

@@ -1,5 +1,12 @@
<?php <?php
/*
* @Author: your name
* @Date: 2020-09-30 17:32:46
* @LastEditTime: 2020-10-12 11:16:10
* @LastEditors: Please set LastEditors
* @Description: In User Settings Edit
* @FilePath: /phptest/fastphp/base/Model.php
*/
namespace fastphp\base; namespace fastphp\base;
@@ -28,8 +35,9 @@ class Model extends Sql
* 获取总数目 * 获取总数目
* *
*/ */
public function getCount(){ public function getCount($where = [])
return $this->field('count(1) as count')->fetch(); {
return $this->field('count(1) as count')->where($where)->fetch();
} }
/** /**
@@ -39,9 +47,10 @@ class Model extends Sql
* @param $limit = '100' 限制查询100条 * @param $limit = '100' 限制查询100条
* $limit = '2,100' 查询第二页 100条数据 * $limit = '2,100' 查询第二页 100条数据
*/ */
public function getListPage($fields = '*',$order = 'id desc', $page = '50') public function getListPage($where = [],$fields = '*', $order = 'id desc', $limit = '50')
{ {
return $this->field($fields)->order($order)->limit($page)->fetchAll(); return $this->field($fields)->where($where)->order($order)->limit($limit)->fetchAll();
} }
} }

View File

@@ -1,6 +1,5 @@
<?php <?php
namespace fastphp\db; namespace fastphp\db;
use \PDOStatement; use \PDOStatement;
@@ -27,7 +26,8 @@ class Sql
* 多条件查询 * 多条件查询
* ['id'=>['<',100]] * ['id'=>['<',100]]
*/ */
public function where($where){ public function where($where)
{
$this->param = []; $this->param = [];
$this->filter = ''; $this->filter = '';
if ($where) { if ($where) {
@@ -67,21 +67,22 @@ class Sql
* @return $this * @return $this
* $order='id desc' * $order='id desc'
*/ */
public function order($order = 'id desc'){ public function order($order = 'id desc')
{
if ($order) { if ($order) {
$this->filter .= ' ORDER BY ' . $order . ' '; $this->filter .= ' ORDER BY ' . $order . ' ';
} }
return $this; return $this;
} }
/** /**
* group by * group by
* @param array $order * @param array $order
* @return $this * @return $this
* $group=['sex','name'] * $group=['sex','name']
*/ */
public function group($group = []){ public function group($group = [])
{
if ($order) { if ($order) {
$this->filter .= ' GROUP BY '; $this->filter .= ' GROUP BY ';
$this->filter .= ' ' . implode(' ,', $group) . ' '; $this->filter .= ' ' . implode(' ,', $group) . ' ';
@@ -96,7 +97,8 @@ class Sql
* $limit = '100' 限制查询100条 * $limit = '100' 限制查询100条
* $limit = '2,100' 查询第二页 100条数据 * $limit = '2,100' 查询第二页 100条数据
*/ */
public function limit($limit = '100'){ public function limit($limit = '100')
{
$this->filter .= ' LIMIT ' . $limit . ' '; $this->filter .= ' LIMIT ' . $limit . ' ';
return $this; return $this;
} }
@@ -107,7 +109,8 @@ class Sql
* @return $this * @return $this
* $field = 'id,count(1),sub(num)' * $field = 'id,count(1),sub(num)'
*/ */
public function field($field = '*'){ public function field($field = '*')
{
$this->field = $field; $this->field = $field;
return $this; return $this;
} }
@@ -116,7 +119,8 @@ class Sql
* 查询所有 * 查询所有
* @return mixed * @return mixed
*/ */
public function fetchAll(){ public function fetchAll()
{
$sql = sprintf('SELECT %s FROM `%s` %s', $this->field, $this->table, $this->filter); $sql = sprintf('SELECT %s FROM `%s` %s', $this->field, $this->table, $this->filter);
$this->filter = ''; $this->filter = '';
$sth = Db::pdo()->prepare($sql); $sth = Db::pdo()->prepare($sql);
@@ -130,7 +134,8 @@ class Sql
* 查询一条 * 查询一条
* @return mixed * @return mixed
*/ */
public function fetch(){ public function fetch()
{
$sql = sprintf('SELECT %s FROM `%s` %s', $this->field, $this->table, $this->filter); $sql = sprintf('SELECT %s FROM `%s` %s', $this->field, $this->table, $this->filter);
$this->filter = ''; $this->filter = '';
$sth = Db::pdo()->prepare($sql); $sth = Db::pdo()->prepare($sql);
@@ -145,7 +150,8 @@ class Sql
* @param $id * @param $id
* @return mixed * @return mixed
*/ */
public function delete(){ public function delete()
{
$sql = sprintf('DELETE FROM `%s` %s', $this->table, $this->filter); $sql = sprintf('DELETE FROM `%s` %s', $this->table, $this->filter);
$this->filter = ''; $this->filter = '';
$sth = Db::pdo()->prepare($sql); $sth = Db::pdo()->prepare($sql);
@@ -160,7 +166,8 @@ class Sql
* @param $data * @param $data
* @return mixed * @return mixed
*/ */
public function add($data){ public function add($data)
{
$sql = sprintf('INSERT INTO `%s` %s', $this->table, $this->formatInsert($data)); $sql = sprintf('INSERT INTO `%s` %s', $this->table, $this->formatInsert($data));
$sth = Db::pdo()->prepare($sql); $sth = Db::pdo()->prepare($sql);
$sth = $this->formatParam($sth, $data); $sth = $this->formatParam($sth, $data);
@@ -174,7 +181,8 @@ class Sql
* @param $data * @param $data
* @return int * @return int
*/ */
public function addAll($data){ public function addAll($data)
{
$sql = sprintf('INSERT INTO `%s` %s', $this->table, $this->formatInsertAll($data)); $sql = sprintf('INSERT INTO `%s` %s', $this->table, $this->formatInsertAll($data));
$sth = Db::pdo()->prepare($sql); $sth = Db::pdo()->prepare($sql);
$sth->execute(); $sth->execute();
@@ -187,7 +195,8 @@ class Sql
* @param $data * @param $data
* @return mixed * @return mixed
*/ */
public function update($data){ public function update($data)
{
$sql = sprintf('UPDATE `%s` SET %s %s', $this->table, $this->formatUpdate($data), $this->filter); $sql = sprintf('UPDATE `%s` SET %s %s', $this->table, $this->formatUpdate($data), $this->filter);
$this->filter = ''; $this->filter = '';
$sth = Db::pdo()->prepare($sql); $sth = Db::pdo()->prepare($sql);
@@ -204,7 +213,8 @@ class Sql
* @param array $params * @param array $params
* @return PDOStatement * @return PDOStatement
*/ */
public function formatParam(PDOStatement $sth,$params = []){ public function formatParam(PDOStatement $sth, $params = [])
{
foreach ($params as $param => &$value) { foreach ($params as $param => &$value) {
$param = is_int($param) ? $param + 1 : ':' . ltrim($param, ':'); $param = is_int($param) ? $param + 1 : ':' . ltrim($param, ':');
$sth->bindParam($param, $value); $sth->bindParam($param, $value);
@@ -217,7 +227,8 @@ class Sql
* @param $data * @param $data
* @return string * @return string
*/ */
private function formatInsert($data){ private function formatInsert($data)
{
$fields = []; $fields = [];
$names = []; $names = [];
foreach ($data as $key => $value) { foreach ($data as $key => $value) {
@@ -234,7 +245,8 @@ class Sql
* @param $data * @param $data
* @return string * @return string
*/ */
private function formatInsertAll($data){ private function formatInsertAll($data)
{
$fields = []; $fields = [];
$values = ''; $values = '';
foreach ($data[0] as $key => $value) { foreach ($data[0] as $key => $value) {
@@ -253,7 +265,8 @@ class Sql
* @param $data * @param $data
* @return string * @return string
*/ */
private function formatUpdate($data){ private function formatUpdate($data)
{
$fields = []; $fields = [];
foreach ($data as $key => $value) { foreach ($data as $key => $value) {
$fields[] = sprintf('`%s`=:%s', $key, $key); $fields[] = sprintf('`%s`=:%s', $key, $key);