he2802 hace 2 años
padre
commit
cf81509bab

+ 88 - 0
zhongzheng-admin/src/main/java/com/zhongzheng/controller/distribution/DistributionSellerController.java

@@ -0,0 +1,88 @@
+package com.zhongzheng.controller.distribution;
+
+import com.zhongzheng.common.annotation.Log;
+import com.zhongzheng.common.core.controller.BaseController;
+import com.zhongzheng.common.core.domain.AjaxResult;
+import com.zhongzheng.common.core.page.TableDataInfo;
+import com.zhongzheng.common.enums.BusinessType;
+import com.zhongzheng.common.utils.ServletUtils;
+import com.zhongzheng.framework.web.service.SellerTokenService;
+import com.zhongzheng.modules.distribution.bo.DistributionSellerAddBo;
+import com.zhongzheng.modules.distribution.bo.DistributionSellerEditBo;
+import com.zhongzheng.modules.distribution.bo.DistributionSellerQueryBo;
+import com.zhongzheng.modules.distribution.service.IDistributionSellerService;
+import com.zhongzheng.modules.distribution.vo.DistributionSellerVo;
+import com.zhongzheng.modules.user.bo.UserVisitLogAddBo;
+import com.zhongzheng.modules.user.entity.ClientLoginSeller;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.RequiredArgsConstructor;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * 分销业务员Controller
+ *
+ * @author hjl
+ * @date 2023-03-13
+ */
+@Api(value = "分销业务员控制器", tags = {"分销业务员管理"})
+@RequiredArgsConstructor(onConstructor_ = @Autowired)
+@RestController
+@RequestMapping("/distribution/seller")
+public class DistributionSellerController extends BaseController {
+
+    private final IDistributionSellerService iDistributionSellerService;
+
+
+    /**
+     * 查询分销业务员列表
+     */
+    @ApiOperation("查询分销业务员列表")
+    @PreAuthorize("@ss.hasPermi('system:seller:list')")
+    @GetMapping("/list")
+    public TableDataInfo<DistributionSellerVo> list(DistributionSellerQueryBo bo) {
+        startPage();
+        List<DistributionSellerVo> list = iDistributionSellerService.queryList(bo);
+        return getDataTable(list);
+    }
+
+
+    /**
+     * 获取分销业务员详细信息
+     */
+    @ApiOperation("获取分销业务员详细信息")
+    @PreAuthorize("@ss.hasPermi('system:seller:query')")
+    @GetMapping("/{salerId}")
+    public AjaxResult<DistributionSellerVo> getInfo(@PathVariable("salerId" ) Long salerId) {
+        return AjaxResult.success(iDistributionSellerService.queryById(salerId));
+    }
+
+    /**
+     * 新增分销业务员
+     */
+    @ApiOperation("新增分销业务员")
+    @PreAuthorize("@ss.hasPermi('system:seller:add')")
+    @Log(title = "分销业务员", businessType = BusinessType.INSERT)
+    @PostMapping()
+    public AjaxResult<Void> add(@RequestBody DistributionSellerAddBo bo) {
+        return toAjax(iDistributionSellerService.insertByAddBo(bo) ? 1 : 0);
+    }
+
+    /**
+     * 修改分销业务员
+     */
+    @ApiOperation("修改分销业务员")
+    @PreAuthorize("@ss.hasPermi('system:seller:edit')")
+    @Log(title = "分销业务员", businessType = BusinessType.UPDATE)
+    @PostMapping("/edit")
+    public AjaxResult<Void> edit(@RequestBody DistributionSellerEditBo bo) {
+        return toAjax(iDistributionSellerService.updateByEditBo(bo) ? 1 : 0);
+    }
+
+
+
+}

+ 51 - 1
zhongzheng-framework/src/main/java/com/zhongzheng/framework/web/service/DistributionSellerServiceImpl.java

@@ -301,13 +301,63 @@ public class DistributionSellerServiceImpl extends ServiceImpl<DistributionSelle
         return voList;
     }
 
+    /**
+     * 后台注册
+     * @param bo 分销业务员新增业务对象
+     * @return
+     */
     @Override
     public Boolean insertByAddBo(DistributionSellerAddBo bo) {
+        if(StringUtils.isBlank(bo.getIdCard())){
+            throw new CustomException("身份证不能为空");
+        }
+        if(bo.getTelphone()==null){
+            throw new CustomException("手机号不能为空");
+        }
+        if(Validator.isEmpty(bo.getRealname())){
+            throw new CustomException("姓名不能为空");
+        }
         DistributionSeller add = BeanUtil.toBean(bo, DistributionSeller.class);
         validEntityBeforeSave(add);
         add.setCreateTime(DateUtils.getNowTime());
         add.setUpdateTime(DateUtils.getNowTime());
-        return this.save(add);
+        DistributionSeller seller = getOne(new LambdaQueryWrapper<DistributionSeller>()
+                .eq(DistributionSeller::getTelphone, EncryptHandler.encrypt(bo.getTelphone())).last("limit 1"));
+        if(Validator.isNotNull(seller)){
+            throw new CustomException("该手机号已注册");
+        }
+        DistributionSeller sellerIdCard = getOne(new LambdaQueryWrapper<DistributionSeller>()
+                .eq(DistributionSeller::getIdCard,EncryptHandler.encrypt(bo.getIdCard())).last("limit 1"));
+        if(Validator.isNotNull(sellerIdCard)){
+            throw new CustomException("该身份证已注册");
+        }
+        DistributionSeller inertData = new DistributionSeller();
+        //密码身份证后六位
+        String pwd =  bo.getIdCard().substring(bo.getIdCard().length() - 6);
+        inertData.setPassword(SecurityUtils.encryptPassword(pwd));
+        inertData.setTelphone(bo.getTelphone());
+        inertData.setIdCard(bo.getIdCard());
+        inertData.setRealname(bo.getRealname());
+        inertData.setAvatar(Constants.DEFAULT_AVATAR);
+        inertData.setPassword(SecurityUtils.encryptPassword(bo.getPassword()));
+        inertData.setUserAccount(ServletUtils.getEncoded("YW"));
+        inertData.setCreateTime(DateUtils.getNowTime());
+        inertData.setUpdateTime(DateUtils.getNowTime());
+        inertData.setShareCode(ToolsUtils.getRandomString(8));
+        inertData.setAvatar(bo.getAvatar());
+        User userIdCard = iUserService.getOne(new LambdaQueryWrapper<User>()
+                .eq(User::getIdCard,EncryptHandler.encrypt(bo.getIdCard())).last("limit 1"));
+        if(Validator.isNotEmpty(userIdCard)){
+            inertData.setUserId(userIdCard.getUserId());
+        }
+        if(Validator.isNotEmpty(bo.getShareCode())){
+            DistributionSeller sellerShare = getOne(new LambdaQueryWrapper<DistributionSeller>()
+                    .eq(DistributionSeller::getShareCode,bo.getShareCode()).last("limit 1"));
+            if(Validator.isNotEmpty(sellerShare)){
+                inertData.setParentId(sellerShare.getSellerId());
+            }
+        }
+        return this.save(inertData);
     }
 
     @Override