diff --git a/app/admin/controller/WorkbenchController.php b/app/admin/controller/WorkbenchController.php index 86053d804..744ab58a6 100644 --- a/app/admin/controller/WorkbenchController.php +++ b/app/admin/controller/WorkbenchController.php @@ -178,7 +178,11 @@ class WorkbenchController extends BaseAdminController public function get_user_basic() { $date=$this->request->get('date',''); + $store_id=$this->request->get('store_id'); $where['create_time'] = $this->getDay($date); + if($store_id){ + $where['store_id'] = $store_id; + } $data=(new UserStatisticLogic())->getBasic($where); return $this->data($data); } @@ -189,7 +193,11 @@ class WorkbenchController extends BaseAdminController public function get_user_trend() { $date=$this->request->get('date',''); + $store_id=$this->request->get('store_id'); $where['create_time'] = $this->getDay($date); + if($store_id){ + $where['store_id'] = $store_id; + } $data=(new UserStatisticLogic())->getTrend($where); return $this->data($data); diff --git a/app/admin/controller/store_product/StoreProductController.php b/app/admin/controller/store_product/StoreProductController.php index 6ea157ae6..507a8b360 100644 --- a/app/admin/controller/store_product/StoreProductController.php +++ b/app/admin/controller/store_product/StoreProductController.php @@ -7,6 +7,7 @@ use app\admin\controller\BaseAdminController; use app\admin\lists\store_product\StoreProductLists; use app\admin\logic\store_product\StoreProductLogic; use app\admin\validate\store_product\StoreProductValidate; +use app\common\model\warehouse_product_storege\WarehouseProductStorege; use Webman\RedisQueue\Redis; /** diff --git a/app/admin/lists/store_branch_product/StoreBranchProductLists.php b/app/admin/lists/store_branch_product/StoreBranchProductLists.php index 50b5906e7..ac7ed8b91 100644 --- a/app/admin/lists/store_branch_product/StoreBranchProductLists.php +++ b/app/admin/lists/store_branch_product/StoreBranchProductLists.php @@ -65,7 +65,7 @@ class StoreBranchProductLists extends BaseAdminDataLists implements ListsSearchI $this->searchWhere[]=$where; } return StoreBranchProduct::where($this->searchWhere) - ->field(['id','store_id','product_id', 'image', 'store_name', 'cate_id', 'price', 'sales', 'stock', 'unit', 'cost','purchase', 'status','batch','vip_price','manufacturer_information']) + ->field(['id','store_id','product_id', 'image', 'store_name','store_info', 'cate_id', 'price', 'sales', 'stock', 'unit', 'cost','purchase', 'status','batch','vip_price','manufacturer_information']) ->when(!empty($this->adminInfo['store_id']), function ($query) { $query->where('store_id', $this->adminInfo['store_id']); }) diff --git a/app/admin/lists/warehouse_product/WarehouseProductLists.php b/app/admin/lists/warehouse_product/WarehouseProductLists.php index b3c6a4e87..3dd0c0f88 100644 --- a/app/admin/lists/warehouse_product/WarehouseProductLists.php +++ b/app/admin/lists/warehouse_product/WarehouseProductLists.php @@ -8,6 +8,7 @@ use app\common\model\warehouse_product\WarehouseProduct; use app\common\lists\ListsSearchInterface; use app\common\model\auth\Admin; use app\common\model\store_product\StoreProduct; +use app\common\model\system_store\SystemStore; use app\common\model\warehouse\Warehouse; /** @@ -45,12 +46,15 @@ class WarehouseProductLists extends BaseAdminDataLists implements ListsSearchInt public function lists(): array { return WarehouseProduct::where($this->searchWhere) - ->field(['id', 'admin_id','warehouse_id', 'product_id', 'financial_pm', 'batch', 'nums', 'price', 'total_price', 'manufacture','expiration_date','status','mark']) + ->field(['id', 'admin_id','store_id','warehouse_id', 'product_id', 'financial_pm', 'batch', 'nums', 'price','purchase','cost', 'total_price', 'manufacture','expiration_date','status','mark','create_time']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function ($item){ if($item->financial_pm==0){ $item->financial_pm_name='出库'; + if($item->store_id>0){ + $item->financial_pm_name='出库=>'.SystemStore::where('id',$item->store_id)->value('name'); + } }else{ $item->financial_pm_name='入库'; } diff --git a/app/admin/logic/statistic/TradeStatisticLogic.php b/app/admin/logic/statistic/TradeStatisticLogic.php index 5c2d1e276..9d2dde9f3 100644 --- a/app/admin/logic/statistic/TradeStatisticLogic.php +++ b/app/admin/logic/statistic/TradeStatisticLogic.php @@ -3,6 +3,7 @@ namespace app\admin\logic\statistic; use app\common\logic\BaseLogic; +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\user_recharge\UserRecharge; @@ -277,8 +278,10 @@ class TradeStatisticLogic extends BaseLogic $lastOfflineMoney = $this->getOfflineTotalMoney($dateWhere, 'sum', "", $isNum); $offlineCurve = $this->getOfflineTotalMoney($where, 'group', "create_time"); $offlineChain = countRate($offlineMoney, $lastOfflineMoney); + $cash=$this->getStoreCashFinanceFlowMoney($where); $topData[6] = [ 'title' => '现金收银金额', + 'cash_title' => $cash, 'desc' => '选定条件下,用户在线下现金支付的金额', 'total_money' => $offlineMoney, 'rate' => $offlineChain, @@ -433,6 +436,7 @@ class TradeStatisticLogic extends BaseLogic $data['series'][$k]['name'] = $v['title']; $data['series'][$k]['desc'] = $v['desc']; $data['series'][$k]['money'] = $v['total_money']; + $data['series'][$k]['cash_title'] = $v['cash_title']??''; $data['series'][$k]['type'] = $v['type']; $data['series'][$k]['rate'] = $v['rate']; $data['series'][$k]['value'] = array_values($v['value']); @@ -770,6 +774,19 @@ class TradeStatisticLogic extends BaseLogic return $totalMoney; } + /** + * 现金上缴统计 + */ + public function getStoreCashFinanceFlowMoney(array $where,) + { + $receivable= StoreCashFinanceFlow::where('status',0)->whereBetweenTime('create_time', strtotime($where['create_time']['start_time']), strtotime($where['create_time']['end_time']))->sum('receivable'); + if($receivable>0){ + return '未上缴'.$receivable; + }else{ + return '已上缴'; + } + } + /** * 处理Y坐标数据 * @param array $data diff --git a/app/admin/logic/statistic/UserStatisticLogic.php b/app/admin/logic/statistic/UserStatisticLogic.php index aae56b899..4e7e21274 100644 --- a/app/admin/logic/statistic/UserStatisticLogic.php +++ b/app/admin/logic/statistic/UserStatisticLogic.php @@ -26,7 +26,8 @@ class UserStatisticLogic extends BaseLogic $time = [strtotime($time[0]), strtotime($time[1])]; if (count($time) != 2) throw new Exception('参数错误'); - $userVisit = new UserVisit(); + unset($where['create_time']); + // $userVisit = new UserVisit(); /** @var UserServices $user */ $user = new User(); $order = new StoreOrder(); @@ -36,19 +37,19 @@ class UserStatisticLogic extends BaseLogic // /** @var OtherOrderServices $otherOrder */ // $otherOrder = app()->make(OtherOrderServices::class); - $now['people'] = $userVisit->where('create_time', 'between', $time)->group('uid')->count(); //访客数 - $now['browse'] = $userVisit->where('create_time', 'between', $time)->sum('id'); //访问量 - $now['newUser'] = $user->where('create_time', 'between', $time)->count(); //新增用户数 - $now['payPeople'] = $order->where('create_time', 'between', $time)->group('uid')->count(); //成交用户数 - $now['payPercent'] = bcmul((string)($now['people'] > 0 ? bcdiv($now['payPeople'], $now['people'], 4) : 0), '100', 2); //访问-付款转化率 - $now['payUser'] = $user->where('create_time', 'between', $time)->where('user_ship', 1)->count(); //激活付费会员数 - $now['rechargePeople'] = $user_recharge->where('create_time', 'between', $time)->where('paid', 1)->group('uid')->count(); //充值用户数 - $totalPayPrice = $order->where('create_time', 'between', $time)->where('paid', 1)->sum('pay_price'); - $now['payPrice'] = floatval($now['payPeople'] > 0 ? bcdiv($totalPayPrice, $now['payPeople'], 2) : 0); //客单价 - $now['cumulativeUser'] = $user->count(); //累计用户数 - $now['cumulativePayUser'] = 0; //count($otherOrder->getPayUserCount(strtotime($time[1]), $where['channel_type']));//到截至日期有付费会员状态的会员数 - $now['cumulativeRechargePeople'] = $user_recharge->where('paid', 1)->group('uid')->count(); //累计充值用户数 - $now['cumulativePayPeople'] = $order->where('paid', 1)->group('uid')->count(); //累计成交用户数 + $now['now_money'] = $user->where($where)->sum('now_money'); //余额 + $now['purchase_funds'] = $user->where($where)->sum('purchase_funds'); //采购款 + $now['newUser'] = $user->where($where)->where('create_time', 'between', $time)->count(); //新增用户数 + $now['payPeople'] = $order->where($where)->where('create_time', 'between', $time)->group('uid')->count(); //成交用户数 + // $now['payPercent'] = bcmul((string)($now['people'] > 0 ? bcdiv($now['payPeople'], $now['people'], 4) : 0), '100', 2); //访问-付款转化率 + // $now['payUser'] = $user->where('create_time', 'between', $time)->where('user_ship', 1)->count(); //激活付费会员数 + $now['rechargePeople'] = $user_recharge->where($where)->where('create_time', 'between', $time)->where('paid', 1)->group('uid')->count(); //充值用户数 + // $totalPayPrice = $order->where('create_time', 'between', $time)->where('paid', 1)->sum('pay_price'); + // $now['payPrice'] = floatval($now['payPeople'] > 0 ? bcdiv($totalPayPrice, $now['payPeople'], 2) : 0); //客单价 + $now['cumulativeUser'] = $user->where($where)->count(); //累计用户数 + // $now['cumulativePayUser'] = 0; //count($otherOrder->getPayUserCount(strtotime($time[1]), $where['channel_type']));//到截至日期有付费会员状态的会员数 + $now['cumulativeRechargePeople'] = $user_recharge->where($where)->where('paid', 1)->group('uid')->count(); //累计充值用户数 + $now['cumulativePayPeople'] = $order->where($where)->where('paid', 1)->group('uid')->count(); //累计成交用户数 $dayNum = ($time[1] - $time[0]) / 86400 + 1; @@ -58,19 +59,19 @@ class UserStatisticLogic extends BaseLogic ]; // $where['time'] = implode('-', $lastTime); // $toEndtime = implode('-', [0, $lastTime[1]]); - $last['people'] = $userVisit->where('create_time', 'between', $time)->group('uid')->count(); //访客数 - $last['browse'] = $userVisit->where('create_time', 'between', $time)->sum('id'); //访问量 - $last['newUser'] = $user->where('create_time', 'between', $time)->count(); //新增用户数 - $last['payPeople'] = $order->where('create_time', 'between', $time)->group('uid')->count(); //成交用户数 - $last['payPercent'] = bcmul((string)($last['people'] > 0 ? bcdiv($last['payPeople'], $last['people'], 4) : 0), '100', 2); //访问-付款转化率 - $last['payUser'] = $user->where('create_time', 'between', $time)->where('user_ship', 1)->count(); //激活付费会员数 - $last['rechargePeople'] = $user_recharge->where('create_time', 'between', $time)->where('paid', 1)->group('uid')->count(); //充值用户数 - $totalPayPrice = $order->where('create_time', 'between', $time)->where('paid', 1)->sum('pay_price'); - $last['payPrice'] = floatval($last['payPeople'] > 0 ? bcdiv($totalPayPrice, $last['payPeople'], 2) : 0); //客单价 - $last['cumulativeUser'] = $user->count(); //累计用户数 - $last['cumulativePayUser'] = 0; //count($otherOrder->getPayUserCount(strtotime($lastTime[1]) + 86400, $where['channel_type']));//到截至日期有付费会员状态的会员数 - $last['cumulativeRechargePeople'] = $user_recharge->where('paid', 1)->group('uid')->count(); //累计充值用户数 - $last['cumulativePayPeople'] = $order->where('paid', 1)->group('uid')->count(); //累计成交用户数 + $last['now_money'] =$now['now_money']; + $last['purchase_funds'] = $now['purchase_funds']; + $last['newUser'] = $user->where($where)->where('create_time', 'between', $time)->count(); //新增用户数 + $last['payPeople'] = $order->where($where)->where('create_time', 'between', $time)->group('uid')->count(); //成交用户数 + // $last['payPercent'] = bcmul((string)($last['people'] > 0 ? bcdiv($last['payPeople'], $last['people'], 4) : 0), '100', 2); //访问-付款转化率 + // $last['payUser'] = $user->where('create_time', 'between', $time)->where('user_ship', 1)->count(); //激活付费会员数 + $last['rechargePeople'] = $user_recharge->where($where)->where('create_time', 'between', $time)->where('paid', 1)->group('uid')->count(); //充值用户数 + // $totalPayPrice = $order->where('create_time', 'between', $time)->where('paid', 1)->sum('pay_price'); + // $last['payPrice'] = floatval($last['payPeople'] > 0 ? bcdiv($totalPayPrice, $last['payPeople'], 2) : 0); //客单价 + $last['cumulativeUser'] = $user->where($where)->count(); //累计用户数 + // $last['cumulativePayUser'] = 0; //count($otherOrder->getPayUserCount(strtotime($lastTime[1]) + 86400, $where['channel_type']));//到截至日期有付费会员状态的会员数 + $last['cumulativeRechargePeople'] = $user_recharge->where($where)->where('paid', 1)->group('uid')->count(); //累计充值用户数 + $last['cumulativePayPeople'] = $order->where($where)->where('paid', 1)->group('uid')->count(); //累计成交用户数 //组合数据,计算环比 $data = []; @@ -93,18 +94,18 @@ class UserStatisticLogic extends BaseLogic { $time = explode('-', $where['create_time']); $time = [strtotime($time[0]), strtotime($time[1])]; - $channelType = ''; //$where['channel_type']; + unset($where['create_time']); if (count($time) != 2) throw new Exception('参数错误'); $dayCount = ($time[1] - $time[0]) / 86400 + 1; $data = []; if ($dayCount == 1) { - $data = $this->trend($time, $channelType, 0, $excel); + $data = $this->trend($time, $where, 0, $excel); } elseif ($dayCount > 1 && $dayCount <= 31) { - $data = $this->trend($time, $channelType, 1, $excel); + $data = $this->trend($time, $where, 1, $excel); } elseif ($dayCount > 31 && $dayCount <= 92) { - $data = $this->trend($time, $channelType, 3, $excel); + $data = $this->trend($time, $where, 3, $excel); } elseif ($dayCount > 92) { - $data = $this->trend($time, $channelType, 30, $excel); + $data = $this->trend($time, $where, 30, $excel); } return $data; } @@ -117,19 +118,18 @@ class UserStatisticLogic extends BaseLogic * @param $excel * @return array */ - public function trend($time, $channelType, $num, $excel) + public function trend($time, $where, $num, $excel) { $user = new User(); - $userVisit = new UserVisit(); + // $userVisit = new UserVisit(); $order = new StoreOrder(); $recharge = new UserRecharge(); - $newPeople = $visitPeople = $paidPeople = $rechargePeople = $vipPeople = []; - $newPeople['name'] = '新增用户数'; - $visitPeople['name'] = '访客数'; - $paidPeople['name'] = '成交用户数'; - $rechargePeople['name'] = '充值用户'; - $vipPeople['name'] = '新增付费用户数'; + $newPeople = $paidPeople = $rechargePeople = $vipPeople = []; + $newPeople['name'] = '新增用户'; + // $visitPeople['name'] = '访客数'; + $paidPeople['name'] = '成交用户'; + $vipPeople['name'] = '新增会员用户'; if ($num == 0) { $xAxis = ['00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23']; $timeType = '%H'; @@ -148,19 +148,17 @@ class UserStatisticLogic extends BaseLogic } } } - $visitPeople = array_column($userVisit->getTrendData($time, $channelType, $timeType, 'count(distinct(uid))'), 'num', 'days'); - $newPeople = array_column($user->getTrendData($time, $channelType, $timeType), 'num', 'days'); - $paidPeople = array_column($order->getTrendData($time, $channelType, $timeType, 'count(distinct(uid))'), 'num', 'days'); - $rechargePeople = array_column($recharge->getTrendData(['paid'=>1],$time, $channelType, $timeType, 'count(distinct(uid))'), 'num', 'days'); - $vipPeople = array_column($recharge->getTrendData(['paid'=>1,'price'=>1000],$time, $channelType, $timeType, 'count(distinct(uid))'), 'num', 'days'); + // $visitPeople = array_column($userVisit->getTrendData($time, $channelType, $timeType, 'count(distinct(uid))'), 'num', 'days'); + $newPeople = array_column($user->getTrendData($time, [], $timeType), 'num', 'days'); + $paidPeople = array_column($order->getTrendData($time, $where, $timeType, 'count(distinct(uid))'), 'num', 'days'); + $vipPeople = array_column($user->getTrendData($time, [], $timeType, 'vip_time'), 'days'); $data = $series = []; foreach ($xAxis as $item) { - $data['新增用户数'][] = isset($newPeople[$item]) ? intval($newPeople[$item]) : 0; - $data['访客数'][] = isset($visitPeople[$item]) ? intval($visitPeople[$item]) : 0; - $data['成交用户数'][] = isset($paidPeople[$item]) ? intval($paidPeople[$item]) : 0; - $data['充值用户'][] = isset($rechargePeople[$item]) ? intval($rechargePeople[$item]) : 0; - $data['新增付费用户数'][] = isset($vipPeople[$item]) ? intval($vipPeople[$item]) : 0; + $data['新增用户'][] = isset($newPeople[$item]) ? intval($newPeople[$item]) : 0; + // $data['访客数'][] = isset($visitPeople[$item]) ? intval($visitPeople[$item]) : 0; + $data['成交用户'][] = isset($paidPeople[$item]) ? intval($paidPeople[$item]) : 0; + $data['新增会员用户'][] = isset($vipPeople[$item]) ? intval($vipPeople[$item]) : 0; } foreach ($data as $key => $item) { $series[] = ['name' => $key, 'value' => $item]; diff --git a/app/admin/logic/warehouse_product/WarehouseProductLogic.php b/app/admin/logic/warehouse_product/WarehouseProductLogic.php index 15f03eb72..8de456ab4 100644 --- a/app/admin/logic/warehouse_product/WarehouseProductLogic.php +++ b/app/admin/logic/warehouse_product/WarehouseProductLogic.php @@ -5,6 +5,7 @@ namespace app\admin\logic\warehouse_product; use app\common\model\warehouse_product\WarehouseProduct; use app\common\logic\BaseLogic; +use app\common\model\store_branch_product\StoreBranchProduct; use app\common\model\store_product\StoreProduct; use app\common\model\warehouse_product_storege\WarehouseProductStorege; use support\Log; @@ -31,27 +32,29 @@ class WarehouseProductLogic extends BaseLogic { Db::startTrans(); try { - $data=[ + $data = [ 'warehouse_id' => $params['warehouse_id'], 'product_id' => $params['product_id'], 'financial_pm' => $params['financial_pm'], - 'batch' => $params['batch'], + 'batch' => 0, 'nums' => $params['nums'], - 'price' => $params['price']??'', - 'total_price' => $params['total_price']??'', + 'price' => $params['price'] ?? '', + 'purchase' => $params['purchase'] ?? '', + 'cost' => $params['cost'] ?? '', + 'total_price' => $params['total_price'] ?? '', 'admin_id' => $params['admin_id'], - 'code' => $params['code']??'', - 'status' => $params['status']??0, - 'mark' => $params['mark']??'', + 'code' => $params['code'] ?? '', + 'status' => $params['status'] ?? 0, + 'mark' => $params['mark'] ?? '', ]; - if(isset($params['manufacture']) &&$params['manufacture']!=''){ - $data['manufacture']=strtotime($params['manufacture']); + if (isset($params['manufacture']) && $params['manufacture'] != '') { + $data['manufacture'] = strtotime($params['manufacture']); } - if(isset($params['expiration_date']) &&$params['expiration_date']!=''){ - $data['expiration_date']=strtotime($params['expiration_date']); + if (isset($params['expiration_date']) && $params['expiration_date'] != '') { + $data['expiration_date'] = strtotime($params['expiration_date']); } - $res=WarehouseProduct::create($data); - self::enter($res['id'],$params['financial_pm']); + $res = WarehouseProduct::create($data); + self::enter($res['id'], $params['financial_pm']); Db::commit(); return true; } catch (\Exception $e) { @@ -73,74 +76,73 @@ class WarehouseProductLogic extends BaseLogic { Db::startTrans(); try { - $data=[ + $data = [ 'warehouse_id' => $params['warehouse_id'], 'product_id' => $params['product_id'], 'financial_pm' => $params['financial_pm'], - 'batch' => $params['batch'], + 'batch' => WarehouseProduct::where(['product_id' => $params['product_id'], 'warehouse_id' => $params['warehouse_id'], 'financial_pm' => $params['financial_pm']])->count(), 'nums' => $params['nums'], 'price' => $params['price'], 'admin_id' => $params['admin_id'], 'total_price' => $params['total_price'], 'code' => $params['code'], + 'purchase' => $params['purchase'] ?? '', + 'cost' => $params['cost'] ?? '', ]; - if(isset($params['manufacture']) &&$params['manufacture']!=''){ - $data['manufacture']=strtotime($params['manufacture']); + if (isset($params['manufacture']) && $params['manufacture'] != '') { + $data['manufacture'] = strtotime($params['manufacture']); } - if(isset($params['expiration_date']) &&$params['expiration_date']!=''){ - $data['expiration_date']=strtotime($params['expiration_date']); + if (isset($params['expiration_date']) && $params['expiration_date'] != '') { + $data['expiration_date'] = strtotime($params['expiration_date']); } - $res=WarehouseProduct::where('id', $params['id'])->update($data); + $res = WarehouseProduct::where('id', $params['id'])->update($data); Db::commit(); return $res; } catch (\Exception $e) { Db::rollback(); + d($e); self::setError($e->getMessage()); return false; } } - + /** * @notes 确认商品仓储信息 * @param array $params * @author admin * @date 2024/07/31 16:55 */ - public static function enter($id,$financial_pm=0) + public static function enter($id, $financial_pm = 0) { - Db::startTrans(); - try { - $find=WarehouseProduct::where('id',$id)->find(); - $find->status=1; - $find->save(); - $storege=WarehouseProductStorege::where('warehouse_id',$find['warehouse_id'])->where('product_id',$find['product_id'])->find(); - if($financial_pm==0){ - StoreProduct::where('id',$find['product_id'])->dec('stock',$find['nums'])->update(); - }else{ - StoreProduct::where('id',$find['product_id'])->inc('stock',$find['nums'])->update(); - } - if($storege){ - if($financial_pm==0){ - $storege->nums=bcsub($storege->nums,$find['nums']); - }else{ - $storege->nums=bcadd($storege->nums,$find['nums']); - } - $storege->save(); - }else{ - WarehouseProductStorege::create([ - 'warehouse_id' => $find['warehouse_id'], - 'product_id' => $find['product_id'], - 'nums' => $find['nums'], - ]); + $find = WarehouseProduct::where('id', $id)->find(); + $find->status = 1; + $find->batch = WarehouseProduct::where(['product_id' => $find['product_id'], 'warehouse_id' => $find['warehouse_id'], 'financial_pm' => $financial_pm])->count(); + $find->save(); + + $storege = WarehouseProductStorege::where('warehouse_id', $find['warehouse_id'])->where('product_id', $find['product_id'])->find(); + if ($financial_pm == 0) { + StoreProduct::where('id', $find['product_id'])->dec('stock', $find['nums'])->update(); + } else { + StoreProduct::where('id', $find['product_id'])->inc('stock', $find['nums'])->update(['purchase' => $find['purchase'], 'cost' => $find['cost'], 'price' => $find['price']]); + StoreBranchProduct::where('product_id', $find['product_id'])->update(['purchase' => $find['purchase'], 'cost' => $find['cost'], 'price' => $find['price']]); + } + + if ($storege) { + if ($financial_pm == 0) { + $storege->nums = bcsub($storege->nums, $find['nums']); + } else { + + $storege->nums = bcadd($storege->nums, $find['nums']); } - Db::commit(); - return true; - } catch (\Exception $e) { - Db::rollback(); - self::setError($e->getMessage()); - return false; + $storege->save(); + } else { + WarehouseProductStorege::create([ + 'warehouse_id' => $find['warehouse_id'], + 'product_id' => $find['product_id'], + 'nums' => $find['nums'], + ]); } } @@ -167,12 +169,11 @@ class WarehouseProductLogic extends BaseLogic */ public static function detail($params): array { - $data= WarehouseProduct::findOrEmpty($params['id'])->toArray(); - if($data){ - $data['manufacture']=date('Y-m-d',$data['manufacture']); - $data['expiration_date']=date('Y-m-d',$data['expiration_date']); - + $data = WarehouseProduct::findOrEmpty($params['id'])->toArray(); + if ($data) { + $data['manufacture'] = date('Y-m-d', $data['manufacture']); + $data['expiration_date'] = date('Y-m-d', $data['expiration_date']); } return $data; } -} \ No newline at end of file +} diff --git a/app/admin/validate/warehouse_product/WarehouseProductValidate.php b/app/admin/validate/warehouse_product/WarehouseProductValidate.php index a3a7cb795..aa9797b88 100644 --- a/app/admin/validate/warehouse_product/WarehouseProductValidate.php +++ b/app/admin/validate/warehouse_product/WarehouseProductValidate.php @@ -56,7 +56,7 @@ class WarehouseProductValidate extends BaseValidate */ public function sceneAdd() { - return $this->only(['warehouse_id','product_id','financial_pm','batch','nums','price','total_price']); + return $this->only(['warehouse_id','product_id','financial_pm','nums','price','total_price']); } @@ -68,7 +68,7 @@ class WarehouseProductValidate extends BaseValidate */ public function sceneEdit() { - return $this->only(['id','warehouse_id','product_id','financial_pm','batch','nums','price','total_price']); + return $this->only(['id','warehouse_id','product_id','financial_pm','nums','price','total_price']); } diff --git a/app/common/model/store_order/StoreOrder.php b/app/common/model/store_order/StoreOrder.php index 69b1b301b..2f817b0dd 100644 --- a/app/common/model/store_order/StoreOrder.php +++ b/app/common/model/store_order/StoreOrder.php @@ -78,11 +78,9 @@ class StoreOrder extends BaseModel * @param $timeType * @return mixed */ - public function getTrendData($time, $type, $timeType, $str) + public function getTrendData($time, $where, $timeType, $str) { - return $this->when($type != '', function ($query) use ($type) { - $query->where('channel_type', $type); - })->where('paid', 1)->where('paid', '>=', 0)->where(function ($query) use ($time) { + return $this->where($where)->where('paid', 1)->where('refund_status', '=', 0)->where(function ($query) use ($time) { if ($time[0] == $time[1]) { $query->whereDay('create_time', date('Y-m-d',$time[0])); } else { diff --git a/app/common/model/user/User.php b/app/common/model/user/User.php index 290132284..e0ae912f4 100644 --- a/app/common/model/user/User.php +++ b/app/common/model/user/User.php @@ -184,17 +184,15 @@ class User extends BaseModel * @param $timeType * @return mixed */ - public function getTrendData($time, $type, $timeType) + public function getTrendData($time, $where, $timeType,$create_time='create_time') { - return $this->when($type != '', function ($query) use ($type) { - $query->where('user_type', $type); - })->where(function ($query) use ($time) { + return $this->where($where)->where(function ($query) use ($time,$create_time) { if ($time[0] == $time[1]) { - $query->whereDay('create_time', date('Y-m-d',$time[0])); + $query->whereDay($create_time, date('Y-m-d',$time[0])); } else { $time[1] = $time[1] + 86400; - $query->whereTime('create_time', 'between', $time); + $query->whereTime($create_time, 'between', $time); } - })->field("FROM_UNIXTIME(create_time,'$timeType') as days,count(id) as num")->group('days')->select()->toArray(); + })->field("FROM_UNIXTIME($create_time,'$timeType') as days,count(id) as num")->group('days')->select()->toArray(); } } diff --git a/app/queue/redis/StoreStorageSend.php b/app/queue/redis/StoreStorageSend.php index 0ae7662a8..cea7038a3 100644 --- a/app/queue/redis/StoreStorageSend.php +++ b/app/queue/redis/StoreStorageSend.php @@ -174,6 +174,7 @@ class StoreStorageSend implements Consumer $data=[ 'warehouse_id'=>$warehouse_id, 'product_id' => $product_arr['id'], + 'store_id' => $store_id, 'financial_pm' => 0, 'batch' => $product_arr['batch']??1, 'nums' => $product_arr['stock'], diff --git a/app/store/lists/store_order/StoreOrderLists.php b/app/store/lists/store_order/StoreOrderLists.php index cdb7d1e1d..edb792fb4 100644 --- a/app/store/lists/store_order/StoreOrderLists.php +++ b/app/store/lists/store_order/StoreOrderLists.php @@ -88,6 +88,9 @@ class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface } else { $item['paid_name'] = '已支付'; } + if($item['status']==4){ + $item['paid_name'] = $item['status_name']; + } $product = StoreOrderCartInfo::where('oid', $item['id'])->field(['id', 'oid', 'product_id', 'cart_info']) ->limit(3)->select(); foreach ($product as &$items) {