mirror of
https://gitee.com/lab1024/smart-admin.git
synced 2025-10-03 10:46:38 +08:00
Merge branch 'sit-Carl' into sit-jiamin-v2
This commit is contained in:
commit
8b890c44d7
@ -1,6 +1,5 @@
|
||||
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;
|
||||
@ -13,7 +12,6 @@ import net.lab1024.smartadmin.module.system.royalcanin.orderMaster.QueryEntity;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
@Service
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.lab1024.smartadmin.module.system.alipay;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alipay.api.AlipayApiException;
|
||||
import com.alipay.api.AlipayClient;
|
||||
import com.alipay.api.DefaultAlipayClient;
|
||||
@ -10,10 +11,21 @@ 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.common.heartbeat.StringUtil;
|
||||
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.MemberAccountService;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.good.model.OrderEntity;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.good.model.ProductMasterQueryEntity;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.good.service.OrderService;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.memberAccount.MemberAccountChangeEntity;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.notify.model.NotifyEntity;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.notify.service.NotifyService;
|
||||
import net.lab1024.smartadmin.util.MapRemoveNullUtil;
|
||||
import net.lab1024.smartadmin.util.SmartHttpUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@ -23,7 +35,7 @@ import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
@Api(tags = {SwaggerTagConst.Admin.MANAGER_MALL_PAY_API})
|
||||
@Api(tags = {SwaggerTagConst.Admin.MANAGER_MALL_API})
|
||||
@OperateLog
|
||||
@Slf4j
|
||||
@RestController
|
||||
@ -32,6 +44,17 @@ public class AlipayController {
|
||||
|
||||
public static String notify_url = "";
|
||||
|
||||
@Autowired
|
||||
private OrderService orderService;
|
||||
|
||||
String url = "https://miniapp-test.royalcanin.com.cn/rcmini/h5/";
|
||||
|
||||
@Autowired
|
||||
private MemberAccountService memberAccountService;
|
||||
|
||||
@Autowired
|
||||
private NotifyService notifyService;
|
||||
|
||||
/**
|
||||
* @Description: 前往支付宝第三方网关进行支付
|
||||
*/
|
||||
@ -65,47 +88,88 @@ public class AlipayController {
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// @RequestMapping("royalcanin/updateOrderAliPay")
|
||||
// public String returnUrl(HttpServletRequest request) throws Exception {
|
||||
// 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 total_amount = new String(request.getParameter("total_amount").getBytes("ISO-8859-1"),"UTF-8");
|
||||
//
|
||||
//
|
||||
// //支付宝交易号
|
||||
// String trade_no = new String(request.getParameter("trade_no").getBytes("ISO-8859-1"),"UTF-8");
|
||||
// OrderEntity orderEntity = orderService.findByOrderId(out_trade_no);
|
||||
// String[] products = orderEntity.getProductCode().split(",");
|
||||
// ProductMasterQueryEntity productMasterQueryEntity = new ProductMasterQueryEntity();
|
||||
// double basePoint = 0;
|
||||
// //自动获取会员积分
|
||||
// for (String product : products) {
|
||||
// productMasterQueryEntity.setProductCode(product);
|
||||
// Map<String, String> paramMap = MapRemoveNullUtil.setConditionMap(productMasterQueryEntity);
|
||||
// MapRemoveNullUtil.removeNullEntry(paramMap);
|
||||
// paramMap.put("secret", "H5@2021");
|
||||
// paramMap.put("channelId", "15");
|
||||
// String sb = SmartHttpUtil.sendPostForm(url + "productMaster/query", paramMap, null);
|
||||
// JSONObject jsonObject = JSONObject.parseObject(sb);
|
||||
// com.alibaba.fastjson.JSONArray jsonArray = JSONObject.parseArray(jsonObject.getString("data"));
|
||||
// JSONObject jsonObjectData = (JSONObject) jsonArray.get(0);
|
||||
// basePoint = basePoint + Double.parseDouble(jsonObjectData.getString("basePoint"));
|
||||
// }
|
||||
// MemberAccountChangeEntity memberAccountChangeEntity = new MemberAccountChangeEntity();
|
||||
// memberAccountChangeEntity.setChangeTypeId("1");
|
||||
// memberAccountChangeEntity.setChangeValue(StringUtil.toString(basePoint));
|
||||
// memberAccountChangeEntity.setMemberId(orderEntity.getMemberId());
|
||||
// memberAccountService.memberAccountChange(memberAccountChangeEntity);
|
||||
// NotifyEntity notifyEntity = new NotifyEntity();
|
||||
// notifyEntity.setAppId(AlipayConfig.app_id);
|
||||
// notifyEntity.setMchId(request.getParameter("seller_id"));
|
||||
// notifyEntity.setSign(request.getParameter("sign"));
|
||||
// notifyEntity.setResultCode(request.getParameter("code"));
|
||||
// notifyEntity.setOpenid(request.getParameter("merchant_order_no"));
|
||||
// notifyEntity.setOutTradeNo(out_trade_no);
|
||||
// notifyEntity.setTotalFee(total_amount);
|
||||
// notifyEntity.setTradeType(request.getParameter("sub_code"));
|
||||
// notifyEntity.setFeeType("CNY");
|
||||
// notifyEntity.setNonceStr(trade_no);
|
||||
// notifyService.insertNotify(notifyEntity);
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// 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("royalcanin/updateOrderAliPay")
|
||||
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 {
|
||||
|
||||
@ -151,6 +215,7 @@ public class AlipayController {
|
||||
String total_amount = new String(request.getParameter("total_amount").getBytes("ISO-8859-1"), "UTF-8");
|
||||
|
||||
if (trade_status.equals("TRADE_FINISHED")) {
|
||||
return "TRADE_FINISHED";
|
||||
//判断该笔订单是否在商户网站中已经做过处理
|
||||
//如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序
|
||||
//如果有做过处理,不执行商户的业务程序
|
||||
@ -167,23 +232,48 @@ public class AlipayController {
|
||||
|
||||
// 修改叮当状态,改为 支付成功,已付款; 同时新增支付流水
|
||||
// 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("***************************************************************");
|
||||
|
||||
OrderEntity orderEntity = orderService.findByOrderId(out_trade_no);
|
||||
String[] products = orderEntity.getProductCode().split(",");
|
||||
ProductMasterQueryEntity productMasterQueryEntity = new ProductMasterQueryEntity();
|
||||
double basePoint = 0;
|
||||
//自动获取会员积分
|
||||
for (String product : products) {
|
||||
productMasterQueryEntity.setProductCode(product);
|
||||
Map<String, String> paramMap = MapRemoveNullUtil.setConditionMap(productMasterQueryEntity);
|
||||
MapRemoveNullUtil.removeNullEntry(paramMap);
|
||||
paramMap.put("secret", "H5@2021");
|
||||
paramMap.put("channelId", "15");
|
||||
String sb = SmartHttpUtil.sendPostForm(url + "productMaster/query", paramMap, null);
|
||||
JSONObject jsonObject = JSONObject.parseObject(sb);
|
||||
com.alibaba.fastjson.JSONArray jsonArray = JSONObject.parseArray(jsonObject.getString("data"));
|
||||
JSONObject jsonObjectData = (JSONObject) jsonArray.get(0);
|
||||
basePoint = basePoint + Double.parseDouble(jsonObjectData.getString("basePoint"));
|
||||
}
|
||||
MemberAccountChangeEntity memberAccountChangeEntity = new MemberAccountChangeEntity();
|
||||
memberAccountChangeEntity.setChangeTypeId("1");
|
||||
memberAccountChangeEntity.setChangeValue(StringUtil.toString(basePoint));
|
||||
memberAccountChangeEntity.setMemberId(orderEntity.getMemberId());
|
||||
memberAccountService.memberAccountChange(memberAccountChangeEntity);
|
||||
NotifyEntity notifyEntity = new NotifyEntity();
|
||||
notifyEntity.setAppId(AlipayConfig.app_id);
|
||||
notifyEntity.setMchId(request.getParameter("seller_id"));
|
||||
notifyEntity.setSign(request.getParameter("sign"));
|
||||
notifyEntity.setResultCode(request.getParameter("code"));
|
||||
notifyEntity.setOpenid(request.getParameter("merchant_order_no"));
|
||||
notifyEntity.setOutTradeNo(out_trade_no);
|
||||
notifyEntity.setTotalFee(total_amount);
|
||||
notifyEntity.setTradeType(request.getParameter("sub_code"));
|
||||
notifyEntity.setFeeType("CNY");
|
||||
notifyEntity.setNonceStr(trade_no);
|
||||
notifyService.insertNotify(notifyEntity);
|
||||
}else {
|
||||
return "验签失败";
|
||||
}
|
||||
// LOGGER.info("支付成功...");
|
||||
|
||||
} else {//验证失败
|
||||
// LOGGER.info("支付, 验签失败...");
|
||||
return "支付, 验签失败";
|
||||
}
|
||||
|
||||
return "success";
|
||||
|
@ -31,9 +31,10 @@ public class MemberService {
|
||||
JSONObject json = JSONObject.parseObject(jsonObject.getString("data"));
|
||||
String id = json.getString("id");
|
||||
jsonObject.put("xaccessToken", SmartJWTUtil.generateToken(id));
|
||||
jsonObject.put("type","1");
|
||||
return jsonObject.toJSONString();
|
||||
}else {
|
||||
return sb;
|
||||
return jsonObject.toJSONString();
|
||||
}
|
||||
}
|
||||
public String memberCheck(MemberCheckEntity memberCheckEntity)throws Exception {
|
||||
@ -42,7 +43,7 @@ public class MemberService {
|
||||
return SmartHttpUtil.sendPostForm(url+"check",paramMap,null);
|
||||
}
|
||||
|
||||
public String memberAdd(MemberAddEntity memberAddEntity)throws Exception {
|
||||
public String memberAdd(MemberAddEntity memberAddEntity){
|
||||
Map<String, String> paramMap = MapRemoveNullUtil.setConditionMap(memberAddEntity);
|
||||
paramMap.put("cityId",StringUtil.toString(memberAddEntity.getCityId()).equals("0")?null:StringUtil.toString(memberAddEntity.getCityId()));
|
||||
paramMap.put("gender",StringUtil.toString(memberAddEntity.getGender()).equals("0")?null:StringUtil.toString(memberAddEntity.getGender()));
|
||||
@ -50,7 +51,17 @@ public class MemberService {
|
||||
paramMap.put("provinceId",StringUtil.toString(memberAddEntity.getProvinceId()).equals("0")?null:StringUtil.toString(memberAddEntity.getProvinceId()));
|
||||
MapRemoveNullUtil.removeNullEntry(paramMap);
|
||||
net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(paramMap);
|
||||
return SmartHttpUtil.httpPostRaw(url+"add",jsonObject.toString(),null,"utf-8");
|
||||
String sb = SmartHttpUtil.httpPostRaw(url+"add",jsonObject.toString(),null,"utf-8");
|
||||
JSONObject jsonObjectResult = JSONObject.parseObject(sb);
|
||||
if(jsonObjectResult.getString("code").equals("0")){
|
||||
JSONObject json = JSONObject.parseObject(jsonObjectResult.getString("data"));
|
||||
String id = json.getString("id");
|
||||
jsonObjectResult.put("xaccessToken", SmartJWTUtil.generateToken(id));
|
||||
jsonObject.put("type","2");
|
||||
return jsonObjectResult.toJSONString();
|
||||
}else {
|
||||
return jsonObjectResult.toJSONString();
|
||||
}
|
||||
}
|
||||
|
||||
public String memberUpdateMemberLevel(MemberUpdateMemberLevelEntity memberUpdateMemberLevelEntity)throws Exception {
|
||||
|
@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import net.lab1024.smartadmin.common.anno.OperateLog;
|
||||
import net.lab1024.smartadmin.common.constant.ResponseCodeConst;
|
||||
import net.lab1024.smartadmin.common.domain.ResponseDTO;
|
||||
@ -15,8 +14,6 @@ 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.OrderEntity;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.good.model.ProductMasterQueryEntity;
|
||||
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.*;
|
||||
@ -28,8 +25,6 @@ import net.lab1024.smartadmin.module.system.royalcanin.memberAddress.MemberAddre
|
||||
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 net.lab1024.smartadmin.util.MapRemoveNullUtil;
|
||||
import net.lab1024.smartadmin.util.SmartHttpUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
@ -38,7 +33,6 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Api(tags = {SwaggerTagConst.Admin.MANAGER_MALL_API})
|
||||
@ -80,13 +74,13 @@ public class TransitionController {
|
||||
switch (type)
|
||||
{
|
||||
case "get":
|
||||
result = memberService.memberGet(objectMapper.convertValue(object,MemberGetEntity.class));
|
||||
result = memberService.memberGet(objectMapper.convertValue(object,MemberGetEntity.class)).toString();
|
||||
break;
|
||||
case "check":
|
||||
result = memberService.memberCheck(objectMapper.convertValue(object,MemberCheckEntity.class));
|
||||
break;
|
||||
case "add":
|
||||
result = memberService.memberAdd(objectMapper.convertValue(object,MemberAddEntity.class));
|
||||
result = memberService.memberAdd(objectMapper.convertValue(object,MemberAddEntity.class)).toString();
|
||||
break;
|
||||
case "updateMemberLevel":
|
||||
result = memberService.memberUpdateMemberLevel(objectMapper.convertValue(object, MemberUpdateMemberLevelEntity.class));
|
||||
@ -105,20 +99,20 @@ public class TransitionController {
|
||||
|
||||
@ApiOperation(value = "登录或注册", notes = "会员查询,登录注册")
|
||||
@PostMapping("royalcanin/regOrLogin")
|
||||
public ResponseDTO<String> regOrLogin(@RequestParam String phoneNumber) throws Exception {
|
||||
public String regOrLogin(@RequestParam String phoneNumber) throws Exception {
|
||||
MemberCheckEntity memberCheckEntity = new MemberCheckEntity();
|
||||
memberCheckEntity.setMobile(phoneNumber);
|
||||
JSONObject jsonObject = JSONObject.parseObject(memberService.memberCheck(memberCheckEntity));
|
||||
if(jsonObject.getString("code").equals("103")){
|
||||
MemberGetEntity memberGetEntity = new MemberGetEntity ();
|
||||
memberGetEntity.setMobile(phoneNumber);
|
||||
return ResponseDTO.succData(memberService.memberGet(memberGetEntity),"1");
|
||||
return memberService.memberGet(memberGetEntity);
|
||||
}else if(jsonObject.getString("code").equals("0")){
|
||||
MemberAddEntity memberAddEntity = new MemberAddEntity();
|
||||
memberAddEntity.setMobile(phoneNumber);
|
||||
return ResponseDTO.succData(memberService.memberAdd(memberAddEntity),"2");
|
||||
return memberService.memberAdd(memberAddEntity);
|
||||
}else{
|
||||
return ResponseDTO.wrap(ResponseCodeConst.ERROR_PARAM);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -136,13 +136,14 @@ public class OrderController {
|
||||
|
||||
@ApiOperation(value = "微信支付H5订单", notes = "生成H5订单")
|
||||
@PostMapping("royalcanin/generateOrderWXH5")
|
||||
public Map<String, String> generateOrderWXH5(@RequestBody List<OrdersEntity> ordersEntityList) throws Exception {
|
||||
public ResponseDTO<Map<String, String>> generateOrderWXH5(@RequestBody List<OrdersEntity> ordersEntityList) throws Exception {
|
||||
StringBuffer productId = new StringBuffer();
|
||||
StringBuffer productName = new StringBuffer();
|
||||
String memberId = "";
|
||||
String mobile = "";
|
||||
int buyCount = 0;
|
||||
double total_fee = 0 ;
|
||||
double basePoint = 0 ;
|
||||
WxPayEntity wxPayEntity = new WxPayEntity();
|
||||
JSONArray orderDatilListJson = new JSONArray();
|
||||
OrdersEntity ordersEntity = new OrdersEntity();
|
||||
@ -157,14 +158,23 @@ public class OrderController {
|
||||
orderDatilListEntity.setEcPrice(ordersEntitys.getPayAmount());
|
||||
orderDatilListJson.add(orderDatilListEntity);
|
||||
if(ordersEntitys.getCouponCode() != "" && ordersEntitys.getCouponCode() != null) {
|
||||
ordersEntity.setCouponAmount(ordersEntitys.getCouponAmount());
|
||||
ordersEntity.setCouponCode(ordersEntitys.getCouponCode());
|
||||
ordersEntity.setCouponName(ordersEntitys.getCouponName());
|
||||
ordersEntity.setCouponId(ordersEntitys.getCouponId());
|
||||
CouponGetAllEntity couponGetAllEntity = new CouponGetAllEntity ();
|
||||
couponGetAllEntity.setMemberId(ordersEntitys.getMemberId());
|
||||
couponGetAllEntity.setCouponCode(ordersEntitys.getCouponCode());
|
||||
String couponInfo = couponService.couponGetAll(couponGetAllEntity);
|
||||
JSONObject jsonObject = JSONObject.parseObject(couponInfo);
|
||||
com.alibaba.fastjson.JSONArray jsonArray = JSONObject.parseArray(jsonObject.getString("data"));
|
||||
JSONObject jsonObjectData = (JSONObject)jsonArray.get(0);
|
||||
|
||||
ordersEntity.setCouponAmount(jsonObjectData.getString("couponAmount") == null ?jsonObjectData.getString("discount"):jsonObjectData.getString("couponAmount"));
|
||||
ordersEntity.setCouponCode(jsonObjectData.getString("couponCode"));
|
||||
ordersEntity.setCouponName(jsonObjectData.getString("couponName"));
|
||||
ordersEntity.setCouponId(jsonObjectData.getString("couponId"));
|
||||
total_fee = total_fee + orderService.couponTotal(ordersEntitys.getCouponTypeId(),Double.parseDouble(ordersEntitys.getCouponAmount()),Double.parseDouble(ordersEntitys.getPayAmount()),ordersEntitys.getBuyCount());
|
||||
}else{
|
||||
total_fee = total_fee + Double.parseDouble(ordersEntitys.getPayAmount()) * ordersEntitys.getBuyCount() ;
|
||||
}
|
||||
basePoint = basePoint + ordersEntitys.getBasePoint();
|
||||
orderAddress.setAddressCityName(ordersEntitys.getOrderAddress().getAddressCityName());
|
||||
orderAddress.setAddressCountyName(ordersEntitys.getOrderAddress().getAddressCountyName());
|
||||
orderAddress.setAddressDetailInfo(ordersEntitys.getOrderAddress().getAddressDetailInfo());
|
||||
@ -173,7 +183,6 @@ public class OrderController {
|
||||
orderAddress.setAddressProvinceName(ordersEntitys.getOrderAddress().getAddressProvinceName());
|
||||
productId.append(ordersEntitys.getProductCode()+",");
|
||||
productName.append(ordersEntitys.getProductName()+",");
|
||||
|
||||
memberId = ordersEntitys.getMemberId();
|
||||
mobile = ordersEntitys.getPhoneNumber();
|
||||
buyCount = buyCount + ordersEntitys.getBuyCount();
|
||||
@ -187,17 +196,23 @@ public class OrderController {
|
||||
ordersEntity.setBuyCount(buyCount);
|
||||
ordersEntity.setOrderNo(GenerateSequenceUtil.generateSequenceNo());
|
||||
ordersEntity.setOrderStatus("0");
|
||||
ordersEntity.setBasePoint(basePoint);
|
||||
|
||||
|
||||
if(orderService.generateOrder(ordersEntity,orderDatilListJson) == 1){
|
||||
wxPayEntity.setProduct_id(ordersEntity.getProductCode());
|
||||
wxPayEntity.setTotal_fee(StringUtil.toString(total_fee));
|
||||
wxPayEntity.setOut_trade_no(ordersEntity.getOrderNo());
|
||||
return wxpayService.dounifiedOrder(wxPayEntity);
|
||||
}else {
|
||||
return null;
|
||||
|
||||
Map<String, String> returnMap = new HashMap<>();
|
||||
returnMap.put("orderNumber",ordersEntity.getOrderNo());
|
||||
returnMap.put("orderAmount",ordersEntity.getOrderAmount());
|
||||
return ResponseDTO.succData(returnMap,wxpayService.dounifiedOrder(wxPayEntity));
|
||||
}
|
||||
return ResponseDTO.wrap(OrderResponseCodeConst.GENERATE_ORDER_FAIL);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "重新支付", notes = "重新支付")
|
||||
@ApiOperation(value = "重新支付(二维码)", notes = "重新支付(二维码)")
|
||||
@PostMapping("royalcanin/repayOrderWX")
|
||||
public ResponseDTO<String> repayOrderWX(String orderNo) throws Exception {
|
||||
OrderEntity ordersEntity = orderService.findByOrderId(orderNo);
|
||||
@ -212,7 +227,31 @@ public class OrderController {
|
||||
wxPayEntity.setProduct_id(ordersEntity.getProductCode());
|
||||
wxPayEntity.setTotal_fee(jsonObject.getString("salesAmount"));
|
||||
wxPayEntity.setOut_trade_no(ordersEntity.getOrderNo());
|
||||
return ResponseDTO.succData(orderInfo, wxpayService.generateQRCode(wxPayEntity));
|
||||
return ResponseDTO.succData(orderNo, wxpayService.generateQRCode(wxPayEntity));
|
||||
}else {
|
||||
return ResponseDTO.wrap(OrderResponseCodeConst.GENERATE_ORDER_ERROR,orderInfo);
|
||||
}
|
||||
}else {
|
||||
return ResponseDTO.wrap(OrderResponseCodeConst.WITHOUT_ORDER);
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "重新支付(H5)", notes = "重新支付(H5)")
|
||||
@PostMapping("royalcanin/repayOrderWXH5")
|
||||
public ResponseDTO<String> repayOrderWXH5(String orderNo) throws Exception {
|
||||
OrderEntity ordersEntity = orderService.findByOrderId(orderNo);
|
||||
if(ordersEntity != null){
|
||||
QueryEntity queryEntity = new QueryEntity();
|
||||
queryEntity.setOrderNumber(ordersEntity.getOrderNo());
|
||||
String orderInfo = orderService.query(queryEntity);
|
||||
com.alibaba.fastjson.JSONArray jsonArray = JSONObject.parseArray(orderInfo);
|
||||
JSONObject jsonObject = (JSONObject)jsonArray.get(0);
|
||||
if(jsonObject.getString("status").equals("0")) {
|
||||
WxPayEntity wxPayEntity = new WxPayEntity();
|
||||
wxPayEntity.setProduct_id(ordersEntity.getProductCode());
|
||||
wxPayEntity.setTotal_fee(jsonObject.getString("salesAmount"));
|
||||
wxPayEntity.setOut_trade_no(ordersEntity.getOrderNo());
|
||||
return ResponseDTO.succData(orderNo,wxpayService.dounifiedOrder(wxPayEntity));
|
||||
}else {
|
||||
return ResponseDTO.wrap(OrderResponseCodeConst.GENERATE_ORDER_ERROR,orderInfo);
|
||||
}
|
||||
@ -239,11 +278,7 @@ public class OrderController {
|
||||
return ResponseDTO.wrap(OrderResponseCodeConst.NOTIFY_ERROR);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "支付宝更新订单", notes = "支付宝更新订单")
|
||||
@RequestMapping(value = "royalcanin/updateOrderAlipay")
|
||||
public void updateOrderAlipay(HttpServletRequest request, HttpServletResponse response){
|
||||
// aliPayService.orderCallBackAliPay(request,response);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "取消订单", notes = "取消订单")
|
||||
@RequestMapping(value = "royalcanin/cancelOrder",method = RequestMethod.POST)
|
||||
|
@ -226,9 +226,18 @@ public class OrderService {
|
||||
long elapsedTime = acceptTime - startTime;
|
||||
JSONObject jsonObject = JSONObject.parseObject(result);
|
||||
String afterDecodeResult = AESUtil.decryptLinux(jsonObject.getString("data"), AESUtil.KEY);
|
||||
com.alibaba.fastjson.JSONArray jsonArray = JSONObject.parseArray(afterDecodeResult);
|
||||
JSONObject jsonObjectResult = (JSONObject)jsonArray.get(0);
|
||||
if (queryEntity.getOrderNumber() != null &&queryEntity.getOrderNumber() != "") {
|
||||
OrderEntity orderEntity = ordersDao.findByOrderId(queryEntity.getOrderNumber());
|
||||
//新增支付方式paytype
|
||||
jsonObjectResult.put("paytype",orderEntity.getPayType());
|
||||
}
|
||||
|
||||
//记录服务响应时间
|
||||
addOperatreFullData(url+"orderMaster/query",queryEntity.toString(),result, startTime,elapsedTime,acceptTime);
|
||||
return afterDecodeResult;
|
||||
|
||||
return jsonArray.toJSONString();
|
||||
}
|
||||
|
||||
public ResponseDTO<String> addOperatreFullData(String type, String params, String result, Long startTime, Long elapsedTime, Long acceptTime){
|
||||
|
@ -19,7 +19,7 @@ public class MyConfig implements WXPayConfig {
|
||||
public String notify_url = "https://royalcanincn.escase.cn/jc/royalcanin/royalcanin/updateOrderWX";
|
||||
|
||||
// 微信支付h5 回调地址
|
||||
public static String NOTIFY_URL_H5 = "https://www.XXXXXX.com/server/weixin/WxQuery";
|
||||
public static String NOTIFY_URL_H5 = "https://shop.royalcanin.com.cn/myorder/usertion?";
|
||||
|
||||
// 请求地址
|
||||
public static String UFDODER_URL = "https://api.mch.weixin.qq.com/pay/unifiedorder";
|
||||
|
@ -68,7 +68,7 @@ public class WxpayService {
|
||||
try {
|
||||
Map<String, String> resp = wxpay.unifiedOrder(data);
|
||||
if (resp != null) {
|
||||
return resp.get("code_url");
|
||||
return resp.get("code_url") == null ?resp.get("err_code_des"):resp.get("code_url");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@ -141,10 +141,6 @@ public class WxpayService {
|
||||
response.getWriter().println("<xml> <return_code><![CDATA[SUCCESS]]></return_code> <return_msg><![CDATA[OK]]></return_msg> </xml>");
|
||||
response.setContentType("text/html");
|
||||
response.getWriter().println("SUCCESS");
|
||||
QueryEntity queryEntity = new QueryEntity();
|
||||
queryEntity.setOrderNumber(outTradeNo);
|
||||
String orderEntityJson = orderService.query(queryEntity);
|
||||
orderService.completeOrder(totalFee,orderEntityJson);
|
||||
}
|
||||
}else {
|
||||
// 未成功,就都处理为失败订单
|
||||
@ -168,7 +164,7 @@ public class WxpayService {
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public Map<String, String> dounifiedOrder(WxPayEntity wxPayEntity) throws Exception {
|
||||
public String dounifiedOrder(WxPayEntity wxPayEntity) throws Exception {
|
||||
//返回参数
|
||||
Map<String, String> returnMap = new HashMap<>();
|
||||
WXPay wxpay = new WXPay(config);
|
||||
@ -194,18 +190,20 @@ public class WxpayService {
|
||||
if (returnCode.equals("SUCCESS")) {
|
||||
returnMap.put("ok", "200");
|
||||
//拼接返回跳转地址
|
||||
String url= config.NOTIFY_URL_H5;
|
||||
String url= config.NOTIFY_URL_H5+"orderNumber="+wxPayEntity.getOut_trade_no() ;
|
||||
returnMap.put("url", response.get("mweb_url")+"&redirect_url="+url);
|
||||
return response.get("mweb_url") == null ? response.get("err_code_des"):returnMap.get("url");
|
||||
} else {
|
||||
returnMap.put("ok", "201");
|
||||
returnMap.put("url",null);
|
||||
return returnMap;
|
||||
return returnMap.get("url");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println(e);
|
||||
return "Error";
|
||||
//系统等其他错误的时候
|
||||
}
|
||||
return returnMap;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user