public MerchantTypes GetMerchantTypes() { var merchantType = MerchantTypeHelper.GetMerchantType(Mid); if (merchantType != null) { return(merchantType.TypeId); } return(MerchantTypes.Food); }
/// <summary> /// 保存商户分类列表 /// </summary> public void SaveMerchantTypeList() { string data_save = GetString("data_save"); if (string.IsNullOrEmpty(data_save)) { ReturnErrorMsg("没有选择需要保存的商户分类"); return; } var json = new JavaScriptSerializer(); var list = json.Deserialize(data_save, typeof(List <SaveMerchantTypeItem>)) as List <SaveMerchantTypeItem>; if (list == null) { ReturnErrorMsg("没有选择需要保存的商户分类"); return; } var merTypeList = MerchantTypeHelper.GetList(); var saveTypeList = new List <MerchantType>(); foreach (var saveMerchantTypeItem in list) { var item = merTypeList.FirstOrDefault(o => o.Id == saveMerchantTypeItem.Id); if (item == null) { ReturnErrorMsg("上传了不存在商户类型id"); return; } item.Name = saveMerchantTypeItem.Name; saveTypeList.Add(item); } if (saveTypeList.Count == 0) { ReturnErrorMsg("没有选择需要保存的商户分类"); return; } if (MerchantTypeHelper.SaveMerchantTypeList(saveTypeList)) { ReturnCorrectMsg("保存成功"); } else { ReturnErrorMsg("保存失败"); } }
/// <summary> /// 获取商户列表 /// </summary> public void GetMerchantList() { var mid = GetInt("mid"); var orderby = GetInt("orderby"); var orderbytype = GetInt("orderbytype"); var start = GetInt("start"); var limit = GetInt("limit"); var merresult = MerchantHelper.GetMerchantList(mid, orderby, orderbytype, start * limit, limit); var mertyperesult = MerchantTypeHelper.GetList(); var data = new List <MerchantItem>(); var idlist = merresult.Results.Select(o => o.Id).ToList(); var users = AccountHelper.GetUserList(Utility.GetWhereSql(idlist)); foreach (var merchant in merresult.Results) { var merchantitem = new MerchantItem(); merchantitem.Id = merchant.Id; merchantitem.UserCount = merchant.UserCount; var user = users.Results.FirstOrDefault(o => o.Id == merchant.Id); if (user == null) { ReturnErrorMsg("数据出错"); return; } merchantitem.Money = user.Money; var mertype = mertyperesult.FirstOrDefault(o => o.Id == merchant.Mid); if (mertype == null) { ReturnErrorMsg("数据出错"); return; } merchantitem.Cname = mertype.Name; merchantitem.CreateTime = merchant.CreateTime; merchantitem.DevName = merchant.DevName; merchantitem.Name = merchant.Name; merchantitem.LogoUrl = merchant.LogoUrl; data.Add(merchantitem); } var jt = new JsonTransfer(); jt.Add("list", data); jt.Add("totalcount", merresult.TotalCount); Response.Write(jt.ToJson()); Response.End(); }
/// <summary> /// 获取商户详情页面的一些配置列表 /// </summary> public void GetCfgList() { var result = MerchantTypeHelper.GetList(); var tresult = TempleHelper.GetList(); var signlist = ParamHelper.PlatformCfgData.SignList; var jt = new JsonTransfer(); var nowdate = DateTime.Now.ToString("yyyy-MM-d"); var serverdata = DateTime.Now.AddYears(1).ToString("yyyy-MM-d");; jt.Add("mertypelist", result); jt.Add("templelist", tresult.Results); jt.Add("signlist", signlist); jt.Add("nowdate", nowdate); jt.Add("serverdata", serverdata); Response.Write(jt.ToJson()); Response.End(); }
/// <summary> /// 获取商户类型列表 /// </summary> public void GetMerchantTypeList() { var type = GetInt("type"); var result = MerchantTypeHelper.GetList(); if (type == 0) { result.Insert(0, new MerchantType() { Id = 0, Name = "全部分类" }); } var jt = new JsonTransfer(); jt.Add("list", result); Response.Write(jt.ToJson()); Response.End(); }
/// <summary> /// 删除商户类型列表 /// </summary> public void DelMerchantTypeList() { var ids = GetString("ids"); var idlist = Utility.GetListint(ids); if (idlist.Count == 0) { ReturnErrorMsg("删除的商户类型id不能为空"); return; } if (MerchantTypeHelper.DelMerchantTypeList(ids)) { ReturnCorrectMsg("删除成功"); } else { ReturnErrorMsg("删除失败"); } }
/// <summary> /// 新增商户类型 /// </summary> public void AddMerchantType() { var name = GetString("name"); var typeid = GetInt("typeid"); if (string.IsNullOrEmpty(name) || typeid == 0) { ReturnErrorMsg("参数有误"); return; } var merchantType = new MerchantType(); merchantType.TypeId = (MerchantTypes)typeid; merchantType.Name = name; if (MerchantTypeHelper.AddMerchantType(merchantType)) { ReturnCorrectMsg("新增成功"); } else { ReturnErrorMsg("新增失败"); } }
/// <summary> /// 保存商户信息 /// </summary> public void SaveMerchant() { string data_save = GetString("data_save"); if (string.IsNullOrEmpty(data_save)) { ReturnErrorMsg("商户信息为空"); return; } var json = new JavaScriptSerializer(); var merchantinfo = json.Deserialize <SaveMerchantInfo>(data_save); if (merchantinfo == null) { ReturnErrorMsg("商户信息为空"); return; } var user = new Account(); if (MerchantHelper.JudgeMerchant(merchantinfo.Name, merchantinfo.Id)) { ReturnErrorMsg(string.Format("已存在名称为【{0}】的商户", merchantinfo.Name)); return; } var id = merchantinfo.Id; if (id == 0) { user.UserName = merchantinfo.UserName; user.Pwd = "111111"; user.RoleType = RoleType.Merchant; user.Phone = merchantinfo.Phone; user.Address = merchantinfo.Address; merchantinfo.Id = AccountHelper.SaveAccount(user); } else { user = AccountHelper.GetUser(merchantinfo.Id); } if (user == null) { ReturnErrorMsg("不存在该商户"); return; } var merchant = MerchantHelper.GetMerchant(merchantinfo.Id); var isadd = 0; var changeCountList = new List <GoodsHandler.ChangeCountItem>(); if (merchant == null) { merchant = new Merchant(); merchant.Id = merchantinfo.Id; isadd = 1; changeCountList.Add(new GoodsHandler.ChangeCountItem() { Id = merchantinfo.Mid, Change = 1 }); } user.UserName = merchantinfo.UserName; merchant.Name = merchantinfo.Name; merchant.LogoUrl = merchantinfo.LogoUrl; if (id > 0 && merchantinfo.Mid != merchant.Mid) { if (merchant.Mid > 0) { changeCountList.Add(new GoodsHandler.ChangeCountItem() { Id = merchant.Mid, Change = -1 }); } changeCountList.Add(new GoodsHandler.ChangeCountItem() { Id = merchantinfo.Mid, Change = 1 }); } merchant.Mid = merchantinfo.Mid; merchant.Tid = merchantinfo.Tid; //merchant.ServerEndTime = merchantinfo.ServerEndTime; merchant.HasWifi = merchantinfo.HasWifi; merchant.HasPrint = merchantinfo.HasPrint; merchant.HasDelivery = merchantinfo.HasDelivery; merchant.Sid = merchantinfo.Sid; merchant.Phone = merchantinfo.Phone; merchant.ManagerPhone = merchantinfo.ManagerPhone; merchant.Address = merchantinfo.Address; merchant.WinXinAccount = merchantinfo.WinXinAccount; merchant.Qq = merchantinfo.Qq; merchant.Remark = merchantinfo.Note; merchant.IosUrl = merchantinfo.IosUrl; merchant.IosVersion = merchantinfo.IosVer; merchant.AndroidUrl = merchantinfo.AndroidUrl; merchant.AndroidVersion = merchantinfo.AndroidVer; merchant.MachineCode = merchantinfo.MachineCode; merchant.MachineKey = merchantinfo.MachineKey; if (string.IsNullOrEmpty(merchantinfo.CnameList[0])) { merchantinfo.CnameList[0] = "活动咨询"; } if (string.IsNullOrEmpty(merchantinfo.CnameList[1])) { merchantinfo.CnameList[1] = "商品展示"; } if (string.IsNullOrEmpty(merchantinfo.CnameList[2])) { merchantinfo.CnameList[2] = "快速预约"; } if (string.IsNullOrEmpty(merchantinfo.CnameList[3])) { merchantinfo.CnameList[3] = "图片墙"; } if (string.IsNullOrEmpty(merchantinfo.CnameList[4])) { merchantinfo.CnameList[4] = "包厢"; } merchant.CnameList = merchantinfo.CnameList; merchant.DevName = merchantinfo.DevName; merchant.WifiAccount = merchantinfo.WifiAccount; AccountHelper.SaveAccount(user); if (MerchantHelper.SaveMerchant(merchant, isadd)) { MerchantTypeHelper.UpdateMerchantCount(changeCountList); if (id == 0) { if (Utility._msg_opensend == "1") { //发送短信给商户 SendMsgClass5 jsobject = new SendMsgClass5(); jsobject.param1 = string.IsNullOrEmpty(merchant.Name) ? "商户名称为空" : merchant.Name; jsobject.param2 = Utility._domainurl + "/view/dev/Index.aspx"; jsobject.param3 = string.IsNullOrEmpty(user.UserName) ? string.IsNullOrEmpty(user.Phone) ? "用户名为空" : user.Phone : user.UserName; jsobject.param4 = user.Pwd; jsobject.param5 = Utility._3vurl; if (Utility.SendMsg(merchant.Phone, MsgTempleId.AddMerchant, jsobject) != "发送成功") { logger.InfoFormat("短信模板:{0},Phone:{3},发送失败merchantId:{1},Name:{2}", (int)MsgTempleId.AddMerchant, merchant.Id, merchant.Name, merchant.Phone); } } ReturnCorrectMsg("添加成功"); } else { ReturnCorrectMsg("更新成功"); } } else if (id == 0) { ReturnErrorMsg("添加失败"); } else { ReturnErrorMsg("更新失败"); } }
public static bool SendOrdersMsgToPrint(Orders orders) { var merchant = MerchantHelper.GetMerchant(orders.SellerId); if (merchant == null) { return(false); } if (string.IsNullOrEmpty(merchant.MachineCode) || string.IsNullOrEmpty(merchant.MachineKey)) { return(false); } var merchanttype = MerchantTypeHelper.GetMerchantType(merchant.Mid); if (merchanttype == null) { return(false); } StringBuilder sb = new StringBuilder(string.Empty); var ordertypename = orders.OrderType == OrderType.Shop ? "到店" : "送餐"; sb.AppendFormat("【{0}】{1}\n", merchanttype.Name, ordertypename); sb.AppendFormat("订单号:{0}\n", orders.Id); if (merchant.MerType == MerchantTypes.Food) { sb.AppendFormat("订单类型:{0}\n", ordertypename); } sb.AppendFormat("订单时间:{0}\n", orders.CreateTime.ToString("yyyy-MM-dd hh:mm:ss")); if (orders.OrderType == OrderType.Shop) { sb.AppendFormat("到店时间:{0}\n", orders.OrderTime.ToString("yyyy-MM-dd hh:mm:ss")); } sb.Append("【收货信息】\n"); sb.AppendFormat("联系人:{0}\n", orders.LinkMan); sb.AppendFormat("联系电话:{0}\n", orders.Mobile); if ((merchant.MerType == MerchantTypes.Food && orders.OrderType != OrderType.Shop) || merchant.MerType == MerchantTypes.Company) { sb.AppendFormat("地址:{0}\n", orders.Address); } else if (merchant.MerType == MerchantTypes.Night) { sb.AppendFormat("包厢号:{0}\n", orders.Boxno); } sb.Append("【订单详情】\n"); sb.Append("******************************\n"); var i = 0; foreach (var order in orders.GidList) { sb.AppendFormat("{0} {1}份 {2}元\n" , orders.TitleList[i], orders.NumList[i], orders.NumList[i] * orders.NowPriceList[i]); i++; } sb.Append("******************************\n"); sb.AppendFormat("总计数量:{0}\n", orders.NumList.Sum(o => o)); sb.AppendFormat("总金额:{0}\n", orders.TotalPrice); sb.AppendFormat("【备注】:{0}\n", orders.Remark); return(SendPrinterData(sb.ToString(), merchant)); }