コード例 #1
0
        public object Do_ReloadScanCode(BaseApi baseApi)
        {
            MemberDao memberDao = new MemberDao();
            string    memberId  = Utils.GetMemberID(baseApi.token);
            string    scanCode  = "";

            using (var md5 = MD5.Create())
            {
                var result    = md5.ComputeHash(Encoding.UTF8.GetBytes(Guid.NewGuid().ToString()));
                var strResult = BitConverter.ToString(result);
                scanCode = "CHECK_" + strResult.Replace("-", "");
            }
            if (!memberDao.UpdateScanCode(memberId, scanCode))
            {
                throw new ApiException(CodeMessage.UpdateScanCodeError, "UpdateScanCodeError");
            }

            MemberCheckStoreCodeParam memberCheckStoreCodeParam = new MemberCheckStoreCodeParam
            {
                code = scanCode,
            };

            MemberCheckStoreCode memberCheckStoreCode = new MemberCheckStoreCode
            {
                code     = scanCode,
                memberId = memberId,
                Unique   = memberCheckStoreCodeParam.GetUnique(),
            };

            Utils.SetCache(memberCheckStoreCode, 0, 0, 30);

            return(scanCode);
        }
コード例 #2
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("");
        }