优化话费定时任务代码

dev-discount
袁野 2 years ago
parent 2d13835ab0
commit 1adc37c728
  1. 3
      hai-bweb/src/main/java/com/bweb/controller/ApiMchProduct/ApiMchProductController.java
  2. 2
      hai-bweb/src/main/java/com/bweb/controller/HighTestController.java
  3. 14
      hai-cweb/src/main/java/com/cweb/controller/CommonController.java
  4. 38
      hai-cweb/src/main/java/com/cweb/controller/OutRechargePriceController.java
  5. 6
      hai-service/src/main/java/com/hai/openApi/model/ApiGasOliPriceModel.java
  6. 11
      hai-service/src/main/java/com/hai/openApi/model/ApiMchStoreModel.java
  7. 20
      hai-service/src/main/java/com/hai/openApi/service/ApiMchProductService.java
  8. 39
      hai-service/src/main/java/com/hai/openApi/service/impl/ApiMchProductServiceImpl.java
  9. 12
      hai-service/src/main/java/com/hai/service/CommonService.java
  10. 14
      hai-service/src/main/java/com/hai/service/impl/CommonServiceImpl.java
  11. 4
      hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java
  12. 55
      v1/src/main/java/com/v1/config/ApiCommonConfig.java
  13. 1
      v1/src/main/java/com/v1/config/AuthConfig.java
  14. 50
      v1/src/main/java/com/v1/controller/RefuelOnlineController.java
  15. 2
      v1/src/main/resources/dev/application.yml

@ -75,9 +75,6 @@ public class ApiMchProductController {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "商户状态错误"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "商户状态错误");
} }
apiMchProductService.detailConfigMchProduct(object.getString("mchId"));
secConfigService.deleteSecConfig(object.getString("mchId"));
if (object.getJSONArray("productType") != null && object.getJSONArray("productType").size() > 0) { if (object.getJSONArray("productType") != null && object.getJSONArray("productType").size() > 0) {
apiMchProductService.configMchProduct(object); apiMchProductService.configMchProduct(object);
} }

File diff suppressed because one or more lines are too long

@ -232,6 +232,20 @@ public class CommonController {
} }
} }
@RequestMapping(value="/findSecConfigByType",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "根据码值类型查询数据")
public ResponseData findSecConfigByType(@RequestParam(name = "codeType", required = true) String codeType) {
try {
return ResponseMsgUtil.success(commonService.findSecConfigByType(codeType));
} catch (Exception e) {
log.error("CommonController --> getDictionaryByCodeTypeAndValue() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/ getScanCodePageHtmlSign", method = RequestMethod.POST) @RequestMapping(value = "/ getScanCodePageHtmlSign", method = RequestMethod.POST)
@ResponseBody @ResponseBody
@ApiOperation(value = "获取扫码页面签名") @ApiOperation(value = "获取扫码页面签名")

@ -1,5 +1,6 @@
package com.cweb.controller; package com.cweb.controller;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorCode;
@ -8,10 +9,7 @@ import com.hai.common.exception.SysCode;
import com.hai.common.security.SessionObject; import com.hai.common.security.SessionObject;
import com.hai.common.security.UserCenter; import com.hai.common.security.UserCenter;
import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.utils.ResponseMsgUtil;
import com.hai.entity.BsCompany; import com.hai.entity.*;
import com.hai.entity.HighAgent;
import com.hai.entity.OutRechargePrice;
import com.hai.entity.SecRegion;
import com.hai.model.OutRechargePriceModel; import com.hai.model.OutRechargePriceModel;
import com.hai.model.ResponseData; import com.hai.model.ResponseData;
import com.hai.model.UserInfoModel; import com.hai.model.UserInfoModel;
@ -32,6 +30,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -43,35 +42,44 @@ public class OutRechargePriceController {
private static Logger log = LoggerFactory.getLogger(HighMerchantStoreController.class); private static Logger log = LoggerFactory.getLogger(HighMerchantStoreController.class);
@Autowired
private UserCenter userCenter;
@Resource @Resource
private OutRechargePriceService outRechargePriceService; private OutRechargePriceService outRechargePriceService;
@Resource
private BsCompanyService bsCompanyService;
@Resource @Resource
private CommonService commonService; private CommonService commonService;
@RequestMapping(value = "/getRechargePriceByList", method = RequestMethod.GET) @RequestMapping(value = "/getRechargePriceByList", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "查询充值金额列表") @ApiOperation(value = "查询充值金额列表")
public ResponseData getRechargePriceByList( public ResponseData getRechargePriceByList(
@RequestParam(name = "platformId", required = true) Integer platformId, @RequestParam(name = "platformId", required = true) Integer platformId,
@RequestParam(name = "companyId", required = true) Long companyId, @RequestParam(name = "companyId", required = true) Long companyId
@RequestParam(name = "operatorType", required = true) Integer operatorType
) { ) {
try { try {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map;
List<SecDictionary> secDictionaryList = commonService.mappingSysNameOl("OPERATOR_TYPE");
List<Object> list = new ArrayList<>();
for (SecDictionary secDictionary : secDictionaryList) {
map = new HashMap<>();
JSONObject object = new JSONObject();
object.put("title" , secDictionary.getCodeName());
object.put("id" , secDictionary.getCodeValue());
object.put("explain_receipt_time" , commonService.findSecConfigByType("explain_receipt_time").getCodeValue());
map.put("companyId", companyId); map.put("companyId", companyId);
map.put("platformId", platformId); map.put("platformId", platformId);
map.put("operatorType", operatorType); map.put("operatorType", secDictionary.getCodeValue());
object.put("priceList" , outRechargePriceService.getRechargePriceByList(map));
list.add(object);
}
return ResponseMsgUtil.success( outRechargePriceService.getRechargePriceByList(map)); return ResponseMsgUtil.success(list);
} catch (Exception e) { } catch (Exception e) {
log.error("OutRechargePriceController --> getListUser() error!", e); log.error("OutRechargePriceController --> getListUser() error!", e);
return ResponseMsgUtil.exception(e); return ResponseMsgUtil.exception(e);

@ -44,7 +44,7 @@ public class ApiGasOliPriceModel {
/** /**
* 油枪号数组 * 油枪号数组
*/ */
private String[] gasOliNo; private List<String> gasOliNo;
public String getOilNo() { public String getOilNo() {
return oilNo; return oilNo;
@ -102,11 +102,11 @@ public class ApiGasOliPriceModel {
this.oilTypeName = oilTypeName; this.oilTypeName = oilTypeName;
} }
public String[] getGasOliNo() { public List<String> getGasOliNo() {
return gasOliNo; return gasOliNo;
} }
public void setGasOliNo(String[] gasOliNo) { public void setGasOliNo(List<String> gasOliNo) {
this.gasOliNo = gasOliNo; this.gasOliNo = gasOliNo;
} }
} }

@ -7,9 +7,6 @@ public class ApiMchStoreModel {
// 区域名称 // 区域名称
private String regionName; private String regionName;
// 门店logo
private String storeLogo;
// 门店编码 // 门店编码
private String storeCode; private String storeCode;
@ -38,14 +35,6 @@ public class ApiMchStoreModel {
this.regionName = regionName; this.regionName = regionName;
} }
public String getStoreLogo() {
return storeLogo;
}
public void setStoreLogo(String storeLogo) {
this.storeLogo = storeLogo;
}
public String getStoreCode() { public String getStoreCode() {
return storeCode; return storeCode;
} }

@ -57,6 +57,26 @@ public interface ApiMchProductService {
*/ */
ApiMchProduct findById(Long id); ApiMchProduct findById(Long id);
/**
* @Author Sum1Dream
* @Name whereExistence
* @Description // 查询
* @Date 14:31 2023/2/28
* @Param [mchId, productType]
* @Return com.hai.entity.ApiMchProduct
*/
Boolean whereExistence(String mchId , Integer productType);
/**
* @Author Sum1Dream
* @Name findByMap
* @Description // 根据map查询商户产品
* @Date 10:55 2023/2/28
* @Param [map]
* @Return com.hai.entity.ApiMchProduct
*/
ApiMchProduct findByMap(Map<String , Object> map);
/** /**
* @Author Sum1Dream * @Author Sum1Dream
* @Name detailConfigMchProduct * @Name detailConfigMchProduct

@ -13,6 +13,7 @@ import com.hai.openApi.service.ApiMchProductService;
import com.hai.order.type.OrderProductType; import com.hai.order.type.OrderProductType;
import com.hai.service.SecConfigService; import com.hai.service.SecConfigService;
import org.apache.commons.collections4.MapUtils; import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -54,6 +55,14 @@ public class ApiMchProductServiceImpl implements ApiMchProductService {
apiMchProduct.setCreateTime(new Date()); apiMchProduct.setCreateTime(new Date());
apiMchProduct.setUpdateTime(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 secConfig = new SecConfig();
secConfig.setCodeValue(object.getString("mchId")); secConfig.setCodeValue(object.getString("mchId"));
@ -106,6 +115,36 @@ public class ApiMchProductServiceImpl implements ApiMchProductService {
return apiMchProductMapper.selectByPrimaryKey(id); return apiMchProductMapper.selectByPrimaryKey(id);
} }
@Override
public Boolean whereExistence(String mchId, Integer productType) {
ApiMchProductExample example = new ApiMchProductExample();
example.createCriteria().andMchIdEqualTo(mchId).andProductTypeEqualTo(productType);
return apiMchProductMapper.selectByExample(example).size() > 0;
}
@Override
public ApiMchProduct findByMap(Map<String, Object> map) {
ApiMchProductExample example = new ApiMchProductExample();
ApiMchProductExample.Criteria criteria = example.createCriteria();
if (MapUtils.getInteger(map , "productType") != null) {
criteria.andProductTypeEqualTo(MapUtils.getInteger(map , "productType"));
}
if (StringUtils.isNotBlank(MapUtils.getString(map, "mchId"))) {
criteria.andMchIdEqualTo(MapUtils.getString(map, "mchId"));
}
List<ApiMchProduct> list = apiMchProductMapper.selectByExample(example);
if (list.size() > 0 ) {
return list.get(0);
}
return null;
}
@Override @Override
public void detailConfigMchProduct(String mchId) { public void detailConfigMchProduct(String mchId) {
ApiMchProductExample example = new ApiMchProductExample(); ApiMchProductExample example = new ApiMchProductExample();

@ -9,6 +9,7 @@ package com.hai.service;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.hai.entity.ApiCity; import com.hai.entity.ApiCity;
import com.hai.entity.SecConfig;
import com.hai.entity.SecDictionary; import com.hai.entity.SecDictionary;
import com.hai.entity.SecRegion; import com.hai.entity.SecRegion;
import com.hai.model.IndexCountModel; import com.hai.model.IndexCountModel;
@ -298,4 +299,15 @@ public interface CommonService {
ApiCity findCityByProvinceName(String provinceName); ApiCity findCityByProvinceName(String provinceName);
/**
* @Author Sum1Dream
* @Name findSecConfigByType
* @Description // 查询配置内容
* @Date 09:12 2023/2/28
* @Param [codeType]
* @Return com.hai.entity.SecConfig
*/
SecConfig findSecConfigByType(String codeType);
} }

@ -71,6 +71,9 @@ public class CommonServiceImpl implements CommonService {
@Resource @Resource
private ApiCityMapper apiCityMapper; private ApiCityMapper apiCityMapper;
@Resource
private SecConfigMapper secConfigMapper;
private Map<String, Map<String, SecDictionary>> dicCache = new HashMap<String, Map<String, SecDictionary>>(); private Map<String, Map<String, SecDictionary>> dicCache = new HashMap<String, Map<String, SecDictionary>>();
@ -716,5 +719,16 @@ public class CommonServiceImpl implements CommonService {
} }
@Override
public SecConfig findSecConfigByType(String codeType) {
SecConfigExample example = new SecConfigExample();
example.createCriteria().andCodeTypeEqualTo(codeType);
if (secConfigMapper.selectByExample(example).size() > 0) {
return secConfigMapper.selectByExample(example).get(0);
}
return null;
}
} }

@ -886,7 +886,11 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
objectData = (JSONObject) objects; objectData = (JSONObject) objects;
} }
if (objectData.size() == 0) { if (objectData.size() == 0) {
if (jsonObject.getInteger("errno") == 0) {
return 2; return 2;
} else {
return 99;
}
} else { } else {
// -1取消,0充值中 ,1充值成功,2充值失败,3部分成功 // -1取消,0充值中 ,1充值成功,2充值失败,3部分成功
return objectData.getInteger("state"); return objectData.getInteger("state");

@ -0,0 +1,55 @@
package com.v1.config;
import com.hai.entity.ApiMchProduct;
import com.hai.entity.HighGasOilGunNo;
import com.hai.openApi.service.ApiMchProductService;
import com.hai.service.ApiMerchantsService;
import com.hai.service.HighGasOilGunNoService;
import org.springframework.context.annotation.Configuration;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Configuration
public class ApiCommonConfig {
@Resource
private ApiMchProductService ApiMchProductService;
@Resource
private HighGasOilGunNoService highGasOilGunNoService;
public BigDecimal computationPriceCost(String mchId , Integer productType , BigDecimal price) {
Map<String , Object> map = new HashMap<>();
map.put("mchId" , mchId);
map.put("productType" , productType);
ApiMchProduct apiMchProduct = ApiMchProductService.findByMap(map);
return price.multiply(apiMchProduct.getDiscount()).setScale(2, BigDecimal.ROUND_HALF_UP);
}
public List<String> assemblyGasOilGunNo(Long oilPriceId) {
List<String> gasOilGunNos = new ArrayList<>();
List<HighGasOilGunNo> list = highGasOilGunNoService.getGunNoListByOilPrice(oilPriceId);
for (HighGasOilGunNo gasOilGunNo : list) {
gasOilGunNos.add(gasOilGunNo.getGunNo());
}
return gasOilGunNos;
}
}

@ -96,6 +96,7 @@ public class AuthConfig implements WebMvcConfigurer {
.excludePathPatterns("/selfOilStation/*") .excludePathPatterns("/selfOilStation/*")
.excludePathPatterns("/order/*") .excludePathPatterns("/order/*")
.excludePathPatterns("/wxMsg/*") .excludePathPatterns("/wxMsg/*")
.excludePathPatterns("/refuelOnline/*")
; ;
} }

@ -7,13 +7,12 @@ import com.hai.common.exception.SysCode;
import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.utils.ResponseMsgUtil;
import com.hai.entity.*; import com.hai.entity.*;
import com.hai.model.ResponseData; import com.hai.model.ResponseData;
import com.hai.openApi.model.ApiGasOliPriceModel;
import com.hai.openApi.model.ApiMchStoreModel; import com.hai.openApi.model.ApiMchStoreModel;
import com.hai.openApi.service.ApiMchProductService; import com.hai.openApi.service.ApiMchProductService;
import com.hai.order.type.OrderProductType; import com.hai.order.type.OrderProductType;
import com.hai.service.ApiIpAddressService; import com.hai.service.*;
import com.hai.service.ApiMerchantsService; import com.v1.config.ApiCommonConfig;
import com.hai.service.HighMerchantStoreService;
import com.hai.service.SecConfigService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -55,6 +54,12 @@ public class RefuelOnlineController {
@Resource @Resource
private HighMerchantStoreService highMerchantStoreService; private HighMerchantStoreService highMerchantStoreService;
@Resource
private HighGasOilPriceService gasOilPriceService;
@Resource
private ApiCommonConfig apiCommonConfig;
@RequestMapping(value = "/getStationStores", method = RequestMethod.POST) @RequestMapping(value = "/getStationStores", method = RequestMethod.POST)
@ResponseBody @ResponseBody
@ApiOperation(value = "获取油站门店") @ApiOperation(value = "获取油站门店")
@ -69,11 +74,6 @@ public class RefuelOnlineController {
ip = request.getHeader("x-forwarded-for"); 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")) || if (StringUtils.isBlank(object.getString("apiKey")) ||
StringUtils.isBlank(object.getString("merchId")) || StringUtils.isBlank(object.getString("merchId")) ||
StringUtils.isBlank(object.getString("sign")) StringUtils.isBlank(object.getString("sign"))
@ -82,6 +82,11 @@ public class RefuelOnlineController {
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_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")); ApiMerchants apiMerchants = apiMerchantsService.findByMchId(object.getString("merchId"));
if (apiMerchants == null) { if (apiMerchants == null) {
@ -91,7 +96,7 @@ public class RefuelOnlineController {
if (!secConfigService.isConfig(OrderProductType.PRODUCT_TYPE6.getApiCode(), object.getString("merchId"))) { if (!secConfigService.isConfig(OrderProductType.PRODUCT_TYPE6.getApiCode(), object.getString("merchId"))) {
log.error("getAllCities error!", "当前帐户无权限查询!"); log.error("getAllCities error!", "当前帐户无权限查询!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_NOT_AUTHORIZED, "当前帐户无权限查询!"); throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_NOT_AUTHORIZED, "");
} }
Map<String , Object> map = new HashMap<>(); Map<String , Object> map = new HashMap<>();
@ -123,10 +128,31 @@ public class RefuelOnlineController {
for (HighMerchantStore merchantStore : merchantStores) { for (HighMerchantStore merchantStore : merchantStores) {
ApiMchStoreModel apiMchStoreModel = new ApiMchStoreModel(); ApiMchStoreModel apiMchStoreModel = new ApiMchStoreModel();
apiMchStoreModel.setAddress(merchantStore.getAddress()); apiMchStoreModel.setAddress(merchantStore.getAddress());
// apiMchStoreModel.setStore_logo(); apiMchStoreModel.setStoreCode(merchantStore.getStoreKey());
apiMchStoreModel.setLatitude(merchantStore.getLatitude());
apiMchStoreModel.setLongitude(merchantStore.getLongitude());
apiMchStoreModel.setStoreName(merchantStore.getStoreName());
apiMchStoreModel.setRegionName(merchantStore.getRegionName());
List<HighGasOilPrice> gasOilPrices = gasOilPriceService.getGasOilPriceByStore(merchantStore.getId());
for (HighGasOilPrice gasOilPrice : gasOilPrices) {
ApiGasOliPriceModel gasOliPriceModel = new ApiGasOliPriceModel();
gasOliPriceModel.setPriceCost(apiCommonConfig.computationPriceCost(object.getString("merchId") , OrderProductType.PRODUCT_TYPE6.getNumber() , gasOilPrice.getPriceGun()));
gasOliPriceModel.setPriceGun(gasOilPrice.getPriceGun());
gasOliPriceModel.setPriceOfficial(gasOilPrice.getPriceOfficial());
gasOliPriceModel.setOilNo(gasOilPrice.getOilNo());
gasOliPriceModel.setOilNoName(gasOilPrice.getOilNoName());
gasOliPriceModel.setOilType(gasOilPrice.getOilType());
gasOliPriceModel.setOilTypeName(gasOilPrice.getOilTypeName());
gasOliPriceModel.setGasOliNo(apiCommonConfig.assemblyGasOilGunNo(gasOilPrice.getId()));
apiMchStoreModel.getApiGasOliPriceModels().add(gasOliPriceModel);
}
apiMchStoreModels.add(apiMchStoreModel);
} }
return ResponseMsgUtil.success(merchantStores); return ResponseMsgUtil.success(apiMchStoreModels);
} catch (Exception e) { } catch (Exception e) {
log.error("HighOpenApiController --> getRechargeProduct() error!", e); log.error("HighOpenApiController --> getRechargeProduct() error!", e);

@ -9,7 +9,7 @@ debug: false
#datasource数据源设置 #datasource数据源设置
spring: spring:
datasource: datasource:
url: jdbc:mysql://139.159.177.244:3306/hsg_order?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false url: jdbc:mysql://139.159.177.244:3306/hsg_2.0?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false
username: root username: root
password: HF123456. password: HF123456.
type: com.alibaba.druid.pool.DruidDataSource type: com.alibaba.druid.pool.DruidDataSource

Loading…
Cancel
Save