...
|
...
|
@@ -177,32 +177,34 @@ class Ajax extends Frontend |
|
|
$res_store = Db::name('store')->where('id',$info['store_id'])->update($update);
|
|
|
// 修改或新增社区有效期
|
|
|
foreach (explode(',',$info['house_ids']) as $v) {
|
|
|
$store_house = Db::name('store_house')->where(['user_id'=>$info['user_id'],'store_id'=>$info['store_id'],'house_id'=>$v])->find();
|
|
|
if($store_house) {
|
|
|
$house_update = [
|
|
|
'id' => $store_house['id']
|
|
|
];
|
|
|
if($store_house['end_time'] > $time) {
|
|
|
$house_update['end_time'] = $store_house['end_time'] + config('site.house_valid');
|
|
|
if($v) {
|
|
|
$store_house = Db::name('store_house')->where(['user_id' => $info['user_id'], 'store_id' => $info['store_id'], 'house_id' => $v])->find();
|
|
|
if ($store_house) {
|
|
|
$house_update = [
|
|
|
'id' => $store_house['id']
|
|
|
];
|
|
|
if ($store_house['end_time'] > $time) {
|
|
|
$house_update['end_time'] = $store_house['end_time'] + config('site.house_valid') * 86400;
|
|
|
} else {
|
|
|
$house_update['end_time'] = $time + config('site.house_valid') * 86400;
|
|
|
}
|
|
|
$result_store_house = Db::name('store_house')->update(['id' => $store_house['id'], '']);
|
|
|
} else {
|
|
|
$house_update['end_time'] = $time + config('site.house_valid');
|
|
|
$insert = [
|
|
|
'user_id' => $info['user_id'],
|
|
|
'store_id' => $info['store_id'],
|
|
|
'house_id' => $v,
|
|
|
'start_time' => $time,
|
|
|
'end_time' => $time + config('site.house_valid'),
|
|
|
'createtime' => $time,
|
|
|
'updatetime' => $time
|
|
|
];
|
|
|
$result_store_house = Db::name('store_house')->insertGetId($insert);
|
|
|
}
|
|
|
if (!$result_store_house) {
|
|
|
Db::rollback();
|
|
|
return false; // 返回处理完成
|
|
|
}
|
|
|
$result_store_house = Db::name('store_house')->update(['id'=>$store_house['id'],'']);
|
|
|
} else {
|
|
|
$insert = [
|
|
|
'user_id' => $info['user_id'],
|
|
|
'store_id' => $info['store_id'],
|
|
|
'house_id' => $v,
|
|
|
'start_time' => $time,
|
|
|
'end_time' => $time + config('site.house_valid'),
|
|
|
'createtime' => $time,
|
|
|
'updatetime' => $time
|
|
|
];
|
|
|
$result_store_house = Db::name('store_house')->insertGetId($insert);
|
|
|
}
|
|
|
if(!$result_store_house) {
|
|
|
Db::rollback();
|
|
|
return false; // 返回处理完成
|
|
|
}
|
|
|
}
|
|
|
if(!$res_order || !$res_store) {
|
...
|
...
|
|