feat : caterer
This commit is contained in:
@@ -52,15 +52,15 @@ class CatererService extends BaseService
|
||||
->where('admin_user.status',UserCode::ENABLE)
|
||||
->whereIn('admin_user.role_id',[RoleCode::MEAL_CATERING,RoleCode::OPTION_CATERING])
|
||||
->where('admin_user.city_id', $cityId)
|
||||
->paginate($limit,['admin_user.id','admin_user.chinese_name','caterer.kitchen_id','caterer.type','admin_user.role_id','admin_user.status']);
|
||||
->paginate($limit,['admin_user.id','admin_user.chinese_name','caterer.kitchen_id','caterer.type','admin_user.role_id','admin_user.status'])
|
||||
->toArray();
|
||||
|
||||
if ($list->isEmpty()) return $this->return->success('success',['list' => []]);
|
||||
$list = $list->toArray();
|
||||
$kitchenIds = array_unique(array_column($list,'kitchen_id'));
|
||||
if (empty($list['data'])) return $this->return->success('success',['list' => []]);
|
||||
$kitchenIds = array_unique(array_column($list['data'],'kitchen_id'));
|
||||
$kitchenList = $this->kitchenModel->getDataByIds($kitchenIds);
|
||||
$kitchenList = array_column($kitchenList,null,'id');
|
||||
|
||||
foreach ($list as &$item){
|
||||
foreach ($list['data'] as &$item){
|
||||
$item['kitchen_name'] = $kitchenList[$item['kitchen_id']]['name'] ?? '';
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ use App\Exception\ErrException;
|
||||
use App\Extend\StringUtil;
|
||||
use App\Extend\SystemUtil;
|
||||
use App\Lib\Crypto\CryptoFactory;
|
||||
use App\Model\AdminUser;
|
||||
use App\Model\CouponTemplate;
|
||||
use App\Model\User;
|
||||
use App\Model\UserAccount;
|
||||
@@ -137,6 +138,11 @@ abstract class LoginBaseService extends BaseService
|
||||
//todo 更新登录时间
|
||||
}
|
||||
|
||||
/**
|
||||
* @var AdminUser
|
||||
*/
|
||||
#[Inject]
|
||||
protected AdminUser $adminUserModel;
|
||||
|
||||
/**
|
||||
* 返回值
|
||||
@@ -146,12 +152,15 @@ abstract class LoginBaseService extends BaseService
|
||||
*/
|
||||
protected function getReturn():array
|
||||
{
|
||||
$adminUserInfo = $this->adminUserModel->getAdminInfoByBindUserId($this->userId);
|
||||
|
||||
$loginReturn = [
|
||||
'id' => $this->userId,
|
||||
'is_bind_mobile' => $this->userInfo->mobile ? UserCode::IS_BIND_PHONE : UserCode::IS_NOT_BIND_PHONE,
|
||||
'nickName' => $this->userInfo->nickName,
|
||||
'is_default_avatar' => $this->userInfo->avatar_id == 0 ? UserCode::IS_DEFAULT_AVATAR : UserCode::IS_NOT_DEFAULT_AVATAR,
|
||||
'is_newcomer_coupon_pop_up' => $this->isNewcomerCouponPopUp,
|
||||
'role' => $adminUserInfo->role_id ?? 0,
|
||||
// 'is_newcomer_coupon_pop_up' => $this->isNewcomerCouponPopUp,
|
||||
];
|
||||
|
||||
$loginReturn['token'] = $this->cryptoFactory->cryptoClass('jwt', json_encode($loginReturn))->encrypt();
|
||||
@@ -216,49 +225,49 @@ abstract class LoginBaseService extends BaseService
|
||||
if (!$model->save()) throw new ErrException('注册失败-00002');
|
||||
}
|
||||
|
||||
/**
|
||||
* @var CouponTemplate $couponTemplateModel
|
||||
*/
|
||||
#[Inject]
|
||||
protected CouponTemplate $couponTemplateModel;
|
||||
// /**
|
||||
// * @var CouponTemplate $couponTemplateModel
|
||||
// */
|
||||
// #[Inject]
|
||||
// protected CouponTemplate $couponTemplateModel;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
protected function addCoupon(): void
|
||||
{
|
||||
$couponTemplateId = $this->configCache->getConfigValueByKey(ConfigCode::COUPONS_FOR_NEWCOMERS);
|
||||
$couponValidity = $this->configCache->getConfigValueByKey(ConfigCode::NEWBIE_COUPON_VALIDITY);
|
||||
|
||||
// 随便一个为0代表不赠送
|
||||
if ($couponValidity == 0 || $couponTemplateId == 0) return;
|
||||
|
||||
$couponTemplateId = explode(',', $couponTemplateId);
|
||||
$couponTemplateList = $this->couponTemplateModel->getDataByIds($couponTemplateId);
|
||||
|
||||
$insertCoupon = [];
|
||||
foreach ($couponTemplateId as $one){
|
||||
if ($couponTemplateList[$one]['status'] == CouponCode::COUPON_TEMPLATE_STATUS_ENABLE) continue;
|
||||
|
||||
$insertCoupon[] = [
|
||||
'coupon_template_id' => $one,
|
||||
'coupon_dispense_id' => CouponCode::SYSTEMIC_DISTRIBUTION,
|
||||
'user_id' => $this->userId,
|
||||
'status' => CouponCode::COUPON_STATUS_UNUSED,
|
||||
'coupon_name' => $couponTemplateList[$one]['name'],
|
||||
'validity_start_time' => date('Y-m-d H:i:s'),
|
||||
'validity_end_time' => date('Y-m-d', strtotime('+'.$couponValidity.' days')),
|
||||
];
|
||||
}
|
||||
|
||||
if (empty($insertCoupon)) return;
|
||||
|
||||
if (!(new UserCoupon)->insert($insertCoupon)) throw new ErrException('注册失败-00003');
|
||||
|
||||
$this->isNewcomerCouponPopUp = 1;
|
||||
}
|
||||
// /**
|
||||
// * @return void
|
||||
// * @throws ContainerExceptionInterface
|
||||
// * @throws NotFoundExceptionInterface
|
||||
// */
|
||||
// protected function addCoupon(): void
|
||||
// {
|
||||
// $couponTemplateId = $this->configCache->getConfigValueByKey(ConfigCode::COUPONS_FOR_NEWCOMERS);
|
||||
// $couponValidity = $this->configCache->getConfigValueByKey(ConfigCode::NEWBIE_COUPON_VALIDITY);
|
||||
//
|
||||
// // 随便一个为0代表不赠送
|
||||
// if ($couponValidity == 0 || $couponTemplateId == 0) return;
|
||||
//
|
||||
// $couponTemplateId = explode(',', $couponTemplateId);
|
||||
// $couponTemplateList = $this->couponTemplateModel->getDataByIds($couponTemplateId);
|
||||
//
|
||||
// $insertCoupon = [];
|
||||
// foreach ($couponTemplateId as $one){
|
||||
// if ($couponTemplateList[$one]['status'] == CouponCode::COUPON_TEMPLATE_STATUS_ENABLE) continue;
|
||||
//
|
||||
// $insertCoupon[] = [
|
||||
// 'coupon_template_id' => $one,
|
||||
// 'coupon_dispense_id' => CouponCode::SYSTEMIC_DISTRIBUTION,
|
||||
// 'user_id' => $this->userId,
|
||||
// 'status' => CouponCode::COUPON_STATUS_UNUSED,
|
||||
// 'coupon_name' => $couponTemplateList[$one]['name'],
|
||||
// 'validity_start_time' => date('Y-m-d H:i:s'),
|
||||
// 'validity_end_time' => date('Y-m-d', strtotime('+'.$couponValidity.' days')),
|
||||
// ];
|
||||
// }
|
||||
//
|
||||
// if (empty($insertCoupon)) return;
|
||||
//
|
||||
// if (!(new UserCoupon)->insert($insertCoupon)) throw new ErrException('注册失败-00003');
|
||||
//
|
||||
// $this->isNewcomerCouponPopUp = 1;
|
||||
// }
|
||||
|
||||
/**
|
||||
* @return void
|
||||
|
||||
Reference in New Issue
Block a user