提交修改

袁野 2 years ago
parent cebe26da2b
commit 841e9285fd
  1. 2
      hai-cweb/src/main/java/com/cweb/controller/HighTestController.java
  2. 12
      hai-cweb/src/main/java/com/cweb/controller/HighThirdPartyController.java
  3. 42
      hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java
  4. 3
      hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java
  5. 1
      v1/src/main/java/com/v1/config/AuthConfig.java
  6. 175
      v1/src/main/java/com/v1/controller/HighOrderController.java
  7. 6
      v1/src/main/java/com/v1/controller/RechargeProductController.java

File diff suppressed because one or more lines are too long

@ -114,9 +114,9 @@ public class HighThirdPartyController {
for (ApiStarbucksProducts apiStarbucksProducts : list) {
apiStarbucksProducts.setExt1(String.valueOf(i));
BigDecimal salesVentiPrice = apiStarbucksProducts.getSalesVentiPrice().add(apiStarbucksProducts.getSalesVentiPrice().multiply(productDiscount.divide(new BigDecimal(100)))).setScale(2, RoundingMode.HALF_UP);
BigDecimal salesTallPrice = apiStarbucksProducts.getSalesTallPrice().add(apiStarbucksProducts.getSalesTallPrice().multiply(productDiscount.divide(new BigDecimal(100)))).setScale(2, RoundingMode.HALF_UP);
BigDecimal salesGrandePrice = apiStarbucksProducts.getSalesGrandePrice().add(apiStarbucksProducts.getSalesGrandePrice().multiply(productDiscount.divide(new BigDecimal(100)))).setScale(2, RoundingMode.HALF_UP);
BigDecimal salesVentiPrice = apiStarbucksProducts.getSalesVentiPrice().add(apiStarbucksProducts.getMarketVentiPrice().multiply(productDiscount.divide(new BigDecimal(100)))).setScale(2, RoundingMode.HALF_UP);
BigDecimal salesTallPrice = apiStarbucksProducts.getSalesTallPrice().add(apiStarbucksProducts.getMarketTallPrice().multiply(productDiscount.divide(new BigDecimal(100)))).setScale(2, RoundingMode.HALF_UP);
BigDecimal salesGrandePrice = apiStarbucksProducts.getSalesGrandePrice().add(apiStarbucksProducts.getMarketGrandePrice().multiply(productDiscount.divide(new BigDecimal(100)))).setScale(2, RoundingMode.HALF_UP);
if (salesVentiPrice.compareTo(apiStarbucksProducts.getMarketVentiPrice()) > 0) {
salesVentiPrice = apiStarbucksProducts.getMarketVentiPrice();
@ -236,7 +236,7 @@ public class HighThirdPartyController {
JSONObject productsObject = (JSONObject) products;
BigDecimal productsPrice = productsObject.getBigDecimal("price");
BigDecimal salePriceF = productsPrice.add(productsPrice.multiply(productDiscount).divide(new BigDecimal(100))).setScale(2, RoundingMode.HALF_UP);
BigDecimal salePriceF = productsPrice.add(productsObject.getBigDecimal("originalPrice").multiply(productDiscount).divide(new BigDecimal(100))).setScale(2, RoundingMode.HALF_UP);
if (salePriceF.compareTo(productsObject.getBigDecimal("originalPrice")) > 0) {
salePriceF = productsObject.getBigDecimal("originalPrice");
}
@ -246,7 +246,7 @@ public class HighThirdPartyController {
for (Object specGroups : productsObject.getJSONArray("specGroups")) {
JSONObject specGroupsObject = (JSONObject) specGroups;
BigDecimal specGroupsPrice = specGroupsObject.getBigDecimal("price");
BigDecimal salePrice = specGroupsPrice.add(specGroupsPrice.multiply(productDiscount).divide(new BigDecimal(100))).setScale(2, RoundingMode.HALF_UP);
BigDecimal salePrice = specGroupsPrice.add(specGroupsObject.getBigDecimal("originalPrice").multiply(productDiscount).divide(new BigDecimal(100))).setScale(2, RoundingMode.HALF_UP);
if (salePrice.compareTo(specGroupsObject.getBigDecimal("originalPrice")) > 0) {
salePrice = specGroupsObject.getBigDecimal("originalPrice");
}
@ -493,7 +493,7 @@ public class HighThirdPartyController {
for (ApiMemberProduct memberProduct : list) {
BigDecimal costPrice = memberProduct.getCostPrice().add(memberProduct.getCostPrice().multiply(productDiscount.divide(new BigDecimal(100)))).setScale(2, RoundingMode.HALF_UP);
BigDecimal costPrice = memberProduct.getCostPrice().add(memberProduct.getPrice().multiply(productDiscount.divide(new BigDecimal(100)))).setScale(2, RoundingMode.HALF_UP);
if (costPrice.compareTo(memberProduct.getPrice()) > 0) {
costPrice = memberProduct.getPrice();

@ -1220,6 +1220,9 @@ public class HighOrderServiceImpl implements HighOrderService {
if (MapUtils.getString(map, "phone") != null) {
criteria.andMemPhoneEqualTo(MapUtils.getString(map, "phone"));
}
if (MapUtils.getString(map, "merchId") != null) {
criteria.andMerchIdEqualTo(MapUtils.getString(map, "merchId"));
}
example.setOrderByClause("create_time desc");
List<HighOrder> list = highOrderMapper.selectByExample(example);
@ -1826,6 +1829,7 @@ public class HighOrderServiceImpl implements HighOrderService {
public HighOrder insertThirdProduct(JSONObject object) throws Exception {
HighOrder highOrder = new HighOrder();
highOrder.setMerchId(object.getString("mchId"));
HighUser user = highUserService.findByUserId(object.getLong("userId"));
JSONObject jsonObject = null;
@ -1891,8 +1895,8 @@ public class HighOrderServiceImpl implements HighOrderService {
}
// 下单
jsonObject = QianZhuConfig.starbucksOrders(user.getId().toString(), object.getString("storeCode"), List.toString().replace(" ", ""), object.getString("customerMobile"));
// jsonObject = QianZhuConfig.starbucksOrders(user.getId().toString(), "50562", List.toString().replace(" ", ""), object.getString("customerMobile"));
// jsonObject = QianZhuConfig.starbucksOrders(user.getId().toString(), object.getString("storeCode"), List.toString().replace(" ", ""), object.getString("customerMobile"));
jsonObject = QianZhuConfig.starbucksOrders(user.getId().toString(), "50562", List.toString().replace(" ", ""), object.getString("customerMobile"));
// 判断下单是否成功
if (!Objects.equals(jsonObject.getString("code"), "200")) {
@ -1917,7 +1921,6 @@ public class HighOrderServiceImpl implements HighOrderService {
highOrder.setCompanyId(object.getLong("companyId"));
highOrder.setCreateTime(new Date());
highOrder.setMemId(user.getId());
highOrder.setMerchId(object.getString("mchId"));
highOrder.setMemName(user.getName());
highOrder.setMemPhone(user.getPhone());
highOrder.setOrderStatus(1);
@ -1940,18 +1943,19 @@ public class HighOrderServiceImpl implements HighOrderService {
childOrder.setGoodsImg(childObject.getString("imgUrl"));
childOrder.setSaleCount(childObject.getInteger("quantity"));
childOrder.setGoodsPrice(childObject.getBigDecimal("marketPrice"));
if (object.getLong("memDiscountId") != null) {
childOrder.setGoodsActualPrice(childObject.getBigDecimal("marketPrice"));
} else {
childOrder.setGoodsActualPrice(childObject.getBigDecimal("unitPrice"));
}
// 计算利润
BigDecimal profitPrice = childOrder.getGoodsActualPrice().multiply(productDetail.getBigDecimal("priceDiscount").divide(new BigDecimal(100)));
BigDecimal profitPrice = childObject.getBigDecimal("marketPrice").multiply(productDetail.getBigDecimal("priceDiscount").divide(new BigDecimal(100)));
// 计算子订单支付金额
BigDecimal childPrice = childOrder.getGoodsActualPrice().add(profitPrice).setScale(2 , RoundingMode.HALF_UP);
BigDecimal childPrice = childObject.getBigDecimal("unitPrice").add(profitPrice).setScale(2 , RoundingMode.HALF_UP);
if (childPrice.compareTo(childObject.getBigDecimal("marketPrice")) > 0) {
childPrice = childObject.getBigDecimal("marketPrice");
}
if (object.getLong("memDiscountId") != null) {
childOrder.setGoodsActualPrice(childObject.getBigDecimal("marketPrice"));
} else {
childOrder.setGoodsActualPrice(childPrice);
}
childPrice = childPrice.multiply(childObject.getBigDecimal("quantity"));
// 计算总订单实际支付金额
orderPayPrice = orderPayPrice.add(childPrice);
@ -2008,20 +2012,20 @@ public class HighOrderServiceImpl implements HighOrderService {
childOrder.setGoodsImg(childObject.getString("imageUrl"));
childOrder.setSaleCount(childObject.getInteger("quantity"));
childOrder.setGoodsPrice(childObject.getBigDecimal("originPrice"));
if (object.getLong("memDiscountId") != null) {
childOrder.setGoodsActualPrice(childObject.getBigDecimal("originPrice"));
} else {
childOrder.setGoodsActualPrice(childObject.getBigDecimal("price"));
}
// 计算利润
BigDecimal profitPrice = childOrder.getGoodsActualPrice().multiply(productDetail.getBigDecimal("priceDiscount").divide(new BigDecimal(100)));
BigDecimal profitPrice = childObject.getBigDecimal("originPrice").multiply(productDetail.getBigDecimal("priceDiscount").divide(new BigDecimal(100)));
// 计算子订单支付金额
BigDecimal childPrice = childOrder.getGoodsActualPrice().add(profitPrice).setScale(2 , RoundingMode.HALF_UP);
BigDecimal childPrice = childObject.getBigDecimal("price").add(profitPrice).setScale(2 , RoundingMode.HALF_UP);
if (childPrice.compareTo(childObject.getBigDecimal("originPrice")) > 0) {
childPrice = childObject.getBigDecimal("originPrice");
}
if (object.getLong("memDiscountId") != null) {
childOrder.setGoodsActualPrice(childObject.getBigDecimal("originPrice"));
} else {
childOrder.setGoodsActualPrice(childPrice);
}
childPrice = childPrice.multiply(childObject.getBigDecimal("quantity"));
// 计算总订单实际支付金额
orderPayPrice = orderPayPrice.add(childPrice);
@ -2049,7 +2053,7 @@ public class HighOrderServiceImpl implements HighOrderService {
highOrder.setOrderStatus(1);
// 计算实际支付金额
orderPayPrice = memberProduct.getCostPrice().add(memberProduct.getCostPrice().multiply(productDetail.getBigDecimal("priceDiscount").divide(new BigDecimal(100)))).setScale(2, RoundingMode.HALF_UP);
orderPayPrice = memberProduct.getCostPrice().add(memberProduct.getPrice().multiply(productDetail.getBigDecimal("priceDiscount").divide(new BigDecimal(100)))).setScale(2, RoundingMode.HALF_UP);
if (orderPayPrice.compareTo(memberProduct.getPrice()) > 0) {
orderPayPrice = memberProduct.getPrice();
}

@ -142,6 +142,9 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
if (MapUtils.getInteger(map, "operatorType") != null) {
criteria.andOperatorTypeEqualTo(MapUtils.getInteger(map, "operatorType"));
}
if (MapUtils.getString(map, "merchId") != null) {
criteria.andMerchIdEqualTo(MapUtils.getString(map, "merchId"));
}
if (MapUtils.getInteger(map, "rechargeStatus") != null) {
criteria.andRechargeStatusEqualTo(MapUtils.getInteger(map, "rechargeStatus"));

@ -94,6 +94,7 @@ public class AuthConfig implements WebMvcConfigurer {
.excludePathPatterns("/gzSinopec/*")
.excludePathPatterns("/thirdParty/*")
.excludePathPatterns("/selfOilStation/*")
.excludePathPatterns("/order/*")
;
}

@ -0,0 +1,175 @@
package com.v1.controller;
import com.alibaba.fastjson.JSONObject;
import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode;
import com.hai.common.utils.ResponseMsgUtil;
import com.hai.entity.ApiMerchants;
import com.hai.model.ResponseData;
import com.hai.service.*;
import com.v1.config.ToolConfig;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
/**
* @serviceName rechargeProductController.java
* @author Sum1Dream
* @version 1.0.0
* @Description // 充值产品接口
* @createTime 17:14 2022/6/9
**/
@Controller
@RequestMapping(value = "/order")
@Api(value = "订单")
public class HighOrderController {
private static Logger log = LoggerFactory.getLogger(HighOrderController.class);
@Resource
private ApiMerchantsService apiMerchantsService;
@Resource
private SecConfigService secConfigService;
@Resource
private OutRechargeOrderService outRechargeOrderService;
@Resource
private HighOrderService highOrderService;
@RequestMapping(value = "/getCallOrderList", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "获取话费订单列表")
public ResponseData getCallOrderList(@RequestBody JSONObject object , HttpServletRequest request ) {
try {
String ip = "";
// 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for
if (request.getHeader("x-forwarded-for") == null) {
ip = request.getRemoteAddr();
} else {
ip = request.getHeader("x-forwarded-for");
}
if (!secConfigService.isConfig("IP_WHITE" , ip)) {
log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!");
}
if (StringUtils.isBlank(object.getString("apiKey")) ||
StringUtils.isBlank(object.getString("merchId")) ||
StringUtils.isBlank(object.getString("timetable")) ||
StringUtils.isBlank(object.getString("sign"))
) {
log.error("getRechargeProduct error!", "请求参数校验失败!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR);
}
ApiMerchants apiMerchants = apiMerchantsService.findByMchId(object.getString("merchId"));
if (apiMerchants == null) {
log.error("getRechargeProduct error!", "商户号错误!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_NOT_EXIST);
}
Map<String , Object> map = new HashMap<>();
map.put("apiKey" , object.getString("apiKey"));
map.put("timetable" , object.getString("timetable"));
map.put("merchId" , object.getString("merchId"));
if (!secConfigService.isSignVerify(map , object.getString("sign"))) {
log.error("getRechargeProduct error!", "签名校验失败!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.SIGN_VERIFY);
}
if (!ToolConfig.timetableCheck(15L , object.getLong("timetable"))) {
log.error("getRechargeProduct error!", "请求时间超过15分钟!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.SIGN_VERIFY);
}
Map<String, Object> postMap = new HashMap<>();
postMap.put("merchId" , object.getString("merchId"));
return ResponseMsgUtil.success(outRechargeOrderService.getListRechargeOrder(postMap));
} catch (Exception e) {
log.error("HighOpenApiController --> getRechargeProduct() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/getOrderList", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "获取订单列表")
public ResponseData getOrderList(@RequestBody JSONObject object , HttpServletRequest request ) {
try {
String ip = "";
// 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for
if (request.getHeader("x-forwarded-for") == null) {
ip = request.getRemoteAddr();
} else {
ip = request.getHeader("x-forwarded-for");
}
if (!secConfigService.isConfig("IP_WHITE" , ip)) {
log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!");
}
if (StringUtils.isBlank(object.getString("apiKey")) ||
StringUtils.isBlank(object.getString("merchId")) ||
StringUtils.isBlank(object.getString("timetable")) ||
StringUtils.isBlank(object.getString("sign"))
) {
log.error("getRechargeProduct error!", "请求参数校验失败!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR);
}
ApiMerchants apiMerchants = apiMerchantsService.findByMchId(object.getString("merchId"));
if (apiMerchants == null) {
log.error("getRechargeProduct error!", "商户号错误!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_NOT_EXIST);
}
Map<String , Object> map = new HashMap<>();
map.put("apiKey" , object.getString("apiKey"));
map.put("timetable" , object.getString("timetable"));
map.put("merchId" , object.getString("merchId"));
if (!secConfigService.isSignVerify(map , object.getString("sign"))) {
log.error("getRechargeProduct error!", "签名校验失败!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.SIGN_VERIFY);
}
if (!ToolConfig.timetableCheck(15L , object.getLong("timetable"))) {
log.error("getRechargeProduct error!", "请求时间超过15分钟!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.SIGN_VERIFY);
}
Map<String, Object> postMap = new HashMap<>();
postMap.put("merchId" , object.getString("merchId"));
return ResponseMsgUtil.success(highOrderService.getOrderList(postMap));
} catch (Exception e) {
log.error("HighOpenApiController --> getRechargeProduct() error!", e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -20,7 +20,9 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
@ -55,9 +57,6 @@ public class RechargeProductController {
@Resource
private ApiOpenService apiOpenService;
@Resource
private HighOrderService highOrderService;
@RequestMapping(value = "/getRechargeProduct", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "获取充值产品")
@ -335,4 +334,5 @@ public class RechargeProductController {
}
}
}

Loading…
Cancel
Save