116 lines
3.0 KiB
PHP
116 lines
3.0 KiB
PHP
<?php
|
|
|
|
namespace app\admin\logic\purchase_order;
|
|
|
|
|
|
use app\common\model\purchase_order\PurchaseOrder;
|
|
use app\common\logic\BaseLogic;
|
|
use think\facade\Db;
|
|
|
|
|
|
/**
|
|
* 采购订单逻辑
|
|
* Class PurchaseOrderLogic
|
|
* @package app\admin\logic\purchase_order
|
|
*/
|
|
class PurchaseOrderLogic extends BaseLogic
|
|
{
|
|
|
|
|
|
/**
|
|
* @notes 添加采购订单
|
|
* @param array $params
|
|
* @return bool
|
|
* @author admin
|
|
* @date 2024/08/01 16:32
|
|
*/
|
|
public static function add(array $params): bool
|
|
{
|
|
Db::startTrans();
|
|
try {
|
|
PurchaseOrder::create([
|
|
'store_id' => $params['store_id'],
|
|
'order_arr' => $params['order_arr'],
|
|
'order_id' => $params['order_id'],
|
|
'total' => $params['total'],
|
|
'actual' => $params['actual'],
|
|
'money' => $params['money'],
|
|
'paid' => $params['paid'],
|
|
'file' => $params['file'],
|
|
'data' => $params['data'],
|
|
'is_opurchase' => $params['is_opurchase'],
|
|
'is_mer' => $params['is_mer'],
|
|
'storage' => $params['storage']
|
|
]);
|
|
|
|
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/08/01 16:32
|
|
*/
|
|
public static function edit(array $params): bool
|
|
{
|
|
Db::startTrans();
|
|
try {
|
|
PurchaseOrder::where('id', $params['id'])->update([
|
|
'store_id' => $params['store_id'],
|
|
'order_arr' => $params['order_arr'],
|
|
'order_id' => $params['order_id'],
|
|
'total' => $params['total'],
|
|
'actual' => $params['actual'],
|
|
'money' => $params['money'],
|
|
'paid' => $params['paid'],
|
|
'file' => $params['file'],
|
|
'data' => $params['data'],
|
|
'is_opurchase' => $params['is_opurchase'],
|
|
'is_mer' => $params['is_mer'],
|
|
'storage' => $params['storage']
|
|
]);
|
|
|
|
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/08/01 16:32
|
|
*/
|
|
public static function delete(array $params): bool
|
|
{
|
|
return PurchaseOrder::destroy($params['id']);
|
|
}
|
|
|
|
|
|
/**
|
|
* @notes 获取采购订单详情
|
|
* @param $params
|
|
* @return array
|
|
* @author admin
|
|
* @date 2024/08/01 16:32
|
|
*/
|
|
public static function detail($params): array
|
|
{
|
|
return PurchaseOrder::findOrEmpty($params['id'])->toArray();
|
|
}
|
|
} |