You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

205 lines
7.3 KiB

2 years ago
  1. using EasyBL.WebApi.Message;
  2. using Entity.Sugar;
  3. using SqlSugar.Base;
  4. using System;
  5. namespace EasyBL.WEBAPP.WSM
  6. {
  7. public class PackingOrder_UpdService : ServiceBase
  8. {
  9. #region 依據展覽獲取展覽報價規則
  10. /// <summary>
  11. /// 依據展覽獲取展覽報價規則
  12. /// </summary>
  13. /// <param name="i_crm"></param>
  14. /// <returns></returns>
  15. public ResponseMessage GetExhibitionRules(RequestMessage i_crm)
  16. {
  17. ResponseMessage rm = null;
  18. string sMsg = null;
  19. var db = SugarBase.GetIntance();
  20. try
  21. {
  22. do
  23. {
  24. var iId = _fetchInt(i_crm, "Id");
  25. var oRules = db.Queryable<CusExhibitionRules, OTB_OPM_Exhibition>((t1, t2) => t1.OrgID == t2.OrgID && t1.Guid == t2.CostRulesId)
  26. .Where((t1, t2) => t2.SN == iId)
  27. .Select((t1, t2) => new CusExhibitionRules
  28. {
  29. Guid = t1.Guid,
  30. Title = t1.Title,
  31. ExhibitionCode = t2.ExhibitionCode,
  32. CostRules = t1.CostRules,
  33. PackingPrice = t1.PackingPrice,
  34. FeedingPrice = t1.FeedingPrice,
  35. StoragePrice = t1.StoragePrice,
  36. CostInstruction = t1.CostInstruction,
  37. Currency = t1.Currency,
  38. }).Single();
  39. rm = new SuccessResponseMessage(null, i_crm);
  40. rm.DATA.Add(BLWording.REL, oRules);
  41. } while (false);
  42. }
  43. catch (Exception ex)
  44. {
  45. sMsg = Util.GetLastExceptionMsg(ex);
  46. LogAndSendEmail(sMsg + "Params:" + JsonToString(i_crm), ex, i_crm.ORIGID, i_crm.USERID, "EasyBL.WEBAPP.WSM.PackingOrder_UpdService", "", "GetExhibitionRules(依據展覽獲取展覽報價規則)", "", "", "");
  47. }
  48. finally
  49. {
  50. if (null != sMsg)
  51. {
  52. rm = new ErrorResponseMessage(sMsg, i_crm);
  53. }
  54. }
  55. return rm;
  56. }
  57. #endregion 依據展覽獲取展覽報價規則
  58. #region 設置匯入廠商下拉單
  59. /// <summary>
  60. /// 設置匯入廠商下拉單
  61. /// </summary>
  62. /// <param name="i_crm"></param>
  63. /// <returns></returns>
  64. public ResponseMessage SetImpCusDrop(RequestMessage i_crm)
  65. {
  66. ResponseMessage rm = null;
  67. string sMsg = null;
  68. var db = SugarBase.GetIntance();
  69. try
  70. {
  71. do
  72. {
  73. var iId = _fetchInt(i_crm, "Id");
  74. var saImportCustomers = db.Queryable<OTB_CRM_ImportCustomers>()
  75. .Select(x => new { x.guid, x.CustomerCName, x.ExhibitionNO })
  76. .Where(x => x.ExhibitionNO == iId).ToList();
  77. rm = new SuccessResponseMessage(null, i_crm);
  78. rm.DATA.Add(BLWording.REL, saImportCustomers);
  79. } while (false);
  80. }
  81. catch (Exception ex)
  82. {
  83. sMsg = Util.GetLastExceptionMsg(ex);
  84. LogAndSendEmail(sMsg + "Params:" + JsonToString(i_crm), ex, i_crm.ORIGID, i_crm.USERID, "EasyBL.WEBAPP.WSM.PackingOrder_UpdService", "", "SetImpCusDrop(設置匯入廠商下拉單)", "", "", "");
  85. }
  86. finally
  87. {
  88. if (null != sMsg)
  89. {
  90. rm = new ErrorResponseMessage(sMsg, i_crm);
  91. }
  92. }
  93. return rm;
  94. }
  95. #endregion 設置匯入廠商下拉單
  96. #region 獲取匯入廠商資料
  97. /// <summary>
  98. /// 獲取匯入廠商資料
  99. /// </summary>
  100. /// <param name="i_crm"></param>
  101. /// <returns></returns>
  102. public ResponseMessage GetImpCusData(RequestMessage i_crm)
  103. {
  104. ResponseMessage rm = null;
  105. string sMsg = null;
  106. var db = SugarBase.GetIntance();
  107. try
  108. {
  109. do
  110. {
  111. var sId = _fetchString(i_crm, "Id");
  112. var oImportCustomers = db.Queryable<OTB_CRM_ImportCustomers>().Single(x => x.OrgID == i_crm.ORIGID && x.guid == sId);
  113. rm = new SuccessResponseMessage(null, i_crm);
  114. rm.DATA.Add(BLWording.REL, oImportCustomers);
  115. } while (false);
  116. }
  117. catch (Exception ex)
  118. {
  119. sMsg = Util.GetLastExceptionMsg(ex);
  120. LogAndSendEmail(sMsg + "Params:" + JsonToString(i_crm), ex, i_crm.ORIGID, i_crm.USERID, "EasyBL.WEBAPP.WSM.PackingOrder_UpdService", "", "GetImpCusData(獲取匯入廠商資料)", "", "", "");
  121. }
  122. finally
  123. {
  124. if (null != sMsg)
  125. {
  126. rm = new ErrorResponseMessage(sMsg, i_crm);
  127. }
  128. }
  129. return rm;
  130. }
  131. #endregion 獲取匯入廠商資料
  132. #region 對應匯入廠商
  133. /// <summary>
  134. /// 對應匯入廠商
  135. /// </summary>
  136. /// <param name="i_crm"></param>
  137. /// <returns></returns>
  138. public ResponseMessage CorrespondImpCus(RequestMessage i_crm)
  139. {
  140. ResponseMessage rm = null;
  141. string sMsg = null;
  142. var db = SugarBase.GetIntance();
  143. try
  144. {
  145. do
  146. {
  147. var sId = _fetchString(i_crm, "Id");
  148. var sCustomerId = _fetchString(i_crm, "CustomerId");
  149. var oImportCustomers = db.Queryable<OTB_CRM_ImportCustomers>().Single(x => x.OrgID == i_crm.ORIGID && x.guid == sCustomerId);
  150. var iRel = db.Updateable(
  151. new OTB_WSM_PackingOrder
  152. {
  153. CustomerId = sCustomerId,
  154. CompName = oImportCustomers.CustomerCName
  155. }
  156. )
  157. .UpdateColumns(x => new { x.CustomerId, x.CompName })
  158. .Where(x => x.OrgID == i_crm.ORIGID && x.AppointNO == sId).ExecuteCommand();
  159. rm = new SuccessResponseMessage(null, i_crm);
  160. rm.DATA.Add(BLWording.REL, iRel > 0 ? true : false);
  161. } while (false);
  162. }
  163. catch (Exception ex)
  164. {
  165. sMsg = Util.GetLastExceptionMsg(ex);
  166. LogAndSendEmail(sMsg + "Params:" + JsonToString(i_crm), ex, i_crm.ORIGID, i_crm.USERID, "EasyBL.WEBAPP.WSM.PackingOrder_UpdService", "", "CorrespondImpCus(對應匯入廠商)", "", "", "");
  167. }
  168. finally
  169. {
  170. if (null != sMsg)
  171. {
  172. rm = new ErrorResponseMessage(sMsg, i_crm);
  173. }
  174. }
  175. return rm;
  176. }
  177. #endregion 對應匯入廠商
  178. }
  179. public class CusExhibitionRules : OTB_WSM_ExhibitionRules
  180. {
  181. public CusExhibitionRules()
  182. {
  183. ExhibitionCode = "";
  184. }
  185. public string ExhibitionCode { get; set; }
  186. }
  187. }