コード例 #1
0
        public ActionResult Info(string id, string name)
        {
            Session["SourceAccountId"] = name;
            CrmMember model = null;

            ViewBag.AccountMoney    = 0;
            ViewBag.Score           = 0;
            ViewBag.PresentMoney    = 0;
            ViewBag.CompanyId       = id;
            ViewBag.SourceAccountId = name;

            try
            {
                CrmMemberModel      cmModel  = new CrmMemberModel();
                CrmMemberScoreModel cmsModel = new CrmMemberScoreModel();

                if (!string.IsNullOrEmpty(name))
                {
                    model = cmModel.getCrmMemberListInfoData(name).FirstOrDefault();

                    var prepayAccount = cmModel.GetPrepayAccount(model.Uid);
                    var memberScore   = cmsModel.SelCrmMemberScoreInfo(model.Uid).FirstOrDefault();

                    if (prepayAccount != null)
                    {
                        ViewBag.AccountMoney = prepayAccount.AccountMoney;
                        ViewBag.PresentMoney = prepayAccount.PresentMoney;
                    }
                    if (memberScore != null)
                    {
                        ViewBag.Score = memberScore.Score;
                    }
                }
            }
            catch
            {
            }
            finally
            {
            }

            return(View(model));
        }
コード例 #2
0
ファイル: BuyerOldDAL.cs プロジェクト: fubendong/--CTCRM
        public static bool Add(CrmMember o, string sellerID, string groupNo)
        {
            try
            {
                string query = @"insert into Buyer(buyer_id,SELLER_ID,buyer_nick,avg_price,status,close_trade_count,close_trade_amount,
item_close_count,last_trade_time,item_num,trade_amount,grade,province,city,trade_count,createDate,groupNo,buyerType)
   values(@buyer_id,@SELLER_ID,@buyer_nick,@avg_price,@status,@close_trade_count,@close_trade_amount,
@item_close_count,@last_trade_time,@item_num,@trade_amount,@grade,@province,@city,@trade_count,@createDate,@groupNo,@buyerType)";

                SqlParameter[] param = new SqlParameter[]
                {
                    new SqlParameter("@buyer_id", o.BuyerId),
                    new SqlParameter("@SELLER_ID", sellerID),
                    new SqlParameter("@buyer_nick", o.BuyerNick),
                    new SqlParameter("@avg_price", string.IsNullOrEmpty(o.AvgPrice)?"0":o.AvgPrice),
                    new SqlParameter("@status", string.IsNullOrEmpty(o.Status)?"":o.Status),
                    new SqlParameter("@close_trade_count", o.CloseTradeCount),
                    new SqlParameter("@close_trade_amount", string.IsNullOrEmpty(o.CloseTradeAmount)?"0":o.CloseTradeAmount),
                    new SqlParameter("@item_close_count", o.ItemCloseCount),
                    new SqlParameter("@last_trade_time", string.IsNullOrEmpty(o.LastTradeTime)?"":o.LastTradeTime),
                    new SqlParameter("@item_num", o.ItemNum),
                    new SqlParameter("@trade_amount", string.IsNullOrEmpty(o.TradeAmount)?"0":o.TradeAmount),
                    new SqlParameter("@grade", o.Grade),
                    new SqlParameter("@province", o.Province),
                    new SqlParameter("@city", o.City == null?"":o.City),
                    new SqlParameter("@trade_count", o.TradeCount),
                    new SqlParameter("@createDate", DateTime.Now),
                    new SqlParameter("@groupNo", int.Parse(groupNo)),
                    new SqlParameter("@buyerType", "0")//0表示自己店铺的会员
                };
                DataBase.ExecuteSql(query, param);
                return(true);
            }
            catch (Exception ex)
            {
                ExceptionReporter.WriteLog(ex, ExceptionPostion.TBApply_Data);
                return(false);
            }
        }
コード例 #3
0
        public static bool UpdateBuyerInfo(CrmMember o, string sellerNick, string groupNo, string Seller_Id)
        {
            try
            {
                string query = @"update Buyer_" + Seller_Id + @" set avg_price = @avg_price,status = @status,close_trade_count = @close_trade_count,
                                close_trade_amount = @close_trade_amount,item_close_count = @item_close_count,last_trade_time = @last_trade_time,
                                item_num = @item_num,trade_amount = @trade_amount,grade = @grade,trade_count = @trade_count,updateDate = getdate(),
                                groupNo = @groupNo
                                WHERE buyer_id = @buyer_id and SELLER_ID = @SELLER_ID";

                SqlParameter[] param = new SqlParameter[]
                {
                    new SqlParameter("@buyer_id", o.BuyerId),
                    new SqlParameter("@avg_price", string.IsNullOrEmpty(o.AvgPrice)?"0":o.AvgPrice),
                    new SqlParameter("@status", string.IsNullOrEmpty(o.Status)?"":o.Status),
                    new SqlParameter("@close_trade_count", o.CloseTradeCount),
                    new SqlParameter("@close_trade_amount", string.IsNullOrEmpty(o.CloseTradeAmount)?"0":o.CloseTradeAmount),
                    new SqlParameter("@item_close_count", o.ItemCloseCount),
                    new SqlParameter("@last_trade_time", string.IsNullOrEmpty(o.LastTradeTime)?"":o.LastTradeTime),
                    new SqlParameter("@item_num", o.ItemNum),
                    new SqlParameter("@trade_amount", string.IsNullOrEmpty(o.TradeAmount)?"0":o.TradeAmount),
                    new SqlParameter("@grade", o.Grade),
                    new SqlParameter("@trade_count", o.TradeCount),
                    new SqlParameter("@groupNo", groupNo),
                    new SqlParameter("@SELLER_ID", sellerNick)
                };
                DataBase.ExecuteSql(query, param);

                return(true);
            }
            catch (Exception ex)
            {
                ExceptionManager exceptionManager = new ExceptionManager();
                exceptionManager.WriteFileLog("查询中差评错误", ex.Message, ex.Message);
                ExceptionReporter.WriteLog(ex, ExceptionPostion.TBApply_Data);
                return(false);
            }
        }
コード例 #4
0
 /// <summary>
 /// 同步买家的分组
 /// </summary>
 /// <param name="o"></param>
 /// <returns></returns>
 public static string UpdateGroup(CrmMember o)
 {
     //新客户
     if (o.TradeCount == 1)
     {
         return("1");
     }
     //老客户
     if (o.TradeCount > 1)
     {
         return("2");
     }
     //潜在客户
     if (o.TradeCount == 0)
     {
         return("0");
     }
     //休眠3个月
     if (Convert.ToDateTime(o.LastTradeTime) < DateTime.Now.AddMonths(-3))
     {
         return("3");
     }
     return("0");
 }
コード例 #5
0
        public bool SaveMember(string wxOpenid, string companyid)
        {
            bool resukt = false;

            using (TransactionScope transaction = new TransactionScope())
            {
                var user = getCrmMemberListInfoData(wxOpenid);
                if (user == null || (user != null && user.Count == 0))
                {
                    CrmMember member = new CrmMember();
                    member.MemberSource    = "01";
                    member.SourceAccountId = wxOpenid;
                    member.TypeId          = 1;
                    member.UseState        = "01";
                    member.RegDate         = DateTime.Now;
                    member.CompanyId       = new Guid(companyid);

                    var v = GetNewUserId();
                    member.Uid = v.ToString();

                    #region Add new user
                    DbCommand cmd = null;
                    string    sql;
                    sql = "insert into CrmMember([Uid],MemberSource,SourceAccountId,TypeId,UseState,RegDate,CompanyId) " +
                          "values(@Uid,@MemberSource,@SourceAccountId,@TypeId,@UseState,@RegDate,@CompanyId)";
                    cmd = db.GetSqlStringCommand(sql);
                    db.AddInParameter(cmd, "Uid", DbType.String, member.Uid);
                    db.AddInParameter(cmd, "MemberSource", DbType.String, member.MemberSource);
                    db.AddInParameter(cmd, "SourceAccountId", DbType.String, member.SourceAccountId);
                    db.AddInParameter(cmd, "TypeId", DbType.Int32, member.TypeId);
                    db.AddInParameter(cmd, "UseState", DbType.String, member.UseState);
                    db.AddInParameter(cmd, "RegDate", DbType.DateTime, member.RegDate);
                    db.AddInParameter(cmd, "CompanyId", DbType.Guid, member.CompanyId);

                    ExecSql(cmd);

                    #endregion

                    #region Add PrepayAccount

                    PrepayAccount acc = new PrepayAccount();
                    acc.uid              = member.Uid;
                    acc.AccountMoney     = 0;
                    acc.TotalMoney       = 0;
                    acc.PresentMoney     = 0;
                    acc.TotalPresent     = 0;
                    acc.LastConsumeMoney = 0;
                    acc.LastPresentMoney = 0;

                    cmd = null;
                    sql = "insert into PrepayAccount([Uid],AccountMoney,TotalMoney,PresentMoney,TotalPresent,LastConsumeMoney,LastPresentMoney) " +
                          "values(@Uid,@AccountMoney,@TotalMoney,@PresentMoney,@TotalPresent,@LastConsumeMoney,@LastPresentMoney)";
                    cmd = db.GetSqlStringCommand(sql);
                    db.AddInParameter(cmd, "Uid", DbType.String, acc.uid);
                    db.AddInParameter(cmd, "AccountMoney", DbType.Decimal, acc.AccountMoney);
                    db.AddInParameter(cmd, "TotalMoney", DbType.Decimal, acc.TotalMoney);
                    db.AddInParameter(cmd, "PresentMoney", DbType.Decimal, acc.PresentMoney);
                    db.AddInParameter(cmd, "TotalPresent", DbType.Decimal, acc.TotalPresent);
                    db.AddInParameter(cmd, "LastConsumeMoney", DbType.Decimal, acc.LastConsumeMoney);
                    db.AddInParameter(cmd, "LastPresentMoney", DbType.Decimal, acc.LastPresentMoney);

                    ExecSql(cmd);

                    #endregion

                    #region Add CrmMemberScore

                    CrmMemberScore scroe = new CrmMemberScore()
                    {
                        LastScore      = 0,
                        LastScoredDate = DateTime.Now,
                        Score          = 0,
                        TotalScore     = 0,
                        Uid            = member.Uid,
                        UseMoney       = 0,
                        UseScore       = 0
                    };
                    cmd = null;
                    sql = "insert into CrmMemberScore([Uid],LastScoredDate,Score,LastScore,UseMoney,UseScore) " +
                          "values(@Uid,@LastScoredDate,@Score,@LastScore,@UseMoney,@UseScore)";
                    cmd = db.GetSqlStringCommand(sql);
                    db.AddInParameter(cmd, "Uid", DbType.String, scroe.Uid);
                    db.AddInParameter(cmd, "LastScoredDate", DbType.DateTime, scroe.LastScoredDate);
                    db.AddInParameter(cmd, "Score", DbType.Int32, scroe.Score);
                    db.AddInParameter(cmd, "LastScore", DbType.Int32, scroe.LastScore);
                    db.AddInParameter(cmd, "UseMoney", DbType.Int32, scroe.UseMoney);
                    db.AddInParameter(cmd, "UseScore", DbType.Int32, scroe.UseScore);

                    ExecSql(cmd);

                    #endregion
                }
                else
                {
                    #region Set user to New
                    DbCommand cmd = null;
                    string    sql;
                    sql = "update CrmMember set UseState='01' where SourceAccountId=@SourceAccountId";
                    cmd = db.GetSqlStringCommand(sql);
                    db.AddInParameter(cmd, "SourceAccountId", DbType.String, wxOpenid);

                    ExecSql(cmd);

                    #endregion
                }
                transaction.Complete();
                resukt = true;
            }
            return(resukt);
        }