Browse Source

修改商铺和互助组功能

loovi 1 year ago
parent
commit
b0a4680b77

+ 4 - 4
sp-service/level-one-server/src/main/java/com/pj/tb_enterprise/TbEnterprise.java

@@ -150,10 +150,10 @@ public class TbEnterprise extends Model<TbEnterprise> implements Serializable {
 	@JsonFormat(pattern = "yyyy-MM-dd")
 	private Date registerTime;
 
-	/**
-	 *  
-	 */
-	private String personId;
+//	/**
+//	 *
+//	 */
+//	private String personId;
 
 	/**
 	 * 创建时间 

+ 7 - 24
sp-service/level-one-server/src/main/java/com/pj/tb_enterprise/TbEnterpriseController.java

@@ -38,8 +38,7 @@ public class TbEnterpriseController {
 	/** 底层 Service 对象 */
 	@Autowired
 	TbEnterpriseService tbEnterpriseService;
-	@Autowired
-	AdminInterface adminInterface;
+
 
 
 	/** 增 */  
@@ -145,16 +144,10 @@ public class TbEnterpriseController {
 	*/
 	@RequestMapping("audit")
 	@SaCheckPermission(TbEnterprise.PERMISSION_CODE_EDIT)
-	public AjaxJson audit(TbEnterprise t){
+	public AjaxJson audit(@RequestBody TbEnterpriseDto tbEnterpriseDto){
 
-		Long loginId = StpUserUtil.getLoginIdAsLong();
-		TbEnterprise tbEnterprise = tbEnterpriseService.getById(t.getId());
-		if(Objects.isNull(tbEnterprise)){
-			return AjaxJson.getSuccess("该商户不存在");
-		}
-		tbEnterprise.setUpdateBy(String.valueOf(loginId));
-		tbEnterpriseService.update(t);
-		return AjaxJson.getSuccess();
+		int line = tbEnterpriseService.audit(tbEnterpriseDto);
+		return AjaxJson.getByLine(line);
 	}
 
 
@@ -166,18 +159,8 @@ public class TbEnterpriseController {
 	*/
 	@RequestMapping("isLock")
 	@SaCheckPermission(TbEnterprise.PERMISSION_CODE_EDIT)
-	public AjaxJson isLock(TbEnterprise t) {
-		Long loginId = StpUserUtil.getLoginIdAsLong();
-		TbEnterprise tbEnterprise = tbEnterpriseService.getById(t.getId());
-		if (Objects.isNull(tbEnterprise)) {
-			return AjaxJson.getSuccess("该商户不存在");
-		}
-		// 如果商户被锁住则禁止app端登录
-		adminInterface.isLock(String.valueOf(t.getId()), Integer.valueOf(t.getType()),0);
-		tbEnterprise.setUpdateBy(String.valueOf(loginId));
-		tbEnterpriseService.update(t);
-
-
-		return AjaxJson.getSuccess();
+	public AjaxJson isLock(@RequestBody  TbEnterpriseDto tbEnterpriseDto) {
+		int line = tbEnterpriseService.isLock( tbEnterpriseDto);
+		return AjaxJson.getByLine(line);
 	}
 }

+ 121 - 0
sp-service/level-one-server/src/main/java/com/pj/tb_enterprise/TbEnterpriseDto.java

@@ -0,0 +1,121 @@
+package com.pj.tb_enterprise;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.Date;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class TbEnterpriseDto {
+
+
+
+
+    // ---------- 表中字段 ----------
+    /**
+     *
+     */
+    private Long id;
+    /**
+     * 名称
+     */
+    private String name;
+
+    /**
+     * 国别
+     */
+    private String nationality;
+
+    /**
+     * 商户分类(自营商铺=自营商铺,劳务商铺=劳务商铺)
+     */
+    private String type;
+
+    /**
+     * 法人
+     */
+    private String legalPerson;
+
+    /**
+     * 身份证号
+     */
+    private String idCard;
+
+    /**
+     * 手机号码
+     */
+    private String contact;
+
+    /**
+     * 营业执照
+     */
+    private String businessLicense;
+
+    /**
+     * 所在铺位ID
+     */
+    private Long shopId;
+
+    /**
+     * 所在铺位名称(1=100-2)
+     */
+    private String shopName;
+
+    /**
+     * 银行编号(CMB= 招商银行)
+     */
+    private String bankNo;
+
+    /**
+     *
+     */
+    private String bankName;
+
+    /**
+     * 银行账号
+     */
+    private String bankAccount;
+
+    /**
+     * 税号
+     */
+    private String dutyParagraph;
+
+    /**
+     *
+     */
+    private String addressIds;
+
+    /**
+     *
+     */
+    private String address;
+
+    /**
+     *
+     */
+    private String agreement;
+
+    /**
+     *
+     */
+    private int judgeStatus;
+
+    /**
+     *
+     */
+    private String judgeContent;
+
+
+
+    /**
+     * 是否锁定
+     */
+    private Integer isLock;
+}

+ 64 - 64
sp-service/level-one-server/src/main/java/com/pj/tb_enterprise/TbEnterpriseMapper.xml

@@ -17,74 +17,74 @@
 		from tb_enterprise 
 	</sql>
 
-	
+
 	<!-- 查集合 - 根据条件(参数为空时代表忽略指定条件) [G] -->
 	<select id="getList" resultMap="model">
 		<include refid="select_sql"></include>
-		<where>
-			<if test=' this.has("id") '> and id = #{id} </if>
-			<if test=' this.has("name") '> and name = #{name} </if>
-			<if test=' this.has("nationality") '> and nationality = #{nationality} </if>
-			<if test=' this.has("type") '> and type = #{type} </if>
-			<if test=' this.has("legalPerson") '> and legal_person = #{legalPerson} </if>
-			<if test=' this.has("idCard") '> and id_card = #{idCard} </if>
-			<if test=' this.has("contact") '> and contact = #{contact} </if>
-			<if test=' this.has("shopId") '> and shop_id = #{shopId} </if>
-			<if test=' this.has("shopName") '> and shop_name = #{shopName} </if>
-			<if test=' this.has("bankNo") '> and bank_no = #{bankNo} </if>
-			<if test=' this.has("bankName") '> and bank_name = #{bankName} </if>
-			<if test=' this.has("bankAccount") '> and bank_account = #{bankAccount} </if>
-			<if test=' this.has("dutyParagraph") '> and duty_paragraph = #{dutyParagraph} </if>
-			<if test=' this.has("addressIds") '> and address_ids = #{addressIds} </if>
-			<if test=' this.has("address") '> and address = #{address} </if>
-			<if test=' this.has("agreement") '> and agreement = #{agreement} </if>
-			<if test=' this.has("judgeStatus") '> and judge_status = #{judgeStatus} </if>
-			<if test=' this.has("judgeContent") '> and judge_content = #{judgeContent} </if>
-			<if test=' this.has("judgeTime") '> and judge_time = #{judgeTime} </if>
-			<if test=' this.has("registerTime") '> and register_time = #{registerTime} </if>
-			<if test=' this.has("personId") '> and person_id = #{personId} </if>
-			<if test=' this.has("createTime") '> and create_time = #{createTime} </if>
-			<if test=' this.has("createBy") '> and create_by = #{createBy} </if>
-			<if test=' this.has("createName") '> and create_name = #{createName} </if>
-			<if test=' this.has("updateTime") '> and update_time = #{updateTime} </if>
-			<if test=' this.has("updateBy") '> and update_by = #{updateBy} </if>
-			<if test=' this.has("updateName") '> and update_name = #{updateName} </if>
-			<if test=' this.has("deleteStatus") '> and delete_status = #{deleteStatus} </if>
-		</where>
-		order by
-		<choose>
-			<when test='sortType == 1'> id desc </when>
-			<when test='sortType == 2'> name desc </when>
-			<when test='sortType == 3'> nationality desc </when>
-			<when test='sortType == 4'> type desc </when>
-			<when test='sortType == 5'> legal_person desc </when>
-			<when test='sortType == 6'> id_card desc </when>
-			<when test='sortType == 7'> contact desc </when>
-			<when test='sortType == 8'> shop_id desc </when>
-			<when test='sortType == 9'> shop_name desc </when>
-			<when test='sortType == 10'> bank_no desc </when>
-			<when test='sortType == 11'> bank_name desc </when>
-			<when test='sortType == 12'> bank_account desc </when>
-			<when test='sortType == 13'> duty_paragraph desc </when>
-			<when test='sortType == 14'> address_ids desc </when>
-			<when test='sortType == 15'> address desc </when>
-			<when test='sortType == 16'> agreement desc </when>
-			<when test='sortType == 17'> judge_status desc </when>
-			<when test='sortType == 18'> judge_content desc </when>
-			<when test='sortType == 19'> judge_time desc </when>
-			<when test='sortType == 20'> register_time desc </when>
-			<when test='sortType == 21'> person_id desc </when>
-			<when test='sortType == 22'> create_time desc </when>
-			<when test='sortType == 23'> create_by desc </when>
-			<when test='sortType == 24'> create_name desc </when>
-			<when test='sortType == 25'> update_time desc </when>
-			<when test='sortType == 26'> update_by desc </when>
-			<when test='sortType == 27'> update_name desc </when>
-			<when test='sortType == 28'> delete_status desc </when>
-			<otherwise> id desc </otherwise>
-		</choose>
+<!--		<where>-->
+<!--			<if test=' this.has("id") '> and id = #{id} </if>-->
+<!--			<if test=' this.has("name") '> and name = #{name} </if>-->
+<!--			<if test=' this.has("nationality") '> and nationality = #{nationality} </if>-->
+<!--			<if test=' this.has("type") '> and type = #{type} </if>-->
+<!--			<if test=' this.has("legalPerson") '> and legal_person = #{legalPerson} </if>-->
+<!--			<if test=' this.has("idCard") '> and id_card = #{idCard} </if>-->
+<!--			<if test=' this.has("contact") '> and contact = #{contact} </if>-->
+<!--			<if test=' this.has("shopId") '> and shop_id = #{shopId} </if>-->
+<!--			<if test=' this.has("shopName") '> and shop_name = #{shopName} </if>-->
+<!--			<if test=' this.has("bankNo") '> and bank_no = #{bankNo} </if>-->
+<!--			<if test=' this.has("bankName") '> and bank_name = #{bankName} </if>-->
+<!--			<if test=' this.has("bankAccount") '> and bank_account = #{bankAccount} </if>-->
+<!--			<if test=' this.has("dutyParagraph") '> and duty_paragraph = #{dutyParagraph} </if>-->
+<!--			<if test=' this.has("addressIds") '> and address_ids = #{addressIds} </if>-->
+<!--			<if test=' this.has("address") '> and address = #{address} </if>-->
+<!--			<if test=' this.has("agreement") '> and agreement = #{agreement} </if>-->
+<!--			<if test=' this.has("judgeStatus") '> and judge_status = #{judgeStatus} </if>-->
+<!--			<if test=' this.has("judgeContent") '> and judge_content = #{judgeContent} </if>-->
+<!--			<if test=' this.has("judgeTime") '> and judge_time = #{judgeTime} </if>-->
+<!--			<if test=' this.has("registerTime") '> and register_time = #{registerTime} </if>-->
+<!--			<if test=' this.has("personId") '> and person_id = #{personId} </if>-->
+<!--			<if test=' this.has("createTime") '> and create_time = #{createTime} </if>-->
+<!--			<if test=' this.has("createBy") '> and create_by = #{createBy} </if>-->
+<!--			<if test=' this.has("createName") '> and create_name = #{createName} </if>-->
+<!--			<if test=' this.has("updateTime") '> and update_time = #{updateTime} </if>-->
+<!--			<if test=' this.has("updateBy") '> and update_by = #{updateBy} </if>-->
+<!--			<if test=' this.has("updateName") '> and update_name = #{updateName} </if>-->
+<!--			<if test=' this.has("deleteStatus") '> and delete_status = #{deleteStatus} </if>-->
+<!--		</where>-->
+<!--		order by-->
+<!--		<choose>-->
+<!--			<when test='sortType == 1'> id desc </when>-->
+<!--			<when test='sortType == 2'> name desc </when>-->
+<!--			<when test='sortType == 3'> nationality desc </when>-->
+<!--			<when test='sortType == 4'> type desc </when>-->
+<!--			<when test='sortType == 5'> legal_person desc </when>-->
+<!--			<when test='sortType == 6'> id_card desc </when>-->
+<!--			<when test='sortType == 7'> contact desc </when>-->
+<!--			<when test='sortType == 8'> shop_id desc </when>-->
+<!--			<when test='sortType == 9'> shop_name desc </when>-->
+<!--			<when test='sortType == 10'> bank_no desc </when>-->
+<!--			<when test='sortType == 11'> bank_name desc </when>-->
+<!--			<when test='sortType == 12'> bank_account desc </when>-->
+<!--			<when test='sortType == 13'> duty_paragraph desc </when>-->
+<!--			<when test='sortType == 14'> address_ids desc </when>-->
+<!--			<when test='sortType == 15'> address desc </when>-->
+<!--			<when test='sortType == 16'> agreement desc </when>-->
+<!--			<when test='sortType == 17'> judge_status desc </when>-->
+<!--			<when test='sortType == 18'> judge_content desc </when>-->
+<!--			<when test='sortType == 19'> judge_time desc </when>-->
+<!--			<when test='sortType == 20'> register_time desc </when>-->
+<!--			<when test='sortType == 21'> person_id desc </when>-->
+<!--			<when test='sortType == 22'> create_time desc </when>-->
+<!--			<when test='sortType == 23'> create_by desc </when>-->
+<!--			<when test='sortType == 24'> create_name desc </when>-->
+<!--			<when test='sortType == 25'> update_time desc </when>-->
+<!--			<when test='sortType == 26'> update_by desc </when>-->
+<!--			<when test='sortType == 27'> update_name desc </when>-->
+<!--			<when test='sortType == 28'> delete_status desc </when>-->
+<!--			<otherwise> id desc </otherwise>-->
+<!--		</choose>-->
 	</select>
-	
+
 	
 	
 	

+ 49 - 1
sp-service/level-one-server/src/main/java/com/pj/tb_enterprise/TbEnterpriseService.java

@@ -5,15 +5,20 @@ import java.io.IOException;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 import java.util.List;
+import java.util.Objects;
 
 import com.alibaba.excel.EasyExcel;
 import com.alibaba.excel.event.AnalysisEventListener;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.pj.api.client.admin.AdminInterface;
+import com.pj.current.satoken.StpUserUtil;
+import com.pj.utils.sg.AjaxJson;
 import com.pj.utils.so.SoMap;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.hssf.usermodel.HSSFRow;
 import org.apache.poi.hssf.usermodel.HSSFSheet;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.service.IService;
@@ -35,6 +40,8 @@ public class TbEnterpriseService extends ServiceImpl<TbEnterpriseMapper, TbEnter
 	/** 底层 Mapper 对象 */
 	@Autowired
 	TbEnterpriseMapper tbEnterpriseMapper;
+	@Autowired
+	AdminInterface adminInterface;
 
 	/** 非事务方法调用事务方法需要代理对象 */
 	@Autowired
@@ -66,6 +73,47 @@ public class TbEnterpriseService extends ServiceImpl<TbEnterpriseMapper, TbEnter
 		return tbEnterpriseMapper.getList(so);	
 	}
 
+	public int audit(TbEnterpriseDto tbEnterpriseDto){
+
+		// 获取当前登录用户id
+		Long loginId = StpUserUtil.getLoginIdAsLong();
+		// 根据id获取商户
+		TbEnterprise tbEnterprise = tbEnterpriseMapper.selectById(tbEnterpriseDto.getId());
+		// 如果商户不存在则抛出异常
+		if(Objects.isNull(tbEnterprise)){
+			throw new RuntimeException("该商户不存在");
+		}
+		BeanUtils.copyProperties(tbEnterpriseDto,tbEnterprise);
+		// 写入更新者id
+		tbEnterprise.setUpdateBy(String.valueOf(loginId));
+		// 更新商户审核状态
+		int line = tbEnterpriseMapper.updateById(tbEnterprise);
+		return line;
+	}
+
+	public int isLock(TbEnterpriseDto tbEnterpriseDto) {
+		// 获取当前登录用户id
+		Long loginId = StpUserUtil.getLoginIdAsLong();
+		// 根据id获取商户
+		TbEnterprise tbEnterprise = tbEnterpriseMapper.selectById(tbEnterpriseDto.getId());
+		// 如果商户不存在则抛出异常
+		if(Objects.isNull(tbEnterprise)){
+			throw new RuntimeException("该商户不存在");
+		}
+		BeanUtils.copyProperties(tbEnterpriseDto,tbEnterprise);
+		// 写入更新者id
+		tbEnterprise.setUpdateBy(String.valueOf(loginId));
+		// 更新商户锁定状态
+		int  line = tbEnterpriseMapper.updateById(tbEnterprise);
+		//获取商户锁定状态
+		int isLock = tbEnterprise.getIsLock();
+		// 如果商户被锁住则禁止app端登录
+		// TODO
+		adminInterface.isLock(String.valueOf(tbEnterprise.getId()), 0,isLock);
+
+		return line;
+	}
+
 	/**
 	 * 导入
 	 * @param file excel文件
@@ -171,7 +219,7 @@ public class TbEnterpriseService extends ServiceImpl<TbEnterpriseMapper, TbEnter
 			sheetRow.createCell(18).setCellValue((selectedList.get(i).getJudgeContent() + "").equals("null")? "": selectedList.get(i).getJudgeContent() + "");
 			sheetRow.createCell(19).setCellValue((selectedList.get(i).getJudgeTime() + "").equals("null")? "": selectedList.get(i).getJudgeTime() + "");
 			sheetRow.createCell(20).setCellValue((selectedList.get(i).getRegisterTime() + "").equals("null")? "": selectedList.get(i).getRegisterTime() + "");
-			sheetRow.createCell(21).setCellValue((selectedList.get(i).getPersonId() + "").equals("null")? "": selectedList.get(i).getPersonId() + "");
+//			sheetRow.createCell(21).setCellValue((selectedList.get(i).getPersonId() + "").equals("null")? "": selectedList.get(i).getPersonId() + "");
 			sheetRow.createCell(22).setCellValue((selectedList.get(i).getCreateTime() + "").equals("null")? "": selectedList.get(i).getCreateTime() + "");
 			sheetRow.createCell(23).setCellValue((selectedList.get(i).getCreateBy() + "").equals("null")? "": selectedList.get(i).getCreateBy() + "");
 			sheetRow.createCell(24).setCellValue((selectedList.get(i).getCreateName() + "").equals("null")? "": selectedList.get(i).getCreateName() + "");

+ 13 - 78
sp-service/level-one-server/src/main/java/com/pj/tb_group/TbGroupController.java

@@ -35,8 +35,7 @@ public class TbGroupController {
 	/** 底层 Service 对象 */
 	@Autowired
 	TbGroupService tbGroupService;
-	@Autowired
-	TbPeopleService tbPeopleService;
+
 
 	/** 增 */  
 	@RequestMapping("add")
@@ -144,32 +143,10 @@ public class TbGroupController {
 	 */
 	@RequestMapping("setLeader")
 	@SaCheckPermission(TbGroup.PERMISSION_CODE_EDIT)
-	public AjaxJson setLeader(Long groupId,Long leaderId){
-
-		Long loginId = StpUserUtil.getLoginIdAsLong();
-
-		TbGroup tbGroup = tbGroupService.getById(groupId);
-		TbPeople tbPeople = tbPeopleService.getById(leaderId);
-		if (Objects.isNull(tbGroup)){
-			return AjaxJson.getSuccess("该互助组不存在");
-		}
-		if (Objects.isNull(tbPeople)){
-			return AjaxJson.getSuccess("该用户不存在");
-		}
-		if(tbGroup.getIsLock()==1){
-			return AjaxJson.getSuccess("该互助组已被锁定");
-		}
-		if (tbPeople.getIsLock()==1){
-			return AjaxJson.getSuccess("该用户已被锁定");
-		}
+	public AjaxJson setLeader(@RequestParam("groupId") Long groupId,@RequestParam("leaderId")Long leaderId){
+		int line = tbGroupService.setLeader(groupId,leaderId);
 
-		tbGroup.setLeaderId(tbGroup.getLeaderId());
-		tbGroup.setLeaderName(tbPeople.getName());
-		tbGroup.setLeaderPhone(tbGroup.getLeaderPhone());
-
-		tbGroup.setUpdateBy(String.valueOf(loginId));
-		tbGroupService.update(tbGroup);
-		return AjaxJson.getSuccess();
+		return AjaxJson.getByLine(line);
 	}
 	/**
 	*向互助组添加边民
@@ -179,27 +156,9 @@ public class TbGroupController {
 	*/
 	@RequestMapping("groupAddPeople")
 	@SaCheckPermission(TbGroup.PERMISSION_CODE_EDIT)
-	public AjaxJson AddGroupPeople(Long groupId,Long [] peopleIds){
-
-		Long loginId = StpUserUtil.getLoginIdAsLong();
-
-		TbGroup tbGroup = tbGroupService.getById(groupId);
-		if (Objects.isNull(tbGroup)){
-			return AjaxJson.getSuccess("该互助组不存在");
-		}
-		if(tbGroup.getIsLock()==1){
-			return AjaxJson.getSuccess("该互助组已被锁定");
-		}
-		List<Long> list = Arrays.asList(peopleIds);
-
-		list.forEach(peopleId->{
-			TbPeople tbPeople = tbPeopleService.getById(peopleId);
-			tbPeople.setGroupId(tbGroup.getId());
-			tbPeople.setGroupName(tbGroup.getName());
-			tbPeople.setUpdateBy(String.valueOf(loginId));
-			tbPeopleService.updateById(tbPeople);
-		});
-		return AjaxJson.getSuccess();
+	public AjaxJson AddGroupPeople(@RequestParam("groupId") Long groupId,@RequestParam("peopleIds") Long [] peopleIds){
+		int line = tbGroupService.AddGroupPeople(groupId,peopleIds);
+		return AjaxJson.getByLine(line);
 	}
 	/**
 	 *互助组删除边民
@@ -209,27 +168,9 @@ public class TbGroupController {
 	 */
 	@RequestMapping("groupDelPeople")
 	@SaCheckPermission(TbGroup.PERMISSION_CODE_EDIT)
-	public AjaxJson DelGroupPeople(Long groupId,Long [] peopleIds){
-
-		Long loginId = StpUserUtil.getLoginIdAsLong();
-
-		TbGroup tbGroup = tbGroupService.getById(groupId);
-		if (Objects.isNull(tbGroup)){
-			return AjaxJson.getSuccess("该互助组不存在");
-		}
-		if(tbGroup.getIsLock()==1){
-			return AjaxJson.getSuccess("该互助组已被锁定");
-		}
-		List<Long> list = Arrays.asList(peopleIds);
-
-		list.forEach(peopleId->{
-			TbPeople tbPeople = tbPeopleService.getById(peopleId);
-			tbPeople.setGroupId(0L);
-			tbPeople.setGroupName("");
-			tbPeople.setUpdateBy(String.valueOf(loginId));
-			tbPeopleService.updateById(tbPeople);
-		});
-		return AjaxJson.getSuccess();
+	public AjaxJson DelGroupPeople(@RequestParam("groupId") Long groupId,@RequestParam("peopleIds") Long [] peopleIds){
+		int line = tbGroupService.DelGroupPeople(groupId,peopleIds);
+		return AjaxJson.getByLine(line);
 	}
 	/**
 	 *是否锁住互助组
@@ -239,15 +180,9 @@ public class TbGroupController {
 	 */
 	@RequestMapping("isLock")
 	@SaCheckPermission(TbGroup.PERMISSION_CODE_EDIT)
-	public AjaxJson isLock(TbGroup t) {
-		Long loginId = StpUserUtil.getLoginIdAsLong();
-		TbGroup tbGroup = tbGroupService.getById(t.getId());
-		if (Objects.isNull(tbGroup)) {
-			return AjaxJson.getSuccess("该互助组不存在");
-		}
-		tbGroup.setUpdateBy(String.valueOf(loginId));
-		tbGroupService.update(t);
-		return AjaxJson.getSuccess();
+	public AjaxJson isLock(@RequestBody TbGroupDto tbGroupDto) {
+		int line = tbGroupService.isLock(tbGroupDto);
+		return AjaxJson.getByLine(line);
 	}
 
 

+ 78 - 0
sp-service/level-one-server/src/main/java/com/pj/tb_group/TbGroupDto.java

@@ -0,0 +1,78 @@
+package com.pj.tb_group;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.Date;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class TbGroupDto {
+    // ---------- 表中字段 ----------
+    /**
+     *
+     */
+    private Long id;
+
+    /**
+     *
+     */
+    private String addressIds;
+
+    /**
+     *
+     */
+    private String address;
+
+    /**
+     *
+     */
+    private String detailAddress;
+
+    /**
+     * 名称
+     */
+    private String name;
+
+    /**
+     * 组长ID
+     */
+    private Long leaderId;
+
+    /**
+     * 组长名
+     */
+    private String leaderName;
+
+    /**
+     * 组长电话
+     */
+    private String leaderPhone;
+
+    /**
+     *
+     */
+    private String code;
+
+    /**
+     * 当天该组剩余额度
+     */
+    private Double leftPrice;
+
+
+
+    /**
+     * 删除状态(0=禁用,1=启用)
+     */
+    private Integer deleteStatus;
+
+    /**
+     * 是否锁定
+     */
+    private Integer isLock;
+}

+ 123 - 0
sp-service/level-one-server/src/main/java/com/pj/tb_group/TbGroupService.java

@@ -4,15 +4,21 @@ import java.io.FileOutputStream;
 import java.io.IOException;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
+import java.util.Arrays;
 import java.util.List;
+import java.util.Objects;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.pj.current.satoken.StpUserUtil;
 import com.pj.tb_goods_transit.TbGoodsTransit;
+import com.pj.tb_people.TbPeople;
+import com.pj.tb_people.TbPeopleMapper;
 import com.pj.utils.so.SoMap;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.hssf.usermodel.HSSFRow;
 import org.apache.poi.hssf.usermodel.HSSFSheet;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.service.IService;
@@ -34,6 +40,8 @@ public class TbGroupService extends ServiceImpl<TbGroupMapper, TbGroup> implemen
 	/** 底层 Mapper 对象 */
 	@Autowired
 	TbGroupMapper tbGroupMapper;
+	@Autowired
+	TbPeopleMapper tbPeopleMapper;
 
 	@Autowired
 	private MethodGroupService methodGroupService;
@@ -62,8 +70,123 @@ public class TbGroupService extends ServiceImpl<TbGroupMapper, TbGroup> implemen
 	List<TbGroup> getList(SoMap so) { 
 		return tbGroupMapper.getList(so);	
 	}
+	public int setLeader(Long groupId,Long leaderId){
+		// 获取当前登录用户id
+		Long loginId = StpUserUtil.getLoginIdAsLong();
+		// 获取互助组信息
+		TbGroup tbGroup = tbGroupMapper.selectById(groupId);
+		// 获取边民信息
+		TbPeople tbPeople = tbPeopleMapper.selectById(leaderId);
+		// 如果互助组不存在则抛异常
+		if (Objects.isNull(tbGroup)){
+			throw new RuntimeException("该互助组不存在");
+		}
+		// 如果边民不存在
+		if (Objects.isNull(tbPeople)){
+			throw new RuntimeException("该用户不存在");
+		}
+		// 如果互助组被锁定则抛异常
+		if(tbGroup.getIsLock()==1){
+			throw new RuntimeException("该互助组已被锁定");
+		}
+		// 如果边民不存在则抛异常
+		if (tbPeople.getIsLock()==1){
+			throw new RuntimeException("该用户已被锁定");
+		}
+		// 设置互助组组长
+		tbGroup.setLeaderId(tbPeople.getId());
+		tbGroup.setLeaderName(tbPeople.getName());
+		tbGroup.setLeaderPhone(tbPeople.getPhone());
+		// 写入更新者id
+		tbGroup.setUpdateBy(String.valueOf(loginId));
+		// 更新互助组
+		int line = tbGroupMapper.updateById(tbGroup);
+		return line;
+	}
+	public int AddGroupPeople(Long groupId,Long [] peopleIds){
+		// 获取当前登录用户id
+//		Long loginId = StpUserUtil.getLoginIdAsLong();
+		int line=0;
+		// 获取互助组信息
+		TbGroup tbGroup = tbGroupMapper.selectById(groupId);
+		// 如果互助组不存在则抛异常
+		if (Objects.isNull(tbGroup)){
+			throw new RuntimeException("该互助组不存在");
+		}
+		// 如果互助组被锁定则抛异常
+		if(tbGroup.getIsLock()==1){
+			throw new RuntimeException("该互助组已被锁定");
+		}
+		// 如果互助组被删除则抛异常
+		if(tbGroup.getDeleteStatus()==1){
+			throw new RuntimeException("该互助组已被删除");
+		}
+		List<Long> list = Arrays.asList(peopleIds);
+		// 把互助组信息写入边民表
+		for (Long peopleId : list) {
+			TbPeople tbPeople = tbPeopleMapper.selectById(peopleId);
+			tbPeople.setGroupId(tbGroup.getId());
+			tbPeople.setGroupName(tbGroup.getName());
+			// 写入更新者id
+//			tbPeople.setUpdateBy(String.valueOf(loginId));
+			int i = tbPeopleMapper.updateById(tbPeople);
+			line= i + 1;
+		}
+		return line;
 
+	}
+	public int DelGroupPeople(Long groupId,Long [] peopleIds){
 
+		// 获取当前登录用户id
+		Long loginId = StpUserUtil.getLoginIdAsLong();
+		int line=0;
+		// 获取互助组信息
+		TbGroup tbGroup = tbGroupMapper.selectById(groupId);
+		// 如果互助组不存在则抛异常
+		if (Objects.isNull(tbGroup)){
+			throw new RuntimeException("该互助组不存在");
+		}
+		// 如果互助组被锁定则抛异常
+		if(tbGroup.getIsLock()==1){
+			throw new RuntimeException("该互助组已被锁定");
+		}
+		// 如果互助组被删除则抛异常
+		if(tbGroup.getDeleteStatus()==1){
+			throw new RuntimeException("该互助组已被删除");
+		}
+		List<Long> list = Arrays.asList(peopleIds);
+		// 把边民表互助组信息置空
+		for (Long peopleId : list) {
+			TbPeople tbPeople = tbPeopleMapper.selectById(peopleId);
+			tbPeople.setGroupId(0L);
+			tbPeople.setGroupName("");
+			// 写入更新者id
+			tbPeople.setUpdateBy(String.valueOf(loginId));
+			int i = tbPeopleMapper.updateById(tbPeople);
+			line= i + 1;
+		}
+		return line;
+	}
+	public int isLock(TbGroupDto tbGroupDto) {
+		// 获取当前登录用户id
+		Long loginId = StpUserUtil.getLoginIdAsLong();
+		// 获取互助组信息
+		TbGroup tbGroup = tbGroupMapper.selectById(tbGroupDto.getId());
+		// 如果互助组不存在则抛异常
+		if (Objects.isNull(tbGroup)) {
+			throw new RuntimeException("该互助组不存在");
+		}
+		// 如果互助组被删除则抛异常
+		if (tbGroup.getDeleteStatus()==1) {
+			throw new RuntimeException("该互助组已被删除");
+		}
+		BeanUtils.copyProperties(tbGroupDto,tbGroup);
+		// 写入更新者id
+		tbGroup.setUpdateBy(String.valueOf(loginId));
+		// 更新互助组信息
+		int line = tbGroupMapper.updateById(tbGroup);
+		return line;
+	}
 	/**
 	 * 导入
 	 * @param file excel文件