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")) { if (!StringUtils.equals(device.getString("client_type"), "wxapp")) {
res.put("rate", paymentApi.channelApi("Wechat").queryExchangeRateDecimal(client_id)); res.put("rate", paymentApi.channelApi("Wechat").queryExchangeRateDecimal(client_id));
res.put("alipay_rate", paymentApi.channelApi("Alipay").queryExchangeRateDecimal(client_id));
} }
return res; return res;
} }
@ -1451,7 +1452,7 @@ public class RetailAppServiceImp implements RetailAppService {
@Override @Override
public void changeManualSettle(JSONObject device, boolean manual_settle) { 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); void changeRole(JSONObject manager, String clientMoniker, String accountId, int role);
@Transactional @Transactional
void toggleAuditRefund(String clientMoniker, boolean enable); void toggleAuditRefund(String clientMoniker, boolean enable, JSONObject account);
List<JSONObject> listPaymentNoticeAccounts(int clientId); 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.ClientConfigService;
import au.com.royalpay.payment.manage.merchants.core.ClientInfoCacheSupport; 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.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.notice.core.MailService;
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;
@ -179,6 +181,9 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
// todo 作用 // todo 作用
@Resource @Resource
private ClientComplyValidator[] validators; private ClientComplyValidator[] validators;
@Resource
private ClientModifySupport clientModifySupport;
@Resource @Resource
private PaymentChannelApi[] channels; private PaymentChannelApi[] channels;
@Resource @Resource
@ -1088,12 +1093,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
} }
@Override @Override
public void toggleAuditRefund(String clientMoniker, boolean enable) { public void toggleAuditRefund(String clientMoniker, boolean enable, JSONObject account) {
JSONObject partner = getClientInfoByMoniker(clientMoniker); clientModifySupport.processClientModify(new RefundAuditModify(account, clientMoniker, enable));
Assert.notNull(partner, "Merchant is null");
partner.put("enable_refund_auth", enable);
clientMapper.update(partner);
clientInfoCacheSupport.clearClientCache(partner.getIntValue("client_id"));
} }
@Override @Override

@ -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) @PartnerMapping(value = "/audit_refund", method = RequestMethod.PUT, roles = PartnerRole.ADMIN)
@ResponseBody @ResponseBody
public void toggleAuditRefund(@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject account, @RequestBody JSONObject enable) { 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}) @PartnerMapping(value = "/refund_pwd", method = RequestMethod.PUT, roles = {PartnerRole.ADMIN, PartnerRole.MANAGER})

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

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

@ -1,24 +1,39 @@
package au.com.royalpay.payment.manage.apps.core.impls; 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.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.BoundListOperations;
import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner; 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. * Created by wangning on 05/01/2018.
*/ */
@SpringBootTest @SpringBootTest
@ActiveProfiles({ "local", "alipay", "wechat", "jd", "bestpay" }) @ActiveProfiles({ "proxy", "alipay", "wechat", "jd", "bestpay" })
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
public class CustomerImpressionImplTest { public class CustomerImpressionImplTest {
@Resource @Resource
@ -26,14 +41,89 @@ public class CustomerImpressionImplTest {
@Resource @Resource
private StringRedisTemplate stringRedisTemplate; 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 @Test
public void redisQueue() { public void excel() {
BoundListOperations<String, String> ops = stringRedisTemplate.boundListOps("customer_impression"); try {
JSONObject order = orderMapper.find("00009201711300930013961422");
for (int i = 0; i < 10000; i++) { List<JSONObject> asd =null;
ops.rightPush(order.toJSONString()); 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