flexbiz-server 12.2.1 → 12.2.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 +1 -1
- package/server/auths/local.js +2 -1
- package/server/models/assrequest.js +2 -2
- package/server/models/dmhoahonghd.js +5 -5
- package/server/models/file.js +2 -2
- package/server/models/folder.js +2 -2
- package/server/models/group.js +4 -4
- package/server/models/keyresult.js +2 -1
- package/server/models/moduleinfo.js +4 -3
- package/server/models/okr.js +1 -1
- package/server/models/so1.js +14 -14
- package/server/models/task.js +1 -1
- package/server/modules/lists/ls-customer.js +5 -4
- package/server/modules/lists/ls-dmbp.js +2 -2
- package/server/modules/lists/ls-dmdt.js +5 -5
- package/server/modules/lists/ls-dmdvt.js +1 -1
- package/server/modules/lists/ls-dmkho.js +1 -2
- package/server/modules/lists/ls-dmnhtask.js +5 -4
- package/server/modules/lists/ls-dmnv.js +14 -14
- package/server/modules/lists/ls-dvcs.js +1 -1
- package/server/modules/lists/ls-file.js +4 -4
- package/server/modules/lists/ls-task.js +4 -3
- package/server/modules/reports/rp-congviectheobp.js +4 -4
- package/server/modules/reports/rp-congviectheodt.js +5 -5
- package/server/modules/reports/rp-congviectheokh.js +5 -5
- package/server/modules/reports/rp-congviectheonv.js +3 -3
- package/server/modules/systems/sys-app.js +4 -4
- package/server/modules/vouchers/vo-hd2.js +37 -37
- package/server/modules/vouchers/vo-pnh.js +5 -4
- package/server/modules/vouchers/vo-pxh.js +4 -3
- package/server/modules/vouchers/vo-so1.js +68 -66
|
@@ -4,33 +4,34 @@ numeral=require("numeral"),App=global.getModel("app"),Introducer=global.getModel
|
|
|
4
4
|
$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$$){console.error("Error send coin",$e$$,$receiver_user$$,$receiver_address$$,$amount$$,$denom$$,$memo$$)}},hoahonghdgt=async $obj$$=>{if(!$obj$$.da_chuyen_hoa_hong_gt){$obj$$.tien_hoa_hong_gt=0;$obj$$.ty_le_hoa_hong_gt=0;$obj$$.ma_kh_hoa_hong_gt="";if($obj$$.introduce_code){$obj$$.user_gt="";var $intro_intro$jscomp$1_intro$$=
|
|
5
5
|
await global.getModel("introducer").findOne({id_app:$obj$$.id_app,introduce_code:$obj$$.introduce_code});$intro_intro$jscomp$1_intro$$&&($obj$$.user_gt=$intro_intro$jscomp$1_intro$$.be_introduced_by)}$obj$$.user_gt&&!$obj$$.introduce_code&&($intro_intro$jscomp$1_intro$$=await global.getModel("introducer").findOne({id_app:$obj$$.id_app,be_introduced_by:$obj$$.user_gt}))&&($obj$$.introduce_code=$intro_intro$jscomp$1_intro$$.introduce_code);!$obj$$.user_gt&&($obj$$.introduce_code="",$intro_intro$jscomp$1_intro$$=
|
|
6
6
|
await global.getModel("introducer").findOne({id_app:$obj$$.id_app,be_introduced:$obj$$.user_created}))&&($obj$$.user_gt=$intro_intro$jscomp$1_intro$$.be_introduced_by,$obj$$.introduce_code=$intro_intro$jscomp$1_intro$$.introduce_code);if($obj$$.user_gt&&$obj$$.introduce_code){if($intro_intro$jscomp$1_intro$$=await global.getModel("customer").findOne({id_app:$obj$$.id_app,of_user:$obj$$.user_gt}))$obj$$.ma_kh_hoa_hong_gt=$intro_intro$jscomp$1_intro$$.ma_kh;$intro_intro$jscomp$1_intro$$=$obj$$.details.csum("tien_hang_nt");
|
|
7
|
-
var $
|
|
8
|
-
moment($obj$$.ngay_ct).startOf("date").toDate();var $hieu_luc_tu_i_q_ma_kh$$={$lte:moment($obj$$.ngay_ct).endOf("date").toDate()};$ckhd_hieu_luc_den_q_nh_kh_tu_ngay$$={$gte:$ckhd_hieu_luc_den_q_nh_kh_tu_ngay$$};$
|
|
9
|
-
await customer.findOne({id_app:$obj$$.id_app,ma_kh:$obj$$.ma_kh},{nh_kh:1});$g_kh$jscomp$1_lan_mua_thu$$&&$g_kh$jscomp$1_lan_mua_thu$$.nh_kh&&($ckhd_hieu_luc_den_q_nh_kh_tu_ngay$$={$in:[void 0,null,"",$g_kh$jscomp$1_lan_mua_thu$$.nh_kh]});($g_kh$jscomp$1_lan_mua_thu$$=await model.countDocuments({id_app:$obj$$.id_app,ma_kh:$obj$$.ma_kh,trang_thai:{$in:["5",
|
|
10
|
-
email:$obj$$.user_gt}).lean())$
|
|
11
|
-
|
|
12
|
-
$g_kh$jscomp$1_lan_mua_thu$$=$ckhd_hieu_luc_den_q_nh_kh_tu_ngay$$.sl_toi_thieu||0;let $sl_dap_ung$$=0;$g_kh$jscomp$1_lan_mua_thu$$&&$ckhd_hieu_luc_den_q_nh_kh_tu_ngay$$.vts&&0<$ckhd_hieu_luc_den_q_nh_kh_tu_ngay$$.vts.length&&$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&&
|
|
13
|
-
$ds_tien$$.map($d$$=>$d$$.sl_xuat).reduce(($a$$,$b$$)=>$a$$+$b$$,0);$ds_tien$$=$ds_tien$$.map($d$$=>($d$$.tien_hang_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||
|
|
14
|
-
$obj$$.ty_le_hoa_hong_gt=0):($obj$$.ty_le_hoa_hong_gt=$ckhd_hieu_luc_den_q_nh_kh_tu_ngay$$.ty_le_hh||0,$obj$$.tien_hoa_hong_gt=Math.roundBy($
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
$ds$jscomp$1_tien$$=$ds$jscomp$1_tien$$.map($d$$=>($d$$.tien_hang_nt||0)-($d$$.tien_ck_nt||0)).reduce(($a$$,$b$$)=>$a$$+$b$$,0);$vt$$.sl_tu&&$so_luong$$<$vt$$.sl_tu
|
|
26
|
-
$
|
|
27
|
-
"
|
|
28
|
-
$
|
|
29
|
-
|
|
30
|
-
$
|
|
31
|
-
$
|
|
32
|
-
|
|
33
|
-
|
|
7
|
+
var $loi_nhuan_t_ck_nt_t_gv_nt$$=$obj$$.details.csum("tien_ck_nt");$intro_intro$jscomp$1_intro$$=$intro_intro$jscomp$1_intro$$-$loi_nhuan_t_ck_nt_t_gv_nt$$-($obj$$.tien_ck_hd||0);$loi_nhuan_t_ck_nt_t_gv_nt$$=$obj$$.details.csum("tien_xuat_tmp");$loi_nhuan_t_ck_nt_t_gv_nt$$=$intro_intro$jscomp$1_intro$$-$loi_nhuan_t_ck_nt_t_gv_nt$$;var $ckhds_query$$={id_app:$obj$$.id_app,gt_tu:{$lte:$intro_intro$jscomp$1_intro$$},ma_kho:{$in:[void 0,null,"",$obj$$.ma_kho]},doi_tuong:"1",ma_nv:{$in:[void 0,null,"",
|
|
8
|
+
$obj$$.ma_nv]}};$ckhds_query$$.$and=[{$or:[{gt_den:{$in:[0,void 0,null]}},{gt_den:{$gte:$intro_intro$jscomp$1_intro$$}}]}];var $ckhd_hieu_luc_den_q_nh_kh_tu_ngay$$=moment($obj$$.ngay_ct).startOf("date").toDate();var $hieu_luc_tu_i_q_ma_kh$$={$lte:moment($obj$$.ngay_ct).endOf("date").toDate()};$ckhd_hieu_luc_den_q_nh_kh_tu_ngay$$={$gte:$ckhd_hieu_luc_den_q_nh_kh_tu_ngay$$};$ckhds_query$$.hieu_luc_tu=$hieu_luc_tu_i_q_ma_kh$$;$ckhds_query$$.hieu_luc_den=$ckhd_hieu_luc_den_q_nh_kh_tu_ngay$$;$hieu_luc_tu_i_q_ma_kh$$=
|
|
9
|
+
{$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 $g_kh$jscomp$1_lan_mua_thu$$=await customer.findOne({id_app:$obj$$.id_app,ma_kh:$obj$$.ma_kh},{nh_kh:1});$g_kh$jscomp$1_lan_mua_thu$$&&$g_kh$jscomp$1_lan_mua_thu$$.nh_kh&&($ckhd_hieu_luc_den_q_nh_kh_tu_ngay$$={$in:[void 0,null,"",$g_kh$jscomp$1_lan_mua_thu$$.nh_kh]});($g_kh$jscomp$1_lan_mua_thu$$=await model.countDocuments({id_app:$obj$$.id_app,ma_kh:$obj$$.ma_kh,trang_thai:{$in:["5",
|
|
10
|
+
"6"]}}))||($g_kh$jscomp$1_lan_mua_thu$$=0);$g_kh$jscomp$1_lan_mua_thu$$+=1}if($obj$$.user_gt){if($g_kh$jscomp$1_lan_mua_thu$$=await global.getModel("participant").findOne({id_app:$obj$$.id_app,email:$obj$$.user_gt}).lean())$ckhds_query$$.user_group={$in:[($g_kh$jscomp$1_lan_mua_thu$$.group_id||"").toString(),null,void 0,""]}}else $ckhds_query$$.user_group={$in:[null,void 0,""]};$ckhds_query$$.$or=[{$and:[{ma_kh:$hieu_luc_tu_i_q_ma_kh$$},{nh_kh:{$in:["",null,void 0]}}]},{$and:[{nh_kh:$ckhd_hieu_luc_den_q_nh_kh_tu_ngay$$},
|
|
11
|
+
{ma_kh:{$in:["",null,void 0]}}]}];$ckhds_query$$.ap_dung_lan_mua_thu={$in:[null,void 0,0,void 0]};$ckhds_query$$=await global.getModel("dmhoahonghd").find($ckhds_query$$).sort({do_uu_tien:1,gt_tu:-1,tien_hh:-1,ty_le_hh:-1,ma_nv:-1,user_group:-1,nh_kh:-1,hieu_luc_tu:-1,kieu:1}).limit(1).lean();$ckhds_query$$=$ckhds_query$$.filter($cs$$=>$cs$$.chi_su_dung_cho_ct?0<=$cs$$.chi_su_dung_cho_ct.indexOf($obj$$.ma_ct):$cs$$.khong_su_dung_cho_ct?0>$cs$$.khong_su_dung_cho_ct.indexOf($obj$$.ma_ct):!0);if(0<$ckhds_query$$.length)for($hieu_luc_tu_i_q_ma_kh$$=
|
|
12
|
+
0;$hieu_luc_tu_i_q_ma_kh$$<$ckhds_query$$.length;$hieu_luc_tu_i_q_ma_kh$$++){$ckhd_hieu_luc_den_q_nh_kh_tu_ngay$$=$ckhds_query$$[$hieu_luc_tu_i_q_ma_kh$$];$g_kh$jscomp$1_lan_mua_thu$$=$ckhd_hieu_luc_den_q_nh_kh_tu_ngay$$.sl_toi_thieu||0;let $sl_dap_ung$$=0;$g_kh$jscomp$1_lan_mua_thu$$&&$ckhd_hieu_luc_den_q_nh_kh_tu_ngay$$.vts&&0<$ckhd_hieu_luc_den_q_nh_kh_tu_ngay$$.vts.length&&$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&&
|
|
13
|
+
(!$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(0!=$ds_tien$$.length){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_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||
|
|
14
|
+
($sl_dap_ung$$+=1)}});if($g_kh$jscomp$1_lan_mua_thu$$<=$sl_dap_ung$$){$ckhd_hieu_luc_den_q_nh_kh_tu_ngay$$.tien_hh?($obj$$.tien_hoa_hong_gt=$ckhd_hieu_luc_den_q_nh_kh_tu_ngay$$.tien_hh,$obj$$.ty_le_hoa_hong_gt=0):($obj$$.ty_le_hoa_hong_gt=$ckhd_hieu_luc_den_q_nh_kh_tu_ngay$$.ty_le_hh||0,$obj$$.tien_hoa_hong_gt="9"==$ckhd_hieu_luc_den_q_nh_kh_tu_ngay$$.kieu?Math.roundBy($loi_nhuan_t_ck_nt_t_gv_nt$$*$ckhd_hieu_luc_den_q_nh_kh_tu_ngay$$.ty_le_hh/100,0):Math.roundBy($intro_intro$jscomp$1_intro$$*$ckhd_hieu_luc_den_q_nh_kh_tu_ngay$$.ty_le_hh/
|
|
15
|
+
100,0));$ckhd_hieu_luc_den_q_nh_kh_tu_ngay$$.so_tien_max&&($obj$$.tien_hoa_hong_gt=Math.min($ckhd_hieu_luc_den_q_nh_kh_tu_ngay$$.so_tien_max,$obj$$.tien_hoa_hong_gt));$obj$$.chuyen_ngay_gt="1"==$ckhd_hieu_luc_den_q_nh_kh_tu_ngay$$.hinh_thuc_tt;break}}}}},hoahonghdnv=async $obj$$=>{if($obj$$.tu_tinh_hoa_hong&&!$obj$$.da_chuyen_hoa_hong){$obj$$.tien_hoa_hong=0;$obj$$.ty_le_hoa_hong=0;$obj$$.ma_kh_hoa_hong="";if(!$obj$$.user_nv&&$obj$$.ma_nv){var $kh$jscomp$2_nv_t_tien_nt$jscomp$1_t_tt_nt$$=await global.getModel("dmnv").findOne({id_app:$obj$$.id_app,
|
|
16
|
+
ma_nv:$obj$$.ma_nv}).lean();$kh$jscomp$2_nv_t_tien_nt$jscomp$1_t_tt_nt$$&&($obj$$.ma_kh_hoa_hong=$kh$jscomp$2_nv_t_tien_nt$jscomp$1_t_tt_nt$$.ma_kh,$obj$$.user_nv=$kh$jscomp$2_nv_t_tien_nt$jscomp$1_t_tt_nt$$.user)}$obj$$.user_nv&&!$obj$$.ma_kh_hoa_hong&&($kh$jscomp$2_nv_t_tien_nt$jscomp$1_t_tt_nt$$=await global.getModel("customer").findOne({id_app:$obj$$.id_app,of_user:$obj$$.user_nv}))&&($obj$$.ma_kh_hoa_hong=$kh$jscomp$2_nv_t_tien_nt$jscomp$1_t_tt_nt$$.ma_kh);$kh$jscomp$2_nv_t_tien_nt$jscomp$1_t_tt_nt$$=
|
|
17
|
+
$obj$$.details.csum("tien_hang_nt");var $loi_nhuan$jscomp$1_t_ck_nt$jscomp$1_t_gv_nt$$=$obj$$.details.csum("tien_ck_nt");$kh$jscomp$2_nv_t_tien_nt$jscomp$1_t_tt_nt$$=$kh$jscomp$2_nv_t_tien_nt$jscomp$1_t_tt_nt$$-$loi_nhuan$jscomp$1_t_ck_nt$jscomp$1_t_gv_nt$$-($obj$$.tien_ck_hd||0);$loi_nhuan$jscomp$1_t_ck_nt$jscomp$1_t_gv_nt$$=$obj$$.details.csum("tien_xuat_tmp");$loi_nhuan$jscomp$1_t_ck_nt$jscomp$1_t_gv_nt$$=$kh$jscomp$2_nv_t_tien_nt$jscomp$1_t_tt_nt$$-$loi_nhuan$jscomp$1_t_ck_nt$jscomp$1_t_gv_nt$$;
|
|
18
|
+
var $ckhds$jscomp$1_query$$={id_app:$obj$$.id_app,gt_tu:{$lte:$kh$jscomp$2_nv_t_tien_nt$jscomp$1_t_tt_nt$$},ma_kho:{$in:[void 0,null,"",$obj$$.ma_kho]},doi_tuong:"0",ma_nv:{$in:[void 0,null,"",$obj$$.ma_nv]}};$ckhds$jscomp$1_query$$.$and=[{$or:[{gt_den:{$in:[0,void 0,null]}},{gt_den:{$gte:$kh$jscomp$2_nv_t_tien_nt$jscomp$1_t_tt_nt$$}}]}];var $ckhd$jscomp$1_hieu_luc_den$jscomp$1_q_nh_kh$jscomp$1_tu_ngay$$=moment($obj$$.ngay_ct).startOf("date").toDate();var $g$jscomp$1_hieu_luc_tu$jscomp$1_i$jscomp$1_q_ma_kh$$=
|
|
19
|
+
{$lte:moment($obj$$.ngay_ct).endOf("date").toDate()};$ckhd$jscomp$1_hieu_luc_den$jscomp$1_q_nh_kh$jscomp$1_tu_ngay$$={$gte:$ckhd$jscomp$1_hieu_luc_den$jscomp$1_q_nh_kh$jscomp$1_tu_ngay$$};$ckhds$jscomp$1_query$$.hieu_luc_tu=$g$jscomp$1_hieu_luc_tu$jscomp$1_i$jscomp$1_q_ma_kh$$;$ckhds$jscomp$1_query$$.hieu_luc_den=$ckhd$jscomp$1_hieu_luc_den$jscomp$1_q_nh_kh$jscomp$1_tu_ngay$$;if($obj$$.user_nv){if($g$jscomp$1_hieu_luc_tu$jscomp$1_i$jscomp$1_q_ma_kh$$=await global.getModel("participant").findOne({id_app:$obj$$.id_app,
|
|
20
|
+
email:$obj$$.user_nv}).lean())$ckhds$jscomp$1_query$$.user_group={$in:[($g$jscomp$1_hieu_luc_tu$jscomp$1_i$jscomp$1_q_ma_kh$$.group_id||"").toString(),null,void 0,""]}}else $ckhds$jscomp$1_query$$.user_group={$in:[null,void 0,""]};$g$jscomp$1_hieu_luc_tu$jscomp$1_i$jscomp$1_q_ma_kh$$={$in:[void 0,null,"",$obj$$.ma_kh]};$ckhd$jscomp$1_hieu_luc_den$jscomp$1_q_nh_kh$jscomp$1_tu_ngay$$={$in:[void 0,null,""]};if($obj$$.ma_kh){var $kh$jscomp$3_lan_mua_thu$jscomp$3_sl_toi_thieu$$=await customer.findOne({id_app:$obj$$.id_app,
|
|
21
|
+
ma_kh:$obj$$.ma_kh},{nh_kh:1});$kh$jscomp$3_lan_mua_thu$jscomp$3_sl_toi_thieu$$&&$kh$jscomp$3_lan_mua_thu$jscomp$3_sl_toi_thieu$$.nh_kh&&($ckhd$jscomp$1_hieu_luc_den$jscomp$1_q_nh_kh$jscomp$1_tu_ngay$$={$in:[void 0,null,"",$kh$jscomp$3_lan_mua_thu$jscomp$3_sl_toi_thieu$$.nh_kh]});($kh$jscomp$3_lan_mua_thu$jscomp$3_sl_toi_thieu$$=await model.countDocuments({id_app:$obj$$.id_app,ma_kh:$obj$$.ma_kh,trang_thai:{$in:["5","6"]}}))||($kh$jscomp$3_lan_mua_thu$jscomp$3_sl_toi_thieu$$=0);$kh$jscomp$3_lan_mua_thu$jscomp$3_sl_toi_thieu$$+=
|
|
22
|
+
1}$ckhds$jscomp$1_query$$.$or=[{$and:[{ma_kh:$g$jscomp$1_hieu_luc_tu$jscomp$1_i$jscomp$1_q_ma_kh$$},{nh_kh:{$in:["",null,void 0]}}]},{$and:[{nh_kh:$ckhd$jscomp$1_hieu_luc_den$jscomp$1_q_nh_kh$jscomp$1_tu_ngay$$},{ma_kh:{$in:["",null,void 0]}}]}];$ckhds$jscomp$1_query$$.ap_dung_lan_mua_thu={$in:[null,void 0,0,void 0]};$ckhds$jscomp$1_query$$=await global.getModel("dmhoahonghd").find($ckhds$jscomp$1_query$$).sort({do_uu_tien:1,gt_tu:-1,tien_hh:-1,ty_le_hh:-1,ma_nv:-1,user_group:-1,nh_kh:-1,hieu_luc_tu:-1,
|
|
23
|
+
kieu:1}).limit(1).lean();$ckhds$jscomp$1_query$$=$ckhds$jscomp$1_query$$.filter($cs$$=>$cs$$.chi_su_dung_cho_ct?0<=$cs$$.chi_su_dung_cho_ct.indexOf($obj$$.ma_ct):$cs$$.khong_su_dung_cho_ct?0>$cs$$.khong_su_dung_cho_ct.indexOf($obj$$.ma_ct):!0);if(0<$ckhds$jscomp$1_query$$.length)for($g$jscomp$1_hieu_luc_tu$jscomp$1_i$jscomp$1_q_ma_kh$$=0;$g$jscomp$1_hieu_luc_tu$jscomp$1_i$jscomp$1_q_ma_kh$$<$ckhds$jscomp$1_query$$.length;$g$jscomp$1_hieu_luc_tu$jscomp$1_i$jscomp$1_q_ma_kh$$++){$ckhd$jscomp$1_hieu_luc_den$jscomp$1_q_nh_kh$jscomp$1_tu_ngay$$=
|
|
24
|
+
$ckhds$jscomp$1_query$$[$g$jscomp$1_hieu_luc_tu$jscomp$1_i$jscomp$1_q_ma_kh$$];$kh$jscomp$3_lan_mua_thu$jscomp$3_sl_toi_thieu$$=$ckhd$jscomp$1_hieu_luc_den$jscomp$1_q_nh_kh$jscomp$1_tu_ngay$$.sl_toi_thieu||0;let $sl_dap_ung$$=0;$kh$jscomp$3_lan_mua_thu$jscomp$3_sl_toi_thieu$$&&$ckhd$jscomp$1_hieu_luc_den$jscomp$1_q_nh_kh$jscomp$1_tu_ngay$$.vts&&0<$ckhd$jscomp$1_hieu_luc_den$jscomp$1_q_nh_kh$jscomp$1_tu_ngay$$.vts.length&&$ckhd$jscomp$1_hieu_luc_den$jscomp$1_q_nh_kh$jscomp$1_tu_ngay$$.vts.forEach($vt$$=>
|
|
25
|
+
{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(0!=$ds$jscomp$1_tien$$.length){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||0)-($d$$.tien_ck_nt||0)).reduce(($a$$,$b$$)=>$a$$+$b$$,0);$vt$$.sl_tu&&$so_luong$$<$vt$$.sl_tu||
|
|
26
|
+
$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($kh$jscomp$3_lan_mua_thu$jscomp$3_sl_toi_thieu$$<=$sl_dap_ung$$){$ckhd$jscomp$1_hieu_luc_den$jscomp$1_q_nh_kh$jscomp$1_tu_ngay$$.tien_hh?($obj$$.tien_hoa_hong=$ckhd$jscomp$1_hieu_luc_den$jscomp$1_q_nh_kh$jscomp$1_tu_ngay$$.tien_hh,$obj$$.ty_le_hoa_hong=0):($obj$$.ty_le_hoa_hong=$ckhd$jscomp$1_hieu_luc_den$jscomp$1_q_nh_kh$jscomp$1_tu_ngay$$.ty_le_hh||
|
|
27
|
+
0,$obj$$.tien_hoa_hong="9"==$ckhd$jscomp$1_hieu_luc_den$jscomp$1_q_nh_kh$jscomp$1_tu_ngay$$.kieu?Math.roundBy($loi_nhuan$jscomp$1_t_ck_nt$jscomp$1_t_gv_nt$$*$ckhd$jscomp$1_hieu_luc_den$jscomp$1_q_nh_kh$jscomp$1_tu_ngay$$.ty_le_hh/100,0):Math.roundBy($kh$jscomp$2_nv_t_tien_nt$jscomp$1_t_tt_nt$$*$ckhd$jscomp$1_hieu_luc_den$jscomp$1_q_nh_kh$jscomp$1_tu_ngay$$.ty_le_hh/100,0));$ckhd$jscomp$1_hieu_luc_den$jscomp$1_q_nh_kh$jscomp$1_tu_ngay$$.so_tien_max&&($obj$$.tien_hoa_hong=Math.min($ckhd$jscomp$1_hieu_luc_den$jscomp$1_q_nh_kh$jscomp$1_tu_ngay$$.so_tien_max,
|
|
28
|
+
$obj$$.tien_hoa_hong));$obj$$.chuyen_ngay="1"==$ckhd$jscomp$1_hieu_luc_den$jscomp$1_q_nh_kh$jscomp$1_tu_ngay$$.hinh_thuc_tt;break}}}},khuyenmaihd=async $obj$$=>{if($obj$$.details&&$obj$$.online){var $ckhds$jscomp$2_query$jscomp$2_t_tien_nt$$=$obj$$.details.filter($d$$=>!$d$$.km_yn_for).csum("tien_hang_nt");if(0!==$ckhds$jscomp$2_query$jscomp$2_t_tien_nt$$){var $hieu_luc_tu$jscomp$2_i$jscomp$2_q_ma_kh$jscomp$2_t_ck_nt$jscomp$2_t_tt_nt$$=$obj$$.details.filter($d$$=>!$d$$.km_yn_for).csum("tien_ck_nt");
|
|
29
|
+
$hieu_luc_tu$jscomp$2_i$jscomp$2_q_ma_kh$jscomp$2_t_ck_nt$jscomp$2_t_tt_nt$$=$ckhds$jscomp$2_query$jscomp$2_t_tien_nt$$-$hieu_luc_tu$jscomp$2_i$jscomp$2_q_ma_kh$jscomp$2_t_ck_nt$jscomp$2_t_tt_nt$$;$obj$$.details=$obj$$.details.filter($d$$=>"khuyenmaihd"!=$d$$.km_yn_for);$ckhds$jscomp$2_query$jscomp$2_t_tien_nt$$={id_app:$obj$$.id_app,gt_tu:{$lte:$hieu_luc_tu$jscomp$2_i$jscomp$2_q_ma_kh$jscomp$2_t_ck_nt$jscomp$2_t_tt_nt$$},ma_kho:{$in:[void 0,null,"",$obj$$.ma_kho]}};$ckhds$jscomp$2_query$jscomp$2_t_tien_nt$$.$and=
|
|
30
|
+
[{$or:[{gt_den:{$in:[0,void 0,null]}},{gt_den:{$gte:$hieu_luc_tu$jscomp$2_i$jscomp$2_q_ma_kh$jscomp$2_t_ck_nt$jscomp$2_t_tt_nt$$}}]}];var $ckhd$jscomp$2_hieu_luc_den$jscomp$2_q_nh_kh$jscomp$2_tu_ngay$$=moment($obj$$.ngay_ct).startOf("date").toDate();$hieu_luc_tu$jscomp$2_i$jscomp$2_q_ma_kh$jscomp$2_t_ck_nt$jscomp$2_t_tt_nt$$={$lte:moment($obj$$.ngay_ct).endOf("date").toDate()};$ckhd$jscomp$2_hieu_luc_den$jscomp$2_q_nh_kh$jscomp$2_tu_ngay$$={$gte:$ckhd$jscomp$2_hieu_luc_den$jscomp$2_q_nh_kh$jscomp$2_tu_ngay$$};
|
|
31
|
+
$ckhds$jscomp$2_query$jscomp$2_t_tien_nt$$.hieu_luc_tu=$hieu_luc_tu$jscomp$2_i$jscomp$2_q_ma_kh$jscomp$2_t_ck_nt$jscomp$2_t_tt_nt$$;$ckhds$jscomp$2_query$jscomp$2_t_tien_nt$$.hieu_luc_den=$ckhd$jscomp$2_hieu_luc_den$jscomp$2_q_nh_kh$jscomp$2_tu_ngay$$;$hieu_luc_tu$jscomp$2_i$jscomp$2_q_ma_kh$jscomp$2_t_ck_nt$jscomp$2_t_tt_nt$$={$in:[void 0,null,"",$obj$$.ma_kh]};$ckhd$jscomp$2_hieu_luc_den$jscomp$2_q_nh_kh$jscomp$2_tu_ngay$$={$in:[void 0,null,""]};if($obj$$.ma_kh){var $kh$jscomp$4_lan_mua_thu$jscomp$5_sl_toi_thieu$$=
|
|
32
|
+
await customer.findOne({id_app:$obj$$.id_app,ma_kh:$obj$$.ma_kh},{nh_kh:1});$kh$jscomp$4_lan_mua_thu$jscomp$5_sl_toi_thieu$$&&$kh$jscomp$4_lan_mua_thu$jscomp$5_sl_toi_thieu$$.nh_kh&&($ckhd$jscomp$2_hieu_luc_den$jscomp$2_q_nh_kh$jscomp$2_tu_ngay$$={$in:[void 0,null,"",$kh$jscomp$4_lan_mua_thu$jscomp$5_sl_toi_thieu$$.nh_kh]});($kh$jscomp$4_lan_mua_thu$jscomp$5_sl_toi_thieu$$=await model.countDocuments({id_app:$obj$$.id_app,ma_kh:$obj$$.ma_kh,trang_thai:{$in:["5","6"]}}))||($kh$jscomp$4_lan_mua_thu$jscomp$5_sl_toi_thieu$$=
|
|
33
|
+
0);$kh$jscomp$4_lan_mua_thu$jscomp$5_sl_toi_thieu$$+=1}$ckhds$jscomp$2_query$jscomp$2_t_tien_nt$$.$or=[{$and:[{ma_kh:$hieu_luc_tu$jscomp$2_i$jscomp$2_q_ma_kh$jscomp$2_t_ck_nt$jscomp$2_t_tt_nt$$},{nh_kh:{$in:["",null,void 0]}}]},{$and:[{nh_kh:$ckhd$jscomp$2_hieu_luc_den$jscomp$2_q_nh_kh$jscomp$2_tu_ngay$$},{ma_kh:{$in:["",null,void 0]}}]}];$ckhds$jscomp$2_query$jscomp$2_t_tien_nt$$.ap_dung_lan_mua_thu={$in:[null,void 0,0,void 0]};$ckhds$jscomp$2_query$jscomp$2_t_tien_nt$$.online=!0;$ckhds$jscomp$2_query$jscomp$2_t_tien_nt$$=
|
|
34
|
+
await dmkhuyenmaihd.find($ckhds$jscomp$2_query$jscomp$2_t_tien_nt$$).sort({stt_uu_tien:1,gt_tu:-1,ma_kh:-1,nh_kh:-1,hieu_luc_tu:-1}).lean();for($hieu_luc_tu$jscomp$2_i$jscomp$2_q_ma_kh$jscomp$2_t_ck_nt$jscomp$2_t_tt_nt$$=0;$hieu_luc_tu$jscomp$2_i$jscomp$2_q_ma_kh$jscomp$2_t_ck_nt$jscomp$2_t_tt_nt$$<$ckhds$jscomp$2_query$jscomp$2_t_tien_nt$$.length;$hieu_luc_tu$jscomp$2_i$jscomp$2_q_ma_kh$jscomp$2_t_ck_nt$jscomp$2_t_tt_nt$$++)if(($ckhd$jscomp$2_hieu_luc_den$jscomp$2_q_nh_kh$jscomp$2_tu_ngay$$=$ckhds$jscomp$2_query$jscomp$2_t_tien_nt$$[$hieu_luc_tu$jscomp$2_i$jscomp$2_q_ma_kh$jscomp$2_t_ck_nt$jscomp$2_t_tt_nt$$])&&
|
|
34
35
|
$ckhd$jscomp$2_hieu_luc_den$jscomp$2_q_nh_kh$jscomp$2_tu_ngay$$.details_km&&0<$ckhd$jscomp$2_hieu_luc_den$jscomp$2_q_nh_kh$jscomp$2_tu_ngay$$.details_km.length){$kh$jscomp$4_lan_mua_thu$jscomp$5_sl_toi_thieu$$=$ckhd$jscomp$2_hieu_luc_den$jscomp$2_q_nh_kh$jscomp$2_tu_ngay$$.sl_toi_thieu||0;let $sl_dap_ung$$=0;$kh$jscomp$4_lan_mua_thu$jscomp$5_sl_toi_thieu$$&&$ckhd$jscomp$2_hieu_luc_den$jscomp$2_q_nh_kh$jscomp$2_tu_ngay$$.vts&&0<$ckhd$jscomp$2_hieu_luc_den$jscomp$2_q_nh_kh$jscomp$2_tu_ngay$$.vts.length&&
|
|
35
36
|
$ckhd$jscomp$2_hieu_luc_den$jscomp$2_q_nh_kh$jscomp$2_tu_ngay$$.vts.forEach($vt$$=>{var $ds$jscomp$2_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(0!=$ds$jscomp$2_tien$$.length){var $so_luong$$=$ds$jscomp$2_tien$$.map($d$$=>$d$$.sl_xuat).reduce(($a$$,$b$$)=>$a$$+$b$$,0);$ds$jscomp$2_tien$$=$ds$jscomp$2_tien$$.map($d$$=>($d$$.tien_hang_nt||0)-($d$$.tien_ck_nt||
|
|
36
37
|
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$2_tien$$<$vt$$.gt_tu||$vt$$.gt_den&&$ds$jscomp$2_tien$$>$vt$$.gt_den||($sl_dap_ung$$+=1)}});if($kh$jscomp$4_lan_mua_thu$jscomp$5_sl_toi_thieu$$<=$sl_dap_ung$$){$ckhd$jscomp$2_hieu_luc_den$jscomp$2_q_nh_kh$jscomp$2_tu_ngay$$.details_km.forEach($d$$=>{$d$$={...$d$$,km_yn_for:"khuyenmaihd"};$d$$.sl_xuat=$d$$.sl_km;$d$$.tien_hang_nt=$d$$.tien_hang=0;$d$$.tien_ck_nt=
|
|
@@ -50,11 +51,11 @@ sender_email:$obj$$.id_app,receiver_email:$_intro_amount$$.be_introduced_by,amou
|
|
|
50
51
|
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$$?$amount$$.ma_nvt:""]}}).sort({ma_vt:-1,ma_nvt:-1,hieu_luc_tu:-1}).limit(1);
|
|
51
52
|
return 0<$ckdiemthuong_ty_le_diem_thuong$$.length?($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$$=(await Promise.all($_intro_amount$$)).reduce(($a$$,$b$$)=>$a$$+$b$$,0)){if($_app_diem_thuong_gioi_thieu_old_trans$$=
|
|
52
53
|
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,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",
|
|
53
|
-
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()});$obj$$.paymentByPoints&&
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
if(
|
|
57
|
-
|
|
54
|
+
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()});$obj$$.paymentByPoints&&await transaction.createTrans({id_app:$obj$$.id_app,sender_email:$obj$$.of_user||$obj$$.user_created,
|
|
55
|
+
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$$)=>$a$$+$b$$,0);return($obj$$.evouchers||[]).map($ev$$=>new Promise(($resolve$$,$reject$$)=>{(async()=>{const $_e$$=await Evoucher.findOne({ma:$ev$$.ma,
|
|
56
|
+
id_app:$user$$.current_id_app});if(!$_e$$)return console.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`));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`));
|
|
57
|
+
if(1<=$_e$$.so_lan_sd&&$_e$$.id_ct_useds&&0<$_e$$.id_ct_useds.length&&($_e$$.id_ct_useds=[...(new Set([...$_e$$.id_ct_useds]))],$_e$$.id_ct_useds.length>=$_e$$.so_lan_sd&&(!$obj$$._id||0>$_e$$.id_ct_useds.indexOf($obj$$._id))))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$$.of_user||$obj$$.user_created||$user$$.email))return $reject$$(Error(`Th\u1ebb mua h\u00e0ng ${$ev$$.ma} kh\u00f4ng h\u1ee3p l\u1ec7`));
|
|
58
|
+
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()}`));
|
|
58
59
|
if($_e$$.vts&&0<$_e$$.vts.length&&$_e$$.sl_toi_thieu){let $sl_dap_ung$$=0;$_e$$.vts.forEach($vt$$=>{var $ds$jscomp$4_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(0!=$ds$jscomp$4_tien$$.length){var $so_luong$$=$ds$jscomp$4_tien$$.map($d$$=>$d$$.sl_xuat).reduce(($a$$,$b$$)=>$a$$+$b$$,0);$ds$jscomp$4_tien$$=$ds$jscomp$4_tien$$.map($d$$=>($d$$.tien_hang_nt||
|
|
59
60
|
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$4_tien$$<$vt$$.gt_tu||$vt$$.gt_den&&$ds$jscomp$4_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$$=
|
|
60
61
|
$_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$$)=>
|
|
@@ -80,40 +81,41 @@ $obj$$,$_opt_pre_obj_t_tien_evoucher$$),await Promise.all($_checkEvoucher_tien_c
|
|
|
80
81
|
$tien_evoucher$$-$tien_evoucher_da_phan_bo$$}else $tien_evoucher_con_lai$$=0})}},valid=async function($user$$,$obj$$,$next$$,$i$jscomp$6_pre_obj$$){$i$jscomp$6_pre_obj$$&&($obj$$.online=$i$jscomp$6_pre_obj$$.online,$obj$$._id=$i$jscomp$6_pre_obj$$._id,$obj$$.details=$obj$$.details||$i$jscomp$6_pre_obj$$.details||[],$obj$$.evouchers=$obj$$.evouchers||$i$jscomp$6_pre_obj$$.evouchers);if($obj$$.online)try{await validOnline($user$$,$obj$$,$i$jscomp$6_pre_obj$$)}catch($e$$){return $next$$($e$$.message)}if($obj$$.paymentByPoints)try{var $detail$$=
|
|
81
82
|
await currency.getRate($obj$$.id_app,$obj$$.ma_nt);$detail$$=$detail$$||1;$obj$$.tien_paymentByPoints=$obj$$.paymentByPoints*$detail$$}catch($e$$){return $next$$($e$$.message)}for($i$jscomp$6_pre_obj$$=0;$i$jscomp$6_pre_obj$$<($obj$$.details||[]).length;$i$jscomp$6_pre_obj$$++)$detail$$=($obj$$.details||[])[$i$jscomp$6_pre_obj$$],$detail$$.line=$i$jscomp$6_pre_obj$$,"VND"===$obj$$.ma_nt&&($detail$$.tien_hang=$detail$$.tien_hang_nt,$detail$$.tien_ck=$detail$$.tien_ck_nt||0,$detail$$.gia_ban=$detail$$.gia_ban_nt),
|
|
82
83
|
$detail$$.tien_nt=Math.max(0,$detail$$.tien_hang_nt-$detail$$.tien_ck_nt),$detail$$.tien=Math.max(0,$detail$$.tien_hang-$detail$$.tien_ck),$detail$$.tien_xuat=$detail$$.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$$)):$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")})};
|
|
83
|
-
module.exports=function($contr_router$$){$contr_router$$=new controller($contr_router$$,model,ma_ct.toLowerCase(),{isVoucher:!0,requireRecaptchaToken:!1,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$$)=>{await
|
|
84
|
-
await hoahonghdgt($obj$$)};$contr_router$$.handleAfterPayment=async $obj$$=>{$obj$$.trang_thai_tt="5";$obj$$.trang_thai="1";await model.updateOne({_id:$obj$$._id},{details:$obj$$.details,trang_thai_tt:"5",trang_thai:"1"});let $ctrlSO1$$=global.controllers.SO1;$ctrlSO1$$&&controller.postData($obj$$,$ctrlSO1
|
|
85
|
-
await currency.getRate($obj$$.id_app,$obj$$.ma_nt)||1;const $appInfo$$=await global.getModel("app").findOne({_id:$obj$$.id_app}).lean();await $obj$$.details.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,
|
|
86
|
-
{$details$$.push({...$d$$})});let $data_post$$=$details$$.map($detail$$=>$detail$$.combo&&0<$detail$$.combo.length?$detail$$.combo.map($item$$=>{$item$$=$item$$.toObject?$item$$.toObject():{...$item$$};$item$$.sl_xuat*=$detail$$.sl_xuat;$item$$.tien_xuat=$item$$.tien_xuat_nt=$item$$.sl_xuat*$item$$.gia_von_nt
|
|
87
|
-
return $item$$}):[$detail$$]).reduce(($a$$,$b$$)=>$a$$.concat($b$$),[]);(new PostBook($obj$$,$data_post$$,Sokho,async function($detail$$,$callback$$){$detail$$.nxt=2;$detail$$.ngay_ct=$obj$$.ngay_giao_hang||$obj$$.ngay_ct;$detail$$.ma_kho=$obj$$.ma_kho;$callback$$($detail$$)})).run(function($e$$,$rs$$){$callback$jscomp$0$$($e
|
|
88
|
-
{let $option$$;$option$$=$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$?$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.option||{}:{};($error$$=await dmkho.findOne({id_app:$obj$$.id_app,
|
|
89
|
-
$pt$$=$pt$$||{};$pt$$.tk_tien=$pt$$.tk_cn;$pt$$.tk_cn=$pt$$.tk_cn||$error$$.tk_cn;$pt$$.tk_dt=$error$$.tk_dt||$pt$$.tk_dt;$pt$$.tk_gv=$error$$.tk_gv||$pt$$.tk_gv;$pt$$.tk_ck=$error$$.tk_ck||$pt$$.tk_ck;$pt$$.tk_cp_gh=$error$$.tk_cp_gh||$pt$$.tk_cp_gh;$pt$$.tk_cp_bh=$error$$.tk_cp_bh
|
|
90
|
-
$
|
|
91
|
-
$pt$$.ten.indexOf("COD")?$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;$obj$$.details.forEach($detail$$=>{$detail$$.ma_thue&&$detail$$.tk_thue_co_treo?($detail$$.tien_ct=($detail$$.tien_hang-
|
|
92
|
-
|
|
93
|
-
$detail$$.tien,$detail$$.tien_ct_nt=$detail$$.tien_nt)});const $details$$=[];$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$=$obj$$.details.map($a$$=>($a$$.tien_hang_nt||0)-($a$$.tien_ck_nt||0)).reduce(($a$$,$b$$)
|
|
94
|
-
{...$d$jscomp$
|
|
95
|
-
$d$$.tien_thue).forEach($detail$$=>{$detail$$={...$detail$$};$detail$$.tk_no=$tk_tien$$;$detail$$.tk_co=$detail$$.tk_thue_co_treo;$detail$$.ma_kh||($detail$$.ma_kh=$pt$$.ma_kh||$obj$$.ma_kh);$detail$$.tien=$detail$$.tien_nt=
|
|
96
|
-
$
|
|
97
|
-
$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$
|
|
98
|
-
$option$$.ma_kh;$d$jscomp$
|
|
99
|
-
|
|
100
|
-
$
|
|
101
|
-
|
|
102
|
-
$
|
|
103
|
-
$
|
|
104
|
-
$obj$$.
|
|
105
|
-
$
|
|
106
|
-
|
|
107
|
-
$
|
|
108
|
-
$obj$$.
|
|
109
|
-
$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.
|
|
110
|
-
$obj$$.
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
$
|
|
84
|
+
module.exports=function($contr_router$$){$contr_router$$=new controller($contr_router$$,model,ma_ct.toLowerCase(),{isVoucher:!0,requireRecaptchaToken:!1,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$$)=>{await $obj$$.details.asyncJoinModel2($obj$$.id_app,dmvt,{where:"ma_vt",
|
|
85
|
+
fields:["ma_thue","gia_mua"]});$obj$$.details.forEach($d$$=>{$d$$.tien_xuat_tmp=$d$$.sl_xuat*($d$$.gia_mua||0)});await chietkhauhd($obj$$);await khuyenmaihd($obj$$);await hoahonghdnv($obj$$);await hoahonghdgt($obj$$)};$contr_router$$.handleAfterPayment=async $obj$$=>{$obj$$.trang_thai_tt="5";$obj$$.trang_thai="1";await model.updateOne({_id:$obj$$._id},{details:$obj$$.details,trang_thai_tt:"5",trang_thai:"1"});let $ctrlSO1$$=global.controllers.SO1;$ctrlSO1$$&&controller.postData($obj$$,$ctrlSO1$$,
|
|
86
|
+
$e$$=>{if($e$$)return console.error($e$$);controller.pushNotification($ctrlSO1$$,$obj$$)});return null};$contr_router$$.post=async function($obj$$,$fn$$){$fn$$||($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();await $obj$$.details.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,
|
|
87
|
+
global.getModel("vat"),{where:"ma_thue",fields:["thue_suat","tk_thue_co","tk_thue_co_treo"]});async.series({post_sokho:function($callback$jscomp$0$$){const $details$$=[];$obj$$.details.forEach($d$$=>{$details$$.push({...$d$$})});let $data_post$$=$details$$.map($detail$$=>$detail$$.combo&&0<$detail$$.combo.length?$detail$$.combo.map($item$$=>{$item$$=$item$$.toObject?$item$$.toObject():{...$item$$};$item$$.sl_xuat*=$detail$$.sl_xuat;$item$$.tien_xuat=$item$$.tien_xuat_nt=$item$$.sl_xuat*$item$$.gia_von_nt;
|
|
88
|
+
$item$$.tien_hang=$item$$.tien_hang_nt=$item$$.sl_xuat*$item$$.gia_ban_nt;$item$$.tien_ck=$item$$.tien_ck_nt*=$item$$.sl_xuat;$item$$.tien=$item$$.tien_nt=$item$$.tien_hang_nt-$item$$.tien_ck_nt;return $item$$}):[$detail$$]).reduce(($a$$,$b$$)=>$a$$.concat($b$$),[]);(new PostBook($obj$$,$data_post$$,Sokho,async function($detail$$,$callback$$){$detail$$.nxt=2;$detail$$.ngay_ct=$obj$$.ngay_giao_hang||$obj$$.ngay_ct;$detail$$.ma_kho=$obj$$.ma_kho;$callback$$($detail$$)})).run(function($e$$,$rs$$){$callback$jscomp$0$$($e$$,
|
|
89
|
+
$rs$$)})},post_socai:function($callback$$){options.findOne({id_app:$obj$$.id_app,id_func:ma_ct.toLowerCase()}).lean().exec(async($error$$,$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$)=>{let $option$$;$option$$=$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$?$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.option||{}:{};($error$$=await dmkho.findOne({id_app:$obj$$.id_app,
|
|
90
|
+
ma_kho:$obj$$.ma_kho}).lean())||($error$$={});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$$.tk_tien=$pt$$.tk_cn;$pt$$.tk_cn=$pt$$.tk_cn||$error$$.tk_cn;$pt$$.tk_dt=$error$$.tk_dt||$pt$$.tk_dt;$pt$$.tk_gv=$error$$.tk_gv||$pt$$.tk_gv;$pt$$.tk_ck=$error$$.tk_ck||$pt$$.tk_ck;$pt$$.tk_cp_gh=$error$$.tk_cp_gh||$pt$$.tk_cp_gh;$pt$$.tk_cp_bh=$error$$.tk_cp_bh||
|
|
91
|
+
$pt$$.tk_cp_bh;$pt$$.tk_cp_ctv=$error$$.tk_cp_ctv||$pt$$.tk_cp_ctv;$pt$$.tk_cn_ctv=$error$$.tk_cn_ctv||$pt$$.tk_cn_ctv;$option$$.tk_tien=$pt$$.tk_tien||$error$$.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||
|
|
92
|
+
$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;$option$$.tk_cn_ctv=$pt$$.tk_cn_ctv||$option$$.tk_cn_ctv;$pt$$.ten&&0<=$pt$$.ten.indexOf("COD")?$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;$obj$$.details.forEach($detail$$=>{$detail$$.ma_thue&&$detail$$.tk_thue_co_treo?($detail$$.tien_ct=($detail$$.tien_hang-
|
|
93
|
+
($detail$$.tien_ck||0))/(1+$detail$$.thue_suat/100),$detail$$.tien_ct_nt=($detail$$.tien_hang_nt-($detail$$.tien_ck_nt||0))/(1+$detail$$.thue_suat/100),$detail$$.gia_ban_ct=Math.roundBy($detail$$.tien_ct/($detail$$.sl_xuat||1)),$detail$$.gia_ban_ct_nt=Math.roundBy($detail$$.tien_ct_nt/($detail$$.sl_xuat||1)),$detail$$.tien_ct=$detail$$.sl_xuat*$detail$$.gia_ban_ct,$detail$$.tien_ct_nt=$detail$$.sl_xuat*$detail$$.gia_ban_ct_nt,$detail$$.tien_thue=Math.roundBy($detail$$.tien_ct*$detail$$.thue_suat/
|
|
94
|
+
100),$detail$$.tien_thue_nt=Math.roundBy($detail$$.tien_ct_nt*$detail$$.thue_suat/100)):($detail$$.tien_ck_ct_nt=$detail$$.tien_ck_nt,$detail$$.tien_ck_ct=$detail$$.tien_ck,$detail$$.tien_thue=0,$detail$$.tien_thue_nt=0,$detail$$.tien_ct=$detail$$.tien,$detail$$.tien_ct_nt=$detail$$.tien_nt)});const $details$$=[];$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$=$obj$$.details.map($a$$=>($a$$.tien_hang_nt||0)-($a$$.tien_ck_nt||0)).reduce(($a$$,$b$$)=>
|
|
95
|
+
$a$$+$b$$,0)-(($obj$$.tt_tien_thuong||0)+($obj$$.tien_ck_hd||0)+($obj$$.tien_evoucher||0));let $tien_paymentByPoints$$=$obj$$.tien_paymentByPoints||0;const $hoachtoandtvathue$$=($tk_tien$$,$ty_le$$)=>{$obj$$.details.forEach(function($d$jscomp$35_detail$$){$d$jscomp$35_detail$$={...$d$jscomp$35_detail$$};$d$jscomp$35_detail$$.tk_co=$option$$.tk_dt;$d$jscomp$35_detail$$.tk_no=$tk_tien$$;$d$jscomp$35_detail$$.ma_kh_co=$obj$$.ma_kh;$d$jscomp$35_detail$$.ma_kh_no=$option$$.ma_kh;$d$jscomp$35_detail$$.ngay_ct=
|
|
96
|
+
$obj$$.ngay_giao_hang||$obj$$.ngay_ct;$d$jscomp$35_detail$$.tien=$d$jscomp$35_detail$$.tien_nt=Math.roundBy($d$jscomp$35_detail$$.tien_ct_nt*$ty_le$$);$d$jscomp$35_detail$$.flag="DT_"+($d$jscomp$35_detail$$.ma_vt||"");$details$$.push($d$jscomp$35_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$$.ma_kh||($detail$$.ma_kh=$pt$$.ma_kh||$obj$$.ma_kh);$detail$$.tien=$detail$$.tien_nt=
|
|
97
|
+
Math.roundBy($detail$$.tien_thue_nt*$ty_le$$);$detail$$.flag="THUE_"+($detail$$.ma_vt||"");$details$$.push($detail$$)});console.log("post socai",$tk_tien$$,$ty_le$$)};$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$&&($hoachtoandtvathue$$($option$$.tk_cn,$tien_paymentByPoints$$/$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$),$hoachtoandtvathue$$($option$$.tk_tien,($rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$-
|
|
98
|
+
$tien_paymentByPoints$$)/$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$));$obj$$.details.filter($d$$=>$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$39_detail$$){$d$jscomp$39_detail$$=
|
|
99
|
+
{...$d$jscomp$39_detail$$};$d$jscomp$39_detail$$.tk_co=$option$$.tk_dt;$d$jscomp$39_detail$$.tk_no=$option$$.tk_cn;$d$jscomp$39_detail$$.ma_kh_co=$obj$$.ma_kh;$d$jscomp$39_detail$$.ma_kh_no=$option$$.ma_kh;$d$jscomp$39_detail$$.ngay_ct=$obj$$.ngay_giao_hang||$obj$$.ngay_ct;$d$jscomp$39_detail$$.tien_nt=$d$jscomp$39_detail$$.tien_cp_nt;$d$jscomp$39_detail$$.tien=$d$jscomp$39_detail$$.tien_cp;$details$$.push($d$jscomp$39_detail$$)});$obj$$.tien_phi_vc&&($rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$=
|
|
100
|
+
{},$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.tk_co=$option$$.tk_dt,$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.tk_no=$option$$.tk_cn,$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.tien_nt=$obj$$.tien_phi_vc||0,$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.tien=$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.tien_nt,
|
|
101
|
+
$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.ma_kh_co=$obj$$.ma_kh,$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.ma_kh_no=$obj$$.nhan_vien_giao_hang||$obj$$.don_vi_vc,$details$$.push($rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$));$obj$$.tien_freeship&&($rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$=
|
|
102
|
+
{},$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.tk_no=$option$$.tk_cp_gh,$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.tk_co=$option$$.tk_cn,$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.tien_nt=$obj$$.tien_freeship||0,$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.tien=$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.tien_nt,
|
|
103
|
+
$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.ma_kh_no=$obj$$.ma_kh,$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.ma_kh_co=$option$$.ma_kh,$details$$.push($rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$));$obj$$.tt_tien_thuong&&($rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$={},$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.tk_no=
|
|
104
|
+
$option$$.tk_cp_bh,$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.tk_co=$option$$.tk_cn,$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.tien_nt=$obj$$.tt_tien_thuong||0,$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.tien=$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.tien_nt,$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.ma_kh_no=
|
|
105
|
+
$obj$$.ma_kh,$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.ma_kh_co=$option$$.ma_kh,$details$$.push($rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$));$obj$$.thu_nhap_ctv&&$option$$.tk_cp_ctv&&$option$$.tk_cn_ctv&&($rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$={},$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.tk_no=
|
|
106
|
+
$option$$.tk_cp_ctv,$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.tk_co=$option$$.tk_cn_ctv,$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.tien_nt=$obj$$.thu_nhap_ctv||0,$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.tien=$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.tien_nt,$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.ma_kh=
|
|
107
|
+
$obj$$.ma_ctv,$details$$.push($rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$));$obj$$.tien_evoucher&&($rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$={},$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.tk_no=$obj$$.tk_no_evoucher||$option$$.tk_no_evoucher||$option$$.tk_ck,$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.tk_co=
|
|
108
|
+
$obj$$.tk_co_evoucher||$option$$.tk_co_evoucher||$option$$.tk_cn,$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.tien_nt=$obj$$.tien_evoucher||0,$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.tien=$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.tien_nt,$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.ma_kh_no=
|
|
109
|
+
$obj$$.ma_kh,$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.ma_kh_co=$option$$.ma_kh,$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.check_balance=!1,$details$$.push($rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$));$obj$$.tien_ck_hd&&($rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$={},$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.tk_no=
|
|
110
|
+
$option$$.tk_ck,$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.tk_co=$option$$.tk_cn,$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.tien_nt=$obj$$.tien_ck_hd||0,$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.tien=$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.tien_nt,$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.ma_kh_no=
|
|
111
|
+
$obj$$.ma_kh,$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.ma_kh_co=$option$$.ma_kh,$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.check_balance=!1,$details$$.push($rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$));$obj$$.tien_hoa_hong&&$obj$$.ma_kh_hoa_hong&&($rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$=
|
|
112
|
+
{},$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.tk_no=$obj$$.tk_no_hoa_hong||$error$$.tk_no_hoa_hong||options.tk_no_hoa_hong,$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.tk_co=$obj$$.tk_co_hoa_hong||$error$$.tk_co_hoa_hong||options.tk_co_hoa_hong,$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.tien_nt=$obj$$.tien_hoa_hong,$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.tien=
|
|
113
|
+
$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.tien_nt*($obj$$.ty_gia||1),$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.ma_kh=$obj$$.ma_kh_hoa_hong,$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.ma_nv=$obj$$.ma_nv,$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.check_balance=!1,$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.tk_no&&
|
|
114
|
+
$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.tk_co&&$details$$.push($rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$));$obj$$.tien_hoa_hong_gt&&$obj$$.ma_kh_hoa_hong_gt&&($rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$={},$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.tk_no=$obj$$.tk_no_hoa_hong_gt||
|
|
115
|
+
$error$$.tk_no_hoa_hong_gt||options.tk_no_hoa_hong_gt,$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.tk_co=$obj$$.tk_co_hoa_hong_gt||$error$$.tk_co_hoa_hong_gt||options.tk_co_hoa_hong_gt,$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.tien_nt=$obj$$.tien_hoa_hong_gt,$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.tien=$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.tien_nt*
|
|
114
116
|
($obj$$.ty_gia||1),$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.ma_kh=$obj$$.ma_kh_hoa_hong_gt,$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.ma_nv=$obj$$.ma_nv,$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.check_balance=!1,$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.tk_no&&$rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$.tk_co&&
|
|
115
|
-
$details$$.push($rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$));let $details_tienvon$$=[...$obj$$.details];$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$
|
|
116
|
-
$obj$$.ngay_ct;$d$jscomp$
|
|
117
|
+
$details$$.push($rs$jscomp$4_t_tt_tt_tt$jscomp$1_tt$jscomp$2_tt$jscomp$3_tt$jscomp$4_tt$jscomp$5_tt$jscomp$6_tt$$));let $details_tienvon$$=[...$obj$$.details];$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$40_detail$$){$d$jscomp$40_detail$$={...$d$jscomp$40_detail$$};$d$jscomp$40_detail$$.tk_no=$option$$.tk_gv;$d$jscomp$40_detail$$.ma_kh=$obj$$.ma_kh;$d$jscomp$40_detail$$.ngay_ct=$obj$$.ngay_giao_hang||
|
|
118
|
+
$obj$$.ngay_ct;$d$jscomp$40_detail$$.tk_co=$d$jscomp$40_detail$$.tk_vt||"1561";$d$jscomp$40_detail$$.tien_nt=$d$jscomp$40_detail$$.tien_xuat_nt;$d$jscomp$40_detail$$.tien=$d$jscomp$40_detail$$.tien_xuat;$d$jscomp$40_detail$$.tg_tk||($d$jscomp$40_detail$$.tien=$d$jscomp$40_detail$$.tien_nt=0);$details$$.push($d$jscomp$40_detail$$)});(new PostSocai($obj$$,$details$$,null,Socaitmp)).run(function($e$$,$rs$$){console.log("post result",$rs$$);$callback$$($e$$,$rs$$)})})})},thanhtoanhoahongnv:$callback$$=>
|
|
117
119
|
{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:1});if(!$wallet_nhan_vien$$){$wallet_nhan_vien$$=(new global.getModel("asskey"))({user_created:$obj$$.user_nv,username:$obj$$.user_nv,id_app:$obj$$.id_app,
|
|
118
120
|
wallet_type:1});const $wallet$$=await DirectSecp256k1HdWallet.generate(24,{prefix:configs.ADDRESS_PREFIX});let $accounts$$=await $wallet$$.getAccounts();$wallet_nhan_vien$$.address=$accounts$$[0].address;$wallet_nhan_vien$$.mnemonic=$wallet$$.mnemonic;$wallet_nhan_vien$$.name="T\u00e0i kho\u1ea3n nh\u1eadn th\u01b0\u1edfng";await $wallet_nhan_vien$$.save()}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()}`;
|
|
119
121
|
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$$){console.error("Kh\u00f4ng th\u1ec3 thanh to\u00e1n ti\u1ec1n hoa h\u1ed3ng",$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&&
|
|
@@ -125,7 +127,7 @@ $obj$$.da_chuyen_hoa_hong=!1;$obj$$.da_chuyen_hoa_hong_gt=!1;await $obj$$.detail
|
|
|
125
127
|
$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$$=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&&
|
|
126
128
|
$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$$;$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=
|
|
127
129
|
"",$obj$$.payment_service="",$obj$$.payment_id=""}else $obj$$.virtual_payment_client_url=""}catch($e$$){return console.error($e$$),$next$$("Kh\u00f4ng tao li\u00ean k\u1ebft thanh to\u00e1n:"+($e$$.message||$e$$.error||$e$$))}else console.log("Chua nhap phuong thuc thanh toan"),$obj$$.virtual_payment_client_url="";model.findOneAndUpdate({_id:$obj$$._id},{virtual_payment_client_url:$obj$$.virtual_payment_client_url,payment_id:$obj$$.payment_id,payment_service:$obj$$.payment_service},$e$$=>{$e$$&&(console.error($e$$),
|
|
128
|
-
console.log("error create Virtual Payment ClientURL",$e$$.message))});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=async($user$$,$data$$,$obj$$,$next$$)=>{$data$$.details||($data$$.details=$obj$$.details);if("10"==$data$$.trang_thai&&0>["LCT","0","1"].indexOf($obj$$.trang_thai))return $next$$("Kh\u00f4ng th\u1ec3 hu\u1ef7 \u0111\u01a1n h\u00e0ng n\u00e0y");
|
|
130
|
+
console.log("error create Virtual Payment ClientURL",$e$$.message))});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=async($user$$,$data$$,$obj$$,$next$$)=>{$data$$.details||($data$$.details=$obj$$.details);if("10"==$data$$.trang_thai&&0>["LCT","0","1"].indexOf($obj$$.trang_thai)&&$user$$.email===$obj$$.user_created)return $next$$("Kh\u00f4ng th\u1ec3 hu\u1ef7 \u0111\u01a1n h\u00e0ng n\u00e0y");
|
|
129
131
|
$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",fields:["combo"]});$obj$$.details.forEach($detail$$=>{$detail$$.combo&&0<$detail$$.combo.length&&($detail$$.combo=$detail$$.combo.map($item$$=>{$item$$=$item$$.toObject?$item$$.toObject():{...$item$$};$item$$.sl_xuat*=$detail$$.sl_xuat;$item$$.tien_xuat=$item$$.tien_xuat_nt=$item$$.sl_xuat*($item$$.gia_von_nt||
|
|
130
132
|
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$$}))});$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$$=>
|
|
131
133
|
{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()+":buy"});$next$$(null,$data$$,$obj$$)},$obj$$)};$contr_router$$.updated=async function($amount$jscomp$5_evouchers_user$$,$obj$$,$next$$){if(!$obj$$.virtual_payment_client_url&&("1"===$obj$$.trang_thai||"0"===$obj$$.trang_thai||"LCT"===$obj$$.trang_thai)){if($obj$$.pt_thanh_toan&&
|