USE jinan_fuhang SELECT count(1) FROM mem_info WITH(NOLOCK) WHERE CardCode NOT IN(SELECT CardCode FROM mem_fund) --会员 ALTER TABLE mem_info ADD FMemId BIGINT NOT NULL DEFAULT 0 ALTER TABLE mem_info ADD FMemNo VARCHAR(50) NOT NULL DEFAULT '' ALTER TABLE mem_info ADD FName VARCHAR(50) NOT NULL DEFAULT '' ALTER TABLE mem_info ADD FGender INT NOT NULL DEFAULT 0 ALTER TABLE mem_info ADD FMobile VARCHAR(50) NOT NULL DEFAULT '' ALTER TABLE mem_info ADD FMemo VARCHAR(1000) DEFAULT '' ALTER TABLE mem_info ADD FArrear DECIMAL(18,6) DEFAULT 0 ALTER TABLE mem_info ADD FPoint DECIMAL(18,6) DEFAULT 0 ALTER TABLE mem_info ADD FBirthday DATETIME ALTER TABLE mem_info ADD FBirthdayType CHAR NOT NULL DEFAULT '' ALTER TABLE mem_info ADD FCreateDate DATETIME ALTER TABLE mem_info ADD FExpiredDate DATETIME ALTER TABLE mem_info ADD FCompId BIGINT DEFAULT 0 ALTER TABLE mem_info ADD FDeleted BIT NOT NULL DEFAULT 0 ALTER TABLE mem_info ADD FPassword VARCHAR(1000) DEFAULT '' ALTER TABLE mem_info ADD FCardNo VARCHAR(50) NOT NULL DEFAULT '' ALTER TABLE mem_info ADD FCardTypeId BIGINT NOT NULL DEFAULT 0 ALTER TABLE mem_info ADD FBalance DECIMAL(18,6) NOT NULL DEFAULT 0 ALTER TABLE mem_info ADD FRemainTimes INT NOT NULL DEFAULT 0 ALTER TABLE mem_info ADD FCardId BIGINT NOT NULL DEFAULT 0 ALTER TABLE mem_info ADD FCardMemo VARCHAR(1000) NOT NULL DEFAULT '' ALTER TABLE mem_info ADD FCardState INT NOT NULL DEFAULT 0 SELECT * FROM card_level SELECT * FROM jinan_dreamhair..TCompany SELECT * FROM mem_info where card_id in(select card_id from jinan_dreamhair_feiyue2..mem_info ) UPDATE mem_info SET FCardTypeId = abs( CAST( CAST(CAST(CardTypeGUID AS UNIQUEIDENTIFIER) AS BINARY(16)) AS BIGINT)) ---卡类别 INSERT jinan_dreamhair..TMemberCardType(FId,FNo,FName,FValueType,FMaterial,FPrice,FAcctId,FDeposit,FAcctId2,FDeposit2,FAcctId3,FDeposit3,FTimes,FAlertBalance,FMinRchgAmt,FValidityPeriod,FValidityPeriodUnit,FAllowSale,FAllowRchg,FEnabled,FOrder,FSalePointMode,FSalePointValue,FRchgPointMode,FRchgPointValue) SELECT FId = 20000+level_id, FNo = 'FY2' + cast(level_id as varchar), FName = level_name, 1 AS FValueType, 2 AS FMaterial, 0 AS FPrice, 3 AS FAcctId, 0 AS FDeposit, 0 as FAcctId2, 0 AS FDeposit2, 0 AS FAcctId3, 0 AS FDeposit3, 0 AS FTimes, 0 AS FAlertBalance, 0 AS FMinRchgAmt, 0 AS FValidityPeriod, 0 AS FValidityPeriodUnit, 1 AS FAllowSale, 1 AS FAllowRchg, 1, 1, 0 AS FSalePointMode, 0 AS FSalePointValue, 0 AS FRchgPointMode, 0 AS FRchgPointValue FROM card_level SELECT * FROM jinan_dreamhair..TCompany SELECT * FROM jinan_dreamhair..TMemberCardTypeCross SELECT * FROM jinan_dreamhair..TMemberCardTypeCross INSERT INTO jinan_dreamhair..TMemberCardTypeSub(FId,FCompId,FCardTypeId,FAllowSale,FAllowRchg,FEnabled) SELECT jinan_dreamhair.dbo.FNNewId(),C.FId,I.FId,FAllowSale,FAllowRchg,FEnabled FROM jinan_dreamhair..TMemberCardType AS I,jinan_dreamhair..TCompany AS C WHERE I.FId > 1 AND C.FId != 0 -- AND C.FNo IN('006','008','010','009') AND NOT EXISTS(SELECT TOP 1 1 FROM jinan_dreamhair..TMemberCardTypeSub AS B WHERE B.FCompId = C.FId AND B.FCardTypeId = I.FId) UPDATE A SET A.FCardTypeId = 10000 + level_id FROM jinan_dreamhair_feiyue1..mem_info AS A UPDATE A SET A.FCardTypeId = 20000 + level_id FROM jinan_dreamhair_feiyue2..mem_info AS A UPDATE jinan_dreamhair..TMemberCardType SET FAllowSale = 1,FAllowRchg = 1 --会员资料 select card_id from mem_info group by card_id having(sum(1) > 1) SELECT * FROM mem_info WHERE state != 1 -- 标记为删除 UPDATE mem_info SET FDeleted = 0 UPDATE mem_info SET FDeleted = 1 WHERE card_id IS NULL SELECT * FROM info_storage SELECT * FROM jinan_dreamhair..TCompany --门店 UPDATE mem_info SET FCompId = 1 --会员ID,+100000 UPDATE mem_info SET FMemId = jinan_dreamhair.dbo.FNNewId() --姓名 UPDATE mem_info SET FName = ISNULL(ISNULL(mem_name,tel_no),mem_id) --电话 UPDATE mem_info SET FMobile = ISNULL(tel_no,'') --性别 UPDATE mem_info SET FGender = 0--CASE WHEN sex = 'true' THEN 1 ELSE 0 END --CreateDate --卡 --卡ID UPDATE mem_info SET FCardId = abs( CAST( CAST(newid() AS BINARY(16)) AS BIGINT)) --卡号 UPDATE mem_info SET FCardNO = card_id where card_id is not null --余额 UPDATE mem_info SET FBalance = balance --积分 --UPDATE mem_info SET FPoint = CardPoint --开卡日期 UPDATE mem_info SET FCreateDate = open_date --有效期 UPDATE mem_info SET FExpiredDate = dateadd(year,100,open_date) --密码 --UPDATE mem_info SET FPassword = ISNULL(CardPsw,'') --备注 UPDATE mem_info SET FCardMemo = isnull(mem,'') UPDATE mem_info SET FCardState = 1 UPDATE mem_info set FCardState = 4 WHERE state != 1 --处理重复的卡号 UPDATE jinan_dreamhair_feiyue1..mem_info SET FCardNo = 'A' + FCardNo WHERE FCardNo IN( SELECT card_id FROM jinan_dreamhair_feiyue2..mem_info) UPDATE jinan_dreamhair_feiyue2..mem_info SET FCardNo = 'B' + FCardNo WHERE FCardNo IN( SELECT card_id FROM jinan_dreamhair_feiyue1..mem_info) UPDATE jinan_dreamhair_feiyue2..mem_info SET FMemNO = FCardNo UPDATE jinan_dreamhair_feiyue1..mem_info SET FMemNO = FCardNo SELECT * FROM mem_info --更新会员编号 UPDATE A SET A.FMemNO = B.FCardNo FROM mem_info AS A,mem_info AS B,(SELECT FMemId,MIN(FIndex) AS FIndex FROM mem_info GROUP BY FMemId) AS C WHERE A.FMemId = B.FMemId AND B.FMemId = C.FMemId AND B.FIndex =C.FIndex SELECT mem_id FROM mem_info GROUP BY mem_id having(sum(1) >1) SELECT * FROM mem_info WHERE FMemNO = '' SELECT FMemId,SUM(1) FROM mem_info WHERE FDeleted = 0 GROUP BY FMemId HAVING(SUM(1) > 1) SELECT * FROM mem_info WHERE FCardNo = '' SELECT FMemNO,sum(1) FROM mem_info WHERE FDeleted = 0 GROUP BY FMemNo HAVING(SUM(1) > 1) SELECT A.FName,A.FMobile,* FROM Card AS B,Guest AS A WHERE B.FCardNo in( SELECT FCardNo FROM Card WHERE FDeleted = 0 --AND bChain = 0 GROUP BY FCardNo HAVING(SUM(1) > 1) ) AND B.FDeleted = 0 AND A.FDeleted= 0 AND A.FMemId = B.FMemId ORDER BY FCardNo INSERT INTO jinan_dreamhair..TMember( FMemId, FMemNo, FName, FBriefCode, FTypeId, FCompId, FCreateDate, FGender, FBirthdayType, FBirthday,FTelephone,FMobilePhone,FQQ,FWeChat,FIdCard,FEmail,FAddress,FProId,FCPW,FQPW, FChargeEmpId,FPoint,FRecvConsSMS,FRecvBulkSMS,FMemo,FCustom1,FCustom2,FCustom3,FCustom4,FCustom5) SELECT FMemId AS FMemId, FMemNo AS FMemNo, FName AS FName, jinan_dreamhair.dbo.FNGetFirstPinYin(FName) as fcode, 0 AS FTypeId, FCompId AS FCompId, FCreateDate , FGender AS FGender, 'G' AS FBirthdayType, FBirthday AS FBirthday, '' AS FTelephone, ISNULL(FMobile,'') AS FMobilePhone, '' AS FQQ, '' AS FWeChat, '' AS FIdCard, '' AS FEmail, '' AS FAddress, 0 AS FProId, ISNULL('','') AS FCPW, '' AS FQPW, 0 AS FChargeEmpId, ISNULL( FPoint,0) AS FPoint, 1 AS FRecvConsSMS, 1 AS FRecvBulkSMS, ISNULL('','') AS FMemo, '' AS FCustom1,'' AS FCustom2,'' AS FCustom3,'' AS FCustom4,'' AS FCustom5 -- into #t from jinan_dreamhair_feiyue2..mem_info WHERE FDeleted = 0 SELECT FMemId,sum(1) FROM #t GROUP BY FMemId HAVING(SUM(1) > 1) SELECT * FROM mem_info WHERE FMemId = 4632873443776940758 SELECT * FROM #T WHERE FMemNO = 'NO2YK20238' INSERT INTO jinan_dreamhair..TMemberCard( FCardId, FCardNo, FCardFaceNo, FTypeId, FValueType, FCompId, FMemId, FState, FCreateDate, FExpiredDate, FTotalTimes, FUsedTimes, FSaleCompId, FSaleBillId, FMemo) SELECT FCardId AS FId, FCardNo AS FNo, FCardNo AS FFaceNo, FCardTypeId AS FTypeId, (SELECT FValueType FROM jinan_dreamhair..TMemberCardType WHERE FId = FCardTypeId) AS FValueType, FCompId AS FCompId, FMemId AS FMemId, 1 AS FState, FCreateDate AS FCreateDate, FExpiredDate, 0 AS FTotalTimes, 0 AS FUsedTimes, FCompId AS FSaleCompId, 0 AS FSaleBillId, FCardMemo AS FMemo FROM jinan_dreamhair_feiyue2..mem_info WHERE FDeleted = 0 SELECT level_id FROM mem_info where level_id not in( SELECT level_id FROM card_level) UPDATE jinan_dreamhair..TMemberCardType SET FId UPDATE jinan_dreamhair..TMemberCardType SET FId = 20006 WHERE FNo = 'FY26' UPDATE jinan_dreamhair..TMemberCardType SET FId = 20008 WHERE FNo = 'FY28' UPDATE jinan_dreamhair..TMemberCardType SET FId = 20009 WHERE FNo = 'FY29' SELECT * FROM jinan_dreamhair..TMemberCardType update TMemberCardAccount SET FExpiredDate = null WHERE FCardTypeId IS NOT NULL INSERT jinan_dreamhair..TMemberCardAccount(FMemId,FId,FCardId,FAcctId,FDeposit,FBalance,FArrear,FCreateDate,FExpiredDate,FMemo) SELECT FMemId,jinan_dreamhair.dbo.FNNewId(),FCardId AS FCardId,3,FBalance,FBalance,0,FCreateDate,null AS FExpiredDate,'' FROM jinan_dreamhair_feiyue2..mem_info AS A WHERE FDeleted = 0 INSERT jinan_dreamhair..TMemberCardAcctHist(FId,FMemId,FCardId,FAcctId,FTime,FCardTypeId,FCompId,FBillType,FBizType,FTransId,FTransNo,FInAmount,FOutAmount,FBalance,FArrear,FRecordTime,FMemo) select jinan_dreamhair.dbo.FNNewId(),A.FMemId,A.FCardId,3,getdate(),A.FCardTypeId,A.FCompId,'DR','Import',0,'',A.FBalance,0,A.FBalance,0,getdate(),'从魅秀中导入' FROM jinan_dreamhair_feiyue2..mem_info AS A WHERE FDeleted = 0 UPDATE A SET A.FCreateDate = B.FCreateDate FROM jinan_dreamhair..TMemberCard AS A,jinan_dreamhair_feiyue1..mem_info AS B WHERE A.FCardId = B.FCardId UPDATE A SET A.FCreateDate = B.FCreateDate FROM jinan_dreamhair..TMemberCard AS A,jinan_dreamhair_feiyue2..mem_info AS B WHERE A.FCardId = B.FCardId UPDATE A SET A.FMemo = B.Rem FROM TMemberCard AS A,mem_info3 AS B WHERE A.FCardId = B.FCardId AND B.Rem IS NOT NULL SELECT * FROM TMemberCardType UPDATE TMemberCardType SET FId = FNo + 1000 WHERE FId > 0 UPDATE TMemberCard SET FTypeId = 0 DELETE TMemberCardTypeSUB ALTER TABLE mem_fund ADD FCompId BIGINT UPDATE mem_fund SET FCompId = jinan_dreamhair.dbo.FNCompId('007') WHERE mach = '1001' UPDATE mem_fund SET FCompId = jinan_dreamhair.dbo.FNCompId('008') WHERE mach = '1002' UPDATE mem_fund SET FCompId = jinan_dreamhair.dbo.FNCompId('009') WHERE mach = '1003' UPDATE mem_fund SET FCompId = jinan_dreamhair.dbo.FNCompId('010') WHERE mach = '1005' DELETE TMemberOldTransHist INSERT jinan_dreamhair..TMemberOldTransHist(FId,FMemId,FTime,FCardId,FCompId,FBillType,FBizType,FTransNo,FContent,FPrice,FQuantity,FAmount,FPayment,FEmployee,FMemo) SELECT jinan_dreamhair.dbo.FNNewId(),M.FMemId,fund_time,M.FCardId,A.FCompId,'DR',CASE WHEN fund_Type = 1 THEN '充值' ELSE '消费' END,'',a.mem,0,0,money ,'','','' FROM mem_fund AS A , mem_info AS M WHERE A.mem_id = M.mem_id SELECT * FROM mem_item WHERE mem_id = '203761' SELECT * FROM info_item WHERE item_id IN(select item_id from mem_item) --疗程 ALTER TABLE info_item ADD FId BIGINT ALTER TABLE info_item ADD FCourseId BIGINT UPDATE info_item SET FId = jinan_dreamhair.dbo.FNNewId() UPDATE info_item SET FCourseId = jinan_dreamhair.dbo.FNNewId() INSERT jinan_dreamhair..TItem(FId,FNo,FNoOfPad,FName,FAbbr,FTypeId,FBriefCode,FDescription,FPriceMode,FIsService,FStatTimes,FCustom1,FCustom2,FCustom3,FEnabled,FPrice,FVipPrice,FTime,FDctId,FPointMode,FPointValue,FDeptId,FAllowBooking,FDisplay) SELECT FId,'TL' + item_id,'TL' + item_id,item_name,item_name,0,jinan_dreamhair.dbo.FNGetFirstPinYin(item_name),'',1,1,1,'','','',1,Price,Price,0,0,1,0,0,1,1 FROM info_item WHERE item_id IN(select item_id from mem_item) INSERT jinan_dreamhair..TItemSub(FId,FCompId,FItemId,FPrice,FVipPrice,FTime,FDctId,FPointMode,FPointValue,FDeptId,FAllowBooking,FEnabled) SELECT jinan_dreamhair.dbo.FNNewId(),C.FId,I.FId,I.FPrice,I.FVipPrice,I.FTime,I.FDctId,I.FPointMode,I.FPointValue,I.FDeptId,I.FAllowBooking,I.FEnabled FROM jinan_dreamhair..TItem AS I,jinan_dreamhair..TCompany AS C WHERE I.FId != 0 AND C.FId != 0 AND I.FId IN(SELECT FId FROM info_item) AND C.FNo IN('007','008','009','010') INSERT INTO jinan_dreamhair.. TCourse(FId,FNo,FName,FBriefCode,FItemId,FPackId,FSequence,FTypeId,FTimes,FFreeTimes,FDurable,FValidityPeriodUnit,FValidityPeriod,FCreateDate,FExpiredDate,FDescription,FEnabled,FPrice,FAmount,FCalcMode) SELECT FCourseId, 'TL' + item_id + 'L1', item_name , jinan_dreamhair.dbo.FNGetFirstPinyin(item_name) AS FBriefCode, FId AS FItemId, 0 AS FPackId, 1 AS FSequence, 0 AS FTypeId, 1 AS FTimes, 0 AS FFreeTimes, 0 AS FDurable, 0 AS FValidityPeriodUnit, 0 AS FValidityPeriod, getdate() AS FCreateDate, NULL AS FExpiredDate, '' AS FDescription, 1 AS FEnabled, 0 AS FPrice, 0 AS FAmount, 1 AS FCalcMode FROM info_item WHERE item_id IN(SELECT item_id FROM mem_item) --疗程 ALTER TABLE mem_item ADD FCardTypeId BIGINT ALTER TABLE mem_item ADD FItemId BIGINT ALTER TABLE mem_item ADD FRemainTimes INT ALTER TABLE mem_item ADD FPurTimes INT ALTER TABLE mem_item ADD FUsedTimes INT ALTER TABLE mem_item ADD FPurAmount DECIMAL(18,6) ALTER TABLE mem_item ADD FCreateDate DATETIME ALTER TABLE mem_item ADD FExpiredDate DATETIME ALTER TABLE mem_item ADD FCompId BIGINT ALTER TABLE mem_item ADD FCardId BIGINT ALTER TABLE mem_item ADD FMemId BIGINT ALTER TABLE mem_item ADD FMemo VARCHAR(1000) UPDATE mem_item SET FCardId = jinan_dreamhair.dbo.FNNewId(),FPurAmount = 0 UPDATE A SET A.FCardTypeId = B.FCourseId, A.FItemId = B.FId FROM mem_item AS A,info_item AS B WHERE A.item_id = b.item_id UPDATE mem_item SET FPurTimes = sum_t UPDATE mem_item SET FUsedTimes = pay_t UPDATE A SET A.FCreateDate = B.FCreateDate, A.FMemId = B.FMemId, a.fcompId = B.FCompId FROM mem_item AS A,mem_info AS B WHERE A.mem_id = b.mem_id SELECT * FROM mem_item use jinan_dreamhair EXEC PInsertSystemParam 'AllowModifyCourseConsumePrice',Boolean,False,'疗程卡消费时,允许修改单价','' SELECT * FROM TMemberCardType use jinan_fuhang INSERT jinan_dreamhair..TMemberCourse(FId,FMemId,FCourseId,FMemPackId,FItemId,FCompId,FPurTimes,FUsedPurTimes,FPurAmount,FFreeTimes,FFreeAmount,FPurchaseDate,FExpiredDate,FBizType,FTransId,FArrear,FDurable,FMemo,FCalcMode,FAdjustPrice) SELECT FCardId,FMemId,FCardTypeId,0,FItemId,FCompId,FPurTimes,FUsedTimes,FPurAmount,0,0,FCreateDate,FExpiredDate,'DR.Import',0,0,0,'从飞跃导入',1,0 FROM mem_item AS A WHERE FMemId IS NOT NULL AND FMemId = 7423644254079250980 INSERT INTO jinan_dreamhair..TMemberCourseLog(FId,FMemId,FCardId,FPackId,FCourseId,FTime,FInPurTimes,FInFreeTimes,FOutPurTimes,FOutFreeTimes,FCompId,FBillType,FBizType,FBillId,FBillNo,FBillDetailId,FRecordTime) SELECT jinan_dreamhair.dbo.FNNewId(),FMemId,A.FCardId AS FCardId,0, ISNULL(FCardTypeId,0),getdate(),FPurTimes,0,FUsedTimes,0,FCompId,'DR','Import',0,'',0,getdate() FROM mem_item AS A WHERE FMemId IS NOT NULL use jinan_dreamhair UPDATE TMemberCard SET FCardNo = REPLACE(FCardNo,' ','') UPDATE TMember SET FMemNo = REPLACE(FMemNo,' ','') UPDATE TMember SET FName = REPLACE(FName,' ','') UPDATE TMember SET FMobilePhone = REPLACE(FMobilePhone,' ','') UPDATE TMemberCard SET FMemo = REPLACE(FMemo,' ','') WHERE FMemId IN(SELECT FMemID FROM jinan_fuhang..mem_info) UPDATE TItem SET FNo = REPLACE(FNo,' ','') UPDATE TItem SET FName = REPLACE(FName,' ','')