Browse Source

开发运费区域视图文件

antshop
linyaostalker 5 years ago
parent
commit
4094b2fdde
  1. 69
      backend/modules/shop/views/express-template/express_area_view.php

69
backend/modules/shop/views/express-template/express_area_view.php

@ -1,5 +1,8 @@
<?php
use backend\modules\shop\models\ars\City;
use backend\modules\shop\models\ars\ExpressArea;
use backend\modules\shop\models\ars\Province;
use yii\helpers\Html;
use yii\widgets\DetailView;
use backend\modules\shop\models\ars\ExpressTemplate;
@ -7,42 +10,82 @@ use backend\modules\shop\models\ars\ExpressTemplate;
/* @var $this yii\web\View */
/* @var $model backend\modules\shop\models\ars\ExpressTemplate */
$this->title = $model->name;
$this->params['breadcrumbs'][] = ['label' => 'Express Templates', 'url' => ['index']];
$this->title = $model->id;
$this->params['breadcrumbs'][] = ['label' => '运费模板', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => '运费区域模板:'.$expressTemplateModel->name, 'url' => ['express-area-list?id='.$expressTemplateModel->id]];
$this->params['breadcrumbs'][] = $this->title;
\yii\web\YiiAsset::register($this);
?>
<div class="express-template-view">
<p>
<?= Html::a('返回列表', ['index'], ['class' => 'btn btn-success']) ?>
<?= Html::a('返回列表', ['express-area-list?id='.$expressTemplateModel->id], ['class' => 'btn btn-success']) ?>
</p>
<?= DetailView::widget([
'model' => $model,
'attributes' => [
'id',
'name',
[
'attribute' => 'calculation_type',
'attribute' => 'basic_count',
'label' => ExpressArea::$formList[$expressTemplateModel->calculation_type]['basic_count'],
'value' => function ($model) {
return ExpressTemplate::$calculationType[$model->calculation_type];
$expressTemplateModel = ExpressTemplate::findOne($model->express_template);
if ($expressTemplateModel->calculation_type == ExpressTemplate::CALCULATION_TYPE_WEIGHT) {
return $model->basic_count /= 10;
} else {
return $model->basic_count;
}
}
],
[
'attribute' => 'basic_price',
'label' => ExpressArea::$formList[$expressTemplateModel->calculation_type]['basic_price'],
'value' => function ($model) {
return $model->basic_price /= 100;
}
],
[
'attribute' => 'extra_count',
'label' => ExpressArea::$formList[$expressTemplateModel->calculation_type]['extra_count'],
'value' => function ($model) {
$expressTemplateModel = ExpressTemplate::findOne($model->express_template);
if ($expressTemplateModel->calculation_type == ExpressTemplate::CALCULATION_TYPE_WEIGHT) {
return $model->extra_count /= 10;
} else {
return $model->extra_count;
}
}
],
[
'attribute' => 'extra_price',
'label' => ExpressArea::$formList[$expressTemplateModel->calculation_type]['extra_price'],
'value' => function ($model) {
return $model->extra_price /= 100;
}
],
'basic_price',
'basic_count',
'extra_price',
'extra_count',
'updated_at:datetime',
'created_at:datetime',
['attribute' => 'city',
'value' => function ($model) {
$array = explode(',', $model->city);
$expressAreas = ExpressArea::findOne($model->id);
$expressAresCityIdArr = explode(',', $expressAreas->city);
$cities = [];
foreach (\backend\modules\shop\models\ars\City::find()->andWhere(['in', 'city_id', $array])->all() as $city) {
$provinces = Province::find()->cache(0)->all();
foreach ($provinces as $k => $v) {
$cityId = City::find()
->select(['city_id'])
->where(['province_id' => $v->province_id])
->column();
if (empty(array_diff($cityId, $expressAresCityIdArr))) {
$cities[] = $v->name;
}else{
foreach (\backend\modules\shop\models\ars\City::find()->andWhere(['in', 'city_id', array_diff($cityId, array_diff($cityId, $expressAresCityIdArr))])->all() as $city) {
$cities[] = $city->name;
}
return implode(' // ', $cities);
}
}
return implode(' , ', $cities);
},
],
],

Loading…
Cancel
Save