|
|
@@ -27,7 +27,7 @@ class GroupActivityLogic extends BaseLogic
|
|
|
/**
|
|
|
* @notes 拼团活动详情
|
|
|
*/
|
|
|
- public static function detail($id){
|
|
|
+ public static function detail($id,$userId){
|
|
|
$detail = GroupActivity::with('goods')->where(['id'=>$id])->visible([
|
|
|
'id','title','image','start_time','end_time','type','equity_id',
|
|
|
'participant_num','origin_price','price','form_time_limit'
|
|
|
@@ -39,7 +39,8 @@ class GroupActivityLogic extends BaseLogic
|
|
|
$detail['timestamp'] = time();
|
|
|
$goods = Goods::where('id',$detail['goods']['goods_id'])->field('service_image,goods_category_id')->findOrEmpty()->toArray();
|
|
|
$detail['goods'] = array_merge($detail['goods'],$goods);
|
|
|
-
|
|
|
+ //查询用户是否已有付款订单
|
|
|
+ $detail['order'] = GroupUserOrder::with('group_order')->where(['user_id'=>$userId,'group_activity_id'=>$detail['id'],'pay_status'=>1])->field('id,status,pay_way,pay_time,pay_status,remark,create_time,group_order_id')->findOrEmpty()->toArray();
|
|
|
}
|
|
|
|
|
|
return $detail;
|
|
|
@@ -85,16 +86,8 @@ class GroupActivityLogic extends BaseLogic
|
|
|
{
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
- // 订单位置是否在服务区内
|
|
|
- $area = ServiceArea::serviceArea(['lon'=>$params['lon'],'lat'=>$params['lat']]);
|
|
|
- if (!$area) {
|
|
|
- throw new Exception('已超出服务区域!-1001');
|
|
|
- }
|
|
|
|
|
|
- if(empty($params['mobile'])){
|
|
|
- throw new Exception('请先补充您的联系方式后在提交订单');
|
|
|
- }
|
|
|
- $is_join = GroupUserOrder::where('status','<>',4)->where(['group_activity_id' => $params['group_activity_id'], 'user_id' => $params['user_id']])->value('id');
|
|
|
+ $is_join = GroupUserOrder::where('pay_status',1)->where('refund_status',0)->where(['group_activity_id' => $params['group_activity_id'], 'user_id' => $params['user_id']])->value('id');
|
|
|
if ($is_join) {
|
|
|
throw new Exception('您已参加过该活动!');
|
|
|
}
|
|
|
@@ -137,10 +130,10 @@ class GroupActivityLogic extends BaseLogic
|
|
|
throw new Exception('拼团人数已满!'); //拼团人数已满
|
|
|
}
|
|
|
if ($group_order['status'] == 1 ) {
|
|
|
- throw new Exception('订单已支付!');
|
|
|
+ throw new Exception('活动已成团');
|
|
|
}
|
|
|
if ($group_order['status'] >= 1 ) {
|
|
|
- throw new Exception('订单已取消!');
|
|
|
+ throw new Exception('拼团已取消!');
|
|
|
}
|
|
|
if (strtotime($group_order['end_time']) < time()) {
|
|
|
throw new Exception('拼团活动已结束!'); //拼团活动已结束
|
|
|
@@ -154,15 +147,7 @@ class GroupActivityLogic extends BaseLogic
|
|
|
'group_order_id' => $group_order['id'],
|
|
|
'group_activity_id' => $params['group_activity_id'],
|
|
|
'user_id' => $params['user_id'],
|
|
|
- 'real_name' => $params['real_name'],
|
|
|
- 'mobile' => $params['mobile'],
|
|
|
- 'address' => $params['address'],
|
|
|
- 'lon' => $params['lon'],
|
|
|
- 'lat' => $params['lat'],
|
|
|
- 'province' => $areas['province']??0,
|
|
|
- 'city' => $areas['city']??0,
|
|
|
- 'area_name' => $areas['area_name']??'',
|
|
|
- 'service_area_id' => $areas['id']??0,
|
|
|
+ 'remark' => $params['remark'],
|
|
|
'order_amount' => $order_amount,
|
|
|
'order_terminal' => $params['terminal'],
|
|
|
];
|