diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..35410ca
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# 默认忽略的文件
+/shelf/
+/workspace.xml
+# 基于编辑器的 HTTP 客户端请求
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/deployment.xml b/.idea/deployment.xml
new file mode 100644
index 0000000..3477601
--- /dev/null
+++ b/.idea/deployment.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..980fcda
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/php.xml b/.idea/php.xml
new file mode 100644
index 0000000..ed7688a
--- /dev/null
+++ b/.idea/php.xml
@@ -0,0 +1,101 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/shipin.iml b/.idea/shipin.iml
new file mode 100644
index 0000000..774cdcc
--- /dev/null
+++ b/.idea/shipin.iml
@@ -0,0 +1,107 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/webServers.xml b/.idea/webServers.xml
new file mode 100644
index 0000000..fdca20a
--- /dev/null
+++ b/.idea/webServers.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/api/controller/v1/complaint/ComplaintController.php b/app/api/controller/v1/complaint/ComplaintController.php
index d53b251..c5aca90 100644
--- a/app/api/controller/v1/complaint/ComplaintController.php
+++ b/app/api/controller/v1/complaint/ComplaintController.php
@@ -5,6 +5,10 @@ namespace app\api\controller\v1\complaint;
use app\Request;
use app\services\crud\UserComplaintServices;
+use crmeb\services\SpreadsheetExcelService;
+use mysql_xdevapi\Exception;
+use think\exception\ValidateException;
+use app\model\activity\advance\student;
class ComplaintController
{
@@ -31,21 +35,67 @@ class ComplaintController
{
}
+
/**
- * 添加投诉
+ * 添加投诉 上传模板
*/
public function addComplaint(Request $request)
{
- $data = $request->postMore([
- ['content', '']
- ]);
+ $data = $request->post();
+
+ //解析excel
+ if (!empty($data['type']) && $data['type'] == 1) {
+ $uploadDir = 'uploadsFile/';
+ if (!is_dir($uploadDir)) {
+ mkdir($uploadDir, 0777, true);
+ }
+ $tempName = $_FILES['file']['tmp_name'];
+ $targetName = $uploadDir . basename($_FILES['file']['name']);
+ // 将临时文件移动到目标位置
+ if (move_uploaded_file($tempName, $targetName)) {
+ $ff = 'https://' . $_SERVER['HTTP_HOST'] . '/' . $targetName;
+ $content = file_get_contents($ff);
+ $array = explode(PHP_EOL, $content);
+ $length = count($array);
+ foreach ($array as $k => $v) {
+ if ($k != 0 && $k != $length) {
+ if (preg_match('/(.*?)(\d+)(.*)/', $v, $matches)) {
+ $beforeNumber = $matches[1]; // 第一个数字之前的字符
+ $number = $matches[2]; // 第一个数字
+ //插入数据
+ }
+ }
+ }
+
+
+// $objPHPExcel = \PhpOffice\PhpSpreadsheet\IOFactory::load($ff);
+
+
+ }
+
+ return app('json')->fail('文件上传失败');
+ }
+
+
if (empty($data['content'])) {
return app('json')->fail(100100);
}
+ if (!empty($data['image'])) {
+ // 去除 base64 编码的前缀(如果有的话)
+ $decodedData = base64_decode($data['image']);
+ $imageName = uniqid() . '.png'; // 使用 uniqid 生成唯一的文件名
+ $savePath = 'uploads/' . $imageName; // 指定保存目录和文件名
+ // 将解码后的数据保存为文件
+ if (file_put_contents($savePath, $decodedData)) {
+ // 图片保存成功,获取图片地址
+ $imageUrl = 'http://' . $_SERVER['HTTP_HOST'] . '/uploads/' . $imageName;
+ $data['image'] = $imageUrl;
+ }
+
+ }
+
$user = $request->user()->toArray();
- // echo '
';
- // var_dump($user);
- // return false;
+
$data['school_id'] = $user['school_id'];
$data['user_id'] = $user['uid'];
$data['user_name'] = $user['real_name'];
diff --git a/app/model/activity/advance/Student.php b/app/model/activity/advance/Student.php
new file mode 100644
index 0000000..97fa156
--- /dev/null
+++ b/app/model/activity/advance/Student.php
@@ -0,0 +1,144 @@
+
+// +----------------------------------------------------------------------
+
+namespace app\model\activity\advance;
+
+use app\model\product\product\StoreDescription;
+use app\model\product\product\StoreProduct;
+use crmeb\basic\BaseModel;
+use crmeb\traits\ModelTrait;
+use think\Model;
+
+/**
+ * TODO 预售商品Model
+ * Class StoreSeckill
+ * @package app\model\activity
+ */
+class Student extends BaseModel
+{
+ /**
+ * 数据表主键
+ * @var string
+ */
+ protected $pk = 'id';
+
+ /**
+ * 模型名称
+ * @var string
+ */
+ protected $name = 'student';
+
+ use ModelTrait;
+
+ /**
+ * 一对一关联
+ * 商品关联商品商品详情
+ * @return \think\model\relation\HasOne
+ */
+ public function description()
+ {
+ return $this->hasOne(StoreDescription::class, 'product_id', 'id')->where('type', 6)->bind(['description']);
+ }
+
+ /**
+ * 一对一关联
+ * 商品关联商品商品详情
+ * @return \think\model\relation\HasOne
+ */
+ public function product()
+ {
+ return $this->hasOne(StoreProduct::class, 'id', 'product_id')->where('is_show', 1)->where('is_del', 0)->field(['id', 'cate_id'])->bind([
+ 'cate_id' => 'cate_id'
+ ]);
+ }
+
+ /**
+ * 添加时间获取器
+ * @param $value
+ * @return false|string
+ */
+ protected function getAddTimeAttr($value)
+ {
+ if ($value) return date('Y-m-d H:i:s', (int)$value);
+ return '';
+ }
+
+ /**
+ * 图片获取器
+ * @param $value
+ * @return array|mixed
+ */
+ protected function getImagesAttr($value)
+ {
+ return json_decode($value, true) ?: [];
+ }
+
+ /**
+ * 秒杀商品名称搜索器
+ * @param Model $query
+ * @param $value
+ * @param $query
+ */
+ public function searchTitleAttr($query, $value)
+ {
+ if ($value !== '') $query->where('title|id', 'like', '%' . $value . '%');
+ }
+
+ /**
+ * 是否删除搜索器
+ * @param Model $query
+ * @param $value
+ * @param $data
+ */
+ public function searchIsDelAttr($query, $value, $data)
+ {
+ $query->where('is_del', $value ?? 0);
+ }
+
+ /**
+ * 状态搜索器
+ * @param Model $query
+ * @param $value
+ * @param $data
+ */
+ public function searchStatusAttr($query, $value, $data)
+ {
+ if ($value !== '') $query->where('status', $value);
+ }
+
+ /**
+ * 状态搜索器
+ * @param Model $query
+ * @param $value
+ * @param $data
+ */
+ public function searchTypeAttr($query, $value, $data)
+ {
+ if ($value !== '') $query->where('type', $value);
+ }
+
+ /**
+ * 商品ID搜索器
+ * @param Model $query
+ * @param $value
+ * @param $data
+ */
+ public function searchProductIdAttr($query, $value, $data)
+ {
+ if ($value) {
+ if (is_array($value)) {
+ $query->whereIn('product_id', $value);
+ } else {
+ $query->where('product_id', $value);
+ }
+ }
+ }
+}