INSERT INTO sys_order (
ID,
VIP_ID,
ORDER_TIME,
REMARK,
STAFF_ID,
IS_CROSS,
ORDER_NO,
ACTIVITY,
TOTAL,
card_Pay,
STATU,
arrears,
ZK_TOTAL,
SHOP_ID,
CHANGE_ID,
cash_Pay,
beatuyId,
beatuyName,
pay_time,
company_id,
orderType,
is_has_refund,
cashier_id
)
VALUES (
#{id},
#{vipId},
#{orderTime},
#{remark},
#{staffId},
#{isCross},
#{orderNo},
#{activity},
#{total},
#{cardPay},
#{statu},
#{arrears},
#{zkTotal},
#{shopId},
#{changeId},
#{cashPay},
#{beatuyId},
#{beatuyName},
#{payTime},
#{companyId},
#{orderType},
#{isHasRefund},
#{cashierId}
)
UPDATE sys_order
set pay_time = #{payTime}
WHERE id=#{id}
UPDATE sys_order
VIP_ID = #{vipId},
ORDER_TIME = #{orderTime},
REMARK = #{remark},
STAFF_ID = #{staffId},
IS_CROSS = #{isCross},
ORDER_NO = #{orderNo},
ACTIVITY = #{activity},
TOTAL = #{total},
card_Pay = #{cardPay},
arrears = #{arrears},
STATU = #{statu},
ZK_TOTAL = #{zkTotal},
CHANGE_ID = #{changeId},
cash_Pay = #{cashPay},
pay_time = #{payTime},
is_has_refund = #{isHasRefund},
cashier_id = #{cashierId},
WHERE id=#{id}
delete from sys_order where ID in
#{item}
DELETE FROM sys_order
where ID=#{id}
select
a.*, b.VIP_NAME, c.su_name as STAFF_NAME, e.su_name as cashierName,
d.SHOP_NAME, b.PHONE
from sys_order a
LEFT JOIN sys_vip_info b on b.ID=a.VIP_ID
left JOIN sys_users c on c.su_id=a.STAFF_ID
left JOIN sys_users e on e.su_id=a.cashier_id
left JOIN sys_shop_info d on d.ID=a.SHOP_ID
where 1=1
and (b.PHONE like concat('%',#{record.keyWordVo},'%')
or b.vip_no like concat('%',#{record.keyWordVo},'%')
or b.vip_name like concat('%',#{record.keyWordVo},'%') )
and a.ID = #{record.id}
and b.vip_name like concat('%',#{record.vipName},'%')
and b.PHONE like concat('%',#{record.vipPhone},'%')
and a.ID = #{record.id}
and a.VIP_ID = #{record.vipId}
and a.ORDER_TIME = #{record.orderTime}
and a.STAFF_ID = #{record.staffId}
and a.cashier_id = #{record.cashierId}
and a.IS_CROSS = #{record.isCross}
and a.ORDER_NO LIKE CONCAT('%',#{record.orderNo},'%')
and a.ACTIVITY = #{record.activity}
and a.card_Pay = #{record.cardPay}
and a.arrears = #{record.arrears}
and a.STATU = #{record.statu}
and a.CHANGE_ID = #{record.changeId}
and a.SHOP_ID = #{record.shopId}
and a.company_id = #{record.companyId}
and a.orderType = #{record.orderType}
and a.pay_time >= #{record.beginTimeVo}
order by
${pageVo.sort} ${pageVo.order}
limit
#{pageVo.offset},#{pageVo.limit}
select count(*)
from sys_order a
LEFT JOIN sys_vip_info b on b.ID=a.VIP_ID
left JOIN sys_users c on c.su_id=a.STAFF_ID
left JOIN sys_shop_info d on d.ID=a.SHOP_ID
where 1=1
and (b.PHONE like concat('%',#{record.keyWordVo},'%')
or b.vip_no like concat('%',#{record.keyWordVo},'%')
or b.vip_name like concat('%',#{record.keyWordVo},'%') )
and b.vip_name like concat('%',#{record.vipName},'%')
and b.PHONE like concat('%',#{record.vipPhone},'%')
and a.ID = #{record.id}
and a.VIP_ID = #{record.vipId}
and a.ORDER_TIME = #{record.orderTime}
and a.STAFF_ID = #{record.staffId}
and a.cashier_id = #{record.cashierId}
and a.company_id = #{record.companyId}
and a.orderType = #{record.orderType}
and a.IS_CROSS = #{record.isCross}
and a.ORDER_NO LIKE CONCAT('%',#{record.orderNo},'%')
and a.ACTIVITY = #{record.activity}
and a.card_Pay = #{record.cardPay}
and a.arrears = #{record.arrears}
and a.STATU = #{record.statu}
and a.CHANGE_ID = #{record.changeId}
and a.SHOP_ID = #{record.shopId}
and a.pay_time >= #{record.beginTimeVo}
select
a.*,
c.su_name as STAFF_NAME, e.su_name as cashierName,
d.SHOP_NAME,
d.shop_short_name,
b.PHONE,
b.VIP_NAME
from sys_order a
LEFT JOIN sys_vip_info b on b.ID=a.VIP_ID
left JOIN sys_users c on c.su_id=a.STAFF_ID
left JOIN sys_users e on e.su_id=a.cashier_id
left JOIN sys_shop_info d on d.ID=a.SHOP_ID
where a.id=#{id}
select
a.*,
c.su_name as STAFF_NAME,
d.SHOP_NAME,
b.PHONE
from sys_order a
LEFT JOIN sys_vip_info b on b.ID=a.VIP_ID
left JOIN sys_users c on c.su_id=a.STAFF_ID
left JOIN sys_shop_info d on d.ID=a.SHOP_ID
where 1=1
and a.ID = #{record.id}
and a.VIP_ID = #{record.vipId}
and a.ORDER_TIME = #{record.orderTime}
and a.STAFF_ID = #{record.staffId}
and a.cashier_id = #{record.cashierId}
and a.IS_CROSS = #{record.isCross}
and a.ORDER_NO LIKE CONCAT('%',#{record.orderNo},'%')
and a.ACTIVITY = #{record.activity}
and a.card_Pay = #{record.cardPay}
and a.arrears = #{record.arrears}
and a.STATU = #{record.statu}
and a.CHANGE_ID = #{record.changeId}
and a.SHOP_ID = #{record.shopId}
and a.ORDER_TIME >= #{record.beginTimeVo}
and a.company_id = #{record.companyId}
and a.orderType = #{record.orderType}
where 1=1
and a.ID = #{record.id}
and a.VIP_ID = #{record.vipId}
and a.ORDER_TIME = #{record.orderTime}
and a.STAFF_ID = #{record.staffId}
and a.cashier_id = #{record.cashierId}
and a.IS_CROSS = #{record.isCross}
and a.ORDER_NO LIKE CONCAT('%',#{record.orderNo},'%')
and a.company_id = #{record.companyId}
and a.orderType = #{record.orderType}
and a.ACTIVITY = #{record.activity}
and a.card_Pay = #{record.cardPay}
and a.arrears = #{record.arrears}
and a.STATU =#{record.statu}
and b.PHONE like CONCAT('%',#{record.vipPhone},'%')
and b.VIP_NAME like CONCAT('%',#{record.vipName},'%')
and a.SHOP_ID =#{record.shopId}
and a.CHANGE_ID = #{record.changeId}
and a.ORDER_TIME >= #{record.beginTimeVo}
select
sum(amount) zkTotal,
count(1) times,
MAX(pay_time) payTime,
GROUP_CONCAT(DISTINCT t2.shop_short_name) shopName
from sys_order t1
left join sys_order_flow b on t1.id=b.ORDER_ID and pay_method!='储值卡' and pay_method!='欠款'
left join sys_shop_info t2 on t1.SHOP_ID=t2.ID
where t1.VIP_ID=#{vipId} and STATU='已付款';
select
a.id orderId,
a.VIP_ID vipId,
a.ORDER_NO orderNo,
a.ORDER_TIME orderTime,
a.STATU orderStatus,
a.ZK_TOTAL needPay,
(a.card_Pay + a.cash_Pay) realPay,
a.arrears arrears,
b.su_name staffName,
c.VIP_NAME vipName,
c.PHONE phone
from sys_order a
left join sys_users b on a.STAFF_ID = b.su_id
left join sys_vip_info c on c.id = a.VIP_ID
and (instr(c.vip_name, #{record.queryKey}) or instr(c.phone, #{record.queryKey}) or instr(a.order_no, #{record.queryKey}))
and a.statu = #{record.status}
and a.shop_id=#{record.shopId}
and a.company_id=#{record.companyId}
order by a.order_time desc
limit
#{pageVo.offset},#{pageVo.limit}
select
a.id orderId,
a.VIP_ID vipId,
a.ORDER_NO orderNo,
a.ORDER_TIME orderTime,
a.STATU orderStatus,
a.ZK_TOTAL needPay,
(a.card_Pay + a.cash_Pay) realPay,
a.arrears arrears,
b.su_name staffName,
c.VIP_NAME vipName,
c.PHONE phone
from sys_order a
left join sys_users b on a.STAFF_ID = b.su_id
left join sys_vip_info c on c.id = a.VIP_ID
and (instr(c.vip_name, #{record.queryKey}) or instr(c.phone, #{record.queryKey}) or instr(a.order_no, #{record.queryKey}))
and a.statu = #{record.status}
and a.ORDER_TIME = #{record.orderTime}
and a.shop_id=#{record.shopId}
and a.company_id=#{record.companyId}
order by a.order_time desc
limit
#{pageVo.offset},#{pageVo.limit}
select
count(1)
from sys_order a
left join sys_users b on a.STAFF_ID = b.su_id
left join sys_vip_info c on c.id = a.VIP_ID
and (instr(c.vip_name, #{record.queryKey}) or instr(c.phone, #{record.queryKey}) or instr(a.order_no, #{record.queryKey}))
and a.statu = #{record.status}
and a.shop_id=#{record.shopId}
and a.company_id=#{record.companyId}
select
count(1)
from sys_order a
left join sys_users b on a.STAFF_ID = b.su_id
left join sys_vip_info c on c.id = a.VIP_ID
and (instr(c.vip_name, #{record.queryKey}) or instr(c.phone, #{record.queryKey}) or instr(a.order_no, #{record.queryKey}))
and a.statu = #{record.status}
and a.ORDER_TIME = #{record.orderTime}
and a.shop_id=#{record.shopId}
and a.company_id=#{record.companyId}
select
a.id orderId,
b.VIP_NAME vipName,
b.PHONE phone,
a.ORDER_NO orderNo,
c.su_name staffName,
a.cash_Pay cashPay,
a.card_Pay cardPay,
a.ZK_TOTAL needPay,
a.cash_Pay + a.card_Pay realPay,
a.arrears arrears,
a.TOTAL - a.ZK_TOTAL discount,
a.STATU orderStatus,
a.order_time orderTime
from sys_order a
inner join sys_vip_info b on a.VIP_ID=b.ID
left join sys_users c on a.STAFF_ID=c.su_id
where a.id=#{orderId}
select
a.id orderId,
b.VIP_NAME vipName,
b.PHONE phone,
a.ORDER_NO orderNo,
c.su_name staffName,
a.cash_Pay cashPay,
a.card_Pay cardPay,
a.ZK_TOTAL needPay,
a.cash_Pay + a.card_Pay realPay,
a.arrears arrears,
a.TOTAL - a.ZK_TOTAL discount,
a.STATU orderStatus,
a.order_time orderTime
from sys_order a
inner join sys_vip_info b on a.VIP_ID=b.ID
left join sys_users c on a.STAFF_ID=c.su_id
where a.id=#{orderId}
select
b.shop_short_name name,
b.SHOP_IMAG photo,
sum(IFNULL(a.ZK_TOTAL,0)) amount
from sys_order a
left join sys_shop_info b on a.SHOP_ID=b.ID
a.statu in ('已付款', '欠款')
and a.company_id=#{record.companyId}
and date_format(order_time, '%Y-%m-%d') = date_format(#{record.orderTime}, '%Y-%m-%d')
and date_format(order_time, '%Y-%m') = date_format(#{record.orderTime}, '%Y-%m')
and date_format(order_time, '%Y') = date_format(#{record.orderTime}, '%Y')
group by a.SHOP_ID
order by amount desc, a.shop_id
select
b.su_name name,
b.su_id id,
b.su_photo photo,
sum(ZK_TOTAL) amount,
c.shop_short_name shopName
from sys_order a
left join sys_users b on a.STAFF_ID=b.su_id
left join sys_shop_info c on a.SHOP_ID=c.ID
a.statu in ('已付款', '欠款') and b.su_id is not null
and a.company_id=#{record.companyId}
and a.shop_id=#{record.shopId}
and date_format(order_time, '%Y-%m-%d') = date_format(#{record.orderTime}, '%Y-%m-%d')
and date_format(order_time, '%Y-%m') = date_format(#{record.orderTime}, '%Y-%m')
and date_format(order_time, '%Y') = date_format(#{record.orderTime}, '%Y')
group by b.su_id
order by amount desc, b.su_id
select
a.id orderId,
a.ORDER_NO orderNo,
a.ORDER_TIME orderTime,
a.STATU orderStatus,
a.ZK_TOTAL needPay,
a.TOTAL - a.ZK_TOTAL discount,
(a.card_Pay + a.cash_Pay) realPay,
a.arrears arrears,
b.su_name staffName,
d.shop_name as shopName
from sys_order a
left join sys_users b on a.STAFF_ID = b.su_id
left join sys_vip_info c on c.id = a.VIP_ID
left join sys_shop_info d on d.id=a.shop_id
and instr(a.order_no, #{queryKey})
and a.statu = #{status}
and a.vip_id=#{vipId}
order by a.order_time desc
limit #{offset},#{limit}
select
a.id orderId,
a.ORDER_NO orderNo,
a.ORDER_TIME orderTime,
a.STATU orderStatus,
a.ZK_TOTAL needPay,
a.TOTAL - a.ZK_TOTAL discount,
(a.card_Pay + a.cash_Pay) realPay,
a.arrears arrears,
b.su_name staffName,
d.shop_name as shopName
from sys_order a
left join sys_users b on a.STAFF_ID = b.su_id
left join sys_vip_info c on c.id = a.VIP_ID
left join sys_shop_info d on d.id=a.shop_id
where a.id=#{orderId}
select sum(arrears) from sys_order
where vip_id=#{vipId} and statu='欠款'