diff --git a/api/controllers/Hd.php b/api/controllers/Hd.php
index d67c2141..838d4ad3 100755
--- a/api/controllers/Hd.php
+++ b/api/controllers/Hd.php
@@ -268,6 +268,65 @@ class Hd extends CI_Controller {
}
}
+ /**
+ * 博饼入口
+ */
+ public function bobing()
+ {
+ define('WXAPP_ITEMS', 1);
+ //加载输入参数
+ $this->input_param();
+ $app_id = $this->input_param('app_id');
+ !$app_id && $app_id = $this->input_param('vipcard_id');
+ $version = $this->input_param('version');
+ $sversion = $this->input_param('sversion');
+
+ $this->log_file = get_class($this) . "_{$app_id}.log";
+
+ //应用ID为空
+ if (!$app_id) {
+ debug_log("[fail]" . __FUNCTION__ . ":app_id is null; uri_string:" . $this->uri->uri_string(), $this->log_file);
+ return $this->print_return($this->return_error(API_CODE_INVILD_PARAM, '请求丢失'));
+ }
+ //签名不正确
+ if (!$this->vaild_sign()) {
+ debug_log("[fail]" . __FUNCTION__ . ":sign check fail; uri_string:" . $this->uri->uri_string() . "; param:" . json_encode($this->inputs), $this->log_file);
+ return $this->print_return($this->return_error(API_CODE_INVILD_PARAM, '非法请求'));
+ }
+ $app = self::$apps[$app_id];
+ $class_name = ucfirst($this->uri->segment(3));
+ if ($this->uri->segment(4)) {
+ $method = $this->request . "_" . $this->uri->segment(4);
+ } else {
+ $method = $this->request;
+ }
+ //app定制ct
+ $file_name = APPPATH . "controllers/wxapp/bobing/{$app}/{$class_name}.php";
+ //ct不存在
+ if (file_exists($file_name)) {
+ require_once $file_name;
+ } else {
+ //app定制ct不存在,使用公共ct
+ $file_name = APPPATH . "controllers/wxapp/bobing/{$class_name}.php";
+ if (file_exists($file_name)) {
+ require_once $file_name;
+ } else {
+ debug_log("[fail]" . __FUNCTION__ . ": file '{$file_name}' not exist; method:{$method}, app_id:" . $app_id, $this->log_file);
+ return $this->print_return($this->return_error(API_CODE_NONE, '非法请求'));
+ }
+ }
+ try {
+ $class = new $class_name($this->inputs, $app);
+ $result = $class->$method($version, $sversion);
+ if (!$result) {
+ throw new Exception('', ERR_SYS_FAIL);
+ }
+ return $this->print_return($result);
+ } catch (Exception $e) {
+ return $this->print_return($this->return_error($e->getCode(), $e->getMessage()));
+ }
+ }
+
/**
* 测试签名(开发环境)
*/
diff --git a/api/controllers/plan/Bobing.php b/api/controllers/plan/Bobing.php
new file mode 100644
index 00000000..07fb5f3b
--- /dev/null
+++ b/api/controllers/plan/Bobing.php
@@ -0,0 +1,72 @@
+log_file = 'bobing.log';
+ $this->load->model('bobing/bobing_user_model', 'mdBobingUser');
+ $this->load->model('bobing/bobing_user_credit_model', 'mdBobingUserCredit');
+ $this->appConfig = $this->mdBobingUser->appConfig();
+ }
+
+ public function index()
+ {
+
+ }
+
+ /**
+ * Notes:设置每日中奖
+ * Created on: 2021/8/27 17:20
+ * Created by: dengbw
+ * https://liche-api-dev.xiaoyu.com/plan/bobing/lottery
+ * https://api.liche.cn/plan/bobing/lottery
+ */
+ public function lottery()
+ {
+ $params = $this->input->get();
+ $hour = date('H');
+ if ($hour != '00' && !$params['sd']) {
+ echo '[0]点过后才会开奖昨天的中奖用户[' . $hour . ']';
+ return;
+ }
+ if ($this->appConfig['game_start_date'] > date('Y-m-d')) {
+ echo '博饼未开始';
+ return;
+ }
+ $date = date('Y-m-d', strtotime('+1 day'));
+ if ($this->appConfig['game_end_date'] < $date) {
+ echo '博饼已结束';
+ return;
+ }
+ $date = date('Y-m-d', strtotime('-1 day'));//中奖用户
+ $where = array('app_id' => $this->appConfig['app_id'], 'act_key' => $this->appConfig['act_key'], 'bo_date' => $date, 'lottery' => 1);
+ $re = $this->mdBobingUserCredit->get($where);
+ if ($re) {
+ echo '[' . $date . ']已执行过中奖了';
+ return;
+ }
+ $where['lottery'] = 0;
+ $where['uid not in(select uid from lc_bobing_user_credit where app_id = ' . $this->appConfig['app_id']
+ . ' and act_key = ' . $this->appConfig['act_key'] . ' and lottery= 1)'] = null;
+ $res_c = $this->mdBobingUserCredit->select($where, 'credit desc,u_time asc', 1, $this->appConfig['lottery_nums'], 'id,uid,credit');
+ if ($res_c) {//设置中奖用户
+ $ids = implode(',', array_column($res_c, 'id'));//中奖用户
+ $this->mdBobingUserCredit->update(array('lottery' => 1), array('id in (' . $ids . ')' => null));
+ $lottery = json_encode($res_c, JSON_UNESCAPED_UNICODE);
+ debug_log('lottery:' . $lottery, $this->log_file);
+ echo json_encode($lottery, JSON_UNESCAPED_UNICODE);
+ return;
+ }
+ }
+}
diff --git a/api/controllers/plan/Plan.php b/api/controllers/plan/Plan.php
index cd40f391..4d3c7d13 100644
--- a/api/controllers/plan/Plan.php
+++ b/api/controllers/plan/Plan.php
@@ -26,6 +26,7 @@ class Plan extends CI_Controller
//执行失败的plan重跑
$plan[] = array('url' => base_url(array('plan', 'plan', 'replan')), 'interval' => 1);
+ $plan[] = array('url' => base_url(array('plan', 'bobing', 'lottery')), 'interval' => 30);
$this->plan = $plan;
}
diff --git a/api/controllers/wechat/Liche.php b/api/controllers/wechat/Liche.php
new file mode 100644
index 00000000..df4f1763
--- /dev/null
+++ b/api/controllers/wechat/Liche.php
@@ -0,0 +1,195 @@
+log_file = "wechat_{$target_class}.log";
+ }
+
+ public function index()
+ {
+ echo 'index';
+ }
+
+ /**
+ * Notes:企业微信接收事件
+ * https://liche-api-dev.xiaoyu.com/wechat/liche/get_qymsg
+ * https://api.liche.cn/wechat/liche/get_qymsg
+ * https://open.work.weixin.qq.com/wwopen/devtool/interface?doc_id=14961 测试回调模式
+ * Created on: 2021/5/7 17:23
+ * Created by: dengbw
+ */
+ public function get_qymsg()
+ {
+ $param = $this->input->get();
+ debug_log('
--->qymsg_param:' . json_encode($param), $this->log_file);
+ require_once(COMMPATH . '/third_party/WXqy/WXBizMsgCrypt.php');
+ $encodingAesKey = "VISnPl8WvttxHkAhrENTnADEjeWBc7cvU8qiCj9jH4S";
+ $token = "PMJbt5kIoE7LTf0kWkwTf";
+ $corpId = "wwc2caba960d202087";
+
+ $sVerifyMsgSig = $param['msg_signature'];
+ $sVerifyTimeStamp = $param['timestamp'];
+ $sVerifyNonce = $param['nonce'];
+ $sVerifyEchoStr = $param['echostr'];
+ // 需要返回的明文
+ $sEchoStr = "";
+ $wxcpt = new WXBizMsgCrypt($token, $encodingAesKey, $corpId);
+ if ($sVerifyEchoStr) {//验证回调URL
+ $errCode = $wxcpt->VerifyURL($sVerifyMsgSig, $sVerifyTimeStamp, $sVerifyNonce, $sVerifyEchoStr, $sEchoStr);
+ debug_log('qymsg_errCode:' . $errCode, $this->log_file);
+ if ($errCode == 0) {
+ // 验证URL成功,将sEchoStr返回
+ debug_log('qymsg_sEchoStr:' . $sEchoStr . '&sEchoStrurldecode=' . urldecode($sEchoStr), $this->log_file);
+ echo urldecode($sEchoStr);
+ } else {
+ echo $errCode;
+ }
+ exit;
+ }
+// $sVerifyMsgSig = '08eb02c5d7fefaa29e2bd6a63acb8dfcc902ccf4';
+// $sVerifyTimeStamp = '1620713245';
+// $sVerifyNonce = '1620719758';
+ if ($_SERVER['REQUEST_METHOD'] == "POST") {
+ $sReqData = file_get_contents("php://input");
+ //$sReqData = "";
+ //$log = '---';
+ //if (is_array($sReqData)) $log = print_r($sReqData, true);
+ //debug_log('qymsg_sReqData:' . json_encode($log, JSON_UNESCAPED_UNICODE), $this->log_file);
+ $sMsg = ""; // 解析之后的明文
+ $errCode = $wxcpt->DecryptMsg($sVerifyMsgSig, $sVerifyTimeStamp, $sVerifyNonce, $sReqData, $sMsg);
+ debug_log('qymsg_errCode:' . $errCode, $this->log_file);
+ if ($errCode == 0) {
+ $this->load->model('app/app_wechatqy_model', 'mdWechatqy');
+ $re_msg = (array)simplexml_load_string($sMsg, 'SimpleXMLElement', LIBXML_NOCDATA);//xml转json
+ $ExternalUserID = $re_msg['ExternalUserID'];
+ $ChangeType = $re_msg['ChangeType'];
+ debug_log('qymsg_ChangeType:' . $ChangeType, $this->log_file);
+ $this->load->library('wx_qyapi', array());
+ if ($ChangeType == 'add_external_contact') {//添加企业客户事件
+ $re = $this->wx_qyapi->get_external_contact(array('url' => 'get', 'external_userid' => $ExternalUserID));
+ //debug_log('qymsg_external_errcode:' . $re['errcode'] . '&external_userid=' . $re['external_contact']['external_userid'], $this->log_file);
+ if ($re['errcode'] == 0) {
+ $external_userid = $re['external_contact']['external_userid'];
+ if ($external_userid) {
+ $re_qy = $this->mdWechatqy->get(array('external_userid' => $external_userid, 'app_id' => self::$app_id));
+ $jsondata['external_contact'] = $re['external_contact'] ? $re['external_contact'] : '';
+ $jsondata['follow_user'] = $re['follow_user'] ? $re['follow_user'] : '';
+ $tags_ary = $re['follow_user'][0]['tags'];
+ $tags = '';
+ if ($tags_ary && $tags_ary != '[]' && is_array($tags_ary)) {
+ $tags = implode(',', array_column($tags_ary, 'tag_id'));
+ }
+ $addData = array(
+ 'app_id' => self::$app_id,
+ 'external_userid' => $re['external_contact']['external_userid'],
+ 'name' => $re['external_contact']['name'],
+ 'avatar' => $re['external_contact']['avatar'],
+ 'unionid' => $re['external_contact']['unionid'] ? $re['external_contact']['unionid'] : '',
+ 'userid' => $re['follow_user'][0]['userid'] ? $re['follow_user'][0]['userid'] : '',
+ 'remark' => $re['follow_user'][0]['remark'] ? $re['follow_user'][0]['remark'] : '',
+ 'tags' => $tags,
+ 'c_time' => $re['follow_user'][0]['createtime'] ? $re['follow_user'][0]['createtime'] : time(),
+ 'jsondata' => json_encode($jsondata, JSON_UNESCAPED_UNICODE),
+ 'status' => 1,
+ );
+ if (!$re_qy) {
+ $this->mdWechatqy->add($addData);
+ } else {
+ $this->mdWechatqy->update($addData, array('external_userid' => $external_userid));
+ }
+ //修改企业微信审请通过
+ $this->load->service("app/user_service", array("app_id" => self::$app_id));
+ $re_u = $this->user_service->get(array('unionid' => $addData['unionid']));
+ if ($re_u['id']) {
+ $this->user_service->update(array('wxqy' => 1), array('id' => $re_u['id']));
+ //添加企业微信加分
+ $this->load->library('bobing/bo');
+ $this->bo->uid = $re_u['id'];
+ $result = $this->bo->wxqy_credit();
+ debug_log('wxqy:' . json_encode($result, JSON_UNESCAPED_UNICODE), $this->log_file);
+ }
+ //debug_log('qymsg_addData:' . json_encode($addData, JSON_UNESCAPED_UNICODE), $this->log_file);
+ }
+ }
+ debug_log('qymsg_get:' . json_encode($re, JSON_UNESCAPED_UNICODE), $this->log_file);
+ } else if ($ChangeType == 'update') {//修改企业客户事件
+ debug_log('qymsg_sMsg:' . json_encode($re_msg, JSON_UNESCAPED_UNICODE), $this->log_file);
+// $re = $this->wx_qyapi->get_external_contact(array('url' => 'get', 'external_userid' => $ExternalUserID));
+// debug_log('qymsg_external_errcode:' . $re['errcode'] . '&external_userid=' . $re['external_contact']['external_userid'], $this->log_file);
+// debug_log('qymsg_get:' . json_encode($re, JSON_UNESCAPED_UNICODE), $this->log_file);
+ } else if ($ChangeType == 'del_follow_user') {//删除企业客户事件
+ if ($ExternalUserID) {
+ $re_qy = $this->mdWechatqy->get(array('external_userid' => $ExternalUserID, 'app_id' => self::$app_id));
+ if ($re_qy) {
+ $this->mdWechatqy->update(array('status' => -1), array('id' => $re_qy['id']));
+ $this->load->service("app/user_service", array("app_id" => self::$app_id));
+ $re_u = $this->user_service->get(array('unionid' => $re_qy['unionid']));
+ if ($re_u['id']) {
+ $this->user_service->update(array('wxqy' => -1), array('id' => $re_u['id']));
+ $this->load->model('bobing/bobing_user_model', 'mdBobingUser');
+ $this->mdBobingUser->update(array('wxqy' => -1), array('uid' => $re_u['id'], 'app_id' => self::$app_id));
+ }
+ }
+ }
+ }
+ //debug_log('qymsg_sMsg:' . json_encode($re_msg, JSON_UNESCAPED_UNICODE), $this->log_file);
+ }
+ }
+ }
+
+ /**
+ * Notes:添加企业客户事件
+ * https://hd-api-dev.xiaoyu.com/wechat/xmcard/add_wechatqy
+ * https://api.haodian.cn/wechat/xmcard/add_wechatqy
+ * Created on: 2021/5/14 17:23
+ * Created by: dengbw
+ */
+ public function add_wechatqy()
+ {
+ $param = $this->input->get();
+ $external_userid = $param['external_userid'];
+ if (!$external_userid) {
+ return false;
+ }
+ $this->load->model('app/app_wechatqy_model', 'mdWechatqy');
+ $this->load->library('wx_qyapi', array());
+ $re = $this->wx_qyapi->get_external_contact(array('url' => 'get', 'external_userid' => $external_userid));
+ print_r('qymsg_external_errcode:' . $re['errcode'] . '=' . $re['external_contact']['external_userid']);
+ if ($re['errcode'] == 0) {
+ $external_userid = $re['external_contact']['external_userid'];
+ if ($external_userid) {
+ $re_qy = $this->mdWechatqy->get(array('external_userid' => $external_userid));
+ $jsondata['external_contact'] = $re['external_contact'] ? $re['external_contact'] : '';
+ $jsondata['follow_user'] = $re['follow_user'] ? $re['follow_user'] : '';
+ $addData = array(
+ 'app_id' => self::$app_id,
+ 'external_userid' => $re['external_contact']['external_userid'],
+ 'name' => $re['external_contact']['name'],
+ 'avatar' => $re['external_contact']['avatar'],
+ 'unionid' => $re['external_contact']['unionid'] ? $re['external_contact']['unionid'] : '',
+ 'userid' => $re['follow_user'][0]['userid'] ? $re['follow_user'][0]['userid'] : '',
+ 'remark' => $re['follow_user'][0]['remark'] ? $re['follow_user'][0]['remark'] : '',
+ 'tags' => $re['follow_user'][0]['tags'] ? $re['follow_user'][0]['tags'] : '',
+ 'c_time' => $re['follow_user'][0]['createtime'] ? $re['follow_user'][0]['createtime'] : time(),
+ 'jsondata' => json_encode($jsondata, JSON_UNESCAPED_UNICODE),
+ 'status' => 1,
+ );
+ if (!$re_qy) {
+ $this->mdWechatqy->add($addData);
+ } else {
+ $this->mdWechatqy->update($addData, array('external_userid' => $external_userid));
+ }
+ print_r('qymsg_addData:' . json_encode($addData, JSON_UNESCAPED_UNICODE));
+ }
+ }
+ print_r('qymsg_get:' . json_encode($re, JSON_UNESCAPED_UNICODE));
+ }
+
+}
diff --git a/api/controllers/wxapp/app/Payment.php b/api/controllers/wxapp/app/Payment.php
index 8b71a56c..7274445e 100644
--- a/api/controllers/wxapp/app/Payment.php
+++ b/api/controllers/wxapp/app/Payment.php
@@ -6,7 +6,7 @@ defined('WXAPP_APP') OR exit('No direct script access allowed');
* Desc: 支付接口
* Date: 2021/06/29
* Time: 19:47
- */
+ */
require_once APPPATH . 'controllers/wxapp/Wxapp.php';
class Payment extends Wxapp{
@@ -38,7 +38,7 @@ class Payment extends Wxapp{
$row['total_price'] = 0.01;
}
- $this->config->load('wxpay');
+ $this->config->load('wxpay');
$wx_config = $this->config->item('default');
$this->load->library('WechatPayV3');
$params = [
@@ -48,7 +48,7 @@ class Payment extends Wxapp{
'wechatpayCertificate' => $wx_config['wechatpayCertificate'],
];
$WechatPayV3 = new WechatPayV3($params);
- $n_time = time();
+ $n_time = time();
$json = [
'sp_appid' => $wx_config['appid'],
'sp_mchid' => $wx_config['mchid'],
@@ -81,4 +81,74 @@ class Payment extends Wxapp{
return $result;
}
+ //好店支付方式
+ public function put_hd(){
+ $sid = $this->input_param('sid');
+ $this->load->model('bobing/bobing_user_model', 'mdBobingUser');
+ $this->app_id = $this->mdBobingUser->appConfig()['act_key'];
+ $row = $this->order_purchase_model->get(['sid'=>$sid,'app_id'=>$this->app_id,'app_uid'=>$this->session['uid']]);
+ if(!$row){
+ throw new Exception('订单不存在', API_CODE_FAIL);
+ }
+ if($row['status']>1){
+ throw new Exception('订单已支付', API_CODE_FAIL);
+ }
+ if($row['total_price']>0){
+ $url = http_host_com('api');
+ $notify_url = $url."/wxapp/liche/wxnotify";
+ $result = $this->pay($sid, $row['total_price'], $this->session['openid'], $row['item_title'], $notify_url);
+ }else{
+ $this->load->service('apporder/payhd_service', array('app_id' => $this->app_id));
+ $result = $this->payhd_service->after_pay($sid);
+ }
+ return $result;
+ }
+
+ /**
+ * 支付方法
+ * @param $trade_no
+ * @param $price
+ * @param $openid
+ * @param $body
+ * @param $notify_url
+ * @param $attach
+ * @param $detail
+ * @return bool|json数据,可直接填入js函数作为参数|mixed
+ * @throws WxPayException
+ */
+ private function pay($trade_no,$price,$openid,$body,$notify_url,$attach = '',$detail = ''){
+ if(!$body){return false;}
+ require_once APPPATH."third_party/WXconfig/liche_WxPay.Config.php";
+ require_once APPPATH."third_party/WXpay/WxPay.Api.php";
+ $config = new WxPayConfig();
+ $wxpay = new WxPayUnifiedOrder();
+ $wxpay->SetVersion('1.0');
+ $wxpay->SetBody($body); //简单描述
+ $attach && $wxpay->SetAttach($attach); //附加信息
+ $wxpay->SetNotify_url($notify_url);
+ $wxpay->SetOut_trade_no($trade_no); //订单号
+ $wxpay->SetTotal_fee($price * 100); //支付价格
+ $wxpay->SetTime_start(date("YmdHis")); //交易起始时间
+ $redis = & load_cache('redis');
+ $out_time_key = 'WX_TRADE_NO_OUT_'.$trade_no;
+ $out_time = $redis->get($out_time_key);
+ if(!$out_time){
+ $out_time = date("YmdHis",time() + 29*60*60);
+ $redis->save($out_time_key,$out_time,30*60*60);
+ }
+ $wxpay->SetTime_expire($out_time); //交易结束时间
+ $wxpay->SetTrade_type("JSAPI"); //设置交易类型
+ $wxpay->SetOpenid($openid); //openid
+ $detail && $wxpay->SetDetail($detail);
+ $return = WxPayApi::unifiedOrder($config, $wxpay); //统一支付
+ if($return['result_code'] == 'SUCCESS') {
+ $wxpay_api = new WxPayJsApiPay();
+ $jsApiParameters = WxPayApi::GetJsApiParameters($return, $config, $wxpay_api);
+ $jsApiParameters = json_decode($jsApiParameters, true);
+ return $jsApiParameters;
+ }else{
+ throw new Exception($return['return_msg']?$return['return_msg'].$return['err_code_des']:$return['return_msg'], API_CODE_FAIL);
+ }
+ }
+
}
diff --git a/api/controllers/wxapp/bobing/Bobing.php b/api/controllers/wxapp/bobing/Bobing.php
new file mode 100644
index 00000000..102d9641
--- /dev/null
+++ b/api/controllers/wxapp/bobing/Bobing.php
@@ -0,0 +1,266 @@
+login_white = '';//
+ $this->check_status = array();//用户状态校验
+ $this->check_mobile = array();//需要手机号
+ $this->check_headimg = array();//授权微信信息
+ $this->majia_white = array('get');//超级管理员披上马甲可操作权限
+ $this->uid = $this->session['uid'];
+ //$this->uid = 4;
+ $this->load->model('bobing/bobing_user_model', 'mdBobingUser');
+ $this->load->model('bobing/bobing_user_credit_model', 'mdBobingUserCredit');
+ $this->load->model('bobing/bobing_logs_model', 'mdBobingLogs');
+ $this->appConfig = $this->mdBobingUser->appConfig();
+ }
+
+ /**
+ * Notes:首页
+ * Created on: 2020/8/10 11:47
+ * Created by: dengbw
+ * @return array
+ * @throws Exception
+ */
+ protected function get()
+ {
+ $cf_uid = intval($this->input_param('cf_uid'));//要助力id
+ $this->uid == $cf_uid && $cf_uid = 0;
+ //$cf_uid = 14;
+ $where = array('act_key' => $this->appConfig['act_key'], 'app_id' => $this->app_id, 'uid' => $this->uid);
+ $re_u = $this->mdBobingUser->get($where);
+ if ($re_u) {
+ if (!$cf_uid && $re_u['if_kz'] == 0) {//更新开桌
+ $this->mdBobingUser->update(array("if_kz" => 1), $where);
+ }
+ } else {
+ $if_kz = $cf_uid ? 0 : 1;
+ $addUser = array_merge($where, array('if_kz' => $if_kz, 'c_time' => time()));
+ $idu = $this->mdBobingUser->add($addUser);
+ if (!$idu && $if_kz == 1) {
+ throw new Hd_exception('开桌失败,请重试', API_CODE_FAIL);
+ }
+ }
+ $share = array('title' => '狸车分享标题', 'content' => '
目前累计***幸运分,打败全闽南97.77%的用户,
+继续邀请好友助力博饼,
冲刺购物卡、苹果手机、汽车大奖~
添加小狸微信,还可立即获得288幸运分!
'
+ , 'img' => 'https://qs.haodian.cn/wechat_app/liche/bobing/2021/share-tip.jpg', 'posters' => 'https://qs.haodian.cn/wechat_app/liche/bobing/2021/posterbg.jpg');
+ $result['valid_nums'] = $this->get_valid_nums($cf_uid);
+ $result['top_title'] = $this->get_top_title($cf_uid);
+ $result['users'] = $this->pr_users(true, array('cf_uid' => $cf_uid));
+ $result['logs'] = $this->pr_logs($cf_uid);
+ $result['share'] = $share;
+ return $result;
+ }
+
+ /**
+ * Notes:博一把
+ * Created on: 2021/8/10 15:18
+ * Created by: dengbw
+ */
+ protected function put_bo()
+ {
+ $this->check_game_date();
+ $cf_uid = intval($this->input_param('cf_uid'));//要助力id
+ $this->uid == $cf_uid && $cf_uid = 0;
+ //$cf_uid = 14;
+ $this->load->library('bobing/bo');
+ $this->bo->uid = $this->uid;
+ $valid_nums = $this->get_valid_nums($cf_uid);//获取博饼剩余数
+ $this->bo->valid_nums = $valid_nums['value'];
+ $nickname = '';
+ if ($cf_uid) {//助力博
+ $this->bo->cf_uid = $cf_uid;
+ $result = $this->bo->zl_bo();
+ $reU = $this->app_user_model->get(array('id' => $this->uid));
+ $reU['nickname'] && $nickname = $reU['nickname'];
+ } else {//开桌博
+ $result = $this->bo->kz_bo();
+ }
+ //status 1开桌博饼次数用完2助力数用完
+ if ($result['status']) {//返回错误信息
+ if ($result['status'] == API_CODE_FAIL) {
+ throw new Hd_exception($result['content'], $result['status']);
+ }
+ return $result;
+ }
+ $status = 0;
+ $data['title'] = $result['title'];
+ $data['content'] = $result['content'];
+ //status 3抽到购车金4抽到红包
+ $log = $cf_uid ? $nickname . "为桌长博到{$result['credit']}幸运分" : "桌长博到{$result['credit']}幸运分";
+ if ($result['car_gold'] > 0) {
+ $status = 3;
+ $data['car_gold'] = $result['car_gold'];
+ $log .= $cf_uid ? "和{$result['car_gold']}元购车金" : ",额外幸运地博到{$result['car_gold']}元购车金";
+ } else if ($result['hong_bao'] > 0) {
+ $status = 4;
+ $data['hong_bao_url'] = http_host_com('home') . "/h5/hongbao?id={$result['lid']}&uid={$this->uid}";
+ $log .= ",额外幸运地博到一个现金红包";
+ }
+ $data['log'] = $log;
+ $data['status'] = $status;
+ $valid_nums['value'] = $this->bo->valid_nums <= 0 ? 0 : $this->bo->valid_nums - 1;
+ $data['dices'] = $result['dices'];
+ $data['level'] = $result['level'];
+ $data['bo_title'] = $result['level_name'] . ' + ' . $result['credit'];
+ $data['valid_nums'] = $valid_nums;
+ $data['top_title'] = $this->get_top_title($cf_uid);
+ return $data;
+ }
+
+ protected function get_users()
+ {
+ $params = $this->input->get();
+ $this->data['users'] = $this->pr_users(false, $params);
+ return $this->data;
+ }
+
+
+ /**
+ * Notes:获取博饼剩余数
+ * Created on: 2021/8/17 10:24
+ * Created by: dengbw
+ * @param $cf_uid
+ * @return array
+ */
+ private function get_valid_nums($cf_uid)
+ {
+ if ($cf_uid) {
+ $zl_nums = $this->mdBobingLogs->count(array('app_id' => $this->app_id, 'act_key' => $this->appConfig['act_key']
+ , 'cf_uid' => $this->uid, 'type' => 1));
+ $zl_nums = intval($this->appConfig['zl_nums'] - $zl_nums);//剩下助力博饼数
+ $valid_nums = array('title' => '剩余助力次数:', 'value' => $zl_nums <= 0 ? 0 : $zl_nums);
+ } else {
+ $kz_nums = $this->mdBobingLogs->count(array('app_id' => $this->app_id, 'act_key' => $this->appConfig['act_key']
+ , 'uid' => $this->uid, 'type' => 0));
+ $kz_nums = intval($this->appConfig['kz_nums'] - $kz_nums);//剩下开桌博饼数
+ $valid_nums = array('title' => '剩余博饼次数:', 'value' => $kz_nums <= 0 ? 0 : $kz_nums);
+ }
+ return $valid_nums;
+ }
+
+ /**
+ * Notes:博饼顶部标题
+ * Created on: 2021/8/17 10:14
+ * Created by: dengbw
+ * @return array
+ */
+ private function get_top_title($cf_uid)
+ {
+ if ($cf_uid) {
+ $reU = $this->app_user_model->get(array('id' => $cf_uid));
+ $top_title = $reU['nickname'] ? $reU['nickname'] . '的桌子' : '未知用户的桌子';
+ } else {
+ $credit = $ranking = 0;
+ $where = array('app_id' => $this->app_id, 'act_key' => $this->appConfig['act_key'], 'bo_date' => date('Y-m-d'));
+ $re_c = $this->mdBobingUserCredit->get(array_merge($where, array('uid' => $this->uid)));
+ $re_c && $credit = $re_c['credit'];
+ $ranking = $this->mdBobingUserCredit->count(array_merge($where, array('credit>=' => $credit, 'uid<>' => $this->uid))) + 1;//排名
+ $ranking > 100 && $ranking = '100名外';
+ $top_title = "今日博饼分:{$credit} | 今日排名:{$ranking}";
+ }
+ return $top_title;
+ }
+
+ private function pr_users($return_array = false, $params = array())
+ {
+ $page = $params['page'] ? intval($params['page']) : 1;
+ $size = $params['size'] ? intval($params['size']) : 7;
+ $cf_uid = intval($params['cf_uid']);
+ //$cf_uid = 14;
+ $list = array();
+ if ($cf_uid) {
+ $where = array('app_id' => $this->app_id, 'act_key' => $this->appConfig['act_key'], 'uid' => $cf_uid, 'type' => 1);
+ } else {
+ $where = array('app_id' => $this->app_id, 'act_key' => $this->appConfig['act_key'], 'uid' => $this->uid, 'type' => 1);
+ }
+ $total = $this->mdBobingLogs->count($where, 'distinct(cf_uid)');
+ if ($total) {
+ $res_u = $this->mdBobingLogs->select($where, 'id DESC', $page, $size, 'distinct(cf_uid)');
+ if ($res_u) {
+ $uids = implode(',', array_column($res_u, 'cf_uid'));
+ $list = $this->app_user_model->select(array('id in (' . $uids . ')' => null), 'id DESC', 0, 0, 'nickname,headimg');
+ }
+ }
+ if ($return_array) {
+ return $list;
+ }
+ return array('list' => $list, 'total' => $total);
+ }
+
+ /**
+ * Notes:获取博饼记录
+ * Created on: 2021/8/19 11:16
+ * Created by: dengbw
+ * @param $cf_uid
+ * @return array
+ */
+ private function pr_logs($cf_uid)
+ {
+ //$cf_uid = 14;
+ $logs = array();
+ if ($cf_uid) {
+ $where = array('app_id' => $this->app_id, 'act_key' => $this->appConfig['act_key'], 'uid' => $cf_uid);
+ } else {
+ $where = array('app_id' => $this->app_id, 'act_key' => $this->appConfig['act_key'], 'uid' => $this->uid);
+ }
+ $res_l = $this->mdBobingLogs->select($where, 'id DESC', 1, 7, 'credit,hong_bao,car_gold,type,uid,cf_uid');
+ if ($res_l) {
+ $uids = array_column($res_l, 'cf_uid');
+ array_unique($uids);
+ $users2 = $this->app_user_model->select(array('id in (' . implode(',', $uids) . ')' => null), 'id DESC', 0, 0, 'id,nickname');
+ $nicknames = array();//微信昵称
+ foreach ($users2 as $key => $value) {
+ $nicknames[$value['id']] = $value['nickname'] ? $value['nickname'] : '****';
+ }
+ foreach ($res_l as $key => $value) {
+ $content = '';
+ if ($value['type'] == 0) {
+ $content = "桌长博到{$value['credit']}幸运分";
+ $value['car_gold'] > 0 && $content .= "和{$value['car_gold']}元购车金";
+ } else if ($value['type'] == 1) {
+ $content = $nicknames[$value['cf_uid']] . "为桌长博到{$value['credit']}幸运分";
+ $value['car_gold'] > 0 && $content .= "和{$value['car_gold']}元购车金";
+ $value['hong_bao'] > 0 && $content .= ",额外博到现金红包";
+ } else if ($value['type'] == 2) {
+ $content = "桌长加企业微信得到{$value['credit']}幸运分";
+ }
+ $logs[] = $content;
+ }
+ }
+ return $logs;
+ }
+
+ /**
+ * Notes:检查博饼时间
+ * Created on: 2021/8/27 14:25
+ * Created by: dengbw
+ * @throws Hd_exception
+ */
+ protected function check_game_date()
+ {
+ if ($this->appConfig['game_start_date'] > date('Y-m-d')) {
+ throw new Hd_exception('博饼未开始', API_CODE_FAIL);
+ }
+ if ($this->appConfig['game_end_date'] < date('Y-m-d')) {
+ throw new Hd_exception('博饼已结束', API_CODE_FAIL);
+ }
+ }
+
+}
diff --git a/api/controllers/wxapp/bobing/Home.php b/api/controllers/wxapp/bobing/Home.php
new file mode 100644
index 00000000..80da8e9b
--- /dev/null
+++ b/api/controllers/wxapp/bobing/Home.php
@@ -0,0 +1,375 @@
+login_white = '';//
+ $this->check_status = array();//用户状态校验
+ $this->check_mobile = array();//需要手机号
+ $this->check_headimg = array();//授权微信信息
+ $this->majia_white = array('get');//超级管理员披上马甲可操作权限
+ $this->uid = $this->session['uid'];
+ $this->load->model('bobing/bobing_user_model', 'mdBobingUser');
+ $this->load->model('bobing/bobing_user_credit_model', 'mdBobingUserCredit');
+ $this->load->model('apporder/order_purchase_model', 'mdOrderPurchase');
+ $this->appConfig = $this->mdBobingUser->appConfig();
+ }
+
+ /**
+ * Notes:首页
+ * Created on: 2020/8/10 11:47
+ * Created by: dengbw
+ * @return array
+ * @throws Exception
+ */
+ protected function get()
+ {
+ $this->data['bodata'] = array('title' => "累计博饼次数", 'content' => $this->appConfig['content']
+ , 'bo_nums' => $this->mdBobingUser->boNums($this->appConfig['act_key']));
+ $lucky_car[] = array('title' => '雷丁芒果开回家', 'img' => 'https://qs.haodian.cn/wechat_app/liche/bobing/2021/index-tip.jpg'
+ , 'url' => '/bobing/pages/game/index');
+ $this->data['lucky_car'] = $lucky_car;
+ $this->data['group'] = $this->appConfig['group'];
+ $this->data['title'] = $this->appConfig['title'];
+ return $this->data;
+ }
+
+ /**
+ * Notes:排名
+ * Created on: 2021/8/20 15:23
+ * Created by: dengbw
+ * @return array
+ */
+ protected function get_ranking()
+ {
+ //日期列表-博饼
+ $this->data['dates'] = $this->pr_dates(false);
+ $this->data['rank'] = $this->pr_ranking_date(true);//今日幸运分
+ $this->data['winners'] = $this->pr_winners(true);
+ $this->data['title'] = $this->appConfig['title'];
+ return $this->data;
+ }
+
+ /**
+ * Notes:今日幸运分排名
+ * Created on: 2021/8/20 15:23
+ * Created by: dengbw
+ * @return array
+ */
+ public function get_ranking_date()
+ {
+ $params = $this->input->get();
+ $this->data['rank'] = $this->pr_ranking_date(false, $params);
+ return $this->data;
+ }
+
+ /**
+ * Notes:总幸运分排名
+ * Created on: 2021/8/20 15:24
+ * Created by: dengbw
+ * @return array
+ */
+ public function get_ranking_all()
+ {
+ $params = $this->input->get();
+ $this->data['rank'] = $this->pr_ranking_all(false, $params);
+ return $this->data;
+ }
+
+ /**
+ * Notes:中奖用户
+ * Created on: 2021/8/20 15:38
+ * Created by: dengbw
+ * @return array
+ */
+ public function get_winners()
+ {
+ $params = $this->input->get();
+ $this->data['winners'] = $this->pr_winners(false, $params);
+ return $this->data;
+ }
+
+ private function pr_ranking_date($return_array = false, $params = array())
+ {
+ $page = $params['page'] ? intval($params['page']) : 1;
+ $size = $params['size'] ? intval($params['size']) : 100;
+ $bo_date = date('Y-m-d');
+ $list = array();
+ $where = array('app_id' => $this->app_id, 'act_key' => $this->appConfig['act_key'], 'bo_date' => $bo_date);
+ $total = $this->mdBobingUserCredit->count($where);
+ if ($total) {
+ $res_c = $this->mdBobingUserCredit->select($where, 'credit desc,u_time asc', $page, $size, 'uid,credit');
+ if ($res_c) {
+ $users = array();//微信昵称
+ $uids = array_column($res_c, 'uid');
+ $re_u = $this->app_user_model->select(array('id in (' . implode(',', $uids) . ')' => null), 'id DESC', 0, 0, 'id,nickname,headimg');
+ foreach ($re_u as $key => $value) {
+ $users[$value['id']] = array('nickname' => $value['nickname'], 'headimg' => $value['headimg']);
+ }
+ foreach ($res_c as $key => $value) {
+ $user = $users[$value['uid']];
+ $list[] = array('id' => $key + 1, 'nickname' => $user['nickname'], 'headimg' => $user['headimg']
+ , 'credit' => $value['credit'] . '分');
+ }
+ }
+ }
+ if ($return_array) {
+ return $list;
+ }
+ return array('list' => $list, 'total' => $total);
+ }
+
+ private function pr_ranking_all($return_array = false, $params = array())
+ {
+ $page = $params['page'] ? intval($params['page']) : 1;
+ $size = $params['size'] ? intval($params['size']) : 100;
+ $list = array();
+ $where = array('app_id' => $this->app_id, 'act_key' => $this->appConfig['act_key']);
+ $total = $this->mdBobingUser->count($where);
+ if ($total) {
+ $res_c = $this->mdBobingUser->select($where, 'credit desc,u_time asc', $page, $size, 'uid,credit');
+ if ($res_c) {
+ $users = array();//微信昵称
+ $uids = array_column($res_c, 'uid');
+ $re_u = $this->app_user_model->select(array('id in (' . implode(',', $uids) . ')' => null), 'id DESC', 0, 0, 'id,nickname,headimg');
+ foreach ($re_u as $key => $value) {
+ $users[$value['id']] = array('nickname' => $value['nickname'], 'headimg' => $value['headimg']);
+ }
+ foreach ($res_c as $key => $value) {
+ $user = $users[$value['uid']];
+ $list[] = array('id' => $key + 1, 'nickname' => $user['nickname'], 'headimg' => $user['headimg']
+ , 'credit' => $value['credit'] . '分');
+ }
+ }
+ }
+ if ($return_array) {
+ return $list;
+ }
+ return array('list' => $list, 'total' => $total);
+ }
+
+ private function pr_winners($return_array = false, $params = array())
+ {
+ $dates = $this->pr_dates(false);
+ $date_default = $dates ? $dates[0] : date('Y-m-d');
+ $bo_date = $params['date'] ? $params['date'] : $date_default;
+ //$bo_date = '2021-08-19';
+ $list = array();
+ $where = array('app_id' => $this->app_id, 'act_key' => $this->appConfig['act_key'], 'bo_date' => $bo_date, 'lottery' => 1);
+ $total = $this->mdBobingUserCredit->count($where);
+ if ($total) {
+ $res_c = $this->mdBobingUserCredit->select($where, 'credit desc,u_time asc', 1, 10, 'uid,credit');
+ if ($res_c) {
+ $users = array();//微信昵称
+ $uids = array_column($res_c, 'uid');
+ $re_u = $this->app_user_model->select(array('id in (' . implode(',', $uids) . ')' => null), 'id DESC', 0, 0, 'id,nickname,headimg');
+ foreach ($re_u as $key => $value) {
+ $users[$value['id']] = array('nickname' => $value['nickname'], 'headimg' => $value['headimg']);
+ }
+ foreach ($res_c as $key => $value) {
+ $user = $users[$value['uid']];
+ $list[] = array('id' => $key + 1, 'nickname' => $user['nickname'], 'headimg' => $user['headimg']
+ , 'credit' => $value['credit'] . '分');
+ }
+ }
+ }
+ if ($return_array) {
+ return $list;
+ }
+ return array('list' => $list, 'total' => $total);
+ }
+
+ /**
+ * Notes:规则
+ * Created on: 2021/8/19 17:08
+ * Created by: dengbw
+ * @return array
+ */
+ protected function get_rule()
+ {
+ $this->data['rule'] = $this->appConfig['rule'];
+ $this->data['title'] = $this->appConfig['title'];
+ return $this->data;
+ }
+
+ /**
+ * Notes:礼品
+ * Created on: 2021/8/19 17:45
+ * Created by: dengbw
+ * @return array
+ */
+ protected function get_gift()
+ {
+ $this->data['gift'] = $this->appConfig['gift'];
+ $this->data['title'] = $this->appConfig['title'];
+ return $this->data;
+ }
+
+ /**
+ * Notes:我的
+ * Created on: 2021/8/27 10:29
+ * Created by: dengbw
+ * @return array
+ */
+ protected function get_mine()
+ {
+ $credit = $car_gold = 0;
+ $re_u = $this->mdBobingUser->get(array('app_id' => $this->app_id, 'act_key' => $this->appConfig['act_key'], 'uid' => $this->uid));
+ if ($re_u) {
+ $credit = $re_u['credit'];
+ $car_gold = $re_u['car_gold'] + $re_u['buy_car_gold'];
+ }
+ $img_url = 'https://qs.haodian.cn/wechat_app/liche';
+ $menulist[] = array('title' => '9.9抢500购车金', 'url' => 'buy_car_gold', 'img' => $img_url . '/bobing/2021/icon-mine-1.png');
+ $menulist[] = array('title' => '预约试驾', 'url' => '/pages/buyCar/detail/index?id=13', 'img' => $img_url . '/bobing/2021/icon-mine-4.png');
+ $menulist[] = array('title' => '我的海报', 'url' => '/bobing/pages/game/invite/index', 'img' => $img_url . '/bobing/2021/icon-mine-2.png');
+ $menulist[] = array('title' => '联系客服', 'url' => '/pages/', 'img' => $img_url . '/bobing/2021/icon-mine-3.png');
+ $menulist[] = array('title' => '狸车首页', 'url' => 'lc://switchTab/pages/index/index', 'img' => $img_url . '/bobing/2021/icon-mine-5.png');
+ $data = array(
+ "title" => $this->appConfig['title'],
+ "credit" => array('title' => '幸运分', 'value' => $credit),
+ "car_gold" => array('title' => '购车金', 'value' => $car_gold),
+ "tips" => '您已打败全闽南97.77%的用户
继续邀请好友助力博饼,冲刺大奖吧~
',
+ "menulist" => $menulist
+ );
+ return $data;
+ }
+
+ /**
+ * Notes:购买购车金
+ * Created on: 2021/8/31 9:57
+ * Created by: dengbw
+ * @return array
+ */
+ protected function get_buy_car_gold()
+ {
+ $where = array('app_id' => $this->appConfig['act_key'], 'app_uid' => $this->uid, 'item_id' => 1);
+ $re_p = $this->mdOrderPurchase->get($where);
+ if (!$re_p) {
+ $sid = create_order_no(350200);
+ $add_data = [
+ 'app_id' => $this->appConfig['act_key'],
+ 'app_uid' => $this->uid,
+ 'sid' => $sid,
+ 'item_id' => 1,
+ 'item_title' => '9.9抢500购车金',
+ 'item_num' => 1,
+ 'type' => 3,
+ 'item_price' => 9.9,
+ 'total_price' => 0.01,//9.9
+ 'uname' => $this->session['nickname'],
+ 'mobile' => $this->session['mobile'],
+ 'payway' => 1,
+ 'status' => 1,
+ 'status_detail' => 11,
+ 'c_time' => time()
+ ];
+ $order_id = $this->mdOrderPurchase->add($add_data);
+ $date = array('sid' => $sid, 'tips' => $order_id ? '' : '购买失败请重试');
+ } else {
+ $date = array('sid' => $re_p['sid'], 'tips' => $re_p['status'] == 2 ? '您已经购买了' : '');
+ }
+ return $date;
+ }
+
+ /**
+ * Notes:获取二维码
+ * Created on: 2021/8/27 16:34
+ * Created by: dengbw
+ * @return array
+ * @throws Hd_Exception
+ */
+ protected function get_qrcode()
+ {
+ $scene = $this->input_param('scene');
+ $page = $this->input_param('page');
+ $width = $this->input_param('width');
+ $fig = $this->input_param('fig');
+ if (0 == strlen($scene)) {
+ throw new Hd_Exception('二维码参数必填', API_CODE_INVILD_PARAM);
+ }
+ return $this->qrcode($scene, $page, $width, $fig);
+ }
+
+ /**
+ * Notes:获取图片二维码
+ * Created on: 2021/8/27 16:33
+ * Created by: dengbw
+ * @param $scene
+ * @param string $page
+ * @param int $width
+ * @param string $fig
+ * @return array
+ * @throws Hd_Exception
+ */
+ private function qrcode($scene, $page = '', $width = 0, $fig = 'liche')
+ {
+ $path = "{$page}?{$scene}";
+ $width && $path .= "{$width}";
+ if ($fig) {
+ $this->config->load('app', true, true);
+ $configs = $this->config->item('app');
+ $config = $configs[$fig];
+ if (!$config) {
+ debug_log("[error] " . __FUNCTION__ . ": config not exist;fig={$fig}", $this->log_file);
+ throw new Hd_Exception('请求的小程序不存在', API_CODE_INVILD_PARAM);
+ }
+ $wxconfig = $config['wx'];
+ } else {
+ $wxconfig = $this->wx_config;
+ $fig = $this->app_key;
+ }
+ $filename = "{$fig}/" . substr(md5($path), 8, 16);
+ $this->load->library('Hdwechat');
+ $hdwechat = new Hdwechat($wxconfig);
+ $ret = $hdwechat->qrcode($filename, $scene, $page, $width);
+ if (!$ret) {
+ throw new Hd_Exception('生成失败,稍后重试', API_CODE_FAIL);
+ }
+ $data = array('url' => $ret['url']);
+ return $data;
+ }
+
+ //日期列表
+ private function pr_dates($include_today = true)
+ {
+ $ttl = 60;
+ $mc = &load_cache();
+ $key_dates = 'dates' . $this->appConfig['act_key'] . '_' . date('Y-m-d') . '_' . $include_today;
+ $dates = $mc->get($key_dates);
+ if (!$dates) {
+ $date_end = $include_today ? strtotime(date('Y-m-d')) : strtotime(date('Y-m-d', strtotime('-1 day')));
+ $game_start_date = strtotime($this->appConfig['game_start_date']);
+ $game_start_end = strtotime($this->appConfig['game_end_date']);
+ $dates = array();
+ $do = true;
+ while ($do) {
+ if ($game_start_date <= $date_end && $game_start_date <= $game_start_end) {
+ $dates[] = date('Y-m-d', $game_start_date);
+ $game_start_date = strtotime('+1 day', $game_start_date);
+ } else {
+ $do = false;
+ }
+ }
+ $dates = array_reverse($dates);
+ $mc->save($key_dates, $dates, $ttl);
+ }
+ return $dates;
+ }
+
+}
diff --git a/api/controllers/wxapp/liche/Wxnotify.php b/api/controllers/wxapp/liche/Wxnotify.php
index d94bb68c..c17a0170 100755
--- a/api/controllers/wxapp/liche/Wxnotify.php
+++ b/api/controllers/wxapp/liche/Wxnotify.php
@@ -6,74 +6,73 @@
* Time: 20:17
*/
//微信支付回调
-require_once APPPATH."third_party/WXpay/WxPay.Api.php";
+require_once APPPATH . "third_party/WXpay/WxPay.Api.php";
+require_once APPPATH . "third_party/WXconfig/liche_WxPay.Config.php";
-class Wxnotify extends CI_Controller{
+class Wxnotify extends CI_Controller
+{
private $log_file = 'liche_pay.log';
private $log_dir = "wxapp_liche_pay";
private $app_id = 1;
private $notify;
- public function __construct(){
+
+ public function __construct()
+ {
parent::__construct();
- $this->load->model('app/app_wxpaylog_model', 'wxpaylog_model');
- $this->load->model('apporder/order_purchase_model','purchase_model');
- $input = file_get_contents("php://input");
- debug_log("[info] ". __FUNCTION__ . "# input:" . $input, $this->log_file);
- //xml 转数组
- $obj = simplexml_load_string($input,"SimpleXMLElement", LIBXML_NOCDATA);
- $obj_array = json_decode(json_encode($obj),true);
- $mch_id = $obj_array['mch_id'];
- $config_file = APPPATH."third_party/WXconfig/liche_WxPay.Config.php";
- if(!file_exists($config_file)){
- debug_log("[error] ". __FUNCTION__ . ":商户配置文件不存在", $this->log_file);
- exit();
- }
- try{
+ try {
//如果返回成功则验证签名
$config = new WxPayConfig();
$wxpay = new WxPayNotifyResults();
+ $input = file_get_contents("php://input");
$result = WxPayNotifyResults::Init($config, $input);
$this->notify = $result->GetValues();
- }catch (WxPayException $e){
- debug_log("[error] ". __FUNCTION__ . ":".$e->getMessage(), $this->log_file);
+ debug_log("[info] " . __FUNCTION__ . "# notify:" . json_encode($this->notify, JSON_UNESCAPED_UNICODE), $this->log_file);
+ $this->load->model('app/app_wxpaylog_model', 'wxpaylog_model');
+ $this->load->model('apporder/order_purchase_model', 'purchase_model');
+ $this->load->model('bobing/bobing_user_model', 'mdBobingUser');
+ } catch (WxPayException $e) {
+ debug_log("[error] " . __FUNCTION__ . ":" . $e->getMessage(), $this->log_file);
exit();
}
}
+
//支付回调
- public function index(){
+ public function index()
+ {
$sid = $this->notify['out_trade_no'];
- if($sid&&$this->notify['out_trade_no']){
- debug_log("[start] ". __FUNCTION__ . ": out_trade_no:".$this->notify['out_trade_no'], $this->log_file);
- $order = $this->purchase_model->get(array('sid'=>$sid,'app_id'=>$this->app_id));
- if(!$order){
- debug_log("[error] ". __FUNCTION__ . ":{$sid}_订单不存在", $this->log_file);
+ if ($sid && $this->notify['out_trade_no']) {
+ debug_log("[start] " . __FUNCTION__ . ": out_trade_no:" . $this->notify['out_trade_no'], $this->log_file);
+ $this->app_id = $this->mdBobingUser->appConfig()['act_key'];
+ $order = $this->purchase_model->get(array('sid' => $sid, 'app_id' => $this->app_id));
+ if (!$order) {
+ debug_log("[error] " . __FUNCTION__ . ":{$sid}_订单不存在", $this->log_file);
}
//执行失败
$add = array(
'app_id' => $this->app_id,
- 'sid' => $sid?$sid:0,
- 'trade_no' => $this->notify['transaction_id'],
- 'notify_param' => json_encode($this->notify,JSON_UNESCAPED_UNICODE)
+ 'sid' => $sid ? $sid : 0,
+ 'trade_no' => $this->notify['transaction_id'],
+ 'notify_param' => json_encode($this->notify, JSON_UNESCAPED_UNICODE)
);
$ret = $this->wxpaylog_model->add($add);
- if(!$ret){
- debug_log("[error] ". __FUNCTION__ . ": sql:".$this->wxpaylog_model->db->last_query(), $this->log_file);
+ if (!$ret) {
+ debug_log("[error] " . __FUNCTION__ . ": sql:" . $this->wxpaylog_model->db->last_query(), $this->log_file);
}
- if($this->notify['result_code'] != 'SUCCESS'){ //支付失败
- debug_log("[error] ". __FUNCTION__ . ":支付失败,sid={$sid},app_id=", $this->log_file);
- }else{ //支付成功
- $this->load->service('apporder/payment_service', array('app_id' => $this->app_id));
- $result = $this->payment_service->after_pay($sid,$this->notify['cash_fee']/100);
- if($result['code']){
- debug_log("[success] ". __FUNCTION__ . ":操作成功", $this->log_file);
- }else{
- debug_log("[error] ". __FUNCTION__ . ":".$result['msg'], $this->log_file);
- }
+ if ($this->notify['result_code'] != 'SUCCESS') { //支付失败
+ debug_log("[error] " . __FUNCTION__ . ":支付失败,sid={$sid},app_id=", $this->log_file);
+ } else { //支付成功
+ $this->load->service('apporder/payhd_service', array('app_id' => $this->app_id));
+ $result = $this->payhd_service->after_pay($sid, $this->notify['cash_fee'] / 100);
+ if ($result['code']) {
+ debug_log("[success] " . __FUNCTION__ . ":操作成功", $this->log_file);
+ } else {
+ debug_log("[error] " . __FUNCTION__ . ":" . $result['msg'], $this->log_file);
+ }
}
- debug_log("[finish] ". __FUNCTION__ . ": out_trade_no:".$this->notify['out_trade_no'], $this->log_file);
- }else{
- debug_log("[finish] ". __FUNCTION__ . ": 参数错误:".json_encode($this->notify,JSON_UNESCAPED_UNICODE), $this->log_file);
+ debug_log("[finish] " . __FUNCTION__ . ": out_trade_no:" . $this->notify['out_trade_no'], $this->log_file);
+ } else {
+ debug_log("[finish] " . __FUNCTION__ . ": 参数错误:" . json_encode($this->notify, JSON_UNESCAPED_UNICODE), $this->log_file);
}
echo '';
return;
diff --git a/api/libraries/bobing/Base.class.php b/api/libraries/bobing/Base.class.php
new file mode 100644
index 00000000..2e3dec1e
--- /dev/null
+++ b/api/libraries/bobing/Base.class.php
@@ -0,0 +1,27 @@
+$property_name){
+ return $this->$property_name;
+ } elseif(method_exists($this, $func))
+ {
+ return $this->$property_name = $this->$func();
+ } else {
+ return $this->$property_name = false;
+ }
+ }
+
+ public function get_ci()
+ {
+ $ci = &get_instance();
+ return $ci;
+ }
+}
\ No newline at end of file
diff --git a/api/libraries/bobing/Bo.php b/api/libraries/bobing/Bo.php
new file mode 100644
index 00000000..c026619d
--- /dev/null
+++ b/api/libraries/bobing/Bo.php
@@ -0,0 +1,233 @@
+ '100', 2 => '100', 3 => '150', 4 => '100', 5 => '150', 6 => '100', 7 => '150');
+
+ public function __construct()
+ {
+ $this->ci->load->model('bobing/bobing_user_model');
+ $this->ci->load->model('bobing/bobing_user_credit_model');
+ $this->ci->load->model('bobing/bobing_logs_model');
+ $this->appConfig = $this->ci->bobing_user_model->appConfig();
+ }
+
+ /**
+ * Notes:开桌博饼
+ * Created on: 2021/8/10 17:41
+ * Created by: dengbw
+ * @return mixed
+ */
+ public function kz_bo()
+ {
+ if ($this->valid_nums <= 0) {
+ return array('status' => 1, 'title' => '邀请好友', 'content' => '您的博饼次数已用完啦
立即邀请好友助力博饼,
冲刺购物卡、苹果手机、汽车大奖
');
+ }
+ $mc = &load_cache();
+ $key = 'LiChe_bobing_' . $this->act_key . $this->app_id . $this->uid;
+ $timeout = $mc->get($key);
+ if ($timeout && (time() - $timeout) < 2) {
+ return array('status' => API_CODE_FAIL, 'content' => '您操作太快了,速度越慢越能博到状元,刷新页面再试试');
+ }
+ $mc->save($key, time());
+ $this->ci->load->library('bobing/dice');
+ $this->ci->dice->init();
+ $size_result = $this->ci->dice->getResultArr();
+ $level = $this->ci->dice->getResultLevel();
+ $data['app_id'] = $this->appConfig['app_id'];
+ $data['act_key'] = $this->appConfig['act_key'];
+ $data['uid'] = $this->uid;
+ $data['dices'] = implode(',', $size_result);
+ $data['level'] = $level;
+ $data['credit'] = $this->ci->dice->getcredit($level);
+ $data['bo_date'] = date('Y-m-d');
+ $data['ip'] = get_client_ip();
+ $data['ua'] = $_SERVER['HTTP_USER_AGENT'];
+ $data['type'] = 0;
+ $data['c_time'] = time();
+ $content = $title = '';
+ $re_u = $this->ci->bobing_user_model->get(array('app_id' => $data['app_id'], 'act_key' => $data['act_key'], 'uid' => $this->uid));
+ if ($re_u['car_gold'] < $this->appConfig['max_car_gold']) {//购车金小于购车金设定值
+ if ($this->appConfig['ratio_car_gold'] && $this->appConfig['ratio_car_gold'] >= rand(1, 100)) {//购车金概率
+ $car_gold = $this->carGoldAry[rand(1, 7)];
+ if (($car_gold + $re_u['car_gold']) > $this->appConfig['max_car_gold']) {//如果购车金大于设定值,那么本次增加到最大值
+ $car_gold = $this->appConfig['max_car_gold'] - $re_u['car_gold'];
+ }
+ $data['car_gold'] = $car_gold;
+ $content = '您博到购车金' . $car_gold . '元';
+ $title = '恭喜您';
+ }
+ }
+ $re_l = $this->add_log($data);
+ if ($re_l['status'] == 1) {
+ return array('status' => API_CODE_FAIL, 'content' => '博饼日志添加失败');
+ }
+ $data['level_name'] = $this->ci->dice->getResultName();
+ $data['status'] = 0;
+ $data['lid'] = $re_l['lid'];
+ $data['title'] = $title;
+ $data['content'] = $content;
+ return $data;
+ }
+
+ /**
+ * Notes:助力博饼
+ * Created on: 2021/8/12 17:13
+ * Created by: dengbw
+ * @return mixed
+ */
+ public function zl_bo()
+ {
+ $data['app_id'] = $this->appConfig['app_id'];
+ $data['act_key'] = $this->appConfig['act_key'];
+ if ($this->valid_nums <= 0) {
+ $re_u = $this->ci->bobing_user_model->get(array('app_id' => $data['app_id'], 'act_key' => $data['act_key'], 'uid' => $this->uid));
+ $credit = intval($re_u['credit']);
+ return array('status' => 2, 'title' => '立即开桌', 'content' => '您已获得' . $credit . '积分,
立即开桌获得更多幸运分,
冲刺购物卡、苹果手机、汽车大奖
');
+ }
+ $mc = &load_cache();
+ $key = 'LiChe_bobing_' . $this->act_key . $this->app_id . $this->uid;
+ $timeout = $mc->get($key);
+ if ($timeout && (time() - $timeout) < 2) {
+ return array('status' => API_CODE_FAIL, 'msg' => '您操作太快了,速度越慢越能博到状元,刷新页面再试试');
+ }
+ $mc->save($key, time());
+ $this->ci->load->library('bobing/dice');
+ $this->ci->dice->init();
+ $size_result = $this->ci->dice->getResultArr();
+ $level = $this->ci->dice->getResultLevel();
+
+ $data['uid'] = $this->cf_uid;
+ $data['cf_uid'] = $this->uid;
+ $data['dices'] = implode(',', $size_result);
+ $data['level'] = $level;
+ $data['credit'] = $this->ci->dice->getcredit($level);
+ $data['bo_date'] = date('Y-m-d');
+ $data['ip'] = get_client_ip();
+ $data['ua'] = $_SERVER['HTTP_USER_AGENT'];
+ $data['type'] = 1;
+ $content = $title = '';
+ $re_u = $this->ci->bobing_user_model->get(array('app_id' => $data['app_id'], 'act_key' => $data['act_key'], 'uid' => $data['uid']));
+ if ($re_u['car_gold'] < $this->appConfig['max_car_gold']) {//购车金小于购车金设定值
+ if ($this->appConfig['ratio_car_gold'] && $this->appConfig['ratio_car_gold'] >= rand(1, 100)) {//购车金概率
+ $car_gold = $this->carGoldAry[rand(1, 7)];
+ if (($car_gold + $re_u['car_gold']) > $this->appConfig['max_car_gold']) {//如果购车金大于设定值,那么本次增加到最大值
+ $car_gold = $this->appConfig['max_car_gold'] - $re_u['car_gold'];
+ }
+ $data['car_gold'] = $car_gold;
+ $content = '为桌长博到购车金' . $car_gold . '元';
+ $title = '恭喜您';
+ }
+ }
+ $hong_bao_day = $this->ci->bobing_user_model->hongBaoDay($data['act_key']);
+ if (!$data['car_gold'] && ($hong_bao_day < $this->appConfig['hong_bao_day'])) {//无购车金时抽红包与红包小于每日设定值
+ if ($this->appConfig['ratio_hong_bao'] && $this->appConfig['ratio_hong_bao'] >= rand(1, 100)) {//红包概率
+ $re_l = $this->ci->bobing_logs_model->get(array('app_id' => $data['app_id'], 'act_key' => $data['act_key'], 'uid' => $data['uid']
+ , 'cf_uid' => $data['cf_uid']));
+ if (!$re_l) {//帮博时只能在一个用户上中一次红包
+ $hong_bao = '0.3'; //'0.' . rand(30, 68);//0.30到0.68红包
+ $data['hong_bao'] = $hong_bao;
+ $data['status'] = 1;
+ $content = '您博到现金红包' . $data['hong_bao'] . '元';
+ $title = '恭喜您';
+ $this->ci->bobing_user_model->hongBaoDay($data['act_key'], $hong_bao);
+ }
+ }
+ }
+ $log = $this->add_log($data);
+ if ($log['status'] == 1) {
+ return array('status' => API_CODE_FAIL, 'content' => '博饼日志添加失败');
+ }
+ $data['level_name'] = $this->ci->dice->getResultName();
+ $data['status'] = 0;
+ $data['lid'] = $log['lid'];
+ $data['title'] = $title;
+ $data['content'] = $content;
+ return $data;
+ }
+
+ /**
+ * Notes:添加企业微信加分
+ * Created on: 2021/8/25 10:04
+ * Created by: dengbw
+ */
+ public function wxqy_credit()
+ {
+ $re_l = $this->ci->bobing_logs_model->get(array('uid' => $this->uid, 'app_id' => $this->appConfig['app_id'], 'type' => 3));
+ if ($re_l) {
+ return array('status' => -1, 'content' => '已添过企业微信加分了');
+ }
+ $data['app_id'] = $this->appConfig['app_id'];
+ $data['act_key'] = $this->appConfig['act_key'];
+ $data['uid'] = $this->uid;
+ $data['credit'] = $this->appConfig['wxqy_nums'];
+ $data['bo_date'] = date('Y-m-d');
+ $data['ip'] = get_client_ip();
+ $data['ua'] = $_SERVER['HTTP_USER_AGENT'];
+ $data['type'] = 2;
+ $data['c_time'] = time();
+ $log = $this->add_log($data);
+ if ($log['status'] == 1) {
+ return array('status' => -1, 'content' => '博饼日志添加失败');
+ }
+ return array('status' => $log['lid'], 'content' => '企业微信加分成功');
+ }
+
+ //博饼结果保存到数据库
+ private function add_log($data)
+ {
+ $_data['status'] = 0;
+ $this->ci->bobing_logs_model->db->trans_begin();
+ try {
+ $lid = $this->ci->bobing_logs_model->add($data);
+ if ($lid) {
+ $map = array('act_key' => $data['act_key'], 'app_id' => $data['app_id'], 'uid' => $data['uid']);
+ $up_data["credit = credit+{$data['credit']}"] = null;//加积分
+ $data['car_gold'] && $up_data["car_gold = car_gold+{$data['car_gold']}"] = null;//加购车金
+ $data['type'] == 2 && $up_data["wxqy"] = 1;//加企业微信
+ $this->ci->bobing_user_model->update($up_data, $map);
+ $map['bo_date'] = $data['bo_date'];
+ if ($this->ci->bobing_user_credit_model->cache('get', array($map, 'id'))) {
+ $this->ci->bobing_user_credit_model->update(array("credit = credit+{$data['credit']}" => null), $map);
+ } else {
+ $map['credit'] = $data['credit'];
+ $map['c_time'] = time();
+ $this->ci->bobing_user_credit_model->add($map);
+ }
+ //助力加分
+ if ($data['type'] == 1) {
+ $map_my = array('act_key' => $data['act_key'], 'app_id' => $data['app_id'], 'uid' => $data['cf_uid']);
+ $this->ci->bobing_user_model->update(array("credit = credit+{$data['credit']}" => null), $map_my);
+ $map_my['bo_date'] = $data['bo_date'];
+ if ($this->ci->bobing_user_credit_model->cache('get', array($map_my, 'id'))) {
+ $this->ci->bobing_user_credit_model->update(array("credit = credit+{$data['credit']}" => null), $map_my);
+ } else {
+ $map_my['credit'] = $data['credit'];
+ $map_my['c_time'] = time();
+ $this->ci->bobing_user_credit_model->add($map_my);
+ }
+ }
+ $this->ci->bobing_user_model->boNums($data['act_key'], 1);
+ }
+ $_data['lid'] = $lid;
+ } catch (Exception $e) {
+ $this->ci->bobing_logs_model->db->trans_rollback();
+ $_data['status'] = 1;
+ return $_data;
+ }
+ if ($this->ci->bobing_logs_model->db->trans_status() === FALSE) {
+ $this->ci->bobing_logs_model->db->trans_rollback();
+ $_data['status'] = 1;
+ return $_data;
+ }
+ $this->ci->bobing_logs_model->db->trans_commit();
+ return $_data;
+ }
+}
\ No newline at end of file
diff --git a/api/libraries/bobing/Dice.php b/api/libraries/bobing/Dice.php
new file mode 100644
index 00000000..26c5190c
--- /dev/null
+++ b/api/libraries/bobing/Dice.php
@@ -0,0 +1,312 @@
+ "六勃红",
+ self::RESULT_BDJ => "遍地锦",
+ self::RESULT_LBHEI => "六抔黑",
+ self::RESULT_ZYCJH => "状元插金花",
+ self::RESULT_WH => "五红",
+ self::RESULT_WZDYX => "五子带一秀",
+ self::RESULT_WZ => "五子",
+ self::RESULT_ZY => "状元",
+ self::RESULT_DT => "对堂",
+ self::RESULT_SH => "三红",
+ self::RESULT_SJ => "四进",
+ self::RESULT_EJ => "二举",
+ self::RESULT_YX => "一秀",
+ self::RESULT_FH => "罚黑"
+ );
+ return $arr;
+ }
+
+ /**
+ * 博小鱼币时,鱼币对应关系
+ * @param $level
+ * @return int
+ */
+ static public function getyucoin($level)
+ {
+ $arr = array(
+ self::RESULT_ZYCJH => 20, //状元插金花
+ self::RESULT_LBHONG => 18, //六勃红
+ //self::RESULT_BD => 13, //遍地锦
+ self::RESULT_LBHEI => 16, //六勃黑
+ self::RESULT_WH => 14, //五红
+ self::RESULT_WZDYX => 12, //五子带一秀
+ self::RESULT_WZ => 10, //五子
+ self::RESULT_ZY => 8, //状元
+ self::RESULT_DT => 5, //对堂
+ self::RESULT_SH => 4, //三红
+ self::RESULT_SJ => 3, //四进
+ self::RESULT_EJ => 2, //二举
+ self::RESULT_YX => 1, //一秀
+ self::RESULT_FH => 0, //罚黑
+ );
+ return intval($arr[$level]);
+ }
+
+ //结果名称
+ static public function getName($flag)
+ {
+ $arr = self::getAllLevel();
+ if (empty($arr[$flag])) {
+ return $arr[self::RESULT_FH];
+ } else {
+ return $arr[$flag];
+ }
+ }
+
+ //输出结果
+ static public function show_result_msg($resultlevel, &$resultname, &$istop)
+ {
+ if ($resultlevel == 0) {
+ $resultname = "鱼鱼加油 再试一次";
+ } else if ($resultlevel == Dice::RESULT_YX) {
+ $resultname .= " 一马当先";
+ } else if ($resultlevel == Dice::RESULT_EJ) {
+ $resultname .= " 加把劲往前冲";
+ } else if ($resultlevel == Dice::RESULT_SJ) {
+ $resultname .= " 再博博找找灵感";
+ } else if ($resultlevel == Dice::RESULT_SH) {
+ $resultname .= " 有点能耐继续努力";
+ } else if ($resultlevel == Dice::RESULT_DT) {
+ $resultname .= " 胜利在望";
+ } else if ($resultlevel >= Dice::RESULT_ZY) {
+ $istop = 1;
+ $resultname .= " 恭喜!";
+ }
+ return $resultname;
+ }
+
+ //初始化,随便生成点数
+ function init($resultStr = false)
+ {
+ if (!$resultStr) {
+ $this->run();
+ } else {
+ $this->_resultArr = self::strToArr($resultStr);
+ if (!$this->_resultArr) {
+ return false;
+ }
+ }
+ $this->parse();
+ }
+
+ //掷骰子
+ private function run($resultStr = false)
+ {
+ if (!$resultStr) {
+ $_DICE = array(
+ array(1, 2, 3, 4, 5, 6),
+ array(1, 2, 3, 4, 5, 6),
+ array(1, 2, 3, 4, 5, 6),
+ array(1, 2, 3, 4, 5, 6),
+ array(1, 2, 3, 4, 5, 6),
+ array(1, 2, 3, 4, 5, 6)
+ );
+
+ //生成随机数组
+ $dice_count = count($_DICE);
+ for ($i = 0; $i < $dice_count; $i++) {
+ $this->_resultArr[$i] = $_DICE[$i][rand(0, count($_DICE[$i]) - 1)];
+ }
+ } else {
+ $this->_resultArr = self::strToArr($resultStr);
+ if (!$this->_resultArr) {
+ return false;
+ }
+ }
+ }
+
+ //分析
+ private function parse()
+ {
+ $sumVal = 0; //总点数
+ //结果数量,用于统计哪个点有几个
+ $nums = array(
+ //点=>数量,
+ 1 => 0,
+ 2 => 0,
+ 3 => 0,
+ 4 => 0,
+ 5 => 0,
+ 6 => 0,
+ );
+
+ //统计点数数量
+ foreach ($this->_resultArr as $value) {
+ $nums[$value]++;
+ $sumVal += $value;
+ }
+ if ($nums[4] == 6) {
+ $this->_resultLevel = self::RESULT_LBHONG; //六勃红
+ } /*
+ * else if($nums[1] == 6){
+ $this->_resultLevel = self::RESULT_BDJ; //遍地锦
+ }
+ */
+ else if (($nums[2] == 6) || ($nums[3] == 6) || ($nums[5] == 6) || ($nums[6] == 6) || $nums[1] == 6) {
+ $this->_resultLevel = self::RESULT_LBHEI; //六勃黑
+ } else if (($nums[4] == 4) && ($nums[1] == 2)) {
+ $this->_resultLevel = self::RESULT_ZYCJH; //状元插金花
+ } else if ($nums[4] == 5) {
+ $this->_resultLevel = self::RESULT_WH; //五红
+ $this->_resultVal = $sumVal - 20; //附带点数
+ } else if ((($nums[1] == 5) || ($nums[2] == 5) || ($nums[3] == 5) || ($nums[5] == 5) || ($nums[6] == 5)) && ($nums[4] == 1)) {
+ $this->_resultLevel = self::RESULT_WZDYX; //五子带一秀
+ } else if ((($nums[1] == 5) || ($nums[2] == 5) || ($nums[3] == 5) || ($nums[5] == 5) || ($nums[6] == 5))) {
+ $this->_resultLevel = self::RESULT_WZ; //五子
+ if ($nums[$this->_resultArr[0]] == 5) {
+ $this->_resultVal = $sumVal - $this->_resultArr[0] * 5; //附带点数
+ } else {
+ $this->_resultVal = $this->_resultArr[0]; //附带点数
+ }
+ } else if (($nums[4] == 4)) {
+ $this->_resultLevel = self::RESULT_ZY; //状元
+ $this->_resultVal = $sumVal - 16; //附带点数
+ } else if (($nums[1] == 1) && ($nums[2] == 1) && ($nums[3] == 1) && ($nums[4] == 1) && ($nums[5] == 1) && ($nums[6] == 1)) {
+ $this->_resultLevel = self::RESULT_DT; //对堂
+ } else if ($nums[4] == 3) {
+ $this->_resultLevel = self::RESULT_SH; //三红
+ } else if (($nums[1] == 4) || ($nums[2] == 4) || ($nums[3] == 4) || ($nums[5] == 4) || ($nums[6] == 4)) {
+ $this->_resultLevel = self::RESULT_SJ; //四进
+ } else if ($nums[4] == 2) {
+ $this->_resultLevel = self::RESULT_EJ; //二举
+ } else if ($nums[4] == 1) {
+ $this->_resultLevel = self::RESULT_YX; //一秀
+ } else {
+ $this->_resultLevel = self::RESULT_FH; //罚黑
+ }
+ }
+
+ //重新掷骰子
+ public function reRun($resultStr = false)
+ {
+ //清空数据
+ $this->_resultLevel = 0;
+ $this->_resultVal = 0;
+ $this->_resultArr = array(0, 0, 0, 0, 0, 0);
+ $this->run($resultStr);
+ $this->parse();
+ }
+
+ //取得结果等级
+ public function getResultLevel()
+ {
+ return $this->_resultLevel;
+ }
+
+ //取得结果值(附带点数)
+ public function getResultVal()
+ {
+ return $this->_resultVal;
+ }
+
+ //取得结果名称
+ public function getResultName()
+ {
+ $resultLevel = $this->_resultLevel;
+ return $this->getName($resultLevel);
+ }
+
+ //取得结果骰子点数数组
+ public function getResultArr()
+ {
+ return $this->_resultArr;
+ }
+
+ //取得结果骰子点数字符串代表结果(用于保存到数据库中如234123)
+ public function getResultStr()
+ {
+ return implode($this->_resultArr);
+ }
+
+
+ public function getcredit($level = false)
+ {
+ $level = $level == false ? $this->_resultLevel : $level;
+ $arr = array(
+ self::RESULT_ZYCJH => 80, //状元插金花
+ self::RESULT_LBHONG => 60, //六勃红
+ //self::RESULT_BD => 13, //遍地锦
+ self::RESULT_LBHEI => 50, //六勃黑
+ self::RESULT_WH => 45, //五红
+ self::RESULT_WZDYX => 40, //五子带一秀
+ self::RESULT_WZ => 35, //五子
+ self::RESULT_ZY => 30, //状元
+ self::RESULT_DT => 15, //对堂
+ self::RESULT_SH => 8, //三红
+ self::RESULT_SJ => 4, //四进
+ self::RESULT_EJ => 2, //二举
+ self::RESULT_YX => 1, //一秀
+ self::RESULT_FH => 0, //罚黑
+ );
+ return intval($arr[$level]);
+ }
+
+ //把代表点数的字符串转化为点数数组
+ static public function strToArr($str = "")
+ {
+ if ($str == "") {
+ return false;
+ }
+ $arr = explode(',', $str);
+ if (count($arr) != 6) { //非法字符串
+ return false;
+ }
+ foreach ($arr as $value) {
+ if (!($value >= 1 && $value <= 6)) { //非法字符
+ return false;
+ }
+ }
+ return $arr;
+ }
+
+}
+
+//test
+//$dice = new Dice();
+//while($dice->getResultLevel() != 5)
+//{
+// $dice->reRun();
+//}
+//echo "
result lever:".$dice->getResultLevel();
+//echo "
result val:".$dice->getResultVal();
+//echo "
result name:".$dice->getResultName();
+//echo "
result string:".$dice->getResultStr();
+?>
\ No newline at end of file
diff --git a/api/third_party/WXconfig/liche_WxPay.Config.php b/api/third_party/WXconfig/liche_WxPay.Config.php
index 75af3369..6c92e462 100755
--- a/api/third_party/WXconfig/liche_WxPay.Config.php
+++ b/api/third_party/WXconfig/liche_WxPay.Config.php
@@ -9,7 +9,7 @@ class WxPayConfig
{
const APPID = 'wx98e64c11aac45966';
const APPSECRET = 'f8eec7be1c87a1c8e40213e144821ec3';
- const MCHID = '1611216095';
+ const MCHID = '1612289137';
const KEY = 'd1ddc03f6178767795dc283e68a80e81';
const SIGN_TYPE = 'MD5';
const NOTIFY_URL = '';
diff --git a/common/helpers/comm_helper.php b/common/helpers/comm_helper.php
index f72682c3..3740b4fe 100644
--- a/common/helpers/comm_helper.php
+++ b/common/helpers/comm_helper.php
@@ -880,7 +880,7 @@ if (!function_exists('http_host_com')){
if($type == 'api'){
$url = 'https://liche-api-dev.xiaoyu.com';
} else if($type == 'home'){
- $url = "https://liche-wxdev.xiaoyu.com";
+ $url = "https://liche-dev.xiaoyu.com";
} else if($type == 'admin'){
$url = "http://liche-admin.dev.xiaoyu.com";
}
diff --git a/common/libraries/Wx_qyapi.php b/common/libraries/Wx_qyapi.php
index 80016111..8b5f7c66 100644
--- a/common/libraries/Wx_qyapi.php
+++ b/common/libraries/Wx_qyapi.php
@@ -43,6 +43,11 @@ class Wx_qyapi
function init($params)
{
$configs = array(
+ //狸车
+ 'liche' => array(
+ 'corpid' => 'wwc2caba960d202087',//企业ID
+ 'corpsecret' => 'aQ2yhOBTXZnM0iwFtBzYIWbtyq4wFaIXBYTKg3xFxas',//企业密钥 R9fj_ocdb5p4Vr_qaQY54A4Z5SbyZBRWk4nfTMiPxgo
+ ),
//星选家
'xxj' => array(
'corpid' => 'wwecac3c2b60c31b1b',//企业ID
@@ -59,7 +64,7 @@ class Wx_qyapi
$params['corpid'] && $this->corpid = $params['corpid'];
$params['corpsecret'] && $this->corpsecret = $params['corpsecret'];
- $app = $params['app'] ? $params['app'] : 'xxj';
+ $app = $params['app'] ? $params['app'] : 'liche';
if ($configs[$app]) {
$config = $configs[$app];
!$this->corpid && $config['corpid'] && $this->corpid = $config['corpid'];
@@ -113,7 +118,7 @@ class Wx_qyapi
public function token()
{
- $url = self::BASE_URL . sprintf(self::TOKEN_API, $this->corpid, "EFIev4j-0iv4Uy2vrDATzsL3aIW2IT_kRO4zx73I31g");
+ $url = self::BASE_URL . sprintf(self::TOKEN_API, $this->corpid, $this->corpsecret);
$res = $this->ci->mycurl->httpGet($url);
$result = json_decode($res);
return $result;
diff --git a/common/models/app/App_wechatqy_model.php b/common/models/app/App_wechatqy_model.php
new file mode 100644
index 00000000..7b7a3178
--- /dev/null
+++ b/common/models/app/App_wechatqy_model.php
@@ -0,0 +1,15 @@
+table_name, 'default');
+ }
+}
diff --git a/common/models/bobing/Bobing_logs_model.php b/common/models/bobing/Bobing_logs_model.php
new file mode 100644
index 00000000..3714bb30
--- /dev/null
+++ b/common/models/bobing/Bobing_logs_model.php
@@ -0,0 +1,14 @@
+ 'LiChe博饼', 'content' => '2021闽南博饼嘉年华', 'game_start_date' => '2021-07-20', 'game_end_date' => '2021-09-31',
+ 'group' => array('title' => '添加小狸', 'btn' => '加小狸企业微信', 'tips' => '通过后送288幸运分'),
+ 'app_id' => 1, 'act_key' => $act_key, 'kz_nums' => 20, 'zl_nums' => 5, 'wxqy_nums' => 288, 'ratio_hong_bao' => 30, 'ratio_car_gold' => 50,
+ 'max_car_gold' => 500, 'buy_car_gold' => 500, 'hong_bao_day' => 1000, 'lottery_nums' => 10,
+ 'rule' => array('title' => '活动流程及规则', 'content' => '
+1.通过投放、社群、经销商等渠道,获取种子用户,种子用户发起活动,通过汽车大奖、iPHONE大奖,吸引开桌用户;
+2.开桌用户可以直接获得5次博饼次数,博饼次数用完后,通过邀请助力用户为其博饼,双方可获得如下福利
+(1)开桌用户:
+ ① 获得购车金:助力用户每次助力博饼,随机为开桌用户获得一定金额的购车金,购车金累计最高为500元;
+ ② 获得幸运分: 助力用户每次助力博饼,根据博出的结果,为开桌用户获得不同的幸运分:一秀1分、二举2分、四进5分、三红10分、对堂20分、状元50分…
+(2)助力用户:
+ ① 获得购车金:助力用户每次助力博饼,随机获得0.30元 - 0.68元不等现金红包,点击“立即开桌”后,即可到账(微信钱包);
+ ② 获得幸运分: 助力用户每次助力博饼,根据博出的结果,同时为自己获得幸运分:一秀1分、二举2分、四进5分、三红10分、对堂20分、状元50分…
+3.所有用户添加小狸企业微信,即可获得288幸运分
+4.添加小狸后,自动获取微信小程序链接,9.9元换购500元购车金,与博饼开桌获得的购车金合并,形成1000元购车金
+5.每日博饼幸运分进入日排行榜,前10名可获得100元购物卡(每位用户活动期间只能获得一次);
+6.开桌用户活动期间累计博饼幸运分,进入总排行榜,前11名可获得大奖:
+ ① 第1名获得雷丁芒果大奖
+ ② 第2-11名获得iPHONE 13大奖
'),
+ 'gift' => array(
+ array('id' => 1, 'title' => '第一名', 'img' => 'https://qs.haodian.cn/wechat_app/liche/bobing/2021/gift_box_tip_1.jpg'),
+ array('id' => 2, 'title' => '第2`11名', 'img' => 'https://qs.haodian.cn/wechat_app/liche/bobing/2021/gift_box_tip_2.jpg'),
+ array('id' => 3, 'title' => '购物金', 'img' => 'https://qs.haodian.cn/wechat_app/liche/bobing/2021/gift_box_tip_3.jpg'),
+ array('id' => 4, 'title' => '现金红包', 'img' => 'https://qs.haodian.cn/wechat_app/liche/bobing/2021/gift_box_tip_4.jpg')),
+ );
+ }
+ return $config;
+ }
+
+ //博饼总次数
+ public function boNums($act_key = '', $add = 0)
+ {
+ $redis_key = $act_key . '_bo_nums';
+ $redis = &load_cache('redis');
+ $boNums = $redis->get($redis_key);
+ if ($add) {
+ $boNums = $boNums ? $boNums : 1;
+ $boNums += mt_rand(3, 8);
+ $redis->save($redis_key, $boNums);
+ }
+ return $boNums ? $boNums : 0;
+ }
+
+ //每日红包发放数
+ public function hongBaoDay($act_key = '', $amount = 0)
+ {
+ $redis_key = $act_key . '_hong_bao_day_' . date('Y-m-d');
+ $redis = &load_cache('redis');
+ $get_amount = $redis->get($redis_key);
+ $get_amount = $get_amount ? $get_amount : 0;
+ if ($amount) {
+ $get_amount = $get_amount + $amount;
+ $redis->save($redis_key, $get_amount);
+ }
+ return $amount;
+ }
+}
diff --git a/common/models/bobing/base_model.php b/common/models/bobing/base_model.php
new file mode 100644
index 00000000..19f7a102
--- /dev/null
+++ b/common/models/bobing/base_model.php
@@ -0,0 +1,52 @@
+table_name, 'default');
+ }
+
+ protected function cache_key($params)
+ {
+ return $this->_cache_key_prefix . md5($this->table_name . $params);
+ }
+
+ /**
+ * 对方法的某个结果集做缓存
+ * @param $func
+ * @param array $param
+ * @param string $ttl
+ * @param string $type
+ * @return mixed
+ */
+ public function cache($func, $param = array(), $ttl = '', $type = 'mc')
+ {
+ $cache = &load_cache($type);
+ $cache_key = $this->cache_key($type . $func . json_encode($param));
+ $ttl > 0 && $this->mc_cache_expire = intval($ttl);
+ if (!$rt = $cache->get($cache_key)) {
+ $rt = call_user_func_array(array($this, $func), $param);
+ $cache->save($cache_key, $rt, $this->mc_cache_expire);
+ }
+ return $rt;
+ }
+
+ /**
+ * 删除某方法某个结果集的缓存
+ * @param $func
+ * @param array $param
+ * @param string $type
+ * @return mixed
+ */
+ public function un_cache($func, $param = array(), $type = 'mc')
+ {
+ $cache = &load_cache($type);
+ $cache_key = $this->cache_key($type . $func . json_encode($param));
+ return $cache->delete($cache_key);
+ }
+}
\ No newline at end of file
diff --git a/common/services/apporder/Payhd_service.php b/common/services/apporder/Payhd_service.php
new file mode 100644
index 00000000..1cf99ed5
--- /dev/null
+++ b/common/services/apporder/Payhd_service.php
@@ -0,0 +1,71 @@
+app_id = $params['app_id'];
+ }
+ $this->log_file = __CLASS__ . "_app_id_" . $this->app_id . '.log';
+ $this->load->model('apporder/order_purchase_model', 'mdOrderPurchase');
+ $this->load->model('bobing/bobing_user_model', 'mdBobingUser');
+ }
+
+
+ /**
+ * 支付后逻辑
+ * @param string $sid
+ * @param float $pay_price 订单真实支付金额
+ */
+ public function after_pay($sid, $pay_price = '')
+ {
+ if ($sid) {
+ debug_log("[start] " . __FUNCTION__ . ": sid:" . $sid, $this->log_file);
+ $order = $this->mdOrderPurchase->get(array('sid' => $sid, 'app_id' => $this->app_id));
+ if (!$order) {
+ debug_log("[error] " . __FUNCTION__ . ":{$sid}_订单不存在", $this->log_file);
+ return array('code' => 0, 'msg' => '订单不存在');
+ }
+ if ($order['status'] > 1) {
+ debug_log("[error] " . __FUNCTION__ . ":{$sid}_订单已支付", $this->log_file);
+ return array('code' => 0, 'msg' => '订单已支付');
+ }
+ switch ($order['type']) {
+ case 1: //实物商品
+ break;
+ case 2: //虚拟物品
+ break;
+ case 3: //活动订单
+ $upd = array('status' => 2, 'status_detail' => 21, 'pay_time' => date('Y-m-d H:i:s'));
+ $pay_price && $upd['pay_price'] = $pay_price;
+ $res = $this->mdOrderPurchase->update($upd, array('id' => $order['id']));
+ if ($res) {
+ //博饼加购车金
+ $appConfig = $this->mdBobingUser->appConfig();
+ $where = array('act_key' => $appConfig['act_key'], 'app_id' => $appConfig['app_id'], 'uid' => $order['app_uid']);
+ $this->mdBobingUser->update(array("buy_car_gold" => $appConfig['buy_car_gold']), $where);
+ return array('code' => 1, 'msg' => '操作成功');
+ } else {
+ return array('code' => 0, 'msg' => '更新失败');
+ }
+ break;
+ case 4: //定金
+ break;
+ case 5: //委托服务费
+ case 6: //首付或尾款
+ break;
+ default:
+ debug_log("[error] " . __FUNCTION__ . ":{$order['type']}_未知商品类型", $this->log_file);
+ return array('code' => 0, 'msg' => '未知商品类型');
+ }
+ }
+ }
+}
diff --git a/home/controllers/h5/Hongbao.php b/home/controllers/h5/Hongbao.php
new file mode 100644
index 00000000..893bef49
--- /dev/null
+++ b/home/controllers/h5/Hongbao.php
@@ -0,0 +1,130 @@
+load->model('bobing/bobing_logs_model', 'mdBobingLogs');
+ }
+
+ /**
+ * Notes:
+ * https://liche-dev.xiaoyu.com/h5/hongbao
+ * https://www.liche.cn/h5/hongbao
+ * Created on: 2021/8/26 11:19
+ * Created by: dengbw
+ */
+ public function index()
+ {
+ $params = $this->input->get();
+// $params['uid'] = 14;
+// $params['id'] = 828932;
+ $data = array('code' => 400, 'title' => '领取失败', 'msg' => '');
+ if (!$params['id'] || !$params['uid']) {
+ $data['msg'] = '参数错误!';
+ } else {
+ $this->uid = intval($params['uid']);
+ $id = intval($params['id']);
+ $re_l = $this->mdBobingLogs->get(array('id' => $id));
+ if (!$re_l || $re_l['status'] == 0 || $re_l['hong_bao'] <= 0) {
+ $data['msg'] = '条件不符合!';
+ }
+ if ($re_l['status'] == 2) {
+ $data['msg'] = '您已领取过了!';
+ }
+ if ($re_l['cf_uid'] != $params['uid']) {
+ $data['msg'] = 'uid错误!';
+ }
+ if (!$data['msg']) {
+ $url = http_host_com('home') . "/h5/hongbao?id={$id}&uid={$this->uid}";
+ $params['app_id'] = $re_l['app_id'];
+ $params['cf_uid'] = $re_l['cf_uid'];
+ $user = $this->set_auth($url, $params);
+ //小红榜发红包
+ if ($user['openid_kzh']) {
+ $sid = $this->create_order_no(350200);
+ //企业付款到零钱
+ //$re_l['hong_bao'] = 0.1;
+ $this->load->library('Transfers', array('app_id' => 3));//小红榜支付
+ $result = $this->transfers->sendMoney(array('partner_trade_no' => $sid, 'amount' => $re_l['hong_bao']
+ , 'openid' => $user['openid_kzh'], 'desc' => '狸车博饼红包', 're_user_name' => $user['nickname']));
+ $result['log_id'] = $id;
+ $result['log_uid'] = $this->uid;
+ debug_log("[info] " . __FUNCTION__ . "# result:" . json_encode($result, JSON_UNESCAPED_UNICODE), 'Hongbao.log');
+ if ($result['return_code'] == 'SUCCESS' && $result['result_code'] == 'SUCCESS') {//转帐成功
+ $this->mdBobingLogs->update(array('status' => 2), array('id' => $id));//设为已领取
+ $data['title'] = '领取成功';
+ $data['code'] = 200;
+ $data['msg'] = '¥' . $re_l['hong_bao'] . '元';
+ } else {
+ $data['msg'] = '转帐失败!';
+ }
+ }
+ }
+ }
+ $this->load->view('/h5/hongbao/index', $data);
+ }
+
+ /**
+ * Notes:授权获取openid
+ * Created on: 2021/8/26 14:26
+ * Created by: dengbw
+ * @param string $url
+ * @param array $params
+ * @return mixed
+ */
+ private function set_auth($url = '', $params = array())
+ {
+ if ("wx" == checkua()) {
+ $this->load->service("app/user_service", array("app_id" => $params['app_id']));
+ $re = $this->user_service->get(array('id' => $params['cf_uid']));
+ if ($re['openid_kzh']) {//已经授权获取openid了
+ return array('openid_kzh' => $re['openid_kzh'], 'nickname' => $re['nickname']);
+ }
+ $this->load->helper('url');
+ $config['appid'] = 'wx0d3d21aec5001a8e';//小红榜授权
+ $config['appSecret'] = '41f0721c343e00f284a60332fff991a3';
+ $code = $params['code'];
+ $auth = $params['auth'];//是否信息授权
+ $auth = 0;
+ $auth && $url .= "&auth={$auth}";
+ if ($code) {//授权码获取微信信息
+ $auth_url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid={$config['appid']}&secret={$config['appSecret']}&code={$code}&grant_type=authorization_code";
+ $res = file_get_contents($auth_url);
+ $ret = json_decode($res, true);
+ $openid = $ret['openid'];
+ $unionid = $ret['unionid'];
+ if ($openid) {
+ $this->user_service->update(array('openid_kzh' => $openid), array('id' => $params['cf_uid']));
+ return array('openid_kzh' => $openid, 'nickname' => $re['nickname']);
+ }
+ } elseif ($auth) {//信息授权获取用户微信昵称/头像
+ $redirect_uri = urlencode($url);
+ $auth_url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={$config['appid']}&redirect_uri={$redirect_uri}&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect";
+ redirect($auth_url);
+ } else {//静默授权获取用户openid
+ $redirect_uri = urlencode($url);
+ $auth_url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={$config['appid']}&redirect_uri={$redirect_uri}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect";
+ redirect($auth_url);
+ }
+ }
+ }
+
+ private function create_order_no($city_id = 350200, $source = '', $pay_type = 1, $order_type = 1)
+ {
+ $source_id = sprintf("%02d", 0);
+ return $city_id . $source_id . $pay_type . $order_type . date('Ymd') . sprintf("%06d", rand(1, 999999));
+ }
+
+
+ private function show_json($code, $msg)
+ {
+ $data['code'] = $code;
+ $data['msg'] = $msg;
+ die(json_encode($data, JSON_UNESCAPED_UNICODE));
+ }
+}
diff --git a/api/libraries/Transfers.php b/home/libraries/Transfers.php
similarity index 92%
rename from api/libraries/Transfers.php
rename to home/libraries/Transfers.php
index b1fd561d..b5269e5f 100644
--- a/api/libraries/Transfers.php
+++ b/home/libraries/Transfers.php
@@ -12,21 +12,25 @@ class Transfers
public function __construct($param = array())
{
- $this->app_id = $param['app_id'] ? $param['app_id'] : 3; //默认飞鱼
+ $this->app_id = $param['app_id'] ? $param['app_id'] : 1; //默认狸车
switch ($this->app_id) {
- case 3://飞鱼
+ case 1://狸车
+ $this->wx_config_file = 'liche_WxPay.Config.php';
+ break;
+ case 3://小红榜
$this->wx_config_file = 'fy_WxPay.Config.php';
break;
- case 14://欧菲帮我美
- $this->wx_config_file = 'ofei_WxPay.Config.php';
- break;
- case 15://星盟卡
- $this->wx_config_file = 'xmcard_WxPay.Config.php';
- break;
default:
}
}
+ public function wxPayConfig()
+ {
+ require_once APPPATH . "../home/third_party/WXconfig/" . $this->wx_config_file;
+ $config = new WxPayConfig();
+ return $config;
+ }
+
/**
* Notes:企业付款到零钱
* 接口介绍 https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=14_2
@@ -37,7 +41,7 @@ class Transfers
*/
public function sendMoney($param = array())
{
- require_once APPPATH . "../api/third_party/WXconfig/" . $this->wx_config_file;
+ require_once APPPATH . "../home/third_party/WXconfig/" . $this->wx_config_file;
$config = new WxPayConfig();
$partner_trade_no = $param['partner_trade_no'] ? $param['partner_trade_no']
: date('YmdHis') . rand(1000, 9999);//商户订单号
diff --git a/home/third_party/WXconfig/fy_WxPay.Config.php b/home/third_party/WXconfig/fy_WxPay.Config.php
new file mode 100644
index 00000000..9d7d41f5
--- /dev/null
+++ b/home/third_party/WXconfig/fy_WxPay.Config.php
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+ 领取红包
+
+
+
+
+
+
+
= $title ?>
+
= $msg ?>
+
+ if ($msg == 200) { ?>
+
+

+
+ } ?>
+
+
+
\ No newline at end of file
diff --git a/www/home/84SW5JJLgK.txt b/www/home/84SW5JJLgK.txt
new file mode 100644
index 00000000..1b7ac78e
--- /dev/null
+++ b/www/home/84SW5JJLgK.txt
@@ -0,0 +1 @@
+3988ab96f79da9ea105e464c123ac799
\ No newline at end of file
diff --git a/www/home/MP_verify_L9jPfjssZTbUBkyB.txt b/www/home/MP_verify_L9jPfjssZTbUBkyB.txt
new file mode 100644
index 00000000..5047c677
--- /dev/null
+++ b/www/home/MP_verify_L9jPfjssZTbUBkyB.txt
@@ -0,0 +1 @@
+L9jPfjssZTbUBkyB
\ No newline at end of file
diff --git a/www/home/css/h5/hongbao/red.css b/www/home/css/h5/hongbao/red.css
new file mode 100644
index 00000000..4cb83415
--- /dev/null
+++ b/www/home/css/h5/hongbao/red.css
@@ -0,0 +1 @@
+@charset "UTF-8";/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */html{line-height:1.15;-webkit-text-size-adjust:100%}body{margin:0}main{display:block}h1{font-size:2em;margin:.67em 0}hr{box-sizing:content-box;height:0;overflow:visible}pre{font-family:monospace,monospace;font-size:1em}a{background-color:transparent}abbr[title]{border-bottom:none;text-decoration:underline;-webkit-text-decoration:underline dotted;text-decoration:underline dotted}b,strong{font-weight:bolder}code,kbd,samp{font-family:monospace,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}img{border-style:none}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;line-height:1.15;margin:0}button,input{overflow:visible}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{border-style:none;padding:0}[type=button]:-moz-focusring,[type=reset]:-moz-focusring,[type=submit]:-moz-focusring,button:-moz-focusring{outline:1px dotted ButtonText}fieldset{padding:.35em .75em .625em}legend{box-sizing:border-box;color:inherit;display:table;max-width:100%;padding:0;white-space:normal}progress{vertical-align:baseline}textarea{overflow:auto}[type=checkbox],[type=radio]{box-sizing:border-box;padding:0}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-.267vw}[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}details{display:block}summary{display:list-item}template{display:none}[hidden]{display:none}.bds-1-ccc{border:#ccc 1px solid}.bts-1-ccc{border-top:#ccc 1px solid}.bls-1-ccc{border-left:#ccc 1px solid}.brs-1-ccc{border-right:#ccc 1px solid}.bbs-1-ccc{border-bottom:#ccc 1px solid}.last-b-none:last-child{border-bottom:none}.inner10{padding:1.333vw}.inner20{padding:2.667vw}.inner30{padding:4vw}.inner40{padding:5.333vw}.ulib-r0{border-radius:0!important}.ulib-r5{border-radius:.667vw}.ulib-r10{border-radius:1.333vw}.ulib-r20{border-radius:2.667vw}.ulib-r750{border-radius:100vw}.ml0{margin-left:0}.mt0{margin-top:0}.mr0{margin-right:0}.mb0{margin-bottom:0}.pl0{padding-left:0}.pt0{padding-top:0}.pr0{padding-right:0}.pb0{padding-bottom:0}.ml5{margin-left:.667vw}.mt5{margin-top:.667vw}.mr5{margin-right:.667vw}.mb5{margin-bottom:.667vw}.pl5{padding-left:.667vw}.pt5{padding-top:.667vw}.pr5{padding-right:.667vw}.pb5{padding-bottom:.667vw}.ml10{margin-left:1.333vw}.mt10{margin-top:1.333vw}.mr10{margin-right:1.333vw}.mb10{margin-bottom:1.333vw}.pl10{padding-left:1.333vw}.pt10{padding-top:1.333vw}.pr10{padding-right:1.333vw}.pb10{padding-bottom:1.333vw}.ml15{margin-left:2vw}.mt15{margin-top:2vw}.mr15{margin-right:2vw}.mb15{margin-bottom:2vw}.pl15{padding-left:2vw}.pt15{padding-top:2vw}.pr15{padding-right:2vw}.pb15{padding-bottom:2vw}.ml20{margin-left:2.667vw}.mt20{margin-top:2.667vw}.mr20{margin-right:2.667vw}.mb20{margin-bottom:2.667vw}.pl20{padding-left:2.667vw}.pt20{padding-top:2.667vw}.pr20{padding-right:2.667vw}.pb20{padding-bottom:2.667vw}.ml25{margin-left:3.333vw}.mt25{margin-top:3.333vw}.mr25{margin-right:3.333vw}.mb25{margin-bottom:3.333vw}.pl25{padding-left:3.333vw}.pt25{padding-top:3.333vw}.pr25{padding-right:3.333vw}.pb25{padding-bottom:3.333vw}.ml30{margin-left:4vw}.mt30{margin-top:4vw}.mr30{margin-right:4vw}.mb30{margin-bottom:4vw}.pl30{padding-left:4vw}.pt30{padding-top:4vw}.pr30{padding-right:4vw}.pb30{padding-bottom:4vw}.ml35{margin-left:4.667vw}.mt35{margin-top:4.667vw}.mr35{margin-right:4.667vw}.mb35{margin-bottom:4.667vw}.pl35{padding-left:4.667vw}.pt35{padding-top:4.667vw}.pr35{padding-right:4.667vw}.pb35{padding-bottom:4.667vw}.ml40{margin-left:5.333vw}.mt40{margin-top:5.333vw}.mr40{margin-right:5.333vw}.mb40{margin-bottom:5.333vw}.pl40{padding-left:5.333vw}.pt40{padding-top:5.333vw}.pr40{padding-right:5.333vw}.pb40{padding-bottom:5.333vw}.ml45{margin-left:6vw}.mt45{margin-top:6vw}.mr45{margin-right:6vw}.mb45{margin-bottom:6vw}.pl45{padding-left:6vw}.pt45{padding-top:6vw}.pr45{padding-right:6vw}.pb45{padding-bottom:6vw}.ml50{margin-left:6.667vw}.mt50{margin-top:6.667vw}.mr50{margin-right:6.667vw}.mb50{margin-bottom:6.667vw}.pl50{padding-left:6.667vw}.pt50{padding-top:6.667vw}.pr50{padding-right:6.667vw}.pb50{padding-bottom:6.667vw}.ml55{margin-left:7.333vw}.mt55{margin-top:7.333vw}.mr55{margin-right:7.333vw}.mb55{margin-bottom:7.333vw}.pl55{padding-left:7.333vw}.pt55{padding-top:7.333vw}.pr55{padding-right:7.333vw}.pb55{padding-bottom:7.333vw}.ml60{margin-left:8vw}.mt60{margin-top:8vw}.mr60{margin-right:8vw}.mb60{margin-bottom:8vw}.pl60{padding-left:8vw}.pt60{padding-top:8vw}.pr60{padding-right:8vw}.pb60{padding-bottom:8vw}.pl130{padding-left:17.333vw}.pt130{padding-top:17.333vw}.pr130{padding-right:17.333vw}.pb130{padding-bottom:17.333vw}.pl220{padding-left:29.333vw}.pt220{padding-top:29.333vw}.pr220{padding-right:29.333vw}.pb220{padding-bottom:29.333vw}.btn{display:inline-block;font-size:2vw;text-align:center;border:none;vertical-align:middle;cursor:pointer;-webkit-transition:all .15s ease 0s;transition:all .15s ease 0s}.btn:active{box-shadow:inset 0 .4vw .667vw rgba(0,0,0,.125)}.btn[disabled]{background-color:#aaa;border:.02667rem solid transparent;color:#777}.bg-fa{background-color:#fafafa}.bg-f5{background-color:#f5f5f5}.bg-f7{background-color:#f7f7f7}.color-333{color:#333}.bg-333{background-color:#333}.color-666{color:#666}.bg-666{background-color:#666}.color-888{color:#888}.bg-888{background-color:#888}.color-999{color:#999}.bg-999{background-color:#999}.color-bbb{color:#bbb}.bg-bbb{background-color:#bbb}.color-ccc{color:#ccc}.bg-ccc{background-color:#ccc}.color-ddd{color:#ddd}.bg-ddd{background-color:#ddd}.color-fff{color:#fff}.bg-fff{background-color:#fff}.color-fe8c16{color:#fe8c16}.bg-fe8c16{background-color:#fe8c16}.fn-clear:after,.fn-clear:before{content:"";display:table}.fn-clear:after{clear:both}.fn-clear{zoom:1}.fn-fl{float:left}.fn-fr{float:right}.fn-clear:after,.fn-clear:before{content:"";display:table}.fn-clear:after{clear:both}.fn-clear{zoom:1}.fn-fl{float:left}.fn-fr{float:right}.fn-flex{display:-webkit-box;display:flex;-webkit-box-orient:horizontal;-webkit-box-direction:normal;flex-flow:row;-webkit-box-align:stretch;align-items:stretch}.fn-flex-center{-webkit-box-align:center;align-items:center}.fn-flex-item{display:block;-webkit-box-flex:1;flex:1}.fn-flex-item[flexsize="2"]{-webkit-box-flex:2;flex:2}.fn-flex-item[flexsize="3"]{-webkit-box-flex:3;flex:3}.fn-flex-item[flexsize="4"]{-webkit-box-flex:4;flex:4}.fn-flex-item[flexsize="5"]{-webkit-box-flex:5;flex:5}.fn-flex-item[flexsize="6"]{-webkit-box-flex:6;flex:6}.fn-flex-item[flexsize="7"]{-webkit-box-flex:7;flex:7}.fn-flex-item[flexsize="8"]{-webkit-box-flex:8;flex:8}.fn-flex-item[flexsize="9"]{-webkit-box-flex:9;flex:9}.fn-flex-wrap{flex-wrap:wrap}.justify-between{-webkit-box-pack:justify;justify-content:space-between}.justify-center{-webkit-box-pack:center;justify-content:center}.block{display:block}.inline-block{display:inline-block}.fn-hide{display:none!important}.overflowhidden{overflow:hidden}.scroll-x{overflow-x:auto}.scroll-y{overflow-y:auto}.relative{position:relative}.absolute{position:absolute}.fixed{position:fixed}.top-0{top:0}.left-0{left:0}.bottom-0{bottom:0}.right-0{right:0}.z-index-0{z-index:0}.z-index-1{z-index:1}.z-index-2{z-index:2}.z-index-3{z-index:3}.z-index-4{z-index:4}.box-center-middle{top:50%;left:50%;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%)}.box-middle{top:50%;-webkit-transform:translate(0,-50%);transform:translate(0,-50%)}.box-center{left:50%;-webkit-transform:translate(-50%,0);transform:translate(-50%,0)}.box-border{box-sizing:border-box}.wp20{width:20%;box-sizing:border-box}.wp25{width:25%;box-sizing:border-box}.wp33{width:33%;box-sizing:border-box}.wp40{width:40%;box-sizing:border-box}.wp50{width:50%;box-sizing:border-box}.wp60{width:60%!important;box-sizing:border-box}.wp65{width:65%!important;box-sizing:border-box}.wp70{width:70%!important;box-sizing:border-box}.wp80{width:80%!important;box-sizing:border-box}.wp90{width:90%;box-sizing:border-box}.wp100{width:100%;box-sizing:border-box}.transition-all{-webkit-transition:all ease .2s;transition:all ease .2s}.op20{opacity:.2}.text-nowrap{width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.text-underline{text-decoration:underline}.text-through{text-decoration:line-through}.text-middle{vertical-align:middle}.text-lighter{font-weight:400}.text-bold{font-weight:600}.text-break{word-break:break-all;word-wrap:break-word}.space-nowrap{white-space:nowrap}.space-normal{white-space:normal}.line-clamp-2{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden}.line-clamp-3{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:3;overflow:hidden}.font-24{font-size:3.2vw}.font-26{font-size:3.467vw}.font-28{font-size:3.733vw}.font-30{font-size:4vw}.font-32{font-size:4.267vw}.font-34{font-size:4.533vw}.font-36{font-size:4.8vw}.font-38{font-size:5.067vw}.font-40{font-size:5.333vw}.font-42{font-size:5.6vw}.font-44{font-size:5.867vw}.font-46{font-size:6.133vw}.font-48{font-size:6.4vw}.font-50{font-size:6.667vw}.font-52{font-size:6.933vw}.font-54{font-size:7.2vw}.font-56{font-size:7.467vw}.font-58{font-size:7.733vw}.font-60{font-size:8vw}.font-80{font-size:10.667vw}.font-100{font-size:13.333vw}*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}a,abbr,acronym,address,applet,article,aside,audio,b,big,blockquote,body,canvas,caption,center,cite,code,dd,del,details,dfn,div,dl,dt,em,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,html,i,iframe,img,ins,kbd,label,legend,li,mark,menu,nav,object,ol,p,pre,q,s,samp,section,small,span,strike,strong,sub,summary,sup,table,tbody,td,tfoot,th,thead,time,tr,tt,u,ul,var,video{margin:0;padding:0}ol,ul{list-style:none}table{border-collapse:collapse;border-spacing:0}input:focus,select:focus,textarea:focus{outline:0}em{font-style:normal}input[type=number]::-webkit-inner-spin-button,input[type=number]::-webkit-outer-spin-button{-webkit-appearance:none}input[type=search]{-webkit-appearance:textfield;box-sizing:content-box}input[type=search]::-webkit-search-cancel-button,input[type=search]::-webkit-search-decoration{-webkit-appearance:none}input,textarea{-webkit-appearance:none;-moz-appearance:none;appearance:none}a{text-decoration:none;color:#333}body,button,select,textarea{font-family:'\5FAE\8F6F\96C5\9ED1',Tahoma,Arial,Helvetica,sans-serif}html{width:100%;background-color:#fff}body{background-color:#f3f3f3}img{max-width:100%}body,html{height:100%}.img-top-cover{background-repeat:no-repeat;background-position:center top;background-size:100% auto}.img-center-cover{background-repeat:no-repeat;background-position:center center;background-size:100% auto}.img-middle-cover{background-repeat:no-repeat;background-position:center center;background-size:auto 100%}.img-fill-cover{background-repeat:no-repeat;background-position:center center;background-size:100% 100%}.img-center-middle-100{position:absolute;top:50%;left:50%;max-width:100%;max-height:100%;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%)}.red{height:100%;min-height:146.667vw;background-color:#fff3e8}.wp100{width:100%;box-sizing:border-box}.absolute{position:absolute}.top-320{top:49.333vw}.left-0{left:0}.right-0{right:0}.font-60{font-size:8vw}.font-80{font-size:10.667vw}.pt20{padding-top:2.667vw}.pt120{padding-top:16vw}.pl40{padding-left:5.333vw}.text-bold{font-weight:600}.text-center{text-align:center}.color-fffcf4{color:#fffcf4}.msg{position:fixed;left:0;top:0;width:100%;height:100%;z-index:1000}.msg .msgBg{position:fixed;left:0;top:0;width:100%;height:100%;background-color:rgba(0,0,0,.6)}.msg .msgMain{position:fixed;left:50%;top:50%;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);z-index:9999}.msg .msgMain i.close{position:absolute;left:50%;-webkit-transform:translateX(-50%);transform:translateX(-50%);bottom:-8.267vw;width:6.667vw;height:6.667vw;border-radius:100%;border:.4vw solid #fff;cursor:pointer}.msg .msgMain i.close::after,.msg .msgMain i.close::before{position:absolute;left:50%;top:50%;content:'';width:3.333vw;height:.267vw;background-color:#fff}.msg .msgMain i.close::before{-webkit-transform:translate(-50%,-50%) rotate(-45deg);transform:translate(-50%,-50%) rotate(-45deg)}.msg .msgMain i.close::after{-webkit-transform:translate(-50%,-50%) rotate(45deg);transform:translate(-50%,-50%) rotate(45deg)}.msg .msgMain .content{width:80vw;background-color:#fff;border-radius:1.333vw;padding:5.333vw}.msg .msgMain .content .word h2{font-size:4.8vw;padding-bottom:2vw}.msg .msgMain .content .word .desc{max-height:65vh;overflow-y:auto}.msg .msgMain .content .word p{margin:0 auto;color:#333;line-height:1.7}.msg .msgMain .content .opt{text-align:center;padding-top:2.667vw}.msg .msgMain .content .opt .btn{width:80%;height:9.333vw;line-height:9.333vw;display:inline-block;background-color:#fffcf4;color:#fff;border-radius:133.333vw;font-size:3.733vw}.msg.msg-sign .msgMain .content{width:73.333vw;padding:0}.msg.msg-sign .msgMain .content input[type=text]{width:50.667vw;height:5.333vw;text-indent:.5em}.msg.msg-sign .msgMain .content button{width:25.333vw;height:7.333vw}.msg.msg-imgbox .msgMain .content{width:133.333vw}.msg.msg-imgbox .msgMain .main{height:66.667vw;background-color:#f0f0f0}.msg.msg-imgbox .msgMain .main img{max-width:100%;max-height:100%}
\ No newline at end of file
diff --git a/www/home/img/h5/hongbao/bg.jpg b/www/home/img/h5/hongbao/bg.jpg
new file mode 100644
index 00000000..ae57a511
Binary files /dev/null and b/www/home/img/h5/hongbao/bg.jpg differ
diff --git a/www/home/img/h5/hongbao/title.png b/www/home/img/h5/hongbao/title.png
new file mode 100644
index 00000000..a03fdbcb
Binary files /dev/null and b/www/home/img/h5/hongbao/title.png differ