roundManagementDb = new Round(); $this->gameManagementDb = new GameGpRatio(); $this->checkinManagementDb = new CheckinGpAlloc(); $this->goodManagementDb = new Good(); $this->syslogManagementDb = new Syslog(); } public function getRounds( &$cnt = 0, $orderColumn, $orderDir, $start, $length, $searchValue ) { // 選欄位 $activeStr = ''; foreach (GeneralConst::$activeMap as $k => $v) { $activeStr .= ' when \'' . $k . '\' then \'' . $v . '\''; } $rounds = $this->roundManagementDb ->select([ \DB::raw("(case when dateFinal_tmp=dateFinal and dateFinal_tmp=dateFinal and redeemExtra_tmp=redeemExtra then '' else CONCAT('通過') end) as BtnAudit"), 'id', 'roundName', \DB::raw("CONCAT(IFNULL(dateBegin_tmp, ''), '
', IFNULL(dateBegin, '')) as dateBegin"), \DB::raw("CONCAT(IFNULL(dateFinal_tmp, ''), '
', IFNULL(dateFinal, '')) as dateFinal"), \DB::raw("CONCAT(IFNULL(redeemExtra_tmp, ''), '
', IFNULL(redeemExtra, '')) as redeemExtra"), \DB::raw("(case active $activeStr end) as active"), 'cdate', 'mdate', \DB::raw("(select name from users where id=rounds.oid) as oid"), ]); // 過濾搜尋條件 // 取總筆數 $cnt = $rounds->count(); // 排序 $rounds = $rounds ->orderByRaw((int)$orderColumn . ' ' . $orderDir); // 彙整 // 分頁 $rounds = $rounds ->skip($start)->take($length); // 實際取資料 $rounds = $rounds ->get() ->toArray(); // 整理返回值並返回 return $rounds; } public function getGames( &$cnt = 0, $orderColumn, $orderDir, $start, $length, $searchValue ) { $games = $this->gameManagementDb ->select([ \DB::raw("(case when ratio_tmp=ratio and gp_tmp=gp then '' else CONCAT('通過') end) as BtnAudit"), 'id', \DB::raw("CONCAT(IFNULL(ratio_tmp, ''), '
', IFNULL(ratio, '')) as ratio"), \DB::raw("CONCAT(IFNULL(gp_tmp, ''), '
', IFNULL(gp, '')) as gp"), 'cdate', 'mdate', \DB::raw("(select name from users where id=gameGpRatio.oid) as oid"), ]); // 過濾搜尋條件 // 取總筆數 $cnt = $games->count(); // 排序 $games = $games ->orderByRaw((int)$orderColumn . ' ' . $orderDir); // 彙整 // 分頁 $games = $games ->skip($start)->take($length); // 實際取資料 $games = $games ->get() ->toArray(); // 整理返回值並返回 return $games; } public function getCheckins( &$cnt = 0, $orderColumn, $orderDir, $start, $length, $searchValue ) { $checkins = $this->checkinManagementDb ->select([ \DB::raw("(case when day_tmp=day and gp_tmp=gp then '' else CONCAT('通過') end) as BtnAudit"), 'id', \DB::raw("CONCAT(IFNULL(day_tmp, ''), '
', IFNULL(day, '')) as day"), \DB::raw("CONCAT(IFNULL(gp_tmp, ''), '
', IFNULL(gp, '')) as gp"), 'cdate', 'mdate', \DB::raw("(select name from users where id=checkinGpAlloc.oid) as oid"), ]); // 過濾搜尋條件 // 取總筆數 $cnt = $checkins->count(); // 排序 $checkins = $checkins ->orderByRaw((int)$orderColumn . ' ' . $orderDir); // 彙整 // 分頁 $checkins = $checkins ->skip($start)->take($length); // 實際取資料 $checkins = $checkins ->get() ->toArray(); // 整理返回值並返回 return $checkins; } public function getGoods( &$cnt = 0, $orderColumn, $orderDir, $start, $length, $searchValue ) { $goods = $this->goodManagementDb ->select([ \DB::raw("(case when lp_tmp=lp and gp_tmp=gp and active_tmp=active and totalQty_tmp=totalQty then '' else CONCAT('通過') end) as BtnAudit"), 'id', \DB::raw("CONCAT(IFNULL(lp_tmp, ''), '
', IFNULL(lp, '')) as lp"), \DB::raw("CONCAT(IFNULL(gp_tmp, ''), '
', IFNULL(gp, '')) as gp"), \DB::raw("CONCAT(IFNULL(active_tmp, ''), '
', IFNULL(active, '')) as active"), \DB::raw("CONCAT(IFNULL(totalQty_tmp, ''), '
', IFNULL(totalQty, '')) as totalQty"), 'issuedQty', 'cdate', 'mdate', \DB::raw("(select name from users where id=goods.oid) as oid"), ]); // 過濾搜尋條件 // 取總筆數 $cnt = $goods->count(); // 排序 $goods = $goods ->orderByRaw((int)$orderColumn . ' ' . $orderDir); // 彙整 // 分頁 $goods = $goods ->skip($start)->take($length); // 實際取資料 $goods = $goods ->get() ->toArray(); // 整理返回值並返回 return $goods; } public function passRound($id, $oid) { // 寫入 $data = [ 'dateBegin' => \DB::raw('dateBegin' . '_tmp'), 'dateFinal' => \DB::raw('dateFinal' . '_tmp'), 'redeemExtra' => \DB::raw('redeemExtra' . '_tmp'), 'mdate' => date('Y-m-d H:i:s'), 'oid' => $oid, ]; $res = $this->roundManagementDb->where('id', $id)->update($data); $rc = \DB::select("SELECT ROW_COUNT() AS rc;"); $rc = $rc[0]->rc; // syslog $this->syslogManagementDb ->insert([ 'type' => GeneralConst::LOG_ADMIN, 'func' => __FUNCTION__, 'k' => $oid, 'memoIn' => json_encode(['id' => $id, 'data' => $data], JSON_UNESCAPED_UNICODE), 'memoOut' => json_encode(['rc' => $rc], JSON_UNESCAPED_UNICODE), 'cdate' => date("Y-m-d H:i:s"), ]); // 整理返回值並返回 return $res; } public function passGame($id, $oid) { // 寫入 $data = [ 'ratio' => \DB::raw('ratio' . '_tmp'), 'gp' => \DB::raw('gp' . '_tmp'), 'mdate' => date('Y-m-d H:i:s'), 'oid' => $oid, ]; $res = $this->gameManagementDb->where('id', $id)->update($data); $rc = \DB::select("SELECT ROW_COUNT() AS rc;"); $rc = $rc[0]->rc; // syslog $this->syslogManagementDb ->insert([ 'type' => GeneralConst::LOG_ADMIN, 'func' => __FUNCTION__, 'k' => $oid, 'memoIn' => json_encode(['id' => $id, 'data' => $data], JSON_UNESCAPED_UNICODE), 'memoOut' => json_encode(['rc' => $rc], JSON_UNESCAPED_UNICODE), 'cdate' => date("Y-m-d H:i:s"), ]); // 整理返回值並返回 return $res; } public function passCheckin($id, $oid) { // 寫入 $data = [ 'day' => \DB::raw('day' . '_tmp'), 'gp' => \DB::raw('gp' . '_tmp'), 'mdate' => date('Y-m-d H:i:s'), 'oid' => $oid, ]; $res = $this->checkinManagementDb->where('id', $id)->update($data); $rc = \DB::select("SELECT ROW_COUNT() AS rc;"); $rc = $rc[0]->rc; // syslog $this->syslogManagementDb ->insert([ 'type' => GeneralConst::LOG_ADMIN, 'func' => __FUNCTION__, 'k' => $oid, 'memoIn' => json_encode(['id' => $id, 'data' => $data], JSON_UNESCAPED_UNICODE), 'memoOut' => json_encode(['rc' => $rc], JSON_UNESCAPED_UNICODE), 'cdate' => date("Y-m-d H:i:s"), ]); // 整理返回值並返回 return $res; } public function passGood($id, $oid) { // 寫入 $data = [ 'lp' => \DB::raw('lp' . '_tmp'), 'gp' => \DB::raw('gp' . '_tmp'), 'active' => \DB::raw('active' . '_tmp'), 'totalQty' => \DB::raw('totalQty' . '_tmp'), 'mdate' => date('Y-m-d H:i:s'), 'oid' => $oid, ]; $res = $this->goodManagementDb->where('id', $id)->update($data); $rc = \DB::select("SELECT ROW_COUNT() AS rc;"); $rc = $rc[0]->rc; // syslog $this->syslogManagementDb ->insert([ 'type' => GeneralConst::LOG_ADMIN, 'func' => __FUNCTION__, 'k' => $oid, 'memoIn' => json_encode(['id' => $id, 'data' => $data], JSON_UNESCAPED_UNICODE), 'memoOut' => json_encode(['rc' => $rc], JSON_UNESCAPED_UNICODE), 'cdate' => date("Y-m-d H:i:s"), ]); // 整理返回值並返回 return $res; } }