You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
zhishifufei_php/application/institution/controller/System.php

87 lines
3.7 KiB

9 months ago
<?php
// +----------------------------------------------------------------------
// | 天诚科技 [ 刘海东 17600099397赋能开发者,助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2020 https://www.tczxkj.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 该系统并不是自由软件,未经许可不能去掉相关版权
// +----------------------------------------------------------------------
// | Author:甘肃天诚志信电子商务有限公司 刘海东 联系电话维系17600099397
// +----------------------------------------------------------------------
namespace app\institution\controller;
use service\JsonService;
use service\SystemConfigService;
use app\institution\model\institution\Institution;
use app\institution\model\special\LecturerInstitution as Lecturer;
use service\GroupDataService;
use app\merchant\model\special\Special;
use app\merchant\model\download\DataDownload as DownloadModel;
use app\merchant\model\store\StoreProduct as ProductModel;
use app\merchant\model\ump\EventRegistration as EventRegistrationModel;
class System extends AuthController
{
public function index()
{
$merchant = Institution::where('id', $this->merchantId)->find();
$lecturer = Lecturer::where('id', $this->merchantInfo['lecturer_id'])->field('label,explain,introduction')->find();
$lecturer['introduction'] = htmlspecialchars_decode($lecturer['introduction']);
$this->assign(['merchat' => json_encode($merchant), 'lecturer' => json_encode($lecturer)]);
return $this->fetch();
}
/**
* 保存商户资料
*/
public function edit_merchant()
{
$post = parent::postMore([
['mer_name', ''],
['mer_email', ''],
['mer_phone', ''],
['mer_address', ''],
['mer_avatar', ''],
['mer_info', ''],
['estate', 0],
['card_id', ''],
['bank', ''],
['bank_number', ''],
['bank_name', ''],
['bank_address', ''],
['label', []],
['explains', '']
]);
$data['label'] = json_encode($post['label']);
$data['explain'] = $post['explains'];
$data['introduction'] = htmlspecialchars($post['mer_info']);
$data['lecturer_name'] = $post['mer_name'];
$data['lecturer_head'] = $post['mer_avatar'];
$data['phone'] = $post['mer_phone'];
Institution::beginTrans();
try {
unset($post['label'], $post['explains']);
Institution::edit($post, $this->merchantId, 'id');
if (!$post['estate']) {
Special::where(['is_del' => 0, 'mer_id' => $this->merchantId])->update(['is_show' => 0]);
DownloadModel::where(['is_del' => 0, 'mer_id' => $this->merchantId])->update(['is_show' => 0]);
ProductModel::where(['is_del' => 0, 'mer_id' => $this->merchantId])->update(['is_show' => 0]);
EventRegistrationModel::where(['is_del' => 0, 'mer_id' => $this->merchantId])->update(['is_show' => 0]);
$data['is_show'] = 0;
Lecturer::edit($data, $this->merchantInfo['lecturer_id'], 'id');
} else {
$data['is_show'] = 1;
Lecturer::edit($data, $this->merchantInfo['lecturer_id'], 'id');
}
Institution::commitTrans();
return JsonService::successful('保存成功');
} catch (\Exception $e) {
Institution::rollbackTrans();
return JsonService::fail($e->getMessage());
}
}
}