wuxw 1 gadu atpakaļ
vecāks
revīzija
8dc5beb98a

+ 3 - 0
java110-interface/src/main/java/com/java110/intf/job/IIotInnerServiceSMO.java

@@ -9,6 +9,7 @@ import com.java110.dto.machine.CarInoutDto;
 import com.java110.dto.machine.MachineDto;
 import com.java110.dto.system.Business;
 import com.java110.dto.user.UserDto;
+import com.java110.po.coupon.CouponPropertyUserPo;
 import com.java110.vo.ResultVo;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -51,4 +52,6 @@ public interface IIotInnerServiceSMO {
 
     @RequestMapping(value = "/sendUserInfo", method = RequestMethod.POST)
     ResultVo  sendUserInfo(@RequestBody UserDto userDto);
+    @RequestMapping(value = "/sendChargeCoupon", method = RequestMethod.POST)
+    ResultVo  sendChargeCoupon(@RequestBody CouponPropertyUserPo couponPropertyUserPo);
 }

+ 13 - 7
service-acct/src/main/java/com/java110/acct/cmd/couponProperty/GiftCouponPropertyCmd.java

@@ -16,6 +16,7 @@ import com.java110.intf.acct.ICouponPropertyPoolConfigV1InnerServiceSMO;
 import com.java110.intf.acct.ICouponPropertyPoolDetailV1InnerServiceSMO;
 import com.java110.intf.acct.ICouponPropertyPoolV1InnerServiceSMO;
 import com.java110.intf.acct.ICouponPropertyUserV1InnerServiceSMO;
+import com.java110.intf.job.IIotInnerServiceSMO;
 import com.java110.intf.user.IOwnerV1InnerServiceSMO;
 import com.java110.po.coupon.CouponPropertyPoolPo;
 import com.java110.po.coupon.CouponPropertyPoolDetailPo;
@@ -24,6 +25,7 @@ import com.java110.utils.exception.CmdException;
 import com.java110.utils.lock.DistributedLock;
 import com.java110.utils.util.Assert;
 import com.java110.utils.util.DateUtil;
+import com.java110.utils.util.ListUtil;
 import com.java110.vo.ResultVo;
 import org.springframework.beans.factory.annotation.Autowired;
 
@@ -76,6 +78,9 @@ public class GiftCouponPropertyCmd extends Cmd{
     @Autowired
     private ICouponPropertyUserV1InnerServiceSMO couponPropertyUserV1InnerServiceSMOImpl;
 
+    @Autowired
+    private IIotInnerServiceSMO iotInnerServiceSMOImpl;
+
 
     @Override
     public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException {
@@ -93,7 +98,7 @@ public class GiftCouponPropertyCmd extends Cmd{
         ownerDto.setCommunityId(reqJson.getString("communityId"));
         List<OwnerDto> ownerDtos = ownerV1InnerServiceSMOImpl.queryOwners(ownerDto);
 
-        if(ownerDtos == null || ownerDtos.size()< 1){
+        if(ListUtil.isNull(ownerDtos)){
             throw new CmdException("根据手机号未查询到业主");
         }
 
@@ -106,7 +111,7 @@ public class GiftCouponPropertyCmd extends Cmd{
             couponPropertyPoolDto.setCppId(reqJson.getString("cppId"));
             List<CouponPropertyPoolDto> couponPropertyPoolDtos = couponPropertyPoolV1InnerServiceSMOImpl.queryCouponPropertyPools(couponPropertyPoolDto);
 
-            if (couponPropertyPoolDtos == null || couponPropertyPoolDtos.size() < 1) {
+            if (ListUtil.isNull(couponPropertyPoolDtos)) {
                 return;
             }
 
@@ -152,7 +157,6 @@ public class GiftCouponPropertyCmd extends Cmd{
             if(flag < 1){
                 throw new CmdException("赠送失败");
             }
-
             //用户账户写入优惠券
             CouponPropertyUserPo couponPropertyUserPo = new CouponPropertyUserPo();
             couponPropertyUserPo.setCommunityId(couponPropertyPoolDtos.get(0).getCommunityId());
@@ -168,10 +172,12 @@ public class GiftCouponPropertyCmd extends Cmd{
             couponPropertyUserPo.setTel(ownerDtos.get(0).getLink());
             couponPropertyUserPo.setValue(value);
             couponPropertyUserPo.setStartTime(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_B));
-            flag = couponPropertyUserV1InnerServiceSMOImpl.saveCouponPropertyUser(couponPropertyUserPo);
-
-            if(flag < 1){
-                throw new CmdException("保存赠送业主记录失败");
+            // todo 充点券 同步物联网
+            if(CouponPropertyUserDto.TO_TYPE_CHARGE.equals(couponPropertyPoolDtos.get(0).getToType())){
+                // todo 优惠券写到物联网系统
+                iotInnerServiceSMOImpl.sendChargeCoupon(couponPropertyUserPo);
+            }else{
+                couponPropertyUserV1InnerServiceSMOImpl.saveCouponPropertyUser(couponPropertyUserPo);
             }
         } finally {
             DistributedLock.releaseDistributedLock(requestId, key);

+ 11 - 1
service-job/src/main/java/com/java110/job/adapt/payment/coupon/PayFeeGiftCouponAdapt.java

@@ -21,6 +21,7 @@ import com.java110.intf.community.ICommunityInnerServiceSMO;
 import com.java110.intf.fee.IFeeAttrInnerServiceSMO;
 import com.java110.intf.fee.IFeeDetailInnerServiceSMO;
 import com.java110.intf.fee.IFeeInnerServiceSMO;
+import com.java110.intf.job.IIotInnerServiceSMO;
 import com.java110.job.adapt.DatabusAdaptImpl;
 import com.java110.po.coupon.CouponPropertyPoolPo;
 import com.java110.po.coupon.CouponPropertyPoolDetailPo;
@@ -84,6 +85,9 @@ public class PayFeeGiftCouponAdapt extends DatabusAdaptImpl {
     @Autowired
     private ICouponPropertyUserV1InnerServiceSMO couponPropertyUserV1InnerServiceSMOImpl;
 
+    @Autowired
+    private IIotInnerServiceSMO iotInnerServiceSMOImpl;
+
 
     @Autowired
     private IComputeFeeSMO computeFeeSMOImpl;
@@ -303,7 +307,13 @@ public class PayFeeGiftCouponAdapt extends DatabusAdaptImpl {
             couponPropertyUserPo.setTel(FeeAttrDto.getFeeAttrValue(feeDto, FeeAttrDto.SPEC_CD_OWNER_LINK));
             couponPropertyUserPo.setValue(value);
             couponPropertyUserPo.setStartTime(startTime);
-            couponPropertyUserV1InnerServiceSMOImpl.saveCouponPropertyUser(couponPropertyUserPo);
+            // todo 充点券 同步物联网
+            if(CouponPropertyUserDto.TO_TYPE_CHARGE.equals(couponPropertyPoolDtos.get(0).getToType())){
+                // todo 优惠券写到物联网系统
+                iotInnerServiceSMOImpl.sendChargeCoupon(couponPropertyUserPo);
+            }else{
+                couponPropertyUserV1InnerServiceSMOImpl.saveCouponPropertyUser(couponPropertyUserPo);
+            }
             //这里更新功能 关闭 因为优惠券有有效期 如果 修改显然不合适 modify by  2022-11-24 wuxw
 //            }else{
 //                couponPropertyUserPo.setCouponId(couponPropertyUserDtos.get(0).getCouponId());

+ 16 - 0
service-job/src/main/java/com/java110/job/smo/impl/IotInnerServiceSMOImpl.java

@@ -11,7 +11,9 @@ import com.java110.dto.user.UserDto;
 import com.java110.intf.job.IIotInnerServiceSMO;
 import com.java110.intf.user.IOwnerAppUserV1InnerServiceSMO;
 import com.java110.job.adapt.hcIot.http.ISendIot;
+import com.java110.po.coupon.CouponPropertyUserPo;
 import com.java110.utils.cache.MappingCache;
+import com.java110.utils.util.BeanConvertUtil;
 import com.java110.utils.util.ListUtil;
 import com.java110.utils.util.StringUtil;
 import com.java110.vo.ResultVo;
@@ -124,4 +126,18 @@ public class IotInnerServiceSMOImpl extends BaseServiceSMO implements IIotInnerS
         return resultVo;
     }
 
+    @Override
+    public ResultVo sendChargeCoupon(CouponPropertyUserPo couponPropertyUserPo) {
+        String iotSwitch = MappingCache.getValue("IOT", "IOT_SWITCH");
+
+        if (!"ON".equals(iotSwitch)) {
+            return new ResultVo(ResultVo.CODE_OK, ResultVo.MSG_OK);
+        }
+        JSONObject paramIn = BeanConvertUtil.beanCovertJson(couponPropertyUserPo);
+        paramIn.put("iotApiCode", "sendChargeCoupon");
+        ResultVo resultVo = sendIotImpl.post("/iot/api/common.openCommonApi", paramIn);
+
+        return resultVo;
+    }
+
 }