门店后台添加预订单

This commit is contained in:
lewis 2025-01-03 17:48:43 +08:00
parent acd6f8b402
commit 902069b4f9
3 changed files with 490 additions and 0 deletions

View File

@ -0,0 +1,310 @@
<?php
namespace app\store\controller\beforehand_order;
use app\store\controller\BaseAdminController;
use app\admin\lists\beforehand_order\BeforehandOrderLists;
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\beforehand_order_cart_info\BeforehandOrderCartInfo;
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;
use app\common\model\warehouse_order\WarehouseOrder;
use app\common\model\warehouse_product\WarehouseProduct;
use app\common\service\xlsx\Beforehand;
/**
* 预订单表控制器
* Class BeforehandOrderController
* @package app\admin\controller\beforehand_order
*/
class BeforehandOrderController extends BaseAdminController
{
/**
* @notes 获取预订单表列表
* @return \think\response\Json
* @author admin
* @date 2024/09/30 11:26
*/
public function lists()
{
$params = $this->request->get();
$params['store_id'] = $this->request->adminInfo['store_id'] ?? 0;
$this->request->setGet($params);
return $this->dataLists(new BeforehandOrderLists());
}
public function warehousing_lists()
{
return $this->dataLists(new BeforehandOrderTwoLists());
}
public function outbound_lists()
{
return $this->dataLists(new BeforehandOrderThreeLists());
}
/**
* @notes 添加预订单表
* @return \think\response\Json
* @author admin
* @date 2024/09/30 11:26
*/
public function add()
{
$params = $this->request->post();
$params['admin_id'] = $this->adminId;
$params['store_id'] = $this->request->adminInfo['store_id'] ?? 0;
$other_data = [
'nickname' => $params['nickname'] ?? '',
'phone' => $params['phone'] ?? '',
'address' => $params['address'] ?? '',
'arrival_time' => $params['arrival_time'] ?? '',
'purpose' => $params['purpose'] ?? '',
'tables' => $params['tables'] ?? '',
'days' => $params['days'] ?? '',
'chef' => $params['chef'] ?? '',
'chef_phone' => $params['chef_phone'] ?? '',
'splitting_officer' => $params['splitting_officer'] ?? '',
'merchandiser' => $params['merchandiser'] ?? '',
'distribution_personnel' => $params['distribution_personnel'] ?? '',
'transporter' => $params['transporter'] ?? '',
'system_store_name' => $params['system_store_name'] ?? '',
'regional_manager' => $params['regional_manager'] ?? '',
];
$params['other_data'] = $other_data;
$result = BeforehandOrderLogic::add($params);
return $this->success('添加成功', [], 1, 1);
}
/**
* 生成支付订单
*/
public function generateOrder()
{
$params = $this->request->post();
$result = BeforehandOrderLogic::generateOrder($params);
return $this->success('生成成功', [], 1, 1);
}
/**
* 一键出库
*/
public function createOutboundOrder()
{
$params = $this->request->post();
$params['admin_id'] = $this->adminId;
$result = BeforehandOrderLogic::createOutboundOrder($params);
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
*/
public function orderTransferAdvanceOrder()
{
$params = $this->request->post();
$params['admin_id'] = $this->adminId;
$params['mark'] = '订单转预定单';
$result = BeforehandOrderLogic::orderTransferAdvanceOrder($params);
return $this->success('转单成功', [], 1, 1);
}
/**
* @notes 编辑预订单表
* @return \think\response\Json
* @author admin
* @date 2024/09/30 11:26
*/
public function edit()
{
$params = $this->request->post();
$result = BeforehandOrderLogic::edit($params);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}
return $this->fail(BeforehandOrderLogic::getError());
}
/**
* @notes 删除预订单表
* @return \think\response\Json
* @author admin
* @date 2024/09/30 11:26
*/
public function delete()
{
$params = $this->request->post();
BeforehandOrderLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
}
/**
* @notes 获取预订单表详情
* @return \think\response\Json
* @author admin
* @date 2024/09/30 11:26
*/
public function detail()
{
$params = $this->request->get();
$result = BeforehandOrderLogic::detail($params);
return $this->data($result);
}
/**
* 导出标签
*/
public function export()
{
$params = $this->request->post();
$order = BeforehandOrder::where('id', $params['id'])->field('outbound_id,order_sn')->find();
if (!$order) {
return $this->fail('未生成出库单');
}
$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', $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();
$unit_name = StoreProductUnit::where('id', $find['unit'])->value('name');
$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);
return $this->success('导出成功', ['url' => $file_path]);
}
/**
* 导出订单
*/
public function export_order()
{
$params = $this->request->post();
$order = BeforehandOrder::where('id', $params['id'])->find();
$cart_info = BeforehandOrderCartInfo::where('bhoid', $params['id'])->select();
$file_path = (new Beforehand())->order($order, $cart_info);
return $this->success('导出成功', ['url' => $file_path]);
}
/**
* 导出清单
*/
public function export_order_list()
{
$params = $this->request->post();
$file_path = BeforehandOrderLogic::OrderList($params);
return $this->success('导出成功', ['url' => $file_path]);
}
/**
* 导出分单
*/
public function order_allocation()
{
$params = $this->request->post();
$file_path = BeforehandOrderLogic::OrderAllocation($params);
return $this->success('导出成功', ['url' => $file_path]);
}
/**
* 采购信息
*/
public function order_info()
{
$params = $this->request->post();
$file_path = BeforehandOrderLogic::OrderInfo($params);
return $this->success('导出成功', ['url' => $file_path]);
}
/**
* 导出出库
*/
public function order_outbound()
{
$params = $this->request->post();
if (!empty($params['type']) && $params['type'] == 2) {
$file_path = BeforehandOrderLogic::OrderOutbound2($params);
} else {
$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]);
}
/**
* 导出财务出库
*/
public function order_outbound_finance()
{
$params = $this->request->post();
$file_path = BeforehandOrderLogic::OrderOutboundFinance($params);
return $this->success('导出成功', ['url' => $file_path]);
}
/**
* 导出退库
*/
public function stock_return()
{
$params = $this->request->post();
$file_path = BeforehandOrderLogic::StockReturn($params);
return $this->success('导出成功', ['url' => $file_path]);
}
/**
* 导出退供应商
*/
public function return_supplier()
{
$params = $this->request->post();
$file_path = BeforehandOrderLogic::ReturnSupplier($params);
return $this->success('导出成功', ['url' => $file_path]);
}
}

View File

@ -0,0 +1,170 @@
<?php
namespace app\store\controller\beforehand_order_cart_info;
use app\store\controller\BaseAdminController;
use app\admin\lists\beforehand_order_cart_info\BeforehandOrderCartInfoLists;
use app\admin\logic\beforehand_order_cart_info\BeforehandOrderCartInfoLogic;
use app\common\model\beforehand_order_cart_info\BeforehandOrderCartInfo;
use app\common\model\purchase_product_offer\PurchaseProductOffer;
/**
* 预订单购物详情表控制器
* Class BeforehandOrderCartInfoController
* @package app\admin\controller\beforehand_order_cart_info
*/
class BeforehandOrderCartInfoController extends BaseAdminController
{
/**
* @notes 获取预订单购物详情表列表
* @return \think\response\Json
* @author admin
* @date 2024/09/30 11:32
*/
public function lists()
{
return $this->dataLists(new BeforehandOrderCartInfoLists());
}
/**
* @notes 添加预订单购物详情表
* @return \think\response\Json
* @author admin
* @date 2024/09/30 11:32
*/
public function add()
{
$params = $this->request->post();
$result = BeforehandOrderCartInfoLogic::add($params);
return $this->success('添加成功', [], 1, 1);
}
/**
* @notes 添加预订单购物详情表
* @return \think\response\Json
* @author admin
* @date 2024/09/30 11:32
*/
public function append_add()
{
$params = $this->request->post();
$result = BeforehandOrderCartInfoLogic::appendAdd($params);
return $this->success('追加成功', [], 1, 1);
}
/**
* @notes 编辑预订单购物详情无需采购
*/
public function procurement_status(){
$id=$this->request->post('id');
$res=BeforehandOrderCartInfo::where('id',$id)->find();
$find=PurchaseProductOffer::where(['product_id'=>$res['product_id'],'order_id'=>$res['bhoid']])->find();
if (empty($find)) {
$rawSql = "JSON_CONTAINS(source_order_info, '{\"source_order_id\": {$res['bhoid']}}')";
$find = PurchaseProductOffer::where(['product_id' => $res['product_id']])->whereRaw($rawSql)->find();
}
if($find){
if($find['buyer_confirm']==1){
return $this->fail('该商品已采购完成,无法更改状态');
}else{
if (!empty($find['source_order_info'])) {
$json = $find['source_order_info'];
foreach ($json as $key => $value) {
if ($value['source_order_id'] == $res['bhoid']) {
$find->need_num = $find->need_num - $value['need_num'];
unset($json[$key]);
break;
}
}
$find->source_order_info = array_values($json);
}
if ($find->need_num <= 0) {
$find->delete_time = time();
}
$find->save();
}
}
$res->save(['is_buyer'=>-1]);
if($res){
return $this->success('操作成功',[],1,1);
}else{
return $this->fail('操作失败');
}
}
/**
* @notes 一键入库
*/
public function one_click_storage(){
$params=$this->request->post();
$params['admin_id']=$this->adminId;
BeforehandOrderCartInfoLogic::oneClickStorage($params);
return $this->success('入库成功', [], 1, 1);
}
/**
* @notes 编辑预订单购物详情表
* @return \think\response\Json
* @author admin
* @date 2024/09/30 11:32
*/
public function edit()
{
$params = $this->request->post();
$params['admin_id']=$this->adminId;
$result = BeforehandOrderCartInfoLogic::edit($params);
return $this->success('编辑成功', [], 1, 1);
}
/**
* @notes 删除预订单购物详情表
* @return \think\response\Json
* @author admin
* @date 2024/09/30 11:32
*/
public function delete()
{
$params = $this->request->post();
BeforehandOrderCartInfoLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
}
/**
* @notes 获取预订单购物详情表详情
* @return \think\response\Json
* @author admin
* @date 2024/09/30 11:32
*/
public function detail()
{
$params = $this->request->get();
$result = BeforehandOrderCartInfoLogic::detail($params);
return $this->data($result);
}
/**
* 修改数量
*/
public function edit_nums()
{
$params = $this->request->post();
$result = BeforehandOrderCartInfoLogic::editNums($params);
return $this->data($result);
}
public function fix()
{
$params = $this->request->get();
BeforehandOrderCartInfoLogic::fixAcceptNum($params);
return $this->data([]);
}
}

View File

@ -4,6 +4,7 @@ namespace app\store\controller\store_product;
use app\admin\lists\store_branch_product\StoreBranchProductLists;
use app\admin\lists\store_product\StoreProductLists;
use app\common\controller\Definitions;
use app\store\controller\BaseAdminController;
use app\store\logic\store_branch_product\StoreBranchProductLogic;
@ -139,4 +140,13 @@ class StoreProductController extends BaseAdminController
{
return $this->fail('门店禁止手动增减商品库存');
}
/**
* 商品列表
*/
public function adminLists()
{
return $this->dataLists(new StoreProductLists());
}
}