Browse Source

合同变更修改

anderx 6 years ago
parent
commit
868edb5da1

+ 1 - 1
GeneratorConfig.xml

@@ -9,6 +9,6 @@
     <javaModelGenerator targetPackage="com.goafanti.common.model" targetProject="kede-server" />
     <sqlMapGenerator targetPackage="com.goafanti.common.mapper" targetProject="kede-server" />
     <javaClientGenerator targetPackage="com.goafanti.common.dao" targetProject="kede-server" type="XMLMAPPER" />
-    <table schema="aft" tableName="new_order_change"/>
+    <table schema="aft" tableName="order_refund_invoice"/>
   </context>
 </generatorConfiguration>

+ 5 - 0
src/main/java/com/goafanti/common/dao/TOrderBillNewMapper.java

@@ -7,6 +7,7 @@ import org.apache.ibatis.annotations.Param;
 
 import com.goafanti.common.model.TOrderBillNew;
 import com.goafanti.common.model.TOrderBillNewExample;
+import com.goafanti.order.bo.BillBo;
 
 public interface TOrderBillNewMapper {
     /**
@@ -106,4 +107,8 @@ public interface TOrderBillNewMapper {
     List<TOrderBillNew> getDeptBySome(TOrderBillNew ob);
     
     List<TOrderBillNew> getBillData(TOrderBillNew ob);
+
+	BigDecimal conutAmountByOrderNo(String orderNo);
+
+	List<BillBo> selectByOrderNo(String orderNo);
 }

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

@@ -2,8 +2,10 @@ package com.goafanti.common.dao;
 
 import com.goafanti.common.model.TOrderInvoice;
 import com.goafanti.common.model.TOrderInvoiceExample;
+import com.goafanti.order.bo.InvoiceBo;
 import com.goafanti.order.bo.TOrderInvoiceDetails;
 
+import java.math.BigDecimal;
 import java.util.List;
 import org.apache.ibatis.annotations.Param;
 
@@ -78,4 +80,8 @@ public interface TOrderInvoiceMapper {
 	String checkApplyAmount(@Param("orderNo")String orderNo,@Param("id")Integer id);
 
 	TOrderInvoiceDetails selectByInvoiceDitails(Integer id);
+
+	 BigDecimal conutAmountByOrderNo(String orderNo);
+
+	List<InvoiceBo> selectByOrderNo(String orderNo);
 }

+ 9 - 0
src/main/java/com/goafanti/common/mapper/TOrderBillNewMapper.xml

@@ -612,4 +612,13 @@
   	</if>
   	order by b.order_no, b.creater , b.financial_pay_time
  </select>
+ <select id="conutAmountByOrderNo">
+ select ifnull(sum(a.transaction_amount),0) amount from t_order_bill_new a
+where  a.order_no= #{orderNo,jdbcType=VARCHAR};
+ </select>
+ <select id="selectByOrderNo" resultType="com.goafanti.order.bo.BillBo">
+ select date_format(a.financial_pay_time,'%Y-%m-%d') payTime,a.transaction_amount transactionAmount,b.name aName from t_order_bill_new a 
+left join admin b on a.creater=b.id
+where order_no= #{orderNo,jdbcType=VARCHAR};	
+ </select>
 </mapper>

+ 8 - 0
src/main/java/com/goafanti/common/mapper/TOrderInvoiceMapper.xml

@@ -798,4 +798,12 @@
 	left join t_order_new b on a.order_no=b.order_no
     where id = #{id,jdbcType=INTEGER}
   </select>
+  <select id="conutAmountByOrderNo" >
+  select ifnull(sum(a.amount),0) amount from t_order_invoice a
+	where a.status=2 and a.order_no= #{orderNo,jdbcType=VARCHAR}
+  </select>
+  <select id="selectByOrderNo" resultType="com.goafanti.order.bo.InvoiceBo">
+  select date_format(a.create_time,'%Y-%m-%d %H:%i:%S') createTime,a.amount from t_order_invoice a
+where a.status=2 and a.order_no=  #{orderNo,jdbcType=VARCHAR}
+  </select>
 </mapper>

+ 5 - 7
src/main/java/com/goafanti/common/mapper/TOrderNewMapper.xml

@@ -935,13 +935,12 @@
   	<if test="o.outsource == 1">
   	and f.refund_status=1
   	</if>
-  	and process_status &gt;= 2 and process_status &lt; 7
+  	
   	<if test="o.processStatus == 2">
-  	and (o.finance_id is null or o.finance_id='') 
+  	and process_status = 2 
   	</if>
   	<if test="o.processStatus == 3">
-  	and o.finance_id is not null 
-  	and o.finance_id != ''    
+  	and process_status &gt;= 2 and process_status &lt; 7
   	</if>
   	<if test="o.departmentId != null and o.departmentId != &quot;&quot;">
   	and o.order_dep= #{o.departmentId,jdbcType=VARCHAR}
@@ -979,12 +978,11 @@
   	<if test="o.outsource == 1">
   	and f.refund_status=1
   	</if>
-  	and process_status &gt;= 2 and process_status &lt; 7
   	<if test="o.processStatus == 2">
-  	and (o.finance_id is null or o.finance_id='')
+  	and process_status = 2 
   	</if>
   	<if test="o.processStatus == 3">
-  	and o.finance_id is not null and o.finance_id != ''    
+  	and process_status &gt; 2 and process_status &lt; 7
   	</if>
   	<if test="o.departmentId != null and o.departmentId != &quot;&quot;">
   	and o.order_dep= #{o.departmentId,jdbcType=VARCHAR}

+ 0 - 1
src/main/java/com/goafanti/common/model/BaseModel.java

@@ -11,7 +11,6 @@ public class BaseModel implements Serializable {
 	 * 
 	 */
 	private static final long	serialVersionUID	= 1L;
-
 	private String				id;
 
 	@Override

+ 73 - 4
src/main/java/com/goafanti/order/controller/OrderChangeApiController.java

@@ -13,6 +13,8 @@ import org.springframework.web.bind.annotation.RestController;
 import com.goafanti.common.bo.Result;
 import com.goafanti.common.constant.ErrorConstants;
 import com.goafanti.common.controller.CertifyApiController;
+import com.goafanti.common.model.OrderRefundInvoice;
+import com.goafanti.common.utils.StringUtils;
 import com.goafanti.order.bo.NewOrderChangeBo;
 import com.goafanti.order.service.OrderChangeService;
 
@@ -28,7 +30,7 @@ public class OrderChangeApiController extends CertifyApiController {
 	 *  新增变更
 	 */
 	@RequestMapping(value = "/addOrderChange", method = RequestMethod.POST)
-	public Result addOrderChange(NewOrderChangeBo t){
+	public Result addOrderChange(NewOrderChangeBo t,String startRemarks){
 		Result res = new Result();
 		if(null==t.getOrderNo()){
 			res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "订单编号"));
@@ -38,7 +40,7 @@ public class OrderChangeApiController extends CertifyApiController {
 			res.getError().add(buildError( "", "订单变更未完成"));
 			return res;
 		}
-		res.setData(orderChangeService.addOrderChange(t));
+		res.setData(orderChangeService.addOrderChange(t,startRemarks));
 		return res;
 	}
 	/**
@@ -88,7 +90,7 @@ public class OrderChangeApiController extends CertifyApiController {
 	 *   变更审核
 	 */
 	@RequestMapping(value = "/orderChangeAudit", method = RequestMethod.POST)
-	public Result orderChangeAudit(String orderNo,String remarks,Integer status,Integer processState){
+	public Result orderChangeAudit(String orderNo,String remarks,Integer status,Integer processState,Integer rejectState){
 		Result res = new Result();
 		if(null==orderNo){
 			res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "订单编号", "订单编号"));
@@ -102,7 +104,7 @@ public class OrderChangeApiController extends CertifyApiController {
 			res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "审核批示", "审核批示"));
 			return res;
 		}
-		res.setData(orderChangeService.pushOrderChangeAudit( orderNo, remarks, status, processState));
+		res.setData(orderChangeService.pushOrderChangeAudit( orderNo, remarks, status, processState,rejectState));
 		return res;
 	}
 	/**
@@ -139,4 +141,71 @@ public class OrderChangeApiController extends CertifyApiController {
 				depId, salesmanName, complete,pageSize,  pageNo));
 		return res;
 	}
+	/**
+	 *  新增回收发票
+	 */
+	@RequestMapping(value ="/addOrderRefundInvoice",method = RequestMethod.POST)
+	public Result addOrderRefundInvoice(OrderRefundInvoice o) {
+		Result res =new Result();
+		if (o.getAmount()==null) {
+			res.getError().add(buildError("金额不能为空", "金额不能为空"));
+			return res;
+		}
+		res.data(orderChangeService.addOrderRefundInvoice(o));
+		return res;
+	}
+	/**
+	 *  删除回收发票
+	 */
+	@RequestMapping(value ="/deleteOrderRefundInvoice",method = RequestMethod.POST)
+	public Result deleteOrderRefundInvoice(Integer id) {
+		Result res =new Result();
+		if (id==null) {
+			res.getError().add(buildError("id不能为空", "id不能为空"));
+			return res;
+		}
+		res.data(orderChangeService.deleteOrderRefundInvoice(id));
+		return res;
+	}
+	/**
+	 *  回收发票列表
+	 */
+	@RequestMapping(value ="/listOrderRefundInvoice",method = RequestMethod.GET)
+	public Result listOrderRefundInvoice(String orderNo) {
+		Result res =new Result();
+		if (StringUtils.isBlank(orderNo)) {
+			res.getError().add(buildError("订单编号不能为空", "订单编号不能为空"));
+			return res;
+		}
+		res.data(orderChangeService.listOrderRefundInvoice(orderNo));
+		return res;
+	}
+	
+	/**
+	 *  回收发票列表
+	 */
+	@RequestMapping(value ="/listOrderInvoiceAndBill",method = RequestMethod.GET)
+	public Result listOrderInvoiceAndBill(String orderNo) {
+		Result res =new Result();
+		if (StringUtils.isBlank(orderNo)) {
+			res.getError().add(buildError("订单编号不能为空", "订单编号不能为空"));
+			return res;
+		}
+		res.data(orderChangeService.listOrderInvoiceAndBill(orderNo));
+		return res;
+	}
+	/**
+	 * 完成变更
+	 */
+	@RequestMapping(value ="/completeOrderChange",method = RequestMethod.GET)
+	public Result completeOrderChange(NewOrderChangeBo nb) {
+		Result res =new Result();
+		if (StringUtils.isBlank(nb.getOrderNo())||nb.getType()==null) {
+			res.getError().add(buildError("订单编号和类型不能为空", "订单编号和类型不能为空"));
+			return res;
+		}
+		res.data(orderChangeService.pushCompleteOrderChange(nb));
+		return res;
+	}
+	
 }

+ 16 - 2
src/main/java/com/goafanti/order/service/OrderChangeService.java

@@ -1,18 +1,21 @@
 package com.goafanti.order.service;
 
 import java.util.List;
+import java.util.Map;
 
+import com.goafanti.common.model.OrderRefundInvoice;
 import com.goafanti.core.mybatis.page.Pagination;
 import com.goafanti.order.bo.NewOrderChangeBo;
+import com.goafanti.order.bo.OrderChangeBo;
 import com.goafanti.order.bo.OrderChangeLogBo;
 
 public interface OrderChangeService {
 
-	int addOrderChange(NewOrderChangeBo t);
+	int addOrderChange(NewOrderChangeBo t, String startRemarks);
 
 	NewOrderChangeBo orderChangeDetails(String orderNo);
 
-	int pushOrderChangeAudit(String orderNo, String remarks, Integer status,Integer processState);
+	int pushOrderChangeAudit(String orderNo, String remarks, Integer status,Integer processState, Integer rejectState);
 
 	boolean checkOderNo(String orderNo);
 
@@ -25,6 +28,17 @@ public interface OrderChangeService {
 
 	NewOrderChangeBo orderChangeDetailsById(Integer id);
 
+	int addOrderRefundInvoice(OrderRefundInvoice o);
+
+	int deleteOrderRefundInvoice(Integer id);
+
+	List<OrderRefundInvoice> listOrderRefundInvoice(String orderNo);
+
+	int pushCompleteOrderChange(NewOrderChangeBo nb);
+
+	Map<String ,Object> listOrderInvoiceAndBill(String orderNo);
+
+
 
 
 }

+ 57 - 10
src/main/java/com/goafanti/order/service/impl/OrderChangeServiceImpl.java

@@ -2,6 +2,7 @@ package com.goafanti.order.service.impl;
 
 import java.math.BigDecimal;
 import java.text.ParseException;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -14,12 +15,16 @@ import com.goafanti.common.bo.Error;
 import com.goafanti.common.constant.AFTConstants;
 import com.goafanti.common.dao.NewOrderChangeMapper;
 import com.goafanti.common.dao.OrderChangeLogMapper;
+import com.goafanti.common.dao.OrderRefundInvoiceMapper;
+import com.goafanti.common.dao.TOrderBillNewMapper;
 import com.goafanti.common.dao.TOrderDunMapper;
+import com.goafanti.common.dao.TOrderInvoiceMapper;
 import com.goafanti.common.dao.TOrderLogMapper;
 import com.goafanti.common.dao.TOrderNewMapper;
 import com.goafanti.common.dao.TOrderTaskMapper;
 import com.goafanti.common.error.BusinessException;
 import com.goafanti.common.model.OrderChangeLog;
+import com.goafanti.common.model.OrderRefundInvoice;
 import com.goafanti.common.model.TOrderDun;
 import com.goafanti.common.model.TOrderNew;
 import com.goafanti.common.model.NewOrderChange;
@@ -29,7 +34,10 @@ import com.goafanti.core.mybatis.BaseMybatisDao;
 import com.goafanti.core.mybatis.JDBCIdGenerator;
 import com.goafanti.core.mybatis.page.Pagination;
 import com.goafanti.core.shiro.token.TokenManager;
+import com.goafanti.order.bo.BillBo;
+import com.goafanti.order.bo.InvoiceBo;
 import com.goafanti.order.bo.NewOrderChangeBo;
+import com.goafanti.order.bo.OrderChangeBo;
 import com.goafanti.order.bo.OrderChangeLogBo;
 import com.goafanti.order.bo.TOrderLogBo;
 import com.goafanti.order.bo.TOrderTaskBo;
@@ -50,6 +58,12 @@ public class OrderChangeServiceImpl extends BaseMybatisDao<NewOrderChangeMapper>
 	@Autowired
 	private TOrderTaskMapper	tOrderTaskMapper;
 	@Autowired
+	private TOrderBillNewMapper	tOrderBillNewMapper;
+	@Autowired
+	private TOrderInvoiceMapper	tOrderInvoiceMapper;
+	@Autowired
+	private OrderRefundInvoiceMapper	orderRefundInvoiceMapper;
+	@Autowired
 	private OrderService	orderService;
 	@Autowired
 	private JDBCIdGenerator	idGenerator;
@@ -57,18 +71,22 @@ public class OrderChangeServiceImpl extends BaseMybatisDao<NewOrderChangeMapper>
 	
 	
 	@Override
-	public int addOrderChange(NewOrderChangeBo t) {
+	public int addOrderChange(NewOrderChangeBo t,String startRemarks) {
 		TOrderNew ton=new TOrderNew();
 		ton.setOrderNo(t.getOrderNo());
 		ton.setDeleteSign(2);//将订单置为锁定
 		t.setProcessState(1);//设置营销管理员来审核
 		tOrderNewMapper.updateByPrimaryKeySelective(ton);
+		BigDecimal invoiceAmount=tOrderInvoiceMapper.conutAmountByOrderNo(t.getOrderNo());
+		t.setInvoiceAmount(invoiceAmount);//开票金额
+		BigDecimal paymentAmount=tOrderBillNewMapper.conutAmountByOrderNo(t.getOrderNo());
+		t.setPaymentAmount(paymentAmount);//收款金额
 		newOrderChangeMapper.insertSelective(t);
 		NewOrderChangeBo ncb=newOrderChangeMapper.selectByorderNo(t.getOrderNo());
 		OrderChangeLog ocl=new OrderChangeLog();
 		ocl.setAuditor(TokenManager.getAdminId());
 		ocl.setOrderNo(t.getOrderNo());
-		ocl.setRemarks("发起了订单变更");
+		ocl.setRemarks(startRemarks);
 		ocl.setChangeId(ncb.getId());
 		ocl.setStatus(0);
 		orderChangeLogMapper.insertSelective(ocl);
@@ -85,7 +103,7 @@ public class OrderChangeServiceImpl extends BaseMybatisDao<NewOrderChangeMapper>
 		return nb;
 	}
 	@Override
-	public int pushOrderChangeAudit(String orderNo, String remarks, Integer status,Integer processState) {
+	public int pushOrderChangeAudit(String orderNo, String remarks, Integer status,Integer processState,Integer rejectState) {
 		NewOrderChangeBo nb=newOrderChangeMapper.selectByorderNo(orderNo);
 		if (processState==null||(nb.getProcessState()!=9&&processState !=nb.getProcessState()) ) {
 			throw new BusinessException(new Error( "变更流程与您所操作流程不匹配","变更流程与您所操作流程不匹配"));
@@ -96,10 +114,10 @@ public class OrderChangeServiceImpl extends BaseMybatisDao<NewOrderChangeMapper>
 		//2通过 3驳回
 		if (status==2) {
 			//变更类型 0退单退款 1项目及金额变更 2仅项目变更 3仅金额变更 4重报 5赠送
-			if(nb.getType()==0){
+			if(nb.getType() !=null){
 				if (nb.getChangeAmount().compareTo(new BigDecimal("0.2"))<0) {//小于则总裁通过,大于则董事长
 					if(nb.getProcessState()==7) {//项目变更通过
-						changgeAdopt(nb);
+						//changgeAdopt(nb); 取消订单变更完成
 						}else if(nb.getProcessState()==1){
 							nb.setProcessState(3);
 						}else{
@@ -107,21 +125,23 @@ public class OrderChangeServiceImpl extends BaseMybatisDao<NewOrderChangeMapper>
 							}
 				}else {
 					if(nb.getProcessState()==8) {//项目变更通过
-						changgeAdopt(nb);
+						//changgeAdopt(nb); 取消订单变更完成
 						}else if(nb.getProcessState()==1){
 							nb.setProcessState(3);
 						} else{
 							nb.setProcessState(nb.getProcessState()+1);
 							}
 				}
-			}else {
-				if(nb.getProcessState()==9) {changgeAdopt(nb);}//项目变更通过
+			}/*else {
+				if(nb.getProcessState()==9) {
+					//changgeAdopt(nb); 取消订单变更完成
+					}
 				//流程状态 0营销员 1营销管理员 2技术员 3技术经理 4技术总监 5财务专员(退单) 6财务总监 7总裁 8董事长 9 财务专员(非退单)
 				if (nb.getProcessState()==1) nb.setProcessState(7);
 				else if (nb.getProcessState()==7)nb.setProcessState(9);
-			}
+			}*/ //去掉第二条线
 		}else {
-			nb.setProcessState(0);
+			nb.setProcessState(rejectState);
 			nb.setStatus(3);//订单变更设置为驳回
 		}
 		OrderChangeLog ocl=new OrderChangeLog();
@@ -256,6 +276,33 @@ public class OrderChangeServiceImpl extends BaseMybatisDao<NewOrderChangeMapper>
 		}
 		return newOrderChangeMapper.updateByPrimaryKeySelective(noc);
 	}
+	@Override
+	public int addOrderRefundInvoice(OrderRefundInvoice o) {
+		o.setCreateTime(new Date());
+		return orderRefundInvoiceMapper.insertSelective(o);
+	}
+	@Override
+	public int deleteOrderRefundInvoice(Integer id) {
+		return orderRefundInvoiceMapper.deleteByPrimaryKey(id);
+	}
+	@Override
+	public List<OrderRefundInvoice> listOrderRefundInvoice(String orderNo) {
+		return orderRefundInvoiceMapper.selectByorderNo(orderNo);
+	}
+	@Override
+	public int pushCompleteOrderChange(NewOrderChangeBo nb) {
+		changgeAdopt(nb);
+		return 1;
+	}
+	@Override
+	public Map<String, Object> listOrderInvoiceAndBill(String orderNo) {
+		Map<String, Object> map=new HashMap<>();
+		List<BillBo>list=tOrderBillNewMapper.selectByOrderNo(orderNo);
+		List<InvoiceBo>list2=tOrderInvoiceMapper.selectByOrderNo(orderNo);
+		map.put("bill", list);
+		map.put("invoice", list2);
+		return map;
+	}
 	
 
 }