Browse Source

派单管理查看列表和分配给财务专员

limin 7 years ago
parent
commit
17abd7be59

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

@@ -175,6 +175,6 @@ public interface AdminMapper {
 
 	List<AdminListBo> getListDefaultPassword(String id);
 
-	
+	int getCountById(String id);
 
 }

+ 3 - 0
src/main/java/com/goafanti/common/dao/TOrderNewMapper.java

@@ -117,4 +117,7 @@ public interface TOrderNewMapper {
      * @mbg.generated Mon Nov 19 10:12:37 CST 2018
      */
     int updateByPrimaryKey(TOrderNew record);
+    
+    
+    int getCountByIdAndStatus(TOrderNew orderNew);
 }

+ 7 - 0
src/main/java/com/goafanti/common/mapper/AdminMapper.xml

@@ -954,4 +954,11 @@
   	update admin set status = '锁定' where id in (${lockIds})
   </update>
   
+  <!--  用户是为正常的 -->
+  <select id="getCountById" parameterType="java.lang.String" resultType="java.lang.Integer">
+  	select count(a.id)  from admin a
+   	inner join user_role ur on a.id=ur.uid
+   	where a.id= #{_parameter,jdbcType=VARCHAR} and ( a.status != '注销' or a.status is null)
+  </select>
+  
 </mapper>

+ 135 - 0
src/main/java/com/goafanti/common/mapper/TOrderNewMapper.xml

@@ -795,4 +795,139 @@
       proof_aid = #{proofAid,jdbcType=VARCHAR}
     where order_no = #{orderNo,jdbcType=VARCHAR}
   </update>
+  
+  <!-- 查看所有待财务管理员分配的订单数据 -->
+  <select id="getAllUnassignedListOrder" parameterType="Map" resultType="com.goafanti.order.bo.OrderListBo">
+  	select o.order_no as orderNo, o.order_type orderType, o.create_time as createTime, o.process_status as processStatus
+  	o.sign_time as signTime, u.nickname as buyerName,o.total_amount signTotalAmount, o.approval , a.name sellerName
+  	from t_order_new o 
+  	left join `user` u on o.buyer_id = u.id
+  	left join admin a on o.salesman_id = a.id
+  	where delete_sign = 0
+  	and order_status = 2
+  	<if test="o.processStatus != null">
+  	and process_status = #{o.processStatus,jdbcType=INTEGER}
+  	</if>
+  	<if test='o.orderNo != null and o.orderNo != ""'>
+  	and o.order_no = #{o.orderNo,jdbcType=VARCHAR}
+  	</if>
+  	<if test='o.financeId != null and o.financeId != ""'>
+  	and o.finance_id = #{o.financeId,jdbcType=VARCHAR}
+  	</if>
+  	<if test='o.buyerName != null and o.buyerName != ""'>
+  	<bind name="n" value="'%' + o.buyerName + '%'"/>
+  	and u.nickname  like #{n,jdbcType=VARCHAR}
+  	</if>
+  	<if test='o.startTime != null and o.startTime != "" and o.endTime != null and o.endTime != ""'>
+  	<bind name="a" value="o.startTime + ' 00:00:00'"/>
+  	<bind name="b" value="o.endTime + ' 23:59:59'"/>
+  	and o.sign_time between #{a,jdbcType=VARCHAR} and #{a,jdbcType=VARCHAR}
+  	</if>
+  	<if test="ob = 1">
+  	order by o.sign_time
+  	</if>
+  	<if test="ob = 2">
+  	order by o.liquidation_status,o.sign_time
+  	</if>
+	<if test="page_sql != null">
+		${page_sql}
+	</if>
+  </select>
+  <select id="getAllUnassignedCountOrder" parameterType="Map" resultType="java.lang.Integer">
+  	select count(*)  from t_order_new o 
+  	left join `user` u on o.buyer_id = u.id
+  	left join admin a on o.salesman_id = a.id
+  	where delete_sign = 0
+  	and order_status = 2
+  	<if test="o.processStatus != null">
+  	and process_status = #{o.processStatus,jdbcType=VARCHAR}
+  	</if>
+  	<if test='o.orderNo != null and o.orderNo != ""'>
+  	and o.order_no = #{o.orderNo,jdbcType=VARCHAR}
+  	</if>
+  	<if test='financeId != null and financeId != ""'>
+  	and o.finance_id = #{o.financeId,jdbcType=VARCHAR}
+  	</if>
+  	<if test='o.buyerName != null and o.buyerName != ""'>
+  	<bind name="n" value="'%' + o.buyerName + '%'"/>
+  	and u.nickname  like #{n,jdbcType=VARCHAR}
+  	</if>
+  	<if test='o.startTime != null and o.startTime != "" and o.endTime != null and o.endTime != ""'>
+  	<bind name="a" value="o.startTime + ' 00:00:00'"/>
+  	<bind name="b" value="o.endTime + ' 23:59:59'"/>
+  	and o.sign_time between #{a,jdbcType=VARCHAR} and #{a,jdbcType=VARCHAR}
+  	</if>
+  </select>
+  <!-- 查看某订单状态是否符合要求 -->
+  <select id="getCountByIdAndStatus" parameterType="com.goafanti.common.model.TOrderNew" resultType="java.lang.Integer">
+  		select count(*) from t_order_new 
+  		where order_no = #{orderNo,jdbcType=VARCHAR}
+  	  <if test="orderType != null">
+       and order_type = #{orderType,jdbcType=INTEGER}
+      </if>
+      <if test="creater != null">
+       and creater = #{creater,jdbcType=VARCHAR}
+      </if>
+      <if test="buyerId != null">
+       and buyer_id = #{buyerId,jdbcType=VARCHAR}
+      </if>
+      <if test="firstAmount != null">
+       and first_amount = #{firstAmount,jdbcType=DECIMAL}
+      </if>
+      <if test="totalAmount != null">
+       and total_amount = #{totalAmount,jdbcType=DECIMAL}
+      </if>
+      <if test="settlementAmount != null">
+       and settlement_amount = #{settlementAmount,jdbcType=DECIMAL}
+      </if>
+      <if test="orderStatus != null">
+       and order_status = #{orderStatus,jdbcType=INTEGER}
+      </if>
+      <if test="liquidationStatus == 1">
+       and liquidation_status between 1 and 2 
+      </if>
+      <if test="processStatus != null">
+       and process_status = #{processStatus,jdbcType=INTEGER}
+      </if>
+      <if test="projectStatus != null">
+       and project_status = #{projectStatus,jdbcType=INTEGER}
+      </if>
+      <if test="approval != null">
+       and approval = #{approval,jdbcType=INTEGER}
+      </if>
+      <if test="orderRemarks != null">
+       and order_remarks = #{orderRemarks,jdbcType=VARCHAR}
+      </if>
+      <if test="deleteSign != null">
+       and delete_sign = #{deleteSign,jdbcType=INTEGER}
+      </if>
+      <if test="salesmanId != null">
+       and salesman_id = #{salesmanId,jdbcType=VARCHAR}
+      </if>
+      <if test="financeId != null">
+       and finance_id = #{financeId,jdbcType=VARCHAR}
+      </if>
+      <if test="technicianId != null">
+       and technician_id = #{technicianId,jdbcType=VARCHAR}
+      </if>
+      <if test="contractNo != null">
+       and contract_no = #{contractNo,jdbcType=VARCHAR}
+      </if>
+      <if test="contractType != null">
+       and contract_type = #{contractType,jdbcType=VARCHAR}
+      </if>
+      <if test="contacts != null">
+       and contacts = #{contacts,jdbcType=VARCHAR}
+      </if>
+      <if test="contactMobile != null">
+       and contact_mobile = #{contactMobile,jdbcType=VARCHAR}
+      </if>
+      <if test="legalPerson != null">
+       and legal_person = #{legalPerson,jdbcType=VARCHAR}
+      </if>
+      <if test="legalPersonTel != null">
+       and legal_person_tel = #{legalPersonTel,jdbcType=VARCHAR}
+      </if>
+  </select>
+  
 </mapper>

+ 32 - 0
src/main/java/com/goafanti/order/bo/OrderListBo.java

@@ -38,6 +38,7 @@ public class OrderListBo {
 	private String salesmanName;
 	/** 财务负责人 **/
 	private String financeName;
+	private String financeId;
 	/** 技术员 **/
 	private String technicianName;
 	/** 关联部门名称 **/
@@ -56,6 +57,13 @@ public class OrderListBo {
 	private Integer changeStatus;
 	/** 可操作状态 **/
 	private OperatorActive active;
+	/** 流程状态 **/
+	private Integer processStatus;
+	/** 搜索开始时间 **/
+	private String startTime;
+	/** 搜索结束时间 **/
+	private String endTime;
+	
 	public String getOrderNo() {
 		return orderNo;
 	}
@@ -206,4 +214,28 @@ public class OrderListBo {
 	public void setActive(OperatorActive active) {
 		this.active = active;
 	}
+	public String getFinanceId() {
+		return financeId;
+	}
+	public void setFinanceId(String financeId) {
+		this.financeId = financeId;
+	}
+	public Integer getProcessStatus() {
+		return processStatus;
+	}
+	public void setProcessStatus(Integer processStatus) {
+		this.processStatus = processStatus;
+	}
+	public String getStartTime() {
+		return startTime;
+	}
+	public void setStartTime(String startTime) {
+		this.startTime = startTime;
+	}
+	public String getEndTime() {
+		return endTime;
+	}
+	public void setEndTime(String endTime) {
+		this.endTime = endTime;
+	}
 }

+ 78 - 0
src/main/java/com/goafanti/order/controller/FundManagerOrderApiController.java

@@ -0,0 +1,78 @@
+package com.goafanti.order.controller;
+
+import javax.annotation.Resource;
+
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.goafanti.common.bo.Result;
+import com.goafanti.common.controller.CertifyApiController;
+import com.goafanti.core.shiro.token.TokenManager;
+import com.goafanti.order.bo.OrderListBo;
+import com.goafanti.order.service.FundManageOrderService;
+
+@RestController
+@RequestMapping(value = "/api/admin/financial")
+public class FundManagerOrderApiController extends CertifyApiController {
+	@Resource
+	private FundManageOrderService fundManageOrderServiceImpl;
+	
+	
+	/**
+	 * 财务管理员查看所有待分配的订单
+	 * @param order
+	 * @param pageNo
+	 * @param pageSize
+	 * @return
+	 */
+	@RequestMapping(value="/allUnassignedOrder",method = RequestMethod.GET)
+	public Result allUnassignedOrder(OrderListBo order, Integer pageNo, Integer pageSize ){
+		Result res = new Result();
+		order.setProjectStage(2);
+		res.setData(fundManageOrderServiceImpl.allUnassignedOrder(order, pageNo, pageSize,1));
+		return res;
+	}
+	
+	/**
+	 * 财务管理员分派订单
+	 * @param orderid
+	 * @param financeId
+	 * @return
+	 */
+	@RequestMapping(value="/distributionFinance", method = RequestMethod.POST)
+	public Result distributionFinance(String orderid, String financeId, Integer approval){
+		Result res = new Result();
+		Integer r = fundManageOrderServiceImpl.distributionFinance(orderid, financeId, approval);
+		if(r == -1){
+			res.getError().add(buildError("", "未通过特批不能分配"));
+			return res;
+		}else if( r == -2 ){
+			res.getError().add(buildError("", "订单编号或者财务专员发生异常错误"));
+			return res;
+		}else{
+			res.setData(r);
+		}
+		return res;
+	}
+	
+	/**
+	 * 财务专员查看分配给自己的订单
+	 * @param order
+	 * @param pageNo
+	 * @param pageSize
+	 * @return
+	 */
+	@RequestMapping(value="/financeList", method = RequestMethod.GET)
+	public Result financeList(OrderListBo order, Integer pageNo, Integer pageSize ){
+		Result res = new Result();
+		//财务专员自己的id
+		order.setFinanceId(TokenManager.getUserId());
+		order.setProjectStage(3);
+		res.setData(fundManageOrderServiceImpl.allUnassignedOrder(order, pageNo, pageSize,2));
+		return res;
+	}
+	
+	
+	
+}

+ 26 - 0
src/main/java/com/goafanti/order/service/FundManageOrderService.java

@@ -0,0 +1,26 @@
+package com.goafanti.order.service;
+
+import com.goafanti.core.mybatis.page.Pagination;
+import com.goafanti.order.bo.OrderListBo;
+
+public interface FundManageOrderService {
+	
+	/**
+	 * 财务管理员查看所有未派单的订单
+	 * @param order 与订单相关的查询条件
+	 * @param pageNo
+	 * @param PageSize
+	 * @return
+	 */
+	Pagination<OrderListBo> allUnassignedOrder(OrderListBo order,Integer pageNo,Integer pageSize,Integer ob);
+
+	/**
+	 * 财务管理员分派订单给财务专员
+	 * @param orderid 
+	 * @param financeId
+	 * @return
+	 */
+	Integer distributionFinance(String orderid, String financeId, Integer approval);
+
+	
+}

+ 71 - 0
src/main/java/com/goafanti/order/service/impl/FundManagerOrderServiceImpl.java

@@ -0,0 +1,71 @@
+package com.goafanti.order.service.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.goafanti.common.dao.AdminMapper;
+import com.goafanti.common.dao.TOrderNewMapper;
+import com.goafanti.common.model.TOrderNew;
+import com.goafanti.core.mybatis.BaseMybatisDao;
+import com.goafanti.core.mybatis.page.Pagination;
+import com.goafanti.order.bo.OrderListBo;
+import com.goafanti.order.service.FundManageOrderService;
+
+@Service
+public class FundManagerOrderServiceImpl extends BaseMybatisDao<TOrderNewMapper> implements FundManageOrderService {
+	
+	@Autowired
+	private TOrderNewMapper	tOrderNewMapper;
+	@Autowired
+	private AdminMapper	adminMapper;
+
+	@SuppressWarnings("unchecked")
+	@Override
+	public Pagination<OrderListBo> allUnassignedOrder(OrderListBo order, Integer pageNo,
+			Integer pageSize,Integer ob) {
+		Map<String, Object> params = new HashMap<String, Object>();
+		params.put("o", order);
+		params.put("ob", ob);
+		Pagination<OrderListBo> data = (Pagination<OrderListBo>)findPage("getAllUnassignedListOrder", "getAllUnassignedCountOrder", params, pageNo, pageSize);
+		return data;
+	}
+	
+	@Override
+	public Integer distributionFinance(String orderid, String financeId, Integer approval) {
+		// 先判断订单id和财务专员是否存在或者能够使用
+		TOrderNew onew = new TOrderNew();
+		//判断是不是特批的数据
+		if(approval == 0){
+			onew.setLiquidationStatus(1);//看有没有付钱
+		}else if(approval != 2){//特批未通过
+			return -1;
+		}
+		onew.setOrderNo(orderid);
+		onew.setDeleteSign(0);//正常
+		onew.setProcessStatus(2);//已派财务管理员
+		onew.setApproval(approval);//特批状态
+		onew.setOrderStatus(2);//营销管理员审核通过
+		
+		int idCount = tOrderNewMapper.getCountByIdAndStatus(onew);
+		int fidCount = adminMapper.getCountById(financeId);
+		Integer r = null;
+		if(idCount == 1 && fidCount == 1){
+			//修改订单流程状态
+			TOrderNew record = new TOrderNew();
+			record.setOrderNo(orderid);
+			record.setFinanceId(financeId);
+			record.setProjectStatus(3);
+			r = tOrderNewMapper.updateByPrimaryKeySelective(record);
+		}else{
+			//返回错误标志 提示订单编号或者财务专员选择错误
+			r = -2;
+		}
+		return r;
+	}
+	
+
+	
+}