|
|
@@ -636,11 +636,11 @@ module.exports = class extends Base { |
|
|
* GET /api/mp/regenerateSign |
|
|
* GET /api/mp/regenerateSign |
|
|
*/ |
|
|
*/ |
|
|
async regenerateSignAction() { |
|
|
async regenerateSignAction() { |
|
|
return false; |
|
|
|
|
|
|
|
|
return false; // 先关闭接口,确认后再删除这行 |
|
|
try { |
|
|
try { |
|
|
const patients = await this.model('patient') |
|
|
const patients = await this.model('patient') |
|
|
.field('id, name, sign_promise') |
|
|
.field('id, name, sign_promise') |
|
|
.where({ is_deleted: 0, sign_promise: ['!=', ''] }) |
|
|
|
|
|
|
|
|
.where({ is_deleted: 0, sign_promise: ['!=', ''],id: ['in', [61,62]] }) |
|
|
.select(); |
|
|
.select(); |
|
|
|
|
|
|
|
|
if (!patients.length) return this.json({ code: 1, msg: '没有需要处理的患者' }); |
|
|
if (!patients.length) return this.json({ code: 1, msg: '没有需要处理的患者' }); |
|
|
@@ -681,6 +681,83 @@ module.exports = class extends Base { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* POST /api/mp/regenerateSignByUrl |
|
|
|
|
|
* Temp no-login endpoint. Rebuild sign_income/sign_privacy/sign_promise with a fresh signature image. |
|
|
|
|
|
* Body: { id, url } |
|
|
|
|
|
*/ |
|
|
|
|
|
async regenerateSignByUrlAction() { |
|
|
|
|
|
return false; // 先关闭接口,确认后再删除这行 |
|
|
|
|
|
const id = parseInt(this.post('id') || this.get('id'), 10); |
|
|
|
|
|
const signImageUrl = this.post('url') || this.post('signImageUrl') || this.get('url') || this.get('signImageUrl'); |
|
|
|
|
|
|
|
|
|
|
|
if (![61, 62].includes(id)) { |
|
|
|
|
|
return this.json({ code: 1, msg: '只允许处理患者 61、62' }); |
|
|
|
|
|
} |
|
|
|
|
|
if (!signImageUrl || !/^https?:\/\//i.test(signImageUrl)) { |
|
|
|
|
|
return this.json({ code: 1, msg: 'url 参数错误' }); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
const patient = await this.model('patient') |
|
|
|
|
|
.field('id,name,id_card,sign_income,sign_privacy,sign_promise,income_amount,create_time,update_time') |
|
|
|
|
|
.where({ id, is_deleted: 0 }) |
|
|
|
|
|
.find(); |
|
|
|
|
|
|
|
|
|
|
|
if (think.isEmpty(patient)) { |
|
|
|
|
|
return this.json({ code: 1, msg: '患者不存在' }); |
|
|
|
|
|
} |
|
|
|
|
|
if (!patient.name || !patient.id_card) { |
|
|
|
|
|
return this.json({ code: 1, msg: '患者姓名或身份证缺失' }); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const screenshotService = this.service('screenshot'); |
|
|
|
|
|
const signTime = patient.update_time || patient.create_time || think.datetime(new Date()); |
|
|
|
|
|
const tasks = [ |
|
|
|
|
|
{ field: 'sign_income', key: 'sign_income', amount: patient.income_amount }, |
|
|
|
|
|
{ field: 'sign_privacy', key: 'sign_privacy' }, |
|
|
|
|
|
{ field: 'sign_promise', key: 'sign_promise' } |
|
|
|
|
|
]; |
|
|
|
|
|
const updates = {}; |
|
|
|
|
|
const results = []; |
|
|
|
|
|
|
|
|
|
|
|
for (const item of tasks) { |
|
|
|
|
|
const doc = await this.model('content').getByKey(item.key); |
|
|
|
|
|
if (think.isEmpty(doc)) { |
|
|
|
|
|
throw new Error(`${item.key} 协议内容未配置`); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const newUrl = await screenshotService.generate({ |
|
|
|
|
|
title: doc.title, |
|
|
|
|
|
content: doc.content, |
|
|
|
|
|
signImageUrl, |
|
|
|
|
|
signerName: patient.name, |
|
|
|
|
|
signerIdCard: patient.id_card, |
|
|
|
|
|
signTime, |
|
|
|
|
|
amount: item.amount || null |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
updates[item.field] = newUrl; |
|
|
|
|
|
results.push({ |
|
|
|
|
|
field: item.field, |
|
|
|
|
|
oldUrl: patient[item.field] || '', |
|
|
|
|
|
newUrl |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
await this.model('patient').where({ id }).update(updates); |
|
|
|
|
|
|
|
|
|
|
|
return this.json({ |
|
|
|
|
|
code: 0, |
|
|
|
|
|
data: { id, results }, |
|
|
|
|
|
msg: '重生成成功' |
|
|
|
|
|
}); |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
think.logger.error('regenerateSignByUrl error:', error); |
|
|
|
|
|
return this.json({ code: 1, msg: '重生成失败: ' + error.message }); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// @private |
|
|
// @private |
|
|
async _verifyIdCard(name, idCard) { |
|
|
async _verifyIdCard(name, idCard) { |
|
|
const faceidConfig = require('../config/faceid.js'); |
|
|
const faceidConfig = require('../config/faceid.js'); |
|
|
|