/// <summary> /// 0:正常状态 /// 1:用户回收站 /// 2:用户彻底删除|管理员删除订单时,返还优惠卷,并删除支付单 ///(仅可操作未完成支付的支付单) /// </summary> public bool CancelOrder(M_OrderList orderMod) { B_Payment payBll = new B_Payment(); M_Payment payMod = payBll.SelModelByOrder(orderMod); //支付单不存在,或状态不为未支付,则忽略 if (payMod == null) { return(false); } //返还优惠卷 if (!string.IsNullOrEmpty(payMod.ArriveDetail)) { B_Arrive avBll = new B_Arrive(); M_Arrive avMod = avBll.SelReturnModel(DataConvert.CLng(payMod.ArriveDetail)); if (avMod != null && avMod.State == 10) { avMod.State = 1; avMod.UseRemind = "订单[" + orderMod.OrderNo + "]取消,返还优惠卷"; avBll.GetUpdate(avMod); } } //返回积分,需计算积分的值 if (payMod.UsePoint > 0) { } DBCenter.UpdateSQL(payMod.TbName, "Status=" + (int)M_Payment.PayStatus.NoPay + ",MoneyTrue=0,IsDel=1", "PaymentID=" + payMod.PaymentID); return(true); }
public void Arrive_Add(M_Arrive avMod) { M_Store_Info storeMod = storeBll.SelModelByUser(mu.UserID); if (Mid < 1)//添加优惠券 { avMod.CUser = mu.UserID; avMod.StoreID = storeMod.ID; avMod.State = DataConvert.CLng(Request.Form["state_chk"]); int num = DataConverter.CLng(Request.Form["txtCreateNum"]); CommonReturn retMod = avBll.CreateArrive(avMod, num, "1", Request.Form["UserID_Hid"]); if (retMod.isok) { function.WriteSuccessMsg("批量添加成功!", "ArriveManage"); } else { function.WriteErrMsg(retMod.err); } } else { avMod = avBll.SelReturnModel(Mid); avMod.ArriveName = Request.Form["ArriveName"]; avMod.Amount = DataConvert.CLng(Request.Form["Amount"]); avMod.MinAmount = Convert.ToDouble(Request.Form["MinAmount"]); avMod.MaxAmount = Convert.ToDouble(Request.Form["MaxAmount"]); avMod.AgainTime = DataConvert.CDate(Request.Form["AgainTime"]); avMod.EndTime = DataConvert.CDate(Request.Form["EndTime"]); avBll.GetUpdate(avMod); function.WriteSuccessMsg("修改成功!", "ArriveManage"); } }
public static void Use_Arrive(M_Arrive model, string remind) { List <SqlParameter> list = new List <SqlParameter> { new SqlParameter("remind", remind), new SqlParameter("usetime", DateTime.Now) }; DBCenter.UpdateSQL("ZL_Arrive", "State=10,UseRemind=@remind,UseTime=@usetime", "ID=" + model.ID, list); }
public IActionResult ArriveAdd_Submit() { M_Arrive avMod = new M_Arrive(); if (Mid > 0) { avMod = avBll.SelReturnModel(Mid); } avMod.ArriveName = GetParam("txtName"); avMod.MinAmount = DataConverter.CDouble(GetParam("minAmount_T")); avMod.MaxAmount = DataConverter.CDouble(GetParam("maxAmount_T")); avMod.Amount_Max = DataConverter.CDouble(GetParam("Amount2_Max")); avMod.DateDays = DataConverter.CLng(GetParam("DateDays_T")); avMod.AgainTime = DataConverter.CDate(GetParam("AgainTime_T")); avMod.EndTime = DataConverter.CDate(GetParam("EndTime_T")); avMod.Type = DataConverter.CLng(Request.Form["Type_Rad"]); avMod.DateType = DataConverter.CLng(Request.Form["date_rad"]); avMod.ProIDS = GetParam("UProIDS_Hid"); avMod.StoreID = DataConverter.CLng(GetParam("Store_DP")); avMod.State = DataConvert.CLng(GetParam("state_chk")); avMod.CAdmin = adminMod.AdminId; switch (avMod.Type) { case 1: avMod.Amount = DataConverter.CDouble(GetParam("Amount2_T")); break; default: avMod.Amount = DataConverter.CDouble(GetParam("Amount_T")); break; } //---------------------------------------- if (avMod.ID < 1)//添加优惠券 { int num = DataConverter.CLng(GetParam("txtCreateNum")); CommonReturn retMod = avBll.CreateArrive(avMod, num, GetParam("EcodeType"), GetParam("UserID_Hid")); if (retMod.isok) { return(WriteOK("批量添加成功!", "ArriveManage?name=" + avMod.ArriveName)); } else { return(WriteErr(retMod.err)); } } else { avMod.ArriveNO = GetParam("txtNo"); avMod.ArrivePwd = GetParam("txtPwd"); avBll.GetUpdate(avMod); return(WriteOK("操作成功", "ArriveManage")); } }
/// <summary> /// 测试优惠券,用于订单页 /// </summary> /// <param name="flow"></param> /// <returns>优惠后的金额,</returns> public bool U_CheckArrive(M_Arrive model, int uid, ref double money, ref string err) { if (model == null) { err = "指定的优惠券不存在"; return(false); } model.MaxAmount = model.MaxAmount == 0 ? double.MaxValue : model.MaxAmount; if (model.UserID != uid) { err = "优惠券与用户不匹配"; } else if (uid < 1) { err = "用户信息不正确"; } else if (model.State == 10) { err = "优惠券已被使用"; } else if (model.State == 0) { err = "优惠券尚未激活"; } else if (model.Amount < 1) { err = "优惠券金额异常[" + model.Amount + "]"; } else if (model.MinAmount > money) { err = "未达到最小金额使用限制"; } else if (model.MaxAmount < money) { err = "超过最大金额使用限制"; } else if (model.EndTime < DateTime.Now) { err = "优惠券已过期"; } else if (model.AgainTime > DateTime.Now) { err = "优惠券尚未到可使用时段"; } else { money = money - model.Amount; money = money < 0 ? 0 : money; return(true); } return(false); }
public static M_Arrive AV_SelModel(string avNo) { M_Arrive model = new M_Arrive(); SqlParameter[] sp = new SqlParameter[] { new SqlParameter("arriveNo", avNo) }; using (SqlDataReader sqlDataReader = Sql.SelReturnReader(model.TbName, " Where ArriveNo=@arriveNo", sp)) { if (sqlDataReader.Read()) { return(model.GetModelFromReader(sqlDataReader)); } return(null); } }
/// <summary> /// 使用目标优惠券,并写入日志 /// </summary> /// <param name="model">优惠券模型</param> /// <param name="uid">需要使用该优惠券的用户ID</param> /// <param name="money">订单的金额,优惠完成后该值会被修改</param> /// <param name="err">优惠券错误原因</param> /// <param name="remind">优惠券使用备注</param> /// <returns>true使用成功,false则查看err</returns> public M_Arrive_Result U_UseArrive(M_Arrive model, int uid, DataTable cartdt, double money, string remind) { M_Arrive_Result retMod = U_CheckArrive(model, uid, cartdt, money); if (retMod.enabled) { List <SqlParameter> sp = new List <SqlParameter>() { new SqlParameter("remind", remind), new SqlParameter("usetime", DateTime.Now) }; DBCenter.UpdateSQL("ZL_Arrive", "State=10,UseRemind=@remind,UseTime=@usetime", "ID=" + model.ID, sp); } return(retMod); }
//行绑定 protected void Manufacturerslist_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { HiddenField hfId = e.Item.FindControl("hfId") as HiddenField; HiddenField hfpwd = e.Item.FindControl("hfpwd") as HiddenField; LinkButton btn = e.Item.FindControl("del") as LinkButton; M_Arrive arrive = barrive.GetArriveById(DataConverter.CLng(hfId.Value)); //if (arrive != null && arrive.Id > 0) //{ // btn.Enabled = false; //} } }
/// <summary> /// 使用目标优惠券,并写入日志 /// </summary> /// <param name="model">优惠券模型</param> /// <param name="uid">需要使用该优惠券的用户ID</param> /// <param name="money">订单的金额,优惠完成后该值会被修改</param> /// <param name="err">优惠券错误原因</param> /// <param name="remind">优惠券使用备注</param> /// <returns>true使用成功,false则查看err</returns> public bool U_UseArrive(M_Arrive model, int uid, ref double money, ref string err, string remind) { if (U_CheckArrive(model, uid, ref money, ref err)) { List <SqlParameter> sp = new List <SqlParameter>() { new SqlParameter("remind", remind), new SqlParameter("usetime", DateTime.Now) }; DBCenter.UpdateSQL(TbName, "State=10,UseRemind=@remind,UseTime=@usetime", "ID=" + model.ID, sp); return(true); } else { return(false); } }
public void Arrive_Act() { string ANo = Request.Form["ANo"]; string APwd = Request.Form["APwd"]; //优惠券的实例 M_Arrive avMod = avBll.SelReturnModel(ANo, APwd); if (avMod == null) { function.WriteErrMsg("优惠券不存在"); return; } string str = "优惠券激活成功" + "!此优惠券的面值为[" + avMod.Amount + "]"; function.WriteSuccessMsg(str, "ArriveJiHuo"); }
public IActionResult Arrive_Act() { string ANo = RequestEx["ANo"]; string APwd = RequestEx["APwd"]; //优惠券的实例 M_Arrive avMod = avBll.SelReturnModel(ANo, APwd); if (avMod == null) { return(WriteErr("优惠券不存在")); } string str = "优惠券激活成功" + "!此优惠券的面值为[" + avMod.Amount + "]"; return(WriteOK(str, "ArriveJiHuo")); }
public ActionResult ArriveAdd() { M_Arrive avMod = avBll.SelReturnModel(Mid); if (avMod == null) { avMod = new M_Arrive(); } if (avMod.ID > 0) { return(View("ArriveEdit", avMod)); } else { return(View("ArriveAdd", avMod)); } }
private void MyBind() { if (Mid > 0) { EBtnSubmit.Text = "保存设置"; no.Visible = true; createNum.Visible = false; txtName.Enabled = false; Magclass.Enabled = false; M_Arrive avMod = avBll.GetArriveById(Mid); txtName.Text = avMod.ArriveName; Magclass.SelectedValue = avMod.Type.ToString(); txtNo.Text = avMod.ArriveNO; txtPwd.Text = avMod.ArrivePwd; EditecodType.Style.Add("display", "none"); minAmount_T.Text = avMod.MinAmount.ToString(); maxAmount_T.Text = avMod.MaxAmount.ToString(); Amount_T.Text = avMod.Amount.ToString(); Amount_T.Enabled = avMod.State == 0; AgainTime_T.Text = avMod.AgainTime.ToString(); EndTime_T.Text = avMod.EndTime.ToString(); txtState.Text = "未激活"; if (avMod.State > 0) { txtState.Text = avMod.State == 1 ? "已激活" : "已使用"; } M_UserInfo info = buser.GetUserByUserID(avMod.UserID); if (!info.IsNull) { txtUserID.Text = info.UserName; hfid.Value = avMod.UserID.ToString(); } else { txtUserID.Text = "未送出"; } } else { createNum.Visible = true; no.Visible = false; AgainTime_T.Text = DateTime.Now.ToString("yyyy/MM/dd"); EndTime_T.Text = DateTime.Now.AddYears(1).ToString("yyyy/MM/dd"); } }
//-----新购物流程 public double UserArrive(string arriveNo, string arrivePwd) { if (string.IsNullOrEmpty(arriveNo) || string.IsNullOrEmpty(arrivePwd)) { return(0); } M_Arrive model = SelReturnModel(arriveNo, arrivePwd); if (model == null || model.EndTime < DateTime.Now || model.State != 1) { return(0); } else { UpdateState(arriveNo); return(model.Amount); } }
public IActionResult ArriveAdd() { M_Arrive avMod = new M_Arrive(); if (Mid > 0) { avMod = avBll.SelReturnModel(Mid); } DataTable storeDT = conBll.Store_Sel("", true); if (Mid > 0) { //switch (avMod.Type) //{ // case 1: // Amount2_T.Text = avMod.Amount.ToString("F2"); // Amount2_Max.Text = avMod.Amount_Max.ToString("F2"); // break; // case 2: // break; // default: // Amount_T.Text = avMod.Amount.ToString(); // break; //} //if (avMod.State > 0) { txtState.Text = avMod.State == 1 ? "已激活" : "已使用"; } //M_UserInfo info = buser.GetUserByUserID(avMod.UserID); //if (!info.IsNull) //{ // txtUserID.Text = info.UserName; //} //else //{ // txtUserID.Text = "未送出"; //} } else { avMod.AgainTime = DateTime.Now; avMod.EndTime = DateTime.Now.AddYears(1); } ViewBag.storeDT = storeDT; return(View(avMod)); }
/// <summary> /// 制作优惠卷 /// </summary> /// <param name="noType">优惠卷编码类型</param> /// <param name="uids">默认分配给哪些用户</param> public CommonReturn CreateArrive(M_Arrive avMod, int num, string noType = "1", string uids = "") { if (num < 1) { return(CommonReturn.Failed("未指定生成数量")); } if (avMod.EndTime <= DateTime.Now) { return(CommonReturn.Failed("到期时间不能早于当前时间")); } if (avMod.AgainTime >= avMod.EndTime) { return(CommonReturn.Failed("到期时间不能晚于发布时间")); } if (avMod.MaxAmount < 0 || avMod.MinAmount < 0) { return(CommonReturn.Failed("使用范围数值不正确")); } if (avMod.MaxAmount != 0 && avMod.MinAmount > avMod.MaxAmount) { return(CommonReturn.Failed("使用范围不正确,最小值不能大于最大值")); } if (avMod.Amount < 1) { return(CommonReturn.Failed("优惠金额不正确,最小值为1")); } //---------------------------------------- if (string.IsNullOrEmpty(avMod.Flow)) { avMod.Flow = Guid.NewGuid().ToString(); } int[] uidArr = H_GetUserArr(uids); for (int i = 0; i < num; i++) { avMod.ArriveNO = H_GetArriveNo(noType); avMod.ArrivePwd = "ZL" + function.GetRandomString(9); avMod.UserID = uidArr.Length > i ? uidArr[i] : 0; GetInsert(avMod); } return(CommonReturn.Success()); }
protected void Page_Load(object sender, EventArgs e) { M_UserInfo mu = buser.GetLogin(); double allmoney = DataConvert.CDouble(Request["allmoney"]); string ids = DataConvert.CStr(Request.QueryString["ids"]); //------用户有哪些未使用的优惠券 DataTable avdt = avBll.U_Sel(mu.UserID, -100, 1); DataTable cartdt = null; if (avdt.Rows.Count < 1) { arrive_empty_div.Visible = true; return; } else { arrive_div.Style.Add("display", "block"); arrive_data_div.Visible = true; avdt.Columns.Add("enable", typeof(int)); //优惠券是否有效 1:有效 avdt.Columns.Add("err", typeof(string)); //不能使用的原因 cartdt = cartBll.SelByCartID(B_Cart.GetCartID(), mu.UserID, -100, ids); } //---------------------------------------Logical for (int i = 0; i < avdt.Rows.Count; i++) { DataRow dr = avdt.Rows[i]; M_Arrive avMod = new M_Arrive().GetModelFromReader(dr); double money = allmoney; M_Arrive_Result retMod = avBll.U_CheckArrive(avMod, mu.UserID, cartdt, money); dr["enable"] = retMod.enabled ? 1 : 0; dr["err"] = retMod.err; } avdt.DefaultView.RowFilter = "enable='1'"; Arrive_Active_RPT.DataSource = avdt.DefaultView.ToTable(); Arrive_Active_RPT.DataBind(); avdt.DefaultView.RowFilter = "enable='0'"; Arrive_Disable_RPT.DataSource = avdt.DefaultView.ToTable(); Arrive_Disable_RPT.DataBind(); }
public void Arrive_Act() { string ANo = Request.Form["ANo"]; string APwd = Request.Form["APwd"]; int uid = avBll.GetUserid(ANo);//uid=0 decimal mianzhi = avBll.GetOtherArrive(mu.UserID, ANo, APwd); //获得用户基本信息 M_Uinfo muinfo = buser.GetUserBaseByuserid(uid); avBll.UpdateState(ANo); avBll.UpdateUseTime(ANo); //优惠券的实例 M_Arrive avMod = avBll.SelReturnModel(ANo, APwd); if (avMod == null) { function.WriteErrMsg("优惠券不存在"); return; } string str = "优惠券激活成功" + "!此优惠券的面值为[" + avMod.Amount + "]"; function.WriteSuccessMsg(str, "ArriveJiHuo"); }
public bool GetUpdate(M_Arrive model) { return(DBCenter.UpdateByID(model, model.ID)); }
public IActionResult GetOrderInfo_Submit() { //1,生成订单,2,关联购物车中商品为已绑定订单 string ids = GetParam("ids"); M_UserInfo mu = buser.GetLogin(false); DataTable cartDT = cartBll.SelByCartID(B_Cart.GetCartID(HttpContext), mu.UserID, ProClass, ids);//需要购买的商品 if (cartDT.Rows.Count < 1) { return(WriteErr("你尚未选择商品,<a href='/User/Order/OrderList'>查看我的订单</a>")); } VM_CartOrder vmMod = new VM_CartOrder(); vmMod.IsShowAddress(DataConvert.CLng(cartDT.Rows[0]["ProClass"])); //------------------------------ #region 检测缓存中的值与数据库中是否匹配 //string refreshTip = ",请点击<a href='" + Request.RawUrl() + "'>刷新页面</a>"; //if (VerifyDT == null || VerifyDT.Rows.Count < 1 || VerifyDT.Rows.Count != cartDT.Rows.Count) //{ return WriteErr("验证失效" + refreshTip, Request.RawUrl()); } //for (int i = 0; i < VerifyDT.Rows.Count; i++) //{ // //检测每一个商品,是否发生了ID/金额/数量/价格/总金额上面的差异或缺少 // DataRow verifyDR = VerifyDT.Rows[i]; // DataRow cartDR = GetDRFromDT(cartDT, Convert.ToInt32(verifyDR["ID"])); // if (cartDR == null) { return WriteErr("购物车信息不匹配" + refreshTip, Request.RawUrl()); } // foreach (string field in verifyFields) // { // double verifyVal = DataConvert.CDouble(verifyDR[field]); // double cartVal = DataConvert.CDouble(cartDR[field]); // if (verifyVal != cartVal) { return WriteErr("购物车的[" + field + "]不匹配" + refreshTip, Request.RawUrl()); } // } //} #endregion //------生成订单前检测区 foreach (DataRow dr in cartDT.Rows) { if (!HasStock(dr["Allowed"], DataConvert.CLng(dr["stock"]), Convert.ToInt32(dr["Pronum"]))) { return(WriteErr("购买失败," + dr["proname"] + "的库存数量不足")); } } //------检测End //按店铺生成订单 DataTable storeDT = cartDT.DefaultView.ToTable(true, "StoreID"); List <M_OrderList> orderList = new List <M_OrderList>();//用于生成临时订单,统计计算(Disuse) foreach (DataRow dr in storeDT.Rows) { #region 暂不使用字段 //Odata.province = this.DropDownList1.SelectedValue; //Odata.city = this.DropDownList2.SelectedValue;//将地址省份与市ID存入,XML数据源 //Odata.Guojia = "";//国家 //Odata.Chengshi = DropDownList2.SelectedItem.Text;//城市 //Odata.Diqu = DropDownList3.SelectedItem.Text;//地区 //Odata.Delivery = DataConverter.CLng(Request.Form["Delivery"]); //Odata.Deliverytime = DataConverter.CLng(this.Deliverytime.Text); //Odata.Mobile = receMod.MobileNum; #endregion M_OrderList Odata = new M_OrderList(); Odata.Ordertype = OrderHelper.GetOrderType(ProClass); Odata.OrderNo = B_OrderList.CreateOrderNo((M_OrderList.OrderEnum)Odata.Ordertype); Odata.StoreID = Convert.ToInt32(dr["StoreID"]); cartDT.DefaultView.RowFilter = "StoreID=" + Odata.StoreID; DataTable storeCartDT = cartDT.DefaultView.ToTable(); switch (vmMod.ProClass)//旅游机票等,以联系人信息为地址 { case 7: case 8: M_Cart_Travel model = JsonConvert.DeserializeObject <M_Cart_Travel>(storeCartDT.Rows[0]["Additional"].ToString()); M_Cart_Contract user = model.Contract[0]; Odata.Receiver = user.Name; Odata.Phone = user.Mobile; Odata.MobileNum = user.Mobile; Odata.Email = user.Email; break; default: if (vmMod.ShowAddress) { int arsID = DataConvert.CLng(GetParam("address_rad")); string arsChk = GetParam("ars_chk"); if (!string.IsNullOrEmpty(arsChk)) { #region 自提或微信共享地址 switch (arsChk) { case "self": { Odata.Receiver = "[用户自提]" + GetParam("arsInfo_name"); //用户上门购买,然后自提取商品 Odata.MobileNum = GetParam("arsInfo_mobile"); } break; case "wechat": { Odata.Receiver = GetParam("wxad_name"); Odata.MobileNum = GetParam("wxad_mobile"); Odata.Shengfen = GetParam("wxad_city"); Odata.Jiedao = GetParam("address"); } break; } #endregion } else { M_UserRecei receMod = receBll.GetSelect(arsID, mu.UserID); if (receMod == null) { return(WriteErr("用户尚未选择送货地址,或地址不存在")); } Odata.Receiver = receMod.ReceivName; Odata.Phone = receMod.phone; Odata.MobileNum = receMod.MobileNum; Odata.Email = receMod.Email; Odata.Shengfen = receMod.Provinces; Odata.Jiedao = receMod.Street; Odata.ZipCode = receMod.Zipcode; } } break; } Odata.Invoiceneeds = DataConverter.CLng(GetParam("invoice_rad"));//是否需开发票 Odata.Rename = mu.UserName; Odata.AddUser = mu.UserName;; Odata.Userid = mu.UserID; Odata.Ordermessage = GetParam("ORemind_T");//订货留言 //-----金额计算 Odata.Balance_price = GetTotalMoney(storeCartDT); Odata.Freight = GetFarePrice(storeCartDT, Odata.StoreID); //运费计算 Odata.Ordersamount = Odata.Balance_price + Odata.Freight; //订单金额 Odata.AllMoney_Json = orderCom.GetTotalJson(storeCartDT); //附加需要的虚拟币 Odata.Specifiedprice = Odata.Ordersamount; //订单金额; Odata.OrderStatus = (int)M_OrderList.StatusEnum.Normal; //订单状态 Odata.Paymentstatus = (int)M_OrderList.PayEnum.NoPay; //付款状态 //Odata.Integral = DataConverter.CLng(Request.QueryString["jifen"]); Odata.ExpTime = GetParam("exptime_hid"); Odata.id = orderBll.insert(Odata); //是否需要开发票 if (Odata.Invoiceneeds == 1) { M_Order_Invoice invMod = new M_Order_Invoice(); invMod.OrderID = Odata.id; invMod.InvHead = GetParam("InvoTitle_T").Trim(','); invMod.UserCode = GetParam("InvoUserCode_T").Trim(','); invMod.InvClass = GetParam("invUseType_rad"); invMod.InvContent = GetParam("Invoice_T").Trim(','); invMod.UserID = Odata.Userid; invBll.Insert(invMod); new B_Order_InvTlp().Sync(invMod); } cpBll.CopyToCartPro(mu, storeCartDT, Odata.id); orderList.Add(Odata); orderCom.SendMessage(Odata, null, "ordered"); } cartBll.DelByids(ids); //-----------------订单生成后处理 //进行减库存等操作 foreach (DataRow dr in cartDT.Rows) { M_Product model = proBll.GetproductByid(Convert.ToInt32(dr["Proid"])); model.Stock = model.Stock - DataConvert.CLng(dr["Pronum"]); SqlHelper.ExecuteSql("Update ZL_Commodities Set Stock=" + model.Stock + " Where ID=" + model.ID); } //生成支付单,处理优惠券,并进入付款步骤 M_Payment payMod = payBll.CreateByOrder(orderList); //优惠券 if (!string.IsNullOrEmpty(GetParam("Arrive_Hid"))) { M_Arrive avMod = avBll.SelModelByFlow(GetParam("Arrive_Hid"), mu.UserID); double money = payMod.MoneyPay; string remind = "支付单抵扣[" + payMod.PayNo + "]"; M_Arrive_Result retMod = avBll.U_UseArrive(avMod, mu.UserID, cartDT, money, remind); if (retMod.enabled) { payMod.MoneyPay = retMod.money; payMod.ArriveMoney = retMod.amount; payMod.ArriveDetail = avMod.ID.ToString(); } else { payMod.ArriveDetail = "优惠券[" + avMod.ID + "]异常 :" + retMod.err; } } //积分处理 int maxPoint = Point_CanBeUse(payMod.MoneyPay + payMod.ArriveMoney); if (maxPoint > 0 && DataConvert.CLng(GetParam("Point_T")) > 0) { int point = DataConvert.CLng(GetParam("Point_T")); //此处需咨询,上限额度是否要扣减掉优惠券 //if (point <= 0) { return WriteErr("积分数值不正确"); } if (point > mu.UserExp) { return(WriteErr("您的积分不足!")); } if (point > maxPoint) { return(WriteErr("积分不能大于可兑换金额[" + maxPoint + "]!")); } //生成支付单时扣除用户积分 buser.ChangeVirtualMoney(mu.UserID, new M_UserExpHis() { ScoreType = (int)M_UserExpHis.SType.Point, score = -point, detail = "积分抵扣,支付单号:" + payMod.PayNo }); payMod.UsePoint = point; payMod.UsePointArrive = Point_ToMoney(point); payMod.MoneyPay = payMod.MoneyPay - payMod.UsePointArrive; } payMod.MoneyReal = payMod.MoneyPay; payMod.Remark = cartDT.Rows.Count > 1 ? "[" + cartDT.Rows[0]["ProName"] as string + "]等" : cartDT.Rows[0]["ProName"] as string; payMod.PaymentID = payBll.Add(payMod); { string notify_url = CustomerPageAction.customPath2 + "Shop/Orderlistinfo?ID=" + orderList[0].id; ZoomLa.BLL.User.M_User_Notify notify = new ZoomLa.BLL.User.M_User_Notify(); notify.Title = "有新的订单了"; notify.Content = "<a href='" + notify_url + "' target='main_right' style='font-size:12px;' title='查看详情'>新订单:" + orderList[0].OrderNo + "</a>"; notify.NType = 1; notify.Gid = orderList[0].id.ToString(); notify.AppendReceUser("admin"); ZoomLa.BLL.User.B_User_Notify.Add(notify); } return(Redirect("/PayOnline/Orderpay?PayNo=" + payMod.PayNo)); }
public static M_Arrive_Result CheckArrive(string code, string pwd, double money) { M_Arrive_Result result = new M_Arrive_Result(); if (string.IsNullOrEmpty(code)) { result.err = "The coupon number cannot be empty"; } //else if (string.IsNullOrEmpty(pwd)) //{ // result.err = "The coupon password cannot be empty"; //} else if (money < 1.0) { result.err = "Incorrect order amount"; } B_Arrive avBll = new B_Arrive(); M_Arrive avMod = SnsHelper.AV_SelModel(code); result.money = money; if (avMod == null || avMod.ID < 1) { result.err = "Coupon do not exist"; } else if (avMod.State == 10) { result.err = "Coupon have been used"; } else if (avMod.State == 0) { result.err = "Coupon have not been activated"; } else if (avMod.Amount < 1.0) { result.err = "Abnormal value of coupon[" + avMod.Amount.ToString("N") + "]"; } else if (avMod.EndTime < DateTime.Now) { result.err = "Coupon have expired"; } else if (avMod.AgainTime > DateTime.Now) { result.err = "Coupon have not yet reached the available time"; } if (!string.IsNullOrEmpty(result.err)) { return(result); } result.flow = avMod.Flow; avMod.MaxAmount = avMod.MaxAmount == 0 ? 5000000 : avMod.MaxAmount; if (avMod.MinAmount > money) { result.err = "No minimum amount of use limit"; return(result); } if (avMod.MaxAmount < money) { result.err = "More than maximum use limit"; return(result); } money -= avMod.Amount; money = ((money < 0.0) ? 0.0 : money); result.money = money; result.amount = avMod.Amount; result.enabled = true; return(result); }
public int GetInsert(M_Arrive model) { return(Sql.insert(TbName, model.GetParameters(), BLLCommon.GetParas(model), BLLCommon.GetFields(model))); }
public bool GetUpdate(M_Arrive model) { return(Sql.UpdateByIDs(TbName, PK, model.ID.ToString(), BLLCommon.GetFieldAndPara(model), model.GetParameters())); }
//提交订单 protected void AddOrder_Btn_Click(object sender, EventArgs e) { if (Address_Div.Visible && DataConvert.CLng(Request.Form["address_rad"]) < 1) { function.WriteErrMsg("尚未选定收货地址"); } //1,生成订单,2,关联购物车中商品为已绑定订单 M_UserInfo mu = buser.GetLogin(false); M_UserRecei receMod = receBll.GetSelect(Convert.ToInt32(Request.Form["address_rad"]), mu.UserID); DataTable cartDT = cartBll.SelByCartID(B_Cart.GetCartID(), mu.UserID, ProClass, ids);//需要购买的商品 if (cartDT.Rows.Count < 1) { function.WriteErrMsg("你尚未选择商品,<a href='/User/Order/OrderList'>查看我的订单</a>"); } //------生成订单前检测区 foreach (DataRow dr in cartDT.Rows) { if (!HasStock(dr["Allowed"], DataConvert.CLng(dr["stock"]), Convert.ToInt32(dr["Pronum"]))) { function.WriteErrMsg("购买失败," + dr["proname"] + "的库存数量不足"); } } //------检测End //按店铺生成订单,统一存ZL_Orderinfo DataTable storeDT = cartDT.DefaultView.ToTable(true, "StoreID"); List <M_OrderList> orderList = new List <M_OrderList>();//用于生成临时订单,统计计算(Disuse) foreach (DataRow dr in storeDT.Rows) { #region 暂不使用字段 //Odata.province = this.DropDownList1.SelectedValue; //Odata.city = this.DropDownList2.SelectedValue;//将地址省份与市ID存入,XML数据源 //Odata.Guojia = "";//国家 //Odata.Chengshi = DropDownList2.SelectedItem.Text;//城市 //Odata.Diqu = DropDownList3.SelectedItem.Text;//地区 //Odata.Delivery = DataConverter.CLng(Request.Form["Delivery"]); //Odata.Deliverytime = DataConverter.CLng(this.Deliverytime.Text); //Odata.Mobile = receMod.MobileNum; #endregion M_OrderList Odata = new M_OrderList(); Odata.Ordertype = OrderHelper.GetOrderType(ProClass); Odata.OrderNo = B_OrderList.CreateOrderNo((M_OrderList.OrderEnum)Odata.Ordertype); Odata.StoreID = Convert.ToInt32(dr["StoreID"]); cartDT.DefaultView.RowFilter = "StoreID=" + Odata.StoreID; DataTable storeCartDT = cartDT.DefaultView.ToTable(); switch (ProClass)//旅游机票等,以联系人信息为地址 { case 7: case 8: M_Cart_Travel model = JsonConvert.DeserializeObject <M_Cart_Travel>(storeCartDT.Rows[0]["Additional"].ToString()); M_Cart_Contract user = model.Contract[0]; Odata.Receiver = user.Name; Odata.Reuser = user.Name; Odata.Phone = user.Mobile; Odata.MobileNum = user.Mobile; Odata.Email = user.Email; break; default: if (Address_Div.Visible) { Odata.Receiver = receMod.ReceivName; Odata.Reuser = receMod.ReceivName; Odata.Phone = receMod.phone; Odata.MobileNum = receMod.MobileNum; Odata.Email = receMod.Email; Odata.Shengfen = receMod.Provinces; Odata.Jiedao = receMod.Street; Odata.ZipCode = receMod.Zipcode; } break; } Odata.Invoiceneeds = DataConverter.CLng(Request.Form["invoice_rad"]);//是否需开发票 Odata.Invoice = Odata.Invoiceneeds == 0 ? "" : InvoTitle_T.Text + "||" + Invoice_T.Text; Odata.Rename = mu.UserName; Odata.Outstock = 0; //缺货处理 Odata.Ordermessage = ORemind_T.Text; //订货留言 Odata.Merchandiser = ""; //跟单员 Odata.Internalrecords = ""; //内部记录 Odata.IsCount = false; //-----金额计算 Odata.Balance_price = GetTotalMoney(storeCartDT); Odata.Freight = GetFarePrice(storeCartDT, Odata.StoreID); //运费计算 Odata.Ordersamount = Odata.Balance_price + Odata.Freight; //订单金额 Odata.AllMoney_Json = orderCom.GetTotalJson(storeCartDT); //附加需要的虚拟币 Odata.Specifiedprice = Odata.Ordersamount; //订单金额; Odata.Receivablesamount = 0; //收款金额 Odata.Developedvotes = 0; Odata.OrderStatus = (int)M_OrderList.StatusEnum.Normal; //订单状态 Odata.Paymentstatus = (int)M_OrderList.PayEnum.NoPay; //付款状态 Odata.StateLogistics = 0; //物流状态 Odata.Signed = 0; //签收 Odata.Settle = 0; //结清 Odata.Aside = 0; //作废 Odata.Suspended = 0; //暂停 Odata.AddUser = mu.UserName;; Odata.Userid = mu.UserID; Odata.Integral = DataConverter.CLng(Request.QueryString["jifen"]); Odata.Freight_remark = " "; Odata.Balance_remark = ""; Odata.Promoter = 0; Odata.id = orderBll.Adds(Odata); cartProBll.CopyToCartPro(mu, storeCartDT, Odata.id); orderList.Add(Odata); orderCom.SendMessage(Odata, null, "ordered"); } cartBll.DelByids(ids); //-----------------订单生成后处理 //进行减库存等操作 foreach (DataRow dr in cartDT.Rows) { M_Product model = proBll.GetproductByid(Convert.ToInt32(dr["Proid"])); model.Stock = model.Stock - DataConvert.CLng(dr["Pronum"]); SqlHelper.ExecuteSql("Update ZL_Commodities Set Stock=" + model.Stock + " Where ID=" + model.ID); } //生成支付单,处理优惠券,并进入付款步骤 M_Payment payMod = payBll.CreateByOrder(orderList); //优惠券 if (!string.IsNullOrEmpty(Arrive_Hid.Value)) { M_Arrive avMod = avBll.SelModelByFlow(Arrive_Hid.Value, mu.UserID); double money = payMod.MoneyPay; string err = ""; string remind = "支付单抵扣[" + payMod.PayNo + "]"; if (avBll.U_UseArrive(avMod, mu.UserID, ref money, ref err, remind)) { payMod.MoneyPay = money; payMod.ArriveMoney = avMod.Amount; payMod.ArriveDetail = avMod.ID.ToString(); } else { payMod.ArriveDetail = "优惠券[" + avMod.ID + "]异常 :" + err; } } //积分处理 if (point_body.Visible && DataConvert.CLng(Point_T.Text) > 0) { int point = DataConvert.CLng(Point_T.Text); int maxPoint = (int)((SiteConfig.ShopConfig.PointRatiot * 0.01) * (double)payMod.MoneyPay / SiteConfig.ShopConfig.PointRate); //if (point <= 0) { function.WriteErrMsg("积分数值不正确"); } if (point > mu.UserExp) { function.WriteErrMsg("您的积分不足!"); } if (point > maxPoint) { function.WriteErrMsg("积分不能大于可兑换金额!"); } //生成支付单时扣除用户积分 buser.ChangeVirtualMoney(mu.UserID, new M_UserExpHis() { ScoreType = (int)M_UserExpHis.SType.Point, score = -point, detail = "积分抵扣,支付单号:" + payMod.PayNo }); payMod.MoneyPay = payMod.MoneyPay - (point * SiteConfig.ShopConfig.PointRate); payMod.UsePoint = point; } if (payMod.MoneyPay <= 0) { payMod.MoneyPay = 0.01; } payMod.Remark = cartDT.Rows.Count > 1 ? "[" + cartDT.Rows[0]["ProName"] as string + "]等" : cartDT.Rows[0]["ProName"] as string; payMod.PaymentID = payBll.Add(payMod); Response.Redirect("/PayOnline/Orderpay.aspx?PayNo=" + payMod.PayNo); }
/// <summary> /// 检测优惠券是否可用,用于订单生成页 /// </summary> /// <param name="flow"></param> /// <param name="cartdt">购买的商品列表</param> /// <param name="money">商品累计金额(cartdt)</param> /// <returns>优惠后的金额,不能使用的原因,是否可使用</returns> public M_Arrive_Result U_CheckArrive(M_Arrive model, int uid, DataTable cartdt, double money) { M_Arrive_Result retMod = new M_Arrive_Result(); retMod.flow = model.Flow; retMod.money = money; if (model == null) { retMod.err = "指定的优惠券不存在"; } else if (model.UserID != uid) { retMod.err = "优惠券与用户不匹配"; } else if (uid < 1) { retMod.err = "用户信息不正确"; } else if (model.State == 10) { retMod.err = "优惠券已被使用"; } else if (model.State == 0) { retMod.err = "优惠券尚未激活"; } else if (model.Amount < 1) { retMod.err = "优惠券金额异常[" + model.Amount + "]"; } else if (model.EndTime < DateTime.Now) { retMod.err = "优惠券已过期"; } else if (model.AgainTime > DateTime.Now) { retMod.err = "优惠券尚未到可使用时段"; } if (!string.IsNullOrEmpty(retMod.err)) { return(retMod); } model.MaxAmount = model.MaxAmount == 0 ? 5000000 : model.MaxAmount; if (model.MinAmount > money) { retMod.err = "未达到最小金额使用限制"; return(retMod); } else if (model.MaxAmount < money) { retMod.err = "超过最大金额使用限制"; return(retMod); } //检测是否限定了店铺(商品必须全部属于同一店铺) if (model.StoreID != -100) { if (cartdt.Select("StoreID NOT IN ('" + model.StoreID + "')").Length > 0) { retMod.err = "优惠卷不可用于该店铺"; return(retMod); } } //------------------------------------------------------------------------ #region 如指定了商品,则需要进行商品检测,优惠金额也只限于指定的商品,不可超过上限,直接返回 if (!string.IsNullOrEmpty(model.ProIDS)) { cartdt.DefaultView.RowFilter = "ProID IN (" + StrHelper.PureIDSForDB(model.ProIDS) + ")"; DataTable prodt = cartdt.DefaultView.ToTable(); if (prodt.Rows.Count < 1) { retMod.err = "没有符合该优惠卷的商品"; return(retMod); } double promoney = DataConvert.CDouble(prodt.Compute("SUM(AllMoney)", "")); if (model.MinAmount > promoney) { retMod.err = "指定商品未达到最小金额使用限制"; } else if (model.MaxAmount < promoney) { retMod.err = "指定商品超过最大金额使用限制"; } else { //优惠的金额不可超过指定商品的上限,即以小的为准 double amount = model.Amount <= promoney ? model.Amount : promoney; money = money - amount; money = money < 0 ? 0 : money; retMod.money = money; retMod.amount = amount; retMod.enabled = true; return(retMod); } } #endregion else //正常使用优惠卷 { money = money - model.Amount; money = money < 0 ? 0 : money; retMod.money = money; retMod.amount = model.Amount; retMod.enabled = true; return(retMod); } return(retMod); }
public int GetInsert(M_Arrive model) { return(DBCenter.Insert(model)); }
public void ProcessRequest(HttpContext context) { M_UserInfo mu = buser.GetLogin(); retMod.retcode = M_APIResult.Failed; string cartCookID = GetCartCookID(context); //retMod.callback = CallBack;//暂不开放JsonP try { switch (Action) { case "deladdress": { B_UserRecei receBll = new B_UserRecei(); int id = DataConverter.CLng(Req("id")); if (mu == null || mu.UserID == 0 || id < 1) { OldRep("-1"); } else { receBll.U_DelByID(id, mu.UserID); OldRep("1"); } } break; case "setnum": //ID,数量,Cookies,可不登录,数量不能小于1 { int id = DataConverter.CLng(Req("mid")); int pronum = DataConverter.CLng(Req("pronum")); if (id < 1 || pronum < 1 || string.IsNullOrEmpty(cartCookID)) { OldRep("-1"); } else { cartBll.UpdateProNum(cartCookID, mu.UserID, id, pronum); OldRep("1"); } } break; case "arrive": { B_Arrive avBll = new B_Arrive(); string flow = Req("flow"); double money = double.Parse(Req("money")); string err = ""; M_Arrive avMod = avBll.SelModelByFlow(flow, mu.UserID); if (avBll.U_CheckArrive(avMod, mu.UserID, ref money, ref err)) { retMod.retcode = M_APIResult.Success; //已优惠金额,优惠后金额 retMod.result = "{\"amount\":\"" + avMod.Amount + "\",\"money\":\"" + money + "\"}"; } else { retMod.retmsg = err; } } break; default: retMod.retmsg = "[" + Action + "]接口不存在"; break; } } catch (Exception ex) { retMod.retmsg = ex.Message; } RepToClient(retMod); }
public ContentResult OrderCom() { M_APIResult retMod = new M_APIResult(M_APIResult.Failed); switch (action) { case "cart_del": { cartBll.DelByIDS(CartCookID, buser.GetLogin().UserName, ids); retMod.retcode = M_APIResult.Success; } break; case "setnum": //兼容 case "cart_setnum": //ID,数量,Cookies,可不登录,数量不能小于1 { int id = DataConverter.CLng(GetParam("id")); int pronum = DataConverter.CLng(GetParam("pronum")); if (id < 1 || pronum < 1) { retMod.retmsg = "商品ID与数量不能小于1"; } else if (string.IsNullOrEmpty(CartCookID)) { retMod.retmsg = "CartCookID不存在"; } else { cartBll.UpdateProNum(CartCookID, mu.UserID, id, pronum); retMod.retcode = M_APIResult.Success; } } break; case "deladdress": { int id = DataConverter.CLng(GetParam("id")); if (mu == null || mu.UserID == 0 || id < 1) { return(Content(Failed.ToString())); } else { receBll.U_DelByID(id, mu.UserID); return(Content(Success.ToString())); } } case "arrive": { string flow = GetParam("flow"); double money = double.Parse(GetParam("money")); DataTable cartdt = cartBll.SelByCartID(CartCookID, mu.UserID, -100, ids); if (cartdt.Rows.Count < 1) { retMod.retmsg = "购物车为空"; return(Content(retMod.ToString())); } M_Arrive avMod = avBll.SelModelByFlow(flow, mu.UserID); M_Arrive_Result arrMod = avBll.U_CheckArrive(avMod, mu.UserID, cartdt, money); if (arrMod.enabled) { retMod.retcode = M_APIResult.Success; //已优惠金额,优惠后金额 retMod.result = Newtonsoft.Json.JsonConvert.SerializeObject(arrMod); } else { retMod.retmsg = arrMod.err; } } break; default: retMod.retmsg = "[" + action + "]接口不存在"; break; } return(Content(retMod.ToString())); }
//制作抵用劵 protected void EBtnSubmit_Click(object sender, EventArgs e) { M_Arrive avMod = new M_Arrive(); if (Mid > 0) { avMod = avBll.SelReturnModel(Mid); } avMod.ArriveName = txtName.Text; avMod.MinAmount = DataConverter.CDouble(minAmount_T.Text); avMod.MaxAmount = DataConverter.CDouble(maxAmount_T.Text); avMod.AgainTime = DataConverter.CDate(AgainTime_T.Text); avMod.EndTime = DataConverter.CDate(EndTime_T.Text); avMod.Amount = DataConverter.CDouble(Amount_T.Text); avMod.Type = DataConverter.CLng(Magclass.SelectedItem.Value); if (avMod.EndTime <= DateTime.Now) { function.WriteErrMsg("到期时间不能早于当前时间"); } if (avMod.AgainTime >= avMod.EndTime) { function.WriteErrMsg("到期时间不能晚于发布时间"); } if (avMod.MaxAmount < 0 || avMod.MinAmount < 0) { function.WriteErrMsg("使用范围数值不正确"); } if (avMod.MaxAmount != 0 && avMod.MinAmount > avMod.MaxAmount) { function.WriteErrMsg("使用范围不正确,最小值不能大于最大值"); } if (avMod.Amount < 1) { function.WriteErrMsg("优惠金额不正确,最小值为1"); } //---------------------------------------- if (avMod.ID < 1)//添加优惠券 { avMod.Flow = Guid.NewGuid().ToString(); int num = DataConverter.CLng(txtCreateNum.Text); for (int i = 0; i < num; i++) { switch (EcodeType.SelectedItem.Value) { case "0": //纯数字 avMod.ArriveNO = function.GetRandomString(9, 2); break; case "1": //字母 avMod.ArriveNO = "ZL" + function.GetRandomString(9, 3).ToLower(); break; case "2": //混淆 avMod.ArriveNO = "ZL" + function.GetRandomString(9, 3).ToLower(); break; default: break; } avMod.ArrivePwd = "ZL" + function.GetRandomString(9); avMod.State = isValid_Chk.Checked ? 1 : 0; avMod.UserID = 0; avBll.GetInsert(avMod); } function.WriteSuccessMsg("批量添加成功!", "ArriveManage.aspx?name=" + avMod.ArriveName); } else { avMod.ArriveNO = txtNo.Text; avMod.ArrivePwd = txtPwd.Text; avMod.State = txtState.Text == "未使用" ? 0 : 1; avMod.UserID = DataConverter.CLng(hfid.Value); avBll.GetUpdate(avMod); function.WriteSuccessMsg("修改成功!", "ArriveManage.aspx"); } }