You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
90 lines
2.9 KiB
90 lines
2.9 KiB
10 months ago
|
<?php
|
||
|
|
||
|
// +----------------------------------------------------------------------
|
||
|
// | 天诚科技 [ 刘海东 17600099397赋能开发者,助力企业发展 ]
|
||
|
// +----------------------------------------------------------------------
|
||
|
// | Copyright (c) 2016~2020 https://www.tczxkj.com All rights reserved.
|
||
|
// +----------------------------------------------------------------------
|
||
|
// | Licensed 该系统并不是自由软件,未经许可不能去掉相关版权
|
||
|
// +----------------------------------------------------------------------
|
||
|
// | Author:甘肃天诚志信电子商务有限公司 刘海东 联系电话维系17600099397
|
||
|
// +----------------------------------------------------------------------
|
||
|
|
||
|
namespace app\admin\model\institution;
|
||
|
|
||
|
use traits\ModelTrait;
|
||
|
use basic\ModelBasic;
|
||
|
use service\HookService;
|
||
|
use service\SystemConfigService;
|
||
|
|
||
|
/**
|
||
|
* Class Institution
|
||
|
* @package app\Institution\model\Institution
|
||
|
*/
|
||
|
class Institution extends ModelBasic
|
||
|
{
|
||
|
use ModelTrait;
|
||
|
|
||
|
//设置where条件
|
||
|
public static function setWhere($where, $alirs = '', $model = null)
|
||
|
{
|
||
|
$model = $model === null ? new self() : $model;
|
||
|
$model = $alirs !== '' ? $model->alias($alirs) : $model;
|
||
|
$alirs = $alirs === '' ? $alirs : $alirs . '.';
|
||
|
$model = $model->where("{$alirs}is_del", 0);
|
||
|
if ($where['title'] && $where['title']) $model = $model->where("{$alirs}mer_name", 'LIKE', "%$where[title]%");
|
||
|
return $model;
|
||
|
}
|
||
|
|
||
|
/**机构列表
|
||
|
* @param $where
|
||
|
* @return array
|
||
|
* @throws \think\Exception
|
||
|
*/
|
||
|
public static function getLecturerMerchantList($where)
|
||
|
{
|
||
|
$data = self::setWhere($where)->page((int)$where['page'], (int)$where['limit'])->select();
|
||
|
$data = count($data) ? $data->toArray() : [];
|
||
|
$count = self::setWhere($where)->count();
|
||
|
return compact('data', 'count');
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 删除机构后台
|
||
|
* @param $id
|
||
|
* @return bool|int
|
||
|
* @throws \think\exception\DbException
|
||
|
*/
|
||
|
public static function delMerchant($id)
|
||
|
{
|
||
|
return self::where('id', $id)->update(['is_del' => 1]);
|
||
|
}
|
||
|
|
||
|
public static function getMerWhere()
|
||
|
{
|
||
|
return self::where(['is_del' => 0, 'estate' => 1, 'status' => 1]);
|
||
|
}
|
||
|
|
||
|
/**减机构余额
|
||
|
* @param $mer_id
|
||
|
* @param $price
|
||
|
* @return int|true
|
||
|
* @throws \think\Exception
|
||
|
*/
|
||
|
public static function decMerchantNowMoney($mer_id, $price)
|
||
|
{
|
||
|
return self::where('id', $mer_id)->setDec('now_money', $price);
|
||
|
}
|
||
|
|
||
|
/**机构列表
|
||
|
* @return false|\PDOStatement|string|\think\Collection
|
||
|
* @throws \think\db\exception\DataNotFoundException
|
||
|
* @throws \think\db\exception\ModelNotFoundException
|
||
|
* @throws \think\exception\DbException
|
||
|
*/
|
||
|
public static function getMerchantList()
|
||
|
{
|
||
|
return self::getMerWhere()->field('id,mer_name')->select();
|
||
|
}
|
||
|
}
|