midway-fatcms 0.0.1-beta.4 → 0.0.1-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/controller/manage/UserAccountManageApi.d.ts +1 -1
- package/dist/index.d.ts +26 -4
- package/dist/index.js +26 -4
- package/package.json +1 -1
- package/src/index.ts +32 -4
- package/dist/controller/medstatistic/MedAdminController.d.ts +0 -35
- package/dist/controller/medstatistic/MedAdminController.js +0 -205
- package/dist/controller/medstatistic/MedClientController.d.ts +0 -28
- package/dist/controller/medstatistic/MedClientController.js +0 -188
- package/dist/controller/medstatistic/MedMessageService.d.ts +0 -19
- package/dist/controller/medstatistic/MedMessageService.js +0 -95
- package/dist/controller/medstatistic/MedScoreService.d.ts +0 -21
- package/dist/controller/medstatistic/MedScoreService.js +0 -107
- package/dist/controller/medstatistic/constants.d.ts +0 -32
- package/dist/controller/medstatistic/constants.js +0 -43
- package/src/controller/medstatistic/MedAdminController.ts +0 -221
- package/src/controller/medstatistic/MedClientController.ts +0 -188
- package/src/controller/medstatistic/MedMessageService.ts +0 -89
- package/src/controller/medstatistic/MedScoreService.ts +0 -108
- package/src/controller/medstatistic/constants.ts +0 -63
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.MedMessageService = void 0;
|
|
13
|
-
const core_1 = require("@midwayjs/core");
|
|
14
|
-
const AuthService_1 = require("../../service/AuthService");
|
|
15
|
-
const WorkbenchService_1 = require("../../service/WorkbenchService");
|
|
16
|
-
const SysConfigService_1 = require("../../service/SysConfigService");
|
|
17
|
-
const keys_1 = require("../../libs/crud-pro/models/keys");
|
|
18
|
-
const BaseService_1 = require("../../service/base/BaseService");
|
|
19
|
-
const CurdProService_1 = require("../../service/curd/CurdProService");
|
|
20
|
-
const md5 = require("md5");
|
|
21
|
-
const exceptions_1 = require("../../libs/crud-pro/exceptions");
|
|
22
|
-
const constants_1 = require("./constants");
|
|
23
|
-
/**
|
|
24
|
-
* medstatistic 管理端
|
|
25
|
-
*/
|
|
26
|
-
let MedMessageService = class MedMessageService extends BaseService_1.BaseService {
|
|
27
|
-
async insertMessage(title, content, received_by, msgObj) {
|
|
28
|
-
try {
|
|
29
|
-
return this.insertMessageInner(title, content, received_by, msgObj);
|
|
30
|
-
}
|
|
31
|
-
catch (e) {
|
|
32
|
-
this.logWarn("[MedMessageService]insertMessageInner失败", e);
|
|
33
|
-
return Promise.resolve(e);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
async insertMessageInner(title, content, received_by, msgObj) {
|
|
37
|
-
if (!(0, constants_1.isMsgType)(msgObj.msg_type)) {
|
|
38
|
-
throw new exceptions_1.CommonException("PARAM_IS_NOT_VALID", "msg_type 不正确");
|
|
39
|
-
}
|
|
40
|
-
const msg_type = msgObj.msg_type;
|
|
41
|
-
const userInfo = this.ctx.userSession.getSessionInfo();
|
|
42
|
-
const msg_key = md5(`${userInfo.accountId}_${userInfo.accountType}_${received_by}_${msg_type}_${msgObj.target_object_type}_${msgObj.target_object_id}`);
|
|
43
|
-
// 插入日志
|
|
44
|
-
const insertMessageRes = await this.curdProService.executeCrudByCfg({
|
|
45
|
-
data: {
|
|
46
|
-
title: title,
|
|
47
|
-
content: content,
|
|
48
|
-
content_length: content.length,
|
|
49
|
-
msg_status: constants_1.MsgStatus.unread,
|
|
50
|
-
msg_type: msg_type,
|
|
51
|
-
msg_key: msg_key,
|
|
52
|
-
status: 1,
|
|
53
|
-
target_object_type: msgObj.target_object_type,
|
|
54
|
-
target_object_id: msgObj.target_object_id,
|
|
55
|
-
received_by: received_by,
|
|
56
|
-
received_account_type: 'medstatistic',
|
|
57
|
-
created_by: userInfo.accountId,
|
|
58
|
-
created_account_type: userInfo.accountType,
|
|
59
|
-
created_nickname: userInfo.nickName,
|
|
60
|
-
created_avatar: userInfo.avatar,
|
|
61
|
-
}
|
|
62
|
-
}, {
|
|
63
|
-
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_INSERT,
|
|
64
|
-
sqlTable: "fatbiz_bbs_message",
|
|
65
|
-
sqlDatabase: constants_1.MED_STATISTIC_DB,
|
|
66
|
-
});
|
|
67
|
-
return {
|
|
68
|
-
insertMessageRes,
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
__decorate([
|
|
73
|
-
(0, core_1.Inject)(),
|
|
74
|
-
__metadata("design:type", Object)
|
|
75
|
-
], MedMessageService.prototype, "ctx", void 0);
|
|
76
|
-
__decorate([
|
|
77
|
-
(0, core_1.Inject)(),
|
|
78
|
-
__metadata("design:type", AuthService_1.AuthService)
|
|
79
|
-
], MedMessageService.prototype, "authService", void 0);
|
|
80
|
-
__decorate([
|
|
81
|
-
(0, core_1.Inject)(),
|
|
82
|
-
__metadata("design:type", WorkbenchService_1.WorkbenchService)
|
|
83
|
-
], MedMessageService.prototype, "workbenchService", void 0);
|
|
84
|
-
__decorate([
|
|
85
|
-
(0, core_1.Inject)(),
|
|
86
|
-
__metadata("design:type", SysConfigService_1.SysConfigService)
|
|
87
|
-
], MedMessageService.prototype, "sysConfigService", void 0);
|
|
88
|
-
__decorate([
|
|
89
|
-
(0, core_1.Inject)(),
|
|
90
|
-
__metadata("design:type", CurdProService_1.CurdProService)
|
|
91
|
-
], MedMessageService.prototype, "curdProService", void 0);
|
|
92
|
-
MedMessageService = __decorate([
|
|
93
|
-
(0, core_1.Provide)()
|
|
94
|
-
], MedMessageService);
|
|
95
|
-
exports.MedMessageService = MedMessageService;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Context } from '@midwayjs/koa';
|
|
2
|
-
import { AuthService } from '../../service/AuthService';
|
|
3
|
-
import { WorkbenchService } from "../../service/WorkbenchService";
|
|
4
|
-
import { SysConfigService } from "../../service/SysConfigService";
|
|
5
|
-
import { BaseService } from "../../service/base/BaseService";
|
|
6
|
-
import { CurdProService } from "../../service/curd/CurdProService";
|
|
7
|
-
export declare enum UpdateScorePM {
|
|
8
|
-
decrease = 0,
|
|
9
|
-
increase = 1
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* medstatistic 管理端
|
|
13
|
-
*/
|
|
14
|
-
export declare class MedScoreService extends BaseService {
|
|
15
|
-
protected ctx: Context;
|
|
16
|
-
protected authService: AuthService;
|
|
17
|
-
protected workbenchService: WorkbenchService;
|
|
18
|
-
protected sysConfigService: SysConfigService;
|
|
19
|
-
protected curdProService: CurdProService;
|
|
20
|
-
updateScore(user_id: number, pm: UpdateScorePM, score: number, memo: string): Promise<any>;
|
|
21
|
-
}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.MedScoreService = exports.UpdateScorePM = void 0;
|
|
13
|
-
const core_1 = require("@midwayjs/core");
|
|
14
|
-
const AuthService_1 = require("../../service/AuthService");
|
|
15
|
-
const WorkbenchService_1 = require("../../service/WorkbenchService");
|
|
16
|
-
const SysConfigService_1 = require("../../service/SysConfigService");
|
|
17
|
-
const exceptions_1 = require("../../libs/crud-pro/exceptions");
|
|
18
|
-
const keys_1 = require("../../libs/crud-pro/models/keys");
|
|
19
|
-
const BaseService_1 = require("../../service/base/BaseService");
|
|
20
|
-
const CurdProService_1 = require("../../service/curd/CurdProService");
|
|
21
|
-
const MED_STATISTIC_DB = "medstatistic";
|
|
22
|
-
// 类型:1=增加,0=减少
|
|
23
|
-
var UpdateScorePM;
|
|
24
|
-
(function (UpdateScorePM) {
|
|
25
|
-
UpdateScorePM[UpdateScorePM["decrease"] = 0] = "decrease";
|
|
26
|
-
UpdateScorePM[UpdateScorePM["increase"] = 1] = "increase"; // 增加
|
|
27
|
-
})(UpdateScorePM = exports.UpdateScorePM || (exports.UpdateScorePM = {}));
|
|
28
|
-
/**
|
|
29
|
-
* medstatistic 管理端
|
|
30
|
-
*/
|
|
31
|
-
let MedScoreService = class MedScoreService extends BaseService_1.BaseService {
|
|
32
|
-
async updateScore(user_id, pm, score, memo) {
|
|
33
|
-
// 查询用户信息
|
|
34
|
-
const userRes = await this.curdProService.executeCrudByCfg({
|
|
35
|
-
condition: {
|
|
36
|
-
id: user_id,
|
|
37
|
-
},
|
|
38
|
-
}, {
|
|
39
|
-
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
|
|
40
|
-
sqlTable: "fa_user",
|
|
41
|
-
sqlDatabase: MED_STATISTIC_DB,
|
|
42
|
-
});
|
|
43
|
-
const userOne = userRes.getOneObj();
|
|
44
|
-
if (!userOne) {
|
|
45
|
-
throw new exceptions_1.CommonException('USER_NOT_EXIST', "用户信息没有查询到");
|
|
46
|
-
}
|
|
47
|
-
const beforeScore = Math.max(0, parseInt(userOne.score) || 0);
|
|
48
|
-
const afterScore = pm === UpdateScorePM.decrease ? (beforeScore - score) : (beforeScore + score);
|
|
49
|
-
// 插入日志
|
|
50
|
-
const insertLogRes = await this.curdProService.executeCrudByCfg({
|
|
51
|
-
data: {
|
|
52
|
-
user_id: user_id,
|
|
53
|
-
pm: pm,
|
|
54
|
-
score: score,
|
|
55
|
-
before: beforeScore,
|
|
56
|
-
after: afterScore,
|
|
57
|
-
memo: memo,
|
|
58
|
-
createtime: Math.floor(Date.now() / 1000),
|
|
59
|
-
}
|
|
60
|
-
}, {
|
|
61
|
-
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_INSERT,
|
|
62
|
-
sqlTable: "fa_user_score_log",
|
|
63
|
-
sqlDatabase: MED_STATISTIC_DB,
|
|
64
|
-
});
|
|
65
|
-
// 更新User余额
|
|
66
|
-
const updateUserRes = await this.curdProService.executeCrudByCfg({
|
|
67
|
-
condition: {
|
|
68
|
-
id: user_id,
|
|
69
|
-
},
|
|
70
|
-
data: {
|
|
71
|
-
score: afterScore,
|
|
72
|
-
}
|
|
73
|
-
}, {
|
|
74
|
-
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_UPDATE,
|
|
75
|
-
sqlTable: "fa_user",
|
|
76
|
-
sqlDatabase: MED_STATISTIC_DB,
|
|
77
|
-
});
|
|
78
|
-
return {
|
|
79
|
-
insertLogRes,
|
|
80
|
-
updateUserRes
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
__decorate([
|
|
85
|
-
(0, core_1.Inject)(),
|
|
86
|
-
__metadata("design:type", Object)
|
|
87
|
-
], MedScoreService.prototype, "ctx", void 0);
|
|
88
|
-
__decorate([
|
|
89
|
-
(0, core_1.Inject)(),
|
|
90
|
-
__metadata("design:type", AuthService_1.AuthService)
|
|
91
|
-
], MedScoreService.prototype, "authService", void 0);
|
|
92
|
-
__decorate([
|
|
93
|
-
(0, core_1.Inject)(),
|
|
94
|
-
__metadata("design:type", WorkbenchService_1.WorkbenchService)
|
|
95
|
-
], MedScoreService.prototype, "workbenchService", void 0);
|
|
96
|
-
__decorate([
|
|
97
|
-
(0, core_1.Inject)(),
|
|
98
|
-
__metadata("design:type", SysConfigService_1.SysConfigService)
|
|
99
|
-
], MedScoreService.prototype, "sysConfigService", void 0);
|
|
100
|
-
__decorate([
|
|
101
|
-
(0, core_1.Inject)(),
|
|
102
|
-
__metadata("design:type", CurdProService_1.CurdProService)
|
|
103
|
-
], MedScoreService.prototype, "curdProService", void 0);
|
|
104
|
-
MedScoreService = __decorate([
|
|
105
|
-
(0, core_1.Provide)()
|
|
106
|
-
], MedScoreService);
|
|
107
|
-
exports.MedScoreService = MedScoreService;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
declare const DEFAULT_SECTION_ID = 10002;
|
|
2
|
-
declare const TARGET_OBJECT_TYPE_BBS_TOPIC = 1;
|
|
3
|
-
declare const TARGET_OBJECT_TYPE_BBS_REPLY = 2;
|
|
4
|
-
declare const TARGET_OBJECT_TYPE_BBS_GUIDE = 3;
|
|
5
|
-
declare const TARGET_OBJECT_TYPE_CONTACT_US = 4;
|
|
6
|
-
declare const TARGET_OBJECT_TYPE_USER_AUTHENTICATION = 5;
|
|
7
|
-
export { DEFAULT_SECTION_ID, TARGET_OBJECT_TYPE_BBS_TOPIC, TARGET_OBJECT_TYPE_BBS_REPLY, TARGET_OBJECT_TYPE_BBS_GUIDE, TARGET_OBJECT_TYPE_CONTACT_US, TARGET_OBJECT_TYPE_USER_AUTHENTICATION };
|
|
8
|
-
export declare const MED_STATISTIC_DB = "medstatistic";
|
|
9
|
-
export declare enum MsgStatus {
|
|
10
|
-
unread = 0,
|
|
11
|
-
read = 1
|
|
12
|
-
}
|
|
13
|
-
export declare enum MsgType {
|
|
14
|
-
unknown = 0,
|
|
15
|
-
user_auth_pass = 1,
|
|
16
|
-
bbs_post_be_like = 2,
|
|
17
|
-
bbs_post_be_reply = 3,
|
|
18
|
-
bbs_post_be_violation = 4,
|
|
19
|
-
bbs_reply_be_like = 5,
|
|
20
|
-
bbs_reply_be_reply = 6,
|
|
21
|
-
bbs_reply_be_violation = 7,
|
|
22
|
-
contact_us_be_reply = 8,
|
|
23
|
-
bbs_post_be_favorite = 9
|
|
24
|
-
}
|
|
25
|
-
export declare function isMsgType(value: number): boolean;
|
|
26
|
-
export interface IMedTargetObj {
|
|
27
|
-
target_object_id: number;
|
|
28
|
-
target_object_type: number;
|
|
29
|
-
}
|
|
30
|
-
export interface ISendUserReceivedMsg extends IMedTargetObj {
|
|
31
|
-
msg_type: MsgType;
|
|
32
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isMsgType = exports.MsgType = exports.MsgStatus = exports.MED_STATISTIC_DB = exports.TARGET_OBJECT_TYPE_USER_AUTHENTICATION = exports.TARGET_OBJECT_TYPE_CONTACT_US = exports.TARGET_OBJECT_TYPE_BBS_GUIDE = exports.TARGET_OBJECT_TYPE_BBS_REPLY = exports.TARGET_OBJECT_TYPE_BBS_TOPIC = exports.DEFAULT_SECTION_ID = void 0;
|
|
4
|
-
const DEFAULT_SECTION_ID = 10002;
|
|
5
|
-
exports.DEFAULT_SECTION_ID = DEFAULT_SECTION_ID;
|
|
6
|
-
const TARGET_OBJECT_TYPE_BBS_TOPIC = 1; // bbs_topic (1)
|
|
7
|
-
exports.TARGET_OBJECT_TYPE_BBS_TOPIC = TARGET_OBJECT_TYPE_BBS_TOPIC;
|
|
8
|
-
const TARGET_OBJECT_TYPE_BBS_REPLY = 2; // bbs_reply (2)
|
|
9
|
-
exports.TARGET_OBJECT_TYPE_BBS_REPLY = TARGET_OBJECT_TYPE_BBS_REPLY;
|
|
10
|
-
const TARGET_OBJECT_TYPE_BBS_GUIDE = 3; // bbs_reply (3) // 教程
|
|
11
|
-
exports.TARGET_OBJECT_TYPE_BBS_GUIDE = TARGET_OBJECT_TYPE_BBS_GUIDE;
|
|
12
|
-
const TARGET_OBJECT_TYPE_CONTACT_US = 4; // // 联系我们
|
|
13
|
-
exports.TARGET_OBJECT_TYPE_CONTACT_US = TARGET_OBJECT_TYPE_CONTACT_US;
|
|
14
|
-
const TARGET_OBJECT_TYPE_USER_AUTHENTICATION = 5; // // 用户身份认证
|
|
15
|
-
exports.TARGET_OBJECT_TYPE_USER_AUTHENTICATION = TARGET_OBJECT_TYPE_USER_AUTHENTICATION;
|
|
16
|
-
exports.MED_STATISTIC_DB = "medstatistic";
|
|
17
|
-
// 状态;0 未读, 1 已读
|
|
18
|
-
var MsgStatus;
|
|
19
|
-
(function (MsgStatus) {
|
|
20
|
-
MsgStatus[MsgStatus["unread"] = 0] = "unread";
|
|
21
|
-
MsgStatus[MsgStatus["read"] = 1] = "read"; // 增加
|
|
22
|
-
})(MsgStatus = exports.MsgStatus || (exports.MsgStatus = {}));
|
|
23
|
-
// 状态;0 未读, 1 已读
|
|
24
|
-
var MsgType;
|
|
25
|
-
(function (MsgType) {
|
|
26
|
-
MsgType[MsgType["unknown"] = 0] = "unknown";
|
|
27
|
-
MsgType[MsgType["user_auth_pass"] = 1] = "user_auth_pass";
|
|
28
|
-
MsgType[MsgType["bbs_post_be_like"] = 2] = "bbs_post_be_like";
|
|
29
|
-
MsgType[MsgType["bbs_post_be_reply"] = 3] = "bbs_post_be_reply";
|
|
30
|
-
MsgType[MsgType["bbs_post_be_violation"] = 4] = "bbs_post_be_violation";
|
|
31
|
-
MsgType[MsgType["bbs_reply_be_like"] = 5] = "bbs_reply_be_like";
|
|
32
|
-
MsgType[MsgType["bbs_reply_be_reply"] = 6] = "bbs_reply_be_reply";
|
|
33
|
-
MsgType[MsgType["bbs_reply_be_violation"] = 7] = "bbs_reply_be_violation";
|
|
34
|
-
MsgType[MsgType["contact_us_be_reply"] = 8] = "contact_us_be_reply";
|
|
35
|
-
MsgType[MsgType["bbs_post_be_favorite"] = 9] = "bbs_post_be_favorite";
|
|
36
|
-
})(MsgType = exports.MsgType || (exports.MsgType = {}));
|
|
37
|
-
function isMsgType(value) {
|
|
38
|
-
if (typeof value === "undefined") {
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
return Object.values(MsgType).includes(value);
|
|
42
|
-
}
|
|
43
|
-
exports.isMsgType = isMsgType;
|
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
import {Controller, Inject, Post} from '@midwayjs/core';
|
|
2
|
-
import {Context} from '@midwayjs/koa';
|
|
3
|
-
import * as _ from 'lodash';
|
|
4
|
-
import {BaseApiController} from '../base/BaseApiController';
|
|
5
|
-
import {AuthService} from '../../service/AuthService';
|
|
6
|
-
import {CommonResult} from '../../libs/utils/common-dto';
|
|
7
|
-
import {WorkbenchService} from "../../service/WorkbenchService";
|
|
8
|
-
import {checkPermission} from "../../middleware/permission.middleware";
|
|
9
|
-
import {SysConfigService} from "../../service/SysConfigService";
|
|
10
|
-
import {parseJsonObject} from "../../libs/utils/functions";
|
|
11
|
-
import {CommonException} from "../../libs/crud-pro/exceptions";
|
|
12
|
-
import { KeysOfSimpleSQL } from "../../libs/crud-pro/models/keys";
|
|
13
|
-
import {generateOrderNumber} from "../../libs/utils/ordernum-utils";
|
|
14
|
-
import {MedScoreService, UpdateScorePM} from "./MedScoreService";
|
|
15
|
-
import {DateTimeUtils} from "../../libs/crud-pro/utils/DateTimeUtils";
|
|
16
|
-
import {MedMessageService} from "./MedMessageService";
|
|
17
|
-
import {TARGET_OBJECT_TYPE_USER_AUTHENTICATION, MsgType} from "./constants";
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const MED_STATISTIC_DB = "medstatistic";
|
|
21
|
-
|
|
22
|
-
interface IUserRechargeRule {
|
|
23
|
-
score: number;
|
|
24
|
-
authentication_score: number;
|
|
25
|
-
recharge_package: any[];
|
|
26
|
-
vip_package: any[]
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* medstatistic 管理端
|
|
31
|
-
*/
|
|
32
|
-
@Controller('/ns/api/medadmin')
|
|
33
|
-
export class MedAdminController extends BaseApiController {
|
|
34
|
-
@Inject()
|
|
35
|
-
protected ctx: Context;
|
|
36
|
-
|
|
37
|
-
@Inject()
|
|
38
|
-
protected authService: AuthService;
|
|
39
|
-
|
|
40
|
-
@Inject()
|
|
41
|
-
protected workbenchService: WorkbenchService;
|
|
42
|
-
|
|
43
|
-
@Inject()
|
|
44
|
-
protected sysConfigService: SysConfigService;
|
|
45
|
-
|
|
46
|
-
@Inject()
|
|
47
|
-
protected medScoreService: MedScoreService;
|
|
48
|
-
|
|
49
|
-
@Inject()
|
|
50
|
-
protected medMessageService: MedMessageService;
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* 审批后自动充值30个积分
|
|
54
|
-
*/
|
|
55
|
-
@Post('/recharge_by_authentication_success', {middleware: [checkPermission("BizOperationUserAdmin")]})
|
|
56
|
-
async recharge_by_authentication_success(): Promise<CommonResult> {
|
|
57
|
-
const body = this.ctx.request.body as any; // {user_id}
|
|
58
|
-
const user_id = parseInt(body.user_id); // med的C端用户user_id
|
|
59
|
-
if (!user_id) {
|
|
60
|
-
throw new CommonException("user_id不存在")
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const authRes = await this.curdMixService.executeCrudByCfg({
|
|
65
|
-
condition: {
|
|
66
|
-
user_id: user_id,
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
|
|
71
|
-
sqlTable: "fa_user_authentication",
|
|
72
|
-
sqlDatabase: MED_STATISTIC_DB,
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const authResOne = authRes.getOneObj();
|
|
77
|
-
if (!authResOne || `${authResOne.status}` !== '1') {
|
|
78
|
-
throw new CommonException("未提交认证资料或认证审批未通过")
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const RECHARGE_TYPE_FOR_AUTH = '3';
|
|
82
|
-
|
|
83
|
-
// 查询之前有没有通过积分认证获得积分
|
|
84
|
-
const fa_user_rechargeRes = await this.curdMixService.executeCrudByCfg({
|
|
85
|
-
condition: {
|
|
86
|
-
user_id: user_id,
|
|
87
|
-
type: RECHARGE_TYPE_FOR_AUTH
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
|
|
92
|
-
sqlTable: "fa_user_recharge",
|
|
93
|
-
sqlDatabase: MED_STATISTIC_DB,
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
const fa_user_rechargeResOne = fa_user_rechargeRes.getOneObj();
|
|
98
|
-
if (fa_user_rechargeResOne) {
|
|
99
|
-
return CommonResult.errorRes("用户已经获得认证积分");
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
const rechargeRule = await this.get_med_user_recharge_rule();
|
|
104
|
-
|
|
105
|
-
// 插入充值记录
|
|
106
|
-
await this.curdMixService.executeCrudByCfg({
|
|
107
|
-
data: {
|
|
108
|
-
user_id: user_id,
|
|
109
|
-
type: RECHARGE_TYPE_FOR_AUTH,
|
|
110
|
-
paid:1,
|
|
111
|
-
order_no: generateOrderNumber('CZ'),
|
|
112
|
-
money: 0,
|
|
113
|
-
score: rechargeRule.authentication_score,
|
|
114
|
-
pay_time: DateTimeUtils.getCurrentTimeStampSecond(),
|
|
115
|
-
createtime: DateTimeUtils.getCurrentTimeStampSecond(),
|
|
116
|
-
},
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_INSERT,
|
|
120
|
-
sqlTable: "fa_user_recharge",
|
|
121
|
-
sqlDatabase: MED_STATISTIC_DB,
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
// 查询用户信息
|
|
126
|
-
const userRes = await this.curdMixService.executeCrudByCfg({
|
|
127
|
-
condition: {
|
|
128
|
-
id: user_id,
|
|
129
|
-
},
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
|
|
133
|
-
sqlTable: "fa_user",
|
|
134
|
-
sqlDatabase: MED_STATISTIC_DB,
|
|
135
|
-
});
|
|
136
|
-
const userOne = userRes.getOneObj();
|
|
137
|
-
if (!userOne) {
|
|
138
|
-
return CommonResult.errorRes("用户信息没有查询到");
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// 更新用户日志。
|
|
142
|
-
await this.medScoreService.updateScore(user_id, UpdateScorePM.increase, rechargeRule.authentication_score, "用户认证通过获得积分")
|
|
143
|
-
|
|
144
|
-
// 更新认证状态
|
|
145
|
-
await this.curdMixService.executeCrudByCfg({
|
|
146
|
-
condition: {
|
|
147
|
-
id: user_id,
|
|
148
|
-
},
|
|
149
|
-
data: {
|
|
150
|
-
is_authentication: 1
|
|
151
|
-
}
|
|
152
|
-
},
|
|
153
|
-
{
|
|
154
|
-
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_UPDATE,
|
|
155
|
-
sqlTable: "fa_user",
|
|
156
|
-
sqlDatabase: MED_STATISTIC_DB,
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
// 发送消息
|
|
163
|
-
// title:string, content: string, received_by: string | number, msgObj: ISendUserReceivedMsg
|
|
164
|
-
const title = "您的身份认证请求,已经审批通过";
|
|
165
|
-
await this.medMessageService.insertMessage(title, title, user_id, {
|
|
166
|
-
target_object_id: authResOne.id,
|
|
167
|
-
target_object_type: TARGET_OBJECT_TYPE_USER_AUTHENTICATION,
|
|
168
|
-
msg_type: MsgType.user_auth_pass
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
return CommonResult.successMsg('用户认证审批通过获得积分' + rechargeRule.authentication_score);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* 将DB中的数据同步到Redis,因为PHP的程序需要。
|
|
177
|
-
*/
|
|
178
|
-
@Post('/sync_med_user_recharge_rule_to_redis', {middleware: [checkPermission("BizOperationUserAdmin")]})
|
|
179
|
-
async sync_med_user_recharge_rule_to_redis() {
|
|
180
|
-
const ruleObj = await this.get_med_user_recharge_rule();
|
|
181
|
-
await this.redisService.set("score", ruleObj.score);
|
|
182
|
-
await this.redisService.set("authentication_score", ruleObj.authentication_score);
|
|
183
|
-
await this.redisService.set("recharge_package", JSON.stringify(ruleObj.recharge_package.map((obj0) => {
|
|
184
|
-
const obj:any = {}
|
|
185
|
-
obj.score = "" + obj0.score;
|
|
186
|
-
obj.price = "" + obj0.price;
|
|
187
|
-
return obj;
|
|
188
|
-
})));
|
|
189
|
-
await this.redisService.set("vip_package", JSON.stringify(ruleObj.vip_package.map((obj0) => {
|
|
190
|
-
const obj:any = {}
|
|
191
|
-
obj.score = "" + obj0.score;
|
|
192
|
-
obj.day = "" + obj0.day;
|
|
193
|
-
return obj;
|
|
194
|
-
})));
|
|
195
|
-
|
|
196
|
-
return CommonResult.successRes("SUCCESS")
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
async get_med_user_recharge_rule(): Promise<IUserRechargeRule> {
|
|
201
|
-
|
|
202
|
-
const rowObj = await this.sysConfigService.getSysConfigOne("med_user_recharge_rule");
|
|
203
|
-
|
|
204
|
-
const configContentObj = parseJsonObject(rowObj.config_content)
|
|
205
|
-
const configContentData = configContentObj.data || {};
|
|
206
|
-
const recharge_package = configContentData.recharge_package || [];
|
|
207
|
-
const vip_package = configContentData.vip_package || [];
|
|
208
|
-
|
|
209
|
-
const authentication_score: number = Number(_.get(configContentData, 'score_setting.authentication_score')) || 30
|
|
210
|
-
const score: number = Number(_.get(configContentData, 'score_setting.score')) || 1
|
|
211
|
-
|
|
212
|
-
return {
|
|
213
|
-
score,
|
|
214
|
-
authentication_score,
|
|
215
|
-
recharge_package,
|
|
216
|
-
vip_package
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
}
|