|
@@ -118,25 +118,26 @@ class Placeorder extends AuthController
|
|
|
$info = [];
|
|
|
}
|
|
|
}
|
|
|
- var_dump($info);
|
|
|
- $product = \app\admin\model\store\StoreProduct::get($info['product_id']);
|
|
|
- $discounts = json_decode($product['time_area_discount'], true);
|
|
|
- $discount = 0;
|
|
|
- if (count($discounts) > 0) {
|
|
|
- foreach ($discounts as $kk => $v) {
|
|
|
- $times = explode('-', $kk);
|
|
|
- if (!(count($times) == 2)) {
|
|
|
- break;
|
|
|
- }
|
|
|
- $start = strtotime(date('Y-m-d') . $times[0]);
|
|
|
- $end = strtotime(date('Y-m-d') . $times[1]);
|
|
|
- if (time() > $start && time() <= $end) {
|
|
|
- $discount = $v;
|
|
|
+ if ($info) {
|
|
|
+ $product = \app\admin\model\store\StoreProduct::get($info['product_id']);
|
|
|
+ $discounts = json_decode($product['time_area_discount'], true);
|
|
|
+ $discount = 0;
|
|
|
+ if (count($discounts) > 0) {
|
|
|
+ foreach ($discounts as $kk => $v) {
|
|
|
+ $times = explode('-', $kk);
|
|
|
+ if (!(count($times) == 2)) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ $start = strtotime(date('Y-m-d') . $times[0]);
|
|
|
+ $end = strtotime(date('Y-m-d') . $times[1]);
|
|
|
+ if (time() > $start && time() <= $end) {
|
|
|
+ $discount = $v;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- if ($discount > 0) {
|
|
|
- $info['price'] = bcmul(bcdiv($discount, 100, 4), $info['price'], 2);
|
|
|
+ if ($discount > 0) {
|
|
|
+ $info['price'] = bcmul(bcdiv($discount, 100, 4), $info['price'], 2);
|
|
|
+ }
|
|
|
}
|
|
|
return app('json')->successful($info);
|
|
|
}
|