BaseSeller.php 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526
  1. <?php
  2. /*
  3. * 卖家相关控制中心
  4. */
  5. namespace app\home\controller;
  6. use think\facade\View;
  7. use think\facade\Lang;
  8. /**
  9. *
  10. *
  11. * ----------------------------------------------------------------------------
  12. *
  13. * 控制器
  14. */
  15. class BaseSeller extends BaseMall
  16. {
  17. //店铺信息
  18. protected $store_info = array();
  19. public function initialize()
  20. {
  21. parent::initialize();
  22. Lang::load(base_path() . 'home/lang/' . config('lang.default_lang') . '/basemember.lang.php');
  23. Lang::load(base_path() . 'home/lang/' . config('lang.default_lang') . '/baseseller.lang.php');
  24. if (input('post.PHPSESSID') && !session('seller_id') && request()->controller() == 'SellerTaobaoImport' && request()->action() == 'upload') {
  25. $this->app->session->setId(input('post.PHPSESSID'));
  26. $this->app->session->init();
  27. session('limited', 1);
  28. }
  29. if (session('limited') && (request()->controller() != 'SellerTaobaoImport' || request()->action() != 'upload')) {
  30. $this->redirect('home/Sellerlogin/login');
  31. }
  32. //卖家中心模板路径
  33. $this->template_dir = 'default/seller/' . strtolower(request()->controller()) . '/';
  34. if (request()->controller() != 'Sellerlogin') {
  35. if (!session('member_id')) {
  36. $this->redirect('home/Sellerlogin/login');
  37. }
  38. if (!session('seller_id')) {
  39. $this->redirect('home/Sellerlogin/login');
  40. }
  41. // 验证店铺是否存在
  42. $store_model = model('store');
  43. $this->store_info = $store_model->getStoreInfoByID(session('store_id'));
  44. if (empty($this->store_info)) {
  45. $this->redirect('home/Sellerlogin/login');
  46. }
  47. // 店铺关闭标志
  48. if (intval($this->store_info['store_state']) === 0) {
  49. View::assign('store_closed', true);
  50. View::assign('store_close_info', $this->store_info['store_close_info']);
  51. }
  52. // 店铺等级
  53. if (session('is_platform_store')) {
  54. $this->store_grade = array(
  55. 'storegrade_id' => '0',
  56. 'storegrade_name' => lang('exclusive_grade_stores'),
  57. 'storegrade_goods_limit' => '0',
  58. 'storegrade_album_limit' => '0',
  59. 'storegrade_space_limit' => '999999999',
  60. 'storegrade_template_number' => '6',
  61. // 'storegrade_template' => 'default|style1|style2|style3|style4|style5',
  62. 'storegrade_price' => '0.00',
  63. 'storegrade_description' => '',
  64. 'storegrade_sort' => '255',
  65. );
  66. } else {
  67. $store_grade = rkcache('storegrade', true);
  68. $this->store_grade = @$store_grade[$this->store_info['grade_id']];
  69. }
  70. if (session('seller_is_admin') !== 1 && request()->controller() !== 'Seller' && request()->controller() !== 'Sellerlogin') {
  71. $this->checkPermission();
  72. }
  73. }
  74. }
  75. /**
  76. * 记录卖家日志
  77. *
  78. * @param $content 日志内容
  79. * @param $state 1成功 0失败
  80. */
  81. protected function recordSellerlog($content = '', $state = 1)
  82. {
  83. $seller_info = array();
  84. $seller_info['sellerlog_content'] = $content;
  85. $seller_info['sellerlog_time'] = TIMESTAMP;
  86. $seller_info['sellerlog_seller_id'] = session('seller_id');
  87. $seller_info['sellerlog_seller_name'] = session('seller_name');
  88. $seller_info['sellerlog_store_id'] = session('store_id');
  89. $seller_info['sellerlog_seller_ip'] = request()->ip();
  90. $seller_info['sellerlog_url'] = 'home/' . request()->controller() . '/' . request()->action();
  91. $seller_info['sellerlog_state'] = $state;
  92. $sellerlog_model = model('sellerlog');
  93. $sellerlog_model->addSellerlog($seller_info);
  94. }
  95. /**
  96. * 记录店铺费用
  97. *
  98. * @param $storecost_price 费用金额
  99. * @param $storecost_remark 费用备注
  100. */
  101. protected function recordStorecost($storecost_price, $storecost_remark)
  102. {
  103. // 平台店铺不记录店铺费用
  104. if (check_platform_store()) {
  105. return false;
  106. }
  107. $storecost_model = model('storecost');
  108. $param = array();
  109. $param['storecost_store_id'] = session('store_id');
  110. $param['storecost_seller_id'] = session('seller_id');
  111. $param['storecost_price'] = $storecost_price;
  112. $param['storecost_remark'] = $storecost_remark;
  113. $param['storecost_state'] = 0;
  114. $param['storecost_time'] = TIMESTAMP;
  115. $storecost_model->addStorecost($param);
  116. // 发送店铺消息
  117. $param = array();
  118. $param['code'] = 'store_cost';
  119. $param['store_id'] = session('store_id');
  120. $param['ali_param'] = array(
  121. 'price' => $storecost_price,
  122. 'seller_name' => session('seller_name'),
  123. 'remark' => $storecost_remark
  124. );
  125. $param['ten_param'] = array(
  126. $storecost_price,
  127. session('seller_name'),
  128. $storecost_remark
  129. );
  130. $param['param'] = $param['ali_param'];
  131. //微信模板消息
  132. $param['weixin_param'] = array(
  133. 'url' => config('ds_config.h5_store_site_url') . '/pages/seller/cost/CostList',
  134. 'data' => array(
  135. "keyword1" => array(
  136. "value" => $storecost_price,
  137. "color" => "#333"
  138. ),
  139. "keyword2" => array(
  140. "value" => date('Y-m-d H:i'),
  141. "color" => "#333"
  142. )
  143. ),
  144. );
  145. model('cron')->addCron(array('cron_exetime' => TIMESTAMP, 'cron_type' => 'sendStoremsg', 'cron_value' => serialize($param)));
  146. }
  147. /**
  148. * 添加到任务队列
  149. *
  150. * @param array $goods_array
  151. * @param boolean $ifdel 是否删除以原记录
  152. */
  153. protected function addcron($data = array(), $ifdel = false)
  154. {
  155. $cron_model = model('cron');
  156. if (isset($data[0])) { // 批量插入
  157. $where = array();
  158. foreach ($data as $k => $v) {
  159. // 删除原纪录条件
  160. if ($ifdel) {
  161. $where[] = '(cron_type = "' . $data['cron_type'] . '" and cron_value = "' . $data['cron_value'] . '")';
  162. }
  163. }
  164. // 删除原纪录
  165. if ($ifdel) {
  166. $cron_model->delCron(implode(',', $where));
  167. }
  168. $cron_model->addCronAll($data);
  169. } else { // 单条插入
  170. // 删除原纪录
  171. if ($ifdel) {
  172. $cron_model->delCron(array('cron_type' => $data['cron_type'], 'cron_value' => $data['cron_value']));
  173. }
  174. $cron_model->addCron($data);
  175. }
  176. }
  177. /**
  178. * 当前选中的栏目
  179. */
  180. protected function setSellerCurItem($curitem = '')
  181. {
  182. View::assign('seller_item', $this->getSellerItemList());
  183. View::assign('curitem', $curitem);
  184. }
  185. /**
  186. * 当前选中的子菜单
  187. */
  188. protected function setSellerCurMenu($cursubmenu = '')
  189. {
  190. $seller_menu = self::getSellerMenuList($this->store_info['is_platform_store']);
  191. $seller_menu = $this->parseMenu($seller_menu);
  192. View::assign('seller_menu', $seller_menu);
  193. $curmenu = '';
  194. foreach ($seller_menu as $key => $menu) {
  195. foreach ($menu['submenu'] as $subkey => $submenu) {
  196. if ($submenu['name'] == $cursubmenu) {
  197. $curmenu = $menu['name'];
  198. }
  199. }
  200. }
  201. //当前一级菜单
  202. View::assign('curmenu', $curmenu);
  203. //当前二级菜单
  204. View::assign('cursubmenu', $cursubmenu);
  205. }
  206. /*
  207. * 获取卖家栏目列表,针对控制器下的栏目
  208. */
  209. protected function getSellerItemList()
  210. {
  211. return array();
  212. }
  213. /**
  214. * 验证当前管理员权限是否可以进行操作
  215. *
  216. * @param string $link_nav
  217. * @return
  218. */
  219. protected final function checkPermission($link_nav = null)
  220. {
  221. if (session('seller_is_admin') == 1)
  222. return true;
  223. $controller = request()->controller();
  224. $action = request()->action();
  225. if (!empty(session('seller_limits'))) {
  226. $permission = session('seller_limits');
  227. //显示隐藏小导航,成功与否都直接返回
  228. if (is_array($link_nav)) {
  229. if (!in_array("{$link_nav['controller']}.{$link_nav['action']}", $permission) && !in_array($link_nav['controller'], $permission)) {
  230. return false;
  231. } else {
  232. return true;
  233. }
  234. }
  235. //以下几项不需要验证
  236. $tmp = array();
  237. if (in_array($controller, $tmp)) {
  238. return true;
  239. }
  240. if (in_array($controller, $permission) || in_array("$controller.$action", $permission)) {
  241. return true;
  242. } else {
  243. $extlimit = array('ajax', 'export_step1');
  244. if (in_array($action, $extlimit) && (in_array($controller, $permission) || strpos(serialize($permission), '"' . $controller . '.'))) {
  245. return true;
  246. }
  247. //带前缀的都通过
  248. foreach ($permission as $v) {
  249. if (!empty($v) && strpos("$controller.$action", $v . '_') !== false) {
  250. return true;
  251. break;
  252. }
  253. }
  254. }
  255. }
  256. $this->error(lang('have_no_legalpower'), 'Seller/index');
  257. }
  258. /**
  259. * 过滤掉无权查看的菜单
  260. *
  261. * @param array $menu
  262. * @return array
  263. */
  264. private final function parseMenu($menu = array())
  265. {
  266. if (session('seller_is_admin') === 1) {
  267. return $menu;
  268. }
  269. foreach ($menu as $k => $v) {
  270. foreach ($v['submenu'] as $ck => $cv) {
  271. $tmp = array($cv['action'], $cv['controller']);
  272. //以下几项不需要验证
  273. $except = array();
  274. if (in_array($tmp[1], $except))
  275. continue;
  276. if (!in_array($tmp[1], session('seller_limits')) && !in_array($tmp[1] . '.' . $tmp[0], session('seller_limits'))) {
  277. unset($menu[$k]['submenu'][$ck]);
  278. }
  279. }
  280. if (empty($menu[$k]['submenu'])) {
  281. unset($menu[$k]);
  282. unset($menu[$k]['submenu']);
  283. } else {
  284. $temp = current($menu[$k]['submenu']);
  285. $menu[$k]['url'] = $temp['url'];
  286. }
  287. }
  288. return $menu;
  289. }
  290. /*
  291. * 获取卖家菜单列表
  292. */
  293. public static function getSellerMenuList($is_platform_store = 0)
  294. {
  295. //controller 注意第一个字母要大写
  296. $menu_list = array(
  297. 'sellergoods' =>
  298. array(
  299. 'ico' => '&#xe732;',
  300. 'name' => 'sellergoods',
  301. 'text' => lang('site_search_goods'),
  302. 'url' => (string) url('Sellergoodsonline/index'),
  303. 'submenu' => array(
  304. array('name' => 'sellergoodsadd', 'text' => lang('goods_released'), 'action' => null, 'controller' => 'Sellergoodsadd', 'url' => (string) url('Sellergoodsadd/index'),),
  305. array('name' => 'seller_taobao_import', 'text' => lang('taobao_import'), 'action' => null, 'controller' => 'SellerTaobaoImport', 'url' => (string) url('SellerTaobaoImport/index'),),
  306. array('name' => 'sellergoodsonline', 'text' => lang('goods_on_sale'), 'action' => null, 'controller' => 'Sellergoodsonline', 'url' => (string) url('Sellergoodsonline/index'),),
  307. array('name' => 'sellergoodsoffline', 'text' => lang('warehouse_goods'), 'action' => null, 'controller' => 'Sellergoodsoffline', 'url' => (string) url('Sellergoodsoffline/index'),),
  308. array('name' => 'sellerplate', 'text' => lang('associated_format'), 'action' => null, 'controller' => 'Sellerplate', 'url' => (string) url('Sellerplate/index'),),
  309. array('name' => 'sellerspec', 'text' => lang('product_specifications'), 'action' => null, 'controller' => 'Sellerspec', 'url' => (string) url('Sellerspec/index'),),
  310. array('name' => 'selleralbum', 'text' => lang('image_space'), 'action' => null, 'controller' => 'Selleralbum', 'url' => (string) url('Selleralbum/index'),),
  311. array('name' => 'sellervideo', 'text' => lang('seller_goodsvideo'), 'action' => null, 'controller' => 'Sellervideo', 'url' => (string) url('Sellervideo/index'),),
  312. array('name' => 'seller_service', 'text' => lang('seller_service'), 'action' => null, 'controller' => 'SellerService', 'url' => (string) url('SellerService/index'),),
  313. )
  314. ),
  315. 'sellerorder' =>
  316. array(
  317. 'ico' => '&#xe71f;',
  318. 'name' => 'sellerorder',
  319. 'text' => lang('pointsorderdesc_1'),
  320. 'url' => (string) url('Sellerorder/index'),
  321. 'submenu' => array(
  322. array('name' => 'sellerorder', 'text' => lang('order_physical_transaction'), 'action' => null, 'controller' => 'Sellerorder', 'url' => (string) url('Sellerorder/index'),),
  323. array('name' => 'sellervrorder', 'text' => lang('code_order'), 'action' => null, 'controller' => 'Sellervrorder', 'url' => (string) url('Sellervrorder/index'),),
  324. array('name' => 'sellerdeliver', 'text' => lang('delivery_management'), 'action' => null, 'controller' => 'Sellerdeliver', 'url' => (string) url('Sellerdeliver/index'),),
  325. array('name' => 'sellerdeliverset', 'text' => lang('delivery_settings'), 'action' => null, 'controller' => 'Sellerdeliverset', 'url' => (string) url('Sellerdeliverset/index'),),
  326. array('name' => 'sellerevaluate', 'text' => lang('evaluation_management'), 'action' => null, 'controller' => 'Sellerevaluate', 'url' => (string) url('Sellerevaluate/index'),),
  327. array('name' => 'sellertransport', 'text' => lang('sales_area'), 'action' => null, 'controller' => 'Sellertransport', 'url' => (string) url('Sellertransport/index'),),
  328. array('name' => 'Sellerbill', 'text' => lang('physical_settlement'), 'action' => null, 'controller' => 'Sellerbill', 'url' => (string) url('Sellerbill/index'),),
  329. )
  330. ),
  331. 'sellergroupbuy' =>
  332. array(
  333. 'ico' => '&#xe704;',
  334. 'name' => 'sellergroupbuy',
  335. 'text' => lang('sales_promotion'),
  336. 'url' => (string) url('Sellergroupbuy/index'),
  337. 'submenu' => array(
  338. array('name' => 'Sellerpromotionwholesale', 'text' => lang('wholesale_management'), 'action' => null, 'controller' => 'Sellerpromotionwholesale', 'url' => (string) url('Sellerpromotionwholesale/index'),),
  339. array('name' => 'Sellergroupbuy', 'text' => lang('snap_up_management'), 'action' => null, 'controller' => 'Sellergroupbuy', 'url' => (string) url('Sellergroupbuy/index'),),
  340. array('name' => 'Sellerpromotionxianshi', 'text' => lang('time_discount'), 'action' => null, 'controller' => 'Sellerpromotionxianshi', 'url' => (string) url('Sellerpromotionxianshi/index'),),
  341. array('name' => 'Sellermgdiscount', 'text' => lang('membership_level_discount'), 'action' => null, 'controller' => 'Sellerpromotionmgdiscount', 'url' => (string) url('Sellerpromotionmgdiscount/mgdiscount_store'),),
  342. array('name' => 'Sellerpromotionpintuan', 'text' => lang('syndication'), 'action' => null, 'controller' => 'Sellerpromotionpintuan', 'url' => (string) url('Sellerpromotionpintuan/index'),),
  343. array('name' => 'Sellerpromotionbargain', 'text' => lang('baseseller_bargain'), 'action' => null, 'controller' => 'Sellerpromotionbargain', 'url' => (string) url('Sellerpromotionbargain/index'),),
  344. array('name' => 'Sellerpromotionpresell', 'text' => lang('baseseller_presell'), 'action' => null, 'controller' => 'Sellerpromotionpresell', 'url' => (string) url('Sellerpromotionpresell/index'),),
  345. array('name' => 'Sellerpromotionmansong', 'text' => lang('free_on_delivery'), 'action' => null, 'controller' => 'Sellerpromotionmansong', 'url' => (string) url('Sellerpromotionmansong/index'),),
  346. array('name' => 'Sellerpromotionbundling', 'text' => lang('discount_package'), 'action' => null, 'controller' => 'Sellerpromotionbundling', 'url' => (string) url('Sellerpromotionbundling/index'),),
  347. array('name' => 'Sellerpromotionbooth', 'text' => lang('recommended_stand'), 'action' => null, 'controller' => 'Sellerpromotionbooth', 'url' => (string) url('Sellerpromotionbooth/index'),),
  348. array('name' => 'Sellervoucher', 'text' => lang('voucher_management'), 'action' => null, 'controller' => 'Sellervoucher', 'url' => (string) url('Sellervoucher/templatelist'),),
  349. array('name' => 'Selleractivity', 'text' => lang('activity_management'), 'action' => null, 'controller' => 'Selleractivity', 'url' => (string) url('Selleractivity/index'),),
  350. )
  351. ),
  352. 'seller' =>
  353. array(
  354. 'ico' => '&#xe663;',
  355. 'name' => 'seller',
  356. 'text' => lang('site_search_store'),
  357. 'url' => (string) url('Seller/index'),
  358. 'submenu' => array(
  359. array('name' => 'seller_index', 'text' => lang('store_overview'), 'action' => null, 'controller' => 'Seller', 'url' => (string) url('Seller/index'),),
  360. array('name' => 'seller_setting', 'text' => lang('store_setup'), 'action' => null, 'controller' => 'Sellersetting', 'url' => (string) url('Sellersetting/setting'),),
  361. array('name' => 'seller_editable_page_pc', 'text' => lang('store_editable_page_pc'), 'action' => 'page_list', 'controller' => 'SellerEditablePage', 'url' => (string) url('SellerEditablePage/page_list'),),
  362. array('name' => 'seller_editable_page_h5', 'text' => lang('store_editable_page_h5'), 'action' => 'h5_page_list', 'controller' => 'SellerEditablePage', 'url' => (string) url('SellerEditablePage/h5_page_list'),),
  363. array('name' => 'seller_navigation', 'text' => lang('store_navigation'), 'action' => null, 'controller' => 'Sellernavigation', 'url' => (string) url('Sellernavigation/index'),),
  364. array('name' => 'sellersns', 'text' => lang('store_dynamics'), 'action' => null, 'controller' => 'Sellersns', 'url' => (string) url('Sellersns/index'),),
  365. array('name' => 'sellergoodsclass', 'text' => lang('store_classification'), 'action' => null, 'controller' => 'Sellergoodsclass', 'url' => (string) url('Sellergoodsclass/index'),),
  366. array('name' => 'seller_chain', 'text' => lang('seller_chain'), 'action' => null, 'controller' => 'SellerChain', 'url' => (string) url('SellerChain/index'),),
  367. array('name' => 'seller_brand', 'text' => lang('brand_application'), 'action' => null, 'controller' => 'Sellerbrand', 'url' => (string) url('Sellerbrand/index'),),
  368. )
  369. ),
  370. 'sellerconsult' =>
  371. array(
  372. 'ico' => '&#xe6ab;',
  373. 'name' => 'sellerconsult',
  374. 'text' => lang('after_sales_service'),
  375. 'url' => (string) url('Sellerconsult/index'),
  376. 'submenu' => array(
  377. array('name' => 'seller_consult', 'text' => lang('consulting_management'), 'action' => null, 'controller' => 'Sellerconsult', 'url' => (string) url('Sellerconsult/index'),),
  378. array('name' => 'seller_complain', 'text' => lang('complaint_record'), 'action' => null, 'controller' => 'Sellercomplain', 'url' => (string) url('Sellercomplain/index'),),
  379. array('name' => 'seller_refund', 'text' => lang('refund_paragraph'), 'action' => null, 'controller' => 'Sellerrefund', 'url' => (string) url('Sellerrefund/index'),),
  380. array('name' => 'seller_return', 'text' => lang('refund_cargo'), 'action' => null, 'controller' => 'Sellerreturn', 'url' => (string) url('Sellerreturn/index'),),
  381. )
  382. ),
  383. 'sellerstatistics' =>
  384. array(
  385. 'ico' => '&#xe6a3;',
  386. 'name' => 'sellerstatistics',
  387. 'text' => lang('statistics'),
  388. 'url' => (string) url('Statisticsgeneral/index'),
  389. 'submenu' => array(
  390. array('name' => 'Statisticsgeneral', 'text' => lang('store_overview'), 'action' => null, 'controller' => 'Statisticsgeneral', 'url' => (string) url('Statisticsgeneral/index'),),
  391. array('name' => 'Statisticsgoods', 'text' => lang('commodity_analysis'), 'action' => null, 'controller' => 'Statisticsgoods', 'url' => (string) url('Statisticsgoods/index'),),
  392. array('name' => 'Statisticssale', 'text' => lang('operational_report'), 'action' => null, 'controller' => 'Statisticssale', 'url' => (string) url('Statisticssale/index'),),
  393. array('name' => 'Statisticsindustry', 'text' => lang('industry_analysis'), 'action' => null, 'controller' => 'Statisticsindustry', 'url' => (string) url('Statisticsindustry/index'),),
  394. array('name' => 'Statisticsflow', 'text' => lang('traffic_statistics'), 'action' => null, 'controller' => 'Statisticsflow', 'url' => (string) url('Statisticsflow/index'),),
  395. )
  396. ),
  397. 'sellercallcenter' =>
  398. array(
  399. 'ico' => '&#xe61c;',
  400. 'name' => 'sellercallcenter',
  401. 'text' => lang('news_service'),
  402. 'url' => (string) url('Sellercallcenter/index'),
  403. 'submenu' => array(
  404. array('name' => 'Sellercallcenter', 'text' => lang('setting_service'), 'action' => null, 'controller' => 'Sellercallcenter', 'url' => (string) url('Sellercallcenter/index'),),
  405. array('name' => 'Sellermsg', 'text' => lang('system_message'), 'action' => null, 'controller' => 'Sellermsg', 'url' => (string) url('Sellermsg/index'),),
  406. array('name' => 'seller_instant_message', 'text' => lang('chat_query'), 'action' => null, 'controller' => 'SellerInstantMessage', 'url' => (string) url('SellerInstantMessage/index'),),
  407. )
  408. ),
  409. 'selleraccount' =>
  410. array(
  411. 'ico' => '&#xe702;',
  412. 'name' => 'selleraccount',
  413. 'text' => lang('account'),
  414. 'url' => (string) url('Selleraccount/account_list'),
  415. 'submenu' => array(
  416. array('name' => 'selleraccount', 'text' => lang('account_list'), 'action' => null, 'controller' => 'Selleraccount', 'url' => (string) url('Selleraccount/account_list'),),
  417. array('name' => 'selleraccountgroup', 'text' => lang('account_group'), 'action' => null, 'controller' => 'Selleraccountgroup', 'url' => (string) url('Selleraccountgroup/group_list'),),
  418. array('name' => 'sellerlog', 'text' => lang('account_log'), 'action' => null, 'controller' => 'Sellerlog', 'url' => (string) url('Sellerlog/log_list'),),
  419. )
  420. ),
  421. );
  422. if (!$is_platform_store) {
  423. $menu_list['seller']['submenu'] = array_merge(array(array('name' => 'seller_money', 'text' => lang('store_money'), 'action' => null, 'controller' => 'Sellermoney', 'url' => (string) url('Sellermoney/index'),), array('name' => 'seller_deposit', 'text' => lang('store_deposit'), 'action' => null, 'controller' => 'Sellerdeposit', 'url' => (string) url('Sellerdeposit/index'),), array('name' => 'sellerinfo', 'text' => lang('store_information'), 'action' => null, 'controller' => 'Sellerinfo', 'url' => (string) url('Sellerinfo/index'),),), $menu_list['seller']['submenu']);
  424. $menu_list['selleraccount']['submenu'] = array_merge(array(array('name' => 'sellercost', 'text' => lang('store_consumption'), 'action' => null, 'controller' => 'Sellercost', 'url' => (string) url('Sellercost/cost_list'),)), $menu_list['selleraccount']['submenu']);
  425. }
  426. if (config('ds_config.inviter_open')) {
  427. $menu_list['sellerinviter'] = array(
  428. 'ico' => '&#xe6ed;',
  429. 'name' => 'sellerinviter',
  430. 'text' => lang('distribution'),
  431. 'url' => (string) url('Sellerinviter/goods_list'),
  432. 'submenu' => array(
  433. array('name' => 'sellerinviter_goods', 'text' => lang('distribution_management'), 'action' => 'goods_list', 'controller' => 'Sellerinviter', 'url' => (string) url('Sellerinviter/goods_list'),),
  434. array('name' => 'sellerinviter_order', 'text' => lang('distribution_earnings'), 'action' => 'order_list', 'controller' => 'Sellerinviter', 'url' => (string) url('Sellerinviter/order_list'),),
  435. )
  436. );
  437. }
  438. return $menu_list;
  439. }
  440. /**
  441. * 自动发布店铺动态
  442. *
  443. * @param array $data 相关数据
  444. * @param string $type 类型 'new','coupon','xianshi','mansong','bundling','groupbuy'
  445. * 所需字段
  446. * new goods表' goods_id,store_id,goods_name,goods_image,goods_price,goods_transfee_charge,goods_freight
  447. * xianshi pxianshigoods表' goods_id,store_id,goods_name,goods_image,goods_price,goods_freight,xianshi_price
  448. * mansong pmansong表' mansong_name,start_time,end_time,store_id
  449. * bundling pbundling表' bl_id,bl_name,bl_img,bl_discount_price,bl_freight_choose,bl_freight,store_id
  450. * groupbuy goodsgroup表' group_id,group_name,goods_id,goods_price,groupbuy_price,group_pic,rebate,start_time,end_time
  451. * coupon在后台发布
  452. */
  453. public function storeAutoShare($data, $type)
  454. {
  455. $param = array(
  456. 3 => 'new',
  457. 4 => 'coupon',
  458. 5 => 'xianshi',
  459. 6 => 'mansong',
  460. 7 => 'bundling',
  461. 8 => 'groupbuy'
  462. );
  463. $param_flip = array_flip($param);
  464. if (!in_array($type, $param) || empty($data)) {
  465. return false;
  466. }
  467. $auto_setting = model('storesnssetting')->getStoresnssettingInfo(array('storesnsset_storeid' => session('store_id')));
  468. $auto_sign = false; // 自动发布开启标志
  469. if ($auto_setting['storesnsset_' . $type] == 1) {
  470. $auto_sign = true;
  471. $goodsdata = addslashes(json_encode($data));
  472. if ($auto_setting['storesnsset_' . $type . 'title'] != '') {
  473. $title = $auto_setting['storesnsset_' . $type . 'title'];
  474. } else {
  475. $auto_title = 'ds_store_auto_share_' . $type . rand(1, 5);
  476. $title = lang($auto_title);
  477. }
  478. }
  479. if ($auto_sign) {
  480. // 插入数据
  481. $stracelog_array = array();
  482. $stracelog_array['stracelog_storeid'] = $this->store_info['store_id'];
  483. $stracelog_array['stracelog_storename'] = $this->store_info['store_name'];
  484. $stracelog_array['stracelog_storelogo'] = empty($this->store_info['store_avatar']) ? '' : $this->store_info['store_avatar'];
  485. $stracelog_array['stracelog_title'] = $title;
  486. $stracelog_array['stracelog_content'] = '';
  487. $stracelog_array['stracelog_time'] = TIMESTAMP;
  488. $stracelog_array['stracelog_type'] = $param_flip[$type];
  489. $stracelog_array['stracelog_goodsdata'] = $goodsdata;
  490. model('storesnstracelog')->addStoresnstracelog($stracelog_array);
  491. return true;
  492. } else {
  493. return false;
  494. }
  495. }
  496. }