From 51f5725afabdb73a6f109a0ea2c659c3fbdb349d Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Thu, 22 Aug 2024 17:28:24 +0800 Subject: [PATCH 1/6] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E4=BB=93?= =?UTF-8?q?=E5=BA=93=E5=BA=93=E5=AD=98=E7=BB=9F=E8=AE=A1=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/WorkbenchController.php | 5 +- .../lists/statistics/StoreProductLists.php | 145 ++++++++++++++++++ app/admin/logic/statistic/WarehouseLogic.php | 30 +--- .../model/store_product/StoreProduct.php | 1 - 4 files changed, 153 insertions(+), 28 deletions(-) create mode 100644 app/admin/lists/statistics/StoreProductLists.php diff --git a/app/admin/controller/WorkbenchController.php b/app/admin/controller/WorkbenchController.php index 0ea9348bc..afbd03c59 100644 --- a/app/admin/controller/WorkbenchController.php +++ b/app/admin/controller/WorkbenchController.php @@ -14,6 +14,7 @@ namespace app\admin\controller; +use app\admin\lists\statistics\StoreProductLists; use app\admin\lists\store_order_cart_info\StoreOrderCartInfoGroupLists; use app\admin\lists\store_order_cart_info\StoreOrderCartInfoGroupMonthLists; use app\admin\logic\statistic\ProductStatisticLogic; @@ -287,7 +288,7 @@ class WorkbenchController extends BaseAdminController */ public function warehouse_list() { - $data=WarehouseLogic::warehouse_list(); - return $this->data($data); + return $this->dataLists(new StoreProductLists()); + } } diff --git a/app/admin/lists/statistics/StoreProductLists.php b/app/admin/lists/statistics/StoreProductLists.php new file mode 100644 index 000000000..d5f04386e --- /dev/null +++ b/app/admin/lists/statistics/StoreProductLists.php @@ -0,0 +1,145 @@ + ['cate_id', 'is_show', 'bar_code'], + '<=' => ['stock'], + '%like%' => ['store_name'], + ]; + } + + + /** + * @notes 获取商品列表列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2024/05/31 10:53 + */ + public function lists(): array + { + $class_all = $this->request->get('class_all'); + if ($class_all) { + //查3级别的 + $arr = Cate::where('pid', $class_all)->column('id'); + if ($arr) { + $arr2 = Cate::where('pid', 'in', $arr)->column('id'); + $this->searchWhere[] = ['cate_id', 'in', array_merge($arr, $arr2)]; + } else { + $this->searchWhere[] = ['cate_id', '=', $class_all]; + } + } + $list = StoreProduct::where($this->searchWhere) + ->alias('p') // 为 StoreProduct 表设置别名 + ->limit($this->limitOffset, $this->limitLength) + + ->field('p.id, p.store_name, p.image, + (SELECT SUM(c.cart_num) FROM `la_store_order_cart_info` c WHERE c.product_id=p.id AND c.is_pay=1) AS sales, + (SELECT SUM(b.stock) FROM `la_store_branch_product` b WHERE b.product_id=p.id) AS store_stock, + (SELECT SUM(w.nums) FROM `la_warehouse_product_storege` w WHERE w.product_id=p.id) AS warehouse_stock, + (SELECT SUM(wp.total_price) FROM `la_warehouse_product` wp WHERE wp.product_id=p.id) AS total_purchase, + (SELECT SUM(wp.total_price) FROM `la_warehouse_product` wp WHERE wp.product_id=p.id AND wp.is_pay=1) AS total_completed_amount, + (SELECT SUM(wp.total_price) FROM `la_warehouse_product` wp WHERE wp.product_id=p.id AND wp.is_pay=0) AS total_outstanding_amount') + ->select() + ->each(function ($item) { + // 计算总库存 + $item->total_stock = $item->store_stock + $item->warehouse_stock; + $item->total_completed_amount=$item->total_completed_amount??0; + $item->warehouse_stock=$item->warehouse_stock??0; + $item->total_outstanding_amount=$item->total_outstanding_amount??0; + $item->total_purchase=$item->total_purchase??0; + }) + ->toArray(); + return $list; + } + + + /** + * @notes 获取商品列表数量 + * @return int + * @author likeadmin + * @date 2024/05/31 10:53 + */ + public function count(): int + { + $export=$this->request->get('export'); + if($export==1){ + $class_all = $this->request->get('class_all'); + if ($class_all) { + //查3级别的 + $arr = Cate::where('pid', $class_all)->column('id'); + if ($arr) { + $arr2 = Cate::where('pid', 'in', $arr)->column('id'); + $this->searchWhere[] = ['cate_id', 'in', array_merge($arr, $arr2)]; + } else { + $this->searchWhere[] = ['cate_id', '=', $class_all]; + } + } + } + return StoreProduct::where($this->searchWhere)->count(); + } + + /** + * @notes 导出文件名 + * @return string + * @author 乔峰 + * @date 2022/11/24 16:17 + */ + public function setFileName(): string + { + return '商品列表'; + } + + + /** + * @notes 导出字段 + * @return string[] + * @author 乔峰 + * @date 2022/11/24 16:17 + */ + public function setExcelFields(): array + { + $data = [ + 'store_name' => '商品名称', + 'cate_name'=>'分类', + 'unit_name'=>'单位', + 'stock' => '库存', + 'purchase' => '采购价', + 'cost' => '商户', + 'price' => '零售', + ]; + return $data; + } +} diff --git a/app/admin/logic/statistic/WarehouseLogic.php b/app/admin/logic/statistic/WarehouseLogic.php index a7ff4ec4e..d2ba2d0ac 100644 --- a/app/admin/logic/statistic/WarehouseLogic.php +++ b/app/admin/logic/statistic/WarehouseLogic.php @@ -47,12 +47,12 @@ class WarehouseLogic extends BaseLogic 'value' => [], 'type' => 1, ]; - $store_stock_1 = StoreBranchProduct::where('stock','>',0)->sum('stock'); - $store_stock_2 = WarehouseProductStorege::where('nums','>',0)->sum('nums'); + $store_stock_1 = StoreBranchProduct::where('stock', '>', 0)->sum('stock'); + $store_stock_2 = WarehouseProductStorege::where('nums', '>', 0)->sum('nums'); $topData[] = [ 'title' => '总商品库存', 'desc' => '平台统计商品总库存、含门店仓库', - 'total_money' => bcadd($store_stock_1,$store_stock_2,2), + 'total_money' => bcadd($store_stock_1, $store_stock_2, 2), 'cash_title' => 0, 'value' => [], 'type' => 1, @@ -68,7 +68,7 @@ class WarehouseLogic extends BaseLogic $topData[] = [ 'title' => '海吉星仓库库存', 'desc' => '平台统计海吉星仓库库存', - 'total_money' => WarehouseProductStorege::where('warehouse_id',1)->sum('nums'), + 'total_money' => WarehouseProductStorege::where('warehouse_id', 1)->sum('nums'), 'cash_title' => 0, 'value' => [], 'type' => 1, @@ -76,7 +76,7 @@ class WarehouseLogic extends BaseLogic $topData[] = [ 'title' => '泸县集采集配库存', 'desc' => '平台统计泸县集采集配库存', - 'total_money' => WarehouseProductStorege::where('warehouse_id',2)->sum('nums'), + 'total_money' => WarehouseProductStorege::where('warehouse_id', 2)->sum('nums'), 'cash_title' => 0, 'value' => [], 'type' => 1, @@ -103,24 +103,4 @@ class WarehouseLogic extends BaseLogic return $data; } - public static function warehouse_list() - { - $list = StoreProduct::where('is_show', 1) - ->field('id,store_name,image') - ->select()->each(function ($item) { - // $item->sales = StoreOrderCartInfo::where('product_id', $item['id'])->where('is_pay',1)->sum('cart_num'); - // $store_stock = StoreBranchProduct::where('product_id', $item['id'])->sum('stock'); - // $warehouse_stock = WarehouseProductStorege::where('product_id', $item['id'])->sum('nums'); - // $item->store_stock=$store_stock; - // $item->warehouse_stock=$warehouse_stock; - // $item->total_stock=$store_stock+$warehouse_stock; - // $item->total_purchase=WarehouseProduct::where('product_id', $item['id'])->sum('total_price'); - // $item->total_completed_amount=WarehouseProduct::where('product_id', $item['id'])->where('is_pay',1)->sum('total_price'); - // $item->total_outstanding_amount=WarehouseProduct::where('product_id', $item['id'])->where('is_pay',0)->sum('total_price'); - // sum(branch_product.stock) as store_stock,sum(w_p.total_price) as total_purchase, - })->toArray(); - return $list; - } - - } diff --git a/app/common/model/store_product/StoreProduct.php b/app/common/model/store_product/StoreProduct.php index 871b88caf..dc810fdda 100644 --- a/app/common/model/store_product/StoreProduct.php +++ b/app/common/model/store_product/StoreProduct.php @@ -5,7 +5,6 @@ namespace app\common\model\store_product; use app\common\model\BaseModel; use app\common\model\store_category\StoreCategory; -use app\common\model\store_order_cart_info\StoreOrderCartInfo; use app\common\model\store_product_unit\StoreProductUnit; use think\model\concern\SoftDelete; From 375d91504593e0e39caf4a75e3fe087ce742c600 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Thu, 22 Aug 2024 17:43:51 +0800 Subject: [PATCH 2/6] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E9=80=BB=E8=BE=91=E5=92=8C=E6=94=AF=E4=BB=98=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E9=80=BB=E8=BE=91=E4=BB=A5=E4=BC=98=E5=8C=96=E5=BA=93?= =?UTF-8?q?=E5=AD=98=E5=92=8C=E8=B4=A2=E5=8A=A1=E6=B5=81=E6=B0=B4=E7=9A=84?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/order/OrderLogic.php | 19 ++----------------- app/common/logic/PayNotifyLogic.php | 24 +++++++++++++++++++++--- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index 548a82138..1569872b7 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -340,32 +340,17 @@ class OrderLogic extends BaseLogic $order = StoreOrder::create($_order); $goods_list = $orderInfo['cart_list']; - $updateData = []; - $updateDataTwo = []; + foreach ($goods_list as $k => $v) { $goods_list[$k]['oid'] = $order->id; $goods_list[$k]['uid'] = $uid; $goods_list[$k]['cart_id'] = implode(',', $cartId); $goods_list[$k]['delivery_id'] = $params['store_id']; //商家id - - $id = StoreBranchProduct::where('product_id', $v['product_id'])->where('store_id', $params['store_id'])->value('id'); - if ($id) { - $updateData[] = [ - 'id' => $id, - 'sales' => ['inc', $v['cart_num']], - 'stock' => ['dec', $v['cart_num']], - ]; - } - $updateDataTwo[] = [ - 'id' => $v['product_id'], - 'sales' => ['inc', $v['cart_num']] - ]; } (new StoreOrderCartInfo())->saveAll($goods_list); $where = ['is_pay' => 0]; Cart::whereIn('id', $cartId)->where($where)->update(['is_pay' => 1]); - (new StoreBranchProduct())->saveAll($updateData); - (new StoreProduct())->saveAll($updateDataTwo); + Db::commit(); return $order; } catch (\Exception $e) { diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 681993271..3b1a47d38 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -19,6 +19,7 @@ use app\common\model\store_cash_finance_flow\StoreCashFinanceFlow; use app\common\model\store_finance_flow\StoreFinanceFlow; use app\common\model\store_order\StoreOrder; use app\common\model\store_order_cart_info\StoreOrderCartInfo; +use app\common\model\store_product\StoreProduct; use app\common\model\store_product_log\StoreProductLog; use app\common\model\system_store\SystemStore; use app\common\model\user\User; @@ -324,7 +325,7 @@ class PayNotifyLogic extends BaseLogic StoreOrderCartInfo::where('oid', $order['id'])->update(['status' => OrderEnum::REFUND_STATUS_FINISH]); //处理财务流水退还 - (new StoreFinanceFlowLogic())->store_finance_back($orderSn,$order['store_id']); + (new StoreFinanceFlowLogic())->store_finance_back($orderSn, $order['store_id']); if (in_array($order['pay_type'], [PayEnum::BALANCE_PAY, PayEnum::PURCHASE_FUNDS])) { if ($order['pay_type'] == PayEnum::BALANCE_PAY) { //用户余额支付 $user = User::where('id', $order['uid'])->findOrEmpty(); @@ -358,7 +359,6 @@ class PayNotifyLogic extends BaseLogic $capitalFlowDao->userIncome('user_order_refund', 'system_back', $order['id'], $order['pay_price'], '', 1); self::addStock($order['id']); //微信 return true; - // self::afterPay($order,$extra['transaction_id']); } /** @@ -393,7 +393,7 @@ class PayNotifyLogic extends BaseLogic //增加数量 self::addStock($order['id']); StoreOrderCartInfo::where('oid', $order['id'])->update(['status' => OrderEnum::REFUND_STATUS_FINISH]); - (new StoreFinanceFlowLogic())->store_finance_back($orderSn,$order['store_id']); + (new StoreFinanceFlowLogic())->store_finance_back($orderSn, $order['store_id']); return true; } @@ -572,7 +572,25 @@ class PayNotifyLogic extends BaseLogic */ public static function afterPay($order, $transaction_id = 0) { + $updateData = []; + $updateDataTwo = []; StoreOrderCartInfo::where('oid', $order['id'])->update(['is_pay' => 1]); + $arr = StoreOrderCartInfo::where('oid', $order['id'])->field('id,oid,product_id,store_id,cart_num')->select(); + foreach ($arr as $k => $v) { + $updateData[] = [ + 'store_id' => $v['store_id'], + 'product_id' => $v['product_id'], + 'sales' => ['inc', $v['cart_num']], + 'stock' => ['dec', $v['cart_num']], + ]; + + $updateDataTwo[] = [ + 'id' => $v['product_id'], + 'sales' => ['inc', $v['cart_num']] + ]; + } + (new StoreBranchProduct())->saveAll($updateData); + (new StoreProduct())->saveAll($updateDataTwo); $financeLogic = new StoreFinanceFlowLogic(); $off_activity = Config::where('name', 'off_activity')->value('value'); $village_uid = 0; From cf1d6db00a313529b30533ccd0cef00ff9169d3b Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Thu, 22 Aug 2024 22:08:59 +0800 Subject: [PATCH 3/6] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E5=92=8C=E4=BB=93=E5=BA=93=E9=80=BB=E8=BE=91=EF=BC=8C?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=BA=93=E5=AD=98=E5=92=8C=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../store_order/StoreOrderController.php | 3 +- .../logic/store_order/StoreOrderLogic.php | 54 ++++++++++++++++--- process/Task.php | 3 +- 3 files changed, 52 insertions(+), 8 deletions(-) diff --git a/app/admin/controller/store_order/StoreOrderController.php b/app/admin/controller/store_order/StoreOrderController.php index 34977798c..092c9bb9a 100644 --- a/app/admin/controller/store_order/StoreOrderController.php +++ b/app/admin/controller/store_order/StoreOrderController.php @@ -56,11 +56,12 @@ class StoreOrderController extends BaseAdminController public function add() { $params = $this->request->post(); + $params['admin_id'] = $this->adminId; $result = StoreOrderLogic::add($params); if (StoreOrderLogic::hasError()) { return $this->fail(StoreOrderLogic::getError()); } else { - return $this->success('添加成功,请在30分钟内支付', [], 1, 1); + return $this->success('添加成功,该订单不会因为系统时间而删除', [], 1, 1); } } diff --git a/app/admin/logic/store_order/StoreOrderLogic.php b/app/admin/logic/store_order/StoreOrderLogic.php index 14af044d1..27a2bef83 100644 --- a/app/admin/logic/store_order/StoreOrderLogic.php +++ b/app/admin/logic/store_order/StoreOrderLogic.php @@ -2,14 +2,20 @@ namespace app\admin\logic\store_order; +use app\admin\logic\store_product\StoreProductLogic; +use app\admin\logic\warehouse_product\WarehouseProductLogic; use app\api\logic\order\CartLogic; use app\api\logic\order\OrderLogic; use app\common\enum\PayEnum; use app\common\model\store_order\StoreOrder; use app\common\logic\BaseLogic; use app\common\logic\PayNotifyLogic; +use app\common\model\store_branch_product\StoreBranchProduct; use app\common\model\store_order_cart_info\StoreOrderCartInfo; +use app\common\model\store_product\StoreProduct; use app\common\model\user\User; +use app\common\model\warehouse_order\WarehouseOrder; +use app\common\model\warehouse_product\WarehouseProduct; use think\facade\Db; @@ -35,20 +41,56 @@ class StoreOrderLogic extends BaseLogic foreach ($params['product_arr'] as $k => $v) { $v['uid'] = $params['user_id']; $v['store_id'] = $params['store_id']; - $v['product_id'] = $v['id']; $v['cart_num'] = $v['stock']; + StoreBranchProduct::where('id',$v['id'])->update(['price'=>$v['price'],'vip_price'=>$v['price'],'cost'=>$v['price'],'purchase'=>$v['purchase']]); + unset($v['id']); $res = CartLogic::add($v); $cartId[] = $res['id']; } $user = User::where('id', $params['user_id'])->find(); - $params['shipping_type'] = 2; + $params['shipping_type']=4; $params['pay_type'] = 7; $order = OrderLogic::createOrder($cartId, null, $user, $params); - if ($order != false) { - return true; - } else { - OrderLogic::getError(); + if (OrderLogic::hasError()) { + StoreOrderLogic::setError(OrderLogic::getError()); return false; + } else { + $arr = [ + 'warehouse_id' => 1, + 'store_id' => $params['store_id'], + 'supplier_id' => 0, + 'code' => getNewOrderId('PS'), + 'admin_id' => $params['admin_id'], + 'financial_pm' => 0, + 'batch' => 0, + 'mark' => $mark ?? "", + ]; + $arr['delivery_time'] = time(); + $res = WarehouseOrder::create($arr); + foreach ($params['product_arr'] as $k => $v) { + $data = [ + 'warehouse_id' => 1, + 'product_id' => $v['product_id'], + 'store_id' => $params['store_id'], + 'financial_pm' => 0, + 'batch' => 1, + 'nums' => $arr['stock'], + 'status' => 1, + 'admin_id' => $params['admin_id'], + ]; + $storeProduct = StoreProduct::where('id', $arr['id'])->findOrEmpty()->toArray(); + if ($arr['stock'] == 0) { + StoreProductLogic::ordinary($arr, $params['store_id'], $params['admin_id'], $storeProduct); + } else { + $data['total_price'] = bcmul($arr['stock'], $storeProduct['purchase'], 2); + $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']]); + } + } + return true; } } diff --git a/process/Task.php b/process/Task.php index a08bae717..df537e071 100644 --- a/process/Task.php +++ b/process/Task.php @@ -23,7 +23,8 @@ class Task new Crontab('0 */10 * * * *', function () { $where = ['paid' => 0]; $where[] = ['create_time', '<', time() - 600]; // 10分钟前创建的订单 - // 删除10分钟未支付的订单 + $where[] = ['shipping_type', '<>',4]; + // 删除10分钟未支付的订单 $oid = StoreOrder::where($where)->column('id'); // 删除时间设置为当前时间,即删除 if ($oid) { StoreOrder::where('id', 'in', $oid)->update(['delete_time' => time()]); From a0814641c83b54430744e3606f24e1a4fb6675d4 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 23 Aug 2024 13:46:25 +0800 Subject: [PATCH 4/6] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E4=BA=86Workbenc?= =?UTF-8?q?hController=E5=92=8C=E7=9B=B8=E5=85=B3=E7=9A=84=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B=E7=B1=BB=EF=BC=8C=E4=BC=98=E5=8C=96=E4=BA=86=E4=BB=93?= =?UTF-8?q?=E5=BA=93=E7=BB=9F=E8=AE=A1=E5=8A=9F=E8=83=BD=EF=BC=8C=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E4=BA=86=E9=97=A8=E5=BA=97=E4=BB=93=E5=BA=93=E6=80=BB?= =?UTF-8?q?=E5=BA=93=E5=AD=98=E7=9A=84=E7=BB=9F=E8=AE=A1=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/WorkbenchController.php | 107 ++++++++++-------- .../lists/statistics/StoreProductLists.php | 12 +- app/admin/logic/statistic/WarehouseLogic.php | 32 ++++++ .../logic/store_order/StoreOrderLogic.php | 18 ++- .../WarehouseProductLogic.php | 10 +- app/api/controller/order/OrderController.php | 12 +- app/api/logic/order/OrderLogic.php | 1 + 7 files changed, 123 insertions(+), 69 deletions(-) diff --git a/app/admin/controller/WorkbenchController.php b/app/admin/controller/WorkbenchController.php index afbd03c59..047444343 100644 --- a/app/admin/controller/WorkbenchController.php +++ b/app/admin/controller/WorkbenchController.php @@ -52,13 +52,13 @@ class WorkbenchController extends BaseAdminController public function store_index() { $params = $this->request->get(); - if(!isset($params['store_id']) ||$params['store_id']==''){ - $params['store_id'] =0; + if (!isset($params['store_id']) || $params['store_id'] == '') { + $params['store_id'] = 0; } - if(!isset($params['start_time']) ||$params['start_time']==''){ - $time=explode('-', $this->getDay('')); - $params['start_time'] =$time[0]; - $params['end_time'] =$time[1]; + if (!isset($params['start_time']) || $params['start_time'] == '') { + $time = explode('-', $this->getDay('')); + $params['start_time'] = $time[0]; + $params['end_time'] = $time[1]; } $result = LogicWorkbenchLogic::index($params); @@ -102,24 +102,24 @@ class WorkbenchController extends BaseAdminController public function get_trend() { $dates = []; - $date=$this->request->get('date',''); - $days=31; - if($date){ - $arr=explode('-', $date); - if($arr[0]==$arr[1]){ - $date = new DateTime($arr[0]); - $dates[] = $date->format("Y-m-d"); - }else{ - $datetime_start = new DateTime($arr[0]); - $datetime_end = new DateTime($arr[1]); - $days = $datetime_start->diff($datetime_end)->days; - for ($i = 0; $i <= $days; $i++) { - $date = new DateTime($datetime_start->format('Y-m-d')); - $date->modify('+' . $i . ' days'); - $dates[] = $date->format('Y-m-d'); + $date = $this->request->get('date', ''); + $days = 31; + if ($date) { + $arr = explode('-', $date); + if ($arr[0] == $arr[1]) { + $date = new DateTime($arr[0]); + $dates[] = $date->format("Y-m-d"); + } else { + $datetime_start = new DateTime($arr[0]); + $datetime_end = new DateTime($arr[1]); + $days = $datetime_start->diff($datetime_end)->days; + for ($i = 0; $i <= $days; $i++) { + $date = new DateTime($datetime_start->format('Y-m-d')); + $date->modify('+' . $i . ' days'); + $dates[] = $date->format('Y-m-d'); + } } - } - }else{ + } else { $today = new DateTime(); $thirtyDaysAgo = new DateTime($today->format('Y-m-d')); $thirtyDaysAgo->modify('-30 days'); @@ -166,10 +166,10 @@ class WorkbenchController extends BaseAdminController */ public function get_product_ranking() { - $date=$this->request->get('date',''); + $date = $this->request->get('date', ''); $where['create_time'] = $this->getDay($date); - $data=(new ProductStatisticLogic())->get_product_ranking($where); - return $this->success('',$data); + $data = (new ProductStatisticLogic())->get_product_ranking($where); + return $this->success('', $data); } //-------------------------------用户统计---------------------------------------// @@ -179,13 +179,13 @@ class WorkbenchController extends BaseAdminController */ public function get_user_basic() { - $date=$this->request->get('date',''); - $store_id=$this->request->get('store_id'); + $date = $this->request->get('date', ''); + $store_id = $this->request->get('store_id'); $where['create_time'] = $this->getDay($date); - if($store_id){ + if ($store_id) { $where['store_id'] = $store_id; } - $data=(new UserStatisticLogic())->getBasic($where); + $data = (new UserStatisticLogic())->getBasic($where); return $this->data($data); } @@ -194,13 +194,13 @@ class WorkbenchController extends BaseAdminController */ public function get_user_trend() { - $date=$this->request->get('date',''); - $store_id=$this->request->get('store_id'); + $date = $this->request->get('date', ''); + $store_id = $this->request->get('store_id'); $where['create_time'] = $this->getDay($date); - if($store_id){ + if ($store_id) { $where['store_id'] = $store_id; } - $data=(new UserStatisticLogic())->getTrend($where); + $data = (new UserStatisticLogic())->getTrend($where); return $this->data($data); } @@ -208,7 +208,7 @@ class WorkbenchController extends BaseAdminController //当日订单金额 public function top_trade() { - $logic=(new TradeStatisticLogic()); + $logic = (new TradeStatisticLogic()); $leftToday = $logic->getTopLeftTrade(['create_time' => 'today']); $leftyestoday = $logic->getTopLeftTrade(['create_time' => 'yestoday']); $rightOne = $logic->getTopRightOneTrade(); @@ -231,25 +231,27 @@ class WorkbenchController extends BaseAdminController //交易趋势 public function bottom_trade() { - $date=$this->request->get('date',''); - $data=(new TradeStatisticLogic())->getBottomTrade(['data'=>$this->getDay($date)]); + $date = $this->request->get('date', ''); + $data = (new TradeStatisticLogic())->getBottomTrade(['data' => $this->getDay($date)]); return $this->data($data); } /** * 实时商品统计 */ - public function product_order(){ + public function product_order() + { return $this->dataLists(new StoreOrderCartInfoGroupLists()); } /** * 月销售商品统计 */ - public function product_month_order(){ + public function product_month_order() + { return $this->dataLists(new StoreOrderCartInfoGroupMonthLists()); } - /** + /** * 格式化时间 * @param $time * @return string @@ -261,9 +263,9 @@ class WorkbenchController extends BaseAdminController if (!$startTime && !$endTime) { return date("Y/m/d", strtotime("-30 days", time())) . '-' . date("Y/m/d", time()); } else { - if($startTime==$endTime){ - return $startTime . '-' . $endTime.' 23:59:59'; - }else{ + if ($startTime == $endTime) { + return $startTime . '-' . $endTime . ' 23:59:59'; + } else { return $startTime . '-' . $endTime; } } @@ -271,24 +273,35 @@ class WorkbenchController extends BaseAdminController return date("Y/m/d", strtotime("-30 days", time())) . '-' . date("Y/m/d", time()); } } + //-------------------------------统计仓库---------------------------------------// /** - * 统计仓库 + * 统计仓库头 * @return array */ public function total_warehouse() { - $data=WarehouseLogic::total_warehouse(); + $data = WarehouseLogic::total_warehouse(); return $this->data($data); } - /** - * 统计仓库 + /** + * 统计仓库列表 * @return array */ public function warehouse_list() { return $this->dataLists(new StoreProductLists()); + } + /** + * 统计门店仓库总库存 + * @return array + */ + public function total_warehouse_list() + { + $parmas=$this->request->get(); + $data =WarehouseLogic::total_warehouse_list($parmas,$parmas['type']??1); + return $this->data($data); } } diff --git a/app/admin/lists/statistics/StoreProductLists.php b/app/admin/lists/statistics/StoreProductLists.php index d5f04386e..06350317a 100644 --- a/app/admin/lists/statistics/StoreProductLists.php +++ b/app/admin/lists/statistics/StoreProductLists.php @@ -66,12 +66,12 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa ->limit($this->limitOffset, $this->limitLength) ->field('p.id, p.store_name, p.image, - (SELECT SUM(c.cart_num) FROM `la_store_order_cart_info` c WHERE c.product_id=p.id AND c.is_pay=1) AS sales, - (SELECT SUM(b.stock) FROM `la_store_branch_product` b WHERE b.product_id=p.id) AS store_stock, - (SELECT SUM(w.nums) FROM `la_warehouse_product_storege` w WHERE w.product_id=p.id) AS warehouse_stock, - (SELECT SUM(wp.total_price) FROM `la_warehouse_product` wp WHERE wp.product_id=p.id) AS total_purchase, - (SELECT SUM(wp.total_price) FROM `la_warehouse_product` wp WHERE wp.product_id=p.id AND wp.is_pay=1) AS total_completed_amount, - (SELECT SUM(wp.total_price) FROM `la_warehouse_product` wp WHERE wp.product_id=p.id AND wp.is_pay=0) AS total_outstanding_amount') + (SELECT SUM(c.cart_num) FROM `la_store_order_cart_info` c WHERE c.product_id=p.id AND c.is_pay=1 AND c.delete_time IS NULL) AS sales, + (SELECT SUM(b.stock) FROM `la_store_branch_product` b WHERE b.product_id=p.id AND b.delete_time IS NULL) AS store_stock, + (SELECT SUM(w.nums) FROM `la_warehouse_product_storege` w WHERE w.product_id=p.id AND w.delete_time IS NULL) AS warehouse_stock, + (SELECT SUM(wp.total_price) FROM `la_warehouse_product` wp WHERE wp.product_id=p.id AND wp.delete_time IS NULL) AS total_purchase, + (SELECT SUM(wp.total_price) FROM `la_warehouse_product` wp WHERE wp.product_id=p.id AND wp.is_pay=1 AND wp.delete_time IS NULL) AS total_completed_amount, + (SELECT SUM(wp.total_price) FROM `la_warehouse_product` wp WHERE wp.product_id=p.id AND wp.is_pay=0 AND wp.delete_time IS NULL) AS total_outstanding_amount') ->select() ->each(function ($item) { // 计算总库存 diff --git a/app/admin/logic/statistic/WarehouseLogic.php b/app/admin/logic/statistic/WarehouseLogic.php index d2ba2d0ac..db036f8c1 100644 --- a/app/admin/logic/statistic/WarehouseLogic.php +++ b/app/admin/logic/statistic/WarehouseLogic.php @@ -7,9 +7,11 @@ use app\common\model\store_branch_product\StoreBranchProduct; use app\common\model\store_order\StoreOrder; use app\common\model\store_order_cart_info\StoreOrderCartInfo; use app\common\model\store_product\StoreProduct; +use app\common\model\system_store\SystemStore; use app\common\model\user\User; use app\common\model\user\UserVisit; use app\common\model\user_recharge\UserRecharge; +use app\common\model\warehouse\Warehouse; use app\common\model\warehouse_order\WarehouseOrder; use app\common\model\warehouse_product\WarehouseProduct; use app\common\model\warehouse_product_storege\WarehouseProductStorege; @@ -103,4 +105,34 @@ class WarehouseLogic extends BaseLogic return $data; } + /** + * 统计门店仓库总库存 + * @return array + */ + public static function total_warehouse_list($parmas,$type=1) { + if($type==1){ + $list=StoreBranchProduct::where('stock','>',0)->where('product_id',$parmas['product_id']) + ->select()->each(function ($item){ + $item->system_store = SystemStore::where('id',$item['store_id'])->value('name'); + $item->total_price = bcmul($item->purchase,$item->stock,2); + }); + $count=StoreBranchProduct::where('stock','>',0)->where('product_id',$parmas['product_id']) + ->count(); + }else{ + $list=WarehouseProductStorege::where('nums','>',0)->where('product_id',$parmas['product_id'])->select()->each(function ($item){ + $item->warehouse_name = Warehouse::where('id',$item['warehouse_id'])->value('name'); + $find = StoreProduct::where('id',$item['product_id'])->find(); + $item->store_name=$find['store_name']; + $item->image=$find['image']; + $item->purchase=$find['purchase']; + if($find['purchase']>0 && $item->nums>0){ + $item->total_price = bcmul($find['purchase'],$item->nums,2); + }else{ + $item->total_price = 0; + } + }); + $count=WarehouseProductStorege::where('nums','>',0)->where('product_id',$parmas['product_id'])->count(); + } + return ['lists'=>$list,'count'=>$count]; + } } diff --git a/app/admin/logic/store_order/StoreOrderLogic.php b/app/admin/logic/store_order/StoreOrderLogic.php index 27a2bef83..79c5405e7 100644 --- a/app/admin/logic/store_order/StoreOrderLogic.php +++ b/app/admin/logic/store_order/StoreOrderLogic.php @@ -42,7 +42,7 @@ class StoreOrderLogic extends BaseLogic $v['uid'] = $params['user_id']; $v['store_id'] = $params['store_id']; $v['cart_num'] = $v['stock']; - StoreBranchProduct::where('id',$v['id'])->update(['price'=>$v['price'],'vip_price'=>$v['price'],'cost'=>$v['price'],'purchase'=>$v['purchase']]); + StoreBranchProduct::where('id',$v['id'])->update(['price'=>$v['price'],'vip_price'=>$v['price'],'cost'=>$v['price'],'purchase'=>$v['price']]); unset($v['id']); $res = CartLogic::add($v); $cartId[] = $res['id']; @@ -56,7 +56,7 @@ class StoreOrderLogic extends BaseLogic return false; } else { $arr = [ - 'warehouse_id' => 1, + 'warehouse_id' => $params['warehouse_id']??-1, 'store_id' => $params['store_id'], 'supplier_id' => 0, 'code' => getNewOrderId('PS'), @@ -69,23 +69,21 @@ class StoreOrderLogic extends BaseLogic $res = WarehouseOrder::create($arr); foreach ($params['product_arr'] as $k => $v) { $data = [ - 'warehouse_id' => 1, + 'warehouse_id' => $params['warehouse_id']??-1, 'product_id' => $v['product_id'], 'store_id' => $params['store_id'], 'financial_pm' => 0, 'batch' => 1, - 'nums' => $arr['stock'], + 'nums' => $v['stock'], 'status' => 1, 'admin_id' => $params['admin_id'], ]; - $storeProduct = StoreProduct::where('id', $arr['id'])->findOrEmpty()->toArray(); - if ($arr['stock'] == 0) { - StoreProductLogic::ordinary($arr, $params['store_id'], $params['admin_id'], $storeProduct); - } else { - $data['total_price'] = bcmul($arr['stock'], $storeProduct['purchase'], 2); + $storeProduct = StoreBranchProduct::where('id', $v['id'])->findOrEmpty()->toArray(); + if ($v['stock']>0) { + $data['total_price'] = bcmul($v['stock'], $storeProduct['purchase'], 2); $data['purchase'] = $storeProduct['purchase']; $data['oid'] = $res['id']; - WarehouseProductLogic::add($data); + WarehouseProductLogic::add($data,0); $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']]); } diff --git a/app/admin/logic/warehouse_product/WarehouseProductLogic.php b/app/admin/logic/warehouse_product/WarehouseProductLogic.php index 5e1f61526..b063802b3 100644 --- a/app/admin/logic/warehouse_product/WarehouseProductLogic.php +++ b/app/admin/logic/warehouse_product/WarehouseProductLogic.php @@ -32,7 +32,7 @@ class WarehouseProductLogic extends BaseLogic * @author admin * @date 2024/07/31 16:55 */ - public static function add(array $params) + public static function add(array $params,$type=1) { // Db::startTrans(); try { @@ -55,12 +55,14 @@ class WarehouseProductLogic extends BaseLogic } $storeBranchProduct=StoreProductLogic::ordinary(['id'=>$params['product_id']],$params['store_id'], $params['admin_id'], $storeProduct); } - if ($params['nums'] > 0) { + if ($params['nums'] > 0&&$type==1) { StoreBranchProduct::where('id', $storeBranchProduct['id'])->inc('stock',$params['nums'])->update(); - } + } } else { $after_nums = $storege['nums'] + $params['nums']; - WarehouseProductStorege::where('id', $storege['id'])->inc('nums', $params['nums'])->update(); + if($type==1){ + WarehouseProductStorege::where('id', $storege['id'])->inc('nums', $params['nums'])->update(); + } } $before_nums = $storege['nums']; } else { diff --git a/app/api/controller/order/OrderController.php b/app/api/controller/order/OrderController.php index 15211d3d2..76b788483 100644 --- a/app/api/controller/order/OrderController.php +++ b/app/api/controller/order/OrderController.php @@ -23,6 +23,8 @@ use support\Log; use think\facade\Db; use Webman\RedisQueue\Redis; +use function DI\get; + class OrderController extends BaseApiController { public $notNeedLogin = ['refund_reason']; @@ -134,7 +136,7 @@ class OrderController extends BaseApiController public function createOrder() { $cartId = (array)$this->request->post('cart_id', []); - $store_id = (array)$this->request->post('store_id', 0); + $store_id =$this->request->post('store_id', 0); $pay_type = (int)$this->request->post('pay_type'); $addressId = (int)$this->request->post('address_id'); $auth_code = $this->request->post('auth_code'); //微信支付条码 @@ -145,7 +147,13 @@ class OrderController extends BaseApiController if (count($cartId) > 100) { return $this->fail('购物车商品不能超过100个'); } - + $store_arr=getenv('NO_STORE_ID'); + if($store_arr){ + $store_arr=explode(',',$store_arr); + if (in_array($store_id,$store_arr)){ + return $this->fail('该门店不支持下单'); + } + } $user = User::where('id', $this->userId)->find(); if ($pay_type == PayEnum::PURCHASE_FUNDS || $pay_type == PayEnum::BALANCE_PAY) { if (!isset($params['password'])) { diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index 1569872b7..522dc374a 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -257,6 +257,7 @@ class OrderLogic extends BaseLogic $alert = '当前时间超过配送截止时间16:00,若下单,物品送达时间为' . date('Y-m-d', strtotime($currentDate . '+2 days')); } } catch (\Exception $e) { + d($e); self::setError($e->getMessage()); return false; } From 884f319ddbce924654e7e33821a759c17cc1383a Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 23 Aug 2024 14:41:07 +0800 Subject: [PATCH 5/6] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E5=95=86=E5=93=81=E9=87=87=E8=B4=AD=E6=80=BB=E4=BB=B7?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/WorkbenchController.php | 11 +++++ app/admin/logic/statistic/WarehouseLogic.php | 44 ++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/app/admin/controller/WorkbenchController.php b/app/admin/controller/WorkbenchController.php index 047444343..ddd70d531 100644 --- a/app/admin/controller/WorkbenchController.php +++ b/app/admin/controller/WorkbenchController.php @@ -299,6 +299,17 @@ class WorkbenchController extends BaseAdminController * @return array */ public function total_warehouse_list() + { + $parmas=$this->request->get(); + $data =WarehouseLogic::total_warehouse_list($parmas,$parmas['type']??1); + return $this->data($data); + } + + /** + * 统计门店仓库总库存 + * @return array + */ + public function total_warehouse_product_list() { $parmas=$this->request->get(); $data =WarehouseLogic::total_warehouse_list($parmas,$parmas['type']??1); diff --git a/app/admin/logic/statistic/WarehouseLogic.php b/app/admin/logic/statistic/WarehouseLogic.php index db036f8c1..eb7f01d65 100644 --- a/app/admin/logic/statistic/WarehouseLogic.php +++ b/app/admin/logic/statistic/WarehouseLogic.php @@ -7,6 +7,7 @@ use app\common\model\store_branch_product\StoreBranchProduct; use app\common\model\store_order\StoreOrder; use app\common\model\store_order_cart_info\StoreOrderCartInfo; use app\common\model\store_product\StoreProduct; +use app\common\model\supplier\Supplier; use app\common\model\system_store\SystemStore; use app\common\model\user\User; use app\common\model\user\UserVisit; @@ -135,4 +136,47 @@ class WarehouseLogic extends BaseLogic } return ['lists'=>$list,'count'=>$count]; } + /** + * 统计商品采购总价 已结未结 + * @return array + */ + public static function total_warehouse_product_list($parmas,$type=1) { + $list=[]; + $count=0; + if($type==1){ + //总采购价 + $where=[['product_id','=',$parmas['product_id']],['nums','>',0],['financial_pm','=',1]]; + $list=WarehouseProduct::where($where)->select()->each(function ($item){ + $item->warehouse_name = Warehouse::where('id',$item['warehouse_id'])->value('name'); + $item->supplier_name = Supplier::where('id',$item['supplier_id'])->value('mer_name'); + $find = StoreProduct::where('id',$item['product_id'])->find(); + $item->store_name=$find['store_name']; + $item->image=$find['image']; + }); + $count=WarehouseProduct::where($where)->count(); + }elseif($type==2){ + //已结算采购价 + $where=[['product_id','=',$parmas['product_id']],['nums','>',0],['financial_pm','=',1]]; + $list=WarehouseProduct::where($where)->select()->each(function ($item){ + $item->warehouse_name = Warehouse::where('id',$item['warehouse_id'])->value('name'); + $item->supplier_name = Supplier::where('id',$item['supplier_id'])->value('mer_name'); + $find = StoreProduct::where('id',$item['product_id'])->find(); + $item->store_name=$find['store_name']; + $item->image=$find['image']; + }); + $count=WarehouseProduct::where($where)->count(); + }elseif($type==3){ + //未结算采购价 + $where=[['product_id','=',$parmas['product_id']],['nums','>',0],['financial_pm','=',1]]; + $list=WarehouseProduct::where($where)->select()->each(function ($item){ + $item->warehouse_name = Warehouse::where('id',$item['warehouse_id'])->value('name'); + $item->supplier_name = Supplier::where('id',$item['supplier_id'])->value('mer_name'); + $find = StoreProduct::where('id',$item['product_id'])->find(); + $item->store_name=$find['store_name']; + $item->image=$find['image']; + }); + $count=WarehouseProduct::where($where)->count(); + } + return ['lists'=>$list,'count'=>$count]; + } } From 907584a400b498d27180f8d4f753721440b7d6c6 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 23 Aug 2024 16:58:49 +0800 Subject: [PATCH 6/6] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E4=BA=86?= =?UTF-8?q?=E4=BB=93=E5=BA=93=E5=92=8C=E5=95=86=E5=93=81=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E7=9A=84=E5=8A=9F=E8=83=BD=EF=BC=8C=E5=8C=85=E6=8B=AC=E5=BA=93?= =?UTF-8?q?=E5=AD=98=E7=BB=9F=E8=AE=A1=E3=80=81=E5=95=86=E5=93=81=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E5=B1=95=E7=A4=BA=E7=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/WorkbenchController.php | 2 +- .../warehouse_order/WarehouseOrderController.php | 8 +++++++- .../lists/store_extract/StoreExtractLists.php | 1 + .../lists/store_product/StoreProductLists.php | 1 + .../warehouse_product/WarehouseProductLists.php | 3 ++- app/admin/logic/statistic/WarehouseLogic.php | 14 +++++++------- app/api/controller/IndexController.php | 7 ++++++- 7 files changed, 25 insertions(+), 11 deletions(-) diff --git a/app/admin/controller/WorkbenchController.php b/app/admin/controller/WorkbenchController.php index ddd70d531..c6d88fa77 100644 --- a/app/admin/controller/WorkbenchController.php +++ b/app/admin/controller/WorkbenchController.php @@ -312,7 +312,7 @@ class WorkbenchController extends BaseAdminController public function total_warehouse_product_list() { $parmas=$this->request->get(); - $data =WarehouseLogic::total_warehouse_list($parmas,$parmas['type']??1); + $data =WarehouseLogic::total_warehouse_product_list($parmas,$parmas['type']??1); return $this->data($data); } } diff --git a/app/admin/controller/warehouse_order/WarehouseOrderController.php b/app/admin/controller/warehouse_order/WarehouseOrderController.php index c03ed4932..a37b3a32a 100644 --- a/app/admin/controller/warehouse_order/WarehouseOrderController.php +++ b/app/admin/controller/warehouse_order/WarehouseOrderController.php @@ -209,6 +209,7 @@ class WarehouseOrderController extends BaseAdminController public function export() { $id = $this->request->post('id'); + $type = $this->request->post('type'); $xlsx = new OrderDetail(); $order = WarehouseOrder::where('id', $id)->findOrEmpty(); $system_store = SystemStore::where('id', $order['store_id'])->value('name'); @@ -218,7 +219,12 @@ class WarehouseOrderController extends BaseAdminController $find = StoreProduct::where('id', $value->product_id)->find(); $value->store_name = $find['store_name'] ?? ''; $value->store_info = $find['store_info'] ?? ''; - $value->price = $value['purchase']; + if($type==2){ + $value->price = $find['price']; + $value->total_price=bcmul($find['price'],$value['nums'],2); + }else{ + $value->price = $value['purchase']; + } $value->cart_num = $value['nums']; if (!empty($find['unit'])) { $value->unit_name = StoreProductUnit::where('id', $find['unit'])->value('name'); diff --git a/app/admin/lists/store_extract/StoreExtractLists.php b/app/admin/lists/store_extract/StoreExtractLists.php index 6916faf7d..dbb2ec935 100644 --- a/app/admin/lists/store_extract/StoreExtractLists.php +++ b/app/admin/lists/store_extract/StoreExtractLists.php @@ -60,6 +60,7 @@ class StoreExtractLists extends BaseAdminDataLists implements ListsSearchInterfa } $user_ship=UserShip::where('id',$find['user_ship'])->value('title'); $item->nickname=$name.'('.$user_ship.')'; + // $item->id_card=$name.'('.$user_ship.')'; } }) ->toArray(); diff --git a/app/admin/lists/store_product/StoreProductLists.php b/app/admin/lists/store_product/StoreProductLists.php index 1502506b9..c4f4f50a5 100644 --- a/app/admin/lists/store_product/StoreProductLists.php +++ b/app/admin/lists/store_product/StoreProductLists.php @@ -129,6 +129,7 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa 'purchase' => '采购价', 'cost' => '商户', 'price' => '零售', + 'bar_code' => '条码', ]; return $data; } diff --git a/app/admin/lists/warehouse_product/WarehouseProductLists.php b/app/admin/lists/warehouse_product/WarehouseProductLists.php index 500e54e82..a301f6634 100644 --- a/app/admin/lists/warehouse_product/WarehouseProductLists.php +++ b/app/admin/lists/warehouse_product/WarehouseProductLists.php @@ -98,10 +98,11 @@ class WarehouseProductLists extends BaseAdminDataLists implements ListsSearchInt $item->admin_name = ''; } if ($item->product_id) { - $find = StoreProduct::where('id', $item->product_id)->field('image,store_name')->find(); + $find = StoreProduct::where('id', $item->product_id)->field('price,image,store_name')->find(); if($find){ $item->store_name = $find->store_name . '|' . $item->product_id; $item->image = $find->image; + $item->price = $find->price; } } else { $item->store_name = ''; diff --git a/app/admin/logic/statistic/WarehouseLogic.php b/app/admin/logic/statistic/WarehouseLogic.php index eb7f01d65..23ec94f00 100644 --- a/app/admin/logic/statistic/WarehouseLogic.php +++ b/app/admin/logic/statistic/WarehouseLogic.php @@ -56,7 +56,7 @@ class WarehouseLogic extends BaseLogic 'title' => '总商品库存', 'desc' => '平台统计商品总库存、含门店仓库', 'total_money' => bcadd($store_stock_1, $store_stock_2, 2), - 'cash_title' => 0, + 'cash_title' => 1, 'value' => [], 'type' => 1, ]; @@ -64,7 +64,7 @@ class WarehouseLogic extends BaseLogic 'title' => '总仓库库存', 'desc' => '平台统计仓库库存', 'total_money' => WarehouseProductStorege::sum('nums'), - 'cash_title' => 0, + 'cash_title' => 1, 'value' => [], 'type' => 1, ]; @@ -72,7 +72,7 @@ class WarehouseLogic extends BaseLogic 'title' => '海吉星仓库库存', 'desc' => '平台统计海吉星仓库库存', 'total_money' => WarehouseProductStorege::where('warehouse_id', 1)->sum('nums'), - 'cash_title' => 0, + 'cash_title' => 1, 'value' => [], 'type' => 1, ]; @@ -80,7 +80,7 @@ class WarehouseLogic extends BaseLogic 'title' => '泸县集采集配库存', 'desc' => '平台统计泸县集采集配库存', 'total_money' => WarehouseProductStorege::where('warehouse_id', 2)->sum('nums'), - 'cash_title' => 0, + 'cash_title' => 1, 'value' => [], 'type' => 1, ]; @@ -88,7 +88,7 @@ class WarehouseLogic extends BaseLogic 'title' => '总门店库存', 'desc' => '平台统计门店库存', 'total_money' => StoreBranchProduct::sum('stock'), - 'cash_title' => 0, + 'cash_title' => 1, 'value' => [], 'type' => 1, @@ -156,7 +156,7 @@ class WarehouseLogic extends BaseLogic $count=WarehouseProduct::where($where)->count(); }elseif($type==2){ //已结算采购价 - $where=[['product_id','=',$parmas['product_id']],['nums','>',0],['financial_pm','=',1]]; + $where=[['product_id','=',$parmas['product_id']],['nums','>',0],['financial_pm','=',1],['is_pay','=',1]]; $list=WarehouseProduct::where($where)->select()->each(function ($item){ $item->warehouse_name = Warehouse::where('id',$item['warehouse_id'])->value('name'); $item->supplier_name = Supplier::where('id',$item['supplier_id'])->value('mer_name'); @@ -167,7 +167,7 @@ class WarehouseLogic extends BaseLogic $count=WarehouseProduct::where($where)->count(); }elseif($type==3){ //未结算采购价 - $where=[['product_id','=',$parmas['product_id']],['nums','>',0],['financial_pm','=',1]]; + $where=[['product_id','=',$parmas['product_id']],['nums','>',0],['financial_pm','=',1],['is_pay','=',0]]; $list=WarehouseProduct::where($where)->select()->each(function ($item){ $item->warehouse_name = Warehouse::where('id',$item['warehouse_id'])->value('name'); $item->supplier_name = Supplier::where('id',$item['supplier_id'])->value('mer_name'); diff --git a/app/api/controller/IndexController.php b/app/api/controller/IndexController.php index 40542ea25..36c14354d 100644 --- a/app/api/controller/IndexController.php +++ b/app/api/controller/IndexController.php @@ -208,7 +208,7 @@ class IndexController extends BaseApiController public function config() { //处理返回最近的店铺 - $params=$this->request->get(); + $params = $this->request->get(); if ((isset($params['lat']) && $params['lat'] != '') && (isset($params['long']) && $params['long'] != '')) { $latitude = $params['lat']; $longitude = $params['long']; @@ -216,10 +216,15 @@ class IndexController extends BaseApiController $distanceSql = "SQRT(POW(69.1 * (latitude - {$latitude}), 2) + POW(69.1 * ({$longitude} - longitude) * COS(latitude / 57.3), 2))"; $find = SystemStore::field("id, name,abbreviation, {$distanceSql} AS distance") + ->where('is_show', '=', 1) ->where('latitude', '<>', '') ->where('longitude', '<>', '') ->order('distance', 'asc') // 根据距离排序 ->find(); + if (!$find) { + $store_id = getenv('STORE_ID') ?? 1; + $find = SystemStore::where('id', $store_id)->find(); + } } else { $store_id = getenv('STORE_ID') ?? 1; $find = SystemStore::where('id', $store_id)->find();