예제 #1
0
        public object Do_PickupOrderGoods(BaseApi baseApi)
        {
            PickupOrderGoodsParam pickupOrderGoodsParam = JsonConvert.DeserializeObject <PickupOrderGoodsParam>(baseApi.param.ToString());

            if (pickupOrderGoodsParam == null)
            {
                throw new ApiException(CodeMessage.InvalidParam, "InvalidParam");
            }
            OpenDao   openDao   = new OpenDao();
            StoreUser storeUser = openDao.GetStoreUser(Utils.GetOpenID(baseApi.token));
            StoreDao  storeDao  = new StoreDao();

            if (!storeDao.UpdateOrderState(pickupOrderGoodsParam.orderId, storeUser.storeUserId))
            {
                throw new ApiException(CodeMessage.PickupGoodsError, "PickupGoodsError");
            }
            WsPayStateParam wsPayStateParam = new WsPayStateParam
            {
                scanCode = pickupOrderGoodsParam.code,
            };
            WsPayState wsPayState = new WsPayState
            {
                wsType = WsType.ORDER,
                Unique = wsPayStateParam.GetUnique(),
            };

            Utils.SetCache(wsPayState, 0, 0, 10);
            return("");
        }
예제 #2
0
        public object Do_ScanOrderCode(BaseApi baseApi)
        {
            ScanOrderCodeParam scanOrderCodeParam = JsonConvert.DeserializeObject <ScanOrderCodeParam>(baseApi.param.ToString());

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

            StoreGoodsCode storeGoodsCode = Utils.GetCache <StoreGoodsCode>(scanOrderCodeParam);

            if (storeGoodsCode == null)
            {
                throw new ApiException(CodeMessage.InvalidOrderCode, "InvalidOrderCode");
            }
            StoreDao  storeDao  = new StoreDao();
            string    storeId   = storeDao.GetStoreId(storeGoodsCode.order.storeCode);
            OpenDao   openDao   = new OpenDao();
            StoreUser storeUser = openDao.GetStoreUser(Utils.GetOpenID(baseApi.token));

            if (storeUser.storeId != storeId)
            {
                throw new ApiException(CodeMessage.NotStoreUserOrder, "NotStoreUserOrder");
            }
            Utils.DeleteCache <StoreGoodsCode>(scanOrderCodeParam);
            return(storeGoodsCode.order);
        }
예제 #3
0
        public object Do_ShopUserReg(BaseApi baseApi)
        {
            StoreUserRegParam storeUserRegParam = JsonConvert.DeserializeObject <StoreUserRegParam>(baseApi.param.ToString());

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

            SessionBag sessionBag = SessionContainer.GetSession(baseApi.token);

            if (sessionBag == null)
            {
                throw new ApiException(CodeMessage.InvalidToken, "InvalidToken");
            }

            OpenDao   openDao   = new OpenDao();
            string    openID    = Utils.GetOpenID(baseApi.token);
            StoreUser storeUser = openDao.GetStoreUser(openID);

            if (storeUser != null)
            {
                throw new ApiException(CodeMessage.StoreUserExist, "StoreUserExist");
            }

            string storeId = openDao.GetStoreId(storeUserRegParam.storeCode);

            if (storeId == "")
            {
                throw new ApiException(CodeMessage.InvalidStoreCode, "InvalidStoreCode");
            }

            if (!openDao.StoreUserReg(storeUserRegParam, openID, storeId))
            {
                throw new ApiException(CodeMessage.StoreUserRegError, "StoreUserRegError");
            }
            storeUser = openDao.GetStoreUser(openID);
            SessionUser sessionUser = JsonConvert.DeserializeObject <SessionUser>(sessionBag.Name);

            sessionUser.openid      = sessionBag.OpenId;
            sessionUser.storeUserId = storeUser.storeUserId;
            sessionUser.userType    = "STORE";
            sessionBag.Name         = JsonConvert.SerializeObject(sessionUser);
            SessionContainer.Update(sessionBag.Key, sessionBag, new TimeSpan(Global.SESSION_EXPIRY_H, Global.SESSION_EXPIRY_M, Global.SESSION_EXPIRY_S));

            return("");
        }
예제 #4
0
        public object Do_GetStoreAccount(BaseApi baseApi)
        {
            OpenDao   openDao   = new OpenDao();
            StoreUser storeUser = openDao.GetStoreUser(Utils.GetOpenID(baseApi.token));

            StoreDao storeDao = new StoreDao();

            return(storeDao.GetStoreAccount(storeUser.storeId));
        }
예제 #5
0
        public object Do_MemberCheckStore(BaseApi baseApi)
        {
            MemberCheckStoreParam memberCheckStoreParam = JsonConvert.DeserializeObject <MemberCheckStoreParam>(baseApi.param.ToString());

            if (memberCheckStoreParam == null)
            {
                throw new ApiException(CodeMessage.InvalidParam, "InvalidParam");
            }
            OpenDao   openDao   = new OpenDao();
            StoreUser storeUser = openDao.GetStoreUser(Utils.GetOpenID(baseApi.token));

            MemberCheckStoreCodeParam memberCheckStoreCodeParam = new MemberCheckStoreCodeParam
            {
                code = memberCheckStoreParam.code,
            };

            MemberCheckStoreCode memberCheckStoreCode = Utils.GetCache <MemberCheckStoreCode>(memberCheckStoreCodeParam);

            if (memberCheckStoreCode == null)
            {
                throw new ApiException(CodeMessage.InvalidMemberCkeckStoreCode, "InvalidMemberCkeckStoreCode");
            }

            StoreDao storeDao = new StoreDao();
            string   phone    = storeDao.CheckStoreMember(storeUser.storeId, memberCheckStoreCode.memberId);

            if (phone == "")
            {
                throw new ApiException(CodeMessage.NeedStoreMember, "NeedStoreMember");
            }

            if (memberCheckStoreParam.consume == 0 && !storeDao.CheckMemberCheckStore(storeUser.storeId, memberCheckStoreCode.memberId))
            {
                throw new ApiException(CodeMessage.AlreadyCheckThisStoreToday, "AlreadyCheckThisStoreToday");
            }

            if (!storeDao.InserMemberCheckStore(storeUser.storeId, memberCheckStoreCode.memberId, memberCheckStoreParam.consume, storeUser.storeUserId))
            {
                throw new ApiException(CodeMessage.MemberCkeckStoreError, "MemberCkeckStoreError");
            }

            Utils.DeleteCache <MemberCheckStoreCode>(memberCheckStoreCodeParam);
            WsPayStateParam wsPayStateParam = new WsPayStateParam
            {
                scanCode = memberCheckStoreCodeParam.code,
            };
            WsPayState wsPayState = new WsPayState
            {
                wsType = WsType.CHECK,
                Unique = wsPayStateParam.GetUnique(),
            };

            Utils.SetCache(wsPayState, 0, 0, 10);

            return("");
        }
예제 #6
0
        public object Do_GetAsnAndStock(BaseApi baseApi)
        {
            OpenDao   openDao   = new OpenDao();
            StoreUser storeUser = openDao.GetStoreUser(Utils.GetOpenID(baseApi.token));

            StoreDao          storeDao  = new StoreDao();
            List <StockGoods> listStock = storeDao.GetStockGoodsList(storeUser.storeId);
            List <AsnGoods>   listAsn   = storeDao.GetAsnGoodsList(storeUser.storeId);

            return(new { listAsn, listStock });
        }
예제 #7
0
        public object Do_ShopUserLogin(BaseApi baseApi)
        {
            LoginParam loginParam = JsonConvert.DeserializeObject <LoginParam>(baseApi.param.ToString());

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

            var jsonResult = SnsApi.JsCode2Json(Global.STOREAPPID, Global.STOREAPPSECRET, loginParam.code);

            if (jsonResult.errcode == Senparc.Weixin.ReturnCode.请求成功)
            {
                AccessTokenContainer.Register(Global.STOREAPPID, Global.STOREAPPSECRET);
                var sessionBag = SessionContainer.UpdateSession(null, jsonResult.openid, jsonResult.session_key, jsonResult.unionid);

                OpenDao     openDao     = new OpenDao();
                SessionUser sessionUser = new SessionUser();

                StoreUser storeUser = openDao.GetStoreUser(Utils.GetOpenID(sessionBag.Key));
                if (storeUser == null)
                {
                    sessionUser.userType = "UNKWON";
                    sessionBag.Name      = JsonConvert.SerializeObject(sessionUser);
                    SessionContainer.Update(sessionBag.Key, sessionBag, new TimeSpan(Global.SESSION_EXPIRY_H, Global.SESSION_EXPIRY_M, Global.SESSION_EXPIRY_S));
                    return(new { token = sessionBag.Key, isReg = false });
                }
                else
                {
                    sessionUser.userType    = "STORE";
                    sessionUser.openid      = sessionBag.OpenId;
                    sessionUser.storeUserId = storeUser.storeUserId;
                    sessionBag.Name         = JsonConvert.SerializeObject(sessionUser);
                    SessionContainer.Update(sessionBag.Key, sessionBag, new TimeSpan(Global.SESSION_EXPIRY_H, Global.SESSION_EXPIRY_M, Global.SESSION_EXPIRY_S));
                    return(new
                    {
                        token = sessionBag.Key,
                        isReg = true,
                        storeUser.storeId,
                        storeUser.storeUserId,
                        storeUser.storeUserName,
                        storeUser.storeUserImg,
                        storeUser.storeUserPhone,
                        storeUser.storeUserSex
                    });
                }
            }
            else
            {
                throw new ApiException(CodeMessage.SenparcCode, jsonResult.errmsg);
            }
        }
예제 #8
0
        public object Do_Exchange(BaseApi baseApi)
        {
            ExchangeParam exchangeParam = JsonConvert.DeserializeObject <ExchangeParam>(baseApi.param.ToString());

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

            ScanExchangeCodeParam scanExchangeCodeParam = new ScanExchangeCodeParam
            {
                code = exchangeParam.code
            };

            ExchangeCode exchangeCode = Utils.GetCache <ExchangeCode>(scanExchangeCodeParam);

            if (exchangeCode == null)
            {
                throw new ApiException(CodeMessage.InvalidExchangeCode, "InvalidExchangeCode");
            }

            OpenDao   openDao   = new OpenDao();
            StoreUser storeUser = openDao.GetStoreUser(Utils.GetOpenID(baseApi.token));

            StoreDao storeDao = new StoreDao();
            string   phone    = storeDao.CheckStoreMember(storeUser.storeId, exchangeCode.memberId);

            if (phone == "")
            {
                throw new ApiException(CodeMessage.NeedStoreMember, "NeedStoreMember");
            }

            if (!storeDao.InserRemoteCommit(storeUser.storeId, phone, exchangeParam.score))
            {
                throw new ApiException(CodeMessage.ExchangeError, "ExchangeError");
            }

            Utils.DeleteCache <ExchangeCode>(scanExchangeCodeParam);
            WsPayStateParam wsPayStateParam = new WsPayStateParam
            {
                scanCode = scanExchangeCodeParam.code,
            };
            WsPayState wsPayState = new WsPayState
            {
                wsType = WsType.EXCHANGE,
                Unique = wsPayStateParam.GetUnique(),
            };

            Utils.SetCache(wsPayState, 0, 0, 10);
            return("");
        }
예제 #9
0
        public object Do_CheckAsnGoods(BaseApi baseApi)
        {
            CheckAsnGoodsParam checkAsnGoodsParam = JsonConvert.DeserializeObject <CheckAsnGoodsParam>(baseApi.param.ToString());

            if (checkAsnGoodsParam == null)
            {
                throw new ApiException(CodeMessage.InvalidParam, "InvalidParam");
            }
            OpenDao   openDao   = new OpenDao();
            StoreUser storeUser = openDao.GetStoreUser(Utils.GetOpenID(baseApi.token));
            StoreDao  storeDao  = new StoreDao();

            if (!storeDao.CheckAsnGoods(storeUser.storeId, checkAsnGoodsParam.goodsId, storeUser.storeUserId))
            {
                throw new ApiException(CodeMessage.CheckAsnGoodsError, "CheckAsnGoodsError");
            }

            return("");
        }