提交代码

dev-discount
胡锐 2 years ago
commit d765e3bd16
  1. 2
      hai-bweb/src/main/java/com/bweb/controller/HighTestController.java
  2. 15
      hai-cweb/src/main/java/com/cweb/controller/CommonController.java
  3. 28
      hai-schedule/src/main/java/com/hai/schedule/HighRechargeOrderSchedule.java
  4. 15
      hai-service/src/main/java/com/hai/common/utils/ImageUtils.java
  5. 2
      hai-service/src/main/java/com/hai/config/WeChatQrcodeUtils.java
  6. 61
      hai-service/src/main/java/com/hai/dao/OutRechargeOrderMapperExt.java
  7. 31
      hai-service/src/main/java/com/hai/openApi/config/PriceComputeConfig.java
  8. 30
      hai-service/src/main/java/com/hai/openApi/service/ApiOrderCreateHandleService.java
  9. 2
      hai-service/src/main/java/com/hai/openApi/service/ApiOrderService.java
  10. 15
      hai-service/src/main/java/com/hai/openApi/service/impl/ApiMobileRechargeProductServiceImpl.java
  11. 181
      hai-service/src/main/java/com/hai/openApi/service/impl/ApiOrderCreateHandleServiceImpl.java
  12. 45
      hai-service/src/main/java/com/hai/openApi/service/impl/ApiOrderServiceImpl.java
  13. 44
      hai-service/src/main/java/com/hai/openApi/type/OperatorTypeEnum.java
  14. 43
      hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java
  15. 10
      hai-service/src/main/java/com/hai/service/ApiMemberProductService.java
  16. 4
      hai-service/src/main/java/com/hai/service/OutRechargeOrderService.java
  17. 15
      hai-service/src/main/java/com/hai/service/impl/ApiMemberProductServiceImpl.java
  18. 575
      hai-service/src/main/java/com/hai/service/impl/ApiOpenServiceImpl.java
  19. 19
      hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java
  20. 2
      hai-service/src/main/resources/dev/commonConfig.properties
  21. 353
      v1/src/main/java/com/v1/controller/RechargeProductController.java
  22. 545
      v1/src/main/java/com/v1/controller/ThirdPartyController.java
  23. 118
      v1/src/main/java/com/v1/controller/WxMsgController.java
  24. 4
      v1/src/main/java/com/v1/controller/business/ApiMerchantsController.java
  25. 218
      v1/src/main/java/com/v1/controller/business/KfcController.java
  26. 131
      v1/src/main/java/com/v1/controller/business/MemberProductsController.java
  27. 4
      v1/src/main/java/com/v1/controller/business/MobileRechargeController.java
  28. 45
      v1/src/main/java/com/v1/controller/business/StarbucksController.java
  29. 11
      v1/src/main/java/com/v1/controller/orderController.java
  30. 35
      v1/src/main/resources/prod/application.yml

File diff suppressed because one or more lines are too long

@ -8,6 +8,7 @@ import com.hai.common.exception.SysCode;
import com.hai.common.utils.HttpsUtils;
import com.hai.common.utils.ResponseMsgUtil;
import com.hai.common.utils.WxUtils;
import com.hai.config.WeChatQrcodeUtils;
import com.hai.entity.*;
import com.hai.model.ResponseData;
import com.hai.service.*;
@ -17,6 +18,7 @@ import me.chanjar.weixin.common.util.crypto.SHA1;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@ -43,6 +45,9 @@ public class CommonController {
@Resource
private BsCompanyService bsCompanyService;
@Autowired
private WeChatQrcodeUtils weChatQrcodeUtils;
@Resource
private HighOrderService highOrderService;
@ -246,7 +251,7 @@ public class CommonController {
}
}
@RequestMapping(value = "/ getScanCodePageHtmlSign", method = RequestMethod.POST)
@RequestMapping(value = "/getScanCodePageHtmlSign", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "获取扫码页面签名")
public ResponseData getScanCodePageHtmlSign(@RequestBody JSONObject body) {
@ -261,14 +266,8 @@ public class CommonController {
params.put("secret", SysConst.getSysConfig().getWxH5AppSecret());
params.put("grant_type", "client_credential");
JSONObject accessTokenObject = HttpsUtils.doGet("https://api.weixin.qq.com/cgi-bin/token", params);
if (accessTokenObject == null) {
log.error("getH5UserInfo error!", "获取微信access_token失败" );
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "获取微信access_token失败");
}
params.clear();
params.put("access_token", accessTokenObject.getString("access_token"));
params.put("access_token", weChatQrcodeUtils.getWxToken());
params.put("type", "jsapi");
JSONObject jsapiTicketObject = HttpsUtils.doGet("https://api.weixin.qq.com/cgi-bin/ticket/getticket", params);
if (jsapiTicketObject == null) {

@ -84,5 +84,33 @@ public class HighRechargeOrderSchedule {
System.out.println("话费定时任务 -> 结束任务");
}
@Scheduled(cron = "0 0/5 * * * ?") //每7分钟执行一次
public void phoneErrorOrder() {
List<HighOrder> highOrders = orderService.phoneErrorOrder();
for (HighOrder order: highOrders) {
try {
// 定义话费充值业务订单模型 or 充值记录订单模型
OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderNo(order.getOrderNo());
OutRechargeChildOrder childOrder = outRechargeOrder.getOutRechargeChildOrders().get(0);
// -1 取消,0充值中 ,1充值成功,2充值失败,3部分成功
Integer status = outRechargeOrderService.getRechargeOrderLegality(outRechargeOrder , childOrder);
if (status == 2 || status == -1) {
childOrder.setStatus(103);
childOrder.setUpdateTime(new Date());
rechargeChildOrderService.updateOrder(childOrder);
outRechargeOrder.setRechargeStatus(205);
outRechargeOrderService.updateOrder(outRechargeOrder);
} else if (status == 1) {
outRechargeOrderService.completeOrder(childOrder.getOrderNo());
}
} catch (Exception e) {
log.error("HighCouponSchedule --> expiredCoupon() error!", e);
}
}
System.out.println("话费定时任务 -> 结束任务");
}
}

@ -2,6 +2,7 @@ package com.hai.common.utils;
import com.hai.common.QRCodeGenerator;
import com.hai.config.CommonConfig;
import com.hai.config.CommonSysConst;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
@ -304,4 +305,18 @@ public class ImageUtils {
QRCodeGenerator.generateQRCodeImage(imgPath + id, 134, 134, qrCodeUrl);
return qrCodeImg;
}
// 二维码生产自定义图片
public static void overlapImage(String path , String bgPath , int x, int y) throws Exception {
BufferedImage read = ImageIO.read(new File(CommonSysConst.getSysConfig().getFileUrl() + bgPath));
Image image = ImageIO.read(new File(CommonSysConst.getSysConfig().getFileUrl() + path));
Graphics graphics = read.getGraphics();
graphics.drawImage(image, x ,y, null);
ImageIO.write(read , "png" , new File(CommonSysConst.getSysConfig().getFileUrl() + "/" + path));
}
}

@ -130,7 +130,7 @@ public class WeChatQrcodeUtils {
params.put("secret", CommonSysConst.getSysConfig().getWxH5AppSecret());
params.put("grant_type", "client_credential");
JSONObject accessTokenObject = HttpsUtils.doGet("https://api.weixin.qq.com/cgi-bin/token", params);
redisUtil.set("WxToken" , accessTokenObject.getString("access_token") , 7000);
redisUtil.set("WxToken" , accessTokenObject.getString("access_token") , 5000);
return accessTokenObject.getString("access_token");
}

@ -3,11 +3,9 @@ package com.hai.dao;
import com.hai.entity.HighOrder;
import com.hai.entity.OutRechargeOrder;
import com.hai.entity.OutRechargeOrderExample;
import com.hai.model.*;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;
@ -226,4 +224,59 @@ public interface OutRechargeOrderMapperExt {
"</script>"
})
List<ApiRechargePhoneModel> getApiRechargePhoneByList(@Param("map") Map<String,Object> map);
@Select({"<script>" +
"SELECT * FROM out_recharge_order WHERE order_no NOT IN ( SELECT order_no FROM high_order where product_type = 9);" +
"</script>"
})
@Results({
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
@Result(column="type", property="type", jdbcType=JdbcType.INTEGER),
@Result(column="operator_name", property="operatorName", jdbcType=JdbcType.VARCHAR),
@Result(column="operator_type", property="operatorType", jdbcType=JdbcType.INTEGER),
@Result(column="recharge_price", property="rechargePrice", jdbcType=JdbcType.DECIMAL),
@Result(column="order_no", property="orderNo", jdbcType=JdbcType.VARCHAR),
@Result(column="child_order_no", property="childOrderNo", jdbcType=JdbcType.VARCHAR),
@Result(column="mem_discount_id", property="memDiscountId", jdbcType=JdbcType.BIGINT),
@Result(column="mem_discount_name", property="memDiscountName", jdbcType=JdbcType.VARCHAR),
@Result(column="user_id", property="userId", jdbcType=JdbcType.BIGINT),
@Result(column="user_name", property="userName", jdbcType=JdbcType.VARCHAR),
@Result(column="user_phone", property="userPhone", jdbcType=JdbcType.VARCHAR),
@Result(column="pay_type", property="payType", jdbcType=JdbcType.INTEGER),
@Result(column="labor_union_card", property="laborUnionCard", jdbcType=JdbcType.VARCHAR),
@Result(column="integral_num", property="integralNum", jdbcType=JdbcType.DECIMAL),
@Result(column="discount_deduction_price", property="discountDeductionPrice", jdbcType=JdbcType.DECIMAL),
@Result(column="integral_deduction_price", property="integralDeductionPrice", jdbcType=JdbcType.DECIMAL),
@Result(column="pay_price", property="payPrice", jdbcType=JdbcType.DECIMAL),
@Result(column="order_price", property="orderPrice", jdbcType=JdbcType.DECIMAL),
@Result(column="pay_real_price", property="payRealPrice", jdbcType=JdbcType.DECIMAL),
@Result(column="pay_serial_no", property="paySerialNo", jdbcType=JdbcType.VARCHAR),
@Result(column="pay_status", property="payStatus", jdbcType=JdbcType.INTEGER),
@Result(column="recharge_status", property="rechargeStatus", jdbcType=JdbcType.INTEGER),
@Result(column="recharge_name", property="rechargeName", jdbcType=JdbcType.VARCHAR),
@Result(column="create_timed", property="createTimed", jdbcType=JdbcType.TIMESTAMP),
@Result(column="pay_time", property="payTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="cancel_time", property="cancelTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="finish_time", property="finishTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="remarks", property="remarks", jdbcType=JdbcType.VARCHAR),
@Result(column="out_refund_no", property="outRefundNo", jdbcType=JdbcType.VARCHAR),
@Result(column="refund_time", property="refundTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="tp_refund_order_no", property="tpRefundOrderNo", jdbcType=JdbcType.VARCHAR),
@Result(column="refund_id", property="refundId", jdbcType=JdbcType.VARCHAR),
@Result(column="refund_fee", property="refundFee", jdbcType=JdbcType.DECIMAL),
@Result(column="agent_key", property="agentKey", jdbcType=JdbcType.VARCHAR),
@Result(column="object_id", property="objectId", jdbcType=JdbcType.INTEGER),
@Result(column="recharge_type", property="rechargeType", jdbcType=JdbcType.INTEGER),
@Result(column="abnormal_msg", property="abnormalMsg", jdbcType=JdbcType.VARCHAR),
@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="goods_id", property="goodsId", jdbcType=JdbcType.BIGINT),
@Result(column="recharge_content", property="rechargeContent", jdbcType=JdbcType.VARCHAR),
@Result(column="company_id", property="companyId", jdbcType=JdbcType.BIGINT),
@Result(column="merch_id", property="merchId", jdbcType=JdbcType.VARCHAR),
@Result(column="whether_rebate", property="whetherRebate", jdbcType=JdbcType.BIT)
})
List<OutRechargeOrder> selectList();
}

@ -2,13 +2,18 @@ package com.hai.openApi.config;
import com.hai.entity.ApiAmountRecord;
import com.hai.entity.ApiMerchants;
import com.hai.entity.ApiOrder;
import com.hai.entity.HighOrder;
import com.hai.openApi.service.ApiOrderService;
import com.hai.order.type.OrderProductType;
import com.hai.service.ApiAmountRecordService;
import com.hai.service.ApiMerchantsService;
import com.hai.service.HighOrderService;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Date;
@Component
@ -20,6 +25,12 @@ public class PriceComputeConfig {
@Resource
private ApiAmountRecordService apiAmountRecordService;
@Resource
private HighOrderService highOrderService;
@Resource
private ApiOrderService apiOrderService;
public Boolean mchBalance(ApiMerchants apiMerchants , BigDecimal price , String orderNo) {
@ -28,11 +39,15 @@ public class PriceComputeConfig {
return false;
}
ApiOrder apiOrder = apiOrderService.findByOrderNo(orderNo , null);
HighOrder order = highOrderService.getOrderByOrderNo(apiOrder.getOrderNo());
// 插入金额记录
// 变更前金额
BigDecimal beforeAmount = apiMerchants.getAmounts();
// 计算金额
apiMerchants.setAmounts(apiMerchants.getAmounts().subtract(price));
apiMerchants.setAmounts(apiMerchants.getAmounts(). subtract(price));
// 变更后金额
BigDecimal afterAmount = apiMerchants.getAmounts();
@ -49,10 +64,10 @@ public class PriceComputeConfig {
apiAmountRecord.setAfterAmount(afterAmount);
apiAmountRecord.setBeforeAmount(beforeAmount);
apiAmountRecord.setAmountType(2);
apiAmountRecord.setSourceType(OrderProductType.PRODUCT_TYPE6.getNumber());
apiAmountRecord.setSourceType(OrderProductType.getDataByType(order.getProductType()).getNumber());
apiAmountRecord.setSourceOrderNo(orderNo);
apiAmountRecord.setSourceId(apiMerchants.getId());
apiAmountRecord.setSourceContent(apiMerchants.getMerchantName() + "|在线加油|扣款" + price.setScale(2, BigDecimal.ROUND_HALF_DOWN));
apiAmountRecord.setSourceContent(apiMerchants.getMerchantName() + "|" + OrderProductType.getDataByType(order.getProductType()).getName() + "|扣款" + price.setScale(2, BigDecimal.ROUND_HALF_DOWN));
apiAmountRecordService.insertAmountRecord(apiAmountRecord);
@ -73,9 +88,9 @@ public class PriceComputeConfig {
return price.multiply(discount).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP);
}
//
// public BigDecimal computationPriceCost(BigDecimal discount , BigDecimal price , BigDecimal 成本) {
// return price.multiply(discount).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP);
//
// }
public BigDecimal computationPriceCost(BigDecimal discount , BigDecimal price , BigDecimal costPrice) {
return costPrice.add(price.multiply(discount.divide(new BigDecimal(100)))).setScale(2, RoundingMode.HALF_UP);
}
}

@ -28,4 +28,34 @@ public interface ApiOrderCreateHandleService {
*/
ApiOrder oilHandle(JSONObject object) throws Exception;
/**
* @Author Sum1Dream
* @Name mobileHandle
* @Description // 话费校验操作
* @Date 15:38 2023/3/13
* @Param [object]
* @Return com.hai.entity.ApiOrder
*/
ApiOrder mobileHandle(JSONObject object) throws Exception;
/**
* @Author Sum1Dream
* @Name memberRechargeHandle
* @Description // 第三方会员充值校验操作
* @Date 14:42 2023/3/15
* @Param [object]
* @Return com.hai.entity.ApiOrder
*/
ApiOrder memberRechargeHandle(JSONObject object) throws Exception;
/**
* @Author Sum1Dream
* @Name kfcHandle
* @Description //TODO
* @Date 14:44 2023/3/15
* @Param [object]
* @Return com.hai.entity.ApiOrder
*/
ApiOrder kfcHandle(JSONObject object) throws Exception;
}

@ -31,7 +31,7 @@ public interface ApiOrderService {
/**
* @Author Sum1Dream
* @Name payOrder
* @Description // 创建订单
* @Description // 订单支付
* @Date 17:44 2023/2/28
* @Param [object]
* @Return void

@ -7,6 +7,7 @@ import com.hai.openApi.model.ApiMobileProductModel;
import com.hai.openApi.service.ApiMchProductService;
import com.hai.openApi.service.ApiMobileRechargeProductService;
import com.hai.order.type.OrderProductType;
import com.hai.service.OutRechargePriceService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@ -27,6 +28,9 @@ public class ApiMobileRechargeProductServiceImpl implements ApiMobileRechargePro
@Resource
private PriceComputeConfig priceComputeConfig;
@Resource
private OutRechargePriceService rechargePriceService;
@Override
public List<ApiProduct> getApiProductByList() {
ApiProductExample example = new ApiProductExample();
@ -50,9 +54,16 @@ public class ApiMobileRechargeProductServiceImpl implements ApiMobileRechargePro
ApiMchProduct apiMchProducts = apiMchProductService.findByMap(mapProduct);
List<ApiMobileProductModel> list = new ArrayList<>();
List<ApiProduct> apiProducts = getApiProductByList();
for (ApiProduct product : apiProducts) {
Map<String, Object> map = new HashMap<>();
map.put("status", 1);
map.put("companyId", 22L);
// 获取话费产品
List<OutRechargePrice> rechargePrices = rechargePriceService.getListRechargePrice(map);
for (OutRechargePrice product : rechargePrices) {
ApiMobileProductModel productModel = new ApiMobileProductModel();
productModel.setDiscount(apiMchProducts.getDiscount());
productModel.setProductId(product.getId());

@ -1,16 +1,18 @@
package com.hai.openApi.service.impl;
import com.alibaba.fastjson.JSONArray;
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.config.QianZhuConfig;
import com.hai.entity.*;
import com.hai.openApi.config.PriceComputeConfig;
import com.hai.openApi.service.ApiMchProductService;
import com.hai.openApi.service.ApiOrderCreateHandleService;
import com.hai.service.ApiMerchantsService;
import com.hai.service.HighGasOilPriceService;
import com.hai.service.HighMerchantStoreService;
import com.hai.openApi.type.OperatorTypeEnum;
import com.hai.order.type.OrderProductType;
import com.hai.service.*;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@ -37,6 +39,12 @@ public class ApiOrderCreateHandleServiceImpl implements ApiOrderCreateHandleServ
@Resource
private ApiMchProductService apiMchProductService;
@Resource
private ApiMemberProductService apiMemberProductService;
@Resource
private OutRechargePriceService rechargePriceService;
@Override
public ApiOrder oilHandle(JSONObject object) throws Exception {
@ -59,6 +67,7 @@ public class ApiOrderCreateHandleServiceImpl implements ApiOrderCreateHandleServ
mchProductMap.put("merchantId" , merchantStore.getMerchantId());
ApiMchProduct mchProduct = apiMchProductService.findByMap(mchProductMap);
// 计算成本价格
BigDecimal price = priceComputeConfig.computationPriceCost(mchProduct.getDiscount() , dataObject.getBigDecimal("refuelPrice"));
// 判断金额是否充足
@ -80,7 +89,7 @@ public class ApiOrderCreateHandleServiceImpl implements ApiOrderCreateHandleServ
// 组装api订单
ApiOrder apiOrder = new ApiOrder();
apiOrder.setCreateTime(new Date());
apiOrder.setTitle(apiMerchants.getMerchantName() + "|在线加油|扣款" + price);
apiOrder.setTitle(apiMerchants.getMerchantName() + "|" + OrderProductType.PRODUCT_TYPE6.getName() + "|扣款" + price);
apiOrder.setFacePrice(dataObject.getBigDecimal("refuelPrice"));
apiOrder.setCostPrice(price);
apiOrder.setMchId(object.getString("merchId"));
@ -94,4 +103,168 @@ public class ApiOrderCreateHandleServiceImpl implements ApiOrderCreateHandleServ
return apiOrder;
}
@Override
public ApiOrder mobileHandle(JSONObject object) throws Exception {
// 获取下单内容
JSONObject dataObject = JSONObject.parseObject(object.getString("content"));
// 查询api商户
ApiMerchants apiMerchants = apiMerchantsService.findByMchId(object.getString("merchId"));
// 查询话费产品
OutRechargePrice rechargePrice = rechargePriceService.findById(dataObject.getLong("productId") , null);
// 查询折扣比例
Map<String , Object> mchProductMap = new HashMap<>();
mchProductMap.put("productType" , object.getString("productType"));
mchProductMap.put("mchId" , object.getString("merchId"));
ApiMchProduct mchProduct = apiMchProductService.findByMap(mchProductMap);
// 计算成本价格
BigDecimal price = priceComputeConfig.computationPriceCost(mchProduct.getDiscount() , rechargePrice.getRechargePrice());
// 判断金额是否充足
if (apiMerchants.getAmounts().compareTo(price) < 0) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.INSUFFICIENT_BALANCE);
}
// 组装内容
JSONObject jsonObject = new JSONObject();
jsonObject.put("operatorType" , OperatorTypeEnum.getDataByType(rechargePrice.getOperatorType()).getName());
jsonObject.put("rechargePrice" , rechargePrice.getRechargePrice());
jsonObject.put("mobile" , dataObject.getString("mobile"));
jsonObject.put("productId" , dataObject.getString("productId"));
// 组装api订单
ApiOrder apiOrder = new ApiOrder();
apiOrder.setCreateTime(new Date());
apiOrder.setTitle(apiMerchants.getMerchantName() + "|话费充值|扣款" + price);
apiOrder.setFacePrice(rechargePrice.getRechargePrice());
apiOrder.setCostPrice(price);
apiOrder.setMchId(object.getString("merchId"));
apiOrder.setMchName(apiMerchants.getMerchantName());
apiOrder.setUpdateTime(new Date());
apiOrder.setProductType(object.getInteger("productType"));
apiOrder.setMchOrderNo(object.getString("orderNo"));
apiOrder.setOrderPrice(rechargePrice.getRechargePrice());
apiOrder.setNotifyUrl(object.getString("notifyUrl"));
apiOrder.setContent(jsonObject.toJSONString());
return apiOrder;
}
@Override
public ApiOrder memberRechargeHandle(JSONObject object) throws Exception {
// 获取下单内容
JSONObject dataObject = JSONObject.parseObject(object.getString("content"));
// 查询api商户
ApiMerchants apiMerchants = apiMerchantsService.findByMchId(object.getString("merchId"));
ApiMemberProduct memberProduct = apiMemberProductService.findByProductId(dataObject.getString("productId"));
if (memberProduct == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前产品不可购买");
}
// 查询折扣比例
Map<String , Object> mchProductMap = new HashMap<>();
mchProductMap.put("productType" , object.getString("productType"));
mchProductMap.put("mchId" , object.getString("merchId"));
ApiMchProduct mchProduct = apiMchProductService.findByMap(mchProductMap);
// 计算成本价格
BigDecimal price = priceComputeConfig.computationPriceCost(mchProduct.getDiscount() , memberProduct.getPrice() , memberProduct.getCostPrice());
// 判断金额是否充足
if (apiMerchants.getAmounts().compareTo(price) < 0) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.INSUFFICIENT_BALANCE);
}
// 组装内容
JSONObject jsonObject = new JSONObject();
jsonObject.put("name" ,memberProduct.getName());
jsonObject.put("rechargePrice" , memberProduct.getPrice());
jsonObject.put("mobile" , dataObject.getString("mobile"));
jsonObject.put("productId" , dataObject.getString("productId"));
// 组装api订单
ApiOrder apiOrder = new ApiOrder();
apiOrder.setCreateTime(new Date());
apiOrder.setTitle(apiMerchants.getMerchantName() + "|" + OrderProductType.PRODUCT_TYPE3.getName() + "|扣款" + price);
apiOrder.setFacePrice(memberProduct.getPrice());
apiOrder.setCostPrice(price);
apiOrder.setMchId(object.getString("merchId"));
apiOrder.setMchName(apiMerchants.getMerchantName());
apiOrder.setUpdateTime(new Date());
apiOrder.setProductType(object.getInteger("productType"));
apiOrder.setMchOrderNo(object.getString("orderNo"));
apiOrder.setOrderPrice(memberProduct.getPrice());
apiOrder.setNotifyUrl(object.getString("notifyUrl"));
apiOrder.setContent(jsonObject.toJSONString());
apiOrder.setExt1(memberProduct.getId().toString());
return apiOrder;
}
@Override
public ApiOrder kfcHandle(JSONObject object) throws Exception {
// 获取下单内容
JSONObject dataObject = JSONObject.parseObject(object.getString("content"));
// 查询api商户
ApiMerchants apiMerchants = apiMerchantsService.findByMchId(object.getString("merchId"));
// 查询折扣比例
Map<String , Object> mchProductMap = new HashMap<>();
mchProductMap.put("productType" , object.getString("productType"));
mchProductMap.put("mchId" , object.getString("merchId"));
ApiMchProduct mchProduct = apiMchProductService.findByMap(mchProductMap);
// 查询肯德基门店菜单
JSONObject jsonObject = QianZhuConfig.listByStoreCode(dataObject.getString("storeCode"));
JSONArray array = jsonObject.getJSONArray("data");
if (array == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "门店编码错误");
}
Map<String, Object> mapProduct = new HashMap<>();
mapProduct.put("mchId" , object.getString("merchId"));
mapProduct.put("productType" , OrderProductType.PRODUCT_TYPE2.getNumber());
ApiMchProduct apiMchProducts = apiMchProductService.findByMap(mapProduct);
for (Object data : array) {
JSONObject kfcObject = (JSONObject) data;
if (kfcObject.getJSONArray("products") != null) {
for (Object products : kfcObject.getJSONArray("products")) {
JSONObject productsObject = (JSONObject) products;
productsObject.put("taxOriginalPrice" , null);
productsObject.put("taxOriginalTotalPrice" , null);
productsObject.put("price" , priceComputeConfig.computationPriceCost(apiMchProducts.getDiscount() , productsObject.getBigDecimal("originalPrice") , productsObject.getBigDecimal("price")));
productsObject.put("taxPrice" , null);
if (productsObject.getJSONArray("specGroups") != null) {
for (Object specGroups : productsObject.getJSONArray("specGroups")) {
JSONObject specGroupsObject = (JSONObject) specGroups;
specGroupsObject.put("taxOriginalPrice" , null);
specGroupsObject.put("taxOriginalTotalPrice" , null);
specGroupsObject.put("price" , priceComputeConfig.computationPriceCost(apiMchProducts.getDiscount() , specGroupsObject.getBigDecimal("originalPrice") , specGroupsObject.getBigDecimal("price")));
specGroupsObject.put("taxPrice" , null);
}
}
}
}
}
return null;
}
}

@ -87,6 +87,27 @@ public class ApiOrderServiceImpl implements ApiOrderService {
throw ErrorHelp.genException(SysCode.System, ErrorCode.ORDER_ALREADY_EXISTS);
}
// 处理会员充值订单
if (OrderProductType.PRODUCT_TYPE3.getNumber().equals(object.getInteger("productType"))) {
apiOrder = orderCreateHandleService.memberRechargeHandle(object);
// 组装子订单内容
CreateOrderChildModel createOrderChildModel = new CreateOrderChildModel();
createOrderChildModel.setMemName(apiMerchants.getMerchantName());
createOrderChildModel.setMemPhone(apiMerchants.getPhone());
createOrderChildModel.setCompanyId(2L);
createOrderChildModel.setGoodsType(OrderChildGoodsType.TYPE10.getNumber());
createOrderChildModel.setGoodsId(Long.valueOf(apiOrder.getExt1()));
createOrderChildModel.setRechargeContent(dataObject.getString("mobile"));
createOrderChildModel.setSaleCount(1);
createOrderChildModel.setIsTyAgent(false);
createOrderChildModel.setGoodsPrice(apiOrder.getOrderPrice());
// 组装订单
createOrderModel.getChildOrderList().add(createOrderChildModel);
orderService.createOrder(createOrderModel);
}
// 处理加油订单
if (OrderProductType.PRODUCT_TYPE6.getNumber().equals(object.getInteger("productType"))) {
apiOrder = orderCreateHandleService.oilHandle(object);
@ -109,6 +130,29 @@ public class ApiOrderServiceImpl implements ApiOrderService {
createOrderModel.getChildOrderList().add(createOrderChildModel);
orderService.createOrder(createOrderModel);
}
// 处理话费充值订单
if (OrderProductType.PRODUCT_TYPE9.getNumber().equals(object.getInteger("productType"))) {
apiOrder = orderCreateHandleService.mobileHandle(object);
// 组装子订单内容
CreateOrderChildModel createOrderChildModel = new CreateOrderChildModel();
createOrderChildModel.setMemName(apiMerchants.getMerchantName());
createOrderChildModel.setMemPhone(apiMerchants.getPhone());
createOrderChildModel.setCompanyId(2L);
createOrderChildModel.setGoodsType(OrderChildGoodsType.TYPE6.getNumber());
createOrderChildModel.setGoodsId(dataObject.getLong("productId"));
createOrderChildModel.setRechargeContent(dataObject.getString("mobile"));
createOrderChildModel.setSaleCount(1);
createOrderChildModel.setIsTyAgent(false);
createOrderChildModel.setGoodsPrice(apiOrder.getOrderPrice());
// 组装订单
createOrderModel.getChildOrderList().add(createOrderChildModel);
orderService.createOrder(createOrderModel);
}
apiOrder.setOrderNo(createOrderModel.getOrderNo());
apiOrder.setStatus(1);
apiOrderMapper.insert(apiOrder);
@ -128,6 +172,7 @@ public class ApiOrderServiceImpl implements ApiOrderService {
// 查询订单
HighOrder order = orderService.getOrderDetailByNo(object.getString("orderNo"));
if(!order.getOrderStatus().equals(OrderStatus.STATUS1.getNumber())) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.ORDER_NO_STAY_PAY, "");
}

@ -0,0 +1,44 @@
package com.hai.openApi.type;
import com.hai.enum_type.DeviceTypeEnum;
import com.hai.order.type.OrderProductType;
import java.util.Objects;
public enum OperatorTypeEnum {
type1(1, "电信运营商"),
type2(2, "移动运营商"),
type3(3, "联通运营商"),
;
private Integer type;
private String name;
OperatorTypeEnum(int type, String name) {
this.type = type;
this.name = name;
}
public static OperatorTypeEnum getDataByType(Integer type) {
for (OperatorTypeEnum ele : values()) {
if(Objects.equals(type,ele.getType())) return ele;
}
return null;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}

@ -611,24 +611,22 @@ public class OrderCreateHandleServiceImpl implements OrderCreateHandleService {
JSONObject jsonObject;
List<HighChildOrder> childOrderList = new ArrayList<>();
// 查询用户
HighUser user = highUserService.findByUserId(object.getLong("userId"));
// 千猪返回订单号
String orderNo;
// 查询详单订单的实际
JSONObject productDetail = thirdProductConfig.getThirdPartyByDetail(object.getInteger("platformId"), object.getInteger("productType"), object.getLong("companyId") , object.getLong("productId") , null , "");
JSONObject productDetail = thirdProductConfig.getThirdPartyByDetail(object.getInteger("platformId"), order.getProductType(), object.getLong("companyId") , object.getLong("productId") , null , "");
// 获取token 千猪请求接口token
JSONObject userToken = QianZhuConfig.getTokenV2(user.getId().toString(), user.getName(), user.getPhone());
JSONObject userToken = QianZhuConfig.getTokenV2("19940218", order.getMemName(), order.getMemPhone());
if (!userToken.getBoolean("success")) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, userToken.getString("message"));
}
// 1 星巴克 2 肯德基 3 会员充值
if (object.getInteger("productType") == 1) {
if (order.getProductType() == 1) {
List<String> List = new ArrayList<>();
@ -665,7 +663,7 @@ public class OrderCreateHandleServiceImpl implements OrderCreateHandleService {
}
// 下单
jsonObject = QianZhuConfig.starbucksOrders(user.getId().toString(), object.getString("storeCode"), List.toString().replace(" ", ""), object.getString("customerMobile"));
jsonObject = QianZhuConfig.starbucksOrders("19940218", object.getString("storeCode"), List.toString().replace(" ", ""), object.getString("customerMobile"));
// 判断下单是否成功
if (!Objects.equals(jsonObject.getString("code"), "200")) {
@ -700,10 +698,10 @@ public class OrderCreateHandleServiceImpl implements OrderCreateHandleService {
childOrder.setStoreId(object.getLong("storeCode"));
childOrder.setChannelOrderNo(orderNo);
childOrder.setGoodsId(object.getLong("productId"));
childOrder.setMemId(user.getId());
childOrder.setMemId(order.getMemId());
childOrder.setOrderNo(order.getOrderNo());
childOrder.setMemName(user.getName());
childOrder.setMemPhone(user.getPhone());
childOrder.setMemName(order.getMemName());
childOrder.setMemPhone(order.getMemPhone());
childOrder.setStoreAddress(orderObject.getJSONObject("data").getString("storeAddress"));
childOrder.setStoreName(orderObject.getJSONObject("data").getString("storeName"));
childOrder.setGoodsName(childObject.getString("productName"));
@ -732,7 +730,7 @@ public class OrderCreateHandleServiceImpl implements OrderCreateHandleService {
}
} else if (object.getInteger("productType") == 2) {
} else if (order.getProductType() == 2) {
if (object.getInteger("eatType") == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请选择就餐方式!");
}
@ -760,9 +758,9 @@ public class OrderCreateHandleServiceImpl implements OrderCreateHandleService {
HighChildOrder childOrder = new HighChildOrder();
childOrder.setChildOrderStatus(1);
childOrder.setGoodsType(4);
childOrder.setMemId(user.getId());
childOrder.setMemName(user.getName());
childOrder.setMemPhone(user.getPhone());
childOrder.setMemId(order.getMemId());
childOrder.setMemName(order.getMemName());
childOrder.setMemPhone(order.getMemPhone());
childOrder.setChildOrderNo(OrderUtil.generateChildOrderNo());
childOrder.setOrderNo(order.getOrderNo());
childOrder.setGoodsId(object.getLong("productId"));
@ -793,7 +791,7 @@ public class OrderCreateHandleServiceImpl implements OrderCreateHandleService {
childOrderList.add(childOrder);
}
} else if (object.getInteger("productType") == 3) {
} else if (order.getProductType() == 3) {
ApiMemberProduct memberProduct = apiMemberProductService.findById(object.getLong("goodsId"));
if (memberProduct == null) {
@ -815,11 +813,12 @@ public class OrderCreateHandleServiceImpl implements OrderCreateHandleService {
childOrder.setStoreId(object.getLong("storeCode"));
childOrder.setGoodsId(memberProduct.getId());
childOrder.setGoodsName(memberProduct.getName());
childOrder.setGoodsSpecName(memberProduct.getName());
childOrder.setGiveawayType(false);
childOrder.setSaleCount(1);
childOrder.setMemId(user.getId());
childOrder.setMemName(user.getName());
childOrder.setMemPhone(user.getPhone());
childOrder.setMemId(order.getMemId());
childOrder.setMemName(order.getMemName());
childOrder.setMemPhone(order.getMemPhone());
childOrder.setGoodsPrice(memberProduct.getPrice());
childOrder.setTotalPrice(memberProduct.getPrice());
childOrder.setTotalActualPrice(childPrice);
@ -841,7 +840,6 @@ public class OrderCreateHandleServiceImpl implements OrderCreateHandleService {
// 初始化话费订单对象
OutRechargeOrder outRechargeOrder = new OutRechargeOrder();
// 查询用户信息
HighUser user = highUserService.findByUserId(object.getLong("userId"));
// 产品id
Long goodsId = object.getLong("goodsId");
// 充值内容
@ -858,9 +856,6 @@ public class OrderCreateHandleServiceImpl implements OrderCreateHandleService {
// 生成交易子订单
HighChildOrder childOrder = new HighChildOrder();
childOrder.setMemId(user.getId());
childOrder.setMemName(user.getName());
childOrder.setMemPhone(user.getPhone());
childOrder.setOrderNo(order.getOrderNo());
childOrder.setChildOrderNo(OrderUtil.generateChildOrderNo());
childOrder.setGoodsType(OrderChildGoodsType.TYPE6.getNumber());
@ -878,12 +873,12 @@ public class OrderCreateHandleServiceImpl implements OrderCreateHandleService {
childOrder.setPraiseStatus(0);
childOrder.setCreateTime(new Date());
outRechargeOrder.setUserId(user.getId());
outRechargeOrder.setUserId(order.getMemId());
outRechargeOrder.setRechargeContent(rechargeContent);
outRechargeOrder.setCompanyId(outRechargePrice.getCompanyId());
outRechargeOrder.setUserName(user.getName());
outRechargeOrder.setUserName(order.getMemName());
outRechargeOrder.setRechargeType(outRechargePrice.getRechargeType());
outRechargeOrder.setUserPhone(user.getPhone());
outRechargeOrder.setUserPhone(order.getMemPhone());
outRechargeOrder.setOrderNo(order.getOrderNo());
outRechargeOrder.setChildOrderNo(childOrder.getChildOrderNo());
outRechargeOrder.setCreateTimed(new Date());

@ -53,5 +53,15 @@ public interface ApiMemberProductService {
* @return com.hai.entity.ApiMemberProduct
*/
ApiMemberProduct findById(Long id);
/**
* @Author Sum1Dream
* @Name findByProductId
* @Description //TODO
* @Date 17:26 2023/3/14
* @Param [productId]
* @Return com.hai.entity.ApiMemberProduct
*/
ApiMemberProduct findByProductId(String productId);
}

@ -24,6 +24,10 @@ public interface OutRechargeOrderService {
**/
List<OutRechargeOrder> getListRechargeOrder(Map<String , Object> map);
List<OutRechargeOrder> selectList();
/**
* @Author Sum1Dream
* @Description // 根据订单ID查询订单

@ -49,4 +49,19 @@ public class ApiMemberProductServiceImpl implements ApiMemberProductService {
public ApiMemberProduct findById(Long id) {
return apiMemberProductMapper.selectByPrimaryKey(id);
}
@Override
public ApiMemberProduct findByProductId(String productId) {
ApiMemberProductExample example = new ApiMemberProductExample();
example.createCriteria().andStatusEqualTo(101).andProductIdEqualTo(productId);
List<ApiMemberProduct> list = apiMemberProductMapper.selectByExample(example);
if (list.size() > 0) {
return list.get(0);
}
return null;
}
}

@ -1,575 +0,0 @@
package com.hai.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
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.DateUtil;
import com.hai.common.utils.IDGenerator;
import com.hai.config.CommonSysConst;
import com.hai.config.QianZhuConfig;
import com.hai.config.RechargeConfig;
import com.hai.dao.HighChildOrderMapper;
import com.hai.dao.HighOrderMapper;
import com.hai.dao.OutRechargeOrderMapper;
import com.hai.entity.*;
import com.hai.service.*;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
@Service("apiOpenService")
public class ApiOpenServiceImpl implements ApiOpenService {
@Resource
private ApiOrderRecordService apiOrderRecordService;
@Resource
private ApiMerchantsService apiMerchantsService;
@Resource
private ApiProductService apiProductService;
@Resource
private ApiAmountRecordService apiAmountRecordService;
@Resource
private OutRechargeOrderMapper outRechargeOrderMapper;
@Resource
private OutRechargeChildOrderService outRechargeChildOrderService;
@Resource
private BsRequestRecordService bsRequestRecordService;
@Resource
private HighOrderMapper highOrderMapper;
@Resource
private HighChildOrderMapper highChildOrderMapper;
@Resource
private ApiMemberProductService apiMemberProductService;
@Resource
private SecConfigService secConfigService;
@Resource
private HighOrderService highOrderService;
@Override
@Transactional(rollbackFor=Exception.class,isolation = Isolation.SERIALIZABLE,propagation= Propagation.REQUIRES_NEW)
public void createOrder(JSONObject object , ApiMerchants apiMerchants , ApiProductConfig productConfig) throws Exception {
Map<String, Object> orderMap = new HashMap<>();
orderMap.put("sourceOrderNo" , object.getString("sourceOrderNo"));
// 查询是否用重复订单
ApiOrderRecord apiOrderRecord = apiOrderRecordService.queryOrderResult(orderMap);
if (apiOrderRecord != null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.ORDER_ALREADY_EXISTS);
}
ApiProduct apiProduct = apiProductService.findById(productConfig.getProductId());
// 当前账号余额是否可以充值当前金额
if (apiMerchants.getAmounts().compareTo(productConfig.getDiscountPrice()) < 0) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.INSUFFICIENT_BALANCE);
}
// 插入金额记录
// 变更前金额
BigDecimal beforeAmount = apiMerchants.getAmounts();
// 计算金额
apiMerchants.setAmounts(apiMerchants.getAmounts().subtract(productConfig.getDiscountPrice()));
// 变更后金额
BigDecimal afterAmount = apiMerchants.getAmounts();
apiMerchantsService.updateApiMerchants(apiMerchants);
ApiAmountRecord apiAmountRecord = new ApiAmountRecord();
apiAmountRecord.setCreateTime(new Date());
apiAmountRecord.setUpdateTime(new Date());
apiAmountRecord.setMchId(apiMerchants.getMchId());
apiAmountRecord.setStatus(100);
apiAmountRecord.setAmount(productConfig.getDiscountPrice());
apiAmountRecord.setAfterAmount(afterAmount);
apiAmountRecord.setBeforeAmount(beforeAmount);
apiAmountRecord.setAmountType(2);
apiAmountRecord.setSourceType(3);
apiAmountRecord.setSourceOrderNo(object.getString("orderNo"));
apiAmountRecord.setSourceId(apiProduct.getId());
apiAmountRecord.setSourceContent(apiMerchants.getMerchantName() + "|" + object.getString("mobile") + "充值" + apiProduct.getRechargePrice() + "|扣款" + productConfig.getDiscountPrice());
apiAmountRecordService.insertAmountRecord(apiAmountRecord);
// 充值订单
OutRechargeOrder outRechargeOrder = new OutRechargeOrder();
outRechargeOrder.setPayStatus(102);
outRechargeOrder.setRechargeStatus(204);
outRechargeOrder.setOrderNo("RCG" + DateUtil.date2String(new Date(), "yyyyMMddHHmmss") + IDGenerator.nextId(5));
outRechargeOrder.setPaySerialNo("22" + DateUtil.date2String(new Date(), "yyyyMMddHHmmss") + IDGenerator.nextId(5));
outRechargeOrder.setRechargePrice(apiProduct.getRechargePrice());
outRechargeOrder.setRechargeType(apiProduct.getPhoneRechargeType());
outRechargeOrder.setOrderPrice(productConfig.getDiscountPrice());
outRechargeOrder.setPayPrice(productConfig.getDiscountPrice());
outRechargeOrder.setPayRealPrice(productConfig.getDiscountPrice());
outRechargeOrder.setRechargeContent(object.getString("mobile"));
outRechargeOrder.setPayTime(new Date());
outRechargeOrder.setUserName(apiMerchants.getMerchantName());
outRechargeOrder.setUserPhone(apiMerchants.getPhone());
outRechargeOrder.setPayType(6);
outRechargeOrder.setCompanyId(6666L);
outRechargeOrder.setType(1);
outRechargeOrder.setCreateTimed(new Date());
outRechargeOrder.setOperatorName(apiProduct.getOperatorName());
outRechargeOrder.setOperatorType(apiProduct.getOperatorType());
outRechargeOrder.setGoodsId(apiProduct.getId());
outRechargeOrder.setMerchId(apiMerchants.getMchId());
outRechargeOrder.setUserId(apiMerchants.getId());
outRechargeOrderMapper.insert(outRechargeOrder);
pollRequest(outRechargeOrder);
// 插入订单记录
ApiOrderRecord apiOrderRecordPost = new ApiOrderRecord();
apiOrderRecordPost.setStatus(103);
apiOrderRecordPost.setOrderNo(outRechargeOrder.getOrderNo());
apiOrderRecordPost.setSourceOrderNo(object.getString("sourceOrderNo"));
apiOrderRecordPost.setCreateTime(new Date());
apiOrderRecordPost.setMchId(apiMerchants.getMchId());
apiOrderRecordPost.setOrderId(outRechargeOrder.getId());
apiOrderRecordPost.setGoodsId(productConfig.getId().toString());
apiOrderRecordPost.setNotifyUrl(object.getString("notifyUrl"));
apiOrderRecordPost.setUpdateTime(new Date());
apiOrderRecordService.insertOrderRecord(apiOrderRecordPost);
}
private void pollRequest(OutRechargeOrder outRechargeOrder) throws Exception {
// 查询充值产品
ApiProduct apiProduct = apiProductService.findById(outRechargeOrder.getGoodsId());
// 查询充值子订单
Map<String, Object> childOrderMap = new HashMap<>();
childOrderMap.put("parent_order_id", outRechargeOrder.getId());
childOrderMap.put("status", 102);
List<OutRechargeChildOrder> childOrderList = outRechargeChildOrderService.getListRechargeChildOrder(childOrderMap);
OutRechargeChildOrder childOrder = new OutRechargeChildOrder();
// 1:尖椒 2:龙阅 3:畅停
int type = 0;
int rechargePlatformType = 0;
// 判断子订单是否存在充值中订单
if (childOrderList.size() > 0) {
childOrder = childOrderList.get(0);
childOrder.setStatus(103);
childOrder.setUpdateTime(new Date());
outRechargeChildOrderService.updateOrder(childOrder);
type = childOrder.getRechargePlatform();
} else {
// 查询充值子订单
Map<String, Object> childOrderMap103 = new HashMap<>();
childOrderMap103.put("parent_order_id", outRechargeOrder.getId());
childOrderMap103.put("status", 103);
List<OutRechargeChildOrder> childOrderList103 = outRechargeChildOrderService.getListRechargeChildOrder(childOrderMap103);
if (childOrderList103.size() > 0) {
type = childOrderList103.get(0).getRechargePlatform();
}
}
if (type == 2) {
type = 1;
} else {
type++;
}
JSONObject object = new JSONObject();
String orderNo = "CZ" + DateUtil.date2String(new Date(), "yyyyMMddHHmmss") + IDGenerator.nextId(5);
String[] rechargePlatform = apiProduct.getRechargePlatform().split("-");
for (String s : rechargePlatform) {
// 尖椒充值
if (s.equals("1") && type == 1) {
object.put("out_order_id", orderNo);
object.put("amount", apiProduct.getRechargePrice());
object.put("mobile", outRechargeOrder.getRechargeContent());
object.put("notifyUrl", CommonSysConst.getSysConfig().getJjNotifyUrl());
if (apiProduct.getRechargeType() == 1) {
object.put("is_fast", 1);
}
JSONObject returnObject = RechargeConfig.rechargeOrderByJj(object);
object.put("return_content", returnObject);
if (returnObject != null && returnObject.getLong("code") == 200) {
childOrder.setStatus(102);
} else {
childOrder.setStatus(103);
}
rechargePlatformType = 1;
break;
}
if (s.equals("2") && type == 2) {
object.put("out_trade_num", orderNo);
object.put("product_id", apiProduct.getProductId());
object.put("mobile", outRechargeOrder.getRechargeContent());
object.put("notifyUrl", CommonSysConst.getSysConfig().getLyNotifyUrl());
JSONObject returnObject = RechargeConfig.rechargeOrderByLy(object);
object.put("return_content", returnObject);
if (returnObject != null && returnObject.getLong("errno") == 0) {
childOrder.setStatus(102);
} else {
childOrder.setStatus(103);
}
rechargePlatformType = 2;
break;
}
}
childOrder.setOrderNo(orderNo);
childOrder.setCreateTime(new Date());
childOrder.setParentOrderId(outRechargeOrder.getId());
childOrder.setRechargePlatform(rechargePlatformType);
childOrder.setUpdateTime(new Date());
outRechargeChildOrderService.insertOrder(childOrder);
// 创建提交记录
BsRequestRecord requestRecord = new BsRequestRecord();
requestRecord.setCreateTime(new Date());
requestRecord.setUpdateTime(new Date());
requestRecord.setOrderNo(orderNo);
requestRecord.setRequestContent(object.toJSONString());
requestRecord.setOperatorId(0L);
requestRecord.setOperatorName("系统生成");
requestRecord.setSourceId(childOrder.getId().toString());
requestRecord.setSourceType(1);
bsRequestRecordService.insertRequestRecord(requestRecord);
// 判断是否充值提交成功
if (childOrder.getStatus() == 102) {
outRechargeOrder.setRechargeStatus(201);
}
if (childOrder.getStatus() == 103) {
outRechargeOrder.setRechargeStatus(204);
}
outRechargeOrderMapper.updateByPrimaryKey(outRechargeOrder);
}
@Override
@Transactional(rollbackFor=Exception.class,isolation = Isolation.SERIALIZABLE,propagation= Propagation.REQUIRES_NEW)
public void createOrder(JSONObject object , ApiMerchants apiMerchants) throws Exception {
// // 定义订单
// HighOrder highOrder = new HighOrder();
// highOrder.setMerchId(apiMerchants.getMchId());
// highOrder.setWhetherRebate(false);
// highOrder.setMemPhone(apiMerchants.getPhone());
// highOrder.setMemName(apiMerchants.getMerchantName());
// highOrder.setMemId(apiMerchants.getId());
// highOrder.setCreateTime(new Date());
// highOrder.setOrderStatus(1);
// highOrder.setProductType(object.getInteger("productType"));
// highOrder.setPayType(OrderPayTypeEnum.type8.getType());
// highOrder.setOrderNo("HF" + DateUtil.date2String(new Date(),"yyyyMMddHHmmss") + IDGenerator.nextId(5));
// highOrderMapper.insert(highOrder);
//
// // 订单总金额
// BigDecimal marketPriceTotal = new BigDecimal(0);
//
// // 定义下单json对象
// JSONObject jsonObject;
//
// // 获取token
// JSONObject userToken = QianZhuConfig.getTokenV2(apiMerchants.getId().toString(), apiMerchants.getMerchantName(), apiMerchants.getPhone());
//
// if (!userToken.getBoolean("success")) {
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, userToken.getString("message"));
// }
//
// // 1 星巴克 2 肯德基 3 会员充值
// if (object.getInteger("productType") == 1) {
//
// // 判断当前商户是否有权限下单
// if (!secConfigService.isConfig("STARBUCKS_CONFIG" , object.getString("merchId"))) {
// throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_NOT_AUTHORIZED, "当前帐户无权限查询!");
// }
//
// List<String> List = new ArrayList<>();
//
// // 获取下单内容
// JSONArray array = object.getJSONArray("orderItems");
//
// // 组装下单数据
// for (Object o : array) {
// JSONObject object1 = (JSONObject) o;
// Map<String, Object> contentMap = new LinkedHashMap<>();
// if (!object1.getString("productId").equals("")) {
// contentMap.put("productId", object1.getString("productId"));
// }
// if (!object1.getString("cupSize").equals("")) {
// contentMap.put("cupSize", object1.getString("cupSize"));
// }
// if (!object1.getString("temperature").equals("")) {
// contentMap.put("temperature", object1.getString("temperature"));
// }
// if (!object1.getString("cream").equals("")) {
// contentMap.put("cream", object1.getString("cream"));
// }
// if (!object1.getString("espresso").equals("")) {
// contentMap.put("espresso", object1.getString("espresso"));
// }
// if (!object1.getString("milk").equals("")) {
// contentMap.put("milk", object1.getString("milk"));
// }
// if (!object1.getString("milkBubble").equals("")) {
// contentMap.put("milkBubble", object1.getString("milkBubble"));
// }
// if (!"".equals(object1.getString("num"))) {
// contentMap.put("num", object1.getString("num"));
// }
// // 添加到LIST
// List.add(JSON.toJSONString(contentMap));
// }
//
// // 下单
// jsonObject = QianZhuConfig.starbucksOrders(apiMerchants.getId().toString(), object.getString("storeCode"), List.toString().replace(" ", ""), object.getString("customerMobile"));
//
// // 判断下单是否成功
// if (!Objects.equals(jsonObject.getString("code"), "200")) {
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, jsonObject.getString("message"));
// }
//
// if (!jsonObject.getBoolean("success")) {
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, jsonObject.getString("message"));
// }
//
// // 根据订单号查询订单详情
// JSONObject orderObject = QianZhuConfig.starbucksOrderByOrderNo(jsonObject.getJSONObject("data").getString("orderNo"));
//
// // 判断是否成功
// if (!orderObject.getBoolean("success")) {
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, jsonObject.getString("message"));
// }
//
// // 获取星巴克订单内容
// JSONArray starbucksOrder = orderObject.getJSONObject("data").getJSONArray("orderItems");
//
//
// // 循环获取星巴克订单
// for (Object starbucksObject : starbucksOrder) {
// JSONObject childObject = (JSONObject) starbucksObject;
// HighChildOrder childOrder = new HighChildOrder();
// childOrder.setOrderId(highOrder.getId());
// childOrder.setChildOrdeStatus(1);
// childOrder.setMemId(highOrder.getMemId());
// childOrder.setGoodsType(9);
// childOrder.setStoreId(object.getLong("storeCode"));
// childOrder.setGoodsId(childObject.getLong("id"));
// childOrder.setStoreAddress(childObject.getString("storeAddress"));
// childOrder.setStoreName(childObject.getString("storeName"));
// childOrder.setGoodsName(childObject.getString("productName"));
// childOrder.setGoodsImg(childObject.getString("imgUrl"));
// childOrder.setSaleCount(childObject.getInteger("quantity"));
// childOrder.setGoodsPrice(childObject.getBigDecimal("marketPrice"));
//
// // 计算子订单支付金额
// BigDecimal childPrice = childObject.getBigDecimal("marketPrice");
// childOrder.setGoodsActualPrice(childPrice);
// // 计算市场价金额
// childOrder.setTotalPrice(childPrice.multiply(childObject.getBigDecimal("quantity")));
// marketPriceTotal = marketPriceTotal.add(childOrder.getTotalPrice());
//
// highChildOrderMapper.insert(childOrder);
// }
// // 拼接json对象
// object.put("sourceType" , 5);
// object.put("content" , apiMerchants.getMerchantName() + "|" + "星巴克下单" + "|扣款" + marketPriceTotal);
// }else if (object.getInteger("productType") == 2) {
//
// // 判断当前商户是否有肯德基下单权限
// if (!secConfigService.isConfig("KFC_CONFIG" , object.getString("merchId"))) {
// throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_NOT_AUTHORIZED, "当前帐户无权限查询!");
// }
// // 判断就餐方式
// if (object.getInteger("eatType") == null) {
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请选择就餐方式!");
// }
// // 下单
// jsonObject = QianZhuConfig.createKfcOrder(object.getInteger("eatType"), object.getString("storeCode"), object.getString("customerMobile"), object.getString("orderItems"), apiMerchants.getId().toString());
//
// // 判断下单是否成功
// if (!Objects.equals(jsonObject.getString("code"), "10000")) {
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, jsonObject.getString("message"));
// }
//
// // 根据订单号查询订单详情
// JSONObject orderObject = QianZhuConfig.getKfcOrderByOrderNo(jsonObject.getJSONObject("data").getString("orderNo"));
// // 判断下单是否成功
// if (!orderObject.getBoolean("success")) {
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, jsonObject.getString("message"));
// }
//
// // 获取肯德基订单内容
// JSONArray kfcOrder = orderObject.getJSONObject("data").getJSONObject("kfcPlaceOrder").getJSONArray("items");
// for (Object kfcObject : kfcOrder) {
//
// JSONObject childObject = (JSONObject) kfcObject;
// HighChildOrder childOrder = new HighChildOrder();
// childOrder.setOrderId(highOrder.getId());
// childOrder.setChildOrdeStatus(1);
// childOrder.setGoodsType(4);
// childOrder.setMemId(highOrder.getMemId());
// childOrder.setExt6(object.getString("storeCode"));
// childOrder.setGoodsId(childObject.getLong("productId"));
// childOrder.setStoreAddress(orderObject.getJSONObject("data").getJSONObject("kfcPlaceOrder").getString("storeAddress"));
// childOrder.setStoreName(orderObject.getJSONObject("data").getJSONObject("kfcPlaceOrder").getString("storeName"));
// childOrder.setGoodsName(childObject.getString("productName"));
// childOrder.setGoodsImg(childObject.getString("imageUrl"));
// childOrder.setSaleCount(childObject.getInteger("quantity"));
// childOrder.setGoodsPrice(childObject.getBigDecimal("originPrice"));
//
// // 计算利润
// // 计算子订单支付金额
// BigDecimal childPrice = childObject.getBigDecimal("originPrice");
// childOrder.setGoodsActualPrice(childPrice);
// // 计算市场价金额
// childOrder.setTotalPrice(childPrice.multiply(childObject.getBigDecimal("quantity")));
// marketPriceTotal = marketPriceTotal.add(childOrder.getTotalPrice());
// highChildOrderMapper.insert(childOrder);
// }
// // 拼接json对象
// object.put("sourceType" , 4);
// object.put("content" , apiMerchants.getMerchantName() + "|" + "肯德基下单" + "|扣款" + marketPriceTotal);
// } else if (object.getInteger("productType") == 3) {
//
// // 判断是否有会员充值下单权限
// if (!secConfigService.isConfig("MEMBER_RECHARGE_CONFIG" , object.getString("merchId"))) {
// throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_NOT_AUTHORIZED, "当前帐户无权限查询!");
// }
//
// // 获取会员充值
// ApiMemberProduct memberProduct = apiMemberProductService.findById(object.getLong("goodsId"));
//
// if (memberProduct == null) {
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前产品不可购买");
// }
//
// object.put("productId", memberProduct.getProductId());
//
// HighChildOrder childOrder = new HighChildOrder();
// childOrder.setOrderId(highOrder.getId());
// childOrder.setChildOrdeStatus(1);
// childOrder.setGoodsType(10);
// childOrder.setStoreId(object.getLong("storeCode"));
// childOrder.setGoodsId(memberProduct.getId());
// childOrder.setGoodsName(memberProduct.getName());
// childOrder.setSaleCount(1);
// childOrder.setMemId(highOrder.getMemId());
// childOrder.setGoodsPrice(memberProduct.getPrice());
// childOrder.setGoodsActualPrice(memberProduct.getPrice());
// // 计算市场价金额
// childOrder.setTotalPrice(memberProduct.getPrice());
// marketPriceTotal = marketPriceTotal.add(childOrder.getTotalPrice());
// highChildOrderMapper.insert(childOrder);
// object.put("sourceType" , 6);
// object.put("content" , apiMerchants.getMerchantName() + "|" + "第三方会员充值下单" + "|扣款" + marketPriceTotal);
// }
// // 当前账号余额是否可以充值当前金额
// if (apiMerchants.getAmounts().compareTo(marketPriceTotal) < 0) {
// throw ErrorHelp.genException(SysCode.System, ErrorCode.INSUFFICIENT_BALANCE);
// }
//
// highOrder.setTotalPrice(marketPriceTotal);
// highOrder.setPayPrice(marketPriceTotal);
// highOrder.setPayRealPrice(marketPriceTotal);
// highOrder.setPayablePrice(marketPriceTotal);
// ApiAmountRecord apiAmountRecord = apiMerchantAmount(highOrder , apiMerchants , object);
//
// highOrder.setOrderStatus(2);
// highOrder.setPayTime(new Date());
// highOrder.setPaySerialNo("22" + DateUtil.date2String(new Date(), "yyyyMMddHHmmss") + IDGenerator.nextId(5));
// highOrderMapper.updateByPrimaryKey(highOrder);
//
// // 更新子订单状态
// List<HighChildOrder> childOrderList = highOrderService.getChildOrderByOrder(highOrder.getId());
//
// for (HighChildOrder highChildOrder : childOrderList) {
// highChildOrder.setChildOrdeStatus(2);
// highChildOrderMapper.updateByPrimaryKey(highChildOrder);
// }
//
// // 插入订单记录
// ApiOrderRecord apiOrderRecordPost = new ApiOrderRecord();
// apiOrderRecordPost.setStatus(103);
// apiOrderRecordPost.setOrderNo(highOrder.getOrderNo());
// apiOrderRecordPost.setSourceOrderNo(apiAmountRecord.getSourceOrderNo());
// apiOrderRecordPost.setCreateTime(new Date());
// apiOrderRecordPost.setMchId(apiMerchants.getMchId());
// apiOrderRecordPost.setOrderId(highOrder.getId());
// apiOrderRecordPost.setGoodsId(apiMerchants.getMchId());
// apiOrderRecordPost.setNotifyUrl(object.getString("notifyUrl"));
// apiOrderRecordPost.setUpdateTime(new Date());
//
// apiOrderRecordService.insertOrderRecord(apiOrderRecordPost);
}
private ApiAmountRecord apiMerchantAmount(HighOrder highOrder , ApiMerchants apiMerchants , JSONObject object) throws Exception {
// 插入金额记录
// 变更前金额
BigDecimal beforeAmount = apiMerchants.getAmounts();
// 计算金额
apiMerchants.setAmounts(apiMerchants.getAmounts().subtract(highOrder.getPayPrice()));
// 变更后金额
BigDecimal afterAmount = apiMerchants.getAmounts();
apiMerchantsService.updateApiMerchants(apiMerchants);
ApiAmountRecord apiAmountRecord = new ApiAmountRecord();
apiAmountRecord.setCreateTime(new Date());
apiAmountRecord.setUpdateTime(new Date());
apiAmountRecord.setMchId(apiMerchants.getMchId());
apiAmountRecord.setStatus(100);
apiAmountRecord.setAmount(highOrder.getPayPrice());
apiAmountRecord.setAfterAmount(afterAmount);
apiAmountRecord.setBeforeAmount(beforeAmount);
apiAmountRecord.setAmountType(2);
apiAmountRecord.setSourceType(object.getInteger("sourceType"));
apiAmountRecord.setSourceOrderNo(object.getString("sourceOrderNo"));
apiAmountRecord.setSourceId(apiMerchants.getId());
apiAmountRecord.setSourceContent(object.getString("content"));
apiAmountRecordService.insertAmountRecord(apiAmountRecord);
return apiAmountRecord;
}
}

@ -177,6 +177,11 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
return outRechargeOrderMapper.selectByExample(example);
}
@Override
public List<OutRechargeOrder> selectList() {
return outRechargeOrderMapper.selectList();
}
@Override
public OutRechargeOrder findByOrderId(Long orderId) {
return outRechargeOrderMapper.selectByPrimaryKey(orderId);
@ -606,6 +611,20 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
// 查询充值产品
OutRechargePriceModel outRechargePrice = outRechargePriceService.findById(outRechargeOrder.getGoodsId(), null);
// 查询是否存在充值中的订单
// 定义子订单请求map
Map<String, Object> childOrderMap102 = new HashMap<>();
// 组装查询子订单数据
childOrderMap102.put("parent_order_id", outRechargeOrder.getId());
childOrderMap102.put("status", 102);
// 查询子订单
List<OutRechargeChildOrder> childOrderList102 = outRechargeChildOrderService.getListRechargeChildOrder(childOrderMap102);
if (childOrderList102.size() > 0) {
return;
}
// 查询充值子订单列表
// 定义子订单请求map
Map<String, Object> childOrderMap = new HashMap<>();

@ -111,7 +111,7 @@ unionRsaKey=891f6775fba7f12cc23df7c75e02b39b891f6775fba7f12c
#url
#fileUrl=/home/project/hsg/filesystem/
fileUrl=/Volumes/work/
fileUrl=/Volumes/work/filesystem/
#wx
wxAppId=wx8d49e2f83025229d

@ -1,353 +0,0 @@
package com.v1.controller;
import com.alibaba.fastjson.JSONObject;
import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode;
import com.hai.common.utils.ResponseMsgUtil;
import com.hai.entity.*;
import com.hai.model.ResponseData;
import com.hai.service.*;
import com.v1.config.ToolConfig;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.collections4.MapUtils;
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.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @serviceName rechargeProductController.java
* @author Sum1Dream
* @version 1.0.0
* @Description // 充值产品接口
* @createTime 17:14 2022/6/9
**/
@Controller
@RequestMapping(value = "/rechargeProduct")
@Api(value = "充值产品接口")
public class RechargeProductController {
private static Logger log = LoggerFactory.getLogger(RechargeProductController.class);
@Resource
private ApiMerchantsService apiMerchantsService;
@Resource
private SecConfigService secConfigService;
@Resource
private OutRechargeOrderService outRechargeOrderService;
@Resource
private ApiOrderRecordService apiOrderRecordService;
@Resource
private ApiProductService apiProductService;
@Resource
private ApiOpenService apiOpenService;
@Resource
private ApiIpAddressService apiIpAddressService;
@RequestMapping(value = "/getRechargeProduct", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "获取充值产品")
public ResponseData getRechargeProduct(@RequestBody JSONObject object , HttpServletRequest request ) {
try {
String ip = "";
// 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for
if (request.getHeader("x-forwarded-for") == null) {
ip = request.getRemoteAddr();
} else {
ip = request.getHeader("x-forwarded-for");
}
if (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , ip)) {
log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!");
}
if (StringUtils.isBlank(object.getString("apiKey")) ||
StringUtils.isBlank(object.getString("timetable")) ||
StringUtils.isBlank(object.getString("merchId")) ||
StringUtils.isBlank(object.getString("sign")) ||
object.getInteger("rechargeType") == null
) {
log.error("getRechargeProduct error!", "请求参数校验失败!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR);
}
ApiMerchants apiMerchants = apiMerchantsService.findByMchId(object.getString("merchId"));
if (apiMerchants == null) {
log.error("getRechargeProduct error!", "错误商户,请联系管理人员!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_NOT_EXIST);
}
Map<String , Object> map = new HashMap<>();
map.put("timetable" , object.getString("timetable"));
map.put("apiKey" , object.getString("apiKey"));
map.put("merchId" , object.getString("merchId"));
map.put("rechargeType" , object.getString("rechargeType"));
if (!secConfigService.isSignVerify(map , object.getString("sign"))) {
log.error("getRechargeProduct error!", "签名校验失败!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.SIGN_VERIFY);
}
if (!ToolConfig.timetableCheck(15L , object.getLong("timetable"))) {
log.error("getRechargeProduct error!", "请求时间超过15分钟!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.TIME_OUT);
}
return ResponseMsgUtil.success(apiMerchantsService.getMerchProduct(apiMerchants.getId() , object.getInteger("rechargeType")));
} catch (Exception e) {
log.error("HighOpenApiController --> getRechargeProduct() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/checkAccountBalance", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "查询帐户余额")
public ResponseData checkAccountBalance(@RequestBody JSONObject object , HttpServletRequest request ) {
try {
String ip = "";
// 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for
if (request.getHeader("x-forwarded-for") == null) {
ip = request.getRemoteAddr();
} else {
ip = request.getHeader("x-forwarded-for");
}
if (!secConfigService.isConfig("IP_WHITE" , ip)) {
log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!");
}
if (StringUtils.isBlank(object.getString("apiKey")) ||
StringUtils.isBlank(object.getString("merchId")) ||
StringUtils.isBlank(object.getString("timetable")) ||
StringUtils.isBlank(object.getString("sign"))
) {
log.error("getRechargeProduct error!", "请求参数校验失败!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR);
}
ApiMerchants apiMerchants = apiMerchantsService.findByMchId(object.getString("merchId"));
if (apiMerchants == null) {
log.error("getRechargeProduct error!", "商户号错误!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_NOT_EXIST);
}
Map<String , Object> map = new HashMap<>();
map.put("apiKey" , object.getString("apiKey"));
map.put("timetable" , object.getString("timetable"));
map.put("merchId" , object.getString("merchId"));
if (!secConfigService.isSignVerify(map , object.getString("sign"))) {
log.error("getRechargeProduct error!", "签名校验失败!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.SIGN_VERIFY);
}
if (!ToolConfig.timetableCheck(15L , object.getLong("timetable"))) {
log.error("getRechargeProduct error!", "请求时间超过15分钟!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.TIME_OUT);
}
return ResponseMsgUtil.success(apiMerchants.getAmounts());
} catch (Exception e) {
log.error("HighOpenApiController --> getRechargeProduct() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/queryOrderResult", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "查询订单结果")
public ResponseData queryOrderResult(@RequestBody JSONObject object , HttpServletRequest request ) {
try {
String ip = "";
// 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for
if (request.getHeader("x-forwarded-for") == null) {
ip = request.getRemoteAddr();
} else {
ip = request.getHeader("x-forwarded-for");
}
if (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , ip)) {
log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!");
}
if (StringUtils.isBlank(object.getString("apiKey")) ||
StringUtils.isBlank(object.getString("timetable")) ||
StringUtils.isBlank(object.getString("merchId")) ||
StringUtils.isBlank(object.getString("sign")) ||
StringUtils.isBlank(object.getString("sourceOrderNo"))
) {
log.error("getRechargeProduct error!", "请求参数校验失败!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR);
}
ApiMerchants apiMerchants = apiMerchantsService.findByMchId(object.getString("merchId"));
if (apiMerchants == null) {
log.error("getRechargeProduct error!", "商户号错误!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_NOT_EXIST);
}
Map<String , Object> map = new HashMap<>();
map.put("apiKey" , object.getString("apiKey"));
map.put("timetable" , object.getString("timetable"));
map.put("merchId" , object.getString("merchId"));
map.put("sourceOrderNo" , object.getString("sourceOrderNo"));
if (!secConfigService.isSignVerify(map , object.getString("sign"))) {
log.error("getRechargeProduct error!", "签名校验失败!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.SIGN_VERIFY);
}
if (!ToolConfig.timetableCheck(15L , object.getLong("timetable"))) {
log.error("getRechargeProduct error!", "请求时间超过15分钟!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.TIME_OUT);
}
ApiOrderRecord apiOrderRecord = apiOrderRecordService.queryOrderResult(map);
OutRechargeOrder rechargeOrder = outRechargeOrderService.findByOrderNo(apiOrderRecord.getOrderNo());
JSONObject returnObject = new JSONObject();
returnObject.put("sourceOrderNo" , apiOrderRecord.getSourceOrderNo());
returnObject.put("callbackStatus" , apiOrderRecord.getStatus());
returnObject.put("apiConfigProductId" , apiOrderRecord.getGoodsId());
returnObject.put("type" , rechargeOrder.getType());
returnObject.put("operatorName" , rechargeOrder.getOperatorName());
returnObject.put("rechargeType" , rechargeOrder.getRechargeType());
returnObject.put("rechargeContent" , rechargeOrder.getRechargeContent());
returnObject.put("rechargePrice" , rechargeOrder.getRechargePrice());
returnObject.put("payPrice" , rechargeOrder.getPayPrice());
returnObject.put("createTimed" , rechargeOrder.getCreateTimed());
returnObject.put("payStatus" , rechargeOrder.getPayStatus());
returnObject.put("rechargeStatus" , rechargeOrder.getRechargeStatus());
return ResponseMsgUtil.success(returnObject);
} catch (Exception e) {
log.error("HighOpenApiController --> getRechargeProduct() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/createOrder", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "充值预下单")
public ResponseData createOrder(@RequestBody JSONObject object , HttpServletRequest request ) {
try {
String ip = "";
// 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for
if (request.getHeader("x-forwarded-for") == null) {
ip = request.getRemoteAddr();
} else {
ip = request.getHeader("x-forwarded-for");
}
if (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , ip)) {
log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!");
}
if (StringUtils.isBlank(object.getString("mobile")) ||
StringUtils.isBlank(object.getString("apiConfigProductId")) ||
StringUtils.isBlank(object.getString("apiKey")) ||
StringUtils.isBlank(object.getString("timetable")) ||
StringUtils.isBlank(object.getString("sourceOrderNo")) ||
StringUtils.isBlank(object.getString("notifyUrl")) ||
StringUtils.isBlank(object.getString("sign")) ||
StringUtils.isBlank(object.getString("merchId"))
) {
log.error("createOrder error!", "请求参数校验失败!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR);
}
ApiMerchants apiMerchants = apiMerchantsService.findByMchId(object.getString("merchId"));
if (apiMerchants == null) {
log.error("createOrder error!", "商户错误!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_NOT_EXIST);
}
Map<String, Object> productMap = new HashMap<>();
productMap.put("id" , object.getString("apiConfigProductId"));
productMap.put("merchantsId" , apiMerchants.getId());
ApiProductConfig apiProductConfig = apiProductService.findMchProduct(productMap);
if (apiProductConfig == null) {
log.error("createOrder error!", " 商品错误!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.PRODUCT_ERROR);
}
if (apiProductConfig.getStatus() == 102) {
log.error("createOrder error!", " 商品状态错误!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR , "商品状态错误");
}
Map<String , Object> map = new HashMap<>();
map.put("mobile" , object.getString("mobile"));
map.put("apiConfigProductId" , object.getString("apiConfigProductId"));
map.put("timetable" , object.getString("timetable"));
map.put("sourceOrderNo" , object.getString("sourceOrderNo"));
map.put("notifyUrl" , object.getString("notifyUrl"));
map.put("apiKey" , object.getString("apiKey"));
map.put("merchId" , object.getString("merchId"));
if (!secConfigService.isSignVerify(map, object.getString("sign"))) {
log.error("createOrder error!", "签名校验失败!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.SIGN_VERIFY);
}
if (!ToolConfig.timetableCheck(15L , object.getLong("timetable"))) {
log.error("getRechargeProduct error!", "请求时间超过15分钟!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.TIME_OUT);
}
if (!secConfigService.isConfig("PHONE_CONFIG" , object.getString("merchId"))) {
log.error("getAllCities error!", "当前帐户无权限查询!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_NOT_AUTHORIZED, "当前帐户无权限查询!");
}
apiOpenService.createOrder(object , apiMerchants , apiProductConfig);
return ResponseMsgUtil.success("下单成功");
} catch (Exception e) {
log.error("HighOpenApiController --> createOrder() error!", e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -1,545 +0,0 @@
package com.v1.controller;
import com.alibaba.fastjson.JSONArray;
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.*;
import com.hai.model.ResponseData;
import com.hai.service.*;
import com.v1.config.ToolConfig;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.HashMap;
import java.util.List;
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;
@Resource
private ApiIpAddressService apiIpAddressService;
@Resource
private ApiProductService apiProductService;
@Resource
private ApiOpenService apiOpenService;
@Resource
private ApiMemberProductService apiMemberProductService;
@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 (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);
}
if (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , ip)) {
log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!");
}
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<String , Object> map = new HashMap<>();
map.put("apiKey" , object.getString("apiKey"));
map.put("merchId" , object.getString("merchId"));
if (!secConfigService.isSignVerify(map , object.getString("sign"))) {
log.error("getRechargeProduct error!", "签名校验失败!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.SIGN_VERIFY);
}
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 (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , ip)) {
log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!");
}
if (StringUtils.isBlank(object.getString("apiKey")) ||
StringUtils.isBlank(object.getString("merchId")) ||
StringUtils.isBlank(object.getString("lat")) ||
StringUtils.isBlank(object.getString("lon")) ||
StringUtils.isBlank(object.getString("sign"))
) {
log.error("getRechargeProduct error!", "请求参数校验失败!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR);
}
ApiMerchants apiMerchants = apiMerchantsService.findByMchId(object.getString("merchId"));
if (apiMerchants == null) {
log.error("getRechargeProduct error!", "帐户号错误!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_NOT_EXIST);
}
if (!secConfigService.isConfig("STARBUCKS_CONFIG" , object.getString("merchId"))) {
log.error("getAllCities error!", "当前帐户无权限查询!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_NOT_AUTHORIZED, "当前帐户无权限查询!");
}
Map<String , Object> map = new HashMap<>();
map.put("apiKey" , object.getString("apiKey"));
map.put("merchId" , object.getString("merchId"));
map.put("lat" , object.getString("lat"));
map.put("lon" , object.getString("lon"));
if (!secConfigService.isSignVerify(map , object.getString("sign"))) {
log.error("getRechargeProduct error!", "签名校验失败!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.SIGN_VERIFY);
}
JSONObject jsonObject = QianZhuConfig.getStarbucksStore(object.getString("lat") , object.getString("lon"));
if (jsonObject.getBoolean("success")) {
return ResponseMsgUtil.success(jsonObject.getString("data"));
} else {
log.error("getRechargeProduct error!", "查询失败!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR , jsonObject.getString("message"));
}
} catch (Exception e) {
log.error("HighOpenApiController --> getRechargeProduct() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/getStarbucksProducts", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "查询星巴克商品")
public ResponseData getStarbucksProducts(@RequestBody JSONObject object , HttpServletRequest request ) {
try {
String ip = "";
// 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for
if (request.getHeader("x-forwarded-for") == null) {
ip = request.getRemoteAddr();
} else {
ip = request.getHeader("x-forwarded-for");
}
if (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , ip)) {
log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!");
}
if (StringUtils.isBlank(object.getString("apiKey")) ||
StringUtils.isBlank(object.getString("merchId")) ||
StringUtils.isBlank(object.getString("sign"))
) {
log.error("getRechargeProduct error!", "请求参数校验失败!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR);
}
ApiMerchants apiMerchants = apiMerchantsService.findByMchId(object.getString("merchId"));
if (apiMerchants == null) {
log.error("getRechargeProduct error!", "帐户号错误!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_NOT_EXIST);
}
if (!secConfigService.isConfig("STARBUCKS_CONFIG" , object.getString("merchId"))) {
log.error("getAllCities error!", "当前帐户无权限查询!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_NOT_AUTHORIZED, "当前帐户无权限查询!");
}
Map<String , Object> map = new HashMap<>();
map.put("apiKey" , object.getString("apiKey"));
map.put("merchId" , object.getString("merchId"));
if (!secConfigService.isSignVerify(map , object.getString("sign"))) {
log.error("getRechargeProduct error!", "签名校验失败!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.SIGN_VERIFY);
}
Map<String, Object> mapProduct = new HashMap<>();
List<ApiStarbucksProducts> list = apiProductService.getStarbucksProducts(mapProduct);
for (ApiStarbucksProducts starbucksProducts : list) {
if (starbucksProducts.getMarketGrandePrice().compareTo(new BigDecimal(1000)) > 0) {
starbucksProducts.setMarketGrandePrice(null);
}
if (starbucksProducts.getMarketTallPrice().compareTo(new BigDecimal(1000)) > 0) {
starbucksProducts.setMarketTallPrice(null);
}
if (starbucksProducts.getMarketVentiPrice().compareTo(new BigDecimal(1000)) > 0) {
starbucksProducts.setMarketVentiPrice(null);
}
starbucksProducts.setSalesTallPrice(starbucksProducts.getMarketTallPrice());
starbucksProducts.setSalesVentiPrice(starbucksProducts.getMarketVentiPrice());
starbucksProducts.setSalesGrandePrice(starbucksProducts.getMarketGrandePrice());
}
return ResponseMsgUtil.success(list);
} catch (Exception e) {
log.error("HighOpenApiController --> getRechargeProduct() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/getKfcStoresList", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "查询肯德基门店")
public ResponseData getKfcStoresList(@RequestBody JSONObject object , HttpServletRequest request ) {
try {
String ip = "";
// 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for
if (request.getHeader("x-forwarded-for") == null) {
ip = request.getRemoteAddr();
} else {
ip = request.getHeader("x-forwarded-for");
}
if (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , ip)) {
log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!");
}
if (StringUtils.isBlank(object.getString("apiKey")) ||
StringUtils.isBlank(object.getString("merchId")) ||
StringUtils.isBlank(object.getString("sign"))
) {
log.error("getRechargeProduct error!", "请求参数校验失败!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR);
}
ApiMerchants apiMerchants = apiMerchantsService.findByMchId(object.getString("merchId"));
if (apiMerchants == null) {
log.error("getRechargeProduct error!", "帐户号错误!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_NOT_EXIST);
}
if (!secConfigService.isConfig("KFC_CONFIG" , object.getString("merchId"))) {
log.error("getAllCities error!", "当前帐户无权限查询!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_NOT_AUTHORIZED, "当前帐户无权限查询!");
}
Map<String , Object> map = new HashMap<>();
map.put("apiKey" , object.getString("apiKey"));
map.put("merchId" , object.getString("merchId"));
if (!secConfigService.isSignVerify(map , object.getString("sign"))) {
log.error("getRechargeProduct error!", "签名校验失败!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.SIGN_VERIFY);
}
Map<String, Object> mapStores = new HashMap<>();
List<ApiKfcStores> list = apiProductService.getKfcStoresList(mapStores);
return ResponseMsgUtil.success(list);
} catch (Exception e) {
log.error("HighOpenApiController --> getRechargeProduct() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/kfcProductByStoreCode", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "根据门店编码查询KFC产品")
public ResponseData kfcProductByStoreCode(@RequestBody JSONObject object , HttpServletRequest request ) {
try {
String ip = "";
// 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for
if (request.getHeader("x-forwarded-for") == null) {
ip = request.getRemoteAddr();
} else {
ip = request.getHeader("x-forwarded-for");
}
if (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , ip)) {
log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!");
}
if (StringUtils.isBlank(object.getString("apiKey")) ||
StringUtils.isBlank(object.getString("storeCode")) ||
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<String , Object> map = new HashMap<>();
map.put("apiKey" , object.getString("apiKey"));
map.put("merchId" , object.getString("merchId"));
map.put("storeCode" , object.getString("storeCode"));
if (!secConfigService.isSignVerify(map , object.getString("sign"))) {
log.error("getRechargeProduct error!", "签名校验失败!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.SIGN_VERIFY);
}
JSONObject jsonObject = QianZhuConfig.listByStoreCode(object.getString("storeCode"));
JSONArray array = jsonObject.getJSONArray("data");
if (array == null) {
log.error("kfcProductByStoreCode error!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未查询到商品");
}
for (Object data : array) {
JSONObject dataObject = (JSONObject) data;
if (dataObject.getJSONArray("products") != null) {
for (Object products : dataObject.getJSONArray("products")) {
JSONObject productsObject = (JSONObject) products;
productsObject.put("taxOriginalPrice" , null);
productsObject.put("taxOriginalTotalPrice" , null);
productsObject.put("price" , null);
productsObject.put("taxPrice" , null);
if (productsObject.getJSONArray("specGroups") != null) {
for (Object specGroups : productsObject.getJSONArray("specGroups")) {
JSONObject specGroupsObject = (JSONObject) specGroups;
specGroupsObject.put("taxOriginalPrice" , null);
specGroupsObject.put("taxOriginalTotalPrice" , null);
specGroupsObject.put("price" , null);
specGroupsObject.put("taxPrice" , null);
}
}
}
}
}
return ResponseMsgUtil.success(array);
} catch (Exception e) {
log.error("HighOpenApiController --> getRechargeProduct() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/getMemberProducts", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "查询会员产品")
public ResponseData getMemberProducts(@RequestBody JSONObject object , HttpServletRequest request ) {
try {
String ip = "";
// 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for
if (request.getHeader("x-forwarded-for") == null) {
ip = request.getRemoteAddr();
} else {
ip = request.getHeader("x-forwarded-for");
}
if (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , ip)) {
log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!");
}
if (StringUtils.isBlank(object.getString("apiKey")) ||
StringUtils.isBlank(object.getString("merchId")) ||
StringUtils.isBlank(object.getString("sign"))
) {
log.error("getRechargeProduct error!", "请求参数校验失败!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR);
}
ApiMerchants apiMerchants = apiMerchantsService.findByMchId(object.getString("merchId"));
if (apiMerchants == null) {
log.error("getRechargeProduct error!", "帐户号错误!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_NOT_EXIST);
}
if (!secConfigService.isConfig("MEMBER_RECHARGE_CONFIG" , object.getString("merchId"))) {
log.error("getAllCities error!", "当前帐户无权限查询!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_NOT_AUTHORIZED, "当前帐户无权限查询!");
}
Map<String , Object> map = new HashMap<>();
map.put("apiKey" , object.getString("apiKey"));
map.put("merchId" , object.getString("merchId"));
if (!secConfigService.isSignVerify(map , object.getString("sign"))) {
log.error("getRechargeProduct error!", "签名校验失败!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.SIGN_VERIFY);
}
Map<String, Object> mapProduct = new HashMap<>();
List<ApiMemberProduct> list = apiMemberProductService.getListApiMemberProduct(mapProduct);
for (ApiMemberProduct apiMemberProduct : list) {
apiMemberProduct.setCostPrice(null);
}
return ResponseMsgUtil.success(list);
} catch (Exception e) {
log.error("HighOpenApiController --> getRechargeProduct() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/createOrder", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "充值预下单")
public ResponseData createOrder(@RequestBody JSONObject object , HttpServletRequest request ) {
try {
String ip = "";
// 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for
if (request.getHeader("x-forwarded-for") == null) {
ip = request.getRemoteAddr();
} else {
ip = request.getHeader("x-forwarded-for");
}
if (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , ip)) {
log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!");
}
if (StringUtils.isBlank(object.getString("customerMobile")) ||
StringUtils.isBlank(object.getString("productType")) ||
StringUtils.isBlank(object.getString("apiKey")) ||
StringUtils.isBlank(object.getString("timetable")) ||
StringUtils.isBlank(object.getString("sourceOrderNo")) ||
StringUtils.isBlank(object.getString("notifyUrl")) ||
StringUtils.isBlank(object.getString("sign")) ||
StringUtils.isBlank(object.getString("merchId"))
) {
log.error("createOrder error!", "请求参数校验失败!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR);
}
ApiMerchants apiMerchants = apiMerchantsService.findByMchId(object.getString("merchId"));
if (apiMerchants == null) {
log.error("createOrder error!", "商户错误!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_NOT_EXIST);
}
Map<String , Object> map = new HashMap<>();
map.put("customerMobile" , object.getString("customerMobile"));
map.put("productType" , object.getString("productType"));
map.put("timetable" , object.getString("timetable"));
map.put("sourceOrderNo" , object.getString("sourceOrderNo"));
map.put("notifyUrl" , object.getString("notifyUrl"));
map.put("apiKey" , object.getString("apiKey"));
map.put("merchId" , object.getString("merchId"));
if (!secConfigService.isSignVerify(map, object.getString("sign"))) {
log.error("createOrder error!", "签名校验失败!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.SIGN_VERIFY);
}
if (!ToolConfig.timetableCheck(15L , object.getLong("timetable"))) {
log.error("getRechargeProduct error!", "请求时间超过15分钟!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.TIME_OUT);
}
apiOpenService.createOrder(object , apiMerchants);
return ResponseMsgUtil.success("下单成功");
} catch (Exception e) {
log.error("HighOpenApiController --> createOrder() error!", e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -18,6 +18,7 @@ import com.hai.common.security.AESEncodeUtil;
import com.hai.common.utils.*;
import com.hai.config.CommonSysConst;
import com.hai.config.WeChatQrcodeUtils;
import com.hai.config.WxMsgConfig;
import com.hai.entity.HighUser;
import com.hai.enum_type.WxQrCodeTypeEnum;
import com.hai.model.HighMerchantStoreModel;
@ -58,7 +59,7 @@ import static org.apache.catalina.manager.Constants.CHARSET;
@Api(value = "微信")
public class WxMsgController {
private static Logger log = LoggerFactory.getLogger(ThirdPartyController.class);
private static Logger log = LoggerFactory.getLogger(WxMsgController.class);
@Autowired
private WeChatQrcodeUtils weChatQrcodeUtils;
@ -132,6 +133,15 @@ public class WxMsgController {
JSONObject object = weChatQrcodeUtils.paramPars(eventKey);
// type = 1 推广扫码
if (Objects.equals(object.getString("qrscene_type"), WxQrCodeTypeEnum.type1.getType()) || Objects.equals(object.getString("type"), WxQrCodeTypeEnum.type1.getType())) {
// linkContent = "<a " +
// "data-miniprogram-appid='wx8d49e2f83025229d'" +
// "data-miniprogram-path='/pages/qianZhuPay/union-pay/union-pay" +
// "href='https://mp.weixin.qq.com/s/qKUny68yCU4_6jBdNb1OVg' " +
// "data-miniprogram-type='text'>打开小程序</a>";
linkContent ="<a data-miniprogram-appid='wx8d49e2f83025229d' data-miniprogram-path='/pages/tabBar/user/user' href='https://mp.weixin.qq.com/s/qKUny68yCU4_6jBdNb1OVg'>扫码领取</a>\n\n";
System.out.println(linkContent);
// todo 推广扫码
}
// type = 2 在线加油门店扫码
@ -153,7 +163,7 @@ public class WxMsgController {
if ( Objects.equals(object.getString("code"), "1")) {
linkContent =
"加油优惠选我们,你的出行不再忧愁\uD83D\uDC97\n\n"
+ "<a href='https://mp.weixin.qq.com/s/qKUny68yCU4_6jBdNb1OVg'>查看中石油操作流程</a>\n\n"
+ "<a href='https://mp.weixin.qq.com/s/Il-r_ZfTZOQDyQWgfnck1A'>查看中石油操作流程</a>\n\n"
+ "走得更远,看得更美的风景,加油添生活![太阳]\n\n"
+ "好车要好油,优惠更加牛![發]\n\n";
}
@ -161,7 +171,7 @@ public class WxMsgController {
if (Objects.equals(object.getString("code"), "2")) {
linkContent =
"加满好油,一路畅游!✨✨\n\n"
+ "<a href='https://mp.weixin.qq.com/s/qKUny68yCU4_6jBdNb1OVg'>查看中石化操作流程</a>\n\n"
+ "<a href='https://mp.weixin.qq.com/s/4kj9XV-K_s88uji3ZrXqgg'>查看中石化操作流程</a>\n\n"
+ "用心为您着想,诚意为您服务。\uD83C\uDF39\n\n"
+ "油客来自五湖四海,在这里祝您一路顺风。\n\n";
@ -170,27 +180,50 @@ public class WxMsgController {
}
// 4:支付码牌扫码
if (Objects.equals(object.getString("qrscene_type"), WxQrCodeTypeEnum.type4.getType()) || Objects.equals(object.getString("type"), WxQrCodeTypeEnum.type4.getType())){
// todo 支付扫码
// 支付码码牌上的二维码
if (Objects.equals(object.getString("codeTyp"), "PAYMENT_CODE")) {
linkContent =
"支付分享,享受更高优惠[礼物]\n\n"
+ "<a data-miniprogram-appid='wx8d49e2f83025229d' data-miniprogram-path=\"/pages/qianZhuPay/union-pay/union-pay\" " +
"href='" +
CommonSysConst.getSysConfig().getHsgDomainName()
+ "/hsgH5?accountId=0000012&key=&code="
+ object.getString("code")
+
" data-miniprogram-type=\"text\"></a>\n\n";
}
// 支付成功生成的二维码
if (Objects.equals(object.getString("codeTyp"), "PAYMENT_SUCCESS")) {
linkContent =
"支付分享,享受更高优惠[礼物]\n\n"
+ "<a href='"
// + "https://hsgcs.dctpay.com"
+ CommonSysConst.getSysConfig().getHsgDomainName()
+ "/hsgH5?accountId=0000012&key=&code="
+ object.getString("code")
+ "'>分享好友</a>\n\n";
}
}
// 5:扫码贵州中石化优惠券二维码
if (Objects.equals(object.getString("qrscene_type"), WxQrCodeTypeEnum.type5.getType()) || Objects.equals(object.getString("type"), WxQrCodeTypeEnum.type5.getType())){
mapQrCode.put("type", object.getString("encryptType"));
// 二维码参数
mapQrCode.put("id", object.getString("code"));
log.info("map参数:" + mapQrCode);
// 商户门店
linkContent =
"山高水远,相伴致远[爱心][爱心]\n\n"
+ "<a href='"
+ "https://hsgcs.dctpay.com"
// + CommonSysConst.getSysConfig().getHsgDomainName()
// + "https://hsgcs.dctpay.com"
+ CommonSysConst.getSysConfig().getHsgDomainName()
+ "/hsgH5?accountId=0000011&key=&code="
+ Base64Util.encode(AESEncodeUtil.aesEncrypt(JSON.toJSONString(mapQrCode)))
+ "'>领取中石化加油券</a>\n\n"
+ "您追求实惠的折扣,我们追求高超的品质\uD83D\uDD16\n\n"
+ "迎南来北往宾朋尊驾,[福]\n\n"
+ "送平安顺遂诚意祝福![福]\n\n";
log.info("地址参数:" + linkContent);
}
// 6:扫码重庆中石油优惠券二维码
if (Objects.equals(object.getString("qrscene_type"), WxQrCodeTypeEnum.type6.getType()) || Objects.equals(object.getString("type"), WxQrCodeTypeEnum.type6.getType())){
@ -202,16 +235,16 @@ public class WxMsgController {
linkContent =
"加好油,添好运,我们更适意[礼物]\n\n"
+ "<a href='"
+ "https://hsgcs.dctpay.com"
// + CommonSysConst.getSysConfig().getHsgDomainName()
// + "https://hsgcs.dctpay.com"
+ CommonSysConst.getSysConfig().getHsgDomainName()
+ "/hsgH5?accountId=0000011&key=&code="
+ Base64Util.encode(AESEncodeUtil.aesEncrypt(JSON.toJSONString(mapQrCode)))
+ "'>领取中石油加油券</a>\n\n"
+ "致力于质量与福利,赢得客户心。\n\n"
+ "一路精彩,“油”我相伴!\uD83C\uDF1F\n\n";
log.info("地址参数:" + linkContent);
}
} else {
}
else {
linkContent = "<a href='" + CommonSysConst.getSysConfig().getHsgDomainName() + "/hsgH5'>点击查看更多优惠</a>\n\n";
}
@ -268,25 +301,13 @@ public class WxMsgController {
}
@RequestMapping(value = "/getWxToken", method = RequestMethod.POST)
@RequestMapping(value = "/getWxToken", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "获取微信token")
public ResponseData getWxToken() {
try {
Map<String, Object> params = new HashMap<>();
params.put("appid", SysConst.getSysConfig().getWxH5AppId());
params.put("secret", SysConst.getSysConfig().getWxH5AppSecret());
params.put("grant_type", "client_credential");
JSONObject accessTokenObject = HttpsUtils.doGet("https://api.weixin.qq.com/cgi-bin/token", params);
if (accessTokenObject == null) {
log.error("getH5UserInfo error!", "获取微信access_token失败" );
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "获取微信access_token失败");
}
return ResponseMsgUtil.success(accessTokenObject);
return ResponseMsgUtil.success(weChatQrcodeUtils.getWxToken());
} catch (Exception e) {
return ResponseMsgUtil.exception(e);
@ -368,17 +389,9 @@ public class WxMsgController {
public ResponseData verifyWx(@RequestParam(value = "url", required = true) String url) {
try {
// 获取access_token
Map<String, Object> params = new HashMap<>();
params.put("appid", SysConst.getSysConfig().getWxH5AppId());
params.put("secret", SysConst.getSysConfig().getWxH5AppSecret());
params.put("grant_type", "client_credential");
JSONObject accessTokenObject = HttpsUtils.doGet("https://api.weixin.qq.com/cgi-bin/token", params);
// 获取ticket
Map<String, Object> ticketParams = new HashMap<>();
ticketParams.put("access_token", accessTokenObject.getString("access_token"));
ticketParams.put("access_token", weChatQrcodeUtils.getWxToken());
ticketParams.put("type", "jsapi");
JSONObject jsapiTicket = HttpsUtils.doGet("https://api.weixin.qq.com/cgi-bin/ticket/getticket", ticketParams);
// 拼接签名
@ -408,17 +421,10 @@ public class WxMsgController {
try {
// 获取access_token
Map<String, Object> params = new HashMap<>();
params.put("appid", SysConst.getSysConfig().getWxAppId());
params.put("secret", SysConst.getSysConfig().getWxAppSecret());
params.put("grant_type", "client_credential");
JSONObject accessTokenObject = HttpsUtils.doGet("https://api.weixin.qq.com/cgi-bin/token", params);
JSONObject postObject = new JSONObject();
postObject.put("expire_type" ,1);
postObject.put("expire_interval" ,30);
JSONObject object = HttpsUtils.doPost("https://api.weixin.qq.com/wxa/generate_urllink?access_token=" + accessTokenObject.getString("access_token"), postObject);
JSONObject object = HttpsUtils.doPost("https://api.weixin.qq.com/wxa/generate_urllink?access_token=" + weChatQrcodeUtils.getWxToken(), postObject);
return ResponseMsgUtil.success(object);
} catch (Exception e) {
return null;
@ -454,30 +460,4 @@ public class WxMsgController {
// }
@RequestMapping(value = "/createMenu", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "创建菜单")
public ResponseData createMenu(@RequestBody JSONObject object) {
try {
Map<String, Object> params = new HashMap<>();
params.put("appid", SysConst.getSysConfig().getWxH5AppId());
params.put("secret", SysConst.getSysConfig().getWxH5AppSecret());
params.put("grant_type", "client_credential");
JSONObject accessTokenObject = HttpsUtils.doGet("https://api.weixin.qq.com/cgi-bin/token", params);
if (accessTokenObject == null) {
log.error("getH5UserInfo error!", "获取微信access_token失败" );
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "获取微信access_token失败");
}
JSONObject jsonObject = HttpsUtils.doPost("https://api.weixin.qq.com/cgi-bin/menu/create?access_token=" + accessTokenObject.getString("access_token"), object);
return ResponseMsgUtil.success(jsonObject);
} catch (Exception e) {
return ResponseMsgUtil.exception(e);
}
}
}

@ -8,10 +8,8 @@ import com.hai.common.utils.ResponseMsgUtil;
import com.hai.config.QianZhuConfig;
import com.hai.entity.ApiMerchants;
import com.hai.model.ResponseData;
import com.hai.order.type.OrderProductType;
import com.hai.service.*;
import com.v1.config.ToolConfig;
import com.v1.controller.RechargeProductController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
@ -32,7 +30,7 @@ import java.util.Map;
@RequestMapping(value = "/apiMerchants")
@Api(value = "商户业务")
public class ApiMerchantsController {
private static Logger log = LoggerFactory.getLogger(RechargeProductController.class);
private static Logger log = LoggerFactory.getLogger(ApiMerchantsController.class);
@Resource
private ApiMerchantsService apiMerchantsService;

@ -0,0 +1,218 @@
package com.v1.controller.business;
import com.alibaba.fastjson.JSONArray;
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.ApiKfcStores;
import com.hai.entity.ApiMchProduct;
import com.hai.entity.ApiMerchants;
import com.hai.model.ResponseData;
import com.hai.openApi.config.PriceComputeConfig;
import com.hai.openApi.service.ApiMchProductService;
import com.hai.order.type.OrderProductType;
import com.hai.service.ApiIpAddressService;
import com.hai.service.ApiMerchantsService;
import com.hai.service.ApiProductService;
import com.hai.service.SecConfigService;
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.List;
import java.util.Map;
@Controller
@RequestMapping(value = "/kfc")
@Api(value = "kfc业务")
public class KfcController {
private static Logger log = LoggerFactory.getLogger(KfcController.class);
@Resource
private ApiMerchantsService apiMerchantsService;
@Resource
private SecConfigService secConfigService;
@Resource
private ApiIpAddressService apiIpAddressService;
@Resource
private ApiProductService apiProductService;
@Resource
private PriceComputeConfig priceComputeConfig;
@Resource
private ApiMchProductService apiMchProductService;
@RequestMapping(value = "/kfcStoresList", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "查询肯德基门店")
public ResponseData kfcStoresList(@RequestBody JSONObject object , HttpServletRequest request ) {
try {
String ip = "";
// 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for
if (request.getHeader("x-forwarded-for") == null) {
ip = request.getRemoteAddr();
} else {
ip = request.getHeader("x-forwarded-for");
}
if (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , ip)) {
log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!");
}
if (StringUtils.isBlank(object.getString("apiKey")) ||
StringUtils.isBlank(object.getString("merchId")) ||
StringUtils.isBlank(object.getString("sign"))
) {
log.error("getRechargeProduct error!", "请求参数校验失败!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR);
}
ApiMerchants apiMerchants = apiMerchantsService.findByMchId(object.getString("merchId"));
if (apiMerchants == null) {
log.error("getRechargeProduct error!", "帐户号错误!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_NOT_EXIST);
}
if (!secConfigService.isConfig(OrderProductType.PRODUCT_TYPE2.getApiCode(), object.getString("merchId"))) {
log.error("getAllCities error!", "当前帐户无权限查询!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_NOT_AUTHORIZED, "");
}
Map<String , Object> map = new HashMap<>();
map.put("apiKey" , object.getString("apiKey"));
map.put("merchId" , object.getString("merchId"));
if (!secConfigService.isSignVerify(map , object.getString("sign"))) {
log.error("getRechargeProduct error!", "签名校验失败!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.SIGN_VERIFY);
}
Map<String, Object> mapStores = new HashMap<>();
List<ApiKfcStores> list = apiProductService.getKfcStoresList(mapStores);
return ResponseMsgUtil.success(list);
} catch (Exception e) {
log.error("HighOpenApiController --> getRechargeProduct() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/kfcProductByStoreCode", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "根据门店编码查询KFC产品")
public ResponseData kfcProductByStoreCode(@RequestBody JSONObject object , HttpServletRequest request ) {
try {
String ip = "";
// 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for
if (request.getHeader("x-forwarded-for") == null) {
ip = request.getRemoteAddr();
} else {
ip = request.getHeader("x-forwarded-for");
}
if (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , ip)) {
log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!");
}
if (StringUtils.isBlank(object.getString("apiKey")) ||
StringUtils.isBlank(object.getString("storeCode")) ||
StringUtils.isBlank(object.getString("merchId")) ||
StringUtils.isBlank(object.getString("sign"))
) {
log.error("getRechargeProduct error!", "请求参数校验失败!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR);
}
ApiMerchants apiMerchants = apiMerchantsService.findByMchId(object.getString("merchId"));
if (apiMerchants == null) {
log.error("getRechargeProduct error!", "帐户号错误!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_NOT_EXIST);
}
if (!secConfigService.isConfig(OrderProductType.PRODUCT_TYPE2.getApiCode(), object.getString("merchId"))) {
log.error("getAllCities error!", "当前帐户无权限查询!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_NOT_AUTHORIZED, "");
}
Map<String , Object> map = new HashMap<>();
map.put("apiKey" , object.getString("apiKey"));
map.put("merchId" , object.getString("merchId"));
map.put("storeCode" , object.getString("storeCode"));
if (!secConfigService.isSignVerify(map , object.getString("sign"))) {
log.error("getRechargeProduct error!", "签名校验失败!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.SIGN_VERIFY);
}
JSONObject jsonObject = QianZhuConfig.listByStoreCode(object.getString("storeCode"));
JSONArray array = jsonObject.getJSONArray("data");
if (array == null) {
log.error("kfcProductByStoreCode error!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未查询到商品");
}
Map<String, Object> mapProduct = new HashMap<>();
mapProduct.put("mchId" , object.getString("merchId"));
mapProduct.put("productType" , OrderProductType.PRODUCT_TYPE2.getNumber());
ApiMchProduct apiMchProducts = apiMchProductService.findByMap(mapProduct);
for (Object data : array) {
JSONObject dataObject = (JSONObject) data;
if (dataObject.getJSONArray("products") != null) {
for (Object products : dataObject.getJSONArray("products")) {
JSONObject productsObject = (JSONObject) products;
productsObject.put("taxOriginalPrice" , null);
productsObject.put("taxOriginalTotalPrice" , null);
productsObject.put("price" , priceComputeConfig.computationPriceCost(apiMchProducts.getDiscount() , productsObject.getBigDecimal("originalPrice") , productsObject.getBigDecimal("price")));
productsObject.put("taxPrice" , null);
if (productsObject.getJSONArray("specGroups") != null) {
for (Object specGroups : productsObject.getJSONArray("specGroups")) {
JSONObject specGroupsObject = (JSONObject) specGroups;
specGroupsObject.put("taxOriginalPrice" , null);
specGroupsObject.put("taxOriginalTotalPrice" , null);
specGroupsObject.put("price" , priceComputeConfig.computationPriceCost(apiMchProducts.getDiscount() , specGroupsObject.getBigDecimal("originalPrice") , specGroupsObject.getBigDecimal("price")));
specGroupsObject.put("taxPrice" , null);
}
}
}
}
}
return ResponseMsgUtil.success(array);
} catch (Exception e) {
log.error("HighOpenApiController --> getRechargeProduct() error!", e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -0,0 +1,131 @@
package com.v1.controller.business;
import com.alibaba.fastjson.JSONObject;
import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode;
import com.hai.common.utils.ResponseMsgUtil;
import com.hai.entity.ApiMchProduct;
import com.hai.entity.ApiMemberProduct;
import com.hai.entity.ApiMerchants;
import com.hai.model.ResponseData;
import com.hai.openApi.config.PriceComputeConfig;
import com.hai.openApi.service.ApiMchProductService;
import com.hai.order.type.OrderProductType;
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.List;
import java.util.Map;
@Controller
@RequestMapping(value = "/memberRecharge")
@Api(value = "会员充值业务")
public class MemberProductsController {
private static Logger log = LoggerFactory.getLogger(MemberProductsController.class);
@Resource
private ApiMerchantsService apiMerchantsService;
@Resource
private SecConfigService secConfigService;
@Resource
private ApiIpAddressService apiIpAddressService;
@Resource
private ApiProductService apiProductService;
@Resource
private PriceComputeConfig priceComputeConfig;
@Resource
private ApiMchProductService apiMchProductService;
@Resource
private ApiMemberProductService apiMemberProductService;
@RequestMapping(value = "/memberProducts", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "查询会员产品")
public ResponseData memberProducts(@RequestBody JSONObject object , HttpServletRequest request ) {
try {
String ip = "";
// 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for
if (request.getHeader("x-forwarded-for") == null) {
ip = request.getRemoteAddr();
} else {
ip = request.getHeader("x-forwarded-for");
}
if (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , ip)) {
log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!");
}
if (StringUtils.isBlank(object.getString("apiKey")) ||
StringUtils.isBlank(object.getString("merchId")) ||
StringUtils.isBlank(object.getString("sign"))
) {
log.error("getRechargeProduct error!", "请求参数校验失败!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR);
}
ApiMerchants apiMerchants = apiMerchantsService.findByMchId(object.getString("merchId"));
if (apiMerchants == null) {
log.error("getRechargeProduct error!", "帐户号错误!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_NOT_EXIST);
}
if (!secConfigService.isConfig(OrderProductType.PRODUCT_TYPE3.getApiCode(), object.getString("merchId"))) {
log.error("getAllCities error!", "当前帐户无权限查询!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_NOT_AUTHORIZED, "");
}
Map<String , Object> map = new HashMap<>();
map.put("apiKey" , object.getString("apiKey"));
map.put("merchId" , object.getString("merchId"));
if (!secConfigService.isSignVerify(map , object.getString("sign"))) {
log.error("getRechargeProduct error!", "签名校验失败!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.SIGN_VERIFY);
}
List<ApiMemberProduct> list = apiMemberProductService.getListApiMemberProduct(new HashMap<>());
Map<String, Object> mapProduct = new HashMap<>();
mapProduct.put("mchId" , object.getString("merchId"));
mapProduct.put("productType" , OrderProductType.PRODUCT_TYPE3.getNumber());
ApiMchProduct apiMchProducts = apiMchProductService.findByMap(mapProduct);
for (ApiMemberProduct apiMemberProduct : list) {
apiMemberProduct.setCostPrice(priceComputeConfig.computationPriceCost(apiMchProducts.getDiscount() , apiMemberProduct.getPrice() , apiMemberProduct.getCostPrice()));
}
return ResponseMsgUtil.success(list);
} catch (Exception e) {
log.error("HighOpenApiController --> getRechargeProduct() error!", e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -10,8 +10,6 @@ import com.hai.model.ResponseData;
import com.hai.openApi.service.ApiMobileRechargeProductService;
import com.hai.order.type.OrderProductType;
import com.hai.service.*;
import com.v1.config.ToolConfig;
import com.v1.controller.RechargeProductController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
@ -33,7 +31,7 @@ import java.util.Map;
@Api(value = "话费充值业务")
public class MobileRechargeController {
private static Logger log = LoggerFactory.getLogger(RechargeProductController.class);
private static Logger log = LoggerFactory.getLogger(MobileRechargeController.class);
@Resource
private ApiMerchantsService apiMerchantsService;

@ -6,12 +6,14 @@ 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.ApiMchProduct;
import com.hai.entity.ApiMerchants;
import com.hai.entity.ApiStarbucksProducts;
import com.hai.model.ResponseData;
import com.hai.openApi.config.PriceComputeConfig;
import com.hai.openApi.service.ApiMchProductService;
import com.hai.order.type.OrderProductType;
import com.hai.service.*;
import com.v1.controller.ThirdPartyController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
@ -36,7 +38,7 @@ import java.util.Map;
public class StarbucksController {
private static Logger log = LoggerFactory.getLogger(ThirdPartyController.class);
private static Logger log = LoggerFactory.getLogger(StarbucksController.class);
@Resource
private ApiMerchantsService apiMerchantsService;
@ -50,6 +52,12 @@ public class StarbucksController {
@Resource
private ApiProductService apiProductService;
@Resource
private PriceComputeConfig priceComputeConfig;
@Resource
private ApiMchProductService apiMchProductService;
@RequestMapping(value = "/starbucksStore", method = RequestMethod.POST)
@ResponseBody
@ -118,10 +126,10 @@ public class StarbucksController {
}
}
@RequestMapping(value = "/getStarbucksProducts", method = RequestMethod.POST)
@RequestMapping(value = "/starbucksProducts", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "查询星巴克商品")
public ResponseData getStarbucksProducts(@RequestBody JSONObject object , HttpServletRequest request ) {
public ResponseData starbucksProducts(@RequestBody JSONObject object , HttpServletRequest request ) {
try {
String ip = "";
@ -167,22 +175,37 @@ public class StarbucksController {
}
Map<String, Object> mapProduct = new HashMap<>();
mapProduct.put("mchId" , object.getString("merchId"));
mapProduct.put("productType" , OrderProductType.PRODUCT_TYPE1.getNumber());
List<ApiStarbucksProducts> list = apiProductService.getStarbucksProducts(mapProduct);
ApiMchProduct apiMchProducts = apiMchProductService.findByMap(mapProduct);
List<ApiStarbucksProducts> list = apiProductService.getStarbucksProducts(new HashMap<>());
for (ApiStarbucksProducts starbucksProducts : list) {
if (starbucksProducts.getMarketGrandePrice().compareTo(new BigDecimal(1000)) > 0) {
starbucksProducts.setMarketGrandePrice(null);
}
// 中杯
if (starbucksProducts.getMarketTallPrice().compareTo(new BigDecimal(1000)) > 0) {
starbucksProducts.setMarketTallPrice(null);
starbucksProducts.setSalesTallPrice(null);
} else {
starbucksProducts.setSalesTallPrice(priceComputeConfig.computationPriceCost(apiMchProducts.getDiscount() , starbucksProducts.getMarketTallPrice() , starbucksProducts.getSalesTallPrice()));
}
// 大杯
if (starbucksProducts.getMarketGrandePrice().compareTo(new BigDecimal(1000)) > 0) {
starbucksProducts.setMarketGrandePrice(null);
starbucksProducts.setSalesGrandePrice(null);
}else {
starbucksProducts.setSalesGrandePrice(priceComputeConfig.computationPriceCost(apiMchProducts.getDiscount() , starbucksProducts.getMarketGrandePrice() , starbucksProducts.getSalesGrandePrice()));
}
// 超大杯
if (starbucksProducts.getMarketVentiPrice().compareTo(new BigDecimal(1000)) > 0) {
starbucksProducts.setMarketVentiPrice(null);
starbucksProducts.setSalesVentiPrice(null);
} else {
starbucksProducts.setSalesVentiPrice(priceComputeConfig.computationPriceCost(apiMchProducts.getDiscount() , starbucksProducts.getMarketVentiPrice() , starbucksProducts.getSalesVentiPrice()));
}
starbucksProducts.setSalesTallPrice(starbucksProducts.getMarketTallPrice());
starbucksProducts.setSalesVentiPrice(starbucksProducts.getMarketVentiPrice());
starbucksProducts.setSalesGrandePrice(starbucksProducts.getMarketGrandePrice());
}
return ResponseMsgUtil.success(list);

@ -34,7 +34,7 @@ import java.util.Map;
@Api(value = "订单业务")
public class orderController {
private static Logger log = LoggerFactory.getLogger(RechargeProductController.class);
private static Logger log = LoggerFactory.getLogger(orderController.class);
@Resource
private ApiMerchantsService apiMerchantsService;
@ -124,6 +124,15 @@ public class orderController {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未填写加油信息;加油金额、油号、抢号");
}
}
if (object.getInteger("productType").equals(OrderProductType.PRODUCT_TYPE9.getNumber()) || object.getInteger("productType").equals(OrderProductType.PRODUCT_TYPE3.getNumber())) {
JSONObject dataObject = JSONObject.parseObject(object.getString("content"));
if (StringUtils.isBlank(dataObject.getString("productId"))
|| StringUtils.isBlank(dataObject.getString("mobile"))
) {
log.error("OrderController -> create() error!","");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未填写产品id,充值号码");
}
}
return ResponseMsgUtil.success(orderService.createOrder(object));

@ -4,7 +4,7 @@ server:
context-path: /v1
#配置是否为debug模式,debug模式下,不开启权限校验
debug: true
debug: false
#datasource数据源设置
spring:
@ -29,7 +29,7 @@ spring:
maxOpenPreparedStatements: 20
redis:
database: 0
host: 139.9.154.68
host: 127.0.0.1
port: 36379
password: HF123456.Redis
timeout: 1000
@ -42,36 +42,41 @@ spring:
#MQTT配置信息
mqtt:
#MQTT服务地址
url: ws://139.9.154.68:8083/mqtt
url: ws://122.9.135.148:8083/mqtt
#用户名
username: printer_provider
#密码
password: 123654
password: abcd123!
#客户端id(不能重复)
# client:
# id: provider-id
#MQTT默认的消息推送主题,实际可在调用接口是指定
#MQTT默认的消息推送主题,实际可在调用接口是指定
# default:
# topic: topic
#thymelea模板配置
thymeleaf:
prefix: classpath:/templates/
suffix: .html
mode: HTML5
encoding: UTF-8
#热部署文件,页面不产生缓存,及时更新
cache: false
#配置日期返回至前台为时间戳
jackson:
serialization:
write-dates-as-timestamps: true
rocketmq:
name-server: 139.9.154.68:9876
name-server: 122.9.135.148:9876
producer:
#必须指定group
group: default-group
#配置日期返回至前台为时间戳
jackson:
serialization:
write-dates-as-timestamps: true
mybatis:
mapperLocations:
- classpath*:sqlmap*/*.xml
type-aliases-package:
org.springboot.sample.entity
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
#开启MyBatis的二级缓存
cache-enabled: true
jetcache:
statIntervalMinutes: 15
@ -83,7 +88,7 @@ jetcache:
remote:
default:
type: redis
host: 139.9.154.68
host: 127.0.0.1
port: 36379
password: HF123456.Redis
keyConvertor: fastjson

Loading…
Cancel
Save