Seller.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <?php
  2. namespace app\common\model;
  3. use think\facade\Db;
  4. /**
  5. *
  6. *
  7. * ----------------------------------------------------------------------------
  8. *
  9. * 数据层模型
  10. */
  11. class Seller extends BaseModel
  12. {
  13. /**
  14. * 登录时创建会话SESSION
  15. * @access public
  16. * @author csdeshang
  17. * @param type $member_info 会员信息
  18. * @param type $store_info 店铺信息
  19. * @param type $seller_info 卖家信息
  20. * @param type $seller_group_info 分组信息
  21. */
  22. public function createSellerSession($member_info, $store_info, $seller_info, $seller_group_info)
  23. {
  24. if (empty($member_info) || !is_array($member_info)) {
  25. return;
  26. }
  27. $member_gradeinfo = model('member')->getOneMemberGrade(intval($member_info['member_exppoints']));
  28. $member_info = array_merge($member_info, $member_gradeinfo);
  29. /* 此处卖家登录需要和买家登录 session 一致 createSession方法 BEGIN */
  30. session('is_login', '1');
  31. session('member_id', $member_info['member_id']);
  32. session('member_name', $member_info['member_name']);
  33. session('member_nickname', $member_info['member_nickname']);
  34. session('member_email', $member_info['member_email']);
  35. session('is_buy', $member_info['is_buylimit']);
  36. session('avatar', $member_info['member_avatar']);
  37. session('level', isset($member_info['level']) ? $member_info['level'] : '');
  38. session('level_name', isset($member_info['level_name']) ? $member_info['level_name'] : '');
  39. session('member_exppoints', $member_info['member_exppoints']); //经验值
  40. session('member_points', $member_info['member_points']); //积分值
  41. /* END */
  42. session('grade_id', $store_info['grade_id']); //店铺等级
  43. session('seller_id', $seller_info['seller_id']);
  44. session('seller_name', $seller_info['seller_name']);
  45. session('seller_is_admin', intval($seller_info['is_admin']));
  46. session('store_id', intval($seller_info['store_id']));
  47. session('store_name', $store_info['store_name']);
  48. session('is_platform_store', (bool) $store_info['is_platform_store']);
  49. session('bind_all_gc', (bool) $store_info['bind_all_gc']);
  50. session('seller_limits', isset($seller_group_info['sellergroup_limits']) ? explode('|', $seller_group_info['sellergroup_limits']) : '');
  51. if ($seller_info['is_admin']) {
  52. session('seller_group_name', '管理员');
  53. session('seller_smt_limits', false);
  54. } else {
  55. session('seller_group_name', isset($seller_group_info['sellergroup_name']) ? $seller_group_info['sellergroup_name'] : NULL);
  56. session('seller_smt_limits', isset($seller_group_info['smt_limits']) ? explode(',', $seller_group_info['smt_limits']) : '');
  57. }
  58. if (!$seller_info['last_logintime']) {
  59. $seller_info['last_logintime'] = TIMESTAMP;
  60. }
  61. session('seller_last_logintime', date('Y-m-d H:i', $seller_info['last_logintime']));
  62. }
  63. /**
  64. * 读取列表
  65. * @access public
  66. * @author csdeshang
  67. * @param array $condition 条件
  68. * @param string $order 排序
  69. * @return array
  70. */
  71. public function getSellerList($condition, $order = '')
  72. {
  73. $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();
  74. return $result;
  75. }
  76. /**
  77. * 读取单条记录
  78. * @access public
  79. * @author csdeshang
  80. * @param type $condition 条件
  81. * @return type
  82. */
  83. public function getSellerInfo($condition)
  84. {
  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. {
  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. {
  113. return Db::name('seller')->insertGetId($data);
  114. }
  115. /**
  116. * 更新
  117. * @access public
  118. * @author csdeshang
  119. * @param array $update更新审数据
  120. * @param array $condition 条件
  121. * @return bool
  122. */
  123. public function editSeller($update, $condition)
  124. {
  125. return Db::name('seller')->where($condition)->update($update);
  126. }
  127. /**
  128. * 删除
  129. * @access public
  130. * @author csdeshang
  131. * @param array $condition 条件
  132. * @return bool
  133. */
  134. public function delSeller($condition)
  135. {
  136. return Db::name('seller')->where($condition)->delete();
  137. }
  138. }