/** * Handle GDoctor business command * * @param $app * @param $user * @param $replyArr * @return message string */ public static function handle($app, $openId, $replyArr) { $cmdType = self::dispatch($replyArr); switch ($cmdType) { case self::CMD_ACTIVITY: return self::activityPlugin($app, $openId, $replyArr); break; case self::CMD_SUBSCRIBE: return SubscribeHandler::subscribe($app, $openId, $replyArr); break; case self::CMD_UNSUBSCRIBE: return SubscribeHandler::unsubscribe($app, $openId); break; case self::CMD_REGISTER: return RegisterHandler::userRegister($app, $openId, $replyArr); break; case self::CMD_VALIDATE: return RegisterHandler::userValidate($app, $openId, $replyArr); break; case self::CMD_PUBLIC: return ReplyFormat::replyPublic($replyArr); break; default: return false; break; } }
/** * reply subscribe command * * @param $replyArr * @return Message string */ public static function subscribe($app, $openId, $replyArr) { $isDelete = UserOpenid::isDelete($app['id'], $openId); if ($isDelete) { $model = UserOpenid::where(['wechat_id' => $app['id'], 'open_id' => $openId, 'is_delete' => 1])->get()->first(); if ($model) { $model->is_delete = 0; $model->updated_at = Carbon::now(); if ($model->save()) { if (UserCache::addUser($app, $openId)) { return ReplyFormat::replyPublic($replyArr); } } } } else { $model = new UserOpenid(); $model->open_id = $openId; $model->is_delete = 0; $model->created_at = Carbon::now(); $model->updated_at = Carbon::now(); if ($model->save()) { if (UserCache::addUser($app, $openId)) { return ReplyFormat::replyPublic($replyArr); } } } return false; }
public static function queryPrize($app, $user, $replyArr) { //TODO 查看当前科室会的奖品 return ReplyFormat::replyPublic($replyArr); }
/** * Validate mobile * * @param $app * @param $user * @param $replyArr * @return message string */ public static function userValidate($app, $openId, $replyArr) { $user = UserCache::getByOpenId($app, $openId); if (!$user) { SysLog::error(__FILE__, __METHOD__, __LINE__, 'user not found by openid'); return false; } if (!array_key_exists('cmd_number', $replyArr)) { return ReplyFormat::replyText(SysParams::sys_error['error_empty_validate_code']); } //验证码 $code = $replyArr['cmd_number'][0]; //验证码位数错误 if (strlen($code) != 6) { return ReplyFormat::replyText(SysParams::sys_error['error_invalid_validate_code']); } //检查验证码正确性 $data = self::validateRegisterCode($app, $user, $code); if (!$data) { return ReplyFormat::replyText(SysParams::sys_error['error_wrong_validate_code']); } //用户注册处理 $isReg = self::registerHandle($app, $user, $data['mobile']); if (!$isReg) { return false; } return ReplyFormat::replyPublic($replyArr); }