public ActionResult DoSaoMa() { string p = Request["p"]; string number = Request["mobile_number"]; string spName = Request["SPName"]; string province= Request["Province"]; string city = Request["City"]; if (string.IsNullOrEmpty(p)) { ViewBag.Message = "参数错误,请正确扫码,输入手机号码点充值"; } else { int agentId = 0; int customerId = 0; int activityId = 0; int activityOrderId = 0; string parameters = KMEncoder.Decode(p); if(!string.IsNullOrEmpty(parameters)) { string signature = string.Empty; SortedDictionary<string, string> pvs = parseParameters(parameters,out signature); if (string.IsNullOrEmpty(signature)) { ViewBag.Message = "URL参数不正确,请重新扫码"; return View("SaoMa"); } System.Text.StringBuilder pBuilder = new System.Text.StringBuilder(); if(pvs.Count>0) { int count = 1; foreach(KeyValuePair<string,string> pair in pvs) { pBuilder.Append(pair.Key); pBuilder.Append("="); pBuilder.Append(pair.Value); if(count<pvs.Count) { pBuilder.Append("&"); } count++; switch (pair.Key) { case "agentId": int.TryParse(pair.Value,out agentId); break; case "customerId": int.TryParse(pair.Value, out customerId); break; case "activityId": int.TryParse(pair.Value, out activityId); break; case "activityOrderId": int.TryParse(pair.Value, out activityOrderId); break; } } CustomerManagement customerMgr = new CustomerManagement(0); int total; List<BCustomer> customers = customerMgr.FindCustomers(0, customerId, out total); if(total<=0 || total>1) { ViewBag.Message = "URL参数不正确,请重新扫码"; return View("SaoMa"); } pBuilder.Append("&key="); pBuilder.Append(customers[0].Token); string sign = UrlSignUtil.GetMD5(pBuilder.ToString()); if(sign!=signature) { ViewBag.Message = "URL参数不正确,请重新扫码"; return View("SaoMa"); } ActivityManagement activityMgr = new ActivityManagement(0); BMarketOrderCharge order = new BMarketOrderCharge() { ActivityId = activityId, ActivityOrderId = activityOrderId, AgentId = agentId, CustomerId = customerId, City = city, Province = province, OpenId = "", Phone = number, SPName = spName }; KMBit.BL.Charge.ChargeResult result = activityMgr.MarketingCharge(order); ViewBag.Message = result.Message; //if(result.Status == ChargeStatus.FAILED) //{ // ViewBag.Paras = pvs; // //paras.Add("p", p); //} } }else { ViewBag.Message = "不能重复扫码,或者修改扫码后的URL地址"; } } return View("SaoMa"); }
public ActionResult CreateCustomerActivity(int customerId) { CustomerManagement customerMgr = new CustomerManagement(User.Identity.GetUserId<int>()); List<BCustomer> customers = customerMgr.FindCustomers(User.Identity.GetUserId<int>(), customerId, out total); if (customers.Count == 0) { ViewBag.Message = string.Format("编号为:{0}的客户不是你的客户"); return View("Error"); } AgentManagement agentMgr = new AgentManagement(customerMgr.CurrentLoginUser); List<BAgentRoute> routes = agentMgr.FindTaocans(0,true); ViewBag.Customer = customers[0]; ViewBag.Routes = new SelectList((from r in routes select new {Id=r.Route.Id,Name=r.Taocan.Taocan2.Name+" - "+(r.Taocan.Taocan.Sale_price*r.Route.Discount).ToString("0.00")+"元" }),"Id","Name"); List<DictionaryTemplate> scanTypes = StaticDictionary.GetScanTypeList(); ViewBag.ScanTypes = new SelectList(from st in scanTypes select new { Id=st.Id,Name=st.Value},"Id","Name"); CustomerActivityModel model = new CustomerActivityModel() { Id=0,CustomerId=customerId,Enable=true }; return View(model); }
public ActionResult CustomerAcivities(int customerId) { CustomerManagement customerMgr = new CustomerManagement(User.Identity.GetUserId<int>()); List<BCustomer> customers = customerMgr.FindCustomers(User.Identity.GetUserId<int>(), customerId, out total); if(customers.Count==0) { ViewBag.Message = string.Format("编号为:{0}的客户不是你的客户", customerId); return View("Error"); } BCustomer customer = customers[0]; ActivityManagement activityMgr = new ActivityManagement(customerMgr.CurrentLoginUser); int page = 1; int pageSize = 20; int.TryParse(Request["page"], out page); page = page > 0 ? page : 1; List<BActivity> activities = activityMgr.FindActivities(0,User.Identity.GetUserId<int>(), customerId, out total, true, page, pageSize); PageItemsResult<BActivity> result = new PageItemsResult<BActivity>() { CurrentPage = page, EnablePaging = true, Items = activities, PageSize = pageSize, TotalRecords = total }; KMBit.Grids.KMGrid<BActivity> grid = new Grids.KMGrid<BActivity>(result); ViewBag.Customer = customer; return View("CustomerAcivities",grid); }
public ActionResult CustomerRecharge(int customerId) { CustomerManagement customerMgr = new CustomerManagement(User.Identity.GetUserId<int>()); List<BCustomer> customers = customerMgr.FindCustomers(User.Identity.GetUserId<int>(), customerId, out total); if (customers == null || customers.Count <= 0) { ViewBag.Message = string.Format("编号为{0}的客户不存在", customerId); return View("Error"); } CustomerRechargeModel model = new CustomerRechargeModel() {CurrentAmount=customers[0].RemainingAmount,ChargeAmount=0, CustomerId=customers[0].Id, CustomerName= customers[0].Name }; return View(model); }
public ActionResult EditCustomer(int customerId) { CustomerManagement customerMgr = new CustomerManagement(User.Identity.GetUserId<int>()); List<BCustomer> customers = customerMgr.FindCustomers(User.Identity.GetUserId<int>(), customerId, out total); if(customers==null || customers.Count<=0) { ViewBag.Message = string.Format("编号为{0}的客户不存在",customerId); return View("Error"); } BCustomer customer = customers[0]; CreateCustomerModel model = new CreateCustomerModel() { Amount= customer.RemainingAmount, ContactAddress=customer.ContactAddress, ContactEmail=customer.ContactEmail, ContactPeople=customer.ContactPeople, ContactPhone=customer.ContactPhone, CreditAmount=customer.CreditAmount, Description=customer.Description, Id=customer.Id, Name=customer.Name, OpenAccount=customer.OpenId, OpenType=customer.OpenType }; List<DictionaryTemplate> types = StaticDictionary.GetOpenTypeList(); ViewBag.OpenTypes = new SelectList(types, "Id", "Value"); return View("CreateCustomer", model); }
public ActionResult Customers() { CustomerManagement customerMgr = new CustomerManagement(User.Identity.GetUserId<int>()); int page = 1; int.TryParse(Request["page"],out page); page = page > 0 ? page : 1; int pageSize = 20; List<BCustomer> customers = customerMgr.FindCustomers(User.Identity.GetUserId<int>(),0, out total,true,page,pageSize); PageItemsResult<BCustomer> result = new PageItemsResult<BCustomer>() { CurrentPage=page, EnablePaging=true, Items=customers, PageSize=pageSize, TotalRecords=total }; KMBit.Grids.KMGrid<KMBit.Beans.BCustomer> grid = new KMBit.Grids.KMGrid<KMBit.Beans.BCustomer>(result); return View(grid); }