Files
OMS/app/ome/lib/order/remain/giftpackage.php
2025-12-28 23:13:25 +08:00

55 lines
1.8 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
/**
* Copyright © ShopeX http://www.shopex.cn. All rights reserved.
* See LICENSE file for license details.
*/
class ome_order_remain_giftpackage {
/*
* 获取订单编辑的商品类型配置列表
* @return array conf
*/
public function diff_money($obj){
$amount = 0;
if ($obj['order_items']){
foreach ($obj['order_items'] as $item){
if ($item['delete'] == 'true') return 0;
break;
}
$leave = ($item['quantity']-$item['sendnum'])*($obj['quantity']/$item['quantity']);
$amount = $obj['price']*$leave;
}
return $amount;
}
/*
* 余单撤销处理
*/
public function remain_cancel($obj){
if ($obj) {
$delete = false;
foreach ($obj['order_items'] as $item){
if ($item['sendnum'] == 0){
$delete = true;
break;
}else {
$num = $obj['quantity'] / $item['quantity'] * $item['sendnum'];
}
}
if ($delete == true){
$sql = "UPDATE `sdb_ome_order_items` SET `delete`='true' WHERE `obj_id`='".$obj['obj_id']."'";//"' AND `sendnum`<`nums` AND `sendnum` = '0' ";
kernel::database()->exec($sql);
}else {
$sql = "UPDATE `sdb_ome_order_items` SET `nums`=`sendnum` WHERE `obj_id`='".$obj['obj_id']."' AND `sendnum`<`nums` AND `sendnum` <> '0' ";
kernel::database()->exec($sql);
$sql = "UPDATE `sdb_ome_order_objects` SET `quantity`=".$num." WHERE `obj_id`='".$obj['obj_id']."'";
kernel::database()->exec($sql);
}
return true;
}
return false;
}
}