Просмотр исходного кода

物资 出库入库 选外部时 推送微信模板消息

liyuanyuan лет назад: 4
Родитель
Сommit
53eae6a040

+ 47 - 0
codegit/CallCenterApi/CallCenterAPI.WechatSDK/WxHelper.cs

@@ -329,5 +329,52 @@ namespace CallCenterAPI.WechatSDK
329 329
             
330 330
         }
331 331
         #endregion
332
+
333
+
334
+        //发送微信出库入库客户的确认消息
335
+        public static object SendWechatMsg2(string archiveNames, string firststr, string content, string url, string openid, string templateid = "")
336
+        {
337
+            url = "";
338
+            var obj = new
339
+            {
340
+                first = new { value = firststr },
341
+                keyword1 = new { value = archiveNames },
342
+                keyword2 = new { value = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") },
343
+             
344
+                remark = new { value = content }
345
+            };
346
+            var sendResult = SendTemplateMsg1(openid, url, obj, templateid);
347
+            return sendResult;
348
+        }
349
+
350
+        public static object SendTemplateMsg1(string openid, string url, object jsondata, string templateid)
351
+        {
352
+            //string accesstoken = GetCommonToken();
353
+            if (string.IsNullOrEmpty(templateid))
354
+            {
355
+                templateid = TemplateId;
356
+            }
357
+            SendTemplateMessageResult sendResult;
358
+            try
359
+            {
360
+                  sendResult = TemplateApi.SendTemplateMessage(AppId, openid, templateid, url, jsondata);
361
+            }
362
+            catch (Exception e)
363
+            {
364
+                string str = e.ToString();
365
+                throw;
366
+            }
367
+
368
+        
369
+
370
+
371
+
372
+            object result = sendResult;
373
+
374
+            return "AppId:" + AppId + "||||openid:" + openid + "||||templateid:" + templateid + "||||url:" + url + "||||result" + result;
375
+
376
+
377
+        }
378
+
332 379
     }
333 380
 }

+ 130 - 13
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/archives/archivesController.cs

@@ -21,6 +21,7 @@ using NPOI.XSSF.UserModel;
21 21
 using NPOI.HSSF.UserModel;
22 22
 using Newtonsoft.Json;
23 23
 using CallCenterApi.Common;
24
+using CallCenterAPI.WechatSDK;
24 25
 
25 26
 namespace CallCenterApi.Interface.Controllers.archives
26 27
 {
@@ -29,13 +30,45 @@ namespace CallCenterApi.Interface.Controllers.archives
29 30
         CallCenterApi.BLL.archivesNew archivesnewbll = new BLL.archivesNew();
30 31
         CallCenterApi.BLL.archives archivesbll = new BLL.archives();
31 32
         CallCenterApi.BLL.T_Cus_CustomerBaseNew cusbll = new BLL.T_Cus_CustomerBaseNew();
33
+      
34
+        public ActionResult GetModelarchivesNew(int id)
35
+        {
36
+            var model = archivesnewbll.GetModel(id);
37
+            if (model == null)
38
+                return Error("该信息不存在");
39
+
40
+            string sql = "SELECT * FROM externalOperator where archivesid='"+id+"'";
41
+            DataTable dt=  DbHelperSQL.Query(sql).Tables[0];
42
+            foreach (DataRow item in dt.Rows)
43
+            {
44
+                model.OperationContent = item["Warehousing"].ToString();
45
+                model.OperationDate =Convert.ToDateTime(  item["WarehousingDate"]);
46
+            }
47
+
48
+          
49
+
50
+
51
+            var obj = new Model.archivesNew
52
+            {
53
+                id = model.id,
54
+                A_archiveCode = model.A_archiveCode,
55
+                A_archiveName = model.A_archiveName,
56
+                A_archiveState = model.A_archiveState,
57
+                A_archivePeople = model.A_archivePeople,
58
+                stateName = model.stateName,
59
+                OperationContent = model.OperationContent,
60
+                OperationDate = model.OperationDate
61
+            };
62
+            return Success("获取成功", obj);
63
+        }
64
+
32 65
 
33 66
         // GET: archives
34 67
         /// <summary>
35 68
         /// 查询档案物资表数据信息
36 69
         /// </summary>
37 70
         /// <returns></returns>
38
-        public ActionResult GetListNew(int PageIndex, int PageSize, string openid, string F_CompanyName)
71
+        public ActionResult GetListNew(int PageIndex, int PageSize, string openid, string F_CompanyName,string A_archiveName)
39 72
         {
40 73
             #region 分页显示档案物资
41 74
             if (PageIndex == 0)
@@ -47,7 +80,14 @@ namespace CallCenterApi.Interface.Controllers.archives
47 80
                 PageSize = 10;
48 81
             }
49 82
             var sql = "";
83
+            if (A_archiveName != null)
84
+            {
85
+                if (A_archiveName != "")
86
+                {
87
+                    sql += "  and A_archiveName like '%" + A_archiveName + "%' ";
88
+                }
50 89
 
90
+            }
51 91
             //公司名称查询
52 92
             if (F_CompanyName != null)
53 93
             {
@@ -139,7 +179,7 @@ namespace CallCenterApi.Interface.Controllers.archives
139 179
         /// <param name="openid"></param>
140 180
         /// <param name="F_CompanyName"></param>
141 181
         /// <returns></returns>
142
-        public ActionResult GetListByCompany(int PageIndex, int PageSize, string openid, string F_CompanyName)
182
+        public ActionResult GetListByCompany(int PageIndex, int PageSize, string openid, string F_CompanyName,string F_ArchiveName)
143 183
         {
144 184
             if (PageIndex == 0)
145 185
             {
@@ -151,6 +191,10 @@ namespace CallCenterApi.Interface.Controllers.archives
151 191
             }
152 192
             var sql = "";
153 193
 
194
+            if (!string.IsNullOrEmpty(F_ArchiveName)) {
195
+                sql += "  and A_archiveName = '" + F_ArchiveName + "' ";
196
+            }
197
+
154 198
             //公司名称查询
155 199
             if (F_CompanyName != null)
156 200
             {
@@ -641,9 +685,11 @@ namespace CallCenterApi.Interface.Controllers.archives
641 685
             var customername = "";
642 686
             if (openid != null)
643 687
             {
688
+                Model.T_Cus_CustomerBaseNew cust = cusbll.GetModelcus(openid);
644 689
                 if (archivesbll.GetCustomerName(openid) != "")
645 690
                 {
646 691
                     customername = archivesbll.GetCustomerName(openid);
692
+                    companyName = cust.F_CompanyName;
647 693
                 }
648 694
             }
649 695
             else
@@ -679,15 +725,27 @@ namespace CallCenterApi.Interface.Controllers.archives
679 725
                     externalOperator ex = new externalOperator();
680 726
                     ex.archivesid = arcids;
681 727
 
682
-                    ex.Operator = CurrentUser.UserData.F_UserCode;// CurrentUser.UserData.F_UserCode;//
728
+                    ex.Operator = customername;// CurrentUser.UserData.F_UserCode;// CurrentUser.UserData.F_UserCode;//
683 729
                     ex.fieldId = fields;
684 730
                     ex.WarehousingDate = DateTime.Now;
685 731
                     ex.remark = remark;
686 732
                     ex.Warehousing = arcnames + "添加了一条出库信息";
687 733
                     ex.companyName = companyName;
688 734
                     archivesnewbll.AddexternalOperator(ex);
735
+
736
+                    //微信通知给客户
737
+                    //发送消息
738
+                    BLL.T_Cus_CustomerBaseNew bll = new BLL.T_Cus_CustomerBaseNew();
739
+                    Model.T_Cus_CustomerBaseNew model = bll.GetModelcusName(companyName);
740
+                    model.F_WxOpenId = "oVMGRtxOoKL9nMbRCR_Y2kRxjyRw";
741
+                    if (model != null && !string.IsNullOrEmpty(model.F_WxOpenId))
742
+                    {
743
+                        sendckwxmsg(arcnames,model.F_WxOpenId);
744
+                    }
745
+           
689 746
                 }
690
-              
747
+
748
+
691 749
             }
692 750
             else
693 751
             {
@@ -698,7 +756,7 @@ namespace CallCenterApi.Interface.Controllers.archives
698 756
                     internalOperator ex = new internalOperator();
699 757
                     ex.archivesid = arcids;
700 758
 
701
-                    ex.Operator = CurrentUser.UserData.F_UserCode;// CurrentUser.UserData.F_UserCode;//
759
+                    ex.Operator = customername;// CurrentUser.UserData.F_UserCode;// CurrentUser.UserData.F_UserCode;//
702 760
                     ex.fieldId = fields;
703 761
                     ex.WarehousingDate = DateTime.Now;
704 762
                     ex.remark = remark;
@@ -717,7 +775,7 @@ namespace CallCenterApi.Interface.Controllers.archives
717 775
             }
718 776
             else
719 777
             {
720
-                return Error(error + "物资状态不是在库");
778
+                return Error(error + "物资状态不是在库");
721 779
             }
722 780
 
723 781
         }
@@ -771,13 +829,26 @@ namespace CallCenterApi.Interface.Controllers.archives
771 829
                     externalOperator ex = new externalOperator();
772 830
                     ex.archivesid = arcids;
773 831
 
774
-                    ex.Operator = CurrentUser.UserData.F_UserCode;// CurrentUser.UserData.F_UserCode;//
832
+                    ex.Operator = customername;// CurrentUser.UserData.F_UserCode;// CurrentUser.UserData.F_UserCode;//
775 833
                     ex.fieldId = fields;
776 834
                     ex.WarehousingDate = DateTime.Now;
777 835
                     ex.remark = remark;
778 836
                     ex.Warehousing = arcnames + "添加了一条入库信息";
779 837
                     ex.companyName = companyName;
780 838
                     archivesnewbll.AddexternalOperator(ex);
839
+
840
+                    //微信通知给客户
841
+                    //发送消息
842
+                    //微信通知给客户
843
+                    //发送消息
844
+                    BLL.T_Cus_CustomerBaseNew bll = new BLL.T_Cus_CustomerBaseNew();
845
+                    Model.T_Cus_CustomerBaseNew model = bll.GetModelcusName(companyName);
846
+                    model.F_WxOpenId = "oVMGRtxOoKL9nMbRCR_Y2kRxjyRw";
847
+                    if (model != null && !string.IsNullOrEmpty(model.F_WxOpenId))
848
+                    {
849
+                        sendrkwxmsg(arcnames, model.F_WxOpenId);
850
+                    }
851
+
781 852
                 }
782 853
             }
783 854
             else
@@ -789,7 +860,7 @@ namespace CallCenterApi.Interface.Controllers.archives
789 860
                     internalOperator ex = new internalOperator();
790 861
                     ex.archivesid = arcids;
791 862
 
792
-                    ex.Operator = CurrentUser.UserData.F_UserCode;// CurrentUser.UserData.F_UserCode;//
863
+                    ex.Operator = customername;// CurrentUser.UserData.F_UserCode;// CurrentUser.UserData.F_UserCode;//
793 864
                     ex.fieldId = fields;
794 865
                     ex.WarehousingDate = DateTime.Now;
795 866
                     ex.remark = remark;
@@ -808,7 +879,7 @@ namespace CallCenterApi.Interface.Controllers.archives
808 879
             }
809 880
             else
810 881
             {
811
-                return Error(error + "物资状态不是已出库");
882
+                return Error(error + "物资状态不是已出库");
812 883
             }
813 884
 
814 885
 
@@ -869,7 +940,7 @@ namespace CallCenterApi.Interface.Controllers.archives
869 940
                 internalOperator ex = new internalOperator();
870 941
                 ex.archivesid = arcids;
871 942
 
872
-                ex.Operator = CurrentUser.UserData.F_UserCode;// CurrentUser.UserData.F_UserCode;//
943
+                ex.Operator = customername;// CurrentUser.UserData.F_UserCode;// CurrentUser.UserData.F_UserCode;//
873 944
                 ex.fieldId = fields;
874 945
                 ex.WarehousingDate = DateTime.Now;
875 946
                 ex.remark = remark;
@@ -884,7 +955,7 @@ namespace CallCenterApi.Interface.Controllers.archives
884 955
             }
885 956
             else
886 957
             {
887
-                return Error(error + "物资状态不是在库");
958
+                return Error(error + "物资状态不是在库");
888 959
             }
889 960
 
890 961
 
@@ -935,7 +1006,7 @@ namespace CallCenterApi.Interface.Controllers.archives
935 1006
                 internalOperator ex = new internalOperator();
936 1007
                 ex.archivesid = arcids;
937 1008
 
938
-                ex.Operator = CurrentUser.UserData.F_UserCode;// CurrentUser.UserData.F_UserCode;//
1009
+                ex.Operator = customername;//  CurrentUser.UserData.F_UserCode;// CurrentUser.UserData.F_UserCode;//
939 1010
                 ex.fieldId = fields;
940 1011
                 ex.WarehousingDate = DateTime.Now;
941 1012
                 ex.remark = remark;
@@ -951,7 +1022,7 @@ namespace CallCenterApi.Interface.Controllers.archives
951 1022
             }
952 1023
             else
953 1024
             {
954
-                return Error(error + "物资状态不是借阅中");
1025
+                return Error(error + "物资状态不是借阅中");
955 1026
             }
956 1027
 
957 1028
 
@@ -1082,6 +1153,9 @@ namespace CallCenterApi.Interface.Controllers.archives
1082 1153
             };
1083 1154
             return Success("获取成功", obj);
1084 1155
         }
1156
+     
1157
+        
1158
+        
1085 1159
         /// <summary>
1086 1160
         /// 添加档案物资信息
1087 1161
         /// </summary>
@@ -2378,5 +2452,48 @@ namespace CallCenterApi.Interface.Controllers.archives
2378 2452
             return Error("文件不能为空");
2379 2453
         }
2380 2454
 
2455
+
2456
+        //推送微信消息 入库
2457
+        public void sendrkwxmsg( string archievesname, string openid)
2458
+        {
2459
+            string templateid = "B-dXgwc-RhASsRxLfDp3iaKORRQioJ15sib3D-d_6TA";
2460
+            string firststr = "你的物资已入库";
2461
+            #region 推送微信
2462
+            try
2463
+            {
2464
+                if (!string.IsNullOrEmpty(openid))
2465
+                {
2466
+                   string  content = "如果非本公司人员申请,请及时联系三元财务管理人员。";
2467
+                    var msg = WxHelper.SendWechatMsg2(archievesname,firststr, content, "", openid, templateid);
2468
+                    Error("推送微信::::::" + msg.ToString());
2469
+                }
2470
+            }
2471
+            catch { }
2472
+            #endregion
2473
+        }
2474
+
2475
+        //推送微信消息 出库
2476
+        public void sendckwxmsg(string archievesname,  string openid)
2477
+        {
2478
+            string templateid = "PnNPzm9aS-0JKvyxnmwFtiAAwxr9swA3eBbNSWHS_sw";
2479
+       
2480
+            string firststr = "你的物资已出库";
2481
+            #region 推送微信
2482
+            try
2483
+            {
2484
+                if (!string.IsNullOrEmpty(openid))
2485
+                {
2486
+                    string content = "如果非本公司人员申请,请及时联系三元财务管理人员。";
2487
+                    var msg = WxHelper.SendWechatMsg2(archievesname, firststr, content, "", openid, templateid);
2488
+                    Error("推送微信::::::" + msg.ToString());
2489
+                }
2490
+            }
2491
+            catch { }
2492
+            #endregion
2493
+        }
2494
+
2495
+
2496
+
2497
+
2381 2498
     }
2382 2499
 }