美团/饿了么外卖CPS联盟返利公众号小程序核心源码

我们都知道,目前两家巨头饿了么和美团点外卖都可以获得返现,其中饿了么是返利6%,美团是返利3-5%,具体要根据活动来。

也就是说按正常一个人用户点餐,你可以获得每笔外卖的CPS返利佣金,而且外卖的用户粘性极高,已经成了很多淘客的首选,不巧前段时间有客户找我分析开发了一个项目,主要是公众号和小程序(后期还说要开发APP)实现用户一次注册同步关联的跟单返利。

从核心功能方面来说,主要还是实现自动跟单返利,获得CPS交易佣金、另一个是用户角色等级的实现,例如 普通用户、团长用户和联合运营用户角色,每个角色都代表了不同的等级,而要升级这些等级就必须要完成自购 或 自己团队的订单量,作为考核升级,每个升级的用户角色实现就是获得了更高的佣金分成比例和真正裂变赚钱的机会,行业里面有的称为代理商,这样的公众号和小程序渠道,在微信生态下是非常好的裂变,可以迅速获得用户群做社群运营。

分享一下之前给客户开发的核心接口代码(PHP ):可以直接唤起小程序,或者打开饿了么的H5返现链接。

<?php
/**
 * [WeEngine System] Copyright (c) 2014 WE7.CC
 * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
 */
define('IN_API', true);
require_once './framework/bootstrap.inc.php';
load()->model('reply');
load()->app('common');
load()->classs('wesession');
$hash = $_GPC['hash'];
if(!empty($hash)) {
   
	$id = pdo_fetchcolumn("SELECT acid FROM " . tablename('account') . " WHERE hash = :hash", array(':hash' => $hash));
}
if(!empty($_GPC['appid'])) {
   
	$appid = ltrim($_GPC['appid'], '/');
	if ($appid == 'wx570bc396a51b*******') {
     /**  星号隐藏 **/
		$_W['account'] = array(
			'type' => '3',
			'key' => 'wx570bc396a51******',
			'level' => 4,
			'token' => 'platformtestaccount'
		);
	} else {
   
		$id = pdo_fetchcolumn("SELECT acid FROM " . tablename('account_wechats') . " WHERE `key` = :appid", array(':appid' => $appid));
	}
}
if(empty($id)) {
   
	$id = intval($_GPC['id']);
}
if (!empty($id)) {
   
	$uniacid = pdo_getcolumn('account', array('acid' => $id), 'uniacid');
	$_W['account'] = uni_fetch($uniacid);
}
if(empty($_W['account'])) {
   
	exit('initial error hash or id');
}
if(empty($_W['account']['token'])) {
   
	exit('initial missing token');
}
$_W['debug'] = intval($_GPC['debug']);
$_W['acid'] = $_W['account']['acid'];
$_W['uniacid'] = $_W['account']['uniacid'];
$_W['uniaccount'] = uni_fetch($_W['uniacid']);
$_W['account']['groupid'] = $_W['uniaccount']['groupid'];
$_W['account']['qrcode'] = $_W['attachurl'].'qrcode_'.$_W['acid'].'.jpg?time='.$_W['timestamp'];
$_W['account']['avatar'] = $_W['attachurl'].'headimg_'.$_W['acid'].'.jpg?time='.$_W['timestamp'];

$engine = new WeEngine();
if (!empty($_W['setting']['copyright']['status'])) {
   
	$engine->died('抱歉,站点已关闭,关闭原因:' . $_W['setting']['copyright']['reason']);
}
if (!empty($_W['uniaccount']['endtime']) && TIMESTAMP > $_W['uniaccount']['endtime']) {
   
	$engine->died('抱歉,登陆过期,请重新授权登陆');
}

if($_W['isajax'] && $_W['ispost'] && $_GPC['flag'] == 1) {
   
	$engine->encrypt();
}
if($_W['isajax'] && $_W['ispost'] && $_GPC['flag'] == 2) {
   
	$engine->decrypt();
}
load()->func('compat.biz');
$_W['isajax'] = false;
$engine->start();


class WeEngine {
   
	
	private $account = null;
	
	private $modules = array();
	
	public $keyword = array();
	
	public $message = array();

	
	public function __construct() {
   
		global $_W;
		$this->account = WeAccount::create($_W['account']);
		if(strtolower($_SERVER['REQUEST_METHOD']) == 'post') {
   
			$_W['modules'] = uni_modules();
			$this->modules = array_keys($_W['modules']);
			$this->modules[] = 'cover';
			$this->modules[] = 'default';
			$this->modules[] = 'reply';
			$this->modules = array_unique ($this->modules);
		}
	}

	
	public function encrypt() {
   
		global $_W;
		if(empty($this->account)) {
   
			exit('Miss Account.');
		}
		$timestamp = TIMESTAMP;
		$nonce = random(5);
		$token = $_W['account']['token'];
		$signkey = array($token, TIMESTAMP, $nonce);
		sort($signkey, SORT_STRING);
		$signString = implode($signkey);
		$signString = sha1($signString);

		$_GET['timestamp'] = $timestamp;
		$_GET['nonce'] = $nonce;
		$_GET['signature'] = $signString;
		$postStr = file_get_contents('php://input');
		if(!empty($_W['account']['encodingaeskey']) && strlen($_W['account']['encodingaeskey']) == 43 && !empty($_W['account']['key']) && $_W['setting']['development'] != 1) {
   
			$data = $this->account->encryptMsg($postStr);
			$array = array('encrypt_type' => 'aes', 'timestamp' => $timestamp, 'nonce' => $nonce, 'signature' => $signString, 'msg_signature' => $data[0], 'msg' => $data[1]);
		} else {
   
			$data = array('', '');
			$array = array('encrypt_type' => '', 'timestamp' => $timestamp, 'nonce' => $nonce, 'signature' => $signString, 'msg_signature' => $data[0], 'msg' => $data[1]);
		}
		exit(json_encode($array));
	}

	
	public function decrypt() {
   
		global $_W;
		if(empty($this->account)) {
   
			exit('Miss Account.');
		}
		$postStr = file_get_contents('php://input');
		if(!empty($_W['account']['encodingaeskey']) && strlen($_W['account']['encodingaeskey']) == 43 && !empty($_W['account']['key']) && $_W['setting']['development'] != 1) {
   
			$resp = $this->account->local_decryptMsg($postStr);
		} else {
   
			$resp = $postStr;
		}
		exit($resp);
	}

	
	public function start() {
   
		
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值