mirror of
https://gitee.com/ShopeX/OMS
synced 2026-04-13 17:25:39 +08:00
66 lines
2.3 KiB
PHP
66 lines
2.3 KiB
PHP
<?php
|
|
/**
|
|
* Copyright 2012-2026 ShopeX (https://www.shopex.cn)
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
|
|
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;
|
|
}
|
|
|
|
} |