/// <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\"}"); }