Merge remote-tracking branch 'origin/develop'

# Conflicts:
#	src/main/ui/static/analysis/templates/cheat_monitor_risk.html
master
james.zhao 6 years ago
commit ba79b580b0

@ -0,0 +1,15 @@
package au.com.royalpay.payment.manage.customers.core;
import com.alibaba.fastjson.JSONObject;
import javax.servlet.http.HttpServletRequest;
public interface CustomerRewardLogService {
JSONObject takeReward(String openid,String channel);
JSONObject getRewardDetail(String reward_id);
void saveReward(int type2,int type3,String type1,String date);
void checkRedpacksStatus(String rewardId);
}

@ -0,0 +1,222 @@
package au.com.royalpay.payment.manage.customers.core.impls;
import au.com.royalpay.payment.manage.customers.core.CustomerRewardLogService;
import au.com.royalpay.payment.manage.mappers.customers.CusRewardConfigMapper;
import au.com.royalpay.payment.manage.mappers.customers.CusRewardCouponMapper;
import au.com.royalpay.payment.manage.mappers.customers.CusRewardLogsMapper;
import au.com.royalpay.payment.manage.mappers.payment.OrderMapper;
import au.com.royalpay.payment.manage.mappers.system.CustomerMapper;
import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApi;
import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApiProvider;
import au.com.royalpay.payment.tools.connections.mpsupport.beans.WechatRedpack;
import au.com.royalpay.payment.tools.env.PlatformEnvironment;
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import au.com.royalpay.payment.tools.exceptions.ForbiddenException;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.ParseException;
import java.util.Date;
import java.util.List;
/**
* @Author: james7whm
* @Date: 2019/1/17 16:56
*/
@Service
public class CustomerRewardLogServiceImpl implements CustomerRewardLogService {
private Logger logger = LoggerFactory.getLogger(getClass());
@Resource
private MpWechatApiProvider mpWechatApiProvider;
@Resource
private OrderMapper orderMapper;
@Resource
private CusRewardConfigMapper cusRewardConfigMapper;
@Resource
private CusRewardLogsMapper cusRewardLogsMapper;
@Resource
private CusRewardCouponMapper cusRewardCouponMapper;
@Resource
private CustomerMapper customerMapper;
@Override
public JSONObject takeReward(String openid,String channel) {
String redpack_openid = openid;
if(channel.equals("Wechat")){
JSONObject customerRelation = customerMapper.findCustomerByOpenId(openid);
if (customerRelation == null) {
customerRelation = customerMapper.findCustomerGlobalpayByOpenId(openid);
}
redpack_openid = customerRelation.getString("redpack_openid");
}
try {
Date now = new Date();
Date begin = DateUtils.parseDate(cusRewardConfigMapper.getValue("begin").getString("value"),"yyyy-MM-dd");
if(begin.after(now)){
throw new ForbiddenException("活动尚未开始");
}
Date end = DateUtils.parseDate(cusRewardConfigMapper.getValue("end").getString("value"),"yyyy-MM-dd");
if(end.before(now)){
throw new ForbiddenException("活动已结束");
}
List<JSONObject> orders = orderMapper.listNewYearOrdersByOpenId(openid, DateFormatUtils.format(now,"yyyy-MM-dd"));
if(orders.isEmpty()){
throw new ForbiddenException("请至少使用微信或支付宝线下支付一笔");
}
int limit = cusRewardConfigMapper.getValue("limit").getIntValue("value");
int currentDayCounts = cusRewardLogsMapper.openIdReceivedCount(redpack_openid,DateUtils.parseDate(DateFormatUtils.format(now,"yyyy-MM-dd")+" 00:00:00","yyyy-MM-dd HH:mm:ss"));
if((limit-currentDayCounts)<=0){
throw new ForbiddenException("您今日已达到抽奖次数上限");
};
//抽完一次后,还想抽下一次
if((orders.size()-currentDayCounts)<=0){
throw new ForbiddenException("请使用微信或支付宝再支付一笔");
};
String fakeOpenId = redpack_openid + DateFormatUtils.format(now, "HHmmssSSS");
if(channel.equals("Wechat")){
if(cusRewardLogsMapper.takeReward(now,fakeOpenId,DateFormatUtils.format(now,"yyyy-MM-dd")) > 0){
JSONObject reward = cusRewardLogsMapper.findRewardByFakeOpenId(fakeOpenId);
Assert.notNull(reward, "reward is null");
String rewardId = reward.getString("reward_id");
reward.put("openid",redpack_openid);
cusRewardLogsMapper.update(reward);
if (reward.getIntValue("type") == 2 || reward.getIntValue("type") == 3) {
reward.put("status",1);
cusRewardLogsMapper.update(reward);
} else {
String sendName = "RoyalPay";
String actName = cusRewardConfigMapper.getValue("act_name").getString("value");
String wishing = cusRewardConfigMapper.getValue("wishing").getString("value");
String notifyUrl = PlatformEnvironment.getEnv().concatUrl("/act/new_year/redpacks/"+rewardId);
MpWechatApi redpackApi = mpWechatApiProvider.getApi("redpack");
WechatRedpack wechatRedpack = new WechatRedpack();
wechatRedpack.setSendName(sendName).setOpenId(redpack_openid).setActName(actName)
.setRemark(actName).setAmount(reward.getBigDecimal("amount").divide(new BigDecimal(100))).setWishing(wishing).setNotifyUrl(notifyUrl);
JSONObject res = redpackApi.sendRedpack(wechatRedpack);
logger.info("2019新年活动获取的红包信息==>"+res.toJSONString());
reward.put("status",0);
reward.put("send_listid",res.getString("redpack_id"));
cusRewardLogsMapper.update(reward);
}
return reward;
}
}
if(channel.equals("Alipay")){
if(cusRewardLogsMapper.takeRewardNotWechat(now,openid,DateFormatUtils.format(now,"yyyy-MM-dd")) > 0){
JSONObject reward = cusRewardLogsMapper.findRewardByFakeOpenId(fakeOpenId);
Assert.notNull(reward, "reward is null");
reward.put("openid",openid);
reward.put("status",1);
cusRewardLogsMapper.update(reward);
return reward;
}
}
} catch (ParseException e) {
e.printStackTrace();
}
return getRandomReward(channel.equals("Wechat")?redpack_openid:openid);
}
@Override
public JSONObject getRewardDetail(String reward_id) {
return cusRewardLogsMapper.findRewardByRewardId(reward_id);
}
@Override
public void saveReward(int type2, int type3, String type1,String date) {
if(type1!=null){
String[] configs = type1.split(",");
NumberFormat format = new DecimalFormat("00000");
int i = 0;
for (String config : configs) {
config = StringUtils.trim(config);
String[] detail = config.split("x");
int count = Integer.parseInt(detail[1]);
int amount = new BigDecimal(detail[0]).intValue();
for (int num = 0; num < count; num++) {
JSONObject redpack = new JSONObject();
String idPrefix = "C"+ DateFormatUtils.format(new Date(), "yyyyMMddHHmmssSSS") + format.format(i++);
redpack.put("reward_id", idPrefix + RandomStringUtils.random(28 - idPrefix.length(), true, true));
redpack.put("amount", amount);
redpack.put("status", 0);
redpack.put("date", date);
redpack.put("type", 1);
cusRewardLogsMapper.save(redpack);
}
}
}
if(type2!=0){
JSONObject coupon = cusRewardCouponMapper.getCoupon(2);
NumberFormat format = new DecimalFormat("00000");
for (int i = 0; i < type2; i++) {
JSONObject log = new JSONObject();
String prefix = "C" + DateFormatUtils.format(new Date(), "MMddHHmmssSSS") + format.format(i);
log.put("reward_id", prefix + RandomStringUtils.random(28 - prefix.length(), false, true));
log.put("type", 2);
log.put("date", date);
log.put("coupon_id", coupon.getString("coupon_id"));
cusRewardLogsMapper.save(log);
}
}
if(type3!=0){
JSONObject coupon = cusRewardCouponMapper.getCoupon(3);
NumberFormat format = new DecimalFormat("00000");
for (int i = 0; i < type2; i++) {
JSONObject log = new JSONObject();
String prefix = "C" + DateFormatUtils.format(new Date(), "MMddHHmmssSSS") + format.format(i);
log.put("reward_id", prefix + RandomStringUtils.random(28 - prefix.length(), false, true));
log.put("type", 3);
log.put("date", date);
log.put("coupon_id", coupon.getString("coupon_id"));
cusRewardLogsMapper.save(log);
}
}
}
@Override
public void checkRedpacksStatus(String rewardId) {
MpWechatApi redpackApi = mpWechatApiProvider.getApi("redpack");
JSONObject redpack = redpackApi.redpackStatus(rewardId);
int status = redpack.getIntValue("status");
JSONObject params = new JSONObject();
if(status == 2){
params.put("status",status);
params.put("reward_id",rewardId);
params.put("error_code",redpack.getString("err_code"));
params.put("error_msg",redpack.getString("err_msg"));
cusRewardLogsMapper.update(params);
}else {
params.put("status",status);
params.put("reward_id",rewardId);
cusRewardLogsMapper.update(params);
}
}
private JSONObject getRandomReward(String openid){
JSONObject reward = cusRewardCouponMapper.randomType();
reward.remove("title");
String prefix = "C" + DateFormatUtils.format(new Date(), "MMddHHmmssSSS");
reward.put("reward_id", prefix + RandomStringUtils.random(28 - prefix.length(), false, true));
reward.put("openid",openid);
reward.put("date",DateFormatUtils.format(new Date(),"yyyy-MM-dd"));
reward.put("send_time",new Date());
reward.put("status",1);
cusRewardLogsMapper.save(reward);
return reward;
}
}

@ -0,0 +1,30 @@
package au.com.royalpay.payment.manage.customers.task;
import au.com.royalpay.payment.manage.customers.core.CustomerRewardLogService;
import au.com.royalpay.payment.manage.mappers.customers.CusRewardLogsMapper;
import com.alibaba.fastjson.JSONObject;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
/**
* @Author: james7whm
* @Date: 2019/2/3 20:26
*/
@Component
public class RedpackSendingTask {
@Resource
private CustomerRewardLogService customerRewardLogService;
@Resource
private CusRewardLogsMapper cusRewardLogsMapper;
@Scheduled(cron = "0 0 0/1 * * ?")
public void checkRedpacks() {
List<JSONObject> unConfirmedRedpacks = cusRewardLogsMapper.listUnconfirmRewards();
for (JSONObject redpack : unConfirmedRedpacks) {
customerRewardLogService.checkRedpacksStatus(redpack.getString("send_listid"));
}
}
}

@ -0,0 +1,77 @@
package au.com.royalpay.payment.manage.customers.web;
import au.com.royalpay.payment.manage.customers.core.CustomerRewardLogService;
import au.com.royalpay.payment.tools.CommonConsts;
import au.com.royalpay.payment.tools.exceptions.ForbiddenException;
import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
/**
* @Author: james7whm
* @Date: 2019/1/16 14:35
*/
@Controller
@RequestMapping("/act/new_year")
public class NewYearRedPacketController {
// @Resource
// private MpWechatApi mpWechatApi;
@Resource
private CustomerRewardLogService customerRewardLogService;
@RequestMapping(value = "/reward", method = RequestMethod.GET)
public String takeReward(@ModelAttribute(CommonConsts.WECHATINFO) JSONObject wxUser,
@ModelAttribute(CommonConsts.ALIUSER) JSONObject aliuser) {
// String user_id = "o32MzuA5H8KNIYAO2a__BGS-3iXs";
String user_id = "";
String channel="";
if(aliuser == null && wxUser == null){
throw new ForbiddenException("请使用微信或支付宝客户端打开");
}
if (aliuser != null) {
user_id = aliuser.getString("user_id");
channel = "Alipay";
}
if (wxUser != null) {
user_id = wxUser.getString("openid");
channel = "Wechat";
}
JSONObject reward = customerRewardLogService.takeReward(user_id,channel);
// ModelAndView mav = new ModelAndView("activity/new_year_reward/reward");
// JSONObject reward = new JSONObject();
// reward.put("type",2);
// mav.addObject("reward", reward);
return "redirect:/act/new_year/"+reward.getString("reward_id");
// return encourageService.takeEncourageMoney(orderId, user_id);
}
@RequestMapping(value = "/{reward_id}", method = RequestMethod.GET)
public ModelAndView getReward(@PathVariable String reward_id){
ModelAndView mav = new ModelAndView("activity/new_year_reward/reward");
JSONObject reward = customerRewardLogService.getRewardDetail(reward_id);
mav.addObject("reward", reward);
return mav;
}
@RequestMapping(value = "/description", method = RequestMethod.GET)
public ModelAndView takeDescription(){
ModelAndView mav = new ModelAndView("activity/new_year_reward/description");
return mav;
}
@ResponseBody
@RequestMapping(value = "/coupons", method = RequestMethod.GET)
public void saveCoupons(@RequestParam("type2")int type2,@RequestParam("type3")int type3,@RequestParam("type1")String type1,@RequestParam("date")String date){
customerRewardLogService.saveReward(type2,type3,type1,date);
}
@RequestMapping(value = "/redpacks/{rewardId}", method = RequestMethod.POST)
public void updateRedpackStatus(HttpServletRequest request, @RequestHeader String sign, @RequestHeader long timestamp, @PathVariable String rewardId) {
// mpWechatApi(request.getRequestURI(), sign, timestamp);
// redpackSupport.checkRedpack(rewardId);
}
}

@ -546,8 +546,10 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
if (settle.getBigDecimal("clearing_amount").compareTo(BigDecimal.ZERO) == 0) {
continue;
}
aba.addSettleMerchant(settle.getString("client_moniker"), settle.getString("bsb_no"), settle.getString("account_no"), settle.getString("account_name"),
settle.getBigDecimal("clearing_amount"));
String clientMoniker = settle.getString("client_moniker");
String remark = "RoyalPay" + DateFormatUtils.format(dt, "MMdd") + clientMoniker;
aba.addSettleMerchant(settle.getString("bsb_no"), settle.getString("account_no"), settle.getString("account_name"),
settle.getBigDecimal("clearing_amount"), remark);
}
return aba;
}

@ -0,0 +1,66 @@
package au.com.royalpay.payment.manage.management.clearing.web;
import au.com.royalpay.payment.manage.mappers.log.ValidationLogMapper;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import netscape.javascript.JSObject;
import org.apache.commons.lang3.time.DateUtils;
import org.apache.xerces.impl.validation.ValidationManager;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import javax.annotation.Resource;
import java.text.ParseException;
import java.util.*;
/**
* @Description:
* @Author: lujian
* @Date: 2019/1/30 13:50
*/
@Controller
@RequestMapping("/sys/financial")
public class ArrivalNoticeController {
@Resource
private ValidationLogMapper validationLogMapper;
@GetMapping("/notice")
public String noticePage(HashMap<String, Object> map,
@RequestParam("date") String date) throws ParseException {
JSONArray reports = new JSONArray();
Date dt = DateUtils.parseDate(date, new String[]{"yyyyMMdd"});
JSONObject reportItem = validationLogMapper.findByDate(dt);
if (reportItem != null) {
JSONObject result = JSON.parseObject(reportItem.getString("result"));
reports = result.getJSONArray("channel_details");
for (int i = 0; i < reports.size(); i++) {
JSONObject channelItem = reports.getJSONObject(i);
String channel = channelItem.getString("channel");
if (channel.equals("Wechat") && result.containsKey("wechat_analysis")) {
JSONObject wechatAnalysis = result.getJSONObject("wechat_analysis");
List<JSONObject> analysis = new ArrayList<>();
for (Map.Entry<String, Object> entry : wechatAnalysis.entrySet()) {
JSONObject oneMerchant = new JSONObject();
oneMerchant.put("merchant_id", entry.getKey());
oneMerchant.put("order_amount", ((JSONObject) JSON.toJSON(entry.getValue())).getJSONObject("wechat_analysis").getBigDecimal("order_amount"));
analysis.add(oneMerchant);
}
channelItem.put("analysis", analysis);
}
if (channel.equals("Bestpay") && result.containsKey("bestpay_valid_analysis")) {
List<JSONObject> analysis = new ArrayList<>();
analysis.add(result.getJSONObject("bestpay_valid_analysis"));
reports.getJSONObject(i).put("analysis", analysis);
}
}
}
map.put("reports", reports);
map.put("title", "到账提醒");
return "reports/arrival_notice";
}
}

@ -0,0 +1,18 @@
package au.com.royalpay.payment.manage.mappers.customers;
import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper;
import cn.yixblog.support.mybatis.autosql.annotations.AutoSql;
import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
import com.alibaba.fastjson.JSONObject;
import org.apache.ibatis.annotations.Param;
/**
* @Author: james7whm
* @Date: 2019/1/17 17:34
*/
@AutoMapper(tablename = "cus_reward_config",pkName = "key")
public interface CusRewardConfigMapper {
@AutoSql(type = SqlType.SELECT)
JSONObject getValue(@Param("key") String key);
}

@ -0,0 +1,19 @@
package au.com.royalpay.payment.manage.mappers.customers;
import cn.yixblog.support.mybatis.autosql.annotations.AdvanceSelect;
import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper;
import cn.yixblog.support.mybatis.autosql.annotations.AutoSql;
import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
import com.alibaba.fastjson.JSONObject;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
@AutoMapper(tablename = "cus_reward_coupon",pkName = "coupon_id")
public interface CusRewardCouponMapper {
@Select("SELECT * FROM cus_reward_coupon WHERE type =2 or type =3 order by rand() limit 1")
JSONObject randomType();
@AutoSql(type = SqlType.SELECT)
JSONObject getCoupon(@Param("type") int type);
}

@ -0,0 +1,36 @@
package au.com.royalpay.payment.manage.mappers.customers;
import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper;
import cn.yixblog.support.mybatis.autosql.annotations.AutoSql;
import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
import com.alibaba.fastjson.JSONObject;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.Date;
import java.util.List;
@AutoMapper(tablename = "cus_reward_log",pkName = "reward_id")
public interface CusRewardLogsMapper {
@AutoSql(type = SqlType.INSERT)
void save(JSONObject params);
@AutoSql(type = SqlType.SELECT)
JSONObject findRewardByFakeOpenId(@Param("openid")String fakeOpenId);
@AutoSql(type = SqlType.SELECT)
JSONObject findRewardByRewardId(@Param("reward_id")String reward_id);
@AutoSql(type = SqlType.UPDATE)
void update(JSONObject params);
int openIdReceivedCount(@Param("openid") String openid, @Param("send_time") Date send_time);
int takeReward(@Param("send_time")Date sendTime, @Param("openid")String openid, @Param("date")String date);
int takeRewardNotWechat(@Param("send_time")Date sendTime, @Param("openid")String openid, @Param("date")String date);
@Select("SELECT * FROM cus_reward_log WHERE type=1 AND (`status`=0 OR `status`=1) AND openid IS NOT NULL ORDER BY send_time ASC")
List<JSONObject> listUnconfirmRewards();
}

@ -83,4 +83,10 @@ public interface OrderMapper {
JSONObject findOrderById(@Param("order_id") String orderId,@Param("client_id") int clientId);
List<JSONObject> listHalloweenActOrder(JSONObject param);
@AutoSql(type = SqlType.SELECT)
@AdvanceSelect(addonWhereClause = "status in (5,6,7) AND channel in('Wechat','Alipay')")
List<JSONObject> listNewYearOrdersByOpenId(@Param("customer_id") String open_id,@Param("transaction_date") String date);
}

@ -29,8 +29,8 @@ public class ABAFile {
totalSettleAmount = BigDecimal.ZERO;
}
public void addSettleMerchant(String clientMoniker, String bsbNo, String accountNo, String accountName, BigDecimal settleAmount) {
settlements.add(new SettleMerchantInfo(clientMoniker, bsbNo, accountNo, accountName, settleAmount));
public void addSettleMerchant(String bsbNo, String accountNo, String accountName, BigDecimal settleAmount, String remark) {
settlements.add(new SettleMerchantInfo(bsbNo, accountNo, accountName, settleAmount, remark));
totalSettleAmount = totalSettleAmount.add(settleAmount);
}
@ -129,18 +129,18 @@ public class ABAFile {
}
private class SettleMerchantInfo {
private final String clientMoniker;
private final String bsbNo;
private final String accountNo;
private final String accountName;
private final BigDecimal settleAmount;
private final String remark;
public SettleMerchantInfo(String clientMoniker, String bsbNo, String accountNo, String accountName, BigDecimal settleAmount) {
this.clientMoniker = clientMoniker;
public SettleMerchantInfo(String bsbNo, String accountNo, String accountName, BigDecimal settleAmount, String remark) {
this.bsbNo = bsbNo;
this.accountNo = accountNo.replaceAll("\\D", "");
this.accountName = accountName;
this.settleAmount = settleAmount;
this.remark = remark;
}
public String settleLine() {
@ -151,7 +151,7 @@ public class ABAFile {
lineBuilder.replace(18, 20, "50");
lineBuilder.replace(20, 30, getSettleAmount());
lineBuilder.replace(30, 62, getAccountName());
lineBuilder.replace(62, 80, StringUtils.rightPad("RoyalPay" + DateFormatUtils.format(settleDate, "MMdd") + clientMoniker, 18));
lineBuilder.replace(62, 80, StringUtils.rightPad(getRemark(), 18));
lineBuilder.replace(80, 87, bsbNo(base.getBsb()));
lineBuilder.replace(87, 96, StringUtils.leftPad(base.getAccountNo(), 9));
lineBuilder.replace(96, 112, StringUtils.left(StringUtils.rightPad(base.getAccountName(), 16), 16));
@ -159,19 +159,23 @@ public class ABAFile {
return lineBuilder.toString();
}
private String getBsbNo() {
protected String getRemark() {
return remark;
}
protected String getBsbNo() {
return bsbNo(bsbNo);
}
private String getAccountNo() {
protected String getAccountNo() {
return StringUtils.leftPad(StringUtils.right(accountNo, 9), 9);
}
private String getAccountName() {
protected String getAccountName() {
return StringUtils.rightPad(StringUtils.substring(accountName, 0, 32), 32);
}
private String getSettleAmount() {
protected String getSettleAmount() {
Assert.isTrue(settleAmount.compareTo(BigDecimal.ZERO) > 0, "Invalid Settle Amount:" + settleAmount.toPlainString());
return amountString(settleAmount, 10);
}

@ -0,0 +1,13 @@
<?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.customers.CusRewardLogsMapper">
<select id="openIdReceivedCount" resultType="Integer">
SELECT ifnull(count(l.reward_id),0) FROM cus_reward_log l WHERE openid=#{openid} AND type &lt;= 3 AND send_time>#{send_time}
</select>
<update id="takeReward">
UPDATE cus_reward_log SET send_time=#{send_time},openid=#{openid} WHERE date &lt;=#{date} AND openid IS NULL ORDER BY rand() LIMIT 1
</update>
<update id="takeRewardNotWechat" >
UPDATE cus_reward_log SET send_time=#{send_time},openid=#{openid} WHERE date &lt;=#{date} AND openid IS NULL AND type in(2,3) ORDER BY rand() LIMIT 1
</update>
</mapper>

@ -0,0 +1,33 @@
<!doctype html>
<html xmlns:th="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<meta http-equiv="cache-control" content="max-age=0">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT">
<meta http-equiv="pragma" content="no-cache">
<link rel="stylesheet" href="/static/templates/activity/new_year_reward/my.css?t=201807242202">
<title>Pay Successful</title>
</head>
<body style="background-color: #EDE6D3">
<div class="desc-container">
<p class="desc-title">活动说明</p>
<p class="desc-content">1、用户通过支付宝或微信完成支付后支付成功页面出现“RoyalPay2019年春节红包抽奖”活动弹窗点击进入即可参与抽奖没人每天有2次抽奖机会
</p>
<p class="desc-content">2、用户每天有2次抽奖机会。同一手机号同一手机终端同一账户符合以上任一条件均视为同一用户
</p>
<p class="desc-content">3、参与本次活动需通过支付成功页面入口参加活动需用户主扫二维码支付
</p>
<p class="desc-content">4、本次活动只针对线下场景支付行为
</p>
<p class="desc-content">5、用户需满18岁周岁</p>
<p class="desc-content">6、如用户出现违规行为如虚假交易、作弊、刷单等RoyalPay将撤销违规用户活动参加资格并有权回收违规用户获得的福利
</p>
<p class="desc-content">7、本次活动最终解释权归RoyalPay所有。
</p>
</div>
</body>
</html>

@ -0,0 +1,71 @@
<!doctype html>
<html xmlns:th="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<meta http-equiv="cache-control" content="max-age=0">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT">
<meta http-equiv="pragma" content="no-cache">
<link rel="stylesheet" href="//act.weixin.qq.com/static/cdn/css/wepayui/0.1.1/wepayui.min.css">
<link rel="stylesheet" href="/static/templates/activity/new_year_reward/redpack.css?t=201607242202">
<title>Pay Successful</title>
<script type="text/javascript" src="//res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script type="text/javascript" src="/static/lib/jquery/jquery-2.1.4.min.js"></script>
<script type="text/javascript" src="/static/templates/disable_wechat_menu.js?t=201607281849"></script>
<script type="text/javascript" data-th-inline="javascript">
</script>
</head>
<body style="background-color: #EDE6D3">
<!--<div class="img-bottom">-->
<!--</div>-->
<!--<div class="main-container">-->
<!--<div class="banner"><img style="width: 50px" src="/static/images/act/new_year_redpack/new_year_banner.png"></div>-->
<!--<div class="wish">恭喜您获得RoyalPay新春红包</div>-->
<!--<div class="redpack"><span class="amount">58.00</span><span class="currency">元</span><br><span class="description">Red packet transferred to wallet</span></div>-->
<!--</div>-->
<!--<div class="main-container">-->
<!--<div class="banner"><img style="width: 50px" src="/static/images/act/new_year_redpack/new_year_banner.png"></div>-->
<!--<div class="wish">恭喜您获得RoyalPay新春礼包</div>-->
<!--<div class="redpack">-->
<!--<img style="width: 50px" src="/static/images/act/new_year_redpack/new_year_banner.png">-->
<!--</div>-->
<!--</div>-->
<!--<div class="img-top"></div>-->
<div class="main-body">
<div class="body" data-th-if="${reward['type']}==1">
<div class="head"><img style="width:100%" src="/static/images/act/new_year_redpack/reward_top.png"></div>
<div class="banner"><img style="width: 50px" src="/static/images/act/new_year_redpack/new_year_banner.png"></div>
<div class="wish">恭喜您获得RoyalPay新春红包</div>
<div class="redpack"><span class="amount"><span data-th-text="${reward['amount']}"></span>.00</span><span class="currency"></span><br><span class="description">红包将自动转入您的钱包</span></div>
</div>
<div class="body" data-th-if="${reward['type']}==2">
<div class="head"><img style="width:100%" src="/static/images/act/new_year_redpack/reward_top.png"></div>
<div class="banner"><img style="width: 50px" src="/static/images/act/new_year_redpack/new_year_banner.png"></div>
<div class="wish">恭喜您获得RoyalPay新春好礼</div>
<div class="coupon">
<div class="coupon-back">
<img style="width: 100%" src="/static/images/act/new_year_redpack/new_year_coupon.png">
<div class="coupon-desc">
<div class="coupon-head"><img class="coupon-img" src="/static/images/act/new_year_redpack/au8.png"><span class="coupon-au8">AU8口气清新剂一瓶</span></div>
<p>地址1/550 George St Sydney NSW 2000</p>
<p>有效期: 2019年2月4日-2019年2月9日</p>
<p>使用说明:到店领取,先到先得</p>
</div>
</div>
</div>
</div>
<div class="body" data-th-if="${reward['type']}==3">
<div class="head"><img style="width:100%" src="/static/images/act/new_year_redpack/reward_top.png"></div>
<div class="coupon-content"><img style="width: 100%" src="/static/images/act/new_year_redpack/coupon_content.png"></div>
</div>
<div class="body-bottom"></div>
</div>
<div class="foot"><a style="color: #FDADAA" href="/act/new_year/description">活动介绍 ></a></div>
</body>
</html>

@ -0,0 +1,46 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="zh">
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<meta http-equiv="cache-control" content="max-age=0">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT">
<meta http-equiv="pragma" content="no-cache">
<title th:text="${title}"></title>
<link rel="stylesheet" href="https://pay.unifpay.com/static/lib/weui/weui_new.css">
<link rel="stylesheet" href="https://pay.unifpay.com/static/lib/weui/example.css">
<script type="text/javascript" src="https://pay.unifpay.com/static/lib/jquery/jquery-2.1.4.min.js"></script>
<script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<style type="text/css">
</style>
</head>
<body>
<div class="page__bd" th:each="report : ${reports}">
<div class="weui-form-preview">
<div class="weui-form-preview__hd">
<div class="weui-form-preview__item">
<em class="weui-form-preview__value" th:text="${report.channel}" style="text-align: center;"></em>
</div>
</div>
<div class="weui-form-preview__bd">
<div class="weui-form-preview__item">
<label class="weui-form-preview__label">对账状态</label>
<span class="weui-form-preview__value" th:text="${report.success} ? '成功' : '失败'" th:style="'color: ' + (${report.success} ? 'green' : 'red')"></span>
</div>
</div>
<div class="weui-form-preview__bd" th:each="item : ${report['analysis']}">
<div class="weui-form-preview__item">
<label class="weui-form-preview__label" th:text="${item['merchant_id']} ? ${item['merchant_id']} : 'order_amount'"></label>
<span class="weui-form-preview__value" th:text="${item.order_amount}"></span>
</div>
</div>
</div>
<br>
</div>
</body>
</html>

@ -275,7 +275,7 @@
</div>
</div>
<div class="form-group col-sm-6">
<label class="control-label col-sm-5">订单数:</label>
<label class="control-label col-sm-5">订单数:</label>
<div class="col-sm-6">
<input class="form-control" ng-model="paymentconfig['cheat_monitor.min_orders']">
</div>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 226 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

@ -0,0 +1,343 @@
div,span,a,img{
box-sizing:border-box;
}
.main-container {
position: absolute;
top: 0;
left: 20px;
right: 20px;
bottom: 28px;
background-color: #FCF7EB;
text-align: center;
}
@media screen and (max-height:670px){
.main-container {
position: absolute;
top: 0;
left: 20px;
right: 20px;
bottom: 26px;
background-color: #FCF7EB;
text-align: center;
}
}
@media screen and (max-height: 520px){
.main-container {
position: absolute;
top: 0;
left: 20px;
right: 20px;
bottom: 22px;
background-color: #FCF7EB;
text-align: center;
}
}
.img-top {
width: 100%;
background: url(/static/images/reward_top.png) no-repeat center;
background-size: contain;
height: 57px;
position: absolute;
top: -4px;
}
@media screen and (max-height:670px){
.img-top {
width: 100%;
background: url(/static/images/reward_top.png) no-repeat center;
background-size: contain;
height: 52px;
position: absolute;
top: -2px;
}
}
@media screen and (max-height:520px){
.img-top {
width: 100%;
background: url(/static/images/reward_top.png) no-repeat center;
background-size: contain;
height: 44px;
position: absolute;
top: 0px;
}
}
.img-bottom {
width: 100%;
height: 58px;
background: url(/static/images/reward_bottom.png) no-repeat center;
background-size: contain;
position: absolute;
bottom: 0px;
}
@media screen and (max-height:670px){
.img-bottom {
width: 100%;
height: 53px;
background: url(/static/images/reward_bottom.png) no-repeat center;
background-size: contain;
position: absolute;
bottom: 0px;
}
}
@media screen and (max-height:520px){
.img-bottom {
width: 100%;
height: 45px;
background: url(/static/images/reward_bottom.png) no-repeat center;
background-size: contain;
position: absolute;
bottom: 0px;
}
}
.wish {
font-size: 18px;
color: #B99B6A;
}
.redpack {
padding:20px;
color: #EC421F;
}
.redpack .amount{
font-size: 45px;
}
.redpack .currency{
font-size: 20px;
}
.redpack .description{
font-size: 14px;
}
.desc-container {
position: absolute;
top: 0;
left: 20px;
right: 20px;
bottom: 0;
background-color: #FCF7EB;
color:#B99B6A;
}
.desc-container .desc-title{
text-align: center;
font-size: 18px;
}
.desc-container .desc-content{
font-size: 14px;
}
.banner {
width: 100%;
margin-top: 15%;
padding: 20px;
background-size: contain;
}
.banner .head-box {
width: 65px;
height: 65px;
border: 3px solid #fe783b;
border-radius: 50%;
display: block;
margin: auto;
}
.desc {
width: 100%;
text-align: center;
font-size: 14px;
color: #fff;
margin: 5px 0;
}
.detail-box {
position: absolute;
top: 120px;
bottom: 40px;
left: 20px;
right: 20px;
border-radius: 5px;
background: #fff;
overflow: hidden;
}
.detail-box .detail-heading {
height: 54px;
padding: 18px 20px;
border-bottom: 1px solid #f1f1f1;
position: absolute;
top: 0;
width: 100%;
font-size: 14px;
}
.detail-box .detail-heading:after{
content:'';
clear:both;
display:block;
}
.detail-box .detail-heading .date-range {
color: #000;
float: left;
font-size: 14px;
}
.detail-box .balance-log-container {
position: absolute;
top: 55px;
bottom: 100px;
width: 100%;
left: 0;
padding: 0 20px 15px;
overflow-y: auto;
overflow-x: hidden;
}
.detail-box .balance-log-container .item {
height: 50px;
width: 100%;
position: relative;
padding-left: 15px;
}
.detail-box .balance-log-container .item:before {
content: '';
width: 10px;
height: 10px;
position: absolute;
left: -5px;
border-radius: 50%;
top: 20px;
background: #30af69;
}
.detail-box .balance-log-container .item:after {
content: '';
height: 100%;
top: 50%;
left: -1px;
border-left: 2px solid #30af69;
width: 0;
position: absolute;
}
.detail-box .balance-log-container .item:last-child:after{
display: none;
}
.detail-box .balance-log-container .item .date-box{
font-size: 16px;
float: left;
line-height: 50px;
color: #888888;
}
.detail-box .balance-log-container .item.today .date-box{
color: #30af69;
}
.detail-box .balance-log-container .item .amount{
color: #30af69;
font-size: 20px;
line-height: 50px;
float: right;
text-align: right;
}
.detail-box .balance-log-container .item .amount:before{
content: '$';
}
.detail-box .balance-log-container .item .amount.debit{
color: #888888;
text-decoration: line-through;
}
.detail-box .balance-log-container .item .factor{
font-size: 12px;
color: #888888;
text-align: right;
float: right;
line-height: 12px;
clear:both;
margin-top: -12px;
}
.detail-box .balance-footer{
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 100px;
padding: 20px;
background: #f1f1f1;
}
.detail-box .balance-footer .row{
width: 100%;
line-height: 30px;
height: 30px;
}
.detail-box .balance-footer .row:after{
display: block;
content: '';
clear: both;
}
.detail-box .balance-footer .row .label{
font-size: 16px;
color: #888888;
float: left;
}
.detail-box .balance-footer .row .amount{
color: #888888;
font-size: 16px;
float: right;
}
.detail-box .balance-footer .row .amount:before{
content: '$';
}
.detail-box .balance-footer .row .amount.available{
color: #30af69;
font-size: 28px;
}
.link-box{
width: 100%;
color: #fff;
left: 0;
bottom: 10px;
position: absolute;
font-size: 16px;
text-align: center;
}
.link-box a{
color: #fff;
}
data-box-amount{
width: 30%;
text-align: center;
}
.used{
text-decoration: line-through;
}

@ -0,0 +1,118 @@
.main-body{
height:92.3%;
width:100%;
/*left: 20px;*/
/*right: 20px;*/
position: fixed;
/*background-color: #FCF7EB;*/
/*bottom: 11.6%;*/
/*text-align: center;*/
}
.body{
width: 90%;
left: 5%;;
height: 100%;
background-color: #FCF7EB;
position: relative;
z-index: 1000;
text-align: center;
}
.head{
width:100%;
}
.banner{
margin-top: 15%;
padding: 20px;
background-size: contain;
}
.wish {
font-size: 18px;
color: #B99B6A;
}
.redpack {
padding:20px;
color: #EC421F;
}
.redpack .amount{
font-size: 45px;
}
.redpack .currency{
font-size: 20px;
}
.redpack .description{
font-size: 14px;
}
p {
color: #8C754F;
font-size: 14px;
text-align:left;
}
.coupon{
}
.coupon-back{
position: relative;
}
.coupon-desc{
position: absolute;
padding: 20px;
top: 0;
}
.coupon-au8{
color: #EC421F;
font-size: 16px;
}
.coupon-head{
padding: 20px 0;
}
.coupon-img{
width: 50px;
vertical-align: middle;
}
@media screen and (max-height: 520px){
p {
color: #8C754F;
font-size: 11px;
text-align:left;
}
.coupon-au8{
color: #EC421F;
font-size: 15px;
}
.coupon-head{
padding: 10px 0;
}
}
.coupon_content{
}
/*.foot1{*/
/*width: 100%;*/
/*position: fixed;*/
/*bottom: 7.7%;*/
/*background-color: #D51727;*/
/*height: 3.9%;*/
/*border-radius: 20px 20px 0 0;*/
/*}*/
.body-bottom {
width: 100%;
position: absolute;
height: 3.9%;
bottom: 0;
border-radius: 20px 20px 0 0;
background-color: #D51727;
}
.foot{
width: 100%;
position:fixed;
height:7.7%;
bottom:0;
background-color: #F5504B;
text-align: center;
font-size: 14px;
color: #FDADAA;
line-height: 50px;
}

@ -410,3 +410,127 @@
background: url(/static/images/button@2x.png) no-repeat;
background-size: 100% 100%;
}
.redpack-dialog {
position: fixed;
display: block;
top: 0;
right: 0;
left: 0;
bottom: 0;
padding: 0 80px;
}
.redpack-dialog.hide {
display: none;
}
.redpack-dialog .mask {
position: absolute;
top: 0;
right: 0;
left: 0;
bottom: 0;
background: rgba(0,0,0, .4);
}
.redpack-dialog .dialog-content {
width: 100%;
display: block;
position: relative;
margin-top: 50px;
/*padding-top: 25px;*/
padding-bottom: 19px;
border-radius: 5px;
/*background: -webkit-linear-gradient(top, rgb(253, 99, 1), rgb(251, 120, 4));*/
/*box-shadow: rgba(0,0,0,.3) 5px 5px 10px;*/
animation:0.5s showDialog;
}
.redpack-dialog .dialog-content .redpack-content {
position: relative;
width: 100%;
color: #fff;
text-align: center;
}
.redpack-dialog .close-btn {
position: absolute;
top: -60px;
right: 0;
display: block;
width: 30px;
height: 114px;
}
.redpack-dialog .close-btn:after {
display: block;
content: '';
width: 0;
border-left: 2px solid #fff;
position: absolute;
left: 16px;
bottom: 0;
height: 56px;
}
.redpack-dialog .close-btn .close-circle {
display: block;
position: relative;
border: 2px solid #fff;
border-radius: 50%;
width: 30px;
height: 30px;
margin-top: 24px;
}
.redpack-dialog .close-btn .close-circle:before {
content: '';
display: block;
position: absolute;
top: 10px;
right: 17px;
width: 10px;
height: 10px;
transform-origin: center;
border-top: 1px solid #fff;
border-right: 1px solid #fff;
transform: rotate(45deg);
}
.redpack-dialog .close-btn .close-circle:after {
content: '';
display: block;
position: absolute;
top: 10px;
left: 16px;
width: 10px;
height: 10px;
border-top: 1px solid #fff;
border-left: 1px solid #fff;
transform: rotate(-45deg);
}
.redpack-content .redpack-img{
position: relative;
width: 100%;
}
.redpack-click {
margin-top: -128px;
position: relative;
}
.redpack-royalpay{
margin-bottom: 20px;
}
.redpack-click .link{
width: 130px;
height: 33px;
margin: auto;
display: block;
font-size: 14px;
line-height: 33px;
border-radius: 15px;
/*border: 2px solid #fff;*/
color: #835B23;
background-color: #FBE214;
}

@ -94,5 +94,21 @@ $(function () {
});
$('.points-dialog .close-circle').click(function () {
$('.points-dialog').addClass('hide');
})
});
});
//2019新春红包活动
function loadRedpack(){
var currentDate = new Date();
var actEndDate = new Date("2019/2/10");
var actStartDate = new Date("2019/2/3");
if ((currentDate >= actStartDate) && (currentDate <= actEndDate)) {
$(".redpack-dialog").removeClass('hide');
}
}
loadRedpack();
$('.redpack-dialog .close-circle').click(function () {
$('.redpack-dialog').addClass('hide');
});
});

@ -0,0 +1,66 @@
package au.com.royalpay.payment.manage.process;
import au.com.royalpay.payment.manage.support.abafile.ABAConfig;
import au.com.royalpay.payment.manage.support.abafile.ABAFile;
import au.com.royalpay.payment.tools.env.PlatformEnvironment;
import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVParser;
import org.apache.commons.csv.CSVRecord;
import org.apache.commons.io.FileUtils;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.test.util.ReflectionTestUtils;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
* Create by yixian at 2019-01-17 12:47
*/
public class ABAGenerator {
private ABAConfig.ABABase config;
private Logger logger = LoggerFactory.getLogger(getClass());
private String csvFile = "C:\\Users\\yixian\\Documents\\royalpay\\2019\\cemtexaba-template-csv.csv";
@Before
public void prepareEnv() {
PlatformEnvironment env = new PlatformEnvironment();
env.afterInitialize();
ReflectionTestUtils.setField(env, "foreignCurrency", "AUD");
config = new ABAConfig.ABABase()
.setBank("CBA")
.setApca("301500")
.setBsb("063109")
.setAccountNo("11505847")
.setAccountName("Tunnel Show Pty Ltd");
}
@Test
public void generate() {
ABAFile file = config.initFile(new Date());
try (FileReader reader = new FileReader(csvFile)) {
CSVParser parser = new CSVParser(reader, CSVFormat.newFormat(','));
List<CSVRecord> records = parser.getRecords();
for (CSVRecord record : records) {
logger.debug("reading record:{}", record.toString());
String bsb = record.get(0).replace("-", "");
String accountNo = record.get(1);
String accountName = record.get(2);
BigDecimal amount = new BigDecimal(record.get(3));
String remark = record.get(4);
file.addSettleMerchant(bsb, accountNo, accountName, amount, remark);
}
byte[] bytes = file.output(0);
FileUtils.writeByteArrayToFile(new File("C:\\Users\\yixian\\Documents\\royalpay\\2019\\cemtexaba-template.aba"), bytes);
logger.info("output done");
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
Loading…
Cancel
Save