This commit is contained in:
wanyongkang
2020-10-29 17:57:02 +08:00
parent e3a50a150a
commit 93825fa01a
4 changed files with 186 additions and 10 deletions

View File

@@ -0,0 +1,127 @@
<?php
/*
* @Descripttion:
* @version:
* @Author: kangkang
* @Date: 2020-10-13 19:52:37
* @LastEditors: kangkang
* @LastEditTime: 2020-10-29 17:42:14
*/
/*
* @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\Finance as FinanceModel;
use app\order\model\FinanceOperation as FinanceOperationModel;
use fastphp\base\Controller;
class FinanceCheck extends Controller
{
/**
* @description: 数据列表
* @param {*}
* @return {*}
*/
public function getList()
{
$page = 0;
if (isset($_GET['PageIndex'])) {
$page = ($_GET['PageIndex'] - 1) * 50;
}
$finance_model = new FinanceModel;
$list = $finance_model->getListPage([], '*', 'id desc', "$page,50");
foreach ($list as $k => &$v) {
$v['riqi'] = date('Y-m-d', strtotime($v['riqi']) - 86400);
}
$data = [
'Code' => 10000,
'data' => $list,
'msg' => '',
'count' => (int) $finance_model->getCount()['count'],
];
echo json_encode($data);
}
public function search()
{
$data = json_decode(file_get_contents("php://input"), true)['time'];
$data[0] = date('Y-m-d', strtotime($data[0]) + 86400) . ' 00:00:00';
$data[1] = date('Y-m-d', strtotime($data[1]) + 86400) . ' 23:59:59';
$finance_model = new FinanceModel;
$list = $finance_model->getListSearch(['riqi' => ['>', $data[0]]], ['riqi' => ['<', $data[1]]], '*', 'id desc', "10000");
foreach ($list as $k => &$v) {
$v['riqi'] = date('Y-m-d', strtotime($v['riqi']) - 86400);
}
$data = [
'Code' => 30000,
'data' => $list,
'msg' => '',
'count' => 0,
];
echo json_encode($data);
}
public function buyi()
{
$data = json_decode(file_get_contents("php://input"), true);
$userinfo = $this->userinfo;
$data['op_person'] = $userinfo['LoginName'];
$data['riqi'] = date('Y-m-d',strtotime($data['riqi'])+86400);
$finance_model = new FinanceModel;
$finance_operation_model = new FinanceOperationModel;
$finance_data = $finance_model->getOne("date(riqi)='".$data['riqi']."'");
if(!$finance_data){
die;
}
$data['finance_id'] = $finance_data['id'];
$finance_buyi = 0;
switch($data['type']){
case 1:
case 3:
$finance_buyi = $finance_data[$data['product']] + $data['money'];
break;
case 2:
$finance_buyi = $finance_data[$data['product']] - $data['money'];
break;
}
$types = ['充值','退款','补差价'];
$finance_update = [
$data['product']=>$finance_buyi,
'remark'=>'<'.$finance_data['remark'].$data['product'].'补遗 '.$types[$data['type']-1].$data['money'].'>'
];
$finance_model->updateOne(['id'=>$finance_data['id']],$finance_update);
$finance_operation_model->add($data);
\result();
}
public function buyiList()
{
$page = 0;
if (isset($_GET['PageIndex'])) {
$page = ($_GET['PageIndex'] - 1) * 50;
}
$finance_model = new FinanceOperationModel;
$list = $finance_model->getListPage([], '*', 'id desc', "$page,50");
$types = ['充值','退款','补差价'];
foreach ($list as $k => &$v) {
$v['type'] = $types[$v['type']-1];
}
$data = [
'Code' => 10000,
'data' => $list,
'msg' => '',
'count' => (int) $finance_model->getCount()['count'],
];
echo json_encode($data);
}
}

View File

@@ -5,7 +5,7 @@
* @Author: kangkang
* @Date: 2020-10-13 19:52:37
* @LastEditors: kangkang
* @LastEditTime: 2020-10-26 10:36:11
* @LastEditTime: 2020-10-29 15:12:44
*/
/*
* @Descripttion:
@@ -34,15 +34,6 @@ class IncomeCheck extends Controller
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'];
}
$check_model = new CheckModel;
$list = $check_model->getListPage([], '*', 'id desc', "$page,50");

View File

@@ -0,0 +1,29 @@
<?php
/*
* @Descripttion:
* @version:
* @Author: kangkang
* @Date: 2020-10-22 16:13:41
* @LastEditors: kangkang
* @LastEditTime: 2020-10-29 15:19:12
*/
namespace app\order\model;
use fastphp\base\Model;
class Finance extends Model
{
protected $table = 'finance';
/**
* @description: 单独写
* @param {*}
* @return {*}
*/
public function getListSearch($where1, $where2, $fields = '*', $order = 'id desc', $limit = '50')
{
return $this->field($fields)->where($where1)->where($where2)->order($order)->limit($limit)->fetchAll();
}
}

View File

@@ -0,0 +1,29 @@
<?php
/*
* @Descripttion:
* @version:
* @Author: kangkang
* @Date: 2020-10-22 16:13:41
* @LastEditors: kangkang
* @LastEditTime: 2020-10-29 17:11:13
*/
namespace app\order\model;
use fastphp\base\Model;
class FinanceOperation extends Model
{
protected $table = 'finance_op';
/**
* @description: 单独写
* @param {*}
* @return {*}
*/
public function getListSearch($where1, $where2, $fields = '*', $order = 'id desc', $limit = '50')
{
return $this->field($fields)->where($where1)->where($where2)->order($order)->limit($limit)->fetchAll();
}
}