master
yixian 6 years ago
parent f41db13db2
commit 6529413836

@ -156,7 +156,7 @@ public class BDPrizeServiceImpl implements BDPrizeService {
//todo 10月开始悉尼分公司经理不享受悉尼销售组提成
List<JSONObject> bdLeaders = managerMapper.listByRole(1, ManagerRole.BD_LEADER.getMask());
for (JSONObject leader : bdLeaders) {
BigDecimal groupAmount = transactionMapper.TotalAmountForBDLeaderPrize(now.get(Calendar.YEAR), now.get(Calendar.MONTH) + 1,leader.getString("manager_id"));
BigDecimal groupAmount = transactionMapper.totalAmountForBDLeaderPrize(now.get(Calendar.YEAR), now.get(Calendar.MONTH) + 1,leader.getString("manager_id"));
JSONObject bdConfig = financialBDConfigMapper.getBdConfig(leader.getString("manager_id"));
int bd_type = bdConfig ==null?2:("Sydney").equals(bdConfig.getString("city"))?2:1;//sydney leader 即悉尼大客户经理
JSONObject rateJson = financialBDCommissionConfigMapper.findCurrentCommissionRate(month, groupAmount.toString(), bd_type);
@ -269,7 +269,7 @@ public class BDPrizeServiceImpl implements BDPrizeService {
try {
List<JSONObject> prizeLogList = new ArrayList<>();
JSONObject sydneyPrizeLog = new JSONObject();
BigDecimal sydneyAmount = transactionMapper.TotalAmountForSydneyGMPrize(monthDate.getYear(), monthDate.getMonthOfYear());
BigDecimal sydneyAmount = transactionMapper.totalAmountForSydneyGMPrize(monthDate.getYear(), monthDate.getMonthOfYear());
sydneyPrizeLog.put("total_amount",sydneyAmount);
sydneyPrizeLog.put("bd_type", 3);
JSONObject sydneyGMRate = financialBDCommissionConfigMapper.findCurrentCommissionRate(month, sydneyAmount.toString(), 3);

@ -96,7 +96,7 @@ public class BDPrizeCalculatorDefaultImpl implements BDPrizeCalculator {
log.put("total_amount", 0);
log.put("total_prize", 0);
log.put("total_donation", 0);
BigDecimal totalAmount = transactionMapper.TotalAmountForBDPrize(year,month1,bd.getString("bd_id"));
BigDecimal totalAmount = transactionMapper.totalAmountForBDPrize(year,month1,bd.getString("bd_id"));
List<JSONObject> details = new ArrayList<>();
for (Map.Entry<String, JSONObject> detail : resultItem.getValue().entrySet()) {
JSONObject detailItem = detail.getValue();

@ -1,17 +1,13 @@
package au.com.royalpay.payment.manage.mappers.custom;
import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper;
import cn.yixblog.support.mybatis.autosql.annotations.AutoSql;
import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper;
import cn.yixblog.support.mybatis.autosql.annotations.AutoSql;
import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
/**
* Created by yishuqian on 9/1/16.
*/

@ -22,7 +22,7 @@ public interface NotifyErrorLogMapper {
void saveLog(JSONObject log);
@AutoSql(type = SqlType.SELECT)
@AdvanceSelect(addonWhereClause = "success=0 and addtime(`addtime`,'24:00:00')>now()")
@AdvanceSelect(addonWhereClause = "success=0 and `addtime`>addtime(now(),'-24:00:00')")
List<JSONObject> listErrorLogsInOneHour();
@AutoSql(type = SqlType.UPDATE)

@ -38,14 +38,6 @@ public interface OrderMapper {
JSONObject getOrderDetail(@Param("order_id") String orderId);
@AutoSql(type = SqlType.SELECT)
@AdvanceSelect(addonWhereClause = "(status=2 or status=0) and addtime(create_time,'0:05:00')<now()")
List<JSONObject> listUnConfirmedOrders();
@AutoSql(type = SqlType.SELECT)
@AdvanceSelect(addonWhereClause = "(status=2 or status=0) and addtime(create_time,'1:00:00')>now()")
List<JSONObject> listRecentUnconfirmedOrders();
@AutoSql(type = SqlType.SELECT)
PageList<JSONObject> list(JSONObject params, PageBounds pagination);
@ -58,17 +50,7 @@ public interface OrderMapper {
void updateOrderCreationError(@Param("order_id") String orderId, @Param("status") int status, @Param("error_code") String errorCode, @Param("error_message") String errorMessage);
@AutoSql(type = SqlType.UPDATE)
void setWechatMsgSendStatus(@Param("order_id") String orderId, @Param("wechat_notify") int status);
@AutoSql(type = SqlType.UPDATE)
void setIOSMsgSendStatus(@Param("order_id") String orderId, @Param("ios_notify") int status);
@AutoSql(type = SqlType.SELECT)
@AdvanceSelect(addonWhereClause = "status>4 and wechat_notify=1 and addtime(confirm_time,'12:00:00')>now()")
List<JSONObject> listOrdersWithWechatNotifyFailedToday();
int getOldOrdersPoints(@Param("customer_id") String open_id);
int getOldOrdersPoints(@Param("customer_id") String openId);
PageList<JSONObject> listOrderByCustomer(JSONObject params, PageBounds pagination);

@ -4,6 +4,7 @@ import cn.yixblog.support.mybatis.autosql.annotations.AdvanceSelect;
import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper;
import cn.yixblog.support.mybatis.autosql.annotations.AutoSql;
import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
import cn.yixblog.support.mybatis.paginator.annotations.CountRef;
import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList;
@ -22,45 +23,29 @@ public interface TransactionMapper {
@AutoSql(type = SqlType.INSERT)
void save(JSONObject transaction);
@CountRef(".countTransFlowPage")
PageList<JSONObject> listTransFlowPage(JSONObject params, PageBounds pagination);
int countTransFlowPage(JSONObject params);
List<JSONObject> listTransFlow(JSONObject params);
JSONObject analysisTransFlow(JSONObject params);
Double analysisBalance(JSONObject params);
@AutoSql(type = SqlType.SELECT)
JSONObject findTransById(@Param("transaction_id") String transactionId);
@AutoSql(type = SqlType.SELECT)
@AdvanceSelect(addonWhereClause = "refund_id is null and system_generate=0 and transaction_type = 'Credit'")
JSONObject findIncomeByOrderId(@Param("order_id") String orderId);
@AutoSql(type = SqlType.SELECT)
@AdvanceSelect(addonWhereClause = "transaction_type = 'Credit'")
JSONObject findByOrderId(@Param("order_id") String orderId);
@AutoSql(type = SqlType.SELECT)
@AdvanceSelect(addonWhereClause = "refund_id is null and system_generate=1")
JSONObject findSystemIncomeByOrderId(@Param("order_id") String orderId);
@AutoSql(type = SqlType.UPDATE)
void update(JSONObject transaction);
@AutoSql(type = SqlType.SELECT)
@AdvanceSelect(addonWhereClause = "transaction_type='Debit' and system_generate = 0")
JSONObject findRefundLog(@Param("order_id") String orderId, @Param("refund_id") String refundId);
@AutoSql(type = SqlType.SELECT)
@AdvanceSelect(addonWhereClause = "transaction_type='Credit'")
JSONObject findRefundPayback(@Param("order_id") String orderId, @Param("refund_id") String refundId);
JSONObject findLastIncome();
double getClientUnClearedAmount(@Param("client_id") int clientId);
List<JSONObject> getClientsUnClearedAmount(@Param("client_ids") List<Integer> client_ids);
List<JSONObject> getClientsUnClearedAmount(@Param("client_ids") List<Integer> clientIds);
JSONObject getClientAmountAnalysis(JSONObject params);
@ -76,8 +61,11 @@ public interface TransactionMapper {
PageList<JSONObject> listSettlementLog(JSONObject params, PageBounds pagination);
@CountRef(".countSettlementLogInClients")
PageList<JSONObject> listSettlementLogInClients(JSONObject params, PageBounds pagination);
int countSettlementLogInClients(JSONObject params);
JSONObject analysisSettlementLog(JSONObject params);
List<JSONObject> listSettlementLogTotal(JSONObject params);
@ -98,11 +86,11 @@ public interface TransactionMapper {
List<JSONObject> listTransactionsForBDPrize(@Param("year") int year, @Param("month") int month, @Param("channel") String channel);
BigDecimal TotalAmountForBDPrize(@Param("year") int year, @Param("month") int month, @Param("bd_id") String bd_id);
BigDecimal totalAmountForBDPrize(@Param("year") int year, @Param("month") int month, @Param("bd_id") String bd_id);
BigDecimal TotalAmountForBDLeaderPrize(@Param("year") int year, @Param("month") int month, @Param("bd_group") String bd_group);
BigDecimal totalAmountForBDLeaderPrize(@Param("year") int year, @Param("month") int month, @Param("bd_group") String bd_group);
BigDecimal TotalAmountForSydneyGMPrize(@Param("year") int year, @Param("month") int month);
BigDecimal totalAmountForSydneyGMPrize(@Param("year") int year, @Param("month") int month);
List<JSONObject> listTransactionForCityPartnerCommissionByDate(@Param("year") int year, @Param("month") int month);
@ -118,7 +106,7 @@ public interface TransactionMapper {
@AutoSql(type = SqlType.COUNT)
@AdvanceSelect(addonWhereClause = "transaction_type='Credit'")
int countOrders(@Param("client_id") int client_id);
int countOrders(@Param("client_id") int clientId);
List<JSONObject> listDailyTransactions(@Param("from") Date from, @Param("to") Date to, @Param("dev_id") String devId, @Param("client_id") int clientId, @Param("client_ids") String[] client_ids);
@ -128,16 +116,8 @@ public interface TransactionMapper {
@AdvanceSelect(addonWhereClause = "system_generate=1")
List<JSONObject> findTransactionsBySysGen(@Param("order_id") String orderId);
@AutoSql(type = SqlType.SELECT)
List<JSONObject> findFixTransaction(@Param("order_id") String orderId, @Param("refund_id") String refundId, @Param("system_transaction_id") String systemTransactionId);
BigDecimal analysisCustomerPaid(@Param("customer_id") String customerId, @Param("startDate") Date startDate, @Param("endDate") Date endDate);
@AutoSql(type = SqlType.UPDATE)
void updateTransactionSurcharge(@Param("transaction_id") String transactionId, @Param("surcharge_rate") BigDecimal surchargeRate,
@Param("settle_amount") BigDecimal settleAmount, @Param("total_surcharge") BigDecimal surcharge,
@Param("channel_surcharge") BigDecimal channelSurcharge, @Param("royal_surcharge") BigDecimal royalSurcharge);
List<JSONObject> getSettleDelayAnalysis(@Param("begin") Date begin, @Param("end") Date end);
List<JSONObject> getSettleDelayTotalTransaction(@Param("begin") Date begin, @Param("end") Date end);

@ -8,12 +8,10 @@
t.cny_amount cny_amount ,r.report_status report_status,r.report_id report_id,o.channel channel
from
pmt_orders o
left join
pmt_transactions t
on o.order_id = t.order_id
left join
pmt_custom_report r
on r.order_id = o.order_id
inner join pmt_transactions t on o.order_id = t.order_id and t.transaction_type = 'Credit'
<if test="from!=null">and t.transaction_time &gt;= #{from}</if>
<if test="to!=null">and t.transaction_time &lt; #{to}</if>
left join pmt_custom_report r on r.order_id = o.order_id
where
o.channel in (
<foreach collection="channels" separator="," item="item">
@ -22,7 +20,7 @@
)
and o.client_id = #{client_id}
and transaction_type = 'Credit'
and
o.status in (
<foreach collection="orderStatus" item="item" separator=",">
@ -33,8 +31,7 @@
<!--<if test="channel!=null">-->
<!--and o.channel = #{channel}-->
<!--</if>-->
<if test="from!=null">and t.transaction_time &gt;= #{from}</if>
<if test="to!=null">and t.transaction_time &lt; #{to}</if>
<if test="report_status!=null">
and r.report_status = #{report_status}
</if>

@ -57,6 +57,42 @@
</if>
</where>
</select>
<select id="countTransFlowPage" resultType="int">
SELECT count(1)
FROM pmt_transactions t
<if test="dev_id!=null or ">
INNER JOIN (select o.order_id from pmt_orders o<where>
<if test="dev_id!=null">and o.dev_id = #{dev_id}</if>
<if test="
channel!=null">and
<foreach collection="channel" item="chan" open="(" close=")" separator=" or ">
o.channel=#{chan}
</foreach>
</if>
</where>)oo ON oo.order_id=t.order_id
</if>
<where>
<if test="client_ids!=null">
AND t.client_id IN
<foreach collection="client_ids" open="(" close=")" separator="," item="client_id">
#{client_id}
</foreach>
</if>
<if test="client_ids==null">
and t.client_id=#{client_id}
</if>
<if test="from!=null">and t.transaction_time &gt;= #{from}</if>
<if test="to!=null">and t.transaction_time &lt; #{to}</if>
<if test="transaction_type!=null">and t.transaction_type=#{transaction_type}</if>
<if test="date!=null">and date(t.transaction_time)=date(#{date})</if>
<if test="clearing_status!=null">and t.clearing_status=#{clearing_status}</if>
<if test="trans_type==1">and t.transaction_type = 'Credit'</if>
<if test="trans_type==2">and t.refund_id is NOT NULL</if>
<if test="trans_type==3">and t.transaction_type='Debit' and t.refund_id is NULL</if>
</where>
</select>
<select id="listTransFlow" resultType="com.alibaba.fastjson.JSONObject">
SELECT t.*,
@ -271,15 +307,14 @@
<if test="to!=null">and t.transaction_time &lt; #{to}</if>
</select>
<select id="listPreRefundClients" resultType="com.alibaba.fastjson.JSONObject">
SELECT *
FROM (SELECT ifnull(sum(if(transaction_type = 'Credit', clearing_amount, -clearing_amount)), 0) amount,
SELECT ifnull(sum(if(transaction_type = 'Credit', clearing_amount, -clearing_amount)), 0) amount,
cc.client_id client_id,
max(t.transaction_time) transation_time,
cc.client_moniker client_moniker
FROM pmt_transactions t
INNER JOIN sys_client_config cc on cc.client_id = t.client_id AND cc.enable_refund_auth = 1
GROUP BY cc.client_id) a
WHERE a.amount &lt; 0
from (select client_id,client_moniker from sys_client_config where enable_refund_auth=1) cc
inner join pmt_transactions t on cc.client_id = t.client_id
GROUP BY cc.client_id
having amount &lt; 0
</select>
<select id="validAnalysis" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[
@ -397,19 +432,41 @@
SELECT c.short_name,SUM(t.clearing_amount) total,
sum(if(LOCATE('MERCHANT',t.system_transaction_id),t.clearing_amount,0)) income,
sum(if(LOCATE('SURCHARGE',t.system_transaction_id),t.clearing_amount,0)) fee
FROM pmt_transactions t
RIGHT JOIN sys_clients c ON t.client_id = c.client_id
WHERE t.channel='Settlement'
]]>
<if test="from!=null">and t.transaction_time &gt;= #{from}</if>
<if test="to!=null">and t.transaction_time &lt; #{to}</if>
FROM sys_clients c
]]>
INNER JOIN (select system_transaction_id,clearing_amount,client_id
from pmt_transactions
where channel='Settlement'
<if test="from!=null">and transaction_time &gt;= #{from}</if>
<if test="to!=null">and transaction_time &lt; #{to}</if>
) t ON t.client_id = c.client_id
<where>
<if test="client_moniker!=null">and c.client_moniker=#{client_moniker}</if>
<if test="org_id!=null and org_ids==null">and c.org_id = #{org_id}</if>
<if test="org_ids!=null">and c.org_id in
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
</if>
</where>
GROUP BY c.client_id
order by total desc
</select>
<select id="countSettlementLogInClients" resultType="int">
<![CDATA[
SELECT count(1)
FROM sys_clients c
]]>
<where>
<if test="client_moniker!=null">and c.client_moniker=#{client_moniker}</if>
<if test="org_id!=null and org_ids==null">and c.org_id = #{org_id}</if>
<if test="org_ids!=null">and c.org_id in
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
</if>
and exists (select client_id from pmt_transactions t where channel='Settlement'
<if test="from!=null">and transaction_time &gt;= #{from}</if>
<if test="to!=null">and transaction_time &lt; #{to}</if>
and client_id=c.client_id
)
</where>
exists
</select>
<select id="analysisSettlementLog" resultType="com.alibaba.fastjson.JSONObject">
@ -562,7 +619,7 @@
ORDER BY trade_date ASC, o.client_id ASC
</select>
<select id="TotalAmountForBDPrize" resultType="java.math.BigDecimal">
<select id="totalAmountForBDPrize" resultType="java.math.BigDecimal">
<![CDATA[
select sum(if(temp.transaction_type = 'Credit', temp.clearing_amount * d.proportion,
-temp.clearing_amount * d.proportion))
@ -582,7 +639,7 @@
</select>
<select id="TotalAmountForBDLeaderPrize" resultType="java.math.BigDecimal">
<select id="totalAmountForBDLeaderPrize" resultType="java.math.BigDecimal">
SELECT ifnull(sum(t.total), 0)
total
FROM statistics_customer_order t
@ -599,7 +656,7 @@
or c.manager_id = #{bd_group})
</select>
<select id="TotalAmountForSydneyGMPrize" resultType="java.math.BigDecimal">
<select id="totalAmountForSydneyGMPrize" resultType="java.math.BigDecimal">
SELECT ifnull(sum(t.total), 0)
total
FROM statistics_customer_order t

Loading…
Cancel
Save