xinyb
2024-07-19 d0bd1e17f0265b7190ad3492b79b3ca02b7a983f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
package com.yc.sdk.miniapp.action;
 
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.yc.action.BaseAction;
import com.yc.entity.DataSourceEntity;
import com.yc.entity.UserAccountEntity;
import com.yc.multiData.MultiDataSource;
import com.yc.multiData.SpObserver;
import com.yc.sdk.miniapp.entity.EducationEntity;
import com.yc.sdk.miniapp.entity.MaCompanyEntity;
import com.yc.sdk.miniapp.entity.OrganizationEntity;
import com.yc.sdk.miniapp.service.MaUserIfc;
import com.yc.sdk.shopping.action.api.MatCode;
import com.yc.sdk.shopping.action.api.ShopCcCode;
import com.yc.sdk.shopping.entity.DepartmentEntity;
import com.yc.sdk.shopping.entity.MatCodeEntity;
import com.yc.sdk.shopping.entity.SettingEntity;
import com.yc.sdk.shopping.entity.ShopCcCodeEntity;
import com.yc.sdk.shopping.service.MatCodeIfc;
import com.yc.sdk.shopping.service.SettingIfc;
import com.yc.sdk.shopping.service.department.DepartmentIfc;
import com.yc.sdk.shopping.service.imagedata.ShoppingImageDataIfc;
import com.yc.sdk.shopping.util.SettingKey;
import com.yc.sdk.weixincp.entity.MyWxCpUser;
import com.yc.sdk.weixincp.service.ERPUserIfc;
import com.yc.sdk.weixinmp.entity.MyWxMpUser;
import com.yc.service.user.UserAccountServiceIfc;
import com.yc.utils.SessionKey;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
 
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.List;
 
@Controller
public class MaCardUserInfo extends BaseAction{
    @Autowired
    ERPUserIfc erpUserIfc ;
    @Autowired
    MaUserIfc maUserIfc ;
    @Autowired
    SettingIfc settingIfc;
    @Autowired
    ShoppingImageDataIfc imgData;
    @Autowired
    UserAccountServiceIfc userAccountService;
    @Autowired
    DepartmentIfc departmentIfc ;
    // 商品资料
    @Autowired
    MatCodeIfc matCodeIfc;
 
    /**
     * 获取我的名片列表
     * @param request
     * @param response
     * @throws ServletException
     */
    @RequestMapping("/wx/getCardUserList.do")
    public void getCardUserList(HttpServletRequest request, HttpServletResponse response) throws ServletException {
        HttpSession session=request.getSession();
        
        //String fromUserId = request.getParameter(SettingKey.FROMUSERID) ;
        
        JsonObject json = new JsonObject();
        JsonObject errJson = new JsonObject();
//        if (fromUserId == null || "".equals(fromUserId)) {
//            errJson.addProperty("warning","必须传递 " + SettingKey.FROMUSERID +" 参数");
//            json.add("error", errJson);
//            this.printJson(response, json.toString());
//            return;    
//        }
        
        String dbId =  (String) session.getAttribute(SessionKey.SHOPPING_DBID);
        if (dbId == null || "".equals(dbId)) {
            dbId = (session.getAttribute(SessionKey.DATA_BASE_ID)== null?null :
                (String) session.getAttribute(SessionKey.DATA_BASE_ID));
        }
        String corpId = request.getParameter(SessionKey.WEIXIN_CORPID) ;
        if (corpId == null || "".equals(corpId)) {
            corpId = request.getParameter(SessionKey.WEIXIN_APPID) ;
        }
        if (corpId == null || "".equals(corpId)) {
            corpId = (String) session.getAttribute(SessionKey.WEIXIN_CORPID);
        }
        if (corpId == null || "".equals(corpId)) {
            errJson.addProperty("warning","必须传递 AppId 参数");
            json.add("error", errJson);
            this.printJson(response, json.toString());
            return;    
        }
        
          String openId = request.getParameter(SessionKey.WEIXIN_OPENID);
        if (openId == null || "".equals(openId)) {
            openId = (String)session.getAttribute(SessionKey.WEIXIN_OPENID);
        }
        if (openId == null|| "".equals(openId)) {
            errJson.addProperty("warning", "必须传递 OpenId 参数");
            json.add("error", errJson);
            this.printJson(response, json.toString());
            return;    
        }      
 
        String hostUrl = SettingKey.getHostUrl(request) ;
        DataSourceEntity dataSourceEntity = null ;
        try {
            dataSourceEntity = MultiDataSource.getDataSourceMap( request) ;
            if (dataSourceEntity == null) {
                errJson.addProperty("warning", "未找到数据源【"+ dbId+"】【CorpId:"+ corpId+ "】,请在数据源中设置好【名片】");
                json.add("error", errJson);
                this.printJson(response, json.toString());
                return;    
            }
            
            if (SpObserver.isDemoInstance("_"+dataSourceEntity.getDbId() )) {
                errJson.addProperty("warning", "未找到数据源【"+ dataSourceEntity.getDbId()+"】【CorpId:"+ corpId+ "】,请在数据源中设置好【名片】");
                json.add("error", errJson);
                this.printJson(response, json.toString());
                return;    
            }
        }catch (Exception e) {
            e.printStackTrace();
            errJson.addProperty("warning",e.getCause()!=null? e.getCause().getMessage():e.getMessage());
            json.add("error", errJson);
            this.printJson(response, json.toString());
            return;    
        }
 
        
        try {
            SpObserver.setDBtoInstance("_"+dataSourceEntity.getDbId());//切换数据源
            SettingEntity settingEntity = settingIfc.getSettingEntity(request) ;
            
            //取网店 shopcccode
            ShopCcCodeEntity shopCcCodeEntity = ShopCcCode.getShopCcCode(settingEntity,request);
            
            //向后台导购发送AI提示消息 
            List<MyWxCpUser> userList = maUserIfc.getKeFuUserList(openId,shopCcCodeEntity.getShopCcCode()) ;
            JsonArray matCodeJsonArray = new JsonArray();
            for(int i = 0;userList !=null && i<userList.size();i++) {
                MyWxCpUser myWxCpUser = userList.get(i) ;
                JsonObject jsonObject = new JsonObject();
                jsonObject.addProperty("UserId", myWxCpUser.getUserId()==null?"":myWxCpUser.getUserId());
                jsonObject.addProperty("Name", myWxCpUser.getName()==null?"":myWxCpUser.getName());
                jsonObject.addProperty("Position", myWxCpUser.getPosition()==null?"":myWxCpUser.getPosition());
                jsonObject.addProperty("Mobile", myWxCpUser.getMobile()==null?"":myWxCpUser.getMobile());
                jsonObject.addProperty("Telephone", myWxCpUser.getTelephone()==null?"":myWxCpUser.getTelephone());
                jsonObject.addProperty("WeiXinUserCode", myWxCpUser.getWeiXinUserCode()==null?"":myWxCpUser.getWeiXinUserCode());
                jsonObject.addProperty("EMail", myWxCpUser.getEmail()==null?"":myWxCpUser.getEmail());
                
                String defaultAvatar = myWxCpUser.getAvatar()==null?"":myWxCpUser.getAvatar() ;
                
                if ((defaultAvatar==null||"".equals(defaultAvatar)) && myWxCpUser.getAvatarUnid() != null && !"".equals(myWxCpUser.getAvatarUnid())) {
                    defaultAvatar = imgData.getImageUrl(myWxCpUser.getAvatarUnid(),settingEntity.getImageThumbWidth(),settingEntity.getImageThumbHeight(),settingEntity.isShowThumbOrgImage(),settingEntity.isFromCached(),request);
                }
 
                if (defaultAvatar==null||"".equals(defaultAvatar)) {
                    defaultAvatar = hostUrl + "/shopping/weixinby3rd/setting/image/defaultavatar.png" ;
                }
                
                jsonObject.addProperty("Avatar",defaultAvatar );
                
                String companyName = "" ,address = "",longitude = "" ,latitude = "",industryTypeName = "",companyPhoto = "" ;
                UserAccountEntity userAccount = userAccountService.getUserInfoByWeiXinCorpUserId(myWxCpUser.getUserId()==null?"":myWxCpUser.getUserId()) ;
                DepartmentEntity departmentEntity = null ;
                if (userAccount != null  ) {
                    MaCompanyEntity maCompanyEntity = erpUserIfc.getMaCompanyEntity(userAccount.getCompanyId());
                    companyName = (maCompanyEntity.getCompanyName()==null?"":maCompanyEntity.getCompanyName()+" ") ;
                    address = (maCompanyEntity.getAddress()==null?"":maCompanyEntity.getAddress()) ;
                    longitude = maCompanyEntity.getLongitude()==null?"":maCompanyEntity.getLongitude() ;
                    latitude = maCompanyEntity.getLatitude()==null?"":maCompanyEntity.getLatitude() ;
                    companyPhoto = imgData.getImageUrl(maCompanyEntity.getPhoto(),settingEntity.getImageThumbWidth(),settingEntity.getImageThumbHeight(),true,settingEntity.isFromCached(),request);  
                    industryTypeName = erpUserIfc.getIndustryTypeName(maCompanyEntity.getCompanyId()) ;
                    if (userAccount.getCcCode()!=null && !"".equals(userAccount.getCcCode())) {
                        departmentEntity = departmentIfc.getDepartmentByCcCode(userAccount.getCcCode()) ;
                        if (departmentEntity!= null) {
                            if (settingEntity.isStartupLeagueShopCcCode()) {
                                companyName = (departmentEntity.getCcName()==null?"":departmentEntity.getCcName()) ;
                                companyPhoto = imgData.getImageUrl(departmentEntity.getPhoto(),settingEntity.getImageThumbWidth(),settingEntity.getImageThumbHeight(),true,settingEntity.isFromCached(),request); 
                                industryTypeName = erpUserIfc.getIndustryTypeName(userAccount.getCcCode()) ; 
                            }else {
                                companyName += (departmentEntity.getCcName()==null?"":departmentEntity.getCcName()) ;
                            }
                            address = (departmentEntity.getAddress()==null?"":departmentEntity.getAddress()) ;
                            longitude = departmentEntity.getLongitude()==null?"":departmentEntity.getLongitude() ;
                            latitude = departmentEntity.getLatitude()==null?"":departmentEntity.getLatitude() ;
                        }
                    }
                }
                jsonObject.addProperty("CompanyName", companyName) ;
                jsonObject.addProperty("Address", address);
                jsonObject.addProperty("Longitude", longitude);
                jsonObject.addProperty("Latitude", latitude);
                jsonObject.addProperty("CompanyPhoto", companyPhoto);
                jsonObject.addProperty("IndustryTypeName", industryTypeName==null?"":industryTypeName);
                
                String cardImage = imgData.getImageUrl(myWxCpUser.getCardImage(),settingEntity.getImageThumbWidth(),settingEntity.getImageThumbHeight(),true,settingEntity.isFromCached(),request);
                jsonObject.addProperty("CardImage",cardImage );
                
                matCodeJsonArray.add(jsonObject);
            
            }
            json.add("list", matCodeJsonArray);
            json.addProperty("state", "success");
            this.printJson(response, json.toString());
            return;    
            
            
        } catch (Exception e) {
            e.printStackTrace();
            errJson.addProperty("warning",e.getCause()!=null? e.getCause().getMessage():e.getMessage());
            json.add("error", errJson);
            this.printJson(response, json.toString());
            return;    
        }finally {
            SpObserver.setDBtoInstance();
        }
        
    }
    
    /**
     * 获取我的名片详细记录
     * @param request
     * @param response
     * @throws ServletException
     */
    @RequestMapping("/wx/getCardUserInfo.do")
    public void getCardUserInfo(HttpServletRequest request, HttpServletResponse response) throws ServletException {
        HttpSession session=request.getSession();
        
        
        
        String fromUserId = request.getParameter(SettingKey.FROMUSERID) ;
        //String fromUserRowId = request.getParameter(SettingKey.FROMUSERROWID) ;
        
        JsonObject json = new JsonObject();
        JsonObject errJson = new JsonObject();
//        if (fromUserId == null || "".equals(fromUserId)) {
//            errJson.addProperty("warning","必须传递 " + SettingKey.FROMUSERID +" 参数");
//            json.add("error", errJson);
//            this.printJson(response, json.toString());
//            return;    
//        }
        
        String dbId =  (String) session.getAttribute(SessionKey.SHOPPING_DBID);
        if (dbId == null || "".equals(dbId)) {
            dbId = (session.getAttribute(SessionKey.DATA_BASE_ID)== null?null :
                (String) session.getAttribute(SessionKey.DATA_BASE_ID));
        }
        String corpId = request.getParameter(SessionKey.WEIXIN_CORPID) ;
        if (corpId == null || "".equals(corpId)) {
            corpId = request.getParameter(SessionKey.WEIXIN_APPID) ;
        }
        if (corpId == null || "".equals(corpId)) {
            corpId = (String) session.getAttribute(SessionKey.WEIXIN_CORPID);
        }
        if (corpId == null || "".equals(corpId)) {
            errJson.addProperty("warning","必须传递 AppId 参数");
            json.add("error", errJson);
            this.printJson(response, json.toString());
            return;    
        }
        String openId = (String)session.getAttribute(SessionKey.WEIXIN_OPENID) ;
        String cltCode = (String) session.getAttribute(SettingKey.CLTCODE) ;
        String hostUrl = SettingKey.getHostUrl(request) ;
        SimpleDateFormat yearFormat = new SimpleDateFormat("yyyy");    
        try {
 
            DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap( request) ;
            if (dataSourceEntity == null) {
                errJson.addProperty("warning", "未找到数据源【"+ dbId+"】【CorpId:"+ corpId+ "】【CorpId:"+ corpId+ "】,请在数据源中设置好【名片】");
                json.add("error", errJson);
                this.printJson(response, json.toString());
                return;    
            }
            if (SpObserver.isDemoInstance("_"+dataSourceEntity.getDbId() )) {
                errJson.addProperty("warning", "未找到数据源【"+ dataSourceEntity.getDbId()+"】【CorpId:"+ corpId+ "】,请在数据源中设置好【名片】");
                json.add("error", errJson);
                this.printJson(response, json.toString());
                return;    
            }
            
            SpObserver.setDBtoInstance("_"+dataSourceEntity.getDbId());//切换数据源
            SettingEntity settingEntity = settingIfc.getSettingEntity(request) ;      
            
            //如果传递了 UserRowId 参数,则认为是直播二维码带过来的 ,详细说明参考:SettingKey.FROMUSERROWID   //此处注释掉,因为后面的代码要重新获取一次 FromUserId 参数 
//            if (fromUserRowId!=null && !"".equals(fromUserRowId) ) {
//                fromUserId = null ;
//                MyWxCpUser cpUser = erpUserIfc.getWorkAppUserByRowId(fromUserRowId);
//                if (cpUser!= null) {
//                    fromUserId = cpUser.getUserId() ;
//                }
//            }
            
            //获取导购信息用于发送AI雷达提示消息 
            MyWxCpUser myWxCpUser = maUserIfc.getSendAIMessageUser(fromUserId,dataSourceEntity.getSystemDescribe(),openId) ;
            json.addProperty("UserId", myWxCpUser.getUserId()==null?"":myWxCpUser.getUserId());   //名片 userid 
            json.addProperty("Name", myWxCpUser.getName()==null?"":myWxCpUser.getName());   //名片上的姓名
            json.addProperty("Position", myWxCpUser.getPosition()==null?"":myWxCpUser.getPosition());   //职位
            json.addProperty("Mobile", myWxCpUser.getMobile()==null?"":myWxCpUser.getMobile());   //手机
            json.addProperty("Telephone", myWxCpUser.getTelephone()==null?"":myWxCpUser.getTelephone());   //办公电话
            json.addProperty("WeiXinUserCode", myWxCpUser.getWeiXinUserCode()==null?"":myWxCpUser.getWeiXinUserCode());   //微信号
            json.addProperty("EMail", myWxCpUser.getEmail()==null?"":myWxCpUser.getEmail());   //邮件
            
            json.addProperty(SettingKey.FROMUSERROWID,myWxCpUser.getRowId()==null?"":myWxCpUser.getRowId());  //修改了 FROMUSERROWID 值
            
            //取导购企业用户头像
            String defaultAvatar = imgData.getImageUrl(myWxCpUser.getAvatarUnid(),settingEntity.getImageThumbWidth(),settingEntity.getImageThumbHeight(),settingEntity.isShowThumbOrgImage(),settingEntity.isFromCached(),request);
            
            
            if (fromUserId!=null&& !"".equals(fromUserId) && openId != null && !"".equals(openId)) {
                //更新小程序用户“最近服务的客服” 和 “最近选择的联盟”
                maUserIfc.updateLastUserIdAndShopCcCode(myWxCpUser.getUserId()!=null?myWxCpUser.getUserId():fromUserId,myWxCpUser.getShopCcCode(), openId);
            }
            
            //取导购企业用户头像
            if ((defaultAvatar==null||"".equals(defaultAvatar)) && myWxCpUser.getAvatarUnid() != null && !"".equals(myWxCpUser.getAvatarUnid())) {
                defaultAvatar = (myWxCpUser.getAvatar()==null?"":myWxCpUser.getAvatar() );  //imgData.getImageUrl(myWxCpUser.getAvatarUnid(),settingEntity.getImageThumbWidth(),settingEntity.getImageThumbHeight(),settingEntity.isShowThumbOrgImage(),settingEntity.isFromCached(),request);
            }
            
            //取导购小程序用户的头像
            if (defaultAvatar==null||"".equals(defaultAvatar)) {
                MyWxMpUser shopGuideUser = maUserIfc.getUserByTelephone(myWxCpUser.getMobile()) ;
                if (shopGuideUser !=null) {
                    defaultAvatar = imgData.getImageUrl(shopGuideUser.getWeiXinAvatarUnid(),settingEntity.getImageThumbWidth(),settingEntity.getImageThumbHeight(),settingEntity.isShowThumbOrgImage(),settingEntity.isFromCached(),request);
                    if (defaultAvatar==null||"".equals(defaultAvatar)) {
                        defaultAvatar = shopGuideUser.getHeadImgUrl();
                    }
                }
            }
 
            if (defaultAvatar==null||"".equals(defaultAvatar)) {
                defaultAvatar = hostUrl + "/shopping/weixinby3rd/setting/image/defaultavatar.png" ;
            }
            
            json.addProperty("Avatar",defaultAvatar );
            
            String companyName = "" ,address = "",longitude = "" ,latitude = "",industryTypeName = "",companyPhoto = "" ;
            UserAccountEntity userAccount = userAccountService.getUserInfoByWeiXinCorpUserId(myWxCpUser.getUserId()==null?"":myWxCpUser.getUserId()) ;
            DepartmentEntity departmentEntity = null ;
            if (userAccount != null  ) {
                MaCompanyEntity maCompanyEntity = erpUserIfc.getMaCompanyEntity(userAccount.getCompanyId());
                companyName = (maCompanyEntity.getCompanyName()==null?"":maCompanyEntity.getCompanyName()+" ") ;
                address = (maCompanyEntity.getAddress()==null?"":maCompanyEntity.getAddress()) ;
                longitude = maCompanyEntity.getLongitude()==null?"":maCompanyEntity.getLongitude() ;
                latitude = maCompanyEntity.getLatitude()==null?"":maCompanyEntity.getLatitude() ;
                companyPhoto = imgData.getImageUrl(maCompanyEntity.getPhoto(),settingEntity.getImageThumbWidth(),settingEntity.getImageThumbHeight(),true,settingEntity.isFromCached(),request);  
                industryTypeName = erpUserIfc.getIndustryTypeName(maCompanyEntity.getCompanyId()) ; 
                if (userAccount.getCcCode()!=null && !"".equals(userAccount.getCcCode())) {
                    departmentEntity = departmentIfc.getDepartmentByCcCode(userAccount.getCcCode()) ;
                    if (departmentEntity!= null) {
                        if (settingEntity.isStartupLeagueShopCcCode()) {
                            companyName = (departmentEntity.getCcName()==null?"":departmentEntity.getCcName()) ;
                            companyPhoto = imgData.getImageUrl(departmentEntity.getPhoto(),settingEntity.getImageThumbWidth(),settingEntity.getImageThumbHeight(),true,settingEntity.isFromCached(),request); 
                            industryTypeName = erpUserIfc.getIndustryTypeName(userAccount.getCcCode()) ; 
                        }else {
                            //不用显示部门名称,Modified by Johns Wang,2020-06-10
                            //companyName += (departmentEntity.getCcName()==null?"":departmentEntity.getCcName()) ;
                        }
                        address = (departmentEntity.getAddress()==null?"":departmentEntity.getAddress()) ;
                        longitude = departmentEntity.getLongitude()==null?"":departmentEntity.getLongitude() ;
                        latitude = departmentEntity.getLatitude()==null?"":departmentEntity.getLatitude() ;
                    }
                }
            }
            json.addProperty("CompanyName", companyName) ;   //公司名称
            json.addProperty("Address", address);  //地址 
            json.addProperty("Longitude", longitude);   //坐标
            json.addProperty("Latitude", latitude);    //坐标
            json.addProperty("CompanyPhoto", companyPhoto);    //公司背景图
            json.addProperty("IndustryTypeName", industryTypeName==null?"":industryTypeName);   //所属行业
            
            String cardImage = imgData.getImageUrl(myWxCpUser.getCardImage(),settingEntity.getImageThumbWidth(),settingEntity.getImageThumbHeight(),true,settingEntity.isFromCached(),request);   //名片背景图
            json.addProperty("CardImage",cardImage );    //名片背景图
            
            
            //取处理过的我的个人简介
            request.setAttribute(SettingKey.FROMOPENID, openId);
            String description = imgData.getDescriptionByNewImgLink(myWxCpUser.getDescription()==null?"":myWxCpUser.getDescription(), request) ;
            json.addProperty("Description", description);   //我的个人简介
            json.addProperty("Hometown", myWxCpUser.getHometown()==null?"":myWxCpUser.getHometown());   //家乡
            json.addProperty("HometownGreetings", myWxCpUser.getHometownGreetings()==null?"":myWxCpUser.getHometownGreetings());   //同乡问候语
            boolean isHometown = maUserIfc.isHometown(myWxCpUser.getUserId()==null?"":myWxCpUser.getUserId(), openId) ;
            json.addProperty("IsHometown",isHometown)  ;  //是否同乡 
            json.addProperty("HometownGreetingsImage",imgData.getImageUrl(settingEntity.getHometownGreetingsImage(), settingEntity.getImageProductWidth(),
                        settingEntity.getImageProductHeight(), settingEntity.isShowProductOrgImage(),
                        settingEntity.isFromCached(), request) )  ;  //同乡问候语图片 
            
            //我的标签
            String myTags[] = (myWxCpUser.getMyTag()==null?"":myWxCpUser.getMyTag()).split(";") ;
            JsonArray myTagJsonArray = new JsonArray();
            for (int i = 0 ;i < myTags.length;i ++) {
                JsonObject myTabJson = new JsonObject();
                myTabJson.addProperty("MyTag" ,myTags[i] ) ;
                Integer likeActionTimes =  maUserIfc.getLikeActionTimes(myWxCpUser.getUserId()==null?"":myWxCpUser.getUserId(), null,"LikeMyTag",myTags[i]) ;
                myTabJson.addProperty("LikeMyTagTimes" ,likeActionTimes ) ;  //点赞总数
                Integer likeMyTagForMe =  maUserIfc.getLikeActionTimes(myWxCpUser.getUserId()==null?"":myWxCpUser.getUserId(), openId,"LikeMyTag",myTags[i]) ;
                myTabJson.addProperty("isLikeMyTagForMe" ,likeMyTagForMe!=null&& likeMyTagForMe.intValue() > 0?true:false) ;  //此标签我是否点过赞?
                myTagJsonArray.add(myTabJson) ;
            }
            json.add("MyTagList",myTagJsonArray) ;  //我的标签
            
            //我的语音
            json.addProperty("MyVoice", imgData.getImageUrl(myWxCpUser.getMyVoice(), settingEntity.getImageProductWidth(),settingEntity.getImageProductHeight(), settingEntity.isShowProductOrgImage(),settingEntity.isFromCached(), request) );   
            //我的视频
            json.addProperty("MyVideo", imgData.getImageUrl(myWxCpUser.getMyVideo(), settingEntity.getImageProductWidth(),settingEntity.getImageProductHeight(), settingEntity.isShowProductOrgImage(),settingEntity.isFromCached(), request) );   
            //我的视频封面
            json.addProperty("MyVideoCover",imgData.getImageUrl( myWxCpUser.getMyVideoCover(),settingEntity.getImageThumbWidth(),settingEntity.getImageThumbHeight(),true,settingEntity.isFromCached(),request));  
            
            //我的照片
            JsonArray myPhotoJsonArray = new JsonArray();
            if (myWxCpUser.getMyPhoto() != null && !"".equals(myWxCpUser.getMyPhoto())) {
                String unids[] = myWxCpUser.getMyPhoto().split(";") ;
                String unid = unids[0] ;
                for (int m = 0 ;m < unids.length;m++) {
                    if (m == 0) continue ; 
                    String seq = unids[m] ;
                    JsonObject unidSeqJson = new JsonObject();
                    unidSeqJson.addProperty(SettingKey.UNID,unid) ;
                    unidSeqJson.addProperty("seq",seq) ;
                    unidSeqJson.addProperty("url",imgData.getImageUrl(unid +";" + seq, settingEntity.getImageProductWidth(),
                              settingEntity.getImageProductHeight(), settingEntity.isShowProductOrgImage(),
                              settingEntity.isFromCached(), request) ) ;
                    myPhotoJsonArray.add(unidSeqJson) ;
                }
            }
            json.add("MyPhotoList",myPhotoJsonArray) ;  //我的照片
            
            json.addProperty("AboutUs", myWxCpUser.getAboutUs()==null?"":myWxCpUser.getAboutUs());   //关于我们
            
            //获取点赞名片最近5个人的头像
            //ActionType值范围: LikeMyCard:点赞我的名片 , LikeWebsite: 点赞公司官网, LikeProductDetail :点赞商品 , LikeInformation:点赞信息咨询,LikeMyVoice:点赞我的语音,LikeMyVideo:点赞我的视频,LikeMyPhoto:点赞我的图片,LikeMyTag:点赞我的标签
            List<MyWxMpUser> likeMyCardList = maUserIfc.getUserLastVisitList(myWxCpUser.getUserId()==null?"":myWxCpUser.getUserId(),5);
            Integer viewMyCardTimes = 0 ;
            JsonArray viewMyCardListArray = new JsonArray();
            for(int i = 0;likeMyCardList!= null && i < likeMyCardList.size() ; i ++) {
                String weiXinAvatarUnid = imgData.getImageUrl(likeMyCardList.get(i).getWeiXinAvatarUnid(), settingEntity.getImageProductWidth(),
                        settingEntity.getImageProductHeight(), settingEntity.isShowProductOrgImage(),
                        settingEntity.isFromCached(), request); 
                if (weiXinAvatarUnid!= null && !"".equals(weiXinAvatarUnid)) {
                    viewMyCardListArray.add(weiXinAvatarUnid);
                }
                viewMyCardTimes = likeMyCardList.get(i).getViewMyCardTimes();
            }
            json.add("ViewMyCardList",viewMyCardListArray) ;    //最近访问名片的人列表(只取前6个人)
            json.addProperty("ViewMyCardTimes",viewMyCardTimes) ;   //查看名片总次数
            
            //名片点赞总数
            Integer likeActionTimes = maUserIfc.getLikeActionTimes(myWxCpUser.getUserId()==null?"":myWxCpUser.getUserId(), null,"LikeMyCard",null) ;
            json.addProperty("LikeMyCardTimes",likeActionTimes) ;  //名片点赞总数
            
            Integer isLikeMyCardForMe = maUserIfc.getLikeActionTimes(myWxCpUser.getUserId()==null?"":myWxCpUser.getUserId(), openId,"LikeMyCard",null) ;
            json.addProperty("isLikeMyCardForMe",isLikeMyCardForMe!=null&& isLikeMyCardForMe.intValue()>0?true:false) ;  //名片点赞总数
            
            //我推荐的商品
            List<MatCodeEntity> matCodeList =  matCodeIfc.getMatCodesByFromUserId(fromUserId,myWxCpUser.getShopCcCode(),cltCode,openId) ;
            JsonArray matCodeJsonArray = MatCode.getJsonArrayByMatCodeList(matCodeList,request, settingEntity,dataSourceEntity.getDbId()) ;
            json.add("MatCodeList",matCodeJsonArray) ;
            
            //我的教育经历
            List<EducationEntity> educationList =  maUserIfc.getEducationList(myWxCpUser.getUserId()==null?"":myWxCpUser.getUserId(),openId);
            JsonArray educationListArray = new JsonArray();
            for (int i = 0 ;educationList!= null && i < educationList.size() ; i ++) {
                JsonObject educationJson = new JsonObject();
                educationJson.addProperty("SchoolCode",educationList.get(i).getSchoolCode() ) ;  //学校编码
                educationJson.addProperty("SchoolName",educationList.get(i).getSchoolName() ) ;  //学校名称
                educationJson.addProperty("Education",educationList.get(i).getEducation() ) ;    //学历
                educationJson.addProperty("Major",educationList.get(i).getMajor() ) ;   //专业
                educationJson.addProperty("LearningStartDate",educationList.get(i).getLearningStartDate()==null?"":yearFormat.format(educationList.get(i).getLearningStartDate()) ) ;   //在校开始时间
                educationJson.addProperty("LearningEndDate",educationList.get(i).getLearningEndDate()==null?"":yearFormat.format(educationList.get(i).getLearningEndDate()) ) ;   //在校结束时间
                educationJson.addProperty("SchoolmateGreetings",educationList.get(i).getSchoolmateGreetings() ) ;  //同校问喉语
                educationJson.addProperty("IsSchoolfellow",educationList.get(i).isSchoolfellow() ) ;  //是否校友
                educationJson.addProperty(SettingKey.DOCCODE,educationList.get(i).getDocCode() ) ;  //doccode
                educationJson.addProperty(SettingKey.ROWID,educationList.get(i).getRowId() ) ;  //rowid
                
                educationListArray.add(educationJson) ;
            }
            json.add("EducationList",educationListArray) ;
            json.addProperty("SchoolmateGreetingsImage",imgData.getImageUrl(settingEntity.getSchoolmateGreetingsImage(), settingEntity.getImageProductWidth(),
                    settingEntity.getImageProductHeight(), settingEntity.isShowProductOrgImage(),
                    settingEntity.isFromCached(), request) )  ;  //校友问候语图片 
            
            //我的其它公司信息
            List<OrganizationEntity> organizationList = erpUserIfc.getOrganizationList(myWxCpUser.getUserId()==null?"":myWxCpUser.getUserId())  ;
            JsonArray organizationListArray = new JsonArray();
            for (int i = 0 ;organizationList!= null && i < organizationList.size() ; i ++) {
                JsonObject organizationJson = new JsonObject();
                organizationJson.addProperty("DocCode",organizationList.get(i).getDocCode()) ;   //单号
                organizationJson.addProperty("RowId",organizationList.get(i).getRowId()) ;    //rowid
                organizationJson.addProperty("DocItem",organizationList.get(i).getDocItem()) ;  //排序
                organizationJson.addProperty("OrganizationName",organizationList.get(i).getOrganizationName()) ;  //公司名称
                organizationJson.addProperty("Description",organizationList.get(i).getDescription()) ;  //公司描述
                organizationJson.addProperty("Position",organizationList.get(i).getPosition()) ;    //职务
                organizationJson.addProperty("Telephone",organizationList.get(i).getTelephone()) ;  //电话
                organizationJson.addProperty("Address",organizationList.get(i).getAddress()) ;    //地址
                organizationJson.addProperty("Longitude",organizationList.get(i).getLongitude()) ;  //地理经度(x)
                organizationJson.addProperty("Latitude",organizationList.get(i).getLatitude()) ;   //地理纬度(y)
                organizationJson.addProperty("IndustryTypeFullName",organizationList.get(i).getIndustryTypeFullName()) ;  //拼接的行业名称
                
                organizationListArray.add(organizationJson) ;
            }
            json.add("OrganizationList",organizationListArray) ;
            
            json.addProperty("state", "success");
            this.printJson(response, json.toString());
            return;    
            
            
        } catch (Exception e) {
            e.printStackTrace();
            errJson.addProperty("warning",e.getCause()!=null? e.getCause().getMessage():e.getMessage());
            json.add("error", errJson);
            this.printJson(response, json.toString());
            return;    
        }finally {
            SpObserver.setDBtoInstance();
        }
        
    }
    
    /**
     * 新增或删除点赞记录
     * @param request
     * @param response
     * @throws ServletException
     */
    @RequestMapping("/wx/saveLikeAction.do")
    public void saveLikeAction(HttpServletRequest request, HttpServletResponse response) throws ServletException {
        HttpSession session=request.getSession();
            
        String fromUserId = request.getParameter(SettingKey.FROMUSERID) ;
        //String fromUserRowId = request.getParameter(SettingKey.FROMUSERROWID) ;
        
        JsonObject json = new JsonObject();
        JsonObject errJson = new JsonObject();
        if (fromUserId == null || "".equals(fromUserId)) {
            errJson.addProperty("warning","必须传递 " + SettingKey.FROMUSERID +" 参数");
            json.add("error", errJson);
            this.printJson(response, json.toString());
            return;    
        }
        
        String dbId =  (String) session.getAttribute(SessionKey.SHOPPING_DBID);
        if (dbId == null || "".equals(dbId)) {
            dbId = (session.getAttribute(SessionKey.DATA_BASE_ID)== null?null :
                (String) session.getAttribute(SessionKey.DATA_BASE_ID));
        }
        String corpId = request.getParameter(SessionKey.WEIXIN_CORPID) ;
        if (corpId == null || "".equals(corpId)) {
            corpId = request.getParameter(SessionKey.WEIXIN_APPID) ;
        }
        if (corpId == null || "".equals(corpId)) {
            corpId = (String) session.getAttribute(SessionKey.WEIXIN_CORPID);
        }
        if (corpId == null || "".equals(corpId)) {
            errJson.addProperty("warning","必须传递 AppId 参数");
            json.add("error", errJson);
            this.printJson(response, json.toString());
            return;    
        }
        String openId = (String)session.getAttribute(SessionKey.WEIXIN_OPENID) ;
        String actionType = request.getParameter("ActionType") ;
        if (actionType == null || "".equals(actionType)) {
            errJson.addProperty("warning","必须传递 ActionType 参数");
            json.add("error", errJson);
            this.printJson(response, json.toString());
            return;    
        }
        
        String actionName = (request.getParameter("ActionName")==null?"":request.getParameter("ActionName")) ;
        //ActionType值范围:LikeMyCard:点赞我的名片 , LikeWebsite: 点赞公司官网, LikeProductDetail :点赞商品 , 
        //                 LikeInformation:点赞信息咨询,LikeMyVoice:点赞我的语音,LikeMyVideo:点赞我的视频,
        //                 LikeMyPhoto:点赞我的图片,LikeMyTag:点赞我的标签
        if (Arrays.asList("LikeMyCard","LikeMyVoice","LikeMyVideo").contains(actionType)) {
            if (actionName != null && !"".equals(actionName)) {
                errJson.addProperty("warning","ActionType为[LikeMyCard,LikeMyVoice,LikeMyVideo]时,不需要传递 ActionName 参数");
                json.add("error", errJson);
                this.printJson(response, json.toString());
                return;    
            }
        }
 
        if (Arrays.asList("LikeWebsite","LikeProductDetail","LikeInformation","LikeMyPhoto","LikeMyTag").contains(actionType)) {
            if  (actionName == null || "".equals(actionName)) {
                errJson.addProperty("warning","ActionType为[LikeWebsite,LikeProductDetail,LikeInformation,LikeMyPhoto,LikeMyTag]时,必需要传递 ActionName 参数");
                json.add("error", errJson);
                this.printJson(response, json.toString());
                return;    
            }
        }
        
        
        String ac = request.getParameter("ac") ;
        if (ac == null || "".equals(ac)) {
            errJson.addProperty("warning","必须传递 ac 参数,且该参数值只能是 add 或 delete");
            json.add("error", errJson);
            this.printJson(response, json.toString());
            return;    
        }
        if (! Arrays.asList("add","delete").contains(ac)) {
            errJson.addProperty("warning","传递的 ac 参数只能是 add 或 delete");
            json.add("error", errJson);
            this.printJson(response, json.toString());
            return;    
        }
        
        try {
            DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap( request) ;
            SpObserver.setDBtoInstance("_"+dataSourceEntity.getDbId());//切换数据源
            //SettingEntity settingEntity = settingIfc.getSettingEntity() ;      
            
            //ActionType值范围:LikeMyCard:点赞我的名片 , LikeWebsite: 点赞公司官网, LikeProductDetail :点赞商品 , LikeInformation:点赞信息咨询,LikeMyVoice:点赞我的语音,LikeMyVideo:点赞我的视频,LikeMyPhoto:点赞我的图片,LikeMyTag:点赞我的标签
            Integer affectedRowCount = null ;
            if (ac.equals("add")) {
                affectedRowCount = maUserIfc.addLikeAction(fromUserId, openId, actionType, actionName) ;
            }else {
                affectedRowCount = maUserIfc.deleteLikeAction(fromUserId, openId, actionType, actionName) ;
            }
            
            Integer likeActionTimes = maUserIfc.getLikeActionTimes( fromUserId, null, actionType, actionName);
            
            json.addProperty("likeActionTimes", likeActionTimes);   //点赞记录总数
            Integer likeActionTimesForMe = maUserIfc.getLikeActionTimes( fromUserId, openId, actionType, actionName);
            
            json.addProperty("isLikeActionForMe", likeActionTimesForMe!=null&& likeActionTimesForMe.intValue() > 0 ? true:false);   //我是否点过赞了
            json.addProperty("affectedRowCount", affectedRowCount);  //本次更新影响的行数
            json.addProperty("state", "success");
            this.printJson(response, json.toString());
            return;    
        } catch (Exception e) {
            e.printStackTrace();
            errJson.addProperty("warning",e.getCause()!=null? e.getCause().getMessage():e.getMessage());
            json.add("error", errJson);
            this.printJson(response, json.toString());
            return;    
        }finally {
            SpObserver.setDBtoInstance();
        }
    }
    
    /**
     * 新增或删除同乡记录
     * @param request
     * @param response
     * @throws ServletException
     */
    @RequestMapping("/wx/saveHometown.do")
    public void saveHometown(HttpServletRequest request, HttpServletResponse response) throws ServletException {
        HttpSession session=request.getSession();
            
        String fromUserId = request.getParameter(SettingKey.FROMUSERID) ;
        //String fromUserRowId = request.getParameter(SettingKey.FROMUSERROWID) ;
        
        JsonObject json = new JsonObject();
        JsonObject errJson = new JsonObject();
        if (fromUserId == null || "".equals(fromUserId)) {
            errJson.addProperty("warning","必须传递 " + SettingKey.FROMUSERID +" 参数");
            json.add("error", errJson);
            this.printJson(response, json.toString());
            return;    
        }
        
        String dbId =  (String) session.getAttribute(SessionKey.SHOPPING_DBID);
        if (dbId == null || "".equals(dbId)) {
            dbId = (session.getAttribute(SessionKey.DATA_BASE_ID)== null?null :
                (String) session.getAttribute(SessionKey.DATA_BASE_ID));
        }
        String corpId = request.getParameter(SessionKey.WEIXIN_CORPID) ;
        if (corpId == null || "".equals(corpId)) {
            corpId = request.getParameter(SessionKey.WEIXIN_APPID) ;
        }
        if (corpId == null || "".equals(corpId)) {
            corpId = (String) session.getAttribute(SessionKey.WEIXIN_CORPID);
        }
        if (corpId == null || "".equals(corpId)) {
            errJson.addProperty("warning","必须传递 AppId 参数");
            json.add("error", errJson);
            this.printJson(response, json.toString());
            return;    
        }
        String openId = (String)session.getAttribute(SessionKey.WEIXIN_OPENID) ;
        
        
        String ac = request.getParameter("ac") ;
        if (ac == null || "".equals(ac)) {
            errJson.addProperty("warning","必须传递 ac 参数");
            json.add("error", errJson);
            this.printJson(response, json.toString());
            return;    
        }
        if (! Arrays.asList("add","delete").contains(ac)) {
            errJson.addProperty("warning","传递的 ac 参数只能是 add 或 delete");
            json.add("error", errJson);
            this.printJson(response, json.toString());
            return;    
        }
        
        try {
            DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap( request) ;
            SpObserver.setDBtoInstance("_"+dataSourceEntity.getDbId());//切换数据源
            //SettingEntity settingEntity = settingIfc.getSettingEntity() ;      
            
            //ActionType值范围:LikeMyCard:点赞我的名片 , LikeWebsite: 点赞公司官网, LikeProductDetail :点赞商品 , LikeInformation:点赞信息咨询,LikeMyVoice:点赞我的语音,LikeMyVideo:点赞我的视频,LikeMyPhoto:点赞我的图片,LikeMyTag:点赞我的标签
            Integer affectedRowCount = null ;
            if (ac.equals("add")) {
                affectedRowCount = maUserIfc.addHometown(fromUserId, openId) ;
            }else {
                affectedRowCount = maUserIfc.deleteHometown(fromUserId, openId) ;
            }
            json.addProperty("affectedRowCount", affectedRowCount);
            json.addProperty("state", "success");
            this.printJson(response, json.toString());
            return;    
        } catch (Exception e) {
            e.printStackTrace();
            errJson.addProperty("warning",e.getCause()!=null? e.getCause().getMessage():e.getMessage());
            json.add("error", errJson);
            this.printJson(response, json.toString());
            return;    
        }finally {
            SpObserver.setDBtoInstance();
        }
    }
    
    
    /**
     * 新增或删除校友记录
     * @param request
     * @param response
     * @throws ServletException
     */
    @RequestMapping("/wx/saveSchoolfellow.do")
    public void saveSchoolfellow(HttpServletRequest request, HttpServletResponse response) throws ServletException {
        HttpSession session=request.getSession();
            
        String fromUserId = request.getParameter(SettingKey.FROMUSERID) ;
        //String fromUserRowId = request.getParameter(SettingKey.FROMUSERROWID) ;
        
        JsonObject json = new JsonObject();
        JsonObject errJson = new JsonObject();
        if (fromUserId == null || "".equals(fromUserId)) {
            errJson.addProperty("warning","必须传递 " + SettingKey.FROMUSERID +" 参数");
            json.add("error", errJson);
            this.printJson(response, json.toString());
            return;    
        }
        
        String dbId =  (String) session.getAttribute(SessionKey.SHOPPING_DBID);
        if (dbId == null || "".equals(dbId)) {
            dbId = (session.getAttribute(SessionKey.DATA_BASE_ID)== null?null :
                (String) session.getAttribute(SessionKey.DATA_BASE_ID));
        }
        String corpId = request.getParameter(SessionKey.WEIXIN_CORPID) ;
        if (corpId == null || "".equals(corpId)) {
            corpId = request.getParameter(SessionKey.WEIXIN_APPID) ;
        }
        if (corpId == null || "".equals(corpId)) {
            corpId = (String) session.getAttribute(SessionKey.WEIXIN_CORPID);
        }
        if (corpId == null || "".equals(corpId)) {
            errJson.addProperty("warning","必须传递 AppId 参数");
            json.add("error", errJson);
            this.printJson(response, json.toString());
            return;    
        }
        String openId = (String)session.getAttribute(SessionKey.WEIXIN_OPENID) ;
        
        
        String ac = request.getParameter("ac") ;
        if (ac == null || "".equals(ac)) {
            errJson.addProperty("warning","必须传递 ac 参数");
            json.add("error", errJson);
            this.printJson(response, json.toString());
            return;    
        }
        if (! Arrays.asList("add","delete").contains(ac)) {
            errJson.addProperty("warning","传递的 ac 参数只能是 add 或 delete");
            json.add("error", errJson);
            this.printJson(response, json.toString());
            return;    
        }
        
        String schoolDocCode = request.getParameter(SettingKey.DOCCODE) ;
        if (schoolDocCode == null || "".equals(schoolDocCode)) {
            errJson.addProperty("warning","必须传递 " + SettingKey.DOCCODE + " 参数");
            json.add("error", errJson);
            this.printJson(response, json.toString());
            return;    
        }
        String schoolRowId = request.getParameter(SettingKey.ROWID) ;
        if (schoolRowId == null || "".equals(schoolRowId)) {
            errJson.addProperty("warning","必须传递 " + SettingKey.ROWID + " 参数");
            json.add("error", errJson);
            this.printJson(response, json.toString());
            return;    
        }
        
        try {
            DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap( request) ;
            SpObserver.setDBtoInstance("_"+dataSourceEntity.getDbId());//切换数据源
            //SettingEntity settingEntity = settingIfc.getSettingEntity() ;      
            
            //ActionType值范围:LikeMyCard:点赞我的名片 , LikeWebsite: 点赞公司官网, LikeProductDetail :点赞商品 , LikeInformation:点赞信息咨询,LikeMyVoice:点赞我的语音,LikeMyVideo:点赞我的视频,LikeMyPhoto:点赞我的图片,LikeMyTag:点赞我的标签
            Integer affectedRowCount = null ;
            if (ac.equals("add")) {
                affectedRowCount = maUserIfc.addSchoolfellow(fromUserId, openId,schoolDocCode,schoolRowId) ;
            }else {
                affectedRowCount = maUserIfc.deleteSchoolfellow(fromUserId, openId,schoolDocCode,schoolRowId) ;
            }
            json.addProperty("affectedRowCount", affectedRowCount);
            json.addProperty("state", "success");
            this.printJson(response, json.toString());
            return;    
        } catch (Exception e) {
            e.printStackTrace();
            errJson.addProperty("warning",e.getCause()!=null? e.getCause().getMessage():e.getMessage());
            json.add("error", errJson);
            this.printJson(response, json.toString());
            return;    
        }finally {
            SpObserver.setDBtoInstance();
        }
    }
    
}