erp/app/admin/logic/retail/CashierclassLogic.php
2024-05-08 11:48:07 +08:00

130 lines
3.6 KiB
PHP

<?php
namespace app\admin\logic\retail;
use app\common\model\retail\Cashierclass;
use app\common\logic\BaseLogic;
use app\common\model\goods\Unit;
use app\common\model\merchant\Merchant;
use app\common\model\retail\Cashierinfo;
use think\facade\Db;
/**
* 零售订单逻辑
* Class CashierclassLogic
* @package app\admin\logic\retail
*/
class CashierclassLogic extends BaseLogic
{
/**
* @notes 添加零售订单
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/04/24 09:57
*/
public static function add(array $params): bool
{
Db::startTrans();
try {
Cashierclass::create([
'merchant' => $params['merchant'],
'store_id' => $params['store_id'],
'uid' => $params['uid'],
'number' => $params['number'],
'total' => $params['total'],
'deduction_price' => $params['deduction_price'],
'actual' => $params['actual'],
'money' => $params['money'],
'pay_type' => $params['pay_type'],
'data' => $params['data'],
'type' => $params['type'],
'more' => $params['more']
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 编辑零售订单
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/04/24 09:57
*/
public static function edit(array $params): bool
{
Db::startTrans();
try {
Cashierclass::where('id', $params['id'])->update([
'merchant' => $params['merchant'],
'store_id' => $params['store_id'],
'uid' => $params['uid'],
'number' => $params['number'],
'total' => $params['total'],
'deduction_price' => $params['deduction_price'],
'actual' => $params['actual'],
'money' => $params['money'],
'pay_type' => $params['pay_type'],
'data' => $params['data'],
'type' => $params['type'],
'more' => $params['more']
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 删除零售订单
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/04/24 09:57
*/
public static function delete(array $params): bool
{
return Cashierclass::destroy($params['id']);
}
/**
* @notes 获取零售订单详情
* @param $params
* @return array
* @author likeadmin
* @date 2024/04/24 09:57
*/
public static function detail($params): array
{
$find=Cashierclass::where($params)->find();
if($find){
$find['goods_list']= Cashierinfo::where('pid',$params['id'])
->with('goodsName')
->field('goods,price sell,nums')->select()->each(function($item){
$item['msg']='预计48小时发货';
$item['goods_unit']=Unit::where('id',$item['unit'])->value('name');
});
$find['merchant_info']=Merchant::where('mer_id',$find['merchant'])->field('mer_id,mer_name,service_phone')->find();
}
return $find->toArray();
}
}