feat: 调整订单相关逻辑,优化门店利润计算方式,移除源类型字段source
This commit is contained in:
parent
9ab052597c
commit
2e4bee3216
@ -5,6 +5,8 @@ namespace app\admin\controller\beforehand_order;
|
||||
|
||||
use app\admin\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;
|
||||
|
||||
|
||||
@ -28,6 +30,14 @@ class BeforehandOrderController extends BaseAdminController
|
||||
return $this->dataLists(new BeforehandOrderLists());
|
||||
}
|
||||
|
||||
public function warehousing_lists()
|
||||
{
|
||||
return $this->dataLists(new BeforehandOrderTwoLists());
|
||||
}
|
||||
public function outbound_lists()
|
||||
{
|
||||
return $this->dataLists(new BeforehandOrderThreeLists());
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 添加预订单表
|
||||
@ -37,12 +47,22 @@ class BeforehandOrderController extends BaseAdminController
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params =$this->request->post();
|
||||
$params = $this->request->post();
|
||||
$params['admin_id'] = $this->adminId;
|
||||
$result = BeforehandOrderLogic::add($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);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 编辑预订单表
|
||||
@ -52,7 +72,7 @@ class BeforehandOrderController extends BaseAdminController
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params =$this->request->post();
|
||||
$params = $this->request->post();
|
||||
$result = BeforehandOrderLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
@ -69,7 +89,7 @@ class BeforehandOrderController extends BaseAdminController
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params =$this->request->post();
|
||||
$params = $this->request->post();
|
||||
BeforehandOrderLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
@ -87,6 +107,4 @@ class BeforehandOrderController extends BaseAdminController
|
||||
$result = BeforehandOrderLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -6,8 +6,7 @@ namespace app\admin\controller\beforehand_order_cart_info;
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\lists\beforehand_order_cart_info\BeforehandOrderCartInfoLists;
|
||||
use app\admin\logic\beforehand_order_cart_info\BeforehandOrderCartInfoLogic;
|
||||
use app\admin\validate\beforehand_order_cart_info\BeforehandOrderCartInfoValidate;
|
||||
|
||||
use app\common\model\beforehand_order_cart_info\BeforehandOrderCartInfo;
|
||||
|
||||
/**
|
||||
* 预订单购物详情表控制器
|
||||
@ -57,7 +56,29 @@ class BeforehandOrderCartInfoController extends BaseAdminController
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 编辑预订单购物详情无需采购
|
||||
*/
|
||||
public function procurement_status(){
|
||||
$id=$this->request->post('id');
|
||||
$res=BeforehandOrderCartInfo::where('id',$id)->update(['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
|
||||
|
@ -64,12 +64,22 @@ class PurchaseProductOfferController extends BaseAdminController
|
||||
return $this->fail('参数错误');
|
||||
break;
|
||||
}
|
||||
if (PurchaseProductOfferLogic::hasError()) {
|
||||
return $this->fail(PurchaseProductOfferLogic::getError());
|
||||
}
|
||||
return $this->success('设置成功', [], 1, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 设置采购信息
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/08/14 15:06
|
||||
*/
|
||||
public function setProcureInfo()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
PurchaseProductOfferLogic::setProcureInfo($params);
|
||||
|
||||
return $this->success('设置成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -213,7 +213,7 @@ class StoreOrderController extends BaseAdminController
|
||||
'warehouse_id' => $warehouse_id,
|
||||
'store_id' => $store_id,
|
||||
'supplier_id' => 0,
|
||||
'code' => getNewOrderId('PS'),
|
||||
'code' => getNewOrderId('CK'),
|
||||
'admin_id' => $this->adminId,
|
||||
'financial_pm' => 0,
|
||||
'batch' => 0,
|
||||
|
@ -43,7 +43,7 @@ class BeforehandOrderLists extends BaseAdminDataLists implements ListsSearchInte
|
||||
public function lists(): array
|
||||
{
|
||||
return BeforehandOrder::where($this->searchWhere)
|
||||
->field(['id', 'store_id', 'order_id', 'uid', 'total_num', 'total_price', 'pay_price', 'deduction_price','create_time', 'source', 'status', 'mark'])
|
||||
->field(['id','order_id', 'uid','total_num', 'total_price', 'pay_price', 'deduction_price','create_time', 'status', 'mark'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
|
@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\lists\beforehand_order;
|
||||
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\model\beforehand_order\BeforehandOrder;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
use app\common\model\store_product_unit\StoreProductUnit;
|
||||
use app\common\model\warehouse_product\WarehouseProduct;
|
||||
|
||||
/**
|
||||
* 预订单表列表
|
||||
* Class BeforehandOrderThreeLists
|
||||
* @package app\admin\listsbeforehand_order
|
||||
*/
|
||||
class BeforehandOrderThreeLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author admin
|
||||
* @date 2024/09/30 11:26
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取预订单表列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author admin
|
||||
* @date 2024/09/30 11:26
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$outbound_id=BeforehandOrder::where('id',$this->request->get('id'))->value('outbound_id');
|
||||
if(empty($outbound_id)){
|
||||
return [];
|
||||
}
|
||||
$this->searchWhere[]=['oid','=',$outbound_id];
|
||||
$this->searchWhere[]=['financial_pm','=',0];
|
||||
return WarehouseProduct::where($this->searchWhere)->select()
|
||||
->each(function($item){
|
||||
$find=StoreProduct::where('id',$item['product_id'])->field('store_name,image,unit')->withTrashed()->find();
|
||||
$item['store_name']=$find['store_name'];
|
||||
$item['image']=$find['image'];
|
||||
if($item['unit']==0){
|
||||
$item['unit_name']=StoreProductUnit::where('id',$find['unit'])->value('name');
|
||||
}else{
|
||||
$item['unit_name']=StoreProductUnit::where('id',$item['unit'])->value('name');
|
||||
}
|
||||
return $item;
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取预订单表数量
|
||||
* @return int
|
||||
* @author admin
|
||||
* @date 2024/09/30 11:26
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return WarehouseProduct::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
}
|
79
app/admin/lists/beforehand_order/BeforehandOrderTwoLists.php
Normal file
79
app/admin/lists/beforehand_order/BeforehandOrderTwoLists.php
Normal file
@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\lists\beforehand_order;
|
||||
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\model\beforehand_order\BeforehandOrder;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
use app\common\model\store_product_unit\StoreProductUnit;
|
||||
use app\common\model\warehouse_product\WarehouseProduct;
|
||||
|
||||
/**
|
||||
* 预订单表列表
|
||||
* Class BeforehandOrderTwoLists
|
||||
* @package app\admin\listsbeforehand_order
|
||||
*/
|
||||
class BeforehandOrderTwoLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author admin
|
||||
* @date 2024/09/30 11:26
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取预订单表列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author admin
|
||||
* @date 2024/09/30 11:26
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$warehousing_id=BeforehandOrder::where('id',$this->request->get('id'))->value('warehousing_id');
|
||||
if(empty($warehousing_id)){
|
||||
return [];
|
||||
}
|
||||
$this->searchWhere[]=['oid','=',$warehousing_id];
|
||||
$this->searchWhere[]=['financial_pm','=',1];
|
||||
return WarehouseProduct::where($this->searchWhere)->select()
|
||||
->each(function($item){
|
||||
$find=StoreProduct::where('id',$item['product_id'])->field('store_name,image,unit')->withTrashed()->find();
|
||||
$item['store_name']=$find['store_name'];
|
||||
$item['image']=$find['image'];
|
||||
if($item['unit']==0){
|
||||
$item['unit_name']=StoreProductUnit::where('id',$find['unit'])->value('name');
|
||||
}else{
|
||||
$item['unit_name']=StoreProductUnit::where('id',$item['unit'])->value('name');
|
||||
}
|
||||
return $item;
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取预订单表数量
|
||||
* @return int
|
||||
* @author admin
|
||||
* @date 2024/09/30 11:26
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return WarehouseProduct::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
}
|
@ -7,6 +7,7 @@ use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\model\beforehand_order_cart_info\BeforehandOrderCartInfo;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
use app\common\model\warehouse_product_storege\WarehouseProductStorege;
|
||||
|
||||
/**
|
||||
* 预订单购物详情表列表
|
||||
@ -43,13 +44,15 @@ class BeforehandOrderCartInfoLists extends BaseAdminDataLists implements ListsSe
|
||||
public function lists(): array
|
||||
{
|
||||
return BeforehandOrderCartInfo::where($this->searchWhere)
|
||||
->field(['id', 'bhoid', 'uid', 'product_id', 'attr_value_id', 'is_pay', 'purchase', 'price', 'total_price', 'cart_num'])
|
||||
->field(['id', 'bhoid', 'uid', 'is_buyer','buyer_uid','product_id', 'attr_value_id', 'is_pay', 'purchase', 'price', 'total_price', 'cart_num'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function($item){
|
||||
$find=StoreProduct::where('id',$item['product_id'])->field('store_name,image')->withTrashed()->find();
|
||||
$find=StoreProduct::where('id',$item['product_id'])->field('store_name,image,unit')->withTrashed()->find();
|
||||
$item['warehouse_stock']=WarehouseProductStorege::where('product_id',$item['product_id'])->value('nums')??0;
|
||||
$item['store_name']=$find['store_name'];
|
||||
$item['image']=$find['image'];
|
||||
$item['unit']=$find['unit'];
|
||||
return $item;
|
||||
})
|
||||
->toArray();
|
||||
|
@ -9,6 +9,7 @@ use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\delivery_service\DeliveryService;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
use app\common\model\store_product_unit\StoreProductUnit;
|
||||
use app\common\model\supplier\Supplier;
|
||||
|
||||
/**
|
||||
* 采购供应链商品列表
|
||||
@ -67,6 +68,11 @@ class PurchaseProductOfferLists extends BaseAdminDataLists implements ListsSearc
|
||||
$item->buyer_confirm_name='采购完成';
|
||||
}
|
||||
}
|
||||
if($item->supplier_id>0){
|
||||
$item->supplier_name=Supplier::where('id',$item->supplier_id)->value('mer_name');
|
||||
}else{
|
||||
$item->supplier_name='';
|
||||
}
|
||||
if($item->is_storage==1){
|
||||
$item->is_storage_name='已入库';
|
||||
}else{
|
||||
|
@ -2,10 +2,14 @@
|
||||
|
||||
namespace app\admin\logic\beforehand_order;
|
||||
|
||||
|
||||
use app\admin\logic\store_product\StoreProductLogic;
|
||||
use app\admin\logic\warehouse_product\WarehouseProductLogic;
|
||||
use app\common\model\beforehand_order\BeforehandOrder;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\beforehand_order_cart_info\BeforehandOrderCartInfo;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
use app\common\model\warehouse_order\WarehouseOrder;
|
||||
use app\common\model\warehouse_product\WarehouseProduct;
|
||||
use support\exception\BusinessException;
|
||||
use think\facade\Db;
|
||||
|
||||
@ -106,6 +110,74 @@ class BeforehandOrderLogic extends BaseLogic
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 一键入库
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author admin
|
||||
* @date 2024/09/30 11:26
|
||||
*/
|
||||
public static function createOutboundOrder(array $params): bool
|
||||
{
|
||||
$warehouse_id= $params['warehouse_id'];
|
||||
$store_id= $params['store_id'];
|
||||
$admin_id= $params['admin_id'];
|
||||
$delivery_time= $params['delivery_time'];
|
||||
$mark= $params['remark']??'';
|
||||
$order=BeforehandOrder::where('id', $params['bhoid'])->find();
|
||||
if(!$order){
|
||||
throw new BusinessException('该订单不存在');
|
||||
}
|
||||
if($order['outbound_id']>0){
|
||||
throw new BusinessException('该订单已创建出库单');
|
||||
}
|
||||
$info=BeforehandOrderCartInfo::where('bhoid', $params['bhoid'])->select();
|
||||
Db::startTrans();
|
||||
try {
|
||||
$arr = [
|
||||
'oid' => 0,
|
||||
'warehouse_id' => $warehouse_id,
|
||||
'store_id' => $store_id,
|
||||
'supplier_id' => 0,
|
||||
'code' => getNewOrderId('CK'),
|
||||
'admin_id' => $admin_id,
|
||||
'financial_pm' => 0,
|
||||
'batch' => 0,
|
||||
'mark' => $mark,
|
||||
];
|
||||
$arr['delivery_time'] = strtotime($delivery_time);
|
||||
$res = WarehouseOrder::create($arr);
|
||||
foreach ($info as $key => $arr) {
|
||||
$data = [
|
||||
'warehouse_id' => $warehouse_id,
|
||||
'product_id' => $arr['product_id'],
|
||||
'store_id' => $store_id,
|
||||
'financial_pm' => 0,
|
||||
'batch' => 1,
|
||||
'nums' => $arr['cart_num'],
|
||||
'status' => 1,
|
||||
'admin_id' => $admin_id,
|
||||
];
|
||||
$storeProduct = StoreProduct::where('id', $arr['product_id'])->findOrEmpty()->toArray();
|
||||
if ($arr['cart_num'] == 0) {
|
||||
StoreProductLogic::ordinary($arr, $store_id, $admin_id, $storeProduct);
|
||||
} else {
|
||||
$data['total_price'] =$arr['total_price'];
|
||||
$data['purchase'] = $storeProduct['purchase'];
|
||||
$data['oid'] = $res['id'];
|
||||
WarehouseProductLogic::add($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']]);
|
||||
}
|
||||
}
|
||||
BeforehandOrder::update(['outbound_id'=>$res['id']],['id'=>$params['bhoid']]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollback();
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 删除预订单表
|
||||
|
@ -2,10 +2,12 @@
|
||||
|
||||
namespace app\admin\logic\beforehand_order_cart_info;
|
||||
|
||||
|
||||
use app\admin\logic\warehouse_product\WarehouseProductLogic;
|
||||
use app\common\model\beforehand_order_cart_info\BeforehandOrderCartInfo;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\beforehand_order\BeforehandOrder;
|
||||
use app\common\model\purchase_product_offer\PurchaseProductOffer;
|
||||
use app\common\model\warehouse_order\WarehouseOrder;
|
||||
use support\exception\BusinessException;
|
||||
use think\facade\Db;
|
||||
|
||||
@ -58,8 +60,8 @@ class BeforehandOrderCartInfoLogic extends BaseLogic
|
||||
Db::startTrans();
|
||||
try {
|
||||
$datas = [];
|
||||
$uid=$params['uid'] ?? 0;
|
||||
$bhoid=$params['id'];
|
||||
$uid = $params['uid'] ?? 0;
|
||||
$bhoid = $params['id'];
|
||||
foreach ($params['product_arr'] as $k => $v) {
|
||||
$datas[$k]['product_id'] = $v['id'];
|
||||
$datas[$k]['uid'] = $uid;
|
||||
@ -68,12 +70,12 @@ class BeforehandOrderCartInfoLogic extends BaseLogic
|
||||
$datas[$k]['price'] = $v['purchase'];
|
||||
$datas[$k]['total_price'] = $v['total_price'];
|
||||
$datas[$k]['create_time'] = time();
|
||||
$datas[$k]['update_time'] =time();
|
||||
$datas[$k]['update_time'] = time();
|
||||
}
|
||||
(new BeforehandOrderCartInfo())->saveAll($datas);
|
||||
|
||||
$info=BeforehandOrderCartInfo::where('bhoid',$bhoid)->field('sum(cart_num) as cart_num,sum(total_price) as total_price')->find();
|
||||
BeforehandOrder::where('id',$bhoid)->update(['total_price'=>$info['total_price'],'total_num'=>$info['cart_num']]);
|
||||
$info = BeforehandOrderCartInfo::where('bhoid', $bhoid)->field('sum(cart_num) as cart_num,sum(total_price) as total_price')->find();
|
||||
BeforehandOrder::where('id', $bhoid)->update(['total_price' => $info['total_price'], 'total_num' => $info['cart_num']]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
@ -99,9 +101,9 @@ class BeforehandOrderCartInfoLogic extends BaseLogic
|
||||
'total_price' => $params['total_price'],
|
||||
'cart_num' => $params['nums'],
|
||||
]);
|
||||
$bhoid=$params['bhoid'];
|
||||
$info=BeforehandOrderCartInfo::where('bhoid',$bhoid)->field('sum(cart_num) as cart_num,sum(total_price) as total_price')->find();
|
||||
BeforehandOrder::where('id',$bhoid)->update(['total_price'=>$info['total_price'],'total_num'=>$info['cart_num']]);
|
||||
$bhoid = $params['bhoid'];
|
||||
$info = BeforehandOrderCartInfo::where('bhoid', $bhoid)->field('sum(cart_num) as cart_num,sum(total_price) as total_price')->find();
|
||||
BeforehandOrder::where('id', $bhoid)->update(['total_price' => $info['total_price'], 'total_num' => $info['cart_num']]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
@ -110,7 +112,57 @@ class BeforehandOrderCartInfoLogic extends BaseLogic
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 一键入库
|
||||
*/
|
||||
public static function oneClickStorage($params)
|
||||
{
|
||||
$count = PurchaseProductOffer::where(['order_id' => $params['bhoid'], 'is_storage' => 0, 'buyer_nums' => 0])->count('id');
|
||||
$warehousing_id = BeforehandOrder::where('id', $params['bhoid'])->value('warehousing_id');
|
||||
|
||||
if ($count > 0 || $warehousing_id > 0) {
|
||||
throw new BusinessException('请勿重复入库');
|
||||
}
|
||||
$offer_list = PurchaseProductOffer::where(['order_id' => $params['bhoid'], 'is_storage' => 0])->select();
|
||||
Db::startTrans();
|
||||
try {
|
||||
$code = getNewOrderId('RK');
|
||||
$arr = [
|
||||
'warehouse_id' => $params['warehouse_id'],
|
||||
'supplier_id' => 0,
|
||||
'admin_id' => $params['admin_id'],
|
||||
'financial_pm' => 1,
|
||||
'batch' => 0,
|
||||
'code' => $code,
|
||||
'mark' => $params['remark'] ?? '',
|
||||
'total_price' => $params['total_price'],
|
||||
'completed_amount' => $params['completed_amount'] ?? 0,
|
||||
'outstanding_amount' => $params['outstanding_amount'] ?? 0,
|
||||
];
|
||||
$res = WarehouseOrder::create($arr);
|
||||
foreach ($offer_list as $k => $v) {
|
||||
$data['admin_id'] = $params['admin_id'];
|
||||
$data['store_id'] = 0;
|
||||
$data['oid'] = $res['id'];
|
||||
$data['supplier_id'] = $v['supplier_id'];
|
||||
$data['warehouse_id'] = $params['warehouse_id'];
|
||||
$data['code'] = $code;
|
||||
$data['product_id'] = $v['product_id'];
|
||||
$data['nums'] = $v['buyer_nums'];
|
||||
$data['purchase'] = $v['price'];
|
||||
$data['total_price'] = $v['total_price'];
|
||||
$data['financial_pm'] = 1;
|
||||
WarehouseProductLogic::add($data);
|
||||
PurchaseProductOffer::where('id', $v['id'])->update(['status' => 1, 'is_storage' => 1]);
|
||||
}
|
||||
BeforehandOrder::where('id', $params['bhoid'])->update(['warehousing_id' => $res['id']]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollback();
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @notes 删除预订单购物详情表
|
||||
* @param array $params
|
||||
@ -135,4 +187,4 @@ class BeforehandOrderCartInfoLogic extends BaseLogic
|
||||
{
|
||||
return BeforehandOrderCartInfo::findOrEmpty($params['id'])->toArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ namespace app\admin\logic\purchase_product_offer;
|
||||
|
||||
use app\common\model\purchase_product_offer\PurchaseProductOffer;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\delivery_service\DeliveryService;
|
||||
use support\exception\BusinessException;
|
||||
use think\facade\Db;
|
||||
|
||||
@ -31,23 +30,15 @@ class PurchaseProductOfferLogic extends BaseLogic
|
||||
Db::startTrans();
|
||||
try {
|
||||
PurchaseProductOffer::create([
|
||||
'supplier_id' => $params['supplier_id'],
|
||||
'order_id' => $params['order_id'],
|
||||
'product_id' => $params['product_id'],
|
||||
'price' => $params['price'],
|
||||
'nums' => $params['nums'],
|
||||
'unit' => $params['unit'],
|
||||
'is_buyer' => $params['is_buyer'],
|
||||
'buyer_confirm' => $params['buyer_confirm'],
|
||||
'is_storage' => $params['is_storage'],
|
||||
'is_stream' => $params['is_stream'],
|
||||
'need_num' => $params['need_num'],
|
||||
'notes' => $params['notes'],
|
||||
'notes' => $params['notes'] ?? '',
|
||||
'buyer_id' => $params['buyer_id'],
|
||||
'status' => $params['status'],
|
||||
'stream_admin_id' => $params['stream_admin_id'],
|
||||
'stream_time' => $params['stream_time'],
|
||||
'storage_admin_id' => $params['storage_admin_id']
|
||||
'status' => 0,
|
||||
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
@ -92,7 +83,31 @@ class PurchaseProductOfferLogic extends BaseLogic
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollback();
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @notes 设置采购信息
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author admin
|
||||
* @date 2024/08/14 15:06
|
||||
*/
|
||||
public static function setProcureInfo(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
PurchaseProductOffer::update([
|
||||
'buyer_nums' => $params['buyer_nums'],
|
||||
'supplier_id' => $params['supplier_id'],
|
||||
'price' => $params['price'],
|
||||
'total_price' => $params['total_price'],
|
||||
],['id'=>$params['id']]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollback();
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
@ -103,20 +118,20 @@ class PurchaseProductOfferLogic extends BaseLogic
|
||||
*/
|
||||
public static function buyer($params)
|
||||
{
|
||||
if($params['is_buyer']==1){
|
||||
if($params['buyer_id']==''){
|
||||
if ($params['is_buyer'] == 1) {
|
||||
if ($params['buyer_id'] == '') {
|
||||
throw new BusinessException('采购人不能为空');
|
||||
}
|
||||
$data['buyer_id']=$params['buyer_id'];
|
||||
$data['buyer_nums']=$params['buyer_nums'];
|
||||
$data['buyer_id'] = $params['buyer_id'];
|
||||
$data['buyer_nums'] = $params['buyer_nums'];
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
$data['is_buyer']=$params['is_buyer'];
|
||||
$data['is_buyer'] = $params['is_buyer'];
|
||||
PurchaseProductOffer::where('id', $params['id'])->update($data);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollback();
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ class PurchaseProductOfferValidate extends BaseValidate
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->only(['supplier_id','product_id','price','nums','is_buyer','need_num']);
|
||||
return $this->only(['product_id','is_buyer','need_num']);
|
||||
}
|
||||
|
||||
|
||||
|
@ -462,9 +462,9 @@ class OrderController extends BaseApiController
|
||||
$params = (new OrderValidate())->post()->goCheck('add');
|
||||
$uid = $this->userId;
|
||||
//拆单逻辑
|
||||
$res = OrderLogic::dealRefund($uid, $params);
|
||||
$detail = StoreOrder::where('id', $params['id'])->where('refund_status', 1)->find();
|
||||
if ($detail && $res != 2) {
|
||||
// $res = OrderLogic::dealRefund($uid, $params);
|
||||
$detail = StoreOrder::where('id', $params['id'])->where('uid',$uid)->where('status','<>',2)->where('paid',1)->find();
|
||||
if ($detail) {
|
||||
$res = StoreOrderLogic::refund($detail, ['order_id' => $detail['order_id']]);
|
||||
if ($res != false) {
|
||||
return $this->success($res);
|
||||
|
Loading…
x
Reference in New Issue
Block a user