parent
83b0537dfa
commit
cac57f0474
@ -0,0 +1,96 @@ |
||||
package com.bweb.controller; |
||||
|
||||
import com.alibaba.fastjson.JSONArray; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.hfkj.common.exception.ErrorCode; |
||||
import com.hfkj.common.exception.ErrorHelp; |
||||
import com.hfkj.common.exception.SysCode; |
||||
import com.hfkj.common.utils.ResponseMsgUtil; |
||||
import com.hfkj.entity.BsGasChannelConfig; |
||||
import com.hfkj.model.ResponseData; |
||||
import com.hfkj.service.order.BsGasChannelConfigService; |
||||
import com.hfkj.sysenum.MerchantSourceTypeEnum; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import io.swagger.models.auth.In; |
||||
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; |
||||
|
||||
@Controller |
||||
@RequestMapping(value = "/gasChannelConfig") |
||||
@Api(value = "加油渠道配置") |
||||
public class BsGasChannelConfigController { |
||||
private static Logger log = LoggerFactory.getLogger(BsGasChannelConfigController.class); |
||||
@Resource |
||||
private BsGasChannelConfigService gasChannelConfigService; |
||||
|
||||
@RequestMapping(value = "/editConfig", method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "编辑配置") |
||||
public ResponseData editConfig(@RequestBody BsGasChannelConfig body) { |
||||
try { |
||||
if (body == null |
||||
|| body.getGasChannelType() == null |
||||
|| StringUtils.isBlank(body.getChannelMerNo()) |
||||
|| StringUtils.isBlank(body.getChannelMerKey()) |
||||
|| body.getLedgerAccountFlag() == null |
||||
) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
// 查询配置
|
||||
BsGasChannelConfig config = gasChannelConfigService.getDetail(MerchantSourceTypeEnum.type2); |
||||
if (config == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
if(body.getLedgerAccountFlag().equals(true)) { |
||||
if (StringUtils.isBlank(body.getLedgerAccountData())) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
JSONArray ledgerAccountArray = JSONArray.parseArray(body.getLedgerAccountData()); |
||||
for (Object obj : ledgerAccountArray) { |
||||
JSONObject ledgerAccount = (JSONObject) obj; |
||||
if (StringUtils.isBlank(ledgerAccount.getString("receiverMerNo")) |
||||
|| StringUtils.isBlank(ledgerAccount.getString("receiverMerName")) |
||||
|| ledgerAccount.getBigDecimal("receiverRatio") == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
} |
||||
config.setLedgerAccountData(body.getLedgerAccountData()); |
||||
} else { |
||||
config.setLedgerAccountData(null); |
||||
} |
||||
config.setChannelMerNo(body.getChannelMerNo()); |
||||
config.setChannelMerKey(body.getChannelMerKey()); |
||||
config.setLedgerAccountFlag(body.getLedgerAccountFlag()); |
||||
gasChannelConfigService.editData(config); |
||||
|
||||
return ResponseMsgUtil.success("操作成功"); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("BsGasChannelConfigController --> editConfig() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
|
||||
@RequestMapping(value = "/queryConfig", method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "获取配置") |
||||
public ResponseData queryConfig(@RequestParam(name = "gasChannelType", required = true) Integer gasChannelType) { |
||||
try { |
||||
|
||||
return ResponseMsgUtil.success(gasChannelConfigService.getDetail(MerchantSourceTypeEnum.getDataByType(gasChannelType))); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("BsGasChannelConfigController --> queryConfig() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,266 @@ |
||||
package com.hfkj.channel.gas.newlink; |
||||
|
||||
import com.alibaba.excel.util.CollectionUtils; |
||||
import com.alibaba.fastjson.JSONArray; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.hfkj.entity.BsGasOilGunNo; |
||||
import com.hfkj.entity.BsGasOilPrice; |
||||
import com.hfkj.entity.BsGasOilPriceExample; |
||||
import com.hfkj.entity.BsMerchant; |
||||
import com.hfkj.service.gas.BsGasOilGunNoService; |
||||
import com.hfkj.service.gas.BsGasOilPriceService; |
||||
import com.hfkj.service.gas.BsGasService; |
||||
import com.hfkj.service.gas.impl.BsGasOilGunNoServiceImpl; |
||||
import com.hfkj.service.merchant.BsMerchantService; |
||||
import com.hfkj.sysenum.MerchantSourceTypeEnum; |
||||
import com.hfkj.sysenum.MerchantStatusEnum; |
||||
import com.hfkj.sysenum.gas.GasOilNoEnum; |
||||
import com.hfkj.sysenum.gas.GasOilPriceStatusEnum; |
||||
import org.apache.commons.lang3.StringUtils; |
||||
import org.apache.poi.util.StringUtil; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.math.BigDecimal; |
||||
import java.util.ArrayList; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
import java.util.concurrent.ArrayBlockingQueue; |
||||
import java.util.concurrent.CountDownLatch; |
||||
import java.util.concurrent.ThreadPoolExecutor; |
||||
import java.util.concurrent.TimeUnit; |
||||
import java.util.stream.Collectors; |
||||
|
||||
/** |
||||
* @className: NewLinkGasService |
||||
* @author: HuRui |
||||
* @date: 2024/7/8 |
||||
**/ |
||||
@Component |
||||
public class NewLinkGasService { |
||||
@Resource |
||||
private BsMerchantService merchantService; |
||||
@Resource |
||||
private BsGasService gasService; |
||||
@Resource |
||||
private BsGasOilPriceService gasOilPriceService; |
||||
@Resource |
||||
private BsGasOilGunNoService gasOilGunNoService; |
||||
|
||||
public void refresh() throws Exception { |
||||
// 最新全量加油站数据
|
||||
List<Object> gasDataList = new ArrayList<>(); |
||||
// 初始化页数
|
||||
Integer totalPageNum = 3; |
||||
for (int pageIndex = 1; pageIndex <= totalPageNum;pageIndex++) { |
||||
// 查询油站
|
||||
JSONObject object = NewLinkRequestService.queryGasInfoListByPage(pageIndex, 3000); |
||||
// 总页数
|
||||
totalPageNum = object.getJSONObject("result").getInteger("totalPageNum"); |
||||
// 加入全量数据集合
|
||||
gasDataList.addAll(object.getJSONObject("result").getJSONArray("gasInfoList")); |
||||
} |
||||
// 设备核心数目
|
||||
int processorsNum = Runtime.getRuntime().availableProcessors(); |
||||
|
||||
Long startTime = System.currentTimeMillis(); |
||||
System.out.println("本次更新任务开始"); |
||||
// 初始化线程池
|
||||
ThreadPoolExecutor threadPool = new ThreadPoolExecutor( |
||||
processorsNum * 2, |
||||
processorsNum * 2, |
||||
4, |
||||
TimeUnit.SECONDS, |
||||
new ArrayBlockingQueue(processorsNum * 2 * 10), |
||||
new ThreadPoolExecutor.DiscardPolicy()); |
||||
|
||||
// 大集合拆分成N个小集合,然后用多线程去处理数据,确保不会因为数据量过大导致执行过慢
|
||||
List<List<Object>> splitNList = splitList(gasDataList, 200); |
||||
// 记录单个任务的执行次数
|
||||
CountDownLatch countDownLatch = new CountDownLatch(splitNList.size()); |
||||
// 对拆分的集合进行批量处理, 先拆分的集合, 再多线程执行
|
||||
for (List<Object> singleList : splitNList) { |
||||
// 线程池执行
|
||||
threadPool.execute(new Thread(new Runnable(){ |
||||
@Override |
||||
public void run() { |
||||
//模拟执行时间
|
||||
System.out.println("当前线程:"+Thread.currentThread().getName()); |
||||
try { |
||||
for (Object obj : singleList) { |
||||
try { |
||||
//组装要执行的批量更新数据
|
||||
JSONObject gasData = (JSONObject) obj; |
||||
// 查询商户
|
||||
BsMerchant merchant = merchantService.getMerchant(gasData.getString("gasId")); |
||||
if (merchant == null) { |
||||
merchant = new BsMerchant(); |
||||
merchant.setStatus(MerchantStatusEnum.status1.getNumber()); |
||||
} |
||||
merchant.setSourceType(MerchantSourceTypeEnum.type2.getNumber()); |
||||
merchant.setProvinceCode(gasData.getLong("provinceCode")); |
||||
merchant.setProvinceName(gasData.getString("provinceName")); |
||||
merchant.setCityCode(gasData.getLong("cityCode")); |
||||
merchant.setCityName(gasData.getString("cityName")); |
||||
merchant.setAreaCode(gasData.getLong("countyCode")); |
||||
merchant.setAreaName(gasData.getString("countyName")); |
||||
merchant.setMerNo(gasData.getString("gasId")); |
||||
merchant.setMerName(gasData.getString("gasName")); |
||||
merchant.setMerLogo(gasData.getString("gasLogoBig")); |
||||
merchant.setAddress(gasData.getString("gasAddress")); |
||||
merchant.setLongitude(gasData.getString("gasAddressLongitude")); |
||||
merchant.setLatitude(gasData.getString("gasAddressLatitude")); |
||||
merchant.setContactsName(merchant.getMerName()); |
||||
merchant.setContactsTel(merchant.getMerNo()); |
||||
merchant.setMerLabel(StringUtils.join(gasData.getJSONArray("gasFeatureList"),",")); |
||||
if (merchant.getId() == null) { |
||||
merchantService.createMerchant(merchant); |
||||
} else { |
||||
merchantService.updateMerchant(merchant); |
||||
} |
||||
|
||||
// 查询油站油价
|
||||
List<BsGasOilPrice> gasOilPriceList = gasOilPriceService.getGasOilPriceList(merchant.getId()); |
||||
BsGasOilPrice oilPriceExample = new BsGasOilPrice(); |
||||
oilPriceExample.setStatus(GasOilPriceStatusEnum.status2.getNumber()); |
||||
gasOilPriceService.batchUpdate(merchant.getMerNo(), oilPriceExample); |
||||
|
||||
// 查询油站抢号
|
||||
List<BsGasOilGunNo> oilGunNoList = gasOilGunNoService.getOilGunNoList(merchant.getMerNo()); |
||||
for (BsGasOilGunNo gunNo : oilGunNoList) { |
||||
gunNo.setStatus(0); |
||||
} |
||||
|
||||
JSONArray oilPriceList = gasData.getJSONArray("oilPriceList"); |
||||
for (Object oilPrice : oilPriceList) { |
||||
JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); |
||||
// 查询油站油价
|
||||
List<BsGasOilPrice> oilPriceCollect = gasOilPriceList.stream().filter(o -> o.getOilNo().equals(oilPriceObject.getString("oilNo"))).collect(Collectors.toList()); |
||||
BsGasOilPrice gasOilPrice = null; |
||||
if (oilPriceCollect.isEmpty()) { |
||||
gasOilPrice = new BsGasOilPrice(); |
||||
gasOilPrice.setMerId(merchant.getId()); |
||||
gasOilPrice.setMerNo(merchant.getMerNo()); |
||||
gasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); |
||||
gasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); |
||||
gasOilPrice.setOilNo(oilPriceObject.getString("oilNo")); |
||||
gasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); |
||||
gasOilPrice.setStatus(GasOilPriceStatusEnum.status1.getNumber()); |
||||
} else { |
||||
gasOilPrice = oilPriceCollect.get(0); |
||||
gasOilPrice.setStatus(GasOilPriceStatusEnum.status1.getNumber()); |
||||
} |
||||
// 平台优惠
|
||||
gasOilPrice.setPreferentialMargin(new BigDecimal("0")); |
||||
// 国标价 - 油站价 = 油站直降
|
||||
gasOilPrice.setGasStationDrop(oilPriceObject.getBigDecimal("priceOfficial").subtract(oilPriceObject.getBigDecimal("priceGun"))); |
||||
gasOilPrice.setPriceCost(oilPriceObject.getBigDecimal("priceVip")); |
||||
gasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceGun")); |
||||
gasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); |
||||
gasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); |
||||
gasOilPriceService.editOilPrice(gasOilPrice); |
||||
|
||||
for (Object gunNo : gasData.getJSONArray("gasGunList")) { |
||||
JSONObject gunNoObject = (JSONObject) gunNo; |
||||
// 查询抢号
|
||||
List<BsGasOilGunNo> gunNoCollect = oilGunNoList.stream() |
||||
.filter(o -> o.getOilNo().equals(gunNoObject.getString("oilNo")) && o.getGunNo().equals(gunNoObject.getString("gunNo"))) |
||||
.collect(Collectors.toList()); |
||||
// 如果没有找到抢号就新增一个
|
||||
BsGasOilGunNo gasOilGunNo = null; |
||||
if (gunNoCollect.isEmpty()) { |
||||
gasOilGunNo = new BsGasOilGunNo(); |
||||
gasOilGunNo.setGasOilPriceId(gasOilPrice.getId()); |
||||
gasOilGunNo.setMerId(gasOilPrice.getMerId()); |
||||
gasOilGunNo.setMerNo(gasOilPrice.getMerNo()); |
||||
gasOilGunNo.setOilNo(gasOilPrice.getOilNo()); |
||||
gasOilGunNo.setOilNoName(gasOilPrice.getOilNoName()); |
||||
gasOilGunNo.setOilType(gasOilPrice.getOilType()); |
||||
gasOilGunNo.setOilTypeName(gasOilPrice.getOilTypeName()); |
||||
gasOilGunNo.setGunNo(gunNoObject.getString("gunNo")); |
||||
gasOilGunNo.setStatus(1); |
||||
gasOilGunNo.setCreateTime(new Date()); |
||||
oilGunNoList.add(gasOilGunNo); |
||||
} else { |
||||
gasOilGunNo = gunNoCollect.get(0); |
||||
gasOilGunNo.setStatus(1); |
||||
} |
||||
} |
||||
} |
||||
|
||||
// 添加
|
||||
gasOilGunNoService.batchInsert(oilGunNoList.stream().filter(o-> o.getId() == null).collect(Collectors.toList())); |
||||
// 更新
|
||||
gasOilGunNoService.batchUpdate(oilGunNoList.stream().filter(o-> o.getId() != null && o.getStatus().equals(0)).collect(Collectors.toList())); |
||||
// 删除缓存
|
||||
gasOilGunNoService.cleanCache(merchant.getMerNo()); |
||||
// 清除油站缓存
|
||||
gasService.clean(merchant.getMerNo()); |
||||
} catch (Exception e) { |
||||
System.out.println("更新油站失败"); |
||||
} |
||||
} |
||||
|
||||
} catch (Exception e) { |
||||
System.out.println("更新油站出现异常"); |
||||
System.out.println(e.getMessage()); |
||||
} finally { |
||||
// 任务个数 - 1, 直至为0时唤醒await()
|
||||
countDownLatch.countDown(); |
||||
} |
||||
} |
||||
})); |
||||
} |
||||
try { |
||||
// 让当前线程处于阻塞状态,直到锁存器计数为零
|
||||
countDownLatch.await(); |
||||
} catch (Exception e) { |
||||
System.out.println("系统出现异常"); |
||||
} |
||||
Long endTime = System.currentTimeMillis(); |
||||
Long useTime = endTime - startTime; |
||||
System.out.println("本次更新任务结束,共计用时"+useTime+"毫秒"); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 拆分集合 |
||||
* |
||||
* @param <T> 泛型对象 |
||||
* @param resList 需要拆分的集合 |
||||
* @param subListLength 每个子集合的元素个数 |
||||
* @return 返回拆分后的各个集合组成的列表 |
||||
**/ |
||||
public static <T> List<List<T>> splitList(List<T> resList, int subListLength) { |
||||
if (CollectionUtils.isEmpty(resList) || subListLength <= 0) { |
||||
return new ArrayList<>(); |
||||
} |
||||
List<List<T>> ret = new ArrayList<>(); |
||||
int size = resList.size(); |
||||
if (size <= subListLength) { |
||||
// 数据量不足 subListLength 指定的大小
|
||||
ret.add(resList); |
||||
} else { |
||||
int pre = size / subListLength; |
||||
int last = size % subListLength; |
||||
// 前面pre个集合,每个大小都是 subListLength 个元素
|
||||
for (int i = 0; i < pre; i++) { |
||||
List<T> itemList = new ArrayList<>(subListLength); |
||||
for (int j = 0; j < subListLength; j++) { |
||||
itemList.add(resList.get(i * subListLength + j)); |
||||
} |
||||
ret.add(itemList); |
||||
} |
||||
|
||||
// last的进行处理
|
||||
if (last > 0) { |
||||
List<T> itemList = new ArrayList<>(last); |
||||
for (int i = 0; i < last; i++) { |
||||
itemList.add(resList.get(pre * subListLength + i)); |
||||
} |
||||
ret.add(itemList); |
||||
} |
||||
} |
||||
return ret; |
||||
} |
||||
} |
@ -0,0 +1,209 @@ |
||||
package com.hfkj.channel.gas.newlink; |
||||
|
||||
import com.alibaba.fastjson.JSON; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.hfkj.common.pay.util.sdk.WXPayConstants; |
||||
import com.hfkj.common.utils.HttpsUtils; |
||||
import com.hfkj.common.utils.MD5Util; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
|
||||
import java.util.*; |
||||
|
||||
/** |
||||
* 【团游】能链渠道服务请求 |
||||
* @author hurui |
||||
*/ |
||||
public class NewLinkRequestService { |
||||
private static final Logger log = LoggerFactory.getLogger(NewLinkRequestService.class); |
||||
private static final String REQ_URL = "https://hcs.czb365.com"; |
||||
private static final String APP_KEY = "305490138943968"; |
||||
private static final String APP_SECRET = "dbf7dca3de20c2f2a41fd64cfb682be8"; |
||||
|
||||
/** |
||||
* 分页获取(全量)油站信息 |
||||
* @param pageIndex 页数 |
||||
* @param pageSize 单页数据量,最大 3000 |
||||
* @return 请求结果 |
||||
* @throws Exception |
||||
*/ |
||||
public static JSONObject queryGasInfoListByPage(Integer pageIndex,Integer pageSize) throws Exception { |
||||
Map<String,Object> paramMap = new HashMap<>(); |
||||
paramMap.put("app_key", APP_KEY); |
||||
paramMap.put("timestamp", System.currentTimeMillis()); |
||||
paramMap.put("pageIndex", pageIndex); |
||||
paramMap.put("pageSize", pageSize); |
||||
paramMap.put("sign", MD5Util.encode(generateTuanYouSignature(paramMap, APP_SECRET).getBytes()).toLowerCase()); |
||||
return HttpsUtils.doPost(REQ_URL+"/services/vp/openapi/queryGasInfoListByPage", JSON.toJSONString(paramMap)); |
||||
} |
||||
|
||||
/** |
||||
* 根据油站 id 拉取最新的油站数据 |
||||
* @param gasId 油站 ID |
||||
* @return 请求结果 |
||||
* @throws Exception |
||||
*/ |
||||
public static JSONObject queryGasInfoByGasId(String gasId) throws Exception { |
||||
Map<String,Object> paramMap = new HashMap<>(); |
||||
paramMap.put("app_key", APP_KEY); |
||||
paramMap.put("timestamp", System.currentTimeMillis()); |
||||
paramMap.put("gasId", gasId); |
||||
paramMap.put("sign", MD5Util.encode(generateTuanYouSignature(paramMap, APP_SECRET).getBytes()).toLowerCase()); |
||||
return HttpsUtils.doPost(REQ_URL+"/services/vp/openapi/queryGasInfoByGasId", JSON.toJSONString(paramMap)); |
||||
} |
||||
|
||||
/** |
||||
* 查询油站,某油号实时价格 |
||||
* @param gasId 加油站id |
||||
* @param oilNo 油号id |
||||
* @return 请求结果 |
||||
* @throws Exception |
||||
*/ |
||||
public static JSONObject queryCompanyPriceDetail(String gasId,String oilNo) throws Exception { |
||||
Map<String,Object> paramMap = new HashMap<>(); |
||||
paramMap.put("app_key", APP_KEY); |
||||
paramMap.put("timestamp", System.currentTimeMillis()); |
||||
paramMap.put("gasId", gasId); |
||||
paramMap.put("oilNo", oilNo); |
||||
paramMap.put("sign", MD5Util.encode(generateTuanYouSignature(paramMap,APP_SECRET).getBytes()).toLowerCase()); |
||||
return HttpsUtils.doPost(REQ_URL+"/services/vp/openapi/queryCompanyPriceDetail", JSON.toJSONString(paramMap)); |
||||
} |
||||
|
||||
/** |
||||
* 推送订单 |
||||
* @param map |
||||
* @return 请求结果 |
||||
* @throws Exception |
||||
*/ |
||||
public static JSONObject refuelingOrderPush(Map<String,Object> map) throws Exception { |
||||
Map<String,Object> paramMap = new HashMap<>(); |
||||
paramMap.put("app_key", APP_KEY); |
||||
paramMap.put("timestamp", System.currentTimeMillis()); |
||||
for (Map.Entry<String, Object> entry : map.entrySet()) { |
||||
paramMap.put(entry.getKey(), entry.getValue().toString()); |
||||
} |
||||
paramMap.put("sign", MD5Util.encode(generateTuanYouSignature(paramMap, APP_SECRET).getBytes()).toLowerCase()); |
||||
return HttpsUtils.doPost(REQ_URL+"/services/vp/openapi/refuelingOrderPush", JSON.toJSONString(paramMap)); |
||||
} |
||||
|
||||
/** |
||||
* 订单退款 |
||||
* @param driverPhone 司机手机号 |
||||
* @param thirdSerialNo 三方订单号 |
||||
* @param refundReason 退款原因 |
||||
* @return 请求结果 |
||||
* @throws Exception |
||||
*/ |
||||
public static JSONObject refuelingOrderRefund(String driverPhone,String thirdSerialNo,String refundReason) throws Exception { |
||||
Map<String,Object> paramMap = new HashMap<>(); |
||||
paramMap.put("app_key", APP_KEY); |
||||
paramMap.put("timestamp", System.currentTimeMillis()); |
||||
paramMap.put("driverPhone", driverPhone); |
||||
paramMap.put("thirdSerialNo", thirdSerialNo); |
||||
paramMap.put("refundReason", refundReason); |
||||
paramMap.put("sign", MD5Util.encode(generateTuanYouSignature(paramMap, APP_SECRET).getBytes()).toLowerCase()); |
||||
return HttpsUtils.doPost(REQ_URL+"/services/vp/openapi/refuelingOrderRefund", JSON.toJSONString(paramMap)); |
||||
} |
||||
|
||||
/** |
||||
* queryCompanyAccountBalance |
||||
* @return 企业余额查询(多能源类型) |
||||
* @throws Exception |
||||
*/ |
||||
public static JSONObject queryCompanyAccountInfo2JD() throws Exception { |
||||
Map<String,Object> paramMap = new HashMap<>(); |
||||
paramMap.put("app_key", APP_KEY); |
||||
paramMap.put("timestamp", System.currentTimeMillis()); |
||||
paramMap.put("companyCode", APP_KEY); |
||||
paramMap.put("sign", MD5Util.encode(generateTuanYouSignature(paramMap,APP_SECRET).getBytes()).toLowerCase()); |
||||
return HttpsUtils.doPost(REQ_URL+"/services/vp/openapi/queryCompanyAccountInfo2JD", JSON.toJSONString(paramMap)); |
||||
} |
||||
|
||||
/** |
||||
* 订单结果查询 |
||||
* @param thirdSerialNo 三方订单号 |
||||
* @return 请求结果 |
||||
* @throws Exception |
||||
*/ |
||||
public static JSONObject queryThirdOrderDetail(String thirdSerialNo) throws Exception { |
||||
Map<String,Object> paramMap = new HashMap<>(); |
||||
paramMap.put("app_key", APP_KEY); |
||||
paramMap.put("timestamp", System.currentTimeMillis()); |
||||
paramMap.put("companyCode", APP_KEY); |
||||
paramMap.put("thirdSerialNo", thirdSerialNo); |
||||
paramMap.put("sign", MD5Util.encode(generateTuanYouSignature(paramMap,APP_SECRET).getBytes()).toLowerCase()); |
||||
return HttpsUtils.doPost(REQ_URL+"/services/vp/openapi/queryThirdOrderDetail", JSON.toJSONString(paramMap)); |
||||
} |
||||
|
||||
/** |
||||
* 订单列表查询 |
||||
* @param companyCode 公司 code AppKey |
||||
* @param startTime 查询开始时间 2018-11-30 12:28:55 |
||||
* @param endTime 查询结束时间 2018-11-30 16:28 |
||||
* @param page 页码(缺省默认 1) |
||||
* @param rows 每页记录行数(缺省默认 20)最大值 200 |
||||
* @param orderPayFlag 订单状态 未支付:1, 已支付:3, 退款中:5, 已退款:6,退款失败:7; |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
public static JSONObject queryOrderInfoList(String companyCode,String startTime,String endTime,Integer page,Integer rows,Integer orderPayFlag) throws Exception { |
||||
Map<String,Object> paramMap = new HashMap<>(); |
||||
paramMap.put("app_key", APP_KEY); |
||||
paramMap.put("timestamp", System.currentTimeMillis()); |
||||
paramMap.put("companyCode", companyCode); |
||||
paramMap.put("startTime", startTime); |
||||
paramMap.put("endTime", endTime); |
||||
if (page != null) { |
||||
paramMap.put("page", page); |
||||
} |
||||
if (rows != null) { |
||||
paramMap.put("rows", rows); |
||||
} |
||||
if (orderPayFlag != null) { |
||||
paramMap.put("orderPayFlag", orderPayFlag); |
||||
} |
||||
paramMap.put("sign", MD5Util.encode(generateTuanYouSignature(paramMap,APP_SECRET).getBytes()).toLowerCase()); |
||||
return HttpsUtils.doPost(REQ_URL+"/services/vp/openapi/queryOrderInfoList", JSON.toJSONString(paramMap)); |
||||
} |
||||
|
||||
/** |
||||
* 上汽油站下单结果查询 |
||||
* @param thirdSerialNo 三方订单号 |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
public static JSONObject loopShangQiOrder(String thirdSerialNo) throws Exception { |
||||
Map<String,Object> paramMap = new HashMap<>(); |
||||
paramMap.put("app_key", APP_KEY); |
||||
paramMap.put("timestamp", System.currentTimeMillis()); |
||||
paramMap.put("thirdSerialNo", thirdSerialNo); |
||||
paramMap.put("sign", MD5Util.encode(generateTuanYouSignature(paramMap, APP_SECRET).getBytes()).toLowerCase()); |
||||
return HttpsUtils.doPost(REQ_URL+"/services/vp/openapi/loopShangQiOrder", JSON.toJSONString(paramMap)); |
||||
} |
||||
|
||||
/** |
||||
* 生成签名 |
||||
* @param data 数据 |
||||
* @param key 秘钥app_secret |
||||
* @return 加密结果 |
||||
*/ |
||||
public static String generateTuanYouSignature(final Map<String, Object> data, String key){ |
||||
Set<String> keySet = data.keySet(); |
||||
String[] keyArray = keySet.toArray(new String[keySet.size()]); |
||||
Arrays.sort(keyArray); |
||||
StringBuilder sb = new StringBuilder(); |
||||
sb.append(key); |
||||
for (String k : keyArray) { |
||||
if (k.equals(WXPayConstants.FIELD_SIGN)) { |
||||
continue; |
||||
} |
||||
if (data.get(k) != null) // 参数值为空,则不参与签名
|
||||
sb.append(k).append(data.get(k)); |
||||
} |
||||
sb.append(key); |
||||
return sb.toString(); |
||||
} |
||||
|
||||
|
||||
|
||||
} |
@ -0,0 +1,130 @@ |
||||
package com.hfkj.dao; |
||||
|
||||
import com.hfkj.entity.BsGasChannelConfig; |
||||
import com.hfkj.entity.BsGasChannelConfigExample; |
||||
import java.util.List; |
||||
import org.apache.ibatis.annotations.Delete; |
||||
import org.apache.ibatis.annotations.DeleteProvider; |
||||
import org.apache.ibatis.annotations.Insert; |
||||
import org.apache.ibatis.annotations.InsertProvider; |
||||
import org.apache.ibatis.annotations.Options; |
||||
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.SelectProvider; |
||||
import org.apache.ibatis.annotations.Update; |
||||
import org.apache.ibatis.annotations.UpdateProvider; |
||||
import org.apache.ibatis.type.JdbcType; |
||||
import org.springframework.stereotype.Repository; |
||||
|
||||
/** |
||||
* |
||||
* 代码由工具生成,请勿修改!!! |
||||
* 如果需要扩展请在其父类进行扩展 |
||||
* |
||||
**/ |
||||
@Repository |
||||
public interface BsGasChannelConfigMapper extends BsGasChannelConfigMapperExt { |
||||
@SelectProvider(type=BsGasChannelConfigSqlProvider.class, method="countByExample") |
||||
long countByExample(BsGasChannelConfigExample example); |
||||
|
||||
@DeleteProvider(type=BsGasChannelConfigSqlProvider.class, method="deleteByExample") |
||||
int deleteByExample(BsGasChannelConfigExample example); |
||||
|
||||
@Delete({ |
||||
"delete from bs_gas_channel_config", |
||||
"where id = #{id,jdbcType=BIGINT}" |
||||
}) |
||||
int deleteByPrimaryKey(Long id); |
||||
|
||||
@Insert({ |
||||
"insert into bs_gas_channel_config (gas_channel_type, channel_type, ", |
||||
"channel_mer_no, channel_mer_key, ", |
||||
"ledger_account_flag, ledger_account_data, ", |
||||
"create_time, update_time, ", |
||||
"`status`, ext_1, ext_2, ", |
||||
"ext_3)", |
||||
"values (#{gasChannelType,jdbcType=INTEGER}, #{channelType,jdbcType=INTEGER}, ", |
||||
"#{channelMerNo,jdbcType=VARCHAR}, #{channelMerKey,jdbcType=VARCHAR}, ", |
||||
"#{ledgerAccountFlag,jdbcType=BIT}, #{ledgerAccountData,jdbcType=VARCHAR}, ", |
||||
"#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, ", |
||||
"#{status,jdbcType=INTEGER}, #{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, ", |
||||
"#{ext3,jdbcType=VARCHAR})" |
||||
}) |
||||
@Options(useGeneratedKeys=true,keyProperty="id") |
||||
int insert(BsGasChannelConfig record); |
||||
|
||||
@InsertProvider(type=BsGasChannelConfigSqlProvider.class, method="insertSelective") |
||||
@Options(useGeneratedKeys=true,keyProperty="id") |
||||
int insertSelective(BsGasChannelConfig record); |
||||
|
||||
@SelectProvider(type=BsGasChannelConfigSqlProvider.class, method="selectByExample") |
||||
@Results({ |
||||
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), |
||||
@Result(column="gas_channel_type", property="gasChannelType", jdbcType=JdbcType.INTEGER), |
||||
@Result(column="channel_type", property="channelType", jdbcType=JdbcType.INTEGER), |
||||
@Result(column="channel_mer_no", property="channelMerNo", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="channel_mer_key", property="channelMerKey", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="ledger_account_flag", property="ledgerAccountFlag", jdbcType=JdbcType.BIT), |
||||
@Result(column="ledger_account_data", property="ledgerAccountData", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), |
||||
@Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP), |
||||
@Result(column="status", property="status", jdbcType=JdbcType.INTEGER), |
||||
@Result(column="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) |
||||
}) |
||||
List<BsGasChannelConfig> selectByExample(BsGasChannelConfigExample example); |
||||
|
||||
@Select({ |
||||
"select", |
||||
"id, gas_channel_type, channel_type, channel_mer_no, channel_mer_key, ledger_account_flag, ", |
||||
"ledger_account_data, create_time, update_time, `status`, ext_1, ext_2, ext_3", |
||||
"from bs_gas_channel_config", |
||||
"where id = #{id,jdbcType=BIGINT}" |
||||
}) |
||||
@Results({ |
||||
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), |
||||
@Result(column="gas_channel_type", property="gasChannelType", jdbcType=JdbcType.INTEGER), |
||||
@Result(column="channel_type", property="channelType", jdbcType=JdbcType.INTEGER), |
||||
@Result(column="channel_mer_no", property="channelMerNo", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="channel_mer_key", property="channelMerKey", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="ledger_account_flag", property="ledgerAccountFlag", jdbcType=JdbcType.BIT), |
||||
@Result(column="ledger_account_data", property="ledgerAccountData", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), |
||||
@Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP), |
||||
@Result(column="status", property="status", jdbcType=JdbcType.INTEGER), |
||||
@Result(column="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) |
||||
}) |
||||
BsGasChannelConfig selectByPrimaryKey(Long id); |
||||
|
||||
@UpdateProvider(type=BsGasChannelConfigSqlProvider.class, method="updateByExampleSelective") |
||||
int updateByExampleSelective(@Param("record") BsGasChannelConfig record, @Param("example") BsGasChannelConfigExample example); |
||||
|
||||
@UpdateProvider(type=BsGasChannelConfigSqlProvider.class, method="updateByExample") |
||||
int updateByExample(@Param("record") BsGasChannelConfig record, @Param("example") BsGasChannelConfigExample example); |
||||
|
||||
@UpdateProvider(type=BsGasChannelConfigSqlProvider.class, method="updateByPrimaryKeySelective") |
||||
int updateByPrimaryKeySelective(BsGasChannelConfig record); |
||||
|
||||
@Update({ |
||||
"update bs_gas_channel_config", |
||||
"set gas_channel_type = #{gasChannelType,jdbcType=INTEGER},", |
||||
"channel_type = #{channelType,jdbcType=INTEGER},", |
||||
"channel_mer_no = #{channelMerNo,jdbcType=VARCHAR},", |
||||
"channel_mer_key = #{channelMerKey,jdbcType=VARCHAR},", |
||||
"ledger_account_flag = #{ledgerAccountFlag,jdbcType=BIT},", |
||||
"ledger_account_data = #{ledgerAccountData,jdbcType=VARCHAR},", |
||||
"create_time = #{createTime,jdbcType=TIMESTAMP},", |
||||
"update_time = #{updateTime,jdbcType=TIMESTAMP},", |
||||
"`status` = #{status,jdbcType=INTEGER},", |
||||
"ext_1 = #{ext1,jdbcType=VARCHAR},", |
||||
"ext_2 = #{ext2,jdbcType=VARCHAR},", |
||||
"ext_3 = #{ext3,jdbcType=VARCHAR}", |
||||
"where id = #{id,jdbcType=BIGINT}" |
||||
}) |
||||
int updateByPrimaryKey(BsGasChannelConfig record); |
||||
} |
@ -0,0 +1,7 @@ |
||||
package com.hfkj.dao; |
||||
|
||||
/** |
||||
* mapper扩展类 |
||||
*/ |
||||
public interface BsGasChannelConfigMapperExt { |
||||
} |
@ -0,0 +1,346 @@ |
||||
package com.hfkj.dao; |
||||
|
||||
import com.hfkj.entity.BsGasChannelConfig; |
||||
import com.hfkj.entity.BsGasChannelConfigExample.Criteria; |
||||
import com.hfkj.entity.BsGasChannelConfigExample.Criterion; |
||||
import com.hfkj.entity.BsGasChannelConfigExample; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
import org.apache.ibatis.jdbc.SQL; |
||||
|
||||
public class BsGasChannelConfigSqlProvider { |
||||
|
||||
public String countByExample(BsGasChannelConfigExample example) { |
||||
SQL sql = new SQL(); |
||||
sql.SELECT("count(*)").FROM("bs_gas_channel_config"); |
||||
applyWhere(sql, example, false); |
||||
return sql.toString(); |
||||
} |
||||
|
||||
public String deleteByExample(BsGasChannelConfigExample example) { |
||||
SQL sql = new SQL(); |
||||
sql.DELETE_FROM("bs_gas_channel_config"); |
||||
applyWhere(sql, example, false); |
||||
return sql.toString(); |
||||
} |
||||
|
||||
public String insertSelective(BsGasChannelConfig record) { |
||||
SQL sql = new SQL(); |
||||
sql.INSERT_INTO("bs_gas_channel_config"); |
||||
|
||||
if (record.getGasChannelType() != null) { |
||||
sql.VALUES("gas_channel_type", "#{gasChannelType,jdbcType=INTEGER}"); |
||||
} |
||||
|
||||
if (record.getChannelType() != null) { |
||||
sql.VALUES("channel_type", "#{channelType,jdbcType=INTEGER}"); |
||||
} |
||||
|
||||
if (record.getChannelMerNo() != null) { |
||||
sql.VALUES("channel_mer_no", "#{channelMerNo,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getChannelMerKey() != null) { |
||||
sql.VALUES("channel_mer_key", "#{channelMerKey,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getLedgerAccountFlag() != null) { |
||||
sql.VALUES("ledger_account_flag", "#{ledgerAccountFlag,jdbcType=BIT}"); |
||||
} |
||||
|
||||
if (record.getLedgerAccountData() != null) { |
||||
sql.VALUES("ledger_account_data", "#{ledgerAccountData,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getCreateTime() != null) { |
||||
sql.VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}"); |
||||
} |
||||
|
||||
if (record.getUpdateTime() != null) { |
||||
sql.VALUES("update_time", "#{updateTime,jdbcType=TIMESTAMP}"); |
||||
} |
||||
|
||||
if (record.getStatus() != null) { |
||||
sql.VALUES("`status`", "#{status,jdbcType=INTEGER}"); |
||||
} |
||||
|
||||
if (record.getExt1() != null) { |
||||
sql.VALUES("ext_1", "#{ext1,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getExt2() != null) { |
||||
sql.VALUES("ext_2", "#{ext2,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getExt3() != null) { |
||||
sql.VALUES("ext_3", "#{ext3,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
return sql.toString(); |
||||
} |
||||
|
||||
public String selectByExample(BsGasChannelConfigExample example) { |
||||
SQL sql = new SQL(); |
||||
if (example != null && example.isDistinct()) { |
||||
sql.SELECT_DISTINCT("id"); |
||||
} else { |
||||
sql.SELECT("id"); |
||||
} |
||||
sql.SELECT("gas_channel_type"); |
||||
sql.SELECT("channel_type"); |
||||
sql.SELECT("channel_mer_no"); |
||||
sql.SELECT("channel_mer_key"); |
||||
sql.SELECT("ledger_account_flag"); |
||||
sql.SELECT("ledger_account_data"); |
||||
sql.SELECT("create_time"); |
||||
sql.SELECT("update_time"); |
||||
sql.SELECT("`status`"); |
||||
sql.SELECT("ext_1"); |
||||
sql.SELECT("ext_2"); |
||||
sql.SELECT("ext_3"); |
||||
sql.FROM("bs_gas_channel_config"); |
||||
applyWhere(sql, example, false); |
||||
|
||||
if (example != null && example.getOrderByClause() != null) { |
||||
sql.ORDER_BY(example.getOrderByClause()); |
||||
} |
||||
|
||||
return sql.toString(); |
||||
} |
||||
|
||||
public String updateByExampleSelective(Map<String, Object> parameter) { |
||||
BsGasChannelConfig record = (BsGasChannelConfig) parameter.get("record"); |
||||
BsGasChannelConfigExample example = (BsGasChannelConfigExample) parameter.get("example"); |
||||
|
||||
SQL sql = new SQL(); |
||||
sql.UPDATE("bs_gas_channel_config"); |
||||
|
||||
if (record.getId() != null) { |
||||
sql.SET("id = #{record.id,jdbcType=BIGINT}"); |
||||
} |
||||
|
||||
if (record.getGasChannelType() != null) { |
||||
sql.SET("gas_channel_type = #{record.gasChannelType,jdbcType=INTEGER}"); |
||||
} |
||||
|
||||
if (record.getChannelType() != null) { |
||||
sql.SET("channel_type = #{record.channelType,jdbcType=INTEGER}"); |
||||
} |
||||
|
||||
if (record.getChannelMerNo() != null) { |
||||
sql.SET("channel_mer_no = #{record.channelMerNo,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getChannelMerKey() != null) { |
||||
sql.SET("channel_mer_key = #{record.channelMerKey,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getLedgerAccountFlag() != null) { |
||||
sql.SET("ledger_account_flag = #{record.ledgerAccountFlag,jdbcType=BIT}"); |
||||
} |
||||
|
||||
if (record.getLedgerAccountData() != null) { |
||||
sql.SET("ledger_account_data = #{record.ledgerAccountData,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getCreateTime() != null) { |
||||
sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}"); |
||||
} |
||||
|
||||
if (record.getUpdateTime() != null) { |
||||
sql.SET("update_time = #{record.updateTime,jdbcType=TIMESTAMP}"); |
||||
} |
||||
|
||||
if (record.getStatus() != null) { |
||||
sql.SET("`status` = #{record.status,jdbcType=INTEGER}"); |
||||
} |
||||
|
||||
if (record.getExt1() != null) { |
||||
sql.SET("ext_1 = #{record.ext1,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getExt2() != null) { |
||||
sql.SET("ext_2 = #{record.ext2,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getExt3() != null) { |
||||
sql.SET("ext_3 = #{record.ext3,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
applyWhere(sql, example, true); |
||||
return sql.toString(); |
||||
} |
||||
|
||||
public String updateByExample(Map<String, Object> parameter) { |
||||
SQL sql = new SQL(); |
||||
sql.UPDATE("bs_gas_channel_config"); |
||||
|
||||
sql.SET("id = #{record.id,jdbcType=BIGINT}"); |
||||
sql.SET("gas_channel_type = #{record.gasChannelType,jdbcType=INTEGER}"); |
||||
sql.SET("channel_type = #{record.channelType,jdbcType=INTEGER}"); |
||||
sql.SET("channel_mer_no = #{record.channelMerNo,jdbcType=VARCHAR}"); |
||||
sql.SET("channel_mer_key = #{record.channelMerKey,jdbcType=VARCHAR}"); |
||||
sql.SET("ledger_account_flag = #{record.ledgerAccountFlag,jdbcType=BIT}"); |
||||
sql.SET("ledger_account_data = #{record.ledgerAccountData,jdbcType=VARCHAR}"); |
||||
sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}"); |
||||
sql.SET("update_time = #{record.updateTime,jdbcType=TIMESTAMP}"); |
||||
sql.SET("`status` = #{record.status,jdbcType=INTEGER}"); |
||||
sql.SET("ext_1 = #{record.ext1,jdbcType=VARCHAR}"); |
||||
sql.SET("ext_2 = #{record.ext2,jdbcType=VARCHAR}"); |
||||
sql.SET("ext_3 = #{record.ext3,jdbcType=VARCHAR}"); |
||||
|
||||
BsGasChannelConfigExample example = (BsGasChannelConfigExample) parameter.get("example"); |
||||
applyWhere(sql, example, true); |
||||
return sql.toString(); |
||||
} |
||||
|
||||
public String updateByPrimaryKeySelective(BsGasChannelConfig record) { |
||||
SQL sql = new SQL(); |
||||
sql.UPDATE("bs_gas_channel_config"); |
||||
|
||||
if (record.getGasChannelType() != null) { |
||||
sql.SET("gas_channel_type = #{gasChannelType,jdbcType=INTEGER}"); |
||||
} |
||||
|
||||
if (record.getChannelType() != null) { |
||||
sql.SET("channel_type = #{channelType,jdbcType=INTEGER}"); |
||||
} |
||||
|
||||
if (record.getChannelMerNo() != null) { |
||||
sql.SET("channel_mer_no = #{channelMerNo,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getChannelMerKey() != null) { |
||||
sql.SET("channel_mer_key = #{channelMerKey,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getLedgerAccountFlag() != null) { |
||||
sql.SET("ledger_account_flag = #{ledgerAccountFlag,jdbcType=BIT}"); |
||||
} |
||||
|
||||
if (record.getLedgerAccountData() != null) { |
||||
sql.SET("ledger_account_data = #{ledgerAccountData,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getCreateTime() != null) { |
||||
sql.SET("create_time = #{createTime,jdbcType=TIMESTAMP}"); |
||||
} |
||||
|
||||
if (record.getUpdateTime() != null) { |
||||
sql.SET("update_time = #{updateTime,jdbcType=TIMESTAMP}"); |
||||
} |
||||
|
||||
if (record.getStatus() != null) { |
||||
sql.SET("`status` = #{status,jdbcType=INTEGER}"); |
||||
} |
||||
|
||||
if (record.getExt1() != null) { |
||||
sql.SET("ext_1 = #{ext1,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getExt2() != null) { |
||||
sql.SET("ext_2 = #{ext2,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getExt3() != null) { |
||||
sql.SET("ext_3 = #{ext3,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
sql.WHERE("id = #{id,jdbcType=BIGINT}"); |
||||
|
||||
return sql.toString(); |
||||
} |
||||
|
||||
protected void applyWhere(SQL sql, BsGasChannelConfigExample example, boolean includeExamplePhrase) { |
||||
if (example == null) { |
||||
return; |
||||
} |
||||
|
||||
String parmPhrase1; |
||||
String parmPhrase1_th; |
||||
String parmPhrase2; |
||||
String parmPhrase2_th; |
||||
String parmPhrase3; |
||||
String parmPhrase3_th; |
||||
if (includeExamplePhrase) { |
||||
parmPhrase1 = "%s #{example.oredCriteria[%d].allCriteria[%d].value}"; |
||||
parmPhrase1_th = "%s #{example.oredCriteria[%d].allCriteria[%d].value,typeHandler=%s}"; |
||||
parmPhrase2 = "%s #{example.oredCriteria[%d].allCriteria[%d].value} and #{example.oredCriteria[%d].criteria[%d].secondValue}"; |
||||
parmPhrase2_th = "%s #{example.oredCriteria[%d].allCriteria[%d].value,typeHandler=%s} and #{example.oredCriteria[%d].criteria[%d].secondValue,typeHandler=%s}"; |
||||
parmPhrase3 = "#{example.oredCriteria[%d].allCriteria[%d].value[%d]}"; |
||||
parmPhrase3_th = "#{example.oredCriteria[%d].allCriteria[%d].value[%d],typeHandler=%s}"; |
||||
} else { |
||||
parmPhrase1 = "%s #{oredCriteria[%d].allCriteria[%d].value}"; |
||||
parmPhrase1_th = "%s #{oredCriteria[%d].allCriteria[%d].value,typeHandler=%s}"; |
||||
parmPhrase2 = "%s #{oredCriteria[%d].allCriteria[%d].value} and #{oredCriteria[%d].criteria[%d].secondValue}"; |
||||
parmPhrase2_th = "%s #{oredCriteria[%d].allCriteria[%d].value,typeHandler=%s} and #{oredCriteria[%d].criteria[%d].secondValue,typeHandler=%s}"; |
||||
parmPhrase3 = "#{oredCriteria[%d].allCriteria[%d].value[%d]}"; |
||||
parmPhrase3_th = "#{oredCriteria[%d].allCriteria[%d].value[%d],typeHandler=%s}"; |
||||
} |
||||
|
||||
StringBuilder sb = new StringBuilder(); |
||||
List<Criteria> oredCriteria = example.getOredCriteria(); |
||||
boolean firstCriteria = true; |
||||
for (int i = 0; i < oredCriteria.size(); i++) { |
||||
Criteria criteria = oredCriteria.get(i); |
||||
if (criteria.isValid()) { |
||||
if (firstCriteria) { |
||||
firstCriteria = false; |
||||
} else { |
||||
sb.append(" or "); |
||||
} |
||||
|
||||
sb.append('('); |
||||
List<Criterion> criterions = criteria.getAllCriteria(); |
||||
boolean firstCriterion = true; |
||||
for (int j = 0; j < criterions.size(); j++) { |
||||
Criterion criterion = criterions.get(j); |
||||
if (firstCriterion) { |
||||
firstCriterion = false; |
||||
} else { |
||||
sb.append(" and "); |
||||
} |
||||
|
||||
if (criterion.isNoValue()) { |
||||
sb.append(criterion.getCondition()); |
||||
} else if (criterion.isSingleValue()) { |
||||
if (criterion.getTypeHandler() == null) { |
||||
sb.append(String.format(parmPhrase1, criterion.getCondition(), i, j)); |
||||
} else { |
||||
sb.append(String.format(parmPhrase1_th, criterion.getCondition(), i, j,criterion.getTypeHandler())); |
||||
} |
||||
} else if (criterion.isBetweenValue()) { |
||||
if (criterion.getTypeHandler() == null) { |
||||
sb.append(String.format(parmPhrase2, criterion.getCondition(), i, j, i, j)); |
||||
} else { |
||||
sb.append(String.format(parmPhrase2_th, criterion.getCondition(), i, j, criterion.getTypeHandler(), i, j, criterion.getTypeHandler())); |
||||
} |
||||
} else if (criterion.isListValue()) { |
||||
sb.append(criterion.getCondition()); |
||||
sb.append(" ("); |
||||
List<?> listItems = (List<?>) criterion.getValue(); |
||||
boolean comma = false; |
||||
for (int k = 0; k < listItems.size(); k++) { |
||||
if (comma) { |
||||
sb.append(", "); |
||||
} else { |
||||
comma = true; |
||||
} |
||||
if (criterion.getTypeHandler() == null) { |
||||
sb.append(String.format(parmPhrase3, i, j, k)); |
||||
} else { |
||||
sb.append(String.format(parmPhrase3_th, i, j, k, criterion.getTypeHandler())); |
||||
} |
||||
} |
||||
sb.append(')'); |
||||
} |
||||
} |
||||
sb.append(')'); |
||||
} |
||||
} |
||||
|
||||
if (sb.length() > 0) { |
||||
sql.WHERE(sb.toString()); |
||||
} |
||||
} |
||||
} |
@ -1,7 +1,59 @@ |
||||
package com.hfkj.dao; |
||||
|
||||
import com.hfkj.entity.BsGasOilGunNo; |
||||
import org.apache.ibatis.annotations.Insert; |
||||
import org.apache.ibatis.annotations.Param; |
||||
import org.apache.ibatis.annotations.Update; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* mapper扩展类 |
||||
*/ |
||||
public interface BsGasOilGunNoMapperExt { |
||||
} |
||||
|
||||
@Insert({ |
||||
"<script>" + |
||||
"insert into bs_gas_oil_gun_no (gas_oil_price_id, mer_id, ", |
||||
"mer_no, oil_type, ", |
||||
"oil_type_name, oil_no, ", |
||||
"oil_no_name, gun_no, ", |
||||
"`status`, create_time, ", |
||||
"ext_1, ext_2, ext_3)", |
||||
"values " + |
||||
"<foreach collection='list' item='item' separator=','>", |
||||
" (#{item.gasOilPriceId}, #{item.merId}, ", |
||||
" #{item.merNo}, #{item.oilType}, ", |
||||
" #{item.oilTypeName}, #{item.oilNo}, ", |
||||
" #{item.oilNoName}, #{item.gunNo}, ", |
||||
" #{item.status}, #{item.createTime}, ", |
||||
" #{item.ext1}, #{item.ext2}, #{item.ext3})" + |
||||
"</foreach>" + |
||||
"</script>", |
||||
}) |
||||
void batchInsert(@Param(value = "list") List<BsGasOilGunNo> list); |
||||
|
||||
@Update({ |
||||
"<script>" + |
||||
"<foreach collection='list' item='item' separator=';'>", |
||||
" update bs_gas_oil_gun_no", |
||||
" set" + |
||||
" gas_oil_price_id = #{item.gasOilPriceId},", |
||||
" mer_id = #{item.merId},", |
||||
" mer_no = #{item.merNo},", |
||||
" oil_type = #{item.oilType},", |
||||
" oil_type_name = #{item.oilTypeName},", |
||||
" oil_no = #{item.oilNo},", |
||||
" oil_no_name = #{item.oilNoName},", |
||||
" gun_no = #{item.gunNo},", |
||||
" `status` = #{item.status},", |
||||
" create_time = #{item.createTime},", |
||||
" ext_1 = #{item.ext1},", |
||||
" ext_2 = #{item.ext2},", |
||||
" ext_3 = #{item.ext3}", |
||||
" where id = #{item.id}", |
||||
"</foreach>" + |
||||
"</script>", |
||||
}) |
||||
void batchUpdate(@Param(value = "list") List<BsGasOilGunNo> list); |
||||
} |
||||
|
@ -0,0 +1,245 @@ |
||||
package com.hfkj.entity; |
||||
|
||||
import java.io.Serializable; |
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* bs_gas_channel_config |
||||
* @author |
||||
*/ |
||||
/** |
||||
* |
||||
* 代码由工具生成 |
||||
* |
||||
**/ |
||||
public class BsGasChannelConfig implements Serializable { |
||||
private Long id; |
||||
|
||||
/** |
||||
* 油站渠道 |
||||
*/ |
||||
private Integer gasChannelType; |
||||
|
||||
/** |
||||
* 支付渠道类型 |
||||
*/ |
||||
private Integer channelType; |
||||
|
||||
/** |
||||
* 支付渠道商户号 |
||||
*/ |
||||
private String channelMerNo; |
||||
|
||||
/** |
||||
* 支付渠道商户秘钥 |
||||
*/ |
||||
private String channelMerKey; |
||||
|
||||
/** |
||||
* 是否分账 0:否 :是 |
||||
*/ |
||||
private Boolean ledgerAccountFlag; |
||||
|
||||
/** |
||||
* 分账接收方数据 |
||||
*/ |
||||
private String ledgerAccountData; |
||||
|
||||
/** |
||||
* 创建时间 |
||||
*/ |
||||
private Date createTime; |
||||
|
||||
/** |
||||
* 修改时间 |
||||
*/ |
||||
private Date updateTime; |
||||
|
||||
/** |
||||
* 状态 1:正常 2:停用 |
||||
*/ |
||||
private Integer status; |
||||
|
||||
private String ext1; |
||||
|
||||
private String ext2; |
||||
|
||||
private String ext3; |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
public Long getId() { |
||||
return id; |
||||
} |
||||
|
||||
public void setId(Long id) { |
||||
this.id = id; |
||||
} |
||||
|
||||
public Integer getGasChannelType() { |
||||
return gasChannelType; |
||||
} |
||||
|
||||
public void setGasChannelType(Integer gasChannelType) { |
||||
this.gasChannelType = gasChannelType; |
||||
} |
||||
|
||||
public Integer getChannelType() { |
||||
return channelType; |
||||
} |
||||
|
||||
public void setChannelType(Integer channelType) { |
||||
this.channelType = channelType; |
||||
} |
||||
|
||||
public String getChannelMerNo() { |
||||
return channelMerNo; |
||||
} |
||||
|
||||
public void setChannelMerNo(String channelMerNo) { |
||||
this.channelMerNo = channelMerNo; |
||||
} |
||||
|
||||
public String getChannelMerKey() { |
||||
return channelMerKey; |
||||
} |
||||
|
||||
public void setChannelMerKey(String channelMerKey) { |
||||
this.channelMerKey = channelMerKey; |
||||
} |
||||
|
||||
public Boolean getLedgerAccountFlag() { |
||||
return ledgerAccountFlag; |
||||
} |
||||
|
||||
public void setLedgerAccountFlag(Boolean ledgerAccountFlag) { |
||||
this.ledgerAccountFlag = ledgerAccountFlag; |
||||
} |
||||
|
||||
public String getLedgerAccountData() { |
||||
return ledgerAccountData; |
||||
} |
||||
|
||||
public void setLedgerAccountData(String ledgerAccountData) { |
||||
this.ledgerAccountData = ledgerAccountData; |
||||
} |
||||
|
||||
public Date getCreateTime() { |
||||
return createTime; |
||||
} |
||||
|
||||
public void setCreateTime(Date createTime) { |
||||
this.createTime = createTime; |
||||
} |
||||
|
||||
public Date getUpdateTime() { |
||||
return updateTime; |
||||
} |
||||
|
||||
public void setUpdateTime(Date updateTime) { |
||||
this.updateTime = updateTime; |
||||
} |
||||
|
||||
public Integer getStatus() { |
||||
return status; |
||||
} |
||||
|
||||
public void setStatus(Integer status) { |
||||
this.status = status; |
||||
} |
||||
|
||||
public String getExt1() { |
||||
return ext1; |
||||
} |
||||
|
||||
public void setExt1(String ext1) { |
||||
this.ext1 = ext1; |
||||
} |
||||
|
||||
public String getExt2() { |
||||
return ext2; |
||||
} |
||||
|
||||
public void setExt2(String ext2) { |
||||
this.ext2 = ext2; |
||||
} |
||||
|
||||
public String getExt3() { |
||||
return ext3; |
||||
} |
||||
|
||||
public void setExt3(String ext3) { |
||||
this.ext3 = ext3; |
||||
} |
||||
|
||||
@Override |
||||
public boolean equals(Object that) { |
||||
if (this == that) { |
||||
return true; |
||||
} |
||||
if (that == null) { |
||||
return false; |
||||
} |
||||
if (getClass() != that.getClass()) { |
||||
return false; |
||||
} |
||||
BsGasChannelConfig other = (BsGasChannelConfig) that; |
||||
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) |
||||
&& (this.getGasChannelType() == null ? other.getGasChannelType() == null : this.getGasChannelType().equals(other.getGasChannelType())) |
||||
&& (this.getChannelType() == null ? other.getChannelType() == null : this.getChannelType().equals(other.getChannelType())) |
||||
&& (this.getChannelMerNo() == null ? other.getChannelMerNo() == null : this.getChannelMerNo().equals(other.getChannelMerNo())) |
||||
&& (this.getChannelMerKey() == null ? other.getChannelMerKey() == null : this.getChannelMerKey().equals(other.getChannelMerKey())) |
||||
&& (this.getLedgerAccountFlag() == null ? other.getLedgerAccountFlag() == null : this.getLedgerAccountFlag().equals(other.getLedgerAccountFlag())) |
||||
&& (this.getLedgerAccountData() == null ? other.getLedgerAccountData() == null : this.getLedgerAccountData().equals(other.getLedgerAccountData())) |
||||
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime())) |
||||
&& (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime())) |
||||
&& (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus())) |
||||
&& (this.getExt1() == null ? other.getExt1() == null : this.getExt1().equals(other.getExt1())) |
||||
&& (this.getExt2() == null ? other.getExt2() == null : this.getExt2().equals(other.getExt2())) |
||||
&& (this.getExt3() == null ? other.getExt3() == null : this.getExt3().equals(other.getExt3())); |
||||
} |
||||
|
||||
@Override |
||||
public int hashCode() { |
||||
final int prime = 31; |
||||
int result = 1; |
||||
result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); |
||||
result = prime * result + ((getGasChannelType() == null) ? 0 : getGasChannelType().hashCode()); |
||||
result = prime * result + ((getChannelType() == null) ? 0 : getChannelType().hashCode()); |
||||
result = prime * result + ((getChannelMerNo() == null) ? 0 : getChannelMerNo().hashCode()); |
||||
result = prime * result + ((getChannelMerKey() == null) ? 0 : getChannelMerKey().hashCode()); |
||||
result = prime * result + ((getLedgerAccountFlag() == null) ? 0 : getLedgerAccountFlag().hashCode()); |
||||
result = prime * result + ((getLedgerAccountData() == null) ? 0 : getLedgerAccountData().hashCode()); |
||||
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode()); |
||||
result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode()); |
||||
result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode()); |
||||
result = prime * result + ((getExt1() == null) ? 0 : getExt1().hashCode()); |
||||
result = prime * result + ((getExt2() == null) ? 0 : getExt2().hashCode()); |
||||
result = prime * result + ((getExt3() == null) ? 0 : getExt3().hashCode()); |
||||
return result; |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
StringBuilder sb = new StringBuilder(); |
||||
sb.append(getClass().getSimpleName()); |
||||
sb.append(" ["); |
||||
sb.append("Hash = ").append(hashCode()); |
||||
sb.append(", id=").append(id); |
||||
sb.append(", gasChannelType=").append(gasChannelType); |
||||
sb.append(", channelType=").append(channelType); |
||||
sb.append(", channelMerNo=").append(channelMerNo); |
||||
sb.append(", channelMerKey=").append(channelMerKey); |
||||
sb.append(", ledgerAccountFlag=").append(ledgerAccountFlag); |
||||
sb.append(", ledgerAccountData=").append(ledgerAccountData); |
||||
sb.append(", createTime=").append(createTime); |
||||
sb.append(", updateTime=").append(updateTime); |
||||
sb.append(", status=").append(status); |
||||
sb.append(", ext1=").append(ext1); |
||||
sb.append(", ext2=").append(ext2); |
||||
sb.append(", ext3=").append(ext3); |
||||
sb.append(", serialVersionUID=").append(serialVersionUID); |
||||
sb.append("]"); |
||||
return sb.toString(); |
||||
} |
||||
} |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,28 @@ |
||||
package com.hfkj.service.order; |
||||
|
||||
import com.hfkj.entity.BsGasChannelConfig; |
||||
import com.hfkj.sysenum.MerchantSourceTypeEnum; |
||||
import com.hfkj.sysenum.order.OrderPayChannelEnum; |
||||
import com.hfkj.sysenum.order.OrderPayTypeEnum; |
||||
|
||||
/** |
||||
* @className: BsGasChannelConfigService |
||||
* @author: HuRui |
||||
* @date: 2024/7/10 |
||||
**/ |
||||
public interface BsGasChannelConfigService { |
||||
|
||||
/** |
||||
* 编辑数据 |
||||
* @param gasChannelConfig |
||||
*/ |
||||
void editData(BsGasChannelConfig gasChannelConfig); |
||||
|
||||
/** |
||||
* 查询详情 |
||||
* @param gasSourceType |
||||
* @return |
||||
*/ |
||||
BsGasChannelConfig getDetail(MerchantSourceTypeEnum gasSourceType); |
||||
|
||||
} |
@ -0,0 +1,57 @@ |
||||
package com.hfkj.service.order.impl; |
||||
|
||||
import com.hfkj.common.utils.RedisUtil; |
||||
import com.hfkj.dao.BsGasChannelConfigMapper; |
||||
import com.hfkj.entity.BsGasChannelConfig; |
||||
import com.hfkj.entity.BsGasChannelConfigExample; |
||||
import com.hfkj.service.order.BsGasChannelConfigService; |
||||
import com.hfkj.sysenum.MerchantSourceTypeEnum; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @className: BsGasChannelConfigServiceImpl |
||||
* @author: HuRui |
||||
* @date: 2024/7/10 |
||||
**/ |
||||
@Service("") |
||||
public class BsGasChannelConfigServiceImpl implements BsGasChannelConfigService { |
||||
@Resource |
||||
private BsGasChannelConfigMapper gasChannelConfigMapper; |
||||
private final static String CACHE_KEY = "GAS_CHANNEL_CONFIG:"; |
||||
@Resource |
||||
private RedisUtil redisUtil; |
||||
@Override |
||||
public void editData(BsGasChannelConfig gasChannelConfig) { |
||||
gasChannelConfig.setUpdateTime(new Date()); |
||||
if (gasChannelConfig.getId() == null) { |
||||
gasChannelConfig.setCreateTime(new Date()); |
||||
gasChannelConfigMapper.insert(gasChannelConfig); |
||||
} else { |
||||
gasChannelConfigMapper.updateByPrimaryKey(gasChannelConfig); |
||||
} |
||||
// 存入缓存
|
||||
redisUtil.set(CACHE_KEY+gasChannelConfig.getChannelType(), gasChannelConfig); |
||||
} |
||||
|
||||
@Override |
||||
public BsGasChannelConfig getDetail(MerchantSourceTypeEnum gasSourceType) { |
||||
Object obj = redisUtil.get(CACHE_KEY + gasSourceType); |
||||
if (obj != null) { |
||||
return (BsGasChannelConfig) obj; |
||||
} |
||||
BsGasChannelConfigExample example = new BsGasChannelConfigExample(); |
||||
example.createCriteria().andGasChannelTypeEqualTo(gasSourceType.getNumber()); |
||||
List<BsGasChannelConfig> list = gasChannelConfigMapper.selectByExample(example); |
||||
if (!list.isEmpty()) { |
||||
BsGasChannelConfig gasChannelConfig = list.get(0); |
||||
// 存入缓存
|
||||
redisUtil.set(CACHE_KEY+gasChannelConfig.getChannelType(), gasChannelConfig); |
||||
return gasChannelConfig; |
||||
} |
||||
return null; |
||||
} |
||||
} |
Loading…
Reference in new issue