This commit is contained in:
junshuai
2022-07-23 13:54:07 +08:00
parent 809c426b5a
commit 62548736a7
4912 changed files with 827659 additions and 38 deletions

View File

@@ -0,0 +1,39 @@
package cn.pluss.platform;
import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.retry.annotation.EnableRetry;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.web.context.request.RequestContextListener;
@MapperScan("cn.pluss.platform.mapper")
@SpringBootApplication(scanBasePackages = "cn.pluss.platform")
@EnableRetry
@EnableAsync
public class WapApplication extends SpringBootServletInitializer{
private static final Logger logger = LoggerFactory.getLogger(WapApplication.class);
public static void main(String[] args) {
SpringApplication.run(WapApplication.class, args);
logger.info("WapApplication Service Start Success");
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(WapApplication.class);
}
@Bean
public RequestContextListener requestContextListenerBean() {
return new RequestContextListener();
}
}

View File

@@ -0,0 +1,50 @@
package cn.pluss.platform.controller.component;
import cn.pluss.platform.entity.MerchantOrder;
import cn.pluss.platform.merchantOrder.MerchantOrderService;
import cn.pluss.platform.merchantProfit.MerchantProfitService;
import cn.pluss.platform.realFans.RealFansService;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Configuration;
import javax.annotation.Resource;
/**
* @author SSS
*/
@Slf4j
@Configuration
@ConditionalOnProperty(prefix = "scheduling", name = "enabled", havingValue = "true")
@RabbitListener(queues = "payCallback")
public class PayCallbackConsumer {
@Resource
private MerchantProfitService merchantProfitService;
@Resource
private MerchantOrderService merchantOrderService;
@Resource
private RealFansService realFansService;
@RabbitHandler
public void process(String msg) {
log.info("接受到的消息内容为:{}", msg);
MerchantOrder order = JSON.parseObject(msg, MerchantOrder.class);
if(!"1".equals(order.getStatus())){
return;
}
if(!"1".equals(order.getOrderType())){
realFansService.createFansProfit(order);
}
merchantProfitService.createOrderProfitV2(order,"1");
MerchantOrder update = new MerchantOrder();
update.setId(order.getId());
update.setProfitShareMoney(order.getProfitShareMoney());
update.setFansShareMoney(order.getFansShareMoney());
merchantOrderService.updateById(update);
}
}

View File

@@ -0,0 +1,116 @@
package cn.pluss.platform.controller.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.accept.ContentNegotiationManager;
import org.springframework.web.servlet.View;
import org.springframework.web.servlet.ViewResolver;
import org.springframework.web.servlet.view.ContentNegotiatingViewResolver;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
import org.springframework.web.servlet.view.json.MappingJackson2JsonView;
import org.thymeleaf.spring5.SpringTemplateEngine;
import org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver;
import org.thymeleaf.spring5.view.ThymeleafViewResolver;
import org.thymeleaf.templatemode.TemplateMode;
import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver;
import org.thymeleaf.templateresolver.ITemplateResolver;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
/**
* 主要配置多视图实现的视图解析器相关bean实例,将该视图解析器注册到容器中
* <p>
* <p>
* 其实关键点在于两个:
* 1、配置order属性
* 2、配置viewnames属性
**/
@Configuration
public class ViewResolverConfiguration{
@Bean
public ViewResolver contentNegotiatingViewResolver(ContentNegotiationManager manager) {
ContentNegotiatingViewResolver resolver = new ContentNegotiatingViewResolver();
resolver.setContentNegotiationManager(manager);
List<ViewResolver> resolvers = new ArrayList<ViewResolver>();
resolvers.add(jsonViewResolver());
resolvers.add(jspViewResolver());
resolvers.add(thymeleafViewResolver());
resolver.setViewResolvers(resolvers);
return resolver;
}
@Bean
public ViewResolver jsonViewResolver() {
return new ViewResolver() {
@Override
public View resolveViewName(String viewName, Locale locale) throws Exception {
MappingJackson2JsonView view = new MappingJackson2JsonView();
view.setPrettyPrint(true);
return view;
}
};
}
@Bean
public ViewResolver jspViewResolver() {
InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
viewResolver.setPrefix("/WEB-INF/jsp/");
viewResolver.setSuffix(".jsp");
viewResolver.setContentType("text/html");
viewResolver.setOrder(2);
return viewResolver;
}
@Bean
public ViewResolver thymeleafViewResolver() {
ThymeleafViewResolver viewResolver = new ThymeleafViewResolver();
viewResolver.setTemplateEngine(thymeleafTemplateEngine());
viewResolver.setCharacterEncoding("UTF-8");
viewResolver.setOrder(0);
// Important!!
// th_page1.html, th_page2.html, ...
// 可以删除
viewResolver.setViewNames(new String[] { "th_*","*/th_*"});
return viewResolver;
}
// Thymeleaf template engine with Spring integration
@Bean
public SpringTemplateEngine thymeleafTemplateEngine() {
SpringTemplateEngine templateEngine = new SpringTemplateEngine();
templateEngine.setTemplateResolver(thymeleafTemplateResolver());
templateEngine.setEnableSpringELCompiler(true);
return templateEngine;
}
@Bean
public SpringResourceTemplateResolver springResourceTemplateResolver() {
return new SpringResourceTemplateResolver();
}
// Thymeleaf template resolver serving HTML 5
@Bean
public ITemplateResolver thymeleafTemplateResolver() {
ClassLoaderTemplateResolver templateResolver = new ClassLoaderTemplateResolver();
templateResolver.setPrefix("templates/");
templateResolver.setCacheable(false);
templateResolver.setSuffix(".html");
templateResolver.setTemplateMode(TemplateMode.HTML);
templateResolver.setCharacterEncoding("UTF-8");
return templateResolver;
}
}

View File

@@ -0,0 +1,68 @@
package cn.pluss.platform.controller.filter;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import cn.pluss.platform.entity.MerchantMenber;
/**
* @author yuchen
*
* @Description
*/
@Slf4j
@Component
public class AuthFilter implements Filter {
@Override
public void doFilter(ServletRequest req, ServletResponse resp, FilterChain arg2)
throws IOException, ServletException {
HttpServletRequest request=(HttpServletRequest) req;
log.info("requestURI : {}", request.getRequestURI());
log.info("requestMethod : {}", request.getMethod());
log.info("requestParams : {}", request.getParameterMap());
HttpServletResponse response= (HttpServletResponse) resp;
MerchantMenber merchantMenber = (MerchantMenber) request.getSession().getAttribute("sessionMerchantMenber");
String url = request.getRequestURI();
if(merchantMenber==null) {
if(!url.contains("CallBack")
&& !url.contains("wechat")
&& !url.contains("merchant")
&& !url.contains("myVIPCard")
&& !url.contains("resources")
&& !url.contains("openCardSuccess")
&& !url.contains("vipOpenCard")
&& !url.contains("auth")
&& !url.contains("jft")
&& !url.contains("getMemberInfo")
&& !url.contains("aliPay")
&& !url.contains("test")
&& !url.contains("life")
&& !url.contains("getPhoneCode")
&& !url.contains("api")
&& !url.contains("user")
&& !url.contains("activity")
&& !url.contains("kaptcha")
&& !url.contains("aliyun")) {
request.getRequestDispatcher("/vip/myVIPCard").forward(req, resp);
return;
}
}
arg2.doFilter(request, response);
}
}

View File

@@ -0,0 +1,223 @@
package cn.pluss.platform.controller.home;
import cn.pluss.platform.ali.AliPayNotifyService;
import cn.pluss.platform.api.Result;
import cn.pluss.platform.api.ResultGenerator;
import cn.pluss.platform.deviceMerchantBuy.DeviceMerchantBuyService;
import cn.pluss.platform.entity.*;
import cn.pluss.platform.pay.ApiPayService;
import cn.pluss.platform.util.*;
import cn.pluss.platform.wap.HttpUrlConnection;
import com.alibaba.fastjson.JSONObject;
import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.internal.util.AlipaySignature;
import com.alipay.api.request.AlipaySystemOauthTokenRequest;
import com.alipay.api.response.AlipaySystemOauthTokenResponse;
import lombok.Setter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.UnsupportedEncodingException;
import java.text.SimpleDateFormat;
import java.util.Base64;
import java.util.HashMap;
import java.util.Map;
/**
* @author yuchen
*
* @Description 授权应用获取token控制器
*/
@Controller
@RequestMapping("aliPay")
public class AliPayController {
@Setter(onMethod_ = {@Autowired})
private AliPayNotifyService aliPayNotifyService;
private static final Logger logger = LoggerFactory.getLogger(AliPayController.class);
@Setter(onMethod_ = {@Autowired})
private HttpServletRequest request;
@Setter(onMethod_ = {@Autowired})
private DeviceMerchantBuyService deviceMerchantBuyService;
/**
* base64编码
*/
final static Base64.Encoder encoder = Base64.getEncoder();
@Resource
private ApiPayService apiPayService;
@GetMapping("/index")
public String index() throws UnsupportedEncodingException {
String userId = request.getParameter("userId");
if (userId == null) {
return "aliPay/fail";
}
byte[] textByte = userId.getBytes("UTF-8");
String returnUrl = ParametersUtil.ALI_RETURN_URL;
userId = encoder.encodeToString(textByte);
StringBuffer sb = new StringBuffer();
sb.append("https://openauth.alipay.com/oauth2/appToAppBatchAuth.htm?");
sb.append("app_id=" + ParametersUtil.ALI_APP_ID);
sb.append("&application_type=WEBAPP,MOBILEAPP");
sb.append("&redirect_uri=" + returnUrl);
sb.append("&state=" + userId);
request.setAttribute("returnUrl", sb);
return "aliPay/aliPay";
}
@GetMapping("/returnUrl")
public String returnUrl(String orderNumber){
request.setAttribute("orderNumber",orderNumber);
request.setAttribute("appId",ParametersUtil.ZY_ALI_APP_ID);
return "th_alipay";
}
/**
* aliCallBack:(设备订单支付宝回调通知). <br/>
*
* @param request
* @return
*
* @author Administrator
* @since JDK 1.8
*/
@PostMapping("/aliCallBack")
public String aliCallBack(HttpServletRequest request) {
Map<String, Object> srcParam = HttpUrlConnection.convertRequestParamsToMap(this.request);
Map<String, String> params = new HashMap<>();
for (Map.Entry<String, Object> entry : srcParam.entrySet()) {
params.put(entry.getKey(), (String) entry.getValue());
}
try {
boolean signVerified = AlipaySignature.rsaCheckV1(params, ParametersUtil.ZY_PUB, "UTF-8", "RSA2");
if (signVerified) {
String tradeStatus = params.get("trade_status");
logger.info("=====tradeStatus=====" + tradeStatus);
if ("TRADE_SUCCESS".equals(tradeStatus)) {
String tradeNumber = params.get("trade_no");
String orderNumber = params.get("out_trade_no");// 商家订单号
String consumTime = params.get("gmt_payment");// 交易付款时间
DeviceMerchantBuy deviceMerchantBuy = new DeviceMerchantBuy();
deviceMerchantBuy.setOrderNo(orderNumber);
deviceMerchantBuy = deviceMerchantBuyService.queryDeviceMerchantBuy(deviceMerchantBuy);
if ("1".equals(deviceMerchantBuy.getStatus())) {
return "success";
}
deviceMerchantBuy.setStatus("1");
deviceMerchantBuy.setTransNo(tradeNumber);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
deviceMerchantBuy.setTransDt(sdf.parse(consumTime));
deviceMerchantBuyService.updateDeviceMerchantBuy(deviceMerchantBuy);
}
return "success";
}
} catch (Exception e) {
e.printStackTrace();
return "failure";
}
return "failure";
}
/**
* aliCallBack:(设备订单支付宝回调通知). <br/>
*
* @param request
* @return
*
* @author Administrator
* @since JDK 1.8
*/
@PostMapping("/aliCallBackV2")
public String aliCallBackV2(HttpServletRequest request) {
Map<String, Object> param = HttpUrlConnection.convertRequestParamsToMap(request);
try {
aliPayNotifyService.commonPayNotify(param);
return "success";
} catch (Exception e) {
e.printStackTrace();
return "failure";
}
}
@PostMapping("/app/getAuthOpenId")
@ResponseBody
public Result<Object> getAuthOpenId(@RequestBody JSONObject params) {
String authCode = params.getString("authCode");
if(StringUtil.isEmpty(authCode)){
return ResultGenerator.genFailResult("获取授权信息失败!");
}
String privateKey = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCEWqqQVjebxhtnuGC9yBUFnFJ7R4ZYKJ/110WYdww/N2YDQPmOqYLW5d4BSDtjZmYlMwG/QFO2NIf5tMz1vtN4/Px9PUIlEFYkdTNAr4kQeQ/cEpj+jymZZ1cpGnZnFBiGYuSsovGIe5CmeegYBMKreuTzjZP5tsGMH2UQ9bEsc4q2y74VGV8j0ealA5Z9fh9aIF+CSi0SfftGuc3n0SSDIWB/ZOFVEkcuVbO/qbIM+2xFkS2RbKKlDW88cdHr9cSPY9A4b8c9aiaHUHWHCHRCKMZsgY8ANGrvCRC4sgMaX96UKk+0Ioy5lI0lkdHr5Yal/NExyWRwTZEugIaSMWF5AgMBAAECggEAR61iWbCXhQEQrmcn3R+SYut5r9HYa730gwsGYb93HnU+Bd0WSbB7by4lwMQBhZ9bCiJJe+22aCKi0RSdOykRFaDMjHa0b6YdQLlH/GwT6pvlfuWDfbjCapWQmm3+WWyEq6K6/NNxwtxIRiAXFYrecken3k56KO5UezI1Za3pOYzB2kRaIoJ0/jqpQPUBhbdIQ8CkztHmXmWb57CmuvlKHjc5YlxGS+vRTdRY6ifSbwFrcJgiO43zOmDjKJdnrmAaSVjZX4pThu4xZsOQLRJb6gWy6/Ia6rExF2dd0JsCOukt3TTvk3/qL/RIdvQ1AqKMQvlC65hxW9AjboC8nFpgEQKBgQC6izerAMaVDNaeWWJz6FioWrFtEDLg8HZNf76ydoYlB3867dK1IXGImItLsLAeH2oPs0WnDO4vBXRDHeyaYlYaeQWHrF/bK6nshs4Bbp7T1PL/S84glm5vFfW8RwWiKclFDaHj5xicN3sPJDyhebeiqRNefpWXhQWD9wiU2R0HCwKBgQC1okIEi+FKeWz2GZ0FMSt7A962yNQBx8DrDHOS62vo5U6YcbT2gepzjySToppkavyV08qJ3diQW3M4sBZAd/83TixogwiohMxtqxK4EKl/NzeWs/OxJB/5MHavlhthCpZ6jPJUXsz2xRqdSSsYVZ6QXXeWCXkfuKLaXHR9ChK8CwKBgCYdsic3xlvIPsYmP26tiAgGWACP8cVyfMnDE2UFwM0qJf4VgBtQlREzEitKFAJjqtlAaTgD9VsYQzQ/lgvJkgxgtBePyhpPZq4UsV0rjDp+ZZRymdCgzDnYg9iPrn//B8gbS/v0SVwKHhPu9JCN/U64O2Pwe4J1RLY9MLyxTDQXAoGAbtYs4wlY2VFvpF3M67Ytiku6RGAYv11d5BEdFbKDjwMfCveYLjTpFMtszoqTHGQM7oDnP2oZFT44+Ya6jWysWNtjTgNn7S3cca/LJHdGd1MCoPv+4UHiIPXp9wvqeTU0zmPkHIgdGxj8PK7BlX/p2r6ukugE+c550jZI/2R+OjECgYEAktRz2ujFsF+HVdRyT/0QRIEW9RSEzTO2oEjXQXA0XOqvKB56A4Bx27W/Bvpl4FUPEDUl+n0xZvA9rWYvkz8aIQPU7Lp8BMBu6y2MYKaljKkXhyNOZVfJdHClRjLjIIZGMqqyfQgdQwv+IewolWwEYCgJEzd0J7m2lCImnatMjMo=";
String publicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4Dlipw4sxS6I9xMbUAiPSQkfD+8JkGAdLQo5+7MpjYAHPBGakMNfOOZgFO6PDeMvnJtRhSrw0fIRK+S382Xx3kg9TXa2NW6J4tJ+limKEv4HKEH3a0ocNdVtjmyl5CoPlhuZVtktuan+3DVMLdHDXABOyRad447DWJkExpKqu79lAcvySzzgRwXPgDnvbOGrAiPIMJ0esp+aw9gGraais+EcYnptMTvbwlFiADcgPEyVf7htIVdxyZtBLiZl1ltYX9W69Fk6prP7/wYccy4uOyu2uhHS0AmMQrbXZg4EmpAUoY7ckUOqplP0+/nJlJLB1jMxkXWzDqnCanU9pEL3sQIDAQAB";
//实例化客户端 参数正式环境URL,Appid,商户私钥 PKCS8格式,字符编码格式,字符格式,支付宝公钥,签名方式
AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do","2021003101623191",privateKey,"json","GBK",publicKey,"RSA2");
AlipaySystemOauthTokenRequest request = new AlipaySystemOauthTokenRequest();
// 值为authorization_code时代表用code换取
request.setGrantType("authorization_code");
//授权码,用户对应用授权后得到的
request.setCode(authCode);
AlipaySystemOauthTokenResponse response = null;
try {
response = alipayClient.execute(request);
//刷新令牌上次换取访问令牌时得到。见出参的refresh_token字段
request.setRefreshToken(response.getAccessToken());
//返回成功时 就将唯一标识返回
if(response.isSuccess()){
return ResultGenerator.genSuccessResult("获取成功",response.getUserId());
} else {
return ResultGenerator.genFailResult("授权失败");
}
} catch (AlipayApiException e) {
e.printStackTrace();
}
return ResultGenerator.genFailResult("授权失败");
}
@PostMapping("/orderPay")
@ResponseBody
public Result<Object> orderPay(String authCode,String orderNumber) {
if(StringUtil.isEmpty(authCode)){
return ResultGenerator.genFailResult("授权码信息为空");
}
if(StringUtil.isEmpty(orderNumber)){
return ResultGenerator.genFailResult("订单号为空");
}
AlipaySystemOauthTokenResponse tokenResponse = AliUtil.getAliUserIdV2(authCode, ParametersUtil.ZY_PRI, ParametersUtil.ZY_PUB, ParametersUtil.ZY_ALI_APP_ID);
return apiPayService.orderPay(tokenResponse.getUserId(),orderNumber);
}
public static void main(String[] args) {
String openid = "o_q_P5bPxk3JvvfGEHrDcDYxbl3o";
JSONObject result = new JSONObject(10);
result.put("merchantCode","M800202107223018811");
result.put("method","trans_wap_pay");
result.put("subject","测试123");
result.put("ip","127.0.0.1");
result.put("payWay","ZFBZF");
result.put("paySource","01");
result.put("mercOrderNo",StringUtil.getBillno());
result.put("payAmt","0.20");
result.put("notifyUrl","https://www.baici.com");
// String str = SignUtils.getSignContent(result) +"&key=efaa811e9f004429b5dc070c410405c8";
String str = SignUtils.getSignContent(result) +"&key=4c8d277b0f274604af68e590cc0b3e6b";
String ckeckSign = MD5Util.MD5Encode(str, "UTF-8");
result.put("sign",ckeckSign);
System.out.println("支付参数:"+result.toJSONString());
}
}

View File

@@ -0,0 +1,94 @@
package cn.pluss.platform.controller.home;
import cn.pluss.platform.ali.device.AliDeviceService;
import cn.pluss.platform.alidevice.AliScanCodeDevicePayEntity;
import cn.pluss.platform.alidevice.AliScanCodeDevicePayEnum;
import cn.pluss.platform.alidevice.RespDeviceEntity;
import lombok.Setter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
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;
/**
*
*阿里云设备管理类
*@author: bzg
*@time: 2021/12/22 11:26
*/
@RestController
@RequestMapping(value = "aliyun/device")
public class AliYunDeviceController {
@Setter(onMethod_ = {@Autowired, @Qualifier("aliScanCodeDeviceService")})
private AliDeviceService aliScanCodeDeviceService;
/**
* 反扫阿里云扫码王设备支付接口
* @date: 2021/12/27 11:35
* @param payEntity:
* @return cn.pluss.platform.alidevice.RespDeviceEntity
*/
@RequestMapping(value = "/pay/barcode",method = RequestMethod.POST)
public RespDeviceEntity payBarCode(@RequestBody AliScanCodeDevicePayEntity payEntity){
return aliScanCodeDeviceService.orderPay(payEntity, AliScanCodeDevicePayEnum.BARCODE.getCode());
}
/**
* 主扫阿里云扫码王设备支付接口
* @date: 2021/12/27 11:36
* @param payEntity:
* @return cn.pluss.platform.alidevice.RespDeviceEntity
*/
@RequestMapping(value = "/pay/qrcode",method = RequestMethod.POST)
public RespDeviceEntity payQrCode(@RequestBody AliScanCodeDevicePayEntity payEntity){
return aliScanCodeDeviceService.orderPay(payEntity, AliScanCodeDevicePayEnum.QRCODE.getCode());
}
/**
* 阿里云设备扫码王订单查询接口
* @date: 2021/12/27 11:36
* @param payEntity:
* @return cn.pluss.platform.alidevice.RespDeviceEntity
*/
@RequestMapping(value = "/order/query",method = RequestMethod.POST)
public RespDeviceEntity orderQuery(@RequestBody AliScanCodeDevicePayEntity payEntity){
return aliScanCodeDeviceService.orderQuery(payEntity.getTrace());
}
/**
* 获取阿里云云设备状态接口V1
* @date: 2021/12/27 11:37
* @return java.lang.Integer
*/
@RequestMapping(value = "/status/v1",method = RequestMethod.POST)
public RespDeviceEntity getStatusV1(@RequestBody AliScanCodeDevicePayEntity payEntity){
return aliScanCodeDeviceService.getDeviceStatusV1(payEntity.getCode());
}
/**
* 获取阿里云扫码王设备状态接口V2
* @date: 2021/12/27 11:37
* @param payEntity:
* @return cn.pluss.platform.alidevice.AliScanCodeDeviceStatus
*/
@RequestMapping(value = "/status/v2",method = RequestMethod.POST)
public RespDeviceEntity getStatusV2(@RequestBody AliScanCodeDevicePayEntity payEntity){
return aliScanCodeDeviceService.getDeviceStatusV2(payEntity.getCode());
}
// /**
// * 设备绑定接口 测试
// * @date: 2021/12/27 14:45
// * @param deviceNo:
// * @return cn.pluss.platform.alidevice.RespDeviceEntity
// */
// @RequestMapping(value = "/bind/{deviceNo}",method = RequestMethod.POST)
// @ResponseBody
// public Result<Object> payBarCode(@PathVariable("deviceNo") String deviceNo){
// return aliScanCodeDeviceService.bindDevice(deviceNo,"1791");
// }
}

View File

@@ -0,0 +1,33 @@
package cn.pluss.platform.controller.home;
import cn.pluss.platform.api.ApiMercSplitService;
import cn.pluss.platform.api.SplitReq;
import cn.pluss.platform.api.Result;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
* TODO
* 接口商户分账设置控制器
* @author crystal
* @date 2022/6/29 14:07
*/
@RestController
@RequestMapping(value = "/api")
public class ApiMercSplitController {
@Resource
private ApiMercSplitService apiMercSplitService;
/**
* 商户分账
* @return
*/
@RequestMapping(value = "/split")
public Result<Object> splitOperat(@RequestBody SplitReq req){
return apiMercSplitService.splitOperat(req);
}
}

View File

@@ -0,0 +1,229 @@
package cn.pluss.platform.controller.home;
import cn.pluss.platform.api.Result;
import cn.pluss.platform.api.ResultGenerator;
import cn.pluss.platform.appletInfo.AppletInfoService;
import cn.pluss.platform.entity.*;
import cn.pluss.platform.enums.SubAppLetInfo;
import cn.pluss.platform.exception.MsgException;
import cn.pluss.platform.merchant.MerchantBaseInfoService;
import cn.pluss.platform.merchantOrder.MerchantOrderService;
import cn.pluss.platform.merchantStore.MerchantStoreService;
import cn.pluss.platform.notify.NotifyMessageService;
import cn.pluss.platform.pay.ApiPayService;
import cn.pluss.platform.util.*;
import cn.pluss.platform.wechat.WxConstants;
import cn.pluss.platform.wx.WxAccessTokenRequest;
import cn.pluss.platform.wx.WxCommonService;
import cn.pluss.platform.wx.WxOpenidResponse;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
/**
* 下游上送订单接口类
*/
@Controller
@RequestMapping(value = "/api")
public class ApiPayController {
/**
* 日志打印 log
*/
private Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
private MerchantOrderService merchantOrderService;
@Autowired
private NotifyMessageService notifyMessageService;
@Autowired
private ApiPayService apiPayService;
@Autowired
private MerchantStoreService merchantStoreService;
@Autowired
private MerchantBaseInfoService merchantBaseInfoService;
@Autowired
private WxCommonService wxCommonService;
@Autowired
private AppletInfoService appletInfoService;
@RequestMapping(value = "/trans/pay",method = RequestMethod.POST)
@ResponseBody
public JSONObject apiPay(@RequestBody String json, HttpServletRequest request){
logger.info("============>交易接口下单,请求交易数据:{}<============",json);
try {
String ip = IpUtils.getIpAddr(request);
return apiPayService.pay(json,ip);
}catch (Exception e){
return ResultGenerator.genFailJsonResult(e.getMessage());
}
}
/**
* 小程序退款接口
* @param params
* @return
*/
@RequestMapping(value = "/trans/refund",method = RequestMethod.POST)
@ResponseBody
public Result<JSONObject> refund(@RequestBody JSONObject params){
return apiPayService.refund(params);
}
/**
* api退款接口
* @param params
* @return
*/
@RequestMapping(value = "/trans/refund.do",method = RequestMethod.POST)
@ResponseBody
public Result<JSONObject> apiRefund(@RequestBody JSONObject params){
return apiPayService.apiRefund(params);
}
/**
* 小程序订单查询
* @param params
* @return
*/
@RequestMapping(value = "/refund/query",method = RequestMethod.POST)
@ResponseBody
public Result<Object> refundQuery(@RequestBody JSONObject params){
return apiPayService.refundQuery(params);
}
/**
* 小程序取消支付
* @param params
* @return
*/
@RequestMapping(value = "/mqtt/pay/cancel",method = RequestMethod.POST)
@ResponseBody
public Result<JSONObject> cancel(@RequestBody JSONObject params){
String storeId = Optional.ofNullable(params.getString("storeId")).orElseThrow(() -> new MsgException("店铺ID不能为空"));
String money = params.getString("money");
MerchantStore store = merchantStoreService.queryMerchantStore(new MerchantStore().setId(Integer.valueOf(storeId)));
if(store != null){
QueryWrapper<MerchantBaseInfo> queryWrapper = new QueryWrapper<MerchantBaseInfo>().eq("merchantCode",store.getMerchantCode());
List<MerchantBaseInfo> list = merchantBaseInfoService.list(queryWrapper);
if(!list.isEmpty()){
params.put("mercId",list.get(0).getId());
params.put("money",money);
params.put("userId",list.get(0).getUserId());
notifyMessageService.sendCancelPayMessage(params);
return ResultGenerator.genSuccessResult("推送成功!",null);
}
}
return ResultGenerator.genFailResult("推送失败!",null);
}
/**
* @description:小程序获取openid
* @date: 2021/10/13 13:46
* @param params:
* @return cn.pluss.platform.api.Result<com.alibaba.fastjson.JSONObject>
*/
@RequestMapping(value = "/wxapp/getOpenId",method = RequestMethod.POST)
@ResponseBody
public Result<Object> getOpenId(@RequestBody JSONObject params){
String code = params.getString("code");
if(StringUtil.isEmpty(code)){
return ResultGenerator.genFailResult("缺失参数!");
}
String appid = StringUtil.isNotEmpty(params.getString("appid")) ? params.getString("appid") : SubAppLetInfo.SYB.getAppid();
AppletInfo applet = appletInfoService.getAppletInfoByAppId(appid);
MsgException.checkNull(applet,"小程序配置信息异常!");
String appSecret = applet.getSecret();
try {
WxAccessTokenRequest request = WxAccessTokenRequest.buidWxToken(appid,appSecret,code, WxConstants.WX_APPLET_OPENID_URL);
WxOpenidResponse wxOpenId = wxCommonService.getWxOpenId(request);
return ResultGenerator.genSuccessResult("获取成功!",wxOpenId);
}catch (Exception e){
return ResultGenerator.genFailResult(e.getMessage());
}
}
/**
* @description:小程序获取订单
* @date: 2021/10/13 13:46
* @param params:
* @return cn.pluss.platform.api.Result<com.alibaba.fastjson.JSONObject>
*/
@RequestMapping(value = "/wxapp/getOrder",method = RequestMethod.POST)
@ResponseBody
public Result<Object> getOrder(@RequestBody JSONObject params){
String openid = params.getString("openid");
if(StringUtil.isEmpty(openid)){
return ResultGenerator.genFailResult("缺失参数!");
}
QueryWrapper<MerchantOrder> queryWrapper = new QueryWrapper<MerchantOrder>()
.eq("mercUserId",openid).eq("status","1");
List<MerchantOrder> list = merchantOrderService.list(queryWrapper);
return ResultGenerator.genSuccessResult("获取成功",list);
}
/**
*内部微信小程序支付
* @date: 2021/12/24 13:32
* @param params:
* @return cn.pluss.platform.api.Result<java.lang.Object>
*/
@RequestMapping(value = "/wxapp/pay",method = RequestMethod.POST)
@ResponseBody
public JSONObject wxappPay(@RequestBody JSONObject params){
try {
return apiPayService.wxappPay(params);
}catch (Exception e){
return ResultGenerator.genFailJsonResult(e.getMessage());
}
}
@PostMapping("/applet/orderPay")
@ResponseBody
public Result<Object> orderPay(@RequestBody JSONObject params) {
String userId = params.getString("userId");
String orderNumber = params.getString("orderNumber");
return apiPayService.orderPay(userId,orderNumber);
}
public static void main(String[] args) {
// String openid = "oPhYX5BsUDxDgGOQ8GNLhanMR3f8";
String key = "5d7d4c33067b4489bcca25f034f46551";
String merchantCode = "M800202206280ff7f1";
String method = "trans_pay";
String notifyUrl = "https://www.shouyinbei.net/wap/notify/sxfCallBack";
// String returnUrl = "https://www.baidu.com";
String mercOrderNo = StringUtil.generateMixStr(3).toUpperCase(Locale.ROOT) + StringUtil.getBillno();
JSONObject params = new JSONObject(10);
params.put("merchantCode",merchantCode);
params.put("method",method);
params.put("mercOrderNo",mercOrderNo);
params.put("payAmt","0.20");
params.put("notifyUrl",notifyUrl);
params.put("payWay","WXZF");
params.put("payType","02");
params.put("subject","测试订单");
// params.put("userId",openid);
String signContent = SignUtils.getSignContent(params) + "&key="+key;
String sign = MD5Util.MD5Encode(signContent, "UTF-8");
params.put("sign",sign);
System.out.println("param==>" + params.toJSONString());
}
}

View File

@@ -0,0 +1,27 @@
package cn.pluss.platform.controller.home;
import cn.pluss.platform.util.ParametersUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* 因客户端错误的代码,添加的额外接口,临时使用
*/
@Controller
public class ExtraController {
/**
* @TODO 下个版本安卓修改后,该接口需要删除
*/
@GetMapping(value = "/wap/merchant/toUpGradeAuth")
public void toUpGradeAuth(String userId, HttpServletResponse response) {
String domain_wap = ParametersUtil.domain + "/wap";
try {
response.sendRedirect(domain_wap + "/merchant/toUpGradeAuth?userAppId=" + userId);
} catch (IOException e) {
}
}
}

View File

@@ -0,0 +1,63 @@
package cn.pluss.platform.controller.home;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import cn.pluss.platform.entity.SystemConfig;
import cn.pluss.platform.systemConfig.SystemConfigService;
@Controller
@RequestMapping("platform")
public class HomeController {
@Autowired
private SystemConfigService systemConfigService;
@RequestMapping(value = "/console", method = RequestMethod.GET)
public String index(HttpServletRequest request) {
List<SystemConfig> systemConfigList=systemConfigService.querySystemConfigList(null);
request.setAttribute("systemConfigList", systemConfigList);
return "index/index";
}
@RequestMapping(value = "/first", method = RequestMethod.GET)
public String first() {
System.out.println(111);
return "index/first";
}
@RequestMapping(value = "/logout", method = RequestMethod.POST)
@ResponseBody
public Map<String,Object> login() {
Map<String,Object> result=new HashMap<String,Object>();
result.put("result", 2);
// 从SecurityUtils里边创建一个 subject
Subject subject = SecurityUtils.getSubject();
// 执行认证登陆
try {
subject.logout();
result.put("result", 1);
result.put("url", "/login");
} catch (Exception uae) {
}
return result;
}
}

View File

@@ -0,0 +1,70 @@
package cn.pluss.platform.controller.home;
import cn.pluss.platform.api.Result;
import cn.pluss.platform.jfShop.JfShopHandler;
import cn.pluss.platform.other.JfShopParam;
import cn.pluss.platform.other.JfShopAccount;
import cn.pluss.platform.other.JfShopValidTask;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
* TODO
*
* @author crystal
* @date 2022/5/16 14:43
*/
@Slf4j
@RestController
@RequestMapping("/api/jf/shop")
public class JfShopController {
@Resource
private JfShopHandler jfShopHandler;
/**
* 新版积分商城积分数量获取接口
* @param param
* @return
*/
@RequestMapping("/get/account")
public Result<JfShopAccount> getAccount(@RequestBody JfShopParam param){
return jfShopHandler.getAccount(param);
}
/**
* 获取积分详情
* @param param
* @return
*/
@RequestMapping("/integral/page")
public Object page(@RequestBody JfShopParam param){
return jfShopHandler.page(param);
}
/**
* 积分商城新增接口
* @param param
* @return
*/
@PostMapping("/integral/operate")
public Result<Object> operate(@RequestBody JfShopParam param){
return jfShopHandler.operate(param);
}
/**
*
* 获取积分商城任务完成进度
* @param param
* @return
*/
@PostMapping("/task/status")
public Result<Object> getTaskStatus(@RequestBody JfShopValidTask param){
return jfShopHandler.getTaskStatus(param);
}
}

View File

@@ -0,0 +1,85 @@
package cn.pluss.platform.controller.home;
import cn.pluss.platform.api.Result;
import cn.pluss.platform.dto.jft.JftPayDataDTO;
import cn.pluss.platform.entity.JftReceiptInfo;
import cn.pluss.platform.entity.JftReceiptOrder;
import cn.pluss.platform.jft.JftReceiptInfoService;
import cn.pluss.platform.jft.JftReceiptOrderService;
import cn.pluss.platform.util.DateUtils;
import lombok.extern.slf4j.Slf4j;
import mob.push.api.http.Http;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
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.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* TODO
* 缴费通入口
* @author crystal
* @date 2022/6/22 17:28
*/
@Controller
@RequestMapping(value = "jft")
public class JftController {
@Resource
private JftReceiptInfoService jftReceiptInfoService;
@Resource
private JftReceiptOrderService jftReceiptOrderService;
@RequestMapping(value = "/auth")
public ModelAndView auth(HttpServletRequest request, HttpServletResponse response, String tk){
try {
JftReceiptInfo receiptInfo = jftReceiptInfoService.wapCheckTk(tk,request);
response.sendRedirect(receiptInfo.getJumpUrl());
return null;
}catch (Exception e){
ModelAndView view = new ModelAndView("merchant/errorInfo");
request.setAttribute("error",e.getMessage());
return view;
}
}
@RequestMapping(value = "/pay")
public String pay(HttpServletRequest request,HttpServletResponse response,String tk,String auth_code,String userId){
try {
jftReceiptInfoService.getPayInfo(request,response,tk,auth_code,userId);
return "jft/th_jft_pay";
}catch (Exception e){
request.setAttribute("error",e.getMessage());
return "merchant/errorInfo2";
}
}
@RequestMapping(value = "/jump")
public String pay(HttpServletRequest request,String orderNumber){
JftReceiptOrder orderInfo = jftReceiptOrderService.getOrderByNo(orderNumber);
JftReceiptInfo receiptInfo = jftReceiptInfoService.getById(orderInfo.getRid());
request.setAttribute("merchantName",orderInfo.getMerchantName());
request.setAttribute("payTypeDesc",orderInfo.getPayTypeDesc());
request.setAttribute("amount",orderInfo.getAmount());
request.setAttribute("pName",receiptInfo.getProjectName());
request.setAttribute("orderNumber",orderInfo.getOrderNumber());
request.setAttribute("date", DateUtils.toString(orderInfo.getCreateTime(),"yyyy-MM-dd HH:mm:ss"));
return "jft/th_jft_success";
}
/**
* 发起支付
* @param dto
* @return
*/
@RequestMapping(value = "/tradePay")
@ResponseBody
public Result<Object> tradePay(JftPayDataDTO dto,HttpServletRequest request){
return jftReceiptOrderService.tradePay(dto,request);
}
}

View File

@@ -0,0 +1,56 @@
package cn.pluss.platform.controller.home;
import cn.pluss.platform.constants.Constant;
import com.google.code.kaptcha.impl.DefaultKaptcha;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.apache.tomcat.util.http.fileupload.IOUtils;
import javax.imageio.ImageIO;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.awt.image.BufferedImage;
import java.io.IOException;
/**
*
*获取图形验证码
*@author: bzg
*@time: 2021/12/20 11:30
*/
@RestController
@RequestMapping(value = "kaptcha")
public class KaptchaController {
@Autowired
private DefaultKaptcha defaultKaptcha;
@GetMapping("/get")
public void getKaptcha(HttpServletRequest request, HttpServletResponse response) throws IOException {
//设置响应头
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Pragma", "no-cache");
response.setContentType("image/jpeg");
String text = defaultKaptcha.createText();
HttpSession session = request.getSession();
//将验证码存入session
session.setAttribute(Constant.LOGIN_VALIDATE_CODE, text);
//创建验证码图片
BufferedImage image = defaultKaptcha.createImage(text);
ServletOutputStream os = response.getOutputStream();
ImageIO.write(image, "jpg", os);
ServletOutputStream out = response.getOutputStream();
// write the data out
ImageIO.write(image, "jpg", out);
try {
out.flush();
} finally {
out.close();
}
}
}

View File

@@ -0,0 +1,59 @@
package cn.pluss.platform.controller.home;
import cn.pluss.platform.api.Result;
import cn.pluss.platform.api.ResultGenerator;
import cn.pluss.platform.entity.MerchantMemberCode;
import cn.pluss.platform.life.LifeApiHandler;
import cn.pluss.platform.life.LifeParam;
import cn.pluss.platform.systemConfig.SystemConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.sql.ResultSet;
/**
* TODO
* 生活圈apiController
* @author crystal
* @date 2022/6/7 15:00
*/
@Slf4j
@RestController
@RequestMapping(value = "life")
public class LifeApiController {
@Resource
private LifeApiHandler lifeApiHandler;
/**
* 生活圈获取会员卡过期时间
* @return
*/
@RequestMapping(value = "/card/expire")
public Result<Object> getCardExpire(){
String value = lifeApiHandler.getCardExpire();
return ResultGenerator.genSuccessResult("获取成功",value);
}
/**
* 会员卡刷新code
* @param code
* @return
*/
@RequestMapping(value = "/card/refresh")
public Result<Object> refreshCardCode(MerchantMemberCode code){
return lifeApiHandler.refreshCardCode(code);
}
/**
* 获取商户信息
* @return
*/
@RequestMapping(value = "/merchant/info")
public Result<Object> getMerchantInfo(LifeParam param){
return lifeApiHandler.getMerchantInfo(param);
}
}

View File

@@ -0,0 +1,54 @@
package cn.pluss.platform.controller.home;
import java.util.HashMap;
import java.util.Map;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Controller;
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;
@Controller
@RequestMapping("login")
public class LoginController {
/**
* 引导页
*
* @return
*/
@RequestMapping(value = "", method = RequestMethod.GET)
public String index() {
return "index/login";
}
@RequestMapping(value = "/doLogin", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> login(@RequestParam("loginName") String username, @RequestParam("password") String password) {
Map<String, Object> result = new HashMap<String, Object>();
result.put("result", 2);
// 从SecurityUtils里边创建一个 subject
Subject subject = SecurityUtils.getSubject();
// 在认证提交前准备 token令牌
UsernamePasswordToken token = new UsernamePasswordToken(username, password);
// 执行认证登陆
try {
subject.login(token);
result.put("result", 1);
result.put("redirectUri", "/platform/console");
} catch (Exception uae) {
result.put("message", "用户名或者密码错误");
}
return result;
}
}

View File

@@ -0,0 +1,116 @@
package cn.pluss.platform.controller.home;
import cn.pluss.platform.api.Result;
import cn.pluss.platform.deviceStock.DeviceStockService;
import cn.pluss.platform.entity.DeviceStock;
import cn.pluss.platform.entity.OfficialGoods;
import cn.pluss.platform.entity.UserApp;
import cn.pluss.platform.exception.MsgException;
import cn.pluss.platform.officialGoods.exchange.OfficialGoodsExchangeService;
import cn.pluss.platform.userApp.UserAppService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
/**
* @author SSS
*/
@Controller
@RequestMapping("/merchantDevice")
public class MerchantDeviceController {
@Autowired
private UserAppService uaService;
@Autowired
private OfficialGoodsExchangeService officialGoodsExchangeService;
@Autowired
private DeviceStockService dsService;
/**
* 流量卡充值开始页面
*
* @return
*/
@GetMapping("/simChargeIndex")
public String simChargeIndex(HttpServletRequest request, String token) {
try {
request.setAttribute("token", token);
return "device/simChargeIndex";
} catch (Exception e) {
e.printStackTrace();
request.setAttribute("error", "拒绝访问!");
return "merchant/errorInfo2";
}
}
@GetMapping("/simOrder")
public String simOrder(HttpServletRequest request, String token, String snNo) {
try {
LambdaQueryWrapper<DeviceStock> qWrapper = Wrappers.lambdaQuery();
qWrapper.eq(DeviceStock::getDeviceNo, snNo).or().eq(DeviceStock::getSnNo, snNo);
DeviceStock one = dsService.getOne(qWrapper.last("limit 1"));
if (one == null) {
throw new MsgException("设备编号不存在");
}
if (!one.getCode().contains("4G")) {
throw new MsgException("该设备编码不需要通信服务费");
}
if (!"3".equals(one.getStatus())) {
throw new MsgException("该设备暂未绑定商户");
}
request.setAttribute("token", token);
request.setAttribute("snNo", snNo);
request.setAttribute("device", one);
return "device/order";
} catch (Exception e) {
e.printStackTrace();
request.setAttribute("error", e.getMessage());
return "merchant/errorInfo2";
}
}
@PostMapping("/simOrder")
@ResponseBody
public Result<Object> createSimChargeOrder(HttpServletRequest request, OfficialGoods goods, String token) {
LambdaQueryWrapper<DeviceStock> qWrapper = Wrappers.lambdaQuery();
qWrapper.eq(DeviceStock::getDeviceNo, goods.getAddress()).or().eq(DeviceStock::getSnNo, goods.getAddress());
DeviceStock one = dsService.getOne(qWrapper.last("limit 1"));
if (one == null) {
throw new MsgException("设备编号不存在");
}
if (!one.getCode().contains("4G")) {
throw new MsgException("该设备编码不需要通信服务费");
}
if (!"3".equals(one.getStatus())) {
throw new MsgException("该设备暂未绑定商户");
}
UserApp own = new UserApp();
own.setUserId(1791L);
own = uaService.getOne(new QueryWrapper<>(own));
goods.setId(10086);
goods.setIsPostage(1);
goods.setPostageFee(BigDecimal.ZERO);
goods.setDeductValue(BigDecimal.TEN);
goods.setGoodPrice(BigDecimal.TEN);
goods.setDeductRule(1);
return officialGoodsExchangeService.exchange(goods, own);
}
}

View File

@@ -0,0 +1,61 @@
package cn.pluss.platform.controller.home;
import cn.pluss.platform.pay.PayService;
import cn.pluss.platform.ryx.pay.RyxPayService;
import cn.pluss.platform.sxf.pay.SxfPayService;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.*;
/**
* 统一接收支付成功异步地址
*/
@RestController
@Slf4j
@RequiredArgsConstructor
@RequestMapping("/notify")
public class PayNotifyController {
@Setter(onMethod_ = {@Autowired, @Qualifier("ysPayOldService")})
private PayService ysPayOldService;
@Setter(onMethod_ = {@Autowired, @Qualifier("ysPayService")})
private PayService ysPayService;
@Setter(onMethod_ = {@Autowired, @Lazy})
private SxfPayService sxfPayService;
@Setter(onMethod_ = {@Autowired, @Lazy})
private RyxPayService ryxPayService;
@RequestMapping(value = "/sxfCallBack",method = RequestMethod.POST)
public Map<String,String> sxfCallBack(@RequestBody Map<String, String> map) {
log.info("【随行付】异步回调开始,【随行付】回调参数:{}<=====================",JSONObject.toJSONString(map));
return (Map<String, String>) sxfPayService.payNotifyCallBack(map);
}
@RequestMapping(value = "/old/ysCallBack",method = RequestMethod.POST)
public String oldYsCallBack(@RequestParam Map<String,String> params) {
log.info("【银盛】旧版接口异步回调开始,【银盛】回调参数:{}<=====================",JSONObject.toJSONString(params));
return (String) ysPayOldService.payNotifyCallBack(params);
}
@RequestMapping(value = "/ysCallBack",method = RequestMethod.POST)
public String ysCallBack(@RequestParam Map<String,String> params) {
log.info("【银盛】新版异步回调开始,【银盛】回调参数:{}<=====================",JSONObject.toJSONString(params));
return (String) ysPayService.payNotifyCallBack(params);
}
@RequestMapping(value = "/ryxCallBack",method = RequestMethod.POST)
public String ryxCallBack(@RequestParam Map<String,String> params) {
log.info("【瑞银信】异步回调开始,【瑞银信】回调参数:{}<=====================",JSONObject.toJSONString(params));
return (String) ryxPayService.payNotifyCallBack(params);
}
}

View File

@@ -0,0 +1,89 @@
package cn.pluss.platform.controller.home;
import cn.pluss.platform.api.Result;
import cn.pluss.platform.api.ResultGenerator;
import cn.pluss.platform.entity.UserApp;
import cn.pluss.platform.enums.UserRoleEnum;
import cn.pluss.platform.userApp.UserAppService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;
/**
*
*用户相关controller
*@author: bzg
*@time: 2022/2/16 10:14
*/
@Controller
@RequestMapping(value = "/user")
public class UserController {
@Resource
private UserAppService userAppService;
private final String ERROR_PATH = "merchant/errorInfo";
private final String ERROR_NAME = "error";
@GetMapping(value = "/agent/children")
public ModelAndView bstAgentChildrenList(ModelAndView view,String token,HttpServletRequest request){
view.setViewName(ERROR_PATH);
try {
userAppService.checkWapToken(token,request,UserRoleEnum.ZY_BST);
view.setViewName("user/th_agent_list");
view.addObject("token",token);
return view;
}catch (Exception e){
view.addObject(ERROR_NAME,e.getMessage());
return view;
}
}
@GetMapping(value = "/agent/open")
public ModelAndView bstOpenAgent(ModelAndView view,String token,HttpServletRequest request){
view.setViewName(ERROR_PATH);
try {
UserApp userApp = userAppService.checkWapToken(token,request,UserRoleEnum.ZY_BST);
view.setViewName("user/th_agent");
view.addObject("uid",userApp.getUserId());
view.addObject("token",token);
return view;
}catch (Exception e){
view.addObject(ERROR_NAME,e.getMessage());
return view;
}
}
@PostMapping(value = "/agent/save")
@ResponseBody
public Result<Object> bstSaveAgent(@RequestParam Map<String,Object> params){
try {
userAppService.bstSaveAgent(params);
return ResultGenerator.genSuccessResult("注册成功");
}catch (Exception e){
return ResultGenerator.genFailResult(e.getMessage(),null);
}
}
@PostMapping(value = "/agent/page")
@ResponseBody
public Result<Object> page(Page<UserApp> page,
String token, HttpServletRequest request){
try {
UserApp userApp = userAppService.checkWapToken(token,request,UserRoleEnum.ZY_BST);
QueryWrapper<UserApp> queryWrapper = new QueryWrapper<UserApp>().eq("parentId",userApp.getUserId())
.eq("userType","agent");
page = userAppService.page(page, queryWrapper);
return ResultGenerator.genSuccessResult("获取成功",page);
}catch (Exception e){
return ResultGenerator.genFailResult(e.getMessage());
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,506 @@
package cn.pluss.platform.controller.home;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import cn.pluss.platform.api.Result;
import cn.pluss.platform.api.ResultGenerator;
import cn.pluss.platform.constants.Constant;
import cn.pluss.platform.entity.*;
import cn.pluss.platform.exception.MsgException;
import cn.pluss.platform.merchantStore.MerchantStoreService;
import cn.pluss.platform.pay.ApiPayService;
import cn.pluss.platform.systemConfig.SystemConfigService;
import cn.pluss.platform.util.*;
import cn.pluss.platform.wap.MD5Util;
import cn.pluss.platform.wechat.WxConstants;
import cn.pluss.platform.wx.*;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.servlet.ModelAndView;
import cn.pluss.platform.deviceMerchantBuy.DeviceMerchantBuyService;
import cn.pluss.platform.wap.XmlUtil;
import cn.pluss.platform.leshua.LeshuaService;
import cn.pluss.platform.merchantMenber.MerchantMenberService;
import cn.pluss.platform.userApp.UserAppService;
/**
* @author yuchen
*
* @Description
*/
@Controller
@Slf4j
@RequestMapping("wechat")
public class WechantController {
@Setter(onMethod_ = {@Autowired,@Lazy})
private UserAppService userAppService;
@Setter(onMethod_ = {@Autowired})
private WxPayNotifyService wxPayNotifyService;
@Setter(onMethod_ = {@Autowired})
private LeshuaService leshuaService;
@Setter(onMethod_ = {@Autowired})
private DeviceMerchantBuyService deviceMerchantBuyService;
@Setter(onMethod_ = {@Autowired})
private MerchantMenberService merchantMenberService;
@Setter(onMethod_ = {@Autowired})
private SystemConfigService systemConfigService;
@Setter(onMethod_ = {@Autowired})
private ApiPayService apiPayService;
@Setter(onMethod_ = {@Autowired})
private WxCommonService wxCommonService;
@Setter(onMethod_ = {@Autowired})
private MerchantStoreService merchantStoreService;
@Setter(onMethod_ = {@Autowired})
private RestTemplate restTemplate;
/**
*
* goUpgradePage:(跳转到升级页面). <br/>
*
*
* @author Administrator
* @param userId
* @return
* @since JDK 1.8
*/
@GetMapping(value = "/goUpgradePage")
public ModelAndView goUpgradePage(String userId) {
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("wechat/goUpgradePage");
setUpVipAmtResult(modelAndView,"twoUpVipAmount",2);
setUpVipAmtResult(modelAndView,"threeUpVipAmount",3);
modelAndView.addObject("userId", userId);
UserApp userApp=new UserApp();
userApp.setUserId(Long.valueOf(userId));
userApp=userAppService.queryUserApp(userApp);
if(null!=userApp) {
modelAndView.addObject("level", userApp.getLevel());
}
return modelAndView;
}
public void setUpVipAmtResult(ModelAndView modelAndView, String propertyKey,int level) {
String configValue = systemConfigService.querySystemConfigValue(propertyKey);
if(StringUtil.isNotEmpty(configValue)){
if(configValue.contains("-")){
modelAndView.addObject(propertyKey, configValue.split("-")[0]);
//modelAndView.addObject(shapeKey, propertyValue.split("-")[1]);
}
}else{
if(level == 2){
modelAndView.addObject(propertyKey, 999);
//modelAndView.addObject(shapeKey, 500);
}else{
modelAndView.addObject(propertyKey, 9999);
//modelAndView.addObject(shapeKey, 5000);
}
}
}
/**
*
* jumpUrl:(乐刷支付完成后的跳转地址). <br/>
*
*
* @author Administrator
* @param orderNumber
* @param
* @return
* @since JDK 1.8
*/
@GetMapping("/jumpUrl")
public ModelAndView jumpUrl(String orderNumber) {
log.info("====订单号====" + orderNumber);
if (orderNumber.contains("?")) {
String str[] = orderNumber.split("[?]");
orderNumber = str[0];
}
ModelAndView modelAndView = new ModelAndView();
Map<String, String> reqMap = new HashMap<String, String>(16);
Map<String, Object> mapLeshua = new HashMap<String, Object>(16);
try {
reqMap.put("service", "query_status");
reqMap.put("merchant_id", ParametersUtil.LESHUALIU);
reqMap.put("third_order_id", orderNumber);
reqMap.put("nonce_str", StringUtil.getBillno());
String requestPay = leshuaService.requestPay(reqMap, ParametersUtil.leshuapaykey, true);
mapLeshua = XmlUtil.toMapLeshua(requestPay);
String resp_code = (String) mapLeshua.get("resp_code");
if ("0".equals(resp_code)) {
String result_code = (String) mapLeshua.get("result_code");
if ("0".equals(result_code)) {
String status = (String) mapLeshua.get("status");
if ("2".equals(status)) {
modelAndView.setViewName("merchant/paySuccess");
} else {
modelAndView.setViewName("merchant/payFail");
}
} else {
modelAndView.addObject("message", "支付结果查询错误");
modelAndView.setViewName("merchant/error");
}
} else {
modelAndView.addObject("message", "支付结果查询错误");
modelAndView.setViewName("merchant/error");
}
} catch (Exception e) {
e.printStackTrace();
modelAndView.addObject("message", "支付结果查询错误");
modelAndView.setViewName("merchant/error");
}
return modelAndView;
}
// public static Set<String> resExcludedSignParams() {
// Set<String> exludedSignParams = new HashSet<String>(2);
// exludedSignParams.add("sign");
// exludedSignParams.add("error_code");
// return exludedSignParams;
// }
/**
*
* getMerchantInfo:(得到商户名称,门店名称). <br/>
*
*
* @author Administrator
* @param merchantCode
* @param storeId
* @return
* @since JDK 1.8
*/
// private MerchantStore getMerchantInfo(String merchantCode, String storeId) {
// // 因害怕表数据有误 分别根据merchantCode 查商家表 storeId查门店表
// MerchantStore merchantStore = new MerchantStore();
// merchantStore.setStoreId(storeId);
// MerchantBaseInfo merchantBaseInfo = new MerchantBaseInfo();
// merchantBaseInfo.setMerchantCode(merchantCode);
// List<MerchantBaseInfo> queryMerchantBaseInfoList = merchantBaseInfoService
// .queryMerchantBaseInfoList(merchantBaseInfo);
// if (queryMerchantBaseInfoList != null && queryMerchantBaseInfoList.size() > 0) {
// merchantBaseInfo = queryMerchantBaseInfoList.get(0);
// merchantStore.setMerchantCode(merchantCode);
// } else {
// merchantBaseInfo = null;
// merchantStore = null;
// return merchantStore;
// }
// List<MerchantStore> queryMerchantStoreList = merchantStoreService.queryMerchantStoreList(merchantStore);
// if (queryMerchantStoreList != null && queryMerchantStoreList.size() > 0) {
// merchantStore = queryMerchantStoreList.get(0);
// merchantStore.setMerchantName(merchantBaseInfo.getMerchantName());
// } else {
// merchantStore = null;
// }
// return merchantStore;
// }
/**
* 从request中获取请求方IP
*
* @param request
* @return
*/
public static String getIpAddress(HttpServletRequest request) {
String ip = request.getHeader("x-forwarded-for");
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("WL-Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_CLIENT_IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_X_FORWARDED_FOR");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
// 若以上方式均为获取到ip则证明获得客户端并没有采用反向代理直接使用getRemoteAddr()获取客户端的ip地址
ip = request.getRemoteAddr();
}
// 多个路由时取第一个非unknown的ip
final String[] arr = ip.split(",");
for (final String str : arr) {
if (!"unknown".equalsIgnoreCase(str)) {
ip = str;
break;
}
}
return ip;
}
/**
*
* wechatCallBack:(设备订单微信回调通知). <br/>
*
*
* @author Administrator
* @param request
* @param response
* @since JDK 1.8
*/
@PostMapping(value = "/wechatCallBack")
public void wechatCallBack(HttpServletRequest request, HttpServletResponse response) {
try {
InputStream is = request.getInputStream();
String xml = XmlUtil.toUTF8(is);
Map<String, Object> notifyMap = XmlUtil.toMap(xml);// 将微信发的xml转map
if ("SUCCESS".equals(notifyMap.get("result_code"))) {
String ordersSn = (String) notifyMap.get("out_trade_no");// 商户订单号
String transaction_id = (String) notifyMap.get("transaction_id");
// String amountpaid = (String) notifyMap.get("total_fee");// 实际支付的订单金额:单位 分
// String openid = (String) notifyMap.get("openid");// 用户openid
String time_end = (String) notifyMap.get("time_end");// 支付完成时间
// Double amount=Double.valueOf(amountpaid)*100;
DeviceMerchantBuy deviceMerchantBuy = new DeviceMerchantBuy();
deviceMerchantBuy.setOrderNo(ordersSn);
deviceMerchantBuy = deviceMerchantBuyService.queryDeviceMerchantBuy(deviceMerchantBuy);
if ("1".equals(deviceMerchantBuy.getStatus())) {
response.getWriter().write("<xml><return_code><![CDATA[SUCCESS]]></return_code></xml>");
return;
}
deviceMerchantBuy.setStatus("1");
deviceMerchantBuy.setTransNo(transaction_id);
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
deviceMerchantBuy.setTransDt(sdf.parse(time_end));
deviceMerchantBuyService.updateDeviceMerchantBuy(deviceMerchantBuy);
}
is.close();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
*
* wechatCallBack:(设备订单微信回调通知). <br/>
*
*
* @author Administrator
* @param request
* @param response
* @since JDK 1.8
*/
@PostMapping(value = "/wechatCallBackV2")
public void wechatCallBackV2(HttpServletRequest request, HttpServletResponse response) {
try {
InputStream is = request.getInputStream();
String xml = XmlUtil.toUTF8(is);
is.close();
// 将微信发的xml转map
assert xml != null : "无有效参数";
Map<String, Object> notifyMap = XmlUtil.toMap(xml);
wxPayNotifyService.commonPayNotify(notifyMap);
response.getWriter().write("<xml><return_code><![CDATA[SUCCESS]]></return_code></xml>");
} catch (Exception e) {
e.printStackTrace();
}
}
@RequestMapping("attentionCallBack")
public void wechatNotice(HttpServletRequest request, HttpServletResponse response) throws Exception {
String signature = request.getParameter("signature");
// 时间戳
String timestamp = request.getParameter("timestamp");
// 随机数
String nonce = request.getParameter("nonce");
// 随机字符串
String echostr = request.getParameter("echostr");
InputStream is = request.getInputStream();
// 处理微信请求
if (!StringUtil.isEmpty(echostr)) {
// 响应消息
PrintWriter out = response.getWriter();
out.print(echostr);
out.close();
// this.sendMessages(echostr);
response.setContentType("text/json; charset=utf-8");
response.setCharacterEncoding("UTF-8");
response.getWriter().print(echostr);
}
String xml = readRequestMsg(request);
Map<String, Object> map = XmlUtil.toMap(xml);
String MsgType = (String) map.get("MsgType");
//openId
String openId = (String) map.get("FromUserName");
WxAccessTokenRequest tokenRequest = WxAccessTokenRequest.buidWxToken(ParametersUtil.APPID,ParametersUtil.APPSECRET,null, WxConstants.WX_USER_INFO_URL);
log.info("【微信消息接收】解析消息内容为:{}", JSON.toJSONString(map));
if("event".equals(MsgType)) {
String eventKey = (String) map.get("EventKey");
if("VIEW".equals(map.get("Event"))){
request.getRequestDispatcher(eventKey).forward(request,response);
}else if("subscribe".equals(map.get("Event"))||"SCAN".equals(map.get("Event"))){
//关注公众号 消息回复
if("subscribe".equals(map.get("Event"))){
StringBuilder backMsgXml = new StringBuilder("<xml>");
backMsgXml.append("<ToUserName><![CDATA["+openId+"]]></ToUserName>");
backMsgXml.append("<FromUserName><![CDATA["+(String) map.get("ToUserName")+"]]></FromUserName>");
backMsgXml.append("<CreateTime>"+System.currentTimeMillis()+"</CreateTime>");
backMsgXml.append("<MsgType><![CDATA[text]]></MsgType>");
backMsgXml.append("<Content><![CDATA[你好,欢迎关注收银呗生活圈!]]></Content>");
backMsgXml.append("</xml>");
response.setContentType("text/xml; charset=utf-8");
response.setCharacterEncoding("UTF-8");
response.getWriter().write(backMsgXml.toString());
}
WxUserInfoResponse wxUserInfo = wxCommonService.getWxUserInfo(tokenRequest, openId);
if(StringUtil.isNotEmpty(eventKey)){
eventKey = eventKey.replace("qrscene_","");
String[] data = null;
if(eventKey.contains("_")){
data = eventKey.split("_");
}else if(eventKey.contains(",")){
data = eventKey.split(",");
}else{
MsgException.throwException("分隔符有误!");
}
//商户id
String merchantCode = data[0];
//门店id
String storeId = data[1];
//手机号
String phone = data[2];
MerchantMenber merchantMenber=new MerchantMenber();
merchantMenber.setPhone(phone);
merchantMenber.setStoreId(storeId);
merchantMenber.setMerchantCode(merchantCode);
List<MerchantMenber> queryMerchantMenberList = merchantMenberService.queryMerchantMenberList(merchantMenber);
if(queryMerchantMenberList!=null&&queryMerchantMenberList.size()>0) {
merchantMenber = queryMerchantMenberList.get(0);
if(StringUtil.isBlank(merchantMenber.getOpenid())){
merchantMenber.setOpenid(openId);
if(wxUserInfo != null){
wxUserInfo.buildMember(merchantMenber,null);
}
merchantMenberService.updateMerchantMenber(merchantMenber);
try {
MerchantStore store = merchantStoreService.getStoreByMerchantCode(merchantMenber.getMerchantCode());
JSONObject miniprogram = new JSONObject();
miniprogram.put("appid",ParametersUtil.APPLETS_APPID);
miniprogram.put("pagepath","pages/card/index?storeId="+store.getId()+"&phone="+merchantMenber.getPhone());
String first = "恭喜您成为本店会员,祝你生活愉快!";
String remark = "如对此卡有疑问或查询会员更多优惠信息,可以点此进入小程序中查看!";
double usableRechargeFee = merchantMenber.getUsableRechargeFee() == null ? 0 : StringUtil.bigDecimal(merchantMenber.getUsableRechargeFee());
double usableGiveFee = merchantMenber.getUsableGiveFee() == null ? 0 : StringUtil.bigDecimal(merchantMenber.getUsableGiveFee());
String useFee = BigDecimal.valueOf(usableRechargeFee + usableGiveFee).setScale(2,BigDecimal.ROUND_HALF_DOWN).toString();
String[] array = {store.getStoreName(),merchantMenber.getPhone(),store.getStoreName()+"会员卡",useFee+""};
WxTemolateRequest tempRequest = new WxTemolateRequest(openId,WxConstants.VIP_CARD_SUCCESS_TEMPLATE_ID,null,miniprogram)
.buildData(first,remark,array);
//发送开卡成功消息模板
wxCommonService.sendTemplateMsg(tempRequest,tokenRequest);
}catch (Exception e){
e.printStackTrace();
}
}
}
}else{
if(StringUtil.isNotEmpty(wxUserInfo.getUnionid())){
merchantMenberService.updateByUnionId(openId,wxUserInfo.getUnionid());
}
}
}
}else{
StringBuilder backMsgXml = new StringBuilder("<xml>");
backMsgXml.append("<ToUserName><![CDATA["+openId+"]]></ToUserName>");
backMsgXml.append("<FromUserName><![CDATA["+(String) map.get("ToUserName")+"]]></FromUserName>");
backMsgXml.append("<CreateTime>"+System.currentTimeMillis()+"</CreateTime>");
backMsgXml.append("<MsgType><![CDATA[text]]></MsgType>");
backMsgXml.append("<Content><![CDATA[您好~很高兴为您服务\n<a href='https://gffhax2lhf4de.cschat.antcloud.com.cn/index.htm?tntInstId=1Jp_K9x2&scene=SCE00323632'>点此接入在线客服</a>]]></Content>");
backMsgXml.append("</xml>");
response.setContentType("text/xml; charset=utf-8");
response.setCharacterEncoding("UTF-8");
response.getWriter().write(backMsgXml.toString());
}
}
/**
* 读取request数据
*
* @param request
* @return
*/
public String readRequestMsg(HttpServletRequest request) {
java.io.BufferedReader bis = null;
String line = null;
String result = "";
try {
bis = new java.io.BufferedReader(new java.io.InputStreamReader(request.getInputStream(), "UTF-8"));
while ((line = bis.readLine()) != null) {
result += line + "\r\n";
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
bis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return result;
}
@PostMapping("/orderPay")
@ResponseBody
public Result<Object> orderPay(@RequestBody JSONObject params) {
String openid = params.getString("openid");
String orderNumber = params.getString("orderNumber");
return apiPayService.orderPay(openid,orderNumber);
}
@PostMapping("/getAddress")
@ResponseBody
public Result<Object> getAddress(String lat ,String lng) {
String location = lat + "," + lng;
String key = "5G5BZ-BXLC3-BRM32-3LPUU-HVBFF-ULBRS";
String sercetKey = "LTDOFZ9utWc85jxPZdUzS2VelRCcqGf2";
String method = "/ws/geocoder/v1";
String reqParams = "key="+ key +"&location="+location + "&output=json";
String signStr = method + "?"+reqParams + sercetKey;
String sign = MD5Util.MD5Encode(signStr).toLowerCase(Locale.ROOT);
String url = Constant.TENCENT_GET_ADDRESS_URL + "?" + reqParams + "&sig=" + sign;
JSONObject response = restTemplate.getForObject(url, JSONObject.class);
Integer status = response.getInteger("status");
if(status != 0){
return ResultGenerator.genFailResult(response.getString("message"));
}
JSONObject result = response.getJSONObject("result");
JSONObject ad_info = result.getJSONObject("ad_info");
String province = ad_info.getString("province");
if(StringUtil.isEmpty(province)){
province = ad_info.getString("city");
}
return ResultGenerator.genSuccessResult("获取成功",province);
}
}

View File

@@ -0,0 +1,151 @@
//package cn.pluss.platform.controller.job;
//
//import java.util.Date;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.scheduling.annotation.EnableScheduling;
//import org.springframework.scheduling.annotation.Scheduled;
//import org.springframework.stereotype.Component;
//
//import com.alipay.api.AlipayApiException;
//import com.alipay.api.AlipayClient;
//import com.alipay.api.DefaultAlipayClient;
//import com.alipay.api.request.AlipayTradeQueryRequest;
//import com.alipay.api.response.AlipayTradeQueryResponse;
//
//import cn.pluss.platform.entity.MerchantOrder;
//import cn.pluss.platform.entity.UserApp;
//import cn.pluss.platform.wap.HttpUrlConnection;
//import cn.pluss.platform.wap.WxPaySignatureUtils;
//import cn.pluss.platform.wap.XmlUtil;
//import cn.pluss.platform.merchantOrder.MerchantOrderService;
//import cn.pluss.platform.systemConfig.SystemConfigService;
//import cn.pluss.platform.userApp.UserAppService;
//import cn.pluss.platform.util.DateUtils;
//import cn.pluss.platform.util.StringUtil;
//import net.sf.json.JSONObject;
//
///**
// * @author yuchen
// *
// * @Description
// * 定时任务查订单状态为等待付款的订单
// */
//@Component
//@Configuration //1.主要用于标记配置类兼备Component的效果。
//@EnableScheduling // 2.开启定时任务
//public class SaticScheduleTask {
//
// @Autowired
// private MerchantOrderService merchantOrderService;
//
// @Autowired
// private SystemConfigService systemConfigService;
//
// @Autowired
// private UserAppService userAppService;
//
//// @Scheduled(fixedRate=1000*60*30)
// private void configureTasks() throws AlipayApiException {
// MerchantOrder merchantOrder=new MerchantOrder();
// merchantOrder.setStatus("5");
// String endTime = DateUtils.formatDateDefault(new Date(),"yyyy-MM-dd 23:59:59");
// String startTime = DateUtils.getDay(endTime, (int)0);
// merchantOrder.setStartTime(startTime);
// merchantOrder.setEndTime(endTime);
// List<MerchantOrder> queryMerchantOrderList = merchantOrderService.queryMerchantOrderList(merchantOrder);
// for (MerchantOrder m : queryMerchantOrderList) {
// merchantOrder.setId(m.getId());
// if("wechatPay".equalsIgnoreCase(m.getPayTypeCode())) {
// getwechatOrderQuery(merchantOrder);
// }else if("aliPay".equalsIgnoreCase(m.getPayTypeCode())) {
// getaliPayOrderQuery(merchantOrder);
// }
// }
// }
//
// /**
// * getaliPayOrderQuery:(查询支付宝订单 若trade_status=TRADE_SUCCESS 修改订单). <br/>
// *
// * @author Administrator
// * @throws AlipayApiException
// * @since JDK 1.8
// */
// private void getaliPayOrderQuery(MerchantOrder merchantOrder) throws AlipayApiException {
// UserApp userApp=new UserApp();
// userApp.setMerchantCode(merchantOrder.getMerchantCode());
// List<UserApp> queryUserAppList = userAppService.queryUserAppList(userApp);
// if(queryUserAppList!=null&&queryUserAppList.size()>0) {
// userApp = queryUserAppList.get(0);
// }
// if(userApp.getAppAuthToken()==null) {
// return;
// }
// AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do",systemConfigService.querySystemConfigValue("ALI_APP_ID"),systemConfigService.querySystemConfigValue("PRI"),"json","GBK",systemConfigService.querySystemConfigValue("PUB"),"RSA2");
// AlipayTradeQueryRequest request = new AlipayTradeQueryRequest();
// request.setBizContent("{" +
// "\"out_trade_no\":\""+merchantOrder.getOrderNumber()+"\"" +
// " }");
// AlipayTradeQueryResponse response = alipayClient.execute(request);
// request.putOtherTextParam("app_auth_token", userApp.getAppAuthToken());
// if(response.isSuccess()){
// String body = response.getBody();
// JSONObject object = (JSONObject) JSONObject.fromObject(body).get("alipay_trade_query_response");
// String tradeStatus = (String) object.get("trade_status");
// if("TRADE_SUCCESS".equals(tradeStatus)) {
// merchantOrder.setStatus("0");
// merchantOrderService.updateMerchantOrder(merchantOrder);
// }
// }
// }
//
// /**
// *
// * getwechatOrderQuery:(查询微信订单). <br/>
// *
// * @author Administrator
// * @since JDK 1.8
// */
// private void getwechatOrderQuery(MerchantOrder merchantOrder) {
// UserApp userApp=new UserApp();
// userApp.setMerchantCode(merchantOrder.getMerchantCode());
// List<UserApp> queryUserAppList = userAppService.queryUserAppList(userApp);
// if(queryUserAppList!=null&&queryUserAppList.size()>0) {
// userApp = queryUserAppList.get(0);
// }
// if(userApp.getSubMchId()==null) {
// return;
// }
// Map<String, String> map=new HashMap<String, String>(16);
// map.put("appid", systemConfigService.querySystemConfigValue("APPID"));
// map.put("mch_id", systemConfigService.querySystemConfigValue("PID"));
// map.put("sub_mch_id", userApp.getSubMchId());
// map.put("out_trade_no", merchantOrder.getOrderNumber());
// map.put("nonce_str", StringUtil.getBillno());
// String WX_PAY_KEY = systemConfigService.querySystemConfigValue("KEY");
// String sign = WxPaySignatureUtils.signature(map, WX_PAY_KEY);
// StringBuffer xml=new StringBuffer();
// xml.append("<xml>");
// xml.append("<appid>"+ systemConfigService.querySystemConfigValue("APPID") +"</appid>");
// xml.append("<mch_id>"+ systemConfigService.querySystemConfigValue("PID") +"</mch_id>");
// xml.append("<nonce_str>"+ StringUtil.getBillno() +"</nonce_str>");
// xml.append("<out_trade_no>"+ merchantOrder.getOrderNumber() +"</out_trade_no>");
// xml.append("<sign>"+ sign +"</sign>");
// xml.append("</xml>");
// String httpXML = HttpUrlConnection.httpXML("https://api.mch.weixin.qq.com/pay/orderquery", xml.toString());
// Map<String, Object> result = XmlUtil.toMap(httpXML);
// if("SUCCESS".equals(result.get("return_code"))) {
// String tradeState = (String) result.get("trade_state");
// if("SUCCESS".equals(tradeState)){
// merchantOrder.setStatus("0");
// merchantOrderService.updateMerchantOrder(merchantOrder);
// }
// }
// }
//
//}
//

View File

@@ -0,0 +1,102 @@
package cn.pluss.platform.controller.phonecode;
import cn.pluss.platform.api.Result;
import cn.pluss.platform.api.ResultCode;
import cn.pluss.platform.constants.Constant;
import cn.pluss.platform.entity.MerchantMenber;
import cn.pluss.platform.entity.PhoneValidateCode;
import cn.pluss.platform.entity.UserInfo;
import cn.pluss.platform.merchantMenber.MerchantMenberService;
import cn.pluss.platform.phoneValidateCode.PhoneValidateCodeService;
import cn.pluss.platform.userInfo.UserInfoService;
import cn.pluss.platform.util.StringUtil;
import cn.pluss.platform.util.ValidateCodeUtil;
import com.alibaba.fastjson.JSON;
import com.aliyuncs.exceptions.ClientException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author yuchen
* @Description 验证码
*/
@Controller
public class PhoneCodeController {
@Autowired
private PhoneValidateCodeService phoneValidateCodeService;
@Autowired
private UserInfoService userInfoService;
@Autowired
private MerchantMenberService merchantMenberService;
@Autowired
private ValidateCodeUtil validateCodeUtil;
public Object sevice(String param) throws ClientException {
UserInfo userInfo = new UserInfo();
userInfo.setLoginName(param);
Map<String, Object> result = new HashMap<>(16);
List<UserInfo> queryUserInfoList = userInfoService.queryUserInfoList(userInfo);
if (queryUserInfoList != null && queryUserInfoList.size() > 0) {
result.put(Constant.RESULT_CODE_FAIL, "手机号已注册");
return JSON.toJSONString(result);
}
String checkCode = StringUtil.random(4);
Result<Object> objectResult = validateCodeUtil.requestValidateCode(param, checkCode);
if (objectResult != null && objectResult.getCode() == ResultCode.FAIL.code()) {
result.put(Constant.RESULT_CODE_FAIL, objectResult.getMessage());
return JSON.toJSONString(result);
}
PhoneValidateCode phoneValidateCode = new PhoneValidateCode();
phoneValidateCode.setPhone(param);
phoneValidateCode.setSendDt(new Date());
result.put(Constant.RESULT_CODE_SUCCESS, "发送成功");
phoneValidateCode.setCode(checkCode);
phoneValidateCode.setStatus("1");
phoneValidateCodeService.savePhoneValidateCode(phoneValidateCode);
String res = JSON.toJSONString(result);
System.out.println(res);
return res;
}
public Object seviceVIP(String phone, String storeId) throws ClientException {
MerchantMenber merchantMenber = new MerchantMenber();
merchantMenber.setPhone(phone);
merchantMenber.setStoreId(storeId);
Map<String, Object> result = new HashMap<>(16);
List<MerchantMenber> queryMerchantMenberList = merchantMenberService.queryMerchantMenberList(merchantMenber);
if (queryMerchantMenberList != null && queryMerchantMenberList.size() > 0) {
result.put(Constant.RESULT_CODE_FAIL, "该门店已注册会员");
return JSON.toJSONString(result);
}
String checkCode = StringUtil.random(4);
Result<Object> objectResult = validateCodeUtil.requestValidateCode(phone, checkCode);
if (objectResult != null && objectResult.getCode() == ResultCode.FAIL.code()) {
result.put(Constant.RESULT_CODE_FAIL, objectResult.getMessage());
return JSON.toJSONString(result);
}
PhoneValidateCode phoneValidateCode = new PhoneValidateCode();
phoneValidateCode.setPhone(phone);
phoneValidateCode.setSendDt(new Date());
result.put(Constant.RESULT_CODE_SUCCESS, "发送成功");
phoneValidateCode.setCode(checkCode);
phoneValidateCode.setStatus("1");
phoneValidateCodeService.savePhoneValidateCode(phoneValidateCode);
return JSON.toJSONString(result);
}
}

View File

@@ -0,0 +1,150 @@
package cn.pluss.platform.controller.systemConfig;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import cn.pluss.platform.entity.SystemConfig;
import cn.pluss.platform.systemConfig.SystemConfigService;
import cn.pluss.platform.util.StringUtil;
@Controller
@RequestMapping("systemconfig")
public class SystemConfigController {
private Integer PAGE_SIZE=12;
@Autowired
private SystemConfigService systemConfigService;
//引导页
@RequestMapping(value = "/index", method = RequestMethod.GET)
public String index() {
return "systemConfig/systemconfigList";
}
//分页查询
@RequestMapping(value = "/querySystemconfigByPage", method = RequestMethod.POST)
@ResponseBody
public Map<String,Object> querySystemconfigByPage(Integer currPage,Integer id) {
if(currPage==null) {
currPage=1;
}
Map<String,Object> map=new HashMap<String, Object>();
map.put("pageSize",PAGE_SIZE);
map.put("offset", (currPage-1)*PAGE_SIZE);
map.put("id", id);
List<SystemConfig> systemconfigList=systemConfigService.querySystemConfigPage(map);
Integer count=systemConfigService.querySystemConfigPageCount(map);
Map<String,Object> result=new HashMap<String,Object>();
result.put("systemconfigList", systemconfigList);
result.put("count", count);
result.put("pageCount",StringUtil.getPageCount(count,PAGE_SIZE));
result.put("currPage", currPage);
return result;
}
//查询详情
@RequestMapping(value = "/querySystemconfigDetails", method = RequestMethod.GET)
public String querySystemconfigDetails(HttpServletRequest request,Integer id,Integer pageIndex) {
if(id!=null&&id!=0) {
SystemConfig systemconfig=new SystemConfig();
systemconfig.setId(id);
systemconfig=systemConfigService.querySystemConfig(systemconfig);
request.setAttribute("systemconfig", systemconfig);
request.setAttribute("pageIndex", pageIndex);
}
return "systemConfig/systemconfigDetails";
}
/**
*查询详情
*/
@RequestMapping(value = "/querySystemconfigBaseInfo", method = RequestMethod.GET)
public String querySystemConfigBaseInfo(HttpServletRequest request ,Integer id){
if(id!=null&&id!=0) {
SystemConfig systemconfig=new SystemConfig();
systemconfig.setId(id);
systemconfig=systemConfigService.querySystemConfig(systemconfig);
request.setAttribute("systemconfig", systemconfig);
}
return "systemConfig/systemconfigBaseInfo";
}
/**
*查询详情
*/
@RequestMapping(value = "/querySystemconfigExtendsInfo", method = RequestMethod.GET)
public String querySystemConfigExtendsInfo(){
return "systemConfig/systemconfigExtendsInfo";
}
/**
*查询详情
*/
@RequestMapping(value = "/querySystemconfigFunctionsInfo", method = RequestMethod.GET)
public String querySystemConfigFunctionsInfo(){
return "systemConfig/systemconfigFunctionsInfo";
}
/**
*保存对象
*/
@RequestMapping(value = "/saveSystemconfig", method = RequestMethod.POST)
@ResponseBody
public Map<String,Object> saveSystemConfig(SystemConfig systemconfig){
if(systemconfig.getId()!=null&&systemconfig.getId()!=0){
systemConfigService.updateSystemConfig(systemconfig);
}else{
systemConfigService.saveSystemConfig(systemconfig);
}
Map<String,Object> result=new HashMap<String,Object>();
result.put("resultCode", "1");
result.put("resultMessage", "保存成功!");
return result;
}
/**
*修改对象
*/
@RequestMapping(value = "/updateSystemconfig", method = RequestMethod.POST)
@ResponseBody
public Map<String,Object> updateSystemConfig(Integer id){
SystemConfig systemconfig=new SystemConfig();
systemconfig.setId(id);
systemConfigService.updateSystemConfig(systemconfig);
Map<String,Object> result=new HashMap<String,Object>();
result.put("resultCode", "1");
result.put("resultMessage", "保存成功!");
return result;
}
/**
*删除对象
*/
@RequestMapping(value = "/deleteSystemconfig", method = RequestMethod.POST)
@ResponseBody
public Map<String,Object> deleteSystemConfig(Integer id){
SystemConfig systemconfig=new SystemConfig();
systemconfig.setId(id);
systemConfigService.deleteSystemConfig(systemconfig);
Map<String,Object> result=new HashMap<String,Object>();
result.put("resultCode", "1");
result.put("resultMessage", "保存成功!");
return result;
}
}

View File

@@ -0,0 +1,61 @@
package cn.pluss.platform.controller.test;
import cn.pluss.platform.api.Result;
import cn.pluss.platform.api.ResultGenerator;
import cn.pluss.platform.pay.ApiPayService;
import cn.pluss.platform.util.IpUtils;
import cn.pluss.platform.util.MD5Util;
import cn.pluss.platform.util.SignUtils;
import cn.pluss.platform.util.StringUtil;
import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
@Controller
@RequestMapping(value = "/test")
public class HelloController {
@Resource
private ApiPayService apiPayService;
@RequestMapping(value = "/callbackV1")
@ResponseBody
public JSONObject callbackV1(){
JSONObject result = new JSONObject();
result.put("code","SUCCESS");
result.put("msg","成功");
return result;
}
@RequestMapping(value = "/callbackV2")
@ResponseBody
public String callbackV2(){
return "SUCCESS";
}
@RequestMapping(value = "testPay")
@ResponseBody
public Result<Object> payTest(Double payAmt, HttpServletRequest request){
String key = "4c8d277b0f274604af68e590cc0b3e6b";
JSONObject params = new JSONObject();
params.put("mercOrderNo","TEST100"+ StringUtil.genRandomNum(20));
params.put("merchantCode","M800202107223018811");
params.put("method","trans_wap_pay");
params.put("payAmt", BigDecimal.valueOf(payAmt).setScale(2,BigDecimal.ROUND_HALF_UP));
params.put("ip","171.83.125.71");
params.put("notifyUrl","http://bzgcrystal.natapp1.cc/wap/test/callbackV1");
params.put("payWay","WXZF");
params.put("subject","测试");
params.put("returnUrl","http://www.baidu.com");
String sigStr = SignUtils.getSignContent(params)+"&key="+key;
String sign = MD5Util.MD5Encode(sigStr, "UTF-8");
params.put("sign",sign);
JSONObject pay = apiPayService.pay(params.toString(), IpUtils.getIpAddr(request));
return ResultGenerator.genSuccessResult("获取成功",pay.getJSONObject("data").getString("orderNumber"));
}
}