Merge branch 'master' of http://119.23.72.7/q578953158/yunxin into hcy-5.28-对接财务对账

parents 5328b7f2 1ad2ecdc
......@@ -202,5 +202,10 @@ class ApiController extends Controller
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
$data['title']='自营价格明细';
$data['time']=time();
$res = (new ServerMicModel())->synchronization(['goods_id'=>[$goods_id]],2);
$data['ladder_price'] = $res['code'] > 0 ? [] : @$res['data'][$goods_id]['ladder_price'];
return view('pure',$data);
$ladder_price = @$res['data'][$goods_id]['ladder_price'];
$data['ladder_price'] = $res['code'] > 0 ? [] : ($ladder_price ? $ladder_price : []);
$data['ti'] = 5-count($data['ladder_price']);
return view('pure',$data);
}
......
......@@ -905,6 +905,18 @@ function arrayToCommaStr($data,$col,$type=''){
}
}
/*
* 判断是否大于0的正整数
*/
function checkIn($str){
if(preg_match("/^[1-9]{1}\d{0,9}$/",$str))
{
return true;
}else{
return false;
}
}
/*
* /^[1-9]{1}\d{0,9}$/
* 判断是否大于0的数字,包括小数
*/
function checkFloat($str){
......@@ -916,6 +928,16 @@ function checkFloat($str){
}
}
/*
* 判断大于0 多少位小数
*/
function checkFloatInt($number,$w = 2){
if (preg_match('/^[0-9]+(.[0-9]{1,'.$w.'})?$/', $number)) {
return true;
}else{
return false;
}
}
/*
* api专用分页类
*@param str $sql sql
*@param int $pageIndex 第几页
......@@ -1038,6 +1060,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);
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
*/
......
......@@ -23,11 +23,11 @@ class ServerFoostoneModel
$datas = ExcessEncryption($data,$this->appid,$this->key);
$urls = $this->_url.$url;
$res = (curl($urls,$datas));
if (self::IS_DEBUG){
print_r($urls);
print_r("<br/>");
print_r($data);
print_r($datas);
print_r("<br/>");
print_r($res);
die();
......@@ -88,6 +88,63 @@ class ServerFoostoneModel
$data['up_id'] = $up_id_arr;
return $this->push('/yunxin/api/pool/select/uploadlog',$data,$type);
}
/*
*修改联营sku
*$data = [
'goods_id'=>1, //商品id
'stock' => 200, //商品库存
'ladder_price' => [{"purchases":1,"price_cn":0,"price_us":1203.05}], //梯度价格
]
*/
public function comSkuEdit($data,$type =1){
if (empty(@$data['goods_id'])) return [1001,'商品id必填'];
$tdata['goods_id'] = $data['goods_id'];
$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)) {
$ladder_price = [];
$price_cn = $data['price_cn']; //国内含税价
$price_us = $data['price_us']; //香港含税价
$purchases = $data['purchases'];//梯度价
//检测梯度
foreach ($purchases as $k=>$v ){
if ($v === "") continue;
if ( !checkIn($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 ($b == '0') return [1007,"国内含税价填写不对:".$b];
if ($b === "") continue;
if (!checkFloatInt($b,5)) return [1007,"国内含税价填写不对:".$b];
}
foreach ($price_us as $c=>$d){
if ($d == '0') return [1008,"香港含税价填写不对:".$d];
if ($d === "") continue;
if (!checkFloatInt($d,5)) return [1008,"香港含税价填写不对:".$d];
}
$tdata['ladder_price'] = $ladder_price;
}
$res = $this->push('/yunxin/api/pool/sku/edit',$tdata,$type);
return [$res['code'],$res['errmsg']];
}
}
\ No newline at end of file
......@@ -63,7 +63,7 @@
{field:'goods_status_name', title: '状态',align:'center'},
{field:'expire', title: '是否过期',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'
,page:{
......@@ -155,6 +155,49 @@
})
}();
/*
修改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 () {
$("#box1").hide()
$('#form1')[0].reset()
},
btn1: function(index) {
layer.close(index);
},
btn2: function() {
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(index);
}
});
}
/*
sku价格明细弹框
*/
function purePrice(goods_id) {
......
......@@ -3,14 +3,27 @@
var table_data = [];
window.app = {
init: function () {
app.tableList();
//刷新列表
$("#search").click(function () {
app.tableList()
$("#edit").click(function () {
$("#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 () {
app.init();
......
......@@ -28,7 +28,7 @@
$(".finish_time").html(other.finish_time);
$(".currency").html(other.currency);
$(".day_num").html(other.day_num);
if(other.status == "已对账"){
if(other.status == "已对账" || other.status == "付款中"){
$("#changeChecking").remove()
}
var html;
......
/*
存放公共函数地方
*/
var num_int = /^[1-9]\d*$/; //大于0正则
/*
ajax 请求
@param str url 请求地址
......
......@@ -63,6 +63,7 @@
<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="pureEditStock('@{{ d.goods_id }}','@{{ d.stock }}')">&nbsp;修改库存&nbsp;</button>
</script>
</div>
......@@ -75,4 +76,18 @@
.lx-content .lx-content-wrap .lx-content-r .con-section .table-list table tr th{
border-top: none !important;
}
</style>
\ No newline at end of file
</style>
<!--调整库存弹框-->
<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 @@
</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>
<tr>
<th style="width: 30%">阶梯数量 </th>
......@@ -17,11 +17,51 @@
@foreach($ladder_price as $k=>$v)
<tr >
<td>{{@$v['purchases'].'+'}}</td>
<td>{{ @$v['price_cn'] ? '¥'.@$v['price_cn'] : "" }}</td>
<td>{{ @$v['price_us'] ? '$'.@$v['price_us'] : "" }}</td>
<td>{{ @$v['price_cn'] ? '¥'.@$v['price_cn'] : '¥0' }}</td>
<td>{{ @$v['price_us'] ? '$'.@$v['price_us'] : '$0' }}</td>
</tr>
@endforeach
@endif
</tbody>
</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