Userlabel.php 3.78 KB
<?php


namespace app\mobile\controller;
use app\home\logic\UsersLogic;
use app\home\model\Message;
use think\Cookie;
use think\Page;
use think\Request;
use think\Session;
use think\Verify;
use think\db;
use think\Cache;
use qcloudcos\Conf;
use qcloudcos\Myqcloudcos;


class userlabel extends MobileBase
{
  //查询自定义标签
    public function user_label(){
        $user = session('user');
        $store_id= getMobileStoId();;
        $data['storeId'] = getMobileStoId();
        $this->assign('storeid',  $store_id );
        $accdb = tpCache('shop_info.ERPId', getMobileStoId());
       /* 获取商家自定义标签*/
        $list= getApiData_java_p("/api/erp/marketing/vip/interest/label/page",$accdb ,$data, 1, 50, null, "GET");
        if ($list) {
            $list = json_decode($list, true);
            $pagedata = $list['data']['pageData'];
            $this->assign('list', $pagedata);
        }
     /*   获取商家设置*/
        $store_config= M('store_config')->where("store_id", $store_id)->find();
        if ($store_config) {
            $switch_list = $store_config['switch_list'];
            $switch_list = json_decode($switch_list, true);

            $is_dj = $switch_list['rank_switch'];
            $user_label_set = $switch_list['user_label_set'];//是否开启的名称
            $user_label_val = $switch_list['user_label_val'];//获取的积分或成长值
            $user_label_type = $switch_list['user_label_type'];//是否为积分还是成长值
            $this->assign('user_label_set', $user_label_set);
            $this->assign('user_label_val', $user_label_val);
            $this->assign('user_label_type', $user_label_type);
            $this->assign('is_dj', $is_dj);
            //查询会员的标签
            if ($user['erpvipid']) {
                $data['VIPId'] = urlencode($user['erpvipid']);
                $vip_user = getApiData_java_p("/api/erp/marketing/vip/interest/label/get", $accdb, $data, 1, 1000, null, "GET");
                $vip_user = json_decode($vip_user, true);
                $label_data = $vip_user['data'];
                $label_id = $label_data['VipLabelId'];
                $label_name = $label_data['VipLabel'];
                $this->assign('label_id1', $label_id);
                $this->assign('label_name1', $label_name);
                if ($label_name) {
                    $label_name = explode(",", $label_name);
                    $this->assign('label_name', $label_name);
                }
                $label_id = explode(",", $label_id);


                $arr = $label_name[0];
                $this->assign('arrs', $arr);
                $this->assign('label_id', $label_id);
            }
        }

        return $this->fetch('', getMobileStoId());
    }
    /*保存与修改会员自定义标签*/

    public function ajax_add_label(){
        $stoid=getMobileStoId();
        $accdb = tpCache("shop_info.ERPId", $stoid);
        $user = session('user');
        $label_data=I('post.');
        $vipid=$user['erpvipid'];
        $labelid=$label_data['labelId'];
        $label=$label_data['label'];
        $val=$label_data['val'];
        $type=$label_data['type'];

        $type=(int)$type+1;
        if(!$val){ $type=0;  }

        $time=date("YmdHis");
        $random=rand(1000,9999);
        $fromType="REWARD";
        $orderNo=$accdb.$time.$random;
        $data['VIPId']=$vipid;
        $data['VIPLabelId']=$labelid;
        $data['VIPLabel']=$label;
        $data['OrderNo']= $orderNo;
        $data['Type']= $type;
        $data['FromType']= $fromType;
        $data['Value']=$val;
        $data['Remark']=$label_data["remark"];
        $rec=getApiData_java_p("/api/erp/marketing/vip/interest/label/update",$accdb ,$data, null, null, null, "put");
        $rec=json_decode($rec,true);
        return json(['data' => $rec]);

    }



}