Index.php 32 KB

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