diff --git a/app/api/controller/Feedback.php b/app/api/controller/Feedback.php new file mode 100644 index 00000000..17399938 --- /dev/null +++ b/app/api/controller/Feedback.php @@ -0,0 +1,82 @@ + +// +---------------------------------------------------------------------- +declare (strict_types=1); + +namespace app\api\controller; + +use app\common\model\store\StoreSettle; +use app\api\service\User as UserService; +use think\response\Json; +use app\api\model\Feedback as feedbackModel; +use app\common\model\UploadFile; +use app\common\model\Channel; + +/** + * 意见反馈 + * Class Store + * @package app\store\controller + */ +class Feedback extends Controller +{ + /** + * @notes:新增文章 + * @return Json + * @throws BaseException + * @author: wanghousheng + */ + public function add(): Json + { + if (!UserService::isStore()) { + throwError("无权限", 403); + } + + $useInfo = UserService::getCurrentLoginUser(true); + + $content = $this->request->post('content'); + if (!$content) { + return $this->renderError('内容不能为空'); + } + $cate = intval($this->request->post('cate')); + if (!$cate) { + return $this->renderError('分类不能为空'); + } + + $data = $this->postForm(); + $data['merchant_id'] = $this->merchantId; + if ((new squareModel)->add($data)) { + return $this->renderSuccess('添加成功'); + } + return $this->renderError('添加失败'); + } + + + /** + * 列表 + */ + public function list(): Json { + $model = new feedbackModel; + + $params = $this->request->param(); + $list = $model->getList($params)->toArray(); + + foreach ($list['data'] as $kr => $r) { + $res[$kr]['imgs'] = []; + if ($r['imgs']) { + $img_ids = explode(",", $r['imgs']); + $files = UploadFile::getFileList($img_ids); + $list['data'][$kr]['imgs'] = $files ?: null; + } + } + return $this->renderSuccess($list); + } + + +} diff --git a/app/api/controller/Square.php b/app/api/controller/Square.php new file mode 100644 index 00000000..1318aa9d --- /dev/null +++ b/app/api/controller/Square.php @@ -0,0 +1,102 @@ + +// +---------------------------------------------------------------------- +declare (strict_types=1); + +namespace app\api\controller; + +use app\common\model\store\StoreSettle; +use app\api\service\User as UserService; +use think\response\Json; +use app\api\model\Square as squareModel; +use app\api\model\Squarelike as squarelikeModel; +use app\common\model\UploadFile; +use app\common\model\Channel; + +/** + * 广场动态 + * Class Store + * @package app\store\controller + */ +class Square extends Controller +{ + /** + * @notes:新增文章 + * @return Json + * @throws BaseException + * @author: wanghousheng + */ + public function add(): Json + { + if (!UserService::isStore()) { + throwError("无权限", 403); + } + + $useInfo = UserService::getCurrentLoginUser(true); + + $content = $this->request->post('content'); + if (!$content) { + return $this->renderError('内容不能为空'); + } + $cate = intval($this->request->post('cate')); + if (!$cate) { + return $this->renderError('分类不能为空'); + } + + $data = $this->postForm(); + $data['merchant_id'] = $this->merchantId; + if ((new squareModel)->add($data)) { + return $this->renderSuccess('添加成功'); + } + return $this->renderError('添加失败'); + } + + + /** + * 列表 + */ + public function list(): Json { + $model = new squareModel; + $list = $model->getList($this->request->param())->toArray(); + + foreach ($list['data'] as $kr => $r) { + $res[$kr]['imgs'] = []; + if ($r['imgs']) { + $img_ids = explode(",", $r['imgs']); + $files = UploadFile::getFileList($img_ids); + $list['data'][$kr]['imgs'] = $files ?: null; + } + } + return $this->renderSuccess($list); + } + + public function dynamicLike(int $id): Json + { + if (!UserService::isStore()) { + throwError("无权限", 403); + } + $useInfo = UserService::getCurrentLoginUser(true); + + $model = new squarelikeModel; + $detail = squarelikeModel::detail($id, $useInfo['data']['user_name']); + $data = $this->postForm(); + if (empty($detail)) { + if ($model->add($data)) { + return $this->renderSuccess('操作成功'); + } + } else { + $data['squarelike_id'] = $detail['squarelike_id']; + if ($detail->delete($data)) { + return $this->renderSuccess('操作成功'); + } + } + } + +} diff --git a/app/api/model/Feedback.php b/app/api/model/Feedback.php new file mode 100644 index 00000000..b8881f75 --- /dev/null +++ b/app/api/model/Feedback.php @@ -0,0 +1,63 @@ + +// +---------------------------------------------------------------------- +declare (strict_types=1); + +namespace app\api\model; + + +/** + * Class Store + * @package app\store\model + */ +class Feedback extends \app\common\model\Feedback +{ + /** + * 更新记录 + * @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]); + } +} diff --git a/app/api/model/Square.php b/app/api/model/Square.php new file mode 100644 index 00000000..48103018 --- /dev/null +++ b/app/api/model/Square.php @@ -0,0 +1,63 @@ + +// +---------------------------------------------------------------------- +declare (strict_types=1); + +namespace app\api\model; + + +/** + * Class Store + * @package app\store\model + */ +class Square extends \app\common\model\Square +{ + /** + * 更新记录 + * @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]); + } +} diff --git a/app/api/model/Squarelike.php b/app/api/model/Squarelike.php new file mode 100644 index 00000000..f3309352 --- /dev/null +++ b/app/api/model/Squarelike.php @@ -0,0 +1,61 @@ + +// +---------------------------------------------------------------------- +declare (strict_types=1); + +namespace app\api\model; + + +/** + * Class Store + * @package app\store\model + */ +class Squarelike extends \app\common\model\Squarelike +{ + /** + * 更新记录 + * @param array $data + * @return bool + */ + public function edit(array $data): bool + { + 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]); + } +} diff --git a/app/common/model/Feedback.php b/app/common/model/Feedback.php new file mode 100644 index 00000000..ae77aa92 --- /dev/null +++ b/app/common/model/Feedback.php @@ -0,0 +1,93 @@ + +// +---------------------------------------------------------------------- +declare (strict_types=1); + +namespace app\common\model; + +use cores\BaseModel; +use think\model\relation\HasOne; + +/** + * 商家记录表模型 + * Class Store + * @package app\common\model + */ +class Feedback extends BaseModel +{ + // 定义表名 + protected $name = 'feedback'; + + // 定义主键 + protected $pk = 'feedback_id'; + + + /** + * 详情信息 + * @param int $storeId + * @return static|array|null + */ + public static function detail(int $merchantId) + { + $where = [ + 'merchant_id' => $merchantId, + 'store_id' => self::$storeId + ]; + return static::get($where, []); + } + + /** + * 获取列表数据 + * @param bool $isRecycle 是否在回收站 + * @return \think\Paginator + * @throws \think\db\exception\DbException + */ + public function getList(array $param = [], int $pageSize = 15): \think\Paginator + { + $res = $this->where($this->getFilter($param)) + ->where('is_delete', '=', 0) + ->order(['create_time' => 'desc', $this->getPk()]) + ->paginate($pageSize); + + return $res; + } + + /** + * 设置列表查询条件 + * @param array $param + * @return array + */ + private function getFilter(array $param = []): array + { + // 默认查询参数 + $params = $this->setQueryDefaultValue($param, [ + 'search' => '', // 搜索关键词: 门店名称/联系人/电话 + ]); + // 检索查询条件 + $filter = []; + // 搜索关键词 + !empty($params['cate']) && $filter[] = ['cate', '=', $params['cate']]; + + !empty($params['userName']) && $filter[] = ['user_name', '=', $params['userName']]; + + // 门店状态 + //is_numeric($params['status']) && $filter[] = ['status', '=', (int)$params['status']]; + return $filter; + } + + /** + * 软删除 + * @return bool + */ + public function setDelete(): bool + { + return $this->save(['is_delete' => 1]); + } +} diff --git a/app/common/model/Square.php b/app/common/model/Square.php new file mode 100644 index 00000000..2acfc393 --- /dev/null +++ b/app/common/model/Square.php @@ -0,0 +1,90 @@ + +// +---------------------------------------------------------------------- +declare (strict_types=1); + +namespace app\common\model; + +use cores\BaseModel; +use think\model\relation\HasOne; + +/** + * 商家记录表模型 + * Class Store + * @package app\common\model + */ +class Square extends BaseModel +{ + // 定义表名 + protected $name = 'square'; + + // 定义主键 + protected $pk = 'square_id'; + + + /** + * 详情信息 + * @param int $storeId + * @return static|array|null + */ + public static function detail(int $merchantId) + { + $where = [ + 'merchant_id' => $merchantId, + 'store_id' => self::$storeId + ]; + return static::get($where, []); + } + + /** + * 获取列表数据 + * @param bool $isRecycle 是否在回收站 + * @return \think\Paginator + * @throws \think\db\exception\DbException + */ + public function getList(array $param = [], int $pageSize = 15): \think\Paginator + { + $res = $this->where($this->getFilter($param)) + ->where('is_delete', '=', 0) + ->order(['create_time' => 'desc', $this->getPk()]) + ->paginate($pageSize); + + return $res; + } + + /** + * 设置列表查询条件 + * @param array $param + * @return array + */ + private function getFilter(array $param = []): array + { + // 默认查询参数 + $params = $this->setQueryDefaultValue($param, [ + 'search' => '', // 搜索关键词: 门店名称/联系人/电话 + ]); + // 检索查询条件 + $filter = []; + // 搜索关键词 + !empty($params['cate']) && $filter[] = ['cate', '=', "%{$params['cate']}%"]; + // 门店状态 + //is_numeric($params['status']) && $filter[] = ['status', '=', (int)$params['status']]; + return $filter; + } + + /** + * 软删除 + * @return bool + */ + public function setDelete(): bool + { + return $this->save(['is_delete' => 1]); + } +} diff --git a/app/common/model/Squarelike.php b/app/common/model/Squarelike.php new file mode 100644 index 00000000..ef503dbc --- /dev/null +++ b/app/common/model/Squarelike.php @@ -0,0 +1,91 @@ + +// +---------------------------------------------------------------------- +declare (strict_types=1); + +namespace app\common\model; + +use cores\BaseModel; +use think\model\relation\HasOne; + +/** + * 商家记录表模型 + * Class Store + * @package app\common\model + */ +class Squarelike extends BaseModel +{ + // 定义表名 + protected $name = 'square'; + + // 定义主键 + protected $pk = 'square_id'; + + + /** + * 详情信息 + * @param int $storeId + * @return static|array|null + */ + public static function detail(int $id, String $userName) + { + $where = [ + 'square_id' => $id, + 'user_name' => $userName, + 'store_id' => self::$storeId + ]; + return static::get($where, []); + } + + /** + * 获取列表数据 + * @param bool $isRecycle 是否在回收站 + * @return \think\Paginator + * @throws \think\db\exception\DbException + */ + public function getList(array $param = [], int $pageSize = 15): \think\Paginator + { + $res = $this->where($this->getFilter($param)) + ->where('is_delete', '=', 0) + ->order(['create_time' => 'desc', $this->getPk()]) + ->paginate($pageSize); + + return $res; + } + + /** + * 设置列表查询条件 + * @param array $param + * @return array + */ + private function getFilter(array $param = []): array + { + // 默认查询参数 + $params = $this->setQueryDefaultValue($param, [ + 'search' => '', // 搜索关键词: 门店名称/联系人/电话 + ]); + // 检索查询条件 + $filter = []; + // 搜索关键词 + !empty($params['cate']) && $filter[] = ['cate', '=', "%{$params['cate']}%"]; + // 门店状态 + //is_numeric($params['status']) && $filter[] = ['status', '=', (int)$params['status']]; + return $filter; + } + + /** + * 软删除 + * @return bool + */ + public function setDelete(): bool + { + return $this->save(['is_delete' => 1]); + } +} diff --git a/public/install/data/install_struct.sql b/public/install/data/install_struct.sql index 94c593ef..54cb6608 100644 --- a/public/install/data/install_struct.sql +++ b/public/install/data/install_struct.sql @@ -1740,6 +1740,23 @@ CREATE TABLE `yoshop_style` ( KEY `store_id` (`store_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='风格表'; +DROP TABLE IF EXISTS `yoshop_square`; +CREATE TABLE `yoshop_square` ( + `square_id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '动态ID', + `store_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '商城ID', + `merchant_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '商户ID、商店ID 隔离商城里面的商户', + `imgs` varchar(200) NOT NULL DEFAULT '' COMMENT '图片ID', + `content` longtext NOT NULL COMMENT '动态内容', + `cate` varchar(200) NOT NULL DEFAULT '' COMMENT '动态类别', + `user_name` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '买家用户名', + `real_name` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '真实用户名', + `is_delete` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '是否删除', + `create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间', + `update_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间', + PRIMARY KEY (`square_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', @@ -1753,5 +1770,26 @@ CREATE TABLE `yoshop_squarelike` ( `update_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间', PRIMARY KEY (`squarelike_id`), KEY `store_id` (`store_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='点赞表'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='动态点赞表'; + + +DROP TABLE IF EXISTS `yoshop_feedback`; +CREATE TABLE `yoshop_feedback` ( + `feedback_id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '动态ID', + `store_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '商城ID', + `merchant_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '商户ID、商店ID 隔离商城里面的商户', + `imgs` varchar(200) NOT NULL DEFAULT '' COMMENT '图片ID', + `suggest` longtext NOT NULL COMMENT '反馈建议', + `type` int(1) unsigned NOT NULL DEFAULT '1' COMMENT '问题类型', + `user_name` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '买家用户名', + `real_name` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '真实用户名', + `name` varchar(100) NOT NULL DEFAULT '' COMMENT '填写的用户名', + `phone` varchar(100) NOT NULL DEFAULT '' COMMENT '电话', + `unit` varchar(100) NOT NULL DEFAULT '' COMMENT '单位', + `is_delete` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '是否删除', + `create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间', + `update_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间', + PRIMARY KEY (`feedback_id`), + KEY `store_id` (`store_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='反馈表';