diff --git a/app/admin/lists/store_order_cart_info/StoreOrderCartInfoGroupLists.php b/app/admin/lists/store_order_cart_info/StoreOrderCartInfoGroupLists.php index 37153b059..20d362251 100644 --- a/app/admin/lists/store_order_cart_info/StoreOrderCartInfoGroupLists.php +++ b/app/admin/lists/store_order_cart_info/StoreOrderCartInfoGroupLists.php @@ -52,6 +52,8 @@ class StoreOrderCartInfoGroupLists extends BaseAdminDataLists implements ListsSe if($this->request->get('start_time')==''){ $this->searchWhere[]=['create_time','between',[strtotime(date('Y-m-d 00:00:00')),strtotime(date('Y-m-d 23:59:59'))]]; } + $this->searchWhere[]=['is_pay','=',1]; + $this->searchWhere[]=['status','>=',0]; return StoreOrderCartInfo::where($this->searchWhere) ->field('product_id,price,SUM(total_price) as total_price,SUM(cart_num) as cart_num')->group('product_id') ->limit($this->limitOffset, $this->limitLength) diff --git a/app/admin/lists/store_order_cart_info/StoreOrderCartInfoTwoLists.php b/app/admin/lists/store_order_cart_info/StoreOrderCartInfoTwoLists.php index 2a8557d5e..468e3ee92 100644 --- a/app/admin/lists/store_order_cart_info/StoreOrderCartInfoTwoLists.php +++ b/app/admin/lists/store_order_cart_info/StoreOrderCartInfoTwoLists.php @@ -52,6 +52,8 @@ class StoreOrderCartInfoTwoLists extends BaseAdminDataLists implements ListsSear if ($this->request->get('start_time') == '') { $this->searchWhere[] = ['create_time', 'between', [strtotime(date('Y-m-d 00:00:00')), strtotime(date('Y-m-d 23:59:59'))]]; } + $this->searchWhere[]=['is_pay','=',1]; + $this->searchWhere[]=['status','>=',0]; $query = StoreOrderCartInfo::where($this->searchWhere); if ($this->request->get('is_group') == 1) { $query->field('store_id,product_id,price,SUM(total_price) as total_price,SUM(cart_num) as cart_num')->group(['store_id', 'product_id']); diff --git a/app/admin/logic/statistic/TradeStatisticLogic.php b/app/admin/logic/statistic/TradeStatisticLogic.php index 123d2b182..5c2d1e276 100644 --- a/app/admin/logic/statistic/TradeStatisticLogic.php +++ b/app/admin/logic/statistic/TradeStatisticLogic.php @@ -314,7 +314,7 @@ class TradeStatisticLogic extends BaseLogic $depositWehre['financial_type'] = 11; $orderDepositMoney = $this->getFinanceFlow($depositWehre, "sum"); $lastOrderDepositMoney = $this->getFinanceFlow($dateWhere, "sum", "", $isNum); - $OrderDepositCurve = $this->getFinanceFlow($where, "group", "create_time"); + $OrderDepositCurve = $this->getFinanceFlow($depositWehre, "group", "create_time"); $OrderDepositChain = countRate($orderDepositMoney, $lastOrderDepositMoney); $topData[8] = [ @@ -483,17 +483,17 @@ class TradeStatisticLogic extends BaseLogic $orderGroup = "create_time"; $OrderMoney = $this->getOrderTotalMoney($where, $selectType, $orderGroup); //用户充值收入 - $rechargeGroup = "create_time"; - $RechargeMoneyHome = $this->getRechargeTotalMoney($where, $selectType, $rechargeGroup); - $RechargeMoneyAdmin = $this->getBillYeTotalMoney($where, $selectType, $rechargeGroup); - $RechargeMoney = $this->totalArrData([$RechargeMoneyHome, $RechargeMoneyAdmin]); + // $rechargeGroup = "create_time"; + // $RechargeMoneyHome = $this->getRechargeTotalMoney($where, $selectType, $rechargeGroup); + // $RechargeMoneyAdmin = $this->getBillYeTotalMoney($where, $selectType, $rechargeGroup); + // $RechargeMoney = $this->totalArrData([$RechargeMoneyHome, $RechargeMoneyAdmin]); //购买会员收入 - $memberGroup = "create_time"; - $MemberMoney = $this->getMemberTotalMoney($where, $selectType, $memberGroup); + // $memberGroup = "create_time"; + // $MemberMoney = $this->getMemberTotalMoney($where, $selectType, $memberGroup); //线下收款收入 $offlineGroup = "create_time"; $OfflineMoney = $this->getOfflineTotalMoney($where, $selectType, $offlineGroup); - return $this->totalArrData([$OrderMoney, $RechargeMoney, $MemberMoney, $OfflineMoney]); + return $this->totalArrData([$OrderMoney, $OfflineMoney]); } diff --git a/app/admin/logic/system_store_storage/SystemStoreStorageLogic.php b/app/admin/logic/system_store_storage/SystemStoreStorageLogic.php index f9f75441f..3b7014ecb 100644 --- a/app/admin/logic/system_store_storage/SystemStoreStorageLogic.php +++ b/app/admin/logic/system_store_storage/SystemStoreStorageLogic.php @@ -8,6 +8,8 @@ use app\common\model\store_branch_product_attr_value\StoreBranchProductAttrValue use app\common\model\system_store_storage\SystemStoreStorage; use app\common\logic\BaseLogic; use app\common\model\store_product\StoreProduct; +use app\common\model\warehouse_product\WarehouseProduct; +use app\common\model\warehouse_product_storege\WarehouseProductStorege; use think\facade\Db; @@ -59,11 +61,12 @@ class SystemStoreStorageLogic extends BaseLogic */ public static function edit(array $params): bool { - $stock=StoreProduct::where('id', $params['product_id'])->value('stock'); - $nums=SystemStoreStorage::where('id', $params['id'])->value('nums'); - $stock=bcadd($stock,$nums); - if($stock<$params['nums']){ - self::setError('库存不足,主库为:'.$stock); + $find=SystemStoreStorage::where('id', $params['id'])->find(); + + //查看仓库库存 + $productStorege=WarehouseProductStorege::where('product_id', $params['product_id'],['warehouse_id'=>$find['warehouse_id']])->find(); + if($productStorege && $productStorege['nums']<$params['nums']){ + self::setError('库存不足,仓库库存为:'.$productStorege['nums']); return false; } Db::startTrans(); @@ -71,8 +74,12 @@ class SystemStoreStorageLogic extends BaseLogic SystemStoreStorage::where('id', $params['id'])->update([ 'nums' => $params['nums'], 'admin_id' => $params['admin_id'], + 'status' => 0, + 'mark' => '', ]); - StoreProduct::where('id', $params['product_id'])->update(['stock'=>bcsub($stock,$params['nums'])]); + StoreProduct::where('id', $params['product_id'])->inc('stock',bcsub($find['nums'] ,$params['nums'],2))->update(); + WarehouseProductStorege::where('id',$productStorege['id'])->inc('stock',bcsub($find['nums'] ,$params['nums'],2))->update(); + WarehouseProduct::where('id',$find['outbound_id'])->update(['nums',$params['nums']]); Db::commit(); return true; } catch (\Exception $e) { diff --git a/app/admin/logic/warehouse_product/WarehouseProductLogic.php b/app/admin/logic/warehouse_product/WarehouseProductLogic.php index 665401481..15f03eb72 100644 --- a/app/admin/logic/warehouse_product/WarehouseProductLogic.php +++ b/app/admin/logic/warehouse_product/WarehouseProductLogic.php @@ -90,10 +90,10 @@ class WarehouseProductLogic extends BaseLogic if(isset($params['expiration_date']) &&$params['expiration_date']!=''){ $data['expiration_date']=strtotime($params['expiration_date']); } - WarehouseProduct::where('id', $params['id'])->update($data); + $res=WarehouseProduct::where('id', $params['id'])->update($data); Db::commit(); - return true; + return $res; } catch (\Exception $e) { Db::rollback(); self::setError($e->getMessage()); diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index f0d160fcb..d1c8d5cd7 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -563,6 +563,7 @@ class PayNotifyLogic extends BaseLogic */ public static function afterPay($order, $transaction_id = 0) { + StoreOrderCartInfo::where('oid', $order['id'])->update(['is_pay' => 1]); $financeLogic = new StoreFinanceFlowLogic(); $off_activity = Config::where('name', 'off_activity')->value('value'); $village_uid = 0; diff --git a/app/queue/redis/StoreStorageSend.php b/app/queue/redis/StoreStorageSend.php index 5d51219af..0ae7662a8 100644 --- a/app/queue/redis/StoreStorageSend.php +++ b/app/queue/redis/StoreStorageSend.php @@ -169,6 +169,7 @@ class StoreStorageSend implements Consumer 'nums' => $product_arr['stock'], 'admin_id' => $admin_id, 'type' => $stock_type, + 'warehouse_id'=>$warehouse_id, ]; $data=[ 'warehouse_id'=>$warehouse_id, @@ -187,11 +188,13 @@ class StoreStorageSend implements Consumer $storage['mark'] = '库存不足,分库存为:' .$warehouse['nums']; $data['mark'] = '库存不足,分库存为:' .$warehouse['nums'].' 总仓库存为:'.$find['stock']; } + $res=WarehouseProductLogic::add($data); + $storage['outbound_id']=$res['id']??0; SystemStoreStorage::create($storage); - WarehouseProductLogic::add($data); } else { + $res=WarehouseProductLogic::add($data); + $storage['outbound_id']=$res['id']??0; SystemStoreStorage::create($storage); - WarehouseProductLogic::add($data); } }