gongdecai 4 vuotta sitten
vanhempi
commit
684f0c26a4
19 muutettua tiedostoa jossa 1225 lisäystä ja 4 poistoa
  1. 43 0
      winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/controller/CommonUserController.java
  2. 175 0
      winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/entity/CacheComponent.java
  3. 10 3
      winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/entity/CommonUser.java
  4. 15 0
      winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/exception/AppServiceException.java
  5. 192 0
      winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/exception/ExceptionDefinition.java
  6. 36 0
      winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/exception/ServiceException.java
  7. 13 0
      winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/exception/ServiceExceptionDefinition.java
  8. 3 0
      winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/mapper/CommonUserMapper.java
  9. 98 0
      winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/notify/AliyunSMSClient.java
  10. 45 0
      winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/notify/MockSMSClient.java
  11. 82 0
      winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/notify/QCloudSMSClient.java
  12. 19 0
      winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/notify/SMSClient.java
  13. 15 0
      winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/notify/SMSResult.java
  14. 25 0
      winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/ICommonUserService.java
  15. 311 0
      winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/impl/CommonUserServiceImpl.java
  16. 37 0
      winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/util/Const.java
  17. 48 0
      winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/util/GeneratorUtil.java
  18. 44 0
      winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/util/MD5Util.java
  19. 14 1
      winsea-haixin-plugin-yiliangyiyun/src/main/resources/mapper/CommonUserMapper.xml

+ 43 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/controller/CommonUserController.java

@@ -1,6 +1,14 @@
 package com.yh.saas.plugin.yiliangyiyun.controller;
 
 
+import com.yh.saas.plugin.yiliangyiyun.entity.CommonUser;
+import com.yh.saas.plugin.yiliangyiyun.entity.ContractGoodsInfo;
+import com.yh.saas.plugin.yiliangyiyun.exception.ServiceException;
+import com.yh.saas.plugin.yiliangyiyun.service.ICommonUserService;
+import com.yh.saas.plugin.yiliangyiyun.service.IContractGoodsInfoService;
+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.RequestMapping;
 
 import org.springframework.web.bind.annotation.RestController;
@@ -17,5 +25,40 @@ import org.springframework.web.bind.annotation.RestController;
 @RequestMapping("/commonUser")
 public class CommonUserController {
 
+    @Autowired
+    private ICommonUserService commonUserService;
+
+
+    /**
+     * 注册
+     * @param commonUser
+     * @return
+     */
+    @PostMapping("/register")
+    public  String register(CommonUser commonUser) throws ServiceException {
+        return commonUserService.register(commonUser);
+    }
+
+    /**
+     * 发送验证码
+     * @param phone
+     * @return
+     * @throws ServiceException
+     */
+    @GetMapping("/sendVerifyCode")
+    public  String sendVerifyCode(String phone) throws ServiceException {
+        return commonUserService.sendVerifyCode(phone);
+    }
+
+    /**
+     * 发送验证码
+     * @param commonUser
+     * @return
+     * @throws ServiceException
+     */
+    @GetMapping("/sendloginVerifyCode")
+    public CommonUser login(CommonUser commonUser) throws ServiceException {
+        return commonUserService.login(commonUser);
+    }
 }
 

+ 175 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/entity/CacheComponent.java

@@ -0,0 +1,175 @@
+package com.yh.saas.plugin.yiliangyiyun.entity;
+
+import com.alibaba.fastjson.JSONObject;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.StringRedisTemplate;
+import org.springframework.stereotype.Component;
+import org.springframework.util.StringUtils;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Created by rize on 2019/3/22.
+ */
+@Component
+public class CacheComponent {
+
+    @Autowired
+    private StringRedisTemplate stringRedisTemplate;
+
+    public void putObj(String key, Object obj, Integer expireSec) {
+        if (expireSec != null) {
+            stringRedisTemplate.opsForValue().set(key, JSONObject.toJSONString(obj), expireSec, TimeUnit.SECONDS);
+        } else {
+            stringRedisTemplate.opsForValue().set(key, JSONObject.toJSONString(obj));
+        }
+    }
+
+    public Long incRaw(String key) {
+        return stringRedisTemplate.opsForValue().increment(key);
+    }
+
+    public  <T> T getObj(String key, Class<T> clazz) {
+        String json = stringRedisTemplate.opsForValue().get(key);
+        if (StringUtils.isEmpty(json)) {
+            return null;
+        }
+        return JSONObject.parseObject(json, clazz);
+    }
+
+    public <T> List<T> getObjList(String key, Class<T> clazz) {
+        String json = stringRedisTemplate.opsForValue().get(key);
+        if (StringUtils.isEmpty(json)) {
+            return null;
+        }
+        return JSONObject.parseArray(json, clazz);
+    }
+
+    public void putHashAll(String key, Map<String, String> map, Integer expireSec) {
+        stringRedisTemplate.opsForHash().putAll(key, map);
+        stringRedisTemplate.expire(key, expireSec, TimeUnit.SECONDS);
+    }
+
+    public Map<String,String> getHashAll(String key) {
+        if (!stringRedisTemplate.hasKey(key)) {
+            return null;
+        }
+        return (Map)stringRedisTemplate.opsForHash().entries(key);
+    }
+
+    public <T> T getHashObj(String hashName, String key, Class<T> clazz) {
+        String o = (String) stringRedisTemplate.opsForHash().get(hashName, key);
+        if (StringUtils.isEmpty(o)) {
+            return null;
+        }
+        return JSONObject.parseObject(o, clazz);
+    }
+
+    public String getHashRaw(String hashName, String key) {
+        String o = (String) stringRedisTemplate.opsForHash().get(hashName, key);
+        if (StringUtils.isEmpty(o)) {
+            return null;
+        }
+        return o;
+    }
+
+    public <T> List<T> getHashArray(String hashName, String key, Class<T> clazz) {
+        String o = (String) stringRedisTemplate.opsForHash().get(hashName, key);
+        if (StringUtils.isEmpty(o)) {
+            return null;
+        }
+        return JSONObject.parseArray(o, clazz);
+    }
+
+    public Long incHashRaw(String hashName, String key, long delta) {
+        return stringRedisTemplate.opsForHash().increment(hashName, key, delta);
+    }
+
+    public void putHashRaw(String hashName, String key, String str, Integer expireSec) {
+        boolean hasKey = stringRedisTemplate.hasKey(key);
+        stringRedisTemplate.opsForHash().put(hashName, key, str);
+        if (!hasKey) {
+            stringRedisTemplate.expire(key, expireSec, TimeUnit.SECONDS);
+        }
+    }
+
+    public void putHashRaw(String hashName, String key, String str) {
+        stringRedisTemplate.opsForHash().put(hashName, key, str);
+    }
+
+    public void putHashObj(String hashName, String key, Object obj, Integer expireSec) {
+        boolean hasKey = stringRedisTemplate.hasKey(key);
+        stringRedisTemplate.opsForHash().put(hashName, key, JSONObject.toJSONString(obj));
+        if (!hasKey) {
+            stringRedisTemplate.expire(key, expireSec, TimeUnit.SECONDS);
+        }
+    }
+
+    public void delHashObj(String hashName, String key) {
+        stringRedisTemplate.opsForHash().delete(hashName, key);
+    }
+
+
+    public void putRaw(String key, String value) {
+        putRaw(key, value, null);
+    }
+
+    public void putRaw(String key, String value, Integer expireSec) {
+        if (expireSec != null) {
+            stringRedisTemplate.opsForValue().set(key, value, expireSec, TimeUnit.SECONDS);
+        } else {
+            stringRedisTemplate.opsForValue().set(key, value);
+        }
+    }
+
+    public String getRaw(String key) {
+        return stringRedisTemplate.opsForValue().get(key);
+    }
+
+    public void del(String key) {
+        stringRedisTemplate.delete(key);
+    }
+
+    public boolean hasKey(String key) {
+        return stringRedisTemplate.hasKey(key);
+    }
+
+    public void putSetRaw(String key, String member, Integer expireSec) {
+        stringRedisTemplate.opsForSet().add(key, member);
+        stringRedisTemplate.expire(key, expireSec, TimeUnit.SECONDS);
+    }
+
+    public void putSetRawAll(String key, String[] set, Integer expireSec) {
+        stringRedisTemplate.opsForSet().add(key, set);
+        stringRedisTemplate.expire(key, expireSec, TimeUnit.SECONDS);
+    }
+
+    public void removeSetRaw(String key, String member) {
+        stringRedisTemplate.opsForSet().remove(key, member);
+    }
+
+    public boolean isSetMember(String key, String member) {
+        return stringRedisTemplate.opsForSet().isMember(key, member);
+    }
+
+    /**
+     * 获取指定前缀的Key
+     * @param prefix
+     * @return
+     */
+    public Set<String> getPrefixKeySet(String prefix) {
+        return stringRedisTemplate.keys(prefix + "*");
+    }
+
+    public void delPrefixKey(String prefix) {
+        Set<String> prefixKeySet = getPrefixKeySet(prefix);
+        for (String key : prefixKeySet) {
+            stringRedisTemplate.delete(key);
+        }
+    }
+
+
+}

+ 10 - 3
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/entity/CommonUser.java

@@ -1,8 +1,10 @@
 package com.yh.saas.plugin.yiliangyiyun.entity;
 
 import com.baomidou.mybatisplus.activerecord.Model;
+
 import java.io.Serializable;
 
+import com.baomidou.mybatisplus.annotations.TableField;
 import com.baomidou.mybatisplus.annotations.TableId;
 import com.baomidou.mybatisplus.annotations.TableName;
 import com.baomidou.mybatisplus.annotations.Version;
@@ -15,7 +17,7 @@ import lombok.experimental.Accessors;
 
 /**
  * <p>
- * 
+ *
  * </p>
  *
  * @author Gongdc
@@ -28,7 +30,7 @@ import lombok.experimental.Accessors;
 public class CommonUser extends BaseModel<CommonUser> {
 
     private static final long serialVersionUID = 1L;
-    
+
     @TableId(type = IdType.UUID)
     private String id;
     /**
@@ -66,7 +68,7 @@ public class CommonUser extends BaseModel<CommonUser> {
     /**
      * 所属公司ID
      */
-    private Long companyId;
+    private String companyId;
     /**
      * 登录token
      */
@@ -79,6 +81,11 @@ public class CommonUser extends BaseModel<CommonUser> {
      * 推送id
      */
     private String cid;
+    /**
+     * 注册码
+     */
+    @TableField(exist = false)
+    private String verifyCode;
 
 
     @Override

+ 15 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/exception/AppServiceException.java

@@ -0,0 +1,15 @@
+package com.yh.saas.plugin.yiliangyiyun.exception;
+
+/**
+ * Created by rize on 2019/7/1.
+ */
+public class AppServiceException extends ServiceException {
+
+    public AppServiceException(ServiceExceptionDefinition definition) {
+        super(definition);
+    }
+
+    public AppServiceException(String message, int code) {
+        super(message,code);
+    }
+}

+ 192 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/exception/ExceptionDefinition.java

@@ -0,0 +1,192 @@
+package com.yh.saas.plugin.yiliangyiyun.exception;
+
+/**
+ * Created by rize on 2019/7/1.
+ */
+public class ExceptionDefinition {
+
+    public static  ServiceExceptionDefinition THIRD_PART_SERVICE_EXCEPTION =
+            new ServiceExceptionDefinition(0, "第三方服务异常");
+
+    public static  ServiceExceptionDefinition PLUGIN_EXCEPTION =
+            new ServiceExceptionDefinition(1, "插件异常: ${0}");
+
+    public static  ServiceExceptionDefinition THIRD_PART_IO_EXCEPTION =
+            new ServiceExceptionDefinition(2, "第三方网络异常");
+
+    public static  ServiceExceptionDefinition APP_UNKNOWN_EXCEPTION =
+            new ServiceExceptionDefinition(10000, "系统未知异常");
+
+    public static  ServiceExceptionDefinition PARAM_CHECK_FAILED =
+            new ServiceExceptionDefinition(10002, "参数校验失败");
+
+    public static  ServiceExceptionDefinition SYSTEM_BUSY =
+            new ServiceExceptionDefinition(10007, "系统繁忙~");
+
+    public static  ServiceExceptionDefinition USER_UNKNOWN_EXCEPTION =
+            new ServiceExceptionDefinition(11000, "用户系统未知异常");
+
+    public static  ServiceExceptionDefinition USER_SEND_VERIFY_FAILED =
+            new ServiceExceptionDefinition(11001, "发送验证码失败");
+
+    public static  ServiceExceptionDefinition USER_VERIFY_CODE_NOT_EXIST =
+            new ServiceExceptionDefinition(11002, "验证码未发送或已过期");
+
+    public static  ServiceExceptionDefinition USER_VERIFY_CODE_NOT_CORRECT =
+            new ServiceExceptionDefinition(11003, "验证码不正确");
+
+    public static  ServiceExceptionDefinition USER_PHONE_HAS_EXISTED =
+            new ServiceExceptionDefinition(11004, "手机已经被注册");
+
+    public static  ServiceExceptionDefinition USER_PHONE_NOT_EXIST =
+            new ServiceExceptionDefinition(11005, "手机尚未绑定账号");
+
+    public static  ServiceExceptionDefinition USER_PHONE_OR_PASSWORD_NOT_CORRECT =
+            new ServiceExceptionDefinition(11006, "手机号或密码错误!");
+
+    public static  ServiceExceptionDefinition USER_THIRD_PART_LOGIN_FAILED =
+            new ServiceExceptionDefinition(11007, "用户第三方登录失败");
+
+    public static  ServiceExceptionDefinition USER_THIRD_UNEXPECT_RESPONSE =
+            new ServiceExceptionDefinition(11008, "第三方登录期望之外的错误");
+
+    public static  ServiceExceptionDefinition USER_THIRD_PART_NOT_SUPPORT =
+            new ServiceExceptionDefinition(11009, "未知的第三方登录平台");
+
+    public static  ServiceExceptionDefinition USER_INFORMATION_MISSING =
+            new ServiceExceptionDefinition(11010, "用户信息缺失,不能添加");
+
+    public static  ServiceExceptionDefinition USER_PHONE_ALREADY_EXIST =
+            new ServiceExceptionDefinition(11011, "用户电话已经存在,不能添加");
+
+    public static  ServiceExceptionDefinition USER_CAN_NOT_ACTICE =
+            new ServiceExceptionDefinition(11012, "用户处于冻结状态,请联系管理员");
+
+    public static  ServiceExceptionDefinition ADDRESS_DATABASE_QUERY_FAILED  =
+            new ServiceExceptionDefinition(16002, "执行语句失败");
+    public static  ServiceExceptionDefinition PURCHASE_OVER_NUM  =
+            new ServiceExceptionDefinition(16002, "送粮人每年收购总量不得超过五百吨");
+
+    public static  ServiceExceptionDefinition ADVERTISEMENT_SQL_ADD_FAILED =
+            new ServiceExceptionDefinition(22001, "添加广告数据库失败");
+
+    public static  ServiceExceptionDefinition ADVERTISEMENT_SQL_DELETE_FAILED =
+            new ServiceExceptionDefinition(22002, "删除广告数据库失败");
+
+    public static  ServiceExceptionDefinition ADVERTISEMENT_SQL_UPDATE_FAILED =
+            new ServiceExceptionDefinition(22003, "修改广告数据库失败");
+
+
+    public static  ServiceExceptionDefinition ADMIN_UNKNOWN_EXCEPTION =
+            new ServiceExceptionDefinition(50000, "管理员系统未知异常");
+
+    public static  ServiceExceptionDefinition COLLECT_ERROR =
+            new ServiceExceptionDefinition(50000, "预收款不足,请仔细检查");
+    public static  ServiceExceptionDefinition ADMIN_NOT_EXIST =
+            new ServiceExceptionDefinition(50001, "管理员不存在");
+
+    public static  ServiceExceptionDefinition ADMIN_PASSWORD_ERROR =
+            new ServiceExceptionDefinition(50002, "密码错误");
+
+    public static  ServiceExceptionDefinition ADMIN_NOT_BIND_WECHAT =
+            new ServiceExceptionDefinition(50003, "管理员尚未绑定微信");
+
+    public static  ServiceExceptionDefinition ADMIN_APPLY_NOT_BELONGS_TO_YOU =
+            new ServiceExceptionDefinition(50004, "用户申请表并不属于您");
+
+    public static  ServiceExceptionDefinition ADMIN_APPLY_NOT_SUPPORT_ONE_KEY =
+            new ServiceExceptionDefinition(50005, "未定义类型不支持一键发布");
+
+    public static  ServiceExceptionDefinition ADMIN_ROLE_IS_EMPTY =
+            new ServiceExceptionDefinition(50006, "管理员角色为空!");
+
+    public static  ServiceExceptionDefinition ADMIN_USER_NAME_REPEAT =
+            new ServiceExceptionDefinition(50007, "管理员用户名重复");
+
+    public static  ServiceExceptionDefinition ADMIN_VERIFYCODE_ERROR =
+            new ServiceExceptionDefinition(50008, "登陆验证码错误");
+
+    public static  ServiceExceptionDefinition ADMIN_USER_NOT_EXITS =
+            new ServiceExceptionDefinition(50009, "管理员不存在,请输入正确账号密码");
+
+    public static  ServiceExceptionDefinition ADMIN_GUEST_NOT_NEED_VERIFY_CODE =
+            new ServiceExceptionDefinition(50010, "游客用户无须验证码,请直接输入666666");
+
+    public static  ServiceExceptionDefinition ADMIN_VERIFY_CODE_SEND_FAIL=
+            new ServiceExceptionDefinition(50011, "登陆验证码发送失败");
+
+    public static  ServiceExceptionDefinition ADMIN_GENERATOR_WORK_DIR_NOT_EXIST =
+            new ServiceExceptionDefinition(50012, "工作路径不正确");
+
+    public static  ServiceExceptionDefinition ADMIN_GENERATOR_FILE_ALREADY_EXIST =
+            new ServiceExceptionDefinition(50013, "欲生成的文件已经存在");
+
+    public static  ServiceExceptionDefinition ADMIN_GENERATOR_IO_EXCEPTION =
+            new ServiceExceptionDefinition(50013, "代码生成网络异常");
+
+    public static  ServiceExceptionDefinition ADMIN_GENERATOR_TEMPLATE_EXCEPTION =
+            new ServiceExceptionDefinition(50013, "代码生成模板异常");
+
+
+    public static  ServiceExceptionDefinition SALE_NEED_STATUS_ERROR =
+            new ServiceExceptionDefinition(53015, "销售信息是该状态,无法改变");
+    public static  ServiceExceptionDefinition SALE_UPDATE_SQL_FAILED =
+            new ServiceExceptionDefinition(53015, "销售信息执行修改SQL失败");
+    public static  ServiceExceptionDefinition SALE_NOT_EXIST =
+            new ServiceExceptionDefinition(53015, "销售信息并不存在");
+    public static  ServiceExceptionDefinition SALE_TITLE_NOT_EXIST =
+            new ServiceExceptionDefinition(53015, "未维护标题");
+    public static  ServiceExceptionDefinition SALE_DINGJIA_STATUS_ERROR =
+            new ServiceExceptionDefinition(53015, "只能申请状态为未申请的数据");
+    public static  ServiceExceptionDefinition ROLE_NOT_EXIST =
+            new ServiceExceptionDefinition(53015, "并未决策人角色,无法申请定价");
+    public static  ServiceExceptionDefinition PRICE_ERROR =
+            new ServiceExceptionDefinition(53015, "指导价不正确");
+    public static  ServiceExceptionDefinition WANSHAN_ERROR =
+            new ServiceExceptionDefinition(53015, "完善承运信息失败");
+    public static  ServiceExceptionDefinition JIEDAN_ERROR =
+            new ServiceExceptionDefinition(53015, "接单失败");
+    public static  ServiceExceptionDefinition JUJIE_ERROR =
+            new ServiceExceptionDefinition(53015, "拒接失败");
+    public static  ServiceExceptionDefinition TUIHUI_ERROR =
+            new ServiceExceptionDefinition(53015, "退回失败");
+    public static  ServiceExceptionDefinition CONTRACT_ERROR =
+            new ServiceExceptionDefinition(53015, "生成运输合同异常");
+    public static  ServiceExceptionDefinition SIGN_CONTRACT_ERROR =
+            new ServiceExceptionDefinition(53015, "签订运输合同异常");
+    public static  ServiceExceptionDefinition TRAN_COUNT_ERROR =
+            new ServiceExceptionDefinition(53015, "运量任务不足,请额外申请运量");
+    public static  ServiceExceptionDefinition WORK_STATUS_ERROR =
+            new ServiceExceptionDefinition(53015, "存在未交货的车辆,请完成交货后再完货");
+    public static  ServiceExceptionDefinition WORK_STATUS_ERROR1 =
+            new ServiceExceptionDefinition(53015, "存在未放货的车辆,请完成放货后再完货");
+    public static  ServiceExceptionDefinition WORK_STATUS_ERROR2 =
+            new ServiceExceptionDefinition(53015, "存在未完成接货的车辆,请接货后再完成");
+    public static  ServiceExceptionDefinition BANK_PERSON_CHECK =
+            new ServiceExceptionDefinition(53015, "收款人姓名、身份证号、银行卡号不匹配");
+    public static  ServiceExceptionDefinition TIME_EXCEED_RANGE =
+            new ServiceExceptionDefinition(53015, "此时间(8:00-11:30/12:30-15:00/20:00-23:00)不可点价");
+    public static  ServiceExceptionDefinition TIME_EXCEED_STATUS =
+            new ServiceExceptionDefinition(53015, "已受理的合同不可点价");
+    public static  ServiceExceptionDefinition  CONTRACT_NO_ERRO=
+            new ServiceExceptionDefinition(53015, "采购合同编号重复");
+    public static  ServiceExceptionDefinition  CONTRACT_NO_COPY=
+            new ServiceExceptionDefinition(53015, "合同编号已存在");
+    public static ServiceExceptionDefinition buildVariableException(ServiceExceptionDefinition definition, String ...args) {
+        String msg = definition.getMsg();
+        for (int i = 0; i < args.length; i++) {
+            msg = msg.replace("${" + i + "}", args[i]);
+        }
+        return new ServiceExceptionDefinition(definition.getCode(), msg);
+    }
+
+    public static  ServiceExceptionDefinition IMPORT_STORE_NAME_ERROR =
+            new ServiceExceptionDefinition(50000, "存在不正确的库点名称,请检查后重新导入");
+    public static  ServiceExceptionDefinition IN_STORE_ERROR =
+            new ServiceExceptionDefinition(50000, "入库任务异常");
+    public static  ServiceExceptionDefinition FLAT_COUNT_ERROR =
+            new ServiceExceptionDefinition(50000, "可平仓数量不足");
+
+
+
+}

+ 36 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/exception/ServiceException.java

@@ -0,0 +1,36 @@
+package com.yh.saas.plugin.yiliangyiyun.exception;
+
+import java.io.Serializable;
+
+/**
+ * Created with IntelliJ IDEA.
+ * Description:
+ * User: rize
+ * Date: 2019-01-31
+ * Time: 下午8:07
+ */
+public abstract class ServiceException extends Exception implements Serializable {
+
+    private int code;
+
+    public int getCode() {
+        return code;
+    }
+
+    public void setCode(int code) {
+        this.code = code;
+    }
+
+    public ServiceException() {
+    }
+
+    public ServiceException(String message, int code) {
+        super(message);
+        this.code = code;
+    }
+
+    public ServiceException(ServiceExceptionDefinition definition) {
+        super(definition.getMsg());
+        this.code = definition.getCode();
+    }
+}

+ 13 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/exception/ServiceExceptionDefinition.java

@@ -0,0 +1,13 @@
+package com.yh.saas.plugin.yiliangyiyun.exception;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class ServiceExceptionDefinition {
+    private int code;
+    private String msg;
+}

+ 3 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/mapper/CommonUserMapper.java

@@ -2,6 +2,7 @@ package com.yh.saas.plugin.yiliangyiyun.mapper;
 
 import com.yh.saas.plugin.yiliangyiyun.entity.CommonUser;
 import com.baomidou.mybatisplus.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
 
 /**
  * <p>
@@ -13,4 +14,6 @@ import com.baomidou.mybatisplus.mapper.BaseMapper;
  */
 public interface CommonUserMapper extends BaseMapper<CommonUser> {
 
+
+    CommonUser login(@Param("phone") String phone, @Param("cryptPassword") String cryptPassword);
 }

+ 98 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/notify/AliyunSMSClient.java

@@ -0,0 +1,98 @@
+package com.yh.saas.plugin.yiliangyiyun.notify;
+
+import com.alibaba.fastjson.JSONObject;
+import com.aliyuncs.CommonRequest;
+import com.aliyuncs.CommonResponse;
+import com.aliyuncs.DefaultAcsClient;
+import com.aliyuncs.IAcsClient;
+import com.aliyuncs.exceptions.ClientException;
+import com.aliyuncs.http.MethodType;
+import com.aliyuncs.profile.DefaultProfile;
+import com.iotechn.unimall.core.exception.ExceptionDefinition;
+import com.iotechn.unimall.core.exception.ServiceException;
+import com.iotechn.unimall.core.exception.ThirdPartServiceException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.beans.factory.annotation.Value;
+
+/**
+ * Created by rize on 2019/8/1.
+ */
+public class AliyunSMSClient implements SMSClient, InitializingBean {
+
+    @Value("${sms.aliyun.accessId}")
+    private String accessId;
+    @Value("${sms.aliyun.accessKey}")
+    private String accessKey;
+    @Value("${sms.aliyun.register-template-id}")
+    private String registerTemplateId;
+    @Value("${sms.aliyun.bind-phone-template-id}")
+    private String bindPhoneTemplateId;
+    @Value("${sms.aliyun.reset-password-template-id}")
+    private String resetPasswordTemplateId;
+    @Value("${sms.aliyun.admin-login-template-id}")
+    private String adminLoginTemplateId;
+    @Value("${sms.aliyun.signature}")
+    private String signature;
+
+    private IAcsClient client;
+
+    private static Logger logger = LoggerFactory.getLogger(AliyunSMSClient.class);
+
+    @Override
+    public void afterPropertiesSet() throws Exception {
+        this.client = new DefaultAcsClient(DefaultProfile.getProfile("default", accessId, accessKey));
+    }
+
+    @Override
+    public SMSResult sendRegisterVerify(String phone, String verifyCode) throws ServiceException {
+        return sendCommon(phone, verifyCode, registerTemplateId, signature);
+    }
+
+    @Override
+    public SMSResult sendBindPhoneVerify(String phone, String verifyCode) throws ServiceException {
+        return sendCommon(phone, verifyCode, bindPhoneTemplateId, signature);
+    }
+
+    @Override
+    public SMSResult sendResetPasswordVerify(String phone, String verifyCode) throws ServiceException {
+        return sendCommon(phone, verifyCode, resetPasswordTemplateId, signature);
+    }
+
+    @Override
+    public SMSResult sendAdminLoginVerify(String phone, String verifyCode) throws ServiceException {
+        return sendCommon(phone, verifyCode, adminLoginTemplateId, signature);
+    }
+
+    private SMSResult sendCommon(String phone, String verifyCode, String templateId, String signature) throws ServiceException {
+        try {
+            CommonRequest request = new CommonRequest();
+            request.setMethod(MethodType.POST);
+            request.setDomain("dysmsapi.aliyuncs.com");
+            request.setVersion("2017-05-25");
+            request.setAction("SendSms");
+            request.putQueryParameter("RegionId", "default");
+            request.putQueryParameter("PhoneNumbers", phone);
+            request.putQueryParameter("SignName", signature);
+            request.putQueryParameter("TemplateCode", templateId);
+            request.putQueryParameter("TemplateParam", "{\"code\":\"" + verifyCode + "\"}");
+            CommonResponse commonResponse = client.getCommonResponse(request);
+            String data = commonResponse.getData();
+            JSONObject jsonObject = JSONObject.parseObject(data);
+            String message = jsonObject.getString("Message");
+            SMSResult smsResult = new SMSResult();
+            smsResult.setSucc("OK".equalsIgnoreCase(message));
+            smsResult.setMsg(message);
+            return smsResult;
+        } catch (ClientException e) {
+            throw new ThirdPartServiceException(e.getMessage(), ExceptionDefinition.THIRD_PART_SERVICE_EXCEPTION.getCode());
+        } catch (Exception e) {
+            logger.error("[阿里云短信发送] 异常", e);
+            throw new ThirdPartServiceException(ExceptionDefinition.APP_UNKNOWN_EXCEPTION.getMsg(), ExceptionDefinition.APP_UNKNOWN_EXCEPTION.getCode());
+        }
+    }
+
+
+
+}

+ 45 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/notify/MockSMSClient.java

@@ -0,0 +1,45 @@
+package com.yh.saas.plugin.yiliangyiyun.notify;
+
+import com.iotechn.unimall.core.exception.ServiceException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Created with IntelliJ IDEA.
+ * Description:
+ * User: rize
+ * Date: 2019/11/17
+ * Time: 15:50
+ */
+public class MockSMSClient implements SMSClient {
+
+    private static Logger logger = LoggerFactory.getLogger(MockSMSClient.class);
+
+    @Override
+    public SMSResult sendRegisterVerify(String phone, String verifyCode) throws ServiceException {
+        return send(phone, verifyCode);
+    }
+
+    @Override
+    public SMSResult sendBindPhoneVerify(String phone, String verifyCode) throws ServiceException {
+        return send(phone, verifyCode);
+    }
+
+    @Override
+    public SMSResult sendResetPasswordVerify(String phone, String verifyCode) throws ServiceException {
+        return send(phone, verifyCode);
+    }
+
+    @Override
+    public SMSResult sendAdminLoginVerify(String phone, String verifyCode) throws ServiceException {
+        return send(phone, verifyCode);
+    }
+
+    public SMSResult send(String phone, String verifyCode) {
+        logger.info("[模拟短信发送] phone=" + phone + "; verifyCode=" + verifyCode);
+        SMSResult smsResult = new SMSResult();
+        smsResult.setSucc(true);
+        smsResult.setMsg("OK");
+        return smsResult;
+    }
+}

+ 82 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/notify/QCloudSMSClient.java

@@ -0,0 +1,82 @@
+package com.yh.saas.plugin.yiliangyiyun.notify;
+
+import com.github.qcloudsms.SmsSingleSender;
+import com.github.qcloudsms.SmsSingleSenderResult;
+import com.iotechn.unimall.core.exception.ExceptionDefinition;
+import com.iotechn.unimall.core.exception.ServiceException;
+import com.iotechn.unimall.core.exception.ThirdPartServiceException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.beans.factory.annotation.Value;
+
+/**
+ * Created by rize on 2019/7/1.
+ */
+public class QCloudSMSClient implements SMSClient, InitializingBean {
+
+    private SmsSingleSender sender;
+
+    @Value("${sms.qcloud.app-id}")
+    private Integer appid;
+    @Value("${sms.qcloud.app-key}")
+    private String appkey;
+    @Value("${sms.qcloud.register-template-id}")
+    private Integer registerTemplateId;
+    @Value("${sms.qcloud.bind-phone-template-id}")
+    private Integer bindPhoneTemplateId;
+    @Value("${sms.qcloud.reset-password-template-id}")
+    private Integer resetPasswordTemplateId;
+    @Value("${sms.qcloud.admin-login-template-id}")
+    private Integer adminLoginTemplateId;
+    @Value("${sms.qcloud.sign}")
+    private String sign;
+
+    private static Logger logger = LoggerFactory.getLogger(QCloudSMSClient.class);
+
+    @Override
+    public void afterPropertiesSet() throws Exception {
+        sender = new SmsSingleSender(appid, appkey);
+    }
+
+    public SMSResult sendMsg(String phone, int templateId, String ...params) throws ServiceException {
+        try {
+            SmsSingleSenderResult smsSingleSenderResult = sender.sendWithParam("86", phone, templateId, params, this.sign, "", "");
+            if (smsSingleSenderResult.result == 0) {
+                SMSResult smsResult = new SMSResult();
+                smsResult.setSucc(true);
+                smsResult.setMsg("成功");
+                return smsResult;
+            } else {
+                logger.info("[腾讯短信发送] 回复与预期不一致 result=" + smsSingleSenderResult.result + ";errMsg=" + smsSingleSenderResult.errMsg);
+                throw new ThirdPartServiceException(smsSingleSenderResult.errMsg, smsSingleSenderResult.result);
+            }
+        } catch (ServiceException e) {
+            throw e;
+        } catch (Exception e) {
+            logger.error("[腾讯短信发送] 异常", e);
+            throw new ThirdPartServiceException("腾讯云短信发送未知异常", ExceptionDefinition.THIRD_PART_SERVICE_EXCEPTION.getCode());
+        }
+    }
+
+
+    @Override
+    public SMSResult sendRegisterVerify(String phone, String verifyCode) throws ServiceException {
+        return sendMsg(phone, registerTemplateId, verifyCode);
+    }
+
+    @Override
+    public SMSResult sendBindPhoneVerify(String phone, String verifyCode) throws ServiceException {
+        return sendMsg(phone, registerTemplateId, verifyCode);
+    }
+
+    @Override
+    public SMSResult sendResetPasswordVerify(String phone, String verifyCode) throws ServiceException {
+        return sendMsg(phone, registerTemplateId, verifyCode);
+    }
+
+    @Override
+    public SMSResult sendAdminLoginVerify(String phone, String verifyCode) throws ServiceException {
+        return sendMsg(phone, adminLoginTemplateId,verifyCode);
+    }
+}

+ 19 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/notify/SMSClient.java

@@ -0,0 +1,19 @@
+package com.yh.saas.plugin.yiliangyiyun.notify;
+
+import com.iotechn.unimall.core.exception.ServiceException;
+
+/**
+ * Created by rize on 2019/7/1.
+ */
+public interface SMSClient {
+
+    SMSResult sendRegisterVerify(String phone, String verifyCode) throws ServiceException;
+
+    SMSResult sendBindPhoneVerify(String phone, String verifyCode) throws ServiceException;
+
+    SMSResult sendResetPasswordVerify(String phone, String verifyCode) throws ServiceException;
+
+    SMSResult sendAdminLoginVerify(String phone, String verifyCode) throws ServiceException;
+
+
+}

+ 15 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/notify/SMSResult.java

@@ -0,0 +1,15 @@
+package com.yh.saas.plugin.yiliangyiyun.notify;
+
+import lombok.Data;
+
+/**
+ * Created by rize on 2019/7/1.
+ */
+@Data
+public class SMSResult {
+
+    private boolean succ;
+
+    private String msg;
+
+}

+ 25 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/ICommonUserService.java

@@ -2,6 +2,7 @@ package com.yh.saas.plugin.yiliangyiyun.service;
 
 import com.yh.saas.plugin.yiliangyiyun.entity.CommonUser;
 import com.baomidou.mybatisplus.service.IService;
+import com.yh.saas.plugin.yiliangyiyun.exception.ServiceException;
 
 /**
  * <p>
@@ -13,4 +14,28 @@ import com.baomidou.mybatisplus.service.IService;
  */
 public interface ICommonUserService extends IService<CommonUser> {
 
+    /**
+     * 注册
+     * @param commonUser
+     * @return
+     * @throws ServiceException
+     */
+    String register(CommonUser commonUser) throws ServiceException;
+
+    /**
+     * 发送验证码
+     * @param phone
+     * @return
+     * @throws ServiceException
+     */
+    String sendVerifyCode(String phone) throws ServiceException;
+
+
+    /**
+     * 登录
+     * @param commonUser
+     * @return
+     * @throws ServiceException
+     */
+    CommonUser login(CommonUser commonUser) throws ServiceException;
 }

+ 311 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/impl/CommonUserServiceImpl.java

@@ -1,10 +1,32 @@
 package com.yh.saas.plugin.yiliangyiyun.service.impl;
 
+import cn.hutool.core.lang.UUID;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.mapper.EntityWrapper;
+import com.yh.saas.plugin.yiliangyiyun.entity.CacheComponent;
 import com.yh.saas.plugin.yiliangyiyun.entity.CommonUser;
+import com.yh.saas.plugin.yiliangyiyun.exception.AppServiceException;
+import com.yh.saas.plugin.yiliangyiyun.exception.ExceptionDefinition;
+import com.yh.saas.plugin.yiliangyiyun.exception.ServiceException;
 import com.yh.saas.plugin.yiliangyiyun.mapper.CommonUserMapper;
+import com.yh.saas.plugin.yiliangyiyun.notify.SMSClient;
+import com.yh.saas.plugin.yiliangyiyun.notify.SMSResult;
 import com.yh.saas.plugin.yiliangyiyun.service.ICommonUserService;
 import com.baomidou.mybatisplus.service.impl.ServiceImpl;
+import com.yh.saas.plugin.yiliangyiyun.util.Const;
+import com.yh.saas.plugin.yiliangyiyun.util.GeneratorUtil;
+import com.yh.saas.plugin.yiliangyiyun.util.MD5Util;
+import org.apache.commons.codec.digest.Md5Crypt;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.data.redis.core.StringRedisTemplate;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.StringUtils;
+
+import java.sql.*;
+import java.util.Date;
 
 /**
  * <p>
@@ -16,5 +38,294 @@ import org.springframework.stereotype.Service;
  */
 @Service
 public class CommonUserServiceImpl extends ServiceImpl<CommonUserMapper, CommonUser> implements ICommonUserService {
+    private static  String VERIFY_CODE_PREFIX = "VERIFY_CODE_";
+    @Autowired
+    private CacheComponent cacheComponent;
+
+    @Autowired
+    private SMSClient smsClient;
+
+    @Autowired
+    private CommonUserMapper commonUserMapper;
+
+    @Autowired
+    private StringRedisTemplate userRedisTemplate;
+
+    Connection  coon=null;
+    Connection  coon1=null;
+    @Value("com.mysql.jdbc.Driver")
+    private String driverClassName;
+    @Value("jdbc:mysql://47.100.3.209:3306/talk-portal?createDatabaseIfNotExist=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&allowMultiQueries=true")
+    private String url;
+    @Value("root")
+    private String username;
+    @Value("Ccj841968545")
+    private String password;
+    @Value("wxce2e964b11803018")
+    private String gzhAppId;
+    @Value("122059c777309ff3efc7448ec8794fd5")
+    private String gzhAppSecret;
+    @Value("${spring.liangxin.url1}jdbc:mysql://47.100.3.209:3306/talk-core?createDatabaseIfNotExist=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&allowMultiQueries=true")
+    private String url1;
+    @Value("root")
+    private String username1;
+    @Value("Ccj841968545")
+    private String password1;
+
+    /**
+     * 注册
+     * @param commonUser
+     * @return
+     * @throws ServiceException
+     */
+    @Override
+    public String register(CommonUser commonUser) throws ServiceException {
+        //1.校验验证码
+        checkVerifyCode(commonUser.getPhone(), commonUser.getVerifyCode());
+        //2.校验用户是否存在
+        Integer count = this.selectCount(
+                new EntityWrapper<CommonUser>()
+                        .eq("phone", commonUser.getPhone()));
+        if (count > 0) {
+            throw new AppServiceException(ExceptionDefinition.USER_PHONE_HAS_EXISTED);
+        }
+        //3.校验成功,注册用户
+        CommonUser user = new CommonUser();
+        user.setPhone(commonUser.getPhone());
+        user.setPassword(Md5Crypt.md5Crypt(commonUser.getPassword().getBytes(), "$1$" + commonUser.getPhone().substring(0, 7)));
+        this.insert(user);
+        //返回用户DTO
+        cacheComponent.del(VERIFY_CODE_PREFIX + commonUser.getPhone());
+        return commonUser.getPhone();
+    }
+
+    /**
+     * 发送验证码
+     * @param phone
+     * @return
+     * @throws ServiceException
+     */
+    @Override
+    public String sendVerifyCode(String phone) throws ServiceException {
+        String verifyCode = GeneratorUtil.genSixVerifyCode();
+        System.out.println("verifyCode:"+verifyCode);
+        SMSResult res = smsClient.sendRegisterVerify(phone, verifyCode);
+        if (res.isSucc()) {
+            cacheComponent.putRaw(VERIFY_CODE_PREFIX + phone, verifyCode, 300);
+            return "ok";
+        } else {
+            throw new AppServiceException(res.getMsg(), ExceptionDefinition.USER_SEND_VERIFY_FAILED.getCode());
+        }
+
+    }
+
+
+    /**
+     * 登录
+     * @param commonUser
+     * @return
+     * @throws ServiceException
+     */
+    @Override
+    @Transactional
+    public CommonUser login(CommonUser commonUser) throws ServiceException {
+        String cryptPassword = Md5Crypt.md5Crypt(commonUser.getPassword().getBytes(), "$1$" + commonUser.getPhone().substring(0, 7));
+        CommonUser user = commonUserMapper.login(commonUser.getPhone(), cryptPassword);
+
+        if (user == null) {
+            throw new AppServiceException(ExceptionDefinition.USER_PHONE_OR_PASSWORD_NOT_CORRECT);
+        }
+        CommonUser userDO = this.selectById(user.getId());
+        //检查帐号是否已经冻结
+        if (userDO.getStatus() == 0) {
+            throw new AppServiceException(ExceptionDefinition.USER_CAN_NOT_ACTICE);
+        }
+        if(commonUser.getPhone() != null){
+            DBConnection();
+            String sUserId = null;
+            password = null;
+            if(excSelect("select * from t_user t where t.MOBILE = '"+commonUser.getPhone()+"'",this.coon) > 0){
+                excUpdate("update t_user t set t.LAST_LOGIN_TIME = now() where t.MOBILE = '"+commonUser.getPhone()+"'",this.coon);
+                sUserId=excSelect1("select * from t_user t where t.MOBILE = '"+commonUser.getPhone()+"'",this.coon);
+            }
+            else{
+                password = MD5Util.encrypt(commonUser.getPhone(), "123456");
+                excInsert("insert into t_user (USERNAME,PASSWORD,REALNAME,STATUS,MOBILE,CREATE_TIME,MODIFY_TIME,LAST_LOGIN_TIME,AVATAR,OPER_ID) " +
+                        "VALUES ('"+commonUser.getPhone()+"','"+ password +"','"+userDO.getUserName()+"',1,'"+commonUser.getPhone()+"',NOW(),NOW(),NOW(),'https://liangxin.zthymaoyi.com/upload/default.jpg','"
+                        + UUID.randomUUID().toString(true)+"')",this.coon);
+                Long user_id = excSelect("select * from t_user t where t.MOBILE = '"+commonUser.getPhone()+"'",this.coon);
+                sUserId=excSelect1("select * from t_user t where t.MOBILE = '"+commonUser.getPhone()+"'",this.coon);
+                excInsert("insert into t_user_role (USER_ID,ROLE_ID) " +
+                        "VALUES ("+user_id+",7)",this.coon);
+                excInsert("insert into t_user_config (USER_ID,THEME,LAYOUT,MULTI_PAGE,FIX_SIDERBAR,FIX_HEADER,COLOR) " +
+                        "VALUES ("+user_id+",'dark','side','0','1','1','rgb(66, 185, 131)')",this.coon);
+
+            }
+            close();
+            DBConnection1();
+            if( excSelect2("select * from s_user t where t.id = '"+sUserId+"'",this.coon1)!= null){
+                excUpdate("update s_user t set t.last_oper_time = now() where t.id = '"+sUserId+"'",this.coon1);
+            }
+            else{
+                excInsert("insert into s_user (id,nick_name,user_name,password,avatar,money,status,oper_time,last_oper_time) " +
+                        "VALUES ('"+sUserId+"','"+ userDO.getUserName()+"','"+commonUser.getPhone()+"','"+password+"','https://liangxin.zthymaoyi.com/upload/default.jpg','0.0',0,NOW(),NOW())",this.coon1);
+            }
+            close1();
+            userDO.setLiangxinId(sUserId);
+            this.updateById(userDO);
+        }
+        //返回用户DTO
+        cacheComponent.del(VERIFY_CODE_PREFIX + commonUser.getPhone());
+        String accessToken = GeneratorUtil.genSessionId();
+        BeanUtils.copyProperties(userDO,user);
+        user.setAccessToken(accessToken);
+        //放入SESSION专用Redis数据源中
+        userRedisTemplate.opsForValue().set(Const.USER_REDIS_PREFIX + accessToken, JSONObject.toJSONString(user));
+        this.updateById(userDO);
+        return user;
+    }
+
+    public void DBConnection(){
+        try{
+            //加载驱动程序
+            Class.forName(driverClassName);
+            coon=(Connection) DriverManager.getConnection(url,username,password);
+            if(!coon.isClosed()){
+                System.out.println("成功连接数据库!");
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+    }
+
+    //    查询s_user表
+    public String excSelect2(String sql,Connection  coon){
+        try{
+            Statement stmt=(Statement)coon.createStatement();
+            ResultSet rs=(ResultSet)stmt.executeQuery(sql);//得到的是结果的集合
+
+            while(rs.next()){
+                String id=rs.getString("ID");
+                if(id != null && !id.isEmpty()){
+                    return id;
+                }
+            }
+            stmt.close();
+            return null;
+        }catch(Exception e){
+            e.printStackTrace();
+            return null;
+        }
+    }
+    //    增加数据
+    public void excInsert(String sql,Connection  coon){
+        try{
+            PreparedStatement preStmt=(PreparedStatement)coon.prepareStatement(sql);
+            preStmt.executeUpdate();
+            System.out.println("插入数据成功!");
+            preStmt.close();
+        }catch(Exception e){
+            System.out.println("粮信插入数据异常!");
+            e.printStackTrace();
+        }
+    }
+    //    查询t_user表
+    public String excSelect1(String sql,Connection  coon){
+        try{
+            Statement stmt=(Statement)coon.createStatement();
+            ResultSet rs=(ResultSet)stmt.executeQuery(sql);//得到的是结果的集合
+
+            while(rs.next()){
+                String id=rs.getString("OPER_ID");
+                if(id != null && !id.isEmpty()){
+                    return id;
+                }
+            }
+            stmt.close();
+            return null;
+        }catch(Exception e){
+            e.printStackTrace();
+            return null;
+        }
+    }
+
+    public void close(){
+        try{
+            this.coon.close();
+            System.out.println("成功关闭数据库连接!");
+        }catch(Exception e){
+            e.printStackTrace();
+            System.out.println("关闭数据库连接异常!");
+        }
+    }
+
+    public void close1(){
+        try{
+            this.coon1.close();
+            System.out.println("成功关闭数据库连接!");
+        }catch(Exception e){
+            e.printStackTrace();
+            System.out.println("关闭数据库连接异常!");
+        }
+    }
+    //    更改数据
+    public void excUpdate(String sql,Connection  coon){
+        try{
+            PreparedStatement prestmt=(PreparedStatement)coon.prepareStatement(sql);
+            prestmt.executeUpdate();
+            System.out.println("更改数据成功!");
+            prestmt.close();
+        }catch(Exception e){
+            System.out.println("粮信更改数据异常!");
+            e.printStackTrace();
+        }
+    }
+
+    //    查询t_user表
+    public Long excSelect(String sql,Connection  coon){
+        try{
+            Statement stmt=(Statement)coon.createStatement();
+            ResultSet rs=(ResultSet)stmt.executeQuery(sql);//得到的是结果的集合
 
+            while(rs.next()){
+                Long name=rs.getLong("USER_ID");
+                if(name != null && name > 0){
+                    return name;
+                }
+            }
+            stmt.close();
+            return -1l;
+        }catch(Exception e){
+            e.printStackTrace();
+            return -1l;
+        }
+    }
+    public void DBConnection1(){
+        try{
+            //加载驱动程序
+            Class.forName(driverClassName);
+            coon1=(Connection)DriverManager.getConnection(url1,username1,password1);
+            if(!coon1.isClosed()){
+                System.out.println("成功连接数据库!");
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+    }
+    /**
+     * 验证码抽取校验
+     *
+     * @param phone
+     * @param verifyCode
+     * @throws ServiceException
+     */
+    private void checkVerifyCode(String phone, String verifyCode) throws ServiceException {
+        String raw = cacheComponent.getRaw(VERIFY_CODE_PREFIX + phone);
+        if (StringUtils.isEmpty(raw)) {
+            throw new AppServiceException(ExceptionDefinition.USER_VERIFY_CODE_NOT_EXIST);
+        }
+        if (!raw.equals(verifyCode)) {
+            throw new AppServiceException(ExceptionDefinition.USER_VERIFY_CODE_NOT_CORRECT);
+        }
+    }
 }

+ 37 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/util/Const.java

@@ -0,0 +1,37 @@
+package com.yh.saas.plugin.yiliangyiyun.util;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created with IntelliJ IDEA.
+ * Description:
+ * User: rize
+ * Date: 2018-08-11
+ * Time: 下午11:43
+ */
+public class Const {
+
+    public static  List<Class> IGNORE_PARAM_LIST = new ArrayList<>();
+
+    static {
+        IGNORE_PARAM_LIST.add(Integer.class);
+        IGNORE_PARAM_LIST.add(Long.class);
+        IGNORE_PARAM_LIST.add(String.class);
+        IGNORE_PARAM_LIST.add(Float.class);
+        IGNORE_PARAM_LIST.add(Double.class);
+        IGNORE_PARAM_LIST.add(Boolean.class);
+    }
+
+    public static  Integer CACHE_ONE_DAY = 60 * 60 * 24;
+
+
+    public static final String USER_ACCESS_TOKEN = "ACCESSTOKEN";
+
+    public static final String USER_REDIS_PREFIX = "USER_SESSION_";
+
+    public static final String ADMIN_ACCESS_TOKEN = "ADMINTOKEN";
+
+    public static final String ADMIN_REDIS_PREFIX = "ADMIN_SESSION_";
+
+}

+ 48 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/util/GeneratorUtil.java

@@ -0,0 +1,48 @@
+package com.yh.saas.plugin.yiliangyiyun.util;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.UUID;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * Created by rize on 2019/7/1.
+ */
+public class GeneratorUtil {
+
+    private static  AtomicInteger orderIdCount = new AtomicInteger();
+    private static  AtomicInteger tranContractCount = new AtomicInteger();
+
+    private static  SimpleDateFormat ORDER_ID_FORMAT = new SimpleDateFormat("yyyyMMDDHHmmss");
+
+    public static String genSixVerifyCode() {
+        String time = System.nanoTime() + "";
+        return time.substring(time.length() - 6);
+    }
+
+    public static String genSessionId() {
+        return UUID.randomUUID().toString().replace("-","").toUpperCase();
+    }
+
+
+    public static String genOrderId(String head) {
+        int i = orderIdCount.incrementAndGet() % 100;
+        if (i < 100)
+            i += 100;
+        return head + ORDER_ID_FORMAT.format(new Date()) + i;
+    }
+    public static String genContractNo(String head) {
+        int i = tranContractCount.incrementAndGet() % 100;
+        if (i < 100)
+            i += 100;
+        return head + ORDER_ID_FORMAT.format(new Date()) + i;
+    }
+    public static String genFileName(){
+        return UUID.randomUUID().toString().replaceAll("-", "");
+    }
+
+    public static String genUUId() {
+        return UUID.randomUUID().toString().replace("-", "");
+    }
+
+}

+ 44 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/util/MD5Util.java

@@ -0,0 +1,44 @@
+package com.yh.saas.plugin.yiliangyiyun.util;
+
+import org.apache.commons.codec.digest.DigestUtils;
+import org.apache.shiro.crypto.hash.SimpleHash;
+import org.apache.shiro.util.ByteSource;
+
+/**
+ * MD5通用类
+ */
+public class MD5Util {
+    /**
+     * MD5方法
+     *
+     * @param text 明文
+     * @param key  密钥
+     * @return 密文
+     * @throws Exception
+     */
+    public static String md5(String text, String key) {
+        //加密后的字符串
+        return DigestUtils.md5Hex(text + key);
+    }
+
+    private static final String ALGORITH_NAME = "md5";
+    private static final int HASH_ITERATIONS = 2;
+    public static String encrypt(String username, String password) {
+        return new SimpleHash(ALGORITH_NAME, password, ByteSource.Util.bytes(username.toLowerCase() + password),
+                HASH_ITERATIONS).toHex();
+    }
+    /**
+     * MD5验证方法
+     *
+     * @param text 明文
+     * @param key  密钥
+     * @param md5  密文
+     * @return true/false
+     * @throws Exception
+     */
+    public static boolean verify(String text, String key, String md5) {
+        //根据传入的密钥进行验证
+        String md5Text = md5(text, key);
+        return md5Text.equalsIgnoreCase(md5);
+    }
+}

+ 14 - 1
winsea-haixin-plugin-yiliangyiyun/src/main/resources/mapper/CommonUserMapper.xml

@@ -1,5 +1,18 @@
 <?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.yh.saas.plugin.yiliangyiyun.mapper.CommonUserMapper">
-
+    <select id="login" resultType="com.yh.saas.plugin.yiliangyiyun.entity.CommonUser">
+        SELECT
+            id,
+            phone,
+            access_token as accessToken,
+            liangxin_id as liangxinId,
+            user_name as userName,
+            avatar_url AS avatarUrl,
+            status
+        FROM
+            common_user
+        WHERE
+            phone = #{phone} AND `password` = #{cryptPassword}
+    </select>
 </mapper>