淘宝退款资金明细
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
* @Author: kangkang
|
||||
* @Date: 2020-10-13 19:52:37
|
||||
* @LastEditors: kangkang
|
||||
* @LastEditTime: 2020-10-14 22:10:49
|
||||
* @LastEditTime: 2020-10-15 17:51:08
|
||||
*/
|
||||
/*
|
||||
* @Descripttion:
|
||||
@@ -20,16 +20,17 @@ namespace app\order\controller;
|
||||
|
||||
use app\order\model\TbRefund as RefundMOdel;
|
||||
use app\order\model\User as UserModel;
|
||||
use app\order\model\UserScore as ScoreModel;
|
||||
use enum\order\TbRefund as RefundEnum;
|
||||
use fastphp\base\Controller;
|
||||
|
||||
class TbRefund extends Controller
|
||||
{
|
||||
function list() {
|
||||
public function refundList()
|
||||
{
|
||||
$refund = new RefundMOdel;
|
||||
$list = $refund->getListPage();
|
||||
foreach ($list as &$v) {
|
||||
$v['Phone'] = substr($v['Phone'], 0, 3) . '***' . substr($v['Phone'], -3);
|
||||
$v['status'] = RefundEnum::$refundStatus[$v['status']];
|
||||
}
|
||||
$count = $refund->getCount();
|
||||
@@ -50,7 +51,6 @@ class TbRefund extends Controller
|
||||
$refund = new RefundMOdel;
|
||||
$list = $refund->getListPage([], '*', 'id desc', "$page,50");
|
||||
foreach ($list as &$v) {
|
||||
$v['Phone'] = substr($v['Phone'], 0, 3) . '***' . substr($v['Phone'], -3);
|
||||
$v['status'] = RefundEnum::$refundStatus[$v['status']];
|
||||
}
|
||||
$data = [
|
||||
@@ -72,12 +72,11 @@ class TbRefund extends Controller
|
||||
$count = $refund->getCount();
|
||||
}
|
||||
foreach ($list as &$v) {
|
||||
$v['Phone'] = substr($v['Phone'], 0, 3) . '***' . substr($v['Phone'], -3);
|
||||
$v['status'] = RefundEnum::$refundStatus[$v['status']];
|
||||
}
|
||||
$data = [
|
||||
'Code' => 10000,
|
||||
'count' => $count['count'] ?? 0,
|
||||
'count' => isset($count['count']) ? $count['count'] : 0,
|
||||
'data' => $list,
|
||||
];
|
||||
echo json_encode($data);
|
||||
@@ -118,13 +117,13 @@ class TbRefund extends Controller
|
||||
$refund = new RefundMOdel;
|
||||
$update_data['handle_user'] = $user['LoginName'];
|
||||
|
||||
$refund_info = $refund->getOne(['Id'=>$id]);
|
||||
|
||||
$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){
|
||||
if ($returnOk < 0) {
|
||||
$return = [
|
||||
'Code' => 30000,
|
||||
'msg' => '余额不足',
|
||||
@@ -133,16 +132,33 @@ class TbRefund extends Controller
|
||||
die;
|
||||
} else {
|
||||
$update_data['f_balance'] = $user_info['RestAmount'];
|
||||
if ($refund->updateOne(['Id' => $id],$update_data)) {
|
||||
$userModel->updateOne(['LoginCode' => $refund_info['Phone']],['RestAmount' => $returnOk]);
|
||||
if ($refund->updateOne(['Id' => $id], $update_data)) {
|
||||
$userModel->updateOne(['LoginCode' => $refund_info['Phone']], ['RestAmount' => $returnOk]);
|
||||
//记录资金明细
|
||||
$score_data = [
|
||||
'UserId' => $user_info['Id'],
|
||||
'ScoreType' => 4,
|
||||
'ScoreTypeName' => '淘宝退款扣除',
|
||||
'ScoreValue' => $refund_info["RefundFee"],
|
||||
'Remark' => $refund_info["Tid"],
|
||||
'UserName' => $refund_info['Phone'],
|
||||
'OperateUserName' => $user['LoginName'],
|
||||
'RestAmount1' => $user_info['RestAmount'],
|
||||
'RestAmount2' => $returnOk,
|
||||
'CreateTime' => date('Y-m-d H:i:s',time()),
|
||||
'UpdateTime' => date('Y-m-d H:i:s',time()),
|
||||
'TenantId' => 0,
|
||||
'DeleteTag' => 0,
|
||||
];
|
||||
$score = new ScoreModel;
|
||||
$score->add($score_data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$return = [
|
||||
'Code' => 30000,
|
||||
'msg' => '操作成功',
|
||||
'balance' => $update_data['f_balance']
|
||||
'balance' => $update_data['f_balance'],
|
||||
];
|
||||
echo json_encode($return);
|
||||
}
|
||||
|
||||
21
app/order/model/UserScore.php
Normal file
21
app/order/model/UserScore.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
/*
|
||||
* @Descripttion:
|
||||
* @version:
|
||||
* @Author: kangkang
|
||||
* @Date: 2020-10-15 17:31:30
|
||||
* @LastEditors: kangkang
|
||||
* @LastEditTime: 2020-10-15 17:32:22
|
||||
*/
|
||||
|
||||
namespace app\order\model;
|
||||
|
||||
use fastphp\base\Model;
|
||||
|
||||
class UserScore extends Model
|
||||
{
|
||||
protected $table = 'user_score';
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
* @Author: kangkang
|
||||
* @Date: 2020-09-30 17:32:46
|
||||
* @LastEditors: kangkang
|
||||
* @LastEditTime: 2020-10-15 14:02:27
|
||||
* @LastEditTime: 2020-10-15 17:31:20
|
||||
*/
|
||||
|
||||
return [
|
||||
|
||||
Reference in New Issue
Block a user