123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411 |
- <?php
- /**
- * lionfish 商城系统
- *
- *
- * @author fish
- *
- */
- namespace Seller\Controller;
- class WeprogramController extends CommonController{
-
- protected function _initialize(){
- parent::_initialize();
-
- //'pinjie' => '拼团介绍',
- }
-
- public function index()
- {
-
- $type = I('request.type');
-
- $type = isset($type) && !empty($type) ? $type : 1;
-
-
- if (IS_POST) {
-
- $data = I('request.parameter');
- $param['wepro_share_title'] = trim($data['wepro_share_title']);
-
-
- $param['wepro_appid'] = trim($data['wepro_appid']);
- $param['wepro_appsecret'] = trim($data['wepro_appsecret']);
- $param['wepro_partnerid'] = trim($data['wepro_partnerid']);
- $param['wepro_key'] = trim($data['wepro_key']);
- $param['is_open_yinpay'] =$data['is_open_yinpay'] ? trim($data['is_open_yinpay']) : 0;
-
- if(!empty($data['wechat_apiclient_cert_pem'])){ $param['wechat_apiclient_cert_pem'] = trim($data['wechat_apiclient_cert_pem']);}
- if(!empty($data['wechat_apiclient_key_pem'])){ $param['wechat_apiclient_key_pem'] = trim($data['wechat_apiclient_key_pem']);}
- if(!empty($data['sup_wechat_apiclient_cert_pem'])){ $param['sup_wechat_apiclient_cert_pem'] = trim($data['sup_wechat_apiclient_cert_pem']);}
- if(!empty($data['sup_wechat_apiclient_key_pem'])){ $param['sup_wechat_apiclient_key_pem'] = trim($data['sup_wechat_apiclient_key_pem']);}
- if(!empty($data['wepro_sub_mch_id'])){ $param['wepro_sub_mch_id'] = trim($data['wepro_sub_mch_id']);}
- if(!empty($data['wepro_fuwu_appid'])){ $param['wepro_fuwu_appid'] = trim($data['wepro_fuwu_appid']);}
- if(!empty($data['wepro_fuwu_partnerid'])){ $param['wepro_fuwu_partnerid'] = trim($data['wepro_fuwu_partnerid']);}
- if(!empty($data['sup_wepro_key'])){ $param['sup_wepro_key'] = trim($data['sup_wepro_key']);}
- D('Seller/Config')->update($param);
-
- show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
- }
- $data = D('Seller/Config')->get_all_config();
-
- $this->data = $data;
- $this->type = $type;
-
- $this->display();
- }
-
-
- public function autosubscribetemplateconfig()
- {
-
- D('Seller/User')->mange_subscribetemplate_auto();
-
- show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
- }
-
-
- public function autotemplateconfig()
- {
- global $_W;
- global $_GPC;
-
- D('Seller/User')->mange_template_auto();
-
- show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
- }
-
- public function templateconfig()
- {
- $_GPC = I('request.');
-
- if( !isset($_GPC['type']) || empty($_GPC['type']) )
- {
- $_GPC['type'] = 1;
- }
-
- if($_GPC['type']=='2'){
-
- //获取选中的会员id
- $data = array();
- $data['userids'] = $_GPC['limit_user_list'];
-
- //提交更新
- if(IS_POST)
- {
-
- $platform = array();
- $platform['platform_send_info_member']= $data['userids'];
-
- D('Seller/Config')->update($platform);
-
- show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
- }
-
- //查询下会员id
- $send = M('lionfish_comshop_config')->where( array('name' => 'platform_send_info_member') )->find();
-
- if(!empty($send['value'])){
-
- //in语句查询会员对应信息
- $list = array();
- if( !empty($send['value']) )
- {
- $list = M('lionfish_comshop_member')->field('member_id, username as nickname,avatar')->where('member_id in('.$send['value'].')')->select();
- }
-
- //组合
- foreach($list as $key => $vv){
- $userall =array(
- 'member_id' => $vv[member_id],
- 'nickname' => $vv[nickname],
- 'avatar' => tomedia($vv[avatar]),
- );
- $user_list[$key]=$userall;
- }
- }else{
-
- $user_list = array();
- }
-
-
-
- }
- else if( $_GPC['type']=='3' )
- {
- $member_group_list = M('lionfish_comshop_member_group')->order('id asc')->select();
-
- $this->member_group_list = $member_group_list;
- }
- else{
- if ( IS_POST ) {
-
- $data = ((is_array($_GPC['parameter']) ? $_GPC['parameter'] : array()));
- $data['wepro_share_title'] = trim($data['wepro_share_title']);
-
- D('Seller/Config')->update($data);
-
- show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
- }
-
- $data = D('Seller/Config')->get_all_config();
- }
-
- $type = I('get.type',1);
-
- $this->type = $type;
- $this->user_list = $user_list;
- $this->_GPC = $_GPC;
-
- $this->data = $data;
- $this->display();
- }
-
-
- public function templateconfig_set()
- {
- $_GPC = I('request.');
-
- if (IS_POST) {
-
- $data = ((is_array($_GPC['parameter']) ? $_GPC['parameter'] : array()));
-
- D('Seller/Config')->update($data);
-
- show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
- }
- $data = D('Seller/Config')->get_all_config();
- $this->data = $data;
-
- include $this->display();
- }
-
-
-
- public function templateconfig_fenxi()
- {
- $_GPC = I('request.');
-
- $subtitle = $_GPC['subtitle'];
-
- $datas = $_GPC['datas'];
- $all_msg_send_type = $_GPC['all_msg_send_type'];
- $member_id = $_GPC['member_id'];
- $member_group_id = $_GPC['member_group_id'];
- $all_send_template_id = $_GPC['all_send_template_id'];
- $link = $_GPC['link'];
-
- $limit_user_list = $_GPC['limit_user_list'];
-
- if( $all_msg_send_type == 1)
- {
- //单人
- if( empty($limit_user_list) )
- {
- show_json(0, '请选择会员');
- die();
- }
-
- }else if( $all_msg_send_type == 2 )
- {
- //用户组
- if( empty($member_group_id) || $member_group_id <= 0 )
- {
- show_json(0, '请选择会员组');
- die();
- }
- }else if( $all_msg_send_type == 3 )
- {
- //群发所有人
- }
-
- if( empty($datas) )
- {
- show_json(0, '请填写模板消息内容');
- die();
- }
-
- $template_data = array();
-
- foreach( $datas as $key => $val )
- {
- $str = $key;
-
- $str = str_replace('{{','', $str );
- $str = str_replace('.DATA','', $str );
- $tp_key = str_replace('}}','', $str );
-
- $template_data[$tp_key] = array('value' => ($val), 'color' => '#173177');
- }
-
- if( empty($all_send_template_id) )
- {
- show_json(0, '请填写模板ID');
- die();
- }
- if( empty($link) )
- {
- show_json(0, '请填写点击链接');
- die();
- }
-
- @set_time_limit(0);
-
- //todo///
- if( $all_msg_send_type == 3 )
- {
- $membercount = M('lionfish_comshop_member')->count();
-
- if( empty($membercount) || $membercount == 0 )
- {
- show_json(0, '暂无会员可发送消息');
- die();
- }
-
- $msg_order = array();
- $msg_order['uniacid'] = 0;
- $msg_order['template_data'] = serialize($template_data);
- $msg_order['url'] = $link;
- $msg_order['open_id'] = '';
- $msg_order['template_id'] = $all_send_template_id;
- $msg_order['type'] = 1;
- $msg_order['state'] = 0;
- $msg_order['total_count'] = $membercount;
- $msg_order['send_total_count'] = 0;
- $msg_order['addtime'] = time();
-
- M('lionfish_comshop_templatemsg')->add( $msg_order );
-
- show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
- }else{
-
- if( $all_msg_send_type == 1 )
- {
- $mb_info_all = M('lionfish_comshop_member')->field('we_openid')->where( 'member_id in ('.$limit_user_list.')' )->select();
-
- foreach($mb_info_all as $mb_info )
- {
- $msg_order = array();
- $msg_order['uniacid'] = 0;
- $msg_order['template_data'] = serialize($template_data);
- $msg_order['url'] = $link;
- $msg_order['open_id'] = $mb_info['we_openid'];
- $msg_order['template_id'] = $all_send_template_id;
- $msg_order['type'] = 0;
- $msg_order['state'] = 0;
- $msg_order['addtime'] = time();
-
- M('lionfish_comshop_templatemsg')->add( $msg_order );
- }
-
- show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
- }else if( $all_msg_send_type == 2 )
- {
- $mb_info_list = M('lionfish_comshop_member')->field('we_openid')->where( array('groupid' => $member_group_id ) )->select();
-
- foreach( $mb_info_list as $mb_info )
- {
- $msg_order = array();
- $msg_order['uniacid'] = 0;
- $msg_order['template_data'] = serialize($template_data);
- $msg_order['url'] = $link;
- $msg_order['open_id'] = $mb_info['we_openid'];
- $msg_order['template_id'] = $all_send_template_id;
- $msg_order['type'] = 0;
- $msg_order['state'] = 0;
- $msg_order['addtime'] = time();
-
- M('lionfish_comshop_templatemsg')->add($msg_order);
- }
- show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
-
- }
-
-
- }
-
- }
-
- public function subscribetemplateconfig()
- {
- $_GPC = I('request.');
-
- if ( IS_POST ) {
-
- $data = ((is_array($_GPC['parameter']) ? $_GPC['parameter'] : array()));
- $data['wepro_share_title'] = trim($data['wepro_share_title']);
-
- D('Seller/Config')->update($data);
-
- show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
- }
- $data = D('Seller/Config')->get_all_config();
-
- $this->data = $data;
-
- $this->display();
- }
-
- /**
- * tabbar设置
- */
- public function tabbar()
- {
-
- if ( IS_POST) {
-
- $gpc = I('request.');
-
- $data = ((is_array($gpc['parameter']) ? $gpc['parameter'] : array()));
- $param = array();
- $param['wepro_tabbar_list'] = array();
- $param['wepro_tabbar_list']['t1'] = trim($data['wepro_tabbar_text1']);
- $param['wepro_tabbar_list']['t2'] = trim($data['wepro_tabbar_text2']);
- $param['wepro_tabbar_list']['t3'] = trim($data['wepro_tabbar_text3']);
- $param['wepro_tabbar_list']['t4'] = trim($data['wepro_tabbar_text4']);
- $param['wepro_tabbar_list']['t5'] = trim($data['wepro_tabbar_text5']);
- $param['wepro_tabbar_list']['s1'] = save_media($data['wepro_tabbar_selectedIconPath1']);
- $param['wepro_tabbar_list']['s2'] = save_media($data['wepro_tabbar_selectedIconPath2']);
- $param['wepro_tabbar_list']['s3'] = save_media($data['wepro_tabbar_selectedIconPath3']);
- $param['wepro_tabbar_list']['s4'] = save_media($data['wepro_tabbar_selectedIconPath4']);
- $param['wepro_tabbar_list']['s5'] = save_media($data['wepro_tabbar_selectedIconPath5']);
- $param['wepro_tabbar_list']['i1'] = save_media($data['wepro_tabbar_iconPath1']);
- $param['wepro_tabbar_list']['i2'] = save_media($data['wepro_tabbar_iconPath2']);
- $param['wepro_tabbar_list']['i3'] = save_media($data['wepro_tabbar_iconPath3']);
- $param['wepro_tabbar_list']['i4'] = save_media($data['wepro_tabbar_iconPath4']);
- $param['wepro_tabbar_list']['i5'] = save_media($data['wepro_tabbar_iconPath5']);
- $param['wepro_tabbar_list'] = serialize($param['wepro_tabbar_list']);
- $param['open_tabbar_type'] = $data['open_tabbar_type'];
- $param['open_tabbar_out_weapp'] = $data['open_tabbar_out_weapp'];
- $param['tabbar_out_appid'] = $data['tabbar_out_appid'];
- $param['tabbar_out_link'] = $data['tabbar_out_link'];
- $param['tabbar_out_type'] = $data['tabbar_out_type'];
- $param['wepro_tabbar_selectedColor'] = $data['wepro_tabbar_selectedColor'];
- $param['wepro_tabbar_bgColor'] = $data['wepro_tabbar_bgColor'];
-
- D('Seller/Config')->update($param);
-
-
- show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
- }
- $data = D('Seller/Config')->get_all_config();
-
- if(!is_array($data['wepro_tabbar_list']))
- $data['wepro_tabbar_list'] = unserialize($data['wepro_tabbar_list'] );
-
- $this->data = $data;
-
- $this->display();
- }
-
-
-
- }
- ?>
|