修改机构折扣

This commit is contained in:
yuyang 2022-03-25 09:39:19 +08:00
parent 73c8f1816e
commit 88c7918752
9 changed files with 58 additions and 56 deletions

View File

@ -43,7 +43,7 @@ public interface PileOrderService {
* @param orderNo 订单号 * @param orderNo 订单号
* @return * @return
*/ */
@PostMapping("/chargeOrder/pileEndOrder") @GetMapping("/chargeOrder/pileEndOrder")
R pileEndOrder(@RequestParam(value = "orderNo") String orderNo); R pileEndOrder(@RequestParam(value = "orderNo") String orderNo);

View File

@ -48,7 +48,7 @@ public interface UserTypeService {
* 获取该机构的折扣比例 * 获取该机构的折扣比例
*/ */
@GetMapping("/common/getMechanismDiscount") @GetMapping("/common/getMechanismDiscount")
R getMechanismDiscount(@RequestParam(value = "userId")Long userId, @RequestParam(value = "userType")Integer userType, @RequestParam(value = "tenantId")String tenantId, @Param("chargingStationId")Long chargingStationId); R getMechanismDiscount(@RequestParam(value = "userId")Long userId, @RequestParam(value = "userType")Integer userType, @RequestParam(value = "tenantId")String tenantId,@RequestParam(value = "chargingStationId")Long chargingStationId);
} }

View File

@ -2,7 +2,6 @@ package com.xhpc.common.api.factory;
import com.xhpc.common.api.UserTypeService; import com.xhpc.common.api.UserTypeService;
import com.xhpc.common.core.domain.R; import com.xhpc.common.core.domain.R;
import org.apache.ibatis.annotations.Param;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory; import org.springframework.cloud.openfeign.FallbackFactory;
@ -33,7 +32,7 @@ public class UserTypeFallbackFactory implements FallbackFactory<UserTypeService>
} }
@Override @Override
public R getMechanismDiscount(Long userId, Integer userType, String tenantId, @Param("chargingStationId")Long chargingStationId) { public R getMechanismDiscount(Long userId, Integer userType, String tenantId,Long chargingStationId) {
return R.fail("机构信息获取失败:" + cause.getMessage()); return R.fail("机构信息获取失败:" + cause.getMessage());
} }
}; };

View File

@ -5,7 +5,6 @@ import com.xhpc.databigscreen.domain.CoreParam;
import com.xhpc.databigscreen.domain.OrderRatio; import com.xhpc.databigscreen.domain.OrderRatio;
import com.xhpc.databigscreen.domain.OrderTrend; import com.xhpc.databigscreen.domain.OrderTrend;
import com.xhpc.databigscreen.domain.RealtimeOrders; import com.xhpc.databigscreen.domain.RealtimeOrders;
import org.graalvm.compiler.hotspot.replacements.ObjectCloneNode;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;

View File

@ -21,10 +21,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
@ -247,7 +244,7 @@ public class XhpcPileOrderController extends BaseController {
* 桩订单结束回调 * 桩订单结束回调
*/ */
@Transactional @Transactional
@PostMapping("/chargeOrder/pileEndOrder") @GetMapping(value = "/chargeOrder/pileEndOrder")
public R pileEndOrder(@RequestParam(value = "orderNo") String orderNo) { public R pileEndOrder(@RequestParam(value = "orderNo") String orderNo) {
logger.info("桩订单结束回调>>>>>orderNo"+orderNo); logger.info("桩订单结束回调>>>>>orderNo"+orderNo);
try{ try{

View File

@ -447,49 +447,52 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
if ( !UserTypeUtil.INTERNET_TYPE.equals(source)) { if ( !UserTypeUtil.INTERNET_TYPE.equals(source)) {
if(UserTypeUtil.COMMUNIT_TYPE.equals(source) || UserTypeUtil.CUSTOMERS_TYPE.equals(source)){ if(UserTypeUtil.COMMUNIT_TYPE.equals(source) || UserTypeUtil.CUSTOMERS_TYPE.equals(source)){
//折扣机构用户没有活动时计算 //折扣机构用户没有活动时计算
R mechanismDiscount = userTypeService.getMechanismDiscount(userId, source, xhpcChargeOrder.getTenantId(),xhpcChargeOrder.getChargingStationId()); if(xhpcChargeOrder.getChargingStationId()!=null){
if(mechanismDiscount !=null && mechanismDiscount.getData() !=null) { R mechanismDiscount = userTypeService.getMechanismDiscount(userId, source, xhpcChargeOrder.getTenantId(),xhpcChargeOrder.getChargingStationId());
Map<String, Object> userDiscount = (Map<String, Object>) mechanismDiscount.getData();
if (userDiscount != null && userDiscount.get("commissionType") != null && userDiscount.get("servicePreferential") != null) {
String commissionType = userDiscount.get("commissionType").toString();
BigDecimal servicePreferential =new BigDecimal(userDiscount.get("servicePreferential").toString()).divide(new BigDecimal(100),2,BigDecimal.ROUND_HALF_UP);
if(servicePreferential.compareTo(new BigDecimal(0))==1){ if(mechanismDiscount !=null && mechanismDiscount.getData() !=null) {
if("0".equals(commissionType) || "1".equals(commissionType) || "2".equals(commissionType)){ Map<String, Object> userDiscount = (Map<String, Object>) mechanismDiscount.getData();
BigDecimal decimal1 = surplusPowerPrice.multiply(servicePreferential).setScale(2, BigDecimal.ROUND_HALF_UP); if (userDiscount != null && userDiscount.get("commissionType") != null && userDiscount.get("servicePreferential") != null) {
BigDecimal decimal2 = surplusServicePrice.multiply(servicePreferential).setScale(2, BigDecimal.ROUND_HALF_UP); String commissionType = userDiscount.get("commissionType").toString();
if("0".equals(commissionType)){ BigDecimal servicePreferential =new BigDecimal(userDiscount.get("servicePreferential").toString()).divide(new BigDecimal(100),2,BigDecimal.ROUND_HALF_UP);
//总金额
actPrice =actPrice.subtract(decimal1.add(decimal2)); if(servicePreferential.compareTo(new BigDecimal(0))==1){
//折扣的钱 if("0".equals(commissionType) || "1".equals(commissionType) || "2".equals(commissionType)){
promotionDiscount = decimal1.add(decimal2); BigDecimal decimal1 = surplusPowerPrice.multiply(servicePreferential).setScale(2, BigDecimal.ROUND_HALF_UP);
surplusPowerPrice = surplusPowerPrice.subtract(decimal1); BigDecimal decimal2 = surplusServicePrice.multiply(servicePreferential).setScale(2, BigDecimal.ROUND_HALF_UP);
surplusServicePrice= surplusServicePrice.subtract(decimal2); if("0".equals(commissionType)){
}else if("1".equals(commissionType)){ //总金额
//服务费 actPrice =actPrice.subtract(decimal1.add(decimal2));
if(surplusServicePrice.compareTo(decimal2) > -1){ //折扣的钱
surplusServicePrice =surplusServicePrice.subtract(decimal2); promotionDiscount = decimal1.add(decimal2);
actPrice =actPrice.subtract(decimal2); surplusPowerPrice = surplusPowerPrice.subtract(decimal1);
surplusServicePrice= surplusServicePrice.subtract(decimal2);
}else if("1".equals(commissionType)){
//服务费
if(surplusServicePrice.compareTo(decimal2) > -1){
surplusServicePrice =surplusServicePrice.subtract(decimal2);
actPrice =actPrice.subtract(decimal2);
}else{
promotionDiscount = surplusServicePrice;
actPrice =actPrice.subtract(surplusServicePrice);
surplusServicePrice =new BigDecimal(0);
}
}else{ }else{
promotionDiscount = surplusServicePrice; //电量抽成
actPrice =actPrice.subtract(surplusServicePrice); BigDecimal chargingDegree = xhpcChargeOrder.getChargingDegree();
surplusServicePrice =new BigDecimal(0); //电量的钱
} promotionDiscount = chargingDegree.multiply(new BigDecimal(userDiscount.get("servicePreferential").toString())).setScale(2, BigDecimal.ROUND_HALF_UP);
}else{ logger.info("=============电量优惠==="+promotionDiscount);
//电量抽成 logger.info("=============服务费==="+surplusServicePrice);
BigDecimal chargingDegree = xhpcChargeOrder.getChargingDegree(); //当电量的折扣大于服务费时电量==服务费
//电量的钱 if(surplusServicePrice.compareTo(promotionDiscount)>-1){
promotionDiscount = chargingDegree.multiply(new BigDecimal(userDiscount.get("servicePreferential").toString())).setScale(2, BigDecimal.ROUND_HALF_UP); surplusServicePrice= surplusServicePrice.subtract(promotionDiscount);
logger.info("=============电量优惠==="+promotionDiscount); actPrice =actPrice.subtract(promotionDiscount);
logger.info("=============服务费==="+surplusServicePrice); }else{
//当电量的折扣大于服务费时电量==服务费 promotionDiscount = surplusServicePrice;
if(surplusServicePrice.compareTo(promotionDiscount)>-1){ actPrice =actPrice.subtract(surplusServicePrice);
surplusServicePrice= surplusServicePrice.subtract(promotionDiscount); surplusServicePrice =new BigDecimal(0);
actPrice =actPrice.subtract(promotionDiscount); }
}else{
promotionDiscount = surplusServicePrice;
actPrice =actPrice.subtract(surplusServicePrice);
surplusServicePrice =new BigDecimal(0);
} }
} }
} }

View File

@ -462,6 +462,8 @@
from xhpc_community co from xhpc_community co
join xhpc_mechanism me on me.mechanism_id = co.community_id and me.source = 0 and me.del_flag =0 join xhpc_mechanism me on me.mechanism_id = co.community_id and me.source = 0 and me.del_flag =0
where co.community_id = (select community_id from xhpc_community_personnel where community_personnel_id=#{userId} and tenant_id=#{tenantId} and del_flag =0) where co.community_id = (select community_id from xhpc_community_personnel where community_personnel_id=#{userId} and tenant_id=#{tenantId} and del_flag =0)
and me.charging_station_id=#{chargingStationId} <if test="chargingStationId !=null">
and me.charging_station_id=#{chargingStationId}
</if>
</select> </select>
</mapper> </mapper>

View File

@ -459,6 +459,8 @@
from xhpc_customers co from xhpc_customers co
join xhpc_mechanism me on me.mechanism_id = co.customers_id and me.source = 1 and me.del_flag =0 join xhpc_mechanism me on me.mechanism_id = co.customers_id and me.source = 1 and me.del_flag =0
where co.customers_id = (select customers_id from xhpc_customers_personnel where customers_personnel_id=#{userId} and tenant_id=#{tenantId} and del_flag =0) where co.customers_id = (select customers_id from xhpc_customers_personnel where customers_personnel_id=#{userId} and tenant_id=#{tenantId} and del_flag =0)
and me.charging_station_id=#{chargingStationId} <if test="chargingStationId !=null">
and me.charging_station_id=#{chargingStationId}
</if>
</select> </select>
</mapper> </mapper>

View File

@ -355,13 +355,13 @@
order by totalPrice desc) us on xaus.app_user_id = us.appUserId order by totalPrice desc) us on xaus.app_user_id = us.appUserId
where xaus.del_flag = 0 where xaus.del_flag = 0
<if test="activity !=null"> <if test="activity !=null">
and activity &gt;= #{activity} and us.activity &gt;= #{activity}
</if> </if>
<if test="frequency !=null"> <if test="frequency !=null">
and frequency &gt;= #{frequency} and us.number &gt;= #{frequency}
</if> </if>
<if test="amount !=null"> <if test="amount !=null">
and amount &gt;= #{amount} and us.amount &gt;= #{amount}
</if> </if>
<if test="tenantId !=null and tenantId !=''"> <if test="tenantId !=null and tenantId !=''">
and xaus.tenant_id =#{tenantId} and xaus.tenant_id =#{tenantId}