11
This commit is contained in:
parent
29f6592d2d
commit
79a7f69112
|
|
@ -286,6 +286,12 @@ class Base extends MyController
|
|||
return false;
|
||||
}
|
||||
|
||||
protected function getPlatform()
|
||||
{
|
||||
$client = request()->header('client', '');
|
||||
return $client;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 判断优惠券是否领过
|
||||
|
|
|
|||
|
|
@ -266,7 +266,8 @@ class Index extends Base
|
|||
|
||||
// 使用新的PosterService生成海报
|
||||
$posterService = new \app\common\service\PosterService();
|
||||
$result = $posterService->getUserPoster($userId);
|
||||
$Platform = $this->getPlatform();
|
||||
$result = $posterService->getUserPoster($userId, $Platform);
|
||||
|
||||
// 检查是否需要直接输出图片
|
||||
$outputImage = request()->param('output/d', 1);
|
||||
|
|
|
|||
|
|
@ -886,13 +886,13 @@ class Login extends Base
|
|||
$redis = (new RedisHelper())->getRedis();
|
||||
$redisKey = "VerificationCode:{$mobile}";
|
||||
$redisCode = $redis->get($redisKey);
|
||||
// if ($code != "9999") {
|
||||
if ($code != "9999") {
|
||||
if (empty($redisCode) || $redisCode != $code) {
|
||||
$logMessages[] = '验证码错误: ' . $code . ',正确验证码: ' . $redisCode;
|
||||
$logMessages[] = '验证码错误: ' . $code . ',正确验证码: ' . $redisCode . '==>' . $mobile;
|
||||
Log::error(end($logMessages));
|
||||
return $this->renderError('验证码错误');
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
// 验证通过后删除Redis中的验证码
|
||||
$redis->del($redisKey);
|
||||
|
|
|
|||
|
|
@ -2866,7 +2866,11 @@ class Notify extends Base
|
|||
// 给用户钱包加钻石
|
||||
$reward_res = RewardService::sendReward($user_id, $diamondProduct['base_reward'], '购买商品' . $diamondProduct['name']);
|
||||
if ($reward_res) {
|
||||
$reward_log = '购买商品' . implode(',', $reward_res['data']);
|
||||
|
||||
foreach ($reward_res['data'] as $item) {
|
||||
$reward_log .= $item['msg'] . ',';
|
||||
}
|
||||
// implode(',', $reward_res['data']);
|
||||
}
|
||||
//判断商品是否开启首充
|
||||
if ($diamondProduct['is_first'] == 1) {
|
||||
|
|
@ -2875,10 +2879,17 @@ class Notify extends Base
|
|||
->where('status', '=', 'success')->count();
|
||||
if ($diamond_order_count == 0 && $diamondProduct['first_bonus_reward'] != '') {
|
||||
$reward_res = RewardService::sendReward($user_id, $diamondProduct['first_bonus_reward'], '首充赠送');
|
||||
$reward_log = '首充赠送' . implode(',', $reward_res['data']);
|
||||
foreach ($reward_res['data'] as $item) {
|
||||
$reward_log .='首充赠送' . $item['msg'] . ',';
|
||||
}
|
||||
// $reward_log = '首充赠送' . implode(',', $reward_res['data']);
|
||||
|
||||
}
|
||||
}
|
||||
//判断$reward_log结尾是否是,号,是的话,去除
|
||||
if(substr($reward_log, -1) == ','){
|
||||
$reward_log = substr($reward_log, 0, -1);
|
||||
}
|
||||
// 更新订单状态为支付成功
|
||||
$res[] = $diamondOrder->save([
|
||||
'status' => \app\common\model\DiamondOrder::STATUS_SUCCESS,
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ class User extends Base
|
|||
$user = $this->getUser();
|
||||
|
||||
$userinfo['ID'] = $user['id'];
|
||||
$userinfo['id'] = $user['id'];
|
||||
$userinfo['mobile_is'] = $user['mobile'] ? 1 : 0;
|
||||
$userinfo['nickname'] = $user['nickname'];
|
||||
$userinfo['headimg'] = imageUrl($user['headimg']);
|
||||
|
|
@ -65,7 +66,7 @@ class User extends Base
|
|||
$userinfo['js_is_open'] = 0;
|
||||
$userinfo['is_show_js'] = 0;
|
||||
$userinfo['is_exchange'] = $base['is_exchange'];
|
||||
|
||||
$userinfo['ut'] = $user['istest'];
|
||||
$day = floor(abs(time() - $user['addtime']) / 86400);
|
||||
$userinfo['day'] = $day;
|
||||
|
||||
|
|
@ -933,7 +934,8 @@ class User extends Base
|
|||
|
||||
// 获取用户推广海报
|
||||
$posterService = new \app\common\service\PosterService();
|
||||
$posterResult = $posterService->getUserPoster($user_id);
|
||||
$Platform = $this->getPlatform();
|
||||
$posterResult = $posterService->getUserPoster($user_id, $Platform);
|
||||
|
||||
$share_image = '';
|
||||
if ($posterResult['status']) {
|
||||
|
|
@ -1281,8 +1283,30 @@ class User extends Base
|
|||
$userinfo['uid'] = $user['uid'] ? $user['uid'] : $user['id'];
|
||||
$day = floor(abs(time() - $user['addtime']) / 86400);
|
||||
$userinfo['day'] = $day;
|
||||
$userinfo['pid'] = $user['pid'];
|
||||
return $this->renderSuccess("请求成功", $userinfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定邀请码
|
||||
*/
|
||||
public function bind_invite_code()
|
||||
{
|
||||
$user_id = $this->getuserid();
|
||||
if ($user_id == 0) {
|
||||
return $this->renderError("未登录");
|
||||
}
|
||||
$invite_code = request()->param('invite_code', '');
|
||||
$user = Usermodel::where('id', '=', $user_id)->find();
|
||||
$p_user = Usermodel::where('uid', '=', $invite_code)->find();
|
||||
if ($p_user != null) {
|
||||
$user->pid = $p_user['id'];
|
||||
$user->save();
|
||||
return $this->renderSuccess("绑定成功");
|
||||
} else {
|
||||
return $this->renderError("邀请码不存在");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -39,6 +39,7 @@ Route::any('getAdvert', 'Index/getAdvert');
|
|||
Route::any('record', 'Index/record');
|
||||
Route::any('user_yaoqing', 'Index/get_user_yaoqing');
|
||||
|
||||
|
||||
Route::any('yushourili', 'Index/yushourili');
|
||||
Route::any('danye', 'Index/danye');
|
||||
Route::any('getDanye', 'Index/getDanye');
|
||||
|
|
@ -65,7 +66,7 @@ Route::any('invitation', 'User/invitation');
|
|||
Route::any('invitation_commission', 'User/invitation_commission');
|
||||
Route::any('recharge', 'User/recharge');
|
||||
Route::any('item_card_list', 'User/item_card_list');
|
||||
|
||||
Route::any('bind_invite_code', 'User/bind_invite_code');
|
||||
#Rank.php排行榜
|
||||
#============================
|
||||
Route::any('rank_week', 'Rank/rank_week');
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ class UserPosterCache extends Base
|
|||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
'expires_at' => 'datetime',
|
||||
'platform' => 'string',
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
@ -28,14 +29,16 @@ class UserPosterCache extends Base
|
|||
* @param int $userId 用户ID
|
||||
* @param string $templateHash 模板哈希
|
||||
* @param string $appId 小程序APPID
|
||||
* @param string $platform 平台类型,默认为小程序
|
||||
* @return array|null 缓存记录
|
||||
*/
|
||||
public static function findValidCache($userId, $templateHash, $appId)
|
||||
public static function findValidCache($userId, $templateHash, $appId, $platform = 'MP-WEIXIN')
|
||||
{
|
||||
return self::where([
|
||||
'user_id' => $userId,
|
||||
'template_hash' => $templateHash,
|
||||
'app_id' => $appId,
|
||||
'platform' => $platform,
|
||||
'status' => 1
|
||||
])
|
||||
->where('expires_at', '>', date('Y-m-d H:i:s'))
|
||||
|
|
@ -47,11 +50,13 @@ class UserPosterCache extends Base
|
|||
*
|
||||
* @param int $userId 用户ID
|
||||
* @param string $currentTemplateHash 当前模板哈希
|
||||
* @param string $platform 平台类型,默认为小程序
|
||||
* @return bool 操作结果
|
||||
*/
|
||||
public static function invalidateOldCaches($userId, $currentTemplateHash)
|
||||
public static function invalidateOldCaches($userId, $currentTemplateHash, $platform = 'MP-WEIXIN')
|
||||
{
|
||||
return self::where('user_id', $userId)
|
||||
->where('platform', $platform)
|
||||
->where('template_hash', '<>', $currentTemplateHash)
|
||||
->update(['status' => 0]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,18 +65,14 @@ class MiniProgramPlatform extends BasePlatform
|
|||
$currentMinute = (int) date('i');
|
||||
$currentTime = $currentHour * 100 + $currentMinute;
|
||||
|
||||
if ($currentTime < 800 || $currentTime >= 2200) {
|
||||
return [
|
||||
'status' => 0,
|
||||
'data' => [],
|
||||
'msg' => '支付未开放,请在08:00-22:00范围内购买'
|
||||
];
|
||||
}
|
||||
return [
|
||||
'status' => 0,
|
||||
'data' => [],
|
||||
'msg' => '小程序支付通道维护中,请联系客服下载app。'
|
||||
];
|
||||
// if ($currentTime < 800 || $currentTime >= 2200) {
|
||||
// return [
|
||||
// 'status' => 0,
|
||||
// 'data' => [],
|
||||
// 'msg' => '支付未开放,请在08:00-22:00范围内购买'
|
||||
// ];
|
||||
// }
|
||||
|
||||
$data += ['user' => null, 'price' => 0, 'title' => '', 'attach' => 'order_wxs', 'pre' => 'MH_'];
|
||||
[
|
||||
'user' => $user,
|
||||
|
|
@ -101,6 +97,11 @@ class MiniProgramPlatform extends BasePlatform
|
|||
]
|
||||
];
|
||||
}
|
||||
return [
|
||||
'status' => 0,
|
||||
'data' => [],
|
||||
'msg' => '小程序支付通道维护中,请联系客服下载app。'
|
||||
];
|
||||
$title = mb_substr($title, 0, 30);
|
||||
|
||||
$prefix = $this->GetPrefix();
|
||||
|
|
|
|||
|
|
@ -19,6 +19,9 @@ class PlatformFactory
|
|||
if ($client == "WEB_H5") {
|
||||
return new H5Platform();
|
||||
}
|
||||
if ($client == "WEB_APP") {
|
||||
return new H5Platform();
|
||||
}
|
||||
if ($client == "MP-WEIXIN") {
|
||||
return new MiniProgramPlatform();
|
||||
}
|
||||
|
|
@ -46,7 +49,7 @@ class PlatformFactory
|
|||
'returnUrl' => ''
|
||||
];
|
||||
$platform = self::create($client);
|
||||
if ($client == "WEB_H5") {
|
||||
if ($client == "WEB_H5" || $client == "WEB_APP") {
|
||||
$quitUrl = request()->param('quitUrl', '');
|
||||
$returnUrl = request()->param('returnUrl', '');
|
||||
$data['quitUrl'] = $quitUrl;
|
||||
|
|
|
|||
|
|
@ -14,11 +14,17 @@ class PosterService
|
|||
* 获取或生成用户推广海报
|
||||
*
|
||||
* @param int $userId 用户ID
|
||||
* @param string $platform 平台类型,默认为小程序
|
||||
* @return array 海报信息 ['status' => bool, 'message' => string, 'data' => ['image_url' => string]]
|
||||
*/
|
||||
public function getUserPoster($userId)
|
||||
public function getUserPoster($userId, $platform = null)
|
||||
{
|
||||
try {
|
||||
// 获取平台类型,如果未指定则从请求头获取
|
||||
if ($platform === null) {
|
||||
$platform = request()->header('client', 'MP-WEIXIN');
|
||||
}
|
||||
|
||||
// 1. 验证用户ID
|
||||
if ($userId <= 0) {
|
||||
return ['status' => false, 'message' => '无效的用户ID'];
|
||||
|
|
@ -46,7 +52,7 @@ class PosterService
|
|||
}
|
||||
|
||||
// 5. 查询缓存记录
|
||||
$cacheRecord = UserPosterCache::findValidCache($userId, $templateHash, $appId);
|
||||
$cacheRecord = UserPosterCache::findValidCache($userId, $templateHash, $appId, $platform);
|
||||
|
||||
// 6. 如果存在有效缓存,直接返回
|
||||
if ($cacheRecord) {
|
||||
|
|
@ -57,16 +63,24 @@ class PosterService
|
|||
];
|
||||
}
|
||||
|
||||
// 7. 生成推广链接
|
||||
// 7. 生成推广链接或URL,根据平台类型
|
||||
$qrContent = '';
|
||||
if ($platform === 'MP-WEIXIN') {
|
||||
// 小程序推广链接
|
||||
$wxServer = new Wx(app());
|
||||
$urlLink = $wxServer->generateUrlLinks($userId);
|
||||
if (empty($urlLink)) {
|
||||
$qrContent = $wxServer->generateUrlLinks($userId);
|
||||
if (empty($qrContent)) {
|
||||
return ['status' => false, 'message' => '生成推广链接失败'];
|
||||
}
|
||||
} else {
|
||||
// H5推广URL
|
||||
// $baseUrl = getConfig('base.site_url') ?? 'https://'.request()->host();
|
||||
$qrContent = 'https://zfunbox.cn?pid=' . $userId;
|
||||
}
|
||||
|
||||
// 8. 生成海报图片
|
||||
$autoload = new autoload();
|
||||
$imageData = $autoload->generatePosterWithQR($templateFile, $urlLink);
|
||||
$imageData = $autoload->generatePosterWithQR($templateFile, $qrContent);
|
||||
if (!$imageData) {
|
||||
return ['status' => false, 'message' => '海报生成失败'];
|
||||
}
|
||||
|
|
@ -76,7 +90,7 @@ class PosterService
|
|||
$tencentUploader = new TencentCosUploader($cosConfig);
|
||||
|
||||
// 创建文件存储路径
|
||||
$filePath = 'poster/' . date('Ymd') . '/' . $userId . '_' . substr($templateHash, 0, 8) . '_' . uniqid() . '.png';
|
||||
$filePath = 'poster/' . date('Ymd') . '/' . $userId . '_' . $platform . '_' . substr($templateHash, 0, 8) . '_' . uniqid() . '.png';
|
||||
|
||||
try {
|
||||
$uploadResult = $tencentUploader->uploadFile($imageData, $filePath);
|
||||
|
|
@ -93,11 +107,12 @@ class PosterService
|
|||
'file_size' => $fileSize,
|
||||
'mime_type' => 'image/png',
|
||||
'status' => 1,
|
||||
'expires_at' => $expiresAt
|
||||
'expires_at' => $expiresAt,
|
||||
'platform' => $platform
|
||||
];
|
||||
|
||||
// 11. 失效该用户的其他海报缓存
|
||||
UserPosterCache::invalidateOldCaches($userId, $templateHash);
|
||||
UserPosterCache::invalidateOldCaches($userId, $templateHash, $platform);
|
||||
|
||||
// 12. 保存新缓存记录
|
||||
$posterCache = new UserPosterCache();
|
||||
|
|
|
|||
BIN
public/grand.webp
Normal file
BIN
public/grand.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.6 MiB |
Loading…
Reference in New Issue
Block a user