diff --git a/app/admin/controller/PurchaseFundsController.php b/app/admin/controller/PurchaseFundsController.php new file mode 100644 index 00000000..db4de0ec --- /dev/null +++ b/app/admin/controller/PurchaseFundsController.php @@ -0,0 +1,115 @@ +dataLists(new PurchaseFundsLists()); + } + + + /** + * @notes 添加 + * @author admin + * @date 2025/03/19 14:59 + */ + public function add() + { + $params = (new PurchaseFundsValidate())->post()->goCheck('add'); + $result = PurchaseFundsLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(PurchaseFundsLogic::getError()); + } + + + /** + * @notes 编辑 + * @author admin + * @date 2025/03/19 14:59 + */ + public function edit() + { + $params = (new PurchaseFundsValidate())->post()->goCheck('edit'); + $result = PurchaseFundsLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(PurchaseFundsLogic::getError()); + } + + + /** + * @notes 删除 + * @author admin + * @date 2025/03/19 14:59 + */ + public function delete() + { + $params = (new PurchaseFundsValidate())->post()->goCheck('delete'); + PurchaseFundsLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取详情 + * @author admin + * @date 2025/03/19 14:59 + */ + public function detail() + { + $params = (new PurchaseFundsValidate())->goCheck('detail'); + $result = PurchaseFundsLogic::detail($params); + return $this->data($result); + } + + /** + * @notes 审核 + * @author admin + * @date 2025/03/19 14:59 + */ + public function audit() + { + $params = (new PurchaseFundsValidate())->post()->goCheck('delete'); + $params['approve_uid'] = $this->adminId; + PurchaseFundsLogic::audit($params); + return $this->success('操作成功', [], 1, 1); + } + + /** + * @notes 补充 + * @author admin + * @date 2025/03/19 14:59 + */ + public function replenish() + { + $params = (new PurchaseFundsValidate())->post()->goCheck('delete'); + $params['approve_uid'] = $this->adminId; + PurchaseFundsLogic::replenish($params); + return $this->success('操作成功', [], 1, 1); + } + +} \ No newline at end of file diff --git a/app/admin/lists/PurchaseFundsLists.php b/app/admin/lists/PurchaseFundsLists.php new file mode 100644 index 00000000..47a1df35 --- /dev/null +++ b/app/admin/lists/PurchaseFundsLists.php @@ -0,0 +1,88 @@ + ['from_uid', 'approve_uid', 'status'], + + ]; + } + + + /** + * @notes 获取列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author admin + * @date 2025/03/19 14:59 + */ + public function lists(): array + { + $query = PurchaseFunds::where($this->searchWhere); + if (!empty($this->params['approve_uid'])) { + $userIds = Admin::where('name', 'like', '%' . $this->params['approve_uid'] . '%')->column('id'); + $query->whereIn('approve_uid', $userIds); + } + if (!empty($this->params['order'])) { + $query->order(['id' => 'asc']); + } else { + $query->order(['id' => 'desc']); + } + return $query + ->field(['id', 'from_uid', 'approve_uid', 'amount', 'current_amount', 'supply_price', 'status', 'create_time', 'audit_time']) + ->limit($this->limitOffset, $this->limitLength) + ->select() + ->each(function ($item) { + $item['from_name'] = User::where('id', $item['from_uid'])->value('nickname'); + $item['approve_name'] = empty($item['approve_uid']) ? '' : Admin::where('id', $item['approve_uid'])->value('name'); + $item['status_name'] = $item->getStatusName(); + if ($item['current_amount'] < 0) { + $item['status'] = -1; + $item['status_name'] = '已超额'; + } + $item['audit_time'] = empty($item['audit_time']) ? '' : date('Y-m-d H:i:s', $item['audit_time']); + $item['current_profit'] = ProductSourceLinkInfo::where('purchase_funds_id', $item['id'])->where('types', ProductSourceLinkInfo::TypeOrder)->sum('total_price'); + }) + ->toArray(); + } + + + /** + * @notes 获取数量 + * @return int + * @author admin + * @date 2025/03/19 14:59 + */ + public function count(): int + { + return PurchaseFunds::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/admin/logic/PurchaseFundsLogic.php b/app/admin/logic/PurchaseFundsLogic.php new file mode 100644 index 00000000..8e4ae225 --- /dev/null +++ b/app/admin/logic/PurchaseFundsLogic.php @@ -0,0 +1,163 @@ + $params['from_uid'], + 'amount' => $params['amount'], + ]); + + Db::commit(); + return true; + } catch (\Throwable $e) { + Db::rollback(); + throw new BusinessException($e->getMessage()); + } + } + + + /** + * @notes 编辑 + * @param array $params + * @return bool + * @author admin + * @date 2025/03/19 14:59 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + PurchaseFunds::where('id', $params['id'])->update([ + 'from_uid' => $params['from_uid'], + 'approve_uid' => $params['approve_uid'], + 'amount' => $params['amount'], + 'status' => $params['status'], + ]); + + Db::commit(); + return true; + } catch (\Throwable $e) { + Db::rollback(); + throw new BusinessException($e->getMessage()); + } + } + + + /** + * @notes 删除 + * @param array $params + * @return bool + * @author admin + * @date 2025/03/19 14:59 + */ + public static function delete(array $params): bool + { + return PurchaseFunds::destroy($params['id']); + } + + + /** + * @notes 获取详情 + * @param $params + * @return array + * @author admin + * @date 2025/03/19 14:59 + */ + public static function detail($params): array + { + return PurchaseFunds::findOrEmpty($params['id'])->toArray(); + } + + /** + * @notes 审核 + * @param array $params + * @return bool + * @author admin + * @date 2025/03/19 14:59 + */ + public static function audit(array $params): bool + { + $purchaseFunds = PurchaseFunds::findOrEmpty($params['id']); + if ($purchaseFunds->isEmpty()) { + throw new BusinessException('数据不存在'); + } + Db::startTrans(); + try { + $attrs = [ + 'approve_uid' => $params['approve_uid'], + 'status' => $params['status'], + 'audit_time' => time(), + ]; + if ($params['status'] == 1) { + $attrs['current_amount'] = $purchaseFunds['amount']; + } + PurchaseFunds::where('id', $params['id'])->update($attrs); + if ($params['status'] == 1) { + DeliveryServiceLogic::addPurchaseFunds($purchaseFunds['from_uid'], $purchaseFunds['amount']); + } + + Db::commit(); + return true; + } catch (\Throwable $e) { + Db::rollback(); + throw new BusinessException($e->getMessage()); + } + } + + /** + * @notes 补充 + * @param array $params + * @return bool + * @author admin + * @date 2025/03/19 14:59 + */ + public static function replenish(array $params): bool + { + $purchaseFunds = PurchaseFunds::findOrEmpty($params['id']); + if ($purchaseFunds->isEmpty()) { + throw new BusinessException('数据不存在'); + } + Db::startTrans(); + try { + PurchaseFunds::where('id', $params['id'])->update([ + 'amount' => Db::raw('amount+' . $params['replenish_amount']), + 'current_amount' => Db::raw('current_amount+' . $params['replenish_amount']), + ]); + DeliveryServiceLogic::addPurchaseFunds($purchaseFunds['from_uid'], $params['replenish_amount']); + + Db::commit(); + return true; + } catch (\Throwable $e) { + Db::rollback(); + throw new BusinessException($e->getMessage()); + } + } +} \ No newline at end of file diff --git a/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php b/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php index f2447f96..7da69ea5 100644 --- a/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php +++ b/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php @@ -450,8 +450,9 @@ class BeforehandOrderCartInfoLogic extends BaseLogic $data['price'] = $data['purchase']; $data['manufacture'] = $purchaseProductOffer['manufacture'] > 0 ? date('Y-m-d H:i:s', $purchaseProductOffer['manufacture']) : ''; $data['expiration_date'] = $purchaseProductOffer['expiration_date'] > 0 ? date('Y-m-d H:i:s', $purchaseProductOffer['expiration_date']) : ''; + $data['purchase_funds_id'] = $params['purchase_funds_id']; if ($data['nums'] > 0) { - WarehouseProductLogic::add($data, 1, $params['admin_id']); + $warehouseProduct = WarehouseProductLogic::add($data, 1, $params['admin_id']); } $offerUpdate = ['price' => $purchaseProductOffer['price'], 'status' => 1, 'is_storage' => 1, 'warehouse_num' => $params['warehouse_num']]; $offerResult = PurchaseProductOffer::where('id', $purchaseProductOffer['id'])->where('is_storage', 0)->update($offerUpdate); @@ -472,7 +473,7 @@ class BeforehandOrderCartInfoLogic extends BaseLogic $product = StoreProduct::where('id', $purchaseProductOffer['product_id'])->withTrashed()->field('id,store_name,top_cate_id,two_cate_id,cate_id')->find(); if (!in_array($beforehandOrder['order_type'], [6, 9])) { - PurchaseProductOfferLogic::setProductPrice($purchaseProductOffer, $product, $params['warehouse_id']); + PurchaseProductOfferLogic::setProductPrice($purchaseProductOffer, $product, $params['warehouse_id'], $warehouseProduct->id ?? 0); } Db::commit(); return true; diff --git a/app/admin/logic/delivery_service/DeliveryServiceLogic.php b/app/admin/logic/delivery_service/DeliveryServiceLogic.php index 99f67168..69231458 100644 --- a/app/admin/logic/delivery_service/DeliveryServiceLogic.php +++ b/app/admin/logic/delivery_service/DeliveryServiceLogic.php @@ -96,4 +96,24 @@ class DeliveryServiceLogic extends BaseLogic { return DeliveryService::findOrEmpty($params['id'])->toArray(); } + + public static function addPurchaseFunds($uid, $amount) + { + $model = DeliveryService::findOrEmpty($uid); + if (!$model->isEmpty()) { + $model->purchase_funds_total = bcadd($model->purchase_funds_total, $amount, 2); + $model->current_purchase_funds = bcadd($model->current_purchase_funds, $amount, 2); + $model->save(); + } + } + + public static function subPurchaseFunds($uid, $amount) + { + $model = DeliveryService::findOrEmpty($uid); + if (!$model->isEmpty()) { + $model->current_purchase_funds = bcsub($model->current_purchase_funds, $amount, 2); + $model->save(); + } + } + } \ No newline at end of file diff --git a/app/admin/logic/product_source_link/ProductSourceLinkLogic.php b/app/admin/logic/product_source_link/ProductSourceLinkLogic.php index c89c1f85..c8630376 100644 --- a/app/admin/logic/product_source_link/ProductSourceLinkLogic.php +++ b/app/admin/logic/product_source_link/ProductSourceLinkLogic.php @@ -4,6 +4,7 @@ namespace app\admin\logic\product_source_link; use app\admin\logic\product_source_link_info\ProductSourceLinkInfoLogic; +use app\admin\logic\purchase_product_offer\PurchaseProductOfferLogic; use app\common\model\inventory_transfer\InventoryTransfer; use app\common\model\product_source_link\ProductSourceLink; use app\common\logic\BaseLogic; @@ -42,7 +43,7 @@ class ProductSourceLinkLogic extends BaseLogic $model->warehouse_id = $info['warehouse_id']; $model->save(); } - ProductSourceLinkInfoLogic::add([ + $attrs = [ 'oid' => $model['id'], 'product_id' => $offer['product_id'], 'warehouse_id' => $info['warehouse_id'], @@ -52,7 +53,16 @@ class ProductSourceLinkLogic extends BaseLogic 'link_id' => $info['link_id'], 'price' => $offer['price'], 'total_price' => $offer['total_price'], - ]); + 'purchase_funds_id' => $offer['purchase_funds_id'] ?? 0, + ]; + if ($attrs['types'] == ProductSourceLinkInfo::TypeIn) { + // 商品入库,记录采购总价和供货总价 + $priceRate = PurchaseProductOfferLogic::getProductPriceRate(['id' => $offer['product_id']]); + $attrs['purchase_price'] = $offer['total_price']; + $rate = bcdiv($priceRate['supply_rate'], 100, 2); + $attrs['supply_price'] = bcmul($offer['total_price'], $rate, 2); + } + ProductSourceLinkInfoLogic::add($attrs); } return true; } @@ -166,7 +176,7 @@ class ProductSourceLinkLogic extends BaseLogic 'update_time' => $time, ]; } else { - $insert[] = [ + $insertItem = [ 'product_id' => $item['product_id'], 'warehouse_id' => $info['warehouse_id'] ?? 0, 'store_id' => $info['store_id'] ?? 0, @@ -178,9 +188,21 @@ class ProductSourceLinkLogic extends BaseLogic 'current_nums' => $needNum, 'price' => $item['price'], 'total_price' => bcmul($item['price'], $needNum, 2), + 'purchase_funds_id' => $item['purchase_funds_id'], 'create_time' => !empty($info['create_time']) ? $info['create_time'] : $time, 'update_time' => $time, ]; + if ($insertItem['types'] == ProductSourceLinkInfo::TypeOut) { + // 商品出库,价格为供货价,总价为供货总价 + $insertItem['price'] = bcdiv($item['supply_price'], $item['nums'], 2); + $insertItem['total_price'] = bcmul($insertItem['price'], $insertItem['nums'], 2); + } elseif ($insertItem['types'] == ProductSourceLinkInfo::TypeOrder) { + // 商品订单出库,价格为销售价,总价为销售总价 + $insertItem['price'] = $info['product']['price']; + $insertItem['total_price'] = bcmul($insertItem['price'], $insertItem['nums'], 2); + $insertItem['supply_price'] = bcmul($info['product']['supply_price'], $insertItem['nums'], 2); + } + $insert[] = $insertItem; } return [$update, $insert]; } @@ -215,6 +237,7 @@ class ProductSourceLinkLogic extends BaseLogic 'from_id' => $item['id'], 'price' => $item['price'], 'total_price' => $item['total_price'], + 'purchase_funds_id' => $item['purchase_funds_id'], ]); } } diff --git a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php index e4141796..4e0930f7 100644 --- a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php +++ b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php @@ -384,12 +384,14 @@ class PurchaseProductOfferLogic extends BaseLogic * 设置商品价格 * @param $params * @param $product + * @param $warehouseId + * @param $warehouseProductId * @return void * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ - public static function setProductPrice($params, $product, $warehouseId = 0) + public static function setProductPrice($params, $product, $warehouseId = 0, $warehouseProductId = 0) { $priceConfig = []; $data = [ @@ -401,6 +403,7 @@ class PurchaseProductOfferLogic extends BaseLogic 'update_time' => time(), 'status' => 0, 'warehouse_id' => $warehouseId, + 'warehouse_product_id' => $warehouseProductId, ]; $productPriceRate = self::getProductPriceRate($product); if (!empty($productPriceRate)) { @@ -423,8 +426,8 @@ class PurchaseProductOfferLogic extends BaseLogic if (empty($list)) { $list = [ 'supply_rate' => 110, - 'merchant_rate' => 106, - 'vip_rate' => 110, + 'merchant_rate' => 103, + 'vip_rate' => 115, 'price_rate' => 120, ]; } diff --git a/app/admin/logic/store_product_price/StoreProductPriceLogic.php b/app/admin/logic/store_product_price/StoreProductPriceLogic.php index a93c4bc2..cf7b6817 100644 --- a/app/admin/logic/store_product_price/StoreProductPriceLogic.php +++ b/app/admin/logic/store_product_price/StoreProductPriceLogic.php @@ -4,6 +4,7 @@ namespace app\admin\logic\store_product_price; use app\admin\service\ProductPriceService; +use app\common\model\product_source_link_info\ProductSourceLinkInfo; use app\common\model\store_product_group_price\StoreProductGroupPrice; use app\common\model\store_product_price\StoreProductPrice; use app\common\logic\BaseLogic; @@ -58,51 +59,41 @@ class StoreProductPriceLogic extends BaseLogic { Db::startTrans(); try { - $postData = $params; $find = StoreProductPrice::where('id', $params['id'])->find(); if ($find) { - $changePurchase = false; + $productPriceListAttrs = []; if ($find['purchase_lv'] != $params['purchase_lv']) { - $params = self::updateProductPriceList2($find['product_id'], 'supply_rate', $params['purchase_lv'], $params, 'purchase', $find['purchase_price']); - $changePurchase = true; - } - if ($changePurchase) { - $params['cost'] = bcmul($params['purchase'], $params['cost_lv'], 2); - $params['vip_price'] = bcmul($params['purchase'], $params['vip_lv'], 2); - $params['price'] = bcmul($params['purchase'], $params['price_lv'], 2); + $productPriceListAttrs['supply_rate'] = $params['purchase_lv'] * 100; } if ($find['cost_lv'] != $params['cost_lv']) { - $params = self::updateProductPriceList2($find['product_id'], 'merchant_rate', $params['cost_lv'], $params, 'cost', $params['purchase']); + $productPriceListAttrs['merchant_rate'] = $params['cost_lv'] * 100; } if ($find['vip_lv'] != $params['vip_lv']) { - $params = self::updateProductPriceList2($find['product_id'], 'vip_rate', $params['vip_lv'], $params, 'vip_price', $params['purchase']); + $productPriceListAttrs['vip_rate'] = $params['vip_lv'] * 100; } if ($find['price_lv'] != $params['price_lv']) { - $params = self::updateProductPriceList2($find['product_id'], 'price_rate', $params['price_lv'], $params, 'price', $params['purchase']); + $productPriceListAttrs['price_rate'] = $params['price_lv'] * 100; + } + if (!empty($productPriceListAttrs)) { + $id = StoreProductPriceList::where('product_id', $find['product_id'])->value('id'); + if (empty($id)) { + $productPriceListAttrs = array_merge($productPriceListAttrs, ['product_id' => $find['product_id']]); + StoreProductPriceList::create($productPriceListAttrs); + } else { + StoreProductPriceList::where('id', $id)->update($productPriceListAttrs); + } } - - $params['supply_rate'] = bcmul($params['purchase_lv'], 100); - $params['merchant_rate'] = bcmul($params['cost_lv'], 100); - $params['vip_rate'] = bcmul($params['vip_lv'], 100); - $params['price_rate'] = bcmul($params['price_lv'], 100); - $productService = new ProductPriceService(); - $priceArray = $productService->setProductPrice($find['purchase_price'], $params); - // 计算出的价格与提交价格不同时,以提交价格为准 - $priceArray['purchase'] = $postData['purchase'] != $priceArray['pxurchase'] ? $postData['purchase'] : $priceArray['purchase']; - $priceArray['cost'] = $postData['cost'] != $priceArray['cost'] ? $postData['cost'] : $priceArray['cost']; - $priceArray['vip_price'] = $postData['vip_price'] != $priceArray['vip_price'] ? $postData['vip_price'] : $priceArray['vip_price']; - $priceArray['price'] = $postData['price'] != $priceArray['price'] ? $postData['price'] : $priceArray['price']; $find->save([ 'status' => 1, - 'purchase' => $priceArray['purchase'], - 'purchase_lv' => $priceArray['purchase_lv'], - 'cost' => $priceArray['cost'], - 'cost_lv' => $priceArray['cost_lv'], - 'vip_price' => $priceArray['vip_price'], - 'vip_lv' => $priceArray['vip_lv'], - 'price' => $priceArray['price'], - 'price_lv' => $priceArray['price_lv'], + 'purchase' => $params['purchase'], + 'purchase_lv' => $params['purchase_lv'], + 'cost' => $params['cost'], + 'cost_lv' => $params['cost_lv'], + 'vip_price' => $params['vip_price'], + 'vip_lv' => $params['vip_lv'], + 'price' => $params['price'], + 'price_lv' => $params['price_lv'], 'price_config' => $params['price_config'], ]); StoreProduct::where('id', $find['product_id'])->update([ @@ -119,6 +110,15 @@ class StoreProductPriceLogic extends BaseLogic 'price' => $find['vip_price'], 'ot_price' => $find['price'] ]); + + $productSourceLinkInfo = ProductSourceLinkInfo::where('product_id', $find['product_id']) + ->where('link_id', $find['warehouse_product_id']) + ->where('types', ProductSourceLinkInfo::TypeIn) + ->find(); + if (!empty($productSourceLinkInfo)) { + ProductSourceLinkInfo::where('id', $productSourceLinkInfo['id'])->update(['supply_price' => bcmul($find['purchase'], $productSourceLinkInfo['nums'], 2)]); + } + } Db::commit(); return true; @@ -128,7 +128,7 @@ class StoreProductPriceLogic extends BaseLogic } } - public static function updateProductPriceList2($productId, $field, $rate, $params, $index, $basePrice) + public static function updateProductPriceList2($productId, $field, $rate) { $id = StoreProductPriceList::where('product_id', $productId)->value('id'); if (empty($id)) { @@ -139,8 +139,6 @@ class StoreProductPriceLogic extends BaseLogic } else { StoreProductPriceList::where('id', $id)->update([$field => $rate * 100]); } - $params[$index] = bcmul($basePrice, $rate, 2); - return $params; } public static function updateProductPriceList($productId, $priceType, $rate, $params, $field, $basePrice) diff --git a/app/admin/logic/warehouse_order/WarehouseOrderLogic.php b/app/admin/logic/warehouse_order/WarehouseOrderLogic.php index 5b1d9e91..0c842c6c 100644 --- a/app/admin/logic/warehouse_order/WarehouseOrderLogic.php +++ b/app/admin/logic/warehouse_order/WarehouseOrderLogic.php @@ -173,6 +173,9 @@ class WarehouseOrderLogic extends BaseLogic * @date 2024/08/20 10:50 */ public static function update_edit($data){ + if (!empty($data['create_time'])) { + $data['create_time'] = strtotime($data['create_time']); + } $res=WarehouseOrder::update($data); if($res){ return true; diff --git a/app/admin/logic/warehouse_product/WarehouseProductLogic.php b/app/admin/logic/warehouse_product/WarehouseProductLogic.php index 3518ad79..6fde2a0a 100644 --- a/app/admin/logic/warehouse_product/WarehouseProductLogic.php +++ b/app/admin/logic/warehouse_product/WarehouseProductLogic.php @@ -8,6 +8,7 @@ use app\admin\logic\store_branch_product\StoreBranchProductLogic; use app\admin\logic\store_product\StoreProductLogic; use app\common\model\beforehand_order\BeforehandOrder; use app\common\model\product_source_link_info\ProductSourceLinkInfo; +use app\common\model\PurchaseFunds; use app\common\model\warehouse_product\WarehouseProduct; use app\common\logic\BaseLogic; use app\common\model\purchase_product_offer\PurchaseProductOffer; @@ -118,6 +119,10 @@ class WarehouseProductLogic extends BaseLogic $res = WarehouseProduct::create($data); SqlChannelLog('WarehouseProduct', $res['id'], $params['nums'], $params['financial_pm'] == 1 ? 1 : -1, Request()->url(),$admin_id); + if (!empty($params['purchase_funds_id'])) { + PurchaseFunds::where('id', $params['purchase_funds_id'])->dec('current_amount', $params['total_price'])->save(); + } + ProductSourceLinkLogic::add([ 'purchase_product_offer' => [$params], 'types' => ProductSourceLinkInfo::TypeIn, @@ -142,20 +147,6 @@ 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['store_id'] == 3 && in_array($params['order_type'], [1, 2, 3, 4, 8])) || in_array($params['order_type'], [1, 4])) { - // SystemStoreStorage::create([ - // 'store_id' => $params['store_id'], - // 'admin_id' => $params['admin_id'], - // 'order_type' => $params['order_type'], - // 'staff_id' => 0, - // 'type' => 1, - // 'product_id' => $params['product_id'], - // 'nums' => $params['nums'], - // 'outbound_id' => $params['oid'] ?? 0, - // 'warehouse_id' =>1, - // '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']]); diff --git a/app/admin/validate/PurchaseFundsValidate.php b/app/admin/validate/PurchaseFundsValidate.php new file mode 100644 index 00000000..dc438fcb --- /dev/null +++ b/app/admin/validate/PurchaseFundsValidate.php @@ -0,0 +1,82 @@ + 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + ]; + + + /** + * @notes 添加场景 + * @return PurchaseFundsValidate + * @author admin + * @date 2025/03/19 14:59 + */ + public function sceneAdd() + { + return $this->remove('id', true); + } + + + /** + * @notes 编辑场景 + * @return PurchaseFundsValidate + * @author admin + * @date 2025/03/19 14:59 + */ + public function sceneEdit() + { + return $this->only(['id']); + } + + + /** + * @notes 删除场景 + * @return PurchaseFundsValidate + * @author admin + * @date 2025/03/19 14:59 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return PurchaseFundsValidate + * @author admin + * @date 2025/03/19 14:59 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 47d62a75..ccf69a25 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -645,6 +645,8 @@ class PayNotifyLogic extends BaseLogic 'product' => [ 'product_id' => $v['product_id'], 'nums' => $v['cart_num'], + 'price' => $branchProduct['price'], + 'supply_price' => $branchProduct['purchase'], ], 'is_store_order' => true, 'store_id' => $v['store_id'], diff --git a/app/common/model/PurchaseFunds.php b/app/common/model/PurchaseFunds.php new file mode 100644 index 00000000..26e66f17 --- /dev/null +++ b/app/common/model/PurchaseFunds.php @@ -0,0 +1,35 @@ +status == self::StatusWait) { + return '待审核'; + } else if ($this->status == self::StatusApproved) { + return '通过'; + } else { + return '拒绝'; + } + } + +} \ No newline at end of file