diff --git a/app/admin/controller/purchase_product_offer/PurchaseProductOfferController.php b/app/admin/controller/purchase_product_offer/PurchaseProductOfferController.php index 17070d16a..deaa23fe0 100644 --- a/app/admin/controller/purchase_product_offer/PurchaseProductOfferController.php +++ b/app/admin/controller/purchase_product_offer/PurchaseProductOfferController.php @@ -96,6 +96,12 @@ class PurchaseProductOfferController extends BaseAdminController PurchaseProductOfferLogic::setStoreroomInfo($params); return $this->success('设置成功', [], 1, 1); } + public function setStoreroomInfoTwo() + { + $params = $this->request->post(); + PurchaseProductOfferLogic::setStoreroomInfoTwo($params); + return $this->success('设置成功', [], 1, 1); + } /** * @notes 删除采购商品 * @return \think\response\Json diff --git a/app/admin/controller/store_product_group_price/StoreProductGroupPriceController.php b/app/admin/controller/store_product_group_price/StoreProductGroupPriceController.php new file mode 100644 index 000000000..6f969d650 --- /dev/null +++ b/app/admin/controller/store_product_group_price/StoreProductGroupPriceController.php @@ -0,0 +1,93 @@ +dataLists(new StoreProductGroupPriceLists()); + } + + + /** + * @notes 添加分组报价 + * @return \think\response\Json + * @author admin + * @date 2024/12/02 15:42 + */ + public function add() + { + $params = (new StoreProductGroupPriceValidate())->post()->goCheck('add'); + $result = StoreProductGroupPriceLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(StoreProductGroupPriceLogic::getError()); + } + + + /** + * @notes 编辑分组报价 + * @return \think\response\Json + * @author admin + * @date 2024/12/02 15:42 + */ + public function edit() + { + $params = $this->request->post(); + $result = StoreProductGroupPriceLogic::edit($params); + return $this->success('编辑成功', [], 1, 1); + + } + + + /** + * @notes 删除分组报价 + * @return \think\response\Json + * @author admin + * @date 2024/12/02 15:42 + */ + public function delete() + { + $params = (new StoreProductGroupPriceValidate())->post()->goCheck('delete'); + StoreProductGroupPriceLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取分组报价详情 + * @return \think\response\Json + * @author admin + * @date 2024/12/02 15:42 + */ + public function detail() + { + $params = $this->request->get(); + $result = StoreProductGroupPriceLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/admin/lists/store_product_group_price/StoreProductGroupPriceLists.php b/app/admin/lists/store_product_group_price/StoreProductGroupPriceLists.php new file mode 100644 index 000000000..db95f69cf --- /dev/null +++ b/app/admin/lists/store_product_group_price/StoreProductGroupPriceLists.php @@ -0,0 +1,70 @@ + ['product_id'], + ]; + } + + + /** + * @notes 获取分组报价列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author admin + * @date 2024/12/02 15:42 + */ + public function lists(): array + { + return StoreProduct::where($this->searchWhere)->limit($this->limitOffset, $this->limitLength) + ->field('id,store_name,purchase,cost,vip_price,price,unit') + ->order(['id' => 'desc']) + ->select()->each(function ($item) { + $item['lists'] =StoreProductGroupPrice::where('product_id',$item['id'])->field('id,group_id,price') + ->select()->each(function ($item_two){ + $item_two['group_name']=UserShip::where('id',$item_two['group_id'])->value('title'); + }); + }) + ->toArray(); + } + + + /** + * @notes 获取分组报价数量 + * @return int + * @author admin + * @date 2024/12/02 15:42 + */ + public function count(): int + { + return StoreProduct::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php index 3755bfd56..a83d437d9 100644 --- a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php +++ b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php @@ -58,6 +58,11 @@ class BeforehandOrderLogic extends BaseLogic if ($order_type == 4) { throw new BusinessException('不能添加线上订单,线上订单只能转换'); } + if($order_type==7 ||$order_type==5){ + $is_buyer=1; + }else{ + $is_buyer=-1; + } Db::startTrans(); try { $datas = []; @@ -83,6 +88,7 @@ class BeforehandOrderLogic extends BaseLogic $datas[$k]['net_weight'] = $v['net_weight'] ?? ''; $datas[$k]['cart_num'] = $v['nums']; $datas[$k]['accept_num'] = $v['nums']; + $datas[$k]['is_buyer'] = $is_buyer; $datas[$k]['price'] = $v['price']; $datas[$k]['package'] = $v['package'] ?? ''; $datas[$k]['total_price'] = $total_prices; diff --git a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php index 42e18dcb8..f26b26ddb 100644 --- a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php +++ b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php @@ -255,6 +255,18 @@ class PurchaseProductOfferLogic extends BaseLogic throw new BusinessException($e->getMessage()); } } + public static function setStoreroomInfoTwo(array $params): bool + { + Db::startTrans(); + try { + PurchaseProductOffer::where('id', $params['id'])->update(['buyer_nums' => $params['buyer_nums']]); + Db::commit(); + return true; + } catch (\Throwable $e) { + Db::rollback(); + throw new BusinessException($e->getMessage()); + } + } /** * 是否需采购 */ diff --git a/app/admin/logic/store_product_group_price/StoreProductGroupPriceLogic.php b/app/admin/logic/store_product_group_price/StoreProductGroupPriceLogic.php new file mode 100644 index 000000000..a337b3d39 --- /dev/null +++ b/app/admin/logic/store_product_group_price/StoreProductGroupPriceLogic.php @@ -0,0 +1,124 @@ +getMessage()); + } + } + + + /** + * @notes 编辑分组报价 + * @param array $params + * @return bool + * @author admin + * @date 2024/12/02 15:42 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + foreach($params as $k=>$v){ + if($v['group_price_id']==0 && !empty($v['price'])){ + StoreProductGroupPrice::create([ + 'product_id'=>$v['product_id'], + 'group_id'=>$v['id'], + 'price_type'=>$v['price_type'], + 'base_rate'=>$v['base_rate'], + 'price'=>$v['price'], + ]); + }elseif($v['group_price_id']>0 && !empty($v['price'])){ + StoreProductGroupPrice::where('id', $v['group_price_id'])->update([ + 'price_type'=>$v['price_type'], + 'base_rate'=>$v['base_rate'], + 'price'=>$v['price'], + ]); + } + } + Db::commit(); + return true; + } catch (\Throwable $e) { + Db::rollback(); + throw new BusinessException($e->getMessage()); + } + } + + + /** + * @notes 删除分组报价 + * @param array $params + * @return bool + * @author admin + * @date 2024/12/02 15:42 + */ + public static function delete(array $params): bool + { + return StoreProductGroupPrice::destroy($params['id']); + } + + + /** + * @notes 获取分组报价详情 + * @param $params + * @return array + * @author admin + * @date 2024/12/02 15:42 + */ + public static function detail($params): array + { + $arr=StoreProductGroupPrice::where('product_id',$params['product_id'])->select()->toArray(); + $purchase=StoreProduct::where('id',$params['product_id'])->value('purchase'); + $arr_two=UserShip::where('id','>',4)->select()->toArray(); + foreach ($arr_two as $k=>$v){ + $arr_two[$k]['purchase']=$purchase; + $arr_two[$k]['product_id']=$params['product_id']; + $arr_two[$k]['group_price_id']=0; + foreach ($arr as $k_two=>$v_two){ + if($v['id']==$v_two['group_id']){ + $arr_two[$k]['price_type']=$v_two['price_type']; + $arr_two[$k]['base_rate']=$v_two['base_rate']; + $arr_two[$k]['price']=$v_two['price']; + $arr_two[$k]['group_price_id']=$v_two['id']; + } + } + } + return $arr_two; + } +} \ No newline at end of file diff --git a/app/admin/logic/warehouse_product/WarehouseProductLogic.php b/app/admin/logic/warehouse_product/WarehouseProductLogic.php index 2b99da170..159125f0e 100644 --- a/app/admin/logic/warehouse_product/WarehouseProductLogic.php +++ b/app/admin/logic/warehouse_product/WarehouseProductLogic.php @@ -218,16 +218,26 @@ class WarehouseProductLogic extends BaseLogic $before_nums = $warehouseProductStorege['nums']; $after_nums = bcsub($warehouseProductStorege['nums'], $params['nums'], 2); } - WarehouseProduct::where('id', $params['id'])->update([ - 'nums' => $params['nums'], - 'supplier_id' => $params['supplier_id'], - 'pay_type' => $params['pay_type'], - 'nums' => $params['nums'], - 'purchase' => $params['purchase'], - 'before_nums' => $before_nums, - 'after_nums' => $after_nums, - 'total_price' => $params['nums'] * $params['purchase'], - ]); + if($find['financial_pm']==1){ + $datas=[ + 'nums' => $params['nums'], + 'supplier_id' => $params['supplier_id'], + 'pay_type' => $params['pay_type'], + 'purchase' => $params['purchase'], + 'before_nums' => $before_nums, + 'after_nums' => $after_nums, + 'total_price' => $params['total_price'], + ]; + }else{ + $datas=[ + 'nums' => $params['nums'], + 'price' => $params['price'], + 'before_nums' => $before_nums, + 'after_nums' => $after_nums, + 'total_price' => $params['total_price'], + ]; + } + WarehouseProduct::where('id', $params['id'])->update($datas); $finds = WarehouseProduct::where('oid', $params['oid'])->field('sum(nums) as nums,sum(total_price) as total_price')->find(); if ($finds) { WarehouseOrder::where('id', $params['oid'])->update([ diff --git a/app/admin/validate/store_product_group_price/StoreProductGroupPriceValidate.php b/app/admin/validate/store_product_group_price/StoreProductGroupPriceValidate.php new file mode 100644 index 000000000..b32c30433 --- /dev/null +++ b/app/admin/validate/store_product_group_price/StoreProductGroupPriceValidate.php @@ -0,0 +1,82 @@ + 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + ]; + + + /** + * @notes 添加场景 + * @return StoreProductGroupPriceValidate + * @author admin + * @date 2024/12/02 15:42 + */ + public function sceneAdd() + { + return $this->remove('id', true); + } + + + /** + * @notes 编辑场景 + * @return StoreProductGroupPriceValidate + * @author admin + * @date 2024/12/02 15:42 + */ + public function sceneEdit() + { + return $this->only(['id']); + } + + + /** + * @notes 删除场景 + * @return StoreProductGroupPriceValidate + * @author admin + * @date 2024/12/02 15:42 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return StoreProductGroupPriceValidate + * @author admin + * @date 2024/12/02 15:42 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/common/model/store_product_group_price/StoreProductGroupPrice.php b/app/common/model/store_product_group_price/StoreProductGroupPrice.php new file mode 100644 index 000000000..71cfe9841 --- /dev/null +++ b/app/common/model/store_product_group_price/StoreProductGroupPrice.php @@ -0,0 +1,22 @@ +