flexbiz-server 12.7.1 → 12.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -5
- package/server/app.js +23 -348
- package/server/cluster.js +1 -5
- package/server/models/account.js +7 -0
- package/server/models/actionLog.js +2 -0
- package/server/models/afflink.js +2 -0
- package/server/models/aimemory.js +1 -0
- package/server/models/app.js +16 -0
- package/server/models/approve.js +95 -0
- package/server/models/assabcihandler.js +35 -0
- package/server/models/assbank.js +19 -0
- package/server/models/assbooking.js +4 -0
- package/server/models/assbuy.js +3 -0
- package/server/models/asscashwithdraw.js +4 -0
- package/server/models/assfindhash.js +2 -0
- package/server/models/assinvestment.js +13 -0
- package/server/models/assissue.js +2 -0
- package/server/models/asskey.js +15 -0
- package/server/models/assneedtobuy.js +6 -0
- package/server/models/assperiod.js +7 -0
- package/server/models/assproduct.js +13 -0
- package/server/models/assprofitsharing.js +4 -0
- package/server/models/assreceiver.js +2 -0
- package/server/models/assrequest.js +10 -0
- package/server/models/asssell.js +7 -0
- package/server/models/asstransaction.js +3 -0
- package/server/models/asstransfer.js +4 -0
- package/server/models/assuser_identity.js +4 -0
- package/server/models/asswithdraw.js +4 -0
- package/server/models/attend.js +2 -0
- package/server/models/banggiaban.js +8 -0
- package/server/models/bangtinhluong.js +6 -0
- package/server/models/base.js +1 -0
- package/server/models/bg1.js +9 -0
- package/server/models/bg2.js +10 -0
- package/server/models/cache.js +3 -0
- package/server/models/cacheDataReport.js +2 -0
- package/server/models/cacheSessionReport.js +5 -0
- package/server/models/calllog.js +4 -0
- package/server/models/cart.js +5 -0
- package/server/models/cddiem.js +2 -0
- package/server/models/cddt.js +3 -0
- package/server/models/cdkh.js +5 -0
- package/server/models/cdkhtheongay.js +5 -0
- package/server/models/cdnphep.js +2 -0
- package/server/models/cdtk.js +3 -0
- package/server/models/cdtktheongay.js +3 -0
- package/server/models/cdvt.js +5 -0
- package/server/models/cdvtnpp.js +6 -0
- package/server/models/cdvttheongay.js +5 -0
- package/server/models/chamcong.js +7 -0
- package/server/models/chat_message.js +2 -0
- package/server/models/chat_session.js +2 -0
- package/server/models/checkin.js +4 -0
- package/server/models/checkinactivity.js +3 -0
- package/server/models/checkinkpi.js +4 -0
- package/server/models/checkinlocation.js +2 -0
- package/server/models/chitietluongds.js +12 -0
- package/server/models/chitieukpi.js +3 -0
- package/server/models/chudethaoluan.js +3 -0
- package/server/models/ckgtluong.js +2 -0
- package/server/models/colleague.js +2 -0
- package/server/models/comment.js +4 -0
- package/server/models/congdoansx.js +4 -0
- package/server/models/congtacvien.js +4 -0
- package/server/models/congthuctinhgiaban.js +8 -0
- package/server/models/consultant.js +4 -0
- package/server/models/contract.js +6 -0
- package/server/models/counter.js +2 -0
- package/server/models/csluongtheods.js +3 -0
- package/server/models/csphucap.js +2 -0
- package/server/models/ctds.js +5 -0
- package/server/models/ctds2.js +7 -0
- package/server/models/currency.js +3 -0
- package/server/models/custom_report.js +1 -0
- package/server/models/customer.js +31 -0
- package/server/models/customer_care.js +2 -0
- package/server/models/data_list_config.js +7 -0
- package/server/models/databanle.js +8 -0
- package/server/models/datlich.js +4 -0
- package/server/models/deal.js +2 -0
- package/server/models/dh2.js +20 -0
- package/server/models/diagram.js +2 -0
- package/server/models/dinhmucsx.js +8 -0
- package/server/models/dkhoc.js +6 -0
- package/server/models/dknphep.js +2 -0
- package/server/models/dmban.js +4 -0
- package/server/models/dmbp.js +12 -0
- package/server/models/dmca.js +2 -0
- package/server/models/dmchietkhau.js +8 -0
- package/server/models/dmchietkhauhd.js +19 -0
- package/server/models/dmchinhanh.js +2 -0
- package/server/models/dmcpmh.js +2 -0
- package/server/models/dmdiemthuong.js +3 -0
- package/server/models/dmdoi.js +4 -0
- package/server/models/dmdoituongdanhgia.js +2 -0
- package/server/models/dmdt.js +8 -0
- package/server/models/dmdvt.js +3 -0
- package/server/models/dmgiaban.js +9 -0
- package/server/models/dmgiamua.js +5 -0
- package/server/models/dmgiathitruong.js +5 -0
- package/server/models/dmgiathitruong_ngay.js +2 -0
- package/server/models/dmgiathitruong_theodoi.js +2 -0
- package/server/models/dmhoahonghd.js +8 -0
- package/server/models/dmhoahongnpp.js +8 -0
- package/server/models/dmkc.js +3 -0
- package/server/models/dmkho.js +7 -0
- package/server/models/dmkhuyenmai.js +9 -0
- package/server/models/dmkhuyenmaihd.js +11 -0
- package/server/models/dmletet.js +2 -0
- package/server/models/dmlo.js +4 -0
- package/server/models/dmloaicong.js +4 -0
- package/server/models/dmloaitask.js +2 -0
- package/server/models/dmloaits.js +2 -0
- package/server/models/dmnckkm.js +4 -0
- package/server/models/dmnghiepvu.js +4 -0
- package/server/models/dmnguonvon.js +2 -0
- package/server/models/dmnhnv.js +4 -0
- package/server/models/dmnv.js +17 -0
- package/server/models/dmnvt.js +10 -0
- package/server/models/dmphi.js +3 -0
- package/server/models/dmqct.js +3 -0
- package/server/models/dmqddvt.js +3 -0
- package/server/models/dmtanggiamts.js +3 -0
- package/server/models/dmto.js +4 -0
- package/server/models/dmtt.js +6 -0
- package/server/models/dmvt.js +17 -0
- package/server/models/dmyt.js +4 -0
- package/server/models/dn0.js +13 -0
- package/server/models/dnm.js +11 -0
- package/server/models/dokho.js +2 -0
- package/server/models/domain.js +2 -0
- package/server/models/dvcs.js +3 -0
- package/server/models/ecomcategories.js +3 -0
- package/server/models/ecomcategories_cty.js +3 -0
- package/server/models/ecomproductlines.js +2 -0
- package/server/models/ecompromotion_flashsales.js +2 -0
- package/server/models/ecompromotion_freeships.js +2 -0
- package/server/models/email.js +2 -0
- package/server/models/endpoint.js +1 -0
- package/server/models/events.js +3 -0
- package/server/models/evoucher.js +5 -0
- package/server/models/experiencejourney.js +2 -0
- package/server/models/experiencejourneydata.js +4 -0
- package/server/models/experiencejourneypersona.js +3 -0
- package/server/models/experiencejourneystage.js +2 -0
- package/server/models/exportexceltemplate.js +2 -0
- package/server/models/fbconversation.js +15 -0
- package/server/models/fbmessage.js +2 -0
- package/server/models/fbpage.js +2 -0
- package/server/models/fbpost.js +2 -0
- package/server/models/fieldright.js +2 -0
- package/server/models/fifo_dk.js +2 -0
- package/server/models/fifo_lot.js +3 -0
- package/server/models/fifo_trace.js +4 -0
- package/server/models/file.js +4 -0
- package/server/models/filechunk.js +2 -0
- package/server/models/financialroadmap.js +3 -0
- package/server/models/flow.js +2 -0
- package/server/models/flowdata.js +3 -0
- package/server/models/flowpending.js +2 -0
- package/server/models/folder.js +4 -0
- package/server/models/follow.js +2 -0
- package/server/models/forminfo.js +5 -0
- package/server/models/giaoca.js +4 -0
- package/server/models/giatb.js +3 -0
- package/server/models/group.js +9 -0
- package/server/models/gt_ctgt.js +4 -0
- package/server/models/gt_hspb.js +3 -0
- package/server/models/gt_sltk.js +3 -0
- package/server/models/gt_thcppstk.js +3 -0
- package/server/models/hanmucton.js +4 -0
- package/server/models/hd1.js +11 -0
- package/server/models/hd2.js +26 -0
- package/server/models/hd3.js +17 -0
- package/server/models/hd4.js +13 -0
- package/server/models/hd7.js +17 -0
- package/server/models/hd8.js +12 -0
- package/server/models/hde.js +11 -0
- package/server/models/hmcn.js +3 -0
- package/server/models/hmcnct.js +2 -0
- package/server/models/hspbts.js +4 -0
- package/server/models/htl.js +13 -0
- package/server/models/importexceltemplate.js +2 -0
- package/server/models/introducebonus.js +4 -0
- package/server/models/introducecode.js +3 -0
- package/server/models/introducer.js +4 -0
- package/server/models/kbbtpb.js +7 -0
- package/server/models/kbmPttct.js +4 -0
- package/server/models/kbmTkgtgt.js +5 -0
- package/server/models/kbm_bcdkt_old.js +4 -0
- package/server/models/kbm_kqhdkd_old.js +3 -0
- package/server/models/kbm_lcttgt_old.js +5 -0
- package/server/models/kbm_lctttt_old.js +4 -0
- package/server/models/kbm_pttct_old.js +4 -0
- package/server/models/kbm_tkgtgt_old.js +5 -0
- package/server/models/kbmbcdkt.js +4 -0
- package/server/models/kbmbcqt.js +4 -0
- package/server/models/kbmkqhdkd.js +3 -0
- package/server/models/kbmlcttgt.js +6 -0
- package/server/models/kbmlctttt.js +4 -0
- package/server/models/kbmtmbctc.js +4 -0
- package/server/models/kehoachdtcp.js +3 -0
- package/server/models/kehoachmh.js +8 -0
- package/server/models/keyresult.js +7 -0
- package/server/models/khunghangthanhvien.js +3 -0
- package/server/models/label.js +2 -0
- package/server/models/labelinfo.js +2 -0
- package/server/models/lenhcapphat.js +8 -0
- package/server/models/lenhsx.js +8 -0
- package/server/models/lienhe.js +4 -0
- package/server/models/like_module.js +2 -0
- package/server/models/link.js +2 -0
- package/server/models/listinfo.js +1365 -0
- package/server/models/loaidiem.js +2 -0
- package/server/models/lock.js +2 -0
- package/server/models/log.js +8 -0
- package/server/models/mailaccount.js +3 -0
- package/server/models/mailgroup.js +3 -0
- package/server/models/mailreceived.js +2 -0
- package/server/models/mailsent.js +2 -0
- package/server/models/mailtemplate.js +2 -0
- package/server/models/maudanhgia.js +2 -0
- package/server/models/menuinfo.js +2 -0
- package/server/models/message.js +8 -0
- package/server/models/message2.js +4 -0
- package/server/models/message2setting.js +3 -0
- package/server/models/moduleinfo.js +4 -0
- package/server/models/momo.js +18 -0
- package/server/models/news.js +3 -0
- package/server/models/newsfeed.js +4 -0
- package/server/models/note.js +2 -0
- package/server/models/notification.js +8 -0
- package/server/models/okr.js +4 -0
- package/server/models/okrdiagram.js +3 -0
- package/server/models/onepay.js +24 -0
- package/server/models/opportunity.js +4 -0
- package/server/models/options.js +2 -0
- package/server/models/originimportid.js +1 -0
- package/server/models/otp.js +1 -0
- package/server/models/parameter.js +2 -0
- package/server/models/participant.js +21 -0
- package/server/models/partner.js +1 -0
- package/server/models/payload.js +1 -0
- package/server/models/pbl.js +16 -0
- package/server/models/pc0.js +13 -0
- package/server/models/pc1.js +14 -0
- package/server/models/pc2.js +13 -0
- package/server/models/pc3.js +13 -0
- package/server/models/pc5.js +8 -0
- package/server/models/pc6.js +14 -0
- package/server/models/pcl.js +6 -0
- package/server/models/pdn.js +9 -0
- package/server/models/pdx.js +9 -0
- package/server/models/pgh.js +5 -0
- package/server/models/phieudanhgia.js +3 -0
- package/server/models/pht.js +8 -0
- package/server/models/phucap.js +4 -0
- package/server/models/pkc.js +6 -0
- package/server/models/pkh.js +6 -0
- package/server/models/pkk.js +10 -0
- package/server/models/pkt.js +12 -0
- package/server/models/pn1.js +18 -0
- package/server/models/pn2.js +12 -0
- package/server/models/pn3.js +13 -0
- package/server/models/pn5.js +14 -0
- package/server/models/pn6.js +14 -0
- package/server/models/pn9.js +17 -0
- package/server/models/pnc.js +9 -0
- package/server/models/pnh.js +11 -0
- package/server/models/pnk.js +10 -0
- package/server/models/po1.js +19 -0
- package/server/models/ppb.js +6 -0
- package/server/models/productcode.js +2 -0
- package/server/models/profile.js +4 -0
- package/server/models/pt1.js +12 -0
- package/server/models/pt5.js +8 -0
- package/server/models/ptl.js +5 -0
- package/server/models/ptthanhtoan.js +6 -0
- package/server/models/purchase_contract.js +17 -0
- package/server/models/pxc.js +9 -0
- package/server/models/pxh.js +11 -0
- package/server/models/pxk.js +9 -0
- package/server/models/qts.js +14 -0
- package/server/models/qts_dieuchinh.js +3 -0
- package/server/models/qts_dieuchuyen.js +4 -0
- package/server/models/quanhuyen.js +2 -0
- package/server/models/reason.js +2 -0
- package/server/models/receivedinvoice.js +2 -0
- package/server/models/reportinfo.js +5 -0
- package/server/models/right.js +4 -0
- package/server/models/rpt.js +2 -0
- package/server/models/rptform.js +3 -0
- package/server/models/rptobject.js +2 -0
- package/server/models/sale_contract.js +9 -0
- package/server/models/schedule.js +18 -0
- package/server/models/schedule_log.js +2 -0
- package/server/models/shipbook.js +12 -0
- package/server/models/shortcut.js +2 -0
- package/server/models/smsaccount.js +10 -0
- package/server/models/smssend.js +2 -0
- package/server/models/so1.js +22 -0
- package/server/models/so5.js +15 -0
- package/server/models/so9.js +19 -0
- package/server/models/socai.js +28 -0
- package/server/models/socainpp.js +18 -0
- package/server/models/socaitc.js +6 -0
- package/server/models/socaitmp.js +16 -0
- package/server/models/socaitt.js +4 -0
- package/server/models/sodiemthuong.js +4 -0
- package/server/models/sokho.js +27 -0
- package/server/models/sokhocapphat.js +18 -0
- package/server/models/sokhokhongton.js +19 -0
- package/server/models/sokhonpp.js +19 -0
- package/server/models/sokhotc.js +8 -0
- package/server/models/sokhott.js +18 -0
- package/server/models/sophanbokh.js +3 -0
- package/server/models/sosanxuat.js +5 -0
- package/server/models/sotinhkh.js +2 -0
- package/server/models/spdd_ck.js +3 -0
- package/server/models/spdd_dk.js +3 -0
- package/server/models/step.js +2 -0
- package/server/models/strategicdiagram.js +3 -0
- package/server/models/strategicgoal.js +4 -0
- package/server/models/strategickpi.js +6 -0
- package/server/models/strategicobjective.js +5 -0
- package/server/models/strategicplan.js +5 -0
- package/server/models/subscribe.js +2 -0
- package/server/models/support.js +2 -0
- package/server/models/synctime.js +2 -0
- package/server/models/sys_job_queue_book_keeping.js +2 -0
- package/server/models/sysconfig.js +2 -0
- package/server/models/sysgroup.js +2 -0
- package/server/models/tableinfo.js +3 -0
- package/server/models/task.js +9 -0
- package/server/models/tc.js +2 -0
- package/server/models/tdttco.js +9 -0
- package/server/models/tdttco_tt.js +5 -0
- package/server/models/tdttno.js +9 -0
- package/server/models/tdttno_tt.js +5 -0
- package/server/models/templaterpt.js +2 -0
- package/server/models/templatestore.js +3 -0
- package/server/models/templatevoucher.js +3 -0
- package/server/models/tinhthanh.js +2 -0
- package/server/models/tokens.js +3 -0
- package/server/models/tontucthoi.js +9 -0
- package/server/models/trangthai.js +4 -0
- package/server/models/trangthaiapp.js +4 -0
- package/server/models/transaction.js +16 -0
- package/server/models/trialinfo.js +2 -0
- package/server/models/user.js +40 -0
- package/server/models/usergroup.js +7 -0
- package/server/models/vanchuyen.js +12 -0
- package/server/models/vat.js +3 -0
- package/server/models/vatra.js +6 -0
- package/server/models/vatvao.js +6 -0
- package/server/models/versioninfo.js +2 -0
- package/server/models/vietqrbanks.js +2 -0
- package/server/models/vsocai.js +6 -0
- package/server/models/wallet.js +8 -0
- package/server/models/warranty.js +3 -0
- package/server/models/warrantyclaim.js +2 -0
- package/server/models/warrantypolicy.js +1 -0
- package/server/models/workflow.js +4 -0
- package/server/models/xaphuong.js +2 -0
- package/server/models/xhd.js +10 -0
- package/server/models/ytdd_ck.js +4 -0
- package/server/models/ytdd_dk.js +4 -0
- package/server/models/zalo.js +17 -0
- package/server/modules/lists/bg-cddiem.js +6 -0
- package/server/modules/lists/bg-cddt.js +7 -0
- package/server/modules/lists/bg-cdkh.js +11 -0
- package/server/modules/lists/bg-cdnphep.js +6 -0
- package/server/modules/lists/bg-cdtk.js +9 -0
- package/server/modules/lists/bg-cdvt.js +8 -0
- package/server/modules/lists/bg-cdvtnpp.js +8 -0
- package/server/modules/lists/bg-fifo_dk.js +8 -0
- package/server/modules/lists/ls-account.js +4 -0
- package/server/modules/lists/ls-afflink.js +3 -0
- package/server/modules/lists/ls-approve.js +5 -0
- package/server/modules/lists/ls-assabcihandler.js +3 -0
- package/server/modules/lists/ls-assbank.js +3 -0
- package/server/modules/lists/ls-assbooking.js +20 -0
- package/server/modules/lists/ls-assbuy.js +8 -0
- package/server/modules/lists/ls-asscashwithdraw.js +8 -0
- package/server/modules/lists/ls-assinvestment.js +31 -0
- package/server/modules/lists/ls-assissue.js +3 -0
- package/server/modules/lists/ls-asskey.js +41 -0
- package/server/modules/lists/ls-assneedtobuy.js +10 -0
- package/server/modules/lists/ls-assperiod.js +19 -0
- package/server/modules/lists/ls-assproduct.js +9 -0
- package/server/modules/lists/ls-assprofitsharing.js +8 -0
- package/server/modules/lists/ls-assreceiver.js +3 -0
- package/server/modules/lists/ls-assrequest.js +4 -0
- package/server/modules/lists/ls-asssell.js +13 -0
- package/server/modules/lists/ls-asstransaction.js +3 -0
- package/server/modules/lists/ls-asstransfer.js +3 -0
- package/server/modules/lists/ls-assuser_identity.js +1 -0
- package/server/modules/lists/ls-asswithdraw.js +12 -0
- package/server/modules/lists/ls-bangtinhluong.js +2 -0
- package/server/modules/lists/ls-calllog.js +4 -0
- package/server/modules/lists/ls-cart.js +14 -0
- package/server/modules/lists/ls-chamcong.js +3 -0
- package/server/modules/lists/ls-chat_session.js +5 -0
- package/server/modules/lists/ls-checkin.js +24 -0
- package/server/modules/lists/ls-checkinactivity.js +8 -0
- package/server/modules/lists/ls-checkinkpi.js +3 -0
- package/server/modules/lists/ls-checkinlocation.js +1 -0
- package/server/modules/lists/ls-chitietluongds.js +4 -0
- package/server/modules/lists/ls-chitieukpi.js +1 -0
- package/server/modules/lists/ls-chudethaoluan.js +1 -0
- package/server/modules/lists/ls-ckgtluong.js +1 -0
- package/server/modules/lists/ls-comment.js +9 -0
- package/server/modules/lists/ls-congdoansx.js +3 -0
- package/server/modules/lists/ls-congtacvien.js +5 -0
- package/server/modules/lists/ls-consultant.js +2 -0
- package/server/modules/lists/ls-contract.js +7 -0
- package/server/modules/lists/ls-csluongtheods.js +1 -0
- package/server/modules/lists/ls-csphucap.js +1 -0
- package/server/modules/lists/ls-ctds.js +4 -0
- package/server/modules/lists/ls-ctds2.js +4 -0
- package/server/modules/lists/ls-currency.js +1 -0
- package/server/modules/lists/ls-customer.js +22 -0
- package/server/modules/lists/ls-customer_care.js +1 -0
- package/server/modules/lists/ls-datlich.js +9 -0
- package/server/modules/lists/ls-dckhauhaots.js +3 -0
- package/server/modules/lists/ls-deal.js +3 -0
- package/server/modules/lists/ls-diagram.js +1 -0
- package/server/modules/lists/ls-dkhoc.js +6 -0
- package/server/modules/lists/ls-dknphep.js +1 -0
- package/server/modules/lists/ls-dmban.js +4 -0
- package/server/modules/lists/ls-dmbp.js +7 -0
- package/server/modules/lists/ls-dmca.js +1 -0
- package/server/modules/lists/ls-dmchietkhau.js +19 -0
- package/server/modules/lists/ls-dmchietkhauhd.js +4 -0
- package/server/modules/lists/ls-dmchinhanh.js +1 -0
- package/server/modules/lists/ls-dmchucvu.js +2 -0
- package/server/modules/lists/ls-dmcpmh.js +1 -0
- package/server/modules/lists/ls-dmdiemthuong.js +4 -0
- package/server/modules/lists/ls-dmdoi.js +4 -0
- package/server/modules/lists/ls-dmdoituongdanhgia.js +1 -0
- package/server/modules/lists/ls-dmdt.js +11 -0
- package/server/modules/lists/ls-dmdvt.js +2 -0
- package/server/modules/lists/ls-dmgiaban.js +4 -0
- package/server/modules/lists/ls-dmgiamua.js +4 -0
- package/server/modules/lists/ls-dmgiathitruong.js +15 -0
- package/server/modules/lists/ls-dmgiathitruong_ngay.js +2 -0
- package/server/modules/lists/ls-dmgiathitruong_theodoi.js +1 -0
- package/server/modules/lists/ls-dmhoahonghd.js +1 -0
- package/server/modules/lists/ls-dmhoahongnpp.js +1 -0
- package/server/modules/lists/ls-dmkc.js +3 -0
- package/server/modules/lists/ls-dmkho.js +7 -0
- package/server/modules/lists/ls-dmkhuyenmai.js +5 -0
- package/server/modules/lists/ls-dmkhuyenmaihd.js +3 -0
- package/server/modules/lists/ls-dmletet.js +1 -0
- package/server/modules/lists/ls-dmlo.js +1 -0
- package/server/modules/lists/ls-dmloaicong.js +1 -0
- package/server/modules/lists/ls-dmloaits.js +1 -0
- package/server/modules/lists/ls-dmnckkm.js +7 -0
- package/server/modules/lists/ls-dmnghiepvu.js +1 -0
- package/server/modules/lists/ls-dmnguonvon.js +1 -0
- package/server/modules/lists/ls-dmnhnv.js +6 -0
- package/server/modules/lists/ls-dmnhtask.js +5 -0
- package/server/modules/lists/ls-dmnkh.js +6 -0
- package/server/modules/lists/ls-dmntt.js +6 -0
- package/server/modules/lists/ls-dmnv.js +14 -0
- package/server/modules/lists/ls-dmnvt.js +7 -0
- package/server/modules/lists/ls-dmphi.js +6 -0
- package/server/modules/lists/ls-dmqct.js +2 -0
- package/server/modules/lists/ls-dmqddvt.js +3 -0
- package/server/modules/lists/ls-dmtanggiamts.js +1 -0
- package/server/modules/lists/ls-dmto.js +5 -0
- package/server/modules/lists/ls-dmtt.js +7 -0
- package/server/modules/lists/ls-dmvt.js +52 -0
- package/server/modules/lists/ls-dmyt.js +1 -0
- package/server/modules/lists/ls-dokho.js +1 -0
- package/server/modules/lists/ls-dvcs.js +1 -0
- package/server/modules/lists/ls-ecomcategories.js +5 -0
- package/server/modules/lists/ls-ecomcategories_cty.js +5 -0
- package/server/modules/lists/ls-email.js +4 -0
- package/server/modules/lists/ls-events.js +3 -0
- package/server/modules/lists/ls-evoucher.js +3 -0
- package/server/modules/lists/ls-experiencejourney.js +1 -0
- package/server/modules/lists/ls-experiencejourneydata.js +3 -0
- package/server/modules/lists/ls-experiencejourneypersona.js +4 -0
- package/server/modules/lists/ls-experiencejourneystage.js +1 -0
- package/server/modules/lists/ls-fbconversation.js +2 -0
- package/server/modules/lists/ls-fbmessage.js +2 -0
- package/server/modules/lists/ls-fbpage.js +11 -0
- package/server/modules/lists/ls-fbpost.js +2 -0
- package/server/modules/lists/ls-file.js +38 -0
- package/server/modules/lists/ls-financialroadmap.js +3 -0
- package/server/modules/lists/ls-flow.js +6 -0
- package/server/modules/lists/ls-flowdata.js +1 -0
- package/server/modules/lists/ls-flowpending.js +3 -0
- package/server/modules/lists/ls-folder.js +1 -0
- package/server/modules/lists/ls-forminfo.js +1 -0
- package/server/modules/lists/ls-giaoca.js +5 -0
- package/server/modules/lists/ls-group.js +5 -0
- package/server/modules/lists/ls-hmcn.js +2 -0
- package/server/modules/lists/ls-hspbts.js +3 -0
- package/server/modules/lists/ls-introducebonus.js +4 -0
- package/server/modules/lists/ls-introducecode.js +10 -0
- package/server/modules/lists/ls-introducer.js +21 -0
- package/server/modules/lists/ls-kbm-bcdkt.js +1 -0
- package/server/modules/lists/ls-kbm-bcqt.js +5 -0
- package/server/modules/lists/ls-kbm-kqhdkd.js +1 -0
- package/server/modules/lists/ls-kbm-lcttgt.js +1 -0
- package/server/modules/lists/ls-kbm-lctttt.js +1 -0
- package/server/modules/lists/ls-kbm-pttct.js +3 -0
- package/server/modules/lists/ls-kbm-tkgtgt.js +3 -0
- package/server/modules/lists/ls-kbm-tmbctc.js +3 -0
- package/server/modules/lists/ls-kehoachdtcp.js +4 -0
- package/server/modules/lists/ls-keyresult.js +7 -0
- package/server/modules/lists/ls-khunghangthanhvien.js +1 -0
- package/server/modules/lists/ls-label.js +1 -0
- package/server/modules/lists/ls-lienhe.js +4 -0
- package/server/modules/lists/ls-like-module.js +1 -0
- package/server/modules/lists/ls-link.js +1 -0
- package/server/modules/lists/ls-loaidiem.js +1 -0
- package/server/modules/lists/ls-lock.js +1 -0
- package/server/modules/lists/ls-log.js +3 -0
- package/server/modules/lists/ls-mailaccount.js +5 -0
- package/server/modules/lists/ls-mailreceived.js +5 -0
- package/server/modules/lists/ls-mailsent.js +4 -0
- package/server/modules/lists/ls-mailtemplate.js +4 -0
- package/server/modules/lists/ls-maudanhgia.js +3 -0
- package/server/modules/lists/ls-message2.js +8 -0
- package/server/modules/lists/ls-message2setting.js +5 -0
- package/server/modules/lists/ls-news.js +7 -0
- package/server/modules/lists/ls-newsfeed.js +4 -0
- package/server/modules/lists/ls-note.js +6 -0
- package/server/modules/lists/ls-okr.js +5 -0
- package/server/modules/lists/ls-okrdiagram.js +1 -0
- package/server/modules/lists/ls-opportunity.js +5 -0
- package/server/modules/lists/ls-options.js +4 -0
- package/server/modules/lists/ls-parameter.js +3 -0
- package/server/modules/lists/ls-participant.js +12 -0
- package/server/modules/lists/ls-phieudanhgia.js +7 -0
- package/server/modules/lists/ls-phucap.js +2 -0
- package/server/modules/lists/ls-productcode.js +9 -0
- package/server/modules/lists/ls-profile.js +1 -0
- package/server/modules/lists/ls-ptthanhtoan.js +3 -0
- package/server/modules/lists/ls-qts-dieuchinh.js +2 -0
- package/server/modules/lists/ls-qts-dieuchuyen.js +8 -0
- package/server/modules/lists/ls-reason.js +1 -0
- package/server/modules/lists/ls-rpt.js +5 -0
- package/server/modules/lists/ls-rptform.js +3 -0
- package/server/modules/lists/ls-shortcut.js +1 -0
- package/server/modules/lists/ls-smsaccount.js +1 -0
- package/server/modules/lists/ls-smssend.js +3 -0
- package/server/modules/lists/ls-sosanxuat.js +4 -0
- package/server/modules/lists/ls-step.js +1 -0
- package/server/modules/lists/ls-strategicdiagram.js +1 -0
- package/server/modules/lists/ls-strategicgoal.js +3 -0
- package/server/modules/lists/ls-strategickpi.js +7 -0
- package/server/modules/lists/ls-strategicobjective.js +3 -0
- package/server/modules/lists/ls-strategicplan.js +6 -0
- package/server/modules/lists/ls-support.js +3 -0
- package/server/modules/lists/ls-task.js +28 -0
- package/server/modules/lists/ls-tc.js +1 -0
- package/server/modules/lists/ls-templaterpt.js +5 -0
- package/server/modules/lists/ls-templatevoucher.js +1 -0
- package/server/modules/lists/ls-tontucthoi.js +3 -0
- package/server/modules/lists/ls-trangthaiapp.js +3 -0
- package/server/modules/lists/ls-transaction.js +4 -0
- package/server/modules/lists/ls-usergroup.js +7 -0
- package/server/modules/lists/ls-vat.js +1 -0
- package/server/modules/lists/ls-vatra.js +5 -0
- package/server/modules/lists/ls-vatvao.js +6 -0
- package/server/modules/lists/ls-warranty.js +3 -0
- package/server/modules/lists/ls-workflow.js +1 -0
- package/server/modules/lists/ls_hanmucton.js +3 -0
- package/server/modules/lists/ls_hspb.js +4 -0
- package/server/modules/lists/ls_spdd_ck.js +3 -0
- package/server/modules/lists/ls_spdd_dk.js +3 -0
- package/server/modules/lists/ls_ytdd_ck.js +4 -0
- package/server/modules/lists/ls_ytdd_dk.js +4 -0
- package/server/modules/lists/sys-attend.js +4 -0
- package/server/modules/lists/sys-follow.js +4 -0
- package/server/modules/lists/sys-right.js +2 -0
- package/server/modules/public/app.js +4 -0
- package/server/modules/public/approve.js +37 -0
- package/server/modules/public/callin.js +7 -0
- package/server/modules/public/comment.js +5 -0
- package/server/modules/public/dmnvt.js +4 -0
- package/server/modules/public/dmvt.js +9 -0
- package/server/modules/public/file.js +11 -0
- package/server/modules/public/forminfo.js +1 -0
- package/server/modules/public/group.js +4 -0
- package/server/modules/public/introducecode.js +1 -0
- package/server/modules/public/listinfo.js +1 -0
- package/server/modules/public/media-webhook.js +1 -0
- package/server/modules/public/partner.js +1 -0
- package/server/modules/public/paymentCallback.js +32 -0
- package/server/modules/public/province.js +1 -0
- package/server/modules/public/ptthanhtoan.js +4 -0
- package/server/modules/public/subscribe.js +30 -0
- package/server/modules/public/support.js +3 -0
- package/server/modules/public/tableinfo.js +1 -0
- package/server/modules/public/trialinfo.js +4 -0
- package/server/modules/public/versioninfo.js +1 -0
- package/server/modules/reports/calc-tinhgiafifo.js +8 -0
- package/server/modules/reports/calc-tinhgiatb.js +7 -0
- package/server/modules/reports/calc-tinhgiathanh.js +7 -0
- package/server/modules/reports/calc-tinhkhauhaots.js +3 -0
- package/server/modules/reports/calc-tinhluong.js +68 -0
- package/server/modules/reports/rp-analyzedata.js +6 -0
- package/server/modules/reports/rp-assbonus.js +4 -0
- package/server/modules/reports/rp-assinterest.js +8 -0
- package/server/modules/reports/rp-assproductowners.js +3 -0
- package/server/modules/reports/rp-asssupply.js +1 -0
- package/server/modules/reports/rp-asstransferlog.js +10 -0
- package/server/modules/reports/rp-backup.js +4 -0
- package/server/modules/reports/rp-banggiatb.js +3 -0
- package/server/modules/reports/rp-bangtinhkhauhao.js +6 -0
- package/server/modules/reports/rp-baoCaoFifoKy.js +1 -0
- package/server/modules/reports/rp-baocaokhachhang.js +6 -0
- package/server/modules/reports/rp-bcdkt.js +11 -0
- package/server/modules/reports/rp-bcintroducebonus.js +4 -0
- package/server/modules/reports/rp-bckhtiemnang.js +3 -0
- package/server/modules/reports/rp-bcqt.js +85 -0
- package/server/modules/reports/rp-bkchamcong.js +5 -0
- package/server/modules/reports/rp-bkct.js +13 -0
- package/server/modules/reports/rp-bkshipbook.js +8 -0
- package/server/modules/reports/rp-bkvanchuyen.js +8 -0
- package/server/modules/reports/rp-bkvatra.js +7 -0
- package/server/modules/reports/rp-bkvatvao.js +7 -0
- package/server/modules/reports/rp-capnhatsocaitc.js +4 -0
- package/server/modules/reports/rp-cdpsdiem.js +4 -0
- package/server/modules/reports/rp-cdpsdt.js +5 -0
- package/server/modules/reports/rp-cdpskh.js +8 -0
- package/server/modules/reports/rp-cdpsnphep.js +3 -0
- package/server/modules/reports/rp-cdpstk.js +4 -0
- package/server/modules/reports/rp-chitietchitientheohoadon.js +12 -0
- package/server/modules/reports/rp-chitiettaisan.js +13 -0
- package/server/modules/reports/rp-chitietthutientheohoadon.js +13 -0
- package/server/modules/reports/rp-ckcn.js +3 -0
- package/server/modules/reports/rp-ckdiem.js +2 -0
- package/server/modules/reports/rp-cktk.js +3 -0
- package/server/modules/reports/rp-ckvt.js +10 -0
- package/server/modules/reports/rp-ckvttheokho.js +4 -0
- package/server/modules/reports/rp-ckvttheotg.js +4 -0
- package/server/modules/reports/rp-ckvttt.js +3 -0
- package/server/modules/reports/rp-congnophaithutheotuoino.js +3 -0
- package/server/modules/reports/rp-congnophaitratheotuoino.js +3 -0
- package/server/modules/reports/rp-congnosapthu.js +4 -0
- package/server/modules/reports/rp-congnosaptra.js +4 -0
- package/server/modules/reports/rp-congviectheobp.js +9 -0
- package/server/modules/reports/rp-congviectheodt.js +8 -0
- package/server/modules/reports/rp-congviectheokh.js +8 -0
- package/server/modules/reports/rp-congviectheonv.js +9 -0
- package/server/modules/reports/rp-congviectheotimeline.js +6 -0
- package/server/modules/reports/rp-ctbanle.js +15 -0
- package/server/modules/reports/rp-ctbanle2.js +20 -0
- package/server/modules/reports/rp-ctbanlectv.js +20 -0
- package/server/modules/reports/rp-ctbanlenpp.js +24 -0
- package/server/modules/reports/rp-ctdanhgianhanvien.js +8 -0
- package/server/modules/reports/rp-cthangbanbitralai.js +4 -0
- package/server/modules/reports/rp-ctmuahang.js +7 -0
- package/server/modules/reports/rp-cttralaihang.js +4 -0
- package/server/modules/reports/rp-databanle.js +10 -0
- package/server/modules/reports/rp-diemthuong.js +2 -0
- package/server/modules/reports/rp-dkcn.js +3 -0
- package/server/modules/reports/rp-dktk.js +2 -0
- package/server/modules/reports/rp-dsnhanviencm.js +9 -0
- package/server/modules/reports/rp-dsnhanvientb.js +9 -0
- package/server/modules/reports/rp-dtbanlekempk.js +12 -0
- package/server/modules/reports/rp-dtbanletheoct.js +22 -0
- package/server/modules/reports/rp-dtbanletheoctkempk.js +25 -0
- package/server/modules/reports/rp-dtbanletheokh.js +17 -0
- package/server/modules/reports/rp-dtbanletheokhnpp.js +19 -0
- package/server/modules/reports/rp-dtbanletheokho.js +15 -0
- package/server/modules/reports/rp-dtbanletheonam.js +3 -0
- package/server/modules/reports/rp-dtbanletheongay.js +1 -0
- package/server/modules/reports/rp-dtbanletheonpp.js +23 -0
- package/server/modules/reports/rp-dtbanletheonv.js +19 -0
- package/server/modules/reports/rp-dtbanletheoquy.js +3 -0
- package/server/modules/reports/rp-dtbanletheosp.js +9 -0
- package/server/modules/reports/rp-dtbanletheospnpp.js +6 -0
- package/server/modules/reports/rp-dtbanletheothang.js +3 -0
- package/server/modules/reports/rp-dtbanletheothungan.js +12 -0
- package/server/modules/reports/rp-dtbanletheovt.js +2 -0
- package/server/modules/reports/rp-dtbanletheovtnpp.js +2 -0
- package/server/modules/reports/rp-dutoanthuchitheodt.js +4 -0
- package/server/modules/reports/rp-getPXC2PNC.js +8 -0
- package/server/modules/reports/rp-getariseofaccountsbymonth.js +4 -0
- package/server/modules/reports/rp-getbtpb.js +6 -0
- package/server/modules/reports/rp-getcashbycashier.js +7 -0
- package/server/modules/reports/rp-getcschietkhau.js +5 -0
- package/server/modules/reports/rp-getdinhmuc4lenhcp.js +7 -0
- package/server/modules/reports/rp-getdinhmuc4pxk.js +9 -0
- package/server/modules/reports/rp-getdk4pht.js +8 -0
- package/server/modules/reports/rp-getdk4pkc.js +10 -0
- package/server/modules/reports/rp-getdttheoca.js +5 -0
- package/server/modules/reports/rp-getinvoice2pay.js +4 -0
- package/server/modules/reports/rp-getinvoice2receive.js +4 -0
- package/server/modules/reports/rp-getinvoice2return.js +5 -0
- package/server/modules/reports/rp-getinvoice2return_bl.js +6 -0
- package/server/modules/reports/rp-getkehoachmh4lenhcp.js +4 -0
- package/server/modules/reports/rp-getkhauhao.js +7 -0
- package/server/modules/reports/rp-getluong.js +8 -0
- package/server/modules/reports/rp-getluongchuyen.js +5 -0
- package/server/modules/reports/rp-getpn2fee.js +5 -0
- package/server/modules/reports/rp-getpn2return.js +5 -0
- package/server/modules/reports/rp-getthanhpham4pnk.js +7 -0
- package/server/modules/reports/rp-getvc2xhd.js +11 -0
- package/server/modules/reports/rp-gt_cpnvltt.js +6 -0
- package/server/modules/reports/rp-hangbanbitralai.js +5 -0
- package/server/modules/reports/rp-hangthanhvien.js +3 -0
- package/server/modules/reports/rp-hoadonbanhangtheohantt.js +5 -0
- package/server/modules/reports/rp-hoadonmuahangtheohantt.js +5 -0
- package/server/modules/reports/rp-hoahong.js +15 -0
- package/server/modules/reports/rp-kcsns.js +19 -0
- package/server/modules/reports/rp-kgchamcong.js +1 -0
- package/server/modules/reports/rp-khoaso.js +11 -0
- package/server/modules/reports/rp-kiemtrasocaitcvssocai.js +6 -0
- package/server/modules/reports/rp-kqdanhgianhanvien.js +5 -0
- package/server/modules/reports/rp-kqhdkd.js +1 -0
- package/server/modules/reports/rp-lcttgt.js +16 -0
- package/server/modules/reports/rp-lctttt.js +11 -0
- package/server/modules/reports/rp-linkslist.js +4 -0
- package/server/modules/reports/rp-phanbochitienchohoadon.js +11 -0
- package/server/modules/reports/rp-phanbothutienchohoadon.js +11 -0
- package/server/modules/reports/rp-ptbitralai.js +7 -0
- package/server/modules/reports/rp-ptcttct.js +24 -0
- package/server/modules/reports/rp-ptdonhang.js +8 -0
- package/server/modules/reports/rp-pttct.js +52 -0
- package/server/modules/reports/rp-pttctkho.js +32 -0
- package/server/modules/reports/rp-pttctkho2.js +29 -0
- package/server/modules/reports/rp-referredusers.js +5 -0
- package/server/modules/reports/rp-sctbhxh.js +4 -0
- package/server/modules/reports/rp-sctcnkh.js +11 -0
- package/server/modules/reports/rp-sctdiem.js +3 -0
- package/server/modules/reports/rp-sctdt.js +7 -0
- package/server/modules/reports/rp-sctdtcp.js +11 -0
- package/server/modules/reports/rp-sctluong.js +6 -0
- package/server/modules/reports/rp-sctthuetncn.js +4 -0
- package/server/modules/reports/rp-scttk.js +9 -0
- package/server/modules/reports/rp-sctvt.js +5 -0
- package/server/modules/reports/rp-sctvt_sl.js +5 -0
- package/server/modules/reports/rp-sctvtnpp.js +6 -0
- package/server/modules/reports/rp-sctvttt.js +5 -0
- package/server/modules/reports/rp-search.js +4 -0
- package/server/modules/reports/rp-socai.js +6 -0
- package/server/modules/reports/rp-socaitk.js +1 -0
- package/server/modules/reports/rp-sochut.js +7 -0
- package/server/modules/reports/rp-sokho.js +7 -0
- package/server/modules/reports/rp-sokhott.js +5 -0
- package/server/modules/reports/rp-sonkbh.js +5 -0
- package/server/modules/reports/rp-sonkc.js +6 -0
- package/server/modules/reports/rp-sonkct.js +5 -0
- package/server/modules/reports/rp-sonkmh.js +5 -0
- package/server/modules/reports/rp-sonktt.js +5 -0
- package/server/modules/reports/rp-soquy.js +11 -0
- package/server/modules/reports/rp-sosanhkhvatt.js +13 -0
- package/server/modules/reports/rp-sosanhkhvatt2.js +5 -0
- package/server/modules/reports/rp-sotaisan.js +13 -0
- package/server/modules/reports/rp-sotiengui.js +7 -0
- package/server/modules/reports/rp-taodinhmuctudkhoc.js +5 -0
- package/server/modules/reports/rp-thbanhangkempk.js +28 -0
- package/server/modules/reports/rp-thdanhgianhanvien.js +9 -0
- package/server/modules/reports/rp-thgt.js +6 -0
- package/server/modules/reports/rp-thnxt.js +11 -0
- package/server/modules/reports/rp-thnxt_sl.js +9 -0
- package/server/modules/reports/rp-thnxtnpp.js +10 -0
- package/server/modules/reports/rp-thnxttt.js +9 -0
- package/server/modules/reports/rp-tkbanhangtheogioithieu.js +9 -0
- package/server/modules/reports/rp-tkgioithieukh.js +4 -0
- package/server/modules/reports/rp-tkgtgt.js +76 -0
- package/server/modules/reports/rp-tkgtgt_old.js +7 -0
- package/server/modules/reports/rp-tmbctc.js +20 -0
- package/server/modules/reports/rp-tonghopbanhang.js +6 -0
- package/server/modules/reports/rp-tonghopmuahang.js +5 -0
- package/server/modules/reports/rp-tonghoptralaihang.js +5 -0
- package/server/modules/reports/rp-tongquanbanle.js +20 -0
- package/server/modules/reports/rp-tongquanbds.js +3 -0
- package/server/modules/reports/rp-tongquancongty.js +6 -0
- package/server/modules/reports/rp-tongquanctvnpp.js +12 -0
- package/server/modules/reports/rp-tongquannvbh.js +14 -0
- package/server/modules/reports/rp-tongquannvnpp.js +5 -0
- package/server/modules/reports/rp-uoctinhnvl.js +11 -0
- package/server/modules/reports/rp-wallet.js +3 -0
- package/server/modules/reports/rpt-tkdiemtichluy.js +9 -0
- package/server/modules/systems/sys-app.js +34 -0
- package/server/modules/systems/sys-colleague.js +11 -0
- package/server/modules/systems/sys-data_list_config.js +1 -0
- package/server/modules/systems/sys-domain.js +1 -0
- package/server/modules/systems/sys-ecomproductlines.js +1 -0
- package/server/modules/systems/sys-exportexceltemplate.js +1 -0
- package/server/modules/systems/sys-fieldright.js +1 -0
- package/server/modules/systems/sys-importexceltemplate.js +1 -0
- package/server/modules/systems/sys-labelinfo.js +4 -0
- package/server/modules/systems/sys-listinfo.js +10 -0
- package/server/modules/systems/sys-menuinfo.js +4 -0
- package/server/modules/systems/sys-message.js +14 -0
- package/server/modules/systems/sys-moduleinfo.js +4 -0
- package/server/modules/systems/sys-notification.js +8 -0
- package/server/modules/systems/sys-quanhuyen.js +1 -0
- package/server/modules/systems/sys-reportinfo.js +5 -0
- package/server/modules/systems/sys-rptobject.js +1 -0
- package/server/modules/systems/sys-schedule.js +10 -0
- package/server/modules/systems/sys-sysconfig.js +1 -0
- package/server/modules/systems/sys-sysgroup.js +1 -0
- package/server/modules/systems/sys-tableinfo.js +1 -0
- package/server/modules/systems/sys-templatestore.js +5 -0
- package/server/modules/systems/sys-tinhthanh.js +1 -0
- package/server/modules/systems/sys-token.js +3 -0
- package/server/modules/systems/sys-trangthai.js +3 -0
- package/server/modules/systems/sys-trialinfo.js +1 -0
- package/server/modules/systems/sys-user.js +45 -0
- package/server/modules/systems/sys-users.js +10 -0
- package/server/modules/systems/sys-versioninfo.js +1 -0
- package/server/modules/systems/sys-vietqrbanks.js +1 -0
- package/server/modules/systems/sys-xaphuong.js +1 -0
- package/server/modules/vouchers/vo-banggiaban.js +8 -0
- package/server/modules/vouchers/vo-bc1.js +34 -0
- package/server/modules/vouchers/vo-bc5.js +15 -0
- package/server/modules/vouchers/vo-bg1.js +10 -0
- package/server/modules/vouchers/vo-bg2.js +12 -0
- package/server/modules/vouchers/vo-bn1.js +36 -0
- package/server/modules/vouchers/vo-bn5.js +15 -0
- package/server/modules/vouchers/vo-dh2.js +35 -0
- package/server/modules/vouchers/vo-dinhmucsx.js +6 -0
- package/server/modules/vouchers/vo-dkb.js +21 -0
- package/server/modules/vouchers/vo-dn0.js +9 -0
- package/server/modules/vouchers/vo-dnm.js +20 -0
- package/server/modules/vouchers/vo-hd1.js +37 -0
- package/server/modules/vouchers/vo-hd2.js +108 -0
- package/server/modules/vouchers/vo-hd3.js +38 -0
- package/server/modules/vouchers/vo-hd4.js +13 -0
- package/server/modules/vouchers/vo-hd7.js +29 -0
- package/server/modules/vouchers/vo-hd8.js +29 -0
- package/server/modules/vouchers/vo-hde.js +39 -0
- package/server/modules/vouchers/vo-htl.js +11 -0
- package/server/modules/vouchers/vo-kbbtpb.js +6 -0
- package/server/modules/vouchers/vo-kehoachmh.js +11 -0
- package/server/modules/vouchers/vo-lenhcapphat.js +9 -0
- package/server/modules/vouchers/vo-lenhsx.js +12 -0
- package/server/modules/vouchers/vo-pbl.js +94 -0
- package/server/modules/vouchers/vo-pc0.js +14 -0
- package/server/modules/vouchers/vo-pc1.js +31 -0
- package/server/modules/vouchers/vo-pc2.js +25 -0
- package/server/modules/vouchers/vo-pc3.js +14 -0
- package/server/modules/vouchers/vo-pc5.js +15 -0
- package/server/modules/vouchers/vo-pc6.js +19 -0
- package/server/modules/vouchers/vo-pcl.js +7 -0
- package/server/modules/vouchers/vo-pdn.js +11 -0
- package/server/modules/vouchers/vo-pdx.js +9 -0
- package/server/modules/vouchers/vo-pgh.js +16 -0
- package/server/modules/vouchers/vo-pht.js +6 -0
- package/server/modules/vouchers/vo-pkc.js +5 -0
- package/server/modules/vouchers/vo-pkh.js +9 -0
- package/server/modules/vouchers/vo-pkk.js +12 -0
- package/server/modules/vouchers/vo-pkt.js +12 -0
- package/server/modules/vouchers/vo-pn1.js +30 -0
- package/server/modules/vouchers/vo-pn2.js +17 -0
- package/server/modules/vouchers/vo-pn3.js +18 -0
- package/server/modules/vouchers/vo-pn5.js +18 -0
- package/server/modules/vouchers/vo-pn6.js +18 -0
- package/server/modules/vouchers/vo-pn9.js +23 -0
- package/server/modules/vouchers/vo-pnc.js +19 -0
- package/server/modules/vouchers/vo-pnh.js +17 -0
- package/server/modules/vouchers/vo-pnk.js +14 -0
- package/server/modules/vouchers/vo-pnknpp.js +12 -0
- package/server/modules/vouchers/vo-po1.js +14 -0
- package/server/modules/vouchers/vo-ppb.js +8 -0
- package/server/modules/vouchers/vo-pt1.js +20 -0
- package/server/modules/vouchers/vo-pt5.js +15 -0
- package/server/modules/vouchers/vo-ptl.js +8 -0
- package/server/modules/vouchers/vo-purchase_contract.js +9 -0
- package/server/modules/vouchers/vo-pxc.js +24 -0
- package/server/modules/vouchers/vo-pxh.js +18 -0
- package/server/modules/vouchers/vo-pxk.js +15 -0
- package/server/modules/vouchers/vo-pxknpp.js +14 -0
- package/server/modules/vouchers/vo-qts.js +12 -0
- package/server/modules/vouchers/vo-sale_contract.js +11 -0
- package/server/modules/vouchers/vo-shipbook.js +17 -0
- package/server/modules/vouchers/vo-so1.js +125 -0
- package/server/modules/vouchers/vo-so5.js +57 -0
- package/server/modules/vouchers/vo-so7.js +97 -0
- package/server/modules/vouchers/vo-so9.js +119 -0
- package/server/modules/vouchers/vo-vanchuyen.js +14 -0
- package/server/modules/vouchers/vo-xhd.js +33 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
const moment=require("moment"),numeral=require("numeral"),_=require("lodash"),PostSokho=require("../../libs/post-sokho"),options=global.getModel("options"),PostSocai=require("../../libs/post-socai"),User=global.getModel("user"),Socai=global.getModel("socai"),transaction=global.getModel("transaction"),Evoucher=global.getModel("evoucher"),dvcs=global.getModel("dvcs"),dmvt=global.getModel("dmvt"),dmtt=global.getModel("dmtt"),dmcpmh=global.getModel("dmcpmh"),dmkho=global.getModel("dmkho"),customer=global.getModel("customer"),
|
|
2
|
+
dmdt=global.getModel("dmdt"),dmphi=global.getModel("dmphi"),contract=global.getModel("contract"),trangthai=global.getModel("trangthai"),currency=global.getModel("currency"),ptthanhtoan=global.getModel("ptthanhtoan"),dmdiemthuong=global.getModel("dmdiemthuong"),model=global.getModel("so1"),pt1=global.getModel("pt1"),controller=require("../../controllers/controller"),async=require("async"),ma_ct="SO1",ckdiem=require("../../libs/ckdiem"),tinhhoahong=require("../../libs/tinhhoahong"),blockchainconnect=
|
|
3
|
+
require("../../libs/blockchainconnect"),App=global.getModel("app"),Introducer=global.getModel("introducer"),getGiaBan=require("../../libs/getGiabanAsync"),dmchietkhauhd=global.getModel("dmchietkhauhd"),dmkhuyenmaihd=global.getModel("dmkhuyenmaihd"),utils=require("../../libs/utils"),spend=async($appInfo$$,$receiver_user$$,$receiver_address$$,$amount$$,$denom$$,$memo$$,$introduce_code$$,$sub_action$$="")=>{try{await blockchainconnect.spend($appInfo$$._id,$appInfo$$.wallet_token,$appInfo$$.wallet_address,
|
|
4
|
+
$receiver_address$$,{amount:$amount$$,denom:$denom$$,memo:$memo$$,action:"bonus",introduce_code:$introduce_code$$,sub_action:$sub_action$$})}catch($e$$){Logger.error("Error send coin",$e$$,$receiver_user$$,$receiver_address$$,$amount$$,$denom$$,$memo$$)}},validOffline=$detail$$=>{$detail$$.ma_thue?($detail$$.gia_ban_ct_nt=$detail$$.gia_ban_ct=Math.roundBy($detail$$.gia_ban_nt/(1+$detail$$.thue_suat/100),5),$detail$$.tien_hang_ct=$detail$$.tien_hang_ct_nt=Math.roundBy($detail$$.sl_xuat*$detail$$.gia_ban_ct_nt,
|
|
5
|
+
0),$detail$$.ty_le_ck&&($detail$$.tien_ck=$detail$$.tien_ck_nt=utils.round($detail$$.tien_hang_ct*$detail$$.ty_le_ck/100)),$detail$$.tien_thue=$detail$$.tien_thue_nt=Math.roundBy(($detail$$.tien_hang_ct_nt-$detail$$.tien_ck_nt)*$detail$$.thue_suat/100)):($detail$$.gia_ban_ct=$detail$$.gia_ban,$detail$$.gia_ban_ct_nt=$detail$$.gia_ban_nt,$detail$$.tien_hang_ct=$detail$$.tien_hang_ct_nt=$detail$$.tien_hang_nt,$detail$$.ty_le_ck&&($detail$$.tien_ck=$detail$$.tien_ck_nt=utils.round($detail$$.tien_hang_ct*
|
|
6
|
+
$detail$$.ty_le_ck/100)),$detail$$.tien_thue=0,$detail$$.tien_thue_nt=0)},khuyenmaihd=async $obj$$=>{if($obj$$.details&&$obj$$.online){var $ckhds_query_t_tien_hang_ct_nt$$=$obj$$.details.filter($d$$=>!$d$$.km_yn_for).csum("tien_hang_ct_nt");if($ckhds_query_t_tien_hang_ct_nt$$!==0){var $hieu_luc_tu_i_q_ma_kh_t_ck_nt_t_tt_nt$$=$obj$$.details.filter($d$$=>!$d$$.km_yn_for).csum("tien_ck_nt");$hieu_luc_tu_i_q_ma_kh_t_ck_nt_t_tt_nt$$=$ckhds_query_t_tien_hang_ct_nt$$-$hieu_luc_tu_i_q_ma_kh_t_ck_nt_t_tt_nt$$;
|
|
7
|
+
$obj$$.details=$obj$$.details.filter($d$$=>$d$$.km_yn_for!="khuyenmaihd");$ckhds_query_t_tien_hang_ct_nt$$={id_app:$obj$$.id_app,gt_tu:{$lte:$hieu_luc_tu_i_q_ma_kh_t_ck_nt_t_tt_nt$$},ma_kho:{$in:[void 0,null,"",$obj$$.ma_kho]}};$ckhds_query_t_tien_hang_ct_nt$$.$and=[{$or:[{gt_den:{$in:[0,void 0,null]}},{gt_den:{$gte:$hieu_luc_tu_i_q_ma_kh_t_ck_nt_t_tt_nt$$}}]}];var $ckhd_hieu_luc_den_q_nh_kh_tu_ngay$$=moment($obj$$.ngay_ct).startOf("date").toDate();$hieu_luc_tu_i_q_ma_kh_t_ck_nt_t_tt_nt$$={$lte:moment($obj$$.ngay_ct).endOf("date").toDate()};
|
|
8
|
+
$ckhd_hieu_luc_den_q_nh_kh_tu_ngay$$={$gte:$ckhd_hieu_luc_den_q_nh_kh_tu_ngay$$};$ckhds_query_t_tien_hang_ct_nt$$.hieu_luc_tu=$hieu_luc_tu_i_q_ma_kh_t_ck_nt_t_tt_nt$$;$ckhds_query_t_tien_hang_ct_nt$$.hieu_luc_den=$ckhd_hieu_luc_den_q_nh_kh_tu_ngay$$;$hieu_luc_tu_i_q_ma_kh_t_ck_nt_t_tt_nt$$={$in:[void 0,null,"",$obj$$.ma_kh]};$ckhd_hieu_luc_den_q_nh_kh_tu_ngay$$={$in:[void 0,null,""]};if($obj$$.ma_kh){var $kh_lan_mua_thu$$=await customer.findOne({id_app:$obj$$.id_app,ma_kh:$obj$$.ma_kh},{nh_kh:1});
|
|
9
|
+
$kh_lan_mua_thu$$&&$kh_lan_mua_thu$$.nh_kh&&($ckhd_hieu_luc_den_q_nh_kh_tu_ngay$$={$in:[void 0,null,"",$kh_lan_mua_thu$$.nh_kh]});($kh_lan_mua_thu$$=await model.countDocuments({id_app:$obj$$.id_app,ma_kh:$obj$$.ma_kh,trang_thai:{$in:["5","6"]}}))||($kh_lan_mua_thu$$=0);$kh_lan_mua_thu$$+=1}$ckhds_query_t_tien_hang_ct_nt$$.$or=[{$and:[{ma_kh:$hieu_luc_tu_i_q_ma_kh_t_ck_nt_t_tt_nt$$},{nh_kh:{$in:["",null,void 0]}}]},{$and:[{nh_kh:$ckhd_hieu_luc_den_q_nh_kh_tu_ngay$$},{ma_kh:{$in:["",null,void 0]}}]}];
|
|
10
|
+
$ckhds_query_t_tien_hang_ct_nt$$.ap_dung_lan_mua_thu={$in:[null,void 0,0,void 0]};$ckhds_query_t_tien_hang_ct_nt$$.online=!0;$ckhds_query_t_tien_hang_ct_nt$$=await dmkhuyenmaihd.find($ckhds_query_t_tien_hang_ct_nt$$).sort({stt_uu_tien:1,gt_tu:-1,ma_kh:-1,nh_kh:-1,hieu_luc_tu:-1}).lean();for($hieu_luc_tu_i_q_ma_kh_t_ck_nt_t_tt_nt$$=0;$hieu_luc_tu_i_q_ma_kh_t_ck_nt_t_tt_nt$$<$ckhds_query_t_tien_hang_ct_nt$$.length;$hieu_luc_tu_i_q_ma_kh_t_ck_nt_t_tt_nt$$++)if(($ckhd_hieu_luc_den_q_nh_kh_tu_ngay$$=$ckhds_query_t_tien_hang_ct_nt$$[$hieu_luc_tu_i_q_ma_kh_t_ck_nt_t_tt_nt$$])&&
|
|
11
|
+
$ckhd_hieu_luc_den_q_nh_kh_tu_ngay$$.details_km&&$ckhd_hieu_luc_den_q_nh_kh_tu_ngay$$.details_km.length>0){$kh_lan_mua_thu$$=$ckhd_hieu_luc_den_q_nh_kh_tu_ngay$$.sl_toi_thieu||0;let $sl_dap_ung$$=0;$kh_lan_mua_thu$$&&$ckhd_hieu_luc_den_q_nh_kh_tu_ngay$$.vts&&$ckhd_hieu_luc_den_q_nh_kh_tu_ngay$$.vts.length>0&&$ckhd_hieu_luc_den_q_nh_kh_tu_ngay$$.vts.forEach($vt$$=>{var $ds_tien$$=$obj$$.details.filter($d$$=>$d$$.ma_vt===$vt$$.ma_vt&&(!$vt$$.ma_tt1||$vt$$.ma_tt1===$d$$.ma_tt1)&&(!$vt$$.ma_tt2||$vt$$.ma_tt2===
|
|
12
|
+
$d$$.ma_tt2)&&(!$vt$$.ma_tt3||$vt$$.ma_tt3===$d$$.ma_tt3));if($ds_tien$$.length!=0){var $so_luong$$=$ds_tien$$.map($d$$=>$d$$.sl_xuat).reduce(($a$$,$b$$)=>$a$$+$b$$,0);$ds_tien$$=$ds_tien$$.map($d$$=>($d$$.tien_hang_ct_nt||0)-($d$$.tien_ck_nt||0)).reduce(($a$$,$b$$)=>$a$$+$b$$,0);$vt$$.sl_tu&&$so_luong$$<$vt$$.sl_tu||$vt$$.sl_den&&$so_luong$$>$vt$$.sl_den||$vt$$.gt_tu&&$ds_tien$$<$vt$$.gt_tu||$vt$$.gt_den&&$ds_tien$$>$vt$$.gt_den||($sl_dap_ung$$+=1)}});if($kh_lan_mua_thu$$<=$sl_dap_ung$$){$ckhd_hieu_luc_den_q_nh_kh_tu_ngay$$.details_km.forEach($d$jscomp$6_detail$$=>
|
|
13
|
+
{$d$jscomp$6_detail$$={...$d$jscomp$6_detail$$,km_yn_for:"khuyenmaihd"};$d$jscomp$6_detail$$.sl_xuat=$d$jscomp$6_detail$$.sl_km;$d$jscomp$6_detail$$.tien_hang_ct_nt=$d$jscomp$6_detail$$.tien_hang_ct=$d$jscomp$6_detail$$.tien_hang_nt=$d$jscomp$6_detail$$.tien_hang=0;$d$jscomp$6_detail$$.tien_ck_nt=$d$jscomp$6_detail$$.tien_ck=0;$d$jscomp$6_detail$$.ty_le_ck=0;$d$jscomp$6_detail$$.tien_nt=$d$jscomp$6_detail$$.tien=0;$obj$$.details.push($d$jscomp$6_detail$$)});break}}}}},chietkhauhd=async $obj$$=>{if(!$obj$$.signature&&
|
|
14
|
+
$obj$$.online){$obj$$.details=$obj$$.details||[];var $t_ck_nt$$=$obj$$.details.csum("tien_ck_nt"),$t_tien_hang_ct_nt$$=$obj$$.details.csum("tien_hang_ct_nt");dmchietkhauhd.tinhChietKhau($obj$$.user_created,$obj$$.id_app,$obj$$,$t_tien_hang_ct_nt$$-$t_ck_nt$$)}},getPointBalance=async($id_app$$,$sender_email$$)=>new Promise(($resolve$$,$reject$$)=>{ckdiem({id_app:$id_app$$,email:$sender_email$$},($e$$,$rs$$)=>{if($e$$)return $reject$$(Error($e$$));$resolve$$($rs$$.length===0?0:$rs$$[0].ton00)})}),createTransactionBonus=
|
|
15
|
+
async function($obj$$){if($obj$$.trang_thai!="5"&&$obj$$.trang_thai!="6")return await transaction.deleteTrans({id_ct:$obj$$._id.toString()+":bonus"},"Tr\u1ea3 l\u1ea1i \u0111i\u1ec3m th\u01b0\u1edfng \u0111\u1ec3 t\u00ednh l\u1ea1i"),await transaction.deleteTrans({id_ct:$obj$$._id.toString()+":introduce"},"Tr\u1ea3 l\u1ea1i \u0111i\u1ec3m th\u01b0\u1edfng gi\u1edbi thi\u1ec7u th\u00e0nh vi\u00ean m\u1edbi \u0111\u1ec3 t\u00ednh l\u1ea1i"),null;let $kh$$=await customer.findOne({id_app:$obj$$.id_app,
|
|
16
|
+
ma_kh:$obj$$.ma_kh})||{},$lan_mua$$=(await model.find({id_app:$obj$$.id_app,ma_kh:$obj$$.ma_kh,ngay_ct:{$lte:$obj$$.ngay_ct}})).length+1;var $_app_diem_thuong_gioi_thieu_old_trans$$=await App.findOne({_id:$obj$$.id_app}),$_intro_amount$$=await Introducer.findOne({id_app:$obj$$.id_app,be_introduced:$obj$$.of_user||$obj$$.user_created});$_app_diem_thuong_gioi_thieu_old_trans$$=$_app_diem_thuong_gioi_thieu_old_trans$$.exfields.diem_thuong_gioi_thieu;$lan_mua$$===1&&$_app_diem_thuong_gioi_thieu_old_trans$$&&
|
|
17
|
+
$_intro_amount$$&&await transaction.createTrans({id_app:$obj$$.id_app,sender_email:$obj$$.id_app,receiver_email:$_intro_amount$$.be_introduced_by,amount:$_app_diem_thuong_gioi_thieu_old_trans$$,description:"\u0110i\u1ec3m th\u01b0\u1edfng gi\u1edbi thi\u1ec7u kh\u00e1ch h\u00e0ng",otherData:{ma_ct:$obj$$.ma_ct,so_ct:$obj$$.so_ct,ngay_ct:$obj$$.ngay_ct,id_ct:$obj$$._id.toString()+":introduce"}});if(!$obj$$.exfields.survey)return null;let $now$$=moment(new Date).startOf("date").toDate();$_intro_amount$$=
|
|
18
|
+
$obj$$.details.filter($d$$=>$d$$.tien_hang).map(async $d$$=>{var $amount$$=await dmvt.findOne({ma_vt:$d$$.ma_vt,id_app:$obj$$.id_app}),$ckdiemthuong_ty_le_diem_thuong$$=await dmdiemthuong.find({id_app:$obj$$.id_app,status:!0,ma_kh:{$in:[null,"",$kh$$.ma_kh]},ma_kho:{$in:[null,"",$obj$$.ma_kho]},nh_kh:{$in:[null,"",$kh$$.nh_kh]},hieu_luc_tu:{$lte:$now$$},hieu_luc_den:{$gte:$now$$},ap_dung_lan_mua_thu:{$in:[0,$lan_mua$$]},ma_vt:{$in:[null,"",void 0,$d$$.ma_vt]},ma_nvt:{$in:[null,"",void 0,$amount$$?
|
|
19
|
+
$amount$$.ma_nvt:""]}}).sort({ma_vt:-1,ma_nvt:-1,hieu_luc_tu:-1}).limit(1);return $ckdiemthuong_ty_le_diem_thuong$$.length>0?($amount$$=0,$ckdiemthuong_ty_le_diem_thuong$$[0].tien?($ckdiemthuong_ty_le_diem_thuong$$=$ckdiemthuong_ty_le_diem_thuong$$[0].diem/$ckdiemthuong_ty_le_diem_thuong$$[0].tien)||($amount$$=Math.roundBy(($d$$.tien_hang-($d$$.tien_ck||0))*$ckdiemthuong_ty_le_diem_thuong$$,0)):$amount$$=$ckdiemthuong_ty_le_diem_thuong$$[0].diem*($d$$.sl_xuat||1),$amount$$):0});if($_intro_amount$$=
|
|
20
|
+
(await Promise.all($_intro_amount$$)).reduce(($a$$,$b$$)=>$a$$+$b$$,0)){if($_app_diem_thuong_gioi_thieu_old_trans$$=await transaction.findOne({id_ct:$obj$$._id.toString()+":bonus"}),!$_app_diem_thuong_gioi_thieu_old_trans$$||$_app_diem_thuong_gioi_thieu_old_trans$$.amount!==$_intro_amount$$)return await transaction.deleteTrans({id_ct:$obj$$._id.toString()+":bonus"},"Tr\u1ea3 l\u1ea1i \u0111i\u1ec3m th\u01b0\u1edfng \u0111\u1ec3 t\u00ednh l\u1ea1i"),await transaction.createTrans({id_app:$obj$$.id_app,
|
|
21
|
+
sender_email:$obj$$.id_app,receiver_email:$obj$$.of_user||$obj$$.user_created,amount:$_intro_amount$$,description:"\u0110i\u1ec3m th\u01b0\u1edfng mua h\u00e0ng",otherData:{ma_ct:$obj$$.ma_ct,so_ct:$obj$$.so_ct,ngay_ct:$obj$$.ngay_ct,id_ct:$obj$$._id.toString()+":bonus"}})}else await transaction.deleteTrans({id_ct:$obj$$._id.toString()+":bonus"},"Tr\u1ea3 l\u1ea1i \u0111i\u1ec3m th\u01b0\u1edfng \u0111\u1ec3 t\u00ednh l\u1ea1i")},createTransactionPayment=async function($obj$$){await transaction.deleteTrans({id_ct:$obj$$._id.toString()});
|
|
22
|
+
$obj$$.paymentByPoints&&await transaction.createTrans({id_app:$obj$$.id_app,sender_email:$obj$$.of_user||$obj$$.user_created,receiver_email:$obj$$.id_app,amount:$obj$$.paymentByPoints,description:"Thanh to\u00e1n cho \u0111\u01a1n h\u00e0ng s\u1ed1 "+$obj$$.so_ct,otherData:{ma_ct:$obj$$.ma_ct,so_ct:$obj$$.so_ct,ngay_ct:$obj$$.ngay_ct,id_ct:$obj$$._id.toString()}})},checkEvoucher=($user$$,$obj$$)=>{let $gt_don_hang$$=$obj$$.details.map($d$$=>$d$$.tien_hang_nt-($d$$.tien_ck_nt||0)).reduce(($a$$,$b$$)=>
|
|
23
|
+
$a$$+$b$$,0);return($obj$$.evouchers||[]).map($ev$$=>new Promise(($resolve$$,$reject$$)=>{(async()=>{const $_e$$=await Evoucher.findOne({ma:$ev$$.ma,id_app:$user$$.current_id_app});if(!$_e$$)return Logger.error("Th\u1ebb mua h\u00e0ng kh\u00f4ng t\u1ed3n t\u1ea1i",$ev$$),$reject$$(Error(`Th\u1ebb mua h\u00e0ng ${$ev$$.ma} kh\u00f4ng t\u1ed3n t\u1ea1i`));if(!$_e$$.online)return $reject$$(Error(`Kh\u00f4ng th\u1ec3 s\u1eed d\u1ee5ng th\u1ebb mua h\u00e0ng ${$ev$$.ma} cho \u0111\u01a1n h\u00e0ng online`));
|
|
24
|
+
if($_e$$.id_ct_used&&$_e$$.id_ct_used!==($obj$$._id||"").toString())return $reject$$(Error(`Th\u1ebb mua h\u00e0ng ${$ev$$.ma} \u0111\u00e3 \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng`));if($_e$$.so_lan_sd>=1&&$_e$$.id_ct_useds&&$_e$$.id_ct_useds.length>0&&($_e$$.id_ct_useds=[...(new Set([...$_e$$.id_ct_useds]))],$_e$$.id_ct_useds.length>=$_e$$.so_lan_sd&&(!$obj$$._id||$_e$$.id_ct_useds.indexOf($obj$$._id)<0)))return $reject$$(Error(`Th\u1ebb mua h\u00e0ng ${$ev$$.ma} \u0111\u00e3 \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng h\u1ebft`));
|
|
25
|
+
if($_e$$.user&&$_e$$.user!==($obj$$.of_user||$obj$$.user_created||$user$$.email))return $reject$$(Error(`Th\u1ebb mua h\u00e0ng ${$ev$$.ma} kh\u00f4ng h\u1ee3p l\u1ec7`));var $date_created_so_tien_giam$$=new Date($obj$$.date_created);if(moment($_e$$.hieu_luc_den).endOf("date").toDate().getTime()<$date_created_so_tien_giam$$.getTime())return $reject$$(Error(`Th\u1ebb mua h\u00e0ng ${$ev$$.ma} \u0111\u00e3 h\u1ebft h\u1ea1n s\u1eed d\u1ee5ng`));if($_e$$.gt_don_hang_toi_thieu&&$gt_don_hang$$<$_e$$.gt_don_hang_toi_thieu)return $reject$$(Error(`Th\u1ebb mua h\u00e0ng ${$ev$$.ma} ch\u1ec9 \u00e1p d\u1ee5ng cho c\u00e1c \u0111\u01a1n h\u00e0ng c\u00f3 gi\u00e1 tr\u1ecb l\u1edbn h\u01a1n ho\u1eb7c b\u1eb1ng ${numeral($_e$$.gt_don_hang_toi_thieu).format()}`));
|
|
26
|
+
if($_e$$.vts&&$_e$$.vts.length>0&&$_e$$.sl_toi_thieu){let $sl_dap_ung$$=0;$_e$$.vts.forEach($vt$$=>{var $ds$jscomp$1_tien$$=$obj$$.details.filter($d$$=>$d$$.ma_vt===$vt$$.ma_vt&&(!$vt$$.ma_tt1||$vt$$.ma_tt1===$d$$.ma_tt1)&&(!$vt$$.ma_tt2||$vt$$.ma_tt2===$d$$.ma_tt2)&&(!$vt$$.ma_tt3||$vt$$.ma_tt3===$d$$.ma_tt3));if($ds$jscomp$1_tien$$.length!=0){var $so_luong$$=$ds$jscomp$1_tien$$.map($d$$=>$d$$.sl_xuat).reduce(($a$$,$b$$)=>$a$$+$b$$,0);$ds$jscomp$1_tien$$=$ds$jscomp$1_tien$$.map($d$$=>($d$$.tien_hang_nt||
|
|
27
|
+
0)-($d$$.tien_ck_nt||0)).reduce(($a$$,$b$$)=>$a$$+$b$$,0);$vt$$.sl_tu&&$so_luong$$<$vt$$.sl_tu||$vt$$.sl_den&&$so_luong$$>$vt$$.sl_den||$vt$$.gt_tu&&$ds$jscomp$1_tien$$<$vt$$.gt_tu||$vt$$.gt_den&&$ds$jscomp$1_tien$$>$vt$$.gt_den||($sl_dap_ung$$+=1)}});if($_e$$.sl_toi_thieu>$sl_dap_ung$$)return $reject$$(Error(`Th\u1ebb mua h\u00e0ng ${$ev$$.ma} kh\u00f4ng h\u1ee3p l\u1ec7 do kh\u00f4ng \u0111\u00e1p \u1ee9ng \u0111\u01b0\u1ee3c y\u00eau c\u1ea7u s\u1ea3n ph\u1ea9m`))}$date_created_so_tien_giam$$=
|
|
28
|
+
$_e$$.so_tien;$_e$$.ty_le&&($date_created_so_tien_giam$$=Math.roundBy($gt_don_hang$$*$_e$$.ty_le/100));$_e$$.so_tien_max&&$date_created_so_tien_giam$$>$_e$$.so_tien_max&&($date_created_so_tien_giam$$=$_e$$.so_tien_max);if($ev$$.so_tien_giam!==$date_created_so_tien_giam$$)return $reject$$(Error(`S\u1ed1 ti\u1ec1n gi\u1ea3m cho th\u1ebb ${$ev$$.ma} kh\u00f4ng h\u1ee3p l\u1ec7`));$ev$$.so_tien_giam=$date_created_so_tien_giam$$;$resolve$$(!0)})()}))},updateEvoucher=async($id_app$$,$evoucher_code$$,$id_ct_rs$$)=>
|
|
29
|
+
{if($evoucher_code$$){$id_ct_rs$$=$id_ct_rs$$.toString();var $e$$=await Evoucher.findOne({ma:$evoucher_code$$,id_app:$id_app$$});$e$$?($id_app$$=$e$$.id_ct_useds||[],$id_app$$.push($id_ct_rs$$),$id_app$$=[...(new Set($id_app$$))],$id_ct_rs$$=await Evoucher.findOneAndUpdate({_id:$e$$._id},{id_ct_useds:$id_app$$}),Logger.info("update id_ct_useds",$evoucher_code$$,$id_app$$,$id_ct_rs$$)):Logger.error("can't find evoucher",$evoucher_code$$)}},deleteEvoucher=async($e$jscomp$3_id_app$$,$evoucher_code$jscomp$1_id_ct_useds$$,
|
|
30
|
+
$id_ct$$)=>{$evoucher_code$jscomp$1_id_ct_useds$$&&($id_ct$$=$id_ct$$.toString(),$e$jscomp$3_id_app$$=await Evoucher.findOne({id_app:$e$jscomp$3_id_app$$,ma:$evoucher_code$jscomp$1_id_ct_useds$$}))&&($evoucher_code$jscomp$1_id_ct_useds$$=($e$jscomp$3_id_app$$.id_ct_useds||[]).filter($ct$$=>$ct$$!==$id_ct$$),await Evoucher.findOneAndUpdate({_id:$e$jscomp$3_id_app$$._id},{id_ct_useds:$evoucher_code$jscomp$1_id_ct_useds$$}))},validOnline=async function($user$$,$obj$$,$_opt_pre_obj_t_tien_evoucher$$){$_opt_pre_obj_t_tien_evoucher$$&&
|
|
31
|
+
($obj$$.tinh_thanh=$obj$$.tinh_thanh||$_opt_pre_obj_t_tien_evoucher$$.tinh_thanh,$obj$$.quan_huyen=$obj$$.quan_huyen||$_opt_pre_obj_t_tien_evoucher$$.quan_huyen,$obj$$.xa_phuong=$obj$$.xa_phuong||$_opt_pre_obj_t_tien_evoucher$$.xa_phuong,$obj$$.ma_freeship=$obj$$.ma_freeship!==void 0?$obj$$.ma_freeship:$_opt_pre_obj_t_tien_evoucher$$.ma_freeship,$obj$$.tien_freeship=$obj$$.tien_freeship!==void 0?$obj$$.tien_freeship:$_opt_pre_obj_t_tien_evoucher$$.ma_freeship);await ($obj$$.details||[]).filter($d$$=>
|
|
32
|
+
!$d$$.ma_dvt&&$d$$.ma_tt1).asyncJoinModel2($user$$.current_id_app,dmtt,{where:{ma_vt:"ma_vt",ma_tt1:"ma_tt"},fields:"ma_dvt"});await ($obj$$.details||[]).filter($d$$=>!$d$$.ma_dvt&&$d$$.ma_tt2).asyncJoinModel2($user$$.current_id_app,dmtt,{where:{ma_vt:"ma_vt",ma_tt2:"ma_tt"},fields:"ma_dvt"});await ($obj$$.details||[]).filter($d$$=>!$d$$.ma_dvt&&$d$$.ma_tt3).asyncJoinModel2($user$$.current_id_app,dmtt,{where:{ma_vt:"ma_vt",ma_tt3:"ma_tt"},fields:"ma_dvt"});await ($obj$$.details||[]).filter($d$$=>
|
|
33
|
+
!$d$$.ma_dvt).asyncJoinModel2($user$$.current_id_app,dmvt,{where:"ma_vt",fields:"ma_dvt"});await ($obj$$.details||[]).asyncJoinModel2($user$$.current_id_app,dmvt,{where:$item$$=>({ma_vt:$item$$.ma_vt}),fields:["ma_danh_muc","khu_vuc_kd","ten_vt","ten_vt_eng"]});var $details_dvgh_t_tien_nt$$=$obj$$.details.filter($d$$=>$d$$.khu_vuc_kd&&$d$$.khu_vuc_kd.length>0);for(var $freeship_i$$=0;$freeship_i$$<$details_dvgh_t_tien_nt$$.length;$freeship_i$$++){var $detail$$=$details_dvgh_t_tien_nt$$[$freeship_i$$],
|
|
34
|
+
$i$$=$detail$$.khu_vuc_kd.find($k$$=>$k$$.tinh_thanh===$obj$$.tinh_thanh);if(!$i$$)throw Error(`Kh\u00f4ng th\u1ec3 giao m\u1eb7t h\u00e0ng ${$detail$$.ten_vt} t\u1edbi ${$obj$$.tinh_thanh}`);if($i$$.quan_huyen&&$i$$.quan_huyen.length>0){$i$$=$i$$.quan_huyen.find($q$$=>$q$$.quan_huyen===$obj$$.quan_huyen);if(!$i$$)throw Error(`Kh\u00f4ng th\u1ec3 giao m\u1eb7t h\u00e0ng ${$detail$$.ten_vt} t\u1edbi ${$obj$$.tinh_thanh}-${$obj$$.quan_huyen}`);if($i$$.xa_phuong&&$i$$.xa_phuong.length>0&&!$i$$.xa_phuong.find($q$$=>
|
|
35
|
+
$q$$.xa_phuong===$obj$$.xa_phuong))throw Error(`Kh\u00f4ng th\u1ec3 giao m\u1eb7t h\u00e0ng ${$detail$$.ten_vt} t\u1edbi ${$obj$$.tinh_thanh}-${$obj$$.quan_huyen} - ${$obj$$.xa_phuong}`);}}const $t_gt_hd$$=$obj$$.details.filter($d$$=>!$d$$.km_yn_for).map($a$$=>$a$$.tien_hang_nt||0).reduce(($a$$,$b$$)=>$a$$+$b$$,0);try{await Promise.all($obj$$.details.map($item$$=>(async()=>{if($item$$.km_yn_for&&$item$$.km_yn_for.toUpperCase()!="SO1")$item$$.gia_ban=$item$$.gia_ban_nt=0,$item$$.tien_ck=$item$$.tien_ck_nt=
|
|
36
|
+
0,$item$$.tien_hang=$item$$.tien_hang_nt=0,$item$$.tien=$item$$.tien_nt=0;else if(!$item$$.km_yn_for||$item$$.km_yn_for.toUpperCase()=="SO1"){if($item$$.km_yn_for&&$item$$.km_yn_for.toUpperCase()=="SO1"&&!$item$$.id_cs)throw Error("S\u1ea3n ph\u1ea9m mua th\u00eam theo ch\u00ednh s\u00e1ch chi\u1ebft kh\u1ea5u thi\u1ebfu id_cs");var $condition$$={ma_vt:$item$$.ma_vt,id_app:$user$$.current_id_app,user:{email:$obj$$.user_created},ma_kh:$obj$$.ma_kh,ngay_ct:$obj$$.ngay_ct};$item$$.ma_tt1&&($condition$$.ma_tt1=
|
|
37
|
+
$item$$.ma_tt1);$item$$.ma_tt2&&($condition$$.ma_tt2=$item$$.ma_tt2);$item$$.ma_tt3&&($condition$$.ma_tt3=$item$$.ma_tt3);$condition$$.sl_xuat=$item$$.sl_xuat;$condition$$.online=!0;$condition$$.t_gt_hd=$t_gt_hd$$;if($condition$$=await getGiaBan($condition$$)){if($item$$.gia_ban_nt!=$condition$$.gia_ban_le)throw Error("Gi\u00e1 b\u00e1n kh\u00f4ng h\u1ee3p l\u1ec7");if($item$$.km_yn_for&&$item$$.km_yn_for.toUpperCase()=="SO1"){let $dc$$=($condition$$.discount||[]).find($r$$=>$r$$._id===$item$$.id_cs&&
|
|
38
|
+
$r$$.mua_them&&$r$$.gt_hd_tu>0&&$r$$.gt_hd_tu<=$t_gt_hd$$&&(!$r$$.gt_hd_den||$r$$.gt_hd_den>=$t_gt_hd$$));if(!$dc$$)throw Error("S\u1ea3n ph\u1ea9m mua th\u00eam theo ch\u00ednh s\u00e1ch chi\u1ebft kh\u1ea5u c\u00f3 id_cs kh\u00f4ng h\u1ee3p l\u1ec7");$condition$$.ty_le_ck=$dc$$.ty_le_ck;$condition$$.tien_ck=$dc$$.tien_ck;$condition$$.sl_tu=$dc$$.sl_tu;$condition$$.gt_hd_tu=$dc$$.gt_hd_tu;$condition$$.gt_hd_den=$dc$$.gt_hd_den;$condition$$.sl_ap_dung=$dc$$.sl_ap_dung;$condition$$.so_tien_max=$dc$$.so_tien_max}$item$$.tien_ck=
|
|
39
|
+
0;$item$$.tien_ck_nt=0;$item$$.ty_le_ck=0;delete $condition$$._id;delete $condition$$.ma_vt;delete $condition$$.ten_vt;_.extend($item$$,$condition$$);$item$$.gia_ban=$item$$.gia_ban_nt=$item$$.gia_ban_le;$item$$.gia_ban_ct=$item$$.gia_ban_ct_nt=$item$$.gia_ban_le_ct;$condition$$.sl_ap_dung?$item$$.tien_ck?($item$$.tien_ck=$item$$.tien_ck_nt=Math.roundBy(($item$$.tien_ck||0)*Math.min($item$$.sl_xuat,$condition$$.sl_ap_dung)),$item$$.ty_le_ck=0):$item$$.tien_ck=$item$$.tien_ck_nt=Math.roundBy(($item$$.ty_le_ck||
|
|
40
|
+
0)*$item$$.gia_ban_ct_nt/100*Math.min($item$$.sl_xuat,$condition$$.sl_ap_dung)):$item$$.tien_ck?($item$$.tien_ck=$item$$.tien_ck_nt=Math.roundBy(($item$$.tien_ck||0)*$item$$.sl_xuat),$item$$.ty_le_ck=0):$item$$.tien_ck=$item$$.tien_ck_nt=Math.roundBy(($item$$.ty_le_ck||0)*$item$$.gia_ban_ct_nt/100*$item$$.sl_xuat)}else $item$$.gia_ban=$item$$.gia_ban_nt=$item$$.gia_ban_le0;$item$$.tien_hang=$item$$.tien_hang_nt=Math.roundBy($item$$.gia_ban*$item$$.sl_xuat);$item$$.tien_hang_ct=$item$$.tien_hang_ct_nt=
|
|
41
|
+
Math.roundBy($item$$.gia_ban_ct*$item$$.sl_xuat);$item$$.so_tien_max&&($item$$.tien_ck=$item$$.tien_ck_nt=Math.min($item$$.so_tien_max,$item$$.tien_ck_nt));$item$$.tien=$item$$.tien_nt=$item$$.tien_hang_ct-($item$$.tien_ck||0)+($item$$.tien_thue||0);$item$$.ma_thue?$item$$.tien_thue=$item$$.tien_thue_nt=Math.roundBy(($item$$.tien_hang_ct_nt-$item$$.tien_ck_nt)*$item$$.thue_suat/100):($item$$.tien_thue=0,$item$$.tien_thue_nt=0)}})()))}catch($e$$){throw Error($e$$.message);}$details_dvgh_t_tien_nt$$=
|
|
42
|
+
$obj$$.details.map($a$$=>($a$$.tien_hang_ct_nt||0)-($a$$.tien_ck_nt||0)+($a$$.tien_thue_nt||0)).reduce(($a$$,$b$$)=>$a$$+$b$$,0)-($obj$$.tien_ck_hd||0);$obj$$.ngay_ct=new Date($obj$$.ngay_ct);if($obj$$.tien_freeship){if(!$obj$$.ma_freeship)throw Error("Ti\u1ec1n mi\u1ec5n ph\u00ed v\u1eadn chuy\u1ec3n kh\u00f4ng h\u1ee3p l\u1ec7 do kh\u00f4ng c\u00f3 m\u00e3 freeship");$freeship_i$$=await global.getModel("ecompromotion_freeships").findOne({id_app:$obj$$.id_app,ma_chietkhau:$obj$$.ma_freeship,status:!0,
|
|
43
|
+
trang_thai:"1",hieu_luc_tu:{$lte:$obj$$.ngay_ct},hieu_luc_den:{$gte:$obj$$.ngay_ct}});if(!$freeship_i$$)throw Error(`M\u00e3 freeship ${$obj$$.ma_freeship} kh\u00f4ng t\u1ed3n t\u1ea1i ho\u1eb7c kh\u00f4ng c\u00f3 hi\u1ec7u l\u1ef1c`);if($freeship_i$$.phi_van_chuyen<$obj$$.tien_freeship)throw Error("Ti\u1ec1n mi\u1ec5n ph\u00ed v\u1eadn chuy\u1ec3n ph\u1ea3i nh\u1ecf h\u01a1n ho\u1eb7c b\u1eb1ng ti\u1ec1n mi\u1ec5n ph\u00ed v\u1eadn chuy\u1ec3n trong ch\u00ednh s\u00e1ch freeship");if($freeship_i$$.gia_tri_dh&&
|
|
44
|
+
$freeship_i$$.gia_tri_dh>$details_dvgh_t_tien_nt$$)throw Error("Ti\u1ec1n mi\u1ec5n ph\u00ed v\u1eadn chuy\u1ec3n kh\u00f4ng h\u1ee3p l\u1ec7. Gi\u00e1 tr\u1ecb \u0111\u01a1n h\u00e0ng ph\u1ea3i >="+$freeship_i$$.gia_tri_dh);if($freeship_i$$.details&&$freeship_i$$.details.length>0){$detail$$=!1;for($i$$=0;$i$$<$freeship_i$$.details.length;$i$$++){let $free$$=$freeship_i$$.details[$i$$];if($free$$.ma_vt){if($obj$$.details.find($d$$=>$d$$.ma_vt===$free$$.ma_vt)){$detail$$=!0;break}}else if($free$$.ma_danh_muc&&
|
|
45
|
+
$obj$$.details.find($d$$=>$d$$.ma_danh_muc===$free$$.ma_danh_muc)){$detail$$=!0;break}}if(!$detail$$)throw Error("Ti\u1ec1n mi\u1ec5n ph\u00ed v\u1eadn chuy\u1ec3n kh\u00f4ng h\u1ee3p l\u1ec7");}if($obj$$.tien_phi_vc<$obj$$.tien_freeship)throw Error("Ti\u1ec1n mi\u1ec5n ph\u00ed v\u1eadn chuy\u1ec3n ph\u1ea3i nh\u1ecf h\u01a1n ho\u1eb7c b\u1eb1ng ti\u1ec1n ph\u00ed v\u1eadn chuy\u1ec3n");}try{var $_checkEvoucher_tien_con_lai$$=checkEvoucher($user$$,$obj$$,$_opt_pre_obj_t_tien_evoucher$$);await Promise.all($_checkEvoucher_tien_con_lai$$)}catch($e$$){throw Logger.error($e$$),
|
|
46
|
+
Error($e$$.message||$e$$);}$obj$$.evouchers=$obj$$.evouchers||($_opt_pre_obj_t_tien_evoucher$$||{}).evouchers||[];$_opt_pre_obj_t_tien_evoucher$$=$obj$$.evouchers.map($e$$=>$e$$.so_tien_giam||0).reduce(($a$$,$b$$)=>$a$$+$b$$,0);$_checkEvoucher_tien_con_lai$$=$details_dvgh_t_tien_nt$$-($obj$$.tt_tien_thuong||0);$_opt_pre_obj_t_tien_evoucher$$>$_checkEvoucher_tien_con_lai$$&&($_opt_pre_obj_t_tien_evoucher$$=$_checkEvoucher_tien_con_lai$$);$obj$$.tien_evoucher=$_opt_pre_obj_t_tien_evoucher$$;if($obj$$.tien_evoucher&&
|
|
47
|
+
($_opt_pre_obj_t_tien_evoucher$$=await options.findOne({id_app:$obj$$.id_app,id_func:$obj$$.ma_ct.toLowerCase()}).lean())&&$_opt_pre_obj_t_tien_evoucher$$.option&&$_opt_pre_obj_t_tien_evoucher$$.option.phan_bo_evoucher){let $tien_evoucher_da_phan_bo$$=0,$tien_evoucher$$=$obj$$.tien_evoucher,$tien_evoucher_con_lai$$=$tien_evoucher$$-$tien_evoucher_da_phan_bo$$;($obj$$.details||[]).forEach($detail$$=>{if($tien_evoucher_con_lai$$>0){var $tien_evoucher_duoc_pb_tien_hang_con_lai$$=$detail$$.tien_hang_nt-
|
|
48
|
+
($detail$$.tien_ck_nt||0);$tien_evoucher_duoc_pb_tien_hang_con_lai$$=$tien_evoucher_con_lai$$>$tien_evoucher_duoc_pb_tien_hang_con_lai$$?$tien_evoucher_duoc_pb_tien_hang_con_lai$$:$tien_evoucher_con_lai$$;$detail$$.tien_evoucher_duoc_pb=$tien_evoucher_duoc_pb_tien_hang_con_lai$$;$tien_evoucher_da_phan_bo$$+=$tien_evoucher_duoc_pb_tien_hang_con_lai$$;$tien_evoucher_con_lai$$=$tien_evoucher$$-$tien_evoucher_da_phan_bo$$}else $tien_evoucher_con_lai$$=0})}},valid=async function($user$$,$obj$$,$next$$,
|
|
49
|
+
$detail$jscomp$5_i$jscomp$3_pre_obj$$){$detail$jscomp$5_i$jscomp$3_pre_obj$$&&($obj$$.online=$detail$jscomp$5_i$jscomp$3_pre_obj$$.online,$obj$$._id=$detail$jscomp$5_i$jscomp$3_pre_obj$$._id,$obj$$.details=$obj$$.details||$detail$jscomp$5_i$jscomp$3_pre_obj$$.details||[],$obj$$.evouchers=$obj$$.evouchers||$detail$jscomp$5_i$jscomp$3_pre_obj$$.evouchers);await $obj$$.details.asyncJoinModel2($obj$$.id_app,"vat",{where:"ma_thue",fields:["thue_suat","tk_thue_co","tk_thue_co_treo"]});if($obj$$.online)try{await validOnline($user$$,
|
|
50
|
+
$obj$$,$detail$jscomp$5_i$jscomp$3_pre_obj$$)}catch($e$$){return $next$$($e$$.message)}else for($detail$jscomp$5_i$jscomp$3_pre_obj$$=0;$detail$jscomp$5_i$jscomp$3_pre_obj$$<($obj$$.details||[]).length;$detail$jscomp$5_i$jscomp$3_pre_obj$$++)validOffline(($obj$$.details||[])[$detail$jscomp$5_i$jscomp$3_pre_obj$$]);if($obj$$.paymentByPoints)try{var $he_so_qd_i$$=await currency.getRate($obj$$.id_app,$obj$$.ma_nt);$obj$$.tien_paymentByPoints=$obj$$.paymentByPoints*($he_so_qd_i$$||1)}catch($e$$){return $next$$($e$$.message)}for($he_so_qd_i$$=
|
|
51
|
+
0;$he_so_qd_i$$<($obj$$.details||[]).length;$he_so_qd_i$$++)$detail$jscomp$5_i$jscomp$3_pre_obj$$=($obj$$.details||[])[$he_so_qd_i$$],$detail$jscomp$5_i$jscomp$3_pre_obj$$.line=$he_so_qd_i$$,$obj$$.ma_nt==="VND"&&($detail$jscomp$5_i$jscomp$3_pre_obj$$.tien_hang=$detail$jscomp$5_i$jscomp$3_pre_obj$$.tien_hang_nt,$detail$jscomp$5_i$jscomp$3_pre_obj$$.tien_hang_ct=$detail$jscomp$5_i$jscomp$3_pre_obj$$.tien_hang_ct_nt,$detail$jscomp$5_i$jscomp$3_pre_obj$$.tien_ck=$detail$jscomp$5_i$jscomp$3_pre_obj$$.tien_ck_nt||
|
|
52
|
+
0,$detail$jscomp$5_i$jscomp$3_pre_obj$$.gia_ban=$detail$jscomp$5_i$jscomp$3_pre_obj$$.gia_ban_nt,$detail$jscomp$5_i$jscomp$3_pre_obj$$.gia_ban_ct=$detail$jscomp$5_i$jscomp$3_pre_obj$$.gia_ban_ct_nt,$detail$jscomp$5_i$jscomp$3_pre_obj$$.tien_thue=$detail$jscomp$5_i$jscomp$3_pre_obj$$.tien_thue_nt||0),$detail$jscomp$5_i$jscomp$3_pre_obj$$.tien_nt=Math.max(0,$detail$jscomp$5_i$jscomp$3_pre_obj$$.tien_hang_ct_nt-$detail$jscomp$5_i$jscomp$3_pre_obj$$.tien_ck_nt+$detail$jscomp$5_i$jscomp$3_pre_obj$$.tien_thue_nt),
|
|
53
|
+
$detail$jscomp$5_i$jscomp$3_pre_obj$$.tien=Math.max(0,$detail$jscomp$5_i$jscomp$3_pre_obj$$.tien_hang-$detail$jscomp$5_i$jscomp$3_pre_obj$$.tien_ck+$detail$jscomp$5_i$jscomp$3_pre_obj$$.tien_thue),$detail$jscomp$5_i$jscomp$3_pre_obj$$.tien_xuat=$detail$jscomp$5_i$jscomp$3_pre_obj$$.tien_xuat_nt;$obj$$.ma_dvcs?$next$$(null,$obj$$):dvcs.findOne({id_app:$user$$.current_id_app},{_id:1},function($error$$,$dv$$){return $error$$?$next$$($error$$):$dv$$?($obj$$.ma_dvcs=$dv$$._id.toString(),$next$$(null,$obj$$)):
|
|
54
|
+
$next$$("C\u00f4ng ty/c\u1eeda h\u00e0ng n\u00e0y ch\u01b0a c\u00f3 m\u1ed9t \u0111\u01a1n v\u1ecb c\u01a1 s\u1edf n\u00e0o")})};
|
|
55
|
+
module.exports=function($contr_router$$){$contr_router$$=new controller($contr_router$$,model,ma_ct.toLowerCase(),{isVoucher:!0,requireRecaptchaToken:!1,kiem_tra_han_muc_cong_no:!0,unique:["so_ct"],sort:{ngay_ct:-1,so_ct:-1},onEmitEvent:async($obj$$,$users_will_receive$$,$next$$)=>{$obj$$.user_nv_giao_hang&&$users_will_receive$$.push($obj$$.user_nv_giao_hang);$next$$(null,$users_will_receive$$)}});$contr_router$$.route();$contr_router$$.saving=async($user$$,$obj$$)=>{$obj$$.user_created||($obj$$.user_created=
|
|
56
|
+
$user$$.email);$obj$$.details.forEach($d$$=>{$d$$.tien_xuat_tmp=$d$$.sl_xuat*($d$$.gia_mua||0)});await chietkhauhd($obj$$);await khuyenmaihd($obj$$);$obj$$.details.forEach($d$$=>{$d$$.sl_xuat=utils.round($d$$.sl_xuat,4);$d$$.tt_nt=($d$$.tien_han_ct_nt||0)-($d$$.tien_ck_nt||0);$d$$.tt=($d$$.tien_hang_ct||0)-($d$$.tien_ck||0)});await tinhhoahong($obj$$,$user$$)};$contr_router$$.handleAfterPayment=async $obj$$=>{Logger.info("[so1][handleAfterPayment]",$obj$$);$obj$$.trang_thai_tt="5";$obj$$.trang_thai=
|
|
57
|
+
"1";await model.updateOne({_id:$obj$$._id},{details:$obj$$.details,trang_thai_tt:"5",trang_thai:"1"});let $ctrlSO1$$=global.controllers.SO1;$ctrlSO1$$&&(await controller.asyncPostData($obj$$,$ctrlSO1$$),controller.pushNotification($ctrlSO1$$,$obj$$));return null};$contr_router$$.post=async function($obj$$,$fn$$,$_options$$={}){$fn$$||=function(){};let $he_so_qd$$=await currency.getRate($obj$$.id_app,$obj$$.ma_nt)||1;const $appInfo$$=await global.getModel("app").findOne({_id:$obj$$.id_app}).lean();
|
|
58
|
+
await $obj$$.details.filter($d$$=>!$d$$.ma_thue).asyncJoinModel2($obj$$.id_app,dmvt,{where:"ma_vt",fields:["ma_thue","gia_mua"]});await $obj$$.details.filter($d$$=>$d$$.ma_thue).asyncJoinModel2($obj$$.id_app,global.getModel("vat"),{where:"ma_thue",fields:["thue_suat","tk_thue_co","tk_thue_co_treo"]});let $product_details$$=$obj$$.details.map($detail$$=>$detail$$.combo&&$detail$$.combo.length>0?$detail$$.combo.map($item$$=>{$item$$=$item$$.toObject?$item$$.toObject():{...$item$$};delete $item$$.px_gia_dd;
|
|
59
|
+
$item$$.ma_kho=$detail$$.ma_kho;return $item$$}):[$detail$$]).reduce(($a$$,$b$$)=>$a$$.concat($b$$),[]),$ket_qua_post_sokho$$;async.series({post_sokho:function($callback$$){(new PostSokho($obj$$,$product_details$$,async function($detail$$,$callback$$){$detail$$.nxt=2;$detail$$.ngay_ct=$obj$$.ngay_giao_hang||$obj$$.ngay_ct;$detail$$.ma_kho=$detail$$.ma_kho||$obj$$.ma_kho;$callback$$($detail$$)})).run(function($e$$,$rs$$){if($e$$)return $callback$$($e$$);$ket_qua_post_sokho$$=$rs$$.rs_sokho;$callback$$(null,
|
|
60
|
+
$rs$$)})},post_socai:function($callback$$){options.findOne({id_app:$obj$$.id_app,id_func:ma_ct.toLowerCase()}).lean().exec(async($error$jscomp$3_t_tt_tien_ck_hd_tt_tt$jscomp$1_tt$jscomp$2_tt$$,$rs$jscomp$3_tien_paymentByPoints_tt$$)=>{let $option$$;$option$$=$rs$jscomp$3_tien_paymentByPoints_tt$$?$rs$jscomp$3_tien_paymentByPoints_tt$$.option||{}:{};let $kho$$=await dmkho.findOne({id_app:$obj$$.id_app,ma_kho:$obj$$.ma_kho}).lean();$kho$$||={};let $pt$$;$obj$$.pt_thanh_toan&&global.mongoose.Types.ObjectId.isValid($obj$$.pt_thanh_toan)&&
|
|
61
|
+
($pt$$=await ptthanhtoan.findOne({id_app:$obj$$.id_app,_id:$obj$$.pt_thanh_toan}).lean());$pt$$=$pt$$||{};$pt$$.tk_tien=$pt$$.tk_cn;$pt$$.tk_cn=$pt$$.tk_cn||$kho$$.tk_cn;$pt$$.tk_dt=$kho$$.tk_dt||$pt$$.tk_dt;$pt$$.tk_gv=$kho$$.tk_gv||$pt$$.tk_gv;$pt$$.tk_ck=$kho$$.tk_ck||$pt$$.tk_ck;$pt$$.tk_cp_gh=$kho$$.tk_cp_gh||$pt$$.tk_cp_gh;$pt$$.tk_cp_bh=$kho$$.tk_cp_bh||$pt$$.tk_cp_bh;$pt$$.tk_cp_ctv=$kho$$.tk_cp_ctv||$pt$$.tk_cp_ctv;$pt$$.tk_cn_ctv=$kho$$.tk_cn_ctv||$pt$$.tk_cn_ctv;$option$$.tk_tien=$pt$$.tk_tien||
|
|
62
|
+
$kho$$.tk_tien||$option$$.tk_tien||"1111";$option$$.tk_cn=$pt$$.tk_cn||$option$$.tk_cn||"131111";$option$$.tk_dt=$pt$$.tk_dt||$option$$.tk_dt||"51111";$option$$.tk_tl=$pt$$.tk_tl||$option$$.tk_tl||"52131";$option$$.tk_ck=$pt$$.tk_ck||$option$$.tk_ck||"52111";$option$$.tk_gv=$pt$$.tk_gv||$option$$.tk_gv||"6321";$option$$.tk_cp_gh=$pt$$.tk_cp_gh||$option$$.tk_cp_gh||"6418";$option$$.tk_cp_bh=$pt$$.tk_cp_bh||$option$$.tk_cp_bh||$option$$.tk_ck;$option$$.tk_cp_ctv=$pt$$.tk_cp_ctv||$option$$.tk_cp_ctv;
|
|
63
|
+
$option$$.tk_cn_ctv=$pt$$.tk_cn_ctv||$option$$.tk_cn_ctv;$pt$$.ten&&$pt$$.ten.indexOf("COD")>=0?$option$$.ma_kh=$obj$$.nhan_vien_giao_hang||$obj$$.don_vi_vc||$pt$$.ma_kh||$obj$$.ma_kh:$option$$.ma_kh=$pt$$.ma_kh||$obj$$.ma_kh;const $details$$=[];$error$jscomp$3_t_tt_tien_ck_hd_tt_tt$jscomp$1_tt$jscomp$2_tt$$=$obj$$.details.map($a$$=>($a$$.tien_hang_nt||0)-($a$$.tien_ck_nt||0)).reduce(($a$$,$b$$)=>$a$$+$b$$,0)-(($obj$$.tt_tien_thuong||0)+($obj$$.tien_ck_hd||0)+($obj$$.tien_evoucher||0));$rs$jscomp$3_tien_paymentByPoints_tt$$=
|
|
64
|
+
$obj$$.tien_paymentByPoints||0;const $hoachtoandtvathue$$=($tk_tien$$,$ty_le$$)=>{$obj$$.details.forEach(function($d$jscomp$25_detail$$){$d$jscomp$25_detail$$={...$d$jscomp$25_detail$$};let $tien_nt$$;$tien_nt$$=$d$jscomp$25_detail$$.tien_hang_ct_nt;$d$jscomp$25_detail$$.tk_co=$option$$.tk_dt;$d$jscomp$25_detail$$.tk_no=$tk_tien$$;$d$jscomp$25_detail$$.ma_kh_co=$obj$$.ma_kh;$d$jscomp$25_detail$$.ma_kh_no=$option$$.ma_kh;$d$jscomp$25_detail$$.ngay_ct=$obj$$.ngay_giao_hang||$obj$$.ngay_ct;$d$jscomp$25_detail$$.tien=
|
|
65
|
+
$d$jscomp$25_detail$$.tien_nt=Math.roundBy($tien_nt$$*$ty_le$$);$d$jscomp$25_detail$$.flag="DT_"+($d$jscomp$25_detail$$.ma_vt||"");$details$$.push($d$jscomp$25_detail$$)});$obj$$.details.filter($d$$=>$d$$.tien_thue).forEach($detail$$=>{$detail$$={...$detail$$};$detail$$.tk_no=$tk_tien$$;$detail$$.tk_co=$detail$$.tk_thue_co_treo||$detail$$.tk_thue_co;$detail$$.ma_kh||($detail$$.ma_kh=$pt$$.ma_kh||$obj$$.ma_kh);$detail$$.tien=$detail$$.tien_nt=Math.roundBy($detail$$.tien_thue_nt*$ty_le$$);$detail$$.flag=
|
|
66
|
+
"THUE_"+($detail$$.ma_vt||"");$details$$.push($detail$$)})};$error$jscomp$3_t_tt_tien_ck_hd_tt_tt$jscomp$1_tt$jscomp$2_tt$$&&($hoachtoandtvathue$$($option$$.tk_cn,$rs$jscomp$3_tien_paymentByPoints_tt$$/$error$jscomp$3_t_tt_tien_ck_hd_tt_tt$jscomp$1_tt$jscomp$2_tt$$),$hoachtoandtvathue$$($option$$.tk_tien,($error$jscomp$3_t_tt_tien_ck_hd_tt_tt$jscomp$1_tt$jscomp$2_tt$$-$rs$jscomp$3_tien_paymentByPoints_tt$$)/$error$jscomp$3_t_tt_tien_ck_hd_tt_tt$jscomp$1_tt$jscomp$2_tt$$));$obj$$.details.filter($d$$=>
|
|
67
|
+
$d$$.diem_thuong&&$d$$.tk_km_no&&$d$$.tk_km_co).forEach(function($d$$){let $detail$$={...$d$$};$detail$$.tk_co=$option$$.tk_km_co||$d$$.tk_km_co;$detail$$.tk_no=$option$$.tk_km_no||$d$$.tk_km_no;$detail$$.ma_kh=$obj$$.ma_kh;$detail$$.tien=$detail$$.tien_nt=$detail$$.diem_thuong*$he_so_qd$$;$details$$.push($detail$$)});$obj$$.ctcpbhs&&$obj$$.ctcpbhs.forEach(function($d$jscomp$29_detail$$){$d$jscomp$29_detail$$={...$d$jscomp$29_detail$$};$d$jscomp$29_detail$$.tk_co=$option$$.tk_dt;$d$jscomp$29_detail$$.tk_no=
|
|
68
|
+
$option$$.tk_cn;$d$jscomp$29_detail$$.ma_kh_co=$obj$$.ma_kh;$d$jscomp$29_detail$$.ma_kh_no=$option$$.ma_kh;$d$jscomp$29_detail$$.ngay_ct=$obj$$.ngay_giao_hang||$obj$$.ngay_ct;$d$jscomp$29_detail$$.tien_nt=$d$jscomp$29_detail$$.tien_cp_nt;$d$jscomp$29_detail$$.tien=$d$jscomp$29_detail$$.tien_cp;$details$$.push($d$jscomp$29_detail$$)});$obj$$.tien_phi_vc&&$option$$.tk_phi_vc&&($error$jscomp$3_t_tt_tien_ck_hd_tt_tt$jscomp$1_tt$jscomp$2_tt$$={},$error$jscomp$3_t_tt_tien_ck_hd_tt_tt$jscomp$1_tt$jscomp$2_tt$$.tk_co=
|
|
69
|
+
$option$$.tk_phi_vc,$error$jscomp$3_t_tt_tien_ck_hd_tt_tt$jscomp$1_tt$jscomp$2_tt$$.tk_no=$option$$.tk_cn,$error$jscomp$3_t_tt_tien_ck_hd_tt_tt$jscomp$1_tt$jscomp$2_tt$$.tien_nt=$obj$$.tien_phi_vc||0,$error$jscomp$3_t_tt_tien_ck_hd_tt_tt$jscomp$1_tt$jscomp$2_tt$$.tien=$error$jscomp$3_t_tt_tien_ck_hd_tt_tt$jscomp$1_tt$jscomp$2_tt$$.tien_nt,$error$jscomp$3_t_tt_tien_ck_hd_tt_tt$jscomp$1_tt$jscomp$2_tt$$.ma_kh_co=$obj$$.ma_kh,$error$jscomp$3_t_tt_tien_ck_hd_tt_tt$jscomp$1_tt$jscomp$2_tt$$.ma_kh_no=$obj$$.nhan_vien_giao_hang||
|
|
70
|
+
$obj$$.don_vi_vc,$details$$.push($error$jscomp$3_t_tt_tien_ck_hd_tt_tt$jscomp$1_tt$jscomp$2_tt$$));$obj$$.tien_freeship&&($error$jscomp$3_t_tt_tien_ck_hd_tt_tt$jscomp$1_tt$jscomp$2_tt$$={},$error$jscomp$3_t_tt_tien_ck_hd_tt_tt$jscomp$1_tt$jscomp$2_tt$$.tk_no=$option$$.tk_cp_gh,$error$jscomp$3_t_tt_tien_ck_hd_tt_tt$jscomp$1_tt$jscomp$2_tt$$.tk_co=$option$$.tk_cn,$error$jscomp$3_t_tt_tien_ck_hd_tt_tt$jscomp$1_tt$jscomp$2_tt$$.tien_nt=$obj$$.tien_freeship||0,$error$jscomp$3_t_tt_tien_ck_hd_tt_tt$jscomp$1_tt$jscomp$2_tt$$.tien=
|
|
71
|
+
$error$jscomp$3_t_tt_tien_ck_hd_tt_tt$jscomp$1_tt$jscomp$2_tt$$.tien_nt,$error$jscomp$3_t_tt_tien_ck_hd_tt_tt$jscomp$1_tt$jscomp$2_tt$$.ma_kh_no=$obj$$.ma_kh,$error$jscomp$3_t_tt_tien_ck_hd_tt_tt$jscomp$1_tt$jscomp$2_tt$$.ma_kh_co=$option$$.ma_kh,$details$$.push($error$jscomp$3_t_tt_tien_ck_hd_tt_tt$jscomp$1_tt$jscomp$2_tt$$));$obj$$.tt_tien_thuong&&($error$jscomp$3_t_tt_tien_ck_hd_tt_tt$jscomp$1_tt$jscomp$2_tt$$={},$error$jscomp$3_t_tt_tien_ck_hd_tt_tt$jscomp$1_tt$jscomp$2_tt$$.tk_no=$option$$.tk_cp_bh,
|
|
72
|
+
$error$jscomp$3_t_tt_tien_ck_hd_tt_tt$jscomp$1_tt$jscomp$2_tt$$.tk_co=$option$$.tk_cn,$error$jscomp$3_t_tt_tien_ck_hd_tt_tt$jscomp$1_tt$jscomp$2_tt$$.tien_nt=$obj$$.tt_tien_thuong||0,$error$jscomp$3_t_tt_tien_ck_hd_tt_tt$jscomp$1_tt$jscomp$2_tt$$.tien=$error$jscomp$3_t_tt_tien_ck_hd_tt_tt$jscomp$1_tt$jscomp$2_tt$$.tien_nt,$error$jscomp$3_t_tt_tien_ck_hd_tt_tt$jscomp$1_tt$jscomp$2_tt$$.ma_kh_no=$obj$$.ma_kh,$error$jscomp$3_t_tt_tien_ck_hd_tt_tt$jscomp$1_tt$jscomp$2_tt$$.ma_kh_co=$option$$.ma_kh,$details$$.push($error$jscomp$3_t_tt_tien_ck_hd_tt_tt$jscomp$1_tt$jscomp$2_tt$$));
|
|
73
|
+
$obj$$.tien_evoucher&&($error$jscomp$3_t_tt_tien_ck_hd_tt_tt$jscomp$1_tt$jscomp$2_tt$$={},$error$jscomp$3_t_tt_tien_ck_hd_tt_tt$jscomp$1_tt$jscomp$2_tt$$.tk_no=$obj$$.tk_no_evoucher||$option$$.tk_no_evoucher||$option$$.tk_ck,$error$jscomp$3_t_tt_tien_ck_hd_tt_tt$jscomp$1_tt$jscomp$2_tt$$.tk_co=$obj$$.tk_co_evoucher||$option$$.tk_co_evoucher||$option$$.tk_cn,$error$jscomp$3_t_tt_tien_ck_hd_tt_tt$jscomp$1_tt$jscomp$2_tt$$.tien_nt=$obj$$.tien_evoucher||0,$error$jscomp$3_t_tt_tien_ck_hd_tt_tt$jscomp$1_tt$jscomp$2_tt$$.tien=
|
|
74
|
+
$error$jscomp$3_t_tt_tien_ck_hd_tt_tt$jscomp$1_tt$jscomp$2_tt$$.tien_nt,$error$jscomp$3_t_tt_tien_ck_hd_tt_tt$jscomp$1_tt$jscomp$2_tt$$.ma_kh_no=$obj$$.ma_kh,$error$jscomp$3_t_tt_tien_ck_hd_tt_tt$jscomp$1_tt$jscomp$2_tt$$.ma_kh_co=$option$$.ma_kh,$error$jscomp$3_t_tt_tien_ck_hd_tt_tt$jscomp$1_tt$jscomp$2_tt$$.check_balance=!1,$details$$.push($error$jscomp$3_t_tt_tien_ck_hd_tt_tt$jscomp$1_tt$jscomp$2_tt$$));if($error$jscomp$3_t_tt_tien_ck_hd_tt_tt$jscomp$1_tt$jscomp$2_tt$$=($obj$$.tien_ck_hd||0)+$obj$$.details.map($d$$=>
|
|
75
|
+
$d$$.tien_ck||0).reduce(($a$$,$b$$)=>$a$$+$b$$,0))$rs$jscomp$3_tien_paymentByPoints_tt$$={},$rs$jscomp$3_tien_paymentByPoints_tt$$.tk_no=$option$$.tk_ck,$rs$jscomp$3_tien_paymentByPoints_tt$$.tk_co=$option$$.tk_cn,$rs$jscomp$3_tien_paymentByPoints_tt$$.tien_nt=$error$jscomp$3_t_tt_tien_ck_hd_tt_tt$jscomp$1_tt$jscomp$2_tt$$,$rs$jscomp$3_tien_paymentByPoints_tt$$.tien=$rs$jscomp$3_tien_paymentByPoints_tt$$.tien_nt,$rs$jscomp$3_tien_paymentByPoints_tt$$.ma_kh_no=$obj$$.ma_kh,$rs$jscomp$3_tien_paymentByPoints_tt$$.ma_kh_co=
|
|
76
|
+
$option$$.ma_kh,$rs$jscomp$3_tien_paymentByPoints_tt$$.check_balance=!1,$details$$.push($rs$jscomp$3_tien_paymentByPoints_tt$$);$obj$$.thu_nhap_ctv&&($obj$$.details.filter($r$$=>$r$$.tien_hoa_hong_ctv).forEach($r$$=>{$r$$.tk_cp_ctv=$r$$.tk_cp_ctv||$obj$$.tk_cp_ctv||$kho$$.tk_cp_ctv||options.tk_cp_ctv||$obj$$.tk_no_hoa_hong||$kho$$.tk_no_hoa_hong||options.tk_no_hoa_hong;$r$$.tk_cn_ctv=$r$$.tk_cn_ctv||$obj$$.tk_cn_ctv||$kho$$.tk_cn_ctv||options.tk_cn_ctv||$obj$$.tk_co_hoa_hong||$kho$$.tk_co_hoa_hong||
|
|
77
|
+
options.tk_co_hoa_hong}),(await $obj$$.details.filter($r$$=>$r$$.tien_hoa_hong_ctv).asyncGroupBy(["tk_cp_ctv","tk_cn_ctv"],["tien_hoa_hong_ctv"])).forEach($r$$=>{let $tt$$={};$tt$$.tk_no=$r$$.tk_cp_ctv;$tt$$.tk_co=$r$$.tk_cn_ctv;$tt$$.tien=$tt$$.tien_nt=$r$$.tien_hoa_hong_ctv;$tt$$.ma_kh=$obj$$.ma_ctv;$tt$$.ma_nt="VND";$tt$$.ty_gia=1;$tt$$.tk_no&&$tt$$.tk_co&&$details$$.push($tt$$)}));$obj$$.tien_hoa_hong&&$obj$$.ma_kh_hoa_hong&&($obj$$.details.filter($r$$=>$r$$.tien_hoa_hong).forEach($r$$=>{$r$$.tk_no_hoa_hong=
|
|
78
|
+
$r$$.tk_no_hoa_hong||$obj$$.tk_no_hoa_hong||$kho$$.tk_no_hoa_hong||options.tk_no_hoa_hong;$r$$.tk_co_hoa_hong=$r$$.tk_co_hoa_hong||$obj$$.tk_co_hoa_hong||$kho$$.tk_co_hoa_hong||options.tk_co_hoa_hong}),(await $obj$$.details.filter($r$$=>$r$$.tien_hoa_hong).asyncGroupBy(["tk_no_hoa_hong","tk_co_hoa_hong"],["tien_hoa_hong"])).forEach($r$$=>{let $tt$$={};$tt$$.tk_no=$r$$.tk_no_hoa_hong;$tt$$.tk_co=$r$$.tk_co_hoa_hong;$tt$$.tien=$tt$$.tien_nt=$r$$.tien_hoa_hong;$tt$$.tien=$tt$$.tien_nt*($obj$$.ty_gia||
|
|
79
|
+
1);$tt$$.ma_kh=$obj$$.ma_kh_hoa_hong;$tt$$.ma_nv=$obj$$.ma_nv;$tt$$.check_balance=!1;$tt$$.ma_nt="VND";$tt$$.ty_gia=1;$tt$$.tk_no&&$tt$$.tk_co&&$details$$.push($tt$$)}));$obj$$.tien_hoa_hong_gt&&$obj$$.ma_kh_hoa_hong_gt&&($obj$$.details.filter($r$$=>$r$$.tien_hoa_hong_gt).forEach($r$$=>{$r$$.tk_no_hoa_hong_gt=$r$$.tk_no_hoa_hong_gt||$obj$$.tk_no_hoa_hong_gt||$kho$$.tk_no_hoa_hong_gt||options.tk_no_hoa_hong_gt||$obj$$.tk_no_hoa_hong||$kho$$.tk_no_hoa_hong||options.tk_no_hoa_hong;$r$$.tk_co_hoa_hong_gt=
|
|
80
|
+
$r$$.tk_co_hoa_hong_gt||$obj$$.tk_co_hoa_hong_gt||$kho$$.tk_co_hoa_hong_gt||options.tk_co_hoa_hong_gt||$obj$$.tk_co_hoa_hong||$kho$$.tk_co_hoa_hong||options.tk_co_hoa_hong}),(await $obj$$.details.filter($r$$=>$r$$.tien_hoa_hong_gt).asyncGroupBy(["tk_no_hoa_hong_gt","tk_co_hoa_hong_gt"],["tien_hoa_hong_gt"])).forEach($r$$=>{let $tt$$={};$tt$$.tk_no=$r$$.tk_no_hoa_hong_gt;$tt$$.tk_co=$r$$.tk_co_hoa_hong_gt;$tt$$.tien_nt=$r$$.tien_hoa_hong_gt;$tt$$.tien=$tt$$.tien_nt*($obj$$.ty_gia||1);$tt$$.ma_kh=$obj$$.ma_kh_hoa_hong_gt;
|
|
81
|
+
$tt$$.ma_nv=$obj$$.ma_nv;$tt$$.check_balance=!1;$tt$$.ma_nt="VND";$tt$$.ty_gia=1;$tt$$.tk_no&&$tt$$.tk_co&&$details$$.push($tt$$)}));let $details_tienvon$$=[...($ket_qua_post_sokho$$||[])];$details_tienvon$$.joinModel2($obj$$.id_app,dmvt,{where:"ma_vt",fields:["tk_vt","gia_mua","tk_gv","tg_tk"]},()=>{$details_tienvon$$.forEach(function($d$jscomp$31_detail$$){$d$jscomp$31_detail$$={...$d$jscomp$31_detail$$};$d$jscomp$31_detail$$.tk_no=$option$$.tk_gv;$d$jscomp$31_detail$$.ma_kh=$obj$$.ma_kh;$d$jscomp$31_detail$$.ngay_ct=
|
|
82
|
+
$obj$$.ngay_giao_hang||$obj$$.ngay_ct;$d$jscomp$31_detail$$.tk_co=$d$jscomp$31_detail$$.tk_vt||"1561";$d$jscomp$31_detail$$.tien_nt=$d$jscomp$31_detail$$.tien_xuat_nt;$d$jscomp$31_detail$$.tien=$d$jscomp$31_detail$$.tien_xuat;$d$jscomp$31_detail$$.tg_tk||($d$jscomp$31_detail$$.tien=$d$jscomp$31_detail$$.tien_nt=0);$d$jscomp$31_detail$$.ma_nt="VND";$d$jscomp$31_detail$$.ty_gia=1;$details$$.push($d$jscomp$31_detail$$)});(new PostSocai($obj$$,$details$$,null,Socai,$_options$$)).run(function($e$$,$rs$$){$callback$$($e$$,
|
|
83
|
+
$rs$$)})})})},thanhtoanhoahongnv:$callback$$=>{if($obj$$.da_chuyen_hoa_hong||!$obj$$.tien_hoa_hong||!$obj$$.user_nv||!$obj$$.chuyen_ngay)return $callback$$();setImmediate(async()=>{try{if($appInfo$$.wallet_address&&$appInfo$$.wallet_token&&$appInfo$$.tang_gioi_thieu_denom){let $wallet_nhan_vien$$=await global.getModel("asskey").findOne({id_app:$appInfo$$._id.toString(),username:$obj$$.user_nv,wallet_type:8});$wallet_nhan_vien$$||=await global.getModel("asskey").createWallet($appInfo$$._id.toString(),
|
|
84
|
+
$obj$$.user_nv,"T\u00e0i kho\u1ea3n nh\u1eadn th\u01b0\u1edfng",8);let $amount$$=$obj$$.tien_hoa_hong,$denom$$=$appInfo$$.tang_gioi_thieu_denom,$memo$$=`Hoa h\u1ed3ng cho \u0111\u01a1n h\u00e0ng s\u1ed1 ${$obj$$.so_ct}: ${numeral($amount$$).format()} ${$denom$$.toUpperCase()}`;await spend($appInfo$$,$obj$$.be_introduced,$wallet_nhan_vien$$.address,$amount$$,$denom$$,$memo$$,"","2");$obj$$.da_chuyen_hoa_hong=!0;await model.updateOne({_id:$obj$$._id},{da_chuyen_hoa_hong:!0})}}catch($e$$){Logger.error("Kh\u00f4ng th\u1ec3 thanh to\u00e1n ti\u1ec1n hoa h\u1ed3ng",
|
|
85
|
+
$e$$)}$callback$$()})},thanhtoanhoahonggt:$callback$$=>{if($obj$$.da_chuyen_hoa_hong_gt||!$obj$$.tien_hoa_hong_gt||!$obj$$.user_gt||!$obj$$.chuyen_ngay_gt)return $callback$$();setImmediate(async()=>{try{if($appInfo$$.wallet_address&&$appInfo$$.wallet_token&&$appInfo$$.tang_gioi_thieu_denom){let $wallet_gt$$=await global.getModel("asskey").findOne({id_app:$appInfo$$._id.toString(),username:$obj$$.user_gt,wallet_type:8});$wallet_gt$$||=await global.getModel("asskey").createWallet($appInfo$$._id.toString(),
|
|
86
|
+
$obj$$.user_gt,"T\u00e0i kho\u1ea3n nh\u1eadn th\u01b0\u1edfng",8);let $amount$$=$obj$$.tien_hoa_hong_gt,$denom$$=$appInfo$$.tang_gioi_thieu_denom,$memo$$=`Hoa h\u1ed3ng cho \u0111\u01a1n h\u00e0ng s\u1ed1 ${$obj$$.so_ct}: ${numeral($amount$$).format()} ${$denom$$.toUpperCase()}`;await spend($appInfo$$,$obj$$.be_introduced,$wallet_gt$$.address,$amount$$,$denom$$,$memo$$,$obj$$.introduce_code,"2");$obj$$.da_chuyen_hoa_hong_gt=!0;await model.updateOne({_id:$obj$$._id},{da_chuyen_hoa_hong_gt:!0})}}catch($e$$){Logger.error("Kh\u00f4ng th\u1ec3 thanh to\u00e1n ti\u1ec1n hoa h\u1ed3ng",
|
|
87
|
+
$e$$)}$callback$$()})},thanhtoanhoahongctv:$callback$$=>{if($obj$$.da_chuyen_hoa_hong_ctv||!$obj$$.thu_nhap_ctv||!$obj$$.user_ctv||!$obj$$.chuyen_ngay_ctv)return $callback$$();setImmediate(async()=>{try{if($appInfo$$.wallet_address&&$appInfo$$.wallet_token&&$appInfo$$.tang_gioi_thieu_denom){let $wallet_gt$$=await global.getModel("asskey").findOne({id_app:$appInfo$$._id.toString(),username:$obj$$.user_ctv,wallet_type:8});$wallet_gt$$||=await global.getModel("asskey").createWallet($appInfo$$._id.toString(),
|
|
88
|
+
$obj$$.user_ctv,"T\u00e0i kho\u1ea3n nh\u1eadn th\u01b0\u1edfng",8);let $amount$$=$obj$$.thu_nhap_ctv,$denom$$=$appInfo$$.tang_gioi_thieu_denom,$memo$$=`Hoa h\u1ed3ng cho \u0111\u01a1n h\u00e0ng s\u1ed1 ${$obj$$.so_ct}: ${numeral($amount$$).format()} ${$denom$$.toUpperCase()}`;await spend($appInfo$$,$obj$$.be_introduced,$wallet_gt$$.address,$amount$$,$denom$$,$memo$$,$obj$$.introduce_code,"2");$obj$$.da_chuyen_hoa_hong_ctv=!0;await model.updateOne({_id:$obj$$._id},{da_chuyen_hoa_hong_ctv:!0})}}catch($e$$){Logger.error("Kh\u00f4ng th\u1ec3 thanh to\u00e1n ti\u1ec1n hoa h\u1ed3ng",
|
|
89
|
+
$e$$)}$callback$$()})}},function($e$$,$rs$$){$fn$$($e$$,$rs$$)})};$contr_router$$.creating=async function($user$$,$obj$$,$next$$){$obj$$.details||($obj$$.details=[]);if(!$obj$$.ma_kh){var $afflink_kh$$=await customer.findOne({id_app:$obj$$.id_app||$user$$.current_id_app,of_user:$user$$.email},{ma_kh:-1});$afflink_kh$$&&($obj$$.ma_kh=$afflink_kh$$.ma_kh)}$obj$$.id_afflink&&global.mongoose.Types.ObjectId.isValid($obj$$.id_afflink)&&($afflink_kh$$=await global.getModel("afflink").findOne({_id:$obj$$.id_afflink}))&&
|
|
90
|
+
($obj$$.user_afflink=$afflink_kh$$.of_user||$afflink_kh$$.user_created);delete $obj$$.virtual_payment_client_url;$obj$$.da_chuyen_hoa_hong=!1;$obj$$.da_chuyen_hoa_hong_gt=!1;await $obj$$.details.asyncJoinModel2($user$$.current_id_app,dmvt,{where:"ma_vt",setFields:($item$$,$ref$$)=>{$item$$.combo=$ref$$.combo||[];$item$$.ma_thue=$ref$$.ma_thue;$item$$.gia_mua=$ref$$.gia_mua_tmp}});let $ngay_nay_thang_truoc$$=moment($obj$$.ngay_ct).subtract(1,"months").toDate(),$details$$=[];$obj$$.details.forEach($d$$=>
|
|
91
|
+
{$d$$.combo&&$d$$.combo.length>0?$details$$=[...$details$$,...$d$$.combo]:$details$$.push($d$$)});await $details$$.filter($r$$=>!$r$$.gia_mua).asyncJoinModel2($obj$$.id_app,"giatb",{where:$item$$=>({ma_vt:$item$$.ma_vt,id_app:$obj$$.id_app,nam:$ngay_nay_thang_truoc$$.getFullYear(),thang:$ngay_nay_thang_truoc$$.getMonth()+1,gia:{$gt:0}}),fields:[{gia_mua:"gia"}]});$ngay_nay_thang_truoc$$=moment($ngay_nay_thang_truoc$$).subtract(1,"months").toDate();await $details$$.filter($r$$=>!$r$$.gia_mua).asyncJoinModel2($obj$$.id_app,
|
|
92
|
+
"giatb",{where:$item$$=>({ma_vt:$item$$.ma_vt,id_app:$obj$$.id_app,nam:$ngay_nay_thang_truoc$$.getFullYear(),thang:$ngay_nay_thang_truoc$$.getMonth()+1,gia:{$gt:0}}),fields:[{gia_mua:"gia"}]});await $details$$.filter($r$$=>!$r$$.ma_kho).asyncJoinModel2($obj$$.id_app,"dmvt",{where:"ma_vt",fields:{ma_kho:"ma_kho_df"}});$obj$$.details.forEach($detail$$=>{$detail$$.combo&&$detail$$.combo.length>0&&($detail$$.combo=$detail$$.combo.map($item$$=>{$item$$=$item$$.toObject?$item$$.toObject():{...$item$$};
|
|
93
|
+
$item$$.sl_xuat_1_combo=$item$$.sl_xuat;$item$$.sl_xuat=$item$$.sl_xuat_1_combo*$detail$$.sl_xuat;$item$$.tien_xuat=$item$$.tien_xuat_nt=$item$$.sl_xuat*($item$$.gia_von_nt||0);$item$$.tien_hang=$item$$.tien_hang_nt=$item$$.sl_xuat*($item$$.gia_ban_nt||0);$item$$.tien_ck=$item$$.tien_ck_nt=$item$$.sl_xuat*($item$$.tien_ck_nt||0);$item$$.tien=$item$$.tien_nt=$item$$.tien_hang_nt-($item$$.tien_ck_nt||0);return $item$$}),$detail$$.gia_mua=$detail$$.combo.map($c$$=>($c$$.gia_mua||0)*$c$$.sl_xuat_1_combo).reduce(($a$$,
|
|
94
|
+
$b$$)=>$a$$+$b$$,0))});valid($user$$,$obj$$,async $error$$=>{if($error$$)return $next$$($error$$);if(!$obj$$.paymentByPoints)return $next$$(null,$obj$$);try{if(await getPointBalance($user$$.current_id_app,$obj$$.of_user||$user$$.email)<$obj$$.paymentByPoints)return $next$$("B\u1ea1n kh\u00f4ng c\u00f3 \u0111\u1ee7 \u0111i\u1ec3m \u0111\u1ec3 th\u1ef1c hi\u1ec7n giao d\u1ecbch n\u00e0y.");$next$$(null,$obj$$)}catch($e$$){$next$$($e$$.message)}})};$contr_router$$.created=async function($user$$,$obj$$,
|
|
95
|
+
$next$$){if($obj$$.pt_thanh_toan&&global.mongoose.Types.ObjectId.isValid($obj$$.pt_thanh_toan))try{const $pt_thanh_toan$$=await global.getModel("ptthanhtoan").findOne({_id:$obj$$.pt_thanh_toan});if($pt_thanh_toan$$.payment_service){let $paymentServiceModel$$=global.getModel($pt_thanh_toan$$.payment_service);$obj$$.amount=$obj$$.t_tt_nt-($obj$$.tien_paymentByPoints||0);if($obj$$.amount&&$paymentServiceModel$$.createVirtualPaymentClientURL){let $virtual_payment_client_url$$=await $paymentServiceModel$$.createVirtualPaymentClientURL($obj$$,
|
|
96
|
+
$user$$.clientIp,$pt_thanh_toan$$);$obj$$.virtual_payment_client_url=$virtual_payment_client_url$$;$obj$$.payment_service=$pt_thanh_toan$$.payment_service;$obj$$.payment_id=((await $paymentServiceModel$$.findOne({$or:[{id_ct:$obj$$._id.toString()},{request_id:$obj$$._id.toString()},{order_id:$obj$$._id.toString()}]})||{})._id||"").toString()}else $obj$$.virtual_payment_client_url="",$obj$$.payment_service="",$obj$$.payment_id=""}else $obj$$.virtual_payment_client_url=""}catch($e$$){return Logger.error($e$$),
|
|
97
|
+
$next$$("Kh\u00f4ng t\u1ea1o li\u00ean k\u1ebft thanh to\u00e1n:"+($e$$.message||$e$$.error||$e$$))}else Logger.info("Chua nhap phuong thuc thanh toan"),$obj$$.virtual_payment_client_url="";await model.updateOne({_id:$obj$$._id},{virtual_payment_client_url:$obj$$.virtual_payment_client_url,payment_id:$obj$$.payment_id,payment_service:$obj$$.payment_service}).catch(console.error);await createTransactionPayment($obj$$);await createTransactionBonus($obj$$);$obj$$.evouchers&&await Promise.all($obj$$.evouchers.map($e$$=>
|
|
98
|
+
updateEvoucher($e$$.id_app,$e$$.ma,$obj$$._id)));$obj$$.id_afflink&&global.mongoose.Types.ObjectId.isValid($obj$$.id_afflink)&&await global.getModel("afflink").updateOne({_id:$obj$$.id_afflink},{$inc:{da_dat_hang:1}}).catch(console.error);$next$$(null,$obj$$)};$contr_router$$.updating=async($user$$,$data$$,$obj$$,$next$$)=>{delete $data$$.id_afflink;delete $data$$.user_afflink;$data$$.details||($data$$.details=$obj$$.details);$data$$.ngay_ct=$data$$.ngay_ct||$obj$$.ngay_ct;if($data$$.trang_thai==
|
|
99
|
+
"10"&&["LCT","0","1"].indexOf($obj$$.trang_thai)<0&&$user$$.email===$obj$$.user_created)return $next$$("Kh\u00f4ng th\u1ec3 hu\u1ef7 \u0111\u01a1n h\u00e0ng n\u00e0y");$data$$.da_chuyen_hoa_hong=$obj$$.da_chuyen_hoa_hong;$data$$.da_chuyen_hoa_hong_gt=$obj$$.da_chuyen_hoa_hong_gt;await $data$$.details.asyncJoinModel2($user$$.current_id_app,dmvt,{where:"ma_vt",setFields:($item$$,$ref$$)=>{let $old_combo$$=($item$$.combo||[]).map($i$$=>({ma_vt:$i$$.ma_vt,sl_xuat:$i$$.sl_xuat})),$new_combo$$=($ref$$.combo||
|
|
100
|
+
[]).map($i$$=>({ma_vt:$i$$.ma_vt,sl_xuat:$i$$.sl_xuat}));_.isEqual($old_combo$$,$new_combo$$)||($item$$.combo=$ref$$.combo||[]);$item$$.gia_mua=$ref$$.gia_mua_tmp;$obj$$.details.find($d$$=>$d$$.ma_vt===$item$$.ma_vt)?$item$$.ma_thue||($item$$.ma_thue=$ref$$.ma_thue):$item$$.ma_thue=$ref$$.ma_thue}});let $ngay_nay_thang_truoc$$=moment($data$$.ngay_ct).subtract(1,"months").toDate(),$details$$=[];$data$$.details.forEach($d$$=>{$d$$.combo&&$d$$.combo.length>0?$details$$=[...$details$$,...$d$$.combo]:
|
|
101
|
+
$details$$.push($d$$)});await $details$$.filter($r$$=>!$r$$.gia_mua).asyncJoinModel2($obj$$.id_app,"giatb",{where:$item$$=>({ma_vt:$item$$.ma_vt,id_app:$obj$$.id_app,nam:$ngay_nay_thang_truoc$$.getFullYear(),thang:$ngay_nay_thang_truoc$$.getMonth()+1,gia:{$gt:0}}),fields:[{gia_mua:"gia"}]});$ngay_nay_thang_truoc$$=moment($ngay_nay_thang_truoc$$).subtract(1,"months").toDate();await $details$$.filter($r$$=>!$r$$.gia_mua).asyncJoinModel2($obj$$.id_app,"giatb",{where:$item$$=>({ma_vt:$item$$.ma_vt,id_app:$obj$$.id_app,
|
|
102
|
+
nam:$ngay_nay_thang_truoc$$.getFullYear(),thang:$ngay_nay_thang_truoc$$.getMonth()+1,gia:{$gt:0}}),fields:[{gia_mua:"gia"}]});await $data$$.details.asyncJoinModel2($obj$$.id_app,"vat",{where:"ma_thue",fields:["thue_suat","tk_thue_co","tk_thue_co_treo"]});$data$$.details.forEach($detail$$=>{$detail$$.combo&&$detail$$.combo.length>0&&($detail$$.combo=$detail$$.combo.map($item$$=>{$item$$=$item$$.toObject?$item$$.toObject():{...$item$$};$item$$.sl_xuat_1_combo==void 0&&($item$$.sl_xuat_1_combo=$item$$.sl_xuat||
|
|
103
|
+
0);$item$$.sl_xuat=$item$$.sl_xuat_1_combo*$detail$$.sl_xuat;$item$$.tien_xuat=$item$$.tien_xuat_nt=$item$$.sl_xuat*($item$$.gia_von_nt||0);$item$$.tien_hang=$item$$.tien_hang_nt=$item$$.sl_xuat*($item$$.gia_ban_nt||0);$item$$.tien_ck=$item$$.tien_ck_nt=$item$$.sl_xuat*($item$$.tien_ck_nt||0);$item$$.tien=$item$$.tien_nt=$item$$.tien_hang_nt-($item$$.tien_ck_nt||0);return $item$$}),$detail$$.gia_mua=$detail$$.combo.map($c$$=>($c$$.gia_mua||0)*$c$$.sl_xuat_1_combo).reduce(($a$$,$b$$)=>$a$$+$b$$,0))});
|
|
104
|
+
$data$$.pt_thanh_toan&&$data$$.pt_thanh_toan!=$obj$$.pt_thanh_toan&&($data$$.virtual_payment_client_url="",$data$$.payment_service="",$data$$.payment_id="");$data$$.evouchers=$data$$.evouchers||$obj$$.evouchers||[];valid($user$$,$data$$,async $error$$=>{if($error$$)return $next$$($error$$);if(($obj$$.paymentByPoints||0)!==($data$$.paymentByPoints||0))return $next$$("B\u1ea1n kh\u00f4ng th\u1ec3 c\u1eadp nh\u1eadt s\u1ed1 \u0111i\u1ec3m thanh to\u00e1n.");await transaction.deleteTrans({id_ct:$obj$$._id.toString()+
|
|
105
|
+
":buy"});$next$$(null,$data$$,$obj$$)},$obj$$)};$contr_router$$.updated=async function($amount$jscomp$6_evouchers_user$$,$obj$$,$next$$){if(!$obj$$.virtual_payment_client_url&&($obj$$.trang_thai==="1"||$obj$$.trang_thai==="0"||$obj$$.trang_thai==="LCT")){if($obj$$.pt_thanh_toan&&global.mongoose.Types.ObjectId.isValid($obj$$.pt_thanh_toan))try{var $pt_thanh_toan$jscomp$1_pt_thanh_toan$$=await global.getModel("ptthanhtoan").findOne({_id:$obj$$.pt_thanh_toan});if($pt_thanh_toan$jscomp$1_pt_thanh_toan$$.payment_service){var $app_paymentServiceModel$$=
|
|
106
|
+
global.getModel($pt_thanh_toan$jscomp$1_pt_thanh_toan$$.payment_service);$obj$$.amount=$obj$$.t_tt_nt-($obj$$.tien_paymentByPoints||0);if($obj$$.amount&&$app_paymentServiceModel$$.createVirtualPaymentClientURL){var $memo$jscomp$4_virtual_payment_client_url$$=await $app_paymentServiceModel$$.createVirtualPaymentClientURL($obj$$,$amount$jscomp$6_evouchers_user$$.clientIp,$pt_thanh_toan$jscomp$1_pt_thanh_toan$$);$obj$$.virtual_payment_client_url=$memo$jscomp$4_virtual_payment_client_url$$;$obj$$.payment_service=
|
|
107
|
+
$pt_thanh_toan$jscomp$1_pt_thanh_toan$$.payment_service;$obj$$.payment_id=((await $app_paymentServiceModel$$.findOne({$or:[{id_ct:$obj$$._id.toString()},{request_id:$obj$$._id.toString()},{order_id:$obj$$._id.toString()}]})||{})._id||"").toString()}else $obj$$.virtual_payment_client_url="",$obj$$.payment_service="",$obj$$.payment_id=""}else $obj$$.virtual_payment_client_url=""}catch($e$$){return Logger.error($e$$),$next$$("Error create Virtual Payment ClientURL:"+($e$$.message||$e$$.error||$e$$))}else $obj$$.virtual_payment_client_url=
|
|
108
|
+
"";await model.updateOne({_id:$obj$$._id},{virtual_payment_client_url:$obj$$.virtual_payment_client_url,payment_id:$obj$$.payment_id,payment_service:$obj$$.payment_service}).catch(console.error)}await Evoucher.updateMany({id_ct_used:$obj$$._id.toString()},{id_ct_used:null});$amount$jscomp$6_evouchers_user$$=await Evoucher.find({id_ct_useds:$obj$$._id.toString()});await Promise.all($amount$jscomp$6_evouchers_user$$.map($e$$=>deleteEvoucher($e$$.id_app,$e$$.ma,$obj$$._id)));if($obj$$.trang_thai==="9"||
|
|
109
|
+
$obj$$.trang_thai==="10"){if(await transaction.deleteTrans({id_ct:$obj$$._id.toString()}),await transaction.deleteTrans({id_ct:$obj$$._id.toString()+":bonus"},"Tr\u1ea3 l\u1ea1i \u0111i\u1ec3m th\u01b0\u1edfng"),await transaction.deleteTrans({id_ct:$obj$$._id.toString()+":buy"}),$obj$$.trang_thai==="10"&&$obj$$.payment_id&&global.mongoose.Types.ObjectId.isValid($obj$$.payment_id)&&$obj$$.trang_thai_tt==="5"&&$obj$$.virtual_payment_client_url&&$obj$$.pt_thanh_toan&&global.mongoose.Types.ObjectId.isValid($obj$$.pt_thanh_toan)&&
|
|
110
|
+
($pt_thanh_toan$jscomp$1_pt_thanh_toan$$=await global.getModel("ptthanhtoan").findOne({_id:$obj$$.pt_thanh_toan}),$pt_thanh_toan$jscomp$1_pt_thanh_toan$$.payment_service=="assrequest"&&($amount$jscomp$6_evouchers_user$$=$obj$$.t_tt_nt-($obj$$.tien_paymentByPoints||0))))if($pt_thanh_toan$jscomp$1_pt_thanh_toan$$=await global.getModel($pt_thanh_toan$jscomp$1_pt_thanh_toan$$.payment_service).findOne({_id:$obj$$.payment_id}),$app_paymentServiceModel$$=await App.findOne({_id:$obj$$.id_app}),$app_paymentServiceModel$$.wallet_address&&
|
|
111
|
+
$app_paymentServiceModel$$.wallet_token&&$pt_thanh_toan$jscomp$1_pt_thanh_toan$$&&$pt_thanh_toan$jscomp$1_pt_thanh_toan$$.trang_thai=="1"){$memo$jscomp$4_virtual_payment_client_url$$="Tr\u1ea3 l\u1ea1i ti\u1ec1n cho \u0111\u01a1n h\u00e0ng "+$pt_thanh_toan$jscomp$1_pt_thanh_toan$$.order_id;let $denom$$=$pt_thanh_toan$jscomp$1_pt_thanh_toan$$.denom;try{await blockchainconnect.spend($obj$$.id_app,$app_paymentServiceModel$$.wallet_token,$app_paymentServiceModel$$.wallet_address,$pt_thanh_toan$jscomp$1_pt_thanh_toan$$.sender_address,
|
|
112
|
+
{amount:$amount$jscomp$6_evouchers_user$$,denom:$denom$$,memo:$memo$jscomp$4_virtual_payment_client_url$$}),await model.updateOne({_id:$obj$$._id},{trang_thai_tt:9})}catch($e$$){Logger.error("Kh\u00f4ng th\u1ec3 tr\u1ea3 ti\u1ec1n cho \u0111\u01a1n h\u00e0ng",$e$$)}}}else await createTransactionPayment($obj$$),createTransactionBonus($obj$$),$obj$$.evouchers&&await Promise.all($obj$$.evouchers.map($e$$=>updateEvoucher($e$$.id_app,$e$$.ma,$obj$$._id)));$next$$(null,$obj$$)};$contr_router$$.deleting=
|
|
113
|
+
function($user$$,$obj$$,$next$$){$next$$(null,$obj$$)};$contr_router$$.deleted=async function($user$$,$obj$$,$next$$){await transaction.deleteTrans({id_ct:$obj$$._id.toString()});await transaction.deleteTrans({id_ct:$obj$$._id.toString()+":bonus"},"Tr\u1ea3 l\u1ea1i \u0111i\u1ec3m th\u01b0\u1edfng");await transaction.deleteTrans({id_ct:$obj$$._id.toString()+":buy"});$obj$$.evouchers&&await Promise.all($obj$$.evouchers.map($e$$=>deleteEvoucher($e$$.id_app,$e$$.ma,$obj$$._id)));$next$$(null,$obj$$)};
|
|
114
|
+
$contr_router$$.view=function($user$$,$items$$,$fn$$){async.parallel({app:function($callback$$){$items$$.filter($item$$=>$item$$.id_app).joinModel2(null,App,[{where:{id_app:"_id"},fields:{name_app:"name"}}],function(){$callback$$()})},kh:function($callback$$){$items$$.filter($item$$=>$item$$.ma_kh).joinModel2(null,customer,[{where:$item$$=>({id_app:$item$$.id_app,ma_kh:$item$$.ma_kh}),fields:"ten_kh"}],function(){$callback$$()})},nhan_vien_giao_hang:function($callback$$){$items$$.filter($item$$=>
|
|
115
|
+
$item$$.nhan_vien_giao_hang).joinModel2(null,customer,[{where:{nhan_vien_giao_hang:"ma_kh"},fields:[{ten_nhan_vien_giao_hang:"ten_kh"}]}],function(){$callback$$()})},nv_giao_hang:function($callback$$){$items$$.filter($item$$=>$item$$.user_nv_giao_hang).joinModel2(null,User,{where:{user_nv_giao_hang:"email"},fields:{ten_nv_giao_hang:"name"}},function(){$callback$$()})},kho:function($callback$$){$items$$.filter($item$$=>$item$$.ma_kho).joinModel2(null,dmkho,[{where:$item$$=>({id_app:$item$$.id_app,
|
|
116
|
+
ma_kho:$item$$.ma_kho}),fields:["ten_kho",{tk_cn_kho:"tk_cn"}]}],function(){$callback$$()})},trangthai:function($callback$$){$items$$.filter($item$$=>$item$$.trang_thai).joinModel2(null,trangthai,[{where:{trang_thai:"ma_trang_thai",ma_ct:"ma_ct"},fields:["ten_trang_thai","color"]}],function(){$callback$$()})},ptthanhtoan:function($callback$$){$items$$.filter($item$$=>$item$$.pt_thanh_toan).joinModel2(null,ptthanhtoan,[{where:$item$$=>({_id:$item$$.pt_thanh_toan,id_app:$item$$.id_app}),fields:[{ten_pt_thanh_toan:"ten"},
|
|
117
|
+
{tk_cn_thanhtoan:"tk_cn"}]}],function(){$callback$$()})},pt1:function($callback$$){$items$$.joinModel2(null,pt1,[{where:$item$$=>({id_app:$item$$.id_app,id_so1:"_id"}),fields:[{id_pt1:"_id"},{so_ct_pt1:"so_ct"},{ma_ct_pt1:"ma_ct"},{ngay_ct_pt1:"ngay_ct"}]}],function(){$callback$$()})},t_tien:function($callback$$){$items$$.filter($item$$=>$item$$.details).forEach(function($r$$){$r$$.tien_phi_vc=$r$$.tien_phi_vc||0;$r$$.tien_freeship=$r$$.tien_freeship||0;$r$$.details?($r$$.t_sl=$r$$.details.csum("sl_xuat"),
|
|
118
|
+
$r$$.t_tien_hang=$r$$.details.csum("tien_hang"),$r$$.t_tien_hang_nt=$r$$.details.csum("tien_hang_nt"),$r$$.t_tien_hang_ct=$r$$.details.csum("tien_hang_ct"),$r$$.t_tien_hang_ct_nt=$r$$.details.csum("tien_hang_ct_nt"),$r$$.t_tien_ck=$r$$.details.csum("tien_ck"),$r$$.t_tien_ck_nt=$r$$.details.csum("tien_ck_nt"),$r$$.t_thue_nt=$r$$.details.csum("tien_thue_nt"),$r$$.t_thue=$r$$.details.csum("tien_thue"),$r$$.t_ck=$r$$.t_tien_ck+$r$$.tien_ck_hd+($r$$.tien_evoucher||0),$r$$.t_ck_nt=$r$$.t_tien_ck_nt+$r$$.tien_ck_hd+
|
|
119
|
+
($r$$.tien_evoucher||0),$r$$.t_tien_nt=$r$$.t_tien_hang_ct_nt-$r$$.t_ck_nt+$r$$.t_thue_nt,$r$$.t_tien=$r$$.t_tien_hang_ct-$r$$.t_ck+$r$$.t_thue,$r$$.tien_hoa_hong=$r$$.details.csum("tien_hoa_hong"),$r$$.tien_hoa_hong_gt=$r$$.details.csum("tien_hoa_hong_gt"),$r$$.tien_hoa_hong_ctv=$r$$.details.csum("tien_hoa_hong_ctv"),$r$$.tien_hoa_hong_ql=$r$$.details.csum("tien_hoa_hong_ql")):($r$$.t_sl=0,$r$$.t_tien_hang=0,$r$$.t_tien_hang_nt=0,$r$$.t_tien_hang_ct=0,$r$$.t_tien_hang_ct_nt=0,$r$$.t_tien_ck=0,$r$$.t_tien_ck_nt=
|
|
120
|
+
0,$r$$.t_ck=0,$r$$.t_ck_nt=0,$r$$.t_thue=0,$r$$.t_thue_nt=0,$r$$.t_tien=$r$$.t_tien_hang,$r$$.t_tien_nt=$r$$.t_tien_hang_nt);$r$$.ctcpbhs?($r$$.t_cp_cpb_nt=$r$$.ctcpbhs.csum("tien_cp_nt"),$r$$.t_cp_cpb=$r$$.ctcpbhs.csum("tien_cp")):($r$$.t_cp_cpb_nt=0,$r$$.t_cp_cpb=0);$r$$.t_tt=$r$$.t_tt_nt=Math.max(0,$r$$.t_tien_hang_ct_nt+$r$$.t_thue_nt+$r$$.t_cp_cpb_nt-$r$$.t_ck_nt-($r$$.tt_tien_thuong||0)+($r$$.tien_phi_vc||0)-($r$$.tien_freeship||0))});$callback$$()},details_vt:function($callback$$){async.each($items$$,
|
|
121
|
+
function($r$$,$callback1$$){const $details$$=$r$$.details||[];if(!$details$$)return $callback1$$();$details$$.joinModel2(null,dmvt,[{where:$item$$=>({id_app:$r$$.id_app,ma_vt:$item$$.ma_vt}),fields:"ten_vt ten_vt_eng picture chieu_cao chieu_rong chieu_sau trong_luong".split(" ")}],function(){$callback1$$()})},function(){$callback$$()})},details_tt1:function($callback$$){async.mapLimit($items$$,10,function($r$$,$callback1$$){($r$$.details||[]).filter($item$$=>$item$$.ma_tt1).joinModel2(null,dmtt,[{where:$item$$=>
|
|
122
|
+
({id_app:$r$$.id_app,ma_vt:$item$$.ma_vt,ma_tt1:$item$$.ma_tt1}),setFields:($item$$,$ref$$)=>{$item$$.ten_vt=$item$$.ten_vt+" - "+$ref$$.ten_tt}}],function(){$callback1$$()})},function(){$callback$$()})},details_dt:function($callback$$){async.mapLimit($items$$,10,function($r$$,$callback1$$){const $details$$=$r$$.details;if(!$details$$)return $callback1$$();$details$$.filter($item$$=>$item$$.ma_dt).joinModel2(null,dmdt,[{where:$item$$=>({id_app:$r$$.id_app,ma_dt:$item$$.ma_dt}),fields:["ten_dt"]}],
|
|
123
|
+
function(){$callback1$$()})},function(){$callback$$()})},details_contract:function($callback$$){async.mapLimit($items$$,10,function($r$$,$callback1$$){const $details$$=$r$$.details;if(!$details$$)return $callback1$$();$details$$.filter($item$$=>$item$$.ma_hd).joinModel2(null,contract,[{where:$item$$=>({id_app:$r$$.id_app,so_hd:$item$$.ma_hd}),fields:["ten_hd"]}],function(){$callback1$$()})},function(){$callback$$()})},details_phi:function($callback$$){async.mapLimit($items$$,10,function($r$$,$callback1$$){const $details$$=
|
|
124
|
+
$r$$.details;if(!$details$$)return $callback1$$();$details$$.filter($item$$=>$item$$.ma_phi).joinModel2(null,dmphi,[{where:$item$$=>({id_app:$r$$.id_app,ma_phi:$item$$.ma_phi}),fields:["ten_phi"]}],function(){$callback1$$()})},function(){$callback$$()})},details_chietkhau:function($callback$$){async.mapLimit($items$$,10,function($r$$,$callback1$$){($r$$.details||[]).filter($item$$=>$item$$.id_cs_ck).joinModel2(null,"dmchietkhau",[{where:$item$$=>({id_app:$r$$.id_app,_id:$item$$.id_cs_ck}),fields:["ma_chietkhau",
|
|
125
|
+
"ten_chietkhau"]}],function(){$callback1$$()})},function(){$callback$$()})},details_cpbh:function($callback$$){async.each($items$$,function($r$$,$callback1$$){let $ctcpbhs$$=$r$$.ctcpbhs;if(!$ctcpbhs$$)return $callback1$$();$ctcpbhs$$?$ctcpbhs$$.filter($item$$=>$item$$.ma_cp).joinModel2(null,dmcpmh,[{where:$item$$=>({id_app:$r$$.id_app,ma_cp:$item$$.ma_cp}),fields:["ten_cp"]}],function(){$callback1$$()}):$callback1$$()},function(){$callback$$()})}},function(){$fn$$(null,$items$$)})}};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
const PostBook=require("../../libs/post-book"),options=global.getModel("options"),PostSocai=require("../../libs/post-socai"),User=global.getModel("user"),Sodiemthuong=global.getModel("sodiemthuong"),transaction=global.getModel("transaction"),Evoucher=global.getModel("evoucher"),dvcs=global.getModel("dvcs"),dmvt=global.getModel("dmvt"),dmtt=global.getModel("dmtt"),dmcpmh=global.getModel("dmcpmh"),customer=global.getModel("customer"),dmdt=global.getModel("dmdt"),dmphi=global.getModel("dmphi"),contract=
|
|
2
|
+
global.getModel("contract"),trangthai=global.getModel("trangthai"),currency=global.getModel("currency"),ptthanhtoan=global.getModel("ptthanhtoan"),dmdiemthuong=global.getModel("dmdiemthuong"),model=global.getModel("so5"),pt1=global.getModel("pt1"),controller=require("../../controllers/controller"),async=require("async"),ma_ct="SO5",ckdiem=require("../../libs/ckdiem"),blockchainconnect=require("../../libs/blockchainconnect"),moment=require("moment"),App=global.getModel("app"),Introducer=global.getModel("introducer"),
|
|
3
|
+
getPointBalance=async($id_app$$,$sender_email$$)=>new Promise(($resolve$$,$reject$$)=>{ckdiem({id_app:$id_app$$,email:$sender_email$$},($e$$,$rs$$)=>{if($e$$)return $reject$$(Error($e$$));$resolve$$($rs$$.length===0?0:$rs$$[0].ton00)})}),getWalletBalanceOfApp=async($app_bl_id_app$$,$denom$$)=>{$app_bl_id_app$$=await App.findOne({_id:$app_bl_id_app$$});return $app_bl_id_app$$.wallet_address&&$app_bl_id_app$$.wallet_token?($app_bl_id_app$$=await blockchainconnect.bankBalancesGet($app_bl_id_app$$.wallet_address))?
|
|
4
|
+
$app_bl_id_app$$.filter($r$$=>$r$$.denom==$denom$$).map($r$$=>Number($r$$.amount)).reduce(($a$$,$b$$)=>$a$$+$b$$,0):0:0},createTransactionBonus=async function($obj$$){if($obj$$.trang_thai!="5"&&$obj$$.trang_thai!="6")return await transaction.deleteTrans({id_ct:$obj$$._id.toString()+":bonus"},"Tr\u1ea3 l\u1ea1i \u0111i\u1ec3m th\u01b0\u1edfng \u0111\u1ec3 t\u00ednh l\u1ea1i"),await transaction.deleteTrans({id_ct:$obj$$._id.toString()+":introduce"},"Tr\u1ea3 l\u1ea1i \u0111i\u1ec3m th\u01b0\u1edfng gi\u1edbi thi\u1ec7u th\u00e0nh vi\u00ean m\u1edbi \u0111\u1ec3 t\u00ednh l\u1ea1i"),
|
|
5
|
+
null;let $kh$$=await customer.findOne({id_app:$obj$$.id_app,ma_kh:$obj$$.ma_kh})||{},$lan_mua$$=(await model.find({id_app:$obj$$.id_app,ma_kh:$obj$$.ma_kh,ngay_ct:{$lte:$obj$$.ngay_ct}})).length+1;var $_app_diem_thuong_gioi_thieu_old_trans$$=await App.findOne({_id:$obj$$.id_app}),$_intro_amount_calcDiemThuong$$=await Introducer.findOne({id_app:$obj$$.id_app,be_introduced:$obj$$.email||$obj$$.user_created});$_app_diem_thuong_gioi_thieu_old_trans$$=$_app_diem_thuong_gioi_thieu_old_trans$$.exfields.diem_thuong_gioi_thieu;
|
|
6
|
+
$lan_mua$$===1&&$_app_diem_thuong_gioi_thieu_old_trans$$&&$_intro_amount_calcDiemThuong$$&&await transaction.createTrans({id_app:$obj$$.id_app,sender_email:$obj$$.id_app,receiver_email:$_intro_amount_calcDiemThuong$$.be_introduced_by,amount:$_app_diem_thuong_gioi_thieu_old_trans$$,description:"\u0110i\u1ec3m th\u01b0\u1edfng gi\u1edbi thi\u1ec7u kh\u00e1ch h\u00e0ng",otherData:{ma_ct:$obj$$.ma_ct,so_ct:$obj$$.so_ct,ngay_ct:$obj$$.ngay_ct,id_ct:$obj$$._id.toString()+":introduce"}});if(!$obj$$.exfields.survey)return null;
|
|
7
|
+
let $now$$=moment(new Date).startOf("date").toDate();$_intro_amount_calcDiemThuong$$=$obj$$.details.filter($d$$=>$d$$.tien_hang).map(async $d$$=>{var $amount$$=await dmvt.findOne({ma_vt:$d$$.ma_vt,id_app:$obj$$.id_app}),$ckdiemthuong_ty_le_diem_thuong$$=await dmdiemthuong.find({id_app:$obj$$.id_app,status:!0,ma_kh:{$in:[null,"",$kh$$.ma_kh]},ma_kho:{$in:[null,"",$obj$$.ma_kho]},nh_kh:{$in:[null,"",$kh$$.nh_kh]},hieu_luc_tu:{$lte:$now$$},hieu_luc_den:{$gte:$now$$},ap_dung_lan_mua_thu:{$in:[0,$lan_mua$$]},
|
|
8
|
+
ma_vt:{$in:[null,"",void 0,$d$$.ma_vt]},ma_nvt:{$in:[null,"",void 0,$amount$$?$amount$$.ma_nvt:""]}}).sort({ma_vt:-1,ma_nvt:-1,hieu_luc_tu:-1}).limit(1);return $ckdiemthuong_ty_le_diem_thuong$$.length>0?($amount$$=0,$ckdiemthuong_ty_le_diem_thuong$$[0].tien?($ckdiemthuong_ty_le_diem_thuong$$=$ckdiemthuong_ty_le_diem_thuong$$[0].diem/$ckdiemthuong_ty_le_diem_thuong$$[0].tien)||($amount$$=Math.roundBy(($d$$.tien_hang-($d$$.tien_ck||0))*$ckdiemthuong_ty_le_diem_thuong$$,0)):$amount$$=$ckdiemthuong_ty_le_diem_thuong$$[0].diem*
|
|
9
|
+
($d$$.sl_xuat||1),$amount$$):0});if($_intro_amount_calcDiemThuong$$=(await Promise.all($_intro_amount_calcDiemThuong$$)).reduce(($a$$,$b$$)=>$a$$+$b$$,0)){if($_app_diem_thuong_gioi_thieu_old_trans$$=await transaction.findOne({id_ct:$obj$$._id.toString()+":bonus"}),!$_app_diem_thuong_gioi_thieu_old_trans$$||$_app_diem_thuong_gioi_thieu_old_trans$$.amount!==$_intro_amount_calcDiemThuong$$)return await transaction.deleteTrans({id_ct:$obj$$._id.toString()+":bonus"},"Tr\u1ea3 l\u1ea1i \u0111i\u1ec3m th\u01b0\u1edfng \u0111\u1ec3 t\u00ednh l\u1ea1i"),
|
|
10
|
+
await transaction.createTrans({id_app:$obj$$.id_app,sender_email:$obj$$.id_app,receiver_email:$obj$$.user_created,amount:$_intro_amount_calcDiemThuong$$,description:"\u0110i\u1ec3m th\u01b0\u1edfng mua h\u00e0ng",otherData:{ma_ct:$obj$$.ma_ct,so_ct:$obj$$.so_ct,ngay_ct:$obj$$.ngay_ct,id_ct:$obj$$._id.toString()+":bonus"}})}else await transaction.deleteTrans({id_ct:$obj$$._id.toString()+":bonus"},"Tr\u1ea3 l\u1ea1i \u0111i\u1ec3m th\u01b0\u1edfng \u0111\u1ec3 t\u00ednh l\u1ea1i")},createTransactionPayment=
|
|
11
|
+
async function($obj$$){await transaction.deleteTrans({id_ct:$obj$$._id.toString()});$obj$$.paymentByPoints&&await transaction.createTrans({id_app:$obj$$.id_app,sender_email:$obj$$.user_created,receiver_email:$obj$$.id_app,amount:$obj$$.paymentByPoints,description:"Thanh to\u00e1n cho \u0111\u01a1n h\u00e0ng s\u1ed1 "+$obj$$.so_ct,otherData:{ma_ct:$obj$$.ma_ct,so_ct:$obj$$.so_ct,ngay_ct:$obj$$.ngay_ct,id_ct:$obj$$._id.toString()}})},BuyPoint=async function($obj$$){await transaction.deleteTrans({id_ct:$obj$$._id.toString()+
|
|
12
|
+
":buy"});let $amount$$=$obj$$.details.filter($d$$=>$d$$.is_point).map($d$$=>$d$$.sl_xuat).reduce(($a$$,$b$$)=>$a$$+$b$$,0);$amount$$&&await transaction.createTrans({id_app:$obj$$.id_app,sender_email:$obj$$.id_app,receiver_email:$obj$$.user_created,amount:$amount$$,description:$obj$$.dien_giai||"N\u1ed9p ti\u1ec1n m\u1eb7t v\u00e0o v\u00ed",otherData:{ma_ct:$obj$$.ma_ct,so_ct:$obj$$.so_ct,ngay_ct:$obj$$.ngay_ct,id_ct:$obj$$._id.toString()+":buy"}})},checkEvoucher=($user$$,$obj$$,$pre_obj$$)=>($obj$$.evouchers||
|
|
13
|
+
[]).map($ev$$=>new Promise(($resolve$$,$reject$$)=>{(async()=>{const $_e$$=await Evoucher.findOne({ma:$ev$$.ma,id_app:$user$$.current_id_app});if(!$_e$$)return Logger.error("Th\u1ebb mua h\u00e0ng kh\u00f4ng t\u1ed3n t\u1ea1i",$ev$$),$reject$$(Error(`Th\u1ebb mua h\u00e0ng ${$ev$$.ma} kh\u00f4ng t\u1ed3n t\u1ea1i`));if($_e$$.id_ct_used&&$_e$$.id_ct_used!==($obj$$._id||"").toString())return $reject$$(Error(`Th\u1ebb mua h\u00e0ng ${$ev$$.ma} \u0111\u00e3 \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng`));if($_e$$.so_lan_sd>=
|
|
14
|
+
1&&$_e$$.id_ct_useds&&$_e$$.id_ct_useds.length>0){if($pre_obj$$&&$_e$$.id_ct_useds.indexOf($pre_obj$$._id.toString())>=0)return $resolve$$(!0);if($_e$$.id_ct_useds.length>$_e$$.so_lan_sd)return $reject$$(Error(`Th\u1ebb mua h\u00e0ng ${$ev$$.ma} \u0111\u00e3 \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng h\u1ebft`))}if($_e$$.user&&$_e$$.user!==($obj$$.user_created||$user$$.email))return $reject$$(Error(`Th\u1ebb mua h\u00e0ng ${$ev$$.ma} kh\u00f4ng h\u1ee3p l\u1ec7`));var $date_created_so_tien_giam$$=new Date($obj$$.date_created);
|
|
15
|
+
if(moment($_e$$.hieu_luc_den).endOf("date").toDate().getTime()<$date_created_so_tien_giam$$.getTime())return $reject$$(Error(`Th\u1ebb mua h\u00e0ng ${$ev$$.ma} \u0111\u00e3 h\u1ebft h\u1ea1n s\u1eed d\u1ee5ng`));$date_created_so_tien_giam$$=$_e$$.so_tien;$_e$$.ty_le&&($date_created_so_tien_giam$$=Math.roundBy($obj$$.details.map($d$$=>$d$$.tien_hang_nt).reduce(($a$$,$b$$)=>$a$$+$b$$,0)*$_e$$.ty_le/100));$_e$$.so_tien_max&&$date_created_so_tien_giam$$>$_e$$.so_tien_max&&($date_created_so_tien_giam$$=
|
|
16
|
+
$_e$$.so_tien_max);if($ev$$.so_tien_giam!==$date_created_so_tien_giam$$)return $reject$$(Error(`S\u1ed1 ti\u1ec1n gi\u1ea3m cho th\u1ebb ${$ev$$.ma} kh\u00f4ng h\u1ee3p l\u1ec7`));$resolve$$(!0)})()})),updateEvoucher=async($id_app$$,$evoucher_code$$,$id_ct_rs$$)=>{if($evoucher_code$$){$id_ct_rs$$=$id_ct_rs$$.toString();var $e$$=await Evoucher.findOne({ma:$evoucher_code$$,id_app:$id_app$$});$e$$?($id_app$$=$e$$.id_ct_useds||[],$id_app$$.push($id_ct_rs$$),$id_app$$=[...(new Set($id_app$$))],$id_ct_rs$$=
|
|
17
|
+
await Evoucher.findOneAndUpdate({_id:$e$$._id},{id_ct_useds:$id_app$$}),Logger.info("update id_ct_useds",$evoucher_code$$,$id_app$$,$id_ct_rs$$)):Logger.error("can't find evoucher",$evoucher_code$$)}},deleteEvoucher=async($id_app$jscomp$3_id_ct_useds$$,$evoucher_code$$,$id_ct$$)=>{if($evoucher_code$$){$id_ct$$=$id_ct$$.toString();var $e$jscomp$2_rs$$=await Evoucher.findOne({id_app:$id_app$jscomp$3_id_ct_useds$$,ma:$evoucher_code$$});$e$jscomp$2_rs$$&&($id_app$jscomp$3_id_ct_useds$$=($e$jscomp$2_rs$$.id_ct_useds||
|
|
18
|
+
[]).filter($ct$$=>$ct$$!==$id_ct$$),$e$jscomp$2_rs$$=await Evoucher.findOneAndUpdate({_id:$e$jscomp$2_rs$$._id},{id_ct_useds:$id_app$jscomp$3_id_ct_useds$$}),Logger.info("update id_ct_useds",$evoucher_code$$,$id_app$jscomp$3_id_ct_useds$$,$e$jscomp$2_rs$$))}},valid=async function($user$$,$obj$$,$next$$,$_opt_detail$jscomp$1_pre_obj$$){try{const $_checkEvoucher$$=checkEvoucher($user$$,$obj$$,$_opt_detail$jscomp$1_pre_obj$$);await Promise.all($_checkEvoucher$$)}catch($e$$){return $next$$($e$$.message)}if($obj$$.tien_evoucher&&
|
|
19
|
+
($_opt_detail$jscomp$1_pre_obj$$=await options.findOne({id_app:$obj$$.id_app,id_func:$obj$$.ma_ct.toLowerCase()}).lean())&&$_opt_detail$jscomp$1_pre_obj$$.option&&$_opt_detail$jscomp$1_pre_obj$$.option.phan_bo_evoucher){let $tien_evoucher_da_phan_bo$$=0,$tien_evoucher$$=$obj$$.tien_evoucher,$tien_evoucher_con_lai$$=$tien_evoucher$$-$tien_evoucher_da_phan_bo$$;($obj$$.details||[]).forEach($detail$$=>{if($tien_evoucher_con_lai$$>0){var $tien_evoucher_duoc_pb_tien_hang_con_lai$$=$detail$$.tien_hang_nt-
|
|
20
|
+
($detail$$.tien_ck_nt||0);$tien_evoucher_duoc_pb_tien_hang_con_lai$$=$tien_evoucher_con_lai$$>$tien_evoucher_duoc_pb_tien_hang_con_lai$$?$tien_evoucher_duoc_pb_tien_hang_con_lai$$:$tien_evoucher_con_lai$$;$detail$$.tien_evoucher_duoc_pb=$tien_evoucher_duoc_pb_tien_hang_con_lai$$;$tien_evoucher_da_phan_bo$$+=$tien_evoucher_duoc_pb_tien_hang_con_lai$$;$tien_evoucher_con_lai$$=$tien_evoucher$$-$tien_evoucher_da_phan_bo$$}else $tien_evoucher_con_lai$$=0})}await ($obj$$.details||[]).asyncJoinModel2($user$$.current_id_app,
|
|
21
|
+
dmvt,{where:"ma_vt",fields:"is_coin"});if($obj$$.paymentByPoints)try{var $he_so_qd_i$$=await currency.getRate($obj$$.id_app,$obj$$.ma_nt);$obj$$.tien_paymentByPoints=$obj$$.paymentByPoints*$he_so_qd_i$$}catch($e$$){return $next$$($e$$.message)}for($he_so_qd_i$$=0;$he_so_qd_i$$<($obj$$.details||[]).length;$he_so_qd_i$$++)$_opt_detail$jscomp$1_pre_obj$$=($obj$$.details||[])[$he_so_qd_i$$],$_opt_detail$jscomp$1_pre_obj$$.line=$he_so_qd_i$$,$obj$$.ma_nt==="VND"&&($_opt_detail$jscomp$1_pre_obj$$.tien=
|
|
22
|
+
$_opt_detail$jscomp$1_pre_obj$$.tien_nt,$_opt_detail$jscomp$1_pre_obj$$.tien_hang=$_opt_detail$jscomp$1_pre_obj$$.tien_hang_nt,$_opt_detail$jscomp$1_pre_obj$$.tien_ck=$_opt_detail$jscomp$1_pre_obj$$.tien_ck_nt,$_opt_detail$jscomp$1_pre_obj$$.gia_ban=$_opt_detail$jscomp$1_pre_obj$$.gia_ban_nt),$_opt_detail$jscomp$1_pre_obj$$.tien_xuat=$_opt_detail$jscomp$1_pre_obj$$.tien_xuat_nt;$obj$$.ma_dvcs?$next$$(null,$obj$$):dvcs.findOne({id_app:$user$$.current_id_app},{_id:1},function($error$$,$dv$$){return $error$$?
|
|
23
|
+
$next$$($error$$):$dv$$?($obj$$.ma_dvcs=$dv$$._id.toString(),$next$$(null,$obj$$)):$next$$("C\u00f4ng ty/c\u1eeda h\u00e0ng n\u00e0y ch\u01b0a c\u00f3 m\u1ed9t \u0111\u01a1n v\u1ecb c\u01a1 s\u1edf n\u00e0o")})};
|
|
24
|
+
module.exports=function($contr_router$$){$contr_router$$=new controller($contr_router$$,model,ma_ct.toLowerCase(),{isVoucher:!0,requireRecaptchaToken:!1,requireOtp:$data$$=>$data$$.trang_thai=="0"||$data$$.trang_thai=="2"||$data$$.trang_thai=="8"?!1:!0,unique:["so_ct"],sort:{ngay_ct:-1,so_ct:-1},onEmitEvent:async($obj$$,$users_will_receive$$,$next$$)=>{$obj$$.user_nv_giao_hang&&$users_will_receive$$.push($obj$$.user_nv_giao_hang);$next$$(null,$users_will_receive$$)}});$contr_router$$.route();$contr_router$$.handleAfterPayment=
|
|
25
|
+
async $obj$$=>{Logger.info("[so5][handleAfterPayment]xu ly nap tien vao vi",$obj$$.details);var $app$$=await App.findOne({_id:$obj$$.id_app});if($app$$.wallet_address&&$app$$.wallet_token&&$obj$$.details){try{for(let $detail$$ of $obj$$.details.filter($d$$=>$d$$.is_coin&&!$d$$.transferred&&$d$$.wallet_receiver)){let $memo$$=$obj$$.dien_giai||"N\u1ea1p ti\u1ec1n v\u00e0o v\u00ed",$amount$$=$detail$$.sl_xuat,$denom$$=$detail$$.ma_vt.toLowerCase();Logger.info("chuyen tien vao vi nguoi nap",{amount:$amount$$,
|
|
26
|
+
denom:$denom$$,receiver:$detail$$.wallet_receiver});let $rs$$=await blockchainconnect.spend($obj$$.id_app,$app$$.wallet_token,$app$$.wallet_address,$detail$$.wallet_receiver,{amount:$amount$$,denom:$denom$$,memo:$memo$$});Logger.info("[so5][handleAfterPayment]buy point result",$rs$$,$amount$$,$denom$$,$memo$$);$detail$$.transferred=!0}await model.findOneAndUpdate({_id:$obj$$._id},{details:$obj$$.details,trang_thai:"5"});$obj$$.trang_thai="5"}catch($e$$){Logger.error($e$$),await model.findOneAndUpdate({_id:$obj$$._id},
|
|
27
|
+
{trang_thai:"7"}),$obj$$.trang_thai="7"}if($app$$=global.controllers.SO5)await controller.asyncPostData($obj$$,$app$$),controller.pushNotification($app$$,$obj$$)}return null};$contr_router$$.post=async function($obj$$,$fn$$){$fn$$||=function(){};let $he_so_qd$$=await currency.getRate($obj$$.id_app,$obj$$.ma_nt)||1;await ($obj$$.details||[]).asyncJoinModel2($obj$$.id_app,dmvt,{where:"ma_vt",fields:["is_point","is_coin"]});async.series({BuyPoint:$callback$$=>{BuyPoint($obj$$).then(()=>{$callback$$()}).catch($e$$=>
|
|
28
|
+
{$callback$$($e$$)})},post_sodiemthuong:function($callback$$){const $details$$=[];$obj$$.details.filter($d$$=>$d$$.diem_thuong).forEach($d$jscomp$7_detail$$=>{$d$jscomp$7_detail$$={...$d$jscomp$7_detail$$};$d$jscomp$7_detail$$.ngay_ct=$obj$$.ngay_ct;$d$jscomp$7_detail$$.ma_kh=$obj$$.ma_kh;$d$jscomp$7_detail$$.sl_nhan=$d$jscomp$7_detail$$.diem_thuong;$details$$.push($d$jscomp$7_detail$$)});(new PostBook($obj$$,$details$$,Sodiemthuong)).run(function($e$$,$rs$$){$callback$$($e$$,$rs$$)})},post_socai:function($callback$$){if(!$obj$$.virtual_payment_client_url)return $callback$$();
|
|
29
|
+
options.findOne({id_app:$obj$$.id_app,id_func:ma_ct.toLowerCase()}).lean().exec(async($error$jscomp$3_tt_tt$$,$rs$$)=>{let $option$$;$option$$=$rs$$?$rs$$.option||{}:{};let $pt$$;$obj$$.pt_thanh_toan&&global.mongoose.Types.ObjectId.isValid($obj$$.pt_thanh_toan)&&($pt$$=await ptthanhtoan.findOne({id_app:$obj$$.id_app,_id:$obj$$.pt_thanh_toan}).lean());$pt$$=$pt$$||{};$pt$$.ma_kh&&($pt$$.tk_tien=$pt$$.tk_cn);Logger.info("phuong thuc thanh toan so5",$obj$$.pt_thanh_toan,$pt$$);$option$$.tk_tien=$pt$$.tk_tien||
|
|
30
|
+
$option$$.tk_tien||"1111";$option$$.tk_cn=$pt$$.tk_cn||$option$$.tk_cn||"131111";$option$$.tk_dt=$pt$$.tk_dt||$option$$.tk_dt||"51111";$option$$.tk_tl=$pt$$.tk_tl||$option$$.tk_tl||"52131";$option$$.tk_ck=$pt$$.tk_ck||$option$$.tk_ck||"52111";$option$$.tk_cp_bh=$pt$$.tk_cp_bh||$option$$.tk_cp_bh||$option$$.tk_ck;$option$$.ma_kh=$pt$$.ma_kh||$obj$$.ma_kh;const $details$$=[];$obj$$.details.forEach(function($d$jscomp$8_detail$$){$d$jscomp$8_detail$$={...$d$jscomp$8_detail$$};$d$jscomp$8_detail$$.tk_co=
|
|
31
|
+
$option$$.tk_dt;$d$jscomp$8_detail$$.tk_no=$option$$.tk_tien;$d$jscomp$8_detail$$.ma_kh_co=$obj$$.ma_kh;$d$jscomp$8_detail$$.ma_kh_no=$option$$.ma_kh;$d$jscomp$8_detail$$.tien_nt=$d$jscomp$8_detail$$.tien_hang_nt-($d$jscomp$8_detail$$.tien_ck_nt||0);$d$jscomp$8_detail$$.tien=$d$jscomp$8_detail$$.tien_hang-($d$jscomp$8_detail$$.tien_ck||0);$details$$.push($d$jscomp$8_detail$$)});$obj$$.details.filter($d$$=>$d$$.diem_thuong&&$d$$.tk_km_no&&$d$$.tk_km_co).forEach(function($d$$){let $detail$$={...$d$$};
|
|
32
|
+
$detail$$.tk_co=$option$$.tk_km_co||$d$$.tk_km_co;$detail$$.tk_no=$option$$.tk_km_no||$d$$.tk_km_no;$detail$$.ma_kh=$obj$$.ma_kh;$detail$$.tien=$detail$$.tien_nt=$detail$$.diem_thuong*$he_so_qd$$;$details$$.push($detail$$)});$obj$$.tt_tien_thuong&&($error$jscomp$3_tt_tt$$={},$error$jscomp$3_tt_tt$$.tk_no=$option$$.tk_cp_bh,$error$jscomp$3_tt_tt$$.tk_co=$option$$.tk_tien,$error$jscomp$3_tt_tt$$.tien_nt=$obj$$.tt_tien_thuong||0,$error$jscomp$3_tt_tt$$.tien=$error$jscomp$3_tt_tt$$.tien_nt,$error$jscomp$3_tt_tt$$.ma_kh_no=
|
|
33
|
+
$obj$$.ma_kh,$error$jscomp$3_tt_tt$$.ma_kh_co=$option$$.ma_kh,$details$$.push($error$jscomp$3_tt_tt$$));if($obj$$.tien_ck_hd||$obj$$.tien_evoucher)$error$jscomp$3_tt_tt$$={},$error$jscomp$3_tt_tt$$.tk_no=$option$$.tk_ck,$error$jscomp$3_tt_tt$$.tk_co=$option$$.tk_tien,$error$jscomp$3_tt_tt$$.tien_nt=($obj$$.tien_ck_hd||0)+($obj$$.tien_evoucher||0),$error$jscomp$3_tt_tt$$.tien=$error$jscomp$3_tt_tt$$.tien_nt,$error$jscomp$3_tt_tt$$.ma_kh_no=$obj$$.ma_kh,$error$jscomp$3_tt_tt$$.ma_kh_co=$option$$.ma_kh,
|
|
34
|
+
$error$jscomp$3_tt_tt$$.check_balance=!1,$details$$.push($error$jscomp$3_tt_tt$$);(new PostSocai($obj$$,$details$$)).run(function($e$$,$rs$$){$callback$$($e$$,$rs$$)})})}},function($e$$,$rs$$){$fn$$($e$$,$rs$$)})};$contr_router$$.creating=async function($user$$,$obj$$,$next$$){$obj$$.details||($obj$$.details=[]);$obj$$.virtual_payment_client_url=void 0;if(!$obj$$.ma_kh){let $cust$$=await global.getModel("customer").findOne({id_app:$user$$.current_id_app,of_user:$user$$.email},{ma_kh:1,ten_kh:1}).lean();
|
|
35
|
+
$cust$$&&($obj$$.ma_kh=$cust$$.ma_kh)}valid($user$$,$obj$$,async $error$$=>{if($error$$)return $next$$($error$$);if(!$obj$$.paymentByPoints)return $next$$(null,$obj$$);try{let $detail_buy_coins$$=$obj$$.details.filter($d$$=>$d$$.is_coin&&!$d$$.transferred&&$d$$.wallet_receiver).asyncGroupBy(["ma_vt"],["sl_xuat"]);if($detail_buy_coins$$.length==1&&await getWalletBalanceOfApp($user$$.current_id_app,$detail_buy_coins$$[0].ma_vt.toLowerCase())<$detail_buy_coins$$[0].sl_xuat)return $next$$("B\u1ea1n kh\u00f4ng th\u1ec3 n\u1ea1p ti\u1ec1n th\u1eddi gian n\u00e0y. Hay th\u1eed l\u1ea1i sau");
|
|
36
|
+
if($detail_buy_coins$$.length>1)return $next$$("M\u1ed7i l\u1ea7n ch\u1ec9 \u0111\u01b0\u1ee3c mua m\u1ed9t lo\u1ea1i coin");if(await getPointBalance($user$$.current_id_app,$user$$.email)<$obj$$.paymentByPoints)return $next$$("B\u1ea1n kh\u00f4ng c\u00f3 \u0111\u1ee7 \u0111i\u1ec3m \u0111\u1ec3 th\u1ef1c hi\u1ec7n giao d\u1ecbch n\u00e0y.");$next$$(null,$obj$$)}catch($e$$){$next$$($e$$.message)}})};$contr_router$$.created=async function($user$$,$obj$$,$next$$){if($obj$$.pt_thanh_toan&&global.mongoose.Types.ObjectId.isValid($obj$$.pt_thanh_toan))try{const $pt_thanh_toan$$=
|
|
37
|
+
await global.getModel("ptthanhtoan").findOne({_id:$obj$$.pt_thanh_toan});if($pt_thanh_toan$$.payment_service){let $paymentServiceModel$$=global.getModel($pt_thanh_toan$$.payment_service);$obj$$.amount=$obj$$.t_tt_nt-($obj$$.tien_paymentByPoints||0);if($obj$$.amount&&$paymentServiceModel$$.createVirtualPaymentClientURL){let $virtual_payment_client_url$$=await $paymentServiceModel$$.createVirtualPaymentClientURL($obj$$,$user$$.clientIp,$pt_thanh_toan$$);$obj$$.virtual_payment_client_url=$virtual_payment_client_url$$;
|
|
38
|
+
$obj$$.payment_service=$pt_thanh_toan$$.payment_service;$obj$$.payment_id=((await $paymentServiceModel$$.findOne({$or:[{id_ct:$obj$$._id.toString()},{request_id:$obj$$._id.toString()},{order_id:$obj$$._id.toString()}]})||{})._id||"").toString()}else $obj$$.virtual_payment_client_url="",$obj$$.payment_service="",$obj$$.payment_id=""}else $obj$$.virtual_payment_client_url=""}catch($e$$){return Logger.error($e$$),$next$$("Kh\u00f4ng tao li\u00ean k\u1ebft thanh to\u00e1n:"+($e$$.message||$e$$.error||
|
|
39
|
+
$e$$))}else Logger.info("Chua nhap phuong thuc thanh toan"),$obj$$.virtual_payment_client_url="";await model.updateOne({_id:$obj$$._id},{virtual_payment_client_url:$obj$$.virtual_payment_client_url,payment_id:$obj$$.payment_id,payment_service:$obj$$.payment_service}).catch(console.error);await createTransactionPayment($obj$$);await createTransactionBonus($obj$$);$obj$$.evouchers&&await Promise.all($obj$$.evouchers.map($e$$=>updateEvoucher($e$$.id_app,$e$$.ma,$obj$$._id)));$next$$(null,$obj$$)};$contr_router$$.updating=
|
|
40
|
+
async($user$$,$data$$,$obj$$,$next$$)=>{$data$$.pt_thanh_toan&&$data$$.pt_thanh_toan!=$obj$$.pt_thanh_toan&&($data$$.virtual_payment_client_url="",$data$$.payment_service="",$data$$.payment_id="");valid($user$$,$data$$,async $detail_buy_coins$jscomp$1_error$$=>{if($detail_buy_coins$jscomp$1_error$$)return $next$$($detail_buy_coins$jscomp$1_error$$);if(($obj$$.paymentByPoints||0)!==($data$$.paymentByPoints||0))return $next$$("B\u1ea1n kh\u00f4ng th\u1ec3 c\u1eadp nh\u1eadt s\u1ed1 \u0111i\u1ec3m thanh to\u00e1n.");
|
|
41
|
+
$detail_buy_coins$jscomp$1_error$$=$data$$.details.filter($d$$=>$d$$.is_coin&&!$d$$.transferred&&$d$$.wallet_receiver).asyncGroupBy(["ma_vt"],["sl_xuat"]);if($detail_buy_coins$jscomp$1_error$$.length==1&&await getWalletBalanceOfApp($user$$.current_id_app,$detail_buy_coins$jscomp$1_error$$[0].ma_vt.toLowerCase())<$detail_buy_coins$jscomp$1_error$$[0].sl_xuat)return $next$$("B\u1ea1n kh\u00f4ng th\u1ec3 n\u1ea1p ti\u1ec1n th\u1eddi gian n\u00e0y. Hay th\u1eed l\u1ea1i sau");if($detail_buy_coins$jscomp$1_error$$.length>
|
|
42
|
+
1)return $next$$("M\u1ed7i l\u1ea7n ch\u1ec9 \u0111\u01b0\u1ee3c mua m\u1ed9t lo\u1ea1i coin");await transaction.deleteTrans({id_ct:$obj$$._id.toString()+":buy"});$next$$(null,$data$$,$obj$$)},$obj$$)};$contr_router$$.updated=async function($evouchers_user$$,$obj$$,$next$$){if(!$obj$$.virtual_payment_client_url&&($obj$$.trang_thai==="1"||$obj$$.trang_thai==="0")){if($obj$$.pt_thanh_toan&&global.mongoose.Types.ObjectId.isValid($obj$$.pt_thanh_toan))try{const $pt_thanh_toan$$=await global.getModel("ptthanhtoan").findOne({_id:$obj$$.pt_thanh_toan});
|
|
43
|
+
if($pt_thanh_toan$$.payment_service){let $paymentServiceModel$$=global.getModel($pt_thanh_toan$$.payment_service);$obj$$.amount=$obj$$.t_tt_nt-($obj$$.tien_paymentByPoints||0);if($obj$$.amount&&$paymentServiceModel$$.createVirtualPaymentClientURL){let $virtual_payment_client_url$$=await $paymentServiceModel$$.createVirtualPaymentClientURL($obj$$,$evouchers_user$$.clientIp,$pt_thanh_toan$$);$obj$$.virtual_payment_client_url=$virtual_payment_client_url$$;$obj$$.payment_service=$pt_thanh_toan$$.payment_service;
|
|
44
|
+
$obj$$.payment_id=((await $paymentServiceModel$$.findOne({$or:[{id_ct:$obj$$._id.toString()},{request_id:$obj$$._id.toString()},{order_id:$obj$$._id.toString()}]})||{})._id||"").toString()}else $obj$$.virtual_payment_client_url="",$obj$$.payment_service="",$obj$$.payment_id=""}else $obj$$.virtual_payment_client_url=""}catch($e$$){return Logger.error($e$$),$next$$("Error create Virtual Payment ClientURL:"+($e$$.message||$e$$.error||$e$$))}else $obj$$.virtual_payment_client_url="";await model.updateOne({_id:$obj$$._id},
|
|
45
|
+
{virtual_payment_client_url:$obj$$.virtual_payment_client_url,payment_id:$obj$$.payment_id,payment_service:$obj$$.payment_service}).catch(console.error)}$obj$$.trang_thai==="9"?(await transaction.deleteTrans({id_ct:$obj$$._id.toString()}),await transaction.deleteTrans({id_ct:$obj$$._id.toString()+":bonus"},"Tr\u1ea3 l\u1ea1i \u0111i\u1ec3m th\u01b0\u1edfng"),await transaction.deleteTrans({id_ct:$obj$$._id.toString()+":buy"})):(await createTransactionPayment($obj$$),createTransactionBonus($obj$$));
|
|
46
|
+
await Evoucher.updateMany({id_ct_used:$obj$$._id.toString()},{id_ct_used:null});$evouchers_user$$=await Evoucher.find({id_ct_useds:$obj$$._id.toString()});await Promise.all($evouchers_user$$.map($e$$=>deleteEvoucher($e$$.id_app,$e$$.ma,$obj$$._id)));$obj$$.evouchers&&await Promise.all($obj$$.evouchers.map($e$$=>updateEvoucher($e$$.id_app,$e$$.ma,$obj$$._id)));$next$$(null,$obj$$)};$contr_router$$.deleting=function($user$$,$obj$$,$next$$){$next$$(null,$obj$$)};$contr_router$$.deleted=async function($user$$,
|
|
47
|
+
$obj$$,$next$$){await transaction.deleteTrans({id_ct:$obj$$._id.toString()});await transaction.deleteTrans({id_ct:$obj$$._id.toString()+":bonus"},"Tr\u1ea3 l\u1ea1i \u0111i\u1ec3m th\u01b0\u1edfng");await transaction.deleteTrans({id_ct:$obj$$._id.toString()+":buy"});$obj$$.evouchers&&await Promise.all($obj$$.evouchers.map($e$$=>deleteEvoucher($e$$.id_app,$e$$.ma,$obj$$._id)));$next$$(null,$obj$$)};$contr_router$$.view=async function($user$$,$items$$,$fn$$){let $id_app$$=$user$$.current_id_app;await Promise.all($items$$.filter($item$$=>
|
|
48
|
+
$item$$.trang_thai=="0"||$item$$.trang_thai=="2"||$item$$.trang_thai=="7").map($inv$$=>(async()=>{let $tg_hien_tai$$=(new Date).getTime(),$tg_tao$$=(new Date($inv$$.date_created)).getTime();($tg_hien_tai$$-$tg_tao$$)/864E5>1&&($inv$$.trang_thai="9",await model.findOneAndUpdate({_id:$inv$$._id},{trang_thai:9}))})()));async.parallel({kh:function($callback$$){$items$$.filter($item$$=>$item$$.ma_kh).joinModel2($id_app$$,customer,[{where:"ma_kh",fields:"ten_kh"}],function(){$callback$$()})},nhan_vien_giao_hang:function($callback$$){$items$$.filter($item$$=>
|
|
49
|
+
$item$$.nhan_vien_giao_hang).joinModel2($id_app$$,customer,[{where:{nhan_vien_giao_hang:"ma_kh"},fields:[{ten_nhan_vien_giao_hang:"ten_kh"}]}],function(){$callback$$()})},nv_giao_hang:function($callback$$){$items$$.filter($item$$=>$item$$.user_nv_giao_hang).joinModel2(null,User,{where:{user_nv_giao_hang:"email"},fields:{ten_nv_giao_hang:"name"}},function(){$callback$$()})},trangthai:function($callback$$){$items$$.filter($item$$=>$item$$.trang_thai).joinModel2(null,trangthai,[{where:{trang_thai:"ma_trang_thai",
|
|
50
|
+
ma_ct:"ma_ct"},fields:["ten_trang_thai","color"]}],function(){$callback$$()})},ptthanhtoan:function($callback$$){$items$$.filter($item$$=>$item$$.pt_thanh_toan).joinModel2($id_app$$,ptthanhtoan,[{where:{pt_thanh_toan:"_id"},fields:[{ten_pt_thanh_toan:"ten"},{tk_cn_thanhtoan:"tk_cn"}]}],function(){$callback$$()})},pt1:function($callback$$){$items$$.joinModel2($id_app$$,pt1,[{where:{_id:"id_so5"},fields:[{id_pt1:"_id"},{so_ct_pt1:"so_ct"},{ma_ct_pt1:"ma_ct"},{ngay_ct_pt1:"ngay_ct"}]}],function(){$callback$$()})},
|
|
51
|
+
t_tien:function($callback$$){$items$$.forEach(function($r$$){$r$$.details?($r$$.t_sl=$r$$.details.csum("sl_xuat"),$r$$.t_tien_hang=$r$$.details.csum("tien_hang"),$r$$.t_tien_hang_nt=$r$$.details.csum("tien_hang_nt"),$r$$.t_tien=$r$$.t_tien_hang-$r$$.details.csum("tien_ck_nt"),$r$$.t_tien_nt=$r$$.t_tien_hang_nt-$r$$.details.csum("tien_ck"),$r$$.t_ck_nt=$r$$.t_ck=$r$$.tien_ck_hd+($r$$.tien_evoucher||0)):($r$$.t_sl=0,$r$$.t_tien_hang=0,$r$$.t_tien_hang_nt=0,$r$$.t_ck=0,$r$$.t_ck_nt=0,$r$$.t_tien=$r$$.t_tien_hang,
|
|
52
|
+
$r$$.t_tien_nt=$r$$.t_tien_hang_nt);$r$$.ctcpbhs?($r$$.t_cp_cpb_nt=$r$$.ctcpbhs.csum("tien_cp_nt"),$r$$.t_cp_cpb=$r$$.ctcpbhs.csum("tien_cp")):($r$$.t_cp_cpb_nt=0,$r$$.t_cp_cpb=0);$r$$.t_tt_nt=$r$$.t_tien_nt+$r$$.t_cp_cpb_nt-$r$$.t_ck_nt-($r$$.tt_tien_thuong||0)+($r$$.tien_phi_vc||0)-($r$$.tien_freeship||0);$r$$.t_tt=$r$$.t_tien+$r$$.t_cp_cpb-$r$$.t_ck-($r$$.tt_tien_thuong||0)+($r$$.tien_phi_vc||0)-($r$$.tien_freeship||0)});$callback$$()},details_vt:function($callback$$){async.each($items$$,function($details$jscomp$2_r$$,
|
|
53
|
+
$callback1$$){$details$jscomp$2_r$$=$details$jscomp$2_r$$.details;if(!$details$jscomp$2_r$$)return $callback1$$();$details$jscomp$2_r$$.joinModel2($id_app$$,dmvt,[{where:"ma_vt",fields:["ten_vt"]}],function(){$callback1$$()})},function(){$callback$$()})},details_tt1:function($callback$$){async.mapSeries($items$$,function($r$$,$callback1$$){($r$$.details||[]).filter($item$$=>$item$$.ma_tt1).joinModel2($id_app$$,dmtt,[{where:{ma_vt:"ma_vt",ma_tt1:"ma_tt"},setFields:($item$$,$ref$$)=>{$item$$.ten_vt=
|
|
54
|
+
$item$$.ten_vt+" - "+$ref$$.ten_tt}}],function(){$callback1$$()})},function(){$callback$$()})},details_dt:function($callback$$){async.mapSeries($items$$,function($details$jscomp$4_r$$,$callback1$$){$details$jscomp$4_r$$=$details$jscomp$4_r$$.details;if(!$details$jscomp$4_r$$)return $callback1$$();$details$jscomp$4_r$$.filter($item$$=>$item$$.ma_dt).joinModel2($id_app$$,dmdt,[{where:"ma_dt",fields:["ten_dt"]}],function(){$callback1$$()})},function(){$callback$$()})},details_contract:function($callback$$){async.mapSeries($items$$,
|
|
55
|
+
function($details$jscomp$5_r$$,$callback1$$){$details$jscomp$5_r$$=$details$jscomp$5_r$$.details;if(!$details$jscomp$5_r$$)return $callback1$$();$details$jscomp$5_r$$.filter($item$$=>$item$$.ma_hd).joinModel2($id_app$$,contract,[{where:{ma_hd:"so_hd"},fields:["ten_hd"]}],function(){$callback1$$()})},function(){$callback$$()})},details_phi:function($callback$$){async.mapSeries($items$$,function($details$jscomp$6_r$$,$callback1$$){$details$jscomp$6_r$$=$details$jscomp$6_r$$.details;if(!$details$jscomp$6_r$$)return $callback1$$();
|
|
56
|
+
$details$jscomp$6_r$$.filter($item$$=>$item$$.ma_phi).joinModel2($id_app$$,dmphi,[{where:"ma_phi",fields:["ten_phi"]}],function(){$callback1$$()})},function(){$callback$$()})},details_cpbh:function($callback$$){async.each($items$$,function($ctcpbhs_r$$,$callback1$$){$ctcpbhs_r$$=$ctcpbhs_r$$.ctcpbhs;if(!$ctcpbhs_r$$)return $callback1$$();$ctcpbhs_r$$?$ctcpbhs_r$$.filter($item$$=>$item$$.ma_cp).joinModel2($id_app$$,dmcpmh,[{where:"ma_cp",fields:["ten_cp"]}],function(){$callback1$$()}):$callback1$$()},
|
|
57
|
+
function(){$callback$$()})}},function(){$fn$$(null,$items$$)})}};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
const axios=require("axios"),moment=require("moment"),numeral=require("numeral"),PostBook=require("../../libs/post-book"),PostSocai=require("../../libs/post-socai"),Sokho=global.getModel("sokho"),Sokhott=global.getModel("sokhott"),_=require("lodash"),Tdttno=global.getModel("tdttno"),Tdttno_tt=global.getModel("tdttno_tt"),Vatra=global.getModel("vatra"),Options=global.getModel("options"),dvcs=global.getModel("dvcs"),dmvt=global.getModel("dmvt"),account=global.getModel("account"),dmkho=global.getModel("dmkho"),
|
|
2
|
+
customer=global.getModel("customer"),dmnv=global.getModel("dmnv"),dmdt=global.getModel("dmdt"),dmphi=global.getModel("dmphi"),contract=global.getModel("contract"),salecontract=global.getModel("sale_contract"),model=global.getModel("hd2"),controller=require("../../controllers/controller"),utils=require("../../libs/utils"),tinhhoahong=require("../../libs/tinhhoahong"),trangthai=global.getModel("trangthai"),async=require("async"),ma_ct="SO7",App=global.getModel("app"),blockchainconnect=require("../../libs/blockchainconnect"),
|
|
3
|
+
spend=async($appInfo$$,$receiver_user$$,$receiver_address$$,$amount$$,$denom$$,$memo$$,$introduce_code$$,$sub_action$$="")=>{try{await blockchainconnect.spend($appInfo$$._id,$appInfo$$.wallet_token,$appInfo$$.wallet_address,$receiver_address$$,{amount:$amount$$,denom:$denom$$,memo:$memo$$,action:"bonus",introduce_code:$introduce_code$$,sub_action:$sub_action$$})}catch($e$$){Logger.error("Error send coin",$e$$,$receiver_user$$,$receiver_address$$,$amount$$,$denom$$,$memo$$)}},tinhGiaChuaThue=($obj$$,
|
|
4
|
+
$detail$$)=>{let $f_tien_nt$$=$obj$$.ma_nt=="VND"?0:3;$obj$$=($detail$$.ma_thue?$detail$$.thue_suat:$obj$$.thue_suat)||0;$detail$$.gia_ban_ct_nt||($detail$$.tien_thue_nt?($detail$$.gia_ban_ct_nt=$detail$$.gia_ban_nt,$detail$$.tien_ct_nt=$detail$$.tien_nt,$detail$$.gia_ban_nt=$detail$$.gia_ban_ct_nt*(1+$detail$$.thue_suat/100)):($detail$$.gia_ban_ct_nt=utils.round($detail$$.gia_ban_nt/(1+$obj$$/100),5),$detail$$.tien_ct_nt=utils.round($detail$$.gia_ban_ct_nt*$detail$$.sl_xuat,$f_tien_nt$$)));$detail$$.tien_ck_nt=
|
|
5
|
+
$detail$$.tien_ck_nt||0;$detail$$.ty_le_ck&&($detail$$.tien_ck_nt=utils.round($detail$$.tien_ct_nt*$detail$$.ty_le_ck/100,$f_tien_nt$$));$detail$$.tien_thue_nt=utils.round(($detail$$.tien_ct_nt-$detail$$.tien_ck_nt)*$obj$$/100,$f_tien_nt$$);$detail$$.tien_nt=$detail$$.tien_ct_nt-$detail$$.tien_ck_nt+$detail$$.tien_thue_nt};
|
|
6
|
+
module.exports=function($router$$){const $contr$$=new controller($router$$,model,ma_ct.toLowerCase(),{isVoucher:!0,assignWiths:[{field:"ma_kho",ref_collection:"dmkho",ref_field:"ma_kho",ref_module:"dmkho"}],sort:{ngay_ct:-1,so_ct:-1},onFinding:($user$$,$condition$$,$next$$)=>{$next$$(null,$condition$$)}});$contr$$.route();$contr$$.validating=async($user$$,$obj$$,$next$$)=>{$obj$$.sdt_nguoi_nhan&&($obj$$.sdt_nguoi_nhan=$obj$$.sdt_nguoi_nhan.split(" ").join(""));if($obj$$.sdt_nguoi_nhan&&!utils.isMobilePhone($obj$$.sdt_nguoi_nhan,
|
|
7
|
+
"vi-VN"))return $next$$(`S\u1ed1 \u0111i\u1ec7n tho\u1ea1i ng\u01b0\u1eddi nh\u1eadn ${$obj$$.sdt_nguoi_nhan} l\u00e0 kh\u00f4ng h\u1ee3p l\u1ec7`);$next$$(null,$obj$$)};$contr$$.reposting=async($user$$,$obj$$)=>{$obj$$.user_created||($obj$$.user_created=$user$$.email);let $d$$=moment($obj$$.ngay_ct).subtract(1,"months").toDate();await $obj$$.details.asyncJoinModel2($obj$$.id_app,"giatb",{where:$item$$=>({ma_vt:$item$$.ma_vt,id_app:$obj$$.id_app,nam:$d$$.getFullYear(),thang:$d$$.getMonth()+1,gia:{$gt:0}}),
|
|
8
|
+
fields:[{gia_mua:"gia"}]});$obj$$.details.forEach($d$$=>{$d$$.tt_nt=$d$$.tien_ct_nt-$d$$.tien_ck_nt;$d$$.tt=$d$$.tien_ct-$d$$.tien_ck;$d$$.combo&&$d$$.combo.length>0&&($d$$.combo.forEach($c$$=>{$c$$.sl_xuat_1_combo=$d$$.sl_xuat?$c$$.sl_xuat/$d$$.sl_xuat:0;$c$$.tien_hang=$c$$.tien_hang_nt=0}),$d$$.gia_mua=$d$$.combo.map($c$$=>($c$$.gia_mua||0)*$c$$.sl_xuat_1_combo).reduce(($a$$,$b$$)=>$a$$+$b$$,0));$d$$.tien_xuat_tmp=$d$$.sl_xuat*($d$$.gia_mua||0)});await tinhhoahong($obj$$,$user$$);await model.updateOne({_id:$obj$$._id},
|
|
9
|
+
$obj$$)};$contr$$.saving=async($user$$,$obj$$)=>{$obj$$.ma_kho_npp="";$obj$$.of_user="";let $kho$$;$obj$$.ma_kho&&($kho$$=await global.getModel("dmkho").findOne({id_app:$obj$$.id_app,ma_kho:$obj$$.ma_kho,la_kho_thue:!0}).lean());$kho$$||=await global.getModel("dmkho").findOne({id_app:$obj$$.id_app,user_cho_thue:$user$$.email,la_kho_thue:!0}).lean();!$kho$$&&($kho$$=await global.getModel("dmkho").findOne({id_app:$obj$$.id_app,ds_ctv_kho_thue:$user$$.email,la_kho_thue:!0}).lean())&&($obj$$.user_ctv=
|
|
10
|
+
$user$$.email);if(!$kho$$)throw"Kho b\u00e1n kh\u00f4ng t\u1ed3n t\u1ea1i ho\u1eb7c kh\u00f4ng h\u1ee3p l\u1ec7";$obj$$.ma_kho=$kho$$.ma_kho;$obj$$.tk_no=$kho$$.tk_tien_giu_ho;$obj$$.of_user=$kho$$.user_cho_thue;$obj$$.user_created||($obj$$.user_created=$user$$.email);$obj$$.details.forEach($d$$=>{$d$$.sl_xuat=utils.round($d$$.sl_xuat,4);$d$$.tt_nt=$d$$.tien_ct_nt-$d$$.tien_ck_nt;$d$$.tt=$d$$.tien_ct-$d$$.tien_ck;$d$$.tien_xuat_tmp=$d$$.sl_xuat*($d$$.gia_mua||0);$d$$.ma_kho=""});await tinhhoahong($obj$$,
|
|
11
|
+
$user$$)};$contr$$.post=async($obj$$,$fn$$)=>{$fn$$||=function(){};const $appInfo$$=await global.getModel("app").findOne({_id:$obj$$.id_app}).lean(),$kho$$=await dmkho.findOne({id_app:$obj$$.id_app,ma_kho:$obj$$.ma_kho}).lean()||{};let $ma_kh_kho$$=(($kho$$.user_cho_thue?await customer.findOne({id_app:$obj$$.id_app,of_user:$kho$$.user_cho_thue}).lean():void 0)||{}).ma_kh,$options$$;try{$options$$=await Options.getInfo($obj$$.id_app,{id_func:$obj$$.ma_ct.toLowerCase()},"option")}catch($e$$){Logger.info($e$$.message,
|
|
12
|
+
{id_func:$obj$$.ma_ct})}$options$$||={};await $obj$$.details.asyncJoinModel2($obj$$.id_app,dmvt,{where:"ma_vt",fields:["gia_mua"]});let $product_details$$=$obj$$.details.map($detail$$=>{$detail$$.tien_nt=$detail$$.tien_nt||0;$detail$$.tien=$detail$$.tien||0;return $detail$$.combo&&$detail$$.combo.length>0?$detail$$.combo.map($item$$=>{$item$$=$item$$.toObject?$item$$.toObject():{...$item$$};$detail$$.gia_ban_nt||($item$$.gia_ban_nt=0,$item$$.gia_nt=0,$item$$.tien_nt=0,$item$$.tien=0,$item$$.tien_ck_nt=
|
|
13
|
+
0,$item$$.tien_ck=0);$item$$.ma_kho=$detail$$.ma_kho;delete $item$$.px_gia_dd;return $item$$}):[$detail$$]}).reduce(($a$$,$b$$)=>$a$$.concat($b$$),[]);async.series({post_sokho:$callback$$=>{let $details$$=[...$obj$$.details];$obj$$.details.forEach($d$$=>{$d$$.promotion&&$d$$.promotion.details_km&&$d$$.promotion.details_km.forEach($p$$=>{if($p$$.ma_vt&&$p$$.sl_km){let $_p$$={};_.extend($_p$$,$p$$,{sl_xuat:$p$$.sl_km});$details$$.push($_p$$)}})});$obj$$.promotion&&$obj$$.promotion.forEach($p$$=>{if($p$$.ma_vt&&
|
|
14
|
+
$p$$.sl_km){let $_p$$={};_.extend($_p$$,$p$$,{sl_xuat:$p$$.sl_km});$details$$.push($_p$$)}});async.series({kt:$callback$$=>{$options$$.not_post_sokho?$callback$$():(new PostBook($obj$$,$product_details$$,Sokho,async($detail$$,$callback$$)=>{$detail$$.nxt=2;$detail$$.tk_no=$obj$$.tk_no;$detail$$.ma_kho=$detail$$.ma_kho||$obj$$.ma_kho;$callback$$($detail$$)})).run(function($e$$,$rs$$){$callback$$($e$$,$rs$$)})},tt:$callback$$=>{$options$$.post_sokhott?(new PostBook($obj$$,$product_details$$,Sokhott,
|
|
15
|
+
async($detail$$,$callback$$)=>{$detail$$.nxt=2;$detail$$.tk_no=$obj$$.tk_no;$detail$$.ma_kho=$detail$$.ma_kho||$obj$$.ma_kho;$callback$$($detail$$)})).run(function($e$$,$rs$$){$callback$$($e$$,$rs$$)}):$callback$$()},npp:$callback$$=>{setImmediate(async()=>{$obj$$.ma_kho_npp?(new PostBook($obj$$,$product_details$$,global.getModel("sokhonpp"),async($detail$$,$callback$$)=>{$detail$$.nxt=1;$detail$$.sl_nhap=$detail$$.sl_xuat;$detail$$.gia_von_nt=$detail$$.gia_ban_nt;$detail$$.gia_von=$detail$$.gia_ban;
|
|
16
|
+
$detail$$.tien_nhap_nt=$detail$$.tien_nt-($detail$$.tien_ck_nt||0);$detail$$.tien_nhap=$detail$$.tien-($detail$$.tien_ck||0);$detail$$.tk_co=$obj$$.tk_co;$detail$$.ma_kho=$obj$$.ma_kho_npp;$detail$$.sl_xuat=0;$detail$$.sl_xuat_qd=0;$detail$$.tien_xuat=$detail$$.tien_xuat_nt=0;$callback$$($detail$$)})).run(function($e$$,$rs$$){$callback$$($e$$,$rs$$)}):$callback$$()})}},($e$$,$rs$$)=>{$callback$$($e$$,$rs$$)})},post_vatra:function($callback$$){(async()=>{if($obj$$.ngay_hd){let $d$$=$obj$$.details.map($detail$$=>
|
|
17
|
+
({...$detail$$,thue_suat:($detail$$.ma_thue?$detail$$.thue_suat:$obj$$.thue_suat)||0,ma_thue:$detail$$.ma_thue||$obj$$.ma_thue,tien_thue_nt:$detail$$.tien_thue_nt||0,tien_thue:$detail$$.tien_thue||0})).filter($d$$=>$d$$.ma_thue);await $d$$.filter($r$$=>!$r$$.tk_thue_co&&$r$$.ma_thue).asyncJoinModel2($obj$$.id_app,"vat",{where:"ma_thue",fields:["tk_thue_co"]});$d$$.asyncGroupBy(["ma_thue","thue_suat","ten_vt_vat","tk_thue_co"],"tien_ct_nt tien_ct tien_nt tien tien_ck tien_ck_nt tien_thue tien_thue_nt".split(" ")).then($ds$$=>
|
|
18
|
+
{if($ds$$.length==1){let $tien_thue_nt$$=$ds$$.map($d$$=>$d$$.tien_thue_nt).reduce(($a$$,$b$$)=>$a$$+$b$$,0),$tien_thue$$=$ds$$.map($d$$=>$d$$.tien_thue).reduce(($a$$,$b$$)=>$a$$+$b$$,0);$tien_thue_nt$$==0&&$tien_thue$$==0&&($tien_thue_nt$$=$obj$$.t_thue_nt||0,$tien_thue$$=$obj$$.t_thue||0);$ds$$[0].tien_thue_nt=$tien_thue_nt$$;$ds$$[0].tien_thue=$tien_thue$$}(new PostBook($obj$$,$ds$$,Vatra,function($detail$$,$callback$$){try{$detail$$.tk_du_thue=$obj$$.tk_no,$detail$$.t_tien_nt=($detail$$.tien_ct_nt||
|
|
19
|
+
0)-($detail$$.tien_ck_nt||0),$detail$$.t_tien=($detail$$.tien_ct||0)-($detail$$.tien_ck||0),$detail$$.t_thue_nt=$detail$$.tien_thue_nt,$detail$$.t_thue=$detail$$.tien_thue,$detail$$.ten_vt=$detail$$.ten_vt_vat||$obj$$.ten_vt||$obj$$.dien_giai}catch($e$$){Logger.error($e$$,$obj$$)}$callback$$($detail$$)})).run(function($e$$,$rs$$){$callback$$($e$$,$rs$$)})})}else $callback$$()})()},post_socai:function($callback$$){setImmediate(async()=>{let $details$$=[];$obj$$.details.forEach(function($d$jscomp$9_detail$$){$d$jscomp$9_detail$$=
|
|
20
|
+
{...$d$jscomp$9_detail$$};$d$jscomp$9_detail$$.tien_nt=$d$jscomp$9_detail$$.tien_ct_nt;$d$jscomp$9_detail$$.tien=$d$jscomp$9_detail$$.tien_ct;$d$jscomp$9_detail$$.tk_co=$d$jscomp$9_detail$$.tk_dt||$kho$$.tk_dt||$options$$.tk_dt;$d$jscomp$9_detail$$.ma_kh=$ma_kh_kho$$;$d$jscomp$9_detail$$.tk_no=$obj$$.tk_no;$details$$.push($d$jscomp$9_detail$$)});$obj$$.details.forEach(function($d$jscomp$10_detail$$){$d$jscomp$10_detail$$={...$d$jscomp$10_detail$$};$d$jscomp$10_detail$$.tk_no=$d$jscomp$10_detail$$.tk_ck||
|
|
21
|
+
$obj$$.tk_ck||$kho$$.tk_ck||$options$$.tk_ck;$d$jscomp$10_detail$$.ma_kh=$ma_kh_kho$$;$d$jscomp$10_detail$$.tk_co=$obj$$.tk_no;$d$jscomp$10_detail$$.tien_nt=$d$jscomp$10_detail$$.tien_ck_nt;$d$jscomp$10_detail$$.tien=$d$jscomp$10_detail$$.tien_ck;$d$jscomp$10_detail$$.check_balance=!1;$details$$.push($d$jscomp$10_detail$$)});if($obj$$.tien_ck_hd){var $o_tt$$={};$o_tt$$.tk_no=$obj$$.tk_ck||$kho$$.tk_ck||$options$$.tk_ck;$o_tt$$.tk_co=$obj$$.tk_no;$o_tt$$.tien_nt=$obj$$.tien_ck_hd;$o_tt$$.tien=$o_tt$$.tien_nt*
|
|
22
|
+
($obj$$.ty_gia||1);$o_tt$$.ma_kh=$ma_kh_kho$$;$o_tt$$.check_balance=!1;$details$$.push($o_tt$$)}$o_tt$$={...$obj$$};$o_tt$$.tk_no=$obj$$.tk_no;$o_tt$$.tk_co=$obj$$.tk_thue_co;$o_tt$$.ma_kh=$ma_kh_kho$$;$o_tt$$.tien_nt=$obj$$.tien_thue_dc_nt||$obj$$.details.csum("tien_thue_nt");$o_tt$$.tien=$o_tt$$.tien_nt*$o_tt$$.ty_gia;$o_tt$$.dien_giai_thue&&($o_tt$$.dien_giai=$o_tt$$.dien_giai_thue);$details$$.push($o_tt$$);$obj$$.thu_nhap_ctv&&$obj$$.ma_ctv&&($obj$$.details.filter($r$$=>$r$$.tien_hoa_hong_ctv).forEach($r$$=>
|
|
23
|
+
{$r$$.tk_cp_ctv=$r$$.tk_cp_ctv||$obj$$.tk_cp_ctv||$kho$$.tk_cp_ctv||$options$$.tk_cp_ctv||$obj$$.tk_no_hoa_hong||$kho$$.tk_no_hoa_hong||$options$$.tk_no_hoa_hong;$r$$.tk_cn_ctv=$r$$.tk_cn_ctv||$obj$$.tk_cn_ctv||$kho$$.tk_cn_ctv||$options$$.tk_cn_ctv||$obj$$.tk_co_hoa_hong||$kho$$.tk_co_hoa_hong||$options$$.tk_co_hoa_hong}),(await $obj$$.details.filter($r$$=>$r$$.tien_hoa_hong_ctv).asyncGroupBy(["tk_cp_ctv","tk_cn_ctv"],["tien_hoa_hong_ctv"])).forEach($r$$=>{let $tt$$={};$tt$$.tk_no=$r$$.tk_cp_ctv;
|
|
24
|
+
$tt$$.tk_co=$r$$.tk_cn_ctv;$tt$$.tien=$tt$$.tien_nt=$r$$.tien_hoa_hong_ctv;$tt$$.ma_kh=$obj$$.ma_ctv;$tt$$.ma_nt="VND";$tt$$.ty_gia=1;$tt$$.dien_giai="Hoa h\u1ed3ng b\u00e1n h\u00e0ng c\u1ed9ng t\u00e1c vi\u00ean c\u1ea5p 1";$tt$$.tk_no&&$tt$$.tk_co&&$details$$.push($tt$$)}));$obj$$.thu_nhap_ctv2&&$obj$$.ma_ctv2&&($obj$$.details.filter($r$$=>$r$$.tien_hoa_hong_ctv2).forEach($r$$=>{$r$$.tk_cp_ctv=$r$$.tk_cp_ctv||$obj$$.tk_cp_ctv||$kho$$.tk_cp_ctv||$options$$.tk_cp_ctv||$obj$$.tk_no_hoa_hong||$kho$$.tk_no_hoa_hong||
|
|
25
|
+
$options$$.tk_no_hoa_hong;$r$$.tk_cn_ctv=$r$$.tk_cn_ctv||$obj$$.tk_cn_ctv||$kho$$.tk_cn_ctv||$options$$.tk_cn_ctv||$obj$$.tk_co_hoa_hong||$kho$$.tk_co_hoa_hong||$options$$.tk_co_hoa_hong}),(await $obj$$.details.filter($r$$=>$r$$.tien_hoa_hong_ctv2).asyncGroupBy(["tk_cp_ctv","tk_cn_ctv"],["tien_hoa_hong_ctv2"])).forEach($r$$=>{let $tt$$={};$tt$$.tk_no=$r$$.tk_cp_ctv;$tt$$.tk_co=$r$$.tk_cn_ctv;$tt$$.tien=$tt$$.tien_nt=$r$$.tien_hoa_hong_ctv2;$tt$$.ma_kh=$obj$$.ma_ctv2;$tt$$.ma_nt="VND";$tt$$.ty_gia=
|
|
26
|
+
1;$tt$$.dien_giai="Hoa h\u1ed3ng b\u00e1n h\u00e0ng c\u00f4ng t\u00e1c vi\u00ean c\u1ea5p 2";$tt$$.tk_no&&$tt$$.tk_co&&$details$$.push($tt$$)}));$obj$$.tien_hoa_hong&&$obj$$.ma_kh_hoa_hong&&($obj$$.details.filter($r$$=>$r$$.tien_hoa_hong).forEach($r$$=>{$r$$.tk_no_hoa_hong=$r$$.tk_no_hoa_hong||$obj$$.tk_no_hoa_hong||$kho$$.tk_no_hoa_hong||$options$$.tk_no_hoa_hong;$r$$.tk_co_hoa_hong=$r$$.tk_co_hoa_hong||$obj$$.tk_co_hoa_hong||$kho$$.tk_co_hoa_hong||$options$$.tk_co_hoa_hong}),(await $obj$$.details.filter($r$$=>
|
|
27
|
+
$r$$.tien_hoa_hong).asyncGroupBy(["tk_no_hoa_hong","tk_co_hoa_hong"],["tien_hoa_hong"])).forEach($r$$=>{let $tt$$={};$tt$$.tk_no=$r$$.tk_no_hoa_hong;$tt$$.tk_co=$r$$.tk_co_hoa_hong;$tt$$.tien=$tt$$.tien_nt=$r$$.tien_hoa_hong;$tt$$.tien=$tt$$.tien_nt*($obj$$.ty_gia||1);$tt$$.ma_kh=$obj$$.ma_kh_hoa_hong;$tt$$.ma_nv=$obj$$.ma_nv;$tt$$.check_balance=!1;$tt$$.ma_nt="VND";$tt$$.ty_gia=1;$tt$$.dien_giai="Hoa h\u1ed3ng b\u00e1n h\u00e0ng";$tt$$.tk_no&&$tt$$.tk_co&&$details$$.push($tt$$)}));$obj$$.tien_hoa_hong_gt&&
|
|
28
|
+
$obj$$.ma_kh_hoa_hong_gt&&($obj$$.details.filter($r$$=>$r$$.tien_hoa_hong_gt).forEach($r$$=>{$r$$.tk_no_hoa_hong_gt=$r$$.tk_no_hoa_hong_gt||$obj$$.tk_no_hoa_hong_gt||$kho$$.tk_no_hoa_hong_gt||$options$$.tk_no_hoa_hong_gt||$obj$$.tk_no_hoa_hong||$kho$$.tk_no_hoa_hong||$options$$.tk_no_hoa_hong;$r$$.tk_co_hoa_hong_gt=$r$$.tk_co_hoa_hong_gt||$obj$$.tk_co_hoa_hong_gt||$kho$$.tk_co_hoa_hong_gt||$options$$.tk_co_hoa_hong_gt||$obj$$.tk_co_hoa_hong||$kho$$.tk_co_hoa_hong||$options$$.tk_co_hoa_hong}),(await $obj$$.details.filter($r$$=>
|
|
29
|
+
$r$$.tien_hoa_hong_gt).asyncGroupBy(["tk_no_hoa_hong_gt","tk_co_hoa_hong_gt"],["tien_hoa_hong_gt"])).forEach($r$$=>{let $tt$$={};$tt$$.tk_no=$r$$.tk_no_hoa_hong_gt;$tt$$.tk_co=$r$$.tk_co_hoa_hong_gt;$tt$$.tien_nt=$r$$.tien_hoa_hong_gt;$tt$$.tien=$tt$$.tien_nt*($obj$$.ty_gia||1);$tt$$.ma_kh=$obj$$.ma_kh_hoa_hong_gt;$tt$$.ma_nv=$obj$$.ma_nv;$tt$$.check_balance=!1;$tt$$.dien_giai="Hoa h\u1ed3ng gi\u1edbi thi\u1ec7u";$tt$$.ma_nt="VND";$tt$$.ty_gia=1;$tt$$.tk_no&&$tt$$.tk_co&&$details$$.push($tt$$)}));
|
|
30
|
+
$obj$$.tien_hoa_hong_kho&&$obj$$.ma_kh_hoa_hong_kho&&($obj$$.details.filter($r$$=>$r$$.tien_hoa_hong_kho).forEach($r$$=>{$r$$.tk_no_hoa_hong_kho=$r$$.tk_no_hoa_hong_kho||$obj$$.tk_no_hoa_hong_kho||$kho$$.tk_no_hoa_hong_kho||$options$$.tk_no_hoa_hong_kho||$obj$$.tk_no_hoa_hong||$kho$$.tk_no_hoa_hong||$options$$.tk_no_hoa_hong;$r$$.tk_co_hoa_hong_kho=$r$$.tk_co_hoa_hong_kho||$obj$$.tk_co_hoa_hong_kho||$kho$$.tk_co_hoa_hong_kho||$options$$.tk_co_hoa_hong_kho||$obj$$.tk_co_hoa_hong||$kho$$.tk_co_hoa_hong||
|
|
31
|
+
$options$$.tk_co_hoa_hong}),(await $obj$$.details.filter($r$$=>$r$$.tien_hoa_hong_kho).asyncGroupBy(["tk_no_hoa_hong_kho","tk_co_hoa_hong_kho"],["tien_hoa_hong_kho"])).forEach($r$$=>{let $tt$$={};$tt$$.tk_no=$r$$.tk_no_hoa_hong_kho;$tt$$.tk_co=$r$$.tk_co_hoa_hong_kho;$tt$$.tien_nt=$r$$.tien_hoa_hong_kho;$tt$$.tien=$tt$$.tien_nt*($obj$$.ty_gia||1);$tt$$.ma_kh=$obj$$.ma_kh_hoa_hong_kho;$tt$$.ma_nv=$obj$$.ma_nv;$tt$$.check_balance=!1;$tt$$.dien_giai="Hoa h\u1ed3ng cho ch\u1ee7 kho";$tt$$.ma_nt="VND";
|
|
32
|
+
$tt$$.ty_gia=1;$tt$$.tk_no&&$tt$$.tk_co&&$details$$.push($tt$$)}));$obj$$.tien_hoa_hong_ql&&$obj$$.ma_kh_hoa_hong_ql&&($obj$$.details.filter($r$$=>$r$$.tien_hoa_hong_ql).forEach($r$$=>{$r$$.tk_no_hoa_hong_ql=$r$$.tk_no_hoa_hong_ql||$obj$$.tk_no_hoa_hong_ql||$kho$$.tk_no_hoa_hong_ql||$options$$.tk_no_hoa_hong_ql||$obj$$.tk_no_hoa_hong||$kho$$.tk_no_hoa_hong||$options$$.tk_no_hoa_hong;$r$$.tk_co_hoa_hong_ql=$r$$.tk_co_hoa_hong_ql||$obj$$.tk_co_hoa_hong_ql||$kho$$.tk_co_hoa_hong_ql||$options$$.tk_co_hoa_hong_ql||
|
|
33
|
+
$obj$$.tk_co_hoa_hong||$kho$$.tk_co_hoa_hong||$options$$.tk_co_hoa_hong}),(await $obj$$.details.filter($r$$=>$r$$.tien_hoa_hong_ql).asyncGroupBy(["tk_no_hoa_hong_ql","tk_co_hoa_hong_ql"],["tien_hoa_hong_ql"])).forEach($r$$=>{let $tt$$={};$tt$$.tk_no=$r$$.tk_no_hoa_hong_ql;$tt$$.tk_co=$r$$.tk_co_hoa_hong_ql;$tt$$.tien_nt=$r$$.tien_hoa_hong_ql;$tt$$.tien=$tt$$.tien_nt*($obj$$.ty_gia||1);$tt$$.ma_kh=$obj$$.ma_kh_hoa_hong_ql;$tt$$.ma_nv=$obj$$.ma_nv;$tt$$.check_balance=!1;$tt$$.dien_giai="Hoa h\u1ed3ng cho \u0111i\u1ec1u h\u00e0nh kinh doanh";
|
|
34
|
+
$tt$$.ma_nt="VND";$tt$$.ty_gia=1;$tt$$.tk_no&&$tt$$.tk_co&&$details$$.push($tt$$)}));const $details_giavon$$=[];[...$product_details$$].forEach(function($d$jscomp$11_detail$$){$d$jscomp$11_detail$$={...$d$jscomp$11_detail$$};$d$jscomp$11_detail$$.tk_no=$d$jscomp$11_detail$$.tk_gv;$d$jscomp$11_detail$$.ma_kh||($d$jscomp$11_detail$$.ma_kh=$obj$$.ma_kh);$d$jscomp$11_detail$$.tk_co=$d$jscomp$11_detail$$.tk_vt;$d$jscomp$11_detail$$.tien_nt=$d$jscomp$11_detail$$.tien_xuat_nt;$d$jscomp$11_detail$$.tien=
|
|
35
|
+
$d$jscomp$11_detail$$.tien_xuat;$details_giavon$$.push($d$jscomp$11_detail$$);$d$jscomp$11_detail$$.promotion&&$d$jscomp$11_detail$$.promotion.details_km&&$d$jscomp$11_detail$$.promotion.details_km.forEach($detail$$=>{$detail$$.ma_vt&&($detail$$.tk_no=$detail$$.tk_gv,$detail$$.ma_kh||($detail$$.ma_kh=$obj$$.ma_kh),$detail$$.tk_co=$detail$$.tk_vt,$detail$$.tien_nt=$detail$$.tien_xuat_nt||0,$detail$$.tien=$detail$$.tien_xuat||0,$details_giavon$$.push($detail$$))})});$obj$$.promotion&&$obj$$.promotion.forEach(function($detail$$){$detail$$.ma_vt&&
|
|
36
|
+
($detail$$.tk_no=$detail$$.tk_gv,$detail$$.ma_kh||($detail$$.ma_kh=$obj$$.ma_kh),$detail$$.tk_co=$detail$$.tk_vt,$detail$$.tien_nt=$detail$$.tien_xuat_nt||0,$detail$$.tien=$detail$$.tien_xuat||0,$details_giavon$$.push($detail$$))});async.series({xdtk:$callback$$=>{$details_giavon$$.joinModel2($obj$$.id_app,dmvt,{where:"ma_vt",fields:["tk_vt","gia_mua","tk_gv"]},()=>{$details_giavon$$.forEach($s$$=>{$s$$.tk_co||($s$$.tk_co=$s$$.tk_vt||$options$$.tk_vt);$s$$.tk_no||($s$$.tk_no=$s$$.tk_gv||$options$$.tk_gv);
|
|
37
|
+
$s$$.ma_nt="VND";$s$$.ty_gia=1});$callback$$()})}},()=>{$details$$=$details$$.concat($details_giavon$$);(new PostSocai($obj$$,$details$$)).run(function($e$$,$rs$$){$callback$$($e$$,$rs$$)})})})},post_tdttno:function($callback$$){account.findOne({tk:$obj$$.tk_no,id_app:$obj$$.id_app},{tk_cn:1},function($_obj_error$$,$tk$$){if($_obj_error$$)return $callback$$($_obj_error$$);$tk$$&&$tk$$.tk_cn===!0?($_obj_error$$={...$obj$$},$_obj_error$$.ma_kh=$ma_kh_kho$$,(new PostBook($_obj_error$$,[{...$_obj_error$$}],
|
|
38
|
+
Tdttno,function($detail$$,$callback$$){try{$detail$$.so_hd||($detail$$.so_hd=$obj$$.so_ct),$detail$$.ngay_hd||($detail$$.ngay_hd=$obj$$.ngay_ct),$detail$$.tien_nt=$obj$$.details.csum("tien_ct_nt")-$obj$$.details.csum("tien_ck_nt")+($obj$$.tien_thue_dc_nt||$obj$$.details.csum("tien_thue_nt"))+($obj$$.tien_phi_vc_nt||0),$detail$$.tien=$detail$$.tien_nt*$obj$$.ty_gia}catch($e$$){Logger.error($e$$,$obj$$)}$callback$$($detail$$)})).run(function($e$$,$rs$$){$callback$$($e$$,$rs$$)})):Tdttno.deleteMany({id_ct:$obj$$._id},
|
|
39
|
+
function($error$$){$callback$$($error$$)})})},thanhtoanhoahongnv:$callback$$=>{if($obj$$.da_chuyen_hoa_hong||!$obj$$.tien_hoa_hong||!$obj$$.user_nv||!$obj$$.chuyen_ngay)return $callback$$();setImmediate(async()=>{try{if($appInfo$$.wallet_address&&$appInfo$$.wallet_token&&$appInfo$$.tang_gioi_thieu_denom){let $wallet_nhan_vien$$=await global.getModel("asskey").findOne({id_app:$appInfo$$._id.toString(),username:$obj$$.user_nv,wallet_type:8});$wallet_nhan_vien$$||=await global.getModel("asskey").createWallet($appInfo$$._id.toString(),
|
|
40
|
+
$obj$$.user_nv,"T\u00e0i kho\u1ea3n nh\u1eadn th\u01b0\u1edfng",8);let $amount$$=$obj$$.tien_hoa_hong,$denom$$=$appInfo$$.tang_gioi_thieu_denom,$memo$$=`Hoa h\u1ed3ng cho \u0111\u01a1n h\u00e0ng s\u1ed1 ${$obj$$.so_ct}: ${numeral($amount$$).format()} ${$denom$$.toUpperCase()}`;await spend($appInfo$$,$obj$$.be_introduced,$wallet_nhan_vien$$.address,$amount$$,$denom$$,$memo$$,"","2");$obj$$.da_chuyen_hoa_hong=!0;await model.updateOne({_id:$obj$$._id},{da_chuyen_hoa_hong:!0})}}catch($e$$){Logger.error("Kh\u00f4ng th\u1ec3 thanh to\u00e1n ti\u1ec1n hoa h\u1ed3ng",
|
|
41
|
+
$e$$)}$callback$$()})},thanhtoanhoahonggt:$callback$$=>{if($obj$$.da_chuyen_hoa_hong_gt||!$obj$$.tien_hoa_hong_gt||!$obj$$.user_gt||!$obj$$.chuyen_ngay_gt)return $callback$$();setImmediate(async()=>{try{if($appInfo$$.wallet_address&&$appInfo$$.wallet_token&&$appInfo$$.tang_gioi_thieu_denom){let $wallet_gt$$=await global.getModel("asskey").findOne({id_app:$appInfo$$._id.toString(),username:$obj$$.user_gt,wallet_type:8});$wallet_gt$$||=await global.getModel("asskey").createWallet($appInfo$$._id.toString(),
|
|
42
|
+
$obj$$.user_gt,"T\u00e0i kho\u1ea3n nh\u1eadn th\u01b0\u1edfng",8);let $amount$$=$obj$$.tien_hoa_hong_gt,$denom$$=$appInfo$$.tang_gioi_thieu_denom,$memo$$=`Hoa h\u1ed3ng cho \u0111\u01a1n h\u00e0ng s\u1ed1 ${$obj$$.so_ct}: ${numeral($amount$$).format()} ${$denom$$.toUpperCase()}`;await spend($appInfo$$,$obj$$.be_introduced,$wallet_gt$$.address,$amount$$,$denom$$,$memo$$,$obj$$.introduce_code,"2");$obj$$.da_chuyen_hoa_hong_gt=!0;await model.updateOne({_id:$obj$$._id},{da_chuyen_hoa_hong_gt:!0})}}catch($e$$){Logger.error("Kh\u00f4ng th\u1ec3 thanh to\u00e1n ti\u1ec1n hoa h\u1ed3ng",
|
|
43
|
+
$e$$)}$callback$$()})},thanhtoanhoahongctv:$callback$$=>{if($obj$$.da_chuyen_hoa_hong_ctv||!$obj$$.thu_nhap_ctv||!$obj$$.user_ctv||!$obj$$.chuyen_ngay_ctv)return $callback$$();setImmediate(async()=>{try{if($appInfo$$.wallet_address&&$appInfo$$.wallet_token&&$appInfo$$.tang_gioi_thieu_denom){if($obj$$.user_ctv&&$obj$$.thu_nhap_ctv){let $wallet_ctv$$=await global.getModel("asskey").findOne({id_app:$appInfo$$._id.toString(),username:$obj$$.user_ctv,wallet_type:8});$wallet_ctv$$||=await global.getModel("asskey").createWallet($appInfo$$._id.toString(),
|
|
44
|
+
$obj$$.user_ctv,"T\u00e0i kho\u1ea3n nh\u1eadn th\u01b0\u1edfng",8);let $amount$$=$obj$$.thu_nhap_ctv,$denom$$=$appInfo$$.tang_gioi_thieu_denom,$memo$$=`Hoa h\u1ed3ng cho \u0111\u01a1n h\u00e0ng s\u1ed1 ${$obj$$.so_ct}: ${numeral($amount$$).format()} ${$denom$$.toUpperCase()}`;await spend($appInfo$$,$obj$$.be_introduced,$wallet_ctv$$.address,$amount$$,$denom$$,$memo$$,$obj$$.introduce_code,"2")}if($obj$$.user_ctv2&&$obj$$.thu_nhap_ctv2){let $wallet_ctv2$$=await global.getModel("asskey").findOne({id_app:$appInfo$$._id.toString(),
|
|
45
|
+
username:$obj$$.user_ctv2,wallet_type:8});$wallet_ctv2$$||=await global.getModel("asskey").createWallet($appInfo$$._id.toString(),$obj$$.user_ctv2,"T\u00e0i kho\u1ea3n nh\u1eadn th\u01b0\u1edfng",8);let $amount$$=$obj$$.thu_nhap_ctv2,$denom$$=$appInfo$$.tang_gioi_thieu_denom,$memo$$=`Hoa h\u1ed3ng cho \u0111\u01a1n h\u00e0ng s\u1ed1 ${$obj$$.so_ct}: ${numeral($amount$$).format()} ${$denom$$.toUpperCase()}`;await spend($appInfo$$,$obj$$.be_introduced,$wallet_ctv2$$.address,$amount$$,$denom$$,$memo$$,
|
|
46
|
+
$obj$$.introduce_code,"2")}$obj$$.da_chuyen_hoa_hong_ctv=!0;await model.updateOne({_id:$obj$$._id},{da_chuyen_hoa_hong_ctv:!0})}}catch($e$$){Logger.error("Kh\u00f4ng th\u1ec3 thanh to\u00e1n ti\u1ec1n hoa h\u1ed3ng",$e$$)}$callback$$()})},thanhtoanhoahongql:$callback$$=>{if($obj$$.da_chuyen_hoa_hong_ql||!$obj$$.tien_hoa_hong_ql||!$obj$$.user_ql||!$obj$$.chuyen_ngay_ql)return $callback$$();setImmediate(async()=>{try{if($appInfo$$.wallet_address&&$appInfo$$.wallet_token&&$appInfo$$.tang_gioi_thieu_denom){let $wallet_ql$$=
|
|
47
|
+
await global.getModel("asskey").findOne({id_app:$appInfo$$._id.toString(),username:$obj$$.user_ql,wallet_type:8});$wallet_ql$$||=await global.getModel("asskey").createWallet($appInfo$$._id.toString(),$obj$$.user_ql,"T\u00e0i kho\u1ea3n nh\u1eadn th\u01b0\u1edfng",8);let $amount$$=$obj$$.tien_hoa_hong_ql,$denom$$=$appInfo$$.tang_gioi_thieu_denom,$memo$$=`Hoa h\u1ed3ng cho \u0111\u01a1n h\u00e0ng s\u1ed1 ${$obj$$.so_ct}: ${numeral($amount$$).format()} ${$denom$$.toUpperCase()}`;await spend($appInfo$$,
|
|
48
|
+
$obj$$.be_introduced,$wallet_ql$$.address,$amount$$,$denom$$,$memo$$,$obj$$.introduce_code,"2");$obj$$.da_chuyen_hoa_hong_ql=!0;await model.updateOne({_id:$obj$$._id},{da_chuyen_hoa_hong_ql:!0})}}catch($e$$){Logger.error("Kh\u00f4ng th\u1ec3 thanh to\u00e1n ti\u1ec1n hoa h\u1ed3ng",$e$$)}$callback$$()})},thanhtoanhoahongchukho:$callback$$=>{if($obj$$.da_chuyen_hoa_hong_kho||!$obj$$.tien_hoa_hong_kho||!$obj$$.user_kho||!$obj$$.chuyen_ngay_kho)return $callback$$();setImmediate(async()=>{try{if($appInfo$$.wallet_address&&
|
|
49
|
+
$appInfo$$.wallet_token&&$appInfo$$.tang_gioi_thieu_denom){let $wallet_kho$$=await global.getModel("asskey").findOne({id_app:$appInfo$$._id.toString(),username:$obj$$.user_kho,wallet_type:8});$wallet_kho$$||=await global.getModel("asskey").createWallet($appInfo$$._id.toString(),$obj$$.user_kho,"T\u00e0i kho\u1ea3n nh\u1eadn th\u01b0\u1edfng",8);let $amount$$=$obj$$.tien_hoa_hong_kho,$denom$$=$appInfo$$.tang_gioi_thieu_denom,$memo$$=`Hoa h\u1ed3ng cho \u0111\u01a1n h\u00e0ng s\u1ed1 ${$obj$$.so_ct}: ${numeral($amount$$).format()} ${$denom$$.toUpperCase()}`;
|
|
50
|
+
await spend($appInfo$$,$obj$$.be_introduced,$wallet_kho$$.address,$amount$$,$denom$$,$memo$$,$obj$$.introduce_code,"2");$obj$$.da_chuyen_hoa_hong_kho=!0;await model.updateOne({_id:$obj$$._id},{da_chuyen_hoa_hong_kho:!0})}}catch($e$$){Logger.error("Kh\u00f4ng th\u1ec3 thanh to\u00e1n ti\u1ec1n hoa h\u1ed3ng",$e$$)}$callback$$()})}},function($e$$,$rs$$){$fn$$($e$$,$rs$$)})};const $valid$$=function($f_tien_nt$jscomp$1_t_thue_nt_user$$,$obj$$,$next$$){$obj$$.thue_suat=$obj$$.thue_suat||0;$f_tien_nt$jscomp$1_t_thue_nt_user$$=
|
|
51
|
+
$obj$$.ma_nt=="VND"?0:3;$obj$$.tien_phi_vc_nt=$obj$$.tien_phi_vc_nt||0;$obj$$.tien_phi_vc=utils.round($obj$$.tien_phi_vc_nt*$obj$$.ty_gia,0);$obj$$.details.forEach($detail$$=>{tinhGiaChuaThue($obj$$,$detail$$)});for(var $i_t_thue$$=0;$i_t_thue$$<$obj$$.details.length;$i_t_thue$$++){var $detail$$=$obj$$.details[$i_t_thue$$];$detail$$.line=$i_t_thue$$;$detail$$.tien_ck_nt=$detail$$.tien_ck_nt||0;$detail$$.tien_thue_nt=$detail$$.tien_thue_nt||0;$detail$$.tien=utils.round($detail$$.tien_nt*$obj$$.ty_gia,
|
|
52
|
+
0);$detail$$.tien_ct=utils.round($detail$$.tien_ct_nt*$obj$$.ty_gia,0);$detail$$.gia_ban=utils.round($detail$$.gia_ban_nt*$obj$$.ty_gia,0);$detail$$.tien_ck=utils.round($detail$$.tien_ck_nt*$obj$$.ty_gia,0);$detail$$.tien_thue=utils.round($detail$$.tien_thue_nt*$obj$$.ty_gia,0);$detail$$.tien_xuat=$detail$$.tien_xuat_nt}!$obj$$.details.find($r$$=>$r$$.ma_thue)&&$obj$$.thue_suat&&($obj$$.t_thue_nt=$obj$$.tien_thue_dc_nt||utils.round(($obj$$.details.csum("tien_ct_nt")-$obj$$.details.csum("tien_ck_nt"))*
|
|
53
|
+
$obj$$.thue_suat/100,$f_tien_nt$jscomp$1_t_thue_nt_user$$),$obj$$.t_thue=utils.round($obj$$.t_thue_nt*($obj$$.ty_gia||1),0),$f_tien_nt$jscomp$1_t_thue_nt_user$$=$obj$$.details.csum("tien_thue_nt"),$i_t_thue$$=$obj$$.details.csum("tien_thue"),($f_tien_nt$jscomp$1_t_thue_nt_user$$!==$obj$$.t_thue_nt||$i_t_thue$$!==$obj$$.t_thue)&&$obj$$.details.length>0&&($detail$$=$obj$$.details[$obj$$.details.length-1],$detail$$.tien_thue_nt+=$obj$$.t_thue_nt-$f_tien_nt$jscomp$1_t_thue_nt_user$$,$detail$$.tien_thue+=
|
|
54
|
+
$obj$$.t_thue-$i_t_thue$$));$obj$$.id_contract?salecontract.findOne({_id:$obj$$.id_contract}).lean().exec(($e$$,$c$$)=>{$c$$&&($obj$$.ma_hd=$c$$.ma_hd);$next$$(null,$obj$$)}):$next$$(null,$obj$$)};$contr$$.creating=function($user$$,$obj$$,$next$$){$obj$$.details||($obj$$.details=[]);$valid$$($user$$,$obj$$,async function($error$$){if($error$$)return $next$$($error$$);await $obj$$.details.asyncJoinModel2($user$$.current_id_app,dmvt,{where:"ma_vt",setFields:($item$$,$ref$$)=>{$item$$.ten_vt=$ref$$.ten_vt;
|
|
55
|
+
$item$$.combo=$ref$$.combo||[];$item$$.ma_thue=$ref$$.ma_thue;$item$$.status_vt=$ref$$.status;$item$$.gia_mua=$ref$$.gia_mua_tmp}});$error$$=$obj$$.details.filter($d$$=>!$d$$.status_vt);if($error$$.length>0)return $next$$(`C\u00e1c m\u1eb7t h\u00e0ng sau \u0111\u00e3 ng\u1eebng kinh doanh : ${$error$$.map($d$$=>$d$$.ten_vt).join(",")}`);let $ngay_nay_thang_truoc$$=moment($obj$$.ngay_ct).subtract(1,"months").toDate(),$details$$=[];$obj$$.details.forEach($d$$=>{$d$$.combo&&$d$$.combo.length>0?$details$$=
|
|
56
|
+
[...$details$$,...$d$$.combo]:$details$$.push($d$$)});await $details$$.filter($r$$=>!$r$$.gia_mua).asyncJoinModel2($obj$$.id_app,"giatb",{where:$item$$=>({ma_vt:$item$$.ma_vt,id_app:$obj$$.id_app,nam:$ngay_nay_thang_truoc$$.getFullYear(),thang:$ngay_nay_thang_truoc$$.getMonth()+1,gia:{$gt:0}}),fields:[{gia_mua:"gia"}]});$ngay_nay_thang_truoc$$=moment($ngay_nay_thang_truoc$$).subtract(1,"months").toDate();await $details$$.filter($r$$=>!$r$$.gia_mua).asyncJoinModel2($obj$$.id_app,"giatb",{where:$item$$=>
|
|
57
|
+
({ma_vt:$item$$.ma_vt,id_app:$obj$$.id_app,nam:$ngay_nay_thang_truoc$$.getFullYear(),thang:$ngay_nay_thang_truoc$$.getMonth()+1,gia:{$gt:0}}),fields:[{gia_mua:"gia"}]});$obj$$.details.filter($d$$=>$d$$.combo&&$d$$.combo.length>0).forEach($detail$$=>{$detail$$.combo=$detail$$.combo.map($item$$=>{$item$$.sl_xuat_1_combo=$item$$.sl_xuat;$item$$.sl_xuat=$item$$.sl_xuat_1_combo*$detail$$.sl_xuat;$item$$.tien_xuat=$item$$.tien_xuat_nt=$item$$.sl_xuat*($item$$.gia_von_nt||0);$item$$.tien_hang=$item$$.tien_hang_nt=
|
|
58
|
+
0;$item$$.tien=$item$$.tien_nt=$item$$.sl_xuat*($item$$.gia_ban_nt||0);$item$$.tien_ck=$item$$.tien_ck_nt=$item$$.sl_xuat*($item$$.tien_ck_nt||0);$item$$.tt=$item$$.tt_nt=$item$$.tien_nt-($item$$.tien_ck_nt||0);return{...$item$$}});$detail$$.gia_mua=$detail$$.combo.map($c$$=>($c$$.gia_mua||0)*$c$$.sl_xuat_1_combo).reduce(($a$$,$b$$)=>$a$$+$b$$,0)});$obj$$.result_export_einvoice=null;$next$$(null,$obj$$)})};$contr$$.updating=async function($user$$,$data$$,$obj$$,$next$$){$data$$.details||($data$$.details=
|
|
59
|
+
$obj$$.details);$data$$.ngay_ct=$data$$.ngay_ct||$obj$$.ngay_ct;await $data$$.details.asyncJoinModel2($user$$.current_id_app,dmvt,{where:"ma_vt",setFields:($item$$,$ref$$)=>{let $old_combo$$=($item$$.combo||[]).map($i$$=>({ma_vt:$i$$.ma_vt,sl_xuat:$i$$.sl_xuat})),$new_combo$$=($ref$$.combo||[]).map($i$$=>({ma_vt:$i$$.ma_vt,sl_xuat:$i$$.sl_xuat}));_.isEqual($old_combo$$,$new_combo$$)||($item$$.combo=$ref$$.combo||[]);$item$$.gia_mua=$ref$$.gia_mua_tmp}});let $ngay_nay_thang_truoc$$=moment($data$$.ngay_ct).subtract(1,
|
|
60
|
+
"months").toDate(),$details$$=[];$data$$.details.forEach($d$$=>{$d$$.combo&&$d$$.combo.length>0?$details$$=$details$$.concat($d$$.combo):$details$$.push($d$$)});await $details$$.filter($r$$=>!$r$$.gia_mua).asyncJoinModel2($obj$$.id_app,"giatb",{where:$item$$=>({ma_vt:$item$$.ma_vt,id_app:$obj$$.id_app,nam:$ngay_nay_thang_truoc$$.getFullYear(),thang:$ngay_nay_thang_truoc$$.getMonth()+1,gia:{$gt:0}}),fields:[{gia_mua:"gia"}]});$ngay_nay_thang_truoc$$=moment($ngay_nay_thang_truoc$$).subtract(1,"months").toDate();
|
|
61
|
+
await $details$$.filter($r$$=>!$r$$.gia_mua).asyncJoinModel2($obj$$.id_app,"giatb",{where:$item$$=>({ma_vt:$item$$.ma_vt,id_app:$obj$$.id_app,nam:$ngay_nay_thang_truoc$$.getFullYear(),thang:$ngay_nay_thang_truoc$$.getMonth()+1,gia:{$gt:0}}),fields:[{gia_mua:"gia"}]});$data$$.details.filter($d$$=>$d$$.combo&&$d$$.combo.length>0).forEach($detail$$=>{$detail$$.combo=$detail$$.combo.map($item$$=>{$item$$.sl_xuat_1_combo==void 0&&($item$$.sl_xuat_1_combo=$item$$.sl_xuat||0);$item$$.sl_xuat=$item$$.sl_xuat_1_combo*
|
|
62
|
+
$detail$$.sl_xuat;$item$$.tien_xuat=$item$$.tien_xuat_nt=$item$$.sl_xuat*($item$$.gia_von_nt||0);$item$$.tien_hang=$item$$.tien_hang_nt=0;$item$$.tien=$item$$.tien_nt=$item$$.sl_xuat*($item$$.gia_ban_nt||0);$item$$.tien_ck=$item$$.tien_ck_nt=$item$$.sl_xuat*($item$$.tien_ck_nt||0);$item$$.tt=$item$$.tt_nt=$item$$.tien_nt-($item$$.tien_ck_nt||0);return{...$item$$}});$detail$$.gia_mua=$detail$$.combo.map($c$$=>($c$$.gia_mua||0)*$c$$.sl_xuat_1_combo).reduce(($a$$,$b$$)=>$a$$+$b$$,0)});Tdttno_tt.findOne({id_hd:$obj$$._id,
|
|
63
|
+
id_app:$obj$$.id_app},function($error$$,$ct_tt$$){if($error$$)return $next$$($error$$);$ct_tt$$?$next$$(`Kh\u00f4ng th\u1ec3 c\u1eadp nh\u1eadt phi\u1ebfu n\u00e0y do \u0111\u00e3 \u0111\u01b0\u1ee3c thanh to\u00e1n b\u1edfi ${$ct_tt$$.ma_ct||"ch\u1ee9ng t\u1eeb"}: ${$ct_tt$$.so_ct}, ng\u00e0y ${moment($ct_tt$$.ngay_ct).format("DD/MM/YYYY")}`):$valid$$($user$$,$data$$,function($error$$){if($error$$)return $next$$($error$$);$next$$(null,$data$$,$obj$$)})})};$contr$$.deleting=function($user$$,$obj$$,
|
|
64
|
+
$next$$){Tdttno_tt.findOne({id_hd:$obj$$._id,id_app:$obj$$.id_app},function($error$$,$ct_tt$$){if($error$$)return $next$$($error$$);$ct_tt$$?$next$$(`Kh\u00f4ng th\u1ec3 xo\u00e1 phi\u1ebfu n\u00e0y do \u0111\u00e3 \u0111\u01b0\u1ee3c thanh to\u00e1n b\u1edfi ${$ct_tt$$.ma_ct||"ch\u1ee9ng t\u1eeb"}: ${$ct_tt$$.so_ct}, ng\u00e0y ${moment($ct_tt$$.ngay_ct).format("DD/MM/YYYY")}`):$next$$(null,$obj$$)})};$contr$$.view=function($user$$,$items$$,$fn$$){const $id_app$$=$user$$.current_id_app;async.series({dv:function($callback$$){$items$$.filter($item$$=>
|
|
65
|
+
$item$$.ma_dvcs).joinModel($id_app$$,dvcs,[{akey:"ma_dvcs",bkey:"_id",fields:[{name:"ten_dvcs",value:"ten_dvcs"}]}],function(){$callback$$()})},tk:function($callback$$){$items$$.filter($item$$=>$item$$.tk_no).joinModel($id_app$$,account,[{akey:"tk_no",bkey:"tk",fields:[{name:"ten_tk_no",value:"ten_tk"}]}],function(){$callback$$()})},dt:function($callback$$){$items$$.filter($item$$=>$item$$.ma_dt).joinModel($id_app$$,dmdt,[{akey:"ma_dt",bkey:"ma_dt",fields:[{name:"ten_dt",value:"ten_dt"}]}],function(){$callback$$()})},
|
|
66
|
+
kh:function($callback$$){$items$$.filter($item$$=>$item$$.ma_kh).joinModel2($id_app$$,customer,[{where:"ma_kh",fields:["ten_kh","email","nh_kh"]}],function(){$callback$$()})},nv:function($callback$$){$items$$.filter($item$$=>$item$$.ma_nv).joinModel($id_app$$,dmnv,[{akey:"ma_nv",bkey:"ma_nv",setFields:($item$$,$ref$$)=>{$item$$.ma_bp||($item$$.ma_bp=$ref$$.ma_bp);$item$$.ten_nv=$ref$$.ten_nv}}],function(){$callback$$()})},trangthai:function($callback$$){$items$$.filter($item$$=>$item$$.trang_thai).joinModel2(null,
|
|
67
|
+
trangthai,[{where:{trang_thai:"ma_trang_thai",ma_ct:"ma_ct"},fields:["ten_trang_thai","color"]}],function(){$callback$$()})},contract:function($callback$$){$items$$.filter($item$$=>$item$$.ma_hd).joinModel2($id_app$$,contract,[{where:{ma_hd:"so_hd"},fields:["ten_hd","ten_hd"]}],function(){$callback$$()})},t_tien:function($callback$$){$items$$.forEach(function($r$$){$r$$.details&&($r$$.details.forEach($d$$=>{$d$$.gia_ban_ct_nt==void 0&&$r$$.ma_nt&&tinhGiaChuaThue($r$$,$d$$);$d$$.tien_nt=$d$$.tien_ct_nt-
|
|
68
|
+
$d$$.tien_ck_nt+$d$$.tien_thue_nt}),$r$$.t_sl=$r$$.details.csum("sl_xuat"),$r$$.t_thue=$r$$.details.csum("tien_thue"),$r$$.t_thue_nt=$r$$.details.csum("tien_thue_nt"),$r$$.t_tien=$r$$.details.csum("tien"),$r$$.t_tien_nt=$r$$.details.csum("tien_nt"),$r$$.t_tien_ct=$r$$.details.csum("tien_ct"),$r$$.t_tien_ct_nt=$r$$.details.csum("tien_ct_nt"),$r$$.t_ck=$r$$.details.csum("tien_ck"),$r$$.t_ck_nt=$r$$.details.csum("tien_ck_nt"),$r$$.tc_ck_nt=$r$$.t_ck_nt+($r$$.tien_ck_hd||0),$r$$.tc_ck=$r$$.t_ck+($r$$.tien_ck_hd||
|
|
69
|
+
0)*$r$$.ty_gia,$r$$.t_tt=$r$$.t_tien_ct-$r$$.tc_ck+$r$$.t_thue+($r$$.tien_phi_vc||0),$r$$.t_tt_nt=$r$$.t_tien_ct_nt-$r$$.tc_ck_nt+$r$$.t_thue_nt+($r$$.tien_phi_vc_nt||0),$r$$.t_tien_xuat=$r$$.details.csum("tien_xuat"),$r$$.t_tien_xuat_nt=$r$$.details.csum("tien_xuat_nt"),$r$$.tien_hoa_hong=$r$$.details.csum("tien_hoa_hong"),$r$$.tien_hoa_hong_gt=$r$$.details.csum("tien_hoa_hong_gt"),$r$$.thu_nhap_ctv=$r$$.details.csum("tien_hoa_hong_ctv"),$r$$.thu_nhap_ctv2=$r$$.details.csum("tien_hoa_hong_ctv2"),
|
|
70
|
+
$r$$.tien_hoa_hong_ql=$r$$.details.csum("tien_hoa_hong_ql"),$r$$.tien_hoa_hong_kho=$r$$.details.csum("tien_hoa_hong_kho"))});$callback$$()},details_tk:function($callback$$){async.mapSeries($items$$,function($r$$,$callback$$){($r$$.details||[]).filter($item$$=>$item$$.ma_kho).joinModel2($id_app$$,dmkho,[{where:"ma_kho",fields:["ten_kho"]}],function(){$callback$$()})},function(){$callback$$()})},details_vt:function($callback$$){async.mapSeries($items$$,function($r$$,$callback1$$){($r$$.details||[]).joinModel2($id_app$$,
|
|
71
|
+
dmvt,[{where:"ma_vt",setFields:($item$$,$ref$$)=>{$item$$.ten_vt=$ref$$.ten_vt;$item$$.tk_tl=$ref$$.tk_tl;$item$$.ma_nvt||($item$$.ma_nvt=$ref$$.ma_nvt);$item$$.tk_vt=$item$$.tk_vt||$ref$$.tk_vt;$item$$.tk_dt=$item$$.tk_dt||$ref$$.tk_dt;$item$$.tk_gv=$item$$.tk_gv||$ref$$.tk_gv}}],function(){$callback1$$()})},function(){$callback$$()})},details_tt1:function($callback$$){async.mapSeries($items$$,function($r$$,$callback1$$){($r$$.details||[]).filter($d$$=>$d$$.ma_tt1).joinModel2($id_app$$,"dmtt",[{where:{ma_vt:"ma_vt",
|
|
72
|
+
ma_tt1:"ma_tt"},setFields:($item$$,$ref$$)=>{$item$$.thuoc_tinh=$ref$$}}],function(){$callback1$$()})},function(){$callback$$()})},details_dt:function($callback$$){async.mapSeries($items$$,function($r$$,$callback1$$){($r$$.details||[]).filter($item$$=>$item$$.ma_dt).joinModel2($id_app$$,dmdt,[{where:"ma_dt",fields:["ten_dt"]}],function(){$callback1$$()})},function(){$callback$$()})},details_contract:function($callback$$){async.mapSeries($items$$,function($r$$,$callback1$$){($r$$.details||[]).filter($item$$=>
|
|
73
|
+
$item$$.ma_hd).joinModel($id_app$$,contract,[{akey:"ma_hd",bkey:"so_hd",fields:[{name:"ten_hd",value:"ten_hd"}]}],function(){$callback1$$()})},function(){$callback$$()})},details_phi:function($callback$$){async.mapSeries($items$$,function($r$$,$callback1$$){($r$$.details||[]).filter($item$$=>$item$$.ma_phi).joinModel2($id_app$$,dmphi,[{where:"ma_phi",fields:["ten_phi"]}],function(){$callback1$$()})},function(){$callback$$()})},details_chietkhau:function($callback$$){async.mapSeries($items$$,function($r$$,
|
|
74
|
+
$callback1$$){($r$$.details||[]).filter($item$$=>$item$$.id_cs_ck).joinModel2(null,"dmchietkhau",[{where:$item$$=>({id_app:$r$$.id_app,_id:$item$$.id_cs_ck}),fields:["ma_chietkhau","ten_chietkhau"]}],function(){$callback1$$()})},function(){$callback$$()})}},function(){$fn$$(null,$items$$)})};$contr$$.createRoute("export2viettel/:id_ct",async($data$$,$next$$)=>{var $auth_id_app$$=$data$$.user.current_id_app,$app_msg_e$$=await App.findOne({_id:$auth_id_app$$});if(!$app_msg_e$$)return $next$$("Kh\u00f4ng t\u00ecm th\u1ea5y c\u00f4ng ty n\u00e0y");
|
|
75
|
+
if(!$app_msg_e$$.viettel_url_service||!$app_msg_e$$.viettel_user||!$app_msg_e$$.viettel_password)return $next$$("Th\u00f4ng tin xu\u1ea5t ho\u00e1 \u0111\u01a1n Viettel ch\u01b0a \u0111\u01b0\u1ee3c khai b\u00e1o \u0111\u1ea7y \u0111\u1ee7");if(!$app_msg_e$$.ma_so_thue)return $next$$("B\u1ea1n ch\u01b0a nh\u1eadp m\u00e3 s\u1ed1 thu\u1ebf c\u1ee7a c\u00f4ng ty");const $ct$$=await model.findOne({id_app:$auth_id_app$$,_id:$data$$.params.id_ct}).lean();if(!$ct$$)return $next$$("Ch\u1ee9ng t\u1eeb kh\u00f4ng h\u1ee3p l\u1ec7");
|
|
76
|
+
$data$$=$ct$$._id.toString();try{var $kh_result_export_einvoice_url$$=await utils.getInvoice($app_msg_e$$,$data$$);if($kh_result_export_einvoice_url$$){if($kh_result_export_einvoice_url$$.errorCode)return $next$$($kh_result_export_einvoice_url$$.data||$kh_result_export_einvoice_url$$.description);Logger.info("\u0110\u1ed3ng b\u1ed9 hoa \u0111\u01a1n viettel");$ct$$.result_export_einvoice=$kh_result_export_einvoice_url$$;await utils.updateInvoice($contr$$,$ct$$);return $next$$(null,$kh_result_export_einvoice_url$$)}}catch($e$$){return Logger.error("error export to viettel",
|
|
77
|
+
$e$$),$next$$($e$$)}if($ct$$.result_export_einvoice&&$ct$$.result_export_einvoice.result&&$ct$$.result_export_einvoice.result.invoiceNo)return $next$$(null,$ct$$.result_export_einvoice);$kh_result_export_einvoice_url$$=await customer.findOne({id_app:$auth_id_app$$,ma_kh:$ct$$.ma_kh})||{};await $ct$$.details.asyncJoinModel2($auth_id_app$$,dmvt,{where:"ma_vt",fields:"ten_vt"});$auth_id_app$$=Math.abs($ct$$.details.map($d$$=>$d$$.tien_ct_nt).reduce(($a$$,$b$$)=>$a$$+$b$$,0));const $t_ck$$=Math.abs($ct$$.details.map($d$$=>
|
|
78
|
+
$d$$.tien_ck_nt).reduce(($a$$,$b$$)=>$a$$+$b$$,0)),$t_tien$$=Math.abs($ct$$.details.map($d$$=>$d$$.tien_ct_nt-$d$$.tien_ck_nt).reduce(($a$$,$b$$)=>$a$$+$b$$,0));let $t_thue$$=Math.abs($ct$$.details.map($d$$=>$d$$.tien_thue_nt).reduce(($a$$,$b$$)=>$a$$+$b$$,0));const $tien_ck_hd$$=$ct$$.tien_ck_hd||0,$getThueSuat$$=($ma_thue$$,$thue_suat$$,$tien_ct_nt$$)=>{switch($ma_thue$$){case "KT":return $tien_ct_nt$$<0?void 0:-2;case "KK":return $tien_ct_nt$$<0?void 0:-1;default:return $thue_suat$$}};let $taxBreakdowns$$=
|
|
79
|
+
$ct$$.details.map($detail$$=>({...$detail$$,ma_thue:$detail$$.ma_thue||$ct$$.ma_thue,thue_suat:($detail$$.ma_thue?$detail$$.thue_suat:$ct$$.thue_suat)||0})).filter($d$$=>$d$$.ma_thue);if($taxBreakdowns$$.length===0)return $next$$("B\u1ea1n ch\u01b0a khai b\u00e1o thu\u1ebf");$taxBreakdowns$$=$taxBreakdowns$$.filter($d$$=>$d$$.ma_thue!="KT"&&$d$$.ma_thue!="KK").map($detail$$=>({taxPercentage:$detail$$.thue_suat,taxableAmount:Math.abs($detail$$.tien_ct_nt-$detail$$.tien_ck_nt),taxAmount:Math.abs($detail$$.tien_thue_nt)}));
|
|
80
|
+
$taxBreakdowns$$=await $taxBreakdowns$$.asyncGroupBy("taxPercentage",["taxableAmount","taxAmount"]);let $itemInfo$$;var $thue_suat$$=[...(new Set($ct$$.details.map($detail$$=>$getThueSuat$$($detail$$.ma_thue||$ct$$.ma_thue,($detail$$.ma_thue?$detail$$.thue_suat:$ct$$.thue_suat)||0,$detail$$.tien_ct_nt))))];if($thue_suat$$.length==1||$ct$$.details.find($d$$=>$d$$.tien_ct_nt<0)){$itemInfo$$=$ct$$.details.map(($detail$$,$index$$)=>{var $taxAmount$jscomp$1_thue_suat$$=($detail$$.ma_thue?$detail$$.thue_suat:
|
|
81
|
+
$ct$$.thue_suat)||0;let $unitPrice$$=$detail$$.gia_ban_ct_nt,$quantity$$=$detail$$.sl_xuat,$itemTotalAmountWithoutTax$$=$detail$$.tien_ct_nt,$itemTotalAmountAfterDiscount$$=$itemTotalAmountWithoutTax$$-0,$taxPercentage$$=$getThueSuat$$($detail$$.ma_thue||$ct$$.ma_thue,$taxAmount$jscomp$1_thue_suat$$,$detail$$.tien_ct_nt);$taxAmount$jscomp$1_thue_suat$$=Math.round($detail$$.tien_ct_nt*$taxAmount$jscomp$1_thue_suat$$/100);return{lineNumber:$index$$+1,selection:1,itemCode:$detail$$.ma_vt,itemName:$detail$$.ten_vt_vat||
|
|
82
|
+
$detail$$.ten_vt,unitName:$detail$$.ma_dvt,itemNote:"",unitPrice:$unitPrice$$,quantity:$quantity$$,itemTotalAmountWithoutTax:$itemTotalAmountWithoutTax$$,discount:0,itemDiscount:0,itemTotalAmountAfterDiscount:$itemTotalAmountAfterDiscount$$,taxPercentage:$taxPercentage$$,taxAmount:$taxAmount$jscomp$1_thue_suat$$,itemTotalAmountWithTax:$itemTotalAmountAfterDiscount$$+$taxAmount$jscomp$1_thue_suat$$,customTaxAmount:"0",batchNo:"",expDate:""}});$thue_suat$$=$thue_suat$$[0];let $tong_tien_ck$$=$ct$$.details.map($d$$=>
|
|
83
|
+
$d$$.tien_ck_nt).reduce(($a$$,$b$$)=>$a$$+$b$$),$tien_thue_ck$$=Math.round($tong_tien_ck$$*Math.max($thue_suat$$,0)/100,0);$tien_thue_ck$$&&($t_thue$$=$itemInfo$$.map($i$$=>$i$$.taxAmount).reduce(($a$$,$b$$)=>$a$$+$b$$,0)-$tien_thue_ck$$);$tong_tien_ck$$>0&&$itemInfo$$.push({lineNumber:$ct$$.details.length,selection:3,itemCode:"discount",itemName:"Ti\u1ec1n chi\u1ebft kh\u1ea5u",unitName:"",itemNote:"",unitPrice:void 0,quantity:void 0,itemTotalAmountWithoutTax:$tong_tien_ck$$,discount:0,itemDiscount:0,
|
|
84
|
+
itemTotalAmountAfterDiscount:$tong_tien_ck$$,taxPercentage:$thue_suat$$,taxAmount:$tien_thue_ck$$,itemTotalAmountWithTax:$tong_tien_ck$$+$tien_thue_ck$$,customTaxAmount:"0",batchNo:"",expDate:""})}else $itemInfo$$=$ct$$.details.map(($detail$$,$index$$)=>{let $unitPrice$$=$detail$$.tien_ct_nt<0?void 0:$detail$$.gia_ban_ct_nt,$quantity$$=$detail$$.tien_ct_nt<0?void 0:$detail$$.sl_xuat,$itemTotalAmountWithoutTax$$=Math.abs($detail$$.tien_ct_nt),$discount$$=$detail$$.ty_le_ck,$itemDiscount$$=Math.abs($detail$$.tien_ck_nt),
|
|
85
|
+
$itemTotalAmountAfterDiscount$$=Math.abs($detail$$.tien_ct_nt-$detail$$.tien_ck_nt),$taxPercentage$$=$getThueSuat$$($detail$$.ma_thue||$ct$$.ma_thue,($detail$$.ma_thue?$detail$$.thue_suat:$ct$$.thue_suat)||0,$detail$$.tien_ct_nt);return{lineNumber:$index$$+1,selection:$detail$$.tien_ct_nt<0?3:1,itemCode:$detail$$.ma_vt,itemName:$detail$$.ten_vt_vat||$detail$$.ten_vt,unitName:$detail$$.tien_ct_nt<0?"":$detail$$.ma_dvt,itemNote:"",unitPrice:$unitPrice$$,quantity:$quantity$$,itemTotalAmountWithoutTax:$itemTotalAmountWithoutTax$$,
|
|
86
|
+
discount:$discount$$,itemDiscount:$itemDiscount$$,itemTotalAmountAfterDiscount:$itemTotalAmountAfterDiscount$$,taxPercentage:$taxPercentage$$,taxAmount:Math.abs($detail$$.tien_thue_nt),itemTotalAmountWithTax:Math.abs($detail$$.tien_ct_nt-$detail$$.tien_ck_nt+$detail$$.tien_thue_nt),customTaxAmount:"0",batchNo:"",expDate:""}});$data$$={generalInvoiceInfo:{invoiceType:$ct$$.ma_hoa_don||$app_msg_e$$.ma_hoa_don||"1",templateCode:$ct$$.ky_hieu_hoa_don||$app_msg_e$$.ky_hieu_hoa_don||"1/001",invoiceSeries:$ct$$.so_seri,
|
|
87
|
+
transactionUuid:$data$$,currencyCode:"VND",adjustmentType:"1",paymentStatus:!0,cusGetInvoiceRight:!0,userName:$ct$$.user_created},buyerInfo:{buyerName:$ct$$.ong_ba||"",buyerLegalName:$ct$$.ten_kh||$kh_result_export_einvoice_url$$.ten_kh||"",buyerTaxCode:$ct$$.ma_so_thue||$kh_result_export_einvoice_url$$.ma_so_thue||"",buyerAddressLine:$ct$$.dia_chi||$kh_result_export_einvoice_url$$.dia_chi||"",buyerPostalCode:"",buyerDistrictName:"",buyerCityName:"",buyerCountryCode:"",buyerPhoneNumber:$ct$$.dien_thoai||
|
|
88
|
+
$kh_result_export_einvoice_url$$.dien_thoai||"",buyerFaxNumber:"",buyerEmail:$kh_result_export_einvoice_url$$.email||"",buyerBankName:"",buyerBankAccount:"",buyerIdType:"",buyerIdNo:"",buyerCode:"",buyerBirthDay:""},sellerInfo:{sellerLegalName:$app_msg_e$$.name,sellerTaxCode:$app_msg_e$$.ma_so_thue,sellerAddressLine:$app_msg_e$$.dia_chi_xuat_hoa_don||$app_msg_e$$.address,sellerPhoneNumber:$app_msg_e$$.phone||"",sellerEmail:$app_msg_e$$.email||"",sellerBankName:$app_msg_e$$.ten_ngan_hang||"",sellerBankAccount:$app_msg_e$$.tai_khoan_ngan_hang||
|
|
89
|
+
""},itemInfo:$itemInfo$$,summarizeInfo:{sumOfTotalLineAmountWithoutTax:$auth_id_app$$,discountAmount:$t_ck$$,settlementDiscountAmount:$tien_ck_hd$$,totalAmountWithoutTax:$t_tien$$,totalTaxAmount:$t_thue$$,totalAmountWithTax:$t_tien$$+$t_thue$$},taxBreakdowns:$taxBreakdowns$$,payments:[{paymentMethodName:$ct$$.hinh_thuc_tt||"TM"}],extAttribute:[],deliveryInfo:{},metadata:[]};$ct$$.ngay_hd||($ct$$.ngay_hd=new Date);let $viettel_token$$;$auth_id_app$$={username:$app_msg_e$$.viettel_user.trim(),password:$app_msg_e$$.viettel_password.trim()};
|
|
90
|
+
if($app_msg_e$$.viettel_version!="1"){$data$$.generalInvoiceInfo.invoiceIssuedDate=(new Date($ct$$.ngay_hd)).getTime();$kh_result_export_einvoice_url$$=$app_msg_e$$.viettel_direct_issue?`${$app_msg_e$$.viettel_url_service.trim()}/services/einvoiceapplication/api/InvoiceAPI/InvoiceWS/createInvoice/${$app_msg_e$$.ma_so_thue.trim()}`:`${$app_msg_e$$.viettel_url_service.trim()}/services/einvoiceapplication/api/InvoiceAPI/InvoiceWS/createOrUpdateInvoiceDraft/${$app_msg_e$$.ma_so_thue.trim()}`;var $headers_url_token$$=
|
|
91
|
+
`${$app_msg_e$$.viettel_url_service.trim()}/auth/login`;try{$viettel_token$$=(await axios({method:"post",url:$headers_url_token$$,data:$auth_id_app$$})).data.access_token}catch($e$$){return Logger.error("error when get token viettel",$auth_id_app$$,$headers_url_token$$),($app_msg_e$$=$e$$.response?$e$$.response.data:$e$$.message)&&$app_msg_e$$.detail&&($app_msg_e$$.message=$app_msg_e$$.detail),$next$$($app_msg_e$$||$e$$.message||$e$$.error||$e$$)}$headers_url_token$$={Cookie:`"access_token":"${$viettel_token$$}"; access_token=${$viettel_token$$}; session_token=${$viettel_token$$}`,
|
|
92
|
+
"Content-Type":"application/json"};$auth_id_app$$=void 0}else $data$$.generalInvoiceInfo.invoiceIssuedDate=moment($ct$$.ngay_hd).format("YYYY-MM-DD"),$kh_result_export_einvoice_url$$=$app_msg_e$$.viettel_direct_issue?`${$app_msg_e$$.viettel_url_service.trim()}/InvoiceAPI/InvoiceWS/createInvoice/${$app_msg_e$$.ma_so_thue.trim()}`:`${$app_msg_e$$.viettel_url_service.trim()}/InvoiceAPI/InvoiceWS/createOrUpdateInvoiceDraft/${$app_msg_e$$.ma_so_thue.trim()}`;axios({method:"post",url:$kh_result_export_einvoice_url$$,
|
|
93
|
+
data:$app_msg_e$$.viettel_version!="1"?JSON.stringify($data$$):$data$$,auth:$auth_id_app$$,headers:$headers_url_token$$}).then(async $data$$=>{$data$$=$data$$.data;if(!$data$$)return $next$$("Kh\u00f4ng th\u1ec3 xu\u1ea5t ho\u00e1 \u0111\u01a1n");if($data$$.errorCode)return $next$$($data$$.description);$ct$$.result_export_einvoice=$data$$;$ct$$.so_hd=$ct$$.result_export_einvoice.result.invoiceNo;await model.updateOne({_id:$ct$$._id},$ct$$);$ct$$.so_hd&&await Tdttno.updateMany({id_ct:$ct$$._id.toString()},
|
|
94
|
+
{so_hd:$ct$$.so_hd});$ct$$.so_hd&&await Tdttno_tt.updateMany({id_hd:$ct$$._id.toString()},{so_hd:$ct$$.so_hd});$ct$$.so_hd&&await Vatra.updateMany({id_ct:$ct$$._id.toString()},{so_hd:$ct$$.so_hd});controller.postData($ct$$,$contr$$,$e$$=>{if($e$$)return Logger.error($e$$);controller.pushNotification($contr$$,$ct$$)});$next$$(null,$data$$)}).catch($e$$=>{Logger.error("error invocie viettel",$e$$.response);let $msg_e$$=$e$$.response?$e$$.response.data:$e$$.message;$msg_e$$.data&&($msg_e$$.message=$msg_e$$.data);
|
|
95
|
+
$msg_e$$.detail&&($msg_e$$.message=$msg_e$$.detail);$next$$($msg_e$$||$e$$.message||$e$$.error||$e$$)})},{method:"GET"});$contr$$.on("saved",async function($obj$$){try{if($obj$$.ma_kh&&$obj$$.dia_chi_nguoi_nhan){var $kh$$=await customer.findOne({ma_kh:$obj$$.ma_kh,id_app:$obj$$.id_app}).lean();if($kh$$){var $ecomuser_address$$=global.getModel("ecomuser_address"),$ten_nguoi_nhan$$=$obj$$.ten_nguoi_nhan||$kh$$.ten_kh,$sdt_nguoi_nhan$$=$obj$$.sdt_nguoi_nhan||$kh$$.dien_thoai,$tinh_thanh$$=$obj$$.tinh_thanh||
|
|
96
|
+
$kh$$.tinh_thanh,$quan_huyen$$=$obj$$.quan_huyen||$kh$$.quan_huyen,$xa_phuong$$=$obj$$.xa_phuong||$kh$$.xa_phuong,$dia_chi$$=$obj$$.dia_chi_nguoi_nhan;await $ecomuser_address$$.findOne({ma_kh:$obj$$.ma_kh,id_app:$obj$$.id_app,tinh_thanh:$tinh_thanh$$,quan_huyen:$quan_huyen$$,xa_phuong:$xa_phuong$$,dia_chi:$dia_chi$$}).lean()||await $ecomuser_address$$.create({loai_dia_chi:"2",id_app:$obj$$.id_app,ma_kh:$obj$$.ma_kh,ten_nguoi_nhan:$ten_nguoi_nhan$$,sdt_nguoi_nhan:$sdt_nguoi_nhan$$,email_nguoi_nhan:$obj$$.email_nguoi_nhan||
|
|
97
|
+
$kh$$.email,dia_chi:$dia_chi$$,tinh_thanh:$tinh_thanh$$,quan_huyen:$quan_huyen$$,xa_phuong:$xa_phuong$$,ghi_chu:$obj$$.note_ship,ngam_dinh:!0,status:!0,user_created:$obj$$.user_created})}}}catch($e$$){Logger.error("Can't auto create address for customer",$e$$)}})};
|