Browse Source

冲突解决

anderx 8 years ago
parent
commit
e29dbab042

+ 13 - 0
src/main/java/com/goafanti/admin/bo/BusinessProjectBo.java

@@ -63,6 +63,7 @@ public class BusinessProjectBo {
 	 * @mbg.generated  Mon Dec 04 15:29:25 CST 2017
 	 */
 	private String activityFlag;
+	
 	/**
 	 * This field was generated by MyBatis Generator. This field corresponds to the database column business_project.member_price
 	 * @mbg.generated  Mon Dec 04 15:29:25 CST 2017
@@ -530,4 +531,16 @@ public class BusinessProjectBo {
 	public void setCreateName(String createName) {
 		this.createName = createName;
 	}
+
+	@Override
+	public String toString() {
+		return "BusinessProjectBo [id=" + id + ", createId=" + createId + ", createTime=" + createTime + ", updateTime="
+				+ updateTime + ", deleteSign=" + deleteSign + ", bname=" + bname + ", cid=" + cid + ", price=" + price
+				+ ", offset=" + offset + ", activityPrice=" + activityPrice + ", activityFlag=" + activityFlag
+				+ ", memberPrice=" + memberPrice + ", introduce=" + introduce + ", status=" + status + ", country="
+				+ country + ", province=" + province + ", city=" + city + ", district=" + district + ", principalId="
+				+ principalId + ", valueEffect=" + valueEffect + ", clientSize=" + clientSize + ", cname=" + cname
+				+ ", createName=" + createName + "]";
+	}
+	
 }

+ 30 - 0
src/main/java/com/goafanti/admin/bo/ProjectSizeBo.java

@@ -3,6 +3,10 @@ package com.goafanti.admin.bo;
 import java.math.BigDecimal;
 import java.util.Date;
 
+import org.apache.commons.lang3.time.DateFormatUtils;
+
+import com.goafanti.common.constant.AFTConstants;
+
 public class ProjectSizeBo {
 
 	    /**
@@ -112,6 +116,10 @@ public class ProjectSizeBo {
 	     * @mbg.generated Mon Dec 04 09:52:04 CST 2017
 	     */
 	    private Integer status;
+	    /**
+	     * 项目名称
+	     */
+	    private String bname;
 
 	    /**
 	     * This method was generated by MyBatis Generator.
@@ -172,6 +180,13 @@ public class ProjectSizeBo {
 	    public Date getCreateTime() {
 	        return createTime;
 	    }
+	    public String getCreateTimeFormattedDate() {
+			if (this.createTime == null) {
+				return null;
+			} else {
+				return DateFormatUtils.format(this.getCreateTime(), AFTConstants.YYYYMMDDHHMMSS);
+			}
+		}
 
 	    /**
 	     * This method was generated by MyBatis Generator.
@@ -196,6 +211,13 @@ public class ProjectSizeBo {
 	    public Date getUpdateTime() {
 	        return updateTime;
 	    }
+	    public String getUpdateTimeFormattedDate() {
+			if (this.updateTime == null) {
+				return null;
+			} else {
+				return DateFormatUtils.format(this.getCreateTime(), AFTConstants.YYYYMMDDHHMMSS);
+			}
+		}
 
 	    /**
 	     * This method was generated by MyBatis Generator.
@@ -400,5 +422,13 @@ public class ProjectSizeBo {
 	    public void setStatus(Integer status) {
 	        this.status = status;
 	    }
+
+		public String getBname() {
+			return bname;
+		}
+
+		public void setBname(String bname) {
+			this.bname = bname;
+		}
 	}
 

+ 66 - 23
src/main/java/com/goafanti/admin/controller/BusinessProjectController.java

@@ -9,8 +9,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
 
-import com.goafanti.admin.bo.BusinessProjectBo;
-import com.goafanti.admin.bo.ProjectSizeBo;
+
 import com.goafanti.admin.service.BusinessProjectService;
 import com.goafanti.common.bo.Result;
 import com.goafanti.common.constant.AFTConstants;
@@ -130,30 +129,32 @@ public class BusinessProjectController extends CertifyApiController{
 		res.setData(businessprojectService.getAllCname());
 		return res;
 	}
+	
 	/**
-	 * 最低折扣增加
-	 */
-	@RequestMapping(value = "/addOffset", method = RequestMethod.GET)
-	public Result addOffset(String id){
-		Result res=new Result();
-		res.setData(businessprojectService.updateAddOffset(id));
-		return res;
-	}
-	/**
-	 * 最低折扣减少
-	 */
-	@RequestMapping(value = "/subtractOffset", method = RequestMethod.GET)
-	public Result subtractOffset(String id){
-		Result res=new Result();
-		res.setData(businessprojectService.updateSubtractOffset(id));
-		return res;
-	}
-	/**
-	 * 编辑保存
+	 * 编辑基本保存
 	 */
 	@RequestMapping(value = "/updateProject", method = RequestMethod.POST)
 	public Result updateProject(BusinessProject s){
 		Result res=new Result();
+		if (StringUtils.isBlank(s.getBname())) {
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "项目名称名称为空", "项目名称"));
+			return res;
+		}
+		
+		if (StringUtils.isBlank(s.getCid())) {
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "所属品类为空", "所属品类"));
+			return res;
+		}
+		if (businessprojectService.getBnamecount(s.getBname())>1) {
+			res.getError().add(buildError(ErrorConstants.PARAM_BEING_ERROR, "项目名称已存在", "项目名称"));
+			return res;
+		}
+		if(Integer.valueOf(s.getCountry())==0){
+			if (StringUtils.isBlank(s.getProvince())) {
+				res.getError().add(buildError( "至少指定省", "至少指定省"));
+				return res;
+			}
+		}
 		res.setData(businessprojectService.updateProject(s));
 		return res;
 	}
@@ -163,12 +164,17 @@ public class BusinessProjectController extends CertifyApiController{
 	@RequestMapping(value = "/addProjectSize", method = RequestMethod.POST)
 	public Result addProjectSize(ProjectSize ps){
 		Result res=new Result();
+		if (businessprojectService.WhetherRepeat(ps)) {
+				res.getError().add(buildError(ErrorConstants.PARAM_BEING_ERROR, "规格名称已存在", "规格名称"));
+				return res;
+			}
+		
 		res.setData(businessprojectService.addProjectSize(ps));
 		return res;
 	}
 	
 	/**
-	 * 编辑规格
+	 * 编辑保存规格
 	 */
 	@RequestMapping(value = "/orgProjectSize", method = RequestMethod.POST)
 	public Result orgProjectSize(ProjectSize ps){
@@ -177,7 +183,44 @@ public class BusinessProjectController extends CertifyApiController{
 		return res;
 	}
 	/**
-	 * 编辑规格
+	 * 规格列表
 	 */
+	@RequestMapping(value = "/listProjectSize", method = RequestMethod.GET)
+	public Result listProjectSize(String pid,Integer pNo,Integer Psize){
+		Result res=new Result();
+		if (StringUtils.isBlank(pid)) {
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "项目名称名称为空", "项目"));
+			return res;
+		}
+		res.setData(businessprojectService.listProjectSize(pid,pNo, Psize));
+		return res;
+	}
 	
+	/**
+	 * 获取规格详情
+	 */
+	@RequestMapping(value = "/getProjectSize", method = RequestMethod.GET)
+	public Result getProjectSize(String  id){
+		Result res=new Result();
+		res.setData(businessprojectService.getProjectSize(id));
+		return res;
+	}
+	/**
+	 * 删除规格
+	 */
+	@RequestMapping(value = "/deleteProjectSize", method = RequestMethod.GET)
+	public Result deleteProjectSize(String  id){
+		Result res=new Result();
+		res.setData(businessprojectService.deleteProjectSize(id));
+		return res;
+	}
+	/**
+	 * 停用规格
+	 */
+	@RequestMapping(value = "/stopProjectSize", method = RequestMethod.GET)
+	public Result stopProjectSize(String  id){
+		Result res=new Result();
+		res.setData(businessprojectService.updateSotpProjectSize(id));
+		return res;
+	}
 }

+ 10 - 3
src/main/java/com/goafanti/admin/service/BusinessProjectService.java

@@ -27,9 +27,6 @@ public interface BusinessProjectService {
 	
 	List<Map<String, String>> getAllCname();
 	
-	int updateAddOffset(String id);
-	
-	int updateSubtractOffset(String id);
 	
 	int updateProject(BusinessProject s);
 	
@@ -37,4 +34,14 @@ public interface BusinessProjectService {
 	
 	int updateOrgProjectSize(ProjectSize ps);
 	
+	Pagination<ProjectSizeBo> listProjectSize(String pid,Integer pNo,Integer pSize);
+
+	ProjectSizeBo getProjectSize(String id);
+
+	int  deleteProjectSize(String id);
+
+	int updateSotpProjectSize(String id);
+
+	boolean WhetherRepeat(ProjectSize ps);
+	
 }

+ 61 - 32
src/main/java/com/goafanti/admin/service/impl/BusinessProjectServiceImpl.java

@@ -1,6 +1,6 @@
 package com.goafanti.admin.service.impl;
 
-import java.math.BigDecimal;
+
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
@@ -66,10 +66,14 @@ public class BusinessProjectServiceImpl extends BaseMybatisDao<BusinessProjectMa
 		if (pSize == null || pSize < 0 || pSize > 10) {
 			pSize = 10;
 		} 	
-		
-		return (Pagination<BusinessProjectBo>)findPage("findProjectListByPage", "findProjectListCount",
+		Pagination<BusinessProjectBo> pt=(Pagination<BusinessProjectBo>)findPage("findProjectListByPage", "findProjectListCount",
 				disposeParams(bname,  cid,  country, province, city, district,  activityFlag,
 						 status),pNo,pSize);
+		List<BusinessProjectBo> list=(List<BusinessProjectBo>) pt.getList();
+		for (BusinessProjectBo o : list) {
+			o.setCname(getAllCname(o.getCid()));
+		}
+		return pt;
 	}
 	private Map<String, Object> disposeParams(String bname, String cid, String country,String province,String city,String district, String activityFlag,
 			String status) {
@@ -134,9 +138,7 @@ public class BusinessProjectServiceImpl extends BaseMybatisDao<BusinessProjectMa
 		BusinessProjectBo bpo=new BusinessProjectBo();
 		BeanUtils.copyProperties(bp,bpo);
 		String cname=getAllCname(bpo.getCid());
-		System.out.println("----------------"+bpo.getCid());
 		String createId=bpo.getCreateId();
-		System.out.println(createId); 
 		bpo.setCreateName(businessProjectMapper.getCreateName(createId));
 		bpo.setCname(cname);
 		return bpo;
@@ -173,30 +175,9 @@ public class BusinessProjectServiceImpl extends BaseMybatisDao<BusinessProjectMa
 			return cid.length()>3?cname:"";
 		}
 	}
-	@Override
-	public int updateAddOffset(String id) {
-		BusinessProject bp=businessProjectMapper.selectByPrimaryKey(id);
-		if (null==bp.getOffset()) {
-			bp.setOffset(new BigDecimal(1));	
-		}
-		if (bp.getOffset().compareTo(new BigDecimal(1))==-1) {
-			bp.setOffset(bp.getOffset().add(new BigDecimal(0.01)));
-		}
-		
-		return businessProjectMapper.updateByPrimaryKey(bp);
-	}
 	
-	@Override
-	public int updateSubtractOffset(String id) {
-		BusinessProject bp=businessProjectMapper.selectByPrimaryKey(id);
-		if (null==bp.getOffset()) {
-			bp.setOffset(new BigDecimal(1));	
-		}
-		if (bp.getOffset().compareTo(new BigDecimal(0))==1) {
-			bp.setOffset(bp.getOffset().subtract(new BigDecimal(0.01)));
-		}
-		return businessProjectMapper.updateByPrimaryKey(bp);
-	}
+	
+	
 	@Override
 	public int updateProject(BusinessProject s) {
 		BusinessProject bp=businessProjectMapper.selectByPrimaryKey(s.getId());
@@ -271,6 +252,7 @@ public class BusinessProjectServiceImpl extends BaseMybatisDao<BusinessProjectMa
 	public int updateOrgProjectSize(ProjectSize ps) {
 		ProjectSize psz=projectSizeMapper.selectByPrimaryKey(ps.getId());
 		projectSizeConfiguration(ps, psz);
+		System.out.println(psz);
 		return projectSizeMapper.updateByPrimaryKeySelective(psz);
 	}
 	private void projectSizeConfiguration(ProjectSize ps, ProjectSize psz) {
@@ -298,10 +280,57 @@ public class BusinessProjectServiceImpl extends BaseMybatisDao<BusinessProjectMa
 		if (null!=(ps.getStatus())) {
 			psz.setStatus(ps.getStatus());
 		}
+		psz.setUpdateTime(new Date());
 	}
-	
-	/*public ProjectSizeBo orgProjectSize(String id) {
+	@SuppressWarnings("unchecked")
+	@Override
+	public Pagination<ProjectSizeBo>  listProjectSize(String pid,Integer pNo,Integer pSize) {
+		if (pNo == null || pNo < 0) {
+			pNo = 1;
+		}
+
+		if (pSize == null || pSize < 0 || pSize > 10) {
+			pSize = 10;
+		} 
+		Map<String, Object>map=new HashMap<>();
+		map.put("pid", pid);
+			
+		
+		Pagination<ProjectSizeBo> pt=(Pagination<ProjectSizeBo>)findPage("findProjectSizeListByPage", "findProjectSizeListCount",
+				map,pNo,pSize);
+		return pt;
+	}
+	@Override
+	public ProjectSizeBo getProjectSize(String id) {
+		return projectSizeMapper.selectByBusinessId(id);
+	}
+	@Override
+	public int deleteProjectSize(String id) {
 		
-		return null;
-	}*/
+		return projectSizeMapper.deleteByPrimaryKey(id);
+	}
+	@Override
+	public int updateSotpProjectSize(String id) {
+		ProjectSize ps=projectSizeMapper.selectByPrimaryKey(id);
+			int i=ps.getStatus();
+			if (i==0) {
+				ps.setStatus(1);
+			}else {
+				ps.setStatus(0);
+			}
+		return projectSizeMapper.updateByPrimaryKey(ps);
+	}
+	@Override
+	public boolean WhetherRepeat(ProjectSize ps) {
+		List<ProjectSizeBo> list=projectSizeMapper.getgetPnamecount(ps.getPname());
+		if (null!=list&&list.isEmpty()) {
+		if (list.size()>1&&list.get(0).getPid().equals(ps.getPid())) {
+			System.out.println("true");
+			return true;
+		}
+		}
+		return false;
+	}
+	
+	
 }

+ 6 - 0
src/main/java/com/goafanti/common/dao/ProjectSizeMapper.java

@@ -1,5 +1,6 @@
 package com.goafanti.common.dao;
 
+import com.goafanti.admin.bo.ProjectSizeBo;
 import com.goafanti.common.model.ProjectSize;
 import com.goafanti.common.model.ProjectSizeExample;
 import java.util.List;
@@ -72,4 +73,9 @@ public interface ProjectSizeMapper {
 	 * @mbg.generated  Mon Dec 04 15:29:25 CST 2017
 	 */
 	int updateByPrimaryKey(ProjectSize record);
+
+	List<ProjectSizeBo> selectByPrimaryBusinessId(String id);
+					
+	ProjectSizeBo selectByBusinessId(String id);
+	List<ProjectSizeBo> getgetPnamecount(String pname);
 }

+ 20 - 1
src/main/java/com/goafanti/common/mapper/BusinessProjectMapper.xml

@@ -2,6 +2,7 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.goafanti.common.dao.BusinessProjectMapper">
   <resultMap id="BaseResultMap" type="com.goafanti.common.model.BusinessProject">
+  
     <!--
       WARNING - @mbg.generated
       This element is automatically generated by MyBatis Generator, do not modify.
@@ -540,7 +541,7 @@
   
   	<select id="findProjectListByPage" resultType="com.goafanti.admin.bo.BusinessProjectBo">
  		select b.id, b.create_id, b.create_time, b.update_time,  b.delete_sign, b.bname,
- 		  b.cid,  b.price,  b.offset,  b.activity_price,  b.activity_flag,  b.member_price, 
+ 		  b.cid,  b.price,  b.offset,  b.activity_price as activityPrice,  b.activity_flag as activityFlag,  b.member_price as memberPrice, 
  		  b.introduce,  b.status,  b.country,  b.province,  b.city,  b.district, 
           b.principal_id,  b.Value_effect,  b.client_size,b2.cname 
   		from business_project b
@@ -623,6 +624,24 @@
   
   </select>
   
+  <select id="findProjectSizeListByPage" resultType="com.goafanti.admin.bo.ProjectSizeBo">
+  select 
+  	 p.id, p.create_id as createId, p.create_time as createTime, p.update_time as updateTime, p.pid, p.pname, p.price, p.offset, p.activity_price as activityPrice, 
+    p.activity_flag as activityFlag, p.member_price as memberPrice, p.status,b.bname
+    from project_size p
+    left join business_project b on  p.pid =b.id 
+    where p.pid = #{pid,jdbcType=VARCHAR}
+    <if test="page_sql!=null">
+			${page_sql}
+	</if>
+  </select>
   
+  <select id="findProjectSizeListCount" resultType="Integer">
+  select 
+  	count(0)
+    from project_size p
+    left join business_project b on  p.pid =b.id 
+    where p.pid = #{pid,jdbcType=VARCHAR}
+  </select>
   
 </mapper>

+ 28 - 1
src/main/java/com/goafanti/common/mapper/ProjectSizeMapper.xml

@@ -331,7 +331,7 @@
       <include refid="Update_By_Example_Where_Clause" />
     </if>
   </update>
-  <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.ProjectSize">
+  <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.admin.bo.ProjectSizeBo">
     <!--
       WARNING - @mbg.generated
       This element is automatically generated by MyBatis Generator, do not modify.
@@ -395,4 +395,31 @@
       status = #{status,jdbcType=INTEGER}
     where id = #{id,jdbcType=VARCHAR}
   </update>
+ 	
+  <select id="selectByPrimaryBusinessId" resultType="com.goafanti.admin.bo.ProjectSizeBo">
+    
+    select 
+  	 p.id, p.create_id as createId, p.create_time as createTime, p.update_time as updateTime, p.pid, p.pname, p.price, p.offset, p.activity_price as activityPrice, 
+    p.activity_flag as activityFlag, p.member_price as memberPrice, p.status,b.bname
+    from project_size p
+    left join business_project b on  p.pid =b.id 
+    where p.pid = #{pid,jdbcType=VARCHAR}
+  </select>
+  
+  <select id="selectByBusinessId" parameterType="java.lang.String" resultType="com.goafanti.admin.bo.ProjectSizeBo">
+    select 
+    p.id, p.create_id as createId, p.create_time as createTime, p.update_time as updateTime, p.pid, p.pname, p.price, p.offset, p.activity_price as activityPrice, 
+    p.activity_flag as activityFlag, p.member_price as memberPrice, p.status,b.bname
+    from project_size p
+    left join business_project b on  p.pid =b.id 
+    where p.id = #{id,jdbcType=VARCHAR}
+  </select>	
+  
+  <select id="getgetPnamecount" resultType="com.goafanti.admin.bo.ProjectSizeBo">
+   select 
+   p.id, p.create_id as createId, p.create_time as createTime, p.update_time as updateTime, p.pid, p.pname, p.price, p.offset, p.activity_price as activityPrice, 
+   p.activity_flag as activityFlag, p.member_price as memberPrice, p.status
+    from project_size p
+   where p.pname=#{pname,jdbcType=VARCHAR}
+  </select>
 </mapper>

+ 26 - 0
src/main/java/com/goafanti/common/model/ProjectSize.java

@@ -3,6 +3,10 @@ package com.goafanti.common.model;
 import java.math.BigDecimal;
 import java.util.Date;
 
+import org.apache.commons.lang3.time.DateFormatUtils;
+
+import com.goafanti.common.constant.AFTConstants;
+
 public class ProjectSize {
 
 	/**
@@ -110,6 +114,13 @@ public class ProjectSize {
 	public Date getCreateTime() {
 		return createTime;
 	}
+	public String getCreateTimeFormattedDate() {
+		if (this.createTime == null) {
+			return null;
+		} else {
+			return DateFormatUtils.format(this.getCreateTime(), AFTConstants.YYYYMMDDHHMMSS);
+		}
+	}
 
 	/**
 	 * This method was generated by MyBatis Generator. This method sets the value of the database column project_size.create_time
@@ -128,6 +139,13 @@ public class ProjectSize {
 	public Date getUpdateTime() {
 		return updateTime;
 	}
+	public String getUpdateTimeFormattedDate() {
+		if (this.updateTime == null) {
+			return null;
+		} else {
+			return DateFormatUtils.format(this.getCreateTime(), AFTConstants.YYYYMMDDHHMMSS);
+		}
+	}
 
 	/**
 	 * This method was generated by MyBatis Generator. This method sets the value of the database column project_size.update_time
@@ -281,4 +299,12 @@ public class ProjectSize {
 	public void setStatus(Integer status) {
 		this.status = status;
 	}
+
+	@Override
+	public String toString() {
+		return "ProjectSize [id=" + id + ", createId=" + createId + ", createTime=" + createTime + ", updateTime="
+				+ updateTime + ", pid=" + pid + ", pname=" + pname + ", price=" + price + ", offset=" + offset
+				+ ", activityPrice=" + activityPrice + ", activityFlag=" + activityFlag + ", memberPrice=" + memberPrice
+				+ ", status=" + status + "]";
+	}
 }