Stringsql2="select sod.*, agp.sURL from tSalesOrderDtl sod left join V_GetminAgentGoodsPic agp on agp.nAgentID = sod.nAgentID and agp.nGoodsID = sod.nGoodsID and agp.sPicTypeID = 1 where sod.sSalesOrderID in ("+StringUtil.join("', '","'","'",orderIds)+")";
Stringsql4="select sosd.*, agp.sURL from tSalesOrderSubDtl sosd left join V_GetminAgentGoodsPic agp on agp.nAgentID = sosd.nAgentID and agp.nGoodsID = sosd.nGoodsID and agp.sPicTypeID = 1 where sosd.sSubOrderID in ("+StringUtil.join("', '","'","'",subIds)+")";
Stringsql2="select sod.*, agp.sURL, pm.sPromoTheme, pm.sPromoActionType sPromoType, pm.sPromoActionTypeID sPromoTypeID from tSalesOrderDtl sod left join tYWPromoMain pm on pm.sPromoPaperNO = sod.sPromoPaperNO left join V_GetminAgentGoodsPic agp on agp.nAgentID = sod.nAgentID and agp.nGoodsID = sod.nGoodsID and agp.sPicTypeID = 1 where sod.sSalesOrderID = ?";
Stringsql2="select sosd.*, agp.sURL, pm.sPromoTheme, pm.sPromoActionType sPromoType, pm.sPromoActionTypeID sPromoTypeID from tSalesOrderSubDtl sosd 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 in ("+StringUtil.join("', '","'","'",subIds)+")";
+"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 "
+"from tSalesOrderSub sos where sos.sSubOrderID = ?",subOrderID);
+"case when so.nOrderStatus&145 = 144 then '16' when so.nOrderStatus&145 = 128 then '8' when so.nOrderStatus&145 = 0 then '4' when so.nOrderStatus&5 = 4 then '2' else '0' end nOrderStatus, "
+"case when so.nOrderStatus&145 = 144 then '已完成' when so.nOrderStatus&145 = 128 then '配送中' when so.nOrderStatus&145 = 0 then '待发货' when so.nOrderStatus&5 = 4 then '已审核' else '未审核' end sOrderStatusText "
+"from tSalesOrder so where so.sSalesOrderID = ?",subOrderMap.get("sSalesOrderID"));
Stringsql=""
+"select "
+"sosd.*, "
+"agp.sURL, "
+"pm.sPromoTheme, "
+"pm.sPromoActionType sPromoType, "
+"pm.sPromoActionTypeID sPromoTypeID "
+"from tSalesOrderSubDtl sosd "
+"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 = ?";
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 = ?";
StringstockSql="select og.sWarehouseNO, og.sAgentContractNO, og.nGoodsID, og.nStockQty, og.nLockedQty from tPromoRuleGoods prg, V_OrgGoods og where prg.sAgentContractNO = og.sAgentContractNO and prg.nGoodsID = og.nGoodsID and og.sOrgNO = ? and prg.sPromoPaperNO = ? and prg.sPromoGroupNO = ?";
Map<String,Object>custMap=jdbcTemplate.queryForMap("select c.* from tCustomer c, tShop s where c.sCustNO = s.sCustNO and s.sShopNO = ? and s.sOrgNO = ?",shopNo,orgNo);
jdbcTemplate.batchUpdate("update tAgentStockOnline set nLockedQty = (nLockedQty + ?) where sAgentContractNO = ? and nGoodsID = ? and sWarehouseNO = ?",batchArgs);
Map<String,Object>planSum=jdbcTemplate.queryForMap("select sum(nTotalSaleQty) nOrderQty, sum(nTotalSaleAmount) nOrderAmount from tSalesOrder where nPlanID = ? and nOrderStatus&1 = 0",planId);
LongnProjectID=jdbcTemplate.queryForLong("select nProjectID from tZHCPlan where nPlanID = ?",planId);
Stringsql="select count(so.sSalesOrderID) nSalePaperQty, isnull(sum(so.nTotalSaleQty), 0) nSaleQty, isnull(sum(so.nTotalSaleAmount), 0) nSaleAmount from tSalesOrder so, tZHCPlan p where so.sB2BOrderTypeID = '3' and so.nTag&1 = 0 and so.nPlanID = p.nPlanID and p.nProjectID = ?";
StringgSql="select t.*, ap.nRealSalePrice nApSalePrice from V_OrgGoods t left join tAgentCustTypePrice ap on ap.sCustTypeID = ? and ap.sAgentContractNO = t.sAgentContractNO and ap.nGoodsID = t.nGoodsID where t.sOrgNO = ? and t.sAgentContractNO = ? and t.nGoodsID = ?";
+"SELECT @OrderStatus = nOrderStatus FROM tSalesOrderSub WHERE sSubOrderID = @SubOrderID "
+"IF @OrderStatus&@TargetStatus = 0 "
+"BEGIN "
+"SELECT @SalesOrderID = sSalesOrderID FROM tSalesOrderSub WHERE sSubOrderID = @SubOrderID "
+"UPDATE tSalesOrderSub SET nOrderStatus = nOrderStatus|@TargetStatus, nOrderStatusName = @OrderStatusName, dLastUpdateTime = GETDATE() WHERE sSubOrderID = @SubOrderID "
+"UPDATE tSalesOrderSubDtl SET nReceiveQty = td.nSendQty, nReceiveAmount = td.nSendAmount, dLastUpdateTime = GETDATE() FROM tSalesOrderSub t, tSalesOrderSubDtl td WHERE t.sSubOrderID = td.sSubOrderID AND t.sSubOrderID = @SubOrderID AND td.nReceiveQty IS NULL "
+"DECLARE @Idx INT "
+"SELECT @Idx = ISNULL(MAX(nIdx), 0) + 1 FROM tSalesOrderSubStatus WHERE sSubOrderID = @SubOrderID "