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 @@ SELECT count(1) FROM act_red_packets_customer_orders - WHERE open_id = #{open_id} AND date(event_time) = date(#{event_date}) AND status != 0 AND act_id = #{act_id} + WHERE open_id = #{open_id} + + AND date(event_time) = date(#{event_date}) + + AND status != 0 AND act_id = #{act_id} + + and event_time >= #{from} + and event_time <= #{to} + GROUP BY date + + + + + \ No newline at end of file diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientMapper.xml index ba3b6391b..2a0b8eccd 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientMapper.xml @@ -286,7 +286,7 @@ diff --git a/src/main/ui/index.html b/src/main/ui/index.html index 26b8502c2..74f25f658 100644 --- a/src/main/ui/index.html +++ b/src/main/ui/index.html @@ -914,16 +914,21 @@ margin-bottom: 10%;"/>
  • - Products & Sale + Extended products diff --git a/src/main/ui/static/analysis/customer_analysis.js b/src/main/ui/static/analysis/customer_analysis.js index 3ac557e08..e7c2f4a9e 100644 --- a/src/main/ui/static/analysis/customer_analysis.js +++ b/src/main/ui/static/analysis/customer_analysis.js @@ -148,6 +148,7 @@ define(['angular', 'static/commons/commons', 'static/commons/angular-ueditor', ' // $scope.analysis = resp.data.analysis; }); }; + $scope.chooseToday(); $scope.orderDetail = function (order) { orderService.managerOrderDetail(order) diff --git a/src/main/ui/static/analysis/templates/client_rates.html b/src/main/ui/static/analysis/templates/client_rates.html index 83009e07e..833b9186c 100644 --- a/src/main/ui/static/analysis/templates/client_rates.html +++ b/src/main/ui/static/analysis/templates/client_rates.html @@ -61,7 +61,7 @@
    - {{bd.display_name}}[{{bd.percentage}}%] diff --git a/src/main/ui/static/analysis/templates/customer_analysis.html b/src/main/ui/static/analysis/templates/customer_analysis.html index b50d77cd4..0c6387fa1 100644 --- a/src/main/ui/static/analysis/templates/customer_analysis.html +++ b/src/main/ui/static/analysis/templates/customer_analysis.html @@ -90,8 +90,8 @@

    Customer List

    - Total Amount:{{customers_analysis.total_amount}},Total - Points:{{customers_analysis.total_points}} + Total Amount:{{customers_analysis.total_amount}}
    @@ -101,7 +101,7 @@ Customer openId Amount(AUD) - Points + Orders Max Order(AUD) @@ -112,7 +112,7 @@ ng-click="order_params.customer_id=customer.customer_id;listCustomerOrders()"> - + diff --git a/src/main/ui/static/boot/index-boot.js b/src/main/ui/static/boot/index-boot.js index 66de21a27..55e98e262 100644 --- a/src/main/ui/static/boot/index-boot.js +++ b/src/main/ui/static/boot/index-boot.js @@ -59,7 +59,6 @@ var modules = [ {path: 'static/boot/indexMainApp', module: 'indexMainApp', roles: [1, 2, 3]}, {path: 'static/commons/commons', module: 'commons', roles: [1, 2, 3]}, {path: 'static/payment/good/good-manage', module: 'goodManagement', roles: [1, 2, 3]}, - {path: 'static/payment/good/good-sale', module: 'goodSale', roles: [1, 2, 3]}, {path: 'static/payment/partner/partner', module: 'partnerInfoApp', roles: [1, 2, 3]}, {path: 'static/payment/tradelog/tradelog', module: 'tradeLogApp', roles: [1, 2, 3]}, {path: 'static/payment/tradelog/transflow', module: 'balanceReport', roles: [1, 2, 3]}, @@ -75,7 +74,8 @@ var modules = [ {path: 'static/application/clientAuthentication', module: 'clientAuthentication', roles: [1]}, {path: 'static/cashback/partner-cashback', module: 'cashbackApp', roles: [1,2,3]}, {path: 'static/integralmall/coupon_cancellation', module: 'couponCancellation', roles: [1,2]}, - {path: 'static/invoice/invoice_assistant', module: 'partnerInvoice', roles: [1]} + {path: 'static/invoice/invoice_assistant', module: 'partnerInvoice', roles: [1]}, + {path: 'static/payment/billqrcode/bill-qrcode-manage', module: 'billQrCodeManagement', roles: [1,2,3]} ]; require(['angular', 'jquery'], function (angular, $) { diff --git a/src/main/ui/static/boot/indexMainApp.js b/src/main/ui/static/boot/indexMainApp.js index 7737488a4..fb359860b 100644 --- a/src/main/ui/static/boot/indexMainApp.js +++ b/src/main/ui/static/boot/indexMainApp.js @@ -540,7 +540,9 @@ define(['angular', 'angularSanitize', 'angularAnimate', 'angularMessages', 'uiRo case '10': return 'APP'; case '11': - return 'Share Code' + return 'Share Code'; + case '12': + return 'MICROAPP' } } }); diff --git a/src/main/ui/static/boot/managerMainApp.js b/src/main/ui/static/boot/managerMainApp.js index 5909fa751..f0850e4e8 100644 --- a/src/main/ui/static/boot/managerMainApp.js +++ b/src/main/ui/static/boot/managerMainApp.js @@ -325,7 +325,9 @@ define(['angular', 'angularSanitize', 'angularAnimate', 'angularMessages', 'uiRo case '10': return 'APP网关'; case '11': - return '账单码' + return '账单码'; + case '12': + return '小程序' } } }); diff --git a/src/main/ui/static/config/redpackets/act-redpackets-customer.js b/src/main/ui/static/config/redpackets/act-redpackets-customer.js index 7560792c8..c9e2a7ebf 100644 --- a/src/main/ui/static/config/redpackets/act-redpackets-customer.js +++ b/src/main/ui/static/config/redpackets/act-redpackets-customer.js @@ -37,11 +37,184 @@ define(['angular', 'static/commons/commons', 'uiBootstrap', 'uiRouter', 'ngBootS }]); - app.controller('actCustomerRedpackOrdersCtrl',['$scope','$http',function ($scope, $http) { + app.controller('actCustomerRedpackOrdersCtrl',['$scope','$http','$filter',function ($scope, $http,$filter) { + $scope.analysis = {}; + $scope.today = new Date(); + $scope.chooseToday = function () { + $scope.analysis.begin = $scope.analysis.end = new Date(); + $scope.doAnalysis(); + }; + $scope.chooseYesterday = function () { + var yesterday = new Date(); + yesterday.setDate(yesterday.getDate() - 1); + $scope.analysis.begin = $scope.analysis.end = yesterday; + $scope.doAnalysis(); + }; + $scope.chooseLast7Days = function () { + $scope.analysis.end = new Date(); + var day = new Date(); + day.setDate(day.getDate() - 7); + $scope.analysis.begin = day; + $scope.doAnalysis(); + }; + $scope.thisMonth = function () { + $scope.analysis.end = new Date(); + var monthBegin = new Date(); + monthBegin.setDate(1); + $scope.analysis.begin = monthBegin; + $scope.doAnalysis(); + }; + $scope.doAnalysis = function () { + var params = angular.copy($scope.analysis); + if (params.begin) { + params.from = $filter('date')(params.begin, 'yyyyMMdd'); + } else { + params.from = $filter('date')(new Date(), 'yyyyMMdd'); + } + if (params.end) { + params.to = $filter('date')(params.end, 'yyyyMMdd'); + } else { + params.to = $filter('date')(new Date(), 'yyyyMMdd'); + } + $http.get('/sys/redpack/customer/'+$scope.act.act_id+'/sendLogs/analysis', {params: params}).then(function (resp) { + $scope.redPackCounts = angular.copy(resp.data); + var dates = []; + var send_counts = []; + var fail_counts = []; + var receive_counts = []; + var refund_counts = []; + var amounts = []; + var real_amounts = []; + resp.data.forEach(function (e) { + dates.push(e.date); + send_counts.push(e.send_counts); + fail_counts.push(e.fail_counts); + receive_counts.push(e.receive_counts); + refund_counts.push(e.refund_counts); + amounts.push(e.amount); + real_amounts.push(e.real_amount); + }); + var customerRedPackSendLogsHistory = function (dates, send_counts, fail_counts, receive_counts, refund_counts, amounts, real_amounts) { + return { + color: colors, + tooltip: { + trigger: 'axis', + axisPointer: { // 坐标轴指示器,坐标轴触发有效 + type: 'shadow' // 默认为直线,可选为:'line' | 'shadow' + } + }, + legend: { + data: ['已领取', '发送未领取', '发送失败', '退回', '发送红包金额', '实际红包金额'] + }, + grid: { + left: '3%', + right: '4%', + bottom: '3%', + containLabel: true + }, + xAxis: [ + { + type: 'category', + data: dates + } + ], + yAxis: [ + { + type: 'value', + name: 'RedPackets' + }, { + type: 'value', + name: 'Amount(¥)' + } + ], + series: [{ + name: '已领取', + type: 'bar', + stack: 'repackets', + data: receive_counts + }, + { + name: '发送未领取', + type: 'bar', + stack: 'repackets', + data: send_counts + }, + { + name: '发送失败', + type: 'bar', + stack: 'repackets', + data: fail_counts + }, + + { + name: '退回', + type: 'bar', + stack: 'repackets', + data: refund_counts + }, + { + name: '发送红包金额', + type: 'line', + yAxisIndex: 1, + data: amounts + }, + { + name: '实际红包金额', + type: 'line', + yAxisIndex: 1, + data: real_amounts + } + ] + }; + }; + $scope.customerRedPackSendLogsHistory = customerRedPackSendLogsHistory(dates, send_counts, fail_counts, receive_counts, refund_counts, amounts, real_amounts); + + }) + }; + $scope.chooseLast7Days(); + + /* 《==========================================OrderList========================================================>*/ + $scope.params = {}; $scope.redpack_order_pagination = {}; + $scope.chooseTodayForLogs = function () { + $scope.params.begin = $scope.params.end = new Date(); + $scope.listOrders(1); + }; + $scope.chooseYesterdayForLogs = function () { + var yesterday = new Date(); + yesterday.setDate(yesterday.getDate() - 1); + $scope.params.begin = $scope.params.end = yesterday; + $scope.listOrders(1); + }; + $scope.chooseLast7DaysForLogs = function () { + $scope.params.end = new Date(); + var day = new Date(); + day.setDate(day.getDate() - 7); + $scope.params.begin = day; + $scope.listOrders(1); + }; + $scope.thisMonthForLogs = function () { + $scope.params.end = new Date(); + var monthBegin = new Date(); + monthBegin.setDate(1); + $scope.params.begin = monthBegin; + $scope.listOrders(1); + }; + $scope.customerLuckyMoneyAnalysis = function (params) { + $http.get('/sys/redpack/customer/act/' + $scope.act.act_id + '/analysis', {params: params}).then(function (resp) { + $scope.luckyMoneyAnalysis = resp.data; + }); + }; + $scope.customerLuckyMoneyAnalysis({}); $scope.listOrders = function (page) { - var params = angular.copy($scope.redpack_order_pagination); - params.page = page || params.page || 1; + var params = angular.copy($scope.params); + if (params.begin) { + params.from = $filter('date')(params.begin, 'yyyyMMdd'); + } + if (params.end) { + params.to = $filter('date')(params.end, 'yyyyMMdd'); + } + params.page = page || $scope.redpack_order_pagination.page || 1; $http.get('/sys/redpack/customer/act/'+$scope.act.act_id, {params: params}).then(function (resp) { $scope.redpack_order_pagination = resp.data.pagination; $scope.orders = resp.data.data; @@ -94,6 +267,17 @@ define(['angular', 'static/commons/commons', 'uiBootstrap', 'uiRouter', 'ngBootS }; $scope.listClients(); + $scope.addAttendClient = function () { + $uibModal.open({ + templateUrl: '/static/config/redpackets/templates/add_act_client.html', + controller: 'addClientInfoCtrl', + resolve: { + act: $scope.act + } + }).result.then(function () { + $scope.listClients(); + }) + }; $scope.editClientInfo = function (client) { var client = angular.copy(client); $uibModal.open({ @@ -129,6 +313,18 @@ define(['angular', 'static/commons/commons', 'uiBootstrap', 'uiRouter', 'ngBootS $scope.$close(); } }]); + app.controller('addClientInfoCtrl',['$scope', '$http','act','commonDialog', function ($scope, $http,act,commonDialog) { + $scope.client = {act_name:act.act_name}; + $scope.doAddClientInfo = function(){ + var params= {'send_name':$scope.client.send_name,'act_name':$scope.client.act_name,'wishing':$scope.client.wishing}; + $http.post('/sys/lucky_money/customer/acts/'+act.act_id+'/partners/'+$scope.client.client_moniker,params).then(function () { + commonDialog.alert({title: 'Success', content: '新增成功!', type: 'success'}); + $scope.$close(); + }, function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + }); + } + }]); app.filter('send_status', function () { return function (stateValue) { diff --git a/src/main/ui/static/config/redpackets/templates/act_customer_detail.html b/src/main/ui/static/config/redpackets/templates/act_customer_detail.html index cc58cb6ca..44ec94f1e 100644 --- a/src/main/ui/static/config/redpackets/templates/act_customer_detail.html +++ b/src/main/ui/static/config/redpackets/templates/act_customer_detail.html @@ -49,13 +49,20 @@

    红包限制:订单满足的最小金额

    -
    +

    红包限制:每个客户每天最多所能获取的红包数量

    +
    + +
    +

    +

    红包限制:每个客户活动期间最多所能获取的红包数量

    +
    +
    diff --git a/src/main/ui/static/config/redpackets/templates/act_customer_edit.html b/src/main/ui/static/config/redpackets/templates/act_customer_edit.html index 94663d4a5..b492c3886 100644 --- a/src/main/ui/static/config/redpackets/templates/act_customer_edit.html +++ b/src/main/ui/static/config/redpackets/templates/act_customer_edit.html @@ -53,8 +53,20 @@
    - -
    + +
    + + +
    +
    +
    @@ -79,6 +91,31 @@
    +
    + +
    + +

    红包限制:每个客户活动内最多所能获取的红包数量

    +
    +
    + No more than 100 +
    +
    + No less than 1 +
    +
    + Required Field +
    +
    +
    +
    +
    diff --git a/src/main/ui/static/config/redpackets/templates/act_customer_partners.html b/src/main/ui/static/config/redpackets/templates/act_customer_partners.html index a82ef1586..3518cdb57 100644 --- a/src/main/ui/static/config/redpackets/templates/act_customer_partners.html +++ b/src/main/ui/static/config/redpackets/templates/act_customer_partners.html @@ -1,23 +1,35 @@ -
    - - - - - - - - - - - - - - - - - -
    ClientSend NameAct NameOperation
    {{client.short_name}}({{client.client_moniker}}) - - -
    -
    \ No newline at end of file +
    +
    +
    +
    + +
    +
    +
    + +
    +
    +
    + + + + + + + + + + + + + + + + + +
    ClientSend NameAct NameOperation
    {{client.short_name}}({{client.client_moniker}}) + + +
    +
    +
    diff --git a/src/main/ui/static/config/redpackets/templates/act_customer_send_orders.html b/src/main/ui/static/config/redpackets/templates/act_customer_send_orders.html index ca3e2c59c..42846e4b1 100644 --- a/src/main/ui/static/config/redpackets/templates/act_customer_send_orders.html +++ b/src/main/ui/static/config/redpackets/templates/act_customer_send_orders.html @@ -1,37 +1,206 @@ -
    - - - - - - - - - - - - - - - - - -
    Client MonikerstatusOrder AmountCreate Time
    {{order.client_moniker}}{{order.status|send_status}}{{order.order_amount}}{{order.create_time}}
    +
    + +
    +
    +
    +
    +
    +
    +
    -
    Total Records:{{redpack_order_pagination.totalCount}};Total Pages:{{redpack_order_pagination.totalPages}}
    +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    + +
    + +
    +
    + +
    + +
    + ~ +
    + +
    + +
    + Today +
    +
    + Yesterday +
    + + +
    +
    +
    +
    +
    -
    \ No newline at end of file +
    +
    +
    + Orders(总共红包{{luckyMoneyAnalysis.total_counts}}|{{luckyMoneyAnalysis.total_amount}}¥; + 已发红包{{luckyMoneyAnalysis.send_counts}}|{{luckyMoneyAnalysis.send_amount}}¥;客户所得红包{{luckyMoneyAnalysis.receive_counts}}|{{luckyMoneyAnalysis.receive_amount}}¥ + 待发送红包{{luckyMoneyAnalysis.unsend_counts}}|{{luckyMoneyAnalysis.unsend_amount}}¥)
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + +
    Client MonikerLucky MoneyOrder AmountNick NamestatusEvent TimeCreate Time
    {{order.client_moniker}}{{order.red_packet_amount}}{{order.order_amount}} {{order.nickname}}{{order.status|send_status}}{{order.event_time}}{{order.create_time}}
    + + +
    +
    + +
    diff --git a/src/main/ui/static/config/redpackets/templates/add_act_client.html b/src/main/ui/static/config/redpackets/templates/add_act_client.html new file mode 100644 index 000000000..455539848 --- /dev/null +++ b/src/main/ui/static/config/redpackets/templates/add_act_client.html @@ -0,0 +1,51 @@ + + + \ No newline at end of file diff --git a/src/main/ui/static/dashboard/dashboard.js b/src/main/ui/static/dashboard/dashboard.js index 088b02048..2f9d7c595 100644 --- a/src/main/ui/static/dashboard/dashboard.js +++ b/src/main/ui/static/dashboard/dashboard.js @@ -100,7 +100,7 @@ define(['angular', 'uiRouter', 'uiBootstrap', 'angularEcharts'], function (angul loadTradeAmountInTypes(); loadTradePartnersInTypes(); loadTopPartners(); - loadTradeTimeAnalysis(); + /*loadTradeTimeAnalysis();*/ loadTradeLimite(); }; @@ -281,7 +281,7 @@ define(['angular', 'uiRouter', 'uiBootstrap', 'angularEcharts'], function (angul $scope.analysis.top_partners = chartParser.parse(topPartnerConfig, resp.data.reverse()); }) } - function loadTradeTimeAnalysis() { + /*function loadTradeTimeAnalysis() { var timeAnalysis = function (legend, series) { return { // title : { @@ -413,7 +413,7 @@ define(['angular', 'uiRouter', 'uiBootstrap', 'angularEcharts'], function (angul }); $scope.analysis.trade_time = timeAnalysis(leg, series); }) - } + }*/ function loadFeeAnalysis(params) { var analysisConfig = { diff --git a/src/main/ui/static/dashboard/templates/dashboard.html b/src/main/ui/static/dashboard/templates/dashboard.html index 75c4371f7..1eb8df98a 100644 --- a/src/main/ui/static/dashboard/templates/dashboard.html +++ b/src/main/ui/static/dashboard/templates/dashboard.html @@ -232,7 +232,7 @@
    -
    +
    diff --git a/src/main/ui/static/images/utilities/bill_electricity.png b/src/main/ui/static/images/utilities/bill_electricity.png new file mode 100644 index 000000000..5fa51aea6 Binary files /dev/null and b/src/main/ui/static/images/utilities/bill_electricity.png differ diff --git a/src/main/ui/static/images/utilities/bill_gas.png b/src/main/ui/static/images/utilities/bill_gas.png new file mode 100644 index 000000000..b0465d659 Binary files /dev/null and b/src/main/ui/static/images/utilities/bill_gas.png differ diff --git a/src/main/ui/static/images/utilities/bill_internet.png b/src/main/ui/static/images/utilities/bill_internet.png new file mode 100644 index 000000000..30a0abad5 Binary files /dev/null and b/src/main/ui/static/images/utilities/bill_internet.png differ diff --git a/src/main/ui/static/images/utilities/bill_life.png b/src/main/ui/static/images/utilities/bill_life.png new file mode 100644 index 000000000..5ff5a6086 Binary files /dev/null and b/src/main/ui/static/images/utilities/bill_life.png differ diff --git a/src/main/ui/static/images/utilities/bill_water.png b/src/main/ui/static/images/utilities/bill_water.png new file mode 100644 index 000000000..4cdd6efe5 Binary files /dev/null and b/src/main/ui/static/images/utilities/bill_water.png differ diff --git a/src/main/ui/static/images/utilities/r_logo.png b/src/main/ui/static/images/utilities/r_logo.png new file mode 100644 index 000000000..f9e1458f0 Binary files /dev/null and b/src/main/ui/static/images/utilities/r_logo.png differ diff --git a/src/main/ui/static/payment/billqrcode/bill-qrcode-manage.js b/src/main/ui/static/payment/billqrcode/bill-qrcode-manage.js new file mode 100644 index 000000000..a5d0b2248 --- /dev/null +++ b/src/main/ui/static/payment/billqrcode/bill-qrcode-manage.js @@ -0,0 +1,107 @@ +define(['angular', 'static/commons/commons', 'uiBootstrap', 'uiRouter', 'ngBootSwitch', 'ngFileUpload'], function (angular) { + 'use strict'; + + var app = angular.module('billQrCodeManagement', ['ui.bootstrap', 'ui.router', 'frapontillo.bootstrap-switch', 'ngFileUpload']); + app.config(['$stateProvider', function ($stateProvider) { + $stateProvider.state('bill_qrcode', { + url: '/bill_qrcode', + templateUrl: '/static/payment/billqrcode/templates/bill_qrcode.html', + controller: 'billQrCodeCtrl' + }) + }]); + app.controller('billQrCodeCtrl', ['$scope', '$http', 'commonDialog','$filter','orderService', function ($scope, $http, commonDialog,$filter,orderService) { + $scope.pagination = {}; + $scope.params = {}; + $scope.new_bill = {}; + $scope.minDate = new Date(); + var maxDate = new Date(); + $scope.maxDate = maxDate.setDate(maxDate.getDate() + 14); + + + $scope.loadBills = function (page) { + var params = angular.copy($scope.params); + params.page = page || $scope.pagination.page || 1; + $http.get('/partner/qrcode', {params: params}).then(function (resp) { + $scope.bills = resp.data; + $scope.pagination = resp.data.pagination; + }); + }; + $scope.loadBills(1); + $scope.generateBill = function () { + var params = angular.copy($scope.new_bill); + if(!params.client_order_id){ + alert("client order id为空,是否后台自动生成?"); + } + if(!params.order_amount){ + alert("order amount不可为空!"); + return; + } + if(params.cancle_time){ + params.cancle_time = $filter('date')(params.cancle_time, 'yyyy-MM-dd HH:mm:ss') + }else { + alert("Expire Date 不可为空!"); + } + $http.post('/partner/qrcode/bills',params).then(function (resp) { + commonDialog.alert({title: 'Success', content: 'Success', type: 'success'}); + $scope.code_url = resp.data; + $scope.loadBills(1); + },function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}); + }); + }; + $scope.disableBill = function (bill) { + commonDialog.confirm( + { + title: 'Delete Bill', + content: 'Are you sure to delete this bill?' + }).then(function () { + $http.delete('/partner/qrcode/'+bill.bill_code_id).then(function(){ + $scope.loadBills(1); + }); + }) + }; + $scope.clearBill = function () { + $scope.new_bill = {}; + $scope.code_url = ""; + }; + + $scope.showTradeDetail = function (order) { + orderService.clientOrderDetail(order) + }; + }]); + + app.filter('billStatus', function () { + return function (status) { + switch (status + '') { + case '1': + return 'wait for payment'; + case '2': + return 'disabled'; + case '3': + return 'payment success' + } + } + }); + + app.filter('remarkCut', function () { + return function (value, wordwise, max, tail) { + if (!value) return ''; + + max = parseInt(max, 10); + if (!max) return value; + if (value.length <= max) return value; + + value = value.substr(0, max); + if (wordwise) { + var lastspace = value.lastIndexOf(' '); + if (lastspace != -1) { + value = value.substr(0, lastspace); + } + } + return value + (tail || ' …'); + }; + }); + + + return app; +}); \ No newline at end of file diff --git a/src/main/ui/static/payment/billqrcode/templates/bill_qrcode.html b/src/main/ui/static/payment/billqrcode/templates/bill_qrcode.html new file mode 100644 index 000000000..3a0ff9daa --- /dev/null +++ b/src/main/ui/static/payment/billqrcode/templates/bill_qrcode.html @@ -0,0 +1,180 @@ + +
    +
    +

    Bill QR Code

    + +
    + +
    +
    +
    +
    +
    +
    +
    +
    + +
    +
    + + $ +
    +

    +
    +
    +
    + +
    + +

    The date of expiry should not exceed fifteen days

    +
    +
    + +
    + +
    + +

    System will automatically generate when the Reference NO is empty

    +
    +
    +
    + +
    + +

    within 100 characters

    +
    +
    +
    + +
    +     + +
    +
    +
    + +
    +
    +
    +
    +
    +
    + +   + All | + Success | + Disabled +
    +         +
    + + +
    +
    + +
    +
    +
    + +
    +
    +
    +

    + Bill List +

    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Order AmountReference NOPayerOrder StatusBill StatusExpire DateRemarkCreate timeOperation
    + + + + + Disable +
    +
    + +
    +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/src/main/ui/static/payment/good/good-manage.js b/src/main/ui/static/payment/good/good-manage.js index bbfdf88ae..cf2324d83 100644 --- a/src/main/ui/static/payment/good/good-manage.js +++ b/src/main/ui/static/payment/good/good-manage.js @@ -10,6 +10,11 @@ define(['angular', 'static/commons/commons', 'uiBootstrap', 'uiRouter', 'ngBootS templateUrl: '/static/payment/good/templates/goods.html', controller: 'goodListCtrl', data: {label: '商品列表'} + }).state('goods.sale', { + url: '/sale', + templateUrl: '/static/payment/good/templates/good_sale.html', + controller: 'goodOrderListCtrl', + data: {label: '商品列表'} }).state('goods.new', { url: '/new', templateUrl: '/static/payment/good/templates/add_good.html', @@ -196,7 +201,57 @@ define(['angular', 'static/commons/commons', 'uiBootstrap', 'uiRouter', 'ngBootS $scope.ctrl = {}; }]); - + app.controller('goodOrderListCtrl', ['$scope', '$http', function ($scope, $http) { + $scope.pagination = {}; + $scope.params = {status:'1'}; + $scope.today = new Date(); + $scope.chooseToday = function () { + $scope.params.datefrom = $scope.params.dateto = new Date(); + $scope.loadGoodOrders(1); + }; + $scope.chooseYesterday = function () { + var yesterday = new Date(); + yesterday.setDate(yesterday.getDate() - 1); + $scope.params.datefrom = $scope.params.dateto = yesterday; + $scope.loadGoodOrders(1); + }; + $scope.chooseLast7Days = function () { + $scope.params.dateto = new Date(); + var day = new Date(); + day.setDate(day.getDate() - 7); + $scope.params.datefrom = day; + $scope.loadGoodOrders(1); + }; + $scope.thisMonth = function () { + $scope.params.dateto = new Date(); + var monthBegin = new Date(); + monthBegin.setDate(1); + $scope.params.datefrom = monthBegin; + $scope.loadGoodOrders(1); + }; + $scope.lastMonth = function () { + var monthFinish = new Date(); + monthFinish.setDate(0); + $scope.params.dateto = monthFinish; + var monthBegin = new Date(); + monthBegin.setDate(0); + monthBegin.setDate(1); + $scope.params.datefrom = monthBegin; + $scope.loadGoodOrders(1); + }; + $scope.loadGoodOrders = function (page) { + var params = angular.copy($scope.params); + if (params.status=='ALL'){ + delete params.status; + } + params.page = page || $scope.pagination.page || 1; + $http.get('/sys/client/goods/goodOrders', {params: params}).then(function (resp) { + $scope.sales = resp.data.data; + $scope.pagination = resp.data.pagination; + }); + }; + $scope.loadGoodOrders(1); + }]); return app; }); \ No newline at end of file diff --git a/src/main/ui/static/payment/good/good-sale.js b/src/main/ui/static/payment/good/good-sale.js index d21af8f22..af1c50538 100644 --- a/src/main/ui/static/payment/good/good-sale.js +++ b/src/main/ui/static/payment/good/good-sale.js @@ -1,6 +1,7 @@ /** * Created by yishuqian on 8/29/16. */ +/* define(['angular', 'static/commons/commons', 'uiBootstrap', 'uiRouter', 'ngBootSwitch'], function (angular) { 'use strict'; @@ -67,4 +68,4 @@ define(['angular', 'static/commons/commons', 'uiBootstrap', 'uiRouter', 'ngBootS }]); return app; -}); \ No newline at end of file +});*/ diff --git a/src/main/ui/static/payment/good/templates/good_sale.html b/src/main/ui/static/payment/good/templates/good_sale.html index 4151186ae..40183929a 100644 --- a/src/main/ui/static/payment/good/templates/good_sale.html +++ b/src/main/ui/static/payment/good/templates/good_sale.html @@ -1,158 +1,146 @@ -
    -
    -

    List of Products Sold

    - -
    - -
    -
    -
    -
    -
    -
    -
    -
    - -
    -

    - All | - Payment Success | - Waiting for Payment -

    +
    +
    +
    +
    +
    +
    +
    + + +
    +
    + +
    +
    +
    +
    -
    -
    - -
    -
    -
    - -
    - ~ -
    - -
    - -
    - Today -
    -
    - Yesterday -
    - - - -
    - + ~ +
    +
    +
    + Today +
    +
    + Yesterday +
    + + +
    - - - - - -
    +
    + + + + + +
    +
    +
    -
    -
    -

    List of Products Sold

    -
    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - +
    +
    +

    List of Products Sold

    +
    -
    - -
    Sale IDPayment Order IDProduct NameUnit PriceQuantityOrder TotalOrder StatusCreate Time
    - PAID - NOT PAID - CLOSED -
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Sale IDPayment Order IDProduct NameUnit PriceQuantityOrder TotalOrder StatusCreate Time
    + PAID + NOT PAID + CLOSED +
    -
    - + -
    + +
    +
    -
    \ No newline at end of file +
    diff --git a/src/main/ui/static/payment/good/templates/goods.html b/src/main/ui/static/payment/good/templates/goods.html index 1ad5e2a60..8a6b4dd2e 100644 --- a/src/main/ui/static/payment/good/templates/goods.html +++ b/src/main/ui/static/payment/good/templates/goods.html @@ -1,135 +1,150 @@ -
    -
    -

    Product Management

    - -
    -
    +
    +

    Product & Sale

    + +
    +
    -
    -
    -
    -
    - - - - -
    - - -
    -
    - - -
    - - - - - -
    - -
    -
    + -
    - -
    -
    +
    -
    \ No newline at end of file diff --git a/src/main/ui/static/payment/invoice/invoice.js b/src/main/ui/static/payment/invoice/invoice.js index 3d485eeb2..f02fc73e7 100644 --- a/src/main/ui/static/payment/invoice/invoice.js +++ b/src/main/ui/static/payment/invoice/invoice.js @@ -1,7 +1,7 @@ /** * Created by yixian on 2017-02-05. */ -define(['angular'], function (angular) { +define(['angular','decimal'], function (angular,decimal) { 'use strict'; var app = angular.module('invoiceApp', ['ui.router']); app.config(['$stateProvider', function ($stateProvider) { @@ -67,6 +67,7 @@ define(['angular'], function (angular) { $scope.tradeLogs = resp.data.data; $scope.pagination = resp.data.pagination; $scope.analysis = resp.data.analysis; + $scope.total_surcharge = decimal.add($scope.analysis.total_surcharge,$scope.analysis.tax_amount).toFixed(2); $scope.analysis.refund_fee = angular.copy(Math.abs($scope.analysis.refund_fee)); }, function (resp) { commonDialog.alert({title: 'Search failed', content: resp.data.message, type: 'error'}); diff --git a/src/main/ui/static/payment/invoice/templates/invoice.html b/src/main/ui/static/payment/invoice/templates/invoice.html index 9606c0804..81a760973 100644 --- a/src/main/ui/static/payment/invoice/templates/invoice.html +++ b/src/main/ui/static/payment/invoice/templates/invoice.html @@ -141,7 +141,7 @@
    Total Surcharge + ng-bind="total_surcharge|currency:'AUD '">
    diff --git a/src/main/ui/static/payment/partner/partner-manage.js b/src/main/ui/static/payment/partner/partner-manage.js index 0f2545c36..672af88c2 100644 --- a/src/main/ui/static/payment/partner/partner-manage.js +++ b/src/main/ui/static/payment/partner/partner-manage.js @@ -344,6 +344,10 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter return; } + if ($scope.partner.company_name.indexOf("Migration") != -1) { + alert("Company Name包含敏感词汇,请检查后重新提交!"); + return; + } if ($scope.partner.company_phone_a && ('' + $scope.partner.company_phone_a != '')) { if ($scope.partner.company_phone_a.indexOf('0') == 0) { alert("Please remove the first character '0' of area code"); @@ -920,6 +924,10 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter return; } + if ($scope.partner.company_name.indexOf("Migration") != -1) { + alert("Company Name包含敏感词汇,请检查后重新提交!"); + return; + } if ($scope.partner.company_phone.indexOf(' ') != -1) { alert('Company Phone can not contain space character'); return; @@ -1788,7 +1796,10 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter return; } $scope.errmsg = null; - + if ($scope.partner.company_name.indexOf("Migration") != -1) { + alert("Company Name包含敏感词汇,请检查后重新提交!"); + return; + } if ($scope.partner.company_phone_a && ('' + $scope.partner.company_phone_a != '')) { if ($scope.partner.company_phone_a.indexOf('0') == 0) { diff --git a/src/main/ui/static/payment/partner/templates/partner_pay_logs.html b/src/main/ui/static/payment/partner/templates/partner_pay_logs.html index 3a8000e4d..351050ba1 100644 --- a/src/main/ui/static/payment/partner/templates/partner_pay_logs.html +++ b/src/main/ui/static/payment/partner/templates/partner_pay_logs.html @@ -58,7 +58,9 @@ APP | Share Code + ng-click="params.gateway=[11];loadTradeLogs(1)">Share Code | + MiniProgram

    diff --git a/src/main/ui/static/payment/tradelog/templates/partner_trade_logs.html b/src/main/ui/static/payment/tradelog/templates/partner_trade_logs.html index dfc9bcbb4..44741988a 100644 --- a/src/main/ui/static/payment/tradelog/templates/partner_trade_logs.html +++ b/src/main/ui/static/payment/tradelog/templates/partner_trade_logs.html @@ -118,9 +118,11 @@ Third Party Gateway | APP + ng-click="params.gateway=[10];loadTradeLogs(1)">APP | Share Code + ng-click="params.gateway=[11];loadTradeLogs(1)">Share Code | + MiniProgram

    diff --git a/src/main/ui/static/payment/tradelog/templates/trade_logs.html b/src/main/ui/static/payment/tradelog/templates/trade_logs.html index 36d8b6f17..a73711411 100644 --- a/src/main/ui/static/payment/tradelog/templates/trade_logs.html +++ b/src/main/ui/static/payment/tradelog/templates/trade_logs.html @@ -156,9 +156,11 @@ Third Party Gateway | APP + ng-click="params.gateway=[10];loadTradeLogs(1)">APP | Share Code + ng-click="params.gateway=[11];loadTradeLogs(1)">Share Code | + MiniProgram

    diff --git a/src/main/ui/static/risk/templates/risk.html b/src/main/ui/static/risk/templates/risk.html index ff55c8552..c53c559d8 100644 --- a/src/main/ui/static/risk/templates/risk.html +++ b/src/main/ui/static/risk/templates/risk.html @@ -7,7 +7,37 @@
    -
    +
    +
    +
    +
    + + +
    +    +
    + + + +
    +
    + +
    +
    +
    +
    +
    Records
    diff --git a/src/main/ui/static/templates/alipay/v1/bill_retail_jsapi.js b/src/main/ui/static/templates/alipay/v1/bill_retail_jsapi.js new file mode 100644 index 000000000..7e7290d52 --- /dev/null +++ b/src/main/ui/static/templates/alipay/v1/bill_retail_jsapi.js @@ -0,0 +1,79 @@ +/** + * Created by yixian on 2016-07-15. + */ +$(document).ready(function () { + 'use strict'; + decode(); + function decode() { + var redirect = window.redirect; + while(redirect.indexOf('://')<0){ + redirect = decodeURIComponent(redirect); + if(redirect==window.redirect){ + break; + } + window.redirect = redirect; + } + } + var dataCache = {paying: false}; + $('#key_P').bind('touchstart', startPay); + function startPay() { + $('#wdiv').show(); + if (dataCache.paying) { + return; + } + dataCache.paying = true; + + $.ajax({ + url: '/api/v1.0/alipay/partners/' + window.client_moniker + '/orders/'+window.order_id+'/order_params', + method: 'GET', + dataType: 'json', + success: function (pay) { + if (pay.direct_paid) { + location.href = window.redirect; + return; + } + if (window.AlipayJSBridge) { + callPayment(); + } else { + // 如果没有注入则监听注入的事件 + document.addEventListener('AlipayJSBridgeReady', callPayment, false); + } + + function callPayment() { + try { + AlipayJSBridge.call('tradePay', { + tradeNO: pay.trade_no + }, function (res) { + dataCache.paying = false; + if (res.resultCode == '9000') { + AlipayJSBridge.call('startApp', { + appId: '20000056', + param: { + actionType: 'showSuccPage', + payResult: res.result + }, + closeCurrentApp: false + }); + location.href = window.redirect; + } else { + alert(res.memo); + } + $('#wdiv').hide(); + }) + } catch (err) { + alert(err); + $('#wdiv').hide(); + } + } + }, + error: function (jqXhr) { + alert(jqXhr.responseJSON.message); + $('#wdiv').hide(); + dataCache.paying = false; + } + }) + + + } + +}); \ No newline at end of file diff --git a/src/main/ui/static/templates/payment/bill_gateway_jsapi.css b/src/main/ui/static/templates/payment/bill_gateway_jsapi.css new file mode 100644 index 000000000..3440c90b9 --- /dev/null +++ b/src/main/ui/static/templates/payment/bill_gateway_jsapi.css @@ -0,0 +1,120 @@ +.weui_cell_ft { + max-width: 60%; + white-space: normal +} +.pay-container{ + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; +} +.pay-container>img{ + display: block; + margin: auto; + width: 250px; +} +div,span,img,button,a,p{ + box-sizing: border-box; +} +body{ + background: #fff; +} +.royal-container{ + margin-top: 20%; + display: block; + width: 100%; + padding: 10px 30px; +} + +.royal-container .royal-row{ + border-bottom: 1px solid #d1d2d4; + padding: 5px 0; +} +.royal-container .royal-row.brand{ + text-align: center; +} +.royal-container .royal-row.brand img{ + display: block; + max-width: 60%; + max-height: 100px; + margin: auto; +} +.royal-container .royal-row.brand .name{ + display: block; + margin: auto; + font-size: 1.6em; +} +.text-title{ + color: #888888; + font-size: 0.9em; +} + +.text-main{ + color: #333333; + font-size: 1.1em; +} + +.royal-pay-btn{ + background: #30af69; + color: #fff; + width: 96%; + display: block; + margin: 10px auto 30px; + height: 50px; + line-height: 50px; + font-size: 1.4em; + text-align: center; +} + +.alipay .royal-pay-btn{ + background: #108ee9; +} + +.alipay .amount_title{ + background: #108ee9; +} + +.amount_title{ + height: 14%; + z-index: 10; + background: #30af69; + max-height: 200px; + min-height: 120px; + width: 100%; +} +.amount_title_logo{ + float: left; + max-width: 90px; + min-width: 80px; + margin-left: 10px; +} +.amount_title_content{ + float: left; +} +.amount_title_content_amount{ + font-family: Avenir-Roman; + font-size: 30px; + color: #FFFFFF; +} + +.amount_title_content_text{ + font-family: PingFangSC-Regular; + font-size: 17px; + color: #FFFFFF; +} +.merchant_info{ + height: 100px; + z-index: 1; + position: absolute; + width: 94%; + margin: -5% 0% 0px 3%; + text-align: center; + background-color: #FFFFFF; + box-shadow: 0px 0px 8px 0px rgba(171,171,171,0.50); +} + +.merchant_info img{ + max-height: 60px; + min-height: 50px; +} \ No newline at end of file diff --git a/src/main/ui/static/templates/payment/v1/bill_retail_jsapi.js b/src/main/ui/static/templates/payment/v1/bill_retail_jsapi.js new file mode 100644 index 000000000..f9c529a9e --- /dev/null +++ b/src/main/ui/static/templates/payment/v1/bill_retail_jsapi.js @@ -0,0 +1,106 @@ + +$(document).ready(function () { + 'use strict'; + decode(); + + function decode() { + var redirect = window.redirect; + while (redirect.indexOf('://') < 0) { + redirect = decodeURIComponent(redirect); + if (redirect == window.redirect) { + break; + } + window.redirect = redirect; + } + } + + var dataCache = {paying: false}; + $('#key_P').bind('touchstart', startPay); + + function startPay() { + $('#wdiv').show(); + if (dataCache.paying) { + return; + } + dataCache.paying = true; + + $.ajax({ + url: '/api/payment/v1.0/wechat_jsapi_payment/partners/' + window.client_moniker + '/orders/' + window.order_id + '/preorder', + method: 'get', + dataType: 'json', + success: function (pay) { + try { + if (pay.direct_paid) { + dataCache.paying = false; + location.href = window.redirect; + } + var paydata = pay.jsapi; + invokePay(paydata); + }catch (e) { + alert("Unexpected Error:" + e); + $('#wdiv').hide(); + dataCache.paying = false; + } + }, + error: function (jqXhr) { + var respText = jqXhr.responseText; + try { + alert(JSON.parse(respText).message); + $('#wdiv').hide(); + dataCache.paying = false; + } catch (e) { + alert("Unexpected Error:" + respText); + $('#wdiv').hide(); + dataCache.paying = false; + } + + } + }); + + + } + + function invokePay(paydata) { + WeixinJSBridge.invoke('getBrandWCPayRequest', { + 'appId': paydata.appId, + 'timeStamp': paydata.timeStamp, + 'nonceStr': paydata.nonceStr, + 'package': paydata.package, + 'signType': paydata.signType, + 'paySign': paydata.paySign + }, function (res) { + dataCache.paying = false; + if (res.err_msg == 'get_brand_wcpay_request:ok') { + startCheckOrder(window.order_id) + } else { + if (res.err_msg != 'get_brand_wcpay_request:cancel' && res.err_msg != 'get_brand_wcpay_request:fail') { + alert('WeChat Error:' + res.err_msg); + } + if (window.paydata) { + location.href = window.redirect + (window.redirect.indexOf('?') < 0 ? '?' : '&') + 'success=false'; + } + } + //todo get status from server + $('#wdiv').hide(); + }) + } + + function startCheckOrder(orderId) { + function checkOrderStd() { + $.ajax({ + url: '/api/v1.0/payment/orders/' + orderId + '/status', + method: 'GET', + dataType: 'json', + success: function (res) { + if (res.paid) { + location.href = window.redirect + (window.redirect.indexOf('?') < 0 ? '?' : '&') + 'success=true'; + } else { + setTimeout(checkOrderStd, 500); + } + } + }) + } + + checkOrderStd(); + } +}); \ No newline at end of file diff --git a/src/test/java/au/com/royalpay/payment/manage/apps/core/impls/CustomerImpressionImplTest.java b/src/test/java/au/com/royalpay/payment/manage/apps/core/impls/CustomerImpressionImplTest.java index 0a0758101..615a1ee29 100644 --- a/src/test/java/au/com/royalpay/payment/manage/apps/core/impls/CustomerImpressionImplTest.java +++ b/src/test/java/au/com/royalpay/payment/manage/apps/core/impls/CustomerImpressionImplTest.java @@ -2,34 +2,28 @@ package au.com.royalpay.payment.manage.apps.core.impls; import au.com.royalpay.payment.manage.mappers.payment.OrderMapper; import au.com.royalpay.payment.manage.mappers.system.ClientMapper; +import au.com.royalpay.payment.manage.mappers.system.OrgMapper; -import com.alibaba.fastjson.JSONObject; - -import org.apache.poi.hssf.usermodel.HSSFCell; -import org.apache.poi.ss.usermodel.Cell; -import org.apache.poi.ss.usermodel.Row; -import org.apache.poi.xssf.usermodel.XSSFSheet; -import org.apache.poi.xssf.usermodel.XSSFWorkbook; -import org.junit.Ignore; +import org.apache.commons.codec.binary.Base64; +import org.apache.commons.lang3.time.DateUtils; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.web.bind.annotation.RequestMethod; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; import java.io.IOException; -import java.io.OutputStream; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; +import java.net.URISyntaxException; +import java.nio.charset.Charset; +import java.util.Date; import javax.annotation.Resource; +import cn.yixblog.platform.http.HttpRequestGenerator; +import cn.yixblog.platform.http.HttpRequestResult; + /** * Created by wangning on 05/01/2018. */ @@ -44,7 +38,10 @@ public class CustomerImpressionImplTest { private StringRedisTemplate stringRedisTemplate; @Resource private ClientMapper clientMapper; - + @Resource + private OrgMapper orgMapper; +// @Resource +// private MailGunClient mailGunClient; // @Test // public void redisQueue() { @@ -56,75 +53,88 @@ public class CustomerImpressionImplTest { // } // } - @Ignore - public void excel() { - try { - - List asd =null; - Map map = new HashMap<>(); - asd.forEach(p->{ - map.put(p.getString("sub_merchant_id"),p); - }); - - XSSFWorkbook workbook = new XSSFWorkbook(new FileInputStream(new File("/Users/wangning/Desktop/qwe.xlsx"))); - XSSFSheet sheet = workbook.getSheetAt(0); - Iterator rowIterator = sheet.rowIterator(); - Row row = null; - Cell cell = null; - while (rowIterator.hasNext()) { - row = rowIterator.next(); - cell = row.getCell(1); - if(cell==null){ - continue; - } - cell.setCellType(HSSFCell.CELL_TYPE_STRING); - JSONObject tmpOBJ = map.get(cell.getStringCellValue()); - if(tmpOBJ==null){ - continue; - } - row.createCell(4).setCellValue(tmpOBJ.getString("cc")); - row.createCell(5).setCellValue(tmpOBJ.getString("maxct")); - } -// -// -// if (!"Australia".equals(row.getCell(1).getStringCellValue())) { -// continue; -// } -// cell = row.getCell(0); +// @Test +// public void excel() { +// try { +// XSSFWorkbook workbook = new XSSFWorkbook(new FileInputStream(new File("/Users/wangning/Desktop/asd.xlsx"))); +// XSSFSheet sheet = workbook.getSheetAt(0); +// Iterator rowIterator = sheet.rowIterator(); +// Row row = null; +// Cell cell = null; +// while (rowIterator.hasNext()) { +// row = rowIterator.next(); +// cell = row.getCell(3); // cell.setCellType(HSSFCell.CELL_TYPE_STRING); // -// JSONObject client = clientMapper.clientInfoBySubMerchantId(cell.getStringCellValue()); +// JSONObject client = clientMapper.findClientByMoniker(cell.getStringCellValue().trim()); // if(client==null){ +// System.out.println(); // continue; // } -// row.createCell(4).setCellValue(client.getString("bd_user_name")); -// row.createCell(5).setCellValue(client.getString("client_moniker")); -// row.createCell(6).setCellValue(client.getString("short_name")); -// } -// -// XSSFSheet sheet3 = workbook.getSheetAt(3); -// Iterator rowIterator3 = sheet3.rowIterator(); -// while (rowIterator3.hasNext()) { -// row = rowIterator3.next(); -// if (!"Australia".equals(row.getCell(1).getStringCellValue())) { -// continue; -// } -// cell = row.getCell(0); -// cell.setCellType(HSSFCell.CELL_TYPE_STRING); -// JSONObject client = clientMapper.clientInfoBySubMerchantId(cell.getStringCellValue()); -// if(client==null){ +// JSONObject org = orgMapper.findOne(client.getIntValue("org_id")); +// if(org==null){ // continue; // } -// row.createCell(4).setCellValue(client.getString("bd_user_name")); -// row.createCell(5).setCellValue(client.getString("client_moniker")); -// row.createCell(6).setCellValue(client.getString("short_name")); +// +// row.createCell(5).setCellValue(org.getString("name")); // } +// +// OutputStream out = new FileOutputStream("/Users/wangning/Desktop/春节活动报名结果通知(包含BD名称).xlsx"); +// workbook.write(out); +// workbook.close(); +// } catch (IOException e) { +// e.printStackTrace(); +// } +// } - OutputStream out = new FileOutputStream("/Users/wangning/Desktop/订单fin.xlsx"); - workbook.write(out); - workbook.close(); + @Test + public void sendSimpleMessage() throws Exception { + String url = "https://api.mailgun.net/v3/dev.showcodes.com/events"; + HttpRequestGenerator generator = new HttpRequestGenerator(url, RequestMethod.POST).addHeader("Authorization", getHeader()); + + generator.addQueryString("ascending", "yes"); + generator.addQueryString("limit", "12"); + System.out.println(String.valueOf(DateUtils.addDays(new Date(),1))); + HttpRequestResult res = null; + try { + res = generator.execute(); + } catch (URISyntaxException e) { + e.printStackTrace(); + } + System.out.println(res.getException()); + System.out.println(); + System.out.println(); + + try { + System.out.println(res.getResponseContentJSONObj().toJSONString()); } catch (IOException e) { e.printStackTrace(); } } + + private String getHeader() { + String auth = "api:key-96fa3b5866ace125b8ec5a9d27e19353"; + byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(Charset.forName("UTF-8"))); + String authHeader = "Basic " + new String(encodedAuth); + return authHeader; + } + +// @Test +// public void sendSimpleMessages() throws Exception { +// SendMail sendMail = new SendMail(); +// sendMail.setContent("

    Hi kira

    "); +// Set mailCCs = new HashSet<>(); +// mailCCs.add("164851225@qq.com"); +// sendMail.setMailCcs(mailCCs); +// Set mailtos = new HashSet<>(); +// mailtos.add("1029811920@qq.com"); +// sendMail.setMailTos(mailtos); +// sendMail.setTitle("Final Test"); +// +// JSONObject result = mailGunClient.sendMail(sendMail); +// System.out.println(result.toJSONString()); +// System.out.println(result.toJSONString()); +// System.out.println(result.toJSONString()); +// } + } \ No newline at end of file