Index.php 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  1. <?php
  2. namespace app\api\controller;
  3. use think\facade\Db;
  4. /**
  5. *
  6. *
  7. * ----------------------------------------------------------------------------
  8. *
  9. * 公共数据控制器
  10. */
  11. class Index extends MobileMall
  12. {
  13. public function initialize()
  14. {
  15. parent::initialize();
  16. }
  17. /**
  18. * @api {POST} api/Index/getEditablePageConfigList 获取可编辑模块配置列表
  19. * @apiVersion 1.0.0
  20. * @apiGroup Index
  21. *
  22. * @apiSuccess {String} code 返回码,10000为成功
  23. * @apiSuccess {String} message 返回消息
  24. * @apiSuccess {Object} result 返回数据
  25. * @apiSuccess {Object} result.editable_page 可编辑页面类型数据
  26. * @apiSuccess {Int} result.editable_page.editable_page_id 页面类型id
  27. * @apiSuccess {String} result.editable_page.editable_page_name 页面名称
  28. * @apiSuccess {String} result.editable_page.editable_page_path index/index商场首页store/index店铺首页special/index专题活动页
  29. * @apiSuccess {Int} result.editable_page.editable_page_item_id 页面项目id
  30. * @apiSuccess {Int} result.editable_page.store_id 店铺id
  31. * @apiSuccess {String} result.editable_page.editable_page_client 客户端pc、h5
  32. * @apiSuccess {String} result.editable_page.editable_page_theme 页面主题
  33. * @apiSuccess {String} result.editable_page.editable_page_theme_config 页面主题配置
  34. * @apiSuccess {Int} result.editable_page.editable_page_edit_time 页面编辑时间
  35. * @apiSuccess {Object} result.editable_page_config_list 可编辑页面数据
  36. * @apiSuccess {Int} result.editable_page_config_list.editable_page_config_id 页面配置id
  37. * @apiSuccess {Int} result.editable_page_config_list.editable_page_id 页面id
  38. * @apiSuccess {Int} result.editable_page_config_list.editable_page_model_id 页面模块id
  39. * @apiSuccess {Int} result.editable_page_config_list.editable_page_config_sort_order 排序
  40. * @apiSuccess {String} result.editable_page_config_list.editable_page_config_content 配置内容
  41. */
  42. public function getEditablePageConfigList()
  43. {
  44. $store_id = intval(input('param.store_id'));
  45. $editable_page_id = intval(input('param.editable_page_id'));
  46. $editable_page_path = input('param.editable_page_path');
  47. $editable_page_item_id = intval(input('param.editable_page_item_id'));
  48. $editable_page_model = model('editable_page');
  49. if (!$editable_page_id && !$editable_page_path) {
  50. ds_json_encode(10001, lang('param_error'));
  51. }
  52. $condition = array();
  53. $condition[] = array('editable_page_client', '=', 'h5');
  54. if ($editable_page_id) {
  55. $condition[] = array('editable_page_id', '=', $editable_page_id);
  56. } else {
  57. $condition[] = array('editable_page_path', '=', $editable_page_path);
  58. $condition[] = array('editable_page_item_id', '=', $editable_page_item_id);
  59. }
  60. if ($store_id) {
  61. $condition[] = array('store_id', '=', $store_id);
  62. }
  63. $editable_page_config_list = false;
  64. $editable_page = $editable_page_model->getOneEditablePage($condition);
  65. if ($editable_page) {
  66. $editable_page['editable_page_theme_config'] = json_decode($editable_page['editable_page_theme_config'], true);
  67. $editable_page_config_model = model('editable_page_config');
  68. $editable_page_config_list = $editable_page_config_model->getEditablePageConfigList(array(array('editable_page_id', '=', $editable_page['editable_page_id'])));
  69. foreach ($editable_page_config_list as $key => $val) {
  70. $config_info = json_decode($val['editable_page_config_content'], true);
  71. $model_id = $val['editable_page_model_id'];
  72. if (!empty($config_info)) {
  73. require_once PLUGINS_PATH . '/editable_page_model/h5_' . $model_id . '/config.php';
  74. $model_name = 'Model' . $model_id;
  75. $model = new $model_name();
  76. $res = $model->filterData($config_info);
  77. if ($res['code']) {
  78. $res = $model->formatData(json_encode($res['data']), $store_id);
  79. if ($res['code']) {
  80. $editable_page_config_list[$key]['editable_page_config_content'] = $res['data'];
  81. }
  82. }
  83. }
  84. }
  85. }
  86. ds_json_encode(10000, '', array('editable_page_config_list' => $editable_page_config_list, 'editable_page' => $editable_page));
  87. }
  88. /**
  89. * @api {POST} api/Index/search_key_list 默认搜索词列表
  90. * @apiVersion 1.0.0
  91. * @apiGroup Index
  92. *
  93. * @apiSuccess {String} code 返回码,10000为成功
  94. * @apiSuccess {String} message 返回消息
  95. * @apiSuccess {Object} result 返回数据
  96. * @apiSuccess {String[]} result.list 热门搜索列表
  97. * @apiSuccess {String[]} result.his_list 历史搜索列表
  98. */
  99. public function search_key_list()
  100. {
  101. $list = @explode(',', config('ds_config.hot_search'));
  102. if (!$list || !is_array($list)) {
  103. $list = array();
  104. }
  105. if (cookie('hisSearch') != '') {
  106. $his_search_list = explode('~', cookie('hisSearch'));
  107. } else {
  108. $his_search_list = array();
  109. }
  110. if (!is_array($his_search_list)) {
  111. $his_search_list = array();
  112. }
  113. ds_json_encode(10000, '', array('list' => $list, 'his_list' => $his_search_list));
  114. }
  115. /**
  116. * @api {POST} api/Index/getAppadList VueJS 获取广告图
  117. * @apiVersion 1.0.0
  118. * @apiGroup Index
  119. * @apiParam {String} ap_id 广告分类ID
  120. *
  121. * @apiSuccess {String} code 返回码,10000为成功
  122. * @apiSuccess {String} message 返回消息
  123. * @apiSuccess {Object} result 返回数据
  124. * @apiSuccess {Object[]} result.ad_list 广告图列表
  125. * @apiSuccess {Int} result.ad_list.adv_id 广告ID
  126. * @apiSuccess {Int} result.ad_list.ap_id 广告位ID
  127. * @apiSuccess {String} result.ad_list.adv_title 广告标题
  128. * @apiSuccess {String} result.ad_list.adv_type APP广告类型,goods,store,article
  129. * @apiSuccess {String} result.ad_list.adv_typedate APP广告类型对应的值
  130. * @apiSuccess {String} result.ad_list.adv_code APP广告图片地址
  131. * @apiSuccess {Int} result.ad_list.adv_startdate APP广告开始时间,Unix时间戳
  132. * @apiSuccess {Int} result.ad_list.adv_enddate APP广告结束时间,Unix时间戳
  133. * @apiSuccess {Int} result.ad_list.adv_sort 广告图排序
  134. * @apiSuccess {Int} result.ad_list.adv_enabled 是否开启广告图 1是0否
  135. */
  136. public function getAppadList()
  137. {
  138. $ap_id = intval(input('param.ap_id'));
  139. if ($ap_id <= 0) {
  140. ds_json_encode(10001, lang('param_error'));
  141. }
  142. $prefix = 'api-getAppadList-';
  143. $result = rcache($ap_id, $prefix);
  144. if (empty($result)) {
  145. $condition = array();
  146. $condition[] = array('ap_id', '=', $ap_id);
  147. $condition[] = array('adv_enabled', '=', 1);
  148. $condition[] = array('adv_startdate', '<', TIMESTAMP);
  149. $condition[] = array('adv_enddate', '>', TIMESTAMP);
  150. $ad_list = model('appadv')->getAppadvList($condition);
  151. if (!empty($ad_list)) {
  152. foreach ($ad_list as $key => $banner) {
  153. $ad_list[$key]['adv_code'] = get_appadv_code($banner['adv_code']);
  154. }
  155. }
  156. $result['ad_list'] = $ad_list;
  157. wcache($ap_id, $result, $prefix, 3600);
  158. }
  159. ds_json_encode(10000, '', $result);
  160. }
  161. /**
  162. * @api {POST} api/Index/getIndexAdList 获取首页广告图
  163. * @apiVersion 1.0.0
  164. * @apiGroup Index
  165. *
  166. * @apiSuccess {String} code 返回码,10000为成功
  167. * @apiSuccess {String} message 返回消息
  168. * @apiSuccess {Object} result 返回数据
  169. * @apiSuccess {Object[]} result.banners 广告图列表
  170. * @apiSuccess {Int} result.banners.adv_id 广告ID
  171. * @apiSuccess {Int} result.banners.ap_id 广告位ID
  172. * @apiSuccess {String} result.banners.adv_title 广告标题
  173. * @apiSuccess {String} result.banners.adv_type APP广告类型,goods,store,article
  174. * @apiSuccess {String} result.banners.adv_typedate APP广告类型对应的值
  175. * @apiSuccess {String} result.banners.adv_code APP广告图片地址
  176. * @apiSuccess {Int} result.banners.adv_startdate APP广告开始时间,Unix时间戳
  177. * @apiSuccess {Int} result.banners.adv_enddate APP广告结束时间,Unix时间戳
  178. * @apiSuccess {Int} result.banners.adv_sort 广告图排序
  179. * @apiSuccess {Int} result.banners.adv_enabled 是否开启广告图 1是0否
  180. * @apiSuccess {Object[]} result.promotion_ads 广告图列表
  181. * @apiSuccess {Int} result.promotion_ads.adv_id 广告ID
  182. * @apiSuccess {Int} result.promotion_ads.ap_id 广告位ID
  183. * @apiSuccess {String} result.promotion_ads.adv_title 广告标题
  184. * @apiSuccess {String} result.promotion_ads.adv_type APP广告类型,goods,store,article
  185. * @apiSuccess {String} result.promotion_ads.adv_typedate APP广告类型对应的值
  186. * @apiSuccess {String} result.promotion_ads.adv_code APP广告图片地址
  187. * @apiSuccess {Int} result.promotion_ads.adv_startdate APP广告开始时间,Unix时间戳
  188. * @apiSuccess {Int} result.promotion_ads.adv_enddate APP广告结束时间,Unix时间戳
  189. * @apiSuccess {Int} result.promotion_ads.adv_sort 广告图排序
  190. * @apiSuccess {Int} result.promotion_ads.adv_enabled 是否开启广告图 1是0否
  191. * @apiSuccess {Object[]} result.navs 广告图列表
  192. * @apiSuccess {Int} result.navs.adv_id 广告ID
  193. * @apiSuccess {Int} result.navs.ap_id 广告位ID
  194. * @apiSuccess {String} result.navs.adv_title 广告标题
  195. * @apiSuccess {String} result.navs.adv_type APP广告类型,goods,store,article
  196. * @apiSuccess {String} result.navs.adv_typedate APP广告类型对应的值
  197. * @apiSuccess {String} result.navs.adv_code APP广告图片地址
  198. * @apiSuccess {Int} result.navs.adv_startdate APP广告开始时间,Unix时间戳
  199. * @apiSuccess {Int} result.navs.adv_enddate APP广告结束时间,Unix时间戳
  200. * @apiSuccess {Int} result.navs.adv_sort 广告图排序
  201. * @apiSuccess {Int} result.navs.adv_enabled 是否开启广告图 1是0否
  202. * @apiSuccess {Object[]} result.floor_ads 广告图列表
  203. * @apiSuccess {Int} result.floor_ads.adv_id 广告ID
  204. * @apiSuccess {Int} result.floor_ads.ap_id 广告位ID
  205. * @apiSuccess {String} result.floor_ads.adv_title 广告标题
  206. * @apiSuccess {String} result.floor_ads.adv_type APP广告类型,goods,store,article
  207. * @apiSuccess {String} result.floor_ads.adv_typedate APP广告类型对应的值
  208. * @apiSuccess {String} result.floor_ads.adv_code APP广告图片地址
  209. * @apiSuccess {Int} result.floor_ads.adv_startdate APP广告开始时间,Unix时间戳
  210. * @apiSuccess {Int} result.floor_ads.adv_enddate APP广告结束时间,Unix时间戳
  211. * @apiSuccess {Int} result.floor_ads.adv_sort 广告图排序
  212. * @apiSuccess {Int} result.floor_ads.adv_enabled 是否开启广告图 1是0否
  213. */
  214. public function getIndexAdList()
  215. {
  216. $cache_key = "api-getIndexAdList";
  217. $result = rcache($cache_key);
  218. if (empty($result)) {
  219. $condition = array();
  220. $condition[] = array('adv_enabled', '=', 1);
  221. // 首页轮播图
  222. $condition[] = array('ap_id', '=', 1);
  223. $condition[] = array('adv_startdate', '<', TIMESTAMP);
  224. $condition[] = array('adv_enddate', '>', TIMESTAMP);
  225. $banners_list = model('appadv')->getAppadvList($condition);
  226. if (!empty($banners_list)) {
  227. foreach ($banners_list as $key => $banner) {
  228. $banners_list[$key]['adv_code'] = get_appadv_code($banner['adv_code']);
  229. }
  230. }
  231. $result['banners'] = $banners_list;
  232. // 首页促销
  233. $condition = array();
  234. $condition[] = array('adv_enabled', '=', 1);
  235. $condition[] = array('ap_id', '=', 2);
  236. $condition[] = array('adv_startdate', '<', TIMESTAMP);
  237. $condition[] = array('adv_enddate', '>', TIMESTAMP);
  238. $promotion_ads = model('appadv')->getAppadvList($condition);
  239. if (!empty($promotion_ads)) {
  240. foreach ($promotion_ads as $key => $banner) {
  241. $promotion_ads[$key]['adv_code'] = get_appadv_code($banner['adv_code']);
  242. }
  243. }
  244. $result['promotion_ads'] = $promotion_ads;
  245. // 首页Navs
  246. $condition = array();
  247. $condition[] = array('adv_enabled', '=', 1);
  248. $condition[] = array('ap_id', '=', 3);
  249. $condition[] = array('adv_startdate', '<', TIMESTAMP);
  250. $condition[] = array('adv_enddate', '>', TIMESTAMP);
  251. $navs_list = model('appadv')->getAppadvList($condition);
  252. if (!empty($navs_list)) {
  253. foreach ($navs_list as $key => $banner) {
  254. $navs_list[$key]['adv_code'] = get_appadv_code($banner['adv_code']);
  255. }
  256. }
  257. $result['navs'] = $navs_list;
  258. // 首页横图广告
  259. $condition = array();
  260. $condition[] = array('adv_enabled', '=', 1);
  261. $condition[] = array('ap_id', '=', 4);
  262. $condition[] = array('adv_startdate', '<', TIMESTAMP);
  263. $condition[] = array('adv_enddate', '>', TIMESTAMP);
  264. $floor_ads = model('appadv')->getAppadvList($condition);
  265. if (!empty($floor_ads)) {
  266. foreach ($floor_ads as $key => $banner) {
  267. $floor_ads[$key]['adv_code'] = get_appadv_code($banner['adv_code']);
  268. }
  269. }
  270. $result['floor_ads'] = $floor_ads;
  271. wcache($cache_key, $result);
  272. }
  273. ds_json_encode(10000, '', $result);
  274. }
  275. /**
  276. * @api {POST} api/Index/getConfigList 配置列表
  277. * @apiVersion 1.0.0
  278. * @apiGroup Index
  279. *
  280. * @apiSuccess {String} code 返回码,10000为成功
  281. * @apiSuccess {String} message 返回消息
  282. * @apiSuccess {Object} result 返回数据
  283. * @apiSuccess {Object[]} result.config_list 配置列表
  284. * @apiSuccess {String} result.config_list.site_name 站点名称
  285. * @apiSuccess {String} result.config_list.site_mobile_logo 站点logo
  286. * @apiSuccess {String} result.config_list.instant_message_gateway_url 聊天接口地址
  287. * @apiSuccess {String} result.config_list.instant_message_open 是否开启聊天 1是0否
  288. * @apiSuccess {String} result.config_list.qq_isuse 是否使用QQ互联 1是0否
  289. * @apiSuccess {String} result.config_list.sms_login 是否手机登录 1是0否
  290. * @apiSuccess {String} result.config_list.baidu_ak 百度地图AK密钥
  291. * @apiSuccess {String} result.config_list.inviter_open 推广开关 1是0否
  292. * @apiSuccess {String} result.config_list.inviter_level 推广级别
  293. * @apiSuccess {String} result.config_list.inviter_show 详情页显示推广佣金
  294. * @apiSuccess {String} result.config_list.inviter_return 推广员返佣 1是0否
  295. * @apiSuccess {String} result.config_list.inviter_view 推广员审核 1是0否
  296. * @apiSuccess {String} result.config_list.business_licence 营业执照
  297. * @apiSuccess {String} result.config_list.points_isuse 是否开启积分 1是0否
  298. * @apiSuccess {String} result.config_list.points_signin_isuse 是否开启签到送积分 1是0否
  299. * @apiSuccess {String} result.config_list.points_signin_cycle 签到持续周期
  300. * @apiSuccess {String} result.config_list.points_signin_reward 签到持续周期额外奖励
  301. */
  302. public function getConfigList()
  303. {
  304. $list_config = rkcache('config', true);
  305. $wechat_model = model('wechat');
  306. $wx_config = $wechat_model->getOneWxconfig();
  307. if (!empty($list_config['business_licence'])) {
  308. $list_config['business_licence'] = ds_get_pic(ATTACH_COMMON, $list_config['business_licence']);
  309. }
  310. $config_list = array(
  311. 'site_name' => $list_config['site_name'],
  312. 'site_mobile_logo' => ds_get_pic(ATTACH_COMMON, $list_config['site_mobile_logo']),
  313. 'member_auth' => $list_config['member_auth'],
  314. 'instant_message_gateway_url' => $list_config['instant_message_gateway_url'], //站内IM服务器地址
  315. 'instant_message_open' => $list_config['instant_message_open'], //是否启用im
  316. 'qq_isuse' => $list_config['qq_isuse'], //是否使用QQ互联
  317. 'sina_isuse' => $list_config['sina_isuse'], //是否使用微博互联
  318. 'weixin_isuse' => $list_config['weixin_isuse'], //是否使用微信互联
  319. 'member_normal_register' => $list_config['member_normal_register'], //是否普通注册
  320. 'sms_register' => $list_config['sms_register'], //是否手机注册
  321. 'sms_login' => $list_config['sms_login'], //是否手机登录
  322. 'mapak_type' => $list_config['mapak_type'], //地图类型
  323. 'gaode_ak' => $list_config['gaode_ak'], //高德地图AK密钥
  324. 'gaode_jscode' => $list_config['gaode_jscode'], //高德地图安全密钥
  325. 'baidu_ak' => $list_config['baidu_ak'], //百度浏览器端地图AK密钥
  326. 'baiduservice_ak' => $list_config['baiduservice_ak'], //百度服务端地图AK密钥
  327. 'inviter_open' => $list_config['inviter_open'], //推广开关
  328. 'inviter_level' => $list_config['inviter_level'], //推广级别
  329. 'inviter_show' => $list_config['inviter_show'], //详情页显示推广佣金
  330. 'inviter_return' => $list_config['inviter_return'], //推广员返佣
  331. 'inviter_view' => $list_config['inviter_view'], //推广员审核
  332. 'business_licence' => $list_config['business_licence'], //营业执照,
  333. 'points_isuse' => $list_config['points_isuse'], //是否开启积分
  334. 'points_signin_isuse' => $list_config['points_signin_isuse'], //是否开启签到送积分
  335. 'points_signin_cycle' => $list_config['points_signin_cycle'], //签到持续周期
  336. 'points_signin_reward' => $list_config['points_signin_reward'], //签到持续周期额外奖励
  337. 'wechat_appid' => !empty($wx_config) ? $wx_config['appid'] : '', //微信appid
  338. 'captcha_status_register' => $list_config['captcha_status_register'], //注册验证码
  339. 'captcha_status_login' => $list_config['captcha_status_login'], //登录验证码
  340. 'captcha_status_goodsqa' => $list_config['captcha_status_goodsqa'], //咨询验证码
  341. 'store_joinin_open' => $list_config['store_joinin_open'], //店铺入驻开启
  342. 'flow_static_code' => $list_config['flow_static_code'], //版权信息
  343. 'video_type' => $list_config['video_type'], //视频服务商
  344. 'aliyun_user_id' => $list_config['aliyun_user_id'], //版权信息
  345. 'live_type' => $list_config['live_type'], //直播类型
  346. 'chain_isuse' => $list_config['chain_isuse'], //代收是否开启
  347. 'wab_number' => $list_config['wab_number'], //网安备
  348. 'icp_number' => $list_config['icp_number'], //ICP
  349. );
  350. ds_json_encode(10000, '', array('config_list' => $config_list));
  351. }
  352. /**
  353. * @api {POST} api/Index/getProductList 产品列表
  354. * @apiVersion 1.0.0
  355. * @apiGroup Index
  356. *
  357. * @apiSuccess {String} code 返回码,10000为成功
  358. * @apiSuccess {String} message 返回消息
  359. * @apiSuccess {Object} result 返回数据
  360. * @apiSuccess {Object[]} result.hot_products 热卖商品列表
  361. * @apiSuccess {Int} result.hot_products.evaluation_count 评论数
  362. * @apiSuccess {Int} result.hot_products.evaluation_good_star 好评评分
  363. * @apiSuccess {String} result.hot_products.goods_advword 广告词
  364. * @apiSuccess {Int} result.hot_products.goods_commonid 商品公共ID
  365. * @apiSuccess {Int} result.hot_products.goods_id 商品ID
  366. * @apiSuccess {String} result.hot_products.goods_image 商品图片名称
  367. * @apiSuccess {String} result.hot_products.goods_img_480 商品图片完整路径
  368. * @apiSuccess {Float} result.hot_products.goods_marketprice 市场价
  369. * @apiSuccess {String} result.hot_products.goods_name 商品名
  370. * @apiSuccess {Float} result.hot_products.goods_price 商品价格
  371. * @apiSuccess {Float} result.hot_products.goods_promotion_price 促销价
  372. * @apiSuccess {String} result.hot_products.goods_promotion_type 促销类型
  373. * @apiSuccess {Int} result.hot_products.goods_salenum 销量
  374. * @apiSuccess {Int} result.hot_products.is_goodsfcode 是否F码商品 0否1是
  375. * @apiSuccess {Int} result.hot_products.is_have_gift 是否含赠品 0否1是
  376. * @apiSuccess {Int} result.hot_products.is_platform_store 是否自营商品 0否1是
  377. * @apiSuccess {Int} result.hot_products.is_virtual 是否虚拟商品 0否1是
  378. * @apiSuccess {Int} result.hot_products.store_id 店铺ID
  379. * @apiSuccess {String} result.hot_products.store_name 店铺名称
  380. * @apiSuccess {Object[]} result.recently_products 最新商品列表
  381. * @apiSuccess {Int} result.recently_products.evaluation_count 评论数
  382. * @apiSuccess {Int} result.recently_products.evaluation_good_star 好评评分
  383. * @apiSuccess {String} result.recently_products.goods_advword 广告词
  384. * @apiSuccess {Int} result.recently_products.goods_commonid 商品公共ID
  385. * @apiSuccess {Int} result.recently_products.goods_id 商品ID
  386. * @apiSuccess {String} result.recently_products.goods_image 商品图片名称
  387. * @apiSuccess {String} result.recently_products.goods_img_480 商品图片完整路径
  388. * @apiSuccess {Float} result.recently_products.goods_marketprice 市场价
  389. * @apiSuccess {String} result.recently_products.goods_name 商品名
  390. * @apiSuccess {Float} result.recently_products.goods_price 商品价格
  391. * @apiSuccess {Float} result.recently_products.goods_promotion_price 促销价
  392. * @apiSuccess {String} result.recently_products.goods_promotion_type 促销类型
  393. * @apiSuccess {Int} result.recently_products.goods_salenum 销量
  394. * @apiSuccess {Int} result.recently_products.is_goodsfcode 是否F码商品 0否1是
  395. * @apiSuccess {Int} result.recently_products.is_have_gift 是否含赠品 0否1是
  396. * @apiSuccess {Int} result.recently_products.is_platform_store 是否自营商品 0否1是
  397. * @apiSuccess {Int} result.recently_products.is_virtual 是否虚拟商品 0否1是
  398. * @apiSuccess {Int} result.recently_products.store_id 店铺ID
  399. * @apiSuccess {String} result.recently_products.store_name 店铺名称
  400. * @apiSuccess {Object[]} result.good_products 推荐展位商品列表
  401. * @apiSuccess {Int} result.good_products.evaluation_count 评论数
  402. * @apiSuccess {Int} result.good_products.evaluation_good_star 好评评分
  403. * @apiSuccess {String} result.good_products.goods_advword 广告词
  404. * @apiSuccess {Int} result.good_products.goods_commonid 商品公共ID
  405. * @apiSuccess {Int} result.good_products.goods_id 商品ID
  406. * @apiSuccess {String} result.good_products.goods_image 商品图片名称
  407. * @apiSuccess {String} result.good_products.goods_img_480 商品图片完整路径
  408. * @apiSuccess {Float} result.good_products.goods_marketprice 市场价
  409. * @apiSuccess {String} result.good_products.goods_name 商品名
  410. * @apiSuccess {Float} result.good_products.goods_price 商品价格
  411. * @apiSuccess {Float} result.good_products.goods_promotion_price 促销价
  412. * @apiSuccess {String} result.good_products.goods_promotion_type 促销类型
  413. * @apiSuccess {Int} result.good_products.goods_salenum 销量
  414. * @apiSuccess {Int} result.good_products.is_goodsfcode 是否F码商品 0否1是
  415. * @apiSuccess {Int} result.good_products.is_have_gift 是否含赠品 0否1是
  416. * @apiSuccess {Int} result.good_products.is_platform_store 是否自营商品 0否1是
  417. * @apiSuccess {Int} result.good_products.is_virtual 是否虚拟商品 0否1是
  418. * @apiSuccess {Int} result.good_products.store_id 店铺ID
  419. * @apiSuccess {String} result.good_products.store_name 店铺名称
  420. */
  421. public function getProductList()
  422. {
  423. $cache_key = "api-getProductList";
  424. $result = rcache($cache_key);
  425. if (empty($result)) {
  426. $goods_model = model('goods');
  427. //所需字段
  428. $fieldstr = "goods.goods_id,goods.goods_storage,goodscommon.goods_commonid,goodscommon.store_id,goodscommon.goods_name,goodscommon.goods_advword,goodscommon.goods_price,goods.goods_promotion_price,goods.goods_promotion_type,goodscommon.goods_marketprice,goodscommon.goods_image,goods.goods_salenum,goods.evaluation_good_star,goods.evaluation_count";
  429. $fieldstr .= ',goodscommon.is_virtual,goodscommon.is_goodsfcode,goods.is_have_gift,goodscommon.store_name,goodscommon.is_platform_store';
  430. $hot_products = $goods_model->getGoodsUnionList(array(), $fieldstr, 'goods_salenum desc', 'goodscommon.goods_commonid', $this->pagesize);
  431. if ($hot_products) {
  432. foreach ($hot_products as $key => $val) {
  433. if (!$val['goods_storage']) {
  434. $goods_info = $goods_model->getGoodsStorageByCommonId($val['goods_commonid']);
  435. if ($goods_info) {
  436. $hot_products[$key]['goods_id'] = $goods_info['goods_id'];
  437. $hot_products[$key]['goods_promotion_price'] = $goods_info['goods_promotion_price'];
  438. }
  439. }
  440. $hot_products[$key]['goods_img_480'] = goods_thumb($val, 480);
  441. }
  442. }
  443. $result['hot_products'] = $hot_products;
  444. $recently_products = $goods_model->getGoodsUnionList(array(), $fieldstr, 'goods_edittime desc', 'goodscommon.goods_commonid', $this->pagesize);
  445. if ($recently_products) {
  446. foreach ($recently_products as $key => $val) {
  447. if (!$val['goods_storage']) {
  448. $goods_info = $goods_model->getGoodsStorageByCommonId($val['goods_commonid']);
  449. if ($goods_info) {
  450. $recently_products[$key]['goods_id'] = $goods_info['goods_id'];
  451. $recently_products[$key]['goods_promotion_price'] = $goods_info['goods_promotion_price'];
  452. }
  453. }
  454. $recently_products[$key]['goods_img_480'] = goods_thumb($val, 480);
  455. }
  456. }
  457. $result['recently_products'] = $recently_products;
  458. $good_products = $goods_model->getGoodsUnionList(array(array('goodscommon.mall_goods_commend', '=', 1)), $fieldstr, 'goodscommon.mall_goods_sort asc', 'goodscommon.goods_commonid', $this->pagesize);
  459. if ($good_products) {
  460. foreach ($good_products as $key => $val) {
  461. if (!$val['goods_storage']) {
  462. $goods_info = $goods_model->getGoodsStorageByCommonId($val['goods_commonid']);
  463. if ($goods_info) {
  464. $good_products[$key]['goods_id'] = $goods_info['goods_id'];
  465. $good_products[$key]['goods_promotion_price'] = $goods_info['goods_promotion_price'];
  466. }
  467. }
  468. $good_products[$key]['goods_img_480'] = goods_thumb($val, 480);
  469. }
  470. }
  471. $result['good_products'] = $good_products;
  472. //秒杀
  473. $xianshicondition = array(
  474. array('xianshigoods_state', '=', 1),
  475. array('xianshigoods_starttime', '<', TIMESTAMP),
  476. array('xianshigoods_end_time', '>', TIMESTAMP),
  477. );
  478. $xianshi = model('pxianshigoods')->getXianshigoodsList($xianshicondition, null, '', '*', 3);
  479. foreach ($xianshi as $k => $v) {
  480. $price_array = explode(".", $v['xianshigoods_price']);
  481. $xianshi[$k]['goods_image'] = goods_cthumb($v['goods_image'], 480);
  482. $xianshi[$k]['xianshigoods_end_time'] = date("m-d H:i", $v['xianshigoods_end_time']);
  483. }
  484. $result['xianshi_products'] = $xianshi;
  485. wcache($cache_key, $result);
  486. }
  487. ds_json_encode(10000, '', $result);
  488. }
  489. /**
  490. * @api {POST} api/Index/getWechatShare 微信js分享的配置信息
  491. * @apiVersion 1.0.0
  492. * @apiGroup Index
  493. * @apiParam {String} url 分享链接
  494. *
  495. * @apiSuccess {String} code 返回码,10000为成功
  496. * @apiSuccess {String} message 返回消息
  497. * @apiSuccess {Object} result 返回数据
  498. * @apiSuccess {Object} result.signPackage 微信配置信息
  499. * @apiSuccess {String} result.signPackage.appId 微信appid
  500. * @apiSuccess {String} result.signPackage.nonceStr 随机字符串
  501. * @apiSuccess {String} result.signPackage.timestamp 微信时间戳
  502. * @apiSuccess {String} result.signPackage.url 分享链接
  503. * @apiSuccess {String} result.signPackage.signature 微信签名
  504. * @apiSuccess {String} result.signPackage.rawString 原始数据
  505. */
  506. public function getWechatShare()
  507. {
  508. $wechat_model = model('wechat');
  509. $wechat_model->getOneWxconfig();
  510. $signPackage = $wechat_model->GetSignPackage(urldecode(input('param.url')));
  511. $goods_detail['signPackage'] = $signPackage;
  512. if ($wechat_model->error_code) {
  513. ds_json_encode(10001, $wechat_model->error_message);
  514. } else {
  515. ds_json_encode(10000, '', array('signPackage' => $signPackage));
  516. }
  517. }
  518. /**
  519. * @api {POST} api/Index/getQrcode 获取二维码
  520. * @apiVersion 1.0.0
  521. * @apiGroup Index
  522. * @apiParam {String} url 链接
  523. *
  524. * @apiSuccess {String} code 返回码,10000为成功
  525. * @apiSuccess {String} message 返回消息
  526. * @apiSuccess {Object} result 返回数据
  527. */
  528. public function getQrcode()
  529. {
  530. include_once root_path() . 'extend/qrcode/phpqrcode.php';
  531. $value = strip_tags(htmlspecialchars_decode(input('get.url')));
  532. $errorCorrectionLevel = "L";
  533. $matrixPointSize = "4";
  534. \QRcode::png($value, false, $errorCorrectionLevel, $matrixPointSize, 2);
  535. exit;
  536. }
  537. /**
  538. * @api {POST} api/Index/getGuessLike 猜你喜欢
  539. * @apiVersion 1.0.0
  540. * @apiGroup Index
  541. * @apiParam {Int} member_id 用户id
  542. *
  543. * @apiSuccess {String} code 返回码,10000为成功
  544. * @apiSuccess {String} message 返回消息
  545. * @apiSuccess {Object} result 返回数据
  546. */
  547. public function getGuessLike()
  548. {
  549. $member_id = intval(input('param.member_id'));
  550. $goods_list = model('goodsbrowse')->getGuessLikeGoods($member_id, 20);
  551. if ($goods_list) {
  552. foreach ($goods_list as $key => $val) {
  553. $goods_list[$key]['goods_img_480'] = goods_thumb($val, 480);
  554. }
  555. }
  556. if (empty($goods_list)) { //随机请求
  557. $max_id = Db::name('goods')->where(array(array('goods_state', '=', 1), array('goods_verify', '=', 1)))->max('goods_commonid');
  558. if ($max_id) {
  559. $goods_model = model('goods');
  560. $goods_commonids = array();
  561. for ($i = 0; $i < 20; $i++) {
  562. $condition = array();
  563. $condition[] = array('goods_state', '=', 1);
  564. $condition[] = array('goods_verify', '=', 1);
  565. $rand_id = rand(1, $max_id);
  566. $condition[] = array('goods_commonid', '>=', $rand_id);
  567. $goods = $goods_model->getGoodsInfo($condition);
  568. if ($goods && !in_array($goods['goods_commonid'], $goods_commonids)) {
  569. $goods_commonids[] = $goods['goods_commonid'];
  570. $goods['goods_img_480'] = goods_thumb($goods, 480);
  571. $goods_list[] = $goods;
  572. }
  573. $i++;
  574. }
  575. }
  576. }
  577. ds_json_encode(10000, '', array('goods_list' => $goods_list));
  578. }
  579. }