Example #1
0
        /// <summary>
        /// 确认支付
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public static bool ConfirmPay(int ID, int PayType, int pay)
        {
            orders bll = new orders("dt_");

            Model.orders model = bll.GetModel(ID);

            user_coupon coubll = new user_coupon("dt_");

            Model.user_coupon coumodel = new Model.user_coupon();
            if (model.str_code != "")
            {
                coumodel = coubll.GetModel(" str_code='" + model.str_code + "'");
            }

            if (model.status > 1 || model.payment_status == 2)
            {
                return(false);
            }
            model.payment_status = 2;
            model.payment_time   = DateTime.Now;
            model.status         = PayType;
            model.payment_id     = pay;
            model.confirm_time   = DateTime.Now;
            if (bll.Update(model))
            {
                if (model.str_code != "")
                {
                    coumodel.status = 2;
                    coubll.Update(coumodel);

                    users       bll1     = new users("dt_");
                    Model.users userinfo = bll1.GetModel(model.user_id);
                    //优惠券使用记录
                    user_coupon_log       cbll   = new user_coupon_log("dt_");
                    Model.user_coupon_log cmodel = new Model.user_coupon_log();
                    cmodel.user_id   = userinfo.id;
                    cmodel.user_name = userinfo.user_name;
                    cmodel.coupon_id = coumodel.id;
                    cmodel.str_code  = model.str_code;
                    cmodel.order_id  = model.id;
                    cmodel.order_no  = model.order_no;
                    cmodel.add_time  = coumodel.add_time;
                    cmodel.use_time  = DateTime.Now;
                    cmodel.status    = 2;
                }

                return(true);
            }

            return(false);
        }
Example #2
0
        public HttpResponseMessage Put([FromBody] orders obj)
        {
            HttpResponseMessage checkIfAlreadyInExistance = Get(obj.id);

            if (checkIfAlreadyInExistance.StatusCode != HttpStatusCode.NotFound)
            {
                return(Request.CreateResponse(HttpStatusCode.Conflict, "An entity with id " + obj.id + " already exists."));
            }

            orders orders     = new orders();
            string outMessage = string.Empty;

            if (orders.Update(obj, out outMessage))
            {
                var message = Request.CreateResponse(HttpStatusCode.Accepted, obj);
                message.Headers.Location = new Uri(Request.RequestUri + obj.id);
                return(message);
            }
            else
            {
                return(Request.CreateErrorResponse(HttpStatusCode.NotModified, outMessage));
            }
        }