|
@@ -8,10 +8,10 @@ use app\common\library\Tlssigapiv2;
|
|
|
use think\Db;
|
|
|
class Plantask extends Controller
|
|
|
{
|
|
|
- //关于计划任务
|
|
|
+ //关于本文件里的计划任务
|
|
|
//只有 public 方法,auto_开头的才是计划任务,其他private 方法都是工具方法
|
|
|
|
|
|
-
|
|
|
+////////////////////////////////////////下面都是计划任务方法///////////////////////////////////////////////////////////////
|
|
|
//主动拉取im群组内 聊天记录
|
|
|
public function auto_imgroup(){
|
|
|
$im_config = config('tencent_im');
|
|
@@ -131,7 +131,66 @@ class Plantask extends Controller
|
|
|
exit;
|
|
|
}
|
|
|
|
|
|
+ //送礼物(api/party/giveGiftToYou)拆分出来的异步用户升级方法,
|
|
|
+ public function auto_user_level_up(){
|
|
|
+ Db::startTrans();
|
|
|
+ $tasklist = Db::name('gift_user_party')->where('task_status',0)->limit(20)->lock(true)->select();
|
|
|
+ if(empty($tasklist)){
|
|
|
+ Db::rollback();
|
|
|
+ echo 'empty';
|
|
|
+ exit;
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ $getempirical_conf = config("site.getempirical");
|
|
|
+ foreach($tasklist as $key => $giftuserparty){
|
|
|
+ echo $giftuserparty['id'].'<br>';
|
|
|
+
|
|
|
+ $giftValue = $giftuserparty['value'];
|
|
|
+ $hotValue = $giftValue;
|
|
|
+ //用户经验升级
|
|
|
+ $getempirical = $getempirical_conf * $hotValue;
|
|
|
+ // 获取用户贵族信息
|
|
|
+ $noble = \app\common\model\User::getUserNoble($giftuserparty['user_id']);
|
|
|
+ if(isset($noble["noble_on"]) && $noble["noble_on"] == 1) {
|
|
|
+ $getempirical = $getempirical + $getempirical * ($noble["explain"]/100);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 增加用户经验值
|
|
|
+ $res = \app\common\model\User::addEmpirical($giftuserparty['user_id'],$getempirical);
|
|
|
+ /*if ($res){
|
|
|
+ $this->auth->level = $res->level;
|
|
|
+ }*/
|
|
|
+
|
|
|
+ //增加被送礼物用户的魅力等级
|
|
|
+ $res_charm = \app\common\model\User::add_charm_level($giftuserparty['user_to_id'],$giftValue);
|
|
|
+
|
|
|
+ // +exp
|
|
|
+ \app\common\model\TaskLog::tofinish($giftuserparty['user_id'],"OBHqCX4g",$giftuserparty['number']);
|
|
|
+
|
|
|
+ // +message
|
|
|
+ //\app\common\model\Message::addMessage($user_id,"礼物通知","收到 ".$this->auth->nickname." 赠送的".$giftInfo["name"]." x".$number." 价值 ".$giftValue ." 钻石");
|
|
|
+
|
|
|
+ //增加送礼用户的财富等级
|
|
|
+ $res_wealth = \app\common\model\User::add_wealth_level($giftuserparty['user_id'],$giftValue);
|
|
|
+
|
|
|
+ Db::name('gift_user_party')->where('id',$giftuserparty['id'])->update(['task_status'=>1]);
|
|
|
+ }
|
|
|
+ Db::commit();
|
|
|
+ } catch (ValidateException $e) {
|
|
|
+ Db::rollback();
|
|
|
+ $this->error($e->getMessage());
|
|
|
+ } catch (PDOException $e) {
|
|
|
+ Db::rollback();
|
|
|
+ $this->error($e->getMessage());
|
|
|
+ } catch (Exception $e) {
|
|
|
+ Db::rollback();
|
|
|
+ $this->error($e->getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
+/////////////////////////////////////////下面都是工具方法////////////////////////////////////////////////
|
|
|
//下载远程文件 到指定目录
|
|
|
private function downloadfile($file_url, $path = '', $save_file_name = '')
|
|
|
{
|