CustomerInfoBasicService.java 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. package com.ygj.yuemum.service.customer;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.github.pagehelper.PageHelper;
  4. import com.ygj.yuemum.dao.customer.CustomerInfoBasicDao;
  5. import com.ygj.yuemum.domain.admin.JlAdminUser;
  6. import com.ygj.yuemum.domain.customer.CustomerInfoBasic;
  7. import com.ygj.yuemum.domain.customer.CustomerInfoServiceLog;
  8. import com.ygj.yuemum.domain.customer.dto.CustomerInfoBasicCyDto;
  9. import com.ygj.yuemum.domain.customer.dto.CustomerInfoBasicDto;
  10. import com.ygj.yuemum.service.admin.JlAdminUserService;
  11. import org.apache.commons.lang.StringUtils;
  12. import org.apache.shiro.SecurityUtils;
  13. import org.springframework.stereotype.Service;
  14. import javax.annotation.Resource;
  15. import java.util.Date;
  16. import java.util.HashMap;
  17. import java.util.List;
  18. import java.util.Map;
  19. /**
  20. * customer_info_basic
  21. * @author zrz
  22. * @date 2020/06/17
  23. */
  24. @Service
  25. public class CustomerInfoBasicService {
  26. @Resource
  27. private CustomerInfoBasicDao customerInfoBasicDao;
  28. @Resource
  29. CustomerInfoServiceLogService customerInfoServiceLogService;
  30. @Resource
  31. JlAdminUserService jladminuserService;
  32. public int insert(CustomerInfoBasic customerInfoBasic) {
  33. this.setDefValue(customerInfoBasic);
  34. int count = customerInfoBasicDao.insert(customerInfoBasic);
  35. if (count != 0) {
  36. this.insertServiceLog(customerInfoBasic.getId(), "新增", customerInfoBasic);
  37. return count;
  38. }
  39. return 0;
  40. }
  41. public int delete(int id) {
  42. int ret = customerInfoBasicDao.delete(id);
  43. return ret;
  44. }
  45. public int update(CustomerInfoBasic customerInfoBasic) {
  46. this.insertServiceLog(customerInfoBasic.getId(), "修改", customerInfoBasic);
  47. int ret = customerInfoBasicDao.update(customerInfoBasic);
  48. return ret;
  49. }
  50. public CustomerInfoBasic load(int id) {
  51. return customerInfoBasicDao.load(id);
  52. }
  53. public Map<String,Object> pageList(int offset, int pagesize) {
  54. List<CustomerInfoBasic> pageList = customerInfoBasicDao.pageList(offset, pagesize);
  55. int totalCount = customerInfoBasicDao.pageListCount(offset, pagesize);
  56. // result
  57. Map<String, Object> result = new HashMap<String, Object>();
  58. result.put("pageList", pageList);
  59. result.put("totalCount", totalCount);
  60. return result;
  61. }
  62. public List<CustomerInfoBasic> selectByPageNumSize(CustomerInfoBasicDto customerInfoBasic) {
  63. PageHelper.startPage(customerInfoBasic.getPage(), customerInfoBasic.getLimit(), true, false);
  64. return customerInfoBasicDao.selectByPageNumSize(customerInfoBasic);
  65. }
  66. public void insertInfoBasicList(List<CustomerInfoBasicCyDto> list) {
  67. customerInfoBasicDao.insertInfoBasicList(list);
  68. }
  69. private void insertServiceLog(Integer sl_no, String type, CustomerInfoBasic customerInfoBasic) {
  70. JlAdminUser jlAdminUser = jladminuserService.getUserByDefPrincipal();
  71. CustomerInfoServiceLog customerInfoServiceLog = new CustomerInfoServiceLog();
  72. customerInfoServiceLog.setSl_userid(jlAdminUser.getId());
  73. customerInfoServiceLog.setSl_username(jlAdminUser.getName());
  74. customerInfoServiceLog.setSl_createdate(new Date());
  75. customerInfoServiceLog.setSl_no(sl_no);
  76. customerInfoServiceLog.setSl_table("customer_info_basic");
  77. customerInfoServiceLog.setSl_type(type);
  78. customerInfoServiceLog.setSl_comment(JSONObject.toJSONString(customerInfoBasic));
  79. customerInfoServiceLogService.insert(customerInfoServiceLog);
  80. }
  81. private void setDefValue(CustomerInfoBasic customerInfoBasic) {
  82. if (StringUtils.isBlank(customerInfoBasic.getFb_customer_name())) {
  83. customerInfoBasic.setFb_customer_name("");
  84. }
  85. if (StringUtils.isBlank(customerInfoBasic.getFb_customer_phone())) {
  86. customerInfoBasic.setFb_customer_phone("");
  87. }
  88. }
  89. }