123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- <?php
- namespace app\admin\model;
- use think\facade\Db;
- use think\model;
- class CostProject extends Model
- {
- /**
- * 获取分页列表
- * @param $where
- * @param $param
- */
- public function getCostProjectList($where, $param)
- {
- $rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit'];
- $order = empty($param['order']) ? 'id desc' : $param['order'];
- $list = self::where($where)->field('id,status,project_name,project_num,project_time,review_unit,review_head,review_head_phone,sent_review_unit,sent_review_head,sent_review_phone,construction_unit,construction_head,construction_phone,project_scale,engineering_category,engineering_type,project_region,fiscal_nature,sent_review_cost,preparation_amount,sent_review_amount,authorize_amount,review_add_amount,review_reduce_amount,report_time,charge_standard,invoicing__amount,invoicing__num,operate_head,operate_team,project_end_time')
- ->order($order)->paginate($rows, false, ['query' => $param]);
- return $list;
- }
- /**
- * 添加数据
- * @param $param
- */
- public function addCostProject($param)
- {
- $insertId = 0;
- try {
- $param['create_time'] = time();
- $insertId = self::strict(false)->field(true)->insertGetId($param);
- // halt($insertId);
- add_log('add', $insertId, $param);
- add_project_log("创建项目", $insertId);
- add_project_log('新增', $insertId);
- } catch (\Exception $e) {
- return to_assign(1, '操作失败,原因:' . $e->getMessage());
- }
- return to_assign(0, '操作成功', ['aid' => $insertId]);
- }
- /**
- * 添加数据
- * @param $param
- */
- public function addConstructionPeople($param)
- {
- try {
- $param['create_time'] = time();
- self::where('id', $param['id'])->save($param);
- } catch (\Exception $e) {
- return to_assign(1, '操作失败,原因:' . $e->getMessage());
- }
- return to_assign(0, '操作成功');
- }
- /**
- * 编辑信息
- * @param $param
- */
- public function editCostProject($param)
- {
- try {
- $param['update_time'] = time();
- self::where('id', $param['id'])->strict(false)->field(true)->update($param);
- add_log('edit', $param['id'], $param);
- } catch (\Exception $e) {
- return to_assign(1, '操作失败,原因:' . $e->getMessage());
- }
- return to_assign(0, '操作成功');
- }
- /**
- * 根据id获取信息
- * @param $id
- */
- public function getCostProjectById($id)
- {
- $info = self::where('id', $id)->find();
- if(!empty($info["operate_team"])){
- $operate_team = explode(",", $info["operate_team"]);
- $name = Db::name("admin")->whereIn("id", $operate_team)->column("nickname");
- $names = implode(",",$name);
- $info["operate_team_names"] = $names;
- }
- if(!empty($info)){
- $unit_type = Db::name("department")->where("id",get_login_admin("unit_name"))->value("type");
- $info["unit_type"] = $unit_type;
- }
- return $info;
- }
- /**
- * 删除信息
- * @param $id
- * @return array
- */
- public function delCostProjectById($id, $type = 0)
- {
- if ($type == 0) {
- //逻辑删除
- try {
- $param['delete_time'] = time();
- self::where('id', $id)->update(['delete_time' => time()]);
- add_log('delete', $id);
- add_project_log('删除', $id);
- } catch (\Exception $e) {
- return to_assign(1, '操作失败,原因:' . $e->getMessage());
- }
- } else {
- //物理删除
- try {
- self::where('id', $id)->delete();
- add_log('delete', $id);
- add_project_log('删除', $id);
- } catch (\Exception $e) {
- return to_assign(1, '操作失败,原因:' . $e->getMessage());
- }
- }
- return to_assign();
- }
- }
|