Commit 522c4640 authored by 张永's avatar 张永

需求 #14244

parent 9ae19d73
...@@ -27,6 +27,7 @@ import com.egolm.common.StringUtil; ...@@ -27,6 +27,7 @@ import com.egolm.common.StringUtil;
import com.egolm.common.bean.Rjx; import com.egolm.common.bean.Rjx;
import com.egolm.common.jdbc.Page; import com.egolm.common.jdbc.Page;
import com.egolm.shop.api.service.OrderService; import com.egolm.shop.api.service.OrderService;
import com.egolm.shop.bean.RespObject;
import com.egolm.shop.common.utils.XmlUtil; import com.egolm.shop.common.utils.XmlUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
...@@ -106,6 +107,28 @@ public class OrderController { ...@@ -106,6 +107,28 @@ public class OrderController {
return orderService.queryOrderList(orgNo, shopNo, status, types.toArray(new String[types.size()]), langID, page); return orderService.queryOrderList(orgNo, shopNo, status, types.toArray(new String[types.size()]), langID, page);
} }
@ApiOperation("B2B售后退单列表")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name="orgNo", dataType = "String", required = true),
@ApiImplicitParam(paramType = "query", name="shopNo", dataType = "String", required = true, value = "店铺编号"),
@ApiImplicitParam(paramType = "query", name="refundStatus", dataType = "int", required = true, value = "退单状态,1=申请售后、2=平台确认、3=退货/退款、4=售后完成"),
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端标识", defaultValue = "wechat"),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = true, value = "语言", defaultValue = "936"),
@ApiImplicitParam(paramType = "query", name = "index", dataType = "String", required = true, value = "第几页", defaultValue = "1"),
@ApiImplicitParam(paramType = "query", name = "limit", dataType = "String", required = true, value = "每页数量", defaultValue = "20"),
})
@RequestMapping(value = "/getRefundOrderList",method=RequestMethod.GET)
public RespObject getRefundOrderList(String orgNo, String shopNo, Integer refundStatus, String langID, Integer index, Integer limit) {
Page page = new Page();
page.setIndex(Long.valueOf(index));
page.setLimit(Long.valueOf(limit));
page.setLimitKey("OrderDate desc");
return orderService.queryRefundOrderList(orgNo, shopNo, refundStatus, langID, page);
}
@ApiOperation("获取主订单详情") @ApiOperation("获取主订单详情")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name="salesOrderId", dataType = "String", required = true), @ApiImplicitParam(paramType = "query", name="salesOrderId", dataType = "String", required = true),
......
...@@ -7,6 +7,7 @@ import java.util.Map; ...@@ -7,6 +7,7 @@ import java.util.Map;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.egolm.common.jdbc.Page; import com.egolm.common.jdbc.Page;
import com.egolm.shop.bean.RespObject;
public interface OrderService { public interface OrderService {
...@@ -35,5 +36,9 @@ public interface OrderService { ...@@ -35,5 +36,9 @@ public interface OrderService {
public void confirmReceipt(String custNo, String subOrderID); public void confirmReceipt(String custNo, String subOrderID);
public List<Map<String, Object>> getDeliverSubDetail(String aocOrderID); public List<Map<String, Object>> getDeliverSubDetail(String aocOrderID);
public RespObject queryRefundOrderList(String orgNo, String shopNo, Integer refundStatus, String langID, Page page);
} }
...@@ -2,6 +2,7 @@ package com.egolm.shop.api.service.impl; ...@@ -2,6 +2,7 @@ package com.egolm.shop.api.service.impl;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
...@@ -14,7 +15,7 @@ import org.springframework.jdbc.UncategorizedSQLException; ...@@ -14,7 +15,7 @@ import org.springframework.jdbc.UncategorizedSQLException;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.egolm.common.DateUtil; import com.egolm.common.DateUtil;
import com.egolm.common.StringUtil; import com.egolm.common.StringUtil;
import com.egolm.common.Util; import com.egolm.common.Util;
...@@ -24,7 +25,8 @@ import com.egolm.common.jdbc.Page; ...@@ -24,7 +25,8 @@ import com.egolm.common.jdbc.Page;
import com.egolm.common.jdbc.dialect.Dialect; import com.egolm.common.jdbc.dialect.Dialect;
import com.egolm.common.jdbc.dialect.SqlServerDialect; import com.egolm.common.jdbc.dialect.SqlServerDialect;
import com.egolm.common.jdbc.dialect.bean.Sql; import com.egolm.common.jdbc.dialect.bean.Sql;
import com.egolm.shop.api.service.OrderService; import com.egolm.shop.api.service.OrderService;
import com.egolm.shop.bean.RespObject;
import com.egolm.shop.bean.TSalesOrder; import com.egolm.shop.bean.TSalesOrder;
import com.egolm.shop.bean.TSalesOrderDtl; import com.egolm.shop.bean.TSalesOrderDtl;
import com.egolm.shop.common.XException; import com.egolm.shop.common.XException;
...@@ -895,5 +897,132 @@ public class OrderServiceImpl implements OrderService { ...@@ -895,5 +897,132 @@ public class OrderServiceImpl implements OrderService {
wxService.sendMessage(wxMessage); wxService.sendMessage(wxMessage);
}*/ }*/
} }
@Override
public RespObject queryRefundOrderList(String orgNo, String shopNo, Integer refundStatus, String langID, Page page) {
List<Map<String, Object>> sortList = new ArrayList<Map<String, Object>>();
int saleReturnDays = 0;
try {
String dSql = "select SaleReturnDays = convert(int, sValue1) FROM tSystemCtrl WHERE sCode = 'SaleReturnDays' ";
saleReturnDays = jdbcTemplate.queryForInt(dSql);
} catch (Exception e) {
}
String sql = "select " +
" SalesOrderID = a.sSalesOrderID, " +
" SubOrderID = a.sSubOrderID, " +
" OrderDate = a.dOrderDate, " +
" SalesOrderTypeID = a.sSalesOrderTypeID," +
" SalesOrderType = a.sSalesOrderType," +
" TotalSaleQty = a.nTotalSaleQty," +
" TotalSaleAmount = a.nTotalSaleAmount," +
" TotalDisAmount = a.nTotalDisAmount," +
" DeliveryTypeID = a.sDeliveryTypeID," +
" DeliveryType = a.sDeliveryType," +
" Contacts = a.sContacts," +
" Mobile = a.sMobile," +
" Address = a.sAddress," +
" ExpressFee = a.nExpressFee," +
" OrderStatus = a.nOrderStatus," +
" OrderStatusName = a.nOrderStatusName," +
" OrderMemo = a.sOrderMemo" +
" from tSalesOrderSub a "
+ " where a.sShopNO = '"+shopNo+"' " ;
if(refundStatus == 1) { /*查询指定状态订单:1=申请售后*/
sql += " and a.sSalesOrderTypeID = '0' "
+ " and a.sB2BOrderTypeID = '1' "
+ " and a.nOrderStatus&1 = 0 "
+ " and (a.nOrderStatus&16=16 or nOrderStatus&4=0) "
+ " and (datediff(dd, a.dOrderDate, getdate()) <= "+saleReturnDays+" or "+saleReturnDays+" = 0) "
+ " and exists(select 1 from tSalesOrderSubDtl where sSubOrderID = a.sSubOrderID and (nSaleQty - isnull(nReturnQty,0)) > 0) ";
}else if (refundStatus == 2) { /*查询指定状态订单:2=平台确认*/
sql += " and a.sSalesOrderTypeID = '2' "
+ " and isnull(a.sOldSubOrderID,'') <> '' "
+ " and a.nOrderStatus&4=0 " ;
}else if (refundStatus == 3) {
sql += " and a.sSalesOrderTypeID = '2' "
+ " and isnull(a.sOldSubOrderID,'') <> '' "
+ " and a.nOrderStatus&1=0 "
+ " and a.nOrderStatus&16=0 " ;
}else {
sql += " and a.sSalesOrderTypeID = '2' "
+ " and isnull(a.sOldSubOrderID,'') <> '' "
+ " and a.nOrderStatus&1=0 "
+ " and a.nOrderStatus&16=16 ";
}
List<Map<String, Object>> orderList = jdbcTemplate.limit(sql, page);
sortList.addAll(orderList);
sortList.sort(new Comparator<Map<String, Object>>() {
public int compare(Map<String, Object> arg0, Map<String, Object> arg1) {
Date time1 = this.getOrderTime(arg0);
Date time2 = this.getOrderTime(arg1);
return time2.compareTo(time1);
}
private Date getOrderTime(Map<String, Object> map) {
String SalesOrderTypeID = (String)map.get("SalesOrderTypeID");
if(StringUtil.isNotBlank(SalesOrderTypeID)) {
return (Date)map.get("OrderDate");
} else {
return (Date)map.get("OrderDateTime");
}
}
});
Integer start = page.getFirstRowNumber().intValue() - 1;
Integer end = page.getLastRowNumber().intValue();
Integer size = sortList.size();
end = size < end ? size : end;
page.setTotal((long)sortList.size());
List<Map<String, Object>> datas = sortList.subList(start, end);
if(orderList != null && orderList.size() >0 ) {
List<String> orderIdList = orderList.stream().map(o -> (String)o.get("SubOrderID")).collect(Collectors.toList());
String detailSql = "select" +
" SalesOrderID = a.sSalesOrderID," +
" SubOrderID = a.sSubOrderID," +
" Idx = a.nIdx," +
" GoodsID = a.nGoodsID," +
" GoodsNO = ag.sGoodsNO," +
" GoodsDesc = a.sGoodsDesc," +
" Spec = ag.sSpec," +
" Unit = a.sUnit," +
" SaleQty = case when b.sSalesOrderTypeID = '0' then a.nSaleQty else 0 end," +
" SalePrice = a.nSalePrice," +
" RealSalePrice = ag.nRealSalePrice," +
" SaleAmount = case when b.sSalesOrderTypeID = '0' then a.nSaleAmount else 0 end," +
" DisAmount = case when b.sSalesOrderTypeID = '0' then a.nDisAmount else 0 end," +
" PromoPaperNO = a.sPromoPaperNO," +
" PromoActionTypeID = a.sPromoActionTypeID," +
" ReturnQty = case when b.sSalesOrderTypeID = '0' then isnull(a.nReturnQty,0) else abs(a.nSaleQty) end," +
" LeftRefundQty = case when b.sSalesOrderTypeID = '0' then a.nSaleQty - isnull(a.nReturnQty,0) else 0 end," +
" Memo = a.sMemo," +
" Tag = a.nTag," +
" GoodsURL = gp.sURL "
+ " from tSalesOrderSubDtl a join tSalesOrderSub b on a.sSubOrderID = b.sSubOrderID left join tAgentContractGoods ag on a.nAgentID = ag.nAgentID "
+ " and a.sAgentContractNO = ag.sAgentContractNO and a.nGoodsID = ag.nGoodsID "
+ " left join V_GetminAgentGoodsPic gp on a.nAgentID = gp.nAgentID and a.nGoodsID = gp.nGoodsID "
+ " where a.sSubOrderID in (?) " +
" order by a.nIdx" ;
List<Map<String, Object>> goodsList = jdbcTemplate.queryForList(detailSql, orderIdList.toArray());
Map<String, List<Map<String, Object>>> gmList = Util.listToML(goodsList, "SalesOrderID");
for(Map<String, Object> orderMap : orderList) {
orderMap.put("SalesOrderDtl", gmList.get(orderMap.get("SalesOrderID")));
}
}
Map<String, Object> result = new HashMap<String, Object>();
result.put("page", page);
result.put("SalesOrderList", datas);
return new RespObject(result);
}
} }
package com.egolm.shop.bean;
import java.io.Serializable;
public class RespObject implements Serializable {
private static final long serialVersionUID = 1L;
private int code = 200;
private String message = "OK";
private Object data;
public RespObject() {
this.data = null;
}
public RespObject(Object data) {
this.data = data;
}
public RespObject(int code, String message, Object data) {
this.code = code;
this.message = message;
this.data = data;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public Object getData() {
return data;
}
public void setData(Object data) {
this.data = data;
}
public static long getSerialversionuid() {
return serialVersionUID;
}
}
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 to comment