feat : caterer

This commit is contained in:
2025-03-24 15:19:05 +08:00
parent a2d081d387
commit 33ed3bf960
2 changed files with 57 additions and 48 deletions

View File

@@ -52,15 +52,15 @@ class CatererService extends BaseService
->where('admin_user.status',UserCode::ENABLE) ->where('admin_user.status',UserCode::ENABLE)
->whereIn('admin_user.role_id',[RoleCode::MEAL_CATERING,RoleCode::OPTION_CATERING]) ->whereIn('admin_user.role_id',[RoleCode::MEAL_CATERING,RoleCode::OPTION_CATERING])
->where('admin_user.city_id', $cityId) ->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' => []]); if (empty($list['data'])) return $this->return->success('success',['list' => []]);
$list = $list->toArray(); $kitchenIds = array_unique(array_column($list['data'],'kitchen_id'));
$kitchenIds = array_unique(array_column($list,'kitchen_id'));
$kitchenList = $this->kitchenModel->getDataByIds($kitchenIds); $kitchenList = $this->kitchenModel->getDataByIds($kitchenIds);
$kitchenList = array_column($kitchenList,null,'id'); $kitchenList = array_column($kitchenList,null,'id');
foreach ($list as &$item){ foreach ($list['data'] as &$item){
$item['kitchen_name'] = $kitchenList[$item['kitchen_id']]['name'] ?? ''; $item['kitchen_name'] = $kitchenList[$item['kitchen_id']]['name'] ?? '';
} }

View File

@@ -21,6 +21,7 @@ use App\Exception\ErrException;
use App\Extend\StringUtil; use App\Extend\StringUtil;
use App\Extend\SystemUtil; use App\Extend\SystemUtil;
use App\Lib\Crypto\CryptoFactory; use App\Lib\Crypto\CryptoFactory;
use App\Model\AdminUser;
use App\Model\CouponTemplate; use App\Model\CouponTemplate;
use App\Model\User; use App\Model\User;
use App\Model\UserAccount; use App\Model\UserAccount;
@@ -137,6 +138,11 @@ abstract class LoginBaseService extends BaseService
//todo 更新登录时间 //todo 更新登录时间
} }
/**
* @var AdminUser
*/
#[Inject]
protected AdminUser $adminUserModel;
/** /**
* 返回值 * 返回值
@@ -146,12 +152,15 @@ abstract class LoginBaseService extends BaseService
*/ */
protected function getReturn():array protected function getReturn():array
{ {
$adminUserInfo = $this->adminUserModel->getAdminInfoByBindUserId($this->userId);
$loginReturn = [ $loginReturn = [
'id' => $this->userId, 'id' => $this->userId,
'is_bind_mobile' => $this->userInfo->mobile ? UserCode::IS_BIND_PHONE : UserCode::IS_NOT_BIND_PHONE, 'is_bind_mobile' => $this->userInfo->mobile ? UserCode::IS_BIND_PHONE : UserCode::IS_NOT_BIND_PHONE,
'nickName' => $this->userInfo->nickName, 'nickName' => $this->userInfo->nickName,
'is_default_avatar' => $this->userInfo->avatar_id == 0 ? UserCode::IS_DEFAULT_AVATAR : UserCode::IS_NOT_DEFAULT_AVATAR, '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(); $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'); if (!$model->save()) throw new ErrException('注册失败-00002');
} }
/** // /**
* @var CouponTemplate $couponTemplateModel // * @var CouponTemplate $couponTemplateModel
*/ // */
#[Inject] // #[Inject]
protected CouponTemplate $couponTemplateModel; // protected CouponTemplate $couponTemplateModel;
/** // /**
* @return void // * @return void
* @throws ContainerExceptionInterface // * @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface // * @throws NotFoundExceptionInterface
*/ // */
protected function addCoupon(): void // protected function addCoupon(): void
{ // {
$couponTemplateId = $this->configCache->getConfigValueByKey(ConfigCode::COUPONS_FOR_NEWCOMERS); // $couponTemplateId = $this->configCache->getConfigValueByKey(ConfigCode::COUPONS_FOR_NEWCOMERS);
$couponValidity = $this->configCache->getConfigValueByKey(ConfigCode::NEWBIE_COUPON_VALIDITY); // $couponValidity = $this->configCache->getConfigValueByKey(ConfigCode::NEWBIE_COUPON_VALIDITY);
//
// 随便一个为0代表不赠送 // // 随便一个为0代表不赠送
if ($couponValidity == 0 || $couponTemplateId == 0) return; // if ($couponValidity == 0 || $couponTemplateId == 0) return;
//
$couponTemplateId = explode(',', $couponTemplateId); // $couponTemplateId = explode(',', $couponTemplateId);
$couponTemplateList = $this->couponTemplateModel->getDataByIds($couponTemplateId); // $couponTemplateList = $this->couponTemplateModel->getDataByIds($couponTemplateId);
//
$insertCoupon = []; // $insertCoupon = [];
foreach ($couponTemplateId as $one){ // foreach ($couponTemplateId as $one){
if ($couponTemplateList[$one]['status'] == CouponCode::COUPON_TEMPLATE_STATUS_ENABLE) continue; // if ($couponTemplateList[$one]['status'] == CouponCode::COUPON_TEMPLATE_STATUS_ENABLE) continue;
//
$insertCoupon[] = [ // $insertCoupon[] = [
'coupon_template_id' => $one, // 'coupon_template_id' => $one,
'coupon_dispense_id' => CouponCode::SYSTEMIC_DISTRIBUTION, // 'coupon_dispense_id' => CouponCode::SYSTEMIC_DISTRIBUTION,
'user_id' => $this->userId, // 'user_id' => $this->userId,
'status' => CouponCode::COUPON_STATUS_UNUSED, // 'status' => CouponCode::COUPON_STATUS_UNUSED,
'coupon_name' => $couponTemplateList[$one]['name'], // 'coupon_name' => $couponTemplateList[$one]['name'],
'validity_start_time' => date('Y-m-d H:i:s'), // 'validity_start_time' => date('Y-m-d H:i:s'),
'validity_end_time' => date('Y-m-d', strtotime('+'.$couponValidity.' days')), // 'validity_end_time' => date('Y-m-d', strtotime('+'.$couponValidity.' days')),
]; // ];
} // }
//
if (empty($insertCoupon)) return; // if (empty($insertCoupon)) return;
//
if (!(new UserCoupon)->insert($insertCoupon)) throw new ErrException('注册失败-00003'); // if (!(new UserCoupon)->insert($insertCoupon)) throw new ErrException('注册失败-00003');
//
$this->isNewcomerCouponPopUp = 1; // $this->isNewcomerCouponPopUp = 1;
} // }
/** /**
* @return void * @return void