123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232 |
- <?php
- /*
- * @Author: wang jun
- * @Date: 2021-11-18 11:26:25
- * @Last Modified by: wang jun
- * @Last Modified time: 2021-12-29 14:44:51
- */
- namespace app\index\logic;
- use app\index\logic\businesslogic;
- use app\index\model\userinfomodel;
- use app\index\model\userpartymodel;
- use app\index\model\userpartypicturemodel;
- class partylogic
- {
- /**
- * 获取活动信息
- *
- * @param [array] $arr
- * @return void
- */
- public function getpartyinfo($arr)
- {
- if (!isset($arr['code']) || empty($arr['code'])) {
- return backarr(0, "请求失败");
- }
- $code = $arr['code'];
- $data = [
- 'type' => 'normal',
- 'typeid' => 1,
- //'code' => 'P202201121202'
- 'code' => $code,
- ];
- $l_bl = new businesslogic();
- $result = $l_bl->handlepartybusiness($data);
- if (1 != $result['status']) {
- return $result;
- }
- return backarr(1, "success", $result['data']);
- }
- /**
- * 用户参与活动
- * wj
- * 20220112
- * @return array
- */
- public function partinparty($arr)
- {
- $fillfield = ['userid', 'code'];
- foreach ($fillfield as $key => $value) {
- if (!isset($arr[$value]) || empty($arr[$value])) {
- return backarr(0, "请求失败");
- }
- }
- $userid = $arr['userid'];
- $code = $arr['code'];
- //活动业务处理
- $data = [
- 'userid' => $userid,
- 'type' => 'normal',
- 'typeid' => 1,
- //'code' => 'P202201121202'
- 'code' => $code,
- ];
- $l_bl = new businesslogic();
- $result = $l_bl->handlepartybusiness($data);
- if (1 != $result['status']) {
- return $result;
- }
- $partyinfo = $result['data'];
- $partyid = $partyinfo['id'];
- $m_u = new userinfomodel();
- $uinfo = $m_u->getInfo(['id' => $userid], ['wname', 'id', 'telno']);
- if (empty($uinfo)) {
- return backarr(0, "无用户信息");
- }
- $m_up = new userpartymodel();
- $where = [
- 'partyid' => $partyid,
- 'userid' => $userid,
- ];
- $upinfo = $m_up->getInfo($where);
- $isnew = false;
- if (empty($upinfo)) {
- $upinsertData = [
- 'partyid' => $partyid,
- 'userid' => $userid,
- 'createtime' => date('Y-m-d H:i:s'),
- ];
- $upid = $m_up->insertData($upinsertData);
- if (empty($upid)) {
- return backarr(0, "用户活动信息创建失败");
- }
- $where = ['id' => $upid];
- $upinfo = $m_up->getInfo($where);
- $isnew = true;
- }
- $upinfo['isnew'] = $isnew;
- $upinfo['userinfo'] = $uinfo;
- return backarr(1, "查询成功", $upinfo);
- }
- /**
- * 保存参与信息
- * wj
- * 20220112
- * @return array
- */
- public function saveinfo($arr)
- {
- if (!isset($arr['id']) || empty($arr['id'])) {
- return backarr(0, "请求失败");
- }
- $id = $arr['id'];
- $m_up = new userpartymodel();
- $where = [
- 'id' => $id,
- ];
- $upinfo = $m_up->getInfo($where);
- if (empty($upinfo)) {
- return backarr(0, '无对应信息');
- }
- $updateData = [];
- if (isset($arr['info']) && !empty($arr['info']) && is_string($arr['info'])) {
- $updateData['info'] = $arr['info'];
- }
- if (empty($updateData)) {
- return backarr(0, "无修改信息");
- }
- $row = $m_up->updateinfo($where, $updateData);
- return backarr(1, "修改成功", ['id' => $id]);
- }
- /**
- * 保存参与图片
- * wj
- * 20220112
- * @return array
- */
- public function savepicture($arr)
- {
- $m_upp = new userpartypicturemodel();
- $isnew = true;
- $id = 0;
- if (isset($arr['id']) && !empty($arr['id'])) {
- $where = [
- 'id' => $arr['id'],
- 'userid' => $arr['userid'],
- 'partyid' => $arr['partyid'],
- ];
- $info = $m_upp->getInfo($where);
- if ($info) {
- $isnew = false;
- $id = $info['id'];
- $updatefield = ['pictureurl'];
- $updateData = [];
- foreach ($updatefield as $key => $value) {
- if (isset($arr[$value]) && $arr[$value] != $info[$value]) {
- $updateData[$value] = $arr[$value];
- }
- }
- if (!empty($updateData)) {
- $where = ['id' => $id];
- $row = $m_upp->updateinfo($where, $updateData);
- if (empty($row)) {
- return backarr(0, "图片修改失败");
- }
- }
- }
- }
- if ($isnew) {
- $id = $m_upp->insertData($arr);
- if (empty($id)) {
- return backarr(0, "新增失败");
- }
- }
- if (empty($id)) {
- return backarr(0, "操作失败");
- }
- return backarr(1, "新增成功", ['id' => $id]);
- }
- /**
- * 获取上传图片
- * wj
- * 20220112
- * @return array
- */
- public function getpicture($arr)
- {
- $m_upp = new userpartypicturemodel();
- $where = [
- 'partyid' => $arr['partyid'],
- 'userid' => $arr['userid'],
- ];
- $page = isset($arr['page']) && !empty($arr['page']) ? $arr['page'] : 1;
- $size = isset($arr['size']) && !empty($arr['size']) ? $arr['size'] : 10;
- $count = $m_upp->getList($where, "count");
- if ($count <= 0) {
- return backarr(0, "无数据");
- }
- $list = $m_upp->getList($where, "*", $page, $size, 'sort asc');
- $data = [
- 'count' => $count,
- 'list' => $list,
- ];
- return backarr(1, "新增成功", $data);
- }
- /**
- * 设置上传完成
- * wj
- * 20220114
- * @return array
- */
- public function setisoverbyid($arr)
- {
- if (!isset($arr['id']) || empty($arr['id'])) {
- return backarr(0, "请求失败");
- }
- $id = $arr['id'];
- $m_up = new userpartymodel();
- $where = [
- 'id' => $id,
- ];
- $upinfo = $m_up->getInfo($where);
- if (empty($upinfo)) {
- return backarr(0, '无对应信息');
- }
- $updateData = ['isover' => 1];
- $row = $m_up->updateinfo($where, $updateData);
- return backarr(1, "修改成功", ['id' => $id]);
- }
- }
|