Browse Source

Merge branch 'purchase_limit' of http://120.24.33.109:11081/hyzjshwo/lanzu_api_hyperf into purchase_limit

master
Lemon 5 years ago
parent
commit
b9fe5d78a4
  1. 13
      app/Service/AttachmentService.php
  2. 23
      app/Service/OrderService.php
  3. 5
      app/Service/PurchaseLimitService.php

13
app/Service/AttachmentService.php

@ -70,4 +70,17 @@ class AttachmentService implements AttachmentServiceInterface
$path .= '/'.date('Y').'/'.date('m').'/'.date('d'); $path .= '/'.date('Y').'/'.date('m').'/'.date('d');
return $baseDir.$path; return $baseDir.$path;
} }
public function switchImgToAliOss($path, $bucket = 'thumbnail_q50')
{
if (strpos($path, 'http') === false || strpos($path, 'https') === false) {
$path = 'https://img.lanzulive.com/' . $path;
} else {
$temp = explode('//', $path);
$temp = explode('/', $temp[1]);
unset($temp[0]);
$path = 'https://img.lanzulive.com/' . implode('/', $temp);
}
return $path . '!' . $bucket;
}
} }

23
app/Service/OrderService.php

@ -64,6 +64,12 @@ class OrderService implements OrderServiceInterface
*/ */
protected $financialService; protected $financialService;
/**
* @Inject
* @var AttachmentServiceInterface
*/
protected $attachmentService;
/** /**
* @inheritDoc * @inheritDoc
*/ */
@ -302,7 +308,7 @@ class OrderService implements OrderServiceInterface
} }
//判断是否有购买多个特价商品 //判断是否有购买多个特价商品
$result = $this->purchaseLimitService->PurchaseLimit($orderGoods); $result = $this->purchaseLimitService->PurchaseLimit($orderGoods);
if(!$result){
if($result > 0){
Db::rollBack(); Db::rollBack();
return '同一个订单不能购买多个特价商品'; return '同一个订单不能购买多个特价商品';
} }
@ -972,22 +978,9 @@ class OrderService implements OrderServiceInterface
$goods = OrderGoods::query()->whereIn('order_id', $orderChildIds)->select(['name', 'img'])->first(); $goods = OrderGoods::query()->whereIn('order_id', $orderChildIds)->select(['name', 'img'])->first();
$order['good_name'] = $goods->name; $order['good_name'] = $goods->name;
// TODO 临时写死oss压缩类型 // TODO 临时写死oss压缩类型
$order['img'] = $this->switchImgToAliOss($goods->img);
$order['img'] = $this->attachmentService->switchImgToAliOss($goods->img);
} }
return $orders; return $orders;
} }
public function switchImgToAliOss($path, $bucket = 'thumbnail_q50')
{
if (strpos($path, 'http') === false || strpos($path, 'https') === false) {
$path = 'https://img.lanzulive.com/' . $path;
} else {
$temp = explode('//', $path);
$temp = explode('/', $temp[1]);
unset($temp[0]);
$path = 'https://img.lanzulive.com/' . implode('/', $temp);
}
return $path . '!' . $bucket;
}
} }

5
app/Service/PurchaseLimitService.php

@ -83,13 +83,10 @@ class PurchaseLimitService implements PurchaseLimitServiceInterface
foreach ($orderGoods as $goods){ foreach ($orderGoods as $goods){
$sum = 0; $sum = 0;
if($goods['money'] == 0.01){ if($goods['money'] == 0.01){
if($sum > 0){
return false;
}
$sum++; $sum++;
} }
} }
return true;
return $sum;
} }
public function test($params) public function test($params)

Loading…
Cancel
Save