feat(tongji): 接入小游戏真实周榜与微信分享

This commit is contained in:
大哥大哥的大哥哥
2026-07-17 18:02:00 +08:00
parent 62467dc01c
commit 7192c4db8c
8 changed files with 1014 additions and 32 deletions
@@ -21,6 +21,7 @@ use app\api\logic\tcm\DailyFamilyLikeLogic;
use app\api\logic\tcm\DailyShareLogic;
use app\api\logic\tcm\DailyPhoneLogic;
use app\api\logic\tcm\DailyDietAiLogic;
use app\api\logic\tcm\GamePlatformLogic;
use app\adminapi\logic\ConfigLogic;
use app\common\model\tcm\Diagnosis;
use app\common\model\tcm\BloodRecord;
@@ -39,6 +40,54 @@ class TcmController extends BaseApiController
* @var array
*/
public array $notNeedLogin = ['getPatientSignature', 'diagnosisDetail', 'getDict', 'confirmDiagnosis', 'getCardList', 'getOrderByNo', 'patientHangupVideo', 'dailySharePreview', 'dailyFamilyLike'];
/** 获取当前登录用户的控糖消消乐每周7人同行榜。 */
public function gameWeeklyLeaderboard()
{
$result = GamePlatformLogic::leaderboard((int) $this->userId);
if ($result === false) {
return $this->fail(GamePlatformLogic::getError());
}
return $this->data($result);
}
/** 幂等上报一局的认糖进度和分数。 */
public function gameSubmitProgress()
{
$result = GamePlatformLogic::submitProgress((int) $this->userId, [
'session_key' => (string) $this->request->post('session_key', ''),
'learned_count' => (int) $this->request->post('learned_count', 0),
'score' => (int) $this->request->post('score', 0),
'ended' => (int) $this->request->post('ended', 0),
]);
if ($result === false) {
return $this->fail(GamePlatformLogic::getError());
}
return $this->data($result);
}
/** 记录发起分享,返回本周不包含用户ID的分享码。 */
public function gameRecordShare()
{
$result = GamePlatformLogic::recordShare((int) $this->userId);
if ($result === false) {
return $this->fail(GamePlatformLogic::getError());
}
return $this->data($result);
}
/** 登录用户从微信分享卡片进入时,记录一次轻量同行关系。 */
public function gameAcceptShare()
{
$result = GamePlatformLogic::acceptShare(
(int) $this->userId,
(string) $this->request->post('invite_code', '')
);
if ($result === false) {
return $this->fail(GamePlatformLogic::getError());
}
return $this->data($result);
}
/**
* @notes 获取患者签名(供小程序调用)