全量开通商户 CBPAY

master
taylor.dang 6 years ago
parent 4ece67e6aa
commit a30d4b34b9

@ -28,7 +28,10 @@ import au.com.royalpay.payment.manage.system.core.TradeSecureService;
import au.com.royalpay.payment.manage.system.core.beans.TradeSecureFile;
import au.com.royalpay.payment.manage.tradelog.core.TradeLogService;
import au.com.royalpay.payment.tools.CommonConsts;
import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApi;
import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApiProvider;
import au.com.royalpay.payment.tools.defines.TradeType;
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.http.HttpUtils;
@ -67,6 +70,8 @@ import java.util.Arrays;
import java.util.Date;
import java.util.List;
import static au.com.royalpay.payment.manage.permission.utils.OrgCheckUtils.checkOrgPermission;
/**
* Created by yixian on 2016-07-06.
*/
@ -128,6 +133,8 @@ public class TestController implements ApplicationEventPublisherAware {
@Resource
private SysConfigManager sysConfigManager;
@Resource
private MpWechatApiProvider mpWechatApiProvider;
@Resource
private TradeSecureService tradeSecureService;
private final static String EMAIL = "lily.tao@royalpay.com.au,bella.sun@royalpay.com.au,astro.dai@royalpay.com.au,taylor.dang@royalpay.com.au";
@ -469,4 +476,33 @@ public class TestController implements ApplicationEventPublisherAware {
public void initClientPayType(@RequestParam int begin,@RequestParam int end) {
aliforexcelService.initClientPayType(begin,end);
}
@PutMapping(value = "/open/cb_bankpay")
public void switchCBBankPayLinkPermission() {
List<JSONObject> merchants = clientMapper.listNeedOpenCbpayMerchant();
merchants.forEach(mch -> {
JSONObject client = clientMapper.findClientByMonikerAll(mch.getString("client_moniker"));
if (client == null) {
throw new InvalidShortIdException();
}
if (StringUtils.isEmpty(client.getString("cb_bankpay_url"))) {
String longUrl = PlatformEnvironment.getEnv().concatUrl("/sys/partners/" + client.getString("client_moniker") + "/cb_bankpay/link/pc");
String cb_bankpay_url = getCBBankShortLink(longUrl);
client.put("cb_bankpay_url", cb_bankpay_url);
client.put("enable_cb_bankpay_link", true);
client.put("enable_cb_bankpay", true);
clientMapper.update(client);
} else {
client.put("enable_cb_bankpay_link", true);
clientMapper.update(client);
}
});
}
private String getCBBankShortLink(String longUrl) {
MpWechatApi api = mpWechatApiProvider.getNewPaymentApi();
return api.registerShortUrl(longUrl);
}
}

@ -38,6 +38,8 @@ public interface ClientMapper {
@AutoSql(type = SqlType.SELECT)
JSONObject findClientByMonikerAll(@Param("client_moniker") String clientMoniker);
List<JSONObject> listNeedOpenCbpayMerchant();
@AutoSql(type = SqlType.SELECT)
@AdvanceSelect(addonWhereClause = "is_valid=1")
List<JSONObject> getClientBySubMerchantId(@Param("sub_merchant_id") String subMerchantId);

@ -649,4 +649,16 @@
<select id="getPartnercode" resultType="int">
SELECT count(1) FROM sys_clients where client_moniker=#{codes};
</select>
<select id="listNeedOpenCbpayMerchant" resultType="com.alibaba.fastjson.JSONObject">
SELECT sc.client_moniker,
sc.client_id
FROM sys_clients sc
WHERE sc.client_id IN (SELECT scr.client_id
FROM sys_client_rates scr
WHERE scr.rate_name = 'CB_BankPay'
AND (scr.expiry_time IS NULL
OR scr.expiry_time >= NOW()));
</select>
</mapper>

Loading…
Cancel
Save