1616import com .java110 .intf .acct .ICouponPropertyPoolDetailV1InnerServiceSMO ;
1717import com .java110 .intf .acct .ICouponPropertyPoolV1InnerServiceSMO ;
1818import com .java110 .intf .acct .ICouponPropertyUserV1InnerServiceSMO ;
19+ import com .java110 .intf .job .IIotInnerServiceSMO ;
1920import com .java110 .intf .user .IOwnerV1InnerServiceSMO ;
2021import com .java110 .po .coupon .CouponPropertyPoolPo ;
2122import com .java110 .po .coupon .CouponPropertyPoolDetailPo ;
2425import com .java110 .utils .lock .DistributedLock ;
2526import com .java110 .utils .util .Assert ;
2627import com .java110 .utils .util .DateUtil ;
28+ import com .java110 .utils .util .ListUtil ;
2729import com .java110 .vo .ResultVo ;
2830import org .springframework .beans .factory .annotation .Autowired ;
2931
@@ -76,6 +78,9 @@ public class GiftCouponPropertyCmd extends Cmd{
7678 @ Autowired
7779 private ICouponPropertyUserV1InnerServiceSMO couponPropertyUserV1InnerServiceSMOImpl ;
7880
81+ @ Autowired
82+ private IIotInnerServiceSMO iotInnerServiceSMOImpl ;
83+
7984
8085 @ Override
8186 public void validate (CmdEvent event , ICmdDataFlowContext context , JSONObject reqJson ) throws CmdException {
@@ -93,7 +98,7 @@ public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJso
9398 ownerDto .setCommunityId (reqJson .getString ("communityId" ));
9499 List <OwnerDto > ownerDtos = ownerV1InnerServiceSMOImpl .queryOwners (ownerDto );
95100
96- if (ownerDtos == null || ownerDtos . size ()< 1 ){
101+ if (ListUtil . isNull ( ownerDtos ) ){
97102 throw new CmdException ("根据手机号未查询到业主" );
98103 }
99104
@@ -106,7 +111,7 @@ public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJso
106111 couponPropertyPoolDto .setCppId (reqJson .getString ("cppId" ));
107112 List <CouponPropertyPoolDto > couponPropertyPoolDtos = couponPropertyPoolV1InnerServiceSMOImpl .queryCouponPropertyPools (couponPropertyPoolDto );
108113
109- if (couponPropertyPoolDtos == null || couponPropertyPoolDtos . size () < 1 ) {
114+ if (ListUtil . isNull ( couponPropertyPoolDtos ) ) {
110115 return ;
111116 }
112117
@@ -152,7 +157,6 @@ public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJso
152157 if (flag < 1 ){
153158 throw new CmdException ("赠送失败" );
154159 }
155-
156160 //用户账户写入优惠券
157161 CouponPropertyUserPo couponPropertyUserPo = new CouponPropertyUserPo ();
158162 couponPropertyUserPo .setCommunityId (couponPropertyPoolDtos .get (0 ).getCommunityId ());
@@ -168,10 +172,12 @@ public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJso
168172 couponPropertyUserPo .setTel (ownerDtos .get (0 ).getLink ());
169173 couponPropertyUserPo .setValue (value );
170174 couponPropertyUserPo .setStartTime (DateUtil .getNow (DateUtil .DATE_FORMATE_STRING_B ));
171- flag = couponPropertyUserV1InnerServiceSMOImpl .saveCouponPropertyUser (couponPropertyUserPo );
172-
173- if (flag < 1 ){
174- throw new CmdException ("保存赠送业主记录失败" );
175+ // todo 充点券 同步物联网
176+ if (CouponPropertyUserDto .TO_TYPE_CHARGE .equals (couponPropertyPoolDtos .get (0 ).getToType ())){
177+ // todo 优惠券写到物联网系统
178+ iotInnerServiceSMOImpl .sendChargeCoupon (couponPropertyUserPo );
179+ }else {
180+ couponPropertyUserV1InnerServiceSMOImpl .saveCouponPropertyUser (couponPropertyUserPo );
175181 }
176182 } finally {
177183 DistributedLock .releaseDistributedLock (requestId , key );
0 commit comments