| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- <?php
- /*
- * @Author: wang jun
- * @Date: 2021-10-29 16:16:29
- * @Last Modified by: wang jun
- * @Last Modified time: 2021-12-31 17:52:41
- */
- namespace app\index\server;
- use app\index\model\signinmodel;
- use app\index\model\userinfomodel;
- use app\index\server\scorebusinessserver as BusinessBase;
- /**
- * 签到
- * 20220104
- * wj
- */
- class signinbusinessserver extends BusinessBase
- {
- private $info;
- //private $option;
- private $param;
- public function dobusiness($param)
- {
- $this->param = $param;
- $this->info = $this->getinfo($this->param);
- //$this->option = json_decode($this->info['option'], true);
- //$isaddscore = false;
- $msg = "签到";
- $uinfo = $this->getuserinfo();
- $userid = $uinfo['id'];
- $issign = $this->issign();
- if ($issign) {
- return backarr(0, "已签到");
- }
- $adddata = [
- 'sourcedemo' => $msg,
- 'userid' => $userid,
- 'scoretype' => $this->info['scoretype'],
- 'addscore' => $this->info['score'],
- 'sourcetype' => 2,
- ];
- $result = $this->adduserscore($adddata);
- if (empty($result['status'])) {
- return $result;
- }
- $data = $result['data'];
- $uaarid = $data['uaarid'];
- $recorddata = [
- 'sbid' => $this->info['id'],
- 'code' => $this->info['code'],
- 'refid' => $uaarid,
- 'type' => 1, //积分增加
- ];
- $id = $this->newrecord($recorddata);
- if (!$id) {
- log::error($msg . " 创建关系失败");
- }
- $returndata = [
- 'uaarid' => $uaarid,
- 'addscore' => $adddata['addscore'],
- ];
- return backarr(1, $msg, $returndata);
- }
- /**
- * 是否签到
- * 20220105
- * wj
- */
- private function issign()
- {
- $arr = $this->param;
- $m_s = new signinmodel();
- $where = [
- 'userid' => $arr['userid'],
- 'signdate' => date('Y-m-d'),
- ];
- $count = $m_s->getList($where, 'count');
- return 1 < $count ? true : false;
- }
- /**
- * 获取分享详情
- * 20220104
- * wj
- */
- private function getuserinfo()
- {
- $arr = $this->param;
- $checkuserinfo = isset($arr['checkuserinfo']) && $arr['checkuserinfo'] ? true : false;
- $where = [];
- if (isset($arr['userid'])) {
- $where['id'] = $arr['userid'];
- }
- if (isset($arr['openid'])) {
- $where['openid'] = $arr['openid'];
- }
- if (empty($where)) {
- throw new Exception("请求数据错误");
- }
- if ($checkuserinfo) {
- $m_u = new userinfomodel();
- $info = $m_u->getInfo($where);
- if (empty($info)) {
- throw new Exception("无用户信息");
- }
- } else {
- $info = $where;
- }
- return $info;
- }
- }
|