ss panel v3
ss panel v3

自助商店指定用户购买

对数据库的操作

登录 phpmyadmin,执行 sql 语句

ALTER TABLE `shop` ADD `limitUserId` VARCHAR(1024) NOT NULL DEFAULT '0' COMMENT '限制特定用户id购买,0为允许全体;或填允许购买的用户id' AFTER `status`;

对HTML文件的操作

编辑 /home/wwwroot/sspanel/resources/views/material/admin/shop/create.tpl ,插入如下内容到如图所示位置

<div class="form-group form-group-label">
<label class="floating-label" for="purchaseRestrictions">购买限制</label>
<input class="form-control maxwidth-edit" id="purchaseRestrictions" type="text" value="0">
</div>
https://sspanel3.com/wp-content/uploads/2020/06/Snipaste_2020-06-08_23-02-31.png

同样是该文件,插入如下内容到如图所示位置

purchaseRestrictions: $$getValue('purchaseRestrictions'),
https://sspanel3.com/wp-content/uploads/2020/06/Snipaste_2020-06-08_23-05-38.png

编辑/home/wwwroot/sspanel/resources/views/material/admin/shop/edit.tpl,插入如下内容到如图所示位置

<div class="form-group form-group-label">
<label class="floating-label" for="purchaseRestrictions">购买限制</label>
<input class="form-control maxwidth-edit" id="purchaseRestrictions" type="text" value="{$shop->purchaseRestrictions()}">
</div>
https://sspanel3.com/wp-content/uploads/2020/06/Snipaste_2020-06-08_23-06-57.png

同样是该文件,插入如下内容到如图所示位置

purchaseRestrictions: $$getValue('purchaseRestrictions'),
https://sspanel3.com/wp-content/uploads/2020/06/Snipaste_2020-06-08_23-08-36.png

对PHP文件的操作

编辑 /home/wwwroot/sspanel/app/Models/Shop.php ,找到129行,插入

public function purchaseRestrictions()
{
$content = json_decode($this->attributes['content']);
return $content->limitUserId ?? 0;
}
https://sspanel3.com/wp-content/uploads/2020/06/Snipaste_2020-06-08_00-11-54.png

编辑/home/wwwroot/sspanel/app/Controllers/Admin/ShopController.php ,找到40行,插入

$shop->limitUserId = $request->getParam('purchaseRestrictions');
https://sspanel3.com/wp-content/uploads/2020/06/Snipaste_2020-06-08_00-18-53.png

找到82行,插入

$content['limitUserId'] = $request->getParam('purchaseRestrictions');
https://sspanel3.com/wp-content/uploads/2020/06/Snipaste_2020-06-08_00-14-55.png

找到124行,插入

$shop->limitUserId = $request->getParam('purchaseRestrictions');
https://sspanel3.com/wp-content/uploads/2020/06/Snipaste_2020-06-08_23-13-51.png

找到168行,插入

$content['limitUserId'] = $request->getParam('purchaseRestrictions');
https://sspanel3.com/wp-content/uploads/2020/06/Snipaste_2020-06-08_23-14-19.png

对TPL文件的操作

编辑 /home/wwwroot/sspanel/resources/views/material/user/shop.tpl ,找到如下代码

{foreach $shops as $shop}

如上 代码 下方 插入如下内容

{$limitUserIdArray = $shop->limitUserId}
{$limitUserIdArray = explode(",", $limitUserIdArray)}
{if (in_array({$user->id}, $limitUserIdArray)) || $shop->limitUserId == 0}

找到如下代码

{/foreach}

如上 代码 上方 插入如下内容

{/if}

如何使用

在套餐的添加或编辑页面设置购买限制。当购买限制设置为 0 时,该套餐所有用户可见,所有用户可购买

https://sspanel3.com/wp-content/uploads/2020/06/Snipaste_2020-06-08_23-18-22.png

当购买限制设置为某一用户 id 时,该套餐所仅对该 id 用户可见。多个用户 id 用英文逗号 , 分隔

https://sspanel3.com/wp-content/uploads/2020/06/Snipaste_2020-06-08_23-25-05.png

发表回复

textsms
account_circle
email

ss panel v3

自助商店指定用户购买
对数据库的操作 登录 phpmyadmin,执行 sql 语句 ALTER TABLE `shop` ADD `limitUserId` VARCHAR(1024) NOT NULL DEFAULT '0' COMMENT '限制特定用户id购买,0为允许全体;或填允许购…
扫描二维码继续阅读
2020-06-08