Seller.php 5.4 KB

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