/// <summary> /// Create a new CouPon object. /// </summary> /// <param name="couPon_ID">Initial value of CouPon_ID.</param> public static CouPon CreateCouPon(int couPon_ID) { CouPon couPon = new CouPon(); couPon.CouPon_ID = couPon_ID; return couPon; }
public ActionResult OrderDetails(string id) { string hotelId = id; string key = HotelCloud.Common.HCRequest.GetString("key"); //"酒店微信id@用户微信id" string weixinid = HotelCloud.Common.HCRequest.GetString("weixinID"); //酒店微信id string userweixinid = ""; if (!key.Equals("") && key.Contains("@")) { weixinid = key.Split('@')[0];//酒店微信id userweixinid = key.Split('@')[1]; } //计算订单总金额 var shoppingCarDataTable = cartService.GetDataByUserId(id, userweixinid); double sum = 0; decimal canCouponSum = 0; int needPoints = 0; int canPoints = 1; foreach (DataRow data in shoppingCarDataTable.Rows) { sum += double.Parse(data["Price"].ToString()) * int.Parse(data["Total"].ToString()); if (int.Parse(data["CanCouPon"].ToString()) == 1) { canCouponSum += decimal.Parse(data["Price"].ToString()) * int.Parse(data["Total"].ToString()); } if (int.Parse(data["CanPurchase"].ToString()) == 0) { canPoints = 0; } else { needPoints += int.Parse(data["PurchasePoints"].ToString()) * int.Parse(data["Total"].ToString()); } } ViewData["NoExpressAmount"] = sum; ViewData["canPoints"] = canPoints; ViewData["needPoints"] = needPoints; ViewData["myPoints"] = 0; var userDt = orderService.GetScoreByUser(weixinid, userweixinid); if (userDt.Rows.Count > 0) { ViewData["myPoints"] = userDt.Rows[0]["Emoney"]; } //获取收货地址 List <OrderAddress> list = DishOrderLogic.GetAddressList(userweixinid); OrderAddress address = list.Find(a => a.isSelected == true); ViewData["ExpressFee"] = 0; ViewData["hotelName"] = DishOrderLogic.GetHotelName(hotelId); ViewData["addressRoomNo"] = ""; if (address != null) { var hotelData = SupermarketController.GetHotelBySupermarket(int.Parse(id)).Rows[0]; ViewData["ExpressFee2"] = hotelData["expressfee"]; if (address.addressType == 1) { ViewData["addressType"] = "酒店"; ViewData["addressName"] = address.Address + address.RoomNo; ViewData["addressRoomNo"] = address.RoomNo; ViewData["ExpressFee"] = 0; } else { ViewData["addressType"] = "快递"; ViewData["addressName"] = address.kuaidiAddress; try { ViewData["ExpressFee"] = hotelData["expressfee"]; ViewData["hotelPhone"] = hotelData["tel"]; sum += double.Parse(hotelData["expressfee"].ToString()); } catch (Exception e) { ViewData["ExpressFee"] = 0; ViewData["hotelPhone"] = ""; } } ViewData["Address"] = address; ViewData["OriginAddressType"] = address.addressType; } else { ViewData["Address"] = new OrderAddress(); ViewData["addressType"] = "酒店"; ViewData["hotelPhone"] = ""; ViewData["addressName"] = ViewData["hotelName"]; ViewData["OriginAddressType"] = 1; } //获取可用红包 var couponDataTable = CouPon.GetUserCouPonDataTable(weixinid, userweixinid, "3"); ViewData["couponDataTable"] = new DataTable(); ViewData["canCouponSum"] = canCouponSum; if (couponDataTable.Rows.Count > 0 && canCouponSum > 0) { ViewData["couponDataTable"] = couponDataTable; //var q1 = from dt1 in couponDataTable.AsEnumerable()//查询 // //orderby dt1.Field<int>("ID") descending//排序 // where dt1.Field<decimal>("amountlimit") <= canCouponSum//条件 // select dt1; //if (q1.Count() > 0) //{ // ViewData["couponDataTable"] = q1.CopyToDataTable<DataRow>(); //} } //获取积分 ViewData["orderScore"] = 0; ViewData["equivalence"] = 1; ViewData["GradePlus"] = 1; MemberInfo Info = MemberHelper.GetMemberInfo(weixinid); string cardno = MemberHelper.GetCardNo(userweixinid, weixinid); if (!string.IsNullOrEmpty(cardno)) { MemberCard MyCard = MemberHelper.GetMemberCard(cardno, weixinid); MemberCardIntegralRule IntegralRule = MemberHelper.IntegralRule(Info, MyCard); var score = sum; if (IntegralRule.equivalence > 0) { score = score * IntegralRule.equivalence; ViewData["equivalence"] = IntegralRule.equivalence; } if ((double)IntegralRule.GradePlus > 0) { score = score * (double)IntegralRule.GradePlus; ViewData["GradePlus"] = IntegralRule.GradePlus; } ViewData["orderScore"] = Math.Floor(Math.Round(score, 2)); } ViewData["shoppingCarDataTable"] = shoppingCarDataTable; ViewData["amount"] = sum; ViewData["hotelId"] = id; ViewData["weixinid"] = weixinid; ViewData["userweixinid"] = userweixinid; return(View()); }
/// <summary> /// There are no comments for CouPon in the schema. /// </summary> public void AddToCouPon(CouPon couPon) { base.AddObject("CouPon", couPon); }