Beispiel #1
0
        //报单调用的类
        public void SaveHOrder(SqlTransaction tran, IList <MemberDetailsModel> list, MemberOrderModel memberOrderModel)
        {
            RegistermemberBLL RegistermemberBLL = new RegistermemberBLL();

            //添加对账单
            if (memberOrderModel.DefrayType == 2)
            {
                BLL.Logistics.D_AccountBLL.AddAccount(memberOrderModel.ElectronicaccountId, Convert.ToDouble(memberOrderModel.TotalMoney), D_AccountSftype.MemberType, D_AccountKmtype.Declarations, DirectionEnum.AccountReduced, "会员【" + memberOrderModel.Number + "】用会员【" + memberOrderModel.ElectronicaccountId + "】电子货币报单,订单号为【" + memberOrderModel.OrderId + "】", tran);
                BLL.Logistics.D_AccountBLL.AddAccount(memberOrderModel.StoreId, Convert.ToDouble(memberOrderModel.TotalMoney), D_AccountSftype.StoreType, D_AccountKmtype.AccountTransfer, DirectionEnum.AccountsIncreased, "会员【" + memberOrderModel.Number + "】用会员【" + memberOrderModel.ElectronicaccountId + "】电子货币报单转入,订单号为【" + memberOrderModel.OrderId + "】", tran);
                // 电子帐户支付
                IsElecPay(tran, memberOrderModel);
            }

            AddOrderDataDAL addOrderDataDAL = new AddOrderDataDAL();

            //插入memberOrder表
            addOrderDataDAL.INSERT_H_Order(memberOrderModel, tran);

            foreach (Model.MemberDetailsModel mDetails in list)
            {
                //插入订单明细
                addOrderDataDAL.insert_MemberOrderDetails(memberOrderModel, mDetails, tran);

                //未支付报单不算库存
                if (memberOrderModel.DefrayState == 1)
                {
                    //更新减去店库存
                    int result = 0;
                    result = addOrderDataDAL.updateStore(memberOrderModel.StoreId, mDetails, tran);

                    ////添加该类型的记录,用负数表示
                    if (result <= 0)
                    {
                        addOrderDataDAL.updateStore2(memberOrderModel.StoreId, mDetails, tran);
                    }
                }
            }

            if (memberOrderModel.DefrayState == 1)
            {
                //报单生成订单
                int     count      = 0;
                decimal totalMoney = 0;
                decimal totalPv    = 0;
                foreach (MemberDetailsModel mDetails in list)
                {
                    if (mDetails.NotEnoughProduct > 0)
                    {
                        totalMoney += mDetails.NotEnoughProduct * mDetails.Price;
                        totalPv    += mDetails.NotEnoughProduct * mDetails.Pv;
                        count++;
                    }
                }
                if (count > 0)
                {
                    string orderId = "";
                    orderId = BLL.Logistics.OrderGoodsBLL.GetNewOrderID();
                    //自动为店铺生成要货申请单
                    OrderGoodsMedel storeItem = GetOrderModel(orderId, memberOrderModel, tran, totalMoney, totalPv);
                    //插入要货申请单明细
                    OrderSubmit(memberOrderModel.OrderId.ToString(), list, storeItem, tran);
                }



                int sd = addOrderDataDAL.updateStoreL(tran, memberOrderModel.OrderId);



                //添加对账单
                if (memberOrderModel.DefrayType == 1 || memberOrderModel.DefrayType == 2)
                {
                    if (Convert.ToDouble(memberOrderModel.LackProductMoney) > 0)
                    {
                        BLL.Logistics.D_AccountBLL.AddAccount(memberOrderModel.StoreId, Convert.ToDouble(memberOrderModel.LackProductMoney), D_AccountSftype.StoreType, D_AccountKmtype.Declarations, DirectionEnum.AccountReduced, "会员【" + memberOrderModel.Number + "】报单现金扣除额,订单号为【" + memberOrderModel.OrderId + "】", tran);
                    }
                }


                //增加该店铺的总报单的费用(累计)
                addOrderDataDAL.updateStore3(memberOrderModel.StoreId, tran, Convert.ToDouble(memberOrderModel.LackProductMoney));
            }
        }