feat: 修改财务转账相关代码以优化查询效率和用户体验

This commit is contained in:
mkm 2024-06-21 17:27:59 +08:00
parent 20e3347b56
commit 3db2bda607
5 changed files with 24 additions and 25 deletions

View File

@ -10,7 +10,7 @@ use app\admin\validate\financial_transfers\FinancialTransfersValidate;
/**
* FinancialTransfers控制器
* 财务转账控制器
* Class FinancialTransfersController
* @package app\admin\controller\financial_transfers
*/
@ -64,13 +64,6 @@ class FinancialTransfersController extends BaseAdminController
}
/**
* @notes 添加
* @return \think\response\Json

View File

@ -6,10 +6,10 @@ namespace app\admin\lists\financial_transfers;
use app\admin\lists\BaseAdminDataLists;
use app\common\model\financial_transfers\FinancialTransfers;
use app\common\lists\ListsSearchInterface;
use app\common\model\store_cash_finance_flow\StoreCashFinanceFlow;
/**
* FinancialTransfers列表
* 财务转账列表
* Class FinancialTransfersLists
* @package app\admin\listsfinancial_transfers
*/
@ -50,6 +50,9 @@ class FinancialTransfersLists extends BaseAdminDataLists implements ListsSearchI
->toArray();
foreach ($data as &$value){
if($value['initiation_time']){
$time=strtotime('-1 month',$value['initiation_time']);
$date=date('Y-m-d',$time);//获取一个月前的日期
$value['receivable']=StoreCashFinanceFlow::whereMonth('create_time',$date)->where('status',0)->sum('receivable');
$value['initiation_time'] = date('Y-m-d H:i:s',$value['initiation_time']);
}

View File

@ -27,7 +27,7 @@ class StoreCashFinanceFlowLists extends BaseAdminDataLists implements ListsSearc
public function setSearch(): array
{
return [
'=' => ['store_id'],
'=' => ['store_id','status'],
"between_time" => 'create_time'
];
}

View File

@ -5,6 +5,7 @@ namespace app\admin\logic\financial_transfers;
use app\common\model\financial_transfers\FinancialTransfers;
use app\common\logic\BaseLogic;
use app\common\model\store_cash_finance_flow\StoreCashFinanceFlow;
use think\facade\Db;
@ -127,13 +128,18 @@ class FinancialTransfersLogic extends BaseLogic
self::setError($e->getMessage());
return false;
}
}
public static function dealchange($params, $id)
{
$find = FinancialTransfers::where('id', $id)->find();
$time = strtotime('-1 month', $find['initiation_time']);
$date = date('Y-m-d', $time); //获取一个月前的日期
$receivable = StoreCashFinanceFlow::whereMonth('create_time', $date)->where('status', 0)->sum('receivable');
if($receivable==0){
self::setError('暂无法确认,还有未收取的现金');
}
Db::startTrans();
try {
FinancialTransfers::where('id', $id)
@ -148,9 +154,5 @@ class FinancialTransfersLogic extends BaseLogic
self::setError($e->getMessage());
return false;
}
}
}

View File

@ -20,6 +20,7 @@ class CashFlowLogic extends BaseLogic
$model->store_id = $storeId;
$model->cash_price = $amount;
$model->receivable = $amount;
$model->remark = '银行转账请备注:'.mt_rand(1000, 9999);
$model->status = YesNoEnum::NO; //收银台收了默认算完成了
$model->save();
}