Commit cd6737c1 by Sixong.Zhu

Merge branch 'master' into pre

parents 7c3549d8 98df262b
...@@ -61,6 +61,12 @@ export default class ChatList extends Vue { ...@@ -61,6 +61,12 @@ export default class ChatList extends Vue {
@chatStore.State(ChatStore.STATE_CURRENT_UNREAD_MESSAGE_COUNT) @chatStore.State(ChatStore.STATE_CURRENT_UNREAD_MESSAGE_COUNT)
protected readonly unread!: ChatStore.STATE_CURRENT_UNREAD_MESSAGE_COUNT; protected readonly unread!: ChatStore.STATE_CURRENT_UNREAD_MESSAGE_COUNT;
@chatStore.Getter(ChatStore.GETTER_CURRENT_CURRENT_CHAT)
protected readonly currentChat!: ChatStore.GETTER_CURRENT_CURRENT_CHAT;
@chatStore.Action(ChatStore.ACTION_CHAT_FINISH_RECEPTION)
protected readonly _finishReception!: ChatStore.ACTION_CHAT_FINISH_RECEPTION;
protected parseMesage(data: ChatItem) { protected parseMesage(data: ChatItem) {
if (data.last_msg_sender && data.last_msg_sender !== "0") { if (data.last_msg_sender && data.last_msg_sender !== "0") {
if (this.userNames[data.last_msg_sender] === undefined) { if (this.userNames[data.last_msg_sender] === undefined) {
......
...@@ -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,15 @@ ...@@ -493,6 +499,15 @@
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: {
payment: (this.messageBody.msg as PayMessageBody).paymentId,
msg: this.data.id,
},
});
}
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 +519,14 @@ ...@@ -504,12 +519,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) {
......
class DevAppTools {
private db!: IDBDatabase;
private readonly key = 'dev-tools';
private readonly valueKey = 'value';
private readonly table = 'dev-table';
private onReady() {
if (this.db) {
return Promise.resolve();
}
return new Promise<void>((resolve => {
if (indexedDB) {
const r = indexedDB.open(this.key, 1);
const setupDb = () => {
if (this.db && !this.db.objectStoreNames.contains(this.table)) {
this.db.createObjectStore(this.table, { keyPath: this.valueKey });
}
resolve();
};
r.onsuccess = (e) => {
this.db = (e.target as any).result;
setupDb();
};
r.onupgradeneeded = (e) => {
this.db = (e.target as any).result;
setupDb();
};
r.onerror = () => setupDb();
} else {
resolve();
}
}));
}
private buildTransaction(key: string) {
return this.db.transaction(key, "readwrite");
}
private buildStore(key: string) {
const transaction = this.buildTransaction(key);
return transaction.objectStore(key);
}
public isOpen() {
return new Promise<boolean>((resolve) => {
this.onReady().finally(() => {
if (!this.db) {
return resolve(false);
}
setTimeout(() => {
const store = this.buildStore(this.table);
const r = store.getKey(1);
r.onsuccess = (o) => resolve((o.target as any).result);
r.onerror = () => resolve(false);
}, 300);
});
});
}
public toggle() {
return new Promise<boolean>((resolve) => {
this.onReady().finally(() => {
setTimeout(() => {
this.isOpen().then(r => {
if (r) {
const store = this.buildStore(this.table);
const d = store.delete(1);
d.onsuccess = () => resolve(false);
d.onerror = () => resolve(false);
} else {
const store = this.buildStore(this.table);
const d = store.add({ value: 1 });
d.onsuccess = () => resolve(true);
d.onerror = () => resolve(true);
}
});
}, 300);
});
});
}
}
export const devAppTools = new DevAppTools();
...@@ -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 {
......
...@@ -305,3 +305,51 @@ export const enum IMCatalog { ...@@ -305,3 +305,51 @@ export const enum IMCatalog {
Flb = "福利宝", Flb = "福利宝",
Order = "专项业务订单", Order = "专项业务订单",
} }
export class MessageTypeController {
private static readonly pays = new Set<MessageType>([
MessageType.Pay,
MessageType.PayResult,
MessageType.PayV1,
MessageType.Refund,
MessageType.RefundV1,
MessageType.Withdraw,
]);
private static readonly charges = new Set<MessageType>([
MessageType.Pay,
MessageType.PayV1,
MessageType.Refund,
MessageType.RefundV1,
]);
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("查看订单")
);
}
public static isOrderClosedMessage(e: Message) {
if (e && e.msg && !+e.eid) {
const msg = e.msg;
return (
msg.includes("办理完成") ||
msg.includes("办理失败") ||
msg.includes("订单已取消")
);
}
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;
......
...@@ -224,7 +224,7 @@ class OrderService { ...@@ -224,7 +224,7 @@ class OrderService {
.query(); .query();
} }
public sendPayAccountInfo(params: { send: string }) { public sendPayAccountInfo(params: { send: string, type?: number }) {
return this.getSdk() return this.getSdk()
.domainService("hro_spview", "OrderSetting", "sendPayAccountInfo") .domainService("hro_spview", "OrderSetting", "sendPayAccountInfo")
.request("get", { params }); .request("get", { params });
......
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