MobileSeller.php 6.8 KB

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