diff --git a/pom.xml b/pom.xml
index 6c9ab7a3d..d43ae02c5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -16,6 +16,11 @@
au.com.royalpay.payment
tools
+
+ cn.yixblog
+ yixblog-platform
+ 1.2.0
+
au.com.royalpay.payment
payment-core
diff --git a/src/db/modify.sql b/src/db/modify.sql
index f37a998db..33cff6cca 100644
--- a/src/db/modify.sql
+++ b/src/db/modify.sql
@@ -466,3 +466,30 @@ insert into `royalpay_production`.`sys_configs` ( `config_key`, `config_value`)
insert into `royalpay_production`.`sys_configs` ( `config_key`, `config_value`) values ( 'risk_total_amout', '5000');
+CREATE TABLE `pmt_directed_bill_code` (
+ `bill_code_id` varchar(50) NOT NULL DEFAULT '',
+ `client_id` int(15) not NULL,
+ `client_order_id` varchar(50) DEFAULT NULL,
+ `status` int(10) DEFAULT '1' COMMENT '账单状态 1:可用,2:关闭 3:完成',
+ `customer_id` varchar(200) DEFAULT NULL COMMENT 'open_id',
+ `create_time` datetime not NULL DEFAULT now() comment '账单创建时间',
+ `currency` varchar(10) not NULL,
+ `remark` varchar(200) DEFAULT NULL,
+ `cancle_time` datetime DEFAULT NULL,
+ `channel` varchar(10) DEFAULT NULL,
+ `nickname` varchar(80) DEFAULT NULL,
+ `headimg` varchar(200) DEFAULT NULL,
+ `code_url` varchar(200) DEFAULT '',
+ `order_id` varchar(50) DEFAULT '',
+ `order_amount` decimal(10,4) not NULL comment '账单金额',
+ `pay_amount` decimal(10,4) DEFAULT NULL comment '订单支付金额',
+ `pay_time` datetime DEFAULT NULL comment '支付时间',
+ `order_status` int(10) DEFAULT NULL COMMENT '订单状态(0-New,1-OrderFailed,2-WaitingForPayment,3-OrderCanceled,4-PaymentFailed,5-PaymentSuccess,6-PartialRefund,7-FullRefund)',
+ PRIMARY KEY (`bill_code_id`),
+ KEY `client_id` (`client_id`),
+ KEY `order_id` (`order_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
+
+ALTER TABLE `act_red_packets_customer` ADD COLUMN `rule_max_num_limit` tinyint(1) DEFAULT 1 COMMENT '0:Whole Activity,1:day'
+
+
diff --git a/src/main/java/au/com/royalpay/payment/manage/activities/monsettledelay/core/impls/ActMonDelaySettleServiceImp.java b/src/main/java/au/com/royalpay/payment/manage/activities/monsettledelay/core/impls/ActMonDelaySettleServiceImp.java
index f553a604b..fa21fd761 100644
--- a/src/main/java/au/com/royalpay/payment/manage/activities/monsettledelay/core/impls/ActMonDelaySettleServiceImp.java
+++ b/src/main/java/au/com/royalpay/payment/manage/activities/monsettledelay/core/impls/ActMonDelaySettleServiceImp.java
@@ -152,7 +152,7 @@ public class ActMonDelaySettleServiceImp implements ActMonDelaySettleService {
device.put("rate", params.getBigDecimal("rate") == null ? new BigDecimal(0.15) : params.getBigDecimal("rate"));
device.put("expire_time", act.getDate("expire_date"));
actMonDelaySettleMapper.save(device);
- clientManager.changeManualSettle(client_id,true,device.getString("account_id"),1,"参加活动打开手动清算");
+ clientManager.changeManualSettle(account,client_id,true,device.getString("account_id"),1,"参加活动打开手动清算");
}
@@ -174,7 +174,8 @@ public class ActMonDelaySettleServiceImp implements ActMonDelaySettleService {
clientLog.put("is_valid", 0);
clientLog.put("expire_time", new Date());
actMonDelaySettleMapper.update(clientLog);
- clientManager.changeManualSettle(client_id,false,device.getString("account_id"),1,"退出活动关闭手动清算");
+ JSONObject account = clientAccountMapper.findById(device.getString("account_id"));
+ clientManager.changeManualSettle(account,client_id,false,device.getString("account_id"),1,"退出活动关闭手动清算");
}
private void recodeActClient(JSONObject device){
diff --git a/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/DashboardServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/DashboardServiceImpl.java
index c7a51b3ca..be08de126 100644
--- a/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/DashboardServiceImpl.java
+++ b/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/DashboardServiceImpl.java
@@ -23,6 +23,7 @@ import org.apache.commons.lang3.time.DurationFormatUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cache.annotation.Cacheable;
+import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
@@ -35,6 +36,7 @@ import java.util.List;
import java.util.Map;
import java.util.TimeZone;
import java.util.TreeMap;
+import java.util.concurrent.TimeUnit;
import javax.annotation.Resource;
@@ -60,12 +62,22 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT
@Resource
private TransactionMapper transactionMapper;
+ @Resource
+ private StringRedisTemplate stringRedisTemplate;
+
@Override
public JSONObject getCommonAnalysis1(JSONObject params) {
+ String jsonStr = stringRedisTemplate.boundValueOps("org_commonAnalysis1"+ params.getString("org_id")+ params.getString("begin")).get();
+ JSONObject commonAnalysis1 = JSONObject.parseObject(jsonStr);
+ if(commonAnalysis1 != null){
+ return commonAnalysis1;
+ }
JSONObject res = transactionAnalysisMapper.getClientTransaction(params);
-// res.put("new_partners", clientAnalysisMapper.countNewClients(params));
+ stringRedisTemplate.boundValueOps("org_commonAnalysis1"+params.getString("org_id")+params.getString("begin")).set(res.toJSONString(), 5, TimeUnit.MINUTES);
+ return res;
+ // res.put("new_partners", clientAnalysisMapper.countNewClients(params));
// res.put("total_partners", clientAnalysisMapper.countClients(params));
// res.put("traded_partners", clientAnalysisMapper.countTradedPartners(params));
// List topOrders = transactionAnalysisMapper.getTopOrders(params, new PageBounds(1, 1, Order.formString("aud_fee.desc")));
@@ -75,7 +87,6 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT
// res.put("total_customers", transactionAnalysisMapper.countCustomers(params));
// //res.put("new_customers", transactionAnalysisMapper.countNewCustomers(params));
// res.put("old_customers", transactionAnalysisMapper.countOldCustomers(params));
- return res;
}
@Override
diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java b/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java
index 30038b918..046be4ee5 100644
--- a/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java
+++ b/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java
@@ -1133,8 +1133,9 @@ public class RetailAppServiceImp implements RetailAppService {
@Override
public JSONObject listDailyTransactions(String dateStr, String timezone, boolean thisDevOnly, JSONObject device,String app_client_ids) {
try {
+ JSONObject client = clientManager.getClientInfo(device.getIntValue("client_id"));
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
- dateFormat.setTimeZone(TimeZone.getTimeZone(timezone));
+ dateFormat.setTimeZone(TimeZone.getTimeZone(client.getString("timezone")));
Date date = dateFormat.parse(dateStr);
String clientType = device.getString("client_type");
DeviceRegister register = deviceSupport.findRegister(clientType);
@@ -1542,7 +1543,8 @@ 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, "商户"+(manual_settle?"打开":"关闭")+"手动清算");
+ JSONObject account = clientAccountMapper.findById(device.getString("account_id"));
+ clientManager.changeManualSettle(account,device.getIntValue("client_id"), manual_settle, device.getString("account_id"), 1, "商户"+(manual_settle?"打开":"关闭")+"手动清算");
}
diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java b/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java
index e88beb389..70ca70922 100644
--- a/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java
+++ b/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java
@@ -22,22 +22,31 @@ import au.com.royalpay.payment.tools.exceptions.ForbiddenException;
import au.com.royalpay.payment.tools.http.HttpUtils;
import au.com.royalpay.payment.tools.merchants.beans.QRCodeConfig;
import au.com.royalpay.payment.tools.merchants.beans.UpdateSurchargeDTO;
+
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
+
import org.apache.commons.lang3.time.DateUtils;
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.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
-import javax.annotation.Resource;
-import javax.servlet.http.HttpServletResponse;
-import javax.validation.Valid;
import java.math.BigDecimal;
import java.text.ParseException;
import java.util.Date;
import java.util.List;
import java.util.Map;
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import javax.validation.Valid;
+
import static au.com.royalpay.payment.tools.CommonConsts.RETAIL_DEVICE;
/**
@@ -439,10 +448,13 @@ public class RetailAppController {
}
@RequestMapping(value = "/qrcode", method = RequestMethod.GET)
- public JSONObject getQrcode(@ModelAttribute(RETAIL_DEVICE) JSONObject device,@RequestParam(required = false,defaultValue = "0") int client_id, QRCodeConfig config) {
+ public JSONObject getQrcode(@ModelAttribute(RETAIL_DEVICE) JSONObject device,@RequestParam(required = false,defaultValue = "0") int client_id, QRCodeConfig config,@RequestParam(required = false,defaultValue = "0") int app_client_ids) {
if(client_id==0){
client_id = device.getIntValue("client_id");
}
+ if(app_client_ids!=0){
+ client_id = app_client_ids;
+ }
return retailAppService.getQrcode(device,config,client_id);
}
@@ -461,4 +473,16 @@ public class RetailAppController {
public void getInvoiceFile(@ModelAttribute(RETAIL_DEVICE) JSONObject device,AppQueryBean appQueryBean,HttpServletResponse httpResponse) throws Exception {
retailAppService.getInvoiceFile(device,appQueryBean,httpResponse);
}
+
+ @RequestMapping(value = "/surcharge", method = RequestMethod.GET)
+ public JSONObject changeQRCodePaySurCharge(@ModelAttribute(RETAIL_DEVICE) JSONObject device) {
+ JSONObject client = retailAppService.getClientInfo(device);
+ JSONObject result = new JSONObject();
+ result.put("qrcode_surcharge", client.getBooleanValue("qrcode_surcharge"));
+ result.put("retail_surcharge", client.getBooleanValue("retail_surcharge"));
+ result.put("api_surcharge", client.getBooleanValue("api_surcharge"));
+ result.put("require_custinfo", client.getBooleanValue("require_custinfo"));
+ result.put("require_remark", client.getBooleanValue("require_remark"));
+ return result;
+ }
}
diff --git a/src/main/java/au/com/royalpay/payment/manage/billqrcode/bean/NewBillQrCodeBean.java b/src/main/java/au/com/royalpay/payment/manage/billqrcode/bean/NewBillQrCodeBean.java
new file mode 100644
index 000000000..937620a67
--- /dev/null
+++ b/src/main/java/au/com/royalpay/payment/manage/billqrcode/bean/NewBillQrCodeBean.java
@@ -0,0 +1,77 @@
+package au.com.royalpay.payment.manage.billqrcode.bean;
+
+import com.alibaba.fastjson.JSONObject;
+import org.apache.commons.lang3.StringUtils;
+
+import java.math.BigDecimal;
+
+public class NewBillQrCodeBean {
+
+ private BigDecimal order_amount;
+
+ private String currency = "AUD";
+
+ private String remark;
+
+ private String cancle_time;
+
+ private String client_order_id;
+
+ public JSONObject toJson(){
+ JSONObject record = new JSONObject();
+ if(order_amount != null){
+ record.put("order_amount",order_amount);
+ }
+ if(StringUtils.isNotEmpty(remark)){
+ record.put("remark",remark);
+ }
+ if(StringUtils.isNotEmpty(client_order_id)){
+ record.put("client_order_id",client_order_id);
+ }
+ if (StringUtils.isNotEmpty(cancle_time)) {
+ record.put("cancle_time",cancle_time);
+ }
+ record.put("currency",currency);
+ return record;
+ }
+
+ public BigDecimal getOrder_amount() {
+ return order_amount;
+ }
+
+ public void setOrder_amount(BigDecimal order_amount) {
+ this.order_amount = order_amount;
+ }
+
+ public String getCurrency() {
+ return currency;
+ }
+
+ public void setCurrency(String currency) {
+ this.currency = currency;
+ }
+
+ public String getRemark() {
+ return remark;
+ }
+
+ public void setRemark(String remark) {
+ this.remark = remark;
+ }
+
+ public String getCancle_time() {
+ return cancle_time;
+ }
+
+ public void setCancle_time(String cancle_time) {
+ this.cancle_time = cancle_time;
+ }
+
+ public String getClient_order_id() {
+ return client_order_id;
+ }
+
+ public void setClient_order_id(String client_order_id) {
+ this.client_order_id = client_order_id;
+ }
+}
diff --git a/src/main/java/au/com/royalpay/payment/manage/billqrcode/bean/QueryBillBean.java b/src/main/java/au/com/royalpay/payment/manage/billqrcode/bean/QueryBillBean.java
new file mode 100644
index 000000000..bf5e7fb6b
--- /dev/null
+++ b/src/main/java/au/com/royalpay/payment/manage/billqrcode/bean/QueryBillBean.java
@@ -0,0 +1,57 @@
+package au.com.royalpay.payment.manage.billqrcode.bean;
+
+import com.alibaba.fastjson.JSONObject;
+import org.apache.commons.lang3.StringUtils;
+
+/**
+ * Created by yuan on 2018/5/9.
+ */
+public class QueryBillBean {
+ private int limit = 10;
+ private int page = 1;
+ private String status;
+ private String client_order_id;
+
+ public JSONObject toJson(){
+ JSONObject jason = new JSONObject();
+ if(StringUtils.isNotEmpty(status)){
+ jason.put("status",status);
+ }
+ if(StringUtils.isNotEmpty(client_order_id)){
+ jason.put("client_order_id",client_order_id);
+ }
+ return jason;
+ }
+
+ public int getLimit() {
+ return limit;
+ }
+
+ public void setLimit(int limit) {
+ this.limit = limit;
+ }
+
+ public int getPage() {
+ return page;
+ }
+
+ public void setPage(int page) {
+ this.page = page;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+ public String getClient_order_id() {
+ return client_order_id;
+ }
+
+ public void setClient_order_id(String client_order_id) {
+ this.client_order_id = client_order_id;
+ }
+}
diff --git a/src/main/java/au/com/royalpay/payment/manage/billqrcode/core/PartnerBillService.java b/src/main/java/au/com/royalpay/payment/manage/billqrcode/core/PartnerBillService.java
new file mode 100644
index 000000000..def496f3c
--- /dev/null
+++ b/src/main/java/au/com/royalpay/payment/manage/billqrcode/core/PartnerBillService.java
@@ -0,0 +1,20 @@
+package au.com.royalpay.payment.manage.billqrcode.core;
+
+import au.com.royalpay.payment.manage.billqrcode.bean.NewBillQrCodeBean;
+import au.com.royalpay.payment.manage.billqrcode.bean.QueryBillBean;
+import com.alibaba.fastjson.JSONObject;
+
+import java.util.List;
+
+/**
+ * Created by yuan on 2018/5/3.
+ */
+public interface PartnerBillService {
+ String saveBill(JSONObject partner, NewBillQrCodeBean newBillQrCodeBean);
+
+ List listBills(JSONObject partner, QueryBillBean queryBillBean);
+
+ void dailyCheckDirectedBillCode();
+
+ void disableBills(JSONObject partner,String bill_code_id);
+}
diff --git a/src/main/java/au/com/royalpay/payment/manage/billqrcode/core/impl/PartnerBillServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/billqrcode/core/impl/PartnerBillServiceImpl.java
new file mode 100644
index 000000000..7029bc925
--- /dev/null
+++ b/src/main/java/au/com/royalpay/payment/manage/billqrcode/core/impl/PartnerBillServiceImpl.java
@@ -0,0 +1,126 @@
+package au.com.royalpay.payment.manage.billqrcode.core.impl;
+
+import au.com.royalpay.payment.manage.billqrcode.bean.NewBillQrCodeBean;
+import au.com.royalpay.payment.manage.billqrcode.bean.QueryBillBean;
+import au.com.royalpay.payment.manage.billqrcode.core.PartnerBillService;
+import au.com.royalpay.payment.manage.mappers.billqrcode.DirectedBillCodeMapper;
+import au.com.royalpay.payment.manage.mappers.system.ClientMapper;
+import au.com.royalpay.payment.manage.merchants.core.ClientManager;
+import au.com.royalpay.payment.tools.env.PlatformEnvironment;
+import au.com.royalpay.payment.tools.exceptions.BadRequestException;
+import au.com.royalpay.payment.tools.exceptions.NotFoundException;
+import au.com.royalpay.payment.tools.utils.QRCodeUtils;
+import com.alibaba.fastjson.JSONObject;
+import com.github.miemiedev.mybatis.paginator.domain.Order;
+import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
+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.LoggerFactory;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Created by yuan on 2018/5/3.
+ */
+@Service
+public class PartnerBillServiceImpl implements PartnerBillService {
+ private org.slf4j.Logger logger = LoggerFactory.getLogger(getClass());
+ @Resource
+ private ClientMapper clientMapper;
+
+ @Resource
+ private ClientManager clientManager;
+
+ @Resource
+ private DirectedBillCodeMapper directedBillCodeMapper;
+
+
+ @Override
+ @Transactional
+ public String saveBill(JSONObject partner, NewBillQrCodeBean newBillQrCodeBean) {
+ JSONObject client = clientMapper.findClientByMoniker(partner.getString("client_moniker"));
+ if (client == null) {
+ throw new NotFoundException("client info not found");
+ }
+ if(StringUtils.isNotEmpty(newBillQrCodeBean.getClient_order_id())){
+ JSONObject bill = directedBillCodeMapper.findOne(newBillQrCodeBean.getClient_order_id());
+ if(bill != null){
+ if(bill.getIntValue("status") == 2){
+ throw new BadRequestException("该订单已关闭,请确认");
+ }
+ if(bill.getIntValue("status") == 3){
+ throw new BadRequestException("该订单已完成,请确认");
+ }
+ if(bill.getIntValue("status") == 1){
+ if(bill.getBigDecimal("order_amount") == newBillQrCodeBean.getOrder_amount()){
+ return QRCodeUtils.qrcodeImageCode(bill.getString("code_url"), 250, false);
+ }
+ throw new BadRequestException("已有相同订单号正在被支付,详情请查看订单列表");
+ }
+ }
+ }
+ JSONObject record = newBillQrCodeBean.toJson();
+ if(record.getString("client_order_id") == null){
+ record.put("client_order_id","Bill_" + DateFormatUtils.format(new Date(), "yyyyMMddHHmmss") + "_" + RandomStringUtils.random(5, true, true).toUpperCase());
+ }
+ record.put("client_id",partner.getIntValue("client_id"));
+ record.put("create_time", new Date());
+ record.put("status",1);
+ directedBillCodeMapper.save(record);
+ String code_url = getQRCodeImg(record);
+ record.put("code_url",code_url);
+ directedBillCodeMapper.update(record);
+ return QRCodeUtils.qrcodeImageCode(code_url, 250, false);
+ }
+
+ private String getQRCodeImg(JSONObject bill){
+ return PlatformEnvironment.getEnv().concatUrl("api/v1.0/share_code/business/bills/"+bill.getString("bill_code_id"));
+ }
+
+ @Override
+ public List listBills(JSONObject partner, QueryBillBean queryBillBean) {
+ int client_id = partner.getInteger("client_id");
+ JSONObject client = clientManager.getClientInfo(client_id);
+ if (client == null) {
+ throw new NotFoundException("client info not found");
+ }
+ JSONObject params = queryBillBean.toJson();
+ params.put("client_id",client_id);
+ List bills = directedBillCodeMapper.findByClientId(params,new PageBounds(queryBillBean.getPage(),queryBillBean.getLimit(), Order.formString("create_time.desc")));
+ bills.stream().filter(t->StringUtils.isNotEmpty(t.getString("code_url"))).forEach(t->t.put("code_url",QRCodeUtils.qrcodeImageCode(t.getString("code_url"), 250, false)));
+ return bills;
+ }
+
+ @Override
+ public void disableBills(JSONObject partner, String bill_code_id) {
+ int client_id = partner.getInteger("client_id");
+ JSONObject client = clientManager.getClientInfo(client_id);
+ if (client == null) {
+ throw new NotFoundException("client info not found");
+ }
+ JSONObject bill = directedBillCodeMapper.findOneByBillCodeId(bill_code_id);
+ if(bill.getIntValue("status")==1){
+ if(bill.getString("order_id") != null){
+ bill.put("status",2);
+ directedBillCodeMapper.update(bill);
+ }
+ }
+ }
+
+ @Override
+ public void dailyCheckDirectedBillCode() {
+ List listAllBill = directedBillCodeMapper.listAllBills();
+ for (JSONObject bill: listAllBill) {
+ if(DateUtils.addDays(bill.getDate("cancle_time"),1).before(new Date())){
+ bill.put("status",2);
+ directedBillCodeMapper.update(bill);
+ }
+ }
+ }
+}
diff --git a/src/main/java/au/com/royalpay/payment/manage/billqrcode/web/PartnerBillController.java b/src/main/java/au/com/royalpay/payment/manage/billqrcode/web/PartnerBillController.java
new file mode 100644
index 000000000..745f281a8
--- /dev/null
+++ b/src/main/java/au/com/royalpay/payment/manage/billqrcode/web/PartnerBillController.java
@@ -0,0 +1,37 @@
+package au.com.royalpay.payment.manage.billqrcode.web;
+
+import au.com.royalpay.payment.manage.billqrcode.bean.NewBillQrCodeBean;
+import au.com.royalpay.payment.manage.billqrcode.bean.QueryBillBean;
+import au.com.royalpay.payment.manage.billqrcode.core.PartnerBillService;
+import au.com.royalpay.payment.manage.permission.manager.PartnerMapping;
+import au.com.royalpay.payment.tools.CommonConsts;
+import com.alibaba.fastjson.JSONObject;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+/**
+ * Created by yuan on 2018/5/3.
+ */
+@RestController
+@RequestMapping("/partner/qrcode")
+public class PartnerBillController {
+
+ @Resource
+ private PartnerBillService partnerBillService;
+
+ @PartnerMapping(value = "/bills", method = RequestMethod.POST)
+ public String addBill(@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject partner, @RequestBody NewBillQrCodeBean newBillQrCodeBean) {
+ return partnerBillService.saveBill(partner, newBillQrCodeBean);
+ }
+
+ @PartnerMapping(value = "", method = RequestMethod.GET)
+ public List listBills(@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject partner, QueryBillBean queryBillBean) {
+ return partnerBillService.listBills(partner,queryBillBean);
+ }
+ @PartnerMapping(value = "/{bill_code_id}", method = RequestMethod.DELETE)
+ public void disableBills(@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject partner,@PathVariable String bill_code_id) {
+ partnerBillService.disableBills(partner,bill_code_id);
+ }
+}
diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/billqrcode/DirectedBillCodeMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/billqrcode/DirectedBillCodeMapper.java
new file mode 100644
index 000000000..95b64f29e
--- /dev/null
+++ b/src/main/java/au/com/royalpay/payment/manage/mappers/billqrcode/DirectedBillCodeMapper.java
@@ -0,0 +1,33 @@
+package au.com.royalpay.payment.manage.mappers.billqrcode;
+
+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 com.github.miemiedev.mybatis.paginator.domain.PageBounds;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+@AutoMapper(tablename = "pmt_directed_bill_code", pkName = "bill_code_id")
+public interface DirectedBillCodeMapper {
+ @AutoSql(type = SqlType.INSERT)
+ int save(JSONObject record);
+
+ @AutoSql(type = SqlType.SELECT)
+ JSONObject findOne(@Param("client_order_id") String client_order_id);
+
+ @AutoSql(type = SqlType.SELECT)
+ JSONObject findOneByBillCodeId(@Param("bill_code_id") String bill_code_id);
+
+ @AutoSql(type = SqlType.UPDATE)
+ int update(JSONObject record);
+
+ @AutoSql(type = SqlType.SELECT)
+ List findByClientId(JSONObject params, PageBounds pageBounds);
+
+ @AutoSql(type = SqlType.SELECT)
+ @AdvanceSelect(addonWhereClause = "status=1")
+ List listAllBills();
+}
diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/redpack/ActRedPacketsCustomerOrdersMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/redpack/ActRedPacketsCustomerOrdersMapper.java
index 67c544ec4..631a78ca6 100644
--- a/src/main/java/au/com/royalpay/payment/manage/mappers/redpack/ActRedPacketsCustomerOrdersMapper.java
+++ b/src/main/java/au/com/royalpay/payment/manage/mappers/redpack/ActRedPacketsCustomerOrdersMapper.java
@@ -44,4 +44,8 @@ public interface ActRedPacketsCustomerOrdersMapper {
PageList listOrders(JSONObject jsonObject, PageBounds pageBounds);
List listUnsend(@Param("act_id") String actId, @Param("before") Date before);
+
+ List getCustomerRedpackAnalysis(JSONObject params);
+
+ JSONObject analysisCustomerLuckyMoney(JSONObject params);
}
diff --git a/src/main/java/au/com/royalpay/payment/manage/merchantid/core/impl/MerchantIdManageServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/merchantid/core/impl/MerchantIdManageServiceImpl.java
index cb6618a72..6a77ac270 100644
--- a/src/main/java/au/com/royalpay/payment/manage/merchantid/core/impl/MerchantIdManageServiceImpl.java
+++ b/src/main/java/au/com/royalpay/payment/manage/merchantid/core/impl/MerchantIdManageServiceImpl.java
@@ -7,6 +7,7 @@ import au.com.royalpay.payment.manage.mappers.client.ClientSubMerchantIdMapper;
import au.com.royalpay.payment.manage.mappers.payment.CommonSubMerchantIdMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientMapper;
import au.com.royalpay.payment.manage.merchantid.core.MerchantIdManageService;
+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.ServerErrorException;
@@ -144,19 +145,14 @@ public class MerchantIdManageServiceImpl implements MerchantIdManageService {
@Override
public JSONObject getClientQrCodeImg(JSONObject manager,String sub_merchant_id) {
- List clientMonikers = showClientMoniker(manager,sub_merchant_id);
- if(clientMonikers.isEmpty()){
- throw new BadRequestException("当前子商户号下暂无商户");
- }
- String partner_code = clientMonikers.get(0).getString("client_moniker");
+ String partner_code = "PINE";
String orderId = "Merchant" + DateFormatUtils.format(new Date(), "yyyyMMddHHmmss") + "_" + RandomStringUtils.random(5, true, true).toUpperCase();
JSONObject param = new JSONObject();
- param.put("price", 10);
+ param.put("price", 1);
param.put("description", "order");
param.put("operator", "web");
- param.put("currency","CNY");
- String createUrl= "https://mpay.royalpay.com.au/api/v1.0/gateway/partners/" + partner_code + "/orders/" + orderId + "?" + queryParams(partner_code);
-
+ param.put("sub_merchant_id",sub_merchant_id);
+ String createUrl= PlatformEnvironment.getEnv().concatUrl("api/v1.0/gateway/partners/" + partner_code + "/orders/" + orderId +"/manager/test"+"?" + queryParams(partner_code));
HttpRequestResult result = null;
try {
result = new HttpRequestGenerator(createUrl, RequestMethod.PUT).setJSONEntity(param).execute();
diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java
index 4f2a1293f..dd3a36ba7 100644
--- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java
+++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java
@@ -229,7 +229,7 @@ public interface ClientManager {
void changePaymentPage(JSONObject account, String paypad_version);
- void changeManualSettle(int client_id, boolean manual_settle,String operator_id,int type,String operation);
+ void changeManualSettle(JSONObject account , int client_id, boolean manual_settle,String operator_id,int type,String operation);
void changeQRCodePaySurcharge(JSONObject account, boolean paySurcharge);
diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java
index 0540b3bb7..f7a08274c 100644
--- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java
+++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java
@@ -669,6 +669,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
boolean checkGreenChannel = client.getIntValue("approve_result") == 2 && (client.getIntValue("source") == 1 || client.getIntValue("source") == 2);
AuditModify auditModify = new AuditModify(manager, clientMoniker, pass, manager.getString("manager_id"), new Date());
auditModify.setOpen_status(5);
+ client.put("open_status", 5);
if (client.getIntValue("source") == 5) {
auditModify.setSource(1);
}
@@ -2182,6 +2183,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
if (CollectionUtils.isEmpty(existFiles)) {
throw new BadRequestException("The Agree File is not Complete!");
}
+ client.put("open_status", 3);
clientModifySupport.processClientModify(new OpenStatusModify(manager, clientMoniker, 3));
saveClientAuditProcess(client.getIntValue("client_id"), 2, 3, "合同制作完成,等待BD处理", manager);
// sendAgreeFileMsgToBD(client,null);
@@ -2541,8 +2543,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
} else {
openStatusModify.setApprove_time(new Date());
openStatusModify.setApprove_result(4);
-
}
+ client.put("open_status", 4);
clientModifySupport.processClientModify(openStatusModify);
saveClientAuditProcess(client.getIntValue("client_id"), open_status_from, 4, "BD完成签字提交compliance审核", manager);
if (manager != null) {
@@ -2676,16 +2678,12 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
@Override
@Transactional
- public void changeManualSettle(int client_id, boolean manual_settle, String operator_id, int type, String operation) {
+ public void changeManualSettle(JSONObject account,int client_id, boolean manual_settle, String operator_id, int type, String operation) {
JSONObject client = getClientInfo(client_id);
if (client == null) {
throw new BadRequestException("merchant not found");
}
- JSONObject record = new JSONObject();
- record.put("client_id", client_id);
- record.put("manual_settle", manual_settle);
- clientConfigService.update(record);
-
+ clientModifySupport.processClientConfigModify(new SwitchPermissionModify(account,client.getString("client_moniker"),"manual_settle",manual_settle));
JSONObject actClientLog = new JSONObject();
actClientLog.put("client_id", client_id);
actClientLog.put("operator_id", operator_id);
diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/AuditModify.java b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/AuditModify.java
index 2fb4092c2..2e84e79d2 100644
--- a/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/AuditModify.java
+++ b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/AuditModify.java
@@ -19,7 +19,6 @@ public class AuditModify extends ClientModify {
private Date approve_time;
private String refuse_remark;
-
public AuditModify(JSONObject account, String clientMoniker, Integer approve_result, String approver, Date approve_time) {
super(account, clientMoniker);
this.approve_result = approve_result;
@@ -35,17 +34,15 @@ public class AuditModify extends ClientModify {
@Override
protected JSONObject getModifyResult() {
JSONObject modify = new JSONObject();
- modify.put("approve_result",approve_result);
- modify.put("approver",approver);
- modify.put("approve_time",approve_time);
- if(source!=null){
- modify.put("source",source);
- }
- if(open_status!=null){
- modify.put("open_status",open_status);
+ modify.put("approve_result", approve_result);
+ modify.put("approver", approver);
+ modify.put("approve_time", approve_time);
+ if (source != null) {
+ modify.put("source", source);
}
- if(StringUtils.isNotEmpty(refuse_remark)){
- modify.put("refuse_remark",refuse_remark);
+ modify.put("open_status", open_status);
+ if (StringUtils.isNotEmpty(refuse_remark)) {
+ modify.put("refuse_remark", refuse_remark);
}
return modify;
}
@@ -66,4 +63,3 @@ public class AuditModify extends ClientModify {
this.approve_result = approve_result;
}
}
-
diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerViewController.java b/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerViewController.java
index 59567a097..3e2e8fcad 100644
--- a/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerViewController.java
+++ b/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerViewController.java
@@ -365,7 +365,7 @@ 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,account.getIntValue("client_id"), manual_settle, account.getString("account_id"), 1, "商户" + (manual_settle ? "打开" : "关闭") + "手动清算");
}
@PartnerMapping(value = "/checkContract", method = RequestMethod.GET)
diff --git a/src/main/java/au/com/royalpay/payment/manage/redpack/beans/CustomerRedpackActBean.java b/src/main/java/au/com/royalpay/payment/manage/redpack/beans/CustomerRedpackActBean.java
index bbe9b58de..cf9b1a460 100644
--- a/src/main/java/au/com/royalpay/payment/manage/redpack/beans/CustomerRedpackActBean.java
+++ b/src/main/java/au/com/royalpay/payment/manage/redpack/beans/CustomerRedpackActBean.java
@@ -13,6 +13,7 @@ public class CustomerRedpackActBean {
private String act_name;
private BigDecimal rule_order_total;
private int rule_max_num;
+ private int rule_max_num_limit;
private int status=0;
private List prize_type_list;
@@ -59,4 +60,12 @@ public class CustomerRedpackActBean {
public void setPrize_type_list(List prize_type_list) {
this.prize_type_list = prize_type_list;
}
+
+ public int getRule_max_num_limit() {
+ return rule_max_num_limit;
+ }
+
+ public void setRule_max_num_limit(int rule_max_num_limit) {
+ this.rule_max_num_limit = rule_max_num_limit;
+ }
}
diff --git a/src/main/java/au/com/royalpay/payment/manage/redpack/beans/RedpackQuery.java b/src/main/java/au/com/royalpay/payment/manage/redpack/beans/RedpackQuery.java
index 2a54140c7..bbad4bfb5 100644
--- a/src/main/java/au/com/royalpay/payment/manage/redpack/beans/RedpackQuery.java
+++ b/src/main/java/au/com/royalpay/payment/manage/redpack/beans/RedpackQuery.java
@@ -2,6 +2,7 @@ package au.com.royalpay.payment.manage.redpack.beans;
import au.com.royalpay.payment.core.exceptions.ParamInvalidException;
import com.alibaba.fastjson.JSONObject;
+import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import java.text.ParseException;
@@ -50,16 +51,16 @@ public class RedpackQuery {
throw new ParamInvalidException("event_date", "error.payment.valid.invalid_date_format");
}
}
- if (short_name != null){
+ if (StringUtils.isNotEmpty(short_name)){
param.put("short_name",short_name);
}
- if (client_moniker != null){
+ if (StringUtils.isNotEmpty(client_moniker)){
param.put("client_moniker",client_moniker);
}
- if (nickname != null){
+ if (StringUtils.isNotEmpty(nickname)){
param.put("nickname",nickname);
}
- if (org_id != null){
+ if (StringUtils.isNotEmpty(org_id)){
param.put("org_id",org_id);
}
if (bd != null){
diff --git a/src/main/java/au/com/royalpay/payment/manage/redpack/core/ActRedPackService.java b/src/main/java/au/com/royalpay/payment/manage/redpack/core/ActRedPackService.java
index 7e7c886c7..5a4b44fef 100644
--- a/src/main/java/au/com/royalpay/payment/manage/redpack/core/ActRedPackService.java
+++ b/src/main/java/au/com/royalpay/payment/manage/redpack/core/ActRedPackService.java
@@ -1,8 +1,11 @@
package au.com.royalpay.payment.manage.redpack.core;
import au.com.royalpay.payment.core.exceptions.RedPackException;
+import au.com.royalpay.payment.manage.redpack.beans.RedpackQuery;
import com.alibaba.fastjson.JSONObject;
+import java.util.List;
+
/**
* Created by wangning on 2017/8/10.
*/
@@ -23,4 +26,8 @@ public interface ActRedPackService {
JSONObject listCustomerOrders(JSONObject params, int page, int limit);
void resendFailed();
+
+ List getCustomerRedpackAnalysis(String act_id, RedpackQuery redpackQuery);
+
+ JSONObject analysisCustomerLuckyMoney(JSONObject params);
}
diff --git a/src/main/java/au/com/royalpay/payment/manage/redpack/core/impls/ActRedPackServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/redpack/core/impls/ActRedPackServiceImpl.java
index 963cdcd66..c56780750 100644
--- a/src/main/java/au/com/royalpay/payment/manage/redpack/core/impls/ActRedPackServiceImpl.java
+++ b/src/main/java/au/com/royalpay/payment/manage/redpack/core/impls/ActRedPackServiceImpl.java
@@ -7,6 +7,7 @@ import au.com.royalpay.payment.manage.mappers.redpack.ActPrizeTypeCustomerMapper
import au.com.royalpay.payment.manage.mappers.redpack.ActRedPacketsCustomerMapper;
import au.com.royalpay.payment.manage.mappers.redpack.ActRedPacketsCustomerOrdersMapper;
import au.com.royalpay.payment.manage.mappers.system.CustomerMapper;
+import au.com.royalpay.payment.manage.redpack.beans.RedpackQuery;
import au.com.royalpay.payment.manage.redpack.core.ActRedPackService;
import au.com.royalpay.payment.tools.CommonConsts;
import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApi;
@@ -15,13 +16,15 @@ import au.com.royalpay.payment.tools.connections.mpsupport.beans.WechatRedpack;
import au.com.royalpay.payment.tools.exceptions.ForbiddenException;
import au.com.royalpay.payment.tools.exceptions.NotFoundException;
import au.com.royalpay.payment.tools.utils.PageListUtils;
+
import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList;
+
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.RandomStringUtils;
-import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.RandomUtils;
+import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.slf4j.Logger;
@@ -30,7 +33,6 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
-import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Collections;
import java.util.Date;
@@ -39,6 +41,8 @@ import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
+import javax.annotation.Resource;
+
/**
* Created by wangning on 2017/8/10.
*/
@@ -129,37 +133,51 @@ public class ActRedPackServiceImpl implements ActRedPackService {
int getTotalCounts = getRedPacketsByOpenid(open_id, new Date(), actId);
int ruleMaxNum = redpackCustomerActivity.getIntValue("rule_max_num");
if (getTotalCounts >= ruleMaxNum) {
- logger.error("open_id:" + open_id + "当日红包发送数量已到达" + ruleMaxNum + "!跳过");
+ logger.debug("open_id:" + open_id + "已达到本次活动发送最大次数" + ruleMaxNum + "!跳过");
+ return;
+ }
+
+ int getDailyTotalCounts = getRedPacketsByOpenid(open_id, new Date(), actId);
+ int ruleMaxNumLimit = redpackCustomerActivity.getIntValue("rule_max_num_limit");
+ if (getDailyTotalCounts >= ruleMaxNumLimit) {
+ logger.debug("open_id:" + open_id + "已达当日发送最大次数" + ruleMaxNumLimit + "!跳过");
return;
}
- takeRedpack(actId,orderId, client_id, clientApply, currencyAmount, open_id, 0);
+
+ takeRedpack(actId, orderId, client_id, clientApply, currencyAmount, open_id, 0);
}
- private void takeRedpack(String actId,String orderId, int client_id, JSONObject clientApply, BigDecimal currencyAmount, String open_id, int tryTimes)
+ private void takeRedpack(String actId, String orderId, int client_id, JSONObject clientApply, BigDecimal currencyAmount, String open_id, int tryTimes)
throws RedPackException {
if (tryTimes > 5) {
return;
}
+ int random = (int) (Math.random() * 100);
+ if (random > 80) {
+ logger.info("未达到触发概率当前概率为:" + random);
+ return;
+ }
+
List prizeTypes = actPrizeTypeCustomerMapper.listAvailableTypes(actId);
Collections.shuffle(prizeTypes);
int totalWeight = 0;
for (JSONObject prizeType : prizeTypes) {
totalWeight += prizeType.getIntValue("weight");
}
- int ran = RandomUtils.nextInt(0,totalWeight);
+ int ran = RandomUtils.nextInt(0, totalWeight);
for (JSONObject prizeType : prizeTypes) {
ran -= prizeType.getIntValue("weight");
if (ran < 0) {
String lock = Long.toString(System.currentTimeMillis(), 36) + RandomStringUtils.random(5, true, true);
- int lockedCount = actRedPacketsCustomerOrdersMapper.lockPrize(actId,lock, prizeType.getString("type_id"), open_id, client_id, orderId, currencyAmount,
- new Date());
+ int lockedCount = actRedPacketsCustomerOrdersMapper.lockPrize(actId, lock, prizeType.getString("type_id"), open_id, client_id, orderId,
+ currencyAmount, new Date());
if (lockedCount > 0) {
doSendActLuckyMoney(open_id, lock, clientApply.getString("act_name"), clientApply.getString("send_name"), clientApply.getString("wishing"));
break;
} else {
- takeRedpack(actId,orderId, client_id, clientApply, currencyAmount, open_id, tryTimes + 1);
+ takeRedpack(actId, orderId, client_id, clientApply, currencyAmount, open_id, tryTimes + 1);
break;
}
}
@@ -211,8 +229,8 @@ public class ActRedPackServiceImpl implements ActRedPackService {
if (redpack_counts > 0) {
for (int i = 0; i < redpack_counts; i++) {
BigDecimal amount = amountFrom.equals(amountTo) ? amountFrom
- : amountFrom.add(BigDecimal.valueOf(RandomUtils.nextInt(0,amountTo.subtract(amountFrom).multiply(CommonConsts.HUNDRED).intValue()))
- .divide(CommonConsts.HUNDRED, 2, BigDecimal.ROUND_DOWN));
+ : amountFrom.add(BigDecimal.valueOf(RandomUtils.nextInt(0, amountTo.subtract(amountFrom).multiply(CommonConsts.HUNDRED).intValue()))
+ .divide(CommonConsts.HUNDRED, 2, BigDecimal.ROUND_DOWN));
JSONObject prize = new JSONObject();
String prefix = DateFormatUtils.format(new Date(), "yyyyMMddHHmmssSSS");
String red_packet_order_id = prefix + RandomStringUtils.random(28 - prefix.length(), true, true);
@@ -277,7 +295,8 @@ public class ActRedPackServiceImpl implements ActRedPackService {
pool.execute(() -> {
JSONObject clientApply = actClientApplyMapper.findActivity(actId, redpack.getIntValue("client_id"));
try {
- doSendActLuckyMoney(redpack.getString("open_id"), redpack.getString("lock"), clientApply.getString("act_name"), clientApply.getString("send_name"), clientApply.getString("wishing"));
+ doSendActLuckyMoney(redpack.getString("open_id"), redpack.getString("lock"), clientApply.getString("act_name"),
+ clientApply.getString("send_name"), clientApply.getString("wishing"));
} catch (RedPackException e) {
e.printStackTrace();
}
@@ -286,4 +305,15 @@ public class ActRedPackServiceImpl implements ActRedPackService {
}
}
+ @Override
+ public List getCustomerRedpackAnalysis(String act_id, RedpackQuery redpackQuery) {
+ JSONObject params = redpackQuery.params();
+ params.put("act_id", act_id);
+ return actRedPacketsCustomerOrdersMapper.getCustomerRedpackAnalysis(params);
+ }
+
+ @Override
+ public JSONObject analysisCustomerLuckyMoney(JSONObject params) {
+ return actRedPacketsCustomerOrdersMapper.analysisCustomerLuckyMoney(params);
+ }
}
diff --git a/src/main/java/au/com/royalpay/payment/manage/redpack/web/ActRedpackConfigController.java b/src/main/java/au/com/royalpay/payment/manage/redpack/web/ActRedpackConfigController.java
index 0023166f3..2c25f1b04 100644
--- a/src/main/java/au/com/royalpay/payment/manage/redpack/web/ActRedpackConfigController.java
+++ b/src/main/java/au/com/royalpay/payment/manage/redpack/web/ActRedpackConfigController.java
@@ -1,12 +1,14 @@
package au.com.royalpay.payment.manage.redpack.web;
import au.com.royalpay.payment.manage.permission.manager.ManagerMapping;
+import au.com.royalpay.payment.manage.redpack.beans.RedpackQuery;
import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
import au.com.royalpay.payment.manage.redpack.core.ActRedPackService;
import com.alibaba.fastjson.JSONObject;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
+import java.util.List;
/**
* Created by wangning on 2017/8/10.
@@ -30,10 +32,21 @@ public class ActRedpackConfigController {
}
@RequestMapping(value = "/act/{act_id}",method = RequestMethod.GET)
- private JSONObject listCustomerOrders(@PathVariable String act_id, @RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "10") int limit){
- JSONObject params = new JSONObject();
+ private JSONObject listCustomerOrders(@PathVariable String act_id, RedpackQuery redpackQuery){
+ JSONObject params = redpackQuery.params();
params.put("actId",act_id);
- return actRedPackService.listCustomerOrders(params,page,limit);
+ return actRedPackService.listCustomerOrders(params,redpackQuery.getPage(),redpackQuery.getLimit());
}
+ @ManagerMapping(value = "/{act_id}/sendLogs/analysis",method = RequestMethod.GET)
+ public List getCustomerRedpackAnalysis(@PathVariable String act_id, RedpackQuery query){
+ return actRedPackService.getCustomerRedpackAnalysis(act_id,query);
+ }
+
+ @ManagerMapping(value = "/act/{act_id}/analysis",method = RequestMethod.GET)
+ public JSONObject customerLuckyMoneyAnalysis(@PathVariable String act_id, RedpackQuery query){
+ JSONObject params= query.params();
+ params.put("act_id",act_id);
+ return actRedPackService.analysisCustomerLuckyMoney(params);
+ }
}
diff --git a/src/main/java/au/com/royalpay/payment/manage/risk/bean/QueryRiskRecord.java b/src/main/java/au/com/royalpay/payment/manage/risk/bean/QueryRiskRecord.java
index e43902673..16ab92af8 100644
--- a/src/main/java/au/com/royalpay/payment/manage/risk/bean/QueryRiskRecord.java
+++ b/src/main/java/au/com/royalpay/payment/manage/risk/bean/QueryRiskRecord.java
@@ -2,6 +2,7 @@ package au.com.royalpay.payment.manage.risk.bean;
import com.alibaba.fastjson.JSONObject;
+import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import java.text.ParseException;
@@ -19,10 +20,18 @@ public class QueryRiskRecord {
public JSONObject toParams() {
JSONObject params = new JSONObject();
- params.put("status", this.status);
- params.put("client_moniker", this.client_moniker);
- params.put("record_id", this.record_id);
- params.put("client_id", this.client_id);
+ if(StringUtils.isNotEmpty(status)){
+ params.put("status", this.status);
+ }
+ if(StringUtils.isNotEmpty(client_moniker)){
+ params.put("client_moniker", this.client_moniker);
+ }
+ if(StringUtils.isNotEmpty(record_id)){
+ params.put("record_id", this.record_id);
+ }
+ if(StringUtils.isNotEmpty(String.valueOf(client_id))){
+ params.put("client_id", this.client_id);
+ }
try {
if (c_end_time != null) {
params.put("c_end_time", DateUtils.parseDate(this.c_end_time, new String[] { "yyyy-MM-dd HH:mm:ss" }));
diff --git a/src/main/java/au/com/royalpay/payment/manage/system/web/MailCallBackController.java b/src/main/java/au/com/royalpay/payment/manage/system/web/MailCallBackController.java
new file mode 100644
index 000000000..7b172ce52
--- /dev/null
+++ b/src/main/java/au/com/royalpay/payment/manage/system/web/MailCallBackController.java
@@ -0,0 +1,22 @@
+package au.com.royalpay.payment.manage.system.web;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+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.RestController;
+
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+@RestController
+@RequestMapping(value = "/mailgun")
+public class MailCallBackController {
+ Logger logger = LoggerFactory.getLogger(getClass());
+ @RequestMapping(value = "/callback", method = RequestMethod.POST)
+ public void contractList(@RequestBody String content, HttpServletRequest req) {
+ logger.info(content);
+ }
+}
diff --git a/src/main/java/au/com/royalpay/payment/manage/task/BillOrderCheckTask.java b/src/main/java/au/com/royalpay/payment/manage/task/BillOrderCheckTask.java
index b2498e66f..c44acb701 100644
--- a/src/main/java/au/com/royalpay/payment/manage/task/BillOrderCheckTask.java
+++ b/src/main/java/au/com/royalpay/payment/manage/task/BillOrderCheckTask.java
@@ -2,17 +2,15 @@ package au.com.royalpay.payment.manage.task;
import au.com.royalpay.payment.manage.mappers.bill.BillOrderMapper;
import au.com.royalpay.payment.manage.mappers.payment.OrderMapper;
-
+import au.com.royalpay.payment.tools.scheduler.SynchronizedScheduler;
import com.alibaba.fastjson.JSONObject;
-
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
-import java.util.List;
-
import javax.annotation.Resource;
+import java.util.List;
/**
* Created by wangning on 2018/1/2.
@@ -25,25 +23,30 @@ public class BillOrderCheckTask {
@Resource
private OrderMapper orderMapper;
+ @Resource
+ private SynchronizedScheduler synchronizedScheduler;
@Scheduled(cron = "0 0/3 * * * ?")
public void checkGreenChannel() {
- List orderIds = billOrderMapper.findOrderIdByStatus("0");
- if(CollectionUtils.isEmpty(orderIds)){
- return;
- }
- for (String p : orderIds) {
- if (p==null){
- continue;
+ synchronizedScheduler.executeProcess("manage_task:checkGreenChannel", 120_000, () -> {
+ List orderIds = billOrderMapper.findOrderIdByStatus("0");
+ if (CollectionUtils.isEmpty(orderIds)) {
+ return;
}
- JSONObject order = orderMapper.find(p);
- int status = order.getIntValue("status");
- if(status==3||status==1){
- billOrderMapper.updateStatusByOrderId(p,"2");
+ for (String p : orderIds) {
+ if (p == null) {
+ continue;
+ }
+ JSONObject order = orderMapper.find(p);
+ int status = order.getIntValue("status");
+ if (status == 3 || status == 1) {
+ billOrderMapper.updateStatusByOrderId(p, "2");
+ }
+ if (status == 5) {
+ billOrderMapper.updateStatusByOrderId(p, "1");
+ }
}
- if(status==5){
- billOrderMapper.updateStatusByOrderId(p,"1");
- }
- }
+ });
+
}
}
diff --git a/src/main/java/au/com/royalpay/payment/manage/task/CheckPartnerAuthStatusAndSendMessageTask.java b/src/main/java/au/com/royalpay/payment/manage/task/CheckPartnerAuthStatusAndSendMessageTask.java
index d8b18c490..75da6d0b9 100644
--- a/src/main/java/au/com/royalpay/payment/manage/task/CheckPartnerAuthStatusAndSendMessageTask.java
+++ b/src/main/java/au/com/royalpay/payment/manage/task/CheckPartnerAuthStatusAndSendMessageTask.java
@@ -2,6 +2,7 @@ package au.com.royalpay.payment.manage.task;
import au.com.royalpay.payment.manage.application.core.SimpleClientService;
+import au.com.royalpay.payment.tools.scheduler.SynchronizedScheduler;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@@ -16,13 +17,16 @@ import javax.annotation.Resource;
public class CheckPartnerAuthStatusAndSendMessageTask {
@Resource
private SimpleClientService simpleClientService;
+ @Resource
+ private SynchronizedScheduler synchronizedScheduler;
+
// @Scheduled(cron = "0 0 9 * * ?")
// public void checkAuthAndSendMessage(){
// simpleClientService.checkAuthAndSendMessage();
// }
@Scheduled(cron = "0 0 9 * * ?")
- public void checkGreenChannel(){
- simpleClientService.checkGreenChannelClients();
+ public void checkGreenChannel() {
+ synchronizedScheduler.executeProcess("manage_task:CheckPartnerAuthStatus", 120_000, () -> simpleClientService.checkGreenChannelClients());
}
}
diff --git a/src/main/java/au/com/royalpay/payment/manage/task/CustomerImpressionTask.java b/src/main/java/au/com/royalpay/payment/manage/task/CustomerImpressionTask.java
index bb956e571..0e0920d32 100644
--- a/src/main/java/au/com/royalpay/payment/manage/task/CustomerImpressionTask.java
+++ b/src/main/java/au/com/royalpay/payment/manage/task/CustomerImpressionTask.java
@@ -3,6 +3,7 @@ package au.com.royalpay.payment.manage.task;
import au.com.royalpay.payment.manage.apps.core.CustomerImpressionService;
import au.com.royalpay.payment.manage.mappers.system.ClientMapper;
+import au.com.royalpay.payment.tools.scheduler.SynchronizedScheduler;
import com.alibaba.fastjson.JSONObject;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
@@ -27,32 +28,36 @@ public class CustomerImpressionTask {
private ClientMapper clientMapper;
@Resource
private CustomerImpressionService customerImpressionService;
+ @Resource
+ private SynchronizedScheduler synchronizedScheduler;
private ThreadPoolExecutor generatePool = new ThreadPoolExecutor(10, 30, 5, TimeUnit.SECONDS, new LinkedBlockingQueue());
- @Scheduled(cron = "0 0 3 * * ?")
+ @Scheduled(cron = "0 30 3 * * ?")
public void generateTags() {
- List clients = clientMapper.listValidClient();
- List> splitList = new ArrayList<>();
- for (int i = 0; i < clients.size(); i+=200) {
- if(i+200>clients.size()){
- splitList.add(clients.subList(i,clients.size()));
- }else {
- splitList.add(clients.subList(i,i+200));
- }
+ synchronizedScheduler.executeProcess("manage_task:CustomerImpression", 120_000, () -> {
+ List clients = clientMapper.listValidClient();
+ List> splitList = new ArrayList<>();
+ for (int i = 0; i < clients.size(); i += 200) {
+ if (i + 200 > clients.size()) {
+ splitList.add(clients.subList(i, clients.size()));
+ } else {
+ splitList.add(clients.subList(i, i + 200));
+ }
- }
- for (List splitClients : splitList) {
- Runnable task = () -> splitClients.forEach((p)->{
- System.out.println("当前执行到"+p.getIntValue("client_id"));
- customerImpressionService.generateTag(p.getIntValue("client_id"));
- });
- generatePool.execute(task);
- }
+ }
+ for (List splitClients : splitList) {
+ Runnable task = () -> splitClients.forEach((p) -> {
+ System.out.println("当前执行到" + p.getIntValue("client_id"));
+ customerImpressionService.generateTag(p.getIntValue("client_id"));
+ });
+ generatePool.execute(task);
+ }
+ });
}
@Scheduled(cron = "0/1 * * * * ?")
public void generateInfo() {
- customerImpressionService.generateInfo();
+ synchronizedScheduler.executeProcess("manage_task:CustomerImpression", 1_000, () -> customerImpressionService.generateInfo());
}
}
diff --git a/src/main/java/au/com/royalpay/payment/manage/task/DailyReportGenerationTask.java b/src/main/java/au/com/royalpay/payment/manage/task/DailyReportGenerationTask.java
index 08f43b0a5..020182dd2 100644
--- a/src/main/java/au/com/royalpay/payment/manage/task/DailyReportGenerationTask.java
+++ b/src/main/java/au/com/royalpay/payment/manage/task/DailyReportGenerationTask.java
@@ -2,6 +2,7 @@ package au.com.royalpay.payment.manage.task;
import au.com.royalpay.payment.manage.analysis.core.DailyReport;
+import au.com.royalpay.payment.tools.scheduler.SynchronizedScheduler;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
@@ -21,10 +22,14 @@ public class DailyReportGenerationTask {
@Resource
private DailyReport dailyReport;
+ @Resource
+ private SynchronizedScheduler synchronizedScheduler;
@Scheduled(cron = "0 0 10 * * ?")
public void autoGenerateReport() {
- Date yesterday = DateUtils.addDays(new Date(), -1);
- dailyReport.generateReport(DateFormatUtils.format(yesterday, "yyyy-MM-dd"), true);
+ synchronizedScheduler.executeProcess("manage_task:autoGenerateDailyReport", 120_000, () -> {
+ Date yesterday = DateUtils.addDays(new Date(), -1);
+ dailyReport.generateReport(DateFormatUtils.format(yesterday, "yyyy-MM-dd"), true);
+ });
}
}
diff --git a/src/main/java/au/com/royalpay/payment/manage/task/DashboardTaskManager.java b/src/main/java/au/com/royalpay/payment/manage/task/DashboardTaskManager.java
index 8b580a49e..9003942f1 100644
--- a/src/main/java/au/com/royalpay/payment/manage/task/DashboardTaskManager.java
+++ b/src/main/java/au/com/royalpay/payment/manage/task/DashboardTaskManager.java
@@ -2,6 +2,7 @@ package au.com.royalpay.payment.manage.task;
import au.com.royalpay.payment.manage.analysis.core.DashboardService;
+import au.com.royalpay.payment.tools.scheduler.SynchronizedScheduler;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.annotation.Scheduled;
@@ -19,8 +20,12 @@ import javax.annotation.Resource;
public class DashboardTaskManager {
@Resource
private DashboardService dashboardService;
+ @Resource
+ private SynchronizedScheduler synchronizedScheduler;
+
@Scheduled(cron = "0 0 2 * * ?")
- public void analysisDashboard(){
- dashboardService.generateCustomersAndOrdersStatistics(DateUtils.addDays(new Date(), -1));
+ public void analysisDashboard() {
+ synchronizedScheduler.executeProcess("manage_task:dashboardTask", 120_000,
+ () -> dashboardService.generateCustomersAndOrdersStatistics(DateUtils.addDays(new Date(), -1)));
}
}
diff --git a/src/main/java/au/com/royalpay/payment/manage/task/DirectedBillCodeStatusDailyCheck.java b/src/main/java/au/com/royalpay/payment/manage/task/DirectedBillCodeStatusDailyCheck.java
new file mode 100644
index 000000000..acf52088f
--- /dev/null
+++ b/src/main/java/au/com/royalpay/payment/manage/task/DirectedBillCodeStatusDailyCheck.java
@@ -0,0 +1,27 @@
+package au.com.royalpay.payment.manage.task;
+
+import au.com.royalpay.payment.manage.billqrcode.core.PartnerBillService;
+import au.com.royalpay.payment.tools.scheduler.SynchronizedScheduler;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+
+/**
+ * Created by yuan on 2018/5/4.
+ */
+@Component
+@ConditionalOnProperty(value = "app.run-tasks", havingValue = "true")
+public class DirectedBillCodeStatusDailyCheck {
+ @Resource
+ private PartnerBillService partnerBillService;
+ @Resource
+ private SynchronizedScheduler synchronizedScheduler;
+
+ @Scheduled(cron = "0 30 5 * * ?")
+ public void statusDailyCheck() {
+ synchronizedScheduler.executeProcess("manage_task:dailyCheckDirected", 120_000,
+ () -> partnerBillService.dailyCheckDirectedBillCode());
+ }
+}
diff --git a/src/main/java/au/com/royalpay/payment/manage/task/OfeiOrderCheckTask.java b/src/main/java/au/com/royalpay/payment/manage/task/OfeiOrderCheckTask.java
index a7afa75a7..661c55dc5 100644
--- a/src/main/java/au/com/royalpay/payment/manage/task/OfeiOrderCheckTask.java
+++ b/src/main/java/au/com/royalpay/payment/manage/task/OfeiOrderCheckTask.java
@@ -3,6 +3,7 @@ package au.com.royalpay.payment.manage.task;
import au.com.royalpay.payment.manage.mappers.ofei.TopUpOrderMapper;
import au.com.royalpay.payment.manage.ofei.core.OfeiServer;
+import au.com.royalpay.payment.tools.scheduler.SynchronizedScheduler;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@@ -22,14 +23,19 @@ public class OfeiOrderCheckTask {
private OfeiServer ofeiServer;
@Resource
private TopUpOrderMapper topUpOrderMapper;
+ @Resource
+ private SynchronizedScheduler synchronizedScheduler;
+
@Scheduled(cron = "0 0/20 * * * ?")
- public void checkGreenChannel(){
- List orderIds = topUpOrderMapper.findOrderIdByStatus("10");
- if(CollectionUtils.isEmpty(orderIds)){
- return;
- }
- for (String orderId : orderIds) {
- ofeiServer.checkOrder(orderId);
- }
+ public void checkGreenChannel() {
+ synchronizedScheduler.executeProcess("manage_task:ofeiOrderCheck", 120_000, () -> {
+ List orderIds = topUpOrderMapper.findOrderIdByStatus("10");
+ if (CollectionUtils.isEmpty(orderIds)) {
+ return;
+ }
+ for (String orderId : orderIds) {
+ ofeiServer.checkOrder(orderId);
+ }
+ });
}
}
diff --git a/src/main/java/au/com/royalpay/payment/manage/task/PartnerInitEmailChecker.java b/src/main/java/au/com/royalpay/payment/manage/task/PartnerInitEmailChecker.java
index fd0acb9c6..9464522ed 100644
--- a/src/main/java/au/com/royalpay/payment/manage/task/PartnerInitEmailChecker.java
+++ b/src/main/java/au/com/royalpay/payment/manage/task/PartnerInitEmailChecker.java
@@ -3,6 +3,7 @@ package au.com.royalpay.payment.manage.task;
import au.com.royalpay.payment.manage.merchants.core.ClientManager;
import au.com.royalpay.payment.tools.env.PlatformEnvironment;
+import au.com.royalpay.payment.tools.scheduler.SynchronizedScheduler;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@@ -13,15 +14,19 @@ import javax.annotation.Resource;
* Created by yixian on 2017-02-22.
*/
@Component
-@ConditionalOnProperty(value = "app.run-tasks",havingValue = "true")
+@ConditionalOnProperty(value = "app.run-tasks", havingValue = "true")
public class PartnerInitEmailChecker {
@Resource
private ClientManager clientManager;
+ @Resource
+ private SynchronizedScheduler synchronizedScheduler;
+
@Scheduled(cron = "0 0/5 * * * *")
- public void checkEmailStatus(){
+ public void checkEmailStatus() {
if (PlatformEnvironment.getEnv().taskEnabled()) {
- clientManager.checkEmailStatus();
+ synchronizedScheduler.executeProcess("manage_task:emailStatusCheck", 120_000,
+ () -> clientManager.checkEmailStatus());
}
}
}
diff --git a/src/main/java/au/com/royalpay/payment/manage/task/PartnerTransactionsDailyMsgTaskManager.java b/src/main/java/au/com/royalpay/payment/manage/task/PartnerTransactionsDailyMsgTaskManager.java
index e89b10039..0ee93c32b 100644
--- a/src/main/java/au/com/royalpay/payment/manage/task/PartnerTransactionsDailyMsgTaskManager.java
+++ b/src/main/java/au/com/royalpay/payment/manage/task/PartnerTransactionsDailyMsgTaskManager.java
@@ -2,6 +2,7 @@ package au.com.royalpay.payment.manage.task;
import au.com.royalpay.payment.manage.analysis.core.CustomersAnalysisService;
+import au.com.royalpay.payment.tools.scheduler.SynchronizedScheduler;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.annotation.Scheduled;
@@ -19,8 +20,12 @@ import javax.annotation.Resource;
public class PartnerTransactionsDailyMsgTaskManager {
@Resource
private CustomersAnalysisService customersAnalysisService;
+ @Resource
+ private SynchronizedScheduler synchronizedScheduler;
+
@Scheduled(cron = "0 0 8 * * ?")
- public void analysisDashboard(){
- customersAnalysisService.sendPartnerTransactionDaily(DateUtils.addDays(new Date(), -1));
+ public void analysisDashboard() {
+ synchronizedScheduler.executeProcess("manage_task:partnerDailyMsg", 120_000,
+ () -> customersAnalysisService.sendPartnerTransactionDaily(DateUtils.addDays(new Date(), -1)));
}
}
diff --git a/src/main/java/au/com/royalpay/payment/manage/task/PostponeClientTask.java b/src/main/java/au/com/royalpay/payment/manage/task/PostponeClientTask.java
index 8648c3ce6..f2342bb43 100644
--- a/src/main/java/au/com/royalpay/payment/manage/task/PostponeClientTask.java
+++ b/src/main/java/au/com/royalpay/payment/manage/task/PostponeClientTask.java
@@ -8,6 +8,7 @@ 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.TemplateMessage;
+import au.com.royalpay.payment.tools.scheduler.SynchronizedScheduler;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.time.DateFormatUtils;
@@ -44,56 +45,61 @@ public class PostponeClientTask {
private ClientAccountMapper clientAccountMapper;
@Resource
private ManagerMapper managerMapper;
+ @Resource
+ private SynchronizedScheduler synchronizedScheduler;
+
- @Scheduled(cron = "0 30 8 * * ?")
+ @Scheduled(cron = "0 30 8 * * ?")
public void checkGreenChannel() {
- Date now = new Date();
- Date tomorrow = DateUtils.addDays(now, 1);
- Date yearTomorrow = DateUtils.addYears(tomorrow, 1);
- String expireDate = DateFormatUtils.format(yearTomorrow, "yyyy-MM-dd");
- List expiryClient = clientRateMapper.getAllExpiry(now);
-
- if(CollectionUtils.isEmpty(expiryClient)){
- return;
- }
- Map expiryClients = new HashMap<>();
- expiryClient.forEach(p -> {
- expiryClients.put(p.getInteger("client_id"), p);
- });
- expiryClients.values().forEach(p -> {
- int client_id = p.getIntValue("client_id");
- List adminAccounts = clientAccountMapper.listAdminAccounts(client_id);
- List clientRates = clientRateMapper.maxChannelExpiryTime(client_id, null);
- JSONObject wechatRate = clientRateMapper.latestChannelCleanDays("Wechat", p.getIntValue("client_id"));
- int cleanDays = 1;
- if (wechatRate.getInteger("clean_days") != null) {
- cleanDays = wechatRate.getIntValue("clean_days");
- } else {
- cleanDays = wechatRate.getIntValue("c_clean_days");
+ synchronizedScheduler.executeProcess("manage_task:postPoneClient", 120_000, () -> {
+ Date now = new Date();
+ Date tomorrow = DateUtils.addDays(now, 1);
+ Date yearTomorrow = DateUtils.addYears(tomorrow, 1);
+ String expireDate = DateFormatUtils.format(yearTomorrow, "yyyy-MM-dd");
+ List expiryClient = clientRateMapper.getAllExpiry(now);
+
+ if (CollectionUtils.isEmpty(expiryClient)) {
+ return;
}
- int finalCleanDays = cleanDays;
- clientRates.forEach(o -> {
- JSONObject record = clientRateMapper.latestExpiryConfig(client_id,o.getString("rate_name"));
- record.remove("client_rate_id");
- record.put("active_time", now);
- record.put("manager_id", 0);
- record.put("expiry_time", yearTomorrow);
- record.put("create_time", now);
- record.put("update_time", now);
- record.put("clean_days", finalCleanDays);
- record.put("manager_name", "System");
- record.put("remark", "费率到期系统自动延期1年");
- clientRateMapper.saveRate(record);
-
+ Map expiryClients = new HashMap<>();
+ expiryClient.forEach(p -> {
+ expiryClients.put(p.getInteger("client_id"), p);
});
- adminAccounts.forEach(o -> {
- sendClientPostponeNotify(o, expireDate);
+ expiryClients.values().forEach(p -> {
+ int client_id = p.getIntValue("client_id");
+ List adminAccounts = clientAccountMapper.listAdminAccounts(client_id);
+ List clientRates = clientRateMapper.maxChannelExpiryTime(client_id, null);
+ JSONObject wechatRate = clientRateMapper.latestChannelCleanDays("Wechat", p.getIntValue("client_id"));
+ int cleanDays = 1;
+ if (wechatRate.getInteger("clean_days") != null) {
+ cleanDays = wechatRate.getIntValue("clean_days");
+ } else {
+ cleanDays = wechatRate.getIntValue("c_clean_days");
+ }
+ int finalCleanDays = cleanDays;
+ clientRates.forEach(o -> {
+ JSONObject record = clientRateMapper.latestExpiryConfig(client_id, o.getString("rate_name"));
+ record.remove("client_rate_id");
+ record.put("active_time", now);
+ record.put("manager_id", 0);
+ record.put("expiry_time", yearTomorrow);
+ record.put("create_time", now);
+ record.put("update_time", now);
+ record.put("clean_days", finalCleanDays);
+ record.put("manager_name", "System");
+ record.put("remark", "费率到期系统自动延期1年");
+ clientRateMapper.saveRate(record);
+
+ });
+ adminAccounts.forEach(o -> {
+ sendClientPostponeNotify(o, expireDate);
+ });
});
+ sendComplianceNotify(expiryClients, expireDate);
});
- sendComplianceNotify(expiryClients, expireDate);
}
- private void sendClientPostponeNotify(JSONObject account,String newExpireDate) {
+ private void sendClientPostponeNotify(JSONObject account, String newExpireDate) {
JSONObject client = clientManager.getClientInfo(account.getIntValue("client_id"));
try {
@@ -101,8 +107,8 @@ public class PostponeClientTask {
if (api != null) {
String templateId = api.getTemplateId("client-postpone");
if (templateId != null) {
- TemplateMessage notice = initClientMessage(client,newExpireDate,account.getString("wechat_openid"),templateId);
- api.sendTemplateMessage(notice);
+ TemplateMessage notice = initClientMessage(client, newExpireDate, account.getString("wechat_openid"), templateId);
+ api.sendTemplateMessage(notice);
}
}
} catch (Exception e) {
@@ -129,7 +135,7 @@ public class PostponeClientTask {
private TemplateMessage initClientMessage(JSONObject client, String newExpiryDate, String wechatOpenid, String templateId) {
TemplateMessage notice = new TemplateMessage(wechatOpenid, templateId, null);
notice.put("first", "您好,您的合同费率已到期,根据合同协议系统已自动为您延期1年。", "#ff0000");
- notice.put("keyword1", client.getString("short_name")+"("+client.getString("client_moniker")+")", "#ff0000");
+ notice.put("keyword1", client.getString("short_name") + "(" + client.getString("client_moniker") + ")", "#ff0000");
notice.put("keyword2", newExpiryDate, "#0000ff");
notice.put("remark", "如有疑问请联系RoyalPay", "#000000");
return notice;
diff --git a/src/main/java/au/com/royalpay/payment/manage/task/RedPackTaskManager.java b/src/main/java/au/com/royalpay/payment/manage/task/RedPackTaskManager.java
index b1b25a4e1..790670dc6 100644
--- a/src/main/java/au/com/royalpay/payment/manage/task/RedPackTaskManager.java
+++ b/src/main/java/au/com/royalpay/payment/manage/task/RedPackTaskManager.java
@@ -3,6 +3,7 @@ package au.com.royalpay.payment.manage.task;
import au.com.royalpay.payment.manage.redpack.core.ActRedPackService;
import au.com.royalpay.payment.manage.redpack.core.RedpackService;
+import au.com.royalpay.payment.tools.scheduler.SynchronizedScheduler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
@@ -23,20 +24,22 @@ public class RedPackTaskManager {
private RedpackService redpackService;
@Resource
private ActRedPackService actRedPackService;
+ @Resource
+ private SynchronizedScheduler synchronizedScheduler;
@Scheduled(cron = "0 0/10 * * * ?")
public void updateRedPackStatus() {
- redpackService.updateRedPacketsStatus("3");
+ synchronizedScheduler.executeProcess("manage_task:updateRedpackStatus", 120_000, () -> redpackService.updateRedPacketsStatus("3"));
}
@Scheduled(cron = "0 0/10 * * * ?")
public void updateAlipayRedPackStatus() {
- redpackService.updateAlipayRedPacketsStatus("3");
+ synchronizedScheduler.executeProcess("manage_task:updateAlipayRedpackStatus", 120_000, () -> redpackService.updateAlipayRedPacketsStatus("3"));
}
@Scheduled(cron = "0 0/3 * * * *")
public void resendFailedRedpack() {
- actRedPackService.resendFailed();
+ synchronizedScheduler.executeProcess("manage_task:resendFailedRedpack", 120_000, () -> actRedPackService.resendFailed());
}
}
diff --git a/src/main/java/au/com/royalpay/payment/manage/task/SettleEstimateTaskManger.java b/src/main/java/au/com/royalpay/payment/manage/task/SettleEstimateTaskManger.java
index 3cb196f24..2699d3d26 100644
--- a/src/main/java/au/com/royalpay/payment/manage/task/SettleEstimateTaskManger.java
+++ b/src/main/java/au/com/royalpay/payment/manage/task/SettleEstimateTaskManger.java
@@ -2,6 +2,7 @@ package au.com.royalpay.payment.manage.task;
import au.com.royalpay.payment.manage.analysis.core.EstimateAnalysisService;
import au.com.royalpay.payment.manage.analysis.core.PlatformClearService;
+import au.com.royalpay.payment.tools.scheduler.SynchronizedScheduler;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@@ -19,26 +20,28 @@ public class SettleEstimateTaskManger {
@Resource
private PlatformClearService platformClearService;
+ @Resource
+ private SynchronizedScheduler synchronizedScheduler;
// 3:15 am at every work days
@Scheduled(cron = "0 20 3 * * ?")
public void generateSettleAmount() {
- estimateAnalysisService.generateSettleAmount();
+ synchronizedScheduler.executeProcess("manage_task:genSettleAmount", 120_000, () -> estimateAnalysisService.generateSettleAmount());
}
// 2:15 every day
@Scheduled(cron = "0 0 3 * * ?")
public void generateTransactionAmount() {
- estimateAnalysisService.generateTransactionData();
+ synchronizedScheduler.executeProcess("manage_task:genTransAmount", 120_000, () -> estimateAnalysisService.generateTransactionData());
}
@Scheduled(cron = "0 0 13 * * ?")
public void generateSettleLogs() {
- platformClearService.generateSettleLogs();
+ synchronizedScheduler.executeProcess("manage_task:genSettleLog", 120_000, () -> platformClearService.generateSettleLogs());
}
@Scheduled(cron = "0 0 10 * * ?")
public void generateSettleLogs2() {
- platformClearService.generateSettleLogs();
+ synchronizedScheduler.executeProcess("manage_task:genSettleLog", 120_000, () -> platformClearService.generateSettleLogs());
}
}
diff --git a/src/main/java/au/com/royalpay/payment/manage/task/SubMerchantIdTaskManager.java b/src/main/java/au/com/royalpay/payment/manage/task/SubMerchantIdTaskManager.java
index ef2d50b53..e6dd275cb 100644
--- a/src/main/java/au/com/royalpay/payment/manage/task/SubMerchantIdTaskManager.java
+++ b/src/main/java/au/com/royalpay/payment/manage/task/SubMerchantIdTaskManager.java
@@ -1,6 +1,7 @@
package au.com.royalpay.payment.manage.task;
import au.com.royalpay.payment.manage.merchantid.core.MerchantIdManageService;
+import au.com.royalpay.payment.tools.scheduler.SynchronizedScheduler;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@@ -12,8 +13,11 @@ import javax.annotation.Resource;
public class SubMerchantIdTaskManager {
@Resource
private MerchantIdManageService merchantIdManageService;
+ @Resource
+ private SynchronizedScheduler synchronizedScheduler;
+
@Scheduled(cron = "0 0 4 * * ?")
- public void analysisDashboard(){
- merchantIdManageService.generateClientsSunMerchantId();
+ public void analysisDashboard() {
+ synchronizedScheduler.executeProcess("manage_task:checkSubMchId", 120_000, () -> merchantIdManageService.generateClientsSunMerchantId());
}
}
diff --git a/src/main/java/au/com/royalpay/payment/manage/task/WeekReportGenerationTask.java b/src/main/java/au/com/royalpay/payment/manage/task/WeekReportGenerationTask.java
index 4964aa5d2..aef28d736 100644
--- a/src/main/java/au/com/royalpay/payment/manage/task/WeekReportGenerationTask.java
+++ b/src/main/java/au/com/royalpay/payment/manage/task/WeekReportGenerationTask.java
@@ -2,6 +2,7 @@ package au.com.royalpay.payment.manage.task;
import au.com.royalpay.payment.manage.analysis.core.WeekReporter;
+import au.com.royalpay.payment.tools.scheduler.SynchronizedScheduler;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
@@ -21,11 +22,15 @@ public class WeekReportGenerationTask {
@Resource
private WeekReporter weekReporter;
+ @Resource
+ private SynchronizedScheduler synchronizedScheduler;
@Scheduled(cron = "0 0 2 * * 1")
public void autoGenerateReport() {
- Date lastweek = new Date();
- lastweek = DateUtils.addDays(lastweek, -7);
- weekReporter.generateReport(DateFormatUtils.format(lastweek, "yyyy-MM-dd"), true);
+ synchronizedScheduler.executeProcess("manage_task:genWeekReport", 120_000, () -> {
+ Date lastweek = new Date();
+ lastweek = DateUtils.addDays(lastweek, -7);
+ weekReporter.generateReport(DateFormatUtils.format(lastweek, "yyyy-MM-dd"), true);
+ });
}
}
diff --git a/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/OrderAnalysisMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/OrderAnalysisMapper.xml
index ff6fdfd89..d8c12acdc 100644
--- a/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/OrderAnalysisMapper.xml
+++ b/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/OrderAnalysisMapper.xml
@@ -198,7 +198,6 @@