KuaishouRewardBaseInfoController.java 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. package com.ruixuan.isc.controller;
  2. import java.util.List;
  3. import javax.servlet.http.HttpServletResponse;
  4. import com.alibaba.fastjson.JSONObject;
  5. import com.ruixuan.common.annotation.Log;
  6. import com.ruixuan.common.core.controller.BaseController;
  7. import com.ruixuan.common.core.domain.AjaxResult;
  8. import com.ruixuan.common.core.page.TableDataInfo;
  9. import com.ruixuan.common.enums.BusinessType;
  10. import com.ruixuan.common.utils.Check;
  11. import com.ruixuan.common.utils.DateUtils;
  12. import com.ruixuan.common.utils.poi.ExcelUtil;
  13. import com.ruixuan.isc.entity.KuaishouRewardBaseInfo;
  14. import com.ruixuan.isc.service.IKuaishouRewardBaseInfoService;
  15. import org.springframework.security.access.prepost.PreAuthorize;
  16. import org.springframework.beans.factory.annotation.Autowired;
  17. import org.springframework.web.bind.annotation.GetMapping;
  18. import org.springframework.web.bind.annotation.PostMapping;
  19. import org.springframework.web.bind.annotation.PutMapping;
  20. import org.springframework.web.bind.annotation.DeleteMapping;
  21. import org.springframework.web.bind.annotation.PathVariable;
  22. import org.springframework.web.bind.annotation.RequestBody;
  23. import org.springframework.web.bind.annotation.RequestMapping;
  24. import org.springframework.web.bind.annotation.RestController;
  25. /**
  26. * 【请填写功能名称】Controller
  27. *
  28. * @author ruoyi
  29. * @date 2024-10-31
  30. */
  31. @RestController
  32. @RequestMapping("/finance/reward")
  33. public class KuaishouRewardBaseInfoController extends BaseController {
  34. @Autowired
  35. private IKuaishouRewardBaseInfoService kuaishouRewardBaseInfoService;
  36. /**
  37. * 查询【请填写功能名称】列表
  38. */
  39. @GetMapping("/list")
  40. public TableDataInfo list(KuaishouRewardBaseInfo kuaishouRewardBaseInfo) {
  41. startPage();
  42. List<KuaishouRewardBaseInfo> list = kuaishouRewardBaseInfoService.selectKuaishouRewardBaseInfoList(kuaishouRewardBaseInfo);
  43. return getDataTable(list);
  44. }
  45. @GetMapping("/getTotal")
  46. public JSONObject getTotal(KuaishouRewardBaseInfo kuaishouRewardBaseInfo) {
  47. JSONObject json = kuaishouRewardBaseInfoService.getTotal(kuaishouRewardBaseInfo);
  48. return json;
  49. }
  50. /**
  51. * 导出【请填写功能名称】列表
  52. */
  53. @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
  54. @PostMapping("/export")
  55. public void export(HttpServletResponse response, KuaishouRewardBaseInfo kuaishouRewardBaseInfo) {
  56. List<KuaishouRewardBaseInfo> list = kuaishouRewardBaseInfoService.selectKuaishouRewardBaseInfoList(kuaishouRewardBaseInfo);
  57. ExcelUtil<KuaishouRewardBaseInfo> util = new ExcelUtil<KuaishouRewardBaseInfo>(KuaishouRewardBaseInfo.class);
  58. util.exportExcel(response, list, "【请填写功能名称】数据");
  59. }
  60. /**
  61. * 获取【请填写功能名称】详细信息
  62. */
  63. @GetMapping(value = "/{id}")
  64. public AjaxResult getInfo(@PathVariable("id") Long id) {
  65. return AjaxResult.success(kuaishouRewardBaseInfoService.selectKuaishouRewardBaseInfoById(id));
  66. }
  67. /**
  68. * 新增【请填写功能名称】
  69. */
  70. @PostMapping("/add")
  71. public AjaxResult add(@RequestBody KuaishouRewardBaseInfo kuaishouRewardBaseInfo) {
  72. AjaxResult result = new AjaxResult();
  73. try {
  74. Long itemId = kuaishouRewardBaseInfo.getItemId();
  75. if (Check.isNull(itemId)) {
  76. throw new Exception("请输入商品ID");
  77. }
  78. String promoterId = kuaishouRewardBaseInfo.getPromoterId();
  79. if (Check.isNull(promoterId)) {
  80. throw new Exception("请输入达人ID");
  81. }
  82. String statDate = kuaishouRewardBaseInfo.getStatDate();
  83. if (Check.isNull(statDate)) {
  84. throw new Exception("请输入结算日期");
  85. }
  86. kuaishouRewardBaseInfo.setStatDate(statDate);
  87. Integer dataCount = kuaishouRewardBaseInfoService.checkData(itemId, promoterId, statDate);
  88. if (dataCount >= 1) {
  89. throw new Exception("此达人下此商品所选日期已结算");
  90. }
  91. JSONObject getInfo = kuaishouRewardBaseInfoService.getInfo(itemId, promoterId);
  92. if (!Check.isNull(getInfo)) {
  93. String itemName = getInfo.getString("itemName");
  94. if (!Check.isNull(itemName)) {
  95. kuaishouRewardBaseInfo.setItemTitle(itemName);
  96. }
  97. String promoterName = getInfo.getString("promoterName");
  98. if (!Check.isNull(promoterName)) {
  99. kuaishouRewardBaseInfo.setPromoterName(promoterName);
  100. }
  101. }
  102. return toAjax(kuaishouRewardBaseInfoService.insertKuaishouRewardBaseInfo(kuaishouRewardBaseInfo));
  103. } catch (Exception e) {
  104. result.put("code", 500);
  105. result.put("msg", e.getMessage());
  106. return result;
  107. }
  108. }
  109. /**
  110. * 修改【请填写功能名称】
  111. */
  112. @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
  113. @PutMapping
  114. public AjaxResult edit(@RequestBody KuaishouRewardBaseInfo kuaishouRewardBaseInfo) {
  115. return toAjax(kuaishouRewardBaseInfoService.updateKuaishouRewardBaseInfo(kuaishouRewardBaseInfo));
  116. }
  117. /**
  118. * 删除【请填写功能名称】
  119. */
  120. @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
  121. @DeleteMapping("/{ids}")
  122. public AjaxResult remove(@PathVariable Long[] ids) {
  123. return toAjax(kuaishouRewardBaseInfoService.deleteKuaishouRewardBaseInfoByIds(ids));
  124. }
  125. }