Merge branch 'clientmodify' into develop_client_config

master
wangning 7 years ago
commit b7ef26926e

Binary file not shown.

Before

Width:  |  Height:  |  Size: 59 KiB

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 71 KiB

After

Width:  |  Height:  |  Size: 73 KiB

@ -190,6 +190,7 @@ public class RetailAppServiceImp implements RetailAppService {
// 微信小程序不查询汇率
if (!StringUtils.equals(device.getString("client_type"), "wxapp")) {
res.put("rate", paymentApi.channelApi("Wechat").queryExchangeRateDecimal(client_id));
res.put("alipay_rate", paymentApi.channelApi("Alipay").queryExchangeRateDecimal(client_id));
}
return res;
}
@ -1451,7 +1452,7 @@ public class RetailAppServiceImp implements RetailAppService {
@Override
public void changeManualSettle(JSONObject device, boolean manual_settle) {
clientManager.changeManualSettle(device.getIntValue("client_id"), manual_settle, device.getString("account_id"), 1, "商户修改手动清算配置");
clientManager.changeManualSettle(device.getIntValue("client_id"), manual_settle, device.getString("account_id"), 1, "商户"+(manual_settle?"打开":"关闭")+"手动清算");
}

@ -121,7 +121,7 @@ public interface ClientManager {
void changeRole(JSONObject manager, String clientMoniker, String accountId, int role);
@Transactional
void toggleAuditRefund(String clientMoniker, boolean enable);
void toggleAuditRefund(String clientMoniker, boolean enable, JSONObject account);
List<JSONObject> listPaymentNoticeAccounts(int clientId);

@ -0,0 +1,11 @@
package au.com.royalpay.payment.manage.merchants.core;
import au.com.royalpay.payment.manage.merchants.entity.ClientModify;
/**
* Create by yixian at 2018-04-12 16:24
*/
public interface ClientModifySupport {
void processClientModify(ClientModify clientModify);
}

@ -42,6 +42,8 @@ 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.RefundAuditModify;
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;
@ -179,6 +181,9 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
// todo 作用
@Resource
private ClientComplyValidator[] validators;
@Resource
private ClientModifySupport clientModifySupport;
@Resource
private PaymentChannelApi[] channels;
@Resource
@ -1088,12 +1093,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
}
@Override
public void toggleAuditRefund(String clientMoniker, boolean enable) {
JSONObject partner = getClientInfoByMoniker(clientMoniker);
Assert.notNull(partner, "Merchant is null");
partner.put("enable_refund_auth", enable);
clientMapper.update(partner);
clientInfoCacheSupport.clearClientCache(partner.getIntValue("client_id"));
public void toggleAuditRefund(String clientMoniker, boolean enable, JSONObject account) {
clientModifySupport.processClientModify(new RefundAuditModify(account, clientMoniker, enable));
}
@Override
@ -2150,7 +2151,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
file.put("last_update_by", manager.getString("display_name"));
}
JSONObject contract = clientsContractMapper.findByClientId(client.getIntValue("client_id"));
if (contract == null || now.compareTo(contract.getDate("expiry_date")) > 0 ||!contract.getBoolean("has_sign")|| existFile == null || existFile.isEmpty()) {
if (contract == null || now.compareTo(contract.getDate("expiry_date")) > 0 || !contract.getBoolean("has_sign") || existFile == null || existFile.isEmpty()) {
clientFilesMapper.save(file);
} else {
file.put("file_id", existFile.getString("file_id"));
@ -3009,7 +3010,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
}
private TemplateMessage initSendToComplianceGreenChannelTemplate(String loginUrl, String wxopenid, String templateId2, String bd_user_name,
JSONObject client) {
JSONObject client) {
TemplateMessage msg = new TemplateMessage(wxopenid, templateId2, loginUrl);
msg.put("first", bd_user_name + " 提交了新商户绿色通道申请,请审核", "#ff0000");
msg.put("keyword1", client.getString("client_moniker") + "申请绿色通道", "#0000ff");
@ -3250,12 +3251,12 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
@Override
public JSONObject getCheckClientInfo(int client_id, String account_id, String channel) {
JSONObject result = null;
JSONObject expireInfo = clientContractService.getClientContractExpire(client_id,channel);
JSONObject expireInfo = clientContractService.getClientContractExpire(client_id, channel);
JSONObject account = clientAccountMapper.findById(account_id);
if (PartnerRole.getRole(account.getIntValue("role")) == PartnerRole.CASHIER) {
return result;
return result;
} else {
if(expireInfo.getBoolean("alert")){
if (expireInfo.getBoolean("alert")) {
result = new JSONObject();
// result.put("content","Dear Valued Merchants,\n" +
// "\n" +
@ -3303,8 +3304,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
// "\n" +
// "GST只针对手续费部分与商品价格无关\n" +
// "\n");
result.put("content","<p class=\"p1\"><span style=\"font-size: 20px;\"></span></p><p class=\"p1\"><span style=\"font-size: 20px;\">Dear Valued Merchants,</span></p><p class=\"p2\"><span style=\"font-size: 20px;\"><br/></span></p><p class=\"p1\"><span style=\"font-size: 20px;\">We would like to extend our warm gratitude to your business for your continued support of RoyalPay. Without our merchants we wouldn&#39;t be where we are today.&nbsp;</span></p><p class=\"p2\"><span style=\"font-size: 20px;\"><br/></span></p><p class=\"p1\"><span style=\"font-size: 20px;\">RoyalPay has and always will be committed to complying with all Australian laws, rules and regulations. With our deep roots in China, we also work with all Chinese regulations simultaneously with Australia. Since our humble beginnings in 2016 we have worked with the ATO (Australian Tax Office) to make sure that we are in alignment with all tax requirements.&nbsp;</span></p><p class=\"p2\"><span style=\"font-size: 20px;\"><br/></span></p><p class=\"p1\"><span style=\"font-size: 20px;\"></span></p><p><span style=\"font-size: 20px;\">During FY18 we entered negotiations with the ATO to file for GST exemptions for the part of surcharge fees. The ATO has recently advised that we have been unsuccessful in this bid. To ensure we comply with the ATO, we will need to adjust our current service agreements to be exclusionary of GST.&nbsp;</span></p><p><br/></p><p><span style=\"font-size: 20px;\">This will result in contractual changes to your agreement. However, your business may be eligible to claim this amount back depending on the tax relationship of your business. Please consult with your accounting team in relation to these changes.&nbsp;</span></p><p><span style=\"font-size: 20px;\"><br/></span></p><p><span style=\"font-size: 20px;\">If you have any questions related to this change please direct them to our Sales Management Team or your relevant BD officer.</span><br/></p><p><br/></p><p><strong><span style=\"font-size: 20px;\">(note: GST is for the surcharge fee only, not related to the price of the goods.)</span></strong></p><p class=\"p1\"><br/></p><p class=\"p1\"><span style=\"font-size: 20px;\">尊敬的商户,<br/></span></p><p class=\"p2\"><span style=\"font-size: 20px;\"></span></p><p class=\"p2\"><span style=\"font-size: 20px;\"><br/></span></p><p class=\"p3\"><span style=\"font-size: 20px;\">感谢您选择RoyalPay。作为澳洲移动支付的先行者和领导者RoyalPay自2016年起就开始针对交易手续费这一澳洲目前空白的税务问题对接澳大利亚相关监管机构。作为市场上全新的支付模式这两年来我们不断地与相关机构探讨最为合适的监管法令应用同时澳洲的相应法律法规也在不断地完善来提供更全面的监管来营造更加稳定、健康、健全的金融市场。</span></p><p class=\"p2\"><span style=\"font-size: 20px;\"><br/></span></p><p class=\"p3\"><span style=\"font-size: 20px;\">RoyalPay于近期正式收到澳洲监管机构的通知针对手续费Tax Free的申请和特殊税务条款考量做出了相应的回复目前澳洲市场上的移动支付扫码解决方案所产生的手续费部分的GST并不能享受Tax Free及部分减免的政策条款。我们已经替2018年前交易的商户补足了手续费部分的税金并应澳大利亚税务局ATO的要求进行了合同上手续费GST部分的相应调整。您也可咨询专业的会计师来申请您额外的手续费GST Return。感谢您的支持和理解愿我们一起共同努力塑造一个良好而有序的澳洲移动支付市场。</span></p><p class=\"p2\"><span style=\"font-size: 20px;\"><br/></span></p><p class=\"p3\"><span style=\"font-size: 20px;\">有任何疑问,请随时联络我们的客服与公众号。</span></p><p class=\"p3\"><strong><span style=\"font-size: 20px;\">GST只针对手续费部分与商品价格无关</span></strong></p><p><br/></p>");
result.put("title","【Important重要】GST Modification Notice | 澳洲监管机构关于手续费GST调整问题通知\n");
result.put("content", "<p class=\"p1\"><span style=\"font-size: 20px;\"></span></p><p class=\"p1\"><span style=\"font-size: 20px;\">Dear Valued Merchants,</span></p><p class=\"p2\"><span style=\"font-size: 20px;\"><br/></span></p><p class=\"p1\"><span style=\"font-size: 20px;\">We would like to extend our warm gratitude to your business for your continued support of RoyalPay. Without our merchants we wouldn&#39;t be where we are today.&nbsp;</span></p><p class=\"p2\"><span style=\"font-size: 20px;\"><br/></span></p><p class=\"p1\"><span style=\"font-size: 20px;\">RoyalPay has and always will be committed to complying with all Australian laws, rules and regulations. With our deep roots in China, we also work with all Chinese regulations simultaneously with Australia. Since our humble beginnings in 2016 we have worked with the ATO (Australian Tax Office) to make sure that we are in alignment with all tax requirements.&nbsp;</span></p><p class=\"p2\"><span style=\"font-size: 20px;\"><br/></span></p><p class=\"p1\"><span style=\"font-size: 20px;\"></span></p><p><span style=\"font-size: 20px;\">During FY18 we entered negotiations with the ATO to file for GST exemptions for the part of surcharge fees. The ATO has recently advised that we have been unsuccessful in this bid. To ensure we comply with the ATO, we will need to adjust our current service agreements to be exclusionary of GST.&nbsp;</span></p><p><br/></p><p><span style=\"font-size: 20px;\">This will result in contractual changes to your agreement. However, your business may be eligible to claim this amount back depending on the tax relationship of your business. Please consult with your accounting team in relation to these changes.&nbsp;</span></p><p><span style=\"font-size: 20px;\"><br/></span></p><p><span style=\"font-size: 20px;\">If you have any questions related to this change please direct them to our Sales Management Team or your relevant BD officer.</span><br/></p><p><br/></p><p><strong><span style=\"font-size: 20px;\">(note: GST is for the surcharge fee only, not related to the price of the goods.)</span></strong></p><p class=\"p1\"><br/></p><p class=\"p1\"><span style=\"font-size: 20px;\">尊敬的商户,<br/></span></p><p class=\"p2\"><span style=\"font-size: 20px;\"></span></p><p class=\"p2\"><span style=\"font-size: 20px;\"><br/></span></p><p class=\"p3\"><span style=\"font-size: 20px;\">感谢您选择RoyalPay。作为澳洲移动支付的先行者和领导者RoyalPay自2016年起就开始针对交易手续费这一澳洲目前空白的税务问题对接澳大利亚相关监管机构。作为市场上全新的支付模式这两年来我们不断地与相关机构探讨最为合适的监管法令应用同时澳洲的相应法律法规也在不断地完善来提供更全面的监管来营造更加稳定、健康、健全的金融市场。</span></p><p class=\"p2\"><span style=\"font-size: 20px;\"><br/></span></p><p class=\"p3\"><span style=\"font-size: 20px;\">RoyalPay于近期正式收到澳洲监管机构的通知针对手续费Tax Free的申请和特殊税务条款考量做出了相应的回复目前澳洲市场上的移动支付扫码解决方案所产生的手续费部分的GST并不能享受Tax Free及部分减免的政策条款。我们已经替2018年前交易的商户补足了手续费部分的税金并应澳大利亚税务局ATO的要求进行了合同上手续费GST部分的相应调整。您也可咨询专业的会计师来申请您额外的手续费GST Return。感谢您的支持和理解愿我们一起共同努力塑造一个良好而有序的澳洲移动支付市场。</span></p><p class=\"p2\"><span style=\"font-size: 20px;\"><br/></span></p><p class=\"p3\"><span style=\"font-size: 20px;\">有任何疑问,请随时联络我们的客服与公众号。</span></p><p class=\"p3\"><strong><span style=\"font-size: 20px;\">GST只针对手续费部分与商品价格无关</span></strong></p><p><br/></p>");
result.put("title", "【Important重要】GST Modification Notice | 澳洲监管机构关于手续费GST调整问题通知\n");
}
}
return result;

@ -0,0 +1,30 @@
package au.com.royalpay.payment.manage.merchants.core.impls;
import au.com.royalpay.payment.manage.mappers.system.ClientMapper;
import au.com.royalpay.payment.manage.merchants.core.ClientInfoCacheSupport;
import au.com.royalpay.payment.manage.merchants.core.ClientModifySupport;
import au.com.royalpay.payment.manage.merchants.entity.ClientModify;
import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/**
* Create by yixian at 2018-04-12 16:25
*/
@Service
public class ClientModifySupportImpl implements ClientModifySupport {
@Resource
private MerchantInfoProvider merchantInfoProvider;
@Resource
private ClientInfoCacheSupport clientInfoCacheSupport;
@Resource
private ClientMapper clientMapper;
@Override
public void processClientModify(ClientModify modify) {
int clientId = modify.doModify(merchantInfoProvider, mapper, clientMapper);
clientInfoCacheSupport.clearClientCache(clientId);
}
}

@ -0,0 +1,53 @@
package au.com.royalpay.payment.manage.merchants.entity;
import au.com.royalpay.payment.manage.mappers.system.ClientMapper;
import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import java.util.Map;
import java.util.stream.Collectors;
/**
* Create by yixian at 2018-04-12 16:19
*/
public abstract class ClientModify {
private JSONObject manager;
private JSONObject account;
private String clientMoniker;
public ClientModify(JSONObject manager, JSONObject account, String clientMoniker) {
this.manager = manager;
this.account = account;
this.clientMoniker = clientMoniker;
}
protected abstract String business();
protected abstract JSONObject getModifyResult();
public int doModify(MerchantInfoProvider merchantInfoProvider, ModifyHistoryMapper modifyHistoryMapper, ClientMapper clientMapper) {
JSONObject client = merchantInfoProvider.getClientInfoByMoniker(clientMoniker);
JSONObject modifyResult = getModifyResult();
saveModifyHistory(modifyHistoryMapper, client, modifyResult);
int clientId = client.getIntValue("client_id");
modifyResult.put("client_id", clientId);
clientMapper.update(modifyResult);
return clientId;
}
private void saveModifyHistory(ModifyHistoryMapper modifyHistoryMapper, JSONObject client, JSONObject modifyResult) {
Map<String, Object> beforeModify = modifyResult.keySet().stream().collect(Collectors.toMap(key -> key, client::get));
JSONObject modifyHistory = new JSONObject();
modifyHistory.put("client_id", client.getIntValue("client_id"));
modifyHistory.put("business", business());
modifyHistory.put("user_type", manager == null ? "Merchant" : "Manager");
modifyHistory.put("user_id", manager == null ? account.getString("account_id") : manager.getString("manager_id"));
modifyHistory.put("username", manager == null ? account.getString("display_name") : manager.getString("display_name"));
modifyHistory.put("origin_data", JSON.toJSONString(beforeModify));
modifyHistory.put("new_data", modifyResult.toJSONString());
modifyHistoryMapper.saveModifyHistory(modifyHistory);
}
}

@ -0,0 +1,28 @@
package au.com.royalpay.payment.manage.merchants.entity.impls;
import au.com.royalpay.payment.manage.merchants.entity.ClientModify;
import com.alibaba.fastjson.JSONObject;
/**
* Create by yixian at 2018-04-12 16:43
*/
public class RefundAuditModify extends ClientModify {
private boolean enable;
public RefundAuditModify(JSONObject account, String clientMoniker, boolean enable) {
super(null, account, clientMoniker);
this.enable = enable;
}
@Override
protected String business() {
return "refund_audit";
}
@Override
protected JSONObject getModifyResult() {
JSONObject modify = new JSONObject();
modify.put("enable_refund_auth", enable)
return modify;
}
}

@ -225,7 +225,7 @@ public class PartnerViewController {
@PartnerMapping(value = "/audit_refund", method = RequestMethod.PUT, roles = PartnerRole.ADMIN)
@ResponseBody
public void toggleAuditRefund(@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject account, @RequestBody JSONObject enable) {
clientManager.toggleAuditRefund(account.getString("client_moniker"), enable.getBooleanValue("enable"));
clientManager.toggleAuditRefund(account.getString("client_moniker"), enable.getBooleanValue("enable"), account);
}
@PartnerMapping(value = "/refund_pwd", method = RequestMethod.PUT, roles = {PartnerRole.ADMIN, PartnerRole.MANAGER})
@ -292,7 +292,7 @@ public class PartnerViewController {
public JSONObject listClientDevices(@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject account, @RequestParam(required = false) String remark,
@RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "10") int limit,
@RequestParam(required = false) String client_type, @RequestParam(required = false) String[] client_ids) {
return clientManager.listClientDevices(null, account.getString("client_moniker"), remark, page, limit,client_type,client_ids);
return clientManager.listClientDevices(null, account.getString("client_moniker"), remark, page, limit, client_type, client_ids);
}
@PartnerMapping(value = "/devices/{devId}", method = RequestMethod.PUT, roles = PartnerRole.ADMIN)
@ -366,18 +366,18 @@ public class PartnerViewController {
@PartnerMapping(value = "/manual_settle", method = RequestMethod.PUT, roles = PartnerRole.ADMIN)
@ResponseBody
public void manualSettle(@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject account, @RequestParam boolean manual_settle) {
clientManager.changeManualSettle(account.getIntValue("client_id"),manual_settle,account.getString("account_id"),1,"商户"+(manual_settle?"打开":"关闭")+"手动清算");
clientManager.changeManualSettle(account.getIntValue("client_id"), manual_settle, account.getString("account_id"), 1, "商户" + (manual_settle ? "打开" : "关闭") + "手动清算");
}
@PartnerMapping(value = "/checkContract", method = RequestMethod.GET)
@ResponseBody
public JSONObject getCheckClientInfov2(@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject account) {
return clientManager.getCheckClientInfo(account.getIntValue("client_id"),account.getString("account_id"),"PC");
return clientManager.getCheckClientInfo(account.getIntValue("client_id"), account.getString("account_id"), "PC");
}
@PartnerMapping(value = "/agree/confirm", method = RequestMethod.POST,roles = {PartnerRole.ADMIN, PartnerRole.MANAGER})
@PartnerMapping(value = "/agree/confirm", method = RequestMethod.POST, roles = {PartnerRole.ADMIN, PartnerRole.MANAGER})
@ResponseBody
public void confirmSourceAgreeFile(@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject account) {
clientContractService.confirmSourceAgreement(account.getIntValue("client_id"),account.getString("account_id"),"PC");
clientContractService.confirmSourceAgreement(account.getIntValue("client_id"), account.getString("account_id"), "PC");
}
}

@ -542,6 +542,10 @@ public class TradeLogServiceImpl implements TradeLogService {
.filter(log -> log.getBigDecimal("settle_amount") != null)
.map(log -> getSymbol(log).multiply(log.getBigDecimal("total_surcharge").add(log.getBigDecimal("tax_amount"))))
.reduce(BigDecimal::add).orElse(BigDecimal.ZERO));
analysis.put("tax_amount", logs.parallelStream()
.filter(log -> log.getBigDecimal("settle_amount") != null)
.map(log -> getSymbol(log).multiply(log.getBigDecimal("tax_amount")))
.reduce(BigDecimal::add).orElse(BigDecimal.ZERO));
analysis.put("wechat_fee", logs.parallelStream()
.filter(log -> log.getBigDecimal("settle_amount") != null)
.filter(log -> "WechatSettlement".contains(log.getString("channel")))
@ -604,11 +608,8 @@ public class TradeLogServiceImpl implements TradeLogService {
parmerters.put("wechat_fee", takeDecimalOrDefault(analysis, "wechat_fee", BigDecimal.ZERO));
parmerters.put("bestpay_fee", takeDecimalOrDefault(analysis, "bestpay_fee", BigDecimal.ZERO));
parmerters.put("jd_fee", takeDecimalOrDefault(analysis, "jd_fee", BigDecimal.ZERO));
parmerters.put("alipay_online_fee", takeDecimalOrDefault(analysis, "alipay_online_fee", BigDecimal.ZERO)); // parmerters.put("gst", analysis.containsKey("clearing_fee") ?
// analysis.getBigDecimal("clearing_fee").multiply(new BigDecimal(0.11)).setScale(2,
// BigDecimal.ROUND_DOWN) : 0);
// parmerters.put("gst",
// analysis.containsKey("total_royal_surcharge") ? analysis.getBigDecimal("total_royal_surcharge").divide(new BigDecimal(11), 2, BigDecimal.ROUND_DOWN) : 0);
parmerters.put("alipay_online_fee", takeDecimalOrDefault(analysis, "alipay_online_fee", BigDecimal.ZERO));
parmerters.put("gst", takeDecimalOrDefault(analysis, "tax_amount", BigDecimal.ZERO));
dataList.parallelStream().forEach(item -> {
scaleDecimalVal(item, "display_amount", item.getString("currency"));
String platformCurrency = PlatformEnvironment.getEnv().getForeignCurrency();

@ -176,6 +176,7 @@
<th>Currency</th>
<th>Total Amount</th>
<th>Clearing Amount</th>
<th>Remark</th>
</tr>
</thead>
<tbody>
@ -185,6 +186,7 @@
<td ng-bind="tr.transaction_currency"></td>
<td ng-bind="tr.transaction_amount"></td>
<td ng-bind="tr.clearing_amount"></td>
<td ng-bind="tr.remark"></td>
</tr>
</tbody>
</table>

@ -1,24 +1,39 @@
package au.com.royalpay.payment.manage.apps.core.impls;
import javax.annotation.Resource;
import au.com.royalpay.payment.manage.mappers.payment.OrderMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientMapper;
import com.alibaba.fastjson.JSONObject;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.BoundListOperations;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import com.alibaba.fastjson.JSONObject;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import au.com.royalpay.payment.manage.mappers.payment.OrderMapper;
import javax.annotation.Resource;
/**
* Created by wangning on 05/01/2018.
*/
@SpringBootTest
@ActiveProfiles({ "local", "alipay", "wechat", "jd", "bestpay" })
@ActiveProfiles({ "proxy", "alipay", "wechat", "jd", "bestpay" })
@RunWith(SpringRunner.class)
public class CustomerImpressionImplTest {
@Resource
@ -26,14 +41,89 @@ public class CustomerImpressionImplTest {
@Resource
private StringRedisTemplate stringRedisTemplate;
@Resource
private ClientMapper clientMapper;
// @Test
// public void redisQueue() {
// BoundListOperations<String, String> ops = stringRedisTemplate.boundListOps("customer_impression");
// JSONObject order = orderMapper.find("00009201711300930013961422");
// for (int i = 0; i < 10000; i++) {
// ops.rightPush(order.toJSONString());
//
// }
// }
@Test
public void redisQueue() {
BoundListOperations<String, String> ops = stringRedisTemplate.boundListOps("customer_impression");
JSONObject order = orderMapper.find("00009201711300930013961422");
for (int i = 0; i < 10000; i++) {
ops.rightPush(order.toJSONString());
public void excel() {
try {
List<JSONObject> asd =null;
Map<String,JSONObject> map = new HashMap<>();
asd.forEach(p->{
map.put(p.getString("sub_merchant_id"),p);
});
XSSFWorkbook workbook = new XSSFWorkbook(new FileInputStream(new File("/Users/wangning/Desktop/qwe.xlsx")));
XSSFSheet sheet = workbook.getSheetAt(0);
Iterator<Row> rowIterator = sheet.rowIterator();
Row row = null;
Cell cell = null;
while (rowIterator.hasNext()) {
row = rowIterator.next();
cell = row.getCell(1);
if(cell==null){
continue;
}
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
JSONObject tmpOBJ = map.get(cell.getStringCellValue());
if(tmpOBJ==null){
continue;
}
row.createCell(4).setCellValue(tmpOBJ.getString("cc"));
row.createCell(5).setCellValue(tmpOBJ.getString("maxct"));
}
//
//
// if (!"Australia".equals(row.getCell(1).getStringCellValue())) {
// continue;
// }
// cell = row.getCell(0);
// cell.setCellType(HSSFCell.CELL_TYPE_STRING);
//
// JSONObject client = clientMapper.clientInfoBySubMerchantId(cell.getStringCellValue());
// if(client==null){
// continue;
// }
// row.createCell(4).setCellValue(client.getString("bd_user_name"));
// row.createCell(5).setCellValue(client.getString("client_moniker"));
// row.createCell(6).setCellValue(client.getString("short_name"));
// }
//
// XSSFSheet sheet3 = workbook.getSheetAt(3);
// Iterator<Row> rowIterator3 = sheet3.rowIterator();
// while (rowIterator3.hasNext()) {
// row = rowIterator3.next();
// if (!"Australia".equals(row.getCell(1).getStringCellValue())) {
// continue;
// }
// cell = row.getCell(0);
// cell.setCellType(HSSFCell.CELL_TYPE_STRING);
// JSONObject client = clientMapper.clientInfoBySubMerchantId(cell.getStringCellValue());
// if(client==null){
// continue;
// }
// row.createCell(4).setCellValue(client.getString("bd_user_name"));
// row.createCell(5).setCellValue(client.getString("client_moniker"));
// row.createCell(6).setCellValue(client.getString("short_name"));
// }
OutputStream out = new FileOutputStream("/Users/wangning/Desktop/订单fin.xlsx");
workbook.write(out);
workbook.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
Loading…
Cancel
Save