changeTicket2Flower(); $this->addPairDeed(); } public function changeTicket2Flower() { dump("「解锁卡转换成小花」开始"); $datas = TicketModel::select(\DB::raw('uid, count(*) as c')) ->where([['type', 5], ['state', 0], ['validity_time', '>', time()]]) ->groupBy('uid')->take(5000)->get(); foreach ($datas as $data) { dump($data); \DB::beginTransaction(); try { \DB::table('kdgx_partner_charge_user')->where('uid', $data->uid) ->increment('red_flower', $data->c * 7.5); \DB::table('kdgx_partner_charge_pay_logs')->insert([ 'uid' => $data->uid, 'type' => 5, 'red_flower' => $data->c * 7.5, 'remark' => '更新补偿', 'create_at' => time() ]); TicketModel::where([ ['type', 5], ['state', 0], ['validity_time', '>', time()], ['uid', $data->uid] ])->update(['validity_time' => mktime(12, 0, 0)]); \DB::commit(); } catch (\Exception $e) { dump($e); \DB::rollBack(); } } dump("「解锁卡转换成小花」结束"); } /** * @deprecated */ public function addPairDeed() { dump("「补全报名契约」开始"); $ings = ActivityModel::getActivitys(); $ings['last'] = 67; dump("当前处理的期数:「{$ings['last']}」"); $activity = ActivityModel::findOrFail($ings['last']); $acks = \DB::table('kdgx_fpdx_deed')->where([ ['type', 1], ['way', 0], ['publish_at', $activity->open_time] ])->pluck('way_id'); $datas = \DB::table('kdgx_partner_charge_pair')->where('stage_id', $ings['last']) ->whereNotIn('id', $acks)->get(); foreach ($datas as $data) { dump($data->id); \DB::beginTransaction(); try { if ( \DB::table('kdgx_fpdx_deed')->where([ ['type', 1], ['ack', $data->id] ])->exists() ) { continue; } else { \DB::table('kdgx_fpdx_deed')->insertGetId([ 'created_at' => time(), 'updated_at' => time(), 'uid' => $data->uid, 'sign' => '签名', 'type' => 1, 'ack' => $data->id, 'state' => 1, 'sign_at' => $data->create_time, 'publish_at' => $activity->open_time, 'confirm_at' => $activity->rematched_at, 'end_at' => $activity->close_time, 'way' => 0, 'way_id' => $data->id ]); } \DB::commit(); } catch (\Exception $e) { dump($e); \DB::rollBack(); } } dump("「补全报名契约」结束"); } }