Expedite.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  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. }
  14. /**
  15. * @title 获取商品详情(商城商品)
  16. * @desc 获取商品详情(商城商品)
  17. * @author qc
  18. * @url /api/Expedite/getGoodsDetail
  19. * @method GET
  20. * @header name:Authorization require:1 desc:Token
  21. * @param name:goods_id type:int require:1 default:0 desc:商品id
  22. * @return name:goods_info type:array default:-- desc:商品详情
  23. * @return name:goods_info.name type:string default:-- desc:商品名称
  24. * @return name:goods_info.cover type:string default:-- desc:商品封面图
  25. * @return name:goods_info.desc type:string default:-- desc:商品简述
  26. * @return name:goods_info.goods_price type:float default:-- desc:价格
  27. * @return name:goods_info.end_time type:float default:-- desc:结束时间
  28. * @return name:goods_info.spec type:string default:-- desc:魔盒设置
  29. * @return name:spec.award_name type:string default:-- desc:名称
  30. * @return name:spec.spec_img type:string default:-- desc:封面
  31. * @return name:spec.store_num type:string default:-- desc:剩余库存
  32. * @return name:spec.base_num type:string default:-- desc:初始库存
  33. * @return name:spec.crystal type:string default:-- desc:水晶价值
  34. * @return name:spec.rate type:string default:-- desc:抽中概率
  35. * @return name:goods_info.first_classify type:int default:-- desc:分类id
  36. * @return name:goods_info.detail type:int default:-- desc:商品详情
  37. * @return name:goods_info.stock type:float default:-- desc:剩余库存
  38. * @return name:goods_info.base_stock type:float default:-- desc:初始库存
  39. * @return name:goods_info.special_award type:array default:-- desc:特殊奖励设置(前后场两个奖励)
  40. * @return name:goods_info.special_award.title type:string default:-- desc:标题
  41. * @return name:goods_info.special_award.goods type:string default:-- desc:商品名
  42. * @return name:goods_info.special_award.cover type:string default:-- desc:图片
  43. * @return name:goods_info.special_award.crystal type:string default:-- desc:水晶
  44. * @return name:goods_info.special_award.is_over type:string default:-- desc:奖励是否完成
  45. * @return name:goods_info.special_point type:int default:-- desc:前后场分割数
  46. * @return name:goods_info.before_num type:int default:-- desc:前场数
  47. * @return name:goods_info.after_num type:int default:-- desc:后场数
  48. *
  49. */
  50. public function getGoodsDetail()
  51. {
  52. $goods_id = input('goods_id');
  53. $field = 'id,name,cover,desc,goods_price,spec,first_classify,detail,stock,base_stock,end_time,special_award,special_point';
  54. $detail = Db::table('store_goods')
  55. ->field($field)
  56. ->where(['id'=>$goods_id,'status'=>1,'is_deleted'=>0])
  57. ->find($goods_id);
  58. if(empty($detail)) $this->error('商品已下架');
  59. $detail['before_num'] = $detail['special_point'];
  60. $detail['after_num'] =$detail['base_stock'] - $detail['special_point'];
  61. $this->success('oK',['goods_info'=>$detail,]);
  62. }
  63. /**
  64. * @title 获取商品列表(商城商品)
  65. * @desc 获取商品列表(商城商品)
  66. * @author qc
  67. * @url /api/Expedite/getGoodsList
  68. * @method GET
  69. * @header name:Authorization require:1 desc:Token
  70. * @param name:page type:int default:1 desc:页数
  71. * @param name:page_num type:int : default:20 desc:每页数
  72. * @param name:goods_name type:string require:0 default:-- desc:商品名称
  73. * @param name:cate_id type:int require:0 default:0 desc:分类id
  74. * @return name:name type:string default:-- desc:商品名称
  75. * @return name:cover type:string default:-- desc:商品封面图
  76. * @return name:desc type:string default:-- desc:商品简述
  77. * @return name:goods_price type:float default:-- desc:价格
  78. * @return name:spec type:string default:-- desc:规格详情
  79. * @return name:spec.award_name type:string default:-- desc:名称
  80. * @return name:spec.spec_img type:string default:-- desc:封面
  81. * @return name:spec.store_num type:string default:-- desc:剩余库存
  82. * @return name:spec.base_num type:string default:-- desc:初始库存
  83. * @return name:spec.crystal type:string default:-- desc:水晶价值
  84. * @return name:first_classify type:int default:-- desc:一级分类id
  85. * @return name:detail type:int default:-- desc:商品详情
  86. * @return name:stock type:float default:-- desc:剩余库存
  87. * @return name:base_stock type:float default:-- desc:初始库存
  88. * @return name:end_time type:string default:-- desc:结束时间
  89. * @return name:goods_info.special_award type:array default:-- desc:特殊奖励设置(前后场两个奖励)
  90. * @return name:goods_info.special_award.title type:string default:-- desc:标题
  91. * @return name:goods_info.special_award.goods type:string default:-- desc:商品名
  92. * @return name:goods_info.special_award.cover type:string default:-- desc:图片
  93. * @return name:goods_info.special_award.crystal type:string default:-- desc:水晶
  94. * @return name:goods_info.special_award.is_over type:string default:-- desc:奖励是否完成
  95. */
  96. public function getGoodsList()
  97. {
  98. $sel_where = [];
  99. $sel_where[] = ['status','=',1];
  100. $sel_where[] = ['is_deleted','=',0];
  101. $sel_where[] = ['end_time','> time',date("Y-m-d H:i:s")];
  102. if(input('goods_name')) $sel_where[] = ['name','like',"%".input('goods_name')."%"];
  103. if(input('cate_id',0)) $sel_where[] = ['first_classify','=',input('cate_id')];
  104. $field = 'id,name,cover,desc,goods_price,spec,first_classify,detail,stock,base_stock,end_time,special_award';
  105. $list = Db::table('store_goods')
  106. ->field($field)
  107. ->where($sel_where)
  108. ->order('sort desc , id desc ')
  109. ->limit($this->off_set,$this->page_num)
  110. ->select();
  111. $this->success('ok',['list'=>$list]);
  112. }
  113. /**
  114. * @title 获取商品分类(商城商品)
  115. * @desc 获取商品分类(商城商品)
  116. * @author qc
  117. * @url /api/Expedite/getGoodCate
  118. * @method GET
  119. * @header name:Authorization require:1 desc:Token
  120. * @return name:id type:array default:-- desc:商品详情
  121. * @return name:title type:string default:-- desc:分类名称
  122. */
  123. public function getGoodCate()
  124. {
  125. $list = Db::table('store_goods_cate')
  126. ->where('pid',0)
  127. ->where('status',1)
  128. ->where('is_deleted',0)
  129. ->field('id,title')
  130. ->order('sort desc , id desc')
  131. ->select();
  132. $this->success('ok',['list'=>$list]);
  133. }
  134. /**
  135. * @title 获取首页轮播图
  136. * @desc 获取首页轮播图
  137. * @author qc
  138. * @url /api/Expedite/getBanner
  139. * @method GET
  140. * @header name:Authorization require:1 desc:Token
  141. * @param name:num type:int default:5 desc:查询数量
  142. * @return name:name type:srting default:-- desc:标题
  143. * @return name:cover type:srting default:-- desc:图片路径
  144. * @return name:link type:srting default:-- desc:跳转地址
  145. */
  146. public function getBanner()
  147. {
  148. $num = input('get.num',20);
  149. $list = Db::table('store_banner')
  150. ->field('id,name,cover,link')
  151. ->where(['is_deleted'=>0])
  152. ->limit(0,$num)
  153. ->order('sort desc ,id desc')
  154. ->select();
  155. $this->success('ok',['list'=>$list]);
  156. }
  157. /**
  158. * @title 获取订单列表(商城商品)
  159. * @desc 获取订单列表(商城商品)
  160. * @author qc
  161. * @url /api/Expedite/getOrderListByGoodsId
  162. * @method GET
  163. * @header name:Authorization require:1 desc:Token
  164. * @param name:page type:int default:1 desc:页数
  165. * @param name:page_num type:int : default:20 desc:每页数
  166. * @param name:goods_id type:string require:1 default:-- desc:商品id
  167. * @return name:create_at type:string default:-- desc:时间
  168. * @return name:goods_name type:string default:-- desc:商品
  169. * @return name:name type:string default:-- desc:会员名称
  170. * @return name:headimg type:string default:-- desc:会员头像
  171. */
  172. public function getOrderListByGoodsId()
  173. {
  174. $goods_id = input('goods_id',0);
  175. $list = Db::table('goods_order')
  176. ->alias('o')
  177. ->field('o.create_at,o.goods_name,m.name,m.headimg')
  178. ->join('store_member m','o.uid = m.id')
  179. ->where('o.goods_id',$goods_id)
  180. ->where('o.pay_state',1)
  181. ->order('o.id desc ')
  182. ->limit($this->off_set,$this->page_num)
  183. ->select();
  184. $this->success('ok',['list'=>$list]);
  185. }
  186. /**
  187. * @title 获取商品中奖详情
  188. * @desc 获取商品中奖详情
  189. * @author qc
  190. * @url /api/Expedite/getAwardDetailByGoodsId
  191. * @method GET
  192. * @header name:Authorization require:1 desc:Token
  193. * @param name:page type:int default:1 desc:页数
  194. * @param name:page_num type:int : default:20 desc:每页数
  195. * @param name:goods_id type:string require:1 default:-- desc:商品id
  196. * @return name:create_at type:string default:-- desc:时间
  197. * @return name:award_name type:string default:-- desc:奖品标题
  198. * @return name:award_cover type:string default:-- desc:奖品图片
  199. * @return name:name type:string default:-- desc:会员名称
  200. * @return name:headimg type:string default:-- desc:会员头像
  201. */
  202. public function getAwardDetailByGoodsId()
  203. {
  204. $goods_id = input('goods_id',0);
  205. $list = Db::table('magic_draw')
  206. ->alias('d')
  207. ->field('d.award_name,d.award_cover,d.create_at,m.name,m.headimg')
  208. ->join('store_member m','d.user_id = m.id')
  209. ->where('d.goods_id',$goods_id)
  210. ->order('d.is_special desc,d.id desc ')
  211. ->limit($this->off_set,$this->page_num)
  212. ->select();
  213. $this->success('ok',['list'=>$list]);
  214. }
  215. /**
  216. * @title 获取商品详情(兑换商品)
  217. * @desc 获取商品详情(兑换商品)
  218. * @author qc
  219. * @url /api/Expedite/getExchangeGoodsDetail
  220. * @method GET
  221. * @header name:Authorization require:1 desc:Token
  222. * @param name:goods_id type:int require:1 default:0 desc:兑换商品id
  223. * @return name:name type:string default:-- desc:商品名称
  224. * @return name:cover type:string default:-- desc:商品封面图
  225. * @return name:desc type:string default:-- desc:商品简述
  226. * @return name:crystal type:int default:-- desc:水晶
  227. * @return name:first_classify type:int default:-- desc:一级分类id
  228. * @return name:detail type:int default:-- desc:商品详情
  229. * @return name:stock type:float default:-- desc:剩余库存
  230. */
  231. public function getExchangeGoodsDetail()
  232. {
  233. $goods_id = input('goods_id');
  234. $field = 'id,name,cover,desc,first_classify,detail,stock,crystal';
  235. $detail = Db::table('exchange_goods')
  236. ->field($field)
  237. ->where(['id'=>$goods_id,'status'=>1,'is_deleted'=>0])
  238. ->find($goods_id);
  239. if(empty($detail)) $this->error('商品已下架');
  240. $this->success('oK',$detail);
  241. }
  242. /**
  243. * @title 获取商品列表(兑换商品)
  244. * @desc 获取商品列表(兑换商品)
  245. * @author qc
  246. * @url /api/Expedite/getExchangeGoodsList
  247. * @method GET
  248. * @header name:Authorization require:1 desc:Token
  249. * @param name:page type:int default:1 desc:页数
  250. * @param name:page_num type:int : default:20 desc:每页数
  251. * @param name:goods_name type:string require:0 default:-- desc:商品名称
  252. * @param name:cate_id type:int require:0 default:0 desc:分类id
  253. * @return name:name type:string default:-- desc:商品名称
  254. * @return name:cover type:string default:-- desc:商品封面图
  255. * @return name:desc type:string default:-- desc:商品简述
  256. * @return name:crystal type:int default:-- desc:水晶
  257. * @return name:first_classify type:int default:-- desc:一级分类id
  258. * @return name:detail type:int default:-- desc:商品详情
  259. * @return name:stock type:float default:-- desc:剩余库存
  260. */
  261. public function getExchangeGoodsList()
  262. {
  263. $sel_where = [];
  264. $sel_where[] = ['status','=',1];
  265. $sel_where[] = ['is_deleted','=',0];
  266. if(input('goods_name')) $sel_where[] = ['name','like',"%".input('goods_name')."%"];
  267. if(input('cate_id',0)) $sel_where[] = ['first_classify','=',input('cate_id')];
  268. $field = 'id,name,cover,desc,first_classify,detail,stock,crystal';
  269. $list = Db::table('exchange_goods')
  270. ->field($field)
  271. ->where($sel_where)
  272. ->order('sort desc , id desc ')
  273. ->limit($this->off_set,$this->page_num)
  274. ->select();
  275. $this->success('ok',['list'=>$list]);
  276. }
  277. /**
  278. * @title 获取平台设置
  279. * @desc 获取平台设置
  280. * @author qc
  281. * @url /api/Expedite/getSysConfig
  282. * @method GET
  283. * @return name:agreement type:string default:-- desc:用户协议
  284. * @return name:purchase_notice type:string default:-- desc:购买须知
  285. * @return name:platform_notice type:string default:-- desc:平台消息
  286. * @return name:crystal_switch type:string default:-- desc:提现开关(1开启0关闭)
  287. */
  288. public function getSysConfig(){
  289. $con_name =['agreement','purchase_notice','platform_notice','crystal_switch'];
  290. $set = Db::table('system_config')->where('name','in',$con_name)->select();
  291. $ret = [];
  292. foreach ($set as $value) {
  293. $ret[$value['name']]=$value['value'];
  294. }
  295. $this->success('获取成功',$ret);
  296. }
  297. }