<?php 
require 'db.php';
$data = json_decode(file_get_contents('php://input'), true);
if($data['uid'] == '' or $data['oid'] == '')
{
    $returnArr = array("ResponseCode"=>"401","Result"=>"false","ResponseMsg"=>"Something Went Wrong!");
}
else
{
    $uid = strip_tags(mysqli_real_escape_string($con,$data['uid']));
    $oid = strip_tags(mysqli_real_escape_string($con,$data['oid']));
    $reason = strip_tags(mysqli_real_escape_string($con,$data['reason']));
    
    $shops = $con->query("select * from orders where order_id='$oid'");
	if($roww = $shops->fetch_assoc())
	{
	    $coins = $roww['coins'];
	}
	
	$con->query("update user set coins='$coins' where id='$uid'");
    
    $con->query("update orders set o_status='0',status='cancelled',comment='$reason' where order_id='$oid' and uid='$uid'");
    
    $new_oid = "%#".$oid."%";
    
    $con->query("delete from coin_transactions where uid = '$uid' and name LIKE '$new_oid'");

    $returnArr = array("ResponseCode"=>"200","Result"=>"true","ResponseMsg"=>"Order Cancel Successfully!","coins"=>$coins);
}
echo json_encode($returnArr);