Browse Source

Merge branch 'antshop' into kernel

wechat_public_accounts
root 5 years ago
parent
commit
94643aa063
  1. 2
      backend/modules/goods/controllers/GoodsController.php
  2. 8
      backend/modules/goods/models/ars/Goods.php
  3. 61
      backend/modules/goods/views/goods/_search.php
  4. 24
      backend/modules/goods/views/goods/express.php
  5. 46
      backend/modules/goods/views/goods/goods.php
  6. 29
      backend/modules/shop/views/express-template/express_area_form.php
  7. 83
      console/runtime/logs/app.log
  8. 2
      vendor/iron/grid/GridView.php

2
backend/modules/goods/controllers/GoodsController.php

@ -99,7 +99,7 @@ class GoodsController extends Controller
$model->stock = -1;
$model->is_taking = Goods::IS_TAKING_NO;
$model->is_express = Goods::IS_EXPRESS_YES;
$model->express_type = Goods::EXPRESS_TYPE_EXPRESS_TEMPLAGE;
$model->express_type = Goods::EXPRESS_TYPE_EXPRESS_TEMPLATE;
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
if ($model->uniform_postage) {
$model->uniform_postage *= 100;

8
backend/modules/goods/models/ars/Goods.php

@ -77,7 +77,7 @@ class Goods extends \yii\db\ActiveRecord
const IS_EXPRESS_YES = 1; //是
//快递运费计算方式express_type
const EXPRESS_TYPE_UNIFORM_POSTAGE = 1; //统一邮费
const EXPRESS_TYPE_EXPRESS_TEMPLAGE = 2; //运费模板
const EXPRESS_TYPE_EXPRESS_TEMPLATE = 2; //运费模板
public static $isTaking = [
self::IS_TAKING_NO => '否',
@ -89,7 +89,7 @@ class Goods extends \yii\db\ActiveRecord
];
public static $expressType = [
self::EXPRESS_TYPE_UNIFORM_POSTAGE => '统一邮费',
self::EXPRESS_TYPE_EXPRESS_TEMPLAGE => '运费模板'
self::EXPRESS_TYPE_EXPRESS_TEMPLATE => '运费模板'
];
public static $isSale = [
self::IS_SALE_NO => '不在售',
@ -128,7 +128,7 @@ class Goods extends \yii\db\ActiveRecord
public function rules()
{
return [
[['pid', 'cat_id', 'brand_id', 'shop_cat_id', 'supplier_id', 'weight', 'length', 'width', 'height', 'diameter', 'sold_count', 'limit_count', 'stock', 'stock_warn', 'market_price', 'price', 'image', 'model_id', 'is_sale', 'sort_order', 'bouns_points', 'experience_points', 'is_delete', 'express_template', 'sku_mode', 'is_taking', 'is_express', 'express_type'], 'integer'],
[['pid', 'cat_id', 'brand_id', 'shop_cat_id', 'supplier_id', 'weight', 'length', 'width', 'height', 'diameter', 'sold_count', 'limit_count', 'stock', 'stock_warn', 'image', 'model_id', 'is_sale', 'sort_order', 'bouns_points', 'experience_points', 'is_delete', 'express_template', 'sku_mode', 'is_taking', 'is_express', 'express_type'], 'integer'],
[['cat_id', 'brand_id', 'shop_cat_id', 'name'], 'required'],
[['sn'], 'checkExist'],
[['description', 'coverImageId', 'detailImageId'], 'string'],
@ -138,7 +138,7 @@ class Goods extends \yii\db\ActiveRecord
[['unit'], 'string', 'max' => 16],
[['brief'], 'string', 'max' => 255],
[['weight', 'length', 'width', 'height', 'diameter', 'sold_count', 'market_price', 'price', 'uniform_postage'], 'checkNegative'],
[['uniform_postage'], 'safe']
[['uniform_postage', 'market_price', 'price'], 'safe']
];
}

61
backend/modules/goods/views/goods/_search.php

@ -3,6 +3,9 @@
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use \blobt\widgets\DateRangePicker;
use linyao\widgets\Select2;
use backend\modules\goods\models\ars\Category;
use backend\modules\goods\models\ars\ShopCategory;
/* @var $this yii\web\View */
/* @var $model common\models\searchs\GoodsSearch */
@ -13,9 +16,9 @@ use \blobt\widgets\DateRangePicker;
'action' => ['index'],
'method' => 'get',
'validateOnType' => true,
]);
]);
?>
<div class="row">
<div class="row">
<div class="col">
<?= $form->field($model, 'id', [
"template" => "{input}{error}",
@ -29,6 +32,58 @@ use \blobt\widgets\DateRangePicker;
])
?>
</div>
<div class="col">
<?= $form->field($model, 'name', [
"template" => "{input}{error}",
"inputOptions" => [
"placeholder" => "商品名称",
"class" => "form-control",
],
"errorOptions" => [
"class" => "error-tips"
]
])
?>
</div>
<div class="col">
<?= $form->field($model, 'sn', [
"template" => "{input}{error}",
"inputOptions" => [
"placeholder" => "商品唯一货号",
"class" => "form-control",
],
"errorOptions" => [
"class" => "error-tips"
]
])
?>
</div>
<div class="col">
<?= $form->field($model, 'cat_id', [
"template" => "{input}{error}",
"inputOptions" => [
"placeholder" => "后台商品类别",
"class" => "form-control",
],
"errorOptions" => [
"class" => "error-tips"
]
])->dropDownList(Category::modelColumn(), ['prompt' => '后台商品类别']);
?>
</div>
<div class="col">
<?= $form->field($model, 'shop_cat_id', [
"template" => "{input}{error}",
"inputOptions" => [
"placeholder" => "前端商品类别",
"class" => "form-control",
],
"errorOptions" => [
"class" => "error-tips"
]
])->dropDownList(ShopCategory::modelColumn(), ['prompt' => '前端商品类别']);
?>
</div>
<div class="col">
<?= $form->field($model, "created_at_range", [
"template" => "{input}{error}",
@ -45,5 +100,5 @@ use \blobt\widgets\DateRangePicker;
<?= Html::submitButton('<i class="fa fa-filter"></i>', ['class' => 'btn btn-default']) ?>
<?= Html::resetButton('<i class="fa fa-eraser"></i>', ['class' => 'btn btn-default']) ?>
</div>
</div>
</div>
<?php ActiveForm::end(); ?>

24
backend/modules/goods/views/goods/express.php

@ -21,7 +21,7 @@ use backend\modules\shop\models\ars\ExpressTemplate;
<?= $form->field($model, 'uniform_postage')->textInput() ?>
</fieldset>
<fieldset id="expressTemplate" style="display: <?= $model->express_type == Goods::EXPRESS_TYPE_EXPRESS_TEMPLAGE ? 'block' : 'none' ?>">
<fieldset id="expressTemplate" style="display: <?= $model->express_type == Goods::EXPRESS_TYPE_EXPRESS_TEMPLATE ? 'block' : 'none' ?>">
<?= $form->field($model, 'express_template')->widget(Select2::className(), ["items" => ExpressTemplate::modelColumn()]) ?>
</fieldset>
</fieldset>
@ -52,8 +52,28 @@ use backend\modules\shop\models\ars\ExpressTemplate;
$(this).val("0.00")
}
var basicPrice = $(this).val();
$(this).val(basicPrice.toString().match(/^\d+(?:\.\d{0,2})?/));
$(this).val(toFixeds($(this).val(), 2));
})
//金额补全
function toFixeds(val, pre) {
const num = parseFloat(val);
// eslint-disable-next-line no-restricted-globals
if (isNaN(num)) {
return false;
}
const p = 10 ** pre;
const value = num * p;
let f = (Math.round(value) / p).toString();
let rs = f.indexOf('.');
if (rs < 0) {
rs = f.length;
f += '.';
}
while (f.length <= rs + pre) {
f += '0';
}
return f;
}
JS;
$this->registerJs($js);

46
backend/modules/goods/views/goods/goods.php

@ -62,3 +62,49 @@ use backend\modules\goods\models\ars\Goods;
<?= Html::submitButton('保存', ['class' => 'btn btn-success']) ?>
<?= Html::a('返回', ['index'], ['class' => 'btn btn-info']) ?>
</div>
<?php
$js =<<<JS
$("#goods-market_price").blur(function(){
if(isNaN($(this).val())){
$(this).val("0.00")
}
if($(this).val().indexOf('-') != -1){
$(this).val("0.00")
}
var basicPrice = $(this).val();
$(this).val(toFixeds($(this).val(), 2));
})
$("#goods-price").blur(function(){
if(isNaN($(this).val())){
$(this).val("0.00")
}
if($(this).val().indexOf('-') != -1){
$(this).val("0.00")
}
var basicPrice = $(this).val();
$(this).val(toFixeds($(this).val(), 2));
})
//金额补全
function toFixeds(val, pre) {
const num = parseFloat(val);
// eslint-disable-next-line no-restricted-globals
if (isNaN(num)) {
return false;
}
const p = 10 ** pre;
const value = num * p;
let f = (Math.round(value) / p).toString();
let rs = f.indexOf('.');
if (rs < 0) {
rs = f.length;
f += '.';
}
while (f.length <= rs + pre) {
f += '0';
}
return f;
}
JS;
$this->registerJs($js);
?>

29
backend/modules/shop/views/express-template/express_area_form.php

@ -86,6 +86,26 @@ function changeCalType(type){//当切换计算方式
}
calType = type;
}
//金额补全
function toFixeds(val, pre) {
const num = parseFloat(val);
// eslint-disable-next-line no-restricted-globals
if (isNaN(num)) {
return false;
}
const p = 10 ** pre;
const value = num * p;
let f = (Math.round(value) / p).toString();
let rs = f.indexOf('.');
if (rs < 0) {
rs = f.length;
f += '.';
}
while (f.length <= rs + pre) {
f += '0';
}
return f;
}
$(document).ready(function(){
$("#expressarea-basic_count").blur(function(){
if(isNaN($(this).val())){
@ -96,8 +116,7 @@ $(document).ready(function(){
$(this).val(1)
}
var basiccount = $(this).val();
// $(this).val(Math.floor(basiccount * 10) / 10);
$(this).val(basiccount.toString().match(/^\d+(?:\.\d{0,1})?/));
$(this).val(toFixeds($(this).val(), 1));
} else{
if($(this).val() < 1){
$(this).val(1)
@ -114,7 +133,7 @@ $(document).ready(function(){
$(this).val("0.00")
}
var basicPrice = $(this).val();
$(this).val(basicPrice.toString().match(/^\d+(?:\.\d{0,2})?/));
$(this).val(toFixeds($(this).val(), 2));
})
$("#expressarea-extra_count").blur(function(){
if(isNaN($(this).val())){
@ -125,7 +144,7 @@ $(document).ready(function(){
$(this).val(0)
}
var basiccount = $(this).val();
$(this).val(Math.floor(basiccount * 10) / 10);
$(this).val(toFixeds($(this).val(), 1));
} else{
if($(this).val() < 0){
$(this).val(0)
@ -142,7 +161,7 @@ $(document).ready(function(){
$(this).val("0.00")
}
var basicPrice = $(this).val();
$(this).val(basicPrice.toString().match(/^\d+(?:\.\d{0,2})?/));
$(this).val(toFixeds($(this).val(), 2));
})
$("input:radio[name='ExpressArea[calculation_type]']").on('ifChecked', function(event){

83
console/runtime/logs/app.log
File diff suppressed because it is too large
View File

2
vendor/iron/grid/GridView.php

@ -269,7 +269,7 @@ HTML;
</div>
HTML;
public $create =<<<HTML
<a href="{url}/create" class="btn btn-default"><i class="fas fa-plus-square mr-2"></i>添加</a>
<a href="create" class="btn btn-default"><i class="fas fa-plus-square mr-2"></i>添加</a>
HTML;
/**

Loading…
Cancel
Save