Revert "✨ feat(db): 给GiftCode添加只读库支持"
This reverts commit a75feb611ff5e732a48408ea9360cb07f9c09f2e.
This commit is contained in:
@@ -11,7 +11,7 @@ import { useGiftPackage } from "../../../services/activity/giftPackageService";
|
||||
import { getAp, setAp, setApBuyTimes } from "../../../services/actionPointService";
|
||||
import { ActionPointModel } from "../../../db/ActionPoint";
|
||||
import { GiftCodeDetailModel } from "../../../db/GiftCodeDetail";
|
||||
import GiftCode from "../../../db/GiftCode";
|
||||
import { GiftCodeType, GiftCodeModel } from "../../../db/GiftCode";
|
||||
import { nowSeconds } from "../../../pubUtils/timeUtil";
|
||||
import { AP } from "../../../pubUtils/dicParam";
|
||||
import { GiftPackageFloorModel } from "../../../db/GiftPackageFloor";
|
||||
@@ -172,7 +172,7 @@ export class ItemHandler {
|
||||
if(!giftCodeDetail) {
|
||||
return resResult(STATUS.GIFT_CODE_NOT_FOUND);
|
||||
}
|
||||
let giftCode = await GiftCode.findByGiftId(giftCodeDetail.giftId);
|
||||
let giftCode = await GiftCodeModel.findByGiftId(giftCodeDetail.giftId);
|
||||
if(!giftCode) {
|
||||
return resResult(STATUS.GIFT_CODE_NOT_FOUND);
|
||||
}
|
||||
@@ -198,7 +198,7 @@ export class ItemHandler {
|
||||
|
||||
|
||||
await GiftCodeDetailModel.increaseUsedNum(code, roleId, roleName, serverId);
|
||||
await GiftCode.increaseUsedNum(giftCode.id);
|
||||
await GiftCodeModel.increaseUsedNum(giftCode.id);
|
||||
|
||||
let goods = await addItems(roleId, roleName, sid, giftCode.goods, ITEM_CHANGE_REASON.USE_GIFT_CODE);
|
||||
return resResult(STATUS.SUCCESS, { goods });
|
||||
|
||||
@@ -22,7 +22,7 @@ import { sendMessageToUserWithSuc } from "./pushService";
|
||||
import { GuildLeader } from "../domain/rank";
|
||||
import { initTaLoggingMode } from "./sdk/ta";
|
||||
import { DicPushMessage } from "../pubUtils/dictionary/DicPushMessage";
|
||||
import GiftCode from "../db/GiftCode";
|
||||
import { GiftCodeModel } from "../db/GiftCode";
|
||||
import { GiftCodeDetailModel } from "../db/GiftCodeDetail";
|
||||
|
||||
// 检查私聊是否合法
|
||||
@@ -331,7 +331,7 @@ export async function sendGiftCodeMail(message: string) {
|
||||
let [roleId, _giftId] = message.split('|');
|
||||
let giftId = parseInt(_giftId);
|
||||
if(isNaN(giftId) || !roleId) return false;
|
||||
let giftCode = await GiftCode.findByGiftId(giftId);
|
||||
let giftCode = await GiftCodeModel.findByGiftId(giftId);
|
||||
if(!giftCode) {
|
||||
console.log('***** sendSurveyMail giftId not found', giftId);
|
||||
return false;
|
||||
|
||||
@@ -8,7 +8,7 @@ import Item from '@db/Item';
|
||||
import { gameData } from '@pubUtils/data';
|
||||
import { smsModel } from '@db/Sms';
|
||||
import { isString } from 'underscore';
|
||||
import GiftCode from '@db/GiftCode';
|
||||
import { GiftCodeModel } from '@db/GiftCode';
|
||||
import GiftCodeDetail, { GiftCodeDetailModel } from '@db/GiftCodeDetail';
|
||||
import { deletRole } from '@pubUtils/roleUtil';
|
||||
import { RScriptRecordModel } from '@db/RScriptRecord';
|
||||
@@ -519,8 +519,8 @@ export default class GMUsers extends Service {
|
||||
public async getGiftCodeList(page: number, pageSize: number, sortField: string, sortOrder: string, form: SearchGiftCodeParam = {}) {
|
||||
const { ctx } = this;
|
||||
|
||||
const list = await GiftCode.findByCondition(page, pageSize, sortField, sortOrder, form);
|
||||
const total = await GiftCode.countByCondition( form )
|
||||
const list = await GiftCodeModel.findByCondition(page, pageSize, sortField, sortOrder, form);
|
||||
const total = await GiftCodeModel.countByCondition( form )
|
||||
return ctx.service.utils.resResult(STATUS.SUCCESS, {
|
||||
list: list.map(cur => ({...cur, env: ctx.app.config.realEnv })), total
|
||||
});
|
||||
@@ -531,7 +531,7 @@ export default class GMUsers extends Service {
|
||||
let params = new CreateGiftCode(obj);
|
||||
if(!isNumber(count) || !params.checkParams()) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
||||
|
||||
let giftCode = await GiftCode.createData(params);
|
||||
let giftCode = await GiftCodeModel.createData(params);
|
||||
await GiftCodeDetailModel.generateMany(giftCode, count, ctx.user?.uid);
|
||||
return ctx.service.utils.resResult(STATUS.SUCCESS, giftCode);
|
||||
}
|
||||
@@ -541,7 +541,7 @@ export default class GMUsers extends Service {
|
||||
let params = new UpdateGiftCode(id, obj);
|
||||
if(!params.checkParams()) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
||||
|
||||
const result = await GiftCode.updateData(id, params, ctx.user?.uid);
|
||||
const result = await GiftCodeModel.updateData(id, params, ctx.user?.uid);
|
||||
if(!result) return ctx.service.utils.resResult(STATUS.INTERNAL_ERR);
|
||||
return ctx.service.utils.resResult(STATUS.SUCCESS);
|
||||
}
|
||||
@@ -550,7 +550,7 @@ export default class GMUsers extends Service {
|
||||
const { ctx } = this;
|
||||
if(!isNumber(id) || !isNumber(count)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
||||
|
||||
let giftCode = await GiftCode.findByGiftId(id);
|
||||
let giftCode = await GiftCodeModel.findByGiftId(id);
|
||||
if(!giftCode) return ctx.service.utils.resResult(STATUS.DB_DATA_NOT_FOUND);
|
||||
await GiftCodeDetailModel.generateMany(giftCode, count, ctx.user?.uid);
|
||||
return ctx.service.utils.resResult(STATUS.SUCCESS, giftCode);
|
||||
@@ -560,16 +560,16 @@ export default class GMUsers extends Service {
|
||||
const { ctx } = this;
|
||||
if(!isNumber(id)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
||||
|
||||
let giftCode = await GiftCode.findByGiftId(id);
|
||||
let giftCode = await GiftCodeModel.findByGiftId(id);
|
||||
if(!giftCode) return ctx.service.utils.resResult(STATUS.DB_DATA_NOT_FOUND);
|
||||
await GiftCode.updateData(id, { isEnable }, ctx.user?.uid);
|
||||
await GiftCodeModel.updateData(id, { isEnable }, ctx.user?.uid);
|
||||
return ctx.service.utils.resResult(STATUS.SUCCESS, giftCode);
|
||||
}
|
||||
|
||||
public async getGiftCodeDetailFile(id: number, fileType: string) {
|
||||
const { ctx } = this;
|
||||
|
||||
let giftCode = await GiftCode.findByGiftId(id);
|
||||
let giftCode = await GiftCodeModel.findByGiftId(id);
|
||||
if(!giftCode) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
||||
let giftCodeDetails = await GiftCodeDetailModel.findAllCodeByGiftId(giftCode.id);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { getModelForClass, prop, DocumentType, modelOptions, mongoose, ReturnModelType } from '@typegoose/typegoose';
|
||||
import { getModelForClass, prop, DocumentType, modelOptions } from '@typegoose/typegoose';
|
||||
import { CounterModel } from './Counter';
|
||||
import { COUNTER, GIFT_GENERATE_TYPE } from '../consts';
|
||||
import { SearchGiftCodeParam } from '../domain/backEndField/search';
|
||||
@@ -60,7 +60,7 @@ export default class GiftCode extends BaseModel {
|
||||
|
||||
|
||||
public static async findByGiftId(id: number) {
|
||||
let rec: GiftCodeType = await GiftCodeROModel.findOne({ id }).lean();
|
||||
let rec: GiftCodeType = await GiftCodeModel.findOne({ id }).lean();
|
||||
return rec;
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ export default class GiftCode extends BaseModel {
|
||||
sort[sortField] = -1;
|
||||
}
|
||||
}
|
||||
const result: GiftCodeType[] = await GiftCodeROModel.find(searchObj, { _id: 0 }).limit(pageSize).skip((page - 1) * pageSize).sort(sort).lean({ getters: true, virtuals: true });
|
||||
const result: GiftCodeType[] = await GiftCodeModel.find(searchObj, { _id: 0 }).limit(pageSize).skip((page - 1) * pageSize).sort(sort).lean({ getters: true, virtuals: true });
|
||||
return result;
|
||||
|
||||
}
|
||||
@@ -121,19 +121,11 @@ export default class GiftCode extends BaseModel {
|
||||
public static async countByCondition(form: SearchGiftCodeParam = {}) {
|
||||
|
||||
let searchObj = this.getSearchObj(form);
|
||||
const result = await GiftCodeROModel.count(searchObj);
|
||||
const result = await GiftCodeModel.count(searchObj);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
export let GiftCodeModel = getModelForClass(GiftCode);
|
||||
|
||||
export let GiftCodeROModel: ReturnModelType<typeof GiftCode, {}>;
|
||||
export function loadGiftCodeROModel(connect: mongoose.Connection) {
|
||||
GiftCodeROModel = getModelForClass(GiftCode, {
|
||||
existingConnection: connect
|
||||
});
|
||||
}
|
||||
|
||||
export interface GiftCodeType extends Pick<DocumentType<GiftCode>, keyof GiftCode> { }
|
||||
export type GiftCodeParam = Partial<GiftCodeType>;
|
||||
|
||||
@@ -19,7 +19,6 @@ import { loadHeroROModel } from "./Hero";
|
||||
import { loadItemROModel } from "./Item";
|
||||
import { loadUserGachaRecROModel } from "./UserGachaRec";
|
||||
import { loadUserGachaROModel } from "./UserGacha";
|
||||
import { loadGiftCodeROModel } from "./GiftCode";
|
||||
|
||||
export function loadGmDb(connect: mongoose.Connection) {
|
||||
// console.log('************')
|
||||
@@ -50,5 +49,4 @@ export function loadRODb(connect: mongoose.Connection) {
|
||||
loadItemROModel(connect);
|
||||
loadUserGachaRecROModel(connect);
|
||||
loadUserGachaROModel(connect);
|
||||
loadGiftCodeROModel(connect);
|
||||
}
|
||||
@@ -17,7 +17,7 @@ import moment = require('moment');
|
||||
import { RegionModel } from '@db/Region';
|
||||
import { ActivityPublicAccountCodeModel } from '@db/ActivityPublicAccountCode';
|
||||
import { GiftCodeDetailModel } from '@db/GiftCodeDetail';
|
||||
import GiftCode from '@db/GiftCode';
|
||||
import { GiftCodeModel } from '@db/GiftCode';
|
||||
|
||||
/**
|
||||
* Test Service
|
||||
@@ -450,7 +450,7 @@ export default class Sdk extends Service {
|
||||
if(!giftCodeDetail) {
|
||||
return resResult(SDK_37_ACTIVITY_CODE.GIFT_NOT_FOUND);
|
||||
}
|
||||
let giftCode = await GiftCode.findByGiftId(giftCodeDetail.giftId);
|
||||
let giftCode = await GiftCodeModel.findByGiftId(giftCodeDetail.giftId);
|
||||
if(!giftCode) {
|
||||
return resResult(SDK_37_ACTIVITY_CODE.GIFT_NOT_FOUND);
|
||||
}
|
||||
@@ -475,7 +475,7 @@ export default class Sdk extends Service {
|
||||
}
|
||||
|
||||
await GiftCodeDetailModel.increaseUsedNum(giftCodeDetail.code, role.roleId, role.roleName, role.serverId, params.order_id);
|
||||
await GiftCode.increaseUsedNum(giftCode.id);
|
||||
await GiftCodeModel.increaseUsedNum(giftCode.id);
|
||||
|
||||
await ctx.service.utils.pushGiftCodeChannel(role.roleId, giftCode.id);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user