Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
黄成意
/
yunxin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
67d36d77
authored
May 30, 2019
by
PRY5YKGJ82EZEPX\Administrator
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
更新修改联营sku价格
parent
a8ae9cc3
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
192 additions
and
18 deletions
app/Http/Controllers/ApiController.php
app/Http/Controllers/PureController.php
app/Http/function.php
app/Model/Server/ServerFoostoneModel.php
public/pc/js/controller/GoodsComList.js
public/pc/js/controller/PureComPrice.js
public/pc/js/public.js
resources/views/pc/GoodsComList.blade.php
resources/views/pure/PureComPrice.blade.php
app/Http/Controllers/ApiController.php
View file @
67d36d77
...
...
@@ -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
);
}
}
app/Http/Controllers/PureController.php
View file @
67d36d77
...
...
@@ -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
);
}
...
...
app/Http/function.php
View file @
67d36d77
...
...
@@ -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专用分页类
*@param str $sql sql
*@param int $pageIndex 第几页
...
...
@@ -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
);
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
*/
...
...
app/Model/Server/ServerFoostoneModel.php
View file @
67d36d77
...
...
@@ -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
();
...
...
@@ -97,7 +97,41 @@ class ServerFoostoneModel
]
*/
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
);
}
...
...
public/pc/js/controller/GoodsComList.js
View file @
67d36d77
...
...
@@ -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
:
1
0
0
,
align
:
'center'
,
fixed
:
'right'
}
{
field
:
'cahe'
,
title
:
'操作'
,
templet
:
'#cahe'
,
width
:
1
8
0
,
align
:
'center'
,
fixed
:
'right'
}
]]
,
id
:
'Abnormal'
,
page
:{
...
...
@@ -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价格明细弹框
*/
function
purePrice
(
goods_id
)
{
...
...
public/pc/js/controller/PureComPrice.js
View file @
67d36d77
...
...
@@ -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
();
...
...
public/pc/js/public.js
View file @
67d36d77
/*
存放公共函数地方
*/
var
num_int
=
/^
[
1-9
]\d
*$/
;
//大于0正则
/*
ajax 请求
@param str url 请求地址
...
...
resources/views/pc/GoodsComList.blade.php
View file @
67d36d77
...
...
@@ -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
resources/views/pure/PureComPrice.blade.php
View file @
67d36d77
...
...
@@ -4,7 +4,7 @@
</style>
<table
class=
"layui-table"
id=
"tb"
style=
"width: 95%;"
lay-filter=
"parse-table-demo1"
>
<table
class=
"layui-table"
id=
"tb
1
"
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"
>
编辑
</button>
<button
class=
"btn btn-xs btn-outline btn-success pointer bt1d"
style=
"display: none"
id=
"save"
>
保存
</button>
<button
class=
"btn btn-xs btn-outline btn-success pointer bt2d"
style=
"display: none"
id=
"cancel"
>
取消
</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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment