//-------------------附加币价格判断 public static string GetPriceStr(double price, object price_obj) { if (!HasPrice(price_obj)) //无附加商品价 { return(price.ToString("f2")); } string price_json = price_obj.ToString(); string html = "现金:<span>" + price.ToString("f2") + "</span>"; if (HasPrice(price_json)) { string json = DataConvert.CStr(price_json); M_LinPrice priceMod = JsonConvert.DeserializeObject <M_LinPrice>(json); if (priceMod.Purse > 0) { html += "|余额:<span>" + priceMod.Purse.ToString("f2") + "</span>"; } if (priceMod.Sicon > 0) { html += "|银币:<span>" + priceMod.Sicon.ToString("f0") + "</span>"; } if (priceMod.Point > 0) { html += "|积分:<span>" + priceMod.Point.ToString("f0") + "</span>"; } } return(html); }
/// <summary> /// 是否有附加商品价True:有 /// </summary> public static bool HasPrice(object obj) { if (obj == null || obj == DBNull.Value || string.IsNullOrEmpty(obj.ToString())) { return(false); } string json = DataConvert.CStr(obj); M_LinPrice priceMod = JsonConvert.DeserializeObject <M_LinPrice>(json); return(priceMod.Purse > 0 || priceMod.Sicon > 0 || priceMod.Point > 0); }
//附加金额 public bool HasPrice(object obj) { string json = DataConvert.CStr(obj); if (string.IsNullOrEmpty(json)) { return(false); } M_LinPrice priceMod = JsonConvert.DeserializeObject <M_LinPrice>(json); return(priceMod.Purse > 0 || priceMod.Sicon > 0 || priceMod.Point > 0); }
//根据订单表,计算并返回总金额 public string GetTotalJson(DataTable dt)//可传订单表或购物车表 { M_LinPrice totalMod = new M_LinPrice(); foreach (DataRow dr in dt.Rows) { if (HasPrice(dr["AllMoney_Json"])) { M_LinPrice priceMod = JsonConvert.DeserializeObject <M_LinPrice>(DataConvert.CStr(dr["AllMoney_Json"])); totalMod.Purse += priceMod.Purse; totalMod.Sicon += priceMod.Sicon; totalMod.Point += priceMod.Point; } } return(JsonConvert.SerializeObject(totalMod)); }
//小计 public string GetPrice() { M_Product proMod = proBll.GetproductByid(Convert.ToInt32(Eval("ProID"))); //string field = "LinPrice"; int pronum = Convert.ToInt32(Eval("Pronum")); double price = proBll.P_GetByUserType(proBll.GetproductByid(Convert.ToInt32(Eval("ProID"))), buser.GetLogin()); if (price <= 0) { M_LinPrice priceMod = JsonConvert.DeserializeObject <M_LinPrice>(proMod.LinPrice_Json); price = priceMod.Point; } double total = price * pronum; return(total.ToString("0.00")); }
public void OrdersCheck(M_OrderList orderMod) { if (orderMod == null) { function.WriteErrMsg(orderMod.OrderNo + "订单不存在"); } if (orderMod.OrderStatus < (int)M_OrderList.OrderEnum.Normal) { function.WriteErrMsg(orderMod.OrderNo + "订单状态异常,无法完成支付"); } if (orderMod.Ordersamount <= 0) { if (!string.IsNullOrEmpty(orderMod.AllMoney_Json)) { M_LinPrice priceMod = JsonConvert.DeserializeObject <M_LinPrice>(orderMod.AllMoney_Json); if (priceMod.Point <= 0) { function.WriteErrMsg(orderMod.OrderNo + "订单应付金额异常"); } else { PayPlat_RPT.Visible = false; virtual_ul.Visible = false; BtnSubmit.Visible = false; PoinPay_Btn.Visible = true; } } } if (orderMod.Paymentstatus != (int)M_OrderList.PayEnum.NoPay) { function.WriteErrMsg(orderMod.OrderNo + "订单已支付过,不能重复付款!"); } //配置文件,开放性检测 if (SiteConfig.ShopConfig.IsCheckPay == 1 && orderMod.OrderStatus == (int)M_OrderList.OrderEnum.Normal) { function.WriteErrMsg(orderMod.OrderNo + "订单未确认,请等待确认后再支付!"); } if (SiteConfig.ShopConfig.OrderExpired > 0 && (DateTime.Now - orderMod.AddTime).TotalHours > SiteConfig.ShopConfig.OrderExpired) { function.WriteErrMsg(orderMod.OrderNo + "订单已过期,关闭支付功能!"); } //if (orderMod.Ordertype == 8)//需要检测库存的商品,如有任意一项不足,则订单不允许进行,主用于云购 //{ // if (!cartProBll.CheckStock(orderMod.id)) function.WriteErrMsg(orderMod.OrderNo + "中的商品库存数量不足,取消购买"); //} }
//附加货币计算 public string GetAllMoney_Json() { string json = DataConvert.CStr(Eval("AllMoney_Json")); string html = ""; if (orderCom.HasPrice(json)) { M_LinPrice priceMod = JsonConvert.DeserializeObject <M_LinPrice>(json); if (priceMod.Purse > 0) { html += "<br />余额:<span class='purse_sp'>" + priceMod.Purse.ToString("f2") + "</span>"; } if (priceMod.Sicon > 0) { html += "|银币:<span class='sicon_sp'>" + priceMod.Sicon.ToString("f0") + "</span>"; } if (priceMod.Point > 0) { html += "|积分:<span class='point_sp'>" + priceMod.Point.ToString("f0") + "</span>"; } } return(html); }
//单价 public string GetMyPrice() { string linprice = Convert.ToDouble(Eval("LinPrice")).ToString("f2"); string html = "<i class='fa fa-rmb'></i><span id='price_" + Eval("ID") + "'>" + linprice + "</span>"; if (orderCom.HasPrice(Eval("LinPrice_Json"))) { string json = DataConvert.CStr(Eval("LinPrice_Json")); M_LinPrice priceMod = JsonConvert.DeserializeObject <M_LinPrice>(json); if (priceMod.Purse > 0) { html += "余额:<span id='price_purse_" + Eval("ID") + "'>" + priceMod.Purse.ToString("f2") + "</span>"; } if (priceMod.Sicon > 0) { html += "|银币:<span id='price_sicon_" + Eval("ID") + "'>" + priceMod.Sicon.ToString("f0") + "</span>"; } if (priceMod.Point > 0) { html += "|积分:<span id='price_point_" + Eval("ID") + "'>" + priceMod.Point.ToString("f0") + "</span>"; } } return(html); }