|
|
@@ -71,7 +71,7 @@ class ShowTemplate extends BaseController{
|
|
|
*/
|
|
|
public function add(Request $request){
|
|
|
$post = UtilService::getMore([
|
|
|
- ['id','0'],
|
|
|
+ ['id',''],
|
|
|
['title','','empty','请填写模板标题'],
|
|
|
['price','0','is_numeric','请输入正确的模板售价'],
|
|
|
['old_price','0','is_numeric','请输入正确的模板原价'],
|
|
|
@@ -94,10 +94,18 @@ class ShowTemplate extends BaseController{
|
|
|
$save["unreal_sales"] = (int)$post["unreal_sales"];
|
|
|
$save["admin_time"] = time();
|
|
|
$save["admin_id"] = $request->adminInfo['id'];
|
|
|
- $id = $post["id"];
|
|
|
+ $id = empty($post["id"])?0:(int)$post["id"];
|
|
|
+ $codeWhere[]=["code","=",$save["code"]];
|
|
|
+ if($id>0){
|
|
|
+ $save["time"] = time();
|
|
|
+ $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($post);
|
|
|
}else{
|
|
|
$r = (new ShowTemplateModel)->where("id",$id)->update($save);
|