UNPKG

flexbiz-server

Version:

Flexible Server

16 lines (15 loc) 6.66 kB
'use strict';const moment=require("moment"),socaitmpSchema=new Schema({id_app:{type:String,required:!0,maxlength:1024},ma_dvcs:{type:String,required:!0,maxlength:1024},id_ct:{type:String,required:!0,maxlength:1024},ma_ct:{type:String,required:!0,uppercase:!0,maxlength:32,trim:!0},ma_gd:{type:String,default:"0",maxlength:32,trim:!0},ngay_ct:{type:Date,required:!0},so_ct:{type:String,required:!0,uppercase:!0,maxlength:32,trim:!0},ngay_hd:{type:Date},so_hd:{type:String,uppercase:!0,maxlength:32,trim:!0}, tk_no:{type:String,required:!0,uppercase:!0,maxlength:32,trim:!0},tk_co:{type:String,required:!0,uppercase:!0,maxlength:32,trim:!0},ma_kh_no:{type:String,uppercase:!0,default:"",maxlength:32,trim:!0},ma_kh_co:{type:String,uppercase:!0,default:"",maxlength:32,trim:!0},ma_nt:{type:String,default:"VND",required:!0,uppercase:!0,maxlength:32,trim:!0},ty_gia:{type:Number,default:1},tien_nt:{type:Number,default:0},tien:{type:Number,default:0},dien_giai:{type:String,default:"",maxlength:1024},ong_ba:{type:String, default:"",maxlength:1024},ma_kho:{type:String,default:"",uppercase:!0,maxlength:32,trim:!0},ma_bp:{type:String,default:"",uppercase:!0,maxlength:32,trim:!0},ma_phi:{type:String,default:"",uppercase:!0,maxlength:32,trim:!0},ma_hd:{type:String,default:"",uppercase:!0,maxlength:32,trim:!0},ma_dt:{type:String,default:"",uppercase:!0,maxlength:32,trim:!0},ma_nv:{type:String,default:"",uppercase:!0,maxlength:32,trim:!0},ma_lo:{type:String,default:"",uppercase:!0,maxlength:32,trim:!0},han_sd:{type:Date}, ma_tt1:{type:String,default:"",uppercase:!0,maxlength:32,trim:!0},ma_tt2:{type:String,default:"",uppercase:!0,maxlength:32,trim:!0},ma_tt3:{type:String,default:"",uppercase:!0,maxlength:32,trim:!0},ma_ca:{type:String,uppercase:!0,maxlength:32,trim:!0},ma_cp:{type:String,default:"",uppercase:!0,maxlength:32,trim:!0},ma_sp:{type:String,default:"",uppercase:!0,maxlength:1024,trim:!0},ma_vt:{type:String,default:"",uppercase:!0,maxlength:1024,trim:!0},ma_dvt_sp:{type:String,maxlength:32,trim:!0},ma_tt1_sp:{type:String, default:"",uppercase:!0,maxlength:32,trim:!0},ma_tt2_sp:{type:String,default:"",uppercase:!0,maxlength:32,trim:!0},ma_tt3_sp:{type:String,default:"",uppercase:!0,maxlength:32,trim:!0},ma_cum_chi_tiet:{type:String,uppercase:!0,default:"",maxlength:32,trim:!0},ten_cum_chi_tiet:{type:String,default:"",maxlength:1024},ma_cong_doan:{type:String,uppercase:!0,default:"",maxlength:32,trim:!0},id_lenhsx:{type:String,maxlength:1024},id_link:String,ma_ct_link:String,so_ct_link:String,trang_thai:{type:String, maxlength:32},nh_dk:{type:Number,default:0},id_kbbtpb:{type:String,maxlength:1024},exfields:Schema.Types.Mixed,exfields_detail:Schema.Types.Mixed,flag:{type:String,maxlength:1024},gio:Number,ngay:Number,thang:Number,quy:Number,nam:Number,ma_kenh:String,ma_td1:Schema.Types.Mixed,ma_td2:Schema.Types.Mixed,ma_td3:Schema.Types.Mixed,ma_td4:Schema.Types.Mixed,ma_td5:Schema.Types.Mixed,ma_td6:Schema.Types.Mixed,ma_td7:Schema.Types.Mixed,ma_td8:Schema.Types.Mixed,ma_td9:Schema.Types.Mixed,pt_thanh_toan:String, pt_thanh_toan2:String,status:{type:Boolean,default:!0},date_created:{type:Date,default:Date.now},date_updated:{type:Date,default:Date.now},user_created:{type:String,default:""},user_updated:{type:String,default:""}},{toJSON:{virtuals:!0}}); socaitmpSchema.pre("save",function($next$$){this.tien="VND"==this.ma_nt?this.tien_nt=Math.roundBy(this.tien_nt,0):Math.roundBy(this.tien,0);let $ngay_ct$$=moment(this.ngay_ct);this.gio=$ngay_ct$$.get("hours");this.ngay=$ngay_ct$$.get("dates");this.quy=$ngay_ct$$.get("quarters");this.thang=$ngay_ct$$.get("months")+1;this.nam=$ngay_ct$$.get("year");$next$$()});const model=mongoose.models.socaitmp||mongoose.model("socaitmp",socaitmpSchema); (global.configs||{}).createIndexes&&(socaitmpSchema.index({id_app:1}),socaitmpSchema.index({ma_dvcs:1}),socaitmpSchema.index({so_ct:1}),socaitmpSchema.index({ngay_ct:1}),socaitmpSchema.index({so_ct:1,ngay_ct:1}),socaitmpSchema.index({gio:1}),socaitmpSchema.index({ngay:1}),socaitmpSchema.index({thang:1}),socaitmpSchema.index({quy:1}),socaitmpSchema.index({nam:-1}),socaitmpSchema.index({ma_ct:1}),socaitmpSchema.index({id_ct:1}),socaitmpSchema.index({tk_no:1}),socaitmpSchema.index({tk_co:1}),socaitmpSchema.index({ma_kh_no:1}), socaitmpSchema.index({ma_kh_co:1}),socaitmpSchema.index({ma_nt:1}),socaitmpSchema.index({ma_bp:1}),socaitmpSchema.index({ma_phi:1}),socaitmpSchema.index({ma_hd:1}),socaitmpSchema.index({ma_dt:1}),socaitmpSchema.index({ma_nv:1}),socaitmpSchema.index({ma_sp:1}),socaitmpSchema.index({ma_vt:1}),socaitmpSchema.index({ma_kenh:1}),socaitmpSchema.index({ma_td1:1}),socaitmpSchema.index({ma_td2:1}),socaitmpSchema.index({ma_td3:1}),socaitmpSchema.index({ma_td4:1}),socaitmpSchema.index({ma_td5:1}),socaitmpSchema.index({ma_td6:1}), socaitmpSchema.index({ma_td7:1}),socaitmpSchema.index({ma_td8:1}),socaitmpSchema.index({ma_td9:1}),socaitmpSchema.index({ma_lo:1}),socaitmpSchema.index({han_sd:-1}),socaitmpSchema.index({ma_tt1:1}),socaitmpSchema.index({ma_tt2:1}),socaitmpSchema.index({ma_tt3:1}),socaitmpSchema.index({id_lenhsx:1}),socaitmpSchema.index({flag:1}),socaitmpSchema.index({id_link:1}),socaitmpSchema.index({id_app:1,id_ct:1,so_ct:-1,ngay_ct:-1,ma_kh_no:1,ma_kh_co:1,tk_no:1,tk_co:1}),socaitmpSchema.index({dien_giai:"text"}), socaitmpSchema.index({status:1}),socaitmpSchema.index({user_created:1,visible_to:1,visible_to_users:1}),socaitmpSchema.index({trang_thai:1}),model.on("index",async function($err$$){$err$$?console.error("socaitmp index error",$err$$):console.info("socaitmp indexing complete")})); model.getArise=async($query$$,$options$$={fields:void 0})=>{let $condition$$={ngay_ct:{$gte:$query$$.tu_ngay,$lte:$query$$.den_ngay},id_app:$query$$.id_app};$query$$.ma_dvcs&&($condition$$.ma_dvcs=$query$$.ma_dvcs);$query$$.ma_bp&&($condition$$.ma_bp=$query$$.ma_bp);$query$$.ma_hd&&($condition$$.ma_hd=$query$$.ma_hd);$query$$.ma_dt&&($condition$$.ma_dt=$query$$.ma_dt);$query$$.ma_sp&&($condition$$.ma_sp=$query$$.ma_sp);$query$$.ma_nv&&($condition$$.ma_nv=$query$$.ma_nv);$query$$.ma_phi&&($condition$$.ma_phi= $query$$.ma_phi);$query$$.ma_kho&&($condition$$.ma_kho=$query$$.ma_kho);if($query$$.tk_no&&Array.isArray($query$$.tk_no)){var $tk_co_tk_no$$=$query$$.tk_no.reg();$condition$$.tk_no=$query$$.giam_tru_no?{$not:new RegExp($tk_co_tk_no$$)}:{$regex:$tk_co_tk_no$$,$options:"i"}}$query$$.tk_co&&Array.isArray($query$$.tk_co)&&($tk_co_tk_no$$=$query$$.tk_co.reg(),$condition$$.tk_co=$query$$.giam_tru_co&&$tk_co_tk_no$$?{$not:new RegExp($tk_co_tk_no$$)}:{$regex:$tk_co_tk_no$$,$options:"i"});return await model.find($condition$$, $options$$.fields).lean()};module.exports=model;