- 框架初始化
 - 安装插件
 - 修复PHP8.4报错
This commit is contained in:
2025-04-19 17:21:20 +08:00
commit c6a4e1f5f6
5306 changed files with 967782 additions and 0 deletions

View File

@@ -0,0 +1,59 @@
<?php
namespace addons\shopro\controller\app;
use addons\shopro\controller\Common;
use app\admin\model\shopro\app\mplive\Room;
use addons\shopro\facade\Wechat;
use addons\shopro\library\mplive\ServiceProvider;
class Mplive extends Common
{
protected $noNeedLogin = ['getRoomList', 'getMpLink'];
protected $noNeedRight = ['*'];
public function getRoomList()
{
// 通过客户端访问触发每10分钟刷新一次房间状态
$lastUpdateTime = cache('wechatMplive.update');
if ($lastUpdateTime < (time() - 60 * 10)) {
cache('wechatMplive.update', time());
$app = Wechat::miniProgram();
(new ServiceProvider())->register($app);
$res = $app->broadcast->getRooms();
$data = [];
if (isset($res['errcode']) && ($res['errcode'] !== 0 && $res['errcode'] !== 1001)) {
$this->error($res['errmsg'] ?? '');
} else {
// 更新直播间列表
Room::where('roomid', '>', 0)->delete();
foreach ($res['room_info'] as $room) {
$room['status'] = $room['live_status'];
$room['type'] = $room['live_type'];
$data[] = $room;
}
Room::strict(false)->insertAll($data);
}
}
$params = $this->request->param();
$ids = $params['ids'] ?? '';
$list = Room::where('roomid', 'in', $ids)->select();
$this->success('获取成功', $list);
}
public function getMpLink()
{
$wechat = Wechat::miniProgram();
(new ServiceProvider())->register($wechat);
// TODO: 需防止被恶意消耗次数
$res = $wechat->broadcast->urlscheme();
$link = $res['openlink'];
$this->success('获取成功', $link);
}
}

View File

@@ -0,0 +1,94 @@
<?php
namespace addons\shopro\controller\app;
use addons\shopro\controller\Common;
use addons\shopro\service\goods\GoodsService;
use app\admin\model\shopro\user\GoodsLog;
class ScoreShop extends Common
{
protected $noNeedLogin = ['index', 'ids', 'detail'];
protected $noNeedRight = ['*'];
public function index()
{
$params = $this->request->param();
$keyword = $params['keyword'] ?? '';
$sort = $params['sort'] ?? 'weigh';
$order = $params['order'] ?? 'desc';
$service = new GoodsService(function ($goods) {
$goods->score = $goods->score;
return $goods;
});
$service->show()->score()->with(['all_score_sku_prices']); // 包含下架的积分规格
if ($keyword) {
$service->search($keyword);
}
if ($sort) {
$service->order($sort, $order);
}
$goods = $service->paginate();
$this->success('获取成功', $goods);
}
public function ids()
{
$params = $this->request->param();
$ids = $params['ids'] ?? '';
$service = new GoodsService(function ($goods) {
$goods->score = $goods->score;
return $goods;
});
$service->show()->score()->with(['all_score_sku_prices']);
if ($ids) {
$service->whereIds($ids);
}
$goods = $service->select();
$this->success('获取成功', $goods);
}
public function detail()
{
$user = auth_user();
$id = $this->request->param('id');
$service = new GoodsService(function ($goods, $service) {
$goods->score = $goods->score;
$goods->service = $goods->service;
$goods->skus = $goods->skus;
return $goods;
});
$goods = $service->show()->score()->where('id', $id)->find();
if (!$goods) {
$this->error(__('No Results were found'));
}
// 添加浏览记录
GoodsLog::addView($user, $goods);
// 处理商品规格
$skuPrices = $goods['new_sku_prices'];
$content = $goods['content'];
$goods = $goods->toArray();
$goods['sku_prices'] = $skuPrices;
$goods['content'] = $content;
unset($goods['new_sku_prices']);
$this->success('获取成功', $goods);
}
}