优化出库单和预约单导出功能
- 修改了出库单和预约单导出时的数据处理逻辑,增加了更多订单相关信息 - 优化了导出文档的格式,提高了可读性和信息完整性 - 新增字符串转数字的工具函数 `convertStringToNumber`
This commit is contained in:
parent
18fbbdeb36
commit
194fbbb2dd
@ -9,6 +9,7 @@ use app\admin\lists\beforehand_order\BeforehandOrderTwoLists;
|
||||
use app\admin\lists\beforehand_order\BeforehandOrderThreeLists;
|
||||
use app\admin\logic\beforehand_order\BeforehandOrderLogic;
|
||||
use app\common\model\beforehand_order\BeforehandOrder;
|
||||
use app\common\model\store_order\StoreOrder;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
use app\common\model\store_product_unit\StoreProductUnit;
|
||||
use app\common\model\system_store\SystemStore;
|
||||
@ -133,19 +134,29 @@ class BeforehandOrderController extends BaseAdminController
|
||||
public function export()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$outbound_id = BeforehandOrder::where('id', $params['id'])->value('outbound_id');
|
||||
if(!$outbound_id){
|
||||
$order = BeforehandOrder::where('id', $params['id'])->field('outbound_id,order_sn')->find();
|
||||
if(!$order){
|
||||
return $this->fail('未生成出库单');
|
||||
}
|
||||
$warehouseOrder = WarehouseOrder::where('id', $outbound_id)->field('store_id,delivery_time')->find();
|
||||
$warehouseOrder = WarehouseOrder::where('id', $order['outbound_id'])->field('store_id,delivery_time')->find();
|
||||
$system_store = SystemStore::where('id', $warehouseOrder['store_id'])->value('name');
|
||||
$data = WarehouseProduct::where('oid', $outbound_id)->field('product_id,nums')->select()
|
||||
->each(function ($item) use ($system_store,$warehouseOrder) {
|
||||
$item['system_store'] = $system_store;
|
||||
$data = WarehouseProduct::where('oid', $order['outbound_id'])->field('product_id,nums')->select()
|
||||
->each(function ($item) use ($system_store,$warehouseOrder,$order) {
|
||||
$find = StoreProduct::where('id', $item['product_id'])->field('store_name,unit')->find();
|
||||
$item['store_name'] = $find['store_name'];
|
||||
$unit_name = StoreProductUnit::where('id', $find['unit'])->value('name');
|
||||
$item['unit_name'] = $item['nums'].'/'.$unit_name.' '.date('m-d',$warehouseOrder['delivery_time']);
|
||||
$item['system_store'] = $system_store;
|
||||
$item['subtitle'] = $item['oid'].' '.convertStringToNumber($item['nums']).'/'.$unit_name;
|
||||
$item['store_name'] = $find['store_name'];
|
||||
if($warehouseOrder['oid']){
|
||||
$find=StoreOrder::where('order_id',$order['order_sn'])->field('real_name,user_address')->find();
|
||||
if($find){
|
||||
$item['address'] = $find['real_name'].' '.$find['user_address'];
|
||||
}else{
|
||||
$item['address'] = '无地址';
|
||||
}
|
||||
}else{
|
||||
$item['address'] = '无地址';
|
||||
}
|
||||
})
|
||||
->toArray();
|
||||
$file_path=(new Beforehand())->export($data, $system_store);
|
||||
|
@ -283,15 +283,25 @@ class WarehouseOrderController extends BaseAdminController
|
||||
public function export_tags()
|
||||
{
|
||||
$id = $this->request->post('id');
|
||||
$warehouseOrder = WarehouseOrder::where('id', $id)->field('store_id,delivery_time')->find();
|
||||
$warehouseOrder = WarehouseOrder::where('id', $id)->field('oid,store_id,delivery_time')->find();
|
||||
$system_store = SystemStore::where('id', $warehouseOrder['store_id'])->value('introduction');
|
||||
$data = WarehouseProduct::where('oid', $id)->where('financial_pm',0)->field('oid,product_id,nums')->select()
|
||||
->each(function ($item) use ($system_store,$warehouseOrder) {
|
||||
$item['system_store'] = $system_store.' '.$item['oid'];
|
||||
$find = StoreProduct::where('id', $item['product_id'])->field('store_name,unit')->find();
|
||||
$item['store_name'] = $find['store_name'];
|
||||
$unit_name = StoreProductUnit::where('id', $find['unit'])->value('name');
|
||||
$item['unit_name'] = $item['nums'].'/'.$unit_name.' '.date('m-d',$warehouseOrder['delivery_time']);
|
||||
$item['system_store'] = $system_store;
|
||||
$item['subtitle'] = $item['oid'].' '.convertStringToNumber($item['nums']).'/'.$unit_name;
|
||||
$item['store_name'] = $find['store_name'];
|
||||
if($warehouseOrder['oid']){
|
||||
$find=StoreOrder::where('id',$warehouseOrder['oid'])->field('real_name,user_address')->find();
|
||||
if($find){
|
||||
$item['address'] = $find['real_name'].' '.$find['user_address'];
|
||||
}else{
|
||||
$item['address'] = '无地址';
|
||||
}
|
||||
}else{
|
||||
$item['address'] = '无地址';
|
||||
}
|
||||
})
|
||||
->toArray();
|
||||
$file_path=(new Beforehand())->export($data, $system_store);
|
||||
|
@ -22,11 +22,17 @@ class Beforehand
|
||||
'marginBottom' => Converter::cmToTwip(0),
|
||||
));
|
||||
$fontStyle = ['name' => 'Arial', 'size' => 12, 'bold' => true];
|
||||
$fontStyle1 = ['name' => 'Arial', 'size' => 8, 'bold' => true];
|
||||
$fontStyle2 = ['name' => 'Arial', 'size' => 8, 'bold' => true];
|
||||
$fontStyle3 = ['name' => 'Arial', 'size' => 8, 'bold' => true];
|
||||
|
||||
foreach ($data as $k => $v) {
|
||||
$section->addText(mb_substr($v['system_store'], 0, 8, 'UTF-8'), $fontStyle);
|
||||
$section->addText(mb_substr( $v['store_name'], 0, 8, 'UTF-8'), $fontStyle);
|
||||
$section->addText(mb_substr($v['unit_name'], 0, 8, 'UTF-8'), $fontStyle);
|
||||
$textRun =$section->addTextRun();
|
||||
|
||||
$textRun->addText($v['system_store'], $fontStyle);
|
||||
$textRun->addText(' '.mb_substr($v['subtitle'], 0, 8, 'UTF-8'), $fontStyle1);
|
||||
$section->addText(mb_substr( $v['store_name'], 0, 16, 'UTF-8'), $fontStyle2);
|
||||
$section->addText($v['address'], $fontStyle3);
|
||||
}
|
||||
|
||||
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
|
||||
|
@ -500,6 +500,29 @@ if (!function_exists('convertNumber')) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!function_exists('convertStringToNumber')) {
|
||||
|
||||
/**
|
||||
* 根据字符串是否包含小数点以及小数点后的值,决定将其转换为浮点数或整数
|
||||
*
|
||||
* @param string $str 需要转换的字符串
|
||||
* @return mixed 转换后的浮点数或整数
|
||||
*/
|
||||
function convertStringToNumber($str)
|
||||
{
|
||||
$count = explode('.', $str);
|
||||
if (count($count) > 1) {
|
||||
// 包含小数点,转换为浮点数
|
||||
if ($count[1] > 0) {
|
||||
return floatval($str);
|
||||
}
|
||||
return intval($str);
|
||||
} else {
|
||||
// 不包含小数点,转换为整数
|
||||
return intval($str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 日志记录
|
||||
|
Loading…
x
Reference in New Issue
Block a user