diff --git a/backend/modules/shop/Module.php b/backend/modules/shop/Module.php old mode 100644 new mode 100755 diff --git a/backend/modules/shop/controllers/ExpressTemplateController.php b/backend/modules/shop/controllers/ExpressTemplateController.php index 2ff09b1..8984993 100755 --- a/backend/modules/shop/controllers/ExpressTemplateController.php +++ b/backend/modules/shop/controllers/ExpressTemplateController.php @@ -71,8 +71,8 @@ class ExpressTemplateController extends Controller public function actionCreate() { $model = new ExpressTemplate(); - $model->calculation = ExpressTemplate::CALCULATION_NUMBER; - $model->basic_amount = 1; + $model->calculation_type = ExpressTemplate::CALCULATION_TYPE_NUMBER; + $model->basic_count = 1; $model->basic_price = '0.00'; if (Yii::$app->request->isPost) { diff --git a/backend/modules/shop/migrations/m191205_062533_update_columns_basic_amount_extra_amount_calculation_in_table_ats_express_template.php b/backend/modules/shop/migrations/m191205_062533_update_columns_basic_amount_extra_amount_calculation_in_table_ats_express_template.php new file mode 100755 index 0000000..6d8a75e --- /dev/null +++ b/backend/modules/shop/migrations/m191205_062533_update_columns_basic_amount_extra_amount_calculation_in_table_ats_express_template.php @@ -0,0 +1,30 @@ +dropColumn('ats_express_template', 'basic_amount'); + $this->dropColumn('ats_express_template', 'extra_amount'); + $this->dropColumn('ats_express_template', 'calculation'); + $this->addColumn('ats_express_template', 'basic_count', $this->integer(20)->defaultValue(null)->comment('基本数量')); + $this->addColumn('ats_express_template', 'extra_count', $this->integer(20)->defaultValue(null)->comment('续重数量')); + $this->addColumn('ats_express_template', 'calculation_type', $this->tinyInteger(2)->defaultValue(0)->comment('计算方式')); + } + + public function down() + { + $this->dropColumn('ats_express_template', 'basic_amount'); + $this->dropColumn('ats_express_template', 'extra_amount'); + $this->dropColumn('ats_express_template', 'calculation'); + $this->addColumn('ats_express_template', 'basic_amount', $this->integer(20)->defaultValue(null)->comment('基本数量')); + $this->addColumn('ats_express_template', 'extra_amount', $this->integer(20)->defaultValue(null)->comment('续重数量')); + $this->addColumn('ats_express_template', 'calculation', $this->tinyInteger(2)->defaultValue(0)->comment('计算方式')); + return true; + } +} diff --git a/backend/modules/shop/models/ars/ExpressTemplate.php b/backend/modules/shop/models/ars/ExpressTemplate.php old mode 100755 new mode 100644 index 4774c6e..ba1f02a --- a/backend/modules/shop/models/ars/ExpressTemplate.php +++ b/backend/modules/shop/models/ars/ExpressTemplate.php @@ -1,6 +1,6 @@ '按重量', - self::CALCULATION_NUMBER => '按件数' + public static $calculationType = [ + self::CALCULATION_TYPE_WEIGHT => '按重量', + self::CALCULATION_TYPE_NUMBER => '按件数' ]; /** * {@inheritdoc} @@ -45,26 +45,13 @@ class ExpressTemplate extends \yii\db\ActiveRecord public function rules() { return [ - [['name', 'calculation', 'basic_price', 'basic_amount'], 'required'], - [['province', 'city', 'area', 'basic_price', 'extra_price', 'basic_amount', 'extra_amount'], 'string'], - [['calculation'], 'integer'], + [['name'], 'required'], + [['province', 'city', 'area'], 'string'], + [['extra_price', 'basic_price', 'basic_count', 'extra_count', 'calculation_type'], 'integer'], [['name'], 'string', 'max' => 255], - [['basic_amount', 'basic_price', 'extra_price', 'extra_amount'], 'checkNegative'], ]; } - /** - * @param $attribute - * @param $params - * 验证是否为负数 - */ - public function checkNegative($attribute, $params) - { - if ($this->$attribute < 0) { - $this->addError($attribute, "不得为负数"); - } - } - /** * {@inheritdoc} */ @@ -76,13 +63,13 @@ class ExpressTemplate extends \yii\db\ActiveRecord 'province' => '省份', 'city' => '城市', 'area' => '区域', - 'calculation' => '计算方式', - 'basic_price' => '基本运费', - 'basic_amount' => '基本数量', 'extra_price' => '续重运费', - 'extra_amount' => '续重数量', 'updated_at' => '更新时间', 'created_at' => '创建时间', + 'basic_price' => '基本运费', + 'basic_count' => '基本数量', + 'extra_count' => '续重数量', + 'calculation_type' => '计算方式', ]; } diff --git a/backend/modules/shop/models/searchs/ExpressTemplateSearch.php b/backend/modules/shop/models/searchs/ExpressTemplateSearch.php index 4cb0bff..8cee01c 100755 --- a/backend/modules/shop/models/searchs/ExpressTemplateSearch.php +++ b/backend/modules/shop/models/searchs/ExpressTemplateSearch.php @@ -26,7 +26,7 @@ class ExpressTemplateSearch extends ExpressTemplate public function rules() { return [ - [['id', 'calculation', 'basic_price', 'basic_amount', 'extra_price', 'extra_amount', 'updated_at', 'created_at'], 'integer'], + [['id', 'calculation_type', 'basic_price', 'basic_count', 'extra_price', 'extra_count', 'updated_at', 'created_at'], 'integer'], [['name', 'province', 'city', 'area'], 'safe'], ['created_at_range','safe'], ]; @@ -121,11 +121,11 @@ class ExpressTemplateSearch extends ExpressTemplate // grid filtering conditions $query->andFilterWhere([ 'id' => $this->id, - 'calculation' => $this->calculation, + 'calculation_type' => $this->calculation_type, 'basic_price' => $this->basic_price, - 'basic_amount' => $this->basic_amount, + 'basic_count' => $this->basic_count, 'extra_price' => $this->extra_price, - 'extra_amount' => $this->extra_amount, + 'extra_count' => $this->extra_count, 'updated_at' => $this->updated_at, 'created_at' => $this->created_at, ]); diff --git a/backend/modules/shop/views/express-template/_form.php b/backend/modules/shop/views/express-template/_form.php index 1dfe48e..8f21860 100755 --- a/backend/modules/shop/views/express-template/_form.php +++ b/backend/modules/shop/views/express-template/_form.php @@ -21,13 +21,13 @@ if ($status == 1) { field($model, 'name')->textInput(['maxlength' => true]) ?> -field($model, 'calculation')->widget(Icheck::className(), ["items" => ExpressTemplate::$calculation, 'type' => "radio"]) ?> +field($model, 'calculation_type')->widget(Icheck::className(), ["items" => ExpressTemplate::$calculationType, 'type' => "radio"]) ?> -field($model, 'basic_amount')->textInput() ?> +field($model, 'basic_count')->textInput() ?> field($model, 'basic_price')->textInput() ?> -field($model, 'extra_amount')->textInput() ?> +field($model, 'extra_count')->textInput() ?> field($model, 'extra_price')->textInput() ?> @@ -35,17 +35,17 @@ if ($status == 1) { $js=<<params['breadcrumbs'][] = $this->title; 'id', 'name', [ - 'attribute' => 'calculation', + 'attribute' => 'calculation_type', 'value' => function ($model) { - return ExpressTemplate::$calculation[$model->calculation]; + return ExpressTemplate::$calculationType[$model->calculation_type]; } ], 'basic_price', - 'basic_amount', + 'basic_count', 'extra_price', - 'extra_amount', + 'extra_count', 'updated_at:datetime', 'created_at:datetime', ['attribute' => 'city',