Exemplo n.º 1
0
        /// <summary>
        /// 长时间未消费客户回访
        /// </summary>
        public void CallMemberBack()
        {
            //获取在执行中的回访任务卖家
            string          typ       = "back";
            ShopData        data      = new ShopData();
            CustomerData    cusData   = new CustomerData();
            MessageData     dbMessage = new MessageData();
            List <ShopInfo> shoplist  = data.GetActMissionShop(typ);

            for (int i = 0; i < shoplist.Count; i++)
            {
                ShopInfo shop = shoplist[i];

                try
                {
                    //获取该卖家符合条件的买家清单
                    List <Customer> cusList = cusData.GetBackCustomer(shop);

                    //每天最多发送100条提醒
                    int total = 0;

                    for (int j = 0; j < cusList.Count; j++)
                    {
                        Customer customer = cusList[j];
                        //发送短信
                        if (customer.Mobile != "")
                        {
                            if (!dbMessage.IsSendMsgNearDays(customer, typ, shop.MissionBackDay))
                            {
                                string msgResult = Message.SendGuodu(customer.Mobile, shop.MissionContent);
                                data.InsertShopMsgLog(shop, customer, shop.MissionContent, msgResult, typ);
                                Console.Write(shop.MissionContent + "--" + customer.Nick + "--" + customer.BuyNick + "[" + shop.MissionContent.Length.ToString() + "]\r\n");
                                total++;

                                //每天最多发送100条
                                if (total > 100)
                                {
                                    break;
                                }
                            }
                        }
                    }
                }
                catch
                {
                    Console.WriteLine(shop.Nick + "------------err!!");
                }

                //Console.ReadLine();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 生日关怀
        /// </summary>
        public void BirthDayCall()
        {
            //获取在执行中的回访任务卖家
            string          typ       = "birthday";
            ShopData        data      = new ShopData();
            CustomerData    cusData   = new CustomerData();
            MessageData     dbMessage = new MessageData();
            List <ShopInfo> shoplist  = data.GetActMissionShop(typ);

            for (int i = 0; i < shoplist.Count; i++)
            {
                ShopInfo shop = shoplist[i];
                //获取该卖家符合条件的买家清单
                try
                {
                    List <Customer> cusList = cusData.GetBirthdayCustomer(shop);
                    for (int j = 0; j < cusList.Count; j++)
                    {
                        Customer customer = cusList[j];
                        //发送短信
                        if (customer.Mobile != "")
                        {
                            if (!dbMessage.IsSendMsgNearDays(customer, typ, "30"))
                            {
                                string msgResult = Message.SendGuodu(customer.Mobile, shop.MissionContent);
                                data.InsertShopMsgLog(shop, customer, shop.MissionContent, msgResult, typ);
                                Console.Write(shop.MissionContent + "--" + customer.Nick + "--" + customer.BuyNick + "[" + shop.MissionContent.Length.ToString() + "]\r\n");
                            }
                        }
                    }
                }
                catch
                {
                    Console.WriteLine(shop.Nick + "------------err!!");
                }
            }
        }
Exemplo n.º 3
0
        private void ActRateInfoDetail(string sql)
        {
            try
            {
                DataTable dt    = utils.ExecuteDataTable(sql);
                Trade     trade = new Trade();
                ShopInfo  shop  = new ShopInfo();
                ShopData  db    = new ShopData();

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    string mobile = dt.Rows[i][0].ToString();
                    trade.Nick    = dt.Rows[i][1].ToString();
                    shop.Nick     = dt.Rows[i][1].ToString();
                    trade.BuyNick = dt.Rows[i][2].ToString();
                    trade.Mobile  = dt.Rows[i][0].ToString();

                    Console.WriteLine(trade.Mobile + "-" + Msg);
                    //string result = Message.Send(trade.Mobile, msg);
                    sql = "SELECT total FROM TCS_ShopConfig WHERE nick = '" + Nick + "'";
                    string total = utils.ExecuteString(sql);

                    if (int.Parse(total) > 0)
                    {
                        if (!db.IsSendMsgToday(trade, "act"))
                        {
                            //先插入数据库 解决多优惠券赠送短信多发问题
                            string msgResult = Message.SendMuti(trade.Mobile, Msg);

                            db.InsertShopMsgLog(shop, trade, Msg, msgResult, "act");
                        }
                    }
                }
            }
            catch { }
        }
Exemplo n.º 4
0
        public void Start()
        {
            //获取目前正在使用的卖家
            ShopData        dbShop = new ShopData();
            List <ShopInfo> list   = dbShop.GetShopInfoListAlert();

            //循环判定卖家是否到提醒发货时间了
            Console.Write(list.Count.ToString() + "\r\n");
            for (int i = 0; i < list.Count; i++)
            {
                ShopInfo shop = list[i];
                Console.Write(shop.Nick + "-" + shop.MsgReviewTime + "-" + DateTime.Now.Hour.ToString() + "\r\n");
                if (DateTime.Now.Hour.ToString() == list[i].MsgReviewTime || shop.IsXuni == "1")
                {
                    //获取那些延迟不确认且没发过短信的订单给予提示
                    TradeData    dbTrade   = new TradeData();
                    List <Trade> listTrade = new List <Trade>();

                    if (shop.IsXuni == "1")
                    {
                        //如果是虚拟商品
                        listTrade = dbTrade.GetUnconfirmTradeXuni(shop);
                    }
                    else
                    {
                        listTrade = dbTrade.GetUnconfirmTrade(shop);
                    }

                    Console.Write(listTrade.Count.ToString() + "\r\n");
                    for (int j = 0; j < listTrade.Count; j++)
                    {
                        Trade trade = listTrade[j];

                        //判断如果是分销的订单,则不处理
                        if (trade.OrderType.ToLower() == "fenxiao")
                        {
                            return;
                        }

                        //发送短信-上LOCK锁定
                        lock (padlock4)
                        {
                            //判断同类型的短信该客户今天是否只收到一条
                            ShopData db = new ShopData();
                            if (!db.IsSendMsgOrder(trade, "review") && !db.IsSendMsgToday(trade, "review"))
                            {
                                //判断该用户是否开启了发货短信
                                if (shop.MsgIsReview == "1" && int.Parse(shop.MsgCount) > 0)
                                {
                                    //发送短信
                                    //string msg = Message.GetMsg(shop.MsgReviewContent, shop.MsgShopName, trade.BuyNick, shop.IsCoupon);
                                    string msg       = Message.GetMsg(shop, trade, shop.MsgReviewContent);
                                    string msgResult = Message.Send(trade.Mobile, msg);

                                    //记录
                                    if (msgResult != "0")
                                    {
                                        db.InsertShopMsgLog(shop, trade, msg, msgResult, "review");
                                    }
                                    else
                                    {
                                        db.InsertShopErrMsgLog(shop, trade, msg, msgResult, "review");
                                    }
                                    shop.MsgCount = (int.Parse(shop.MsgCount) - 1).ToString();
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 处理订单完成时的相应逻辑
        /// </summary>
        public void Start()
        {
            //获取店铺的基础数据
            ShopData data = new ShopData();
            ShopInfo shop = data.ShopInfoGetByNick(TradeInfo.Nick);

            //Console.Write(shop.Session + "!!!!!!!!!!!!\r\n");
            if (shop.Version != "2" && shop.Version != "3")
            {
                return;
            }

            //通过TOP接口查询该订单的详细数据并记录到数据库中
            TopApiHaoping api       = new TopApiHaoping(shop.Session);
            TradeData     tradeData = new TradeData();
            Trade         trade     = tradeData.GetTradeDetailShippingInfo(TradeInfo);

            trade = api.GetTradeByTid(trade);

            //记录该订单对应的评价记录
            TradeRate tradeRate = api.GetTradeRate(trade);

            tradeRate.ItemId = trade.NumIid;
            tradeRate.Nick   = TradeInfo.Nick;

            //只有双方都评价了才会有插入数据库和赠送的操作
            if (tradeRate.Content != "")
            {
                //判断该订单是否已经有过评价记录
                TradeRateData dbTradeRate = new TradeRateData();
                if (!dbTradeRate.CheckTradeRateExits(tradeRate))
                {
                    //没有记录过写入数据库
                    dbTradeRate.InsertTradeInfo(tradeRate);
                }

                //判断该订单是否存在
                TradeData dbTrade = new TradeData();
                if (!dbTrade.CheckTradeExits(trade))
                {
                    //更新该订单的评价时间
                    dbTrade.InsertTradeInfo(trade);
                }

                //更新该订单的评价时间
                dbTrade.UpdateTradeRateById(trade, tradeRate);
            }
            else
            {
                //否则中断
                return;
            }

            //判断如果是分销的订单,则不处理
            if (trade.OrderType.ToLower() == "fenxiao")
            {
                return;
            }

            try
            {
                //更新订单的优惠券使用情况
                TopApiHaoping apiCoupon = new TopApiHaoping(shop.Session);
                string        result    = apiCoupon.GetCouponTradeTotalByNick(trade);

                MatchCollection match = new Regex(@"<promotion_details list=""true""><promotion_detail><discount_fee>([^\<]*)</discount_fee><id>[0-9]*</id><promotion_desc>[^\<]*</promotion_desc><promotion_id>shopbonus-[0-9]*_[0-9]*-([0-9]*)</promotion_id><promotion_name>店铺优惠券</promotion_name></promotion_detail>", RegexOptions.IgnoreCase).Matches(result);

                if (match.Count != 0)
                {
                    string price    = match[0].Groups[1].ToString();
                    string couponid = match[0].Groups[2].ToString();

                    if (couponid.Length != 0)
                    {
                        TradeData dataTradeCoupon = new TradeData();
                        dataTradeCoupon.UpdateTradeCouponInfo(trade, price, couponid);
                    }
                }
            }
            catch { }

            //判断是否开启了客服审核,如果开启了则自动记录并中断
            if (shop.IsKefu == "1")
            {
                TradeRateData dataKefu   = new TradeRateData();
                string        resultKefu = "手动审核订单!";
                dataKefu.UpdateTradeRateResult(tradeRate, resultKefu);

                //更新该订单的评价为待审核状态
                TradeData dbTrade = new TradeData();
                if (!dbTrade.CheckTradeRateCheckExits(trade))
                {
                    dbTrade.UpdateTradeKefuById(trade, tradeRate);
                }

                try
                {
                    //记录会员信息数据
                    GetUserData getUser = new GetUserData();
                    getUser.Get(trade);
                }
                catch { }

                return;
            }

            Console.WriteLine(trade.ShippingType + "!!");

            //获取订单的具体物流状态,如果订单物流状态为空则获取物流信息
            if (trade.ShippingType != "system" && trade.ShippingType != "self")
            {
                //获取该订单的物流状态
                TopApiHaoping apiHaoping = new TopApiHaoping(shop.Session);
                string        status     = apiHaoping.GetShippingStatusByTid(trade);
                TradeData     dbTrade    = new TradeData();

                Console.Write(status + "\r\n");
                //如果该物流信息不存在
                if (status.IndexOf("不存在") != -1)
                {
                    //如果该物流公司不支持查询则更新为self
                    dbTrade.UpdateTradeShippingStatusSelf(trade, status);
                }

                //获取该订单的物流相关信息
                trade = api.GetOrderShippingInfo(trade);
                if (!dbTrade.IsTaobaoCompany(trade))
                {
                    //如果不是淘宝合作物流则直接更新
                    dbTrade.UpdateTradeShippingStatusSelf(trade, status);
                    trade.ShippingType = "self";
                }
                else
                {
                    //根据服务器的物流状态进行判断,如果物流状态是已签收
                    if (status == "ACCEPTED_BY_RECEIVER" || status == "ACCEPTING" || status == "ACCEPTED")
                    {
                        string result = api.GetShippingStatusDetailByTid(trade);
                        Console.Write("【" + result + "】\r\n");
                        //如果是虚拟物品
                        if (result.IndexOf("该订单未指定运单号") != -1)
                        {
                            //如果该物流公司不支持查询则更新为self
                            dbTrade.UpdateTradeShippingStatusSelf(trade, status);
                        }

                        //如果订单不是服务器错误
                        if (result.IndexOf("company-not-support") != -1)
                        {
                            //如果该物流公司不支持查询则更新为self
                            dbTrade.UpdateTradeShippingStatusSelf(trade, status);
                        }

                        //再根据订单的详细物流信息判断签收的状态
                        if (result.IndexOf("签收人") != -1 || result.IndexOf(" 妥投") != -1 || result.IndexOf(" 签收") != -1 || result.IndexOf("正常签收") != -1 || result.IndexOf(" 已签收") != -1)
                        {
                            //如果物流已经签收了则更新对应订单状态
                            trade.DeliveryEnd  = utils.GetShippingEndTime(result);;
                            trade.DeliveryMsg  = result;
                            trade.ShippingType = "system";

                            //如果物流到货时间还是为空
                            if (trade.DeliveryEnd == "")
                            {
                                LogData dbLog = new LogData();
                                dbLog.InsertErrorLog(trade.Nick, "deliveryDateNullOrder", "", result, "");
                            }

                            dbTrade.UpdateTradeShippingStatusSystem(trade, status);
                        }
                    }
                }
            }

            //处理优惠券赠送及短信-上LOCK锁定
            lock (TradeSuccess.padlockRate)
            {
                //淘宝优惠券赠送
                bool isSendCoupon = true;
                //判断是否符合赠送条件
                if (CheckCouponSend(shop, tradeRate, trade))
                {
                    //如果符合赠送条件调用赠送接口
                    CouponData dbCoupon = new CouponData();
                    Coupon     coupon   = dbCoupon.GetCouponInfoById(shop);

                    //判定该优惠券是否过期或删除
                    if (!dbCoupon.CheckCouponCanUsed(shop))
                    {
                        //优惠券过期,自动帮客户延长优惠券期限
                        //考虑到淘宝即将开启短授权,该功能改成消息通知,暂不制作
                        isSendCoupon = false;
                        //return;
                    }
                    else
                    {
                        //解决多线程冲突问题先插入优惠券赠送记录,如果赠送失败再删除记录
                        string couponId = string.Empty;
                        if (dbCoupon.InsertCouponSendRecord(trade, shop, couponId))
                        {
                            string taobaoResult = string.Empty;
                            couponId = api.SendCoupon(trade.BuyNick, coupon.TaobaoCouponId, ref taobaoResult);

                            //获取的赠送接口的返回结果
                            if (couponId != "")
                            {
                                //如果成功赠送则记录
                                dbCoupon.UpdateCouponSendRecord(trade, shop, couponId);
                            }
                            else
                            {
                                //如果没有赠送成功则删除刚才的临时记录
                                dbCoupon.DeleteCouponSendRecord(trade, shop, couponId);
                                Console.WriteLine(couponId);
                                try
                                {
                                    //记录淘宝自身错误
                                    string        err      = new Regex(@"<reason>([^<]*)</reason>", RegexOptions.IgnoreCase).Match(taobaoResult).Groups[1].ToString();
                                    TradeRateData dataRate = new TradeRateData();
                                    if (err.Length == 0)
                                    {
                                        taobaoResult += "淘宝系统错误,不赠送优惠券,错误代码是【" + taobaoResult + "】!";
                                    }
                                    else
                                    {
                                        taobaoResult += "淘宝系统错误,不赠送优惠券,错误代码是【" + err + "】!";
                                    }
                                    dataRate.UpdateTradeRateResult(tradeRate, taobaoResult);
                                }
                                catch { }
                                //有可能是客户订购的优惠券服务已经到期记录错误信息并中断
                                //return;
                                isSendCoupon = false;
                            }
                        }
                        else
                        {
                            isSendCoupon = false;
                        }
                    }
                }
                else
                {
                    isSendCoupon = false;
                }

                //支付宝现金券赠送
                bool isSendAlipay = true;
                //判断是否符合赠送条件
                if (CheckAlipaySend(shop, tradeRate, trade))
                {
                    //获取一条需要赠送的支付宝红包数据
                    CouponData   cou    = new CouponData();
                    AlipayDetail detail = cou.GetAlipayDetailInfoById(shop);

                    //如果符合赠送条件调用短信接口直接将红包发到客户手机上
                    string shopName = shop.MsgShopName;
                    if (shop.MsgShopName.Length == 0)
                    {
                        shopName = shop.Nick;
                    }
                    string msgAlipay = "亲," + shopName + "赠送您支付宝红包,卡号" + detail.Card + "密码" + detail.Pass + ",您可以到支付宝绑定使用。";
                    Console.Write(msgAlipay + "\r\n");
                    string msgResultAlipay = Message.Send(trade.Mobile, msgAlipay);

                    Console.Write(msgResultAlipay + "\r\n");
                    //更新支付宝红包使用状态
                    cou.InsertAlipaySendRecord(trade, shop, detail);

                    //记录短信发送记录
                    ShopData dbAlipay = new ShopData();
                    if (msgResultAlipay != "0")
                    {
                        dbAlipay.InsertShopMsgLog(shop, trade, msgAlipay, msgResultAlipay, "alipay");
                    }
                    else
                    {
                        isSendAlipay = false;
                        dbAlipay.InsertShopErrMsgLog(shop, trade, msgAlipay, msgResultAlipay, "alipay");
                    }
                    shop.MsgCount = (int.Parse(shop.MsgCount) - 1).ToString();
                }
                else
                {
                    isSendAlipay = false;
                }

                //包邮卡赠送
                bool isSendFreeCard = true;
                try
                {
                    //判断是否符合赠送条件
                    if (CheckFreeCardSend(shop, tradeRate, trade))
                    {
                        //赠送包邮卡
                        FreeCardData freeData = new FreeCardData();
                        freeData.SendFreeCard(shop, trade);

                        //判断该用户是否开启了包邮卡短信
                        if (shop.MsgIsFreecard == "1" && int.Parse(shop.MsgCount) > 0)
                        {
                            ShopData db   = new ShopData();
                            FreeCard free = freeData.GetFreeCardById(shop.FreeCardId);
                            //发送短信
                            string msg = Message.GetMsg(shop.MsgFreecardContent, shop.MsgShopName, TradeInfo.BuyNick, shop.IsCoupon, free.Name);

                            //手机号码为空不发
                            if (trade.Mobile.Length == 0)
                            {
                                return;
                            }

                            if (!db.IsSendMsgToday(trade, "freecard"))
                            {
                                string msgResult = Message.Send(trade.Mobile, msg);

                                //记录
                                if (msgResult != "0")
                                {
                                    db.InsertShopMsgLog(shop, trade, msg, msgResult, "freecard");
                                }
                                else
                                {
                                    db.InsertShopErrMsgLog(shop, trade, msg, msgResult, "freecard");
                                }
                                shop.MsgCount = (int.Parse(shop.MsgCount) - 1).ToString();
                            }
                        }
                    }
                    else
                    {
                        isSendFreeCard = false;
                    }
                }
                catch (Exception e) {
                    Console.WriteLine(e.Message + e.StackTrace + e.Source);
                }



                try
                {
                    //记录会员信息数据
                    GetUserData getUser = new GetUserData();
                    getUser.Get(trade);
                }
                catch { }

                //Console.WriteLine(isSendCoupon + "!!");
                //Console.WriteLine(isSendAlipay + "!!");
                //Console.WriteLine(trade.Mobile + "!!");

                //如果优惠券和支付宝现金都没有赠送成功,则直接中断方法不发短信
                //2012.9.17改为只有赠送成功优惠券才发送此短信
                if (!isSendCoupon)
                {
                    return;
                }

                //判断该用户是否开启了发货短信
                if (shop.MsgIsCoupon == "1" && int.Parse(shop.MsgCount) > 0)
                {
                    ShopData db = new ShopData();
                    //发送短信
                    string msg = Message.GetMsg(shop.MsgCouponContent, shop.MsgShopName, TradeInfo.BuyNick, shop.IsCoupon);
                    //string msg = Message.GetMsg(shop, trade, shop.MsgCouponContent);

                    //手机号码为空不发
                    if (trade.Mobile.Length == 0)
                    {
                        return;
                    }

                    if (!db.IsSendMsgToday(trade, "gift"))
                    {
                        ////先插入数据库 解决多优惠券赠送短信多发问题
                        //db.InsertShopMsgLog(shop, trade, msg, "888888", "gift");

                        string msgResult = Message.Send(trade.Mobile, msg);

                        //记录
                        if (msgResult != "0")
                        {
                            db.InsertShopMsgLog(shop, trade, msg, msgResult, "gift");
                        }
                        else
                        {
                            db.InsertShopErrMsgLog(shop, trade, msg, msgResult, "gift");
                        }
                        shop.MsgCount = (int.Parse(shop.MsgCount) - 1).ToString();
                    }
                }
            }
        }
Exemplo n.º 6
0
        public void Start(string index)
        {
            //获取目前正在使用的卖家(需要改成全部卖家,否则物流状态无法获取)
            ShopData        dbShop = new ShopData();
            List <ShopInfo> list   = dbShop.GetShopInfoListShippingAlert(index);

            //循环判定这些卖家的订单是否物流到货
            for (int i = 0; i < list.Count; i++)
            {
                try
                {
                    ShopInfo shop = list[i];
                    //获取那些状态是发货中且没发过短信的订单给予提示
                    TradeData    dbTrade   = new TradeData();
                    List <Trade> listTrade = dbTrade.GetShippingTrade(shop);

                    Console.Write(listTrade.Count.ToString() + "\r\n");
                    for (int j = 0; j < listTrade.Count; j++)
                    {
                        //如果是晚上10点到早上9点这个时间端内,不发送物流提醒短信
                        if (DateTime.Now.Hour > 8 && DateTime.Now.Hour < 22)
                        {
                            Trade trade = listTrade[j];

                            //判断如果是分销的订单,则不处理
                            if (trade.OrderType.ToLower() == "fenxiao")
                            {
                                continue;
                            }

                            //获取该订单的物流状态
                            TopApiHaoping api    = new TopApiHaoping(shop.Session);
                            string        status = api.GetShippingStatusByTid(listTrade[j]);

                            Console.Write(status + "\r\n");
                            //如果该物流信息不存在
                            if (status.IndexOf("不存在") != -1)
                            {
                                //如果该物流公司不支持查询则更新为self
                                dbTrade.UpdateTradeShippingStatusSelf(trade, status);
                                continue;
                            }

                            trade = api.GetOrderShippingInfo(trade);

                            if (!dbTrade.IsTaobaoCompany(trade))
                            {
                                //如果不是淘宝合作物流则直接更新
                                dbTrade.UpdateTradeShippingStatusSelf(trade, status);
                            }
                            else
                            {
                                //根据服务器的物流状态进行判断,如果物流状态是已签收
                                if (status == "ACCEPTED_BY_RECEIVER" || status == "ACCEPTING" || status == "ACCEPTED")
                                {
                                    string result = api.GetShippingStatusDetailByTid(trade);
                                    Console.Write("【" + result + "】\r\n");
                                    //如果订单不是服务器错误
                                    if (result.IndexOf("company-not-support") != -1)
                                    {
                                        //如果该物流公司不支持查询则更新为self
                                        dbTrade.UpdateTradeShippingStatusSelf(trade, status);
                                        continue;
                                    }

                                    //再根据订单的详细物流信息判断签收的状态
                                    if (result.IndexOf("签收人") != -1 || result.IndexOf(" 签收") != -1 || result.IndexOf(" 已签收") != -1 || result.IndexOf(" 妥投") != -1 || result.IndexOf("正常签收") != -1)
                                    {
                                        //如果物流已经签收了则更新对应订单状态
                                        trade.DeliveryEnd = utils.GetShippingEndTime(result);;
                                        trade.DeliveryMsg = result;

                                        //如果物流到货时间还是为空
                                        if (trade.DeliveryEnd == "")
                                        {
                                            LogData dbLog = new LogData();
                                            dbLog.InsertErrorLog(trade.Nick, "deliveryDateNull", "", result, "");
                                            continue;
                                        }

                                        //更新物流到货时间
                                        dbTrade.UpdateTradeShippingStatusSystem(trade, status);

                                        //发送短信-上LOCK锁定
                                        lock (ShippingSuccess.padlock1)
                                        {
                                            //判断同类型的短信该客户今天是否只收到一条
                                            ShopData db = new ShopData();
                                            if (!db.IsSendMsgOrder(trade, "shipping") && !db.IsSendMsgNear(trade, "shipping"))
                                            {
                                                //判断该用户是否开启了发货短信
                                                if (shop.MsgIsShipping == "1" && int.Parse(shop.MsgCount) > 0)
                                                {
                                                    //发送短信
                                                    //string msg = Message.GetMsg(shop.MsgShippingContent, shop.MsgShopName, trade.BuyNick, shop.IsCoupon);
                                                    string msg       = Message.GetMsg(shop, trade, shop.MsgShippingContent);
                                                    string msgResult = Message.Send(trade.Mobile, msg);

                                                    //记录
                                                    if (msgResult != "0")
                                                    {
                                                        db.InsertShopMsgLog(shop, trade, msg, msgResult, "shipping");
                                                    }
                                                    else
                                                    {
                                                        db.InsertShopErrMsgLog(shop, trade, msg, msgResult, "shipping");
                                                    }

                                                    shop.MsgCount = (int.Parse(shop.MsgCount) - 1).ToString();
                                                }
                                            }
                                        }
                                    }
                                }
                            }

                            //return;
                        }
                    }
                }
                catch { }
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// 处理订单生成时的相应逻辑
        /// </summary>
        public string Start()
        {
            ShopData data = new ShopData();
            ShopInfo shop = data.ShopInfoGetByNick(TradeInfo.Nick);

            if (shop.Version != "2" && shop.Version != "3")
            {
                return("1");
            }

            //通过TOP接口查询该订单的详细数据并记录到数据库中
            TopApiHaoping api = new TopApiHaoping(shop.Session);

            //处理包邮卡逻辑
            if (IsFreePost(TradeInfo, shop))
            {
                //通过API免运费
                api.FreeTradePost(TradeInfo);

                //记录免邮订单方便统计销售
            }

            //如果该客户没短信直接推出
            if (int.Parse(shop.MsgCount) <= 0)
            {
                return("1");
            }

            //判断该客户是否开启了催单短信
            if (data.IsCuiByShop(TradeInfo))
            {
                //获取小时数
                string timecount = data.GetCuiDateByShop(shop);
                //Console.WriteLine(timecount);
                //if (timecount != "0")
                //{
                //判断下单时间离现在有多久
                TimeSpan ts1     = new TimeSpan(DateTime.Now.Ticks);
                TimeSpan ts2     = new TimeSpan(DateTime.Parse(TradeInfo.Modified).Ticks);
                TimeSpan ts      = ts1.Subtract(ts2).Duration();
                string   minutes = ((int)ts.TotalMinutes).ToString();

                Console.Write(TradeInfo.Tid + "-" + minutes + "....\r\n");
                if (int.Parse(minutes) > int.Parse(timecount))
                {
                    if (int.Parse(shop.MsgCount) > 0)
                    {
                        //判断同类型的短信该客户今天是否只收到一条
                        ShopData db = new ShopData();
                        if (!db.IsSendMsgToday(TradeInfo, "cui"))
                        {
                            //特殊判断催单订单不获取物流信息
                            TradeInfo.Status = "CuiDan";
                            Trade trade = api.GetTradeByTid(TradeInfo);
                            //如果是货到交易付款则不发送催单短信并结束改消息
                            if (trade.OrderType.ToLower() == "cod")
                            {
                                return("1");
                            }

                            Console.WriteLine(trade.Status.ToUpper());
                            //如果该订单已付款则取消发送
                            if (trade.Status.ToUpper() != "WAIT_BUYER_PAY")
                            {
                                return("1");
                            }

                            //晚上12点到早上10点不发
                            if (DateTime.Now.Hour < 10)
                            {
                                return("0");
                            }

                            //发送短信
                            string msg = data.GetCuiContentByShop(shop);
                            msg = Message.GetMsg(msg, shop.MsgShopName, "", "");
                            //Console.Write(msg + "...\r\n");
                            string msgResult = Message.Send(trade.Mobile, msg);

                            //记录
                            if (msgResult != "0")
                            {
                                db.InsertShopMsgLog(shop, trade, msg, msgResult, "cui");
                            }
                            else
                            {
                                db.InsertShopErrMsgLog(shop, trade, msg, msgResult, "cui");
                            }
                            shop.MsgCount = (int.Parse(shop.MsgCount) - 1).ToString();
                        }
                    }
                }
                else
                {
                    return("0");
                }
                //}
            }

            return("1");
        }
Exemplo n.º 8
0
        /// <summary>
        /// 处理订单发货时的相应逻辑
        /// </summary>
        public void Start()
        {
            //获取店铺的基础数据
            ShopData data = new ShopData();
            ShopInfo shop = data.ShopInfoGetByNick(TradeInfo.Nick);

            if (shop.Version != "2" && shop.Version != "3")
            {
                return;
            }

            //通过TOP接口查询该订单的详细数据并记录到数据库中
            TopApiHaoping api   = new TopApiHaoping(shop.Session);
            Trade         trade = api.GetTradeByTid(TradeInfo);

            trade = api.GetOrderShippingInfo(trade);

            //发送短信-上LOCK锁定
            //判断该评价是否存在
            TradeData dbTrade = new TradeData();

            if (!dbTrade.CheckTradeExits(trade))
            {
                //更新该订单的评价时间
                dbTrade.InsertTradeInfo(trade);
            }

            try
            {
                //更新订单的优惠券使用情况
                TopApiHaoping apiCoupon = new TopApiHaoping(shop.Session);
                string        result    = apiCoupon.GetCouponTradeTotalByNick(trade);

                MatchCollection match = new Regex(@"<promotion_details list=""true""><promotion_detail><discount_fee>([^\<]*)</discount_fee><id>[0-9]*</id><promotion_desc>[^\<]*</promotion_desc><promotion_id>shopbonus-[0-9]*_[0-9]*-([0-9]*)</promotion_id><promotion_name>店铺优惠券</promotion_name></promotion_detail>", RegexOptions.IgnoreCase).Matches(result);

                if (match.Count != 0)
                {
                    string price    = match[0].Groups[1].ToString();
                    string couponid = match[0].Groups[2].ToString();

                    if (couponid.Length != 0)
                    {
                        TradeData dataTradeCoupon = new TradeData();
                        dataTradeCoupon.UpdateTradeCouponInfo(trade, price, couponid);
                    }
                }
            }
            catch { }



            lock (padlock2)
            {
                //判断如果是分销的订单,则不处理
                if (trade.OrderType.ToLower() == "fenxiao")
                {
                    return;
                }

                //判断该用户是否开启了发货短信
                if (shop.MsgIsFahuo == "1" && int.Parse(shop.MsgCount) > 0)
                {
                    //判断同类型的短信该客户今天是否只收到一条
                    ShopData db = new ShopData();
                    if (!db.IsSendMsgToday(trade, "fahuo"))
                    {
                        //发送短信
                        string msg       = Message.GetMsg(shop.MsgFahuoContent, shop.MsgShopName, TradeInfo.BuyNick, shop.IsCoupon, TradeInfo.ShippingCompanyName, TradeInfo.ShippingNumber, shop, trade);
                        string msgResult = Message.SendGuodu(trade.Mobile, msg);

                        //记录
                        if (msgResult != "0")
                        {
                            db.InsertShopMsgLog(shop, trade, msg, msgResult, "fahuo");
                        }
                        else
                        {
                            db.InsertShopErrMsgLog(shop, trade, msg, msgResult, "fahuo");
                        }
                        shop.MsgCount = (int.Parse(shop.MsgCount) - 1).ToString();
                    }
                }
            }
        }