|
|
@@ -6,7 +6,9 @@ use app\portal\model\UserModel;
|
|
|
use app\weixin\model\Books;
|
|
|
use app\weixin\model\Devices;
|
|
|
use app\weixin\model\Member;
|
|
|
+use app\weixin\model\UserBalanceLog;
|
|
|
use app\weixin\model\UserContactLog;
|
|
|
+use app\weixin\service\Award;
|
|
|
use app\weixin\service\PRedis;
|
|
|
use think\Controller;
|
|
|
|
|
|
@@ -117,14 +119,14 @@ class TaskController extends Controller
|
|
|
$userIds = [];
|
|
|
$queenKey = "queens:hearts:" . date('Ymd');
|
|
|
//echo $queenKey."<br>\n";
|
|
|
- for($i=0; $i<500; $i++){
|
|
|
+ for ($i = 0; $i < 500; $i++) {
|
|
|
$userId = PRedis::lpop($queenKey);
|
|
|
//echo $userId."\n";
|
|
|
- if($userId){
|
|
|
+ if ($userId) {
|
|
|
$userIds[] = $userId;
|
|
|
- $url = url('/api/task/catchUserHeart','','', true);
|
|
|
+ $url = url('/api/task/catchUserHeart', '', '', true);
|
|
|
|
|
|
- httpRequest($url, ['uid'=> $userId],'post','', 2);
|
|
|
+ httpRequest($url, ['uid' => $userId], 'post', '', 2);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -140,7 +142,8 @@ class TaskController extends Controller
|
|
|
/**
|
|
|
* 处理怦然心动
|
|
|
*/
|
|
|
- public function catchUserHeart(){
|
|
|
+ public function catchUserHeart()
|
|
|
+ {
|
|
|
$uid = input('uid', 0);
|
|
|
$dataList = Member::getHeartList($uid, '', true);
|
|
|
showJson(1005, 1001, $dataList);
|
|
|
@@ -183,13 +186,13 @@ class TaskController extends Controller
|
|
|
$userids = [];
|
|
|
$queenKey = "queens:hearts:" . date('Ymd');
|
|
|
foreach ($dataList as $userId) {
|
|
|
- if ($userId && PRedis::rpush($queenKey, $userId)) {
|
|
|
+ if ($userId && PRedis::rpush($queenKey, $userId)) {
|
|
|
$userids[] = $userId;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- PRedis::expire($queenKey, 2*3600);
|
|
|
- PRedis::set('tasks:hearts:' . date('Ymd'), ['datalist' => $dataList, 'results' => $userids, 'time'=> date('Y-m-d H:i:s'), 'sql' => $sql], 3600);
|
|
|
+ PRedis::expire($queenKey, 2 * 3600);
|
|
|
+ PRedis::set('tasks:hearts:' . date('Ymd'), ['datalist' => $dataList, 'results' => $userids, 'time' => date('Y-m-d H:i:s'), 'sql' => $sql], 3600);
|
|
|
$msg = "更新推荐数据入队结果,累计处理" . count($userids) . "个会员数据更新";
|
|
|
return showJson(1005, $msg, "\n");
|
|
|
} catch (\Exception $exception) {
|
|
|
@@ -205,7 +208,8 @@ class TaskController extends Controller
|
|
|
* @throws \think\exception\DbException
|
|
|
* @throws \think\exception\PDOException
|
|
|
*/
|
|
|
- public function updateHeartStatus(){
|
|
|
+ public function updateHeartStatus()
|
|
|
+ {
|
|
|
set_time_limit(0);
|
|
|
$key = input('key', '');
|
|
|
$checkKey = config('task.upHeartKey');
|
|
|
@@ -216,7 +220,7 @@ class TaskController extends Controller
|
|
|
$dataList = Member::alias('m')
|
|
|
->join('user_profile up', 'up.userid=m.id', 'left')
|
|
|
->where($where)
|
|
|
- ->where(function($query){
|
|
|
+ ->where(function ($query) {
|
|
|
$query->where(db()->raw("up.introduce is NULL or up.introduce = ''"))
|
|
|
->whereOr(db()->raw("up.family is NULL or up.family = ''"))
|
|
|
->whereOr(db()->raw("up.hobby is NULL or up.hobby = ''"))
|
|
|
@@ -226,13 +230,65 @@ class TaskController extends Controller
|
|
|
})
|
|
|
->field('m.id,up.introduce,up.family,up.hobby,up.purpose,up.cause,up.expect')
|
|
|
->select()
|
|
|
- ->each(function($profile, $k){
|
|
|
- if(empty($profile) || (empty($profile['photolist']) || empty($profile['introduce']) || empty($profile['family']) || empty($profile['hobby']) || empty($profile['purpose']) || empty($profile['cause']) || empty($profile['expect']))){
|
|
|
- Member::where(['id'=> $profile['id']])->update(['is_heart'=> 2,'remark'=> '系统检测自动设置隐身']);
|
|
|
+ ->each(function ($profile, $k) {
|
|
|
+ if (empty($profile) || (empty($profile['photolist']) || empty($profile['introduce']) || empty($profile['family']) || empty($profile['hobby']) || empty($profile['purpose']) || empty($profile['cause']) || empty($profile['expect']))) {
|
|
|
+ Member::where(['id' => $profile['id']])->update(['is_heart' => 2, 'remark' => '系统检测自动设置隐身']);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
|
|
|
showJson(1005, 1001, $dataList);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 活动报名分销收益结算
|
|
|
+ * @throws \think\Exception
|
|
|
+ * @throws \think\Exception\DbException
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ */
|
|
|
+ public function catchBookMarket()
|
|
|
+ {
|
|
|
+ set_time_limit(0);
|
|
|
+ $key = input('key', '');
|
|
|
+ $checkKey = config('task.catchBookMarket');
|
|
|
+ if ($key != $checkKey) {
|
|
|
+ showJson(1004, 2009, '', "\n");
|
|
|
+ }
|
|
|
+
|
|
|
+ $catchIds = [];
|
|
|
+ $catchList = [];
|
|
|
+ $bookList = Books::alias('b')
|
|
|
+ ->leftJoin('activity a', 'a.id=b.aid')
|
|
|
+ ->leftJoin('user u', 'u.id=b.uid')
|
|
|
+ ->where('a.endtime', '<=', time())
|
|
|
+// ->where('a.endtime', '>', time()-24*3600*3)
|
|
|
+ ->where('u.parent_id', '>', 0)
|
|
|
+ ->where(['a.is_top' => 0, 'a.status' => 1, 'b.status' => 3, 'b.is_market' => 2])
|
|
|
+ ->field('b.id,b.uid,b.aid,b.money,u.parent_id,b.status')
|
|
|
+ ->order('b.book_at asc,b.id asc')
|
|
|
+ ->paginate(50)
|
|
|
+ ->each(function ($item, $k) use (&$catchList, &$catchIds) {
|
|
|
+ $userId = isset($item['uid']) ? intval($item['uid']) : 0;
|
|
|
+ $aid = isset($item['aid']) ? $item['aid'] : 0;
|
|
|
+ $money = isset($item['money']) ? floatval($item['money']) : 0;
|
|
|
+ $inviteInfo = Member::getInviteInfo($userId);
|
|
|
+ $inviteId = isset($inviteInfo['invite_id']) ? $inviteInfo['invite_id'] : 0;
|
|
|
+ if ($inviteInfo && $inviteId > 0 && $aid > 0 && $money > 0) {
|
|
|
+ if (!UserBalanceLog::checkHasMarketBySource($inviteId, $userId, $aid, 9)) {
|
|
|
+ $catchList[] = $item;
|
|
|
+ PRedis::set('markets:activity:book_' . $userId . '_' . $aid . '_' . $inviteId, ['info' => $item, 'inviteInfo' => $inviteInfo], 7200);
|
|
|
+ Award::marketAward($inviteId, $userId, 9, $money);
|
|
|
+ $catchIds[] = $item['id'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ if($catchIds){
|
|
|
+ Books::whereIn('id', $catchIds)->update(['is_market'=> 1,'remark'=> '分销已结算']);
|
|
|
+ }
|
|
|
+
|
|
|
+ $bookList = $bookList? $bookList->toArray() : [];
|
|
|
+ showJson(1005, 1001, ['total'=> $bookList['total'],'bookList' => $bookList['data'], 'catchList' => $catchList]);
|
|
|
+ }
|
|
|
}
|