Эх сурвалжийг харах

Merge branch 'master' of http://git.daboryhost.com:10880/dabory/dbrerp

hokky 3 сар өмнө
parent
commit
06cb676be7

+ 21 - 0
app/helpers.php

@@ -6,6 +6,27 @@ use Illuminate\Support\Str;
 use Jenssegers\Agent\Agent as Agent;
 use Unirest\Request;
 
+function getHashSorderNo($sorderNo)
+{
+    $sorderNoExplode = explode('-', $sorderNo);
+    return $sorderNoExplode[0] . '-' . generate4DigitHash($sorderNo);
+}
+
+function generate4DigitHash($input)
+{
+    // Generate a SHA-256 hash
+    $hash = hash('sha256', $input);
+
+    // Convert hash to base 10 and get the first 4 digits
+    $decimalHash = base_convert($hash, 16, 10);
+
+    // Truncate or pad to ensure it's 4 digits long
+    $fourDigitHash = substr($decimalHash, 0, 4);
+
+    // Ensure it's always 4 digits
+    return str_pad($fourDigitHash, 4, '0', STR_PAD_LEFT);
+}
+
 function detect($view)
 {
     $agent = new Agent();

+ 3 - 0
public/js/utils/lib.js

@@ -143,6 +143,9 @@ function rand(min, max) {
 
 function format_decimal(val, number) {
     let format = decimal_convert(number);
+    // 소수점 버린다.
+    return numeral(Math.floor(val).toFixed(number)).format(format);
+    // 소수점 반올림.
     return numeral(parseFloat(val).toFixed(number)).format(format);
 }