<?php
|
|
namespace app\admin\model;
|
|
use app\admin\model\page\Page as PageModel;
|
use app\common\model\shop\Client as ClientModel;
|
|
class Client extends ClientModel
|
{
|
/**
|
* 获取小程序列表
|
*/
|
public function getList($limit, $is_recycle = false)
|
{
|
return $this->alias('client')->field(['client.*,agent.agent_name'])->where('client.is_recycle', '=', (int)$is_recycle)
|
->join('dl_agent agent', 'agent.agent_id = client.agent_id','left')
|
->where('client.is_delete', '=', 0)
|
->order(['client.create_time' => 'asc'])
|
->paginate($limit);
|
}
|
|
/**
|
* 新增记录
|
*/
|
public function add($data)
|
{
|
$this->startTrans();
|
try {
|
// 添加小程序记录
|
$this->save($data);
|
|
$this->commit();
|
return true;
|
} catch (\Exception $e) {
|
$this->error = $e->getMessage();
|
$this->rollback();
|
return false;
|
}
|
}
|
|
/**
|
* 修改记录
|
*/
|
public function edit($data)
|
{
|
$this->startTrans();
|
try {
|
$save_data = [
|
'client_name' => $data['client_name'],
|
'company' => $data['company'],
|
'mark_manager' => $data['mark_manager'],
|
'handrate_wx'=>$data['handrate_wx'],
|
'commissionrate_wx' => $data['commissionrate_wx'],
|
'agent_id' => $data['agent_id'],
|
];
|
$this->save($save_data);
|
|
$this->commit();
|
return true;
|
} catch (\Exception $e) {
|
$this->error = $e->getMessage();
|
$this->rollback();
|
return false;
|
}
|
}
|
/**
|
* 移入移出回收站
|
*/
|
public function recycle($is_recycle = true)
|
{
|
return $this->save(['is_recycle' => (int)$is_recycle]);
|
}
|
|
/**
|
* 软删除
|
*/
|
public function setDelete()
|
{
|
return $this->save(['is_delete' => 1]);
|
}
|
|
}
|