Another awk approach:
awk -F'|' 'NR==FNR{f1[$1FS$2]=$NF;next} {f2[$1FS$2]=$NF} END{for (x in f1){print x,f1[x],f2[x]?f2[x]:0; delete f2[x]}; for (y in f2) print y, 0, f2[y] }' file[12] OFS='|' ###Explanation:
NR==FNR{f1[$1FS$2]=$NF;next}, this will run only for file1 and with the key combination of$1FS$2will store last column value$NFin array calledf1(FSwill substitute with|as awk's Field Seperator).{f2[$1FS$2]=$NF}, same as above but this will run only for file2for (x in f1){print x,f1[x],f2[x]?f2[x]:0; delete f2[x]}, loop within arrayf1and print key (x), its value in file1f1[x]and if there same file1 key in file2, then print it as well, else print0(Used ternary conditionf2[x]?f2[x]:0), after that we are also deleting record of same key from file2 withdelete f2[x].for (y in f2) print y, 0, f2[y], now arrayf2has records which exist in file2 only, so we are printing their key (y),0because doesn't not exist in file1 and their value in file2f2[y].