Merge remote-tracking branch 'origin/develop'

master
james.zhao 6 years ago
commit 05dfec70e6

@ -341,6 +341,7 @@
* 如果需要可以用相同订单号再次发起支付单支付成功或支付中的无法重复发起订单 * 如果需要可以用相同订单号再次发起支付单支付成功或支付中的无法重复发起订单
* @apiSuccess {String} order_id RoyalPay订单ID同时也是微信订单ID最终支付成功的订单ID可能不同 * @apiSuccess {String} order_id RoyalPay订单ID同时也是微信订单ID最终支付成功的订单ID可能不同
* @apiSuccess {String} partner_order_id 商户订单ID * @apiSuccess {String} partner_order_id 商户订单ID
* @apiSuccess {String} channel_order_id 渠道方(支付宝微信)交易流水号
* @apiSuccess {int} total_fee 订单金额单位是货币最小面值单位 * @apiSuccess {int} total_fee 订单金额单位是货币最小面值单位
* @apiSuccess {int} real_fee 实际支付金额单位是货币最小面值单位(目前等于订单金额为卡券预留) * @apiSuccess {int} real_fee 实际支付金额单位是货币最小面值单位(目前等于订单金额为卡券预留)
* @apiSuccess {Double} rate 交易时使用的汇率1AUD=?CNY * @apiSuccess {Double} rate 交易时使用的汇率1AUD=?CNY
@ -636,6 +637,7 @@
* @apiParam (JSON) {String} nonce_str 随机字符串 * @apiParam (JSON) {String} nonce_str 随机字符串
* @apiParam (JSON) {String} sign 签名 * @apiParam (JSON) {String} sign 签名
* @apiParam (JSON) {String} partner_order_id 商户订单ID * @apiParam (JSON) {String} partner_order_id 商户订单ID
* @apiParam (JSON) {String} channel_order_id 渠道方(支付宝微信)交易流水号
* @apiParam (JSON) {String} order_id RoyalPay订单ID * @apiParam (JSON) {String} order_id RoyalPay订单ID
* @apiParam (JSON) {int} total_fee 订单金额单位是最小货币单位 * @apiParam (JSON) {int} total_fee 订单金额单位是最小货币单位
* @apiParam (JSON) {int} real_fee 支付金额单位是最小货币单位 * @apiParam (JSON) {int} real_fee 支付金额单位是最小货币单位

@ -352,6 +352,7 @@
* Use the same order id to call create order API can renew the order. PAYING, PAY_SUCCESS orders cannot be renewed. * Use the same order id to call create order API can renew the order. PAYING, PAY_SUCCESS orders cannot be renewed.
* @apiSuccess {String} order_id Order id in RoyalPay, which is also WeChat order id. The final order id which is paid may be different from this one * @apiSuccess {String} order_id Order id in RoyalPay, which is also WeChat order id. The final order id which is paid may be different from this one
* @apiSuccess {String} partner_order_id Partner order id * @apiSuccess {String} partner_order_id Partner order id
* @apiSuccess {String} channel_order_id PayChannel(AlipayWechat) Transaction Trade No
* @apiSuccess {int} total_fee Order amount, which uses the base unit of current currency * @apiSuccess {int} total_fee Order amount, which uses the base unit of current currency
* @apiSuccess {int} real_fee Actual paid amount.(Equal to total fee at the moment. After coupon feature is finished, this value may be different. ) * @apiSuccess {int} real_fee Actual paid amount.(Equal to total fee at the moment. After coupon feature is finished, this value may be different. )
* @apiSuccess {Double} rate Exchange Rate used while trading. 1AUD=?CNY * @apiSuccess {Double} rate Exchange Rate used while trading. 1AUD=?CNY
@ -646,6 +647,7 @@
* @apiParam (JSON) {String} nonce_str Random string * @apiParam (JSON) {String} nonce_str Random string
* @apiParam (JSON) {String} sign Sign * @apiParam (JSON) {String} sign Sign
* @apiParam (JSON) {String} partner_order_id Partner order id * @apiParam (JSON) {String} partner_order_id Partner order id
* @apiParam (JSON) {String} channel_order_id PayChannel(AlipayWechat) Transaction Trade No
* @apiParam (JSON) {String} order_id RoyalPay order id * @apiParam (JSON) {String} order_id RoyalPay order id
* @apiParam (JSON) {int} total_fee Order amount * @apiParam (JSON) {int} total_fee Order amount
* @apiParam (JSON) {int} real_fee Actual paid amount * @apiParam (JSON) {int} real_fee Actual paid amount

@ -7,13 +7,15 @@ import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds; import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
* Created by davep on 2016-07-28. * Created by davep on 2016-07-28.
*/ */
@AutoMapper(tablename = "sys_clients", pkName = "client_id", pkAutoIncrement = true) @AutoMapper(tablename = "sys_clients", pkName = "client_id", keyGenerator = Jdbc3KeyGenerator.class)
public interface ClientAnalysisMapper { public interface ClientAnalysisMapper {
int countNewClients(JSONObject params); int countNewClients(JSONObject params);
@ -44,5 +46,7 @@ public interface ClientAnalysisMapper {
List<JSONObject> notTradeSubMerchantId(); List<JSONObject> notTradeSubMerchantId();
List<JSONObject> tradeSubMerchantIdBy60Days(@Param("begin") Date begin);
List<JSONObject> countClientsSettlementCycle(JSONObject params); List<JSONObject> countClientsSettlementCycle(JSONObject params);
} }

@ -1,7 +1,9 @@
package au.com.royalpay.payment.manage.analysis.mappers; package au.com.royalpay.payment.manage.analysis.mappers;
import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper; import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper;
import cn.yixblog.support.mybatis.autosql.annotations.AutoSql; import cn.yixblog.support.mybatis.autosql.annotations.AutoSql;
import cn.yixblog.support.mybatis.autosql.annotations.SqlType; import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
import cn.yixblog.support.mybatis.paginator.annotations.CountRef;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds; import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList; import com.github.miemiedev.mybatis.paginator.domain.PageList;
@ -12,7 +14,7 @@ import java.util.List;
/** /**
* Created by yishuqian on 09/11/2016. * Created by yishuqian on 09/11/2016.
*/ */
@AutoMapper(tablename = "statistics_customer_order",pkName = "id") @AutoMapper(tablename = "statistics_customer_order", pkName = "id")
public interface CustomerAndOrdersStatisticsMapper { public interface CustomerAndOrdersStatisticsMapper {
@AutoSql(type = SqlType.INSERT) @AutoSql(type = SqlType.INSERT)
void save(JSONObject jsonObject); void save(JSONObject jsonObject);
@ -50,8 +52,11 @@ public interface CustomerAndOrdersStatisticsMapper {
JSONObject getCommonCount(JSONObject params); JSONObject getCommonCount(JSONObject params);
@CountRef(".countAreaMerchantTradeAnalysis")
PageList<JSONObject> getAreaMerchantTradeAnalysis(JSONObject params, PageBounds pageBounds); PageList<JSONObject> getAreaMerchantTradeAnalysis(JSONObject params, PageBounds pageBounds);
int countAreaMerchantTradeAnalysis(JSONObject params);
List<JSONObject> countTradedClientsByDate(JSONObject parasm); List<JSONObject> countTradedClientsByDate(JSONObject parasm);
List<JSONObject> getAreaMerchantTradeByLastCycle(JSONObject parasm); List<JSONObject> getAreaMerchantTradeByLastCycle(JSONObject parasm);

@ -1,5 +1,6 @@
package au.com.royalpay.payment.manage.analysis.mappers; package au.com.royalpay.payment.manage.analysis.mappers;
import cn.yixblog.support.mybatis.paginator.annotations.CountRef;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds; import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList; import com.github.miemiedev.mybatis.paginator.domain.PageList;
@ -21,7 +22,10 @@ public interface OrderAnalysisMapper {
JSONObject analysisOrderSuccessRateDetailOfGlobal(@Param("date") Date date); JSONObject analysisOrderSuccessRateDetailOfGlobal(@Param("date") Date date);
@CountRef(".countCustomersData")
PageList<JSONObject> listCustomersData(JSONObject params, PageBounds pageBounds); PageList<JSONObject> listCustomersData(JSONObject params, PageBounds pageBounds);
int countCustomersData(JSONObject params);
JSONObject listCustomersDataAnalysis(JSONObject params); JSONObject listCustomersDataAnalysis(JSONObject params);
} }

@ -1,6 +1,7 @@
package au.com.royalpay.payment.manage.analysis.mappers; package au.com.royalpay.payment.manage.analysis.mappers;
import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper; import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper;
import cn.yixblog.support.mybatis.paginator.annotations.CountRef;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds; import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList; import com.github.miemiedev.mybatis.paginator.domain.PageList;
@ -65,22 +66,29 @@ public interface TransactionAnalysisMapper {
JSONObject getAmountRangeAnalysis(JSONObject params); JSONObject getAmountRangeAnalysis(JSONObject params);
@CountRef(".countAmountRangeOrders")
PageList<JSONObject> listAmountRangeOrders(JSONObject params, PageBounds pagination); PageList<JSONObject> listAmountRangeOrders(JSONObject params, PageBounds pagination);
int countAmountRangeOrders(JSONObject params);
BigDecimal getOneOrder(@Param("order_id") String order_id); BigDecimal getOneOrder(@Param("order_id") String order_id);
int getCountCustomers(@Param("date") Date date); int getCountCustomers(@Param("date") Date date);
JSONObject getClientTransaction(JSONObject params); JSONObject getClientTransaction(JSONObject params);
PageList<JSONObject> getAreaMerchantAmountAnalysis(JSONObject params,PageBounds pagination); @CountRef(".countAreaMerchantAmountAnalysis")
PageList<JSONObject> getAreaMerchantAmountAnalysis(JSONObject params, PageBounds pagination);
int countAreaMerchantAmountAnalysis(JSONObject params);
List<JSONObject> getAreaMerchantAmountByCycle(JSONObject params); List<JSONObject> getAreaMerchantAmountByCycle(JSONObject params);
JSONObject getOrderClearAmount(@Param("order_id") String order_id); JSONObject getOrderClearAmount(@Param("order_id") String orderId);
/** /**
* cny_amount * cny_amount
*
* @param params * @param params
* @return * @return
*/ */

@ -4,6 +4,7 @@ import au.com.royalpay.payment.core.beans.OrderStatus;
import au.com.royalpay.payment.core.exceptions.ParamInvalidException; import au.com.royalpay.payment.core.exceptions.ParamInvalidException;
import au.com.royalpay.payment.core.beans.PayChannel; import au.com.royalpay.payment.core.beans.PayChannel;
import au.com.royalpay.payment.tools.defines.TradeType; import au.com.royalpay.payment.tools.defines.TradeType;
import au.com.royalpay.payment.tools.utils.TimeZoneUtils;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.lang3.time.DateUtils;
@ -39,16 +40,16 @@ public class AppQueryBean {
} }
if (begin != null) { if (begin != null) {
try { try {
params.put("begin", format.parse(begin)); params.put("begin", TimeZoneUtils.formatTime(format.parse(begin),"yyyy-MM-dd HH:mm:ss","Australia/Melbourne"));
params.put("from", format.parse(begin)); params.put("from", TimeZoneUtils.formatTime(format.parse(begin),"yyyy-MM-dd HH:mm:ss","Australia/Melbourne"));
} catch (ParseException e) { } catch (ParseException e) {
throw new ParamInvalidException("begin", "error.payment.valid.invalid_date_format"); throw new ParamInvalidException("begin", "error.payment.valid.invalid_date_format");
} }
} }
if (end != null) { if (end != null) {
try { try {
params.put("end", DateUtils.addDays(format.parse(end), 1)); params.put("end", TimeZoneUtils.formatTime(DateUtils.addDays(format.parse(end), 1),"yyyy-MM-dd HH:mm:ss","Australia/Melbourne"));
params.put("to", DateUtils.addDays(format.parse(end), 1)); params.put("to", TimeZoneUtils.formatTime(DateUtils.addDays(format.parse(end), 1),"yyyy-MM-dd HH:mm:ss","Australia/Melbourne"));
} catch (ParseException e) { } catch (ParseException e) {
throw new ParamInvalidException("end", "error.payment.valid.invalid_date_format"); throw new ParamInvalidException("end", "error.payment.valid.invalid_date_format");
} }

@ -76,4 +76,12 @@ public interface ManageAppService {
void updateProduct(JSONObject device, ProductBean productBean); void updateProduct(JSONObject device, ProductBean productBean);
void deleteProduct(JSONObject device, String commodity_id); void deleteProduct(JSONObject device, String commodity_id);
void bindAccountEmail(JSONObject device,JSONObject email);
void updateAccountEmail(JSONObject device,JSONObject codekey);
void bindAccountPhone(JSONObject device,JSONObject phone);
void updateAccountPhone(JSONObject device,JSONObject codekey);
} }

@ -169,4 +169,22 @@ public interface RetailAppService {
void cancelCouponAccuessLog(String accuess_id, String remark); void cancelCouponAccuessLog(String accuess_id, String remark);
void submitMaterial(JSONObject material, JSONObject device); void submitMaterial(JSONObject material, JSONObject device);
void bindAccountEmail(JSONObject device,JSONObject email);
void updateAccountEmail(JSONObject device,JSONObject codekey);
void bindAccountPhone(JSONObject device,JSONObject phone);
void updateAccountPhone(JSONObject device,JSONObject codekey);
/**
* 退
*/
void verifyRefundPassword(JSONObject device, JSONObject json);
/**
* 退
*/
void resetRefundPassword(JSONObject device, JSONObject json);
} }

@ -1,5 +1,6 @@
package au.com.royalpay.payment.manage.appclient.core.impls; package au.com.royalpay.payment.manage.appclient.core.impls;
import au.com.royalpay.payment.core.exceptions.EmailException;
import au.com.royalpay.payment.manage.appclient.beans.AppMerchantBean; import au.com.royalpay.payment.manage.appclient.beans.AppMerchantBean;
import au.com.royalpay.payment.manage.appclient.core.ManageAppService; import au.com.royalpay.payment.manage.appclient.core.ManageAppService;
import au.com.royalpay.payment.manage.bdprize.core.BDPrizeService; import au.com.royalpay.payment.manage.bdprize.core.BDPrizeService;
@ -16,26 +17,37 @@ import au.com.royalpay.payment.manage.merchants.beans.ClientAuthFilesInfo;
import au.com.royalpay.payment.manage.merchants.beans.ClientRegisterInfo; import au.com.royalpay.payment.manage.merchants.beans.ClientRegisterInfo;
import au.com.royalpay.payment.manage.merchants.beans.PartnerQuery; import au.com.royalpay.payment.manage.merchants.beans.PartnerQuery;
import au.com.royalpay.payment.manage.merchants.core.ClientManager; import au.com.royalpay.payment.manage.merchants.core.ClientManager;
import au.com.royalpay.payment.manage.notice.core.MailService;
import au.com.royalpay.payment.manage.product.beans.ProductBean; import au.com.royalpay.payment.manage.product.beans.ProductBean;
import au.com.royalpay.payment.manage.product.core.ClientProduct; import au.com.royalpay.payment.manage.product.core.ClientProduct;
import au.com.royalpay.payment.manage.signin.beans.ChangePwdBean; import au.com.royalpay.payment.manage.signin.beans.ChangePwdBean;
import au.com.royalpay.payment.manage.signin.core.ManagerAccountsService; import au.com.royalpay.payment.manage.signin.core.ManagerAccountsService;
import au.com.royalpay.payment.manage.signin.core.SignInAccountService; import au.com.royalpay.payment.manage.signin.core.SignInAccountService;
import au.com.royalpay.payment.manage.support.sms.SmsSender;
import au.com.royalpay.payment.tools.device.DeviceSupport; import au.com.royalpay.payment.tools.device.DeviceSupport;
import au.com.royalpay.payment.tools.device.ManageDeviceSupport; import au.com.royalpay.payment.tools.device.ManageDeviceSupport;
import au.com.royalpay.payment.tools.device.support.DeviceRegister; import au.com.royalpay.payment.tools.device.support.DeviceRegister;
import au.com.royalpay.payment.tools.env.PlatformEnvironment; import au.com.royalpay.payment.tools.env.PlatformEnvironment;
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import au.com.royalpay.payment.tools.exceptions.ForbiddenException; import au.com.royalpay.payment.tools.exceptions.ForbiddenException;
import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
import au.com.royalpay.payment.tools.threadpool.RoyalThreadPoolExecutor;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds; import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.thymeleaf.context.Context;
import org.thymeleaf.spring4.SpringTemplateEngine;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Service @Service
@ -67,6 +79,19 @@ public class ManageAppServiceImp implements ManageAppService {
private FinancialBDConfigMapper financialBDConfigMapper; private FinancialBDConfigMapper financialBDConfigMapper;
@Resource @Resource
private ClientProduct clientProduct; private ClientProduct clientProduct;
@Resource
private StringRedisTemplate stringRedisTemplate;
@Resource
private MailService mailService;
@Resource
private RoyalThreadPoolExecutor royalThreadPoolExecutor;
@Resource
private SpringTemplateEngine thymeleaf;
@Resource
private SmsSender smsSender;
private final String BIND_MANAGE_EMAIL_PREFIX = "BIND_MANAGE_EMAIL";
private final String BIND_MANAGE_PHONE_PREFIX = "BIND_MANAGE_PHONE";
private final int BIND_PHONE_TEMPLID = 126978;
@Override @Override
@ -391,9 +416,9 @@ public class ManageAppServiceImp implements ManageAppService {
JSONObject manager = managerMapper.findById(device.getString("manager_id")); JSONObject manager = managerMapper.findById(device.getString("manager_id"));
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();
if (manager.getIntValue("org_id") == 1) { if (manager.getIntValue("org_id") == 1) {
result.put("url", "http://192.168.0.49:9002/app/rules/bd"); result.put("url", PlatformEnvironment.getEnv().concatUrl("/app/rules/bd"));
} else { } else {
result.put("url", "http://192.168.0.49:9002/app/rules/org"); result.put("url", PlatformEnvironment.getEnv().concatUrl("/app/rules/org"));
} }
return result; return result;
} }
@ -429,4 +454,106 @@ public class ManageAppServiceImp implements ManageAppService {
JSONObject manager = managerMapper.findById(device.getString("manager_id")); JSONObject manager = managerMapper.findById(device.getString("manager_id"));
clientProduct.deleteProduct(manager, commodity_id); clientProduct.deleteProduct(manager, commodity_id);
} }
@Override
public void bindAccountEmail(JSONObject device, JSONObject email) {
String codeKey = device.getString("manager_id");
String codeKeyValueRedis = stringRedisTemplate.boundValueOps(getUpdateManageEmailKey(codeKey)).get();
if(StringUtils.isNotEmpty(codeKeyValueRedis)){
throw new BadRequestException("Captcha has been sent.Please check your email or try again in 5 minutes.");
}
String codeKeyValue = RandomStringUtils.random(6, false, true);
Context ctx = new Context();
JSONObject manager = managerMapper.findById(device.getString("manager_id"));
ctx.setVariable("account",manager);
ctx.setVariable("captcha",codeKeyValue);
final String content = thymeleaf.process("mail/account_bind_email.html", ctx);
royalThreadPoolExecutor.execute(() -> {
try {
mailService.sendEmail("Your account is in the process of binding a mailbox", email.getString("contact_email"),
"", content);
} catch (Exception e) {
throw new EmailException("Email Sending Failed", e);
}
});
stringRedisTemplate.boundValueOps(getUpdateManageEmailKey(codeKey)).set(codeKeyValue+"&"+email.getString("contact_email"), 5, TimeUnit.MINUTES);
}
@Override
public void updateAccountEmail(JSONObject device, JSONObject params) {
String key = stringRedisTemplate.boundValueOps(getUpdateManageEmailKey(device.getString("manager_id"))).get();
if(key == null){
throw new BadRequestException("Captcha has expired");
}
String captcha = key.split("&")[0];
String email = key.split("&")[1];
if(!StringUtils.equals(captcha,params.getString("captcha"))){
throw new BadRequestException("Verification code is wrong");
}
JSONObject account = new JSONObject();
account.put("manager_id",device.getString("manager_id"));
account.put("email",email);
managerMapper.update(account);
deleteManageEmailKey(device.getString("manager_id"));
}
@Override
public void bindAccountPhone(JSONObject device, JSONObject phone) {
String codeKey = device.getString("manager_id");
String codeKeyValueRedis = stringRedisTemplate.boundValueOps(getUpdateManagePhoneKey(codeKey)).get();
if(StringUtils.isNotEmpty(codeKeyValueRedis)){
throw new BadRequestException("Captcha has been sent.Please check your phone or try again in 5 minutes.");
}
String codeKeyValue = RandomStringUtils.random(6, false, true);
String nationCode = phone.getString("nation_code");
String phoneNumber = phone.getString("contact_phone");
ArrayList<String> param = new ArrayList<>();
param.add("绑定手机号");
param.add(codeKeyValue);
String expireMin = "5";
param.add(expireMin);
try {
smsSender.getSender().sendWithParam(nationCode.trim(), phoneNumber, BIND_PHONE_TEMPLID, param, "RoyalPay", "", "");
} catch (Exception e) {
e.printStackTrace();
throw new ServerErrorException("Phone number is wrong.Please try again.");
}
stringRedisTemplate.boundValueOps(getUpdateManagePhoneKey(codeKey)).set(codeKeyValue+"&"+nationCode+"&"+phoneNumber, Long.parseLong(expireMin), TimeUnit.MINUTES);
}
@Override
public void updateAccountPhone(JSONObject device, JSONObject params) {
String key = stringRedisTemplate.boundValueOps(getUpdateManagePhoneKey(device.getString("manager_id"))).get();
if(key == null){
throw new BadRequestException("Captcha has expired");
}
String captcha = key.split("&")[0];
String nation_code = key.split("&")[1];
String contact_phone = key.split("&")[2];
if(!StringUtils.equals(captcha,params.getString("captcha"))){
throw new BadRequestException("Verification code is wrong");
}
JSONObject account = new JSONObject();
account.put("manager_id",device.getString("manager_id"));
account.put("contact_phone",contact_phone);
account.put("nation_code","+" + nation_code);
managerMapper.update(account);
deleteManagePhoneKey(device.getString("manager_id"));
}
private void deleteManageEmailKey(String codeKey){
stringRedisTemplate.delete(getUpdateManageEmailKey(codeKey));
}
private void deleteManagePhoneKey(String codeKey){
stringRedisTemplate.delete(getUpdateManagePhoneKey(codeKey));
}
private String getUpdateManageEmailKey(String codeKey){
return BIND_MANAGE_EMAIL_PREFIX+codeKey;
}
private String getUpdateManagePhoneKey(String codeKey){
return BIND_MANAGE_PHONE_PREFIX+codeKey;
}
} }

@ -1,6 +1,7 @@
package au.com.royalpay.payment.manage.appclient.core.impls; package au.com.royalpay.payment.manage.appclient.core.impls;
import au.com.royalpay.payment.core.PaymentApi; import au.com.royalpay.payment.core.PaymentApi;
import au.com.royalpay.payment.core.exceptions.EmailException;
import au.com.royalpay.payment.manage.activities.app_index.core.AppActService; import au.com.royalpay.payment.manage.activities.app_index.core.AppActService;
import au.com.royalpay.payment.manage.analysis.mappers.CustomerAndOrdersStatisticsMapper; import au.com.royalpay.payment.manage.analysis.mappers.CustomerAndOrdersStatisticsMapper;
import au.com.royalpay.payment.manage.analysis.mappers.TransactionAnalysisMapper; import au.com.royalpay.payment.manage.analysis.mappers.TransactionAnalysisMapper;
@ -15,12 +16,7 @@ import au.com.royalpay.payment.manage.mappers.log.*;
import au.com.royalpay.payment.manage.mappers.notice.NoticePartnerMapper; import au.com.royalpay.payment.manage.mappers.notice.NoticePartnerMapper;
import au.com.royalpay.payment.manage.mappers.payment.OrderMapper; import au.com.royalpay.payment.manage.mappers.payment.OrderMapper;
import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper; import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper; import au.com.royalpay.payment.manage.mappers.system.*;
import au.com.royalpay.payment.manage.mappers.system.ClientDeviceTokenMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientSettleDelayConfMapper;
import au.com.royalpay.payment.manage.mappers.system.CustomerMapper;
import au.com.royalpay.payment.manage.mappers.system.ManagerCustomerRelationAlipayMapper;
import au.com.royalpay.payment.manage.merchants.beans.ClientAuthFilesInfo; import au.com.royalpay.payment.manage.merchants.beans.ClientAuthFilesInfo;
import au.com.royalpay.payment.manage.merchants.beans.ClientUpdateInfo; import au.com.royalpay.payment.manage.merchants.beans.ClientUpdateInfo;
import au.com.royalpay.payment.manage.merchants.core.ClientConfigService; import au.com.royalpay.payment.manage.merchants.core.ClientConfigService;
@ -28,6 +24,7 @@ import au.com.royalpay.payment.manage.merchants.core.ClientManager;
import au.com.royalpay.payment.manage.merchants.core.ClientModifySupport; import au.com.royalpay.payment.manage.merchants.core.ClientModifySupport;
import au.com.royalpay.payment.manage.merchants.entity.impls.SwitchPermissionModify; import au.com.royalpay.payment.manage.merchants.entity.impls.SwitchPermissionModify;
import au.com.royalpay.payment.manage.notice.beans.NoticeInfo; import au.com.royalpay.payment.manage.notice.beans.NoticeInfo;
import au.com.royalpay.payment.manage.notice.core.MailService;
import au.com.royalpay.payment.manage.notice.core.NoticeManage; import au.com.royalpay.payment.manage.notice.core.NoticeManage;
import au.com.royalpay.payment.manage.notice.core.NoticePartner; import au.com.royalpay.payment.manage.notice.core.NoticePartner;
import au.com.royalpay.payment.manage.openim.core.CustomerServiceService; import au.com.royalpay.payment.manage.openim.core.CustomerServiceService;
@ -40,6 +37,7 @@ import au.com.royalpay.payment.manage.riskbusiness.enums.RiskResultTypeEnum;
import au.com.royalpay.payment.manage.signin.beans.ChangePwdBean; import au.com.royalpay.payment.manage.signin.beans.ChangePwdBean;
import au.com.royalpay.payment.manage.signin.core.SignInAccountService; import au.com.royalpay.payment.manage.signin.core.SignInAccountService;
import au.com.royalpay.payment.manage.signin.core.impls.SignInAccountServiceImpl; import au.com.royalpay.payment.manage.signin.core.impls.SignInAccountServiceImpl;
import au.com.royalpay.payment.manage.support.sms.SmsSender;
import au.com.royalpay.payment.manage.tradelog.beans.TradeLogQuery; import au.com.royalpay.payment.manage.tradelog.beans.TradeLogQuery;
import au.com.royalpay.payment.manage.tradelog.core.TradeLogService; import au.com.royalpay.payment.manage.tradelog.core.TradeLogService;
import au.com.royalpay.payment.manage.tradelog.refund.RefundService; import au.com.royalpay.payment.manage.tradelog.refund.RefundService;
@ -58,7 +56,9 @@ import au.com.royalpay.payment.tools.merchants.beans.QRCodeConfig;
import au.com.royalpay.payment.tools.merchants.beans.UpdateSurchargeDTO; import au.com.royalpay.payment.tools.merchants.beans.UpdateSurchargeDTO;
import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider; import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider;
import au.com.royalpay.payment.tools.permission.enums.PartnerRole; import au.com.royalpay.payment.tools.permission.enums.PartnerRole;
import au.com.royalpay.payment.tools.threadpool.RoyalThreadPoolExecutor;
import au.com.royalpay.payment.tools.utils.PageListUtils; import au.com.royalpay.payment.tools.utils.PageListUtils;
import au.com.royalpay.payment.tools.utils.PasswordUtils;
import au.com.royalpay.payment.tools.utils.QRCodeUtils; import au.com.royalpay.payment.tools.utils.QRCodeUtils;
import au.com.royalpay.payment.tools.utils.TimeZoneUtils; import au.com.royalpay.payment.tools.utils.TimeZoneUtils;
@ -69,7 +69,9 @@ import com.github.miemiedev.mybatis.paginator.domain.Order;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds; import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList; import com.github.miemiedev.mybatis.paginator.domain.PageList;
import com.github.qcloudsms.httpclient.HTTPException;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.RandomUtils; import org.apache.commons.lang3.RandomUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.commons.lang3.time.DateFormatUtils;
@ -78,9 +80,14 @@ import org.jsoup.Jsoup;
import org.jsoup.nodes.Document; import org.jsoup.nodes.Document;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.thymeleaf.context.Context;
import org.thymeleaf.spring4.SpringTemplateEngine;
import java.io.IOException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.text.DateFormat; import java.text.DateFormat;
@ -186,6 +193,19 @@ public class RetailAppServiceImp implements RetailAppService {
private RiskBusinessService riskBusinessService; private RiskBusinessService riskBusinessService;
@Resource @Resource
private RiskUploadService riskUploadService; private RiskUploadService riskUploadService;
@Resource
private MailService mailService;
@Resource
private RoyalThreadPoolExecutor royalThreadPoolExecutor;
@Resource
private SpringTemplateEngine thymeleaf;
@Resource
private StringRedisTemplate stringRedisTemplate;
@Resource
private SmsSender smsSender;
private final String BIND_ACCOUNT_EMAIL_PREFIX = "BIND_ACCOUNT_EMAIL";
private final String BIND_ACCOUNT_PHONE_PREFIX = "BIND_ACCOUNT_PHONE";
private final int BIND_PHONE_TEMPLID = 126978;
private Map<String, AppMsgSender> senderMap = new HashMap<>(); private Map<String, AppMsgSender> senderMap = new HashMap<>();
private final String fileName[] = { "client_bank_file", "client_id_file", "client_company_file" }; private final String fileName[] = { "client_bank_file", "client_id_file", "client_company_file" };
@ -805,6 +825,9 @@ public class RetailAppServiceImp implements RetailAppService {
ArrayList<String> date_contains = new ArrayList<>(); ArrayList<String> date_contains = new ArrayList<>();
for (JSONObject order : orders) { for (JSONObject order : orders) {
Calendar calendar = (Calendar) order.get("transaction_time"); Calendar calendar = (Calendar) order.get("transaction_time");
if (timezone != null) {
calendar.setTimeZone(TimeZone.getTimeZone(timezone));
}
String trade_date = DateFormatUtils.format(calendar, "yyyy-MM-dd", calendar.getTimeZone()); String trade_date = DateFormatUtils.format(calendar, "yyyy-MM-dd", calendar.getTimeZone());
String trade_time = DateFormatUtils.format(calendar, "HH:mm:ss", calendar.getTimeZone()); String trade_time = DateFormatUtils.format(calendar, "HH:mm:ss", calendar.getTimeZone());
order.put("trade_date", trade_date); order.put("trade_date", trade_date);
@ -818,14 +841,17 @@ public class RetailAppServiceImp implements RetailAppService {
} }
if (!date_contains.contains(trade_date)) { if (!date_contains.contains(trade_date)) {
String re_date = trade_date.replaceAll("-", ""); String re_date = trade_date.replaceAll("-", "");
TradeLogQuery date_query = new TradeLogQuery(); AppQueryBean date_query = new AppQueryBean();
date_query.setDatefrom(re_date); date_query.setBegin(re_date);
date_query.setDateto(re_date); date_query.setEnd(re_date);
if (timezone != null && !timezone.isEmpty()) {
query.setTimezone(timezone);
}
// date_query.setStatus(OrderStatus.ALL); // date_query.setStatus(OrderStatus.ALL);
if (params.containsKey("client_ids")) { if (params.containsKey("client_ids")) {
date_query.setClient_ids((String[]) params.get("client_ids")); date_query.setClient_ids((String[]) params.get("client_ids"));
} }
JSONObject date_params = date_query.toParams(query.getTimezone()); JSONObject date_params = date_query.toParams();
date_params.put("begin", date_params.getDate("from")); date_params.put("begin", date_params.getDate("from"));
date_params.put("end", date_params.getDate("to")); date_params.put("end", date_params.getDate("to"));
date_params.put("client_id", device.getIntValue("client_id")); date_params.put("client_id", device.getIntValue("client_id"));
@ -1894,4 +1920,144 @@ public class RetailAppServiceImp implements RetailAppService {
RiskResultTypeEnum.WAIT_FOR_AUDIT.getResultType()); RiskResultTypeEnum.WAIT_FOR_AUDIT.getResultType());
} }
@Override
public void bindAccountEmail(JSONObject device, JSONObject email) {
String codeKey = device.getString("account_id");
String codeKeyValueRedis = stringRedisTemplate.boundValueOps(getUpdateAccountEmailKey(codeKey)).get();
if(StringUtils.isNotEmpty(codeKeyValueRedis)){
throw new BadRequestException("Captcha has been sent.Please check your email or try again in 5 minutes.");
}
String codeKeyValue = RandomStringUtils.random(6, false, true);
Context ctx = new Context();
JSONObject account = clientAccountMapper.findById(device.getString("account_id"));
ctx.setVariable("account",account);
ctx.setVariable("captcha",codeKeyValue);
final String content = thymeleaf.process("mail/account_bind_email.html", ctx);
royalThreadPoolExecutor.execute(() -> {
try {
mailService.sendEmail("Your account is in the process of binding a mailbox", email.getString("contact_email"),
"", content);
} catch (Exception e) {
throw new EmailException("Email Sending Failed", e);
}
});
stringRedisTemplate.boundValueOps(getUpdateAccountEmailKey(codeKey)).set(codeKeyValue+"&"+email.getString("contact_email"), 5, TimeUnit.MINUTES);
}
@Override
public void updateAccountEmail(JSONObject device, JSONObject params) {
String key = stringRedisTemplate.boundValueOps(getUpdateAccountEmailKey(device.getString("account_id"))).get();
if(key == null){
throw new BadRequestException("Captcha has expired");
}
String captcha = key.split("&")[0];
String email = key.split("&")[1];
if(!StringUtils.equals(captcha,params.getString("captcha"))){
throw new BadRequestException("Verification code is wrong");
}
JSONObject account = new JSONObject();
account.put("account_id",device.getString("account_id"));
account.put("contact_email",email);
clientAccountMapper.update(account);
deleteAccountEmailKey(device.getString("account_id"));
}
@Override
public void bindAccountPhone(JSONObject device, JSONObject phone) {
String codeKey = device.getString("account_id");
String codeKeyValueRedis = stringRedisTemplate.boundValueOps(getUpdateAccountPhoneKey(codeKey)).get();
if(StringUtils.isNotEmpty(codeKeyValueRedis)){
throw new BadRequestException("Captcha has been sent.Please check your phone or try again in 5 minutes.");
}
String codeKeyValue = RandomStringUtils.random(6, false, true);
String nationCode = phone.getString("nation_code");
String phoneNumber = phone.getString("contact_phone");
ArrayList<String> param = new ArrayList<>();
param.add("绑定手机号");
param.add(codeKeyValue);
String expireMin = "5";
param.add(expireMin);
try {
smsSender.getSender().sendWithParam(nationCode.trim(), phoneNumber, BIND_PHONE_TEMPLID, param, "RoyalPay", "", "");
} catch (Exception e) {
e.printStackTrace();
throw new ServerErrorException("Phone number is wrong.Please try again.");
}
stringRedisTemplate.boundValueOps(getUpdateAccountPhoneKey(codeKey)).set(codeKeyValue+"&"+nationCode+"&"+phoneNumber, Long.parseLong(expireMin), TimeUnit.MINUTES);
}
@Override
public void updateAccountPhone(JSONObject device, JSONObject params) {
String key = stringRedisTemplate.boundValueOps(getUpdateAccountPhoneKey(device.getString("account_id"))).get();
if(key == null){
throw new BadRequestException("Captcha has expired");
}
String captcha = key.split("&")[0];
String nation_code = key.split("&")[1];
String contact_phone = key.split("&")[2];
if(!StringUtils.equals(captcha,params.getString("captcha"))){
throw new BadRequestException("Verification code is wrong");
}
JSONObject account = new JSONObject();
account.put("account_id",device.getString("account_id"));
account.put("contact_phone",contact_phone);
account.put("nation_code","+" + nation_code);
clientAccountMapper.update(account);
deleteAccountPhoneKey(device.getString("account_id"));
}
@Override
public void verifyRefundPassword(JSONObject device, JSONObject json) {
String clientType = device.getString("client_type");
deviceSupport.findRegister(clientType);
JSONObject clientConfig = clientConfigService.find(device.getIntValue("client_id"));
String needVerifyPassword = json.getString("refund_password");
String refundPwdSalt = clientConfig.getString("refund_pwd_salt");
if (!StringUtils.equals(clientConfig.getString("refund_pwd"), PasswordUtils.hashPwd(needVerifyPassword, refundPwdSalt))) {
throw new BadRequestException("Incorrect refund password");
}
}
@Override
@Transactional
public void resetRefundPassword(JSONObject device, JSONObject json) {
String clientType = device.getString("client_type");
deviceSupport.findRegister(clientType);
JSONObject account = clientAccountMapper.findById(device.getString("account_id"));
if (PartnerRole.getRole(account.getIntValue("role")) != PartnerRole.ADMIN) {
throw new BadRequestException("You have no permission");
}
verifyRefundPassword(device, json);
String newSalt = PasswordUtils.newSalt();
String newPassWord = json.getString("new_refund_password");
if (!StringUtils.isNumeric(newPassWord)) {
throw new BadRequestException("Refund password must be pure number");
}
String newPwdHash = PasswordUtils.hashPwd(newPassWord, newSalt);
if (StringUtils.equals(newPwdHash, PasswordUtils.hashPwd(json.getString("refund_password"), newSalt))) {
throw new BadRequestException("Old and new passwords cannot be duplicated");
}
JSONObject update = new JSONObject();
update.put("client_id", device.getIntValue("client_id"));
update.put("refund_pwd", newPwdHash);
update.put("refund_pwd_salt", newSalt);
clientConfigService.update(update);
}
private void deleteAccountEmailKey(String codeKey){
stringRedisTemplate.delete(getUpdateAccountEmailKey(codeKey));
}
private void deleteAccountPhoneKey(String codeKey){
stringRedisTemplate.delete(getUpdateAccountPhoneKey(codeKey));
}
private String getUpdateAccountEmailKey(String codeKey){
return BIND_ACCOUNT_EMAIL_PREFIX+codeKey;
}
private String getUpdateAccountPhoneKey(String codeKey){
return BIND_ACCOUNT_PHONE_PREFIX+codeKey;
}
} }

@ -30,6 +30,8 @@ import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import static au.com.royalpay.payment.tools.CommonConsts.RETAIL_DEVICE;
@AppClientController @AppClientController
@RequestMapping("/api/v1.0/manage/app") @RequestMapping("/api/v1.0/manage/app")
@ -200,4 +202,48 @@ public class ManageAppController {
manageAppService.deleteProduct(device, commodity_id); manageAppService.deleteProduct(device, commodity_id);
} }
/**
*
* @param device
* @param email contact_email
* @throws Exception
*/
@RequestMapping(value = "/account/email",method = RequestMethod.PUT)
public void bindAccountEmail(@ModelAttribute(CommonConsts.MANAGER_DEVICE) JSONObject device,@RequestBody JSONObject email){
manageAppService.bindAccountEmail(device,email);
}
/**
*
* @param device
* @param params
* @throws Exception
*/
@RequestMapping(value = "/account/email/bind",method = RequestMethod.PUT)
public void updateAccountEmail(@ModelAttribute(CommonConsts.MANAGER_DEVICE) JSONObject device,@RequestBody JSONObject params){
manageAppService.updateAccountEmail(device,params);
}
/**
*
* @param device
* @param phone contact_phone
* @throws Exception
*/
@RequestMapping(value = "/account/phone",method = RequestMethod.PUT)
public void bindAccountPhone(@ModelAttribute(CommonConsts.MANAGER_DEVICE) JSONObject device,@RequestBody JSONObject phone) {
manageAppService.bindAccountPhone(device,phone);
}
/**
*
* @param device
* @param params
* @throws Exception
*/
@RequestMapping(value = "/account/phone/bind",method = RequestMethod.PUT)
public void updateAccountPhone(@ModelAttribute(CommonConsts.MANAGER_DEVICE) JSONObject device,@RequestBody JSONObject params){
manageAppService.updateAccountPhone(device,params);
}
} }

@ -33,7 +33,6 @@ import au.com.royalpay.payment.tools.merchants.beans.UpdateSurchargeDTO;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.lang3.time.DateUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -644,4 +643,64 @@ public class RetailAppController {
return attachmentClient.uploadFile(file,false); return attachmentClient.uploadFile(file,false);
} }
/**
*
* @param device
* @param email contact_email
* @throws Exception
*/
@RequestMapping(value = "/account/email",method = RequestMethod.PUT)
public void bindAccountEmail(@ModelAttribute(RETAIL_DEVICE) JSONObject device,@RequestBody JSONObject email) throws Exception {
retailAppService.bindAccountEmail(device,email);
}
/**
*
* @param device
* @param params
* @throws Exception
*/
@RequestMapping(value = "/account/email/bind",method = RequestMethod.PUT)
public void updateAccountEmail(@ModelAttribute(RETAIL_DEVICE) JSONObject device,@RequestBody JSONObject params) throws Exception {
retailAppService.updateAccountEmail(device,params);
}
/**
*
* @param device
* @param phone contact_phone
* @throws Exception
*/
@RequestMapping(value = "/account/phone",method = RequestMethod.PUT)
public void bindAccountPhone(@ModelAttribute(RETAIL_DEVICE) JSONObject device,@RequestBody JSONObject phone) throws Exception {
retailAppService.bindAccountPhone(device,phone);
}
/**
*
* @param device
* @param params
* @throws Exception
*/
@RequestMapping(value = "/account/phone/bind",method = RequestMethod.PUT)
public void updateAccountPhone(@ModelAttribute(RETAIL_DEVICE) JSONObject device,@RequestBody JSONObject params) throws Exception {
retailAppService.updateAccountPhone(device,params);
}
/**
* 退
*/
@RequestMapping(value = "/refund/passwd/verify", method = RequestMethod.PUT)
public void verifyRefundPassword(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @RequestBody JSONObject json) {
retailAppService.verifyRefundPassword(device, json);
}
/**
* 退
*/
@RequestMapping(value = "/refund/passwd/reset", method = RequestMethod.PUT)
public void resetRefundPassWord(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @RequestBody JSONObject json) {
retailAppService.resetRefundPassword(device, json);
}
} }

@ -48,4 +48,10 @@ public interface BDPrizeService {
void exportCommissionDetail(String month, String managerId, HttpServletResponse response); void exportCommissionDetail(String month, String managerId, HttpServletResponse response);
List<JSONObject> findCommissionList(JSONObject manager); List<JSONObject> findCommissionList(JSONObject manager);
List<JSONObject> getBDTeamKpiCompletionDegree(String month);
List<JSONObject> getBDProportionByTeamType(String month, String teamType);
JSONObject getBDKpiByManagerId(String month, String manager_id);
} }

@ -46,6 +46,7 @@ import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.GregorianCalendar; import java.util.GregorianCalendar;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@ -155,7 +156,7 @@ public class BDPrizeServiceImpl implements BDPrizeService {
//todo 10月开始悉尼分公司经理不享受悉尼销售组提成 //todo 10月开始悉尼分公司经理不享受悉尼销售组提成
List<JSONObject> bdLeaders = managerMapper.listByRole(1, ManagerRole.BD_LEADER.getMask()); List<JSONObject> bdLeaders = managerMapper.listByRole(1, ManagerRole.BD_LEADER.getMask());
for (JSONObject leader : bdLeaders) { 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")); JSONObject bdConfig = financialBDConfigMapper.getBdConfig(leader.getString("manager_id"));
int bd_type = bdConfig ==null?2:("Sydney").equals(bdConfig.getString("city"))?2:1;//sydney leader 即悉尼大客户经理 int bd_type = bdConfig ==null?2:("Sydney").equals(bdConfig.getString("city"))?2:1;//sydney leader 即悉尼大客户经理
JSONObject rateJson = financialBDCommissionConfigMapper.findCurrentCommissionRate(month, groupAmount.toString(), bd_type); JSONObject rateJson = financialBDCommissionConfigMapper.findCurrentCommissionRate(month, groupAmount.toString(), bd_type);
@ -268,7 +269,7 @@ public class BDPrizeServiceImpl implements BDPrizeService {
try { try {
List<JSONObject> prizeLogList = new ArrayList<>(); List<JSONObject> prizeLogList = new ArrayList<>();
JSONObject sydneyPrizeLog = new JSONObject(); 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("total_amount",sydneyAmount);
sydneyPrizeLog.put("bd_type", 3); sydneyPrizeLog.put("bd_type", 3);
JSONObject sydneyGMRate = financialBDCommissionConfigMapper.findCurrentCommissionRate(month, sydneyAmount.toString(), 3); JSONObject sydneyGMRate = financialBDCommissionConfigMapper.findCurrentCommissionRate(month, sydneyAmount.toString(), 3);
@ -690,6 +691,82 @@ public class BDPrizeServiceImpl implements BDPrizeService {
return null; return null;
} }
@Override
public List<JSONObject> getBDTeamKpiCompletionDegree(String month) {
JSONObject report = financialBDPrizeRecordMapper.findByMonth(month);
List<JSONObject> prizeAmountAndBdTypeList = new ArrayList<>();
if (report == null) {
try {
Date start_date = DateUtils.parseDate(month+"-01","yyyy-MM-dd");
Date end_date = DateUtils.addMonths(start_date,1);
prizeAmountAndBdTypeList = financialBDPrizeLogMapper.findBdPrizeAmountRealTime(start_date,end_date);
} catch (ParseException e) {
e.printStackTrace();
}
}else{
prizeAmountAndBdTypeList = financialBDPrizeLogMapper.findBdPrizeAmountAndBdType(getReportByMonth(month));
}
for (JSONObject prize : prizeAmountAndBdTypeList) {
BigDecimal kpi = financialBDCommissionConfigMapper.findCurrentCommissionMaxAmount(month, prize.getIntValue("bd_type"));
prize.put("kpi", kpi);
prize.put("completionDegree", prize.getBigDecimal("total_amount").divide(kpi,2));
}
List<JSONObject> prizeSort = prizeAmountAndBdTypeList.stream()
.sorted((prize1, prize2) -> prize2.getBigDecimal("completionDegree").compareTo(prize1.getBigDecimal("completionDegree")))
.collect(Collectors.toList());
return prizeSort;
}
@Override
public List<JSONObject> getBDProportionByTeamType(String month, String teamType) {
JSONObject report = financialBDPrizeRecordMapper.findByMonth(month);
if (report == null) {
try {
Date start_date = DateUtils.parseDate(month+"-01","yyyy-MM-dd");
Date end_date = DateUtils.addMonths(start_date,1);
return financialBDConfigMapper.findManagerByTeamTypeRealTime(teamType,start_date,end_date);
} catch (ParseException e) {
e.printStackTrace();
throw new BadRequestException("Month is wrong");
}
}else {
return financialBDConfigMapper.findManagerByTeamType(teamType, getReportByMonth(month));
}
}
@Override
public JSONObject getBDKpiByManagerId(String month, String manager_id) {
JSONObject report = financialBDPrizeRecordMapper.findByMonth(month);
if (report == null) {
try {
Date start_date = DateUtils.parseDate(month+"-01","yyyy-MM-dd");
Date end_date = DateUtils.addMonths(start_date,1);
return financialBDPrizeLogMapper.findByReportAndBDTotalRealTime(manager_id,start_date,end_date);
} catch (ParseException e) {
e.printStackTrace();
throw new BadRequestException("Month is wrong");
}
}else {
return financialBDPrizeLogMapper.findByReportAndBDTotal(getReportByMonth(month), manager_id);
}
}
public String getReportByMonth(String month) {
try {
Date mon = DateUtils.parseDate(month, new String[]{"yyyy-MM"});
month = DateFormatUtils.format(mon, "yyyy-MM");
} catch (ParseException e) {
throw new BadRequestException("Invalid Month");
}
JSONObject report = financialBDPrizeRecordMapper.findByMonth(month);
if (report == null) {
throw new BadRequestException("Report not created");
}
return report.getString("record_id");
}
private String financialBdLevel (int level) { private String financialBdLevel (int level) {
switch (level) { switch (level) {
case 0: case 0:

@ -96,7 +96,7 @@ public class BDPrizeCalculatorDefaultImpl implements BDPrizeCalculator {
log.put("total_amount", 0); log.put("total_amount", 0);
log.put("total_prize", 0); log.put("total_prize", 0);
log.put("total_donation", 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<>(); List<JSONObject> details = new ArrayList<>();
for (Map.Entry<String, JSONObject> detail : resultItem.getValue().entrySet()) { for (Map.Entry<String, JSONObject> detail : resultItem.getValue().entrySet()) {
JSONObject detailItem = detail.getValue(); JSONObject detailItem = detail.getValue();

@ -119,4 +119,28 @@ public class BDPrizeController {
public void exportCommissionBdUserDetail(@PathVariable String month, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, HttpServletResponse response) { public void exportCommissionBdUserDetail(@PathVariable String month, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, HttpServletResponse response) {
bdPrizeService.exportCommissionDetail(month, manager.getString("manager_id"), response); bdPrizeService.exportCommissionDetail(month, manager.getString("manager_id"), response);
} }
/**
* BDKPI
*/
@ManagerMapping(value = "/commission/{month}/completion_degree", method = RequestMethod.GET, role = {ManagerRole.DIRECTOR, ManagerRole.ADMIN})
public List<JSONObject> getBDTeamKpiCompletionDegree(@PathVariable String month) {
return bdPrizeService.getBDTeamKpiCompletionDegree(month);
}
/**
* BD
*/
@ManagerMapping(value = "/commission/{month}/bd_proportion/{teamType}", method = RequestMethod.GET, role = {ManagerRole.DIRECTOR, ManagerRole.ADMIN})
public List<JSONObject> getBDProportionByTeamType(@PathVariable String month, @PathVariable String teamType) {
return bdPrizeService.getBDProportionByTeamType(month, teamType);
}
/**
* BD KPI
*/
@ManagerMapping(value = "/commission/{month}/bd_user_kpi/{manager_id}", method = RequestMethod.GET, role = {ManagerRole.DIRECTOR, ManagerRole.ADMIN})
public JSONObject getBDKpiByManagerId(@PathVariable String month, @PathVariable String manager_id) {
return bdPrizeService.getBDKpiByManagerId(month, manager_id);
}
} }

@ -2,6 +2,7 @@ package au.com.royalpay.payment.manage.citypartner.core;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import javax.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;
/** /**
@ -43,6 +44,5 @@ public interface CityPartnerPrizeService {
JSONObject getSenior(String monthStr, String orgId); JSONObject getSenior(String monthStr, String orgId);
void exportMonthFiles(String monthStr, HttpServletResponse httpResponse) throws Exception;
} }

@ -31,6 +31,11 @@ import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.lang3.time.DateUtils;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.usermodel.*;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -182,7 +187,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
private Date parseMonth(String monthStr) { private Date parseMonth(String monthStr) {
try { try {
return DateUtils.parseDate(monthStr, new String[] { "yyyy-MM" }); return DateUtils.parseDate(monthStr, new String[]{"yyyy-MM"});
} catch (ParseException e) { } catch (ParseException e) {
throw new BadRequestException("Invalid month format"); throw new BadRequestException("Invalid month format");
} }
@ -203,7 +208,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
return null; return null;
} }
String tableColumn[] = { "gross_amount", "total_charge", "royalpay_charge", "org_charge", "net_charge" }; String tableColumn[] = {"gross_amount", "total_charge", "royalpay_charge", "org_charge", "net_charge"};
List<String> recordIds = new ArrayList<>(); List<String> recordIds = new ArrayList<>();
Map<String, BigDecimal> chargeResultMap = new HashMap<>(); Map<String, BigDecimal> chargeResultMap = new HashMap<>();
@ -274,7 +279,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
sumResult.put("net_charge", netCharge); sumResult.put("net_charge", netCharge);
sumResult.put("client_moniker", clientMoniker); sumResult.put("client_moniker", clientMoniker);
sumResult.put("channel_detail", entry.getValue()); sumResult.put("channel_detail", entry.getValue());
sumResult.put("type",type); sumResult.put("type", type);
partnerClientInfos.add(sumResult); partnerClientInfos.add(sumResult);
} }
result.put("partner_client_infos", partnerClientInfos); result.put("partner_client_infos", partnerClientInfos);
@ -390,7 +395,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
int month = monthCal.get(Calendar.MONTH) + 1; int month = monthCal.get(Calendar.MONTH) + 1;
List<JSONObject> list = financialPartnerCommissionMapper.list(year, month); List<JSONObject> list = financialPartnerCommissionMapper.list(year, month);
if (list!=null &&list.size() > 0) { if (list != null && list.size() > 0) {
throw new ServerErrorException("请不要重复生成合伙人记录"); throw new ServerErrorException("请不要重复生成合伙人记录");
} }
@ -430,7 +435,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
// shall never happen // shall never happen
throw new ServerErrorException("Organization Id not exists:" + orgId); throw new ServerErrorException("Organization Id not exists:" + orgId);
} }
if (org.getInteger("commission_type")!=1) { if (org.getInteger("commission_type") != 1) {
generateold(monthStr); generateold(monthStr);
return; return;
} }
@ -438,7 +443,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
List<JSONObject> items = oneOrg.getValue(); List<JSONObject> items = oneOrg.getValue();
Map<String, List<JSONObject>> groupByChannelMap = items.stream().collect(Collectors.groupingBy(e -> e.getString("channel"))); Map<String, List<JSONObject>> groupByChannelMap = items.stream().collect(Collectors.groupingBy(e -> e.getString("channel")));
List<JSONObject> channelAmount = orgChannelAmount(org,groupByChannelMap, channelCharge); List<JSONObject> channelAmount = orgChannelAmount(org, groupByChannelMap, channelCharge);
for (JSONObject channel : channelAmount) { for (JSONObject channel : channelAmount) {
channel.put("share_charge", 0); channel.put("share_charge", 0);
channel.put("month", month); channel.put("month", month);
@ -454,7 +459,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
JSONObject org = orgMapper.findOne(oneClient.getValue().get(0).getInteger("org_id")); JSONObject org = orgMapper.findOne(oneClient.getValue().get(0).getInteger("org_id"));
Map<String, List<JSONObject>> groupByChannel = oneClient.getValue().stream().collect(Collectors.groupingBy(e -> e.getString("channel"))); Map<String, List<JSONObject>> groupByChannel = oneClient.getValue().stream().collect(Collectors.groupingBy(e -> e.getString("channel")));
List<JSONObject> clientChannelAmount = clientChannelAmount(oneClient.getKey(),org, groupByChannel, channelCharge,year,month,1); List<JSONObject> clientChannelAmount = clientChannelAmount(oneClient.getKey(), org, groupByChannel, channelCharge, year, month, 1);
for (JSONObject channel : clientChannelAmount) { for (JSONObject channel : clientChannelAmount) {
financialPartnerCommissionDetailMapper.save(channel); financialPartnerCommissionDetailMapper.save(channel);
} }
@ -471,7 +476,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
} }
public List<JSONObject> orgChannelAmount(JSONObject orgInfo,Map<String, List<JSONObject>> channelMap,JSONObject channelCharge) { public List<JSONObject> orgChannelAmount(JSONObject orgInfo, Map<String, List<JSONObject>> channelMap, JSONObject channelCharge) {
List<JSONObject> amountByChannel = new ArrayList<>(); List<JSONObject> amountByChannel = new ArrayList<>();
for (Map.Entry<String, List<JSONObject>> oneChannel : channelMap.entrySet()) { for (Map.Entry<String, List<JSONObject>> oneChannel : channelMap.entrySet()) {
@ -487,7 +492,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
if (orgInfo.get("cb_bankpay_rate_value") == null) { if (orgInfo.get("cb_bankpay_rate_value") == null) {
throw new ServerErrorException(orgInfo.getString("name") + "组织下" + "cbbankpay" + "成本手续费未设置"); throw new ServerErrorException(orgInfo.getString("name") + "组织下" + "cbbankpay" + "成本手续费未设置");
} }
}else { } else {
if (orgInfo.get(channel.toLowerCase() + "_rate_value") == null) { if (orgInfo.get(channel.toLowerCase() + "_rate_value") == null) {
throw new ServerErrorException(orgInfo.getString("name") + "组织下" + oneChannel.getKey() + "成本手续费未设置"); throw new ServerErrorException(orgInfo.getString("name") + "组织下" + oneChannel.getKey() + "成本手续费未设置");
} }
@ -502,14 +507,14 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
total = total.add(tmpClearingAmount); total = total.add(tmpClearingAmount);
total_surage = total_surage.add(tmpTotalSurcharge).setScale(i, RoundingMode.HALF_UP); total_surage = total_surage.add(tmpTotalSurcharge).setScale(i, RoundingMode.HALF_UP);
royalpay_surage = royalpay_surage.add(tmpClearingAmount.multiply(channelRate).setScale(i, RoundingMode.HALF_UP)); royalpay_surage = royalpay_surage.add(tmpClearingAmount.multiply(channelRate).setScale(i, RoundingMode.HALF_UP));
// net_surage = net_surage.add(getThirdPartyCharge(params.getString("channel"), params.getBigDecimal("clearing_amount"), channelCharge)); // net_surage = net_surage.add(getThirdPartyCharge(params.getString("channel"), params.getBigDecimal("clearing_amount"), channelCharge));
net_surage = net_surage.add(params.getBigDecimal("channel_surcharge")); net_surage = net_surage.add(params.getBigDecimal("channel_surcharge"));
} }
BigDecimal org_charge = total_surage.subtract(royalpay_surage); BigDecimal org_charge = total_surage.subtract(royalpay_surage);
json.put("channel",oneChannel.getKey()); json.put("channel", oneChannel.getKey());
json.put("gross_amount",total); json.put("gross_amount", total);
json.put("total_charge",total_surage); json.put("total_charge", total_surage);
json.put("net_charge",net_surage); json.put("net_charge", net_surage);
json.put("org_rate", orgInfo.getBigDecimal(channel.toLowerCase() + "_rate_value")); json.put("org_rate", orgInfo.getBigDecimal(channel.toLowerCase() + "_rate_value"));
json.put("royalpay_charge", royalpay_surage); json.put("royalpay_charge", royalpay_surage);
json.put("org_charge", org_charge); json.put("org_charge", org_charge);
@ -518,10 +523,10 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
amountByChannel.add(json); amountByChannel.add(json);
} }
return amountByChannel; return amountByChannel;
} }
public List<JSONObject> parentOrgChannelAmount(JSONObject orgInfo,JSONObject parentOrgInfo,Map<String, List<JSONObject>> channelMap,JSONObject channelCharge) { public List<JSONObject> parentOrgChannelAmount(JSONObject orgInfo, JSONObject parentOrgInfo, Map<String, List<JSONObject>> channelMap, JSONObject channelCharge) {
List<JSONObject> amountByChannel = new ArrayList<>(); List<JSONObject> amountByChannel = new ArrayList<>();
for (Map.Entry<String, List<JSONObject>> oneChannel : channelMap.entrySet()) { for (Map.Entry<String, List<JSONObject>> oneChannel : channelMap.entrySet()) {
@ -549,14 +554,14 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
royalpay_surage = royalpay_surage.add(roy_surage); royalpay_surage = royalpay_surage.add(roy_surage);
//net_surage = net_surage.add(getThirdPartyCharge(params.getString("channel"), params.getBigDecimal("clearing_amount"), channelCharge)); //net_surage = net_surage.add(getThirdPartyCharge(params.getString("channel"), params.getBigDecimal("clearing_amount"), channelCharge));
net_surage = net_surage.add(params.getBigDecimal("channel_surcharge")); net_surage = net_surage.add(params.getBigDecimal("channel_surcharge"));
share_surage = share_surage.add(roy_surage.subtract(parent_surage)).setScale(i,RoundingMode.HALF_UP); share_surage = share_surage.add(roy_surage.subtract(parent_surage)).setScale(i, RoundingMode.HALF_UP);
} }
BigDecimal org_charge = total_surage.subtract(royalpay_surage); BigDecimal org_charge = total_surage.subtract(royalpay_surage);
json.put("channel",oneChannel.getKey()); json.put("channel", oneChannel.getKey());
json.put("gross_amount",total); json.put("gross_amount", total);
json.put("total_charge",total_surage); json.put("total_charge", total_surage);
json.put("net_charge",net_surage); json.put("net_charge", net_surage);
json.put("org_rate", orgInfo.getBigDecimal(channel.toLowerCase() + "_rate_value")); json.put("org_rate", orgInfo.getBigDecimal(channel.toLowerCase() + "_rate_value"));
json.put("partner_charge", royalpay_surage); json.put("partner_charge", royalpay_surage);
json.put("share_charge", share_surage); json.put("share_charge", share_surage);
@ -570,7 +575,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
} }
//type 1:一级代理 2:二级代理 //type 1:一级代理 2:二级代理
public List<JSONObject> clientChannelAmount(int clientId,JSONObject orgInfo,Map<String, List<JSONObject>> channelMap,JSONObject channelCharge,int year,int month,int type) { public List<JSONObject> clientChannelAmount(int clientId, JSONObject orgInfo, Map<String, List<JSONObject>> channelMap, JSONObject channelCharge, int year, int month, int type) {
List<JSONObject> amountByChannel = new ArrayList<>(); List<JSONObject> amountByChannel = new ArrayList<>();
for (Map.Entry<String, List<JSONObject>> oneChannel : channelMap.entrySet()) { for (Map.Entry<String, List<JSONObject>> oneChannel : channelMap.entrySet()) {
@ -599,10 +604,10 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
BigDecimal tmpTotalSurcharge = tmpClearingAmount.multiply(params.getBigDecimal("surcharge_rate")).setScale(2, RoundingMode.HALF_UP); BigDecimal tmpTotalSurcharge = tmpClearingAmount.multiply(params.getBigDecimal("surcharge_rate")).setScale(2, RoundingMode.HALF_UP);
//增加货币判断 //增加货币判断
int i = currencyScale(params.getString("clearing_currency")); int i = currencyScale(params.getString("clearing_currency"));
if (total.compareTo(BigDecimal.ZERO)==0 ) { if (total.compareTo(BigDecimal.ZERO) == 0) {
datefrom = params.getDate("transaction_time"); datefrom = params.getDate("transaction_time");
dateto = params.getDate("transaction_time"); dateto = params.getDate("transaction_time");
}else { } else {
if (params.getDate("transaction_time").before(datefrom)) { if (params.getDate("transaction_time").before(datefrom)) {
datefrom = params.getDate("transaction_time"); datefrom = params.getDate("transaction_time");
} }
@ -618,29 +623,29 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
net_surage = net_surage.add(params.getBigDecimal("channel_surcharge")); net_surage = net_surage.add(params.getBigDecimal("channel_surcharge"));
} }
BigDecimal org_charge = total_surage.subtract(royalpay_surage); BigDecimal org_charge = total_surage.subtract(royalpay_surage);
if(channel.toLowerCase().equals("alipay_direct")){ if (channel.toLowerCase().equals("alipay_direct")) {
channel = channel.replace("_", ""); channel = channel.replace("_", "");
} }
json.put("channel",oneChannel.getKey()); json.put("channel", oneChannel.getKey());
json.put("record_id",recordId); json.put("record_id", recordId);
json.put("client_id",clientId); json.put("client_id", clientId);
json.put("client_rate",oneChannel.getValue().get(0).getBigDecimal("surcharge_rate").multiply(CommonConsts.HUNDRED)); json.put("client_rate", oneChannel.getValue().get(0).getBigDecimal("surcharge_rate").multiply(CommonConsts.HUNDRED));
json.put("gross_amount",total); json.put("gross_amount", total);
json.put("total_charge",total_surage); json.put("total_charge", total_surage);
json.put("org_rate", orgInfo.getBigDecimal(channel.toLowerCase() + "_rate_value")); json.put("org_rate", orgInfo.getBigDecimal(channel.toLowerCase() + "_rate_value"));
json.put("royalpay_charge", royalpay_surage); json.put("royalpay_charge", royalpay_surage);
if (type == 1) { if (type == 1) {
json.put("net_charge",net_surage); json.put("net_charge", net_surage);
} }
if (type == 2) { if (type == 2) {
json.put("org_net_charge",net_surage); json.put("org_net_charge", net_surage);
} }
json.put("org_charge", org_charge); json.put("org_charge", org_charge);
json.put("commission_type", "1"); json.put("commission_type", "1");
json.put("create_time", new Date()); json.put("create_time", new Date());
json.put("date_from", DateFormatUtils.format(datefrom,"yyyy-MM-dd")); json.put("date_from", DateFormatUtils.format(datefrom, "yyyy-MM-dd"));
json.put("date_to", DateFormatUtils.format(dateto,"yyyy-MM-dd")); json.put("date_to", DateFormatUtils.format(dateto, "yyyy-MM-dd"));
json.put("year", year); json.put("year", year);
json.put("month", month); json.put("month", month);
amountByChannel.add(json); amountByChannel.add(json);
@ -662,20 +667,20 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
return i; return i;
} }
private BigDecimal getThirdPartyCharge(String channel, BigDecimal total,JSONObject chargeRate) { private BigDecimal getThirdPartyCharge(String channel, BigDecimal total, JSONObject chargeRate) {
BigDecimal thirdPartyPaymentCharge = BigDecimal.ZERO; BigDecimal thirdPartyPaymentCharge = BigDecimal.ZERO;
switch (channel) { switch (channel) {
case "Alipay": case "Alipay":
thirdPartyPaymentCharge = total.multiply(chargeRate.getBigDecimal("alipayChargeRate").divide(CommonConsts.HUNDRED, 4, BigDecimal.ROUND_DOWN)).setScale(2,RoundingMode.HALF_UP); thirdPartyPaymentCharge = total.multiply(chargeRate.getBigDecimal("alipayChargeRate").divide(CommonConsts.HUNDRED, 4, BigDecimal.ROUND_DOWN)).setScale(2, RoundingMode.HALF_UP);
break; break;
case "Wechat": case "Wechat":
thirdPartyPaymentCharge = total.multiply(chargeRate.getBigDecimal("wechatChargeRate").divide(CommonConsts.HUNDRED, 4, BigDecimal.ROUND_DOWN)).setScale(2,RoundingMode.HALF_UP); thirdPartyPaymentCharge = total.multiply(chargeRate.getBigDecimal("wechatChargeRate").divide(CommonConsts.HUNDRED, 4, BigDecimal.ROUND_DOWN)).setScale(2, RoundingMode.HALF_UP);
break; break;
case "jd": case "jd":
thirdPartyPaymentCharge = total.multiply(chargeRate.getBigDecimal("jdChargeRate").divide(CommonConsts.HUNDRED, 4, BigDecimal.ROUND_DOWN)).setScale(2,RoundingMode.HALF_UP); thirdPartyPaymentCharge = total.multiply(chargeRate.getBigDecimal("jdChargeRate").divide(CommonConsts.HUNDRED, 4, BigDecimal.ROUND_DOWN)).setScale(2, RoundingMode.HALF_UP);
break; break;
case "AlipayOnline": case "AlipayOnline":
thirdPartyPaymentCharge = total.multiply(chargeRate.getBigDecimal("alipayonlineChargeRate").divide(CommonConsts.HUNDRED, 4, BigDecimal.ROUND_DOWN)).setScale(2,RoundingMode.HALF_UP); thirdPartyPaymentCharge = total.multiply(chargeRate.getBigDecimal("alipayonlineChargeRate").divide(CommonConsts.HUNDRED, 4, BigDecimal.ROUND_DOWN)).setScale(2, RoundingMode.HALF_UP);
break; break;
default: default:
break; break;
@ -684,7 +689,6 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
} }
@Override @Override
@Transactional @Transactional
public void generateReferrer(String monthStr) { public void generateReferrer(String monthStr) {
@ -775,7 +779,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
} }
@Transactional @Transactional
public void generateAgent(String monthStr,JSONObject channelCharge) { public void generateAgent(String monthStr, JSONObject channelCharge) {
Date mon = checkMonth(monthStr); Date mon = checkMonth(monthStr);
Calendar monthCal = Calendar.getInstance(); Calendar monthCal = Calendar.getInstance();
@ -800,13 +804,13 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
// shall never happen // shall never happen
throw new ServerErrorException("Parent Organization Id not exists:" + orgId); throw new ServerErrorException("Parent Organization Id not exists:" + orgId);
} }
if (org.getInteger("commission_type")!=1) { if (org.getInteger("commission_type") != 1) {
generateold(monthStr); generateold(monthStr);
return; return;
} }
List<JSONObject> items = oneOrg.getValue(); List<JSONObject> items = oneOrg.getValue();
Map<String, List<JSONObject>> groupByChannelMap = items.stream().collect(Collectors.groupingBy(e -> e.getString("channel"))); Map<String, List<JSONObject>> groupByChannelMap = items.stream().collect(Collectors.groupingBy(e -> e.getString("channel")));
List<JSONObject> channelAmount = parentOrgChannelAmount(org,parentOrg,groupByChannelMap, channelCharge); List<JSONObject> channelAmount = parentOrgChannelAmount(org, parentOrg, groupByChannelMap, channelCharge);
for (JSONObject channel : channelAmount) { for (JSONObject channel : channelAmount) {
if (channel.getBigDecimal("share_charge").compareTo(BigDecimal.ZERO) != 0) { if (channel.getBigDecimal("share_charge").compareTo(BigDecimal.ZERO) != 0) {
JSONObject parentCommission = financialPartnerCommissionMapper.findByChanel(year, month, parentOrg.getInteger("org_id"), channel.getString("channel")); JSONObject parentCommission = financialPartnerCommissionMapper.findByChanel(year, month, parentOrg.getInteger("org_id"), channel.getString("channel"));
@ -857,8 +861,6 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
// } // }
} }
@Override @Override
@ -970,7 +972,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
private Date checkMonth(String month) { private Date checkMonth(String month) {
try { try {
return DateUtils.parseDate(month, new String[] { "yyyy-MM" }); return DateUtils.parseDate(month, new String[]{"yyyy-MM"});
} catch (ParseException e) { } catch (ParseException e) {
throw new BadRequestException("Invalid Month Format"); throw new BadRequestException("Invalid Month Format");
} }
@ -1047,7 +1049,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
} }
} }
String tableColumn[] = { "gross_amount", "total_charge", "org_charge", "org_net_charge" }; String tableColumn[] = {"gross_amount", "total_charge", "org_charge", "org_net_charge"};
List<String> recordIds = new ArrayList<>(); List<String> recordIds = new ArrayList<>();
Map<String, BigDecimal> chargeResultMap = new HashMap<>(); Map<String, BigDecimal> chargeResultMap = new HashMap<>();
@ -1224,4 +1226,73 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
return financialSeniorPartnerCommissionMapper.find(year, month, orgId); return financialSeniorPartnerCommissionMapper.find(year, month, orgId);
} }
@Override
public void exportMonthFiles(String monthStr, HttpServletResponse resp) throws Exception {
OutputStream ous = null;
Date monthDate = parseMonth(monthStr);
Calendar monthCal = Calendar.getInstance();
monthCal.setTime(monthDate);
int year = monthCal.get(Calendar.YEAR);
int month = monthCal.get(Calendar.MONTH) + 1;
List<JSONObject> report = financialPartnerCommissionMapper.listWithOrgInfo(year, month);
if (report != null) {
resp.setContentType("application/octet-stream;");
resp.addHeader("Content-Disposition", "attachment; filename=" + "CityPartner_Commission_Info_" + monthStr + ".xls");
ous = resp.getOutputStream();
HSSFWorkbook wb = new HSSFWorkbook();
Cell cell = null;
HSSFFont font = wb.createFont();
font.setBoldweight(Font.BOLDWEIGHT_BOLD);
font.setFontHeightInPoints((short) 10);
CellStyle titleStyle = wb.createCellStyle();
titleStyle.setFont(font);
HSSFCellStyle style = wb.createCellStyle();
style.setFillForegroundColor(HSSFColor.RED.index);
style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
Sheet sheet = wb.createSheet("CityPartner_Commission_Info_" + month);
sheet.setDefaultColumnWidth(20);
int rowNum = 0;
Row row = sheet.createRow(rowNum);
String[] CommissionTitle = {"City Partner Name", "Transaction Amount", "Total Charge", "RoyalPay Charge", "Net Charge", "City Partner Charge", "Share Charge", "Type"};
for (int i = 0; i < CommissionTitle.length; i++) {
cell = row.createCell(i, Cell.CELL_TYPE_STRING);
cell.setCellStyle(titleStyle);
cell.setCellValue(CommissionTitle[i]);
}
for (JSONObject log : report) {
row = sheet.createRow(++rowNum);
StringBuffer name = new StringBuffer(log.getString("name"));
if (log.get("parent_org_id") == null) {
name.append("(一级代理)");
} else {
name.append("(二级代理)");
}
String type = "";
switch (log.getIntValue("commission_type")) {
case 1:
type = "渠道计算法";
break;
case 2:
type = "总交易额比例";
break;
case 3:
type = "收益比例";
break;
default:
break;
}
row.createCell(0, Cell.CELL_TYPE_STRING).setCellValue(name.toString());
row.createCell(1, Cell.CELL_TYPE_STRING).setCellValue(log.getBigDecimal("gross_amount") == null ? BigDecimal.ZERO.toPlainString() : log.getBigDecimal("gross_amount").toPlainString());
row.createCell(2, Cell.CELL_TYPE_STRING).setCellValue(log.getBigDecimal("total_charge") == null ? BigDecimal.ZERO.toPlainString() : log.getBigDecimal("total_charge").toPlainString());
row.createCell(3, Cell.CELL_TYPE_STRING).setCellValue(log.getBigDecimal("royalpay_charge") == null ? BigDecimal.ZERO.toPlainString() : log.getBigDecimal("royalpay_charge").toPlainString());
row.createCell(4, Cell.CELL_TYPE_STRING).setCellValue(log.getBigDecimal("net_charge") == null ? BigDecimal.ZERO.toPlainString() : log.getBigDecimal("net_charge").toPlainString());
row.createCell(5, Cell.CELL_TYPE_STRING).setCellValue(log.getBigDecimal("org_charge") == null ? BigDecimal.ZERO.toPlainString() : log.getBigDecimal("org_charge").toPlainString());
row.createCell(6, Cell.CELL_TYPE_STRING).setCellValue(log.getBigDecimal("share_charge") == null ? BigDecimal.ZERO.toPlainString() : log.getBigDecimal("share_charge").toPlainString());
row.createCell(7, Cell.CELL_TYPE_STRING).setCellValue(type);
}
wb.write(ous);
ous.flush();
}
}
} }

@ -20,6 +20,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
/** /**
* Created by yixian on 2017-03-08. * Created by yixian on 2017-03-08.
@ -42,6 +43,11 @@ public class CityPartnerPrizeController {
return cityPartnerPrizeService.listAvailableMonths(year); return cityPartnerPrizeService.listAvailableMonths(year);
} }
@RequestMapping(value = "/export/{monthStr}", method = RequestMethod.GET)
public void exportExcel(@PathVariable String monthStr,HttpServletResponse httpResponse) throws Exception {
cityPartnerPrizeService.exportMonthFiles(monthStr,httpResponse);
}
@RequestMapping(value = "/months/{monthStr}") @RequestMapping(value = "/months/{monthStr}")
public JSONObject getCityPartnersPrizeInfo(@PathVariable String monthStr) { public JSONObject getCityPartnersPrizeInfo(@PathVariable String monthStr) {
List<JSONObject> partnerPrizeInfos = cityPartnerPrizeService.getCityPartnerPrizeInfoList(monthStr); List<JSONObject> partnerPrizeInfos = cityPartnerPrizeService.getCityPartnerPrizeInfoList(monthStr);

@ -335,7 +335,7 @@ public class TestController implements ApplicationEventPublisherAware {
} }
JSONObject order = orderMapper.find(refundOrder.getString("order_id")); JSONObject order = orderMapper.find(refundOrder.getString("order_id"));
Assert.notNull(order); Assert.notNull(order);
String channel = order.getString("channel"); String channel = order.getString("order_channel");
JSONObject res = new JSONObject(); JSONObject res = new JSONObject();
TradeType type = TradeType.fromGatewayNumber(order.getIntValue("gateway")); TradeType type = TradeType.fromGatewayNumber(order.getIntValue("gateway"));
switch (channel) { switch (channel) {

@ -4,15 +4,14 @@ import au.com.royalpay.payment.core.risk.bean.RiskTypeEnum;
import au.com.royalpay.payment.manage.logview.beans.LogRiskQueryBean; import au.com.royalpay.payment.manage.logview.beans.LogRiskQueryBean;
import au.com.royalpay.payment.manage.mappers.log.LogRiskMapper; import au.com.royalpay.payment.manage.mappers.log.LogRiskMapper;
import au.com.royalpay.payment.manage.permission.manager.ManagerMapping; import au.com.royalpay.payment.manage.permission.manager.ManagerMapping;
import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
import au.com.royalpay.payment.manage.tradelog.beans.PreRefundQueryBean; import au.com.royalpay.payment.manage.tradelog.beans.PreRefundQueryBean;
import au.com.royalpay.payment.manage.tradelog.core.TradeLogService; import au.com.royalpay.payment.manage.tradelog.core.TradeLogService;
import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
import au.com.royalpay.payment.tools.utils.PageListUtils; import au.com.royalpay.payment.tools.utils.PageListUtils;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds; import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -30,14 +29,14 @@ public class LogRiskController {
@Resource @Resource
private TradeLogService tradeLogService; private TradeLogService tradeLogService;
@RequestMapping(value = "/risk_log/list", method = RequestMethod.GET) @GetMapping(value = "/risk_log/list")
public JSONObject listLogRisk(LogRiskQueryBean logRiskQueryBean) { public JSONObject listLogRisk(LogRiskQueryBean logRiskQueryBean) {
return PageListUtils.buildPageListResult( return PageListUtils.buildPageListResult(
logRiskMapper.listWithClientInfo(logRiskQueryBean.toParams(), new PageBounds(logRiskQueryBean.getPage(), logRiskQueryBean.getLimit()))); logRiskMapper.listWithClientInfo(logRiskQueryBean.toParams(), new PageBounds(logRiskQueryBean.getPage(), logRiskQueryBean.getLimit())));
} }
@RequestMapping(value = "/risk_log/typeCharts", method = RequestMethod.GET) @GetMapping(value = "/risk_log/typeCharts")
public JSONObject typeCharts(LogRiskQueryBean logRiskQueryBean) { public JSONObject typeCharts(LogRiskQueryBean logRiskQueryBean) {
List<JSONObject> statisticsRiskLogList = logRiskMapper.statisticsRiskLog(logRiskQueryBean.toParams()); List<JSONObject> statisticsRiskLogList = logRiskMapper.statisticsRiskLog(logRiskQueryBean.toParams());
if (CollectionUtils.isEmpty(statisticsRiskLogList)) { if (CollectionUtils.isEmpty(statisticsRiskLogList)) {
@ -84,8 +83,8 @@ public class LogRiskController {
return result; return result;
} }
@RequestMapping(value = "/pre_refund/list", method = RequestMethod.GET) @GetMapping(value = "/pre_refund/list")
public JSONObject listPreRefund(PreRefundQueryBean preRefundQueryBean) { public JSONObject listPreRefund(PreRefundQueryBean preRefundQueryBean) {
return PageListUtils.buildPageListResult(tradeLogService.listPreRefundClients(preRefundQueryBean)); return tradeLogService.listPreRefundClients(preRefundQueryBean);
} }
} }

@ -4,11 +4,7 @@ import au.com.royalpay.payment.core.PaymentApi;
import au.com.royalpay.payment.core.exceptions.InvalidShortIdException; import au.com.royalpay.payment.core.exceptions.InvalidShortIdException;
import au.com.royalpay.payment.core.tasksupport.SettlementSupport; import au.com.royalpay.payment.core.tasksupport.SettlementSupport;
import au.com.royalpay.payment.manage.management.clearing.core.CleanService; import au.com.royalpay.payment.manage.management.clearing.core.CleanService;
import au.com.royalpay.payment.manage.mappers.log.ClearingDetailAnalysisMapper; import au.com.royalpay.payment.manage.mappers.log.*;
import au.com.royalpay.payment.manage.mappers.log.ClearingDetailMapper;
import au.com.royalpay.payment.manage.mappers.log.ClearingLogMapper;
import au.com.royalpay.payment.manage.mappers.log.LogSettleMailMapper;
import au.com.royalpay.payment.manage.mappers.log.ValidationLogMapper;
import au.com.royalpay.payment.manage.mappers.payment.TaskManualSettleMapper; 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.payment.TransactionMapper;
import au.com.royalpay.payment.manage.mappers.system.*; import au.com.royalpay.payment.manage.mappers.system.*;
@ -34,16 +30,15 @@ import au.com.royalpay.payment.tools.locale.LocaleSupport;
import au.com.royalpay.payment.tools.lock.Locker; import au.com.royalpay.payment.tools.lock.Locker;
import au.com.royalpay.payment.tools.permission.enums.ManagerRole; import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
import au.com.royalpay.payment.tools.tasksupport.TaskFinishNotifyEvent; import au.com.royalpay.payment.tools.tasksupport.TaskFinishNotifyEvent;
import au.com.royalpay.payment.tools.utils.DateVaildUtil;
import au.com.royalpay.payment.tools.utils.PageListUtils; import au.com.royalpay.payment.tools.utils.PageListUtils;
import au.com.royalpay.payment.tools.utils.TimeZoneUtils; import au.com.royalpay.payment.tools.utils.TimeZoneUtils;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.Order; import com.github.miemiedev.mybatis.paginator.domain.Order;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds; import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList; import com.github.miemiedev.mybatis.paginator.domain.PageList;
import org.apache.commons.codec.binary.Base64; import org.apache.commons.codec.binary.Base64;
import org.apache.commons.csv.CSVFormat; import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVPrinter; import org.apache.commons.csv.CSVPrinter;
@ -52,12 +47,7 @@ import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.lang3.time.DateUtils;
import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.joda.time.Days; import org.joda.time.Days;
@ -75,37 +65,20 @@ import org.springframework.util.CollectionUtils;
import org.thymeleaf.context.Context; import org.thymeleaf.context.Context;
import org.thymeleaf.spring4.SpringTemplateEngine; import org.thymeleaf.spring4.SpringTemplateEngine;
import java.io.BufferedWriter; import javax.annotation.Resource;
import java.io.ByteArrayOutputStream; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.*;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Writer;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.NumberFormat; import java.text.NumberFormat;
import java.util.ArrayList; import java.util.*;
import java.util.Calendar;
import java.util.Currency;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.TreeMap;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream; import java.util.zip.ZipOutputStream;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import static au.com.royalpay.payment.manage.permission.utils.OrgCheckUtils.checkOrgPermission; import static au.com.royalpay.payment.manage.permission.utils.OrgCheckUtils.checkOrgPermission;
/** /**
@ -163,7 +136,7 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
@Resource @Resource
private ClientDeviceMapper clientDeviceMapper; private ClientDeviceMapper clientDeviceMapper;
private static final int MAX_TRACK_DAYS = 31;
@Value("${app.settlement.email-to}") @Value("${app.settlement.email-to}")
private String settlementEmailTo; private String settlementEmailTo;
@Value("${app.settlement.email-cc}") @Value("${app.settlement.email-cc}")
@ -627,9 +600,9 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
@Override @Override
public JSONObject getCleanLogsInClients(ClearingLogQuery query, JSONObject manager) { public JSONObject getCleanLogsInClients(ClearingLogQuery query, JSONObject manager) {
JSONObject params = query.toParams(); JSONObject params = query.toParams();
DateVaildUtil.validDateDuration(params.getDate("from"), params.getDate("to"), MAX_TRACK_DAYS);
if (query.getClientMoniker() != null && !query.getClientMoniker().isEmpty()) { if (query.getClientMoniker() != null && !query.getClientMoniker().isEmpty()) {
JSONObject client = clientManager.getClientInfoByMoniker(query.getClientMoniker()); JSONObject client = clientManager.getClientInfoByMoniker(query.getClientMoniker());
Assert.notNull(client);
} }
if (manager.getInteger("org_id") != null) { if (manager.getInteger("org_id") != null) {
params.put("org_id", manager.getIntValue("org_id")); params.put("org_id", manager.getIntValue("org_id"));
@ -642,9 +615,9 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
@Override @Override
public JSONObject analysisCleanLogs(ClearingLogQuery query, JSONObject manager) { public JSONObject analysisCleanLogs(ClearingLogQuery query, JSONObject manager) {
JSONObject params = query.toParams(); JSONObject params = query.toParams();
DateVaildUtil.validDateDuration(params.getDate("from"), params.getDate("to"), MAX_TRACK_DAYS);
if (query.getClientMoniker() != null && !query.getClientMoniker().isEmpty()) { if (query.getClientMoniker() != null && !query.getClientMoniker().isEmpty()) {
JSONObject client = clientManager.getClientInfoByMoniker(query.getClientMoniker()); JSONObject client = clientManager.getClientInfoByMoniker(query.getClientMoniker());
Assert.notNull(client);
} }
if (manager.getInteger("org_id") != null) { if (manager.getInteger("org_id") != null) {
params.put("org_id", manager.getIntValue("org_id")); params.put("org_id", manager.getIntValue("org_id"));
@ -734,11 +707,11 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
JSONObject client = clientManager.getClientInfo(client_id); JSONObject client = clientManager.getClientInfo(client_id);
Assert.notNull(client, "Client not exists"); Assert.notNull(client, "Client not exists");
int parent_client_id = client.getIntValue("parent_client_id"); int parent_client_id = client.getIntValue("parent_client_id");
if (partner.get("client_id") != null) {
if (client_id != partner.getIntValue("client_id") && parent_client_id != partner.getIntValue("client_id")) { if (client_id != partner.getIntValue("client_id") && parent_client_id != partner.getIntValue("client_id")) {
throw new ForbiddenException("No Permission"); throw new ForbiddenException("No Permission");
}
} }
JSONObject clearClient = clearingDetailMapper.listReport(clearingDetailId, client_id); JSONObject clearClient = clearingDetailMapper.listReport(clearingDetailId, client_id);
if (clearClient == null) { if (clearClient == null) {
throw new NotFoundException(); throw new NotFoundException();

@ -4,9 +4,7 @@ import au.com.royalpay.payment.manage.mappers.log.ValidationLogMapper;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import netscape.javascript.JSObject;
import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.lang3.time.DateUtils;
import org.apache.xerces.impl.validation.ValidationManager;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;

@ -1,17 +1,16 @@
package au.com.royalpay.payment.manage.management.clearing.web; package au.com.royalpay.payment.manage.management.clearing.web;
import au.com.royalpay.payment.manage.management.clearing.core.CleanService; import au.com.royalpay.payment.manage.management.clearing.core.CleanService;
import au.com.royalpay.payment.manage.permission.manager.PartnerMapping;
import au.com.royalpay.payment.tools.permission.enums.ManagerRole; import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
import au.com.royalpay.payment.manage.permission.manager.RequireManager; import au.com.royalpay.payment.manage.permission.manager.RequireManager;
import au.com.royalpay.payment.manage.tradelog.beans.ClearingLogQuery; import au.com.royalpay.payment.manage.tradelog.beans.ClearingLogQuery;
import au.com.royalpay.payment.tools.CommonConsts; import au.com.royalpay.payment.tools.CommonConsts;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;
/** /**
@ -44,4 +43,10 @@ public class CleanLogManagementController {
return cleanService.getSettlementLogs(query, manager); return cleanService.getSettlementLogs(query, manager);
} }
@PartnerMapping("/{client_id}/settlement_logs/{clearingDetailId}/export")
public void exportListClearingTransactions(@PathVariable int client_id, @PathVariable String clearingDetailId,
@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject partner, HttpServletResponse resp) {
cleanService.exportListClearingTransactions(client_id, clearingDetailId, partner, resp);
}
} }

@ -8,13 +8,14 @@ import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds; import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList; import com.github.miemiedev.mybatis.paginator.domain.PageList;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator;
import java.util.List; import java.util.List;
/** /**
* Created by yixian on 2017-03-21. * Created by yixian on 2017-03-21.
*/ */
@AutoMapper(tablename = "act_diet_attend", pkName = "attend_id", pkAutoIncrement = true) @AutoMapper(tablename = "act_diet_attend", pkName = "attend_id", keyGenerator = Jdbc3KeyGenerator.class)
public interface ActDietAttendMapper { public interface ActDietAttendMapper {
@AutoSql(type = SqlType.SELECT) @AutoSql(type = SqlType.SELECT)

@ -1,11 +1,13 @@
package au.com.royalpay.payment.manage.mappers.client; package au.com.royalpay.payment.manage.mappers.client;
import cn.yixblog.support.mybatis.autosql.annotations.AdvanceSelect;
import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper; import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper;
import cn.yixblog.support.mybatis.autosql.annotations.AutoSql; import cn.yixblog.support.mybatis.autosql.annotations.AutoSql;
import cn.yixblog.support.mybatis.autosql.annotations.SqlType; import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds; import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List; import java.util.List;
@ -14,6 +16,8 @@ public interface ClientSubMerchantIdMapper {
@AutoSql(type = SqlType.SELECT) @AutoSql(type = SqlType.SELECT)
List<JSONObject> listSubMerchantId(PageBounds pageBounds); List<JSONObject> listSubMerchantId(PageBounds pageBounds);
List<JSONObject> listSubMerchantIdByDiffDays(@Param("begin") int begin,@Param("end") int end);
@AutoSql(type = SqlType.INSERT) @AutoSql(type = SqlType.INSERT)
void save(JSONObject subMerchantId); void save(JSONObject subMerchantId);
@ -22,4 +26,7 @@ public interface ClientSubMerchantIdMapper {
@AutoSql(type = SqlType.DELETE) @AutoSql(type = SqlType.DELETE)
void delete(@Param("sub_merchant_id") String sub_merchant_id); void delete(@Param("sub_merchant_id") String sub_merchant_id);
@AutoSql(type = SqlType.DELETE)
void deleteAll();
} }

@ -1,17 +1,13 @@
package au.com.royalpay.payment.manage.mappers.custom; 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.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds; import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList; import com.github.miemiedev.mybatis.paginator.domain.PageList;
import org.apache.ibatis.annotations.Param; 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. * Created by yishuqian on 9/1/16.
*/ */

@ -6,6 +6,7 @@ import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.math.BigDecimal;
import java.util.List; import java.util.List;
/** /**
@ -31,4 +32,6 @@ public interface FinancialBDCommissionConfigMapper {
void deleteConfig(@Param("bc_config_id") String configInfo); void deleteConfig(@Param("bc_config_id") String configInfo);
JSONObject findCurrentCommissionRate(@Param("month") String month, @Param("amount") String amount, @Param("bd_type") int bd_type); JSONObject findCurrentCommissionRate(@Param("month") String month, @Param("amount") String amount, @Param("bd_type") int bd_type);
BigDecimal findCurrentCommissionMaxAmount(@Param("month") String month, @Param("bd_type") int bd_type);
} }

@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONObject;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
@ -37,4 +38,8 @@ public interface FinancialBDConfigMapper {
List<JSONObject> listBDCity(); List<JSONObject> listBDCity();
JSONObject listCityCommission(@Param("city") String city, @Param("record_id") String record_id); JSONObject listCityCommission(@Param("city") String city, @Param("record_id") String record_id);
List<JSONObject> findManagerByTeamType(@Param("bd_type") String bdType, @Param("record_id") String record_id);
List<JSONObject> findManagerByTeamTypeRealTime(@Param("bd_type") String bdType, @Param("start_date") Date start_date, @Param("end_date") Date end_date);
} }

@ -9,6 +9,7 @@ import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Select;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
@ -32,13 +33,34 @@ public interface FinancialBDPrizeLogMapper {
@AdvanceSelect(addonWhereClause = "prize_type=0") @AdvanceSelect(addonWhereClause = "prize_type=0")
List<JSONObject> findByReportAndBD(@Param("record_id") String recordId, @Param("manager_id") String managerId); List<JSONObject> findByReportAndBD(@Param("record_id") String recordId, @Param("manager_id") String managerId);
@Select("SELECT prize_log_id,record_id,manager_id,bd_name,bd_level,SUM(total_amount) total_amount, " + @Select("SELECT prize_log_id,record_id,kpi_amount,manager_id,bd_name,bd_level,SUM(total_amount) total_amount, " +
"SUM(total_prize) total_prize,SUM(total_donation) total_donation, SUM(send_prize) send_prize, " + "SUM(total_prize) total_prize,SUM(total_donation) total_donation, SUM(send_prize) send_prize, " +
"SUM(hold_prize) hold_prize,last_punish,prize_type FROM financial_bd_prize_log fbpl " + "SUM(hold_prize) hold_prize,last_punish,prize_type FROM financial_bd_prize_log fbpl " +
"where fbpl.prize_type = 0 and fbpl.record_id = #{record_id} and fbpl.manager_id = #{manager_id} " + "where fbpl.prize_type = 0 and fbpl.record_id = #{record_id} and fbpl.manager_id = #{manager_id} " +
"GROUP BY fbpl.manager_id") "GROUP BY fbpl.manager_id")
JSONObject findByReportAndBDTotal(@Param("record_id") String recordId, @Param("manager_id") String managerId); JSONObject findByReportAndBDTotal(@Param("record_id") String recordId, @Param("manager_id") String managerId);
@Select("SELECT\n" +
"\tc.bd_name,\n" +
"\tc.manager_id,\n" +
"\tc.kpi_amount,\n" +
"\tsum( o.total * d.proportion ) AS total_amount \n" +
"FROM\n" +
"\tstatistics_customer_order o\n" +
"\tINNER JOIN sys_clients sc ON sc.client_id = o.client_id\n" +
"\tINNER JOIN sys_client_bd d ON o.client_id = d.client_id\n" +
"\tINNER JOIN financial_bd_config c ON d.bd_id = c.manager_id \n" +
"WHERE\n" +
"\tsc.org_id = 1 \n" +
"\tAND o.date >= #{start_date} \n" +
"\tAND o.date < #{end_date} \n" +
"\tAND d.start_date <= o.date AND d.is_valid = 1 AND ( d.end_date IS NULL OR d.end_date > o.date \n" +
"\t) \n" +
"\tAND c.get_prize = 1 \n" +
"\tAND c.manager_id = #{manager_id}")
JSONObject findByReportAndBDTotalRealTime(@Param("manager_id") String manage_id, @Param("start_date") Date start_date, @Param("end_date") Date end_date);
@Select("SELECT prize_log_id,record_id,manager_id,bd_name,bd_level,SUM(total_amount) total_amount," + @Select("SELECT prize_log_id,record_id,manager_id,bd_name,bd_level,SUM(total_amount) total_amount," +
"SUM(total_prize) total_prize,SUM(total_donation) total_donation, SUM(send_prize) send_prize," + "SUM(total_prize) total_prize,SUM(total_donation) total_donation, SUM(send_prize) send_prize," +
"SUM(hold_prize) hold_prize,last_punish,prize_type FROM financial_bd_prize_log fbpl " + "SUM(hold_prize) hold_prize,last_punish,prize_type FROM financial_bd_prize_log fbpl " +
@ -60,4 +82,30 @@ public interface FinancialBDPrizeLogMapper {
@AutoSql(type = SqlType.SELECT) @AutoSql(type = SqlType.SELECT)
List<JSONObject> findReportByOne(@Param("record_id") String recordId, @Param("manager_id") String managerId); List<JSONObject> findReportByOne(@Param("record_id") String recordId, @Param("manager_id") String managerId);
@Select("SELECT c.manager_id, SUM(total_amount) total_amount, c.bd_type\n" +
"FROM financial_bd_prize_log l\n" +
"INNER JOIN financial_bd_config c ON l.manager_id = c.manager_id\n" +
"WHERE prize_type = 1 AND record_id = #{record_id}\n" +
"GROUP BY l.manager_id")
List<JSONObject> findBdPrizeAmountAndBdType(@Param("record_id") String recordId);
@Select("SELECT\n" +
"\tc.*,\n" +
"\tsum( ( o.total ) * d.proportion ) AS total_amount\n" +
"FROM\n" +
"\tstatistics_customer_order o\n" +
"\tINNER JOIN sys_clients sc ON sc.client_id = o.client_id\n" +
"\tINNER JOIN sys_client_bd d ON o.client_id = d.client_id\n" +
"\tINNER JOIN financial_bd_config c ON d.bd_id = c.manager_id \n" +
"WHERE\n" +
"\tsc.org_id = 1 \n" +
"\tAND o.date >= #{start_date} \n" +
"\tAND o.date < #{end_date} \n" +
"\tAND d.start_date <= o.date AND d.is_valid = 1 AND ( d.end_date IS NULL OR d.end_date > o.date \n" +
"\t) \n" +
"\tAND c.bd_group IS NOT NULL \n" +
"GROUP BY\n" +
"\tc.bd_group")
List<JSONObject> findBdPrizeAmountRealTime(@Param("start_date") Date start_date, @Param("end_date") Date end_date);
} }

@ -4,13 +4,14 @@ import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper;
import cn.yixblog.support.mybatis.autosql.annotations.AutoSql; import cn.yixblog.support.mybatis.autosql.annotations.AutoSql;
import cn.yixblog.support.mybatis.autosql.annotations.SqlType; import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator;
import java.util.List; import java.util.List;
/** /**
* Created by yixian on 2017-02-07. * Created by yixian on 2017-02-07.
*/ */
@AutoMapper(tablename = "financial_bd_prize_rate_config", pkName = "config_id", pkAutoIncrement = true) @AutoMapper(tablename = "financial_bd_prize_rate_config", pkName = "config_id", keyGenerator = Jdbc3KeyGenerator.class)
public interface FinancialBDRateConfigMapper { public interface FinancialBDRateConfigMapper {
@AutoSql(type = SqlType.SELECT) @AutoSql(type = SqlType.SELECT)
List<JSONObject> listAllConfig(); List<JSONObject> listAllConfig();

@ -5,6 +5,7 @@ import cn.yixblog.support.mybatis.autosql.annotations.AutoSql;
import cn.yixblog.support.mybatis.autosql.annotations.SqlType; import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
@ -13,7 +14,7 @@ import java.util.List;
/** /**
* Created by yixian on 2017-03-21. * Created by yixian on 2017-03-21.
*/ */
@AutoMapper(tablename = "log_clearing_detail_analysis", pkName = "detail_id", pkAutoIncrement = true) @AutoMapper(tablename = "log_clearing_detail_analysis", pkName = "detail_id", keyGenerator = Jdbc3KeyGenerator.class)
public interface ClearingDetailAnalysisMapper { public interface ClearingDetailAnalysisMapper {
@AutoSql(type = SqlType.INSERT) @AutoSql(type = SqlType.INSERT)
void save(JSONObject channel); void save(JSONObject channel);

@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds; import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList; import com.github.miemiedev.mybatis.paginator.domain.PageList;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -14,7 +15,7 @@ import java.util.List;
/** /**
* Created by davep on 2016-09-05. * Created by davep on 2016-09-05.
*/ */
@AutoMapper(tablename = "log_clearing_detail", pkAutoIncrement = true, pkName = "clear_detail_id") @AutoMapper(tablename = "log_clearing_detail", keyGenerator = Jdbc3KeyGenerator.class, pkName = "clear_detail_id")
public interface ClearingDetailMapper { public interface ClearingDetailMapper {
@AutoSql(type = SqlType.INSERT) @AutoSql(type = SqlType.INSERT)
void save(JSONObject detail); void save(JSONObject detail);

@ -5,6 +5,7 @@ import cn.yixblog.support.mybatis.autosql.annotations.AutoSql;
import cn.yixblog.support.mybatis.autosql.annotations.SqlType; import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -12,7 +13,7 @@ import java.util.List;
/** /**
* Created by davep on 2016-09-04. * Created by davep on 2016-09-04.
*/ */
@AutoMapper(tablename = "log_clearing", pkName = "clearing_id", pkAutoIncrement = true) @AutoMapper(tablename = "log_clearing", pkName = "clearing_id", keyGenerator = Jdbc3KeyGenerator.class)
public interface ClearingLogMapper { public interface ClearingLogMapper {
@AutoSql(type = SqlType.INSERT) @AutoSql(type = SqlType.INSERT)

@ -22,7 +22,7 @@ public interface NotifyErrorLogMapper {
void saveLog(JSONObject log); void saveLog(JSONObject log);
@AutoSql(type = SqlType.SELECT) @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(); List<JSONObject> listErrorLogsInOneHour();
@AutoSql(type = SqlType.UPDATE) @AutoSql(type = SqlType.UPDATE)

@ -5,6 +5,7 @@ import cn.yixblog.support.mybatis.autosql.annotations.AutoSql;
import cn.yixblog.support.mybatis.autosql.annotations.SqlType; import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -12,7 +13,7 @@ import java.util.List;
/** /**
* Created by yixian on 2016-09-19. * Created by yixian on 2016-09-19.
*/ */
@AutoMapper(tablename = "log_order_validation", pkName = "valid_id", pkAutoIncrement = true) @AutoMapper(tablename = "log_order_validation", pkName = "valid_id", keyGenerator = Jdbc3KeyGenerator.class)
public interface ValidationLogMapper { public interface ValidationLogMapper {
@AutoSql(type = SqlType.INSERT) @AutoSql(type = SqlType.INSERT)

@ -38,14 +38,6 @@ public interface OrderMapper {
JSONObject getOrderDetail(@Param("order_id") String orderId); 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) @AutoSql(type = SqlType.SELECT)
PageList<JSONObject> list(JSONObject params, PageBounds pagination); 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); 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) int getOldOrdersPoints(@Param("customer_id") String openId);
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);
PageList<JSONObject> listOrderByCustomer(JSONObject params, PageBounds pagination); PageList<JSONObject> listOrderByCustomer(JSONObject params, PageBounds pagination);

@ -4,10 +4,12 @@ import cn.yixblog.support.mybatis.autosql.annotations.AdvanceSelect;
import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper; import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper;
import cn.yixblog.support.mybatis.autosql.annotations.AutoSql; import cn.yixblog.support.mybatis.autosql.annotations.AutoSql;
import cn.yixblog.support.mybatis.autosql.annotations.SqlType; import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
import cn.yixblog.support.mybatis.paginator.annotations.CountRef;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds; import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList; import com.github.miemiedev.mybatis.paginator.domain.PageList;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
@ -16,50 +18,34 @@ import java.util.List;
/** /**
* Created by yixian on 2016-07-01. * Created by yixian on 2016-07-01.
*/ */
@AutoMapper(tablename = "pmt_transactions", pkName = "transaction_id", pkAutoIncrement = true) @AutoMapper(tablename = "pmt_transactions", pkName = "transaction_id", keyGenerator = Jdbc3KeyGenerator.class)
public interface TransactionMapper { public interface TransactionMapper {
@AutoSql(type = SqlType.INSERT) @AutoSql(type = SqlType.INSERT)
void save(JSONObject transaction); void save(JSONObject transaction);
@CountRef(".countTransFlowPage")
PageList<JSONObject> listTransFlowPage(JSONObject params, PageBounds pagination); PageList<JSONObject> listTransFlowPage(JSONObject params, PageBounds pagination);
int countTransFlowPage(JSONObject params);
List<JSONObject> listTransFlow(JSONObject params); List<JSONObject> listTransFlow(JSONObject params);
JSONObject analysisTransFlow(JSONObject params); JSONObject analysisTransFlow(JSONObject params);
Double analysisBalance(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) @AutoSql(type = SqlType.SELECT)
@AdvanceSelect(addonWhereClause = "transaction_type = 'Credit'") @AdvanceSelect(addonWhereClause = "transaction_type = 'Credit'")
JSONObject findByOrderId(@Param("order_id") String orderId); 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) @AutoSql(type = SqlType.UPDATE)
void update(JSONObject transaction); 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(); JSONObject findLastIncome();
double getClientUnClearedAmount(@Param("client_id") int clientId); 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); JSONObject getClientAmountAnalysis(JSONObject params);
@ -75,8 +61,11 @@ public interface TransactionMapper {
PageList<JSONObject> listSettlementLog(JSONObject params, PageBounds pagination); PageList<JSONObject> listSettlementLog(JSONObject params, PageBounds pagination);
@CountRef(".countSettlementLogInClients")
PageList<JSONObject> listSettlementLogInClients(JSONObject params, PageBounds pagination); PageList<JSONObject> listSettlementLogInClients(JSONObject params, PageBounds pagination);
int countSettlementLogInClients(JSONObject params);
JSONObject analysisSettlementLog(JSONObject params); JSONObject analysisSettlementLog(JSONObject params);
List<JSONObject> listSettlementLogTotal(JSONObject params); List<JSONObject> listSettlementLogTotal(JSONObject params);
@ -97,11 +86,11 @@ public interface TransactionMapper {
List<JSONObject> listTransactionsForBDPrize(@Param("year") int year, @Param("month") int month, @Param("channel") String channel); 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); List<JSONObject> listTransactionForCityPartnerCommissionByDate(@Param("year") int year, @Param("month") int month);
@ -117,7 +106,7 @@ public interface TransactionMapper {
@AutoSql(type = SqlType.COUNT) @AutoSql(type = SqlType.COUNT)
@AdvanceSelect(addonWhereClause = "transaction_type='Credit'") @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); 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);
@ -127,16 +116,8 @@ public interface TransactionMapper {
@AdvanceSelect(addonWhereClause = "system_generate=1") @AdvanceSelect(addonWhereClause = "system_generate=1")
List<JSONObject> findTransactionsBySysGen(@Param("order_id") String orderId); 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); 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> getSettleDelayAnalysis(@Param("begin") Date begin, @Param("end") Date end);
List<JSONObject> getSettleDelayTotalTransaction(@Param("begin") Date begin, @Param("end") Date end); List<JSONObject> getSettleDelayTotalTransaction(@Param("begin") Date begin, @Param("end") Date end);

@ -11,8 +11,9 @@ import java.util.List;
import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper; import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper;
import cn.yixblog.support.mybatis.autosql.annotations.AutoSql; import cn.yixblog.support.mybatis.autosql.annotations.AutoSql;
import cn.yixblog.support.mybatis.autosql.annotations.SqlType; import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
import org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator;
@AutoMapper(tablename = "sys_client_pre_apply", pkName = "client_pre_apply_id",pkAutoIncrement = true) @AutoMapper(tablename = "sys_client_pre_apply", pkName = "client_pre_apply_id",keyGenerator = Jdbc3KeyGenerator.class)
public interface SysClientPreMapperMapper { public interface SysClientPreMapperMapper {
@AutoSql(type = SqlType.UPDATE) @AutoSql(type = SqlType.UPDATE)
void update(JSONObject data); void update(JSONObject data);

@ -11,7 +11,7 @@ import java.util.List;
/** /**
* Created by yishuqian on 04/01/2017. * Created by yishuqian on 04/01/2017.
*/ */
@AutoMapper(tablename = "act_black_list") @AutoMapper(tablename = "act_black_list", pkName = {"act_id", "client_id"})
public interface ActBlackListMapper { public interface ActBlackListMapper {
@AutoSql(type = SqlType.INSERT) @AutoSql(type = SqlType.INSERT)
void save(JSONObject blackObj); void save(JSONObject blackObj);

@ -1,11 +1,11 @@
package au.com.royalpay.payment.manage.mappers.system; package au.com.royalpay.payment.manage.mappers.system;
import cn.yixblog.support.mybatis.autosql.annotations.AdvanceSelect;
import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper; import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper;
import cn.yixblog.support.mybatis.autosql.annotations.AutoSql; import cn.yixblog.support.mybatis.autosql.annotations.AutoSql;
import cn.yixblog.support.mybatis.autosql.annotations.SqlType; import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.joda.time.DateTime;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -16,12 +16,15 @@ public interface ClearingDistributedSurchargeMapper {
List<JSONObject> findTransactions(@Param("client_id") int clientId); List<JSONObject> findTransactions(@Param("client_id") int clientId);
@AutoSql(type = SqlType.UPDATE)
void update(JSONObject transaction);
@AutoSql(type = SqlType.INSERT) @AutoSql(type = SqlType.INSERT)
void save(JSONObject transactions); void save(JSONObject transactions);
List<JSONObject> getMonthDetailByClientId(@Param("datefrom") Date datefrom, @Param("dateto") Date dateto); List<JSONObject> getMonthDetailByClientId(@Param("datefrom") Date datefrom, @Param("dateto") Date dateto);
List<JSONObject> findTransactionsByDate(JSONObject params); List<JSONObject> findSurchargeTransactionsByDetailId(@Param("client_id") int clientId, @Param("detailId") String detailId);
List<JSONObject> listUnClearedByMonth(@Param("dateto") DateTime dateTo);
} }

@ -5,13 +5,14 @@ import cn.yixblog.support.mybatis.autosql.annotations.AutoSql;
import cn.yixblog.support.mybatis.autosql.annotations.SqlType; import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator;
import java.util.List; import java.util.List;
/** /**
* Created by davep on 2016-08-16. * Created by davep on 2016-08-16.
*/ */
@AutoMapper(tablename = "sys_bank_accounts", pkAutoIncrement = true, pkName = "bank_account_id") @AutoMapper(tablename = "sys_bank_accounts", keyGenerator = Jdbc3KeyGenerator.class, pkName = "bank_account_id")
public interface ClientBankAccountMapper { public interface ClientBankAccountMapper {
@AutoSql(type = SqlType.SELECT) @AutoSql(type = SqlType.SELECT)

@ -9,6 +9,8 @@ import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds; import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList; import com.github.miemiedev.mybatis.paginator.domain.PageList;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -16,7 +18,7 @@ import java.util.List;
/** /**
* Created by yixian on 2016-06-25. * Created by yixian on 2016-06-25.
*/ */
@AutoMapper(tablename = "sys_clients", pkName = "client_id", pkAutoIncrement = true) @AutoMapper(tablename = "sys_clients", pkName = "client_id", keyGenerator = Jdbc3KeyGenerator.class)
public interface ClientMapper { public interface ClientMapper {
@AutoSql(type = SqlType.SELECT) @AutoSql(type = SqlType.SELECT)
@AdvanceSelect(addonWhereClause = "is_valid=1") @AdvanceSelect(addonWhereClause = "is_valid=1")
@ -114,5 +116,6 @@ public interface ClientMapper {
JSONObject countBdApproveClients(@Param("manager_id") String manager_id); JSONObject countBdApproveClients(@Param("manager_id") String manager_id);
@Select("select client_id from sys_clients where parent_client_id=#{parent_client_id}")
List<Integer> childClientId(@Param("parent_client_id") int parent_client_id);
} }

@ -5,6 +5,7 @@ import cn.yixblog.support.mybatis.autosql.annotations.AutoSql;
import cn.yixblog.support.mybatis.autosql.annotations.SqlType; import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -12,7 +13,7 @@ import java.util.List;
/** /**
* Created by davep on 2016-08-16. * Created by davep on 2016-08-16.
*/ */
@AutoMapper(tablename = "sys_client_rates", pkName = "client_rate_id", pkAutoIncrement = true) @AutoMapper(tablename = "sys_client_rates", pkName = "client_rate_id", keyGenerator = Jdbc3KeyGenerator.class)
public interface ClientRateMapper { public interface ClientRateMapper {
List<JSONObject> listCurrentClientRates(@Param("client_id") int clientId, @Param("date") Date date, @Param("rate_name") String rateName); List<JSONObject> listCurrentClientRates(@Param("client_id") int clientId, @Param("date") Date date, @Param("rate_name") String rateName);

@ -6,11 +6,12 @@ import cn.yixblog.support.mybatis.autosql.annotations.AutoSql;
import cn.yixblog.support.mybatis.autosql.annotations.SqlType; import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator;
/** /**
* Created by davep on 2016-08-03. * Created by davep on 2016-08-03.
*/ */
@AutoMapper(tablename = "sys_customer_relation", pkName = "relation_id", pkAutoIncrement = true) @AutoMapper(tablename = "sys_customer_relation", pkName = "relation_id", keyGenerator = Jdbc3KeyGenerator.class)
public interface CustomerMapper { public interface CustomerMapper {
@AutoSql(type = SqlType.INSERT) @AutoSql(type = SqlType.INSERT)

@ -6,13 +6,15 @@ import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List; import java.util.List;
@AutoMapper(tablename = "financial_surcharge_account_detail", pkName = "detail_id") @AutoMapper(tablename = "financial_surcharge_account_detail", pkName = "detail_id")
public interface FinancialSurchargeAccountDetailMapper { public interface FinancialSurchargeAccountDetailMapper {
@AutoSql(type = SqlType.SELECT)
JSONObject findByDetailId(@Param("detail_id") String detail_id);
List<JSONObject> findDetailsByMonth(@Param("settle_month") String settle_month); List<JSONObject> findDetailsByMonth(@Param("settle_month") String settle_month);
List<JSONObject> findDetailsByClientId(@Param("client_id") int client_id); List<JSONObject> findDetailsByClientId(@Param("client_id") int client_id);
@ -20,9 +22,11 @@ public interface FinancialSurchargeAccountDetailMapper {
@AutoSql(type = SqlType.INSERT) @AutoSql(type = SqlType.INSERT)
void save(JSONObject detail); void save(JSONObject detail);
List<JSONObject> listSettlementDatesInMonth(@Param("month") String month); @AutoSql(type = SqlType.UPDATE)
void update(JSONObject detail);
List<JSONObject> listSettlementDatesInMonth(@Param("month") String month);
List<JSONObject> listSettlementDatesByClientId(@Param("client_id") int client_id);
} }

@ -8,13 +8,14 @@ import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds; import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList; import com.github.miemiedev.mybatis.paginator.domain.PageList;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator;
import java.util.List; import java.util.List;
/** /**
* Created by yixian on 2016-10-18. * Created by yixian on 2016-10-18.
*/ */
@AutoMapper(tablename = "sys_org", pkName = "org_id", pkAutoIncrement = true) @AutoMapper(tablename = "sys_org", pkName = "org_id", keyGenerator = Jdbc3KeyGenerator.class)
public interface OrgMapper { public interface OrgMapper {
@AutoSql(type = SqlType.SELECT) @AutoSql(type = SqlType.SELECT)
@AdvanceSelect(addonWhereClause = "type != 1") @AdvanceSelect(addonWhereClause = "type != 1")

@ -1,20 +1,18 @@
package au.com.royalpay.payment.manage.mappers.system; package au.com.royalpay.payment.manage.mappers.system;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.alibaba.fastjson.JSONObject;
import cn.yixblog.support.mybatis.autosql.annotations.AdvanceSelect;
import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper; import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper;
import cn.yixblog.support.mybatis.autosql.annotations.AutoSql; import cn.yixblog.support.mybatis.autosql.annotations.AutoSql;
import cn.yixblog.support.mybatis.autosql.annotations.SqlType; import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
import com.alibaba.fastjson.JSONObject;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator;
import java.util.List;
/** /**
* Created by yixian on 2017-02-28. * Created by yixian on 2017-02-28.
*/ */
@AutoMapper(tablename = "sys_permission_partner_modules", pkName = "id",pkAutoIncrement = true) @AutoMapper(tablename = "sys_permission_partner_modules", pkName = "id",keyGenerator = Jdbc3KeyGenerator.class)
public interface PermissionPartnerModuleMapper { public interface PermissionPartnerModuleMapper {
@AutoSql(type = SqlType.INSERT) @AutoSql(type = SqlType.INSERT)
void save(JSONObject module); void save(JSONObject module);

@ -5,13 +5,14 @@ import cn.yixblog.support.mybatis.autosql.annotations.AutoSql;
import cn.yixblog.support.mybatis.autosql.annotations.SqlType; import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator;
import java.util.List; import java.util.List;
/** /**
* Created by yishuqian on 11/11/2016. * Created by yishuqian on 11/11/2016.
*/ */
@AutoMapper(tablename = "austrac_report_config", pkName = "pkid", pkAutoIncrement = true) @AutoMapper(tablename = "austrac_report_config", pkName = "pkid", keyGenerator = Jdbc3KeyGenerator.class)
public interface ReportConfigMapper { public interface ReportConfigMapper {
@AutoSql(type = SqlType.UPDATE) @AutoSql(type = SqlType.UPDATE)
void update(JSONObject jsonObject); void update(JSONObject jsonObject);

@ -13,7 +13,7 @@ public interface MerchantIdManageService {
void generateClientsSunMerchantId(); void generateClientsSunMerchantId();
JSONObject listNotTradeSubMerchantId(JSONObject manager); JSONObject listNotTradeSubMerchantId(int type, JSONObject manager);
List<JSONObject> showClientMoniker(JSONObject manager,String sub_merchant_id); List<JSONObject> showClientMoniker(JSONObject manager,String sub_merchant_id);

@ -19,19 +19,18 @@ import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.IOException; import java.io.IOException;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.util.Date; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -66,22 +65,41 @@ public class MerchantIdManageServiceImpl implements MerchantIdManageService {
return getClientMap(clients); return getClientMap(clients);
} }
@Override @Override
public JSONObject listNotTradeSubMerchantId(JSONObject manager) { public JSONObject listNotTradeSubMerchantId(int type, JSONObject manager) {
List<JSONObject> clients = clientSubMerchantIdMapper.listSubMerchantId(new PageBounds(Order.formString("create_time.desc"))); List<JSONObject> clients = new ArrayList<>();
switch (type) {
case 0: //all
clients = clientSubMerchantIdMapper.listSubMerchantId(new PageBounds(Order.formString("diff_days.desc")));
break;
case 1://0~15天
clients = clientSubMerchantIdMapper.listSubMerchantIdByDiffDays(0,15);
break;
case 2://15~30天
clients = clientSubMerchantIdMapper.listSubMerchantIdByDiffDays(15,30);
break;
case 3://30~45天
clients = clientSubMerchantIdMapper.listSubMerchantIdByDiffDays(30,45);
break;
case 4://45~60天
clients = clientSubMerchantIdMapper.listSubMerchantIdByDiffDays(45,60);
break;
default:
break;
}
Map<String, List<JSONObject>> merchantIdMap = clients.stream().filter(t->t.containsKey("merchant_id")).filter(t->t.containsKey("sub_merchant_id")).collect(Collectors.groupingBy(t->t.getString("merchant_id"))); Map<String, List<JSONObject>> merchantIdMap = clients.stream().filter(t->t.containsKey("merchant_id")).filter(t->t.containsKey("sub_merchant_id")).collect(Collectors.groupingBy(t->t.getString("merchant_id")));
JSONObject returnJason = new JSONObject(); JSONObject returnJason = new JSONObject();
returnJason.put("merchant_id_map",merchantIdMap); returnJason.put("merchant_id_map",merchantIdMap);
returnJason.put("refresh_time",clients.size()>0?clients.get(0).getDate("create_time"):""); returnJason.put("refresh_time",clients.size()>0?clients.get(0).getDate("create_time"):"");
return returnJason; return returnJason;
} }
@Override @Override
public void generateClientsSunMerchantId() { public void generateClientsSunMerchantId() {
//重构未交易商户号逻辑
String tempSubMerchantIds = sysConfigManager.getSysConfig().getString("temp_sub_mch_id"); String tempSubMerchantIds = sysConfigManager.getSysConfig().getString("temp_sub_mch_id");
List<JSONObject> clients = clientAnalysisMapper.notTradeSubMerchantId(); List<JSONObject> clients = clientAnalysisMapper.tradeSubMerchantIdBy60Days(DateUtils.addDays(new Date(), -60));
List<JSONObject> clientSubMerchantId = clientSubMerchantIdMapper.listSubMerchantId(new PageBounds(Order.formString("create_time.desc"))); if (clients.size() > 0) {
Map<String, JSONObject> subMerchantIdMapFromDB = new HashMap<>(); clientSubMerchantIdMapper.deleteAll();
for (JSONObject id : clientSubMerchantId) {
subMerchantIdMapFromDB.put(id.getString("sub_merchant_id"), id);
} }
for (JSONObject client: clients) { for (JSONObject client: clients) {
String subMerchantId = client.getString("sub_merchant_id"); String subMerchantId = client.getString("sub_merchant_id");
@ -90,15 +108,7 @@ public class MerchantIdManageServiceImpl implements MerchantIdManageService {
} }
String id = client.getString("sub_merchant_id"); String id = client.getString("sub_merchant_id");
client.put("create_time",new Date()); client.put("create_time",new Date());
if (subMerchantIdMapFromDB.containsKey(id)) { clientSubMerchantIdMapper.save(client);
subMerchantIdMapFromDB.remove(id);
clientSubMerchantIdMapper.update(client);
} else {
clientSubMerchantIdMapper.save(client);
}
}
for (String id : subMerchantIdMapFromDB.keySet()) {
clientSubMerchantIdMapper.delete(id);
} }
} }

@ -38,8 +38,8 @@ public class MerchantIdManageController {
@RequestMapping(method = RequestMethod.GET,value = "/trade") @RequestMapping(method = RequestMethod.GET,value = "/trade")
@RequireManager(role = {ManagerRole.OPERATOR}) @RequireManager(role = {ManagerRole.OPERATOR})
public JSONObject listNotTradeSubMerchantId(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { public JSONObject listNotTradeSubMerchantId(int type,@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
return merchantIdManageService.listNotTradeSubMerchantId(manager); return merchantIdManageService.listNotTradeSubMerchantId(type, manager);
} }
@RequestMapping(method = RequestMethod.POST,value = "/refresh") @RequestMapping(method = RequestMethod.POST,value = "/refresh")

@ -18,15 +18,23 @@ public class NewAccountBean {
private String displayName; private String displayName;
@JSONField(name = "contact_phone") @JSONField(name = "contact_phone")
private String contactPhone; private String contactPhone;
@JSONField(name = "contact_email")
private String contactEmail;
@JSONField(name = "nation_code") @JSONField(name = "nation_code")
private String nation_code = "+61"; private String nation_code = "+61";
private int role = PartnerRole.CASHIER.getCode(); private int role = PartnerRole.CASHIER.getCode();
@JSONField(name = "client_id")
private int clientId;
public JSONObject toJson() { public JSONObject toJson() {
JSONObject account = new JSONObject(); JSONObject account = new JSONObject();
account.put("display_name", displayName); account.put("display_name", displayName);
account.put("username", getUsername()); account.put("username", getUsername());
account.put("role", role); account.put("role", role);
account.put("nation_code", nation_code.startsWith("+")?nation_code:"+"+nation_code);
if (contactEmail != null){
account.put("contact_email", contactEmail);
}
if (contactPhone != null){ if (contactPhone != null){
account.put("contact_phone", contactPhone); account.put("contact_phone", contactPhone);
} }
@ -80,4 +88,20 @@ public class NewAccountBean {
public void setNation_code(String nation_code) { public void setNation_code(String nation_code) {
this.nation_code = nation_code; this.nation_code = nation_code;
} }
public String getContactEmail() {
return contactEmail;
}
public void setContactEmail(String contactEmail) {
this.contactEmail = contactEmail;
}
public int getClientId() {
return clientId;
}
public void setClientId(int clientId) {
this.clientId = clientId;
}
} }

@ -3,33 +3,23 @@ package au.com.royalpay.payment.manage.merchants.core;
import au.com.royalpay.payment.core.exceptions.EmailException; import au.com.royalpay.payment.core.exceptions.EmailException;
import au.com.royalpay.payment.manage.appclient.beans.AppClientBean; import au.com.royalpay.payment.manage.appclient.beans.AppClientBean;
import au.com.royalpay.payment.manage.appclient.beans.AppMerchantBean; import au.com.royalpay.payment.manage.appclient.beans.AppMerchantBean;
import au.com.royalpay.payment.manage.merchants.beans.BankAccountInfo; import au.com.royalpay.payment.manage.merchants.beans.*;
import au.com.royalpay.payment.manage.merchants.beans.ClientAuthFilesInfo;
import au.com.royalpay.payment.manage.merchants.beans.ClientRateConfig;
import au.com.royalpay.payment.manage.merchants.beans.ClientRegisterInfo;
import au.com.royalpay.payment.manage.merchants.beans.NewAccountBean;
import au.com.royalpay.payment.manage.merchants.beans.PartnerQuery;
import au.com.royalpay.payment.manage.merchants.beans.SubMerchantIdApply;
import au.com.royalpay.payment.manage.tradelog.beans.TradeLogQuery; import au.com.royalpay.payment.manage.tradelog.beans.TradeLogQuery;
import au.com.royalpay.payment.tools.merchants.beans.QRCodeConfig; import au.com.royalpay.payment.tools.merchants.beans.QRCodeConfig;
import au.com.royalpay.payment.tools.merchants.beans.UpdateSurchargeDTO; import au.com.royalpay.payment.tools.merchants.beans.UpdateSurchargeDTO;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.apache.ibatis.annotations.Param;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.Model; import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletResponse;
/** /**
* Created by yixian on 2016-06-25. * Created by yixian on 2016-06-25.
*/ */
@ -173,10 +163,8 @@ public interface ClientManager {
List<JSONObject> listSubClients(JSONObject manager, String clientMoniker); List<JSONObject> listSubClients(JSONObject manager, String clientMoniker);
List<JSONObject> listSubClients(int clientId); List<JSONObject> listSubClients(int clientId);
// void newSubClient(String clientMoniker, SubClientRegistry registry, JSONObject manager); // void newSubClient(String clientMoniker, SubClientRegistry registry, JSONObject manager);
void validateClients(int client_id, JSONObject params) throws Exception; void validateClients(int client_id, JSONObject params) throws Exception;
@ -287,7 +275,9 @@ public interface ClientManager {
List<JSONObject> getAccountTransactions(JSONObject account,String clientMoniker); List<JSONObject> getAccountTransactions(JSONObject account,String clientMoniker);
List<JSONObject> getAccountTransactionsByDate(JSONObject account,String clientMoniker, String date); List<JSONObject> getAccountDetailByMonths(JSONObject account,String clientMoniker);
List<JSONObject> getAccountTransactionsByDetailId(JSONObject account,String clientMoniker, String detailId);
List<JSONObject> getAccountMonthDetails(JSONObject account,String clientMoniker); List<JSONObject> getAccountMonthDetails(JSONObject account,String clientMoniker);
@ -339,6 +329,10 @@ public interface ClientManager {
String queryAlipayGmsStatus(String clientMoniker, JSONObject manager); String queryAlipayGmsStatus(String clientMoniker, JSONObject manager);
JSONObject queryAlipayGmsJson(String clientMoniker, JSONObject manager);
JSONObject queryAlipayOnlineGmsJson(String clientMoniker, JSONObject manager);
String queryAlipayOnlineGmsStatus(String clientMoniker, JSONObject manager); String queryAlipayOnlineGmsStatus(String clientMoniker, JSONObject manager);
List<JSONObject> listMerchantIds(String clientMoniker,JSONObject manager); List<JSONObject> listMerchantIds(String clientMoniker,JSONObject manager);
@ -414,4 +408,20 @@ public interface ClientManager {
void partnerCBChannelConfig(String clientMoniker, String channelKey, String channel_id); void partnerCBChannelConfig(String clientMoniker, String channelKey, String channel_id);
void addDevice(JSONObject manager, String clientMoniker, JSONObject device); void addDevice(JSONObject manager, String clientMoniker, JSONObject device);
/**
* 退
*/
void verifyRefundPassword(JSONObject account, JSONObject json);
/**
* 退
*/
void resetRefundPassword(JSONObject account, JSONObject json);
void resetRefundPasswordByManage(String clientMoniker,JSONObject manage, JSONObject json);
List<Integer> listLevel3Client(int client_id);
void updateRefundCreditLine(JSONObject manager, String clientMoniker, JSONObject refundLineInfo);
} }

@ -16,7 +16,6 @@ import au.com.royalpay.payment.channels.yeepay.runtime.YeePayClient;
import au.com.royalpay.payment.core.PaymentChannelApi; import au.com.royalpay.payment.core.PaymentChannelApi;
import au.com.royalpay.payment.core.exceptions.EmailException; import au.com.royalpay.payment.core.exceptions.EmailException;
import au.com.royalpay.payment.core.exceptions.InvalidShortIdException; import au.com.royalpay.payment.core.exceptions.InvalidShortIdException;
import au.com.royalpay.payment.core.exceptions.ParamInvalidException;
import au.com.royalpay.payment.core.utils.OrderExpiryRuleResolver; import au.com.royalpay.payment.core.utils.OrderExpiryRuleResolver;
import au.com.royalpay.payment.manage.analysis.mappers.TransactionAnalysisMapper; import au.com.royalpay.payment.manage.analysis.mappers.TransactionAnalysisMapper;
import au.com.royalpay.payment.manage.appclient.beans.AppClientBean; import au.com.royalpay.payment.manage.appclient.beans.AppClientBean;
@ -25,30 +24,16 @@ import au.com.royalpay.payment.manage.application.core.SimpleClientApplyService;
import au.com.royalpay.payment.manage.device.core.DeviceManager; import au.com.royalpay.payment.manage.device.core.DeviceManager;
import au.com.royalpay.payment.manage.management.sysconfig.core.impls.PermissionPartnerManagerImpl; import au.com.royalpay.payment.manage.management.sysconfig.core.impls.PermissionPartnerManagerImpl;
import au.com.royalpay.payment.manage.mappers.financial.FinancialBDConfigMapper; import au.com.royalpay.payment.manage.mappers.financial.FinancialBDConfigMapper;
import au.com.royalpay.payment.manage.mappers.log.ClearingDetailMapper; import au.com.royalpay.payment.manage.mappers.log.*;
import au.com.royalpay.payment.manage.mappers.log.ClearingLogMapper;
import au.com.royalpay.payment.manage.mappers.log.ClientsOperationLogMapper;
import au.com.royalpay.payment.manage.mappers.log.LogClientSubMerchantIdMapper;
import au.com.royalpay.payment.manage.mappers.log.LogSettleMailMapper;
import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper; import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper;
import au.com.royalpay.payment.manage.mappers.redpack.ActClientInvitationCodeMapper; import au.com.royalpay.payment.manage.mappers.redpack.ActClientInvitationCodeMapper;
import au.com.royalpay.payment.manage.mappers.risk.RiskAttentionMerchantsMapper; import au.com.royalpay.payment.manage.mappers.risk.RiskAttentionMerchantsMapper;
import au.com.royalpay.payment.manage.mappers.system.*; import au.com.royalpay.payment.manage.mappers.system.*;
import au.com.royalpay.payment.manage.merchants.beans.ActivityPosterBuilder; import au.com.royalpay.payment.manage.merchants.beans.*;
import au.com.royalpay.payment.manage.merchants.beans.BankAccountInfo; import au.com.royalpay.payment.manage.merchants.core.*;
import au.com.royalpay.payment.manage.merchants.beans.ClientAuthFilesInfo;
import au.com.royalpay.payment.manage.merchants.beans.ClientRateConfig;
import au.com.royalpay.payment.manage.merchants.beans.ClientRegisterInfo;
import au.com.royalpay.payment.manage.merchants.beans.NewAccountBean;
import au.com.royalpay.payment.manage.merchants.beans.PartnerQuery;
import au.com.royalpay.payment.manage.merchants.beans.SubMerchantIdApply;
import au.com.royalpay.payment.manage.merchants.core.ClientComplyValidator;
import au.com.royalpay.payment.manage.merchants.core.ClientConfigService;
import au.com.royalpay.payment.manage.merchants.core.ClientInfoCacheSupport;
import au.com.royalpay.payment.manage.merchants.core.ClientManager;
import au.com.royalpay.payment.manage.merchants.core.ClientModifySupport;
import au.com.royalpay.payment.manage.merchants.entity.impls.*; import au.com.royalpay.payment.manage.merchants.entity.impls.*;
import au.com.royalpay.payment.manage.notice.core.MailService; import au.com.royalpay.payment.manage.notice.core.MailService;
import au.com.royalpay.payment.manage.permission.utils.OrgCheckUtils;
import au.com.royalpay.payment.manage.signin.beans.TodoNotice; import au.com.royalpay.payment.manage.signin.beans.TodoNotice;
import au.com.royalpay.payment.manage.signin.core.ManagerTodoNoticeProvider; import au.com.royalpay.payment.manage.signin.core.ManagerTodoNoticeProvider;
import au.com.royalpay.payment.manage.signin.core.SignInAccountService; import au.com.royalpay.payment.manage.signin.core.SignInAccountService;
@ -72,7 +57,6 @@ import au.com.royalpay.payment.tools.inspiry.core.InspiryPOSFinder;
import au.com.royalpay.payment.tools.locale.LocaleSupport; import au.com.royalpay.payment.tools.locale.LocaleSupport;
import au.com.royalpay.payment.tools.lock.Locker; import au.com.royalpay.payment.tools.lock.Locker;
import au.com.royalpay.payment.tools.mail.SendMail; import au.com.royalpay.payment.tools.mail.SendMail;
import org.apache.commons.codec.binary.Base64;
import au.com.royalpay.payment.tools.merchants.beans.QRCodeConfig; import au.com.royalpay.payment.tools.merchants.beans.QRCodeConfig;
import au.com.royalpay.payment.tools.merchants.beans.UpdateSurchargeDTO; import au.com.royalpay.payment.tools.merchants.beans.UpdateSurchargeDTO;
import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider; import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider;
@ -80,31 +64,24 @@ import au.com.royalpay.payment.tools.merchants.qrboard.QRBoard;
import au.com.royalpay.payment.tools.merchants.qrboard.QRBoardProvider; import au.com.royalpay.payment.tools.merchants.qrboard.QRBoardProvider;
import au.com.royalpay.payment.tools.permission.enums.ManagerRole; import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
import au.com.royalpay.payment.tools.permission.enums.PartnerRole; import au.com.royalpay.payment.tools.permission.enums.PartnerRole;
import au.com.royalpay.payment.tools.utils.ImageUtils; import au.com.royalpay.payment.tools.utils.*;
import au.com.royalpay.payment.tools.utils.PageListUtils;
import au.com.royalpay.payment.tools.utils.PasswordUtils;
import au.com.royalpay.payment.tools.utils.PdfUtils;
import au.com.royalpay.payment.tools.utils.QRCodeUtils;
import au.com.royalpay.payment.tools.utils.TimeZoneUtils;
import au.com.royalpay.payment.tools.websocket.notify.PartnerPageEvent; import au.com.royalpay.payment.tools.websocket.notify.PartnerPageEvent;
import cn.yixblog.platform.http.HttpRequestGenerator;
import cn.yixblog.platform.http.HttpRequestResult;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.Order; import com.github.miemiedev.mybatis.paginator.domain.Order;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds; import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList; import com.github.miemiedev.mybatis.paginator.domain.PageList;
import com.yeepay.yop.sdk.service.kj.model.SubmerchantRegisterResult; import com.yeepay.yop.sdk.service.kj.model.SubmerchantRegisterResult;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.RandomUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.lang3.time.DateUtils;
import org.apache.el.parser.AstNot;
import org.apache.http.client.utils.URLEncodedUtils;
import org.dom4j.Element; import org.dom4j.Element;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -124,6 +101,13 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.thymeleaf.context.Context; import org.thymeleaf.context.Context;
import org.thymeleaf.spring4.SpringTemplateEngine; import org.thymeleaf.spring4.SpringTemplateEngine;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import javax.crypto.*;
import javax.crypto.spec.SecretKeySpec;
import javax.imageio.ImageIO;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.awt.*; import java.awt.*;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.*; import java.io.*;
@ -131,34 +115,18 @@ import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.net.URL; import java.net.URL;
import java.net.URLEncoder; import java.nio.charset.StandardCharsets;
import java.security.InvalidKeyException; import java.security.InvalidKeyException;
import java.security.InvalidParameterException; import java.security.InvalidParameterException;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom; import java.security.SecureRandom;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.List; import java.util.List;
import java.util.*;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream; import java.util.zip.ZipOutputStream;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import javax.crypto.*;
import javax.crypto.spec.DESKeySpec;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import javax.imageio.ImageIO;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import cn.yixblog.platform.http.HttpRequestGenerator;
import cn.yixblog.platform.http.HttpRequestResult;
import sun.misc.BASE64Encoder;
import static au.com.royalpay.payment.manage.permission.utils.OrgCheckUtils.checkOrgPermission; import static au.com.royalpay.payment.manage.permission.utils.OrgCheckUtils.checkOrgPermission;
/** /**
@ -388,7 +356,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
client.put("contact_email", "******"); client.put("contact_email", "******");
} }
} else { } else {
client.put("rate_editable",ManagerRole.OPERATOR.hasRole(role)); client.put("rate_editable", ManagerRole.OPERATOR.hasRole(role));
} }
} }
List<JSONObject> children = clientMapper.listChildClients(client.getIntValue("client_id")); List<JSONObject> children = clientMapper.listChildClients(client.getIntValue("client_id"));
@ -884,14 +852,14 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
throw new InvalidShortIdException(); throw new InvalidShortIdException();
} }
checkOrgPermission(manager, client); checkOrgPermission(manager, client);
if(client.getString("yeepay_sub_merchant_id").equals(yeepaySubMerchantInfo.getString("yeepay_sub_merchant_id"))){ if (client.getString("yeepay_sub_merchant_id").equals(yeepaySubMerchantInfo.getString("yeepay_sub_merchant_id"))) {
throw new BadRequestException("The sub merchant Id is in use"); throw new BadRequestException("The sub merchant Id is in use");
} }
JSONObject yeepayConfigValid =yeePayClientConfigMapper.findMerchantConfig(client.getIntValue("client_id")); JSONObject yeepayConfigValid = yeePayClientConfigMapper.findMerchantConfig(client.getIntValue("client_id"));
yeePayClientConfigMapper.updateSubMerchantIdValid(yeepayConfigValid.getString("yeepay_config_id"),0); yeePayClientConfigMapper.updateSubMerchantIdValid(yeepayConfigValid.getString("yeepay_config_id"), 0);
JSONObject yeepayConfig = yeePayClientConfigMapper.findMerchantConfigBySub(client.getIntValue("client_id"), yeepaySubMerchantInfo.getString("yeepay_sub_merchant_id")); JSONObject yeepayConfig = yeePayClientConfigMapper.findMerchantConfigBySub(client.getIntValue("client_id"), yeepaySubMerchantInfo.getString("yeepay_sub_merchant_id"));
yeePayClientConfigMapper.updateSubMerchantIdValid(yeepayConfig.getString("yeepay_config_id"),1); yeePayClientConfigMapper.updateSubMerchantIdValid(yeepayConfig.getString("yeepay_config_id"), 1);
client.put("yeepay_sub_merchant_id",yeepaySubMerchantInfo.getString("yeepay_sub_merchant_id")); client.put("yeepay_sub_merchant_id", yeepaySubMerchantInfo.getString("yeepay_sub_merchant_id"));
clientMapper.update(client); clientMapper.update(client);
} }
@ -1156,14 +1124,13 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
* email = bd.getString("email"); if (StringUtils.isNotEmpty(email)) { emails.add(email); } } new Thread() { * email = bd.getString("email"); if (StringUtils.isNotEmpty(email)) { emails.add(email); } } new Thread() {
* *
* @Override public void run() { try { SendMail sendMail = new SendMail(); Set<String> to = new HashSet<>(); * @Override public void run() { try { SendMail sendMail = new SendMail(); Set<String> to = new HashSet<>();
* to.add(mailTo); sendMail.setFrom("info@mail.royalpay.com.au"); sendMail.setMailTos(to); * to.add(mailTo); sendMail.setFrom("info@mail.royalpay.com.au"); sendMail.setMailTos(to);
* sendMail.setMailCcs(emails); sendMail.setTitle("Your RoyalPay Cross-border Payment has been set up"); * sendMail.setMailCcs(emails); sendMail.setTitle("Your RoyalPay Cross-border Payment has been set up");
* sendMail.setContent(content); sendMail.setTags(tags); JSONObject mailResult = * sendMail.setContent(content); sendMail.setTags(tags); JSONObject mailResult =
* mailGunService.sendMail(sendMail); clientModifySupport.processClientModify(new EmailModify(account, * mailGunService.sendMail(sendMail); clientModifySupport.processClientModify(new EmailModify(account,
* client.getString("client_moniker"), 3, mailResult.getString("mail_id"))); } catch (Exception e) { * client.getString("client_moniker"), 3, mailResult.getString("mail_id"))); } catch (Exception e) {
* clientModifySupport.processClientModify(new EmailModify(account, client.getString("client_moniker"), 0, * clientModifySupport.processClientModify(new EmailModify(account, client.getString("client_moniker"), 0,
* null)); throw new EmailException("Email Sending Failed", e); } } }.start(); } * null)); throw new EmailException("Email Sending Failed", e); } } }.start(); }
*
*/ */
public void sendAuthInitEmail(JSONObject account, final JSONObject client) { public void sendAuthInitEmail(JSONObject account, final JSONObject client) {
@ -1351,7 +1318,11 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
throw new InvalidShortIdException(); throw new InvalidShortIdException();
} }
checkOrgPermission(manager, client); checkOrgPermission(manager, client);
if (!client.containsKey("parent_client_id") && client.getBoolean("sub_manage")) {
return clientAccountMapper.partnerAndSubPartnerAccounts(client.getIntValue("client_id"));
}
return clientAccountMapper.listPartnerAccounts(client.getIntValue("client_id")); return clientAccountMapper.listPartnerAccounts(client.getIntValue("client_id"));
} }
@Override @Override
@ -1370,7 +1341,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
accountJson.put("salt", salt); accountJson.put("salt", salt);
accountJson.put("password_hash", PasswordUtils.hashPwd(account.getPwd(), salt)); accountJson.put("password_hash", PasswordUtils.hashPwd(account.getPwd(), salt));
accountJson.put("password_aes", PasswordUtils.encryptAESPwd(account.getPwd())); accountJson.put("password_aes", PasswordUtils.encryptAESPwd(account.getPwd()));
accountJson.put("client_id", client.getIntValue("client_id")); accountJson.put("client_id", account.getClientId() == 0 ? client.getIntValue("client_id") : account.getClientId());
accountJson.put("creator", managerType == 1 ? manager.getString("manager_id") : manager.getString("account_id")); accountJson.put("creator", managerType == 1 ? manager.getString("manager_id") : manager.getString("account_id"));
accountJson.put("creator_type", managerType); accountJson.put("creator_type", managerType);
accountJson.put("create_time", new Date()); accountJson.put("create_time", new Date());
@ -1401,8 +1372,15 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
if (clientMoniker != null) { if (clientMoniker != null) {
JSONObject client = getClientInfoByMoniker(clientMoniker); JSONObject client = getClientInfoByMoniker(clientMoniker);
Assert.notNull(client); Assert.notNull(client);
//父商户全局管理子商户时候,跳过
if (account.getIntValue("client_id") != client.getIntValue("client_id")) { if (account.getIntValue("client_id") != client.getIntValue("client_id")) {
throw new BadRequestException("error.partner.valid.account_not_match"); //登录用户所属商户
JSONObject clientLogin = getClientInfo(account.getIntValue("client_id"));
Boolean validChildClients = clientLogin.containsKey("parent_client_id") ? clientLogin.getIntValue("parent_client_id") == client.getIntValue("client_id") : false;
Boolean validLevel3Clients = listLevel3Client(client.getIntValue("client_id")).contains(clientLogin.getIntValue("parent_client_id"));
if (!(client.getBoolean("sub_manage") && (validChildClients || validLevel3Clients))) {
throw new BadRequestException("error.partner.valid.account_not_match");
}
} }
checkOrgPermission(manager, client); checkOrgPermission(manager, client);
} }
@ -1795,7 +1773,18 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
throw new InvalidShortIdException(); throw new InvalidShortIdException();
} }
checkOrgPermission(manager, client); checkOrgPermission(manager, client);
return clientMapper.listChildClients(client.getIntValue("client_id")); JSONObject listSubClients = new JSONObject();
List<JSONObject> listChildClients = clientMapper.listChildClients(client.getIntValue("client_id"));
for (JSONObject partner : listChildClients) {
List<JSONObject> clients = clientMapper.listChildClients(partner.getIntValue("client_id"));
if (clients.size() > 0) {
partner.put("level3Clients", clients);
clients.forEach(e->{
e.put("parent_client_moniker", partner.getString("client_moniker"));
});
}
}
return listChildClients;
} }
@Override @Override
@ -1874,7 +1863,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
for (String currentClientId : client_ids) { for (String currentClientId : client_ids) {
JSONObject clientInfo = getClientInfo(Integer.parseInt(currentClientId)); JSONObject clientInfo = getClientInfo(Integer.parseInt(currentClientId));
if (clientInfo.containsKey("parent_client_id")) { if (clientInfo.containsKey("parent_client_id")) {
if (clientInfo.getIntValue("parent_client_id") != client_id) { int parentClientId = clientInfo.getIntValue("parent_client_id");
if (parentClientId != client_id && client_id!= Integer.parseInt(currentClientId) && !listLevel3Client(client_id).contains(parentClientId)) {
throw new Exception("partner has no permission"); throw new Exception("partner has no permission");
} }
} }
@ -1883,6 +1873,27 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
} }
} }
@Override
public List<Integer> listLevel3Client(int clientId) {
return clientMapper.childClientId(clientId);
}
@Override
public void updateRefundCreditLine(JSONObject manager, String clientMoniker, JSONObject refundLineInfo) {
JSONObject client = getClientInfoByMoniker(clientMoniker);
if (client == null) {
throw new InvalidShortIdException();
}
OrgCheckUtils.checkOrgPermission(manager, client);
JSONObject update = new JSONObject();
int clientId = client.getIntValue("client_id");
BigDecimal refundCreditLine = refundLineInfo.getBigDecimal("refund_credit_line");
update.put("client_id", clientId);
update.put("refund_credit_line", refundCreditLine);
clientMapper.update(update);
clientInfoCacheSupport.clearClientCache(clientId);
}
@Override @Override
@Transactional @Transactional
public void updateClientBDUsers(JSONObject manager, String clientMoniker, JSONObject data) throws Exception { public void updateClientBDUsers(JSONObject manager, String clientMoniker, JSONObject data) throws Exception {
@ -2200,6 +2211,57 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
clientDeviceMapper.save(newDevice); clientDeviceMapper.save(newDevice);
} }
@Override
public void verifyRefundPassword(JSONObject account, JSONObject json) {
JSONObject clientConfig = clientConfigMapper.find(account.getIntValue("client_id"));
String needVerifyPassword = json.getString("refund_password");
String refundPwdSalt = clientConfig.getString("refund_pwd_salt");
if (!StringUtils.equals(clientConfig.getString("refund_pwd"), PasswordUtils.hashPwd(needVerifyPassword, refundPwdSalt))) {
throw new BadRequestException("Incorrect refund password");
}
}
@Override
public void resetRefundPassword(JSONObject account, JSONObject json) {
if (PartnerRole.getRole(account.getIntValue("role")) != PartnerRole.ADMIN) {
throw new BadRequestException("You have no permission");
}
verifyRefundPassword(account, json);
String newSalt = PasswordUtils.newSalt();
String newPassWord = json.getString("new_refund_password");
if (!StringUtils.isNumeric(newPassWord)) {
throw new BadRequestException("Refund password must be pure number");
}
String newPwdHash = PasswordUtils.hashPwd(newPassWord, newSalt);
if (StringUtils.equals(newPwdHash, PasswordUtils.hashPwd(json.getString("refund_password"), newSalt))) {
throw new BadRequestException("Old and new passwords cannot be duplicated");
}
JSONObject update = new JSONObject();
update.put("client_id", account.getIntValue("client_id"));
update.put("refund_pwd", newPwdHash);
update.put("refund_pwd_salt", newSalt);
clientConfigMapper.update(update);
}
@Override
public void resetRefundPasswordByManage(String clientMoniker, JSONObject manage, JSONObject json) {
JSONObject client = getClientInfoByMoniker(clientMoniker);
if (client == null) {
throw new InvalidShortIdException();
}
JSONObject update = new JSONObject();
update.put("client_id", client.getIntValue("client_id"));
String newPassWord = json.getString("new_refund_password");
if (!StringUtils.isNumeric(newPassWord)) {
throw new BadRequestException("Refund password must be pure number");
}
String newSalt = PasswordUtils.newSalt();
String newPwdHash = PasswordUtils.hashPwd(newPassWord, newSalt);
update.put("refund_pwd", newPwdHash);
update.put("refund_pwd_salt", newSalt);
clientConfigMapper.update(update);
}
@Override @Override
public void updateDevie(JSONObject manager, String clientMoniker, String devId, String remark) { public void updateDevie(JSONObject manager, String clientMoniker, String devId, String remark) {
JSONObject client = getClientInfoByMoniker(clientMoniker); JSONObject client = getClientInfoByMoniker(clientMoniker);
@ -3359,7 +3421,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
@Override @Override
@Transactional @Transactional
public void setSkipClearing(JSONObject account, String clientMoniker, Boolean skip_clearing,String remark) { public void setSkipClearing(JSONObject account, String clientMoniker, Boolean skip_clearing, String remark) {
JSONObject client = getClientInfoByMoniker(clientMoniker); JSONObject client = getClientInfoByMoniker(clientMoniker);
if (client == null) { if (client == null) {
throw new InvalidShortIdException(); throw new InvalidShortIdException();
@ -3367,7 +3429,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
clientModifySupport.processClientConfigModify(new SwitchPermissionModify(account, clientMoniker, "skip_clearing", skip_clearing)); clientModifySupport.processClientConfigModify(new SwitchPermissionModify(account, clientMoniker, "skip_clearing", skip_clearing));
if (!skip_clearing) { if (!skip_clearing) {
if ("".equals(remark) || remark==null){ if ("".equals(remark) || remark == null) {
throw new ServerErrorException("请填写关闭清算原因"); throw new ServerErrorException("请填写关闭清算原因");
} }
JSONObject clientConfig = clientConfigMapper.find(client.getIntValue("client_id")); JSONObject clientConfig = clientConfigMapper.find(client.getIntValue("client_id"));
@ -3431,8 +3493,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
throw new InvalidShortIdException(); throw new InvalidShortIdException();
} }
List<JSONObject> transactions = clearingDistributedSurchargeMapper.findTransactions(client.getIntValue("client_id")); List<JSONObject> transactions = clearingDistributedSurchargeMapper.findTransactions(client.getIntValue("client_id"));
transactions.forEach(e->{ transactions.forEach(e -> {
if ("Credit".equals(e.getString("type"))) { if ("Credit".equals(e.getString("type")) && !"settle revoke".equals(e.getString("remark"))) {
JSONObject manager = managerMapper.findDetail(e.getString("operation")); JSONObject manager = managerMapper.findDetail(e.getString("operation"));
e.put("operator_displayname", manager.getString("display_name")); e.put("operator_displayname", manager.getString("display_name"));
} }
@ -3441,25 +3503,21 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
} }
@Override @Override
public List<JSONObject> getAccountTransactionsByDate(JSONObject account, String clientMoniker, String date) { public List<JSONObject> getAccountDetailByMonths(JSONObject account, String clientMoniker) {
JSONObject client = getClientInfoByMoniker(clientMoniker); JSONObject client = getClientInfoByMoniker(clientMoniker);
if (client == null) { if (client == null) {
throw new InvalidShortIdException(); throw new InvalidShortIdException();
} }
return financialSurchargeAccountDetailMapper.listSettlementDatesByClientId(client.getIntValue("client_id"));
}
JSONObject params = new JSONObject(); @Override
params.put("client_id", client.getIntValue("client_id")); public List<JSONObject> getAccountTransactionsByDetailId(JSONObject account, String clientMoniker, String detailId) {
params.put("year", date.substring(0, 4)); JSONObject client = getClientInfoByMoniker(clientMoniker);
params.put("month", date.substring(date.length()-2, date.length())); if (client == null) {
throw new InvalidShortIdException();
List<JSONObject> transactions = clearingDistributedSurchargeMapper.findTransactionsByDate(params); }
transactions.forEach(e->{ return clearingDistributedSurchargeMapper.findSurchargeTransactionsByDetailId(client.getIntValue("client_id"),detailId);
if ("Credit".equals(e.getString("type"))) {
JSONObject manager = managerMapper.findDetail(e.getString("operation"));
e.put("operator_displayname", manager.getString("display_name"));
}
});
return transactions;
} }
@Override @Override
@ -3468,8 +3526,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
if (client == null) { if (client == null) {
throw new InvalidShortIdException(); throw new InvalidShortIdException();
} }
List<JSONObject> details = financialSurchargeAccountDetailMapper.findDetailsByClientId(client.getIntValue("client_id")); return financialSurchargeAccountDetailMapper.findDetailsByClientId(client.getIntValue("client_id"));
return details;
} }
@Override @Override
@ -3487,19 +3544,19 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
throw new ServerErrorException("Processing task, wait for a moment"); throw new ServerErrorException("Processing task, wait for a moment");
} }
try { try {
JSONObject surcharge_account = clientsSurchargeAccountsMapper.find(client.getIntValue("client_id")); JSONObject surchargeAccount = clientsSurchargeAccountsMapper.find(client.getIntValue("client_id"));
transaction.put("client_id", client.getIntValue("client_id")); transaction.put("client_id", client.getIntValue("client_id"));
transaction.put("type", "Credit"); transaction.put("type", "Credit");
transaction.put("total_surcharge", BigDecimal.ZERO); transaction.put("total_surcharge", BigDecimal.ZERO);
transaction.put("tax_amount", BigDecimal.ZERO); transaction.put("tax_amount", BigDecimal.ZERO);
transaction.put("post_balance", surcharge_account.getBigDecimal("balance").add(transaction.getBigDecimal("amount"))); transaction.put("post_balance", surchargeAccount.getBigDecimal("balance").add(transaction.getBigDecimal("amount")));
transaction.put("operation", account.getString("manager_id")); transaction.put("operation", account.getString("manager_id"));
transaction.put("create_time", new Date()); transaction.put("create_time", new Date());
clearingDistributedSurchargeMapper.save(transaction); clearingDistributedSurchargeMapper.save(transaction);
surcharge_account.put("balance", surcharge_account.getBigDecimal("balance").add(transaction.getBigDecimal("amount"))); surchargeAccount.put("balance", surchargeAccount.getBigDecimal("balance").add(transaction.getBigDecimal("amount")));
clientsSurchargeAccountsMapper.update(surcharge_account); clientsSurchargeAccountsMapper.update(surchargeAccount);
} finally { } finally {
locker.unlock(clientMoniker + "_surcharge_account_save"); locker.unlock(clientMoniker + "_surcharge_account_save");
@ -3672,8 +3729,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
} }
} }
private TemplateMessage initSendToComplianceGreenChannelTemplate(String loginUrl, String wxopenid, String templateId2, String bd_user_name, private TemplateMessage initSendToComplianceGreenChannelTemplate(String loginUrl, String wxopenid, String templateId2, String bd_user_name, JSONObject client) {
JSONObject client) {
TemplateMessage msg = new TemplateMessage(wxopenid, templateId2, loginUrl); TemplateMessage msg = new TemplateMessage(wxopenid, templateId2, loginUrl);
msg.put("first", bd_user_name + " 提交了新商户绿色通道申请,请审核", "#ff0000"); msg.put("first", bd_user_name + " 提交了新商户绿色通道申请,请审核", "#ff0000");
msg.put("keyword1", client.getString("client_moniker") + "申请绿色通道", "#0000ff"); msg.put("keyword1", client.getString("client_moniker") + "申请绿色通道", "#0000ff");
@ -3938,6 +3994,14 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
} }
client.put("bank_id", client_bank.getString("account_no")); client.put("bank_id", client_bank.getString("account_no"));
if (StringUtils.isBlank(client.getString("business_structure"))) {
throw new BadRequestException("Business Structure can't be null");
}
if (StringUtils.isBlank(client.getString("alipayindustry"))) {
throw new BadRequestException("Alipay Industry can't be null");
}
if (!"Company".equals(client.getString("business_structure"))) { if (!"Company".equals(client.getString("business_structure"))) {
if (StringUtils.isBlank(representative_id.getString("representative_id"))) { if (StringUtils.isBlank(representative_id.getString("representative_id"))) {
throw new BadRequestException("ID or passport number can't be null"); throw new BadRequestException("ID or passport number can't be null");
@ -3976,6 +4040,82 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
return "查询成功:" + responseElement.elementText("secondary_merchant_id") + "报备状态 : " + responseElement.elementText("status"); return "查询成功:" + responseElement.elementText("secondary_merchant_id") + "报备状态 : " + responseElement.elementText("status");
} }
@Override
public JSONObject queryAlipayGmsJson(String clientMoniker, JSONObject manager) {
JSONObject client = getClientInfoByMoniker(clientMoniker);
if (client == null) {
throw new InvalidShortIdException();
}
checkOrgPermission(manager, client);
AlipayConfig.AlipayMerchant mch = AlipayEnvironment.getEnv().getAlipayRetailMerchant();
JSONObject queryGMSJson = new JSONObject(new LinkedHashMap());
queryGMSJson.put("service", "alipay.overseas.secmerchant.offline.maintain");
queryGMSJson.put("partner", mch.getPid());
queryGMSJson.put("sign_type", "MD5");
queryGMSJson.put("_input_charset", "utf-8");
queryGMSJson.put("timestamp", DateFormatUtils.format(System.currentTimeMillis(),"yyyy-MM-dd HH:mm:ss"));
queryGMSJson.put("secondary_merchant_name", client.getString("company_name"));
queryGMSJson.put("secondary_merchant_id", client.getString("client_moniker"));
queryGMSJson.put("store_id", client.getString("client_moniker"));
queryGMSJson.put("store_name", client.getString("short_name"));
queryGMSJson.put("store_country", client.getString("country").substring(0,2));
queryGMSJson.put("store_address", client.getString("country") + " "+client.getString("state") + " "+client.getString("suburb") + " "+client.getString("address"));
queryGMSJson.put("store_industry", client.getString("alipayindustry"));
queryGMSJson.put("internal_store_photo", client.getString("company_photo"));
queryGMSJson.put("external_storefront_photo", client.getString("store_photo"));
queryGMSJson.put("register_country", client.getString("country").substring(0,2));
queryGMSJson.put("register_address", client.getString("country") + " "+client.getString("state") + " "+client.getString("suburb") + " "+client.getString("address"));
if ("Company".equals(client.getString("business_structure"))) {
queryGMSJson.put("secondary_merchant_type", "ENTERPRISE");
queryGMSJson.put("registration_no", client.getString("acn"));
}else {
queryGMSJson.put("secondary_merchant_type", "INDIVIDUAL");
queryGMSJson.put("representative_name", client.getString("contact_person"));
}
queryGMSJson.put("contact_no",client.getString("contact_phone"));
queryGMSJson.put("contact_email",client.getString("contact_email"));
return queryGMSJson;
}
@Override
public JSONObject queryAlipayOnlineGmsJson(String clientMoniker, JSONObject manager) {
JSONObject client = getClientInfoByMoniker(clientMoniker);
if (client == null) {
throw new InvalidShortIdException();
}
checkOrgPermission(manager, client);
JSONObject queryGMSJson = new JSONObject(new LinkedHashMap());
AlipayConfig.AlipayMerchant mch = AlipayEnvironment.getEnv().getAlipayOnlineMerchant();
queryGMSJson.put("service", "alipay.overseas.secmerchant.online.maintain");
queryGMSJson.put("partner", mch.getPid());
queryGMSJson.put("sign_type", "MD5");
queryGMSJson.put("_input_charset", "utf-8");
queryGMSJson.put("timestamp", DateFormatUtils.format(System.currentTimeMillis(),"yyyy-MM-dd HH:mm:ss"));
queryGMSJson.put("secondary_merchant_name", client.getString("company_name"));
queryGMSJson.put("secondary_merchant_id", client.getString("client_moniker"));
queryGMSJson.put("secondary_merchant_industry", client.getString("alipayindustry"));
queryGMSJson.put("register_country", client.getString("country").substring(0,2));
queryGMSJson.put("register_address", client.getString("country") + " "+client.getString("state") + " "+client.getString("suburb") + " "+client.getString("address"));
JSONObject website = new JSONObject();
List<JSONObject> websites = new ArrayList<>();
website.put("site_type", "WEB");
website.put("site_url", client.getString("company_website"));
website.put("site_name", client.getString("company_name") + " Website");
websites.add(website);
queryGMSJson.put("site_infos", websites.toString());
if ("Company".equals(client.getString("business_structure"))) {
queryGMSJson.put("secondary_merchant_type", "ENTERPRISE");
queryGMSJson.put("registration_no", client.getString("acn"));
queryGMSJson.put("shareholder_name", client.getString("contact_person"));
}else {
queryGMSJson.put("secondary_merchant_type", "INDIVIDUAL");
queryGMSJson.put("representative_name", client.getString("contact_person"));
}
queryGMSJson.put("contact_no",client.getString("contact_phone"));
queryGMSJson.put("contact_email",client.getString("contact_email"));
return queryGMSJson;
}
@Override @Override
public void registerAlipayOnlineGms(String clientMoniker, JSONObject representative_id, JSONObject manager) { public void registerAlipayOnlineGms(String clientMoniker, JSONObject representative_id, JSONObject manager) {
JSONObject client = getClientInfoByMoniker(clientMoniker); JSONObject client = getClientInfoByMoniker(clientMoniker);
@ -3986,6 +4126,14 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
if (!client.containsKey("company_website")) { if (!client.containsKey("company_website")) {
throw new InvalidParameterException("Website cannot be empty "); throw new InvalidParameterException("Website cannot be empty ");
} }
if (StringUtils.isBlank(client.getString("business_structure"))) {
throw new BadRequestException("Business Structure can't be null");
}
if (StringUtils.isBlank(client.getString("alipayindustry"))) {
throw new BadRequestException("Alipay Industry can't be null");
}
JSONObject client_bank = getBankAccountByClientId(client.getIntValue("client_id")); JSONObject client_bank = getBankAccountByClientId(client.getIntValue("client_id"));
if (client_bank == null || client_bank.size() <= 0) { if (client_bank == null || client_bank.size() <= 0) {
throw new BadRequestException("The Partner's Account is not config!"); throw new BadRequestException("The Partner's Account is not config!");
@ -4029,7 +4177,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
} }
@Override @Override
public void subRpayMerchantApplication(String clientMoniker, JSONObject merchantInfo,JSONObject manager) { public void subRpayMerchantApplication(String clientMoniker, JSONObject merchantInfo, JSONObject manager) {
JSONObject client = getClientInfoByMoniker(clientMoniker); JSONObject client = getClientInfoByMoniker(clientMoniker);
if (client == null) { if (client == null) {
throw new InvalidShortIdException(); throw new InvalidShortIdException();
@ -4038,7 +4186,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
List<JSONObject> listByshortName = sysRpayMerchantApplyMapper.listByShortName(merchantInfo.getString("company_shortname")); List<JSONObject> listByshortName = sysRpayMerchantApplyMapper.listByShortName(merchantInfo.getString("company_shortname"));
if (listByshortName.size()>0) { if (listByshortName.size() > 0) {
throw new BadRequestException("请修改【" + clientMoniker + "】的Company shortName信息Short Name 已被使用)"); throw new BadRequestException("请修改【" + clientMoniker + "】的Company shortName信息Short Name 已被使用)");
} }
if (client.getString("rpay_enterprise_id") != null) { if (client.getString("rpay_enterprise_id") != null) {
@ -4059,7 +4207,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
merchantInfo.put("merchant_shortname", merchantInfo.getString("company_shortname")); merchantInfo.put("merchant_shortname", merchantInfo.getString("company_shortname"));
sysRpayMerchantApplyMapper.insertRpayMerchantApply(merchantInfo); sysRpayMerchantApplyMapper.insertRpayMerchantApply(merchantInfo);
clientMapper.updateRpayEnterpriseId(client.getIntValue("client_id"), rpayMerchantInfo.getString("merchantId")); clientMapper.updateRpayEnterpriseId(client.getIntValue("client_id"), rpayMerchantInfo.getString("merchantId"));
}else { } else {
throw new BadRequestException("请求失败"); throw new BadRequestException("请求失败");
} }
} }
@ -4074,41 +4222,41 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
} }
checkOrgPermission(manager, client); checkOrgPermission(manager, client);
List<JSONObject> yeepayClientConfigs = yeePayClientConfigMapper.findAllMerchantConfig(client.getIntValue("client_id")); List<JSONObject> yeepayClientConfigs = yeePayClientConfigMapper.findAllMerchantConfig(client.getIntValue("client_id"));
if(yeepayClientConfigs!=null){ if (yeepayClientConfigs != null) {
for(JSONObject yeepayClientConfig:yeepayClientConfigs){ for (JSONObject yeepayClientConfig : yeepayClientConfigs) {
if(yeepayClientConfig.getIntValue("is_valid")==1){ if (yeepayClientConfig.getIntValue("is_valid") == 1) {
yeePayClientConfigMapper.updateSubMerchantIdValid(yeepayClientConfig.getString("yeepay_config_id"),0); yeePayClientConfigMapper.updateSubMerchantIdValid(yeepayClientConfig.getString("yeepay_config_id"), 0);
} }
} }
} }
merchantInfo.put("create_time",new Date()); merchantInfo.put("create_time", new Date());
merchantInfo.put("operator",manager.getString("display_name")); merchantInfo.put("operator", manager.getString("display_name"));
merchantInfo.put("client_id",client.getIntValue("client_id")); merchantInfo.put("client_id", client.getIntValue("client_id"));
merchantInfo.put("client_id",merchantInfo.getString("client_id")); merchantInfo.put("client_id", merchantInfo.getString("client_id"));
// merchantInfo.put("vouchers",merchantInfo.getJSONObject("vouchers").toJSONString()); // merchantInfo.put("vouchers",merchantInfo.getJSONObject("vouchers").toJSONString());
List<JSONObject> directorsAll = new ArrayList<>(); List<JSONObject> directorsAll = new ArrayList<>();
List<JSONObject> executivesAll = new ArrayList<>(); List<JSONObject> executivesAll = new ArrayList<>();
directorsAll.add(merchantInfo.getJSONObject("directors")); directorsAll.add(merchantInfo.getJSONObject("directors"));
executivesAll.add(merchantInfo.getJSONObject("executives")); executivesAll.add(merchantInfo.getJSONObject("executives"));
JSONObject extInfo = new JSONObject(); JSONObject extInfo = new JSONObject();
extInfo.put("directors",directorsAll); extInfo.put("directors", directorsAll);
extInfo.put("executives",executivesAll); extInfo.put("executives", executivesAll);
merchantInfo.put("extinfo",extInfo.toJSONString()); merchantInfo.put("extinfo", extInfo.toJSONString());
yeePayClientConfigMapper.saveMerchantConfig(merchantInfo); yeePayClientConfigMapper.saveMerchantConfig(merchantInfo);
JSONObject yeepayConfig = yeePayClientConfigMapper.findMerchantConfig(client.getIntValue("client_id")); JSONObject yeepayConfig = yeePayClientConfigMapper.findMerchantConfig(client.getIntValue("client_id"));
yeepayConfig.put("company_website",merchantInfo.getString("company_website")); yeepayConfig.put("company_website", merchantInfo.getString("company_website"));
yeepayConfig.put("abn",merchantInfo.getString("abn")); yeepayConfig.put("abn", merchantInfo.getString("abn"));
yeepayConfig.put("company_name",merchantInfo.getString("company_name")); yeepayConfig.put("company_name", merchantInfo.getString("company_name"));
yeepayConfig.put("contact_phone",merchantInfo.getString("contact_phone")); yeepayConfig.put("contact_phone", merchantInfo.getString("contact_phone"));
yeepayConfig.put("contact_email",merchantInfo.getString("contact_email")); yeepayConfig.put("contact_email", merchantInfo.getString("contact_email"));
yeepayConfig.put("contact_person",merchantInfo.getString("contact_person")); yeepayConfig.put("contact_person", merchantInfo.getString("contact_person"));
SubmerchantRegisterResult result = yeePayClient.registerMerchant(client,yeepayConfig); SubmerchantRegisterResult result = yeePayClient.registerMerchant(client, yeepayConfig);
if(result.getStatus().equals("FAILED")){ if (result.getStatus().equals("FAILED")) {
throw new BadRequestException(result.getErrorMsg()); throw new BadRequestException(result.getErrorMsg());
} }
yeepayConfig.put("sub_merchant_id",result.getSubMerchantId()); yeepayConfig.put("sub_merchant_id", result.getSubMerchantId());
yeePayClientConfigMapper.updateSubMerchantId(yeepayConfig.getString("yeepay_config_id"),result.getMerchantId(),result.getSubMerchantId()); yeePayClientConfigMapper.updateSubMerchantId(yeepayConfig.getString("yeepay_config_id"), result.getMerchantId(), result.getSubMerchantId());
client.put("yeepay_sub_merchant_id",result.getSubMerchantId()); client.put("yeepay_sub_merchant_id", result.getSubMerchantId());
clientMapper.update(client); clientMapper.update(client);
} }
@ -4119,25 +4267,25 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
throw new InvalidShortIdException(); throw new InvalidShortIdException();
} }
checkOrgPermission(manager, client); checkOrgPermission(manager, client);
JSONObject config = yeePayClientConfigMapper.findMerchantConfigBySub(client.getIntValue("client_id"),merchantInfo.getString("sub_merchant_id")); JSONObject config = yeePayClientConfigMapper.findMerchantConfigBySub(client.getIntValue("client_id"), merchantInfo.getString("sub_merchant_id"));
if(config != null){ if (config != null) {
throw new BadRequestException("You had add the sub merchant id"); throw new BadRequestException("You had add the sub merchant id");
} }
List<JSONObject> yeepayClientConfigs = yeePayClientConfigMapper.findAllMerchantConfig(client.getIntValue("client_id")); List<JSONObject> yeepayClientConfigs = yeePayClientConfigMapper.findAllMerchantConfig(client.getIntValue("client_id"));
if(yeepayClientConfigs!=null){ if (yeepayClientConfigs != null) {
for(JSONObject yeepayClientConfig:yeepayClientConfigs){ for (JSONObject yeepayClientConfig : yeepayClientConfigs) {
if(yeepayClientConfig.getIntValue("is_valid")==1){ if (yeepayClientConfig.getIntValue("is_valid") == 1) {
yeePayClientConfigMapper.updateSubMerchantIdValid(yeepayClientConfig.getString("yeepay_config_id"),0); yeePayClientConfigMapper.updateSubMerchantIdValid(yeepayClientConfig.getString("yeepay_config_id"), 0);
} }
} }
} }
merchantInfo.put("client_id",client.getIntValue("client_id")); merchantInfo.put("client_id", client.getIntValue("client_id"));
merchantInfo.put("merchant_id",yeePayConfig.getAppKey().split("_")[1]); merchantInfo.put("merchant_id", yeePayConfig.getAppKey().split("_")[1]);
merchantInfo.put("create_time",new Date()); merchantInfo.put("create_time", new Date());
merchantInfo.put("is_valid",1); merchantInfo.put("is_valid", 1);
merchantInfo.put("operator",manager.getString("display_name")); merchantInfo.put("operator", manager.getString("display_name"));
yeePayClientConfigMapper.saveMerchantConfig(merchantInfo); yeePayClientConfigMapper.saveMerchantConfig(merchantInfo);
client.put("yeepay_sub_merchant_id",merchantInfo.getString("sub_merchant_id")); client.put("yeepay_sub_merchant_id", merchantInfo.getString("sub_merchant_id"));
clientMapper.update(client); clientMapper.update(client);
} }
@ -4148,28 +4296,28 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
throw new InvalidShortIdException(); throw new InvalidShortIdException();
} }
checkOrgPermission(manager, client); checkOrgPermission(manager, client);
JSONObject yeepayConfig = yeePayClientConfigMapper.findMerchantConfigBySub(client.getIntValue("client_id"),merchantInfo.getString("subMerchantId")); JSONObject yeepayConfig = yeePayClientConfigMapper.findMerchantConfigBySub(client.getIntValue("client_id"), merchantInfo.getString("subMerchantId"));
List<JSONObject> directorsAll = new ArrayList<>(); List<JSONObject> directorsAll = new ArrayList<>();
List<JSONObject> executivesAll = new ArrayList<>(); List<JSONObject> executivesAll = new ArrayList<>();
directorsAll.add(merchantInfo.getJSONObject("directors")); directorsAll.add(merchantInfo.getJSONObject("directors"));
executivesAll.add(merchantInfo.getJSONObject("executives")); executivesAll.add(merchantInfo.getJSONObject("executives"));
JSONObject extInfo = new JSONObject(); JSONObject extInfo = new JSONObject();
extInfo.put("directors",directorsAll); extInfo.put("directors", directorsAll);
extInfo.put("executives",executivesAll); extInfo.put("executives", executivesAll);
yeepayConfig.put("extinfo",extInfo.toJSONString()); yeepayConfig.put("extinfo", extInfo.toJSONString());
yeepayConfig.put("industry",merchantInfo.getString("industry")); yeepayConfig.put("industry", merchantInfo.getString("industry"));
yeepayConfig.put("business_content",merchantInfo.getString("business_content")); yeepayConfig.put("business_content", merchantInfo.getString("business_content"));
yeepayConfig.put("business_licence",merchantInfo.getString("business_licence")); yeepayConfig.put("business_licence", merchantInfo.getString("business_licence"));
yeePayClientConfigMapper.update(yeepayConfig); yeePayClientConfigMapper.update(yeepayConfig);
yeepayConfig.put("company_website",merchantInfo.getString("company_website")); yeepayConfig.put("company_website", merchantInfo.getString("company_website"));
yeepayConfig.put("abn",merchantInfo.getString("abn")); yeepayConfig.put("abn", merchantInfo.getString("abn"));
yeepayConfig.put("company_name",merchantInfo.getString("company_name")); yeepayConfig.put("company_name", merchantInfo.getString("company_name"));
yeepayConfig.put("contact_phone",merchantInfo.getString("contact_phone")); yeepayConfig.put("contact_phone", merchantInfo.getString("contact_phone"));
yeepayConfig.put("contact_email",merchantInfo.getString("contact_email")); yeepayConfig.put("contact_email", merchantInfo.getString("contact_email"));
yeepayConfig.put("contact_person",merchantInfo.getString("contact_person")); yeepayConfig.put("contact_person", merchantInfo.getString("contact_person"));
yeepayConfig.put("mode","UPDATE"); yeepayConfig.put("mode", "UPDATE");
SubmerchantRegisterResult result = yeePayClient.registerMerchant(client,yeepayConfig); SubmerchantRegisterResult result = yeePayClient.registerMerchant(client, yeepayConfig);
if(result.getStatus().equals("FAILED")){ if (result.getStatus().equals("FAILED")) {
throw new BadRequestException(result.getErrorMsg()); throw new BadRequestException(result.getErrorMsg());
} }
} }
@ -4418,7 +4566,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
} }
@Override @Override
public void switchGatewayLink(JSONObject manager, String clientMoniker,String channel, boolean allow) { public void switchGatewayLink(JSONObject manager, String clientMoniker, String channel, boolean allow) {
JSONObject client = getClientInfoByMoniker(clientMoniker); JSONObject client = getClientInfoByMoniker(clientMoniker);
if (client == null) { if (client == null) {
throw new InvalidShortIdException(); throw new InvalidShortIdException();
@ -4426,18 +4574,18 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
checkOrgPermission(manager, client); checkOrgPermission(manager, client);
if (allow) { if (allow) {
if (StringUtils.isEmpty(client.getString(channel+"_pay_url"))) { if (StringUtils.isEmpty(client.getString(channel + "_pay_url"))) {
String channel_pay_url = getGatewayShortLink(clientMoniker,channel.toLowerCase()); String channel_pay_url = getGatewayShortLink(clientMoniker, channel.toLowerCase());
client.put(channel+"_pay_url", channel_pay_url); client.put(channel + "_pay_url", channel_pay_url);
JSONObject clientConfig = new JSONObject(); JSONObject clientConfig = new JSONObject();
clientConfig.put(channel+"_pay_url", channel_pay_url); clientConfig.put(channel + "_pay_url", channel_pay_url);
clientConfig.put("client_id", client.getIntValue("client_id")); clientConfig.put("client_id", client.getIntValue("client_id"));
clientConfigMapper.update(clientConfig); clientConfigMapper.update(clientConfig);
clientMapper.update(client); clientMapper.update(client);
} }
} }
clientModifySupport.processClientConfigModify(new SwitchPermissionModify(manager, clientMoniker, "enable_"+channel+"_link", allow)); clientModifySupport.processClientConfigModify(new SwitchPermissionModify(manager, clientMoniker, "enable_" + channel + "_link", allow));
clientModifySupport.processClientConfigModify(new SwitchPermissionModify(manager, clientMoniker, "enable_"+channel, allow)); clientModifySupport.processClientConfigModify(new SwitchPermissionModify(manager, clientMoniker, "enable_" + channel, allow));
} }
@ -4466,7 +4614,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
create_time = DateFormatUtils.format(order.getDate("create_time"), "yyyy-MM-dd HH:mm:ss"); create_time = DateFormatUtils.format(order.getDate("create_time"), "yyyy-MM-dd HH:mm:ss");
} }
ctx.setVariable("time", create_time); ctx.setVariable("time", create_time);
final String content = thymeleaf.process( "mail/hf_email_notice", ctx); final String content = thymeleaf.process("mail/hf_email_notice", ctx);
final String mailTo = client.getString("contact_email"); final String mailTo = client.getString("contact_email");
if (StringUtils.isEmpty(mailTo)) { if (StringUtils.isEmpty(mailTo)) {
throw new EmailException("Client Contact Email is invalid"); throw new EmailException("Client Contact Email is invalid");
@ -4488,7 +4636,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
return; return;
} }
if (client.getString("contact_email") == null || if (client.getString("contact_email") == null ||
!clientConfig.getBoolean("enable_"+order.getString("channel").toLowerCase()+"_email_notice")) { !clientConfig.getBoolean("enable_" + order.getString("channel").toLowerCase() + "_email_notice")) {
return; return;
} }
Context ctx = new Context(); Context ctx = new Context();
@ -4506,7 +4654,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
create_time = DateFormatUtils.format(order.getDate("create_time"), "yyyy-MM-dd HH:mm:ss"); create_time = DateFormatUtils.format(order.getDate("create_time"), "yyyy-MM-dd HH:mm:ss");
} }
ctx.setVariable("time", create_time); ctx.setVariable("time", create_time);
final String content = thymeleaf.process( "mail/gateway_email_notice", ctx); final String content = thymeleaf.process("mail/gateway_email_notice", ctx);
final String mailTo = client.getString("contact_email"); final String mailTo = client.getString("contact_email");
if (StringUtils.isEmpty(mailTo)) { if (StringUtils.isEmpty(mailTo)) {
throw new EmailException("Client Contact Email is invalid"); throw new EmailException("Client Contact Email is invalid");
@ -4520,8 +4668,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
}).start(); }).start();
} }
private String getOrderChannel(String channel){ private String getOrderChannel(String channel) {
switch(channel){ switch (channel) {
case "hf": case "hf":
return "汇付"; return "汇付";
case "Yeepay": case "Yeepay":
@ -4529,6 +4677,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
} }
return ""; return "";
} }
@Override @Override
@Transactional @Transactional
public void updateAllPartnerPassword(String clientMoniker) { public void updateAllPartnerPassword(String clientMoniker) {
@ -4570,7 +4719,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
@Override @Override
public String getGatewayShortLink(String clientMoniker, String channel) { public String getGatewayShortLink(String clientMoniker, String channel) {
String longUrl = PlatformEnvironment.getEnv().concatUrl("/api/v1.0/"+channel+"/partners/" + clientMoniker + "/jump/pc"); String longUrl = PlatformEnvironment.getEnv().concatUrl("/api/v1.0/" + channel + "/partners/" + clientMoniker + "/jump/pc");
MpWechatApi api = mpWechatApiProvider.getNewPaymentApi(); MpWechatApi api = mpWechatApiProvider.getNewPaymentApi();
return api.registerShortUrl(longUrl); return api.registerShortUrl(longUrl);
} }
@ -4597,7 +4746,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
infoStr.append("ABN = " + riskInfo.getString("abn") + ",ACN = " + riskInfo.getString("acn") + ",contact_phone = " + riskInfo.getString("contact_phone") + ",contact_person = " + riskInfo.getString("contact_person") + ",bank_account_no = " + riskInfo.getString("bank_account_no")); infoStr.append("ABN = " + riskInfo.getString("abn") + ",ACN = " + riskInfo.getString("acn") + ",contact_phone = " + riskInfo.getString("contact_phone") + ",contact_person = " + riskInfo.getString("contact_person") + ",bank_account_no = " + riskInfo.getString("bank_account_no"));
}); });
appendStr.deleteCharAt(appendStr.length() - 1); appendStr.deleteCharAt(appendStr.length() - 1);
throw new BadRequestException("该商户信息已经进入系统黑名单,关联商户为【" + appendStr.toString().toUpperCase() + "】【" + infoStr.toString() + "】"); throw new BadRequestException("该商户信息已经进入系统黑名单,关联商户为【" + appendStr.toString().toUpperCase() + "】【" + infoStr.toString() + "】");
} }
} }
@ -4666,6 +4815,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
} }
return null; return null;
} }
@Override @Override
@Transactional @Transactional
public boolean postponeClientRate(int clientId, String clientMoniker, String nextYearExipryDate) { public boolean postponeClientRate(int clientId, String clientMoniker, String nextYearExipryDate) {
@ -4785,7 +4935,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
} }
} }
String path = paymentConfig.getString("path"); String path = paymentConfig.getString("path");
path = path.replaceAll("app","pc"); path = path.replaceAll("app", "pc");
response.sendRedirect(String.format(PlatformEnvironment.getEnv().concatUrl(path), clientMoniker)); response.sendRedirect(String.format(PlatformEnvironment.getEnv().concatUrl(path), clientMoniker));
} }
@ -4837,7 +4987,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
List<String> needNotifyUsers = royalPayUsers.stream().filter(user -> StringUtils.isNotEmpty(user.getString("wx_openid"))).map(user -> user.getString("wx_openid")).collect(Collectors.toList()); List<String> needNotifyUsers = royalPayUsers.stream().filter(user -> StringUtils.isNotEmpty(user.getString("wx_openid"))).map(user -> user.getString("wx_openid")).collect(Collectors.toList());
needNotifyUsers.forEach(userOpenId -> { needNotifyUsers.forEach(userOpenId -> {
try { try {
String signStr = "?sign=" + AESencrypt(accounts.toString(),userOpenId); String signStr = "?sign=" + AESencrypt(accounts.toString(), userOpenId);
MpWechatApi paymentApi = mpWechatApiProvider.getNewPaymentApi(); MpWechatApi paymentApi = mpWechatApiProvider.getNewPaymentApi();
TemplateMessage msg = initSendTestPasswordTemplate(userOpenId, paymentApi.getTemplateId("test-merchant-password"), signStr.replace("+", "%2B")); TemplateMessage msg = initSendTestPasswordTemplate(userOpenId, paymentApi.getTemplateId("test-merchant-password"), signStr.replace("+", "%2B"));
paymentApi.sendTemplateMessage(msg); paymentApi.sendTemplateMessage(msg);
@ -4875,21 +5025,11 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
byte[] enCodeFormat = secretKey.getEncoded(); byte[] enCodeFormat = secretKey.getEncoded();
SecretKeySpec key = new SecretKeySpec(enCodeFormat, "AES"); SecretKeySpec key = new SecretKeySpec(enCodeFormat, "AES");
Cipher cipher = Cipher.getInstance("AES"); Cipher cipher = Cipher.getInstance("AES");
byte[] byteContent = content.getBytes("utf-8"); byte[] byteContent = content.getBytes(StandardCharsets.UTF_8);
cipher.init(Cipher.ENCRYPT_MODE, key); cipher.init(Cipher.ENCRYPT_MODE, key);
byte[] result = cipher.doFinal(byteContent); byte[] result = cipher.doFinal(byteContent);
return Base64.encodeBase64String(result); return Base64.encodeBase64String(result);
} catch (NoSuchPaddingException e) { } catch (NoSuchPaddingException | NoSuchAlgorithmException | InvalidKeyException | IllegalBlockSizeException | BadPaddingException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (InvalidKeyException e) {
e.printStackTrace();
} catch (IllegalBlockSizeException e) {
e.printStackTrace();
} catch (BadPaddingException e) {
e.printStackTrace(); e.printStackTrace();
} }
return null; return null;

@ -1,13 +1,7 @@
package au.com.royalpay.payment.manage.merchants.web; package au.com.royalpay.payment.manage.merchants.web;
import au.com.royalpay.payment.manage.dev.core.MerchantLocationService; import au.com.royalpay.payment.manage.dev.core.MerchantLocationService;
import au.com.royalpay.payment.manage.merchants.beans.BankAccountInfo; import au.com.royalpay.payment.manage.merchants.beans.*;
import au.com.royalpay.payment.manage.merchants.beans.ClientAuthFilesInfo;
import au.com.royalpay.payment.manage.merchants.beans.ClientRateConfig;
import au.com.royalpay.payment.manage.merchants.beans.ClientRegisterInfo;
import au.com.royalpay.payment.manage.merchants.beans.NewAccountBean;
import au.com.royalpay.payment.manage.merchants.beans.PartnerQuery;
import au.com.royalpay.payment.manage.merchants.beans.SubMerchantIdApply;
import au.com.royalpay.payment.manage.merchants.core.ClientManager; import au.com.royalpay.payment.manage.merchants.core.ClientManager;
import au.com.royalpay.payment.manage.permission.manager.ManagerMapping; import au.com.royalpay.payment.manage.permission.manager.ManagerMapping;
import au.com.royalpay.payment.manage.permission.manager.RequireManager; import au.com.royalpay.payment.manage.permission.manager.RequireManager;
@ -19,21 +13,14 @@ import au.com.royalpay.payment.tools.merchants.beans.QRCodeConfig;
import au.com.royalpay.payment.tools.permission.enums.ManagerRole; import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.springframework.validation.Errors; import org.springframework.validation.Errors;
import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid; import javax.validation.Valid;
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
/** /**
* Created by yixian on 2016-06-27. * Created by yixian on 2016-06-27.
@ -182,6 +169,11 @@ public class PartnerManageController {
clientManager.updateClientPaymentConfig(manager, clientMoniker, subMerchantInfo); clientManager.updateClientPaymentConfig(manager, clientMoniker, subMerchantInfo);
} }
@ManagerMapping(value = "/{clientMoniker}/refund_credit_line", method = RequestMethod.PUT, role = {ManagerRole.OPERATOR, ManagerRole.BD_USER})
public void updateRefundCreditLine(@PathVariable String clientMoniker, @RequestBody JSONObject refundLineInfo, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
clientManager.updateRefundCreditLine(manager, clientMoniker, refundLineInfo);
}
@ManagerMapping(value = "/{clientMoniker}/rpay_payment_config", method = RequestMethod.PUT, role = {ManagerRole.OPERATOR, ManagerRole.BD_USER}) @ManagerMapping(value = "/{clientMoniker}/rpay_payment_config", method = RequestMethod.PUT, role = {ManagerRole.OPERATOR, ManagerRole.BD_USER})
public void updatePartnerRpayPaymentConfig(@PathVariable String clientMoniker, @RequestBody JSONObject rpaySubMerchantInfo, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { public void updatePartnerRpayPaymentConfig(@PathVariable String clientMoniker, @RequestBody JSONObject rpaySubMerchantInfo, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
clientManager.updateClientRpayPaymentConfig(manager, clientMoniker, rpaySubMerchantInfo); clientManager.updateClientRpayPaymentConfig(manager, clientMoniker, rpaySubMerchantInfo);
@ -272,6 +264,17 @@ public class PartnerManageController {
clientManager.switchPermission(manager, clientMoniker, "common_sub_merchant_id", pass.getBooleanValue("allow")); clientManager.switchPermission(manager, clientMoniker, "common_sub_merchant_id", pass.getBooleanValue("allow"));
} }
/**
*
* @param clientMoniker
* @param pass
* @param manager
*/
@ManagerMapping(value = "/{clientMoniker}/sub_manage", method = RequestMethod.PUT, role = {ManagerRole.OPERATOR})
public void switchSubManage(@PathVariable String clientMoniker, @RequestBody JSONObject pass, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
clientManager.switchPermission(manager, clientMoniker, "sub_manage", pass.getBooleanValue("allow"));
}
@ManagerMapping(value = "/{clientMoniker}/channels/{channel}/permission", method = RequestMethod.PUT, role = {ManagerRole.SERVANT, ManagerRole.DEVELOPER}) @ManagerMapping(value = "/{clientMoniker}/channels/{channel}/permission", method = RequestMethod.PUT, role = {ManagerRole.SERVANT, ManagerRole.DEVELOPER})
public void switchChannelPermission(@PathVariable String clientMoniker, @PathVariable String channel, @RequestBody JSONObject pass, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { public void switchChannelPermission(@PathVariable String clientMoniker, @PathVariable String channel, @RequestBody JSONObject pass, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
clientManager.switchChannelPermission(manager, clientMoniker, channel, pass.getBooleanValue("allow")); clientManager.switchChannelPermission(manager, clientMoniker, channel, pass.getBooleanValue("allow"));
@ -302,6 +305,12 @@ public class PartnerManageController {
clientManager.switchPermission(manager, clientMoniker, "enable_pre_refund", pass.getBooleanValue("allow")); clientManager.switchPermission(manager, clientMoniker, "enable_pre_refund", pass.getBooleanValue("allow"));
} }
@ManagerMapping(value = "/{clientMoniker}/reset/refund_pwd", method = RequestMethod.PUT, role = {ManagerRole.OPERATOR, ManagerRole.ADMIN, ManagerRole.DEVELOPER})
public void changeRefundPwd(@PathVariable String clientMoniker, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager,@RequestBody JSONObject config) {
clientManager.resetRefundPasswordByManage(clientMoniker, manager, config);
}
@ManagerMapping(value = "/{clientMoniker}/payment_page_version", method = RequestMethod.PUT, role = {ManagerRole.OPERATOR, ManagerRole.BD_USER}) @ManagerMapping(value = "/{clientMoniker}/payment_page_version", method = RequestMethod.PUT, role = {ManagerRole.OPERATOR, ManagerRole.BD_USER})
public void changePaymentPage(@PathVariable String clientMoniker, @RequestBody JSONObject pass, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { public void changePaymentPage(@PathVariable String clientMoniker, @RequestBody JSONObject pass, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
clientManager.changePaymentPage(manager, clientMoniker, pass.getString("paypad_version")); clientManager.changePaymentPage(manager, clientMoniker, pass.getString("paypad_version"));
@ -398,9 +407,10 @@ public class PartnerManageController {
public List<JSONObject> accountTransactions(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @PathVariable String clientMoniker) { public List<JSONObject> accountTransactions(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @PathVariable String clientMoniker) {
return clientManager.getAccountTransactions(manager, clientMoniker); return clientManager.getAccountTransactions(manager, clientMoniker);
} }
@ManagerMapping(value = "/{clientMoniker}/account/transactions/date", method = RequestMethod.GET, role = {ManagerRole.ADMIN, ManagerRole.OPERATOR}) @ManagerMapping(value = "/{clientMoniker}/account/transactions/date", method = RequestMethod.GET, role = {ManagerRole.ADMIN, ManagerRole.OPERATOR})
public List<JSONObject> accountTransactionsByDate(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @PathVariable String clientMoniker,@RequestParam String date) { public List<JSONObject> accountTransactionsByDate(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @PathVariable String clientMoniker, @RequestParam String detailId) {
return clientManager.getAccountTransactionsByDate(manager, clientMoniker, date); return clientManager.getAccountTransactionsByDetailId(manager, clientMoniker, detailId);
} }
@ManagerMapping(value = "/{clientMoniker}/account/save", method = RequestMethod.POST, role = {ManagerRole.ADMIN, ManagerRole.OPERATOR}) @ManagerMapping(value = "/{clientMoniker}/account/save", method = RequestMethod.POST, role = {ManagerRole.ADMIN, ManagerRole.OPERATOR})
@ -637,6 +647,16 @@ public class PartnerManageController {
return clientManager.queryAlipayOnlineGmsStatus(clientMoniker, manager); return clientManager.queryAlipayOnlineGmsStatus(clientMoniker, manager);
} }
@ManagerMapping(value = "/{clientMoniker}/query/alipay_gms_json", method = RequestMethod.GET, role = {ManagerRole.OPERATOR, ManagerRole.ADMIN})
public JSONObject queryAlipayGmsJson(@PathVariable String clientMoniker,@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
return clientManager.queryAlipayGmsJson(clientMoniker, manager);
}
@ManagerMapping(value = "/{clientMoniker}/query/alipayOnline_gms_json", method = RequestMethod.GET, role = {ManagerRole.OPERATOR, ManagerRole.ADMIN})
public JSONObject queryAlipayOnlineGmsJson(@PathVariable String clientMoniker,@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
return clientManager.queryAlipayOnlineGmsJson(clientMoniker, manager);
}
@ManagerMapping(value = "/{clientMoniker}/get_merchant_ids",method = RequestMethod.GET,role = {ManagerRole.OPERATOR,ManagerRole.ADMIN}) @ManagerMapping(value = "/{clientMoniker}/get_merchant_ids",method = RequestMethod.GET,role = {ManagerRole.OPERATOR,ManagerRole.ADMIN})
public List<JSONObject> getMerchantIds(@PathVariable String clientMoniker, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { public List<JSONObject> getMerchantIds(@PathVariable String clientMoniker, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
return clientManager.listMerchantIds(clientMoniker,manager); return clientManager.listMerchantIds(clientMoniker,manager);

@ -7,7 +7,6 @@ import au.com.royalpay.payment.manage.merchants.beans.ClientRegisterInfo;
import au.com.royalpay.payment.manage.merchants.beans.NewAccountBean; import au.com.royalpay.payment.manage.merchants.beans.NewAccountBean;
import au.com.royalpay.payment.manage.merchants.core.ClientManager; import au.com.royalpay.payment.manage.merchants.core.ClientManager;
import au.com.royalpay.payment.manage.merchants.core.ClientSignEventSupport; import au.com.royalpay.payment.manage.merchants.core.ClientSignEventSupport;
import au.com.royalpay.payment.manage.permission.manager.ManagerMapping;
import au.com.royalpay.payment.manage.permission.manager.PartnerMapping; import au.com.royalpay.payment.manage.permission.manager.PartnerMapping;
import au.com.royalpay.payment.manage.permission.manager.RequirePartner; import au.com.royalpay.payment.manage.permission.manager.RequirePartner;
import au.com.royalpay.payment.manage.support.wechatclients.KangaLandWechatApiImpl; import au.com.royalpay.payment.manage.support.wechatclients.KangaLandWechatApiImpl;
@ -21,31 +20,21 @@ import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import au.com.royalpay.payment.tools.exceptions.ForbiddenException; import au.com.royalpay.payment.tools.exceptions.ForbiddenException;
import au.com.royalpay.payment.tools.http.HttpUtils; import au.com.royalpay.payment.tools.http.HttpUtils;
import au.com.royalpay.payment.tools.merchants.beans.QRCodeConfig; import au.com.royalpay.payment.tools.merchants.beans.QRCodeConfig;
import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
import au.com.royalpay.payment.tools.permission.enums.PartnerRole; import au.com.royalpay.payment.tools.permission.enums.PartnerRole;
import au.com.royalpay.payment.tools.permission.wechat.WechatMapping; import au.com.royalpay.payment.tools.permission.wechat.WechatMapping;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.Model; import org.springframework.ui.Model;
import org.springframework.validation.Errors; import org.springframework.validation.Errors;
import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid; import javax.validation.Valid;
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
/** /**
* view for partner client * view for partner client
@ -182,7 +171,6 @@ public class PartnerViewController {
clientManager.setOrderExpiryConfig(account,clientMoniker, config.getString("order_expiry_config")); clientManager.setOrderExpiryConfig(account,clientMoniker, config.getString("order_expiry_config"));
} }
@PartnerMapping(value = "/{clientMoniker}/surcharge_account", method = RequestMethod.GET, roles = {PartnerRole.ADMIN, PartnerRole.MANAGER}) @PartnerMapping(value = "/{clientMoniker}/surcharge_account", method = RequestMethod.GET, roles = {PartnerRole.ADMIN, PartnerRole.MANAGER})
@ResponseBody @ResponseBody
public JSONObject surchargeAccount(@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject manager, @PathVariable String clientMoniker) { public JSONObject surchargeAccount(@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject manager, @PathVariable String clientMoniker) {
@ -195,6 +183,18 @@ public class PartnerViewController {
return clientManager.getAccountTransactions(manager, clientMoniker); return clientManager.getAccountTransactions(manager, clientMoniker);
} }
@PartnerMapping(value = "/{clientMoniker}/account/transactions/date", method = RequestMethod.GET, roles = {PartnerRole.ADMIN, PartnerRole.MANAGER})
@ResponseBody
public List<JSONObject> accountTransactionsByDate(@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject manager, @PathVariable String clientMoniker,@RequestParam String date) {
return clientManager.getAccountTransactionsByDetailId(manager, clientMoniker, date);
}
@PartnerMapping(value = "/{clientMoniker}/account/months", method = RequestMethod.GET, roles = {PartnerRole.ADMIN, PartnerRole.MANAGER})
@ResponseBody
public List<JSONObject> getAccountDetailByMonths(@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject manager, @PathVariable String clientMoniker){
return clientManager.getAccountDetailByMonths(manager, clientMoniker);
}
@PartnerMapping(value = "/accounts/{accountId}/audit_refund", method = RequestMethod.PUT, roles = PartnerRole.ADMIN) @PartnerMapping(value = "/accounts/{accountId}/audit_refund", method = RequestMethod.PUT, roles = PartnerRole.ADMIN)
@ResponseBody @ResponseBody
public void toggleAccountAuditRefund(@PathVariable String accountId, @ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject account, @RequestBody JSONObject enable) { public void toggleAccountAuditRefund(@PathVariable String accountId, @ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject account, @RequestBody JSONObject enable) {
@ -243,7 +243,7 @@ public class PartnerViewController {
return "wechat_bind"; return "wechat_bind";
} }
@RequestMapping(value = "/account_receive_notice", method = RequestMethod.PUT) @PutMapping(value = "/account_receive_notice")
@ResponseBody @ResponseBody
public JSONObject toggleReceiveNotice(@ModelAttribute(CommonConsts.WECHATINFO) JSONObject user, @RequestBody JSONObject enable) { public JSONObject toggleReceiveNotice(@ModelAttribute(CommonConsts.WECHATINFO) JSONObject user, @RequestBody JSONObject enable) {
if (user == null) { if (user == null) {
@ -271,6 +271,12 @@ public class PartnerViewController {
clientManager.updateRefundPwd(account, req.getString("pwd")); clientManager.updateRefundPwd(account, req.getString("pwd"));
} }
@PartnerMapping(value = "/refund_pwd_new", method = RequestMethod.PUT, roles = {PartnerRole.ADMIN})
@ResponseBody
public void updateRefundPwdNew(@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject account, @RequestBody JSONObject req) {
clientManager.resetRefundPassword(account, req);
}
@PartnerMapping(value = "/trade_logs", method = RequestMethod.GET) @PartnerMapping(value = "/trade_logs", method = RequestMethod.GET)
@ResponseBody @ResponseBody
public JSONObject listTradeLogs(@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject account, TradeLogQuery query) throws Exception { public JSONObject listTradeLogs(@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject account, TradeLogQuery query) throws Exception {

@ -5,6 +5,7 @@ import au.com.royalpay.payment.manage.mappers.ofei.TopUpOrderMapper;
import au.com.royalpay.payment.manage.ofei.core.OfeiClient; import au.com.royalpay.payment.manage.ofei.core.OfeiClient;
import au.com.royalpay.payment.manage.ofei.enums.OfeiType; import au.com.royalpay.payment.manage.ofei.enums.OfeiType;
import au.com.royalpay.payment.tools.codec.MD5Hash; import au.com.royalpay.payment.tools.codec.MD5Hash;
import au.com.royalpay.payment.tools.env.PlatformEnvironment;
import au.com.royalpay.payment.tools.exceptions.BadRequestException; import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import au.com.royalpay.payment.tools.exceptions.ServerErrorException; import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
import au.com.royalpay.payment.tools.fixing.FixedDocumentHelper; import au.com.royalpay.payment.tools.fixing.FixedDocumentHelper;
@ -84,7 +85,7 @@ public class OfeiClientImpl implements OfeiClient {
params.add(new BasicNameValuePair("sporder_id", orderId)); params.add(new BasicNameValuePair("sporder_id", orderId));
params.add(new BasicNameValuePair("sporder_time", DateFormatUtils.format(now, "yyyyMMddHHmmss"))); params.add(new BasicNameValuePair("sporder_time", DateFormatUtils.format(now, "yyyyMMddHHmmss")));
params.add(new BasicNameValuePair("game_userid", phoneNumber)); params.add(new BasicNameValuePair("game_userid", phoneNumber));
params.add(new BasicNameValuePair("ret_url", "https://mpay.royalpay.com.au/ofei/notice/"+orderId)); params.add(new BasicNameValuePair("ret_url", PlatformEnvironment.getEnv().concatUrl("/ofei/notice/"+orderId)));
saveOrder(orderId, now, OfeiType.PHONE.getMask(), price, phoneNumber); saveOrder(orderId, now, OfeiType.PHONE.getMask(), price, phoneNumber);
HttpRequestGenerator req = initRequest(topUPUrl, signAndEncryptForm(params), RequestMethod.GET); HttpRequestGenerator req = initRequest(topUPUrl, signAndEncryptForm(params), RequestMethod.GET);
@ -220,11 +221,11 @@ public class OfeiClientImpl implements OfeiClient {
params.add(new BasicNameValuePair("sporder_id", orderId)); params.add(new BasicNameValuePair("sporder_id", orderId));
params.add(new BasicNameValuePair("sporder_time", DateFormatUtils.format(now, "yyyyMMddHHmmss"))); params.add(new BasicNameValuePair("sporder_time", DateFormatUtils.format(now, "yyyyMMddHHmmss")));
params.add(new BasicNameValuePair("game_userid", qqNumber)); params.add(new BasicNameValuePair("game_userid", qqNumber));
params.add(new BasicNameValuePair("ret_url", "https://mpay.royalpay.com.au/ofei/notice/"+orderId)); params.add(new BasicNameValuePair("ret_url", PlatformEnvironment.getEnv().concatUrl("/ofei/notice/" + orderId)));
saveOrder(orderId, now, OfeiType.QB.getMask(), price, qqNumber); saveOrder(orderId, now, OfeiType.QB.getMask(), price, qqNumber);
HttpRequestGenerator req = initRequest(qbTopUpUrl, signAndEncryptForm(params), RequestMethod.POST); HttpRequestGenerator req = initRequest(qbTopUpUrl, signAndEncryptForm(params), RequestMethod.POST);
Element respXml = executeRequestXML(req, "ofei QB top up fail"); Element respXml = executeRequestXML(req, "ofei QB top up fail");
handleResponse(orderId, respXml,qqNumber); handleResponse(orderId, respXml, qqNumber);
} }

@ -54,7 +54,7 @@ public class ManagerPermissionScanner implements BeanPostProcessor, PermissionRe
PermissionNode node = new PermissionNode(controller.getSimpleName(), method.getName()); PermissionNode node = new PermissionNode(controller.getSimpleName(), method.getName());
getRequestInfo(node, clazzRequestMapping, methodMapping); getRequestInfo(node, clazzRequestMapping, methodMapping);
node.setPermissions(clazzPermission, methodPermission); node.setPermissions(clazzPermission, methodPermission);
logger.debug("register permission:" + node.getFuncName() + ":" + node.getRequestId()); logger.trace("register permission:{}:{}", node.getFuncName(), node.getRequestId());
if (permissionNodes.containsKey(node.getFuncId())) { if (permissionNodes.containsKey(node.getFuncId())) {
throw new RuntimeException("Duplicated permission function ID:" + controller.getName() + "." + method.getName()); throw new RuntimeException("Duplicated permission function ID:" + controller.getName() + "." + method.getName());
} }

@ -9,6 +9,8 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@ -21,14 +23,14 @@ public class APNSMessageHelper {
@Value("classpath:apple_message_cert_dev.p12") @Value("classpath:apple_message_cert_dev.p12")
private org.springframework.core.io.Resource appleMessageFileDev; private org.springframework.core.io.Resource appleMessageFileDev;
@Value("classpath:apple_message_cert_product.p12") @Value("${apple.message.apns.file}")
private org.springframework.core.io.Resource appleMessageFileProduct; private String appleApnsFile;
@Value("${apple.message.apns.password}") @Value("${apple.message.apns.password}")
private String appleMessagePassword; private String appleMessagePassword;
public void sendAppleMessage(String title, String body, String token, JSONObject data, JSONObject type) throws IOException { public void sendAppleMessage(String title, String body, String token, JSONObject data, JSONObject type) throws IOException {
/**设置参数,发送数据**/ /**设置参数,发送数据**/
InputStream keyIns = appleMessageFileProduct.getInputStream(); InputStream keyIns = new FileInputStream(new File(appleApnsFile));
ApnsService service = APNS.newService().withCert(keyIns, appleMessagePassword).withProductionDestination().build(); ApnsService service = APNS.newService().withCert(keyIns, appleMessagePassword).withProductionDestination().build();
String payload = APNS.newPayload().alertTitle(title).alertBody(body).badge(1).sound("default").customField("data", data).customField("type", type).build(); String payload = APNS.newPayload().alertTitle(title).alertBody(body).badge(1).sound("default").customField("data", data).customField("type", type).build();
service.push(token, payload); service.push(token, payload);
@ -37,7 +39,7 @@ public class APNSMessageHelper {
public void sendAppleMessageDetail(String title, String body, String token, JSONObject data, JSONObject type) throws IOException { public void sendAppleMessageDetail(String title, String body, String token, JSONObject data, JSONObject type) throws IOException {
/**设置参数,发送数据**/ /**设置参数,发送数据**/
InputStream keyIns = appleMessageFileProduct.getInputStream(); InputStream keyIns = new FileInputStream(new File(appleApnsFile));
ApnsService service = APNS.newService().withCert(keyIns, appleMessagePassword).withProductionDestination().build(); ApnsService service = APNS.newService().withCert(keyIns, appleMessagePassword).withProductionDestination().build();
String payload = APNS.newPayload().alertTitle(title).alertBody(body).category("myNotificationCategory").badge(1).sound("default").customField("data", data).customField("type", type).build(); String payload = APNS.newPayload().alertTitle(title).alertBody(body).category("myNotificationCategory").badge(1).sound("default").customField("data", data).customField("type", type).build();
service.push(token, payload); service.push(token, payload);

@ -13,6 +13,7 @@ import au.com.royalpay.payment.tools.CommonConsts;
import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApi; import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApi;
import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApiProvider; import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApiProvider;
import au.com.royalpay.payment.tools.connections.mpsupport.beans.WechatRedpack; import au.com.royalpay.payment.tools.connections.mpsupport.beans.WechatRedpack;
import au.com.royalpay.payment.tools.env.PlatformEnvironment;
import au.com.royalpay.payment.tools.exceptions.ForbiddenException; import au.com.royalpay.payment.tools.exceptions.ForbiddenException;
import au.com.royalpay.payment.tools.exceptions.NotFoundException; import au.com.royalpay.payment.tools.exceptions.NotFoundException;
import au.com.royalpay.payment.tools.utils.PageListUtils; import au.com.royalpay.payment.tools.utils.PageListUtils;
@ -190,7 +191,7 @@ public class ActRedPackServiceImpl implements ActRedPackService {
JSONObject prizeDetail = actRedPacketsCustomerOrdersMapper.findLockedPrize(lock, paymentOpenId); JSONObject prizeDetail = actRedPacketsCustomerOrdersMapper.findLockedPrize(lock, paymentOpenId);
BigDecimal luckyMoeny = prizeDetail.getBigDecimal("red_packet_amount"); BigDecimal luckyMoeny = prizeDetail.getBigDecimal("red_packet_amount");
String redPackOrderId = prizeDetail.getString("red_packet_order_id"); String redPackOrderId = prizeDetail.getString("red_packet_order_id");
String notifyUrl = "https://mpay.royalpay.com.au/sys/lucky_money/customer/redpacks/" + redPackOrderId + "/notify"; String notifyUrl = PlatformEnvironment.getEnv().concatUrl("/sys/lucky_money/customer/redpacks/" + redPackOrderId + "/notify");
JSONObject customerRelation = customerMapper.findCustomerByOpenId(paymentOpenId); JSONObject customerRelation = customerMapper.findCustomerByOpenId(paymentOpenId);
if (customerRelation == null) { if (customerRelation == null) {
customerRelation = customerMapper.findCustomerGlobalpayByOpenId(paymentOpenId); customerRelation = customerMapper.findCustomerGlobalpayByOpenId(paymentOpenId);

@ -8,6 +8,7 @@ import au.com.royalpay.payment.manage.mappers.system.CustomerMapper;
import au.com.royalpay.payment.manage.merchants.beans.PartnerQuery; import au.com.royalpay.payment.manage.merchants.beans.PartnerQuery;
import au.com.royalpay.payment.manage.merchants.core.ClientManager; import au.com.royalpay.payment.manage.merchants.core.ClientManager;
import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApiProvider; import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApiProvider;
import au.com.royalpay.payment.tools.env.PlatformEnvironment;
import au.com.royalpay.payment.tools.permission.enums.ManagerRole; import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
import au.com.royalpay.payment.manage.redpack.beans.ActTypeEnum; import au.com.royalpay.payment.manage.redpack.beans.ActTypeEnum;
import au.com.royalpay.payment.manage.redpack.beans.RedpackQuery; import au.com.royalpay.payment.manage.redpack.beans.RedpackQuery;
@ -263,7 +264,7 @@ public class PartnerLMServiceImp implements PartnerLMService {
String sendName = "RoyalPay"; String sendName = "RoyalPay";
String actName = act.getString("act_name"); String actName = act.getString("act_name");
String wishing = "恭喜获得ROYALPAY红包奖励"; String wishing = "恭喜获得ROYALPAY红包奖励";
String notifyUrl = "https://mpay.royalpay.com.au/sys/lucky_money/partner/" + red_packet_order_id + "notify"; String notifyUrl = PlatformEnvironment.getEnv().concatUrl("/sys/lucky_money/partner/" + red_packet_order_id + "notify");
WechatRedpack wechatRedpack = new WechatRedpack(); WechatRedpack wechatRedpack = new WechatRedpack();
JSONObject customerRelation = customerMapper.findCustomerByOpenId(open_id); JSONObject customerRelation = customerMapper.findCustomerByOpenId(open_id);

@ -13,6 +13,7 @@ import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApi;
import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApiProvider; import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApiProvider;
import au.com.royalpay.payment.tools.connections.mpsupport.beans.AlipayRedpack; import au.com.royalpay.payment.tools.connections.mpsupport.beans.AlipayRedpack;
import au.com.royalpay.payment.tools.connections.mpsupport.beans.WechatRedpack; import au.com.royalpay.payment.tools.connections.mpsupport.beans.WechatRedpack;
import au.com.royalpay.payment.tools.env.PlatformEnvironment;
import au.com.royalpay.payment.tools.exceptions.BadRequestException; import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import au.com.royalpay.payment.tools.utils.CurrencyAmountUtils; import au.com.royalpay.payment.tools.utils.CurrencyAmountUtils;
import au.com.royalpay.payment.tools.utils.PageListUtils; import au.com.royalpay.payment.tools.utils.PageListUtils;
@ -410,7 +411,7 @@ public class RedpackServiceImpl implements RedpackService {
String red_packet_order_id = prizeDetail.getString("red_packet_order_id"); String red_packet_order_id = prizeDetail.getString("red_packet_order_id");
String sendName = "RoyalPay皇家支付"; String sendName = "RoyalPay皇家支付";
String wishing = "恭喜获得ROYALPAY店长福利红包"; String wishing = "恭喜获得ROYALPAY店长福利红包";
String notifyUrl = "https://mpay.royalpay.com.au/sys/lucky_money/partner/" + red_packet_order_id + "notify"; String notifyUrl = PlatformEnvironment.getEnv().concatUrl("/sys/lucky_money/partner/" + red_packet_order_id + "notify");
WechatRedpack wechatRedpack = new WechatRedpack(); WechatRedpack wechatRedpack = new WechatRedpack();
JSONObject customerRelation = customerMapper.findCustomerByOpenId(open_id); JSONObject customerRelation = customerMapper.findCustomerByOpenId(open_id);

@ -24,6 +24,8 @@ public class ManagerInfo {
@Email @Email
private String email; private String email;
private String phone; private String phone;
@JSONField(name = "nation_code")
private String nationCode;
private String wechat; private String wechat;
private boolean admin; private boolean admin;
private boolean operator; private boolean operator;
@ -58,6 +60,7 @@ public class ManagerInfo {
} }
account.put("email", email); account.put("email", email);
account.put("phone", phone); account.put("phone", phone);
account.put("nation_code", "+"+nationCode);
account.put("wechat", wechat); account.put("wechat", wechat);
int role = 0; int role = 0;
if (admin) { if (admin) {
@ -296,4 +299,12 @@ public class ManagerInfo {
public void setSalesmanager(boolean salesmanager) { public void setSalesmanager(boolean salesmanager) {
this.salesmanager = salesmanager; this.salesmanager = salesmanager;
} }
public String getNationCode() {
return nationCode;
}
public void setNationCode(String nationCode) {
this.nationCode = nationCode;
}
} }

@ -27,4 +27,6 @@ public interface ManagerAccountsService {
JSONObject getBDConfig(String bd_id); JSONObject getBDConfig(String bd_id);
List<JSONObject> listServants(JSONObject loginManager); List<JSONObject> listServants(JSONObject loginManager);
void resetPwd(JSONObject account,String password);
} }

@ -3,6 +3,7 @@ package au.com.royalpay.payment.manage.signin.core;
import au.com.royalpay.payment.manage.signin.beans.ChangePwdBean; import au.com.royalpay.payment.manage.signin.beans.ChangePwdBean;
import au.com.royalpay.payment.manage.signin.beans.LoginInfo; import au.com.royalpay.payment.manage.signin.beans.LoginInfo;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.springframework.web.servlet.ModelAndView;
/** /**
* Created by yixian on 2016-06-29. * Created by yixian on 2016-06-29.
@ -15,6 +16,10 @@ public interface SignInAccountService {
JSONObject getClient(String accountId); JSONObject getClient(String accountId);
JSONObject getClientByUsername(String username);
JSONObject getManagerByUsername(String username);
void clearAccountCache(String accountId); void clearAccountCache(String accountId);
JSONObject managerLoginCheck(LoginInfo loginInfo); JSONObject managerLoginCheck(LoginInfo loginInfo);
@ -40,4 +45,16 @@ public interface SignInAccountService {
String ForgetPassword(String partner_code) throws Exception; String ForgetPassword(String partner_code) throws Exception;
void changePasswordByEmail(String codeValue, String login_id, String newPassword); void changePasswordByEmail(String codeValue, String login_id, String newPassword);
void getClientResetPwdCode(JSONObject account,String type);
void getManagerResetPwdCode(JSONObject account,String type);
void verifyClientCaptcha(JSONObject account, String captcha);
void verifyManagerCaptcha(JSONObject account, String captcha);
void deleteClientCodeKey(String codekey);
void deleteManagerCodeKey(String codekey);
} }

@ -11,6 +11,7 @@ import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import au.com.royalpay.payment.tools.exceptions.NotFoundException; import au.com.royalpay.payment.tools.exceptions.NotFoundException;
import au.com.royalpay.payment.tools.permission.enums.ManagerRole; import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
import au.com.royalpay.payment.tools.utils.PasswordUtils;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.Order; import com.github.miemiedev.mybatis.paginator.domain.Order;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds; import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
@ -149,6 +150,15 @@ public class ManagerAccountServiceImpl implements ManagerAccountsService {
return managerMapper.listServants(ManagerRole.SERVANT.getMask()); return managerMapper.listServants(ManagerRole.SERVANT.getMask());
} }
@Override
public void resetPwd(JSONObject account, String password) {
String salt = PasswordUtils.newSalt();
account.put("salt", salt);
account.put("password_hash", PasswordUtils.hashPwd(password, salt));
managerMapper.update(account);
signInAccountService.clearManager(account.getString("manager_id"));
}
private void checkOrg(JSONObject loginManager,JSONObject manager){ private void checkOrg(JSONObject loginManager,JSONObject manager){
if (loginManager.getInteger("org_id")!=null){ if (loginManager.getInteger("org_id")!=null){
List<JSONObject> orgs = orgMapper.listOrgAndChild(loginManager.getIntValue("org_id")); List<JSONObject> orgs = orgMapper.listOrgAndChild(loginManager.getIntValue("org_id"));

@ -1,13 +1,10 @@
package au.com.royalpay.payment.manage.signin.core.impls; package au.com.royalpay.payment.manage.signin.core.impls;
import au.com.royalpay.payment.core.exceptions.EmailException;
import au.com.royalpay.payment.core.exceptions.InvalidShortIdException; import au.com.royalpay.payment.core.exceptions.InvalidShortIdException;
import au.com.royalpay.payment.manage.device.core.DeviceManager; import au.com.royalpay.payment.manage.device.core.DeviceManager;
import au.com.royalpay.payment.manage.management.sysconfig.core.PermissionManager; import au.com.royalpay.payment.manage.management.sysconfig.core.PermissionManager;
import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper; import au.com.royalpay.payment.manage.mappers.system.*;
import au.com.royalpay.payment.manage.mappers.system.ClientMapper;
import au.com.royalpay.payment.manage.mappers.system.ManagerMapper;
import au.com.royalpay.payment.manage.mappers.system.OrgMapper;
import au.com.royalpay.payment.manage.mappers.system.SysCustomerServiceMapper;
import au.com.royalpay.payment.manage.merchants.core.ClientConfigService; import au.com.royalpay.payment.manage.merchants.core.ClientConfigService;
import au.com.royalpay.payment.manage.merchants.core.ClientManager; import au.com.royalpay.payment.manage.merchants.core.ClientManager;
import au.com.royalpay.payment.manage.notice.core.MailService; import au.com.royalpay.payment.manage.notice.core.MailService;
@ -17,36 +14,39 @@ import au.com.royalpay.payment.manage.signin.core.SignInAccountService;
import au.com.royalpay.payment.manage.signin.core.SignInStatusManager; import au.com.royalpay.payment.manage.signin.core.SignInStatusManager;
import au.com.royalpay.payment.manage.signin.events.ClientLoginEvent; import au.com.royalpay.payment.manage.signin.events.ClientLoginEvent;
import au.com.royalpay.payment.manage.signin.events.ManagerLoginEvent; import au.com.royalpay.payment.manage.signin.events.ManagerLoginEvent;
import au.com.royalpay.payment.manage.support.sms.SmsSender;
import au.com.royalpay.payment.manage.system.core.PermissionClientModulesService; import au.com.royalpay.payment.manage.system.core.PermissionClientModulesService;
import au.com.royalpay.payment.tools.env.PlatformEnvironment; import au.com.royalpay.payment.tools.env.PlatformEnvironment;
import au.com.royalpay.payment.tools.env.RequestEnvironment; import au.com.royalpay.payment.tools.env.RequestEnvironment;
import au.com.royalpay.payment.tools.exceptions.BadRequestException; import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import au.com.royalpay.payment.tools.exceptions.ForbiddenException; import au.com.royalpay.payment.tools.exceptions.ForbiddenException;
import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
import au.com.royalpay.payment.tools.locale.LocaleSupport; import au.com.royalpay.payment.tools.locale.LocaleSupport;
import au.com.royalpay.payment.tools.permission.enums.ManagerRole; import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
import au.com.royalpay.payment.tools.threadpool.RoyalThreadPoolExecutor;
import au.com.royalpay.payment.tools.utils.PasswordUtils; import au.com.royalpay.payment.tools.utils.PasswordUtils;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.lang3.time.DateUtils;
import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Cacheable;
import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware; import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.thymeleaf.context.Context; import org.thymeleaf.context.Context;
import org.thymeleaf.spring4.SpringTemplateEngine; import org.thymeleaf.spring4.SpringTemplateEngine;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.TimeUnit;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
/** /**
* account service for sign in Created by yixian on 2016-06-29. * account service for sign in Created by yixian on 2016-06-29.
@ -79,6 +79,15 @@ public class SignInAccountServiceImpl implements SignInAccountService, Applicati
private SysCustomerServiceMapper sysCustomerServiceMapper; private SysCustomerServiceMapper sysCustomerServiceMapper;
@Resource @Resource
private PermissionClientModulesService permissionClientModulesService; private PermissionClientModulesService permissionClientModulesService;
@Resource
private RoyalThreadPoolExecutor royalThreadPoolExecutor;
@Resource
private StringRedisTemplate stringRedisTemplate;
@Resource
private SmsSender smsSender;
private final String RESET_CLIENT_ACCOUNT_PREFIX = "RESET_CLIENT_ACCOUNT";
private final String RESET_MANAGER_ACCOUNT_PREFIX = "RESET_MANAGER_ACCOUNT";
private final int RESET_PASSWORD_TEMPLID = 126978;
private ApplicationEventPublisher publisher; private ApplicationEventPublisher publisher;
private static final List<String> tags = new ArrayList<>(); private static final List<String> tags = new ArrayList<>();
@ -172,6 +181,20 @@ public class SignInAccountServiceImpl implements SignInAccountService, Applicati
return account; return account;
} }
@Override
public JSONObject getClientByUsername(String username) {
JSONObject account = clientAccountMapper.findByUsername(username);
Assert.notNull(account, "Username is not exists!");
return account;
}
@Override
public JSONObject getManagerByUsername(String username) {
JSONObject account = managerMapper.findAvailableByLoginId(username);
Assert.notNull(account, "Username is not exists!");
return account;
}
@Override @Override
@CacheEvict(value = ":login:clients:", key = "''+#accountId") @CacheEvict(value = ":login:clients:", key = "''+#accountId")
public void clearAccountCache(String accountId) { public void clearAccountCache(String accountId) {
@ -454,4 +477,145 @@ public class SignInAccountServiceImpl implements SignInAccountService, Applicati
account.put("is_password_expired", 0); account.put("is_password_expired", 0);
clientAccountMapper.update(account); clientAccountMapper.update(account);
} }
@Override
public void getClientResetPwdCode(JSONObject account,String type) {
if(StringUtils.equals(type,"email") && !account.containsKey("contact_email")){
throw new BadRequestException("Your account is not bound to your mailbox!");
}
if(StringUtils.equals(type,"phone") && !account.containsKey("contact_phone") && !account.containsKey("nation_code")){
throw new BadRequestException("Your account is not bound to your phone!");
}
String accountId = account.getString("account_id");
String codeKeyValueRedis = stringRedisTemplate.boundValueOps(getResetClientAccountKey(accountId)).get();
if(StringUtils.isNotEmpty(codeKeyValueRedis)){
throw new BadRequestException("Captcha has been sent.Please check your "+type+" or try again in 5 minutes.");
}
String codeKeyValue = RandomStringUtils.random(6, false, true);
switch(type){
case "email":
Context ctx = new Context();
ctx.setVariable("account",account);
ctx.setVariable("captcha",codeKeyValue);
final String content = thymeleaf.process("mail/account_reset_email.html", ctx);
royalThreadPoolExecutor.execute(() -> {
try {
mailService.sendEmail("Reset your password", account.getString("contact_email"),
"", content);
} catch (Exception e) {
throw new EmailException("Email Sending Failed", e);
}
});
break;
case "phone":
ArrayList<String> param = new ArrayList<>();
param.add("密码重置服务");
param.add(codeKeyValue);
String expireMin = "5";
param.add(expireMin);
try {
smsSender.getSender().sendWithParam(account.getString("nation_code").trim(), account.getString("contact_phone"), RESET_PASSWORD_TEMPLID, param, "RoyalPay", "", "");
} catch (Exception e) {
e.printStackTrace();
throw new ServerErrorException("Phone number is wrong.Please try again.");
}
break;
}
stringRedisTemplate.boundValueOps(getResetClientAccountKey(accountId)).set(codeKeyValue,5, TimeUnit.MINUTES);
}
@Override
public void getManagerResetPwdCode(JSONObject account, String type) {
if(StringUtils.equals(type,"email") && !account.containsKey("email")){
throw new BadRequestException("Your account is not bound to your mailbox!");
}
if(StringUtils.equals(type,"phone") && !account.containsKey("phone") && !account.containsKey("nation_code")){
throw new BadRequestException("Your account is not bound to your phone!");
}
String managerId = account.getString("manager_id");
String codeKeyValueRedis = stringRedisTemplate.boundValueOps(getResetManagerAccountKey(managerId)).get();
if(StringUtils.isNotEmpty(codeKeyValueRedis)){
throw new BadRequestException("Captcha has been sent.Please check your "+type+" or try again in 5 minutes.");
}
String codeKeyValue = RandomStringUtils.random(6, false, true);
switch(type){
case "email":
Context ctx = new Context();
ctx.setVariable("account",account);
ctx.setVariable("captcha",codeKeyValue);
final String content = thymeleaf.process("mail/account_reset_email.html", ctx);
royalThreadPoolExecutor.execute(() -> {
try {
mailService.sendEmail("Reset your password", account.getString("email"),
"", content);
} catch (Exception e) {
throw new EmailException("Email Sending Failed", e);
}
});
break;
case "phone":
ArrayList<String> param = new ArrayList<>();
param.add("密码重置服务");
param.add(codeKeyValue);
String expireMin = "5";
param.add(expireMin);
try {
smsSender.getSender().sendWithParam(account.getString("nation_code").trim(), account.getString("phone"), RESET_PASSWORD_TEMPLID, param, "RoyalPay", "", "");
} catch (Exception e) {
e.printStackTrace();
throw new ServerErrorException("Phone number is wrong.Please try again.");
}
break;
}
stringRedisTemplate.boundValueOps(getResetManagerAccountKey(managerId)).set(codeKeyValue,5, TimeUnit.MINUTES);
}
@Override
public void verifyClientCaptcha(JSONObject account, String captcha) {
String captchaRedis = stringRedisTemplate.boundValueOps(getResetClientAccountKey(account.getString("account_id"))).get();
if(StringUtils.isBlank(captchaRedis)){
throw new BadRequestException("Captcha has expired");
}
if(StringUtils.equals(captcha,captchaRedis)){
throw new BadRequestException("Captcha is wrong");
}
}
@Override
public void verifyManagerCaptcha(JSONObject account, String captcha) {
String captchaRedis = stringRedisTemplate.boundValueOps(getResetManagerAccountKey(account.getString("manager_id"))).get();
if(StringUtils.isBlank(captchaRedis)){
throw new BadRequestException("Captcha has expired");
}
if(StringUtils.equals(captcha,captchaRedis)){
throw new BadRequestException("Captcha is wrong");
}
}
@Override
public void deleteClientCodeKey(String codekey) {
deleteClientAccountKey(codekey);
}
@Override
public void deleteManagerCodeKey(String codekey) {
deleteManagerAccountKey(codekey);
}
private void deleteClientAccountKey(String codeKey){
stringRedisTemplate.delete(getResetClientAccountKey(codeKey));
}
private void deleteManagerAccountKey(String codeKey){
stringRedisTemplate.delete(getResetManagerAccountKey(codeKey));
}
private String getResetClientAccountKey(String codeKey){
return RESET_CLIENT_ACCOUNT_PREFIX + codeKey;
}
private String getResetManagerAccountKey(String codeKey){
return RESET_MANAGER_ACCOUNT_PREFIX + codeKey;
}
} }

@ -1,5 +1,7 @@
package au.com.royalpay.payment.manage.signin.web; package au.com.royalpay.payment.manage.signin.web;
import au.com.royalpay.payment.manage.merchants.core.ClientManager;
import au.com.royalpay.payment.manage.signin.core.*;
import au.com.royalpay.payment.tools.permission.consumer.ConsumersAction; import au.com.royalpay.payment.tools.permission.consumer.ConsumersAction;
import com.google.code.kaptcha.Producer; import com.google.code.kaptcha.Producer;
@ -10,11 +12,6 @@ import au.com.royalpay.payment.manage.signin.beans.ChangePwdBean;
import au.com.royalpay.payment.manage.signin.beans.FindPwdBean; import au.com.royalpay.payment.manage.signin.beans.FindPwdBean;
import au.com.royalpay.payment.manage.signin.beans.LoginInfo; import au.com.royalpay.payment.manage.signin.beans.LoginInfo;
import au.com.royalpay.payment.manage.signin.beans.TodoNotice; import au.com.royalpay.payment.manage.signin.beans.TodoNotice;
import au.com.royalpay.payment.manage.signin.core.ClientLoginLogRepository;
import au.com.royalpay.payment.manage.signin.core.ManagerLoginLogRepository;
import au.com.royalpay.payment.manage.signin.core.ManagerTodoNoticeProvider;
import au.com.royalpay.payment.manage.signin.core.SignInAccountService;
import au.com.royalpay.payment.manage.signin.core.SignInStatusManager;
import au.com.royalpay.payment.tools.CommonConsts; import au.com.royalpay.payment.tools.CommonConsts;
import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApi; import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApi;
import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApiProvider; import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApiProvider;
@ -69,6 +66,11 @@ public class SignInController {
private Producer captchaProducer; private Producer captchaProducer;
@Resource @Resource
private ManagerTodoNoticeProvider[] managerTodoNoticeProviders; private ManagerTodoNoticeProvider[] managerTodoNoticeProviders;
@Resource
private ClientManager clientManager;
@Resource
private ManagerAccountsService managerAccountsService;
@Resource @Resource
private MpWechatApiProvider mpWechatApiProvider; private MpWechatApiProvider mpWechatApiProvider;
@ -371,4 +373,52 @@ public class SignInController {
HttpUtils.setCookie(response, "CustomerID", statusKey,false); HttpUtils.setCookie(response, "CustomerID", statusKey,false);
return result; return result;
} }
/**
*
* @param username
* @param type emailphone
*/
@RequestMapping(value = "/client/reset_pwd/{type}/{username}", method = RequestMethod.PUT)
public void resetMerchantPwd(@PathVariable("username") String username,@PathVariable("type") String type) {
JSONObject account = signInAccountService.getClientByUsername(username);
signInAccountService.getClientResetPwdCode(account,type);
}
/**
*
* @param info
*/
@RequestMapping(value = "/client/reset_pwd", method = RequestMethod.PUT)
public void resetClientPwd(@RequestBody LoginInfo info) {
JSONObject account = signInAccountService.getClientByUsername(info.getLoginId());
signInAccountService.verifyClientCaptcha(account, info.getVerifyCode());
clientManager.resetAccountPwd(null, null, account.getString("account_id"), info.getPassword());
signInAccountService.deleteClientCodeKey(account.getString("account_id"));
}
/**
*
* @param username
* @param type emailphone
*/
@RequestMapping(value = "/manager/reset_pwd/{type}/{username}", method = RequestMethod.PUT)
public void resetManagerPwd(@PathVariable("username") String username,@PathVariable("type") String type) {
JSONObject account = signInAccountService.getManagerByUsername(username);
signInAccountService.getClientResetPwdCode(account,type);
}
/**
*
* @param info
*/
@RequestMapping(value = "/manager/reset_pwd", method = RequestMethod.PUT)
public void resetManagerPwd(@RequestBody LoginInfo info) {
JSONObject account = signInAccountService.getManagerByUsername(info.getLoginId());
signInAccountService.verifyManagerCaptcha(account, info.getVerifyCode());
managerAccountsService.resetPwd(account, info.getPassword());
signInAccountService.deleteManagerCodeKey(account.getString("manager_id"));
}
} }

@ -2,7 +2,6 @@ package au.com.royalpay.payment.manage.surchargeAccount.core;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import java.util.Date;
import java.util.List; import java.util.List;
public interface SurchargeAccountService { public interface SurchargeAccountService {
@ -11,4 +10,6 @@ public interface SurchargeAccountService {
List<JSONObject> listSettledDatesInMonth(String mon); List<JSONObject> listSettledDatesInMonth(String mon);
void fillMothsSurcharge(JSONObject manager, String detailId);
} }

@ -1,66 +1,132 @@
package au.com.royalpay.payment.manage.surchargeAccount.core.impl; package au.com.royalpay.payment.manage.surchargeAccount.core.impl;
import au.com.royalpay.payment.manage.mappers.system.ClearingDistributedSurchargeMapper; import au.com.royalpay.payment.manage.mappers.system.ClearingDistributedSurchargeMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientsSurchargeAccountsMapper;
import au.com.royalpay.payment.manage.mappers.system.FinancialSurchargeAccountDetailMapper; import au.com.royalpay.payment.manage.mappers.system.FinancialSurchargeAccountDetailMapper;
import au.com.royalpay.payment.manage.surchargeAccount.core.SurchargeAccountService; import au.com.royalpay.payment.manage.surchargeAccount.core.SurchargeAccountService;
import au.com.royalpay.payment.manage.system.core.impl.ClientContractServiceImpl; import au.com.royalpay.payment.manage.system.core.impl.ClientContractServiceImpl;
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import au.com.royalpay.payment.tools.exceptions.ForbiddenException;
import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
import au.com.royalpay.payment.tools.lock.Locker;
import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.time.DateFormatUtils; import org.joda.time.DateTime;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList; import java.math.BigDecimal;
import java.util.Calendar; import java.util.Comparator;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service @Service
public class SurchargeAccountServiceImpl implements SurchargeAccountService{ public class SurchargeAccountServiceImpl implements SurchargeAccountService {
@Resource @Resource
private ClearingDistributedSurchargeMapper clearingDistributedSurchargeMapper; private ClearingDistributedSurchargeMapper clearingDistributedSurchargeMapper;
@Resource @Resource
private FinancialSurchargeAccountDetailMapper financialSurchargeAccountDetailMapper; private FinancialSurchargeAccountDetailMapper financialSurchargeAccountDetailMapper;
@Resource
Logger logger = LoggerFactory.getLogger(ClientContractServiceImpl.class); private Locker locker;
@Resource
private ClientsSurchargeAccountsMapper clientsSurchargeAccountsMapper;
private Logger logger = LoggerFactory.getLogger(ClientContractServiceImpl.class);
@Override @Override
@Transactional @Transactional(rollbackFor = Exception.class)
public void generatorMonthDetail(){ public void generatorMonthDetail() {
Calendar monthCal = Calendar.getInstance(); DateTime dateTo = DateTime.now().withMillisOfDay(0).withDayOfMonth(1);
monthCal.setTime(new Date()); logger.info("===============Start generator surcharge account month detail==============={}", new Date());
monthCal.set(Calendar.DAY_OF_MONTH, 1); List<JSONObject> surchargeTransactions = clearingDistributedSurchargeMapper.listUnClearedByMonth(dateTo);
monthCal.set(Calendar.HOUR_OF_DAY, 0); Map<Integer, List<JSONObject>> clientsDistributed = surchargeTransactions.stream().collect(Collectors.groupingBy(trans -> trans.getInteger("client_id")));
monthCal.set(Calendar.MINUTE, 0); for (Map.Entry<Integer, List<JSONObject>> clientEntry : clientsDistributed.entrySet()) {
monthCal.set(Calendar.SECOND, 0); int clientId = clientEntry.getKey();
Date dateto = monthCal.getTime(); List<JSONObject> surchargeTrans = clientEntry.getValue();
monthCal.set(Calendar.MONTH, (monthCal.get(Calendar.MONTH) - 1)); surchargeTrans.sort(Comparator.comparing(trans -> trans.getDate("create_time")));
Date datefrom = monthCal.getTime(); JSONObject detail = new JSONObject();
detail.put("client_id", clientId);
logger.info("===============Start generator surcharge account month detail===============" + new Date()); detail.put("settle_month", dateTo.plusMonths(-1).toString("yyyy-MM"));
List<JSONObject> thisMonthDetail = clearingDistributedSurchargeMapper.getMonthDetailByClientId(datefrom, dateto); BigDecimal creditAmount = surchargeTrans.stream()
logger.info("this month details : " + thisMonthDetail.toString()); .filter(trans -> "Credit".equals(trans.getString("type")))
.map(trans -> trans.getBigDecimal("amount"))
for (JSONObject detail : thisMonthDetail) { .reduce(BigDecimal::add).orElse(BigDecimal.ZERO);
BigDecimal debitAmount = surchargeTrans.stream()
.filter(trans -> "Debit".equals(trans.getString("type")))
.map(trans -> trans.getBigDecimal("amount"))
.reduce(BigDecimal::add).orElse(BigDecimal.ZERO);
detail.put("credit_amount", creditAmount);
detail.put("debit_amount", debitAmount);
detail.put("total_surcharge", creditAmount.add(debitAmount));
JSONObject lastTrans = surchargeTrans.stream().max(Comparator.comparing(trans -> trans.getDate("create_time")))
.orElse(null);
BigDecimal postBalance;
if (lastTrans == null) {
JSONObject account = clientsSurchargeAccountsMapper.find(clientId);
postBalance = account == null ? BigDecimal.ZERO : account.getBigDecimal("balance");
} else {
postBalance = lastTrans.getBigDecimal("post_balance");
}
detail.put("post_balance", postBalance);
detail.put("send_mail", 0); detail.put("send_mail", 0);
detail.put("wx_send", 0); detail.put("wx_send", 0);
detail.put("settle_month", DateFormatUtils.format(datefrom, "yyyy-MM"));
detail.put("create_time", new Date()); detail.put("create_time", new Date());
detail.put("checkout", 0);
financialSurchargeAccountDetailMapper.save(detail); financialSurchargeAccountDetailMapper.save(detail);
//更新手续费明细中的账单id
surchargeTrans.forEach(trans -> {
trans.put("bill_id", detail.getString("detail_id"));
clearingDistributedSurchargeMapper.update(trans);
});
} }
logger.info("===============generator OVER==============={}", new Date());
logger.info("===============generator OVER===============" + new Date());
} }
@Override @Override
public List<JSONObject> listSettledDatesInMonth(String mon) { public List<JSONObject> listSettledDatesInMonth(String mon) {
List<JSONObject> settledDates = financialSurchargeAccountDetailMapper.listSettlementDatesInMonth(mon); return financialSurchargeAccountDetailMapper.listSettlementDatesInMonth(mon);
}
return settledDates; @Override
public void fillMothsSurcharge(JSONObject manager, String detailId) {
if (!(ManagerRole.ADMIN.hasRole(manager.getIntValue("role")) || ManagerRole.OPERATOR.hasRole(manager.getIntValue("role")) || ManagerRole.FINANCIAL_STAFF.hasRole(manager.getIntValue("role")))) {
throw new ForbiddenException("无法执行平账操作,权限不足");
}
JSONObject detail = financialSurchargeAccountDetailMapper.findByDetailId(detailId);
if (detail.getBooleanValue("checkout")) {
throw new BadRequestException("该记录已结清");
}
if (!locker.lock(detail.getIntValue("client_id") + "_" + detail.getString("settle_month") + "_fill", 120_000)) {
throw new ServerErrorException("Processing task, wait for a moment");
}
try {
JSONObject surchargeAccount = clientsSurchargeAccountsMapper.find(detail.getIntValue("client_id"));
JSONObject transaction = new JSONObject();
transaction.put("client_id", detail.getIntValue("client_id"));
transaction.put("type", "Credit");
transaction.put("bill_id", detailId);
transaction.put("total_surcharge", BigDecimal.ZERO);
transaction.put("tax_amount", BigDecimal.ZERO);
transaction.put("amount", detail.getBigDecimal("debit_amount").negate());
transaction.put("post_balance", surchargeAccount.getBigDecimal("balance").add(transaction.getBigDecimal("amount")));
transaction.put("operation", manager.getString("manager_id"));
transaction.put("create_time", new Date());
transaction.put("remark", detail.getString("settle_month") + "冲正");
clearingDistributedSurchargeMapper.save(transaction);
surchargeAccount.put("balance", surchargeAccount.getBigDecimal("balance").add(transaction.getBigDecimal("amount")));
clientsSurchargeAccountsMapper.update(surchargeAccount);
detail.put("checkout", 1);
detail.put("operator_id", manager.getString("display_name"));
financialSurchargeAccountDetailMapper.update(detail);
} finally {
locker.unlock(detail.getIntValue("client_id") + "_" + detail.getString("settle_month") + "_fill");
}
} }
} }

@ -3,23 +3,17 @@ package au.com.royalpay.payment.manage.surchargeAccount.web;
import au.com.royalpay.payment.manage.permission.manager.ManagerMapping; import au.com.royalpay.payment.manage.permission.manager.ManagerMapping;
import au.com.royalpay.payment.manage.surchargeAccount.core.SurchargeAccountService; import au.com.royalpay.payment.manage.surchargeAccount.core.SurchargeAccountService;
import au.com.royalpay.payment.tools.CommonConsts; import au.com.royalpay.payment.tools.CommonConsts;
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import au.com.royalpay.payment.tools.permission.enums.ManagerRole; import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List; import java.util.List;
@RequestMapping("/sys/surcharge_account") @RequestMapping("/sys/surcharge_account")
@RestController @RestController
public class SurchargeAccountController { public class SurchargeAccountController {
@Resource @Resource
private SurchargeAccountService surchargeAccountService; private SurchargeAccountService surchargeAccountService;
@ -27,4 +21,9 @@ public class SurchargeAccountController {
public List<JSONObject> surchargeAccountSettledDates(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @PathVariable String month) { public List<JSONObject> surchargeAccountSettledDates(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @PathVariable String month) {
return surchargeAccountService.listSettledDatesInMonth(month); return surchargeAccountService.listSettledDatesInMonth(month);
} }
@ManagerMapping(value = "/fill/{detailId}", role = {ManagerRole.ADMIN, ManagerRole.OPERATOR, ManagerRole.FINANCIAL_STAFF}, method = RequestMethod.PUT)
public void fillMothsSurcharge(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @PathVariable String detailId) {
surchargeAccountService.fillMothsSurcharge(manager, detailId);
}
} }

@ -16,10 +16,7 @@ public class SurchargeAccountMonthTask {
@Resource @Resource
private SurchargeAccountService surchargeAccountService; private SurchargeAccountService surchargeAccountService;
@Scheduled(cron = "0 30 23 1 * ?")
@Scheduled(cron = "0 30 6 1 * ?")
public void generateSurchargeAccountDetail() { public void generateSurchargeAccountDetail() {
synchronizedScheduler.executeProcess("manage_task:generateSurchargeAccountMonth", 120_000, () -> synchronizedScheduler.executeProcess("manage_task:generateSurchargeAccountMonth", 120_000, () ->
surchargeAccountService.generatorMonthDetail()); surchargeAccountService.generatorMonthDetail());

@ -4,6 +4,7 @@ import au.com.royalpay.payment.core.beans.OrderStatus;
import au.com.royalpay.payment.core.beans.PayChannel; import au.com.royalpay.payment.core.beans.PayChannel;
import au.com.royalpay.payment.core.exceptions.ParamInvalidException; import au.com.royalpay.payment.core.exceptions.ParamInvalidException;
import au.com.royalpay.payment.tools.defines.TradeType; import au.com.royalpay.payment.tools.defines.TradeType;
import au.com.royalpay.payment.tools.utils.TimeZoneUtils;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -41,19 +42,16 @@ public class TradeLogQuery {
public JSONObject toParams(String timezone) { public JSONObject toParams(String timezone) {
JSONObject params = new JSONObject(); JSONObject params = new JSONObject();
if (timezone != null) {
format.setTimeZone(TimeZone.getTimeZone(timezone));
}
if (datefrom != null) { if (datefrom != null) {
try { try {
params.put("from", format.parse(datefrom)); params.put("from", TimeZoneUtils.formatTime(format.parse(datefrom),"yyyy-MM-dd HH:mm:ss",timezone!=null?timezone:"Australia/Melbourne"));
} catch (ParseException e) { } catch (ParseException e) {
throw new ParamInvalidException("datefrom", "error.payment.valid.invalid_date_format"); throw new ParamInvalidException("datefrom", "error.payment.valid.invalid_date_format");
} }
} }
if (dateto != null) { if (dateto != null) {
try { try {
params.put("to", DateUtils.addDays(format.parse(dateto), 1)); params.put("to", TimeZoneUtils.formatTime(DateUtils.addDays(format.parse(dateto), 1),"yyyy-MM-dd HH:mm:ss",timezone!=null?timezone:"Australia/Melbourne"));
} catch (ParseException e) { } catch (ParseException e) {
throw new ParamInvalidException("dateto", "error.payment.valid.invalid_date_format"); throw new ParamInvalidException("dateto", "error.payment.valid.invalid_date_format");
} }

@ -3,7 +3,6 @@ package au.com.royalpay.payment.manage.tradelog.core;
import au.com.royalpay.payment.manage.tradelog.beans.PreRefundQueryBean; import au.com.royalpay.payment.manage.tradelog.beans.PreRefundQueryBean;
import au.com.royalpay.payment.manage.tradelog.beans.TradeLogQuery; import au.com.royalpay.payment.manage.tradelog.beans.TradeLogQuery;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.PageList;
import org.springframework.ui.Model; import org.springframework.ui.Model;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@ -49,7 +48,7 @@ public interface TradeLogService {
void fullReleasePreAuthorization(JSONObject account, TradeLogQuery query)throws Exception; void fullReleasePreAuthorization(JSONObject account, TradeLogQuery query)throws Exception;
PageList<JSONObject> listPreRefundClients(PreRefundQueryBean params); JSONObject listPreRefundClients(PreRefundQueryBean params);
void exportSettlementLog(TradeLogQuery query, JSONObject partner, HttpServletResponse response); void exportSettlementLog(TradeLogQuery query, JSONObject partner, HttpServletResponse response);

@ -10,16 +10,13 @@ import au.com.royalpay.payment.core.exceptions.InvalidShortIdException;
import au.com.royalpay.payment.core.exceptions.OrderNotMatchException; import au.com.royalpay.payment.core.exceptions.OrderNotMatchException;
import au.com.royalpay.payment.core.exceptions.ParamInvalidException; import au.com.royalpay.payment.core.exceptions.ParamInvalidException;
import au.com.royalpay.payment.manage.mappers.client.ClientCustomersMapper; import au.com.royalpay.payment.manage.mappers.client.ClientCustomersMapper;
import au.com.royalpay.payment.manage.mappers.log.ClearingDetailAnalysisMapper;
import au.com.royalpay.payment.manage.mappers.log.ClearingDetailMapper; import au.com.royalpay.payment.manage.mappers.log.ClearingDetailMapper;
import au.com.royalpay.payment.manage.mappers.log.ClearingLogMapper; import au.com.royalpay.payment.manage.mappers.log.ClearingLogMapper;
import au.com.royalpay.payment.manage.mappers.log.LogSettleMailMapper; import au.com.royalpay.payment.manage.mappers.payment.*;
import au.com.royalpay.payment.manage.mappers.payment.AustracDataMapper; import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper;
import au.com.royalpay.payment.manage.mappers.payment.OrderMapper; import au.com.royalpay.payment.manage.mappers.system.ClientDeviceMapper;
import au.com.royalpay.payment.manage.mappers.payment.RefundAuditionMapper; import au.com.royalpay.payment.manage.mappers.system.CustomerMapper;
import au.com.royalpay.payment.manage.mappers.payment.RefundMapper; import au.com.royalpay.payment.manage.mappers.system.ManagerCustomerRelationAlipayMapper;
import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper;
import au.com.royalpay.payment.manage.mappers.system.*;
import au.com.royalpay.payment.manage.merchants.core.ClientManager; import au.com.royalpay.payment.manage.merchants.core.ClientManager;
import au.com.royalpay.payment.manage.organizations.core.OrgManager; import au.com.royalpay.payment.manage.organizations.core.OrgManager;
import au.com.royalpay.payment.manage.tradelog.beans.PreRefundQueryBean; import au.com.royalpay.payment.manage.tradelog.beans.PreRefundQueryBean;
@ -33,13 +30,11 @@ import au.com.royalpay.payment.tools.permission.enums.PartnerRole;
import au.com.royalpay.payment.tools.utils.CurrencyAmountUtils; import au.com.royalpay.payment.tools.utils.CurrencyAmountUtils;
import au.com.royalpay.payment.tools.utils.PageListUtils; import au.com.royalpay.payment.tools.utils.PageListUtils;
import au.com.royalpay.payment.tools.utils.TimeZoneUtils; import au.com.royalpay.payment.tools.utils.TimeZoneUtils;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.Order; import com.github.miemiedev.mybatis.paginator.domain.Order;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds; import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList; import com.github.miemiedev.mybatis.paginator.domain.PageList;
import com.github.miemiedev.mybatis.paginator.domain.Paginator; import com.github.miemiedev.mybatis.paginator.domain.Paginator;
import net.sf.jasperreports.engine.JRDataSource; import net.sf.jasperreports.engine.JRDataSource;
import net.sf.jasperreports.engine.JasperFillManager; import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint; import net.sf.jasperreports.engine.JasperPrint;
@ -47,34 +42,25 @@ import net.sf.jasperreports.engine.JasperRunManager;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource; import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
import net.sf.jasperreports.engine.export.JRXlsExporter; import net.sf.jasperreports.engine.export.JRXlsExporter;
import net.sf.jasperreports.engine.export.ooxml.JRXlsxExporter; import net.sf.jasperreports.engine.export.ooxml.JRXlsxExporter;
import net.sf.jasperreports.export.ExporterInput; import net.sf.jasperreports.export.*;
import net.sf.jasperreports.export.OutputStreamExporterOutput;
import net.sf.jasperreports.export.SimpleExporterInput;
import net.sf.jasperreports.export.SimpleOutputStreamExporterOutput;
import net.sf.jasperreports.export.SimpleXlsxReportConfiguration;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringEscapeUtils; import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.lang3.time.DateUtils;
import org.apache.poi.hssf.usermodel.HSSFCell; import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFRichTextString;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.HSSFColor; import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.usermodel.*; import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.ui.Model; import org.springframework.ui.Model;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
@ -87,13 +73,11 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream; import java.util.zip.ZipOutputStream;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import static au.com.royalpay.payment.manage.permission.utils.OrgCheckUtils.checkOrgPermission; import static au.com.royalpay.payment.manage.permission.utils.OrgCheckUtils.checkOrgPermission;
@ -118,8 +102,6 @@ public class TradeLogServiceImpl implements TradeLogService {
@Resource @Resource
private ClearingDetailMapper clearingDetailMapper; private ClearingDetailMapper clearingDetailMapper;
@Resource @Resource
private ClearingDetailAnalysisMapper clearingDetailAnalysisMapper;
@Resource
private MpPaymentApi mpPaymentApi; private MpPaymentApi mpPaymentApi;
@Resource @Resource
private TransactionMapper transactionMapper; private TransactionMapper transactionMapper;
@ -134,10 +116,9 @@ public class TradeLogServiceImpl implements TradeLogService {
@Resource @Resource
private ClientCustomersMapper clientCustomersMapper; private ClientCustomersMapper clientCustomersMapper;
@Resource @Resource
LogSettleMailMapper logSettleMailMapper;
@Resource
private ClearingLogMapper clearingLogMapper; private ClearingLogMapper clearingLogMapper;
@Resource
private StringRedisTemplate stringRedisTemplate;
@Resource @Resource
private OrgManager orgManager; private OrgManager orgManager;
@ -1181,7 +1162,6 @@ public class TradeLogServiceImpl implements TradeLogService {
int count = 0; int count = 0;
for (JSONObject object : logs) { for (JSONObject object : logs) {
if (object.getIntValue("clearing_status") == 2 && object.getIntValue("client_id") == client.getIntValue("client_id")) { if (object.getIntValue("clearing_status") == 2 && object.getIntValue("client_id") == client.getIntValue("client_id")) {
System.out.println(object.getString("order_id"));
JSONObject updation = new JSONObject(); JSONObject updation = new JSONObject();
updation.put("transaction_id", object.getString("transaction_id")); updation.put("transaction_id", object.getString("transaction_id"));
updation.put("clearing_status", 0); updation.put("clearing_status", 0);
@ -1199,8 +1179,15 @@ public class TradeLogServiceImpl implements TradeLogService {
} }
@Override @Override
public PageList<JSONObject> listPreRefundClients(PreRefundQueryBean params) { public JSONObject listPreRefundClients(PreRefundQueryBean params) {
return transactionMapper.listPreRefundClients(new PageBounds(params.getPage(), params.getLimit())); String preRefundDataStr = stringRedisTemplate.boundValueOps("payment:pre_refund_data").get();
if (StringUtils.isEmpty(preRefundDataStr)) {
JSONObject preRefundData = PageListUtils.buildPageListResult(transactionMapper.listPreRefundClients(new PageBounds(params.getPage(), params.getLimit())));
stringRedisTemplate.boundValueOps("payment:pre_refund_data").set(preRefundData.toJSONString(), 1, TimeUnit.HOURS);
return preRefundData;
} else {
return JSONObject.parseObject(preRefundDataStr);
}
} }
@Override @Override
@ -1209,6 +1196,9 @@ public class TradeLogServiceImpl implements TradeLogService {
String end = query.getDateto() == null ?"":query.getDateto(); String end = query.getDateto() == null ?"":query.getDateto();
String timezone = partner.getJSONObject("client").getString("timezone"); String timezone = partner.getJSONObject("client").getString("timezone");
JSONObject params = query.toParams(timezone); JSONObject params = query.toParams(timezone);
if (params.get("client_ids") == null) {
params.put("client_id",partner.getJSONObject("client").getString("client_id"));
}
List<JSONObject> clientOrderList = transactionMapper.getClientOrderByTransactionTime(params); List<JSONObject> clientOrderList = transactionMapper.getClientOrderByTransactionTime(params);
List<Integer> clientOrders = new ArrayList<>(clientOrderList.size()); List<Integer> clientOrders = new ArrayList<>(clientOrderList.size());
clientOrderList.parallelStream().forEach(p->{ clientOrderList.parallelStream().forEach(p->{
@ -1233,7 +1223,7 @@ public class TradeLogServiceImpl implements TradeLogService {
int rowNum = 0; int rowNum = 0;
Row row = sheet.createRow(rowNum); Row row = sheet.createRow(rowNum);
String[] title = {"order Id", "Client Order Id", "Transaction Time", "Channel", "Gateway", "Exchange Rate", "Transaction Type", "Currency", String[] title = {"order Id", "Client Order Id", "Transaction Time", "Channel", "Gateway", "Exchange Rate", "Transaction Type", "Currency",
"Input Amount", "Total Amount", "Clearing Amount", "Sruchange Rate", "Settle Amount", "Remark", "Dev No"}; "Input Amount", "Total Amount", "Clearing Amount", "Sruchange Rate", "Settle Amount", "Remark", "Dev No","Company Name","Short Name","Settment Date"};
String[] analysis = {"Total Credit", "Total Debit", "Gross Amount", "Total Charge", "Net Amount"}; String[] analysis = {"Total Credit", "Total Debit", "Gross Amount", "Total Charge", "Net Amount"};
for (int i = 0; i < title.length; i++) { for (int i = 0; i < title.length; i++) {
row.createCell(i, Cell.CELL_TYPE_STRING).setCellValue(title[i]); row.createCell(i, Cell.CELL_TYPE_STRING).setCellValue(title[i]);
@ -1272,6 +1262,9 @@ public class TradeLogServiceImpl implements TradeLogService {
if (device != null) if (device != null)
clientDevId = device.getString("client_dev_id"); clientDevId = device.getString("client_dev_id");
row.createCell(14, Cell.CELL_TYPE_STRING).setCellValue(clientDevId); row.createCell(14, Cell.CELL_TYPE_STRING).setCellValue(clientDevId);
row.createCell(15,Cell.CELL_TYPE_STRING).setCellValue(settle.getString("company_name"));
row.createCell(16,Cell.CELL_TYPE_STRING).setCellValue(settle.getString("short_name"));
row.createCell(17,Cell.CELL_TYPE_STRING).setCellValue(settle.getString("settle_date"));
} }
row = sheet.createRow(++rowNum); row = sheet.createRow(++rowNum);
for (int i = 0; i < analysis.length; i++) { for (int i = 0; i < analysis.length; i++) {
@ -1302,7 +1295,9 @@ public class TradeLogServiceImpl implements TradeLogService {
JSONObject client = partner.getJSONObject("client"); JSONObject client = partner.getJSONObject("client");
String timezone = client.getString("timezone"); String timezone = client.getString("timezone");
JSONObject params = query.toParams(timezone); JSONObject params = query.toParams(timezone);
params.put("client_id",client.getString("client_id")); if (params.get("client_ids") == null) {
params.put("client_id",client.getString("client_id"));
}
List<JSONObject> clientOrderList = transactionMapper.getClientOrderByTransactionTime(params); List<JSONObject> clientOrderList = transactionMapper.getClientOrderByTransactionTime(params);
List<Integer> clientOrders = new ArrayList<>(clientOrderList.size()); List<Integer> clientOrders = new ArrayList<>(clientOrderList.size());
clientOrderList.parallelStream().forEach(p->{ clientOrderList.parallelStream().forEach(p->{

@ -75,8 +75,13 @@ public class RefundServiceImpl implements RefundService, ApplicationEventPublish
@Override @Override
public JSONObject checkOrderRefundAmount(String orderId, JSONObject account) { public JSONObject checkOrderRefundAmount(String orderId, JSONObject account) {
JSONObject order = orderMapper.getOrderDetail(orderId); JSONObject order = orderMapper.getOrderDetail(orderId);
if (account != null) { if (account != null && (account.getIntValue("client_id") != order.getIntValue("client_id"))) {
if (account.getIntValue("client_id") != order.getIntValue("client_id")) { JSONObject client = clientMapper.findClient(account.getIntValue("client_id"));
////父商户全局管理子商户时候,跳过
JSONObject orderTargetClient = clientMapper.findClient(order.getIntValue("client_id"));
if (orderTargetClient.getIntValue("parent_client_id") != account.getIntValue("client_id") && !clientManager.listLevel3Client(account.getIntValue("client_id")).contains(orderTargetClient.getIntValue("parent_client_id"))) {
throw new ForbiddenException("Order is not belong to your shop/merchant");
} else if (!client.getBooleanValue("sub_manage")) {
throw new ForbiddenException("Order is not belong to your shop/merchant"); throw new ForbiddenException("Order is not belong to your shop/merchant");
} }
} }
@ -216,7 +221,8 @@ public class RefundServiceImpl implements RefundService, ApplicationEventPublish
if (type == OperatorType.PARTNER) { if (type == OperatorType.PARTNER) {
int accountClientId = partnerAccount.getIntValue("client_id"); int accountClientId = partnerAccount.getIntValue("client_id");
Assert.isTrue(accountClientId == client.getIntValue("client_id") || accountClientId == client.getIntValue("parent_client_id"), Assert.isTrue(accountClientId == client.getIntValue("client_id") || accountClientId == client.getIntValue("parent_client_id")
||clientManager.listLevel3Client(accountClientId).contains(client.getIntValue("parent_client_id")),
"This order is not belong to current merchant"); "This order is not belong to current merchant");
operator.put("operator_id", partnerAccount.getString("account_id")); operator.put("operator_id", partnerAccount.getString("account_id"));
operator.put("operator", partnerAccount.getString("display_name")); operator.put("operator", partnerAccount.getString("display_name"));

@ -130,6 +130,12 @@ settle.abafile.bank.ANZ.bsb=013006
settle.abafile.bank.ANZ.account-no=837022519 settle.abafile.bank.ANZ.account-no=837022519
settle.abafile.bank.ANZ.account-name=Tunnel Show Pty Ltd settle.abafile.bank.ANZ.account-name=Tunnel Show Pty Ltd
settle.abafile.bank.NAB.manual-sending=true
settle.abafile.bank.NAB.bank=NAB
settle.abafile.bank.NAB.apca=514624
settle.abafile.bank.NAB.bsb=013006
settle.abafile.bank.NAB.account-no=837022519
settle.abafile.bank.NAB.account-name=Tunnel Show Pty Ltd
# 瀚银Secure # 瀚银Secure
app.hanyin-secure.pid=ROYALPAY app.hanyin-secure.pid=ROYALPAY

@ -252,6 +252,26 @@
GROUP by c.sub_merchant_id GROUP by c.sub_merchant_id
</select> </select>
<select id="tradeSubMerchantIdBy60Days" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[
SELECT COUNT(DISTINCT c.client_id) client_count,
c.sub_merchant_id,
c.merchant_id,
tmp.create_time last_trade_time,
datediff(now(), tmp.create_time) diff_days
FROM sys_clients c INNER JOIN (SELECT sub_merchant_id, max(create_time) create_time
FROM pmt_orders where status>=5 and create_time>=#{begin} and create_time<=now()
and channel='Wechat'
GROUP BY sub_merchant_id
) tmp on c.sub_merchant_id = tmp.sub_merchant_id
WHERE
c.sub_merchant_id IS not null AND c.merchant_id IS NOT NULL
AND (c.approve_result = 1 OR c.approve_result= 2) AND c.is_valid = 1
AND c.enable_wechat = 1
]]>
GROUP BY c.sub_merchant_id ORDER BY diff_days desc
</select>
<select id="countClientsSettlementCycle" resultType="com.alibaba.fastjson.JSONObject"> <select id="countClientsSettlementCycle" resultType="com.alibaba.fastjson.JSONObject">
SELECT COUNT(DISTINCT c.client_id) client_count, SELECT COUNT(DISTINCT c.client_id) client_count,
CASE c.clean_days CASE c.clean_days

@ -315,27 +315,39 @@
<![CDATA[ <![CDATA[
select ifnull(sum(CASE WHEN s.channel = 'Alipay' THEN s.total ELSE 0 END),0) alipayamount, select ifnull(sum(CASE WHEN s.channel = 'Alipay' THEN s.total ELSE 0 END),0) alipayamount,
ifnull(sum(CASE WHEN s.channel = 'Alipay' THEN s.orders ELSE 0 END),0) alipay_order_count, ifnull(sum(CASE WHEN s.channel = 'Alipay' THEN s.orders ELSE 0 END),0) alipay_order_count,
ifnull(COUNT(DISTINCT s.client_id,IF(s.channel = 'Alipay',TRUE,NULL)),0) alipay_client_count,
ifnull(sum(CASE WHEN s.channel = 'Bestpay' THEN s.total ELSE 0 END),0) bestpayamount, ifnull(sum(CASE WHEN s.channel = 'Bestpay' THEN s.total ELSE 0 END),0) bestpayamount,
ifnull(sum(CASE WHEN s.channel = 'Bestpay' THEN s.orders ELSE 0 END),0) bestpay_order_count, ifnull(sum(CASE WHEN s.channel = 'Bestpay' THEN s.orders ELSE 0 END),0) bestpay_order_count,
ifnull(COUNT(DISTINCT s.client_id,IF(s.channel = 'Bestpay',TRUE,NULL)),0) bestpay_client_count,
ifnull(sum(CASE WHEN s.channel = 'Wechat' THEN s.total ELSE 0 END),0) wechatamount, ifnull(sum(CASE WHEN s.channel = 'Wechat' THEN s.total ELSE 0 END),0) wechatamount,
ifnull(sum(CASE WHEN s.channel = 'Wechat' THEN s.orders ELSE 0 END),0) wechat_order_count, ifnull(sum(CASE WHEN s.channel = 'Wechat' THEN s.orders ELSE 0 END),0) wechat_order_count,
ifnull(COUNT(DISTINCT s.client_id,IF(s.channel = 'Wechat',TRUE,NULL)),0) wechat_client_count,
ifnull(sum(CASE WHEN s.channel = 'jd' THEN s.total ELSE 0 END),0) jdamount, ifnull(sum(CASE WHEN s.channel = 'jd' THEN s.total ELSE 0 END),0) jdamount,
ifnull(sum(CASE WHEN s.channel = 'jd' THEN s.orders ELSE 0 END),0) jd_order_count, ifnull(sum(CASE WHEN s.channel = 'jd' THEN s.orders ELSE 0 END),0) jd_order_count,
ifnull(COUNT(DISTINCT s.client_id,IF(s.channel = 'jd',TRUE,NULL)),0) jd_client_count,
ifnull(sum(CASE WHEN s.channel = 'AlipayOnline' THEN s.total ELSE 0 END),0) alipayonlineamount, ifnull(sum(CASE WHEN s.channel = 'AlipayOnline' THEN s.total ELSE 0 END),0) alipayonlineamount,
ifnull(sum(CASE WHEN s.channel = 'AlipayOnline' THEN s.orders ELSE 0 END),0) alipayonline_order_count, ifnull(sum(CASE WHEN s.channel = 'AlipayOnline' THEN s.orders ELSE 0 END),0) alipayonline_order_count,
ifnull(COUNT(DISTINCT s.client_id,IF(s.channel = 'AlipayOnline',TRUE,NULL)),0) alipayonline_client_count,
ifnull(sum(CASE WHEN s.channel = 'hf' THEN s.total ELSE 0 END),0) hfamount, ifnull(sum(CASE WHEN s.channel = 'hf' THEN s.total ELSE 0 END),0) hfamount,
ifnull(sum(CASE WHEN s.channel = 'hf' THEN s.orders ELSE 0 END),0) hf_order_count, ifnull(sum(CASE WHEN s.channel = 'hf' THEN s.orders ELSE 0 END),0) hf_order_count,
ifnull(COUNT(DISTINCT s.client_id,IF(s.channel = 'hf',TRUE,NULL)),0) hf_client_count,
ifnull(sum(CASE WHEN s.channel = 'Rpay' THEN s.total ELSE 0 END),0) rpayamount, ifnull(sum(CASE WHEN s.channel = 'Rpay' THEN s.total ELSE 0 END),0) rpayamount,
ifnull(sum(CASE WHEN s.channel = 'Rpay' THEN s.orders ELSE 0 END),0) rpay_order_count, ifnull(sum(CASE WHEN s.channel = 'Rpay' THEN s.orders ELSE 0 END),0) rpay_order_count,
ifnull(COUNT(DISTINCT s.client_id,IF(s.channel = 'Rpay',TRUE,NULL)),0) rpay_client_count,
ifnull(sum(CASE WHEN s.channel = 'Yeepay' THEN s.total ELSE 0 END),0) yeepayamount, ifnull(sum(CASE WHEN s.channel = 'Yeepay' THEN s.total ELSE 0 END),0) yeepayamount,
ifnull(sum(CASE WHEN s.channel = 'Yeepay' THEN s.orders ELSE 0 END),0) yeepay_order_count, ifnull(sum(CASE WHEN s.channel = 'Yeepay' THEN s.orders ELSE 0 END),0) yeepay_order_count,
ifnull(COUNT(DISTINCT s.client_id,IF(s.channel = 'Yeepay',TRUE,NULL)),0) yeepay_client_count,
ifnull(sum(CASE WHEN s.channel = 'LakalaPay' THEN s.total ELSE 0 END),0) lakalapayamount, ifnull(sum(CASE WHEN s.channel = 'LakalaPay' THEN s.total ELSE 0 END),0) lakalapayamount,
ifnull(sum(CASE WHEN s.channel = 'LakalaPay' THEN s.orders ELSE 0 END),0) lakala_order_count ifnull(sum(CASE WHEN s.channel = 'LakalaPay' THEN s.orders ELSE 0 END),0) lakala_order_count,
ifnull(COUNT(DISTINCT s.client_id,IF(s.channel = 'LakalaPay',TRUE,NULL)),0) lakala_client_count,
ifnull(sum(s.orders), 0) all_count,
ifnull(sum(s.total), 0) all_amount,
ifnull(COUNT(DISTINCT s.client_id),0) all_client_count
FROM statistics_customer_order s FROM statistics_customer_order s
LEFT JOIN sys_clients c ON c.client_id = s.client_id and c.is_valid=1 LEFT JOIN sys_clients c ON c.client_id = s.client_id
]]> ]]>
<where> <where>
s.client_id != 0 s.client_id != 0 and c.is_valid=1
<if test="bd_group!=null">and c.client_id in <if test="bd_group!=null">and c.client_id in
(SELECT b.client_id FROM sys_client_bd b (SELECT b.client_id FROM sys_client_bd b
INNER JOIN financial_bd_config c ON c.manager_id=b.bd_id INNER JOIN financial_bd_config c ON c.manager_id=b.bd_id
@ -388,17 +400,50 @@
ifnull(sum(if(s.channel='Alipay'OR s.channel='AlipayOnline',s.orders,0)),0) alipay_order, ifnull(sum(if(s.channel='Alipay'OR s.channel='AlipayOnline',s.orders,0)),0) alipay_order,
ifnull(sum(if(s.channel='Wechat',s.total,0)),0) wechat_toatl, ifnull(sum(if(s.channel='Wechat',s.total,0)),0) wechat_toatl,
ifnull(sum(if(s.channel='Wechat',s.orders,0)),0) wechat_order ifnull(sum(if(s.channel='Wechat',s.orders,0)),0) wechat_order
FROM statistics_customer_order s FROM sys_clients c
RIGHT JOIN sys_clients c ON c.client_id = s.client_id and c.is_valid=1 ]]>
LEFT JOIN (
select ss.client_id,ss.channel,ss.orders,ss.total
from
statistics_customer_order ss
<where>
<if test="begin!=null">and s.date &gt;= #{begin}</if>
<if test="end!=null">and s.date &lt; #{end}</if>
</where>
) s ON c.client_id = s.client_id
<if test="bd_user!=null">
INNER JOIN sys_client_bd d ON c.client_id = d.client_id AND d.bd_id = #{bd_user} and
date(d.start_date)&lt;= #{begin} and (d.end_date is null or date(d.end_date)&gt;= #{end}) and
d.is_valid=1
</if>
where c.is_valid=1
<if test="org_id!=null">and c.org_id = #{org_id}</if>
<if test="state!=null">and c.state = #{state}</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>
<if test="client_monikers!=null">
AND c.client_moniker IN
<foreach collection="client_monikers" open="(" close=")" separator="," item="client_moniker">
#{client_moniker}
</foreach>
</if>
GROUP BY c.client_id ORDER BY total DESC
</select>
<select id="countAreaMerchantTradeAnalysis" resultType="int">
<![CDATA[
SELECT count(distinct c.client_id)
FROM sys_clients c
]]> ]]>
<if test="bd_user!=null"> <if test="bd_user!=null">
INNER JOIN sys_client_bd d ON c.client_id = d.client_id AND d.bd_id = #{bd_user} and INNER JOIN sys_client_bd d ON c.client_id = d.client_id AND d.bd_id = #{bd_user} and
date(d.start_date)&lt;= #{begin} and (d.end_date is null or date(d.end_date)&gt;= #{end}) and date(d.start_date)&lt;= #{begin} and (d.end_date is null or date(d.end_date)&gt;= #{end}) and
d.is_valid=1 d.is_valid=1
</if> </if>
<where> where c.is_valid=1
<if test="begin!=null">and s.date &gt;= #{begin}</if>
<if test="end!=null">and s.date &lt; #{end}</if>
<if test="org_id!=null">and c.org_id = #{org_id}</if> <if test="org_id!=null">and c.org_id = #{org_id}</if>
<if test="state!=null">and c.state = #{state}</if> <if test="state!=null">and c.state = #{state}</if>
<if test="org_id!=null and org_ids==null">and c.org_id=#{org_id}</if> <if test="org_id!=null and org_ids==null">and c.org_id=#{org_id}</if>
@ -410,8 +455,6 @@
#{client_moniker} #{client_moniker}
</foreach> </foreach>
</if> </if>
</where>
GROUP BY s.client_id ORDER BY total DESC
</select> </select>

@ -234,6 +234,36 @@
GROUP BY o.customer_id GROUP BY o.customer_id
</select> </select>
<select id="countCustomersData" resultType="int">
SELECT count(distinct o.customer_id)
FROM pmt_orders o
<where>
<if test="begin!=null">and o.create_time &gt;= #{begin}</if>
<if test="end!=null">and o.create_time &lt; #{end}</if>
<if test="openid_type==0">
AND o.customer_id LIKE 'o32%' and o.channel='Wechat'
</if>
<if test="openid_type==1">
AND o.customer_id LIKE 'obJ%' and o.channel='Wechat'
</if>
<if test="openid_type==2">
and o.channel='Alipay'
</if>
<if test="openid_type==3">
and o.channel='Bestpay'
</if>
<if test="openid_type==4">
AND o.customer_id LIKE 'olH%' and o.channel='Wechat'
</if>
<if test="customer_id!=null">
and o.customer_id=#{customer_id}
</if>
<if test="org_id!=null and org_ids==null">and o.org_id=#{org_id}</if>
<if test="org_ids!=null">and o.org_id in
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if>
</where>
</select>
<select id="listCustomersDataAnalysis" resultType="com.alibaba.fastjson.JSONObject"> <select id="listCustomersDataAnalysis" resultType="com.alibaba.fastjson.JSONObject">
SELECT sum(if(o.status='5',o.customer_payment_amount,0)) total_amount SELECT sum(if(o.status='5',o.customer_payment_amount,0)) total_amount
FROM pmt_orders o FROM pmt_orders o

@ -13,7 +13,8 @@
<select id="getEarliestOrder" resultType="com.alibaba.fastjson.JSONObject"> <select id="getEarliestOrder" resultType="com.alibaba.fastjson.JSONObject">
SELECT * SELECT *
FROM pmt_transactions FROM pmt_transactions
WHERE client_id = #{client_id} AND clearing_amount > 1 WHERE client_id = #{client_id}
AND clearing_amount > 1
ORDER BY transaction_time ORDER BY transaction_time
LIMIT 1; LIMIT 1;
</select> </select>
@ -55,7 +56,8 @@
</if> </if>
<if test="org_id!=null and org_ids==null">and l.org_id=#{org_id}</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 <if test="org_ids!=null">and l.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>
<select id="analysisTotalAmount" resultType="java.math.BigDecimal"> <select id="analysisTotalAmount" resultType="java.math.BigDecimal">
@ -77,7 +79,8 @@
</if> </if>
<if test="org_id!=null and org_ids==null">and l.org_id=#{org_id}</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 <if test="org_ids!=null">and l.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>
<select id="analysisTotalCount" resultType="java.lang.Double"> <select id="analysisTotalCount" resultType="java.lang.Double">
@ -184,7 +187,8 @@
</if> </if>
<if test="org_id!=null and org_ids==null">and o.org_id=#{org_id}</if> <if test="org_id!=null and org_ids==null">and o.org_id=#{org_id}</if>
<if test="org_ids!=null">and o.org_id in <if test="org_ids!=null">and o.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>
<![CDATA[ <![CDATA[
GROUP BY o.order_id ORDER BY aud_fee DESC limit 1 GROUP BY o.order_id ORDER BY aud_fee DESC limit 1
]]> ]]>
@ -244,7 +248,8 @@
<if test="end!=null">and o.create_time &lt;= #{end}</if> <if test="end!=null">and o.create_time &lt;= #{end}</if>
<if test="org_id!=null and org_ids==null">and l.org_id=#{org_id}</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 <if test="org_ids!=null">and l.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 gateway_label GROUP BY gateway_label
</select> </select>
@ -274,7 +279,8 @@
</if> </if>
<if test="org_id!=null and org_ids==null">and l.org_id=#{org_id}</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 <if test="org_ids!=null">and l.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="bd_group!=null">and l.client_id in <if test="bd_group!=null">and l.client_id in
(SELECT b.client_id FROM sys_client_bd b (SELECT b.client_id FROM sys_client_bd b
INNER JOIN financial_bd_config c ON c.manager_id=b.bd_id INNER JOIN financial_bd_config c ON c.manager_id=b.bd_id
@ -311,7 +317,8 @@
</if> </if>
<if test="org_id!=null and org_ids==null">and l.org_id=#{org_id}</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 <if test="org_ids!=null">and l.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>
<![CDATA[ <![CDATA[
GROUP BY date(o.create_time) GROUP BY date(o.create_time)
ORDER BY date(o.create_time) ORDER BY date(o.create_time)
@ -339,7 +346,8 @@
</if> </if>
<if test="org_id!=null and org_ids==null">and l.org_id=#{org_id}</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 <if test="org_ids!=null">and l.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>
<select id="countCustomers" resultType="java.lang.Integer"> <select id="countCustomers" resultType="java.lang.Integer">
<![CDATA[ <![CDATA[
@ -360,7 +368,8 @@
</if> </if>
<if test="org_id!=null and org_ids==null">and o.org_id=#{org_id}</if> <if test="org_id!=null and org_ids==null">and o.org_id=#{org_id}</if>
<if test="org_ids!=null">and o.org_id in <if test="org_ids!=null">and o.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>
<![CDATA[ <![CDATA[
GROUP BY o.customer_id) p GROUP BY o.customer_id) p
]]> ]]>
@ -385,8 +394,9 @@
</if> </if>
<if test="org_id!=null and org_ids==null">and t.org_id=#{org_id}</if> <if test="org_id!=null and org_ids==null">and t.org_id=#{org_id}</if>
<if test="org_ids!=null">and t.org_id in <if test="org_ids!=null">and t.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 test="channel !=null"> and o.channel = #{channel}</if> </if>
<if test="channel !=null">and o.channel = #{channel}</if>
<![CDATA[ <![CDATA[
GROUP BY o.customer_id) p GROUP BY o.customer_id) p
where p.customer_id NOT IN (SELECT o.customer_id FROM pmt_transactions t INNER JOIN pmt_orders o ON o.order_id = t.order_id where p.customer_id NOT IN (SELECT o.customer_id FROM pmt_transactions t INNER JOIN pmt_orders o ON o.order_id = t.order_id
@ -426,8 +436,9 @@
</if> </if>
<if test="org_id!=null and org_ids==null">and t.org_id=#{org_id}</if> <if test="org_id!=null and org_ids==null">and t.org_id=#{org_id}</if>
<if test="org_ids!=null">and t.org_id in <if test="org_ids!=null">and t.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 test="channel !=null"> and o.channel = #{channel}</if> </if>
<if test="channel !=null">and o.channel = #{channel}</if>
<![CDATA[ <![CDATA[
GROUP BY o.customer_id) p GROUP BY o.customer_id) p
where p.customer_id IN (SELECT o.customer_id FROM pmt_transactions t INNER JOIN pmt_orders o ON o.order_id = t.order_id where p.customer_id IN (SELECT o.customer_id FROM pmt_transactions t INNER JOIN pmt_orders o ON o.order_id = t.order_id
@ -451,9 +462,11 @@
<select id="getCountCustomers" resultType="java.lang.Integer"> <select id="getCountCustomers" resultType="java.lang.Integer">
<![CDATA[ <![CDATA[
SELECT count(DISTINCT o.customer_id) FROM pmt_orders o where SELECT count(DISTINCT o.customer_id)
o.create_time < #{date} and o.status>=5 FROM pmt_orders o
]]> where o.create_time < #{date}
and o.status >= 5
]]>
</select> </select>
<select id="getTradePartnersInTypes" resultType="com.alibaba.fastjson.JSONObject"> <select id="getTradePartnersInTypes" resultType="com.alibaba.fastjson.JSONObject">
@ -499,7 +512,8 @@
]]> ]]>
<if test="org_id!=null and org_ids==null">and l.org_id=#{org_id}</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 <if test="org_ids!=null">and l.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="bd_group!=null">and l.client_id in <if test="bd_group!=null">and l.client_id in
(SELECT b.client_id FROM sys_client_bd b (SELECT b.client_id FROM sys_client_bd b
INNER JOIN financial_bd_config c ON c.manager_id=b.bd_id INNER JOIN financial_bd_config c ON c.manager_id=b.bd_id
@ -558,7 +572,8 @@
</if> </if>
<if test="org_id!=null and org_ids==null">and l.org_id=#{org_id}</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 <if test="org_ids!=null">and l.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="bd_group!=null">and l.client_id in <if test="bd_group!=null">and l.client_id in
(SELECT b.client_id FROM sys_client_bd b (SELECT b.client_id FROM sys_client_bd b
INNER JOIN financial_bd_config c ON c.manager_id=b.bd_id INNER JOIN financial_bd_config c ON c.manager_id=b.bd_id
@ -650,18 +665,19 @@
</if> </if>
<if test="org_id!=null and org_ids==null">and ptran.org_id=#{org_id}</if> <if test="org_id!=null and org_ids==null">and ptran.org_id=#{org_id}</if>
<if test="org_ids!=null">and ptran.org_id in <if test="org_ids!=null">and ptran.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>
<select id="listExchangeRates" resultType="com.alibaba.fastjson.JSONObject"> <select id="listExchangeRates" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[ <![CDATA[
SELECT max(t.transaction_time) mx,t.exchange_rate,date(t.transaction_time) `date` SELECT max(t.transaction_time) mx, t.exchange_rate, date(t.transaction_time) `date`
FROM FROM pmt_transactions t
pmt_transactions t WHERE date(t.transaction_time) >= #{begin}
WHERE date(t.transaction_time) >= #{begin} And date(t.transaction_time) <= #{end} AND And date(t.transaction_time) <= #{end}
t.transaction_type ='Credit' AND t.channel =#{channel} AND t.transaction_type = 'Credit'
GROUP BY AND t.channel = #{channel}
date(t.transaction_time) GROUP BY date(t.transaction_time)
order by `date` asc order by `date` asc
]]> ]]>
</select> </select>
@ -693,8 +709,9 @@
</if> </if>
<if test="org_id!=null and org_ids==null">and o.org_id=#{org_id}</if> <if test="org_id!=null and org_ids==null">and o.org_id=#{org_id}</if>
<if test="org_ids!=null">and o.org_id in <if test="org_ids!=null">and o.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>
GROUP BY date , channel ORDER BY date DESC </if>
GROUP BY date , channel ORDER BY date DESC
</select> </select>
<select id="getOrgTransactionAnalysis" resultType="com.alibaba.fastjson.JSONObject"> <select id="getOrgTransactionAnalysis" resultType="com.alibaba.fastjson.JSONObject">
@ -710,7 +727,8 @@
<if test="end!=null">and t.transaction_time &lt;= #{end}</if> <if test="end!=null">and t.transaction_time &lt;= #{end}</if>
<if test="org_id!=null and org_ids==null">and o.org_id=#{org_id}</if> <if test="org_id!=null and org_ids==null">and o.org_id=#{org_id}</if>
<if test="org_ids!=null">and o.org_id in <if test="org_ids!=null">and o.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 o.org_id order by amount desc GROUP BY o.org_id order by amount desc
</select> </select>
@ -749,7 +767,8 @@
<if test="channel!=null">and o.channel=#{channel}</if> <if test="channel!=null">and o.channel=#{channel}</if>
<if test="org_id!=null and org_ids==null">and l.org_id=#{org_id}</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 <if test="org_ids!=null">and l.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>
<select id="countAmountRangeAnalysis" resultType="java.lang.Integer"> <select id="countAmountRangeAnalysis" resultType="java.lang.Integer">
@ -766,7 +785,8 @@
<select id="listAmountRangeOrders" resultType="com.alibaba.fastjson.JSONObject"> <select id="listAmountRangeOrders" resultType="com.alibaba.fastjson.JSONObject">
select c.client_moniker,c.short_name,t.order_id,t.clearing_amount,t.transaction_time,t.channel,o.customer_id,o.customer_ip,o.gateway select
c.client_moniker,c.short_name,t.order_id,t.clearing_amount,t.transaction_time,t.channel,o.customer_id,o.customer_ip,o.gateway
FROM pmt_transactions t FROM pmt_transactions t
LEFT JOIN pmt_orders o on o.order_id=t.order_id LEFT JOIN pmt_orders o on o.order_id=t.order_id
INNER JOIN sys_clients c on c.client_id = t.client_id INNER JOIN sys_clients c on c.client_id = t.client_id
@ -778,6 +798,19 @@
<if test="amount_from!=null">and t.clearing_amount &gt;= #{amount_from}</if> <if test="amount_from!=null">and t.clearing_amount &gt;= #{amount_from}</if>
<if test="amount_to!=null">and t.clearing_amount &lt; #{amount_to}</if> <if test="amount_to!=null">and t.clearing_amount &lt; #{amount_to}</if>
</select> </select>
<select id="countAmountRangeOrders" resultType="int">
select count(1)
FROM pmt_transactions t
<if test="client_moniker!=null">
inner join sys_clients c on c.client_id=t.client_id and c.client_moniker=#{client_moniker}
</if>
where t.transaction_type = 'Credit' and t.refund_id is null and t.channel != 'Settlement'
<if test="begin!=null">and t.transaction_time &gt;= #{begin}</if>
<if test="end!=null">and t.transaction_time &lt;= #{end}</if>
<if test="channel!=null">and t.channel=#{channel}</if>
<if test="amount_from!=null">and t.clearing_amount &gt;= #{amount_from}</if>
<if test="amount_to!=null">and t.clearing_amount &lt; #{amount_to}</if>
</select>
<!--交易金额分析 饼图 --> <!--交易金额分析 饼图 -->
<!--不更改--> <!--不更改-->
@ -804,13 +837,13 @@
<select id="getClientTransaction" resultType="com.alibaba.fastjson.JSONObject"> <select id="getClientTransaction" resultType="com.alibaba.fastjson.JSONObject">
select SELECT
IFNULL(sum(if(l.transaction_type='credit',l.clearing_amount,0)),0) trade_amount, 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, IFNULL(sum(if(l.transaction_type='Debit',l.clearing_amount,0)),0) refund_amount,
ifnull(sum(if(l.transaction_type='Credit',1,0)),0) trade_count, IFNULL(sum(if(l.transaction_type='Credit',1,0)),0) trade_count,
ifnull(sum(if(l.refund_id>0,1,0)),0) refund_orders IFNULL(sum(if(l.transaction_type='Debit',1,0)),0) refund_orders
FROM pmt_transactions l FROM pmt_transactions l
where l.channel!='Settlement' and l.system_generate=0 where l.channel!='Settlement' and l.system_generate=0
<if test="client_ids!=null"> <if test="client_ids!=null">
AND l.client_id IN AND l.client_id IN
<foreach collection="client_ids" open="(" close=")" separator="," item="client_id"> <foreach collection="client_ids" open="(" close=")" separator="," item="client_id">
@ -824,31 +857,39 @@
<if test="end!=null">and l.transaction_time &lt; #{end}</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_id!=null and org_ids==null">and l.org_id=#{org_id}</if>
<if test="org_ids!=null">and l.org_id in <if test="org_ids!=null">and l.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>
<select id="getAreaMerchantAmountAnalysis" resultType="com.alibaba.fastjson.JSONObject"> <select id="getAreaMerchantAmountAnalysis" resultType="com.alibaba.fastjson.JSONObject">
SELECT c.client_moniker,c.short_name,c.bd_user_name,sum(if(t.transaction_type='Credit',t.clearing_amount,0)) total, SELECT c.client_moniker,c.short_name,c.bd_user_name,sum(if(t.transaction_type='Credit',t.clearing_amount,0))
total,
COUNT(DISTINCT t.order_id) orders, COUNT(DISTINCT t.order_id) orders,
c.suburb,c.state,c.royalpayindustry,sum(if(t.channel='Alipay' OR t.channel='AlipayOnline',t.clearing_amount,0)) alipay_total, c.suburb,c.state,c.royalpayindustry,sum(if(t.channel='Alipay' OR t.channel='AlipayOnline',t.clearing_amount,0))
sum(if(t.channel='Alipay'OR t.channel='AlipayOnline',1,0)) alipay_order,sum(if(t.channel='Wechat',t.clearing_amount,0)) wechat_toatl, alipay_total,
sum(if(t.channel='Alipay'OR t.channel='AlipayOnline',1,0))
alipay_order,sum(if(t.channel='Wechat',t.clearing_amount,0)) wechat_toatl,
sum(if(t.channel='Wechat',1,0)) wechat_order sum(if(t.channel='Wechat',1,0)) wechat_order
FROM pmt_transactions t FROM sys_clients c
INNER JOIN pmt_orders ord on ord.order_id = t.order_id LEFT JOIN (select
RIGHT JOIN sys_clients c on t.client_id = c.client_id and c.is_valid = 1 tt.client_id,tt.order_id,tt.transaction_type,tt.clearing_amount, tt.channel
from pmt_transactions tt where tt.transaction_type = 'Credit'
and tt.system_generate=0
<if test="begin!=null">and tt.transaction_time &gt;= #{begin}</if>
<if test="end!=null">and tt.transaction_time &lt;= #{end}</if>
)t on t.client_id = c.client_id
<if test="bd_user!=null"> <if test="bd_user!=null">
INNER JOIN sys_client_bd d ON c.client_id = d.client_id AND d.bd_id = #{bd_user} and INNER JOIN sys_client_bd d ON c.client_id = d.client_id AND d.bd_id = #{bd_user} and
date(d.start_date)&lt;= #{begin} and (d.end_date is null or date(d.end_date)&gt;= #{end}) and date(d.start_date)&lt;= #{begin} and (d.end_date is null or date(d.end_date)&gt;= #{end}) and
d.is_valid=1 d.is_valid=1
</if> </if>
where (t.transaction_type = 'Credit') where (c.is_valid = 1 )
<if test="begin!=null">and t.transaction_time &gt;= #{begin}</if>
<if test="end!=null">and t.transaction_time &lt;= #{end}</if>
<if test="state!=null">and c.state &lt;= #{state}</if> <if test="state!=null">and c.state &lt;= #{state}</if>
<if test="org_id!=null and org_ids==null">and c.org_id=#{org_id}</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 <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>
<if test="client_monikers!=null"> <if test="client_monikers!=null">
AND c.client_moniker IN AND c.client_moniker IN
<foreach collection="client_monikers" open="(" close=")" separator="," item="client_moniker"> <foreach collection="client_monikers" open="(" close=")" separator="," item="client_moniker">
@ -858,6 +899,29 @@
GROUP BY c.client_id order by total desc GROUP BY c.client_id order by total desc
</select> </select>
<select id="countAreaMerchantAmountAnalysis" resultType="int">
SELECT count(distinct c.client_id) clients
FROM sys_clients c
<if test="bd_user!=null">
INNER JOIN sys_client_bd d ON c.client_id = d.client_id AND d.bd_id = #{bd_user} and
date(d.start_date)&lt;= #{begin} and (d.end_date is null or date(d.end_date)&gt;= #{end}) and
d.is_valid=1
</if>
where (c.is_valid = 1)
<if test="state!=null">and c.state &lt;= #{state}</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>
<if test="client_monikers!=null">
AND c.client_moniker IN
<foreach collection="client_monikers" open="(" close=")" separator="," item="client_moniker">
#{client_moniker}
</foreach>
</if>
</select>
<select id="getAreaMerchantAmountByCycle" resultType="com.alibaba.fastjson.JSONObject"> <select id="getAreaMerchantAmountByCycle" resultType="com.alibaba.fastjson.JSONObject">
SELECT c.client_moniker,sum(if(t.transaction_type='Credit',t.clearing_amount,0)) old_total, SELECT c.client_moniker,sum(if(t.transaction_type='Credit',t.clearing_amount,0)) old_total,
@ -868,16 +932,20 @@
RIGHT JOIN sys_clients c on t.client_id = c.client_id and c.is_valid = 1 RIGHT JOIN sys_clients c on t.client_id = c.client_id and c.is_valid = 1
<if test="bd_user!=null"> <if test="bd_user!=null">
INNER JOIN sys_client_bd d ON c.client_id = d.client_id AND d.bd_id = #{bd_user} and INNER JOIN sys_client_bd d ON c.client_id = d.client_id AND d.bd_id = #{bd_user} and
date(d.start_date)&lt;= DATE_ADD(#{begin},INTERVAL -datediff( #{end},#{begin}) DAY) and (d.end_date is null or date(d.end_date)&gt;= #{begin}) and date(d.start_date)&lt;= DATE_ADD(#{begin},INTERVAL -datediff( #{end},#{begin}) DAY) and (d.end_date is null
or date(d.end_date)&gt;= #{begin}) and
d.is_valid=1 d.is_valid=1
</if> </if>
where (t.transaction_type = 'Credit') where (t.transaction_type = 'Credit')
<if test="begin!=null">and t.transaction_time &gt;= DATE_ADD(#{begin},INTERVAL -datediff( #{end},#{begin}) DAY)</if> <if test="begin!=null">and t.transaction_time &gt;= DATE_ADD(#{begin},INTERVAL -datediff( #{end},#{begin})
DAY)
</if>
<if test="end!=null">and t.transaction_time &lt;= #{begin}</if> <if test="end!=null">and t.transaction_time &lt;= #{begin}</if>
<if test="state!=null">and c.state &lt;= #{state}</if> <if test="state!=null">and c.state &lt;= #{state}</if>
<if test="org_id!=null and org_ids==null">and c.org_id=#{org_id}</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 <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>
<if test="client_monikers!=null"> <if test="client_monikers!=null">
AND c.client_moniker IN AND c.client_moniker IN
<foreach collection="client_monikers" open="(" close=")" separator="," item="client_moniker"> <foreach collection="client_monikers" open="(" close=")" separator="," item="client_moniker">
@ -888,9 +956,9 @@
</select> </select>
<select id="getOrderClearAmount" resultType="com.alibaba.fastjson.JSONObject"> <select id="getOrderClearAmount" resultType="com.alibaba.fastjson.JSONObject">
SELECT clearing_amount,o.client_id SELECT clearing_amount, o.client_id
FROM pmt_orders o FROM pmt_orders o
INNER JOIN pmt_transactions pt ON o.order_id = pt.order_id INNER JOIN pmt_transactions pt ON o.order_id = pt.order_id
WHERE o.order_id = #{order_id} WHERE o.order_id = #{order_id}
LIMIT 1; LIMIT 1;
</select> </select>

@ -0,0 +1,11 @@
<?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.client.ClientSubMerchantIdMapper">
<select id="listSubMerchantIdByDiffDays" resultType="com.alibaba.fastjson.JSONObject">
select * from cli_sub_merchant_id
where diff_days >=#{begin}
and diff_days &lt;=#{end}
order by diff_days desc
</select>
</mapper>

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

@ -23,4 +23,11 @@
AND #{amount} >= COMMISSION_START_AMOUNT AND #{amount} >= COMMISSION_START_AMOUNT
AND #{bd_type} = BD_TYPE AND #{bd_type} = BD_TYPE
</select> </select>
<select id="findCurrentCommissionMaxAmount" resultType="java.math.BigDecimal">
SELECT ifnull(MAX(commission_start_amount), 1) max_amount
FROM financial_bd_commission_config
WHERE #{month} >= DATE_FORMAT(START_DATE, '%Y-%m')
AND DATE_FORMAT(END_DATE, '%Y-%m') >= #{month}
AND #{bd_type} = BD_TYPE
</select>
</mapper> </mapper>

@ -82,4 +82,70 @@
AND fbpl.prize_type <> 1 AND fbpl.prize_type <> 1
]]> ]]>
</select> </select>
<select id="findManagerByTeamType" resultType="com.alibaba.fastjson.JSONObject">
SELECT
config.manager_id,config.bd_name,ifnull(total_amount, 0) total_amount,log.kpi_amount
FROM
(
SELECT
*
FROM
financial_bd_config
WHERE
(
manager_id IN (
SELECT
manager_id
FROM
financial_bd_config c
WHERE
bd_type = #{bd_type}
)
OR bd_group IN (
SELECT
manager_id
FROM
financial_bd_config c
WHERE
bd_type = #{bd_type}
)
)
AND get_prize = 1
) config
LEFT JOIN (
SELECT
manager_id,
SUM(total_amount) total_amount,
kpi_amount
FROM
financial_bd_prize_log l
WHERE
record_id = #{record_id} AND prize_type = 0
group by manager_id
) log ON log.manager_id = config.manager_id
</select>
<select id="findManagerByTeamTypeRealTime" resultType="com.alibaba.fastjson.JSONObject">
SELECT
c.bd_name,
c.manager_id,
c.kpi_amount,
sum( o.total * d.proportion ) AS total_amount
FROM
statistics_customer_order o
INNER JOIN sys_clients sc ON sc.client_id = o.client_id
INNER JOIN sys_client_bd d ON o.client_id = d.client_id
INNER JOIN financial_bd_config c ON d.bd_id = c.manager_id
WHERE
sc.org_id = 1
AND o.date &gt;= #{start_date}
AND o.date &lt; #{end_date}
AND d.start_date &lt;= o.date AND d.is_valid = 1 AND ( d.end_date IS NULL OR d.end_date &gt; o.date
)
AND c.get_prize = 1
AND c.bd_group = ( SELECT fc.bd_group FROM financial_bd_config fc WHERE fc.bd_type = #{bd_type} )
GROUP BY
c.manager_id
</select>
</mapper> </mapper>

@ -27,9 +27,13 @@
SELECT SELECT
sum(c.gross_amount) gross_amount, sum(c.total_charge) total_charge, sum(c.gross_amount) gross_amount, sum(c.total_charge) total_charge,
sum(c.royalpay_charge) royalpay_charge, sum(c.org_charge) org_charge, sum(c.royalpay_charge) royalpay_charge, sum(c.org_charge) org_charge,
sum(c.net_charge) net_charge,
sum(c.share_charge) share_charge,
c.commission_type,
o.parent_org_id,
o.name `name`, o.org_id org_id o.name `name`, o.org_id org_id
FROM financial_partner_commission c FROM financial_partner_commission c
INNER JOIN sys_org o ON o.org_id = c.org_id and o.type=0 INNER JOIN sys_org o ON o.org_id = c.org_id
WHERE c.year = #{year} AND c.month = #{month} WHERE c.year = #{year} AND c.month = #{month}
GROUP BY `name` GROUP BY `name`
</select> </select>

@ -139,16 +139,66 @@
</update> </update>
<select id="listOrders" resultType="com.alibaba.fastjson.JSONObject"> <select id="listOrders" resultType="com.alibaba.fastjson.JSONObject">
<if test="bd_user != null">
SELECT temp.* FROM (
</if>
<if test="gateway"> <if test="gateway">
<include refid="gateway_keys"/> <include refid="gateway_keys"/>
</if> </if>
<if test="!gateway"> <if test="!gateway">
<include refid="tradelog_list_keys"/> <include refid="tradelog_list_keys"/>
</if> </if>
FROM pmt_orders o FROM (
select oo.order_id,oo.client_id,oo.total_amount,oo.display_amount,
oo.customer_payment_amount,oo.coupon_payment_amount,oo.currency,
oo.create_time,oo.confirm_time,oo.status,oo.order_description,oo.order_detail,
oo.client_order_id,oo.gateway,oo.channel,oo.pre_authorization,oo.refund_amount,oo.customer_id
from pmt_orders oo
<where>
<if test="search_text != null">
<bind name="name_pattern" value="'%' + search_text + '%'"/>
<if test="text_type == 'remark'">
AND oo.order_detail LIKE #{name_pattern}
</if>
<if test="text_type == 'channel'">
AND oo.channel = #{search_text}
</if>
<if test="text_type == 'order_id'">
AND oo.order_id = #{search_text}
</if>
</if>
<if test="order_id != null">
AND oo.order_id = #{order_id}
</if>
<if test="trade_type != null">
AND oo.gateway IN
<foreach collection="trade_type" item="gateway" open="(" close=")" separator=",">
#{gateway}
</foreach>
</if>
<if test="from != null">
AND oo.create_time &gt;= #{from}
</if>
<if test="to != null">
AND oo.create_time &lt; #{to}
</if>
<if test="date != null">
AND oo.transaction_date = DATE(#{date})
</if>
<if test="dev_id != null">
AND oo.dev_id = #{dev_id}
</if>
<if test="status != null">
AND
<foreach collection="status" item="std" open="(" close=")" separator=" or ">
oo.status = #{std}
</foreach>
</if>
<if test="channel != null">
AND
<foreach collection="channel" item="chan" open="(" close=")" separator=" or ">
oo.channel = #{chan}
</foreach>
</if>
</where>
) o
INNER JOIN sys_clients p INNER JOIN sys_clients p
ON p.client_id = o.client_id ON p.client_id = o.client_id
AND p.is_valid = 1 AND p.is_valid = 1
@ -175,7 +225,7 @@
OR o.order_detail LIKE #{name_pattern} OR o.order_detail LIKE #{name_pattern}
OR t.system_transaction_id = #{search_text} OR t.system_transaction_id = #{search_text}
OR o.channel = #{search_text} OR o.channel = #{search_text}
OR t.order_id = #{search_text} OR o.order_id = #{search_text}
) )
</if> </if>
<if test="text_type == 'client_moniker'"> <if test="text_type == 'client_moniker'">
@ -184,27 +234,9 @@
<if test="text_type == 'client_name'"> <if test="text_type == 'client_name'">
AND p.short_name LIKE #{name_pattern} AND p.short_name LIKE #{name_pattern}
</if> </if>
<if test="text_type == 'remark'">
AND o.order_detail LIKE #{name_pattern}
</if>
<if test="text_type == 'channel'">
AND o.channel = #{search_text}
</if>
<if test="text_type == 'sys_trans_id'"> <if test="text_type == 'sys_trans_id'">
AND t.system_transaction_id = #{search_text} AND t.system_transaction_id = #{search_text}
</if> </if>
<if test="text_type == 'order_id'">
AND o.order_id = #{search_text}
</if>
</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>
</if> </if>
<if test="org_id != null and org_ids == null"> <if test="org_id != null and org_ids == null">
AND p.org_id = #{org_id} AND p.org_id = #{org_id}
@ -215,33 +247,10 @@
#{org_id} #{org_id}
</foreach> </foreach>
</if> </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>
</if>
<if test="channel != null">
AND
<foreach collection="channel" item="chan" open="(" close=")" separator=" or ">
o.channel = #{chan}
</foreach>
</if>
<if test="bd_group != null"> <if test="bd_group != null">
AND p.client_id IN( AND p.client_id IN(
SELECT b.client_id SELECT distinct b.client_id
FROM sys_client_bd b FROM sys_client_bd b
INNER JOIN financial_bd_config c INNER JOIN financial_bd_config c
ON c.manager_id = b.bd_id ON c.manager_id = b.bd_id
@ -254,19 +263,19 @@
</if> </if>
) )
</if> </if>
<if test="bd_user != null">
AND p.client_id in(select distinct d.client_id
from sys_client_bd d
where d.bd_id = #{bd_user}
AND d.is_valid = 1
AND DATE(d.start_date) &lt;= curdate()
AND (d.end_date IS NULL OR DATE(d.end_date) &gt;= curdate()))
</if>
</where> </where>
GROUP BY o.order_id, t.refund_id GROUP BY o.order_id
<if test="bd_user != null">
) temp
INNER JOIN sys_client_bd d
ON temp.client_id = d.client_id
AND d.bd_id = #{bd_user}
AND d.is_valid = 1
AND DATE(d.start_date) &lt;= DATE(now())
AND (d.end_date IS NULL OR DATE(d.end_date) &gt;= DATE(now()))
</if>
</select> </select>
<select id="listOrdersNoPage" resultType="com.alibaba.fastjson.JSONObject"> <select id="listOrdersNoPage" resultType="com.alibaba.fastjson.JSONObject">
<if test="gateway"> <if test="gateway">
<include refid="gateway_keys"/> <include refid="gateway_keys"/>
@ -293,7 +302,7 @@
<if test="from!=null">and o.create_time &gt;= #{from}</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="to!=null">and o.create_time &lt; #{to}</if>
</where> </where>
GROUP BY o.order_id,t.refund_id GROUP BY o.order_id
order by o.create_time order by o.create_time
</select> </select>
@ -371,7 +380,7 @@
</foreach> </foreach>
</if> </if>
</where> </where>
GROUP BY o.order_id,t.refund_id GROUP BY o.order_id
</select> </select>

@ -57,6 +57,42 @@
</if> </if>
</where> </where>
</select> </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 id="listTransFlow" resultType="com.alibaba.fastjson.JSONObject">
SELECT t.*, SELECT t.*,
@ -271,16 +307,16 @@
<if test="to!=null">and t.transaction_time &lt; #{to}</if> <if test="to!=null">and t.transaction_time &lt; #{to}</if>
</select> </select>
<select id="listPreRefundClients" resultType="com.alibaba.fastjson.JSONObject"> <select id="listPreRefundClients" resultType="com.alibaba.fastjson.JSONObject">
SELECT * SELECT sc.client_id,
FROM (SELECT ifnull(sum(if(transaction_type = 'Credit', clearing_amount, -clearing_amount)), 0) amount, sc.client_moniker,
c.client_id client_id, IFNULL(SUM(IF(pt.transaction_type = 'Credit', pt.clearing_amount, -pt.clearing_amount)), 0) amount,
max(t.transaction_time) transation_time, IFNULL(MAX(pt.create_time), sc.approve_time) transation_time
c.client_moniker client_moniker FROM pmt_transactions pt,
FROM pmt_transactions t sys_clients sc
INNER JOIN sys_clients c ON t.client_id = c.client_id WHERE clearing_status = 0
INNER JOIN sys_client_config cc on cc.client_id = c.client_id AND cc.enable_refund_auth = 1 AND pt.client_id = sc.client_id
GROUP BY c.client_id) a GROUP BY client_id
WHERE a.amount &lt; 0 HAVING amount &lt; 0
</select> </select>
<select id="validAnalysis" resultType="com.alibaba.fastjson.JSONObject"> <select id="validAnalysis" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[ <![CDATA[
@ -398,19 +434,41 @@
SELECT c.short_name,SUM(t.clearing_amount) total, 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('MERCHANT',t.system_transaction_id),t.clearing_amount,0)) income,
sum(if(LOCATE('SURCHARGE',t.system_transaction_id),t.clearing_amount,0)) fee sum(if(LOCATE('SURCHARGE',t.system_transaction_id),t.clearing_amount,0)) fee
FROM pmt_transactions t FROM sys_clients c
RIGHT JOIN sys_clients c ON t.client_id = c.client_id ]]>
WHERE t.channel='Settlement' INNER JOIN (select system_transaction_id,clearing_amount,client_id
]]> from pmt_transactions
<if test="from!=null">and t.transaction_time &gt;= #{from}</if> where channel='Settlement'
<if test="to!=null">and t.transaction_time &lt; #{to}</if> <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="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_id!=null and org_ids==null">and c.org_id = #{org_id}</if>
<if test="org_ids!=null">and c.org_id in <if test="org_ids!=null">and c.org_id in
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach> <foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
</if> </if>
</where>
GROUP BY c.client_id 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>
<select id="analysisSettlementLog" resultType="com.alibaba.fastjson.JSONObject"> <select id="analysisSettlementLog" resultType="com.alibaba.fastjson.JSONObject">
@ -563,7 +621,7 @@
ORDER BY trade_date ASC, o.client_id ASC ORDER BY trade_date ASC, o.client_id ASC
</select> </select>
<select id="TotalAmountForBDPrize" resultType="java.math.BigDecimal"> <select id="totalAmountForBDPrize" resultType="java.math.BigDecimal">
<![CDATA[ <![CDATA[
select sum(if(temp.transaction_type = 'Credit', temp.clearing_amount * d.proportion, select sum(if(temp.transaction_type = 'Credit', temp.clearing_amount * d.proportion,
-temp.clearing_amount * d.proportion)) -temp.clearing_amount * d.proportion))
@ -583,7 +641,7 @@
</select> </select>
<select id="TotalAmountForBDLeaderPrize" resultType="java.math.BigDecimal"> <select id="totalAmountForBDLeaderPrize" resultType="java.math.BigDecimal">
SELECT ifnull(sum(t.total), 0) SELECT ifnull(sum(t.total), 0)
total total
FROM statistics_customer_order t FROM statistics_customer_order t
@ -600,7 +658,7 @@
or c.manager_id = #{bd_group}) or c.manager_id = #{bd_group})
</select> </select>
<select id="TotalAmountForSydneyGMPrize" resultType="java.math.BigDecimal"> <select id="totalAmountForSydneyGMPrize" resultType="java.math.BigDecimal">
SELECT ifnull(sum(t.total), 0) SELECT ifnull(sum(t.total), 0)
total total
FROM statistics_customer_order t FROM statistics_customer_order t
@ -1074,10 +1132,15 @@
WHERE WHERE
t.channel = 'Settlement' t.channel = 'Settlement'
]]> ]]>
<if test="client_ids!=null">
AND t.client_id IN AND t.client_id IN
<foreach collection="client_ids" open="(" close=")" separator="," item="clientId"> <foreach collection="client_ids" open="(" close=")" separator="," item="clientId">
#{clientId} #{clientId}
</foreach> </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="from!=null">and t.transaction_time &gt;= #{from}</if>
<if test="to!=null">and t.transaction_time &lt; #{to}</if> <if test="to!=null">and t.transaction_time &lt; #{to}</if>
GROUP BY GROUP BY
@ -1094,13 +1157,16 @@
r.client_refund_id, r.client_refund_id,
o.order_detail, o.order_detail,
o.dev_id, o.dev_id,
a.rate a.rate,
c.company_name,
c.short_name,
date_format(t.clearing_time,'%Y-%m-%d') settle_date
FROM FROM
pmt_transactions t pmt_transactions t
LEFT JOIN pmt_orders o ON o.order_id = t.order_id LEFT JOIN pmt_orders o ON o.order_id = t.order_id
LEFT JOIN pmt_refunds r ON r.refund_id = t.refund_id LEFT JOIN pmt_refunds r ON r.refund_id = t.refund_id
LEFT JOIN log_clearing_detail_analysis a ON a.clearing_detail_id = t.clearing_order LEFT JOIN log_clearing_detail_analysis a ON a.clearing_detail_id = t.clearing_order AND t.channel = a.channel
AND t.channel = a.channel LEFT JOIN sys_clients c ON c.client_id = t.client_id
WHERE t.channel != 'Settlement' WHERE t.channel != 'Settlement'
]]> ]]>
<if test="clientOrders!=null"> <if test="clientOrders!=null">

@ -2,30 +2,40 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <!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.system.ClearingDistributedSurchargeMapper"> <mapper namespace="au.com.royalpay.payment.manage.mappers.system.ClearingDistributedSurchargeMapper">
<select id="getMonthDetailByClientId" resultType="com.alibaba.fastjson.JSONObject"> <select id="getMonthDetailByClientId" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[ SELECT d.client_id,
SELECT d.client_id,c.client_moniker,c.company_name, c.client_moniker,
SUM(IF(d.type='Credit',amount,0)) credit_amount, c.company_name,
SUM(IF(d.type='Debit',amount,0)) debit_amount SUM(IF(d.type = 'Debit', total_surcharge, -total_surcharge)) total_surcharge,
FROM log_clearing_distributed_surcharge d INNER JOIN sys_clients c ON c.client_id=d.client_id SUM(IF(d.type = 'Credit', amount, 0)) credit_amount,
WHERE d.create_time >=#{datefrom} AND d.create_time < #{dateto} SUM(IF(d.type = 'Debit', amount, 0)) debit_amount,
AND c.is_valid= 1 SUM(IF(d.type = 'Debit', total_surcharge, 0)) total_surcharge
GROUP BY d.client_id FROM log_clearing_distributed_surcharge d
]]> INNER JOIN sys_clients c ON c.client_id = d.client_id
WHERE d.create_time >= #{datefrom}
AND #{dateto} > d.create_time
AND c.is_valid = 1
GROUP BY d.client_id
</select> </select>
<select id="findTransactions" resultType="com.alibaba.fastjson.JSONObject"> <select id="findTransactions" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[ SELECT *
SELECT * FROM log_clearing_distributed_surcharge WHERE client_id = #{client_id} FROM log_clearing_distributed_surcharge
ORDER BY create_time DESC WHERE client_id = #{client_id}
]]> ORDER BY create_time DESC
</select> </select>
<select id="findTransactionsByDate" resultType="com.alibaba.fastjson.JSONObject"> <select id="findSurchargeTransactionsByDetailId" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[ SELECT clearing_detail_id, settle_date,total_surcharge,tax_amount, type, amount,create_time,operation,remark
SELECT * FROM log_clearing_distributed_surcharge WHERE client_id = #{client_id} FROM log_clearing_distributed_surcharge
AND year(create_time) = #{year} WHERE client_id = #{client_id}
AND month(create_time) = #{month} AND bill_id = #{detailId}
ORDER BY create_time DESC ORDER BY create_time
]]> DESC
</select>
<select id="listUnClearedByMonth" resultType="com.alibaba.fastjson.JSONObject">
select d.*
from log_clearing_distributed_surcharge d
where d.bill_id is null
and #{dateto} > d.create_time
</select> </select>
</mapper> </mapper>

@ -3,7 +3,8 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd" > "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper"> <mapper namespace="au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper">
<select id="query" resultType="com.alibaba.fastjson.JSONObject"> <select id="query" resultType="com.alibaba.fastjson.JSONObject">
SELECT a.*,c.client_moniker client_moniker FROM sys_accounts a left join sys_clients c on c.client_id = a.client_id SELECT a.*,c.client_moniker client_moniker FROM sys_accounts a left join sys_clients c on c.client_id =
a.client_id
<where> <where>
<if test="clientId!=null"> <if test="clientId!=null">
and a.client_id = #{clientId} and a.client_id = #{clientId}
@ -18,9 +19,13 @@
</where> </where>
</select> </select>
<select id="partnerAndSubPartnerAccounts" resultType="com.alibaba.fastjson.JSONObject"> <select id="partnerAndSubPartnerAccounts" resultType="com.alibaba.fastjson.JSONObject">
SELECT sc.client_moniker, sa.account_id, sa.role, sa.username SELECT sc.client_moniker,sc.short_name,sc.client_id,sc.parent_client_id, sa.account_id, sa.role, sa.username,sa.contact_phone,sa.contact_email,sa.nation_code,sa.wechat_name,sa.wechat_openid,sa.wxapp_openid,
sa.wx_unionid,sa.wechat_headimg,sa.payment_notice,sa.refund_authorised,sa.display_name
FROM sys_clients sc FROM sys_clients sc
INNER JOIN sys_accounts sa ON sc.client_id = sa.client_id AND sa.is_valid = 1 INNER JOIN sys_accounts sa ON sc.client_id = sa.client_id AND sa.is_valid = 1
WHERE sc.client_id = #{client_id} OR sc.parent_client_id = #{client_id} AND sc.is_valid = 1 WHERE sc.is_valid=1 AND
(sc.client_id IN (select client_id from sys_clients where client_id =#{client_id} or parent_client_id=#{client_id})
OR
sc.parent_client_id IN (select client_id from sys_clients where client_id =#{client_id} or parent_client_id=#{client_id}));
</select> </select>
</mapper> </mapper>

@ -113,13 +113,19 @@
locate(c.client_moniker,#{temp_mch_id_source})&lt;=0 locate(c.client_moniker,#{temp_mch_id_source})&lt;=0
</if> </if>
<if test="approving">
and ((c.approve_result=4 and c.open_status is null) or (c.approve_result=3 and c.open_status is null) or
c.open_status=1 or c.open_status=2 or c.open_status=4)
</if>
<if test="quickPass">
and c.source=4
</if>
<if test="greenChannelBdTodo"> <if test="greenChannelBdTodo">
and ((c.source=1 or c.source=2) and c.approve_result=2 and (c.open_status is null or c.open_status=3)) and ((c.source=1 or c.source=2) and c.approve_result=2 and (c.open_status is null or c.open_status=3))
</if> </if>
<if test="search_text!=null"> <if test="search_text!=null">
<bind name="name_pattern" value="'%'+search_text+'%'"/> <bind name="name_pattern" value="'%'+search_text+'%'"/>
<if test="text_type=='all'"> <if test="text_type=='all'">

@ -2,26 +2,35 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <!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.system.FinancialSurchargeAccountDetailMapper"> <mapper namespace="au.com.royalpay.payment.manage.mappers.system.FinancialSurchargeAccountDetailMapper">
<select id="findDetailsByMonth" resultType="com.alibaba.fastjson.JSONObject"> <select id="findDetailsByMonth" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[ SELECT d.*,c.client_moniker,c.short_name,c.company_name
SELECT d.*,c.client_moniker,c.short_name,c.company_name FROM financial_surcharge_account_detail d INNER JOIN sys_clients c ON c.client_id=d.client_id
FROM financial_surcharge_account_detail d INNER JOIN sys_clients c ON c.client_id=d.client_id WHERE d.settle_month = #{settle_month}
WHERE d.settle_month = #{settle_month}
]]>
</select> </select>
<select id="findDetailsByClientId" resultType="com.alibaba.fastjson.JSONObject"> <select id="findDetailsByClientId" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[ SELECT d.*,c.client_moniker,c.short_name,c.company_name
SELECT d.*,c.client_moniker,c.short_name,c.company_name FROM financial_surcharge_account_detail d INNER JOIN sys_clients c ON c.client_id=d.client_id
FROM financial_surcharge_account_detail d INNER JOIN sys_clients c ON c.client_id=d.client_id WHERE d.client_id = #{client_id} ORDER BY create_time desc
WHERE d.client_id = #{client_id} ORDER BY create_time desc
]]>
</select> </select>
<select id="listSettlementDatesInMonth" resultType="com.alibaba.fastjson.JSONObject"> <select id="listSettlementDatesInMonth" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[ SELECT fsad.detail_id,
SELECT d.*,c.client_moniker,c.short_name,c.company_name,s.balance fsad.settle_month,
FROM financial_surcharge_account_detail d INNER JOIN sys_clients c ON c.client_id=d.client_id fsad.total_surcharge,
LEFT JOIN sys_clients_surcharge_accounts s ON s.client_id = d.client_id fsad.credit_amount,
WHERE d.settle_month= #{month} fsad.debit_amount,
ORDER BY s.balance ASC sc.client_moniker,
]]> sc.short_name,
sc.company_name
FROM financial_surcharge_account_detail fsad,
sys_clients sc
WHERE fsad.client_id = sc.client_id
AND fsad.settle_month = #{month}
</select>
<select id="listSettlementDatesByClientId" resultType="com.alibaba.fastjson.JSONObject">
SELECT d.*,c.client_moniker,c.short_name,c.company_name,s.balance
FROM financial_surcharge_account_detail d INNER JOIN sys_clients c ON c.client_id=d.client_id
LEFT JOIN sys_clients_surcharge_accounts s ON s.client_id = d.client_id
WHERE
s.client_id = #{client_id}
ORDER BY s.create_time DESC
</select> </select>
</mapper> </mapper>

@ -14,6 +14,7 @@
SELECT m.manager_id, SELECT m.manager_id,
m.org_id, m.org_id,
m.display_name, m.display_name,
SUBSTRING(m.nation_code,2) nation_code,
m.username,m.role,m.is_valid,m.create_time,m.last_login,o.name org_name, m.username,m.role,m.is_valid,m.create_time,m.last_login,o.name org_name,
m.email,m.phone,m.wechat,m.wx_openid, m.email,m.phone,m.wechat,m.wx_openid,
co.headimg, co.headimg,

@ -0,0 +1,31 @@
<html xmlns:th="http://www.thymeleaf.org" lang="zh">
<b>Dear <span th:text="${account.display_name}"></span> :</b>
<p>
Your account(<span th:text="${account.username}"></span>) is in the process of binding a mailbox, the verification code is <u th:text="${captcha}"></u>,valid within 5 minutes.
</p>
<b>尊敬的<span th:text="${account.display_name}"></span>,您好:</b>
<p>
您的账户(<span th:text="${account.username}"></span>)正在进行绑定邮箱的操作,验证码是<u th:text="${captcha}"></u>5分钟内有效。
</p>
<hr>
<h4>Best Regards</h4>
<p>
<img style="width: 120px;height: 120px"
src="https://mpay.royalpay.com.au/static/images/logo_new.jpg"> <br>
Contact Us<br>
Email:<br>
<a href="mailto:info@royalpay.com.au">info@royalpay.com.au</a> <br>
Tel:<br>
1300 10 77 50<br>
<br>
Service WeChat Account:<br>
<img src="https://mpay.royalpay.com.au/static/images/customer_service.jpg"
style="width: 60px"><br>
Level 14, 383 Kent Street, Sydney NSW 2000<br>
<br>
Level 11, 15 William Street, Melbourne VIC 3000
</p>
<p>Tunnel Show Pty Ltd trading as RoyalPay<br>
Representative of AFSL licensee 448066
</p>
</html>

@ -0,0 +1,34 @@
<html xmlns:th="http://www.thymeleaf.org" lang="zh">
<b>Dear <span th:text="${account.display_name}"></span> :</b>
<p>
You are requesting a password reset service with a verification code of <u th:text="${captcha}"></u>, valid for 5 minutes. Please do not provide this verification code to anyone.
</p>
<p>
<a th:href="${url}">Reset Password ></a>
</p>
<b>尊敬的<span th:text="${account.display_name}"></span>,您好:</b>
<p>
您正在申请密码重置服务,验证码为<u th:text="${captcha}"></u>5分钟内有效请勿向任何人提供此验证码。
</p>
<hr>
<h4>Best Regards</h4>
<p>
<img style="width: 120px;height: 120px"
src="https://mpay.royalpay.com.au/static/images/logo_new.jpg"> <br>
Contact Us<br>
Email:<br>
<a href="mailto:info@royalpay.com.au">info@royalpay.com.au</a> <br>
Tel:<br>
1300 10 77 50<br>
<br>
Service WeChat Account:<br>
<img src="https://mpay.royalpay.com.au/static/images/customer_service.jpg"
style="width: 60px"><br>
Level 14, 383 Kent Street, Sydney NSW 2000<br>
<br>
Level 11, 15 William Street, Melbourne VIC 3000
</p>
<p>Tunnel Show Pty Ltd trading as RoyalPay<br>
Representative of AFSL licensee 448066
</p>
</html>

@ -1003,7 +1003,7 @@ margin-bottom: 10%;"/>
<!--&lt;!&ndash;<i class="fa fa-file-image-o"></i> &ndash;&gt;Marketing Materials--> <!--&lt;!&ndash;<i class="fa fa-file-image-o"></i> &ndash;&gt;Marketing Materials-->
<!--</a>--> <!--</a>-->
<!--</li>--> <!--</li>-->
<li ng-if="(currentUser.client.client_id!=9 && currentUser.client.parent_client_id!=9)&&([1]|withRole)"> <li ng-if="([1]|withRole)">
<a ui-sref="accounts"> <a ui-sref="accounts">
<!--<i class="fa fa-users"></i> -->Accounts <!--<i class="fa fa-users"></i> -->Accounts
</a> </a>

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save