yanliming пре 4 година
родитељ
комит
a0f409b193

+ 18 - 0
common/src/main/java/com/jpsoft/bus/modules/base/dao/OrderLogDAO.java

@@ -0,0 +1,18 @@
+package com.jpsoft.bus.modules.base.dao;
+
+import java.util.List;
+import org.springframework.stereotype.Repository;
+import com.jpsoft.bus.modules.base.entity.OrderLog;
+import java.util.Map;
+import com.jpsoft.bus.modules.common.dto.Sort;
+
+@Repository
+public interface OrderLogDAO {
+	int insert(OrderLog entity);
+	int update(OrderLog entity);
+	int exist(String id);
+	OrderLog get(String id);
+	int delete(String id);
+	List<OrderLog> list();
+	List<OrderLog> search(Map<String, Object> searchParams, List<Sort> sortList);
+}

+ 26 - 0
common/src/main/java/com/jpsoft/bus/modules/base/entity/OrderLog.java

@@ -0,0 +1,26 @@
+package com.jpsoft.bus.modules.base.entity;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.text.SimpleDateFormat;
+import java.math.BigDecimal;
+
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+import com.fasterxml.jackson.annotation.JsonFormat;
+
+/**
+  描述:base_order_log的实体类
+ */
+@Data
+public class OrderLog {
+	private String id;
+	private String orderId;
+	private String content;
+	private String createBy;
+	private Date createTime;
+	private String updateBy;
+	private Date updateTime;
+	private Boolean delFlag;
+
+}

+ 1 - 1
common/src/main/java/com/jpsoft/bus/modules/base/service/OrderInfoService.java

@@ -30,5 +30,5 @@ public interface OrderInfoService {
 	 * @return
 	 * @throws Exception
 	 */
-	Boolean refund(String orderId) throws Exception;
+	Boolean refund(String orderId,String userId) throws Exception;
 }

+ 17 - 0
common/src/main/java/com/jpsoft/bus/modules/base/service/OrderLogService.java

@@ -0,0 +1,17 @@
+package com.jpsoft.bus.modules.base.service;
+
+import java.util.List;
+import java.util.Map;
+import com.jpsoft.bus.modules.base.entity.OrderLog;
+import com.github.pagehelper.Page;
+import com.jpsoft.bus.modules.common.dto.Sort;
+
+public interface OrderLogService {
+	OrderLog get(String id);
+	boolean exist(String id);
+	int insert(OrderLog model);
+	int update(OrderLog model);
+	int delete(String id);
+	List<OrderLog> list();
+	Page<OrderLog> pageSearch(Map<String, Object> searchParams, int pageNum, int pageSize, List<Sort> sortList);
+}

+ 13 - 1
common/src/main/java/com/jpsoft/bus/modules/base/service/impl/OrderInfoServiceImpl.java

@@ -5,6 +5,9 @@ import java.util.Map;
 import java.util.UUID;
 import javax.annotation.Resource;
 
+import com.jpsoft.bus.modules.base.dao.OrderLogDAO;
+import com.jpsoft.bus.modules.base.entity.OrderLog;
+import com.jpsoft.bus.modules.base.service.OrderLogService;
 import com.jpsoft.bus.modules.bus.entity.PassengerInfo;
 import com.jpsoft.bus.modules.bus.service.PassengerInfoService;
 import com.jpsoft.bus.modules.pay.service.AlipayService;
@@ -25,6 +28,9 @@ public class OrderInfoServiceImpl implements OrderInfoService {
 	@Resource(name="orderInfoDAO")
 	private OrderInfoDAO orderInfoDAO;
 
+	@Resource(name="orderLogDAO")
+	private OrderLogDAO orderLogDAO;
+
 	@Autowired
 	private AlipayService alipayService;
 
@@ -104,7 +110,7 @@ public class OrderInfoServiceImpl implements OrderInfoService {
 	}
 
 	@Override
-	public Boolean refund(String orderId) throws Exception {
+	public Boolean refund(String orderId,String userId) throws Exception {
 
 		OrderInfo orderInfo = get(orderId);
 		if (orderInfo == null){
@@ -130,6 +136,12 @@ public class OrderInfoServiceImpl implements OrderInfoService {
 		passengerInfo.setPayStatus("0");
 		passengerInfoService.update(passengerInfo);
 
+		OrderLog orderLog = new OrderLog();
+		orderLog.setCreateBy(userId);
+		orderLog.setContent("线上退款成功,退款金额:"+ orderInfo.getPayFee().toString()+"元");
+		orderLog.setOrderId(orderInfo.getId());
+		orderLogDAO.insert(orderLog);
+
 
 		return true;
 	}

+ 70 - 0
common/src/main/java/com/jpsoft/bus/modules/base/service/impl/OrderLogServiceImpl.java

@@ -0,0 +1,70 @@
+package com.jpsoft.bus.modules.base.service.impl;
+
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import javax.annotation.Resource;
+import org.springframework.stereotype.Component;
+import org.springframework.transaction.annotation.Transactional;
+import com.jpsoft.bus.modules.base.dao.OrderLogDAO;
+import com.jpsoft.bus.modules.base.entity.OrderLog;
+import com.jpsoft.bus.modules.base.service.OrderLogService;
+import com.github.pagehelper.Page;
+import com.jpsoft.bus.modules.common.dto.Sort;
+import com.github.pagehelper.PageHelper;
+
+@Transactional
+@Component(value="orderLogService")
+public class OrderLogServiceImpl implements OrderLogService {
+	@Resource(name="orderLogDAO")
+	private OrderLogDAO orderLogDAO;
+
+	@Override
+	public OrderLog get(String id) {
+		// TODO Auto-generated method stub
+		return orderLogDAO.get(id);
+	}
+
+	@Override
+	public int insert(OrderLog model) {
+		// TODO Auto-generated method stub
+		//model.setId(UUID.randomUUID().toString());
+		
+		return orderLogDAO.insert(model);
+	}
+
+	@Override
+	public int update(OrderLog model) {
+		// TODO Auto-generated method stub
+		return orderLogDAO.update(model);		
+	}
+
+	@Override
+	public int delete(String id) {
+		// TODO Auto-generated method stub
+		return orderLogDAO.delete(id);
+	}
+
+	@Override
+	public boolean exist(String id) {
+		// TODO Auto-generated method stub
+		int count = orderLogDAO.exist(id);
+		
+		return count > 0 ? true : false;
+	}
+	
+	@Override
+	public List<OrderLog> list() {
+		// TODO Auto-generated method stub
+		return orderLogDAO.list();
+	}
+		
+	@Override
+	public Page<OrderLog> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize,List<Sort> sortList) {
+        Page<OrderLog> page = PageHelper.startPage(1,10).doSelectPage(()->{
+            orderLogDAO.search(searchParams,sortList);
+        });
+        
+        return page;
+	}
+}

+ 91 - 0
common/src/main/resources/mapper/base/OrderLog.xml

@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<!-- namespace必须指向DAO接口 -->
+<mapper namespace="com.jpsoft.bus.modules.base.dao.OrderLogDAO">
+	<resultMap id="OrderLogMap" type="com.jpsoft.bus.modules.base.entity.OrderLog">
+		<id property="id" column="id_" />
+			<result property="orderId" column="order_id" />
+			<result property="content" column="content_" />
+			<result property="createBy" column="create_by" />
+			<result property="createTime" column="create_time" />
+			<result property="updateBy" column="update_by" />
+			<result property="updateTime" column="update_time" />
+			<result property="delFlag" column="del_flag" />
+			</resultMap>
+	<insert id="insert" parameterType="com.jpsoft.bus.modules.base.entity.OrderLog">
+	<!--
+	<selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
+		select sys_guid() from dual
+	</selectKey>
+	-->
+	<![CDATA[
+		insert into base_order_log
+	    (id_,order_id,content_,create_by,create_time,update_by,update_time,del_flag)
+		values
+		(
+#{id,jdbcType=VARCHAR}
+,#{orderId,jdbcType=VARCHAR}
+,#{content,jdbcType=VARCHAR}
+,#{createBy,jdbcType=VARCHAR}
+,#{createTime,jdbcType= TIMESTAMP }
+,#{updateBy,jdbcType=VARCHAR}
+,#{updateTime,jdbcType= TIMESTAMP }
+,#{delFlag,jdbcType= NUMERIC }
+		)
+	]]>
+	</insert>
+	<delete id="delete" parameterType="string">
+		delete from base_order_log where id_=#{id,jdbcType=VARCHAR}
+	</delete>
+	<update id="update" parameterType="com.jpsoft.bus.modules.base.entity.OrderLog">
+		update base_order_log
+		<set>
+				<if test="orderId!=null">
+		order_id=#{orderId,jdbcType=VARCHAR},
+		</if>
+				<if test="content!=null">
+		content_=#{content,jdbcType=VARCHAR},
+		</if>
+				<if test="createBy!=null">
+		create_by=#{createBy,jdbcType=VARCHAR},
+		</if>
+				<if test="createTime!=null">
+		create_time=#{createTime,jdbcType= TIMESTAMP },
+		</if>
+				<if test="updateBy!=null">
+		update_by=#{updateBy,jdbcType=VARCHAR},
+		</if>
+				<if test="updateTime!=null">
+		update_time=#{updateTime,jdbcType= TIMESTAMP },
+		</if>
+				<if test="delFlag!=null">
+		del_flag=#{delFlag,jdbcType= NUMERIC },
+		</if>
+		</set>
+	where id_=#{id}
+	</update>
+	<select id="get" parameterType="string" resultMap="OrderLogMap">
+		select 
+id_,order_id,content_,create_by,create_time,update_by,update_time,del_flag		from base_order_log where id_=#{0}
+	</select>
+	<select id="exist" parameterType="string" resultType="int">
+		select count(*) from base_order_log where id_=#{0}
+	</select>
+	<select id="list" resultMap="OrderLogMap">
+		select * from base_order_log
+	</select>
+	<select id="search" parameterType="hashmap" resultMap="OrderLogMap">
+		<![CDATA[
+			select * from base_order_log
+		]]>
+		<where>
+			<if test="searchParams.id != null">
+				and ID_ like #{searchParams.id}
+			</if>
+		</where>
+		<foreach item="sort" collection="sortList"  open="order by" separator=",">
+	        ${sort.name} ${sort.order}
+	 	</foreach>
+	</select>
+</mapper>

+ 27 - 0
web/src/main/java/com/jpsoft/bus/modules/base/controller/OrderInfoController.java

@@ -18,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
+import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
 import java.util.*;
 
@@ -319,4 +320,30 @@ public class OrderInfoController {
 
         return msgResult;
     }
+
+
+    @ApiOperation(value = "修改订单状态")
+    @PostMapping("updateOrder")
+    public MessageResult<Boolean> updateOrder(String id, Integer payStatus, @RequestAttribute String subject) {
+        MessageResult<Boolean> msgResult = new MessageResult<>();
+
+        try {
+
+            boolean result = orderInfoService.refund(id,subject);
+
+            if (result) {
+                msgResult.setResult(true);
+                msgResult.setData(result);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("数据库修改失败");
+            }
+        } catch (Exception ex) {
+            logger.error(ex.getMessage(), ex);
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
 }