Пример #1
0
        /// <summary>
        /// 检查客户的使用情况并给出总评消息提示
        /// </summary>
        public void StartShopStatusAlert()
        {
            //获取目前在用的而且自动赠送优惠券的
            ShopData        dbShop = new ShopData();
            List <ShopInfo> list   = dbShop.GetShopInfoNormalUsed();

            TradeData   dbTrade   = new TradeData();
            CouponData  dbCoupon  = new CouponData();
            MessageData dbMessage = new MessageData();
            string      typ       = "status";

            //循环获取这些卖家的未审核订单
            for (int i = 0; i < list.Count; i++)
            {
                int      couponOrderCount = 0;
                decimal  couponOrderPrice = 0;
                ShopInfo shop             = list[i];

                //获取卖家赠送的优惠券数量
                string sendcount = dbCoupon.GetCouponSendCountWeekByNick(shop);
                //如果一个都没赠送出去就不发送
                if (sendcount == "0")
                {
                    Console.Write("该卖家没有赠送出任何优惠券,先不消息提示..\r\n");
                    continue;
                }

                string sql        = "SELECT COUNT(*) FROM TCS_Trade WHERE nick = '" + shop.Nick + "' AND iscoupon = 1";
                string totalcount = utils.ExecuteString(sql);

                sql = "SELECT SUM(Convert(decimal,totalprice)) FROM TCS_Trade WHERE nick = '" + shop.Nick + "' AND iscoupon = 1";
                string totalprice = utils.ExecuteString(sql);

                //TopApiHaoping api = new TopApiHaoping(shop.Session);
                //List<Trade> listTrade = dbTrade.GetTradeAllByNick(shop);
                //Console.Write("total:[" + listTrade.Count.ToString() + "]\r\n");
                //for (int j = 0; j < listTrade.Count; j++)
                //{
                //    //获取未审核的评价并发送消息
                //    string result = api.GetCouponTradeTotalByNick(listTrade[j]);

                //    string couponid = new Regex(@"<promotion_id>([^\<]*)</promotion_id><promotion_name>店铺优惠券", RegexOptions.IgnoreCase).Match(result).Groups[1].ToString();
                //    string price = new Regex(@"<total_fee>([^\<]*)</total_fee>", RegexOptions.IgnoreCase).Match(result).Groups[1].ToString();
                //    Console.Write(".");
                //    if (couponid != "")
                //    {
                //        Console.Write("\r\n"+couponid + "...........................................................\r\n");
                //        Console.Write(price + "...........................................................\r\n");
                //        couponOrderCount++;
                //        couponOrderPrice += decimal.Parse(price);
                //    }
                //}

                if (totalcount == "0")
                {
                    Console.Write("该卖家没有优惠券产生2次订购,先不消息提示..\r\n");
                    continue;
                }

                string msg = "好评有礼:" + shop.Nick + ",共赠送了" + sendcount + "张优惠券," + totalcount + "个客户使用优惠券产生了二次购买总额" + totalprice + "元";
                Console.Write(msg + "...........................................................\r\n");
                //如果14天内已经发送过类似短信的话则不再提醒
                if (!dbMessage.IsSendMsgNearDays(shop, typ))
                {
                    string msgResult = Message.SendGuodu(shop.Mobile, msg);
                    dbMessage.InsertShopAlertMsgLog(shop, msg, msgResult, typ);
                    Console.Write(msg + "[" + msg.Length.ToString() + "]\r\n");
                }
            }
        }