Esempio n. 1
0
        public void UpdateVIPBonus()
        {
            bool   HasUseBirthdayDiscount = false;
            int    Bonus     = 0;
            string vip_id    = string.IsNullOrEmpty(Request["vip_id"]) ? "" : Request["vip_id"];
            string LastBonus = string.IsNullOrEmpty(Request["LastBonus"]) ? "0" : Request["LastBonus"];

            bool.TryParse(Request["HasUseBirthdayDiscount"], out HasUseBirthdayDiscount);
            int.TryParse(LastBonus, out Bonus);
            bool BonusResult = VipMember.UpdateVipBonus(vip_id, Bonus, HasUseBirthdayDiscount);
            var  result      = new { result = BonusResult };

            ShowResultOnPage(JsonConvert.SerializeObject(result));
        }
Esempio n. 2
0
        public void ReturnePurchase(string OrderID, string PosNo, string ClerkID, string ReturnType)
        {
            string[] ItemNo        = JsonConvert.DeserializeObject <string[]>(Request["ItemNoList"]);
            int      AllowanceID   = 0;
            string   PaperReturnID = "";

            if (!string.IsNullOrEmpty(Request["AllowanceID"]))
            {
                AllowanceID = int.Parse(Request["AllowanceID"]);
            }

            //紙本刷退
            if (!string.IsNullOrEmpty(Request["PaperReturnID"]))
            {
                PaperReturnID = Request["PaperReturnID"];
            }

            bool      status = false;
            DataTable dt     = GetOrderInfo(OrderID);

            if (dt.Rows.Count > 0)
            {
                //判斷需不需要退回多少紅利
                int ReturnBonus = 0;
                int Amount      = 0;
                if (dt.Rows[0]["VIP"] != System.DBNull.Value)
                {
                    vip_id = dt.Rows[0]["VIP"].ToString();
                    //剩下要結帳的金額
                    int.TryParse(Request["Amount"].ToString(), out Amount);
                    int.TryParse(dt.Rows[0]["Amount"].ToString(), out ReturnBonus);
                    //前訂單的金額減掉這次訂單的金額等於要退還的紅利
                    ReturnBonus = ReturnBonus - Amount;
                }

                var aa = POS_Library.ShopPos.NoProduct.SetSalePackageBack(int.Parse(OrderID), _areaId, ClerkName);
                if (aa == true)
                {
                    Log.Add(0, OrderID, "5", "OrderStep:5,商品退回不可銷庫存完成", ClerkID, PosNo);

                    StringBuilder sb = new StringBuilder();
                    Dictionary <string, object> param = new Dictionary <string, object>();
                    //判斷有沒有折讓編號
                    if (AllowanceID == 0)
                    {
                        sb.Append("update Orders set Status=2,SyncedTime=null where OrderID=@OrderID; ");
                    }
                    else
                    {
                        sb.Append("update Orders set Status=6,SyncedTime=null where OrderID=@OrderID; ");
                        sb.Append("insert into PosClient..Allowances(OrderID,Year,Month,AllowanceID) values(@OrderID,@Year,@Month,@AllowanceID) ");
                        param.Add("Year", DateTime.Now.Year);
                        param.Add("Month", DateTime.Now.Month);
                        param.Add("AllowanceID", AllowanceID);
                    }


                    sb.Append("Insert into Returns(OrderID,Type,PosNo,ClerkID,ReturnTime) ");
                    sb.Append("values(@OrderID,@ReturnType,@PosNo,@ClerkID,GETDATE()); ");

                    //新增發票作廢,有可能會多張
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        sb.Append("Insert into NullifiedInvoices(PosNo,InvoiceNo,ClerkID,NullifiedTime)  ");
                        sb.Append(string.Format("values(@PosNo,@InvoiceNo{0},@ClerkID,getdate()); ", i));
                        param.Add("InvoiceNo" + i, dt.Rows[i]["InvoiceNo"].ToString());
                    }

                    param.Add("OrderID", OrderID);
                    param.Add("PosNo", PosNo);
                    param.Add("ClerkID", ClerkID);
                    param.Add("ReturnType", ReturnType);

                    //寫入紙本刷退紀錄
                    if (string.IsNullOrEmpty(PaperReturnID) == false)
                    {
                        sb.Append("Insert Into [PosClient]..[ReturnCreditCardPaper] (OrderID) values (@OrderID) ");
                        param.Add("PaperReturnID", PaperReturnID);
                    }

                    status = DB.DBNonQuery(sb.ToString(), param, "PosClient");

                    if (status)
                    {
                        #region 退紅利

                        //退紅利
                        if (ReturnBonus > 0)
                        {
                            MemberData MD    = VipMember.GetMemberData(vip_id, "");
                            int        Bonus = MD.bonus - ReturnBonus;
                            VipMember.UpdateVipBonus(vip_id, Bonus, false);
                        }
                        #endregion

                        if (ItemNo.Length > 0)
                        {
                            AddOrder();
                            return;
                        }
                    }
                }
                else
                {
                    status = aa;
                }
            }

            GetInvoiceNumber(PosNo);
            var result = new { result = status, NumberNow = InvoiceNumberNow, Remainder = InvoiceRemainder, OrderStep = 5 };
            ShowResultOnPage(JsonConvert.SerializeObject(result));
        }