UNPKG

flexbiz-server

Version:

Flexible Server

5 lines (4 loc) 1.67 kB
const controller=require("../../controllers/controllerRPT"),{createSocaiTC,createSokhoTC}=require("../../libs/utils"),_Notification=global.getModel("notification"),moment=require("moment"); module.exports=function($router$$){new controller($router$$,"capnhatsocaitc",async function($req$$,$callback$$){const $condition$$=$req$$.query;if(!$condition$$.tu_ngay||!$condition$$.den_ngay)return $callback$$("B\u00e1o c\u00e1o n\u00e0y c\u1ea7n c\u00e1c tham s\u1ed1 sau:tu_ngay,den_ngay");const $email$$=$req$$.user.email;try{let $sc$$=await createSocaiTC($condition$$.id_app,$condition$$.tu_ngay,$condition$$.den_ngay),$sk$$=await createSokhoTC($condition$$.id_app,$condition$$.tu_ngay,$condition$$.den_ngay), $message$$=`Ch\u01b0\u01a1ng tr\u00ecnh \u0111\u00e3 c\u1eadp nh\u1eadt s\u1ed5 s\u00e1ch t\u1eeb ng\u00e0y ${moment($condition$$.tu_ngay).format("DD/MM/YYYY")} \u0111\u1ebfn ng\u00e0y ${moment($condition$$.den_ngay).format("DD/MM/YYYY")}`;_Notification.createNotification($email$$,$email$$,$message$$,$message$$,null,{id_app:$condition$$.id_app},!0,$req$$.access_token,!0);$callback$$(null,{sc:$sc$$,sk:$sk$$})}catch($error$$){_Notification.createNotification($email$$,$email$$,$error$$.message||$error$$, $error$$.message||$error$$,null,{id_app:$condition$$.id_app},!0,$req$$.access_token,!0),$callback$$({error:$error$$.message||$error$$.error||$error$$})}},{cache:!1,timeout:18E6,waiting_message:"Ch\u01b0\u01a1ng tr\u00ecnh \u0111ang th\u1ef1c hi\u1ec7n. B\u1ea1n c\u00f3 th\u1ec3 chuy\u1ec3n sang trang kh\u00e1c \u0111\u1ec3 l\u00e0m vi\u1ec7c. Khi ch\u01b0\u01a1ng tr\u00ecnh th\u1ef1c hi\u1ec7n xong s\u1ebd g\u1eedi th\u00f4ng b\u00e1o cho b\u1ea1n."})};