/** * @title 选中蜂店装修模板样式 * @param plate_id 是 int 商品(平台或特色)装修样式ID * @param type_id 是 int 要装修商品的类型(1-平台、2-特色) * @example FlagShipShopDecorate.selectShopDecorate? 调试参数:{"username":"17721355485","check_code":"123456","method":"FlagShipShopDecorate.selectShopDecorate","plate_id":"71","type_id":"1"} * @return {"status":"0","errorCode":"0","msg":"成功","result":[]} * @method POST * @author 邹柯 */ public function selectShopDecorate($res){ $user_id=session("user.user_id"); $plate_id=$res['plate_id']; if(empty($plate_id)){ E('700401'); } $type_id=$res['type_id']; if($type_id !=1 && $type_id !=2){ E('700416'); } $user_shop_decorate=M('user_shop_decorate'); $usd_where['create_id']=$user_id; $usd_where['flagship_shop']=1; $count=$this->getDecorate($user_shop_decorate,$usd_where); $plate_content=$this->getDefaultStyleByPlateId($plate_id,$type_id); $plate_content_draft=json_encode($plate_content); $time=date("Y-m-d H:i:s",time()); if($type_id==1){ $field1="plate_content_draft"; $field2="plate_id"; $field3="select_status"; }else{ $field1="plate_content_draft_features"; $field2="plate_id_features"; $field3="select_status_features"; } if(empty($count)){ $data=array( $field2=>$plate_id, $field1=>$plate_content_draft, 'status'=>1, 'create_time'=>$time, 'create_id'=>$user_id, 'update_time'=>$time, 'update_id'=>$user_id, 'use_status'=>1, $field3=>2, 'flagship_shop'=>1 ); $res=$user_shop_decorate->data($data)->add(); if(!$res && $res !=0){ E('7004034'); } }else{ if($count['use_status']==2){ $use_status=2; }else{ $use_status=1; } if($type_id==1){ if($count['plate_id']==$plate_id){ return true; } }else{ if($count['plate_id_features']==$plate_id){ return true; } } $data=array( $field2=>$plate_id, $field1=>$plate_content_draft, 'status'=>1, 'create_time'=>$time, 'create_id'=>$user_id, 'update_time'=>$time, 'update_id'=>$user_id, 'use_status'=>$use_status, $field3=>2 ); $res=$user_shop_decorate->data($data)->where(['id'=>$count['id']])->save(); if(!$res && $res !=0){ E('7004034'); } } return true; } //获取店铺装修信息 public function getDecorate($user_shop_decorate,$usds_where){ $res_info=$user_shop_decorate->field('id,plate_id,plate_id_features,use_status,plate_content_draft,plate_content_draft_features') ->where($usds_where) ->order('create_time desc') ->find(); return $res_info; }