Exemplo n.º 1
0
 public function calMarketingLinkAction()
 {
     $this->_log("*********  START " . date("Y-m-d H:i:s") . " - Marketing Link *********");
     //Update Register
     $character_obj = new \HaiQuan\Backend\Models\Character();
     $character_banner = $character_obj->getCharacterLink()->toArray();
     $link = new \HaiQuan\Backend\Models\Link();
     if (!empty($character_banner)) {
         foreach ($character_banner as $banner) {
             if (isset($banner["banner"]) && !empty($banner["banner"])) {
                 $link->updateLinkByID(array("link_register" => $banner["value"]), base64_decode($banner["banner"]));
             }
         }
     }
     //Update Revenue
     $payment_obj = new \HaiQuan\Backend\Models\Payment();
     $payment_revenue = $payment_obj->marketingRevenue()->toArray();
     if (!empty($payment_revenue)) {
         foreach ($payment_revenue as $revenue) {
             if (isset($revenue["pid"]) && !empty($revenue["pid"])) {
                 $link->updateLinkByID(array("link_revenue" => $revenue["totalmoney"]), base64_decode($revenue["pid"]));
             }
         }
     }
     //Update Nau
     $nau_link = $character_obj->nauByPID()->toArray();
     if (!empty($nau_link)) {
         foreach ($nau_link as $banner) {
             if (isset($banner["pid"]) && !empty($banner["pid"])) {
                 $link->updateLinkByID(array("link_nau" => $banner["total"]), base64_decode($banner["pid"]));
             }
         }
     }
     //Update PU
     $payment_revenue = $payment_obj->marketingPU()->toArray();
     if (!empty($payment_revenue)) {
         foreach ($payment_revenue as $revenue) {
             if (isset($revenue["pid"]) && !empty($revenue["pid"])) {
                 $link->updateLinkByID(array("link_pu" => $revenue["total"]), base64_decode($revenue["pid"]));
             }
         }
     }
     $this->_log("********* END - Marketing Link *********");
     $this->calMarketingLinkDate();
     //  $this->sendNotice();
     echo "success";
     exit;
 }
Exemplo n.º 2
0
 public function editLinkAction()
 {
     $this->checkPermision("marketing");
     $data_edit = $this->request->getPost("data", null, false);
     $response = array("status" => 0, "message" => "Không Thành Công");
     $link_obj = new \HaiQuan\Backend\Models\Link();
     if (!empty($data_edit)) {
         $data_edit["link_updated_date"] = date("Y-m-d H:i:s");
         if (!isset($data_edit["link_id"]) || empty($data_edit["link_id"])) {
             //Insert
             unset($data_edit["link_id"]);
             $data_edit["link_click"] = 0;
             $data_edit["link_register"] = 0;
             $data_edit["link_created_date"] = date("Y-m-d H:i:s");
             $result = $link_obj->save($data_edit);
             $data_edit["link_id"] = $link_obj->link_id;
             //                $data_query                     = array(
             //                    "campaignname" => $data_edit["link_description"],
             //                    "pid"          => base64_encode($data_edit["link_id"]),
             //                    "client_id"    => $this->config["MKT_CLIENT"]
             //                );
             //                $ch1                            = curl_init();
             //                curl_setopt($ch1, CURLOPT_HEADER, false);
             //                curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
             //                curl_setopt($ch1, CURLOPT_SSL_VERIFYHOST, 0);
             //                curl_setopt($ch1, CURLOPT_SSL_VERIFYPEER, 0);
             //                curl_setopt($ch1, CURLOPT_USERPWD, $this->config["MKT_CLIENT"] . ":" . md5($this->config["MKT_SECRET"] . $this->config["MKT_CLIENT"]));
             //                curl_setopt($ch1, CURLOPT_URL, "http://mkt.vielink.vn/api/UpdateCampaign?" . http_build_query($data_query));
             //                $data                           = curl_exec($ch1);
         } else {
             $result = $link_obj->updateLinkByID($data_edit, $data_edit["link_id"]);
         }
         if ($result) {
             $response["status"] = 1;
         } else {
             $response["message"] = implode(";", $link_obj->getMessages());
         }
         $data_edit["link_ba"] = base64_encode($data_edit["link_id"]);
         $response["data"] = $data_edit;
     }
     echo json_encode($response);
     exit;
 }