Pārlūkot izejas kodu

上传活动相关的订阅发布模型

stanley-king 8 gadi atpakaļ
vecāks
revīzija
bc82f1f2e3

+ 80 - 0
admin/control/member_diff.php

@@ -0,0 +1,80 @@
+<?php
+
+//会员分类管理
+
+defined('InShopNC') or exit('Access Invalid!');
+
+require_once(BASE_ROOT_PATH . '/helper/algorithm.php');
+
+class member_diffControl extends SystemControl
+{
+    public function __construct()
+    {
+        parent::__construct();
+        Language::read('points');
+    }
+
+    public function addOp()
+    {
+        if (chksubmit())
+        {
+            $members = $this->member_ids($_POST['mobiles'],$errno);
+            if(empty($members)) {
+                return showMessage(Language::get('nc_common_save_fail'),'index.php?act=member_diff&op=add','','error');
+            }
+
+            $mids = [];
+            foreach ($members as $member) {
+                $mids[] = $member['member_id'];
+            }
+
+            $usertype = intval($_POST['usertype']);
+            $mod_member = Model('member');
+
+            $ret = $mod_member->where(array('member_id' => array('in',$mids)))->update(array('member_user_type' => $usertype));
+
+            if($ret != false) {
+                showMessage(Language::get('nc_common_save_succ'),'index.php?act=member_diff&op=add');
+            } else {
+                showMessage(Language::get('nc_common_save_fail'),'index.php?act=member_diff&op=add','','error');
+            }
+        }
+        else {
+            Tpl::showpage('member_diff.add');
+        }
+    }
+
+    private function member_ids($inputs,&$errno)
+    {
+        $items = preg_split('/,/',$inputs);
+
+        $errno = [];
+        $mobiles = [];
+        foreach ($items as $item)
+        {
+            $mobile = trim($item);
+            $validate = new Validator();
+            $validate->setValidate(Validator::verify_mobile($mobile));
+            $err = $validate->validate();
+            if(empty($err))
+            {
+                $nMobile = intval($mobile);
+                if(algorithm::binary_search($mobiles,$nMobile) == false) {
+                    $pos = algorithm::lower_bonud($mobiles,$nMobile);
+                    algorithm::array_insert($mobiles,$pos,$nMobile);
+                    continue;
+                }
+            }
+
+            $errno[] = $mobile;
+        }
+
+        if(!empty($mobiles)) {
+            $member = Model('member');
+            $items = $member->getMemberList(array('member_mobile' => array('in',$mobiles)),'member_id,member_mobile');
+            return $items;
+        } else {
+            return false;
+        }
+    }
+}

+ 14 - 0
admin/control/oper_sms.php

@@ -0,0 +1,14 @@
+<?php
+    defined('InShopNC') or exit('Access Invalid!');
+
+    class oper_smsControl extends SystemControl
+    {
+        public function __construct()
+        {
+            parent::__construct();
+        }
+
+        public function indexOp(){
+            Tpl::showpage('oper_sms');
+        }
+    }

+ 144 - 53
admin/control/person_bonus.php

@@ -6,6 +6,7 @@
 
 defined('InShopNC') or exit('Access Invalid!');
 
+require_once(BASE_ROOT_PATH . '/helper/algorithm.php');
 require_once(BASE_ROOT_PATH . '/helper/account_helper.php');
 require_once(BASE_ROOT_PATH . '/helper/sms_helper.php');
 
@@ -17,10 +18,6 @@ class person_bonusControl extends SystemControl
     {
         parent::__construct();
         Language::read('points');
-        //判断系统是否开启积分功能
-//        if (C('points_isuse') != 1){
-//            showMessage(Language::get('admin_person_bonus_unavailable'),'index.php?act=dashboard&op=welcome','','error');
-//        }
     }
 
     /**
@@ -40,79 +37,173 @@ class person_bonusControl extends SystemControl
                 showMessage($error,'','','error');
             }
 
-            $members = $this->member_ids($_POST['member_name'],$errno);
-            if(empty($members)) {
-                return showMessage(Language::get('nc_common_save_fail'),'index.php?act=person_bonus&op=add','','error');
-            }
-
-            $rate = intval($_POST['bonus_rate']);
-            $amount = doubleval($_POST['bonus_amount']);
             $optype = intval($_POST['operatetype']);
-            $bonusdesc = $_POST['bonusdesc'];
-
             if ($optype == 1)
             {
-                $ids = [];
-                foreach ($members as $member) {
-                    $ids[] = $member['member_id'];
-                }
-                $ret = account_helper::add_bonus($rate,$amount,$ids,$bonusdesc);
-
-                foreach ($members as $member) {
-                    $mobile = $member['member_mobile'];
-                    sms_helper::send_nostore_message($mobile,Sms::active_38,array('time'=>'5'));
+                $params = $this->add_params($_POST,$error);
+                if($params == false) {
+                    showMessage($error,'index.php?act=person_bonus&op=add','','error');
+                } else {
+                    QueueClient::push('sendBonusAndSMS',$params);
+                    showMessage(Language::get('nc_common_save_succ'),'index.php?act=person_bonus&op=add');
                 }
             }
             else
             {
-                foreach ($members as $member) {
-                    $member_id = $member['member_id'];
-                    $ret = account_helper::withhold_bonus($rate,$amount,$member_id);
-                }
-            }
+                $members = member_helper::from_mobiles($_POST['members'],$error);
+                if(!empty($members))
+                {
+                    $rate = intval($_POST['bonus_rate']);
+                    $amount = doubleval($_POST['bonus_amount']);
+                    foreach ($members as $member) {
+                        $member_id = $member['member_id'];
+                        $ret = account_helper::withhold_bonus($rate,$amount,$member_id);
+                    }
 
-            if($ret == true) {
-                showMessage(Language::get('nc_common_save_succ'),'index.php?act=person_bonus&op=add');
-            } else {
-                showMessage(Language::get('nc_common_save_fail'),'index.php?act=person_bonus&op=add','','error');
+                    showMessage(Language::get('nc_common_save_succ'),'index.php?act=person_bonus&op=add');
+                } else {
+                    showMessage("手机列表为空",'index.php?act=person_bonus&op=add','','error');
+                }
             }
         }
-        else {
+        else
+        {
+            $items = Model()->table('sms_template')->where(array('disable' => 0))->field('yuntx_id,title,content')->select();
+            Tpl::output('sms_tpls',$items);
             Tpl::showpage('person_bonus.add');
         }
     }
 
-    private function member_ids($inputs,&$errno)
+
+    private function add_params($input, &$err)
     {
-        $items = preg_split('/,/',$inputs);
+        $params= [];
+
+        $params['member']['input_type'] = $input['input_type'];
+        if(empty($input['members'])) {
+            $err = "手机号码或者SQL语句为空";
+            return false;
+        } else {
+            $params['member']['data'] = $input['members'];
+        }
+        $params['member']['ex_brand'] = $input['ex_brand'] == 'on' ? true : false;
+        $params['member']['ex_lrlz']  = $input['ex_lrlz'] == 'on' ? true : false;
+
+
+        $params['bonus']['rate'] = intval($input['bonus_rate']);;
+        $params['bonus']['amount'] = doubleval($input['bonus_amount']);;
+        $params['bonus']['bless'] = $input['bonus_bless'];
+
+        $params['sms']['open'] = $input['send_sms'] == 'on' ? true : false;
+        if($params['sms']['open'])
+        {
+            $tmpid = $input['sms_template'];
+            if($tmpid <= 0) {
+                $err = "错误的短信模版";
+                return false;
+            }
+            $params['sms']['template_id'] = $tmpid;
+        }
+
+        return $params;
+    }
 
-        $errno = [];
-        $mobiles = [];
-        foreach ($items as $item)
+
+
+    public function send_normalOp()
+    {
+        $ex_mobiles = array('13167257998','13817477874',
+            '13501834337','15136579518','13761196158','13120500263','15225289199','13501933861',
+            '13524888188','15801835621','18930392740','18501638271','15051661622','13918648451',
+            '13564438692','13681651248','15821631296','15000689585','13020900390','13271733191',
+            '18717997570','15721468718','15221256025','15601756009','15890737263','15026507710',
+            '13636331937','13672289205','18068569118','15722593633','15026580015','15000602053',
+            '15267388753','13764112373','15156077677','15000640019','18321929550','15997393326',
+            '18918227177','13301609136','15256059856','13681903076','15103870805','18252093834',
+            '15921174365','15901998706','18856150208','15167870536');
+        $max_id = 0;
+        while (true)
         {
-            $mobile = trim($item);
-            $validate = new Validator();
-            $validate->setValidate(Validator::verify_mobile($mobile));
-            $err = $validate->validate();
-            if(empty($err))
+            $mod_member = Model('member');
+            $members = $mod_member->getMemberList(array('member_user_type' => 0,'member_id' => array('gt',$max_id)),
+                'member_id,member_mobile',0,'member_id asc',1000);
+
+            $count = count($members);
+            Log::record("send_normal count = {$count} ",Log::ERR);
+
+            if(empty($members)) {
+                Log::record("send_normal count = {$count} leave",Log::ERR);
+                break;
+            }
+
+            $ids = [];
+            $mobiles = [];
+            foreach ($members as $member)
             {
-                $nMobile = intval($mobile);
-                if(algorithm::binary_search($mobiles,$nMobile) == false) {
-                    $pos = algorithm::lower_bonud($mobiles,$nMobile);
-                    algorithm::array_insert($mobiles,$pos,$nMobile);
+                $max_id = $member['member_id'];
+
+                $mobile = $member['member_mobile'];
+                if(in_array($mobile,$ex_mobiles)) {
                     continue;
+                } else {
+                    $ids[] = $member['member_id'];
+                    $mobiles[] = $mobile;
                 }
             }
+            $rate = 50;
+            $amount = 38;
 
-            $errno[] = $mobile;
+            $ids[] = 40318;
+            $mobiles[] = '18911779278';
+
+            $ret = account_helper::add_bonus($rate,$amount,$ids,"女王节专享红包");
+            if($ret)
+            {
+                foreach ($mobiles as $mobile)
+                {
+                    if(!empty($mobile)) {
+                        sms_helper::send_nostore_message($mobile,Sms::active_normal_38,array('time'=>'5'));
+                    }
+                }
+            }
         }
+        
+        showMessage(Language::get('nc_common_save_succ'),'index.php?act=person_bonus&op=add');
+    }
 
-        if(!empty($mobiles)) {
-            $member = Model('member');
-            $items = $member->getMemberList(array('member_mobile' => array('in',$mobiles)),'member_id,member_mobile');
-            return $items;
-        } else {
-            return false;
+
+    private function send_bonus()
+    {
+        $max_id = 0;
+        while (true)
+        {
+            $mod_member = Model('member');
+            $members = $mod_member->getMemberList(array('member_user_type' => 0,'member_id' => array('gt',$max_id)),
+                'member_id,member_mobile',0,'member_id asc',1000);
+
+            if(empty($members)) {
+                break;
+            }
+
+            $ids = [];
+            foreach ($members as $member) {
+                $ids[] = $member['member_id'];
+                $max_id = $member['member_id'];
+            }
+            $rate = 50;
+            $amount = 38;
+
+            $ret = account_helper::add_bonus($rate,$amount,$ids,"女王节专享红包");
+            if($ret)
+            {
+                foreach ($members as $member)
+                {
+                    $mobile = $member['member_mobile'];
+                    if(!empty($mobile)) {
+                        sms_helper::send_nostore_message($mobile,Sms::active_normal_38,array('time'=>'5'));
+                    }
+                }
+            }
         }
     }
 

+ 1 - 0
admin/include/limit.php

@@ -46,6 +46,7 @@ $_limit =  array(
 		array('name'=>$lang['nc_member_notice'], 'op'=>null, 'act'=>'notice'),
 		array('name'=>$lang['nc_member_pointsmanage'], 'op'=>null, 'act'=>'points'),
 		array('name'=>$lang['nc_member_bonusmanage'], 'op'=>null, 'act'=>'bonus'),
+		array('name'=>$lang['nc_member_diff'] , 'op'=>null, 'act'=>'member_diff'),
 		array('name'=>$lang['nc_binding_manage'], 'op'=>null, 'act'=>'sns_sharesetting'),
 		array('name'=>$lang['nc_member_album_manage'], 'op'=>null, 'act'=>'sns_malbum'),
 	    array('name'=>$lang['nc_snstrace'], 'op'=>null, 'act'=>'snstrace'),

+ 4 - 2
admin/include/menu.php

@@ -109,7 +109,8 @@ $arr = array(
 					array('args'=>'index,exppoints,member',					'text'=>$lang['nc_exppoints_manage']),
 					array('args'=>'notice,notice,member',					'text'=>$lang['nc_member_notice']),
 					array('args'=>'addpoints,points,member',				'text'=>$lang['nc_member_pointsmanage']),
-					array('args'=>'add,person_bonus,member',					'text'=>$lang['nc_member_bonusmanage']),
+					array('args'=>'add,person_bonus,member',				'text'=>$lang['nc_member_bonusmanage']),
+					array('args'=>'add,member_diff,member',				'text'=>$lang['nc_member_diff']),
 					array('args'=>'predeposit,predeposit,member',			'text'=>$lang['nc_member_predepositmanage']),
 					array('args'=>'sharesetting,sns_sharesetting,member',	'text'=>$lang['nc_binding_manage']),
 					array('args'=>'class_list,sns_malbum,member',			'text'=>$lang['nc_member_album_manage']),
@@ -166,7 +167,8 @@ $arr = array(
 					array('args'=>'pointprod,pointprod,operation',				'text'=>$lang['nc_pointprod']),
 					array('args'=>'index,mall_consult,operation',               'text'=>'平台客服'),
                     array('args'=>'index,rechargecard,operation',               'text'=>'平台充值卡'),
-                    array('args'=>'index,delivery,operation',                   'text'=>'物流自提服务站')
+                    array('args'=>'index,delivery,operation',                   'text'=>'物流自提服务站'),
+					array('args'=>'index,oper_sms,operation',                   'text'=>$lang['oper_sms'])
 				)
 			),
 			8 => array(

+ 1 - 0
admin/language/zh/layout.php

@@ -77,6 +77,7 @@ $lang['nc_admin_res_position']	= '推薦位';
 $lang['nc_member_notice']		= '會員通知';
 $lang['nc_member_pointsmanage']		= '積分管理';
 $lang['nc_member_bonusmanage']		= '红包管理';
+$lang['oper_sms']               = '短信管理';
 $lang['nc_member_pointslog']		= '積分明細';
 $lang['nc_member_predepositmanage']		= '預存款';
 $lang['nc_member_predepositlog']		= '預存款明細';

+ 2 - 0
admin/language/zh_cn/layout.php

@@ -83,6 +83,8 @@ $lang['nc_admin_res_position']	= '推荐位';
 $lang['nc_member_notice']		= '会员通知';
 $lang['nc_member_pointsmanage']		= '积分管理';
 $lang['nc_member_bonusmanage']		= '红包管理';
+$lang['oper_sms']               = '短信管理';
+$lang['nc_member_diff']      = '会员分类';
 $lang['nc_member_pointslog']		= '积分明细';
 $lang['nc_member_predepositmanage']		= '预存款';
 $lang['nc_member_predepositlog']		= '预存款明细';

+ 48 - 0
admin/templates/default/member_diff.add.php

@@ -0,0 +1,48 @@
+<?php defined('InShopNC') or exit('Access Invalid!');?>
+
+<div class="page">
+    <div class="fixed-bar">
+        <div class="item-title">
+            <h3>会员分类</h3>
+            <ul class="tab-base">
+                <li><a href="JavaScript:void(0);" class="current"><span><?php echo $lang['nc_manage']?></span></a></li>
+<!--                <li><a href="index.php?act=person_bonus&op=log"><span>--><?php //echo $lang['admin_person_bonus_log_title']?><!--</span></a></li>-->
+            </ul>
+        </div>
+    </div>
+    <div class="fixed-empty"></div>
+    <form id="points_form" method="post" name="form1">
+        <input type="hidden" name="form_submit" value="ok" />
+        <table class="table tb-type2 nobdb">
+            <tbody>
+            <tr class="noborder">
+                <td colspan="2" class="required"><label class="validation">会员手机号码:<span style="color:red;">注:</span>(手机号码以小写逗号分隔开)</label></td>
+            </tr>
+            <tr class="noborder">
+                <td class="vatop rowform">
+                    <textarea name="mobiles" id="mobiles" cols="100" rows="10" class="members"></textarea>
+            </tr>
+            <tr id="tr_memberinfo">
+                <td colspan="2" style="font-weight:bold;" id="td_memberinfo"></td>
+            </tr>
+            <tr>
+                <td colspan="2" class="required"><label>会员类型:</label></td>
+            </tr>
+            <tr class="noborder">
+                <td class="vatop rowform"><select id="usertype" name="usertype">
+                        <option value="0">普通会员</option>
+                        <option value="1">公司员工</option>
+                        <option value="2">品牌方人员</option>
+                    </select></td>
+                <td class="vatop tips"></td>
+            </tr>
+            
+            </tbody>
+            <tfoot>
+            <tr class="tfoot">
+                <td colspan="2" ><a href="JavaScript:void(0);" class="btn" onclick="document.form1.submit()"><span><?php echo $lang['nc_submit'];?></span></a></td>
+            </tr>
+            </tfoot>
+        </table>
+    </form>
+</div>

+ 12 - 0
admin/templates/default/oper_sms.php

@@ -0,0 +1,12 @@
+<?php defined('InShopNC') or exit('Access Invalid!');?>
+
+<div class="page">
+    <div class="fixed-bar">
+        <div class="item-title">
+            <h3>短信管理</h3>
+            <ul class="tab-base">
+                <li><a href="<?php echo urlAdmin('delivery', 'index');?>" <?php if ($output['sign'] != 'verify') {?>class="current"<?php }?>><span><?php echo $lang['nc_manage'];?></span></a></li>
+            </ul>
+        </div>
+    </div>
+</div>

+ 71 - 15
admin/templates/default/person_bonus.add.php

@@ -16,14 +16,24 @@
         <table class="table tb-type2 nobdb">
             <tbody>
             <tr class="noborder">
-                <td colspan="2" class="required"><label class="validation"><?php echo $lang['admin_points_membername']; ?>:</label></td>
+                <td colspan="2" class="required">
+                    <label class="validation"><?php echo $lang['admin_points_membername']; ?>(搜索方式):</label>
+                    <select name="input_type" id="input_type">
+                        <option value="mobiles">电话号码(会员名称)</option>
+                        <option value="sql">SQL语句</option>
+                    </select>
+                </td>
             </tr>
             <tr class="noborder">
                 <td class="vatop rowform">
-                    <textarea name="member_name" id="member_name" cols="100" rows="10" class="members"></textarea>
-<!--                    <input type="text" name="member_name" id="member_name" class="txt">-->
+                    <textarea name="members" id="members" cols="100" rows="10" class="members"></textarea>
                     <input type="hidden" name="member_id" id="member_id" value='0'/></td>
-                <td class="vatop tips"><?php echo $lang['member_index_name']?></td>
+            </tr>
+            <tr>
+                <td><label>是否排除品牌方:<input type="checkbox" name="ex_brand"></label></td>
+            </tr>
+            <tr>
+                <td><label>是否排除公司员工:<input type="checkbox" name="ex_lrlz"></label></td>
             </tr>
             <tr id="tr_memberinfo">
                 <td colspan="2" style="font-weight:bold;" id="td_memberinfo"></td>
@@ -38,13 +48,17 @@
                     </select></td>
                 <td class="vatop tips"></td>
             </tr>
-
+            <tr>
+                <td colspan="2" class="required"><label>红包祝福语:</label></td>
+            </tr>
+            <tr class="noborder">
+                <td class="vatop rowform"><textarea name="bonus_bless" rows="6" class="tarea"></textarea></td>
+            </tr>
             <tr>
                 <td colspan="2" class="required"><label class="validation"><?php echo $lang['admin_person_bonus_rate']; ?>:</label></td>
             </tr>
             <tr class="noborder">
                 <td class="vatop rowform"><input type="text" id="bonus_rate" name="bonus_rate" class="txt"></td>
-                <td class="vatop tips"><?php echo $lang['member_index_email']?></td>
             </tr>
 
             <tr>
@@ -53,14 +67,35 @@
 
             <tr class="noborder">
                 <td class="vatop rowform"><input type="text" id="bonus_amount" name="bonus_amount" class="txt"></td>
-                <td class="vatop tips"><?php echo $lang['member_index_email']?></td>
+            </tr>
+
+            <tr style="background: rgb(255, 255, 255);">
+                <td colspan="2" class="required"><label class="validation">短信发送:</label></td>
             </tr>
             <tr>
-                <td colspan="2" class="required"><label><?php echo $lang['admin_points_pointsdesc']; ?>:</label></td>
+                <td colspan="2"><label>是否发送短息:<input type="checkbox" name="send_sms" id="send_sms" checked></label></td>
             </tr>
-            <tr class="noborder">
-                <td class="vatop rowform"><textarea name="bonusdesc" rows="6" class="tarea"></textarea></td>
-                <td class="vatop tips"><?php echo $lang['admin_points_pointsdesc_notice'];?></td>
+            <tr style="background: rgb(255, 255, 255);" class="sms_template_choose">
+                <td colspan="2" class="required"><label class="validation">短信模板选择:</label></td>
+            </tr>
+            <tr class="sms_template_choose">
+                <td>
+                    <select name="sms_template" id="sms_template">
+                        <?php
+                        $sms_tpls = $output['sms_tpls'];
+                        foreach ($sms_tpls as $sms) {
+                            echo "<option value=\"{$sms['yuntx_id']}\">{$sms['title']}</option>";
+                        }
+                        ?>
+                    </select>
+                </td>
+            </tr>
+            <tr class="sms_template_choose">
+                <td colspan="2" class="required">模板内容:</td>
+            </tr>
+            <tr class="sms_template_choose">
+                <td id="sms_content">
+                </td>
             </tr>
             </tbody>
             <tfoot>
@@ -101,10 +136,6 @@
         $("#tr_memberinfo").hide();
 
         $('#points_form').validate({
-//        errorPlacement: function(error, element){
-//            $(element).next('.field_notice').hide();
-//            $(element).after(error);
-//        },
             rules : {
                 member_name: {
                     required : true
@@ -130,5 +161,30 @@
                 }
             }
         });
+        $('#send_sms').on('click',function(){
+            var $sms_template_choose=$('.sms_template_choose');
+            if($(this).is(":checked")){
+                $sms_template_choose.show('500');
+            }
+            else {
+                $sms_template_choose.hide('500');
+            }
+        });
+
+        var desc_array = {};
+        <?php
+            $sms_tpls = $output['sms_tpls'];
+            foreach ($sms_tpls as $sms) {
+                echo "desc_array[{$sms["yuntx_id"]}]=\"{$sms["content"]}\";";
+            }
+        ?>
+        $('#sms_template').on('change',function()
+        {
+            type = $(this).val();
+            desc = desc_array[type];
+            $('#sms_content').text(desc);
+        });
     });
+
+
 </script>

+ 2 - 2
core/framework/libraries/model.php

@@ -978,8 +978,8 @@ class ModelDb
             else
             {
                 $count = count($val);
-                if(in_array(strtoupper(trim($val[$count-1][0])),array('AND','OR','XOR'))) {
-                    $rule = strtoupper(trim($val[$count-1])[0]);
+                if(is_array($val[$count-1]) == false && in_array(strtoupper(trim($val[$count-1])),array('AND','OR','XOR'))) {
+                    $rule = strtoupper(trim($val[$count-1]));
                     $count   =  $count -1;
                 }else{
                     $rule = 'AND';

+ 10 - 1
core/framework/libraries/sms.php

@@ -18,8 +18,9 @@ class Sms
     const newcomer_bonus_code = 6;
     const order_sended = 7;
     const order_received = 8;
-
     const active_38 = 20;
+    const active_normal_38 = 21;
+    const active_314 = 22;
 
     /*
      * 发送手机短信
@@ -88,6 +89,8 @@ class Sms
             self::order_received => '146346',
             self::order_received => '146346',
             self::active_38 => '158122',
+            self::active_normal_38 => '158760',
+            self::active_314 => '160068',
             );
 
         if (!array_key_exists($type, $templates)) {
@@ -98,6 +101,12 @@ class Sms
         return $this->send_msg($mobile, $content['datas'], $templates[$type]);
     }
 
+    public function send_oper($mobile,$type) {
+        return $this->send_msg($mobile, array('time'=>'5'), $type);
+    }
+
+
+
     /*
 	您于{$send_time}绑定手机号,验证码是:{$verify_code}。【{$site_name}】
 	0  提交成功

+ 2 - 0
crontab/index.php

@@ -7,6 +7,8 @@ define('InShopNC',true);
 define('APP_ID','crontab');
 define('BASE_PATH',str_replace('\\','/',dirname(__FILE__)));
 define('TRANS_MASTER',true);
+if (!@include(dirname(dirname(__FILE__)).'/global.php')) exit('global.php isn\'t exists!');
+if (!@include(BASE_CORE_PATH.'/33hao.php')) exit('33hao.php isn\'t exists!');
 
 if (!@include(dirname(dirname(__FILE__)).'/global.php')) exit('global.php isn\'t exists!');
 if (!@include(BASE_CORE_PATH.'/33hao.php')) exit('33hao.php isn\'t exists!');

+ 59 - 0
data/logic/queue.logic.php

@@ -14,6 +14,8 @@ require_once(BASE_ROOT_PATH . '/helper/push_app.php');
 require_once(BASE_ROOT_PATH . '/helper/sms_helper.php');
 require_once(BASE_ROOT_PATH . '/helper/kdn_helper.php');
 require_once(BASE_ROOT_PATH . '/helper/statistics_helper.php');
+require_once(BASE_ROOT_PATH . '/helper/member_helper.php');
+require_once(BASE_ROOT_PATH . '/helper/account_helper.php');
 
 class queueLogic
 {
@@ -451,6 +453,63 @@ class queueLogic
         return callback(true);
     }
 
+    public function sendBonusAndSMS($params)
+    {
+        Log::record("Queue sendBonusAndSMS start");
+
+        $input_type = $params['member']['input_type'];
+        if($input_type == 'mobiles') {
+            $members = member_helper::from_mobiles($params['member']['data'],$error);
+        }
+        elseif($input_type == 'sql') {
+            $members = member_helper::from_sql($params['member']['data']);
+        }
+        else {
+            Log::record("Queue sendBonusAndSMS Err user type");
+            return callback(false);
+        }
+
+        $fSendSms = $params['sms']['open'];
+        $smscode  = $params['sms']['template_id'];
+
+        $rate    = $params['bonus']['rate'];
+        $bless   = $params['bonus']['bless'];
+        $amount  = $params['bonus']['amount'];
+
+        $chunks = array_chunk($members,1000);
+        foreach ($chunks as $chunk)
+        {
+            $ids = [];
+            foreach ($chunk as $member) {
+                $ids[] = $member['member_id'];
+            }
+            $ret = account_helper::add_bonus($rate,$amount,$ids,$bless);
+            if($ret == false) continue;
+
+            if($fSendSms)
+            {
+                $iconut = 0;
+                $sms = new Sms();
+                foreach ($chunk as $member)
+                {
+                    $mobile = $member['member_mobile'];
+                    try {
+                        $status = $sms->send_oper($mobile, $smscode);
+                        Log::record("sms info: status:" . json_encode($status),Log::DEBUG);
+                    } catch (Exception $e) {
+                        Log::record("sms info: fall error\treturn:" . $e->getMessage(),Log::ERR);
+                    }
+                    ++$iconut;
+                    if($iconut == 10) {
+                        sleep(2);
+                        $iconut = 0;
+                    }
+                }
+            }
+        }
+        return callback(true);
+    }
+
     /**
      * 订阅快递鸟
      * @param $param

+ 3 - 3
data/model/mb_special.model.php

@@ -223,9 +223,9 @@ class mb_specialModel extends Model
             $blocks[] = $block;
         }
 
-        $cache = array('special' => serialize($blocks));
-        wcache($special_id, $cache, $prefix);
-        return $blocks;
+        $cache = array('blocks' => $blocks);
+        wcache($special_id, array('special' => serialize($cache)), $prefix);
+        return $cache;
     }
 
     /**

+ 3 - 3
helper/activity/recommend_combo.php

@@ -51,7 +51,6 @@ class recommend_combo
         $goods_combos = [];
 
         $mod = Model('goods_combo');
-
         $list = $mod->getGoodsComboList(array());
         foreach ($list as $val)
         {
@@ -59,9 +58,10 @@ class recommend_combo
             $cgid   = intval($val['combo_goodsid']);
 
             if(isset($goods_combos[$gid])) {
-                array_push($goods_combos[$gid],$cgid);
+                $goods_combos[$gid][] = $cgid;
             } else {
-                $goods_combos[$gid] = array($cgid);
+                $goods_combos[$gid] = [];
+                $goods_combos[$gid][] = $cgid;
             }
         }
 

+ 2 - 5
helper/activity/recommend_goods.php

@@ -69,14 +69,11 @@ class recommend_goods
         }
 
         $goods_ids = [];
-
         $mod = Model('p_booth');
-
         $list = $mod->getBoothGoodsList(array('store_id' => self::STORE_ID), 'goods_id');
-        foreach ($list as $val)
-        {
+        foreach ($list as $val) {
             $goods_id = intval($val['goods_id']);
-            array_push($goods_ids,$goods_id);
+            $goods_ids[] = $goods_id;
         }
         sort($goods_ids);
 

+ 41 - 12
helper/area/area_check.php

@@ -10,51 +10,63 @@
 namespace area;
 require_once(BASE_ROOT_PATH . '/helper/util_helper.php');
 
+use Db;
+
 class area_check
 {
-    private $mItems;
-    private $mAreaIds;
-    private $mod_area;
+    protected $mItems;
+    protected $mAreaIds;
+    protected $mAreaNames;
+    protected $mod_area;
 
     public function __construct()
     {
         $this->mod_area = Model('area');
         $this->mItems = [];
         $this->mAreaIds = [];
+        $this->mAreaNames = [];
 
         $this->init();
     }
 
-    private function init()
+    protected function init()
     {
-        $items = $this->mod_area->where(array('area_parent_id' => 0))->field('area_id,area_parent_id,area_deep,area_name')->order('area_parent_id ASC ,area_id ASC ,area_name ASC')->select();
+        $items = $this->mod_area->where(array('area_parent_id' => 0,'enable' => 1))->field('area_id,area_parent_id,area_deep,area_name')->order('area_parent_id ASC,area_id ASC,area_name ASC')->select();
         foreach ($items as $item)
         {
             $area_id = intval($item['area_id']);
+            $area_name = trim($item['area_name']);
             if($area_id >= 32) continue; //海外地区不处理了。
 
             $this->mItems[$area_id] = $item;
             $this->mAreaIds[$area_id] = [];
+            $this->mAreaNames[$area_name]['area_id'] = $area_id;
+            $this->mAreaNames[$area_name]['subs'] = [];
 
-            $this->load($area_id);
+            $this->load($area_id,$area_name);
         }
     }
 
-    private function load($parent_id)
+    protected function load($parent_id,$parent_name)
     {
-        $items = $this->mod_area->where(array('area_parent_id' => $parent_id))->field('area_id,area_parent_id,area_deep,area_name')->order('area_parent_id ASC ,area_id ASC ,area_name ASC')->select();
+        $items = $this->mod_area->where(array('area_parent_id' => $parent_id,'enable' => 1))->field('area_id,area_parent_id,area_deep,area_name')->order('area_parent_id ASC,area_id ASC,area_name ASC')->select();
         foreach ($items as $item)
         {
             $area_id = intval($item['area_id']);
+            $area_name = trim($item['area_name']);
 
             $this->mItems[$area_id] = $item;
-            $this->mAreaIds[$area_id] = [] ;
+            $this->mAreaIds[$area_id] = [];
             $this->mAreaIds[$parent_id][] = $area_id;
-            $this->load($area_id);
+
+            $this->mAreaNames[$area_name]['area_id'] = $area_id;
+            $this->mAreaNames[$parent_name]['subs'][] = $area_name;
+
+            $this->load($area_id,$area_name);
         }
     }
 
-    private function next($ids)
+    protected function next($ids)
     {
         $result = [];
         foreach ($ids as $id) {
@@ -66,7 +78,7 @@ class area_check
 
     public function export()
     {
-        $items = $this->mod_area->where(array('area_parent_id' => 0))->field('area_id')->order('area_parent_id ASC ,area_id ASC ,area_name ASC')->select();
+        $items = $this->mod_area->where(array('area_parent_id' => 0,'enable' => 1))->field('area_id')->order('area_parent_id ASC,area_id ASC,area_name ASC')->select();
         $provins = [];
         foreach ($items as $item) {
             $area_id = intval($item['area_id']);
@@ -76,6 +88,7 @@ class area_check
         $areas = $provins;
         $citys = $this->next($provins);
         $areas = array_merge($areas,$citys);
+
         $contrys = $this->next($citys);
         $areas = array_merge($areas,$contrys);
 
@@ -92,4 +105,20 @@ class area_check
 
         return $result;
     }
+
+    public function update_country()
+    {
+        $items = Db::getAll("SELECT max(area_id) as max_id FROM lrlz_area;");
+        $maxid = $items[0]['max_id'];
+
+        if($maxid > 0)
+        {
+            $items = $this->mod_area->where(array('area_name' => array('like',"%其它区%")))->field('area_id')->select();
+            foreach ($items as $item) {
+                $maxid += 1;
+                $area_id = $item['area_id'];
+                $ret = $this->mod_area->where(array('area_id' => $area_id))->update(array('area_id' => $maxid));
+            }
+        }
+    }
 }

+ 171 - 0
helper/area/area_validator.php

@@ -0,0 +1,171 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: stanley-king
+ * Date: 2017/3/22
+ * Time: 上午10:40
+ */
+
+namespace area;
+require_once(BASE_ROOT_PATH . '/helper/util_helper.php');
+require_once(BASE_ROOT_PATH . '/helper/algorithm.php');
+
+
+class area_validator extends area_check
+{
+    private static $stInstance = null;
+
+    private $mProvinces;
+    private $mCities;
+    private $mCountries;
+
+    public function __construct()
+    {
+        parent::__construct();
+        $this->fill();
+    }
+    public static function instance()
+    {
+        if(self::$stInstance == null) {
+            self::$stInstance = new area_validator();
+        }
+        return self::$stInstance;
+    }
+
+    public function province($area_id)
+    {
+        $area_id = intval($area_id);
+        if(algorithm::binary_search($this->mProvinces,$area_id)) {
+            return array('province' => $this->mItems[$area_id]);
+        } else {
+            return false;
+        }
+    }
+    public function city($area_id)
+    {
+        $area_id = intval($area_id);
+        if(algorithm::binary_search($this->mCities,$area_id)) {
+            $result = [];
+            $result['city'] = $this->mItems[$area_id];
+            $parent_id = $this->mItems[$area_id]['area_parent_id'];
+            $result['province'] = $this->mItems[$parent_id];
+            return $result;
+        } else {
+            return false;
+        }
+    }
+    public function country($area_id)
+    {
+        $area_id = intval($area_id);
+        if(algorithm::binary_search($this->mCountries,$area_id)) {
+            $result = [];
+            $result['country'] = $this->mItems[$area_id];
+
+            $city_id = $result['country']['area_parent_id'];
+            $result['city'] = $this->mItems[$city_id];
+
+            $province_id = $this->mItems[$area_id]['area_parent_id'];
+            $result['province'] = $this->mItems[$province_id];
+            return $result;
+        } else {
+            return false;
+        }
+    }
+
+    public function from_areaid($area_id)
+    {
+        if(array_key_exists($area_id,$this->mItems))
+        {
+            $areas = [];
+
+            $area = $this->mItems[$area_id];
+            $areas[] = $area;
+            $parent_id = intval($area['area_parent_id']);
+            while ($parent_id > 0) {
+                $area = $this->mItems[$parent_id];
+                $areas[] = $area;
+                $parent_id = intval($area['area_parent_id']);
+            }
+
+            $result = [];
+            $count = count($areas);
+            for($index = $count - 1 ; $index >= 0; --$index)
+            {
+                if($index == $count - 1) {
+                    $result['province'] = $areas[$index];
+                }
+                elseif($index == $count - 2) {
+                    $result['city'] = $areas[$index];
+                }
+                elseif($index == $count - 3) {
+                    $result['country'] = $areas[$index];
+                }
+            }
+
+            return $result;
+
+        } else {
+            return false;
+        }
+    }
+
+    public function from_name($province,$city,$country)
+    {
+        if(!empty($country) && trim($country) != '其它区') {
+            $area_name = $country;
+        }
+        elseif(!empty($city)) {
+            $area_name = $city;
+        }
+        elseif(!empty($province)) {
+            $area_name = $province;
+        }
+        else {
+            return false;
+        }
+
+        if(!empty($area_name) && array_key_exists($area_name,$this->mAreaNames))
+        {
+            $area_id = $this->mAreaNames[$area_name]['area_id'];
+            $result = $this->from_areaid($area_id);
+
+            if($result == false) {
+                return false;
+            } else {
+                return $result;
+            }
+        }
+        else {
+            return false;
+        }
+    }
+
+
+
+    private function fill()
+    {
+        $items = $this->mod_area->where(array('area_parent_id' => 0,'enable' => 1))->field('area_id')->order('area_parent_id ASC,area_id ASC,area_name ASC')->select();
+        $provins = [];
+        foreach ($items as $item) {
+            $area_id = intval($item['area_id']);
+            if($area_id >= 32) continue; //海外地区不处理了。
+            $provins[] = $area_id;
+        }
+        foreach ($provins as $area_id) {
+            $this->mProvinces[] = intval($area_id);
+        }
+        sort($this->mProvinces);
+
+        $citys = $this->next($provins);
+        foreach ($citys as $area_id) {
+            $this->mCities[] = intval($area_id);
+        }
+        sort($this->mCities);
+
+        $countries = $this->next($citys);
+        foreach ($countries as $area_id) {
+            $this->mCountries[] = intval($area_id);
+        }
+        sort($this->mCountries);
+    }
+}

+ 66 - 0
helper/member_helper.php

@@ -0,0 +1,66 @@
+<?php
+
+/**
+ * Created by PhpStorm.
+ * User: stanley-king
+ * Date: 2017/3/21
+ * Time: 下午2:52
+ */
+
+require_once(BASE_ROOT_PATH . '/helper/algorithm.php');
+
+
+class member_helper
+{
+    public static function from_mobiles($inputs,&$errno)
+    {
+        $items = preg_split('/,/',$inputs);
+
+        $errno = [];
+        $mobiles = [];
+        foreach ($items as $item)
+        {
+            $mobile = trim($item);
+            $validate = new Validator();
+            $validate->setValidate(Validator::verify_mobile($mobile));
+            $err = $validate->validate();
+            if(empty($err))
+            {
+                $nMobile = intval($mobile);
+                if(algorithm::binary_search($mobiles,$nMobile) == false) {
+                    $pos = algorithm::lower_bonud($mobiles,$nMobile);
+                    algorithm::array_insert($mobiles,$pos,$nMobile);
+                    continue;
+                }
+            }
+            $errno[] = $mobile;
+        }
+
+        if(!empty($mobiles)) {
+            $member = Model('member');
+            $items = $member->getMemberList(array('member_mobile' => array('in',$mobiles)),'member_id,member_mobile');
+            return $items;
+        } else {
+            return false;
+        }
+    }
+
+    public static function from_sql($sql)
+    {
+        if(empty($sql)) {
+            return false;
+        }
+        else
+        {
+            $result = [];
+            $items = DB::getAll($sql);
+            foreach ($items as $item) {
+                $member = [];
+                $member['member_id'] = $item['member_id'];
+                $member['member_mobile'] = $item['member_mobile'];
+                $result[] = $member;
+            }
+        }
+        return $result;
+    }
+}

+ 7 - 2
helper/message/publisher.php

@@ -53,6 +53,7 @@ class publisher
             $this->mRedis->publish('ch_index',serialize(array('type'=>'special','value' => 0)));
         }
     }
+    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     public function modify_activity_fullsent()
     {
         if($this->mConnected) {
@@ -62,19 +63,21 @@ class publisher
     public function modify_activity_groupbuy()
     {
         if($this->mConnected) {
+            dcache('all_groupbuy','mb_activity');
             $this->mRedis->publish('activity',serialize(array('type'=>'groupbuy','value' => 0)));
         }
     }
     public function modify_activity_limit()
     {
         if($this->mConnected) {
-
+            dcache('all_limitime','mb_activity');
             $this->mRedis->publish('activity',serialize(array('type'=>'limit','value' => 0)));
         }
     }
     public function modify_activity_recommend_goods()
     {
         if($this->mConnected) {
+            dcache('all_recommend_goods','mb_activity');
             $this->mRedis->publish('activity',serialize(array('type'=>'recommend_goods','value' => 0)));
         }
     }
@@ -88,16 +91,18 @@ class publisher
     public function modify_activity_recommend_combo()
     {
         if($this->mConnected) {
+            dcache('all_recommend_combo','mb_activity');
             $this->mRedis->publish('activity',serialize(array('type'=>'recommend_combo','value' => 0)));
         }
     }
     public function modify_activity_goods_gift()
     {
         if($this->mConnected) {
+            dcache('all_goods_gift','mb_activity');
             $this->mRedis->publish('activity',serialize(array('type'=>'goods_gift','value' => 0)));
         }
     }
-
+    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     public function modify_seracher_init()
     {
         if($this->mConnected) {

+ 3 - 1
helper/search/processor.php

@@ -20,6 +20,7 @@ class processor implements IProcessor
 {
     const GetRelatedWord = 1;
     const SearchReasult  = 2;
+
     public function handle_input($body)
     {
         if(StatesHelper::fetch_state('init')) {
@@ -36,11 +37,12 @@ class processor implements IProcessor
             $result = searcher::instance()->get_word($words);
             return serialize($result);
         }
-        else if($type == self::SearchReasult) {
+        elseif($type == self::SearchReasult) {
             $params = $body['params'];
             $result = searcher::instance()->get_result($params);
             return serialize($result);
         }
+
         else {
 
         }

+ 5 - 0
helper/sms_helper.php

@@ -71,6 +71,11 @@ class sms_helper
         QueueClient::push('sendSMS', array('mobile' => $mobile,'type' => $type, 'datas' => $datas));
     }
 
+    static public function send_oper_message($type,$datas)
+    {
+        QueueClient::push('sendSMS', array('mobile' => $mobile,'type' => $type, 'datas' => $datas));
+    }
+
     static public function check_code($itype,$code,$mobile)
     {
         if(isset($_SESSION['sms_code'][$itype]))

+ 22 - 4
helper/special_helper.php

@@ -304,8 +304,20 @@ class special_formater
         if(empty($specials)) {
             Log::record("getMbSpecialItemUsableListByID is empty",Log::ERR);
         }
-        $this->filter_data = $this->filter($specials,$goods_ids);
-        $this->goods_ids = $goods_ids;
+
+        if(isset($specials["mobile_filter_data"])) {
+            $this->filter_data = $specials['mobile_filter_data'];
+            $this->goods_ids   = $specials['mobile_goods_ids'];
+        } else {
+            $this->filter_data = $this->filter($specials['blocks'],$goods_ids);
+            $this->goods_ids = $goods_ids;
+
+            $specials['mobile_filter_data'] = $this->filter_data;
+            $specials['mobile_goods_ids'] = $goods_ids;
+            $cache = array('special' => serialize($specials));
+
+            wcache($this->special_id, $cache, 'mb_special');
+        }
     }
 
     private function filter($specials,&$goods_ids)
@@ -417,10 +429,16 @@ class special_formater
     {
         foreach($items as &$item)
         {
-            static $types = array('url','innerurl','video');
-            if(in_array($item['type'],$types)){
+            static $action_types = array('url','video');
+            static $show_types = array('webview','video');
+
+            if(in_array($item['type'],$action_types)){
                 $item['data'] =  htmlspecialchars_decode($item['data']);
             }
+
+            if(in_array($item['show_type'],$show_types)){
+                $item['show_data'] =  htmlspecialchars_decode($item['show_data']);
+            }
         }
     }
 

+ 7 - 0
placeholder.php

@@ -0,0 +1,7 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: huanggang
+ * Date: 17/3/7
+ * Time: 18:12
+ */

+ 7 - 1
test/DBTest.php

@@ -18,12 +18,18 @@ class DBTest extends PHPUnit_Framework_TestCase
         Base::run_util();
     }
 
+    public function testQuery()
+    {
+        $items = Db::getAll('select * from lrlz_member');
+
+    }
+
     public static function tearDownAfterClass()
     {
 
     }
 
-    public static function testConnection()
+    public function testConnection()
     {
         $mysql = @new mysqli('192.168.1.103', 'root', '55668899', 'pandashop', '3306');
     }

+ 13 - 0
test/activity_helperTest.php

@@ -52,6 +52,19 @@ class activity_helperTest extends PHPUnit_Framework_TestCase
         $config['old_specials'] = array(0,23,74,87,105,110,182,184,186,187);
     }
 
+    public function testPublishConfig()
+    {
+        $config['old_tabs'] = array(
+            array('special_id' => 246,'name' => "	推荐"),
+            array('special_id' => 190,'name' => "全球专柜"),
+            array('special_id' => 220,'name' => "男士"),
+            array('special_id' => 197,'name' => "天猫店铺榜"),
+            array('special_id' => 211,'name' => "美妆学院"),
+            array('special_id' => 195,'name' => "丽人丽妆")
+        );
+        $config['old_specials'] = array(74,87,105,110,188,190,197,220);
+    }
+
     public function testFull()
     {
         $contents = activity\full_sent::instance()->rules();

+ 13 - 0
test/areaTest.php

@@ -11,6 +11,7 @@ define('BASE_ROOT_PATH',str_replace('/test','',dirname(__FILE__)));
 require_once(BASE_ROOT_PATH . '/fooder.php');
 require_once(BASE_ROOT_PATH . '/helper/area/area_upgrade.php');
 require_once(BASE_ROOT_PATH . '/helper/area/area_check.php');
+require_once(BASE_ROOT_PATH . '/helper/area/area_validator.php');
 
 class areaTest extends PHPUnit_Framework_TestCase
 {
@@ -41,4 +42,16 @@ class areaTest extends PHPUnit_Framework_TestCase
 
         wcache('area_2.0', array('data' => serialize($result)), 'mb_area');
     }
+    public function testUpdate()
+    {
+        $area = new area\area_check();
+        $result = $area->update_country();
+    }
+
+    public function testValidate()
+    {
+        $validator = new area\area_validator();
+        $result = $validator->from_areaid(145);
+        $result_name = $validator->from_name('上海','上海市','松江区');
+    }
 }