diff --git a/hai-bweb/src/main/java/com/bweb/controller/ApiProductController.java b/hai-bweb/src/main/java/com/bweb/controller/ApiProductController.java index 0f09bf86..7e7fdbdd 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/ApiProductController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/ApiProductController.java @@ -334,4 +334,19 @@ public class ApiProductController { } } + @RequestMapping(value = "/getStarbucksProducts", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询星巴克产品") + public ResponseData getStarbucksProducts() { + try { + + return ResponseMsgUtil.success(apiProductService.getStarbucksProducts(new HashMap<>())); + + } catch (Exception e) { + log.error("ApiMerchantsController --> findById() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + } diff --git a/hai-bweb/src/main/java/com/bweb/controller/BsProductConfigController.java b/hai-bweb/src/main/java/com/bweb/controller/BsProductConfigController.java new file mode 100644 index 00000000..8a8439f4 --- /dev/null +++ b/hai-bweb/src/main/java/com/bweb/controller/BsProductConfigController.java @@ -0,0 +1,225 @@ +package com.bweb.controller; + +import com.alibaba.fastjson.JSONObject; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.hai.common.exception.ErrorCode; +import com.hai.common.exception.ErrorHelp; +import com.hai.common.exception.SysCode; +import com.hai.common.security.SessionObject; +import com.hai.common.security.UserCenter; +import com.hai.common.utils.PageUtil; +import com.hai.common.utils.ResponseMsgUtil; +import com.hai.entity.ApiProduct; +import com.hai.entity.ApiStarbucksProducts; +import com.hai.entity.BsProductConfig; +import com.hai.entity.OutRechargePrice; +import com.hai.model.BsProductConfigModel; +import com.hai.model.OutRechargePriceModel; +import com.hai.model.ResponseData; +import com.hai.model.UserInfoModel; +import com.hai.service.ApiProductService; +import com.hai.service.BsConfigService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.models.auth.In; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.*; + + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Controller +@RequestMapping(value = "/bsProductConfig") +@Api(value = "api产品") +public class BsProductConfigController { + + Logger log = LoggerFactory.getLogger(BsProductConfigController.class); + + @Resource + private ApiProductService apiProductService; + + @Resource + private BsConfigService bsConfigService; + + @Autowired + private UserCenter userCenter; + + @RequestMapping(value = "/getProductConfig", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询配置产品") + public ResponseData getProductConfig(@RequestParam(value = "productName", required = false) String productName, + @RequestParam(value = "productType", required = false) Integer productType, + @RequestParam(name = "pageNum", required = true) Integer pageNum, + @RequestParam(name = "pageSize", required = true) Integer pageSize, + HttpServletRequest request) { + try { + SessionObject sessionObject = userCenter.getSessionObject(request); + UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); + + Map map = new HashMap<>(); + map.put("companyId", String.valueOf(userInfoModel.getBsCompany().getId())); + map.put("productName", productName); + map.put("productType", productType); + + + List productConfigs = apiProductService.getProductConfig(map); + + Map listMap; + + List productConfigModels = new ArrayList<>(); + + for (BsProductConfig list : productConfigs) { + BsProductConfigModel bsProductConfigModel = new BsProductConfigModel(); + listMap = new HashMap<>(); + listMap.put("returnType", 2); + listMap.put("productType", "5"); + listMap.put("sourceId", list.getId()); + BeanUtils.copyProperties(list, bsProductConfigModel); + bsProductConfigModel.setIntegralDiscount(bsConfigService.getProductDiscountByMap(listMap).getDiscount()); + bsProductConfigModel.setProductPayTypeString(bsConfigService.getProductPayTypeByMap(listMap)); + bsProductConfigModel.setProductPlatformString(bsConfigService.getProductPlatformByMap(listMap)); + productConfigModels.add(bsProductConfigModel); + + } + + return ResponseMsgUtil.success(PageUtil.initPageInfoObj(pageNum,productConfigModels.size(),pageSize,new PageInfo<>(productConfigModels))); + } catch (Exception e) { + log.error("OutRechargePriceController --> findById() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/productConfig", method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "新增产品配置") + public ResponseData productConfig(@RequestBody JSONObject object, HttpServletRequest request) { + try { + + SessionObject sessionObject = userCenter.getSessionObject(request); + UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); + + if (object == null || + object.getJSONArray("productIds") == null || + object.getBigDecimal("discount") == null || + object.getInteger("productType") == null || + object.getJSONArray("productPlatform") == null || + object.getJSONArray("payType") == null + ) { + log.error("OutRechargePriceController -> productConfig() error!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + + object.put("operatorId", userInfoModel.getSecUser().getId()); + object.put("operatorName", userInfoModel.getSecUser().getLoginName()); + object.put("companyId", userInfoModel.getBsCompany().getId()); + + apiProductService.ProductConfig(object); + + + return ResponseMsgUtil.success("新增成功"); + + } catch (Exception e) { + log.error("OutRechargePriceController --> insertPrice() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/updateProductConfig", method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "编辑产品配置") + public ResponseData updateProductConfig(@RequestBody JSONObject object, HttpServletRequest request) { + try { + + SessionObject sessionObject = userCenter.getSessionObject(request); + UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); + + if (object == null || + object.getLong("id") == null || + object.getJSONArray("productIds") == null || + object.getBigDecimal("discount") == null || + object.getInteger("productType") == null || + object.getJSONArray("productPlatform") == null || + object.getJSONArray("payType") == null + ) { + log.error("OutRechargePriceController -> productConfig() error!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + + object.put("operatorId", userInfoModel.getSecUser().getId()); + object.put("operatorName", userInfoModel.getSecUser().getLoginName()); + object.put("companyId", userInfoModel.getBsCompany().getId()); + + apiProductService.updateProductConfig(object); + + + return ResponseMsgUtil.success("新增成功"); + + } catch (Exception e) { + log.error("OutRechargePriceController --> insertPrice() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + + @RequestMapping(value = "/findProductConfig", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "根据id查询详情") + public ResponseData findProductConfig(@RequestParam(value = "id", required = true) Long id) { + try { + + BsProductConfig bsProductConfig = apiProductService.findProductConfig(id); + + BsProductConfigModel bsProductConfigModel = new BsProductConfigModel(); + BeanUtils.copyProperties(bsProductConfig, bsProductConfigModel); + Map listMap = new HashMap<>(); + listMap.put("productType", "5"); + listMap.put("returnType", 1); + listMap.put("sourceId", bsProductConfig.getId()); + listMap.put("platformId", null); + + bsProductConfigModel.setIntegralDiscount(bsConfigService.getProductDiscountByMap(listMap).getDiscount()); + bsProductConfigModel.setProductPayTypeString(bsConfigService.getProductPayTypeByMap(listMap)); + bsProductConfigModel.setProductPlatformString(bsConfigService.getProductPlatformByMap(listMap)); + return ResponseMsgUtil.success(bsProductConfigModel); + + } catch (Exception e) { + log.error("OutRechargePriceController --> findById() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/findStarbucksProducts", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "根据id查询详情产品详情") + public ResponseData findStarbucksProducts(@RequestParam(value = "id", required = true) Long id) { + try { + + BsProductConfig bsProductConfig = apiProductService.findProductConfig(id); + + ApiStarbucksProducts apiStarbucksProducts = apiProductService.findStarbucksProducts(bsProductConfig.getProductId()); + + apiStarbucksProducts.setSalesVentiPrice(apiStarbucksProducts.getMarketVentiPrice().multiply(bsProductConfig.getDiscount()).divide(new BigDecimal(100))); + apiStarbucksProducts.setSalesTallPrice(apiStarbucksProducts.getMarketTallPrice().multiply(bsProductConfig.getDiscount()).divide(new BigDecimal(100))); + apiStarbucksProducts.setSalesGrandePrice(apiStarbucksProducts.getMarketGrandePrice().multiply(bsProductConfig.getDiscount()).divide(new BigDecimal(100))); + + return ResponseMsgUtil.success(apiStarbucksProducts); + + + } catch (Exception e) { + log.error("OutRechargePriceController --> findById() error!", e); + return ResponseMsgUtil.exception(e); + } + } + +} diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighTestController.java b/hai-bweb/src/main/java/com/bweb/controller/HighTestController.java index 5f247d45..4f5607ab 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighTestController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighTestController.java @@ -1 +1 @@ -package com.bweb.controller; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.bweb.config.SysConst; import com.google.gson.JsonObject; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.pay.util.XmlUtil; import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.utils.*; import com.hai.config.*; import com.hai.dao.HighCouponCodeOtherMapper; import com.hai.dao.HighGasOrderPushMapper; import com.hai.dao.HighUserCouponMapper; import com.hai.entity.*; import com.hai.enum_type.OrderPushType; import com.hai.model.*; import com.hai.service.*; import com.hai.service.pay.impl.GoodsOrderServiceImpl; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpPost; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.ssl.SSLContexts; import org.apache.http.util.EntityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import javax.annotation.Resource; import javax.net.ssl.SSLContext; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.*; import java.math.BigDecimal; import java.security.KeyStore; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.*; /** * @Auther: 胡锐 * @Description: * @Date: 2021/3/26 23:08 */ @Controller @RequestMapping(value = "/test") @Api(value = "订单接口") public class HighTestController { private static Logger log = LoggerFactory.getLogger(HighTestController.class); @Resource private OutRechargeOrderService outRechargeOrderService; @Resource private HighOrderService highOrderService; @Resource private HighUserService highUserService; @Resource private HighOilCardService oilCardService; @Resource private ApiOpenService apiOpenService; @RequestMapping(value = "/kfcRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "KFC退款") public ResponseData kfcRefund(@RequestParam(name = "orderNo", required = true) String orderNo,HttpServletRequest request) { try { OrderRefundModel orderRefundModel = null; if (StringUtils.isNotBlank(orderNo)) { // 查询订单 HighOrder order = highOrderService.getOrderByOrderNo(orderNo); // 订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消 6.退款中 7.拒绝退款 if (order != null && order.getOrderStatus() == 2) { orderRefundModel = WxOrderConfig.orderToRefund(order.getPaySerialNo(), order.getPayRealPrice(), "1609882817", order.getPayRealPrice()); if(orderRefundModel.getResult_code().equals("SUCCESS")) { for (HighChildOrder childOrder : order.getHighChildOrderList()) { childOrder.setChildOrdeStatus(4); } order.setOrderStatus(4); order.setRefundTime(new Date()); order.setRefundPrice(order.getPayRealPrice()); highOrderService.updateOrder(order); return ResponseMsgUtil.success(orderRefundModel); } } } return ResponseMsgUtil.success(orderRefundModel); } catch (Exception e) { log.error("HighUserCardController --> oilCardRefund() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/oilCardRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "油卡退款") public ResponseData oilCardRefund(@RequestParam(name = "orderNo", required = true) String orderNo,HttpServletRequest request) { try { oilCardService.refund(orderNo); return ResponseMsgUtil.success(""); } catch (Exception e) { log.error("HighUserCardController --> oilCardRefund() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value="/resolveResponse",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "解析") public ResponseData resolveResponse( @RequestParam(name = "data", required = false) String data ) { try { JSONObject cardInfoObject = HuiLianTongUnionCardConfig.resolveResponse(data); return ResponseMsgUtil.success(cardInfoObject); } catch (Exception e) { log.error("getUserByTelephone",e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getHuiLianTongCardConsume", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询汇联通工会卡消费记录") public ResponseData getHuiLianTongCardConsume(@RequestParam(name = "businessType", required = true) String businessType, @RequestParam(name = "cardNo", required = true) String cardNo, @RequestParam(name = "sdate", required = true) Long sdate, @RequestParam(name = "edate", required = true) Long edate, @RequestParam(name = "pageNum", required = true) Integer pageNum, @RequestParam(name = "pageSize", required = true) Integer pageSize, HttpServletRequest request) { try { JSONObject consumptionRecord = HuiLianTongUnionCardConfig.queryConsumptionRecordByBusiness(businessType, cardNo, sdate, edate, pageNum, pageSize); if (StringUtils.isBlank(consumptionRecord.getString("data"))) { throw ErrorHelp.genException(SysCode.System, ErrorCode.REQUEST_ERROR, ""); } return ResponseMsgUtil.success(HuiLianTongUnionCardConfig.resolveResponse(consumptionRecord.getString("data"))); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardConsume() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/orderToRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "积分充值退款") public ResponseData orderToRefund(@RequestParam(name = "orderId", required = true) Long orderId ,HttpServletRequest request) { try { HighOrder highOrder = highOrderService.getOrderById(orderId); // 微信退款 OrderRefundModel orderRefundModel = WxOrderConfig.orderToRefund(highOrder.getPaySerialNo(), highOrder.getPayRealPrice(), highOrder.getPayRealPrice()); if(orderRefundModel.getResult_code().equals("SUCCESS")) { for (HighChildOrder childOrder : highOrder.getHighChildOrderList()) { childOrder.setChildOrdeStatus(4); } highOrder.setOrderStatus(4); highOrder.setRefundTime(new Date()); highOrder.setRefundPrice(highOrder.getPayRealPrice()); highOrderService.updateOrder(highOrder); } if (highUserService.findGoldRepeat(3 , highOrder.getId())) { highUserService.goldHandle(highOrder.getMemId(), highOrder.getPayRealPrice().multiply(BigDecimal.valueOf(100)).intValue(), 2, 3, highOrder.getId()); }else { log.error("orderToPay error!", "已有退款记录"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "已有退款记录"); } return ResponseMsgUtil.success(orderRefundModel); } catch (Exception e) { log.error("HighOrderController --> orderToRefund() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/orderToRefundByHlt", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "汇联通充值退款") public ResponseData orderToRefundByHlt(@RequestParam(name = "orderId", required = true) Long orderId ,HttpServletRequest request) { try { HighOrder highOrder = highOrderService.getOrderById(orderId); // 微信退款 OrderRefundModel orderRefundModel = WxOrderConfig.orderToRefund(highOrder.getPaySerialNo(), highOrder.getPayRealPrice(), WxOrderConfig.MCH_ID_1619676214 , highOrder.getPayRealPrice()); if(orderRefundModel.getResult_code().equals("SUCCESS")) { for (HighChildOrder childOrder : highOrder.getHighChildOrderList()) { childOrder.setChildOrdeStatus(4); } highOrder.setOrderStatus(4); highOrder.setRefundTime(new Date()); highOrder.setRefundPrice(highOrder.getPayRealPrice()); highOrderService.updateOrder(highOrder); } return ResponseMsgUtil.success(orderRefundModel); } catch (Exception e) { log.error("HighOrderController --> orderToRefund() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/rechargeOrderToRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "话费退款") public ResponseData rechargeOrderToRefund( @RequestParam(name = "orderId", required = true) Long orderId) { try { outRechargeOrderService.rechargeOrderToRefund(orderId); return ResponseMsgUtil.success("退款成功"); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/postApi", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "请求Api") public ResponseData postApi(HttpServletRequest request) { try { Map map = new HashMap<>(); map.put("apiKey" , "9A838BEBC60712775E119366DB804C43"); map.put("merchId" , "20220670800"); map.put("apiConfigProductId" , "11"); map.put("orderNo" , "TEST" + DateUtil.date2String(new Date(), "yyyyMMddHHmmss") + IDGenerator.nextId(5)); map.put("notifyUrl" , "https://hsgcs.dctpay.com/crest/czOrder/apiCallBack"); map.put("mobile" , "18090580471"); String sign = WxUtils.generateSignApi(map , MapUtils.getString(map , "apiKey"), WXPayConstants.SignType.MD5); map.put("sign" , sign); JSONObject object = HttpsUtils.doPost("http://localhost:9902/v1/rechargeProduct/createOrder" , map , new HashMap<>()); return ResponseMsgUtil.success(object); } catch (Exception e) { log.error("HighUserCardController --> oilCardRefund() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/肯德基请求接口", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "肯德基请求接口") public ResponseData requestOrder() { try { return ResponseMsgUtil.success(apiOpenService.getAllCities()); } catch (Exception e) { log.error("HighUserCardController --> oilCardRefund() error!", e); return ResponseMsgUtil.exception(e); } } } \ No newline at end of file +package com.bweb.controller; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.bweb.config.SysConst; import com.google.gson.JsonObject; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.pay.util.XmlUtil; import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.utils.*; import com.hai.config.*; import com.hai.dao.HighCouponCodeOtherMapper; import com.hai.dao.HighGasOrderPushMapper; import com.hai.dao.HighUserCouponMapper; import com.hai.entity.*; import com.hai.enum_type.OrderPushType; import com.hai.model.*; import com.hai.service.*; import com.hai.service.pay.impl.GoodsOrderServiceImpl; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpPost; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.ssl.SSLContexts; import org.apache.http.util.EntityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import javax.annotation.Resource; import javax.net.ssl.SSLContext; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.*; import java.math.BigDecimal; import java.security.KeyStore; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.*; /** * @Auther: 胡锐 * @Description: * @Date: 2021/3/26 23:08 */ @Controller @RequestMapping(value = "/test") @Api(value = "订单接口") public class HighTestController { private static Logger log = LoggerFactory.getLogger(HighTestController.class); @Resource private OutRechargeOrderService outRechargeOrderService; @Resource private HighOrderService highOrderService; @Resource private HighUserService highUserService; @Resource private HighOilCardService oilCardService; @Resource private ApiProductService apiProductService; @RequestMapping(value = "/kfcRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "KFC退款") public ResponseData kfcRefund(@RequestParam(name = "orderNo", required = true) String orderNo,HttpServletRequest request) { try { OrderRefundModel orderRefundModel = null; if (StringUtils.isNotBlank(orderNo)) { // 查询订单 HighOrder order = highOrderService.getOrderByOrderNo(orderNo); // 订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消 6.退款中 7.拒绝退款 if (order != null && order.getOrderStatus() == 2) { orderRefundModel = WxOrderConfig.orderToRefund(order.getPaySerialNo(), order.getPayRealPrice(), "1609882817", order.getPayRealPrice()); if(orderRefundModel.getResult_code().equals("SUCCESS")) { for (HighChildOrder childOrder : order.getHighChildOrderList()) { childOrder.setChildOrdeStatus(4); } order.setOrderStatus(4); order.setRefundTime(new Date()); order.setRefundPrice(order.getPayRealPrice()); highOrderService.updateOrder(order); return ResponseMsgUtil.success(orderRefundModel); } } } return ResponseMsgUtil.success(orderRefundModel); } catch (Exception e) { log.error("HighUserCardController --> oilCardRefund() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/oilCardRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "油卡退款") public ResponseData oilCardRefund(@RequestParam(name = "orderNo", required = true) String orderNo,HttpServletRequest request) { try { oilCardService.refund(orderNo); return ResponseMsgUtil.success(""); } catch (Exception e) { log.error("HighUserCardController --> oilCardRefund() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value="/resolveResponse",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "解析") public ResponseData resolveResponse( @RequestParam(name = "data", required = false) String data ) { try { JSONObject cardInfoObject = HuiLianTongUnionCardConfig.resolveResponse(data); return ResponseMsgUtil.success(cardInfoObject); } catch (Exception e) { log.error("getUserByTelephone",e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getHuiLianTongCardConsume", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询汇联通工会卡消费记录") public ResponseData getHuiLianTongCardConsume(@RequestParam(name = "businessType", required = true) String businessType, @RequestParam(name = "cardNo", required = true) String cardNo, @RequestParam(name = "sdate", required = true) Long sdate, @RequestParam(name = "edate", required = true) Long edate, @RequestParam(name = "pageNum", required = true) Integer pageNum, @RequestParam(name = "pageSize", required = true) Integer pageSize, HttpServletRequest request) { try { JSONObject consumptionRecord = HuiLianTongUnionCardConfig.queryConsumptionRecordByBusiness(businessType, cardNo, sdate, edate, pageNum, pageSize); if (StringUtils.isBlank(consumptionRecord.getString("data"))) { throw ErrorHelp.genException(SysCode.System, ErrorCode.REQUEST_ERROR, ""); } return ResponseMsgUtil.success(HuiLianTongUnionCardConfig.resolveResponse(consumptionRecord.getString("data"))); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardConsume() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/orderToRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "积分充值退款") public ResponseData orderToRefund(@RequestParam(name = "orderId", required = true) Long orderId ,HttpServletRequest request) { try { HighOrder highOrder = highOrderService.getOrderById(orderId); // 微信退款 OrderRefundModel orderRefundModel = WxOrderConfig.orderToRefund(highOrder.getPaySerialNo(), highOrder.getPayRealPrice(), highOrder.getPayRealPrice()); if(orderRefundModel.getResult_code().equals("SUCCESS")) { for (HighChildOrder childOrder : highOrder.getHighChildOrderList()) { childOrder.setChildOrdeStatus(4); } highOrder.setOrderStatus(4); highOrder.setRefundTime(new Date()); highOrder.setRefundPrice(highOrder.getPayRealPrice()); highOrderService.updateOrder(highOrder); } if (highUserService.findGoldRepeat(3 , highOrder.getId())) { highUserService.goldHandle(highOrder.getMemId(), highOrder.getPayRealPrice().multiply(BigDecimal.valueOf(100)).intValue(), 2, 3, highOrder.getId()); }else { log.error("orderToPay error!", "已有退款记录"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "已有退款记录"); } return ResponseMsgUtil.success(orderRefundModel); } catch (Exception e) { log.error("HighOrderController --> orderToRefund() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/orderToRefundByHlt", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "汇联通充值退款") public ResponseData orderToRefundByHlt(@RequestParam(name = "orderId", required = true) Long orderId ,HttpServletRequest request) { try { HighOrder highOrder = highOrderService.getOrderById(orderId); // 微信退款 OrderRefundModel orderRefundModel = WxOrderConfig.orderToRefund(highOrder.getPaySerialNo(), highOrder.getPayRealPrice(), WxOrderConfig.MCH_ID_1619676214 , highOrder.getPayRealPrice()); if(orderRefundModel.getResult_code().equals("SUCCESS")) { for (HighChildOrder childOrder : highOrder.getHighChildOrderList()) { childOrder.setChildOrdeStatus(4); } highOrder.setOrderStatus(4); highOrder.setRefundTime(new Date()); highOrder.setRefundPrice(highOrder.getPayRealPrice()); highOrderService.updateOrder(highOrder); } return ResponseMsgUtil.success(orderRefundModel); } catch (Exception e) { log.error("HighOrderController --> orderToRefund() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/rechargeOrderToRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "话费退款") public ResponseData rechargeOrderToRefund( @RequestParam(name = "orderId", required = true) Long orderId) { try { outRechargeOrderService.rechargeOrderToRefund(orderId); return ResponseMsgUtil.success("退款成功"); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } // @RequestMapping(value = "/getStarbucksProducts", method = RequestMethod.GET) // @ResponseBody // @ApiOperation(value = "更新星巴克商品") // public ResponseData getStarbucksProducts(HttpServletRequest request) { // try { // // Map map = new HashMap<>(); // // JSONObject jsonObject = QianZhuConfig.getStarbucksProducts(1 , 100); // // JSONObject object = jsonObject.getJSONObject("data"); // JSONArray array = object.getJSONArray("items"); // for (Object data : array) { // JSONObject dataObject = (JSONObject) data; // // ApiStarbucksProducts starbucksProducts = apiProductService.findStarbucksProductsByGoodsId(dataObject.getLong("id")); // // if (dataObject.getInteger("shelfStatus") == 5) { // if (starbucksProducts == null) { // starbucksProducts = new ApiStarbucksProducts(); // } // starbucksProducts.setCategoryName(dataObject.getString("categoryName")); // starbucksProducts.setCream(dataObject.getString("cream")); // starbucksProducts.setCupSize(dataObject.getString("cupSize")); // starbucksProducts.setDefaultImage(dataObject.getString("defaultImage")); // starbucksProducts.setDes(dataObject.getString("des")); // starbucksProducts.setEspresso(dataObject.getString("espresso")); // starbucksProducts.setMarketGrandePrice(dataObject.getBigDecimal("marketGrandePrice")); // starbucksProducts.setMarketTallPrice(dataObject.getBigDecimal("marketTallPrice")); // starbucksProducts.setMarketVentiPrice(dataObject.getBigDecimal("marketVentiPrice")); // starbucksProducts.setSalesGrandePrice(dataObject.getBigDecimal("salesGrandePrice")); // starbucksProducts.setSalesTallPrice(dataObject.getBigDecimal("salesTallPrice")); // starbucksProducts.setSalesVentiPrice(dataObject.getBigDecimal("salesVentiPrice")); // starbucksProducts.setMilk(dataObject.getString("milk")); // starbucksProducts.setMilkBubble(dataObject.getString("milkBubble")); // starbucksProducts.setName(dataObject.getString("name")); // starbucksProducts.setTemperature(dataObject.getString("temperature")); // if (starbucksProducts.getId() == null) { // starbucksProducts.setCreateTime(new Date()); // starbucksProducts.setOperatorId(9999L); // starbucksProducts.setOperatorName("系统生成"); // starbucksProducts.setStatus(100); // starbucksProducts.setGoodsId(dataObject.getLong("id")); // apiProductService.insertStarbucksProducts(starbucksProducts); // } else { // starbucksProducts.setUpdateTime(new Date()); // apiProductService.updateStarbucksProducts(starbucksProducts); // } // } // } // return ResponseMsgUtil.success("商品生成成功"); // // } catch (Exception e) { // log.error("HighUserCardController --> oilCardRefund() error!", e); // return ResponseMsgUtil.exception(e); // } // } @RequestMapping(value = "/getKfcStore", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询肯德基门店") public ResponseData getKfcStore(HttpServletRequest request) { try { JSONObject jsonObject = QianZhuConfig.getKfcStore(); JSONArray object = jsonObject.getJSONArray("data"); for (Object data : object) { JSONObject dataObject = (JSONObject) data; Map mapStore = new HashMap<>(); mapStore.put("storeCode" , dataObject.getString("storeCode")); ApiKfcStores apiKfcStores = apiProductService.findKfcStores(mapStore); if (apiKfcStores == null) { apiKfcStores = new ApiKfcStores(); } apiKfcStores.setProvinceCode(dataObject.getString("provinceCode")); apiKfcStores.setProvinceName(dataObject.getString("provinceName")); apiKfcStores.setCityCode(dataObject.getString("cityCode")); apiKfcStores.setCityName(dataObject.getString("cityName")); apiKfcStores.setCityNameFirstLetter(dataObject.getString("cityNameFirstLetter")); apiKfcStores.setKfcCityId(dataObject.getInteger("kfcCityId")); apiKfcStores.setKfcCityCode(dataObject.getString("kfcCityCode")); apiKfcStores.setStoreName(dataObject.getString("storeName")); apiKfcStores.setStoreCode(dataObject.getString("storeCode")); apiKfcStores.setLon(dataObject.getString("lon")); apiKfcStores.setLat(dataObject.getString("lat")); apiKfcStores.setAddress(dataObject.getString("address")); apiKfcStores.setStartTime(dataObject.getString("startTime")); apiKfcStores.setEndTime(dataObject.getString("endTime")); apiKfcStores.setStoreStatus(dataObject.getInteger("storeStatus")); apiKfcStores.setShelfStatus(dataObject.getInteger("shelfStatus")); if (apiKfcStores.getId() == null) { apiKfcStores.setCreateTime(new Date()); apiKfcStores.setOperatorId(9999L); apiKfcStores.setOperatorName("系统生成"); apiKfcStores.setStatus(100); apiProductService.insertKfcStore(apiKfcStores); } else { apiKfcStores.setUpdateTime(new Date()); apiProductService.updateKfcStore(apiKfcStores); } } return ResponseMsgUtil.success("生成成功"); } catch (Exception e) { log.error("HighUserCardController --> oilCardRefund() error!", e); return ResponseMsgUtil.exception(e); } } } \ No newline at end of file diff --git a/hai-cweb/src/main/java/com/cweb/config/SysConfig.java b/hai-cweb/src/main/java/com/cweb/config/SysConfig.java index e0ab11e9..3753b3ef 100644 --- a/hai-cweb/src/main/java/com/cweb/config/SysConfig.java +++ b/hai-cweb/src/main/java/com/cweb/config/SysConfig.java @@ -25,6 +25,7 @@ public class SysConfig { private String wxUnifiedOrderUrl; private String couponCodePath; private String notifyUrl; + private String imgUrl; private String qzNotifyUrl; private String wxGzSubAppId; @@ -168,4 +169,12 @@ public class SysConfig { public void setWxGzSubMchId(String wxGzSubMchId) { this.wxGzSubMchId = wxGzSubMchId; } + + public String getImgUrl() { + return imgUrl; + } + + public void setImgUrl(String imgUrl) { + this.imgUrl = imgUrl; + } } diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighThirdPartyController.java b/hai-cweb/src/main/java/com/cweb/controller/HighThirdPartyController.java new file mode 100644 index 00000000..2a5be215 --- /dev/null +++ b/hai-cweb/src/main/java/com/cweb/controller/HighThirdPartyController.java @@ -0,0 +1,281 @@ +package com.cweb.controller; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.cweb.config.SysConfig; +import com.cweb.config.SysConst; +import com.hai.common.exception.ErrorCode; +import com.hai.common.exception.ErrorHelp; +import com.hai.common.exception.SysCode; +import com.hai.common.security.SessionObject; +import com.hai.common.security.UserCenter; +import com.hai.common.utils.CoordCommonUtil; +import com.hai.common.utils.ResponseMsgUtil; +import com.hai.config.CommonSysConst; +import com.hai.config.QianZhuConfig; +import com.hai.entity.*; +import com.hai.enum_type.ProductImgEnum; +import com.hai.model.ApiStarbucksProductsModel; +import com.hai.model.BsProductConfigModel; +import com.hai.model.HighUserModel; +import com.hai.model.ResponseData; +import com.hai.service.ApiProductService; +import com.hai.service.BsConfigService; +import com.hai.service.HighOrderService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.collections4.MapUtils; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.*; +import org.w3c.dom.ls.LSException; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.math.BigDecimal; +import java.util.*; +import java.util.stream.Collectors; + + +@Controller +@RequestMapping(value = "/highThirdParty") +@Api(value = "订单接口") +public class HighThirdPartyController { + + private static Logger log = LoggerFactory.getLogger(HighThirdPartyController.class); + + @Resource + private ApiProductService apiProductService; + + @Resource + private BsConfigService bsConfigService; + + @Resource + private HighOrderService highOrderService; + + @Autowired + private UserCenter userCenter; + + + @RequestMapping(value = "/getAllCity", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询所有城市") + public ResponseData getAllCity(@RequestParam(name = "cityName", required = false) String cityName) { + try { + return ResponseMsgUtil.success(apiProductService.getAllCity(cityName)); + + } catch (Exception e) { + log.error("HighUserCardController --> oilCardRefund() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/getStarbucksProducts", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询星巴克商品") + public ResponseData getStarbucksProducts(@RequestParam(name = "name", required = false) String name) { + try { + + List CategoryNameList = apiProductService.getCategoryName(); + + List starbucksProductsList = new ArrayList<>(); + int i = 9999; + for (String s : CategoryNameList) { + i++; + ApiStarbucksProducts starbucksProducts = new ApiStarbucksProducts(); + Map map = new HashMap<>(); + map.put("name" , name); + map.put("categoryName" , s); + List list = apiProductService.getStarbucksProducts(map); + for (ApiStarbucksProducts apiStarbucksProducts : list) { + apiStarbucksProducts.setExt1(String.valueOf(i)); + starbucksProductsList.add(apiStarbucksProducts); + } + starbucksProducts.setName(s); + starbucksProducts.setExt2(SysConst.getSysConfig().getImgUrl() + ProductImgEnum.getNameByImgUrl(s)); + starbucksProducts.setId((long) i); + starbucksProductsList.add(starbucksProducts); + } + + return ResponseMsgUtil.success(starbucksProductsList); + + } catch (Exception e) { + log.error("HighUserCardController --> oilCardRefund() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/getStarbucksStore", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询星巴克门店") + public ResponseData getStarbucksStore(@RequestParam(name = "lat", required = true) String lat, + @RequestParam(name = "lon", required = true) String lon) { + try { + JSONObject jsonObject = QianZhuConfig.getStarbucksStore(lat , lon); + if (jsonObject.getBoolean("success")) { + return ResponseMsgUtil.success(jsonObject.getJSONArray("data")); + } else { + log.error("getRechargeProduct error!", "查询失败!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR , jsonObject.getString("message")); + } + + } catch (Exception e) { + log.error("HighUserCardController --> oilCardRefund() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/findStarbucksProducts", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "根据id查询详情产品详情") + public ResponseData findStarbucksProducts(@RequestParam(value = "id", required = true) Long id) { + try { + + BsProductConfig bsProductConfig = apiProductService.findProductConfigByGoodsId(id); + + if (bsProductConfig == null) { + log.error("findStarbucksProducts error!", "查询失败!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR , "未查询到当前商品"); + } + + ApiStarbucksProducts apiStarbucksProducts = apiProductService.findStarbucksProducts(bsProductConfig.getProductId()); + apiStarbucksProducts.setSalesVentiPrice(apiStarbucksProducts.getMarketVentiPrice().multiply(bsProductConfig.getDiscount()).divide(new BigDecimal(100))); + apiStarbucksProducts.setSalesTallPrice(apiStarbucksProducts.getMarketTallPrice().multiply(bsProductConfig.getDiscount()).divide(new BigDecimal(100))); + apiStarbucksProducts.setSalesGrandePrice(apiStarbucksProducts.getMarketGrandePrice().multiply(bsProductConfig.getDiscount()).divide(new BigDecimal(100))); + + ApiStarbucksProductsModel starbucksProductsModel = new ApiStarbucksProductsModel(); + BeanUtils.copyProperties(apiStarbucksProducts, starbucksProductsModel); + + Map listMap = new HashMap<>(); + listMap.put("productType", "5"); + listMap.put("returnType", 1); + listMap.put("sourceId", bsProductConfig.getId()); + listMap.put("platformId", null); + + starbucksProductsModel.setIntegralDiscount(bsConfigService.getProductDiscountByMap(listMap).getDiscount()); + starbucksProductsModel.setProductPayTypeString(bsConfigService.getProductPayTypeByMap(listMap)); + starbucksProductsModel.setProductPlatformString(bsConfigService.getProductPlatformByMap(listMap)); + + return ResponseMsgUtil.success(starbucksProductsModel); + + + } catch (Exception e) { + log.error("OutRechargePriceController --> findById() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/addOrder", method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "增加订单") + public ResponseData addOrder(@RequestBody JSONObject object, HttpServletRequest request) { + try { + + // 用户 + SessionObject sessionObject = userCenter.getSessionObject(request); + HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject(); + + + if (StringUtils.isBlank(object.getString("customerMobile")) || + StringUtils.isBlank(object.getString("regionId")) || + StringUtils.isBlank(object.getString("productType")) || + object.getJSONArray("orderItems") == null + ) { + log.error("addOrder error!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + + object.put("userId", userInfoModel.getHighUser().getId()); + + highOrderService.insertThirdProduct(object); + + return ResponseMsgUtil.success("下单成功"); + + } catch (Exception e) { + log.error("HighOrderController -> addOrder() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/getKfcStoresList", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询肯德基门店") + public ResponseData getKfcStoresList(@RequestParam(name = "storeName", required = false) String storeName, + @RequestParam(name = "cityCode", required = true) String cityCode, + @RequestParam(name = "lat", required = true) String lat, + @RequestParam(name = "lon", required = true) String lon) { + try { + + Map map = new HashMap<>(); + map.put("storeName" , storeName); + map.put("cityCode" , cityCode); + + List list = apiProductService.getKfcStoresList(map); + + if (StringUtils.isNotBlank(lat)){ + for (ApiKfcStores stores : list) { + double distance = CoordCommonUtil.getDistance(Double.valueOf(stores.getLat()), Double.valueOf(stores.getLon()), Double.valueOf(lat), Double.valueOf(lon)); + stores.setDistance(String.valueOf(Math.round(distance/100d)/10d)); + } + } + + return ResponseMsgUtil.success(list.stream().sorted(Comparator.comparing(ApiKfcStores::getDistance)).collect(Collectors.toList())); + + } catch (Exception e) { + log.error("HighUserCardController --> oilCardRefund() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/listByStoreCode", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询肯德基门店菜单") + public ResponseData listByStoreCode(@RequestParam(name = "storeCode", required = false) String storeCode) { + try { + + JSONObject jsonObject = QianZhuConfig.listByStoreCode(storeCode); + + JSONArray array = jsonObject.getJSONArray("data"); + + Map listMap = new HashMap<>(); + listMap.put("productType", "2"); + listMap.put("companyId", 2); + + List productConfigs = apiProductService.getProductConfig(listMap); + + for (Object data : array) { + JSONObject dataObject = (JSONObject) data; + if (dataObject.getJSONArray("products") != null) { + for (Object products : dataObject.getJSONArray("products")) { + JSONObject productsObject = (JSONObject) products; + BigDecimal productsPrice = productsObject.getBigDecimal("price"); + productsObject.put("salePrice" , productsPrice.add(productsPrice.multiply(productConfigs.get(0).getDiscount()).divide(new BigDecimal(100)))); + + if (productsObject.getJSONArray("specGroups") != null) { + for (Object specGroups : productsObject.getJSONArray("specGroups")) { + JSONObject specGroupsObject = (JSONObject) specGroups; + BigDecimal specGroupsPrice = specGroupsObject.getBigDecimal("price"); + specGroupsObject.put("salePrice" , specGroupsPrice.add(specGroupsPrice.multiply(productConfigs.get(0).getDiscount()).divide(new BigDecimal(100)))); + } + } + } + } + } + + if (jsonObject.getBoolean("success")) { + return ResponseMsgUtil.success(array); + } else { + log.error("getRechargeProduct error!", "查询失败!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR , jsonObject.getString("message")); + } + + } catch (Exception e) { + log.error("HighUserCardController --> oilCardRefund() error!", e); + return ResponseMsgUtil.exception(e); + } + } +} diff --git a/hai-cweb/src/main/resources/dev/config.properties b/hai-cweb/src/main/resources/dev/config.properties index 4e9a74e1..657c7733 100644 --- a/hai-cweb/src/main/resources/dev/config.properties +++ b/hai-cweb/src/main/resources/dev/config.properties @@ -18,6 +18,7 @@ wxGzSubMchId=1619676214 HDAppId = 1614670195 notifyUrl=https://hsgcs.dctpay.com/crest/wechatpay/notify +imgUrl=https://hsgcs.dctpay.com/filesystem/ fileUrl=/home/project/hsg/filesystem cmsPath=/home/project/hsg/filesystem/cmsPath diff --git a/hai-cweb/src/main/resources/prod-9401/config.properties b/hai-cweb/src/main/resources/prod-9401/config.properties index 5b218155..ed2c6c16 100644 --- a/hai-cweb/src/main/resources/prod-9401/config.properties +++ b/hai-cweb/src/main/resources/prod-9401/config.properties @@ -16,6 +16,7 @@ wxGzSubMchId=1619676214 notifyUrl=https://hsg.dctpay.com/crest/wechatpay/notify +imgUrl=https://hsg.dctpay.com/filesystem/ fileUrl=/home/project/hsg/filesystem cmsPath=/home/project/hsg/filesystem/cmsPath diff --git a/hai-cweb/src/main/resources/prod/config.properties b/hai-cweb/src/main/resources/prod/config.properties index 154e7df2..6ad1b7f2 100644 --- a/hai-cweb/src/main/resources/prod/config.properties +++ b/hai-cweb/src/main/resources/prod/config.properties @@ -18,6 +18,7 @@ wxGzSubMchId=1619676214 HDAppId = 1614670195 notifyUrl=https://hsg.dctpay.com/crest/wechatpay/notify +imgUrl=https://hsg.dctpay.com/filesystem/ fileUrl=/home/project/hsg/filesystem cmsPath=/home/project/hsg/filesystem/cmsPath diff --git a/hai-schedule/src/main/java/com/hai/schedule/HighOrderSchedule.java b/hai-schedule/src/main/java/com/hai/schedule/HighOrderSchedule.java index 19f9dfec..62d8fa0b 100644 --- a/hai-schedule/src/main/java/com/hai/schedule/HighOrderSchedule.java +++ b/hai-schedule/src/main/java/com/hai/schedule/HighOrderSchedule.java @@ -99,7 +99,6 @@ public class HighOrderSchedule { map.put("rechargeStatus" , String.valueOf(204)); List orderList = outRechargeOrderService.getListRechargeOrder(map); - System.out.println("订单数量------------------------------------------------------------------------------" + orderList.size()); if (orderList.size() > 0) { for (OutRechargeOrder order : orderList) { try { diff --git a/hai-service/src/main/java/com/hai/common/exception/ErrorCode.java b/hai-service/src/main/java/com/hai/common/exception/ErrorCode.java index 3844e1fd..33d59c8b 100644 --- a/hai-service/src/main/java/com/hai/common/exception/ErrorCode.java +++ b/hai-service/src/main/java/com/hai/common/exception/ErrorCode.java @@ -135,6 +135,7 @@ public enum ErrorCode { ORDER_ALREADY_EXISTS("6007","订单已存在"), IP_ERROR("6008","IP不在白名单"), PRODUCT_ERROR("6009","商品错误"), + MERCHANT_NOT_AUTHORIZED("6010","商户无权限"), MSG_EVENT_NULL("2999","消息类型为空"), USE_VISIT_ILLEGAL("4001","用户身份错误"), diff --git a/hai-service/src/main/java/com/hai/common/utils/HttpsUtils.java b/hai-service/src/main/java/com/hai/common/utils/HttpsUtils.java index 107052d0..1c87283c 100644 --- a/hai-service/src/main/java/com/hai/common/utils/HttpsUtils.java +++ b/hai-service/src/main/java/com/hai/common/utils/HttpsUtils.java @@ -646,7 +646,7 @@ public class HttpsUtils { stringEntity.setContentEncoding("UTF-8"); stringEntity.setContentType("application/json"); httpPost.setEntity(stringEntity); - response = httpClient.execute(httpPost); + response = httpClient.execute(httpPost); HttpEntity entity = response.getEntity(); httpStr = EntityUtils.toString(entity, "UTF-8"); return JSON.parseObject(httpStr); diff --git a/hai-service/src/main/java/com/hai/config/CommonSysConfig.java b/hai-service/src/main/java/com/hai/config/CommonSysConfig.java index 759fa97e..54752e7b 100644 --- a/hai-service/src/main/java/com/hai/config/CommonSysConfig.java +++ b/hai-service/src/main/java/com/hai/config/CommonSysConfig.java @@ -26,6 +26,7 @@ public class CommonSysConfig { private String qinzhuUrl; private String qinzhuHtmlUrl; + private String qianzhuH5url; private String qinzhuMobileUrl; // 话费充值地址 private String qinzhuPlatformId; private String qinzhuSecret; @@ -176,6 +177,15 @@ public class CommonSysConfig { this.tuanYouGasolineAccount = tuanYouGasolineAccount; } + + public String getQianzhuH5url() { + return qianzhuH5url; + } + + public void setQianzhuH5url(String qianzhuH5url) { + this.qianzhuH5url = qianzhuH5url; + } + public String getQinzhuUrl() { return qinzhuUrl; } diff --git a/hai-service/src/main/java/com/hai/config/QianZhuConfig.java b/hai-service/src/main/java/com/hai/config/QianZhuConfig.java index 7d13f415..f5d02eeb 100644 --- a/hai-service/src/main/java/com/hai/config/QianZhuConfig.java +++ b/hai-service/src/main/java/com/hai/config/QianZhuConfig.java @@ -9,6 +9,7 @@ import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.utils.WxUtils; import com.hai.model.ResponseData; import io.swagger.annotations.ApiOperation; +import io.swagger.models.auth.In; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.web.bind.annotation.RequestMapping; @@ -177,6 +178,71 @@ public class QianZhuConfig { return HttpsUtils.doPost("https://nf.qianzhu8.com/gateway", JSON.toJSONString(map)); } + /** + * @Author Sum1Dream + * @name getAllCities.java + * @Description // 查询所有城市 + * @Date 15:45 2022/6/28 + * @Param [] + * @return com.alibaba.fastjson.JSONObject + */ + public static JSONObject getAllCities() throws Exception { + Map map = new HashMap<>(); + map.put("platformId", CommonSysConst.getSysConfig().getQinzhuPlatformId()); + map.put("timestamp", new Date().getTime()); + map.put("sign", MD5Util.encode(QianZhuConfig.generateSignature(map,CommonSysConst.getSysConfig().getQinzhuSecret()).getBytes()).toLowerCase()); + return HttpsUtils.doPost(CommonSysConst.getSysConfig().getQinzhuUrl()+"/openApi/v2/cities/listAll", JSONObject.toJSONString(map)); + } + + /** + * @Author Sum1Dream + * @name getStarbucksStore.java + * @Description // 查询星巴克门店 + * @Date 15:45 2022/6/28 + * @Param [] + * @return com.alibaba.fastjson.JSONObject + */ + public static JSONObject getStarbucksStore(String lat , String lon) throws Exception { + Map contentMap = new LinkedHashMap<>(); + contentMap.put("lon", lon); + contentMap.put("lat", lat); + + Map map = new HashMap<>(); + map.put("platformId", CommonSysConst.getSysConfig().getQinzhuPlatformId()); + map.put("timestamp", new Date().getTime()); + map.put("action", "starbucksStores.listByLonAndLat"); + map.put("content", JSON.toJSONString(contentMap)); + map.put("version", "1.0"); + map.put("traceId", WxUtils.makeNonStr()); + map.put("sign", MD5Util.encode(QianZhuConfig.generateSignature(map,CommonSysConst.getSysConfig().getQinzhuSecret()).getBytes()).toLowerCase()); + return HttpsUtils.doPost(CommonSysConst.getSysConfig().getQianzhuH5url(), JSONObject.toJSONString(map)); + } + + + /** + * @Author Sum1Dream + * @name getStarbucksProducts.java + * @Description // 查询星巴克商品 + * @Date 11:16 2022/6/29 + * @Param [java.lang.Integer, java.lang.Integer] + * @return com.alibaba.fastjson.JSONObject + */ + public static JSONObject getStarbucksProducts(Integer pageIndex , Integer pageSize) throws Exception { + Map contentMap = new LinkedHashMap<>(); + contentMap.put("pageIndex", pageIndex); + contentMap.put("pageSize", pageSize); + + Map map = new HashMap<>(); + map.put("platformId", CommonSysConst.getSysConfig().getQinzhuPlatformId()); + map.put("timestamp", new Date().getTime()); + map.put("action", "starbucksProducts.pagedQuery"); + map.put("content", JSON.toJSONString(contentMap)); + map.put("version", "1.0"); + map.put("traceId", WxUtils.makeNonStr()); + map.put("sign", MD5Util.encode(QianZhuConfig.generateSignature(map,CommonSysConst.getSysConfig().getQinzhuSecret()).getBytes()).toLowerCase()); + return HttpsUtils.doPost(CommonSysConst.getSysConfig().getQianzhuH5url(), JSONObject.toJSONString(map)); + } + /** * 生成签名 * @param data 数据 @@ -201,4 +267,106 @@ public class QianZhuConfig { sb.append(key); return sb.toString(); } + + /** + * @Author Sum1Dream + * @name getKfcStore.java + * @Description // 查询KFC门店 + * @Date 11:16 2022/6/29 + * @Param [java.lang.Integer, java.lang.Integer] + * @return com.alibaba.fastjson.JSONObject + */ + public static JSONObject getKfcStore() throws Exception { + Map map = new HashMap<>(); + map.put("platformId", CommonSysConst.getSysConfig().getQinzhuPlatformId()); + map.put("timestamp", new Date().getTime()); + map.put("sign", MD5Util.encode(QianZhuConfig.generateSignature(map,CommonSysConst.getSysConfig().getQinzhuSecret()).getBytes()).toLowerCase()); + return HttpsUtils.doPost(CommonSysConst.getSysConfig().getQinzhuUrl()+"/openApi/v2/kfcStores/listAll", JSONObject.toJSONString(map)); + } + + /** + * @Author Sum1Dream + * @name getKfcStore.java + * @Description // 查询KFC门店菜单 + * @Date 11:16 2022/6/29 + * @Param [java.lang.Integer, java.lang.Integer] + * @return com.alibaba.fastjson.JSONObject + */ + public static JSONObject listByStoreCode(String storeCode) throws Exception { + Map map = new HashMap<>(); + map.put("platformId", CommonSysConst.getSysConfig().getQinzhuPlatformId()); + map.put("storeCode", storeCode); + map.put("timestamp", new Date().getTime()); + map.put("sign", MD5Util.encode(QianZhuConfig.generateSignature(map,CommonSysConst.getSysConfig().getQinzhuSecret()).getBytes()).toLowerCase()); + return HttpsUtils.doPost(CommonSysConst.getSysConfig().getQinzhuUrl()+"/openApi/v1/kfcMenus/listByStoreCode", JSONObject.toJSONString(map)); + } + + /** + * @Author Sum1Dream + * @name starbucksOrders.java + * @Description // 星巴克下单 + * @Date 17:01 2022/7/4 + * @Param [java.lang.String, java.lang.String, java.lang.String, java.lang.String] + * @return com.alibaba.fastjson.JSONObject + */ + public static JSONObject starbucksOrders( String platformUniqueId ,String storeCode , String orderItems , String customerMobile) throws Exception { + + Map contentMap = new LinkedHashMap<>(); + contentMap.put("storeCode", storeCode); + contentMap.put("orderItems", orderItems); + contentMap.put("customerMobile", customerMobile); + contentMap.put("platformUniqueId", platformUniqueId); + Map map = new HashMap<>(); + map.put("platformId", CommonSysConst.getSysConfig().getQinzhuPlatformId()); + map.put("action", "starbucksOrders.createOrderV2"); + map.put("version", "1.0"); + map.put("content", JSON.toJSONString(contentMap)); + map.put("timestamp", new Date().getTime()); + map.put("sign", MD5Util.encode(QianZhuConfig.generateSignature(map,CommonSysConst.getSysConfig().getQinzhuSecret()).getBytes()).toLowerCase()); + return HttpsUtils.doPost(CommonSysConst.getSysConfig().getQianzhuH5url()+"/openApi/v1/kfcMenus/listByStoreCode", JSONObject.toJSONString(map)); + } + + /** + * @Author Sum1Dream + * @name starbucksOrdersPay.java + * @Description // 星巴克支付 + * @Date 17:03 2022/7/4 + * @Param [java.lang.String] + * @return com.alibaba.fastjson.JSONObject + */ + public static JSONObject starbucksOrdersPay(String orderNo) throws Exception { + Map contentMap = new LinkedHashMap<>(); + contentMap.put("orderNo", orderNo); + Map map = new HashMap<>(); + map.put("platformId", "10458"); + map.put("action", "starbucksOrders.pay"); + map.put("version", "1.0"); + map.put("content", JSON.toJSONString(contentMap)); + map.put("traceId", WxUtils.makeNonStr()); + map.put("timestamp", new Date().getTime()); + map.put("sign", MD5Util.encode(generateSignature(map,"nnl3gg4ss0pka11t").getBytes()).toLowerCase()); + return HttpsUtils.doPost(CommonSysConst.getSysConfig().getQianzhuH5url(), JSON.toJSONString(map)); + } + + /** + * @Author Sum1Dream + * @name createKfcOrder.java + * @Description // 创建kfc订单 + * @Date 17:35 2022/7/4 + * @Param [java.lang.String] + * @return com.alibaba.fastjson.JSONObject + */ + public static JSONObject createKfcOrder(Integer eatType , String storeCode , String mobile , String items , String platformUniqueId , String userRemark) throws Exception { + Map map = new HashMap<>(); + map.put("platformId", CommonSysConst.getSysConfig().getQinzhuPlatformId()); + map.put("eatType", eatType); + map.put("storeCode", storeCode); + map.put("mobile", mobile); + map.put("items", items); + map.put("platformUniqueId", platformUniqueId); + map.put("userRemark", userRemark); + map.put("timestamp", new Date().getTime()); + map.put("sign", MD5Util.encode(QianZhuConfig.generateSignature(map,CommonSysConst.getSysConfig().getQinzhuSecret()).getBytes()).toLowerCase()); + return HttpsUtils.doPost(CommonSysConst.getSysConfig().getQinzhuUrl()+"/openApi/v4/orders/createKfcOrder", JSONObject.toJSONString(map)); + } } diff --git a/hai-service/src/main/java/com/hai/dao/ApiProductConfigMapperExt.java b/hai-service/src/main/java/com/hai/dao/ApiProductConfigMapperExt.java index a5131c52..1a9dc4ff 100644 --- a/hai-service/src/main/java/com/hai/dao/ApiProductConfigMapperExt.java +++ b/hai-service/src/main/java/com/hai/dao/ApiProductConfigMapperExt.java @@ -16,31 +16,20 @@ public interface ApiProductConfigMapperExt { @Select(value = { "" }) @Results({ - @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), - @Result(column="recharge_type", property="rechargeType", jdbcType=JdbcType.INTEGER), - @Result(column="recharge_platform", property="rechargePlatform", jdbcType=JdbcType.VARCHAR), - @Result(column="phone_recharge_type", property="phoneRechargeType", jdbcType=JdbcType.INTEGER), - @Result(column="operator_type", property="operatorType", jdbcType=JdbcType.INTEGER), - @Result(column="recharge_price", property="rechargePrice", jdbcType=JdbcType.DECIMAL), - @Result(column="product_id", property="productId", jdbcType=JdbcType.BIGINT), + @Result(column="rechargeType", property="rechargeType", jdbcType=JdbcType.INTEGER), + @Result(column="phoneRechargeType", property="phoneRechargeType", jdbcType=JdbcType.INTEGER), + @Result(column="operatorType", property="operatorType", jdbcType=JdbcType.INTEGER), + @Result(column="rechargePrice", property="rechargePrice", jdbcType=JdbcType.DECIMAL), @Result(column="api_config_product_id", property="apiConfigProductId", jdbcType=JdbcType.BIGINT), - @Result(column="sort", property="sort", jdbcType=JdbcType.INTEGER), @Result(column="discount", property="discount", jdbcType=JdbcType.DECIMAL), @Result(column="discount_price", property="discountPrice", jdbcType=JdbcType.DECIMAL), - @Result(column="operator_id", property="operatorId", jdbcType=JdbcType.BIGINT), - @Result(column="operator_name", property="operatorName", jdbcType=JdbcType.VARCHAR), - @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), - @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP), - @Result(column="status", property="status", jdbcType=JdbcType.INTEGER), - @Result(column="config_status", property="configStatus", jdbcType=JdbcType.INTEGER), - @Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR), - @Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR), - @Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR) + @Result(column="configStatus", property="configStatus", jdbcType=JdbcType.INTEGER), + }) List getListMerchProduct(Long merchantsId); diff --git a/hai-service/src/main/java/com/hai/dao/ApiStarbucksProductsMapperExt.java b/hai-service/src/main/java/com/hai/dao/ApiStarbucksProductsMapperExt.java index 9993cb14..3889ec81 100644 --- a/hai-service/src/main/java/com/hai/dao/ApiStarbucksProductsMapperExt.java +++ b/hai-service/src/main/java/com/hai/dao/ApiStarbucksProductsMapperExt.java @@ -1,7 +1,20 @@ package com.hai.dao; +import org.apache.ibatis.annotations.Select; + +import java.util.List; + + /** * mapper扩展类 */ public interface ApiStarbucksProductsMapperExt { -} \ No newline at end of file + @Select(value = { + "" + }) + List getCategoryName(); + + +} diff --git a/hai-service/src/main/java/com/hai/entity/BsProductPayType.java b/hai-service/src/main/java/com/hai/entity/BsProductPayType.java index b6db0d6b..18f2644b 100644 --- a/hai-service/src/main/java/com/hai/entity/BsProductPayType.java +++ b/hai-service/src/main/java/com/hai/entity/BsProductPayType.java @@ -19,7 +19,7 @@ public class BsProductPayType implements Serializable { private Long id; /** - * 1:卡券 2:团油 3:话费 4:优惠券包 + * 1:卡券 2:团油 3:话费 4:优惠券包 5:星巴克 */ private Integer productType; @@ -254,4 +254,4 @@ public class BsProductPayType implements Serializable { sb.append("]"); return sb.toString(); } -} \ No newline at end of file +} diff --git a/hai-service/src/main/java/com/hai/enum_type/ProductImgEnum.java b/hai-service/src/main/java/com/hai/enum_type/ProductImgEnum.java new file mode 100644 index 00000000..b811fd0e --- /dev/null +++ b/hai-service/src/main/java/com/hai/enum_type/ProductImgEnum.java @@ -0,0 +1,48 @@ +package com.hai.enum_type; + +import java.util.Objects; + +/** + * 产品图片 + * @author hurui + */ +public enum ProductImgEnum { + name0("product/茶瓦纳.png", "茶瓦纳"), + name1("product/冷萃咖啡.png", "冷萃咖啡"), + name2("product/浓缩咖啡.png", "浓缩咖啡"), + name3("product/其他.png", "其他"), + name4("product/星冰乐.png", "星冰乐"), + ; + + private String name; + + private String imgUrl; + + public static String getNameByImgUrl(String name) { + for (ProductImgEnum ele : values()) { + if(Objects.equals(name,ele.getName())) return ele.getImgUrl(); + } + return null; + } + + ProductImgEnum(String imgUrl, String name) { + this.imgUrl = imgUrl; + this.name = name; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getImgUrl() { + return imgUrl; + } + + public void setImgUrl(String imgUrl) { + this.imgUrl = imgUrl; + } +} diff --git a/hai-service/src/main/java/com/hai/model/ApiProductConfigModel.java b/hai-service/src/main/java/com/hai/model/ApiProductConfigModel.java index 1d4777fd..8b369071 100644 --- a/hai-service/src/main/java/com/hai/model/ApiProductConfigModel.java +++ b/hai-service/src/main/java/com/hai/model/ApiProductConfigModel.java @@ -42,6 +42,17 @@ public class ApiProductConfigModel { */ private Long apiConfigProductId; + + private Integer configStatus; + + public Integer getConfigStatus() { + return configStatus; + } + + public void setConfigStatus(Integer configStatus) { + this.configStatus = configStatus; + } + public Integer getRechargeType() { return rechargeType; } diff --git a/hai-service/src/main/java/com/hai/model/ApiStarbucksProductsModel.java b/hai-service/src/main/java/com/hai/model/ApiStarbucksProductsModel.java new file mode 100644 index 00000000..04a9a4c4 --- /dev/null +++ b/hai-service/src/main/java/com/hai/model/ApiStarbucksProductsModel.java @@ -0,0 +1,41 @@ +package com.hai.model; + +import com.hai.entity.ApiStarbucksProducts; + +import java.math.BigDecimal; + +public class ApiStarbucksProductsModel extends ApiStarbucksProducts { + + // 抵扣比例 + private BigDecimal integralDiscount; + + // 产品展示平台 + private String productPlatformString; + + // 产品支付方式 + private String productPayTypeString; + + public BigDecimal getIntegralDiscount() { + return integralDiscount; + } + + public void setIntegralDiscount(BigDecimal integralDiscount) { + this.integralDiscount = integralDiscount; + } + + public String getProductPlatformString() { + return productPlatformString; + } + + public void setProductPlatformString(String productPlatformString) { + this.productPlatformString = productPlatformString; + } + + public String getProductPayTypeString() { + return productPayTypeString; + } + + public void setProductPayTypeString(String productPayTypeString) { + this.productPayTypeString = productPayTypeString; + } +} diff --git a/hai-service/src/main/java/com/hai/model/BsProductConfigModel.java b/hai-service/src/main/java/com/hai/model/BsProductConfigModel.java new file mode 100644 index 00000000..c40825ce --- /dev/null +++ b/hai-service/src/main/java/com/hai/model/BsProductConfigModel.java @@ -0,0 +1,63 @@ +package com.hai.model; + +import com.hai.entity.BsProductConfig; + +import java.math.BigDecimal; + +public class BsProductConfigModel extends BsProductConfig { + + // 抵扣比例 + private BigDecimal integralDiscount; + + // 产品展示平台 + private String productPlatformString; + + // 产品支付方式 + private String productPayTypeString; + + //最低产品销售价格 + private BigDecimal minProductSalePrice; + + //最低产品市场价格 + private BigDecimal minProductMarketPrice; + + public BigDecimal getIntegralDiscount() { + return integralDiscount; + } + + public void setIntegralDiscount(BigDecimal integralDiscount) { + this.integralDiscount = integralDiscount; + } + + public String getProductPlatformString() { + return productPlatformString; + } + + public void setProductPlatformString(String productPlatformString) { + this.productPlatformString = productPlatformString; + } + + public String getProductPayTypeString() { + return productPayTypeString; + } + + public void setProductPayTypeString(String productPayTypeString) { + this.productPayTypeString = productPayTypeString; + } + + public BigDecimal getMinProductSalePrice() { + return minProductSalePrice; + } + + public void setMinProductSalePrice(BigDecimal minProductSalePrice) { + this.minProductSalePrice = minProductSalePrice; + } + + public BigDecimal getMinProductMarketPrice() { + return minProductMarketPrice; + } + + public void setMinProductMarketPrice(BigDecimal minProductMarketPrice) { + this.minProductMarketPrice = minProductMarketPrice; + } +} diff --git a/hai-service/src/main/java/com/hai/service/ApiOpenService.java b/hai-service/src/main/java/com/hai/service/ApiOpenService.java index 6bd4b69b..ece12ee8 100644 --- a/hai-service/src/main/java/com/hai/service/ApiOpenService.java +++ b/hai-service/src/main/java/com/hai/service/ApiOpenService.java @@ -1,6 +1,7 @@ package com.hai.service; import com.alibaba.fastjson.JSONObject; +import com.hai.entity.ApiCity; import com.hai.entity.ApiMerchants; import com.hai.entity.ApiProduct; import com.hai.entity.ApiProductConfig; @@ -24,14 +25,4 @@ public interface ApiOpenService { */ void createOrder(JSONObject object , ApiMerchants apiMerchants , ApiProductConfig productConfig) throws Exception; - /** - * @Author Sum1Dream - * @name getAllCities.java - * @Description // 获取大陆所有城市 - * @Date 10:16 2022/6/27 - * @Param [] - * @return com.alibaba.fastjson.JSONObject - */ - JSONObject getAllCities(); - } diff --git a/hai-service/src/main/java/com/hai/service/ApiProductService.java b/hai-service/src/main/java/com/hai/service/ApiProductService.java index fef16861..0458b93b 100644 --- a/hai-service/src/main/java/com/hai/service/ApiProductService.java +++ b/hai-service/src/main/java/com/hai/service/ApiProductService.java @@ -1,10 +1,11 @@ package com.hai.service; import com.alibaba.fastjson.JSONObject; -import com.hai.entity.ApiProduct; -import com.hai.entity.ApiProductConfig; +import com.hai.entity.*; +import com.hai.model.BsProductConfigModel; import io.swagger.annotations.Api; +import java.util.Calendar; import java.util.List; import java.util.Map; @@ -96,4 +97,160 @@ public interface ApiProductService { * @return com.hai.entity.ApiProductConfig */ ApiProductConfig findMchProduct(Map map); + + /** + * @Author Sum1Dream + * @name updateStarbucksProducts.java + * @Description // 更新星巴克产品 + * @Date 16:38 2022/6/29 + * @Param [com.hai.entity.ApiStarbucksProducts] + * @return void + */ + void updateStarbucksProducts(ApiStarbucksProducts starbucksProducts); + + /** + * @Author Sum1Dream + * @name insertStarbucksProducts.java + * @Description // 插入星巴克产品 + * @Date 16:38 2022/6/29 + * @Param [com.hai.entity.ApiStarbucksProducts] + * @return void + */ + void insertStarbucksProducts(ApiStarbucksProducts starbucksProducts); + + /** + * @Author Sum1Dream + * @name findStarbucksProductsByGoodsId.java + * @Description // 更新商品id 查询商品 + * @Date 16:56 2022/6/29 + * @Param [java.lang.Long] + * @return com.hai.entity.ApiStarbucksProducts + */ + ApiStarbucksProducts findStarbucksProductsByGoodsId(Long goodsId); + + /** + * @Author Sum1Dream + * @name findStarbucksProducts.java + * @Description // 查询星巴克商品 + * @Date 15:50 2018/6/30 + * @Param [java.lang.Long] + * @return com.hai.entity.ApiStarbucksProducts + */ + ApiStarbucksProducts findStarbucksProducts(Long id); + + /** + * @Author Sum1Dream + * @name findStarbucksProducts.java + * @Description // 查询星巴克商品 + * @Date 15:50 2018/6/30 + * @Param [java.lang.Long] + * @return com.hai.entity.ApiStarbucksProducts + */ + List findStarbucksByCategoryName(String categoryName); + + void ProductConfig(JSONObject object); + + void updateProductConfig(JSONObject object); + + /** + * @Author Sum1Dream + * @name getProductConfig.java + * @Description // 查询星巴克产品 + * @Date 13:47 2022/6/30 + * @Param [] + * @return java.util.List + */ + List getStarbucksProducts(Map map); + + /** + * @Author Sum1Dream + * @name getProductConfig.java + * @Description // 查询配置产品 + * @Date 15:41 2022/6/30 + * @Param [java.util.Map] + * @return java.util.List + */ + List getProductConfigModel(Map map); + + /** + * @Author Sum1Dream + * @name getProductConfig.java + * @Description // 查询产品配置 + * @Date 16:16 2022/6/30 + * @Param [java.util.Map] + * @return java.util.List + */ + List getProductConfig(Map map); + + /** + * @Author Sum1Dream + * @name findProductConfig.java + * @Description // 根据id查询配置产品 + * @Date 17:28 2022/6/30 + * @Param [java.lang.Long] + * @return com.hai.entity.BsProductConfig + */ + BsProductConfig findProductConfig(Long id); + + BsProductConfig findProductConfigByGoodsId(Long productId); + + /** + * @Author Sum1Dream + * @name getCategoryName.java + * @Description // 查询商品分类 + * @Date 10:55 2022/7/1 + * @Param [] + * @return java.util.List + */ + List getCategoryName(); + + /** + * @Author Sum1Dream + * @name getAllCity.java + * @Description // 查询所有城市 + * @Date 10:06 2022/7/4 + * @Param [] + * @return + */ + List getAllCity(String cityName); + + /** + * @Author Sum1Dream + * @name insertKfcStore.java + * @Description // 插入kfc门店 + * @Date 10:32 2022/7/4 + * @Param [com.hai.entity.ApiKfcStores] + * @return void + */ + void insertKfcStore(ApiKfcStores apiKfcStores); + + /** + * @Author Sum1Dream + * @name updateKfcStore.java + * @Description // 更新肯德基门店 + * @Date 10:32 2022/7/4 + * @Param [com.hai.entity.ApiKfcStores] + * @return void + */ + void updateKfcStore(ApiKfcStores apiKfcStores); + + /** + * @Author Sum1Dream + * @name findKfcStores.java + * @Description // 查询肯德基门店 + * @Date 10:33 2022/7/4 + * @Param [java.util.Map] + * @return com.hai.entity.ApiKfcStores + */ + ApiKfcStores findKfcStores(Map map); + + /** + * @Author Sum1Dream + * @name getKfcStoresList.java + * @Description // 查询肯德基门店列表 + * @Date 10:34 2022/7/4 + * @Param [java.util.Map] + * @return java.util.List + */ + List getKfcStoresList(Map map); } diff --git a/hai-service/src/main/java/com/hai/service/HighOrderService.java b/hai-service/src/main/java/com/hai/service/HighOrderService.java index 161c22e6..0adca0de 100644 --- a/hai-service/src/main/java/com/hai/service/HighOrderService.java +++ b/hai-service/src/main/java/com/hai/service/HighOrderService.java @@ -1,5 +1,6 @@ package com.hai.service; +import com.alibaba.fastjson.JSONObject; import com.hai.entity.HighChildOrder; import com.hai.entity.HighOrder; import com.hai.model.*; @@ -433,4 +434,14 @@ public interface HighOrderService { * @param gasId */ void printGasOrder(Long gasId, HighOrder order); + + /** + * @Author Sum1Dream + * @name insertThirdProduct.java + * @Description // 第三方产品下单 + * @Date 09:45 2022/7/4 + * @Param [com.alibaba.fastjson.JSONObject] + * @return void + */ + void insertThirdProduct(JSONObject object); } diff --git a/hai-service/src/main/java/com/hai/service/impl/ApiOpenServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/ApiOpenServiceImpl.java index 4e5eb945..2f59cab6 100644 --- a/hai-service/src/main/java/com/hai/service/impl/ApiOpenServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/ApiOpenServiceImpl.java @@ -8,9 +8,12 @@ import com.hai.common.exception.SysCode; import com.hai.common.utils.DateUtil; import com.hai.common.utils.HttpsUtils; import com.hai.common.utils.IDGenerator; +import com.hai.common.utils.MD5Util; import com.hai.config.CommonSysConst; +import com.hai.config.QianZhuConfig; import com.hai.config.RechargeConfig; import com.hai.dao.ApiAmountRecordMapper; +import com.hai.dao.ApiCityMapper; import com.hai.dao.OutRechargeOrderMapper; import com.hai.entity.*; import com.hai.enum_type.OperatorEnum; @@ -56,6 +59,9 @@ public class ApiOpenServiceImpl implements ApiOpenService { @Resource private OutRechargeOrderService outRechargeOrderService; + @Resource + private ApiCityMapper apiCityMapper; + @Override @Transactional(rollbackFor=Exception.class,isolation = Isolation.SERIALIZABLE,propagation= Propagation.REQUIRES_NEW) public void createOrder(JSONObject object , ApiMerchants apiMerchants , ApiProductConfig productConfig) throws Exception { @@ -271,12 +277,4 @@ public class ApiOpenServiceImpl implements ApiOpenService { } - @Override - public JSONObject getAllCities() { - JSONObject object = HttpsUtils.doPost(CommonSysConst.getSysConfig().getQinzhuUrl()+"/openApi/v2/cities/listAll", ""); - if (object != null && !object.getBoolean("success")) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.REQUEST_ERROR); - } - return object; - } } diff --git a/hai-service/src/main/java/com/hai/service/impl/ApiProductServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/ApiProductServiceImpl.java index cba8dded..27018db5 100644 --- a/hai-service/src/main/java/com/hai/service/impl/ApiProductServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/ApiProductServiceImpl.java @@ -3,9 +3,9 @@ package com.hai.service.impl; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.hai.common.security.UserCenter; -import com.hai.dao.ApiProductConfigMapper; -import com.hai.dao.ApiProductMapper; +import com.hai.dao.*; import com.hai.entity.*; +import com.hai.model.BsProductConfigModel; import com.hai.model.UserInfoModel; import com.hai.service.ApiProductService; import com.hai.service.CommonService; @@ -17,6 +17,7 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.math.BigDecimal; +import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Map; @@ -36,6 +37,18 @@ public class ApiProductServiceImpl implements ApiProductService { @Resource private ApiProductConfigMapper apiProductConfigMapper; + @Resource + private ApiStarbucksProductsMapper apiStarbucksProductsMapper; + + @Resource + private BsProductConfigMapper productConfigMapper; + + @Resource + private ApiCityMapper apiCityMapper; + + @Resource + private ApiKfcStoresMapper apiKfcStoresMapper; + @Override public void insertApiProduct(JSONObject object) { // 转换金额数组 @@ -163,4 +176,243 @@ public class ApiProductServiceImpl implements ApiProductService { } } + + @Override + public void updateStarbucksProducts(ApiStarbucksProducts starbucksProducts) { + apiStarbucksProductsMapper.updateByPrimaryKey(starbucksProducts); + } + + @Override + public void insertStarbucksProducts(ApiStarbucksProducts starbucksProducts) { + apiStarbucksProductsMapper.insert(starbucksProducts); + } + + @Override + public ApiStarbucksProducts findStarbucksProductsByGoodsId(Long goodsId) { + + ApiStarbucksProductsExample example = new ApiStarbucksProductsExample(); + + example.createCriteria().andGoodsIdEqualTo(goodsId); + + List list = apiStarbucksProductsMapper.selectByExample(example); + + if (list.size() > 0) { + return list.get(0); + } + return null; + } + + @Override + @Transactional(propagation = Propagation.REQUIRES_NEW) + public void ProductConfig(JSONObject object) { + // 转换产品数组 + JSONArray productArray = object.getJSONArray("productIds"); + + // 产品配置 + BsProductConfig productConfig; + for (Object product : productArray) { + ApiStarbucksProducts starbucksProducts = findStarbucksProducts(Long.valueOf(product.toString())); + productConfig = new BsProductConfig(); + productConfig.setProductId(Long.valueOf(product.toString())); + productConfig.setCompanyId(object.getLong("companyId")); + productConfig.setCreateTime(new Date()); + productConfig.setDiscount(object.getBigDecimal("discount")); + productConfig.setStatus(101); + productConfig.setOperatorId(object.getLong("operatorId")); + productConfig.setOperatorName(object.getString("operatorName")); + productConfig.setUpdateTime(new Date()); + + productConfig.setProductName(starbucksProducts.getName()); + productConfig.setProductType(object.getInteger("productType")); + + productConfigMapper.insert(productConfig); + + + JSONObject postObject = new JSONObject(); + postObject.put("payType", object.getJSONArray("payType")); + postObject.put("integralDiscount", object.getBigDecimal("integralDiscount")); + postObject.put("productPlatform", object.getJSONArray("productPlatform")); + postObject.put("operatorId", object.getLong("operatorId")); + postObject.put("operatorName", object.getString("operatorName")); + postObject.put("sourceId", productConfig.getId()); + postObject.put("productType", 5); + + // 配置支付方式 + commonService.configPayType(postObject); + // 配置积分折扣比例 + commonService.configIntegralDiscount(postObject); + // 配置展示平台 + commonService.configPlatform(postObject); + } + } + + @Override + @Transactional(propagation = Propagation.REQUIRES_NEW) + public void updateProductConfig(JSONObject object) { + BsProductConfig productConfig = productConfigMapper.selectByPrimaryKey(object.getLong("id")); + + ApiStarbucksProducts starbucksProducts = findStarbucksProducts(productConfig.getProductId()); + productConfig.setProductId(starbucksProducts.getId()); + productConfig.setCompanyId(object.getLong("companyId")); + productConfig.setDiscount(object.getBigDecimal("discount")); + productConfig.setStatus(101); + productConfig.setOperatorId(object.getLong("operatorId")); + productConfig.setOperatorName(object.getString("operatorName")); + productConfig.setUpdateTime(new Date()); + + productConfig.setProductName(starbucksProducts.getName()); + productConfig.setProductType(object.getInteger("productType")); + + productConfigMapper.updateByPrimaryKey(productConfig); + + + JSONObject postObject = new JSONObject(); + postObject.put("payType", object.getJSONArray("payType")); + postObject.put("integralDiscount", object.getBigDecimal("integralDiscount")); + postObject.put("productPlatform", object.getJSONArray("productPlatform")); + postObject.put("operatorId", object.getLong("operatorId")); + postObject.put("operatorName", object.getString("operatorName")); + postObject.put("sourceId", productConfig.getId()); + postObject.put("productType", 5); + + // 配置支付方式 + commonService.configPayType(postObject); + // 配置积分折扣比例 + commonService.configIntegralDiscount(postObject); + // 配置展示平台 + commonService.configPlatform(postObject); + } + + @Override + public ApiStarbucksProducts findStarbucksProducts(Long id) { + return apiStarbucksProductsMapper.selectByPrimaryKey(id); + } + + @Override + public List getStarbucksProducts(Map map) { + + + ApiStarbucksProductsExample example = new ApiStarbucksProductsExample(); + ApiStarbucksProductsExample.Criteria criteria = example.createCriteria(); + + if (MapUtils.getString(map, "name") != null) { + criteria.andNameLike("%" + MapUtils.getString(map, "name") + "%"); + } + if (MapUtils.getString(map, "categoryName") != null) { + criteria.andCategoryNameEqualTo(MapUtils.getString(map, "categoryName")); + } + + return apiStarbucksProductsMapper.selectByExample(example); + } + + @Override + public List findStarbucksByCategoryName(String categoryName) { + ApiStarbucksProductsExample example = new ApiStarbucksProductsExample(); + example.createCriteria().andCategoryNameEqualTo(categoryName); + + + return apiStarbucksProductsMapper.selectByExample(example); + } + + @Override + public List getProductConfigModel(Map map) { + return null; + } + + @Override + public List getProductConfig(Map map) { + + BsProductConfigExample example = new BsProductConfigExample(); + BsProductConfigExample.Criteria criteria = example.createCriteria(); + + if (MapUtils.getLong(map, "companyId") != null) { + criteria.andCompanyIdEqualTo(MapUtils.getLong(map, "companyId")); + } + if (MapUtils.getInteger(map, "productType") != null) { + criteria.andProductTypeEqualTo(MapUtils.getInteger(map, "productType")); + } + if (MapUtils.getString(map, "productName") != null) { + criteria.andProductNameEqualTo(MapUtils.getString(map, "productName")); + } + + return productConfigMapper.selectByExample(example); + } + + @Override + public BsProductConfig findProductConfig(Long id) { + return productConfigMapper.selectByPrimaryKey(id); + } + + @Override + public BsProductConfig findProductConfigByGoodsId(Long productId) { + BsProductConfigExample example = new BsProductConfigExample(); + example.createCriteria().andProductIdEqualTo(productId); + + if (productConfigMapper.selectByExample(example).size() != 0) { + return productConfigMapper.selectByExample(example).get(0); + } + + return null; + } + + @Override + public List getCategoryName() { + return apiStarbucksProductsMapper.getCategoryName(); + } + + @Override + public List getAllCity(String cityName) { + ApiCityExample example = new ApiCityExample(); + if (StringUtils.isNotBlank(cityName)) { + example.createCriteria().andCityNameLike("%" + cityName + "%"); + } + return apiCityMapper.selectByExample(example); + } + + @Override + public void insertKfcStore(ApiKfcStores apiKfcStores) { + apiKfcStoresMapper.insert(apiKfcStores); + } + + @Override + public void updateKfcStore(ApiKfcStores apiKfcStores) { + apiKfcStoresMapper.updateByPrimaryKeySelective(apiKfcStores); + } + + @Override + public ApiKfcStores findKfcStores(Map map) { + ApiKfcStoresExample example = new ApiKfcStoresExample(); + ApiKfcStoresExample.Criteria criteria = example.createCriteria(); + + if (StringUtils.isNotBlank(MapUtils.getString(map , "storeCode"))) { + criteria.andStoreCodeEqualTo(MapUtils.getString(map , "storeCode")); + } + + List apiKfcStores = apiKfcStoresMapper.selectByExample(example); + + if (apiKfcStores.size() > 0) { + apiKfcStores.get(0); + } + return null; + } + + @Override + public List getKfcStoresList(Map map) { + + ApiKfcStoresExample example = new ApiKfcStoresExample(); + ApiKfcStoresExample.Criteria criteria = example.createCriteria(); + + if (StringUtils.isNotBlank(MapUtils.getString(map , "storeName"))) { + criteria.andStoreNameLike("%" + MapUtils.getString(map , "storeName") + "%"); + } + + if (StringUtils.isNotBlank(MapUtils.getString(map , "storeCode"))) { + criteria.andStoreCodeEqualTo(MapUtils.getString(map , "storeCode")); + } + if (StringUtils.isNotBlank(MapUtils.getString(map , "cityCode"))) { + criteria.andCityCodeEqualTo(MapUtils.getString(map , "cityCode")); + } + + return apiKfcStoresMapper.selectByExample(example); + } } diff --git a/hai-service/src/main/java/com/hai/service/impl/CommonServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/CommonServiceImpl.java index 01e53f8f..593df241 100644 --- a/hai-service/src/main/java/com/hai/service/impl/CommonServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/CommonServiceImpl.java @@ -561,7 +561,7 @@ public class CommonServiceImpl implements CommonService { productPayType.setPayTypeId(Integer.valueOf(String.valueOf(payType))); productPayType.setPayTypeLogo(dictionary.getExt1()); productPayType.setPayTypeName(dictionary.getCodeName()); - productPayType.setProductType(3); + productPayType.setProductType(object.getInteger("productType")); productPayType.setOperatorId(object.getLong("operatorId")); productPayType.setOperatorName(object.getString("operatorName")); productPayType.setSourceId(object.getLong("sourceId")); @@ -579,7 +579,7 @@ public class CommonServiceImpl implements CommonService { // 配置积分折扣比例 productDiscount = new BsProductDiscount(); productDiscount.setDiscount(object.getBigDecimal("integralDiscount")); - productDiscount.setProductType(3); + productDiscount.setProductType(object.getInteger("productType")); productDiscount.setCreateTime(new Date()); productDiscount.setUpdateTime(new Date()); productDiscount.setOperatorId(object.getLong("operatorId")); @@ -601,7 +601,7 @@ public class CommonServiceImpl implements CommonService { for (Object platform : productPlatformArray) { productPlatform = new BsProductPlatform(); SecDictionary dictionary = mappingSysCode("SHOW_PLATFORM", String.valueOf(platform)); - productPlatform.setProductType(3); + productPlatform.setProductType(object.getInteger("productType")); productPlatform.setPlatformId(Integer.valueOf(String.valueOf(platform))); productPlatform.setPlatformName(dictionary.getCodeName()); productPlatform.setCreateTime(new Date()); diff --git a/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java index 7802c161..5bae2102 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java @@ -127,6 +127,9 @@ public class HighOrderServiceImpl implements HighOrderService { @Resource private BaiduVoiceService baiduVoiceService; + @Resource + private BsConfigService bsConfigService; + @Override @Transactional( isolation = Isolation.SERIALIZABLE, @@ -1760,5 +1763,21 @@ public class HighOrderServiceImpl implements HighOrderService { } } + @Override + @Transactional( + isolation = Isolation.SERIALIZABLE, + propagation = Propagation.REQUIRES_NEW) + public void insertThirdProduct(JSONObject object) { + HighUser user = highUserService.findByUserId(object.getLong("userId")); + + // 查询积分抵扣比例 + Map listMap = new HashMap<>(); + listMap.put("productType", "5"); + listMap.put("returnType", 1); + listMap.put("sourceId", 100001); + // 查询产品积分抵扣比例 + BsProductDiscount bsProductDiscount = bsConfigService.getProductDiscountByMap(listMap); + + } } diff --git a/hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java index 558eb087..76a0e2e9 100644 --- a/hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java @@ -174,9 +174,9 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { OutRechargeOrder outRechargeOrder = new OutRechargeOrder(); - HighUser user = highUserService.findByUserId(object.getLong("userId")); + // 产品id Long goodsId = object.getLong("goodsId"); diff --git a/hai-service/src/main/java/com/hai/service/impl/OutRechargePriceServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/OutRechargePriceServiceImpl.java index c91288cc..692b28fa 100644 --- a/hai-service/src/main/java/com/hai/service/impl/OutRechargePriceServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/OutRechargePriceServiceImpl.java @@ -142,6 +142,7 @@ public class OutRechargePriceServiceImpl implements OutRechargePriceService { postObject.put("operatorId", object.getLong("operatorId")); postObject.put("operatorName", object.getString("operatorName")); postObject.put("sourceId", outRechargePrice.getId()); + postObject.put("productType", 3); // 配置支付方式 commonService.configPayType(postObject); @@ -176,7 +177,7 @@ public class OutRechargePriceServiceImpl implements OutRechargePriceService { postObject.put("operatorId", object.getLong("operatorId")); postObject.put("operatorName", object.getString("operatorName")); postObject.put("sourceId", outRechargePrice.getId()); - + postObject.put("productType", 3); // 配置支付方式 commonService.configPayType(postObject); // 配置积分折扣比例 diff --git a/hai-service/src/main/resources/dev/commonConfig.properties b/hai-service/src/main/resources/dev/commonConfig.properties index a6b8996f..500a739d 100644 --- a/hai-service/src/main/resources/dev/commonConfig.properties +++ b/hai-service/src/main/resources/dev/commonConfig.properties @@ -15,6 +15,7 @@ shellPlatMerchantKey=123 # ???? qinzhuUrl=https://live-test.qianzhu8.com qinzhuHtmlUrl=https://m-test.qianzhu8.com +qianzhuH5url=https://nf-test.qianzhu8.com/gateway qinzhuPlatformId=10376 qinzhuSecret=ktxb49sh2jfhgn8g qianzhuOrderNotify=https://hsg.dctpay.com/crest/qianzhu/orderNotify diff --git a/hai-service/src/main/resources/prod-9401/commonConfig.properties b/hai-service/src/main/resources/prod-9401/commonConfig.properties index 02f247fb..64072331 100644 --- a/hai-service/src/main/resources/prod-9401/commonConfig.properties +++ b/hai-service/src/main/resources/prod-9401/commonConfig.properties @@ -12,6 +12,7 @@ tuanYouGasolineAccount=9hp52qf04400 qinzhuUrl=https://live.qianzhu8.com qinzhuHtmlUrl=https://qz.dctpay.com +qianzhuH5url=https://nf.qianzhu8.com/gateway qinzhuPlatformId=10458 qinzhuSecret=nnl3gg4ss0pka11t qianzhuOrderNotify=https://hsg.dctpay.com/crest/qianzhu/orderNotify diff --git a/hai-service/src/main/resources/prod/commonConfig.properties b/hai-service/src/main/resources/prod/commonConfig.properties index 02f247fb..64072331 100644 --- a/hai-service/src/main/resources/prod/commonConfig.properties +++ b/hai-service/src/main/resources/prod/commonConfig.properties @@ -12,6 +12,7 @@ tuanYouGasolineAccount=9hp52qf04400 qinzhuUrl=https://live.qianzhu8.com qinzhuHtmlUrl=https://qz.dctpay.com +qianzhuH5url=https://nf.qianzhu8.com/gateway qinzhuPlatformId=10458 qinzhuSecret=nnl3gg4ss0pka11t qianzhuOrderNotify=https://hsg.dctpay.com/crest/qianzhu/orderNotify diff --git a/v1/src/main/java/com/v1/config/AuthConfig.java b/v1/src/main/java/com/v1/config/AuthConfig.java index 3d725107..193e26fa 100644 --- a/v1/src/main/java/com/v1/config/AuthConfig.java +++ b/v1/src/main/java/com/v1/config/AuthConfig.java @@ -92,6 +92,7 @@ public class AuthConfig implements WebMvcConfigurer { .excludePathPatterns("/websocket/*") .excludePathPatterns("/rechargeProduct/*") .excludePathPatterns("/gzSinopec/*") + .excludePathPatterns("/thirdParty/*") ; } diff --git a/v1/src/main/java/com/v1/controller/RechargeProductController.java b/v1/src/main/java/com/v1/controller/RechargeProductController.java index 2959dbe3..a85cd3bb 100644 --- a/v1/src/main/java/com/v1/controller/RechargeProductController.java +++ b/v1/src/main/java/com/v1/controller/RechargeProductController.java @@ -35,7 +35,7 @@ import java.util.Map; @Api(value = "充值产品接口") public class RechargeProductController { - private static Logger log = LoggerFactory.getLogger(GzSinopecController.class); + private static Logger log = LoggerFactory.getLogger(RechargeProductController.class); @Resource private ApiMerchantsService apiMerchantsService; diff --git a/v1/src/main/java/com/v1/controller/ThirdPartyController.java b/v1/src/main/java/com/v1/controller/ThirdPartyController.java new file mode 100644 index 00000000..53a90ddd --- /dev/null +++ b/v1/src/main/java/com/v1/controller/ThirdPartyController.java @@ -0,0 +1,239 @@ +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.config.QianZhuConfig; +import com.hai.entity.ApiMerchants; +import com.hai.model.ResponseData; +import com.hai.service.*; +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 ThirdPartyController.java + * @author Sum1Dream + * @version 1.0.0 + * @Description // 第三方产品接口 + * @createTime 14:48 2022/6/28 + **/ +@Controller +@RequestMapping(value = "/thirdParty") +@Api(value = "第三方产品接口") +public class ThirdPartyController { + + private static Logger log = LoggerFactory.getLogger(ThirdPartyController.class); + + @Resource + private ApiMerchantsService apiMerchantsService; + + @Resource + private SecConfigService secConfigService; + + @RequestMapping(value = "/getAllCities", method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "查询所有城市") + public ResponseData getAllCities(@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("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("KFC_CONFIG" , object.getString("merchId"))) { + log.error("getAllCities error!", "当前商户无权限查询!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_NOT_AUTHORIZED, "当前商户无权限查询!"); + } + + Map 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); + } + + JSONObject jsonObject = QianZhuConfig.getAllCities(); + + return ResponseMsgUtil.success(jsonObject.getString("data")); + + } catch (Exception e) { + log.error("HighOpenApiController --> getRechargeProduct() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/getStarbucksStore", method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "查询星巴克门店") + public ResponseData getStarbucksStore(@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("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("KFC_CONFIG" , object.getString("merchId"))) { + log.error("getAllCities error!", "当前商户无权限查询!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_NOT_AUTHORIZED, "当前商户无权限查询!"); + } + + Map 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 (!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("pageIndex")) || + StringUtils.isBlank(object.getString("pageSize")) || + 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("KFC_CONFIG" , object.getString("merchId"))) { + log.error("getAllCities error!", "当前商户无权限查询!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_NOT_AUTHORIZED, "当前商户无权限查询!"); + } + + Map map = new HashMap<>(); + map.put("apiKey" , object.getString("apiKey")); + map.put("merchId" , object.getString("merchId")); + map.put("pageSize" , object.getString("pageSize")); + map.put("pageIndex" , object.getString("pageIndex")); + + if (!secConfigService.isSignVerify(map , object.getString("sign"))) { + log.error("getRechargeProduct error!", "签名校验失败!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.SIGN_VERIFY); + } + + JSONObject jsonObject = QianZhuConfig.getStarbucksProducts(object.getInteger("pageIndex") , object.getInteger("pageSize")); + + 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); + } + } +} diff --git a/v1/src/main/resources/dev/application.yml b/v1/src/main/resources/dev/application.yml index f0e71e2f..d86cbae9 100644 --- a/v1/src/main/resources/dev/application.yml +++ b/v1/src/main/resources/dev/application.yml @@ -39,6 +39,20 @@ spring: max-wait: -1 max-idle: 10 min-idle: 0 + #MQTT配置信息 + mqtt: + #MQTT服务地址 + url: ws://139.159.177.244:8083/mqtt + #用户名 + username: printer_provider + #密码 + password: 123654 + #客户端id(不能重复) + # client: + # id: provider-id + #MQTT默认的消息推送主题,实际可在调用接口是指定 + # default: + # topic: topic #配置日期返回至前台为时间戳 jackson: serialization: diff --git a/v1/src/main/resources/pre/application.yml b/v1/src/main/resources/pre/application.yml index 1b034025..ef24999b 100644 --- a/v1/src/main/resources/pre/application.yml +++ b/v1/src/main/resources/pre/application.yml @@ -39,6 +39,20 @@ spring: max-wait: -1 max-idle: 10 min-idle: 0 + #MQTT配置信息 + mqtt: + #MQTT服务地址 + url: ws://139.159.177.244:8083/mqtt + #用户名 + username: printer_provider + #密码 + password: 123654 + #客户端id(不能重复) + # client: + # id: provider-id + #MQTT默认的消息推送主题,实际可在调用接口是指定 + # default: + # topic: topic #配置日期返回至前台为时间戳 jackson: serialization: diff --git a/v1/src/main/resources/prod/application.yml b/v1/src/main/resources/prod/application.yml index 28b711c3..cbc4155a 100644 --- a/v1/src/main/resources/prod/application.yml +++ b/v1/src/main/resources/prod/application.yml @@ -39,6 +39,20 @@ spring: max-wait: -1 max-idle: 10 min-idle: 0 + #MQTT配置信息 + mqtt: + #MQTT服务地址 + url: ws://122.9.135.148:8083/mqtt + #用户名 + username: printer_provider + #密码 + password: abcd123! + #客户端id(不能重复) + # client: + # id: provider-id + #MQTT默认的消息推送主题,实际可在调用接口是指定 + # default: + # topic: topic #thymelea模板配置 thymeleaf: prefix: classpath:/templates/