Browse Source

Merge branch 'phoenix' of ssh://120.24.33.109:11022/hyzjshwo/lanzu_api_hyperf into phoenix

master
weigang 5 years ago
parent
commit
bf7a3c073c
  1. 33
      app/Constants/v3/WithdrawalType.php
  2. 2
      app/Controller/v3/OrderOnlineController.php
  3. 9
      app/Model/v3/StoreWithdrawal.php
  4. 49
      app/Service/v3/Implementations/AppointmentTimeService.php
  5. 15
      app/Service/v3/Implementations/StoreService.php

33
app/Constants/v3/WithdrawalType.php

@ -0,0 +1,33 @@
<?php
namespace App\Constants\v3;
use Hyperf\Constants\AbstractConstants;
use Hyperf\Constants\Annotation\Constants;
/**
* @Constants
*/
class WithdrawalType extends AbstractConstants
{
/**
* @Message("微信")
*/
const WECHAT = 1;
/**
* @Message("余额")
*/
const BALANCE = 2;
/**
* @Message("银行")
*/
const BANK = 3;
/**
* @Message("支付宝")
*/
const ALIPAY = 4;
}

2
app/Controller/v3/OrderOnlineController.php

@ -103,7 +103,7 @@ class OrderOnlineController extends BaseController
$res['coupon'] = $this->couponRecService->allForOnlineOrderAvailable($userId, $marketId);
//增值服务接口
$res['value_added_service'] = [
'text' => '买鸡买鸭,免费帮杀;买瓜买黇,包熟包甜',
'text' => '勾选本条款视为您同意接受懒族生活为您提供增值服务的费用,包括但不仅限于洗菜,切菜,装菜所产生的打包费用,送货上门等增值服务',
'select' => 1,
'price' => 3.50,
'original_price' => 0.00

9
app/Model/v3/StoreWithdrawal.php

@ -4,6 +4,7 @@ namespace App\Model\v3;
use App\Model\Model;
use App\Constants\v3\Withdrawal;
use App\Constants\v3\WithdrawalType;
class StoreWithdrawal extends Model
{
protected $table = 'lanzu_store_withdrawal';
@ -11,7 +12,8 @@ class StoreWithdrawal extends Model
protected $appends = [
'state_text',
'check_time_text',
'created_at_text'
'created_at_text',
'pay_type_text'
];
public function getStateTextAttribute()
@ -32,4 +34,9 @@ class StoreWithdrawal extends Model
{
return date('Y-m-d H:i:s', $this->attributes['created_at']);
}
public function getPayTypeTextAttribute()
{
return '提现到'.WithdrawalType::getMessage($this->attributes['type']);
}
}

49
app/Service/v3/Implementations/AppointmentTimeService.php

@ -41,9 +41,11 @@ class AppointmentTimeService implements AppointmentTimeServiceInterface
$time4Arr = [];
$nowTime = time();
foreach($stores as $store){
//店铺手动 点击歇业
if($store['is_rest'] == 1){
return $store['name'].'店铺已打烊';
}
//当前时间小于 开始营业时间
$time1 = strtotime(($store['time1']));
if($nowTime < $time1){
return $store['name'].'店铺已打烊';
@ -64,28 +66,43 @@ class AppointmentTimeService implements AppointmentTimeServiceInterface
array_push($time1Arr,$time1);
array_push($time2Arr,$time2);
}
$res = [];
$time1Max = max($time1Arr);
if($nowTime > $time1Max){
$time1Max = ceil($nowTime / 1800) * 1800;
}
$time2Min = min($time2Arr);
$length = ceil(($time2Min - $time1Max) / 1800);
for ($i=1;$i<=$length;$i++){
$addTime = $time1Max + (30*60*$i);
$res[] = date('h:i',$addTime);
if($time2Min > $nowTime) {
array_push($res, $this->calculateTime($time1Max, $time2Min));
}
if(!empty($time3Arr) && !empty($time4Arr)){
$time3Max = max($time3Arr);
if($nowTime > $time3Max){
$time3Max = ceil($nowTime / 1800) * 1800;
}
$time4Min = min($time4Arr);
$length = ceil(($time4Min - $time3Max) / 1800);
for ($i=1;$i<=$length;$i++){
$addTime = $time3Max + (30*60*$i);
$res[] = date('H:i',$addTime);
$time3Max = max($time3Arr);
$time4Min = min($time4Arr);
if($time4Min > $nowTime) {
array_push($res, $this->calculateTime($time3Max, $time4Min));
}
}
return $res;
}
function calculateTime($startTime,$endTime)
{
$nowTime = time();
//如果开始时间小于当前时间则取当前时间
if($nowTime > $startTime){
$startTime = ceil($nowTime / (30*60)) * (30*60);
}
//高峰段 区间
$peakPeriod = strtotime('16:00');
$peakPeriodEnd = strtotime('18:00');
$span = ($peakPeriodEnd - $peakPeriod)/(30*60);
//取得订单下所有店铺时间段 交集 并计算时间段横跨单位区间长度
$length = ceil(($endTime - $startTime) / (30*60));
for ($i=1;$i<=$length;$i++){
$addTime = $startTime + (30*60*$i);
if($addTime >= $peakPeriod && $addTime < $peakPeriodEnd){
$i+=$span;
$addTime = $startTime + (30*60*$i);
}
$res[] = date('H:i',$addTime) . ' - ' . date('H:i',$addTime + (30*60));
}
return $res;
}
}

15
app/Service/v3/Implementations/StoreService.php

@ -25,14 +25,15 @@ class StoreService implements StoreServiceInterface
->first();
if(!empty($store)){
$nowTime = time();
$time1 = strtotime(($store->time1));
$time2 = strtotime(($store->time2));
if($time1 < $nowTime && $nowTime < $time2){
return true;
$startTime = strtotime(($store->time1));
if(!empty($store->time3) && !empty($store->time4)){
$time4 = strtotime(($store->time4));
$endTime = $time4;
}else{
$time2 = strtotime(($store->time2));
$endTime = $time2;
}
$time3 = strtotime(($store->time3));
$time4 = strtotime(($store->time4));
if($time3 < $nowTime && $nowTime < $time4){
if($nowTime > $startTime && $nowTime < $endTime){
return true;
}
}

Loading…
Cancel
Save