|
@@ -3,6 +3,7 @@
|
|
|
namespace app\admin\controller;
|
|
|
|
|
|
use app\common\controller\Backend;
|
|
|
+use app\common\model\GoodsBind;
|
|
|
use app\common\model\GoodsSku;
|
|
|
use think\Db;
|
|
|
|
|
@@ -189,25 +190,17 @@ class Goods extends Backend
|
|
|
$this->assign('row',$goods);
|
|
|
return $this->fetch();
|
|
|
}else{
|
|
|
- $e=input('e');
|
|
|
- $skuId=input('sku_id');
|
|
|
- $goodsId=input('goods_id');
|
|
|
- if($e=='get'){
|
|
|
- $goods=$this->model->find($goodsId);
|
|
|
- $bindId=$goods->binds()->where('goods_sku_id',$skuId)->column('bind_goods_id');
|
|
|
- $this->success('','',$bindId);
|
|
|
- }
|
|
|
- $goods=$this->model->find($ids);
|
|
|
- $skuId=input('row.sku_id');
|
|
|
- $bindGoods=input('row.goods_id');
|
|
|
- $sku=GoodsSku::find($skuId);
|
|
|
- $goodsIds=array_filter(explode(',',$bindGoods));
|
|
|
- $goods->binds()->where('goods_sku_id',$skuId)->delete();
|
|
|
- foreach ($goodsIds as $_id){
|
|
|
- $goods->binds()->save([
|
|
|
- 'goods_sku_id'=>$sku['id'],
|
|
|
- 'bind_goods_id'=>$_id,
|
|
|
- ]);
|
|
|
+ $data=input('row/a');
|
|
|
+ foreach ($data as $goods_sku_id=>$info){
|
|
|
+ $goodsIds=array_filter(explode(',',$info['goods_id']));
|
|
|
+ $sku=GoodsSku::find($goods_sku_id);
|
|
|
+ $arr=[];
|
|
|
+ foreach ($goodsIds as $goodsId){
|
|
|
+ $arr[$goodsId]=[
|
|
|
+ 'goods_id'=>$ids,
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ $sku->bindGoods()->sync($arr);
|
|
|
}
|
|
|
$this->success();
|
|
|
}
|