Пример #1
0
 public object Post(long timestamp, string sign, [FromBody] UserScheme userRes)
 {
     if (ExternalResponse.signEncode(timestamp, sign))
     {
         return(ExternalResponse.ErrRequest(501, "sign的值错误"));
     }
     using (var db = new SunnyTeachEntities())
     {
         try
         {
             List <long> userids = new List <long>();
             foreach (userparm up in userRes.users)
             {
                 userids.Add(up.userid);
             }
             List <Tb_UserScheme> lUserScheme = db.Tb_UserScheme.Where(w => userids.Contains(w.UserID)).ToList();
             foreach (var item in lUserScheme)
             {
                 item.OptType = 1;
             }
             if (db.SaveChanges() != 0)
             {
                 return(ExternalResponse.ExRequest3());
             }
             else
             {
                 return(ExternalResponse.ErrRequest(504, "删除用户失败!"));
             }
         }
         catch (Exception e)
         {
             return(ExternalResponse.ErrRequest(500, "服务器错误:" + e.Message));
         }
     }
 }
Пример #2
0
 public object Post(long timestamp, string sign, [FromBody] UserScheme userRes)
 {
     if (ExternalResponse.signEncode(timestamp, sign))
     {
         return(ExternalResponse.ErrRequest(501, "sign的值错误"));
     }
     using (var db = new SunnyTeachEntities())
     {
         Tb_Order tb_Order = db.Tb_Order.First(f => f.ID == userRes.ecordercode);
         if (tb_Order == null)
         {
             return(ExternalResponse.ErrRequest(504, "未查询到相应订单!订单号:" + userRes.ecordercode));
         }
         try
         {
             Tb_UserScheme tb_UserScheme;
             foreach (userparm up in userRes.users)
             {
                 tb_UserScheme = db.Tb_UserScheme.Find(up.userid);
                 if (tb_UserScheme != null)
                 {
                     tb_UserScheme.OptType = up.opttype;
                 }
                 else
                 {
                     tb_UserScheme             = new Tb_UserScheme();
                     tb_UserScheme.UserID      = up.userid;
                     tb_UserScheme.ID          = userRes.ecordercode;
                     tb_UserScheme.UserName    = up.username;
                     tb_UserScheme.Useralias   = up.useralias;
                     tb_UserScheme.Mobile      = up.mobile;
                     tb_UserScheme.Email       = up.email;
                     tb_UserScheme.BeginTime   = up.begintime;
                     tb_UserScheme.EndTime     = up.endtime;
                     tb_UserScheme.ApplyNo     = userRes.ecordercode;
                     tb_UserScheme.EcorderCode = userRes.applyno;
                     tb_UserScheme.CustID      = userRes.custid;
                     tb_UserScheme.ProductCode = userRes.productcode;
                     tb_UserScheme.OptType     = up.opttype;
                     tb_UserScheme.IsDelete    = 0;
                     tb_UserScheme.Paras       = JsonHelper.JsonSerializer(up.paras);
                     tb_UserScheme.UserType    = 0;// Convert.ToInt32(up.paras[0].value);
                     db.Tb_UserScheme.Add(tb_UserScheme);
                 }
             }
             if (db.SaveChanges() == 0)
             {
                 return(ExternalResponse.ErrRequest(504, "添加用户或更新失败!"));
             }
             else
             {
                 return(ExternalResponse.ExRequest3());
             }
         }
         catch (Exception e)
         {
             return(ExternalResponse.ErrRequest(500, "服务器错误:" + e.Message));
         }
     }
 }
Пример #3
0
        public object Post(long timestamp, string sign, [FromBody] BusRes busRes)
        {
            if (ExternalResponse.signEncode(timestamp, sign))
            {
                return(ExternalResponse.ErrRequest(501, "sign的值错误"));
            }
            using (var db = new SunnyTeachEntities())
            {
                try
                {
                    Tb_Order Order = db.Tb_Order.Find(busRes.applyno);
                    if (Order != null)
                    {
                        switch (busRes.opttype)
                        {
                        case 0:    //退订
                        case 1:    //暂停
                            Order.OptType = 1;
                            List <Tb_UserScheme> lTb_UserScheme = db.Tb_UserScheme.Where(w => w.ID == busRes.ecordercode).ToList();
                            foreach (Tb_UserScheme tu in lTb_UserScheme)
                            {
                                tu.OptType = 1;
                            }
                            break;

                        case 2:    //恢复
                            Order.OptType = 0;
                            List <Tb_UserScheme> lTb_UserScheme2 = db.Tb_UserScheme.Where(w => w.ID == busRes.ecordercode).ToList();
                            foreach (Tb_UserScheme tu in lTb_UserScheme2)
                            {
                                tu.OptType = 0;
                            }
                            break;

                        default:
                            break;
                        }
                        if (db.SaveChanges() != 0)
                        {
                            return(ExternalResponse.ExRequest());
                        }
                        else
                        {
                            return(ExternalResponse.ErrRequest(500, "服务器错误"));
                        }
                    }
                    else
                    {
                        return(ExternalResponse.ErrRequest(504, "订单不存在"));
                    }
                }
                catch (Exception e)
                {
                    return(ExternalResponse.ErrRequest(500, "服务器错误:" + e.Message));
                }
            }
        }
Пример #4
0
 public object Post([FromBody] BusRes busRes, long timestamp, string sign)
 {
     if (ExternalResponse.signEncode(timestamp, sign))
     {
         return(ExternalResponse.ErrRequest(501, "sign的值错误"));
     }
     using (var db = new SunnyTeachEntities())
     {
         try
         {
             Tb_Order Order = db.Tb_Order.Find(busRes.applyno);
             if (Order != null)
             {
                 return(ExternalResponse.ErrRequest(504, "订单已存在"));
             }
             else
             {
                 Tb_Order tb_Order = new Tb_Order();
                 tb_Order.ID             = busRes.ecordercode;
                 tb_Order.SchoolName     = "移动云"; //待定
                 tb_Order.SchoollID      = 0;     //待定
                 tb_Order.AdminAccount   = busRes.username;
                 tb_Order.Phone          = busRes.mobile;
                 tb_Order.SchemeID       = 0;                                                         //待定 标准版 升级版
                 tb_Order.SchemeName     = "标准版";                                                     //待定 标准版 升级版
                 tb_Order.OrderMon       = Convert.ToInt32(busRes.services[0].serviceparas[0].value); //待定 月数
                 tb_Order.SchemeNum      = Convert.ToInt32(busRes.services[0].serviceparas[1].value); //待定 人数
                 tb_Order.AccessNum      = 0;                                                         //待定 已授权人数
                 tb_Order.SchemeMoney    = 0;                                                         //待定 实收金额
                 tb_Order.OptType        = busRes.services[0].opttype;
                 tb_Order.SchemeStateNm  = "已付款";                                                     //dd
                 tb_Order.SchemeTypeID   = 0;                                                         //dd
                 tb_Order.SchemeTypeName = "新订单";                                                     //dd
                 tb_Order.SchemeNo       = busRes.applyno;
                 tb_Order.SchemeDate     = DateTime.Now;
                 tb_Order.Ecordercode    = busRes.applyno;
                 tb_Order.Trial          = busRes.trial;
                 tb_Order.BossOrderID    = busRes.bossorderid.ToString();
                 tb_Order.CustID         = busRes.custid;
                 tb_Order.CustCode       = busRes.custcode;
                 tb_Order.CustType       = busRes.custtype;
                 tb_Order.RegisterSource = busRes.registersource;
                 tb_Order.Email          = busRes.email;
                 tb_Order.ProductCode    = busRes.services[0].code;
                 tb_Order.BeginTime      = busRes.services[0].begintime;
                 tb_Order.EndTime        = busRes.services[0].endtime;
                 tb_Order.CustName       = busRes.custname;
                 tb_Order.UserID         = busRes.userid;
                 tb_Order.UserName       = busRes.username;
                 tb_Order.UserLias       = busRes.useralias;
                 tb_Order.Produectparas  = JsonHelper.JsonSerializer(busRes.services);
                 db.Tb_Order.Add(tb_Order);
                 long          scUserid      = Convert.ToInt64(busRes.userid);
                 Tb_UserScheme tb_UserScheme = db.Tb_UserScheme.Find(scUserid);
                 if (tb_UserScheme == null)
                 {
                     tb_UserScheme             = new Tb_UserScheme();
                     tb_UserScheme.UserID      = Convert.ToInt64(busRes.userid);
                     tb_UserScheme.UserName    = busRes.username;
                     tb_UserScheme.EcorderCode = busRes.applyno;
                     tb_UserScheme.Useralias   = busRes.useralias;
                     tb_UserScheme.UserType    = 1;
                     tb_UserScheme.OptType     = 1;
                     tb_UserScheme.Mobile      = busRes.mobile;
                     tb_UserScheme.ProductCode = busRes.services[0].code;
                     tb_UserScheme.ID          = busRes.ecordercode;
                     tb_UserScheme.ApplyNo     = busRes.ecordercode;
                     tb_UserScheme.CustID      = busRes.custid;
                     tb_UserScheme.Email       = busRes.email;
                     tb_UserScheme.BeginTime   = busRes.services[0].begintime;
                     tb_UserScheme.EndTime     = busRes.services[0].endtime;
                     tb_UserScheme.IsDelete    = 0;
                     db.Tb_UserScheme.Add(tb_UserScheme);
                 }
                 db.SaveChanges();
                 return(ExternalResponse.ExRequest());
             }
         }
         catch (Exception e)
         {
             return(ExternalResponse.ErrRequest(500, "服务器错误:" + e.Message));
         }
     }
 }