+" IsRefund = case when isnull(sos.sBindPaperNO,'') = '' then 1 when sos.nOrderStatus&17=0 then 0 when datediff(dd,dateadd(dd,1,convert(date,sos.dReceiveDate)),getdate()) >= ? then 0 else 1 end, "
+"case when sos.nOrderStatus&145 = 144 then '16' when sos.nOrderStatus&145 = 128 then '8' when sos.nOrderStatus&145 = 0 then '4' when sos.nOrderStatus&5 = 4 then '2' else '0' end nOrderStatus, "
+"case when sos.nOrderStatus&145 = 144 then '16' when sos.nOrderStatus&145 = 128 then '8' when sos.nOrderStatus&145 = 0 then '4' when sos.nOrderStatus&5 = 4 then '2' else '0' end nOrderStatus, "
+"case when sos.nOrderStatus&145 = 144 then '已完成' when sos.nOrderStatus&145 = 128 then '配送中' when sos.nOrderStatus&145 = 0 then '待发货' when sos.nOrderStatus&5 = 4 then '已审核' else '未审核' end sOrderStatusText "
+"case when sos.nOrderStatus&145 = 144 then '已完成' when sos.nOrderStatus&145 = 128 then '配送中' when sos.nOrderStatus&145 = 0 then '待发货' when sos.nOrderStatus&5 = 4 then '已审核' else '未审核' end sOrderStatusText "
+"from tSalesOrderSub sos where sos.sSubOrderID = ?",subOrderID);
+"from tSalesOrderSub sos left join (select sSubOrderID, nSendQty = sum(nSendQty), nReturnQty = sum(nReturnQty) from tSalesOrderSubDtl where sSubOrderID = ? group by sSubOrderID) d on sos.sSubOrderID = d.sSubOrderID "
+" where sos.sSubOrderID = ?",ReturnDay,subOrderID,subOrderID);
+"left join tYWPromoMain pm on pm.sPromoPaperNO = sosd.sPromoPaperNO "
+"left join tYWPromoMain pm on pm.sPromoPaperNO = sosd.sPromoPaperNO "
+"left join V_GetminAgentGoodsPic agp on agp.nAgentID = sosd.nAgentID and agp.nGoodsID = sosd.nGoodsID and agp.sPicTypeID = 1 where sosd.sSubOrderID = ?";
+"left join V_GetminAgentGoodsPic agp on agp.nAgentID = sosd.nAgentID and agp.nGoodsID = sosd.nGoodsID and agp.sPicTypeID = 1 "
+"left join tAgentContractGoods ag on sosd.sAgentContractNO = ag.sAgentContractNO and sosd.nGoodsID = ag.nGoodsID "
Map<String,Object>deliver=jdbcTemplate.queryForMap("SELECT sum(a.nNum) nTotalCount, sum(a.nPrice * a.nNum) nTotalAmount FROM tSalesOrderDeliverSubDtl a where a.sSubOrderID = ?",subOrderID);
Map<String,Object>deliver=jdbcTemplate.queryForMap("SELECT sum(a.nNum) nTotalCount, sum(a.nPrice * a.nNum) nTotalAmount FROM tSalesOrderDeliverSubDtl a where a.sSubOrderID = ?",subOrderID);
Stringsql3="select sSubOrderID, nOrderMoney, sAocOrderID, sAocOrderNumber, nOrderNum, nPickupNum, sExpressNO, sExpressName from tSalesOrderDeliverSub where nTag&1 = 0 and sSubOrderID = ?";
Stringsql3="select sSubOrderID, nOrderMoney, sAocOrderID, sAocOrderNumber, nOrderNum, nPickupNum, sExpressNO, sExpressName from tSalesOrderDeliverSub where nTag&1 = 0 and sSubOrderID = ?";