Ejemplo n.º 1
0
        public object Do_GetStoreListV2(BaseApi baseApi)
        {
            StoreListV2 storeListV2 = Utils.GetCache <StoreListV2>();
            MallDao     mallDao     = new MallDao();
            string      memberId    = Utils.GetMemberID(baseApi.token);

            storeListV2           = new StoreListV2();
            storeListV2.storeList = mallDao.GetStoreListV2(memberId);
            return(storeListV2);
        }
Ejemplo n.º 2
0
        public object Do_GetShowDay(BaseApi baseApi)
        {
            ShowDayList list = Utils.GetCache <ShowDayList>();

            if (list == null)
            {
                MallDao mallDao = new MallDao();
                list = mallDao.GetShowDay();
                Utils.SetCache(list);
            }
            return(list);
        }
Ejemplo n.º 3
0
        public object Do_GetStoreList(BaseApi baseApi)
        {
            StoreList storeList = Utils.GetCache <StoreList>();

            if (storeList == null)
            {
                MallDao mallDao  = new MallDao();
                string  memberId = Utils.GetMemberID(baseApi.token);
                storeList           = new StoreList();
                storeList.storeList = mallDao.GetStoreList();
                Utils.SetCache(storeList);
            }
            return(storeList);
        }
Ejemplo n.º 4
0
        public object Do_PayOrderV2(BaseApi baseApi)
        {
            PayOrderParamV2 payOrderParamV2 = JsonConvert.DeserializeObject <PayOrderParamV2>(baseApi.param.ToString());

            if (payOrderParamV2 == null)
            {
                throw new ApiException(CodeMessage.InvalidParam, "InvalidParam");
            }

            PreOrder preOrder = Utils.GetCache <PreOrder>(payOrderParamV2.preOrderId);

            if (preOrder == null)
            {
                throw new ApiException(CodeMessage.InvalidPreOrderId, "InvalidPreOrderId");
            }
            string memberId = Utils.GetMemberID(baseApi.token);


            MallDao  mallDao  = new MallDao();
            OrderDao orderDao = new OrderDao();
            Store    store    = mallDao.GetStoreListV2(memberId).Find
                                (
                item => item.storeId.Equals(payOrderParamV2.storeBranchId)
                                );

            if (store == null)
            {
                throw new ApiException(CodeMessage.InvalidStore, "InvalidStore");
            }
            preOrder.total    += store.expFee;
            preOrder.storeCode = store.storeCode;
            string orderCode = preOrder.storeCode + memberId.PadLeft(6, '0') + DateTime.Now.ToString("yyyyMMddHHmmss");

            if (orderDao.InsertOrder(memberId, orderCode, preOrder, payOrderParamV2.remark, payOrderParamV2.expAddr, store.expFee))
            {
                Utils.DeleteCache(payOrderParamV2.preOrderId);
                Order order = orderDao.GetOrderInfoByCode(orderCode);
                if (order == null)
                {
                    throw new ApiException(CodeMessage.CreateOrderError, "CreateOrderError");
                }
                return(order);
            }
            else
            {
                throw new ApiException(CodeMessage.CreateOrderError, "CreateOrderError");
            }
        }
Ejemplo n.º 5
0
        public object Do_InputCart(BaseApi baseApi)
        {
            InputCartParam inputCartParam = JsonConvert.DeserializeObject <InputCartParam>(baseApi.param.ToString());

            if (inputCartParam == null)
            {
                throw new ApiException(CodeMessage.InvalidParam, "InvalidParam");
            }
            MallDao  mallDao  = new MallDao();
            OrderDao orderDao = new OrderDao();
            string   memberId = Utils.GetMemberID(baseApi.token);
            Goods    goods    = mallDao.GetGoodsByGoodsId(inputCartParam.goodsId);

            if (inputCartParam.goodsNum < 0)
            {
                throw new ApiException(CodeMessage.ErrorNum, "ErrorNum");
            }

            if (goods == null)
            {
                throw new ApiException(CodeMessage.InvalidGoods, "InvalidGoods");
            }

            if (goods.goodsStock < inputCartParam.goodsNum)
            {
                throw new ApiException(CodeMessage.NotEnoughGoods, "NotEnoughGoods");
            }

            CartGoods cartGoods = orderDao.GetCartGoodsByGoodsId(memberId, inputCartParam.goodsId);

            if (cartGoods == null)
            {
                if (!orderDao.InsertCart(memberId, inputCartParam.goodsId, inputCartParam.goodsNum))
                {
                    throw new ApiException(CodeMessage.UpdateCartError, "UpdateCartError");
                }
            }
            else
            {
                if (!orderDao.UpdateAddCart(cartGoods.cartId, inputCartParam.goodsNum))
                {
                    throw new ApiException(CodeMessage.UpdateCartError, "UpdateCartError");
                }
            }

            return("");
        }
Ejemplo n.º 6
0
        public object Do_GetShowDayGoodsList(BaseApi baseApi)
        {
            GetShowDayGoodsListParam getShowDayGoodsListParam = JsonConvert.DeserializeObject <GetShowDayGoodsListParam>(baseApi.param.ToString());

            if (getShowDayGoodsListParam == null)
            {
                throw new ApiException(CodeMessage.InvalidParam, "InvalidParam");
            }
            ShowDayGoodsList list = Utils.GetCache <ShowDayGoodsList>(getShowDayGoodsListParam);

            if (list == null)
            {
                MallDao mallDao = new MallDao();
                list        = mallDao.GetShowDayGoodsList(getShowDayGoodsListParam.showId);
                list.Unique = getShowDayGoodsListParam.GetUnique();
                Utils.SetCache(list);
            }
            return(list);
        }
Ejemplo n.º 7
0
        public object Do_GetGoods(BaseApi baseApi)
        {
            GetGoodsParam getGoodsParam = JsonConvert.DeserializeObject <GetGoodsParam>(baseApi.param.ToString());

            if (getGoodsParam == null)
            {
                throw new ApiException(CodeMessage.InvalidParam, "InvalidParam");
            }

            Goods goods = Utils.GetCache <Goods>(getGoodsParam);

            if (goods == null)
            {
                MallDao mallDao = new MallDao();
                goods        = mallDao.GetGoodsByGoodsId(getGoodsParam.goodsId);
                goods.Unique = getGoodsParam.GetUnique();
                Utils.SetCache(goods, 0, 1, 0);
            }

            return(goods);
        }
Ejemplo n.º 8
0
        public object Do_GetHome(BaseApi baseApi)
        {
            Home home = Utils.GetCache <Home>();

            if (home == null)
            {
                MallDao  mallDao  = new MallDao();
                HomeInfo homeInfo = mallDao.GetHome();
                if (homeInfo == null)
                {
                    throw new ApiException(CodeMessage.HomeInitError, "HomeInitError");
                }
                List <HomeList> list = mallDao.GetHomeList(homeInfo.homeId);
                home          = new Home();
                home.homeInfo = homeInfo;
                home.list     = list;

                Utils.SetCache(home);
            }

            return(home);
        }
Ejemplo n.º 9
0
        public object Do_GetStoreInfo(BaseApi baseApi)
        {
            GetStoreInfoParam getStoreInfoParam = JsonConvert.DeserializeObject <GetStoreInfoParam>(baseApi.param.ToString());

            if (getStoreInfoParam == null)
            {
                throw new ApiException(CodeMessage.InvalidParam, "InvalidParam");
            }

            StoreInfo storeInfo = Utils.GetCache <StoreInfo>(getStoreInfoParam);

            if (storeInfo == null)
            {
                MallDao mallDao = new MallDao();
                storeInfo = mallDao.GetStoreInfo(getStoreInfoParam.storeId);
                if (storeInfo == null)
                {
                    throw new ApiException(CodeMessage.InvalidStore, "InvalidStore");
                }
                storeInfo.Unique = getStoreInfoParam.GetUnique();
                Utils.SetCache(storeInfo);
            }
            return(storeInfo);
        }