WokerTask/app/common/model/ShopMerchant.php

61 lines
1.7 KiB
PHP
Raw Permalink Normal View History

2023-12-27 14:06:33 +08:00
<?php
namespace app\common\model;
use app\common\model\contract\Contract;
use app\common\model\dict\DictData;
use think\facade\Db;
class ShopMerchant extends BaseModel
{
protected $name = 'shop_merchant';
public function getCompanyTypeNameAttr($value)
{
return DictData::where('id', $value)->value('name');
}
public function getProvinceNameAttr($value)
{
return Db::name('geo_province')->where(['province_code' => $this->province])->value('province_name');
}
public function getCityNameAttr($value)
{
return Db::name('geo_city')->where(['city_code' => $this->city])->value('city_name');
}
public function getAreaNameAttr($value)
{
return Db::name('geo_area')->where(['area_code' => $this->area])->value('area_name');
}
public function getStreetNameAttr($value)
{
return Db::name('geo_street')->where(['street_code' => $this->street])->value('street_name');
}
public function getVillageNameAttr($value)
{
return Db::name('geo_village')->where(['village_code' => $this->village])->value('village_name');
}
public function getBrigadeNameAttr($value)
{
return Db::name('geo_brigade')->where(['id' => $this->brigade])->value('brigade_name');
}
public function getAreaManagerNameAttr($value)
{
return Db::name('admin')->where(['id' => $this->area_manager])->value('name');
}
public function getContractAttr()
{
$find=ShopContract::where('party_a|party_b', $this->id)->field('check_status,status')->find();
if($find){
return $find->toArray();
}else{
return [];
}
}
}