Expedite.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. <?php
  2. namespace app\api\controller;
  3. use think\Db;
  4. /**
  5. * @title 不需要验证token接口(商品详情,商品列表等)
  6. * @controller Expedite
  7. * @package app\api\controller
  8. */
  9. class Expedite extends Base
  10. {
  11. public function initialize(){
  12. parent::initialize();
  13. parent::set_uid();
  14. }
  15. /**
  16. * @title 获取首页轮播图
  17. * @desc 获取首页轮播图
  18. * @author qc
  19. * @url /api/Expedite/getBanner
  20. * @method GET
  21. * @header name:Authorization require:1 desc:Token
  22. * @param name:num type:int default:5 desc:查询数量
  23. * @return name:cover type:srting default:-- desc:图片路径
  24. * @return name:link' type:srting default:-- desc:链接
  25. */
  26. public function getBanner()
  27. {
  28. $num = input('get.num',20);
  29. $place = input('get.place',1);
  30. $list = Db::table('store_banner')
  31. ->field('id,cover,link')
  32. ->where(['is_deleted'=>0,'place'=>$place])
  33. ->limit(0,$num)
  34. ->order('sort desc ,id desc')
  35. ->select();
  36. $this->success('ok',['list'=>$list]);
  37. }
  38. /**
  39. * @title 获取商品列表
  40. * @desc 获取商品列表
  41. * @author qc
  42. * @url /api/Expedite/getGoodsList
  43. * @method GET
  44. * @header name:Authorization require:1 desc:Token
  45. * @param name:page type:int default:1 desc:页数
  46. * @param name:page_num type:int : default:20 desc:每页数
  47. * @param name:goods_name type:string require:0 default:-- desc:商品名称
  48. * @param name:type type:int require:0 default:1 desc:商品类型(0全部,1售卖,3邀请)
  49. * @param name:sell_type type:int require:0 default:0 desc:售卖类型(0全部,1在售,2未售,3已售)
  50. * @return name:name type:string default:-- desc:商品名称
  51. * @return name:cover type:string default:-- desc:商品封面图
  52. * @return name:desc type:string default:-- desc:商品简述
  53. * @return name:goods_price type:float default:-- desc:价格
  54. * @return name:detail type:int default:-- desc:商品详情
  55. * @return name:stock type:float default:-- desc:剩余库存
  56. * @return name:base_stock type:float default:-- desc:初始库存
  57. * @return name:sell_time type:string default:-- desc:开始售卖时间
  58. * @return name:adv_type type:int default:-- desc:广告类型(1图片,2mp3,3视频)
  59. * @return name:adv_cover type:string default:-- desc:广告图片
  60. * @return name:mp3_url type:string default:-- desc:广告mp3
  61. * @return name:audio_url type:string default:-- desc:广告视频
  62. * @return name:buy_notice type:string default:-- desc:购买须知
  63. * @return name:type type:int default:-- desc:商品类型(1售卖,2兑换,3邀请)
  64. * @return name:is_gift type:int default:0 desc:是否允许赠送(0否1是)
  65. * @return name:is_gift type:int default:0 desc:是否允许赠送(0否1是)
  66. * @return name:crystal type:float default:0 desc:赠送所需元石
  67. * @return name:gift_day type:int default:0 desc:赠送时间限制(天)
  68. * @return name:auth_img type:string default:0 desc:作者头像
  69. * @return name:goods_auth type:string default:0 desc:作者名
  70. * @return name:invite_num type:int default:0 desc:邀请人数
  71. * @return name:sell_day type:int default:0 desc:售卖天
  72. * @return name:sell_point type:int default:0 desc:售卖时间点
  73. */
  74. public function getGoodsList(){
  75. $type = input('type',0);
  76. $sell_type = input('sell_type',0);
  77. $sel_where = [];
  78. $sel_where[] = ['status','=',1];
  79. $sel_where[] = ['is_deleted','=',0];
  80. if(input('goods_name')) $sel_where[] = ['name','like',"%".input('goods_name')."%"];
  81. if($type){
  82. $sel_where[] = ['type','=',$type];
  83. }else{
  84. $sel_where[] = ['type','in','1,3'];
  85. }
  86. if($sell_type){
  87. switch ($sell_type){
  88. case 1:
  89. $sel_where[] = ['sell_time','<= time',date('Y-m-d 23:59:59')];
  90. $sel_where[] = ['stock','>',0];
  91. break;
  92. case 2:
  93. $sel_where[] = ['sell_time','> time',date('Y-m-d H:i:s')];
  94. $sel_where[] = ['stock','>',0];
  95. break;
  96. case 3:
  97. $sel_where[] = ['stock','=',0];
  98. break;
  99. }
  100. }
  101. $list = Db::table('store_goods')
  102. ->where($sel_where)
  103. ->order('sort desc , id desc ')
  104. ->limit($this->off_set,$this->page_num)
  105. ->select();
  106. $this->success('ok',['list'=>$list]);
  107. }
  108. /**
  109. * @title 获取商品列表(预售)
  110. * @desc 获取商品列表(预售)
  111. * @author qc
  112. * @url /api/Expedite/getPreSellGoods
  113. * @method GET
  114. * @header name:Authorization require:1 desc:Token
  115. * @param name:page type:int default:1 desc:页数
  116. * @param name:page_num type:int : default:20 desc:每页数
  117. * @param name:goods_name type:string require:0 default:-- desc:商品名称
  118. * @param name:type type:int require:0 default:1 desc:商品类型(0全部,1售卖,3邀请)
  119. * @return name:name type:string default:-- desc:商品名称
  120. * @return name:cover type:string default:-- desc:商品封面图
  121. * @return name:desc type:string default:-- desc:商品简述
  122. * @return name:goods_price type:float default:-- desc:价格
  123. * @return name:detail type:int default:-- desc:商品详情
  124. * @return name:stock type:float default:-- desc:剩余库存
  125. * @return name:base_stock type:float default:-- desc:初始库存
  126. * @return name:sell_time type:string default:-- desc:开始售卖时间
  127. * @return name:adv_type type:int default:-- desc:广告类型(1图片,2mp3,3视频)
  128. * @return name:adv_cover type:string default:-- desc:广告图片
  129. * @return name:mp3_url type:string default:-- desc:广告mp3
  130. * @return name:audio_url type:string default:-- desc:广告视频
  131. * @return name:buy_notice type:string default:-- desc:购买须知
  132. * @return name:type type:int default:-- desc:商品类型(1售卖,2兑换,3邀请)
  133. * @return name:is_gift type:int default:0 desc:是否允许赠送(0否1是)
  134. * @return name:is_gift type:int default:0 desc:是否允许赠送(0否1是)
  135. * @return name:crystal type:float default:0 desc:赠送所需元石
  136. * @return name:gift_day type:int default:0 desc:赠送时间限制(天)
  137. * @return name:auth_img type:string default:0 desc:作者头像
  138. * @return name:goods_auth type:string default:0 desc:作者名
  139. * @return name:invite_num type:int default:0 desc:邀请人数
  140. * @return name:sell_day type:int default:0 desc:售卖天
  141. * @return name:sell_point type:int default:0 desc:售卖时间点
  142. */
  143. public function getPreSellGoods()
  144. {
  145. $all_day = Db::table('store_goods')
  146. ->field('sell_day')
  147. ->where(['status'=>1,'is_deleted'=>0])
  148. ->where('stock','>',0)
  149. ->where('type','in','1,3')
  150. ->where('sell_day','>',date('Y-m-d'))
  151. ->where('sell_time','> time',date('Y-m-d 23:59:59'))
  152. ->group('sell_day')
  153. ->order('sell_day asc')
  154. ->select();
  155. $date = [];
  156. foreach ($all_day as $dv) {
  157. $date[$dv['sell_day']] = Db::table('store_goods')
  158. ->where(['status'=>1,'is_deleted'=>0])
  159. ->where('stock','>',0)
  160. ->where('sell_day',$dv['sell_day'])
  161. ->order('sell_time asc,id desc')
  162. ->select();
  163. }
  164. $this->success('ok',['list'=>$date]);
  165. }
  166. /**
  167. * @title 获取商品详情
  168. * @desc 获取商品详情
  169. * @author qc
  170. * @url /api/Expedite/getGoodsDetail
  171. * @method GET
  172. * @header name:Authorization require:1 desc:Token
  173. * @param name:goods_id type:int require:1 default:0 desc:商品id
  174. * @return name:name type:string default:-- desc:商品名称
  175. * @return name:cover type:string default:-- desc:商品封面图
  176. * @return name:desc type:string default:-- desc:商品简述
  177. * @return name:goods_price type:float default:-- desc:价格
  178. * @return name:detail type:int default:-- desc:商品详情
  179. * @return name:stock type:float default:-- desc:剩余库存
  180. * @return name:base_stock type:float default:-- desc:初始库存
  181. * @return name:sell_time type:string default:-- desc:开始售卖时间
  182. * @return name:adv_type type:int default:-- desc:广告类型(1图片,2mp3,3视频)
  183. * @return name:adv_cover type:string default:-- desc:广告图片
  184. * @return name:mp3_url type:string default:-- desc:广告mp3
  185. * @return name:audio_url type:string default:-- desc:广告视频
  186. * @return name:buy_notice type:string default:-- desc:购买须知
  187. * @return name:type type:int default:-- desc:商品类型(1售卖,2兑换)
  188. * @return name:is_gift type:int default:0 desc:是否允许赠送(0否1是)
  189. * @return name:crystal type:float default:0 desc:赠送所需元石
  190. * @return name:gift_day type:int default:0 desc:赠送时间限制(天)
  191. * @return name:invite_num type:int default:0 desc:邀请人数
  192. * @return name:share_img type:string default:0 desc:分享
  193. * @return name:goods_auth type:string default:0 desc:作者
  194. * @return name:auth_img type:string default:0 desc:作者头像
  195. * @return name:audio_line type:int default:0 desc:是否展示视频进度条(0否1是)
  196. * @return name:pay_pic type:string default:0 desc:支付完成弹窗图片
  197. * @return name:pay_content type:string default:0 desc:支付完成弹窗内容
  198. * @return name:vir_num type:string default:0 desc:收藏量
  199. * @return name:less_num type:int default:0 desc:还需邀请多少人
  200. * @return name:has_invite type:int default:0 desc:已邀请多少(已经领取的不算)
  201. * @return name:has_get type:int default:0 desc:已领取多少次
  202. * @return name:part_cal type:string default:0 desc:算法
  203. * @return name:part_link type:string default:0 desc:链接
  204. */
  205. public function getGoodsDetail()
  206. {
  207. $goods_id = input('goods_id');
  208. $detail = Db::table('store_goods')
  209. ->where(['id'=>$goods_id,'status'=>1,'is_deleted'=>0])
  210. ->find($goods_id);
  211. if(empty($detail)) $this->error('商品已下架');
  212. $detail['less_num'] = 0;
  213. $detail['has_invite'] = 0;
  214. $detail['part_cal'] = 'ED25519';
  215. $detail['part_link'] = 'JD China';
  216. $detail['is_login'] = 0;
  217. if(strtotime($detail['sell_time']) <= time()) $detail['sell_time'] = date("Y-m-d H:i:s", time() - 3600);
  218. if($detail['type'] == 3 && $this->uid){
  219. $detail['is_login'] = 1;
  220. $invite_num = Db::table('invite_info')->where(['pid'=>$this->uid,'status'=>1])->count();
  221. $detail['has_invite'] = $invite_num;
  222. $detail['has_get'] = Db::table('goods_collect')->where(['user_id'=>$this->uid,'goods_id'=>$goods_id,'source'=>3])->count();
  223. $detail['less_num'] = $detail['invite_num'] - $invite_num > 0 ? $detail['invite_num']-$invite_num :0;
  224. }
  225. $detail['goods_detail_switch'] = intval(sysconf('goods_detail_switch'));
  226. $detail['about_deliver'] = sysconf('about_deliver')?:'';
  227. $this->success('oK',['goods_info'=>$detail]);
  228. }
  229. /**
  230. * @title 获取平台设置
  231. * @desc 获取平台设置
  232. * @author qc
  233. * @url /api/Expedite/getSysConfig
  234. * @method GET
  235. * @return name:agreement type:string default:-- desc:用户协议
  236. * @return name:purchase_notice type:string default:-- desc:购买与转赠须知
  237. * @return name:about_us type:string default:-- desc:关于我们
  238. * @return name:service type:string default:-- desc:客服
  239. * @return name:intro_crystal type:string default:-- desc:什么是元石
  240. * @return name:platform_agreement type:string default:-- desc:平台协议
  241. * @return name:privacy type:string default:-- desc:隐私政策
  242. * @return name:self type:string default:-- desc:自定义文字
  243. * @return name:plat_name type:string default:-- desc:自定义标题名称
  244. * @return name:sell_switch type:int default:-- desc:销售历史开关(1开启,0关闭)
  245. * @return name:goods_detail_switch type:int default:-- desc:商品详情的开关(1开启,0关闭)
  246. */
  247. public function getSysConfig(){
  248. $con_name =['agreement','purchase_notice','about_us','service','intro_crystal','sell_switch','platform_agreement','privacy','self','plat_name','goods_detail_switch'];
  249. $set = Db::table('system_config')->where('name','in',$con_name)->select();
  250. $ret = [];
  251. foreach ($set as $value) {
  252. $ret[$value['name']]=$value['value'];
  253. }
  254. $this->success('获取成功',$ret);
  255. }
  256. /**
  257. * @title 什么是元石
  258. * @desc 什么是元石
  259. * @author qc
  260. * @method GET
  261. * @tag 编辑信息
  262. * @url /api/Expedite/introduceCrystal
  263. * @header name:Authorization require:0 desc:Token
  264. * @return name:str type:string default:-- desc:解释文案
  265. */
  266. public function introduceCrystal()
  267. {
  268. $intro_str = '作品的转赠请求需要消耗对应的元石数量。元石价格:1元/枚';
  269. $this->success('ok',['str'=>$intro_str]);
  270. }
  271. }