|
@@ -215,6 +215,7 @@ class AuctionProductController
|
|
$uid = $product['uid']; // 所属人id
|
|
$uid = $product['uid']; // 所属人id
|
|
|
|
|
|
$product['uid'] = $order['uid'];// 商品拥有人更新
|
|
$product['uid'] = $order['uid'];// 商品拥有人更新
|
|
|
|
+ $product['add_time'] = time();
|
|
$res = $product->save();
|
|
$res = $product->save();
|
|
if ($res){
|
|
if ($res){
|
|
if ($uid > 0){
|
|
if ($uid > 0){
|
|
@@ -296,43 +297,9 @@ class AuctionProductController
|
|
['id']
|
|
['id']
|
|
]);
|
|
]);
|
|
$product = AuctionProduct::where('id', $data['id'])->find();
|
|
$product = AuctionProduct::where('id', $data['id'])->find();
|
|
- $auction = Auction::where('id', $product['auction_id'])->find();
|
|
|
|
if (!$product) return app('json')->fail('商品不存在');
|
|
if (!$product) return app('json')->fail('商品不存在');
|
|
|
|
|
|
- $data['time'] = explode(',', $auction['site']);
|
|
|
|
-
|
|
|
|
- $date = date('w', time()); // 今天星期几
|
|
|
|
- $data['gs_time'] = '';
|
|
|
|
- if (in_array(1, $data['time'])){
|
|
|
|
- if ($date >= 1 and $date <= 2){
|
|
|
|
- $data['gs_time'] = date('Y-m-d H:i:s', strtotime("Wednesday")); // 星期三
|
|
|
|
- }elseif ($date >= 3 and $date <= 4){
|
|
|
|
-
|
|
|
|
- $data['gs_time'] = date('Y-m-d H:i:s', strtotime("Friday")); // 星期五
|
|
|
|
- }elseif ($date >= 5 or $date == 0){
|
|
|
|
-
|
|
|
|
- $data['gs_time'] = date('Y-m-d H:i:s', strtotime("Monday")); // 下个星期一
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }else if (in_array(2, $data['time'])){
|
|
|
|
- if ($date >= 2 and $date <= 3){
|
|
|
|
- $data['gs_time'] = date('Y-m-d H:i:s', strtotime("Thursday")); // 星期四
|
|
|
|
- }elseif ($date >= 4 and $date <= 5){
|
|
|
|
-
|
|
|
|
- $data['gs_time'] = date('Y-m-d H:i:s', strtotime("Saturday")); // 星期六
|
|
|
|
- }elseif ($date >= 6 or $date == 0 or $date == 1){
|
|
|
|
-
|
|
|
|
- $data['gs_time'] = date('Y-m-d H:i:s', strtotime("Tuesday")); // 下个星期二
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- $hanging_price = number_format($product['hanging_price'] * $product['rise']/100, 2); // 溢价
|
|
|
|
- $anticipate = number_format($product['hanging_price'] * $product['deduct']/100, 2); // 扣除
|
|
|
|
-
|
|
|
|
- $data['hanging_price'] = $product['hanging_price'] + $hanging_price;
|
|
|
|
- $data['anticipate'] = (float)$anticipate;
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+ $data = $this->bs($data['id']);
|
|
return app('json')->successful($data);
|
|
return app('json')->successful($data);
|
|
|
|
|
|
}
|
|
}
|
|
@@ -350,7 +317,6 @@ class AuctionProductController
|
|
{
|
|
{
|
|
$data = UtilService::postMore([
|
|
$data = UtilService::postMore([
|
|
['id'],
|
|
['id'],
|
|
- ['gs_time']
|
|
|
|
]);
|
|
]);
|
|
$product = AuctionProduct::where('id', $data['id'])->find();
|
|
$product = AuctionProduct::where('id', $data['id'])->find();
|
|
$user = User::where('uid', $request->uid())->find();
|
|
$user = User::where('uid', $request->uid())->find();
|
|
@@ -358,27 +324,27 @@ class AuctionProductController
|
|
|
|
|
|
if ($product['is_show'] == 1) return app('json')->fail('商品已挂售');
|
|
if ($product['is_show'] == 1) return app('json')->fail('商品已挂售');
|
|
|
|
|
|
- $hanging_price = number_format($product['hanging_price'] * $product['rise']/100, 2); // 溢价
|
|
|
|
- $anticipate = number_format($product['hanging_price'] * $product['deduct']/100, 2); // 扣除
|
|
|
|
- if ($user['anticipate'] < $anticipate) return app('json')->fail('预约券不足');
|
|
|
|
|
|
+ $datas = $this->bs($data['id']);// 获取挂售详情
|
|
|
|
+ if ($user['anticipate'] < $datas['anticipate']) return app('json')->fail('预约券不足');
|
|
|
|
|
|
$product['price'] = $product['hanging_price'];
|
|
$product['price'] = $product['hanging_price'];
|
|
- $product['hanging_price'] += $hanging_price;
|
|
|
|
- $product['is_show'] = 1;
|
|
|
|
|
|
+ $product['hanging_price'] = $datas['hanging_price']; // 商品变为挂售价格
|
|
|
|
+ $product['is_show'] = 1; // 上架
|
|
$product['is_admin'] = 2;
|
|
$product['is_admin'] = 2;
|
|
- $user['anticipate'] -= $anticipate;
|
|
|
|
|
|
+ $user['anticipate'] -= $datas['anticipate']; // 扣除预约券
|
|
try {
|
|
try {
|
|
Db::startTrans();
|
|
Db::startTrans();
|
|
|
|
+ // 新增挂售时间段
|
|
AuctionTime::create([
|
|
AuctionTime::create([
|
|
'uid' => $request->uid(),
|
|
'uid' => $request->uid(),
|
|
'product_id' => $product['id'],
|
|
'product_id' => $product['id'],
|
|
'auction_id' => $product['auction_id'],
|
|
'auction_id' => $product['auction_id'],
|
|
- 'add_time' => strtotime($data['gs_time'])
|
|
|
|
|
|
+ 'add_time' => strtotime($datas['gs_time'])
|
|
]);
|
|
]);
|
|
|
|
|
|
$product->save();
|
|
$product->save();
|
|
$user->save();
|
|
$user->save();
|
|
- UserBill::expend('挂售扣除预约券', $user['uid'], 'anticipate', 'reduce_anticipate', $anticipate, $user['spread_uid'], $user['anticipate'], '挂售商品扣除预约券');
|
|
|
|
|
|
+ UserBill::expend('挂售扣除预约券', $user['uid'], 'anticipate', 'reduce_anticipate', $datas['anticipate'], $user['spread_uid'], $user['anticipate'], '挂售商品扣除预约券');
|
|
|
|
|
|
Db::commit();
|
|
Db::commit();
|
|
return app('json')->successful('挂售成功');
|
|
return app('json')->successful('挂售成功');
|
|
@@ -390,5 +356,51 @@ class AuctionProductController
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public function bs($id)
|
|
|
|
+ {
|
|
|
|
+ $product = AuctionProduct::where('id',$id)->find();
|
|
|
|
+ $auction = Auction::where('id', $product['auction_id'])->find();
|
|
|
|
+ if (!$product) return app('json')->fail('商品不存在');
|
|
|
|
+
|
|
|
|
+ $data['time'] = explode(',', $auction['site']);
|
|
|
|
+
|
|
|
|
+ $date = date('w', time()); // 今天星期几
|
|
|
|
+ $data['gs_time'] = '';
|
|
|
|
+ $bs = 0;
|
|
|
|
+ if (in_array(1, $data['time'])){
|
|
|
|
+ if ($date >= 1 and $date <= 2){
|
|
|
|
+ $data['gs_time'] = date('Y-m-d H:i:s', strtotime("Wednesday")); // 星期三
|
|
|
|
+ $bs = 2;
|
|
|
|
+ }elseif ($date >= 3 and $date <= 4){
|
|
|
|
+ $data['gs_time'] = date('Y-m-d H:i:s', strtotime("Friday")); // 星期五
|
|
|
|
+ $bs = 2;
|
|
|
|
+ }elseif ($date >= 5 or $date == 0){
|
|
|
|
+ $data['gs_time'] = date('Y-m-d H:i:s', strtotime("Monday")); // 下个星期一
|
|
|
|
+ $bs = 3;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }else if (in_array(2, $data['time'])){
|
|
|
|
+ if ($date >= 2 and $date <= 3){
|
|
|
|
+ $data['gs_time'] = date('Y-m-d H:i:s', strtotime("Thursday")); // 星期四
|
|
|
|
+ $bs = 2;
|
|
|
|
+ }elseif ($date >= 4 and $date <= 5){
|
|
|
|
+ $data['gs_time'] = date('Y-m-d H:i:s', strtotime("Saturday")); // 星期六
|
|
|
|
+ $bs = 2;
|
|
|
|
+ }elseif ($date >= 6 or $date == 0 or $date == 1){
|
|
|
|
+ $data['gs_time'] = date('Y-m-d H:i:s', strtotime("Tuesday")); // 下个星期二
|
|
|
|
+ $bs = 3;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $hanging_price = round($product['hanging_price'] * $product['rise']/100, 2); // 溢价
|
|
|
|
+ $anticipate = round($product['hanging_price'] * $product['deduct']/100, 2); // 扣除
|
|
|
|
+
|
|
|
|
+ $data['hanging_price'] = (int)$product['hanging_price'] + ($hanging_price * $bs);
|
|
|
|
+ $data['anticipate'] = $anticipate;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return $data;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
}
|
|
}
|