dever 3 years ago
parent
commit
b5872ed02b

+ 24 - 5
app/goods/lib/Set.php

@@ -24,7 +24,12 @@ class Set
                 $sku = Dever::db('goods/info_sku')->select(array('info_id' => $v['id']));
 
                 if ($sku) {
-                    $other = Dever::db($table)->find(array($type => $id, 'goods_id' => $v['id'], 'sku_id' => -1));
+                    $other_where = array($type => $id, 'goods_id' => $v['id'], 'sku_id' => -1);
+                    $give = Dever::input('give');
+                    if ($give) {
+                        $other_where['give'] = $give;
+                    }
+                    $other = Dever::db($table)->find($other_where);
                     $result[$i]['id'] = $v['id'];
                     $result[$i]['name'] = $v['name'];
                     $result[$i]['price'] = $v['price'];
@@ -43,7 +48,12 @@ class Set
                             $result[$i]['price'] = $v['f_price'];
                         } 
                         if ($other) {
-                            $result[$i]['total'] = $other['total_num'] - $other['sell_num'];
+                            if (isset($other['total_num'])) {
+                                $result[$i]['total'] = $other['total_num'] - $other['sell_num'];
+                            } else {
+                                $result[$i]['total'] = $other['num'];
+                            }
+                            
                             $result[$i]['select'] = $other['state'];
                         } else {
                             $result[$i]['total'] = 0;
@@ -80,8 +90,12 @@ class Set
                                 'del' => 1,
                                 'end' => true,
                             );
-
-                            $other_sku = Dever::db($table)->find(array($type => $id, 'goods_id' => $v['id'], 'sku_id' => $v1['id']));
+                            $other_sku_where = array($type => $id, 'goods_id' => $v['id'], 'sku_id' => $v1['id']);
+                            $give = Dever::input('give');
+                            if ($give) {
+                                $other_sku_where['give'] = $give;
+                            }
+                            $other_sku = Dever::db($table)->find($other_sku_where);
 
                             $children['select'] = 2;
                             if ($type == 'factory_id') {
@@ -96,7 +110,12 @@ class Set
                                 }
                                 $children['total'] = 0;
                                 if ($other_sku) {
-                                    $children['total'] = $other_sku['total_num'] - $other_sku['sell_num'];
+                                    if (isset($other_sku['total_num'])) {
+                                        $children['total'] = $other_sku['total_num'] - $other_sku['sell_num'];
+                                    } else {
+                                        $children['total'] = $other_sku['num'];
+                                    }
+                                    
                                     $children['select'] = $other_sku['state'];
                                 }
                             }

+ 16 - 0
app/shop/database/info.php

@@ -699,5 +699,21 @@ return array
             'group' => 'city',
             'col' => $col,
         ),
+
+        # 获取城市
+        'getDataByType' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'type' => 'yes',
+                'id' => 'yes',
+                'status' => 1,
+                'state' => 1,
+            ),
+            'type' => 'one',
+            'order' => array('reorder' => 'desc', 'id' => 'desc'),
+            'col' => $col,
+        ),
     ),
 );

+ 7 - 0
app/shop/src/Main.php

@@ -198,4 +198,11 @@ class Main extends Core
 
         return $this->data;
     }
+
+    # 获取平台店信息
+    public function getShopByType()
+    {
+        $where['type'] = 10;
+        return Dever::db('shop/info')->getDataByType($where);
+    }
 }

+ 275 - 0
service/agent/assets/pc/html/setGoods.html

@@ -0,0 +1,275 @@
+<!doctype html>
+<html>
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0" />
+<meta name="author" content="siweiyong 2602812659@qq.com"/>
+<title>设置商品</title>
+<link rel="stylesheet" href="../script/lib/miniui/themes/default/miniui.css">
+<link rel="stylesheet" href="../script/lib/layui/css/layui.css" />
+<link rel="stylesheet" href="../script/lib/cashier/common.css">
+<link rel="stylesheet" href="../script/lib/layui/admin/modules/plugin/formselects/formselects.css" media="all" />
+<script src="../script/lib/jquery/jquery.min.js"></script>
+<script src="../script/lib/miniui/miniui.js"></script>
+<script src="../script/lib/layui/layui.js"></script>
+<script><{Dever::script()}></script>
+<script src="../script/dever/core.js"></script>
+</head>
+<body style="background: #F6F7F9;">
+<div class="main">
+<form class="layui-form" lay-filter="form">
+    <div class="layui-row">
+        <div class="main_left layui-col-xs12 layui-col-md3">
+            <div class="layui-row">
+                <div class="top">
+                    <i class="layui-icon layui-icon-app"></i>商品列表
+                </div>
+                <div class="left_main">
+                    <input id="key" class="mini-textbox" placeholder="请输入商品名称" onenter="onKeyEnter"/>
+                    <a class="mini-button" onclick="search()">查询</a> 
+                    <ul id="tree1" class="mini-tree" url="<{$url}>" showTreeIcon="true" textField="name" idField="id" expandOnLoad="true" onNodeClick="onNodeClick">
+                    </ul>
+                </div>
+            </div>
+        </div>
+        <div class="main_right layui-col-xs12 layui-col-md9">
+            <div class="layui-row">
+                <div class="top">
+                    <label>选择赠送类型:</label>
+                    <div class="layui-input-inline">
+
+                        <div><select name="give" id="give" lay-verify=""><{foreach($search as $k => $v):}><option value="<{$k}>" <{if($give == $k):}>selected<{endif}>><{$v}></option><{endforeach}></select></div>
+
+                    </div>
+                    <div class="layui-input-inline">
+                        <button class="layui-btn layui-btn-button" type="button" style="vertical-align: middle;margin-bottom: 2px;" onclick="setShop()">确认选择</button>
+                    </div>
+                </div>
+                <div class="goods_list" style="height:645px;">
+                    <table class="layui-table">
+                        <thead>
+                            <tr>
+                                <th lay-data="{field:'id'}">商品编码</th>
+                                <th lay-data="{field:'name'}">商品名称</th>
+                                <th lay-data="{field:'price', edit: 'text'}">销售价(元)</th>
+                                <th lay-data="{field:'number', edit: 'text'}">更改数量</th>
+                                <th lay-data="{field:'operation'}">操作</th>
+                            </tr>
+                        </thead>
+                        <tbody id="goods">
+                            
+                        </tbody>
+                    </table>
+                </div>
+                <div class="total ft16">
+                    合计:【<span> 当前总数量:<i class="totalNum">0</i> </span>
+                </div>
+                <div class="towbtn">
+                    <input type="button" id="settlement" value="确认设置">
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+</form>
+</div>
+<script>
+    var form;
+    layui.config(
+    {
+        base: '../script/lib/layui/admin/' //静态资源所在路径
+        ,version: true
+    }).extend(
+    {
+        index: 'lib/index', //主入口模块
+        formSelects: 'plugin/formselects/formselects'
+    }).use(['index', 'contlist', 'table', 'form', 'formSelects','layer'], function()
+    {
+        var table = layui.table;
+        form = layui.form; 
+        var formSelects = layui.formSelects;
+        $('#give').val('<{$give}>');
+        form.render(); 
+    });
+
+    $(function()
+    {
+        $("#settlement").click(function(){
+            var url = '<{$submit}>';
+            var role_id = '<{$role_id}>';
+            var give = $('#give').val();
+
+            layui.layer.confirm('确定进行此项设置吗?', function() {
+                var goods_string = JSON.stringify(goods);
+
+                var data = {};
+                data = {role_id:role_id, give:give, goods:goods_string};
+                $.post(url, data, function(t) {
+                    t = JSON.parse(t);
+                    if (t.status == 1) {
+                        layui.layer.alert('商品权益设置成功', function(index){
+                          location.reload();
+                          layer.close(index);
+                        });
+                    } else {
+                        layui.layer.alert(t.msg);
+                    }
+                });
+            });
+        })
+
+        $("#goods").on("keyup", ".goods_num", function() {
+            var num = parseInt($(this).val());
+            if (!num || num <= 0) {
+                num = 0;
+                $(this).val(0);
+            }
+            var id = $(this).parent().attr('value');
+            goods[id].total = num;
+            setTotal();
+        });
+    })
+    var goods = {};
+    var del_goods = {};
+    mini.parse();
+    var tree = mini.get("tree1");
+    for (var i in tree.data) {
+        if (typeof(tree.data[i].children) == 'object') {
+            if (tree.data[i].children.length > 0) {
+                for (var j in tree.data[i].children) {
+                    if(tree.data[i].children[j].select == 1) {
+                        setGoods(tree.data[i].children[j]);
+                    }
+                }
+            } else if(tree.data[i].select == 1) {
+                setGoods(tree.data[i]);
+            }
+        }
+    }
+    function search() 
+    {
+        var key = mini.get("key").getValue();
+        if (key == "") {
+            tree.clearFilter();
+        } else {
+            key = key.toLowerCase();                
+            tree.filter(function (node) {
+                var name = node.name ? node.name.toLowerCase() : "";
+                if (name.indexOf(key) != -1) {
+                    return true;
+                }
+            });
+        }
+    }
+    function onKeyEnter(e)
+    {
+        search();
+    }
+
+    function onNodeClick()
+    {
+        var tree=mini.get("tree1");
+        node=tree.getSelectedNode();
+        if(node.end) {
+            setGoods(node);
+        }
+    }
+
+    function setGoods(node)
+    {
+        if (node.id) {
+            var key = node.id;
+            if (!goods[key] || (goods[key] && goods[key].del == 2)) {
+                goods[key] = node;
+                goods[key].price = parseFloat(goods[key].price);
+                goods[key].price_type = parseInt(goods[key].price_type);
+                goods[key].total = parseFloat(goods[key].total);
+                goods[key].num = 0;
+                goods[key].del = 1;
+                create(node);
+                setTotal();
+            } else if(node.price_type < 4) {
+                add(key);
+            }
+        }
+    }
+
+    function get(key)
+    {
+        return $('#goods_' + key);
+    }
+
+    function create(node)
+    {
+        if (!get(node.id).length) {
+            var addtr = '<tr class="mytr" id="goods_'+node.id+'">';
+            addtr += '<td class="goods_id">'+node.id+'</td>';
+            addtr += '<td class="goods_name">'+node.name+'</td>';     
+            addtr += '<td class="goods_price">'+node.price+'</td>';     
+            addtr += '<td><div class="jiajian" value='+node.id+'><span class="jian" onclick="dec(\''+node.id+'\')">-</span><input type="text" value="'+node.total+'" class="goods_num"><span class="jia" onclick="add(\''+node.id+'\')">+</span></div></td>'; 
+            
+            if (node.total <= 0) {
+                addtr += '<td><a class="delete_btn" onclick="del(\''+node.id+'\')">删除</a></td>';
+            } else {
+                addtr += '<td></td>';
+            }
+                                  
+            addtr += '</tr>';
+            $("#goods").append(addtr);
+        }
+    }
+
+    function add(id)
+    {
+        goods[id].total += 1;
+        get(id).find('.goods_num').val(goods[id].total);
+        setTotal();
+    }
+    
+    function dec(id)
+    {
+        goods[id].total -= 1;
+        if (goods[id].total < 1) {
+            goods[id].total = 0;
+        }
+
+        get(id).find('.goods_num').val(goods[id].total);
+        setTotal();
+    }
+
+    function del(id)
+    {
+        if (confirm('确定删除吗?')) {
+            goods[id].del = 2;
+            get(id).remove();
+            setTotal();
+        }
+    }
+
+    function setTotal()
+    {
+        var cash = 0;
+        var num = 0;
+        var total = 0;
+        for (var i in goods) {
+            //num += goods[i].num;
+            total += goods[i].total;
+        }
+        //$(".totalQuantity").html(num);
+        $(".totalNum").html(total);
+    }
+
+    function setShop()
+    {
+        var give = $('#give').val();
+        if (!give) {
+            layui.layer.alert('请选择赠送类型');
+            return;
+        }
+        layui.layer.confirm('确定切换赠送类型吗?切换后现在选择的商品都将清空', function() {
+            location.href = '<{$host}>&give=' + give;
+        });
+    }
+</script>
+</body>
+</html>

+ 28 - 1
service/agent/database/order.php

@@ -65,6 +65,12 @@ $level = function()
 	return $array;
 };
 
+$order_type = array
+(
+    1 => '新购',
+    2 => '升级',
+);
+
 return array
 (
     # 表名
@@ -78,6 +84,7 @@ return array
     	'goods_status' => $goods_status,
     	'type' => $type,
     	'pay_type' => $pay_type,
+        'order_type' => $order_type,
     ),
     'order' => 99,
     # 数据结构
@@ -124,6 +131,16 @@ return array
             'list'      => true,
         ),
 
+        'order_type'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '订单类型',
+            'default'   => '1',
+            'desc'      => '订单类型',
+            'match'     => 'is_numeric',
+            'option'    => $order_type,
+        ),
+
         'mobile'      => array
         (
             'type'      => 'bigint-11',
@@ -191,6 +208,16 @@ return array
             'list'      => 'Dever::load("area/api.string", "{area}")',
         ),
 
+        'desc'      => array
+        (
+            'type'      => 'varchar-600',
+            'name'      => '付款备注',
+            'default'   => '',
+            'desc'      => '付款备注',
+            'match'     => 'is_string',
+            'update'    => 'text',
+        ),
+
         'price'      => array
         (
             'type'      => 'varchar-50',
@@ -375,7 +402,7 @@ return array
         'list_button' => array
         (
             //fast_list
-            'list' => array('查看详情', '"sell_order_goods&project=shop&order_id={id}&page_type=1"'),
+            'list' => array('查看详情', '"order_process&project=agent&order_id={id}&page_type=1"'),
 
             //'edit' => array('退款', 'status,tk_time,tk_pic,tk_desc,tk_admin,tk_status', '{status} == 6'),
             //'delete' => array('删除', '', '{status} == 1'),

+ 118 - 0
service/agent/database/order_goods.php

@@ -0,0 +1,118 @@
+<?php
+
+$type = array
+(
+	1 => '商品',
+	//2 => '体验卡',
+	//3 => '名额',
+);
+
+return array
+(
+    # 表名
+    'name' => 'role_goods',
+    # 显示给用户看的名称
+    'lang' => '商品权益',
+    'menu' => false,
+    'set' => array
+    (
+    	'type' => $type,
+    ),
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'update'    => 'hidden',
+            //'list'        => true,
+        ),
+
+        'order_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '订单表id',
+            'default'   => '',
+            'desc'      => '订单表id',
+            'match'     => 'is_numeric',
+        ),
+
+        'type'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '类型',
+            'default'   => '1',
+            'desc'      => '类型',
+            'match'     => 'is_numeric',
+            'update'  	=> 'radio',
+            'option'    => $type,
+        ),
+
+        'goods_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '商品名称',
+            'default'   => '-1',
+            'desc'      => '商品名称',
+            'match'     => 'is_numeric',
+            'list'      => 'Dever::load("goods/info-find#name", {goods_id})',
+        ),
+
+        'sku_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'sku_id',
+            'default'   => '-1',
+            'desc'      => 'sku_id',
+            'match'     => 'is_numeric',
+        ),
+
+        'num'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '数量',
+            'default'   => '',
+            'desc'      => '数量',
+            'match'     => 'is_numeric',
+            'search'    => 'select',
+            'list'        => true,
+        ),
+
+        'state'     => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '状态',
+            'default'   => '1',
+            'desc'      => '请选择状态',
+            'match'     => 'is_numeric',
+        ),
+        
+        'cdate'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '创建时间',
+            'match'     => array('is_numeric', time()),
+            'desc'      => '',
+            # 只有insert时才生效
+            //'insert'    => true,
+            'search'    => 'date',
+            'list'      => 'date("Y-m-d H:i:s", {cdate})',
+        ),
+    ),
+
+    'manage' => array
+    (
+        
+    ),
+
+    'request' => array
+    (
+        
+    ),
+);

+ 12 - 1
service/agent/database/order_process.php

@@ -119,6 +119,17 @@ return array
 
     'request' => array
     (
-        
+        'getData' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'order_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('status' => 'asc', 'cdate' => 'desc'),
+            'col' => '*',
+        ),
     ),
 );

+ 90 - 200
service/agent/lib/Order.php

@@ -293,7 +293,10 @@ class Order
 
         $info = Dever::db('agent/order')->one($id);
 
-        $process = Dever::db('agent/order_process')->getData($id);
+        $process = Dever::db('agent/order_process')->getData(array('order_id' => $id));
+
+        $role = Dever::db('setting/role')->one($info['role']);
+        $area = Dever::load("area/api.string", $info['area']);
 
         $status = $config['status'][$info['status']];
 
@@ -315,59 +318,6 @@ class Order
             $fdate = '';
         }
 
-        if (!$member) {
-            $user['username'] = '无';
-        }
-        if (!isset($user['truename'])) {
-            $user['truename'] = $user['username'];
-        }
-
-        if (!$info['coupon_cash']) {
-            $info['coupon_cash'] = 0;
-        }
-
-        if (!$info['kou_cash']) {
-            $info['kou_cash'] = 0;
-        }
-
-        if (!$info['ps_cash']) {
-            $info['ps_cash'] = 0;
-        }
-
-        if (!$info['wallet_cash']) {
-            $info['wallet_cash'] = 0;
-        }
-
-        if (!$info['card_code_cash']) {
-            $info['card_code_cash'] = 0;
-        }
-
-        if ($info['card_code_card']) {
-            $info['card_code_cash'] .= '('.$info['card_code_card'].')';
-        }
-
-        if ($tk && $tk['process'] == 1) {
-            $status = '申请' . $tk_status[$tk['status']];
-            $process = $tk_process[$tk['process']];
-            $process = '';
-        }
-
-        $time = array();
-        $time[] = array('下单时间', $cdate);
-
-        if ($opertime) {
-            if ($info['status'] == 2) {
-                $time[] = array('通知时间', $opertime);
-            }
-            if ($info['status'] == 7) {
-                $time[] = array('取消时间:', $opertime);
-            }
-        }
-
-        if ($fdate) {
-            $time[] = array('完成时间:', $fdate);
-        }
-
         $result = array();
 
         $result[$info['order_num']] = array
@@ -378,201 +328,141 @@ class Order
                 array
                 (
                     array('订单状态', $status),
-                    array('支付方式', $config['pay_method'][$info['pay_method']]),
-                    array('配送方式', $config['method'][$info['method']]),
+                    array('申请日期', $cdate),
                 ),
-                
+            )
+        );
+
+        $info['sign'] = 'https://www.ysbang.cn/images/ysb_logo.png';
+        $idcard_pic = '<a href="'.$info['idcard_front'].'" target="_blank"><img src="'.$info['idcard_front'].'" width="150" /></a>';
+        if ($info['idcard_back']) {
+            $idcard_pic .= '&nbsp;&nbsp;<a href="'.$info['idcard_back'].'" target="_blank"><img src="'.$info['idcard_back'].'" width="150" /></a>';
+        }
+        $sign_pic = '<a href="'.$info['sign'].'" target="_blank"><img src="'.$info['sign'].'" width="150" /></a>';
+
+        $pay_pic = '';
+        if ($info['pay_pic']) {
+            $pay_pic = '&nbsp;&nbsp;<a href="'.$info['pay_pic'].'" target="_blank"><img src="'.$info['pay_pic'].'" width="150" /></a>';
+        }
+
+        $result['账号信息'] = array
+        (
+            'type' => 'info',
+            'content' => array
+            (
                 array
                 (
-                    array('门店名称', $shop['name']),
-                    array('联系人', $shop['truename']),
-                    array('联系电话', $shop['mobile']),
+                    array('手机号', $info['mobile']),
+                    array('类型', $config['type'][$info['type']]),
+                    array('名称', $info['name']),
                 ),
 
                 array
                 (
-                    array('下单用户', $user['username']),
-                    array('联系电话', $info['mobile']),
-                    array('订单备注', $info['info']),
+                    array('证件号码', $info['idcard']),
+                    array('证件照片', $idcard_pic),
                 ),
 
                 array
                 (
-                    array('支付金额', '¥ ' . round($info['price'], 2)),
-                    array('优惠券满减', '¥ ' . $info['coupon_cash']),
-                    array('配送费', '¥ ' . $info['ps_cash']),
+                    array('代理角色', $role['name']),
+                    array('代理区域', $area),
+                    array('注意', '赠送区域无权益'),
                 ),
 
                 array
                 (
-                    array('礼品卡抵扣', '¥ ' . round($info['card_code_cash'], 2)),
-                    array('钱包抵扣', '¥ ' . round($info['wallet_cash'], 2)),
-                    array('抹零', '¥ ' . round($info['kou_cash'], 2)),
+                    array('代理商签名', $sign_pic),
                 ),
-
-                $time,
-            )
+            ),
         );
 
-        if ($info['address_id'] > 0) {
-            $address = Dever::load('passport/address')->getOne($info['uid'], $info['address_id']);
-
-            if ($address) {
-
-                $result['收货地址'] = array
+        $result['支付信息'] = array
+        (
+            'type' => 'info',
+            'content' => array
+            (
+                array
                 (
-                    'type' => 'info',
-                    'content' => array
-                    (
-                        array
-                        (
-                            array('联系人', $address['contact']),
-                            array('联系电话', $address['mobile']),
-                        ),
-
-                        array
-                        (
-                            array('收货地址', $address['address']),
-                            array('门牌号', $address['house_number']),
-                        ),
-                    ),
-                );
-            }
-        }
-
-        
-        if ($info['invoice_id'] > 0) {
-            $invoice = Dever::load('passport/invoice')->getOne($info['uid'], $info['invoice_id']);
-
-            if ($invoice) {
+                    array('支付方式', $config['pay_type'][$info['pay_type']]),
+                    array('支付金额', '¥' . $info['price'] . '元'),
+                    array('系统查询', $config['pay_status'][$info['pay_status']]),
+                ),
 
-                $result['发票信息'] = array
+                array
                 (
-                    'type' => 'info',
-                    'content' => array
-                    (
-                        array
-                        (
-                            array('发票类型', $invoice['title_type_name']),
-                            array('抬头', $invoice['title']),
-                            array('税号', $invoice['number']),
-                        ),
-
-                        array
-                        (
-                            array('手机号', $invoice['mobile']),
-                            array('邮箱', $invoice['email']),
-                        ),
-                    ),
-                );
-            }
-        }
-
-
-        if (!$info['refund_cash']) {
-            $info['refund_cash'] = 0;
-        }
-
-        if ($info['refund_cash'] > 0 && $tk) {
-            $process = $tk_process[$tk['process']];
-            $tk['cdate'] = date('Y-m-d H:i', $tk['cdate']);
-            $result['退款信息'] = array
+                    array('付款备注', $info['desc']),
+                    array('支付凭证', $pay_pic),
+                ),
+            ),
+        );
+        
+        if ($parent_member) {
+            # 这里要获取上级信息
+            $result['分润信息'] = array
             (
                 'type' => 'info',
                 'content' => array
                 (
                     array
                     (
-                        array('退款金额', $info['refund_cash']),
-                        array('数量', $info['num']),
-                        array('退款进度', $process),
+                        array('支付方式', $config['pay_type'][$info['pay_type']]),
+                        array('支付金额', '¥' . $info['price'] . '元'),
+                        array('系统查询', $config['pay_status'][$info['pay_status']]),
                     ),
 
                     array
                     (
-                        array('申请时间', $tk['cdate']),
-                        array('退款原因', $tk['desc']),
+                        array('付款备注', $info['desc']),
+                        array('支付凭证', $pay_pic),
                     ),
                 ),
             );
         }
 
-        $body = $refund_body = array();
-        $body_total = array();
-        $body_total['price'] = 0;
-        $body_total['num'] = 0;
-
-        $refund_body_total = array();
-        $refund_body_total['price'] = 0;
-        $refund_body_total['num'] = 0;
-
-        $goods = Dever::db('shop/sell_order_goods')->select(array('order_id' => $info['id']));
-        $goods_status = Dever::db('shop/sell_order_goods')->config['status'];
-
-        foreach ($goods as $k => $v) {
-            $goods_info = Dever::load('goods/lib/info')->getInfoBySku($v['goods_id'], $v['sku_id']);
-            $status = $goods_status[$v['status']];
-            $tk = Dever::db('shop/sell_order_refund')->find(array('order_id' => $info['id'], 'order_goods_id' => $v['id'], 'type' => 2));
-            if ($tk && $tk['process'] == 1) {
-                $status = '申请' . $tk_status[$tk['status']];
-                //$status .= '&nbsp;&nbsp;[' . $tk_process[$tk['process']] . ']';
-            }
-            if (isset($goods_info['sku'])) {
-                $sku = $goods_info['sku']['string'];
-            } else {
-                $sku = '无';
-            }
+        //$goods = Dever::db('setting/role_goods')->select(array('role_id' => $info['role'], 'give' => $info['order_type']));
 
-            $d = array
-            (
-                'pic' => $goods_info['cover'],
-                'name' => $goods_info['name'],
-                'sku' => $sku,
-                'price' => $v['price'],
-                'num' => $v['num'],
-                'status' => $status,
-            );
+        $goods = Dever::db('agent/order_goods')->select(array('order_id' => $info['id']));
+        if ($goods) {
+            foreach ($goods as $k => $v) {
+                $goods_info = Dever::load('goods/lib/info')->getInfoBySku($v['goods_id'], $v['sku_id']);
+                if (isset($goods_info['sku'])) {
+                    $sku = $goods_info['sku']['string'];
+                } else {
+                    $sku = '无';
+                }
+                $del = Dever::url('order_tui?order_goods_id=' . $v['id'] . '&order_id=' . $info['id'] . '&type=13', 'factory');
 
-            if ($tk && $v['status'] == 3) {
-                $d['status'] = $tk_status[$tk['status']];
-                $refund_body[] = $d;
-                $price = $v['price']*$v['num'];
-                $refund_body_total['price'] += $price;
-                $refund_body_total['num'] += $v['num'];
-            } else {
-                $body[] = $d;
-                $price = $v['price']*$v['num'];
-                $body_total['price'] += $price;
-                $body_total['num'] += $v['num'];
-            }
-        }
+                $status = '<a href="javascript:;" onclick="audit('.$tk['id'].', 2, \''.$url.'\')" class="layui-btn">删除</a>';
 
-        if ($body) {
-            if ($refund_body_total['price']) {
-                $body_total['set_price'] = $body_total['price'] - $refund_body_total['price'];
-            }
-            if ($refund_body_total['num']) {
-                $body_total['set_num'] = $body_total['num'] - $refund_body_total['num'];
+                $d = array
+                (
+                    'pic' => $goods_info['cover'],
+                    'name' => $goods_info['name'],
+                    'sku' => $sku,
+                    'price' => $goods_info['price'],
+                    'num' => $v['num'],
+                    'status' => $status,
+                );
+                $body[] = $d;
             }
 
-            $result['商品清单'] = array
+            $result['权益信息'] = array
             (
                 'type' => 'list',
                 'content' => $body,
-                'total' => $body_total,
             );
-        }
-
-        if ($refund_body) {
-            $result['退款商品'] = array
+        } else {
+            $result['权益信息'] = array
             (
-                'type' => 'list',
-                'content' => $refund_body,
-                'total' => $refund_body_total,
+                'type' => 'button',
+                'content' => array
+                (
+                    array('发放权益', $config['pay_type'][$info['pay_type']]),
+                ),
             );
         }
         
-
         $head = array
         (
             'name' => '基本信息',

+ 88 - 0
service/agent/lib/Set.php

@@ -0,0 +1,88 @@
+<?php
+
+namespace Agent\Lib;
+
+use Dever;
+
+# 批量设置商品
+class Set
+{
+	public function __construct()
+    {
+        Dever::load('manage/auth.init');
+    }
+
+    # 获取商品列表
+    public function goods_api()
+    {
+        $id = Dever::input('id', 1);
+        return Dever::outDiy(Dever::load('goods/lib/set.getGoodsList', $id, 'role_id', 'setting/role_goods'));
+    }
+
+    # 设置商品
+    public function home_api()
+    {
+        $data = array();
+        $data['role_id'] = Dever::input('id', 1);
+        $data['give'] = Dever::input('give', 1);
+        $data['host'] = Dever::url('lib/set.home?id=' . $data['role_id'], 'agent');
+        $data['url'] = Dever::url('lib/set.goods?id=' . $data['role_id'] . '&give=' . $data['give'], 'agent');
+        $data['search'] = Dever::db('setting/role_goods')->config['set']['give'];
+        $data['submit'] = Dever::url('lib/set.action_cmmmit?json=1', 'agent');
+
+        return Dever::render('setGoods', $data);
+    }
+
+    # 设置生产能力
+    public function action_cmmmit_api()
+    {
+        $goods = Dever::input('goods');
+        if (!$goods) {
+            Dever::alert('请传入商品');
+        }
+        $goods = Dever::json_decode($goods);
+        $role_id = Dever::input('role_id');
+        $give = Dever::input('give');
+
+        $where['option_role_id'] = $role_id;
+        $where['option_give'] = $give;
+        $where['set_state'] = 2;
+        Dever::db('setting/role_goods')->updates($where);
+
+        foreach ($goods as $k => $v) {
+            $temp = explode('-', $k);
+            $goods_id = $temp[0];
+            if (isset($temp[1])) {
+                $sku_id = $temp[1];
+            } else {
+                $sku_id = -1;
+            }
+            if ($v['total'] <= 0) {
+            	continue;
+            }
+            $w = array();
+            $w['goods_id'] = $goods_id;
+            $w['role_id'] = $role_id;
+            $w['sku_id'] = $sku_id;
+            $w['give'] = $give;
+            $info = Dever::db('setting/role_goods')->one($w);
+            if ($v['del'] == 2) {
+                if ($info) {
+                    Dever::db('setting/role_goods')->update(array('where_id' => $info['id'], 'state' => 2));
+                }
+            } else {
+            	$w['num'] = $v['total'];
+                
+                if (!$info) {
+                    Dever::db('setting/role_goods')->insert($w);
+                } else {
+                    $w['where_id'] = $info['id'];
+                    $w['state'] = 1;
+                    Dever::db('setting/role_goods')->update($w);
+                }
+            }
+        }
+
+        return 'reload';
+    }
+}

+ 6 - 2
service/setting/database/role.php

@@ -183,9 +183,13 @@ return array
         (
         	'fast' => array('编辑', '"role&where_id={id}&oper_save_jump=role&oper_table=role&oper_parent=role&area={area}"'),
 
-        	'list1' => array('奖励', '"role_reward&search_option_role_id={id}&oper_table=role"'),
+        	'list1' => array('推荐奖励', '"role_reward&search_option_role_id={id}&oper_table=role"'),
 
-        	//'list2' => array('权益', '"role_goods&search_option_role_id={id}&oper_table=role"'),
+        	//'list2' => array('商品权益', '"role_goods&search_option_role_id={id}&oper_table=role"'),
+
+            'location1' => array('商品权益', Dever::url('lib/set.home', 'agent')),
+
+            //'list3' => array('名额权益', '"role_quota&search_option_role_id={id}&oper_table=role"'),
         )
     ),
 

+ 145 - 0
service/setting/database/role_goods.php

@@ -0,0 +1,145 @@
+<?php
+
+$role = function()
+{
+    $info = Dever::db('setting/role')->select();
+    return $info;
+};
+
+$give = array
+(
+	1 => '新购赠送',
+	2 => '升级赠送',
+);
+
+$type = array
+(
+	1 => '商品',
+	//2 => '体验卡',
+);
+
+return array
+(
+    # 表名
+    'name' => 'role_goods',
+    # 显示给用户看的名称
+    'lang' => '商品权益',
+    'menu' => false,
+    'set' => array
+    (
+    	'give' => $give,
+    	'type' => $type,
+    ),
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'update'    => 'hidden',
+            //'list'        => true,
+        ),
+
+        'role_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '代理商角色',
+            'default'   => '',
+            'desc'      => '代理商角色',
+            'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'search'    => 'hidden',
+            'value'     => Dever::input('search_option_role_id'),
+            'list'      => 'Dever::load("setting/role-one#name", {role_id})',
+        ),
+
+        'type'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '类型',
+            'default'   => '1',
+            'desc'      => '类型',
+            'match'     => 'is_numeric',
+            'update'  	=> 'radio',
+            'option'    => $type,
+        ),
+
+        'give'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '赠送',
+            'default'   => '1',
+            'desc'      => '赠送',
+            'match'     => 'is_numeric',
+            'update'  	=> 'radio',
+            'option'    => $give,
+        ),
+
+        'goods_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '商品名称',
+            'default'   => '-1',
+            'desc'      => '商品名称',
+            'match'     => 'is_numeric',
+            'list'      => 'Dever::load("goods/info-find#name", {goods_id})',
+        ),
+
+        'sku_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'sku_id',
+            'default'   => '-1',
+            'desc'      => 'sku_id',
+            'match'     => 'is_numeric',
+        ),
+
+        'num'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '数量',
+            'default'   => '',
+            'desc'      => '数量',
+            'match'     => 'is_numeric',
+            'search'    => 'select',
+            'list'        => true,
+        ),
+
+        'state'     => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '状态',
+            'default'   => '1',
+            'desc'      => '请选择状态',
+            'match'     => 'is_numeric',
+        ),
+        
+        'cdate'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '创建时间',
+            'match'     => array('is_numeric', time()),
+            'desc'      => '',
+            # 只有insert时才生效
+            //'insert'    => true,
+            'search'    => 'date',
+            'list'      => 'date("Y-m-d H:i:s", {cdate})',
+        ),
+    ),
+
+    'manage' => array
+    (
+        
+    ),
+
+    'request' => array
+    (
+        
+    ),
+);