'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]); } }