156 lines
3.7 KiB
PHP
156 lines
3.7 KiB
PHP
<?php
|
|
|
|
namespace app\admin\logic\financial_transfers;
|
|
|
|
|
|
use app\common\model\financial_transfers\FinancialTransfers;
|
|
use app\common\logic\BaseLogic;
|
|
use think\facade\Db;
|
|
|
|
|
|
/**
|
|
* FinancialTransfers逻辑
|
|
* Class FinancialTransfersLogic
|
|
* @package app\admin\logic
|
|
*/
|
|
class FinancialTransfersLogic extends BaseLogic
|
|
{
|
|
|
|
|
|
/**
|
|
* @notes 添加
|
|
* @param array $params
|
|
* @return bool
|
|
* @author admin
|
|
* @date 2024/06/14 10:05
|
|
*/
|
|
public static function add(array $params): bool
|
|
{
|
|
Db::startTrans();
|
|
try {
|
|
FinancialTransfers::create([
|
|
'store_id' => $params['store_id'],
|
|
'admin_id' => $params['admin_id'],
|
|
'uid' => $params['uid'],
|
|
'status' => $params['status'],
|
|
'initiation_time' => $params['initiation_time'],
|
|
'confirmation_time' => $params['confirmation_time'],
|
|
'mark' => $params['mark'],
|
|
'money' => $params['money'],
|
|
'remark_time' => $params['remark_time']
|
|
]);
|
|
|
|
Db::commit();
|
|
return true;
|
|
} catch (\Exception $e) {
|
|
Db::rollback();
|
|
self::setError($e->getMessage());
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* @notes 编辑
|
|
* @param array $params
|
|
* @return bool
|
|
* @author admin
|
|
* @date 2024/06/14 10:05
|
|
*/
|
|
public static function edit(array $params): bool
|
|
{
|
|
Db::startTrans();
|
|
try {
|
|
FinancialTransfers::where('id', $params['id'])->update([
|
|
'store_id' => $params['store_id'],
|
|
'admin_id' => $params['admin_id'],
|
|
'uid' => $params['uid'],
|
|
'status' => $params['status'],
|
|
'initiation_time' => $params['initiation_time'],
|
|
'confirmation_time' => $params['confirmation_time'],
|
|
'mark' => $params['mark'],
|
|
'money' => $params['money'],
|
|
'remark_time' => $params['remark_time']
|
|
]);
|
|
|
|
Db::commit();
|
|
return true;
|
|
} catch (\Exception $e) {
|
|
Db::rollback();
|
|
self::setError($e->getMessage());
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* @notes 删除
|
|
* @param array $params
|
|
* @return bool
|
|
* @author admin
|
|
* @date 2024/06/14 10:05
|
|
*/
|
|
public static function delete(array $params): bool
|
|
{
|
|
return FinancialTransfers::destroy($params['id']);
|
|
}
|
|
|
|
|
|
/**
|
|
* @notes 获取详情
|
|
* @param $params
|
|
* @return array
|
|
* @author admin
|
|
* @date 2024/06/14 10:05
|
|
*/
|
|
public static function detail($params): array
|
|
{
|
|
return FinancialTransfers::findOrEmpty($params['id'])->toArray();
|
|
}
|
|
|
|
public static function dealsend($params)
|
|
{
|
|
Db::startTrans();
|
|
try {
|
|
FinancialTransfers::where('id',$params['id'])
|
|
->update(
|
|
[
|
|
'status'=>1,
|
|
'initiation_time'=>time()
|
|
]
|
|
);
|
|
|
|
Db::commit();
|
|
return true;
|
|
}catch (\Exception $e) {
|
|
Db::rollback();
|
|
self::setError($e->getMessage());
|
|
return false;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
public static function dealchange($params,$id)
|
|
{
|
|
Db::startTrans();
|
|
try {
|
|
FinancialTransfers::where('id',$id)
|
|
->update(
|
|
$params
|
|
);
|
|
|
|
Db::commit();
|
|
return true;
|
|
}catch (\Exception $e) {
|
|
Db::rollback();
|
|
self::setError($e->getMessage());
|
|
return false;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
} |