|
@@ -0,0 +1,146 @@
|
|
|
+<?php
|
|
|
+/*
|
|
|
+ * @Author: wang jun
|
|
|
+ * @Date: 2022-01-18 11:12:23
|
|
|
+ * @Last Modified by: wang jun
|
|
|
+ * @Last Modified time: 2022-01-19 15:51:59
|
|
|
+ */
|
|
|
+namespace app\admin\logic;
|
|
|
+
|
|
|
+use app\admin\model\partymodel;
|
|
|
+use think\facade\Log;
|
|
|
+
|
|
|
+class partylogic extends baselogic
|
|
|
+{
|
|
|
+ /**
|
|
|
+ * 设置请求数据规则
|
|
|
+ * 20220107
|
|
|
+ * wj
|
|
|
+ */
|
|
|
+ protected function setrules()
|
|
|
+ {
|
|
|
+ $list = [
|
|
|
+ 'saveinfo' => [
|
|
|
+ ['name' => 'id', 'title' => 'id', 'type' => 'numeric'],
|
|
|
+ ],
|
|
|
+ 'getinfobyid' => [
|
|
|
+ ['name' => 'id', 'title' => 'id', 'require' => true, 'type' => 'numeric'],
|
|
|
+ ],
|
|
|
+ 'getlistbywhere' => [
|
|
|
+ ['name' => 'isactive', 'title' => 'isactive', 'type' => 'numeric', 'regex' => '/[0|1]{1}/'],
|
|
|
+ ['name' => 'name', 'title' => 'name', 'type' => 'string'],
|
|
|
+ ['name' => 'createdate', 'title' => 'createdate', 'type' => 'array'],
|
|
|
+ ['name' => 'page', 'title' => 'page', 'type' => 'numeric'],
|
|
|
+ ['name' => 'size', 'title' => 'size', 'type' => 'numeric'],
|
|
|
+ ],
|
|
|
+ ];
|
|
|
+ return $list;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 保存活动信息
|
|
|
+ * 20220210
|
|
|
+ * wj
|
|
|
+ */
|
|
|
+ public function saveinfo($arr)
|
|
|
+ {
|
|
|
+ $result = $this->checkparam(__FUNCTION__, $arr);
|
|
|
+ if (1 != $result['status']) {
|
|
|
+ return $result;
|
|
|
+ }
|
|
|
+ $id = $arr['id'];
|
|
|
+ $m_p = new partymodel();
|
|
|
+ $isupdate = false;
|
|
|
+ if (empty($id)) {
|
|
|
+ //创建
|
|
|
+ unset($arr['id']);
|
|
|
+ $insertData = [
|
|
|
+ 'name' => $arr['name'],
|
|
|
+ 'start_time' => $arr['createdate'][0],
|
|
|
+ 'end_time' => $arr['createdate'][0],
|
|
|
+ 'banner_photo' => $arr['bannerphoto'],
|
|
|
+ ];
|
|
|
+ $id = $m_p->insertData($insertData);
|
|
|
+ if (empty($id)) {
|
|
|
+ return backarr(0, "添加失败");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //修改
|
|
|
+ $isupdate = true;
|
|
|
+ $where = ['id' => $id];
|
|
|
+ $info = $m_p->getInfo($where);
|
|
|
+ if (empty($info)) {
|
|
|
+ return backarr(0, "数据不存在");
|
|
|
+ }
|
|
|
+ $fields = ['name', 'start_time', 'end_time', 'isactive', 'banner_photo'];
|
|
|
+ $updateData = [];
|
|
|
+ foreach ($arr as $key => $value) {
|
|
|
+ if (in_array($key, $fields) && !empty($value) && $value != $info[$key]) {
|
|
|
+ $updateData[$key] = $value;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ log::info($updateData);
|
|
|
+ if (!empty($updateData)) {
|
|
|
+ $m_p->updateinfo($where, $updateData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return backarr(1, "操作成功", ['id' => $id, 'isupdate' => $isupdate]);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 根据id获取信息
|
|
|
+ * 20220210
|
|
|
+ * wj
|
|
|
+ */
|
|
|
+ public function getinfobyid($arr)
|
|
|
+ {
|
|
|
+ $result = $this->checkparam(__FUNCTION__, $arr);
|
|
|
+ if (1 != $result['status']) {
|
|
|
+ return $result;
|
|
|
+ }
|
|
|
+ $id = $arr['id'];
|
|
|
+ $m_p = new partymodel();
|
|
|
+ $where = ['id' => $id];
|
|
|
+ $info = $m_p->getInfo($where);
|
|
|
+ if (empty($info)) {
|
|
|
+ return backarr(0, "数据不存在");
|
|
|
+ }
|
|
|
+ return backarr(1, "操作成功", $info);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 根据条件获取列表
|
|
|
+ * 20220210
|
|
|
+ * wj
|
|
|
+ */
|
|
|
+ public function getlistbywhere($arr)
|
|
|
+ {
|
|
|
+ $result = $this->checkparam(__FUNCTION__, $arr);
|
|
|
+ if (1 != $result['status']) {
|
|
|
+ return $result;
|
|
|
+ }
|
|
|
+ if (isset($arr['isactive'])) {
|
|
|
+ $where[] = ['isactive', '=', $arr['isactive']];
|
|
|
+ }
|
|
|
+ if (isset($arr['name'])) {
|
|
|
+ $where[] = ['name', 'like', '%' . $arr['name'] . '%'];
|
|
|
+ }
|
|
|
+ if (isset($arr['createdate'])) {
|
|
|
+ $createdate = $arr['createdate'];
|
|
|
+ if (count($createdate) == count(array_filter($createdate))) {
|
|
|
+ $where[] = ['create_time', '>=', $createdate[0]];
|
|
|
+ $where[] = ['create_time', '<=', $createdate[1]];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $m_p = new partymodel();
|
|
|
+ $count = $m_p->getList($where, 'count');
|
|
|
+ if ($count <= 0) {
|
|
|
+ return backarr(0, "无数据");
|
|
|
+ }
|
|
|
+ $page = isset($arr['page']) && !empty($arr['page']) ? $arr['page'] : 1;
|
|
|
+ $size = isset($arr['size']) && !empty($arr['size']) ? $arr['size'] : 10;
|
|
|
+ $list = $m_p->getList($where, '*', $page, $size);
|
|
|
+ $data = [
|
|
|
+ 'list' => $list,
|
|
|
+ 'total' => $count,
|
|
|
+ ];
|
|
|
+ return backarr(1, "查询成功", $data);
|
|
|
+ }
|
|
|
+}
|