mirror of
https://gitee.com/ShopeX/OMS
synced 2026-05-01 20:55:41 +08:00
1. 【新增】售后单售后原因类型支持搜索
2. 【新增】手工创建订单折扣可输入正数 3. 【优化】盘点申请单确认 4. 【修复】采购退货单模拟出库失败问题 5. 【新增】订单金额客户实付与结算金额 6. 【优化】仓库发货统计报表物料名称显示 7. 【优化】自有仓储虚拟发货逻辑 8. 【修复】基础物料分类管理问题
This commit is contained in:
@@ -14,23 +14,13 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
class ome_sales_delivery {
|
||||
|
||||
/**
|
||||
* __construct
|
||||
* @return mixed 返回值
|
||||
*/
|
||||
public function __construct(){
|
||||
public function __construct(){
|
||||
$this->db = kernel::database();
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理
|
||||
* @param mixed $delivery_id ID
|
||||
* @return mixed 返回值
|
||||
*/
|
||||
public function process($delivery_id){
|
||||
public function process($delivery_id, &$msg){
|
||||
|
||||
|
||||
$sales_data = $this->get_sales_data($delivery_id);
|
||||
@@ -41,11 +31,9 @@ class ome_sales_delivery {
|
||||
$sales_delivery = $saledeliverysObj->db_dump(array('delivery_id'=>$delivery_id),'delivery_id');
|
||||
if ($sales_delivery) return true;
|
||||
|
||||
$this->db->beginTransaction();
|
||||
$rs = $this->insertRow($delivery_id);
|
||||
if (!$rs) {
|
||||
|
||||
$this->db->rollBack();
|
||||
$msg = '发货销售单插入失败!';
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -55,14 +43,11 @@ class ome_sales_delivery {
|
||||
$sql = ome_func::get_insert_sql($itemsObj, $sales_delivery_data);
|
||||
$rs = $this->db->exec($sql);
|
||||
if (!$rs) {
|
||||
|
||||
$this->db->rollBack();
|
||||
$msg = '发货单明细插入失败!';
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->db->commit();
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -87,11 +72,26 @@ class ome_sales_delivery {
|
||||
|
||||
|
||||
$productId = array();
|
||||
$orderItemId = array();
|
||||
foreach ($delivery_items_detail as $item) {
|
||||
$productId[] = $item['product_id'];
|
||||
$orderItemId[] = $item['order_item_id'];
|
||||
}
|
||||
|
||||
$orderItemDetail = app::get('sales')->model('delivery_order_item')->getList('*', array('order_item_id' => $orderItemId), 0, -1);
|
||||
$orderItemSum = array();
|
||||
foreach ($orderItemDetail as $item) {
|
||||
$orderItemSum[$item['order_item_id']]['nums'] += $item['nums'];
|
||||
$orderItemSum[$item['order_item_id']]['pmt_price'] += $item['pmt_price'];
|
||||
$orderItemSum[$item['order_item_id']]['sale_price'] += $item['sale_price'];
|
||||
$orderItemSum[$item['order_item_id']]['apportion_pmt'] += $item['apportion_pmt'];
|
||||
$orderItemSum[$item['order_item_id']]['sales_amount'] += $item['sales_amount'];
|
||||
$orderItemSum[$item['order_item_id']]['platform_amount'] += $item['platform_amount'];
|
||||
$orderItemSum[$item['order_item_id']]['settlement_amount'] += $item['settlement_amount'];
|
||||
$orderItemSum[$item['order_item_id']]['actually_amount'] += $item['actually_amount'];
|
||||
$orderItemSum[$item['order_item_id']]['platform_pay_amount'] += $item['platform_pay_amount'];
|
||||
}
|
||||
|
||||
|
||||
$shop_detail = $this->get_shop_detail($deliveryDetail['shop_id']);
|
||||
|
||||
$branch_detail = $this->get_branch_detail($deliveryDetail['branch_id']);
|
||||
@@ -144,17 +144,27 @@ class ome_sales_delivery {
|
||||
} else {
|
||||
|
||||
//判断是否是最后一条,如果是,剩余的赋上
|
||||
|
||||
$tmpSaleDeliveryData['pmt_price'] = sprintf('%.2f', $tmpItemSalePrice['pmt_price']*$val['number']/$tmpItemSalePrice['nums']);
|
||||
$tmpSaleDeliveryData['sale_price'] = sprintf('%.2f',$tmpItemSalePrice['sale_price']*$val['number']/$tmpItemSalePrice['nums']);
|
||||
$tmpSaleDeliveryData['apportion_pmt'] = sprintf('%.2f', $tmpItemSalePrice['apportion_pmt']*$val['number']/$tmpItemSalePrice['nums']);
|
||||
$tmpSaleDeliveryData['price'] = sprintf('%.2f',$tmpItemSalePrice['price']);
|
||||
$tmpSaleDeliveryData['sales_amount'] = sprintf('%.2f', $tmpItemSalePrice['sales_amount']*$val['number']/$tmpItemSalePrice['nums']);
|
||||
$tmpSaleDeliveryData['platform_amount'] = sprintf('%.2f', $tmpItemSalePrice['platform_amount']*$val['number']/$tmpItemSalePrice['nums']);
|
||||
$tmpSaleDeliveryData['settlement_amount'] = sprintf('%.2f', $tmpItemSalePrice['settlement_amount']*$val['number']/$tmpItemSalePrice['nums']);
|
||||
$tmpSaleDeliveryData['platform_pay_amount'] = sprintf('%.2f', $tmpItemSalePrice['platform_pay_amount']*$val['number']/$tmpItemSalePrice['nums']);
|
||||
$tmpSaleDeliveryData['actually_amount'] = sprintf('%.2f', $tmpItemSalePrice['actually_amount']*$val['number']/$tmpItemSalePrice['nums']);
|
||||
|
||||
if($val['number'] + $orderItemSum[$val['order_item_id']]['nums'] == $tmpItemSalePrice['nums']){
|
||||
$tmpSaleDeliveryData['pmt_price'] = sprintf('%.2f',$tmpItemSalePrice['pmt_price'] - $orderItemSum[$val['order_item_id']]['pmt_price']);
|
||||
$tmpSaleDeliveryData['sale_price'] = sprintf('%.2f',$tmpItemSalePrice['sale_price'] - $orderItemSum[$val['order_item_id']]['sale_price']);
|
||||
$tmpSaleDeliveryData['apportion_pmt'] = sprintf('%.2f',$tmpItemSalePrice['apportion_pmt'] - $orderItemSum[$val['order_item_id']]['apportion_pmt']);
|
||||
$tmpSaleDeliveryData['price'] = sprintf('%.2f',$tmpItemSalePrice['price']);
|
||||
$tmpSaleDeliveryData['sales_amount'] = sprintf('%.2f',$tmpItemSalePrice['sales_amount'] - $orderItemSum[$val['order_item_id']]['sales_amount']);
|
||||
$tmpSaleDeliveryData['platform_amount'] = sprintf('%.2f',$tmpItemSalePrice['platform_amount'] - $orderItemSum[$val['order_item_id']]['platform_amount']);
|
||||
$tmpSaleDeliveryData['settlement_amount'] = sprintf('%.2f',$tmpItemSalePrice['settlement_amount'] - $orderItemSum[$val['order_item_id']]['settlement_amount']);
|
||||
$tmpSaleDeliveryData['platform_pay_amount'] = sprintf('%.2f',$tmpItemSalePrice['platform_pay_amount'] - $orderItemSum[$val['order_item_id']]['platform_pay_amount']);
|
||||
$tmpSaleDeliveryData['actually_amount'] = sprintf('%.2f',$tmpItemSalePrice['actually_amount'] - $orderItemSum[$val['order_item_id']]['actually_amount']);
|
||||
} else {
|
||||
$tmpSaleDeliveryData['pmt_price'] = sprintf('%.2f', $tmpItemSalePrice['pmt_price']*$val['number']/$tmpItemSalePrice['nums']);
|
||||
$tmpSaleDeliveryData['sale_price'] = sprintf('%.2f',$tmpItemSalePrice['sale_price']*$val['number']/$tmpItemSalePrice['nums']);
|
||||
$tmpSaleDeliveryData['apportion_pmt'] = sprintf('%.2f', $tmpItemSalePrice['apportion_pmt']*$val['number']/$tmpItemSalePrice['nums']);
|
||||
$tmpSaleDeliveryData['price'] = sprintf('%.2f',$tmpItemSalePrice['price']);
|
||||
$tmpSaleDeliveryData['sales_amount'] = sprintf('%.2f', $tmpItemSalePrice['sales_amount']*$val['number']/$tmpItemSalePrice['nums']);
|
||||
$tmpSaleDeliveryData['platform_amount'] = sprintf('%.2f', $tmpItemSalePrice['platform_amount']*$val['number']/$tmpItemSalePrice['nums']);
|
||||
$tmpSaleDeliveryData['settlement_amount'] = sprintf('%.2f', $tmpItemSalePrice['settlement_amount']*$val['number']/$tmpItemSalePrice['nums']);
|
||||
$tmpSaleDeliveryData['platform_pay_amount'] = sprintf('%.2f', $tmpItemSalePrice['platform_pay_amount']*$val['number']/$tmpItemSalePrice['nums']);
|
||||
$tmpSaleDeliveryData['actually_amount'] = sprintf('%.2f', $tmpItemSalePrice['actually_amount']*$val['number']/$tmpItemSalePrice['nums']);
|
||||
}
|
||||
}
|
||||
|
||||
$zkjg = $objMath->number_minus(array($tmpSaleDeliveryData['price']*$tmpSaleDeliveryData['nums'],$tmpSaleDeliveryData['pmt_price'],$tmpSaleDeliveryData['sale_price']));
|
||||
@@ -225,11 +235,6 @@ class ome_sales_delivery {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* insertRow
|
||||
* @param mixed $delivery_id ID
|
||||
* @return mixed 返回值
|
||||
*/
|
||||
public function insertRow($delivery_id) {
|
||||
|
||||
$deliveryObj = app::get('ome')->model('delivery');
|
||||
@@ -267,11 +272,6 @@ class ome_sales_delivery {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取_avg_delivery_data
|
||||
* @param mixed $salesData 数据
|
||||
* @return mixed 返回结果
|
||||
*/
|
||||
public function get_avg_delivery_data($salesData){
|
||||
|
||||
$delivery_items = array();
|
||||
@@ -292,4 +292,4 @@ class ome_sales_delivery {
|
||||
|
||||
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
@@ -14,16 +14,10 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
class ome_sales_original_data
|
||||
{
|
||||
private $appName = 'ome';
|
||||
|
||||
/**
|
||||
* 设置AppName
|
||||
* @param mixed $appName appName
|
||||
* @return mixed 返回操作结果
|
||||
*/
|
||||
public function setAppName($appName) {
|
||||
$this->appName = $appName;
|
||||
return $this;
|
||||
@@ -74,6 +68,7 @@ class ome_sales_original_data
|
||||
if($item['delete'] == 'true'){
|
||||
$is_item_delete = true;
|
||||
unset($order_info['order_objects'][$key]['order_items'][$k]);
|
||||
unset($items[$k]);
|
||||
$item_delete_flag++;
|
||||
}
|
||||
if (!$is_item_delete){
|
||||
@@ -97,7 +92,8 @@ class ome_sales_original_data
|
||||
}
|
||||
$tmp_sale_price = $tmp_sale_price-$item['refund_money'];
|
||||
|
||||
$order_info['order_objects'][$key]['order_items'][$k]['sale_price'] = $tmp_sale_price;
|
||||
// 格式化避免浮点数精度问题导致科学计数法
|
||||
$order_info['order_objects'][$key]['order_items'][$k]['sale_price'] = floatval(sprintf('%.2f', $tmp_sale_price));
|
||||
|
||||
$tmp_item_pmt_price_all += $tmp_item_pmt_price;
|
||||
}
|
||||
@@ -113,8 +109,12 @@ class ome_sales_original_data
|
||||
$order_info['order_objects'][$key]['pmt_price'] = $tmp_obj_pmt_price;
|
||||
|
||||
$tmp_obj_sale_price = ($obj['sale_price'] > 0) ? $obj['sale_price'] : ((($tmp_obj_amount-$tmp_obj_pmt_price-$tmp_item_pmt_price_all) > 0) ? ($tmp_obj_amount-$tmp_obj_pmt_price-$tmp_item_pmt_price_all) : 0.000);
|
||||
$order_info['order_objects'][$key]['sale_price'] = $tmp_obj_sale_price;
|
||||
// 格式化避免浮点数精度问题导致科学计数法,使用三位小数与原始代码保持一致
|
||||
$order_info['order_objects'][$key]['sale_price'] = floatval(sprintf('%.3f', $tmp_obj_sale_price));
|
||||
|
||||
if($order_info['settlement_amount'] > 0) {
|
||||
continue;
|
||||
}
|
||||
$platformAmount = $couponPlatform->getPlatformAmount($obj);
|
||||
$order_info['order_objects'][$key]['platform_amount'] = $platformAmount;
|
||||
$order_info['order_objects'][$key]['settlement_amount'] = $platformAmount + $obj['divide_order_fee'];
|
||||
@@ -220,7 +220,8 @@ class ome_sales_original_data
|
||||
$sum -= abs($data['discount']);
|
||||
}
|
||||
|
||||
$sum = $sum - $data['pmt_goods'] - $data['pmt_order'];
|
||||
// 使用 bcmath 进行精确计算,避免浮点数精度问题
|
||||
$sum = bcsub(bcsub($sum, $data['pmt_goods'], 3), $data['pmt_order'], 3);
|
||||
$data['total_amount'] = $data['total_amount']-$data['service_price']-$data['refund_money'];
|
||||
if(bccomp($data['total_amount'], $sum, 3) == 0){
|
||||
return true;
|
||||
@@ -235,4 +236,4 @@ class ome_sales_original_data
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
9
app/ome/lib/sales/original/platform/xhs.php
Normal file
9
app/ome/lib/sales/original/platform/xhs.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
class ome_sales_original_platform_xhs extends ome_sales_original_platform_factory
|
||||
{
|
||||
protected $platfomAmountType = [
|
||||
'pingTaiChengDanYouHuiQuan',
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user