Index.php 33 KB

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