20261008
This commit is contained in:
@@ -0,0 +1,100 @@
|
||||
'use strict';
|
||||
const dayjs = require("dayjs");
|
||||
var isBetween = require('dayjs/plugin/isBetween')
|
||||
dayjs.extend(isBetween)
|
||||
|
||||
module.exports = {
|
||||
/**
|
||||
* XXXnameXXX
|
||||
* @url admin/old/sys/changeField 前端调用的url参数地址
|
||||
* data 请求参数
|
||||
* @param {String} params1 参数1
|
||||
*/
|
||||
main: async (event) => {
|
||||
let {data = {}, userInfo, util, filterResponse, originalParam} = event;
|
||||
let {customUtil, uniID, config, pubFun, vk, db, _} = util;
|
||||
let {uid} = data;
|
||||
let res = {code: 0, msg: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
const dataJson = {}
|
||||
dataJson[data.field] = data.value
|
||||
if (data.field === 'showInAdmin') {
|
||||
dataJson['isShow'] = 0
|
||||
dataJson['status'] = 1
|
||||
} else if (data.field === 'isShow' && data.value === 1) {
|
||||
const sheet = await vk.baseDao.findByWhereJson({
|
||||
dbName: "jjx-process-sheet",
|
||||
whereJson: {
|
||||
_id: data.id
|
||||
},
|
||||
})
|
||||
|
||||
const messageUserList = await vk.baseDao.select({
|
||||
dbName: "jjx-message-config",
|
||||
whereJson: {
|
||||
process: true
|
||||
}
|
||||
})
|
||||
const messageList = []
|
||||
for (let i = 0; i < messageUserList.rows.length; i++) {
|
||||
if (messageUserList.rows[i].uid !== sheet.uid) {
|
||||
const config = messageUserList.rows[i]
|
||||
const date = dayjs().format("YYYY-MM-DD")
|
||||
// if (config.doNotDisturbRange && config.doNotDisturbRange[0]) {
|
||||
// const doNotDisturbRangeStart = dayjs(config.doNotDisturbRange[0]).format("HH:mm")
|
||||
// const doNotDisturbRangeEnd = dayjs(config.doNotDisturbRange[1]).format("HH:mm")
|
||||
// if (dayjs().isBetween(dayjs(`${date} ${doNotDisturbRangeStart}`), dayjs(`${date} ${doNotDisturbRangeEnd}`)))
|
||||
// continue
|
||||
// }
|
||||
if (config.doNotDisturbStart && config.doNotDisturbStart.length) {
|
||||
const doNotDisturbRangeStart = dayjs(`${date} ${config.doNotDisturbStart[0]}:${config.doNotDisturbStart[1]}`).format("HH:mm")
|
||||
const doNotDisturbRangeEnd = dayjs(`${date} ${config.doNotDisturbEnd[0]}:${config.doNotDisturbEnd[1]}`).format("HH:mm")
|
||||
if (dayjs().isBetween(dayjs(`${date} ${doNotDisturbRangeStart}`), dayjs(`${date} ${doNotDisturbRangeEnd}`)))
|
||||
continue
|
||||
}
|
||||
let inAddress = false
|
||||
if (config.addressList && config.addressList.length > 0) {
|
||||
for (let j = 0; j < config.addressList.length; j++) {
|
||||
if (config.addressList[j].province.code === sheet.addressRegion.province.code) {
|
||||
if (config.addressList[j].city === null) inAddress = true
|
||||
else if (config.addressList[j].city.code === sheet.addressRegion.city.code) {
|
||||
if (config.addressList[j].area === null) inAddress = true
|
||||
else if (config.addressList[j].area.code === sheet.addressRegion.area.code) {
|
||||
inAddress = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else inAddress = true
|
||||
if (!inAddress) continue
|
||||
if (!config.tradeSelf && sheet.tradeMethod === 0) continue
|
||||
if (!config.tradePlatform && sheet.tradeMethod === 1) continue
|
||||
messageList.push({
|
||||
uid: messageUserList.rows[i].uid,
|
||||
title: `加工:${sheet.title}`,
|
||||
content: `新的加工信息发布,赶紧去看看吧`,
|
||||
type: 'process',
|
||||
hasRead: false,
|
||||
pk: res.id
|
||||
})
|
||||
await pubFun.sendNotifySms(messageUserList.rows[i].uid, 'SMS_474440033')
|
||||
}
|
||||
}
|
||||
if (messageList.length > 0) {
|
||||
await vk.baseDao.adds({
|
||||
dbName: "jjx-message",
|
||||
dataJson: messageList
|
||||
});
|
||||
}
|
||||
}
|
||||
await vk.baseDao.updateById({
|
||||
dbName: "jjx-process-sheet",
|
||||
id: data.id,
|
||||
dataJson
|
||||
});
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user