Add solde status to products when transaction is detected
This commit is contained in:
parent
3e65bf1fcf
commit
48668e7433
|
@ -17,7 +17,7 @@
|
||||||
<th>Prix en junes</th>';
|
<th>Prix en junes</th>';
|
||||||
|
|
||||||
$params["antenne_slug"] = $antenne_slug;
|
$params["antenne_slug"] = $antenne_slug;
|
||||||
$requete = "SELECT products.*, users.username, users.pubkey
|
$requete = "SELECT products.*, users.username, users.pubkey
|
||||||
FROM products
|
FROM products
|
||||||
LEFT JOIN antennes
|
LEFT JOIN antennes
|
||||||
ON antennes.id = products.antenne_id
|
ON antennes.id = products.antenne_id
|
||||||
|
@ -50,7 +50,13 @@
|
||||||
<td>$number</td>";
|
<td>$number</td>";
|
||||||
$prix = $row['prix'];
|
$prix = $row['prix'];
|
||||||
$vendeur = $row['username'];
|
$vendeur = $row['username'];
|
||||||
$produit = $row['name'];
|
$status = $row['status'];
|
||||||
|
if ($status == "solde") {
|
||||||
|
$produit = "[$status] ";
|
||||||
|
} else {
|
||||||
|
$produit = "";
|
||||||
|
}
|
||||||
|
$produit .= $row['name'];
|
||||||
$pubkey = $row['pubkey'];
|
$pubkey = $row['pubkey'];
|
||||||
$pubkeyShort = substr($pubkey, 0, 8);
|
$pubkeyShort = substr($pubkey, 0, 8);
|
||||||
$vendeur_format = "<a target=\"_blank\" href=\"https://g1.duniter.fr/#/app/wot/$pubkey/\">$vendeur</a>";
|
$vendeur_format = "<a target=\"_blank\" href=\"https://g1.duniter.fr/#/app/wot/$pubkey/\">$vendeur</a>";
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#DUNITER="http://192.168.9.54:45000"
|
||||||
|
DUNITER="https://duniter-g1.p2p.legal"
|
||||||
|
TXBLOCKS=$(curl -s ${DUNITER}/blockchain/with/tx | jq '.result.blocks[]')
|
||||||
|
TXBLOCKS=$(echo "$TXBLOCKS" | tail -n 5 | tr '\n' ' ')
|
||||||
|
|
||||||
|
#echo "$TXBLOCKS"
|
||||||
|
|
||||||
|
for i in $TXBLOCKS2; do
|
||||||
|
result=$(curl -s ${DUNITER}/blockchain/block/$i | jq '.transactions[].comment' | grep -v '""' | tr -d '"')
|
||||||
|
isSell=$(echo "$result" | grep "Merci")
|
||||||
|
# [[ ! -z $isSell ]] && echo $isSell
|
||||||
|
# echo ---
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
isSell="[Achat GMarche] : testCesium"
|
||||||
|
isSell=$(echo $isSell | cut -d' ' -f4-)
|
||||||
|
|
||||||
|
echo "$isSell est vendu"
|
||||||
|
|
||||||
|
req="UPDATE products SET status = 'solde' WHERE name = '$isSell';"
|
||||||
|
|
||||||
|
mysql --database gmarche -e "$req"
|
||||||
|
mysql --database gmarche -e "SELECT name,status FROM products;"
|
||||||
|
|
||||||
|
exit 0
|
Loading…
Reference in New Issue