淘宝退款

This commit is contained in:
wanyongkang
2020-10-15 14:03:09 +08:00
parent 91a914bcc4
commit 729b32f0a4
6 changed files with 78 additions and 15 deletions

View File

@@ -5,7 +5,7 @@
* @Author: kangkang
* @Date: 2020-10-13 19:52:37
* @LastEditors: kangkang
* @LastEditTime: 2020-10-14 20:12:00
* @LastEditTime: 2020-10-14 22:10:49
*/
/*
* @Descripttion:
@@ -19,6 +19,7 @@
namespace app\order\controller;
use app\order\model\TbRefund as RefundMOdel;
use app\order\model\User as UserModel;
use enum\order\TbRefund as RefundEnum;
use fastphp\base\Controller;
@@ -105,14 +106,45 @@ class TbRefund extends Controller
/**
* @description: 处理退款
* @param {type}
* @return {type}
* @param {type}
* @return {type}
*
*/
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'];
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
View 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';
}

View File

@@ -5,7 +5,7 @@
* @Author: kangkang
* @Date: 2020-09-30 17:32:46
* @LastEditors: kangkang
* @LastEditTime: 2020-10-14 20:16:32
* @LastEditTime: 2020-10-15 14:02:27
*/
return [
@@ -32,7 +32,10 @@ return [
// 跨域请求
'origin' => [
'http://www.juip.wyk',
'http://admin.juip.wyk'
'http://admin.juip.wyk',
'http://www.juip.com',
'http://juip.com',
'http://hl957admin.juip.com',
],
//支付宝
'alipay' => [

View File

@@ -5,7 +5,7 @@
* @Author: kangkang
* @Date: 2020-10-14 19:32:50
* @LastEditors: kangkang
* @LastEditTime: 2020-10-14 19:44:19
* @LastEditTime: 2020-10-14 21:13:48
*/
namespace enum\order;
@@ -14,7 +14,7 @@ class TbRefund
{
//淘宝退款状态
public static $refundStatus = [
0 => '待处理',
0 => '申请中',
1 => '已同意',
2 => '已拒绝',
3 => '已关闭',

View File

@@ -34,7 +34,7 @@ class Jwt {
* ]
* @return bool|string
*/
public static function getToken(array $payload)
public static function getToken($payload)
{
if(is_array($payload))
{
@@ -53,7 +53,7 @@ class Jwt {
* @param string $Token 需要验证的token
* @return bool|string
*/
public static function verifyToken(string $Token)
public static function verifyToken($Token)
{
$tokens = explode('.', $Token);
if (count($tokens) != 3)
@@ -95,7 +95,7 @@ class Jwt {
* @param string $input 需要编码的字符串
* @return string
*/
private static function base64UrlEncode(string $input)
private static function base64UrlEncode($input)
{
return str_replace('=', '', strtr(base64_encode($input), '+/', '-_'));
}
@@ -105,7 +105,7 @@ class Jwt {
* @param string $input 需要解码的字符串
* @return bool|string
*/
private static function base64UrlDecode(string $input)
private static function base64UrlDecode($input)
{
$remainder = strlen($input) % 4;
if ($remainder) {
@@ -122,7 +122,7 @@ class Jwt {
* @param string $alg 算法方式
* @return mixed
*/
private static function signature(string $input, string $key, string $alg = 'HS256')
private static function signature($input, $key, $alg)
{
$alg_config=array(
'HS256'=>'sha256'

View File

@@ -2,7 +2,7 @@
/*
* @Author: your name
* @Date: 2020-09-30 17:32:46
* @LastEditTime: 2020-10-14 20:02:14
* @LastEditTime: 2020-10-14 20:40:36
* @LastEditors: kangkang
* @Description: In User Settings Edit
* @FilePath: /phptest/fastphp/base/Model.php
@@ -61,5 +61,14 @@ class Model extends Sql
{
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);
}
}