GroupBuyLbActivity.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. namespace app\api\model\groupbuylb;
  3. use app\common\model\groupbuylb\GroupBuyLbActivity as GroupBuyLbActivityModel;
  4. use app\common\model\groupbuylb\GroupBuyLbActivityAction as GroupBuyLbActivityActionModel;
  5. use app\common\model\groupbuylb\GroupBuyLbGoods as GroupBuyLbGoodsModel;
  6. use think\facade\Log;
  7. /**
  8. * 拼团裂变活动模型
  9. * @package app\store\model\coupon
  10. */
  11. class GroupBuyLbActivity extends GroupBuyLbActivityModel
  12. {
  13. public function getGroupBuyLbPrice($goodsId){
  14. $res = $this->validActivity($goodsId);
  15. var_dump($res);
  16. die();
  17. }
  18. /**
  19. * 获取列表
  20. * @param $goodsId
  21. * @return mixed
  22. * @throws \think\db\exception\DataNotFoundException
  23. * @throws \think\db\exception\DbException
  24. * @throws \think\db\exception\ModelNotFoundException
  25. */
  26. public static function validActivity($goodsId)
  27. {
  28. // 检索查询条件
  29. $now = date('Y-m-d H:i:s');
  30. $filter[] = ['ac.start_time','<',$now];
  31. $filter[] = ['ac.end_time','>',$now];
  32. $filter[] = ['ac.audit_status','=',1];
  33. $filter[] = ['ac.status','=',1];
  34. $filter[] = ['g.goods_id','=',$goodsId];
  35. // 执行查询
  36. $one = self::field('ac.*')
  37. ->with([])
  38. ->alias('ac')
  39. ->leftJoin('group_buy_lb_goods g','g.group_buy_lb_activity_id = ac.id')
  40. ->where($filter)
  41. ->find();
  42. return $list;
  43. // dd(self::getLastSql());
  44. // dd($list['giftGoods']);
  45. // if (!$list)return null;
  46. // $list = $list->toArray();
  47. // $list['empty_gifts'] = false;//当所有的赠品库存都是0:true
  48. // $giftsGoods = null;
  49. // $count = count($list['giftGoods']);
  50. // foreach ($list['giftGoods'] as $key=>$g){
  51. // if ($g['goods_info']['stock_total'] < 1){
  52. // $count--;
  53. // }else{
  54. // $giftsGoods[] = $g;//库存大于0的才展示这个赠品
  55. // }
  56. // }
  57. // unset($list['giftGoods']);
  58. // if ($count == 0){//
  59. // $list['empty_gifts'] = true;
  60. // }
  61. // $list['gift_goods'] = $giftsGoods;
  62. // $list['remain_secs'] = strtotime($list['end_time']) - time();
  63. return $list;
  64. }
  65. }