Exemple #1
0
        public TradeStates?UpgradeTradeState(string tradeId, TradeStates state)
        {
            var executeSqlString = @"spUpgradeTradeState";

            using (var database = this.databaseFactory.GenerateDatabase(isWriteOnly: false)) {
                var parameters = new Dapper.DynamicParameters();
                parameters.Add("@tradeId", tradeId, System.Data.DbType.String);
                parameters.Add("@tradeState", (int)state, System.Data.DbType.Int32);
                parameters.Add("@o_state", null, System.Data.DbType.Int32, System.Data.ParameterDirection.Output);
                database.Execute(executeSqlString, parameters, System.Data.CommandType.StoredProcedure, true);
                return(parameters.Get <TradeStates>("@o_state"));
            }
        }
Exemple #2
0
        private void UpgradeTradeState(TradeStates state)
        {
            var url    = string.Format(Sharing.Agent.Delivery.Constants.API, "UpgradeTradeState");
            var result = url.GetUriJsonContent <TradeStateResponse>((http) => {
                var data = new {
                    TradeId    = this.OrderContext.TradeId,
                    TradeState = state
                };
                http.Method      = "POST";
                http.ContentType = "application/json";
                using (var stream = http.GetRequestStream()) {
                    var body    = data.SerializeToJson();
                    var buffers = UTF8Encoding.UTF8.GetBytes(body);
                    stream.Write(buffers, 0, buffers.Length);
                    stream.Flush();
                }
                return(http);
            });

            this.lab_state.Text     = result.Data.GenernateTradeStateString();
            this.OrderContext.State = result.Data;
        }
Exemple #3
0
        public static string GenernateTradeStateString(this TradeStates state)
        {
            var states = new List <string>();

            if ((state & Core.TradeStates.AckPay) == Core.TradeStates.AckPay)
            {
                states.Add("已支付");
            }
            if ((state & Core.TradeStates.Marking) == Core.TradeStates.Marking)
            {
                states.Add("制作中");
            }
            if ((state & Core.TradeStates.Ready) == Core.TradeStates.Ready)
            {
                states.Add("制作完成");
            }
            if ((state & Core.TradeStates.Delivered) == Core.TradeStates.Delivered)
            {
                states.Add("已交付");
            }
            return(string.Join("|", states));
        }
Exemple #4
0
 public static OnlineOrder Convert(this OrderContext context, string tradeid, int code, TradeStates state)
 {
     return(new OnlineOrder()
     {
         TradeId = tradeid,
         TradeCode = code.ToString("000"),
         Address = context.Address ?? string.Empty,
         Mobile = context.Tel,
         Name = context.Customer,
         Total = context.Money,
         Items = context.Details.Select(ctx =>
         {
             return new OnlineOrderItem()
             {
                 Count = ctx.Number,
                 Option = ctx.Option,
                 Money = (decimal.Parse(ctx.Price)) * (decimal)ctx.Number,
                 Price = decimal.Parse(ctx.Price),
                 Product = ctx.Name
             };
         }).ToArray(),
         Fare = context.Fare.DecimalValue(),
         Delivery = context.Delivery,
         State = state,
         CreatedDateTime = DateTime.Now
     });
 }