更新修改联营sku价格

parent a8ae9cc3
...@@ -202,5 +202,10 @@ class ApiController extends Controller ...@@ -202,5 +202,10 @@ class ApiController extends Controller
Export(2,"没完成"); Export(2,"没完成");
} }
} }
//修改sku价格或库存
private function ApiComSkuEdit($request,$id){
$res = (new ServerFoostoneModel($request->appid,$request->key))->comSkuEdit($request->input(),2);
Export2($res);
}
} }
...@@ -40,8 +40,10 @@ class PureController extends Controller ...@@ -40,8 +40,10 @@ class PureController extends Controller
$data['title']='自营价格明细'; $data['title']='自营价格明细';
$data['time']=time(); $data['time']=time();
$res = (new ServerMicModel())->synchronization(['goods_id'=>[$goods_id]],2); $res = (new ServerMicModel())->synchronization(['goods_id'=>[$goods_id]],2);
$data['ladder_price'] = $res['code'] > 0 ? [] : @$res['data'][$goods_id]['ladder_price']; $ladder_price = @$res['data'][$goods_id]['ladder_price'];
return view('pure',$data); $data['ladder_price'] = $res['code'] > 0 ? [] : ($ladder_price ? $ladder_price : []);
$data['ti'] = 5-count($data['ladder_price']);
return view('pure',$data);
} }
......
...@@ -916,6 +916,16 @@ function checkFloat($str){ ...@@ -916,6 +916,16 @@ function checkFloat($str){
} }
} }
/* /*
* 判断大于0 多少位小数
*/
function checkFloatInt($number,$w = 2,$type = 1){
if (preg_match('/^[0-9]+(.[0-9]{1,'.$w.'})?$/', $number)) {
return true;
}else{
return false;
}
}
/*
* api专用分页类 * api专用分页类
*@param str $sql sql *@param str $sql sql
*@param int $pageIndex 第几页 *@param int $pageIndex 第几页
...@@ -1038,6 +1048,14 @@ function ExportLayui2($errcode=[]){ ...@@ -1038,6 +1048,14 @@ function ExportLayui2($errcode=[]){
echo json_encode(['code'=>$errcode['code'],'msg'=>$errcode['errmsg'],'data'=>@$errcode['data'],'count'=>@$errcode['total'],'other'=>!empty(@$errcode[4]) ? @$errcode[4] : ''], JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES); echo json_encode(['code'=>$errcode['code'],'msg'=>$errcode['errmsg'],'data'=>@$errcode['data'],'count'=>@$errcode['total'],'other'=>!empty(@$errcode[4]) ? @$errcode[4] : ''], JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
exit(); exit();
} }
function Export2($errcode=0,$errmsg='成功',$data='',$other=''){
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);
}else{
echo json_encode(['code'=>$errcode,'errmsg'=>$errmsg,'data'=>$data,'other'=>$other], JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
}
exit();
}
/* /*
* 数组转json * 数组转json
*/ */
......
...@@ -23,11 +23,11 @@ class ServerFoostoneModel ...@@ -23,11 +23,11 @@ class ServerFoostoneModel
$datas = ExcessEncryption($data,$this->appid,$this->key); $datas = ExcessEncryption($data,$this->appid,$this->key);
$urls = $this->_url.$url; $urls = $this->_url.$url;
$res = (curl($urls,$datas)); $res = (curl($urls,$datas));
if (self::IS_DEBUG){ if (self::IS_DEBUG){
print_r($urls); print_r($urls);
print_r("<br/>"); print_r("<br/>");
print_r($data); print_r($data);
print_r($datas);
print_r("<br/>"); print_r("<br/>");
print_r($res); print_r($res);
die(); die();
...@@ -97,7 +97,41 @@ class ServerFoostoneModel ...@@ -97,7 +97,41 @@ class ServerFoostoneModel
] ]
*/ */
public function comSkuEdit($data,$type =1){ public function comSkuEdit($data,$type =1){
return $this->push('/yunxin/api/pool/sku/edit',$data,$type); if (empty(@$data['goods_id'])) return [1001,'商品id必填'];
$tdata['goods_id'] = $data['goods_id'];
if (!empty(@$data['stock'])) $tdata['stock'] = $data['stock'];
if (array_key_exists('purchases',$data)) {
$ladder_price = [];
$price_cn = $data['price_cn']; //国内含税价
$price_us = $data['price_us']; //香港含税价
$purchases = $data['purchases'];//梯度价
//检测梯度
foreach ($purchases as $k=>$v ){
if (empty($v)) continue;
if ( !(int)$v) return [1002,'阶梯数量填写不对:'.$v];
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 ($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).'行香港含税价必须比上一行香港含税价大'];
array_push($ladder_price,[
"purchases"=>$v,
"price_cn"=>$price_cn[$k],
"price_us"=>$price_us[$k]
]);
}
foreach ($price_cn as $a=>$b){
if (empty($v)) continue;
if (!checkFloatInt($b,5,2)) return [1007,"国内含税价填写不对:".$b];
}
foreach ($purchases as $c=>$d){
if (empty($v)) continue;
if (!checkFloatInt($d,5,2)) return [1007,"国内含税价填写不对:".$d];
}
$tdata['ladder_price'] = $ladder_price;
}
return $this->push('/yunxin/api/pool/sku/edit',$tdata,$type);
} }
......
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
{field:'goods_status_name', title: '状态',align:'center'}, {field:'goods_status_name', title: '状态',align:'center'},
{field:'expire', title: '是否过期',align:'center'}, {field:'expire', title: '是否过期',align:'center'},
{field:'update_time', title: '更新时间',width:180,align:'center'}, {field:'update_time', title: '更新时间',width:180,align:'center'},
{field:'cahe', title: '操作',templet:'#cahe',width:100,align:'center', fixed: 'right'} {field:'cahe', title: '操作',templet:'#cahe',width:180,align:'center', fixed: 'right'}
]] ]]
,id:'Abnormal' ,id:'Abnormal'
,page:{ ,page:{
...@@ -155,6 +155,52 @@ ...@@ -155,6 +155,52 @@
}) })
}(); }();
/* /*
修改sku库存
*/
function pureEditStock(goods_id,stock) {
$("input[name='goods_id2']").val(goods_id)
$("input[name='stock']").val(stock)
layer.open({
type:1,
title: '修改库存:'+goods_id,
shadeClose: true,
shade: 0.8,
area: ['380px', '280px'],
content: $("#box1"),
btn: ['取消', '确定'],
success: function(layero){ //按钮居中
layero.find('.layui-layer-btn').css('text-align', 'center')
},
end:function () {
$('#form1')[0].reset()
},
btn1: function(index) {
layer.close(index);
},
btn2: function() {
var stock = $("input[name='stock']").val()
if(!num_int.test(stock)){
alert_err("库存必须是大于0的正整数")
return false;
}
alert_confirm("你确定要修改库存吗?",function () {
var res = ajax_push2("/api/ApiComSkuEdit",{
"goods_id":$("input[name='goods_id2']").val(),
"stock":$("input[name='stock']").val(),
})
res.code > 0 ? alert_err(res.errmsg) : alert_succ(res.errmsg,function () {
window.location.reload()
})
})
},
yes: function(index, layero){
//事件
//layer.close(indxex);
}
});
}
/*
sku价格明细弹框 sku价格明细弹框
*/ */
function purePrice(goods_id) { function purePrice(goods_id) {
......
...@@ -3,14 +3,27 @@ ...@@ -3,14 +3,27 @@
var table_data = []; var table_data = [];
window.app = { window.app = {
init: function () { init: function () {
app.tableList();
//刷新列表 //刷新列表
$("#search").click(function () { $("#edit").click(function () {
app.tableList() $("#tb1").hide()
$("#tb2").show()
$("#save").show()
$("#cancel").show()
$("#edit").hide()
})
//保存
$("#save").click(function () {
alert_confirm("确定修改此sku价格?",function () {
var res = ajax_push("/api/ApiComSkuEdit",$("#form1").serialize())
res.code >0 ? alert_err(res.errmsg) : alert_succ(res.errmsg,function () {
window.parent.location.reload()
})
})
})
//取消
$("#cancel").click(function () {
window.parent.location.reload()
}) })
},
tableList:function () {
return
}, },
}, $(function () { }, $(function () {
app.init(); app.init();
......
/* /*
存放公共函数地方 存放公共函数地方
*/ */
var num_int = /^[1-9]\d*$/; //大于0正则
/* /*
ajax 请求 ajax 请求
@param str url 请求地址 @param str url 请求地址
......
...@@ -63,6 +63,7 @@ ...@@ -63,6 +63,7 @@
<script type="text/html" id="cahe"> <script type="text/html" id="cahe">
<button class="btn btn-xs btn-outline btn-success pointer" style="color: #1080d0;border: 1px solid #1080d0;" onclick="purePrice('@{{ d.goods_id }}')">&nbsp;价格明细&nbsp;</button> <button class="btn btn-xs btn-outline btn-success pointer" style="color: #1080d0;border: 1px solid #1080d0;" onclick="purePrice('@{{ d.goods_id }}')">&nbsp;价格明细&nbsp;</button>
<button class="btn btn-xs btn-outline btn-success pointer" style="color: #1080d0;border: 1px solid #1080d0;" onclick="pureEditStock('@{{ d.goods_id }}','@{{ d.stock }}')">&nbsp;修改库存&nbsp;</button>
</script> </script>
</div> </div>
...@@ -75,4 +76,18 @@ ...@@ -75,4 +76,18 @@
.lx-content .lx-content-wrap .lx-content-r .con-section .table-list table tr th{ .lx-content .lx-content-wrap .lx-content-r .con-section .table-list table tr th{
border-top: none !important; border-top: none !important;
} }
</style> </style>
\ No newline at end of file
<!--调整库存弹框-->
<div id="box1" style="display: none;">
<form id="form1">
<input type="hidden" name="goods_id2" >
<div class="layui-inline" style="margin-top: 50px;">
<label class="layui-form-label">库存数量:</label>
<div class="layui-input-inline">
<input type="text" name="stock" placeholder="" autocomplete="off" class="layui-input">
</div>
</div>
</form>
</div>
\ No newline at end of file
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
</style> </style>
<table class="layui-table" id="tb" style="width: 95%;" lay-filter="parse-table-demo1"> <table class="layui-table" id="tb1" style="width: 95%;" lay-filter="parse-table-demo1">
<thead> <thead>
<tr> <tr>
<th style="width: 30%">阶梯数量 </th> <th style="width: 30%">阶梯数量 </th>
...@@ -17,11 +17,51 @@ ...@@ -17,11 +17,51 @@
@foreach($ladder_price as $k=>$v) @foreach($ladder_price as $k=>$v)
<tr > <tr >
<td>{{@$v['purchases'].'+'}}</td> <td>{{@$v['purchases'].'+'}}</td>
<td>{{ @$v['price_cn'] ? '¥'.@$v['price_cn'] : "" }}</td> <td>{{ @$v['price_cn'] ? '¥'.@$v['price_cn'] : '¥0' }}</td>
<td>{{ @$v['price_us'] ? '$'.@$v['price_us'] : "" }}</td> <td>{{ @$v['price_us'] ? '$'.@$v['price_us'] : '$0' }}</td>
</tr> </tr>
@endforeach @endforeach
@endif @endif
</tbody> </tbody>
</table> </table>
</div>
\ No newline at end of file <table class="layui-table" id="tb2" style="width: 95%;display: none" lay-filter="parse-table-demo1">
<thead>
<tr>
<th style="width: 30%">阶梯数量 </th>
<th style="width: 30%">国内含税价(¥)</th>
<th style="width: 30%">香港交货价($)</th>
</tr>
</thead>
<form id="form1">
<input type="hidden" value="<?= @$_GET['goods_id'] ?>" name="goods_id">
<tbody>
@foreach($ladder_price as $k=>$v)
<tr >
<td><input type="text" class="t1 " name="purchases[]" value="{{ @$v['purchases'] }}"></td>
<td><input type="text" class="t1 " name="price_cn[]" value="{{ @$v['price_cn'] ? @$v['price_cn'] : 0 }}"></td>
<td><input type="text" class="t1 " name="price_us[]" value="{{ @$v['price_us'] ? @$v['price_us'] : 0 }}"></td>
</tr>
@endforeach
<?php for($j=1;$j<=$ti;$j++) { ?>
<tr >
<td><input class="t1 " type="text" name="purchases[]"></td>
<td><input class="t1" type="text" name="price_cn[]" ></td>
<td><input class="t1" type="text" name="price_us[]" ></td>
</tr>
<?php } ?>
</tbody>
</form>
</table>
<button class="btn btn-xs btn-outline btn-success pointer bt1d" id="edit">&nbsp;编辑&nbsp;</button>
<button class="btn btn-xs btn-outline btn-success pointer bt1d" style="display: none" id="save">&nbsp;保存&nbsp;</button>
<button class="btn btn-xs btn-outline btn-success pointer bt2d" style="display: none" id="cancel">&nbsp;取消&nbsp;</button>
</div>
<style type="text/css">
.t1{ border: 1px solid #ccc !important;}
.bt1d{color: #1080d0;border: 1px solid #1080d0; margin: 10px 0px 0px 230px;cursor: pointer}
.bt2d{color: #1080d0;border: 1px solid #1080d0; margin: 10px 0px 0px 10px;cursor: pointer}
</style>
\ No newline at end of file
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