Commit a7483b91 by Sixong.Zhu

merge

parents 4ab11e1c c7763c7d
...@@ -14,12 +14,13 @@ class ChatCacheDatabaseController { ...@@ -14,12 +14,13 @@ class ChatCacheDatabaseController {
private readonly chatMessageKey = "chat-message"; private readonly chatMessageKey = "chat-message";
private setuping = false; private setuping = false;
private setupError = false;
private waitSetupCompleted() { private waitSetupCompleted() {
return new Promise<void>((resolve) => { return new Promise<void>((resolve, reject) => {
const checker = () => { const checker = () => {
if (!this.setuping) { if (!this.setuping) {
resolve(); this.setupError ? reject(new Error(`IM index database setup failed`)) : resolve();
} else { } else {
setTimeout(() => checker(), 200); setTimeout(() => checker(), 200);
} }
...@@ -32,43 +33,45 @@ class ChatCacheDatabaseController { ...@@ -32,43 +33,45 @@ class ChatCacheDatabaseController {
if (this.setuping) { if (this.setuping) {
return this.waitSetupCompleted(); return this.waitSetupCompleted();
} }
return new Promise<void>((resolve) => { return new Promise<void>((resolve, reject) => {
if (uid && indexedDB) { if (uid && indexedDB) {
this.setuping = true; this.setuping = true;
const r = indexedDB.open( const r = indexedDB.open(
"u-" + (this.uid = uid), "u-" + (this.uid = uid),
this.listVersion this.listVersion
); );
// eslint-disable-next-line @typescript-eslint/no-this-alias
const that = this;
const setupDb = () => { const setupDb = () => {
if (this.setuping) { if (this.setuping) {
if (that.db) { if (this.db) {
try { try {
that.buildTables(that.db, that.chatListKey); this.buildTables(this.db, this.chatListKey);
console.log( console.log(
`build index database for chat completed, 100%` `build index database for chat completed, 100%`
); );
} catch (e) { } catch (e) {
this.setupError = true;
console.error(e); console.error(e);
reject();
} }
} }
this.setuping = false; this.setuping = false;
} }
resolve(); resolve();
}; };
r.onsuccess = function (e) { r.onsuccess = (e) => {
that.db = (e.target as any).result; this.db = (e.target as any).result;
console.log(`index database init comepleted`); console.log(`index database init comepleted`);
setupDb(); setupDb();
}; };
r.onupgradeneeded = function (e) { r.onupgradeneeded = (e) => {
that.db = (e.target as any).result; this.db = (e.target as any).result;
console.log(`upgrade database comepleted`); console.log(`upgrade database comepleted`);
setupDb(); setupDb();
}; };
r.onerror = function (e) { r.onerror = (e) => {
console.log(`index database init failed, ${e}`); console.log(`index database init failed, ${e}`);
this.setupError = true;
reject();
}; };
} else { } else {
resolve(); resolve();
...@@ -128,7 +131,11 @@ class ChatCacheDatabaseController { ...@@ -128,7 +131,11 @@ class ChatCacheDatabaseController {
} }
private buildTransaction(key: string) { private buildTransaction(key: string) {
return this.db.transaction(key, "readwrite"); try { return this.db.transaction(key, "readwrite"); }
catch{
window.location.reload();
throw new Error(`transition failed`);
}
} }
private buildStore(key: string) { private buildStore(key: string) {
......
...@@ -80,7 +80,7 @@ export const orderPredict = { ...@@ -80,7 +80,7 @@ export const orderPredict = {
lastMsgContent: "UniplatLastMsgContent", lastMsgContent: "UniplatLastMsgContent",
lastMsgTime: "UniplatLastMsgTime", lastMsgTime: "UniplatLastMsgTime",
unreadCount: 0, unreadCount: 0,
PayPaymentNum: "PayPaymentNum" PayPaymentNum: "PayPaymentNum",
}; };
export const enum PayStatus { export const enum PayStatus {
...@@ -136,6 +136,15 @@ export interface OrderPayItem { ...@@ -136,6 +136,15 @@ export interface OrderPayItem {
paymentItemId?: number; paymentItemId?: number;
} }
export interface OrderComment {
id: number;
content: string;
user: string;
attachment: string;
attachment_label: string;
time: string;
}
export const orderPayItemPredict = { export const orderPayItemPredict = {
status: "Status", status: "Status",
time: "PaymentDate", time: "PaymentDate",
...@@ -153,7 +162,7 @@ export const orderPayItemPredict = { ...@@ -153,7 +162,7 @@ export const orderPayItemPredict = {
OpenningBankName: "ProviderHandleId#ServiceProviderBank.OpenningBankName", OpenningBankName: "ProviderHandleId#ServiceProviderBank.OpenningBankName",
bankAccountNo: "ProviderHandleId#ServiceProviderBank.AccountNo", bankAccountNo: "ProviderHandleId#ServiceProviderBank.AccountNo",
paymentItemId: "PaymentItemId", paymentItemId: "PaymentItemId",
} };
export const enum ChatOpenDirection { export const enum ChatOpenDirection {
/** /**
......
...@@ -9,12 +9,14 @@ import { ...@@ -9,12 +9,14 @@ import {
OrderPayItem, OrderPayItem,
UploadImageItem, UploadImageItem,
orderPayItemPredict, orderPayItemPredict,
OrderComment,
} from "../model"; } from "../model";
import { GeneralOrderDirection } from '../model/order-product'; import { GeneralOrderDirection } from "../model/order-product";
class OrderService { class OrderService {
public readonly generalOrder = "general_order_info"; public readonly generalOrder = "general_order_info";
public readonly generalOrderPaymentModel = "general_order_payment_info"; public readonly generalOrderPaymentModel = "general_order_payment_info";
private readonly commentModel = "uniplat_model_remark@general_order";
private readonly handler = new UniplatSdkExtender(); private readonly handler = new UniplatSdkExtender();
private innerSdk: UniplatSdk | null = null; private innerSdk: UniplatSdk | null = null;
...@@ -65,17 +67,19 @@ class OrderService { ...@@ -65,17 +67,19 @@ class OrderService {
} }
/** 专项工单 */ /** 专项工单 */
public getOrders(params: { public getOrders(
params: {
productCode?: GeneralOrderDirection; productCode?: GeneralOrderDirection;
index: number; index: number;
size?: number; size?: number;
},
}, isHrs = false) { isHrs = false
) {
const list = this.getSdk() const list = this.getSdk()
.model(this.generalOrder) .model(this.generalOrder)
.list(isHrs ? "hroOrgOrderList" : "userOrderList"); .list(isHrs ? "hroOrgOrderList" : "userOrderList");
if (params.productCode) { if (params.productCode) {
list.addPrefilter({ 'ProductId#product.Code': params.productCode }); list.addPrefilter({ "ProductId#product.Code": params.productCode });
} }
return list return list
.query({ item_size: params.size || 100, pageIndex: params.index }) .query({ item_size: params.size || 100, pageIndex: params.index })
...@@ -99,7 +103,7 @@ class OrderService { ...@@ -99,7 +103,7 @@ class OrderService {
.model(this.generalOrder) .model(this.generalOrder)
.list("hroOrgDoingOrderList"); .list("hroOrgDoingOrderList");
if (params.productCode) { if (params.productCode) {
list.addPrefilter({ 'ProductId#product.Code': params.productCode }); list.addPrefilter({ "ProductId#product.Code": params.productCode });
} }
return list return list
.query({ item_size: params.size || 100, pageIndex: params.index }) .query({ item_size: params.size || 100, pageIndex: params.index })
...@@ -207,13 +211,47 @@ class OrderService { ...@@ -207,13 +211,47 @@ class OrderService {
} }
public sendPayAccountInfo(params: { send: string }) { public sendPayAccountInfo(params: { send: string }) {
return this.getSdk().domainService("hro_spview", "OrderSetting", "sendPayAccountInfo") return this.getSdk()
.request("get", { params }) .domainService("hro_spview", "OrderSetting", "sendPayAccountInfo")
.request("get", { params });
}
public sendPayAccountInfoForAgent(params: {
send: string;
userOrderPaymentId: number;
}) {
return this.getSdk()
.domainService(
"hro_spview",
"OrderSetting",
"sendPayAccountInfoForAgent"
)
.request("get", { params });
} }
public sendPayAccountInfoForAgent(params: { send: string; userOrderPaymentId: number }) { public getComments(order: number | string) {
return this.getSdk().domainService("hro_spview", "OrderSetting", "sendPayAccountInfoForAgent") return this.getSdk()
.request("get", { params }) .model(orderService.commentModel)
.list("system_remark")
.addPrefilter({ associate_id: order })
.query({ pageIndex: 1, item_size: 100 })
.then((r) => {
if (r && r.pageData && r.pageData.rows) {
const items = this.handler.buildRows<OrderComment>(
r.pageData.rows,
{
id: "",
time: "create_time",
attachment: "attachments_label",
user: "dealer_name",
content: "",
}
);
return items;
}
return [];
});
} }
} }
......
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