Browse Source

订单模块开发修改

anderx 7 years ago
parent
commit
2d419515bd

+ 3 - 1
src/main/java/com/goafanti/common/dao/TOrderTaskMapper.java

@@ -2,6 +2,8 @@ package com.goafanti.common.dao;
 
 import com.goafanti.common.model.TOrderTask;
 import com.goafanti.common.model.TOrderTaskExample;
+import com.goafanti.order.bo.TOrderTaskBo;
+
 import java.util.List;
 import org.apache.ibatis.annotations.Param;
 
@@ -118,5 +120,5 @@ public interface TOrderTaskMapper {
      */
     int updateByPrimaryKey(TOrderTask record);
 
-	List<TOrderTask> selectOrderTask(String orderNo);
+	List<TOrderTaskBo> selectOrderTask(String orderNo);
 }

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

@@ -366,6 +366,6 @@
     where id = #{id,jdbcType=VARCHAR}
   </update>
   <select id="selectByOrderNoDunSubject" resultType="com.goafanti.common.model.TOrderDun">
-  	select id,dun_subject as dunSubject from t_order_dun where order_no= #{orderNo,jdbcType=VARCHAR}
+  	select id,dun_subject as dunSubject,money from t_order_dun where order_no= #{orderNo,jdbcType=VARCHAR}
   </select>
 </mapper>

+ 24 - 8
src/main/java/com/goafanti/common/mapper/TOrderTaskMapper.xml

@@ -23,6 +23,7 @@
     <result column="task_start_time" jdbcType="TIMESTAMP" property="taskStartTime" />
     <result column="task_end_time" jdbcType="TIMESTAMP" property="taskEndTime" />
     <result column="project_status" jdbcType="INTEGER" property="projectStatus" />
+    <result column="main" jdbcType="INTEGER" property="main" />
     <result column="accept_time" jdbcType="DATE" property="acceptTime" />
     <result column="review_time" jdbcType="DATE" property="reviewTime" />
     <result column="publicity_time" jdbcType="DATE" property="publicityTime" />
@@ -113,7 +114,7 @@
     id, order_no, super_id, commodity_id, commodity_name, commodity_quantity, commodity_mode, 
     commodity_price, task_status, task_distribution_time, task_allocator, task_receiver, 
     task_comment, task_start_time, task_end_time, project_status, accept_time, review_time, 
-    publicity_time, licence_time
+    publicity_time, licence_time ,main
   </sql>
   <sql id="Blob_Column_List">
     <!--
@@ -209,7 +210,7 @@
       task_receiver, task_comment, task_start_time, 
       task_end_time, project_status, accept_time, 
       review_time, publicity_time, licence_time, 
-      attachment_url)
+      attachment_url,main)
     values (#{id,jdbcType=INTEGER}, #{orderNo,jdbcType=VARCHAR}, #{superId,jdbcType=VARCHAR}, 
       #{commodityId,jdbcType=VARCHAR}, #{commodityName,jdbcType=VARCHAR}, #{commodityQuantity,jdbcType=INTEGER}, 
       #{commodityMode,jdbcType=VARCHAR}, #{commodityPrice,jdbcType=DECIMAL}, #{taskStatus,jdbcType=INTEGER}, 
@@ -217,7 +218,7 @@
       #{taskReceiver,jdbcType=VARCHAR}, #{taskComment,jdbcType=VARCHAR}, #{taskStartTime,jdbcType=TIMESTAMP}, 
       #{taskEndTime,jdbcType=TIMESTAMP}, #{projectStatus,jdbcType=INTEGER}, #{acceptTime,jdbcType=DATE}, 
       #{reviewTime,jdbcType=DATE}, #{publicityTime,jdbcType=DATE}, #{licenceTime,jdbcType=DATE}, 
-      #{attachmentUrl,jdbcType=LONGVARCHAR})
+      #{attachmentUrl,jdbcType=LONGVARCHAR},#{main,jdbcType=INTEGER})
   </insert>
   <insert id="insertSelective" parameterType="com.goafanti.common.model.TOrderTask">
     <!--
@@ -290,6 +291,9 @@
       <if test="attachmentUrl != null">
         attachment_url,
       </if>
+      <if test="main != null">
+        main,
+      </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides=",">
       <if test="id != null">
@@ -355,6 +359,9 @@
       <if test="attachmentUrl != null">
         #{attachmentUrl,jdbcType=LONGVARCHAR},
       </if>
+      <if test="main != null">
+        #{main,jdbcType=INTEGER},
+      </if>
     </trim>
   </insert>
   <select id="countByExample" parameterType="com.goafanti.common.model.TOrderTaskExample" resultType="java.lang.Long">
@@ -575,6 +582,9 @@
       <if test="attachmentUrl != null">
         attachment_url = #{attachmentUrl,jdbcType=LONGVARCHAR},
       </if>
+      <if test="main != null">
+        main = #{main,jdbcType=INTEGER},
+      </if>
     </set>
     where id = #{id,jdbcType=INTEGER}
   </update>
@@ -604,7 +614,8 @@
       review_time = #{reviewTime,jdbcType=DATE},
       publicity_time = #{publicityTime,jdbcType=DATE},
       licence_time = #{licenceTime,jdbcType=DATE},
-      attachment_url = #{attachmentUrl,jdbcType=LONGVARCHAR}
+      attachment_url = #{attachmentUrl,jdbcType=LONGVARCHAR},
+      main = #{main,jdbcType=INTEGER}
     where id = #{id,jdbcType=INTEGER}
   </update>
   <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.TOrderTask">
@@ -632,13 +643,18 @@
       accept_time = #{acceptTime,jdbcType=DATE},
       review_time = #{reviewTime,jdbcType=DATE},
       publicity_time = #{publicityTime,jdbcType=DATE},
-      licence_time = #{licenceTime,jdbcType=DATE}
+      licence_time = #{licenceTime,jdbcType=DATE},
+      main = #{main,jdbcType=INTEGER}
     where id = #{id,jdbcType=INTEGER}
   </update>
-  <select id="selectOrderTask"  resultMap="BaseResultMap">
+  <select id="selectOrderTask"  resultType="com.goafanti.order.bo.TOrderTaskBo">
   	select 
-  	<include refid="Base_Column_List" />
-  	 from t_order_task
+  		a.id,a.order_no as orderNo,a.commodity_name as commodityName,a.commodity_id as commodityId,
+  		a.commodity_price as commodityPrice,a.task_comment as taskComment,a.task_status as taskStatus,
+  		a.project_status as project_status,a.main,a.task_receiver as taskReceiver ,d.name as contacts,
+  		d.contact_mobile as contactsMobile,c.cname
+  	 from t_order_task a left join business_project b on a.commodity_id=b.id
+  	 left join business_category c on b.cid=c.id left join admin d on a.task_receiver=d.id
   	where order_no=  #{orderNo,jdbcType=VARCHAR}
   </select>
 </mapper>

+ 12 - 0
src/main/java/com/goafanti/common/model/TOrderTask.java

@@ -192,6 +192,10 @@ public class TOrderTask {
      * @mbg.generated Mon Nov 19 11:03:38 CST 2018
      */
     private String attachmentUrl;
+    
+    
+    
+    private Integer main;
 
     /**
      * This method was generated by MyBatis Generator.
@@ -696,4 +700,12 @@ public class TOrderTask {
     public void setAttachmentUrl(String attachmentUrl) {
         this.attachmentUrl = attachmentUrl;
     }
+
+	public Integer getMain() {
+		return main;
+	}
+
+	public void setMain(Integer main) {
+		this.main = main;
+	}
 }

+ 28 - 0
src/main/java/com/goafanti/order/bo/TOrderTaskBo.java

@@ -0,0 +1,28 @@
+package com.goafanti.order.bo;
+
+import com.goafanti.common.model.TOrderTask;
+
+public class TOrderTaskBo extends TOrderTask{
+	private String contacts;
+	private String contactsMobile;
+	private String cname;
+	public String getContacts() {
+		return contacts;
+	}
+	public void setContacts(String contacts) {
+		this.contacts = contacts;
+	}
+	public String getContactsMobile() {
+		return contactsMobile;
+	}
+	public void setContactsMobile(String contactsMobile) {
+		this.contactsMobile = contactsMobile;
+	}
+	public String getCname() {
+		return cname;
+	}
+	public void setCname(String cname) {
+		this.cname = cname;
+	}
+	
+}

+ 40 - 6
src/main/java/com/goafanti/order/controller/AdminNewOrderApiController.java

@@ -2,6 +2,9 @@ package com.goafanti.order.controller;
 
 
 
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -34,7 +37,6 @@ public class AdminNewOrderApiController extends CertifyApiController {
 			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"","客户编号"));
 			return res;
 		}
-		
 		if(orderType == null){
 			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"","订单类型"));
 			return res;
@@ -54,17 +56,28 @@ public class AdminNewOrderApiController extends CertifyApiController {
 			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"","订单编号"));
 			return res;
 		}
-		
+		if (t.getOrderNo()!=null&&orderNewService.checkOrderMain(t)) {
+			res.getError().add(buildError("订单主要任务已存在","订单主要任务已存在"));
+			return res;
+		}
 		return res.data(orderNewService.addOrderTask(t));
 	}
 	/**
-	 * 添加项目
+	 * 修改项目
 	 * @param t
 	 * @return
 	 */
-	@RequestMapping(value = "/pudateOrderTask",method = RequestMethod.POST)
-	public Result pudateOrderTask(TOrderTask t){
+	@RequestMapping(value = "/updateOrderTask",method = RequestMethod.POST)
+	public Result updateOrderTask(TOrderTask t){
 		Result res=new Result();
+		if(null==t.getId()){
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"","订单编号"));
+			return res;
+		}
+		if (t.getOrderNo()!=null&&orderNewService.checkOrderMain(t)) {
+			res.getError().add(buildError("订单主要任务已存在","订单主要任务已存在"));
+			return res;
+		}
 		return res.data(orderNewService.updateOrderTask(t));
 	}
 	/**
@@ -109,7 +122,7 @@ public class AdminNewOrderApiController extends CertifyApiController {
 	 * @return
 	 */
 	@RequestMapping(value = "/updateServiceOrderNew",method = RequestMethod.POST)
-	public Result updateServiceOrder(TOrderNew t,Integer isSubmit){
+	public Result updateServiceOrder(TOrderNew t,Integer isSubmit,String signDate){
 		Result res = new Result();
 		if(StringUtils.isBlank(t.getOrderNo())){
 			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "订单编号"));
@@ -123,6 +136,14 @@ public class AdminNewOrderApiController extends CertifyApiController {
 			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "合同图片"));
 			return res;
 		}
+		if (StringUtils.isNotBlank(signDate)) {
+			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+			try {
+				t.setSignTime(sdf.parse(signDate));
+			} catch (ParseException e) {
+				e.printStackTrace();
+			}
+		}
 		res.setData(orderNewService.updateServiceOrder(t,isSubmit));
 		return res;
 	}
@@ -156,6 +177,19 @@ public class AdminNewOrderApiController extends CertifyApiController {
 		return res;
 	}
 	/**
+	 * 查看订单收款截点
+	 */
+	@RequestMapping(value = "/selectOrderDun", method = RequestMethod.GET)
+	public Result selectOrderDun(String orderNo){
+		Result res = new Result();
+		if(StringUtils.isBlank(orderNo)){
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "订单编号","订单编号"));
+			return res;
+		}
+		res.setData(orderNewService.selectOrderDun(orderNo));
+		return res;
+	}
+	/**
 	 * 订单列表
 	 */
 	@RequestMapping(value="/orderNewList", method = RequestMethod.GET)

+ 5 - 1
src/main/java/com/goafanti/order/service/OrderNewService.java

@@ -3,6 +3,7 @@ package com.goafanti.order.service;
 import java.util.List;
 
 import com.goafanti.common.model.TDunLog;
+import com.goafanti.common.model.TOrderDun;
 import com.goafanti.common.model.TOrderNew;
 import com.goafanti.common.model.TOrderRefund;
 import com.goafanti.common.model.TOrderRefundWithBLOBs;
@@ -11,6 +12,7 @@ import com.goafanti.core.mybatis.page.Pagination;
 import com.goafanti.order.bo.BillListBo;
 import com.goafanti.order.bo.TDunLogListBo;
 import com.goafanti.order.bo.TOrderNewBo;
+import com.goafanti.order.bo.TOrderTaskBo;
 
 public interface OrderNewService {
 	
@@ -43,7 +45,7 @@ public interface OrderNewService {
 	 * @param orderNo
 	 * @return
 	 */
-	 List<TOrderTask> selectOrderTask(String orderNo);
+	 List<TOrderTaskBo> selectOrderTask(String orderNo);
 	 /**
 	  * 订单提交或保存
 	  * @param t
@@ -120,6 +122,8 @@ public interface OrderNewService {
 	 * @return
 	 */
 	int updateApprovalOrder(String orderNo,Integer confirm,String reason);
+	List<TOrderDun> selectOrderDun(String orderNo);
+	boolean checkOrderMain(TOrderTask t);
 	
 
 	

+ 47 - 7
src/main/java/com/goafanti/order/service/impl/OrderNewServiceImpl.java

@@ -24,6 +24,7 @@ import com.alibaba.fastjson.JSON;
 import com.goafanti.common.bo.Error;
 import com.goafanti.common.constant.AFTConstants;
 import com.goafanti.common.constant.ErrorConstants;
+import com.goafanti.common.dao.OrganizationContactBookMapper;
 import com.goafanti.common.dao.TDunLogMapper;
 import com.goafanti.common.dao.TOrderDunMapper;
 import com.goafanti.common.dao.TOrderMapper;
@@ -33,6 +34,7 @@ import com.goafanti.common.dao.TOrderTaskMapper;
 import com.goafanti.common.dao.UserLockReleaseMapper;
 import com.goafanti.common.enums.UserLockReleaseStatus;
 import com.goafanti.common.error.BusinessException;
+import com.goafanti.common.model.OrganizationContactBook;
 import com.goafanti.common.model.TDunLog;
 import com.goafanti.common.model.TOrder;
 import com.goafanti.common.model.TOrderDetail;
@@ -50,6 +52,7 @@ import com.goafanti.core.shiro.token.TokenManager;
 import com.goafanti.customer.bo.LockingReleaseBo;
 import com.goafanti.order.bo.TDunLogListBo;
 import com.goafanti.order.bo.TOrderNewBo;
+import com.goafanti.order.bo.TOrderTaskBo;
 import com.goafanti.order.enums.ActiveState;
 import com.goafanti.order.enums.ApprovalNewState;
 import com.goafanti.order.enums.LiquidationNewState;
@@ -73,6 +76,8 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
 	@Autowired
 	private TOrderRefundMapper	tOrderRefundMapper;	
 	@Autowired
+	private OrganizationContactBookMapper	organizationContactBookMapper;
+	@Autowired
 	private JDBCIdGenerator	idGenerator;
 	@Autowired
 	private UserLockReleaseMapper	userLockReleaseMapper;
@@ -157,7 +162,7 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
 
 
 	@Override
-	public List<TOrderTask> selectOrderTask(String orderNo) {
+	public List<TOrderTaskBo> selectOrderTask(String orderNo) {
 		return tOrderTaskMapper.selectOrderTask(orderNo);
 	}
 
@@ -165,6 +170,13 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
 
 	@Override
 	public int updateServiceOrder(TOrderNew t, Integer isSubmit) {
+		OrganizationContactBook contactBook=new OrganizationContactBook();
+		contactBook.setId(UUID.randomUUID().toString());
+		contactBook.setAid(TokenManager.getAdminId()==null?"1":TokenManager.getAdminId());
+		contactBook.setUid(t.getBuyerId());
+		contactBook.setName(t.getContacts());
+		contactBook.setMobile(t.getContactMobile());
+		organizationContactBookMapper.insertSelective(contactBook);
 		t.setOrderStatus(isSubmit==1?1:0);
 		return tOrderNewMapper.updateByPrimaryKeySelective(t);
 	}
@@ -196,16 +208,18 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
 					t.setDunBy(TokenManager.getAdminId()==null?"1":TokenManager.getAdminId());
 					tOrderDunMapper.insertSelective(t);
 				}else {
-					tOrderDunMapper.updateByPrimaryKey(t);
+					tOrderDunMapper.updateByPrimaryKeySelective(t);
 				}
+				boolean flag=true;
+				String id="";
 				for (TOrderDun t2 : l2) {
-					boolean flag=true;
 					if (t2.getId().equals(t.getId())) {//查询集合与返回集合比较查出删除项
 						flag=false;
 					}
-					if (flag) {
-						tOrderDunMapper.deleteByPrimaryKey(t2.getId());
-					}
+					id=t2.getId();
+				}
+				if (!id.equals("")&&flag) {
+					tOrderDunMapper.deleteByPrimaryKey(id);
 				}
 			}
 		}
@@ -221,7 +235,7 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
 		Map<String, Object> params = new HashMap<String, Object>();
 		if(pageSize==null||pageSize<0)pageSize=10;
 		if(pageNo==null||pageNo<0)pageNo=1;
-		if (orderStatus==1) {
+		if (orderStatus!=null&&orderStatus==1) {
 			params.put("orderStatus", orderStatus);
 		}else {
 			if (StringUtils.isNotBlank(TokenManager.getAdminId())) params.put("aid", TokenManager.getAdminId()==null?"1":TokenManager.getAdminId());
@@ -309,9 +323,35 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
 			t.setProcessStatus(ProcessStatus.YPZXSGLY.getCode());
 		} else {
 			t.setApproval(3);
+			//TOrderb
 			
 		}
 		return 1;
 	}
+
+
+
+	@Override
+	public List<TOrderDun> selectOrderDun(String orderNo) {
+		
+		return tOrderDunMapper.selectByOrderNoDunSubject(orderNo);
+	}
+
+
+
+	@Override
+	public boolean checkOrderMain(TOrderTask t) {
+		List<TOrderTaskBo> list=tOrderTaskMapper.selectOrderTask(t.getOrderNo());
+		boolean flag=false;
+		for (TOrderTask t2 : list) {
+			if (t2.getMain()==1) {
+				flag=true;
+				if (t.getId()!=null&&t.getId().equals(t2.getId())) {
+					flag=false;
+				}
+			}
+		}
+		return flag;
+	}
 	
 }