mirror of
https://gitee.com/lab1024/smart-admin.git
synced 2025-10-03 02:36:39 +08:00
adding wx-pay and alipay logic and order and good logic code
This commit is contained in:
parent
175e3bc6f2
commit
b704d1b82f
@ -8,6 +8,7 @@ import net.lab1024.smartadmin.module.system.login.LoginResponseCodeConst;
|
||||
import net.lab1024.smartadmin.module.system.position.PositionResponseCodeConst;
|
||||
import net.lab1024.smartadmin.module.system.privilege.constant.PrivilegeResponseCodeConst;
|
||||
import net.lab1024.smartadmin.module.system.role.basic.RoleResponseCodeConst;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.good.constant.OrderResponseCodeConst;
|
||||
import net.lab1024.smartadmin.module.system.systemconfig.constant.SystemConfigResponseCodeConst;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@ -34,6 +35,7 @@ public class ResponseCodeConst {
|
||||
ResponseCodeContainer.register(PrivilegeResponseCodeConst.class, 7001, 7999);
|
||||
ResponseCodeContainer.register(OrderOperateLogOperateTypeConst.class, 8001, 8999);
|
||||
ResponseCodeContainer.register(PositionResponseCodeConst.class, 13000, 13999);
|
||||
ResponseCodeContainer.register(OrderResponseCodeConst.class, 9000, 9999);
|
||||
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,8 @@ public class SmartAuthenticationInterceptor extends HandlerInterceptorAdapter {
|
||||
return true;
|
||||
}
|
||||
Boolean noNeedLogin = request.getServletPath().startsWith("/royalcanin/member");
|
||||
if (noNeedLogin) {
|
||||
Boolean noNeedLoginNotify = request.getServletPath().startsWith("royalcanin/wechatnotify");
|
||||
if (noNeedLogin||noNeedLoginNotify) {
|
||||
return true;
|
||||
}
|
||||
//放行的Uri前缀
|
||||
|
@ -0,0 +1,205 @@
|
||||
package net.lab1024.smartadmin.module.system.alipay;
|
||||
|
||||
import com.alipay.api.AlipayApiException;
|
||||
import com.alipay.api.AlipayClient;
|
||||
import com.alipay.api.DefaultAlipayClient;
|
||||
import com.alipay.api.domain.AlipayTradePrecreateModel;
|
||||
import com.alipay.api.internal.util.AlipaySignature;
|
||||
import com.alipay.api.request.AlipayTradePrecreateRequest;
|
||||
import com.alipay.api.response.AlipayTradePrecreateResponse;
|
||||
import io.swagger.annotations.Api;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.lab1024.smartadmin.common.anno.OperateLog;
|
||||
import net.lab1024.smartadmin.constant.SwaggerTagConst;
|
||||
import net.lab1024.smartadmin.module.system.alipay.alipayModel.AliPayEntity;
|
||||
import net.lab1024.smartadmin.module.system.alipay.conf.AlipayConfig;
|
||||
import net.lab1024.smartadmin.module.system.qrcode.QRCodeUtil;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.good.service.GoodService;
|
||||
import net.lab1024.smartadmin.util.GenerateSequenceUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
@Api(tags = {SwaggerTagConst.Admin.MANAGER_MALL_PAY_API})
|
||||
@OperateLog
|
||||
@Slf4j
|
||||
@RestController
|
||||
public class AlipayController {
|
||||
|
||||
@Autowired
|
||||
private GoodService goodService;
|
||||
|
||||
public static String notify_url = "";
|
||||
|
||||
/**
|
||||
* @Description: 前往支付宝第三方网关进行支付
|
||||
*/
|
||||
|
||||
@RequestMapping("royalcanin/aliPayUnifiedOrder")
|
||||
public void code(@RequestBody AliPayEntity aliPayEntity, HttpServletResponse response) throws Exception{
|
||||
|
||||
//---------------------------------------
|
||||
//------AlipayTradePrecreateModel--------
|
||||
//---------------------------------------
|
||||
AlipayTradePrecreateModel model = new AlipayTradePrecreateModel();
|
||||
model.setSubject(aliPayEntity.getSubject());
|
||||
model.setTotalAmount(aliPayEntity.getTotal_amount());
|
||||
model.setStoreId(UUID.randomUUID().toString());
|
||||
model.setTimeoutExpress("3m");
|
||||
model.setOutTradeNo(aliPayEntity.getOut_trade_no());
|
||||
model.setBody(aliPayEntity.getBody());
|
||||
model.setGoodsDetail(aliPayEntity.getGoodsDetail());
|
||||
//----------------------------------------
|
||||
//-----AlipayTradePagePayRequest----------
|
||||
//----------------------------------------
|
||||
AlipayTradePrecreateRequest request = new AlipayTradePrecreateRequest();
|
||||
request.setBizModel(model);
|
||||
request.setNotifyUrl(notify_url);
|
||||
//---------------------------------------
|
||||
//-----------AlipayClient----------------
|
||||
//---------------------------------------
|
||||
AlipayClient alipayClient = new DefaultAlipayClient(AlipayConfig.gatewayUrl,AlipayConfig.app_id,AlipayConfig.merchant_private_key, "json",AlipayConfig.charset,AlipayConfig.alipay_public_key,AlipayConfig.sign_type);
|
||||
|
||||
AlipayTradePrecreateResponse alipayTradePrecreateResponse = alipayClient.execute(request);
|
||||
if (alipayTradePrecreateResponse.isSuccess()) {
|
||||
String code = alipayTradePrecreateResponse.getQrCode();
|
||||
QRCodeUtil.createCodeToOutputStream(code, response.getOutputStream());
|
||||
} else {
|
||||
throw new RuntimeException("支付宝生成二维码失败");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@RequestMapping("royalcanin/notify_url")
|
||||
public String returnUrl(HttpServletRequest request) throws UnsupportedEncodingException, AlipayApiException{
|
||||
Map<String,String> params = new HashMap<String,String>();
|
||||
Map<String,String[]> requestParams = request.getParameterMap();
|
||||
for (Iterator<String> iter = requestParams.keySet().iterator(); iter.hasNext();) {
|
||||
String name = (String) iter.next();
|
||||
String[] values = (String[]) requestParams.get(name);
|
||||
String valueStr = "";
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
valueStr = (i == values.length - 1) ? valueStr + values[i]
|
||||
: valueStr + values[i] + ",";
|
||||
}
|
||||
//乱码解决,这段代码在出现乱码时使用(如果感觉自己配置没问题,然后验签一直失败,就把这个注释掉试试,反正我的是这个问题)
|
||||
//valueStr = new String(valueStr.getBytes("ISO-8859-1"), "utf-8");
|
||||
params.put(name, valueStr);
|
||||
}
|
||||
System.out.println("params:"+params);
|
||||
boolean signVerified = AlipaySignature.rsaCheckV1(params,AlipayConfig.alipay_public_key,AlipayConfig.charset,AlipayConfig.sign_type); //调用SDK验证签名
|
||||
System.out.println(signVerified);
|
||||
//——请在这里编写您的程序(以下代码仅作参考)——
|
||||
if(signVerified) {
|
||||
//商户订单号
|
||||
String out_trade_no = new String(request.getParameter("out_trade_no").getBytes("ISO-8859-1"),"UTF-8");
|
||||
|
||||
//支付宝交易号
|
||||
String trade_no = new String(request.getParameter("trade_no").getBytes("ISO-8859-1"),"UTF-8");
|
||||
//付款金额
|
||||
String total_amount = new String(request.getParameter("total_amount").getBytes("ISO-8859-1"),"UTF-8");
|
||||
|
||||
String trade_status= new String(request.getParameter("trade_status").getBytes("ISO-8859-1"),"UTF-8");
|
||||
System.out.println("trade_status:"+trade_status);
|
||||
return "trade_no:"+trade_no+"<br/>out_trade_no:"+out_trade_no+"<br/>total_amount:"+total_amount;
|
||||
}else {
|
||||
return "验签失败";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@RequestMapping(value = "/alipayNotifyNotice")
|
||||
@ResponseBody
|
||||
public String alipayNotifyNotice(HttpServletRequest request, HttpServletRequest response) throws Exception {
|
||||
|
||||
// LOGGER.info("支付成功, 进入异步通知接口...");
|
||||
|
||||
//获取支付宝POST过来反馈信息
|
||||
Map<String, String> params = new HashMap<String, String>();
|
||||
Map<String, String[]> requestParams = request.getParameterMap();
|
||||
for (Iterator<String> iter = requestParams.keySet().iterator(); iter.hasNext(); ) {
|
||||
String name = (String) iter.next();
|
||||
String[] values = (String[]) requestParams.get(name);
|
||||
String valueStr = "";
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
valueStr = (i == values.length - 1) ? valueStr + values[i]
|
||||
: valueStr + values[i] + ",";
|
||||
}
|
||||
//乱码解决,这段代码在出现乱码时使用
|
||||
// valueStr = new String(valueStr.getBytes("ISO-8859-1"), "utf-8");
|
||||
params.put(name, valueStr);
|
||||
}
|
||||
|
||||
boolean signVerified = AlipaySignature.rsaCheckV1(params, AlipayConfig.alipay_public_key, AlipayConfig.charset, AlipayConfig.sign_type); //调用SDK验证签名
|
||||
|
||||
//——请在这里编写您的程序(以下代码仅作参考)——
|
||||
|
||||
/* 实际验证过程建议商户务必添加以下校验:
|
||||
1、需要验证该通知数据中的out_trade_no是否为商户系统中创建的订单号,
|
||||
2、判断total_amount是否确实为该订单的实际金额(即商户订单创建时的金额),
|
||||
3、校验通知中的seller_id(或者seller_email) 是否为out_trade_no这笔单据的对应的操作方(有的时候,一个商户可能有多个seller_id/seller_email)
|
||||
4、验证app_id是否为该商户本身。
|
||||
*/
|
||||
if (signVerified) {//验证成功
|
||||
//商户订单号
|
||||
String out_trade_no = new String(request.getParameter("out_trade_no").getBytes("ISO-8859-1"), "UTF-8");
|
||||
|
||||
//支付宝交易号
|
||||
String trade_no = new String(request.getParameter("trade_no").getBytes("ISO-8859-1"), "UTF-8");
|
||||
|
||||
//交易状态
|
||||
String trade_status = new String(request.getParameter("trade_status").getBytes("ISO-8859-1"), "UTF-8");
|
||||
|
||||
//付款金额
|
||||
String total_amount = new String(request.getParameter("total_amount").getBytes("ISO-8859-1"), "UTF-8");
|
||||
|
||||
if (trade_status.equals("TRADE_FINISHED")) {
|
||||
//判断该笔订单是否在商户网站中已经做过处理
|
||||
//如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序
|
||||
//如果有做过处理,不执行商户的业务程序
|
||||
|
||||
//注意: 尚自习的订单没有退款功能, 这个条件判断是进不来的, 所以此处不必写代码
|
||||
//退款日期超过可退款期限后(如三个月可退款),支付宝系统发送该交易状态通知
|
||||
} else if (trade_status.equals("TRADE_SUCCESS")) {
|
||||
//判断该笔订单是否在商户网站中已经做过处理
|
||||
//如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序
|
||||
//如果有做过处理,不执行商户的业务程序
|
||||
|
||||
//注意:
|
||||
//付款完成后,支付宝系统发送该交易状态通知
|
||||
|
||||
// 修改叮当状态,改为 支付成功,已付款; 同时新增支付流水
|
||||
// ordersService.updateOrderStatus(out_trade_no, trade_no, total_amount);
|
||||
//
|
||||
// //这里不用 查 只是为了 看日志 查的方法应该卸载 同步回调 页面 中
|
||||
// Orders order = ordersService.getOrderById(out_trade_no);
|
||||
// Product product = productService.getProductById(order.getProductId());
|
||||
//
|
||||
// LOGGER.info("********************** 支付成功(支付宝异步通知)查询 只是为了 看日志 **********************");
|
||||
// LOGGER.info("* 订单号: {}", out_trade_no);
|
||||
// LOGGER.info("* 支付宝交易号: {}", trade_no);
|
||||
// LOGGER.info("* 实付金额: {}", total_amount);
|
||||
// LOGGER.info("* 购买产品: {}", product.getName());
|
||||
// LOGGER.info("***************************************************************");
|
||||
|
||||
}
|
||||
// LOGGER.info("支付成功...");
|
||||
|
||||
} else {//验证失败
|
||||
// LOGGER.info("支付, 验签失败...");
|
||||
}
|
||||
|
||||
return "success";
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package net.lab1024.smartadmin.module.system.alipay.alipayModel;
|
||||
|
||||
import com.alipay.api.domain.GoodsDetail;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class AliPayEntity {
|
||||
|
||||
private String out_trade_no;
|
||||
|
||||
private String total_amount;
|
||||
|
||||
private String subject;
|
||||
|
||||
private String product_code;
|
||||
|
||||
private String auth_token;
|
||||
|
||||
private String body;
|
||||
|
||||
private String quit_url;
|
||||
|
||||
private List<GoodsDetail> goodsDetail;
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
package net.lab1024.smartadmin.module.system.alipay.conf;
|
||||
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
/* *
|
||||
*类名:AlipayConfig
|
||||
*功能:基础配置类
|
||||
*详细:设置帐户有关信息及返回路径
|
||||
*修改日期:2017-04-05
|
||||
*说明:
|
||||
*以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。
|
||||
*该代码仅供学习和研究支付宝接口使用,只是提供一个参考。
|
||||
*/
|
||||
|
||||
public class AlipayConfig {
|
||||
|
||||
//↓↓↓↓↓↓↓↓↓↓请在这里配置您的基本信息↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
|
||||
|
||||
// 应用ID,您的APPID,收款账号既是您的APPID对应支付宝账号
|
||||
public static String app_id = "2016101800716209";
|
||||
// public static String app_id = "2021000118668627";
|
||||
|
||||
// 商户私钥,您的PKCS8格式RSA2私钥
|
||||
public static String merchant_private_key = "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDL8350XEsOVVSg8+cKZEl6Jx7Tp63JFimk+lldS8chZ8hv3Netz5iMemQJYH328VEB5sKkIXfDiwT1fxR2cgsGdQgmG25omKM/47QfxTRp9C4II65AlMfLsPWOWefc/enaza/gMMzB5SvvFnbpX/71aJmqU7nJvATY8MwW4SxKXKMTEI/K7+jERReR4SxtGHeFTZ892ljr7IOqJbGPnd2CXzLO05AGGhOrsmtFMh9eysD1WzcDKoADJSi26oMI49mExGo3jMF111AcXSR4CgLsx5bSoe4XtXtVbqEr/tOCt4zAWoUbu/Mviog+60eMr9qaE719aobEZP7aI5ECd86NAgMBAAECggEAXRVBtqvU2bLaUCdhYF3LJ0QpjqIt7+P8l75nAOyv8rAiS+O4UCy6TAskEx+F/im/NiXy2eQofAe7+KvKVBDStVy+nl3Qs05O2776G7HurRjz1WUrh3AgC/g06oZgC32buPA9gA3ltez5c0KGfRcCD1FxKMrTtZ3pfHXSP/L/OuRhobxCZvEL5jcWHkxgOeaL37+UQSHJe3dhCPjjj1VOxBj0RLgcAPJ8/KoglcmWHacYvPxgRo26xahrW3yCofcb+cEzG5WhCc3uBK3eSWNB1knSwl2gVMcGmN8gOPBpAneSjqv6pqWUqgAOENxi2kRZYDyTNi3JHt2ZJMdDblU8AQKBgQD2Z+CjGGloaQTvcow/dqxF4a5EAnjeUSA+cdw7ttNqvszNofjvxv9RULKIf8jgrkO9cE5X9ezqHXaWOspyXbFhmPFginH9N5tTGggrzCpeHs7jW3EZKiYJIl2MRzxMVx1jaN8EfT8Z3u/4Ca/QwPvsGNj/Er7kwqLUvkGsLeOHjQKBgQDT5G/8R/T2LqJUvFiKntfY830WVAD9vUGst68ouxfaQKj2IOlOedjvQwRcInOX3GFnQyw8ncWOIZDQOnJdYpQdjQAx3queHmv8toCp+MKyPLLYJYu4LP6ahT/9vd9G9r0QUo57n75sVOcT5tj9ZKdykchPUWe1T02LEUZPxDwjAQKBgQCnf7meZMvSpAEs3EsmIP++iUkzBhMv3Sn0COZS2VciKw2Bg2d7Z2TL2/VhAKyGvy9hKWS4On6QLvMb8F8KG1KnK5Z5r+MI5LH7bai8TQ9H591vhAt/tb0hXHEHGK2On3Fk0Dc6EAHDDl9F1x/i4izeM43e5tlJHF4gDC0MZC1VSQKBgQDMS1yZXXtV/GJw1mN7y2iK+T/qTjXibx2p/DO6TqDRwjPlkpe/HQXGsdO7TVAr48RZvk8hZnB59+zahu+LECeEUlUUv/6xZd1x+zgUKQ72sEUy1wheG6uiqcSnzfA/SFfDLAXKNZtwcW+WJaWisfAsK1h4+SDHk91MruwerjHZAQKBgH6muiaSlg6DvAUBjtxaOE0bgchI+M/j7N4289syb/6A0iTUNeTREWk2kmBT/ZeZCFtrjJx+TdVauyjkRwKx0wEuf9H+WrUM+6i5j5nTrcUEAUTjCY7IRxGk8uhNLM7cyBNvpsD4olI5j2DmRsZWnv/bNuJH2FHbvXMwanZ22vM5";
|
||||
|
||||
// 支付宝公钥,查看地址:https://openhome.alipay.com/platform/keyManage.htm 对应APPID下的支付宝公钥。
|
||||
// public static String alipay_public_key = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAy/N+dFxLDlVUoPPnCmRJeice06etyRYppPpZXUvHIWfIb9zXrc+YjHpkCWB99vFRAebCpCF3w4sE9X8UdnILBnUIJhtuaJijP+O0H8U0afQuCCOuQJTHy7D1jlnn3P3p2s2v4DDMweUr7xZ26V/+9WiZqlO5ybwE2PDMFuEsSlyjExCPyu/oxEUXkeEsbRh3hU2fPdpY6+yDqiWxj53dgl8yztOQBhoTq7JrRTIfXsrA9Vs3AyqAAyUotuqDCOPZhMRqN4zBdddQHF0keAoC7MeW0qHuF7V7VW6hK/7TgreMwFqFG7vzL4qIPutHjK/amhO9fWqGxGT+2iORAnfOjQIDAQAB";
|
||||
public static String alipay_public_key ="MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAjBThgyJ3SJsx0IYUspiW+R/NDInruz2Tirr0vGmzfaNkBSDmyg2vNLmnkNrxbHApJkIRKWqGbC8yPybyjFz1nXP7oji0d/3sPKZZGdNEqOcZLaki8xPeXfOVu1T/uPH/9S084t94yQPNrD9BqehOlN+I4b/mXJ7tDGRnS2OVrQqDrPbg8pjH3OYa0bELkr71R92EHxCN4V2bSdCS1ag96/etgkodduOCmiBPVSmSRXas/GpRw92NVsRKvesWOatfjEjqST0Bz0nRuOuRnQIy1exxs/D2DHCVa6aO6TNogcPWe3C9dvxjxjw9IOiyhkGThWoWrdk8Ot+V8V8LeomcYwIDAQAB";
|
||||
// 服务器异步通知页面路径 需http://格式的完整路径,不能加?id=123这类自定义参数,必须外网可以正常访问
|
||||
// public static String notify_url = "http://工程公网访问地址/alipay.trade.page.pay-JAVA-UTF-8/notify_url.jsp";
|
||||
public static String notify_url = "http://localhost:10086/smart-admin-api/royalcanin/notify_url";
|
||||
// 页面跳转同步通知页面路径 需http://格式的完整路径,不能加?id=123这类自定义参数,必须外网可以正常访问
|
||||
public static String return_url = "http://工程公网访问地址/alipay.trade.page.pay-JAVA-UTF-8/return_url.jsp";
|
||||
|
||||
// 签名方式
|
||||
public static String sign_type = "RSA2";
|
||||
|
||||
// 字符编码格式
|
||||
public static String charset = "utf-8";
|
||||
|
||||
// 支付宝网关
|
||||
public static String gatewayUrl = "https://openapi.alipaydev.com/gateway.do";
|
||||
|
||||
// 支付宝网关
|
||||
public static String log_path = "C:\\";
|
||||
|
||||
|
||||
//↑↑↑↑↑↑↑↑↑↑请在这里配置您的基本信息↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
|
||||
|
||||
/**
|
||||
* 写日志,方便测试(看网站需求,也可以改成把记录存入数据库)
|
||||
* @param sWord 要写入日志里的文本内容
|
||||
*/
|
||||
// public static void logResult(String sWord) {
|
||||
// FileWriter writer = null;
|
||||
// try {
|
||||
// writer = new FileWriter(log_path + "alipay_log_" + System.currentTimeMillis()+".txt");
|
||||
// writer.write(sWord);
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// } finally {
|
||||
// if (writer != null) {
|
||||
// try {
|
||||
// writer.close();
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ public class CouponService {
|
||||
public String couponCancel(CouponCancelEntity couponCancelEntity) throws Exception{
|
||||
Map<String, String> paramMap = MapRemoveNullUtil.setConditionMap(couponCancelEntity);
|
||||
net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(paramMap);
|
||||
return SmartHttpUtil.httpPostRaw(url+"cancel",jsonObject.toString(),null,"utf-8");
|
||||
return SmartHttpUtil.sendPostForm(url+"cancel",paramMap,null);
|
||||
}
|
||||
|
||||
public String couponCosume(CouponCosumeEntity couponCosumeEntity) throws Exception{
|
||||
@ -25,29 +25,28 @@ public class CouponService {
|
||||
paramMap.put("petCategoryId",StringUtil.toString(couponCosumeEntity.getPetCategoryId()).equals("0")?null:StringUtil.toString(couponCosumeEntity.getPetCategoryId()));
|
||||
paramMap.put("petBodySizeId",StringUtil.toString(couponCosumeEntity.getPetBodySizeId()).equals("0")?null:StringUtil.toString(couponCosumeEntity.getPetBodySizeId()));
|
||||
net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(paramMap);
|
||||
return SmartHttpUtil.httpPostRaw(url+"consume",jsonObject.toString(),null,"utf-8");
|
||||
return SmartHttpUtil.sendPostForm(url+"consume",paramMap,null);
|
||||
}
|
||||
|
||||
public String couponFetch(CouponFetchEntity couponFetchEntity) throws Exception{
|
||||
Map<String, String> paramMap = MapRemoveNullUtil.setConditionMap(couponFetchEntity);
|
||||
net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(paramMap);
|
||||
return SmartHttpUtil.httpPostRaw(url+"fetch",jsonObject.toString(),null,"utf-8");
|
||||
return SmartHttpUtil.sendPostForm(url+"fetch",paramMap,null);
|
||||
}
|
||||
|
||||
public String couponGetAll(CouponGetAllEntity couponGetAllEntity) throws Exception{
|
||||
Map<String, String> paramMap = MapRemoveNullUtil.setConditionMap(couponGetAllEntity);
|
||||
paramMap.put("memberId",StringUtil.toString(couponGetAllEntity.getMemberId()).equals("0")?null:StringUtil.toString(couponGetAllEntity.getMemberId()));
|
||||
paramMap.put("status",StringUtil.toString(couponGetAllEntity.getStatus()).equals("0")?null:StringUtil.toString(couponGetAllEntity.getStatus()));
|
||||
paramMap.put("page",StringUtil.toString(couponGetAllEntity.getPage()).equals("0")?null:StringUtil.toString(couponGetAllEntity.getPage()));
|
||||
paramMap.put("rows",StringUtil.toString(couponGetAllEntity.getRows()).equals("0")?null:StringUtil.toString(couponGetAllEntity.getRows()));
|
||||
net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(paramMap);
|
||||
return SmartHttpUtil.httpPostRaw(url+"getAll",jsonObject.toString(),null,"utf-8");
|
||||
return SmartHttpUtil.sendPostForm(url+"getAll",paramMap,null);
|
||||
}
|
||||
|
||||
public String couponGet(CouponGetEntity couponGetEntity) throws Exception{
|
||||
Map<String, String> paramMap = MapRemoveNullUtil.setConditionMap(couponGetEntity);
|
||||
net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(paramMap);
|
||||
return SmartHttpUtil.httpPostRaw(url+"get",jsonObject.toString(),null,"utf-8");
|
||||
return SmartHttpUtil.sendPostForm(url+"get",paramMap,null);
|
||||
}
|
||||
|
||||
|
||||
@ -59,6 +58,6 @@ public class CouponService {
|
||||
paramMap.put("rows",StringUtil.toString(couponV2GetAllEntity.getRows()).equals("0")?null:StringUtil.toString(couponV2GetAllEntity.getRows()));
|
||||
paramMap.put("page",StringUtil.toString(couponV2GetAllEntity.getPage()).equals("0")?null:StringUtil.toString(couponV2GetAllEntity.getPage()));
|
||||
net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(paramMap);
|
||||
return SmartHttpUtil.httpPostRaw(url+"v2/getAll",jsonObject.toString(),null,"utf-8");
|
||||
return SmartHttpUtil.sendPostForm(url+"v2/getAll",paramMap,null);
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,9 @@ import net.lab1024.smartadmin.module.system.royalcanin.couponConfig.CouponConfig
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.couponConfig.CouponConfigGetEntity;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.domain.RoyalcaninOperateLogEntity;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.domain.RoyalcaninOperateLogService;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.good.model.GoodsEntity;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.good.service.GoodService;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.good.service.OrderService;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.member.*;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.memberAccount.MemberAccountChangeEntity;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.memberAccount.MemberAccountHistoryEntity;
|
||||
@ -20,13 +23,18 @@ import net.lab1024.smartadmin.module.system.royalcanin.memberAddress.MemberAddre
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.memberAddress.MemberAddressDeleteEntity;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.memberAddress.MemberAddressGetAllEntity;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.memberAddress.MemberAddressUpdateEntity;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.orderMaster.AddOrSaveEntity;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.orderMaster.QueryEntity;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Api(tags = {SwaggerTagConst.Admin.MANAGER_MALL_API})
|
||||
@ -52,6 +60,10 @@ public class TransitionController {
|
||||
@Autowired
|
||||
private CouponService couponService;
|
||||
|
||||
@Autowired
|
||||
private OrderService orderService;
|
||||
|
||||
|
||||
@ApiOperation(value = "会员信息", notes = "会员查询,验证会员信息,会员注册")
|
||||
@PostMapping("royalcanin/member")
|
||||
public String transferMember(String type , @RequestBody Object object, HttpServletRequest request) throws Exception {
|
||||
@ -191,6 +203,33 @@ public class TransitionController {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "订单信息", notes = "查询订单信息,新增或者更新订单信息")
|
||||
@PostMapping("royalcanin/orderMaster")
|
||||
public String transferOrderMaster(String type ,@RequestBody Object object, HttpServletRequest request) throws Exception {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String result = "null";
|
||||
long startTime = System.currentTimeMillis();
|
||||
switch (type)
|
||||
{
|
||||
case "query":
|
||||
result = orderService.query(objectMapper.convertValue(object, QueryEntity.class));
|
||||
break;
|
||||
case "addOrSave":
|
||||
result = orderService.addOrSave(objectMapper.convertValue(object, AddOrSaveEntity.class));
|
||||
break;
|
||||
}
|
||||
long acceptTime = System.currentTimeMillis() ;
|
||||
long elapsedTime = acceptTime - startTime;
|
||||
//记录服务响应时间
|
||||
addOperatreFullData(type,object.toString(),result, startTime,elapsedTime,acceptTime,request);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ResponseDTO<String> addOperatreFullData(String type,String params,String result,Long startTime,Long elapsedTime,Long acceptTime,HttpServletRequest request){
|
||||
SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
JSONObject jsonObject = JSONObject.parseObject(result);
|
||||
|
@ -26,7 +26,7 @@ public class CouponFetchEntity {
|
||||
* 会员ID
|
||||
*/
|
||||
@ApiModelProperty(example = "1")
|
||||
private int memberId;
|
||||
private String memberId;
|
||||
|
||||
/**
|
||||
* 手机号码
|
||||
|
@ -25,7 +25,7 @@ public class CouponGetAllEntity {
|
||||
* 会员ID
|
||||
*/
|
||||
@ApiModelProperty(example = "1")
|
||||
private int memberId;
|
||||
private String memberId;
|
||||
|
||||
/**
|
||||
* 手机号码
|
||||
|
@ -0,0 +1,33 @@
|
||||
package net.lab1024.smartadmin.module.system.royalcanin.good;
|
||||
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import net.lab1024.smartadmin.common.anno.OperateLog;
|
||||
import net.lab1024.smartadmin.constant.SwaggerTagConst;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.good.model.GoodsEntity;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.good.service.GoodService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Api(tags = {SwaggerTagConst.Admin.MANAGER_MALL_API})
|
||||
@OperateLog
|
||||
@RestController
|
||||
public class GoodController {
|
||||
|
||||
|
||||
@Autowired
|
||||
private GoodService goodService;
|
||||
|
||||
|
||||
@ApiOperation(value = "商品", notes = "商品查询")
|
||||
@PostMapping("royalcanin/goods")
|
||||
public List<GoodsEntity> transferGoods(@RequestBody GoodsEntity goodsEntity) throws Exception {
|
||||
return goodService.listGoodsByName(goodsEntity);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
package net.lab1024.smartadmin.module.system.royalcanin.good;
|
||||
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import net.lab1024.smartadmin.common.anno.OperateLog;
|
||||
import net.lab1024.smartadmin.common.domain.ResponseDTO;
|
||||
import net.lab1024.smartadmin.common.heartbeat.StringUtil;
|
||||
import net.lab1024.smartadmin.constant.SwaggerTagConst;
|
||||
import net.lab1024.smartadmin.module.system.qrcode.QRCodeUtil;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.good.constant.OrderResponseCodeConst;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.good.model.OrdersEntity;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.good.service.OrderService;
|
||||
import net.lab1024.smartadmin.module.system.wxpay.WxpayService;
|
||||
import net.lab1024.smartadmin.module.system.wxpay.sdk.WXPayUtil;
|
||||
import net.lab1024.smartadmin.module.system.wxpay.wxPayModel.WxPayEntity;
|
||||
import org.omg.PortableInterceptor.SYSTEM_EXCEPTION;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.SortedMap;
|
||||
|
||||
@Api(tags = {SwaggerTagConst.Admin.MANAGER_MALL_API})
|
||||
@OperateLog
|
||||
@RestController
|
||||
public class OrderController {
|
||||
|
||||
@Autowired
|
||||
private OrderService orderService;
|
||||
|
||||
@Autowired
|
||||
private WxpayService wxpayService;
|
||||
|
||||
@ApiOperation(value = "微信支付订单", notes = "生成订单")
|
||||
@PostMapping("royalcanin/generateOrderWX")
|
||||
public ResponseDTO<String> generateOrderWX(@RequestBody List<OrdersEntity> ordersEntityList, HttpServletResponse response) throws Exception {
|
||||
StringBuffer productId = new StringBuffer();
|
||||
StringBuffer productName = new StringBuffer();
|
||||
String memberId = "";
|
||||
String mobile = "";
|
||||
int buyCount = 0;
|
||||
double total_fee = 0 ;
|
||||
WxPayEntity wxPayEntity = new WxPayEntity();
|
||||
OrdersEntity ordersEntity = new OrdersEntity();
|
||||
for (OrdersEntity ordersEntitys:ordersEntityList) {
|
||||
productId.append(ordersEntitys.getProductId()+",");
|
||||
productName.append(ordersEntitys.getProductName()+",");
|
||||
total_fee = total_fee + Double.parseDouble(ordersEntitys.getPayAmount())*ordersEntitys.getBuyCount();
|
||||
memberId = ordersEntitys.getMemberId();
|
||||
mobile = ordersEntitys.getPhoneNumber();
|
||||
buyCount = buyCount + ordersEntitys.getBuyCount();
|
||||
}
|
||||
ordersEntity.setProductId(productId.substring(0,productId.length()-1));
|
||||
ordersEntity.setProductName(productName.substring(0,productName.length()-1));
|
||||
ordersEntity.setOrderAmount(StringUtil.toString(total_fee));
|
||||
ordersEntity.setMemberId(memberId);
|
||||
ordersEntity.setPhoneNumber(mobile);
|
||||
ordersEntity.setBuyCount(buyCount);
|
||||
if(orderService.generateOrder(ordersEntity) == 1){
|
||||
wxPayEntity.setProduct_id(ordersEntity.getProductId());
|
||||
wxPayEntity.setTotal_fee(StringUtil.toString(total_fee));
|
||||
wxPayEntity.setOut_trade_no(ordersEntity.getOrderNo());
|
||||
QRCodeUtil.createCodeToOutputStream(wxpayService.generateQRCode(wxPayEntity), response.getOutputStream());
|
||||
}
|
||||
return ResponseDTO.wrap(OrderResponseCodeConst.GENERATE_ORDER_FAIL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ApiOperation(value = "更新订单", notes = "更新订单")
|
||||
@RequestMapping(value = "royalcanin/updateOrderWX",method = RequestMethod.POST)
|
||||
public void updateOrder(HttpServletRequest request, HttpServletResponse response){
|
||||
wxpayService.orderCallBack(request,response);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "取消订单", notes = "取消订单")
|
||||
@RequestMapping(value = "royalcanin/cancelOrder",method = RequestMethod.POST)
|
||||
public ResponseDTO<String> cancelOrder(String orderNo) throws Exception {
|
||||
return orderService.cancelOrder(orderNo);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package net.lab1024.smartadmin.module.system.royalcanin.good.constant;
|
||||
|
||||
import net.lab1024.smartadmin.common.constant.ResponseCodeConst;
|
||||
|
||||
public class OrderResponseCodeConst extends ResponseCodeConst {
|
||||
|
||||
|
||||
public static final OrderResponseCodeConst COUPON_USE_FAIL = new OrderResponseCodeConst(9001, "优惠卷使用失败!");
|
||||
|
||||
|
||||
public static final OrderResponseCodeConst GENERATE_ORDER_FAIL = new OrderResponseCodeConst(9002, "订单生成失败!");
|
||||
|
||||
public OrderResponseCodeConst(int code, String msg) {
|
||||
super(code, msg);
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package net.lab1024.smartadmin.module.system.royalcanin.good.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.good.model.FlowEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
@Component
|
||||
public interface FlowDao extends BaseMapper<FlowEntity> {
|
||||
|
||||
void batchInsert(List<FlowEntity> flowEntities);
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package net.lab1024.smartadmin.module.system.royalcanin.good.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.good.model.GoodsEntity;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.good.model.OrdersEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
@Component
|
||||
public interface GoodsDao extends BaseMapper<OrdersEntity> {
|
||||
|
||||
GoodsEntity findByProductCode(String productCode);
|
||||
|
||||
List<GoodsEntity> selectRoleIdByGoodsName(String goodsName);
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package net.lab1024.smartadmin.module.system.royalcanin.good.dao;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.good.model.OrdersEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 订单
|
||||
* @author scy 2019/3/6
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface OrdersDao extends BaseMapper<OrdersEntity> {
|
||||
|
||||
|
||||
OrdersEntity findByOrderId(String id);
|
||||
|
||||
Integer updateOrderStatus(String out_trade_no,String total_amount);
|
||||
|
||||
Integer cancelOrder(String out_trade_no);
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package net.lab1024.smartadmin.module.system.royalcanin.good.model;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@TableName("t_good_goods")
|
||||
public class FlowEntity {
|
||||
|
||||
private String flowNo;
|
||||
|
||||
private String orderNo;
|
||||
|
||||
private String PayAmount;
|
||||
|
||||
private int payType;
|
||||
|
||||
private int buyCount;
|
||||
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package net.lab1024.smartadmin.module.system.royalcanin.good.model;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@TableName("t_good_goods")
|
||||
public class GoodsEntity {
|
||||
private String productName;
|
||||
|
||||
private String price;
|
||||
|
||||
private String productCode;
|
||||
|
||||
private String brandCode;
|
||||
|
||||
private String brandName;
|
||||
|
||||
private String categoryName;
|
||||
|
||||
private int petType;
|
||||
|
||||
private String tagUsedAge;
|
||||
|
||||
private String sliding_picture;
|
||||
|
||||
private String body_picture;
|
||||
|
||||
private int isSales;
|
||||
|
||||
private int isShow;
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package net.lab1024.smartadmin.module.system.royalcanin.good.model;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@TableName("t_good_orders")
|
||||
public class OrdersEntity {
|
||||
|
||||
private String orderNo;
|
||||
|
||||
private String orderStatus;
|
||||
|
||||
private String orderAmount;
|
||||
|
||||
private String payAmount ="";
|
||||
|
||||
private String productId;
|
||||
|
||||
private String productName;
|
||||
|
||||
private int buyCount;
|
||||
|
||||
private Date payTime;
|
||||
|
||||
private String couponCode="";
|
||||
|
||||
private String couponAmount="0";
|
||||
|
||||
private String couponId="";
|
||||
|
||||
private String couponName="";
|
||||
|
||||
private String memberId="";
|
||||
|
||||
private String phoneNumber="";
|
||||
|
||||
private String payType="1";
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package net.lab1024.smartadmin.module.system.royalcanin.good.service;
|
||||
|
||||
import net.lab1024.smartadmin.common.domain.ResponseDTO;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.good.dao.FlowDao;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.good.dao.GoodsDao;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.good.dao.OrdersDao;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.good.model.FlowEntity;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.good.model.GoodsEntity;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.good.model.OrdersEntity;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class GoodService {
|
||||
|
||||
@Autowired
|
||||
private OrdersDao ordersDao;
|
||||
|
||||
@Autowired
|
||||
private GoodsDao goodsDao;
|
||||
|
||||
@Autowired
|
||||
private FlowDao flowDao;
|
||||
|
||||
|
||||
public OrdersEntity getOrderById(String OrderNo){
|
||||
return ordersDao.findByOrderId(OrderNo);
|
||||
}
|
||||
|
||||
public GoodsEntity getGoodsById(String productCode){
|
||||
return goodsDao.findByProductCode(productCode);
|
||||
}
|
||||
|
||||
public int updateOrderStatus(String out_trade_no,String total_amount){
|
||||
return ordersDao.updateOrderStatus(out_trade_no,total_amount);
|
||||
}
|
||||
|
||||
public int addOrder(OrdersEntity ordersEntity){
|
||||
return ordersDao.insert(ordersEntity);
|
||||
}
|
||||
|
||||
public ResponseDTO<String> batchAddFlow(List<FlowEntity> flowEntities){
|
||||
flowDao.batchInsert(flowEntities);
|
||||
return ResponseDTO.succ();
|
||||
}
|
||||
|
||||
public List<GoodsEntity> listGoodsByName(GoodsEntity goodsEntity){
|
||||
return goodsDao.selectRoleIdByGoodsName(goodsEntity.getProductName());
|
||||
}
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
package net.lab1024.smartadmin.module.system.royalcanin.good.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import net.lab1024.smartadmin.common.domain.ResponseDTO;
|
||||
import net.lab1024.smartadmin.module.system.employee.constant.EmployeeResponseCodeConst;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.CouponService;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.coupon.CouponCosumeEntity;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.coupon.CouponFetchEntity;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.good.constant.OrderResponseCodeConst;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.good.dao.OrdersDao;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.good.model.OrdersEntity;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.orderMaster.AddOrSaveEntity;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.orderMaster.QueryEntity;
|
||||
import net.lab1024.smartadmin.module.system.wxpay.WxpayService;
|
||||
import net.lab1024.smartadmin.module.system.wxpay.wxPayModel.WxPayEntity;
|
||||
import net.lab1024.smartadmin.util.GenerateSequenceUtil;
|
||||
import net.lab1024.smartadmin.util.MapRemoveNullUtil;
|
||||
import net.lab1024.smartadmin.util.SmartHttpUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class OrderService {
|
||||
|
||||
@Autowired
|
||||
private CouponService couponService;
|
||||
|
||||
@Autowired
|
||||
private OrdersDao ordersDao;
|
||||
|
||||
private String url = "http://miniapp-test.royalcanin.com.cn:7080/crm/h5/orderMaster/";
|
||||
|
||||
@Transactional
|
||||
public int generateOrder(OrdersEntity ordersEntity) throws Exception {
|
||||
if (ordersEntity.getCouponCode() != ""&& null != ordersEntity.getCouponCode()) {
|
||||
CouponCosumeEntity couponCosumeEntity = new CouponCosumeEntity();
|
||||
couponCosumeEntity.setCouponCode(ordersEntity.getCouponCode());
|
||||
JSONObject jsonObject = JSONObject.parseObject(couponService.couponCosume(couponCosumeEntity));
|
||||
if(!jsonObject.getString("code").equals("0")) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
ordersEntity.setOrderNo(GenerateSequenceUtil.generateSequenceNo());
|
||||
ordersEntity.setOrderStatus("0");
|
||||
return ordersDao.insert(ordersEntity);
|
||||
}
|
||||
|
||||
public Boolean afterPaySucceedUpdateOrderStatus(String outTradeNo,String totalFee){
|
||||
int result = ordersDao.updateOrderStatus(outTradeNo,totalFee);
|
||||
if(result == 1)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public ResponseDTO<String> cancelOrder(String orderNo) throws Exception {
|
||||
OrdersEntity ordersEntity = ordersDao.findByOrderId(orderNo);
|
||||
if(ordersEntity.getCouponCode() != ""&& null!= ordersEntity.getCouponCode()){
|
||||
CouponFetchEntity couponFetchEntity = new CouponFetchEntity();
|
||||
couponFetchEntity.setChannelId(15);
|
||||
couponFetchEntity.setChannelSecurity("H5@2021");
|
||||
couponFetchEntity.setCouponId(ordersEntity.getCouponId());
|
||||
couponFetchEntity.setMemberId(ordersEntity.getMemberId());
|
||||
couponService.couponFetch(couponFetchEntity);
|
||||
}
|
||||
if(ordersDao.cancelOrder(orderNo) == 1){
|
||||
AddOrSaveEntity addOrSaveEntity = new AddOrSaveEntity();
|
||||
addOrSaveEntity.setChannelId("15");
|
||||
addOrSaveEntity.setSecret("H5@2021");
|
||||
addOrSaveEntity.setOrderNumber(orderNo);
|
||||
addOrSaveEntity.setPhoneNumber(ordersEntity.getPhoneNumber());
|
||||
addOrSaveEntity.setStatus("3");
|
||||
addOrSave(addOrSaveEntity);
|
||||
}
|
||||
return ResponseDTO.succ();
|
||||
}
|
||||
|
||||
|
||||
public String addOrSave(AddOrSaveEntity addOrSaveEntity)throws Exception{
|
||||
Map<String, String> paramMap = MapRemoveNullUtil.setConditionMap(addOrSaveEntity);
|
||||
net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(paramMap);
|
||||
return SmartHttpUtil.httpPostRaw(url+"addOrSave",jsonObject.toString(),null,"utf-8");
|
||||
}
|
||||
|
||||
public String query(QueryEntity queryEntity)throws Exception{
|
||||
Map<String, String> paramMap = MapRemoveNullUtil.setConditionMap(queryEntity);
|
||||
net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(paramMap);
|
||||
return SmartHttpUtil.httpPostRaw(url+"query",jsonObject.toString(),null,"utf-8");
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package net.lab1024.smartadmin.module.system.royalcanin.orderMaster;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class AddOrSaveEntity {
|
||||
|
||||
private String channelId;
|
||||
|
||||
private String secret;
|
||||
|
||||
private String orderNumber;
|
||||
|
||||
private String phoneNumber;
|
||||
|
||||
private String salesAmount;
|
||||
|
||||
private String status;
|
||||
|
||||
private String paymentResult;
|
||||
|
||||
private String paymentAmount;
|
||||
|
||||
private String orderDate;
|
||||
|
||||
private String paymentToken;
|
||||
|
||||
private String deliveryType;
|
||||
|
||||
private OrderDatilListEntity orderDatilListEntity;
|
||||
|
||||
private OrderCouponEntity orderCouponEntity;
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package net.lab1024.smartadmin.module.system.royalcanin.orderMaster;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class OrderCouponEntity {
|
||||
|
||||
private String couponCode;
|
||||
|
||||
private String amount;
|
||||
|
||||
private String couponId;
|
||||
|
||||
private String couponName;
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package net.lab1024.smartadmin.module.system.royalcanin.orderMaster;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class OrderDatilListEntity {
|
||||
|
||||
private String productId;
|
||||
|
||||
private String productCode;
|
||||
|
||||
private String productName;
|
||||
|
||||
private String pcs;
|
||||
|
||||
private String ecPrice;
|
||||
|
||||
private String logisticsCompany;
|
||||
|
||||
private String logisticsNumber;
|
||||
|
||||
private String status;
|
||||
|
||||
private String logisticsDate;
|
||||
|
||||
private String bearCost;
|
||||
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package net.lab1024.smartadmin.module.system.royalcanin.orderMaster;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class QueryEntity {
|
||||
|
||||
private String channelId;
|
||||
|
||||
private String secret;
|
||||
|
||||
private String orderNumber;
|
||||
|
||||
private String phoneNumber;
|
||||
|
||||
}
|
@ -16,6 +16,7 @@ public class MyConfig implements WXPayConfig {
|
||||
// private String path ="C:/Users/Administrator/IdeaProjects/smart-admin/smart-admin-service/smart-admin-api/src/main/resources/wxpay/";
|
||||
private String path ="/home/royalcanin-dev/cert/";
|
||||
|
||||
public String notify_url = "http://47.96.75.242:10086/smart-admin-api/royalcanin/updateOrderWX";
|
||||
|
||||
private byte[] certData;
|
||||
|
||||
|
@ -6,20 +6,23 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import net.lab1024.smartadmin.common.anno.OperateLog;
|
||||
import net.lab1024.smartadmin.constant.SwaggerTagConst;
|
||||
import net.lab1024.smartadmin.module.system.qrcode.QRCodeUtil;
|
||||
import net.lab1024.smartadmin.module.system.wxpay.wxPay.WxPayEntity;
|
||||
import net.lab1024.smartadmin.module.system.wxpay.sdk.WXPayUtil;
|
||||
import net.lab1024.smartadmin.module.system.wxpay.wxPayModel.WxPayEntity;
|
||||
import net.lab1024.smartadmin.util.GenerateSequenceUtil;
|
||||
import net.lab1024.smartadmin.util.MapRemoveNullUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.Inet4Address;
|
||||
import java.net.InetAddress;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.SortedMap;
|
||||
|
||||
@Api(tags = {SwaggerTagConst.Admin.MANAGER_MALL_PAY_API})
|
||||
@OperateLog
|
||||
@ -30,6 +33,8 @@ public class WxpayController {
|
||||
@Autowired
|
||||
private MyConfig config;
|
||||
|
||||
@Autowired
|
||||
private WxpayService wxpayService;
|
||||
|
||||
@GetMapping("royalcanin/qrCode")
|
||||
public void getQRCode(String codeContent, HttpServletResponse response) {
|
||||
@ -48,9 +53,12 @@ public class WxpayController {
|
||||
|
||||
@PostMapping("royalcanin/unifiedOrder")
|
||||
public void unifiedOrder(@RequestBody WxPayEntity wxPayEntity, HttpServletResponse response) throws Exception {
|
||||
// wxpayService.generateQRCode(wxPayEntity,response);
|
||||
|
||||
WXPay wxpay = new WXPay(config);
|
||||
InetAddress ip4 = Inet4Address.getLocalHost();
|
||||
Map<String,String> data = MapRemoveNullUtil.setConditionMap(wxPayEntity);
|
||||
data.put("out_trade_no", GenerateSequenceUtil.generateSequenceNo());
|
||||
data.put("spbill_create_ip", ip4.getHostAddress());
|
||||
data.put("trade_type", "NATIVE"); // 此处指定为扫码支付
|
||||
data.put("body","皇家宠物食品官方商城");
|
||||
@ -89,5 +97,56 @@ public class WxpayController {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信支付回调接口
|
||||
*/
|
||||
// @RequestMapping("royalcanin/wechatnotify")
|
||||
// public void OrderCallBack(HttpServletRequest request, HttpServletResponse response) {
|
||||
// InputStream inputStream = null;
|
||||
// try {
|
||||
// inputStream = request.getInputStream();
|
||||
// // BufferedReader是包装设计模式,性能更高
|
||||
// BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
|
||||
// StringBuffer stringBuffer = new StringBuffer();
|
||||
// String line;
|
||||
// while ((line = bufferedReader.readLine()) != null) {
|
||||
// stringBuffer.append(line);
|
||||
// }
|
||||
// bufferedReader.close();
|
||||
// inputStream.close();
|
||||
// Map<String, String> callBackMap = WXPayUtil.xmlToMap(stringBuffer.toString());
|
||||
// System.out.println(callBackMap.toString());
|
||||
//
|
||||
// SortedMap<String, String> sortedMap = WXPayUtil.getSortedMap(callBackMap);
|
||||
// // 校验签名是否正确
|
||||
// if (WXPayUtil.isCorrectSign(sortedMap, config.getKey())) {
|
||||
// System.out.println("签名校验成功!");
|
||||
// // 更新订单状态
|
||||
// if ("SUCCESS".equals(sortedMap.get("result_code"))) {
|
||||
// String outTradeNo = sortedMap.get("out_trade_no"); // 订单号
|
||||
// String totalFee = sortedMap.get("total_fee"); // 交易金额
|
||||
// if (wxPayService.callBackPayUpdate(outTradeNo, totalFee)) { // 通知微信订单处理成功
|
||||
// response.setContentType("text/xml");
|
||||
// response.setContentType("content-type");
|
||||
// response.getWriter().println("<xml> <return_code><![CDATA[SUCCESS]]></return_code> <return_msg><![CDATA[OK]]></return_msg> </xml>");
|
||||
// //这里说明告诉微信你已经成功啦,别给老子重复回调我的方法啦,这里有一个坑,
|
||||
// response.setContentType("text/xml");
|
||||
// response.getWriter().println("SUCCESS");
|
||||
// //本身我就只有这两句话,然后就导致微信一直回调我的方法,废了半天的劲才搞好啦,
|
||||
// //原因就是格式不对,给他返回的值他不认识,这里可以看一下微信的支付开发文档,虽然文档写的很垃圾
|
||||
// }
|
||||
// }
|
||||
// // 未成功,就都处理为失败订单
|
||||
// response.setContentType("text/html");
|
||||
// response.getWriter().println("fail");
|
||||
// }
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,132 @@
|
||||
package net.lab1024.smartadmin.module.system.wxpay;
|
||||
|
||||
import net.lab1024.smartadmin.common.domain.ResponseDTO;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.good.model.OrdersEntity;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.good.service.OrderService;
|
||||
import net.lab1024.smartadmin.module.system.wxpay.sdk.WXPay;
|
||||
import net.lab1024.smartadmin.module.system.wxpay.sdk.WXPayUtil;
|
||||
import net.lab1024.smartadmin.module.system.wxpay.wxPayModel.WxPayEntity;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.Inet4Address;
|
||||
import java.net.InetAddress;
|
||||
import java.util.Map;
|
||||
import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
|
||||
@Service
|
||||
public class WxpayService {
|
||||
|
||||
@Autowired
|
||||
private MyConfig config;
|
||||
|
||||
@Autowired
|
||||
private OrderService orderService;
|
||||
|
||||
public String generateQRCode(WxPayEntity wxPayEntity) throws Exception {
|
||||
WXPay wxpay = new WXPay(config);
|
||||
InetAddress ip4 = Inet4Address.getLocalHost();
|
||||
SortedMap<String,String> data = new TreeMap<>();
|
||||
data.put("out_trade_no",wxPayEntity.getOut_trade_no());
|
||||
data.put("notify_url",config.notify_url);
|
||||
data.put("fee_type","CNY");
|
||||
data.put("total_fee",getMoney(wxPayEntity.getTotal_fee()));
|
||||
data.put("spbill_create_ip", ip4.getHostAddress());
|
||||
data.put("trade_type", "NATIVE"); // 此处指定为扫码支付
|
||||
data.put("body","皇家宠物食品官方商城");
|
||||
data.put("nonce_str", WXPayUtil.generateNonceStr());
|
||||
data.put("product_id",wxPayEntity.getProduct_id());
|
||||
try {
|
||||
Map<String, String> resp = wxpay.unifiedOrder(data);
|
||||
if (resp != null) {
|
||||
return resp.get("code_url");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void orderCallBack(HttpServletRequest request, HttpServletResponse response) {
|
||||
InputStream inputStream = null;
|
||||
try {
|
||||
inputStream = request.getInputStream();
|
||||
// BufferedReader是包装设计模式,性能更高
|
||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
String line;
|
||||
while ((line = bufferedReader.readLine()) != null) {
|
||||
stringBuffer.append(line);
|
||||
}
|
||||
bufferedReader.close();
|
||||
inputStream.close();
|
||||
Map<String, String> callBackMap = WXPayUtil.xmlToMap(stringBuffer.toString());
|
||||
System.out.println(callBackMap.toString());
|
||||
|
||||
SortedMap<String, String> sortedMap = WXPayUtil.getSortedMap(callBackMap);
|
||||
// 校验签名是否正确
|
||||
if (WXPayUtil.isCorrectSign(sortedMap, config.getKey())) {
|
||||
System.out.println("签名校验成功!");
|
||||
// 更新订单状态
|
||||
if ("SUCCESS".equals(sortedMap.get("result_code"))) {
|
||||
String outTradeNo = sortedMap.get("out_trade_no"); // 流水号
|
||||
String totalFee = sortedMap.get("total_fee"); // 交易金额
|
||||
if (orderService.afterPaySucceedUpdateOrderStatus(outTradeNo,totalFee)) {
|
||||
response.setContentType("text/xml");
|
||||
response.setContentType("content-type");
|
||||
response.getWriter().println("<xml> <return_code><![CDATA[SUCCESS]]></return_code> <return_msg><![CDATA[OK]]></return_msg> </xml>");
|
||||
//这里说明告诉微信你已经成功啦,别给老子重复回调我的方法啦,这里有一个坑,
|
||||
response.setContentType("text/xml");
|
||||
response.getWriter().println("SUCCESS");
|
||||
//本身我就只有这两句话,然后就导致微信一直回调我的方法,废了半天的劲才搞好啦,
|
||||
//原因就是格式不对,给他返回的值他不认识,这里可以看一下微信的支付开发文档,虽然文档写的很垃圾
|
||||
}
|
||||
}
|
||||
// 未成功,就都处理为失败订单
|
||||
response.setContentType("text/html");
|
||||
response.getWriter().println("fail");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 元转换成分
|
||||
* @param amount
|
||||
* @return
|
||||
*/
|
||||
public static String getMoney(String amount) {
|
||||
if(amount==null){
|
||||
return "";
|
||||
}
|
||||
// 金额转化为分为单位
|
||||
// 处理包含, ¥ 或者$的金额
|
||||
String currency = amount.replaceAll("\\$|\\¥|\\,", "");
|
||||
int index = currency.indexOf(".");
|
||||
int length = currency.length();
|
||||
Long amLong = 0l;
|
||||
if(index == -1){
|
||||
amLong = Long.valueOf(currency+"00");
|
||||
}else if(length - index >= 3){
|
||||
amLong = Long.valueOf((currency.substring(0, index+3)).replace(".", ""));
|
||||
}else if(length - index == 2){
|
||||
amLong = Long.valueOf((currency.substring(0, index+2)).replace(".", "")+0);
|
||||
}else{
|
||||
amLong = Long.valueOf((currency.substring(0, index+1)).replace(".", "")+"00");
|
||||
}
|
||||
return amLong.toString();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package net.lab1024.smartadmin.module.system.wxpay.sdk;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
public class MD5Util {
|
||||
|
||||
public static String MD5(String source) {
|
||||
return encodeMd5(source.getBytes());
|
||||
}
|
||||
private static String encodeMd5(byte[] source) {
|
||||
try {
|
||||
return encodeHex(MessageDigest.getInstance("MD5").digest(source));
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new IllegalStateException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private static String encodeHex(byte[] bytes) {
|
||||
StringBuffer buffer = new StringBuffer(bytes.length * 2);
|
||||
for (int i = 0; i < bytes.length; i++) {
|
||||
if(((int) bytes[i] & 0xff) < 0x10) {
|
||||
buffer.append("0");
|
||||
}
|
||||
buffer.append(Long.toString((int) bytes[i] & 0xff, 16));
|
||||
}
|
||||
return buffer.toString();
|
||||
}
|
||||
}
|
@ -267,6 +267,59 @@ public class WXPayUtil {
|
||||
return sb.toString().toUpperCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取有序map
|
||||
* @param map
|
||||
*/
|
||||
public static SortedMap<String, String> getSortedMap(Map<String, String> map){
|
||||
SortedMap<String, String> sortedMap = new TreeMap<>();
|
||||
Iterator<String> it = map.keySet().iterator();
|
||||
while(it.hasNext()){
|
||||
String key = it.next();
|
||||
String value = map.get(key);
|
||||
String temp = "";
|
||||
if(null != value){
|
||||
temp = value.trim();
|
||||
}
|
||||
sortedMap.put(key, value);
|
||||
}
|
||||
return sortedMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验签名
|
||||
* @param params
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public static Boolean isCorrectSign(SortedMap<String, String> params, String key){
|
||||
String sign = createSign(params, key);
|
||||
String wxPaySign = params.get("sign").toUpperCase();
|
||||
|
||||
return wxPaySign.equals(sign);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成微信支付sign
|
||||
*/
|
||||
public static String createSign(SortedMap<String, String> params, String key){
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Set<Map.Entry<String, String>> es = params.entrySet();
|
||||
Iterator<Map.Entry<String, String>> it = es.iterator();
|
||||
while(it.hasNext()){
|
||||
Map.Entry<String, String> entry = it.next();
|
||||
String k = entry.getKey();
|
||||
String v = entry.getValue();
|
||||
if(null != v && !"".equals(v) && !"sign".equals(k) && !"key".equals(k)){
|
||||
sb.append(k + "=" + v + "&");
|
||||
}
|
||||
}
|
||||
sb.append("key=").append(key);
|
||||
String sign = MD5Util.MD5(sb.toString()).toUpperCase();
|
||||
|
||||
return sign;
|
||||
}
|
||||
|
||||
/**
|
||||
* 日志
|
||||
* @return
|
||||
|
@ -1,7 +1,6 @@
|
||||
package net.lab1024.smartadmin.module.system.wxpay.wxPay;
|
||||
package net.lab1024.smartadmin.module.system.wxpay.wxPayModel;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
||||
@Data
|
||||
public class WxPayEntity {
|
||||
@ -10,10 +9,6 @@ public class WxPayEntity {
|
||||
|
||||
public String out_trade_no;
|
||||
|
||||
public String device_info;
|
||||
|
||||
public String fee_type;
|
||||
|
||||
public String total_fee;
|
||||
|
||||
public String spbill_create_ip;
|
@ -0,0 +1,52 @@
|
||||
package net.lab1024.smartadmin.util;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.FieldPosition;
|
||||
import java.text.Format;
|
||||
import java.text.NumberFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
|
||||
|
||||
public class GenerateSequenceUtil {
|
||||
|
||||
/** .log */
|
||||
|
||||
/** The FieldPosition. */
|
||||
private static final FieldPosition HELPER_POSITION = new FieldPosition(0);
|
||||
|
||||
/** This Format for format the data to special format. */
|
||||
private final static Format dateFormat = new SimpleDateFormat("MMddHHmmssS");
|
||||
|
||||
/** This Format for format the number to special format. */
|
||||
private final static NumberFormat numberFormat = new DecimalFormat("0000");
|
||||
|
||||
/** This int is the sequence number ,the default value is 0. */
|
||||
private static int seq = 0;
|
||||
|
||||
private static final int MAX = 9999;
|
||||
|
||||
/**
|
||||
* ʱ<EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* @return String
|
||||
*/
|
||||
public static synchronized String generateSequenceNo() {
|
||||
|
||||
Calendar rightNow = Calendar.getInstance();
|
||||
|
||||
StringBuffer sb = new StringBuffer();
|
||||
|
||||
dateFormat.format(rightNow.getTime(), sb, HELPER_POSITION);
|
||||
|
||||
numberFormat.format(seq, sb, HELPER_POSITION);
|
||||
|
||||
if (seq == MAX) {
|
||||
seq = 0;
|
||||
} else {
|
||||
seq++;
|
||||
}
|
||||
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="net.lab1024.smartadmin.module.system.royalcanin.good.dao.OrdersDao">
|
||||
<resultMap id="OrdersEntity"
|
||||
type="net.lab1024.smartadmin.module.system.royalcanin.good.model.OrdersEntity"></resultMap>
|
||||
|
||||
<select id="findByOrderId" resultMap="OrdersEntity">
|
||||
select * from t_good_orders WHERE id = #{orderNo}
|
||||
</select>
|
||||
|
||||
|
||||
<update id="updateOrderStatus" >
|
||||
update t_good_orders where order_no = #{out_trade_no}
|
||||
set order_status ='1' ,pay_amount = #{total_amount}
|
||||
|
||||
</update>
|
||||
|
||||
<update id="cancelOrder" >
|
||||
update t_good_orders where order_no = #{out_trade_no}
|
||||
set order_status ='3'
|
||||
|
||||
</update>
|
||||
</mapper>
|
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="net.lab1024.smartadmin.module.system.royalcanin.good.dao.FlowDao">
|
||||
<resultMap id="FlowEntity"
|
||||
type="net.lab1024.smartadmin.module.system.royalcanin.good.model.FlowEntity"></resultMap>
|
||||
|
||||
<select id="findByflowNo" resultMap="FlowEntity">
|
||||
select * from t_good_flow WHERE flow_no = #{flow_no}
|
||||
</select>
|
||||
|
||||
<insert id="batchInsert" useGeneratedKeys="true" keyProperty="id" parameterType="java.util.List">
|
||||
INSERT INTO t_good_flow (flow_no,order_no, product_id, pay_amount, pay_type, buy_count) VALUES
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(#{item.flowNo},
|
||||
#{item.orderNo},
|
||||
#{item.productId},
|
||||
#{item.payAmount},
|
||||
#{item.payType},
|
||||
#{item.buyCount},
|
||||
now()
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="net.lab1024.smartadmin.module.system.royalcanin.good.dao.GoodsDao">
|
||||
<resultMap id="GoodsEntity"
|
||||
type="net.lab1024.smartadmin.module.system.royalcanin.good.model.GoodsEntity"></resultMap>
|
||||
|
||||
<select id="findByProductCode" resultMap="GoodsEntity">
|
||||
select * from t_good_goods WHERE productCode = #{productCode}
|
||||
</select>
|
||||
|
||||
<select id="selectRoleIdByGoodsName" resultMap="GoodsEntity">
|
||||
select
|
||||
product_code,
|
||||
product_name,
|
||||
price,
|
||||
brand_code,
|
||||
brand_name,
|
||||
category_name,
|
||||
pet_type,
|
||||
tagUsedAge,
|
||||
sliding_picture,
|
||||
body_picture,
|
||||
isSales
|
||||
from t_good_goods
|
||||
<where>
|
||||
<if test="product_name != null and product_name != ''">
|
||||
<bind name="productName" value=" '%' + product_name +'%' "></bind>
|
||||
AND product_name like #{productName}
|
||||
</if>
|
||||
<if test="product_name == null and product_name == ''">
|
||||
AND isShow = 1
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -1607,3 +1607,62 @@ CREATE TABLE IF NOT EXISTS `t_royalcanin_operate_log` (
|
||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||
|
||||
|
||||
CREATE TABLE `t_good_user` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '用户Id',
|
||||
`username` varchar(128) DEFAULT NULL COMMENT '用户名',
|
||||
`sex` varchar(20) DEFAULT NULL COMMENT '性别',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8 COMMENT='产品用户表';
|
||||
|
||||
CREATE TABLE `t_good_flow` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`flow_no` varchar(32) DEFAULT NULL COMMENT '流水号',
|
||||
`order_no` varchar(20) DEFAULT NULL COMMENT '订单号',
|
||||
`product_id` varchar(20) DEFAULT NULL COMMENT '产品主键ID',
|
||||
`pay_amount` varchar(11) DEFAULT NULL COMMENT '支付金额',
|
||||
`pay_type` int(11) DEFAULT NULL COMMENT '支付方式\r\n 1:支付宝\r\n 2:微信',
|
||||
`buy_count` int(11) DEFAULT NULL COMMENT '购买个数',
|
||||
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='产品流水表';
|
||||
|
||||
CREATE TABLE `t_good_orders` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`order_no` varchar(20) DEFAULT NULL COMMENT '订单号',
|
||||
`order_status` varchar(20) DEFAULT NULL COMMENT '订单状态\r\n 10:待付款\r\n 20:已付款',
|
||||
`order_amount` varchar(11) DEFAULT NULL COMMENT '订单金额',
|
||||
`pay_amount` varchar(11) DEFAULT NULL COMMENT '实际支付金额',
|
||||
`product_id` varchar(20) DEFAULT NULL COMMENT '产品表外键ID',
|
||||
`coupon_code` varchar(20) DEFAULT NULL COMMENT '优惠券code',
|
||||
`coupon_id` varchar(20) DEFAULT NULL COMMENT '优惠券ID',
|
||||
`coupon_name` varchar(20) DEFAULT NULL COMMENT '优惠券名字',
|
||||
`coupon_amount` varchar(20) DEFAULT NULL COMMENT '优惠券金额',
|
||||
`product_name` varchar(50) DEFAULT NULL COMMENT '产品名字',
|
||||
`member_id` varchar(20) DEFAULT NULL COMMENT '用户member',
|
||||
`phone_number` varchar(20) DEFAULT NULL COMMENT '用户手机',
|
||||
`buy_count` int(11) DEFAULT NULL COMMENT '产品购买的个数',
|
||||
`pay_type` int(11) DEFAULT NULL COMMENT '支付方式 1:支付宝 2:微信',
|
||||
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '订单创建时间',
|
||||
`pay_time` datetime DEFAULT NULL COMMENT '支付时间',
|
||||
`remark` varchar(20) DEFAULT NULL COMMENT '备注',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='订单表';
|
||||
|
||||
CREATE TABLE `t_good_goods` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`product_code` VARCHAR(20) NOT NULL COMMENT '标品编码',
|
||||
`product_name` varchar(20) DEFAULT NULL COMMENT '产品名称',
|
||||
`price` varchar(11) DEFAULT NULL COMMENT '价格',
|
||||
`brand_code` varchar(11) DEFAULT NULL COMMENT '品牌编码',
|
||||
`brand_name` varchar(11) DEFAULT NULL COMMENT '品牌名称',
|
||||
`category_name` varchar(11) DEFAULT NULL COMMENT '品类',
|
||||
`pet_type` int(11) DEFAULT NULL COMMENT '宠物类型',
|
||||
`tagUsedAge` varchar(11) DEFAULT NULL COMMENT '适用阶段',
|
||||
`sliding_picture` varchar(200) DEFAULT NULL COMMENT '标品头图',
|
||||
`body_picture` varchar(200) DEFAULT NULL COMMENT '身体头图',
|
||||
`isSales` int(11) DEFAULT NULL COMMENT '0:未销售,1:销售',
|
||||
`isShow` int(11) DEFAULT NULL COMMENT '0:不展示,1:展示',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='产品表 ';
|
Loading…
Reference in New Issue
Block a user