|
@@ -160,6 +160,9 @@ class ShopProduction extends Controller
|
|
|
// print_r($data);
|
|
|
// exit();
|
|
|
//$order= \app\data\model\ShopProduction::create($data);
|
|
|
+ if(!$data['offer_id']){
|
|
|
+ unset($data['offer_id']);
|
|
|
+ }
|
|
|
$order=Model::update($data);
|
|
|
// $order->items()->saveAll($item);
|
|
|
app()->db->commit();
|
|
@@ -167,13 +170,18 @@ class ShopProduction extends Controller
|
|
|
$item_ids=[];
|
|
|
foreach ($item as &$v){
|
|
|
$item_data = [
|
|
|
- 'purchase_id'=>$data['id'],
|
|
|
+ 'production_id'=>$data['id'],
|
|
|
'name'=>$v['name'],
|
|
|
'spec'=>$v['spec'],
|
|
|
'number'=>$v['number'],
|
|
|
// 'standard'=>$v['standard'],
|
|
|
// 'price'=>$v['price'],
|
|
|
];
|
|
|
+ if(isset($v['enclosure'])){
|
|
|
+ $item_data['enclosure'] = $v['enclosure'];
|
|
|
+ }else{
|
|
|
+ $item_data['enclosure'] = [];
|
|
|
+ }
|
|
|
if(!empty($v['id'])){
|
|
|
$itemModel=$order->items()->where('id',$v['id'])->find();
|
|
|
if(!$itemModel){
|
|
@@ -185,10 +193,10 @@ class ShopProduction extends Controller
|
|
|
}
|
|
|
$item_ids[]=$itemModel['id'];
|
|
|
}
|
|
|
- $order = $order->items()->whereNotIn('id',$item_ids)->select()->each(function ($d){$d->delete();});
|
|
|
- ShopProductionOffer::where('order_id',$data['id'])
|
|
|
- ->whereNotIn('item_id',$item_ids)
|
|
|
- ->select()->each(function ($m){$m->delete();});
|
|
|
+// $order = $order->items()->whereNotIn('id',$item_ids)->select()->each(function ($d){$d->delete();});
|
|
|
+// ShopProductionOffer::where('order_id',$data['id'])
|
|
|
+// ->whereNotIn('item_id',$item_ids)
|
|
|
+// ->select()->each(function ($m){$m->delete();});
|
|
|
$this->success('保存成功');
|
|
|
}
|
|
|
}
|