|
@@ -144,6 +144,10 @@ class Kan extends Common
|
|
|
Db::startTrans();
|
|
|
//此次砍价
|
|
|
$kan = Db::name('shopro_activity_kan')->where('id',$kan_id)->lock(true)->find();
|
|
|
+ if($kan['user_id'] == $user['id']){
|
|
|
+ Db::rollback();
|
|
|
+ $this->error('不能砍自己发起的砍价');
|
|
|
+ }
|
|
|
if(empty($kan)){
|
|
|
Db::rollback();
|
|
|
$this->error('不存在的砍价活动');
|
|
@@ -237,6 +241,7 @@ class Kan extends Common
|
|
|
$this->error();
|
|
|
}
|
|
|
|
|
|
+ $user = auth_user();
|
|
|
|
|
|
$kan = Db::name('shopro_activity_kan')->alias('kan')
|
|
|
->field(['kan.*',
|
|
@@ -248,19 +253,29 @@ class Kan extends Common
|
|
|
->where('kan.id',$kan_id)
|
|
|
->find();
|
|
|
$kan = info_domain_image($kan,['image','sku_image']);
|
|
|
- $kan['seconds'] = $kan['expire_time'] - time(); if($kan['seconds'] < 0){$kan['seconds'] = 0;}
|
|
|
+ $kan['expire_seconds'] = $kan['expire_time'] - time(); if($kan['expire_seconds'] < 0){$kan['expire_seconds'] = 0;}
|
|
|
$kan['remain_price'] = bcsub(bcsub($kan['old_price'],$kan['activity_sku_price'],2),$kan['total_kan_price'],2); if($kan['remain_price'] < 0){$kan['remain_price'] = 0;}
|
|
|
if(!empty($kan['sku_image'])){
|
|
|
$kan['image'] = $kan['sku_image'];
|
|
|
}
|
|
|
+ $kan['is_my'] = $kan['user_id'] == $user['id'] ? 1 : 0;
|
|
|
|
|
|
//砍价记录
|
|
|
$kan_log = Db::name('shopro_activity_kan_log')->where('kan_id',$kan_id)->order('id asc')->select();
|
|
|
$kan_log = list_domain_image($kan_log,['avatar']);
|
|
|
|
|
|
+ //我有没有砍过
|
|
|
+ $my_kan = [];
|
|
|
+ foreach($kan_log as $key => $log){
|
|
|
+ if($log['user_id'] == $user['id']){
|
|
|
+ $my_kan = $log;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
$result = [
|
|
|
'activity' => $kan,
|
|
|
'log' => $kan_log,
|
|
|
+ 'my_kan' => $my_kan,
|
|
|
];
|
|
|
$this->success('获取成功',$result);
|
|
|
}
|