| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- <?php
- namespace addons\Store\client\controllers;
- use addons\HuifuPay\common\service\HuifuBillShareService;
- use addons\Store\common\models\StoreAddons;
- use common\enums\AddonsEnum;
- use common\enums\StatusEnum;
- use common\models\mall\MallAddons;
- use Yii;
- /**
- * 商品控制器
- * @Author bing
- * @DateTime 2021-08-16 13:12:44
- * @copyright: Copyright (c) 2020 广东七件事集团
- */
- class AddonsController extends BaseController
- {
- public $enableCsrfValidation = false;
- /**
- * 应用
- * @Author:lun
- * @Date:2023-12-19 14:54
- * @Copyright:copyright(c)2023 广东七件事集团
- * @return mixed|string|null
- */
- public function actionIndex(){
- $request = Yii::$app->request;
- if ($request->isAjax && $request->isGet) {
- $get = Yii::$app->request->get();
- $rules = [
- [['keyword'], 'string'],
- ];
- $res = Yii::$app->services->validate->validate($get, $rules);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $where = [];
- isset($get['keyword']) && $where[] = ['=', 'title', $get['keyword']];
- $where[] = ['=', 'status', StatusEnum::ENABLED];
- $order = 'id asc';
- $params = array('where' => $where, 'order' => $order);
- $data['list'] = StoreAddons::lists($params, true);
- if (empty($data['list'])) return $this->error('获取失败');
- $list = [];
- $static_url = \Yii::$app->services->setting->platform->get('system.static_url');
- foreach ($data['list'] as &$item){
- switch ($item['name']){
- //门店核销券与门店股东相关联,
- case 'Verification':
- if(MallAddons::isInstall($this->mall_id,AddonsEnum::ADDONS_NAME_STORE_BOSS_AGENT)){
- if(empty($item['cover'])){
- $item['cover'] = $static_url.'/static/addons/icon/' . $item['name'] . '.png';
- }
- $list[] = $item;
- }
- break;
- case AddonsEnum::ADDONS_NAME_HUIFU_PAY:
- if (MallAddons::isInstall($this->mall_id, AddonsEnum::ADDONS_NAME_HUIFU_PAY)&&!empty(HuifuBillShareService::isEnableShare($this->mall_id)) ) {
- $list[] = $item;
- }
- break;
- case 'StoreAssociatedUser':
- if(empty($item['cover'])){
- $item['cover'] = $static_url.'/static/addons/icon/' . $item['name'] . '.png';
- }
- $list[] = $item;
- break;
- default:
- if(MallAddons::isInstall($this->mall_id,$item['name'])){
- if(empty($item['cover'])){
- $item['cover'] = $static_url.'/static/addons/icon/' . $item['name'] . '.png';
- }
- $list[] = $item;
- }
- }
- // if(($item['name'] != AddonsEnum::ADDONS_NAME_HUIFU_PAY && MallAddons::isInstall($this->mall_id,$item['name'])) || $item['name'] == 'StoreAssociatedUser'){
- // if(empty($item['cover'])){
- // $item['cover'] = $static_url.'/static/addons/icon/' . $item['name'] . '.png';
- // }
- // $list[] = $item;
- // }
- }
- $data['list'] = $this->getAddonsUrl($list);
- return $this->success('获取成功',$data);
- } else {
- return $this->render($this->action->id);
- }
- }
- /**
- * 获取应用默认跳转地址
- * @Author:lun
- * @Date:2023-12-19 17:20
- * @Copyright:copyright(c)2023 广东七件事集团
- * @param $addons
- * @return mixed
- */
- public function getAddonsUrl($addons)
- {
- $addons_indexby = StoreAddons::getAddonsDefaultUrls(array_column($addons, 'name'));
- foreach ($addons as &$item) {
- $item['url'] = $addons_indexby[$item['name']]['url'];
- }
- return $addons;
- }
- }
|