From c253b555c7905c5136d47cd615ef545fa50cc6ad Mon Sep 17 00:00:00 2001
From: 935090232@qq.com <ak473600000>
Date: Sun, 20 Feb 2022 21:24:16 +0800
Subject: [PATCH] Merge branch 'api_score_meger'

---
 zq-erp/src/main/resources/mybatis/mapper/hive/SysOrderFlowDao.xml |  195 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 195 insertions(+), 0 deletions(-)

diff --git a/zq-erp/src/main/resources/mybatis/mapper/hive/SysOrderFlowDao.xml b/zq-erp/src/main/resources/mybatis/mapper/hive/SysOrderFlowDao.xml
new file mode 100644
index 0000000..55817bf
--- /dev/null
+++ b/zq-erp/src/main/resources/mybatis/mapper/hive/SysOrderFlowDao.xml
@@ -0,0 +1,195 @@
+<?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">
+<mapper namespace="com.matrix.system.hive.dao.SysOrderFlowDao">
+
+    <resultMap id="SysOrderFlowMap" type="SysOrderFlow">
+        <id property="id" column="id" />
+        <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="flowNo" column="flow_no" />
+        <result property="orderId" column="order_id" />
+        <result property="flowContent" column="flow_content" />
+        <result property="flowType" column="flow_type" />
+        <result property="amount" column="amount" />
+        <result property="vipId" column="vip_id" />
+        <result property="payMethod" column="pay_method" />
+        <result property="cardId" column="card_id" />
+        <result property="cardName" column="card_name" />
+        <result property="isGift" column="is_gift" />
+
+		<result property="orderNo" column="order_no" />
+    </resultMap>
+
+    <insert id="insert" parameterType="SysOrderFlow" useGeneratedKeys="true"
+            keyProperty="id">
+		INSERT INTO sys_order_flow (
+		ID,
+		create_by,
+		create_time,
+		update_by,
+		update_time,
+		flow_no,
+		order_id,
+		flow_content,
+		flow_type,
+		amount,
+		vip_id,
+		pay_method,
+		card_id,
+		is_gift,
+		shop_id,
+		company_id
+		)
+		VALUES (
+		#{id},
+		#{createBy},
+		now(),
+		#{updateBy},
+		now(),
+		#{flowNo},
+		#{orderId},
+		#{flowContent},
+		#{flowType},
+		#{amount},
+		#{vipId},
+		#{payMethod},
+		#{cardId},
+		#{isGift},
+		#{shopId},
+		#{companyId}
+		)
+	</insert>
+	<update id="updateTimeByOrderId">
+		UPDATE sys_order_flow set
+		create_time=#{payTime}
+		where order_id=#{orderId}
+	</update>
+    <delete id="deleteByOrderId">
+		delete from sys_order_flow where order_id=#{orderId}
+	</delete>
+
+    <select id="selectByOrderId" resultMap="SysOrderFlowMap">
+		select a.*, b.order_no,c.card_name from sys_order_flow a
+		left join sys_order b on a.order_id=b.id
+		left join money_card_use c on a.card_id=c.id
+		where order_id=#{orderId}
+	</select>
+
+	<select id="selectPayMethodsAmountByOrderId" resultMap="SysOrderFlowMap">
+		select
+			pay_method,
+			sum(amount) amount
+		from sys_order_flow
+		where order_id=#{orderId}
+		group by pay_method
+	</select>
+
+	<select id="selectInPage" resultType="com.matrix.system.hive.vo.OrderFlowVo">
+		SELECT
+		a.id,
+		b.id as orderId,
+		a.create_time as createTime,
+		b.ORDER_NO as orderNo,
+		a.flow_content as flowContent,
+		a.flow_type as flowType,
+		a.amount as amount,
+		c.VIP_NAME as vipName,
+		a.pay_method as payMethod,
+		a.flow_no as flowNo,
+		d.shop_short_name as shopName,
+		f.card_name as cardName,
+		e.su_name as staffName
+		from sys_order_flow a
+		LEFT JOIN sys_order b on a.order_id=b.ID
+		LEFT JOIN sys_vip_info c on a.vip_id=c.ID
+		LEFT JOIN sys_shop_info d on a.shop_id=d.ID
+		LEFT JOIN sys_users e on e.su_id=b.STAFF_ID
+		left join money_card_use f on a.card_id=f.id
+
+		<where>
+
+				and a.company_id=#{record.companyId}
+
+			<if test="record.queryKey != null and record.queryKey != ''">
+				and (instr(c.vip_name, #{record.queryKey}) or instr(c.phone, #{record.queryKey}) )
+			</if>
+			<if test="record.oprationMan != null and record.oprationMan != ''">
+				and instr(e.su_name, #{record.oprationMan})
+			</if>
+			<if test="record.orderNo != null and record.orderNo != ''">
+				and instr(b.ORDER_NO, #{record.orderNo})
+			</if>
+			<if test="record.payMethod != null and record.payMethod != ''">
+				and a.pay_method=#{record.payMethod}
+			</if>
+
+			<if test="record.flowType != null and record.flowType != ''">
+				and a.flow_type=#{record.flowType}
+			</if>
+
+			<if test="record.startTime != null ">
+				and a.create_time >= #{record.startTime}
+			</if>
+			<if test="record.endTime != null   ">
+				<![CDATA[and a.create_time <= #{record.endTime}]]>
+			</if>
+			<if test="record.shopId != null and record.shopId != ''">
+				and a.shop_id=#{record.shopId}
+			</if>
+		</where>
+		<if test="record.sort !=null">
+			order by
+			a.${record.sort} ${record.order}
+		</if>
+		<if test="record.offset >=0  and record.limit >0">
+			limit
+			#{record.offset},#{record.limit}
+		</if>
+
+
+	</select>
+
+	<select id="selectTotal" resultType="java.lang.Integer">
+		SELECT count(*)
+		from sys_order_flow a
+		LEFT JOIN sys_order b on a.order_id=b.ID
+		LEFT JOIN sys_vip_info c on a.vip_id=c.ID
+		LEFT JOIN sys_shop_info d on a.shop_id=d.ID
+		LEFT JOIN sys_users e on e.su_id=b.STAFF_ID
+		<where>
+
+			and a.company_id=#{record.companyId}
+
+			<if test="record.queryKey != null and record.queryKey != ''">
+				and (instr(c.vip_name, #{record.queryKey}) or instr(c.phone, #{record.queryKey}) )
+			</if>
+			<if test="record.oprationMan != null and record.oprationMan != ''">
+				and instr(e.su_name, #{record.oprationMan})
+			</if>
+			<if test="record.orderNo != null and record.orderNo != ''">
+				and instr(b.ORDER_NO, #{record.orderNo})
+			</if>
+			<if test="record.payMethod != null and record.payMethod != ''">
+				and a.pay_method=#{record.payMethod}
+			</if>
+
+			<if test="record.flowType != null and record.flowType != ''">
+				and a.flow_type=#{record.flowType}
+			</if>
+
+			<if test="record.startTime != null ">
+				and a.create_time >= #{record.startTime}
+			</if>
+			<if test="record.endTime != null   ">
+				<![CDATA[and a.create_time <= #{record.endTime}]]>
+			</if>
+			<if test="record.shopId != null and record.shopId != ''">
+				and a.shop_id=#{record.shopId}
+			</if>
+
+		</where>
+	</select>
+
+</mapper>
\ No newline at end of file

--
Gitblit v1.9.1