Merge branch 'dev'
This commit is contained in:
commit
7adaad9365
@ -98,7 +98,17 @@ class BeforehandOrderController extends BaseAdminController
|
||||
|
||||
return $this->success('出库成功', [], 1, 1);
|
||||
}
|
||||
/**
|
||||
* 一键报损出库
|
||||
*/
|
||||
public function createOutboundDamageOrder()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$params['admin_id'] = $this->adminId;
|
||||
$result = BeforehandOrderLogic::createOutboundOrder($params);
|
||||
|
||||
return $this->success('出库成功', [], 1, 1);
|
||||
}
|
||||
/**
|
||||
* @notes 订单转预定单
|
||||
* @return \think\response\Json
|
||||
|
@ -142,4 +142,11 @@ class BeforehandOrderCartInfoController extends BaseAdminController
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
public function fix()
|
||||
{
|
||||
$params = $this->request->get();
|
||||
BeforehandOrderCartInfoLogic::fixAcceptNum($params);
|
||||
return $this->data([]);
|
||||
}
|
||||
|
||||
}
|
@ -71,6 +71,7 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa
|
||||
}
|
||||
$query = StoreProduct::where($this->searchWhere);
|
||||
if (isset($this->params['type_filter'])) {
|
||||
$query->where('product_type', '<>', 5);
|
||||
if ($this->params['type_filter'] == 0) {
|
||||
$query->where(function ($query) {
|
||||
$query->where('product_type', 6)->whereOr('is_show', 0);
|
||||
|
@ -414,6 +414,80 @@ class BeforehandOrderLogic extends BaseLogic
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 一键报损出库
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author admin
|
||||
* @date 2024/09/30 11:26
|
||||
*/
|
||||
public static function createOutboundDamageOrder(array $params): bool
|
||||
{
|
||||
$warehouse_id = $params['warehouse_id'];
|
||||
$admin_id = $params['admin_id'];
|
||||
$mark = $params['remark'] ?? '';
|
||||
$order = BeforehandOrder::where('id', $params['id'])->find();
|
||||
if (!$order) {
|
||||
throw new BusinessException('该订单不存在');
|
||||
}
|
||||
if ($order['order_type'] != 7) {
|
||||
throw new BusinessException('不是报损单,无法出库');
|
||||
}
|
||||
if ($order['outbound_id'] > 0) {
|
||||
throw new BusinessException('该订单已创建出库单');
|
||||
}
|
||||
$info = BeforehandOrderCartInfo::where('bhoid', $params['id'])->select();
|
||||
|
||||
$count = BeforehandOrderCartInfo::where('bhoid', $params['bhoid'])->where('cart_num', 0)->count('id');
|
||||
if ($count > 0) {
|
||||
throw new BusinessException('订单中有数量为0的商品,请先处理');
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
$arr = [
|
||||
'oid' => 0,
|
||||
'warehouse_id' => $warehouse_id,
|
||||
'store_id' => 0,
|
||||
'supplier_id' => 0,
|
||||
'code' => getNewOrderId('BS'),
|
||||
'admin_id' => $admin_id,
|
||||
'financial_pm' => 0,
|
||||
'batch' => 0,
|
||||
'mark' => $mark,
|
||||
];
|
||||
$arr['delivery_time'] = time();
|
||||
$res = WarehouseOrder::create($arr);
|
||||
foreach ($info as $key => $arr) {
|
||||
$data = [
|
||||
'warehouse_id' => $warehouse_id,
|
||||
'product_id' => $arr['product_id'],
|
||||
'store_id' => 0,
|
||||
'financial_pm' => 0,
|
||||
'batch' => 1,
|
||||
'order_type' => $order['order_type'],
|
||||
'nums' => $arr['cart_num'],
|
||||
'status' => 1,
|
||||
'admin_id' => $admin_id,
|
||||
'total_price' => $arr['total_price'],
|
||||
'price' => $arr['price'],
|
||||
'purchase' => $arr['purchase'],
|
||||
'oid' => $res['id'],
|
||||
'code' => $res['code'],
|
||||
'unit' => $arr['unit'] ?? 0,
|
||||
];
|
||||
WarehouseProductLogic::setOutbound($data);
|
||||
}
|
||||
$finds = WarehouseProduct::where('oid', $res['id'])->field('sum(nums) as nums,sum(total_price) as total_price')->find();
|
||||
WarehouseOrder::where('id', $res['id'])->update(['total_price' => $finds['total_price'], 'nums' => $finds['nums']]);
|
||||
$order->save(['outbound_id' => $res['id'], 'is_outbound' => 1, 'pay_price' => $finds['total_price']]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollback();
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @notes 订单转预定单
|
||||
* @param array $params
|
||||
@ -737,15 +811,17 @@ class BeforehandOrderLogic extends BaseLogic
|
||||
$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['total_price'] = bcmul($v['purchase'], $v['nums'], 2);
|
||||
$v['profit']= bcsub($v['price'], $v['purchase'], 2);
|
||||
// $total_profit = bcadd($total_profit, $v['profit'], 2);
|
||||
$v['pay_price'] = bcmul($v['purchase'], $v['nums'], 2);
|
||||
$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');
|
||||
@ -753,8 +829,9 @@ class BeforehandOrderLogic extends BaseLogic
|
||||
unset($order['other_data']);
|
||||
$find = WarehouseOrder::where('id', $order['outbound_id'])->find();
|
||||
$order['order_id'] = $find['code'];
|
||||
$order['pay_price'] = $total_price;
|
||||
// $order['total_profit'] = $total_profit;
|
||||
$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;
|
||||
}
|
||||
|
@ -283,4 +283,15 @@ class BeforehandOrderCartInfoLogic extends BaseLogic
|
||||
{
|
||||
return BeforehandOrderCartInfo::findOrEmpty($params['id'])->toArray();
|
||||
}
|
||||
|
||||
public static function fixAcceptNum($params)
|
||||
{
|
||||
$cartInfo = BeforehandOrderCartInfo::where('bhoid', $params['bhoid'])->select();
|
||||
foreach ($cartInfo as $k => $v) {
|
||||
if ($v['cart_num'] != $v['accept_num']) {
|
||||
$v->save(['accept_num' => $v['cart_num']]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -125,6 +125,7 @@ class WarehouseProductLogic extends BaseLogic
|
||||
if ($params['order_type'] != 6) {
|
||||
$storege = WarehouseProductStorege::where('warehouse_id', $params['warehouse_id'])->where('product_id', $params['product_id'])->find();
|
||||
if ($storege) {
|
||||
if($params['order_type']!=7){
|
||||
SystemStoreStorage::create([
|
||||
'store_id' => $params['store_id'],
|
||||
'admin_id' => $params['admin_id'],
|
||||
@ -135,6 +136,7 @@ class WarehouseProductLogic extends BaseLogic
|
||||
'nums' => $params['nums'],
|
||||
'status' => 0
|
||||
]);
|
||||
}
|
||||
$after_nums = bcsub($storege['nums'], $params['nums']);
|
||||
$total_price = bcmul($after_nums, $params['purchase'], 2);
|
||||
WarehouseProductStorege::update(['nums' => bcsub($storege['nums'], $params['nums']), 'total_price' => $total_price], ['id' => $storege['id']]);
|
||||
|
@ -24,13 +24,13 @@ class OrderSupplyOutbound
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
// 合并单元格A1到K1
|
||||
$sheet->mergeCells('A1:I1');
|
||||
$sheet->mergeCells('A1:K1');
|
||||
$sheet->mergeCells('D2:E2');
|
||||
$sheet->mergeCells('H2:I2');
|
||||
$sheet->mergeCells('G2:I2');
|
||||
|
||||
|
||||
$sheet->mergeCells('H3:I3');
|
||||
$sheet->mergeCells('J3:K3');
|
||||
|
||||
$sheet->setCellValue('A1', $title);
|
||||
$sheet->setCellValue('A2', '姓名:');
|
||||
@ -48,9 +48,11 @@ class OrderSupplyOutbound
|
||||
$sheet->setCellValue('C3', '单位');
|
||||
$sheet->setCellValue('D3', '数量');
|
||||
$sheet->setCellValue('E3', '出库单价');
|
||||
$sheet->setCellValue('F3', '供货价');
|
||||
$sheet->setCellValue('G3', '供货总价');
|
||||
$sheet->setCellValue('H3', '备注');
|
||||
$sheet->setCellValue('F3', '出库总价');
|
||||
$sheet->setCellValue('G3', '供货价');
|
||||
$sheet->setCellValue('H3', '供货总价');
|
||||
$sheet->setCellValue('I3', '利润');
|
||||
$sheet->setCellValue('J3', '备注');
|
||||
|
||||
// 设置默认的单元格样式
|
||||
$defaultStyle = [
|
||||
@ -69,10 +71,12 @@ class OrderSupplyOutbound
|
||||
$sheet->setCellValue('C' . ($k + 4), $v['unit_name']);
|
||||
$sheet->setCellValue('D' . ($k + 4), $v['nums']);
|
||||
$sheet->setCellValue('E' . ($k + 4), $v['price']);
|
||||
$sheet->setCellValue('F' . ($k + 4), $v['purchase']);
|
||||
$sheet->setCellValue('G' . ($k + 4), $v['total_price']);
|
||||
$sheet->mergeCells('H' . ($k + 4) . ':I' . $k + 4);
|
||||
$sheet->setCellValue('H' . ($k + 4), $v['mark']);
|
||||
$sheet->setCellValue('F' . ($k + 4), $v['total_price']);
|
||||
$sheet->setCellValue('G' . ($k + 4), $v['purchase']);
|
||||
$sheet->setCellValue('H' . ($k + 4), $v['pay_price']);
|
||||
$sheet->setCellValue('I' . ($k + 4), $v['profit']);
|
||||
$sheet->mergeCells('J' . ($k + 4) . ':K' . $k + 4);
|
||||
$sheet->setCellValue('J' . ($k + 4), $v['mark']);
|
||||
}
|
||||
|
||||
$count = count($data);
|
||||
@ -88,13 +92,15 @@ class OrderSupplyOutbound
|
||||
|
||||
$sheet->setCellValue('A' . ($count + 6),'出库合计:');
|
||||
$sheet->setCellValue('C' . ($count + 6),'出库金额:');
|
||||
$sheet->setCellValue('D' . ($count + 6),$order['pay_price']==0?$order['total_price']:$order['pay_price']);
|
||||
$sheet->setCellValue('D' . ($count + 6),$order['total_price']);
|
||||
$sheet->setCellValue('E' . ($count + 6),'实收押金:');
|
||||
$sheet->setCellValue('G' . ($count + 6),'供货总价:');
|
||||
$sheet->setCellValue('H' . ($count + 6),$order['pay_price']==0?$order['total_price']:$order['pay_price']);
|
||||
$sheet->setCellValue('H' . ($count + 6),$order['pay_price']);
|
||||
$sheet->setCellValue('I' . ($count + 6),'总利润:');
|
||||
$sheet->setCellValue('J' . ($count + 6),$order['total_profit']);
|
||||
|
||||
$sheet->setCellValue('A' . ($count + 7),'应收:');
|
||||
$sheet->setCellValue('B' . ($count + 7),$order['pay_price']==0?$order['total_price']:$order['pay_price']);
|
||||
$sheet->setCellValue('B' . ($count + 7),$order['pay_price']);
|
||||
$sheet->setCellValue('C' . ($count + 7),'应退:');
|
||||
$sheet->setCellValue('F' . ($count + 7),'门店:');
|
||||
$sheet->mergeCells('G' . ($count + 7) . ':I' . $count + 7);
|
||||
@ -136,7 +142,7 @@ class OrderSupplyOutbound
|
||||
],
|
||||
],
|
||||
];
|
||||
$sheet->getStyle('A1:I' . ($count + 9))->applyFromArray($styleArray);
|
||||
$sheet->getStyle('A1:K' . ($count + 9))->applyFromArray($styleArray);
|
||||
|
||||
// 保存文件到 public 下
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user