Exemple #1
0
        //根据换货单号更新店铺换货为已审
        public bool UpdateReplacement(string DisplaceOrderId, string storeOrderId, string refundmentOrderID, string storeID, int expectNum, string warehouseId, string depotSeatId)
        {
            bool state = false;

            double returnmoney = DisplaceGoodBrowseDAL.GetGoodsReturnMoney(DisplaceOrderId);

            using (SqlConnection conn = new SqlConnection(DBHelper.connString))
            {
                conn.Open();
                SqlTransaction tran = conn.BeginTransaction();
                try
                {
                    new DisplaceGoodBrowseDAL().UpdateReplacement(tran, DisplaceOrderId, storeOrderId, refundmentOrderID, storeID, expectNum, warehouseId, depotSeatId);

                    //添加对账单
                    if (returnmoney > 0)
                    {
                        D_AccountBLL.AddStoreAccount(storeID, Convert.ToDouble(returnmoney), D_AccountSftype.StoreDingHuokuan, S_Sftype.dianhuo, D_AccountKmtype.ReturnRebate, DirectionEnum.AccountsIncreased, refundmentOrderID, tran);
                    }
                    else if (returnmoney < 0)
                    {
                        D_AccountBLL.AddStoreAccount(storeID, Convert.ToDouble(returnmoney), D_AccountSftype.StoreDingHuokuan, S_Sftype.dianhuo, D_AccountKmtype.ReturnCharge, DirectionEnum.AccountReduced, refundmentOrderID, tran);
                    }
                    tran.Commit();
                    state = true;
                }
                catch
                {
                    tran.Rollback();
                    state = false;
                }
                finally
                {
                    conn.Close();
                }
            }
            return(state);
        }
Exemple #2
0
        /// <summary>
        /// 确认订单按钮
        /// </summary>
        /// <returns></returns>
        public Boolean CheckOutStoreOrder(IList <StoreOrderModel> orders, string storeid)
        {
            using (SqlConnection conn = new SqlConnection(DBHelper.connString))
            {
                conn.Open();                                 //打开连接
                SqlTransaction tr = conn.BeginTransaction(); //开启事务

                try
                {
                    decimal ordermoney = 0;
                    decimal turnmoney  = 0;
                    string  orderids   = "";
                    foreach (StoreOrderModel order in orders)
                    {
                        if (!StoreOrderDAL.GetIsCheckOut(tr, order.StoreorderId))            //判断该订单是否已经支付
                        {
                            if (StoreOrderDAL.UpdateOrderGoodsState(tr, order.StoreorderId)) //更改订单成已支付状态
                            {
                                orderids += order.StoreorderId + ";";
                                if (order.OrderType == 0)
                                {
                                    ordermoney += order.TotalMoney;
                                }
                                else if (order.OrderType == 1)
                                {
                                    turnmoney += order.TotalMoney;
                                }
                                if (!StockDAL.UpdateInWayCount(tr, OrderDetailDAL.GetOrderGoodsDetail(order.StoreorderId), storeid))//跟新店库存,添加在途数量,去除预定数量
                                {
                                    tr.Rollback();
                                    return(false);
                                }
                                if (!LogicProductInventoryDAL.UpdateToatlOut(tr, CommonDataBLL.GetNewOrderDetail(OrderDetailDAL.GetOrderGoodsDetail(order.StoreorderId))))//更新公司 逻辑库存
                                {
                                    tr.Rollback();
                                    return(false);
                                }
                            }
                            else
                            {
                                tr.Rollback();
                                return(false);
                            }
                        }
                    }

                    //添加对账单
                    D_AccountBLL.AddAccount(storeid, Convert.ToDouble(ordermoney), D_AccountSftype.StoreType, D_AccountKmtype.StoreOrderout, DirectionEnum.AccountReduced, "店铺【" + storeid + "】在线订货,订货款扣除额,订单号为【" + orderids + "】", tr);
                    //跟新店货款
                    if (!StoreInfoDAL.UpdateSomeMoney(tr, ordermoney, turnmoney, storeid))
                    {
                        tr.Rollback();
                        return(false);
                    }

                    tr.Commit();
                }
                catch
                {
                    tr.Rollback();
                    return(false);
                }
                finally
                {
                    conn.Close();
                }
            }
            return(true);
        }