public int funTraderUserRating(string sellerNick, string sesionKey) { try { //查询卖家对应的评价策略 DataTable tbSellerRateConfig = AutoMsgDB.GetSellerWhichSetAtuoRate(sellerNick); DateTime startDate = DateTime.Now.AddMonths(-1); DateTime endDate = DateTime.Now; DataTable tbRateData = AutoMsgDB.GetRateTradeData(sellerNick, tbSellerRateConfig.Rows[0], startDate, endDate, sesionKey); if (tbRateData != null && tbRateData.Rows.Count > 0) { RateConfig objRate = null; foreach (DataRow rw in tbRateData.Rows) { #region 开始评价 try { objRate = new RateConfig(); string tid = rw["tid"].ToString(); objRate.Tid = Convert.ToInt64(tid); objRate.Oid = Convert.ToInt64(rw["oid"].ToString()); string badRattingContent = tbSellerRateConfig.Rows[0]["badRateContent"].ToString(); if (rw["blackBuyerRatedIsRate"].Equals("1"))//不自动评价 { continue; } else if (rw["blackBuyerRatedIsRate"].Equals("3")) { objRate.Content1 = badRattingContent; objRate.Content2 = badRattingContent; objRate.Content3 = badRattingContent; objRate.Result = "neutral"; } else if (rw["blackBuyerRatedIsRate"].Equals("4")) { objRate.Content1 = badRattingContent; objRate.Content2 = badRattingContent; objRate.Content3 = badRattingContent; objRate.Result = "bad"; } else { objRate.Content1 = tbSellerRateConfig.Rows[0]["content1"].ToString(); objRate.Content2 = tbSellerRateConfig.Rows[0]["content2"].ToString(); objRate.Content3 = tbSellerRateConfig.Rows[0]["content3"].ToString(); objRate.Result = "good"; } objRate.SellerNick = sellerNick; string strContent = ""; TBRating objRateDal = new TBRating(); //新增单个评价,if faild, then list rate TradeRate obj = null; obj = objRateDal.BuyerTradeRateOneByOne(objRate, ref strContent, sesionKey); if (obj == null) { obj = objRateDal.BuyerTradeRate(objRate, ref strContent, sesionKey); } if (obj != null) { //rating sucessfull obj.Content = strContent; obj.Nick = objRate.SellerNick; obj.Tid = Convert.ToInt64(rw["tid"]); obj.Created = obj.Created; //Console.WriteLine("评价卖家:" + obj.Nick + " 评价日期:" + obj.Created); AutoMsgDB.AddRateHisWithSeller(obj); } } catch (Exception ex) { ExceptionReporter.WriteLog(ex, ExceptionPostion.TBApply_Data); continue; } #endregion } } } catch (Exception ex) { ExceptionReporter.WriteLog(ex, ExceptionPostion.TBApply_Data); } return(0); }
private void SendMessageDoTimer_Elapsed(object sender, ElapsedEventArgs e) { try { sendMessageDoTimer.Enabled = true; //查询同步过来的消息MESSAGE //查询主动通知信息从DB开始用于发送短信:只取交易完成的数据用于秒评 DataTable tbTrade = DBUtil.GetTradeData(""); //如果该卖家有消息推送 if (!busySend && tbTrade != null && tbTrade.Rows.Count > 0) { busySend = true; foreach (DataRow row in tbTrade.Rows)//轮训通知消息 { string sellerNick = row["seller_nick"].ToString(); string buyerNick = row["buyer_nick"].ToString(); string tid = row["tid"].ToString(); DateTime createDate = Convert.ToDateTime(row["createDate"]); // 获取卖家保存的自动评价策略 DataTable dtAutoConfig = DBUtil.GetSellerAutoRateConfig(sellerNick); int isMiaoRate = 0; int isWaitBuyerRate = 0; int isQiangRate = 0; if (dtAutoConfig == null || dtAutoConfig.Rows.Count == 0) { continue; } isMiaoRate = Convert.ToInt32(dtAutoConfig.Rows[0]["isMiaoRate"]); isWaitBuyerRate = Convert.ToInt32(dtAutoConfig.Rows[0]["isWaitBuyerRate"]); isQiangRate = Convert.ToInt32(dtAutoConfig.Rows[0]["isQiangRate"]); //判断卖家是否开通秒评 if (isMiaoRate == 1) { #region 秒评 //评价开始 string sessionKey = DBUtil.GetSellerSessionKey(sellerNick); if (!string.IsNullOrEmpty(sessionKey)) { // 获取卖家保存的评价策略 DataTable tbSellerRateConfig = DBUtil.GetSellerRateConfig(sellerNick); //检查商家设置:秒评:只检查该用户是否在黑名单 if (!DBUtil.CheckIsBlacklst(sellerNick, buyerNick)) { Trade objTrade = TBTrade.GetBuyerTrade(tid, sessionKey); if (objTrade != null && objTrade.Orders.Count > 0) { foreach (Order o in objTrade.Orders) { if (!o.SellerRate) { RateConfig objRate = new RateConfig(); objRate.Tid = Convert.ToInt64(tid); objRate.Oid = o.Oid; objRate.Content1 = tbSellerRateConfig.Rows[0]["content1"].ToString(); objRate.Content2 = tbSellerRateConfig.Rows[0]["content2"].ToString(); objRate.Content3 = tbSellerRateConfig.Rows[0]["content3"].ToString(); objRate.Result = tbSellerRateConfig.Rows[0]["result"].ToString(); objRate.SellerNick = sellerNick; string strContent = ""; TBRating objRateDal = new TBRating(); TradeRate obj = null; //调用接口 新增单个评价 obj = objRateDal.BuyerTradeRateOneByOne(objRate, ref strContent, sessionKey); if (obj == null) { // 调用API进行批量评价 obj = objRateDal.BuyerTradeRate(objRate, ref strContent, sessionKey); } if (obj != null) { //rating sucessfull obj.Content = strContent; obj.Nick = objRate.SellerNick; obj.Tid = Convert.ToInt64(tid); obj.Created = obj.Created; // 添加卖家评价:秒评 //Console.WriteLine("评价卖家:" + obj.Nick + " 评价日期:" + obj.Created); DBUtil.AddRateHisWithSeller(obj, "秒评"); Console.WriteLine("当前卖家:" + sellerNick + "评价时间:" + DateTime.Now.ToString()); } } } } } } #endregion } //判断卖家是否开通买家评价以后评价 if (isWaitBuyerRate == 1) { #region 方案二(买家评价以后评价) string sessionKey = DBUtil.GetSellerSessionKey(sellerNick); RateConfig objRate = new RateConfig(); TBRating objRateDal = new TBRating(); objRate.Content1 = dtAutoConfig.Rows[0]["content1"].ToString(); objRate.Content2 = dtAutoConfig.Rows[0]["content2"].ToString(); objRate.Content3 = dtAutoConfig.Rows[0]["content3"].ToString(); objRate.SellerNick = sellerNick; //默认好评 objRate.Result = dtAutoConfig.Rows[0]["result"].ToString(); //检查买家是否评论 List <TradeRate> sates = objRateDal.GetTradeRate(sessionKey); bool isRated = false; foreach (TradeRate trade in sates) { if (trade.Tid.ToString() == tid) { isRated = true; break; } } if (isRated) //买家已评价 { //买家在黑名单 if (DBUtil.CheckIsBlacklst(sellerNick, buyerNick)) { int blackBuyerRatedIsRate = Convert.ToInt32(dtAutoConfig.Rows[0]["blackBuyerRatedIsRate"]); if (blackBuyerRatedIsRate == 1) { continue; } if (blackBuyerRatedIsRate == 3) { objRate.Result = "neutral"; objRate.BadRateContent = dtAutoConfig.Rows[0]["badRateContent"].ToString(); objRate.Content1 = dtAutoConfig.Rows[0]["badRateContent"].ToString(); objRate.Content2 = dtAutoConfig.Rows[0]["badRateContent"].ToString(); objRate.Content3 = dtAutoConfig.Rows[0]["badRateContent"].ToString(); } if (blackBuyerRatedIsRate == 4) { objRate.Result = "bad"; objRate.BadRateContent = dtAutoConfig.Rows[0]["badRateContent"].ToString(); objRate.Content1 = dtAutoConfig.Rows[0]["badRateContent"].ToString(); objRate.Content2 = dtAutoConfig.Rows[0]["badRateContent"].ToString(); objRate.Content3 = dtAutoConfig.Rows[0]["badRateContent"].ToString(); } } } else //买家未评价 { //买家在黑名单 if (DBUtil.CheckIsBlacklst(sellerNick, buyerNick)) { //检查是否到评论时间 TimeSpan ts = DateTime.Now - createDate; int jiange = (ts.Days * 24 * 60 * 60) + (ts.Hours * 60 * 60) + (ts.Minutes * 60) + (ts.Minutes); int congigJiange = (Convert.ToInt32(dtAutoConfig.Rows[0]["blackBuyerNoRateQiangRateDay"]) * 24 * 60 * 60) + (Convert.ToInt32(dtAutoConfig.Rows[0]["blackBuyerNoRateQiangRateHour"]) * 60 * 60) + (Convert.ToInt32(dtAutoConfig.Rows[0]["blackBuyerNoRateQiangRateFen"]) * 60); if (congigJiange < jiange) { continue; } } else //买家不在黑名单 { //检查是否到评论时间 TimeSpan ts = DateTime.Now - createDate; int jiange = (ts.Days * 24 * 60 * 60) + (ts.Hours * 60 * 60) + (ts.Minutes * 60) + (ts.Minutes); int congigJiange = (Convert.ToInt32(dtAutoConfig.Rows[0]["waitBuyerTimeDay"]) * 24 * 60 * 60) + (Convert.ToInt32(dtAutoConfig.Rows[0]["waitBuyerTimeHour"]) * 60 * 60) + (Convert.ToInt32(dtAutoConfig.Rows[0]["waitBuyerTimeFen"]) * 60); if (congigJiange < jiange) { continue; } } } //评价开始 if (!string.IsNullOrEmpty(sessionKey)) { // 获取卖家保存的评价策略 //DataTable tbSellerRateConfig = DBUtil.GetSellerRateConfig(sellerNick); Trade objTrade = TBTrade.GetBuyerTrade(tid, sessionKey); if (objTrade != null && objTrade.Orders.Count > 0) { foreach (Order o in objTrade.Orders) { if (!o.SellerRate) { objRate.Tid = Convert.ToInt64(tid); objRate.Oid = o.Oid; string strContent = ""; TradeRate obj = null; //调用接口 新增单个评价 obj = objRateDal.BuyerTradeRateOneByOne(objRate, ref strContent, sessionKey); if (obj == null) { // 调用API进行批量评价 obj = objRateDal.BuyerTradeRate(objRate, ref strContent, sessionKey); } if (obj != null) { //rating sucessfull obj.Content = strContent; obj.Nick = objRate.SellerNick; obj.Tid = Convert.ToInt64(tid); obj.Created = obj.Created; // 添加卖家评价 //Console.WriteLine("评价卖家:" + obj.Nick + " 评价日期:" + obj.Created); DBUtil.AddRateHisWithSeller(obj, "方案二"); Console.WriteLine("当前卖家:" + sellerNick + "评价时间:" + DateTime.Now.ToString()); } } } } } #endregion } //判断卖家是否开通交易后多长时间评价 if (isQiangRate == 1) { #region 方案三(交易后多长时间评价) //检查是否到评论时间 TimeSpan ts = DateTime.Now - createDate; //当前时间到提单的时间间隔 int jiange = (ts.Days * 24 * 60 * 60) + (ts.Hours * 60 * 60) + (ts.Minutes * 60) + (ts.Minutes); //评价配置的时间间隔 int congigJiange = (Convert.ToInt32(dtAutoConfig.Rows[0]["qiangRateTimeDay"]) * 24 * 60 * 60) + (Convert.ToInt32(dtAutoConfig.Rows[0]["qiangRateTimeHour"]) * 60 * 60) + (Convert.ToInt32(dtAutoConfig.Rows[0]["qiangRateTimeFen"]) * 60); if (congigJiange < jiange) { continue; } //评价开始 string sessionKey = DBUtil.GetSellerSessionKey(sellerNick); if (!string.IsNullOrEmpty(sessionKey)) { //检查商家设置:秒评:只检查该用户是否在黑名单 if (!DBUtil.CheckIsBlacklst(sellerNick, buyerNick)) { Trade objTrade = TBTrade.GetBuyerTrade(tid, sessionKey); if (objTrade != null && objTrade.Orders.Count > 0) { foreach (Order o in objTrade.Orders) { if (!o.SellerRate) { RateConfig objRate = new RateConfig(); objRate.Tid = Convert.ToInt64(tid); objRate.Oid = o.Oid; objRate.Content1 = dtAutoConfig.Rows[0]["content1"].ToString(); objRate.Content2 = dtAutoConfig.Rows[0]["content2"].ToString(); objRate.Content3 = dtAutoConfig.Rows[0]["content3"].ToString(); objRate.Result = dtAutoConfig.Rows[0]["result"].ToString(); objRate.SellerNick = sellerNick; string strContent = ""; TBRating objRateDal = new TBRating(); TradeRate obj = null; //调用接口 新增单个评价 obj = objRateDal.BuyerTradeRateOneByOne(objRate, ref strContent, sessionKey); if (obj == null) { // 调用API进行批量评价 obj = objRateDal.BuyerTradeRate(objRate, ref strContent, sessionKey); } if (obj != null) { //rating sucessfull obj.Content = strContent; obj.Nick = objRate.SellerNick; obj.Tid = Convert.ToInt64(tid); obj.Created = obj.Created; // 添加卖家评价:秒评 //Console.WriteLine("评价卖家:" + obj.Nick + " 评价日期:" + obj.Created); DBUtil.AddRateHisWithSeller(obj, "方案三"); Console.WriteLine("当前卖家:" + sellerNick + "评价时间:" + DateTime.Now.ToString()); } } } } } } #endregion } //自动删除数据 DBUtil.DeleteValidTradeForMiaoRate(tid); } busySend = false; } } catch (Exception ex) { ExceptionReporter.WriteLog(ex, ExceptionPostion.TBApply_Data); } finally { sendMessageDoTimer.Enabled = true; } }