MallActivity.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\model\DiscountActivity;
  4. use app\common\model\DiscountGoods;
  5. use app\common\model\GiftCate;
  6. use app\common\model\GoodsOrder;
  7. use app\common\model\GoodsOrderItem;
  8. use app\common\model\GoodsSellInfo;
  9. use app\common\model\GroupActivity;
  10. use app\common\model\GroupLeader;
  11. use app\common\model\SeckillActivity;
  12. use app\common\model\SeckillGoods;
  13. use app\common\model\SeckillGoodsItem;
  14. use app\common\model\GroupGoods;
  15. use app\common\model\GroupGoodsItem;
  16. use app\common\model\GiftGoods;
  17. /**
  18. * @title 商城活动&&商品(秒杀&&拼团&&心选商品)
  19. * @controller MallActivity
  20. * @package app\api\controller
  21. */
  22. class MallActivity extends Base
  23. {
  24. public function initialize(){
  25. parent::initialize();
  26. parent::setUid();
  27. }
  28. /**
  29. * @title 获取秒杀活动列表
  30. * @desc 获取秒杀活动列表
  31. * @author qc
  32. * @method GET
  33. * @url /api/Mall_activity/getSeckillActivityList
  34. * @header name:Authorization require:1 desc:Token
  35. * @param name:num type:int default:3 desc:查询条数
  36. * @return name:title type:string default:-- desc:标题
  37. * @return name:cover type:string default:-- desc:图片
  38. * @return name:create_at type:string default:-- desc:开始时间
  39. * @return name:end_time type:string default:-- desc:结束时间
  40. * @return name:start_point type:string default:-- desc:开始时间点
  41. * @return name:end_point type:string default:-- desc:结束时间点
  42. */
  43. public function getSeckillActivityList()
  44. {
  45. $num = input('num,3');
  46. $list = SeckillActivity::where([['status','=',1],['end_time','> time',date('Y-m-d H:i:s')],['is_deleted','=',0]])
  47. ->order('sort desc,id asc')->limit(0,$num)->select()->toArray();
  48. foreach ($list as &$v){
  49. $v['start_point'] = date('H:i',strtotime($v['start_time']));
  50. $v['end_point'] = date('H:i',strtotime($v['end_time']));
  51. }
  52. $this->success('ok',['list'=>$list]);
  53. }
  54. /**
  55. * @title 获取秒杀活动商品列表
  56. * @desc 获取秒杀活动商品列表
  57. * @author qc
  58. * @method GET
  59. * @url /api/Mall_activity/getSeckillGoodsList
  60. * @header name:Authorization require:1 desc:Token
  61. * @param name:act_id type:int require:1 default:-- desc:活动id
  62. * @param name:page type:int require:1 default:-- desc:第几页
  63. * @param name:page_num type:int require:1 default:20 desc:每页数
  64. * @return name:id type:int default:-- desc:活动商品记录id
  65. * @return name:goods_id type:int default:-- desc:商品id
  66. * @return name:name type:string default:-- desc:商品名称
  67. * @return name:cover type:string default:-- desc:商品封面
  68. * @return name:low_price type:string default:-- desc:最低价(正常售价)
  69. * @return name:seckill_low type:string default:-- desc:抢购最低价
  70. * @return name:seckill_num type:int default:-- desc:秒杀订单数量
  71. */
  72. public function getSeckillGoodsList()
  73. {
  74. $act_id = input('act_id');
  75. $goods_list = SeckillGoods::field('s.*,g.name,g.cover,g.low_price')->alias('s')->leftJoin('StoreGoods g','g.id = s.goods_id')
  76. ->where(['s.act_id'=>$act_id])
  77. ->order('s.sort desc , s.id desc')
  78. ->limit($this->off_set,$this->page_num)
  79. ->select()->toArray();
  80. array_walk($goods_list,function (&$v,$k)use($act_id){
  81. $v['seckill_low'] = SeckillGoodsItem::where(['act_id'=>$v['act_id'],'goods_id'=>$v['goods_id']])->min('seckill_price');
  82. $v['seckill_num'] = GoodsSellInfo::where(['goods_id'=>$v['id'],'act_type'=>2,'act_id'=>$act_id])->count();
  83. });
  84. $this->success('ok',['list'=>$goods_list]);
  85. }
  86. /**
  87. * @title 获取秒杀活动商品详情
  88. * @desc 获取秒杀活动商品详情
  89. * @author qc
  90. * @method GET
  91. * @url /api/Mall_activity/getSeckillGoodsDetail
  92. * @header name:Authorization require:1 desc:Token
  93. * @param name:act_id type:int require:1 default:-- desc:活动id
  94. * @param name:goods_id type:int require:1 default:-- desc:活动id
  95. * @return name:id type:int default:-- desc:商品id
  96. * @return name:name type:string default:-- desc:商品名称
  97. * @return name:cover type:string default:-- desc:商品封面图
  98. * @return name:desc type:string default:-- desc:商品简述
  99. * @return name:goods_price type:float default:-- desc:价格
  100. * @return name:detail type:int default:-- desc:商品详情
  101. * @return name:stock type:float default:-- desc:剩余库存
  102. * @return name:base_stock type:float default:-- desc:初始库存
  103. * @return name:freight_type type:int default:-- desc:运费类型0固定金额,1运费模板
  104. * @return name:freight_id type:int default:-- desc:模板id(freight_type=1)
  105. * @return name:postage type:float default:-- desc:运费(freight_type=0)
  106. * @return name:goods_param type:array default:-- desc:商品相关参数
  107. * @return name:goods_param.title type:string default:-- desc:参数名
  108. * @return name:goods_param.value type:string default:-- desc:参数值
  109. * @return name:seckill_item type:array default:-- desc:秒杀规格设置
  110. * @return name:seckill_item.goods_spec type:string default:-- desc:规格
  111. * @return name:seckill_item.original_price type:float default:-- desc:原价
  112. * @return name:seckill_item.sell_price type:float default:-- desc:售价
  113. * @return name:seckill_item.seckill_price type:float default:-- desc:秒杀价
  114. * @return name:seckill_item.stock type:float default:-- desc:改规格剩余库存
  115. */
  116. public function getSeckillGoodsDetail()
  117. {
  118. $act_id = input('act_id');
  119. $goods_id = input('goods_id');
  120. $goods_info = SeckillGoods::where(['s.goods_id'=>$goods_id,'s.act_id'=>$act_id])
  121. ->field('g.*,s.id s_id,s.act_id,s.act_id,p.goods_param')
  122. ->alias('s')
  123. ->leftJoin('StoreGoods g','s.goods_id = g.id')
  124. ->leftJoin('GoodsParam p','s.goods_id = p.goods_id')
  125. ->find()->toArray();
  126. $goods_info['seckill_item'] = SeckillGoodsItem::field('s.id,s.original_price,s.sell_price,s.seckill_price,i.stock,i.goods_spec')->alias('s')
  127. ->leftJoin('StoreGoodsItem i','i.id = s.spec_id')
  128. ->where(['s.act_id'=>$act_id,'s.goods_id'=>$goods_id])
  129. ->select()->toArray();// 秒杀设置
  130. $this->success('ok',['detail'=>$goods_info]);
  131. }
  132. /**
  133. * @title 获取拼团活动列表
  134. * @desc 获取拼团活动列表
  135. * @author qc
  136. * @method GET
  137. * @url /api/Mall_activity/getGroupActivityList
  138. * @header name:Authorization require:1 desc:Token
  139. * @param name:num type:int default:3 desc:查询条数
  140. * @return name:title type:string default:-- desc:标题
  141. * @return name:cover type:string default:-- desc:图片
  142. * @return name:full_num type:int default:-- desc:成团人数
  143. * @return name:create_at type:string default:-- desc:开始时间
  144. * @return name:end_time type:string default:-- desc:结束时间
  145. * @return name:start_point type:string default:-- desc:开始时间点
  146. * @return name:end_point type:string default:-- desc:结束时间点
  147. */
  148. public function getGroupActivityList()
  149. {
  150. $num = input('num,3');
  151. $list = GroupActivity::where([['status','=',1],['end_time','> time',date('Y-m-d H:i:s')],['is_deleted','=',0]])
  152. ->order('sort desc,id asc')->limit(0,$num)->select()->toArray();
  153. foreach ($list as &$v){
  154. $v['start_point'] = date('H:i',strtotime($v['start_time']));
  155. $v['end_point'] = date('H:i',strtotime($v['end_time']));
  156. }
  157. $this->success('ok',['list'=>$list]);
  158. }
  159. /**
  160. * @title 获取拼团活动商品列表
  161. * @desc 获取拼团活动商品列表
  162. * @author qc
  163. * @method GET
  164. * @url /api/Mall_activity/getGroupGoodsList
  165. * @header name:Authorization require:1 desc:Token
  166. * @param name:act_id type:int require:1 default:-- desc:活动id
  167. * @param name:page type:int require:1 default:-- desc:第几页
  168. * @param name:page_num type:int require:1 default:20 desc:每页数
  169. * @return name:id type:int default:-- desc:活动商品记录id
  170. * @return name:goods_id type:int default:-- desc:商品id
  171. * @return name:name type:string default:-- desc:商品名称
  172. * @return name:cover type:string default:-- desc:商品封面
  173. * @return name:low_price type:string default:-- desc:最低价(正常售价)
  174. * @return name:group_low type:string default:-- desc:拼团最低价
  175. * @return name:success_num type:int default:-- desc:拼团成功团数量
  176. * @return name:present_num type:int default:-- desc:进行中的团数量
  177. */
  178. public function getGroupGoodsList()
  179. {
  180. $act_id = input('act_id');
  181. $goods_list = GroupGoods::field('s.*,g.name,g.cover,g.low_price')->alias('s')->leftJoin('StoreGoods g','g.id = s.goods_id')
  182. ->where(['s.act_id'=>$act_id])
  183. ->order('s.sort desc , s.id desc')
  184. ->limit($this->off_set,$this->page_num)
  185. ->select()->toArray();
  186. array_walk($goods_list,function (&$v,$k)use($act_id){
  187. $v['group_low'] = GroupGoodsItem::where(['act_id'=>$v['act_id'],'goods_id'=>$v['goods_id']])->min('group_price');
  188. $v['success_num'] = GroupLeader::where(['act_id'=>$act_id,'goods_id'=>$v['goods_id'],'status'=>1])->count();
  189. $v['present_num'] = GroupLeader::where(['act_id'=>$act_id,'goods_id'=>$v['goods_id'],'status'=>0])->count();
  190. });
  191. $this->success('ok',['list'=>$goods_list]);
  192. }
  193. /**
  194. * @title 获取拼团活动商品详情
  195. * @desc 获取拼团活动商品详情
  196. * @author qc
  197. * @method GET
  198. * @url /api/Mall_activity/getGroupGoodsDetail
  199. * @header name:Authorization require:1 desc:Token
  200. * @param name:act_id type:int require:1 default:-- desc:活动id
  201. * @param name:goods_id type:int require:1 default:-- desc:活动id
  202. * @return name:id type:int default:-- desc:商品id
  203. * @return name:name type:string default:-- desc:商品名称
  204. * @return name:cover type:string default:-- desc:商品封面图
  205. * @return name:desc type:string default:-- desc:商品简述
  206. * @return name:goods_price type:float default:-- desc:价格
  207. * @return name:detail type:int default:-- desc:商品详情
  208. * @return name:stock type:float default:-- desc:剩余库存
  209. * @return name:base_stock type:float default:-- desc:初始库存
  210. * @return name:freight_type type:int default:-- desc:运费类型0固定金额,1运费模板
  211. * @return name:freight_id type:int default:-- desc:模板id(freight_type=1)
  212. * @return name:postage type:float default:-- desc:运费(freight_type=0)
  213. * @return name:goods_param type:array default:-- desc:商品相关参数
  214. * @return name:goods_param.title type:string default:-- desc:参数名
  215. * @return name:goods_param.value type:string default:-- desc:参数值
  216. * @return name:group_item type:array default:-- desc:秒杀规格设置
  217. * @return name:group_item.goods_spec type:string default:-- desc:规格
  218. * @return name:group_item.original_price type:float default:-- desc:原价
  219. * @return name:group_item.sell_price type:float default:-- desc:售价
  220. * @return name:group_item.group_price type:float default:-- desc:秒杀价
  221. * @return name:group_item.stock type:float default:-- desc:改规格剩余库存
  222. */
  223. public function getGroupGoodsDetail()
  224. {
  225. $act_id = input('act_id');
  226. $goods_id = input('goods_id');
  227. $goods_info = GroupGoods::where(['s.goods_id'=>$goods_id,'s.act_id'=>$act_id])
  228. ->field('g.*,s.id s_id,s.act_id,s.act_id,p.goods_param')
  229. ->alias('s')
  230. ->leftJoin('StoreGoods g','s.goods_id = g.id')
  231. ->leftJoin('GoodsParam p','s.goods_id = p.goods_id')
  232. ->find()->toArray();
  233. $goods_info['group_item'] = GroupGoodsItem::field('s.id,s.original_price,s.sell_price,s.group_price,i.stock, i.goods_spec')->alias('s')
  234. ->leftJoin('StoreGoodsItem i','i.id = s.spec_id')
  235. ->where(['s.act_id'=>$act_id,'s.goods_id'=>$goods_id])
  236. ->select()->toArray();// 秒杀设置
  237. $this->success('ok',['detail'=>$goods_info]);
  238. }
  239. /**
  240. * @title 获取正在拼团列表
  241. * @desc 获取正在拼团列表
  242. * @author qc
  243. * @method GET
  244. * @url /api/Mall_activity/getGroupLeaderList
  245. * @header name:Authorization require:1 desc:Token
  246. * @param name:act_id type:int require:1 default:-- desc:活动id
  247. * @param name:goods_id type:int require:1 default:-- desc:活动id
  248. * @return name:name type:string default:-- desc:名称
  249. * @return name:headimg type:string default:-- desc:头像
  250. * @return name:num type:int default:-- desc:数量
  251. */
  252. public function getGroupLeaderList()
  253. {
  254. $act_id = input('get.act_id');
  255. $goods_id = input('get.goods_id');
  256. $list = GroupLeader::field('l.id,l.goods_id,l.spec_id,l.create_at,u.name,u.headimg')
  257. ->alias('l')
  258. ->where(['l.act_id'=>$act_id,'l.goods_id'=>$goods_id,'l.status'=>0])
  259. ->leftJoin('StoreMember u','u.id = l.user_id')
  260. ->order('l.id asc')
  261. ->select()->toArray();
  262. $this->success('ok',['list'=>$list,'num'=>count($list)]);
  263. }
  264. /**
  265. * @title 获取折扣活动列表
  266. * @desc 获取折扣活动列表
  267. * @author qc
  268. * @method GET
  269. * @url /api/Mall_activity/getDiscountActivityList
  270. * @header name:Authorization require:1 desc:Token
  271. * @param name:num type:int default:3 desc:查询条数
  272. * @return name:title type:string default:-- desc:标题
  273. * @return name:cover type:string default:-- desc:图片
  274. * @return name:create_at type:string default:-- desc:开始时间
  275. * @return name:end_time type:string default:-- desc:结束时间
  276. * @return name:start_point type:string default:-- desc:开始时间点
  277. * @return name:end_point type:string default:-- desc:结束时间点
  278. */
  279. public function getDiscountActivityList()
  280. {
  281. $num = input('num,3');
  282. $list = DiscountActivity::where([['status','=',1],['end_time','> time',date('Y-m-d H:i:s')],['is_deleted','=',0]])
  283. ->order('sort desc,id asc')->limit(0,$num)->select()->toArray();
  284. foreach ($list as &$v){
  285. $v['start_point'] = date('H:i',strtotime($v['start_time']));
  286. $v['end_point'] = date('H:i',strtotime($v['end_time']));
  287. }
  288. $this->success('ok',['list'=>$list]);
  289. }
  290. /**
  291. * @title 获取折扣活动商品列表
  292. * @desc 获取折扣活动商品列表
  293. * @author qc
  294. * @method GET
  295. * @url /api/Mall_activity/getDiscountGoodsList
  296. * @header name:Authorization require:1 desc:Token
  297. * @param name:act_id type:int require:1 default:-- desc:活动id
  298. * @param name:page type:int require:1 default:-- desc:第几页
  299. * @param name:page_num type:int require:1 default:20 desc:每页数
  300. * @return name:id type:int default:-- desc:活动商品记录id
  301. * @return name:goods_id type:int default:-- desc:商品id
  302. * @return name:name type:string default:-- desc:商品名称
  303. * @return name:cover type:string default:-- desc:商品封面
  304. * @return name:low_price type:float default:-- desc:最低价(正常售价)
  305. * @return name:discount_price type:float default:-- desc:最低价(折扣价)
  306. * @return name:discount type:float default:-- desc:折扣
  307. * @return name:line_price type:float default:-- desc:下划线价格
  308. * @return name:discount_act type:int default:-- desc:折扣活动详情
  309. * @return name:discount_act.id type:int default:-- desc:活动id
  310. */
  311. public function getDiscountGoodsList()
  312. {
  313. $act_id = input('act_id');
  314. $discount_act = DiscountActivity::where('id',$act_id)->find()->toArray();
  315. $price_discount = bcdiv($discount_act['discount'],100,2);
  316. $goods_list = DiscountGoods::field('s.*,g.name,g.cover,g.low_price')
  317. ->alias('s')->leftJoin('StoreGoods g','g.id = s.goods_id')
  318. ->where(['s.act_id'=>$act_id])
  319. ->order('s.sort desc , s.id desc')
  320. ->limit($this->off_set,$this->page_num)
  321. ->select()->toArray();
  322. array_walk($goods_list,function (&$v,$k)use($act_id,$price_discount){
  323. $v['discount_price'] = bcmul($v['low_price'],$price_discount,2);
  324. $v['line_price'] = GoodsOrderItem::where(['goods_id'=>$v['id']])->max('sell_price');
  325. $v['discount'] = $price_discount*10;
  326. });
  327. $this->success('ok',['list'=>$goods_list,'discount'=>$price_discount,'discount_act'=>$discount_act]);
  328. }
  329. /**
  330. * @title 获取心选礼物分类
  331. * @desc 获取心选礼物分类
  332. * @author qc
  333. * @method GET
  334. * @url /api/Mall_activity/getGiftCate
  335. * @header name:Authorization require:1 desc:Token
  336. * @return name:title type:string default:-- desc:标题
  337. * @return name:logo type:string default:-- desc:封面
  338. */
  339. public function getGiftCate()
  340. {
  341. $gift_cate = GiftCate::field('id,title,logo')->where(['is_deleted'=>0])->select()->toArray();
  342. $this->success('ok',['list'=>$gift_cate]);
  343. }
  344. /**
  345. * @title 获取推荐心选商品
  346. * @desc 获取推荐心选商品
  347. * @author qc
  348. * @method GET
  349. * @url /api/Mall_activity/getGiftHotGoods
  350. * @header name:Authorization require:1 desc:Token
  351. * @param name:page type:int require:1 default:-- desc:第几页
  352. * @param name:page_num type:int require:1 default:20 desc:每页数
  353. * @return name:is_custom type:int default:-- desc:是否允许定制(0否1是)
  354. * @return name:custom_cover type:string default:-- desc:定制风格(多图|隔开)
  355. * @return name:custom_color type:string default:-- desc:定制色系图(多图|隔开)
  356. * @return name:goods_id type:int default:-- desc:商品id
  357. * @return name:goods_id type:int default:-- desc:商品id
  358. * @return name:name type:string default:-- desc:商品名称
  359. * @return name:cover type:string default:-- desc:商品封面
  360. * @return name:low_price type:string default:-- desc:最低价(正常售价)
  361. * @return name:line_price type:string default:-- desc:下划线价格
  362. */
  363. public function getGiftHotGoods()
  364. {
  365. $goods_list = GiftGoods::field('s.*,g.name,g.cover,g.low_price')
  366. ->alias('s')->leftJoin('StoreGoods g','g.id = s.goods_id')
  367. ->where(['s.status'=>1,'s.is_hot'=>1,'s.is_deleted'=>0,'g.is_deleted'=>0,'g.status'=>1])
  368. ->order('s.sort desc , s.id desc')
  369. ->limit($this->off_set,$this->page_num)
  370. ->select()->toArray();
  371. array_walk($goods_list,function (&$v,$k){
  372. $v['line_price'] = GoodsOrderItem::where('goods_id',$v['goods_id'])->max('original_price');
  373. });
  374. $this->success('ok',['list'=>$goods_list]);
  375. }
  376. /**
  377. * @title 根据分类获取心选商品
  378. * @desc 根据分类获取心选商品
  379. * @author qc
  380. * @method GET
  381. * @url /api/Mall_activity/getGiftGoodsByCate
  382. * @header name:Authorization require:1 desc:Token
  383. * @param name:page type:int require:1 default:-- desc:第几页
  384. * @param name:page_num type:int require:1 default:20 desc:每页数
  385. * @param name:cate_id type:int require:1 desc:心选礼物分类id
  386. * @return name:is_custom type:int default:-- desc:是否允许定制(0否1是)
  387. * @return name:custom_cover type:string default:-- desc:定制风格(多图|隔开)
  388. * @return name:custom_color type:string default:-- desc:定制色系图(多图|隔开)
  389. * @return name:goods_id type:int default:-- desc:商品id
  390. * @return name:goods_id type:int default:-- desc:商品id
  391. * @return name:name type:string default:-- desc:商品名称
  392. * @return name:cover type:string default:-- desc:商品封面
  393. * @return name:low_price type:string default:-- desc:最低价(正常售价)
  394. * @return name:line_price type:string default:-- desc:下划线价格
  395. */
  396. public function getGiftGoodsByCate()
  397. {
  398. $goods_list = GiftGoods::field('s.*,g.name,g.cover,g.low_price')
  399. ->alias('s')->leftJoin('StoreGoods g','g.id = s.goods_id')
  400. ->where(['s.status'=>1,'s.is_deleted'=>0,'g.is_deleted'=>0,'g.status'=>1,'s.cate_id'=>input('get.cate_id')])
  401. ->order('s.sort desc , s.id desc')
  402. ->limit($this->off_set,$this->page_num)
  403. ->select()->toArray();
  404. array_walk($goods_list,function (&$v,$k){
  405. $v['line_price'] = GoodsOrderItem::where('goods_id',$v['goods_id'])->max('original_price');
  406. });
  407. $this->success('ok',['list'=>$goods_list]);
  408. }
  409. /**
  410. * @title 获取定制商品
  411. * @desc 获取定制商品
  412. * @author qc
  413. * @method GET
  414. * @url /api/Mall_activity/getCustomGoodsList
  415. * @header name:Authorization require:1 desc:Token
  416. * @return name:is_custom type:int default:-- desc:是否允许定制(0否1是)
  417. * @return name:custom_cover type:string default:-- desc:定制风格(多图|隔开)
  418. * @return name:custom_color type:string default:-- desc:定制色系图(多图|隔开)
  419. * @return name:goods_id type:int default:-- desc:商品id
  420. * @return name:goods_id type:int default:-- desc:商品id
  421. * @return name:name type:string default:-- desc:商品名称
  422. * @return name:cover type:string default:-- desc:商品封面
  423. * @return name:low_price type:string default:-- desc:最低价(正常售价)
  424. * @return name:item_list type:array default:-- desc:商品多规格列表
  425. * @return name:item_list.spec_info type:array default:-- desc:规格型号设置;
  426. * @return name:item_list.goods_no type:string default:-- desc:规格货号
  427. * @return name:item_list.goods_title type:string default:-- desc:规格标题
  428. * @return name:item_list.cover type:string default:-- desc:规格封面
  429. * @return name:item_list.stock type:int default:-- desc:剩余库存
  430. * @return name:item_list.original_price type:float default:-- desc:原价
  431. * @return name:item_list.sell_price type:float default:-- desc:售价
  432. */
  433. public function getCustomGoodsList()
  434. {
  435. $where = [];
  436. $where[] = ['s.status','=',1];
  437. $where[] = ['s.is_deleted','=',0];
  438. $where[] = ['g.is_deleted','=',0];
  439. $where[] = ['g.status','=',1];
  440. $where[] = ['s.is_custom','=',1];
  441. $list = GiftGoods::field('s.*,g.name,g.cover,g.low_price')
  442. ->with('itemList')
  443. ->alias('s')->leftJoin('StoreGoods g','g.id = s.goods_id')
  444. ->where($where)
  445. ->select()->toArray();
  446. $this->success('ok',['list'=>$list]);
  447. }
  448. /**
  449. * @title 心选商品设置
  450. * @desc 心选商品设置
  451. * @author qc
  452. * @method GET
  453. * @url /api/Mall_activity/getGiftGoodsDetail
  454. * @header name:Authorization require:1 desc:Token
  455. * @param name:id type:int require:1 desc:心选商品记录id(两个不能同时为空)
  456. * @param name:goods_id type:int require:1 desc:商品id(两个不能同时为空)
  457. * @return name:is_custom type:int default:-- desc:是否允许定制(0否1是)
  458. * @return name:custom_cover type:string default:-- desc:定制风格(多图|隔开)
  459. * @return name:custom_color type:string default:-- desc:定制色系图(多图|隔开)
  460. * @return name:goods_id type:int default:-- desc:商品id
  461. * @return name:goods_id type:int default:-- desc:商品id
  462. * @return name:name type:string default:-- desc:商品名称
  463. * @return name:cover type:string default:-- desc:商品封面
  464. * @return name:low_price type:string default:-- desc:最低价(正常售价)
  465. * @return name:item_list type:array default:-- desc:商品多规格列表
  466. * @return name:item_list.spec_info type:array default:-- desc:规格型号设置;
  467. * @return name:item_list.goods_no type:string default:-- desc:规格货号
  468. * @return name:item_list.goods_title type:string default:-- desc:规格标题
  469. * @return name:item_list.cover type:string default:-- desc:规格封面
  470. * @return name:item_list.stock type:int default:-- desc:剩余库存
  471. * @return name:item_list.original_price type:float default:-- desc:原价
  472. * @return name:item_list.sell_price type:float default:-- desc:售价
  473. */
  474. public function getGiftGoodsDetail()
  475. {
  476. $where = [];
  477. $where[] = ['s.status','=',1];
  478. $where[] = ['s.is_deleted','=',0];
  479. $where[] = ['g.is_deleted','=',0];
  480. $where[] = ['g.status','=',1];
  481. if(input('get.id')) $where[] = ['s.id','=',input('get.id')];
  482. if(input('get.goods_id')) $where[] = ['s.goods_id','=',input('get.goods_id')];
  483. $detail = GiftGoods::field('s.*,g.name,g.cover,g.low_price')
  484. ->with('itemList')
  485. ->alias('s')->leftJoin('StoreGoods g','g.id = s.goods_id')
  486. ->where($where)
  487. ->find();
  488. if(!$detail) $this->error('商品已下架');
  489. $this->success('ok',['detail'=>$detail->toArray()]);
  490. }
  491. }