示例#1
0
        public ApiResultModel GetShopInfo([FromUri] ShopInfoModel model)
        {
            ApiResultModel resultModel = new ApiResultModel();

            try
            {
                //获取当前用户
                IShopUserBLL userBll = BLLFactory <IShopUserBLL> .GetBLL("ShopUserBLL");

                T_ShopUser user = userBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

                if (user != null)
                {
                    //如果验证Token不通过或已过期
                    if (DateTime.Now > user.TokenInvalidTime || model.Token != user.Token)
                    {
                        resultModel.Msg = APIMessage.TOKEN_INVALID;
                        return(resultModel);
                    }
                    //更新最近登录时间和Token失效时间
                    user.LatelyLoginTime  = DateTime.Now;
                    user.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));
                    userBll.Update(user);

                    //调用商家BLL层获取商家信息
                    IShopBLL shopBll = BLLFactory <IShopBLL> .GetBLL("ShopBLL");

                    var shop = shopBll.GetEntity(s => s.Id == model.ShopId);
                    //如果商家信息不为空
                    if (shop != null)
                    {
                        resultModel.result = new
                        {
                            ShopName          = shop.ShopName,
                            ShopContent       = string.Format("MobilePage/StoreIntroduce?ShopId={0}", shop.Id),
                            ShopMainSale      = shop.MainSale,
                            StartBusinessTime = shop.StartBusinessTime,
                            EndBusinessTime   = shop.EndBusinessTime,
                            ShopAddress       = shop.Address,
                            Phone             = shop.Phone,
                            ShopPicList       = shop.ImgPath
                        };
                    }
                    else
                    {
                        resultModel.Msg = APIMessage.NO_APP;
                    }
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }

            return(resultModel);
        }
示例#2
0
        public ApiResultModel SetShopInfo(ShopInfoModel model)
        {
            ApiResultModel resultModel = new ApiResultModel();

            try
            {
                //获取当前用户
                IShopUserBLL userBll = BLLFactory <IShopUserBLL> .GetBLL("ShopUserBLL");

                T_ShopUser user = userBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

                if (user != null)
                {
                    //如果验证Token不通过或已过期
                    if (DateTime.Now > user.TokenInvalidTime || model.Token != user.Token)
                    {
                        resultModel.Msg = APIMessage.TOKEN_INVALID;
                        return(resultModel);
                    }
                    //更新最近登录时间和Token失效时间
                    user.LatelyLoginTime  = DateTime.Now;
                    user.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));
                    userBll.Update(user);

                    //调用商家BLL层获取商家信息
                    IShopBLL shopBll = BLLFactory <IShopBLL> .GetBLL("ShopBLL");

                    var shop = shopBll.GetEntity(s => s.Id == model.ShopId);

                    //设置主营内容
                    if (shop != null)
                    {
                        shop.ShopName = model.ShopName;
                        //shop.Content = model.ShopContent;
                        shop.MainSale          = model.MainSale;
                        shop.StartBusinessTime = model.StartBusinessTime;
                        shop.EndBusinessTime   = model.EndBusinessTime;
                        shop.Address           = model.Address;
                        shop.Phone             = model.Phone;
                        shop.UpdateTime        = DateTime.Now;
                        shopBll.Update(shop);
                    }
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }

            return(resultModel);
        }
示例#3
0
        /// <summary>
        /// 小青蛙详细信息(包括简介、联系方式、二维码、邮箱等等)
        /// </summary>
        /// <returns></returns>
        public ShopInfoModel GetShopInfo()
        {
            var shopmodel = new ShopInfoModel
            {
                ShopName    = "小青蛙商学院",
                Phone       = "17601492856",
                QQNumber    = "1315915446",
                MailAddress = "*****@*****.**",
                WXNumber    = "17601492856",
                Slogan      = "学知识,上小青蛙商学院!",
                WXImageUrl  = @AppConst.OtherImagePath + "/xqw_vip.jpg",
                //Introduction = $@"小青蛙商学院,竭力为您提供全方位的学习资源,靠谱的教学资料,优质的原创课程。学知识,上小青蛙商学院!",
            };

            return(shopmodel);
        }
示例#4
0
        public async Task <IActionResult> Start(TransactionModel model)
        {
            if (!System.Enum.IsDefined(typeof(WalletType), model.WalletType))
            {
                throw new ApplicationException($"Wrong wallet type with value '{model.WalletType}'.");
            }

            ShopInfoModel result = null;
            string        hash   = string.Empty;

            if (!await _merchantRepository.ValidateMerchant(model.MerchantId, model.MerchantSecret))
            {
                throw new ApplicationException($"Unable to load merchant with ID '{model.MerchantId}'.");
            }

            var merchant = await _merchantRepository.GetByMerchant(model.MerchantId);

            var subscriptions = await _subscriptionsRepository.GetByUserId(merchant.Id);

            if (subscriptions != null && !subscriptions.Paid && subscriptions.Expired < DateTime.Now)
            {
                return(BadRequest("Subscription has expired."));
            }

            if (!string.Equals(merchant.RedirectUri, model.CallbackUrl))
            {
                return(BadRequest("The redirect URI is not the same as in the merchant settings."));
            }

            try
            {
                result = await _requestProvider
                         .PostAsync <CheckPaymentShop, ShopInfoModel>(model.CallbackUrl, new CheckPaymentShop { TrxId = model.TrxId });

                hash = await _transactionRepository.CreateTransactions(result, merchant.Id, model.WalletType);

                var trx = await _transactionRepository.GetByHash(hash);

                await _logRepository.Add(trx.Id, "Transaction created.");
            }
            catch (Exception e)
            {
                _logger.LogError(e, e.Message);
            }

            return(RedirectToAction(nameof(PurchaserController.Index), "Purchaser", new { id = hash }));
        }
示例#5
0
        public async Task <string> CreateTransactions(ShopInfoModel shopInfoModel, string userId, WalletType walletType)
        {
            var hash = Guid.NewGuid().ToString().Replace("-", "");

            await Create(new Transaction
            {
                Amount      = shopInfoModel.Amount,
                Description = shopInfoModel.Description,
                Status      = StatusTransaction.Created,
                UserId      = userId,
                Hash        = hash,
                WalletType  = walletType,
                EtherId     = new Random().Next(0, int.MaxValue)
            });

            return(hash);
        }
示例#6
0
        /// <summary>
        /// ユーザーIDから店舗一覧取得
        /// (店舗配置書籍情報は取得しない)
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public List <ShopInfoModel> GetUsersShops(string id)
        {
            using (var conn = new SQLiteConnection("Data Source=" + Setting.SQLITE_PATH))
            {
                //登録データの取得
                conn.Open();
                SQLiteCommand command = conn.CreateCommand();
                command.CommandText = "SELECT * " +
                                      "FROM SHOP_INFO " +
                                      "WHERE ID = @id " +
                                      "AND DELETE_FLG = 0 " +
                                      "ORDER BY REGIST_DATE DESC;";
                command.Parameters.Add("id", System.Data.DbType.String).Value = id;

                List <ShopInfoModel> ret = new List <ShopInfoModel>();

                using (SQLiteDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        if (!reader.HasRows)
                        {
                            continue;
                        }
                        ShopInfoModel mdl = new ShopInfoModel();

                        mdl.Id = Convert.ToString(reader["ID"].ToString());

                        mdl.BackImg     = Convert.ToString(reader["BACK_IMG"].ToString());
                        mdl.Layout      = Convert.ToString(reader["LAYOUT"].ToString());
                        mdl.ShopComment = Convert.ToString(reader["SHOP_COMMENT"].ToString());
                        mdl.ShopId      = Convert.ToString(reader["SHOP_ID"].ToString());
                        mdl.ShopName    = Convert.ToString(reader["SHOP_NAME"].ToString());
                        mdl.RegistDate  = Convert.ToString(reader["REGIST_DATE"].ToString());

                        ret.Add(mdl);
                    }
                }
                return(ret);
            }
        }
示例#7
0
        /// <summary>
        /// 書店更新
        /// </summary>
        /// <param name="shopInfo"></param>
        /// <param name="loginInfo"></param>
        public void UpdateShop(ShopInfoModel shopInfo, LoginInfoModel loginInfo)
        {
            using (var conn = new SQLiteConnection("Data Source=" + Setting.SQLITE_PATH))
            {
                conn.Open();
                using (SQLiteTransaction trans = conn.BeginTransaction())
                {
                    SQLiteCommand command = conn.CreateCommand();

                    /////////////////////////////////
                    //店舗情報更新
                    /////////////////////////////////
                    command.CommandText = "UPDATE SHOP_INFO " +
                                          "SET SHOP_NAME =@SHOP_NAME, SHOP_COMMENT=@SHOP_COMMENT, BACK_IMG=@BACK_IMG,LAYOUT=@LAYOUT " +
                                          "WHERE SHOP_ID = @SHOP_ID AND DELETE_FLG = '0';";


                    command.Parameters.Add("SHOP_ID", System.Data.DbType.String).Value      = shopInfo.ShopId;
                    command.Parameters.Add("SHOP_NAME", System.Data.DbType.String).Value    = shopInfo.ShopName;
                    command.Parameters.Add("SHOP_COMMENT", System.Data.DbType.String).Value = shopInfo.ShopComment;
                    command.Parameters.Add("BACK_IMG", System.Data.DbType.String).Value     = shopInfo.BackImg;
                    command.Parameters.Add("LAYOUT", System.Data.DbType.String).Value       = shopInfo.Layout;

                    int up = command.ExecuteNonQuery();

                    if (up != 1)
                    {
                        throw new Exception("更新失敗");
                    }

                    //店舗_帯情報更新
                    registShopObi(conn, shopInfo.ShopId, shopInfo.ShopObiList);

                    trans.Commit();
                }
            }
        }
示例#8
0
        /// <summary>
        /// 新規登録
        /// </summary>
        public void ReagistShop(ShopInfoModel shopInfo, LoginInfoModel loginInfo)
        {
            //DBへの登録処理
            using (var conn = new SQLiteConnection("Data Source=" + Setting.SQLITE_PATH))
            {
                conn.Open();
                using (SQLiteTransaction trans = conn.BeginTransaction())
                {
                    SQLiteCommand command = conn.CreateCommand();

                    /////////////////////////////////
                    //店舗情報への格納
                    /////////////////////////////////
                    command.CommandText = "INSERT INTO SHOP_INFO (SHOP_ID,ID, SHOP_NAME, SHOP_COMMENT, BACK_IMG,LAYOUT, REGIST_DATE, DELETE_FLG) " +
                                          "VALUES (@SHOP_ID,@ID,@SHOP_NAME , @SHOP_COMMENT, @BACK_IMG , @LAYOUT , @REGIST_DATE, '0');";


                    //店舗IDはユーザーID+タイムスタンプ
                    string shopId = loginInfo.Id + "_" + Now.ToString("yyyyMMddHHmmssfff");

                    command.Parameters.Add("SHOP_ID", System.Data.DbType.String).Value      = shopId;
                    command.Parameters.Add("ID", System.Data.DbType.String).Value           = loginInfo.Id;
                    command.Parameters.Add("SHOP_NAME", System.Data.DbType.String).Value    = shopInfo.ShopName;
                    command.Parameters.Add("SHOP_COMMENT", System.Data.DbType.String).Value = shopInfo.ShopComment;
                    command.Parameters.Add("BACK_IMG", System.Data.DbType.String).Value     = shopInfo.BackImg;
                    command.Parameters.Add("LAYOUT", System.Data.DbType.String).Value       = shopInfo.Layout;

                    command.Parameters.Add("REGIST_DATE", System.Data.DbType.String).Value = Now.ToString("yyyy/MM/dd HH:mm:ss");
                    command.ExecuteNonQuery();

                    //店舗_帯情報更新
                    registShopObi(conn, shopId, shopInfo.ShopObiList);

                    trans.Commit();
                }
            }
        }
示例#9
0
        public ApiResultModel GetShopShippingCost([FromUri] ShopInfoModel model)
        {
            ApiResultModel resultModel = new ApiResultModel();

            try
            {
                //获取当前用户
                IShopUserBLL userBll = BLLFactory <IShopUserBLL> .GetBLL("ShopUserBLL");

                T_ShopUser user = userBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

                if (user != null)
                {
                    //如果验证Token不通过或已过期
                    if (DateTime.Now > user.TokenInvalidTime || model.Token != user.Token)
                    {
                        resultModel.Msg = APIMessage.TOKEN_INVALID;
                        return(resultModel);
                    }
                    //更新最近登录时间和Token失效时间
                    user.LatelyLoginTime  = DateTime.Now;
                    user.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));
                    userBll.Update(user);

                    //调用商家BLL层获取商家信息
                    IShopShippingCostBLL shippingCostBLL = BLLFactory <IShopShippingCostBLL> .GetBLL("ShopShippingCostBLL");

                    var shippingCost = shippingCostBLL.GetEntity(s => s.ShopId == model.ShopId);
                    //如果商家信息不为空
                    if (shippingCost != null)
                    {
                        resultModel.result = new
                        {
                            Id           = shippingCost.Id,
                            OrderExpense = shippingCost.OrderExpense.HasValue ? shippingCost.OrderExpense.ToString() : "",
                            Price        = shippingCost.Price,
                            IsFree       = shippingCost.IsFree
                        };
                    }
                    else
                    {
                        resultModel.result = new
                        {
                            Id           = "",
                            OrderExpense = "",
                            Price        = "",
                            IsFree       = ""
                        };
                    }
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }

            return(resultModel);
        }
示例#10
0
        public ApiResultModel GetShopPayType([FromUri] ShopInfoModel model)
        {
            ApiResultModel resultModel = new ApiResultModel();

            try
            {
                //获取当前用户
                IShopUserBLL userBll = BLLFactory <IShopUserBLL> .GetBLL("ShopUserBLL");

                T_ShopUser user = userBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

                if (user != null)
                {
                    //如果验证Token不通过或已过期
                    if (DateTime.Now > user.TokenInvalidTime || model.Token != user.Token)
                    {
                        resultModel.Msg = APIMessage.TOKEN_INVALID;
                        return(resultModel);
                    }
                    //更新最近登录时间和Token失效时间
                    user.LatelyLoginTime  = DateTime.Now;
                    user.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));
                    userBll.Update(user);

                    //调用商家BLL层获取商家信息
                    IShopBLL shopBll = BLLFactory <IShopBLL> .GetBLL("ShopBLL");

                    var shop = shopBll.GetEntity(s => s.Id == model.ShopId);
                    //如果商家信息不为空
                    if (shop != null)
                    {
                        var payTypeIds = shop.ShopPaymentManagements.Select(s => s.PayTypeId);
                        //是否是绿色直供
                        bool isGreenSupplied = shop.Type.Contains(Property.Common.ConstantParam.SHOP_TYPE_0.ToString());

                        //获取支付类型  绿色直供包含5种
                        var PayTypeList = new List <ShopPaymentType>();

                        if (isGreenSupplied)
                        {
                            PayTypeList.Add(new ShopPaymentType()
                            {
                                TypeId = 1, TypeName = "微信在线支付", TypeFlag = 1
                            });
                            PayTypeList.Add(new ShopPaymentType()
                            {
                                TypeId = 2, TypeName = "支付宝在线支付", TypeFlag = 2
                            });
                        }

                        PayTypeList.Add(new ShopPaymentType()
                        {
                            TypeId = 3, TypeName = "货到现金付款", TypeFlag = 3
                        });
                        PayTypeList.Add(new ShopPaymentType()
                        {
                            TypeId = 4, TypeName = "货到微信付款", TypeFlag = 1
                        });
                        PayTypeList.Add(new ShopPaymentType()
                        {
                            TypeId = 5, TypeName = "货到支付宝付款", TypeFlag = 2
                        });

                        var List = PayTypeList.Select(t => new { TypeId = t.TypeId, TypeName = t.TypeName, TypeFlag = t.TypeFlag, IsCheck = payTypeIds.Contains(t.TypeId) });
                        resultModel.result = List;
                    }
                    else
                    {
                        resultModel.Msg = APIMessage.NO_APP;
                    }
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }

            return(resultModel);
        }
示例#11
0
        /// <summary>
        /// 店舗IDから店舗情報取得
        /// </summary>
        /// <param name="shopId"></param>
        /// <returns></returns>
        public ShopInfoModel GetShop(string shopId)
        {
            using (var conn = new SQLiteConnection("Data Source=" + Setting.SQLITE_PATH))
            {
                conn.Open();
                SQLiteCommand command = conn.CreateCommand();
                ShopInfoModel ret     = new ShopInfoModel();

                /////////////
                //店舗情報
                ////////
                command.CommandText = "SELECT S.ID AS ID, " +
                                      "    S.BACK_IMG AS BACK_IMG, " +
                                      "    S.LAYOUT AS LAYOUT, " +
                                      "    S.SHOP_COMMENT AS SHOP_COMMENT, " +
                                      "    S.SHOP_ID AS SHOP_ID, " +
                                      "    S.SHOP_NAME AS SHOP_NAME, " +
                                      "    S.REGIST_DATE AS REGIST_DATE, " +
                                      "    U.NAME AS NAME " +
                                      "FROM SHOP_INFO S " +
                                      "INNER JOIN USER_INFO U " +
                                      "    ON U.ID = S.ID " +
                                      "WHERE S.SHOP_ID = @shopId " +
                                      "AND U.DELETE_FLG = 0; " +
                                      "AND S.DELETE_FLG = 0; ";

                command.Parameters.Add("shopId", System.Data.DbType.String).Value = shopId;
                using (SQLiteDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        if (!reader.HasRows)
                        {
                            return(null);                //空ならおしまい
                        }
                        ret.Id             = Convert.ToString(reader["ID"].ToString());
                        ret.BackImg        = Convert.ToString(reader["BACK_IMG"].ToString());
                        ret.Layout         = Convert.ToString(reader["LAYOUT"].ToString());
                        ret.ShopComment    = Convert.ToString(reader["SHOP_COMMENT"].ToString());
                        ret.ShopId         = Convert.ToString(reader["SHOP_ID"].ToString());
                        ret.ShopName       = Convert.ToString(reader["SHOP_NAME"].ToString());
                        ret.RegistDate     = Convert.ToString(reader["REGIST_DATE"].ToString());
                        ret.OwnerInfo.Name = Convert.ToString(reader["NAME"].ToString());
                    }
                }

                /////////////
                //店舗-帯画像情報
                //////////
                command             = conn.CreateCommand();
                command.CommandText = "SELECT * " +
                                      "FROM SHOP_OBI SO " +
                                      "INNER JOIN OBI_INFO O " +
                                      "  ON SO.OBI_ID = O.OBI_ID " +
                                      "WHERE SO.SHOP_ID = @shopId " +
                                      "AND O.DELETE_FLG = 0 " +
                                      "ORDER BY SO.ORDER_SEQ ";

                command.Parameters.Add("shopId", System.Data.DbType.String).Value = shopId;
                using (SQLiteDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        if (!reader.HasRows)
                        {
                            continue;
                        }
                        ShopObiModel mdl = new ShopObiModel();

                        mdl.OrderSeq = int.Parse(Convert.ToString(reader["ORDER_SEQ"].ToString()));


                        //todo 以下切り出し
                        mdl.ObiInfo.Id = Convert.ToString(reader["ID"].ToString());
                        string imgP = Convert.ToString(reader["IMG_PATH"].ToString());
                        mdl.ObiInfo.ImgPath = Util.GenerateServerPath(imgP);

                        mdl.ObiInfo.ObiId      = Convert.ToString(reader["OBI_ID"].ToString());
                        mdl.ObiInfo.Author     = Convert.ToString(reader["AUTHOR"].ToString());
                        mdl.ObiInfo.BookTitle  = Convert.ToString(reader["BOOK_TITLE"].ToString());
                        mdl.ObiInfo.Link       = Convert.ToString(reader["LINK"].ToString());
                        mdl.ObiInfo.Publisher  = Convert.ToString(reader["PUBLISHER"].ToString());
                        mdl.ObiInfo.RegistDate = Convert.ToString(reader["REGIST_DATE"].ToString());

                        ret.ShopObiList.Add(mdl);
                    }
                }

                //歯抜け分を補完
                for (int i = 0; i < ShopInfoModel.ShopObiNum; i++)
                {
                    int cnt = (from l in ret.ShopObiList
                               where l.OrderSeq == i
                               select "1").Count();

                    if (cnt == 0)
                    {
                        ret.ShopObiList.Add(new ShopObiModel()
                        {
                            OrderSeq = i
                        });
                    }
                }
                ret.ShopObiList = (from l in ret.ShopObiList
                                   orderby l.OrderSeq
                                   select l).ToList();
                return(ret);
            }
        }