12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?php
- class Sync_Redpack 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;
-
- protected $clearTtl = 600;
- protected $clearAction = 'clearpack';
- public function __construct() {
- $this->objRedpack = new Redpack();
- $this->objRedpackLog = new RedpackLog();
- $this->objBind = new UserBindInfo;
- parent::__construct('redpack', 'id', 'update_time_int');
- }
- 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']);
- $newRows[$k] = $row;
- }
- parent::addNewRows($newRows);
- foreach ($newRows as $row) {
-
- $this->objRedpack->initReward($row, $this->objRedis);
- }
- }
- 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());
- }
- }
- }
- }
|