This commit is contained in:
xiaoyu
2024-02-02 15:43:30 +08:00
parent 8b27dbc64c
commit efab20db98
13 changed files with 213 additions and 42 deletions
+11
View File
@@ -31,4 +31,15 @@ $config = array(
),
'model' => array('user_model' => 'app/licheb/app_licheb_users_model')
),
'neta' => array(
'id' => 3,
'app_id' => 3,
'name' => '哪铁圈',
'sign_key' => 'be0fc63bf56a462f16a623501c156bb5',
'wx' => array(
'appid' => '',
'secret' => '',
),
//'model' => array('user_model' => 'app/neta/app_licheb_users_model')
),
);
+4 -6
View File
@@ -17,6 +17,7 @@ class Hd extends CI_Controller {
private static $apps = array(
'e49d182c6e6dab64' => 'liche',
'1c156bb57cd6984a' => 'licheb',
'fba9a12d2cd8599a' => 'neta',
);
/**
@@ -461,7 +462,7 @@ class Hd extends CI_Controller {
private function print_return($data = array(), $ifgzip = false){
if(!isset($data['code'])){
$msg = $data['msg'] ? $data['msg'] : '';
$msg = $data['msg'] ? $data['msg'] : '执行成功';
$data = array('code' => 200, 'data' => $data, 'msg' => $msg);
}
@@ -611,7 +612,6 @@ class Hd extends CI_Controller {
$buff = "";
foreach($param as $k => $v){
if(!is_array($v) && strlen($v) > 0){
// $buff .= $k . "=" . $v . "&";
$buff .= $k . "=" . ($v) . "&";
}
}
@@ -621,14 +621,12 @@ class Hd extends CI_Controller {
//MD5加密并转大写
$string = strtoupper(md5($buff));
// var_dump($string);
// var_dump($buff);
//var_dump($string);
//var_dump($buff);
if($sign == $string){
return true;
}
// return true;
debug_log("[fail]". __FUNCTION__ . ": sign:{$sign}, check:{$string}, buff:{$buff}", $this->log_file);
return false;
}
+4 -2
View File
@@ -1,7 +1,7 @@
<?php
ini_set('display_errors', 'On');
error_reporting(E_ERROR);
//ini_set('display_errors', 'On');
//error_reporting(E_ERROR);
/**
* Created by PhpStorm.
* User: xuxb
@@ -146,6 +146,7 @@ abstract class Wxapp extends HD_Controller{
}
if(!method_exists($this, $method)){
echo $method;exit;
debug_log("[fail]". __FUNCTION__ . ": request not allow; method:{$method}", $this->log_file);
throw new Exception('非法请求', API_CODE_NONE);
}
@@ -153,6 +154,7 @@ abstract class Wxapp extends HD_Controller{
//某个方法或者整个ct在白名单里无需校验
$session = $this->session;
if(!in_array($name, $this->login_white) && 'all' != $this->login_white){
print_r($this->login_white);exit;
if(!$session){
throw new Exception('还未登录', API_CODE_LOGOUT);
}
+1 -1
View File
@@ -12,7 +12,7 @@ require_once APPPATH . 'controllers/wxapp/Wxapp.php';
*/
class Home extends Wxapp
{
private $uid;
//private $uid;
function __construct($inputs, $app_key)
{
+128
View File
@@ -0,0 +1,128 @@
<?php
defined('WXAPP_APP') or exit('No direct script access allowed');
ini_set('display_errors', 'On');
error_reporting(E_ERROR);
require_once APPPATH . 'controllers/wxapp/Wxapp.php';
class Act extends Wxapp
{
function __construct($inputs, $app_key)
{
parent::__construct($inputs, $app_key);
$this->login_white = 'all';//登录白名单
$this->check_status = [];//用户状态校验
$this->check_mobile = [];//需要手机号
$this->check_headimg = [];//授权微信信息
$this->load->model('market/market_sylive_activity_model');
$this->load->model('market/market_sylive_order_model');
$this->load->model('market/market_sylive_customer_model');
}
protected function get_user()
{
$ukey = $this->input_param('ukey');
$activityId = 27;//活动id
$activity = $this->market_sylive_activity_model->get(['activityId' => $activityId]);
if (!$activity) {
//throw new Hd_exception('活动不存在', API_CODE_FAIL);
}
if (!$ukey) {
throw new Hd_exception('ukey不存在', API_CODE_FAIL);
}
$customer = $this->market_sylive_customer_model->get(['ukey' => $ukey]);
if(!$customer){
throw new Hd_exception('用户不存在', API_CODE_FAIL);
}
$data = [
'customerId' => $customer['customerId'],
];
return $data;
}
protected function post_reward()
{
$activityId = 27;//活动id
$ukey = $this->input_param('ukey');
$reward_id = $this->input_param('reward_id');
//$reward_id 对应 winType
$winTypes = array(
'5051' => '1', //电视机
'5052' => '2', //电冰箱
'5053' => '3', //平板
);
$activity = $this->market_sylive_activity_model->get(['activityId' => $activityId]);
if (!$activity) {
throw new Hd_exception('活动不存在', API_CODE_FAIL);
}
if (!$reward_id || !in_array($reward_id, $winTypes)) {
throw new Hd_exception('参数错误', API_CODE_FAIL);
}
if (!$ukey) {
throw new Hd_exception('ukey不存在', API_CODE_FAIL);
}
$customer = $this->market_sylive_customer_model->get(['ukey' => $ukey]);
if(!$customer){
throw new Hd_exception('用户不存在', API_CODE_FAIL);
}
$order = $this->market_sylive_order_model->get(['activityId' => $activityId, 'userId' => $customer['userId'], 'status' => 1,]);
if($order && $order['win'] == 0){
$data = [
'win' => 1,
'winType' => $winTypes[$reward_id],
'winTime' => date('Y-m-d H:i:s'),
];
$rt = $this->market_sylive_order_model->update($data, ['id' => $order['id']]);
}
if ($rt) {
throw new Hd_exception('执行成功', API_CODE_SUCCESS);
}
throw new Hd_exception('目标对象不存在', API_CODE_FAIL);
}
protected function post_car()
{
$activityId = 27;//活动id
$ukey = $this->input_param('ukey');
$car = $this->input_param('car');
$activity = $this->market_sylive_activity_model->get(['activityId' => $activityId]);
if (!$activity) {
throw new Hd_exception('活动不存在', API_CODE_FAIL);
}
if (!$car) {
throw new Hd_exception('参数错误', API_CODE_FAIL);
}
if (!$ukey) {
throw new Hd_exception('ukey不存在', API_CODE_FAIL);
}
$customer = $this->market_sylive_customer_model->get(['ukey' => $ukey]);
if(!$customer){
throw new Hd_exception('用户不存在', API_CODE_FAIL);
}else{
$data = ['visitTagId' => $car,];
$rt = $this->market_sylive_customer_model->update($data, ['customerId' => $customer['customerId']]);
}
if ($rt) {
throw new Hd_exception('执行成功', API_CODE_SUCCESS);
}
throw new Hd_exception('目标对象不存在', API_CODE_FAIL);
}
}