Explorar el Código

Merge branch 'master' of http://192.168.101.10:13000/LIVE_YE/qianshanCreditInterests

wangmengwei hace 2 años
padre
commit
4c1fbb5ce9
Se han modificado 40 ficheros con 2218 adiciones y 35 borrados
  1. 0 3
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/business/UsageRecordController.java
  2. 111 0
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/business/UseGuideController.java
  3. 113 0
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/business/WelfareGuideController.java
  4. 27 0
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java
  5. 16 6
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java
  6. 177 0
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/wechat/AppletLoginController.java
  7. 5 1
      ruoyi-admin/src/main/resources/application-druid.yml
  8. 5 1
      ruoyi-admin/src/main/resources/application-prod.yml
  9. 28 0
      ruoyi-common/pom.xml
  10. 55 0
      ruoyi-common/src/main/java/com/ruoyi/common/core/domain/dto/AppletLoginForm.java
  11. 53 0
      ruoyi-common/src/main/java/com/ruoyi/common/core/domain/dto/AppletSessionDTO.java
  12. 21 0
      ruoyi-common/src/main/java/com/ruoyi/common/core/domain/dto/WechatEnum.java
  13. 31 17
      ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/LoginBody.java
  14. 57 0
      ruoyi-common/src/main/java/com/ruoyi/common/utils/AppletDecryptDataUtil.java
  15. 278 0
      ruoyi-common/src/main/java/com/ruoyi/common/utils/Base64.java
  16. 114 0
      ruoyi-common/src/main/java/com/ruoyi/common/utils/WxCodeSessionUtil.java
  17. 112 0
      ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpClientUtils.java
  18. 2 2
      ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java
  19. 39 0
      ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java
  20. 1 1
      ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/TokenService.java
  21. 27 0
      ruoyi-system/src/main/java/com/ruoyi/system/domain/UsageRecord.java
  22. 111 0
      ruoyi-system/src/main/java/com/ruoyi/system/domain/UseGuide.java
  23. 97 0
      ruoyi-system/src/main/java/com/ruoyi/system/domain/WelfareGuide.java
  24. 3 0
      ruoyi-system/src/main/java/com/ruoyi/system/mapper/InterestsTableMapper.java
  25. 2 0
      ruoyi-system/src/main/java/com/ruoyi/system/mapper/SettledMerchantsMapper.java
  26. 63 0
      ruoyi-system/src/main/java/com/ruoyi/system/mapper/UseGuideMapper.java
  27. 63 0
      ruoyi-system/src/main/java/com/ruoyi/system/mapper/WelfareGuideMapper.java
  28. 2 0
      ruoyi-system/src/main/java/com/ruoyi/system/service/ISettledMerchantsService.java
  29. 65 0
      ruoyi-system/src/main/java/com/ruoyi/system/service/IUseGuideService.java
  30. 65 0
      ruoyi-system/src/main/java/com/ruoyi/system/service/IWelfareGuideService.java
  31. 1 1
      ruoyi-system/src/main/java/com/ruoyi/system/service/impl/PolicyMenuServiceImpl.java
  32. 22 0
      ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SettledMerchantsServiceImpl.java
  33. 9 0
      ruoyi-system/src/main/java/com/ruoyi/system/service/impl/UsageRecordServiceImpl.java
  34. 108 0
      ruoyi-system/src/main/java/com/ruoyi/system/service/impl/UseGuideServiceImpl.java
  35. 108 0
      ruoyi-system/src/main/java/com/ruoyi/system/service/impl/WelfareGuideServiceImpl.java
  36. 6 1
      ruoyi-system/src/main/resources/mapper/system/InterestsTableMapper.xml
  37. 5 1
      ruoyi-system/src/main/resources/mapper/system/SettledMerchantsMapper.xml
  38. 24 1
      ruoyi-system/src/main/resources/mapper/system/UsageRecordMapper.xml
  39. 98 0
      ruoyi-system/src/main/resources/mapper/system/UseGuideMapper.xml
  40. 94 0
      ruoyi-system/src/main/resources/mapper/system/WelfareGuideMapper.xml

+ 0 - 3
ruoyi-admin/src/main/java/com/ruoyi/web/controller/business/UsageRecordController.java

@@ -37,7 +37,6 @@ public class UsageRecordController extends BaseController
     /**
      * 查询使用记录列表
      */
-    @PreAuthorize("@ss.hasPermi('system:record:list')")
     @GetMapping("/list")
     public TableDataInfo list(UsageRecord usageRecord)
     {
@@ -62,7 +61,6 @@ public class UsageRecordController extends BaseController
     /**
      * 获取使用记录详细信息
      */
-    @PreAuthorize("@ss.hasPermi('system:record:query')")
     @GetMapping(value = "/{recordId}")
     public AjaxResult getInfo(@PathVariable("recordId") Long recordId)
     {
@@ -72,7 +70,6 @@ public class UsageRecordController extends BaseController
     /**
      * 新增使用记录
      */
-    @PreAuthorize("@ss.hasPermi('system:record:add')")
     @Log(title = "使用记录", businessType = BusinessType.INSERT)
     @PostMapping
     public AjaxResult add(@RequestBody UsageRecord usageRecord)

+ 111 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/business/UseGuideController.java

@@ -0,0 +1,111 @@
+package com.ruoyi.web.controller.business;
+
+import java.util.List;
+import javax.servlet.http.HttpServletResponse;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import com.ruoyi.common.annotation.Log;
+import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.enums.BusinessType;
+import com.ruoyi.system.domain.UseGuide;
+import com.ruoyi.system.service.IUseGuideService;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.common.core.page.TableDataInfo;
+
+/**
+ * 使用指南Controller
+ * 
+ * @author ruoyi
+ * @date 2022-07-14
+ */
+@RestController
+@RequestMapping("/system/use")
+public class UseGuideController extends BaseController
+{
+    @Autowired
+    private IUseGuideService useGuideService;
+
+    /**
+     * 查询使用指南列表
+     */
+    @GetMapping("/list")
+    public TableDataInfo list(UseGuide useGuide)
+    {
+        startPage();
+        List<UseGuide> list = useGuideService.selectUseGuideList(useGuide);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出使用指南列表
+     */
+    @Log(title = "使用指南", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, UseGuide useGuide)
+    {
+        List<UseGuide> list = useGuideService.selectUseGuideList(useGuide);
+        ExcelUtil<UseGuide> util = new ExcelUtil<UseGuide>(UseGuide.class);
+        util.exportExcel(response, list, "使用指南数据");
+    }
+
+    /**
+     * 获取使用指南详细信息
+     */
+    @GetMapping(value = "/{id}")
+    public AjaxResult getInfo(@PathVariable("id") Long id)
+    {
+        return AjaxResult.success(useGuideService.selectUseGuideById(id));
+    }
+
+    /**
+     * 新增使用指南
+     */
+    @PreAuthorize("@ss.hasPermi('system:use:add')")
+    @Log(title = "使用指南", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody UseGuide useGuide)
+    {
+        return toAjax(useGuideService.insertUseGuide(useGuide));
+    }
+
+    /**
+     * 修改使用指南
+     */
+    @PreAuthorize("@ss.hasPermi('system:use:edit')")
+    @Log(title = "使用指南", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody UseGuide useGuide)
+    {
+        return toAjax(useGuideService.updateUseGuide(useGuide));
+    }
+
+    /**
+     * 删除使用指南
+     */
+    @PreAuthorize("@ss.hasPermi('system:use:remove')")
+    @Log(title = "使用指南", businessType = BusinessType.DELETE)
+	@DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable Long[] ids)
+    {
+        return toAjax(useGuideService.deleteUseGuideByIds(ids));
+    }
+
+    /**
+     * 获取最新的使用指南详细信息
+     */
+    @GetMapping(value = "/new")
+    public AjaxResult getInfoNew()
+    {
+        return useGuideService.getInfoNew();
+    }
+
+}

+ 113 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/business/WelfareGuideController.java

@@ -0,0 +1,113 @@
+package com.ruoyi.web.controller.business;
+
+import java.util.List;
+import javax.servlet.http.HttpServletResponse;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import com.ruoyi.common.annotation.Log;
+import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.enums.BusinessType;
+import com.ruoyi.system.domain.WelfareGuide;
+import com.ruoyi.system.service.IWelfareGuideService;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.common.core.page.TableDataInfo;
+
+/**
+ * 小程序党建福利信息Controller
+ * 
+ * @author ruoyi
+ * @date 2022-07-14
+ */
+@RestController
+@RequestMapping("/system/welfare")
+public class WelfareGuideController extends BaseController
+{
+    @Autowired
+    private IWelfareGuideService welfareGuideService;
+
+    /**
+     * 查询小程序党建福利信息列表
+     */
+    @PreAuthorize("@ss.hasPermi('system:welfare:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(WelfareGuide welfareGuide)
+    {
+        startPage();
+        List<WelfareGuide> list = welfareGuideService.selectWelfareGuideList(welfareGuide);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出小程序党建福利信息列表
+     */
+    @PreAuthorize("@ss.hasPermi('system:welfare:export')")
+    @Log(title = "小程序党建福利信息", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, WelfareGuide welfareGuide)
+    {
+        List<WelfareGuide> list = welfareGuideService.selectWelfareGuideList(welfareGuide);
+        ExcelUtil<WelfareGuide> util = new ExcelUtil<WelfareGuide>(WelfareGuide.class);
+        util.exportExcel(response, list, "小程序党建福利信息数据");
+    }
+
+    /**
+     * 获取小程序党建福利信息详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('system:welfare:query')")
+    @GetMapping(value = "/{id}")
+    public AjaxResult getInfo(@PathVariable("id") Long id)
+    {
+        return AjaxResult.success(welfareGuideService.selectWelfareGuideById(id));
+    }
+
+    /**
+     * 新增小程序党建福利信息
+     */
+    @PreAuthorize("@ss.hasPermi('system:welfare:add')")
+    @Log(title = "小程序党建福利信息", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody WelfareGuide welfareGuide)
+    {
+        return toAjax(welfareGuideService.insertWelfareGuide(welfareGuide));
+    }
+
+    /**
+     * 修改小程序党建福利信息
+     */
+    @PreAuthorize("@ss.hasPermi('system:welfare:edit')")
+    @Log(title = "小程序党建福利信息", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody WelfareGuide welfareGuide)
+    {
+        return toAjax(welfareGuideService.updateWelfareGuide(welfareGuide));
+    }
+
+    /**
+     * 删除小程序党建福利信息
+     */
+    @PreAuthorize("@ss.hasPermi('system:welfare:remove')")
+    @Log(title = "小程序党建福利信息", businessType = BusinessType.DELETE)
+	@DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable Long[] ids)
+    {
+        return toAjax(welfareGuideService.deleteWelfareGuideByIds(ids));
+    }
+
+    /**
+     * 获取最新的小程序党建福利详细信息
+     */
+    @GetMapping(value = "/new")
+    public AjaxResult getInfoNew()
+    {
+        return welfareGuideService.getInfoNew();
+    }
+}

+ 27 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java

@@ -6,6 +6,9 @@ import java.util.Set;
 import com.ruoyi.common.core.domain.R;
 import com.ruoyi.common.core.domain.model.LoginUser;
 import com.ruoyi.framework.web.service.TokenService;
+import com.ruoyi.system.domain.SettledMerchants;
+import com.ruoyi.system.service.ISettledMerchantsService;
+import com.ruoyi.system.service.ISysUserService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import com.ruoyi.common.constant.Constants;
@@ -38,6 +41,12 @@ public class SysLoginController
     @Autowired
     private TokenService tokenService;
 
+    @Autowired
+    private ISysUserService userService;
+
+    @Autowired
+    private ISettledMerchantsService settledMerchantsService;
+
     /**
      * 登录方法
      * 
@@ -55,6 +64,24 @@ public class SysLoginController
         return ajax;
     }
 
+
+    @PostMapping("/loginApp")
+    public AjaxResult loginApp(@RequestBody LoginBody loginBody)
+    {
+        AjaxResult ajax = AjaxResult.success();
+        // 生成令牌
+        String token = loginService.loginApp(loginBody.getUsername(), loginBody.getPassword(),
+                loginBody.getUuid());
+        ajax.put(Constants.TOKEN, token);
+        //根据userName查询用户
+        SysUser user = userService.selectUserByUserName(loginBody.getUsername());
+        ajax.put("userId", user.getUserId());
+        //获取商家的信息
+        SettledMerchants settledMerchants = settledMerchantsService.selectByPhone(user.getUserName());
+        ajax.put("settledMerchants", settledMerchants);
+        return ajax;
+    }
+
     /**
      * 获取用户信息
      * 

+ 16 - 6
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java

@@ -98,7 +98,6 @@ public class SysUserController extends BaseController
     /**
      * 根据用户编号获取详细信息
      */
-    @PreAuthorize("@ss.hasPermi('system:user:query')")
     @GetMapping(value = { "/", "/{userId}" })
     public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId)
     {
@@ -120,7 +119,6 @@ public class SysUserController extends BaseController
     /**
      * 新增用户
      */
-    @PreAuthorize("@ss.hasPermi('system:user:add')")
     @Log(title = "用户管理", businessType = BusinessType.INSERT)
     @PostMapping
     public AjaxResult add(@Validated @RequestBody SysUser user)
@@ -147,7 +145,6 @@ public class SysUserController extends BaseController
     /**
      * 修改用户
      */
-    @PreAuthorize("@ss.hasPermi('system:user:edit')")
     @Log(title = "用户管理", businessType = BusinessType.UPDATE)
     @PutMapping
     public AjaxResult edit(@Validated @RequestBody SysUser user)
@@ -186,13 +183,26 @@ public class SysUserController extends BaseController
     /**
      * 重置密码
      */
-    @PreAuthorize("@ss.hasPermi('system:user:resetPwd')")
     @Log(title = "用户管理", businessType = BusinessType.UPDATE)
     @PutMapping("/resetPwd")
     public AjaxResult resetPwd(@RequestBody SysUser user)
     {
-        userService.checkUserAllowed(user);
-        userService.checkUserDataScope(user.getUserId());
+        //userService.checkUserAllowed(user);
+        //userService.checkUserDataScope(user.getUserId());
+        user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
+        user.setUpdateBy(getUsername());
+        return toAjax(userService.resetPwd(user));
+    }
+
+    /**
+     * 修改密码
+     */
+    @Log(title = "用户管理", businessType = BusinessType.UPDATE)
+    @PostMapping("/updatePwd")
+    public AjaxResult updatePwd(@RequestBody SysUser user)
+    {
+        //userService.checkUserAllowed(user);
+        //userService.checkUserDataScope(user.getUserId());
         user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
         user.setUpdateBy(getUsername());
         return toAjax(userService.resetPwd(user));

+ 177 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/wechat/AppletLoginController.java

@@ -0,0 +1,177 @@
+package com.ruoyi.web.controller.wechat;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.ruoyi.common.constant.CacheConstants;
+import com.ruoyi.common.constant.Constants;
+import com.ruoyi.common.core.domain.R;
+import com.ruoyi.common.core.domain.UserEnvConstant;
+import com.ruoyi.common.core.domain.dto.AppletLoginForm;
+import com.ruoyi.common.core.domain.dto.AppletSessionDTO;
+import com.ruoyi.common.core.domain.entity.SysDept;
+import com.ruoyi.common.core.domain.entity.SysUser;
+import com.ruoyi.common.core.domain.model.LoginUser;
+import com.ruoyi.common.core.redis.RedisCache;
+import com.ruoyi.common.core.redis.RedisService;
+import com.ruoyi.common.enums.UserStatus;
+import com.ruoyi.common.exception.base.BaseException;
+import com.ruoyi.common.utils.ObjectUtils;
+import com.ruoyi.common.utils.ServletUtils;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.common.utils.WxCodeSessionUtil;
+import com.ruoyi.common.utils.ip.AddressUtils;
+import com.ruoyi.common.utils.ip.IpUtils;
+import com.ruoyi.common.utils.uuid.IdUtils;
+import com.ruoyi.framework.web.service.TokenService;
+import com.ruoyi.system.domain.SettledMerchants;
+import com.ruoyi.system.service.ISettledMerchantsService;
+import com.ruoyi.system.service.ISysLogininforService;
+import com.ruoyi.system.service.ISysUserService;
+import eu.bitwalker.useragentutils.UserAgent;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @author shiqian
+ * @date 2021年09月08日 17:29
+ **/
+@RestController
+@RequestMapping("/applet")
+public class AppletLoginController {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(AppletLoginController.class);
+
+    private final static long EXPIRE_TIME = Constants.TOKEN_EXPIRE * 60;
+
+    private final static long EXPIRE_TIME_QR = 3 * 60;
+
+    private final static String ACCESS_TOKEN = CacheConstants.LOGIN_TOKEN_KEY;
+
+    protected static final long MILLIS_SECOND = 1000;
+
+    @Resource
+    private WxCodeSessionUtil codeUtil;
+    @Resource
+    private RedisService redisService;
+    @Resource
+    private ISysUserService iSysUserService;
+    @Resource
+    private ISysLogininforService iSysLogininforService;
+    @Autowired
+    private ISettledMerchantsService settledMerchantsService;
+    @Autowired
+    private RedisCache redisCache;
+    @Autowired
+    private TokenService tokenService;
+
+
+    @PostMapping("/login")
+    public R<Map<String, Object>> getPhone(@RequestBody AppletLoginForm form) {
+
+        AppletSessionDTO dto = codeUtil.jscode2Session(form);
+        String phoneNumber = dto.getPhoneNumber();
+        if (StringUtils.isBlank(phoneNumber)) {
+            throw new BaseException("对不起,未获取到手机号");
+        }
+        SysUser user = iSysUserService.getByPhone(dto.getPhoneNumber());
+        if (user == null) {
+            throw new BaseException("对不起,未获取到相关信息");
+        }
+        String userName = user.getUserName();
+        if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) {
+            throw new BaseException("对不起,您的账号:" + userName + " 已被删除");
+        }
+
+        if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
+            throw new BaseException("对不起,您的账号:" + userName + " 已停用");
+        }
+
+
+        LOGGER.info("appletLogin, remoteUserService: {}", iSysUserService);
+        //获取当前用户信息
+        LoginUser loginUser = new LoginUser();
+        loginUser.setUser(user);
+        LOGGER.info("appletLogin, loginUser: {}", JSON.toJSONString(loginUser));
+        return R.ok(createToken(loginUser));
+    }
+
+    public Map<String, Object> createToken(LoginUser loginUser) {
+        // 生成token
+        String token = IdUtils.fastUUID();
+        loginUser.setToken(token);
+        loginUser.setUserId(loginUser.getUser().getUserId());
+        loginUser.setUserName(loginUser.getUser().getUserName());
+        loginUser.setIpaddr(IpUtils.getIpAddr(ServletUtils.getRequest()));
+
+        JSONObject userEnv = packUserEnv(loginUser);
+        loginUser.setUserEnv(userEnv);
+        //loginUser.setLoginType("App");
+
+        //设置用户代理信息
+        UserAgent userAgent = UserAgent.parseUserAgentString(ServletUtils.getRequest().getHeader("User-Agent"));
+        String ip = IpUtils.getIpAddr(ServletUtils.getRequest());
+        loginUser.setIpaddr(ip);
+        loginUser.setLoginLocation(AddressUtils.getRealAddressByIP(ip));
+        loginUser.setBrowser(userAgent.getBrowser().getName());
+        loginUser.setOs(userAgent.getOperatingSystem().getName());
+
+        refreshToken(loginUser);
+
+        Map<String, Object> claims = new HashMap<>();
+        claims.put(Constants.LOGIN_USER_KEY, token);
+        // 保存或更新用户token
+        Map<String, Object> map = new HashMap<String, Object>();
+        map.put("access_token", tokenService.createToken(claims));
+        map.put("expires_in", EXPIRE_TIME);
+        //redisService.setCacheObject(ACCESS_TOKEN + token, loginUser, EXPIRE_TIME, TimeUnit.SECONDS);
+
+        //获取商家的信息
+        SettledMerchants settledMerchants = settledMerchantsService.selectByPhone(loginUser.getUser().getUserName());
+        map.put("settledMerchants", settledMerchants);
+        map.put("userId", loginUser.getUser().getUserId());
+        return map;
+    }
+
+    public void refreshToken(LoginUser loginUser) {
+        loginUser.setLoginTime(System.currentTimeMillis());
+        loginUser.setExpireTime(loginUser.getLoginTime() + EXPIRE_TIME * MILLIS_SECOND);
+        // 根据uuid将loginUser缓存
+        String userKey = getTokenKey(loginUser.getToken());
+        redisCache.setCacheObject(userKey, loginUser, (int)EXPIRE_TIME, TimeUnit.SECONDS);
+
+    }
+
+    private String getTokenKey(String token) {
+        return ACCESS_TOKEN + token;
+    }
+
+    private JSONObject packUserEnv(LoginUser loginUser) {
+        JSONObject userEnv = new JSONObject();
+        userEnv.put(UserEnvConstant.USER_ID, loginUser.getUserId());
+        userEnv.put(UserEnvConstant.USERNAME, loginUser.getUsername());
+
+        //SysDept dept = loginUser.getSysUser().getDept();
+        //userEnv.put(UserEnvConstant.USER_DEPT_ID, loginUser.getSysUser().getDeptId());
+        //userEnv.put(UserEnvConstant.USER_DEPT_NAME, dept.getDeptName());
+
+       /* Long parentId = dept.getParentId();
+        SysDept parentDept = remoteDeptService.getById(parentId);
+        if (ObjectUtils.isNotEmpty(parentDept)) {
+            userEnv.put(UserEnvConstant.USER_PARENT_DEPT_ID, parentDept.getId());
+            userEnv.put(UserEnvConstant.USER_PARENT_DEPT_NAME, parentDept.getDeptName());
+        }*/
+
+        return userEnv;
+    }
+}

+ 5 - 1
ruoyi-admin/src/main/resources/application-druid.yml

@@ -94,4 +94,8 @@ spring:
                 # 连接池的最大数据库连接数
                 max-active: 8
                 # #连接池最大阻塞等待时间(使用负值表示没有限制)
-                max-wait: -1ms
+                max-wait: -1ms
+
+wx:
+    appId: wxb9b83f3c86545690
+    appSecret: 95adc6921a24a3c6cff55f2a1290f6f6

+ 5 - 1
ruoyi-admin/src/main/resources/application-prod.yml

@@ -95,4 +95,8 @@ spring:
                 # 连接池的最大数据库连接数
                 max-active: 8
                 # #连接池最大阻塞等待时间(使用负值表示没有限制)
-                max-wait: -1ms
+                max-wait: -1ms
+
+wx:
+    appId: wxb9b83f3c86545690
+    appSecret: 95adc6921a24a3c6cff55f2a1290f6f6

+ 28 - 0
ruoyi-common/pom.xml

@@ -125,6 +125,34 @@
             <artifactId>javax.servlet-api</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <version>1.18.4</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+            <version>4.5</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpmime</artifactId>
+            <version>4.5</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpcore</artifactId>
+            <version>4.4.1</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.bouncycastle</groupId>
+            <artifactId>bcprov-jdk15on</artifactId>
+            <version>1.56</version>
+        </dependency>
+
     </dependencies>
 
 </project>

+ 55 - 0
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/dto/AppletLoginForm.java

@@ -0,0 +1,55 @@
+package com.ruoyi.common.core.domain.dto;
+
+import com.ruoyi.common.core.domain.entity.SysUser;
+
+/**
+ * @author
+ * @date 2021年09月08日 17:15
+ **/
+public class AppletLoginForm {
+
+
+    // 微信code
+    private String code;
+
+    // 微信用户基本信息
+    private SysUser user;
+
+    // 加密数据
+    private String encryptedData;
+
+    // 向量
+    private String iv;
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public SysUser getUser() {
+        return user;
+    }
+
+    public void setUser(SysUser user) {
+        this.user = user;
+    }
+
+    public String getEncryptedData() {
+        return encryptedData;
+    }
+
+    public void setEncryptedData(String encryptedData) {
+        this.encryptedData = encryptedData;
+    }
+
+    public String getIv() {
+        return iv;
+    }
+
+    public void setIv(String iv) {
+        this.iv = iv;
+    }
+}

+ 53 - 0
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/dto/AppletSessionDTO.java

@@ -0,0 +1,53 @@
+package com.ruoyi.common.core.domain.dto;
+
+
+/**
+ * 微信通用接口凭证
+ */
+
+public class AppletSessionDTO {
+
+    // 授权openid
+    private String openId;
+
+    // 微信会话session
+    private String sessionKey;
+
+    // 微信用户唯一unionid
+    private String unionId;
+
+    // 绑定手机号
+    private String phoneNumber;
+
+    public String getOpenId() {
+        return openId;
+    }
+
+    public void setOpenId(String openId) {
+        this.openId = openId;
+    }
+
+    public String getSessionKey() {
+        return sessionKey;
+    }
+
+    public void setSessionKey(String sessionKey) {
+        this.sessionKey = sessionKey;
+    }
+
+    public String getUnionId() {
+        return unionId;
+    }
+
+    public void setUnionId(String unionId) {
+        this.unionId = unionId;
+    }
+
+    public String getPhoneNumber() {
+        return phoneNumber;
+    }
+
+    public void setPhoneNumber(String phoneNumber) {
+        this.phoneNumber = phoneNumber;
+    }
+}

+ 21 - 0
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/dto/WechatEnum.java

@@ -0,0 +1,21 @@
+package com.ruoyi.common.core.domain.dto;
+
+public enum WechatEnum {
+    /** 用户账号登录 */
+    U("u"),
+    /** 微信授权登录 */
+    W("w");
+
+
+    private String value;
+
+    private WechatEnum(String value)
+    {
+        this.value = value;
+    }
+
+    public String getValue()
+    {
+        return value;
+    }
+}

+ 31 - 17
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/LoginBody.java

@@ -5,8 +5,7 @@ package com.ruoyi.common.core.domain.model;
  * 
  * @author ruoyi
  */
-public class LoginBody
-{
+public class LoginBody {
     /**
      * 用户名
      */
@@ -17,16 +16,35 @@ public class LoginBody
      */
     private String password;
 
-    /**
-     * 验证码
-     */
     private String code;
 
+    private String logintype;
+
     /**
-     * 唯一标识
+     * 手机号
+     */
+    private String phone;
+    /**
+     * 扫码登录的uuid
      */
     private String uuid;
 
+    public String getPhone() {
+        return phone;
+    }
+
+    public void setPhone(String phone) {
+        this.phone = phone;
+    }
+
+    public String getUuid() {
+        return uuid;
+    }
+
+    public void setUuid(String uuid) {
+        this.uuid = uuid;
+    }
+
     public String getUsername()
     {
         return username;
@@ -47,23 +65,19 @@ public class LoginBody
         this.password = password;
     }
 
-    public String getCode()
-    {
+    public String getCode() {
         return code;
     }
 
-    public void setCode(String code)
-    {
+    public void setCode(String code) {
         this.code = code;
     }
 
-    public String getUuid()
-    {
-        return uuid;
+    public String getLogintype() {
+        return logintype;
     }
 
-    public void setUuid(String uuid)
-    {
-        this.uuid = uuid;
+    public void setLogintype(String logintype) {
+        this.logintype = logintype;
     }
-}
+}

+ 57 - 0
ruoyi-common/src/main/java/com/ruoyi/common/utils/AppletDecryptDataUtil.java

@@ -0,0 +1,57 @@
+package com.ruoyi.common.utils;
+
+import com.alibaba.fastjson.JSONObject;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+
+import javax.crypto.Cipher;
+import javax.crypto.spec.IvParameterSpec;
+import javax.crypto.spec.SecretKeySpec;
+import java.security.AlgorithmParameters;
+import java.security.Security;
+import java.util.Arrays;
+
+/**
+ * 解密工具
+ */
+public class AppletDecryptDataUtil {
+
+    public static JSONObject decryptData(byte[] keyByte, byte[] ivByte, byte[] dataByte) throws Exception {
+        // 如果密钥不足16位,那么就补足.  这个if 中的内容很重要
+        int base = 16;
+        if (keyByte.length % base != 0) {
+            int groups = keyByte.length / base + (keyByte.length % base != 0 ? 1 : 0);
+            byte[] temp = new byte[groups * base];
+            Arrays.fill(temp, (byte) 0);
+            System.arraycopy(keyByte, 0, temp, 0, keyByte.length);
+            keyByte = temp;
+        }
+
+        byte[] resultByte;
+        // 初始化
+        Security.addProvider(new BouncyCastleProvider());
+        try {
+            Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
+            SecretKeySpec spec = new SecretKeySpec(keyByte, "AES");
+            AlgorithmParameters parameters = AlgorithmParameters.getInstance("AES");
+            parameters.init(new IvParameterSpec(ivByte));
+            cipher.init(Cipher.DECRYPT_MODE, spec, parameters);// 初始化
+            resultByte = cipher.doFinal(dataByte);
+            if (null == resultByte || resultByte.length <= 0) {
+                return null;
+            }
+        }catch (Exception e){
+            Cipher cipher = Cipher.getInstance("AES/CBC/PKCS7Padding","BC");
+            SecretKeySpec spec = new SecretKeySpec(keyByte, "AES");
+            AlgorithmParameters parameters = AlgorithmParameters.getInstance("AES");
+            parameters.init(new IvParameterSpec(ivByte));
+            cipher.init(Cipher.DECRYPT_MODE, spec, parameters);// 初始化
+            resultByte = cipher.doFinal(dataByte);
+            if (null == resultByte || resultByte.length <= 0) {
+                return null;
+            }
+        }
+
+        String result = new String(resultByte, "UTF-8");
+        return JSONObject.parseObject(result);
+    }
+}

+ 278 - 0
ruoyi-common/src/main/java/com/ruoyi/common/utils/Base64.java

@@ -0,0 +1,278 @@
+package com.ruoyi.common.utils;
+
+/*
+ * Copyright (C) 2010 The MobileSecurePay Project
+ * All right reserved.
+ * author: shiqun.shi@alipay.com
+ */
+public final class Base64 {
+
+    static private final int BASELENGTH = 128;
+    static private final int LOOKUPLENGTH = 64;
+    static private final int TWENTYFOURBITGROUP = 24;
+    static private final int EIGHTBIT = 8;
+    static private final int SIXTEENBIT = 16;
+    static private final int FOURBYTE = 4;
+    static private final int SIGN = -128;
+    static private final char PAD = '=';
+    static private final boolean fDebug = false;
+    static final private byte[] base64Alphabet = new byte[BASELENGTH];
+    static final private char[] lookUpBase64Alphabet = new char[LOOKUPLENGTH];
+
+    static {
+        for (int i = 0; i < BASELENGTH; ++i) {
+            base64Alphabet[i] = -1;
+        }
+        for (int i = 'Z'; i >= 'A'; i--) {
+            base64Alphabet[i] = (byte) (i - 'A');
+        }
+        for (int i = 'z'; i >= 'a'; i--) {
+            base64Alphabet[i] = (byte) (i - 'a' + 26);
+        }
+
+        for (int i = '9'; i >= '0'; i--) {
+            base64Alphabet[i] = (byte) (i - '0' + 52);
+        }
+
+        base64Alphabet['+'] = 62;
+        base64Alphabet['/'] = 63;
+
+        for (int i = 0; i <= 25; i++) {
+            lookUpBase64Alphabet[i] = (char) ('A' + i);
+        }
+
+        for (int i = 26, j = 0; i <= 51; i++, j++) {
+            lookUpBase64Alphabet[i] = (char) ('a' + j);
+        }
+
+        for (int i = 52, j = 0; i <= 61; i++, j++) {
+            lookUpBase64Alphabet[i] = (char) ('0' + j);
+        }
+        lookUpBase64Alphabet[62] = (char) '+';
+        lookUpBase64Alphabet[63] = (char) '/';
+
+    }
+
+    private static boolean isWhiteSpace(char octect) {
+        return (octect == 0x20 || octect == 0xd || octect == 0xa || octect == 0x9);
+    }
+
+    private static boolean isPad(char octect) {
+        return (octect == PAD);
+    }
+
+    private static boolean isData(char octect) {
+        return (octect < BASELENGTH && base64Alphabet[octect] != -1);
+    }
+
+    /**
+     * Encodes hex octects into Base64
+     *
+     * @param binaryData Array containing binaryData
+     * @return Encoded Base64 array
+     */
+    public static String encode(byte[] binaryData) {
+
+        if (binaryData == null) {
+            return null;
+        }
+
+        int lengthDataBits = binaryData.length * EIGHTBIT;
+        if (lengthDataBits == 0) {
+            return "";
+        }
+
+        int fewerThan24bits = lengthDataBits % TWENTYFOURBITGROUP;
+        int numberTriplets = lengthDataBits / TWENTYFOURBITGROUP;
+        int numberQuartet = fewerThan24bits != 0 ? numberTriplets + 1 : numberTriplets;
+        char encodedData[] = null;
+
+        encodedData = new char[numberQuartet * 4];
+
+        byte k = 0, l = 0, b1 = 0, b2 = 0, b3 = 0;
+
+        int encodedIndex = 0;
+        int dataIndex = 0;
+        if (fDebug) {
+            System.out.println("number of triplets = " + numberTriplets);
+        }
+
+        for (int i = 0; i < numberTriplets; i++) {
+            b1 = binaryData[dataIndex++];
+            b2 = binaryData[dataIndex++];
+            b3 = binaryData[dataIndex++];
+
+            if (fDebug) {
+                System.out.println("b1= " + b1 + ", b2= " + b2 + ", b3= " + b3);
+            }
+
+            l = (byte) (b2 & 0x0f);
+            k = (byte) (b1 & 0x03);
+
+            byte val1 = ((b1 & SIGN) == 0) ? (byte) (b1 >> 2) : (byte) ((b1) >> 2 ^ 0xc0);
+            byte val2 = ((b2 & SIGN) == 0) ? (byte) (b2 >> 4) : (byte) ((b2) >> 4 ^ 0xf0);
+            byte val3 = ((b3 & SIGN) == 0) ? (byte) (b3 >> 6) : (byte) ((b3) >> 6 ^ 0xfc);
+
+            if (fDebug) {
+                System.out.println("val2 = " + val2);
+                System.out.println("k4   = " + (k << 4));
+                System.out.println("vak  = " + (val2 | (k << 4)));
+            }
+
+            encodedData[encodedIndex++] = lookUpBase64Alphabet[val1];
+            encodedData[encodedIndex++] = lookUpBase64Alphabet[val2 | (k << 4)];
+            encodedData[encodedIndex++] = lookUpBase64Alphabet[(l << 2) | val3];
+            encodedData[encodedIndex++] = lookUpBase64Alphabet[b3 & 0x3f];
+        }
+
+        // form integral number of 6-bit groups
+        if (fewerThan24bits == EIGHTBIT) {
+            b1 = binaryData[dataIndex];
+            k = (byte) (b1 & 0x03);
+            if (fDebug) {
+                System.out.println("b1=" + b1);
+                System.out.println("b1<<2 = " + (b1 >> 2));
+            }
+            byte val1 = ((b1 & SIGN) == 0) ? (byte) (b1 >> 2) : (byte) ((b1) >> 2 ^ 0xc0);
+            encodedData[encodedIndex++] = lookUpBase64Alphabet[val1];
+            encodedData[encodedIndex++] = lookUpBase64Alphabet[k << 4];
+            encodedData[encodedIndex++] = PAD;
+            encodedData[encodedIndex++] = PAD;
+        } else if (fewerThan24bits == SIXTEENBIT) {
+            b1 = binaryData[dataIndex];
+            b2 = binaryData[dataIndex + 1];
+            l = (byte) (b2 & 0x0f);
+            k = (byte) (b1 & 0x03);
+
+            byte val1 = ((b1 & SIGN) == 0) ? (byte) (b1 >> 2) : (byte) ((b1) >> 2 ^ 0xc0);
+            byte val2 = ((b2 & SIGN) == 0) ? (byte) (b2 >> 4) : (byte) ((b2) >> 4 ^ 0xf0);
+
+            encodedData[encodedIndex++] = lookUpBase64Alphabet[val1];
+            encodedData[encodedIndex++] = lookUpBase64Alphabet[val2 | (k << 4)];
+            encodedData[encodedIndex++] = lookUpBase64Alphabet[l << 2];
+            encodedData[encodedIndex++] = PAD;
+        }
+
+        return new String(encodedData);
+    }
+
+    /**
+     * Decodes Base64 data into octects
+     *
+     * @param encoded string containing Base64 data
+     * @return Array containind decoded data.
+     */
+    public static byte[] decode(String encoded) {
+
+        if (encoded == null) {
+            return null;
+        }
+
+        char[] base64Data = encoded.toCharArray();
+        // remove white spaces
+        int len = removeWhiteSpace(base64Data);
+
+        if (len % FOURBYTE != 0) {
+            return null;//should be divisible by four
+        }
+
+        int numberQuadruple = (len / FOURBYTE);
+
+        if (numberQuadruple == 0) {
+            return new byte[0];
+        }
+
+        byte decodedData[] = null;
+        byte b1 = 0, b2 = 0, b3 = 0, b4 = 0;
+        char d1 = 0, d2 = 0, d3 = 0, d4 = 0;
+
+        int i = 0;
+        int encodedIndex = 0;
+        int dataIndex = 0;
+        decodedData = new byte[(numberQuadruple) * 3];
+
+        for (; i < numberQuadruple - 1; i++) {
+
+            if (!isData((d1 = base64Data[dataIndex++])) || !isData((d2 = base64Data[dataIndex++]))
+                    || !isData((d3 = base64Data[dataIndex++]))
+                    || !isData((d4 = base64Data[dataIndex++]))) {
+                return null;
+            }//if found "no data" just return null
+
+            b1 = base64Alphabet[d1];
+            b2 = base64Alphabet[d2];
+            b3 = base64Alphabet[d3];
+            b4 = base64Alphabet[d4];
+
+            decodedData[encodedIndex++] = (byte) (b1 << 2 | b2 >> 4);
+            decodedData[encodedIndex++] = (byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf));
+            decodedData[encodedIndex++] = (byte) (b3 << 6 | b4);
+        }
+
+        if (!isData((d1 = base64Data[dataIndex++])) || !isData((d2 = base64Data[dataIndex++]))) {
+            return null;//if found "no data" just return null
+        }
+
+        b1 = base64Alphabet[d1];
+        b2 = base64Alphabet[d2];
+
+        d3 = base64Data[dataIndex++];
+        d4 = base64Data[dataIndex++];
+        if (!isData((d3)) || !isData((d4))) {//Check if they are PAD characters
+            if (isPad(d3) && isPad(d4)) {
+                if ((b2 & 0xf) != 0)//last 4 bits should be zero
+                {
+                    return null;
+                }
+                byte[] tmp = new byte[i * 3 + 1];
+                System.arraycopy(decodedData, 0, tmp, 0, i * 3);
+                tmp[encodedIndex] = (byte) (b1 << 2 | b2 >> 4);
+                return tmp;
+            } else if (!isPad(d3) && isPad(d4)) {
+                b3 = base64Alphabet[d3];
+                if ((b3 & 0x3) != 0)//last 2 bits should be zero
+                {
+                    return null;
+                }
+                byte[] tmp = new byte[i * 3 + 2];
+                System.arraycopy(decodedData, 0, tmp, 0, i * 3);
+                tmp[encodedIndex++] = (byte) (b1 << 2 | b2 >> 4);
+                tmp[encodedIndex] = (byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf));
+                return tmp;
+            } else {
+                return null;
+            }
+        } else { //No PAD e.g 3cQl
+            b3 = base64Alphabet[d3];
+            b4 = base64Alphabet[d4];
+            decodedData[encodedIndex++] = (byte) (b1 << 2 | b2 >> 4);
+            decodedData[encodedIndex++] = (byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf));
+            decodedData[encodedIndex++] = (byte) (b3 << 6 | b4);
+
+        }
+
+        return decodedData;
+    }
+
+    /**
+     * remove WhiteSpace form MIME containing encoded Base64 data.
+     *
+     * @param data the byte array of base64 data (with WS)
+     * @return the new length
+     */
+    private static int removeWhiteSpace(char[] data) {
+        if (data == null) {
+            return 0;
+        }
+
+        // count characters that's not whitespace
+        int newSize = 0;
+        int len = data.length;
+        for (int i = 0; i < len; i++) {
+            if (!isWhiteSpace(data[i])) {
+                data[newSize++] = data[i];
+            }
+        }
+        return newSize;
+    }
+}

+ 114 - 0
ruoyi-common/src/main/java/com/ruoyi/common/utils/WxCodeSessionUtil.java

@@ -0,0 +1,114 @@
+package com.ruoyi.common.utils;
+
+
+import com.alibaba.fastjson.JSONObject;
+
+import com.ruoyi.common.core.domain.dto.AppletLoginForm;
+import com.ruoyi.common.core.domain.dto.AppletSessionDTO;
+import com.ruoyi.common.utils.http.HttpClientUtils;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+/**
+ *
+ */
+@Component
+@Slf4j
+public class WxCodeSessionUtil {
+
+
+    /**
+     * 根据code获取小程序openid和unionid
+     */
+    private static final String JSCODE_SESSION_API = "https://api.weixin.qq.com/sns/jscode2session?appid=APPID&secret=SECRET&js_code=JSCODE&grant_type=authorization_code";
+
+    /**
+     * 小程序appId
+     */
+    @Value("${wx.appId}")
+    private String appId;
+
+    /**
+     * 小程序密钥
+     */
+    @Value("${wx.appSecret}")
+    private String appSecret;
+
+
+    /**
+     * 根据code获取小程序openid和unionid
+     *
+     * @param form
+     * @return
+     */
+    public AppletSessionDTO jscode2Session(AppletLoginForm form) {
+        // 获取openId和sessionKey
+        JSONObject result;
+        try {
+            String requestUrl = JSCODE_SESSION_API.replace("APPID", this.appId)
+                    .replace("SECRET", this.appSecret)
+                    .replace("JSCODE", form.getCode().trim());
+
+            String jsonStr = HttpClientUtils.doGet1(requestUrl);
+            result = JSONObject.parseObject(jsonStr);
+            if (StringUtils.isEmpty(result.toString())) {
+                throw new RuntimeException("错误");
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw new RuntimeException("错误");
+        }
+
+        int errcode = result.getIntValue("errcode");
+        if (errcode != 0) {
+            String errmsg = result.getString("errmsg");
+            throw new RuntimeException("获取小程序授权错误信息, " + errmsg);
+        }
+        // 获取openId,unionId,sessionKey
+        AppletSessionDTO appletSession = new AppletSessionDTO();
+        appletSession.setOpenId(result.getString("openid"));
+        // unionId有可能是空
+        appletSession.setUnionId(result.getString("unionid"));
+        appletSession.setSessionKey(result.getString("session_key"));
+
+        System.out.println();
+        String phoneNumber = getPhoneNumber(form, appletSession);
+        appletSession.setPhoneNumber(phoneNumber);
+        return appletSession;
+    }
+
+    /**
+     * 手机号解密
+     */
+    private String getPhoneNumber(AppletLoginForm form, AppletSessionDTO appletSession) {
+
+        // 解密文件
+        String encryptedData = form.getEncryptedData();
+        // 解密向量
+        String iv = form.getIv();
+        // 加密秘钥
+        byte[] dataByte = Base64.decode(encryptedData);
+        // session_key
+        byte[] keyByte = Base64.decode(appletSession.getSessionKey());
+        // 偏移量
+        byte[] ivByte = Base64.decode(iv);
+        JSONObject result;
+        try {
+            result = AppletDecryptDataUtil.decryptData(keyByte, ivByte, dataByte);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return null;
+        }
+
+        assert result != null;
+        String purePhoneNumber = result.getString("purePhoneNumber");
+        if (null == purePhoneNumber || purePhoneNumber.isEmpty()) {
+            throw new RuntimeException("获取手机号失败");
+        }
+        return purePhoneNumber;
+    }
+
+
+}

+ 112 - 0
ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpClientUtils.java

@@ -0,0 +1,112 @@
+package com.ruoyi.common.utils.http;
+
+import org.apache.http.NameValuePair;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.util.EntityUtils;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public class HttpClientUtils {
+
+    final static int TIMEOUT = 1000;
+    final static int TIMEOUT_MSEC = 5 * 1000;
+
+    public static String doPost(String url, Map<String, String> paramMap) throws IOException {
+        // 创建Httpclient对象
+        CloseableHttpClient httpClient = HttpClients.createDefault();
+        CloseableHttpResponse response = null;
+        String resultString = "";
+        try {
+            // 创建Http Post请求
+            HttpPost httpPost = new HttpPost(url);
+            // 创建参数列表
+            if (paramMap != null) {
+                List<NameValuePair> paramList = new ArrayList<>();
+                for (Map.Entry<String, String> param : paramMap.entrySet()) {
+                    paramList.add(new BasicNameValuePair(param.getKey(), param.getValue()));
+                }
+                // 模拟表单
+                UrlEncodedFormEntity entity = new UrlEncodedFormEntity(paramList);
+                httpPost.setEntity(entity);
+            }
+
+            httpPost.setConfig(builderRequestConfig());
+
+            // 执行http请求
+            response = httpClient.execute(httpPost);
+
+            resultString = EntityUtils.toString(response.getEntity(), "UTF-8");
+        } catch (Exception e) {
+            throw e;
+        } finally {
+            try {
+                response.close();
+            } catch (IOException e) {
+                throw e;
+            }
+        }
+
+        return resultString;
+    }
+
+    public static String doGet(String url, Map<String, String> paramMap) throws IOException {
+        url += "?appid=" + paramMap.get("appid") + "&secret=" + paramMap.get("secret") + "&js_code=" + paramMap.get("js_code") + "&grant_type=" + paramMap.get("grant_type");
+        // 创建Httpclient对象
+        CloseableHttpClient httpClient = HttpClients.createDefault();
+        CloseableHttpResponse response = null;
+        String resultString = "";
+        try {
+            // 创建Http Post请求
+            HttpGet httpGet = new HttpGet(url);
+            // 执行http请求
+            response = httpClient.execute(httpGet);
+            resultString = EntityUtils.toString(response.getEntity(), "UTF-8");
+        } catch (Exception e) {
+            throw e;
+        } finally {
+            try {
+                response.close();
+            } catch (IOException e) {
+                throw e;
+            }
+        }
+        return resultString;
+    }
+
+    public static String doGet1(String url) throws IOException {
+        // 创建Httpclient对象
+        CloseableHttpClient httpClient = HttpClients.createDefault();
+        CloseableHttpResponse response = null;
+        String resultString = "";
+        try {
+            // 创建Http Post请求
+            HttpGet httpGet = new HttpGet(url);
+            // 执行http请求
+            response = httpClient.execute(httpGet);
+            resultString = EntityUtils.toString(response.getEntity(), "UTF-8");
+        } catch (Exception e) {
+            throw e;
+        } finally {
+            assert response != null;
+            response.close();
+        }
+        return resultString;
+    }
+
+    private static RequestConfig builderRequestConfig() {
+        return RequestConfig.custom()
+                .setConnectTimeout(TIMEOUT_MSEC)
+                .setConnectionRequestTimeout(TIMEOUT_MSEC)
+                .setSocketTimeout(TIMEOUT_MSEC).build();
+    }
+}

+ 2 - 2
ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java

@@ -97,7 +97,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
                 // 过滤请求
                 .authorizeRequests()
                 // 对于登录login 注册register 验证码captchaImage 允许匿名访问
-                .antMatchers("/login", "/register", "/captchaImage").anonymous()
+                .antMatchers("/login","/loginApp", "/applet/login","/register", "/captchaImage").anonymous()
                 .antMatchers(
                         HttpMethod.GET,
                         "/",
@@ -113,8 +113,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
                 .antMatchers("/*/api-docs").anonymous()
                 .antMatchers("/druid/**").anonymous()
                 .antMatchers("/system/h5/**").anonymous()
-                .antMatchers("/system/policy/**").anonymous()
                 .antMatchers("/scanCode/**").anonymous()
+                .antMatchers("/system/policy/listPolicyMenuApp").anonymous()
                 // 除上面外的所有请求全部需要鉴权认证
                 .anyRequest().authenticated()
                 .and()

+ 39 - 0
ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java

@@ -93,6 +93,45 @@ public class SysLoginService
         return tokenService.createToken(loginUser);
     }
 
+
+    /**
+     * 登录验证小程序
+     *
+     * @param username 用户名
+     * @param password 密码
+     * @param uuid 唯一标识
+     * @return 结果
+     */
+    public String loginApp(String username, String password, String uuid)
+    {
+        // 用户验证
+        Authentication authentication = null;
+        try
+        {
+            // 该方法会去调用UserDetailsServiceImpl.loadUserByUsername
+            authentication = authenticationManager
+                    .authenticate(new UsernamePasswordAuthenticationToken(username, password));
+        }
+        catch (Exception e)
+        {
+            if (e instanceof BadCredentialsException)
+            {
+                AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.not.match")));
+                throw new UserPasswordNotMatchException();
+            }
+            else
+            {
+                AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, e.getMessage()));
+                throw new ServiceException(e.getMessage());
+            }
+        }
+        AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")));
+        LoginUser loginUser = (LoginUser) authentication.getPrincipal();
+        recordLoginInfo(loginUser.getUserId());
+        // 生成token
+        return tokenService.createToken(loginUser);
+    }
+
     /**
      * 校验验证码
      * 

+ 1 - 1
ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/TokenService.java

@@ -209,7 +209,7 @@ public class TokenService
      * @param claims 数据声明
      * @return 令牌
      */
-    private String createToken(Map<String, Object> claims)
+    public String createToken(Map<String, Object> claims)
     {
         String token = Jwts.builder()
                 .setClaims(claims)

+ 27 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/UsageRecord.java

@@ -43,6 +43,10 @@ public class UsageRecord extends BaseEntity
     @Excel(name = "记录名称")
     private String recordName;
 
+    /** 核销人员等级 */
+    @Excel(name = "核销人员等级")
+    private String recordLevel;
+
     /** 显示顺序 */
     @Excel(name = "显示顺序")
     private Integer orderNum;
@@ -55,6 +59,11 @@ public class UsageRecord extends BaseEntity
     @Excel(name = "使用人id")
     private Long creditId;
 
+    /** 使用人姓名 */
+    @Excel(name = "使用人姓名")
+    private String creditName;
+
+
     /** 剩余次数 */
     @Excel(name = "剩余次数")
     private String surplusNum;
@@ -184,6 +193,22 @@ public class UsageRecord extends BaseEntity
         this.creditPhone = creditPhone;
     }
 
+    public String getRecordLevel() {
+        return recordLevel;
+    }
+
+    public void setRecordLevel(String recordLevel) {
+        this.recordLevel = recordLevel;
+    }
+
+    public String getCreditName() {
+        return creditName;
+    }
+
+    public void setCreditName(String creditName) {
+        this.creditName = creditName;
+    }
+
     @Override
     public String toString() {
         return "UsageRecord{" +
@@ -194,9 +219,11 @@ public class UsageRecord extends BaseEntity
                 ", recordYear='" + recordYear + '\'' +
                 ", recordType='" + recordType + '\'' +
                 ", recordName='" + recordName + '\'' +
+                ", recordLevel='" + recordLevel + '\'' +
                 ", orderNum=" + orderNum +
                 ", useNum='" + useNum + '\'' +
                 ", creditId=" + creditId +
+                ", creditName='" + creditName + '\'' +
                 ", surplusNum='" + surplusNum + '\'' +
                 ", creditPhone='" + creditPhone + '\'' +
                 ", children=" + children +

+ 111 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/UseGuide.java

@@ -0,0 +1,111 @@
+package com.ruoyi.system.domain;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import com.ruoyi.common.annotation.Excel;
+import com.ruoyi.common.core.domain.BaseEntity;
+
+/**
+ * 使用指南对象 use_guide
+ * 
+ * @author ruoyi
+ * @date 2022-07-14
+ */
+public class UseGuide extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** $column.columnComment */
+    private Long id;
+
+    /** 标题 */
+    @Excel(name = "标题")
+    private String useTitle;
+
+    /** 使用指南简介 */
+    @Excel(name = "使用指南简介")
+    private String useProfile;
+
+    /** 使用指南内容 */
+    private String useContent;
+
+    /** 使用指南版本 */
+    @Excel(name = "使用指南版本")
+    private String useVersion;
+
+    /** 状态(0正常 1关闭) */
+    @Excel(name = "状态", readConverterExp = "0=正常,1=关闭")
+    private String status;
+
+    public void setId(Long id) 
+    {
+        this.id = id;
+    }
+
+    public Long getId() 
+    {
+        return id;
+    }
+    public void setUseTitle(String useTitle) 
+    {
+        this.useTitle = useTitle;
+    }
+
+    public String getUseTitle() 
+    {
+        return useTitle;
+    }
+    public void setUseProfile(String useProfile) 
+    {
+        this.useProfile = useProfile;
+    }
+
+    public String getUseProfile() 
+    {
+        return useProfile;
+    }
+    public void setUseContent(String useContent) 
+    {
+        this.useContent = useContent;
+    }
+
+    public String getUseContent() 
+    {
+        return useContent;
+    }
+    public void setUseVersion(String useVersion) 
+    {
+        this.useVersion = useVersion;
+    }
+
+    public String getUseVersion() 
+    {
+        return useVersion;
+    }
+    public void setStatus(String status) 
+    {
+        this.status = status;
+    }
+
+    public String getStatus() 
+    {
+        return status;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+            .append("id", getId())
+            .append("useTitle", getUseTitle())
+            .append("useProfile", getUseProfile())
+            .append("useContent", getUseContent())
+            .append("useVersion", getUseVersion())
+            .append("status", getStatus())
+            .append("createBy", getCreateBy())
+            .append("createTime", getCreateTime())
+            .append("updateBy", getUpdateBy())
+            .append("updateTime", getUpdateTime())
+            .append("remark", getRemark())
+            .toString();
+    }
+}

+ 97 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/WelfareGuide.java

@@ -0,0 +1,97 @@
+package com.ruoyi.system.domain;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import com.ruoyi.common.annotation.Excel;
+import com.ruoyi.common.core.domain.BaseEntity;
+
+/**
+ * 小程序党建福利信息对象 welfare_guide
+ * 
+ * @author ruoyi
+ * @date 2022-07-14
+ */
+public class WelfareGuide extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** $column.columnComment */
+    private Long id;
+
+    /** 标题 */
+    @Excel(name = "标题")
+    private String welfareTitle;
+
+    /** 福利简介 */
+    @Excel(name = "福利简介")
+    private String welfareProfile;
+
+    /** 福利内容 */
+    private String welfareContent;
+
+    /** 状态(0正常 1关闭) */
+    @Excel(name = "状态", readConverterExp = "0=正常,1=关闭")
+    private String status;
+
+    public void setId(Long id) 
+    {
+        this.id = id;
+    }
+
+    public Long getId() 
+    {
+        return id;
+    }
+    public void setWelfareTitle(String welfareTitle) 
+    {
+        this.welfareTitle = welfareTitle;
+    }
+
+    public String getWelfareTitle() 
+    {
+        return welfareTitle;
+    }
+    public void setWelfareProfile(String welfareProfile) 
+    {
+        this.welfareProfile = welfareProfile;
+    }
+
+    public String getWelfareProfile() 
+    {
+        return welfareProfile;
+    }
+    public void setWelfareContent(String welfareContent) 
+    {
+        this.welfareContent = welfareContent;
+    }
+
+    public String getWelfareContent() 
+    {
+        return welfareContent;
+    }
+    public void setStatus(String status) 
+    {
+        this.status = status;
+    }
+
+    public String getStatus() 
+    {
+        return status;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+            .append("id", getId())
+            .append("welfareTitle", getWelfareTitle())
+            .append("welfareProfile", getWelfareProfile())
+            .append("welfareContent", getWelfareContent())
+            .append("status", getStatus())
+            .append("createBy", getCreateBy())
+            .append("createTime", getCreateTime())
+            .append("updateBy", getUpdateBy())
+            .append("updateTime", getUpdateTime())
+            .append("remark", getRemark())
+            .toString();
+    }
+}

+ 3 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/InterestsTableMapper.java

@@ -2,6 +2,7 @@ package com.ruoyi.system.mapper;
 
 import java.util.List;
 import com.ruoyi.system.domain.InterestsTable;
+import org.apache.ibatis.annotations.Param;
 
 /**
  * 商户权益记录Mapper接口
@@ -58,4 +59,6 @@ public interface InterestsTableMapper
      * @return 结果
      */
     public int deleteInterestsTableByIds(Long[] ids);
+
+    InterestsTable selectInterestsTable(@Param("businessId") Long businessId, @Param("policyId")Long policyId);
 }

+ 2 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SettledMerchantsMapper.java

@@ -65,4 +65,6 @@ public interface SettledMerchantsMapper
      * @return 结果
      */
     public int deleteSettledMerchantsByBusinessIds(Long[] businessIds);
+
+    SettledMerchants selectByPhone(String businessPhone);
 }

+ 63 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/UseGuideMapper.java

@@ -0,0 +1,63 @@
+package com.ruoyi.system.mapper;
+
+import java.util.List;
+import com.ruoyi.system.domain.UseGuide;
+
+/**
+ * 使用指南Mapper接口
+ * 
+ * @author ruoyi
+ * @date 2022-07-14
+ */
+public interface UseGuideMapper 
+{
+    /**
+     * 查询使用指南
+     * 
+     * @param id 使用指南主键
+     * @return 使用指南
+     */
+    public UseGuide selectUseGuideById(Long id);
+
+    /**
+     * 查询使用指南列表
+     * 
+     * @param useGuide 使用指南
+     * @return 使用指南集合
+     */
+    public List<UseGuide> selectUseGuideList(UseGuide useGuide);
+
+    /**
+     * 新增使用指南
+     * 
+     * @param useGuide 使用指南
+     * @return 结果
+     */
+    public int insertUseGuide(UseGuide useGuide);
+
+    /**
+     * 修改使用指南
+     * 
+     * @param useGuide 使用指南
+     * @return 结果
+     */
+    public int updateUseGuide(UseGuide useGuide);
+
+    /**
+     * 删除使用指南
+     * 
+     * @param id 使用指南主键
+     * @return 结果
+     */
+    public int deleteUseGuideById(Long id);
+
+    /**
+     * 批量删除使用指南
+     * 
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteUseGuideByIds(Long[] ids);
+
+    UseGuide getInfoNew();
+}

+ 63 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/WelfareGuideMapper.java

@@ -0,0 +1,63 @@
+package com.ruoyi.system.mapper;
+
+import java.util.List;
+import com.ruoyi.system.domain.WelfareGuide;
+
+/**
+ * 小程序党建福利信息Mapper接口
+ * 
+ * @author ruoyi
+ * @date 2022-07-14
+ */
+public interface WelfareGuideMapper 
+{
+    /**
+     * 查询小程序党建福利信息
+     * 
+     * @param id 小程序党建福利信息主键
+     * @return 小程序党建福利信息
+     */
+    public WelfareGuide selectWelfareGuideById(Long id);
+
+    /**
+     * 查询小程序党建福利信息列表
+     * 
+     * @param welfareGuide 小程序党建福利信息
+     * @return 小程序党建福利信息集合
+     */
+    public List<WelfareGuide> selectWelfareGuideList(WelfareGuide welfareGuide);
+
+    /**
+     * 新增小程序党建福利信息
+     * 
+     * @param welfareGuide 小程序党建福利信息
+     * @return 结果
+     */
+    public int insertWelfareGuide(WelfareGuide welfareGuide);
+
+    /**
+     * 修改小程序党建福利信息
+     * 
+     * @param welfareGuide 小程序党建福利信息
+     * @return 结果
+     */
+    public int updateWelfareGuide(WelfareGuide welfareGuide);
+
+    /**
+     * 删除小程序党建福利信息
+     * 
+     * @param id 小程序党建福利信息主键
+     * @return 结果
+     */
+    public int deleteWelfareGuideById(Long id);
+
+    /**
+     * 批量删除小程序党建福利信息
+     * 
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteWelfareGuideByIds(Long[] ids);
+
+    WelfareGuide getInfoNew();
+}

+ 2 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/ISettledMerchantsService.java

@@ -67,4 +67,6 @@ public interface ISettledMerchantsService
      * @return 结果
      */
     public int deleteSettledMerchantsByBusinessId(Long businessId);
+
+    public SettledMerchants selectByPhone(String businessPhone);
 }

+ 65 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/IUseGuideService.java

@@ -0,0 +1,65 @@
+package com.ruoyi.system.service;
+
+import java.util.List;
+
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.system.domain.UseGuide;
+
+/**
+ * 使用指南Service接口
+ * 
+ * @author ruoyi
+ * @date 2022-07-14
+ */
+public interface IUseGuideService 
+{
+    /**
+     * 查询使用指南
+     * 
+     * @param id 使用指南主键
+     * @return 使用指南
+     */
+    public UseGuide selectUseGuideById(Long id);
+
+    /**
+     * 查询使用指南列表
+     * 
+     * @param useGuide 使用指南
+     * @return 使用指南集合
+     */
+    public List<UseGuide> selectUseGuideList(UseGuide useGuide);
+
+    /**
+     * 新增使用指南
+     * 
+     * @param useGuide 使用指南
+     * @return 结果
+     */
+    public int insertUseGuide(UseGuide useGuide);
+
+    /**
+     * 修改使用指南
+     * 
+     * @param useGuide 使用指南
+     * @return 结果
+     */
+    public int updateUseGuide(UseGuide useGuide);
+
+    /**
+     * 批量删除使用指南
+     * 
+     * @param ids 需要删除的使用指南主键集合
+     * @return 结果
+     */
+    public int deleteUseGuideByIds(Long[] ids);
+
+    /**
+     * 删除使用指南信息
+     * 
+     * @param id 使用指南主键
+     * @return 结果
+     */
+    public int deleteUseGuideById(Long id);
+
+    AjaxResult getInfoNew();
+}

+ 65 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/IWelfareGuideService.java

@@ -0,0 +1,65 @@
+package com.ruoyi.system.service;
+
+import java.util.List;
+
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.system.domain.WelfareGuide;
+
+/**
+ * 小程序党建福利信息Service接口
+ * 
+ * @author ruoyi
+ * @date 2022-07-14
+ */
+public interface IWelfareGuideService 
+{
+    /**
+     * 查询小程序党建福利信息
+     * 
+     * @param id 小程序党建福利信息主键
+     * @return 小程序党建福利信息
+     */
+    public WelfareGuide selectWelfareGuideById(Long id);
+
+    /**
+     * 查询小程序党建福利信息列表
+     * 
+     * @param welfareGuide 小程序党建福利信息
+     * @return 小程序党建福利信息集合
+     */
+    public List<WelfareGuide> selectWelfareGuideList(WelfareGuide welfareGuide);
+
+    /**
+     * 新增小程序党建福利信息
+     * 
+     * @param welfareGuide 小程序党建福利信息
+     * @return 结果
+     */
+    public int insertWelfareGuide(WelfareGuide welfareGuide);
+
+    /**
+     * 修改小程序党建福利信息
+     * 
+     * @param welfareGuide 小程序党建福利信息
+     * @return 结果
+     */
+    public int updateWelfareGuide(WelfareGuide welfareGuide);
+
+    /**
+     * 批量删除小程序党建福利信息
+     * 
+     * @param ids 需要删除的小程序党建福利信息主键集合
+     * @return 结果
+     */
+    public int deleteWelfareGuideByIds(Long[] ids);
+
+    /**
+     * 删除小程序党建福利信息信息
+     * 
+     * @param id 小程序党建福利信息主键
+     * @return 结果
+     */
+    public int deleteWelfareGuideById(Long id);
+
+    AjaxResult getInfoNew();
+}

+ 1 - 1
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/PolicyMenuServiceImpl.java

@@ -265,7 +265,7 @@ public class PolicyMenuServiceImpl implements IPolicyMenuService {
                     map.put("total",interestsNumberTable.getNumber());
                     //查询该用户已在该商家使用次数(按年来查询)
                     String year =DateUtils.getCurrentYear();
-                    int count = usageRecordMapper.selectUsageRecordByRecordNum(creditUser.getPhoneNum(),policyMenuZ.getMenuId(),year);
+                    int count = usageRecordMapper.selectUsageRecordByRecordNum(creditUser.getPhoneNum(),interestsNumberTable.getInterestsId(),year);
                     map.put("remaining",interestsNumberTable.getNumber()-count);
                 }else{
                     map.put("total","无限次");

+ 22 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SettledMerchantsServiceImpl.java

@@ -6,15 +6,18 @@ import java.util.List;
 import com.github.pagehelper.PageHelper;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.domain.entity.PolicyMenu;
+import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.core.page.PageDomain;
 import com.ruoyi.common.core.page.TableSupport;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.ObjectUtils;
+import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.sql.SqlUtil;
 import com.ruoyi.system.domain.SettledMerchantsInterests;
 import com.ruoyi.system.mapper.PolicyMenuMapper;
 import com.ruoyi.system.mapper.SettledMerchantsInterestsMapper;
+import com.ruoyi.system.service.ISysUserService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.ruoyi.system.mapper.SettledMerchantsMapper;
@@ -37,6 +40,8 @@ public class SettledMerchantsServiceImpl implements ISettledMerchantsService
     private SettledMerchantsInterestsMapper settledMerchantsInterestsMapper;
     @Autowired
     private PolicyMenuMapper policyMenuMapper;
+    @Autowired
+    private ISysUserService userService;
 
     /**
      * 查询入驻商家
@@ -136,6 +141,18 @@ public class SettledMerchantsServiceImpl implements ISettledMerchantsService
             settledMerchantsInterests.setMenuName(policyMenu.getMenuName());
             childCount +=  settledMerchantsInterestsMapper.insertSettledMerchantsInterests(settledMerchantsInterests);
         }
+
+        if(childCount > 0){
+            //将入驻商家生成账号
+            SysUser user = new SysUser();
+            user.setUserName(settledMerchants.getBusinessPhone());
+            user.setNickName(settledMerchants.getBusinessName());
+            user.setPhonenumber(settledMerchants.getBusinessPhone());
+            user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
+            userService.insertUser(user);
+
+        }
+
         return childCount > 0 ? AjaxResult.success() : AjaxResult.error();
     }
 
@@ -191,6 +208,11 @@ public class SettledMerchantsServiceImpl implements ISettledMerchantsService
         return settledMerchantsMapper.deleteSettledMerchantsByBusinessId(businessId);
     }
 
+    @Override
+    public SettledMerchants selectByPhone(String businessPhone) {
+        return settledMerchantsMapper.selectByPhone(businessPhone);
+    }
+
     private void startPage() {
         PageDomain pageDomain = TableSupport.buildPageRequest();
         Integer pageNum = pageDomain.getPageNum();

+ 9 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/UsageRecordServiceImpl.java

@@ -10,8 +10,10 @@ import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.system.domain.CreditUser;
 import com.ruoyi.system.domain.InterestsNumberTable;
+import com.ruoyi.system.domain.InterestsTable;
 import com.ruoyi.system.mapper.CreditUserMapper;
 import com.ruoyi.system.mapper.InterestsNumberTableMapper;
+import com.ruoyi.system.mapper.InterestsTableMapper;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.ruoyi.system.mapper.UsageRecordMapper;
@@ -35,6 +37,8 @@ public class UsageRecordServiceImpl implements IUsageRecordService
     private CreditUserMapper creditUserMapper;
     @Autowired
     private InterestsNumberTableMapper interestsNumberTableMapper;
+    @Autowired
+    private InterestsTableMapper interestsTableMapper;
 
     /**
      * 查询使用记录
@@ -73,6 +77,9 @@ public class UsageRecordServiceImpl implements IUsageRecordService
         CreditUser creditUser = new CreditUser();
         creditUser.setPhoneNum(usageRecord.getCreditPhone());
         creditUser = creditUserMapper.selectCreditUser(creditUser);
+        //根据商家ID和分类id查询权益id
+        InterestsTable tnterestsTable = interestsTableMapper.selectInterestsTable(usageRecord.getBusinessId(),usageRecord.getPolicyId());
+        usageRecord.setInterestsId(tnterestsTable.getId());
         //查询用户权益等级对应的商家权益次数
         InterestsNumberTable interestsNumberTable = new InterestsNumberTable();
         interestsNumberTable.setInterestsId(usageRecord.getInterestsId());
@@ -88,6 +95,8 @@ public class UsageRecordServiceImpl implements IUsageRecordService
         usageRecord.setSurplusNum(String.valueOf(index));
         usageRecord.setRecordYear(year);
         usageRecord.setCreditId(creditUser.getId());
+        usageRecord.setRecordLevel(creditUser.getCreditLevel());
+        usageRecord.setCreditName(creditUser.getUserName());
         usageRecord.setCreateTime(DateUtils.getNowDate());
 
         int c = usageRecordMapper.insertUsageRecord(usageRecord);

+ 108 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/UseGuideServiceImpl.java

@@ -0,0 +1,108 @@
+package com.ruoyi.system.service.impl;
+
+import java.util.List;
+
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.utils.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.ruoyi.system.mapper.UseGuideMapper;
+import com.ruoyi.system.domain.UseGuide;
+import com.ruoyi.system.service.IUseGuideService;
+
+/**
+ * 使用指南Service业务层处理
+ * 
+ * @author ruoyi
+ * @date 2022-07-14
+ */
+@Service
+public class UseGuideServiceImpl implements IUseGuideService 
+{
+    @Autowired
+    private UseGuideMapper useGuideMapper;
+
+    /**
+     * 查询使用指南
+     * 
+     * @param id 使用指南主键
+     * @return 使用指南
+     */
+    @Override
+    public UseGuide selectUseGuideById(Long id)
+    {
+        return useGuideMapper.selectUseGuideById(id);
+    }
+
+    /**
+     * 查询使用指南列表
+     * 
+     * @param useGuide 使用指南
+     * @return 使用指南
+     */
+    @Override
+    public List<UseGuide> selectUseGuideList(UseGuide useGuide)
+    {
+        return useGuideMapper.selectUseGuideList(useGuide);
+    }
+
+    /**
+     * 新增使用指南
+     * 
+     * @param useGuide 使用指南
+     * @return 结果
+     */
+    @Override
+    public int insertUseGuide(UseGuide useGuide)
+    {
+        useGuide.setCreateTime(DateUtils.getNowDate());
+        return useGuideMapper.insertUseGuide(useGuide);
+    }
+
+    /**
+     * 修改使用指南
+     * 
+     * @param useGuide 使用指南
+     * @return 结果
+     */
+    @Override
+    public int updateUseGuide(UseGuide useGuide)
+    {
+        useGuide.setUpdateTime(DateUtils.getNowDate());
+        return useGuideMapper.updateUseGuide(useGuide);
+    }
+
+    /**
+     * 批量删除使用指南
+     * 
+     * @param ids 需要删除的使用指南主键
+     * @return 结果
+     */
+    @Override
+    public int deleteUseGuideByIds(Long[] ids)
+    {
+        return useGuideMapper.deleteUseGuideByIds(ids);
+    }
+
+    /**
+     * 删除使用指南信息
+     * 
+     * @param id 使用指南主键
+     * @return 结果
+     */
+    @Override
+    public int deleteUseGuideById(Long id)
+    {
+        return useGuideMapper.deleteUseGuideById(id);
+    }
+
+    @Override
+    public AjaxResult getInfoNew() {
+
+        UseGuide useGuide = useGuideMapper.getInfoNew();
+        if(useGuide == null){
+            useGuide = new UseGuide();
+        }
+        return AjaxResult.success("访问成功",useGuide);
+    }
+}

+ 108 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/WelfareGuideServiceImpl.java

@@ -0,0 +1,108 @@
+package com.ruoyi.system.service.impl;
+
+import java.util.List;
+
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.system.domain.UseGuide;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.ruoyi.system.mapper.WelfareGuideMapper;
+import com.ruoyi.system.domain.WelfareGuide;
+import com.ruoyi.system.service.IWelfareGuideService;
+
+/**
+ * 小程序党建福利信息Service业务层处理
+ * 
+ * @author ruoyi
+ * @date 2022-07-14
+ */
+@Service
+public class WelfareGuideServiceImpl implements IWelfareGuideService 
+{
+    @Autowired
+    private WelfareGuideMapper welfareGuideMapper;
+
+    /**
+     * 查询小程序党建福利信息
+     * 
+     * @param id 小程序党建福利信息主键
+     * @return 小程序党建福利信息
+     */
+    @Override
+    public WelfareGuide selectWelfareGuideById(Long id)
+    {
+        return welfareGuideMapper.selectWelfareGuideById(id);
+    }
+
+    /**
+     * 查询小程序党建福利信息列表
+     * 
+     * @param welfareGuide 小程序党建福利信息
+     * @return 小程序党建福利信息
+     */
+    @Override
+    public List<WelfareGuide> selectWelfareGuideList(WelfareGuide welfareGuide)
+    {
+        return welfareGuideMapper.selectWelfareGuideList(welfareGuide);
+    }
+
+    /**
+     * 新增小程序党建福利信息
+     * 
+     * @param welfareGuide 小程序党建福利信息
+     * @return 结果
+     */
+    @Override
+    public int insertWelfareGuide(WelfareGuide welfareGuide)
+    {
+        welfareGuide.setCreateTime(DateUtils.getNowDate());
+        return welfareGuideMapper.insertWelfareGuide(welfareGuide);
+    }
+
+    /**
+     * 修改小程序党建福利信息
+     * 
+     * @param welfareGuide 小程序党建福利信息
+     * @return 结果
+     */
+    @Override
+    public int updateWelfareGuide(WelfareGuide welfareGuide)
+    {
+        welfareGuide.setUpdateTime(DateUtils.getNowDate());
+        return welfareGuideMapper.updateWelfareGuide(welfareGuide);
+    }
+
+    /**
+     * 批量删除小程序党建福利信息
+     * 
+     * @param ids 需要删除的小程序党建福利信息主键
+     * @return 结果
+     */
+    @Override
+    public int deleteWelfareGuideByIds(Long[] ids)
+    {
+        return welfareGuideMapper.deleteWelfareGuideByIds(ids);
+    }
+
+    /**
+     * 删除小程序党建福利信息信息
+     * 
+     * @param id 小程序党建福利信息主键
+     * @return 结果
+     */
+    @Override
+    public int deleteWelfareGuideById(Long id)
+    {
+        return welfareGuideMapper.deleteWelfareGuideById(id);
+    }
+
+    @Override
+    public AjaxResult getInfoNew() {
+        WelfareGuide welfareGuide = welfareGuideMapper.getInfoNew();
+        if(welfareGuide == null){
+            welfareGuide = new WelfareGuide();
+        }
+        return AjaxResult.success("访问成功",welfareGuide);
+    }
+}

+ 6 - 1
ruoyi-system/src/main/resources/mapper/system/InterestsTableMapper.xml

@@ -54,7 +54,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         left join interests_number_table n on i.id = n.interests_id
         where i.id = #{id}
     </select>
-        
+    <select id="selectInterestsTable"  parameterType="InterestsTable" resultMap="InterestsTableResult">
+        <include refid="selectInterestsTableVo"></include>
+        where merchants_id = #{businessId} and interests_policy_id = #{policyId}
+        limit 1
+    </select>
+
     <insert id="insertInterestsTable" parameterType="InterestsTable" useGeneratedKeys="true" keyProperty="id">
         insert into interests_table
         <trim prefix="(" suffix=")" suffixOverrides=",">

+ 5 - 1
ruoyi-system/src/main/resources/mapper/system/SettledMerchantsMapper.xml

@@ -68,7 +68,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <include refid="selectSettledMerchantsVo"/>
         where policy_id = #{menuId} and status = '0' and visible = '0' order by order_num
     </select>
-        
+     <select id="selectByPhone" resultMap="SettledMerchantsResult">
+        <include refid="selectSettledMerchantsVo"/>
+        where business_phone = #{businessPhone} and status = '0' and visible = '0' order by order_num
+    </select>
+
     <insert id="insertSettledMerchants" parameterType="SettledMerchants" useGeneratedKeys="true" keyProperty="businessId">
         insert into settled_merchants
         <trim prefix="(" suffix=")" suffixOverrides=",">

+ 24 - 1
ruoyi-system/src/main/resources/mapper/system/UsageRecordMapper.xml

@@ -14,9 +14,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="recordYear"    column="record_year"    />
         <result property="recordType"    column="record_type"    />
         <result property="recordName"    column="record_name"    />
+
+        <result property="recordLevel"    column="record_level"    />
+
         <result property="orderNum"    column="order_num"    />
         <result property="useNum"    column="use_num"    />
         <result property="creditId"    column="credit_id"    />
+
+        <result property="creditName"    column="credit_name"    />
+
         <result property="creditPhone"    column="credit_phone"    />
         <result property="surplusNum"    column="surplus_num"    />
         <result property="createBy"    column="create_by"    />
@@ -27,13 +33,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
     <sql id="selectUsageRecordVo">
-        select record_id,business_id,policy_id,interests_id, record_year, record_type, record_name, order_num, use_num, credit_id,credit_phone, surplus_num, create_by, create_time, update_by, update_time, remark from usage_record
+        select record_id,business_id,policy_id,interests_id, record_year, record_type, record_name,record_level, order_num, use_num, credit_id,credit_name,credit_phone, surplus_num, create_by, create_time, update_by, update_time, remark from usage_record
     </sql>
 
     <select id="selectUsageRecordList" parameterType="UsageRecord" resultMap="UsageRecordResult">
         <include refid="selectUsageRecordVo"/>
         <where>
             <if test="creditId != null  and creditId != ''"> and credit_id = #{creditId}</if>
+            <if test="creditName != null  and creditName != ''"> and credit_name = #{creditName}</if>
+            <if test="recordYear != null  and recordYear != ''"> and record_year = #{recordYear }</if>
+            <if test="createTime != null "> and create_time like concat( #{createTime}, '%')</if>
         </where>
     </select>
     
@@ -62,9 +71,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="recordYear != null and recordYear != ''">record_year,</if>
             <if test="recordType != null and recordType != ''">record_type,</if>
             <if test="recordName != null">record_name,</if>
+
+            <if test="recordLevel != null">record_level,</if>
+
             <if test="orderNum != null">order_num,</if>
             <if test="useNum != null">use_num,</if>
             <if test="creditId != null">credit_id,</if>
+            <if test="creditName != null">credit_name,</if>
             <if test="creditPhone != null">credit_phone,</if>
             <if test="surplusNum != null">surplus_num,</if>
             <if test="createBy != null">create_by,</if>
@@ -82,9 +95,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="recordYear != null and recordYear != ''">#{recordYear},</if>
             <if test="recordType != null and recordType != ''">#{recordType},</if>
             <if test="recordName != null">#{recordName},</if>
+
+            <if test="recordLevel != null">#{recordLevel},</if>
+
             <if test="orderNum != null">#{orderNum},</if>
             <if test="useNum != null">#{useNum},</if>
             <if test="creditId != null">#{creditId},</if>
+            <if test="creditName != null">#{creditName},</if>
             <if test="creditPhone != null">#{creditPhone},</if>
             <if test="surplusNum != null">#{surplusNum},</if>
             <if test="createBy != null">#{createBy},</if>
@@ -106,9 +123,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="recordYear != null and recordYear != ''">record_year = #{recordYear},</if>
             <if test="recordType != null and recordType != ''">record_type = #{recordType},</if>
             <if test="recordName != null">record_name = #{recordName},</if>
+
+            <if test="recordLevel != null">record_level = #{recordLevel},</if>
+
             <if test="orderNum != null">order_num = #{orderNum},</if>
             <if test="useNum != null">use_num = #{useNum},</if>
             <if test="creditId != null">credit_id = #{creditId},</if>
+
+            <if test="creditName != null">credit_name = #{creditName},</if>
+
             <if test="creditPhone != null">credit_phone = #{creditPhone},</if>
             <if test="surplusNum != null">surplus_num = #{surplusNum},</if>
             <if test="createBy != null">create_by = #{createBy},</if>

+ 98 - 0
ruoyi-system/src/main/resources/mapper/system/UseGuideMapper.xml

@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ruoyi.system.mapper.UseGuideMapper">
+    
+    <resultMap type="UseGuide" id="UseGuideResult">
+        <result property="id"    column="id"    />
+        <result property="useTitle"    column="use_title"    />
+        <result property="useProfile"    column="use_profile"    />
+        <result property="useContent"    column="use_content"    />
+        <result property="useVersion"    column="use_version"    />
+        <result property="status"    column="status"    />
+        <result property="createBy"    column="create_by"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="updateBy"    column="update_by"    />
+        <result property="updateTime"    column="update_time"    />
+        <result property="remark"    column="remark"    />
+    </resultMap>
+
+    <sql id="selectUseGuideVo">
+        select id, use_title, use_profile, use_content, use_version, status, create_by, create_time, update_by, update_time, remark from use_guide
+    </sql>
+
+    <select id="selectUseGuideList" parameterType="UseGuide" resultMap="UseGuideResult">
+        <include refid="selectUseGuideVo"/>
+        <where>  
+            <if test="useVersion != null  and useVersion != ''"> and use_version = #{useVersion}</if>
+            <if test="status != null  and status != ''"> and status = #{status}</if>
+        </where>
+    </select>
+    
+    <select id="selectUseGuideById" parameterType="Long" resultMap="UseGuideResult">
+        <include refid="selectUseGuideVo"/>
+        where id = #{id}
+    </select>
+    <select id="getInfoNew" parameterType="Long" resultMap="UseGuideResult">
+        <include refid="selectUseGuideVo"/>
+        order by update_time desc
+        limit 1
+    </select>
+
+    <insert id="insertUseGuide" parameterType="UseGuide" useGeneratedKeys="true" keyProperty="id">
+        insert into use_guide
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="useTitle != null">use_title,</if>
+            <if test="useProfile != null">use_profile,</if>
+            <if test="useContent != null">use_content,</if>
+            <if test="useVersion != null">use_version,</if>
+            <if test="status != null">status,</if>
+            <if test="createBy != null">create_by,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="updateBy != null">update_by,</if>
+            <if test="updateTime != null">update_time,</if>
+            <if test="remark != null">remark,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="useTitle != null">#{useTitle},</if>
+            <if test="useProfile != null">#{useProfile},</if>
+            <if test="useContent != null">#{useContent},</if>
+            <if test="useVersion != null">#{useVersion},</if>
+            <if test="status != null">#{status},</if>
+            <if test="createBy != null">#{createBy},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="updateBy != null">#{updateBy},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+            <if test="remark != null">#{remark},</if>
+         </trim>
+    </insert>
+
+    <update id="updateUseGuide" parameterType="UseGuide">
+        update use_guide
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="useTitle != null">use_title = #{useTitle},</if>
+            <if test="useProfile != null">use_profile = #{useProfile},</if>
+            <if test="useContent != null">use_content = #{useContent},</if>
+            <if test="useVersion != null">use_version = #{useVersion},</if>
+            <if test="status != null">status = #{status},</if>
+            <if test="createBy != null">create_by = #{createBy},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="updateBy != null">update_by = #{updateBy},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+            <if test="remark != null">remark = #{remark},</if>
+        </trim>
+        where id = #{id}
+    </update>
+
+    <delete id="deleteUseGuideById" parameterType="Long">
+        delete from use_guide where id = #{id}
+    </delete>
+
+    <delete id="deleteUseGuideByIds" parameterType="String">
+        delete from use_guide where id in 
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+</mapper>

+ 94 - 0
ruoyi-system/src/main/resources/mapper/system/WelfareGuideMapper.xml

@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ruoyi.system.mapper.WelfareGuideMapper">
+    
+    <resultMap type="WelfareGuide" id="WelfareGuideResult">
+        <result property="id"    column="id"    />
+        <result property="welfareTitle"    column="welfare_title"    />
+        <result property="welfareProfile"    column="welfare_profile"    />
+        <result property="welfareContent"    column="welfare_content"    />
+        <result property="status"    column="status"    />
+        <result property="createBy"    column="create_by"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="updateBy"    column="update_by"    />
+        <result property="updateTime"    column="update_time"    />
+        <result property="remark"    column="remark"    />
+    </resultMap>
+
+    <sql id="selectWelfareGuideVo">
+        select id, welfare_title, welfare_profile, welfare_content, status, create_by, create_time, update_by, update_time, remark from welfare_guide
+    </sql>
+
+    <select id="selectWelfareGuideList" parameterType="WelfareGuide" resultMap="WelfareGuideResult">
+        <include refid="selectWelfareGuideVo"/>
+        <where>  
+            <if test="welfareTitle != null  and welfareTitle != ''"> and welfare_title = #{welfareTitle}</if>
+            <if test="status != null  and status != ''"> and status = #{status}</if>
+        </where>
+    </select>
+    
+    <select id="selectWelfareGuideById" parameterType="Long" resultMap="WelfareGuideResult">
+        <include refid="selectWelfareGuideVo"/>
+        where id = #{id}
+    </select>
+    <select id="getInfoNew" parameterType="Long" resultMap="WelfareGuideResult">
+        <include refid="selectWelfareGuideVo"/>
+        order by update_time desc
+        limit 1
+    </select>
+
+    <insert id="insertWelfareGuide" parameterType="WelfareGuide" useGeneratedKeys="true" keyProperty="id">
+        insert into welfare_guide
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="welfareTitle != null">welfare_title,</if>
+            <if test="welfareProfile != null">welfare_profile,</if>
+            <if test="welfareContent != null">welfare_content,</if>
+            <if test="status != null">status,</if>
+            <if test="createBy != null">create_by,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="updateBy != null">update_by,</if>
+            <if test="updateTime != null">update_time,</if>
+            <if test="remark != null">remark,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="welfareTitle != null">#{welfareTitle},</if>
+            <if test="welfareProfile != null">#{welfareProfile},</if>
+            <if test="welfareContent != null">#{welfareContent},</if>
+            <if test="status != null">#{status},</if>
+            <if test="createBy != null">#{createBy},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="updateBy != null">#{updateBy},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+            <if test="remark != null">#{remark},</if>
+         </trim>
+    </insert>
+
+    <update id="updateWelfareGuide" parameterType="WelfareGuide">
+        update welfare_guide
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="welfareTitle != null">welfare_title = #{welfareTitle},</if>
+            <if test="welfareProfile != null">welfare_profile = #{welfareProfile},</if>
+            <if test="welfareContent != null">welfare_content = #{welfareContent},</if>
+            <if test="status != null">status = #{status},</if>
+            <if test="createBy != null">create_by = #{createBy},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="updateBy != null">update_by = #{updateBy},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+            <if test="remark != null">remark = #{remark},</if>
+        </trim>
+        where id = #{id}
+    </update>
+
+    <delete id="deleteWelfareGuideById" parameterType="Long">
+        delete from welfare_guide where id = #{id}
+    </delete>
+
+    <delete id="deleteWelfareGuideByIds" parameterType="String">
+        delete from welfare_guide where id in 
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+</mapper>