diff --git a/app/admin/controller/store_product_price/StoreProductPriceController.php b/app/admin/controller/store_product_price/StoreProductPriceController.php new file mode 100644 index 000000000..48be1bc95 --- /dev/null +++ b/app/admin/controller/store_product_price/StoreProductPriceController.php @@ -0,0 +1,104 @@ +dataLists(new StoreProductPriceLists()); + } + + + /** + * @notes 添加商品价格更改 + * @return \think\response\Json + * @author admin + * @date 2024/10/19 11:31 + */ + public function add() + { + $params = (new StoreProductPriceValidate())->post()->goCheck('add'); + $result = StoreProductPriceLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(StoreProductPriceLogic::getError()); + } + + + /** + * @notes 编辑商品价格更改 + * @return \think\response\Json + * @author admin + * @date 2024/10/19 11:31 + */ + public function edit() + { + $params = $this->request->post(); + $result = StoreProductPriceLogic::edit($params); + return $this->success('设置成功', [], 1, 1); + + } + /** + * @notes 确认改价 + * @return \think\response\Json + */ + public function enterPrice() + { + $params = $this->request->post(); + $result = StoreProductPriceLogic::enterPrice($params); + return $this->success('设置成功', [], 1, 1); + + } + + + /** + * @notes 删除商品价格更改 + * @return \think\response\Json + * @author admin + * @date 2024/10/19 11:31 + */ + public function delete() + { + $params = (new StoreProductPriceValidate())->post()->goCheck('delete'); + StoreProductPriceLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取商品价格更改详情 + * @return \think\response\Json + * @author admin + * @date 2024/10/19 11:31 + */ + public function detail() + { + $params = (new StoreProductPriceValidate())->goCheck('detail'); + $result = StoreProductPriceLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/admin/controller/warehouse_product_return/WarehouseProductReturnController.php b/app/admin/controller/warehouse_product_return/WarehouseProductReturnController.php new file mode 100644 index 000000000..f0f82c79e --- /dev/null +++ b/app/admin/controller/warehouse_product_return/WarehouseProductReturnController.php @@ -0,0 +1,93 @@ +dataLists(new WarehouseProductReturnLists()); + } + + + /** + * @notes 添加仓库商品退货处理 + * @return \think\response\Json + * @author admin + * @date 2024/10/19 16:02 + */ + public function add() + { + $params = $this->request->post(); + $params['admin_id']=$this->adminId; + $result = WarehouseProductReturnLogic::add($params); + return $this->success('退回成功', [], 1, 1); + } + + + /** + * @notes 编辑仓库商品退货处理 + * @return \think\response\Json + * @author admin + * @date 2024/10/19 16:02 + */ + public function edit() + { + $params = (new WarehouseProductReturnValidate())->post()->goCheck('edit'); + $result = WarehouseProductReturnLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(WarehouseProductReturnLogic::getError()); + } + + + /** + * @notes 删除仓库商品退货处理 + * @return \think\response\Json + * @author admin + * @date 2024/10/19 16:02 + */ + public function delete() + { + $params = (new WarehouseProductReturnValidate())->post()->goCheck('delete'); + WarehouseProductReturnLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取仓库商品退货处理详情 + * @return \think\response\Json + * @author admin + * @date 2024/10/19 16:02 + */ + public function detail() + { + $params = (new WarehouseProductReturnValidate())->goCheck('detail'); + $result = WarehouseProductReturnLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/admin/lists/store_product_price/StoreProductPriceLists.php b/app/admin/lists/store_product_price/StoreProductPriceLists.php new file mode 100644 index 000000000..f5eb769df --- /dev/null +++ b/app/admin/lists/store_product_price/StoreProductPriceLists.php @@ -0,0 +1,75 @@ + ['status'], + ]; + } + + + /** + * @notes 获取商品价格更改列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author admin + * @date 2024/10/19 11:31 + */ + public function lists(): array + { + $store_name=$this->request->get('store_name'); + if($store_name){ + $store_id=StoreProduct::where('store_name','like','%'.$store_name.'%')->column('id'); + $this->searchWhere[]=['product_id','in',$store_id]; + } + return StoreProductPrice::where($this->searchWhere) + ->field(['id','bhoid','offer_id', 'product_id', 'purchase_price', 'purchase_lv', 'purchase', 'cost_lv', 'cost', 'price_lv', 'price', 'status']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select()->each(function($item){ + $find = StoreProduct::where('id', $item['product_id'])->field('image,store_name')->find(); + $item['store_name']=$find['store_name']; + $item['image']=$find['image']; + $item['status_name']=$item['status']==0?"未设置":"已设置"; + }) + ->toArray(); + } + + + /** + * @notes 获取商品价格更改数量 + * @return int + * @author admin + * @date 2024/10/19 11:31 + */ + public function count(): int + { + return StoreProductPrice::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/admin/lists/warehouse_product_return/WarehouseProductReturnLists.php b/app/admin/lists/warehouse_product_return/WarehouseProductReturnLists.php new file mode 100644 index 000000000..4270e6508 --- /dev/null +++ b/app/admin/lists/warehouse_product_return/WarehouseProductReturnLists.php @@ -0,0 +1,71 @@ + ['warehouse_id', 'supplier_id', 'store_id', 'product_id', 'return_type'], + ]; + } + + + /** + * @notes 获取仓库商品退货处理列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author admin + * @date 2024/10/19 16:02 + */ + public function lists(): array + { + return WarehouseProductReturn::where($this->searchWhere) + ->field(['id', 'warehouse_id', 'supplier_id', 'store_id', 'product_id', 'unit', 'financial_pm', 'admin_id', 'nums', 'mark', 'price', 'total_price', 'return_type', 'status']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select()->each(function ($item){ + $find = StoreProduct::where('id', $item->product_id)->field('unit,image,store_name')->find(); + $item['unit_name']=StoreProductUnit::where('id',$find['unit'])->value('name'); + $item['store_name']=$find['store_name']; + $item['image']=$find['image']; + }) + ->toArray(); + } + + + /** + * @notes 获取仓库商品退货处理数量 + * @return int + * @author admin + * @date 2024/10/19 16:02 + */ + public function count(): int + { + return WarehouseProductReturn::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 ba046d907..a80e7d829 100644 --- a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php +++ b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php @@ -334,6 +334,7 @@ class BeforehandOrderLogic extends BaseLogic 'status' => 1, 'admin_id' => $admin_id, 'total_price' => $arr['total_price'], + 'price' => $arr['price'], 'purchase' => $arr['price'], 'oid' => $res['id'], 'code' => $res['code'], diff --git a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php index 693eb9a43..1f2d674df 100644 --- a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php +++ b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php @@ -7,6 +7,9 @@ use app\common\model\purchase_product_offer\PurchaseProductOffer; use app\common\logic\BaseLogic; use app\common\model\beforehand_order\BeforehandOrder; use app\common\model\beforehand_order_cart_info\BeforehandOrderCartInfo; +use app\common\model\dict\DictData; +use app\common\model\store_product\StoreProduct; +use app\common\model\store_product_price\StoreProductPrice; use support\exception\BusinessException; use think\facade\Db; @@ -31,9 +34,9 @@ class PurchaseProductOfferLogic extends BaseLogic { Db::startTrans(); try { - $mark=$params['mark'] ?? ''; - if($mark==''){ - $mark=BeforehandOrderCartInfo::where('bhoid',$params['order_id'])->where('product_id',$params['product_id'])->value('mark'); + $mark = $params['mark'] ?? ''; + if ($mark == '') { + $mark = BeforehandOrderCartInfo::where('bhoid', $params['order_id'])->where('product_id', $params['product_id'])->value('mark'); } PurchaseProductOffer::create([ 'order_id' => $params['order_id'], @@ -46,7 +49,7 @@ class PurchaseProductOfferLogic extends BaseLogic 'status' => 0, ]); - BeforehandOrderCartInfo::where(['bhoid'=>$params['order_id'],'product_id'=>$params['product_id']])->update(['is_buyer'=>1]); + BeforehandOrderCartInfo::where(['bhoid' => $params['order_id'], 'product_id' => $params['product_id']])->update(['is_buyer' => 1]); Db::commit(); return true; } catch (\Exception $e) { @@ -105,16 +108,47 @@ class PurchaseProductOfferLogic extends BaseLogic { Db::startTrans(); try { - $offer=PurchaseProductOffer::where(['id'=>$params['id']])->find(); + $offer = PurchaseProductOffer::where(['id' => $params['id']])->find(); $offer->save([ 'buyer_nums' => $params['buyer_nums'], 'supplier_id' => $params['supplier_id'], 'price' => $params['purchase'], - 'outbound_price' => $params['outbound_price']??0, + 'outbound_price' => $params['outbound_price'] ?? 0, 'total_price' => $params['total_price'], - 'pay_type' => $params['pay_type']??0, + 'pay_type' => $params['pay_type'] ?? 0, 'buyer_confirm' => 1, ]); + $find = StoreProductPrice::where(['offer_id' => $params['id']])->find(); + $top_cate_id = StoreProduct::where('id', $offer['product_id'])->value('top_cate_id'); + $dict_data = DictData::where('type_value', 'price_lv_' . $top_cate_id)->field('name,value')->select(); + $data = []; + $data['bhoid'] = $offer['order_id']; + $data['offer_id'] = $params['id']; + $data['product_id'] = $offer['product_id']; + $data['purchase_price'] = $params['purchase']; + $data['status'] = 0; + if ($dict_data) { + foreach ($dict_data as $k => $v) { + if ($v['name'] == 'purchase') { + $data['purchase_lv'] = $v['value']; + $lv = bcmul($v['value'], $params['purchase'], 2); + $data['purchase'] = bcadd($lv, $params['purchase'], 2); + } elseif ($v['name'] == 'cost') { + $data['cost_lv'] = $v['value']; + $lv = bcmul($v['value'], $params['purchase'], 2); + $data['cost'] = bcadd($lv, $params['purchase'], 2); + } elseif ($v['name'] == 'price') { + $data['price_lv'] = $v['value']; + $lv = bcmul($v['value'], $params['purchase'], 2); + $data['price'] = bcadd($lv, $params['purchase'], 2); + } + } + } + if ($find) { + $find->save($data); + } else { + StoreProductPrice::create($data); + } // $find=BeforehandOrderCartInfo::where(['bhoid'=>$params['bhoid'],'product_id'=>$offer['product_id']])->find(); // if($find){ // $find->purchase=$params['purchase']; @@ -140,17 +174,17 @@ class PurchaseProductOfferLogic extends BaseLogic { Db::startTrans(); try { - $data=[]; - foreach($params['product_arr'] as $k=>$v){ - $data[]=[ - 'id'=>$v['id'], - 'total_price'=>$v['total_price'], - 'price'=>$v['purchase'], - 'buyer_nums'=>$v['buyer_nums'], - 'supplier_id'=>$params['supplier_id'], - 'outbound_price'=>0, - 'pay_type'=>$v['pay_type']??0, - 'buyer_confirm'=>1, + $data = []; + foreach ($params['product_arr'] as $k => $v) { + $data[] = [ + 'id' => $v['id'], + 'total_price' => $v['total_price'], + 'price' => $v['purchase'], + 'buyer_nums' => $v['buyer_nums'], + 'supplier_id' => $params['supplier_id'], + 'outbound_price' => 0, + 'pay_type' => $v['pay_type'] ?? 0, + 'buyer_confirm' => 1, ]; } (new PurchaseProductOffer())->saveAll($data); @@ -161,7 +195,7 @@ class PurchaseProductOfferLogic extends BaseLogic throw new BusinessException($e->getMessage()); } } - + /** * @notes 库房设置验收信息 * @param array $params @@ -173,13 +207,13 @@ class PurchaseProductOfferLogic extends BaseLogic { Db::startTrans(); try { - PurchaseProductOffer::where('id',$params['id'])->update(['is_accept'=>1]); - $data=[ - 'gross_weight'=>$params['gross_weight']??0, - 'net_weight'=>$params['net_weight']??0, - 'accept_num'=>$params['accept_num']??0, + PurchaseProductOffer::where('id', $params['id'])->update(['is_accept' => 1]); + $data = [ + 'gross_weight' => $params['gross_weight'] ?? 0, + 'net_weight' => $params['net_weight'] ?? 0, + 'accept_num' => $params['accept_num'] ?? 0, ]; - BeforehandOrderCartInfo::where(['bhoid'=>$params['bhoid'],'product_id'=>$params['product_id']])->update($data); + BeforehandOrderCartInfo::where(['bhoid' => $params['bhoid'], 'product_id' => $params['product_id']])->update($data); Db::commit(); return true; } catch (\Throwable $e) { diff --git a/app/admin/logic/store_product_price/StoreProductPriceLogic.php b/app/admin/logic/store_product_price/StoreProductPriceLogic.php new file mode 100644 index 000000000..6bf17b464 --- /dev/null +++ b/app/admin/logic/store_product_price/StoreProductPriceLogic.php @@ -0,0 +1,146 @@ +getMessage()); + } + } + + + /** + * @notes 编辑商品价格更改 + * @param array $params + * @return bool + * @author admin + * @date 2024/10/19 11:31 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + $find = StoreProductPrice::where('id', $params['id'])->find(); + if ($find) { + $find->save([ + 'status' => 1, + 'purchase' => $params['purchase'], + 'cost' => $params['cost'], + 'price' => $params['price'] + ]); + StoreProduct::where('id', $find['product_id'])->update([ + 'purchase' => $find['purchase'], + 'cost' => $find['cost'], + 'vip_price' => $find['cost'], + 'price' => $find['price'] + ]); + StoreBranchProduct::where('product_id', $find['product_id'])->update([ + 'purchase' => $find['purchase'], + 'cost' => $find['cost'], + 'vip_price' => $find['cost'], + 'price' => $find['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/10/19 11:31 + */ + public static function enterPrice(array $params): bool + { + Db::startTrans(); + try { + $find = StoreProductPrice::where('id', $params['id'])->find(); + if ($find) { + $find->save([ + 'status' => 1 + ]); + StoreProduct::where('id', $find['product_id'])->update([ + 'purchase' => $find['purchase'], + 'cost' => $find['cost'], + 'vip_price' => $find['cost'], + 'price' => $find['price'] + ]); + StoreBranchProduct::where('product_id', $find['product_id'])->update([ + 'purchase' => $find['purchase'], + 'cost' => $find['cost'], + 'vip_price' => $find['cost'], + 'price' => $find['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/10/19 11:31 + */ + public static function delete(array $params): bool + { + return StoreProductPrice::destroy($params['id']); + } + + + /** + * @notes 获取商品价格更改详情 + * @param $params + * @return array + * @author admin + * @date 2024/10/19 11:31 + */ + public static function detail($params): array + { + return StoreProductPrice::findOrEmpty($params['id'])->toArray(); + } +} diff --git a/app/admin/logic/warehouse_product_return/WarehouseProductReturnLogic.php b/app/admin/logic/warehouse_product_return/WarehouseProductReturnLogic.php new file mode 100644 index 000000000..086d239f5 --- /dev/null +++ b/app/admin/logic/warehouse_product_return/WarehouseProductReturnLogic.php @@ -0,0 +1,116 @@ +find(); + if($find){ + WarehouseProductReturn::create([ + 'source_id'=>$params['id'], + 'warehouse_id'=>$find['warehouse_id'], + 'supplier_id'=>$find['supplier_id'], + 'store_id'=>$find['store_id'], + 'product_id'=>$find['product_id'], + 'unit'=>$find['unit'], + 'financial_pm'=>$params['financial_pm'], + 'admin_id'=>$params['admin_id'], + 'nums'=>$params['nums'], + 'return_type'=>$params['return_type'], + 'mark'=>$params['mark'], + 'price'=>$find['price'], + 'total_price'=>bcmul($params['nums'],$find['price'],2), + ]); + if($params['financial_pm']==1 &&$params['return_type']==1){ + WarehouseProductStorege::where(['product_id'=>$find['product_id'],'warehouse_id'=>$find['warehouse_id']])->inc('nums',$params['nums'])->update(); + }elseif($params['financial_pm']==0 &&$params['return_type']==2){ + WarehouseProductStorege::where(['product_id'=>$find['product_id'],'warehouse_id'=>$find['warehouse_id']])->dec('nums',$params['nums'])->update(); + } + } + + + Db::commit(); + return true; + } catch (\Throwable $e) { + Db::rollback(); + throw new BusinessException($e->getMessage()); + } + } + + + /** + * @notes 编辑仓库商品退货处理 + * @param array $params + * @return bool + * @author admin + * @date 2024/10/19 16:02 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + WarehouseProductReturn::where('id', $params['id'])->update([ + + ]); + + Db::commit(); + return true; + } catch (\Throwable $e) { + Db::rollback(); + throw new BusinessException($e->getMessage()); + } + } + + + /** + * @notes 删除仓库商品退货处理 + * @param array $params + * @return bool + * @author admin + * @date 2024/10/19 16:02 + */ + public static function delete(array $params): bool + { + return WarehouseProductReturn::destroy($params['id']); + } + + + /** + * @notes 获取仓库商品退货处理详情 + * @param $params + * @return array + * @author admin + * @date 2024/10/19 16:02 + */ + public static function detail($params): array + { + return WarehouseProductReturn::findOrEmpty($params['id'])->toArray(); + } +} \ No newline at end of file diff --git a/app/admin/validate/store_product_price/StoreProductPriceValidate.php b/app/admin/validate/store_product_price/StoreProductPriceValidate.php new file mode 100644 index 000000000..371427d81 --- /dev/null +++ b/app/admin/validate/store_product_price/StoreProductPriceValidate.php @@ -0,0 +1,82 @@ + 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + ]; + + + /** + * @notes 添加场景 + * @return StoreProductPriceValidate + * @author admin + * @date 2024/10/19 11:31 + */ + public function sceneAdd() + { + return $this->remove('id', true); + } + + + /** + * @notes 编辑场景 + * @return StoreProductPriceValidate + * @author admin + * @date 2024/10/19 11:31 + */ + public function sceneEdit() + { + return $this->only(['id']); + } + + + /** + * @notes 删除场景 + * @return StoreProductPriceValidate + * @author admin + * @date 2024/10/19 11:31 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return StoreProductPriceValidate + * @author admin + * @date 2024/10/19 11:31 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/admin/validate/warehouse_product_return/WarehouseProductReturnValidate.php b/app/admin/validate/warehouse_product_return/WarehouseProductReturnValidate.php new file mode 100644 index 000000000..15985c735 --- /dev/null +++ b/app/admin/validate/warehouse_product_return/WarehouseProductReturnValidate.php @@ -0,0 +1,82 @@ + 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + ]; + + + /** + * @notes 添加场景 + * @return WarehouseProductReturnValidate + * @author admin + * @date 2024/10/19 16:02 + */ + public function sceneAdd() + { + return $this->remove('id', true); + } + + + /** + * @notes 编辑场景 + * @return WarehouseProductReturnValidate + * @author admin + * @date 2024/10/19 16:02 + */ + public function sceneEdit() + { + return $this->only(['id']); + } + + + /** + * @notes 删除场景 + * @return WarehouseProductReturnValidate + * @author admin + * @date 2024/10/19 16:02 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return WarehouseProductReturnValidate + * @author admin + * @date 2024/10/19 16:02 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/common/model/store_product_price/StoreProductPrice.php b/app/common/model/store_product_price/StoreProductPrice.php new file mode 100644 index 000000000..745de6282 --- /dev/null +++ b/app/common/model/store_product_price/StoreProductPrice.php @@ -0,0 +1,22 @@ +