StringsqlPromo="SELECT * FROM tYWPromoMain WHERE sPromoPaperNO in ('"+StringUtil.join("', '",promosNo)
+"')";
StringsqlPromoDtl="SELECT DISTINCT a.* FROM ( SELECT dtl.*, pgc.nQty nGiftQty FROM tYWPromoDtl dtl LEFT JOIN tPromoGiftCount pgc ON pgc.sPromoPaperNO = dtl.sPromoPaperNO AND pgc.nGoodsID = dtl.nGoodsID ) a, tCart c WHERE a.sPromoPaperNO = c.sPromoPaperNO AND c.sShopNO = '"
+shopNo
+"' AND ( a.nTag = 1 OR ( a.sAgentContractNO = c.sAgentContractNO AND a.nGoodsID = c.nGoodsID AND a.nTag = c.nTag ) )";
StringsqlPromoLimit="SELECT sop.sPromoPaperNO, sop.sAgentContractNO, sop.nGoodsID, SUM(sop.nValidQty) nValidQty FROM tSalesOrderPromo sop WHERE sop.sPromoPaperNO IN ('"
+StringUtil.join("', '",promosNo)
+"') GROUP BY sop.sPromoPaperNO, sop.sAgentContractNO, sop.nGoodsID";
+"pn.nTag&2 != 2 OR pn.nTag&1 = 1 OR GETDATE() < pn.dPromoBeginDate OR GETDATE() >= pn.dPromoEndDate";
StringsqlClear=""+"DELETE mmm FROM tCart mmm WHERE mmm.sShopNO = '"+shopNo
+"' AND EXISTS ( SELECT NULL FROM tAgentContractGoods nnn WHERE nnn.nGoodsID = mmm.nGoodsID AND nnn.sAgentContractNO = mmm.sAgentContractNO AND (nnn.nTag & 16 = 0 or nnn.nTag & 1 = 1) AND mmm.sShopNO = '"
+shopNo+"' )"+Util.LINE_SEPARATOR+"DELETE mmmm FROM tCart mmmm WHERE mmmm.sShopNO = '"+shopNo
+"' AND NOT EXISTS ( SELECT NULL FROM tWarehouseDistrict wd, tShop s, tAgentContractWarehouse acw, tAgentContractGoods acg WHERE wd.sDistrictID = s.sDistrictID AND s.sShopNO = '"
+shopNo
+"' AND wd.nTag & 1 = 0 AND acw.sWarehouseNO = wd.sWarehouseNO AND acw.nTag & 1 = 0 AND acg.sAgentContractNO = acw.sAgentContractNO AND acg.nGoodsID = mmmm.nGoodsID AND acg.sAgentContractNO = mmmm.sAgentContractNO ) "