50 ? 50 : (int)$post["pageSize"]; $post["page"] = $post["page"]<=0 ? 1 : (int)$post["page"]; $data = (new ShowTemplateModel)->getDataList($post,"*",1); return app('json')->success(["list" =>$data["list"], "pageSize" => $data["pageSize"],"page"=>$data["page"],"pageCount"=>$data["totalCount"]]); } /** * 添加编辑商品 * @param Request $request * @return type */ public function add(Request $request){ $post = UtilService::getMore([ ['id',''], ['title','','empty','请填写模板标题'], ['price','0','is_numeric','请输入正确的模板售价'], ['old_price','0','is_numeric','请输入正确的模板原价'], // ['imgs',[],'empty','请上传商品主图'], ['imgs',[]], ['is_hot','0'], ['is_recommend','0'], ['is_init','0'], ['code','','empty','请输入CODE'], ['status','0'], ['unreal_sales','0'], ],$request); $save=[]; $save["title"] = $post["title"]; $save["price"] = floatval($post["price"]); $save["old_price"] = floatval($post["old_price"]); $save["status"] = (int)$post["status"] == 1 ? 1 : 0; $save["imgs"] = empty($post["imgs"]) ? "" : implode(",", $post["imgs"]); $save["is_hot"] = (int)$post["is_hot"] == 1 ? 1 : 0; $save["is_recommend"] = (int)$post["is_recommend"]== 1 ? 1 : 0; $save["is_init"] = (int)$post["is_init"] == 1 ? 1 : 0; $save["code"] = $post["code"]; $save["unreal_sales"] = (int)$post["unreal_sales"]; $save["admin_time"] = time(); $save["admin_id"] = $request->adminInfo['id']; if($save["price"]<0 || $save["old_price"]<0){ return app('json')->fail("请输入正确的价格"); } $id = empty($post["id"])?0:(int)$post["id"]; $codeWhere[]=["code","=",$save["code"]]; if($id>0){ $codeWhere[]=["id","<>",$id]; } $count = (new ShowTemplateModel)->where($codeWhere)->where("id","<>",$id)->count(); if($count>0){ return app('json')->fail("当前code已存在"); } $r=0; if(empty($id) || $id=="0"){ $save["time"] = time(); $r = (new ShowTemplateModel)->insert($save); }else{ $r = (new ShowTemplateModel)->where("id",$id)->update($save); } if($r){ return app('json')->success("数据保存成功"); }else{ return app('json')->fail("数据保存失败"); } } /** * 服务类型列表 * @param Request $request * @return type */ public function serviceType(Request $request) { $post = UtilService::getMore([ ['page',1], ['pageSize', 50], ['title',''], ['status',''], ],$request); $data = (new ServiceTypeModel)->getList($post); return app('json')->success([ 'list' => $data["list"], 'pageCount' => $data["totalCount"], 'pageSize' => $data["pageSize"], 'page' => $data["page"], ]); } /** * 添加服务内容 */ public function serviceTypeAdd(Request $request){ $post = UtilService::getMore([ ['id','0'], ['title','','empty','请填写名称'], ['seq','0'], ['content',''], ['img',''], ['status','0'] ],$request); $id = $post["id"]; unset($post["id"]); $r=0; if(empty($id) || $id=="0"){ $r = (new ServiceTypeModel)->insert($post); }else{ $r = (new ServiceTypeModel)->where("id",$id)->update($post); } if($r){ return app('json')->success("数据保存成功"); }else{ return app('json')->fail("数据保存失败"); } } /** * 分类删除 * @param Request $request */ public function serviceTypeDel(Request $request) { [$id] = UtilService::getMore([ ['id',0,'empty','参数错误'] ],$request,true); return app('json')->success("暂不支持删除"); $bool = (new ServiceTypeModel)->where("id",$id)->delete(); return app('json')->success("删除成功"); } /** * 服务时长类型 * @param Request $request */ public function serviceTimeTypeList(Request $request){ $post = UtilService::getMore([ ['page',1], ['pageSize', 50], ['title',''], ['status',''], ],$request); $data = (new ServiceTimeTypeModel)->getList($post); return app('json')->success([ 'list' => $data["list"], 'pageCount' => $data["totalCount"], 'pageSize' => $data["pageSize"], 'page' => $data["page"], ]); } /** * 添加服务时长类型 */ public function serviceTimeTypeAdd(Request $request){ $post = UtilService::getMore([ ['id','0'], ['seq','0'], ['code','','empty','请填写code'], ['title','','empty','请填写名称'], ['content',''], ['status','0'], ['img',''] ],$request); $id = $post["id"]; unset($post["id"]); $r=0; if(empty($id) || $id=="0"){ $r = (new ServiceTimeTypeModel)->insert($post); }else{ $r = (new ServiceTimeTypeModel)->where("id",$id)->update($post); } if($r){ return app('json')->success("数据保存成功"); }else{ return app('json')->fail("数据保存失败"); } } /** * 分类删除 * @param Request $request */ public function serviceTimeTypeDel(Request $request) { [$id] = UtilService::getMore([ ['id',0,'empty','参数错误'] ],$request,true); return app('json')->success("暂不支持删除"); $bool = (new ServiceTimeTypeModel)->where("id",$id)->delete(); return app('json')->success("删除成功"); } }