/// <summary> /// 生成充值订单 /// </summary> public void CreateMoneyOrder() { decimal money = RequestTool.RequestDecimal("RMoney", 0); if (money == 0) { Response.Write("{\"msg\":\"" + Tag("充值金额必须大于0") + "\"}"); return; } Lebi_Currency DefaultCurrency = B_Lebi_Currency.GetModel("IsDefault=1"); if (DefaultCurrency == null) { DefaultCurrency = B_Lebi_Currency.GetList("", "Sort desc").FirstOrDefault(); } int onlinepay_id = RequestTool.RequestInt("onlinepay_id"); int pay_id = RequestTool.RequestInt("Pay_id"); int paytype = RequestTool.RequestInt("paytype"); //Lebi_MoneyOrder order = new Lebi_MoneyOrder(); //order.Code = "M" + Shop.Bussiness.Order.CreateOrderCode(); //order.Money = money; //order.User_id = CurrentUser.id; //order.User_UserName = CurrentUser.UserName; //order.IsPaid = 0; //order.Currency_Code = DefaultCurrency.Code; //order.Currency_ExchangeRate = DefaultCurrency.ExchangeRate; //order.Currency_id = DefaultCurrency.id; //order.Currency_Msige = DefaultCurrency.Msige; //B_Lebi_MoneyOrder.Add(order); Lebi_Order order = new Lebi_Order(); order.Code = "M" + Shop.Bussiness.Order.CreateOrderCode(); order.Money_Order = money; order.Money_Pay = money; order.User_id = CurrentUser.id; order.User_UserName = CurrentUser.UserName; order.IsPaid = 0; order.Currency_Code = DefaultCurrency.Code; order.Currency_ExchangeRate = DefaultCurrency.ExchangeRate; order.Currency_id = DefaultCurrency.id; order.Currency_Msige = DefaultCurrency.Msige; order.Type_id_OrderType = 214; Lebi_Pay pay = B_Lebi_Pay.GetModel(pay_id); if (paytype == 0) { Lebi_OnlinePay onlinepay = B_Lebi_OnlinePay.GetModel(onlinepay_id); if (onlinepay == null) { onlinepay = new Lebi_OnlinePay(); } order.OnlinePay_id = onlinepay.id; order.OnlinePay = onlinepay.Name; pay = B_Lebi_Pay.GetModel("Code='OnlinePay'"); } if (pay == null) { pay = new Lebi_Pay(); } order.Pay_id = pay.id; order.Pay = pay.Name; order.Site_id = CurrentSite.id; order.Language_id = CurrentLanguage.id; B_Lebi_Order.Add(order); order.id = B_Lebi_Order.GetMaxId(); Response.Write("{\"msg\":\"OK\",\"id\":\"" + order.id + "\",\"code\":\"" + order.Code + "\",\"url\":\"" + URL("P_Pay", order.id + "," + order.Code) + "\"}"); }
/// <summary> /// 生成退货单 /// </summary> public void torder_save() { int order_id = RequestTool.RequestInt("order_id", 0); string opid = RequestTool.RequestSafeString("opid"); if (opid == "") { Response.Write("{\"msg\":\"" + Tag("未选择任何商品") + "\"}"); return; } int count = 0; Lebi_Order order = B_Lebi_Order.GetModel(order_id); if (order == null) { Response.Write("{\"msg\":\"" + Tag("参数错误") + "\"}"); return; } if (order.User_id != CurrentUser.id) { Response.Write("{\"msg\":\"" + Tag("参数错误") + "\"}"); return; } List <Lebi_Order_Product> ops = B_Lebi_Order_Product.GetList("id in (lbsql{" + opid + "}) and Order_id=" + order.id + "", ""); foreach (Lebi_Order_Product op in ops) { int rcount = RequestTool.RequestInt("product_" + op.id, 0); if (rcount > (op.Count_Received - op.Count_Return)) { Response.Write("{\"msg\":\"" + Tag("退货数量不能大于收货数量") + "\"}"); return; } if (rcount < 1) { Response.Write("{\"msg\":\"" + Tag("退货数量不能小于1") + "\"}"); return; } count = count + rcount; } if (count == 0) { Response.Write("{\"msg\":\"" + Tag("参数错误") + "\"}"); return; } //CurrentUser.Count_Order = CurrentUser.Count_Order + 1; //B_Lebi_User.Update(CurrentUser); //foreach (Lebi_Order_Product op in ops) //{ // op.Count_Return = op.Count_Return + RequestTool.RequestInt("product_" + op.id, 0); // B_Lebi_Order_Product.Update(op); //} Lebi_Order model = new Lebi_Order(); model.Order_id = order.id; model.User_id = CurrentUser.id; model.User_UserName = CurrentUser.UserName; model.T_Name = order.T_Name; model.T_Address = order.T_Address; model.T_Area_id = order.T_Area_id; model.T_MobilePhone = order.T_MobilePhone; model.T_Phone = order.T_Phone; model.T_Postalcode = order.T_Postalcode; model.Weight = 0; model.Money_Product = 0; model.Type_id_OrderType = 212; model.Code = Shop.Bussiness.Order.CreateOrderCode(); model.Supplier_id = order.Supplier_id; model.Site_id = CurrentSite.id; model.Language_id = CurrentLanguage.id; B_Lebi_Order.Add(model); model.id = B_Lebi_Order.GetMaxId(); foreach (Lebi_Order_Product op in ops) { count = RequestTool.RequestInt("product_" + op.id, 0); op.Count_Return = op.Count_Return + count; B_Lebi_Order_Product.Update(op); op.Count = count; op.Count_Shipped = 0; op.Count_Received = 0; op.Order_Code = model.Code; op.Order_id = model.id; op.Money = op.Price * op.Count; B_Lebi_Order_Product.Add(op); model.Money_Product = model.Money_Product + (op.Price - op.Money_Give_one - op.Money_Card312_one) * count; model.Weight = model.Weight + op.Weight * count; model.Volume = model.Weight + op.Volume * count; model.Point = model.Point + op.Point_Give_one; } model.Money_Product = 0 - model.Money_Product; model.Money_Order = model.Money_Product; model.Money_Pay = model.Money_Product; model.Money_Give = 0 - model.Money_Order; model.Point = 0 - model.Point; B_Lebi_Order.Update(model); //处理留言 Lebi_Comment com = new Lebi_Comment(); com.Content = RequestTool.RequestSafeString("say"); com.Keyid = model.id; com.TableName = "Order"; com.User_id = CurrentUser.id; com.User_UserName = CurrentUser.UserName; B_Lebi_Comment.Add(com); Lebi_User user = B_Lebi_User.GetModel(CurrentUser.id); Lebi_Order ordermodel = B_Lebi_Order.GetModel("Order_id=" + order_id + ""); //发送邮件 if (ShopCache.GetBaseConfig().MailSign.ToLower().Contains("dingdantijiao") || ShopCache.GetBaseConfig().AdminMailSign.ToLower().Contains("ordersubmit")) { Email.SendEmail_ordersubmit(user, ordermodel); } //发送短信 if (ShopCache.GetBaseConfig().SMS_sendmode.Contains("SMSTPL_ordersubmit") || ShopCache.GetBaseConfig().SMS_sendmode.Contains("SMSTPL_Admin_ordersubmit")) { SMS.SendSMS_ordersubmit(user, order); } Response.Write("{\"msg\":\"OK\"}"); }