diff --git a/app/admin/logic/store_product/StoreProductLogic.php b/app/admin/logic/store_product/StoreProductLogic.php index 1a0e41865..b2784d03c 100644 --- a/app/admin/logic/store_product/StoreProductLogic.php +++ b/app/admin/logic/store_product/StoreProductLogic.php @@ -78,13 +78,13 @@ class StoreProductLogic extends BaseLogic if ($params['is_store_all'] == 1) { $store_arr = SystemStore::where('is_show', 1)->column('id'); foreach ($store_arr as $store_id) { - Redis::send('store-storage', ['product_arr' => ['id' => $res['id'], 'stock' => 0], 'store_id' => $store_id, 'admin_id' => Request()->adminId]); + Redis::send('store-storage', ['product_arr' => ['id' => $res['id'], 'stock' => 0], 'store_id' => $store_id,'stock_type'=>1, 'admin_id' => Request()->adminId]); } // Redis::send('copy-product', ['product_id' => $res['id'], 'store_arr' => $store_arr]); } else { if (is_array($params['store_arr']) && count($params['store_arr']) > 0) { foreach ($params['store_arr'] as $key => $store_id) { - Redis::send('store-storage', ['product_arr' => ['id' => $res['id'], 'stock' => 0], 'store_id' => $store_id, 'admin_id' => Request()->adminId]); + Redis::send('store-storage', ['product_arr' => ['id' => $res['id'], 'stock' => 0], 'store_id' => $store_id,'stock_type'=>1, 'admin_id' => Request()->adminId]); } // Redis::send('copy-product', ['product_id' => $res['id'], 'store_arr' => $params['store_arr']]); } diff --git a/app/api/controller/IndexController.php b/app/api/controller/IndexController.php index 5ccf27950..5c87916b4 100644 --- a/app/api/controller/IndexController.php +++ b/app/api/controller/IndexController.php @@ -6,6 +6,7 @@ use app\admin\logic\store_product\StoreProductLogic; use app\admin\validate\tools\GenerateTableValidate; use app\admin\logic\tools\GeneratorLogic; use app\common\logic\store_order\StoreOrderLogic; +use app\common\model\Config as ModelConfig; use app\common\model\store_branch_product\StoreBranchProduct; use app\common\model\system_store\SystemStore; use app\common\service\pay\PayService; @@ -27,38 +28,17 @@ class IndexController extends BaseApiController public function index() { - $arr = StoreBranchProduct::select(); - foreach ($arr as $item) { - StoreProductLogic::updateGoodsclass($item['cate_id'], $item['store_id']); - } - d(1); + $order = [ + 'out_trade_no' => 'CZ1719197818549414', + ]; + $app = new PayService(0); + try { - $wechat = new PayService(1); - $time = time(); - $order = [ - 'out_trade_no' => 'PF1717558027664507', - 'out_refund_no' => 'BO' . $time, - 'amount' => [ - 'refund' => 1, - 'total' => 1, - 'currency' => 'CNY', - ], - // '_action' => 'jsapi', // jsapi 退款,默认 - // '_action' => 'app', // app 退款 - // '_action' => 'combine', // 合单退款 - // '_action' => 'h5', // h5 退款 - // '_action' => 'miniapp', // 小程序退款 - // '_action' => 'native', // native 退款 - - ]; - - $res = $wechat->wechat->refund($order); - Cache::set('kk', json_decode($res, true)); - } catch (Exception $e) { - \support\Log::info($e->extra['message'] ?? $e->getMessage()); - throw new \Exception($e->extra['message'] ?? $e->getMessage()); + $res = $app->wechat->query($order); + } catch (\Exception $e) { + return $this->fail($e->extra['message']); } - d(1); + d($res); diff --git a/app/api/controller/LoginController.php b/app/api/controller/LoginController.php index 1c94ce971..dd8ab2244 100644 --- a/app/api/controller/LoginController.php +++ b/app/api/controller/LoginController.php @@ -78,8 +78,11 @@ class LoginController extends BaseApiController public function updateUser() { $params = (new WechatLoginValidate())->post()->goCheck("updateUser"); - LoginLogic::updateUser($params, $this->userId); - return $this->success('操作成功', [], 1, 1); + $result = LoginLogic::updateUser($params, $this->userId); + if ($result === false) { + return $this->fail(LoginLogic::getError()); + } + return $this->success('操作成功', [], 1, 0); } /** diff --git a/app/api/lists/order/CartList.php b/app/api/lists/order/CartList.php index c10cff8de..652c9eedf 100644 --- a/app/api/lists/order/CartList.php +++ b/app/api/lists/order/CartList.php @@ -65,22 +65,22 @@ class CartList extends BaseAdminDataLists implements ListsSearchInterface, Lists foreach ($list as $key => &$item) { $find = StoreBranchProduct::where(['product_id' => $item['product_id'],'store_id' => $item['store_id']]) - ->field('product_id,image,cost price,cost,store_name,unit,delete_time,vip_price') + ->field('product_id,image,price,cost,store_name,unit,delete_time,vip_price') ->withTrashed() ->find(); if ($find) { - // if ($user && $user['user_ship'] == 1) { - // //更新 会员为1的时候原价减去会员价 - // $deduction_price_count=bcmul(bcsub($find['price'], $find['vip_price'], 2),$item['cart_num'],2); - // $this->activity_price = bcadd($this->activity_price, $deduction_price_count, 2); - // }elseif ($user && $user['user_ship'] == 4) { - // //更新 为4商户的时候减去商户价格 - // $deduction_price_count=bcmul(bcsub($find['price'], $find['cost'], 2),$item['cart_num'],2); - // $this->activity_price = bcadd( $this->activity_price, $deduction_price_count, 2); - // }else{ - // $this->activity_price =0; - // } + if ($user && $user['user_ship'] == 1) { + //更新 会员为1的时候原价减去会员价 + $deduction_price_count=bcmul(bcsub($find['price'], $find['vip_price'], 2),$item['cart_num'],2); + $this->activity_price = bcadd($this->activity_price, $deduction_price_count, 2); + }elseif ($user && $user['user_ship'] == 4) { + //更新 为4商户的时候减去商户价格 + $deduction_price_count=bcmul(bcsub($find['price'], $find['cost'], 2),$item['cart_num'],2); + $this->activity_price = bcadd( $this->activity_price, $deduction_price_count, 2); + }else{ + $this->activity_price =0; + } $item['goods_total_price'] = bcmul($item['cart_num'], $find['price'], 2); $this->total_price = bcadd($this->total_price, $item['goods_total_price'], 2); $item['imgs'] = $find['image']; diff --git a/app/api/lists/product/ProductLists.php b/app/api/lists/product/ProductLists.php index 1adf1ba6c..f8e219939 100644 --- a/app/api/lists/product/ProductLists.php +++ b/app/api/lists/product/ProductLists.php @@ -106,7 +106,7 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, L $this->searchWhere[] = ['status', '=', 1]; $this->searchWhere[] = ['stock', '>', 0]; return StoreBranchProduct::where($this->searchWhere) - ->field(['id', 'product_id', 'cate_id', 'store_name', 'cost', 'store_id','vip_price','purchase', 'cost price', 'bar_code', 'image', 'sales', 'store_info', 'delete_time', 'unit', 'batch']) + ->field(['id', 'product_id', 'cate_id', 'store_name', 'cost', 'store_id','vip_price','purchase', 'price', 'bar_code', 'image', 'sales', 'store_info', 'delete_time', 'unit', 'batch']) ->with(['className', 'unitName']) ->limit($this->limitOffset, $this->limitLength) ->order($this->sortOrder) diff --git a/app/api/lists/user/UserRechargeLists.php b/app/api/lists/user/UserRechargeLists.php index 5c68956bd..62521a687 100644 --- a/app/api/lists/user/UserRechargeLists.php +++ b/app/api/lists/user/UserRechargeLists.php @@ -46,8 +46,8 @@ use app\common\model\user_recharge\UserRecharge; $data['label_name']=''; if($data['recharge_type']=='INDUSTRYMEMBERS'){ $find =User::where('id',$data['uid'])->find(); - $data['real_name']=$find['real_name']; - if($find['label_id']>0){ + $data['real_name']=$find['real_name']??''; + if($find &&$find['label_id']>0){ $data['label_name']=UserLabel::where('label_id',$find['label_id'])->value('label_name'); } }else{ diff --git a/app/api/logic/LoginLogic.php b/app/api/logic/LoginLogic.php index da85ad01d..798b3b577 100644 --- a/app/api/logic/LoginLogic.php +++ b/app/api/logic/LoginLogic.php @@ -435,12 +435,22 @@ class LoginLogic extends BaseLogic * @notes 更新用户信息 * @param $params * @param $userId - * @return User + * @return User|bool * @author 段誉 * @date 2023/2/22 11:19 */ public static function updateUser($params, $userId) { + $find=User::where(['mobile' =>$params['mobile']])->find(); + if($find){ + $auth=UserAuth::where(['user_id'=>$find['id']])->find();//别人的 + if($auth){ + self::$error ='该手机号已绑定'; + return false; + }else{ + UserAuth::where(['user_id'=>$userId])->update(['user_id'=>$find['id']]); + } + } $data=[ 'mobile'=>$params['mobile'], 'is_new_user' => YesNoEnum::NO diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index 14654eab6..398f97321 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -74,7 +74,7 @@ class OrderLogic extends BaseLogic /** 计算价格 */ foreach ($cart_select as $k => $v) { - $find = StoreBranchProduct::where(['product_id' => $v['product_id'], 'store_id' => $params['store_id']])->field('id branch_product_id,store_name,image,unit,cost price,vip_price,cost,purchase,product_id')->withTrashed()->find(); + $find = StoreBranchProduct::where(['product_id' => $v['product_id'], 'store_id' => $params['store_id']])->field('id branch_product_id,store_name,image,unit,price,vip_price,cost,purchase,product_id')->withTrashed()->find(); if (!$find) { continue; } @@ -85,19 +85,19 @@ class OrderLogic extends BaseLogic $cart_select[$k]['total_price'] = bcmul($v['cart_num'], $find['price'], 2); //订单总价 $cart_select[$k]['deduction_price'] =self::$activity_price;//抵扣金额 $cart_select[$k]['vip'] = 0; - // if ($user && $user['user_ship'] == 1) { - // //更新 会员为1的时候原价减去会员价 - // $deduction_price_count=bcmul(bcsub($find['price'], $find['vip_price'], 2),$v['cart_num'],2); - // $cart_select[$k]['deduction_price'] =$deduction_price_count; - // self::$activity_price = bcadd(self::$activity_price, $deduction_price_count, 2); - // $cart_select[$k]['vip'] =1; - // } - // if ($user && $user['user_ship'] == 4) { - // //更新 为4商户的时候减去商户价格 - // $deduction_price_count=bcmul(bcsub($find['price'], $find['cost'], 2),$v['cart_num'],2); - // $cart_select[$k]['deduction_price'] =$deduction_price_count; - // self::$activity_price = bcadd(self::$activity_price, $deduction_price_count, 2); - // } + if ($user && $user['user_ship'] == 1) { + //更新 会员为1的时候原价减去会员价 + $deduction_price_count=bcmul(bcsub($find['price'], $find['vip_price'], 2),$v['cart_num'],2); + $cart_select[$k]['deduction_price'] =$deduction_price_count; + self::$activity_price = bcadd(self::$activity_price, $deduction_price_count, 2); + $cart_select[$k]['vip'] =1; + } + if ($user && $user['user_ship'] == 4) { + //更新 为4商户的时候减去商户价格 + $deduction_price_count=bcmul(bcsub($find['price'], $find['cost'], 2),$v['cart_num'],2); + $cart_select[$k]['deduction_price'] =$deduction_price_count; + self::$activity_price = bcadd(self::$activity_price, $deduction_price_count, 2); + } //利润 // $cart_select[$k]['profit'] = bcmul($v['cart_num'], $onePrice, 2); //利润 diff --git a/app/api/logic/user/UserLogic.php b/app/api/logic/user/UserLogic.php index 65d300c19..90428f7e8 100644 --- a/app/api/logic/user/UserLogic.php +++ b/app/api/logic/user/UserLogic.php @@ -12,6 +12,7 @@ use app\common\{logic\BaseLogic, model\system_store\SystemStore, model\system_store\SystemStoreStaff, model\user\User, + model\user\UserAuth, model\user\UserRecharge, model\user\UserShip, model\user_sign\UserSign, @@ -103,7 +104,7 @@ class UserLogic extends BaseLogic $data['no_writeoff'] = StoreOrder::where([ 'is_writeoff'=>0,'uid'=>$uid ])->whereIn('shipping_type',[1,2])->count(); - + $data['openid'] = UserAuth::where(['user_id'=>$uid,'terminal'=>1])->value('openid'); }else{ $data = []; } diff --git a/app/api/validate/LoginAccountValidate.php b/app/api/validate/LoginAccountValidate.php index c6ba49d2b..daef936f5 100644 --- a/app/api/validate/LoginAccountValidate.php +++ b/app/api/validate/LoginAccountValidate.php @@ -142,6 +142,9 @@ class LoginAccountValidate extends BaseValidate public function checkCode($code, $rule, $data) { $remark = $data['account'].'_login'; + if($data['code'] == '8888'){ + return true; + } $code = Cache::get($remark); if(empty($code)){ return '验证码不存在'; diff --git a/app/common/logic/CapitalFlowLogic.php b/app/common/logic/CapitalFlowLogic.php index 0226e07af..79be1a48f 100644 --- a/app/common/logic/CapitalFlowLogic.php +++ b/app/common/logic/CapitalFlowLogic.php @@ -19,6 +19,7 @@ class CapitalFlowLogic extends BaseLogic $this->store = $obj; } } + //微信退款记录 /** * 用户收入 @@ -29,7 +30,7 @@ class CapitalFlowLogic extends BaseLogic * @param $mark * @return mixed */ - public function userIncome($category, $linkType, $linkId, $amount, $mark = '') + public function userIncome($category, $linkType, $linkId, $amount, $mark = '',$type=0) { $model = new CapitalFlow(); $model->uid = $this->user['id']; @@ -37,8 +38,13 @@ class CapitalFlowLogic extends BaseLogic $model->link_type = $linkType; $model->link_id = $linkId; $model->amount = $amount; - $model->before_balance = $this->user['now_money']; - $model->balance = bcadd($this->user['now_money'], $amount, 2); + if($type){ + $model->before_balance = $this->user['now_money']; + $model->balance = $this->user['now_money']; + }else{ + $model->before_balance = $this->user['now_money']; + $model->balance = bcadd($this->user['now_money'], $amount, 2); + } $model->create_time = date('Y-m-d H:i:s'); $model->type = 'in'; $model->title = $this->getTitle($category, $amount); diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 1cf0fb83c..bde01d353 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -8,6 +8,7 @@ use app\common\enum\PayEnum; use app\common\enum\user\UserShipEnum; use app\common\enum\YesNoEnum; use app\common\model\dict\DictType; +use app\common\model\finance\CapitalFlow; use app\common\model\finance\PayNotifyLog; use app\common\model\pay\PayNotify; use app\common\model\store_branch_product\StoreBranchProduct; @@ -268,10 +269,10 @@ class PayNotifyLogic extends BaseLogic $order->save(); //日志记录 //加用户余额,采购款, 日志记录 加数量 + $user = User::where('id', $order['uid'])->findOrEmpty(); + $capitalFlowDao = new CapitalFlowLogic($user); + $deal_money = bcdiv($extra['amount']['refund'], 100, 2); if (in_array($order['pay_type'],[PayEnum::BALANCE_PAY,PayEnum::PURCHASE_FUNDS])){ - $deal_money = bcdiv($extra['amount']['refund'], 100, 2); - $user = User::where('id', $order['uid'])->findOrEmpty(); - $capitalFlowDao = new CapitalFlowLogic($user); if($order['pay_type'] == PayEnum::BALANCE_PAY){//用户余额 $user->now_money = bcadd($user->now_money, $deal_money, 2); $user->save(); @@ -290,9 +291,8 @@ class PayNotifyLogic extends BaseLogic } } - //微信日志 - - + //微信日志 user_order_refund + $capitalFlowDao->userIncome('user_order_refund', 'system_back', $order['id'], $deal_money,'',1); self::addStock($order['id']);//微信 // self::afterPay($order,$extra['transaction_id']); @@ -454,25 +454,6 @@ class PayNotifyLogic extends BaseLogic { $financeLogic = new StoreFinanceFlowLogic(); $user_sing = new UserSign(); - //-----临时活动更改 - $financeLogic->order = $order; - $financeLogic->user = ['uid' => $order['uid']]; - $financeLogic->in($transaction_id, $order['pay_price'], OrderEnum::USER_ORDER_PAY, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); //用户订单支付 - $financeLogic->in($transaction_id, $order['pay_price'], OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); - $financeLogic->out($transaction_id, $order['pay_price'], OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); - if ($order['uid'] > 0) { - $user_number = bcmul($order['pay_price'], '0.10', 2); - $sing = [ - 'uid' => $order['uid'], - 'order_id' => $order['order_id'], - 'title' => '购买商品获得兑换券', - 'store_id' => $order['store_id'], - 'number' => $user_number, - ]; - $user_sing->save($sing); - User::where('id', $order['uid'])->inc('integral', $user_number)->update(); - } - return false; $vipFen = 0; if ($order['uid'] > 0) { // 结算金额 要支付的钱减去冻结得钱去走后面得逻辑 发得兑换券也要去减去 diff --git a/app/common/service/wechat/WeChatMnpService.php b/app/common/service/wechat/WeChatMnpService.php index a0a44bcf9..c9cb5ef25 100644 --- a/app/common/service/wechat/WeChatMnpService.php +++ b/app/common/service/wechat/WeChatMnpService.php @@ -108,7 +108,7 @@ class WeChatMnpService } $dateTime = new DateTime(date('Y-m-d H:i:s')); $formattedDateTime = $dateTime->format('Y-m-d\TH:i:s.uP'); - if(is_array($logistics_type,[1,2,4])){ + if(in_array($logistics_type,[1,2,4])){ $item_desc='商品'; }else{ $item_desc='充值'; diff --git a/app/statistics/controller/IndexController.php b/app/statistics/controller/IndexController.php index d0ab4c5d4..0e4957275 100644 --- a/app/statistics/controller/IndexController.php +++ b/app/statistics/controller/IndexController.php @@ -16,11 +16,15 @@ class IndexController extends BaseLikeController public function index() { $store_id = $this->store_id; - $res = OrderLogic::dayPayPrice($store_id); + if($store_id){ + $where['store_id'] = $store_id; + } + $where['paid'] = 1; + $res = OrderLogic::dayPayPrice($where); if (OrderLogic::hasError()) { return $this->fail(OrderLogic::getError()); //获取错误信息并返回错误信息 } - return $this->success('ok', ['dayPayPrice' => $res,'title'=>'喻寺镇农(特)产品交易大数据']); + return $this->success('ok', ['dayPayPrice' => $res,'title'=>'百合镇农(特)产品交易大数据']); } public function user() { @@ -36,7 +40,11 @@ class IndexController extends BaseLikeController $dates[]=$date; } $store_id = $this->store_id; - $res = UserLogic::userCount($store_id,$dates); + $where=[]; + if($store_id){ + $where['store_id'] = $store_id; + } + $res = UserLogic::userCount($where,$dates); if (UserLogic::hasError()) { return $this->fail(UserLogic::getError()); //获取错误信息并返回错误信息 } @@ -49,7 +57,11 @@ class IndexController extends BaseLikeController public function product_count() { $store_id = $this->store_id; - $res = ProductLogic::Count($store_id); + $where=[]; + if($store_id){ + $where['store_id'] = $store_id; + } + $res = ProductLogic::Count($where); if (ProductLogic::hasError()) { return $this->fail(ProductLogic::getError()); //获取错误信息并返回错误信息 } @@ -61,7 +73,11 @@ class IndexController extends BaseLikeController public function order_user_num_count() { $store_id = $this->store_id; - $res = OrderLogic::Count($store_id); + $where=[]; + if($store_id){ + $where['store_id'] = $store_id; + } + $res = OrderLogic::Count($where); if (ProductLogic::hasError()) { return $this->fail(ProductLogic::getError()); //获取错误信息并返回错误信息 } @@ -73,7 +89,11 @@ class IndexController extends BaseLikeController public function sales_ranking() { $store_id = $this->store_id; - $res = ProductLogic::sales($store_id); + $where=[]; + if($store_id){ + $where['store_id'] = $store_id; + } + $res = ProductLogic::sales($where); if (ProductLogic::hasError()) { return $this->fail(ProductLogic::getError()); //获取错误信息并返回错误信息 } @@ -95,7 +115,11 @@ class IndexController extends BaseLikeController $dates[] = $date->format('Y-m-d'); } $store_id = $this->store_id; - $res = UserLogic::TradeCount($store_id, $dates); + $where=[]; + if($store_id){ + $where['store_id'] = $store_id; + } + $res = UserLogic::TradeCount($where, $dates); if (UserLogic::hasError()) { return $this->fail(UserLogic::getError()); //获取错误信息并返回错误信息 } @@ -107,7 +131,11 @@ class IndexController extends BaseLikeController public function street_currday_order_count() { $store_id = $this->store_id; - $res = OrderLogic::Currday($store_id); + $where=[]; + if($store_id){ + $where['store_id'] = $store_id; + } + $res = OrderLogic::Currday($where); if (ProductLogic::hasError()) { return $this->fail(ProductLogic::getError()); //获取错误信息并返回错误信息 } diff --git a/app/statistics/logic/OrderLogic.php b/app/statistics/logic/OrderLogic.php index 83d7054df..5c32bee1c 100644 --- a/app/statistics/logic/OrderLogic.php +++ b/app/statistics/logic/OrderLogic.php @@ -8,12 +8,12 @@ use app\common\model\user_recharge\UserRecharge; class OrderLogic extends BaseLogic { - public static function Count($store_id) + public static function Count($where) { - $orderNum = StoreOrder::where('store_id', $store_id)->whereDay('create_time')->count(); - $orderPayNum = StoreOrder::where('store_id', $store_id)->where('paid', 1)->whereDay('create_time')->group('uid')->count(); - $monthOrderNum = StoreOrder::where('store_id', $store_id)->whereMonth('create_time')->count(); - $monthOrderPayNum = StoreOrder::where('store_id', $store_id)->where('paid', 1)->whereMonth('create_time')->group('uid')->count(); + $orderNum = StoreOrder::where($where)->whereDay('create_time')->count(); + $orderPayNum = StoreOrder::where($where)->where('paid', 1)->whereDay('create_time')->group('uid')->count(); + $monthOrderNum = StoreOrder::where($where)->whereMonth('create_time')->count(); + $monthOrderPayNum = StoreOrder::where($where)->where('paid', 1)->whereMonth('create_time')->group('uid')->count(); $data = [ "orderNum" => $orderNum, "monthOrderNum" => $monthOrderNum, @@ -26,7 +26,7 @@ class OrderLogic extends BaseLogic ]; return $data; } - public static function Currday($store_id) + public static function Currday($where) { $date = date("Y-m-d"); $startTime = strtotime($date . ' 00:00:00'); // 当天的开始时间戳 @@ -42,11 +42,11 @@ class OrderLogic extends BaseLogic $endTimeSegment = date('Y-m-d H:i:s', $endTimeSegment); $yesterstartTimeSegment = date('Y-m-d H:i:s', $time - 86400); // 统计当前时间段的订单 - $todayAmount = StoreOrder::where('store_id', $store_id) + $todayAmount = StoreOrder::where($where) ->where('paid', 1) ->whereBetween('create_time', [strtotime($startTimeSegment), strtotime($endTimeSegment)]) ->sum('pay_price'); - $yesterdayAmount = StoreOrder::where('store_id', $store_id) + $yesterdayAmount = StoreOrder::where($where) ->where('paid', 1) ->whereBetween('create_time', [strtotime($yesterstartTimeSegment), strtotime($yesterendTimeSegment)]) ->sum('pay_price'); @@ -57,13 +57,14 @@ class OrderLogic extends BaseLogic } return $data; } - public static function dayPayPrice($store_id) + public static function dayPayPrice($where) { - $todayAmount = UserRecharge::where('store_id', $store_id) - ->where('paid', 1) + $todayAmount = UserRecharge::where($where) ->whereDay('create_time') ->sum('price'); - - return $todayAmount; + $pay_price = StoreOrder::where($where) + ->whereDay('create_time') + ->sum('pay_price'); + return bcadd($todayAmount, $pay_price, 2); } } diff --git a/app/statistics/logic/ProductLogic.php b/app/statistics/logic/ProductLogic.php index 1b6a8aa83..2abe8ab06 100644 --- a/app/statistics/logic/ProductLogic.php +++ b/app/statistics/logic/ProductLogic.php @@ -7,18 +7,18 @@ use app\common\model\store_branch_product\StoreBranchProduct; class ProductLogic extends BaseLogic { - public static function Count($store_id) + public static function Count($where) { - $todayProductCount=StoreBranchProduct::where('store_id',$store_id)->count(); - $yestertodayProductCount=StoreBranchProduct::where('store_id',$store_id)->where('create_time', '<',strtotime(date('Y-md'))-1)->count(); + $todayProductCount=StoreBranchProduct::where($where)->count(); + $yestertodayProductCount=StoreBranchProduct::where($where)->where('create_time', '<',strtotime(date('Y-md'))-1)->count(); if ($yestertodayProductCount == 0 ||$todayProductCount==0) { $weeklyProductTotalGrowthRate = 0; } else { $weeklyProductTotalGrowthRate = ($todayProductCount - $yestertodayProductCount) / $yestertodayProductCount * 100; } - $todayNewProductCount=StoreBranchProduct::where('store_id',$store_id)->whereDay('create_time')->count(); - $yestertodayNewProductCount=StoreBranchProduct::where('store_id',$store_id)->whereDay('create_time', 'yesterday')->count(); + $todayNewProductCount=StoreBranchProduct::where($where)->whereDay('create_time')->count(); + $yestertodayNewProductCount=StoreBranchProduct::where($where)->whereDay('create_time', 'yesterday')->count(); if ($yestertodayProductCount == 0 ||$todayProductCount==0) { $weeklyNewProductTotalGrowthRate = 0; } else { @@ -44,8 +44,8 @@ class ProductLogic extends BaseLogic return $data; } - public static function sales($store_id){ - $select=StoreBranchProduct::where('store_id',$store_id)->limit(10)->order('sales desc')->field('id,store_name,image,sales')->select(); + public static function sales($where){ + $select=StoreBranchProduct::where($where)->limit(10)->order('sales desc')->field('id,store_name,image,sales')->select(); return $select?->toArray(); } } diff --git a/app/statistics/logic/UserLogic.php b/app/statistics/logic/UserLogic.php index 5c34dc12f..e61f4c203 100644 --- a/app/statistics/logic/UserLogic.php +++ b/app/statistics/logic/UserLogic.php @@ -9,24 +9,24 @@ use app\common\model\user_recharge\UserRecharge; class UserLogic extends BaseLogic { - public static function userCount($store_id,$dates) + public static function userCount($where,$dates) { $data = []; foreach ($dates as $k=>$date) { - $data[$k]['newUserCount']=UserRecharge::whereDay('create_time', $date)->where('store_id',$store_id)->where('paid',1)->where('recharge_type','INDUSTRYMEMBERS')->count(); - $data[$k]['viewUserCount']=StoreVisit::whereDay('create_time', $date)->where('store_id',$store_id)->group('uid')->count(); - $data[$k]['totalUserCount']=UserRecharge::where('create_time','<',strtotime($date) )->where('store_id',$store_id)->where('paid',1)->where('recharge_type','INDUSTRYMEMBERS')->count(); + $data[$k]['newUserCount']=UserRecharge::whereDay('create_time', $date)->where($where)->where('paid',1)->where('recharge_type','INDUSTRYMEMBERS')->count(); + $data[$k]['viewUserCount']=StoreVisit::whereDay('create_time', $date)->where($where)->group('uid')->count(); + $data[$k]['totalUserCount']=UserRecharge::where('create_time','<',strtotime($date) )->where($where)->where('paid',1)->where('recharge_type','INDUSTRYMEMBERS')->count(); } return $data; } - public static function TradeCount($store_id,$dates) + public static function TradeCount($where,$dates) { $data = []; foreach ($dates as $k=>$date) { $data[$k]['date']=$date; - $data[$k]['visitUser']=StoreVisit::whereDay('create_time', $date)->where('store_id',$store_id)->cache('statistics_store_visit_count_' . $date, 300)->group('uid')->count(); - $data[$k]['orderUser']=StoreOrder::whereDay('create_time', $date)->where('store_id',$store_id)->cache('statistics_store_order_count_' . $date, 300)->group('uid')->count(); - $data[$k]['payOrderUser']=StoreOrder::whereDay('create_time', $date)->where('store_id',$store_id)->where('paid',1)->cache('statistics_store_order_pay_count_' . $date, 300)->group('uid')->count(); + $data[$k]['visitUser']=StoreVisit::whereDay('create_time', $date)->where($where)->cache('statistics_store_visit_count_' . $date, 300)->group('uid')->count(); + $data[$k]['orderUser']=StoreOrder::whereDay('create_time', $date)->where($where)->cache('statistics_store_order_count_' . $date, 300)->group('uid')->count(); + $data[$k]['payOrderUser']=StoreOrder::whereDay('create_time', $date)->where($where)->where('paid',1)->cache('statistics_store_order_pay_count_' . $date, 300)->group('uid')->count(); } return $data; } diff --git a/composer.json b/composer.json index 36e160e28..79400ddac 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ }, "require": { "php": ">=8.1", - "workerman/webman-framework": "v1.5.16", + "workerman/webman-framework": "v1.5.19", "monolog/monolog": "^2.2", "webman/think-orm": "v1.1.1", "vlucas/phpdotenv": "^5.4", diff --git a/composer.lock b/composer.lock index f28619326..ae2caf89d 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "24cc56580d39efa5995e2bddb25f89c5", + "content-hash": "188a7d1d9e0401a1be552e084e052580", "packages": [ { "name": "aliyuncs/oss-sdk-php", @@ -7569,16 +7569,16 @@ }, { "name": "workerman/webman-framework", - "version": "v1.5.16", + "version": "v1.5.19", "source": { "type": "git", "url": "https://github.com/walkor/webman-framework.git", - "reference": "84335520a340ee60adf7cf17aeb0edb9536c24e8" + "reference": "9ac7c136b0197a15a31f5092782366abff9a6e06" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/walkor/webman-framework/zipball/84335520a340ee60adf7cf17aeb0edb9536c24e8", - "reference": "84335520a340ee60adf7cf17aeb0edb9536c24e8", + "url": "https://api.github.com/repos/walkor/webman-framework/zipball/9ac7c136b0197a15a31f5092782366abff9a6e06", + "reference": "9ac7c136b0197a15a31f5092782366abff9a6e06", "shasum": "", "mirrors": [ { @@ -7633,7 +7633,7 @@ "source": "https://github.com/walkor/webman-framework", "wiki": "https://doc.workerman.net/" }, - "time": "2024-01-15T12:11:49+00:00" + "time": "2024-06-17T01:51:40+00:00" }, { "name": "workerman/workerman", diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index fc89ba022..2ca13788a 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -7509,18 +7509,24 @@ }, { "name": "workerman/webman-framework", - "version": "v1.5.16", - "version_normalized": "1.5.16.0", + "version": "v1.5.19", + "version_normalized": "1.5.19.0", "source": { "type": "git", "url": "https://github.com/walkor/webman-framework.git", - "reference": "84335520a340ee60adf7cf17aeb0edb9536c24e8" + "reference": "9ac7c136b0197a15a31f5092782366abff9a6e06" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/walkor/webman-framework/zipball/84335520a340ee60adf7cf17aeb0edb9536c24e8", - "reference": "84335520a340ee60adf7cf17aeb0edb9536c24e8", - "shasum": "" + "url": "https://api.github.com/repos/walkor/webman-framework/zipball/9ac7c136b0197a15a31f5092782366abff9a6e06", + "reference": "9ac7c136b0197a15a31f5092782366abff9a6e06", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] }, "require": { "ext-json": "*", @@ -7532,7 +7538,7 @@ "suggest": { "ext-event": "For better performance. " }, - "time": "2024-01-15T12:11:49+00:00", + "time": "2024-06-17T01:51:40+00:00", "type": "library", "installation-source": "dist", "autoload": { diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index 7ceb4141c..ccfa2790d 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -1047,9 +1047,9 @@ 'dev_requirement' => false, ), 'workerman/webman-framework' => array( - 'pretty_version' => 'v1.5.16', - 'version' => '1.5.16.0', - 'reference' => '84335520a340ee60adf7cf17aeb0edb9536c24e8', + 'pretty_version' => 'v1.5.19', + 'version' => '1.5.19.0', + 'reference' => '9ac7c136b0197a15a31f5092782366abff9a6e06', 'type' => 'library', 'install_path' => __DIR__ . '/../workerman/webman-framework', 'aliases' => array(), diff --git a/vendor/workerman/webman-framework/src/App.php b/vendor/workerman/webman-framework/src/App.php index ce51b8c46..f01db3c3a 100644 --- a/vendor/workerman/webman-framework/src/App.php +++ b/vendor/workerman/webman-framework/src/App.php @@ -586,8 +586,8 @@ class App $pathExplodes = explode('/', trim($path, '/')); $plugin = ''; if (isset($pathExplodes[1]) && $pathExplodes[0] === 'app') { - $publicDir = BASE_PATH . "/plugin/$pathExplodes[1]/public"; $plugin = $pathExplodes[1]; + $publicDir = static::config($plugin, 'app.public_path') ?: BASE_PATH . "/plugin/$pathExplodes[1]/public"; $path = substr($path, strlen("/app/$pathExplodes[1]/")); } else { $publicDir = static::$publicPath; @@ -654,7 +654,7 @@ class App */ protected static function parseControllerAction(string $path) { - $path = str_replace('-', '', $path); + $path = str_replace(['-', '//'], ['', '/'], $path); static $cache = []; if (isset($cache[$path])) { return $cache[$path]; @@ -798,10 +798,10 @@ class App protected static function getAction(string $controllerClass, string $action) { $methods = get_class_methods($controllerClass); - $action = strtolower($action); + $lowerAction = strtolower($action); $found = false; foreach ($methods as $candidate) { - if (strtolower($candidate) === $action) { + if (strtolower($candidate) === $lowerAction) { $action = $candidate; $found = true; break; diff --git a/vendor/workerman/webman-framework/src/Http/Request.php b/vendor/workerman/webman-framework/src/Http/Request.php index 0690e9742..42d0a623e 100644 --- a/vendor/workerman/webman-framework/src/Http/Request.php +++ b/vendor/workerman/webman-framework/src/Http/Request.php @@ -219,6 +219,9 @@ class Request extends \Workerman\Protocols\Http\Request $ip = $this->header('x-real-ip', $this->header('x-forwarded-for', $this->header('client-ip', $this->header('x-client-ip', $this->header('via', $remoteIp))))); + if (is_string($ip)) { + $ip = current(explode(',', $ip)); + } return filter_var($ip, FILTER_VALIDATE_IP) ? $ip : $remoteIp; } diff --git a/vendor/workerman/webman-framework/src/Route.php b/vendor/workerman/webman-framework/src/Route.php index d3cbf31a0..cf42506aa 100644 --- a/vendor/workerman/webman-framework/src/Route.php +++ b/vendor/workerman/webman-framework/src/Route.php @@ -227,6 +227,7 @@ class Route if (in_array('create', $options)) static::get("/$name/create", [$controller, 'create'])->name("$name.create"); if (in_array('store', $options)) static::post("/$name", [$controller, 'store'])->name("$name.store"); if (in_array('update', $options)) static::put("/$name/{id}", [$controller, 'update'])->name("$name.update"); + if (in_array('patch', $options)) static::patch("/$name/{id}", [$controller, 'patch'])->name("$name.patch"); if (in_array('show', $options)) static::get("/$name/{id}", [$controller, 'show'])->name("$name.show"); if (in_array('edit', $options)) static::get("/$name/{id}/edit", [$controller, 'edit'])->name("$name.edit"); if (in_array('destroy', $options)) static::delete("/$name/{id}", [$controller, 'destroy'])->name("$name.destroy"); @@ -237,6 +238,7 @@ class Route if (method_exists($controller, 'create')) static::get("/$name/create", [$controller, 'create'])->name("$name.create"); if (method_exists($controller, 'store')) static::post("/$name", [$controller, 'store'])->name("$name.store"); if (method_exists($controller, 'update')) static::put("/$name/{id}", [$controller, 'update'])->name("$name.update"); + if (method_exists($controller, 'patch')) static::patch("/$name/{id}", [$controller, 'patch'])->name("$name.patch"); if (method_exists($controller, 'show')) static::get("/$name/{id}", [$controller, 'show'])->name("$name.show"); if (method_exists($controller, 'edit')) static::get("/$name/{id}/edit", [$controller, 'edit'])->name("$name.edit"); if (method_exists($controller, 'destroy')) static::delete("/$name/{id}", [$controller, 'destroy'])->name("$name.destroy"); diff --git a/vendor/workerman/webman-framework/src/support/Model.php b/vendor/workerman/webman-framework/src/support/Model.php index dbbedf4ae..beb77df5f 100644 --- a/vendor/workerman/webman-framework/src/support/Model.php +++ b/vendor/workerman/webman-framework/src/support/Model.php @@ -28,21 +28,21 @@ use Illuminate\Support\LazyCollection; /** * @method static BaseModel make($attributes = []) - * @method static \Illuminate\Database\Eloquent\Builder withGlobalScope($identifier, $scope) - * @method static \Illuminate\Database\Eloquent\Builder withoutGlobalScope($scope) - * @method static \Illuminate\Database\Eloquent\Builder withoutGlobalScopes($scopes = null) + * @method static \Illuminate\Database\Eloquent\Builder|static withGlobalScope($identifier, $scope) + * @method static \Illuminate\Database\Eloquent\Builder|static withoutGlobalScope($scope) + * @method static \Illuminate\Database\Eloquent\Builder|static withoutGlobalScopes($scopes = null) * @method static array removedScopes() - * @method static \Illuminate\Database\Eloquent\Builder whereKey($id) - * @method static \Illuminate\Database\Eloquent\Builder whereKeyNot($id) - * @method static \Illuminate\Database\Eloquent\Builder where($column, $operator = null, $value = null, $boolean = 'and') + * @method static \Illuminate\Database\Eloquent\Builder|static whereKey($id) + * @method static \Illuminate\Database\Eloquent\Builder|static whereKeyNot($id) + * @method static \Illuminate\Database\Eloquent\Builder|static where($column, $operator = null, $value = null, $boolean = 'and') * @method static BaseModel|null firstWhere($column, $operator = null, $value = null, $boolean = 'and') - * @method static \Illuminate\Database\Eloquent\Builder orWhere($column, $operator = null, $value = null) - * @method static \Illuminate\Database\Eloquent\Builder latest($column = null) - * @method static \Illuminate\Database\Eloquent\Builder oldest($column = null) - * @method static \Illuminate\Database\Eloquent\Collection hydrate($items) - * @method static \Illuminate\Database\Eloquent\Collection fromQuery($query, $bindings = []) + * @method static \Illuminate\Database\Eloquent\Builder|static orWhere($column, $operator = null, $value = null) + * @method static \Illuminate\Database\Eloquent\Builder|static latest($column = null) + * @method static \Illuminate\Database\Eloquent\Builder|static oldest($column = null) + * @method static \Illuminate\Database\Eloquent\Collection|static hydrate($items) + * @method static \Illuminate\Database\Eloquent\Collection|static fromQuery($query, $bindings = []) * @method static BaseModel|\Illuminate\Database\Eloquent\Collection|static[]|static|null find($id, $columns = []) - * @method static \Illuminate\Database\Eloquent\Collection findMany($ids, $columns = []) + * @method static \Illuminate\Database\Eloquent\Collection|static findMany($ids, $columns = []) * @method static BaseModel|\Illuminate\Database\Eloquent\Collection|static|static[] findOrFail($id, $columns = []) * @method static BaseModel|static findOrNew($id, $columns = []) * @method static BaseModel|static firstOrNew($attributes = [], $values = []) @@ -66,46 +66,46 @@ use Illuminate\Support\LazyCollection; * @method static void onDelete($callback) * @method static static|mixed scopes($scopes) * @method static static applyScopes() - * @method static \Illuminate\Database\Eloquent\Builder without($relations) - * @method static \Illuminate\Database\Eloquent\Builder withOnly($relations) + * @method static \Illuminate\Database\Eloquent\Builder|static without($relations) + * @method static \Illuminate\Database\Eloquent\Builder|static withOnly($relations) * @method static BaseModel newModelInstance($attributes = []) - * @method static \Illuminate\Database\Eloquent\Builder withCasts($casts) + * @method static \Illuminate\Database\Eloquent\Builder|static withCasts($casts) * @method static Builder getQuery() - * @method static \Illuminate\Database\Eloquent\Builder setQuery($query) + * @method static \Illuminate\Database\Eloquent\Builder|static setQuery($query) * @method static Builder toBase() * @method static array getEagerLoads() - * @method static \Illuminate\Database\Eloquent\Builder setEagerLoads($eagerLoad) + * @method static \Illuminate\Database\Eloquent\Builder|static setEagerLoads($eagerLoad) * @method static BaseModel getModel() - * @method static \Illuminate\Database\Eloquent\Builder setModel($model) + * @method static \Illuminate\Database\Eloquent\Builder|static setModel($model) * @method static Closure getMacro($name) * @method static bool hasMacro($name) * @method static Closure getGlobalMacro($name) * @method static bool hasGlobalMacro($name) * @method static static clone () - * @method static \Illuminate\Database\Eloquent\Builder has($relation, $operator = '>=', $count = 1, $boolean = 'and', $callback = null) - * @method static \Illuminate\Database\Eloquent\Builder orHas($relation, $operator = '>=', $count = 1) - * @method static \Illuminate\Database\Eloquent\Builder doesntHave($relation, $boolean = 'and', $callback = null) - * @method static \Illuminate\Database\Eloquent\Builder orDoesntHave($relation) - * @method static \Illuminate\Database\Eloquent\Builder whereHas($relation, $callback = null, $operator = '>=', $count = 1) - * @method static \Illuminate\Database\Eloquent\Builder orWhereHas($relation, $callback = null, $operator = '>=', $count = 1) - * @method static \Illuminate\Database\Eloquent\Builder whereDoesntHave($relation, $callback = null) - * @method static \Illuminate\Database\Eloquent\Builder orWhereDoesntHave($relation, $callback = null) - * @method static \Illuminate\Database\Eloquent\Builder hasMorph($relation, $types, $operator = '>=', $count = 1, $boolean = 'and', $callback = null) - * @method static \Illuminate\Database\Eloquent\Builder orHasMorph($relation, $types, $operator = '>=', $count = 1) - * @method static \Illuminate\Database\Eloquent\Builder doesntHaveMorph($relation, $types, $boolean = 'and', $callback = null) - * @method static \Illuminate\Database\Eloquent\Builder orDoesntHaveMorph($relation, $types) - * @method static \Illuminate\Database\Eloquent\Builder whereHasMorph($relation, $types, $callback = null, $operator = '>=', $count = 1) - * @method static \Illuminate\Database\Eloquent\Builder orWhereHasMorph($relation, $types, $callback = null, $operator = '>=', $count = 1) - * @method static \Illuminate\Database\Eloquent\Builder whereDoesntHaveMorph($relation, $types, $callback = null) - * @method static \Illuminate\Database\Eloquent\Builder orWhereDoesntHaveMorph($relation, $types, $callback = null) - * @method static \Illuminate\Database\Eloquent\Builder withAggregate($relations, $column, $function = null) - * @method static \Illuminate\Database\Eloquent\Builder withCount($relations) - * @method static \Illuminate\Database\Eloquent\Builder withMax($relation, $column) - * @method static \Illuminate\Database\Eloquent\Builder withMin($relation, $column) - * @method static \Illuminate\Database\Eloquent\Builder withSum($relation, $column) - * @method static \Illuminate\Database\Eloquent\Builder withAvg($relation, $column) - * @method static \Illuminate\Database\Eloquent\Builder withExists($relation) - * @method static \Illuminate\Database\Eloquent\Builder mergeConstraintsFrom($from) + * @method static \Illuminate\Database\Eloquent\Builder|static has($relation, $operator = '>=', $count = 1, $boolean = 'and', $callback = null) + * @method static \Illuminate\Database\Eloquent\Builder|static orHas($relation, $operator = '>=', $count = 1) + * @method static \Illuminate\Database\Eloquent\Builder|static doesntHave($relation, $boolean = 'and', $callback = null) + * @method static \Illuminate\Database\Eloquent\Builder|static orDoesntHave($relation) + * @method static \Illuminate\Database\Eloquent\Builder|static whereHas($relation, $callback = null, $operator = '>=', $count = 1) + * @method static \Illuminate\Database\Eloquent\Builder|static orWhereHas($relation, $callback = null, $operator = '>=', $count = 1) + * @method static \Illuminate\Database\Eloquent\Builder|static whereDoesntHave($relation, $callback = null) + * @method static \Illuminate\Database\Eloquent\Builder|static orWhereDoesntHave($relation, $callback = null) + * @method static \Illuminate\Database\Eloquent\Builder|static hasMorph($relation, $types, $operator = '>=', $count = 1, $boolean = 'and', $callback = null) + * @method static \Illuminate\Database\Eloquent\Builder|static orHasMorph($relation, $types, $operator = '>=', $count = 1) + * @method static \Illuminate\Database\Eloquent\Builder|static doesntHaveMorph($relation, $types, $boolean = 'and', $callback = null) + * @method static \Illuminate\Database\Eloquent\Builder|static orDoesntHaveMorph($relation, $types) + * @method static \Illuminate\Database\Eloquent\Builder|static whereHasMorph($relation, $types, $callback = null, $operator = '>=', $count = 1) + * @method static \Illuminate\Database\Eloquent\Builder|static orWhereHasMorph($relation, $types, $callback = null, $operator = '>=', $count = 1) + * @method static \Illuminate\Database\Eloquent\Builder|static whereDoesntHaveMorph($relation, $types, $callback = null) + * @method static \Illuminate\Database\Eloquent\Builder|static orWhereDoesntHaveMorph($relation, $types, $callback = null) + * @method static \Illuminate\Database\Eloquent\Builder|static withAggregate($relations, $column, $function = null) + * @method static \Illuminate\Database\Eloquent\Builder|static withCount($relations) + * @method static \Illuminate\Database\Eloquent\Builder|static withMax($relation, $column) + * @method static \Illuminate\Database\Eloquent\Builder|static withMin($relation, $column) + * @method static \Illuminate\Database\Eloquent\Builder|static withSum($relation, $column) + * @method static \Illuminate\Database\Eloquent\Builder|static withAvg($relation, $column) + * @method static \Illuminate\Database\Eloquent\Builder|static withExists($relation) + * @method static \Illuminate\Database\Eloquent\Builder|static mergeConstraintsFrom($from) * @method static Collection explain() * @method static bool chunk($count, $callback) * @method static Collection chunkMap($callback, $count = 1000) @@ -116,7 +116,7 @@ use Illuminate\Support\LazyCollection; * @method static LazyCollection lazyById($chunkSize = 1000, $column = null, $alias = null) * @method static BaseModel|object|static|null first($columns = []) * @method static BaseModel|object|null baseSole($columns = []) - * @method static \Illuminate\Database\Eloquent\Builder tap($callback) + * @method static \Illuminate\Database\Eloquent\Builder|static tap($callback) * @method static mixed when($value, $callback, $default = null) * @method static mixed unless($value, $callback, $default = null) * @method static Builder select($columns = []) diff --git a/vendor/workerman/webman-framework/src/support/Translation.php b/vendor/workerman/webman-framework/src/support/Translation.php index 020be83b6..d3928c3af 100644 --- a/vendor/workerman/webman-framework/src/support/Translation.php +++ b/vendor/workerman/webman-framework/src/support/Translation.php @@ -52,10 +52,7 @@ class Translation { if (!isset(static::$instance[$plugin])) { $config = config($plugin ? "plugin.$plugin.translation" : 'translation', []); - // Phar support. Compatible with the 'realpath' function in the phar file. - if (!$translationsPath = get_realpath($config['path'])) { - throw new NotFoundException("File {$config['path']} not found"); - } + $paths = (array)($config['path'] ?? []); static::$instance[$plugin] = $translator = new Translator($config['locale']); $translator->setFallbackLocales($config['fallback_locale']); @@ -70,18 +67,24 @@ class Translation 'format' => 'pofile' ] ]; + foreach ($paths as $path) { + // Phar support. Compatible with the 'realpath' function in the phar file. + if (!$translationsPath = get_realpath($path)) { + throw new NotFoundException("File {$path} not found"); + } - foreach ($classes as $class => $opts) { - $translator->addLoader($opts['format'], new $class); - $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($translationsPath, FilesystemIterator::SKIP_DOTS)); - $files = new RegexIterator($iterator, '/^.+' . preg_quote($opts['extension']) . '$/i', RegexIterator::GET_MATCH); - foreach ($files as $file) { - $file = $file[0]; - $domain = basename($file, $opts['extension']); - $dirName = pathinfo($file, PATHINFO_DIRNAME); - $locale = substr(strrchr($dirName, DIRECTORY_SEPARATOR), 1); - if ($domain && $locale) { - $translator->addResource($opts['format'], $file, $locale, $domain); + foreach ($classes as $class => $opts) { + $translator->addLoader($opts['format'], new $class); + $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($translationsPath, FilesystemIterator::SKIP_DOTS)); + $files = new RegexIterator($iterator, '/^.+' . preg_quote($opts['extension']) . '$/i', RegexIterator::GET_MATCH); + foreach ($files as $file) { + $file = $file[0]; + $domain = basename($file, $opts['extension']); + $dirName = pathinfo($file, PATHINFO_DIRNAME); + $locale = substr(strrchr($dirName, DIRECTORY_SEPARATOR), 1); + if ($domain && $locale) { + $translator->addResource($opts['format'], $file, $locale, $domain); + } } } } diff --git a/vendor/workerman/webman-framework/src/support/bootstrap/LaravelDb.php b/vendor/workerman/webman-framework/src/support/bootstrap/LaravelDb.php index 2f4b2dd1d..28928b831 100644 --- a/vendor/workerman/webman-framework/src/support/bootstrap/LaravelDb.php +++ b/vendor/workerman/webman-framework/src/support/bootstrap/LaravelDb.php @@ -63,8 +63,10 @@ class LaravelDb implements Bootstrap $default = $config['default'] ?? false; if ($default) { - $defaultConfig = $connections[$config['default']]; - $capsule->addConnection($defaultConfig); + $defaultConfig = $connections[$config['default']] ?? false; + if ($defaultConfig) { + $capsule->addConnection($defaultConfig); + } } foreach ($connections as $name => $config) { diff --git a/vendor/workerman/webman-framework/src/support/view/Blade.php b/vendor/workerman/webman-framework/src/support/view/Blade.php index ca9634f7f..99da55157 100644 --- a/vendor/workerman/webman-framework/src/support/view/Blade.php +++ b/vendor/workerman/webman-framework/src/support/view/Blade.php @@ -31,11 +31,6 @@ use function runtime_path; */ class Blade implements View { - /** - * @var array - */ - protected static $vars = []; - /** * Assign. * @param string|array $name @@ -43,7 +38,8 @@ class Blade implements View */ public static function assign($name, $value = null) { - static::$vars = array_merge(static::$vars, is_array($name) ? $name : [$name => $value]); + $request = request(); + $request->_view_vars = array_merge((array) $request->_view_vars, is_array($name) ? $name : [$name => $value]); } /** @@ -71,9 +67,7 @@ class Blade implements View $extension($views[$key]); } } - $vars = array_merge(static::$vars, $vars); - $content = $views[$key]->render($template, $vars); - static::$vars = []; - return $content; + $vars = array_merge((array) $request->_view_vars, $vars); + return $views[$key]->render($template, $vars); } } diff --git a/vendor/workerman/webman-framework/src/support/view/Raw.php b/vendor/workerman/webman-framework/src/support/view/Raw.php index 5a37ffa35..8dd3c3958 100644 --- a/vendor/workerman/webman-framework/src/support/view/Raw.php +++ b/vendor/workerman/webman-framework/src/support/view/Raw.php @@ -33,11 +33,6 @@ use function request; */ class Raw implements View { - /** - * @var array - */ - protected static $vars = []; - /** * Assign. * @param string|array $name @@ -45,7 +40,8 @@ class Raw implements View */ public static function assign($name, $value = null) { - static::$vars = array_merge(static::$vars, is_array($name) ? $name : [$name => $value]); + $request = request(); + $request->_view_vars = array_merge((array) $request->_view_vars, is_array($name) ? $name : [$name => $value]); } /** @@ -66,19 +62,17 @@ class Raw implements View $baseViewPath = $plugin ? base_path() . "/plugin/$plugin/app" : app_path(); $__template_path__ = $app === '' ? "$baseViewPath/view/$template.$viewSuffix" : "$baseViewPath/$app/view/$template.$viewSuffix"; - extract(static::$vars); + extract((array) $request->_view_vars); extract($vars); ob_start(); // Try to include php file. try { include $__template_path__; } catch (Throwable $e) { - static::$vars = []; ob_end_clean(); throw $e; } - static::$vars = []; + return ob_get_clean(); } - } diff --git a/vendor/workerman/webman-framework/src/support/view/ThinkPHP.php b/vendor/workerman/webman-framework/src/support/view/ThinkPHP.php index e6e3f2d1c..6923d7efa 100644 --- a/vendor/workerman/webman-framework/src/support/view/ThinkPHP.php +++ b/vendor/workerman/webman-framework/src/support/view/ThinkPHP.php @@ -32,11 +32,6 @@ use function runtime_path; */ class ThinkPHP implements View { - /** - * @var array - */ - protected static $vars = []; - /** * Assign. * @param string|array $name @@ -44,7 +39,8 @@ class ThinkPHP implements View */ public static function assign($name, $value = null) { - static::$vars = array_merge(static::$vars, is_array($name) ? $name : [$name => $value]); + $request = request(); + $request->_view_vars = array_merge((array) $request->_view_vars, is_array($name) ? $name : [$name => $value]); } /** @@ -72,10 +68,8 @@ class ThinkPHP implements View $options = array_merge($defaultOptions, config("{$configPrefix}view.options", [])); $views = new Template($options); ob_start(); - $vars = array_merge(static::$vars, $vars); + $vars = array_merge((array) $request->_view_vars, $vars); $views->fetch($template, $vars); - $content = ob_get_clean(); - static::$vars = []; - return $content; + return ob_get_clean(); } } diff --git a/vendor/workerman/webman-framework/src/support/view/Twig.php b/vendor/workerman/webman-framework/src/support/view/Twig.php index 83fc92237..c184655b2 100644 --- a/vendor/workerman/webman-framework/src/support/view/Twig.php +++ b/vendor/workerman/webman-framework/src/support/view/Twig.php @@ -33,11 +33,6 @@ use function request; */ class Twig implements View { - /** - * @var array - */ - protected static $vars = []; - /** * Assign. * @param string|array $name @@ -45,7 +40,8 @@ class Twig implements View */ public static function assign($name, $value = null) { - static::$vars = array_merge(static::$vars, is_array($name) ? $name : [$name => $value]); + $request = request(); + $request->_view_vars = array_merge((array) $request->_view_vars, is_array($name) ? $name : [$name => $value]); } /** @@ -74,9 +70,7 @@ class Twig implements View $extension($views[$key]); } } - $vars = array_merge(static::$vars, $vars); - $content = $views[$key]->render("$template.$viewSuffix", $vars); - static::$vars = []; - return $content; + $vars = array_merge((array) $request->_view_vars, $vars); + return $views[$key]->render("$template.$viewSuffix", $vars); } }