失败的订单

This commit is contained in:
wanyongkang
2020-10-16 17:45:04 +08:00
parent 3aadd03949
commit a2b249bece
5 changed files with 108 additions and 21 deletions

View File

@@ -0,0 +1,53 @@
<?php
/*
* @Descripttion:
* @version:
* @Author: kangkang
* @Date: 2020-10-13 19:52:37
* @LastEditors: kangkang
* @LastEditTime: 2020-10-16 17:21:58
*/
/*
* @Descripttion:
* @version:
* @Author: kangkang
* @Date: 2020-10-13 19:52:37
* @LastEditors: kangkang
* @LastEditTime: 2020-10-14 20:04:16
*/
namespace app\order\controller;
use app\order\model\ProductOrder;
use fastphp\base\Controller;
class Failed extends Controller
{
public function getFailedList()
{
$page = 0;
if (isset($_GET['PageIndex'])) {
$page = ($_GET['PageIndex'] - 1) * 50;
}
if (isset($_GET['ProductId'])){
$where['ProductId'] = $_GET['ProductId'];
}
if (isset($_GET['PackageId'])){
$where['PackageId'] = $_GET['PackageId'];
}
if (!empty($_GET['keyWord'])){
$where['OrderNo'] = $_GET['keyWord'];
}
$where['Remark'] = ['like','%失败%'];
$productOrder = new ProductOrder;
$list = $productOrder->getListPage($where, '*', 'id desc', "$page,50");
$data = [
'Code' => 10000,
'Data' => $list,
'Message' => '',
'TotalCount' => (int)$productOrder->getCount(['Remark'=>['like','%失败%']]),
];
echo json_encode($data);
}
}

View File

@@ -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-15 17:51:08 * @LastEditTime: 2020-10-16 11:15:13
*/ */
/* /*
* @Descripttion: * @Descripttion:
@@ -29,9 +29,11 @@ class TbRefund extends Controller
public function refundList() public function refundList()
{ {
$refund = new RefundMOdel; $refund = new RefundMOdel;
$userModel = new UserModel;
$list = $refund->getListPage(); $list = $refund->getListPage();
foreach ($list as &$v) { foreach ($list as &$v) {
$v['status'] = RefundEnum::$refundStatus[$v['status']]; $v['status'] = RefundEnum::$refundStatus[$v['status']];
$v['account'] = $userModel->getOne(['LoginCode' => $v['Phone']])['RestAmount'];
} }
$count = $refund->getCount(); $count = $refund->getCount();
$data = [ $data = [
@@ -49,9 +51,11 @@ class TbRefund extends Controller
} }
$page = ($_GET['page'] - 1) * 50; $page = ($_GET['page'] - 1) * 50;
$refund = new RefundMOdel; $refund = new RefundMOdel;
$userModel = new UserModel;
$list = $refund->getListPage([], '*', 'id desc', "$page,50"); $list = $refund->getListPage([], '*', 'id desc', "$page,50");
foreach ($list as &$v) { foreach ($list as &$v) {
$v['status'] = RefundEnum::$refundStatus[$v['status']]; $v['status'] = RefundEnum::$refundStatus[$v['status']];
$v['account'] = $userModel->getOne(['LoginCode' => $v['Phone']])['RestAmount'];
} }
$data = [ $data = [
'Code' => 10000, 'Code' => 10000,
@@ -65,6 +69,7 @@ class TbRefund extends Controller
{ {
$Phone = json_decode(file_get_contents("php://input"), true)['Phone']; $Phone = json_decode(file_get_contents("php://input"), true)['Phone'];
$refund = new RefundMOdel; $refund = new RefundMOdel;
$userModel = new UserModel;
if ($Phone) { if ($Phone) {
$list = $refund->getListPage(['Phone' => $Phone], '*', 'id desc', '100'); $list = $refund->getListPage(['Phone' => $Phone], '*', 'id desc', '100');
} else { } else {
@@ -73,6 +78,7 @@ class TbRefund extends Controller
} }
foreach ($list as &$v) { foreach ($list as &$v) {
$v['status'] = RefundEnum::$refundStatus[$v['status']]; $v['status'] = RefundEnum::$refundStatus[$v['status']];
$v['account'] = $userModel->getOne(['LoginCode' => $v['Phone']])['RestAmount'];
} }
$data = [ $data = [
'Code' => 10000, 'Code' => 10000,
@@ -96,11 +102,7 @@ class TbRefund extends Controller
$refund = new RefundMOdel; $refund = new RefundMOdel;
$where = ['Id' => $id]; $where = ['Id' => $id];
$info = $refund->getOne($where); $info = $refund->getOne($where);
$data = [ \result($info);
'Code' => 10000,
'data' => $info,
];
echo json_encode($data);
} }
/** /**
@@ -124,12 +126,7 @@ class TbRefund extends Controller
//判断余额是否大于退款金额 //判断余额是否大于退款金额
$returnOk = $user_info['RestAmount'] - $refund_info["RefundFee"]; $returnOk = $user_info['RestAmount'] - $refund_info["RefundFee"];
if ($returnOk < 0) { if ($returnOk < 0) {
$return = [ \result([],'余额不足',30000);
'Code' => 30000,
'msg' => '余额不足',
];
echo json_encode($return);
die;
} else { } else {
$update_data['f_balance'] = $user_info['RestAmount']; $update_data['f_balance'] = $user_info['RestAmount'];
if ($refund->updateOne(['Id' => $id], $update_data)) { if ($refund->updateOne(['Id' => $id], $update_data)) {

View File

@@ -0,0 +1,18 @@
<?php
/*
* @Descripttion:
* @version:
* @Author: kangkang
* @Date: 2020-10-16 14:44:02
* @LastEditors: kangkang
* @LastEditTime: 2020-10-16 15:53:03
*/
namespace app\order\model;
use fastphp\base\Model;
class ProductOrder extends Model
{
protected $table = 'product_order';
}

View File

@@ -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-15 17:31:20 * @LastEditTime: 2020-10-16 17:44:31
*/ */
return [ return [

View File

@@ -1,4 +1,12 @@
<?php <?php
/*
* @Descripttion:
* @version:
* @Author: kangkang
* @Date: 2020-09-30 17:32:46
* @LastEditors: kangkang
* @LastEditTime: 2020-10-16 11:14:25
*/
/** /**
* 浏览器友好的变量输出 * 浏览器友好的变量输出
* @param mixed $var 变量 * @param mixed $var 变量
@@ -7,7 +15,8 @@
* @param boolean $strict 是否严谨 默认为true * @param boolean $strict 是否严谨 默认为true
* @return void|string * @return void|string
*/ */
function dd($var, $echo=true, $label=null, $strict=true) { function dd($var, $echo = true, $label = null, $strict = true)
{
echo (echoBase($var, $echo = true, $label = null, $strict = true)); echo (echoBase($var, $echo = true, $label = null, $strict = true));
exit; exit;
} }
@@ -20,11 +29,13 @@ function dd($var, $echo=true, $label=null, $strict=true) {
* @param boolean $strict 是否严谨 默认为true * @param boolean $strict 是否严谨 默认为true
* @return void|string * @return void|string
*/ */
function dump($var, $echo=true, $label=null, $strict=true) { function dump($var, $echo = true, $label = null, $strict = true)
{
echo (echoBase($var, $echo = true, $label = null, $strict = true)); echo (echoBase($var, $echo = true, $label = null, $strict = true));
} }
function echoBase($var, $echo=true, $label=null, $strict=true) { function echoBase($var, $echo = true, $label = null, $strict = true)
{
$label = ($label === null) ? '' : rtrim($label) . ' '; $label = ($label === null) ? '' : rtrim($label) . ' ';
if (!$strict) { if (!$strict) {
if (ini_get('html_errors')) { if (ini_get('html_errors')) {
@@ -45,6 +56,14 @@ function echoBase($var, $echo=true, $label=null, $strict=true) {
return $output; return $output;
} }
function JWTDecode($token,$_secret,$verify = true){ //接口返回函数
function result($data = [], $msg = '', $code = 10000)
{
$info = [
'Code' => $code,
'msg' => $msg,
'data' => $data,
];
echo json_encode($info);
die;
} }