Seller.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <?php
  2. namespace app\common\model;
  3. use think\facade\Db;
  4. /**
  5. * ============================================================================
  6. * DSMall多用户商城
  7. * ============================================================================
  8. * 版权所有 2014-2028 长沙德尚网络科技有限公司,并保留所有权利。
  9. * 网站地址: http://www.csdeshang.com
  10. * ----------------------------------------------------------------------------
  11. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
  12. * 不允许对程序代码以任何形式任何目的的再发布。
  13. * ============================================================================
  14. * 数据层模型
  15. */
  16. class Seller extends BaseModel {
  17. /**
  18. * 登录时创建会话SESSION
  19. * @access public
  20. * @author csdeshang
  21. * @param type $member_info 会员信息
  22. * @param type $store_info 店铺信息
  23. * @param type $seller_info 卖家信息
  24. * @param type $seller_group_info 分组信息
  25. */
  26. public function createSellerSession($member_info,$store_info,$seller_info,$seller_group_info) {
  27. if (empty($member_info) || !is_array($member_info)) {
  28. return;
  29. }
  30. $member_gradeinfo = model('member')->getOneMemberGrade(intval($member_info['member_exppoints']));
  31. $member_info = array_merge($member_info, $member_gradeinfo);
  32. /* 此处卖家登录需要和买家登录 session 一致 createSession方法 BEGIN */
  33. session('is_login', '1');
  34. session('member_id', $member_info['member_id']);
  35. session('member_name', $member_info['member_name']);
  36. session('member_nickname', $member_info['member_nickname']);
  37. session('member_email', $member_info['member_email']);
  38. session('is_buy', $member_info['is_buylimit']);
  39. session('avatar', $member_info['member_avatar']);
  40. session('level', isset($member_info['level']) ? $member_info['level'] : '');
  41. session('level_name', isset($member_info['level_name']) ? $member_info['level_name'] : '');
  42. session('member_exppoints', $member_info['member_exppoints']); //经验值
  43. session('member_points', $member_info['member_points']); //积分值
  44. /* END */
  45. session('grade_id', $store_info['grade_id']); //店铺等级
  46. session('seller_id', $seller_info['seller_id']);
  47. session('seller_name', $seller_info['seller_name']);
  48. session('seller_is_admin', intval($seller_info['is_admin']));
  49. session('store_id', intval($seller_info['store_id']));
  50. session('store_name', $store_info['store_name']);
  51. session('is_platform_store', (bool) $store_info['is_platform_store']);
  52. session('bind_all_gc', (bool) $store_info['bind_all_gc']);
  53. session('seller_limits', isset($seller_group_info['sellergroup_limits']) ? explode('|', $seller_group_info['sellergroup_limits']) : '');
  54. if ($seller_info['is_admin']) {
  55. session('seller_group_name', '管理员');
  56. session('seller_smt_limits', false);
  57. } else {
  58. session('seller_group_name', isset($seller_group_info['sellergroup_name']) ? $seller_group_info['sellergroup_name'] : NULL);
  59. session('seller_smt_limits', isset($seller_group_info['smt_limits']) ? explode(',', $seller_group_info['smt_limits']) : '');
  60. }
  61. if (!$seller_info['last_logintime']) {
  62. $seller_info['last_logintime'] = TIMESTAMP;
  63. }
  64. session('seller_last_logintime', date('Y-m-d H:i', $seller_info['last_logintime']));
  65. }
  66. /**
  67. * 读取列表
  68. * @access public
  69. * @author csdeshang
  70. * @param array $condition 条件
  71. * @param string $order 排序
  72. * @return array
  73. */
  74. public function getSellerList($condition, $order = '') {
  75. $result = Db::name('seller')->alias('seller')->join('member member', 'member.member_id = seller.member_id', 'LEFT')->field('seller.*,member.member_name')->where($condition)->order($order)->select()->toArray();
  76. return $result;
  77. }
  78. /**
  79. * 读取单条记录
  80. * @access public
  81. * @author csdeshang
  82. * @param type $condition 条件
  83. * @return type
  84. */
  85. public function getSellerInfo($condition) {
  86. $result = Db::name('seller')->where($condition)->find();
  87. return $result;
  88. }
  89. /**
  90. * 判断是否存在
  91. * @access public
  92. * @author csdeshang
  93. * @param type $condition 条件
  94. * @return boolean
  95. */
  96. public function isSellerExist($condition) {
  97. $result = $this->getSellerInfo($condition);
  98. if (empty($result)) {
  99. return FALSE;
  100. } else {
  101. return TRUE;
  102. }
  103. }
  104. /**
  105. * 增加
  106. * @access public
  107. * @author csdeshang
  108. * @param array $data 数据
  109. * @return bool
  110. */
  111. public function addSeller($data) {
  112. return Db::name('seller')->insertGetId($data);
  113. }
  114. /**
  115. * 更新
  116. * @access public
  117. * @author csdeshang
  118. * @param array $update更新审数据
  119. * @param array $condition 条件
  120. * @return bool
  121. */
  122. public function editSeller($update, $condition) {
  123. return Db::name('seller')->where($condition)->update($update);
  124. }
  125. /**
  126. * 删除
  127. * @access public
  128. * @author csdeshang
  129. * @param array $condition 条件
  130. * @return bool
  131. */
  132. public function delSeller($condition) {
  133. return Db::name('seller')->where($condition)->delete();
  134. }
  135. }