Example #1
0
        /// <summary>
        /// 添加物流信息到数据库
        /// </summary>
        /// <param name="logstic"></param>
        /// <returns></returns>
        public static bool AddLogistics(LogsticDetailTrace logstic)
        {
            try
            {
                string query = @"insert into tab_logistics(tid,action,company_name,out_sid,action_desc,time)
                        values(@tid,@action,@company_name,@out_sid,@desc,@time)";

                SqlParameter[] param = new SqlParameter[]
                {
                    new SqlParameter("@tid", logstic.Tid),
                    new SqlParameter("@action", logstic.Action),
                    new SqlParameter("@company_name", logstic.Company_name),
                    new SqlParameter("@out_sid", logstic.Out_side),
                    new SqlParameter("@desc", logstic.Desc),
                    new SqlParameter("@time", logstic.Time),
                };
                DataBase.ExecuteSql(query, param);
                return(true);
            }
            catch (Exception ex)
            {
                //ExceptionReporter.WriteLog(ex, ExceptionPostion.TBApply_Data);
                return(false);
            }
        }
Example #2
0
        /// <summary>
        /// 更新物流信息
        /// </summary>
        /// <param name="logstic"></param>
        /// <returns></returns>
        public static bool updateLogistics(LogsticDetailTrace logstic)
        {
            try
            {
                string query = @"update tab_logistics set action=@action,action_desc=@desc,time=@time where tid=@tid";

                SqlParameter[] param = new SqlParameter[]
                {
                    new SqlParameter("@tid", logstic.Tid),
                    new SqlParameter("@action", logstic.Action),
                    new SqlParameter("@desc", logstic.Desc),
                    new SqlParameter("@time", logstic.Time),
                };
                DataBase.ExecuteSql(query, param);
                return(true);
            }
            catch (Exception ex)
            {
                //ExceptionReporter.WriteLog(ex, ExceptionPostion.TBApply_Data);
                return(false);
            }
        }
Example #3
0
 /// <summary>
 /// 更新物流信息
 /// </summary>
 /// <param name="logstic"></param>
 /// <returns></returns>
 public static bool updateLogistics(LogsticDetailTrace logstic)
 {
     return(CTCRM.DAL.LogisticsDAL.updateLogistics(logstic));
 }
Example #4
0
 /// <summary>
 /// 添加物流信息到数据库
 /// </summary>
 /// <param name="logstic"></param>
 /// <returns></returns>
 public static bool AddLogistics(LogsticDetailTrace logstic)
 {
     return(CTCRM.DAL.LogisticsDAL.AddLogistics(logstic));
 }
Example #5
0
        public static void Main(string[] args)
        {
            TmcClient client = new TmcClient(appKey, appSecret, "default");

            client.OnMessage += (s, e) =>
            {
                try
                {
                    string status = e.Message.Topic;
                    //将消息进行转换
                    IDictionary obj = TopUtils.ParseJson(e.Message.Content);

                    if (obj != null)
                    {
                        #region //物流信息的处理20160916 yao
                        try
                        {
                            if (obj.Contains("action"))
                            {
                                Console.WriteLine(DateTime.Now.ToString() + ":物流提醒:" + e.Message.Content);
                                LogsticDetailTrace logstic = new LogsticDetailTrace();

                                logstic.Tid  = obj["tid"].ToString();
                                logstic.Desc = obj["desc"].ToString();
                                if (obj.Contains("out_sid"))
                                {
                                    logstic.Out_side = obj["out_sid"].ToString();
                                }
                                logstic.Time = obj["time"].ToString();
                                if (obj.Contains("company_name"))
                                {
                                    logstic.Company_name = obj["company_name"].ToString();
                                }
                                logstic.Action = obj["action"].ToString();
                                if (LogisticsBLL.TidIsExist(logstic.Tid))
                                {
                                    LogisticsBLL.updateLogistics(logstic);
                                }
                                else
                                {
                                    LogisticsBLL.AddLogistics(logstic);
                                }
                            }
                            else
                            {
                                NotifyTrade trade = null;
                                Console.WriteLine(DateTime.Now.ToString() + ":店铺管家订单:" + e.Message.Content);
                                trade            = new NotifyTrade();
                                trade.Tid        = obj["tid"].ToString();
                                trade.BuyerNick  = obj["buyer_nick"].ToString();
                                trade.Status     = status;
                                trade.SellerNick = obj["seller_nick"].ToString();
                                trade.Oid        = obj["oid"].ToString();
                                trade.Payment    = obj["payment"].ToString();
                                if (!DBUtil.CheckNoteTradeIsExit(trade.Tid.ToString()))
                                {
                                    DBUtil.AddNoteTradeToDB(trade);                //物流提醒之用
                                    if (status.Equals("taobao_trade_TradeCreate")) //订单拦截之用
                                    {
                                        DBUtil.AddTradeOrderDenfense(trade);
                                    }
                                }
                                else
                                {
                                    DBUtil.UpdateNoteTradeToDB(trade);
                                }
                            }
                        }
                        catch (Exception e1)
                        {
                            Console.WriteLine(e1.ToString());
                        }
                        #endregion
                    }
                    // 默认不抛出异常则认为消息处理成功
                }
                catch (Exception exp)
                {
                    ExceptionReporter.WriteLog(exp, ExceptionPostion.TBApply_Data);
                    e.Fail(); // 消息处理失败回滚,服务端需要重发
                }
            };
            client.Connect("ws://mc.api.taobao.com/");
            Console.ReadLine();
        }