/**
  * 保存联盟订单
  *
  * @param array $order
  * @param array $affiliate
  * @return string
  */
 public function save_affiliate_order($order, $affiliate)
 {
     //计算IP
     $f = intval($order['ip'] / (256 * 256 * 256));
     $f_r = $order['ip'] - 256 * 256 * 256 * $f;
     $s = intval($f_r / (256 * 256));
     $s_r = $f_r - 256 * 256 * $s;
     $t = intval($s_r / 256);
     $t_r = $s_r - 256 * $t;
     $ip = "{$f}.{$s}.{$t}.{$t_r}";
     /* 联盟订单记录 start */
     $query_struct = array('affiliate_id' => $affiliate['affiliate_id'], 'affiliate_name' => $affiliate['affiliate_name'], 'site_id' => $order['site_id'], 'site_name' => $_SERVER['HTTP_HOST'], 'order_num' => $order['order_num'], 'order_amount' => $order['total_product'], 'currency' => $order['currency'], 'order_time' => $order['date_add'], 'user_ip' => $ip, 'user_country' => $order['billing_country']);
     //判断订单是否有记录防止重复发送
     $arr = Affiliate_orderService::get_instance()->query_row(array('where' => array('order_num' => $order['order_num'])));
     if (!empty($arr)) {
         return '<!-- this order has been recorded before -->';
     }
     $orm_instance = ORM::factory('affiliate_order');
     $data = $orm_instance->as_array();
     foreach ($query_struct as $key => $val) {
         array_key_exists($key, $data) && ($orm_instance->{$key} = $val);
     }
     $orm_instance->save();
     return 1;
 }
Beispiel #2
0
 /**
  * 订单支付成功页获取的单独的代码,向联盟发送订单成功支付信息
  *
  * @param array $order
  * @param string $affiliate_name
  * @return string
  */
 function get_code($order, $affiliate_name = 'shareasale')
 {
     //检查联盟是否安装,并获取联盟的信息
     $affiliate = Site_affiliateService::get_instance()->query_row(array('where' => array('affiliate_name' => $affiliate_name, 'site_id' => $order['site_id'], 'mark' => 1)));
     if (empty($affiliate)) {
         return '<!-- affiliate ' . $affiliate_name . ' is not exist,or been uninstalled -->';
     }
     $prm_value = json_decode($affiliate['prm_value']);
     //货币转换相关
     $currency = $affiliate['currency'] == 'default' ? Kohana::config('affiliates.affiliatefuture.currency') : $affiliate['currency'];
     if ($currency != 'default') {
         $order['total_product'] = isset($order['total_products']) ? BLL_Currency::get_price($order['total_products'], $order['currency'], $currency) : BLL_Currency::get_price($order['total_product'], $order['currency'], $currency);
         $order['total_product'] = str_replace(',', '', $order['total_product']);
         //$order['total_product'] = BLL_Currency::get_price($order['total_product'], $order['currency'], $currency);
         $order['currency'] = $currency;
     }
     $save_return = Affiliate_orderService::save_affiliate_order($order, $affiliate);
     if ($save_return != 1) {
         return $save_return;
     }
     $string = "<img src=\"https://shareasale.com/sale.cfm" . "?amount={$order['total_product']}" . "&tracking={$order['order_num']}" . "&transtype=" . Kohana::config('affiliates.shareasale.transtype') . "&merchantID={$prm_value->merchantid}\" width=\"1\" height=\"1\">";
     return $string;
 }
Beispiel #3
0
 /**
  * 订单支付成功页获取的单独的代码,向联盟发送订单成功支付信息
  *
  * @param array $order
  * @param string $affiliate_name
  * @return string
  */
 function get_code($order, $affiliate_name = 'clixgalore')
 {
     //获取站点联盟信息,并判断是否
     $affiliate = Site_affiliateService::get_instance()->query_row(array('where' => array('affiliate_name' => $affiliate_name, 'site_id' => $order['site_id'], 'mark' => 1)));
     if (empty($affiliate)) {
         return '<!-- affiliate ' . $affiliate_name . ' is not exist,or been uninstalled -->';
     }
     $prm_value = json_decode($affiliate['prm_value']);
     //货币转换相关
     $currency = $affiliate['currency'] == 'default' ? Kohana::config('affiliates.affiliatefuture.currency') : $affiliate['currency'];
     if ($currency != 'default') {
         $order['total_product'] = isset($order['total_products']) ? BLL_Currency::get_price($order['total_products'], $order['currency'], $currency) : BLL_Currency::get_price($order['total_product'], $order['currency'], $currency);
         $order['total_product'] = str_replace(',', '', $order['total_product']);
         //$order['total_product'] = BLL_Currency::get_price($order['total_product'], $order['currency'], $currency);
         $order['currency'] = $currency;
     }
     $save_return = Affiliate_orderService::save_affiliate_order($order, $affiliate);
     if ($save_return != 1) {
         return $save_return;
     }
     //要返回的联盟的代码
     $string = "<!--begin clixGalore code -->" . "<img src=\"https://www.clixGalore.com/AdvTransaction.aspx" . "?AdID={$prm_value->adid}" . "&SV={$order['total_product']}" . "&OID={$order['order_num']}\" height=\"1\" width=\"1\" border=\"0\">" . "<!--end clixGalore code -->";
     return $string;
 }
Beispiel #4
0
 /**
  * 订单支付成功页获取的单独的代码,向联盟发送订单成功支付信息
  *
  * @param array $order
  * @param string $affiliate_name
  * @return string
  */
 function get_code($order, $affiliate_name = 'earnmoney')
 {
     //获取站点联盟信息,并判断是否
     $affiliate = Site_affiliateService::get_instance()->query_row(array('where' => array('affiliate_name' => $affiliate_name, 'site_id' => $order['site_id'], 'mark' => 1)));
     if (empty($affiliate)) {
         return '<!-- affiliate ' . $affiliate_name . ' is not exist,or been uninstalled -->';
     }
     $prm_value = json_decode($affiliate['prm_value']);
     //检查参数格式是否正确,如果参数格式不正确不予以处理
     $params = cookie::get('earnmoney_params');
     $strDecode = self::uriDecode($params);
     $aryParams = explode('|', $strDecode);
     if ('nid' == $aryParams[0] && 'uid' == $aryParams[2] && 'resource' == $aryParams[4] && 'url' == $aryParams[6]) {
         $url = $aryParams[7];
         $uid = $aryParams[3];
         $nid = $aryParams[1];
         $resource = $aryParams[5];
     } else {
         return '<!-- prams format is not exact -->';
     }
     //货币转换相关
     $currency = $affiliate['currency'] == 'default' ? Kohana::config('affiliates.affiliatefuture.currency') : $affiliate['currency'];
     if ($currency != 'default') {
         $order['total_product'] = isset($order['total_products']) ? BLL_Currency::get_price($order['total_products'], $order['currency'], $currency) : BLL_Currency::get_price($order['total_product'], $order['currency'], $currency);
         $order['total_product'] = str_replace(',', '', $order['total_product']);
         //$order['total_product'] = BLL_Currency::get_price($order['total_product'], $order['currency'], $currency);
         $order['currency'] = $currency;
     }
     $save_return = Affiliate_orderService::save_affiliate_order($order, $affiliate);
     if ($save_return != 1) {
         return $save_return;
     }
     $post_var = "uid=" . $uid . "&nid=" . $nid . "&order_num=" . $order['order_num'] . "&order_amount=" . $order['total_product'] . "&referAddress=" . "http://" . $_SERVER['HTTP_HOST'] . "/";
     self::cul_em($post_var);
     return '<!-- earnmoney 数据发送成功 -->';
 }
Beispiel #5
0
 /**
  * 订单支付成功页获取的单独的代码,向联盟发送订单成功支付信息
  *
  * @param array $order
  * @param string $affiliate_name
  * @return string
  */
 public function get_code($order, $affiliate_name = 'affiliatefuture')
 {
     //获取站点联盟信息,并判断是否
     $affiliate = Site_affiliateService::get_instance()->query_row(array('where' => array('affiliate_name' => $affiliate_name, 'site_id' => $order['site_id'], 'mark' => 1)));
     if (empty($affiliate)) {
         return '<!-- affiliate ' . $affiliate_name . ' is not exist,or been uninstalled -->';
     }
     $prm_value = json_decode($affiliate['prm_value']);
     //货币转换相关
     $currency = $affiliate['currency'] == 'default' ? Kohana::config('affiliates.affiliatefuture.currency') : $affiliate['currency'];
     if ($currency != 'default') {
         $order['total_product'] = isset($order['total_products']) ? BLL_Currency::get_price($order['total_products'], $order['currency'], $currency) : BLL_Currency::get_price($order['total_product'], $order['currency'], $currency);
         $order['total_product'] = str_replace(',', '', $order['total_product']);
         //$order['total_product'] = BLL_Currency::get_price($order['total_product'], $order['currency'], $currency);
         $order['currency'] = $currency;
     }
     $save_return = Affiliate_orderService::save_affiliate_order($order, $affiliate);
     if ($save_return != 1) {
         return $save_return;
     }
     //要返回的联盟的代码
     $string = "<script language=\"javascript\" src=\"https://scripts.affiliatefuture.com/AFFunctions.js\"></script>\n\t\t<script language=\"javascript\">\n\t\t   var merchantID = {$prm_value->merchantid};\n\t\t   var orderValue = '{$order['total_product']}';\n\t\t   var orderRef = '{$order['order_num']}';\n\t\t   var payoutCodes = '" . Kohana::config('affiliates.affiliatefuture.payoutcodes') . "';\n\t\t   var offlineCode = '" . Kohana::config('affiliates.affiliatefuture.offlinecode') . "';\n\t\t   AFProcessSaleV2(merchantID, orderValue, orderRef,payoutCodes,offlineCode);\n\t\t</script>";
     return $string;
 }
 /**
  * 订单支付成功页获取的单独的代码,向联盟发送订单成功支付信息
  *
  * @param array $order
  * @param string $affiliate_name
  * @return string
  */
 function get_code($order, $affiliate_name = 'commissionjunction')
 {
     //获取站点联盟信息,并判断是否
     $affiliate = Site_affiliateService::get_instance()->query_row(array('where' => array('affiliate_name' => $affiliate_name, 'site_id' => $order['site_id'], 'mark' => 1)));
     if (empty($affiliate)) {
         return '<!-- affiliate ' . $affiliate_name . ' is not exist,or been uninstalled -->';
     }
     $prm_value = json_decode($affiliate['prm_value']);
     //货币转换相关
     $currency = $affiliate['currency'] == 'default' ? Kohana::config('affiliates.affiliatefuture.currency') : $affiliate['currency'];
     if ($currency != 'default') {
         $order['total_product'] = isset($order['total_products']) ? BLL_Currency::get_price($order['total_products'], $order['currency'], $currency) : BLL_Currency::get_price($order['total_product'], $order['currency'], $currency);
         $order['total_product'] = str_replace(',', '', $order['total_product']);
         //$order['total_product'] = BLL_Currency::get_price($order['total_product'], $order['currency'], $currency);
         $order['currency'] = $currency;
     }
     $save_return = Affiliate_orderService::save_affiliate_order($order, $affiliate);
     if ($save_return != 1) {
         return $save_return;
     }
     //要返回的联盟的代码
     $string = "<img src=\"https://www.emjcd.com/u" . "?AMOUNT={$order['total_product']}" . "&CID={$prm_value->cid}" . "&OID={$order['order_num']}" . "&TYPE=" . $prm_value->actionid . "&CURRENCY={$order['currency']}&" . "METHOD=IMG\" height=\"1\" width=\"1\">";
     return $string;
 }
Beispiel #7
0
 /**
  * 订单支付成功页获取的单独的代码,向联盟发送订单成功支付信息
  *
  * @param array $order
  * @param string $affiliate_name
  * @return string
  */
 function get_code($order, $affiliate_name = 'linkshare')
 {
     //获取站点联盟信息,并判断是否
     $affiliate = Site_affiliateService::get_instance()->query_row(array('where' => array('affiliate_name' => $affiliate_name, 'site_id' => $order['site_id'], 'mark' => 1)));
     if (empty($affiliate)) {
         return '<!-- affiliate ' . $affiliate_name . ' is not exist,or been uninstalled -->';
     }
     $prm_value = json_decode($affiliate['prm_value']);
     //货币转换相关
     $currency = $affiliate['currency'] == 'default' ? Kohana::config('affiliates.affiliatefuture.currency') : $affiliate['currency'];
     /* 订单详情 */
     $where = array();
     $where['site_id'] = $order['site_id'];
     $where['order_id'] = $order['id'];
     /* 订单产品 */
     $order_products = Myorder_product::instance()->order_products($where);
     $namelist = $amtlist = $qlist = $skulist = array();
     foreach ($order_products as $key => $order_product_detail) {
         $namelist[] = urlencode($order_product_detail['name']);
         $skulist[] = $order_product_detail['SKU'];
         $qlist[] = $order_product_detail['quantity'];
         $amount = $order_product_detail['discount_price'] * $order_product_detail['quantity'] * 100;
         $amount = str_replace(',', '', $amount);
         $amtlist[] = $currency != 'default' ? BLL_Currency::get_price($amount, $order['currency'], $currency) : $amount;
     }
     $order['namelist'] = implode("|", $namelist);
     $order['skulist'] = implode("|", $skulist);
     $order['qlist'] = implode("|", $qlist);
     $order['amtlist'] = implode("|", $amtlist);
     if ($currency != 'default') {
         $order['total_product'] = isset($order['total_products']) ? BLL_Currency::get_price($order['total_products'], $order['currency'], $currency) : BLL_Currency::get_price($order['total_product'], $order['currency'], $currency);
         $order['total_product'] = str_replace(',', '', $order['total_product']);
         //$order['total_product'] = BLL_Currency::get_price($order['total_product'], $order['currency'], $currency);
         $order['currency'] = $currency;
     }
     $save_return = Affiliate_orderService::save_affiliate_order($order, $affiliate);
     if ($save_return != 1) {
         return $save_return;
     }
     $string = "<img src=\"http://track.linksynergy.com/ep" . "?mid={$prm_value->mid}" . "&ord={$order['order_num']}" . "&skulist={$order['skulist']}" . "&qlist={$order['qlist']}" . "&amtlist={$order['amtlist']}" . "&cur={$order['currency']}" . "&namelist={$order['namelist']}\" height=\"1\" width=\"1\">";
     return $string;
 }
Beispiel #8
0
 /**
  * 订单支付成功页获取的单独的代码,向联盟发送订单成功支付信息
  *
  * @param array $order
  * @param string $affiliate_name
  * @return string
  */
 function get_code($order, $affiliate_name = 'webgains')
 {
     //检查联盟是否安装,并获取联盟的信息
     $affiliate = Site_affiliateService::get_instance()->query_row(array('where' => array('affiliate_name' => $affiliate_name, 'site_id' => $order['site_id'], 'mark' => 1)));
     if (empty($affiliate)) {
         return '<!-- affiliate ' . $affiliate_name . ' is not exist,or been uninstalled -->';
     }
     $prm_value = json_decode($affiliate['prm_value']);
     //货币转换相关
     $currency = $affiliate['currency'] == 'default' ? Kohana::config('affiliates.affiliatefuture.currency') : $affiliate['currency'];
     if ($currency != 'default') {
         $order['total_product'] = isset($order['total_products']) ? BLL_Currency::get_price($order['total_products'], $order['currency'], $currency) : BLL_Currency::get_price($order['total_product'], $order['currency'], $currency);
         $order['total_product'] = str_replace(',', '', $order['total_product']);
         //$order['total_product'] = BLL_Currency::get_price($order['total_product'], $order['currency'], $currency);
         $order['currency'] = $currency;
     }
     $save_return = Affiliate_orderService::save_affiliate_order($order, $affiliate);
     if ($save_return != 1) {
         return $save_return;
     }
     $string = "<!-- <webgains tracking code> -->\n\t\t<script language=\"javascript\" type=\"text/javascript\">\n\t\tvar wgOrderReference = '{$order['order_num']}';\n\t\tvar wgOrderValue = '{$order['total_product']}';\n\t\tvar wgEventID = '{$prm_value->wgeventid}';\n\t\tvar wgComment = '';\n\t\tvar wgLang = 'en_EN';\n\t\tvar wgsLang = 'javascript-client';\n\t\tvar wgVersion = '1.2';\n\t\tvar wgProgramID = '{$prm_value->wgprogramid}';\n\t\tvar wgSubDomain = 'track';\n\t\tvar wgCheckSum = '';\n\t\tvar wgItems = '';\n\t\tvar wgVoucherCode = '';\n\t\tvar wgCustomerID = '';\n\t\t\n\t\tif(location.protocol.toLowerCase() == \"https:\") wgProtocol=\"https\";\n\t\telse wgProtocol = \"http\";\n\t\t\n\t\twgUri = wgProtocol + \"://\" + wgSubDomain + \".webgains.com/transaction.html\" + \"?wgver=\" + wgVersion + \"&wgprotocol=\" + wgProtocol + \"&wgsubdomain=\" + wgSubDomain + \"&wgslang=\" + wgsLang + \"&wglang=\" + wgLang + \"&wgprogramid=\" + wgProgramID + \"&wgeventid=\" + wgEventID + \"&wgvalue=\" + wgOrderValue + \"&wgchecksum=\" + wgCheckSum + \"&wgorderreference=\"  + wgOrderReference + \"&wgcomment=\" + escape(wgComment) + \"&wglocation=\" + escape(document.referrer) + \"&wgitems=\" + escape(wgItems) + \"&wgcustomerid=\" + escape(wgCustomerID) + \"&wgvouchercode=\" + escape(wgVoucherCode);\n\t\tdocument.write('<sc'+'ript language=\"JavaScript\"  type=\"text/javascript\" src=\"'+wgUri+'\"></sc'+'ript>');\n\t\t\n\t\t</script>\n\t\t<noscript>\n\t\t<img src=\"http://track.webgains.com/transaction.html" . "?wgver=1.2" . "&wgprogramid={$prm_value->wgprogramid}" . "&wgrs=1" . "&wgvalue={$order['total_product']}" . "&wgeventid={$prm_value->wgeventid}" . "&wgorderreference={$order['order_num']}" . "&wgitems=&wgvouchercode=&wgcustomerid=\" alt=\"\" />\n\t\t</noscript>\n\t\t<!-- </webgains tracking code> -->";
     return $string;
 }
Beispiel #9
0
 /**
  * 对网站联盟订单的查询处理
  *
  */
 public function select()
 {
     $site_id_list = role::check('affiliate');
     $return_struct = array('status' => 0, 'code' => 501, 'msg' => 'Not Implemented', 'content' => array());
     try {
         //* 初始化返回数据 */
         $return_data = array('assoc' => NULL, 'count' => 0);
         //* 收集请求数据 ==根据业务逻辑定制== */
         $request_data = $this->input->get();
         $site_ids = role::get_site_ids();
         if (empty($site_ids)) {
             throw new MyRuntimeException(Kohana::lang('o_global.access_denied'), 403);
         }
         $in_site_id = site::id();
         if (isset($request_data['site_id']) and $request_data['site_id'] === '0') {
             unset($request_data['site_id']);
         }
         if (isset($request_data['site_id']) and !in_array($request_data['site_id'], $site_ids)) {
             throw new MyRuntimeException(Kohana::lang('o_global.access_denied'), 403);
         }
         if ($in_site_id > 0) {
             $query_site_id = $in_site_id;
         } else {
             $query_site_id = $site_ids;
             //throw new MyRuntimeException(Kohana::lang('o_global.select_site'), 400);
         }
         $site_name = Mysite::instance($this->site_id)->get('domain');
         //页数
         $page = isset($request_data['page']) && intval($request_data['page']) >= 1 ? intval($request_data['page']) : 1;
         //联盟id
         $affiliate_id = isset($request_data['affiliate_id']) && intval($request_data['affiliate_id']) >= 1 ? intval($request_data['affiliate_id']) : 0;
         //起始时间
         $time_f = isset($request_data['time_f']) ? $request_data['time_f'] : date('Y-m-d', time() - 86400 * 365 * 5);
         $time_f = $time_f == '' ? date('Y-m-d', time() - 86400 * 365 * 5) : $time_f;
         //结束时间
         $time_t = isset($request_data['time_t']) ? $request_data['time_t'] : date('Y-m-d');
         $time_t = $time_t == '' ? date('Y-m-d') : $time_t;
         //获取联盟的订单
         $where = array('site_id' => $query_site_id, 'order_time >' => date('Y-m-d H:i:s', strtotime($time_f . ' 00:00:00')), 'order_time <' => date('Y-m-d H:i:s', strtotime($time_t . ' 23:59:59')));
         if ($affiliate_id > 0) {
             $where['affiliate_id'] = $affiliate_id;
         }
         $query_struct = array('where' => $where, 'limit' => array('page' => $page, 'per_page' => 20));
         $orders = Affiliate_orderService::get_instance()->index($query_struct);
         $orders_count = Affiliate_orderService::get_instance()->count($query_struct);
         $this->pagination = new Pagination(array('total_items' => $orders_count, 'items_per_page' => 20));
         $affiliates = AffiliateService::get_instance()->index(array('where' => array('mark' => 1)));
         for ($i = 0; $i < count($affiliates); $i++) {
             if ($affiliates[$i]['id'] == $affiliate_id) {
                 $affiliates[$i]['selected'] = 1;
             } else {
                 $affiliates[$i]['selected'] = 0;
             }
         }
         $content = new View($this->package_name . '/' . $this->class_name . '/' . __FUNCTION__);
         $this->template->content = $content;
         $this->template->content->site_name = $site_name;
         $this->template->content->orders = $orders;
         $this->template->content->pagination = $this->pagination;
         $this->template->content->time_f = $time_f;
         $this->template->content->time_t = $time_t;
         $this->template->content->affiliates = $affiliates;
     } catch (MyRuntimeException $ex) {
         $return_struct['status'] = 0;
         $return_struct['code'] = $ex->getCode();
         $return_struct['msg'] = $ex->getMessage();
         //TODO 异常处理
         //throw $ex;
         if ($this->is_ajax_request()) {
             $this->template->content = $return_struct;
         } else {
             $this->template->return_struct = $return_struct;
             $content = new View('info');
             $this->template->content = $content;
             //* 请求结构数据绑定 */
             $this->template->content->request_data = $request_data;
             //* 返回结构体绑定 */
             $this->template->content->return_struct = $return_struct;
         }
     }
 }