2024-06-06 11:02:56 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace app\common\logic;
|
|
|
|
|
2024-06-18 10:47:26 +08:00
|
|
|
use app\common\enum\YesNoEnum;
|
2024-06-06 11:02:56 +08:00
|
|
|
use app\common\model\store_cash_finance_flow\StoreCashFinanceFlow;
|
|
|
|
|
|
|
|
class CashFlowLogic extends BaseLogic
|
|
|
|
{
|
|
|
|
|
2025-01-13 10:38:10 +08:00
|
|
|
public function insert($storeId, $amount,$source_mark='')
|
2024-06-06 11:02:56 +08:00
|
|
|
{
|
|
|
|
$model = new StoreCashFinanceFlow();
|
2024-06-21 16:56:54 +08:00
|
|
|
$find = $model->where(['store_id' => $storeId])->whereDay('create_time')->where('status', 0)->find();
|
|
|
|
if ($find) {
|
|
|
|
$find->cash_price = bcadd($find->cash_price, $amount, 2);
|
|
|
|
$find->receivable = bcadd($find->receivable, $amount, 2);
|
|
|
|
$find->save();
|
|
|
|
} else {
|
|
|
|
$model->store_id = $storeId;
|
|
|
|
$model->cash_price = $amount;
|
|
|
|
$model->receivable = $amount;
|
2024-06-21 17:27:59 +08:00
|
|
|
$model->remark = '银行转账请备注:'.mt_rand(1000, 9999);
|
2025-01-13 10:38:10 +08:00
|
|
|
$model->source_mark = $source_mark;
|
2024-06-21 16:56:54 +08:00
|
|
|
$model->status = YesNoEnum::NO; //收银台收了默认算完成了
|
|
|
|
$model->save();
|
|
|
|
}
|
2024-06-06 11:02:56 +08:00
|
|
|
}
|
|
|
|
}
|