Commit 8b626fd2 by Sixong.Zhu

update withdraw message

parent b509c106
......@@ -170,10 +170,10 @@
import { ChatRole } from "@/customer-service/model";
import { getUserMapping } from "../utils/user-info";
import Xim from "@/customer-service/xim";
import { CustomerServiceEvent } from "../event";
import { CustomerServiceEvent, MessageEvent } from "../event";
import { PayMessageBody } from "../xim/models/chat";
const twoMinutes = 2 * 60 * 1000;
const twoHours = 2 * 60 * 60 * 1000;
const messageMapping = new Map<dto.MessageType, string>([
[dto.MessageType.Image, "image-message"],
......@@ -269,12 +269,18 @@
private isWithdraw = true;
private get isPayMessage() {
return dto.MessageTypeController.isPayMessage(this.data.type);
}
private get canWithdraw() {
if (this.backend && this.data) {
if (this.isPayMessage) {
return true;
}
if (this.needReadTip) {
return new Date().valueOf() - this.data.ts * 1000 < twoMinutes;
}
return new Date().valueOf() - this.data.ts * 1000 < twoHours;
}
return false;
}
......@@ -493,6 +499,12 @@
if (!this.hoverWithdraw()) {
return Xim.error("不能撤回");
}
if (dto.MessageTypeController.isChargeMessage(this.data.type)) {
return this.openMessage({
type: MessageEvent.WithdrawCharge,
model: (this.messageBody.msg as PayMessageBody).paymentId,
});
}
ximInstance.withdraw(this.chatId, this.data.id).finally(() => {
dbController
.removeMessage(this.chatId, [this.data.id])
......@@ -504,12 +516,14 @@
}
private hoverWithdraw() {
if (this.isPayMessage) {
return true;
}
if (!this.isWithdraw || !this.isMyMessage) {
return false;
}
return (this.isWithdraw = this.needReadTip
? new Date().valueOf() - this.data.ts * 1000 < twoMinutes
: new Date().valueOf() - this.data.ts * 1000 < twoHours);
return (this.isWithdraw =
new Date().valueOf() - this.data.ts * 1000 < twoMinutes);
}
private openReaderList(e: MouseEvent) {
......
......@@ -2,6 +2,7 @@ export const enum MessageEvent {
Default = "open-message",
PayMessage = "pay-message",
PositionMessage = "position-message",
WithdrawCharge = "widthdraw-charge",
}
export class CustomerServiceEvent {
......
......@@ -306,7 +306,6 @@ export const enum IMCatalog {
Order = "专项业务订单",
}
export class MessageTypeController {
private static readonly pays = new Set<MessageType>([
MessageType.Pay,
......@@ -314,21 +313,40 @@ export class MessageTypeController {
MessageType.PayV1,
MessageType.Refund,
MessageType.RefundV1,
MessageType.Withdraw
MessageType.Withdraw,
]);
private static readonly charges = new Set<MessageType>([
MessageType.Pay,
MessageType.PayV1,
]);
public static isPayMessage(type: MessageType) {
return this.pays.has(type);
}
public static isChargeMessage(type: MessageType) {
return this.charges.has(type);
}
public static isOrderOpenedMessage(e: Message) {
return e && !+e.eid && e.msg && e.msg.includes('订单详情') && e.msg.includes('查看订单');
return (
e &&
!+e.eid &&
e.msg &&
e.msg.includes("订单详情") &&
e.msg.includes("查看订单")
);
}
public static isOrderClosedMessage(e: Message) {
if (e && e.msg && !+e.eid) {
const msg = e.msg;
return msg.includes('办理完成') || msg.includes('办理失败') || msg.includes('订单已取消');
return (
msg.includes("办理完成") ||
msg.includes("办理失败") ||
msg.includes("订单已取消")
);
}
return false;
}
......
import { Chat } from "../xim/models/chat";
import { GeneralOrderDirection } from './order-product';
import { action } from 'uniplat-sdk';
export interface ChatGroup extends Chat {
children?: ChatGroup[];
......@@ -143,7 +144,7 @@ export interface OrderPayItem {
desc: string;
agent: string;
createdTime: string;
actions?: any[];
actions?: action[];
bankAccountName?: string;
OpenningBankName?: string;
bankAccountNo?: string;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment