Merge pull request '会员表单' (#391) from dev into main

Reviewed-on: #391
This commit is contained in:
mkm 2024-12-15 15:19:05 +08:00
commit 70bd6f9c90
2 changed files with 54 additions and 0 deletions

View File

@ -255,6 +255,15 @@ class BeforehandOrderController extends BaseAdminController
$file_path = BeforehandOrderLogic::OrderOutbound($params);
}
return $this->success('导出成功', ['url' => $file_path]);
}
/**
* 导出会员出库
*/
public function order_outbound3()
{
$params = $this->request->post();
$file_path = BeforehandOrderLogic::OrderOutbound3($params);
return $this->success('导出成功', ['url' => $file_path]);
}
/**
* 导出财务出库

View File

@ -17,6 +17,7 @@ use app\common\model\store_category\StoreCategory;
use app\common\model\store_order\StoreOrder;
use app\common\model\store_order_cart_info\StoreOrderCartInfo;
use app\common\model\store_product\StoreProduct;
use app\common\model\store_product_group_price\StoreProductGroupPrice;
use app\common\model\store_product_unit\StoreProductUnit;
use app\common\model\system_store\SystemStore;
use app\common\model\user\User;
@ -835,4 +836,48 @@ class BeforehandOrderLogic extends BaseLogic
$file_path = $order_info->export($data, $order, $other_data, 2);
return $file_path;
}
/**
* 导出供货出库
*/
public static function OrderOutbound3($params)
{
$order_info = new OrderSupplyOutbound();
$order = BeforehandOrder::where('id', $params['id'])->find();
if ($order['outbound_id'] <= 0) {
throw new BusinessException('订单未出库,不能导出出库单');
}
$order['admin_name'] = Admin::where('id', $order['admin_id'])->value('name');
$data = WarehouseProduct::where('oid', $order['outbound_id'])->where('nums', '>', 0)->select();
$total_price = 0;
$pay_price = 0;
$total_profit = 0;
foreach ($data as $k => &$v) {
$find = StoreProduct::where('id', $v['product_id'])->field('top_cate_id,store_name,unit,after_sales')->withTrashed()->find();
$v['unit_name'] = StoreProductUnit::where('id', $find['unit'])->value('name');
$v['store_name'] = $find['store_name'];
$v['mark'] = $find['after_sales'];
$v['purchase']=StoreProductGroupPrice::where('product_id',$v['product_id'])->where('group_id',18)->value('price');
if($v['purchase']){
$v['pay_price'] = bcmul($v['purchase'], $v['nums'], 2);
}else{
$v['pay_price']=0;
}
$v['profit']= bcsub($v['total_price'], $v['pay_price'], 2);
$total_profit = bcadd($total_profit, $v['profit'], 2);
$pay_price = bcadd($pay_price, $v['pay_price'], 2);
$total_price = bcadd($total_price, $v['total_price'], 2);
}
$order['system_store_name'] = SystemStore::where('id', $order['store_id'])->value('name');
$other_data = $order['other_data'];
unset($order['other_data']);
$find = WarehouseOrder::where('id', $order['outbound_id'])->find();
$order['order_id'] = $find['code'];
$order['pay_price'] = $pay_price;
$order['total_profit'] = $total_profit;
$order['total_price'] = $total_price;
$file_path = $order_info->export($data, $order, $other_data, 2);
return $file_path;
}
}