unionShareUser.html 17.5 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Yoho!Buy运营平台</title>
    <script src="/union/js/include.js"></script>
    <script src="/union/js/ajaxfileupload.js"></script>
</head>
<body class="easyui-layout" fit="true">
<div region="north" style="padding-bottom: 35px; height: auto;">
    <script>
        document.write(addHead('CPS联盟管理', 'CPS联盟用户管理'));
    </script>
    <form id="searchForm" method="post" accept-charset="utf-8">
        <div style="margin-left: 10px;margin-top: 10px">
            <label>用户ID:</label>
            <input class="easyui-textbox" id="uid" name="uid"/>
            <label>渠道号:</label>
            <input class="easyui-textbox" id="unionType" name="unionType"/>
            <label>是否有锁粉权限:</label>
            <input class="easyui-combobox" id="specialStatus" name="specialStatus"
                   data-options="valueField: 'value',
		                        textField: 'label',
		                        data: [{
			                      label: '是',
			                      value: '2'
		                          },{
			                      label: '否',
			                      value: '1'
		                          }]">
            </input>
            <a id="searchBtn" style="margin-left: 20px" class="easyui-linkbutton btn-primary" data-options="iconCls:'icon-more'">查询</a>
            <a id="passButton" style="margin-left: 20px" class="easyui-linkbutton btn-primary" data-options="iconCls:'icon-more'">批量开通锁粉</a>
            <a id="rewardBtn" style="margin-left: 20px" class="easyui-linkbutton btn-primary" data-options="iconCls:'icon-more'">部分补</a>
            <a id="settleBtn" style="margin-left: 20px" class="easyui-linkbutton btn-primary" data-options="iconCls:'icon-more'">结算变更</a>
        </div>
    </form>
</div>
<div region="center">
    <div style="margin-left: 30px;margin-top: 20px; height: 500px;">
        <table id="userTable"></table>
    </div>
</div>
<script type="text/javascript">
    var checkedItems = [];
    function getQueryString(url,name) {
        debugger;
        var i=url.lastIndexOf('?');
        if(i==-1)return;
        var querystr=url.substr(i+1);
        var arr1=querystr.split('&');
        var arr2=new Object();
        for  (i in arr1){
            var ta=arr1[i].split('=');
            arr2[ta[0]]=ta[1];
        }
        return arr2[name];
    }

    var param=window.location.search;
    var pid = getQueryString(param, "pid");
    $(function () {
        $("#userTable").myDatagrid({
            fit: true,
            fitColumns: true,
            <!-- idField: "id",-->
            view: fileview,
            nowrap: false,
            onCheckAll: addcheckItem,
            onCheck: addcheckItem,
            onUncheckAll: removeAllItem,
            onUncheck: removeSingleItem,
            url: contextPath + "/UnionShareRest/queryUnionShareUsers",
            method: 'POST',
            loadFilter: function (data) {
                var temp = defaultLoadFilter(data);
                temp=null==temp?[]:temp;
                temp.rows = temp.list;
                return temp;
            },
            columns: [[{
                title: "ID",
                field: "id",
                idField:"id",
                width: 200,
                align: "center",
                checkbox: true
            }, {
                title: "用户ID",
                field: "uid",
                width: 200,
                align: "center"
            }, {
                title: "渠道号",
                field: "unionType",
                width: 200,
                align: "center"
            }, {
                title: "渠道名称",
                field: "unionName",
                width: 200,
                align: "center"
            }, {
                title: "是否有锁粉权限",
                field: "specialStatus",
                width: 200,
                align: "center",
                formatter: function (value, rowData, rowIndex) {
                    if(value == 1) {
                        return "否";
                    }
                    if(value == 2) {
                        return "是";
                    }
                }
           }, {
                title: "创建时间",
                field: "createTimeStr",
                width: 200,
                align: "center"
            }, {
                title: "更新时间",
                field: "updateTimeStr",
                width: 200,
                align: "center"
            }, {
                title: "参与新人活动id",
                field: "cpsActivityId",
                width: 100,
                align: "center"
            }, {
                title: "操作",
                field: "asdf",
                width: 200,
                align: "center",
                formatter: function (value, rowData, rowIndex) {
//                    var str = "<a role='reward' dataId='" + rowData.uid + "' style='margin-left:10px'>部分补</a>";
                    if(rowData.specialStatus == 1) {
                        var str = "<a role='pass' dataId='" + rowData.id + "' style='margin-left:10px'>开通锁粉</a>";
                        return str;
                    }
                }
            }
            ]],
            cache: false,
            pagination: true,
            pageSize: 10,
            pageList: [10],
            idField: "id",
            singleSelect: false,
            checkOnSelect: false,
            onLoadSuccess: function (data) {
                resetSelectedCheckBox(data);

                $(this).myDatagrid("getPanel").find("a[role='pass']").linkbutton({
                    iconCls: "icon-more",
                    onClick: function () {
                        var cancleId=$(this).attr("dataId");
                        pass(cancleId);
                    }
                });
//                $(this).myDatagrid("getPanel").find("a[role='reward']").linkbutton({
//                    iconCls: "icon-more",
//                    onClick: function () {
//                        var uid=$(this).attr("dataId");
//                        reward(cancleId);
//                    }
//                });

            }
        });
        function resetSelectedCheckBox(data){
            $("input[type='checkbox'][name='id']").each(function () {
                var cb=$(this);
                $.each(checkedItems,function(index,value){
                    if(value==cb.val()){
                        cb.attr("checked",true);
                        return false;
                    }
                });
            });
        }
        $("#searchBtn").linkbutton({
            iconCls : "icon-search",
            onClick : function() {
                var param = getParams();
                $("#userTable").myDatagrid("load", param);
            }
        });
        $("#settleBtn").linkbutton({
            iconCls : "icon-search",
            onClick : function() {
                var div = $("<div>").appendTo($(window.self.document.body));
                window.self.$(div).myDialog({
                    modal : true,
                    collapsible : true,
                    cache : false,
                    title : "奖励结算状态变更",
                    width: 690,
                    height: 600,
                    href: contextPath + "/html/unionshare/unionShareRewardChange.html",
                    buttons : [{
                        text : "结算变更",
                        iconCls : "icon-save",
                        handler : function() {
                            debugger;
                            var rewardStatus = $("#rewardStatus").combobox('getValue');
                            if (rewardStatus == "") {
                                window.self.$.messager.alert("提示消息", "请选择状态");
                                return;
                            }
                            var orderIds = $("#orderIds").val();
                            if (orderIds == "") {
                                window.self.$.messager.alert("提示消息", "请输入变更id,用逗号隔开");
                                return;
                            }

                            var param = {};
                            param.status = $.trim(rewardStatus);
                            param.orderIds = $.trim(orderIds);
                            param.pid = pid;

                            $.ajax({
                                type: "POST",
                                contentType: "application/json",
                                url: contextPath + '/UnionShareRest/specialAwardChange',
                                data: JSON.stringify(param),
                                dataType: 'json',
                                success: function(result) {
                                    if(result.data){
                                        window.self.$.messager.alert("提示消息","成功更新状态数:"+result.data);
                                        window.self.$(div).dialog('close');
                                    }else {
                                        window.self.$.messager.alert("操作失败",result.message);
                                    }

                                }
                            });
                        }
                    },{
                        id : "closeBtn",
                        text : "关闭",
                        iconCls : "icon-cancel",
                        handler : function() {
                            window.self.$(div).dialog('close');
                        }
                    }]
                });

            }
        });
        $("#rewardBtn").linkbutton({
            iconCls: "icon-search",
            text: "部分补",
            onClick: function () {
                var div = $("<div>").appendTo($(window.self.document.body));
                window.self.$(div).myDialog({
                    modal : true,
                    collapsible : true,
                    cache : false,
                    title : "佣金发放",
                    width: 690,
                    height: 600,
                    href: contextPath + "/html/unionshare/unionShareReward.html",
                    buttons : [{
                        text : "发放",
                        iconCls : "icon-save",
                        handler : function() {
                            debugger;
                            var rewardUid = $("#rewardUid").val();
                            if (rewardUid == "") {
                                window.self.$.messager.alert("提示消息", "请输入奖励发放目标用户uid");
                                return;
                            }
                            var penny = $("#penny").val();
                            if (penny == "") {
                                window.self.$.messager.alert("提示消息", "请输入奖励数额(以分为单位)");
                                return;
                            }
                            var activityId = $("#activityId").val();
                            if (activityId == "") {
                                window.self.$.messager.alert("提示消息", "请输入奖励活动id");
                                return;
                            }
//                            var rewardStatus = $("#rewardStatus").val();
//                            if (rewardStatus == "") {
//                                window.self.$.messager.alert("提示消息", "请输入奖励状态(10-待结算,20-可结算)");
//                                return;
//                            }
                            var orderCodes = $("#orderCodes").val();
                            if (orderCodes == "") {
                                window.self.$.messager.alert("提示消息", "请输入关联订单号");
                                return;
                            }
                            var param = {};
                            param.uid = $.trim(rewardUid);
                            param.penny = $.trim(penny);
                            param.activityId = $.trim(activityId);
//                            param.status = $.trim(rewardStatus);
                            param.orderCodes = $.trim(orderCodes);
                            param.pid = pid;

                            var remarks = $("#remarks").val();
                            if (remarks != "") {
                                param.remarks = $.trim(remarks);
                            }
                            $.ajax({
                                type: "POST",
                                contentType: "application/json",
                                url: contextPath + '/UnionShareRest/specialAward',
                                data: JSON.stringify(param),
                                dataType: 'json',
                                success: function(result) {
                                    if(result.data){
                                        window.self.$.messager.alert("提示消息","操作成功");
                                        window.self.$(div).dialog('close');
                                    }else {
                                        window.self.$.messager.alert("操作失败",result.message);
                                    }

                                }
                            });
                        }
                    },{
                        id : "closeBtn",
                        text : "关闭",
                        iconCls : "icon-cancel",
                        handler : function() {
                            window.self.$(div).dialog('close');
                        }
                    }]
                });
            }
        });

        function pass(id) {
            var paramObj={};
            if(id==null) {
                paramObj.ids = checkedItems.toString();
            }else {
                paramObj.id = id;
            }
            $.post(contextPath + "/UnionShareRest/passSpecialFans", paramObj, function (res) {
                $.messager.progress("close");
                if (res.code == 200) {
                    if(res.data > 0) {
                        $.messager.show({
                            title: "提示",
                            msg: "锁粉开通成功!",
                            height: 120
                        });
                    }else {
                        $.messager.alert("失败", "操作失败,请重新操作", "error");
                    }
                    $("#searchBtn").click();
                } else {
                    $.messager.alert("失败", res.message, "error");
                }
            }, "json");

        }

        function reward(id) {
            var paramObj={};
            paramObj.uid = id;

            $.post(contextPath + "/UnionShareRest/specialAward", paramObj, function (res) {
                $.messager.progress("close");
                if (res.code == 200) {
                    if(res.data > 0) {
                        $.messager.show({
                            title: "提示",
                            msg: "锁粉开通成功!",
                            height: 120
                        });
                    }else {
                        $.messager.alert("失败", "操作失败,请重新操作", "error");
                    }
                    $("#searchBtn").click();
                } else {
                    $.messager.alert("失败", res.message, "error");
                }
            }, "json");

        }


        function isCheckItem() {
            for (var i = 0; i < checkedItems.length; i++) {
                $("input[type='checkbox'][name='id'][value='"+checkedItems[i]+"']").attr("checked", "checked");
            }
        }
        var fileview = $.extend({}, $.fn.datagrid.defaults.view, { onAfterRender: function (target) { isCheckItem(); } });
        function findCheckedItem(ID) {
            for (var i = 0; i < checkedItems.length; i++) {
                if (checkedItems[i] == ID) return i;
            }
            return -1;
        }
        function addcheckItem() {
            $("input[type='checkbox'][name='id']:checked").each(function () {
                var k = findCheckedItem($(this).val());
                if (k == -1) {
                    checkedItems.push($(this).val());
                }
            });
        }
        function removeAllItem(rows) {
            $("input[type='checkbox'][name='id']").each(function () {
                if (!this.checked) {
                    var k = findCheckedItem($(this).val());
                    if (k != -1) {
                        checkedItems.splice(k, 1);
                    }
                }
            });
        }

        function removeSingleItem(rowIndex, rowData) {
            var k = findCheckedItem(rowData.id);
            if (k != -1) {
                checkedItems.splice(k, 1);
            }
        }
        $("#passButton").linkbutton({
            onClick : function() {
                if (checkedItems.length == 0) {
                    $.messager.alert('提示','请选择要审核通过的数据');
                    return;
                }
                pass(null);
            }
        });

        function getParams() {
            var param = {
                uid:$("#uid").val(),
                unionType:$("#unionType").val(),
                specialStatus:$("#specialStatus").combobox('getValue')
            };
            return param;
        }


    });
</script>
</body>
</html>