Seller.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <?php
  2. namespace app\common\model;
  3. use think\facade\Db;
  4. /**
  5. * ============================================================================
  6. *
  7. * ============================================================================
  8. *
  9. * ----------------------------------------------------------------------------
  10. *
  11. * ============================================================================
  12. * 数据层模型
  13. */
  14. class Seller extends BaseModel
  15. {
  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. {
  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. {
  76. $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();
  77. return $result;
  78. }
  79. /**
  80. * 读取单条记录
  81. * @access public
  82. * @author csdeshang
  83. * @param type $condition 条件
  84. * @return type
  85. */
  86. public function getSellerInfo($condition)
  87. {
  88. $result = Db::name('seller')->where($condition)->find();
  89. return $result;
  90. }
  91. /**
  92. * 判断是否存在
  93. * @access public
  94. * @author csdeshang
  95. * @param type $condition 条件
  96. * @return boolean
  97. */
  98. public function isSellerExist($condition)
  99. {
  100. $result = $this->getSellerInfo($condition);
  101. if (empty($result)) {
  102. return FALSE;
  103. } else {
  104. return TRUE;
  105. }
  106. }
  107. /**
  108. * 增加
  109. * @access public
  110. * @author csdeshang
  111. * @param array $data 数据
  112. * @return bool
  113. */
  114. public function addSeller($data)
  115. {
  116. return Db::name('seller')->insertGetId($data);
  117. }
  118. /**
  119. * 更新
  120. * @access public
  121. * @author csdeshang
  122. * @param array $update更新审数据
  123. * @param array $condition 条件
  124. * @return bool
  125. */
  126. public function editSeller($update, $condition)
  127. {
  128. return Db::name('seller')->where($condition)->update($update);
  129. }
  130. /**
  131. * 删除
  132. * @access public
  133. * @author csdeshang
  134. * @param array $condition 条件
  135. * @return bool
  136. */
  137. public function delSeller($condition)
  138. {
  139. return Db::name('seller')->where($condition)->delete();
  140. }
  141. }