初始版本
This commit is contained in:
619
server/app/adminapi/logic/coach/CoachLogic.php
Executable file
619
server/app/adminapi/logic/coach/CoachLogic.php
Executable file
@@ -0,0 +1,619 @@
|
||||
<?php
|
||||
namespace app\adminapi\logic\coach;
|
||||
use app\common\enum\accountLog\CoachAccountLogEnum;
|
||||
use app\common\enum\coach\CoachEnum;
|
||||
use app\common\enum\DefaultEnum;
|
||||
use app\common\enum\notice\NoticeEnum;
|
||||
use app\common\enum\shop\ShopEnum;
|
||||
use app\common\logic\CoachAccountLogLogic;
|
||||
use app\common\model\coach\Coach;
|
||||
use app\common\model\coach\CoachGoodsIndex;
|
||||
use app\common\model\coach\CoachLifePhoto;
|
||||
use app\common\model\coach\CoachUpdate;
|
||||
use app\common\model\coach\CoachUser;
|
||||
use app\common\model\goods\Goods;
|
||||
use app\common\model\skill\Skill;
|
||||
use app\common\service\ConfigService;
|
||||
use app\common\service\FileService;
|
||||
use think\Exception;
|
||||
use think\facade\Config;
|
||||
use think\facade\Db;
|
||||
|
||||
/**
|
||||
* 技师逻辑类
|
||||
* Class CoachLogic
|
||||
* @package app\adminapi\logic\coach
|
||||
*/
|
||||
class CoachLogic
|
||||
{
|
||||
/**
|
||||
* @notes 技师账号列表
|
||||
* @return CoachUser[]|array|\think\Collection
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author cjhao
|
||||
* @date 2024/8/20 17:33
|
||||
*/
|
||||
public function coachUserLists()
|
||||
{
|
||||
$coachUserIds = Coach::where('audit_status','<>',CoachEnum::AUDIT_STATUS_PASS)->column('coach_user_id');
|
||||
return CoachUser::where('id','not in',$coachUserIds)->field('id,sn,account')->select()->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 技能列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author cjhao
|
||||
* @date 2024/8/20 18:02
|
||||
*/
|
||||
public function skillLists($shopId = 0)
|
||||
{
|
||||
$whereShop = [];
|
||||
if($shopId){
|
||||
$whereShop[] = ['G.shop_id','in',[0,$shopId]];
|
||||
}else{
|
||||
$whereShop[] = ['G.shop_id','=',0];
|
||||
}
|
||||
$skillLists = Skill::field('name,id')->select()->toArray();
|
||||
$goodsLists = Goods::alias('G')
|
||||
->where(['G.status'=>1,'G.audit_status'=>1])
|
||||
->where($whereShop)
|
||||
->append(['category_desc','skill_desc'])
|
||||
->join('goods_skill_index GSI','G.id = GSI.goods_id')
|
||||
->field('G.id,G.price,G.name,G.category_id,G.image,GSI.skill_id')
|
||||
->select()->toArray();
|
||||
foreach ($skillLists as $key => $skill){
|
||||
$skillGoodsLists = [];
|
||||
foreach ($goodsLists as $goods){
|
||||
if($skill['id'] == $goods['skill_id']){
|
||||
$skillGoodsLists[] = $goods;
|
||||
}
|
||||
}
|
||||
$skillLists[$key]['goods_list'] = $skillGoodsLists;
|
||||
}
|
||||
return $skillLists;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加
|
||||
* @param array $params
|
||||
* @return string|true
|
||||
* @throws \Exception
|
||||
* @author cjhao
|
||||
* @date 2024/8/21 15:49
|
||||
*/
|
||||
public function add(array $params)
|
||||
{
|
||||
try {
|
||||
Db::startTrans();
|
||||
$number = CoachUser::count()+1;
|
||||
$sn = sprintf("%03d", $number);
|
||||
$passwordSalt = Config::get('project.unique_identification');
|
||||
$password = create_password($params['mobile'], $passwordSalt);
|
||||
$avatar = ConfigService::get('default_image', 'user_avatar');
|
||||
$coachUser = CoachUser::where(['account'=>$params['mobile']])->findOrEmpty();
|
||||
if(!$coachUser->isEmpty()){
|
||||
throw new Exception('手机号码已重复');
|
||||
}
|
||||
$coachUser = CoachUpdate::where(['mobile'=>$params['mobile'],'audit_status'=>CoachEnum::AUDIT_STATUS_WAIT])->findOrEmpty();
|
||||
if(!$coachUser->isEmpty()){
|
||||
throw new Exception('手机号码已重复');
|
||||
}
|
||||
$coachUser = CoachUser::create([
|
||||
'sn' => $sn,
|
||||
'avatar' => $avatar,
|
||||
'account' => $params['mobile'],
|
||||
'password' => $password,
|
||||
// 'channel' => $params['channel'],
|
||||
]);
|
||||
|
||||
$coach = new Coach();
|
||||
$coach->name = $params['name'];
|
||||
$coach->sn = $coachUser->sn;
|
||||
$coach->gender = $params['gender'];
|
||||
$coach->age = $params['age'];
|
||||
$coach->id_card = $params['id_card'];
|
||||
$coach->mobile = $params['mobile'];
|
||||
$coach->education = $params['education'];
|
||||
$coach->nation = $params['nation'];
|
||||
$coach->province_id = $params['province_id'];
|
||||
$coach->city_id = $params['city_id'];
|
||||
$coach->region_id = $params['region_id'];
|
||||
$coach->longitude = $params['longitude'];
|
||||
$coach->latitude = $params['latitude'];
|
||||
$coach->address_detail = $params['address_detail'];
|
||||
$coach->coach_user_id = $coachUser->id;
|
||||
$coach->skill_id = $params['skill_id'];
|
||||
$coach->id_card_front = $params['id_card_front'];
|
||||
$coach->id_card_back = $params['id_card_back'];
|
||||
$coach->portrait_shooting = $params['portrait_shooting'];
|
||||
$coach->work_photo = $params['work_photo'];
|
||||
$coach->certification = $params['certification'] ?? '';
|
||||
$coach->health_certificate = $params['health_certificate'] ?? '';
|
||||
$coach->work_status = $params['work_status'];
|
||||
$coach->server_status = $params['server_status'];
|
||||
$coach->longitude = $params['longitude'] ?? '';
|
||||
$coach->latitude = $params['latitude'] ?? '';
|
||||
$coach->audit_status = CoachEnum::AUDIT_STATUS_PASS;
|
||||
$coach->save();
|
||||
|
||||
//生活照
|
||||
$lifePhoto = $params['life_photo'] ?? [];
|
||||
$lifePhotoLists = [];
|
||||
foreach ($lifePhoto as $photo){
|
||||
$lifePhotoLists[] = [
|
||||
'uri' => $photo,
|
||||
'coach_id' => $coach->id
|
||||
];
|
||||
}
|
||||
(new CoachLifePhoto())->saveAll($lifePhotoLists);
|
||||
|
||||
//关联服务
|
||||
$goodsIds = $params['goods_ids'] ?? [];
|
||||
$goodsLists = [];
|
||||
foreach ($goodsIds as $goodsId)
|
||||
{
|
||||
$goodsLists[] = [
|
||||
'goods_id' => $goodsId,
|
||||
'coach_id' => $coach->id,
|
||||
];
|
||||
}
|
||||
(new CoachGoodsIndex())->saveAll($goodsLists);
|
||||
Db::commit();
|
||||
|
||||
return true;
|
||||
}catch (Exception $e){
|
||||
Db::rollback();
|
||||
return $e->getMessage();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 详情
|
||||
* @param int $id
|
||||
* @return array
|
||||
* @author cjhao
|
||||
* @date 2024/8/21 15:30
|
||||
*/
|
||||
public function detail(int $id)
|
||||
{
|
||||
$coach = (new Coach())
|
||||
->where(['id'=>$id])
|
||||
->append(['province_name','city_name','region_name','region_desc','life_photo'])
|
||||
->withoutField('create_time,update_time,delete_time')
|
||||
->findOrEmpty()
|
||||
->toArray();
|
||||
|
||||
$goodsLists = Goods::alias('G')
|
||||
->where(['CGI.coach_id'=>$id])
|
||||
->join('coach_goods_index CGI','G.id=CGI.goods_id')
|
||||
->field('G.id,G.name,G.image')
|
||||
->select()->toArray();
|
||||
$coach['life_photo'] = array_column($coach['life_photo']->toArray(),'uri');
|
||||
$coach['goods_lists'] = $goodsLists;
|
||||
$coach['goods_ids'] = array_column($goodsLists,'id');
|
||||
return $coach;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑
|
||||
* @param array $params
|
||||
* @return string|true
|
||||
* @throws \Exception
|
||||
* @author cjhao
|
||||
* @date 2024/8/21 15:50
|
||||
*/
|
||||
public function edit(array $params)
|
||||
{
|
||||
try {
|
||||
Db::startTrans();
|
||||
$coach = Coach::find($params['id']);
|
||||
$coachUser = CoachUser::where('id','<>',$coach['coach_user_id'])
|
||||
->where('account','=',$params['mobile'])
|
||||
->findOrEmpty();
|
||||
if(!$coachUser->isEmpty()){
|
||||
throw new Exception('手机号码已存在');
|
||||
}
|
||||
$coachUser = CoachUpdate::where('mobile','=',$params['mobile'])
|
||||
->where(['audit_status'=>ShopEnum::AUDIT_STATUS_WAIT])
|
||||
->where('coach_user_id','<>',$coach['coach_user_id'])
|
||||
->findOrEmpty();
|
||||
if(!$coachUser->isEmpty()){
|
||||
throw new Exception('手机号码已存在');
|
||||
}
|
||||
CoachUser::update(['account'=>$params['mobile']],['id'=>$coach['coach_user_id']]);
|
||||
|
||||
$coach->name = $params['name'];
|
||||
$coach->gender = $params['gender'];
|
||||
$coach->age = $params['age'];
|
||||
$coach->id_card = $params['id_card'];
|
||||
$coach->mobile = $params['mobile'];
|
||||
$coach->education = $params['education'];
|
||||
$coach->nation = $params['nation'];
|
||||
$coach->province_id = $params['province_id'];
|
||||
$coach->city_id = $params['city_id'];
|
||||
$coach->region_id = $params['region_id'];
|
||||
$coach->longitude = $params['longitude'];
|
||||
$coach->latitude = $params['latitude'];
|
||||
$coach->address_detail = $params['address_detail'];
|
||||
// $coach->coach_user_id = $params['coach_user_id'];
|
||||
$coach->skill_id = $params['skill_id'];
|
||||
$coach->id_card_front = $params['id_card_front'];
|
||||
$coach->id_card_back = $params['id_card_back'];
|
||||
$coach->portrait_shooting = $params['portrait_shooting'];
|
||||
$coach->work_photo = $params['work_photo'];
|
||||
$coach->certification = $params['certification'] ?? '';
|
||||
$coach->health_certificate = $params['health_certificate'] ?? '';
|
||||
$workStatus = $params['work_status'];
|
||||
if( 0 == $params['server_status']){
|
||||
$workStatus = 0;
|
||||
}
|
||||
$coach->work_status = $workStatus;
|
||||
$coach->server_status = $params['server_status'];
|
||||
$coach->save();
|
||||
|
||||
(new CoachLifePhoto())->where(['coach_id'=>$params['id']])->delete();
|
||||
(new CoachGoodsIndex())->where(['coach_id'=>$params['id']])->delete();
|
||||
//生活照
|
||||
$lifePhoto = $params['life_photo'] ?? [];
|
||||
$lifePhotoLists = [];
|
||||
foreach ($lifePhoto as $photo){
|
||||
$lifePhotoLists[] = [
|
||||
'uri' => $photo,
|
||||
'coach_id' => $coach->id
|
||||
];
|
||||
}
|
||||
(new CoachLifePhoto())->saveAll($lifePhotoLists);
|
||||
|
||||
//关联服务
|
||||
$goodsIds = $params['goods_ids'] ?? [];
|
||||
$goodsLists = [];
|
||||
foreach ($goodsIds as $goodsId)
|
||||
{
|
||||
$goodsLists[] = [
|
||||
'goods_id' => $goodsId,
|
||||
'coach_id' => $coach->id,
|
||||
];
|
||||
}
|
||||
(new CoachGoodsIndex())->saveAll($goodsLists);
|
||||
Db::commit();
|
||||
|
||||
return true;
|
||||
}catch (Exception $e){
|
||||
Db::rollback();
|
||||
return $e->getMessage();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 其他数据
|
||||
* @return array
|
||||
* @author cjhao
|
||||
* @date 2024/8/21 18:16
|
||||
*/
|
||||
public function otherLists()
|
||||
{
|
||||
$educationLists = DefaultEnum::getEducationLists();
|
||||
$nationLists = DefaultEnum::getNationLists();
|
||||
return [
|
||||
'education_lists' => $educationLists,
|
||||
'nation_lists' => $nationLists,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 调整佣金
|
||||
* @param array $params
|
||||
* @return string|true
|
||||
* @author cjhao
|
||||
* @date 2024/8/23 15:04
|
||||
*/
|
||||
public function adjustMoney(array $params)
|
||||
{
|
||||
try {
|
||||
Db::startTrans();
|
||||
|
||||
$coach = Coach::where(['id'=>$params['id']])->findOrEmpty();
|
||||
if($coach->isEmpty()){
|
||||
return '技师不存在';
|
||||
}
|
||||
|
||||
$action = $params['action'];
|
||||
if(1 == $action){
|
||||
|
||||
$coach->money = $coach->money+$params['money'];
|
||||
$coach->save();
|
||||
|
||||
CoachAccountLogLogic::add(
|
||||
$coach->id,
|
||||
CoachAccountLogEnum::MONEY,
|
||||
CoachAccountLogEnum::ADMIN_INC_MONEY,
|
||||
$action,
|
||||
$params['money'],
|
||||
'',
|
||||
$params['admin_id']
|
||||
);
|
||||
|
||||
}else{
|
||||
if($params['money'] > $coach->money){
|
||||
return '当前技师佣金仅剩:'.$coach->money;
|
||||
}
|
||||
$coach->money = $coach->money - $params['money'];
|
||||
$coach->save();
|
||||
CoachAccountLogLogic::add(
|
||||
$coach->id,
|
||||
CoachAccountLogEnum::MONEY,
|
||||
CoachAccountLogEnum::ADMIN_DEC_MONEY,
|
||||
2,
|
||||
$params['money'],
|
||||
'',
|
||||
$params['admin_id']
|
||||
);
|
||||
}
|
||||
Db::commit();
|
||||
|
||||
return true;
|
||||
}catch (Exception $e){
|
||||
Db::rollback();
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 调整佣金
|
||||
* @param array $params
|
||||
* @return string|true
|
||||
* @author cjhao
|
||||
* @date 2024/8/23 15:04
|
||||
*/
|
||||
public function adjustDeposit(array $params)
|
||||
{
|
||||
try {
|
||||
Db::startTrans();
|
||||
|
||||
$coach = Coach::where(['id'=>$params['id']])->findOrEmpty();
|
||||
if($coach->isEmpty()){
|
||||
return '技师不存在';
|
||||
}
|
||||
|
||||
$action = $params['action'];
|
||||
if(1 == $action){
|
||||
|
||||
$coach->deposit = $coach->deposit+$params['money'];
|
||||
$coach->save();
|
||||
|
||||
CoachAccountLogLogic::add(
|
||||
$coach->id,
|
||||
CoachAccountLogEnum::DEPOSIT,
|
||||
CoachAccountLogEnum::ADMIN_INC_DEPOSIT,
|
||||
$action,
|
||||
$params['money'],
|
||||
'',
|
||||
$params['admin_id']
|
||||
);
|
||||
|
||||
}else{
|
||||
if($params['money'] > $coach->deposit){
|
||||
return '当前技师保证金仅剩:'.$coach->deposit;
|
||||
}
|
||||
$coach->deposit = $coach->deposit - $params['money'];
|
||||
$coach->save();
|
||||
CoachAccountLogLogic::add(
|
||||
$coach->id,
|
||||
CoachAccountLogEnum::DEPOSIT,
|
||||
CoachAccountLogEnum::ADMIN_DEC_DEPOSIT,
|
||||
$action,
|
||||
$params['money'],
|
||||
'',
|
||||
$params['admin_id']
|
||||
);
|
||||
}
|
||||
Db::commit();
|
||||
|
||||
return true;
|
||||
}catch (Exception $e){
|
||||
Db::rollback();
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/***
|
||||
* @notes 技师审核
|
||||
* @param $params
|
||||
* @return string|true
|
||||
* @author cjhao
|
||||
* @date 2024/8/23 18:47
|
||||
*/
|
||||
public function coachAudit($params)
|
||||
{
|
||||
try {
|
||||
// Db::startTrans();
|
||||
$coach = Coach::where(['id'=>$params['id']])->findOrEmpty();
|
||||
if($coach->isEmpty()){
|
||||
return '技师不存在';
|
||||
}
|
||||
if(CoachEnum::AUDIT_STATUS_WAIT != $coach->audit_status){
|
||||
return '技师的审核状态已改变,请刷新页面';
|
||||
}
|
||||
$status = CoachEnum::AUDIT_STATUS_PASS;
|
||||
if(0 == $params['audit_status']){
|
||||
$status = CoachEnum::AUDIT_STATUS_REFUSE;
|
||||
}
|
||||
$coach->audit_status = $status;
|
||||
$coach->audit_remark = $params['audit_remark'] ?? '';
|
||||
$coach->save();
|
||||
if(CoachEnum::AUDIT_STATUS_PASS == $status){
|
||||
//入驻申请成功通知-师傅
|
||||
event('Notice', [
|
||||
'scene_id' => NoticeEnum::APPLY_SUCCESS_NOTICE_STAFF,
|
||||
'params' => [
|
||||
'coach_id' => $coach['id'],
|
||||
]
|
||||
]);
|
||||
}else{
|
||||
//入驻申请失败通知-师傅
|
||||
event('Notice', [
|
||||
'scene_id' => NoticeEnum::APPLY_FAIL_NOTICE_STAFF,
|
||||
'params' => [
|
||||
'coach_id' => $coach['id'],
|
||||
]
|
||||
]);
|
||||
}
|
||||
return true;
|
||||
}catch (Exception $e){
|
||||
// Db::rollback();
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取技师详情
|
||||
* @param int $id
|
||||
* @return array
|
||||
* @author cjhao
|
||||
* @date 2024/8/28 11:28
|
||||
*/
|
||||
public function updateDetail(int $id)
|
||||
{
|
||||
|
||||
$updateCoach = (new CoachUpdate())
|
||||
->where(['id'=>$id])
|
||||
->append(['goods_lists'])
|
||||
->withoutField('create_time,update_time,delete_time')
|
||||
->findOrEmpty()
|
||||
->toArray();
|
||||
$coach = (new Coach())
|
||||
->where(['id'=>$updateCoach['coach_id'],'audit_status'=>CoachEnum::AUDIT_STATUS_PASS])
|
||||
->append(['life_photo','goods_ids'])
|
||||
->withoutField('create_time,update_time,delete_time')
|
||||
->findOrEmpty()
|
||||
->toArray();
|
||||
foreach ($updateCoach as $key => $update){
|
||||
$cancel = ['id','goods_lists','coach_id','coach_user_id'];
|
||||
if(in_array($key,$cancel)){
|
||||
continue;
|
||||
}
|
||||
$data = $coach[$key] ?? '';
|
||||
$updateCoach[$key.'_update'] = $update != $data ?: false;
|
||||
if('goods_ids' == $key && $data){
|
||||
$goodsIds = array_column($data->toArray(),'goods_id');
|
||||
sort($goodsIds);
|
||||
sort($update);
|
||||
$updateCoach[$key.'_update'] = $update != $goodsIds ?: false;
|
||||
}
|
||||
if('life_photo' == $key && $data){
|
||||
$uriLists = array_column($data->toArray(),'uri');
|
||||
foreach ($uriLists as $uriKey => $uri){
|
||||
$uriLists[$uriKey] = FileService::setFileUrl($uri);
|
||||
}
|
||||
sort($uriLists);
|
||||
sort($update);
|
||||
$updateCoach[$key.'_update'] = $uriLists != $update ?: false;
|
||||
}
|
||||
}
|
||||
return $updateCoach;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 技师资料审核
|
||||
* @param $params
|
||||
* @return string|true
|
||||
* @throws \Exception
|
||||
* @author cjhao
|
||||
* @date 2024/8/28 11:31
|
||||
*/
|
||||
public function updateAudit($params)
|
||||
{
|
||||
try {
|
||||
Db::startTrans();
|
||||
$coachUpdate = CoachUpdate::where(['id'=>$params['id']])->findOrEmpty();
|
||||
if($coachUpdate->isEmpty()){
|
||||
return '申请记录不存在';
|
||||
}
|
||||
if(CoachEnum::AUDIT_STATUS_WAIT != $coachUpdate->audit_status){
|
||||
return '申请的审核状态已改变,请刷新页面';
|
||||
}
|
||||
$status = CoachEnum::AUDIT_STATUS_PASS;
|
||||
if(0 == $params['audit_status']){
|
||||
$status = CoachEnum::AUDIT_STATUS_REFUSE;
|
||||
|
||||
}
|
||||
$coachUpdate->audit_status = $status;
|
||||
$coachUpdate->audit_remark = $params['audit_remark'] ?? '';
|
||||
$coachUpdate->save();
|
||||
if(0 == $params['audit_status']){
|
||||
Db::commit();
|
||||
return true;
|
||||
}
|
||||
$coach = Coach::where(['id'=>$coachUpdate->coach_id])->findOrEmpty();
|
||||
$coach->name = $coachUpdate->name;
|
||||
$coach->gender = $coachUpdate->gender;
|
||||
$coach->age = $coachUpdate->age;
|
||||
$coach->id_card = $coachUpdate->id_card;
|
||||
// $coach->mobile = $coachUpdate->mobile;
|
||||
$coach->education = $coachUpdate->education;
|
||||
$coach->nation = $coachUpdate->nation;
|
||||
$coach->province_id = $coachUpdate->province_id;
|
||||
$coach->city_id = $coachUpdate->city_id;
|
||||
$coach->region_id = $coachUpdate->region_id;
|
||||
$coach->latitude = $coachUpdate->latitude;
|
||||
$coach->longitude = $coachUpdate->longitude;
|
||||
$coach->address_detail = $coachUpdate->address_detail;
|
||||
$coach->coach_user_id = $coachUpdate->coach_user_id;
|
||||
$coach->skill_id = $coachUpdate->skill_id;
|
||||
$coach->id_card_front = $coachUpdate->id_card_front;
|
||||
$coach->id_card_back = $coachUpdate->id_card_back;
|
||||
$coach->portrait_shooting = $coachUpdate->portrait_shooting;
|
||||
// $coach->work_photo = $coachUpdate->work_photo;
|
||||
$coach->certification = $coachUpdate->certification;
|
||||
$coach->health_certificate = $coachUpdate->health_certificate;
|
||||
// $coach->work_status = $coachUpdate->work_status;
|
||||
// $coach->server_status = $coachUpdate->server_status;
|
||||
$coach->save();
|
||||
(new CoachLifePhoto())->where(['coach_id'=>$coach->id])->delete();
|
||||
(new CoachGoodsIndex())->where(['coach_id'=>$coach->id])->delete();
|
||||
//生活照
|
||||
$lifePhoto = $coachUpdate->life_photo;
|
||||
$lifePhotoLists = [];
|
||||
foreach ($lifePhoto as $photo){
|
||||
$lifePhotoLists[] = [
|
||||
'uri' => $photo,
|
||||
'coach_id' => $coach->id
|
||||
];
|
||||
}
|
||||
(new CoachLifePhoto())->saveAll($lifePhotoLists);
|
||||
|
||||
//关联服务
|
||||
$goodsIds = $coachUpdate->goods_ids ;
|
||||
$goodsLists = [];
|
||||
foreach ($goodsIds as $goodsId)
|
||||
{
|
||||
$goodsLists[] = [
|
||||
'goods_id' => $goodsId,
|
||||
'coach_id' => $coach->id,
|
||||
];
|
||||
}
|
||||
(new CoachGoodsIndex())->saveAll($goodsLists);
|
||||
Db::commit();
|
||||
|
||||
return true;
|
||||
}catch (Exception $e){
|
||||
Db::rollback();
|
||||
return $e->getMessage();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
94
server/app/adminapi/logic/coach/DepositPackageLogic.php
Executable file
94
server/app/adminapi/logic/coach/DepositPackageLogic.php
Executable file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop开源商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
|
||||
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | likeshop团队版权所有并拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshop.cn.team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\logic\coach;
|
||||
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\deposit\DepositPackage;
|
||||
|
||||
class DepositPackageLogic extends BaseLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 添加
|
||||
* @param $params
|
||||
* @return bool
|
||||
* @author ljj
|
||||
* @date 2022/2/8 5:03 下午
|
||||
*/
|
||||
public function add($params)
|
||||
{
|
||||
DepositPackage::create([
|
||||
'name' => $params['name'],
|
||||
'money' => $params['money'],
|
||||
'order_limit' => $params['order_limit'],
|
||||
]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 查看服务分类详情
|
||||
* @param $id
|
||||
* @return array
|
||||
* @author ljj
|
||||
* @date 2022/2/8 5:21 下午
|
||||
*/
|
||||
public function detail($id)
|
||||
{
|
||||
$result = DepositPackage::where('id',$id)->withoutField('update_time,delete_time')->findOrEmpty()->toArray();
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 编辑服务分类
|
||||
* @param $params
|
||||
* @return bool
|
||||
* @author ljj
|
||||
* @date 2022/2/8 6:25 下午
|
||||
*/
|
||||
public function edit($params)
|
||||
{
|
||||
|
||||
DepositPackage::update([
|
||||
'name' => $params['name'],
|
||||
'money' => $params['money'],
|
||||
'order_limit' => $params['order_limit'],
|
||||
],['id'=>$params['id']]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 删除服务
|
||||
* @param $id
|
||||
* @return bool
|
||||
* @author ljj
|
||||
* @date 2022/2/8 6:34 下午
|
||||
*/
|
||||
public function del($id)
|
||||
{
|
||||
return DepositPackage::destroy($id);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
104
server/app/adminapi/logic/coach/SKillLogic.php
Executable file
104
server/app/adminapi/logic/coach/SKillLogic.php
Executable file
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop开源商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
|
||||
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | likeshop团队版权所有并拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshop.cn.team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\logic\coach;
|
||||
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\goods\GoodsCategory;
|
||||
use app\common\model\skill\Skill;
|
||||
|
||||
class SKillLogic extends BaseLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 添加
|
||||
* @param $params
|
||||
* @return bool
|
||||
* @author ljj
|
||||
* @date 2022/2/8 5:03 下午
|
||||
*/
|
||||
public function add($params)
|
||||
{
|
||||
Skill::create([
|
||||
'name' => $params['name'],
|
||||
'is_show' => $params['is_show'],
|
||||
]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 查看服务分类详情
|
||||
* @param $id
|
||||
* @return array
|
||||
* @author ljj
|
||||
* @date 2022/2/8 5:21 下午
|
||||
*/
|
||||
public function detail($id)
|
||||
{
|
||||
$result = Skill::where('id',$id)->withoutField('update_time,delete_time')->findOrEmpty()->toArray();
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 编辑服务分类
|
||||
* @param $params
|
||||
* @return bool
|
||||
* @author ljj
|
||||
* @date 2022/2/8 6:25 下午
|
||||
*/
|
||||
public function edit($params)
|
||||
{
|
||||
|
||||
Skill::update([
|
||||
'name' => $params['name'],
|
||||
'is_show' => $params['is_show'],
|
||||
],['id'=>$params['id']]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 删除服务
|
||||
* @param $id
|
||||
* @return bool
|
||||
* @author ljj
|
||||
* @date 2022/2/8 6:34 下午
|
||||
*/
|
||||
public function del($id)
|
||||
{
|
||||
return Skill::destroy($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 修改状态
|
||||
* @param $params
|
||||
* @return bool
|
||||
* @author ljj
|
||||
* @date 2022/2/10 10:57 上午
|
||||
*/
|
||||
public function status($params)
|
||||
{
|
||||
Skill::update(['is_show'=>$params['is_show']],['id'=>$params['id']]);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user