Commit 9f78bc86 authored by 孙磊's avatar 孙磊

模板

Signed-off-by: 孙磊's avatarsunlei <sunlei@romens.cn>
parent d003cdbc
......@@ -4,6 +4,7 @@ namespace app\models\v1\branch;
use Yii;
use app\models\v1\BaseModel;
use app\models\v1\branch\ShopCityDistributionSetting;
use yii\data\ActiveDataProvider;
/**
* This is the model class for table "shop_city_distribution_region".
......@@ -44,6 +45,12 @@ class ShopCityDistributionRegion extends BaseModel
[['SORT'], 'integer'],
[['REGION_RANGE','COLORS'], 'string'],
[['INITIAL_PRICE', 'DELIVERY_PRICE','REGION_R'], 'double'],
[['GUID', 'REGION_RANGE'], 'required','on'=>['create']],
[['GUID'],'required','on'=>['update']],
[['GUID', 'ORG_GUID', 'CITY_DISTR_GUID', 'ORDEX', 'COLORS', 'WEEK', 'IS_TYPE'], 'string', 'max' => 50,'on'=>['create']],
[['GUID'], 'unique','on'=>['create']],
[['INITIAL_PRICE'], 'required','on'=>['import'] ,'message' => '{attribute}不能为空'],
];
}
......@@ -75,4 +82,36 @@ class ShopCityDistributionRegion extends BaseModel
{
return $this->hasOne(ShopCityDistributionSetting::className(), ['GUID' => 'CITY_DISTR_GUID']);
}
//获取门店起送价
public function getBranchInitialPrice($params,$guid='')
{
$query = static::find()->alias('sg')
->select("sg.GUID,cs.REGION_TYPE,cs.REGION_DISTR_DISTANCE,cs.REGION_DISTR_PRICE,cs.INCREASE_DISTANCE,
cs.INCREASE_PRICE,sg.DELIVERY_PRICE,cs.STATUS,sb.CODE,sb.NAME,sg.INITIAL_PRICE,cs.SETTING_TYPE" )
->leftJoin('SHOP_CITY_DISTRIBUTION_SETTING cs', 'cs.GUID=sg.CITY_DISTR_GUID')
->leftJoin('SHOP_BRANCH sb','sb.GUID=cs.BRANCH_GUID')
->where(['cs.SETTING_TYPE' => 2]);
//门店名称或编码
if (isset($params) && !empty($params)) {
$query->andfilterWhere(['or', ['like','sb.CODE', $params['CODE']],['like', 'sb.NAME', $params['CODE']]]);
}
//批量修改 条件
if(isset($guid) && !empty($guid)){
$query->andFilterWhere(['=','cs.BRANCH_GUID',$guid]);
$query->andFilterWhere(['!=','sg.GUID','']);
}
return new ActiveDataProvider([
'query' => $query->asArray(),
'pagination' => [
'pageSize' => PAGE_SIZE
],
'sort' => [
'attributes' => [
'CODE' => SORT_DESC
]
]
]);
}
}
<?php
namespace app\models\v1\transport;
use app\models\v1\BaseModel;
use Yii;
use yii\data\ActiveDataProvider;
use app\models\v1\branch\ShopCityDistributionSetting;
/**
* This is the model class for table "shop_city_distribution_region".
*
* @property string $GUID 电子围栏GUID
* @property string $ORG_GUID 组织机构号
* @property string $CITY_DISTR_GUID 同城配送设置表,关联CITY_DISTRIBUTION_SETTING表GUID
* @property string $ORDEX 区域序号
* @property string $COLORS 区域颜色
* @property int $HF_TYPE 区域划分方式,1半径 2自定义
* @property string $REGION_R 划分方式为半径,存半径的值
* @property string $REGION_RANGE 划分方式自定义时,存数组值
* @property float $QS_PRICE 起送价格
* @property float $PS_PRICE 配送价格
* @property string|null $WEEK 配送时间周*
* @property string|null $IS_TYPE 配送时段和区域,QY为区域,SJ为时间,QS_PRICE和PS_PRICE为起始时间字段
*
* @property ShopCityDistributionSetting $cITYDISTRGU
*/
class CityDistributionRegion extends BaseModel
{
/**
* {@inheritdoc}
*/
public static function tableName()
{
return 'shop_city_distribution_region';
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['GUID', 'REGION_RANGE'], 'required','on'=>['create']],
[['GUID'],'required','on'=>['update']],
[['HF_TYPE'], 'integer'],
[['REGION_RANGE'], 'string'],
[['QS_PRICE', 'PS_PRICE'], 'number'],
[['GUID', 'ORG_GUID', 'CITY_DISTR_GUID', 'ORDEX', 'COLORS', 'WEEK', 'IS_TYPE'], 'string', 'max' => 50,'on'=>['create']],
[['REGION_R'], 'string', 'max' => 20],
[['GUID'], 'unique','on'=>['create']],
[['CITY_DISTR_GUID'], 'exist', 'skipOnError' => true, 'targetClass' => ShopCityDistributionSetting::className(), 'targetAttribute' => ['CITY_DISTR_GUID' => 'GUID']],
[['QS_PRICE'], 'required','on'=>['import'] ,'message' => '{attribute}不能为空'],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'GUID' => 'Guid',
'ORG_GUID' => 'Org Guid',
'CITY_DISTR_GUID' => 'City Distr Guid',
'ORDEX' => 'Ordex',
'COLORS' => 'Colors',
'HF_TYPE' => 'Hf Type',
'REGION_R' => 'Region R',
'REGION_RANGE' => 'Region Range',
'QS_PRICE' => 'Qs Price',
'PS_PRICE' => 'Ps Price',
'WEEK' => 'Week',
'IS_TYPE' => 'Is Type',
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getCITYDISTRGU()
{
return $this->hasOne(ShopCityDistributionSetting::className(), ['GUID' => 'CITY_DISTR_GUID']);
}
//获取门店起送价
public function getBranchInitialPrice($params,$guid='')
{
$query = static::find()->alias('sg')
->select("sg.GUID,cs.REGION_TYPE,cs.REGION_DISTR_DISTANCE,cs.REGION_DISTR_PRICE,cs.INCREASE_DISTANCE,
cs.INCREASE_PRICE,sg.PS_PRICE,cs.STATUS,sb.CODE,sb.NAME,sg.QS_PRICE,cs.SETTING_TYPE" )
->leftJoin('SHOP_CITY_DISTRIBUTION_SETTING cs', 'cs.GUID=sg.CITY_DISTR_GUID')
->leftJoin('SHOP_BRANCH sb','sb.GUID=cs.BRANCH_GUID')
->where(['cs.SETTING_TYPE' => 2]);
//门店名称或编码
if (isset($params) && !empty($params)) {
$query->andfilterWhere(['or', ['like','sb.CODE', $params['CODE']],['like', 'sb.NAME', $params['CODE']]]);
}
//批量修改 条件
if(isset($guid) && !empty($guid)){
$query->andFilterWhere(['=','cs.BRANCH_GUID',$guid]);
$query->andFilterWhere(['!=','sg.GUID','']);
}
// return $query->createCommand()->getSql();
return new ActiveDataProvider([
'query' => $query->asArray(),
'pagination' => [
'pageSize' => 15
],
'sort' => [
'attributes' => [
'CODE' => SORT_DESC
]
]
]);
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment