Browse Source

Merge remote-tracking branch 'origin/dev' into dev

lzm 3 years ago
parent
commit
acdd5c11cc

+ 2 - 1
app/pages/wx/pay.vue

@@ -29,7 +29,8 @@
 								</u-checkbox>
 							</view>
 							<view class="c">{{item.carNo}}</view>
-							<view class="r">{{item.price}}元</view>
+							<view class="r" v-if="item.price>0">{{item.price}}元</view>
+								<view class="r" v-else>无需缴费</view>
 						</label>
 					</view>
 				</u-checkbox-group>

+ 1 - 1
sp-admin/static/sa.js

@@ -22,7 +22,7 @@ var sa = {
 		api_url: 'https://dxkaa1.bgigc.com/pro',
 		web_url: 'http://www.baidu.com'
 	}
-	sa.cfg = cfg_dev; // 最终环境 , 上线前请选择正确的环境
+	sa.cfg = cfg_test; // 最终环境 , 上线前请选择正确的环境
 })();
 
 

+ 11 - 9
sp-server/src/main/java/com/pj/api/open/service/OpenService.java

@@ -61,7 +61,8 @@ public class OpenService {
         Date now = new Date();
         if (tbBusinessCar == null || (tbBusinessCar.getRealInTime() != null && tbBusinessCar.getRealOutTime() != null)) {
             tbBusinessCar = new TbBusinessCar();
-            tbBusinessCar.setCarNo(carNo).setPay(0).setCarSize(3D).setIsLock(0).setInChannel(channel).setRealInTime(now);
+            tbBusinessCar.setCarNo(carNo).setPay(0).setCarSize(3D).setIsLock(0)
+                    .setInChannel(channel).setRealInTime(now).setBasePartMoney(new BigDecimal("0"));
             tbBusinessCarService.save(tbBusinessCar);
             return;
         }
@@ -85,6 +86,14 @@ public class OpenService {
         }
         Date now = new Date();
         String businessId = tbBusinessCar.getBusinessId();
+        BigDecimal price = tbBusinessService.calculationPartMoney(tbBusinessCar.getRealInTime(), now,StrUtil.isNotEmpty(businessId));
+        double dif = price.subtract(tbBusinessCar.getMoney()).doubleValue();
+        if (dif > 0) {
+            tbBusinessCar.setPay(0);
+            tbBusinessCarService.updateById(tbBusinessCar);
+            RedisUtil.set(channel, carNo);
+            return ResultJson.error("请缴停车费" + dif + "元");
+        }
         if (StrUtil.isEmpty(businessId)) {
             tbBusinessCar.setRealOutTime(now).setOutChannel(channel);
             tbBusinessCarService.updateById(tbBusinessCar);
@@ -103,14 +112,7 @@ public class OpenService {
                 return ResultJson.error("请缴纳业务费用");
             }
         }
-        BigDecimal price = tbBusinessService.calculationPartMoney(tbBusinessCar.getRealInTime(), now);
-        double dif = price.subtract(tbBusinessCar.getMoney()).doubleValue();
-        if (dif > 0) {
-            tbBusinessCar.setPay(0);
-            tbBusinessCarService.updateById(tbBusinessCar);
-            RedisUtil.set(channel, carNo);
-            return ResultJson.error("请缴停车费" + dif + "元");
-        }
+
         if (TbBusiness.BusinessType.CAR_DISINCLE.getCode().equals(business.getBusinessType()) && !business.getItemPrice().equals(itemPayPrice)) {
             return ResultJson.error("请缴纳业务费用");
         }

+ 3 - 1
sp-server/src/main/java/com/pj/api/service/ApiService.java

@@ -134,6 +134,8 @@ public class ApiService {
             TbBusiness tbBusiness = tbBusinessService.getById(businessId);
             return tbBusiness.getAdminConfirmInput() == 1;
         }).collect(Collectors.toList());
+       List<TbBusinessCar>cars= tbBusinessCarService.findTheNoBusinessCar(carNo);
+       list.addAll(cars);
         return list;
     }
 
@@ -153,7 +155,7 @@ public class ApiService {
             return result;
         }
         Date now = new Date();
-        BigDecimal price = tbBusinessService.calculationPartMoney(tbBusinessCar.getRealInTime(), now);
+        BigDecimal price = tbBusinessService.calculationPartMoney(tbBusinessCar.getRealInTime(), now,StrUtil.isNotEmpty(tbBusinessCar.getBusinessId()));
         BigDecimal dif = price.subtract(tbBusinessCar.getMoney());
         Map<String, Object> car = new HashMap<>();
         car.put("id", tbBusinessCar.getId());

+ 1 - 4
sp-server/src/main/java/com/pj/current/task/TokenTask.java

@@ -19,16 +19,14 @@ public class TokenTask implements Runnable {
 
     @Override
     public void run() {
-        log.info("start to get wx access token");
         String tokenKey = wxConfig.getAccessTokenKey();
         String ticketKey = wxConfig.getJsApiTicketKey();
         String tokenUrl = wxConfig.getAccessTokenUrl();
         String resp = HttpUtil.get(tokenUrl);
         JSONObject result = JSONUtil.parseObj(resp);
         String accessToken = result.getStr("access_token");
-        log.info("get access token result:{}", resp);
         if (StrUtil.isEmpty(accessToken)) {
-            log.error("=======获取accessToken失败==========");
+            log.error("get access token fail:{}", resp);
             return;
         }
         RedisUtil.set(tokenKey, accessToken);
@@ -36,7 +34,6 @@ public class TokenTask implements Runnable {
         String jsResp = HttpUtil.get(jsUrl);
         JSONObject jsResult = JSONUtil.parseObj(jsResp);
         String ticket = jsResult.getStr("ticket");
-        log.info("get js ticket result:{}", jsResult);
         if (StrUtil.isEmpty(ticket)) {
             log.error("=======ticket=====fail======");
             return;

+ 17 - 16
sp-server/src/main/java/com/pj/project/tb_business/TbBusinessService.java

@@ -412,7 +412,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
             iTime = tbBusiness.getChinaCarInTime();
             oTime = tbBusiness.getChinaCarOutTime();
         }
-        BigDecimal price = calculationPartMoney(iTime, oTime);
+        BigDecimal price = calculationPartMoney(iTime, oTime, true);
         if (itemType.contains("中国")) {
             int len = tbBusiness.getCardNo().split(" ").length;
             tbBusiness.setChinaPartMoney(price.multiply(new BigDecimal(len)));
@@ -422,7 +422,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
         tbBusiness.setTotalMoney(tbBusiness.getItemPrice().add(tbBusiness.getChinaPartMoney()).add(tbBusiness.getPartMoney()));
     }
 
-    public BigDecimal calculationPartMoney(Date iTime, Date oTime) {
+    public BigDecimal calculationPartMoney(Date iTime, Date oTime, boolean businessCar) {
         LocalDateTime inDayTime = iTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
         LocalDateTime outDayTime = oTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
         long minutes = ChronoUnit.MINUTES.between(inDayTime, outDayTime);
@@ -432,11 +432,16 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
         }
         long days = ChronoUnit.DAYS.between(inDayTime.toLocalDate(), outDayTime.toLocalDate());
         long hour = ChronoUnit.HOURS.between(inDayTime, outDayTime);
-        BigDecimal basePrice = partConfig.getBasePrice();
+        BigDecimal basePrice = businessCar ? partConfig.getBasePrice() : new BigDecimal("0");
+        BigDecimal p = partConfig.getBasePrice();//乘积因子
         BigDecimal extraPrice = partConfig.getExtraPrice();
-        return basePrice.add(basePrice.multiply(new BigDecimal(hour / 24))).add(new BigDecimal(days).multiply(extraPrice));
+        if (minutes>partConfig.getFreeMinutes()&&minutes<24*60){
+            days=1;
+        }
+        return basePrice.add(p.multiply(new BigDecimal(hour / 24))).add(new BigDecimal(days).multiply(extraPrice));
     }
 
+
     /**
      * @param carNo
      * @param inOrOut 1入 2出
@@ -468,23 +473,19 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
         String businessId = car.getBusinessId();
         result.put("businessId", businessId);
         List<TbBusinessCar> cars = tbBusinessCarService.findByBusinessId(businessId);
-        if (cars.isEmpty()){
+        if (cars.isEmpty()) {
             cars.add(car);
         }
         Date now = new Date();
         List<Map<String, Object>> carsList = new ArrayList<>();
         for (TbBusinessCar tbBusinessCar : cars) {
-            double partMoney = tbBusinessCar.getBasePartMoney().doubleValue();
-            if (!StrUtil.equals("STATE", state)) {
-                Date inTime = tbBusinessCar.getRealInTime();
-                if (inTime != null) {
-                    BigDecimal price = this.calculationPartMoney(inTime, now);
-                    BigDecimal money = tbBusinessCar.getMoney();
-                    BigDecimal basePrice = tbBusinessCar.getBasePartMoney();
-                    partMoney = money == null ? price.subtract(basePrice).doubleValue() : price.subtract(money).doubleValue();
-                } else {
-                    partMoney = 0D;
-                }
+            BigDecimal basePrice = StrUtil.isEmpty(tbBusinessCar.getBusinessId()) ? new BigDecimal("0") : tbBusinessCar.getBasePartMoney();
+            double partMoney = basePrice.doubleValue();
+            Date inTime = tbBusinessCar.getRealInTime();
+            if (inTime != null) {
+                BigDecimal price = this.calculationPartMoney(inTime, now, StrUtil.isNotEmpty(tbBusinessCar.getBusinessId()));
+                BigDecimal money = tbBusinessCar.getMoney();
+                partMoney = money == null ? price.subtract(basePrice).doubleValue() : price.subtract(money).doubleValue();
             }
             Map<String, Object> carMap = new HashMap<>();
             carMap.put("price", partMoney);

+ 2 - 0
sp-server/src/main/java/com/pj/project/tb_business_car/TbBusinessCarMapper.java

@@ -28,4 +28,6 @@ public interface TbBusinessCarMapper extends BaseMapper <TbBusinessCar> {
 
 
     List<TbBusinessCar> searchPartCar(String carNo);
+
+	List<TbBusinessCar> findTheNoBusinessCar(String carNo);
 }

+ 8 - 0
sp-server/src/main/java/com/pj/project/tb_business_car/TbBusinessCarMapper.xml

@@ -63,6 +63,14 @@
             AND b.total_money> b.pay_money
             AND a.car_no LIKE CONCAT( '%', #{carNo}, '%' )
 	</select>
+    <select id="findTheNoBusinessCar" resultType="com.pj.project.tb_business_car.TbBusinessCar">
+            SELECT * from tb_business_car
+             WHERE (business_id is null or business_id='')
+             and car_no like CONCAT('%',#{carNo},'%')
+             and real_in_time is not null
+             and real_out_time is null
+             AND pay=0
+    </select>
 
 
 </mapper>

+ 3 - 0
sp-server/src/main/java/com/pj/project/tb_business_car/TbBusinessCarService.java

@@ -253,4 +253,7 @@ public class TbBusinessCarService extends ServiceImpl<TbBusinessCarMapper, TbBus
 
     }
 
+    public List<TbBusinessCar> findTheNoBusinessCar(String carNo) {
+        return tbBusinessCarMapper.findTheNoBusinessCar(carNo);
+    }
 }

+ 1 - 1
sp-server/src/main/resources/application-dev.yml

@@ -49,7 +49,7 @@ spring:
         web-domain: https://127.0.0.1:8080
 part-config:
     base-price: 30 #基础费用
-    extra-price: 0.01 #过夜额外收费
+    extra-price: 10 #过夜额外收费
     night-end: 06:00:00 #夜间结束时间
     free-minutes: 30
     free-car-length: 4.2