rabbitmq->getProducer('producers'); $msg = serialize(['dataset_id' => rand(1, 100), 'linked_datasets' => []]); $producer->publish($msg, 'ex1', 'route1'); echo 'ok'; } public function actionBindOpen() { $merchant = $this->merchant; $wxAppId = $merchant['wxAppId']; $miniAppId = $merchant['miniAppId']; $open_appid = $merchant['openAppId']; echo "
";
$id = Yii::$app->request->get('id', 0);
//创建平台,并将公众号绑定到平台
if ($id == 1) {
weixinUtil::createOpenAccount($wxAppId, $this->merchant);
$return = weixinUtil::getOpenAccount($wxAppId, $this->merchant);
print_r($return);
if ($return['errcode'] == 0) {
$openAppId = $return['open_appid'];
xhMerchantService::updateById($this->merchantId, ['openAppId' => $openAppId]);
}
}
//将小程序绑定到平台
if ($id == 2) {
$openAppId = $merchant['openAppId'];
$r = weixinUtil::bindOpenAccount($miniAppId, $openAppId, $merchant, true);
print_r($r);
}
//查询公众号 小程序的绑定情况
if ($id == 3) {
$return = weixinUtil::getOpenAccount($wxAppId, $this->merchant);
print_r($return);
$return = weixinUtil::getOpenAccount($miniAppId, $this->merchant, true);
print_r($return);
}
//设置小程序服务器域名
if ($id == 4) {
weixinUtil::setDomain($this->merchant);
weixinUtil::setWebViewDomain($this->merchant);
}
//为授权的小程序帐号上传小程序代码
if ($id == 5) {
$tId = $_GET['tId'];
weixinUtil::miniCommit($this->merchant, $tId);
}
//获取小程序体验码
if ($id == 6) {
weixinUtil::getExperienceQrCode($this->merchant);
}
//获取授权小程序帐号已设置的类目
if ($id == 7) {
weixinUtil::getMiniCategory($this->merchant);
}
//获取小程序的第三方提交代码的页面配置
if ($id == 8) {
weixinUtil::getMiniPage($this->merchant);
}
//将第三方提交的代码包提交审核
if ($id == 9) {
weixinUtil::miniSubmitAudit($this->merchant);
}
//查询最新一次提交的审核状态
if ($id == 10) {
weixinUtil::miniGetLatestAuditStatus($this->merchant);
}
//发布已通过审核的小程序
if ($id == 11) {
weixinUtil::miniRelease($this->merchant);
}
//撤回审核
if ($id == 12) {
weixinUtil::rollbackCheck($this->merchant);
}
//生成 申请会员页 的小程序码
if ($id == 13) {
weixinUtil::generateMemberCode($this->merchant);
}
//解绑小程序和公众号绑定的平台
if ($id == 14) {
weixinUtil::unbindAccount($this->merchant);
weixinUtil::unbindMiniProgram($this->merchant);
}
Yii::$app->end();
$r = weixinUtil::bindOpenAccount($miniAppId, $open_appid, $merchant, true);
print_r($r);
echo $miniAppId . ' ' . $open_appid . ' ';
$return = weixinUtil::getOpenAccount($wxAppId, $this->merchant);
print_r($return);
die;
$return = weixinUtil::createOpenAccount($wxAppId, $this->merchant);
print_r($return);
die;
$r = weixinUtil::bindOpenAccount($miniAppId, $open_appid, $merchant);
print_r($r);
echo $miniAppId . ' ' . $open_appid . ' ';
$return = weixinUtil::getOpenAccount($wxAppId, $this->merchant);
print_r($return);
$return = weixinUtil::getOpenAccount($miniAppId, $this->merchant);
print_r($return);
die;
if ($return['errcode'] == 0) {
$open_appid = isset($return['open_appid']) ? $return['open_appid'] : '';
} else {
$return = weixinUtil::createOpenAccount($wxAppId, $this->merchant);
if ($return['errcode'] == 0) {
$open_appid = isset($return['open_appid']) ? $return['open_appid'] : '';
}
}
echo "
open_appid:" . $open_appid . "
";
if (!empty($open_appid)) {
xhMerchantService::updateById($this->merchantId, ['openAppId' => $open_appid]);
$r = weixinUtil::bindOpenAccount($miniAppId, $open_appid, $merchant);
echo "绑定小程序结果:
";
print_r($r);
}
echo "
";
$return = weixinUtil::getOpenAccount($wxAppId, $merchant);
echo "微信appId:{$wxAppId}
";
print_r($return);
$return = weixinUtil::getOpenAccount($miniAppId, $merchant);
echo "
小程序appId:{$miniAppId}
";
print_r($return);
}
public function actionCs()
{
// 忽略获取的header数据
$ignore = ['host', 'accept', 'content-length', 'content-type'];
$headers = [];
foreach ($_SERVER as $key => $value) {
if (substr($key, 0, 5) === 'HTTP_') {
$key = substr($key, 5);
$key = str_replace('_', ' ', $key);
$key = str_replace(' ', '-', $key);
$key = strtolower($key);
if (!in_array($key, $ignore)) {
$headers[$key] = $value;
}
}
}
$token = isset($headers['token']) ? $headers['token'] : '';
}
public function actionIndex()
{
echo 'aaa';die;
$time = strtotime(date("Y-m-d"));
$todayIncome = xhStatIncomeService::getTodayIncome($this->merchantId, $time);
$year = date("Y");
$month = date("n");
$monthIncome = xhStatIncomeMonthService::getMonthIncome($this->merchantId, $year, $month);
$statUser = StatUserByDayService::getTodayNum();
$todayVisit = VisitByDayService::getTodayNum($this->merchantId);
$totalVisit = VisitByDayService::getTotalVisit($this->merchantId);
$latestIncome = xhStatIncomeService::getLatestIncome($this->merchantId);//取最近10天的收入
$dayIncome = xhStatIncome::find()->where(['merchantId' => $this->merchantId])->asArray()->orderBy('time desc')->limit(3)->all();
$income = StatIncomeService::getTodayNum();
//获取最近的订单 shish 2019.8.19
$orderList = OrderService::getLatestOrder();
//今日访问量
$todayVisitNum = VisitByDayService::getTodayNum($this->merchantId);
return $this->render('index', [
'merchant' => $this->merchant,
'merchantExtend' => $this->merchantExtend,
'merchantAsset' => $this->merchantAsset,
'todayIncome' => $todayIncome,
'monthIncome' => $monthIncome,
'statUser' => $statUser,
'todayVisit' => $todayVisit,
'totalVisit' => $totalVisit,
'latestIncome' => $latestIncome,
'dayIncome' => $dayIncome,
'orderList' => $orderList,
'income' => $income,
'todayVisitNum' => $todayVisitNum,
]);
}
public function actionTest()
{
}
public function actionLogin()
{
return $this->renderPartial('login');
}
/**
* 重复登陆,记录登陆名
* @return string
*/
public function actionRelogin()
{
return $this->renderPartial('relogin');
}
public function actionLogout()
{
xhAdminService::logout();
$this->redirect(['main/login']);
}
public function actionCheckLogin()
{
$request = Yii::$app->request;
$mobile = $request->post('mobile');
$password = $request->post('password');
$return = xhAdminService::loginByMobile($mobile, $password, true);//true 自动登陆
util::encode($return);
}
public function actionSetLoginPassword()
{
$id = $this->adminId;
$admin = xhAdminService::getById($id);
return $this->render('setLoginPassword', ['admin' => $admin]);
}
public function actionModifyLoginPassword()
{
$post = Yii::$app->request->post();
$prePassword = isset($post['prePassword']) ? $post['prePassword'] : '';
$id = $this->adminId;
$admin = xhAdminService::getById($id);
$savePwd = $admin['password'];
if (empty($savePwd)) {
util::failInfo('请填写密码');
}
if (md5($prePassword) == $savePwd) {
util::failInfo('原密码不正确');
}
xhAdminService::updateById($id, ['password' => md5($post['password'])]);
util::successInfo('修改成功');
}
/**
* 扫码枪扫码
*/
public function actionSearch()
{
$get = Yii::$app->request->get();
$content = isset($get['content']) ? $get['content'] : '';
$id = preg_replace('/\D/s', '', $content);
if (strpos($content, configDict::getQrKey('user')) === 0) {
$this->redirect(['/user/detail', 'id' => $id]);
Yii::$app->end();
}
if (strpos($content, configDict::getQrKey('coupon')) === 0) {
$this->redirect(['/coupon/detail', 'id' => $id]);
Yii::$app->end();
}
}
/**
* 审核通过
*/
public function actionApprove()
{
$openMerchant = xhWxOpenService::getMerchant();
return $this->render('approve', ['admin' => $this->admin, 'openMerchant' => $openMerchant]);
}
public function actionQuickOrder()
{
$this->redirect(Yii::$app->params['frontUrl'] . '/payment/quick-order?account=' . $this->merchant['id']);
}
public function actionPub()
{
$channelName = 'redis_shi';
$time = time();
Yii::$app->redis->executeCommand('PUBLISH', [$channelName, $time]);
}
public function actionSub()
{
$channelName = 'redis_shi';
print_r(Yii::$app->redis->executeCommand('SUBSCRIBE', [$channelName]));
}
public function actionError()
{
$msg = Yii::$app->request->get('msg');
return $this->render('error', ['msg' => $msg]);
}
}