feature/main20240421
guojia 7 months ago
parent ea5c37459e
commit 37cdc10f62
  1. 11
      app/common/model/Merchant.php
  2. 92
      app/common/model/Style.php
  3. 25
      app/store/controller/Merchant.php
  4. 65
      app/store/model/Style.php
  5. 15
      public/install/data/install_struct.sql

@ -29,9 +29,9 @@ class Merchant extends BaseModel
protected $pk = 'merchant_id';
/**
* 关联logo图片
* @return HasOne
*/
* 关联logo图片
* @return HasOne
*/
public function logoImage(): HasOne
{
return $this->hasOne('UploadFile', 'file_id', 'logo_image_id');
@ -41,11 +41,12 @@ class Merchant extends BaseModel
* 关联logo图片
* @return HasOne
*/
public function licenseImage(): HasOne
public function licenseImage(): HasMany
{
return $this->hasOne('UploadFile', 'file_id', 'license_img_id');
return $this->HasMany('UploadFile', 'file_id', 'license_img_id');
}
/**
* 详情信息
* @param int $storeId

@ -0,0 +1,92 @@
<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types=1);
namespace app\common\model;
use cores\BaseModel;
use think\model\relation\HasOne;
/**
* 商家记录表模型
* Class Store
* @package app\common\model
*/
class Style extends BaseModel
{
// 定义表名
protected $name = 'style';
// 定义主键
protected $pk = 'style_id';
/**
* 详情信息
* @param int $storeId
* @return static|array|null
*/
public static function detail()
{
try {
$list = self::withoutGlobalScope()
->where('1', '=', 1)
->find();
return $list ?? null;
} catch (\Exception $e) {
return null;
}
}
/**
* 获取列表数据
* @param bool $isRecycle 是否在回收站
* @return \think\Paginator
* @throws \think\db\exception\DbException
*/
public function getList(array $param = []): \think\Paginator
{
return $this->with(['logoImage'])
->where($this->getFilter($param))
->where('is_delete', '=', 0)
->order(['sort' => 'asc', $this->getPk()])
->paginate(15);
}
/**
* 设置列表查询条件
* @param array $param
* @return array
*/
private function getFilter(array $param = []): array
{
// 默认查询参数
$params = $this->setQueryDefaultValue($param, [
'search' => '', // 搜索关键词: 门店名称/联系人/电话
]);
// 检索查询条件
$filter = [];
// 搜索关键词
!empty($params['search']) && $filter[] = ['shop_name|shop_label', 'like', "%{$params['search']}%"];
// 门店状态
//is_numeric($params['status']) && $filter[] = ['status', '=', (int)$params['status']];
return $filter;
}
/**
* 软删除
* @return bool
*/
public function setDelete(): bool
{
return $this->save(['is_delete' => 1]);
}
}

@ -15,6 +15,7 @@ namespace app\store\controller;
use app\common\model\store\StoreSettle;
use think\response\Json;
use app\store\model\Merchant as MerchantModel;
use app\store\model\Style as StyleModel;
use app\common\model\Channel;
use app\store\model\store\User as StoreUserModel;
@ -25,7 +26,6 @@ use app\store\model\store\User as StoreUserModel;
*/
class Merchant extends Controller
{
/**
* 获取当前登录的商城信息
* @return Json
@ -46,7 +46,6 @@ class Merchant extends Controller
$userIds = array_column($list2['data'], "user_name");
$list = array_diff($list, $userIds);
return $this->renderSuccess(compact('list'));
}
@ -125,4 +124,26 @@ class Merchant extends Controller
return $this->renderSuccess(compact('detail'));
}
/**
* 更新商城信息
* @return Json
*/
public function setPageStyle(): Json
{
// 新增记录
$model = new StyleModel;
$data = $this->postForm();
if ($model->add($data)) {
return $this->renderSuccess('添加成功');
}
return $this->renderError($model->getError() ?: '添加失败');
}
public function getPageStyle(): Json
{
// 新增记录
$detail = StyleModel::detail();
return $this->renderSuccess(compact('detail'));
}
}

@ -0,0 +1,65 @@
<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types=1);
namespace app\store\model;
use app\common\model\Style as model;
/**
* 商家记录表模型
* Class Store
* @package app\store\model
*/
class Style extends model
{
/**
* 更新记录
* @param array $data
* @return bool
*/
public function edit(array $data): bool
{
// 是否删除图片
!isset($data['logo_image_id']) && $data['logo_image_id'] = 0;
return $this->save($data) !== false;
}
/**
* 新增记录
* @param array $data
* @return bool
*/
public function add(array $data): bool
{
return $this->save($this->createData($data));
}
/**
* 创建数据
* @param array $data
* @return array
*/
private function createData(array $data): array
{
$data['store_id'] = self::$storeId;
return $data;
}
/**
* 软删除
* @return bool
*/
public function setDelete(): bool
{
return $this->save(['is_delete' => 1]);
}
}

@ -1716,7 +1716,7 @@ CREATE TABLE `yoshop_merchant` (
`shop_name` varchar(100) NOT NULL DEFAULT '' COMMENT '名称',
`shop_label` varchar(100) NOT NULL DEFAULT '' COMMENT '标签',
`logo_image_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '门店logo图片ID',
`license_img_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '营业执照图片ID',
`license_img_id` varchar(200) NOT NULL DEFAULT '' COMMENT '营业执照图片ID',
`user_name` varchar(100) NOT NULL DEFAULT '' COMMENT '买家用户名',
`sort` int(11) NOT NULL DEFAULT '0' COMMENT '门店排序(数字越小越靠前)',
`is_delete` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '是否删除',
@ -1727,6 +1727,19 @@ CREATE TABLE `yoshop_merchant` (
KEY `store_id` (`store_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='商户表';
DROP TABLE IF EXISTS `yoshop_style`;
CREATE TABLE `yoshop_style` (
`style_id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`style` varchar(100) NOT NULL DEFAULT '' COMMENT '风格',
`is_delete` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '是否删除',
`store_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '商城ID',
`merchant_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '商户ID',
`create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
`update_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间',
PRIMARY KEY (`style_id`),
KEY `store_id` (`store_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='风格表';
DROP TABLE IF EXISTS `yoshop_squarelike`;
CREATE TABLE `yoshop_squarelike` (
`squarelike_id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',

Loading…
Cancel
Save