Merge branch 'agreement' into develop

master
eason.qian 7 years ago
commit 7ee71d67e8

@ -237,3 +237,21 @@ alter table statistics_customer_order add column refund_amount DECIMAL(20,2) DEF
ALTER TABLE `financial_bd_prize_log`
MODIFY COLUMN `manager_id` varchar(50) NOT NULL COMMENT 'bd user id' AFTER `record_id`;
ALTER TABLE sys_files DROP INDEX UK_sys_files;
create table sys_clients_contract(
id varchar(50) not null,
client_id int(11) not null,
create_time datetime not null,
expiry_date date not null,
has_sign TINYINT(1) DEFAULT 0 not null,
sign_channel varchar(10) not null ,
sign_account_id varchar(50) DEFAULT null,
signatory varchar(20) DEFAULT null,
PRIMARY key (`id`)
);

@ -4,6 +4,7 @@ import au.com.royalpay.payment.manage.appclient.beans.AppClientBean;
import au.com.royalpay.payment.manage.appclient.beans.AppQueryBean;
import au.com.royalpay.payment.manage.notice.beans.NoticeInfo;
import au.com.royalpay.payment.manage.signin.beans.ChangePwdBean;
import com.alibaba.fastjson.JSONObject;
import java.math.BigDecimal;
@ -109,4 +110,7 @@ public interface RetailAppService {
JSONObject getAd(JSONObject device);
JSONObject getAdDetail(JSONObject device, String article_id);
JSONObject getCheckClientInfo(JSONObject device);
}

@ -24,11 +24,11 @@ import au.com.royalpay.payment.manage.notice.beans.NoticeInfo;
import au.com.royalpay.payment.manage.notice.core.NoticeManage;
import au.com.royalpay.payment.manage.notice.core.NoticePartner;
import au.com.royalpay.payment.manage.pushMessage.APNSMessageHelper;
import au.com.royalpay.payment.manage.pushMessage.JpushMessageHelper;
import au.com.royalpay.payment.manage.pushMessage.bean.AppManagerMessageBuilder;
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.impls.SignInAccountServiceImpl;
import au.com.royalpay.payment.manage.system.core.ClientContractService;
import au.com.royalpay.payment.manage.tradelog.beans.TradeLogQuery;
import au.com.royalpay.payment.tools.cms.RoyalPayCMSSupport;
import au.com.royalpay.payment.tools.device.DeviceSupport;
@ -36,6 +36,7 @@ import au.com.royalpay.payment.tools.device.message.AppMessage;
import au.com.royalpay.payment.tools.device.message.AppMsgSender;
import au.com.royalpay.payment.tools.device.support.DeviceRegister;
import au.com.royalpay.payment.tools.env.PlatformEnvironment;
import au.com.royalpay.payment.tools.env.SysConfigManager;
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import au.com.royalpay.payment.tools.exceptions.ForbiddenException;
import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
@ -52,6 +53,7 @@ import com.github.miemiedev.mybatis.paginator.domain.Order;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.RandomUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
@ -135,7 +137,9 @@ public class RetailAppServiceImp implements RetailAppService {
@Resource
private ClientDeviceTokenMapper clientDeviceTokenMapper;
@Resource
private JpushMessageHelper jpushMessageHelper;
private ClientContractService clientContractService;
@Resource
private SysConfigManager sysConfigManager;
private Map<String, AppMsgSender> senderMap = new HashMap<>();
@ -175,8 +179,8 @@ public class RetailAppServiceImp implements RetailAppService {
setAllClientIds(params, client_id);
params.put("client_id", client_id);
JSONObject res = transactionAnalysisMapper.getClientTransaction(params);
// res.put("trade_amount", transactionAnalysisMapper.analysisTotalAmount(params));
// res.put("trade_count", transactionAnalysisMapper.analysisTotalCount(params));
// res.put("trade_amount", transactionAnalysisMapper.analysisTotalAmount(params));
// res.put("trade_count", transactionAnalysisMapper.analysisTotalCount(params));
// res.put("refund_amount", transactionAnalysisMapper.analysisRefundAmount(params));
res.put("not_settled", transactionAnalysisMapper.analysisNotSettled(params));
res.put("old_customers", transactionAnalysisMapper.countOldCustomers(params));
@ -202,8 +206,8 @@ public class RetailAppServiceImp implements RetailAppService {
params.put("client_id", client_id);
JSONObject res = transactionAnalysisMapper.getClientTransaction(params);
// res.put("trade_amount", transactionAnalysisMapper.analysisTotalAmount(params));
// res.put("trade_count", transactionAnalysisMapper.analysisTotalCount(params));
// res.put("trade_amount", transactionAnalysisMapper.analysisTotalAmount(params));
// res.put("trade_count", transactionAnalysisMapper.analysisTotalCount(params));
res.put("not_settled", transactionAnalysisMapper.analysisNotSettled(params));
return res;
}
@ -640,7 +644,7 @@ public class RetailAppServiceImp implements RetailAppService {
public void sendNoticeMessage(final NoticeInfo notice, final String[] client_monikers) {
for (String clientMoniker : client_monikers) {
JSONObject client = clientManager.getClientInfoByMoniker(clientMoniker);
if(client==null){
if (client == null) {
continue;
}
sendingAppleMsgPool.execute(() -> {
@ -1046,12 +1050,12 @@ public class RetailAppServiceImp implements RetailAppService {
Boolean isUpdate = PlatformEnvironment.getEnv().isAppUpdate(clientType);
String updateContent = PlatformEnvironment.getEnv().getAppUpdateContent(clientType);
int update_type = 0;// 0:不更新 1更新 2强制更新
String versionInt = version.replace(".","");
String newAppVersionInt = newAppVersion.replace(".","");
if (Integer.valueOf(versionInt)<Integer.valueOf(newAppVersionInt)){
String versionInt = version.replace(".", "");
String newAppVersionInt = newAppVersion.replace(".", "");
if (Integer.valueOf(versionInt) < Integer.valueOf(newAppVersionInt)) {
update_type = 1;
if(isUpdate){
update_type=2;
if (isUpdate) {
update_type = 2;
}
}
JSONObject res = new JSONObject();
@ -1337,9 +1341,22 @@ public class RetailAppServiceImp implements RetailAppService {
return res;
}
@Override
public JSONObject getCheckClientInfo(JSONObject device) {
return clientManager.getCheckClientInfo(device.getIntValue("client_id"), device.getString("account_id"));
}
private static boolean mathchLetterorNum(String str) {
String regex = "[A-Za-z0-9]{8}";
return str.matches(regex);
}
private String editContractOrdinaryWaring(String[] key, String sourceStr) {
if (StringUtils.isEmpty(sourceStr) || ArrayUtils.isEmpty(key)) {
return "";
}
for (int i = 0; i < key.length; i++) {
sourceStr = sourceStr.replace("{" + i + "}", key[i]);
}
return sourceStr;
}
}

@ -11,8 +11,10 @@ import au.com.royalpay.payment.manage.bill.core.BillOrderService;
import au.com.royalpay.payment.manage.bill.core.BillService;
import au.com.royalpay.payment.manage.signin.beans.ChangePwdBean;
import au.com.royalpay.payment.manage.signin.core.SignInStatusManager;
import au.com.royalpay.payment.manage.system.core.ClientContractService;
import au.com.royalpay.payment.tools.CommonConsts;
import au.com.royalpay.payment.tools.device.advise.AppClientController;
import au.com.royalpay.payment.tools.env.SysConfigManager;
import au.com.royalpay.payment.tools.exceptions.ForbiddenException;
import au.com.royalpay.payment.tools.http.HttpUtils;
@ -48,6 +50,10 @@ public class RetailAppController {
private BillOrderService billOrderService;
@Resource
private BillService billService;
@Resource
private ClientContractService clientContractService;
@Resource
private SysConfigManager sysConfigManager;
@RequestMapping(value = "/token", method = RequestMethod.PUT)
public void updateDevToken(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @RequestBody JSONObject token) {
@ -59,7 +65,6 @@ public class RetailAppController {
return retailAppService.listSubClients(device);
}
@RequestMapping(value = "/common", method = RequestMethod.GET)
public JSONObject getTransactionCommonData(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, AppQueryBean appQueryBean) {
return retailAppService.getTransactionCommonData(device, appQueryBean);
@ -102,20 +107,21 @@ public class RetailAppController {
return retailAppService.getClientSettlementLog(device, appQueryBean);
}
@RequestMapping("/transaction_log/{clearing_detail_id}")
public JSONObject getTransactionLogByClearingDetailId(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @PathVariable int clearing_detail_id, @RequestParam(required = false) String timezone) {
public JSONObject getTransactionLogByClearingDetailId(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @PathVariable int clearing_detail_id,
@RequestParam(required = false) String timezone) {
return retailAppService.getTransactionLogsByClearingDetailId(device, clearing_detail_id, timezone);
}
/*消息模块begin*/
/* 消息模块begin */
@RequestMapping(value = "/notice", method = RequestMethod.GET)
public JSONObject listNotices(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @RequestParam Map<String, Object> params) {
return retailAppService.listNotices(device, (JSONObject) JSON.toJSON(params));
}
@RequestMapping(value = "/notice/{noticeId}", method = RequestMethod.PUT)
public void updateNoticePartnerHasRead(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @PathVariable String noticeId, @RequestBody JSONObject account_param) {
public void updateNoticePartnerHasRead(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @PathVariable String noticeId,
@RequestBody JSONObject account_param) {
if (!device.getString("account_id").equals(account_param.getString("account_id"))) {
throw new ForbiddenException("You have no permission");
}
@ -126,12 +132,12 @@ public class RetailAppController {
public JSONObject getNoticeId(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @PathVariable String noticeId) {
return retailAppService.getNoticeDetailById(device, noticeId);
}
/*消息模块end*/
/* 消息模块end */
/*我的页面begin*/
/* 我的页面begin */
@RequestMapping(value = "/partner_password/{account_id}", method = RequestMethod.PUT)
public void changePassword(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @PathVariable String account_id, @RequestBody @Valid ChangePwdBean change, Errors errors) {
public void changePassword(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @PathVariable String account_id,
@RequestBody @Valid ChangePwdBean change, Errors errors) {
HttpUtils.handleValidErrors(errors);
retailAppService.changeAccountPassword(device, change, account_id);
}
@ -155,9 +161,9 @@ public class RetailAppController {
public void signOut(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) {
retailAppService.sign_out(device);
}
/*我的页面end*/
/* 我的页面end */
/*活动页面 begin*/
/* 活动页面 begin */
@RequestMapping(value = "/activities", method = RequestMethod.GET)
public JSONObject getActivities(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @RequestParam(defaultValue = "activity_page") String type,
@RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "10") int limit) {
@ -174,7 +180,7 @@ public class RetailAppController {
return retailAppService.checkT1Client(device);
}
/*活动页面 end*/
/* 活动页面 end */
/**
*
@ -192,16 +198,19 @@ public class RetailAppController {
return retailAppService.getClientInfo(device);
}
@RequestMapping(value = "/client/check", method = RequestMethod.GET)
public JSONObject getCheckClientInfo(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) {
return retailAppService.getCheckClientInfo(device);
}
@RequestMapping(value = "/client", method = RequestMethod.PUT)
public void updateClient(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @RequestBody AppClientBean appClientBean) {
retailAppService.updateClient(device, appClientBean);
}
@RequestMapping(value = "/daily_transactions/date/{dateStr}", method = RequestMethod.GET)
public JSONObject listDailyTransactions(@PathVariable String dateStr, @RequestParam(defaultValue = "Australia/Melbourne") String timezone,
@RequestParam(defaultValue = "false") boolean thisdevice,
@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) {
@RequestParam(defaultValue = "false") boolean thisdevice, @ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) {
return retailAppService.listDailyTransactions(dateStr, timezone, thisdevice, device);
}
@ -251,7 +260,8 @@ public class RetailAppController {
}
@RequestMapping(value = "/cash_back/clean_info", method = RequestMethod.GET)
public JSONObject getCashbackCleanInfo(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @RequestParam(value = "client_id", required = false) String client_id) {
public JSONObject getCashbackCleanInfo(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device,
@RequestParam(value = "client_id", required = false) String client_id) {
if (client_id == null) {
client_id = device.getString("client_id");
}
@ -263,11 +273,11 @@ public class RetailAppController {
signInStatusManager.clientQRCodeAppSignIn(device, codeId);
}
/*优惠券Begin*/
/* 优惠券Begin */
@RequestMapping(value = "/coupon/used", method = RequestMethod.GET)
public JSONObject getCoupons(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @RequestParam(value = "page", defaultValue = "1") int page, @RequestParam(value = "limit", defaultValue = "10") int limit) {
public JSONObject getCoupons(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @RequestParam(value = "page", defaultValue = "1") int page,
@RequestParam(value = "limit", defaultValue = "10") int limit) {
return retailAppService.getCoupons(device, page, limit);
}
@ -280,8 +290,7 @@ public class RetailAppController {
public void useCoupon(@PathVariable String coupon_log_id, @ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) {
retailAppService.useCoupon(device, coupon_log_id);
}
/*优惠券End*/
/* 优惠券End */
/**
* 广
@ -296,30 +305,46 @@ public class RetailAppController {
return retailAppService.getAdDetail(device, article_id);
}
@RequestMapping(value = "/bills/{bill_id}",method = RequestMethod.GET)
public JSONObject getBill(@PathVariable("bill_id")String bill_id,@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device){
return billService.getBillDetail(bill_id,device.getIntValue("client_id"));
@RequestMapping(value = "/bills/{bill_id}", method = RequestMethod.GET)
public JSONObject getBill(@PathVariable("bill_id") String bill_id, @ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) {
return billService.getBillDetail(bill_id, device.getIntValue("client_id"));
}
@RequestMapping(value = "/bills/list",method = RequestMethod.GET)
public JSONObject getBills(QueryBillBean queryBillBean,@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device){
return billService.queryBills(device.getIntValue("client_id"),queryBillBean);
@RequestMapping(value = "/bills/list", method = RequestMethod.GET)
public JSONObject getBills(QueryBillBean queryBillBean, @ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) {
return billService.queryBills(device.getIntValue("client_id"), queryBillBean);
}
@RequestMapping(value = "/bills",method = RequestMethod.PUT)
public JSONObject addBill(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device,@RequestBody NewBillBean newBillBean){
JSONObject result = billService.save(device.getIntValue("client_id"),newBillBean);
@RequestMapping(value = "/bills", method = RequestMethod.PUT)
public JSONObject addBill(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @RequestBody NewBillBean newBillBean) {
JSONObject result = billService.save(device.getIntValue("client_id"), newBillBean);
result.remove("bill");
return result;
}
@RequestMapping(value = "/bills/{bill_id}/close",method = RequestMethod.POST)
public void closeBill(@PathVariable("bill_id")String bill_id,@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device){
billService.updateBillStatus(bill_id,"2",device.getIntValue("client_id"));
@RequestMapping(value = "/bills/{bill_id}/close", method = RequestMethod.POST)
public void closeBill(@PathVariable("bill_id") String bill_id, @ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) {
billService.updateBillStatus(bill_id, "2", device.getIntValue("client_id"));
}
@RequestMapping(value = "/bills/orders/{bill_id}",method = RequestMethod.GET)
public JSONObject getBillOrders(@PathVariable("bill_id")String bill_id, QueryBillOrderBean queryBillOrderBean,@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device){
JSONObject result =billOrderService.query(bill_id,device.getIntValue("client_id"),queryBillOrderBean);
result.put("analysis",billOrderService.analysis(bill_id,device.getIntValue("client_id"),queryBillOrderBean));
@RequestMapping(value = "/bills/orders/{bill_id}", method = RequestMethod.GET)
public JSONObject getBillOrders(@PathVariable("bill_id") String bill_id, QueryBillOrderBean queryBillOrderBean,
@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) {
JSONObject result = billOrderService.query(bill_id, device.getIntValue("client_id"), queryBillOrderBean);
result.put("analysis", billOrderService.analysis(bill_id, device.getIntValue("client_id"), queryBillOrderBean));
return result;
}
@RequestMapping(value = "/file/agree", method = RequestMethod.GET)
public JSONObject generateSourceAgreeFile(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) {
JSONObject file = clientContractService.getSourceAgreement(device.getIntValue("client_id"));
JSONObject result = new JSONObject();
result.put("file_url",file.getString("file_value"));
return result;
}
@RequestMapping(value = "/file/agree/confirm", method = RequestMethod.POST)
public void confirmSourceAgreeFile(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) {
clientContractService.confirmSourceAgreement(device.getIntValue("client_id"),device.getString("account_id"),"App");
}
}

@ -25,6 +25,8 @@ public interface ClientFilesMapper {
@AutoSql(type = SqlType.SELECT)
JSONObject findFileById(@Param("file_id") String file_id);
@AutoSql(type = SqlType.SELECT)
JSONObject findFileByClientAndType(@Param("client_id") int client_id, @Param("file_name") String file_name);
List<JSONObject> findFileByClientAndType(@Param("client_id") int client_id, @Param("file_name") String file_name);
void confirmAgreeFile(@Param("client_id") int client_id);
}

@ -36,4 +36,6 @@ public interface ClientRateMapper {
List<JSONObject> listClientRatesForSaving(@Param("client_id") int clientId, @Param("active_time") Date activeTime,
@Param("expiry_time") Date expiryTime, @Param("rate_value") Double rateValue,
@Param("clean_days") Integer cleanDays, @Param("rate_name") String rateName);
List<JSONObject> minExpiryTime(@Param("client_id")int client_id,@Param("rate_name") String rate_name);
}

@ -0,0 +1,26 @@
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.AutoMapper;
import cn.yixblog.support.mybatis.autosql.annotations.AutoSql;
import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
/**
* Created by yishuqian on 06/03/2017.
*/
@AutoMapper(tablename = "sys_clients_contract", pkName = "id")
public interface ClientsContractMapper {
@AutoSql(type = SqlType.INSERT)
void save(JSONObject partner);
@AutoSql(type = SqlType.UPDATE)
void update(JSONObject partner);
JSONObject findByClientId(@Param("client_id") int clientId);
}

@ -1,24 +1,32 @@
package au.com.royalpay.payment.manage.merchants.core;
import au.com.royalpay.payment.channels.wechat.runtime.beans.SubMerchantInfo;
import au.com.royalpay.payment.core.exceptions.EmailException;
import au.com.royalpay.payment.manage.appclient.beans.AppClientBean;
import au.com.royalpay.payment.manage.merchants.beans.*;
import au.com.royalpay.payment.manage.merchants.beans.BankAccountInfo;
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.tools.merchants.beans.QRCodeConfig;
import au.com.royalpay.payment.tools.merchants.beans.UpdateSurchargeDTO;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
/**
* Created by yixian on 2016-06-25.
*/
@ -248,11 +256,11 @@ public interface ClientManager {
void getAgreeFile(String clientMoniker, JSONObject manager) throws Exception;
void getAggregateAgreeFile(String clientMoniker, JSONObject manager) throws Exception;
void getAggregateAgreeFile(String clientMoniker, JSONObject manager,boolean renewal) throws Exception;
void temporaryExportPdf(String clientMoniker, JSONObject manager, HttpServletResponse httpResponse) throws Exception;
void importAgreeFile(String clientMoniker, JSONObject manager, String sourceFile);
void importAgreeFile(String clientMoniker, JSONObject manager, String sourceFile,boolean renewal);
void completeAgree(String clientMoniker, JSONObject manager);
@ -275,4 +283,6 @@ public interface ClientManager {
List<JSONObject> listMerchantIds(String clientMoniker,JSONObject manager);
void clearCacheSubMerchantIdApplices(String clientMoniker);
JSONObject getCheckClientInfo(int client_id,String account_id);
}

@ -14,14 +14,35 @@ import au.com.royalpay.payment.manage.appclient.beans.AppClientBean;
import au.com.royalpay.payment.manage.mappers.financial.FinancialBDConfigMapper;
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.system.*;
import au.com.royalpay.payment.manage.merchants.beans.*;
import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientApplyMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientAuditProcessMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientBDMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientBankAccountMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientDeviceMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientFilesMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientRateMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientsContractMapper;
import au.com.royalpay.payment.manage.mappers.system.CommoditiesMapper;
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.SysWxMerchantApplyMapper;
import au.com.royalpay.payment.manage.merchants.beans.ActivityPosterBuilder;
import au.com.royalpay.payment.manage.merchants.beans.BankAccountInfo;
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.ClientManager;
import au.com.royalpay.payment.manage.notice.core.MailService;
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.SignInAccountService;
import au.com.royalpay.payment.manage.system.core.ClientContractService;
import au.com.royalpay.payment.manage.tradelog.beans.TradeLogQuery;
import au.com.royalpay.payment.tools.connections.attachment.core.AttachmentClient;
import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApi;
@ -29,6 +50,7 @@ import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApiProvider;
import au.com.royalpay.payment.tools.connections.mpsupport.beans.TemplateMessage;
import au.com.royalpay.payment.tools.connections.mpsupport.exceptions.WechatException;
import au.com.royalpay.payment.tools.env.PlatformEnvironment;
import au.com.royalpay.payment.tools.env.RequestEnvironment;
import au.com.royalpay.payment.tools.env.SysConfigManager;
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import au.com.royalpay.payment.tools.exceptions.ForbiddenException;
@ -43,17 +65,23 @@ import au.com.royalpay.payment.tools.merchants.qrboard.QRBoard;
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.PartnerRole;
import au.com.royalpay.payment.tools.utils.*;
import au.com.royalpay.payment.tools.utils.ImageUtils;
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 cn.yixblog.platform.http.HttpRequestGenerator;
import cn.yixblog.platform.http.HttpRequestResult;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.Order;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
@ -66,32 +94,46 @@ import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.context.MessageSource;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.Model;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.RequestMethod;
import org.thymeleaf.context.Context;
import org.thymeleaf.spring4.SpringTemplateEngine;
import javax.annotation.Resource;
import javax.imageio.ImageIO;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.*;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import javax.annotation.Resource;
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 static au.com.royalpay.payment.manage.permission.utils.OrgCheckUtils.checkOrgPermission;
/**
@ -168,6 +210,13 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
@Resource
private FinancialBDConfigMapper financialBDConfigMapper;
@Resource
private ClientsContractMapper clientsContractMapper;
@Resource
private ClientContractService clientContractService;
@Resource
private MessageSource messageSource;
private static final String SOURCE_AGREE_FILE = "source_agree_file";
private static final String CLIENT_BANK_FILE = "client_bank_file";
private static final String CLIENT_ID_FILE = "client_id_file";
@ -1820,7 +1869,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
ByteArrayOutputStream bos = pdu.templetPdfBos(file);
stream = new ByteArrayInputStream(bos.toByteArray());
JSONObject fileRes = attachmentClient.uploadFile(stream, clientMoniker + "_agreement.pdf", false);
importAgreeFile(clientMoniker, manager, fileRes.getString("url"));
importAgreeFile(clientMoniker, manager, fileRes.getString("url"),false);
} catch (Exception e) {
logger.error("合同制作出现问题:", e);
} finally {
@ -1830,7 +1879,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
@Override
@Transactional
public void getAggregateAgreeFile(String clientMoniker, JSONObject manager) throws Exception {
public void getAggregateAgreeFile(String clientMoniker, JSONObject manager,boolean renewal) throws Exception {
JSONObject client = getClientInfoByMoniker(clientMoniker);
if (client == null) {
throw new InvalidShortIdException();
@ -1848,37 +1897,26 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
client.put("company_name_acn", client.getString("company_name") + " (ABN " + client.getString("abn") + ")");
}
JSONObject weChatRate = merchantInfoProvider.clientCurrentRate(client.getIntValue("client_id"), new Date(), "Wechat");
if (weChatRate == null) {
List<JSONObject> clientRate = clientRateMapper.minExpiryTime(client.getIntValue("client_id"), null);
if (CollectionUtils.isEmpty(clientRate)) {
throw new BadRequestException("The Partner's Rate is not config!");
}
client.put("wechat_rate", weChatRate.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN));
client.put("clean", "T+" + weChatRate.getString("clean_days"));
client.put("clean_days", weChatRate.getString("clean_days"));
try {
JSONObject alipayRate = merchantInfoProvider.clientCurrentRate(client.getIntValue("client_id"), new Date(), "Alipay");
if (alipayRate != null) {
client.put("alipay_rate", alipayRate.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN));
}
JSONObject bestPayRate = merchantInfoProvider.clientCurrentRate(client.getIntValue("client_id"), new Date(), "Bestpay");
if (bestPayRate != null) {
client.put("bestpay_rate", bestPayRate.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN));
}
JSONObject jdRate = merchantInfoProvider.clientCurrentRate(client.getIntValue("client_id"), new Date(), "jd");
if (jdRate != null) {
client.put("jd_rate", jdRate.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN));
}
JSONObject alipayOnlineRate = merchantInfoProvider.clientCurrentRate(client.getIntValue("client_id"), new Date(), "AlipayOnline");
if (alipayOnlineRate != null) {
client.put("alipay_online_rate", alipayOnlineRate.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN));
}
} catch (Exception ignored) {
// do nothing
}
clientRate.forEach((p) -> {
String rate_name = p.getString("rate_name");
if ("Wechat".equals(rate_name)) {
client.put("wechat_rate", p.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN));
client.put("clean", "T+" + p.getString("clean_days"));
client.put("clean_days", p.getString("clean_days"));
} else if ("Alipay".equals(rate_name)) {
client.put("alipay_rate", p.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN));
} else if ("Bestpay".equals(rate_name)) {
client.put("bestpay_rate", p.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN));
} else if ("jd".equals(rate_name)) {
client.put("jd_rate", p.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN));
} else if ("AlipayOnline".equals(rate_name)) {
client.put("alipay_online_rate", p.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN));
}
});
JSONObject account = getBankAccountByClientId(client.getIntValue("client_id"));
if (account == null || account.size() <= 0) {
@ -1897,9 +1935,9 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
File file = new File(clientMoniker + "_agreement.pdf");
ByteArrayOutputStream bos = pdu.templetPdfBos(file);
InputStream stream = new ByteArrayInputStream(bos.toByteArray());
JSONObject fileRes = attachmentClient.uploadFile(stream, clientMoniker + "_agreement.pdf", false);
JSONObject fileRes = attachmentClient.uploadFile(stream, clientMoniker + "_" + System.currentTimeMillis() + "_agreement.pdf", false);
if (fileRes != null) {
importAgreeFile(clientMoniker, manager, fileRes.getString("url"));
importAgreeFile(clientMoniker, manager, fileRes.getString("url"),renewal);
}
stream.close();
} catch (Exception e) {
@ -1985,31 +2023,45 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
@Override
@Transactional
public void importAgreeFile(String clientMoniker, JSONObject manager, String sourceFile) {
public void importAgreeFile(String clientMoniker, JSONObject manager, String sourceFile,boolean renewal) {
JSONObject client = getClientInfoByMoniker(clientMoniker);
if (client == null) {
throw new InvalidShortIdException();
}
if (sourceFile != null) {
JSONObject existFile = clientFilesMapper.findFileByClientAndType(client.getIntValue("client_id"), SOURCE_AGREE_FILE);
List<JSONObject> existFiles = clientFilesMapper.findFileByClientAndType(client.getIntValue("client_id"), SOURCE_AGREE_FILE);
JSONObject existFile = null;
if (!CollectionUtils.isEmpty(existFiles)) {
existFile = existFiles.get(0);
}
Date now = new Date();
JSONObject file = new JSONObject();
file.put("file_name", SOURCE_AGREE_FILE);
file.put("file_value", sourceFile);
file.put("client_id", client.getIntValue("client_id"));
file.put("last_update_date", new Date());
file.put("last_update_date", now);
if (manager == null) {
file.put("last_update_by", "System Import");
} else {
file.put("last_update_by", manager.getString("display_name"));
if (existFile == null || existFile.isEmpty()) {
}
JSONObject contract = clientsContractMapper.findByClientId(client.getIntValue("client_id"));
if (contract == null || now.compareTo(contract.getDate("expiry_date")) > 0 || existFile == null || existFile.isEmpty()) {
clientFilesMapper.save(file);
} else {
file.put("file_id", existFile.getString("file_id"));
clientFilesMapper.update(file);
}
if(!renewal) {
client.put("open_status", 2);
clientMapper.update(client);
}
if (manager != null) {
saveClientAuditProcess(client.getIntValue("client_id"), 1, 2, "Compliance合同制作中", manager);
}
}
}
@Override
public void completeAgree(String clientMoniker, JSONObject manager) {
@ -2017,8 +2069,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
if (client == null) {
throw new InvalidShortIdException();
}
JSONObject existFiles = clientFilesMapper.findFileByClientAndType(client.getIntValue("client_id"), SOURCE_AGREE_FILE);
if (existFiles == null || existFiles.isEmpty()) {
List<JSONObject> existFiles = clientFilesMapper.findFileByClientAndType(client.getIntValue("client_id"), SOURCE_AGREE_FILE);
if (CollectionUtils.isEmpty(existFiles)) {
throw new BadRequestException("The Agree File is not Complete!");
}
client.put("open_status", 3);
@ -2077,7 +2129,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
}
checkOrgPermission(manager, client);
if (StringUtils.isNotBlank(master_merchant)) {
//throw new NotFoundException("Invalid Input");
// throw new NotFoundException("Invalid Input");
JSONObject master_client = getClientInfoByMoniker(master_merchant);
if (master_client == null) {
throw new InvalidShortIdException();
@ -2296,7 +2348,12 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
public void updateSysClientFiles(JSONObject manager, int clientId, String fileType, String fileValue) {
if (fileValue != null) {
JSONObject existFile = clientFilesMapper.findFileByClientAndType(clientId, fileType);
List<JSONObject> existFiles = clientFilesMapper.findFileByClientAndType(clientId, fileType);
JSONObject existFile = null;
if (!CollectionUtils.isEmpty(existFiles)) {
existFile = existFiles.get(0);
}
JSONObject fileJson = new JSONObject();
fileJson.put("client_id", clientId);
fileJson.put("last_update_date", new Date());
@ -2984,7 +3041,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
throw new InvalidShortIdException();
}
checkOrgPermission(manager, client);
List<JSONObject> applices = sysWxMerchantApplyMapper.listWxMerchantApplices(client.getInteger("client_id"), new PageBounds(Order.formString("create_time.desc")));
List<JSONObject> applices = sysWxMerchantApplyMapper.listWxMerchantApplices(client.getInteger("client_id"),
new PageBounds(Order.formString("create_time.desc")));
if (!applices.isEmpty()) {
return applices;
} else {
@ -3061,4 +3119,46 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
@CacheEvict(value = ":all_sub_merchant_id_applices:", key = "#clientMoniker")
public void clearCacheSubMerchantIdApplices(String clientMoniker) {
}
@Override
public JSONObject getCheckClientInfo(int client_id,String account_id) {
JSONObject result = clientContractService.getClientContractExpire(client_id);
JSONObject account = clientAccountMapper.findById(account_id);
boolean expire = result.getBoolean("rate_expire");
boolean waring = result.getBoolean("rate_waring");
if (PartnerRole.getRole(account.getIntValue("role")) == PartnerRole.CASHIER) {
result.put("is_ordinary", true);
if (!expire && waring) {
String[] key = { result.getString("expire_days") };
result.put("contract_info", editContractOrdinaryWaring(key, messageSource.getMessage("sys.contract.ordinary.waring", null, RequestEnvironment.getLocale())));
}
if (expire) {
result.put("contract_info", messageSource.getMessage("sys.contract.ordinary.info", null, RequestEnvironment.getLocale()));
}
return result;
} else {
result.put("is_ordinary", false);
if (!expire && waring) {
String[] key = { result.getString("expire_days") };
result.put("contract_info", editContractOrdinaryWaring(key,messageSource.getMessage("sys.contract.waring", null, RequestEnvironment.getLocale())));
}
if (expire) {
result.put("contract_info", messageSource.getMessage("sys.contract.info", null, RequestEnvironment.getLocale()));
}
JSONObject file = clientContractService.getOrGenerateSourceAgreement(account.getIntValue("client_id"),"pc");
result.put("file_url", file.getString("file_value"));
return result;
}
}
private String editContractOrdinaryWaring(String[] key, String sourceStr) {
if (StringUtils.isEmpty(sourceStr) || ArrayUtils.isEmpty(key)) {
return "";
}
for (int i = 0; i < key.length; i++) {
sourceStr = sourceStr.replace("{" + i + "}", key[i]);
}
return sourceStr;
}
}

@ -1,27 +1,45 @@
package au.com.royalpay.payment.manage.merchants.web;
import au.com.royalpay.payment.manage.dev.core.MerchantLocationService;
import au.com.royalpay.payment.manage.merchants.beans.*;
import au.com.royalpay.payment.manage.merchants.beans.BankAccountInfo;
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.permission.manager.ManagerMapping;
import au.com.royalpay.payment.tools.merchants.beans.QRCodeConfig;
import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
import au.com.royalpay.payment.manage.permission.manager.PartnerMapping;
import au.com.royalpay.payment.manage.permission.manager.RequireManager;
import au.com.royalpay.payment.manage.system.core.ClientContractService;
import au.com.royalpay.payment.manage.tradelog.beans.TradeLogQuery;
import au.com.royalpay.payment.manage.tradelog.core.TradeLogService;
import au.com.royalpay.payment.tools.CommonConsts;
import au.com.royalpay.payment.tools.env.SysConfigManager;
import au.com.royalpay.payment.tools.http.HttpUtils;
import au.com.royalpay.payment.tools.merchants.beans.QRCodeConfig;
import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
import com.alibaba.fastjson.JSONObject;
import org.springframework.validation.Errors;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.ModelAttribute;
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 javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
/**
* Created by yixian on 2016-06-27.
*/
@ -35,7 +53,10 @@ public class PartnerManageController {
private TradeLogService tradeLogService;
@Resource
private MerchantLocationService merchantLocationService;
@Resource
private ClientContractService clientContractService;
@Resource
private SysConfigManager sysConfigManager;
@RequestMapping(method = RequestMethod.GET)
@RequireManager(role = {ManagerRole.ADMIN, ManagerRole.BD_USER, ManagerRole.OPERATOR, ManagerRole.SERVANT, ManagerRole.FINANCIAL_STAFF, ManagerRole.DIRECTOR})
public JSONObject listClients(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, PartnerQuery query) {
@ -418,7 +439,7 @@ public class PartnerManageController {
@ManagerMapping(value = "/{clientMoniker}/export/aggregate/agreepdf", method = RequestMethod.GET, role = {ManagerRole.ADMIN, ManagerRole.DIRECTOR, ManagerRole.OPERATOR})
public void exportAggregateAgreeFile(@PathVariable String clientMoniker, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) throws Exception {
clientManager.getAggregateAgreeFile(clientMoniker, manager);
clientManager.getAggregateAgreeFile(clientMoniker, manager,false);
}
@ManagerMapping(value = "/{clientMoniker}/temp/export/pdf", method = RequestMethod.GET, role = {ManagerRole.ADMIN, ManagerRole.BD_USER, ManagerRole.DIRECTOR, ManagerRole.OPERATOR})
@ -428,7 +449,7 @@ public class PartnerManageController {
@ManagerMapping(value = "/{clientMoniker}/import/agreepdf", method = RequestMethod.PUT, role = {ManagerRole.ADMIN, ManagerRole.DIRECTOR, ManagerRole.OPERATOR})
public void importAgreeFile(@PathVariable String clientMoniker, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @RequestBody JSONObject source) throws Exception {
clientManager.importAgreeFile(clientMoniker, manager, source.getString("source_agree_file"));
clientManager.importAgreeFile(clientMoniker, manager, source.getString("source_agree_file"),false);
}
@ManagerMapping(value = "/{clientMoniker}/notify/completeAgree", method = RequestMethod.GET, role = {ManagerRole.ADMIN, ManagerRole.OPERATOR})
@ -502,4 +523,14 @@ public class PartnerManageController {
public List<JSONObject> getMerchantIds(@PathVariable String clientMoniker, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
return clientManager.listMerchantIds(clientMoniker,manager);
}
@PartnerMapping(value = "/check", method = RequestMethod.GET)
public JSONObject getCheckClientInfo(@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject account) {
return clientManager.getCheckClientInfo(account.getIntValue("client_id"),account.getString("account_id"));
}
@PartnerMapping(value = "/agree/confirm", method = RequestMethod.POST)
public void confirmSourceAgreeFile(@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject account) {
clientContractService.confirmSourceAgreement(account.getIntValue("client_id"),account.getString("account_id"),"PC");
}
}

@ -0,0 +1,15 @@
package au.com.royalpay.payment.manage.system.core;
import com.alibaba.fastjson.JSONObject;
public interface ClientContractService {
JSONObject getOrGenerateSourceAgreement(int client_id,String channel);
void confirmSourceAgreement(int client_id,String account_id,String channel);
JSONObject getSourceAgreement(int client_id);
JSONObject getClientContractExpire(int client_id);
}

@ -0,0 +1,189 @@
package au.com.royalpay.payment.manage.system.core.impl;
import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientFilesMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientRateMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientsContractMapper;
import au.com.royalpay.payment.manage.merchants.core.ClientManager;
import au.com.royalpay.payment.manage.system.core.ClientContractService;
import au.com.royalpay.payment.tools.env.SysConfigManager;
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import au.com.royalpay.payment.tools.exceptions.NotFoundException;
import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.time.DateUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
@Service
public class ClientContractServiceImpl implements ClientContractService {
Logger logger = LoggerFactory.getLogger(ClientContractServiceImpl.class);
@Resource
private ClientFilesMapper clientFilesMapper;
@Resource
private ClientManager clientManager;
@Resource
private ClientsContractMapper clientsContractMapper;
@Resource
private ClientRateMapper clientRateMapper;
@Resource
private SysConfigManager sysConfigManager;
@Resource
private ClientAccountMapper clientAccountMapper;
@Override
@Transactional
public JSONObject getOrGenerateSourceAgreement(int client_id,String channel) {
JSONObject client = clientManager.getClientInfo(client_id);
if (client == null) {
throw new NotFoundException("merchant not found");
}
JSONObject expireInfo = getClientContractExpire(client_id);
JSONObject contract = clientsContractMapper.findByClientId(client_id);
Date now = new Date();
if (contract == null || now.compareTo(contract.getDate("expiry_date")) > 0) {
try {
clientManager.getAggregateAgreeFile(client.getString("client_moniker"), null,true);
} catch (Exception e) {
logger.info("App generate PDF failed");
throw new ServerErrorException("System error");
}
List<JSONObject> files = clientFilesMapper.findFileByClientAndType(client_id, "source_agree_file");
saveContract(client_id, now,channel);
return files.get(0);
} else {
List<JSONObject> files = clientFilesMapper.findFileByClientAndType(client_id, "source_agree_file");
JSONObject file = files.get(0);
if (expireInfo.getBoolean("rate_expire")) {
contract.put("create_time", now);
contract.put("expiry_date", DateUtils.addYears(now, 1));
clientsContractMapper.update(contract);
}
return file;
}
}
private void saveContract(int client_id, Date now,String channel) {
JSONObject newContract = new JSONObject();
newContract.put("create_time", now);
newContract.put("expiry_date", DateUtils.addYears(now, 1));
newContract.put("sign_channel", channel);
newContract.put("client_id", client_id);
newContract.put("has_sign", false);
clientsContractMapper.save(newContract);
}
@Override
@Transactional
public void confirmSourceAgreement(int client_id,String account_id,String channel) {
JSONObject client = clientManager.getClientInfo(client_id);
if (client == null) {
throw new NotFoundException("merchant not found");
}
JSONObject rateExpire = getClientContractExpire(client_id);
boolean expire = rateExpire.getBoolean("rate_expire");
boolean waring = rateExpire.getBoolean("rate_waring");
JSONObject contract = clientsContractMapper.findByClientId(client_id);
if (contract == null) {
throw new BadRequestException("generate contract first");
}
if(contract.getBoolean("has_sign")){
return;
}
JSONObject account = clientAccountMapper.findById(account_id);
contract.put("has_sign", 1);
contract.put("sign_account_id",account_id);
contract.put("sign_channel",channel);
contract.put("signatory",account.getString("display_name"));
clientsContractMapper.update(contract);
Date now = new Date();
List<JSONObject> rateInfo = clientRateMapper.minExpiryTime(client_id, null);
if(expire){
rateInfo.forEach((p)->{
p.remove("client_rate_id");
p.put("create_time",now);
p.put("active_time",now);
p.put("update_time",now);
p.put("manager_id","0");
p.put("expiry_time",DateUtils.addYears(now,1));
p.put("manager_name","merchant_"+account_id+"_"+account.getString("display_name"));
clientRateMapper.saveRate(p);
});
}
if(!expire && waring){
rateInfo.forEach((p)->{
p.remove("client_rate_id");
p.put("create_time",now);
p.put("manager_id","0");
p.put("update_time",now);
p.put("manager_name","merchant_"+account_id+"_"+account.getString("display_name"));
p.put("active_time",DateUtils.addDays(p.getDate("expiry_time"),1));
p.put("expiry_time",DateUtils.addYears(p.getDate("active_time"),1));
clientRateMapper.saveRate(p);
});
}
clientManager.setClientTaxInSurcharge(client.getString("client_moniker"),false);
}
@Override
public JSONObject getSourceAgreement(int client_id) {
List<JSONObject> files = clientFilesMapper.findFileByClientAndType(client_id, "source_agree_file");
if (CollectionUtils.isEmpty(files)) {
throw new NotFoundException("Contract not generated");
}
return files.get(0);
}
@Override
public JSONObject getClientContractExpire(int client_id) {
JSONObject client = clientManager.getClientInfo(client_id);
if (client == null) {
throw new NotFoundException("merchant not found please check ID");
}
List<JSONObject> rateInfo = clientRateMapper.minExpiryTime(client_id, null);
JSONObject result = new JSONObject();
if (CollectionUtils.isEmpty(rateInfo)) {
result.put("rate_expire", true);
result.put("rate_waring", true);
return result;
}
result.put("rate_expire", false);
result.put("rate_waring", false);
Date now = new Date();
JSONObject contract = clientsContractMapper.findByClientId(client_id);
if (contract != null && contract.getDate("expiry_date").compareTo(now) > 0 && contract.getBoolean("has_sign")) {
return result;
}
int waringDays = sysConfigManager.getSysConfig().getIntValue("rate_warning_days");
rateInfo.forEach((p) -> {
if (now.compareTo(DateUtils.addDays(p.getDate("expiry_time"),1)) > -1) {
result.put("rate_expire", true);
}
if (DateUtils.addDays(now, waringDays).compareTo(DateUtils.addDays(p.getDate("expiry_time"),1)) > -1) {
result.put("rate_waring", true);
}
});
int expireDay = 0;
long expireSS = (DateUtils.addDays(rateInfo.get(0).getDate("expiry_time"),1).getTime()-now.getTime());
expireDay = (int)expireSS/(1000*60*60*24);
if(expireSS%(1000*60*60*24)>1){
++expireDay;
}
result.put("expire_days",expireDay);
return result;
}
}

@ -0,0 +1 @@
package au.com.royalpay.payment.manage.system;

@ -0,0 +1,16 @@
<?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.system.ClientFilesMapper">
<select id="findFileByClientAndType" resultType="com.alibaba.fastjson.JSONObject">
select * from sys_files
where client_id = #{client_id}
and file_name = #{file_name}
order by last_update_date desc
</select>
<update id="confirmAgreeFile">
update sys_files
set state = 2
where file_name = 'source_agree_file'
and client_id = #{client_id}
</update>
</mapper>

@ -87,4 +87,14 @@
order by update_time desc
]]>
</select>
<select id="minExpiryTime" resultType="com.alibaba.fastjson.JSONObject">
SELECT * FROM
sys_client_rates
WHERE client_id = #{client_id}
AND active_time =
(
SELECT max(active_time) FROM sys_client_rates
WHERE client_id = #{client_id}
)
</select>
</mapper>

@ -0,0 +1,10 @@
<?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.system.ClientsContractMapper">
<select id="findByClientId" resultType="com.alibaba.fastjson.JSONObject">
select * from sys_clients_contract
where client_id = #{client_id}
order by create_time desc
limit 1
</select>
</mapper>

@ -101,3 +101,7 @@ app.label.close=Close
app.label.coupons=Available Coupons
sys.contract.ordinary.info=Dear merchant, your service contract with ROYALPAY has expired. In order not to affect your normal use, please contact your supervisor or use your administrator account as soon as possible for service renewal.
sys.contract.ordinary.waring=Dear merchant, your service contract with ROYALPAY expires in {0} days. In order not to affect your normal use, please contact your supervisor or use your administrator account as soon as possible in order to renew your service contract.
sys.contract.waring=Dear merchant, your service contract with ROYALPAY is due to expire in {0} days. In order not to affect your normal use, please see the latest service agreement for renewal.
sys.contract.info=Dear merchant, your service contract with ROYALPAY has expired. Please check the latest service agreement to renew your contract so as not to affect your normal use.

@ -94,3 +94,8 @@ app.label.remark=备注
app.label.creating-order=...
app.label.close=关闭
app.label.coupons=可用优惠券
sys.contract.ordinary.info=尊敬的商户您与ROYALPAY的服务合同已到期为了不影响您的正常使用请尽快联系您的主管或使用管理员账户登录以便进行服务续约
sys.contract.ordinary.waring=尊敬的商户您与ROYALPAY的服务合同还有{0}天到期,为了不影响您的正常使用,请尽快联系您的主管或使用管理员账户登录以便进行服务续约
sys.contract.waring=尊敬的商户您与ROYALPAY的服务合同还有{0}天到期,为了不影响您的正常使用,请查看最新服务协议进行续约。
sys.contract.info=尊敬的商户您与ROYALPAY的服务合同已到期为了不影响您的正常使用请查看最新服务协议进行续约。

@ -107,13 +107,58 @@ define(['angular', 'angularSanitize', 'angularAnimate', 'angularMessages', 'uiRo
$scope.loadPartnerNotice();
})
};
$scope.showAG = function (ag) {
$uibModal.open({
templateUrl: '/static/commons/templates/ag_detail.html',
controller: 'agreementDetailCtrl',
resolve: {
ag: ag
},
size: 'lg',
type:'info',
backdrop:'static',
keyboard:false
}).result.then(function () {
// $scope.loadPartnerNotice();
})
};
$scope.getAgStatus = function () {
$http.get('/sys/partners/check').then(function (resp) {
// $scope.rate_expire = resp.data.rate_expire;
$scope.rate_waring = resp.data.rate_waring;
// $scope.file_url = resp.data.file_url;
if (resp.data.is_ordinary){
if($scope.rate_waring){
commonDialog.alert({
title: 'Contract expiration notice',
content: resp.data.contract_info,
size:'lg',
type:'info'
}).then(function () {
if (resp.data.rate_expire){
location.href = 'login.html'
}
})
}
}else {
if($scope.rate_waring){
$scope.showAG(resp.data);
}
}
});
};
$scope.getAgStatus();
$scope.refundNotice = {counts: 0};
$scope.openRefundNotice = false;
$scope.showRefundNotice = function () {
$http.get('/api/payment/v1.0/refund/json/auditions').then(function (resp) {
$scope.refundNotice.counts = resp.data.counts;
});
}
};
$scope.showRefundNotice();
$scope.toggleOpenRefundNotice = function () {
var openRefundNotice = angular.copy($scope.openRefundNotice);
@ -276,6 +321,21 @@ define(['angular', 'angularSanitize', 'angularAnimate', 'angularMessages', 'uiRo
}
}]);
app.controller('agreementDetailCtrl', ['$scope', '$http', '$sce', 'ag', function ($scope, $http, $sce, ag) {
$scope.ag = angular.copy(ag);
$scope.agreeCheck = false;
$scope.agree = function () {
$http.post('/sys/partners/agree/confirm').then(function () {
$scope.$close();
}, function (resp) {
commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'});
})
};
$scope.notAgree = function () {
window.location.href = "https://mpay.royalpay.com.au";
}
}]);
app.controller('changePwdCtrl', ['$scope', '$http', function ($scope, $http) {
$scope.formData = {};
$scope.submit = function (form) {
@ -508,6 +568,11 @@ define(['angular', 'angularSanitize', 'angularAnimate', 'angularMessages', 'uiRo
return roles.indexOf($rootScope.currentUser.role) >= 0;
}
}]);
app.filter("trustUrl", ['$sce', function ($sce) {
return function (recordingUrl) {
return $sce.trustAsResourceUrl(recordingUrl);
};
}]);
app.constant('uiDatetimePickerConfig', {
dateFormat: 'yyyy-MM-dd HH:mm',

@ -0,0 +1,22 @@
<div class="modal-header bg-green">
<h4 style="text-align: center">合同到期续签通知</h4>
<h5 style="text-align: center"><span style="color:lightgrey">({{ag.contract_info}})</span></h5>
</div>
<div class="modal-body">
<div class="row">
<div class="col-xs-12">
<embed ng-src="{{ag.file_url|trustUrl}}" type="application/pdf" width="100%" height="500px">
</div>
</div>
</div>
<div class="modal-footer">
<div class="form-inline">
<label class="checkbox" style="float: left">
<input type="checkbox" ng-model="agreeCheck"> 我已阅读完合同内容,并同意相关条款
</label>
<button class="btn btn-success" ng-disabled="!agreeCheck" type="button" ng-click="agree()">我同意 | I Agree</button>
<button ng-if="ag.rate_expire" class="btn btn-danger" type="button" ng-click="notAgree()">不同意,退出 | Login Out</button>
<button ng-if="!ag.rate_expire && ag.rate_waring" class="btn btn-danger" type="button" ng-click="$dismiss()">取消 | Cancel</button>
</div>
</div>
Loading…
Cancel
Save