/** * @title 发布装修的店铺 * @example FlagShipShopDecorate.fabu? 调试参数:{"username":"17721355485","check_code":"123456","method":"FlagShipShopDecorate.fabu"} * @return {"status":"0","errorCode":"0","msg":"该样式已发布成功","result":[]} * @method POST * @author 邹柯 */ public function fabu($res){ $user_id=session("user.user_id"); $user_shop_decorate=M('user_shop_decorate'); $usd_where['create_id']=$user_id; $usd_where['flagship_shop']=1; $res_info=$user_shop_decorate->field('id,use_status,plate_content_draft,plate_content_draft_features')->where($usd_where)->order('create_time desc')->find(); if(!empty($res_info)){ $us_where['id']=array("neq",$res_info['id']); $u_data=[ 'use_status'=>1, 'select_status'=>1 ]; $res_da=$user_shop_decorate->data($u_data)->where($us_where)->save(); if(!$res_da && $res_da !=0){ E('700403'); } } $plate_content_draft=json_decode($res_info['plate_content_draft'],true); foreach($plate_content_draft as $k=>$v){ foreach($v['goods'] as $k2=>$v2){ if($v2['operate_type']==2){ E('700415'); } } } $plate_content_draft_features=json_decode($res_info['plate_content_draft_features'],true); foreach($plate_content_draft_features as $k=>$v){ $operate_types=array_unique(array_column($v['goods'],'operate_type')); if(count($operate_types) >=2){ E('700415'); } if($operate_types[0]==2){ unset($plate_content_draft_features[$k]); } } $time=date("Y-m-d H:i:s",time()); $data=array( 'plate_content'=>$res_info['plate_content_draft'], 'plate_content_features'=>empty($plate_content_draft_features)?null:json_encode($plate_content_draft_features), 'status'=>2, 'update_time'=>$time, 'update_id'=>$user_id, 'use_status'=>2, 'select_status'=>2 ); $res=$user_shop_decorate->data($data)->where(['id'=>$res_info['id']])->save(); if(!$res && $res !=0){ E('700403'); } $list['msg']="该样式已发布成功"; return $list; }