From fcf97218ecd4ea7f77528544e22375de1ad05194 Mon Sep 17 00:00:00 2001 From: = <=> Date: Wed, 30 Jun 2021 23:38:08 +0800 Subject: [PATCH] =?UTF-8?q?'=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cweb/controller/HighGasController.java | 13 +- .../cweb/controller/HighTestController.java | 120 ++++++++++++------ .../com/hai/schedule/HighOrderSchedule.java | 21 +++ .../src/main/resources/dev/application.yml | 2 +- .../java/com/hai/dao/HighOrderMapperExt.java | 3 + .../hai/service/HighGasOilPriceService.java | 8 ++ .../hai/service/HighMerchantStoreService.java | 14 ++ .../com/hai/service/HighOrderService.java | 6 + .../impl/HighGasOilPriceServiceImpl.java | 11 ++ .../impl/HighMerchantStoreServiceImpl.java | 27 ++++ .../service/impl/HighOrderServiceImpl.java | 5 + 11 files changed, 185 insertions(+), 45 deletions(-) diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighGasController.java b/hai-cweb/src/main/java/com/cweb/controller/HighGasController.java index 2e854ac6..98a5c65c 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighGasController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighGasController.java @@ -172,19 +172,18 @@ public class HighGasController { // {"app_key":"208241666939552","gunNo":"1","refuelingAmount":"1.02","thirdSerialNo":"HF2021062716143174807","sign":"83c7e8f70b984a04b937b28b8652aded","driverPhone":"15583658692","gasId":"CS000116587","priceVip":"7.31","oilNo":"90","timestamp":1624781755439,"priceGun":"7.31"}" - String dataStr = "{\"result\": { \"orderNo\": \"CS00011658721062717132106\"},\"code\": 200, \"message\": \"OK\" }"; Map map = new HashMap<>(); map.put("gasId", "CS000116587"); - map.put("oilNo", "90"); - map.put("gunNo", 1); - BigDecimal priceGun = new BigDecimal("7.31"); - BigDecimal priceVip = new BigDecimal("7.31"); + map.put("oilNo", "92"); + map.put("gunNo", 2); + BigDecimal priceGun = new BigDecimal("7.50"); + BigDecimal priceVip = new BigDecimal("7.50"); // BigDecimal priceGun = new BigDecimal("5.58"); // BigDecimal priceVip = new BigDecimal("5.40"); map.put("priceGun", priceGun); // 枪单价 map.put("priceVip", priceVip); // 优惠价 - map.put("driverPhone", "15583658692"); - map.put("thirdSerialNo", new Date().getTime()); + map.put("driverPhone", "18581170527"); + map.put("thirdSerialNo", "HF2021063009483541009"); BigDecimal refuelingAmount = new BigDecimal("1").divide(priceGun,10,BigDecimal.ROUND_DOWN).multiply(priceVip).setScale(2,BigDecimal.ROUND_HALF_UP); map.put("refuelingAmount", refuelingAmount); /*JSONObject orderPushObject = TuanYouConfig.refuelingOrderPush(map); diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighTestController.java b/hai-cweb/src/main/java/com/cweb/controller/HighTestController.java index 13e09baf..ea43b460 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighTestController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighTestController.java @@ -47,7 +47,7 @@ public class HighTestController { @RequestMapping(value = "/initTYMerchantStore", method = RequestMethod.GET) @ResponseBody - @ApiOperation(value = "根据id查询订单详情") + @ApiOperation(value = "根据") public ResponseData initTYMerchantStore(@RequestParam(name = "merchantId", required = true) Long merchantId) { try { @@ -64,43 +64,89 @@ public class HighTestController { for (Object gasObject : jsonArray) { JSONObject object = JSONObject.parseObject(JSONObject.toJSONString(gasObject)); if (object.getInteger("gasStatus") == 1) { - highMerchantStore = new HighMerchantStore(); - highMerchantStore.setType(1); - highMerchantStore.setMerchantId(merchant.getId()); - highMerchantStore.setCompanyId(merchant.getCompanyId()); - highMerchantStore.setStoreKey(object.getString("gasId")); - highMerchantStore.setStoreName(object.getString("gasName")); - highMerchantStore.setStoreLogo(object.getString("gasLogoSmall")); - highMerchantStore.setRegionId(object.getLong("provinceCode")); - highMerchantStore.setRegionName(object.getString("provinceName")); - highMerchantStore.setAddress(object.getString("gasAddress")); - highMerchantStore.setLongitude(object.getString("gasAddressLongitude")); - highMerchantStore.setLatitude(object.getString("gasAddressLatitude")); - highMerchantStore.setStatus(1); - highMerchantStore.setOperatorId(0L); - highMerchantStore.setOperatorName("系统创建"); - highMerchantStore.setCreateTime(new Date()); - highMerchantStore.setUpdateTime(new Date()); - HighMerchantStoreModel merchantStoreModel = new HighMerchantStoreModel(); - BeanUtils.copyProperties(highMerchantStore, merchantStoreModel); - highMerchantStoreService.insertMerchantStore(merchantStoreModel); - - - JSONArray oilPriceList = object.getJSONArray("oilPriceList"); - for (Object oilPrice : oilPriceList) { - JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); - highGasOilPrice = new HighGasOilPrice(); - highGasOilPrice.setMerchantStoreId(merchantStoreModel.getId()); - highGasOilPrice.setOilNo(oilPriceObject.getInteger("oilNo")); - highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); - highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); - highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); - highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); - highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); - highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); - highGasOilPriceService.editGasOilPrice(highGasOilPrice); + HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreByKey(object.getString("gasId")); + if (store != null) { + store.setType(1); + store.setMerchantId(merchant.getId()); + store.setCompanyId(merchant.getCompanyId()); + store.setStoreKey(object.getString("gasId")); + store.setStoreName(object.getString("gasName")); + store.setStoreLogo(object.getString("gasLogoSmall")); + store.setRegionId(object.getLong("provinceCode")); + store.setRegionName(object.getString("provinceName")); + store.setAddress(object.getString("gasAddress")); + store.setLongitude(object.getString("gasAddressLongitude")); + store.setLatitude(object.getString("gasAddressLatitude")); + store.setOperatorId(0L); + store.setOperatorName("系统创建"); + store.setUpdateTime(new Date()); + store.setExt1(object.getString("gasSourceId")); + highMerchantStoreService.updateMerchantStoreDetail(store); + + JSONArray oilPriceList = object.getJSONArray("oilPriceList"); + for (Object oilPrice : oilPriceList) { + JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); + // 查询门店油号 + highGasOilPrice = highGasOilPriceService.getGasOilPriceByStoreAndOilNo(store.getId(), oilPriceObject.getInteger("oilNo")); + if(highGasOilPrice == null) { + highGasOilPrice.setMerchantStoreId(store.getId()); + highGasOilPrice.setOilNo(oilPriceObject.getInteger("oilNo")); + highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); + highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); + highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); + highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); + highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); + highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); + } else { + highGasOilPrice.setMerchantStoreId(store.getId()); + highGasOilPrice.setOilNo(oilPriceObject.getInteger("oilNo")); + highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); + highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); + highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); + highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); + highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); + highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); + } + highGasOilPriceService.editGasOilPrice(highGasOilPrice); + } + } else { + highMerchantStore = new HighMerchantStore(); + highMerchantStore.setType(1); + highMerchantStore.setMerchantId(merchant.getId()); + highMerchantStore.setCompanyId(merchant.getCompanyId()); + highMerchantStore.setStoreKey(object.getString("gasId")); + highMerchantStore.setStoreName(object.getString("gasName")); + highMerchantStore.setStoreLogo(object.getString("gasLogoSmall")); + highMerchantStore.setRegionId(object.getLong("provinceCode")); + highMerchantStore.setRegionName(object.getString("provinceName")); + highMerchantStore.setAddress(object.getString("gasAddress")); + highMerchantStore.setLongitude(object.getString("gasAddressLongitude")); + highMerchantStore.setLatitude(object.getString("gasAddressLatitude")); + highMerchantStore.setStatus(1); + highMerchantStore.setOperatorId(0L); + highMerchantStore.setOperatorName("系统创建"); + highMerchantStore.setCreateTime(new Date()); + highMerchantStore.setUpdateTime(new Date()); + highMerchantStore.setExt1(object.getString("gasSourceId")); + HighMerchantStoreModel merchantStoreModel = new HighMerchantStoreModel(); + BeanUtils.copyProperties(highMerchantStore, merchantStoreModel); + highMerchantStoreService.insertMerchantStore(merchantStoreModel); + + JSONArray oilPriceList = object.getJSONArray("oilPriceList"); + for (Object oilPrice : oilPriceList) { + JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); + highGasOilPrice = new HighGasOilPrice(); + highGasOilPrice.setMerchantStoreId(merchantStoreModel.getId()); + highGasOilPrice.setOilNo(oilPriceObject.getInteger("oilNo")); + highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); + highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); + highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); + highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); + highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); + highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); + highGasOilPriceService.editGasOilPrice(highGasOilPrice); + } } - } } return ResponseMsgUtil.success(jsonArray); diff --git a/hai-schedule/src/main/java/com/hai/schedule/HighOrderSchedule.java b/hai-schedule/src/main/java/com/hai/schedule/HighOrderSchedule.java index 789bef83..50819c66 100644 --- a/hai-schedule/src/main/java/com/hai/schedule/HighOrderSchedule.java +++ b/hai-schedule/src/main/java/com/hai/schedule/HighOrderSchedule.java @@ -11,6 +11,7 @@ import org.springframework.scheduling.annotation.Scheduled; import javax.annotation.Resource; import javax.xml.ws.RespectBinding; +import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -47,4 +48,24 @@ public class HighOrderSchedule { } } + /** + * @Author 胡锐 + * @Description 完成团油订单 超过支付时间24小时订单自动完成 + * @Date 2021/4/4 22:45 + **/ + @Scheduled(cron="0 0/1 * * * ?") //每1分钟执行一次 + public void finishGasOrder() { + List> mapList = highOrderService.getFinishGasOrder(); + if (mapList != null && mapList.size() > 0) { + for (Map map : mapList) { + HighOrder order = highOrderService.getOrderById(Long.parseLong(map.get("orderId").toString())); + if (order != null) { + order.setOrderStatus(3); + order.setFinishTime(new Date()); + highOrderService.updateOrderDetail(order); + } + } + } + } + } diff --git a/hai-schedule/src/main/resources/dev/application.yml b/hai-schedule/src/main/resources/dev/application.yml index ff2ce013..bc02a0d9 100644 --- a/hai-schedule/src/main/resources/dev/application.yml +++ b/hai-schedule/src/main/resources/dev/application.yml @@ -9,7 +9,7 @@ debug: false #datasource数据源设置 spring: datasource: - url: jdbc:mysql://139.159.177.244:3306/hsg_pre?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8 + url: jdbc:mysql://139.159.177.244:3306/hfkj?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8 username: root password: HF123456. type: com.alibaba.druid.pool.DruidDataSource diff --git a/hai-service/src/main/java/com/hai/dao/HighOrderMapperExt.java b/hai-service/src/main/java/com/hai/dao/HighOrderMapperExt.java index e9922955..aaa64de7 100644 --- a/hai-service/src/main/java/com/hai/dao/HighOrderMapperExt.java +++ b/hai-service/src/main/java/com/hai/dao/HighOrderMapperExt.java @@ -191,4 +191,7 @@ public interface HighOrderMapperExt { ""}) List selectGasOrderList(@Param("map") Map map); + @Select({"select a.id orderId,b.id childOrderId from high_order a,high_child_order b where a.id = b.order_id and b.goods_type = 3 and a.order_status = 2 and TIMESTAMPDIFF(MINUTE,a.pay_time,SYSDATE()) > 60*24 GROUP BY b.id"}) + List> selectFinishGasOrder(); + } diff --git a/hai-service/src/main/java/com/hai/service/HighGasOilPriceService.java b/hai-service/src/main/java/com/hai/service/HighGasOilPriceService.java index ec1d9c51..f31f0c72 100644 --- a/hai-service/src/main/java/com/hai/service/HighGasOilPriceService.java +++ b/hai-service/src/main/java/com/hai/service/HighGasOilPriceService.java @@ -13,6 +13,14 @@ public interface HighGasOilPriceService { */ void editGasOilPrice(HighGasOilPrice highGasOilPrice); + /** + * 根据门店和油号查询 + * @param storeId + * @param oilNo + * @return + */ + HighGasOilPrice getGasOilPriceByStoreAndOilNo(Long storeId,Integer oilNo); + /** * 根据门店id 查询 * @param storeId diff --git a/hai-service/src/main/java/com/hai/service/HighMerchantStoreService.java b/hai-service/src/main/java/com/hai/service/HighMerchantStoreService.java index ae0a1afa..85d62316 100644 --- a/hai-service/src/main/java/com/hai/service/HighMerchantStoreService.java +++ b/hai-service/src/main/java/com/hai/service/HighMerchantStoreService.java @@ -35,6 +35,13 @@ public interface HighMerchantStoreService { **/ void updateMerchantStore(HighMerchantStoreModel highMerchantStore) throws Exception; + /** + * 修改门店 + * @param highMerchantStore + * @throws Exception + */ + void updateMerchantStoreDetail(HighMerchantStore highMerchantStore) throws Exception; + /** * @Author 胡锐 * @Description 删除门店 @@ -49,6 +56,13 @@ public interface HighMerchantStoreService { **/ HighMerchantStoreModel getMerchantStoreById(Long id); + /** + * 根据key 查询 + * @param storeKey + * @return + */ + HighMerchantStoreModel getMerchantStoreByKey(String storeKey); + /** * @Author 胡锐 * @Description 查询门店列表 diff --git a/hai-service/src/main/java/com/hai/service/HighOrderService.java b/hai-service/src/main/java/com/hai/service/HighOrderService.java index 5cb0e4d9..282fcdcc 100644 --- a/hai-service/src/main/java/com/hai/service/HighOrderService.java +++ b/hai-service/src/main/java/com/hai/service/HighOrderService.java @@ -161,4 +161,10 @@ public interface HighOrderService { **/ Integer countUnusedDiscountByUserId(Long userId , Integer status); + /** + * 查询团油超过支付时间24小时订单 + * @return + */ + List> getFinishGasOrder(); + } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighGasOilPriceServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighGasOilPriceServiceImpl.java index 00648639..af0c4b7e 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighGasOilPriceServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighGasOilPriceServiceImpl.java @@ -25,6 +25,17 @@ public class HighGasOilPriceServiceImpl implements HighGasOilPriceService { } } + @Override + public HighGasOilPrice getGasOilPriceByStoreAndOilNo(Long storeId, Integer oilNo) { + HighGasOilPriceExample example = new HighGasOilPriceExample(); + example.createCriteria().andMerchantStoreIdEqualTo(storeId).andOilNoEqualTo(oilNo); + List list = highGasOilPriceMapper.selectByExample(example); + if (list.size() > 0) { + return list.get(0); + } + return null; + } + @Override public HighGasOilPrice getGasOilPriceByStore(Long storeId) { HighGasOilPriceExample example = new HighGasOilPriceExample(); diff --git a/hai-service/src/main/java/com/hai/service/impl/HighMerchantStoreServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighMerchantStoreServiceImpl.java index 561d9bc0..3d4c73e8 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighMerchantStoreServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighMerchantStoreServiceImpl.java @@ -90,6 +90,11 @@ public class HighMerchantStoreServiceImpl implements HighMerchantStoreService { } } + @Override + public void updateMerchantStoreDetail(HighMerchantStore highMerchantStore) throws Exception { + highMerchantStoreMapper.updateByPrimaryKey(highMerchantStore); + } + @Override @Transactional public void deleteMerchantStore(Long id) { @@ -127,6 +132,28 @@ public class HighMerchantStoreServiceImpl implements HighMerchantStoreService { return model; } + @Override + public HighMerchantStoreModel getMerchantStoreByKey(String storeKey) { + HighMerchantStoreExample example = new HighMerchantStoreExample(); + example.createCriteria().andStoreKeyEqualTo(storeKey); + List list = highMerchantStoreMapper.selectByExample(example); + if (list.size() > 0) { + HighMerchantStore merchantStore = list.get(0); + if (merchantStore == null) { + return null; + } + HighMerchantStoreModel model = new HighMerchantStoreModel(); + BeanUtils.copyProperties(merchantStore, model); + + // 查询主账号 + SecUser mainAccount = secUserService.getMainAccount(3, merchantStore.getId()); + if (mainAccount != null) { + model.setSecUser(mainAccount); + } + } + return null; + } + @Override public List getMerchantStoreList(Map map) { HighMerchantStoreExample example = new HighMerchantStoreExample(); diff --git a/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java index 003dd7f2..d650fa9c 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java @@ -495,4 +495,9 @@ public class HighOrderServiceImpl implements HighOrderService { example.setOrderByClause("create_time desc"); return highDiscountUserRelMapper.selectByExample(example).size(); } + + @Override + public List> getFinishGasOrder() { + return highOrderMapper.selectFinishGasOrder(); + } }