Commit 2b0d8b3e authored by Kulya's avatar Kulya 😊

Added OrderCreate func

parent 06de5bb9
......@@ -14,6 +14,11 @@
</style>
<script>
var afterLoadPage = function(reload){
var testwin = window.open("https://my2.soliq.uz/main/info/personal/data?tin=303903621");
console.log("testwin:",testwin);
$.ajax({
url: location.origin+location.pathname,
data: {
......
......@@ -714,6 +714,48 @@ class AloVoiceRest
return $result;
}
private function create_billz_order($r=false) {
$arOrderProducts = [
[
"office_id" => 1347,
"id" => 6154,
"billz_id" => 2641209,
"name" => "Ilm olish sirlari",
"barcode" => "9789943510470",
"sku" => "VIP756",
"quantity" => 2,
"price" => 1200,
"discount" =>180
]
];
$arOrderParams = [
"order_id" => "123123123",
"paytype" => "payme",
// "datePaid" => "2018-03-27T09:19:25.667Z",
"products" => $arOrderProducts
];
$createRes = BillzRest::createOrder($arOrderParams);
// answer {
// "settings": {
// "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJxYW0uYml0cml4MjQucnUiLCJpYXQiOjE2MzkxMzU5NTQsImV4cCI6MTYzOTI4NTk1NCwic3ViIjoicWFtYXIuYml0cml4MjQifQ.N1I8rP3admsR_dGIHvYyAPcgu64wPoDTAaI9XHIfCyc",
// "url": "https://api.billz.uz/v4/"
// },
// "params": "{\"jsonrpc\":\"2.0\",\"method\":\"orders.create\",\"params\":{\"subTotalPrice\":0,\"orderID\":\"123123123\",\"dateCreated\":\"2021-12-10T16:32:34Z\",\"products\":[{\"billzOfficeID\":1347,\"billzProductID\":2641209,\"productID\":6154,\"name\":\"Ilm olish sirlari\",\"barCode\":\"9789943510470\",\"sku\":\"VIP756\",\"qty\":2,\"subTotalPrice\":1200,\"discountAmount\":180,\"totalPrice\":1020}],\"paymentMethod\":\"payme\",\"totalPrice\":0}}",
// "answer": {
// "jsonrpc": "2.0",
// "error": {
// "code": -32601,
// "message": "Method not found"
// }
// }
// }
return $createRes;
}
private function test($r=false) {
$conf = self::get_billzconf();
return BxRest::call("catalog.product.getFieldsByFilter",[
......
......@@ -31,7 +31,62 @@ require_once (__DIR__.'/keys.php');
return $result;
}
public static function createOrder($params=false) {
/*
order_id
paytype
datePaid
products
office_id (todo select from billz)
id
billz_id
name
barcode
sku
quantity
price (optional)
discount (optional)
*/
$qPparams['subTotalPrice'] = 0;
$arProducts = [];
foreach($params["products"] as $prd){
$price = (!empty($prd["price"])) ? $prd["price"] : 0;
$dsnt = (!empty($prd["discount"])) ? $prd["discount"] : 0;
$arProducts[] = [
"billzOfficeID" => $prd["office_id"],
"billzProductID" => $prd["billz_id"],
"productID" => $prd["id"],
"name" => $prd["name"],
"barCode" => $prd["barcode"],
"sku" => $prd["sku"],
"qty" => $prd["quantity"],
"subTotalPrice" => $price,
"discountAmount" => $dsnt,
"totalPrice" => $price-$dsnt,
];
$qPparams['subTotalPrice'] = $qPparams['subTotalPrice']+$price;
}
$qPparams['orderID'] = $params["order_id"];
$qPparams['dateCreated'] = date('Y-m-d').'T'.date('H:i:s').'Z';
$qPparams['products'] = $arProducts;
$qPparams['paymentMethod'] = "payme"; //$params["paytype"];
// $params['datePaid'] = date('Y-m-d').'T'.date('H:i:s').'Z'; // ??
if(!empty($qPparams['discount'])){
$qPparams['discountAmount'] = $qPparams['discount'];
}
$qPparams['totalPrice'] = (!empty($qPparams['discountAmount'])) ? $qPparams['subTotalPrice']-$qPparams['discount'] : $qPparams['subTotalPrice'];
$result = static::callCurl("orders.create",$qPparams);
return $result;
}
public static function getCatalog($page=1,$cnt=1) {
$result = static::callCurl("catalog.get",[
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment