|
|
|
|
|
|
|
|
|
use QingDao_DeLai
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CREATE TABLE TImpCompany
|
|
|
|
|
(
|
|
|
|
|
shopId VARCHAR(100),
|
|
|
|
|
FCompId BIGINT
|
|
|
|
|
)
|
|
|
|
|
INSERT TImpCompany(shopId,FCompId)
|
|
|
|
|
SELECT '5610',DBO.FNCompId('001')
|
|
|
|
|
INSERT TImpCompany(shopId,FCompId)
|
|
|
|
|
SELECT '5611',DBO.FNCompId('002')
|
|
|
|
|
INSERT TImpCompany(shopId,FCompId)
|
|
|
|
|
SELECT '9558',DBO.FNCompId('003')
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD>Ŀ
|
|
|
|
|
--<EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
UPDATE TSystemParam SET FValue = 'true' WHERE FKey = 'AutoMatchDotEnabled'
|
|
|
|
|
|
|
|
|
|
CREATE TABLE TImpItemType
|
|
|
|
|
(
|
|
|
|
|
FId BIGINT,
|
|
|
|
|
FName NVARCHAR(100)
|
|
|
|
|
)
|
|
|
|
|
DELETE TImpItemType
|
|
|
|
|
|
|
|
|
|
INSERT TImpItemType(FId,FName)
|
|
|
|
|
SELECT dbo.FNNewId(),levelName
|
|
|
|
|
FROM TImpItem
|
|
|
|
|
GROUP BY levelName
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INSERT INTO TBasicType(FId,FKey,FNo,FName,FParentId,FDescription,FImage,FCustom,FOrder,FAllowEdit,FEnabled)
|
|
|
|
|
SELECT FId,'ItemType',FName,FName,0,'','','',0,14,1
|
|
|
|
|
FROM TImpItemType
|
|
|
|
|
|
|
|
|
|
INSERT TBasicTypeSub(FCompId,FBasicTypeID)
|
|
|
|
|
SELECT C.FId,A.FId
|
|
|
|
|
FROM TImpItemType AS A,TCompany AS C
|
|
|
|
|
WHERE 1=1
|
|
|
|
|
AND C.FId > 0
|
|
|
|
|
-- C.FNo IN('000','002')
|
|
|
|
|
|
|
|
|
|
DROP TABLE TImpItemEx
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD><EFBFBD><EFBFBD>Ŀ
|
|
|
|
|
SELECT dbo.FNNewId() AS FId,
|
|
|
|
|
MIN(number) AS number,
|
|
|
|
|
serviceName AS FName,
|
|
|
|
|
Min(levelName) AS FTypeName,
|
|
|
|
|
MAX(servicePrice) AS FPrice ,
|
|
|
|
|
CAST(MIN(number) AS VARCHAR(100)) AS FNo,
|
|
|
|
|
MAX(createtime) AS createtime,
|
|
|
|
|
CAST(0 AS INT) AS FIndex,
|
|
|
|
|
CAST(0 AS BIGINT) AS FTypeId
|
|
|
|
|
INTO TImpItemEx
|
|
|
|
|
FROM TImpItem
|
|
|
|
|
GROUP BY serviceName
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FIndex = (SELECT count(1) FROM TImpItemEx AS B WHERE (B.createTime < A.createTime OR (B.createTime = A.createTime AND A.Fid > b.fid) ) AND B.number = A.number)
|
|
|
|
|
FROM TImpItemEx AS A
|
|
|
|
|
|
|
|
|
|
UPDATE TImpItemEx SET FNo = number + '.' WHERE FIndex = 1
|
|
|
|
|
UPDATE TImpItemEx SET FNo = number + '..' WHERE FIndex = 2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TIMpItemEx
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FTypeId = B.FId
|
|
|
|
|
FROM TImpItemEx AS A,TImpItemType AS B
|
|
|
|
|
WHERE A.FTypeName = B.FName
|
|
|
|
|
|
|
|
|
|
ALTER TABLE TImpItem ADD FId BIGINT
|
|
|
|
|
ALTER TABLE TImpItem ADD FCompId BIGINT
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FId = B.FId
|
|
|
|
|
FROM TImpItem AS A,TImpItemEx AS B
|
|
|
|
|
WHERE A.serviceName = B.FName
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FCompId = B.FCompId
|
|
|
|
|
FROM TImpItem AS A,TImpCompany AS B
|
|
|
|
|
WHERE A.shopId = B.shopId
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INSERT INTO TItem(FId,FNo,FNoOfPad,FName,FAbbr,FTypeId,FBriefCode,FDescription,FPriceMode,FIsService,FStatTimes,FCustom1,FCustom2,FCustom3,FEnabled,FPrice,FVipPrice,FTime,FDctId,FDisplayTypeId,FBrandId,FPointMode,FPointValue,FDeptId,FAllowBooking,FDisplay,FHidden,FDeleted)
|
|
|
|
|
SELECT FId,FNo,FNo,FName,FName,FTypeId,dbo.FNGetFirstPinYin(FName),'',1,1,0,'','','',1,FPrice,FPrice,0,0,0,0,0,0,0,1,1,0,0
|
|
|
|
|
FROM TImpItemEx
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INSERT INTO TItemSub(FId,FCompId,FItemId,FPrice,FVipPrice,FTime,FDctId,FPointMode,FPointValue,FDeptId,FAllowBooking,FEnabled)
|
|
|
|
|
SELECT dbo.FNNewId(),B.FCompId,B.FId,MAX(serviceprice),MAX(serviceprice),0,0,0,0,0,1,1
|
|
|
|
|
FROM TImpItem AS B
|
|
|
|
|
GROUP BY FCompId,FId
|
|
|
|
|
|
|
|
|
|
ALTER TABLE TImpItemEx ADD FCourseId BIGINT
|
|
|
|
|
UPDATE TImpItemEx SET FCourseId = dbo.FNNewId()
|
|
|
|
|
|
|
|
|
|
INSERT INTO TCourse(FId,FNo,FName,FBriefCode,FItemId,FPackId,FSequence,FTypeId,FTimes,FFreeTimes,FDurable,FValidityPeriodUnit,FValidityPeriod,FCreateDate,FExpiredDate,FDescription,FEnabled,FPrice,FAmount,FCalcMode)
|
|
|
|
|
SELECT FCourseId AS FId,
|
|
|
|
|
I.FNo + 'L1',
|
|
|
|
|
I.FName + '-' + '<EFBFBD>Ƴ<EFBFBD>1' AS FName,
|
|
|
|
|
'' AS FBriefCode,
|
|
|
|
|
I.FId AS FItemId,
|
|
|
|
|
0 AS FPackId,
|
|
|
|
|
1 AS FSequence,
|
|
|
|
|
(SELECT TOP 1 FId FROM TBasicType WHERE FKey = 'CourseType') 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 TImpItemEx AS I
|
|
|
|
|
WHERE FName IN(SELECT serviceName FROM TImpMemberCourse)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD>Ʒ
|
|
|
|
|
CREATE TABLE TImpGoodsType
|
|
|
|
|
(
|
|
|
|
|
FId BIGINT,
|
|
|
|
|
FName NVARCHAR(100)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
DELETE TImpGoodsType
|
|
|
|
|
|
|
|
|
|
INSERT TImpGoodsType(FId,FName)
|
|
|
|
|
SELECT dbo.FNNewId(),levelName
|
|
|
|
|
FROM TImpGoods
|
|
|
|
|
GROUP BY levelName
|
|
|
|
|
|
|
|
|
|
INSERT INTO TBasicType(FId,FKey,FNo,FName,FParentId,FDescription,FImage,FCustom,FOrder,FAllowEdit,FEnabled)
|
|
|
|
|
SELECT FId,'GoodsType',FName,FName,0,'','','',0,14,1
|
|
|
|
|
FROM TImpGoodsType
|
|
|
|
|
|
|
|
|
|
INSERT TBasicTypeSub(FCompId,FBasicTypeID)
|
|
|
|
|
SELECT C.FId,A.FId
|
|
|
|
|
FROM TImpGoodsType AS A,TCompany AS C
|
|
|
|
|
WHERE 1=1
|
|
|
|
|
AND C.FId > 0
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD>λ
|
|
|
|
|
CREATE TABLE TImpGoodsUnit
|
|
|
|
|
(
|
|
|
|
|
FId BIGINT,
|
|
|
|
|
FName NVARCHAR(100)
|
|
|
|
|
)
|
|
|
|
|
INSERT TImpGoodsUnit(FId,FName)
|
|
|
|
|
SELECT dbo.FNNewId(),unit FROM TImpGoods
|
|
|
|
|
WHERE unit NOT IN(SELECT FName FROM TBasicType WHERE FKey = 'GoodsUnit')
|
|
|
|
|
AND unit > ''
|
|
|
|
|
GROUP BY unit
|
|
|
|
|
|
|
|
|
|
INSERT INTO TBasicType(FId,FKey,FNo,FName,FParentId,FDescription,FImage,FCustom,FOrder,FAllowEdit,FEnabled)
|
|
|
|
|
SELECT FId,'GoodsUnit',FName,FName,0,'','','',0,14,1
|
|
|
|
|
FROM TImpGoodsUnit
|
|
|
|
|
|
|
|
|
|
INSERT TBasicTypeSub(FCompId,FBasicTypeID)
|
|
|
|
|
SELECT C.FId,A.FId
|
|
|
|
|
FROM TImpGoodsUnit AS A,TCompany AS C
|
|
|
|
|
WHERE 1=1
|
|
|
|
|
AND C.FId > 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DROP TABLE TImpGoodsEx
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD><EFBFBD><EFBFBD>Ŀ
|
|
|
|
|
SELECT dbo.FNNewId() AS FId,
|
|
|
|
|
MIN(number) AS number,
|
|
|
|
|
goodsName AS FName,
|
|
|
|
|
Min(levelName) AS FTypeName,
|
|
|
|
|
MAX(price_out) AS FPrice ,
|
|
|
|
|
CAST(MIN(number) AS VARCHAR(100)) AS FNo,
|
|
|
|
|
MAX(createtime) AS createtime,
|
|
|
|
|
MAX(unit) AS unit,
|
|
|
|
|
CAST(0 AS BIGINT) AS FUnitId,
|
|
|
|
|
CAST(0 AS INT) AS FIndex,
|
|
|
|
|
CAST(0 AS BIGINT) AS FTypeId
|
|
|
|
|
INTO TImpGoodsEx
|
|
|
|
|
FROM TImpGoods
|
|
|
|
|
GROUP BY goodsName
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FIndex = (SELECT count(1) FROM TImpGoodsEx AS B WHERE (B.createTime < A.createTime OR (B.createTime = A.createTime AND A.Fid > b.fid) ) AND B.number = A.number)
|
|
|
|
|
FROM TImpGoodsEx AS A
|
|
|
|
|
|
|
|
|
|
UPDATE TImpGoodsEx SET FNo = number + '.' WHERE FIndex = 1
|
|
|
|
|
UPDATE TImpGoodsEx SET FNo = number + '..' WHERE FIndex = 2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FTypeId = B.FId
|
|
|
|
|
FROM TImpGoodsEx AS A,TImpGoodsType AS B
|
|
|
|
|
WHERE A.FTypeName = B.FName
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FUnitId = B.FId
|
|
|
|
|
FROM TImpGoodsEx AS A,TBasicType AS B
|
|
|
|
|
WHERE A.unit = B.FName
|
|
|
|
|
AND B.FKey = 'GoodsUnit'
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FUnitId = B.FId
|
|
|
|
|
FROM TImpGoodsEx AS A,TBasicType AS B
|
|
|
|
|
WHERE B.FKey = 'GoodsUnit'
|
|
|
|
|
AND B.FName = 'ƿ'
|
|
|
|
|
AND A.FUnitId = 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FUnitId = B.FId
|
|
|
|
|
FROM TImpGoodsEx AS A,TImpGoodsUnit AS B
|
|
|
|
|
WHERE A.unit = B.FName
|
|
|
|
|
|
|
|
|
|
ALTER TABLE TImpGoods ADD FId BIGINT
|
|
|
|
|
ALTER TABLE TImpGoods ADD FCompId BIGINT
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FId = B.FId
|
|
|
|
|
FROM TImpGoods AS A,TImpGoodsEx AS B
|
|
|
|
|
WHERE A.goodsName = B.FName
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FCompId = B.FCompId
|
|
|
|
|
FROM TImpGoods AS A,TImpCompany AS B
|
|
|
|
|
WHERE A.shopId = B.shopId
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INSERT INTO TGoods(FId,FNo,FName,FNoOfPad,FTypeId,FBriefCode,FUnitId,FSalePrice,FPurCostPrice,FSaleCostPrice,FConsCostPrice,FValuationMode,FBarCode,FEnabled,FSpecification,FPurUnitId,FConsUnitId,FSupplierId,FStoreId,FConsStoreId,FSaleStoreId,FMaxStock,FMinStock,FPeriodEnabled,FShelfLife,FDctId,FDisplayTypeId,FPointMode,FPointValue,FDeptId,FIsSale,FUnitLock,FDescription,FCustom1,FCustom2,FCustom3,FImage,FHidden,FDeleted)
|
|
|
|
|
SELECT FId,FNo,FName,FNo,FTypeId,dbo.FNGetFirstPinYin(FName),FUnitId,FPrice AS FSalePrice,0 as FPurCostPrice,0 as FSaleCostPrice,0 as FConsCostPrice,0 as FValuationMode,'' as FBarCode,1 as FEnabled,0 as FSpecification,0 as FPurUnitId,0 as FConsUnitId,0 as FSupplierId,0 as FStoreId,0 as FConsStoreId,0 as FSaleStoreId,0 as FMaxStock,0 as FMinStock,0 as FPeriodEnabled,0 as FShelfLife,0 AS FDctId,0 AS FDisplayTypeId,0 AS FPointMode,0 AS FPointValue,0 AS FDeptId,1 AS FIsSale,0 AS FUnitLock,'' AS FDescription,'' AS FCustom1,'' AS FCustom2,'' AS FCustom3,'' AS FImage,0 AS FHidden,0 AS FDeleted
|
|
|
|
|
FROM TIMpGoodsEx
|
|
|
|
|
|
|
|
|
|
INSERT INTO TGoodsSub(FId,FCompId,FGoodsId,FSalePrice,FPurCostPrice,FSaleCostPrice,FConsCostPrice)
|
|
|
|
|
SELECT dbo.FNNewId(),FCompId,FId,MAX(price_out),0,0,0
|
|
|
|
|
FROM TImpGoods
|
|
|
|
|
GROUP BY FCompId,FId
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpMemberCard
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--Ա<EFBFBD><EFBFBD>
|
|
|
|
|
CREATE TABLE TImpPosition
|
|
|
|
|
(
|
|
|
|
|
FId BIGINT,
|
|
|
|
|
FName VARCHAR(100)
|
|
|
|
|
)
|
|
|
|
|
INSERT TImpPosition
|
|
|
|
|
SELECT DBO.FNNEWiD(),levelname
|
|
|
|
|
FROM TImpEmployee
|
|
|
|
|
GROUP BY levelName
|
|
|
|
|
|
|
|
|
|
INSERT INTO TBasicType(FId,FKey,FNo,FName,FParentId,FDescription,FImage,FCustom,FOrder,FAllowEdit,FEnabled)
|
|
|
|
|
SELECT FId,'Position',FName,FName,0,'','','',0,14,1
|
|
|
|
|
FROM TImpPosition
|
|
|
|
|
|
|
|
|
|
INSERT TBasicTypeSub(FCompId,FBasicTypeID)
|
|
|
|
|
SELECT C.FId,A.FId
|
|
|
|
|
FROM TImpPosition AS A,TCompany AS C
|
|
|
|
|
WHERE 1=1
|
|
|
|
|
AND C.FId > 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ALTER TABLE TImpEmployee ADD FCompId BIGINT
|
|
|
|
|
ALTER TABLE TImpEmployee ADD FPosId BIGINT
|
|
|
|
|
ALTER TABLE TImpEmployee ADD FId BIGINT
|
|
|
|
|
ALTER TABLE TImpEmployee ADD FNo VARCHAR(50)
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FCompId = B.FCompId
|
|
|
|
|
FROM TImpEmployee AS A,TImpCompany AS B
|
|
|
|
|
WHERE A.shopId = B.shopId
|
|
|
|
|
|
|
|
|
|
update TImpEmployee SET FId = dbo.FNNewId()
|
|
|
|
|
update TImpEmployee SET FNo = number
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FNo = C.FNo + A.number
|
|
|
|
|
FROM TImpEmployee AS A,TCompany AS C
|
|
|
|
|
WHERE C.FId = A.FCompId
|
|
|
|
|
AND A.number
|
|
|
|
|
IN(SELECT number FROM TImpEmployee
|
|
|
|
|
GROUP BY number
|
|
|
|
|
HAVING SUM(1) > 1
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FPosId = B.FId
|
|
|
|
|
FROM TImpEmployee AS A,TImpPosition AS B
|
|
|
|
|
WHERE A.levelName = B.FName
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TEmployeeRole
|
|
|
|
|
|
|
|
|
|
INSERT INTO TEmployee(FId,FNo,FName,FEnLname,FEnFname,FNickname,FCompId,FDeptId,FPosId,FTechTypeId,FGroupId,FBriefCode,FGender,FStature,FWeight,FNationPlace,FNation,FEducation,FMarital,FAddress,FTelephone,FMobilePhone,FQQ,FEmail,FIdCard,FBirthdayType,FBirthday,FCardNo,FPW,FBank,FBankCardNo,FSSNo,FHCNo,FLinkMan,FLinkManTel,FLinkManAddr,FIsManager,FAllowBooking,FBookingCount,FContractType,FState,FCreatorId,FCreateDate,FEntryDate,FExpiredDate,FLeaveDate,FIntroduction,FMemo,FPrice,FTags,FAvatar,FRoleId,FDeleted)
|
|
|
|
|
SELECT FId,FNo,truename,'' AS FEnLname,'' AS FEnFname,truename AS FNickname,FCompId,0,FPosId,0,0,dbo.FNGetFirstPinYin(truename),case when sex = '<EFBFBD><EFBFBD>' then 1 else 0 end,0 as FStature,0 as FWeight,'' as FNationPlace,'' as FNation,'' as FEducation,'' as FMarital,'' as FAddress,'' as FTelephone,tel as FMobilePhone,'' as FQQ,'' as FEmail,idcard as FIdCard,'G' as FBirthdayType,'' as FBirthday,'' as FCardNo,'' as FPW,'' as FBank,'' as FBankCardNo,'' as FSSNo,'' as FHCNo,''as FLinkMan,'' as FLinkManTel,'' as FLinkManAddr,0 as FIsManager,1 as FAllowBooking,0 as FBookingCount,'' as FContractType,1 as FState,0 as FCreatorId,getdate() as FCreateDate,entrytime as FEntryDate,null as FExpiredDate,null as FLeaveDate,'' as FIntroduction,'' as FMemo,0 as FPrice,'' as FTags,'' as FAvatar,10000 as FRoleId,0 FDeleted
|
|
|
|
|
FROM TImpEmployee
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INSERT INTO TEmployeeSub(FEmpId,FCompId,FSerialNo)
|
|
|
|
|
SELECT FId,FCompId,number
|
|
|
|
|
FROM TImpEmployee
|
|
|
|
|
|
|
|
|
|
SELECT FNo,truename FROM TImpEmployee
|
|
|
|
|
WHERE truename IN(
|
|
|
|
|
|
|
|
|
|
SELECT truename FROM TImpEmployee
|
|
|
|
|
GROUP BY truename
|
|
|
|
|
HAVING SUM(1 ) >1
|
|
|
|
|
)
|
|
|
|
|
ORDER BY truename
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD>Ա
|
|
|
|
|
ALTER TABLE TImpMember ADD FMemId BIGINT
|
|
|
|
|
ALTER TABLE TImpMember ADD FCardId BIGINT
|
|
|
|
|
ALTER TABLE TImpMember ADD FCardTypeName VARCHAR(100)
|
|
|
|
|
ALTER TABLE TImpMember ADD FMemNo VARCHAR(50)
|
|
|
|
|
ALTER TABLE TImpMember ADD FCardNo VARCHAR(50)
|
|
|
|
|
ALTER TABLE TImpMember ADD FName VARCHAR(50)
|
|
|
|
|
ALTER TABLE TImpMember ADD FGender INT
|
|
|
|
|
ALTER TABLE TImpMember ADD FMobile VARCHAR(50)
|
|
|
|
|
ALTER TABLE TImpMember ADD FBirthdayType VARCHAR(50)
|
|
|
|
|
ALTER TABLE TImpMember ADD FBirthday DATETIME
|
|
|
|
|
ALTER TABLE TImpMember ADD FCompId BIGINT
|
|
|
|
|
ALTER TABLE TImpMember ADD FCardTypeId BIGINT
|
|
|
|
|
ALTER TABLE TImpMember ADD FMemo VARCHAR(MAX)
|
|
|
|
|
ALTER TABLE TImpMember ADD FBalance DECIMAL(18,6)
|
|
|
|
|
ALTER TABLE TImpMember ADD FBalance2 DECIMAL(18,6)
|
|
|
|
|
ALTER TABLE TImpMember ADD FPoint DECIMAL(18,6)
|
|
|
|
|
ALTER TABLE TImpMember ADD FCreateDate DATETIME
|
|
|
|
|
ALTER TABLE TImpMember ADD FExpiredDate DATETIME
|
|
|
|
|
ALTER TABLE TImpMember ADD FDeleted BIT
|
|
|
|
|
ALTER TABLE TImpMember ADD FBizEmpId BIGINT
|
|
|
|
|
|
|
|
|
|
drop table TImpCardTypeEx
|
|
|
|
|
|
|
|
|
|
SELECT dbo.FNNewId() AS FId,
|
|
|
|
|
cardtypename AS FNo,
|
|
|
|
|
cardtypename AS FName,
|
|
|
|
|
getdate() AS createTime,
|
|
|
|
|
CAST(0 AS INT) AS FIndex
|
|
|
|
|
INTO TImpCardTypeEx
|
|
|
|
|
FROM TImpMember
|
|
|
|
|
GROUP BY cardtypename
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FIndex = (SELECT count(1) FROM TImpCardTypeEx AS B WHERE (B.createTime < A.createTime OR (B.createTime = A.createTime AND A.Fid > b.fid) ) AND B.cardno = A.cardno)
|
|
|
|
|
FROM TImpCardTypeEx AS A
|
|
|
|
|
|
|
|
|
|
UPDATE TImpCardTypeEx SET FNo = cardno + '.' WHERE FIndex = 1
|
|
|
|
|
UPDATE TImpCardTypeEx SET FNo = cardno + '..' WHERE FIndex = 2
|
|
|
|
|
|
|
|
|
|
ALTER TABLE TImpCardType ADD FCompId BIGINT,FId BIGINT
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FCompId = B.FCompId
|
|
|
|
|
FROM TImpCardType AS A,TImpCompany AS B
|
|
|
|
|
WHERE A.shopId = B.shopId
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FId = B.FId
|
|
|
|
|
FROM TImpCardType AS A,TImpCardTypeEX AS B
|
|
|
|
|
WHERE a.cardName = B.FName
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
INSERT INTO TMemberCardType(FId,FNo,FName,FValueType,FMaterial,FPrice,FCardFeeAmt,FAcctId,FDeposit,FAcctId2,FDeposit2,FAcctId3,FDeposit3,FTimes,FAlertBalance,FMinRchgAmt,FSalePointMode,FSalePointValue,FRchgPointMode,FRchgPointValue,FPaySmsFee,FTimeCard,FValidityPeriod,FValidityPeriodUnit,FExpiredDate,FDefaultMemo,FCreateTime,FAllowSale,FAllowRchg,FDeptId,FEnabled,FOrder)
|
|
|
|
|
SELECT FId ,FNo,FName,1,FMaterial = 2,0,FCardFeeAmt = 0,FAcctId = 3,FDeposit = 0,FAcctId2 = 0,FDeposit2 = 0 ,FAcctId3 = 0,FDeposit3 = 0,
|
|
|
|
|
FTimes = 0,FAlertBalance = 0,FMinRchgAmt = 0,FSalePointMode = 0,FSalePointValue = 0 ,FRchgPointMode = 0,FRchgPointValue = 0,FPaySmsFee = 0,FTimeCard = 0,FValidityPeriod = 100,FValidityPeriodUnit = 1,
|
|
|
|
|
FExpiredDate = NULL,FDefaultMemo = '',FCreateTime = GETDATE(),1,1,FDeptId = 0,FEnabled =1,FOrder = 1
|
|
|
|
|
FROM TImpCardTypeEx
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INSERT TMemberCardTypeSub(FId,FCompId,FCardTypeId,FAllowSale,FAllowRchg,FEnabled)
|
|
|
|
|
SELECT dbo.FNNewId(),dbo.FNCompId('006'),A.FId,1,1,1
|
|
|
|
|
FROM TImpCardTypeEx AS A
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INSERT TMemberCardTypeSub(FId,FCompId,FCardTypeId,FAllowSale,FAllowRchg,FEnabled)
|
|
|
|
|
SELECT dbo.FNNewId(),1,FId,1,1,1
|
|
|
|
|
FROM TImpCardTypeEx
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE TImpMember SET FCardId = dbo.FNNewId() WHERE FCardId IS NULL
|
|
|
|
|
UPDATE TImpMember SET FMemId = dbo.FNNewId() WHERE FMemId IS NULL
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE TImpMember SET FName = truename
|
|
|
|
|
UPDATE TImpMember SET FMobile = phone
|
|
|
|
|
UPDATE TImpMember SET FMemNO = cardno
|
|
|
|
|
UPDATE TImpMember SET FCardNo = cardno
|
|
|
|
|
UPDATE TImpMember SET FCompId = dbo.FNCompId('006')
|
|
|
|
|
UPDATE TImpMember SET FGender = CASE WHEN sex = 1 THEN 0 ELSE 1 END
|
|
|
|
|
UPDATE TImpMember SET FMemo = ISNULL(remark,'')
|
|
|
|
|
UPDATE TImpMember SET FMemo = '' WHERE FMemo IS NULL
|
|
|
|
|
UPDATE TImpMember SET FPoint = integral
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE TImpMember SET FBalance = balance
|
|
|
|
|
UPDATE TImpMember SET FBalance2 = freeprice
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE TImpMember SET FCreateDate = createTime
|
|
|
|
|
UPDATE TImpMember SET FExpiredDate = NULL
|
|
|
|
|
UPDATE TImpMember SET FExpiredDate = dateadd(year,100,FCreateDate) where FExpiredDate IS NULL
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FCardTypeId = B.Fid
|
|
|
|
|
FROM TImpMember AS A,TImpCardTypeEx AS B
|
|
|
|
|
WHERE A.cardtypename = b.FName
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FBizEmpId = B.FId
|
|
|
|
|
FROM TImpMember AS A, TImpEmployee AS B
|
|
|
|
|
WHERE A.rel_staffid = b.id
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE TImpMember SET FBirthday = birthday WHERE birthday != '' AND LEN(birthday ) >= 10
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE TImpMember SET FBirthdayType = CASE birthday_type WHEN 1 THEN 'L' ELSE 'G' END
|
|
|
|
|
|
|
|
|
|
UPDATE TImpMember SET FDeleted = 0
|
|
|
|
|
UPDATE TImpMember SET FDeleted = 1 WHERE isdelete = 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FCompId = B.FCompId
|
|
|
|
|
FROM TImpMember AS A,TImpCompany AS B
|
|
|
|
|
WHERE A.shopId = B.shopId
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--<EFBFBD>ظ<EFBFBD>
|
|
|
|
|
ALTER TABLE TImpMember ADD FINdex INT
|
|
|
|
|
ALTER TABLE TImpMember ADD FIndex INT
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FIndex = 1+(SELECT COUNT(1) FROM TImpMember AS B WHERE A.FCardNo = B.FCardNo AND (A.FCreateDate > B.FCreateDate OR (A.FCreateDate = B.FCreateDate AND (A.FCardId > B.FCardId) )))
|
|
|
|
|
FROM TImpMember AS A
|
|
|
|
|
|
|
|
|
|
UPDATE TImpMember
|
|
|
|
|
SET FCardNO = FCardNo + '.' + CAST(FIndex AS VARCHAR)
|
|
|
|
|
WHERE FCardNo in(
|
|
|
|
|
SELECT FCardNo FROM TImpMember
|
|
|
|
|
WHERE FDeleted = 0
|
|
|
|
|
GROUP BY FCardNo
|
|
|
|
|
HAVING SUM(1 ) > 1)
|
|
|
|
|
|
|
|
|
|
UPDATE TImpMember SET FMemNO = FCardNo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INSERT INTO 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,
|
|
|
|
|
dbo.FNGetFirstPinYin(FName),
|
|
|
|
|
0 AS FTypeId,
|
|
|
|
|
FCompId AS FCompId,
|
|
|
|
|
FCreateDate AS FCreateDate,
|
|
|
|
|
FGender AS FGender,
|
|
|
|
|
FBirthdayType AS FBirthdayType,
|
|
|
|
|
FBirthday AS FBirthday,
|
|
|
|
|
'' AS FTelephone,
|
|
|
|
|
ISNULL(FMobile,'') AS FMobilePhone,
|
|
|
|
|
'' AS FQQ,
|
|
|
|
|
'' AS FWeChat,
|
|
|
|
|
'' AS FIdCard,
|
|
|
|
|
'' AS FEmail,
|
|
|
|
|
'' AS FAddress,
|
|
|
|
|
0 AS FProId,
|
|
|
|
|
'' AS FCPW,
|
|
|
|
|
'' AS FQPW,
|
|
|
|
|
0 AS FChargeEmpId,
|
|
|
|
|
0 AS FPoint,
|
|
|
|
|
1 AS FRecvConsSMS,
|
|
|
|
|
1 AS FRecvBulkSMS,
|
|
|
|
|
'' AS FMemo,
|
|
|
|
|
'' AS FCustom1,'' AS FCustom2,'' AS FCustom3,'' AS FCustom4,'' AS FCustom5
|
|
|
|
|
from TImpMember
|
|
|
|
|
WHERE FDeleted = 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INSERT INTO TMemberCard(
|
|
|
|
|
FCardId,
|
|
|
|
|
FCardNo,
|
|
|
|
|
|
|
|
|
|
FTypeId,
|
|
|
|
|
FValueType,
|
|
|
|
|
FCompId,
|
|
|
|
|
FMemId,
|
|
|
|
|
FState,
|
|
|
|
|
FCreateDate,
|
|
|
|
|
FExpiredDate,
|
|
|
|
|
FTotalTimes,
|
|
|
|
|
FUsedTimes,
|
|
|
|
|
FSaleCompId,
|
|
|
|
|
FSaleBillId,
|
|
|
|
|
FMemo,
|
|
|
|
|
FBizEmpId)
|
|
|
|
|
SELECT
|
|
|
|
|
FCardId AS FId,
|
|
|
|
|
FMemNo AS FNo,
|
|
|
|
|
|
|
|
|
|
FCardTypeId AS FTypeId,
|
|
|
|
|
(SELECT FValueType FROM TMemberCardType WHERE FId = FCardTypeId) AS FValueType,
|
|
|
|
|
FCompId AS FCompId,
|
|
|
|
|
FMemId AS FMemId,
|
|
|
|
|
1 AS FState,
|
|
|
|
|
FCreateDate AS FCreateDate,
|
|
|
|
|
FExpiredDate AS FExpiredDate,
|
|
|
|
|
0 AS FTotalTimes,
|
|
|
|
|
0 AS FUsedTimes,
|
|
|
|
|
FCompId AS FSaleCompId,
|
|
|
|
|
0 AS FSaleBillId,
|
|
|
|
|
FMemo AS FMemo ,
|
|
|
|
|
ISNULL(FBizEmpId, 0)
|
|
|
|
|
FROM TImpMember
|
|
|
|
|
WHERE FDeleted = 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INSERT TMemberCardAccount(FMemId,FId,FCardId,FAcctId,FDeposit,FBalance,FArrear,FCreateDate,FExpiredDate,FMemo)
|
|
|
|
|
SELECT FMemId,dbo.FNNewId(),FCardId AS FCardId,3,FBalance,FBalance,0,FCreateDate,NULL AS FExpiredDate,''
|
|
|
|
|
FROM TImpMember
|
|
|
|
|
WHERE FDeleted = 0
|
|
|
|
|
|
|
|
|
|
INSERT TMemberCardAcctHist(FId,FMemId,FCardId,FAcctId,FTime,FCardTypeId,FCompId,FBillType,FBizType,FTransId,FTransNo,FInAmount,FOutAmount,FBalance,FArrear,FRecordTime,FMemo)
|
|
|
|
|
select dbo.FNNewId(),A.FMemId,A.FCardId,3,getdate(),A.FCardTypeId,A.FCompId,'DR','Import',0,'',A.FBalance,0,A.FBalance,0,getdate(),'<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ<EFBFBD>е<EFBFBD><EFBFBD><EFBFBD>'
|
|
|
|
|
FROM TImpMember AS A
|
|
|
|
|
WHERE FDeleted = 0
|
|
|
|
|
|
|
|
|
|
INSERT TMemberCardAccount(FMemId,FId,FCardId,FAcctId,FDeposit,FBalance,FArrear,FCreateDate,FExpiredDate,FMemo)
|
|
|
|
|
SELECT FMemId,dbo.FNNewId(),FCardId AS FCardId,10,FBalance2,FBalance2,0,FCreateDate,NULL AS FExpiredDate,''
|
|
|
|
|
FROM TImpMember
|
|
|
|
|
WHERE FBalance2 > 0
|
|
|
|
|
AND FDeleted = 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INSERT TMemberCardAcctHist(FId,FMemId,FCardId,FAcctId,FTime,FCardTypeId,FCompId,FBillType,FBizType,FTransId,FTransNo,FInAmount,FOutAmount,FBalance,FArrear,FRecordTime,FMemo)
|
|
|
|
|
select dbo.FNNewId(),A.FMemId,A.FCardId,10,getdate(),A.FCardTypeId,A.FCompId,'DR','Import',0,'',A.FBalance2,0,A.FBalance2,0,getdate(),'<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ<EFBFBD>е<EFBFBD><EFBFBD><EFBFBD>'
|
|
|
|
|
FROM TImpMember AS A
|
|
|
|
|
WHERE FBalance2 > 0
|
|
|
|
|
AND FDeleted = 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INSERT TMemberPointHist(FId,FMemId,FTime,FCardId,FCompId,FBillType,FBizType,FTransId,FTransNo,FInAmount,FOutAmount,FBalance,FMemo,FRecordTime)
|
|
|
|
|
SELECT dbo.FNNewId(),A.FMemId,getdate(),0,1,'DR','Import',0,'',FPoint,0,FPoint,'',getdate()
|
|
|
|
|
FROM TImpMember AS A
|
|
|
|
|
WHERE FPoint != 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpMemberCourse
|
|
|
|
|
WHERE memberId = 2234504
|
|
|
|
|
|
|
|
|
|
WHERE packageId IN(SELECT id FROM TImpCourse)
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpMember WHERE id = 2234504
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpCourse
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ALTER TABLE TImpMemberCourse ADD FMemId BIGINT
|
|
|
|
|
ALTER TABLE TImpMemberCourse ADD FId BIGINT
|
|
|
|
|
ALTER TABLE TImpMemberCourse ADD FCourseId BIGINT
|
|
|
|
|
ALTER TABLE TImpMemberCourse ADD FRemainTimes DECIMAL(18,6)
|
|
|
|
|
ALTER TABLE TImpMemberCourse ADD FUsedPurTimes DECIMAL(18,6)
|
|
|
|
|
ALTER TABLE TImpMemberCourse ADD FPurAmount DECIMAL(18,6)
|
|
|
|
|
ALTER TABLE TImpMemberCourse ADD FCompId BIGINT
|
|
|
|
|
ALTER TABLE TImpMemberCourse ADD FItemId BIGINT
|
|
|
|
|
ALTER TABLE TImpMemberCourse ADD FCreateDate DATETIME
|
|
|
|
|
ALTER TABLE TImpMemberCourse ADD FExpiredDate DATETIME
|
|
|
|
|
ALTER TABLE TImpMemberCourse ADD FPurTimes DECIMAL(18,6)
|
|
|
|
|
ALTER TABLE TImpMemberCourse ADD FAdjustPrice DECIMAL(18,6)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FMemId = B.FMemId
|
|
|
|
|
FROM TImpMemberCourse AS A,TImpMember AS B
|
|
|
|
|
WHERE A.memberId = B.memId
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FCompId = B.FCompId
|
|
|
|
|
FROM TImpMemberCourse AS A,TImpCompany AS B
|
|
|
|
|
WHERE A.shopId = B.shopId
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FItemId = B.FId,
|
|
|
|
|
A.FCourseId = B.FCourseId
|
|
|
|
|
FROM TImpMemberCourse AS A,TImpItemEx AS B
|
|
|
|
|
WHERE A.serviceName = B.FName
|
|
|
|
|
|
|
|
|
|
UPDATE TImpMemberCourse SET FId = dbo.FNNewId()
|
|
|
|
|
UPDATE TImpMemberCourse SET FPurTimes = count
|
|
|
|
|
UPDATE TImpMemberCourse SET FPurAmount = totalPrice
|
|
|
|
|
UPDATE TImpMemberCourse SET FAdjustPrice = cast(avgPrice as float)
|
|
|
|
|
UPDATE TImpMemberCourse SET FUsedPurTimes = countuse
|
|
|
|
|
UPDATE TImpMemberCourse SET FExpiredDate = validtime where validtime != '0000-00-00'
|
|
|
|
|
UPDATE TImpMemberCourse SET FExpiredDate = null where validtime = '0000-00-00'
|
|
|
|
|
UPDATE TImpMemberCourse SET FCreateDate = getdate()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INSERT TMemberCourse(FId,FMemId,FCourseId,FMemPackId,FItemId,FCompId,FPurTimes,FPurAmount,FFreeTimes,FUsedPurTimes,FFreeAmount,FPurchaseDate,FExpiredDate,FBizType,FTransId,FArrear,FDurable,FMemo,FCalcMode,FAdjustPrice)
|
|
|
|
|
SELECT FId,FMemId,FCourseId,0,FItemId,FCompId,FPurTimes,ISNULL(FPurAmount,0),0,FUsedPurTimes,0,FCreateDate,FExpiredDate,'DR.Import',0,0,0,'<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>',1,ISNULL(FAdjustPrice,0)
|
|
|
|
|
FROM TImpMemberCourse
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INSERT INTO TMemberCourseLog(FId,FMemId,FCardId,FPackId,FCourseId,FTime,FInPurTimes,FInFreeTimes,FOutPurTimes,FOutFreeTimes,
|
|
|
|
|
FCompId,
|
|
|
|
|
FBillType,FBizType,FBillId,FBillNo,FBillDetailId)
|
|
|
|
|
|
|
|
|
|
SELECT dbo.FNNewId(),FMemId,FId,0,FCourseId,FTime = getdate(),FPurTimes,FUsedPurTimes,0,0,
|
|
|
|
|
FCompId,
|
|
|
|
|
'DR','Import',0,'',0
|
|
|
|
|
FROM TImpMemberCourse
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TMember WHERE FMemId = 6882680520780379331
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpMemberTransHist
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|