活动:支付接口
This commit is contained in:
141
game-server/app/servers/order/handler/orderHandler.ts
Normal file
141
game-server/app/servers/order/handler/orderHandler.ts
Normal file
@@ -0,0 +1,141 @@
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { genCode, resResult } from '../../../pubUtils/util';
|
||||
import { ACTIVITY_TYPE, ORDER_STATE, PAY_TYPE, STATUS } from '../../../consts';
|
||||
import { RoleModel } from '../../../db/Role';
|
||||
import { addReward, stringToRewardParam, useGiftPackage } from '../../../services/giftPackageService';
|
||||
import { dicRMB } from '../../../pubUtils/dictionary/DicRMB';
|
||||
import { UserOrderModel } from '../../../db/UserOrder';
|
||||
import _ = require('underscore');
|
||||
|
||||
export default function (app: Application) {
|
||||
return new orderHandler(app);
|
||||
}
|
||||
|
||||
export class orderHandler {
|
||||
constructor(private app: Application) {
|
||||
}
|
||||
|
||||
/************************订单****************************/
|
||||
|
||||
/**
|
||||
* @description 获取订单号
|
||||
* @param {{productID:string, payType:number }} msg
|
||||
* @param {BackendSession} session
|
||||
* @memberof orderHandler
|
||||
*/
|
||||
async applyOrder(msg: { productID: string, payType: number }, session: BackendSession) {
|
||||
const { productID, payType } = msg;
|
||||
const roleId = session.get('roleId');
|
||||
const serverId = session.get('serverId');
|
||||
|
||||
if (!productID || !_.isString(productID) || !payType || !_.isNumber(payType)) {
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
}
|
||||
|
||||
//商品价格信息
|
||||
let productInfo = dicRMB.get(productID)
|
||||
if (!productInfo) {
|
||||
return resResult(STATUS.NO_PRODUCT_ID);
|
||||
}
|
||||
|
||||
let price = productInfo.price;//价格
|
||||
let productType = productInfo.type;//类型
|
||||
let localOrderID = genCode(32);//本地订单号
|
||||
let orderID = '';//平台订单号
|
||||
|
||||
//生成订单号
|
||||
let orderInfo = await UserOrderModel.applyOrder(serverId, roleId, productID, localOrderID, orderID, price, payType);
|
||||
|
||||
return resResult(STATUS.SUCCESS, { orderInfo, productInfo });
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @description 查询订单,结算奖励
|
||||
* @param {{ localOrderID: string}} msg
|
||||
* @param {BackendSession} session
|
||||
* @memberof firstGiftHandler
|
||||
*/
|
||||
async checkOrder(msg: { localOrderID: string }, session: BackendSession) {
|
||||
const { localOrderID } = msg;
|
||||
// const roleId = session.get('roleId');
|
||||
const serverId = session.get('serverId');
|
||||
const sid = session.get('sid');
|
||||
const roleName = session.get('roleName');
|
||||
const funcs: number[] = session.get('funcs');
|
||||
if (!localOrderID || !_.isString(localOrderID)) {
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
}
|
||||
|
||||
let orderInfo = await UserOrderModel.findOrder(localOrderID);
|
||||
if (!orderInfo) {
|
||||
return resResult(STATUS.NO_ORDER);
|
||||
}
|
||||
if (orderInfo.state == ORDER_STATE.RESULT_SUCCESS) {
|
||||
return resResult(STATUS.DUPLICATE_ORDER);
|
||||
}
|
||||
|
||||
//商品价格信息
|
||||
let productInfo = dicRMB.get(orderInfo.productID)
|
||||
if (!productInfo) {
|
||||
return resResult(STATUS.NO_PRODUCT_ID);
|
||||
}
|
||||
|
||||
let productType = productInfo.type;//类型
|
||||
let price = orderInfo.price;//下单时的价格
|
||||
let payType = orderInfo.payType;//支付类型
|
||||
let roleId = orderInfo.roleId;//角色
|
||||
|
||||
switch (productType) {
|
||||
case ACTIVITY_TYPE.NEW_PLAYER_LIMIT_PACKAGE:
|
||||
{
|
||||
break;
|
||||
}
|
||||
default:
|
||||
console.log('未知错误类型');
|
||||
return resResult(STATUS.NO_PRODUCT_ID);
|
||||
|
||||
}
|
||||
|
||||
orderInfo = await UserOrderModel.check(roleId, localOrderID);
|
||||
if (!orderInfo) {
|
||||
return resResult(STATUS.DUPLICATE_ORDER);
|
||||
}
|
||||
switch (payType) {
|
||||
case PAY_TYPE.WX:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case PAY_TYPE.ALI:
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
case PAY_TYPE.APPLE:
|
||||
{
|
||||
break;
|
||||
}
|
||||
default:
|
||||
console.log('未知支付类型');
|
||||
return resResult(STATUS.NO_PAY_TYPE);
|
||||
}
|
||||
|
||||
//订单成功
|
||||
let isSuccess = true;
|
||||
if (isSuccess) {
|
||||
orderInfo = await UserOrderModel.success(roleId, localOrderID);
|
||||
if (orderInfo) {
|
||||
//结算奖励
|
||||
console.log('结算完成', localOrderID)
|
||||
return resResult(STATUS.SUCCESS, Object.assign({}));
|
||||
}
|
||||
} else {
|
||||
let message = '订单校验失败';
|
||||
orderInfo = await UserOrderModel.fail(roleId, localOrderID, message);
|
||||
}
|
||||
|
||||
|
||||
return resResult(STATUS.DUPLICATE_ORDER);
|
||||
}
|
||||
|
||||
}
|
||||
3
game-server/app/services/orderService.ts
Normal file
3
game-server/app/services/orderService.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import { UserOrderModel } from '../db/UserOrder';
|
||||
import { ActivitySignInModel, ActivitySignInModelType } from '../db/ActivitySignIn';
|
||||
import { SignInData, SignInItem } from '../domain/activityField/signInField';
|
||||
@@ -25,4 +25,7 @@ module.exports = [{
|
||||
}, {
|
||||
'type': 'activity',
|
||||
'token': 'agarxhqb98rpajloaxn34ga8xrunpagkjwlaw3ruxnpaagl29w4rxn'
|
||||
}, {
|
||||
'type': 'order',
|
||||
'token': 'agarxhqb98rpajloaxn34ga8xrunpagkjwlaw3ruxnpaagl29w4rxn'
|
||||
}];
|
||||
@@ -12,16 +12,16 @@ module.exports = {
|
||||
}
|
||||
],
|
||||
'chat': [
|
||||
{'id': 'chat-server-1', 'host': '127.0.0.1', 'port': 6050, "args": " --inspect=9237"}
|
||||
{ 'id': 'chat-server-1', 'host': '127.0.0.1', 'port': 6050, "args": " --inspect=9237" }
|
||||
],
|
||||
'role': [
|
||||
{'id': 'role-server-1', 'host': '127.0.0.1', 'port': 6053, "args": " --inspect=9229"}
|
||||
{ 'id': 'role-server-1', 'host': '127.0.0.1', 'port': 6053, "args": " --inspect=9229" }
|
||||
],
|
||||
'battle': [
|
||||
{'id': 'battle-server-1', 'host': '127.0.0.1', 'port': 6054, "args": " --inspect=9238"}
|
||||
{ 'id': 'battle-server-1', 'host': '127.0.0.1', 'port': 6054, "args": " --inspect=9238" }
|
||||
],
|
||||
'gm': [
|
||||
{'id': 'gm-server-1', 'host': '127.0.0.1', 'port': 6055,"args": " --inspect=9234"}
|
||||
{ 'id': 'gm-server-1', 'host': '127.0.0.1', 'port': 6055, "args": " --inspect=9234" }
|
||||
],
|
||||
'gate': [
|
||||
{
|
||||
@@ -42,33 +42,36 @@ module.exports = {
|
||||
}
|
||||
],
|
||||
'systimer': [
|
||||
{'id': 'systimer-server-1', 'host': '127.0.0.1', 'port': 6056, "args": " --inspect=9233"}
|
||||
{ 'id': 'systimer-server-1', 'host': '127.0.0.1', 'port': 6056, "args": " --inspect=9233" }
|
||||
],
|
||||
'guild': [
|
||||
{'id': 'guild-server-1', 'host': '127.0.0.1', 'port': 6057, "args": " --inspect=9239"},
|
||||
{'id': 'guild-server-2', 'host': '127.0.0.1', 'port': 6058, "args": " --inspect=9240"}
|
||||
{ 'id': 'guild-server-1', 'host': '127.0.0.1', 'port': 6057, "args": " --inspect=9239" },
|
||||
{ 'id': 'guild-server-2', 'host': '127.0.0.1', 'port': 6058, "args": " --inspect=9240" }
|
||||
],
|
||||
'activity': [
|
||||
{'id': 'activity-server-1', 'host': '127.0.0.1', 'port': 6059, "args": " --inspect=9241"},
|
||||
{ 'id': 'activity-server-1', 'host': '127.0.0.1', 'port': 6059, "args": " --inspect=9241" },
|
||||
],
|
||||
'order': [
|
||||
{ 'id': 'order-server-1', 'host': '127.0.0.1', 'port': 6060, "args": " --inspect=9242" },
|
||||
]
|
||||
},
|
||||
'production': {
|
||||
'connector': [
|
||||
{'id': 'connector-server-1', 'port': 4050, 'clientHost': 'pinus_test.trgame.cn', 'host': '127.0.0.1', 'clientPort': 3050, 'frontend': true},
|
||||
{'id': 'connector-server-2', 'port': 4051, 'clientHost': 'pinus_test.trgame.cn', 'host': '127.0.0.1', 'clientPort': 3051, 'frontend': true},
|
||||
{'id': 'connector-server-3', 'port': 4052, 'clientHost': 'pinus_test.trgame.cn', 'host': '127.0.0.1', 'clientPort': 3052, 'frontend': true}
|
||||
{ 'id': 'connector-server-1', 'port': 4050, 'clientHost': 'pinus_test.trgame.cn', 'host': '127.0.0.1', 'clientPort': 3050, 'frontend': true },
|
||||
{ 'id': 'connector-server-2', 'port': 4051, 'clientHost': 'pinus_test.trgame.cn', 'host': '127.0.0.1', 'clientPort': 3051, 'frontend': true },
|
||||
{ 'id': 'connector-server-3', 'port': 4052, 'clientHost': 'pinus_test.trgame.cn', 'host': '127.0.0.1', 'clientPort': 3052, 'frontend': true }
|
||||
],
|
||||
'chat': [
|
||||
{'id': 'chat-server-1', 'host': '127.0.0.1', 'port': 6050},
|
||||
{ 'id': 'chat-server-1', 'host': '127.0.0.1', 'port': 6050 },
|
||||
],
|
||||
'role': [
|
||||
{'id': 'role-server-1', 'host': '127.0.0.1', 'port': 6053}
|
||||
{ 'id': 'role-server-1', 'host': '127.0.0.1', 'port': 6053 }
|
||||
],
|
||||
'battle': [
|
||||
{'id': 'battle-server-1', 'host': '127.0.0.1', 'port': 6054}
|
||||
{ 'id': 'battle-server-1', 'host': '127.0.0.1', 'port': 6054 }
|
||||
],
|
||||
'gate': [
|
||||
{'id': 'gate-server-1', 'host': '127.0.0.1', 'clientHost': 'pinus_test.trgame.cn', 'clientPort': 3014, 'frontend': true},
|
||||
{ 'id': 'gate-server-1', 'host': '127.0.0.1', 'clientHost': 'pinus_test.trgame.cn', 'clientPort': 3014, 'frontend': true },
|
||||
{
|
||||
'id': 'gate-server-2',
|
||||
'host': '127.0.0.1',
|
||||
@@ -78,38 +81,41 @@ module.exports = {
|
||||
}
|
||||
],
|
||||
'gm': [
|
||||
{'id': 'gm-server-1', 'host': '127.0.0.1', 'port': 6055}
|
||||
{ 'id': 'gm-server-1', 'host': '127.0.0.1', 'port': 6055 }
|
||||
],
|
||||
'systimer': [
|
||||
{'id': 'systimer-server-1', 'host': '127.0.0.1', 'port': 6056}
|
||||
{ 'id': 'systimer-server-1', 'host': '127.0.0.1', 'port': 6056 }
|
||||
],
|
||||
'guild': [
|
||||
{'id': 'guild-server-1', 'host': '127.0.0.1', 'port': 6057, "args": " --inspect=9239"},
|
||||
{'id': 'guild-server-2', 'host': '127.0.0.1', 'port': 6058, "args": " --inspect=9240"}
|
||||
{ 'id': 'guild-server-1', 'host': '127.0.0.1', 'port': 6057, "args": " --inspect=9239" },
|
||||
{ 'id': 'guild-server-2', 'host': '127.0.0.1', 'port': 6058, "args": " --inspect=9240" }
|
||||
],
|
||||
'activity': [
|
||||
{'id': 'activity-server-1', 'host': '127.0.0.1', 'port': 6059, "args": " --inspect=9241"},
|
||||
{ 'id': 'activity-server-1', 'host': '127.0.0.1', 'port': 6059, "args": " --inspect=9241" },
|
||||
],
|
||||
'order': [
|
||||
{ 'id': 'order-server-1', 'host': '127.0.0.1', 'port': 6060, "args": " --inspect=9242" },
|
||||
]
|
||||
},
|
||||
'alpha': {
|
||||
'connector': [
|
||||
{'id': 'connector-server-1', 'port': 4050, 'clientHost': 'zyz_web.trgame.cn', 'host': '127.0.0.1', 'clientPort': 3050, 'frontend': true},
|
||||
{'id': 'connector-server-2', 'port': 4051, 'clientHost': 'zyz_web.trgame.cn', 'host': '127.0.0.1', 'clientPort': 3051, 'frontend': true},
|
||||
{'id': 'connector-server-3', 'port': 4052, 'clientHost': 'zyz_web.trgame.cn', 'host': '127.0.0.1', 'clientPort': 3052, 'frontend': true}
|
||||
{ 'id': 'connector-server-1', 'port': 4050, 'clientHost': 'zyz_web.trgame.cn', 'host': '127.0.0.1', 'clientPort': 3050, 'frontend': true },
|
||||
{ 'id': 'connector-server-2', 'port': 4051, 'clientHost': 'zyz_web.trgame.cn', 'host': '127.0.0.1', 'clientPort': 3051, 'frontend': true },
|
||||
{ 'id': 'connector-server-3', 'port': 4052, 'clientHost': 'zyz_web.trgame.cn', 'host': '127.0.0.1', 'clientPort': 3052, 'frontend': true }
|
||||
],
|
||||
'chat': [
|
||||
{'id': 'chat-server-1', 'host': '127.0.0.1', 'port': 6050},
|
||||
{'id': 'chat-server-2', 'host': '127.0.0.1', 'port': 6051},
|
||||
{'id': 'chat-server-3', 'host': '127.0.0.1', 'port': 6052}
|
||||
{ 'id': 'chat-server-1', 'host': '127.0.0.1', 'port': 6050 },
|
||||
{ 'id': 'chat-server-2', 'host': '127.0.0.1', 'port': 6051 },
|
||||
{ 'id': 'chat-server-3', 'host': '127.0.0.1', 'port': 6052 }
|
||||
],
|
||||
'role': [
|
||||
{'id': 'role-server-1', 'host': '127.0.0.1', 'port': 6053}
|
||||
{ 'id': 'role-server-1', 'host': '127.0.0.1', 'port': 6053 }
|
||||
],
|
||||
'battle': [
|
||||
{'id': 'battle-server-1', 'host': '127.0.0.1', 'port': 6054}
|
||||
{ 'id': 'battle-server-1', 'host': '127.0.0.1', 'port': 6054 }
|
||||
],
|
||||
'gate': [
|
||||
{'id': 'gate-server-1', 'host': '127.0.0.1', 'clientHost': 'zyz_web.trgame.cn', 'clientPort': 3014, 'frontend': true},
|
||||
{ 'id': 'gate-server-1', 'host': '127.0.0.1', 'clientHost': 'zyz_web.trgame.cn', 'clientPort': 3014, 'frontend': true },
|
||||
{
|
||||
'id': 'gate-server-2',
|
||||
'host': '127.0.0.1',
|
||||
@@ -119,38 +125,41 @@ module.exports = {
|
||||
}
|
||||
],
|
||||
'gm': [
|
||||
{'id': 'gm-server-1', 'host': '127.0.0.1', 'port': 6055}
|
||||
{ 'id': 'gm-server-1', 'host': '127.0.0.1', 'port': 6055 }
|
||||
],
|
||||
'systimer': [
|
||||
{'id': 'systimer-server-1', 'host': '127.0.0.1', 'port': 6056}
|
||||
{ 'id': 'systimer-server-1', 'host': '127.0.0.1', 'port': 6056 }
|
||||
],
|
||||
'guild': [
|
||||
{'id': 'guild-server-1', 'host': '127.0.0.1', 'port': 6057, "args": " --inspect=9239"},
|
||||
{'id': 'guild-server-2', 'host': '127.0.0.1', 'port': 6058, "args": " --inspect=9240"}
|
||||
{ 'id': 'guild-server-1', 'host': '127.0.0.1', 'port': 6057, "args": " --inspect=9239" },
|
||||
{ 'id': 'guild-server-2', 'host': '127.0.0.1', 'port': 6058, "args": " --inspect=9240" }
|
||||
],
|
||||
'activity': [
|
||||
{'id': 'activity-server-1', 'host': '127.0.0.1', 'port': 6059, "args": " --inspect=9241"},
|
||||
{ 'id': 'activity-server-1', 'host': '127.0.0.1', 'port': 6059, "args": " --inspect=9241" },
|
||||
],
|
||||
'order': [
|
||||
{ 'id': 'order-server-1', 'host': '127.0.0.1', 'port': 6060, "args": " --inspect=9242" },
|
||||
]
|
||||
},
|
||||
'dev': {
|
||||
'connector': [
|
||||
{'id': 'connector-server-1', 'port': 4050, 'clientHost': 'zyzdev.trgame.cn', 'host': '127.0.0.1', 'clientPort': 3050, 'frontend': true, "args": " --inspect=9237"},
|
||||
{'id': 'connector-server-2', 'port': 4051, 'clientHost': 'zyzdev.trgame.cn', 'host': '127.0.0.1', 'clientPort': 3051, 'frontend': true, "args": " --inspect=9229"},
|
||||
{'id': 'connector-server-3', 'port': 4052, 'clientHost': 'zyzdev.trgame.cn', 'host': '127.0.0.1', 'clientPort': 3052, 'frontend': true, "args": " --inspect=9238"}
|
||||
{ 'id': 'connector-server-1', 'port': 4050, 'clientHost': 'zyzdev.trgame.cn', 'host': '127.0.0.1', 'clientPort': 3050, 'frontend': true, "args": " --inspect=9237" },
|
||||
{ 'id': 'connector-server-2', 'port': 4051, 'clientHost': 'zyzdev.trgame.cn', 'host': '127.0.0.1', 'clientPort': 3051, 'frontend': true, "args": " --inspect=9229" },
|
||||
{ 'id': 'connector-server-3', 'port': 4052, 'clientHost': 'zyzdev.trgame.cn', 'host': '127.0.0.1', 'clientPort': 3052, 'frontend': true, "args": " --inspect=9238" }
|
||||
],
|
||||
'chat': [
|
||||
{'id': 'chat-server-1', 'host': '127.0.0.1', 'port': 6050,"args": " --inspect=9234"},
|
||||
{'id': 'chat-server-2', 'host': '127.0.0.1', 'port': 6051,"args": " --inspect=9235"},
|
||||
{'id': 'chat-server-3', 'host': '127.0.0.1', 'port': 6052,"args": " --inspect=9236"}
|
||||
{ 'id': 'chat-server-1', 'host': '127.0.0.1', 'port': 6050, "args": " --inspect=9234" },
|
||||
{ 'id': 'chat-server-2', 'host': '127.0.0.1', 'port': 6051, "args": " --inspect=9235" },
|
||||
{ 'id': 'chat-server-3', 'host': '127.0.0.1', 'port': 6052, "args": " --inspect=9236" }
|
||||
],
|
||||
'role': [
|
||||
{'id': 'role-server-1', 'host': '127.0.0.1', 'port': 6053,"args": " --inspect=9231"}
|
||||
{ 'id': 'role-server-1', 'host': '127.0.0.1', 'port': 6053, "args": " --inspect=9231" }
|
||||
],
|
||||
'battle': [
|
||||
{'id': 'battle-server-1', 'host': '127.0.0.1', 'port': 6054,"args": " --inspect=9230"}
|
||||
{ 'id': 'battle-server-1', 'host': '127.0.0.1', 'port': 6054, "args": " --inspect=9230" }
|
||||
],
|
||||
'gate': [
|
||||
{'id': 'gate-server-1', 'host': '127.0.0.1', 'clientHost': 'zyzdev.trgame.cn', 'clientPort': 3014, 'frontend': true,"args": " --inspect=9227"},
|
||||
{ 'id': 'gate-server-1', 'host': '127.0.0.1', 'clientHost': 'zyzdev.trgame.cn', 'clientPort': 3014, 'frontend': true, "args": " --inspect=9227" },
|
||||
{
|
||||
'id': 'gate-server-2',
|
||||
'host': '127.0.0.1',
|
||||
@@ -161,36 +170,39 @@ module.exports = {
|
||||
}
|
||||
],
|
||||
'gm': [
|
||||
{'id': 'gm-server-1', 'host': '127.0.0.1', 'port': 6055,"args": " --inspect=9232"}
|
||||
{ 'id': 'gm-server-1', 'host': '127.0.0.1', 'port': 6055, "args": " --inspect=9232" }
|
||||
],
|
||||
'systimer': [
|
||||
{'id': 'systimer-server-1', 'host': '127.0.0.1', 'port': 6056, "args": " --inspect=9233"}
|
||||
{ 'id': 'systimer-server-1', 'host': '127.0.0.1', 'port': 6056, "args": " --inspect=9233" }
|
||||
],
|
||||
'guild': [
|
||||
{'id': 'guild-server-1', 'host': '127.0.0.1', 'port': 6057, "args": " --inspect=9239"},
|
||||
{'id': 'guild-server-2', 'host': '127.0.0.1', 'port': 6058, "args": " --inspect=9240"}
|
||||
{ 'id': 'guild-server-1', 'host': '127.0.0.1', 'port': 6057, "args": " --inspect=9239" },
|
||||
{ 'id': 'guild-server-2', 'host': '127.0.0.1', 'port': 6058, "args": " --inspect=9240" }
|
||||
],
|
||||
'activity': [
|
||||
{'id': 'activity-server-1', 'host': '127.0.0.1', 'port': 6059, "args": " --inspect=9241"},
|
||||
{ 'id': 'activity-server-1', 'host': '127.0.0.1', 'port': 6059, "args": " --inspect=9241" },
|
||||
],
|
||||
'order': [
|
||||
{ 'id': 'order-server-1', 'host': '127.0.0.1', 'port': 6060, "args": " --inspect=9242" },
|
||||
]
|
||||
},
|
||||
'isbn': {
|
||||
'connector': [
|
||||
{'id': 'connector-server-1', 'port': 4050, 'clientHost': 'zyz_isbn.trgame.cn', 'host': '127.0.0.1', 'clientPort': 3050, 'frontend': true},
|
||||
{'id': 'connector-server-2', 'port': 4051, 'clientHost': 'zyz_isbn.trgame.cn', 'host': '127.0.0.1', 'clientPort': 3051, 'frontend': true},
|
||||
{'id': 'connector-server-3', 'port': 4052, 'clientHost': 'zyz_isbn.trgame.cn', 'host': '127.0.0.1', 'clientPort': 3052, 'frontend': true}
|
||||
{ 'id': 'connector-server-1', 'port': 4050, 'clientHost': 'zyz_isbn.trgame.cn', 'host': '127.0.0.1', 'clientPort': 3050, 'frontend': true },
|
||||
{ 'id': 'connector-server-2', 'port': 4051, 'clientHost': 'zyz_isbn.trgame.cn', 'host': '127.0.0.1', 'clientPort': 3051, 'frontend': true },
|
||||
{ 'id': 'connector-server-3', 'port': 4052, 'clientHost': 'zyz_isbn.trgame.cn', 'host': '127.0.0.1', 'clientPort': 3052, 'frontend': true }
|
||||
],
|
||||
'chat': [
|
||||
{'id': 'chat-server-1', 'host': '127.0.0.1', 'port': 6050},
|
||||
{ 'id': 'chat-server-1', 'host': '127.0.0.1', 'port': 6050 },
|
||||
],
|
||||
'role': [
|
||||
{'id': 'role-server-1', 'host': '127.0.0.1', 'port': 6053}
|
||||
{ 'id': 'role-server-1', 'host': '127.0.0.1', 'port': 6053 }
|
||||
],
|
||||
'battle': [
|
||||
{'id': 'battle-server-1', 'host': '127.0.0.1', 'port': 6054}
|
||||
{ 'id': 'battle-server-1', 'host': '127.0.0.1', 'port': 6054 }
|
||||
],
|
||||
'gate': [
|
||||
{'id': 'gate-server-1', 'host': '127.0.0.1', 'clientHost': 'zyz_isbn.trgame.cn', 'clientPort': 3014, 'frontend': true},
|
||||
{ 'id': 'gate-server-1', 'host': '127.0.0.1', 'clientHost': 'zyz_isbn.trgame.cn', 'clientPort': 3014, 'frontend': true },
|
||||
{
|
||||
'id': 'gate-server-2',
|
||||
'host': '127.0.0.1',
|
||||
@@ -200,50 +212,56 @@ module.exports = {
|
||||
}
|
||||
],
|
||||
'gm': [
|
||||
{'id': 'gm-server-1', 'host': '127.0.0.1', 'port': 6055}
|
||||
{ 'id': 'gm-server-1', 'host': '127.0.0.1', 'port': 6055 }
|
||||
],
|
||||
'systimer': [
|
||||
{'id': 'systimer-server-1', 'host': '127.0.0.1', 'port': 6056}
|
||||
{ 'id': 'systimer-server-1', 'host': '127.0.0.1', 'port': 6056 }
|
||||
],
|
||||
'guild': [
|
||||
{'id': 'guild-server-1', 'host': '127.0.0.1', 'port': 6057, "args": " --inspect=9239"},
|
||||
{'id': 'guild-server-2', 'host': '127.0.0.1', 'port': 6058, "args": " --inspect=9240"}
|
||||
{ 'id': 'guild-server-1', 'host': '127.0.0.1', 'port': 6057, "args": " --inspect=9239" },
|
||||
{ 'id': 'guild-server-2', 'host': '127.0.0.1', 'port': 6058, "args": " --inspect=9240" }
|
||||
],
|
||||
'activity': [
|
||||
{'id': 'activity-server-1', 'host': '127.0.0.1', 'port': 6059, "args": " --inspect=9241"},
|
||||
{ 'id': 'activity-server-1', 'host': '127.0.0.1', 'port': 6059, "args": " --inspect=9241" },
|
||||
],
|
||||
'order': [
|
||||
{ 'id': 'order-server-1', 'host': '127.0.0.1', 'port': 6060, "args": " --inspect=9242" },
|
||||
]
|
||||
},
|
||||
'monitor': {
|
||||
'connector': [
|
||||
{'id': 'connector-server-1', 'port': 4050, 'clientHost': 'zyz_monitor.trgame.cn', 'host': '127.0.0.1', 'clientPort': 3050, 'frontend': true},
|
||||
{'id': 'connector-server-2', 'port': 4051, 'clientHost': 'zyz_monitor.trgame.cn', 'host': '127.0.0.1', 'clientPort': 3051, 'frontend': true},
|
||||
{'id': 'connector-server-3', 'port': 4052, 'clientHost': 'zyz_monitor.trgame.cn', 'host': '127.0.0.1', 'clientPort': 3052, 'frontend': true}
|
||||
{ 'id': 'connector-server-1', 'port': 4050, 'clientHost': 'zyz_monitor.trgame.cn', 'host': '127.0.0.1', 'clientPort': 3050, 'frontend': true },
|
||||
{ 'id': 'connector-server-2', 'port': 4051, 'clientHost': 'zyz_monitor.trgame.cn', 'host': '127.0.0.1', 'clientPort': 3051, 'frontend': true },
|
||||
{ 'id': 'connector-server-3', 'port': 4052, 'clientHost': 'zyz_monitor.trgame.cn', 'host': '127.0.0.1', 'clientPort': 3052, 'frontend': true }
|
||||
],
|
||||
'chat': [
|
||||
{'id': 'chat-server-1', 'host': '127.0.0.1', 'port': 6050},
|
||||
{ 'id': 'chat-server-1', 'host': '127.0.0.1', 'port': 6050 },
|
||||
],
|
||||
'role': [
|
||||
{'id': 'role-server-1', 'host': '127.0.0.1', 'port': 6053}
|
||||
{ 'id': 'role-server-1', 'host': '127.0.0.1', 'port': 6053 }
|
||||
],
|
||||
'battle': [
|
||||
{'id': 'battle-server-1', 'host': '127.0.0.1', 'port': 6054}
|
||||
{ 'id': 'battle-server-1', 'host': '127.0.0.1', 'port': 6054 }
|
||||
],
|
||||
'gate': [
|
||||
{'id': 'gate-server-1', 'host': '127.0.0.1', 'clientHost': 'zyz_monitor.trgame.cn', 'clientPort': 3014, 'frontend': true},
|
||||
{'id': 'gate-server-2', 'host': '127.0.0.1', 'clientHost': 'zyz_monitor.trgame.cn', 'clientPort': 3015, 'frontend': true}
|
||||
{ 'id': 'gate-server-1', 'host': '127.0.0.1', 'clientHost': 'zyz_monitor.trgame.cn', 'clientPort': 3014, 'frontend': true },
|
||||
{ 'id': 'gate-server-2', 'host': '127.0.0.1', 'clientHost': 'zyz_monitor.trgame.cn', 'clientPort': 3015, 'frontend': true }
|
||||
],
|
||||
'gm': [
|
||||
{'id': 'gm-server-1', 'host': '127.0.0.1', 'port': 6055}
|
||||
{ 'id': 'gm-server-1', 'host': '127.0.0.1', 'port': 6055 }
|
||||
],
|
||||
'systimer': [
|
||||
{'id': 'systimer-server-1', 'host': '127.0.0.1', 'port': 6056}
|
||||
{ 'id': 'systimer-server-1', 'host': '127.0.0.1', 'port': 6056 }
|
||||
],
|
||||
'guild': [
|
||||
{'id': 'guild-server-1', 'host': '127.0.0.1', 'port': 6057, "args": " --inspect=9239"},
|
||||
{'id': 'guild-server-2', 'host': '127.0.0.1', 'port': 6058, "args": " --inspect=9240"}
|
||||
{ 'id': 'guild-server-1', 'host': '127.0.0.1', 'port': 6057, "args": " --inspect=9239" },
|
||||
{ 'id': 'guild-server-2', 'host': '127.0.0.1', 'port': 6058, "args": " --inspect=9240" }
|
||||
],
|
||||
'activity': [
|
||||
{'id': 'activity-server-1', 'host': '127.0.0.1', 'port': 6059, "args": " --inspect=9241"},
|
||||
{ 'id': 'activity-server-1', 'host': '127.0.0.1', 'port': 6059, "args": " --inspect=9241" },
|
||||
],
|
||||
'order': [
|
||||
{ 'id': 'order-server-1', 'host': '127.0.0.1', 'port': 6060, "args": " --inspect=9242" },
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
@@ -59,4 +59,23 @@ export enum FIRST_GIFT_STATE {
|
||||
NOT_OPEN = 0, // 未开启
|
||||
OPEN = 1, // 开启中
|
||||
CLOSED = 2, //结束
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付类型
|
||||
*/
|
||||
export enum PAY_TYPE {
|
||||
WX = 1, // 微信
|
||||
ALI = 2, // 阿里
|
||||
APPLE = 3, // 苹果
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单状态类型
|
||||
*/
|
||||
export enum ORDER_STATE {
|
||||
APPLY = 1, // 下单成功
|
||||
CHECK_ORDER = 2, // 触发查询订单
|
||||
RESULT_SUCCESS = 3, // 订单成功并结算奖励
|
||||
RESULT_FAIL = 4, // 订单失败
|
||||
}
|
||||
|
||||
@@ -484,6 +484,7 @@ export const FILENAME = {
|
||||
DIC_GACHA_CONTENT: 'dic_zyz_recruitContent',
|
||||
DIC_GIFT_PACKAGE: 'dic_zyz_giftPackage',
|
||||
DIC_RECRUIT: 'dic_zyz_recruit',
|
||||
DIC_RMB: 'dic_zyz_rmb'
|
||||
}
|
||||
|
||||
export const WAR_RELATE_TABLES = [
|
||||
|
||||
@@ -366,6 +366,11 @@ export const STATUS = {
|
||||
GM_HERO_NOT_FOUND: { code: 60011, simStr: '未找到武将' },
|
||||
GM_PVP_DEFENSE_NOT_FOUND: { code: 60012, simStr: '该玩家未保存防守阵' },
|
||||
GM_PVP_DEFENSE_HERO_NOT_FOUND: { code: 60013, simStr: '该守阵没有该武将' },
|
||||
GM_JSON_FORMAT_ERR: { code: 60005, simStr: 'json格式错误' }
|
||||
GM_JSON_FORMAT_ERR: { code: 60005, simStr: 'json格式错误' },
|
||||
// 支付相关状态 70000 - 79999
|
||||
NO_PRODUCT_ID: { code: 70001, simStr: '无效商品' },
|
||||
NO_PAY_TYPE: { code: 70002, simStr: '无效支付类型' },
|
||||
NO_ORDER: { code: 70003, simStr: '没有此订单' },
|
||||
DUPLICATE_ORDER: { code: 70004, simStr: '订单已经结算' }
|
||||
|
||||
}
|
||||
|
||||
73
shared/db/UserOrder.ts
Normal file
73
shared/db/UserOrder.ts
Normal file
@@ -0,0 +1,73 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
|
||||
import { ORDER_STATE } from '../consts';
|
||||
|
||||
/**
|
||||
* 玩家充值订单
|
||||
*/
|
||||
@index({ localOrderID: 1 })
|
||||
|
||||
export default class UserOrder extends BaseModel {
|
||||
|
||||
@prop({ required: true })
|
||||
serverId: number; // 区号
|
||||
@prop({ required: true })
|
||||
roleId: string; // 用户id
|
||||
@prop({ required: true })
|
||||
productID: string; // 商品
|
||||
@prop({ required: true })
|
||||
orderID: string; // 平台订单号
|
||||
@prop({ required: true })
|
||||
localOrderID: string; // 本地订单号
|
||||
@prop({ required: true })
|
||||
payType: number; // 支付类型 PAY_TYPE
|
||||
@prop({ required: true })
|
||||
price: number; // 价格
|
||||
@prop({ required: true })
|
||||
state: number; // 订单状态 ORDER_STATE 3.支付成功并结算
|
||||
@prop({ required: true })
|
||||
message: string; // 信息
|
||||
|
||||
//校验订单
|
||||
public static async check(roleId: string, localOrderID: string, message: string = '') {
|
||||
let result: UserOrderModelType = await UserOrderModel.findOneAndUpdate({ roleId, localOrderID, state: { $ne: ORDER_STATE.RESULT_SUCCESS } },
|
||||
{ $set: { state: ORDER_STATE.CHECK_ORDER, message } },
|
||||
{ new: true }).lean(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
//订单支付失败
|
||||
public static async fail(roleId: string, localOrderID: string, message: string = '') {
|
||||
let result: UserOrderModelType = await UserOrderModel.findOneAndUpdate({ roleId, localOrderID, state: { $ne: ORDER_STATE.RESULT_SUCCESS } },
|
||||
{ $set: { state: ORDER_STATE.RESULT_FAIL, message } },
|
||||
{ new: true }).lean(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
//订单支付成功
|
||||
public static async success(roleId: string, localOrderID: string, message: string = '') {
|
||||
let result: UserOrderModelType = await UserOrderModel.findOneAndUpdate({ roleId, localOrderID, state: { $ne: ORDER_STATE.RESULT_SUCCESS } },
|
||||
{ $set: { state: ORDER_STATE.RESULT_SUCCESS, message } },
|
||||
{ new: true }).lean(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
//查询订单详情
|
||||
public static async findOrder(localOrderID: string) {
|
||||
let result: UserOrderModelType = await UserOrderModel.findOne({ localOrderID }).lean(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
//新增订单
|
||||
public static async applyOrder(serverId: number, roleId: string, productID: string, localOrderID: string, orderID: string, price: number, payType: number, message: string = '') {
|
||||
let result: UserOrderModelType = await UserOrderModel.findOneAndUpdate({ serverId, roleId, productID, localOrderID, orderID, payType },
|
||||
{ $set: { price, state: ORDER_STATE.APPLY, message } },
|
||||
{ upsert: true, new: true }).lean(true);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
export const UserOrderModel = getModelForClass(UserOrder);
|
||||
|
||||
export interface UserOrderModelType extends Pick<DocumentType<UserOrder>, keyof UserOrder> { }
|
||||
export type UserOrderModelTypeParam = Partial<UserOrderModelType>; // 将所有字段变成可选项
|
||||
22
shared/pubUtils/dictionary/DicRMB.ts
Normal file
22
shared/pubUtils/dictionary/DicRMB.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
// RMB商品价格表
|
||||
import { readJsonFile } from '../util';
|
||||
import { FILENAME } from '../../consts';
|
||||
|
||||
export interface DicRMB {
|
||||
// 商品ID 必须唯一不能相同
|
||||
readonly productID: string;
|
||||
// 类型 ACTIVITY_TYPE
|
||||
readonly type: number;
|
||||
// 价格
|
||||
readonly price: number;
|
||||
// 描述
|
||||
readonly message: string;
|
||||
}
|
||||
|
||||
const str = readJsonFile(FILENAME.DIC_RMB);
|
||||
let arr = JSON.parse(str);
|
||||
|
||||
export const dicRMB = new Map<string, DicRMB>();
|
||||
arr.forEach(o => {
|
||||
dicRMB.set(o.productID, o);
|
||||
});
|
||||
14
shared/resource/jsons/dic_zyz_rmb.json
Normal file
14
shared/resource/jsons/dic_zyz_rmb.json
Normal file
@@ -0,0 +1,14 @@
|
||||
[
|
||||
{
|
||||
"productID": "com.bantu.zyz.yb1",
|
||||
"type": 15,
|
||||
"price": 6,
|
||||
"message": "赵云传购买元宝60"
|
||||
},
|
||||
{
|
||||
"productID": "com.bantu.zyz.yb2",
|
||||
"type": 15,
|
||||
"price": 12,
|
||||
"message": "赵云传购买元宝160"
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user