BE_MallUserLevel_Add.groovy 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. import com.sdtool.business.dao.MallDao
  2. import com.sdtool.common.api.BusinessExecutor
  3. import com.sdtool.common.api.NoSqlKeysService
  4. import com.sdtool.common.datas.ERPModule
  5. import com.sdtool.common.datas.RedisKeys
  6. import com.sdtool.common.entity.base.InvokeCallParams
  7. import com.sdtool.common.entity.base.InvokeCallResult
  8. import com.sdtool.common.entity.mall.MallUserLevel
  9. import com.dySweetFishPlugin.redis.RedisService
  10. import com.dySweetFishPlugin.sql.TableIdService
  11. import com.dySweetFishPlugin.sql.dao.OperatorWait
  12. import com.dySweetFishPlugin.sql.dao.TunaService
  13. import com.sweetfish.convert.json.JsonConvert
  14. import com.sweetfish.service.RetResult
  15. import org.apache.commons.lang3.StringUtils
  16. import javax.annotation.Resource
  17. /**
  18. * @Author: xl Created on 2024-05-11
  19. * @Content:
  20. */
  21. class BE_MallUserLevel_Add implements BusinessExecutor<InvokeCallParams, InvokeCallResult> {
  22. @Resource
  23. TunaService tunaService
  24. @Resource
  25. JsonConvert jsonConvert
  26. @Resource
  27. TableIdService tableIdService
  28. @Resource
  29. RedisService redisService
  30. @Resource
  31. NoSqlKeysService keysService
  32. private MallDao mallDao
  33. @Override
  34. String scriptName() {
  35. return "用户级别-增加"
  36. }
  37. @Override
  38. ERPModule module() {
  39. return ERPModule.MALL_ADMIN
  40. }
  41. @Override
  42. OperatorWait getAWait(InvokeCallParams s) {
  43. return OperatorWait.ASNYC
  44. }
  45. @Override
  46. boolean needLogin(InvokeCallParams source) {
  47. return true
  48. }
  49. @Override
  50. void start(long supplierCode) {
  51. mallDao = tunaService.generate(MallDao.class)
  52. }
  53. @Override
  54. RetResult<InvokeCallParams> checkExecute(InvokeCallParams source) {
  55. MallUserLevel mallUserLevel = jsonConvert.convertFrom(MallUserLevel.class, source.params)
  56. if (StringUtils.isBlank(mallUserLevel.levelName)) {
  57. return RetResult.<InvokeCallParams>errorT().retinfo("级别名称不能为空")
  58. }
  59. return RetResult.<InvokeCallParams> successT().result(source)
  60. }
  61. RetResult<InvokeCallResult> execute(InvokeCallParams source) {
  62. MallUserLevel userLevel = jsonConvert.convertFrom(MallUserLevel.class, source.params)
  63. userLevel.id = tableIdService.getTableIdMulti("maMallUserLevel.id", 1, source.dataSourceId, String.valueOf(source.supplierCode))
  64. userLevel.voidFlag = 0
  65. if (userLevel.levelValue == null || userLevel.levelValue <= 0) {
  66. userLevel.levelValue = BigDecimal.ONE
  67. }
  68. MallUserLevel.create(userLevel,source.currentUser.id)
  69. int iData = mallDao.addMallUserLevel(userLevel, source.dataSourceId, source.supplierCode)
  70. if (iData > 0) {
  71. redisService.hset(keysService.getRedisKey(RedisKeys.KEY_ERP_MALL_USER_LEVEL, source.supplierCode), String.valueOf(userLevel.id), jsonConvert.convertTo(userLevel))
  72. return RetResult.<InvokeCallResult> successT()
  73. }
  74. RetResult.<InvokeCallResult>errorT().retinfo("增加用户级别失败")
  75. }
  76. }