Exemple #1
0
        public static VCouponRule Parse(JObject ja)
        {
            VCouponRule vcr = new VCouponRule();

            vcr.couponname  = ja["couponname"].ToString();
            vcr.description = ja["description"].ToString();

            /*if (ja["begintime"] != null && ja["begintime"].ToString() != "")
             * {
             *  vcr.begintime = DateTime.Parse(ja["begintime"].ToString());
             * }
             * if (ja["endtime"] != null && ja["endtime"].ToString() != "")
             * {
             *  vcr.endtime = DateTime.Parse(ja["endtime"].ToString());
             * }
             * if (ja["inserttime"] != null && ja["inserttime"].ToString() != "")
             * {
             *  vcr.inserttime = DateTime.Parse(ja["inserttime"].ToString());
             * }*/

            vcr.ruleid   = ja["ruleid"].ToString();
            vcr.couponid = ja["couponid"].ToString();
            vcr.dishid   = ja["dishid"].ToString();
            vcr.banktype = ja["banktype"].ToString();
            if (vcr.banktype == "100")
            {
                vcr.dishnum = strtoint(ja["dishnum"].ToString());
            }
            else
            {
                vcr.dishnum = 20;
            }
            vcr.freedishid   = ja["freedishid"].ToString();
            vcr.freedishnum  = strtoint(ja["freedishnum"].ToString());
            vcr.couponway    = strtoint(ja["couponway"].ToString());
            vcr.comsumeway   = strtoint(ja["comsumeway"].ToString());
            vcr.couponrate   = strtodecimal(ja["couponrate"].ToString());
            vcr.couponamount = strtodecimal(ja["couponamount"].ToString());
            vcr.totalamount  = strtodecimal(ja["totalamount"].ToString());
            vcr.couponcash   = strtodecimal(ja["couponcash"].ToString());
            vcr.couponnum    = strtoint(ja["couponnum"].ToString());
            vcr.freeamount   = strtodecimal(ja["freeamount"].ToString());
            vcr.partnername  = ja["partnername"].ToString();
            vcr.groupweb     = ja["groupweb"].ToString();
            vcr.unitid       = ja["unitid"].ToString();
            vcr.wholesingle  = ja["wholesingle"].ToString();
            try
            {
                vcr.debitamount = strtodecimal(ja["debitamount"].ToString());
            }
            catch { vcr.debitamount = 0; }
            vcr.type     = strtoint(ja["type"].ToString());
            vcr.sub_type = "0";
            return(vcr);
        }
Exemple #2
0
        /// <summary>
        /// 新表结构转为对像
        /// </summary>
        /// <param name="ja"></param>
        /// <returns></returns>
        public static VCouponRule Parsev2(JObject ja)
        {
            VCouponRule vcr = new VCouponRule();

            try
            {
                vcr.couponname = ja["name"].ToString();
            }
            catch
            {
                try
                {
                    vcr.couponname = ja["free_reason"].ToString();
                }
                catch { vcr.couponname = ja["couponname"].ToString(); }
            }
            vcr.FreeReason = ja["free_reason"] != null ? ja["free_reason"].ToString() : null;
            //vcr.couponname = ja["name"].ToString();//couponname
            if (vcr.couponname.Equals(""))
            {
                try
                { vcr.couponname = ja["company_name"].ToString(); }
                catch { }
            }
            try
            {
                vcr.description = ja["activity_introduction"].ToString();//description
            }
            catch { vcr.description = ""; }

            vcr.Color    = ja["color"] != null ? ja["color"].ToString() : null;
            vcr.ruleid   = ja["id"].ToString();           //ruleid
            vcr.couponid = ja["preferential"].ToString(); //couponid
            try
            { vcr.dishid = ja["dish"].ToString(); } //dishid
            catch { }
            try
            {
                vcr.banktype = ja["type"].ToString(); //banktype
            }
            catch { vcr.banktype = "06"; }

            if (vcr.banktype == "100")
            {
                vcr.dishnum = strtoint(ja["dishnum"].ToString());
            }
            else
            {
                vcr.dishnum = 20;
            }
            vcr.freedishid  = vcr.dishid; // ja["dish"].ToString(); //freedishid
            vcr.freedishnum = 0;          // strtoint(ja["freedishnum"].ToString());
            vcr.couponway   = 0;          // strtoint(ja["couponway"].ToString());
            vcr.comsumeway  = 0;          // strtoint(ja["comsumeway"].ToString());

            try
            {
                vcr.couponrate = decimal.Parse(ja["discount"].ToString()); //banktype
            }
            catch { vcr.couponrate = 0; }
            //vcr.couponrate = 0;// strtodecimal(ja["couponrate"].ToString());
            vcr.couponamount = 0; // strtodecimal(ja["couponamount"].ToString());
            vcr.totalamount  = 0; // strtodecimal(ja["totalamount"].ToString());
            vcr.couponcash   = 0; // strtodecimal(ja["couponcash"].ToString());
            vcr.couponnum    = 0; // strtoint(ja["couponnum"].ToString());
            string bill_amount = "0";

            try
            {
                bill_amount = ja["bill_amount"].ToString();
            }
            catch { }
            string amount = "0";

            try
            {
                amount = ja["amount"].ToString();
            }
            catch { }
            if (bill_amount.Equals(""))
            {
                vcr.freeamount = strtodecimal(amount);
            }
            else
            {
                vcr.freeamount = strtodecimal(bill_amount) - strtodecimal(amount);//freeamount
            }
            try
            {
                vcr.partnername = ja["company_name"].ToString(); //partnername
            }
            catch { }
            if (vcr.partnername == null)
            {
                vcr.partnername = "";
            }
            vcr.groupweb = "0";// ja["groupweb"].ToString();
            try
            {
                vcr.unitid = ja["unit"].ToString();//unitid
            }
            catch { }
            if (vcr.freedishid != null)
            {
                vcr.wholesingle = "1"; //单品折扣类调用新接口获取优惠的金额
            }
            else
            {
                vcr.wholesingle = "0";
            }
            //vcr.wholesingle = ja["wholesingle"].ToString();
            try
            {
                if (bill_amount.Equals(""))
                {
                    vcr.debitamount = 0;
                }
                else
                {
                    vcr.debitamount = strtodecimal(amount);//strtodecimal(ja["debitamount"].ToString());
                }
            }
            catch { vcr.debitamount = 0; }
            try
            {
                vcr.type = strtoint(ja["type"].ToString());
            }
            catch { vcr.type = 6; }
            try
            {
                vcr.sub_type = ja["sub_type"].ToString();
            }
            catch { vcr.sub_type = ""; }

            if (vcr.sub_type == null)
            {
                vcr.sub_type = "";
            }
            return(vcr);
        }