## 退货管理
>[info]功能:
1,显示数据:查询 `wp_order` 订单表 显示已完成的订单信息 订单由前台用户购买商品生成
>[info]2,关联`wp_order_value` 订单详情表 查看此订单下详细的购买商品情况 ;
选择要退货的商品 数量 然后点击确定 把要退货的商品 插入到`wp_order_return` 表中
changeActual: function(v) {
this.actual += v;
},
inquire: function(actual) {
var this_ = this;
if(!actual){
Public.tips.error( "请输入正确的查询信息");
}
$.get(base_url+"/home/user_search/order_list",{wq:actual},function(rs){
if(!rs.data){
Public.tips.error( "暂无此订单信息");
}else{
this_.reproducts = rs.data;
}
var Swiperorder = new Swiper('.swiper-order-back', {
scrollbar: '.swiper-scrollbar-order-return',
direction: 'vertical',
slidesPerView: 'auto',
slidesPerView:6,
mousewheelControl: true,
freeMode: true,
initialSlide :0,
observer:true,//修改swiper自己或子元素时,自动初始化
observeParents:true//修改swiper的父元素时,自动初始化swiper
});
},'json')
},
del: function(){
this.actual = '';
},
backspace: function() {
if(this.actual) {
this.actual = this.actual.replace(/.$/,'');
}
},
order:function(obj){
var this_ = this;
$('.list').css('display','none');
$('.info').css('display','block');
this_.return_order_id = [];
this_.return_order_num = [];
this_.return_goods_price = [];
$.get(base_url+"/home/user_search/info_good",{order_id:obj.order_id},function(rs){
this_.infogood = rs.data['0'];
this_.number = rs.data['order_id'];
var swiperss= new Swiper('.swiper-return', {
scrollbar: '.swiper-scrollbar-return',
direction: 'vertical',
slidesPerView: 'auto',
slidesPerView:5,
mousewheelControl: true,
freeMode: true,
initialSlide :0,
observer:true,//修改swiper自己或子元素时,自动初始化
observeParents:true//修改swiper的父元素时,自动初始化swiper
});
var url = " " ;
switch(rs.data['payid'])
{
case 'cash':
url = '现金';
break;
case 'xpsm':
url = '小票扫码';
break;
case 'wepay':
url = '微信';
break;
case 'unionpay':
url = '银行卡'
break;
case 'alipay':
url = '支付宝';
break;
case 'member':
url = '余额';
break;
}
this_.payid = url;
this_.return_num = rs.data['return_num'];
this_.return_price = rs.data['return_price'];
for(var i in rs.data['0']){
this_.return_order_id.push(rs.data['0'][i]['goods_id']);
this_.return_order_num.push(rs.data['0'][i]['num']);
this_.return_goods_price.push(rs.data['0'][i]['num'] * rs.data['0'][i]['price']);
}
},'json')
},
rnnedo:function(){
$('.list').css('display','block');
$('.info').css('display','none');
},
tanchu:function(obj){
if(!this.return_order_id.length){
Public.tips.error( "请选择要退货的商品");
}else{
$('.tanchu').css('display','block')
}
},
quxiao:function(){
$('.tanchu').css('display','none')
},
add:function(obj){
if(obj.num<obj.tmp_num){
obj.num++;
if(obj.state){
this.return_num ++ ;
this.return_price = parseFloat(this.return_price) + parseFloat(obj.price);
var u = this.return_order_id.indexOf(obj.goods_id);
this.return_order_num[u] = obj.num;
this.return_goods_price[u] = obj.num*obj.price;
}
}else{
obj.num = obj.tmp_num;
Public.tips.error( "退货数量超过限度");
}
},
reduce:function(obj){
/*商品数量减少 价钱随之改变 */
if(obj.num > 1){
obj.num--;
if(obj.state){
this.return_num -- ;
this.return_price = parseFloat(this.return_price) - parseFloat(obj.price);
var u = this.return_order_id.indexOf(obj.goods_id);
this.return_order_num[u] = obj.num;
this.return_goods_price[u] = obj.num*obj.price;
}
}else if(obj.num == 0){
obj.num = 0;
Public.tips.error( "此商品无退货数量可选择");
}else{
obj.num = 1;
Public.tips.error( "退货数量不能为空");
}
},
checkbox:function(obj){
if(obj.state){
this.return_num += parseInt(obj.num) ;
this.return_price += parseFloat(obj.price*obj.num);
this.return_order_id.push(obj.goods_id);
this.return_order_num.push(obj.num);
this.return_goods_price.push(obj.num*obj.price);
}else{
this.return_num -= parseInt(obj.num) ;
this.return_price -= parseFloat(obj.price*obj.num);
var u = this.return_order_id.indexOf(obj.goods_id);
this.return_order_id.splice(u, 1);
this.return_order_num.splice(u, 1);
this.return_goods_price.splice(u, 1);
}
},
btn:function(){
var that = this;
$('.tanchu').css('display','none');
$.ajax({
type: "GET",
url: base_url+"/home/welcome/order_return",
data: {goods_id:that.return_order_id, goods_num:that.return_order_num, order_id:that.number, price:that.return_price, goods_price:that.return_goods_price},
dataType: "json",
success: function(data) {
if(data.status == true) {
Public.tips.success( data.msg);
$('.list').css('display','block');
$('.info').css('display','none');
}else{
Public.tips.error(data.msg);
}
}
});
},
back: function(){
$.ajax({
type: "GET",
url: base_url+"/home/welcome/user_index",
data: {},
dataType: "json",
success: function(data) {
if(data.status) {
$(" body").html(data.html);
}else if(data.msg){
Public.tips.error(data.msg);
}
}
});
}