淘宝退款
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
* @Author: kangkang
|
* @Author: kangkang
|
||||||
* @Date: 2020-10-13 19:52:37
|
* @Date: 2020-10-13 19:52:37
|
||||||
* @LastEditors: kangkang
|
* @LastEditors: kangkang
|
||||||
* @LastEditTime: 2020-10-14 20:12:00
|
* @LastEditTime: 2020-10-14 22:10:49
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
* @Descripttion:
|
* @Descripttion:
|
||||||
@@ -19,6 +19,7 @@
|
|||||||
namespace app\order\controller;
|
namespace app\order\controller;
|
||||||
|
|
||||||
use app\order\model\TbRefund as RefundMOdel;
|
use app\order\model\TbRefund as RefundMOdel;
|
||||||
|
use app\order\model\User as UserModel;
|
||||||
use enum\order\TbRefund as RefundEnum;
|
use enum\order\TbRefund as RefundEnum;
|
||||||
use fastphp\base\Controller;
|
use fastphp\base\Controller;
|
||||||
|
|
||||||
@@ -107,12 +108,43 @@ class TbRefund extends Controller
|
|||||||
* @description: 处理退款
|
* @description: 处理退款
|
||||||
* @param {type}
|
* @param {type}
|
||||||
* @return {type}
|
* @return {type}
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
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)['row'];
|
||||||
$id = $data['Id'];
|
$id = $data['Id'];
|
||||||
dump($data);
|
$user = $this->userinfo;
|
||||||
|
$refund = new RefundMOdel;
|
||||||
|
$update_data['handle_user'] = $user['LoginName'];
|
||||||
|
|
||||||
|
$refund_info = $refund->getOne(['Id'=>$id]);
|
||||||
|
|
||||||
|
$userModel = new UserModel;
|
||||||
|
$user_info = $userModel->getOne(['LoginCode' => $refund_info['Phone']]);
|
||||||
|
//判断余额是否大于退款金额
|
||||||
|
$returnOk = $user_info['RestAmount'] - $refund_info["RefundFee"];
|
||||||
|
if($returnOk < 0){
|
||||||
|
$return = [
|
||||||
|
'Code' => 30000,
|
||||||
|
'msg' => '余额不足',
|
||||||
|
];
|
||||||
|
echo json_encode($return);
|
||||||
|
die;
|
||||||
|
} else {
|
||||||
|
$update_data['f_balance'] = $user_info['RestAmount'];
|
||||||
|
if ($refund->updateOne(['Id' => $id],$update_data)) {
|
||||||
|
$userModel->updateOne(['LoginCode' => $refund_info['Phone']],['RestAmount' => $returnOk]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$return = [
|
||||||
|
'Code' => 30000,
|
||||||
|
'msg' => '操作成功',
|
||||||
|
'balance' => $update_data['f_balance']
|
||||||
|
];
|
||||||
|
echo json_encode($return);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
19
app/order/model/User.php
Normal file
19
app/order/model/User.php
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* @Descripttion:
|
||||||
|
* @version:
|
||||||
|
* @Author: kangkang
|
||||||
|
* @Date: 2020-10-14 20:25:53
|
||||||
|
* @LastEditors: kangkang
|
||||||
|
* @LastEditTime: 2020-10-14 20:26:11
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
namespace app\order\model;
|
||||||
|
|
||||||
|
use fastphp\base\Model;
|
||||||
|
|
||||||
|
class User extends Model
|
||||||
|
{
|
||||||
|
protected $table = 'user';
|
||||||
|
}
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
* @Author: kangkang
|
* @Author: kangkang
|
||||||
* @Date: 2020-09-30 17:32:46
|
* @Date: 2020-09-30 17:32:46
|
||||||
* @LastEditors: kangkang
|
* @LastEditors: kangkang
|
||||||
* @LastEditTime: 2020-10-14 20:16:32
|
* @LastEditTime: 2020-10-15 14:02:27
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return [
|
return [
|
||||||
@@ -32,7 +32,10 @@ return [
|
|||||||
// 跨域请求
|
// 跨域请求
|
||||||
'origin' => [
|
'origin' => [
|
||||||
'http://www.juip.wyk',
|
'http://www.juip.wyk',
|
||||||
'http://admin.juip.wyk'
|
'http://admin.juip.wyk',
|
||||||
|
'http://www.juip.com',
|
||||||
|
'http://juip.com',
|
||||||
|
'http://hl957admin.juip.com',
|
||||||
],
|
],
|
||||||
//支付宝
|
//支付宝
|
||||||
'alipay' => [
|
'alipay' => [
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
* @Author: kangkang
|
* @Author: kangkang
|
||||||
* @Date: 2020-10-14 19:32:50
|
* @Date: 2020-10-14 19:32:50
|
||||||
* @LastEditors: kangkang
|
* @LastEditors: kangkang
|
||||||
* @LastEditTime: 2020-10-14 19:44:19
|
* @LastEditTime: 2020-10-14 21:13:48
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace enum\order;
|
namespace enum\order;
|
||||||
@@ -14,7 +14,7 @@ class TbRefund
|
|||||||
{
|
{
|
||||||
//淘宝退款状态
|
//淘宝退款状态
|
||||||
public static $refundStatus = [
|
public static $refundStatus = [
|
||||||
0 => '待处理',
|
0 => '申请中',
|
||||||
1 => '已同意',
|
1 => '已同意',
|
||||||
2 => '已拒绝',
|
2 => '已拒绝',
|
||||||
3 => '已关闭',
|
3 => '已关闭',
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class Jwt {
|
|||||||
* ]
|
* ]
|
||||||
* @return bool|string
|
* @return bool|string
|
||||||
*/
|
*/
|
||||||
public static function getToken(array $payload)
|
public static function getToken($payload)
|
||||||
{
|
{
|
||||||
if(is_array($payload))
|
if(is_array($payload))
|
||||||
{
|
{
|
||||||
@@ -53,7 +53,7 @@ class Jwt {
|
|||||||
* @param string $Token 需要验证的token
|
* @param string $Token 需要验证的token
|
||||||
* @return bool|string
|
* @return bool|string
|
||||||
*/
|
*/
|
||||||
public static function verifyToken(string $Token)
|
public static function verifyToken($Token)
|
||||||
{
|
{
|
||||||
$tokens = explode('.', $Token);
|
$tokens = explode('.', $Token);
|
||||||
if (count($tokens) != 3)
|
if (count($tokens) != 3)
|
||||||
@@ -95,7 +95,7 @@ class Jwt {
|
|||||||
* @param string $input 需要编码的字符串
|
* @param string $input 需要编码的字符串
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private static function base64UrlEncode(string $input)
|
private static function base64UrlEncode($input)
|
||||||
{
|
{
|
||||||
return str_replace('=', '', strtr(base64_encode($input), '+/', '-_'));
|
return str_replace('=', '', strtr(base64_encode($input), '+/', '-_'));
|
||||||
}
|
}
|
||||||
@@ -105,7 +105,7 @@ class Jwt {
|
|||||||
* @param string $input 需要解码的字符串
|
* @param string $input 需要解码的字符串
|
||||||
* @return bool|string
|
* @return bool|string
|
||||||
*/
|
*/
|
||||||
private static function base64UrlDecode(string $input)
|
private static function base64UrlDecode($input)
|
||||||
{
|
{
|
||||||
$remainder = strlen($input) % 4;
|
$remainder = strlen($input) % 4;
|
||||||
if ($remainder) {
|
if ($remainder) {
|
||||||
@@ -122,7 +122,7 @@ class Jwt {
|
|||||||
* @param string $alg 算法方式
|
* @param string $alg 算法方式
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
private static function signature(string $input, string $key, string $alg = 'HS256')
|
private static function signature($input, $key, $alg)
|
||||||
{
|
{
|
||||||
$alg_config=array(
|
$alg_config=array(
|
||||||
'HS256'=>'sha256'
|
'HS256'=>'sha256'
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
/*
|
/*
|
||||||
* @Author: your name
|
* @Author: your name
|
||||||
* @Date: 2020-09-30 17:32:46
|
* @Date: 2020-09-30 17:32:46
|
||||||
* @LastEditTime: 2020-10-14 20:02:14
|
* @LastEditTime: 2020-10-14 20:40:36
|
||||||
* @LastEditors: kangkang
|
* @LastEditors: kangkang
|
||||||
* @Description: In User Settings Edit
|
* @Description: In User Settings Edit
|
||||||
* @FilePath: /phptest/fastphp/base/Model.php
|
* @FilePath: /phptest/fastphp/base/Model.php
|
||||||
@@ -61,5 +61,14 @@ class Model extends Sql
|
|||||||
{
|
{
|
||||||
return $this->field($fields)->where($where)->limit('1')->fetch();
|
return $this->field($fields)->where($where)->limit('1')->fetch();
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @description: 更新一条数据
|
||||||
|
* @param {type}
|
||||||
|
* @return {type}
|
||||||
|
*/
|
||||||
|
public function updateOne($where = [], $data = [])
|
||||||
|
{
|
||||||
|
return $this->where($where)->update($data);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user