commit
43a20d74fc
@ -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);
|
||||
|
@ -18,8 +18,10 @@ 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_unit\StoreProductUnit;
|
||||
use app\common\model\system_store\SystemStore;
|
||||
use app\common\model\warehouse_order\WarehouseOrder;
|
||||
use app\common\model\warehouse_product\WarehouseProduct;
|
||||
use app\common\service\xlsx\Beforehand;
|
||||
use app\common\service\xlsx\OrderDetail;
|
||||
use support\exception\BusinessException;
|
||||
use think\facade\Db;
|
||||
@ -168,9 +170,9 @@ class StoreOrderController extends BaseAdminController
|
||||
$order['delivery_time'] = date('Y-m-d', $time);
|
||||
$data = StoreOrderCartInfo::where('oid', $id)->select();
|
||||
foreach ($data as $key => &$value) {
|
||||
if(in_array($order['store_id'],[17,18])){
|
||||
$find = StoreBranchProduct::where('product_id', $value->product_id)->where('store_id',$order['store_id'])->find();
|
||||
}else{
|
||||
if (in_array($order['store_id'], [17, 18])) {
|
||||
$find = StoreBranchProduct::where('product_id', $value->product_id)->where('store_id', $order['store_id'])->find();
|
||||
} else {
|
||||
$find = StoreProduct::where('id', $value->product_id)->find();
|
||||
}
|
||||
$value->store_name = $find['store_name'] ?? '';
|
||||
@ -198,12 +200,12 @@ class StoreOrderController extends BaseAdminController
|
||||
$warehouse_id = $this->request->post('warehouse_id');
|
||||
$delivery_time = $this->request->post('delivery_time');
|
||||
$mark = $this->request->post('mark');
|
||||
$find = WarehouseOrder::where('oid',$id)->find();
|
||||
if($find){
|
||||
$find = WarehouseOrder::where('oid', $id)->find();
|
||||
if ($find) {
|
||||
return $this->fail('该订单已创建出库单');
|
||||
}
|
||||
$product_arr=StoreOrderCartInfo::where('oid',$id)->field('oid,product_id id,price,total_price,cart_num stock')->select();
|
||||
if(!$product_arr){
|
||||
$product_arr = StoreOrderCartInfo::where('oid', $id)->field('oid,product_id id,price,total_price,cart_num stock')->select();
|
||||
if (!$product_arr) {
|
||||
return $this->fail('无商品');
|
||||
}
|
||||
Db::startTrans();
|
||||
@ -252,4 +254,31 @@ class StoreOrderController extends BaseAdminController
|
||||
}
|
||||
return $this->success('已导入后台队列,请在门店入库记录中查看', [], 1, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出标签
|
||||
*/
|
||||
public function export_tags()
|
||||
{
|
||||
$id = $this->request->post('id');
|
||||
$order = StoreOrder::where('id', $id)->field('store_id,uid,real_name,user_address')->find();
|
||||
|
||||
$system_store = SystemStore::where('id', $order['store_id'])->value('introduction');
|
||||
$data = StoreOrderCartInfo::where('oid', $id)->field('oid,product_id,cart_num')->select()
|
||||
->each(function ($item) use ($system_store, $order) {
|
||||
$find = StoreProduct::where('id', $item['product_id'])->field('store_name,unit')->find();
|
||||
$unit_name = StoreProductUnit::where('id', $find['unit'])->value('name');
|
||||
$item['system_store'] = $system_store;
|
||||
$item['subtitle'] = $item['oid'] . ' ' . convertStringToNumber($item['cart_num']) . '/' . $unit_name;
|
||||
$item['store_name'] = $find['store_name'];
|
||||
if ($order['uid']) {
|
||||
$item['address'] = $find['real_name'] . ' ' . $find['user_address'];
|
||||
} else {
|
||||
$item['address'] = '无地址';
|
||||
}
|
||||
})
|
||||
->toArray();
|
||||
$file_path = (new Beforehand())->export($data, $system_store);
|
||||
return $this->success('导出成功', ['url' => $file_path]);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -207,6 +207,7 @@ class BeforehandOrderLogic extends BaseLogic
|
||||
}
|
||||
$order = BeforehandOrder::create([
|
||||
'order_id' => getNewOrderId('YG'),
|
||||
'order_sn' => $order['order_id'],
|
||||
'admin_id' => $params['admin_id'] ?? 0,
|
||||
'uid' => $uid,
|
||||
'total_num' => $total_num,
|
||||
|
@ -21,12 +21,18 @@ class Beforehand
|
||||
'marginTop' => Converter::cmToTwip(0.2),
|
||||
'marginBottom' => Converter::cmToTwip(0),
|
||||
));
|
||||
$fontStyle = ['name' => 'Arial', 'size' => 12, 'bold' => true];
|
||||
$fontStyle = ['name' => 'Arial', 'size' => 10, '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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 日志记录
|
||||
@ -510,16 +533,16 @@ if (!function_exists('convertNumber')) {
|
||||
function onBeforeUpdate($data, $type)
|
||||
{
|
||||
$log = Log::channel($type);
|
||||
$log->info('更新前:',$data);
|
||||
$log->info('更新前:', $data);
|
||||
}
|
||||
function onAfterUpdate($data, $type)
|
||||
{
|
||||
$log = Log::channel($type);
|
||||
$log->info('更新后:' ,$data);
|
||||
$log->info('更新后:', $data);
|
||||
}
|
||||
|
||||
function channelLog($data, $type,$title='更新前')
|
||||
function channelLog($data, $type, $title = '更新前')
|
||||
{
|
||||
$log = Log::channel($type);
|
||||
$log->info($title ,$data);
|
||||
}
|
||||
$log->info($title, $data);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user