更新修改联营sku

parent 67d36d77
...@@ -905,6 +905,19 @@ function arrayToCommaStr($data,$col,$type=''){ ...@@ -905,6 +905,19 @@ function arrayToCommaStr($data,$col,$type=''){
} }
} }
/* /*
* /^[1-9]{1}\d{0,9}$/
* 判断是否大于0的数字,包括小数
*/
function checkIn($str){
if(preg_match("/^[1-9]{1}\d{0,9}$/",$str)) //大于0的数字,包括小数
{
return true;
}else{
return false;
}
}
/*
* /^[1-9]{1}\d{0,9}$/
* 判断是否大于0的数字,包括小数 * 判断是否大于0的数字,包括小数
*/ */
function checkFloat($str){ function checkFloat($str){
...@@ -1050,7 +1063,7 @@ function ExportLayui2($errcode=[]){ ...@@ -1050,7 +1063,7 @@ function ExportLayui2($errcode=[]){
} }
function Export2($errcode=0,$errmsg='成功',$data='',$other=''){ function Export2($errcode=0,$errmsg='成功',$data='',$other=''){
if(is_array($errcode)){ if(is_array($errcode)){
echo json_encode(['code'=>$errcode[0],'errmsg'=>$errcode[1],'data'=>!empty(@$errcode[2])?@$errcode[2]:'','other'=>@$errcode[3]], JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES); echo json_encode(['code'=>@$errcode[0],'errmsg'=>@$errcode[1],'data'=>!empty(@$errcode[2])?@$errcode[2]:'','other'=>@$errcode[3]], JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
}else{ }else{
echo json_encode(['code'=>$errcode,'errmsg'=>$errmsg,'data'=>$data,'other'=>$other], JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES); echo json_encode(['code'=>$errcode,'errmsg'=>$errmsg,'data'=>$data,'other'=>$other], JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
} }
......
...@@ -99,7 +99,14 @@ class ServerFoostoneModel ...@@ -99,7 +99,14 @@ class ServerFoostoneModel
public function comSkuEdit($data,$type =1){ public function comSkuEdit($data,$type =1){
if (empty(@$data['goods_id'])) return [1001,'商品id必填']; if (empty(@$data['goods_id'])) return [1001,'商品id必填'];
$tdata['goods_id'] = $data['goods_id']; $tdata['goods_id'] = $data['goods_id'];
if (!empty(@$data['stock'])) $tdata['stock'] = $data['stock']; $stock = @$data['stock'];
if (array_key_exists('stock',$data)){
if(@$stock != '0' && !checkIn($stock)) //大于0的数字,包括小数
{
return [1002,'库存数量填写不正确:'.$stock];
}
$tdata['stock'] = $stock;
}
if (array_key_exists('purchases',$data)) { if (array_key_exists('purchases',$data)) {
$ladder_price = []; $ladder_price = [];
$price_cn = $data['price_cn']; //国内含税价 $price_cn = $data['price_cn']; //国内含税价
...@@ -111,8 +118,8 @@ class ServerFoostoneModel ...@@ -111,8 +118,8 @@ class ServerFoostoneModel
if ( !(int)$v) return [1002,'阶梯数量填写不对:'.$v]; if ( !(int)$v) return [1002,'阶梯数量填写不对:'.$v];
if ($k>0 && $purchases[$k] <= $purchases[$k-1]) return [1003,'第'.($k+1).'行阶梯数量必须比上一行阶梯数量大']; if ($k>0 && $purchases[$k] <= $purchases[$k-1]) return [1003,'第'.($k+1).'行阶梯数量必须比上一行阶梯数量大'];
if (empty($price_cn[$k]) && empty($price_us[$k]) ) return [1004,'阶梯数量对应国内含税价或香港交货价必填写一个'.$price_cn[$k]]; if (empty($price_cn[$k]) && empty($price_us[$k]) ) return [1004,'阶梯数量对应国内含税价或香港交货价必填写一个'.$price_cn[$k]];
if ($k>0 && $price_cn[$k] != "" && $price_cn[$k] <= $price_cn[$k-1]) return [1005,'第'.($k+1).'行国内含税价必须比上一行国内含税价大']; if ($k>0 && $price_cn[$k] != "" && $price_cn[$k] >= $price_cn[$k-1]) return [1005,'第'.($k+1).'行国内含税价必须比上一行国内含税价小'];
if ($k>0 && $price_us[$k] != "" && $price_us[$k] <= $price_us[$k-1]) return [1006,'第'.($k+1).'行香港含税价必须比上一行香港含税价大']; if ($k>0 && $price_us[$k] != "" && $price_us[$k] >= $price_us[$k-1]) return [1006,'第'.($k+1).'行香港含税价必须比上一行香港含税价小'];
array_push($ladder_price,[ array_push($ladder_price,[
"purchases"=>$v, "purchases"=>$v,
"price_cn"=>$price_cn[$k], "price_cn"=>$price_cn[$k],
...@@ -120,18 +127,19 @@ class ServerFoostoneModel ...@@ -120,18 +127,19 @@ class ServerFoostoneModel
]); ]);
} }
foreach ($price_cn as $a=>$b){ foreach ($price_cn as $a=>$b){
if (empty($v)) continue; if (empty($b)) continue;
if (!checkFloatInt($b,5,2)) return [1007,"国内含税价填写不对:".$b]; if (!checkFloatInt($b,5,2)) return [1007,"国内含税价填写不对:".$b];
} }
foreach ($purchases as $c=>$d){ foreach ($purchases as $c=>$d){
if (empty($v)) continue; if (empty($d)) continue;
if (!checkFloatInt($d,5,2)) return [1007,"国内含税价填写不对:".$d]; if (!checkFloatInt($d,5,2)) return [1007,"国内含税价填写不对:".$d];
} }
$tdata['ladder_price'] = $ladder_price; $tdata['ladder_price'] = $ladder_price;
} }
return $this->push('/yunxin/api/pool/sku/edit',$tdata,$type); $res = $this->push('/yunxin/api/pool/sku/edit',$tdata,$type);
return [$res['code'],$res['errmsg']];
} }
......
...@@ -178,11 +178,6 @@ function pureEditStock(goods_id,stock) { ...@@ -178,11 +178,6 @@ function pureEditStock(goods_id,stock) {
layer.close(index); layer.close(index);
}, },
btn2: function() { btn2: function() {
var stock = $("input[name='stock']").val()
if(!num_int.test(stock)){
alert_err("库存必须是大于0的正整数")
return false;
}
alert_confirm("你确定要修改库存吗?",function () { alert_confirm("你确定要修改库存吗?",function () {
var res = ajax_push2("/api/ApiComSkuEdit",{ var res = ajax_push2("/api/ApiComSkuEdit",{
"goods_id":$("input[name='goods_id2']").val(), "goods_id":$("input[name='goods_id2']").val(),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment