1
This commit is contained in:
parent
7c9f67e8bc
commit
527ddb7063
@ -131,10 +131,16 @@ class CommonGoodsEditForm extends Model
|
||||
$this->model->freight_id = $this->freight_id;
|
||||
$this->model->sort = $this->sort;
|
||||
$this->model->status = 1;
|
||||
// $this->handleAttrGroups();
|
||||
// $this->model->attr_groups = json_encode($this->attrGroups,JSON_UNESCAPED_UNICODE);
|
||||
$this->model->attr_groups = 1; //商品规格组 用不到看表 0 不需要规格组
|
||||
|
||||
$this->handleAttrGroups();
|
||||
|
||||
if ($this->attrGroups) {
|
||||
$this->model->attr_groups = json_encode($this->attrGroups, JSON_UNESCAPED_UNICODE);
|
||||
|
||||
$this->use_attr = 1;
|
||||
$this->model->use_attr = $this->use_attr;
|
||||
// $this->model->attr_groups = 1; //商品规格组 用不到看表 0 不需要规格组
|
||||
}
|
||||
$this->model->date = strtotime($this->date);
|
||||
|
||||
//保存商品基础信息
|
||||
@ -142,7 +148,11 @@ class CommonGoodsEditForm extends Model
|
||||
|
||||
//保存商品基础信息
|
||||
$res1 = $this->saveGoodsCat();
|
||||
|
||||
$res2 = $this->saveGoodsAttr();
|
||||
if ($res2['code'] != 0) {
|
||||
$t->rollBack();
|
||||
return $res;
|
||||
}
|
||||
|
||||
if ($res['code'] != 0 || $res1['code'] != 0) {
|
||||
$t->rollBack();
|
||||
@ -273,7 +283,7 @@ class CommonGoodsEditForm extends Model
|
||||
}
|
||||
$goodsAttr->goods_id = $this->model->id;
|
||||
$goodsAttr->sign_id = $signIds;
|
||||
$goodsAttr->stock = $newAttr['stock'];
|
||||
$goodsAttr->stock = 0;
|
||||
$goodsAttr->price = $newAttr['price'];
|
||||
$goodsAttr->serial_no = $newAttr['serial_no'];
|
||||
$goodsAttr->weight = $newAttr['weight'] ?: 0;
|
||||
@ -290,7 +300,7 @@ class CommonGoodsEditForm extends Model
|
||||
if ($goodsStock > 9999999) {
|
||||
return $this->apiReturnError('商品总库存不能大于9999999');
|
||||
}
|
||||
$this->model->goods_stock = $goodsStock;
|
||||
$this->model->goods_stock = 0;
|
||||
$res = $this->model->save();
|
||||
if (!$res) {
|
||||
return $this->getModelError($this->model);
|
||||
|
||||
@ -165,10 +165,12 @@ class CommonGoodsListForm extends Model
|
||||
|
||||
$item['cover_pic'] = SiteHelper::getFullUrl($item['cover_pic']);
|
||||
if ($this->scenario == 'detail') {
|
||||
$item['detail'] = SiteHelper::repairContent($item['detail']);
|
||||
$item['pic_urls'] = $this->fixPicUrls($item['pic_urls']);
|
||||
$item['video_url'] = SiteHelper::getFullUrl($item['video_url']);
|
||||
$item['goods_sales'] = $item['virtaul_sales'] + $item['sales'];
|
||||
|
||||
|
||||
// $item['detail'] = SiteHelper::repairContent($item['detail']);
|
||||
// $item['pic_urls'] = $this->fixPicUrls($item['pic_urls']);
|
||||
// $item['video_url'] = SiteHelper::getFullUrl($item['video_url']);
|
||||
// $item['goods_sales'] = $item['virtaul_sales'] + $item['sales'];
|
||||
$item['attr_groups'] = empty($item['attr_groups']) ? [] : json_decode($item['attr_groups'], true);
|
||||
$item['attr'] = $this->getAttr($item['id']);
|
||||
}
|
||||
@ -300,10 +302,6 @@ class CommonGoodsListForm extends Model
|
||||
])
|
||||
->select('gr.id,gr.goods_id,gr.price,gr.sign_id,gr.stock,gr.serial_no,gr.weight,gr.cover_pic')
|
||||
->asArray()->all();
|
||||
foreach ($attr as $index => $item) {
|
||||
$item['cover_pic'] = SiteHelper::getFullUrl($item['cover_pic']);
|
||||
$attr[$index] = $item;
|
||||
}
|
||||
return $attr;
|
||||
|
||||
}
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
* _____LOG_____
|
||||
*
|
||||
*/
|
||||
|
||||
namespace app\models\common\integral\mall;
|
||||
|
||||
use app\models\common\CommonGoodsListForm;
|
||||
@ -48,12 +49,30 @@ class CommonIntegralMallGoodsListForm extends CommonGoodsListForm
|
||||
}
|
||||
$item['cover_pic'] = SiteHelper::getFullUrl($item['cover_pic']);
|
||||
if ($this->scenario == 'detail') {
|
||||
$item['detail'] = SiteHelper::repairContent($item['detail']);
|
||||
$item['pic_urls'] = $this->fixPicUrls($item['pic_urls']);
|
||||
$item['video_url'] = SiteHelper::getFullUrl($item['video_url']);
|
||||
$item['goods_sales'] = $item['virtaul_sales'] + $item['sales'];
|
||||
// $item['detail'] = SiteHelper::repairContent($item['detail']);
|
||||
// $item['pic_urls'] = $this->fixPicUrls($item['pic_urls']);
|
||||
// $item['video_url'] = SiteHelper::getFullUrl($item['video_url']);
|
||||
// $item['goods_sales'] = $item['virtaul_sales'] + $item['sales'];
|
||||
$item['attr_groups'] = empty($item['attr_groups']) ? [] : json_decode($item['attr_groups'], true);
|
||||
$item['attr'] = $this->getAttr($item['id']);
|
||||
$attr = $this->getAttr($item['id']);
|
||||
|
||||
$attr = array_column($attr, 'price', 'sign_id');
|
||||
|
||||
if (is_array($item['attr_groups'])) {
|
||||
|
||||
foreach ($item['attr_groups'] as $key => $value) {
|
||||
|
||||
// unset($value['attr_group_name']);
|
||||
unset($value['attr_group_id']);
|
||||
|
||||
foreach ($value['attr_list'] as $key1 => $value1) {
|
||||
$value['attr_list'][$key1]['price'] = $attr[$value1['attr_id']];
|
||||
}
|
||||
$item['attr_groups'][$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
$list[$index] = $item;
|
||||
}
|
||||
@ -64,18 +83,13 @@ class CommonIntegralMallGoodsListForm extends CommonGoodsListForm
|
||||
private function getAttr($goods_id)
|
||||
{
|
||||
$attr = GoodsAttr::find()->alias('gr')
|
||||
->leftJoin(['imgr' => IntegralMallGoodsAttr::tableName()],'imgr.goods_attr_id=gr.id')
|
||||
->where([
|
||||
'gr.goods_id' => $goods_id,
|
||||
'gr.is_delete' => 0,
|
||||
'imgr.is_delete' => 0
|
||||
])
|
||||
->select('gr.id,gr.goods_id,gr.price,gr.sign_id,gr.stock,gr.serial_no,gr.weight,gr.cover_pic,imgr.integral_num')
|
||||
->select('gr.id,gr.goods_id,gr.price,gr.sign_id')
|
||||
->asArray()->all();
|
||||
foreach($attr as $index => $item){
|
||||
$item['cover_pic'] = SiteHelper::getFullUrl($item['cover_pic']);
|
||||
$attr[$index] = $item;
|
||||
}
|
||||
|
||||
return $attr;
|
||||
|
||||
}
|
||||
|
||||
@ -137,8 +137,6 @@ class GoodsController extends Controller
|
||||
if (\Yii::$app->request->isPost) {
|
||||
$form = new CommonGoodsEditForm();
|
||||
$post = \Yii::$app->request->post();
|
||||
|
||||
|
||||
$form->attributes = $post;
|
||||
$form->cx_mch_id = $this->cx_mch_id;
|
||||
$form->model = $model;
|
||||
@ -196,17 +194,42 @@ class GoodsController extends Controller
|
||||
|
||||
$model->date = date('Y', $model->date);
|
||||
|
||||
// var_dump($model->goodsHub->video_url);
|
||||
// var_dump($model->goodsHub->video_banner_urls);
|
||||
//
|
||||
// die();
|
||||
|
||||
|
||||
$attr = [];
|
||||
$attr_groups = [];
|
||||
if ($model->use_attr == 1) {
|
||||
$attr_groups = !empty($model->attr_groups) ? json_decode($model->attr_groups, true) : [];
|
||||
$attr = GoodsAttr::find()->alias('ga')
|
||||
->where([
|
||||
'ga.goods_id' => $model->id,
|
||||
'ga.is_delete' => 0
|
||||
])
|
||||
->select('ga.id,ga.price,ga.stock,ga.serial_no,ga.weight,ga.cover_pic,ga.sign_id')
|
||||
->asArray()->all();
|
||||
foreach ($attr as $index => $item) {
|
||||
$item['attr_list'] = [];
|
||||
$sign_ids = explode(':', $item['sign_id']);
|
||||
foreach ($sign_ids as $attr_id) {
|
||||
$attr_info = $this->getAttrInfo($attr_id, $attr_groups);
|
||||
if (!empty($attr_info)) {
|
||||
$item['attr_list'][] = $attr_info;
|
||||
}
|
||||
}
|
||||
$attr[$index] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return $this->render('edit', [
|
||||
'cat_list' => $cat_list,
|
||||
'cat_list1' => $cat_list1,
|
||||
'cat_list2' => $cat_list2,
|
||||
'cat_list3' => $cat_list3,
|
||||
'cat_list4' => $cat_list4,
|
||||
|
||||
'attr' => $attr,
|
||||
'attr_groups' => $attr_groups,
|
||||
'model' => $model,
|
||||
'return_url' => $return_url,
|
||||
]);
|
||||
|
||||
@ -51,6 +51,12 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
]) ?>
|
||||
|
||||
|
||||
<div class="layui-form-item">
|
||||
|
||||
<?= GoodsSku::widget(['id' => 'goods_attrs', 'attr' => $attr, 'attr_groups' => $attr_groups, 'open_integral' => false]) ?>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label required">冠军级别</label>
|
||||
<div class="layui-input-block" style="width: 200px">
|
||||
@ -310,6 +316,12 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
return val.url
|
||||
})
|
||||
|
||||
|
||||
var attrs = fixAttrGroups();
|
||||
data.attr = attrs.attr;
|
||||
data.attrGroups = attrs.attr_groups;
|
||||
|
||||
|
||||
data.video_url = JSON.stringify(urls);
|
||||
data.pic_urls = JSON.stringify(_gallery_pic_urls);
|
||||
data._csrf = _csrf;
|
||||
|
||||
@ -70,11 +70,18 @@ class GoodsController extends Controller
|
||||
public function actionIndex()
|
||||
{
|
||||
$form = new CommonIntegralMallGoodsListForm();
|
||||
$form->attributes = \Yii::$app->request->get();
|
||||
|
||||
$get = \Yii::$app->request->get();
|
||||
$form->attributes = $get;
|
||||
$form->cx_mch_id = $this->cx_mch_id;
|
||||
$form->status = Goods::STATUS_ONLINE;
|
||||
$form->plugin_sign = SysConst::$cxPluginSceneIntegralMall;
|
||||
$form->setFields('g.id,g.price,g.date,g.sort,gh.subtitle,gh.banner_urls,g.created_at,gh.name,gh.cover_pic,gh.video_url,gh.pic_urls,gh.video_banner_urls');
|
||||
|
||||
if (isset($get['goods_id'])) {
|
||||
$form->scenario = 'detail';
|
||||
}
|
||||
|
||||
$form->setFields('g.id,g.price,g.attr_groups,g.date,g.sort,gh.subtitle,gh.banner_urls,g.created_at,gh.name,gh.cover_pic,gh.video_url,gh.pic_urls,gh.video_banner_urls');
|
||||
$data = $form->search();
|
||||
|
||||
foreach ($data['data'] as $key => $value) {
|
||||
|
||||
@ -40,12 +40,12 @@
|
||||
}
|
||||
</style>
|
||||
<div class="layui-form-item attr-group-panel" id="<?=$id?>" lay-ignore>
|
||||
<label class="layui-form-label">规格组与规格值</label>
|
||||
<label class="layui-form-label">业务类型</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="input-control-group">
|
||||
<label class="label">规格组</label>
|
||||
<label class="label">业务组</label>
|
||||
<div class="input-wrap">
|
||||
<input type="text" name="" required="" placeholder="请输入如颜色" autocomplete="off" class="input-control" v-model="attr_group_name">
|
||||
<input type="text" name="" required="" placeholder="请输入业务" autocomplete="off" class="input-control" v-model="attr_group_name">
|
||||
</div>
|
||||
<span class="btn-control" v-on:click="add_attr_group"><i class="layui-icon"></i>添加</span>
|
||||
</div>
|
||||
@ -83,57 +83,13 @@
|
||||
<button class="layui-btn layui-btn-primary layui-btn-sm" v-on:click="batch_set_goods_price()" >设置</button>
|
||||
</div>
|
||||
</th>
|
||||
<th>
|
||||
<div class="layui-inline">库存</div>
|
||||
<div class="layui-inline">
|
||||
<input class="layui-input" type="text" placeholder="批量设置库存" name="batch_stock" v-model="batch_stock" style="margin-right: 0;height: 34px;line-height: 34px;width:120px"/>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<button class="layui-btn layui-btn-primary layui-btn-sm" v-on:click="batch_set_goods_stock()" >设置</button>
|
||||
</div>
|
||||
</th>
|
||||
<?php if($open_integral):?>
|
||||
<th>
|
||||
<div class="layui-inline">积分</div>
|
||||
<div class="layui-inline">
|
||||
<input class="layui-input" type="number" placeholder="批量设置积分" name="batch_integral_num" v-model="batch_integral_num" style="margin-right: 0;height: 34px;line-height: 34px;width:120px"/>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<button class="layui-btn layui-btn-primary layui-btn-sm" v-on:click="batch_set_goods_integral_num()" >设置</button>
|
||||
</div>
|
||||
</th>
|
||||
<?php endif;?>
|
||||
<th>
|
||||
<div class="layui-inline">货号</div>
|
||||
</th>
|
||||
<th>
|
||||
<div class="layui-inline">重量</div>
|
||||
</th>
|
||||
<th>
|
||||
<div class="layui-inline">图片</div>
|
||||
</th>
|
||||
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="(goods_attr,index) in attr">
|
||||
<td v-for="attr_val in goods_attr['attr_list']">{{attr_val.attr_name}}</td>
|
||||
<td><input class="layui-input" type="number" placeholder="" name="" v-model="attr[index]['price']" style="margin-right: 0;height: 34px;line-height: 34px;"/></td>
|
||||
<td><input class="layui-input" type="number" placeholder="" name="" v-model="attr[index]['stock']" style="margin-right: 0;height: 34px;line-height: 34px;"/></td>
|
||||
<?php if($open_integral):?>
|
||||
<td><input class="layui-input" type="number" placeholder="" name="" v-model="attr[index]['integral_num']" style="margin-right: 0;height: 34px;line-height: 34px;"/></td>
|
||||
<?php endif;?>
|
||||
<td><input class="layui-input" type="text" placeholder="" name="" v-model="attr[index]['serial_no']" style="margin-right: 0;height: 34px;line-height: 34px;width:88px"/></td>
|
||||
<td><input class="layui-input" type="number" placeholder="" name="" v-model="attr[index]['weight']" style="margin-right: 0;height: 34px;line-height: 34px;width:88px"/></td>
|
||||
<td>
|
||||
<div class="layui-inline">
|
||||
<img v-bind:src="attr[index]['cover_pic']" style="width:34px;height:34px;">
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<input class="layui-input" type="text" placeholder="" name="" v-model="attr[index]['cover_pic']" style="margin-right: 0;height: 34px;line-height: 34px;"/>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<button class="layui-btn layui-btn-primary layui-btn-sm " v-on:click="upload_goods_cover_pic(index)"><i class="layui-icon"></i></button>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@ -322,10 +278,6 @@
|
||||
item.sign_id = sign_ids.join(':');
|
||||
item.attr_list = attr_list;
|
||||
item.price = '';
|
||||
item.stock = 0;
|
||||
item.cover_pic = '';
|
||||
item.serial_no = '';
|
||||
item.weight = '';
|
||||
<?php if($open_integral):?>
|
||||
item.integral_num = 0;
|
||||
<?php endif;?>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user