diff --git a/app/admin/controller/financial_transfers/FinancialTransfersController.php b/app/admin/controller/financial_transfers/FinancialTransfersController.php index 9f98930d..7d9b75f8 100644 --- a/app/admin/controller/financial_transfers/FinancialTransfersController.php +++ b/app/admin/controller/financial_transfers/FinancialTransfersController.php @@ -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 diff --git a/app/admin/lists/financial_transfers/FinancialTransfersLists.php b/app/admin/lists/financial_transfers/FinancialTransfersLists.php index 8c989e28..6703d363 100644 --- a/app/admin/lists/financial_transfers/FinancialTransfersLists.php +++ b/app/admin/lists/financial_transfers/FinancialTransfersLists.php @@ -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']); } diff --git a/app/admin/lists/store_cash_finance_flow/StoreCashFinanceFlowLists.php b/app/admin/lists/store_cash_finance_flow/StoreCashFinanceFlowLists.php index e4c25f5a..4feb8ccd 100644 --- a/app/admin/lists/store_cash_finance_flow/StoreCashFinanceFlowLists.php +++ b/app/admin/lists/store_cash_finance_flow/StoreCashFinanceFlowLists.php @@ -27,7 +27,7 @@ class StoreCashFinanceFlowLists extends BaseAdminDataLists implements ListsSearc public function setSearch(): array { return [ - '=' => ['store_id'], + '=' => ['store_id','status'], "between_time" => 'create_time' ]; } diff --git a/app/admin/logic/financial_transfers/FinancialTransfersLogic.php b/app/admin/logic/financial_transfers/FinancialTransfersLogic.php index 8a571e70..d9b0577b 100644 --- a/app/admin/logic/financial_transfers/FinancialTransfersLogic.php +++ b/app/admin/logic/financial_transfers/FinancialTransfersLogic.php @@ -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; @@ -112,45 +113,46 @@ class FinancialTransfersLogic extends BaseLogic { Db::startTrans(); try { - FinancialTransfers::where('id',$params['id']) + FinancialTransfers::where('id', $params['id']) ->update( [ - 'status'=>1, - 'initiation_time'=>time() + 'status' => 1, + 'initiation_time' => time() ] ); Db::commit(); return true; - }catch (\Exception $e) { + } catch (\Exception $e) { Db::rollback(); self::setError($e->getMessage()); return false; } - - } - public static function dealchange($params,$id) + 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) + FinancialTransfers::where('id', $id) ->update( $params ); Db::commit(); return true; - }catch (\Exception $e) { + } catch (\Exception $e) { Db::rollback(); self::setError($e->getMessage()); return false; } - - } - - -} \ No newline at end of file +} diff --git a/app/common/logic/CashFlowLogic.php b/app/common/logic/CashFlowLogic.php index 9b0e3c72..3c15d154 100644 --- a/app/common/logic/CashFlowLogic.php +++ b/app/common/logic/CashFlowLogic.php @@ -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(); }