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.
104 lines
2.9 KiB
104 lines
2.9 KiB
<?php
|
|
|
|
namespace app\common\model;
|
|
|
|
use think\Model;
|
|
|
|
class ProjectCategory extends Model
|
|
{
|
|
// 表名
|
|
protected $name = 'project_category';
|
|
// 开启自动写入时间戳字段
|
|
protected $autoWriteTimestamp = 'int';
|
|
|
|
// 追加属性
|
|
protected $append = [
|
|
|
|
];
|
|
|
|
public function projectCategoryFlow() {
|
|
return $this->hasMany(ProjectCategoryFlow::class, 'category_id', 'id');
|
|
}
|
|
|
|
|
|
/**
|
|
* 获取施工进展
|
|
* @return array
|
|
*/
|
|
public static function getProgress($order_id, $category_id) {
|
|
$data = self::with('projectCategoryFlow')->where('id', $category_id)->find();
|
|
// $_data['sign_url'] = request()->domain().$data['sign_url'];
|
|
$_data = [];
|
|
if ($data) {
|
|
$_data['category_name'] = $data['name'];
|
|
foreach ($data['project_category_flow'] as $v) {
|
|
$progress = ProjectOrderAfterSales::where('flow_id',$v['id'])
|
|
->where('type', 'progress')
|
|
->where('order_id', $order_id)
|
|
->order('create_time', 'DESC')
|
|
->limit(10)
|
|
->select();
|
|
foreach ($progress as &$row) {
|
|
$row['images'] = self::imagesFormat($row['images']);
|
|
$row['add_user'] = User::get($row['add_user'])->nickname ?? '';
|
|
}
|
|
$_data['project_category_flow'][] = [
|
|
'id' => $v['id'],
|
|
'name' => $v['name'],
|
|
'content' => $v['content'],
|
|
'flow_status' => ProjectOrderFlow::getStatus($order_id, $v['id']),
|
|
'img_urls' => self::imgUrlsFormat($v['img_urls'],$v['img_names']),
|
|
'sign_url' => $v['sign_url'] ? request()->domain().$v['sign_url'] : '',
|
|
'progress' =>$progress
|
|
];
|
|
}
|
|
}
|
|
|
|
return $_data;
|
|
}
|
|
|
|
|
|
public static function imagesFormat($images) {
|
|
$data = [];
|
|
if ($images) {
|
|
foreach ($images as $key => $v) {
|
|
$data[$key] = request()->domain().$v;
|
|
}
|
|
}
|
|
|
|
return $data;
|
|
}
|
|
/**
|
|
* 图片格式化
|
|
* @param $img_urls
|
|
* @return array
|
|
*/
|
|
public static function imgUrlsFormat($img_urls, $names) {
|
|
$data = [];
|
|
if ($img_urls) {
|
|
foreach ($img_urls as $key => $v) {
|
|
$data[$key]['url'] = request()->domain().$v;
|
|
$data[$key]['name'] = !empty($names[$key]) ? $names[$key] : '';
|
|
}
|
|
}
|
|
|
|
return $data;
|
|
}
|
|
|
|
/**
|
|
* 进场完成状态
|
|
*/
|
|
public static function getStatus($order_id, $flow_id) {
|
|
$res = ProjectOrderAfterSales::where(['order_id'=>$order_id, 'flow_id'=>$flow_id])->find();
|
|
return $res['flow_status'];
|
|
}
|
|
|
|
public static function getList() {
|
|
return self::field('id,name')->select();
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} |