Commit 8b626fd2 by Sixong.Zhu

update withdraw message

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