manual settle request

master
yixian 7 years ago
parent 4d2a27c2ca
commit de40d0d0ea

@ -11,6 +11,7 @@ import au.com.royalpay.payment.manage.bill.bean.QueryBillBean;
import au.com.royalpay.payment.manage.bill.bean.QueryBillOrderBean;
import au.com.royalpay.payment.manage.bill.core.BillOrderService;
import au.com.royalpay.payment.manage.bill.core.BillService;
import au.com.royalpay.payment.manage.settlement.core.ManualSettleSupport;
import au.com.royalpay.payment.manage.signin.beans.ChangePwdBean;
import au.com.royalpay.payment.manage.signin.core.SignInStatusManager;
import au.com.royalpay.payment.manage.system.core.ClientContractService;
@ -22,6 +23,7 @@ import au.com.royalpay.payment.tools.http.HttpUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.validation.Errors;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
@ -32,6 +34,8 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import java.math.BigDecimal;
import java.text.ParseException;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -58,6 +62,8 @@ public class RetailAppController {
private AppActService appActService;
@Resource
private ClientContractService clientContractService;
@Resource
private ManualSettleSupport manualSettleSupport;
@RequestMapping(value = "/token", method = RequestMethod.PUT)
public void updateDevToken(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @RequestBody JSONObject token) {
@ -114,7 +120,7 @@ public class RetailAppController {
@RequestMapping("/transaction_log/{clearing_detail_id}")
public JSONObject getTransactionLogByClearingDetailId(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @PathVariable int clearing_detail_id,
@RequestParam(required = false) String timezone) {
@RequestParam(required = false) String timezone) {
return retailAppService.getTransactionLogsByClearingDetailId(device, clearing_detail_id, timezone);
}
@ -126,7 +132,7 @@ public class RetailAppController {
@RequestMapping(value = "/notice/{noticeId}", method = RequestMethod.PUT)
public void updateNoticePartnerHasRead(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @PathVariable String noticeId,
@RequestBody JSONObject account_param) {
@RequestBody JSONObject account_param) {
if (!device.getString("account_id").equals(account_param.getString("account_id"))) {
throw new ForbiddenException("You have no permission");
}
@ -147,7 +153,7 @@ public class RetailAppController {
/* 我的页面begin */
@RequestMapping(value = "/partner_password/{account_id}", method = RequestMethod.PUT)
public void changePassword(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @PathVariable String account_id,
@RequestBody @Valid ChangePwdBean change, Errors errors) {
@RequestBody @Valid ChangePwdBean change, Errors errors) {
HttpUtils.handleValidErrors(errors);
retailAppService.changeAccountPassword(device, change, account_id);
}
@ -176,7 +182,7 @@ public class RetailAppController {
/* 活动页面 begin */
@RequestMapping(value = "/activities", method = RequestMethod.GET)
public JSONObject getActivities(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @RequestParam(defaultValue = "activity_page") String type,
@RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "10") int limit) {
@RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "10") int limit) {
return retailAppService.getActivities(device, type, page, limit);
}
@ -220,7 +226,7 @@ public class RetailAppController {
@RequestMapping(value = "/daily_transactions/date/{dateStr}", method = RequestMethod.GET)
public JSONObject listDailyTransactions(@PathVariable String dateStr, @RequestParam(defaultValue = "Australia/Melbourne") String timezone,
@RequestParam(defaultValue = "false") boolean thisdevice, @ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) {
@RequestParam(defaultValue = "false") boolean thisdevice, @ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) {
return retailAppService.listDailyTransactions(dateStr, timezone, thisdevice, device);
}
@ -271,7 +277,7 @@ public class RetailAppController {
@RequestMapping(value = "/cash_back/clean_info", method = RequestMethod.GET)
public JSONObject getCashbackCleanInfo(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device,
@RequestParam(value = "client_id", required = false) String client_id) {
@RequestParam(value = "client_id", required = false) String client_id) {
if (client_id == null) {
client_id = device.getString("client_id");
}
@ -287,7 +293,7 @@ public class RetailAppController {
@RequestMapping(value = "/coupon/used", method = RequestMethod.GET)
public JSONObject getCoupons(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @RequestParam(value = "page", defaultValue = "1") int page,
@RequestParam(value = "limit", defaultValue = "10") int limit) {
@RequestParam(value = "limit", defaultValue = "10") int limit) {
return retailAppService.getCoupons(device, page, limit);
}
@ -339,15 +345,15 @@ public class RetailAppController {
@RequestMapping(value = "/bills/orders/{bill_id}", method = RequestMethod.GET)
public JSONObject getBillOrders(@PathVariable("bill_id") String bill_id, QueryBillOrderBean queryBillOrderBean,
@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) {
@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) {
JSONObject result = billOrderService.query(bill_id, device.getIntValue("client_id"), queryBillOrderBean);
result.put("analysis", billOrderService.analysis(bill_id, device.getIntValue("client_id"), queryBillOrderBean));
return result;
}
@RequestMapping(value = "/acts",method = RequestMethod.GET)
public List<JSONObject> getIndexAct(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device){
@RequestMapping(value = "/acts", method = RequestMethod.GET)
public List<JSONObject> getIndexAct(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) {
return appActService.listAppActs();
}
@ -373,12 +379,31 @@ public class RetailAppController {
public JSONObject generateSourceAgreeFile(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) {
JSONObject file = clientContractService.getSourceAgreement(device.getIntValue("client_id"));
JSONObject result = new JSONObject();
result.put("file_url",file.getString("file_value"));
result.put("file_url", file.getString("file_value"));
return result;
}
@RequestMapping(value = "/file/agree/confirm", method = RequestMethod.POST)
public void confirmSourceAgreeFile(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) {
clientContractService.confirmSourceAgreement(device.getIntValue("client_id"),device.getString("account_id"),"App");
clientContractService.confirmSourceAgreement(device.getIntValue("client_id"), device.getString("account_id"), "App");
}
@RequestMapping(value = "/manual_settle", method = RequestMethod.GET)
public JSONObject getManualSettleStatus(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) {
return manualSettleSupport.findCurrentSettle(device.getIntValue("client_id"), true);
}
@RequestMapping(value = "/manual_settle", method = RequestMethod.PUT)
public JSONObject requestManualSettle(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @RequestBody JSONObject data) {
String settleToStr = data.getString("settle_to");
if (settleToStr == null) {
throw new ParamInvalidException("settle_to", "error.payment.valid.param_missing");
}
try {
Date setteTo = DateUtils.parseDate(settleToStr, "yyyy-MM-dd");
return manualSettleSupport.requestManualSettle(setteTo, device.getString("account_id"));
} catch (ParseException e) {
throw new ParamInvalidException("settle_to", "error.payment.valid.invalid_time");
}
}
}

@ -0,0 +1,31 @@
package au.com.royalpay.payment.manage.mappers.payment;
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 com.alibaba.fastjson.JSONObject;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* Create by yixian at 2018-03-20 18:05
*/
@AutoMapper(tablename = "task_client_manual_settle", pkName = "task_id")
public interface TaskManualSettleMapper {
@AutoSql(type = SqlType.SELECT)
@AdvanceSelect(addonWhereClause = "request_time>curdate()")
JSONObject findTodayTask(@Param("client_id") int clientId);
@AutoSql(type = SqlType.SELECT)
@AdvanceSelect(addonWhereClause = "clearing_order is null")
List<JSONObject> listActiveTasks(@Param("client_id") int clientId);
@AutoSql(type = SqlType.INSERT)
void save(JSONObject task);
@AutoSql(type = SqlType.UPDATE)
void update(JSONObject task);
}

@ -128,4 +128,6 @@ public interface TransactionMapper {
List<JSONObject> getClientRank(@Param("begin") Date begin, @Param("end") Date end);
List<JSONObject> listClientUnsettleDataByDate(@Param("client_id") int clientId);
}

@ -0,0 +1,16 @@
package au.com.royalpay.payment.manage.settlement.core;
import com.alibaba.fastjson.JSONObject;
import java.util.Date;
/**
* Create by yixian at 2018-03-20 17:42
*/
public interface ManualSettleSupport {
JSONObject requestManualSettle(Date settleTo, String accountId);
JSONObject findCurrentSettle(int clientId, boolean includingUnsettleData);
}

@ -0,0 +1,81 @@
package au.com.royalpay.payment.manage.settlement.core.impls;
import au.com.royalpay.payment.manage.mappers.log.ClearingLogMapper;
import au.com.royalpay.payment.manage.mappers.payment.TaskManualSettleMapper;
import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper;
import au.com.royalpay.payment.manage.settlement.core.ManualSettleSupport;
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import au.com.royalpay.payment.tools.exceptions.ForbiddenException;
import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
/**
* Create by yixian at 2018-03-20 17:44
*/
@Service
public class ManualSettleSupportImpl implements ManualSettleSupport {
@Resource
private MerchantInfoProvider merchantInfoProvider;
@Resource
private TransactionMapper transactionMapper;
@Resource
private TaskManualSettleMapper taskManualSettleMapper;
@Resource
private ClearingLogMapper clearingLogMapper;
@Resource
private ClientAccountMapper clientAccountMapper;
@Override
public JSONObject requestManualSettle(Date settleTo, String accountId) {
JSONObject account = clientAccountMapper.findById(accountId);
int clientId = account.getIntValue("client_id");
JSONObject client = merchantInfoProvider.getClientInfo(clientId);
if (!client.getBooleanValue("manual_settle")) {
throw new ForbiddenException("Manual Settlement Not Enabled");
}
if (DateUtils.isSameDay(new Date(), settleTo)) {
throw new BadRequestException("Cannot settle today's transactions");
}
JSONObject currentTask = findCurrentSettle(clientId, false);
String taskId = currentTask.getString("task_id");
currentTask.put("request_time", new Date());
currentTask.put("client_id", clientId);
currentTask.put("applier_id", account.getString("account_id"));
currentTask.put("applier_name", account.getString("display_name"));
currentTask.put("settle_to", settleTo);
if (taskId != null) {
taskManualSettleMapper.update(currentTask);
} else {
taskManualSettleMapper.save(currentTask);
}
return currentTask;
}
@Override
public JSONObject findCurrentSettle(int clientId, boolean includingUnsettleData) {
JSONObject todayTask = taskManualSettleMapper.findTodayTask(clientId);
if (todayTask != null) {
todayTask.put("settle_to", DateFormatUtils.format(todayTask.getDate("settle_to"), "yyyy-MM-dd"));
} else {
todayTask = new JSONObject();
}
List<JSONObject> settleLogs = clearingLogMapper.findByDate(new Date());
//今天未清算则锁定
todayTask.put("locked", settleLogs.isEmpty());
if (includingUnsettleData) {
List<JSONObject> unsettleReports = transactionMapper.listClientUnsettleDataByDate(clientId);
unsettleReports.parallelStream().forEach(report -> report.put("date_str", DateFormatUtils.format(report.getDate("trans_date"), "yyyy-MM-dd")));
todayTask.put("unsettle", unsettleReports);
}
return todayTask;
}
}

@ -0,0 +1,5 @@
/**
*
* Create by yixian at 2018-03-20 17:42
*/
package au.com.royalpay.payment.manage.settlement;

@ -31,20 +31,22 @@
<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>
<if test="channel!=null">
and <foreach collection="channel" item="chan" open="(" close=")" separator=" or ">o.channel=#{chan}</foreach>
and
<foreach collection="channel" item="chan" open="(" close=")" separator=" or ">o.channel=#{chan}
</foreach>
</if>
</where>
</select>
<select id="listTransFlow" resultType="com.alibaba.fastjson.JSONObject">
SELECT t.*,
ifnull(o.client_order_id,'--') client_order_id,
if(t.channel='Settlement','clearing',
if(t.transaction_type='Credit','payment','refund')) trans_type,
t.system_transaction_id,
if(t.channel='Settlement',
if(locate('MERCHANT',t.system_transaction_id)>0, 'Transfer to Merchant','Merchant Service Fee'),
if(t.system_generate=0,t.order_id,t.remark)) order_id2,
ifnull(o.client_order_id,'--') client_order_id,
if(t.channel='Settlement','clearing',
if(t.transaction_type='Credit','payment','refund')) trans_type,
t.system_transaction_id,
if(t.channel='Settlement',
if(locate('MERCHANT',t.system_transaction_id)>0, 'Transfer to Merchant','Merchant Service Fee'),
if(t.system_generate=0,t.order_id,t.remark)) order_id2,
if(t.channel='Settlement','-',CASE t.clearing_status
WHEN 0 THEN 'ReadyToClear'
WHEN 1 THEN 'Cleared'
@ -72,7 +74,9 @@
<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>
<if test="channel!=null">
and <foreach collection="channel" item="chan" open="(" close=")" separator=" or ">o.channel=#{chan}</foreach>
and
<foreach collection="channel" item="chan" open="(" close=")" separator=" or ">o.channel=#{chan}
</foreach>
</if>
</where>
order by t.transaction_time desc
@ -95,14 +99,22 @@
sum(if(t.transaction_type='Debit' AND t.refund_id is NOT NULL and o.pre_authorization=1,t.clearing_amount,0))
pre_refund_fee,
ifnull(sum(if(t.transaction_type = 'Credit' and t.channel != 'Settlement',t.settle_amount,if(t.channel != 'Settlement',-t.settle_amount,0))),0) total_settle_amount,
ifnull(sum(if(t.transaction_type = 'Credit' and t.channel != 'Settlement',t.royal_surcharge,if(t.channel != 'Settlement',-t.royal_surcharge,0))),0) total_royal_surcharge,
ifnull(sum(if(t.transaction_type = 'Credit' and t.channel != 'Settlement',t.total_surcharge,if(t.channel != 'Settlement',-t.total_surcharge,0))),0) total_surcharge,
ifnull(sum(if(t.transaction_type = 'Credit' and t.channel = 'Wechat',t.channel_surcharge,if(t.channel = 'Wechat',-t.channel_surcharge,0))),0) wechat_fee,
ifnull(sum(if(t.transaction_type = 'Credit' and t.channel = 'Alipay',t.channel_surcharge,if(t.channel = 'Alipay',-t.channel_surcharge,0))),0) alipay_fee,
ifnull(sum(if(t.transaction_type = 'Credit' and t.channel = 'jd',t.channel_surcharge,if(t.channel = 'jd',-t.channel_surcharge,0))),0) jd_fee,
ifnull(sum(if(t.transaction_type = 'Credit' and t.channel = 'Bestpay',t.channel_surcharge,if(t.channel = 'Bestpay',-t.channel_surcharge,0))),0) bestpay_fee,
ifnull(sum(if(t.transaction_type = 'Credit' and t.channel = 'AlipayOnline',t.channel_surcharge,if(t.channel = 'AlipayOnline',-t.channel_surcharge,0))),0) alipay_online_fee
ifnull(sum(if(t.transaction_type = 'Credit' and t.channel != 'Settlement',t.settle_amount,if(t.channel !=
'Settlement',-t.settle_amount,0))),0) total_settle_amount,
ifnull(sum(if(t.transaction_type = 'Credit' and t.channel != 'Settlement',t.royal_surcharge,if(t.channel !=
'Settlement',-t.royal_surcharge,0))),0) total_royal_surcharge,
ifnull(sum(if(t.transaction_type = 'Credit' and t.channel != 'Settlement',t.total_surcharge,if(t.channel !=
'Settlement',-t.total_surcharge,0))),0) total_surcharge,
ifnull(sum(if(t.transaction_type = 'Credit' and t.channel = 'Wechat',t.channel_surcharge,if(t.channel =
'Wechat',-t.channel_surcharge,0))),0) wechat_fee,
ifnull(sum(if(t.transaction_type = 'Credit' and t.channel = 'Alipay',t.channel_surcharge,if(t.channel =
'Alipay',-t.channel_surcharge,0))),0) alipay_fee,
ifnull(sum(if(t.transaction_type = 'Credit' and t.channel = 'jd',t.channel_surcharge,if(t.channel =
'jd',-t.channel_surcharge,0))),0) jd_fee,
ifnull(sum(if(t.transaction_type = 'Credit' and t.channel = 'Bestpay',t.channel_surcharge,if(t.channel =
'Bestpay',-t.channel_surcharge,0))),0) bestpay_fee,
ifnull(sum(if(t.transaction_type = 'Credit' and t.channel = 'AlipayOnline',t.channel_surcharge,if(t.channel =
'AlipayOnline',-t.channel_surcharge,0))),0) alipay_online_fee
FROM pmt_transactions t
left JOIN pmt_orders o on o.order_id=t.order_id
<where>
@ -124,7 +136,9 @@
<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>
<if test="channel!=null">
and <foreach collection="channel" item="chan" open="(" close=")" separator=" or ">o.channel=#{chan}</foreach>
and
<foreach collection="channel" item="chan" open="(" close=")" separator=" or ">o.channel=#{chan}
</foreach>
</if>
</where>
</select>
@ -172,12 +186,16 @@
<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, c.client_id client_id,max(t.transaction_time) transation_time,c.client_moniker client_moniker
from pmt_transactions t INNER join sys_clients c
on t.client_id = c.client_id and c.enable_refund_auth = 0
group by c.client_id) a
where a.amount &lt; 0
SELECT *
FROM (SELECT
ifnull(sum(if(transaction_type = 'Credit', clearing_amount, -clearing_amount)), 0) amount,
c.client_id client_id,
max(t.transaction_time) transation_time,
c.client_moniker client_moniker
FROM pmt_transactions t INNER JOIN sys_clients c
ON t.client_id = c.client_id AND c.enable_refund_auth = 0
GROUP BY c.client_id) a
WHERE a.amount &lt; 0
</select>
<select id="validAnalysis" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[
@ -279,7 +297,8 @@
<if test="to!=null">and t.transaction_time &lt; #{to}</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>
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
</if>
GROUP BY DATE(t.transaction_time)
order by t.clearing_time desc
</select>
@ -298,7 +317,8 @@
<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>
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
</if>
GROUP BY c.client_id
order by total desc
</select>
@ -317,7 +337,8 @@
<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>
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
</if>
</select>
<select id="getAusTracData" resultType="com.alibaba.fastjson.JSONObject">
@ -457,33 +478,33 @@
<![CDATA[
SELECT
sum(if(t.transaction_type = 'Credit', t.clearing_amount, -t.clearing_amount)) * b.proportion
total,
total,
t.client_id,
m.org_id,
c.approve_time client_create_time,
c.source client_source,
date(t.transaction_time) trade_date,
t.channel channel,
c.approve_time client_create_time,
c.source client_source,
date(t.transaction_time) trade_date,
t.channel channel,
ifnull((SELECT min(r.rate_value)
FROM sys_client_rates r
WHERE r.client_id = t.client_id AND r.active_time <= t.transaction_time AND
r.expiry_time >= t.transaction_time AND
r.rate_name = 'Wechat'), 1) wechat_rate_value,
r.rate_name = 'Wechat'), 1) wechat_rate_value,
ifnull((SELECT min(r.rate_value)
FROM sys_client_rates r
WHERE r.client_id = t.client_id AND r.active_time <= t.transaction_time AND
r.expiry_time >= t.transaction_time AND
r.rate_name = 'Alipay'), 1) alipay_rate_value,
r.rate_name = 'Alipay'), 1) alipay_rate_value,
ifnull((SELECT min(r.rate_value)
FROM sys_client_rates r
WHERE r.client_id = t.client_id AND r.active_time <= t.transaction_time AND
r.expiry_time >= t.transaction_time AND
r.rate_name = 'Bestpay'), 1) bestpay_rate_value,
r.rate_name = 'Bestpay'), 1) bestpay_rate_value,
ifnull((SELECT min(r.rate_value)
FROM sys_client_rates r
WHERE r.client_id = t.client_id AND r.active_time <= t.transaction_time AND
r.expiry_time >= t.transaction_time AND
r.rate_name = 'jd'), 1) jd_rate_value,
r.rate_name = 'jd'), 1) jd_rate_value,
ifnull((SELECT min(r.rate_value)
FROM sys_client_rates r
WHERE r.client_id = t.client_id AND r.active_time <= t.transaction_time AND
@ -517,7 +538,7 @@
INNER JOIN sys_org so
ON c.referrer_id = so.org_id AND so.is_valid = 1 AND so.type = 1 AND so.commission = 1
WHERE year(t.transaction_time) = #{year} AND month(t.transaction_time) = #{month} AND t.channel != 'Settlement'
GROUP BY so.org_id, trade_date,t.client_id
GROUP BY so.org_id, trade_date, t.client_id
ORDER BY c.org_id ASC, t.client_id ASC, trade_date ASC
</select>
@ -525,33 +546,33 @@
<![CDATA[
SELECT
sum(if(t.transaction_type = 'Credit', t.clearing_amount, -t.clearing_amount))
total,
t.client_id client_id,
c.approve_time client_create_time,
c.source client_source,
date(t.transaction_time) trade_date,
t.channel channel,
ifnull(so.rate_value, 1) rate_value,
total,
t.client_id client_id,
c.approve_time client_create_time,
c.source client_source,
date(t.transaction_time) trade_date,
t.channel channel,
ifnull(so.rate_value, 1) rate_value,
ifnull((SELECT min(r.rate_value)
FROM sys_client_rates r
WHERE r.client_id = t.client_id AND r.active_time <= t.transaction_time AND
r.expiry_time >= t.transaction_time AND
r.rate_name = 'Wechat'), 1) wechat_rate_value,
r.rate_name = 'Wechat'), 1) wechat_rate_value,
ifnull((SELECT min(r.rate_value)
FROM sys_client_rates r
WHERE r.client_id = t.client_id AND r.active_time <= t.transaction_time AND
r.expiry_time >= t.transaction_time AND
r.rate_name = 'Alipay'), 1) alipay_rate_value,
r.rate_name = 'Alipay'), 1) alipay_rate_value,
ifnull((SELECT min(r.rate_value)
FROM sys_client_rates r
WHERE r.client_id = t.client_id AND r.active_time <= t.transaction_time AND
r.expiry_time >= t.transaction_time AND
r.rate_name = 'Bestpay'), 1) bestpay_rate_value,
r.rate_name = 'Bestpay'), 1) bestpay_rate_value,
ifnull((SELECT min(r.rate_value)
FROM sys_client_rates r
WHERE r.client_id = t.client_id AND r.active_time <= t.transaction_time AND
r.expiry_time >= t.transaction_time AND
r.rate_name = 'jd'), 1) jd_rate_value,
r.rate_name = 'jd'), 1) jd_rate_value,
ifnull((SELECT min(r.rate_value)
FROM sys_client_rates r
WHERE r.client_id = t.client_id AND r.active_time <= t.transaction_time AND
@ -561,7 +582,7 @@
INNER JOIN sys_clients c ON c.client_id = t.client_id
INNER JOIN sys_org so
ON c.org_id = so.org_id AND so.is_valid = 1 AND so.type = 0 AND so.parent_org_id = #{parent_org_id}
WHERE year(t.transaction_time) = #{year} AND month(t.transaction_time) = #{month} AND t.channel != 'Settlement'
WHERE year(t.transaction_time) = #{year} AND month(t.transaction_time) = #{month} AND t.channel != 'Settlement'
GROUP BY t.client_id, trade_date, channel
ORDER BY c.org_id ASC, t.client_id ASC, trade_date ASC
]]>
@ -676,7 +697,8 @@
select sum(if(t.transaction_type='Credit',settle_amount,-settle_amount)) settle_amount ,
DATE_FORMAT(t.transaction_time,'%Y%m%d') weekend
from pmt_transactions t
INNER JOIN log_clearing_detail d on d.clear_detail_id=t.clearing_order and DAYOFWEEK(d.report_date)>2 and clear_days = 1
INNER JOIN log_clearing_detail d on d.clear_detail_id=t.clearing_order and DAYOFWEEK(d.report_date)>2 and
clear_days = 1
where (DAYOFWEEK(t.transaction_time)=1 or DAYOFWEEK(t.transaction_time) = 7)
<if test="begin!=null">
and t.transaction_time &gt; #{begin}
@ -722,5 +744,15 @@
and t.clearing_order is not NULL
group by client_id
</select>
<select id="listClientUnsettleDataByDate" resultType="com.alibaba.fastjson.JSONObject">
SELECT
date(transaction_time) trans_date,
sum(if(transaction_type = 'Credit', clearing_amount, -clearing_amount)) clearing_amount,
sum(if(transaction_type = 'Credit', settle_amount, -settle_amount)) settle_amount
FROM pmt_transactions t
WHERE t.client_id = #{client_id} AND t.clearing_status = 0
GROUP BY trans_date
ORDER BY trans_date DESC
</select>
</mapper>
Loading…
Cancel
Save