MobileSeller.php 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <?php
  2. namespace app\api\controller;
  3. use think\facade\Lang;
  4. /**
  5. * ============================================================================
  6. * DSMall多用户商城
  7. * ============================================================================
  8. * 版权所有 2014-2028 长沙德尚网络科技有限公司,并保留所有权利。
  9. * 网站地址: http://www.csdeshang.com
  10. * ----------------------------------------------------------------------------
  11. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
  12. * 不允许对程序代码以任何形式任何目的的再发布。
  13. * ============================================================================
  14. * 控制器
  15. */
  16. class MobileSeller extends MobileHome {
  17. protected $seller_info = array();
  18. protected $seller_group_info = array();
  19. protected $member_info = array();
  20. protected $store_info = array();
  21. protected $store_grade = array();
  22. public function initialize() {
  23. parent::initialize();
  24. Lang::load(base_path() . 'home/lang/' . config('lang.default_lang') . '/baseseller.lang.php');
  25. $mbsellertoken_model = model('mbsellertoken');
  26. $key = request()->header('X-DS-KEY');
  27. if (empty($key)) {
  28. ds_json_encode(13001,lang('please_login'), array('login' => '0'));
  29. }
  30. $mb_seller_token_info = $mbsellertoken_model->getMbsellertokenInfoByToken($key);
  31. if (empty($mb_seller_token_info)) {
  32. ds_json_encode(13001,lang('please_login'), array('login' => '0'));
  33. }
  34. $seller_model = model('seller');
  35. $member_model = model('member');
  36. $store_model = model('store');
  37. $sellergroup_model = model('sellergroup');
  38. $this->seller_info = $seller_model->getSellerInfo(array('seller_id' => $mb_seller_token_info['seller_id']));
  39. $this->member_info = $member_model->getMemberInfoByID($this->seller_info['member_id']);
  40. $this->store_info = $store_model->getStoreInfoByID($this->seller_info['store_id']);
  41. $this->seller_group_info = $sellergroup_model->getSellergroupInfo(array('sellergroup_id' => $this->seller_info['sellergroup_id']));
  42. if(!is_array($this->seller_group_info)){
  43. $this->seller_group_info=array();
  44. }
  45. // 店铺等级
  46. if (intval($this->store_info['is_platform_store']) === 1) {
  47. $this->store_grade = array(
  48. 'storegrade_id' => '0',
  49. 'storegrade_name' => lang('store_grade_ownshop'),
  50. 'storegrade_goods_limit' => '0',
  51. 'storegrade_album_limit' => '0',
  52. 'storegrade_space_limit' => '999999999',
  53. 'storegrade_template_number' => '6',
  54. 'storegrade_price' => '0.00',
  55. 'storegrade_description' => '',
  56. 'storegrade_sort' => '255',
  57. );
  58. } else {
  59. $store_grade = rkcache('storegrade', true);
  60. $this->store_grade = $store_grade[$this->store_info['grade_id']];
  61. }
  62. if (empty($this->member_info)) {
  63. ds_json_encode(13001,lang('please_login'), array('login' => '0'));
  64. } else {
  65. $this->seller_info['seller_clienttype'] = $mb_seller_token_info['seller_clienttype'];
  66. }
  67. $seller_model->createSellerSession($this->member_info,$this->store_info,$this->seller_info, $this->seller_group_info);
  68. if ($this->seller_info['is_admin'] !== 1 && request()->controller() !== 'Sellerindex' && request()->controller() !== 'Sellerlogout' && !(request()->controller() == 'Sellergoodsclass' && request()->action() == 'get_tree')) {
  69. $seller_limits=isset($this->seller_group_info['sellergroup_limits'])?explode('|', $this->seller_group_info['sellergroup_limits']):'';
  70. if (!in_array(request()->controller(), $seller_limits)) {
  71. ds_json_encode(10001,lang('have_no_legalpower'));
  72. }
  73. }
  74. }
  75. /**
  76. * 记录卖家日志
  77. *
  78. * @param $content 日志内容
  79. * @param $state 1成功 0失败
  80. */
  81. protected function recordSellerlog($content = '', $state = 1) {
  82. $seller_info = array();
  83. $seller_info['sellerlog_content'] = $content;
  84. $seller_info['sellerlog_time'] = TIMESTAMP;
  85. $seller_info['sellerlog_seller_id'] =$this->seller_info['seller_id'];
  86. $seller_info['sellerlog_seller_name'] = $this->seller_info['seller_name'];
  87. $seller_info['sellerlog_store_id'] = $this->store_info['store_id'];
  88. $seller_info['sellerlog_seller_ip'] = request()->ip();
  89. $seller_info['sellerlog_url'] = 'home/' . request()->controller() . '/' . request()->action();
  90. $seller_info['sellerlog_state'] = $state;
  91. $sellerlog_model = model('sellerlog');
  92. $sellerlog_model->addSellerlog($seller_info);
  93. }
  94. /**
  95. * 记录店铺费用
  96. *
  97. * @param $storecost_price 费用金额
  98. * @param $storecost_remark 费用备注
  99. */
  100. protected function recordStorecost($storecost_price, $storecost_remark) {
  101. // 平台店铺不记录店铺费用
  102. if ($this->store_info['is_platform_store']) {
  103. return false;
  104. }
  105. $storecost_model = model('storecost');
  106. $param = array();
  107. $param['storecost_store_id'] = $this->store_info['store_id'];
  108. $param['storecost_seller_id'] = $this->seller_info['seller_id'];
  109. $param['storecost_price'] = $storecost_price;
  110. $param['storecost_remark'] = $storecost_remark;
  111. $param['storecost_state'] = 0;
  112. $param['storecost_time'] = TIMESTAMP;
  113. $storecost_model->addStorecost($param);
  114. // 发送店铺消息
  115. $param = array();
  116. $param['code'] = 'store_cost';
  117. $param['store_id'] = $this->store_info['store_id'];
  118. $param['ali_param'] = array(
  119. 'price' => $storecost_price,
  120. 'seller_name' => $this->seller_info['seller_name'],
  121. 'remark' => $storecost_remark
  122. );
  123. $param['ten_param'] = array(
  124. $storecost_price,
  125. $this->seller_info['seller_name'],
  126. $storecost_remark
  127. );
  128. $param['param'] = $param['ali_param'];
  129. //微信模板消息
  130. $param['weixin_param'] = array(
  131. 'url' => config('ds_config.h5_store_site_url').'/pages/seller/cost/CostList',
  132. 'data'=>array(
  133. "keyword1" => array(
  134. "value" => $storecost_price,
  135. "color" => "#333"
  136. ),
  137. "keyword2" => array(
  138. "value" => date('Y-m-d H:i'),
  139. "color" => "#333"
  140. )
  141. ),
  142. );
  143. model('cron')->addCron(array('cron_exetime'=>TIMESTAMP,'cron_type'=>'sendStoremsg','cron_value'=>serialize($param)));
  144. }
  145. }
  146. ?>