@ -5,6 +5,7 @@
<id column= "order_id" jdbcType= "BIGINT" property= "orderId" />
<result column= "parent_id" jdbcType= "BIGINT" property= "parentId" />
<result column= "shop_id" jdbcType= "BIGINT" property= "shopId" />
<result column= "project" jdbcType= "VARCHAR" property= "project" />
<result column= "order_formid" jdbcType= "VARCHAR" property= "orderFormid" />
<result column= "buyer_user_id" jdbcType= "BIGINT" property= "buyerUserId" />
<result column= "coupon_id" jdbcType= "BIGINT" property= "couponId" />
@ -45,7 +46,7 @@
<result column= "platform_commission" jdbcType= "DECIMAL" property= "platformCommission" />
</resultMap>
<sql id= "Base_Column_List" >
order_id, parent_id,shop_id, order_formid, buyer_user_id, coupon_id,id, shop_seckill_id, shop_group_work_id,
order_id, parent_id,shop_id, project, order_formid, buyer_user_id, coupon_id,id, shop_seckill_id, shop_group_work_id,
shop_discount_id, shop_operate_id, order_price, logistics_price,discount_price, price, old_price,
`state`, payment_state, payment_mode, payment_time, customer_name, customer_phone,
receive_name, receive_phone, receive_adress,address,receive_time, postal_code, remark, after_state, logistics_id,
@ -72,6 +73,9 @@
<if test= "shopId != null" >
shop_id = #{shopId,jdbcType=BIGINT},
</if>
<if test= "project != null and project!=''" >
project = #{project,jdbcType=VARCHAR},
</if>
<if test= "orderFormid != null and orderFormid!=''" >
order_formid = #{orderFormid,jdbcType=VARCHAR},
</if>
@ -192,12 +196,40 @@
<select id= "getAll" parameterType= "com.shop.cereshop.business.param.order.OrderGetAllParam"
resultType="com.shop.cereshop.business.page.order.ShopOrder">
SELECT a.order_id,a.order_formid,a.buyer_user_id,a.price,IF(a.order_id IS NOT NULL,sum(b.number),NULL) number,a.state,a.remark,d.transaction_id,
a.customer_name,a.payment_mode,a.payment_state,a.payment_time,a.create_time,a.receive_name,a.receive_phone,a.address,a.receive_adress,c.shop_name FROM cere_shop_order a
SELECT
a.order_id,
a.order_formid,
a.buyer_user_id,
a.price,
IF(a.order_id IS NOT NULL,sum(b.number),NULL) number,
a.state,
a.remark,
d.transaction_id,
a.customer_name,
a.payment_mode,
a.payment_state,
a.payment_time,
a.create_time,
a.receive_name,
a.receive_phone,
a.address,
a.receive_adress,
c.shop_name
FROM cere_shop_order a
LEFT JOIN cere_order_product b ON a.order_id=b.order_id
LEFT JOIN cere_platform_shop c ON a.shop_id=c.shop_id
LEFT JOIN cere_pay_log d ON a.order_formid=d.order_formid
where a.shop_id=#{shopId}
where
1=1
<if test= "shopId!=null" >
and a.shop_id=#{shopId}
</if>
<if test= "businessId!=null" >
and c.business_id=#{businessId}
</if>
<if test= "project!=null and project!=''" >
and a.project=#{project}
</if>
<if test= 'searchType=="1" and search!=null and search!=""' >
and a.order_id like concat('%',#{search},'%')
</if>
@ -258,23 +290,21 @@
a.buyer_user_id,
e.deliver_formid,f.dict_name express,
IF(c.after_state = 1, '审核中',
IF(c.after_state = 2, '退款中', IF(c.after_state = 3, '退货中', IF(c.after_state = 4, '退款成功',
IF(c.after_state = 5, '退款失败',
IF(c.after_state = 6, '审核不通过', IF(
c.after_state = 7, '评审中',
IF(c.after_state = 8,
'退货完成,拒绝退款',
IF(c.after_state = 9, '已关闭', '审核通过'))))))))) after_state_name
IF(c.after_state = 2, '退款中',
IF(c.after_state = 3, '退货中',
IF(c.after_state = 4, '退款成功',
IF(c.after_state = 5, '退款失败',
IF(c.after_state = 6, '审核不通过',
IF(c.after_state = 7, '评审中',
IF(c.after_state = 8, '退货完成,拒绝退款',
IF(c.after_state = 9, '已关闭', '审核通过'))))))))) after_state_name
from cere_shop_order a
LEFT JOIN cere_pay_log b ON a.order_formid = b.order_formid and b.state = '支付'
LEFT JOIN cere_order_after c ON a.order_id = c.order_id
LEFT JOIN cere_order_logistics d ON a.logistics_id = d.logistics_id
LEFT JOIN cere_order_dilever e ON a.order_id=e.order_id
LEFT JOIN cere_platform_dict f ON e.express=f.dict_id
LEFT JOIN cere_pay_log b ON a.order_formid = b.order_formid and b.state = '支付'
LEFT JOIN cere_order_after c ON a.order_id = c.order_id
LEFT JOIN cere_order_logistics d ON a.logistics_id = d.logistics_id
LEFT JOIN cere_order_dilever e ON a.order_id=e.order_id
LEFT JOIN cere_platform_dict f ON e.express=f.dict_id
where a.order_id = #{orderId}
<if test= "shopId != null and shopId != 0" >
and a.shop_id = #{shopId}
</if>
</select>
<select id= "getOrderTotals" parameterType= "java.lang.Object" resultType= "java.lang.Integer" >
@ -324,115 +354,228 @@
where order_id = #{orderId,jdbcType=BIGINT}
</update>
<select id= "getTurnover" parameterType= "java.lang.Object" resultType= "java.math.BigDecimal" >
SELECT IFNULL(SUM(IFNULL(price, 0)), 0)
FROM cere_shop_order
where shop_id = #{shopId}
and state in (2, 3, 4)
<select id= "getTurnover" resultType= "java.math.BigDecimal" >
SELECT IFNULL(SUM(IFNULL(cso.price, 0)), 0)
FROM cere_shop_order cso
INNER JOIN cere_platform_shop cps ON cso.shop_id=cps.shop_id
where
cso.state in (2, 3, 4)
<if test= "project != null and project != ''" >
AND cso.project = #{project}
</if>
<if test= "businessId != null" >
AND cps.business_id = #{businessId}
</if>
<if test= "shopId != null" >
AND cso.shop_id = #{shopId}
</if>
</select>
<select id= "getPlatformCommission" parameterType= "java.lang.Object" resultType= "java.math.BigDecimal" >
SELECT IFNULL(SUM(IFNULL(platform_commission, 0)), 0)
FROM cere_shop_order
where shop_id = #{shopId}
and state in (2, 3, 4)
<select id= "getPlatformCommission" resultType= "java.math.BigDecimal" >
SELECT IFNULL(SUM(IFNULL(cso.platform_commission, 0)), 0)
FROM cere_shop_order cso
INNER JOIN cere_platform_shop cps ON cso.shop_id=cps.shop_id
where
cso.state in (2, 3, 4)
<if test= "project != null and project != ''" >
AND cso.project = #{project}
</if>
<if test= "businessId != null" >
AND cps.business_id = #{businessId}
</if>
<if test= "shopId != null" >
AND cso.shop_id = #{shopId}
</if>
</select>
<select id= "getFrozenMoney" parameterType= "java.lang.Object" resultType= "java.math.BigDecimal" >
<select id= "getFrozenMoney" resultType= "java.math.BigDecimal" >
SELECT IFNULL(SUM(IFNULL(cso.price, 0)),0)
FROM cere_shop_order cso
inner join cere_platform_shop cps on cps.shop_id = cso.shop_id
where cso.shop_id = #{shopId}
WHERE 1=1
<if test= "project != null and project != ''" >
AND cso.project = #{project}
</if>
<if test= "businessId != null" >
AND cps.business_id = #{businessId}
</if>
<if test= "shopId != null" >
AND cso.shop_id = #{shopId}
</if>
and (cso.state in (2, 3) or (cso.state = 4 AND DATEDIFF(cso.receive_time, sysdate()) <![CDATA[<=]]> IFNULL(cps.share_days, 0)))
</select>
<select id= "getWithdrawableMoney" parameterType= "java.lang.Object" resultType= "java.math.BigDecimal" >
SELECT IF(SUM(withdrawal_money) IS NULL, 0, SUM(withdrawal_money))
FROM cere_shop_withdrawal
where shop_id = #{shopId}
and state = 1
SELECT IF(SUM(csw.withdrawal_money) IS NULL, 0, SUM(csw.withdrawal_money))
FROM cere_shop_withdrawal csw
where csw.state = 1
<if test= "project != null and project != ''" >
AND csw.project = #{project}
</if>
<if test= "businessId != null" >
AND csw.shop_id = #{businessId}
</if>
</select>
<select id= "getAllWithdrawableMoney" parameterType= "java.lang.Object" resultType= "java.math.BigDecimal" >
<select id= "getAllWithdrawableMoney" resultType= "java.math.BigDecimal" >
SELECT IFNULL(SUM(IFNULL(cso.price, 0)),0)
FROM cere_shop_order cso
inner join cere_platform_shop cps on cps.shop_id = cso.shop_id
where cso.shop_id = #{shopId}
where
1=1
<if test= "project != null and project != ''" >
AND cso.project = #{project}
</if>
<if test= "businessId != null" >
AND cps.business_id = #{businessId}
</if>
<if test= "shopId != null" >
AND cso.shop_id = #{shopId},
</if>
and (cso.state = 4 AND DATEDIFF(cso.receive_time, sysdate()) <![CDATA[>]]> IFNULL(cps.share_days, 0))
</select>
<select id= "getWithdrawableStayMoney" parameterType= "java.lang.Object" resultType= "java.math.BigDecimal" >
SELECT IFNULL(SUM(IFNULL(withdrawal_money, 0)),0)
FROM cere_shop_withdrawal
where shop_id = #{shopId}
and state = 0
<select id= "getWithdrawableStayMoney" resultType= "java.math.BigDecimal" >
SELECT IFNULL(SUM(IFNULL(csw.withdrawal_money, 0)),0)
FROM cere_shop_withdrawal csw
where csw.state = 0
<if test= "project != null and project != ''" >
AND csw.project = #{project}
</if>
<if test= "businessId != null" >
AND csw.shop_id = #{businessId}
</if>
</select>
<select id= "getFinanceByDay" parameterType= "java.lang.Object"
resultType="com.shop.cereshop.business.page.finance.Finance">
SELECT IFNULL(SUM(IFNULL(total_fee, 0)),0) income,IFNULL(SUM(IFNULL(platform_commission, 0)),0) commission,LEFT(create_time,10) time from cere_pay_log
where shop_id=#{shopId} and create_time like concat('%',#{time},'%')
SELECT
IFNULL(SUM(IFNULL(cpl.total_fee, 0)),0) income,
IFNULL(SUM(IFNULL(cpl.platform_commission, 0)),0) commission,
LEFT(cpl.create_time,10) time
from cere_pay_log cpl
INNER JOIN cere_platform_shop cps ON cpl.shop_id=cps.shop_id
where
1=1
<if test= "project != null and project != ''" >
AND cpl.project = #{project}
</if>
<if test= "businessId != null" >
AND cps.business_id = #{businessId}
</if>
<if test= "shopId != null" >
AND cpl.shop_id = #{shopId}
</if>
and cpl.create_time like concat('%',#{time},'%')
<if test= 'type=="1"' >
and state='支付'
and cpl. state='支付'
</if>
<if test= 'type=="2"' >
and (state='退款' OR state='提现')
and (cpl. state='退款' OR cpl. state='提现')
</if>
GROUP BY LEFT(create_time,10)
ORDER BY create_time DESC
GROUP BY LEFT(cpl.c reate_time,10)
ORDER BY cpl.c reate_time DESC
</select>
<select id= "getFinanceByMonth" parameterType= "java.lang.Object"
resultType="com.shop.cereshop.business.page.finance.Finance">
SELECT IFNULL(SUM(IFNULL(total_fee, 0)),0) income,IFNULL(SUM(IFNULL(platform_commission, 0)),0) commission,LEFT(create_time,7) time from cere_pay_log
where shop_id=#{shopId} and create_time like concat('%',#{time},'%')
SELECT
IFNULL(SUM(IFNULL(cpl.total_fee, 0)),0) income,
IFNULL(SUM(IFNULL(cpl.platform_commission, 0)),0) commission,
LEFT(cpl.create_time,7) time
from cere_pay_log cpl
INNER JOIN cere_platform_shop cps ON cpl.shop_id=cps.shop_id
where
1=1
<if test= "project != null and project != ''" >
AND cpl.project = #{project}
</if>
<if test= "businessId != null" >
AND cps.business_id = #{businessId}
</if>
<if test= "shopId != null" >
AND cpl.shop_id = #{shopId}
</if>
and cpl.create_time like concat('%',#{time},'%')
<if test= 'type=="1"' >
and state='支付'
and cpl. state='支付'
</if>
<if test= 'type=="2"' >
and (state='退款' OR state='提现')
and (cpl. state='退款' OR cpl. state='提现')
</if>
GROUP BY LEFT(create_time,7)
ORDER BY create_time DESC
GROUP BY LEFT(cpl.c reate_time,7)
ORDER BY cpl.c reate_time DESC
</select>
<select id= "getWithdrawalDetails" parameterType= "com.shop.cereshop.business.param.finance.FinanceWithdrawalParam"
resultType="com.shop.cereshop.business.page.finance.WithdrawalDetail">
SELECT withdrawal_money,state,bank_card,bank_name,apply_time from cere_shop_withdrawal
where shop_id=#{shopId}
SELECT
csw.withdrawal_money,
csw.state,
csw.bank_card,
csw.bank_name,
csw.apply_time
from cere_shop_withdrawal csw
where 1=1
<if test= "project != null and project != ''" >
AND csw.project = #{project}
</if>
<if test= "businessId != null" >
AND csw.shop_id = #{businessId}
</if>
<if test= "startTime!=null and startTime!=''" >
and apply_time> =#{startTime} and apply_time< =#{endTime}
</if>
</select>
<select id= "getBank" parameterType= "java.lang.Object" resultType= "com.shop.cereshop.business.page.finance.Bank" >
<select id= "getBank" resultType= "com.shop.cereshop.business.page.finance.Bank" >
SELECT a.shop_id,
b.shop_name,
b.shop_code,
b.business_name shopN ame,
b.business_code shopC ode,
c.dict_name bankName,
a.card_number bankCard,
a.card_name collectionNme
from cere_shop_bank a
LEFT JOIN cere_platform_shop b ON a.shop_id = b.shop _id
LEFT JOIN cere_platform_dict c ON a.bank = c.dict_id
where a.shop_id = #{shop Id}
INNER JOIN cere_platform_business b ON a.shop_id = b.business _id
INNER JOIN cere_platform_dict c ON a.bank = c.dict_id
where a.shop_id = #{business Id}
</select>
<select id= "getDetails" parameterType= "com.shop.cereshop.business.param.finance.FinanceDetailParam"
resultType="com.shop.cereshop.business.page.finance.FlowingWater">
SELECT IF(state='支付','订单入账',IF(state='退款','买家退款','提现')) waterType,
order_formid,IF(state='支付','收入','支出') incomeType,total_fee money,platform_commission commission,create_time time from cere_pay_log
where shop_id=#{shopId} and create_time like concat('%',#{time},'%')
SELECT
cpl.shop_id,
cps.shop_name,
IF(cpl.state='支付','订单入账',IF(cpl.state='退款','买家退款','提现')) waterType,
cpl.order_formid,
IF(cpl.state='支付','收入','支出') incomeType,
cpl.total_fee money,
cpl.platform_commission commission,
cpl.create_time time
from cere_pay_log cpl
INNER JOIN cere_platform_shop cps ON cpl.shop_id=cps.shop_id
where
1=1
<if test= "project != null and project != ''" >
AND cpl.project = #{project}
</if>
<if test= "businessId != null" >
AND cps.business_id = #{businessId}
</if>
<if test= "shopId != null" >
AND cpl.shop_id = #{shopId}
</if>
and cpl.create_time like concat('%',#{time},'%')
<if test= 'income=="1"' >
and state='支付'
and cpl. state='支付'
</if>
<if test= 'income=="2"' >
and (state='退款' OR state='提现')
and (cpl. state='退款' OR cpl. state='提现')
</if>
<if test= "state!=null and state!=''" >
and state=#{state}
and cpl. state=#{state}
</if>
ORDER BY create_time DESC
ORDER BY cpl.c reate_time DESC
</select>
<select id= "getTurnoverByTime" parameterType= "com.shop.cereshop.business.page.finance.FlowingWater"