Merge remote-tracking branch 'origin/develop' into develop

master
Tayl0r 7 years ago
commit 354b6b6595

@ -231,3 +231,9 @@ CREATE TABLE `sys_wx_merchant_apply` (
`operator` varchar(50) DEFAULT NULL,
PRIMARY KEY (`merchant_app_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
alter table statistics_customer_order add column refund_orders int(10) DEFAULT NULL COMMENT '' AFTER `orders`;
alter table statistics_customer_order add column refund_amount DECIMAL(20,2) DEFAULT NULL COMMENT '' AFTER `total`;
ALTER TABLE `financial_bd_prize_log`
MODIFY COLUMN `manager_id` varchar(50) NOT NULL COMMENT 'bd user id' AFTER `record_id`;

@ -53,12 +53,10 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT
@Override
public JSONObject getCommonAnalysis1(JSONObject params) {
JSONObject res = new JSONObject();
JSONObject res = transactionAnalysisMapper.getClientTransaction(params);
res.put("new_partners", clientAnalysisMapper.countNewClients(params));
res.put("total_partners", clientAnalysisMapper.countClients(params));
res.put("traded_partners", clientAnalysisMapper.countTradedPartners(params));
res.put("trade_amount", transactionAnalysisMapper.analysisTotalAmount(params));
// res.put("trade_count", transactionAnalysisMapper.analysisTotalCount(params));
// List<JSONObject> topOrders = transactionAnalysisMapper.getTopOrders(params, new PageBounds(1, 1, Order.formString("aud_fee.desc")));
// if (!topOrders.isEmpty()) {
// res.put("top_amount_order", topOrders.get(0));
@ -75,7 +73,7 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT
// res.put("total_partners", clientAnalysisMapper.countClients(params));
// res.put("traded_partners", clientAnalysisMapper.countTradedPartners(params));
// res.put("trade_amount", transactionAnalysisMapper.analysisTotalAmount(params));
res.put("trade_count", transactionAnalysisMapper.analysisTotalCount(params));
// res.put("trade_count", transactionAnalysisMapper.getClientTransaction(params).getIntValue("trade_count"));
List<JSONObject> topOrders = transactionAnalysisMapper.getTopOrders(params, new PageBounds(1, 1, Order.formString("aud_fee.desc")));
if (!topOrders.isEmpty()) {
res.put("top_amount_order", topOrders.get(0));
@ -212,7 +210,10 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT
@Override
public List<JSONObject> getTradeAnalysisInDays(JSONObject params) {
return transactionAnalysisMapper.tradeAnalysisInDays(params);
if (!params.containsKey("client_ids") && !params.containsKey("org_id")) {
params.put("client_id", 0);
}
return customerAndOrdersStatisticsMapper.getSumCustomersAnalysis(params);
}
@Override
@ -227,9 +228,10 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT
}
JSONObject res = new JSONObject();
params.put("client_id", partner.getIntValue("client_id"));
res.put("trade_amount", transactionAnalysisMapper.analysisTotalAmount(params));
res.put("trade_count", transactionAnalysisMapper.analysisTotalCount(params));
res.put("refund_amount", transactionAnalysisMapper.analysisRefundAmount(params));
JSONObject object = transactionAnalysisMapper.getClientTransaction(params);
res.put("trade_amount", object.getBigDecimal("trade_amount"));
res.put("trade_count", object.getIntValue("trade_count"));
res.put("refund_amount", object.getBigDecimal("refund_amount"));
res.put("not_settled", transactionAnalysisMapper.analysisNotSettled(params));
res.put("pre_amount", transactionAnalysisMapper.analysisPreAmount(params));
List<JSONObject> topOrders = transactionAnalysisMapper.getTopOrders(params, new PageBounds(1, 1, Order.formString("aud_fee.desc")));

@ -71,4 +71,5 @@ public interface TransactionAnalysisMapper {
int getCountCustomers(@Param("date") Date date);
JSONObject getClientTransaction(JSONObject params);
}

@ -24,6 +24,8 @@ public interface RetailAppService {
JSONObject listOrders(JSONObject device, AppQueryBean query);
JSONObject listOrdersNew(JSONObject device, AppQueryBean query);
JSONObject listOrdersShareCode(JSONObject device, AppQueryBean query);
void updateDevToken(JSONObject device, String devToken);

@ -173,10 +173,10 @@ public class RetailAppServiceImp implements RetailAppService {
}
JSONObject params = appQueryBean.toParams();
setAllClientIds(params, client_id);
JSONObject res = new JSONObject();
params.put("client_id", client_id);
res.put("trade_amount", transactionAnalysisMapper.analysisTotalAmount(params));
res.put("trade_count", transactionAnalysisMapper.analysisTotalCount(params));
JSONObject res = transactionAnalysisMapper.getClientTransaction(params);
// res.put("trade_amount", transactionAnalysisMapper.analysisTotalAmount(params));
// res.put("trade_count", transactionAnalysisMapper.analysisTotalCount(params));
// res.put("refund_amount", transactionAnalysisMapper.analysisRefundAmount(params));
res.put("not_settled", transactionAnalysisMapper.analysisNotSettled(params));
res.put("old_customers", transactionAnalysisMapper.countOldCustomers(params));
@ -199,10 +199,11 @@ public class RetailAppServiceImp implements RetailAppService {
}
JSONObject params = appQueryBean.toParams();
setAllClientIds(params, client_id);
JSONObject res = new JSONObject();
params.put("client_id", client_id);
res.put("trade_amount", transactionAnalysisMapper.analysisTotalAmount(params));
res.put("trade_count", transactionAnalysisMapper.analysisTotalCount(params));
JSONObject res = transactionAnalysisMapper.getClientTransaction(params);
// res.put("trade_amount", transactionAnalysisMapper.analysisTotalAmount(params));
// res.put("trade_count", transactionAnalysisMapper.analysisTotalCount(params));
res.put("not_settled", transactionAnalysisMapper.analysisNotSettled(params));
return res;
}
@ -356,6 +357,7 @@ public class RetailAppServiceImp implements RetailAppService {
params.put("dev_id", device.getString("dev_id"));
}
params.put("client_id", client_id);
PageList<JSONObject> orders = orderMapper.listOrdersByClients(params,
new PageBounds(query.getPage(), query.getLimit(), Order.formString("create_time.desc")));
TimeZoneUtils.switchTimeZone(orders, query.getTimezone(), "create_time", "transaction_time", "confirm_time");
@ -387,6 +389,70 @@ public class RetailAppServiceImp implements RetailAppService {
return PageListUtils.buildPageListResult(orders);
}
@Override
public JSONObject listOrdersNew(JSONObject device, AppQueryBean query) {
String clientType = device.getString("client_type");
DeviceRegister register = deviceSupport.findRegister(clientType);
int client_id = device.getIntValue("client_id");
JSONObject client = clientManager.getClientInfo(client_id);
String timezone = client.getString("timezone");
if (timezone != null && !timezone.isEmpty()) {
query.setTimezone(timezone);
}
JSONObject params = query.toParams();
setAllClientIds(params, client_id);
if (register.includeDevId()) {
params.put("dev_id", device.getString("dev_id"));
}
params.put("client_id", client_id);
PageList<JSONObject> orders = orderMapper.listTransactionsForApp(params,
new PageBounds(query.getPage(), query.getLimit(), Order.formString("create_time.desc")));
TimeZoneUtils.switchTimeZone(orders, query.getTimezone(), "create_time", "transaction_time", "confirm_time");
ArrayList<String> date_contains = new ArrayList<>();
for (JSONObject order : orders) {
String customer_id = order.getString("customer_id");
if (StringUtils.isEmpty(customer_id)) {
continue;
}
switch (order.getString("channel")) {
case "Alipay":
JSONObject alipayUser = customerRelationAlipayMapper.findCustomerByUserId(customer_id);
order.put("nickname", alipayUser.getString("nickname"));
order.put("headimg", alipayUser.getString("headimg"));
break;
case "Wechat":
JSONObject weUser = customerMapper.findCustomerByOpenId(customer_id);
order.put("nickname", weUser.getString("nickname"));
order.put("headimg", weUser.getString("headimg"));
break;
default:
break;
}
Calendar calendar = (Calendar) order.get("create_time");
String trade_date = DateFormatUtils.format(calendar, "yyyy-MM-dd");
String trade_time = DateFormatUtils.format(calendar, "HH:mm:ss");
order.put("trade_date", trade_date);
order.put("trade_time", trade_time);
if (!date_contains.contains(trade_date)) {
String re_date = trade_date.replaceAll("-", "");
TradeLogQuery date_query = new TradeLogQuery();
date_query.setDatefrom(re_date);
date_query.setDateto(re_date);
// date_query.setStatus(OrderStatus.ALL);
if (params.containsKey("client_ids")) {
date_query.setClient_ids((String[]) params.get("client_ids"));
}
JSONObject date_params = date_query.toParams(query.getTimezone());
date_params.put("client_id", device.getIntValue("client_id"));
JSONObject analysis = orderMapper.analysisOrders(date_params);
order.put("date_total", analysis);
date_contains.add(trade_date);
}
}
return PageListUtils.buildPageListResult(orders);
}
@Override
public JSONObject listOrdersShareCode(JSONObject device, AppQueryBean query) {
query.setGateway_app("11");

@ -4,6 +4,11 @@ import au.com.royalpay.payment.core.exceptions.ParamInvalidException;
import au.com.royalpay.payment.manage.appclient.beans.AppClientBean;
import au.com.royalpay.payment.manage.appclient.beans.AppQueryBean;
import au.com.royalpay.payment.manage.appclient.core.RetailAppService;
import au.com.royalpay.payment.manage.bill.bean.NewBillBean;
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.signin.beans.ChangePwdBean;
import au.com.royalpay.payment.manage.signin.core.SignInStatusManager;
import au.com.royalpay.payment.tools.CommonConsts;
@ -39,6 +44,10 @@ public class RetailAppController {
private RetailAppService retailAppService;
@Resource
private SignInStatusManager signInStatusManager;
@Resource
private BillOrderService billOrderService;
@Resource
private BillService billService;
@RequestMapping(value = "/token", method = RequestMethod.PUT)
public void updateDevToken(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @RequestBody JSONObject token) {
@ -78,6 +87,11 @@ public class RetailAppController {
return retailAppService.listOrders(device, query);
}
@RequestMapping(value = "/orders_new", method = RequestMethod.GET)
public JSONObject listOrdersNew(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, AppQueryBean query) {
return retailAppService.listOrdersNew(device, query);
}
@RequestMapping(value = "/orders/share_code", method = RequestMethod.GET)
public JSONObject listOrdersShareCode(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, AppQueryBean query) {
return retailAppService.listOrdersShareCode(device, query);
@ -279,4 +293,31 @@ public class RetailAppController {
public JSONObject getAdDetail(@PathVariable String article_id,@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) {
return retailAppService.getAdDetail(device,article_id);
}
@RequestMapping(value = "/bills/{bill_id}",method = RequestMethod.GET)
public JSONObject getBill(@PathVariable("bill_id")String bill_id,@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device){
return billService.getBillDetail(bill_id,device.getIntValue("client_id"));
}
@RequestMapping(value = "/bills/list",method = RequestMethod.GET)
public JSONObject getBills(QueryBillBean queryBillBean,@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device){
return billService.queryBills(device.getIntValue("client_id"),queryBillBean);
}
@RequestMapping(value = "/bills",method = RequestMethod.PUT)
public JSONObject addBill(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device,@RequestBody NewBillBean newBillBean){
JSONObject result = billService.save(device.getIntValue("client_id"),newBillBean);
result.remove("bill");
return result;
}
@RequestMapping(value = "/bills/{bill_id}/close",method = RequestMethod.POST)
public void closeBill(@PathVariable("bill_id")String bill_id,@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device){
billService.updateBillStatus(bill_id,"2",device.getIntValue("client_id"));
}
@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){
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;
}
}

@ -143,7 +143,7 @@ public class BDPrizeServiceImpl implements BDPrizeService {
BigDecimal send_prize = groupPrize;
JSONObject prizeLog = new JSONObject();
prizeLog.put("record_id", record.getString("record_id"));
prizeLog.put("manager_id", leader.getIntValue("manager_id"));
prizeLog.put("manager_id", leader.getString("manager_id"));
prizeLog.put("bd_name", leader.getString("display_name"));
prizeLog.put("bd_level", 0);
prizeLog.put("total_amount", groupAmount);

@ -23,10 +23,10 @@ public class BDPrizeCalculatorDefaultImpl implements BDPrizeCalculator {
private final Date month;
private ClientBDMapper clientBDMapper;
private DefaultClientWithBDAwayDeterminor clientsWithBDAwayDeterminor;
private Map<Integer, Map<String, JSONObject>> results = new HashMap<>();
private Map<Integer, JSONObject> bdMap = new HashMap<>();
private Map<String, Map<String, JSONObject>> results = new HashMap<>();
private Map<String, JSONObject> bdMap = new HashMap<>();
private Map<Integer, Map<Integer, List<JSONObject>>> rateConfigMap = new HashMap<>();
private Map<Integer, BigDecimal> bdTotalMap = new HashMap<>();
private Map<String, BigDecimal> bdTotalMap = new HashMap<>();
public BDPrizeCalculatorDefaultImpl(List<JSONObject> tradeLogs, Date month) {
this.tradeLogs = tradeLogs;
@ -75,7 +75,7 @@ public class BDPrizeCalculatorDefaultImpl implements BDPrizeCalculator {
@Override
public List<JSONObject> getReport() {
List<JSONObject> report = new ArrayList<>();
for (Map.Entry<Integer, Map<String, JSONObject>> resultItem : results.entrySet()) {
for (Map.Entry<String, Map<String, JSONObject>> resultItem : results.entrySet()) {
JSONObject log = new JSONObject();
log.put("manager_id", resultItem.getKey());
JSONObject bd = bdMap.get(resultItem.getKey());
@ -123,7 +123,7 @@ public class BDPrizeCalculatorDefaultImpl implements BDPrizeCalculator {
Date tradeDate = trade.getDate("trade_date");
List<JSONObject> bdUsers = clientBDMapper.listClientBDAvailable(clientId, tradeDate);
for (JSONObject bd : bdUsers) {
int bdId = bd.getIntValue("bd_id");
String bdId = bd.getString("bd_id");
int bdLevel = bd.getIntValue("bd_level");
boolean getPrize = bd.getBooleanValue("get_prize");
if (!getPrize) {
@ -173,7 +173,7 @@ public class BDPrizeCalculatorDefaultImpl implements BDPrizeCalculator {
return monthDiff;
}
private JSONObject initDetail(int clientId, int bdId, int months, int clientSource, BigDecimal rateValue, BigDecimal coefficient, Date tradeDate) {
private JSONObject initDetail(int clientId, String bdId, int months, int clientSource, BigDecimal rateValue, BigDecimal coefficient, Date tradeDate) {
JSONObject detail;
detail = new JSONObject();
detail.put("client_id", clientId);

@ -0,0 +1,49 @@
package au.com.royalpay.payment.manage.bill.bean;
import java.math.BigDecimal;
/**
* Created by wangning on 11/02/2018.
*/
public class NewBillBean {
private BigDecimal amount;
private String currency;
private String remark;
private String expire;
public BigDecimal getAmount() {
return amount;
}
public void setAmount(BigDecimal amount) {
this.amount = amount;
}
public String getCurrency() {
return currency;
}
public void setCurrency(String currency) {
this.currency = currency;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public String getExpire() {
return expire;
}
public void setExpire(String expire) {
this.expire = expire;
}
}

@ -0,0 +1,41 @@
package au.com.royalpay.payment.manage.bill.bean;
import com.alibaba.fastjson.JSONObject;
/**
* Created by wangning on 26/02/2018.
*/
public class QueryBillBean {
private String status;
private int page = 1;
private int limit = 20;
public JSONObject toParams(){
JSONObject params = new JSONObject();
params.put("status",status);
return params;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public int getPage() {
return page;
}
public void setPage(int page) {
this.page = page;
}
public int getLimit() {
return limit;
}
public void setLimit(int limit) {
this.limit = limit;
}
}

@ -0,0 +1,41 @@
package au.com.royalpay.payment.manage.bill.bean;
import com.alibaba.fastjson.JSONObject;
/**
* Created by wangning on 26/02/2018.
*/
public class QueryBillOrderBean {
private String status;
private int page = 1;
private int limit = 20;
public JSONObject toParams(){
JSONObject param = new JSONObject();
param.put("status",status);
return param;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public int getPage() {
return page;
}
public void setPage(int page) {
this.page = page;
}
public int getLimit() {
return limit;
}
public void setLimit(int limit) {
this.limit = limit;
}
}

@ -0,0 +1,19 @@
package au.com.royalpay.payment.manage.bill.core;
import au.com.royalpay.payment.manage.bill.bean.QueryBillOrderBean;
import com.alibaba.fastjson.JSONObject;
import java.util.List;
/**
* Created by wangning on 11/02/2018.
*/
public interface BillOrderService {
List<JSONObject> getByBillId(String bill_id, int client_id);
JSONObject query(String bill_id,int client_id, QueryBillOrderBean queryBillOrderBean);
JSONObject analysis(String bill_id,int client_id, QueryBillOrderBean queryBillOrderBean);
}

@ -0,0 +1,23 @@
package au.com.royalpay.payment.manage.bill.core;
import au.com.royalpay.payment.manage.bill.bean.NewBillBean;
import au.com.royalpay.payment.manage.bill.bean.QueryBillBean;
import com.alibaba.fastjson.JSONObject;
/**
* Created by wangning on 11/02/2018.
*/
public interface BillService {
JSONObject getBillDetail(String billId,int client_id);
void updateBillStatus(String billId,String status,int client_id);
void removeBill(String billId);
JSONObject save(int client_id,NewBillBean newBillBean);
JSONObject queryBills(int client_id, QueryBillBean queryBillBean);
}

@ -0,0 +1,75 @@
package au.com.royalpay.payment.manage.bill.core.impl;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList;
import au.com.royalpay.payment.manage.bill.bean.QueryBillOrderBean;
import au.com.royalpay.payment.manage.bill.core.BillOrderService;
import au.com.royalpay.payment.manage.mappers.bill.BillMapper;
import au.com.royalpay.payment.manage.mappers.bill.BillOrderMapper;
import au.com.royalpay.payment.manage.mappers.system.CustomerRelationAlipayMapper;
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import au.com.royalpay.payment.tools.utils.PageListUtils;
/**
* Created by wangning on 11/02/2018.
*/
@Service
public class BillOrderServiceImpl implements BillOrderService {
@Resource
private BillOrderMapper billOrderMapper;
@Resource
private BillMapper billMapper;
@Resource
private CustomerRelationAlipayMapper customerRelationAlipayMapper;
@Override
public List<JSONObject> getByBillId(String bill_id, int client_id) {
JSONObject bill = billMapper.findOne(bill_id);
if (bill.getIntValue("client_id") != client_id) {
throw new BadRequestException("You have no right to check this bill");
}
List<JSONObject> wechatBillOrders = billOrderMapper.findByBillIdWithWechatInfo(bill_id);
for (JSONObject order : wechatBillOrders) {
if ("Alipay".equals(order.getString("channel"))) {
JSONObject alipayInfo = customerRelationAlipayMapper.findCustomerByUserId(order.getString("customer_id"));
if (alipayInfo != null) {
order.put("nickname", alipayInfo.getString("nickname"));
order.put("headimg", alipayInfo.getString("headimg"));
}
}
}
return wechatBillOrders;
}
@Override
public JSONObject query(String bill_id, int client_id, QueryBillOrderBean queryBillOrderBean) {
JSONObject bill = billMapper.findOne(bill_id);
if (bill.getIntValue("client_id") != client_id) {
throw new BadRequestException("You have no right to check this bill");
}
PageList<JSONObject> list = billOrderMapper.query(bill_id, queryBillOrderBean.toParams(),
new PageBounds(queryBillOrderBean.getPage(), queryBillOrderBean.getLimit()));
for (JSONObject order : list) {
order.put("currency",bill.getString("currency"));
}
return PageListUtils.buildPageListResult(list);
}
@Override
public JSONObject analysis(String bill_id, int client_id, QueryBillOrderBean queryBillOrderBean) {
JSONObject bill = billMapper.findOne(bill_id);
if (bill.getIntValue("client_id") != client_id) {
throw new BadRequestException("You have no right to check this bill");
}
return billOrderMapper.analysis(bill_id, queryBillOrderBean.toParams());
}
}

@ -0,0 +1,110 @@
package au.com.royalpay.payment.manage.bill.core.impl;
import java.math.BigDecimal;
import java.util.Date;
import javax.annotation.Resource;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList;
import au.com.royalpay.payment.manage.bill.bean.NewBillBean;
import au.com.royalpay.payment.manage.bill.bean.QueryBillBean;
import au.com.royalpay.payment.manage.bill.core.BillService;
import au.com.royalpay.payment.manage.mappers.bill.BillMapper;
import au.com.royalpay.payment.manage.merchants.core.ClientManager;
import au.com.royalpay.payment.tools.CommonConsts;
import au.com.royalpay.payment.tools.env.PlatformEnvironment;
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
import au.com.royalpay.payment.tools.utils.PageListUtils;
/**
* Created by wangning on 11/02/2018.
*/
@Service
public class BillServiceImpl implements BillService {
@Resource
private BillMapper billMapper;
@Resource
private ClientManager clientManager;
@Override
public JSONObject save(int client_id, NewBillBean newBillBean) {
JSONObject client = clientManager.getClientInfo(client_id);
// if(client==null){
// throw new NotFoundException("client info not found");
// }
Date now = new Date();
JSONObject record = new JSONObject();
record.put("client_id", client_id);
record.put("price", newBillBean.getAmount().divide(CommonConsts.HUNDRED,2, BigDecimal.ROUND_DOWN));
record.put("currency", newBillBean.getCurrency());
record.put("remark", newBillBean.getRemark());
record.put("create_time", now);
record.put("cancle_time", addExpire(now, newBillBean.getExpire()));
record.put("status", 1);
billMapper.save(record);
JSONObject result = new JSONObject();
result.put("partner_name",client.getString("short_name"));
result.put("partner_code",client.getString("client_moniker"));
result.put("full_name",client.getString("company_name"));
result.put("code_url", PlatformEnvironment.getEnv().concatUrl("/api/v1.0/share_code/bills/payment/orders/"+record.getString("bill_id")));
result.put("bill",record);
return result;
}
@Override
public JSONObject queryBills(int client_id, QueryBillBean queryBillBean) {
JSONObject params = queryBillBean.toParams();
params.put("client_id", client_id);
PageList<JSONObject> list = billMapper.listWithOrderAnalysis(params, new PageBounds(queryBillBean.getPage(), queryBillBean.getLimit()));
return PageListUtils.buildPageListResult(list);
}
@Override
public JSONObject getBillDetail(String billId, int client_id) {
JSONObject bill = billMapper.findOne(billId);
if (bill.getIntValue("client_id") != client_id) {
throw new BadRequestException("You have no right to check this bill");
}
return bill;
}
@Override
public void updateBillStatus(String billId, String status, int client_id) {
JSONObject bill = billMapper.findOne(billId);
if (bill.getIntValue("client_id") != client_id) {
throw new BadRequestException("You have no right to check this bill");
}
JSONObject record = new JSONObject();
record.put("bill_id", billId);
record.put("status", status);
billMapper.update(record);
}
@Override
public void removeBill(String billId) {
billMapper.delete(billId);
}
private Date addExpire(Date now, String expire) {
if (Integer.valueOf(expire.substring(0, expire.length() - 1)) == 0) {
return null;
}
String unit = expire.substring(expire.length() - 1, expire.length());
switch (unit) {
case "s":
return DateUtils.addSeconds(now, Integer.valueOf(expire.substring(0, expire.length() - 1)));
case "h":
return DateUtils.addHours(now, Integer.valueOf(expire.substring(0, expire.length() - 1)));
case "d":
return DateUtils.addDays(now, Integer.valueOf(expire.substring(0, expire.length() - 1)));
}
throw new ServerErrorException("日期单位不正确");
}
}

@ -0,0 +1,36 @@
package au.com.royalpay.payment.manage.mappers.bill;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList;
import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper;
import cn.yixblog.support.mybatis.autosql.annotations.AutoSql;
import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
/**
* Create by yixian at 2017-12-19 19:09
*/
@AutoMapper(tablename = "pmt_bill", pkName = "bill_id")
public interface BillMapper {
@AutoSql(type = SqlType.INSERT)
int save(JSONObject record);
@AutoSql(type = SqlType.SELECT)
JSONObject findOne(@Param("bill_id") String bill_id);
@AutoSql(type = SqlType.UPDATE)
int update(JSONObject record);
@AutoSql(type = SqlType.SELECT)
List<JSONObject> findByClientId(@Param("client_id") int client_id);
@AutoSql(type = SqlType.DELETE)
void delete(@Param("bill_id") String billId);
PageList<JSONObject> listWithOrderAnalysis(@Param("param") JSONObject jsonObject, PageBounds pageBounds);
}

@ -0,0 +1,39 @@
package au.com.royalpay.payment.manage.mappers.bill;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList;
import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper;
import cn.yixblog.support.mybatis.autosql.annotations.AutoSql;
import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
/**
* Create by yixian at 2017-12-19 19:09
*/
@AutoMapper(tablename = "pmt_bill_order_relation", pkName = "bill_id")
public interface BillOrderMapper {
@AutoSql(type = SqlType.INSERT)
JSONObject save(JSONObject record);
@AutoSql(type = SqlType.UPDATE)
int update(JSONObject record);
List<JSONObject> findByBillIdWithWechatInfo(@Param("bill_id") String bill_id);
List<JSONObject> findByBillIdWithAlipayInfo(@Param("bill_id") String bill_id);
@AutoSql(type = SqlType.SELECT)
JSONObject findByClientId(@Param("client_id") int client_id);
@AutoSql(type = SqlType.SELECT)
List<JSONObject> findByBillId(@Param("bill_id") String bill_id);
PageList<JSONObject> query(@Param("bill_id") String bill_id, @Param("param") JSONObject jsonObject, PageBounds pageBounds);
JSONObject analysis(@Param("bill_id")String bill_id,@Param("param")JSONObject jsonObject);
}

@ -77,4 +77,6 @@ public interface OrderMapper {
List<JSONObject> listOrdersByClientsNoPages(JSONObject params);
List<JSONObject> listAnalysisClientCustomer(JSONObject params);
PageList<JSONObject> listTransactionsForApp(JSONObject params, PageBounds pageBounds);
}

@ -87,7 +87,7 @@
<select id="listPartnersTradeAmount" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[
SELECT
p.client_moniker,p.short_name,ifnull(sum(if(t.transaction_type='Credit',t.clearing_amount,-t.clearing_amount)),0)aud_fee,
p.client_moniker,p.short_name,ifnull(sum(if(t.transaction_type='Credit',t.clearing_amount,0)),0)aud_fee,
count(DISTINCT t.order_id) orders,max(t.clearing_amount)max_order,ifnull(sum(if(t.refund_id is not null,if(t.transaction_type='Debit',t.clearing_amount,-t.clearing_amount),0)),0)refund_amount,
ifnull(sum(if(t.refund_id is not null and t.transaction_type='Debit',1,0)),0)refund_orders,max(if(t.refund_id is not null and t.transaction_type='Debit',t.clearing_amount,0))max_refund
FROM sys_clients p

@ -39,6 +39,7 @@
<select id="getSumOrdersAndCustomersDaily" resultType="com.alibaba.fastjson.JSONObject">
SELECT sum(s.customers) customers,sum(s.orders) orders,sum(s.new_customers) new_customers,
sum(s.old_customers) old_customers,sum(s.total) total, sum(s.total)/sum(s.customers) single_amount,
sum(s.refund_amount) refund_amount,sum(s.refund_orders) refund_orders,
date_format(s.date,'%d/%m/%Y') trade_date
FROM statistics_customer_order s
<where>
@ -175,9 +176,8 @@
</where>
</select>-->
<select id="getSumCustomersChannelAnalysis" resultType="com.alibaba.fastjson.JSONObject">
SELECT SUM(IF(t.transaction_type = 'Credit', t.clearing_amount, -t.clearing_amount)) AS total_amount
SELECT SUM(IF(t.transaction_type = 'Credit', t.clearing_amount,0)) AS total_amount
FROM pmt_transactions t
<where>
t.transaction_time >= #{begin}

@ -197,8 +197,8 @@
</select>
<select id="listCustomersData" resultType="com.alibaba.fastjson.JSONObject">
SELECT o.customer_id,sum(if(t.transaction_type='Credit',t.clearing_amount,-t.clearing_amount)) amount,
sum(if(t.transaction_type='Credit',t.clearing_amount div 10,-(t.clearing_amount div 10))) points,
SELECT o.customer_id,sum(if(t.transaction_type='Credit',t.clearing_amount,0)) amount,
sum(if(t.transaction_type='Credit',t.clearing_amount div 10,0)) points,
COUNT(DISTINCT o.order_id) orders,max(t.clearing_amount) max_order
FROM pmt_orders o
INNER JOIN pmt_transactions t on t.order_id=o.order_id and t.system_generate=0 and (t.transaction_type='Credit' or t.transaction_type>0)
@ -228,8 +228,8 @@
</select>
<select id="listCustomersDataAnalysis" resultType="com.alibaba.fastjson.JSONObject">
SELECT sum(if(t.transaction_type='Credit',t.clearing_amount,-t.clearing_amount)) total_amount,
sum(if(t.transaction_type='Credit',t.clearing_amount div 10,-(t.clearing_amount div 10))) total_points
SELECT sum(if(t.transaction_type='Credit',t.clearing_amount,0)) total_amount,
sum(if(t.transaction_type='Credit',t.clearing_amount div 10,0)) total_points
FROM pmt_orders o
INNER JOIN pmt_transactions t on t.order_id=o.order_id and t.system_generate=0 and (t.transaction_type='Credit' or t.refund_id is not null)
<where>

@ -20,7 +20,7 @@
<select id="getTransactionCommonAnalysis" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[
SELECT ifnull(sum(if(t.transaction_type = 'Credit',t.clearing_amount,-t.clearing_amount)), 0) total_amount,
SELECT ifnull(sum(if(t.transaction_type = 'Credit' ,t.clearing_amount,0)), 0) total_amount,
ifnull(sum(if(t.transaction_type = 'Credit' and t.refund_id is null,1,0)), 0) total_count,
ifnull(sum(if(t.refund_id is not null,if(t.transaction_type = 'Debit',t.clearing_amount,-t.clearing_amount),0)), 0) refund_amount,
ifnull(sum(if(t.clearing_status != 1,if(t.transaction_type = 'Credit',t.clearing_amount,-t.clearing_amount),0)), 0) notsettle_amount,
@ -99,7 +99,6 @@
</if>
</select>
<select id="analysisNotSettled" resultType="java.lang.Double">
<![CDATA[
SELECT ifnull(sum(if(transaction_type = 'Credit', clearing_amount, -clearing_amount)), 0)
@ -136,7 +135,6 @@
</if>
</select>
<select id="getTopOrders" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[
SELECT
@ -169,6 +167,7 @@
]]>
</select>
<select id="getTradeAmountInTypes" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[
SELECT
@ -198,7 +197,7 @@
WHEN 11
THEN 'Share Code'
END AS gateway_label,
ifnull(sum(if(l.transaction_type='Credit',l.clearing_amount,-l.clearing_amount)), 0) aud_fee
ifnull(sum(if(l.transaction_type='Credit',l.clearing_amount,0)), 0) aud_fee
FROM pmt_transactions l
INNER JOIN pmt_orders o ON o.order_id = l.order_id
WHERE (l.transaction_type = 'Credit' or l.refund_id is not null)
@ -211,11 +210,12 @@
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if>
GROUP BY gateway_label
</select>
<select id="tradeAnalysisInHours" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[
SELECT h, round(sum(count)/datediff(#{end},#{begin}),1) count, round(sum(aud_fee)/datediff(#{end},#{begin}),2) aud_fee
FROM(
SELECT HOUR(o.create_time) h, DATE(o.create_time) dt, sum(if(l.transaction_type='Credit' and l.refund_id is null,1,0)) count, ifnull(sum(if(l.transaction_type='Credit',l.clearing_amount,-l.clearing_amount)), 0) aud_fee
SELECT HOUR(o.create_time) h, DATE(o.create_time) dt, sum(if(l.transaction_type='Credit' and l.refund_id is null,1,0)) count, ifnull(sum(if(l.transaction_type='Credit',l.clearing_amount,0)), 0) aud_fee
FROM pmt_transactions l
inner join pmt_orders o on o.order_id = l.order_id
WHERE (l.transaction_type='Credit' or l.refund_id is not null)
@ -252,11 +252,12 @@
order by h
]]>
</select>
<select id="tradeAnalysisInDays" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[
SELECT
date_format(o.create_time, '%Y-%m-%d') date_str,
ifnull(sum(if(l.transaction_type = 'Credit', l.clearing_amount, -l.clearing_amount)), 0) aud_fee,
ifnull(sum(if(l.transaction_type = 'Credit', l.clearing_amount, 0)), 0) aud_fee,
ifnull(sum(if(l.transaction_type='Credit' and l.refund_id is null,1,0)),0) order_count
FROM pmt_transactions l
INNER JOIN pmt_orders o ON o.order_id = l.order_id AND o.create_time >= #{begin} AND o.create_time <= #{end}
@ -279,11 +280,12 @@
ORDER BY date(o.create_time)
]]>
</select>
<select id="tradeAnalysisInDay" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[
SELECT
date_format(#{end}, '%Y-%m-%d') date_str,
ifnull(sum(if(l.transaction_type = 'Credit', l.clearing_amount, -l.clearing_amount)), 0) aud_fee,
date_format(#{begin}, '%Y-%m-%d') date_str,
ifnull(sum(if(l.transaction_type = 'Credit', l.clearing_amount,0)), 0) aud_fee,
ifnull(sum(if(l.transaction_type='Credit' and l.refund_id is null,1,0)),0) order_count
FROM pmt_transactions l
INNER JOIN pmt_orders o ON o.order_id = l.order_id AND o.create_time >= #{begin} AND o.create_time <= #{end}
@ -466,9 +468,10 @@
GROUP BY gateway_label
</select>
<select id="getPartnersByTradeType" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[
SELECT c.short_name ,ifnull(SUM(if(l.transaction_type = 'Credit',l.clearing_amount,-l.clearing_amount)), 0) total
SELECT c.short_name ,ifnull(SUM(if(l.transaction_type = 'Credit',l.clearing_amount,0)), 0) total
FROM pmt_transactions l
INNER JOIN pmt_orders o ON o.order_id = l.order_id
left JOIN sys_clients c on c.client_id=o.client_id AND c.is_valid=1
@ -542,6 +545,7 @@
<!--</if>-->
<!--<if test="org_id!=null">and l.org_id=#{org_id}</if>-->
<!--</select>-->
<select id="getOrdersByGateway" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[
SELECT po.create_time,
@ -607,7 +611,9 @@
COUNT(DISTINCT o.order_id) AS orders,
COUNT(DISTINCT o.customer_id) AS customers,
o.channel AS channel,
ifnull(SUM(if(t.transaction_type = 'Credit', t.clearing_amount, -t.clearing_amount)), 0) AS total,
ifnull(SUM(if(t.transaction_type = 'Credit', t.clearing_amount, 0)), 0) AS total,
ifnull(SUM(if(t.refund_id>0, t.clearing_amount, 0)), 0) AS refund_amount,
SUM(if(t.refund_id>0, 1, 0)) AS refund_orders,
round(SUM(if(t.transaction_type='Credit',t.clearing_amount,0))/COUNT(DISTINCT o.customer_id),2) single_amount
FROM pmt_transactions t
INNER JOIN pmt_orders o ON o.order_id = t.order_id
@ -629,9 +635,10 @@
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if>
GROUP BY date , channel ORDER BY date DESC
</select>
<select id="getOrgTransactionAnalysis" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[
SELECT o.org_id, o.name org_name,sum(if(t.transaction_type='Credit',t.clearing_amount,-t.clearing_amount)) amount
SELECT o.org_id, o.name org_name,sum(if(t.transaction_type='Credit',t.clearing_amount,0)) amount
FROM pmt_transactions t
INNER JOIN pmt_orders ord on ord.order_id = t.order_id
RIGHT JOIN sys_clients c on t.client_id = c.client_id and c.is_valid = 1
@ -645,9 +652,10 @@
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if>
GROUP BY o.org_id order by amount desc
</select>
<select id="getPartnersAmountByOrg" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[
SELECT c.client_moniker,c.short_name,sum(if(t.transaction_type='Credit',t.clearing_amount,-t.clearing_amount)) amount
SELECT c.client_moniker,c.short_name,sum(if(t.transaction_type='Credit',t.clearing_amount,0)) amount
FROM pmt_transactions t
INNER JOIN pmt_orders ord on ord.order_id = t.order_id
RIGHT JOIN sys_clients c on t.client_id = c.client_id and c.is_valid = 1 AND c.org_id = #{org_id}
@ -658,9 +666,10 @@
GROUP BY c.client_id order by amount desc
</select>
<select id="getPlatformAmount" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[
SELECT ifnull(sum(if(l.transaction_type = 'Credit',l.clearing_amount,-l.clearing_amount)), 0) amount,
SELECT ifnull(sum(if(l.transaction_type = 'Credit',l.clearing_amount,0)), 0) amount,
ifnull(count(DISTINCT l.order_id), 0) order_count
FROM pmt_transactions l
INNER JOIN pmt_orders o ON o.order_id = l.order_id AND o.create_time >= #{begin} AND
@ -709,6 +718,8 @@
<if test="amount_to!=null">and t.clearing_amount &lt; #{amount_to}</if>
</select>
<!--交易金额分析 饼图 -->
<!--不更改-->
<select id="getAmountRangeAnalysis" resultType="com.alibaba.fastjson.JSONObject">
select
sum(if(t.clearing_amount &gt;= 0 and t.clearing_amount &lt; 20,1,0)) amount0_20,
@ -729,4 +740,29 @@
<if test="client_moniker!=null">and c.client_moniker=#{client_moniker}</if>
<if test="channel!=null">and t.channel=#{channel}</if>
</select>
<select id="getClientTransaction" resultType="com.alibaba.fastjson.JSONObject">
select
IFNULL(sum(if(l.transaction_type='credit',l.clearing_amount,0)),0) trade_amount,
ifnull(sum(if(l.refund_id>0,l.clearing_amount,0)),0) refund_amount,
sum(if(l.transaction_type='Credit',1,0)) trade_count,
sum(if(l.refund_id>0,1,0)) refund_orders
FROM pmt_transactions l
where l.channel!='Settlement' and l.system_generate=0
<if test="client_ids!=null">
AND l.client_id IN
<foreach collection="client_ids" open="(" close=")" separator="," item="client_id">
#{client_id}
</foreach>
</if>
<if test="client_ids==null and client_id != null">
and l.client_id=#{client_id}
</if>
<if test="begin!=null">and l.transaction_time &gt;= #{begin}</if>
<if test="end!=null">and l.transaction_time &lt; #{end}</if>
<if test="org_id!=null and org_ids==null">and l.org_id=#{org_id}</if>
<if test="org_ids!=null">and l.org_id in
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if>
</select>
</mapper>

@ -0,0 +1,18 @@
<?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="au.com.royalpay.payment.manage.mappers.bill.BillMapper">
<select id="listWithOrderAnalysis" resultType="com.alibaba.fastjson.JSONObject" >
select b.bill_id,b.status,b.currency,DATE_FORMAT(b.create_time,'%Y-%c-%e') create_date, DATE_FORMAT(b.create_time,'%H:%m:%s') create_time,b.remark,b.price,count(o.bill_order_id) order_counts,sum(o.order_total_amount) order_total_amount
from pmt_bill b left join pmt_bill_order o
on b.bill_id = o.bill_id and o.order_status &lt; 2
<where>
b.client_id = #{param.client_id}
<if test="param.status != null">
and o.order_status = #{param.status}
</if>
</where>
group by b.bill_id,create_time,create_date,b.remark,b.price,b.status,b.currency
order by b.create_time desc
</select>
</mapper>

@ -0,0 +1,33 @@
<?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="au.com.royalpay.payment.manage.mappers.bill.BillOrderMapper">
<select id="findByBillIdWithWechatInfo" resultType="com.alibaba.fastjson.JSONObject">
select o.client_id,o.order_id,o.order_total_amount,o.order_status,o.create_time,o.customer_id,
r.nickname,r.headimg
from pmt_bill_order o left join sys_customer_relation r on r.wechat_openid = o.customer_id and o.channel = 'Wechat' and o.bill_id = #{bill_id}
</select>
<select id="findByBillIdWithAlipayInfo" resultType="com.alibaba.fastjson.JSONObject">
select o.client_id,o.order_id,o.order_total_amount,o.order_status,o.create_time,o.customer_id,
r.nickname,r.headimg
from pmt_bill_order o left join sys_customer_relation_alipay r on r.alipay_uid = o.customer_id and o.channel = 'Alipay' and o.bill_id = #{bill_id}
</select>
<select id="query" resultType="com.alibaba.fastjson.JSONObject">
select * from pmt_bill_order
where
bill_id = #{bill_id}
<if test="param.status != null">
and order_status = #{param.status}
</if>
order by create_time
</select>
<select id="analysis" resultType="com.alibaba.fastjson.JSONObject">
select count(1) counts from pmt_bill_order
where
bill_id = #{bill_id}
<if test="param.status != null">
and order_status = #{param.status}
</if>
</select>
</mapper>

@ -95,6 +95,8 @@
<update id="updateRefundAmount">
<![CDATA[
UPDATE pmt_orders o
LEFT JOIN (
SELECT
@ -113,16 +115,23 @@
THEN 7
END
WHERE o.order_id = #{order_id}
]]>
</update>
<update id="updateOrderCreationError">
<![CDATA[
UPDATE pmt_orders
SET status = #{status}, error_code = #{error_code}, error_message = #{error_message}
WHERE order_id = #{order_id} AND status <= #{status}
]]>
</update>
<select id="listOrders" resultType="com.alibaba.fastjson.JSONObject">
<if test="bd_user!=null">
SELECT temp.* FROM (
@ -150,7 +159,8 @@
<bind name="name_pattern" value="'%'+search_text+'%'"/>
<if test="text_type=='all'">
and (p.client_moniker=#{search_text} or p.short_name like #{name_pattern} or o.order_detail like
#{name_pattern} or t.system_transaction_id =#{search_text} or o.channel = #{search_text} or t.order_id =#{search_text})
#{name_pattern} or t.system_transaction_id =#{search_text} or o.channel = #{search_text} or
t.order_id =#{search_text})
</if>
<if test="text_type=='client_moniker'">
and p.client_moniker=#{search_text}
@ -177,16 +187,20 @@
</if>
<if test="org_id!=null and org_ids==null">and p.org_id=#{org_id}</if>
<if test="org_ids!=null">and p.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>
<if test="from!=null">and o.create_time &gt;= #{from}</if>
<if test="to!=null">and o.create_time &lt; #{to}</if>
<if test="date!=null">and date(o.create_time)=date(#{date})</if>
<if test="dev_id!=null">and o.dev_id=#{dev_id}</if>
<if test="status!=null">
and <foreach collection="status" item="std" open="(" close=")" separator=" or ">o.status=#{std}</foreach>
and
<foreach collection="status" item="std" open="(" close=")" separator=" or ">o.status=#{std}</foreach>
</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>
<if test="bd_group!=null">and p.client_id in
(SELECT b.client_id FROM sys_client_bd b
@ -263,7 +277,8 @@
<bind name="name_pattern" value="'%'+search_text+'%'"/>
<if test="text_type=='all'">
and (p.client_moniker=#{search_text} or p.short_name like #{name_pattern} or o.order_detail like
#{name_pattern} or t.system_transaction_id=#{search_text} or o.channel = #{search_text} or t.order_id = #{search_text}
#{name_pattern} or t.system_transaction_id=#{search_text} or o.channel = #{search_text} or
t.order_id = #{search_text}
or o.client_order_id = #{search_text})
</if>
<if test="text_type=='client_moniker'">
@ -294,33 +309,42 @@
</if>
<if test="org_id!=null and org_ids==null">and p.org_id=#{org_id}</if>
<if test="org_ids!=null">and p.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>
<if test="from!=null">and o.create_time &gt;= #{from}</if>
<if test="to!=null">and o.create_time &lt; #{to}</if>
<if test="date!=null">and date(o.create_time)=date(#{date})</if>
<if test="status!=null">
and <foreach collection="status" item="std" open="(" close=")" separator=" or ">o.status=#{std}</foreach>
and
<foreach collection="status" item="std" open="(" close=")" separator=" or ">o.status=#{std}</foreach>
</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>
GROUP BY o.order_id,t.refund_id
</select>
<select id="analysisOrders" resultType="com.alibaba.fastjson.JSONObject">
select
count(DISTINCT l.order_id) order_count,
ifnull(sum(if(l.transaction_type='Credit' and l.refund_id is null,l.clearing_amount,0)),0) paid_fee,
ifnull(sum(if(l.transaction_type='Credit',l.clearing_amount,0)),0) paid_fee,
ifnull(sum(if(l.refund_id is not null,if(l.transaction_type='Debit',-l.clearing_amount,l.clearing_amount),0)),0)
refund_fee,
ifnull(sum(if(l.refund_id is not null AND l.pre_authorization=1,l.clearing_amount,0)),0)
pre_refund_fee,
count(DISTINCT l.customer_id) customers,
ifnull(sum(if(l.transaction_type='Credit' and l.refund_id is null and l.currency!='CNY',l.display_amount,0)),0) display_amount,
ifnull(sum(if(l.transaction_type='Credit' and l.refund_id is null and l.currency!='CNY' and l.pre_authorization=1,l.display_amount,0)),0) pre_display_amount,
ifnull(sum(if(l.transaction_type='Credit' and l.refund_id is null and l.currency='CNY',l.display_amount,0)),0) cny_display_amount,
ifnull(sum(if(l.transaction_type='Credit' and l.refund_id is null and l.currency='CNY' and l.pre_authorization=1,l.display_amount,0)),0) pre_cny_display_amount
ifnull(sum(if(l.transaction_type='Credit' and l.refund_id is null and l.currency!='CNY',l.display_amount,0)),0)
display_amount,
ifnull(sum(if(l.transaction_type='Credit' and l.refund_id is null and l.currency!='CNY' and
l.pre_authorization=1,l.display_amount,0)),0) pre_display_amount,
ifnull(sum(if(l.transaction_type='Credit' and l.refund_id is null and l.currency='CNY',l.display_amount,0)),0)
cny_display_amount,
ifnull(sum(if(l.transaction_type='Credit' and l.refund_id is null and l.currency='CNY' and
l.pre_authorization=1,l.display_amount,0)),0) pre_cny_display_amount
from (
<if test="bd_user!=null">
SELECT temp.* FROM (
@ -344,7 +368,8 @@
<bind name="name_pattern" value="'%'+search_text+'%'"/>
<if test="text_type=='all'">
and (p.client_moniker=#{search_text} or p.short_name like #{name_pattern} or o.order_detail like
#{name_pattern} or t.system_transaction_id=#{search_text} or o.channel = #{search_text} or t.order_id = #{search_text}
#{name_pattern} or t.system_transaction_id=#{search_text} or o.channel = #{search_text} or
t.order_id = #{search_text}
or o.client_order_id = #{search_text})
</if>
<if test="text_type=='client_moniker'">
@ -373,7 +398,8 @@
</if>
</if>
<if test="org_ids!=null">and p.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>
<if test="order_id!=null">and o.order_id=#{order_id}</if>
<if test="trade_type!=null">and o.gateway in
<foreach collection="trade_type" item="gateway" open="(" close=")" separator=",">#{gateway}</foreach>
@ -384,10 +410,13 @@
<if test="date!=null">and date(o.create_time)=date(#{date})</if>
<if test="dev_id!=null">and o.dev_id=#{dev_id}</if>
<if test="status!=null">
and <foreach collection="status" item="std" open="(" close=")" separator=" or ">o.status=#{std}</foreach>
and
<foreach collection="status" item="std" open="(" close=")" separator=" or ">o.status=#{std}</foreach>
</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>
<if test="bd_group!=null">and p.client_id in
(SELECT b.client_id FROM sys_client_bd b
@ -449,6 +478,8 @@
</select>
<select id="listOrdersWithNoTransactions" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[
SELECT
o.order_id,
o.channel
@ -457,6 +488,8 @@
SELECT DISTINCT order_id
FROM pmt_transactions
WHERE transaction_type = 'Credit') AND o.status >= 5 AND o.customer_payment_amount > 0
]]>
</select>
@ -468,6 +501,7 @@
WHERE o.customer_id = #{customer_id} and t.transaction_time &gt;= '2017-11-07'
</select>
<select id="listOrderByCustomer" resultType="com.alibaba.fastjson.JSONObject">
SELECT o.*,c.short_name,c.client_moniker FROM pmt_orders o
LEFT JOIN sys_clients c on c.client_id = o.client_id
@ -483,7 +517,8 @@
<if test="to!=null">and o.create_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>
</where>
</select>
@ -514,7 +549,8 @@
<bind name="name_pattern" value="'%'+search_text+'%'"/>
<if test="text_type=='all'">
and (p.client_moniker=#{search_text} or p.short_name like #{name_pattern} or o.order_detail like
#{name_pattern} or t.system_transaction_id=#{search_text} or o.channel = #{search_text} or t.order_id = #{search_text})
#{name_pattern} or t.system_transaction_id=#{search_text} or o.channel = #{search_text} or
t.order_id = #{search_text})
</if>
<if test="text_type=='client_moniker'">
and p.client_moniker=#{search_text}
@ -541,15 +577,19 @@
</if>
<if test="org_id!=null and org_ids==null">and p.org_id=#{org_id}</if>
<if test="org_ids!=null">and p.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>
<if test="from!=null">and o.create_time &gt;= #{from}</if>
<if test="to!=null">and o.create_time &lt; #{to}</if>
<if test="date!=null">and date(o.create_time)=date(#{date})</if>
<if test="status!=null">
and <foreach collection="status" item="std" open="(" close=")" separator=" or ">o.status=#{std}</foreach>
and
<foreach collection="status" item="std" open="(" close=")" separator=" or ">o.status=#{std}</foreach>
</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>
GROUP BY o.order_id,t.refund_id
@ -558,24 +598,24 @@
<select id="listAnalysisClientCustomer" resultType="com.alibaba.fastjson.JSONObject">
SELECT
count(*) payment_times ,
sum(customer_payment_amount) total_amount,
o.client_id client_id,
o.customer_id customer_id,
o.channel channel,
max( o.confirm_time) confirm_time
SELECT
count(*) payment_times ,
sum(customer_payment_amount) total_amount,
o.client_id client_id,
o.customer_id customer_id,
o.channel channel,
max( o.confirm_time) confirm_time
from pmt_orders o
where o.customer_id is not null and o.channel is not null
and client_id = #{client_id}
<if test="confirm_time">
and o.confirm_time > #{confirm_time}
</if>
<if test="include_success_status!=null">
and o.status >#{include_success_status}
</if>
group by o.customer_id
from pmt_orders o
where o.customer_id is not null and o.channel is not null
and client_id = #{client_id}
<if test="confirm_time">
and o.confirm_time > #{confirm_time}
</if>
<if test="include_success_status!=null">
and o.status >#{include_success_status}
</if>
group by o.customer_id
</select>
<select id="listPaid" resultType="com.alibaba.fastjson.JSONObject">
SELECT * FROM pmt_orders
@ -585,7 +625,63 @@
and client_id = #{client_id}
</if>
<if test="channels != null">
and channel IN <foreach collection="channels" item="channel" open="(" close=")" separator=",">#{channel}</foreach>
and channel IN
<foreach collection="channels" item="channel" open="(" close=")" separator=",">#{channel}</foreach>
</if>
</where>
</select>
<select id="listTransactionsForApp" resultType="com.alibaba.fastjson.JSONObject">
select
o.order_id,
o.client_id,
o.display_amount,
o.customer_payment_amount,
o.coupon_payment_amount,
o.currency,
o.create_time,
o.confirm_time,
o.status,
o.gateway,
o.channel,
o.pre_authorization,
o.refund_amount refund_fee,
o.customer_id,
t.clearing_amount,
t.refund_id,
t.transaction_time,
t.transaction_type,
t.transaction_id,
t.exchange_rate,
t.clearing_status,
t.settle_amount
from pmt_orders o
left join pmt_transactions t on t.order_id=o.order_id and t.channel!='Settlement' and t.system_generate=0
<where>
<if test="client_ids!=null">
AND o.client_id IN
<foreach collection="client_ids" open="(" close=")" separator="," item="client_id">
#{client_id}
</foreach>
</if>
<if test="client_ids==null and client_id !=null">
and o.client_id=#{client_id}
</if>
<if test="from!=null">and o.create_time &gt;= #{from}</if>
<if test="to!=null">and o.create_time &lt; #{to}</if>
<if test="date!=null">and date(o.create_time)=date(#{date})
</if>
<if test="trade_type!=null">and o.gateway in
<foreach collection="trade_type" item="gateway" open="(" close=")" separator=",">#{gateway}</foreach>
</if>
<if test="status!=null">
and
<foreach collection="status" item="std" open="(" close=")" separator=" or ">o.status=#{std}</foreach>
</if>
<if test="channel!=null">
and
<foreach collection="channel" item="chan" open="(" close=")" separator=" or ">o.channel=#{chan}
</foreach>
</if>
</where>
</select>

@ -158,6 +158,7 @@
FROM pmt_transactions
WHERE clearing_status = 0 AND client_id = #{client_id}
</select>
<select id="getClientAmountAnalysis" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[
SELECT
@ -228,6 +229,7 @@
ORDER BY t.transaction_type, t.transaction_time
]]>
</select>
<select id="listSettlementLog" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[
SELECT t.client_id,DATE(t.transaction_time) clearing_time,SUM(t.clearing_amount) total,
@ -423,6 +425,7 @@
WHERE t.transaction_type = 'Credit' OR t.refund_id IS NOT NULL
ORDER BY t.order_id ASC
</select>
<select id="listTransactionsForBDPrize" resultType="com.alibaba.fastjson.JSONObject">
SELECT
sum(if(t.transaction_type = 'Credit', t.clearing_amount, -t.clearing_amount))

@ -11,7 +11,7 @@
width: 100%;
height: 100%;
background-color: #d2d6de;
background: url(../images/bg.jpg);
background: url(../images/bg1.jpg);
/*background: url(../images/logonbg.jpg) ;*/
position: relative;
background-size: 100% 100%;

@ -128,6 +128,8 @@ define(['angular', 'uiRouter', 'uiBootstrap', 'angularEcharts'], function (angul
$scope.analysis.total_partners = resp.data.total_partners;
$scope.analysis.traded_partners = resp.data.traded_partners;
$scope.analysis.trade_amount = resp.data.trade_amount;
$scope.analysis.trade_count = resp.data.trade_count;
// $scope.analysis.top_amount_order = resp.data.top_amount_order;
// $scope.analysis.trade_count = resp.data.trade_count;
// $scope.analysis.total_customers = resp.data.total_customers;
@ -140,7 +142,7 @@ define(['angular', 'uiRouter', 'uiBootstrap', 'angularEcharts'], function (angul
// $scope.analysis.traded_partners = resp.data.traded_partners;
// $scope.analysis.trade_amount = resp.data.trade_amount;
$scope.analysis.top_amount_order = resp.data.top_amount_order;
$scope.analysis.trade_count = resp.data.trade_count;
// $scope.analysis.trade_count = resp.data.trade_count;
$scope.analysis.total_customers = resp.data.total_customers;
$scope.analysis.new_customers = resp.data.total_customers - resp.data.old_customers;
$scope.analysis.old_customers = resp.data.old_customers;
@ -444,17 +446,17 @@ define(['angular', 'uiRouter', 'uiBootstrap', 'angularEcharts'], function (angul
type: 'category',
boundaryGap: false
},
key: 'date_str'
key: 'trade_date'
},
series: [
{
basic: {type: 'line', label: {normal: {show: true}}, showAllSymbols: true},
column: {key: 'aud_fee'}
column: {key: 'total'}
}
]
};
$http.get('/dashboard/system/fee_analysis', {params: params}).then(function (resp) {
$scope.analysis.trade_line = chartParser.parse(analysisConfig, resp.data);
$scope.analysis.trade_line = chartParser.parse(analysisConfig, resp.data.reverse());
})
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 514 KiB

@ -93,11 +93,13 @@ $(function () {
$('#audVal').html(dataCache.price);
var realPrice = dataCache.price;
$('#audValReal').html(realPrice);
var poundage = updatePoundage(realPrice);
var surchargeData = calculateSurcharge(realPrice);
var price = poundage || realPrice;
var price = surchargeData.newPrice || realPrice;
var priceBeforeDiscount = price;
dataCache.discounts = [];
dataCache.tax = surchargeData.tax;
dataCache.surcharge = surchargeData.surcharge;
$(window.coupons).each(function () {
price = this.handleDiscount(price, dataCache.price, dataCache.discounts, dataCache.coupons);
});
@ -199,8 +201,11 @@ $(function () {
var bd = $('.weui_dialog_bd', dialog);
var currencySymbol = window.currency == 'AUD' ? '$' : '¥';
$('<p></p>').html('Input Price 输入金额:' + currencySymbol + dataCache.price).appendTo(bd);
if (dataCache.poundageValue > 0) {
$('<p></p>').html('Surcharge 手续费(' + window.rateValue + '%):+' + currencySymbol + dataCache.poundageValue).appendTo(bd);
if (parseFloat(dataCache.surcharge) > 0) {
$('<p></p>').html('Surcharge 手续费(' + window.rateValue + '%):+' + currencySymbol + dataCache.surcharge).appendTo(bd);
}
if (parseFloat(dataCache.tax) > 0) {
$('<p></p>').html('GST(10%):'+currencySymbol+dataCache.tax).appendTo(bd);
}
$(dataCache.discounts).each(function () {
$('<p></p>').html(this.title + ':-' + currencySymbol + this.amount).appendTo(bd);

@ -82,9 +82,11 @@ $(function () {
$('#audVal').html(dataCache.price);
var realPrice = dataCache.price;
$('#audValReal').html(realPrice);
var poundage = updatePoundage(realPrice);
var surchargeData = calculateSurcharge(realPrice);
var price = poundage || realPrice;
dataCache.tax = surchargeData.tax;
dataCache.surcharge = surchargeData.surcharge;
var price = surchargeData.newPrice || realPrice;
var priceBeforeDiscount = price;
dataCache.discounts = [];
$(window.coupons).each(function () {
@ -188,8 +190,11 @@ $(function () {
var bd = $('.weui_dialog_bd', dialog);
var currencySymbol = window.currency == 'AUD' ? '$' : '¥';
$('<p></p>').html('Input Price 输入金额:' + currencySymbol + dataCache.price).appendTo(bd);
if (dataCache.poundageValue > 0) {
$('<p></p>').html('Surcharge 手续费(' + window.rateValue + '%):+' + currencySymbol + dataCache.poundageValue).appendTo(bd);
if (parseFloat(dataCache.surcharge) > 0) {
$('<p></p>').html('Surcharge 手续费(' + window.rateValue + '%):+' + currencySymbol + dataCache.surcharge).appendTo(bd);
}
if (parseFloat(dataCache.tax) > 0) {
$('<p></p>').html('GST(10%):'+currencySymbol+dataCache.tax).appendTo(bd);
}
$(dataCache.discounts).each(function () {
$('<p></p>').html(this.title + ':-' + currencySymbol + this.amount).appendTo(bd);

@ -86,11 +86,13 @@ $(function () {
$('#audVal').html(dataCache.price);
var realPrice = dataCache.price;
$('#audValReal').html(realPrice);
var poundage = updatePoundage(realPrice);
var surchargeData = calculateSurcharge(realPrice);
var price = poundage || realPrice;
var price = surchargeData.newPrice || realPrice;
var priceBeforeDiscount = price;
dataCache.discounts = [];
dataCache.tax = surchargeData.tax;
dataCache.surcharge = surchargeData.surcharge;
$(window.coupons).each(function () {
price = this.handleDiscount(price, dataCache.price, dataCache.discounts, dataCache.coupons);
});
@ -192,8 +194,11 @@ $(function () {
var bd = $('.weui_dialog_bd', dialog);
var currencySymbol = window.currency == 'CNY' ? '¥' : '$';
$('<p></p>').html('Input Price 输入金额:' + currencySymbol + dataCache.price).appendTo(bd);
if (dataCache.poundageValue > 0) {
$('<p></p>').html('Surcharge 手续费(' + window.rateValue + '%):+' + currencySymbol + dataCache.poundageValue).appendTo(bd);
if (parseFloat(dataCache.surcharge) > 0) {
$('<p></p>').html('Surcharge 手续费(' + window.rateValue + '%):+' + currencySymbol + dataCache.surcharge).appendTo(bd);
}
if (parseFloat(dataCache.tax) > 0) {
$('<p></p>').html('GST(10%):'+currencySymbol+dataCache.tax).appendTo(bd);
}
$(dataCache.discounts).each(function () {
$('<p></p>').html(this.title + ':-' + currencySymbol + this.amount).appendTo(bd);
@ -305,6 +310,7 @@ $(function () {
}
})
}
checkOrderStd();
}

Loading…
Cancel
Save