示例#1
0
        public static M_Arrive_Result CheckArrive(string code, string pwd, double money)
        {
            M_Arrive_Result result = new M_Arrive_Result();

            if (string.IsNullOrEmpty(code))
            {
                result.err = "The coupon number cannot be empty";
            }
            //else if (string.IsNullOrEmpty(pwd))
            //{
            //    result.err = "The coupon password cannot be empty";
            //}
            else if (money < 1.0)
            {
                result.err = "Incorrect order amount";
            }
            B_Arrive avBll = new B_Arrive();
            M_Arrive avMod = SnsHelper.AV_SelModel(code);

            result.money = money;
            if (avMod == null || avMod.ID < 1)
            {
                result.err = "Coupon do not exist";
            }
            else if (avMod.State == 10)
            {
                result.err = "Coupon have been used";
            }
            else if (avMod.State == 0)
            {
                result.err = "Coupon have not been activated";
            }
            else if (avMod.Amount < 1.0)
            {
                result.err = "Abnormal value of coupon[" + avMod.Amount.ToString("N") + "]";
            }
            else if (avMod.EndTime < DateTime.Now)
            {
                result.err = "Coupon have expired";
            }
            else if (avMod.AgainTime > DateTime.Now)
            {
                result.err = "Coupon have not yet reached the available time";
            }
            if (!string.IsNullOrEmpty(result.err))
            {
                return(result);
            }
            result.flow     = avMod.Flow;
            avMod.MaxAmount = avMod.MaxAmount == 0 ? 5000000 : avMod.MaxAmount;
            if (avMod.MinAmount > money)
            {
                result.err = "No minimum amount of use limit";
                return(result);
            }
            if (avMod.MaxAmount < money)
            {
                result.err = "More than maximum use limit";
                return(result);
            }
            money         -= avMod.Amount;
            money          = ((money < 0.0) ? 0.0 : money);
            result.money   = money;
            result.amount  = avMod.Amount;
            result.enabled = true;
            return(result);
        }
示例#2
0
        public void ProcessRequest(HttpContext context)
        {
            M_UserInfo mu = buser.GetLogin();

            retMod.retcode = M_APIResult.Failed;
            string cartCookID = GetCartCookID(context);

            //retMod.callback = CallBack;//暂不开放JsonP
            try
            {
                switch (Action)
                {
                case "deladdress":
                {
                    B_UserRecei receBll = new B_UserRecei();
                    int         id      = DataConverter.CLng(Req("id"));
                    if (mu == null || mu.UserID == 0 || id < 1)
                    {
                        OldRep("-1");
                    }
                    else
                    {
                        receBll.U_DelByID(id, mu.UserID); OldRep("1");
                    }
                }
                break;

                case "setnum":    //ID,数量,Cookies,可不登录,数量不能小于1
                {
                    int id     = DataConverter.CLng(Req("mid"));
                    int pronum = DataConverter.CLng(Req("pronum"));
                    if (id < 1 || pronum < 1 || string.IsNullOrEmpty(cartCookID))
                    {
                        OldRep("-1");
                    }
                    else
                    {
                        cartBll.UpdateProNum(cartCookID, mu.UserID, id, pronum);
                        OldRep("1");
                    }
                }
                break;

                case "arrive":
                {
                    B_Arrive avBll = new B_Arrive();
                    string   flow  = Req("flow");
                    double   money = double.Parse(Req("money"));
                    string   err   = "";
                    M_Arrive avMod = avBll.SelModelByFlow(flow, mu.UserID);
                    if (avBll.U_CheckArrive(avMod, mu.UserID, ref money, ref err))
                    {
                        retMod.retcode = M_APIResult.Success;
                        //已优惠金额,优惠后金额
                        retMod.result = "{\"amount\":\"" + avMod.Amount + "\",\"money\":\"" + money + "\"}";
                    }
                    else
                    {
                        retMod.retmsg = err;
                    }
                }
                break;

                default:
                    retMod.retmsg = "[" + Action + "]接口不存在";
                    break;
                }
            }
            catch (Exception ex) { retMod.retmsg = ex.Message; }
            RepToClient(retMod);
        }