rabin 7 月之前
父節點
當前提交
e32e13d263
共有 58 個文件被更改,包括 1077 次插入89 次删除
  1. 2 2
      package/manage/index.html
  2. 2 2
      package/manage/sector.html
  3. 1 1
      package/manage/static/css/213.89045697.css
  4. 1 1
      package/manage/static/css/780.4065063c.css
  5. 1 1
      package/manage/static/css/app.d065fbce.css
  6. 1 1
      package/manage/static/css/vab-chunk-c6f52c3a.c8416701.css
  7. 1 1
      package/manage/static/css/vab-plugins.f6f5c03c.css
  8. 1 1
      package/manage/static/js/213.c4b735c6.js
  9. 1 1
      package/manage/static/js/592.41e25131.js
  10. 1 1
      package/manage/static/js/780.f3d655d2.js
  11. 1 1
      package/manage/static/js/962.faf0c7f7.js
  12. 0 1
      package/manage/static/js/app.4138775c.js
  13. 1 1
      package/manage/static/js/vab-chunk-0b9a05e8.3a2acba3.js
  14. 1 1
      package/manage/static/js/vab-chunk-54e012b3.75c10119.js
  15. 1 1
      package/manage/static/js/vab-chunk-844ca20f.8fd468cb.js
  16. 1 1
      package/manage/static/js/vab-chunk-b3a4eaa1.509e2c01.js
  17. 0 5
      package/manage/static/js/vab-chunk-c6f52c3a.079f4300.js
  18. 5 0
      package/manage/static/js/vab-chunk-c6f52c3a.71b8757d.js
  19. 5 0
      package/manage/static/js/vab-plugins.9a805736.js
  20. 0 5
      package/manage/static/js/vab-plugins.fa8bceb3.js
  21. 164 0
      src/place/api/Client.php
  22. 1 2
      src/place/api/Url.php
  23. 22 12
      src/place/boot.php
  24. 114 0
      src/place/lib/Client.php
  25. 2 0
      src/place/lib/Main.php
  26. 45 0
      src/place/lib/Manage.php
  27. 122 0
      src/place/lib/Resource.php
  28. 0 21
      src/place/lib/Util.php
  29. 3 3
      src/place/manage/agent.php
  30. 30 0
      src/place/manage/client.php
  31. 30 0
      src/place/manage/client_price.php
  32. 28 3
      src/place/manage/info.php
  33. 3 3
      src/place/manage/vip.php
  34. 39 0
      src/place/table/client.php
  35. 34 0
      src/place/table/client_price.php
  36. 56 0
      src/place/table/client_resource.php
  37. 39 0
      src/place/table/client_sell.php
  38. 12 0
      src/place/table/info.php
  39. 7 0
      src/place/table/member.php
  40. 56 0
      src/place/table/resource_relation.php
  41. 2 2
      src/resource/content/lib/Info.php
  42. 2 2
      src/resource/content/manage/agent_price.php
  43. 25 0
      src/resource/content/manage/client_price.php
  44. 1 1
      src/resource/content/manage/core.php
  45. 39 2
      src/resource/content/manage/info.php
  46. 1 1
      src/resource/content/manage/vip_price.php
  47. 33 0
      src/resource/content/table/client_price.php
  48. 12 0
      src/resource/content/table/info.php
  49. 5 2
      src/resource/goods/lib/Info.php
  50. 3 3
      src/resource/goods/manage/agent_price.php
  51. 25 0
      src/resource/goods/manage/client_price.php
  52. 1 1
      src/resource/goods/manage/core.php
  53. 32 2
      src/resource/goods/manage/info.php
  54. 1 1
      src/resource/goods/manage/vip_price.php
  55. 33 0
      src/resource/goods/table/client_price.php
  56. 12 0
      src/resource/goods/table/info.php
  57. 5 0
      src/sector/manage/user.php
  58. 11 0
      src/sector/table/user.php

+ 2 - 2
package/manage/index.html

@@ -1,5 +1,5 @@
-<!doctype html><html lang="zh-cmn-Hans"><head><meta charset="utf-8"/><meta content="IE=edge" http-equiv="X-UA-Compatible"/><meta content="webkit" name="renderer"/><meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport"/><link href="favicon.ico" rel="icon"/><title>Dever Manage</title><meta content="Dever,PHP,PHP框架,轻量,微服务,组件化,接口,低代码,后台,自定义后台,开发,快速开发,AI,人工智能,文档,轻应用,应用,时空之翼,神秘城" name="keywords"/><meta content="rabin@shemic.com" name="author"/><link href="static/css/loading.css?random=2024-08-06 12:35:57-shemic" rel="stylesheet"/><script>document.write(
+<!doctype html><html lang="zh-cmn-Hans"><head><meta charset="utf-8"/><meta content="IE=edge" http-equiv="X-UA-Compatible"/><meta content="webkit" name="renderer"/><meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport"/><link href="favicon.ico" rel="icon"/><title>Dever Manage</title><meta content="Dever,PHP,PHP框架,轻量,微服务,组件化,接口,低代码,后台,自定义后台,开发,快速开发,AI,人工智能,文档,轻应用,应用,时空之翼,神秘城" name="keywords"/><meta content="rabin@shemic.com" name="author"/><link href="static/css/loading.css?random=2024-08-13 17:55:24-shemic" rel="stylesheet"/><script>document.write(
         "<script type='text/javascript' src='config.js?" +
           Math.random() +
           "'><\/script>"
-      )</script><script defer="defer" src="static/js/app.76a45ca5.js"></script><script defer="defer" src="static/js/213.1c59bfaf.js"></script><link href="static/css/app.d065fbce.css" rel="stylesheet"><link href="static/css/213.89045697.css" rel="stylesheet"></head><body><noscript></noscript><div id="app"><div class="first-loading-wrp"><div class="loading-wrp"><span class="dot dot-spin"><i></i> <i></i> <i></i> <i></i></span></div><h1>Dever Manage</h1></div></div></body></html>
+      )</script><script defer="defer" src="static/js/app.4138775c.js"></script><script defer="defer" src="static/js/213.c4b735c6.js"></script><link href="static/css/app.d065fbce.css" rel="stylesheet"><link href="static/css/213.89045697.css" rel="stylesheet"></head><body><noscript></noscript><div id="app"><div class="first-loading-wrp"><div class="loading-wrp"><span class="dot dot-spin"><i></i> <i></i> <i></i> <i></i></span></div><h1>Dever Manage</h1></div></div></body></html>

+ 2 - 2
package/manage/sector.html

@@ -1,5 +1,5 @@
-<!doctype html><html lang="zh-cmn-Hans"><head><meta charset="utf-8"/><meta content="IE=edge" http-equiv="X-UA-Compatible"/><meta content="webkit" name="renderer"/><meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport"/><link href="favicon.ico" rel="icon"/><title>Dever Manage</title><meta content="Dever,PHP,PHP框架,轻量,微服务,组件化,接口,低代码,后台,自定义后台,开发,快速开发,AI,人工智能,文档,轻应用,应用,时空之翼,神秘城" name="keywords"/><meta content="rabin@shemic.com" name="author"/><link href="static/css/loading.css?random=2024-08-06 12:35:57-shemic" rel="stylesheet"/><script>document.write(
+<!doctype html><html lang="zh-cmn-Hans"><head><meta charset="utf-8"/><meta content="IE=edge" http-equiv="X-UA-Compatible"/><meta content="webkit" name="renderer"/><meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport"/><link href="favicon.ico" rel="icon"/><title>Dever Manage</title><meta content="Dever,PHP,PHP框架,轻量,微服务,组件化,接口,低代码,后台,自定义后台,开发,快速开发,AI,人工智能,文档,轻应用,应用,时空之翼,神秘城" name="keywords"/><meta content="rabin@shemic.com" name="author"/><link href="static/css/loading.css?random=2024-08-13 17:55:24-shemic" rel="stylesheet"/><script>document.write(
         "<script type='text/javascript' src='sector_config.js?" +
           Math.random() +
           "'><\/script>"
-      )</script><script defer="defer" src="static/js/app.76a45ca5.js"></script><script defer="defer" src="static/js/213.1c59bfaf.js"></script><link href="static/css/app.d065fbce.css" rel="stylesheet"><link href="static/css/213.89045697.css" rel="stylesheet"></head><body><noscript></noscript><div id="app"><div class="first-loading-wrp"><div class="loading-wrp"><span class="dot dot-spin"><i></i> <i></i> <i></i> <i></i></span></div><h1>Dever Manage</h1></div></div></body></html>
+      )</script><script defer="defer" src="static/js/app.4138775c.js"></script><script defer="defer" src="static/js/213.c4b735c6.js"></script><link href="static/css/app.d065fbce.css" rel="stylesheet"><link href="static/css/213.89045697.css" rel="stylesheet"></head><body><noscript></noscript><div id="app"><div class="first-loading-wrp"><div class="loading-wrp"><span class="dot dot-spin"><i></i> <i></i> <i></i> <i></i></span></div><h1>Dever Manage</h1></div></div></body></html>

File diff suppressed because it is too large
+ 1 - 1
package/manage/static/css/213.89045697.css


File diff suppressed because it is too large
+ 1 - 1
package/manage/static/css/780.4065063c.css


File diff suppressed because it is too large
+ 1 - 1
package/manage/static/css/app.d065fbce.css


File diff suppressed because it is too large
+ 1 - 1
package/manage/static/css/vab-chunk-c6f52c3a.c8416701.css


File diff suppressed because it is too large
+ 1 - 1
package/manage/static/css/vab-plugins.f6f5c03c.css


File diff suppressed because it is too large
+ 1 - 1
package/manage/static/js/213.c4b735c6.js


File diff suppressed because it is too large
+ 1 - 1
package/manage/static/js/592.41e25131.js


File diff suppressed because it is too large
+ 1 - 1
package/manage/static/js/780.f3d655d2.js


File diff suppressed because it is too large
+ 1 - 1
package/manage/static/js/962.faf0c7f7.js


File diff suppressed because it is too large
+ 0 - 1
package/manage/static/js/app.4138775c.js


File diff suppressed because it is too large
+ 1 - 1
package/manage/static/js/vab-chunk-0b9a05e8.3a2acba3.js


File diff suppressed because it is too large
+ 1 - 1
package/manage/static/js/vab-chunk-54e012b3.75c10119.js


File diff suppressed because it is too large
+ 1 - 1
package/manage/static/js/vab-chunk-844ca20f.8fd468cb.js


File diff suppressed because it is too large
+ 1 - 1
package/manage/static/js/vab-chunk-b3a4eaa1.509e2c01.js


File diff suppressed because it is too large
+ 0 - 5
package/manage/static/js/vab-chunk-c6f52c3a.079f4300.js


File diff suppressed because it is too large
+ 5 - 0
package/manage/static/js/vab-chunk-c6f52c3a.71b8757d.js


File diff suppressed because it is too large
+ 5 - 0
package/manage/static/js/vab-plugins.9a805736.js


File diff suppressed because it is too large
+ 0 - 5
package/manage/static/js/vab-plugins.fa8bceb3.js


+ 164 - 0
src/place/api/Client.php

@@ -0,0 +1,164 @@
+<?php namespace Place\Api;
+use Dever;
+use Place;
+use Place\Lib\Main;
+class Client extends Main
+{
+    protected $login = true;
+    protected $entry = true;
+
+    public function __construct()
+    {
+        parent::__construct();
+        # 查询当前源主界面是否有进货功能
+        if (Place::$info['channel'] != 1) {
+            Dever::error('渠道信息获取失败');
+        }
+    }
+
+    # 检测是否绑定源主
+    private function check($type = 1)
+    {
+        if ($type == 2) {
+            if (Place::$user['client_id'] <= 0) {
+                Dever::error('您还未绑定源主');
+            }
+            $user = Dever::db('user', 'sector')->find(Place::$uid);
+            $mobile = $user['mobile'];
+        } else {
+            $mobile = Dever::input('mobile', 'is_numeric', '手机号');
+            if (Place::$user['client_id'] > 0) {
+                Dever::error('您已经绑定过了,请先解绑再来吧');
+            }
+        }
+        return $mobile;
+    }
+
+    # 发送绑定短信验证码
+    public function sms()
+    {
+        $type = Dever::input('type', 'is_numeric', '类型', 1);
+        $mobile = $this->check($type);
+        $data = Dever::load('template', 'msg')->send('user_code', array('mobile' => $mobile));
+        return $data;
+    }
+
+    # 绑定源主
+    public function bind()
+    {
+        $mobile = $this->check();
+        $code = Dever::input('code', 'is_string', '验证码');
+        Dever::load('template', 'msg')->check('user_code', $mobile, $code);
+        $user = Dever::db('user', 'sector')->find(array('mobile' => $mobile, 'status' => 1));
+        if (!$user) {
+            Dever::error('您绑定的手机号未开通源主');
+        }
+        $data = array('client_id' => $user['id']);
+        $member = Dever::db('member', 'place')->find($data);
+        if ($member) {
+            Dever::error('手机号已绑定源主,您无法绑定');
+        }
+        Dever::db('member', 'place')->update(Place::$uid, $data);
+        Place::$user['client_id'] = $data['client_id'];
+        return Place::$user;
+    }
+
+    # 解绑源主
+    public function unbind()
+    {
+        $mobile = $this->check(2);
+        $code = Dever::input('code', 'is_string', '验证码');
+        Dever::load('template', 'msg')->check('user_code', $mobile, $code);
+        Dever::db('member', 'place')->update(Place::$uid, array('client_id' => -1));
+    }
+
+    # 点击进货按钮
+    public function submit()
+    {
+        if (Place::$user['client_id'] <= 0) {
+            Dever::error('您不是源主');
+        }
+        $where = array('uid' => Place::$user['client_id']);
+        if (Place::$user['client_id'] == Place::$info['uid']) {
+            $where['id'] = array('!=', Place::$id);
+        }
+        # 获取源主的身份
+        $data['place'] = Dever::db('info', 'place')->select($where, array('col' => 'id, name'));
+        if (!$data['place']) {
+            Dever::error('请先创建身份');
+        }
+        $type = Dever::input('type', 'is_numeric', '资源类型');
+        $type_id = Dever::input('type_id', 'is_numeric', '资源ID');
+        $resource = new \Place\Lib\Resource($type);
+        $data['info'] = $resource->getInfo($type_id);
+        $data['info'] = Dever::load('info', $resource->app)->submit($data['info'], 'client');
+        return $data;
+    }
+
+    # 确定进货或者修改进货
+    public function act_commit(){}
+    public function act()
+    {
+        if (Place::$user['client_id'] <= 0) {
+            Dever::error('您不是源主');
+        }
+        
+        $data['uid'] = Place::$uid;
+        $data['client_id'] = Place::$user['client_id'];
+        $data['type'] = Dever::input('type', 'is_numeric', '资源类型');
+        $data['type_id'] = Dever::input('type_id', 'is_numeric', '资源ID');
+
+        $info = Dever::db('client_resource', 'place')->find($data);
+
+        $data['status'] = 1;
+        $data['place_id'] = Dever::input('place_id', 'is_string', '身份ID');
+        $temp = explode(',', $data['place_id']);
+        $where = array('id' => array('in', $data['place_id']), 'uid' => Place::$user['client_id']);
+        if (Place::$user['client_id'] == Place::$info['uid']) {
+            $where['id#'] = array('!=', Place::$id);
+        }
+        $place = Dever::db('info', 'place')->select($where);
+        if (count($place) != count($temp)) {
+            Dever::error('身份不存在');
+        }
+
+        $resource = new \Place\Lib\Resource($data['type']);
+        $resource_info = $resource->getInfo($data['type_id']);
+        $data['price'] = $resource_info['client']['value'];
+        $resource_info['price'] = $resource_info['price']['value'];
+        $resource_info['status'] = 2;
+        unset($resource_info['cdate']);
+        unset($resource_info['cdate_str']);
+        unset($resource_info['client']);
+        unset($resource_info['password']);
+
+        if ($info) {
+            Dever::db('client_resource', 'place')->update($info['id'], $data);
+        } else {
+            Dever::db('client_resource', 'place')->insert($data);
+        }
+        # 同时同步源主里的内容信息
+        Dever::load('client', 'place')->resource($place, $data, $resource, $resource_info);
+        return 'ok';
+    }
+
+    # 取消进货
+    public function cancel_commit(){}
+    public function cancel()
+    {
+        if (Place::$user['client_id'] <= 0) {
+            Dever::error('您不是源主');
+        }
+        $data['uid'] = Place::$uid;
+        $data['client_id'] = Place::$user['client_id'];
+        $data['type'] = Dever::input('type', 'is_numeric', '资源类型');
+        $data['type_id'] = Dever::input('type_id', 'is_numeric', '资源ID');
+        $info = Dever::db('client_resource', 'place')->find($data);
+        if ($info) {
+            # 同时删除源主里的内容信息
+            Dever::load('client', 'place')->resourceDel($info['place_id'], $data);
+            Dever::db('client_resource', 'place')->update($info['id'], array('status' => 2));
+        }
+        return 'ok';
+    }
+}

+ 1 - 2
src/place/api/Url.php

@@ -1,9 +1,8 @@
 <?php namespace Place\Api;
 use Dever;
 use Place;
-use Place\Lib\Main;
 use Dever\Helper\Secure;
-class Url extends Main
+class Url
 {
     public function place()
     {

+ 22 - 12
src/place/boot.php

@@ -7,11 +7,15 @@ class Place
     public static $resource;
     public static $uid;
     public static $code;
+    public static $system;
+    public static $sector;
+    public static $module;
+    public static $id;
 
     public static function entry($sector_id, $module_id, $user_id, $place_id)
     {
-        $Main = \Dever\Helper\Secure::encode($sector_id . '-' . $module_id . '-' . $user_id . '-' . $place_id);
-        return $Main;
+        $code = \Dever\Helper\Secure::encode($sector_id . '-' . $module_id . '-' . $user_id . '-' . $place_id);
+        return $code;
     }
 
     # 初始化
@@ -23,20 +27,20 @@ class Place
             Dever::error('身份码错误');
         }
         list($sector_id, $module_id, $user_id, $place_id) = explode('-', $code);
-        $system = Dever::db('system', 'manage')->find(array('key' => 'sector'));
-        $sector = Dever::db($system['info_table'])->find($sector_id);
-        if (!$sector) {
+        self::$system = Dever::db('system', 'manage')->find(array('key' => 'sector'));
+        self::$sector = Dever::db(self::$system['info_table'])->find($sector_id);
+        if (!self::$sector) {
             Dever::error('领域信息错误');
         }
         # 切换数据库
-        Dever::load('common', 'manage')->setAuth($system['partition'], $system['id'], $sector_id, $module_id, $user_id);
+        Dever::load('common', 'manage')->setAuth(self::$system['partition'], self::$system['id'], self::$sector['id'], $module_id, $user_id);
 
         # 初始化身份
-        self::info($place_id);
+        self::info($user_id, $place_id);
 
         # 切换数据库
-        $module = Dever::db('system_module', 'manage')->find(array('key' => 'sector_place'));
-        Dever::load('common', 'manage')->setAuth($system['partition'], $system['id'], $sector_id, $module['id'], $place_id);
+        self::$module = Dever::db('system_module', 'manage')->find(array('key' => 'sector_place'));
+        Dever::load('common', 'manage')->setAuth(self::$system['partition'], self::$system['id'], self::$sector['id'], self::$module['id'], $place_id);
 
         # 初始化资源
         self::resource();
@@ -44,18 +48,24 @@ class Place
     }
 
     # 身份信息
-    public static function info($place_id)
+    public static function info($user_id, $place_id)
     {
-        self::$info = Dever::db('info', 'place')->find($place_id, array('col' => 'name,logo,content,score as score_name,score_per,bg,type,vip_name,agent_name,money_id'));
+        $user = Dever::db('user', 'sector')->find($user_id);
+        self::$info = Dever::db('info', 'place')->find($place_id, array('col' => 'name,logo,content,score as score_name,score_per,bg,type,vip_name,agent_name,money_id,uid'));
         if (!self::$info) {
             Dever::error('信息有误');
         }
+        if (self::$info['uid'] != $user['id']) {
+            Dever::error('信息有误');
+        }
         if (!self::$info['vip_name']) {
             self::$info['vip_name'] = '会员';
         }
         if (!self::$info['agent_name']) {
             self::$info['agent_name'] = '代理';
         }
+        self::$id = $place_id;
+        self::$info['channel'] = $user['channel'];
         self::$info['content'] = htmlspecialchars_decode(self::$info['content']);
         $money = Dever::db('money', 'sector')->find(self::$info['money_id']);
         self::$info['money_name'] = $money['sign'];
@@ -70,7 +80,7 @@ class Place
     # 用户信息
     public static function user($uid)
     {
-        self::$user = Dever::db('member', 'place')->find($uid, array('col' => 'id,name,avatar,cash,score_cash,vip_id,agent_id'));
+        self::$user = Dever::db('member', 'place')->find($uid, array('col' => 'id,name,avatar,cash,score_cash,vip_id,agent_id,client_id'));
         if (self::$user) {
             self::$uid = $uid;
             self::$user['score_cash_name'] = self::$user['score_cash'] . self::$info['score_name'];

+ 114 - 0
src/place/lib/Client.php

@@ -0,0 +1,114 @@
+<?php namespace Place\Lib;
+use Dever;
+use Place;
+class Client
+{
+    public function get($info, $app, $type, $button)
+    {
+        if (Place::$user['client_id'] <= 0) {
+            Dever::error('您不是源主');
+        }
+        $result = array();
+        $result['status'] = 2;
+        $result['text'] = '';
+        $result['original'] = $info['price'];
+        $result['value'] = $info['price'];
+        $result['button'] = $button;
+        $result['list'] = array();
+
+        $client_resource = Dever::db('client_resource', 'place')->find(array('uid' => Place::$uid, 'client_id' => Place::$user['client_id'], 'type' => $type, 'type_id' => $info['id']));
+        if ($client_resource && $client_resource['status'] == 1) {
+            $result['status'] = 1;
+        }
+
+        # 基础折扣
+        $base = Dever::db('client_price', 'place')->find(array('type' => $type, 'status' => 1));
+        if ($base && $base['per']) {
+            $per = $base['per'];
+            $result['value'] = Dever::load('price', 'place')->getValue($per, $result['value'], 3);
+        }
+        
+        $client = Dever::db('client', 'place')->select(array('status' => 1), array('order' => 'day asc,sell desc', 'col' => 'id,day,sell,per'));
+        $price = false;
+        if ($client) {
+            $set = array('col' =>  'sum(num) as num');
+            foreach ($client as $k => $v) {
+                $v['value'] = Dever::load('price', 'place')->getValue($v['per'], $result['value'], 3);
+                $v['name'] = $v['day'] . '天内总销量>=' . $v['sell'];
+                $v['text'] = Dever::load('price', 'place')->getText($v['value'], $type);
+                $result['list'][] = $v;
+                # 获取时效内销量
+                $day = time() - $v['day']*86400;
+                $where = array('uid' => Place::$uid, 'type' => $type, 'day' => array('>=', $day));
+                $sell = Dever::db('client_sell', 'place')->find($where, $set);
+                if ($sell && $sell['num'] >= 0) {
+                    # 获取自定义销量
+                    $resource = Dever::db('client_price', $app)->select(array('client_id' => $v['id']), array('order' => 'sell desc'));
+                    if ($resource) {
+                        foreach ($resource as $v1) {
+                            if ($v1['sell'] > 0) {
+                                $v['value'] = Dever::load('price', 'place')->getValue($v1['value'], $info['value'], 3);
+                                $v['name'] = $v['day'] . '天内本品销量>=' . $v1['sell'];
+                                $v['text'] = Dever::load('price', 'place')->getText($v['value'], $type);
+                                $result['list'][] = $v;
+                                if (!$price) {
+                                    $where['type_id'] = $v1['info_id'];
+                                    $sell = Dever::db('client_sell', 'place')->find($where, $set);
+                                    if ($sell && $sell['num'] >= $v1['sell']) {
+                                        $price = $v['value'];
+                                    }
+                                }
+                            }
+                        }
+                    }
+                    if (!$price && $sell['num'] >= $v['sell']) {
+                        $price = $v['value'];
+                    }
+                }
+            }
+        }
+        if ($price) {
+            $info['value'] = $price;
+        }
+        $result['text'] = Dever::load('price', 'place')->getText($result['value'], $type);
+        return $result;
+    }
+
+    # 同步资源
+    public function resource($place, $data, $resource, $info)
+    {
+        $relation['info'] = $info;
+        $relation['cate'] = Dever::db('cate', $resource->app)->select(array('id' => array('in', $info['cate'])), array('order' => 'parent_id asc'));
+
+        if ($data['type'] == 3 && $info['spec_type'] == 3) {
+            # 还要同步一下sku
+            $relation['spec'] = Dever::db('spec', $resource->app)->select(array('info_id' => $info['id']));
+            if ($relation['spec']) {
+                foreach ($relation['spec'] as &$v) {
+                    $v['value'] = Dever::db('spec_value', $resource->app)->select(array('spec_id' => $v['id']));
+                }
+            }
+            $relation['sku'] = Dever::db('sku', $resource->app)->select(array('info_id' => $info['id']));
+        }
+
+        $place_id = Place::$id;
+        foreach ($place as $v1) {
+            # 切换身份
+            Dever::load('common', 'manage')->setAuth(Place::$system['partition'], Place::$system['id'], Place::$sector['id'], Place::$module['id'], $v1['id']);
+            $resource->relation($place_id, $data, $relation);
+        }
+    }
+
+    # 删除已同步的资源
+    public function resourceDel($place, $data)
+    {
+        $resource = new \Place\Lib\Resource($data['type']);
+        $place = explode(',', $place);
+        $place_id = Place::$id;
+        foreach ($place as $k => $v) {
+            # 切换身份
+            Dever::load('common', 'manage')->setAuth(Place::$system['partition'], Place::$system['id'], Place::$sector['id'], Place::$module['id'], $v);
+            $resource->relationDel($place_id, $data);
+        }
+    }
+}

+ 2 - 0
src/place/lib/Main.php

@@ -22,6 +22,8 @@ class Main
                 if ($this->login && !Place::$uid) {
                     $this->showLogin();
                 }
+            } elseif ($this->login) {
+                $this->showLogin();
             }
         }
         if ($this->entry) {

+ 45 - 0
src/place/lib/Manage.php

@@ -18,6 +18,24 @@ class Manage extends Auth
         return $result;
     }
 
+    # 获取资源默认值
+    public function getResourceDefault($field)
+    {
+        $db = Dever::db('resource', 'place');
+        $option = array();
+        foreach ($db->value('type') as $k => $v) {
+            $info = array('type' => $v['id'], 'status' => 1);
+            foreach ($field as $k1 => $v1) {
+                if (isset($v[$v1])) {
+                    $v1 = $v[$v1];
+                }
+                $info[$k1] = $v1;
+            }
+            $option[] = $info;
+        }
+        return $option;
+    }
+
     # 检测身份码
     public function checkPlaceCode($db, $data)
     {
@@ -103,4 +121,31 @@ class Manage extends Auth
         }
         return $result;
     }
+
+    public function getClientList()
+    {
+        $where['status'] = 1;
+        $client = Dever::db('client', 'place')->select($where);
+        if ($client) {
+            foreach ($client as &$v) {
+                $v['name'] = $v['day'] . '天内>=' . $v['sell'] . '销量';
+            }
+        }
+        return $client;
+    }
+
+    public function getSource($id, $type, $app = 'content')
+    {
+        $result = array();
+        $info = Dever::db('info', $app)->find($id);
+        $result[] = Dever::db('info', $app)->value('source', $info['source']);
+        if ($info['source'] == 2) {
+            $relation = Dever::db('resource_relation', 'place')->find(array('type' => $type, 'type_id' => $id));
+            if ($relation) {
+                $place = Dever::db('info', 'place')->find($relation['channel_place_id']);
+                $result[] = $place['name'];
+            }
+        }
+        return implode('<br />', $result);
+    }
 }

+ 122 - 0
src/place/lib/Resource.php

@@ -69,10 +69,132 @@ class Resource
         return $this->handleInfo($info);
     }
 
+    # 同步资源,关联资源
+    public function relation($place_id, $data, $relation)
+    {
+        $where['channel_place_id'] = $place_id;
+        $where['channel_type'] = $data['type'];
+        $where['channel_type_id'] = $data['type_id'];
+        $info = Dever::db('resource_relation', 'place')->find($where);
+        if ($info) {
+            if ($info['status'] == 2) {
+                Dever::db('resource_relation', 'place')->update($info['id'], array('status' => 1));
+                $update['source'] = 2;
+                Dever::db('info', $this->app, false)->update($info['type_id'], $update);
+                # 同步sku
+                $this->relationSku($info['type_id'], $relation);
+            }
+        } else {
+            $parent_id = $child_id = 0;
+            foreach ($relation['cate'] as $k => $v) {
+                unset($v['id']);
+                unset($v['cdate']);
+                if (!$parent_id) {
+                    $v['parent_id'] = 0;
+                    $parent_id = $this->createCate($v);
+                } else {
+                    $v['parent_id'] = $parent_id;
+                    $child_id = $this->createCate($v);
+                }
+            }
+            $cate[] = $relation['info']['cate_parent_id'] = $parent_id;
+            if ($child_id) {
+                $cate[] = $relation['info']['cate_child_id'] = $child_id;
+            }
+            $relation['info']['cate'] = implode(',', $cate);
+            $relation['info']['source'] = 2;
+            unset($relation['info']['id']);
+            $info_id = Dever::db('info', $this->app, false)->insert($relation['info']);
+            if ($info_id) {
+                # 同步sku
+                $this->relationSku($info_id, $relation);
+
+                $where['type'] = $data['type'];
+                $where['type_id'] = $info_id;
+                $where['channel_price'] = $data['price'];
+                $where['status'] = 1;
+                Dever::db('resource_relation', 'place')->insert($where);
+            }
+        }
+    }
+
+    # 同步sku
+    public function relationSku($info_id, $relation)
+    {
+        if (isset($relation['sku']) && $relation['sku']) {
+            $spec_value = array();
+            $spec_db = Dever::db('spec', $this->app, false);
+            $spec_value_db = Dever::db('spec_value', $this->app, false);
+            $sku_db = Dever::db('sku', $this->app, false);
+            $spec_db->delete(array('info_id' => $info_id));
+            $spec_value_db->delete(array('info_id' => $info_id));
+            $sku_db->delete(array('info_id' => $info_id));
+            foreach ($relation['spec'] as $v) {
+                unset($v['id']);
+                unset($v['cdate']);
+                $v['info_id'] = $info_id;
+                $spec_id = $spec_db->insert($v);
+                foreach ($v['value'] as $v1) {
+                    $id = $v1['id'];
+                    unset($v1['id']);
+                    unset($v1['cdate']);
+                    $v1['info_id'] = $info_id;
+                    $v1['spec_id'] = $spec_id;
+                    $value_id = $spec_value_db->insert($v1);
+                    $spec_value[$id] = $value_id;
+                }
+            }
+            
+            foreach ($relation['sku'] as $v) {
+                unset($v['id']);
+                unset($v['cdate']);
+                $key = explode(',', $v['key']);
+                $v['key'] = array();
+                foreach ($key as $v1) {
+                    if (isset($spec_value[$v1])) {
+                        $v['key'][] = $spec_value[$v1];
+                    }
+                }
+                $v['key'] = implode(',', $v['key']);
+                $sku_db->insert($v);
+            }
+        }
+    }
+
+    # 删除关联关系
+    public function relationDel($place_id, $data)
+    {
+        $where['channel_place_id'] = $place_id;
+        $where['channel_type'] = $data['type'];
+        $where['channel_type_id'] = $data['type_id'];
+        $where['status'] = 1;
+        $info = Dever::db('resource_relation', 'place')->find($where);
+        if ($info) {
+            Dever::db('resource_relation', 'place')->update($info['id'], array('status' => 2));
+            Dever::db('info', $this->app, false)->update($info['type_id'], array('source' => 1));
+        }
+    }
+
+    # 创建分类
+    private function createCate($v)
+    {
+        $db = Dever::db('cate', $this->app, false);
+        $info = $db->find(array('key' => $v['key']));
+        if (!$info) {
+            $id = $db->insert($v);
+        } else {
+            $id = $info['id'];
+        }
+        return $id;
+    }
+
     private function handleInfo($info)
     {
         $info = Dever::load('info', $this->app)->getInfo($info);
         $info['cdate_str'] = date('Y-m-d H:i:s', $info['cdate']);
+        if (Place::$user['client_id'] > 0) {
+            $info['client'] = Dever::load('client', 'place')->get($info, $this->app, $this->type, '进货');
+        }
         $info['price'] = Dever::load('price', 'place')->get($info, $this->app, $this->type, '下载');
 
         if (isset($info['content'])) {

+ 0 - 21
src/place/lib/Util.php

@@ -1,21 +0,0 @@
-<?php namespace Place\Lib;
-use Dever;
-class Util
-{
-    public function getManageType($field)
-    {
-        $db = Dever::db('resource', 'place');
-        $option = array();
-        foreach ($db->value('type') as $k => $v) {
-            $info = array('type' => $v['id'], 'status' => 1);
-            foreach ($field as $k1 => $v1) {
-                if (isset($v[$v1])) {
-                    $v1 = $v[$v1];
-                }
-                $info[$k1] = $v1;
-            }
-            $option[] = $info;
-        }
-        return $option;
-    }
-}

+ 3 - 3
src/place/manage/agent.php

@@ -64,10 +64,10 @@ return array
 
             'place/agent_price' => array
             (
-                'name' => '折扣设置',
+                'name' => '默认折扣',
                 'where'  => array('agent_id' => 'id'),
-                'desc' => '设置购买资源的折扣,如果资源里单独设置了“代理折扣/价格”或者“代理佣金”,此处相应的设置将失效',
-                'default' => Dever::load('util', 'place')->getManageType(array('per' => '')),
+                'desc' => '设置购买资源的默认折扣,如果资源里单独设置了“代理折扣/价格”或者“代理佣金”,此处相应的设置将失效',
+                'default' => Dever::load('manage', 'place')->getResourceDefault(array('per' => '')),
             ),
         ),
     ),

+ 30 - 0
src/place/manage/client.php

@@ -0,0 +1,30 @@
+<?php
+return array
+(
+    'update' => array
+    (
+        'field'    => array
+        (
+            'day' => array
+            (
+                'tips' => '填写销售的时效,单位是天',
+            ),
+            'sell' => array
+            (
+                'tips' => '售出资源的总数量,仅限已完成订单',
+            ),
+            'per' => array
+            (
+                'tips' => '当在时效内达到销量时,该源主享受的折扣<br />注意这个折扣是在源主折扣的基础上计算,相当于折上折',
+            ),
+            'status' => array
+            (
+                'width' => '40',
+                'type' => 'switch',
+                'show'  => '{status}',
+                'active_value' => 1,
+                'inactive_value' => 2,
+            ),
+        ),
+    ),
+);

+ 30 - 0
src/place/manage/client_price.php

@@ -0,0 +1,30 @@
+<?php
+return array
+(
+    'update' => array
+    (
+        'field'    => array
+        (
+            'type' => 'hidden',
+            'type_name' => array
+            (
+                'name' => '资源类型',
+                'type' => 'show',
+                'default' => 'Dever::call("place/manage.getResourceType", "{type}")',
+            ),
+            'per' => array
+            (
+                'tips' => '资源价格*折扣%=源主进货价格<br />如:折扣填写为80,则源主进货=资源价格*80%',
+                'placeholder' => '资源价格*折扣%=源主进货价格',
+            ),
+            'status' => array
+            (
+                'width' => '40',
+                'type' => 'switch',
+                'show'  => '{status}',
+                'active_value' => 1,
+                'inactive_value' => 2,
+            ),
+        ),
+    ),
+);

+ 28 - 3
src/place/manage/info.php

@@ -1,19 +1,44 @@
 <?php
 $config = include('place.php');
+$config['update']['tab']['展示设置'] = 'vip_name,agent_name,place/resource';
 $config['update']['field']['place/resource'] = array
 (
     'name' => '资源选项',
     'where'  => array('id' => array('>', 0)),
     'desc' => '设置要展示的资源选项',
-    'default' => Dever::load('util', 'place')->getManageType(array('name' => 'name')),
+    'default' => Dever::load('manage', 'place')->getResourceDefault(array('name' => 'name')),
 );
-$config['update']['tab']['展示设置'] = 'vip_name,agent_name,place/resource';
+
+$data = Dever::load('manage', 'place')->getPlaceTree();
+$uid = $data[0]['children'][0]['uid'];
+$user = Dever::db('user', 'sector')->find($uid);
+if ($user['channel'] == 1) {
+    $config['update']['tab']['渠道设置'] = 'channel,place/client_price,place/client';
+    $config['update']['field']['channel'] = array
+    (
+        'type' => 'radio',
+        'tips' => '开启后,将拥有源主供货能力',
+    );
+    $config['update']['field']['place/client_price'] = array
+    (
+        'name' => '默认基础折扣',
+        'where'  => array('id' => array('>', 0)),
+        'desc' => '设置源主进货资源的默认基础折扣',
+        'default' => Dever::load('manage', 'place')->getResourceDefault(array('per' => '')),
+    );
+    $config['update']['field']['place/client'] = array
+    (
+        'name' => '默认销量折扣',
+        'where'  => array('id' => array('>', 0)),
+        'desc' => '设置后,如果n天内的销量达到预设值,将在默认基础折扣上再计算折扣',
+    );
+}
 $config['update']['column'] = array
 (
     'load' => 'place/info',
     //'add' => '新增',
     'key' => 'id',
-    'data' => 'place/manage.getPlaceTree',
+    'data' => $data,
     'active' => 1,
     'where' => 'id',
     'hidden' => true,

+ 3 - 3
src/place/manage/vip.php

@@ -75,10 +75,10 @@ return array
 
             'place/vip_price' => array
             (
-                'name' => '折扣设置',
+                'name' => '默认折扣',
                 'where'  => array('vip_id' => 'id'),
-                'desc' => '设置购买资源的折扣,如果资源里单独设置了“会员价格”,此处设置将失效',
-                'default' => Dever::load('util', 'place')->getManageType(array('per' => '')),
+                'desc' => '设置购买资源的默认折扣,如果资源里单独设置了“会员价格/折扣”,此处设置将失效',
+                'default' => Dever::load('manage', 'place')->getResourceDefault(array('per' => '')),
             ),
         ),
     ),

+ 39 - 0
src/place/table/client.php

@@ -0,0 +1,39 @@
+<?php
+return array
+(
+    'name' => '源主销量折扣设置',
+    'partition' => 'Dever::call("manage/common.system")',
+    'order' => 'sell desc',
+    'struct' => array
+    (
+        'day' => array
+        (
+            'name'      => '时效(天)',
+            'type'      => 'int(11)',
+        ),
+
+        'sell' => array
+        (
+            'name'      => '销量',
+            'type'      => 'int(11)',
+        ),
+
+        'per' => array
+        (
+            'name'      => '折扣',
+            'type'      => 'varchar(11)',
+        ),
+
+        'status' => array
+        (
+            'name'      => '状态',
+            'type'      => 'tinyint(1)',
+            'default'   => 1,
+            'value'     => array
+            (
+                1 => '开启',
+                2 => '禁用',
+            ),
+        ),
+    ),
+);

+ 34 - 0
src/place/table/client_price.php

@@ -0,0 +1,34 @@
+<?php
+return array
+(
+    'name' => '源主供货价格设置表',
+    'partition' => 'Dever::call("manage/common.system")',
+    'order' => 'id asc',
+    'struct' => array
+    (
+        'type' => array
+        (
+            'name'      => '资源类型',
+            'type'      => 'tinyint(1)',
+            'default'   => 1,
+        ),
+
+        'per' => array
+        (
+            'name'      => '折扣',
+            'type'      => 'varchar(11)',
+        ),
+        
+        'status' => array
+        (
+            'name'      => '状态',
+            'type'      => 'tinyint(1)',
+            'default'   => 1,
+            'value'     => array
+            (
+                1 => '开启',
+                2 => '禁用',
+            ),
+        ),
+    ),
+);

+ 56 - 0
src/place/table/client_resource.php

@@ -0,0 +1,56 @@
+<?php
+return array
+(
+    'name' => '源主进货资源',
+    'partition' => 'Dever::call("manage/common.system", array(false, true, "place/info.funcType"))',
+    'struct' => array
+    (
+        'type'        => array
+        (
+            'type'      => 'tinyint(1)',
+            'name'      => '类型',
+        ),
+
+        'type_id'        => array
+        (
+            'type'      => 'int(11)',
+            'name'      => '类型ID',
+        ),
+
+        'uid'       => array
+        (
+            'type'      => 'int(11)',
+            'name'      => '用户',
+        ),
+
+        'client_id'       => array
+        (
+            'type'      => 'int(11)',
+            'name'      => '源主',
+        ),
+
+        'place_id'       => array
+        (
+            'type'      => 'varchar(100)',
+            'name'      => '身份',
+        ),
+
+        'price' => array
+        (
+            'name'      => '进货价格记录',
+            'type'      => 'decimal(11,2)',
+        ),
+
+        'status' => array
+        (
+            'name'      => '状态',
+            'type'      => 'tinyint(1)',
+            'default'   => 1,
+            'value'     => array
+            (
+                1 => '有效',
+                2 => '无效',
+            ),
+        ),
+    ),
+);

+ 39 - 0
src/place/table/client_sell.php

@@ -0,0 +1,39 @@
+<?php
+return array
+(
+    'name' => '源主销售表',
+    'partition' => 'Dever::call("manage/common.system")',
+    'order' => 'id desc',
+    'struct' => array
+    (
+        'type'        => array
+        (
+            'type'      => 'tinyint(1)',
+            'name'      => '类型',
+        ),
+
+        'type_id'        => array
+        (
+            'type'      => 'int(11)',
+            'name'      => '类型ID',
+        ),
+
+        'uid'       => array
+        (
+            'type'      => 'int(11)',
+            'name'      => '用户',
+        ),
+
+        'num' => array
+        (
+            'type'      => 'int(11)',
+            'name'      => '数量',
+        ),
+        
+        'day' => array
+        (
+            'type'      => 'int(11)',
+            'name'      => '天',
+        ),
+    ),
+);

+ 12 - 0
src/place/table/info.php

@@ -97,6 +97,18 @@ return array
             'default'   => '1',
         ),
 
+        'channel' => array
+        (
+            'name'      => '渠道',
+            'type'      => 'tinyint(1)',
+            'default'   => 2,
+            'value'     => array
+            (
+                1 => '开启',
+                2 => '关闭',
+            ),
+        ),
+
         'status' => array
         (
             'name'      => '状态',

+ 7 - 0
src/place/table/member.php

@@ -39,6 +39,13 @@ return array
             'value'     => 'Dever::call("place/agent.getList")',
             'default'   => -1,
         ),
+        'client_id' => array
+        (
+            'name'      => '源主',
+            'type'      => 'int(11)',
+            'value'     => 'sector/user',
+            'default'   => -1,
+        ),
         'score_cash' => array
         (
             'name'      => '积分余额',

+ 56 - 0
src/place/table/resource_relation.php

@@ -0,0 +1,56 @@
+<?php
+return array
+(
+    'name' => '资源关联表',
+    'partition' => 'Dever::call("manage/common.system", array(false, true, "place/info.funcType"))',
+    'struct' => array
+    (
+        'channel_type'        => array
+        (
+            'type'      => 'tinyint(1)',
+            'name'      => '类型',
+        ),
+
+        'channel_type_id'        => array
+        (
+            'type'      => 'int(11)',
+            'name'      => '类型ID',
+        ),
+
+        'channel_place_id'       => array
+        (
+            'type'      => 'int(11)',
+            'name'      => '渠道身份',
+        ),
+
+        'type'        => array
+        (
+            'type'      => 'tinyint(1)',
+            'name'      => '类型',
+        ),
+
+        'type_id'        => array
+        (
+            'type'      => 'int(11)',
+            'name'      => '类型ID',
+        ),
+
+        'channel_price' => array
+        (
+            'name'      => '进货价格记录',
+            'type'      => 'decimal(11,2)',
+        ),
+
+        'status' => array
+        (
+            'name'      => '状态',
+            'type'      => 'tinyint(1)',
+            'default'   => 1,
+            'value'     => array
+            (
+                1 => '有效',
+                2 => '无效',
+            ),
+        ),
+    ),
+);

+ 2 - 2
src/resource/content/lib/Info.php

@@ -15,9 +15,9 @@ class Info
         return $info;
     }
 
-    public function submit($info)
+    public function submit($info, $type = 'price')
     {
-        $result = $info['price'];
+        $result = $info[$type];
         $password = Dever::input('password');
         if ($password) {
             if ($info['password'] && $password == $info['password']) {

+ 2 - 2
src/resource/content/manage/agent_price.php

@@ -15,11 +15,11 @@ return array
             ),
             'value' => array
             (
-                'tips' => '价格设置为0,当前选择的代理免费<br />为空则使用默认代理折扣计算代理购买价格',
+                'tips' => '资源价格*折扣%=代理价格<br />设置为0,当前选择的代理免费<br />为空则使用代理的“默认折扣计算代理购买价格',
             ),
             'fee' => array
             (
-                'tips' => '资源价格*佣金比例%=代理佣金<br />为空则使用默认代理佣金比例',
+                'tips' => '资源价格*佣金比例%=代理佣金<br />为空则使用代理的“默认佣金比例',
                 'placeholder' => '资源价格*佣金比例%=代理佣金',
             ),
             'status' => array

+ 25 - 0
src/resource/content/manage/client_price.php

@@ -0,0 +1,25 @@
+<?php
+return array
+(
+    'update' => array
+    (
+        'field'    => array
+        (
+            'client_id' => array
+            (
+                'placeholder' => '请选择时效',
+                //'tips' => '请选择时效',
+                'type' => 'select',
+                'clearable' => true,
+            ),
+            'sell' => array
+            (
+                'tips' => '售出当前资源的总数量<br />如为0则使用“默认销量折扣”中的销量<br />如大于0则“默认销量折扣”中的销量无效',
+            ),
+            'value' => array
+            (
+                'tips' => '设置为0,源主免费<br />为空则使用“默认销量折扣”计算源主进货价格',
+            ),
+        ),
+    ),
+);

+ 1 - 1
src/resource/content/manage/core.php

@@ -8,7 +8,7 @@ return array
             'parent'    => 'sector_place_source',
             'name'      => '内容管理',
             'icon'      => 'clipboard-line',
-            'sort'      => '1',
+            'sort'      => '2',
         ),
         'info' => array
         (

+ 39 - 2
src/resource/content/manage/info.php

@@ -1,5 +1,5 @@
 <?php
-return array
+$config = array
 (
     'list' => array
     (
@@ -13,6 +13,10 @@ return array
             (
                 //'tip' => false,
             ),
+            'source' => array
+            (
+                'show' => 'Dever::call("place/manage.getSource", array({id}, 1, "content"))',
+            ),
             'cate' => array
             (
                 'show' => 'Dever::call("place/manage.getCateInfo", array("content", "{cate}"))',
@@ -126,7 +130,40 @@ return array
                 'where'  => array('info_id' => 'id'),
                 'desc' => '可以按照代理等级设置不同的价格',
             ),
+            'content/client_price' => array
+            (
+                'name' => '源主销量折扣',
+                'where'  => array('info_id' => 'id'),
+            ),
         ),
         'end' => 'place/manage.updateCate',
     ),
-);
+);
+$extend = Dever::load('common', 'manage')->extend();
+$place = Dever::db('info', 'place')->find(array('id' => $extend['data_id']));
+if ($place && $place['channel'] == 1) {
+    $config['update']['tab']['价格设置'] .= ',content/client_price';
+}
+
+$id = Dever::input('id');
+if ($id) {
+    $info = Dever::db('info', 'content')->find($id);
+    if ($info && isset($info['source']) && $info['source'] == 2) {
+        $relation = Dever::db('resource_relation', 'place')->find(array('type' => 1, 'type_id' => $id));
+        if ($relation && $relation['status'] = 1) {
+            unset($config['update']['tab']['附件信息']);
+            $place = Dever::db('info', 'place')->find($relation['channel_place_id']);
+            $config['update']['tab']['价格设置'] = 'price_show,' . $config['update']['tab']['价格设置'];
+
+            $config['update']['field']['price_show'] = array
+            (
+                'type' => 'show',
+                'name' => '进价参考',
+                'default' => $relation['channel_price'],
+                'tips' => '这里仅为您进货时记录的价格,如需实时报价请到“'.$place['name'].'”查询',
+            );
+        }
+    }
+}
+
+return $config;

+ 1 - 1
src/resource/content/manage/vip_price.php

@@ -15,7 +15,7 @@ return array
             ),
             'value' => array
             (
-                'tips' => '设置为0,当前选择的会员免费<br />为空则使用默认会员折扣计算会员购买价格',
+                'tips' => '资源价格*折扣%=会员价格<br />设置为0,当前选择的会员免费<br />为空则使用会员的“默认折扣计算会员购买价格',
             ),
             'status' => array
             (

+ 33 - 0
src/resource/content/table/client_price.php

@@ -0,0 +1,33 @@
+<?php
+return array
+(
+    'name' => '内容源主价格表',
+    'partition' => 'Dever::call("manage/common.system")',
+    'struct' => array
+    (
+        'info_id' => array
+        (
+            'name'      => '内容ID',
+            'type'      => 'int(11)',
+        ),
+
+        'client_id' => array
+        (
+            'name'      => '时效',
+            'type'      => 'int(11)',
+            'value'     => 'Dever::call("place/manage.getClientList")',
+        ),
+
+        'sell' => array
+        (
+            'name'      => '当前内容销量',
+            'type'      => 'int(11)',
+        ),
+
+        'value' => array
+        (
+            'name'      => '折扣',
+            'type'      => 'varchar(11)',
+        ),
+    ),
+);

+ 12 - 0
src/resource/content/table/info.php

@@ -79,5 +79,17 @@ return array
                 2 => '下架',
             ),
         ),
+
+        'source' => array
+        (
+            'name'      => '来源',
+            'type'      => 'tinyint(1)',
+            'default'   => 1,
+            'value'     => array
+            (
+                1 => '录入',
+                2 => '源小货',
+            ),
+        ),
     ),
 );

+ 5 - 2
src/resource/goods/lib/Info.php

@@ -22,12 +22,15 @@ class Info
         $info['price'] = $sku['price'];
         $info['sku_name'] = $sku['name'];
         $info['sku_id'] = $sku['id'];
+        if (Dever::input('show_sku')) {
+            $result['sku'] = Dever::load('sku', 'api')->getList(array('info_id' => $info['id']), Dever::input('sku_id'), 'goods');
+        }
         return $info;
     }
 
-    public function submit($info)
+    public function submit($info, $type = 'price')
     {
-        $result = $info['price'];
+        $result = $info[$type];
         $result['id'] = $info['id'];
         $result['name'] = $info['name'];
         if ($result['status'] == 3) {

+ 3 - 3
src/resource/goods/manage/agent_price.php

@@ -15,11 +15,11 @@ return array
             ),
             'value' => array
             (
-                'tips' => '资源价格*折扣%=代理价格<br />设置为0,当前选择的代理免费<br />为空则使用默认代理折扣计算代理购买价格',
+                'tips' => '资源价格*折扣%=代理价格<br />设置为0,当前选择的代理免费<br />为空则使用代理的“默认折扣计算代理购买价格',
             ),
             'fee' => array
             (
-                'tips' => '资源价格*佣金比例%=代理佣金<br />为空则使用默认代理佣金比例',
+                'tips' => '资源价格*佣金比例%=代理佣金<br />为空则使用代理的“默认佣金比例',
                 'placeholder' => '资源价格*佣金比例%=代理佣金',
             ),
             'status' => array
@@ -29,7 +29,7 @@ return array
                 'show'  => '{status}',
                 'active_value' => 1,
                 'inactive_value' => 2,
-                'tips' => '勾选后,仅限当前选择的代理可以下载',
+                'tips' => '勾选后,仅限当前选择的代理可以购买',
             ),
         ),
     ),

+ 25 - 0
src/resource/goods/manage/client_price.php

@@ -0,0 +1,25 @@
+<?php
+return array
+(
+    'update' => array
+    (
+        'field'    => array
+        (
+            'client_id' => array
+            (
+                'placeholder' => '请选择时效',
+                //'tips' => '请选择时效',
+                'type' => 'select',
+                'clearable' => true,
+            ),
+            'sell' => array
+            (
+                'tips' => '售出当前资源的总数量<br />如为0则使用“默认销量折扣”中的销量<br />如大于0则“默认销量折扣”中的销量无效',
+            ),
+            'value' => array
+            (
+                'tips' => '设置为0,源主免费<br />为空则使用“默认销量折扣”计算源主进货价格',
+            ),
+        ),
+    ),
+);

+ 1 - 1
src/resource/goods/manage/core.php

@@ -8,7 +8,7 @@ return array
             'parent'    => 'sector_place_source',
             'name'      => '商品管理',
             'icon'      => 'shopping-bag-2-line',
-            'sort'      => '4',
+            'sort'      => '1',
         ),
         
         'info' => array

+ 32 - 2
src/resource/goods/manage/info.php

@@ -1,5 +1,5 @@
 <?php
-return array
+$config = array
 (
     'list' => array
     (
@@ -13,6 +13,10 @@ return array
             (
                 //'tip' => false,
             ),
+            'source' => array
+            (
+                'show' => 'Dever::call("place/manage.getSource", array({id}, 3, "goods"))',
+            ),
             'cate' => array
             (
                 'show' => 'Dever::call("place/manage.getCateInfo", array("goods", "{cate}"))',
@@ -147,6 +151,7 @@ return array
                 # 获取规格数据的接口
                 'spec_data' => 'api/spec.manage',
                 'desc' => '如需设置商品库存,请到“商品库存”中设置,不设置库存则商品无库存',
+                'disable' => false,
             ),
 
             'goods/vip_price' => array
@@ -161,6 +166,31 @@ return array
                 'where'  => array('info_id' => 'id'),
                 'desc' => '可以按照代理等级设置不同的价格',
             ),
+
+            'goods/client_price' => array
+            (
+                'name' => '源主销量折扣',
+                'where'  => array('info_id' => 'id'),
+            ),
         ),
     ),
-);
+);
+$extend = Dever::load('common', 'manage')->extend();
+$place = Dever::db('info', 'place')->find(array('id' => $extend['data_id']));
+if ($place && $place['channel'] == 1) {
+    $config['update']['tab']['特殊价格设置'] .= ',goods/client_price';
+}
+$id = Dever::input('id');
+if ($id) {
+    $info = Dever::db('info', 'goods')->find($id);
+    if ($info && isset($info['source']) && $info['source'] == 2) {
+        $relation = Dever::db('resource_relation', 'place')->find(array('type' => 3, 'type_id' => $id));
+        if ($relation && $relation['status'] = 1) {
+            $place = Dever::db('info', 'place')->find($relation['channel_place_id']);
+            $config['update']['field']['spec_type']['disable'] = true;
+            $config['update']['field']['goods/sku#']['disable'] = true;
+        }
+    }
+}
+
+return $config;

+ 1 - 1
src/resource/goods/manage/vip_price.php

@@ -15,7 +15,7 @@ return array
             ),
             'value' => array
             (
-                'tips' => '资源价格*折扣%=会员价格<br />设置为0,当前选择的会员免费<br />为空则使用默认会员折扣计算会员购买价格',
+                'tips' => '资源价格*折扣%=会员价格<br />设置为0,当前选择的会员免费<br />为空则使用会员的“默认折扣计算会员购买价格',
             ),
             'status' => array
             (

+ 33 - 0
src/resource/goods/table/client_price.php

@@ -0,0 +1,33 @@
+<?php
+return array
+(
+    'name' => '商品源主价格表',
+    'partition' => 'Dever::call("manage/common.system")',
+    'struct' => array
+    (
+        'info_id' => array
+        (
+            'name'      => '商品ID',
+            'type'      => 'int(11)',
+        ),
+
+        'client_id' => array
+        (
+            'name'      => '时效',
+            'type'      => 'int(11)',
+            'value'     => 'Dever::call("place/manage.getClientList")',
+        ),
+
+        'sell' => array
+        (
+            'name'      => '当前商品销量',
+            'type'      => 'int(11)',
+        ),
+
+        'value' => array
+        (
+            'name'      => '折扣',
+            'type'      => 'varchar(11)',
+        ),
+    ),
+);

+ 12 - 0
src/resource/goods/table/info.php

@@ -79,5 +79,17 @@ return array
                 2 => '下架',
             ),
         ),
+
+        'source' => array
+        (
+            'name'      => '来源',
+            'type'      => 'tinyint(1)',
+            'default'   => 1,
+            'value'     => array
+            (
+                1 => '录入',
+                2 => '源小货',
+            ),
+        ),
     ),
 );

+ 5 - 0
src/sector/manage/user.php

@@ -105,6 +105,11 @@ return array
                     ),
                 ),
             ),
+            'channel' => array
+            (
+                'type' => 'radio',
+                'tips' => '开启后,将拥有源主供货能力',
+            ),
             'role' => array
             (
                 'type' => 'checkbox',

+ 11 - 0
src/sector/table/user.php

@@ -42,6 +42,17 @@ return array
             'name'      => '头像',
             'type'      => 'varchar(300)',
         ),
+        'channel' => array
+        (
+            'name'      => '渠道',
+            'type'      => 'tinyint(1)',
+            'default'   => 2,
+            'value'     => array
+            (
+                1 => '开启',
+                2 => '关闭',
+            ),
+        ),
         'status' => array
         (
             'name'      => '状态',

Some files were not shown because too many files changed in this diff