1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <?php
- /**
- * 同布红包(MeetOne侧链
- * User: ben
- */
- class Sync_RedpackMeetOne extends Sync_Base {
- protected $dbKey = 'dw_chat';
- protected $frequency = 1;
- protected $index = 4;
- protected $dataField = ['sender', 'status','num_left', 'quantity_left', 'quantity_left_int', 'transfer_trx_id', 'update_time_int'];
- private $objRedpack;
- private $objRedpackLog;
- private $objBind;
- /**
- * 清除数据的时间间隔
- * @var int
- */
- protected $clearTtl = 600;
- protected $clearAction = 'clearpack';
- public function __construct() {
- $this->objRedpack = new Redpack();
- $this->objRedpackLog = new RedpackLog();
- $this->objBind = new UserBindInfo;
- ENV === ENV_FORMAL && $GLOBALS['eosUrl'] = $GLOBALS['eosxURL']; // 改为MeetOne侧链
- parent::__construct('redpack', 'id', 'update_time_int', null, $GLOBALS['codeMeeMO'], ['net_id' => Eos::NET_MEETONE]);
- }
- protected function addNewRows($newRows) {
- foreach ($newRows as $k => $row) {
- $row['create_time'] = $this->formatDateTime($row['create_time']);
- $row['quantity_total_int'] = Eos::toNumber($row['quantity_total']);
- $row['quantity_left_int'] = Eos::toNumber($row['quantity_left']);
- $row['sender_id'] = $this->objBind->getUserIdBy($row['sender'], Account::TYPE_MEETONE);
- $row['net_id'] = Eos::NET_MEETONE;
- $newRows[$k] = $row;
- }
- parent::addNewRows($newRows);
- foreach ($newRows as $row) {
- // 初始化红包奖励队列
- $this->objRedpack->initReward($row, $this->objRedis, Eos::NET_MEETONE);
- }
- }
- protected function updateRow($row, $priValue, $dbRow) {
- $row['create_time'] = $this->formatDateTime($row['create_time']);
- $row['quantity_total_int'] = Eos::toNumber($row['quantity_total']);
- $row['quantity_left_int'] = Eos::toNumber($row['quantity_left']);
- parent::updateRow($row, $priValue, $dbRow);
- // 红包结束计算最佳
- if ($dbRow['status'] == 0 && $row['status'] > 0) {
- try {
- $this->objRedpackLog->updateBest($row['transfer_trx_id']);
- } catch (Exception $e) {
- alermErrorMsg($e->getMessage());
- }
- }
- }
- }
|