parent
11415b2f40
commit
ff0c2b148f
File diff suppressed because one or more lines are too long
@ -1,189 +0,0 @@ |
|||||||
package com.web.controller.business; |
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON; |
|
||||||
import com.alibaba.fastjson.JSONObject; |
|
||||||
import com.hai.common.pay.WechatPayUtil; |
|
||||||
import com.hai.common.security.UserCenter; |
|
||||||
import com.hai.config.UnionPayConfig; |
|
||||||
import com.hai.config.WxMsgConfig; |
|
||||||
import com.hai.dao.HighGasOrderPushMapper; |
|
||||||
import com.hai.entity.*; |
|
||||||
import com.hai.enum_type.OrderPushType; |
|
||||||
import com.hai.enum_type.OrderStatusEnum; |
|
||||||
import com.hai.enum_type.RechargePayType; |
|
||||||
import com.hai.order.service.OrderService; |
|
||||||
import com.hai.order.type.OrderChildStatus; |
|
||||||
import com.hai.service.*; |
|
||||||
import com.hai.service.impl.OutRechargeOrderServiceImpl; |
|
||||||
import io.swagger.annotations.Api; |
|
||||||
import io.swagger.annotations.ApiOperation; |
|
||||||
import org.slf4j.Logger; |
|
||||||
import org.slf4j.LoggerFactory; |
|
||||||
import org.springframework.stereotype.Controller; |
|
||||||
import org.springframework.web.bind.annotation.*; |
|
||||||
|
|
||||||
|
|
||||||
import javax.annotation.Resource; |
|
||||||
import javax.servlet.http.HttpServletRequest; |
|
||||||
import javax.servlet.http.HttpServletResponse; |
|
||||||
import java.io.PrintWriter; |
|
||||||
import java.util.Date; |
|
||||||
import java.util.HashMap; |
|
||||||
import java.util.Map; |
|
||||||
import java.util.Objects; |
|
||||||
|
|
||||||
@Controller |
|
||||||
@RequestMapping(value = "telChargeCallback") |
|
||||||
@Api(value = "话费充值回调业务") |
|
||||||
public class OrderTelChargeCallbackController { |
|
||||||
|
|
||||||
|
|
||||||
private static Logger log = LoggerFactory.getLogger(OutRechargeOrderServiceImpl.class); |
|
||||||
|
|
||||||
@Resource |
|
||||||
private OutRechargeOrderService outRechargeOrderService; |
|
||||||
|
|
||||||
@Resource |
|
||||||
private OutRechargeChildOrderService outRechargeChildOrderService; |
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping(value = "/rechargeCallbackByJj", method = RequestMethod.POST) |
|
||||||
@ApiOperation(value = "尖椒充值回调") |
|
||||||
@ResponseBody |
|
||||||
public void rechargeCallbackByJj(@RequestBody String reqBodyStr, HttpServletRequest request, HttpServletResponse response) { |
|
||||||
try { |
|
||||||
|
|
||||||
JSONObject dataObject = JSONObject.parseObject(reqBodyStr, JSONObject.class); |
|
||||||
|
|
||||||
log.info("============回调任务Start============="); |
|
||||||
log.info("尖椒订单充值-回调参数: " + dataObject); |
|
||||||
log.info("============回调任务End============="); |
|
||||||
|
|
||||||
// 判断是否充值成功
|
|
||||||
if (dataObject.getInteger("status") == 3) { |
|
||||||
// 充值成功操作
|
|
||||||
outRechargeOrderService.completeOrder(dataObject.getString("out_order_id")); |
|
||||||
} else { |
|
||||||
// 充值失败操作
|
|
||||||
callbackResult(dataObject.getString("out_order_id")); |
|
||||||
} |
|
||||||
|
|
||||||
response.setCharacterEncoding("UTF-8"); |
|
||||||
response.setContentType("text/html;charset=utf-8"); |
|
||||||
PrintWriter writer= response.getWriter(); |
|
||||||
writer.write("SUCCESS"); |
|
||||||
|
|
||||||
|
|
||||||
} catch (Exception e) { |
|
||||||
log.error("WechatPayController --> wechatNotify() error!", e); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping(value = "/rechargeCallbackByLy", method = RequestMethod.POST) |
|
||||||
@ApiOperation(value = "龙阅充值回调") |
|
||||||
@ResponseBody |
|
||||||
public void rechargeCallbackByLy( |
|
||||||
@RequestParam(name = "out_trade_num", required = true) String out_trade_num, |
|
||||||
@RequestParam(name = "userid", required = true) Long userid, |
|
||||||
@RequestParam(name = "state", required = true) Long state, |
|
||||||
@RequestBody String reqBodyStr , |
|
||||||
HttpServletRequest request, HttpServletResponse response) { |
|
||||||
try { |
|
||||||
|
|
||||||
log.info("============回调任务Start============="); |
|
||||||
log.info("龙阅订单充值-回调参数: " + reqBodyStr); |
|
||||||
log.info("============回调任务End============="); |
|
||||||
|
|
||||||
// 判断是否充值成功
|
|
||||||
if (state == 1) { |
|
||||||
outRechargeOrderService.completeOrder(out_trade_num); |
|
||||||
} else { |
|
||||||
callbackResult(out_trade_num); |
|
||||||
} |
|
||||||
|
|
||||||
response.setCharacterEncoding("UTF-8"); |
|
||||||
response.setContentType("text/html;charset=utf-8"); |
|
||||||
PrintWriter writer= response.getWriter(); |
|
||||||
writer.write("SUCCESS"); |
|
||||||
|
|
||||||
|
|
||||||
} catch (Exception e) { |
|
||||||
log.error("WechatPayController --> wechatNotify() error!", e); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
@RequestMapping(value = "/rechargeCallbackByHg", method = RequestMethod.POST) |
|
||||||
@ApiOperation(value = "畅停充值回调") |
|
||||||
@ResponseBody |
|
||||||
public void rechargeCallbackByHg( |
|
||||||
@RequestParam(name = "mchid", required = false) String mchid, |
|
||||||
@RequestParam(name = "out_order_id", required = false) String out_order_id, |
|
||||||
@RequestParam(name = "orderid", required = true) String orderid, |
|
||||||
@RequestParam(name = "return_time", required = false) String return_time, |
|
||||||
@RequestParam(name = "return_price", required = false) String return_price, |
|
||||||
@RequestParam(name = "recharge_price", required = false) String recharge_price, |
|
||||||
@RequestParam(name = "price", required = false) String price, |
|
||||||
@RequestParam(name = "status", required = true) String status, |
|
||||||
@RequestParam(name = "phone", required = false) String phone, |
|
||||||
@RequestParam(name = "secret_key", required = false) String secret_key, |
|
||||||
HttpServletResponse response) { |
|
||||||
try { |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
JSONObject dataObject = new JSONObject(); |
|
||||||
|
|
||||||
dataObject.put("mchid" , mchid); |
|
||||||
dataObject.put("out_order_id" , out_order_id); |
|
||||||
dataObject.put("orderid" , orderid); |
|
||||||
dataObject.put("return_time" , return_time); |
|
||||||
dataObject.put("return_price" , return_price); |
|
||||||
dataObject.put("recharge_price" , recharge_price); |
|
||||||
dataObject.put("price" , price); |
|
||||||
dataObject.put("status" , status); |
|
||||||
dataObject.put("phone" , phone); |
|
||||||
dataObject.put("secret_key" , secret_key); |
|
||||||
|
|
||||||
log.info("============回调任务Start============="); |
|
||||||
log.info("畅停订单充值-回调参数: " + dataObject); |
|
||||||
log.info("============回调任务End============="); |
|
||||||
|
|
||||||
// 判断是否充值成功 并发送微信小程序服务通知
|
|
||||||
if (Objects.equals(status, "1")) { |
|
||||||
|
|
||||||
outRechargeOrderService.completeOrder(orderid); |
|
||||||
|
|
||||||
} else { |
|
||||||
// 充值失败操作
|
|
||||||
callbackResult(orderid); |
|
||||||
} |
|
||||||
|
|
||||||
response.setCharacterEncoding("UTF-8"); |
|
||||||
response.setContentType("text/html;charset=utf-8"); |
|
||||||
PrintWriter writer= response.getWriter(); |
|
||||||
writer.write("success"); |
|
||||||
|
|
||||||
|
|
||||||
} catch (Exception e) { |
|
||||||
log.error("WechatPayController --> wechatNotify() error!", e); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
// 充值回调结果处理
|
|
||||||
private void callbackResult(String orderNo) { |
|
||||||
|
|
||||||
// 查询充值订单
|
|
||||||
OutRechargeOrder rechargeOrder = outRechargeOrderService.findByOrderNo(orderNo); |
|
||||||
OutRechargeChildOrder childOrder = rechargeOrder.getOutRechargeChildOrders().get(0); |
|
||||||
|
|
||||||
childOrder.setStatus(103); |
|
||||||
childOrder.setUpdateTime(new Date()); |
|
||||||
outRechargeChildOrderService.updateOrder(childOrder); |
|
||||||
rechargeOrder.setRechargeStatus(205); |
|
||||||
outRechargeOrderService.updateOrder(rechargeOrder); |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
} |
|
@ -0,0 +1,71 @@ |
|||||||
|
package com.hai.openApi.model; |
||||||
|
|
||||||
|
import java.math.BigDecimal; |
||||||
|
|
||||||
|
public class ApiMobileProductModel { |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 主键 |
||||||
|
*/ |
||||||
|
private Long productId; |
||||||
|
|
||||||
|
/** |
||||||
|
* 运营商 1 电信 2.移动 3.联通 |
||||||
|
*/ |
||||||
|
private Integer operatorType; |
||||||
|
/** |
||||||
|
* 折扣比例 |
||||||
|
*/ |
||||||
|
private BigDecimal discount; |
||||||
|
|
||||||
|
/** |
||||||
|
* 充值金额 |
||||||
|
*/ |
||||||
|
private BigDecimal rechargePrice; |
||||||
|
|
||||||
|
/** |
||||||
|
* 成本价格 |
||||||
|
*/ |
||||||
|
private BigDecimal costPrice; |
||||||
|
|
||||||
|
public Long getProductId() { |
||||||
|
return productId; |
||||||
|
} |
||||||
|
|
||||||
|
public void setProductId(Long productId) { |
||||||
|
this.productId = productId; |
||||||
|
} |
||||||
|
|
||||||
|
public Integer getOperatorType() { |
||||||
|
return operatorType; |
||||||
|
} |
||||||
|
|
||||||
|
public void setOperatorType(Integer operatorType) { |
||||||
|
this.operatorType = operatorType; |
||||||
|
} |
||||||
|
|
||||||
|
public BigDecimal getDiscount() { |
||||||
|
return discount; |
||||||
|
} |
||||||
|
|
||||||
|
public void setDiscount(BigDecimal discount) { |
||||||
|
this.discount = discount; |
||||||
|
} |
||||||
|
|
||||||
|
public BigDecimal getRechargePrice() { |
||||||
|
return rechargePrice; |
||||||
|
} |
||||||
|
|
||||||
|
public void setRechargePrice(BigDecimal rechargePrice) { |
||||||
|
this.rechargePrice = rechargePrice; |
||||||
|
} |
||||||
|
|
||||||
|
public BigDecimal getCostPrice() { |
||||||
|
return costPrice; |
||||||
|
} |
||||||
|
|
||||||
|
public void setCostPrice(BigDecimal costPrice) { |
||||||
|
this.costPrice = costPrice; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,48 @@ |
|||||||
|
package com.hai.openApi.service; |
||||||
|
|
||||||
|
import com.hai.entity.ApiMerchants; |
||||||
|
import com.hai.entity.ApiProduct; |
||||||
|
import com.hai.openApi.model.ApiMobileProductModel; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* @serviceName ApiMobileRechargeProductService.java |
||||||
|
* @author Sum1Dream |
||||||
|
* @version 1.0.0 |
||||||
|
* @Description // 话费产品业务
|
||||||
|
* @createTime 11:36 2023/3/10 |
||||||
|
**/ |
||||||
|
public interface ApiMobileRechargeProductService { |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* @Author Sum1Dream |
||||||
|
* @Name getMobileProductByList |
||||||
|
* @Description // 查询话费充值产品
|
||||||
|
* @Date 11:35 2023/3/10 |
||||||
|
* @Param [] |
||||||
|
* @Return java.util.List<com.hai.openApi.model.ApiMobileProductModel> |
||||||
|
*/ |
||||||
|
List<ApiProduct> getApiProductByList(); |
||||||
|
|
||||||
|
/** |
||||||
|
* @Author Sum1Dream |
||||||
|
* @Name findMobileProduct |
||||||
|
* @Description // 查询话费产品
|
||||||
|
* @Date 11:36 2023/3/10 |
||||||
|
* @Param [id] |
||||||
|
* @Return com.hai.entity.ApiProduct |
||||||
|
*/ |
||||||
|
ApiProduct findMobileProduct(Long id); |
||||||
|
|
||||||
|
/** |
||||||
|
* @Author Sum1Dream |
||||||
|
* @Name getMobileProductByList |
||||||
|
* @Description // 拼装话费产品
|
||||||
|
* @Date 11:35 2023/3/10 |
||||||
|
* @Param [] |
||||||
|
* @Return java.util.List<com.hai.openApi.model.ApiMobileProductModel> |
||||||
|
*/ |
||||||
|
List<ApiMobileProductModel> getMobileProductByList(String mchId); |
||||||
|
} |
@ -0,0 +1,68 @@ |
|||||||
|
package com.hai.openApi.service.impl; |
||||||
|
|
||||||
|
import com.hai.dao.ApiProductMapper; |
||||||
|
import com.hai.entity.*; |
||||||
|
import com.hai.openApi.config.PriceComputeConfig; |
||||||
|
import com.hai.openApi.model.ApiMobileProductModel; |
||||||
|
import com.hai.openApi.service.ApiMchProductService; |
||||||
|
import com.hai.openApi.service.ApiMobileRechargeProductService; |
||||||
|
import com.hai.order.type.OrderProductType; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
import javax.annotation.Resource; |
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.List; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
@Service("apiMobileRechargeProductService") |
||||||
|
public class ApiMobileRechargeProductServiceImpl implements ApiMobileRechargeProductService { |
||||||
|
|
||||||
|
@Resource |
||||||
|
private ApiProductMapper apiProductMapper; |
||||||
|
|
||||||
|
@Resource |
||||||
|
private ApiMchProductService apiMchProductService; |
||||||
|
|
||||||
|
@Resource |
||||||
|
private PriceComputeConfig priceComputeConfig; |
||||||
|
|
||||||
|
@Override |
||||||
|
public List<ApiProduct> getApiProductByList() { |
||||||
|
ApiProductExample example = new ApiProductExample(); |
||||||
|
example.createCriteria().andStatusEqualTo(101); |
||||||
|
|
||||||
|
return apiProductMapper.selectByExample(example); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public ApiProduct findMobileProduct(Long id) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public List<ApiMobileProductModel> getMobileProductByList(String mchId) { |
||||||
|
|
||||||
|
Map<String, Object> mapProduct = new HashMap<>(); |
||||||
|
mapProduct.put("mchId" , mchId); |
||||||
|
mapProduct.put("productType" , OrderProductType.PRODUCT_TYPE9.getNumber()); |
||||||
|
|
||||||
|
ApiMchProduct apiMchProducts = apiMchProductService.findByMap(mapProduct); |
||||||
|
|
||||||
|
List<ApiMobileProductModel> list = new ArrayList<>(); |
||||||
|
List<ApiProduct> apiProducts = getApiProductByList(); |
||||||
|
|
||||||
|
for (ApiProduct product : apiProducts) { |
||||||
|
ApiMobileProductModel productModel = new ApiMobileProductModel(); |
||||||
|
productModel.setDiscount(apiMchProducts.getDiscount()); |
||||||
|
productModel.setProductId(product.getId()); |
||||||
|
productModel.setRechargePrice(product.getRechargePrice()); |
||||||
|
productModel.setOperatorType(product.getOperatorType()); |
||||||
|
productModel.setCostPrice(priceComputeConfig.computationPriceCost(apiMchProducts.getDiscount() , product.getRechargePrice())); |
||||||
|
list.add(productModel); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
return list; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,195 @@ |
|||||||
|
package com.v1.controller.business; |
||||||
|
|
||||||
|
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.config.QianZhuConfig; |
||||||
|
import com.hai.entity.ApiMerchants; |
||||||
|
import com.hai.entity.ApiStarbucksProducts; |
||||||
|
import com.hai.model.ResponseData; |
||||||
|
import com.hai.order.type.OrderProductType; |
||||||
|
import com.hai.service.*; |
||||||
|
import com.v1.controller.ThirdPartyController; |
||||||
|
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.math.BigDecimal; |
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.List; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
@Controller |
||||||
|
@RequestMapping(value = "/starbucks") |
||||||
|
@Api(value = "星巴克业务") |
||||||
|
public class StarbucksController { |
||||||
|
|
||||||
|
|
||||||
|
private static Logger log = LoggerFactory.getLogger(ThirdPartyController.class); |
||||||
|
|
||||||
|
@Resource |
||||||
|
private ApiMerchantsService apiMerchantsService; |
||||||
|
|
||||||
|
@Resource |
||||||
|
private SecConfigService secConfigService; |
||||||
|
|
||||||
|
@Resource |
||||||
|
private ApiIpAddressService apiIpAddressService; |
||||||
|
|
||||||
|
@Resource |
||||||
|
private ApiProductService apiProductService; |
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(value = "/starbucksStore", method = RequestMethod.POST) |
||||||
|
@ResponseBody |
||||||
|
@ApiOperation(value = "查询星巴克门店") |
||||||
|
public ResponseData starbucksStore(@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 (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , 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("lat")) || |
||||||
|
StringUtils.isBlank(object.getString("lon")) || |
||||||
|
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); |
||||||
|
} |
||||||
|
|
||||||
|
if (!secConfigService.isConfig(OrderProductType.PRODUCT_TYPE1.getApiCode(), object.getString("merchId"))) { |
||||||
|
log.error("getAllCities error!", "当前帐户无权限查询!"); |
||||||
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_NOT_AUTHORIZED, ""); |
||||||
|
} |
||||||
|
|
||||||
|
Map<String , Object> map = new HashMap<>(); |
||||||
|
map.put("apiKey" , object.getString("apiKey")); |
||||||
|
map.put("merchId" , object.getString("merchId")); |
||||||
|
map.put("lat" , object.getString("lat")); |
||||||
|
map.put("lon" , object.getString("lon")); |
||||||
|
|
||||||
|
if (!secConfigService.isSignVerify(map , object.getString("sign"))) { |
||||||
|
log.error("getRechargeProduct error!", "签名校验失败!"); |
||||||
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.SIGN_VERIFY); |
||||||
|
} |
||||||
|
|
||||||
|
JSONObject jsonObject = QianZhuConfig.getStarbucksStore(object.getString("lat") , object.getString("lon")); |
||||||
|
|
||||||
|
if (jsonObject.getBoolean("success")) { |
||||||
|
return ResponseMsgUtil.success(jsonObject.getString("data")); |
||||||
|
} else { |
||||||
|
log.error("getRechargeProduct error!", "查询失败!"); |
||||||
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR , jsonObject.getString("message")); |
||||||
|
} |
||||||
|
|
||||||
|
} catch (Exception e) { |
||||||
|
log.error("HighOpenApiController --> getRechargeProduct() error!", e); |
||||||
|
return ResponseMsgUtil.exception(e); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@RequestMapping(value = "/getStarbucksProducts", method = RequestMethod.POST) |
||||||
|
@ResponseBody |
||||||
|
@ApiOperation(value = "查询星巴克商品") |
||||||
|
public ResponseData getStarbucksProducts(@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 (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , 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("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); |
||||||
|
} |
||||||
|
|
||||||
|
if (!secConfigService.isConfig(OrderProductType.PRODUCT_TYPE1.getApiCode(), object.getString("merchId"))) { |
||||||
|
log.error("getAllCities error!", "当前帐户无权限查询!"); |
||||||
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_NOT_AUTHORIZED, ""); |
||||||
|
} |
||||||
|
|
||||||
|
Map<String , Object> map = new HashMap<>(); |
||||||
|
map.put("apiKey" , object.getString("apiKey")); |
||||||
|
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); |
||||||
|
} |
||||||
|
|
||||||
|
Map<String, Object> mapProduct = new HashMap<>(); |
||||||
|
|
||||||
|
List<ApiStarbucksProducts> list = apiProductService.getStarbucksProducts(mapProduct); |
||||||
|
|
||||||
|
for (ApiStarbucksProducts starbucksProducts : list) { |
||||||
|
if (starbucksProducts.getMarketGrandePrice().compareTo(new BigDecimal(1000)) > 0) { |
||||||
|
starbucksProducts.setMarketGrandePrice(null); |
||||||
|
} |
||||||
|
if (starbucksProducts.getMarketTallPrice().compareTo(new BigDecimal(1000)) > 0) { |
||||||
|
starbucksProducts.setMarketTallPrice(null); |
||||||
|
} |
||||||
|
if (starbucksProducts.getMarketVentiPrice().compareTo(new BigDecimal(1000)) > 0) { |
||||||
|
starbucksProducts.setMarketVentiPrice(null); |
||||||
|
} |
||||||
|
starbucksProducts.setSalesTallPrice(starbucksProducts.getMarketTallPrice()); |
||||||
|
starbucksProducts.setSalesVentiPrice(starbucksProducts.getMarketVentiPrice()); |
||||||
|
starbucksProducts.setSalesGrandePrice(starbucksProducts.getMarketGrandePrice()); |
||||||
|
} |
||||||
|
|
||||||
|
return ResponseMsgUtil.success(list); |
||||||
|
|
||||||
|
} catch (Exception e) { |
||||||
|
log.error("HighOpenApiController --> getRechargeProduct() error!", e); |
||||||
|
return ResponseMsgUtil.exception(e); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue