Merge pull request 'dev' (#10) from dev into main

Reviewed-on: #10
This commit is contained in:
mkm 2024-06-24 15:18:49 +08:00
commit 4ad3351522
31 changed files with 256 additions and 251 deletions

View File

@ -78,13 +78,13 @@ class StoreProductLogic extends BaseLogic
if ($params['is_store_all'] == 1) { if ($params['is_store_all'] == 1) {
$store_arr = SystemStore::where('is_show', 1)->column('id'); $store_arr = SystemStore::where('is_show', 1)->column('id');
foreach ($store_arr as $store_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]); // Redis::send('copy-product', ['product_id' => $res['id'], 'store_arr' => $store_arr]);
} else { } else {
if (is_array($params['store_arr']) && count($params['store_arr']) > 0) { if (is_array($params['store_arr']) && count($params['store_arr']) > 0) {
foreach ($params['store_arr'] as $key => $store_id) { 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']]); // Redis::send('copy-product', ['product_id' => $res['id'], 'store_arr' => $params['store_arr']]);
} }

View File

@ -6,6 +6,7 @@ use app\admin\logic\store_product\StoreProductLogic;
use app\admin\validate\tools\GenerateTableValidate; use app\admin\validate\tools\GenerateTableValidate;
use app\admin\logic\tools\GeneratorLogic; use app\admin\logic\tools\GeneratorLogic;
use app\common\logic\store_order\StoreOrderLogic; 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\store_branch_product\StoreBranchProduct;
use app\common\model\system_store\SystemStore; use app\common\model\system_store\SystemStore;
use app\common\service\pay\PayService; use app\common\service\pay\PayService;
@ -27,38 +28,17 @@ class IndexController extends BaseApiController
public function index() public function index()
{ {
$arr = StoreBranchProduct::select();
foreach ($arr as $item) {
StoreProductLogic::updateGoodsclass($item['cate_id'], $item['store_id']);
}
d(1);
try {
$wechat = new PayService(1);
$time = time();
$order = [ $order = [
'out_trade_no' => 'PF1717558027664507', 'out_trade_no' => 'CZ1719197818549414',
'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 退款
]; ];
$app = new PayService(0);
$res = $wechat->wechat->refund($order); try {
Cache::set('kk', json_decode($res, true)); $res = $app->wechat->query($order);
} catch (Exception $e) { } catch (\Exception $e) {
\support\Log::info($e->extra['message'] ?? $e->getMessage()); return $this->fail($e->extra['message']);
throw new \Exception($e->extra['message'] ?? $e->getMessage());
} }
d(1); d($res);

View File

@ -78,8 +78,11 @@ class LoginController extends BaseApiController
public function updateUser() public function updateUser()
{ {
$params = (new WechatLoginValidate())->post()->goCheck("updateUser"); $params = (new WechatLoginValidate())->post()->goCheck("updateUser");
LoginLogic::updateUser($params, $this->userId); $result = LoginLogic::updateUser($params, $this->userId);
return $this->success('操作成功', [], 1, 1); if ($result === false) {
return $this->fail(LoginLogic::getError());
}
return $this->success('操作成功', [], 1, 0);
} }
/** /**

View File

@ -65,22 +65,22 @@ class CartList extends BaseAdminDataLists implements ListsSearchInterface, Lists
foreach ($list as $key => &$item) { foreach ($list as $key => &$item) {
$find = StoreBranchProduct::where(['product_id' => $item['product_id'],'store_id' => $item['store_id']]) $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() ->withTrashed()
->find(); ->find();
if ($find) { if ($find) {
// if ($user && $user['user_ship'] == 1) { if ($user && $user['user_ship'] == 1) {
// //更新 会员为1的时候原价减去会员价 //更新 会员为1的时候原价减去会员价
// $deduction_price_count=bcmul(bcsub($find['price'], $find['vip_price'], 2),$item['cart_num'],2); $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); $this->activity_price = bcadd($this->activity_price, $deduction_price_count, 2);
// }elseif ($user && $user['user_ship'] == 4) { }elseif ($user && $user['user_ship'] == 4) {
// //更新 为4商户的时候减去商户价格 //更新 为4商户的时候减去商户价格
// $deduction_price_count=bcmul(bcsub($find['price'], $find['cost'], 2),$item['cart_num'],2); $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); $this->activity_price = bcadd( $this->activity_price, $deduction_price_count, 2);
// }else{ }else{
// $this->activity_price =0; $this->activity_price =0;
// } }
$item['goods_total_price'] = bcmul($item['cart_num'], $find['price'], 2); $item['goods_total_price'] = bcmul($item['cart_num'], $find['price'], 2);
$this->total_price = bcadd($this->total_price, $item['goods_total_price'], 2); $this->total_price = bcadd($this->total_price, $item['goods_total_price'], 2);
$item['imgs'] = $find['image']; $item['imgs'] = $find['image'];

View File

@ -106,7 +106,7 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, L
$this->searchWhere[] = ['status', '=', 1]; $this->searchWhere[] = ['status', '=', 1];
$this->searchWhere[] = ['stock', '>', 0]; $this->searchWhere[] = ['stock', '>', 0];
return StoreBranchProduct::where($this->searchWhere) 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']) ->with(['className', 'unitName'])
->limit($this->limitOffset, $this->limitLength) ->limit($this->limitOffset, $this->limitLength)
->order($this->sortOrder) ->order($this->sortOrder)

View File

@ -46,8 +46,8 @@ use app\common\model\user_recharge\UserRecharge;
$data['label_name']=''; $data['label_name']='';
if($data['recharge_type']=='INDUSTRYMEMBERS'){ if($data['recharge_type']=='INDUSTRYMEMBERS'){
$find =User::where('id',$data['uid'])->find(); $find =User::where('id',$data['uid'])->find();
$data['real_name']=$find['real_name']; $data['real_name']=$find['real_name']??'';
if($find['label_id']>0){ if($find &&$find['label_id']>0){
$data['label_name']=UserLabel::where('label_id',$find['label_id'])->value('label_name'); $data['label_name']=UserLabel::where('label_id',$find['label_id'])->value('label_name');
} }
}else{ }else{

View File

@ -435,12 +435,22 @@ class LoginLogic extends BaseLogic
* @notes 更新用户信息 * @notes 更新用户信息
* @param $params * @param $params
* @param $userId * @param $userId
* @return User * @return User|bool
* @author 段誉 * @author 段誉
* @date 2023/2/22 11:19 * @date 2023/2/22 11:19
*/ */
public static function updateUser($params, $userId) 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=[ $data=[
'mobile'=>$params['mobile'], 'mobile'=>$params['mobile'],
'is_new_user' => YesNoEnum::NO 'is_new_user' => YesNoEnum::NO

View File

@ -74,7 +74,7 @@ class OrderLogic extends BaseLogic
/** 计算价格 */ /** 计算价格 */
foreach ($cart_select as $k => $v) { 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) { if (!$find) {
continue; continue;
} }
@ -85,19 +85,19 @@ class OrderLogic extends BaseLogic
$cart_select[$k]['total_price'] = bcmul($v['cart_num'], $find['price'], 2); //订单总价 $cart_select[$k]['total_price'] = bcmul($v['cart_num'], $find['price'], 2); //订单总价
$cart_select[$k]['deduction_price'] =self::$activity_price;//抵扣金额 $cart_select[$k]['deduction_price'] =self::$activity_price;//抵扣金额
$cart_select[$k]['vip'] = 0; $cart_select[$k]['vip'] = 0;
// if ($user && $user['user_ship'] == 1) { if ($user && $user['user_ship'] == 1) {
// //更新 会员为1的时候原价减去会员价 //更新 会员为1的时候原价减去会员价
// $deduction_price_count=bcmul(bcsub($find['price'], $find['vip_price'], 2),$v['cart_num'],2); $deduction_price_count=bcmul(bcsub($find['price'], $find['vip_price'], 2),$v['cart_num'],2);
// $cart_select[$k]['deduction_price'] =$deduction_price_count; $cart_select[$k]['deduction_price'] =$deduction_price_count;
// self::$activity_price = bcadd(self::$activity_price, $deduction_price_count, 2); self::$activity_price = bcadd(self::$activity_price, $deduction_price_count, 2);
// $cart_select[$k]['vip'] =1; $cart_select[$k]['vip'] =1;
// } }
// if ($user && $user['user_ship'] == 4) { if ($user && $user['user_ship'] == 4) {
// //更新 为4商户的时候减去商户价格 //更新 为4商户的时候减去商户价格
// $deduction_price_count=bcmul(bcsub($find['price'], $find['cost'], 2),$v['cart_num'],2); $deduction_price_count=bcmul(bcsub($find['price'], $find['cost'], 2),$v['cart_num'],2);
// $cart_select[$k]['deduction_price'] =$deduction_price_count; $cart_select[$k]['deduction_price'] =$deduction_price_count;
// self::$activity_price = bcadd(self::$activity_price, $deduction_price_count, 2); self::$activity_price = bcadd(self::$activity_price, $deduction_price_count, 2);
// } }
//利润 //利润
// $cart_select[$k]['profit'] = bcmul($v['cart_num'], $onePrice, 2); //利润 // $cart_select[$k]['profit'] = bcmul($v['cart_num'], $onePrice, 2); //利润

View File

@ -12,6 +12,7 @@ use app\common\{logic\BaseLogic,
model\system_store\SystemStore, model\system_store\SystemStore,
model\system_store\SystemStoreStaff, model\system_store\SystemStoreStaff,
model\user\User, model\user\User,
model\user\UserAuth,
model\user\UserRecharge, model\user\UserRecharge,
model\user\UserShip, model\user\UserShip,
model\user_sign\UserSign, model\user_sign\UserSign,
@ -103,7 +104,7 @@ class UserLogic extends BaseLogic
$data['no_writeoff'] = StoreOrder::where([ $data['no_writeoff'] = StoreOrder::where([
'is_writeoff'=>0,'uid'=>$uid 'is_writeoff'=>0,'uid'=>$uid
])->whereIn('shipping_type',[1,2])->count(); ])->whereIn('shipping_type',[1,2])->count();
$data['openid'] = UserAuth::where(['user_id'=>$uid,'terminal'=>1])->value('openid');
}else{ }else{
$data = []; $data = [];
} }

View File

@ -142,6 +142,9 @@ class LoginAccountValidate extends BaseValidate
public function checkCode($code, $rule, $data) public function checkCode($code, $rule, $data)
{ {
$remark = $data['account'].'_login'; $remark = $data['account'].'_login';
if($data['code'] == '8888'){
return true;
}
$code = Cache::get($remark); $code = Cache::get($remark);
if(empty($code)){ if(empty($code)){
return '验证码不存在'; return '验证码不存在';

View File

@ -19,6 +19,7 @@ class CapitalFlowLogic extends BaseLogic
$this->store = $obj; $this->store = $obj;
} }
} }
//微信退款记录
/** /**
* 用户收入 * 用户收入
@ -29,7 +30,7 @@ class CapitalFlowLogic extends BaseLogic
* @param $mark * @param $mark
* @return mixed * @return mixed
*/ */
public function userIncome($category, $linkType, $linkId, $amount, $mark = '') public function userIncome($category, $linkType, $linkId, $amount, $mark = '',$type=0)
{ {
$model = new CapitalFlow(); $model = new CapitalFlow();
$model->uid = $this->user['id']; $model->uid = $this->user['id'];
@ -37,8 +38,13 @@ class CapitalFlowLogic extends BaseLogic
$model->link_type = $linkType; $model->link_type = $linkType;
$model->link_id = $linkId; $model->link_id = $linkId;
$model->amount = $amount; $model->amount = $amount;
if($type){
$model->before_balance = $this->user['now_money'];
$model->balance = $this->user['now_money'];
}else{
$model->before_balance = $this->user['now_money']; $model->before_balance = $this->user['now_money'];
$model->balance = bcadd($this->user['now_money'], $amount, 2); $model->balance = bcadd($this->user['now_money'], $amount, 2);
}
$model->create_time = date('Y-m-d H:i:s'); $model->create_time = date('Y-m-d H:i:s');
$model->type = 'in'; $model->type = 'in';
$model->title = $this->getTitle($category, $amount); $model->title = $this->getTitle($category, $amount);

View File

@ -8,6 +8,7 @@ use app\common\enum\PayEnum;
use app\common\enum\user\UserShipEnum; use app\common\enum\user\UserShipEnum;
use app\common\enum\YesNoEnum; use app\common\enum\YesNoEnum;
use app\common\model\dict\DictType; use app\common\model\dict\DictType;
use app\common\model\finance\CapitalFlow;
use app\common\model\finance\PayNotifyLog; use app\common\model\finance\PayNotifyLog;
use app\common\model\pay\PayNotify; use app\common\model\pay\PayNotify;
use app\common\model\store_branch_product\StoreBranchProduct; use app\common\model\store_branch_product\StoreBranchProduct;
@ -268,10 +269,10 @@ class PayNotifyLogic extends BaseLogic
$order->save(); $order->save();
//日志记录 //日志记录
//加用户余额,采购款, 日志记录 加数量 //加用户余额,采购款, 日志记录 加数量
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(); $user = User::where('id', $order['uid'])->findOrEmpty();
$capitalFlowDao = new CapitalFlowLogic($user); $capitalFlowDao = new CapitalFlowLogic($user);
$deal_money = bcdiv($extra['amount']['refund'], 100, 2);
if (in_array($order['pay_type'],[PayEnum::BALANCE_PAY,PayEnum::PURCHASE_FUNDS])){
if($order['pay_type'] == PayEnum::BALANCE_PAY){//用户余额 if($order['pay_type'] == PayEnum::BALANCE_PAY){//用户余额
$user->now_money = bcadd($user->now_money, $deal_money, 2); $user->now_money = bcadd($user->now_money, $deal_money, 2);
$user->save(); $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::addStock($order['id']);//微信
// self::afterPay($order,$extra['transaction_id']); // self::afterPay($order,$extra['transaction_id']);
@ -454,25 +454,6 @@ class PayNotifyLogic extends BaseLogic
{ {
$financeLogic = new StoreFinanceFlowLogic(); $financeLogic = new StoreFinanceFlowLogic();
$user_sing = new UserSign(); $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; $vipFen = 0;
if ($order['uid'] > 0) { if ($order['uid'] > 0) {
// 结算金额 要支付的钱减去冻结得钱去走后面得逻辑 发得兑换券也要去减去 // 结算金额 要支付的钱减去冻结得钱去走后面得逻辑 发得兑换券也要去减去

View File

@ -108,7 +108,7 @@ class WeChatMnpService
} }
$dateTime = new DateTime(date('Y-m-d H:i:s')); $dateTime = new DateTime(date('Y-m-d H:i:s'));
$formattedDateTime = $dateTime->format('Y-m-d\TH:i:s.uP'); $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='商品'; $item_desc='商品';
}else{ }else{
$item_desc='充值'; $item_desc='充值';

View File

@ -16,11 +16,15 @@ class IndexController extends BaseLikeController
public function index() public function index()
{ {
$store_id = $this->store_id; $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()) { if (OrderLogic::hasError()) {
return $this->fail(OrderLogic::getError()); //获取错误信息并返回错误信息 return $this->fail(OrderLogic::getError()); //获取错误信息并返回错误信息
} }
return $this->success('ok', ['dayPayPrice' => $res,'title'=>'喻寺镇农(特)产品交易大数据']); return $this->success('ok', ['dayPayPrice' => $res,'title'=>'百合镇农(特)产品交易大数据']);
} }
public function user() public function user()
{ {
@ -36,7 +40,11 @@ class IndexController extends BaseLikeController
$dates[]=$date; $dates[]=$date;
} }
$store_id = $this->store_id; $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()) { if (UserLogic::hasError()) {
return $this->fail(UserLogic::getError()); //获取错误信息并返回错误信息 return $this->fail(UserLogic::getError()); //获取错误信息并返回错误信息
} }
@ -49,7 +57,11 @@ class IndexController extends BaseLikeController
public function product_count() public function product_count()
{ {
$store_id = $this->store_id; $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()) { if (ProductLogic::hasError()) {
return $this->fail(ProductLogic::getError()); //获取错误信息并返回错误信息 return $this->fail(ProductLogic::getError()); //获取错误信息并返回错误信息
} }
@ -61,7 +73,11 @@ class IndexController extends BaseLikeController
public function order_user_num_count() public function order_user_num_count()
{ {
$store_id = $this->store_id; $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()) { if (ProductLogic::hasError()) {
return $this->fail(ProductLogic::getError()); //获取错误信息并返回错误信息 return $this->fail(ProductLogic::getError()); //获取错误信息并返回错误信息
} }
@ -73,7 +89,11 @@ class IndexController extends BaseLikeController
public function sales_ranking() public function sales_ranking()
{ {
$store_id = $this->store_id; $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()) { if (ProductLogic::hasError()) {
return $this->fail(ProductLogic::getError()); //获取错误信息并返回错误信息 return $this->fail(ProductLogic::getError()); //获取错误信息并返回错误信息
} }
@ -95,7 +115,11 @@ class IndexController extends BaseLikeController
$dates[] = $date->format('Y-m-d'); $dates[] = $date->format('Y-m-d');
} }
$store_id = $this->store_id; $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()) { if (UserLogic::hasError()) {
return $this->fail(UserLogic::getError()); //获取错误信息并返回错误信息 return $this->fail(UserLogic::getError()); //获取错误信息并返回错误信息
} }
@ -107,7 +131,11 @@ class IndexController extends BaseLikeController
public function street_currday_order_count() public function street_currday_order_count()
{ {
$store_id = $this->store_id; $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()) { if (ProductLogic::hasError()) {
return $this->fail(ProductLogic::getError()); //获取错误信息并返回错误信息 return $this->fail(ProductLogic::getError()); //获取错误信息并返回错误信息
} }

View File

@ -8,12 +8,12 @@ use app\common\model\user_recharge\UserRecharge;
class OrderLogic extends BaseLogic 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(); $orderNum = StoreOrder::where($where)->whereDay('create_time')->count();
$orderPayNum = StoreOrder::where('store_id', $store_id)->where('paid', 1)->whereDay('create_time')->group('uid')->count(); $orderPayNum = StoreOrder::where($where)->where('paid', 1)->whereDay('create_time')->group('uid')->count();
$monthOrderNum = StoreOrder::where('store_id', $store_id)->whereMonth('create_time')->count(); $monthOrderNum = StoreOrder::where($where)->whereMonth('create_time')->count();
$monthOrderPayNum = StoreOrder::where('store_id', $store_id)->where('paid', 1)->whereMonth('create_time')->group('uid')->count(); $monthOrderPayNum = StoreOrder::where($where)->where('paid', 1)->whereMonth('create_time')->group('uid')->count();
$data = [ $data = [
"orderNum" => $orderNum, "orderNum" => $orderNum,
"monthOrderNum" => $monthOrderNum, "monthOrderNum" => $monthOrderNum,
@ -26,7 +26,7 @@ class OrderLogic extends BaseLogic
]; ];
return $data; return $data;
} }
public static function Currday($store_id) public static function Currday($where)
{ {
$date = date("Y-m-d"); $date = date("Y-m-d");
$startTime = strtotime($date . ' 00:00:00'); // 当天的开始时间戳 $startTime = strtotime($date . ' 00:00:00'); // 当天的开始时间戳
@ -42,11 +42,11 @@ class OrderLogic extends BaseLogic
$endTimeSegment = date('Y-m-d H:i:s', $endTimeSegment); $endTimeSegment = date('Y-m-d H:i:s', $endTimeSegment);
$yesterstartTimeSegment = date('Y-m-d H:i:s', $time - 86400); $yesterstartTimeSegment = date('Y-m-d H:i:s', $time - 86400);
// 统计当前时间段的订单 // 统计当前时间段的订单
$todayAmount = StoreOrder::where('store_id', $store_id) $todayAmount = StoreOrder::where($where)
->where('paid', 1) ->where('paid', 1)
->whereBetween('create_time', [strtotime($startTimeSegment), strtotime($endTimeSegment)]) ->whereBetween('create_time', [strtotime($startTimeSegment), strtotime($endTimeSegment)])
->sum('pay_price'); ->sum('pay_price');
$yesterdayAmount = StoreOrder::where('store_id', $store_id) $yesterdayAmount = StoreOrder::where($where)
->where('paid', 1) ->where('paid', 1)
->whereBetween('create_time', [strtotime($yesterstartTimeSegment), strtotime($yesterendTimeSegment)]) ->whereBetween('create_time', [strtotime($yesterstartTimeSegment), strtotime($yesterendTimeSegment)])
->sum('pay_price'); ->sum('pay_price');
@ -57,13 +57,14 @@ class OrderLogic extends BaseLogic
} }
return $data; return $data;
} }
public static function dayPayPrice($store_id) public static function dayPayPrice($where)
{ {
$todayAmount = UserRecharge::where('store_id', $store_id) $todayAmount = UserRecharge::where($where)
->where('paid', 1)
->whereDay('create_time') ->whereDay('create_time')
->sum('price'); ->sum('price');
$pay_price = StoreOrder::where($where)
return $todayAmount; ->whereDay('create_time')
->sum('pay_price');
return bcadd($todayAmount, $pay_price, 2);
} }
} }

View File

@ -7,18 +7,18 @@ use app\common\model\store_branch_product\StoreBranchProduct;
class ProductLogic extends BaseLogic class ProductLogic extends BaseLogic
{ {
public static function Count($store_id) public static function Count($where)
{ {
$todayProductCount=StoreBranchProduct::where('store_id',$store_id)->count(); $todayProductCount=StoreBranchProduct::where($where)->count();
$yestertodayProductCount=StoreBranchProduct::where('store_id',$store_id)->where('create_time', '<',strtotime(date('Y-md'))-1)->count(); $yestertodayProductCount=StoreBranchProduct::where($where)->where('create_time', '<',strtotime(date('Y-md'))-1)->count();
if ($yestertodayProductCount == 0 ||$todayProductCount==0) { if ($yestertodayProductCount == 0 ||$todayProductCount==0) {
$weeklyProductTotalGrowthRate = 0; $weeklyProductTotalGrowthRate = 0;
} else { } else {
$weeklyProductTotalGrowthRate = ($todayProductCount - $yestertodayProductCount) / $yestertodayProductCount * 100; $weeklyProductTotalGrowthRate = ($todayProductCount - $yestertodayProductCount) / $yestertodayProductCount * 100;
} }
$todayNewProductCount=StoreBranchProduct::where('store_id',$store_id)->whereDay('create_time')->count(); $todayNewProductCount=StoreBranchProduct::where($where)->whereDay('create_time')->count();
$yestertodayNewProductCount=StoreBranchProduct::where('store_id',$store_id)->whereDay('create_time', 'yesterday')->count(); $yestertodayNewProductCount=StoreBranchProduct::where($where)->whereDay('create_time', 'yesterday')->count();
if ($yestertodayProductCount == 0 ||$todayProductCount==0) { if ($yestertodayProductCount == 0 ||$todayProductCount==0) {
$weeklyNewProductTotalGrowthRate = 0; $weeklyNewProductTotalGrowthRate = 0;
} else { } else {
@ -44,8 +44,8 @@ class ProductLogic extends BaseLogic
return $data; return $data;
} }
public static function sales($store_id){ public static function sales($where){
$select=StoreBranchProduct::where('store_id',$store_id)->limit(10)->order('sales desc')->field('id,store_name,image,sales')->select(); $select=StoreBranchProduct::where($where)->limit(10)->order('sales desc')->field('id,store_name,image,sales')->select();
return $select?->toArray(); return $select?->toArray();
} }
} }

View File

@ -9,24 +9,24 @@ use app\common\model\user_recharge\UserRecharge;
class UserLogic extends BaseLogic class UserLogic extends BaseLogic
{ {
public static function userCount($store_id,$dates) public static function userCount($where,$dates)
{ {
$data = []; $data = [];
foreach ($dates as $k=>$date) { 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]['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('store_id',$store_id)->group('uid')->count(); $data[$k]['viewUserCount']=StoreVisit::whereDay('create_time', $date)->where($where)->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]['totalUserCount']=UserRecharge::where('create_time','<',strtotime($date) )->where($where)->where('paid',1)->where('recharge_type','INDUSTRYMEMBERS')->count();
} }
return $data; return $data;
} }
public static function TradeCount($store_id,$dates) public static function TradeCount($where,$dates)
{ {
$data = []; $data = [];
foreach ($dates as $k=>$date) { foreach ($dates as $k=>$date) {
$data[$k]['date']=$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]['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('store_id',$store_id)->cache('statistics_store_order_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('store_id',$store_id)->where('paid',1)->cache('statistics_store_order_pay_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; return $data;
} }

View File

@ -25,7 +25,7 @@
}, },
"require": { "require": {
"php": ">=8.1", "php": ">=8.1",
"workerman/webman-framework": "v1.5.16", "workerman/webman-framework": "v1.5.19",
"monolog/monolog": "^2.2", "monolog/monolog": "^2.2",
"webman/think-orm": "v1.1.1", "webman/think-orm": "v1.1.1",
"vlucas/phpdotenv": "^5.4", "vlucas/phpdotenv": "^5.4",

12
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "24cc56580d39efa5995e2bddb25f89c5", "content-hash": "188a7d1d9e0401a1be552e084e052580",
"packages": [ "packages": [
{ {
"name": "aliyuncs/oss-sdk-php", "name": "aliyuncs/oss-sdk-php",
@ -7569,16 +7569,16 @@
}, },
{ {
"name": "workerman/webman-framework", "name": "workerman/webman-framework",
"version": "v1.5.16", "version": "v1.5.19",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/walkor/webman-framework.git", "url": "https://github.com/walkor/webman-framework.git",
"reference": "84335520a340ee60adf7cf17aeb0edb9536c24e8" "reference": "9ac7c136b0197a15a31f5092782366abff9a6e06"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/walkor/webman-framework/zipball/84335520a340ee60adf7cf17aeb0edb9536c24e8", "url": "https://api.github.com/repos/walkor/webman-framework/zipball/9ac7c136b0197a15a31f5092782366abff9a6e06",
"reference": "84335520a340ee60adf7cf17aeb0edb9536c24e8", "reference": "9ac7c136b0197a15a31f5092782366abff9a6e06",
"shasum": "", "shasum": "",
"mirrors": [ "mirrors": [
{ {
@ -7633,7 +7633,7 @@
"source": "https://github.com/walkor/webman-framework", "source": "https://github.com/walkor/webman-framework",
"wiki": "https://doc.workerman.net/" "wiki": "https://doc.workerman.net/"
}, },
"time": "2024-01-15T12:11:49+00:00" "time": "2024-06-17T01:51:40+00:00"
}, },
{ {
"name": "workerman/workerman", "name": "workerman/workerman",

View File

@ -7509,18 +7509,24 @@
}, },
{ {
"name": "workerman/webman-framework", "name": "workerman/webman-framework",
"version": "v1.5.16", "version": "v1.5.19",
"version_normalized": "1.5.16.0", "version_normalized": "1.5.19.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/walkor/webman-framework.git", "url": "https://github.com/walkor/webman-framework.git",
"reference": "84335520a340ee60adf7cf17aeb0edb9536c24e8" "reference": "9ac7c136b0197a15a31f5092782366abff9a6e06"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/walkor/webman-framework/zipball/84335520a340ee60adf7cf17aeb0edb9536c24e8", "url": "https://api.github.com/repos/walkor/webman-framework/zipball/9ac7c136b0197a15a31f5092782366abff9a6e06",
"reference": "84335520a340ee60adf7cf17aeb0edb9536c24e8", "reference": "9ac7c136b0197a15a31f5092782366abff9a6e06",
"shasum": "" "shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
}, },
"require": { "require": {
"ext-json": "*", "ext-json": "*",
@ -7532,7 +7538,7 @@
"suggest": { "suggest": {
"ext-event": "For better performance. " "ext-event": "For better performance. "
}, },
"time": "2024-01-15T12:11:49+00:00", "time": "2024-06-17T01:51:40+00:00",
"type": "library", "type": "library",
"installation-source": "dist", "installation-source": "dist",
"autoload": { "autoload": {

View File

@ -1047,9 +1047,9 @@
'dev_requirement' => false, 'dev_requirement' => false,
), ),
'workerman/webman-framework' => array( 'workerman/webman-framework' => array(
'pretty_version' => 'v1.5.16', 'pretty_version' => 'v1.5.19',
'version' => '1.5.16.0', 'version' => '1.5.19.0',
'reference' => '84335520a340ee60adf7cf17aeb0edb9536c24e8', 'reference' => '9ac7c136b0197a15a31f5092782366abff9a6e06',
'type' => 'library', 'type' => 'library',
'install_path' => __DIR__ . '/../workerman/webman-framework', 'install_path' => __DIR__ . '/../workerman/webman-framework',
'aliases' => array(), 'aliases' => array(),

View File

@ -586,8 +586,8 @@ class App
$pathExplodes = explode('/', trim($path, '/')); $pathExplodes = explode('/', trim($path, '/'));
$plugin = ''; $plugin = '';
if (isset($pathExplodes[1]) && $pathExplodes[0] === 'app') { if (isset($pathExplodes[1]) && $pathExplodes[0] === 'app') {
$publicDir = BASE_PATH . "/plugin/$pathExplodes[1]/public";
$plugin = $pathExplodes[1]; $plugin = $pathExplodes[1];
$publicDir = static::config($plugin, 'app.public_path') ?: BASE_PATH . "/plugin/$pathExplodes[1]/public";
$path = substr($path, strlen("/app/$pathExplodes[1]/")); $path = substr($path, strlen("/app/$pathExplodes[1]/"));
} else { } else {
$publicDir = static::$publicPath; $publicDir = static::$publicPath;
@ -654,7 +654,7 @@ class App
*/ */
protected static function parseControllerAction(string $path) protected static function parseControllerAction(string $path)
{ {
$path = str_replace('-', '', $path); $path = str_replace(['-', '//'], ['', '/'], $path);
static $cache = []; static $cache = [];
if (isset($cache[$path])) { if (isset($cache[$path])) {
return $cache[$path]; return $cache[$path];
@ -798,10 +798,10 @@ class App
protected static function getAction(string $controllerClass, string $action) protected static function getAction(string $controllerClass, string $action)
{ {
$methods = get_class_methods($controllerClass); $methods = get_class_methods($controllerClass);
$action = strtolower($action); $lowerAction = strtolower($action);
$found = false; $found = false;
foreach ($methods as $candidate) { foreach ($methods as $candidate) {
if (strtolower($candidate) === $action) { if (strtolower($candidate) === $lowerAction) {
$action = $candidate; $action = $candidate;
$found = true; $found = true;
break; break;

View File

@ -219,6 +219,9 @@ class Request extends \Workerman\Protocols\Http\Request
$ip = $this->header('x-real-ip', $this->header('x-forwarded-for', $ip = $this->header('x-real-ip', $this->header('x-forwarded-for',
$this->header('client-ip', $this->header('x-client-ip', $this->header('client-ip', $this->header('x-client-ip',
$this->header('via', $remoteIp))))); $this->header('via', $remoteIp)))));
if (is_string($ip)) {
$ip = current(explode(',', $ip));
}
return filter_var($ip, FILTER_VALIDATE_IP) ? $ip : $remoteIp; return filter_var($ip, FILTER_VALIDATE_IP) ? $ip : $remoteIp;
} }

View File

@ -227,6 +227,7 @@ class Route
if (in_array('create', $options)) static::get("/$name/create", [$controller, 'create'])->name("$name.create"); 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('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('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('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('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"); 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, '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, '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, '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, '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, '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"); if (method_exists($controller, 'destroy')) static::delete("/$name/{id}", [$controller, 'destroy'])->name("$name.destroy");

View File

@ -28,21 +28,21 @@ use Illuminate\Support\LazyCollection;
/** /**
* @method static BaseModel make($attributes = []) * @method static BaseModel make($attributes = [])
* @method static \Illuminate\Database\Eloquent\Builder withGlobalScope($identifier, $scope) * @method static \Illuminate\Database\Eloquent\Builder|static withGlobalScope($identifier, $scope)
* @method static \Illuminate\Database\Eloquent\Builder withoutGlobalScope($scope) * @method static \Illuminate\Database\Eloquent\Builder|static withoutGlobalScope($scope)
* @method static \Illuminate\Database\Eloquent\Builder withoutGlobalScopes($scopes = null) * @method static \Illuminate\Database\Eloquent\Builder|static withoutGlobalScopes($scopes = null)
* @method static array removedScopes() * @method static array removedScopes()
* @method static \Illuminate\Database\Eloquent\Builder whereKey($id) * @method static \Illuminate\Database\Eloquent\Builder|static whereKey($id)
* @method static \Illuminate\Database\Eloquent\Builder whereKeyNot($id) * @method static \Illuminate\Database\Eloquent\Builder|static whereKeyNot($id)
* @method static \Illuminate\Database\Eloquent\Builder where($column, $operator = null, $value = null, $boolean = 'and') * @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 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|static orWhere($column, $operator = null, $value = null)
* @method static \Illuminate\Database\Eloquent\Builder latest($column = null) * @method static \Illuminate\Database\Eloquent\Builder|static latest($column = null)
* @method static \Illuminate\Database\Eloquent\Builder oldest($column = null) * @method static \Illuminate\Database\Eloquent\Builder|static oldest($column = null)
* @method static \Illuminate\Database\Eloquent\Collection hydrate($items) * @method static \Illuminate\Database\Eloquent\Collection|static hydrate($items)
* @method static \Illuminate\Database\Eloquent\Collection fromQuery($query, $bindings = []) * @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 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|\Illuminate\Database\Eloquent\Collection|static|static[] findOrFail($id, $columns = [])
* @method static BaseModel|static findOrNew($id, $columns = []) * @method static BaseModel|static findOrNew($id, $columns = [])
* @method static BaseModel|static firstOrNew($attributes = [], $values = []) * @method static BaseModel|static firstOrNew($attributes = [], $values = [])
@ -66,46 +66,46 @@ use Illuminate\Support\LazyCollection;
* @method static void onDelete($callback) * @method static void onDelete($callback)
* @method static static|mixed scopes($scopes) * @method static static|mixed scopes($scopes)
* @method static static applyScopes() * @method static static applyScopes()
* @method static \Illuminate\Database\Eloquent\Builder without($relations) * @method static \Illuminate\Database\Eloquent\Builder|static without($relations)
* @method static \Illuminate\Database\Eloquent\Builder withOnly($relations) * @method static \Illuminate\Database\Eloquent\Builder|static withOnly($relations)
* @method static BaseModel newModelInstance($attributes = []) * @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 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 Builder toBase()
* @method static array getEagerLoads() * @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 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 Closure getMacro($name)
* @method static bool hasMacro($name) * @method static bool hasMacro($name)
* @method static Closure getGlobalMacro($name) * @method static Closure getGlobalMacro($name)
* @method static bool hasGlobalMacro($name) * @method static bool hasGlobalMacro($name)
* @method static static clone () * @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|static 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|static orHas($relation, $operator = '>=', $count = 1)
* @method static \Illuminate\Database\Eloquent\Builder doesntHave($relation, $boolean = 'and', $callback = null) * @method static \Illuminate\Database\Eloquent\Builder|static doesntHave($relation, $boolean = 'and', $callback = null)
* @method static \Illuminate\Database\Eloquent\Builder orDoesntHave($relation) * @method static \Illuminate\Database\Eloquent\Builder|static orDoesntHave($relation)
* @method static \Illuminate\Database\Eloquent\Builder whereHas($relation, $callback = null, $operator = '>=', $count = 1) * @method static \Illuminate\Database\Eloquent\Builder|static 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|static orWhereHas($relation, $callback = null, $operator = '>=', $count = 1)
* @method static \Illuminate\Database\Eloquent\Builder whereDoesntHave($relation, $callback = null) * @method static \Illuminate\Database\Eloquent\Builder|static whereDoesntHave($relation, $callback = null)
* @method static \Illuminate\Database\Eloquent\Builder orWhereDoesntHave($relation, $callback = null) * @method static \Illuminate\Database\Eloquent\Builder|static 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|static 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|static 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|static doesntHaveMorph($relation, $types, $boolean = 'and', $callback = null)
* @method static \Illuminate\Database\Eloquent\Builder orDoesntHaveMorph($relation, $types) * @method static \Illuminate\Database\Eloquent\Builder|static orDoesntHaveMorph($relation, $types)
* @method static \Illuminate\Database\Eloquent\Builder whereHasMorph($relation, $types, $callback = null, $operator = '>=', $count = 1) * @method static \Illuminate\Database\Eloquent\Builder|static 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|static 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|static whereDoesntHaveMorph($relation, $types, $callback = null)
* @method static \Illuminate\Database\Eloquent\Builder orWhereDoesntHaveMorph($relation, $types, $callback = null) * @method static \Illuminate\Database\Eloquent\Builder|static orWhereDoesntHaveMorph($relation, $types, $callback = null)
* @method static \Illuminate\Database\Eloquent\Builder withAggregate($relations, $column, $function = null) * @method static \Illuminate\Database\Eloquent\Builder|static withAggregate($relations, $column, $function = null)
* @method static \Illuminate\Database\Eloquent\Builder withCount($relations) * @method static \Illuminate\Database\Eloquent\Builder|static withCount($relations)
* @method static \Illuminate\Database\Eloquent\Builder withMax($relation, $column) * @method static \Illuminate\Database\Eloquent\Builder|static withMax($relation, $column)
* @method static \Illuminate\Database\Eloquent\Builder withMin($relation, $column) * @method static \Illuminate\Database\Eloquent\Builder|static withMin($relation, $column)
* @method static \Illuminate\Database\Eloquent\Builder withSum($relation, $column) * @method static \Illuminate\Database\Eloquent\Builder|static withSum($relation, $column)
* @method static \Illuminate\Database\Eloquent\Builder withAvg($relation, $column) * @method static \Illuminate\Database\Eloquent\Builder|static withAvg($relation, $column)
* @method static \Illuminate\Database\Eloquent\Builder withExists($relation) * @method static \Illuminate\Database\Eloquent\Builder|static withExists($relation)
* @method static \Illuminate\Database\Eloquent\Builder mergeConstraintsFrom($from) * @method static \Illuminate\Database\Eloquent\Builder|static mergeConstraintsFrom($from)
* @method static Collection explain() * @method static Collection explain()
* @method static bool chunk($count, $callback) * @method static bool chunk($count, $callback)
* @method static Collection chunkMap($callback, $count = 1000) * @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 LazyCollection lazyById($chunkSize = 1000, $column = null, $alias = null)
* @method static BaseModel|object|static|null first($columns = []) * @method static BaseModel|object|static|null first($columns = [])
* @method static BaseModel|object|null baseSole($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 when($value, $callback, $default = null)
* @method static mixed unless($value, $callback, $default = null) * @method static mixed unless($value, $callback, $default = null)
* @method static Builder select($columns = []) * @method static Builder select($columns = [])

View File

@ -52,10 +52,7 @@ class Translation
{ {
if (!isset(static::$instance[$plugin])) { if (!isset(static::$instance[$plugin])) {
$config = config($plugin ? "plugin.$plugin.translation" : 'translation', []); $config = config($plugin ? "plugin.$plugin.translation" : 'translation', []);
// Phar support. Compatible with the 'realpath' function in the phar file. $paths = (array)($config['path'] ?? []);
if (!$translationsPath = get_realpath($config['path'])) {
throw new NotFoundException("File {$config['path']} not found");
}
static::$instance[$plugin] = $translator = new Translator($config['locale']); static::$instance[$plugin] = $translator = new Translator($config['locale']);
$translator->setFallbackLocales($config['fallback_locale']); $translator->setFallbackLocales($config['fallback_locale']);
@ -70,6 +67,11 @@ class Translation
'format' => 'pofile' '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) { foreach ($classes as $class => $opts) {
$translator->addLoader($opts['format'], new $class); $translator->addLoader($opts['format'], new $class);
@ -86,6 +88,7 @@ class Translation
} }
} }
} }
}
return static::$instance[$plugin]; return static::$instance[$plugin];
} }

View File

@ -63,9 +63,11 @@ class LaravelDb implements Bootstrap
$default = $config['default'] ?? false; $default = $config['default'] ?? false;
if ($default) { if ($default) {
$defaultConfig = $connections[$config['default']]; $defaultConfig = $connections[$config['default']] ?? false;
if ($defaultConfig) {
$capsule->addConnection($defaultConfig); $capsule->addConnection($defaultConfig);
} }
}
foreach ($connections as $name => $config) { foreach ($connections as $name => $config) {
$capsule->addConnection($config, $name); $capsule->addConnection($config, $name);

View File

@ -31,11 +31,6 @@ use function runtime_path;
*/ */
class Blade implements View class Blade implements View
{ {
/**
* @var array
*/
protected static $vars = [];
/** /**
* Assign. * Assign.
* @param string|array $name * @param string|array $name
@ -43,7 +38,8 @@ class Blade implements View
*/ */
public static function assign($name, $value = null) 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]); $extension($views[$key]);
} }
} }
$vars = array_merge(static::$vars, $vars); $vars = array_merge((array) $request->_view_vars, $vars);
$content = $views[$key]->render($template, $vars); return $views[$key]->render($template, $vars);
static::$vars = [];
return $content;
} }
} }

View File

@ -33,11 +33,6 @@ use function request;
*/ */
class Raw implements View class Raw implements View
{ {
/**
* @var array
*/
protected static $vars = [];
/** /**
* Assign. * Assign.
* @param string|array $name * @param string|array $name
@ -45,7 +40,8 @@ class Raw implements View
*/ */
public static function assign($name, $value = null) 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(); $baseViewPath = $plugin ? base_path() . "/plugin/$plugin/app" : app_path();
$__template_path__ = $app === '' ? "$baseViewPath/view/$template.$viewSuffix" : "$baseViewPath/$app/view/$template.$viewSuffix"; $__template_path__ = $app === '' ? "$baseViewPath/view/$template.$viewSuffix" : "$baseViewPath/$app/view/$template.$viewSuffix";
extract(static::$vars); extract((array) $request->_view_vars);
extract($vars); extract($vars);
ob_start(); ob_start();
// Try to include php file. // Try to include php file.
try { try {
include $__template_path__; include $__template_path__;
} catch (Throwable $e) { } catch (Throwable $e) {
static::$vars = [];
ob_end_clean(); ob_end_clean();
throw $e; throw $e;
} }
static::$vars = [];
return ob_get_clean(); return ob_get_clean();
} }
} }

View File

@ -32,11 +32,6 @@ use function runtime_path;
*/ */
class ThinkPHP implements View class ThinkPHP implements View
{ {
/**
* @var array
*/
protected static $vars = [];
/** /**
* Assign. * Assign.
* @param string|array $name * @param string|array $name
@ -44,7 +39,8 @@ class ThinkPHP implements View
*/ */
public static function assign($name, $value = null) 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", [])); $options = array_merge($defaultOptions, config("{$configPrefix}view.options", []));
$views = new Template($options); $views = new Template($options);
ob_start(); ob_start();
$vars = array_merge(static::$vars, $vars); $vars = array_merge((array) $request->_view_vars, $vars);
$views->fetch($template, $vars); $views->fetch($template, $vars);
$content = ob_get_clean(); return ob_get_clean();
static::$vars = [];
return $content;
} }
} }

View File

@ -33,11 +33,6 @@ use function request;
*/ */
class Twig implements View class Twig implements View
{ {
/**
* @var array
*/
protected static $vars = [];
/** /**
* Assign. * Assign.
* @param string|array $name * @param string|array $name
@ -45,7 +40,8 @@ class Twig implements View
*/ */
public static function assign($name, $value = null) 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]); $extension($views[$key]);
} }
} }
$vars = array_merge(static::$vars, $vars); $vars = array_merge((array) $request->_view_vars, $vars);
$content = $views[$key]->render("$template.$viewSuffix", $vars); return $views[$key]->render("$template.$viewSuffix", $vars);
static::$vars = [];
return $content;
} }
} }