优化话费定时任务代码

dev-discount
袁野 2 years ago
parent f70899b16a
commit 03f9ca62a0
  1. 8
      hai-bweb/src/main/java/com/bweb/controller/ApiMchProduct/ApiMchProductController.java
  2. 2
      hai-bweb/src/main/java/com/bweb/controller/ApiMerchantsController.java
  3. 12
      hai-bweb/src/main/java/com/bweb/controller/ApiProductController.java
  4. 2
      hai-bweb/src/main/java/com/bweb/controller/HighTestController.java
  5. 21
      hai-bweb/src/main/java/com/bweb/controller/LoginController.java
  6. 5
      hai-bweb/src/main/java/com/bweb/controller/OutRechargePriceController.java
  7. 5
      hai-order/src/main/java/com/web/controller/OrderController.java
  8. 4
      hai-order/src/main/java/com/web/controller/notify/MobileRechargeNotifyController.java
  9. 2
      hai-service/src/main/java/com/hai/dao/OutRechargePriceMapperExt.java
  10. 12
      hai-service/src/main/java/com/hai/entity/ApiAmountRecord.java
  11. 62
      hai-service/src/main/java/com/hai/openApi/config/PriceComputeConfig.java
  12. 2
      hai-service/src/main/java/com/hai/openApi/service/ApiMchProductService.java
  13. 31
      hai-service/src/main/java/com/hai/openApi/service/ApiOrderCreateHandleService.java
  14. 60
      hai-service/src/main/java/com/hai/openApi/service/ApiOrderService.java
  15. 36
      hai-service/src/main/java/com/hai/openApi/service/impl/ApiMchProductServiceImpl.java
  16. 97
      hai-service/src/main/java/com/hai/openApi/service/impl/ApiOrderCreateHandleServiceImpl.java
  17. 201
      hai-service/src/main/java/com/hai/openApi/service/impl/ApiOrderServiceImpl.java
  18. 8
      hai-service/src/main/java/com/hai/order/model/CreateOrderChildModel.java
  19. 2
      hai-service/src/main/java/com/hai/order/model/CreateOrderModel.java
  20. 12
      hai-service/src/main/java/com/hai/order/service/OrderPayService.java
  21. 22
      hai-service/src/main/java/com/hai/order/service/impl/OrderPayServiceImpl.java
  22. 10
      hai-service/src/main/java/com/hai/order/service/impl/OrderPaySuccessServiceImpl.java
  23. 2
      hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java
  24. 1
      hai-service/src/main/java/com/hai/order/type/OrderPayType.java
  25. 1
      hai-service/src/main/java/com/hai/service/impl/ApiProductServiceImpl.java
  26. 10
      hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java
  27. 2
      v1/src/main/java/com/v1/config/ApiCommonConfig.java
  28. 128
      v1/src/main/java/com/v1/controller/ApiOrderController.java
  29. 193
      v1/src/main/java/com/v1/controller/HighOrderController.java
  30. 2
      v1/src/main/java/com/v1/controller/ThirdPartyController.java
  31. 2
      v1/src/main/java/com/v1/controller/WxMsgController.java
  32. 5
      v1/src/main/java/com/v1/controller/business/ApiMerchantsController.java
  33. 7
      v1/src/main/java/com/v1/controller/business/GzSinopecController.java
  34. 14
      v1/src/main/java/com/v1/controller/business/RefuelOnlineController.java
  35. 253
      v1/src/main/java/com/v1/controller/orderController.java

@ -123,7 +123,15 @@ public class ApiMchProductController {
ApiMchProduct apiMchProduct = apiMchProductService.findById(id);
Map<String , Object> map = new HashMap<>();
map.put("productType" , apiMchProduct.getProductType());
map.put("mchId" , apiMchProduct.getMchId());
List<ApiMchProduct> list = apiMchProductService.getListMchProduct(map);
if (list.size() == 1) {
secConfigService.deleteSecConfig(apiMchProduct.getMchId() , OrderProductType.getDataByType(apiMchProduct.getProductType()).getApiCode());
}
apiMchProductService.detailApiMchProduct(id);
return ResponseMsgUtil.success("操作成功");

@ -250,7 +250,7 @@ public class ApiMerchantsController {
}
Map<String, Object> map = new HashMap<>();
map.put("sourceType", ApiAmountRecordTypeEnum.type1.getType());
map.put("sourceType", 99);
map.put("sourceContent", "充值金额:" + body.getBigDecimal("amount") + " 元");
apiMerchantsService.recharge(body.getLong("merchantId"), body.getBigDecimal("amount"), map);

@ -89,8 +89,7 @@ public class ApiProductController {
if (object == null ||
object.getJSONArray("prices") == null ||
object.getInteger("operatorType") == null ||
object.getJSONArray("rechargePlatform") == null ||
object.getInteger("phoneRechargeType") == null
object.getJSONArray("rechargePlatform") == null
) {
log.error("ApiProductController -> insertProduct() error!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
@ -122,8 +121,7 @@ public class ApiProductController {
if (object == null ||
object.getLong("id") == null ||
object.getInteger("operatorType") == null ||
object.getJSONArray("rechargePlatform") == null ||
object.getInteger("phoneRechargeType") == null
object.getJSONArray("rechargePlatform") == null
) {
log.error("ApiProductController -> updateProduct() error!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
@ -139,12 +137,10 @@ public class ApiProductController {
apiProduct.setOperatorId(userInfoModel.getSecUser().getId());
apiProduct.setOperatorName(userInfoModel.getSecUser().getLoginName());
apiProduct.setRechargeType(object.getInteger("rechargeType"));
apiProduct.setPhoneRechargeType(object.getInteger("phoneRechargeType"));
apiProduct.setOperatorType(object.getInteger("operatorType"));
apiProduct.setRechargePlatform("-" + StringUtils.join(object.getJSONArray("rechargePlatform"), "-") + "-");
apiProduct.setUpdateTime(new Date());
apiProduct.setSort(object.getInteger("sort"));
apiProduct.setProductId(object.getLong("productId"));
apiProduct.setOperatorName(object.getString("operatorName"));
apiProduct.setOperatorId(object.getLong("operatorId"));
@ -169,9 +165,9 @@ public class ApiProductController {
ApiProduct apiProduct = apiProductService.findById(object.getLong("id"));
if (object.getInteger("status") == 101 && apiProduct.getRechargePlatform().contains("-2-") && apiProduct.getProductId() == null) {
if (object.getInteger("status") == 101 && (apiProduct.getRechargePlatform().contains("-2-") || apiProduct.getRechargePlatform().contains("-4-"))) {
log.error("ApiProductController -> editProductStatus() error!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "龙阅平台需要输入商品编码!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "龙阅,城宇,畅停平台需要输入商品编码!");
}
apiProduct.setStatus(object.getInteger("status"));

File diff suppressed because one or more lines are too long

@ -71,6 +71,12 @@ public class LoginController {
@Resource
private HighGasStaffService gasStaffService;
@Resource
private ApiMerchantsService apiMerchantsService;
@Resource
private ApiIpAddressService apiIpAddressService;
@RequestMapping(value="/userLogin",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "机构用户登录({'loginName':'','password':''})")
@ -232,6 +238,21 @@ public class LoginController {
throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_STORE_NOF_FOUND, "");
}
userInfoModel.setMerchantStore(merchantStore);
} else if (secUser.getObjectType() == 21) {
// 查询APi
ApiMerchants apiMerchants = apiMerchantsService.findById(secUser.getObjectId());
if(apiMerchants == null){
log.error("login error!","当前账户不存在");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前账户不存在");
}
if(apiMerchants.getStatus() != 100) {
log.error("login error!","账户状态异常,请联系管理员");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "账户状态异常,请联系管理员");
}
ApiIpAddress apiIpAddress = apiIpAddressService.findByMchId(apiMerchants.getMchId());
apiMerchants.setExt1(apiIpAddress.getIpAddress());
userInfoModel.setApiMerchants(apiMerchants);
} else {
log.error("login error!","用户信息错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.SEC_USER_EXPIRED, "");

@ -323,7 +323,8 @@ public class OutRechargePriceController {
@ResponseBody
@ApiOperation(value = "获取充值产品编码列表")
public ResponseData getRechargeCodeList(@RequestParam(value = "id", required = true) Long id,
@RequestParam(value = "codeType", required = true) String codeType) {
@RequestParam(value = "codeType", required = true) String codeType,
@RequestParam(value = "type", required = true) Integer type) {
try {
List<SecDictionary> list = commonService.mappingSysNameOl(codeType);
@ -334,7 +335,7 @@ public class OutRechargePriceController {
JSONObject object = new JSONObject();
Map<String, Object> map = new HashMap<>();
map.put("type" , 1);
map.put("type" , type);
map.put("sourceId" , id);
map.put("rechargePlatform" , dictionary.getCodeValue());
BsRechargeCode rechargeCode = bsRechargeCodeService.findByMap(map);

@ -108,6 +108,11 @@ public class OrderController {
log.error("OrderController -> create() error!","");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请输入充值内容!");
}
} else if (childModel.getGoodsType().equals(OrderChildGoodsType.TYPE4.getNumber()) || childModel.getGoodsType().equals(OrderChildGoodsType.TYPE9.getNumber())|| childModel.getGoodsType().equals(OrderChildGoodsType.TYPE10.getNumber())) {
if (childModel.getCustomerMobile() == null) {
log.error("OrderController -> create() error!","");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请输入下单手机号!");
}
}
}

@ -166,9 +166,9 @@ public class MobileRechargeNotifyController {
// 充值回调结果处理
private void callbackResult(String orderNo) {
OutRechargeChildOrder childOrder = outRechargeChildOrderService.findByOrderNo(orderNo);
// 查询充值订单
OutRechargeOrder rechargeOrder = outRechargeOrderService.findByOrderNo(orderNo);
OutRechargeChildOrder childOrder = rechargeOrder.getOutRechargeChildOrders().get(0);
OutRechargeOrder rechargeOrder = outRechargeOrderService.findByOrderId(childOrder.getParentOrderId());
childOrder.setStatus(103);
childOrder.setUpdateTime(new Date());

@ -24,7 +24,7 @@ public interface OutRechargePriceMapperExt {
"and operator_type = #{param.operatorType} " +
"and company_id = #{param.companyId} " +
"and product_type = 9 " +
"order by sort asc; " +
"order by status asc ,sort asc; " +
" </script>"})
@Results({
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),

@ -45,7 +45,17 @@ public class ApiAmountRecord implements Serializable {
private String mchId;
/**
* 1:充值金额 2订单退款 3 话费消费
* 产品类型
* 1星巴克
* 2肯德基
* 3会员充值
* 4积分充值
* 5购买卡券
* 6加油服务
* 7优惠券包
* 8汇联通充值
* 9话费充值
* 99 商户充值
*/
private Integer sourceType;

@ -0,0 +1,62 @@
package com.hai.openApi.config;
import com.hai.entity.ApiAmountRecord;
import com.hai.entity.ApiMerchants;
import com.hai.order.type.OrderProductType;
import com.hai.service.ApiAmountRecordService;
import com.hai.service.ApiMerchantsService;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Date;
@Component
public class PriceComputeConfig {
@Resource
private ApiMerchantsService apiMerchantsService;
@Resource
private ApiAmountRecordService apiAmountRecordService;
public Boolean mchBalance(ApiMerchants apiMerchants , BigDecimal price , String orderNo) {
// 当前账号余额是否可以充值当前金额
if (apiMerchants.getAmounts().compareTo(price) < 0) {
return false;
}
// 插入金额记录
// 变更前金额
BigDecimal beforeAmount = apiMerchants.getAmounts();
// 计算金额
apiMerchants.setAmounts(apiMerchants.getAmounts().subtract(price));
// 变更后金额
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(price);
apiAmountRecord.setAfterAmount(afterAmount);
apiAmountRecord.setBeforeAmount(beforeAmount);
apiAmountRecord.setAmountType(2);
apiAmountRecord.setSourceType(OrderProductType.PRODUCT_TYPE6.getNumber());
apiAmountRecord.setSourceOrderNo(orderNo);
apiAmountRecord.setSourceId(apiMerchants.getId());
apiAmountRecord.setSourceContent(apiMerchants.getMerchantName() + "|在线加油|扣款" + price.setScale(2, BigDecimal.ROUND_HALF_DOWN));
apiAmountRecordService.insertAmountRecord(apiAmountRecord);
return true;
}
}

@ -65,7 +65,7 @@ public interface ApiMchProductService {
* @Param [mchId, productType]
* @Return com.hai.entity.ApiMchProduct
*/
Boolean whereExistence(String mchId , Integer productType);
Boolean whereExistence(String mchId , Integer productType , Long merchantId);
/**
* @Author Sum1Dream

@ -0,0 +1,31 @@
package com.hai.openApi.service;
import com.alibaba.fastjson.JSONObject;
import com.hai.entity.ApiOrder;
import com.hai.entity.HighChildOrder;
import com.hai.entity.HighDiscountUserRel;
import com.hai.entity.HighOrder;
import com.hai.order.model.CreateOrderChildModel;
import com.hai.order.model.CreateOrderModel;
import java.util.List;
/**
* 创建订单-业务校验组装数据
* @className: CreateOrderCheckService
* @author: HuRui
* @date: 2022/8/25
**/
public interface ApiOrderCreateHandleService {
/**
* @Author Sum1Dream
* @Name oilHandle
* @Description // 在线加油校验操作
* @Date 13:59 2023/3/1
* @Param [object]
* @Return com.hai.entity.ApiOrder
*/
ApiOrder oilHandle(JSONObject object) throws Exception;
}

@ -0,0 +1,60 @@
package com.hai.openApi.service;
import com.alibaba.fastjson.JSONObject;
import com.hai.entity.ApiOrder;
import java.util.List;
import java.util.Map;
/**
* @Author Sum1Dream
* @Name orderService
* @Description // 订单业务
* @Date 17:43 2023/2/28
* @Param
* @Return
*/
public interface ApiOrderService {
/**
* @Author Sum1Dream
* @Name createOrder
* @Description // 创建订单
* @Date 17:44 2023/2/28
* @Param [object]
* @Return void
*/
ApiOrder createOrder(JSONObject object) throws Exception;
/**
* @Author Sum1Dream
* @Name payOrder
* @Description // 创建订单
* @Date 17:44 2023/2/28
* @Param [object]
* @Return void
*/
ApiOrder payOrder(JSONObject object) throws Exception;
/**
* @Author Sum1Dream
* @Name getOrderByMap
* @Description // 查询订单
* @Date 17:49 2023/2/28
* @Param [map]
* @Return com.hai.entity.ApiOrder
*/
List<ApiOrder> getOrderByMap(Map<String , Object> map);
/**
* @Author Sum1Dream
* @Name findByOrderNo
* @Description // 根据订单号查询订单
* @Date 20:40 2023/3/1
* @Param [mchOrderNo, orderNo]
* @Return com.hai.entity.ApiOrder
*/
ApiOrder findByOrderNo(String mchOrderNo , String orderNo);
}

@ -55,19 +55,6 @@ public class ApiMchProductServiceImpl implements ApiMchProductService {
apiMchProduct.setCreateTime(new Date());
apiMchProduct.setUpdateTime(new Date());
if (whereExistence((object.getString("mchId")) , Integer.valueOf(productType.toString()))) {
continue;
}
if (secConfigService.isConfig(OrderProductType.getDataByType(Integer.valueOf(productType.toString())).getApiCode() , object.getString("mchId"))) {
continue;
}
// 插入接口权限
SecConfig secConfig = new SecConfig();
secConfig.setCodeValue(object.getString("mchId"));
secConfig.setCodeType(OrderProductType.getDataByType(Integer.valueOf(productType.toString())).getApiCode());
secConfigService.insertSecConfig(secConfig);
if (Integer.valueOf(productType.toString()).equals(OrderProductType.PRODUCT_TYPE6.getNumber())) {
if (object.getLong("companyId") == null ||
@ -77,14 +64,30 @@ public class ApiMchProductServiceImpl implements ApiMchProductService {
}
JSONArray merchantIdS = object.getJSONArray("merchantId");
for (Object merchantId : merchantIdS) {
if (whereExistence((object.getString("mchId")) , Integer.valueOf(productType.toString()) , Long.valueOf(merchantId.toString()))) {
continue;
}
apiMchProduct.setMerchantId(Long.valueOf(merchantId.toString()));
apiMchProduct.setCompanyId(object.getLong("companyId"));
insertMchProduct(apiMchProduct);
}
} else {
insertMchProduct(apiMchProduct);
}
if (secConfigService.isConfig(OrderProductType.getDataByType(Integer.valueOf(productType.toString())).getApiCode() , object.getString("mchId"))) {
continue;
}
// 插入接口权限
SecConfig secConfig = new SecConfig();
secConfig.setCodeValue(object.getString("mchId"));
secConfig.setCodeType(OrderProductType.getDataByType(Integer.valueOf(productType.toString())).getApiCode());
secConfigService.insertSecConfig(secConfig);
}
}
@ -116,10 +119,10 @@ public class ApiMchProductServiceImpl implements ApiMchProductService {
}
@Override
public Boolean whereExistence(String mchId, Integer productType) {
public Boolean whereExistence(String mchId, Integer productType , Long merchantId) {
ApiMchProductExample example = new ApiMchProductExample();
example.createCriteria().andMchIdEqualTo(mchId).andProductTypeEqualTo(productType);
example.createCriteria().andMchIdEqualTo(mchId).andProductTypeEqualTo(productType).andMerchantIdEqualTo(merchantId);
return apiMchProductMapper.selectByExample(example).size() > 0;
}
@ -135,6 +138,9 @@ public class ApiMchProductServiceImpl implements ApiMchProductService {
if (StringUtils.isNotBlank(MapUtils.getString(map, "mchId"))) {
criteria.andMchIdEqualTo(MapUtils.getString(map, "mchId"));
}
if (MapUtils.getLong(map, "merchantId") != null) {
criteria.andMerchantIdEqualTo(MapUtils.getLong(map, "merchantId"));
}
List<ApiMchProduct> list = apiMchProductMapper.selectByExample(example);

@ -0,0 +1,97 @@
package com.hai.openApi.service.impl;
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.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 org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@Service("apiOrderCreateHandleService")
public class ApiOrderCreateHandleServiceImpl implements ApiOrderCreateHandleService {
@Resource
private ApiMerchantsService apiMerchantsService;
@Resource
private HighGasOilPriceService highGasOilPriceService;
@Resource
private PriceComputeConfig priceComputeConfig;
@Resource
private HighMerchantStoreService highMerchantStoreService;
@Resource
private ApiMchProductService apiMchProductService;
@Override
public ApiOrder oilHandle(JSONObject object) throws Exception {
// 获取下单内容
JSONObject dataObject = JSONObject.parseObject(object.getString("content"));
// 查询油枪价
HighGasOilPrice highGasOilPrice = highGasOilPriceService.getGasOilPriceByStoreAndOilNo(dataObject.getLong("storeCode") , dataObject.getString("gasOilNo"));
// 查询api商户
ApiMerchants apiMerchants = apiMerchantsService.findByMchId(object.getString("merchId"));
// 查询加油门店
HighMerchantStore merchantStore = highMerchantStoreService.getMerchantStoreById(dataObject.getLong("storeCode"));
// 查询折扣比例
Map<String , Object> mchProductMap = new HashMap<>();
mchProductMap.put("productType" , object.getString("productType"));
mchProductMap.put("mchId" , object.getString("merchId"));
mchProductMap.put("merchantId" , merchantStore.getMerchantId());
ApiMchProduct mchProduct = apiMchProductService.findByMap(mchProductMap);
BigDecimal price = dataObject.getBigDecimal("refuelPrice").multiply(mchProduct.getDiscount()).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_DOWN);
// 判断金额是否充足
if (apiMerchants.getAmounts().compareTo(price) < 0) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.INSUFFICIENT_BALANCE);
}
// 组装内容
JSONObject jsonObject = new JSONObject();
jsonObject.put("oilNo" , highGasOilPrice.getOilNo());
jsonObject.put("oilNoName" , highGasOilPrice.getOilNoName());
jsonObject.put("priceGun" , highGasOilPrice.getPriceGun());
jsonObject.put("priceCost" , highGasOilPrice.getPriceGun().multiply(mchProduct.getDiscount()).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP));
jsonObject.put("oilTypeName" , highGasOilPrice.getOilTypeName());
jsonObject.put("storeName" , merchantStore.getStoreName());
jsonObject.put("address" , merchantStore.getAddress());
jsonObject.put("regionName" , merchantStore.getRegionName());
// 组装api订单
ApiOrder apiOrder = new ApiOrder();
apiOrder.setCreateTime(new Date());
apiOrder.setTitle(apiMerchants.getMerchantName() + "|在线加油|扣款" + price);
apiOrder.setFacePrice(dataObject.getBigDecimal("refuelPrice"));
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(dataObject.getBigDecimal("refuelPrice"));
apiOrder.setNotifyUrl(object.getString("notifyUrl"));
apiOrder.setContent(jsonObject.toJSONString());
return apiOrder;
}
}

@ -0,0 +1,201 @@
package com.hai.openApi.service.impl;
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.dao.ApiOrderMapper;
import com.hai.entity.ApiMerchants;
import com.hai.entity.ApiOrder;
import com.hai.entity.ApiOrderExample;
import com.hai.entity.HighOrder;
import com.hai.openApi.service.ApiOrderCreateHandleService;
import com.hai.openApi.service.ApiOrderService;
import com.hai.order.model.CreateOrderChildModel;
import com.hai.order.model.CreateOrderModel;
import com.hai.order.service.OrderPayBeforeService;
import com.hai.order.service.OrderPayService;
import com.hai.order.service.OrderService;
import com.hai.order.type.OrderChildGoodsType;
import com.hai.order.type.OrderProductType;
import com.hai.order.type.OrderStatus;
import com.hai.order.utils.OrderUtil;
import com.hai.service.ApiMerchantsService;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
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.util.*;
@Service("apiOrderService")
public class ApiOrderServiceImpl implements ApiOrderService {
@Resource
private ApiMerchantsService apiMerchantsService;
@Resource
private ApiOrderMapper apiOrderMapper;
@Resource
private ApiOrderCreateHandleService orderCreateHandleService;
@Resource
private OrderService orderService;
@Resource
private OrderPayBeforeService orderPayBeforeService;
@Resource
private OrderPayService orderPayService;
@Resource
private ApiOrderService apiOrderService;
@Override
@Transactional(rollbackFor=Exception.class,isolation = Isolation.SERIALIZABLE,propagation= Propagation.REQUIRES_NEW)
public ApiOrder createOrder(JSONObject object) throws Exception {
ApiOrder apiOrder = new ApiOrder();
// 获取下单内容
JSONObject dataObject = JSONObject.parseObject(object.getString("content"));
CreateOrderModel createOrderModel = new CreateOrderModel();
createOrderModel.setChildOrderList(new ArrayList<>());
// 查询订单
Map<String , Object> orderMap = new HashMap<>();
orderMap.put("mchOrderNo" , object.getString("orderNo"));
List<ApiOrder> apiOrderList = getOrderByMap(orderMap);
ApiMerchants apiMerchants = apiMerchantsService.findByMchId(object.getString("merchId"));
createOrderModel.setMemName(apiMerchants.getMerchantName());
createOrderModel.setMemPhone(apiMerchants.getPhone());
createOrderModel.setCompanyId(2L);
createOrderModel.setOrderNo(OrderUtil.generateOrderNo());
// 判断订单号是否重复
if (apiOrderList.size() > 0) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.ORDER_ALREADY_EXISTS);
}
// 处理加油订单
if (OrderProductType.PRODUCT_TYPE6.getNumber().equals(object.getInteger("productType"))) {
apiOrder = orderCreateHandleService.oilHandle(object);
// 组装子订单内容
CreateOrderChildModel createOrderChildModel = new CreateOrderChildModel();
createOrderChildModel.setMemName(apiMerchants.getMerchantName());
createOrderChildModel.setMemPhone(apiMerchants.getPhone());
createOrderChildModel.setCompanyId(2L);
createOrderChildModel.setGoodsType(OrderChildGoodsType.TYPE3.getNumber());
createOrderChildModel.setGasGunNo(dataObject.getString("gasGunNo"));
createOrderChildModel.setGasOilNo(dataObject.getString("gasOilNo"));
createOrderChildModel.setStoreId(dataObject.getLong("storeCode"));
createOrderChildModel.setGoodsId(dataObject.getLong("storeCode"));
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);
return apiOrder;
}
@Override
@Transactional(rollbackFor=Exception.class,isolation = Isolation.SERIALIZABLE,propagation= Propagation.REQUIRES_NEW)
public ApiOrder payOrder(JSONObject object) {
ApiMerchants apiMerchants = apiMerchantsService.findByMchId(object.getString("merchId"));
ApiOrder apiOrder = apiOrderService.findByOrderNo(object.getString("mchOrderNo") , null);
// 查询订单
HighOrder order = orderService.getOrderDetailByNo(object.getString("orderNo"));
if(!order.getOrderStatus().equals(OrderStatus.STATUS1.getNumber())) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.ORDER_NO_STAY_PAY, "");
}
// 支付业务交易
orderPayBeforeService.payOrderCheck(order);
// 处理订单
HighOrder highOrder = orderPayService.apiMchAmount(order , apiMerchants , apiOrder);
if (highOrder.getOrderStatus() != OrderStatus.STATUS1.getNumber()) {
apiOrder.setStatus(highOrder.getOrderStatus());
apiOrder.setUpdateTime(new Date());
apiOrderMapper.updateByPrimaryKey(apiOrder);
}
return apiOrder;
}
@Override
public List<ApiOrder> getOrderByMap(Map<String, Object> map) {
ApiOrderExample example = new ApiOrderExample();
ApiOrderExample.Criteria criteria = example.createCriteria();
if (MapUtils.getInteger(map, "productType") != null) {
criteria.andProductTypeEqualTo(MapUtils.getInteger(map, "productType"));
}
if (StringUtils.isNotBlank(MapUtils.getString(map, "orderNo"))) {
criteria.andOrderNoEqualTo(MapUtils.getString(map, "orderNo"));
}
if (StringUtils.isNotBlank(MapUtils.getString(map, "mchOrderNo"))) {
criteria.andMchOrderNoEqualTo(MapUtils.getString(map, "mchOrderNo"));
}
if (StringUtils.isNotBlank(MapUtils.getString(map, "merchId"))) {
criteria.andMchIdEqualTo(MapUtils.getString(map, "merchId"));
}
if (StringUtils.isNotBlank(MapUtils.getString(map, "createTimeS")) && StringUtils.isNotBlank(MapUtils.getString(map, "createTimeE"))) {
criteria.andCreateTimeBetween(
DateUtil.format(MapUtils.getString(map, "createTimeS"), "yyyy-MM-dd HH:mm:ss"),
DateUtil.format(MapUtils.getString(map, "createTimeE"), "yyyy-MM-dd HH:mm:ss"));
}
return apiOrderMapper.selectByExample(example);
}
@Override
public ApiOrder findByOrderNo(String mchOrderNo , String orderNo) {
ApiOrderExample example = new ApiOrderExample();
ApiOrderExample.Criteria criteria = example.createCriteria();
if (mchOrderNo != null) {
criteria.andMchOrderNoEqualTo(mchOrderNo);
}
if (orderNo != null) {
criteria.andOrderNoEqualTo(orderNo);
}
List<ApiOrder> list = apiOrderMapper.selectByExample(example);
if (list.size() > 0) {
return list.get(0);
}
return null;
}
}

@ -82,7 +82,7 @@ public class CreateOrderChildModel {
/** ======================= 油站所需参数 ======================== **/
/** ======================= 肯德基,星巴克,会员充值所需参数 ======================== **/
/** ======================= 肯德基,星巴克,会员充值所需参数 start ======================== **/
// 下单电话
private String customerMobile;
// 产品类型 1:星巴克 2:肯德基 3:会员充值
@ -95,11 +95,11 @@ public class CreateOrderChildModel {
private String storeCode;
// 请求参数
private Object orderItems;
/** ======================= 肯德基,星巴克,会员充值所需参数 ======================== **/
/** ======================= 肯德基,星巴克,会员充值所需参数 end ======================== **/
/** ======================= 话费充值所需参数 ======================== **/
/** ======================= 话费充值所需参数 start ======================== **/
// 充值内容
private String rechargeContent;
/** ======================= 话费充值所需参数 ======================== **/
/** ======================= 话费充值所需参数 end ======================== **/
}

@ -2,6 +2,7 @@ package com.hai.order.model;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
/**
@ -68,4 +69,5 @@ public class CreateOrderModel {
*/
private List<CreateOrderChildModel> childOrderList;
}

@ -1,5 +1,7 @@
package com.hai.order.service;
import com.hai.entity.ApiMerchants;
import com.hai.entity.ApiOrder;
import com.hai.entity.HighOrder;
import com.hai.entity.HighUserCard;
@ -35,4 +37,14 @@ public interface OrderPayService {
*/
HighOrder oilCardFleetPay(HighOrder order, HighUserCard userCard, String carLicensePlate);
/**
* @Author Sum1Dream
* @Name apiMchAmount
* @Description // API商户金额支付
* @Date 20:44 2023/3/1
* @Param [order, apiMerchants]
* @Return com.hai.entity.HighOrder
*/
HighOrder apiMchAmount(HighOrder order , ApiMerchants apiMerchants , ApiOrder apiOrder);
}

@ -7,6 +7,7 @@ import com.hai.common.exception.SysCode;
import com.hai.config.HuiLianTongUnionCardConfig;
import com.hai.entity.*;
import com.hai.enum_type.OilCardRecordSourceTypeEnum;
import com.hai.openApi.config.PriceComputeConfig;
import com.hai.order.service.OrderPayService;
import com.hai.order.service.OrderPaySuccessService;
import com.hai.order.service.OrderService;
@ -49,6 +50,9 @@ public class OrderPayServiceImpl implements OrderPayService {
@Resource
private HighGasOrderService gasOrderService;
@Resource
private PriceComputeConfig priceComputeConfig;
@Override
public HighOrder hltCardPay(HighOrder order, HighUserCard userCard) throws Exception {
String goodsDesc = "";
@ -151,4 +155,22 @@ public class OrderPayServiceImpl implements OrderPayService {
userCard);
}
@Override
public HighOrder apiMchAmount(HighOrder order, ApiMerchants apiMerchants , ApiOrder apiOrder) {
// 判断金额是否充足
if (!priceComputeConfig.mchBalance(apiMerchants , apiOrder.getCostPrice() , apiOrder.getMchOrderNo())) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.INSUFFICIENT_BALANCE);
}
// 处理订单业务
return orderPaySuccessService.orderPaySuccessHandle(
order.getOrderNo(),
OrderPayType.PAY_TYPE9,
null,
order.getPayPrice(),
null);
}
}

@ -472,16 +472,8 @@ public class OrderPaySuccessServiceImpl implements OrderPaySuccessService {
// 下单
ApiMemberProduct memberProduct = apiMemberProductService.findById(order.getHighChildOrderList().get(0).getGoodsId());
JSONObject object = QianZhuConfig.insertV2(memberProduct.getProductId() , order.getOrderNo() , order.getRemarks());
QianZhuConfig.insertV2(memberProduct.getProductId() , order.getOrderNo() , order.getRemarks());
// // 推送订单记录
// HighGasOrderPush highGasOrderPush = new HighGasOrderPush();
// highGasOrderPush.setType(OrderPushType.type8.getType());
// highGasOrderPush.setOrderNo(order.getOrderNo());
// highGasOrderPush.setCreateTime(new Date());
// highGasOrderPush.setRequestContent(order.getOrderNo());
// highGasOrderPush.setReturnContent(object.toJSONString());
// highGasOrderPushMapper.insert(highGasOrderPush);
}

@ -278,6 +278,7 @@ public class OrderServiceImpl implements OrderService {
order.setTitle("+"+childOrder.getGoodsName());
}
}
order.setRemarks(object.getString("customerMobile"));
} else {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知业务类型");
}
@ -419,6 +420,7 @@ public class OrderServiceImpl implements OrderService {
}
}
order.setSurplusRefundPrice(new BigDecimal("0"));
order.setSurplusRefundIntegral(0);
order.setSearchTitle(order.getOrderNo());

@ -17,6 +17,7 @@ public enum OrderPayType {
PAY_TYPE6(6, "银联分期"),
PAY_TYPE7(7, "嗨森逛个人油卡"),
PAY_TYPE8(8, "嗨森逛车队油卡"),
PAY_TYPE9(9, "API商户金额"),
;
private Integer number;

@ -64,7 +64,6 @@ public class ApiProductServiceImpl implements ApiProductService {
apiProduct = new ApiProduct();
apiProduct.setRechargePrice(priceBd);
apiProduct.setRechargeType(object.getInteger("rechargeType"));
apiProduct.setPhoneRechargeType(object.getInteger("phoneRechargeType"));
apiProduct.setOperatorType(object.getInteger("operatorType"));
apiProduct.setRechargePlatform("-" + StringUtils.join(object.getJSONArray("rechargePlatform"), "-") + "-");
apiProduct.setCreateTime(new Date());

@ -903,19 +903,21 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
JSONObject jsonObject = RechargeConfig.checkOrderByHg(object);
if (jsonObject.getJSONArray("data") == null) {
return -1;
return 99;
} else {
JSONArray objectJSONArray = jsonObject.getJSONArray("data");
JSONObject objectData;
for (Object objects : objectJSONArray) {
objectData = (JSONObject) objects;
// 充值中1成功2失败3已取消4部分充值5缓存订单
// 0充值中1成功2失败3已取消4部分充值5缓存订单
// -1取消,0充值中 ,1充值成功,2充值失败,3部分成功
if (objectData.getInteger("status") == 1 || objectData.getInteger("status") == 5) {
if (objectData.getInteger("status") == 0 || objectData.getInteger("status") == 5) {
return 0;
} else if (objectData.getInteger("status") == 2) {
} else if (objectData.getInteger("status") == 1) {
return 1;
} else if (objectData.getInteger("status") == 2) {
return 2;
} else if (objectData.getInteger("status") == 3) {
return -1;
} else if (objectData.getInteger("status") == 4) {

@ -31,7 +31,7 @@ public class ApiCommonConfig {
ApiMchProduct apiMchProduct = ApiMchProductService.findByMap(map);
return price.multiply(apiMchProduct.getDiscount()).setScale(2, BigDecimal.ROUND_HALF_UP);
return price.multiply(apiMchProduct.getDiscount()).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP);
}

@ -1,128 +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.ApiMerchants;
import com.hai.entity.ApiProductConfig;
import com.hai.model.ResponseData;
import com.hai.service.*;
import com.v1.config.ToolConfig;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
@Controller
@RequestMapping(value = "/apiOrder")
@Api(value = "API订单接口")
public class ApiOrderController {
private static Logger log = LoggerFactory.getLogger(RechargeProductController.class);
@Resource
private ApiMerchantsService apiMerchantsService;
@Resource
private SecConfigService secConfigService;
@Resource
private ApiProductService apiProductService;
@Resource
private ApiOpenService apiOpenService;
@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 (!secConfigService.isConfig("IP_WHITE" , ip)) {
log.error("createOrder error!", "非法ip地址,请联系管理人员!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!");
}
if (StringUtils.isBlank(object.getString("mobile")) ||
StringUtils.isBlank(object.getString("apiProductId")) ||
StringUtils.isBlank(object.getString("apiKey")) ||
StringUtils.isBlank(object.getString("orderType")) ||
StringUtils.isBlank(object.getString("timetable")) ||
StringUtils.isBlank(object.getString("orderNo")) ||
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);
}
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("orderNo" , object.getString("orderNo"));
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 , apiProductConfig);
return ResponseMsgUtil.success("下单成功");
} catch (Exception e) {
log.error("HighOpenApiController --> createOrder() error!", e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -1,193 +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.ApiMerchants;
import com.hai.model.ResponseData;
import com.hai.service.*;
import com.v1.config.ToolConfig;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.Map;
/**
* @serviceName rechargeProductController.java
* @author Sum1Dream
* @version 1.0.0
* @Description // 充值产品接口
* @createTime 17:14 2022/6/9
**/
@Controller
@RequestMapping(value = "/order")
@Api(value = "订单")
public class HighOrderController {
private static Logger log = LoggerFactory.getLogger(HighOrderController.class);
@Resource
private ApiMerchantsService apiMerchantsService;
@Resource
private SecConfigService secConfigService;
@Resource
private OutRechargeOrderService outRechargeOrderService;
@Resource
private HighOrderService highOrderService;
@Resource
private ApiIpAddressService apiIpAddressService;
@RequestMapping(value = "/getCallOrderList", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "获取话费订单列表")
public ResponseData getCallOrderList(@RequestBody JSONObject object , HttpServletRequest request ) {
try {
String ip = "";
// 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for
if (request.getHeader("x-forwarded-for") == null) {
ip = request.getRemoteAddr();
} else {
ip = request.getHeader("x-forwarded-for");
}
if (!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("createTimeS")) ||
StringUtils.isBlank(object.getString("createTimeE")) ||
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"));
map.put("createTimeS" , object.getString("createTimeS"));
map.put("createTimeE" , object.getString("createTimeE"));
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);
}
Map<String, Object> postMap = new HashMap<>();
postMap.put("merchId" , object.getString("merchId"));
postMap.put("createTimeS", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(object.getLong("createTimeS")));
postMap.put("createTimeE", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(object.getLong("createTimeE")));
return ResponseMsgUtil.success(outRechargeOrderService.getListRechargeOrder(postMap));
} catch (Exception e) {
log.error("HighOpenApiController --> getRechargeProduct() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/getOrderList", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "获取订单列表")
public ResponseData getOrderList(@RequestBody JSONObject object , HttpServletRequest request ) {
try {
String ip = "";
// 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for
if (request.getHeader("x-forwarded-for") == null) {
ip = request.getRemoteAddr();
} else {
ip = request.getHeader("x-forwarded-for");
}
if (!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("createTimeS")) ||
StringUtils.isBlank(object.getString("createTimeE")) ||
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"));
map.put("createTimeS" , object.getString("createTimeS"));
map.put("createTimeE" , object.getString("createTimeE"));
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);
}
Map<String, Object> postMap = new HashMap<>();
postMap.put("merchId" , object.getString("merchId"));
postMap.put("createTimeS", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(object.getLong("createTimeS")));
postMap.put("createTimeE", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(object.getLong("createTimeE")));
return ResponseMsgUtil.success(highOrderService.getOrderList(postMap));
} catch (Exception e) {
log.error("HighOpenApiController --> getRechargeProduct() error!", e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -93,7 +93,7 @@ public class ThirdPartyController {
ApiMerchants apiMerchants = apiMerchantsService.findByMchId(object.getString("merchId"));
if (apiMerchants == null) {
log.error("getRechargeProduct error!", "帐户错误!");
log.error("getRechargeProduct error!", "帐户错误!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_NOT_EXIST);
}

@ -121,7 +121,7 @@ public class WxMsgController {
String content = null;
if (eventKey != null && eventKey.length() != 0) {
JSONObject object = weChatQrcodeUtils.paramPars(eventKey);
// type = 1 推广扫码 type = 2 商户门店 3:查看视频教程
// type = 1 推广扫码 type = 2 商户门店 3:查看视频教程 4:支付扫码
if (Objects.equals(object.getString("qrscene_type"), "1") || Objects.equals(object.getString("type"), "1")) {
linkContent = "<a href='" + CommonSysConst.getSysConfig().getHsgDomainName() + "/hsgH5?accountId=0000010&key=&code=" + object.getString("code") + "'>点击查看更多优惠</a>\n\n";
} else if (Objects.equals(object.getString("qrscene_type"), "2") || Objects.equals(object.getString("type"), "2")){

@ -1,4 +1,4 @@
package com.v1.controller;
package com.v1.controller.business;
import com.alibaba.fastjson.JSONObject;
import com.hai.common.exception.ErrorCode;
@ -9,6 +9,7 @@ import com.hai.entity.ApiMerchants;
import com.hai.model.ResponseData;
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;
@ -27,7 +28,7 @@ import java.util.Map;
@Controller
@RequestMapping(value = "/apiMerchants")
@Api(value = "API商户接口")
@Api(value = "商户业务")
public class ApiMerchantsController {
private static Logger log = LoggerFactory.getLogger(RechargeProductController.class);

@ -1,4 +1,4 @@
package com.v1.controller;
package com.v1.controller.business;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
@ -11,12 +11,9 @@ import com.hai.config.HuiLianTongUnionCardConfig;
import com.hai.dao.HighGasOrderPushMapper;
import com.hai.entity.ApiMerchants;
import com.hai.entity.HighGasOrderPush;
import com.hai.entity.HighUser;
import com.hai.enum_type.OrderPushType;
import com.hai.model.ResponseData;
import com.hai.service.ApiMerchantsService;
import com.hai.service.HighOpenApiService;
import com.hai.service.HighUserService;
import com.hai.service.SecConfigService;
import com.v1.config.ToolConfig;
import io.swagger.annotations.Api;
@ -35,7 +32,7 @@ import java.util.Map;
@Controller
@RequestMapping(value = "/gzSinopec")
@Api(value = "贵州中石化")
@Api(value = "贵州中石化业务")
public class GzSinopecController {
private static Logger log = LoggerFactory.getLogger(GzSinopecController.class);

@ -1,4 +1,4 @@
package com.v1.controller;
package com.v1.controller.business;
import com.alibaba.fastjson.JSONObject;
import com.hai.common.exception.ErrorCode;
@ -26,7 +26,6 @@ import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@ -34,7 +33,7 @@ import java.util.Map;
@Controller
@RequestMapping(value = "/refuelOnline")
@Api(value = "在线加油接口")
@Api(value = "在线加油业务")
public class RefuelOnlineController {
private static Logger log = LoggerFactory.getLogger(RefuelOnlineController.class);
@ -128,7 +127,7 @@ public class RefuelOnlineController {
for (HighMerchantStore merchantStore : merchantStores) {
ApiMchStoreModel apiMchStoreModel = new ApiMchStoreModel();
apiMchStoreModel.setAddress(merchantStore.getAddress());
apiMchStoreModel.setStoreCode(merchantStore.getStoreKey());
apiMchStoreModel.setStoreCode(merchantStore.getId().toString());
apiMchStoreModel.setLatitude(merchantStore.getLatitude());
apiMchStoreModel.setLongitude(merchantStore.getLongitude());
apiMchStoreModel.setStoreName(merchantStore.getStoreName());
@ -136,6 +135,8 @@ public class RefuelOnlineController {
List<HighGasOilPrice> gasOilPrices = gasOilPriceService.getGasOilPriceByStore(merchantStore.getId());
List<ApiGasOliPriceModel> list = new ArrayList<>();
for (HighGasOilPrice gasOilPrice : gasOilPrices) {
ApiGasOliPriceModel gasOliPriceModel = new ApiGasOliPriceModel();
gasOliPriceModel.setPriceCost(apiCommonConfig.computationPriceCost(object.getString("merchId") , OrderProductType.PRODUCT_TYPE6.getNumber() , gasOilPrice.getPriceGun()));
@ -146,9 +147,10 @@ public class RefuelOnlineController {
gasOliPriceModel.setOilType(gasOilPrice.getOilType());
gasOliPriceModel.setOilTypeName(gasOilPrice.getOilTypeName());
gasOliPriceModel.setGasOliNo(apiCommonConfig.assemblyGasOilGunNo(gasOilPrice.getId()));
apiMchStoreModel.getApiGasOliPriceModels().add(gasOliPriceModel);
}
list.add(gasOliPriceModel);
}
apiMchStoreModel.setApiGasOliPriceModels(list);
apiMchStoreModels.add(apiMchStoreModel);
}

@ -0,0 +1,253 @@
package com.v1.controller;
import com.alibaba.fastjson.JSONObject;
import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode;
import com.hai.common.utils.ResponseMsgUtil;
import com.hai.entity.ApiMerchants;
import com.hai.entity.ApiOrder;
import com.hai.entity.ApiProductConfig;
import com.hai.model.ResponseData;
import com.hai.openApi.service.ApiOrderService;
import com.hai.order.type.OrderProductType;
import com.hai.service.*;
import com.v1.config.ToolConfig;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
@Controller
@RequestMapping(value = "/order")
@Api(value = "订单业务")
public class orderController {
private static Logger log = LoggerFactory.getLogger(RechargeProductController.class);
@Resource
private ApiMerchantsService apiMerchantsService;
@Resource
private SecConfigService secConfigService;
@Resource
private ApiOrderService orderService;
@Resource
private ApiIpAddressService apiIpAddressService;
@Resource
private ApiOrderService apiOrderService;
@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("apiKey")) ||
StringUtils.isBlank(object.getString("productType")) ||
StringUtils.isBlank(object.getString("timetable")) ||
StringUtils.isBlank(object.getString("orderNo")) ||
StringUtils.isBlank(object.getString("sign")) ||
StringUtils.isBlank(object.getString("content")) ||
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("getRechargeProduct error!", "帐户错误!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_NOT_EXIST);
}
if (!secConfigService.isConfig(OrderProductType.getDataByType(object.getInteger("productType")).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("timetable" , object.getString("timetable"));
map.put("orderNo" , object.getString("orderNo"));
map.put("productType" , object.getString("productType"));
map.put("apiKey" , object.getString("apiKey"));
map.put("content" , object.getString("content"));
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 (object.getInteger("productType").equals(OrderProductType.PRODUCT_TYPE6.getNumber())) {
JSONObject dataObject = JSONObject.parseObject(object.getString("content"));
if (dataObject.getBigDecimal("refuelPrice") == null
|| StringUtils.isBlank(dataObject.getString("gasOilNo"))
|| StringUtils.isBlank(dataObject.getString("gasGunNo"))
|| StringUtils.isBlank(dataObject.getString("storeCode"))
) {
log.error("OrderController -> create() error!","");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未填写加油信息;加油金额、油号、抢号");
}
}
return ResponseMsgUtil.success(orderService.createOrder(object));
} catch (Exception e) {
log.error("HighOpenApiController --> createOrder() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/orderPay", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "订单支付")
public ResponseData orderPay(@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("mchOrderNo")) ||
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("getRechargeProduct error!", "帐户错误!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_NOT_EXIST);
}
Map<String , Object> map = new HashMap<>();
map.put("mchOrderNo" , object.getString("mchOrderNo"));
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);
}
ApiOrder apiOrder = apiOrderService.findByOrderNo(object.getString("mchOrderNo") , null);
if (apiOrder.getStatus() != 1) {
log.error("createOrder error!", "订单状态错误!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR , "订单状态错误");
}
object.put("orderNo" , apiOrder.getOrderNo());
return ResponseMsgUtil.success(orderService.payOrder(object));
} catch (Exception e) {
log.error("HighOpenApiController --> createOrder() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/queryOrderDetail", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "查询订单详情")
public ResponseData queryOrderDetail(@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("mchOrderNo")) ||
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("getRechargeProduct error!", "帐户错误!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_NOT_EXIST);
}
Map<String , Object> map = new HashMap<>();
map.put("mchOrderNo" , object.getString("mchOrderNo"));
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);
}
return ResponseMsgUtil.success(apiOrderService.findByOrderNo(object.getString("mchOrderNo") , null));
} catch (Exception e) {
log.error("HighOpenApiController --> createOrder() error!", e);
return ResponseMsgUtil.exception(e);
}
}
}
Loading…
Cancel
Save