public static string AuditingOrder(string orderid) { string error = ""; //返回错误信息 MemberOrderModel mo = MemberOrderDAL.GetMemberOrder(orderid); //获取报单信息 List <MemberDetailsModel> list = ViewFuXiaoBLL.GetDetails(mo.OrderId); //获取订单明细 //判断报单是否支付 if (mo.DefrayState != 0) { return(BLL.Translation.Translate("000987", "报单不可重复确认"));// "报单不可重复确认!"; } //验证店铺钱是否够支付保单 double notEnoughmoney = new RegistermemberBLL().CheckMoneyIsEnough(list, mo.StoreId); double storeLeftMoney = new StoreDataDAL().GetLeftRegisterMemberMoney(mo.StoreId); if (storeLeftMoney < notEnoughmoney) { return(BLL.Translation.Translate("006018", "对不起,您的报单额不足!"));// "报单不可重复确认!"; } //更改--报单信息 mo.RemittancesId = MYDateTime.ToYYMMDDHHmmssString(); mo.DefrayState = 1; mo.PayExpect = CommonDataBLL.getMaxqishu(); //double notEnoughmoney = new RegistermemberBLL().CheckMoneyIsEnough(list, mo.StoreId); IList <MemberDetailsModel> listnew = CommonDataBLL.GetNewOrderDetail1(list); for (int i = 0; i < list.Count; i++) { int left = BLL.CommonClass.CommonDataBLL.GetLeftLogicProductInventory(Convert.ToInt32(listnew[i].ProductId)); if (left < listnew[i].Quantity) { return(BLL.Translation.Translate("005967", "对不起,公司库存不够") + "!" + listnew[i].ProductName + BLL.Translation.Translate("005970", "库存数只有") + ":" + left); } } //转化汇率 notEnoughmoney = new RegistermemberBLL().ChangeNotEnoughMoney(mo.StoreId, notEnoughmoney); double EnoughProductMoney = Convert.ToDouble(new RegistermemberBLL().getEnoughProductMoney(list, mo.StoreId)); mo.EnoughProductMoney = Convert.ToInt32(EnoughProductMoney); mo.LackProductMoney = Convert.ToInt32(notEnoughmoney); //拆分组合产品 IList <MemberDetailsModel> md = BLL.CommonClass.CommonDataBLL.GetNewOrderDetail1(list); System.Web.HttpContext.Current.Application.UnLock(); System.Web.HttpContext.Current.Application.Lock(); using (SqlConnection conn = new SqlConnection(DBHelper.connString)) { conn.Open(); SqlTransaction tran = conn.BeginTransaction(); try { //更新会员订单信息 if (!CommonDataBLL.ConfirmMembersOrder(tran, mo.OrderId, mo.PayExpect, mo.EnoughProductMoney, mo.LackProductMoney)) { tran.Rollback(); System.Web.HttpContext.Current.Application.UnLock(); return(BLL.Translation.Translate("000993", "确认失败")); } //更新店铺库存 foreach (MemberDetailsModel memberDetailsModel in list) { //循环根据订单明细跟新库存 int result = ViewFuXiaoBLL.UptStock(tran, memberDetailsModel.StoreId, memberDetailsModel.ProductId, memberDetailsModel.Quantity, memberDetailsModel.NotEnoughProduct); //如果该店铺无盖商品记录,则在店库存表中加记录 if (result <= 0) { new BrowseMemberOrdersBLL().updateStore2(memberDetailsModel, tran); } if (memberDetailsModel.NotEnoughProduct > 0) { if (!CommonDataBLL.ConfirmMembersDetails(tran, memberDetailsModel.ProductId, mo.OrderId, memberDetailsModel.NotEnoughProduct)) { tran.Rollback(); System.Web.HttpContext.Current.Application.UnLock(); return(BLL.Translation.Translate("000993", "确认失败")); } } } //处理公司逻辑库存 int sd = new DAL.AddOrderDataDAL().updateStoreL(tran, md); //报单生成订单 Insert_OrderGoods(list, mo, tran); if (mo.DefrayType == 1) { if (Convert.ToDouble(mo.LackProductMoney) > 0) { //记录对账单明细 BLL.Logistics.D_AccountBLL.AddAccount(mo.StoreId, Convert.ToDouble(mo.LackProductMoney), D_AccountSftype.StoreType, D_AccountKmtype.Declarations, DirectionEnum.AccountReduced, "会员【" + mo.Number + "】报单现金扣除额,订单号为【" + mo.OrderId + "】", tran); } } if (mo.DefrayType == 2) { //记录对账单明细 BLL.Logistics.D_AccountBLL.AddAccount(mo.ElectronicaccountId, Convert.ToDouble(mo.TotalMoney), D_AccountSftype.MemberType, D_AccountKmtype.Declarations, DirectionEnum.AccountReduced, "会员【" + mo.Number + "】用会员【" + mo.ElectronicaccountId + "】电子货币报单,订单号为【" + mo.OrderId + "】", tran); BLL.Logistics.D_AccountBLL.AddAccount(mo.StoreId, Convert.ToDouble(mo.TotalMoney), D_AccountSftype.StoreType, D_AccountKmtype.Declarations, DirectionEnum.AccountsIncreased, "会员【" + mo.Number + "】用会员【" + mo.ElectronicaccountId + "】电子货币报单转入,订单号为【" + mo.OrderId + "】", tran); if (Convert.ToDouble(mo.LackProductMoney) > 0) { BLL.Logistics.D_AccountBLL.AddAccount(mo.StoreId, Convert.ToDouble(mo.LackProductMoney), D_AccountSftype.StoreType, D_AccountKmtype.Declarations, DirectionEnum.AccountReduced, "会员【" + mo.Number + "】报单现金扣除额,订单号为【" + mo.OrderId + "】", tran); } //更新电子账户余额 AddOrderDataDAL.UpdateECTPay(tran, mo.ElectronicaccountId, mo.LackProductMoney); //更新店铺汇款 new AddOrderDataDAL().Add_Remittances(tran, Convert.ToDouble(mo.LackProductMoney), mo.StoreId); //插入汇款信息 new AddOrderDataDAL().AddDataTORemittances(tran, mo); } //更新店铺报单款 new AddOrderDataDAL().updateStore3(mo.StoreId, tran, Convert.ToDouble(mo.LackProductMoney)); //判断是否是注册的会员 if (mo.IsAgain == 0) { //获取会员信息 MemberInfoModel mi = MemberOrderDAL.GetMemberInfo(orderid, tran); //更新会员业绩,会员进入网络图 new AddOrderDataDAL().Upt_UpdateNew1(mi, tran); //激活会员 int resultActive = new GroupRegisterBLL().uptIsActive(mi.Number, tran); } //实时更新会员级别 CommonDataBLL.SetMemberLevel(tran, mo.Number, mo.OrderId); //提交事务 tran.Commit(); } catch (Exception ex) { string sga = ex.Message; error = BLL.Translation.Translate("000993", "确认失败");// "确认失败!"; tran.Rollback(); } finally { conn.Close(); conn.Dispose(); System.Web.HttpContext.Current.Application.UnLock(); } } return(error); }
/// <summary> /// 审核支付报单 /// </summary> /// <param name="orderid"> 报单编号 </param> /// <returns>是否审核成功</returns> public static string AuditingOrder(string orderid) { string error = ""; //返回错误信息 MemberOrderModel mo = MemberOrderDAL.GetMemberOrder(orderid); //获取报单信息 //判断报单是否支付 if (mo.DefrayState != 0) { return("报单不可重复确认!"); } //获得店铺不足货时可以报单的金额 if (mo.DefrayType == 2) { double emoney = new AddOrderDataDAL().HaveMoney(mo.ElectronicaccountId); if (Convert.ToDouble(mo.TotalMoney) > emoney) { return("电子账户余额不足,不能确认!"); } } //更改--报单信息 mo.RemittancesId = MYDateTime.ToYYMMDDHHmmssString(); mo.DefrayState = 1; mo.PayExpect = CommonDataBLL.getMaxqishu(); List <MemberDetailsModel> list = ViewFuXiaoBLL.GetDetails(mo.OrderId);//获取订单明细 using (SqlConnection conn = new SqlConnection(DBHelper.connString)) { conn.Open(); SqlTransaction tran = conn.BeginTransaction(); try { //更新会员订单信息 CommonDataBLL.ConfirmMembersOrder(tran, mo.OrderId, mo.PayExpect); //更新店铺库存 foreach (MemberDetailsModel memberDetailsModel in list) {//循环根据订单明细跟新库存 int result = ViewFuXiaoBLL.UptStock(tran, memberDetailsModel.StoreId, memberDetailsModel.ProductId, memberDetailsModel.Quantity, memberDetailsModel.NotEnoughProduct); //如果该店铺无盖商品记录,则在店库存表中加记录 if (result <= 0) { new BrowseMemberOrdersBLL().updateStore2(memberDetailsModel, tran); } } //更新店铺报单款 new AddOrderDataDAL().updateStore3(mo.StoreId, tran, Convert.ToDouble(mo.TotalMoney)); if (mo.DefrayType == 2) { //更新电子账户余额 AddOrderDataDAL.UpdateECTPay(tran, mo.ElectronicaccountId, mo.TotalMoney); //更新店铺汇款 new AddOrderDataDAL().Add_Remittances(tran, Convert.ToDouble(mo.TotalMoney), mo.StoreId); //插入汇款信息 new AddOrderDataDAL().AddDataTORemittances(tran, mo); } //更新会员业绩 new AddOrderDataDAL().Js_addfuxiao(mo.Number, Convert.ToDouble(mo.TotalPv), mo.PayExpect, mo.DefrayType, tran);//添加网络业绩 //插入订货单 AddOrderGoods(list, tran, mo); //提交事务 tran.Commit(); } catch { error = "确认失败!"; tran.Rollback(); } finally { conn.Close(); } } return(error); }