Quellcode durchsuchen

广誉源商户端-登录-我的技能

jinwenhai vor 6 Tagen
Ursprung
Commit
09753d0e56

+ 321 - 53
nightFragrance-admin/src/main/java/com/ylx/web/controller/massage/MaTechnicianController.java

@@ -1,27 +1,42 @@
 package com.ylx.web.controller.massage;
 
+import java.util.LinkedHashMap;
 import java.util.List;
+import java.util.Random;
+import java.util.concurrent.TimeUnit;
+import java.util.regex.Pattern;
+import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.ylx.common.core.domain.R;
-import com.ylx.common.core.domain.model.LoginUser;
-import com.ylx.massage.domain.dto.MaTechnicianMerchantAddDTO;
-import com.ylx.massage.domain.dto.MaTechnicianMerchantQueryDTO;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.ylx.common.core.domain.model.aliyun.SMSVerificationCode;
+import com.ylx.common.core.domain.model.aliyun.SendSmsComponents;
+import com.ylx.common.core.domain.model.aliyun.SendSmsEnum;
+import com.ylx.common.utils.StringUtils;
+import com.ylx.massage.domain.MaProject;
+import com.ylx.massage.domain.dto.MaProjectSaveDto;
+import com.ylx.massage.domain.dto.MaProjectUpdateDto;
+import com.ylx.massage.domain.vo.MaProjectGetVo;
 import com.ylx.massage.domain.vo.MaTechnicianAppAddVo;
-import com.ylx.massage.domain.vo.MaTechnicianMerchantListVO;
+import com.ylx.massage.domain.vo.Result;
+import com.ylx.massage.domain.vo.ThirdPartyLoginsVo;
+import com.ylx.massage.service.IMaProjectService;
+import com.ylx.project.domain.Project;
+import com.ylx.servicecategory.domain.ServiceCategory;
+import com.ylx.servicecategory.service.ServiceCategoryService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang3.ObjectUtils;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.data.redis.core.StringRedisTemplate;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.*;
 import com.ylx.common.annotation.Log;
 import com.ylx.common.core.controller.BaseController;
 import com.ylx.common.core.domain.AjaxResult;
@@ -43,6 +58,194 @@ import com.ylx.common.core.page.TableDataInfo;
 public class MaTechnicianController extends BaseController {
     @Autowired
     private IMaTechnicianService maTechnicianService;
+    @Autowired
+    private StringRedisTemplate redisTemplate;
+
+    @Autowired
+    private SendSmsComponents sendSms;
+    @Autowired
+    private ServiceCategoryService serviceCategoryService;
+    @Autowired
+    private IMaProjectService maProjectService;
+
+    public static final String PHONE_THREEUSERPARTCLIENT_CODE_KEY = "sys:threeUserPartClient:phone:";
+
+    @GetMapping("/sendMsg")
+    @ApiOperation(value = "短信发送", notes = "短信发送")
+    public Result sendMsg(@RequestParam String phone, HttpServletRequest request) {
+        if (org.apache.commons.lang3.StringUtils.isEmpty(phone)) {
+            return Result.error("手机号不能为空");
+        }
+        Random rand = new Random();
+        // randNumber 将被赋值为一个 MIN 和 MAX 范围内的随机数
+        int randNumber = rand.nextInt(9999 - 1000 + 1) + 1000;
+        // 保存验证码到redis
+        redisTemplate.opsForValue()
+                .set("userH5:order:phone:" + phone, String.valueOf(randNumber), 5L
+                        , TimeUnit.MINUTES);
+        try {
+            SMSVerificationCode smsVerificationCode = new SMSVerificationCode(String.valueOf(randNumber));
+            String jsonString = JSON.toJSONString(smsVerificationCode);
+            sendSms.sendSms(phone, SendSmsEnum.SMS_220650024, jsonString);
+            return Result.ok("发送成功");
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return Result.ok("发送失败");
+    }
+
+    /**
+     * 商户登录接口
+     *
+     * @param thirdPartyLoginsVo
+     * @return
+     */
+    @ApiOperation(value = "商户登录", notes = "商户登录")
+    @PostMapping(value = "/clientLogin")
+    @Transactional
+    public Result<JSONObject> login(@RequestBody ThirdPartyLoginsVo thirdPartyLoginsVo) throws Exception {
+        // 获取登录用户信息
+        Result<JSONObject> result = new Result<>();
+
+        // 校验手机号是否为空
+        if (StringUtils.isEmpty(thirdPartyLoginsVo.getPhone())) {
+            return result.error500("请输入手机号");
+        }
+
+        // 校验用户是否存在且有效
+        LambdaQueryWrapper<MaTechnician> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(MaTechnician::getTePhone, thirdPartyLoginsVo.getPhone());
+        MaTechnician maTechnician = maTechnicianService.getBaseMapper().selectOne(queryWrapper);
+        // 校验用户是否有效
+        if (ObjectUtils.isEmpty(maTechnician)) {
+            return result.error500("商户不存在,请先注册");
+
+        }
+
+        if (thirdPartyLoginsVo.getCodeSwitch()) {
+            // 短信验证
+            String msg = redisTemplate.opsForValue().get(PHONE_THREEUSERPARTCLIENT_CODE_KEY + thirdPartyLoginsVo.getPhone());
+            if (StringUtils.isEmpty(msg)) {
+                return Result.error("验证码已失效");
+            }
+
+            if (!thirdPartyLoginsVo.getPhoneMsg().equals(msg)) {
+                return Result.error("短信验证码不正确");
+            }
+        } else {
+            if (!thirdPartyLoginsVo.getPassWord().equals(maTechnician.getTePassword())) {
+                return Result.error("密码错误");
+            }
+
+        }
+
+        // 登录成功删除验证码
+        redisTemplate.delete(PHONE_THREEUSERPARTCLIENT_CODE_KEY + thirdPartyLoginsVo.getPhone());
+        result.success("登录成功");
+        return result;
+    }
+
+    /**
+     * 商户忘记密码接口
+     */
+    @PostMapping("/resetPassword")
+    public Result<?> resetPassword(@RequestBody ThirdPartyLoginsVo thirdPartyLoginsVo) {
+        // 核心正则表达式:
+        // ^ 表示开头,$ 表示结尾
+        // [a-zA-Z0-9] 表示只能是字母或数字
+        // {8,20} 表示长度必须在8到20之间
+        String regex = "^[a-zA-Z0-9]{8,20}$";
+        boolean isMatch = Pattern.matches(regex, thirdPartyLoginsVo.getPhoneMsg());
+        if (!isMatch) {
+            // 根据需求返回指定的异常提示
+            return Result.error("请输入8-20位数字/字母组合");
+        }
+        // 短信验证
+        String msg = redisTemplate.opsForValue().get(PHONE_THREEUSERPARTCLIENT_CODE_KEY + thirdPartyLoginsVo.getPhone());
+        if (StringUtils.isEmpty(msg)) {
+            return Result.error("验证码已失效");
+        }
+        if (!thirdPartyLoginsVo.getPhoneMsg().equals(msg)) {
+            return Result.error("短信验证码不正确");
+        }
+        // 重置密码逻辑
+        LambdaUpdateWrapper<MaTechnician> updateWrapper = new LambdaUpdateWrapper<>();
+        updateWrapper.eq(MaTechnician::getTePhone, thirdPartyLoginsVo.getPhone());
+        updateWrapper.set(MaTechnician::getTePassword, thirdPartyLoginsVo.getPassWord());
+        maTechnicianService.update(updateWrapper);
+        redisTemplate.delete(PHONE_THREEUSERPARTCLIENT_CODE_KEY + thirdPartyLoginsVo.getPhone());
+        return Result.ok("重置密码成功");
+    }
+
+    /**
+     * 商户入驻申请接口
+     */
+    @PostMapping("/apply")
+    public Result<?> apply(@RequestBody MaTechnicianAppAddVo req) {
+        // 1. 基础参数校验
+        if (StringUtils.isAnyBlank(req.getTeName(), req.getTePhone(), req.getTeAddress(), req.getTeAvatar(), req.getLifePhotos(), req.getTeBrief(), req.getAvatar(), req.getIdCard())) {
+            return Result.error("必填项不能为空");
+        }
+        // 2. 调用业务层处理入驻申请
+        maTechnicianService.apply(req);
+        return Result.ok("提交成功,进入审核流程");
+    }
+
+    /**
+     * 查询商户信息接口
+     */
+    @GetMapping("/getTechnician")
+    public Result<?> getTechnician(@RequestParam String phone) {
+        LambdaQueryWrapper<MaTechnician> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(MaTechnician::getTePhone, phone);
+        MaTechnician maTechnician = maTechnicianService.getBaseMapper().selectOne(queryWrapper);
+        return Result.ok(maTechnician);
+    }
+
+    /**
+     * 修改和上传商户信息接口
+     */
+    @PostMapping("/updateTechnician")
+    public Result<?> updateTechnician(@RequestBody MaTechnicianAppAddVo req) {
+        if (req.getAuditStatus() == 0 || req.getAuditStatus() == 3) {
+            //修改基本信息
+            updateMaTechnician(req);
+        } else if (req.getAuditStatus() == 1 || req.getAuditStatus() == 2) {
+            //上传商户资料信息
+            extractedUpdate(req);
+        }
+        return Result.ok("修改成功");
+    }
+
+    private void extractedUpdate(MaTechnicianAppAddVo req) {
+        LambdaUpdateWrapper<MaTechnician> updateWrapper = new LambdaUpdateWrapper<>();
+        updateWrapper.eq(MaTechnician::getId, req.getId());
+        updateWrapper.set(MaTechnician::getTeAvatar, req.getTeAvatar());
+        updateWrapper.set(MaTechnician::getTeNickName, req.getTeNickName());
+        updateWrapper.set(MaTechnician::getTeBrief, req.getTeBrief());
+        updateWrapper.set(MaTechnician::getLifePhotos, req.getLifePhotos());
+        updateWrapper.set(MaTechnician::getIdCard, req.getIdCard());
+        updateWrapper.set(MaTechnician::getHealthCertificate, req.getHealthCertificate());
+        updateWrapper.set(MaTechnician::getQualificationCertificate, req.getQualificationCertificate());
+        updateWrapper.set(MaTechnician::getNoCrimeRecord, req.getNoCrimeRecord());
+        updateWrapper.set(MaTechnician::getPromoVideo, req.getPromoVideo());
+        updateWrapper.set(MaTechnician::getCommitmentAudio, req.getCommitmentAudio());
+        updateWrapper.set(MaTechnician::getCommitmentPdf, req.getCommitmentPdf());
+        updateWrapper.set(MaTechnician::getCommitmentVideo, req.getCommitmentVideo());
+        maTechnicianService.update(updateWrapper);
+    }
+
+    private void updateMaTechnician(MaTechnicianAppAddVo req) {
+        LambdaUpdateWrapper<MaTechnician> updateWrapper = new LambdaUpdateWrapper<>();
+        updateWrapper.eq(MaTechnician::getId, req.getId());
+        updateWrapper.set(MaTechnician::getTePhone, req.getTePhone());
+        updateWrapper.set(MaTechnician::getTeName, req.getTeName());
+        updateWrapper.set(MaTechnician::getOpenService, req.getOpenService());
+        updateWrapper.set(MaTechnician::getTeAddress, req.getTeAddress());
+        updateWrapper.set(MaTechnician::getTeAge, req.getTeAge());
+        updateWrapper.set(MaTechnician::getAvatar, req.getAvatar());
+        maTechnicianService.update(updateWrapper);
+    }
 
     /**
      * 查询技师列表
@@ -87,45 +290,6 @@ public class MaTechnicianController extends BaseController {
         return toAjax(maTechnicianService.insertMaTechnician(maTechnicianAppAddVo));
     }
 
-    /**
-     * 后台新增商户
-     *
-     * @param dto 商户新增DTO
-     * @return AjaxResult 结果
-     */
-    @ApiOperation("后台新增商户")
-    @PreAuthorize("@ss.hasPermi('technician:technician:add')")
-    @Log(title = "商户", businessType = BusinessType.INSERT)
-    @PostMapping("/merchant")
-    public AjaxResult addMerchant(@RequestBody MaTechnicianMerchantAddDTO dto) {
-        try {
-            LoginUser loginUser = getLoginUser();
-            return toAjax(maTechnicianService.insertMerchant(dto, loginUser));
-        } catch (Exception e) {
-            e.printStackTrace();
-            throw new RuntimeException(e);
-        }
-    }
-
-    /**
-     * 查询商户列表
-     *
-     * @param page  分页参数
-     * @param dto 商户查询DTO
-     * @return Page 商户分页列表
-     */
-    @ApiOperation("后台查询商户列表")
-    @PreAuthorize("@ss.hasPermi('technician:technician:list')")
-    @GetMapping("/merchant/list")
-    public R<Page<MaTechnicianMerchantListVO>> merchantList(Page<MaTechnicianMerchantListVO> page, MaTechnicianMerchantQueryDTO dto) {
-        try {
-            return R.ok(maTechnicianService.selectMerchantList(page, dto));
-        } catch (Exception e) {
-            e.printStackTrace();
-            throw new RuntimeException(e);
-        }
-    }
-
     /**
      * 修改技师
      */
@@ -145,4 +309,108 @@ public class MaTechnicianController extends BaseController {
     public AjaxResult remove(@PathVariable Long[] ids) {
         return toAjax(maTechnicianService.deleteMaTechnicianByIds(ids));
     }
+
+    /**
+     * 1. 获取服务类目列表 (对应图1、图3)
+     */
+    @GetMapping("/getServiceCategoryList")
+    public AjaxResult getServiceCategoryList() {
+        List<ServiceCategory> list = serviceCategoryService.listH5ServiceCategory();
+        return AjaxResult.success(list);
+    }
+
+    /**
+     * 1. 获取技能列表 (对应图1、图3)
+     * 支持 Tab 切换:all(全部), active(已开通), applying(申请中), rejected(驳回)
+     */
+    @PostMapping("/getSkillList")
+    public TableDataInfo getSkillList(@RequestBody MaProjectGetVo req) {
+        startPage();
+        List<MaProject> list = maTechnicianService.selectMaTechnicianListBy(req.getUserId(), req.getAuditStatus());
+        if (ObjectUtils.isEmpty(list)) {
+            List<Project> projectslist = maTechnicianService.selectTechnicianListBy(req.getTypeId());
+            return getDataTable(projectslist);
+        } else {
+            return getDataTable(list);
+        }
+    }
+
+    /**
+     * 查询未开通的服务项目列表
+     *
+     * @param req
+     * @return
+     */
+    @PostMapping("/getNotApplyList")
+    public Result<?> getNotApplyList(@RequestBody MaProjectGetVo req) {
+
+        return Result.ok(maTechnicianService.getNotApplyList(req.getUserId(), req.getTypeId()));
+
+    }
+
+    /**
+     * 申请开通新服务
+     */
+    @PostMapping("/applyForService")
+    public AjaxResult applyForService(@RequestBody MaProjectSaveDto dto) {
+
+        return toAjax(maTechnicianService.applyForService(dto));
+    }
+
+    /**
+     * 重新申请开通新服务
+     *
+     * @param req
+     * @return
+     */
+    @PostMapping("/updateApply")
+    public Result<?> updateApply(@RequestBody MaProjectUpdateDto req) {
+        if (StringUtils.isNotEmpty(req.getProjectId()) && StringUtils.isNotEmpty(req.getApplyReason())) {
+            LambdaUpdateWrapper<MaProject> updateWrapper = new LambdaUpdateWrapper<>();
+            updateWrapper.eq(MaProject::getId, req.getProjectId());
+            updateWrapper.set(MaProject::getApplyReason, req.getApplyReason());
+            updateWrapper.set(MaProject::getAuditStatus, 0);
+            maProjectService.update(updateWrapper);
+        }
+        return Result.ok("重新申请成功,提交到审核阶段");
+
+    }
+
+    /**
+     * 申请下架,删除服务项目,编辑售价价格
+     *
+     * @param req
+     * @return
+     */
+    @PostMapping("/updateMaProject")
+    public Result<?> updateMaProject(@RequestBody MaProjectUpdateDto req) {
+        String message = "";
+        if (StringUtils.isNotEmpty(req.getProjectId())) {
+            if (req.getIsDelete()) {
+                LambdaUpdateWrapper<MaProject> updateWrapper = new LambdaUpdateWrapper<>();
+                updateWrapper.eq(MaProject::getId, req.getProjectId());
+                updateWrapper.set(MaProject::getIsDelete, 1);
+                maProjectService.update(updateWrapper);
+                message = "删除成功";
+            }
+            if (req.getIsPass()) {
+                LambdaUpdateWrapper<MaProject> updateWrapper = new LambdaUpdateWrapper<>();
+                updateWrapper.eq(MaProject::getId, req.getProjectId());
+                updateWrapper.set(MaProject::getProjectIsEnable, 1);
+                maProjectService.update(updateWrapper);
+                message = "申请下架成功";
+            }
+            if (req.getProjectCurrentPrice() != null) {
+
+                LambdaUpdateWrapper<MaProject> updateWrapper = new LambdaUpdateWrapper<>();
+                updateWrapper.eq(MaProject::getId, req.getProjectId());
+                updateWrapper.set(MaProject::getProjectCurrentPrice, req.getProjectCurrentPrice());
+                maProjectService.update(updateWrapper);
+                message = "修改价格完成";
+
+            }
+        }
+        return Result.ok(message);
+    }
+
 }

+ 77 - 2
nightFragrance-admin/src/main/java/com/ylx/web/controller/massage/WeSqController.java

@@ -1,5 +1,9 @@
 package com.ylx.web.controller.massage;
 
+import cn.binarywang.wx.miniapp.api.WxMaService;
+import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
+import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
+import cn.binarywang.wx.miniapp.bean.WxMaUserInfo;
 import cn.hutool.json.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.ylx.common.annotation.Log;
@@ -14,8 +18,10 @@ import com.ylx.framework.manager.AsyncManager;
 import com.ylx.framework.manager.factory.AsyncFactory;
 import com.ylx.framework.web.service.WxTokenService;
 import com.ylx.massage.domain.CouponReceive;
+import com.ylx.massage.domain.MaTechnician;
 import com.ylx.massage.domain.TWxUser;
 import com.ylx.massage.service.CouponReceiveService;
+import com.ylx.massage.service.IMaTechnicianService;
 import com.ylx.massage.service.TWxUserService;
 import com.ylx.massage.utils.WeChatUtil;
 import io.swagger.annotations.Api;
@@ -63,8 +69,10 @@ public class WeSqController extends BaseController {
 
     @Autowired
     public RedisTemplate redisTemplate;
-
-
+    @Autowired
+    private IMaTechnicianService maTechnicianService;
+    @Autowired
+    private WxMaService wxMaService;
     /**
      * 通过微信code获取token和userInfo
      *
@@ -132,4 +140,71 @@ public class WeSqController extends BaseController {
         }
     }
 
+    /**
+     * 通过微信code获取token和userInfo
+     *
+     * @param code 微信授权码
+     * @return R<WxLoginUser> 访问令牌
+     */
+    @GetMapping("/getTechnicianToken")
+    @ResponseBody
+    //@Log(title = "公众号网页登录", businessType = BusinessType.OTHER)
+    public R<WxLoginUser> getTechnicianToken(@RequestParam String code) {
+        // 发送get请求获取 AccessToken
+        try {
+            Map<?, ?> result = weChatUtil.getAccessToken(code);
+           log.info("result的值:{}", result);
+            String accessToken = result.get(ACCESS_TOKEN).toString();
+            log.info("accessToken的值:{}", accessToken);
+            String refreshToken = result.get(REFRESH_TOKEN).toString();
+            String openid = result.get(OPEN_ID).toString();
+//
+//            // 如果用户是第一次进行微信公众号授权
+//            // 进行这一步时用户应点击了同意授权按钮
+            String userInfoJsom = weChatUtil.getUserInfo(accessToken, openid);
+//            // 解析JSON数据
+           JSONObject jsonObject = new JSONObject(userInfoJsom);
+            //log.info("公众号网页登录:{}", jsonObject);
+            String nickName = jsonObject.get("nickname").toString();
+            String avatarUrl = jsonObject.get("headimgurl").toString();
+            String phoneNumber = jsonObject.get("phoneNumber").toString();
+
+            // 将用户信息保存到数据库中
+            LambdaQueryWrapper<MaTechnician> objectLambdaQueryWrapper = new LambdaQueryWrapper<>();
+            objectLambdaQueryWrapper.eq(MaTechnician::getCOpenid, openid);
+            MaTechnician user = maTechnicianService.getOne(objectLambdaQueryWrapper);
+            if (user == null || StringUtils.isEmpty(user.getTeNickName())) {
+                if (user == null) {
+                    user = new MaTechnician();
+                    user.setCOpenid(openid);
+                    user.setTeNickName(nickName);
+                    user.setTeAvatar(avatarUrl);
+                    user.setTePhone(phoneNumber);
+                    user.setOpenService(-1);
+                    maTechnicianService.save(user);
+                    //异步 添加新人优惠卷
+                    //                threadPoolTaskExecutor.submit(() -> couponReceiveService.submit(new CouponReceive().setOpenid(finalUser.getcOpenid()).setCouponId("1")));
+                }
+            }
+            WxLoginUser wxUser = new WxLoginUser();
+            BeanUtils.copyProperties(user, wxUser);
+            // 生成并返回令牌
+            String token = wxTokenService.createToken(wxUser);
+            log.info("token的值:{}", token);
+            if (token == null || token.isEmpty()) {
+                return R.fail("生成令牌失败");
+            }
+            //给我把token的值保存到redis中
+            redisTemplate.opsForValue().set(wxUser.getCOpenid(), token, 180, TimeUnit.MINUTES);
+            wxUser.setToken(token);
+            // 返回用户信息
+            // 记录登录信息
+            AsyncManager.me().execute(AsyncFactory.recordLogininfor(wxUser.getCOpenid(), Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")));
+            return R.ok(wxUser);
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw new RuntimeException(e);
+        }
+    }
+
 }

+ 3 - 0
nightFragrance-admin/src/main/java/com/ylx/web/controller/massage/WxController.java

@@ -47,6 +47,7 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.MediaType;
 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
+import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
@@ -265,11 +266,13 @@ public class WxController extends BaseController {
             objectLambdaQueryWrapper.eq(TWxUser::getcOpenid, openid);
             TWxUser user = wxUserService.getOne(objectLambdaQueryWrapper);
             if (user == null) {
+                BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
                 user = new TWxUser();
                 user.setcOpenid(openid);
                 user.setcNickName(nickName);
                 user.setcIcon(avatarUrl);
                 user.setcPhone(phoneNumber);
+                user.setCPassword(encoder.encode("123456")) ;
                 wxUserService.save(user);
                 //异步 添加新人优惠卷
                 TWxUser finalUser = user;

+ 26 - 0
nightFragrance-massage/src/main/java/com/ylx/massage/domain/dto/MaProjectSaveDto.java

@@ -0,0 +1,26 @@
+package com.ylx.massage.domain.dto;
+
+import com.ylx.point.enums.TaskLimitTimesEnum;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class MaProjectSaveDto {
+    /**
+     * 商户id
+     */
+    private String userId;
+    /**
+     * 商户手机号
+     */
+    private String merchantPhone;
+    /**
+     * 项目id列表
+     */
+    private List<String> projectIdList;
+    /**
+     * 申请理由
+     */
+    private String applyReason;
+}

+ 31 - 0
nightFragrance-massage/src/main/java/com/ylx/massage/domain/dto/MaProjectUpdateDto.java

@@ -0,0 +1,31 @@
+package com.ylx.massage.domain.dto;
+
+import com.ylx.common.annotation.Excel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+@Data
+public class MaProjectUpdateDto {
+
+    /**
+     * 项目id列表
+     */
+    private String projectId;
+    /**
+     * 申请理由
+     */
+    private String applyReason;
+    /**
+     * 是否下架
+     */
+    private Boolean isPass;
+    /**
+     * 是否删除
+     */
+    private Boolean isDelete;
+    /** 我的售价 */
+    private BigDecimal projectCurrentPrice;
+}

+ 66 - 6
nightFragrance-massage/src/main/java/com/ylx/massage/domain/vo/MaTechnicianAppAddVo.java

@@ -1,10 +1,14 @@
 package com.ylx.massage.domain.vo;
 
+import com.baomidou.mybatisplus.annotation.TableName;
 import com.ylx.common.annotation.Excel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
+import lombok.experimental.Accessors;
 
+import java.math.BigInteger;
 import java.util.ArrayList;
+import java.util.Date;
 
 /**
  * 技师对象 ma_technician
@@ -19,31 +23,39 @@ public class MaTechnicianAppAddVo
 
     /** id */
     @ApiModelProperty("id")
-    private Long id;
+    private String id;
 
     /** 姓名 */
     @ApiModelProperty("姓名")
     private String teName;
+    /** 昵称 */
+    @Excel(name = "昵称")
+    private String teNickName;
+    /** 密码 */
+    @Excel(name = "密码")
+    private String tePassword;
 
     /** 性别(0女1男) */
     @Excel(name = "性别(0女1男)")
     @ApiModelProperty("性别(0女1男)")
     private Long teSex;
-
+    /** 开通服务:1-上门按摩 2-同城玩乐 */
+    @Excel(name = "开通服务:1-上门按摩 2-同城玩乐")
+    private BigInteger openService;
     /** 电话 */
     @Excel(name = "电话")
     @ApiModelProperty("电话")
     private String tePhone;
 
-    /** 地址 */
-    @Excel(name = "地址")
-    @ApiModelProperty("地址")
+    /** 合作意向城市 */
+    @Excel(name = "合作意向城市")
+    @ApiModelProperty("合作意向城市")
     private String teAddress;
 
     /** 年龄 */
     @Excel(name = "年龄")
     @ApiModelProperty("年龄")
-    private Long teAge;
+    private BigInteger teAge;
 
     /** 头像 */
     @Excel(name = "头像")
@@ -60,6 +72,54 @@ public class MaTechnicianAppAddVo
     @ApiModelProperty("简介")
     private String teBrief;
 
+    /** 形象照 */
+    @Excel(name = "形象照")
+    @ApiModelProperty("形象照")
+    private String avatar;
+
+    /** 身份证 */
+    @Excel(name = "身份证")
+    @ApiModelProperty("身份证")
+    private String idCard;
+    /** 宣传视频 */
+    @Excel(name = "宣传视频")
+    @ApiModelProperty("宣传视频")
+    private String  promoVideo;
+    /** 健康证 */
+    @Excel(name = "健康证")
+    @ApiModelProperty("健康证")
+    private String healthCertificate;
+
+    /** 从业资格证 */
+    @Excel(name = "从业资格证")
+    @ApiModelProperty("从业资格证")
+    private String qualificationCertificate;
+
+    /** 无犯罪证明 */
+    @Excel(name = "无犯罪证明")
+    @ApiModelProperty("无犯罪证明")
+    private String noCrimeRecord;
+
+    /** 承诺书 */
+    @Excel(name = "承诺书")
+    @ApiModelProperty("承诺书")
+    private String commitmentPdf;
+    /** 承诺录音 */
+    @Excel(name = "承诺录音")
+    @ApiModelProperty("承诺录音")
+    private String commitmentAudio;
+    /** 承诺录像 */
+    @Excel(name = "承诺录像")
+    @ApiModelProperty("承诺录像")
+    private String commitmentVideo;
+    /** 审核状态:0-待审核,1-待审核,2-审核通过,3-审核驳回*/
+    @Excel(name = "审核状态:0-待入驻,1-待审核,2-审核通过,3-审核驳回")
+    @ApiModelProperty("审核状态:0-待入驻,1-待审核,2-审核通过,3-审核驳回")
+    private int auditStatus;
+    /** 审批时间 */
+    @Excel(name = "审批时间")
+    @ApiModelProperty("审批时间")
+    private Date approveTime;
     @ApiModelProperty("项目id集合")
     private ArrayList<Long> projectIds;
 

+ 5 - 20
nightFragrance-massage/src/main/java/com/ylx/massage/mapper/MaTechnicianMapper.java

@@ -3,13 +3,8 @@ package com.ylx.massage.mapper;
 import java.util.List;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ylx.massage.domain.MaTechnician;
-import com.ylx.massage.domain.dto.MaTechnicianMerchantQueryDTO;
-import com.ylx.massage.domain.dto.MassageMerchantRecommendDto;
-import com.ylx.massage.domain.vo.MaTechnicianMerchantListVO;
-import com.ylx.massage.domain.vo.MerchantVo;
-import org.apache.ibatis.annotations.Param;
+import org.mapstruct.Mapper;
 
 /**
  * 技师Mapper接口
@@ -17,7 +12,9 @@ import org.apache.ibatis.annotations.Param;
  * @author ylx
  * @date 2024-03-22
  */
-public interface MaTechnicianMapper extends BaseMapper<MaTechnician> {
+@Mapper
+public interface MaTechnicianMapper extends BaseMapper<MaTechnician>
+{
     /**
      * 查询技师
      *
@@ -32,7 +29,7 @@ public interface MaTechnicianMapper extends BaseMapper<MaTechnician> {
      * @param maTechnician 技师
      * @return 技师集合
      */
-    public List<MaTechnician> selectMaTechnicianList(MaTechnician maTechnician);
+     List<MaTechnician> selectMaTechnicianList(MaTechnician maTechnician);
 
     /**
      * 新增技师
@@ -65,16 +62,4 @@ public interface MaTechnicianMapper extends BaseMapper<MaTechnician> {
      * @return 结果
      */
     public int deleteMaTechnicianByIds(Long[] ids);
-
-    /**
-     * 后台查询商户列表
-     *
-     * @param page 分页参数
-     * @param dto 查询条件
-     * @return 商户分页列表
-     */
-    Page<MaTechnicianMerchantListVO> selectMerchantList(Page<MaTechnicianMerchantListVO> page,
-                                                        @Param("dto") MaTechnicianMerchantQueryDTO dto);
-
-    List<MerchantVo> getMerchantRecommend(@Param("dto") MassageMerchantRecommendDto dto);
 }

+ 167 - 220
nightFragrance-massage/src/main/java/com/ylx/massage/service/impl/MaTechnicianServiceImpl.java

@@ -1,29 +1,19 @@
 package com.ylx.massage.service.impl;
 
-import java.util.ArrayList;
-import java.util.LinkedHashSet;
+import java.util.Date;
 import java.util.List;
-import java.util.Set;
+import java.util.Objects;
+import java.util.stream.Collectors;
 
-import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.ylx.common.core.domain.model.LoginUser;
-import com.ylx.common.exception.ServiceException;
-import com.ylx.common.utils.DateUtils;
-import com.ylx.common.utils.StringUtils;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ylx.massage.domain.MaProject;
-import com.ylx.massage.domain.MaTeProject;
-import com.ylx.massage.domain.dto.MaTechnicianMerchantAddDTO;
-import com.ylx.massage.domain.dto.MaTechnicianMerchantQueryDTO;
-import com.ylx.massage.domain.dto.MassageMerchantRecommendDto;
+import com.ylx.massage.domain.dto.MaProjectSaveDto;
 import com.ylx.massage.domain.vo.MaTechnicianAppAddVo;
-import com.ylx.massage.domain.vo.MaTechnicianMerchantListVO;
-import com.ylx.massage.domain.vo.MerchantVo;
 import com.ylx.massage.mapper.MaProjectMapper;
-import com.ylx.massage.mapper.MaTeProjectMapper;
 import com.ylx.project.domain.Project;
 import com.ylx.project.mapper.ProjectMapper;
+import lombok.Data;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -39,27 +29,81 @@ import org.springframework.transaction.annotation.Transactional;
  * @date 2024-03-22
  */
 @Service
-public class MaTechnicianServiceImpl implements IMaTechnicianService
-{
-    private static final int SERVICE_STATE_AVAILABLE = 1;
-    private static final int POST_STATE_OFFLINE = 0;
-    private static final int ENABLED = 1;
-    private static final int DEFAULT_AGE = 18;
-    private static final int AUDIT_APPROVED = 2;
-    private static final int NS_STATUS_NOT_ON_DUTY = -1;
-    private static final int DEFAULT_STAT_VALUE = 0;
-    private static final long NOT_DELETED = 0L;
-    private static final String MERCHANT_STATUS_NORMAL = "0";
-
+public class MaTechnicianServiceImpl extends ServiceImpl<MaTechnicianMapper, MaTechnician> implements IMaTechnicianService {
     @Autowired
     private MaTechnicianMapper maTechnicianMapper;
-
     @Autowired
-    private MaTeProjectMapper maTeProjectMapper;
-
+    private MaProjectMapper maProjectMapper;
     @Autowired
     private ProjectMapper projectMapper;
 
+    /**
+     * 商户入驻申请注册
+     *
+     * @param req 申请参数
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void apply(MaTechnicianAppAddVo req) {
+        String phone = req.getTePhone();
+        //商户入住前置条件校验
+        getMaTechnician(req, phone);
+        MaTechnician maTechnician = new MaTechnician();
+        BeanUtils.copyProperties(req, maTechnician);
+        //技师类型默认为真实商户
+        maTechnician.setTechType(0);
+        maTechnicianMapper.insert(maTechnician);
+
+    }
+
+    /**
+     * 商户入住前置条件校验
+     *
+     * @param req
+     * @param phone
+     */
+    private void getMaTechnician(MaTechnicianAppAddVo req, String phone) {
+        // 1. 判断当前用户是否已入驻
+        MaTechnician userProfile = getMaTechnician(req);
+        if (userProfile != null) {
+            throw new RuntimeException("当前用户已入驻,请勿重复提交");
+        }
+
+        // 2. 判断手机号是否已存在
+        LambdaQueryWrapper<MaTechnician> queryPhoneWrapper = new LambdaQueryWrapper<>();
+        queryPhoneWrapper.eq(MaTechnician::getTePhone, phone);
+        queryPhoneWrapper.eq(MaTechnician::getIsDelete, 0);
+        MaTechnician maTechnicianPhone = maTechnicianMapper.selectOne(queryPhoneWrapper);
+        if (maTechnicianPhone != null) {
+            throw new RuntimeException("手机号已存在,请更换手机号");
+        }
+        //3、判断手机号是否已绑定其他用户
+        LambdaQueryWrapper<MaTechnician> queryTePhoneWrapper = new LambdaQueryWrapper<>();
+        queryTePhoneWrapper.eq(MaTechnician::getTePhone, phone);
+        queryTePhoneWrapper.eq(MaTechnician::getIsDelete, 0);
+        queryTePhoneWrapper.eq(MaTechnician::getAuditStatus, 2);
+        MaTechnician maTechnicianTePhone = maTechnicianMapper.selectOne(queryTePhoneWrapper);
+        if (maTechnicianPhone != null) {
+            throw new RuntimeException("手机号已被其他用户绑定,请更换手机号");
+        }
+
+    }
+
+    /**
+     * 判断当前用户是否已入驻
+     *
+     * @return
+     */
+    private MaTechnician getMaTechnician(MaTechnicianAppAddVo req) {
+        LambdaQueryWrapper<MaTechnician> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(MaTechnician::getTePhone, req.getTePhone());
+        queryWrapper.eq(MaTechnician::getIsDelete, 0);
+        queryWrapper.eq(MaTechnician::getAuditStatus, 2);
+        queryWrapper.eq(MaTechnician::getOpenService, req.getOpenService());
+        MaTechnician userProfile = maTechnicianMapper.selectOne(queryWrapper);
+        return userProfile;
+    }
+
     /**
      * 查询技师
      *
@@ -67,8 +111,7 @@ public class MaTechnicianServiceImpl implements IMaTechnicianService
      * @return 技师
      */
     @Override
-    public MaTechnician selectMaTechnicianById(Long id)
-    {
+    public MaTechnician selectMaTechnicianById(Long id) {
         return maTechnicianMapper.selectMaTechnicianById(id);
     }
 
@@ -79,8 +122,7 @@ public class MaTechnicianServiceImpl implements IMaTechnicianService
      * @return 技师
      */
     @Override
-    public List<MaTechnician> selectMaTechnicianList(MaTechnician maTechnician)
-    {
+    public List<MaTechnician> selectMaTechnicianList(MaTechnician maTechnician) {
         return maTechnicianMapper.selectMaTechnicianList(maTechnician);
     }
 
@@ -92,100 +134,39 @@ public class MaTechnicianServiceImpl implements IMaTechnicianService
      */
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public int insertMaTechnician(MaTechnicianAppAddVo maTechnicianAppAddVo)
-    {
-        MaTechnician maTechnician = new MaTechnician();
-        BeanUtils.copyProperties(maTechnicianAppAddVo, maTechnician);
-        int rows = maTechnicianMapper.insertMaTechnician(maTechnician);
-        if (maTechnicianAppAddVo.getProjectIds() != null && !maTechnicianAppAddVo.getProjectIds().isEmpty()) {
-            insertProjectRelations(maTechnician.getId(), new LinkedHashSet<>(maTechnicianAppAddVo.getProjectIds()));
-        }
-        return rows;
-    }
-
-    /**
-     * 后台新增商户
-     *
-     * @param dto 新增商户参数
-     * @param loginUser 当前登录用户
-     * @return 结果
-     */
-    @Override
-    @Transactional(rollbackFor = Exception.class)
-    public int insertMerchant(MaTechnicianMerchantAddDTO dto, LoginUser loginUser) {
-        Set<Long> projectIds = checkMerchantAddParam(dto);
-        String userName = loginUser.getUser().getUserName();
+    public int insertMaTechnician(MaTechnicianAppAddVo maTechnicianAppAddVo) {
 
         MaTechnician maTechnician = new MaTechnician();
-        maTechnician.setTeName(dto.getTeName().trim());
-        maTechnician.setTeNickName(dto.getTeNickName().trim());
-        maTechnician.setTeSex(dto.getTeSex());
-        maTechnician.setTePhone(dto.getTePhone().trim());
-        maTechnician.setOpenService(dto.getOpenService());
-        dto.getProjectIds().forEach(projectId -> {
-            Project project = projectMapper.selectById(projectId);
-            if (project != null) {
-                maTechnician.setTeProject(project.getTitle() + ",");
-            }
-        });
-        //移除末尾的逗号
-        maTechnician.setTeProject(StrUtil.removeSuffix(maTechnician.getTeProject(), ","));
-
-        maTechnician.setTechType(dto.getTechType());
-        maTechnician.setIsRecommend(normalizeSwitchValue(dto.getIsRecommend(), "是否推荐"));
-
-        maTechnician.setServiceState(SERVICE_STATE_AVAILABLE);
-        maTechnician.setPostState(POST_STATE_OFFLINE);
-        maTechnician.setTeIsEnable(ENABLED);
-        //上岗状态:默认-1 未上岗
-        maTechnician.setNStatus2(NS_STATUS_NOT_ON_DUTY);
-        maTechnician.setMerchantStatus(MERCHANT_STATUS_NORMAL);
-        //审核状态
-        maTechnician.setAuditStatus(AUDIT_APPROVED);
-        maTechnician.setTeAddress("");
-        maTechnician.setNStar(DEFAULT_STAT_VALUE);
-        maTechnician.setNNum(DEFAULT_STAT_VALUE);
-        maTechnician.setCreateBy(userName);
-        maTechnician.setUpdateBy(userName);
-        maTechnician.setCreateTime(DateUtils.getNowDate());
-        maTechnician.setUpdateTime(DateUtils.getNowDate());
-
-        int rows = maTechnicianMapper.insert(maTechnician);
-        if (rows <= 0) {
-            throw new ServiceException("新增商户失败");
+        BeanUtils.copyProperties(maTechnicianAppAddVo, maTechnician);
+        int i = maTechnicianMapper.insert(maTechnician);
+        // maTechnicianMapper.insertMaTechnician(maTechnician);
+        if (!maTechnicianAppAddVo.getProjectIds().isEmpty()) {
+//            ArrayList<MaTeProject> objects = Lists.newArrayList();
+//            ArrayList<Long> projectIds = maTechnicianAppAddVo.getProjectIds();
+//            projectIds.forEach(id->{
+//                MaTeProject maTeProject = new MaTeProject();
+//                maTeProject.setTeId(maTechnician.getId());
+//                maTeProject.setProjectId(id);
+//                objects.add(maTeProject);
+//            });
+//            i = maTeProjectMapper.insertBatch(objects);
         }
-        insertProjectRelations(maTechnician.getId(), projectIds);
-        return rows;
-    }
-
-    /**
-     * 后台查询商户列表
-     *
-     * @param page 分页参数
-     * @param dto 查询条件
-     * @return 商户分页列表
-     */
-    @Override
-    public Page<MaTechnicianMerchantListVO> selectMerchantList(Page<MaTechnicianMerchantListVO> page,
-                                                               MaTechnicianMerchantQueryDTO dto) {
-        Page<MaTechnicianMerchantListVO> pageParam = page == null ? new Page<>(1, 10) : page;
-        return maTechnicianMapper.selectMerchantList(pageParam, dto);
+        return i;
     }
 
     /**
      * 修改技师
      *
-     * @param  maTechnicianAppAddVo
+     * @param maTechnicianAppAddVo
      * @return 结果
      */
     @Override
-    public int updateMaTechnician(MaTechnicianAppAddVo maTechnicianAppAddVo)
-    {
+    public int updateMaTechnician(MaTechnicianAppAddVo maTechnicianAppAddVo) {
 
         MaTechnician maTechnician = new MaTechnician();
         BeanUtils.copyProperties(maTechnicianAppAddVo, maTechnician);
 
-        return maTechnicianMapper.updateMaTechnician(maTechnician);
+        return maTechnicianMapper.updateById(maTechnician);
     }
 
     /**
@@ -195,8 +176,7 @@ public class MaTechnicianServiceImpl implements IMaTechnicianService
      * @return 结果
      */
     @Override
-    public int deleteMaTechnicianByIds(Long[] ids)
-    {
+    public int deleteMaTechnicianByIds(Long[] ids) {
         return maTechnicianMapper.deleteMaTechnicianByIds(ids);
     }
 
@@ -207,134 +187,101 @@ public class MaTechnicianServiceImpl implements IMaTechnicianService
      * @return 结果
      */
     @Override
-    public int deleteMaTechnicianById(Long id)
-    {
+    public int deleteMaTechnicianById(Long id) {
         return maTechnicianMapper.deleteMaTechnicianById(id);
     }
 
     /**
-     * 首页选中的城市是否有开通服务
-     * @param areaCode
+     * 查询商户技能
+     *
+     * @param userId
      * @return
      */
     @Override
-    public Boolean isHasMerchantCity(String areaCode) {
-        LambdaQueryWrapper<MaTechnician> queryWrapper = new LambdaQueryWrapper<>();
-        queryWrapper.eq(MaTechnician::getTeAreaCode, areaCode);
-        return maTechnicianMapper.selectCount(queryWrapper) > 0;
+    public List<MaProject> selectMaTechnicianListBy(String userId, String type) {
+        LambdaQueryWrapper<MaProject> query = new LambdaQueryWrapper<>();
+        query.eq(MaProject::getUserId, userId);
+        query.eq(MaProject::getAuditStatus, type);
+        return maProjectMapper.selectList(query);
+
     }
 
     /**
-     * 首页按摩推荐
-     * @param dto
+     * 查询技能
+     *
+     * @param typeId
      * @return
      */
     @Override
-    public List<MerchantVo> getMerchantRecommend(MassageMerchantRecommendDto dto) {
-        return maTechnicianMapper.getMerchantRecommend(dto);
-    }
+    public List<Project> selectTechnicianListBy(String typeId) {
+        LambdaQueryWrapper<Project> query = new LambdaQueryWrapper<>();
+        query.eq(Project::getType, typeId);
+        query.eq(Project::getStatus, 0);
+        List<Project> projectList = projectMapper.selectList(query);
+        return projectList;
 
-    private Set<Long> checkMerchantAddParam(MaTechnicianMerchantAddDTO dto) {
-        if (dto == null) {
-            throw new ServiceException("商户参数不能为空");
-        }
-        checkRequiredText(dto.getTeName(), "姓名", 10);
-        checkRequiredText(dto.getTeNickName(), "昵称", 10);
-        checkRequiredText(dto.getTePhone(), "电话", 11);
-        checkEnumValue(dto.getTeSex(), "性别", 0, 1);
-        //checkEnumValue(dto.getOpenService(), "服务类目", 1, 2);
-        //校验服务类名不能为空
-        if (dto.getOpenService() == null) {
-            throw new ServiceException("服务类目不能为空");
-        }
-        checkEnumValue(dto.getTechType(), "商户类型", 0, 1);
-        if (dto.getIsRecommend() != null) {
-            checkEnumValue(dto.getIsRecommend(), "是否推荐", 0, 1);
-        }
-        return checkProjectIds(dto.getProjectIds());
-    }
-
-    private void checkRequiredText(String value, String fieldName, int maxLength) {
-        if (StringUtils.isBlank(value)) {
-            throw new ServiceException(fieldName + "不能为空");
-        }
-        if (value.trim().length() > maxLength) {
-            throw new ServiceException(fieldName + "长度不能超过" + maxLength + "个字符");
-        }
-    }
-
-    private void checkEnumValue(Integer value, String fieldName, int... allowedValues) {
-        if (value == null) {
-            throw new ServiceException(fieldName + "不能为空");
-        }
-        for (int allowedValue : allowedValues) {
-            if (value == allowedValue) {
-                return;
-            }
-        }
-        throw new ServiceException(fieldName + "值不正确");
     }
-
-    private Integer normalizeSwitchValue(Integer value, String fieldName) {
-        if (value == null) {
-            return 0;
-        }
-        checkEnumValue(value, fieldName, 0, 1);
-        return value;
+    /**
+     * 获取未申请技能列表
+     * @param userId
+     * @param typeId
+     * @return
+     */
+    @Override
+    public List<Project> getNotApplyList(String userId, String typeId){
+        LambdaQueryWrapper<MaProject> query = new LambdaQueryWrapper<>();
+        query.eq(MaProject::getUserId, userId);
+        query.eq(MaProject::getMerchantType, typeId);
+        List<MaProject> maProjectList = maProjectMapper.selectList(query);
+        // 获取已申请技能ID集合
+        List<String> projectIdList = maProjectList.stream().map(MaProject::getProjectId).collect(Collectors.toList());
+        LambdaQueryWrapper<Project> query1 = new LambdaQueryWrapper<>();
+        query1.eq(Project::getType, typeId);
+        query1.notIn(Project::getId, projectIdList);
+        return projectMapper.selectList(query1);
     }
-
     /**
-     * 校验服务项目ID集合
-     * @param projectIds
-     * @return 有效服务项目ID集合
+     * 申请开通服务
+     * @param dto
+     * @return
      */
-    private Set<Long> checkProjectIds(List<Long> projectIds) {
-        if (projectIds == null || projectIds.isEmpty()) {
-            throw new ServiceException("服务项目不能为空");
-        }
-
-        Set<Long> distinctProjectIds = new LinkedHashSet<>();
-        for (Long projectId : projectIds) {
-            if (projectId == null) {
-                throw new ServiceException("服务项目ID不能为空");
-            }
-            distinctProjectIds.add(projectId);
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public int applyForService(MaProjectSaveDto dto) {
+        if (Objects.isNull(dto)) {
+            return 0;
         }
-
-        /*int validCount = 0;
-        for (Long projectId : distinctProjectIds) {
-            MaProject project = maProjectMapper.selectMaProjectById(projectId);
-            if (project != null && (project.getIsDelete() == null || project.getIsDelete() != 1)) {
-                validCount++;
-            }
+        if (dto.getProjectIdList().size() > 0) {
+            // 插入商户技能
+            extracted(dto);
+        }else{
+            return 0;
         }
-        if (validCount != distinctProjectIds.size()) {
-            throw new ServiceException("服务项目不存在或已删除");
-        }*/
-        return distinctProjectIds;
+        return 1;
     }
 
     /**
-     * 新增商户与服务项目关联关系
-     *
-     * @param technicianId
-     * @param projectIds
+     * 插入商户技能
+     * @param dto
      */
-    private void insertProjectRelations(Long technicianId, Set<Long> projectIds) {
-        if (technicianId == null) {
-            throw new ServiceException("商户ID不能为空");
-        }
-
-        List<MaTeProject> relations = new ArrayList<>();
-        for (Long projectId : projectIds) {
-            MaTeProject relation = new MaTeProject();
-            relation.setTeId(technicianId);
-            relation.setProjectId(projectId);
-            relations.add(relation);
-        }
-        int rows = maTeProjectMapper.insertBatch(relations);
-        if (rows != relations.size()) {
-            throw new ServiceException("新增商户服务项目失败");
+    private void extracted(MaProjectSaveDto dto) {
+        LambdaQueryWrapper<Project> query = new LambdaQueryWrapper<>();
+        query.in(Project::getId, dto.getProjectIdList());
+        List<Project> projectList = projectMapper.selectList(query);
+        for (Project project : projectList) {
+            MaProject maProject = new MaProject();
+            maProject.setProjectId(project.getId().toString());
+            maProject.setProjectName(project.getTitle());
+            maProject.setProjectDescribe(project.getDetail());
+            maProject.setProjectDuration(project.getStandardDuration());
+            maProject.setProjectOriginalPrice(project.getPrice());
+            maProject.setProjectMaxPrice(project.getPriceMax());
+            maProject.setProjectLowestPrice(project.getPriceMin());
+            maProject.setCreateBy(dto.getUserId());
+            maProject.setUserId(dto.getUserId());
+            maProject.setApplyTime((Data) new Date());
+            maProject.setMerchantPhone(dto.getMerchantPhone());
+            maProjectMapper.insert(maProject);
         }
     }
 }

+ 7 - 7
nightFragrance-massage/src/main/java/com/ylx/massage/service/impl/TAddressServiceImpl.java

@@ -60,9 +60,9 @@ public class TAddressServiceImpl extends ServiceImpl<TAddressMapper, TAddress> i
      @Override
     @Transactional(rollbackFor = Exception.class)
     public Object insertVirtualAddress(TAddress tAddress) {
-        if (StringUtils.isBlank(tAddress.getOpenid())) {
-            throw new RuntimeException("openid不能为空");
-        }
+//        if (StringUtils.isBlank(tAddress.getOpenid())) {
+//            throw new RuntimeException("openid不能为空");
+//        }
         //检查用户类型是否为空
         if (Objects.isNull(tAddress.getUserType())) {
             throw new RuntimeException("用户类型不能为空");
@@ -80,10 +80,10 @@ public class TAddressServiceImpl extends ServiceImpl<TAddressMapper, TAddress> i
          if (Objects.isNull(tAddress.getType())) {
              throw new RuntimeException("地址类型不能为空");
          }
-         //检查地址类型是否为1或2
-         if (tAddress.getType() != 2) {
-             throw new RuntimeException("地址类型错误,地址类型只能为2");
-         }
+//         //检查地址类型是否为1或2
+//         if (tAddress.getType() != 2) {
+//             throw new RuntimeException("地址类型错误,地址类型只能为2");
+//         }
         return this.save(tAddress);
     }
 

+ 2 - 0
nightFragrance-massage/src/main/java/com/ylx/project/mapper/ProjectMapper.java

@@ -9,8 +9,10 @@ import com.ylx.massage.domain.vo.ProductServiceOptionVO;
 import com.ylx.project.domain.Project;
 import com.ylx.project.domain.vo.ProjectDetailVo;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 import java.util.Date;
+@Mapper
 public interface ProjectMapper extends BaseMapper<Project> {
 
     Page<ProductOptionVO> selectOptionUnionPage(Page<ProductOptionVO> page, @Param("dto") OptionDTO dto);

+ 8 - 0
nightFragrance-massage/src/main/resources/mapper/massage/MaTechnicianMapper.xml

@@ -18,6 +18,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="lifePhotos"    column="life_photos"    />
         <result property="avatar"    column="avatar"    />
         <result property="teBrief"    column="te_brief"    />
+        <result property="avatar"    column="avatar"    />
+        <result property="idCard"    column="id_card"    />
+        <result property="healthCertificate"    column="health_certificate"    />
+        <result property="qualificationCertificate"    column="qualification_certificate"    />
+        <result property="noCrimeRecord"    column="no_crime_record"    />
+        <result property="commitmentPdf"    column="commitment_pdf"    />
+        <result property="commitmentAudio"    column="commitment_audio"    />
+        <result property="commitmentVideo"    column="commitment_video"    />
         <result property="serviceState"    column="service_state"    />
         <result property="nStatus2"    column="n_status2"    />
         <result property="merchantStatus"    column="merchant_status"    />