Browse Source

新增小程序接口

anderx 4 years ago
parent
commit
f71948f6d8
55 changed files with 5283 additions and 29 deletions
  1. 1 1
      GeneratorConfig.xml
  2. 126 1
      src/main/java/com/kede/admin/controller/AdminLoginController.java
  3. 18 0
      src/main/java/com/kede/admin/controller/AdminSystemController.java
  4. 12 0
      src/main/java/com/kede/admin/service/OrderService.java
  5. 39 0
      src/main/java/com/kede/admin/service/impl/OrderServiceImpl.java
  6. 53 0
      src/main/java/com/kede/common/bo/CallBackBo.java
  7. 66 0
      src/main/java/com/kede/common/bo/OutOrder.java
  8. 47 0
      src/main/java/com/kede/common/bo/resourceBo.java
  9. 0 22
      src/main/java/com/kede/common/controller/CertifyApiController.java
  10. 71 0
      src/main/java/com/kede/common/controller/PublicApiController.java
  11. 48 0
      src/main/java/com/kede/common/dao/OrderMapper.java
  12. 52 0
      src/main/java/com/kede/common/dao/ProjectMapper.java
  13. 57 0
      src/main/java/com/kede/common/dao/ProjectTypeMapper.java
  14. 43 0
      src/main/java/com/kede/common/dao/UserMapper.java
  15. 235 0
      src/main/java/com/kede/common/mapper/OrderMapper.xml
  16. 297 0
      src/main/java/com/kede/common/mapper/ProjectMapper.xml
  17. 132 0
      src/main/java/com/kede/common/mapper/ProjectTypeMapper.xml
  18. 215 0
      src/main/java/com/kede/common/mapper/UserMapper.xml
  19. 269 0
      src/main/java/com/kede/common/model/Order.java
  20. 341 0
      src/main/java/com/kede/common/model/Project.java
  21. 167 0
      src/main/java/com/kede/common/model/ProjectType.java
  22. 268 0
      src/main/java/com/kede/common/model/User.java
  23. 52 0
      src/main/java/com/kede/common/model/projectBo.java
  24. 8 0
      src/main/java/com/kede/common/utils/PasswordUtil.java
  25. 14 0
      src/main/java/com/kede/common/utils/StringUtils.java
  26. 46 0
      src/main/java/com/kede/common/utils/WxAPIV3AesUtil.java
  27. 1 0
      src/main/java/com/kede/core/shiro/filter/LoginFilter.java
  28. 47 0
      src/main/java/com/kede/core/shiro/filter/UserFilter.java
  29. 13 0
      src/main/java/com/kede/core/shiro/token/TokenManager.java
  30. 18 3
      src/main/java/com/kede/core/shiro/token/UserRealm.java
  31. 79 0
      src/main/java/com/kede/project/controller/ProjectApiController.java
  32. 60 0
      src/main/java/com/kede/project/controller/ProjectTypeApiController.java
  33. 22 0
      src/main/java/com/kede/project/service/ProjectService.java
  34. 19 0
      src/main/java/com/kede/project/service/ProjectTypeService.java
  35. 90 0
      src/main/java/com/kede/project/service/impl/ProjectServiceImpl.java
  36. 47 0
      src/main/java/com/kede/project/service/impl/ProjectTypeServiceImpl.java
  37. 44 0
      src/main/java/com/kede/sdk/IWXPayDomain.java
  38. 59 0
      src/main/java/com/kede/sdk/WXPayConstants.java
  39. 292 0
      src/main/java/com/kede/sdk/WXPayUtil.java
  40. 30 0
      src/main/java/com/kede/sdk/WXPayXmlUtil.java
  41. 106 0
      src/main/java/com/kede/sdk/service/IWxPayConfig.java
  42. 694 0
      src/main/java/com/kede/sdk/service/WXPay.java
  43. 105 0
      src/main/java/com/kede/sdk/service/WXPayConfig.java
  44. 268 0
      src/main/java/com/kede/sdk/service/WXPayReport.java
  45. 262 0
      src/main/java/com/kede/sdk/service/WXPayRequest.java
  46. 195 0
      src/main/java/com/kede/sdk/service/WxService.java
  47. 26 0
      src/main/java/com/kede/user/bo/UserBo.java
  48. 68 0
      src/main/java/com/kede/user/controller/UserApiController.java
  49. 8 0
      src/main/java/com/kede/user/service/UserService.java
  50. 25 0
      src/main/java/com/kede/user/service/impl/UserServiceImpl.java
  51. 10 0
      src/main/resources/props/config_local.properties
  52. 8 0
      src/main/resources/props/config_prod.properties
  53. 4 1
      src/main/resources/shiro_base_auth.ini
  54. 5 0
      src/main/resources/spring/spring-shiro.xml
  55. 1 1
      src/main/webapp/WEB-INF/views/error.html

+ 1 - 1
GeneratorConfig.xml

@@ -43,7 +43,7 @@
     <property name="enableSubPackages" value="false"/>
      <property name="nullCatalogMeansCurrent" value="true"/>
     </javaClientGenerator>
-    <table schema="aft_ow" tableName="banner_details"   enableCountByExample="false"
+    <table schema="aft_ow" tableName="order"   enableCountByExample="false"
                enableUpdateByExample="false"
                enableDeleteByExample="false"
                enableSelectByExample="false"

+ 126 - 1
src/main/java/com/kede/admin/controller/AdminLoginController.java

@@ -1,27 +1,81 @@
 package com.kede.admin.controller;
 
+import java.io.IOException;
+import java.net.InetAddress;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.Collections;
 import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 
+import org.apache.commons.codec.digest.DigestUtils;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpStatus;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.util.EntityUtils;
+import org.apache.shiro.web.util.WebUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.data.domain.Sort;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.ResponseBody;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.kede.common.bo.Result;
+import com.kede.common.constant.ErrorConstants;
 import com.kede.common.controller.BaseController;
 import com.kede.common.dao.AdminMapper;
+import com.kede.common.dao.UserMapper;
+import com.kede.common.error.BusinessException;
 import com.kede.common.model.Admin;
+import com.kede.common.model.User;
+import com.kede.common.utils.LoggerUtils;
+import com.kede.common.utils.PasswordUtil;
+import com.kede.core.mybatis.JDBCIdGenerator;
 import com.kede.core.shiro.token.TokenManager;
+import com.kede.sdk.WXPayUtil;
+import com.kede.sdk.service.IWxPayConfig;
+import com.kede.sdk.service.WXPay;
+
+
 @Controller
 public class AdminLoginController extends BaseController {
 	
 	@Resource
 	private AdminMapper		adminMapper;
+	@Resource
+	private UserMapper	userMapper; 
+	@Autowired
+	private PasswordUtil	passwordUtil;
+	@Autowired
+	private JDBCIdGenerator	idGenerator;
+	
+	@Value(value = "${wx.appId}")
+	private String appId;
+	@Value(value = "${wx.appSecret}")
+	private String appSecret;
+	@Value(value = "${wx.mchId}")
+	private String mchId;
+	@Value(value = "${wx.apiKiy}")
+	private String apiKiy;
+	@Value(value = "${wx.notifyUrl}")
+	private String notifyUrl;
+	
+	
 	
 	/**
 	 * 管理端登录
@@ -52,6 +106,76 @@ public class AdminLoginController extends BaseController {
 		}
 		return res;
 	}
+	
+	
+	
+	
+	/**
+	 * 	微信端登录
+	 * 
+	 * @param user
+	 * @param remember
+	 * @param request
+	 * @return
+	 */
+	@ResponseBody
+	@RequestMapping(value = "/wxLogin", method = RequestMethod.POST)
+	public Result wxLogin(Boolean remember, HttpServletRequest request,String code,String nickname) {
+		Result res = new Result();
+		if (StringUtils.isBlank(code)) {
+			res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"code","code"));
+			return res;
+		}
+		Calendar now = Calendar.getInstance();
+		now.set(Calendar.MILLISECOND, 0);
+		JSONObject jsonObject=getUserOpenId(request, code);
+		String openId=jsonObject.getString("openid");
+		if (StringUtils.isBlank(openId)) {
+			res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"openId","openId"));
+			return res;
+		}
+		User u=userMapper.selectByOpenId(openId);
+		if (u==null) {
+			u=new User();
+			u.setId(UUID.randomUUID().toString());
+			u.setOpenId(openId);
+			u.setNickname(nickname);
+			u.setCreateTime(now.getTime());
+			u.setPassword("123456");//固定初始密码并加密
+			u.setPassword(passwordUtil.getEncryptPwd(u));
+			userMapper.insert(u);
+		}
+		u.setPassword("123456");
+		WebUtils.getAndClearSavedRequest(request);
+		res.data(TokenManager.login(u, remember,openId));
+		return res;
+	}
+	
+	private JSONObject getUserOpenId(HttpServletRequest request,String code){
+		String url = "https://api.weixin.qq.com/sns/jscode2session?";
+		url=url+"appid="+appId+"&secret="+appSecret+"&js_code="+code+"&grant_type=authorization_code";
+		return this.httpGet(url);
+	}
+	
+	public JSONObject httpGet(String url) {
+		JSONObject jsonResult = null;
+		try {
+		HttpClient client = HttpClientBuilder.create().build();//获取DefaultHttpClient请求
+		HttpGet request = new HttpGet(url);
+		HttpResponse response = client.execute(request);
+		if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
+		String strResult = EntityUtils.toString(response.getEntity(),"UTF-8");//此处设定编码格式
+		jsonResult = JSON.parseObject(strResult);
+		} else {
+		LoggerUtils.error(getClass(), "HttpStatus异常");
+		}
+		} catch (IOException e) {
+		e.printStackTrace();
+		}
+		return jsonResult;
+	}
+
+
 	/**
 	 * 退出登陆
 	 * @param request
@@ -66,5 +190,6 @@ public class AdminLoginController extends BaseController {
 		TokenManager.logout();
 		return res;
 	}
-
+	
+		
 }

+ 18 - 0
src/main/java/com/kede/admin/controller/AdminSystemController.java

@@ -1,5 +1,6 @@
 package com.kede.admin.controller;
 
+
 import javax.annotation.Resource;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -7,6 +8,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
 import com.kede.admin.service.AdminService;
+import com.kede.admin.service.OrderService;
 import com.kede.common.bo.Result;
 import com.kede.common.constant.ErrorConstants;
 import com.kede.common.controller.BaseApiController;
@@ -15,6 +17,7 @@ import com.kede.common.utils.PasswordUtil;
 import com.kede.common.utils.StringUtils;
 import com.kede.core.shiro.token.TokenManager;
 import com.kede.easemob.EasemobUtils;
+import com.kede.user.service.UserService;
 
 @RestController
 @RequestMapping(value = "/api/admin")
@@ -24,8 +27,13 @@ public class AdminSystemController extends BaseApiController {
 	EasemobUtils easemobUtils;
 	@Resource
 	private AdminService					adminService;
+	@Resource
+	private UserService						userService;
+	@Resource
+	private OrderService	OrderService;
 	@Resource(name = "passwordUtil")
 	private PasswordUtil					passwordUtil;
+
 	
 	
 	/**
@@ -60,7 +68,17 @@ public class AdminSystemController extends BaseApiController {
 		return res;
 	}
 	
+	@RequestMapping(value = "/userList",method = RequestMethod.GET)
+	public Result userList(String name,Integer pageNo,Integer PageSize) {
+		Result res =new Result();
+		return res.data(userService.list(name,pageNo,PageSize));
+	}
 	
+	@RequestMapping(value = "/orderList",method = RequestMethod.GET)
+	public Result orderList(String name,Integer status,String startTime,String endTime,Integer pageNo,Integer PageSize) {
+		Result res =new Result();
+		return res.data(OrderService.list( name, status, startTime, endTime, pageNo, PageSize));
+	}
 
 	
 }

+ 12 - 0
src/main/java/com/kede/admin/service/OrderService.java

@@ -0,0 +1,12 @@
+package com.kede.admin.service;
+
+import com.kede.common.model.Order;
+
+public interface OrderService {
+
+	Object list(String name, Integer status, String startTime, String endTime, Integer pageNo, Integer pageSize);
+
+	int insert(Order o);
+
+
+}

+ 39 - 0
src/main/java/com/kede/admin/service/impl/OrderServiceImpl.java

@@ -0,0 +1,39 @@
+package com.kede.admin.service.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.kede.admin.service.OrderService;
+import com.kede.common.dao.OrderMapper;
+import com.kede.common.model.Order;
+import com.kede.common.utils.StringUtils;
+import com.kede.core.mybatis.BaseMybatisDao;
+
+@Service
+public class OrderServiceImpl extends BaseMybatisDao<OrderMapper> implements OrderService{
+	@Autowired
+	private OrderMapper orderMapper;
+
+	@Override
+	public Object list(String name, Integer status, String startTime, String endTime, Integer pageNo,
+			Integer pageSize) {
+		Map<String, Object> params=new HashMap<String, Object>();
+		if(StringUtils.isNotBlank(name))params.put("name", name);
+		if(status!=null)params.put("status", status);
+		if(StringUtils.isNotBlank(startTime))params.put("startTime", startTime);
+		if(StringUtils.isNotBlank(endTime))params.put("endTime", endTime);
+		return findPage("selectOrderList", "selectOrderCount", params, pageNo, pageSize);
+	}
+
+	@Override
+	public int insert(Order o) {
+		return orderMapper.insertSelective(o);
+	}
+
+
+	
+	
+}

+ 53 - 0
src/main/java/com/kede/common/bo/CallBackBo.java

@@ -0,0 +1,53 @@
+package com.kede.common.bo;
+
+public class CallBackBo {
+	private String id;
+	private String createTime;
+	private String eventType;
+	private String resourceType;
+	private resourceBo resource;
+	private String summary;
+	public String getId() {
+		return id;
+	}
+	public void setId(String id) {
+		this.id = id;
+	}
+	public String getCreateTime() {
+		return createTime;
+	}
+	public void setCreateTime(String createTime) {
+		this.createTime = createTime;
+	}
+	public String getEventType() {
+		return eventType;
+	}
+	public void setEventType(String eventType) {
+		this.eventType = eventType;
+	}
+	public String getResourceType() {
+		return resourceType;
+	}
+	public void setResourceType(String resourceType) {
+		this.resourceType = resourceType;
+	}
+	public resourceBo getResource() {
+		return resource;
+	}
+	public void setResource(resourceBo resource) {
+		this.resource = resource;
+	}
+	public String getSummary() {
+		return summary;
+	}
+	public void setSummary(String summary) {
+		this.summary = summary;
+	}
+	@Override
+	public String toString() {
+		return "CallBackBo [id=" + id + ", createTime=" + createTime + ", eventType=" + eventType + ", resourceType="
+				+ resourceType + ", resource=" + resource + ", summary=" + summary + "]";
+	}
+	
+	
+}

+ 66 - 0
src/main/java/com/kede/common/bo/OutOrder.java

@@ -0,0 +1,66 @@
+package com.kede.common.bo;
+
+
+public class OutOrder{
+	private String orderNo;
+	private String uid;
+	private String userName;
+	private String mobile;
+	private String projectAmount;
+	private Integer status;
+	private Integer payStatus;
+	private String createTimes;
+	public String getOrderNo() {
+		return orderNo;
+	}
+	public void setOrderNo(String orderNo) {
+		this.orderNo = orderNo;
+	}
+	public String getUid() {
+		return uid;
+	}
+	public void setUid(String uid) {
+		this.uid = uid;
+	}
+	public String getUserName() {
+		return userName;
+	}
+	public void setUserName(String userName) {
+		this.userName = userName;
+	}
+	public String getMobile() {
+		return mobile;
+	}
+	public void setMobile(String mobile) {
+		this.mobile = mobile;
+	}
+	public String getProjectAmount() {
+		return projectAmount;
+	}
+	public void setProjectAmount(String projectAmount) {
+		this.projectAmount = projectAmount;
+	}
+	public Integer getStatus() {
+		return status;
+	}
+	public void setStatus(Integer status) {
+		this.status = status;
+	}
+	public Integer getPayStatus() {
+		return payStatus;
+	}
+	public void setPayStatus(Integer payStatus) {
+		this.payStatus = payStatus;
+	}
+	public String getCreateTimes() {
+		return createTimes;
+	}
+	public void setCreateTimes(String createTimes) {
+		this.createTimes = createTimes;
+	}
+
+	
+	
+	
+	
+}

+ 47 - 0
src/main/java/com/kede/common/bo/resourceBo.java

@@ -0,0 +1,47 @@
+package com.kede.common.bo;
+
+
+public class resourceBo {
+	private String algorithm;
+	private String ciphertext;
+	private String associatedData;
+	private String originalType;
+	private String nonce;
+	public String getAlgorithm() {
+		return algorithm;
+	}
+	public void setAlgorithm(String algorithm) {
+		this.algorithm = algorithm;
+	}
+	public String getCiphertext() {
+		return ciphertext;
+	}
+	public void setCiphertext(String ciphertext) {
+		this.ciphertext = ciphertext;
+	}
+	public String getAssociatedData() {
+		return associatedData;
+	}
+	public void setAssociatedData(String associatedData) {
+		this.associatedData = associatedData;
+	}
+	public String getOriginalType() {
+		return originalType;
+	}
+	public void setOriginalType(String originalType) {
+		this.originalType = originalType;
+	}
+	public String getNonce() {
+		return nonce;
+	}
+	public void setNonce(String nonce) {
+		this.nonce = nonce;
+	}
+	@Override
+	public String toString() {
+		return "resourceBo [algorithm=" + algorithm + ", ciphertext=" + ciphertext + ", associatedData="
+				+ associatedData + ", originalType=" + originalType + ", nonce=" + nonce + "]";
+	}
+	
+	
+}

+ 0 - 22
src/main/java/com/kede/common/controller/CertifyApiController.java

@@ -1,22 +0,0 @@
-package com.kede.common.controller;
-
-import com.kede.common.bo.Result;
-import com.kede.common.constant.ErrorConstants;
-import com.kede.core.shiro.token.TokenManager;
-
-public class CertifyApiController extends BaseApiController {
-
-
-
-
-	public boolean checkAdminLogin(Result res) {
-		if (TokenManager.getAdminToken() == null) {
-			res.getError().add(buildError(ErrorConstants.NON_LOGIN, "找不到登录信息"));
-			return false;
-		}
-		return true;
-	}
-
-	
-
-}

+ 71 - 0
src/main/java/com/kede/common/controller/PublicApiController.java

@@ -2,18 +2,26 @@ package com.kede.common.controller;
 
 
 
+
+import java.util.Map;
+
 import javax.annotation.Resource;
 
+import org.apache.commons.collections4.map.HashedMap;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
 
+import com.alibaba.fastjson.JSON;
 import com.kede.activity.bo.InputActivity;
 import com.kede.activity.service.ActivityService;
 import com.kede.banners.service.BannersService;
+import com.kede.common.bo.CallBackBo;
 import com.kede.common.bo.Result;
 import com.kede.common.constant.ErrorConstants;
 import com.kede.common.model.VisitingCustomers;
+import com.kede.common.utils.LoggerUtils;
 import com.kede.common.utils.StringUtils;
 import com.kede.customerCase.bo.InputCustomerCase;
 import com.kede.customerCase.service.CustomerCaseService;
@@ -21,8 +29,11 @@ import com.kede.news.bo.InputNews;
 import com.kede.news.service.NewsService;
 import com.kede.organization.bo.InputOrganization;
 import com.kede.organization.service.OrganizationService;
+import com.kede.project.service.ProjectService;
+import com.kede.project.service.ProjectTypeService;
 import com.kede.recruitment.bo.InputRecruitment;
 import com.kede.recruitment.service.RecruitmentService;
+import com.kede.sdk.service.WxService;
 import com.kede.visitingCustomers.service.VisitingCustomersService;
 
 
@@ -44,6 +55,14 @@ public class PublicApiController extends BaseController {
 	private VisitingCustomersService	visitingCustomersService;
 	@Resource
 	private ActivityService	activityService;
+	@Resource
+	private ProjectTypeService	projectTypeService;
+	@Resource
+	private ProjectService	projectService;
+	@Resource
+	private WxService	wxService;
+	
+	
 
 	
 	@RequestMapping(value = "/listNews", method = RequestMethod.GET)
@@ -98,4 +117,56 @@ public class PublicApiController extends BaseController {
 		res.data(activityService.listDetails(in,pageSize,pageNo));
 		return res;
 	}
+	
+	
+	@RequestMapping(value = "/projectTypeList", method = RequestMethod.GET)
+	public Result projectTypeList(String name) {
+		Result res =new Result();
+		
+		res.data(projectTypeService.list(name));
+		return res;
+	}
+	
+	@RequestMapping(value = "/projectList", method = RequestMethod.GET)
+	public Result projectList(String name, String startTime, String endTime,Integer pageNo,Integer pageSize) {
+		Result res =new Result();
+		
+		res.data(projectService.list( name,  startTime,  endTime, pageNo, pageSize));
+		return res;
+	}
+	
+	@RequestMapping(value = "/selectProject", method = RequestMethod.GET)
+	public Result selectProject(Integer id) {
+		Result res =new Result();
+		if (id==null) {
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "ID","ID"));
+		}
+		res.data(projectService.getProject( id));
+		return res;
+	}
+	
+	
+	@RequestMapping(value = "/payCallBack", method = RequestMethod.POST)
+	public Map<String, String> wxPayCallBack(@RequestBody String data) {
+		CallBackBo cb = JSON.parseObject(data, CallBackBo.class);
+		LoggerUtils.debug(getClass(), "返回参数 request=%s",cb);
+		Map<String, String> map=new HashedMap<>();
+		if (cb.getSummary().equals("支付成功")) {
+			wxService.wxPayCallBack(cb);
+			map.put("code", "SUCCESS");
+			map.put("message", "成功");
+		}else {
+			map.put("code", "FAIL");
+			map.put("message", "失败");
+		}
+		return map;
+	}
+
+	
+	
+	
+
+	
+	
+	
 }

+ 48 - 0
src/main/java/com/kede/common/dao/OrderMapper.java

@@ -0,0 +1,48 @@
+package com.kede.common.dao;
+
+import org.apache.ibatis.annotations.Param;
+
+import com.kede.common.model.Order;
+
+public interface OrderMapper {
+
+	/**
+	 * This method was generated by MyBatis Generator. This method corresponds to the database table order
+	 * @mbg.generated  Tue Apr 13 14:51:40 CST 2021
+	 */
+	int deleteByPrimaryKey(String orderNo);
+
+	/**
+	 * This method was generated by MyBatis Generator. This method corresponds to the database table order
+	 * @mbg.generated  Tue Apr 13 14:51:40 CST 2021
+	 */
+	int insert(Order record);
+
+	/**
+	 * This method was generated by MyBatis Generator. This method corresponds to the database table order
+	 * @mbg.generated  Tue Apr 13 14:51:40 CST 2021
+	 */
+	int insertSelective(Order record);
+
+	/**
+	 * This method was generated by MyBatis Generator. This method corresponds to the database table order
+	 * @mbg.generated  Tue Apr 13 14:51:40 CST 2021
+	 */
+	Order selectByPrimaryKey(String orderNo);
+
+	/**
+	 * This method was generated by MyBatis Generator. This method corresponds to the database table order
+	 * @mbg.generated  Tue Apr 13 14:51:40 CST 2021
+	 */
+	int updateByPrimaryKeySelective(Order record);
+
+	/**
+	 * This method was generated by MyBatis Generator. This method corresponds to the database table order
+	 * @mbg.generated  Tue Apr 13 14:51:40 CST 2021
+	 */
+	int updateByPrimaryKey(Order record);
+
+	int chakeBuy(@Param("uid")String uid, @Param("pid")Integer pid);
+
+	void updateByOrderNo(@Param("orderNo")String orderNo, @Param("wxNo")String wxNo);
+}

+ 52 - 0
src/main/java/com/kede/common/dao/ProjectMapper.java

@@ -0,0 +1,52 @@
+package com.kede.common.dao;
+
+import com.kede.common.model.Project;
+import com.kede.common.model.projectBo;
+
+public interface ProjectMapper {
+
+	/**
+	 * This method was generated by MyBatis Generator. This method corresponds to the database table project
+	 * @mbg.generated  Mon Apr 12 17:24:38 CST 2021
+	 */
+	int deleteByPrimaryKey(Integer id);
+
+	/**
+	 * This method was generated by MyBatis Generator. This method corresponds to the database table project
+	 * @mbg.generated  Mon Apr 12 17:24:38 CST 2021
+	 */
+	int insert(Project record);
+
+	/**
+	 * This method was generated by MyBatis Generator. This method corresponds to the database table project
+	 * @mbg.generated  Mon Apr 12 17:24:38 CST 2021
+	 */
+	int insertSelective(Project record);
+
+	/**
+	 * This method was generated by MyBatis Generator. This method corresponds to the database table project
+	 * @mbg.generated  Mon Apr 12 17:24:38 CST 2021
+	 */
+	Project selectByPrimaryKey(Integer id);
+
+	/**
+	 * This method was generated by MyBatis Generator. This method corresponds to the database table project
+	 * @mbg.generated  Mon Apr 12 17:24:38 CST 2021
+	 */
+	int updateByPrimaryKeySelective(Project record);
+
+	/**
+	 * This method was generated by MyBatis Generator. This method corresponds to the database table project
+	 * @mbg.generated  Mon Apr 12 17:24:38 CST 2021
+	 */
+	int updateByPrimaryKeyWithBLOBs(Project record);
+
+	/**
+	 * This method was generated by MyBatis Generator. This method corresponds to the database table project
+	 * @mbg.generated  Mon Apr 12 17:24:38 CST 2021
+	 */
+	int updateByPrimaryKey(Project record);
+
+	projectBo getProject(Integer id);
+
+}

+ 57 - 0
src/main/java/com/kede/common/dao/ProjectTypeMapper.java

@@ -0,0 +1,57 @@
+package com.kede.common.dao;
+
+import java.util.List;
+
+import com.kede.common.model.ProjectType;
+
+public interface ProjectTypeMapper {
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table project_type
+     *
+     * @mbg.generated Mon Apr 12 16:06:33 CST 2021
+     */
+    int deleteByPrimaryKey(Integer id);
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table project_type
+     *
+     * @mbg.generated Mon Apr 12 16:06:33 CST 2021
+     */
+    int insert(ProjectType record);
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table project_type
+     *
+     * @mbg.generated Mon Apr 12 16:06:33 CST 2021
+     */
+    int insertSelective(ProjectType record);
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table project_type
+     *
+     * @mbg.generated Mon Apr 12 16:06:33 CST 2021
+     */
+    ProjectType selectByPrimaryKey(Integer id);
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table project_type
+     *
+     * @mbg.generated Mon Apr 12 16:06:33 CST 2021
+     */
+    int updateByPrimaryKeySelective(ProjectType record);
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table project_type
+     *
+     * @mbg.generated Mon Apr 12 16:06:33 CST 2021
+     */
+    int updateByPrimaryKey(ProjectType record);
+
+	List<ProjectType> selectList(String name);
+}

+ 43 - 0
src/main/java/com/kede/common/dao/UserMapper.java

@@ -0,0 +1,43 @@
+package com.kede.common.dao;
+
+import com.kede.common.model.User;
+
+public interface UserMapper {
+    /**
+	 * This method was generated by MyBatis Generator. This method corresponds to the database table user
+	 * @mbg.generated  Mon Apr 12 15:07:09 CST 2021
+	 */
+	int deleteByPrimaryKey(String id);
+
+	/**
+	 * This method was generated by MyBatis Generator. This method corresponds to the database table user
+	 * @mbg.generated  Mon Apr 12 15:07:09 CST 2021
+	 */
+	int insert(User record);
+
+	/**
+	 * This method was generated by MyBatis Generator. This method corresponds to the database table user
+	 * @mbg.generated  Mon Apr 12 15:07:09 CST 2021
+	 */
+	int insertSelective(User record);
+
+	/**
+	 * This method was generated by MyBatis Generator. This method corresponds to the database table user
+	 * @mbg.generated  Mon Apr 12 15:07:09 CST 2021
+	 */
+	User selectByPrimaryKey(String id);
+
+	/**
+	 * This method was generated by MyBatis Generator. This method corresponds to the database table user
+	 * @mbg.generated  Mon Apr 12 15:07:09 CST 2021
+	 */
+	int updateByPrimaryKeySelective(User record);
+
+	/**
+	 * This method was generated by MyBatis Generator. This method corresponds to the database table user
+	 * @mbg.generated  Mon Apr 12 15:07:09 CST 2021
+	 */
+	int updateByPrimaryKey(User record);
+
+	User selectByOpenId(String openId);
+}

+ 235 - 0
src/main/java/com/kede/common/mapper/OrderMapper.xml

@@ -0,0 +1,235 @@
+<?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.kede.common.dao.OrderMapper">
+  <resultMap id="BaseResultMap" type="com.kede.common.model.Order">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Tue Apr 13 14:51:40 CST 2021.
+    -->
+    <id column="order_no" jdbcType="VARCHAR" property="orderNo" />
+    <result column="project_id" jdbcType="INTEGER" property="projectId" />
+    <result column="uid" jdbcType="VARCHAR" property="uid" />
+    <result column="project_name" jdbcType="VARCHAR" property="projectName" />
+    <result column="project_amount" jdbcType="DECIMAL" property="projectAmount" />
+    <result column="pay_amount" jdbcType="DECIMAL" property="payAmount" />
+    <result column="pay_status" jdbcType="INTEGER" property="payStatus" />
+    <result column="status" jdbcType="INTEGER" property="status" />
+    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
+    <result column="wx_order_no" jdbcType="VARCHAR" property="wxOrderNo" />
+  </resultMap>
+  <sql id="Base_Column_List">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Tue Apr 13 14:51:40 CST 2021.
+    -->
+    order_no, project_id, `uid`, project_name, project_amount, pay_amount, pay_status, 
+    `status`, create_time, wx_order_no
+  </sql>
+  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Tue Apr 13 14:51:40 CST 2021.
+    -->
+    select 
+    <include refid="Base_Column_List" />
+    from order
+    where order_no = #{orderNo,jdbcType=VARCHAR}
+  </select>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Tue Apr 13 14:51:40 CST 2021.
+    -->
+    delete from order
+    where order_no = #{orderNo,jdbcType=VARCHAR}
+  </delete>
+  <insert id="insert" parameterType="com.kede.common.model.Order">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Tue Apr 13 14:51:40 CST 2021.
+    -->
+    insert into order (order_no, project_id, `uid`, 
+      project_name, project_amount, pay_amount, 
+      pay_status, `status`, create_time, 
+      wx_order_no)
+    values (#{orderNo,jdbcType=VARCHAR}, #{projectId,jdbcType=INTEGER}, #{uid,jdbcType=VARCHAR}, 
+      #{projectName,jdbcType=VARCHAR}, #{projectAmount,jdbcType=DECIMAL}, #{payAmount,jdbcType=DECIMAL}, 
+      #{payStatus,jdbcType=INTEGER}, #{status,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, 
+      #{wxOrderNo,jdbcType=VARCHAR})
+  </insert>
+  <insert id="insertSelective" parameterType="com.kede.common.model.Order">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Tue Apr 13 14:51:40 CST 2021.
+    -->
+    insert into order
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="orderNo != null">
+        order_no,
+      </if>
+      <if test="projectId != null">
+        project_id,
+      </if>
+      <if test="uid != null">
+        `uid`,
+      </if>
+      <if test="projectName != null">
+        project_name,
+      </if>
+      <if test="projectAmount != null">
+        project_amount,
+      </if>
+      <if test="payAmount != null">
+        pay_amount,
+      </if>
+      <if test="payStatus != null">
+        pay_status,
+      </if>
+      <if test="status != null">
+        `status`,
+      </if>
+      <if test="createTime != null">
+        create_time,
+      </if>
+      <if test="wxOrderNo != null">
+        wx_order_no,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="orderNo != null">
+        #{orderNo,jdbcType=VARCHAR},
+      </if>
+      <if test="projectId != null">
+        #{projectId,jdbcType=INTEGER},
+      </if>
+      <if test="uid != null">
+        #{uid,jdbcType=VARCHAR},
+      </if>
+      <if test="projectName != null">
+        #{projectName,jdbcType=VARCHAR},
+      </if>
+      <if test="projectAmount != null">
+        #{projectAmount,jdbcType=DECIMAL},
+      </if>
+      <if test="payAmount != null">
+        #{payAmount,jdbcType=DECIMAL},
+      </if>
+      <if test="payStatus != null">
+        #{payStatus,jdbcType=INTEGER},
+      </if>
+      <if test="status != null">
+        #{status,jdbcType=INTEGER},
+      </if>
+      <if test="createTime != null">
+        #{createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="wxOrderNo != null">
+        #{wxOrderNo,jdbcType=VARCHAR},
+      </if>
+    </trim>
+  </insert>
+  <update id="updateByPrimaryKeySelective" parameterType="com.kede.common.model.Order">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Tue Apr 13 14:51:40 CST 2021.
+    -->
+    update order
+    <set>
+      <if test="projectId != null">
+        project_id = #{projectId,jdbcType=INTEGER},
+      </if>
+      <if test="uid != null">
+        `uid` = #{uid,jdbcType=VARCHAR},
+      </if>
+      <if test="projectName != null">
+        project_name = #{projectName,jdbcType=VARCHAR},
+      </if>
+      <if test="projectAmount != null">
+        project_amount = #{projectAmount,jdbcType=DECIMAL},
+      </if>
+      <if test="payAmount != null">
+        pay_amount = #{payAmount,jdbcType=DECIMAL},
+      </if>
+      <if test="payStatus != null">
+        pay_status = #{payStatus,jdbcType=INTEGER},
+      </if>
+      <if test="status != null">
+        `status` = #{status,jdbcType=INTEGER},
+      </if>
+      <if test="createTime != null">
+        create_time = #{createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="wxOrderNo != null">
+        wx_order_no = #{wxOrderNo,jdbcType=VARCHAR},
+      </if>
+    </set>
+    where order_no = #{orderNo,jdbcType=VARCHAR}
+  </update>
+  <update id="updateByPrimaryKey" parameterType="com.kede.common.model.Order">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Tue Apr 13 14:51:40 CST 2021.
+    -->
+    update order
+    set project_id = #{projectId,jdbcType=INTEGER},
+      `uid` = #{uid,jdbcType=VARCHAR},
+      project_name = #{projectName,jdbcType=VARCHAR},
+      project_amount = #{projectAmount,jdbcType=DECIMAL},
+      pay_amount = #{payAmount,jdbcType=DECIMAL},
+      pay_status = #{payStatus,jdbcType=INTEGER},
+      `status` = #{status,jdbcType=INTEGER},
+      create_time = #{createTime,jdbcType=TIMESTAMP},
+      wx_order_no = #{wxOrderNo,jdbcType=VARCHAR}
+    where order_no = #{orderNo,jdbcType=VARCHAR}
+  </update>
+  <select id="selectOrderList" resultType="com.kede.common.bo.OutOrder">
+	select a.order_no orderNo,a.uid,b.nickname userName ,b.mobile,a.project_amount projectAmount,a.status,a.pay_status
+	payStatus, date_format(a.create_time,'%Y-%m-%d %H:%i:%S')createTimes
+	from `order` a left join user b on a.uid=b.id
+	where 1=1
+	<if test="name != null">
+	and b.nickname like concat('%',#{name},'%')
+	</if>
+	<if test="status != null">
+	and a.status= #{status}
+	</if>
+	<if test="startTime !=null and endTime != null">
+	and a.create_time between #{startTime} and #{endTime}
+	</if>
+	 <if test="page_sql != null">
+	${page_sql}
+	</if> 
+  </select>
+  <select id="selectOrderCount">
+  select count(*)
+	from `order` a left join user b on a.uid=b.id
+	where 1=1
+	<if test="name != null">
+	and b.nickname like concat('%',#{name},'%')
+	</if>
+	<if test="status != null">
+	and a.status= #{status}
+	</if>
+	<if test="startTime !=null and endTime != null">
+	and a.create_time between #{startTime} and #{endTime}
+	</if>
+  </select>
+  
+  <select id="chakeBuy" resultType="java.lang.Integer">
+  select pay_status from `order` o
+	where uid= #{uid} and project_id = #{pid}
+  </select>
+  
+  <update id="updateByOrderNo">
+  update `order`  set wx_order_no = #{orderNo} ,pay_status =1
+	where order_no = #{wxNo}
+  </update>
+</mapper>

+ 297 - 0
src/main/java/com/kede/common/mapper/ProjectMapper.xml

@@ -0,0 +1,297 @@
+<?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.kede.common.dao.ProjectMapper">
+  <resultMap id="BaseResultMap" type="com.kede.common.model.Project">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Mon Apr 12 17:24:38 CST 2021.
+    -->
+    <id column="id" jdbcType="INTEGER" property="id" />
+    <result column="name" jdbcType="VARCHAR" property="name" />
+    <result column="amount" jdbcType="DECIMAL" property="amount" />
+    <result column="thumbnail_url" jdbcType="VARCHAR" property="thumbnailUrl" />
+    <result column="status" jdbcType="INTEGER" property="status" />
+    <result column="sort" jdbcType="INTEGER" property="sort" />
+    <result column="release_status" jdbcType="INTEGER" property="releaseStatus" />
+    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
+    <result column="release_time" jdbcType="TIMESTAMP" property="releaseTime" />
+    <result column="host" jdbcType="INTEGER" property="host" />
+    <result column="type" jdbcType="INTEGER" property="type" />
+    <result column="commodity_url" jdbcType="VARCHAR" property="commodityUrl" />
+  </resultMap>
+  <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.kede.common.model.Project">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Mon Apr 12 17:24:38 CST 2021.
+    -->
+    <result column="content" jdbcType="LONGVARCHAR" property="content" />
+  </resultMap>
+  <sql id="Base_Column_List">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Mon Apr 12 17:24:38 CST 2021.
+    -->
+    id, `name`, amount, thumbnail_url, `status`, sort, release_status, create_time, release_time, 
+    `host`, `type`, commodity_url
+  </sql>
+  <sql id="Blob_Column_List">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Mon Apr 12 17:24:38 CST 2021.
+    -->
+    content
+  </sql>
+  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="ResultMapWithBLOBs">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Mon Apr 12 17:24:38 CST 2021.
+    -->
+    select 
+    <include refid="Base_Column_List" />
+    ,
+    <include refid="Blob_Column_List" />
+    from project
+    where id = #{id,jdbcType=INTEGER}
+  </select>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Mon Apr 12 17:24:38 CST 2021.
+    -->
+    delete from project
+    where id = #{id,jdbcType=INTEGER}
+  </delete>
+  <insert id="insert" parameterType="com.kede.common.model.Project">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Mon Apr 12 17:24:38 CST 2021.
+    -->
+    insert into project (id, `name`, amount, 
+      thumbnail_url, `status`, sort, 
+      release_status, create_time, release_time, 
+      `host`, `type`, commodity_url, 
+      content)
+    values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{amount,jdbcType=DECIMAL}, 
+      #{thumbnailUrl,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, #{sort,jdbcType=INTEGER}, 
+      #{releaseStatus,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{releaseTime,jdbcType=TIMESTAMP}, 
+      #{host,jdbcType=INTEGER}, #{type,jdbcType=INTEGER}, #{commodityUrl,jdbcType=VARCHAR}, 
+      #{content,jdbcType=LONGVARCHAR})
+  </insert>
+  <insert id="insertSelective" parameterType="com.kede.common.model.Project">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Mon Apr 12 17:24:38 CST 2021.
+    -->
+    insert into project
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        id,
+      </if>
+      <if test="name != null">
+        `name`,
+      </if>
+      <if test="amount != null">
+        amount,
+      </if>
+      <if test="thumbnailUrl != null">
+        thumbnail_url,
+      </if>
+      <if test="status != null">
+        `status`,
+      </if>
+      <if test="sort != null">
+        sort,
+      </if>
+      <if test="releaseStatus != null">
+        release_status,
+      </if>
+      <if test="createTime != null">
+        create_time,
+      </if>
+      <if test="releaseTime != null">
+        release_time,
+      </if>
+      <if test="host != null">
+        `host`,
+      </if>
+      <if test="type != null">
+        `type`,
+      </if>
+      <if test="commodityUrl != null">
+        commodity_url,
+      </if>
+      <if test="content != null">
+        content,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        #{id,jdbcType=INTEGER},
+      </if>
+      <if test="name != null">
+        #{name,jdbcType=VARCHAR},
+      </if>
+      <if test="amount != null">
+        #{amount,jdbcType=DECIMAL},
+      </if>
+      <if test="thumbnailUrl != null">
+        #{thumbnailUrl,jdbcType=VARCHAR},
+      </if>
+      <if test="status != null">
+        #{status,jdbcType=INTEGER},
+      </if>
+      <if test="sort != null">
+        #{sort,jdbcType=INTEGER},
+      </if>
+      <if test="releaseStatus != null">
+        #{releaseStatus,jdbcType=INTEGER},
+      </if>
+      <if test="createTime != null">
+        #{createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="releaseTime != null">
+        #{releaseTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="host != null">
+        #{host,jdbcType=INTEGER},
+      </if>
+      <if test="type != null">
+        #{type,jdbcType=INTEGER},
+      </if>
+      <if test="commodityUrl != null">
+        #{commodityUrl,jdbcType=VARCHAR},
+      </if>
+      <if test="content != null">
+        #{content,jdbcType=LONGVARCHAR},
+      </if>
+    </trim>
+  </insert>
+  <update id="updateByPrimaryKeySelective" parameterType="com.kede.common.model.Project">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Mon Apr 12 17:24:38 CST 2021.
+    -->
+    update project
+    <set>
+      <if test="name != null">
+        `name` = #{name,jdbcType=VARCHAR},
+      </if>
+      <if test="amount != null">
+        amount = #{amount,jdbcType=DECIMAL},
+      </if>
+      <if test="thumbnailUrl != null">
+        thumbnail_url = #{thumbnailUrl,jdbcType=VARCHAR},
+      </if>
+      <if test="status != null">
+        `status` = #{status,jdbcType=INTEGER},
+      </if>
+      <if test="sort != null">
+        sort = #{sort,jdbcType=INTEGER},
+      </if>
+      <if test="releaseStatus != null">
+        release_status = #{releaseStatus,jdbcType=INTEGER},
+      </if>
+      <if test="createTime != null">
+        create_time = #{createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="releaseTime != null">
+        release_time = #{releaseTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="host != null">
+        `host` = #{host,jdbcType=INTEGER},
+      </if>
+      <if test="type != null">
+        `type` = #{type,jdbcType=INTEGER},
+      </if>
+      <if test="commodityUrl != null">
+        commodity_url = #{commodityUrl,jdbcType=VARCHAR},
+      </if>
+      <if test="content != null">
+        content = #{content,jdbcType=LONGVARCHAR},
+      </if>
+    </set>
+    where id = #{id,jdbcType=INTEGER}
+  </update>
+  <update id="updateByPrimaryKeyWithBLOBs" parameterType="com.kede.common.model.Project">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Mon Apr 12 17:24:38 CST 2021.
+    -->
+    update project
+    set `name` = #{name,jdbcType=VARCHAR},
+      amount = #{amount,jdbcType=DECIMAL},
+      thumbnail_url = #{thumbnailUrl,jdbcType=VARCHAR},
+      `status` = #{status,jdbcType=INTEGER},
+      sort = #{sort,jdbcType=INTEGER},
+      release_status = #{releaseStatus,jdbcType=INTEGER},
+      create_time = #{createTime,jdbcType=TIMESTAMP},
+      release_time = #{releaseTime,jdbcType=TIMESTAMP},
+      `host` = #{host,jdbcType=INTEGER},
+      `type` = #{type,jdbcType=INTEGER},
+      commodity_url = #{commodityUrl,jdbcType=VARCHAR},
+      content = #{content,jdbcType=LONGVARCHAR}
+    where id = #{id,jdbcType=INTEGER}
+  </update>
+  <update id="updateByPrimaryKey" parameterType="com.kede.common.model.Project">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Mon Apr 12 17:24:38 CST 2021.
+    -->
+    update project
+    set `name` = #{name,jdbcType=VARCHAR},
+      amount = #{amount,jdbcType=DECIMAL},
+      thumbnail_url = #{thumbnailUrl,jdbcType=VARCHAR},
+      `status` = #{status,jdbcType=INTEGER},
+      sort = #{sort,jdbcType=INTEGER},
+      release_status = #{releaseStatus,jdbcType=INTEGER},
+      create_time = #{createTime,jdbcType=TIMESTAMP},
+      release_time = #{releaseTime,jdbcType=TIMESTAMP},
+      `host` = #{host,jdbcType=INTEGER},
+      `type` = #{type,jdbcType=INTEGER},
+      commodity_url = #{commodityUrl,jdbcType=VARCHAR}
+    where id = #{id,jdbcType=INTEGER}
+  </update>
+  <select id="selectProjectList" resultType="com.kede.common.model.projectBo">
+    select a.id,a.name,a.amount,a.thumbnail_url thumbnailUrl,a.status,a.sort,a.content,a.release_status releaseStatus,
+	  a.host,a.commodity_url commodityUrl ,b.name typeName,a.`type` ,
+	date_format(a.create_time,'%Y-%m-%d %H:%i:%S')createTimes, date_format(a.release_time,'%Y-%m-%d %H:%i:%S')releaseTimes 
+	from project a  left join project_type b on a.`type` =b.id where 1=1
+	<if test="name != null">
+	and a.name like concat('%',#{name},'%')
+	</if>
+	<if test="startTime != null and endTime !=null">
+	and a.create_time between #{startTime} and #{endTime}
+	</if>
+  	<if test="page_sql !=null">
+  	${page_sql}
+  	</if>
+  </select>
+  <select id="selectProjectCount" resultType="java.lang.Integer">
+  select count(*)
+	from project where 1=1
+	<if test="name != null">
+	and name like concat('%',#{name},'%')
+	</if>
+	<if test="startTime != null and endTime !=null">
+	and create_time between #{startTime} and #{endTime}
+	</if>
+  </select>
+    <select id="getProject" parameterType="java.lang.Integer" resultType="com.kede.common.model.projectBo">
+    select a.id,a.name,a.amount,a.thumbnail_url thumbnailUrl,a.status,a.sort,a.content,a.release_status releaseStatus,
+	  a.host,a.commodity_url commodityUrl ,b.name typeName,a.`type` ,
+	date_format(a.create_time,'%Y-%m-%d %H:%i:%S')createTimes, date_format(a.release_time,'%Y-%m-%d %H:%i:%S')releaseTimes 
+	from project a  left join project_type b on a.`type` =b.id where 1=1
+    and a.id = #{id,jdbcType=INTEGER}
+  </select>
+</mapper>

+ 132 - 0
src/main/java/com/kede/common/mapper/ProjectTypeMapper.xml

@@ -0,0 +1,132 @@
+<?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.kede.common.dao.ProjectTypeMapper">
+  <resultMap id="BaseResultMap" type="com.kede.common.model.ProjectType">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Mon Apr 12 16:06:33 CST 2021.
+    -->
+    <id column="id" jdbcType="INTEGER" property="id" />
+    <result column="name" jdbcType="VARCHAR" property="name" />
+    <result column="status" jdbcType="INTEGER" property="status" />
+    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
+  </resultMap>
+  <sql id="Base_Column_List">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Mon Apr 12 16:06:33 CST 2021.
+    -->
+    id, `name`, `status`, create_time
+  </sql>
+  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Mon Apr 12 16:06:33 CST 2021.
+    -->
+    select 
+    <include refid="Base_Column_List" />
+    from project_type
+    where id = #{id,jdbcType=INTEGER}
+  </select>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Mon Apr 12 16:06:33 CST 2021.
+    -->
+    delete from project_type
+    where id = #{id,jdbcType=INTEGER}
+  </delete>
+  <insert id="insert" parameterType="com.kede.common.model.ProjectType">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Mon Apr 12 16:06:33 CST 2021.
+    -->
+    insert into project_type (id, `name`, `status`, 
+      create_time)
+    values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, 
+      #{createTime,jdbcType=TIMESTAMP})
+  </insert>
+  <insert id="insertSelective" parameterType="com.kede.common.model.ProjectType">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Mon Apr 12 16:06:33 CST 2021.
+    -->
+    insert into project_type
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        id,
+      </if>
+      <if test="name != null">
+        `name`,
+      </if>
+      <if test="status != null">
+        `status`,
+      </if>
+      <if test="createTime != null">
+        create_time,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        #{id,jdbcType=INTEGER},
+      </if>
+      <if test="name != null">
+        #{name,jdbcType=VARCHAR},
+      </if>
+      <if test="status != null">
+        #{status,jdbcType=INTEGER},
+      </if>
+      <if test="createTime != null">
+        #{createTime,jdbcType=TIMESTAMP},
+      </if>
+    </trim>
+  </insert>
+  <update id="updateByPrimaryKeySelective" parameterType="com.kede.common.model.ProjectType">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Mon Apr 12 16:06:33 CST 2021.
+    -->
+    update project_type
+    <set>
+      <if test="name != null">
+        `name` = #{name,jdbcType=VARCHAR},
+      </if>
+      <if test="status != null">
+        `status` = #{status,jdbcType=INTEGER},
+      </if>
+      <if test="createTime != null">
+        create_time = #{createTime,jdbcType=TIMESTAMP},
+      </if>
+    </set>
+    where id = #{id,jdbcType=INTEGER}
+  </update>
+  <update id="updateByPrimaryKey" parameterType="com.kede.common.model.ProjectType">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Mon Apr 12 16:06:33 CST 2021.
+    -->
+    update project_type
+    set `name` = #{name,jdbcType=VARCHAR},
+      `status` = #{status,jdbcType=INTEGER},
+      create_time = #{createTime,jdbcType=TIMESTAMP}
+    where id = #{id,jdbcType=INTEGER}
+  </update>
+  
+  <select id="selectList" parameterType="java.lang.String" resultMap="BaseResultMap">
+    select 
+    <include refid="Base_Column_List" />
+    from project_type
+    <if test="name !=null">
+    where name = #{name,jdbcType=INTEGER}
+    </if>
+    
+    </select>
+</mapper>

+ 215 - 0
src/main/java/com/kede/common/mapper/UserMapper.xml

@@ -0,0 +1,215 @@
+<?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.kede.common.dao.UserMapper">
+  <resultMap id="BaseResultMap" type="com.kede.common.model.User">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Mon Apr 12 15:07:09 CST 2021.
+    -->
+    <id column="id" jdbcType="VARCHAR" property="id" />
+    <result column="open_id" jdbcType="VARCHAR" property="openId" />
+    <result column="union_id" jdbcType="VARCHAR" property="unionId" />
+    <result column="mobile" jdbcType="VARCHAR" property="mobile" />
+    <result column="password" jdbcType="VARCHAR" property="password" />
+    <result column="nickname" jdbcType="VARCHAR" property="nickname" />
+    <result column="email" jdbcType="VARCHAR" property="email" />
+    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
+    <result column="buy" jdbcType="INTEGER" property="buy" />
+    <result column="user_no" jdbcType="INTEGER" property="userNo" />
+  </resultMap>
+  <sql id="Base_Column_List">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Mon Apr 12 15:07:09 CST 2021.
+    -->
+    id, open_id, union_id, mobile, `password`, nickname, email, create_time, buy, user_no
+  </sql>
+  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Mon Apr 12 15:07:09 CST 2021.
+    -->
+    select 
+    <include refid="Base_Column_List" />
+    from user
+    where id = #{id,jdbcType=VARCHAR}
+  </select>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Mon Apr 12 15:07:09 CST 2021.
+    -->
+    delete from user
+    where id = #{id,jdbcType=VARCHAR}
+  </delete>
+  <insert id="insert" parameterType="com.kede.common.model.User">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Mon Apr 12 15:07:09 CST 2021.
+    -->
+    insert into user (id, open_id, union_id, 
+      mobile, `password`, nickname, 
+      email, create_time, buy, 
+      user_no)
+    values (#{id,jdbcType=VARCHAR}, #{openId,jdbcType=VARCHAR}, #{unionId,jdbcType=VARCHAR}, 
+      #{mobile,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, #{nickname,jdbcType=VARCHAR}, 
+      #{email,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{buy,jdbcType=INTEGER}, 
+      #{userNo,jdbcType=INTEGER})
+  </insert>
+  <insert id="insertSelective" parameterType="com.kede.common.model.User">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Mon Apr 12 15:07:09 CST 2021.
+    -->
+    insert into user
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        id,
+      </if>
+      <if test="openId != null">
+        open_id,
+      </if>
+      <if test="unionId != null">
+        union_id,
+      </if>
+      <if test="mobile != null">
+        mobile,
+      </if>
+      <if test="password != null">
+        `password`,
+      </if>
+      <if test="nickname != null">
+        nickname,
+      </if>
+      <if test="email != null">
+        email,
+      </if>
+      <if test="createTime != null">
+        create_time,
+      </if>
+      <if test="buy != null">
+        buy,
+      </if>
+      <if test="userNo != null">
+        user_no,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        #{id,jdbcType=VARCHAR},
+      </if>
+      <if test="openId != null">
+        #{openId,jdbcType=VARCHAR},
+      </if>
+      <if test="unionId != null">
+        #{unionId,jdbcType=VARCHAR},
+      </if>
+      <if test="mobile != null">
+        #{mobile,jdbcType=VARCHAR},
+      </if>
+      <if test="password != null">
+        #{password,jdbcType=VARCHAR},
+      </if>
+      <if test="nickname != null">
+        #{nickname,jdbcType=VARCHAR},
+      </if>
+      <if test="email != null">
+        #{email,jdbcType=VARCHAR},
+      </if>
+      <if test="createTime != null">
+        #{createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="buy != null">
+        #{buy,jdbcType=INTEGER},
+      </if>
+      <if test="userNo != null">
+        #{userNo,jdbcType=INTEGER},
+      </if>
+    </trim>
+  </insert>
+  <update id="updateByPrimaryKeySelective" parameterType="com.kede.common.model.User">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Mon Apr 12 15:07:09 CST 2021.
+    -->
+    update user
+    <set>
+      <if test="openId != null">
+        open_id = #{openId,jdbcType=VARCHAR},
+      </if>
+      <if test="unionId != null">
+        union_id = #{unionId,jdbcType=VARCHAR},
+      </if>
+      <if test="mobile != null">
+        mobile = #{mobile,jdbcType=VARCHAR},
+      </if>
+      <if test="password != null">
+        `password` = #{password,jdbcType=VARCHAR},
+      </if>
+      <if test="nickname != null">
+        nickname = #{nickname,jdbcType=VARCHAR},
+      </if>
+      <if test="email != null">
+        email = #{email,jdbcType=VARCHAR},
+      </if>
+      <if test="createTime != null">
+        create_time = #{createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="buy != null">
+        buy = #{buy,jdbcType=INTEGER},
+      </if>
+      <if test="userNo != null">
+        user_no = #{userNo,jdbcType=INTEGER},
+      </if>
+    </set>
+    where id = #{id,jdbcType=VARCHAR}
+  </update>
+  <update id="updateByPrimaryKey" parameterType="com.kede.common.model.User">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Mon Apr 12 15:07:09 CST 2021.
+    -->
+    update user
+    set open_id = #{openId,jdbcType=VARCHAR},
+      union_id = #{unionId,jdbcType=VARCHAR},
+      mobile = #{mobile,jdbcType=VARCHAR},
+      `password` = #{password,jdbcType=VARCHAR},
+      nickname = #{nickname,jdbcType=VARCHAR},
+      email = #{email,jdbcType=VARCHAR},
+      create_time = #{createTime,jdbcType=TIMESTAMP},
+      buy = #{buy,jdbcType=INTEGER},
+      user_no = #{userNo,jdbcType=INTEGER}
+    where id = #{id,jdbcType=VARCHAR}
+  </update>
+    <select id="selectByOpenId" parameterType="java.lang.String" resultMap="BaseResultMap">
+    select 
+    <include refid="Base_Column_List" />
+    from user
+    where open_id = #{openId,jdbcType=VARCHAR}
+  </select>
+  <select id="selectUserList" resultType="com.kede.user.bo.UserBo">
+  select id,mobile ,nickname ,date_format(create_time,'%Y-%m-%d %H:%i:%S')createTimes,buy,user_no userNo 
+    from user where 1=1
+	<if test="name !=null">
+	and nickname like concat('%',#{name},'%')
+	</if>
+	<if test="page_sql != null">
+	${page_sql}
+	</if> 
+  </select>
+  <select id="selectUserCount" resultType="java.lang.Integer">
+  select count(*) 
+   from user where 1=1
+	<if test="name !=null">
+	and nickname like concat('%',#{name},'%')
+	</if>
+	</select>
+</mapper>

+ 269 - 0
src/main/java/com/kede/common/model/Order.java

@@ -0,0 +1,269 @@
+package com.kede.common.model;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.math.BigDecimal;
+
+public class Order implements Serializable {
+
+	/**
+	 * This field was generated by MyBatis Generator. This field corresponds to the database column order.order_no
+	 * @mbg.generated  Tue Apr 13 14:51:40 CST 2021
+	 */
+	private String orderNo;
+	/**
+	 * This field was generated by MyBatis Generator. This field corresponds to the database column order.project_id
+	 * @mbg.generated  Tue Apr 13 14:51:40 CST 2021
+	 */
+	private Integer projectId;
+	/**
+	 * This field was generated by MyBatis Generator. This field corresponds to the database column order.uid
+	 * @mbg.generated  Tue Apr 13 14:51:40 CST 2021
+	 */
+	private String uid;
+	/**
+	 * This field was generated by MyBatis Generator. This field corresponds to the database column order.project_name
+	 * @mbg.generated  Tue Apr 13 14:51:40 CST 2021
+	 */
+	private String projectName;
+	/**
+	 * This field was generated by MyBatis Generator. This field corresponds to the database column order.project_amount
+	 * @mbg.generated  Tue Apr 13 14:51:40 CST 2021
+	 */
+	private BigDecimal projectAmount;
+	/**
+	 * This field was generated by MyBatis Generator. This field corresponds to the database column order.pay_amount
+	 * @mbg.generated  Tue Apr 13 14:51:40 CST 2021
+	 */
+	private BigDecimal payAmount;
+	/**
+	 * This field was generated by MyBatis Generator. This field corresponds to the database column order.pay_status
+	 * @mbg.generated  Tue Apr 13 14:51:40 CST 2021
+	 */
+	private Integer payStatus;
+	/**
+	 * This field was generated by MyBatis Generator. This field corresponds to the database column order.status
+	 * @mbg.generated  Tue Apr 13 14:51:40 CST 2021
+	 */
+	private Integer status;
+	/**
+	 * This field was generated by MyBatis Generator. This field corresponds to the database column order.create_time
+	 * @mbg.generated  Tue Apr 13 14:51:40 CST 2021
+	 */
+	private Date createTime;
+	/**
+	 * This field was generated by MyBatis Generator. This field corresponds to the database column order.wx_order_no
+	 * @mbg.generated  Tue Apr 13 14:51:40 CST 2021
+	 */
+	private String wxOrderNo;
+	/**
+	 * This field was generated by MyBatis Generator. This field corresponds to the database table order
+	 * @mbg.generated  Tue Apr 13 14:51:40 CST 2021
+	 */
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * This method was generated by MyBatis Generator. This method returns the value of the database column order.order_no
+	 * @return  the value of order.order_no
+	 * @mbg.generated  Tue Apr 13 14:51:40 CST 2021
+	 */
+	public String getOrderNo() {
+		return orderNo;
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method sets the value of the database column order.order_no
+	 * @param orderNo  the value for order.order_no
+	 * @mbg.generated  Tue Apr 13 14:51:40 CST 2021
+	 */
+	public void setOrderNo(String orderNo) {
+		this.orderNo = orderNo == null ? null : orderNo.trim();
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method returns the value of the database column order.project_id
+	 * @return  the value of order.project_id
+	 * @mbg.generated  Tue Apr 13 14:51:40 CST 2021
+	 */
+	public Integer getProjectId() {
+		return projectId;
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method sets the value of the database column order.project_id
+	 * @param projectId  the value for order.project_id
+	 * @mbg.generated  Tue Apr 13 14:51:40 CST 2021
+	 */
+	public void setProjectId(Integer projectId) {
+		this.projectId = projectId;
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method returns the value of the database column order.uid
+	 * @return  the value of order.uid
+	 * @mbg.generated  Tue Apr 13 14:51:40 CST 2021
+	 */
+	public String getUid() {
+		return uid;
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method sets the value of the database column order.uid
+	 * @param uid  the value for order.uid
+	 * @mbg.generated  Tue Apr 13 14:51:40 CST 2021
+	 */
+	public void setUid(String uid) {
+		this.uid = uid == null ? null : uid.trim();
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method returns the value of the database column order.project_name
+	 * @return  the value of order.project_name
+	 * @mbg.generated  Tue Apr 13 14:51:40 CST 2021
+	 */
+	public String getProjectName() {
+		return projectName;
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method sets the value of the database column order.project_name
+	 * @param projectName  the value for order.project_name
+	 * @mbg.generated  Tue Apr 13 14:51:40 CST 2021
+	 */
+	public void setProjectName(String projectName) {
+		this.projectName = projectName == null ? null : projectName.trim();
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method returns the value of the database column order.project_amount
+	 * @return  the value of order.project_amount
+	 * @mbg.generated  Tue Apr 13 14:51:40 CST 2021
+	 */
+	public BigDecimal getProjectAmount() {
+		return projectAmount;
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method sets the value of the database column order.project_amount
+	 * @param projectAmount  the value for order.project_amount
+	 * @mbg.generated  Tue Apr 13 14:51:40 CST 2021
+	 */
+	public void setProjectAmount(BigDecimal projectAmount) {
+		this.projectAmount = projectAmount;
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method returns the value of the database column order.pay_amount
+	 * @return  the value of order.pay_amount
+	 * @mbg.generated  Tue Apr 13 14:51:40 CST 2021
+	 */
+	public BigDecimal getPayAmount() {
+		return payAmount;
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method sets the value of the database column order.pay_amount
+	 * @param payAmount  the value for order.pay_amount
+	 * @mbg.generated  Tue Apr 13 14:51:40 CST 2021
+	 */
+	public void setPayAmount(BigDecimal payAmount) {
+		this.payAmount = payAmount;
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method returns the value of the database column order.pay_status
+	 * @return  the value of order.pay_status
+	 * @mbg.generated  Tue Apr 13 14:51:40 CST 2021
+	 */
+	public Integer getPayStatus() {
+		return payStatus;
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method sets the value of the database column order.pay_status
+	 * @param payStatus  the value for order.pay_status
+	 * @mbg.generated  Tue Apr 13 14:51:40 CST 2021
+	 */
+	public void setPayStatus(Integer payStatus) {
+		this.payStatus = payStatus;
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method returns the value of the database column order.status
+	 * @return  the value of order.status
+	 * @mbg.generated  Tue Apr 13 14:51:40 CST 2021
+	 */
+	public Integer getStatus() {
+		return status;
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method sets the value of the database column order.status
+	 * @param status  the value for order.status
+	 * @mbg.generated  Tue Apr 13 14:51:40 CST 2021
+	 */
+	public void setStatus(Integer status) {
+		this.status = status;
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method returns the value of the database column order.create_time
+	 * @return  the value of order.create_time
+	 * @mbg.generated  Tue Apr 13 14:51:40 CST 2021
+	 */
+	public Date getCreateTime() {
+		return createTime;
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method sets the value of the database column order.create_time
+	 * @param createTime  the value for order.create_time
+	 * @mbg.generated  Tue Apr 13 14:51:40 CST 2021
+	 */
+	public void setCreateTime(Date createTime) {
+		this.createTime = createTime;
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method returns the value of the database column order.wx_order_no
+	 * @return  the value of order.wx_order_no
+	 * @mbg.generated  Tue Apr 13 14:51:40 CST 2021
+	 */
+	public String getWxOrderNo() {
+		return wxOrderNo;
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method sets the value of the database column order.wx_order_no
+	 * @param wxOrderNo  the value for order.wx_order_no
+	 * @mbg.generated  Tue Apr 13 14:51:40 CST 2021
+	 */
+	public void setWxOrderNo(String wxOrderNo) {
+		this.wxOrderNo = wxOrderNo == null ? null : wxOrderNo.trim();
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method corresponds to the database table order
+	 * @mbg.generated  Tue Apr 13 14:51:40 CST 2021
+	 */
+	@Override
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		sb.append(getClass().getSimpleName());
+		sb.append(" [");
+		sb.append("Hash = ").append(hashCode());
+		sb.append(", orderNo=").append(orderNo);
+		sb.append(", projectId=").append(projectId);
+		sb.append(", uid=").append(uid);
+		sb.append(", projectName=").append(projectName);
+		sb.append(", projectAmount=").append(projectAmount);
+		sb.append(", payAmount=").append(payAmount);
+		sb.append(", payStatus=").append(payStatus);
+		sb.append(", status=").append(status);
+		sb.append(", createTime=").append(createTime);
+		sb.append(", wxOrderNo=").append(wxOrderNo);
+		sb.append(", serialVersionUID=").append(serialVersionUID);
+		sb.append("]");
+		return sb.toString();
+	}
+}

+ 341 - 0
src/main/java/com/kede/common/model/Project.java

@@ -0,0 +1,341 @@
+package com.kede.common.model;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.math.BigDecimal;
+
+public class Project implements Serializable {
+
+	/**
+	 * This field was generated by MyBatis Generator. This field corresponds to the database column project.id
+	 * @mbg.generated  Mon Apr 12 17:24:38 CST 2021
+	 */
+	private Integer id;
+	/**
+	 * This field was generated by MyBatis Generator. This field corresponds to the database column project.name
+	 * @mbg.generated  Mon Apr 12 17:24:38 CST 2021
+	 */
+	private String name;
+	/**
+	 * This field was generated by MyBatis Generator. This field corresponds to the database column project.amount
+	 * @mbg.generated  Mon Apr 12 17:24:38 CST 2021
+	 */
+	private BigDecimal amount;
+	/**
+	 * This field was generated by MyBatis Generator. This field corresponds to the database column project.thumbnail_url
+	 * @mbg.generated  Mon Apr 12 17:24:38 CST 2021
+	 */
+	private String thumbnailUrl;
+	/**
+	 * This field was generated by MyBatis Generator. This field corresponds to the database column project.status
+	 * @mbg.generated  Mon Apr 12 17:24:38 CST 2021
+	 */
+	private Integer status;
+	/**
+	 * This field was generated by MyBatis Generator. This field corresponds to the database column project.sort
+	 * @mbg.generated  Mon Apr 12 17:24:38 CST 2021
+	 */
+	private Integer sort;
+	/**
+	 * This field was generated by MyBatis Generator. This field corresponds to the database column project.release_status
+	 * @mbg.generated  Mon Apr 12 17:24:38 CST 2021
+	 */
+	private Integer releaseStatus;
+	/**
+	 * This field was generated by MyBatis Generator. This field corresponds to the database column project.create_time
+	 * @mbg.generated  Mon Apr 12 17:24:38 CST 2021
+	 */
+	private Date createTime;
+	/**
+	 * This field was generated by MyBatis Generator. This field corresponds to the database column project.release_time
+	 * @mbg.generated  Mon Apr 12 17:24:38 CST 2021
+	 */
+	private Date releaseTime;
+	/**
+	 * This field was generated by MyBatis Generator. This field corresponds to the database column project.host
+	 * @mbg.generated  Mon Apr 12 17:24:38 CST 2021
+	 */
+	private Integer host;
+	/**
+	 * This field was generated by MyBatis Generator. This field corresponds to the database column project.type
+	 * @mbg.generated  Mon Apr 12 17:24:38 CST 2021
+	 */
+	private Integer type;
+	/**
+	 * This field was generated by MyBatis Generator. This field corresponds to the database column project.commodity_url
+	 * @mbg.generated  Mon Apr 12 17:24:38 CST 2021
+	 */
+	private String commodityUrl;
+	/**
+	 * This field was generated by MyBatis Generator. This field corresponds to the database column project.content
+	 * @mbg.generated  Mon Apr 12 17:24:38 CST 2021
+	 */
+	private String content;
+	/**
+	 * This field was generated by MyBatis Generator. This field corresponds to the database table project
+	 * @mbg.generated  Mon Apr 12 17:24:38 CST 2021
+	 */
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * This method was generated by MyBatis Generator. This method returns the value of the database column project.id
+	 * @return  the value of project.id
+	 * @mbg.generated  Mon Apr 12 17:24:38 CST 2021
+	 */
+	public Integer getId() {
+		return id;
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method sets the value of the database column project.id
+	 * @param id  the value for project.id
+	 * @mbg.generated  Mon Apr 12 17:24:38 CST 2021
+	 */
+	public void setId(Integer id) {
+		this.id = id;
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method returns the value of the database column project.name
+	 * @return  the value of project.name
+	 * @mbg.generated  Mon Apr 12 17:24:38 CST 2021
+	 */
+	public String getName() {
+		return name;
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method sets the value of the database column project.name
+	 * @param name  the value for project.name
+	 * @mbg.generated  Mon Apr 12 17:24:38 CST 2021
+	 */
+	public void setName(String name) {
+		this.name = name == null ? null : name.trim();
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method returns the value of the database column project.amount
+	 * @return  the value of project.amount
+	 * @mbg.generated  Mon Apr 12 17:24:38 CST 2021
+	 */
+	public BigDecimal getAmount() {
+		return amount;
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method sets the value of the database column project.amount
+	 * @param amount  the value for project.amount
+	 * @mbg.generated  Mon Apr 12 17:24:38 CST 2021
+	 */
+	public void setAmount(BigDecimal amount) {
+		this.amount = amount;
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method returns the value of the database column project.thumbnail_url
+	 * @return  the value of project.thumbnail_url
+	 * @mbg.generated  Mon Apr 12 17:24:38 CST 2021
+	 */
+	public String getThumbnailUrl() {
+		return thumbnailUrl;
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method sets the value of the database column project.thumbnail_url
+	 * @param thumbnailUrl  the value for project.thumbnail_url
+	 * @mbg.generated  Mon Apr 12 17:24:38 CST 2021
+	 */
+	public void setThumbnailUrl(String thumbnailUrl) {
+		this.thumbnailUrl = thumbnailUrl == null ? null : thumbnailUrl.trim();
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method returns the value of the database column project.status
+	 * @return  the value of project.status
+	 * @mbg.generated  Mon Apr 12 17:24:38 CST 2021
+	 */
+	public Integer getStatus() {
+		return status;
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method sets the value of the database column project.status
+	 * @param status  the value for project.status
+	 * @mbg.generated  Mon Apr 12 17:24:38 CST 2021
+	 */
+	public void setStatus(Integer status) {
+		this.status = status;
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method returns the value of the database column project.sort
+	 * @return  the value of project.sort
+	 * @mbg.generated  Mon Apr 12 17:24:38 CST 2021
+	 */
+	public Integer getSort() {
+		return sort;
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method sets the value of the database column project.sort
+	 * @param sort  the value for project.sort
+	 * @mbg.generated  Mon Apr 12 17:24:38 CST 2021
+	 */
+	public void setSort(Integer sort) {
+		this.sort = sort;
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method returns the value of the database column project.release_status
+	 * @return  the value of project.release_status
+	 * @mbg.generated  Mon Apr 12 17:24:38 CST 2021
+	 */
+	public Integer getReleaseStatus() {
+		return releaseStatus;
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method sets the value of the database column project.release_status
+	 * @param releaseStatus  the value for project.release_status
+	 * @mbg.generated  Mon Apr 12 17:24:38 CST 2021
+	 */
+	public void setReleaseStatus(Integer releaseStatus) {
+		this.releaseStatus = releaseStatus;
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method returns the value of the database column project.create_time
+	 * @return  the value of project.create_time
+	 * @mbg.generated  Mon Apr 12 17:24:38 CST 2021
+	 */
+	public Date getCreateTime() {
+		return createTime;
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method sets the value of the database column project.create_time
+	 * @param createTime  the value for project.create_time
+	 * @mbg.generated  Mon Apr 12 17:24:38 CST 2021
+	 */
+	public void setCreateTime(Date createTime) {
+		this.createTime = createTime;
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method returns the value of the database column project.release_time
+	 * @return  the value of project.release_time
+	 * @mbg.generated  Mon Apr 12 17:24:38 CST 2021
+	 */
+	public Date getReleaseTime() {
+		return releaseTime;
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method sets the value of the database column project.release_time
+	 * @param releaseTime  the value for project.release_time
+	 * @mbg.generated  Mon Apr 12 17:24:38 CST 2021
+	 */
+	public void setReleaseTime(Date releaseTime) {
+		this.releaseTime = releaseTime;
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method returns the value of the database column project.host
+	 * @return  the value of project.host
+	 * @mbg.generated  Mon Apr 12 17:24:38 CST 2021
+	 */
+	public Integer getHost() {
+		return host;
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method sets the value of the database column project.host
+	 * @param host  the value for project.host
+	 * @mbg.generated  Mon Apr 12 17:24:38 CST 2021
+	 */
+	public void setHost(Integer host) {
+		this.host = host;
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method returns the value of the database column project.type
+	 * @return  the value of project.type
+	 * @mbg.generated  Mon Apr 12 17:24:38 CST 2021
+	 */
+	public Integer getType() {
+		return type;
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method sets the value of the database column project.type
+	 * @param type  the value for project.type
+	 * @mbg.generated  Mon Apr 12 17:24:38 CST 2021
+	 */
+	public void setType(Integer type) {
+		this.type = type;
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method returns the value of the database column project.commodity_url
+	 * @return  the value of project.commodity_url
+	 * @mbg.generated  Mon Apr 12 17:24:38 CST 2021
+	 */
+	public String getCommodityUrl() {
+		return commodityUrl;
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method sets the value of the database column project.commodity_url
+	 * @param commodityUrl  the value for project.commodity_url
+	 * @mbg.generated  Mon Apr 12 17:24:38 CST 2021
+	 */
+	public void setCommodityUrl(String commodityUrl) {
+		this.commodityUrl = commodityUrl == null ? null : commodityUrl.trim();
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method returns the value of the database column project.content
+	 * @return  the value of project.content
+	 * @mbg.generated  Mon Apr 12 17:24:38 CST 2021
+	 */
+	public String getContent() {
+		return content;
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method sets the value of the database column project.content
+	 * @param content  the value for project.content
+	 * @mbg.generated  Mon Apr 12 17:24:38 CST 2021
+	 */
+	public void setContent(String content) {
+		this.content = content == null ? null : content.trim();
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method corresponds to the database table project
+	 * @mbg.generated  Mon Apr 12 17:24:38 CST 2021
+	 */
+	@Override
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		sb.append(getClass().getSimpleName());
+		sb.append(" [");
+		sb.append("Hash = ").append(hashCode());
+		sb.append(", id=").append(id);
+		sb.append(", name=").append(name);
+		sb.append(", amount=").append(amount);
+		sb.append(", thumbnailUrl=").append(thumbnailUrl);
+		sb.append(", status=").append(status);
+		sb.append(", sort=").append(sort);
+		sb.append(", releaseStatus=").append(releaseStatus);
+		sb.append(", createTime=").append(createTime);
+		sb.append(", releaseTime=").append(releaseTime);
+		sb.append(", host=").append(host);
+		sb.append(", type=").append(type);
+		sb.append(", commodityUrl=").append(commodityUrl);
+		sb.append(", content=").append(content);
+		sb.append(", serialVersionUID=").append(serialVersionUID);
+		sb.append("]");
+		return sb.toString();
+	}
+}

+ 167 - 0
src/main/java/com/kede/common/model/ProjectType.java

@@ -0,0 +1,167 @@
+package com.kede.common.model;
+
+import java.io.Serializable;
+import java.util.Date;
+
+public class ProjectType implements Serializable {
+    /**
+     *
+     * This field was generated by MyBatis Generator.
+     * This field corresponds to the database column project_type.id
+     *
+     * @mbg.generated Mon Apr 12 16:06:33 CST 2021
+     */
+    private Integer id;
+
+    /**
+     *
+     * This field was generated by MyBatis Generator.
+     * This field corresponds to the database column project_type.name
+     *
+     * @mbg.generated Mon Apr 12 16:06:33 CST 2021
+     */
+    private String name;
+
+    /**
+     *
+     * This field was generated by MyBatis Generator.
+     * This field corresponds to the database column project_type.status
+     *
+     * @mbg.generated Mon Apr 12 16:06:33 CST 2021
+     */
+    private Integer status;
+
+    /**
+     *
+     * This field was generated by MyBatis Generator.
+     * This field corresponds to the database column project_type.create_time
+     *
+     * @mbg.generated Mon Apr 12 16:06:33 CST 2021
+     */
+    private Date createTime;
+
+    /**
+     * This field was generated by MyBatis Generator.
+     * This field corresponds to the database table project_type
+     *
+     * @mbg.generated Mon Apr 12 16:06:33 CST 2021
+     */
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method returns the value of the database column project_type.id
+     *
+     * @return the value of project_type.id
+     *
+     * @mbg.generated Mon Apr 12 16:06:33 CST 2021
+     */
+    public Integer getId() {
+        return id;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method sets the value of the database column project_type.id
+     *
+     * @param id the value for project_type.id
+     *
+     * @mbg.generated Mon Apr 12 16:06:33 CST 2021
+     */
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method returns the value of the database column project_type.name
+     *
+     * @return the value of project_type.name
+     *
+     * @mbg.generated Mon Apr 12 16:06:33 CST 2021
+     */
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method sets the value of the database column project_type.name
+     *
+     * @param name the value for project_type.name
+     *
+     * @mbg.generated Mon Apr 12 16:06:33 CST 2021
+     */
+    public void setName(String name) {
+        this.name = name == null ? null : name.trim();
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method returns the value of the database column project_type.status
+     *
+     * @return the value of project_type.status
+     *
+     * @mbg.generated Mon Apr 12 16:06:33 CST 2021
+     */
+    public Integer getStatus() {
+        return status;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method sets the value of the database column project_type.status
+     *
+     * @param status the value for project_type.status
+     *
+     * @mbg.generated Mon Apr 12 16:06:33 CST 2021
+     */
+    public void setStatus(Integer status) {
+        this.status = status;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method returns the value of the database column project_type.create_time
+     *
+     * @return the value of project_type.create_time
+     *
+     * @mbg.generated Mon Apr 12 16:06:33 CST 2021
+     */
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method sets the value of the database column project_type.create_time
+     *
+     * @param createTime the value for project_type.create_time
+     *
+     * @mbg.generated Mon Apr 12 16:06:33 CST 2021
+     */
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table project_type
+     *
+     * @mbg.generated Mon Apr 12 16:06:33 CST 2021
+     */
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append(getClass().getSimpleName());
+        sb.append(" [");
+        sb.append("Hash = ").append(hashCode());
+        sb.append(", id=").append(id);
+        sb.append(", name=").append(name);
+        sb.append(", status=").append(status);
+        sb.append(", createTime=").append(createTime);
+        sb.append(", serialVersionUID=").append(serialVersionUID);
+        sb.append("]");
+        return sb.toString();
+    }
+}

+ 268 - 0
src/main/java/com/kede/common/model/User.java

@@ -0,0 +1,268 @@
+package com.kede.common.model;
+
+import java.util.Date;
+import java.io.Serializable;
+
+public class User implements OwUser, Serializable {
+
+	/**
+	 * This field was generated by MyBatis Generator. This field corresponds to the database column user.id
+	 * @mbg.generated  Mon Apr 12 15:07:09 CST 2021
+	 */
+	private String id;
+	/**
+	 * This field was generated by MyBatis Generator. This field corresponds to the database column user.open_id
+	 * @mbg.generated  Mon Apr 12 15:07:09 CST 2021
+	 */
+	private String openId;
+	/**
+	 * This field was generated by MyBatis Generator. This field corresponds to the database column user.union_id
+	 * @mbg.generated  Mon Apr 12 15:07:09 CST 2021
+	 */
+	private String unionId;
+	/**
+	 * This field was generated by MyBatis Generator. This field corresponds to the database column user.mobile
+	 * @mbg.generated  Mon Apr 12 15:07:09 CST 2021
+	 */
+	private String mobile;
+	/**
+	 * This field was generated by MyBatis Generator. This field corresponds to the database column user.password
+	 * @mbg.generated  Mon Apr 12 15:07:09 CST 2021
+	 */
+	private String password;
+	/**
+	 * This field was generated by MyBatis Generator. This field corresponds to the database column user.nickname
+	 * @mbg.generated  Mon Apr 12 15:07:09 CST 2021
+	 */
+	private String nickname;
+	/**
+	 * This field was generated by MyBatis Generator. This field corresponds to the database column user.email
+	 * @mbg.generated  Mon Apr 12 15:07:09 CST 2021
+	 */
+	private String email;
+	/**
+	 * This field was generated by MyBatis Generator. This field corresponds to the database column user.create_time
+	 * @mbg.generated  Mon Apr 12 15:07:09 CST 2021
+	 */
+	private Date createTime;
+	/**
+	 * This field was generated by MyBatis Generator. This field corresponds to the database column user.buy
+	 * @mbg.generated  Mon Apr 12 15:07:09 CST 2021
+	 */
+	private Integer buy;
+	/**
+	 * This field was generated by MyBatis Generator. This field corresponds to the database column user.user_no
+	 * @mbg.generated  Mon Apr 12 15:07:09 CST 2021
+	 */
+	private Integer userNo;
+	/**
+	 * This field was generated by MyBatis Generator. This field corresponds to the database table user
+	 * @mbg.generated  Mon Apr 12 15:07:09 CST 2021
+	 */
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * This method was generated by MyBatis Generator. This method returns the value of the database column user.id
+	 * @return  the value of user.id
+	 * @mbg.generated  Mon Apr 12 15:07:09 CST 2021
+	 */
+	public String getId() {
+		return id;
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method sets the value of the database column user.id
+	 * @param id  the value for user.id
+	 * @mbg.generated  Mon Apr 12 15:07:09 CST 2021
+	 */
+	public void setId(String id) {
+		this.id = id == null ? null : id.trim();
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method returns the value of the database column user.open_id
+	 * @return  the value of user.open_id
+	 * @mbg.generated  Mon Apr 12 15:07:09 CST 2021
+	 */
+	public String getOpenId() {
+		return openId;
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method sets the value of the database column user.open_id
+	 * @param openId  the value for user.open_id
+	 * @mbg.generated  Mon Apr 12 15:07:09 CST 2021
+	 */
+	public void setOpenId(String openId) {
+		this.openId = openId == null ? null : openId.trim();
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method returns the value of the database column user.union_id
+	 * @return  the value of user.union_id
+	 * @mbg.generated  Mon Apr 12 15:07:09 CST 2021
+	 */
+	public String getUnionId() {
+		return unionId;
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method sets the value of the database column user.union_id
+	 * @param unionId  the value for user.union_id
+	 * @mbg.generated  Mon Apr 12 15:07:09 CST 2021
+	 */
+	public void setUnionId(String unionId) {
+		this.unionId = unionId == null ? null : unionId.trim();
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method returns the value of the database column user.mobile
+	 * @return  the value of user.mobile
+	 * @mbg.generated  Mon Apr 12 15:07:09 CST 2021
+	 */
+	public String getMobile() {
+		return mobile;
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method sets the value of the database column user.mobile
+	 * @param mobile  the value for user.mobile
+	 * @mbg.generated  Mon Apr 12 15:07:09 CST 2021
+	 */
+	public void setMobile(String mobile) {
+		this.mobile = mobile == null ? null : mobile.trim();
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method returns the value of the database column user.password
+	 * @return  the value of user.password
+	 * @mbg.generated  Mon Apr 12 15:07:09 CST 2021
+	 */
+	public String getPassword() {
+		return password;
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method sets the value of the database column user.password
+	 * @param password  the value for user.password
+	 * @mbg.generated  Mon Apr 12 15:07:09 CST 2021
+	 */
+	public void setPassword(String password) {
+		this.password = password == null ? null : password.trim();
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method returns the value of the database column user.nickname
+	 * @return  the value of user.nickname
+	 * @mbg.generated  Mon Apr 12 15:07:09 CST 2021
+	 */
+	public String getNickname() {
+		return nickname;
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method sets the value of the database column user.nickname
+	 * @param nickname  the value for user.nickname
+	 * @mbg.generated  Mon Apr 12 15:07:09 CST 2021
+	 */
+	public void setNickname(String nickname) {
+		this.nickname = nickname == null ? null : nickname.trim();
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method returns the value of the database column user.email
+	 * @return  the value of user.email
+	 * @mbg.generated  Mon Apr 12 15:07:09 CST 2021
+	 */
+	public String getEmail() {
+		return email;
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method sets the value of the database column user.email
+	 * @param email  the value for user.email
+	 * @mbg.generated  Mon Apr 12 15:07:09 CST 2021
+	 */
+	public void setEmail(String email) {
+		this.email = email == null ? null : email.trim();
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method returns the value of the database column user.create_time
+	 * @return  the value of user.create_time
+	 * @mbg.generated  Mon Apr 12 15:07:09 CST 2021
+	 */
+	public Date getCreateTime() {
+		return createTime;
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method sets the value of the database column user.create_time
+	 * @param createTime  the value for user.create_time
+	 * @mbg.generated  Mon Apr 12 15:07:09 CST 2021
+	 */
+	public void setCreateTime(Date createTime) {
+		this.createTime = createTime;
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method returns the value of the database column user.buy
+	 * @return  the value of user.buy
+	 * @mbg.generated  Mon Apr 12 15:07:09 CST 2021
+	 */
+	public Integer getBuy() {
+		return buy;
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method sets the value of the database column user.buy
+	 * @param buy  the value for user.buy
+	 * @mbg.generated  Mon Apr 12 15:07:09 CST 2021
+	 */
+	public void setBuy(Integer buy) {
+		this.buy = buy;
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method returns the value of the database column user.user_no
+	 * @return  the value of user.user_no
+	 * @mbg.generated  Mon Apr 12 15:07:09 CST 2021
+	 */
+	public Integer getUserNo() {
+		return userNo;
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method sets the value of the database column user.user_no
+	 * @param userNo  the value for user.user_no
+	 * @mbg.generated  Mon Apr 12 15:07:09 CST 2021
+	 */
+	public void setUserNo(Integer userNo) {
+		this.userNo = userNo;
+	}
+
+	/**
+	 * This method was generated by MyBatis Generator. This method corresponds to the database table user
+	 * @mbg.generated  Mon Apr 12 15:07:09 CST 2021
+	 */
+	@Override
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		sb.append(getClass().getSimpleName());
+		sb.append(" [");
+		sb.append("Hash = ").append(hashCode());
+		sb.append(", id=").append(id);
+		sb.append(", openId=").append(openId);
+		sb.append(", unionId=").append(unionId);
+		sb.append(", mobile=").append(mobile);
+		sb.append(", password=").append(password);
+		sb.append(", nickname=").append(nickname);
+		sb.append(", email=").append(email);
+		sb.append(", createTime=").append(createTime);
+		sb.append(", buy=").append(buy);
+		sb.append(", userNo=").append(userNo);
+		sb.append(", serialVersionUID=").append(serialVersionUID);
+		sb.append("]");
+		return sb.toString();
+	}
+}

+ 52 - 0
src/main/java/com/kede/common/model/projectBo.java

@@ -0,0 +1,52 @@
+package com.kede.common.model;
+
+
+public class projectBo extends Project{
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
+	
+	private String createTimes;
+	
+	private String releaseTimes;
+	private String typeName;
+	
+	private Integer buy;
+
+	public String getCreateTimes() {
+		return createTimes;
+	}
+
+	public void setCreateTimes(String createTimes) {
+		this.createTimes = createTimes;
+	}
+
+	public String getReleaseTimes() {
+		return releaseTimes;
+	}
+
+	public void setReleaseTimes(String releaseTimes) {
+		this.releaseTimes = releaseTimes;
+	}
+
+	public String getTypeName() {
+		return typeName;
+	}
+
+	public void setTypeName(String typeName) {
+		this.typeName = typeName;
+	}
+
+	public Integer getBuy() {
+		return buy;
+	}
+
+	public void setBuy(Integer buy) {
+		this.buy = buy;
+	}
+
+	
+
+}

+ 8 - 0
src/main/java/com/kede/common/utils/PasswordUtil.java

@@ -7,6 +7,7 @@ import org.apache.shiro.util.ByteSource;
 
 import com.kede.common.model.Admin;
 import com.kede.common.model.OwUser;
+import com.kede.common.model.User;
 
 public class PasswordUtil {
 	private String algorithmName = "md5";
@@ -29,10 +30,17 @@ public class PasswordUtil {
 	public String getEncryptPwd(Admin admin) {
 		return new SimpleHash(algorithmName, admin.getPassword(), getManageSalt(admin), hashIterations).toHex();
 	}
+	public String getEncryptPwd(User user) {
+		return new SimpleHash(algorithmName, user.getPassword(), getSalt(user), hashIterations).toHex();
+	}
 
 	public String getEncryptPwd(String pwd, Date date) {
 		return new SimpleHash(algorithmName, pwd, getSalt(date), hashIterations).toHex();
 	}
+	
+	public ByteSource getSalt(User user) {
+		return ByteSource.Util.bytes(String.valueOf(user.getCreateTime().getTime()));
+	}
 
 	
 	public ByteSource getManageSalt(Admin admin) {

+ 14 - 0
src/main/java/com/kede/common/utils/StringUtils.java

@@ -1,5 +1,6 @@
 package com.kede.common.utils;
 
+import java.io.UnsupportedEncodingException;
 import java.util.regex.Pattern;
 
 public class StringUtils extends org.apache.commons.lang3.StringUtils {
@@ -8,4 +9,17 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
 	public static boolean isFractionalNumeric(String val) {
 		return FRACTIONAL_NUMERIC.matcher(val).matches();
 	}
+	
+	
+	public static byte[] strToByte(String str) {
+		byte[] sInput = new byte[0];
+		try {
+		    // 可以指定编码,默认也只UTF-8
+		    sInput = str.getBytes("UTF-8");
+		} catch (UnsupportedEncodingException e) {
+		    e.printStackTrace();
+		}
+		return sInput;
+		
+	}
 }

+ 46 - 0
src/main/java/com/kede/common/utils/WxAPIV3AesUtil.java

@@ -0,0 +1,46 @@
+package com.kede.common.utils;
+
+
+import java.io.IOException;
+import java.security.GeneralSecurityException;
+import java.security.InvalidAlgorithmParameterException;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.util.Base64;
+import javax.crypto.Cipher;
+import javax.crypto.NoSuchPaddingException;
+import javax.crypto.spec.GCMParameterSpec;
+import javax.crypto.spec.SecretKeySpec;
+ 
+public class WxAPIV3AesUtil {
+ 
+    static final int KEY_LENGTH_BYTE = 32;
+    static final int TAG_LENGTH_BIT = 128;
+    private final byte[] aesKey;
+ 
+    public WxAPIV3AesUtil(byte[] key) {
+        if (key.length != KEY_LENGTH_BYTE) {
+            throw new IllegalArgumentException("key="+key.length+"无效的ApiV3Key,长度必须为32个字节");
+        }
+        this.aesKey = key;
+    }
+ 
+    public String decryptToString(byte[] associatedData, byte[] nonce, String ciphertext)
+            throws GeneralSecurityException, IOException {
+        try {
+            Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding");
+ 
+            SecretKeySpec key = new SecretKeySpec(aesKey, "AES");
+            GCMParameterSpec spec = new GCMParameterSpec(TAG_LENGTH_BIT, nonce);
+ 
+            cipher.init(Cipher.DECRYPT_MODE, key, spec);
+            cipher.updateAAD(associatedData);
+ 
+            return new String(cipher.doFinal(Base64.getDecoder().decode(ciphertext)), "utf-8");
+        } catch (NoSuchAlgorithmException | NoSuchPaddingException e) {
+            throw new IllegalStateException(e);
+        } catch (InvalidKeyException | InvalidAlgorithmParameterException e) {
+            throw new IllegalArgumentException(e);
+        }
+    }
+}

+ 1 - 0
src/main/java/com/kede/core/shiro/filter/LoginFilter.java

@@ -5,6 +5,7 @@ import javax.servlet.ServletResponse;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.shiro.SecurityUtils;
 import org.apache.shiro.web.filter.AccessControlFilter;
 import org.springframework.beans.factory.annotation.Autowired;
 

+ 47 - 0
src/main/java/com/kede/core/shiro/filter/UserFilter.java

@@ -0,0 +1,47 @@
+package com.kede.core.shiro.filter;
+
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.shiro.web.filter.AccessControlFilter;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import com.kede.common.bo.Error;
+import com.kede.common.bo.Result;
+import com.kede.common.model.OwUser;
+import com.kede.common.model.User;
+import com.kede.common.utils.LoggerUtils;
+import com.kede.core.shiro.token.TokenManager;
+
+public class UserFilter extends AccessControlFilter {
+	final static Class<UserFilter>	CLASS	= UserFilter.class;
+
+	@Autowired
+	private ShiroFilterUtils		shiroFilterUtils;
+
+	@Override
+	protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue)
+			throws Exception {
+
+		OwUser token = TokenManager.getToken();
+		if (token instanceof User) {
+			return Boolean.TRUE;
+		}
+		return Boolean.FALSE;
+	}
+
+	@Override
+	protected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws Exception {
+		// 保存Request和Response 到登录后的链接
+		if (!shiroFilterUtils.isAjax((HttpServletRequest) request)) {
+			saveRequestAndRedirectToLogin(request, response);
+		} else {
+			LoggerUtils.debug(getClass(), "当前用户没有登录,并且是Ajax请求!");
+			shiroFilterUtils.out((HttpServletResponse) response, new Result().error(new Error("", "403", "当前用户没有登录!")));
+		}
+		return Boolean.FALSE;
+	}
+
+}

+ 13 - 0
src/main/java/com/kede/core/shiro/token/TokenManager.java

@@ -1,11 +1,14 @@
 package com.kede.core.shiro.token;
 
 
+import java.util.UUID;
+
 import org.apache.shiro.SecurityUtils;
 import org.apache.shiro.session.Session;
 
 import com.kede.common.model.Admin;
 import com.kede.common.model.OwUser;
+import com.kede.common.model.User;
 import com.kede.common.utils.SpringContextUtils;
 
 public class TokenManager {
@@ -158,6 +161,14 @@ public class TokenManager {
 		SecurityUtils.getSubject().login(token);
 		return getAdminToken();
 	}
+	
+	public static User login(User user, Boolean rememberMe,String openId) {
+		ShiroToken token = new ShiroToken(user.getOpenId(), user.getPassword(),1,1);
+		token.setRememberMe(null == rememberMe ? false : rememberMe);
+		SecurityUtils.getSubject().login(token);
+		setVal2Session("openId", openId);
+		return (User) getToken();
+		}
 
 	/**
 	 * 判断是否登录
@@ -194,6 +205,8 @@ public class TokenManager {
 	public static void clearUserAuthByUserId(String... userIds) {
 		realm.clearCachedAuthorizationInfo(userIds);
 	}
+
+	
 	
 
 

+ 18 - 3
src/main/java/com/kede/core/shiro/token/UserRealm.java

@@ -15,15 +15,18 @@ import org.apache.shiro.subject.SimplePrincipalCollection;
 import org.springframework.beans.factory.annotation.Autowired;
 
 import com.kede.admin.service.AdminService;
+import com.kede.common.dao.UserMapper;
 import com.kede.common.model.Admin;
+import com.kede.common.model.OwUser;
+import com.kede.common.model.User;
 import com.kede.common.utils.PasswordUtil;
 
 public class UserRealm extends AuthorizingRealm {
 	@Autowired
 	AdminService			adminService;
 	
-//	@Autowired
-//	UserService				userService;
+	@Autowired
+	UserMapper				userMapper;
 //	@Autowired
 //	RoleService				roleService;
 //	@Autowired
@@ -43,7 +46,7 @@ public class UserRealm extends AuthorizingRealm {
 			throws AuthenticationException {
 
 		ShiroToken token = (ShiroToken) authcToken;
-	
+		if (null == token.getType()) {
 			Admin admin = adminService.selectByUserName(token.getUsername());
 			if (null == admin) {
 				throw new UnknownAccountException();
@@ -51,6 +54,18 @@ public class UserRealm extends AuthorizingRealm {
 			token.setId(admin.getId());
 			return new SimpleAuthenticationInfo(admin, admin.getPassword(), passwordUtil.getManageSalt(admin),
 					getName());
+		}else {
+			User user = userMapper.selectByOpenId(token.getUsername());
+			if (null == user) {
+				throw new UnknownAccountException();
+			}
+			User us = userMapper.selectByOpenId(token.getUsername());
+			us.setPassword("123456");
+			token.setId(user.getId());
+			OwUser ocUser = user;
+			return new SimpleAuthenticationInfo(ocUser, ocUser.getPassword(), passwordUtil.getAftSalt(ocUser),
+					getName());
+		}
 	}
 
 	/**

+ 79 - 0
src/main/java/com/kede/project/controller/ProjectApiController.java

@@ -0,0 +1,79 @@
+package com.kede.project.controller;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.kede.common.bo.Result;
+import com.kede.common.constant.ErrorConstants;
+import com.kede.common.controller.BaseApiController;
+import com.kede.common.model.projectBo;
+import com.kede.project.service.ProjectService;
+
+@RestController
+@RequestMapping(value = "/api/admin/project")
+public class ProjectApiController extends BaseApiController {
+	
+	@Resource
+	private ProjectService	projectService;
+	
+	@RequestMapping(value = "/add",method = RequestMethod.POST)
+	public Result add(projectBo bo) {
+		Result res =new Result();
+		if (bo.getName()==null) {
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"名称","名称"));
+			return res;
+		}
+		if (bo.getAmount()==null) {
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"金额","金额"));
+			return res;
+		}
+		res.data(projectService.add(bo));
+		return res;
+	}
+	
+	@RequestMapping(value = "/update",method = RequestMethod.POST)
+	public Result update(projectBo bo) {
+		Result res =new Result();
+		if (bo.getId()==null) {
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"编号","编号"));
+			return res;
+		}
+		
+		res.data(projectService.update(bo));
+		return res;
+	}
+	
+	
+	@RequestMapping(value = "/delete",method = RequestMethod.POST)
+	public Result delete(  Integer id) {
+		Result res =new Result();
+		if (id==null) {
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"编号","编号"));
+			return res;
+		}
+		res.data(projectService.delete(id));
+		return res;
+	}
+	
+	@RequestMapping(value = "/list",method = RequestMethod.GET)
+	public Result list(String name,String startTime,String endTime,Integer pageNo,Integer pageSize) {
+		Result res =new Result();
+		
+		res.data(projectService.list(name, startTime, endTime,pageNo, pageSize));
+		return res;
+	}
+	
+	
+	/** 上传图片 **/
+	@RequestMapping(value = "/uploadFile", method = RequestMethod.POST)
+	public Result uploadOrderInvoiceFile(HttpServletRequest req){
+		Result res = new Result();
+		res.setData(handleFile(res, "/project/", false, req, "project"));
+		return res;
+	}
+
+}

+ 60 - 0
src/main/java/com/kede/project/controller/ProjectTypeApiController.java

@@ -0,0 +1,60 @@
+package com.kede.project.controller;
+
+import javax.annotation.Resource;
+
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.kede.common.bo.Result;
+import com.kede.common.constant.ErrorConstants;
+import com.kede.common.controller.BaseApiController;
+import com.kede.common.model.ProjectType;
+import com.kede.project.service.ProjectTypeService;
+
+@RestController
+@RequestMapping(value = "/api/admin/projectType")
+public class ProjectTypeApiController extends BaseApiController {
+	
+	@Resource
+	private ProjectTypeService	projectTypeService;
+	
+	@RequestMapping(value = "/add",method = RequestMethod.POST)
+	public Result add(ProjectType bo) {
+		Result res =new Result();
+		if (bo.getName()==null) {
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"名称","名称"));
+			return res;
+		}
+		
+		res.data(projectTypeService.add(bo));
+		return res;
+	}
+	
+	@RequestMapping(value = "/update",method = RequestMethod.POST)
+	public Result update(ProjectType bo) {
+		Result res =new Result();
+		if (bo.getId()==null) {
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"编号","编号"));
+			return res;
+		}
+		
+		res.data(projectTypeService.update(bo));
+		return res;
+	}
+	
+	
+	@RequestMapping(value = "/delete",method = RequestMethod.POST)
+	public Result delete(  Integer id) {
+		Result res =new Result();
+		if (id==null) {
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"编号","编号"));
+			return res;
+		}
+		res.data(projectTypeService.delete(id));
+		return res;
+	}
+	
+
+
+}

+ 22 - 0
src/main/java/com/kede/project/service/ProjectService.java

@@ -0,0 +1,22 @@
+package com.kede.project.service;
+
+import com.kede.common.model.Project;
+import com.kede.common.model.projectBo;
+
+public interface ProjectService {
+
+	int add(projectBo bo);
+
+	int update(projectBo bo);
+
+	int delete(Integer id);
+
+	Object list(String name, String startTime, String endTime, Integer pageNo, Integer pageSize);
+
+	Project get(Integer id);
+
+	Object getProject(Integer id);
+
+
+
+}

+ 19 - 0
src/main/java/com/kede/project/service/ProjectTypeService.java

@@ -0,0 +1,19 @@
+package com.kede.project.service;
+
+import java.util.List;
+
+import com.kede.common.model.ProjectType;
+
+public interface ProjectTypeService {
+
+	Object add(ProjectType bo);
+
+	Object update(ProjectType bo);
+
+	Object delete(Integer id);
+
+	List<ProjectType> list(String name);
+
+
+
+}

+ 90 - 0
src/main/java/com/kede/project/service/impl/ProjectServiceImpl.java

@@ -0,0 +1,90 @@
+package com.kede.project.service.impl;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.kede.common.dao.OrderMapper;
+import com.kede.common.dao.ProjectMapper;
+import com.kede.common.model.Project;
+import com.kede.common.model.projectBo;
+import com.kede.common.utils.StringUtils;
+import com.kede.core.mybatis.BaseMybatisDao;
+import com.kede.core.shiro.token.TokenManager;
+import com.kede.project.service.ProjectService;
+
+@Service
+public class ProjectServiceImpl extends BaseMybatisDao<ProjectMapper> implements ProjectService{
+
+	@Autowired
+	private ProjectMapper projectMapper;
+	@Autowired
+	private OrderMapper orderMapper;
+
+	@Override
+	public int add(projectBo bo) {
+		bo.setStatus(0);
+		if (bo.getReleaseStatus()!=null &&bo.getReleaseStatus()==1) {
+			bo.setReleaseTime(new Date());
+		}
+		return projectMapper.insertSelective(bo);
+	}
+
+	@Override
+	public int update(projectBo bo) {
+		if (bo.getReleaseStatus()!=null &&bo.getReleaseStatus()==1) {
+			bo.setReleaseTime(new Date());
+		}
+		return projectMapper.updateByPrimaryKeySelective(bo);
+	}
+
+	@Override
+	public int delete(Integer id) {
+		return projectMapper.deleteByPrimaryKey(id);
+	}
+
+	@Override
+	public Object list(String name, String startTime, String endTime,Integer pageNo,Integer pageSize) {
+		Map<String, Object> params=new HashMap<String, Object>();
+		if(StringUtils.isBlank(name))params.put("name", name);
+		if(StringUtils.isBlank(startTime))params.put("startTime", startTime);
+		if(StringUtils.isBlank(endTime))params.put("endTime", endTime);
+		return findPage("selectProjectList", "selectProjectCount", params, pageNo, pageSize);
+	}
+
+	@Override
+	public Project get(Integer id) {
+		
+		return projectMapper.selectByPrimaryKey(id);
+	}
+
+	@Override
+	public Object getProject(Integer id) {
+		projectBo pb= projectMapper.getProject(id);
+		if (chakeBuy(id)) {
+			pb.setCommodityUrl("");
+			pb.setBuy(0);
+		}else {
+			pb.setBuy(1);
+		}
+		return pb;
+	}
+
+	private boolean chakeBuy(Integer id) {
+		String uid=TokenManager.getUserId();
+		if (uid!=null) {
+			int buy=orderMapper.chakeBuy(uid,id);
+			if (buy>0) {
+				return false;
+			}
+		}
+		return true;
+	}
+
+	
+	
+
+}

+ 47 - 0
src/main/java/com/kede/project/service/impl/ProjectTypeServiceImpl.java

@@ -0,0 +1,47 @@
+package com.kede.project.service.impl;
+
+import java.util.Date;
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.kede.common.dao.ProjectTypeMapper;
+import com.kede.common.model.ProjectType;
+import com.kede.core.mybatis.BaseMybatisDao;
+import com.kede.project.service.ProjectTypeService;
+
+@Service
+public class ProjectTypeServiceImpl extends BaseMybatisDao<ProjectTypeMapper> implements ProjectTypeService{
+
+	@Autowired
+	private ProjectTypeMapper projectTypeMapper;
+
+	@Override
+	public Object add(ProjectType bo) {
+		bo.setCreateTime(new Date());
+		bo.setStatus(1);
+		return projectTypeMapper.insertSelective(bo);
+	}
+
+	@Override
+	public Object update(ProjectType bo) {
+		return projectTypeMapper.updateByPrimaryKeySelective(bo);
+	}
+
+	@Override
+	public Object delete(Integer id) {
+		return projectTypeMapper.deleteByPrimaryKey(id);
+	}
+
+	@Override
+	public List<ProjectType> list(String name) {
+		
+		return projectTypeMapper.selectList(name);
+	}
+
+
+
+	
+
+}

+ 44 - 0
src/main/java/com/kede/sdk/IWXPayDomain.java

@@ -0,0 +1,44 @@
+package com.kede.sdk;
+
+import com.kede.sdk.service.WXPayConfig;
+
+/**
+ * 域名管理,实现主备域名自动切换
+ */
+public abstract interface IWXPayDomain {
+    /**
+     * 上报域名网络状况
+     * @param domain 域名。 比如:api.mch.weixin.qq.com
+     * @param elapsedTimeMillis 耗时
+     * @param ex 网络请求中出现的异常。
+     *           null表示没有异常
+     *           ConnectTimeoutException,表示建立网络连接异常
+     *           UnknownHostException, 表示dns解析异常
+     */
+    abstract void report(final String domain, long elapsedTimeMillis, final Exception ex);
+
+    /**
+     * 获取域名
+     * @param config 配置
+     * @return 域名
+     */
+    abstract DomainInfo getDomain(final WXPayConfig config);
+
+    static class DomainInfo{
+        public String domain;       //域名
+        public boolean primaryDomain;     //该域名是否为主域名。例如:api.mch.weixin.qq.com为主域名
+        public DomainInfo(String domain, boolean primaryDomain) {
+            this.domain = domain;
+            this.primaryDomain = primaryDomain;
+        }
+
+        @Override
+        public String toString() {
+            return "DomainInfo{" +
+                    "domain='" + domain + '\'' +
+                    ", primaryDomain=" + primaryDomain +
+                    '}';
+        }
+    }
+
+}

+ 59 - 0
src/main/java/com/kede/sdk/WXPayConstants.java

@@ -0,0 +1,59 @@
+package com.kede.sdk;
+
+import org.apache.http.client.HttpClient;
+
+/**
+ * 常量
+ */
+public class WXPayConstants {
+
+    public enum SignType {
+        MD5, HMACSHA256
+    }
+
+    public static final String DOMAIN_API = "api.mch.weixin.qq.com";
+    public static final String DOMAIN_API2 = "api2.mch.weixin.qq.com";
+    public static final String DOMAIN_APIHK = "apihk.mch.weixin.qq.com";
+    public static final String DOMAIN_APIUS = "apius.mch.weixin.qq.com";
+
+
+    public static final String FAIL     = "FAIL";
+    public static final String SUCCESS  = "SUCCESS";
+    public static final String HMACSHA256 = "HMAC-SHA256";
+    public static final String MD5 = "MD5";
+
+    public static final String FIELD_SIGN = "sign";
+    public static final String FIELD_SIGN_TYPE = "sign_type";
+
+    public static final String WXPAYSDK_VERSION = "WXPaySDK/3.0.9";
+    public static final String USER_AGENT = WXPAYSDK_VERSION +
+            " (" + System.getProperty("os.arch") + " " + System.getProperty("os.name") + " " + System.getProperty("os.version") +
+            ") Java/" + System.getProperty("java.version") + " HttpClient/" + HttpClient.class.getPackage().getImplementationVersion();
+
+    public static final String MICROPAY_URL_SUFFIX     = "/pay/micropay";
+    public static final String UNIFIEDORDER_URL_SUFFIX = "/pay/unifiedorder";
+    public static final String ORDERQUERY_URL_SUFFIX   = "/pay/orderquery";
+    public static final String REVERSE_URL_SUFFIX      = "/secapi/pay/reverse";
+    public static final String CLOSEORDER_URL_SUFFIX   = "/pay/closeorder";
+    public static final String REFUND_URL_SUFFIX       = "/secapi/pay/refund";
+    public static final String REFUNDQUERY_URL_SUFFIX  = "/pay/refundquery";
+    public static final String DOWNLOADBILL_URL_SUFFIX = "/pay/downloadbill";
+    public static final String REPORT_URL_SUFFIX       = "/payitil/report";
+    public static final String SHORTURL_URL_SUFFIX     = "/tools/shorturl";
+    public static final String AUTHCODETOOPENID_URL_SUFFIX = "/tools/authcodetoopenid";
+
+    // sandbox
+    public static final String SANDBOX_MICROPAY_URL_SUFFIX     = "/sandboxnew/pay/micropay";
+    public static final String SANDBOX_UNIFIEDORDER_URL_SUFFIX = "/sandboxnew/pay/unifiedorder";
+    public static final String SANDBOX_ORDERQUERY_URL_SUFFIX   = "/sandboxnew/pay/orderquery";
+    public static final String SANDBOX_REVERSE_URL_SUFFIX      = "/sandboxnew/secapi/pay/reverse";
+    public static final String SANDBOX_CLOSEORDER_URL_SUFFIX   = "/sandboxnew/pay/closeorder";
+    public static final String SANDBOX_REFUND_URL_SUFFIX       = "/sandboxnew/secapi/pay/refund";
+    public static final String SANDBOX_REFUNDQUERY_URL_SUFFIX  = "/sandboxnew/pay/refundquery";
+    public static final String SANDBOX_DOWNLOADBILL_URL_SUFFIX = "/sandboxnew/pay/downloadbill";
+    public static final String SANDBOX_REPORT_URL_SUFFIX       = "/sandboxnew/payitil/report";
+    public static final String SANDBOX_SHORTURL_URL_SUFFIX     = "/sandboxnew/tools/shorturl";
+    public static final String SANDBOX_AUTHCODETOOPENID_URL_SUFFIX = "/sandboxnew/tools/authcodetoopenid";
+
+}
+

+ 292 - 0
src/main/java/com/kede/sdk/WXPayUtil.java

@@ -0,0 +1,292 @@
+package com.kede.sdk;
+
+import com.kede.sdk.WXPayConstants.SignType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import javax.crypto.Mac;
+import javax.crypto.spec.SecretKeySpec;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.StringWriter;
+import java.security.MessageDigest;
+import java.security.SecureRandom;
+import java.util.*;
+
+
+public class WXPayUtil {
+
+    private static final String SYMBOLS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
+
+    private static final Random RANDOM = new SecureRandom();
+
+    /**
+     * XML格式字符串转换为Map
+     *
+     * @param strXML XML字符串
+     * @return XML数据转换后的Map
+     * @throws Exception
+     */
+    public static Map<String, String> xmlToMap(String strXML) throws Exception {
+        try {
+            Map<String, String> data = new HashMap<String, String>();
+            DocumentBuilder documentBuilder = WXPayXmlUtil.newDocumentBuilder();
+            InputStream stream = new ByteArrayInputStream(strXML.getBytes("UTF-8"));
+            org.w3c.dom.Document doc = documentBuilder.parse(stream);
+            doc.getDocumentElement().normalize();
+            NodeList nodeList = doc.getDocumentElement().getChildNodes();
+            for (int idx = 0; idx < nodeList.getLength(); ++idx) {
+                Node node = nodeList.item(idx);
+                if (node.getNodeType() == Node.ELEMENT_NODE) {
+                    org.w3c.dom.Element element = (org.w3c.dom.Element) node;
+                    data.put(element.getNodeName(), element.getTextContent());
+                }
+            }
+            try {
+                stream.close();
+            } catch (Exception ex) {
+                // do nothing
+            }
+            return data;
+        } catch (Exception ex) {
+            WXPayUtil.getLogger().warn("Invalid XML, can not convert to map. Error message: {}. XML content: {}", ex.getMessage(), strXML);
+            throw ex;
+        }
+
+    }
+
+    /**
+     * 	将Map转换为XML格式的字符串
+     *
+     * @param data Map类型数据
+     * @return XML格式的字符串
+     * @throws Exception
+     */
+    public static String mapToXml(Map<String, String> data) throws Exception {
+        org.w3c.dom.Document document = WXPayXmlUtil.newDocument();
+        org.w3c.dom.Element root = document.createElement("xml");
+        document.appendChild(root);
+        for (String key: data.keySet()) {
+            String value = data.get(key);
+            if (value == null) {
+                value = "";
+            }
+            value = value.trim();
+            org.w3c.dom.Element filed = document.createElement(key);
+            filed.appendChild(document.createTextNode(value));
+            root.appendChild(filed);
+        }
+        TransformerFactory tf = TransformerFactory.newInstance();
+        Transformer transformer = tf.newTransformer();
+        DOMSource source = new DOMSource(document);
+        transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
+        transformer.setOutputProperty(OutputKeys.INDENT, "yes");
+        StringWriter writer = new StringWriter();
+        StreamResult result = new StreamResult(writer);
+        transformer.transform(source, result);
+        String output = writer.getBuffer().toString(); //.replaceAll("\n|\r", "");
+        try {
+            writer.close();
+        }
+        catch (Exception ex) {
+        }
+        return output;
+    }
+
+
+    /**
+     * 	生成带有 sign 的 XML 格式字符串
+     *
+     * @param data Map类型数据
+     * @param key API密钥
+     * @return 含有sign字段的XML
+     */
+    public static String generateSignedXml(final Map<String, String> data, String key) throws Exception {
+        return generateSignedXml(data, key, SignType.MD5);
+    }
+
+    /**
+     * 	生成带有 sign 的 XML 格式字符串
+     *
+     * @param data Map类型数据
+     * @param key API密钥
+     * @param signType 签名类型
+     * @return 含有sign字段的XML
+     */
+    public static String generateSignedXml(final Map<String, String> data, String key, SignType signType) throws Exception {
+        String sign = generateSignature(data, key, signType);
+        data.put(WXPayConstants.FIELD_SIGN, sign);
+        return mapToXml(data);
+    }
+
+
+    /**
+     * 	判断签名是否正确
+     *
+     * @param xmlStr XML格式数据
+     * @param key API密钥
+     * @return 签名是否正确
+     * @throws Exception
+     */
+    public static boolean isSignatureValid(String xmlStr, String key) throws Exception {
+        Map<String, String> data = xmlToMap(xmlStr);
+        if (!data.containsKey(WXPayConstants.FIELD_SIGN) ) {
+            return false;
+        }
+        String sign = data.get(WXPayConstants.FIELD_SIGN);
+        return generateSignature(data, key).equals(sign);
+    }
+
+    /**
+     * 	判断签名是否正确,必须包含sign字段,否则返回false。使用MD5签名。
+     *
+     * @param data Map类型数据
+     * @param key API密钥
+     * @return 签名是否正确
+     * @throws Exception
+     */
+    public static boolean isSignatureValid(Map<String, String> data, String key) throws Exception {
+        return isSignatureValid(data, key, SignType.MD5);
+    }
+
+    /**
+     *	 判断签名是否正确,必须包含sign字段,否则返回false。
+     *
+     * @param data Map类型数据
+     * @param key API密钥
+     * @param signType 签名方式
+     * @return 签名是否正确
+     * @throws Exception
+     */
+    public static boolean isSignatureValid(Map<String, String> data, String key, SignType signType) throws Exception {
+        if (!data.containsKey(WXPayConstants.FIELD_SIGN) ) {
+            return false;
+        }
+        String sign = data.get(WXPayConstants.FIELD_SIGN);
+        return generateSignature(data, key, signType).equals(sign);
+    }
+
+    /**
+     * 	生成签名
+     *
+     * @param data 待签名数据
+     * @param key API密钥
+     * @return 签名
+     */
+    public static String generateSignature(final Map<String, String> data, String key) throws Exception {
+        return generateSignature(data, key, SignType.HMACSHA256);
+    }
+
+    /**
+     * 	生成签名. 注意,若含有sign_type字段,必须和signType参数保持一致。
+     * @param data 待签名数据
+     * @param key API密钥
+     * @param signType 签名方式
+     * @return 签名
+     */
+    public static String generateSignature(final Map<String, String> data, String key, SignType signType) throws Exception {
+        Set<String> keySet = data.keySet();
+        String[] keyArray = keySet.toArray(new String[keySet.size()]);
+        Arrays.sort(keyArray);
+        StringBuilder sb = new StringBuilder();
+        for (String k : keyArray) {
+            if (k.equals(WXPayConstants.FIELD_SIGN)) {
+                continue;
+            }
+            if (data.get(k).trim().length() > 0) // 参数值为空,则不参与签名
+                sb.append(k).append("=").append(data.get(k).trim()).append("&");
+        }
+        sb.append("key=").append(key);
+        if (SignType.MD5.equals(signType)) {
+            return MD5(sb.toString()).toUpperCase();
+        }
+        else if (SignType.HMACSHA256.equals(signType)) {
+            return HMACSHA256(sb.toString(), key);
+        }
+        else {
+            throw new Exception(String.format("Invalid sign_type: %s", signType));
+        }
+    }
+
+
+    /**
+     * 	获取随机字符串 Nonce Str
+     * @return String 随机字符串
+     */
+    public static String generateNonceStr() {
+        char[] nonceChars = new char[32];
+        for (int index = 0; index < nonceChars.length; ++index) {
+            nonceChars[index] = SYMBOLS.charAt(RANDOM.nextInt(SYMBOLS.length()));
+        }
+        return new String(nonceChars);
+    }
+
+
+    /**
+     * 	生成 MD5
+     * @param data 待处理数据
+     * @return MD5结果
+     */
+    public static String MD5(String data) throws Exception {
+        java.security.MessageDigest md = MessageDigest.getInstance("MD5");
+        byte[] array = md.digest(data.getBytes("UTF-8"));
+        StringBuilder sb = new StringBuilder();
+        for (byte item : array) {
+            sb.append(Integer.toHexString((item & 0xFF) | 0x100).substring(1, 3));
+        }
+        return sb.toString().toUpperCase();
+    }
+
+    /**
+     * 	生成 HMACSHA256
+     * @param data 待处理数据
+     * @param key 密钥
+     * @return 加密结果
+     * @throws Exception
+     */
+    public static String HMACSHA256(String data, String key) throws Exception {
+        Mac sha256_HMAC = Mac.getInstance("HmacSHA256");
+        SecretKeySpec secret_key = new SecretKeySpec(key.getBytes("UTF-8"), "HmacSHA256");
+        sha256_HMAC.init(secret_key);
+        byte[] array = sha256_HMAC.doFinal(data.getBytes("UTF-8"));
+        StringBuilder sb = new StringBuilder();
+        for (byte item : array) {
+            sb.append(Integer.toHexString((item & 0xFF) | 0x100).substring(1, 3));
+        }
+        return sb.toString().toUpperCase();
+    }
+
+    /**
+     * 	日志
+     * @return
+     */
+    public static Logger getLogger() {
+        Logger logger = LoggerFactory.getLogger("wxpay java sdk");
+        return logger;
+    }
+
+    /**
+     * 	获取当前时间戳,单位秒
+     * @return
+     */
+    public static long getCurrentTimestamp() {
+        return System.currentTimeMillis()/1000;
+    }
+
+    /**
+     * 	获取当前时间戳,单位毫秒
+     * @return
+     */
+    public static long getCurrentTimestampMs() {
+        return System.currentTimeMillis();
+    }
+
+}

+ 30 - 0
src/main/java/com/kede/sdk/WXPayXmlUtil.java

@@ -0,0 +1,30 @@
+package com.kede.sdk;
+
+import org.w3c.dom.Document;
+
+import javax.xml.XMLConstants;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+/**
+ * 2018/7/3
+ */
+public final class WXPayXmlUtil {
+    public static DocumentBuilder newDocumentBuilder() throws ParserConfigurationException {
+        DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+        documentBuilderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
+        documentBuilderFactory.setFeature("http://xml.org/sax/features/external-general-entities", false);
+        documentBuilderFactory.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
+        documentBuilderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
+        documentBuilderFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
+        documentBuilderFactory.setXIncludeAware(false);
+        documentBuilderFactory.setExpandEntityReferences(false);
+
+        return documentBuilderFactory.newDocumentBuilder();
+    }
+
+    public static Document newDocument() throws ParserConfigurationException {
+        return newDocumentBuilder().newDocument();
+    }
+}

+ 106 - 0
src/main/java/com/kede/sdk/service/IWxPayConfig.java

@@ -0,0 +1,106 @@
+package com.kede.sdk.service;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import com.kede.sdk.IWXPayDomain;
+import com.kede.sdk.WXPayConstants;
+import com.kede.sdk.WXPayUtil;
+
+
+@Service
+public class IWxPayConfig extends WXPayConfig { 
+	// 继承sdk WXPayConfig 实现sdk中部分抽象方法
+
+    private byte[] certData;
+
+    private String app_id;
+
+    private String wx_pay_key;
+
+    private String wx_pay_mch_id;
+
+    public IWxPayConfig(String appid,String mchid,String apiKey) throws Exception {
+    	this.app_id=appid;
+    	this.wx_pay_mch_id=mchid;
+    	this.wx_pay_key=apiKey;
+//    	String s=getSandboxSignKey();
+    	new IWxPayConfig();
+    }
+
+	public IWxPayConfig() throws Exception { 
+   	// 构造方法读取证书, 通过getCertStream 可以使sdk获取到证书
+       String certPath = "F:/project/ztest/src/main/resources/apiclient_cert.p12";
+       File file = new File(certPath);
+       InputStream certStream = new FileInputStream(file);
+       this.certData = new byte[(int) file.length()];
+       certStream.read(this.certData);
+       certStream.close();
+   }
+
+    @Override
+    public String getAppID() {
+        return app_id;
+    }
+
+    @Override
+    public String getMchID() {
+        return wx_pay_mch_id;
+    }
+
+    @Override
+    public String getKey() {
+        return wx_pay_key;
+    }
+
+    @Override
+    public InputStream getCertStream() {
+        return new ByteArrayInputStream(this.certData);
+    }
+
+    @Override
+    public IWXPayDomain getWXPayDomain() {
+    	// 这个方法需要这样实现, 否则无法正常初始化WXPay
+        IWXPayDomain iwxPayDomain = new IWXPayDomain() {
+            @Override
+            public void report(String domain, long elapsedTimeMillis, Exception ex) {
+
+            }
+            @Override
+            public DomainInfo getDomain(WXPayConfig config) {
+                return new IWXPayDomain.DomainInfo(WXPayConstants.DOMAIN_API, true);
+            }
+        };
+        return iwxPayDomain;
+    }
+    
+    public String getSandboxSignKey() throws Exception {
+        WXPay wxPay = new WXPay(this);
+        try {
+            Map<String, String> params = new HashMap<String, String>();
+            params.put("mch_id", this.getMchID());
+            params.put("nonce_str", WXPayUtil.generateNonceStr());
+            params.put("sign", WXPayUtil.generateSignature(params, this.getKey()));
+            String strXML = wxPay.requestWithoutCert("https://api.mch.weixin.qq.com/sandboxnew/pay/getsignkey",
+                    params, this.getHttpConnectTimeoutMs(), this.getHttpReadTimeoutMs());
+ 
+            Map<String, String> result = WXPayUtil.xmlToMap(strXML);
+            System.out.println("retrieveSandboxSignKey:" + result);
+            if ("SUCCESS".equals(result.get("return_code"))) {
+                return result.get("sandbox_signkey");
+            }
+            return null;
+        } catch (Exception e) {
+            System.out.println("获取sandbox_signkey异常" + e.getMessage());
+            return null;
+        }
+    }
+
+}

+ 694 - 0
src/main/java/com/kede/sdk/service/WXPay.java

@@ -0,0 +1,694 @@
+package com.kede.sdk.service;
+
+import com.kede.sdk.WXPayConstants;
+import com.kede.sdk.WXPayUtil;
+import com.kede.sdk.WXPayConstants.SignType;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class WXPay {
+
+    private WXPayConfig config;
+    private SignType signType;
+    private boolean autoReport;
+    private boolean useSandbox;
+    private String notifyUrl;
+    private WXPayRequest wxPayRequest;
+
+    public WXPay(final WXPayConfig config) throws Exception {
+        this(config, null, true, false);
+    }
+
+    public WXPay(final WXPayConfig config, final boolean autoReport) throws Exception {
+        this(config, null, autoReport, false);
+    }
+
+
+    public WXPay(final WXPayConfig config, final boolean autoReport, final boolean useSandbox) throws Exception{
+        this(config, null, autoReport, useSandbox);
+    }
+
+    public WXPay(final WXPayConfig config, final String notifyUrl) throws Exception {
+        this(config, notifyUrl, true, false);
+    }
+
+    public WXPay(final WXPayConfig config, final String notifyUrl, final boolean autoReport) throws Exception {
+        this(config, notifyUrl, autoReport, false);
+    }
+
+    public WXPay(final WXPayConfig config, final String notifyUrl, final boolean autoReport, final boolean useSandbox) throws Exception {
+        this.config = config;
+        this.notifyUrl = notifyUrl;
+        this.autoReport = autoReport;
+        this.useSandbox = useSandbox;
+        if (useSandbox) {
+            this.signType = SignType.MD5; // 沙箱环境
+        }
+        else {
+            this.signType = SignType.HMACSHA256;
+        }
+        this.wxPayRequest = new WXPayRequest(config);
+    }
+
+    private void checkWXPayConfig() throws Exception {
+        if (this.config == null) {
+            throw new Exception("config is null");
+        }
+        if (this.config.getAppID() == null || this.config.getAppID().trim().length() == 0) {
+            throw new Exception("appid in config is empty");
+        }
+        if (this.config.getMchID() == null || this.config.getMchID().trim().length() == 0) {
+            throw new Exception("appid in config is empty");
+        }
+        if (this.config.getCertStream() == null) {
+            throw new Exception("cert stream in config is empty");
+        }
+        if (this.config.getWXPayDomain() == null){
+            throw new Exception("config.getWXPayDomain() is null");
+        }
+
+        if (this.config.getHttpConnectTimeoutMs() < 10) {
+            throw new Exception("http connect timeout is too small");
+        }
+        if (this.config.getHttpReadTimeoutMs() < 10) {
+            throw new Exception("http read timeout is too small");
+        }
+
+    }
+
+    /**
+     * 向 Map 中添加 appid、mch_id、nonce_str、sign_type、sign <br>
+     * 该函数适用于商户适用于统一下单等接口,不适用于红包、代金券接口
+     *
+     * @param reqData
+     * @return
+     * @throws Exception
+     */
+    public Map<String, String> fillRequestData(Map<String, String> reqData) throws Exception {
+        reqData.put("appid", config.getAppID());
+        reqData.put("mch_id", config.getMchID());
+        reqData.put("nonce_str", WXPayUtil.generateNonceStr());
+        if (SignType.MD5.equals(this.signType)) {
+            reqData.put("sign_type", WXPayConstants.MD5);
+        }
+        else if (SignType.HMACSHA256.equals(this.signType)) {
+            reqData.put("sign_type", WXPayConstants.HMACSHA256);
+        }
+        if (useSandbox) {
+			
+		}else {
+			reqData.put("sign", WXPayUtil.generateSignature(reqData, config.getKey(), this.signType));
+		}
+        return reqData;
+    }
+
+    /**
+     * 判断xml数据的sign是否有效,必须包含sign字段,否则返回false。
+     *
+     * @param reqData 向wxpay post的请求数据
+     * @return 签名是否有效
+     * @throws Exception
+     */
+    public boolean isResponseSignatureValid(Map<String, String> reqData) throws Exception {
+        // 返回数据的签名方式和请求中给定的签名方式是一致的
+        return WXPayUtil.isSignatureValid(reqData, this.config.getKey(), this.signType);
+    }
+
+    /**
+     * 判断支付结果通知中的sign是否有效
+     *
+     * @param reqData 向wxpay post的请求数据
+     * @return 签名是否有效
+     * @throws Exception
+     */
+    public boolean isPayResultNotifySignatureValid(Map<String, String> reqData) throws Exception {
+        String signTypeInData = reqData.get(WXPayConstants.FIELD_SIGN_TYPE);
+        SignType signType;
+        if (signTypeInData == null) {
+            signType = SignType.MD5;
+        }
+        else {
+            signTypeInData = signTypeInData.trim();
+            if (signTypeInData.length() == 0) {
+                signType = SignType.MD5;
+            }
+            else if (WXPayConstants.MD5.equals(signTypeInData)) {
+                signType = SignType.MD5;
+            }
+            else if (WXPayConstants.HMACSHA256.equals(signTypeInData)) {
+                signType = SignType.HMACSHA256;
+            }
+            else {
+                throw new Exception(String.format("Unsupported sign_type: %s", signTypeInData));
+            }
+        }
+        return WXPayUtil.isSignatureValid(reqData, this.config.getKey(), signType);
+    }
+
+
+    /**
+     * 不需要证书的请求
+     * @param urlSuffix String
+     * @param reqData 向wxpay post的请求数据
+     * @param connectTimeoutMs 超时时间,单位是毫秒
+     * @param readTimeoutMs 超时时间,单位是毫秒
+     * @return API返回数据
+     * @throws Exception
+     */
+    public String requestWithoutCert(String urlSuffix, Map<String, String> reqData,
+                                     int connectTimeoutMs, int readTimeoutMs) throws Exception {
+        String msgUUID = reqData.get("nonce_str");
+        String reqBody = WXPayUtil.mapToXml(reqData);
+        String resp = this.wxPayRequest.requestWithoutCert(urlSuffix, msgUUID, reqBody, connectTimeoutMs, readTimeoutMs, autoReport);
+        return resp;
+    }
+
+
+    /**
+     * 需要证书的请求
+     * @param urlSuffix String
+     * @param reqData 向wxpay post的请求数据  Map
+     * @param connectTimeoutMs 超时时间,单位是毫秒
+     * @param readTimeoutMs 超时时间,单位是毫秒
+     * @return API返回数据
+     * @throws Exception
+     */
+    public String requestWithCert(String urlSuffix, Map<String, String> reqData,
+                                  int connectTimeoutMs, int readTimeoutMs) throws Exception {
+        String msgUUID= reqData.get("nonce_str");
+        String reqBody = WXPayUtil.mapToXml(reqData);
+
+        String resp = this.wxPayRequest.requestWithCert(urlSuffix, msgUUID, reqBody, connectTimeoutMs, readTimeoutMs, this.autoReport);
+        return resp;
+    }
+
+    /**
+     * 处理 HTTPS API返回数据,转换成Map对象。return_code为SUCCESS时,验证签名。
+     * @param xmlStr API返回的XML格式数据
+     * @return Map类型数据
+     * @throws Exception
+     */
+    public Map<String, String> processResponseXml(String xmlStr) throws Exception {
+        String RETURN_CODE = "return_code";
+        String return_code;
+        Map<String, String> respData = WXPayUtil.xmlToMap(xmlStr);
+        if (respData.containsKey(RETURN_CODE)) {
+            return_code = respData.get(RETURN_CODE);
+        }
+        else {
+            throw new Exception(String.format("No `return_code` in XML: %s", xmlStr));
+        }
+
+        if (return_code.equals(WXPayConstants.FAIL)) {
+            return respData;
+        }
+        else if (return_code.equals(WXPayConstants.SUCCESS)) {
+           if (this.isResponseSignatureValid(respData)) {
+               return respData;
+           }
+           else {
+               throw new Exception(String.format("Invalid sign value in XML: %s", xmlStr));
+           }
+        }
+        else {
+            throw new Exception(String.format("return_code value %s is invalid in XML: %s", return_code, xmlStr));
+        }
+    }
+
+    /**
+     * 作用:提交刷卡支付<br>
+     * 场景:刷卡支付
+     * @param reqData 向wxpay post的请求数据
+     * @return API返回数据
+     * @throws Exception
+     */
+    public Map<String, String> microPay(Map<String, String> reqData) throws Exception {
+        return this.microPay(reqData, this.config.getHttpConnectTimeoutMs(), this.config.getHttpReadTimeoutMs());
+    }
+
+
+    /**
+     * 作用:提交刷卡支付<br>
+     * 场景:刷卡支付
+     * @param reqData 向wxpay post的请求数据
+     * @param connectTimeoutMs 连接超时时间,单位是毫秒
+     * @param readTimeoutMs 读超时时间,单位是毫秒
+     * @return API返回数据
+     * @throws Exception
+     */
+    public Map<String, String> microPay(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception {
+        String url;
+        if (this.useSandbox) {
+            url = WXPayConstants.SANDBOX_MICROPAY_URL_SUFFIX;
+        }
+        else {
+            url = WXPayConstants.MICROPAY_URL_SUFFIX;
+        }
+        String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
+        return this.processResponseXml(respXml);
+    }
+
+    /**
+     * 提交刷卡支付,针对软POS,尽可能做成功
+     * 内置重试机制,最多60s
+     * @param reqData
+     * @return
+     * @throws Exception
+     */
+    public Map<String, String> microPayWithPos(Map<String, String> reqData) throws Exception {
+        return this.microPayWithPos(reqData, this.config.getHttpConnectTimeoutMs());
+    }
+
+    /**
+     * 提交刷卡支付,针对软POS,尽可能做成功
+     * 内置重试机制,最多60s
+     * @param reqData
+     * @param connectTimeoutMs
+     * @return
+     * @throws Exception
+     */
+    public Map<String, String> microPayWithPos(Map<String, String> reqData, int connectTimeoutMs) throws Exception {
+        int remainingTimeMs = 60*1000;
+        long startTimestampMs = 0;
+        Map<String, String> lastResult = null;
+        Exception lastException = null;
+
+        while (true) {
+            startTimestampMs = WXPayUtil.getCurrentTimestampMs();
+            int readTimeoutMs = remainingTimeMs - connectTimeoutMs;
+            if (readTimeoutMs > 1000) {
+                try {
+                    lastResult = this.microPay(reqData, connectTimeoutMs, readTimeoutMs);
+                    String returnCode = lastResult.get("return_code");
+                    if (returnCode.equals("SUCCESS")) {
+                        String resultCode = lastResult.get("result_code");
+                        String errCode = lastResult.get("err_code");
+                        if (resultCode.equals("SUCCESS")) {
+                            break;
+                        }
+                        else {
+                            // 看错误码,若支付结果未知,则重试提交刷卡支付
+                            if (errCode.equals("SYSTEMERROR") || errCode.equals("BANKERROR") || errCode.equals("USERPAYING")) {
+                                remainingTimeMs = remainingTimeMs - (int)(WXPayUtil.getCurrentTimestampMs() - startTimestampMs);
+                                if (remainingTimeMs <= 100) {
+                                    break;
+                                }
+                                else {
+                                    WXPayUtil.getLogger().info("microPayWithPos: try micropay again");
+                                    if (remainingTimeMs > 5*1000) {
+                                        Thread.sleep(5*1000);
+                                    }
+                                    else {
+                                        Thread.sleep(1*1000);
+                                    }
+                                    continue;
+                                }
+                            }
+                            else {
+                                break;
+                            }
+                        }
+                    }
+                    else {
+                        break;
+                    }
+                }
+                catch (Exception ex) {
+                    lastResult = null;
+                    lastException = ex;
+                }
+            }
+            else {
+                break;
+            }
+        }
+
+        if (lastResult == null) {
+            throw lastException;
+        }
+        else {
+            return lastResult;
+        }
+    }
+
+
+
+    /**
+     * 作用:统一下单<br>
+     * 场景:公共号支付、扫码支付、APP支付
+     * @param reqData 向wxpay post的请求数据
+     * @return API返回数据
+     * @throws Exception
+     */
+    public Map<String, String> unifiedOrder(Map<String, String> reqData) throws Exception {
+        return this.unifiedOrder(reqData, config.getHttpConnectTimeoutMs(), this.config.getHttpReadTimeoutMs());
+    }
+
+
+    /**
+     * 作用:统一下单<br>
+     * 场景:公共号支付、扫码支付、APP支付
+     * @param reqData 向wxpay post的请求数据
+     * @param connectTimeoutMs 连接超时时间,单位是毫秒
+     * @param readTimeoutMs 读超时时间,单位是毫秒
+     * @return API返回数据
+     * @throws Exception
+     */
+    public Map<String, String> unifiedOrder(Map<String, String> reqData,  int connectTimeoutMs, int readTimeoutMs) throws Exception {
+        String url;
+        if (this.useSandbox) {
+            url = WXPayConstants.SANDBOX_UNIFIEDORDER_URL_SUFFIX;
+        }
+        else {
+            url = WXPayConstants.UNIFIEDORDER_URL_SUFFIX;
+        }
+//        if(this.notifyUrl != null) {
+//            reqData.put("notify_url", this.notifyUrl);
+//        }
+        String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
+        return this.processResponseXml(respXml);
+    }
+
+
+    /**
+     * 作用:查询订单<br>
+     * 场景:刷卡支付、公共号支付、扫码支付、APP支付
+     * @param reqData 向wxpay post的请求数据
+     * @return API返回数据
+     * @throws Exception
+     */
+    public Map<String, String> orderQuery(Map<String, String> reqData) throws Exception {
+        return this.orderQuery(reqData, config.getHttpConnectTimeoutMs(), this.config.getHttpReadTimeoutMs());
+    }
+
+
+    /**
+     * 作用:查询订单<br>
+     * 场景:刷卡支付、公共号支付、扫码支付、APP支付
+     * @param reqData 向wxpay post的请求数据 int
+     * @param connectTimeoutMs 连接超时时间,单位是毫秒
+     * @param readTimeoutMs 读超时时间,单位是毫秒
+     * @return API返回数据
+     * @throws Exception
+     */
+    public Map<String, String> orderQuery(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception {
+        String url;
+        if (this.useSandbox) {
+            url = WXPayConstants.SANDBOX_ORDERQUERY_URL_SUFFIX;
+        }
+        else {
+            url = WXPayConstants.ORDERQUERY_URL_SUFFIX;
+        }
+        String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
+        return this.processResponseXml(respXml);
+    }
+
+
+    /**
+     * 作用:撤销订单<br>
+     * 场景:刷卡支付
+     * @param reqData 向wxpay post的请求数据
+     * @return API返回数据
+     * @throws Exception
+     */
+    public Map<String, String> reverse(Map<String, String> reqData) throws Exception {
+        return this.reverse(reqData, config.getHttpConnectTimeoutMs(), this.config.getHttpReadTimeoutMs());
+    }
+
+
+    /**
+     * 作用:撤销订单<br>
+     * 场景:刷卡支付<br>
+     * 其他:需要证书
+     * @param reqData 向wxpay post的请求数据
+     * @param connectTimeoutMs 连接超时时间,单位是毫秒
+     * @param readTimeoutMs 读超时时间,单位是毫秒
+     * @return API返回数据
+     * @throws Exception
+     */
+    public Map<String, String> reverse(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception {
+        String url;
+        if (this.useSandbox) {
+            url = WXPayConstants.SANDBOX_REVERSE_URL_SUFFIX;
+        }
+        else {
+            url = WXPayConstants.REVERSE_URL_SUFFIX;
+        }
+        String respXml = this.requestWithCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
+        return this.processResponseXml(respXml);
+    }
+
+
+    /**
+     * 作用:关闭订单<br>
+     * 场景:公共号支付、扫码支付、APP支付
+     * @param reqData 向wxpay post的请求数据
+     * @return API返回数据
+     * @throws Exception
+     */
+    public Map<String, String> closeOrder(Map<String, String> reqData) throws Exception {
+        return this.closeOrder(reqData, config.getHttpConnectTimeoutMs(), this.config.getHttpReadTimeoutMs());
+    }
+
+
+    /**
+     * 作用:关闭订单<br>
+     * 场景:公共号支付、扫码支付、APP支付
+     * @param reqData 向wxpay post的请求数据
+     * @param connectTimeoutMs 连接超时时间,单位是毫秒
+     * @param readTimeoutMs 读超时时间,单位是毫秒
+     * @return API返回数据
+     * @throws Exception
+     */
+    public Map<String, String> closeOrder(Map<String, String> reqData,  int connectTimeoutMs, int readTimeoutMs) throws Exception {
+        String url;
+        if (this.useSandbox) {
+            url = WXPayConstants.SANDBOX_CLOSEORDER_URL_SUFFIX;
+        }
+        else {
+            url = WXPayConstants.CLOSEORDER_URL_SUFFIX;
+        }
+        String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
+        return this.processResponseXml(respXml);
+    }
+
+
+    /**
+     * 作用:申请退款<br>
+     * 场景:刷卡支付、公共号支付、扫码支付、APP支付
+     * @param reqData 向wxpay post的请求数据
+     * @return API返回数据
+     * @throws Exception
+     */
+    public Map<String, String> refund(Map<String, String> reqData) throws Exception {
+        return this.refund(reqData, this.config.getHttpConnectTimeoutMs(), this.config.getHttpReadTimeoutMs());
+    }
+
+
+    /**
+     * 作用:申请退款<br>
+     * 场景:刷卡支付、公共号支付、扫码支付、APP支付<br>
+     * 其他:需要证书
+     * @param reqData 向wxpay post的请求数据
+     * @param connectTimeoutMs 连接超时时间,单位是毫秒
+     * @param readTimeoutMs 读超时时间,单位是毫秒
+     * @return API返回数据
+     * @throws Exception
+     */
+    public Map<String, String> refund(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception {
+        String url;
+        if (this.useSandbox) {
+            url = WXPayConstants.SANDBOX_REFUND_URL_SUFFIX;
+        }
+        else {
+            url = WXPayConstants.REFUND_URL_SUFFIX;
+        }
+        String respXml = this.requestWithCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
+        return this.processResponseXml(respXml);
+    }
+
+
+    /**
+     * 作用:退款查询<br>
+     * 场景:刷卡支付、公共号支付、扫码支付、APP支付
+     * @param reqData 向wxpay post的请求数据
+     * @return API返回数据
+     * @throws Exception
+     */
+    public Map<String, String> refundQuery(Map<String, String> reqData) throws Exception {
+        return this.refundQuery(reqData, this.config.getHttpConnectTimeoutMs(), this.config.getHttpReadTimeoutMs());
+    }
+
+
+    /**
+     * 作用:退款查询<br>
+     * 场景:刷卡支付、公共号支付、扫码支付、APP支付
+     * @param reqData 向wxpay post的请求数据
+     * @param connectTimeoutMs 连接超时时间,单位是毫秒
+     * @param readTimeoutMs 读超时时间,单位是毫秒
+     * @return API返回数据
+     * @throws Exception
+     */
+    public Map<String, String> refundQuery(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception {
+        String url;
+        if (this.useSandbox) {
+            url = WXPayConstants.SANDBOX_REFUNDQUERY_URL_SUFFIX;
+        }
+        else {
+            url = WXPayConstants.REFUNDQUERY_URL_SUFFIX;
+        }
+        String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
+        return this.processResponseXml(respXml);
+    }
+
+
+    /**
+     * 作用:对账单下载(成功时返回对账单数据,失败时返回XML格式数据)<br>
+     * 场景:刷卡支付、公共号支付、扫码支付、APP支付
+     * @param reqData 向wxpay post的请求数据
+     * @return API返回数据
+     * @throws Exception
+     */
+    public Map<String, String> downloadBill(Map<String, String> reqData) throws Exception {
+        return this.downloadBill(reqData, this.config.getHttpConnectTimeoutMs(), this.config.getHttpReadTimeoutMs());
+    }
+
+
+    /**
+     * 作用:对账单下载<br>
+     * 场景:刷卡支付、公共号支付、扫码支付、APP支付<br>
+     * 其他:无论是否成功都返回Map。若成功,返回的Map中含有return_code、return_msg、data,
+     *      其中return_code为`SUCCESS`,data为对账单数据。
+     * @param reqData 向wxpay post的请求数据
+     * @param connectTimeoutMs 连接超时时间,单位是毫秒
+     * @param readTimeoutMs 读超时时间,单位是毫秒
+     * @return 经过封装的API返回数据
+     * @throws Exception
+     */
+    public Map<String, String> downloadBill(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception {
+        String url;
+        if (this.useSandbox) {
+            url = WXPayConstants.SANDBOX_DOWNLOADBILL_URL_SUFFIX;
+        }
+        else {
+            url = WXPayConstants.DOWNLOADBILL_URL_SUFFIX;
+        }
+        String respStr = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs).trim();
+        Map<String, String> ret;
+        // 出现错误,返回XML数据
+        if (respStr.indexOf("<") == 0) {
+            ret = WXPayUtil.xmlToMap(respStr);
+        }
+        else {
+            // 正常返回csv数据
+            ret = new HashMap<String, String>();
+            ret.put("return_code", WXPayConstants.SUCCESS);
+            ret.put("return_msg", "ok");
+            ret.put("data", respStr);
+        }
+        return ret;
+    }
+
+
+    /**
+     * 作用:交易保障<br>
+     * 场景:刷卡支付、公共号支付、扫码支付、APP支付
+     * @param reqData 向wxpay post的请求数据
+     * @return API返回数据
+     * @throws Exception
+     */
+    public Map<String, String> report(Map<String, String> reqData) throws Exception {
+        return this.report(reqData, this.config.getHttpConnectTimeoutMs(), this.config.getHttpReadTimeoutMs());
+    }
+
+
+    /**
+     * 作用:交易保障<br>
+     * 场景:刷卡支付、公共号支付、扫码支付、APP支付
+     * @param reqData 向wxpay post的请求数据
+     * @param connectTimeoutMs 连接超时时间,单位是毫秒
+     * @param readTimeoutMs 读超时时间,单位是毫秒
+     * @return API返回数据
+     * @throws Exception
+     */
+    public Map<String, String> report(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception {
+        String url;
+        if (this.useSandbox) {
+            url = WXPayConstants.SANDBOX_REPORT_URL_SUFFIX;
+        }
+        else {
+            url = WXPayConstants.REPORT_URL_SUFFIX;
+        }
+        String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
+        return WXPayUtil.xmlToMap(respXml);
+    }
+
+
+    /**
+     * 作用:转换短链接<br>
+     * 场景:刷卡支付、扫码支付
+     * @param reqData 向wxpay post的请求数据
+     * @return API返回数据
+     * @throws Exception
+     */
+    public Map<String, String> shortUrl(Map<String, String> reqData) throws Exception {
+        return this.shortUrl(reqData, this.config.getHttpConnectTimeoutMs(), this.config.getHttpReadTimeoutMs());
+    }
+
+
+    /**
+     * 作用:转换短链接<br>
+     * 场景:刷卡支付、扫码支付
+     * @param reqData 向wxpay post的请求数据
+     * @return API返回数据
+     * @throws Exception
+     */
+    public Map<String, String> shortUrl(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception {
+        String url;
+        if (this.useSandbox) {
+            url = WXPayConstants.SANDBOX_SHORTURL_URL_SUFFIX;
+        }
+        else {
+            url = WXPayConstants.SHORTURL_URL_SUFFIX;
+        }
+        String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
+        return this.processResponseXml(respXml);
+    }
+
+
+    /**
+     * 作用:授权码查询OPENID接口<br>
+     * 场景:刷卡支付
+     * @param reqData 向wxpay post的请求数据
+     * @return API返回数据
+     * @throws Exception
+     */
+    public Map<String, String> authCodeToOpenid(Map<String, String> reqData) throws Exception {
+        return this.authCodeToOpenid(reqData, this.config.getHttpConnectTimeoutMs(), this.config.getHttpReadTimeoutMs());
+    }
+
+
+    /**
+     * 作用:授权码查询OPENID接口<br>
+     * 场景:刷卡支付
+     * @param reqData 向wxpay post的请求数据
+     * @param connectTimeoutMs 连接超时时间,单位是毫秒
+     * @param readTimeoutMs 读超时时间,单位是毫秒
+     * @return API返回数据
+     * @throws Exception
+     */
+    public Map<String, String> authCodeToOpenid(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception {
+        String url;
+        if (this.useSandbox) {
+            url = WXPayConstants.SANDBOX_AUTHCODETOOPENID_URL_SUFFIX;
+        }
+        else {
+            url = WXPayConstants.AUTHCODETOOPENID_URL_SUFFIX;
+        }
+        String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
+        return this.processResponseXml(respXml);
+    }
+
+
+} // end class

+ 105 - 0
src/main/java/com/kede/sdk/service/WXPayConfig.java

@@ -0,0 +1,105 @@
+package com.kede.sdk.service;
+
+import java.io.InputStream;
+
+import com.kede.sdk.IWXPayDomain;
+
+public abstract class WXPayConfig {
+
+
+
+    /**
+     * 获取 App ID
+     *
+     * @return App ID
+     */
+    abstract String getAppID();
+
+
+    /**
+     * 获取 Mch ID
+     *
+     * @return Mch ID
+     */
+    abstract String getMchID();
+
+
+    /**
+     * 获取 API 密钥
+     *
+     * @return API密钥
+     */
+    abstract String getKey();
+
+
+    /**
+     * 获取商户证书内容
+     *
+     * @return 商户证书内容
+     */
+    abstract InputStream getCertStream();
+
+    /**
+     * HTTP(S) 连接超时时间,单位毫秒
+     *
+     * @return
+     */
+    public int getHttpConnectTimeoutMs() {
+        return 6*1000;
+    }
+
+    /**
+     * HTTP(S) 读数据超时时间,单位毫秒
+     *
+     * @return
+     */
+    public int getHttpReadTimeoutMs() {
+        return 8*1000;
+    }
+
+    /**
+     * 获取WXPayDomain, 用于多域名容灾自动切换
+     * @return
+     */
+    abstract IWXPayDomain getWXPayDomain();
+
+    /**
+     * 是否自动上报。
+     * 若要关闭自动上报,子类中实现该函数返回 false 即可。
+     *
+     * @return
+     */
+    public boolean shouldAutoReport() {
+        return true;
+    }
+
+    /**
+     * 进行健康上报的线程的数量
+     *
+     * @return
+     */
+    public int getReportWorkerNum() {
+        return 6;
+    }
+
+
+    /**
+     * 健康上报缓存消息的最大数量。会有线程去独立上报
+     * 粗略计算:加入一条消息200B,10000消息占用空间 2000 KB,约为2MB,可以接受
+     *
+     * @return
+     */
+    public int getReportQueueMaxSize() {
+        return 10000;
+    }
+
+    /**
+     * 批量上报,一次最多上报多个数据
+     *
+     * @return
+     */
+    public int getReportBatchSize() {
+        return 10;
+    }
+
+}

+ 268 - 0
src/main/java/com/kede/sdk/service/WXPayReport.java

@@ -0,0 +1,268 @@
+package com.kede.sdk.service;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.config.RegistryBuilder;
+import org.apache.http.conn.socket.ConnectionSocketFactory;
+import org.apache.http.conn.socket.PlainConnectionSocketFactory;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.impl.conn.BasicHttpClientConnectionManager;
+import org.apache.http.util.EntityUtils;
+
+import com.kede.sdk.WXPayConstants;
+import com.kede.sdk.WXPayUtil;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ThreadFactory;
+
+/**
+ * 交易保障
+ */
+public class WXPayReport {
+
+    public static class ReportInfo {
+
+        /**
+         * 布尔变量使用int。0为false, 1为true。
+         */
+
+        // 基本信息
+        private String version = "v1";
+        private String sdk = WXPayConstants.WXPAYSDK_VERSION;
+        private String uuid;  // 交易的标识
+        private long timestamp;   // 上报时的时间戳,单位秒
+        private long elapsedTimeMillis; // 耗时,单位 毫秒
+
+        // 针对主域名
+        private String firstDomain;  // 第1次请求的域名
+        private boolean primaryDomain; //是否主域名
+        private int firstConnectTimeoutMillis;  // 第1次请求设置的连接超时时间,单位 毫秒
+        private int firstReadTimeoutMillis;  // 第1次请求设置的读写超时时间,单位 毫秒
+        private int firstHasDnsError;  // 第1次请求是否出现dns问题
+        private int firstHasConnectTimeout; // 第1次请求是否出现连接超时
+        private int firstHasReadTimeout; // 第1次请求是否出现连接超时
+
+        public ReportInfo(String uuid, long timestamp, long elapsedTimeMillis, String firstDomain, boolean primaryDomain, int firstConnectTimeoutMillis, int firstReadTimeoutMillis, boolean firstHasDnsError, boolean firstHasConnectTimeout, boolean firstHasReadTimeout) {
+            this.uuid = uuid;
+            this.timestamp = timestamp;
+            this.elapsedTimeMillis = elapsedTimeMillis;
+            this.firstDomain = firstDomain;
+            this.primaryDomain = primaryDomain;
+            this.firstConnectTimeoutMillis = firstConnectTimeoutMillis;
+            this.firstReadTimeoutMillis = firstReadTimeoutMillis;
+            this.firstHasDnsError = firstHasDnsError?1:0;
+            this.firstHasConnectTimeout = firstHasConnectTimeout?1:0;
+            this.firstHasReadTimeout = firstHasReadTimeout?1:0;
+         }
+
+        @Override
+        public String toString() {
+            return "ReportInfo{" +
+                    "version='" + version + '\'' +
+                    ", sdk='" + sdk + '\'' +
+                    ", uuid='" + uuid + '\'' +
+                    ", timestamp=" + timestamp +
+                    ", elapsedTimeMillis=" + elapsedTimeMillis +
+                    ", firstDomain='" + firstDomain + '\'' +
+                    ", primaryDomain=" + primaryDomain +
+                    ", firstConnectTimeoutMillis=" + firstConnectTimeoutMillis +
+                    ", firstReadTimeoutMillis=" + firstReadTimeoutMillis +
+                    ", firstHasDnsError=" + firstHasDnsError +
+                    ", firstHasConnectTimeout=" + firstHasConnectTimeout +
+                    ", firstHasReadTimeout=" + firstHasReadTimeout +
+                    '}';
+        }
+
+        /**
+         * 转换成 csv 格式
+         *
+         * @return
+         */
+        public String toLineString(String key) {
+            String separator = ",";
+            Object[] objects = new Object[] {
+                version, sdk, uuid, timestamp, elapsedTimeMillis,
+                    firstDomain, primaryDomain, firstConnectTimeoutMillis, firstReadTimeoutMillis,
+                    firstHasDnsError, firstHasConnectTimeout, firstHasReadTimeout
+            };
+            StringBuffer sb = new StringBuffer();
+            for(Object obj: objects) {
+                sb.append(obj).append(separator);
+            }
+            try {
+                String sign = WXPayUtil.HMACSHA256(sb.toString(), key);
+                sb.append(sign);
+                return sb.toString();
+            }
+            catch (Exception ex) {
+                return null;
+            }
+
+        }
+
+    }
+
+    private static final String REPORT_URL = "http://report.mch.weixin.qq.com/wxpay/report/default";
+    // private static final String REPORT_URL = "http://127.0.0.1:5000/test";
+
+
+    private static final int DEFAULT_CONNECT_TIMEOUT_MS = 6*1000;
+    private static final int DEFAULT_READ_TIMEOUT_MS = 8*1000;
+
+    private LinkedBlockingQueue<String> reportMsgQueue = null;
+    private WXPayConfig config;
+    private ExecutorService executorService;
+
+    private volatile static WXPayReport INSTANCE;
+
+    private WXPayReport(final WXPayConfig config) {
+        this.config = config;
+        reportMsgQueue = new LinkedBlockingQueue<String>(config.getReportQueueMaxSize());
+
+        // 添加处理线程
+        executorService = Executors.newFixedThreadPool(config.getReportWorkerNum(), new ThreadFactory() {
+            public Thread newThread(Runnable r) {
+                Thread t = Executors.defaultThreadFactory().newThread(r);
+                t.setDaemon(true);
+                return t;
+            }
+        });
+
+        if (config.shouldAutoReport()) {
+            WXPayUtil.getLogger().info("report worker num: {}", config.getReportWorkerNum());
+            for (int i = 0; i < config.getReportWorkerNum(); ++i) {
+                executorService.execute(new Runnable() {
+                    public void run() {
+                        while (true) {
+                            // 先用 take 获取数据
+                            try {
+                                StringBuffer sb = new StringBuffer();
+                                String firstMsg = reportMsgQueue.take();
+                                WXPayUtil.getLogger().info("get first report msg: {}", firstMsg);
+                                String msg = null;
+                                sb.append(firstMsg); //会阻塞至有消息
+                                int remainNum = config.getReportBatchSize() - 1;
+                                for (int j=0; j<remainNum; ++j) {
+                                    WXPayUtil.getLogger().info("try get remain report msg");
+                                    // msg = reportMsgQueue.poll();  // 不阻塞了
+                                    msg = reportMsgQueue.take();
+                                    WXPayUtil.getLogger().info("get remain report msg: {}", msg);
+                                    if (msg == null) {
+                                        break;
+                                    }
+                                    else {
+                                        sb.append("\n");
+                                        sb.append(msg);
+                                    }
+                                }
+                                // 上报
+                                WXPayReport.httpRequest(sb.toString(), DEFAULT_CONNECT_TIMEOUT_MS, DEFAULT_READ_TIMEOUT_MS);
+                            }
+                            catch (Exception ex) {
+                                WXPayUtil.getLogger().warn("report fail. reason: {}", ex.getMessage());
+                            }
+                        }
+                    }
+                });
+            }
+        }
+
+    }
+
+    /**
+     * 单例,双重校验,请在 JDK 1.5及更高版本中使用
+     *
+     * @param config
+     * @return
+     */
+    public static WXPayReport getInstance(WXPayConfig config) {
+        if (INSTANCE == null) {
+            synchronized (WXPayReport.class) {
+                if (INSTANCE == null) {
+                    INSTANCE = new WXPayReport(config);
+                }
+            }
+        }
+        return INSTANCE;
+    }
+
+    public void report(String uuid, long elapsedTimeMillis,
+                       String firstDomain, boolean primaryDomain, int firstConnectTimeoutMillis, int firstReadTimeoutMillis,
+                       boolean firstHasDnsError, boolean firstHasConnectTimeout, boolean firstHasReadTimeout) {
+        long currentTimestamp = WXPayUtil.getCurrentTimestamp();
+        ReportInfo reportInfo = new ReportInfo(uuid, currentTimestamp, elapsedTimeMillis,
+                firstDomain, primaryDomain, firstConnectTimeoutMillis, firstReadTimeoutMillis,
+                firstHasDnsError, firstHasConnectTimeout, firstHasReadTimeout);
+        String data = reportInfo.toLineString(config.getKey());
+        WXPayUtil.getLogger().info("report {}", data);
+        if (data != null) {
+            reportMsgQueue.offer(data);
+        }
+    }
+
+
+    @Deprecated
+    private void reportSync(final String data) throws Exception {
+        httpRequest(data, DEFAULT_CONNECT_TIMEOUT_MS, DEFAULT_READ_TIMEOUT_MS);
+    }
+
+    @Deprecated
+    private void reportAsync(final String data) throws Exception {
+        new Thread(new Runnable() {
+            public void run() {
+                try {
+                    httpRequest(data, DEFAULT_CONNECT_TIMEOUT_MS, DEFAULT_READ_TIMEOUT_MS);
+                }
+                catch (Exception ex) {
+                    WXPayUtil.getLogger().warn("report fail. reason: {}", ex.getMessage());
+                }
+            }
+        }).start();
+    }
+
+    /**
+     * http 请求
+     * @param data
+     * @param connectTimeoutMs
+     * @param readTimeoutMs
+     * @return
+     * @throws Exception
+     */
+    private static String httpRequest(String data, int connectTimeoutMs, int readTimeoutMs) throws Exception{
+        BasicHttpClientConnectionManager connManager;
+        connManager = new BasicHttpClientConnectionManager(
+                RegistryBuilder.<ConnectionSocketFactory>create()
+                        .register("http", PlainConnectionSocketFactory.getSocketFactory())
+                        .register("https", SSLConnectionSocketFactory.getSocketFactory())
+                        .build(),
+                null,
+                null,
+                null
+        );
+        HttpClient httpClient = HttpClientBuilder.create()
+                .setConnectionManager(connManager)
+                .build();
+
+        HttpPost httpPost = new HttpPost(REPORT_URL);
+
+        RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(readTimeoutMs).setConnectTimeout(connectTimeoutMs).build();
+        httpPost.setConfig(requestConfig);
+
+        StringEntity postEntity = new StringEntity(data, "UTF-8");
+        httpPost.addHeader("Content-Type", "text/xml");
+        httpPost.addHeader("User-Agent", WXPayConstants.USER_AGENT);
+        httpPost.setEntity(postEntity);
+
+        HttpResponse httpResponse = httpClient.execute(httpPost);
+        HttpEntity httpEntity = httpResponse.getEntity();
+        return EntityUtils.toString(httpEntity, "UTF-8");
+    }
+
+}

+ 262 - 0
src/main/java/com/kede/sdk/service/WXPayRequest.java

@@ -0,0 +1,262 @@
+package com.kede.sdk.service;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.config.RegistryBuilder;
+import org.apache.http.conn.ConnectTimeoutException;
+import org.apache.http.conn.socket.ConnectionSocketFactory;
+import org.apache.http.conn.socket.PlainConnectionSocketFactory;
+import org.apache.http.conn.ssl.DefaultHostnameVerifier;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.impl.conn.BasicHttpClientConnectionManager;
+import org.apache.http.util.EntityUtils;
+
+import com.kede.sdk.IWXPayDomain;
+import com.kede.sdk.WXPayUtil;
+import com.kede.sdk.IWXPayDomain.DomainInfo;
+
+import javax.net.ssl.KeyManagerFactory;
+import javax.net.ssl.SSLContext;
+import java.io.InputStream;
+import java.net.SocketTimeoutException;
+import java.net.UnknownHostException;
+import java.security.KeyStore;
+import java.security.SecureRandom;
+
+import static com.kede.sdk.WXPayConstants.USER_AGENT;
+
+public class WXPayRequest {
+    private WXPayConfig config;
+    public WXPayRequest(WXPayConfig config) throws Exception{
+
+        this.config = config;
+    }
+
+    /**
+     * 请求,只请求一次,不做重试
+     * @param domain
+     * @param urlSuffix
+     * @param uuid
+     * @param data
+     * @param connectTimeoutMs
+     * @param readTimeoutMs
+     * @param useCert 是否使用证书,针对退款、撤销等操作
+     * @return
+     * @throws Exception
+     */
+    private String requestOnce(final String domain, String urlSuffix, String uuid, String data, int connectTimeoutMs, int readTimeoutMs, boolean useCert) throws Exception {
+        BasicHttpClientConnectionManager connManager;
+        if (useCert) {
+            // 证书
+            char[] password = config.getMchID().toCharArray();
+            InputStream certStream = config.getCertStream();
+            KeyStore ks = KeyStore.getInstance("PKCS12");
+            ks.load(certStream, password);
+
+            // 实例化密钥库 & 初始化密钥工厂
+            KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
+            kmf.init(ks, password);
+
+            // 创建 SSLContext
+            SSLContext sslContext = SSLContext.getInstance("TLS");
+            sslContext.init(kmf.getKeyManagers(), null, new SecureRandom());
+
+            SSLConnectionSocketFactory sslConnectionSocketFactory = new SSLConnectionSocketFactory(
+                    sslContext,
+                    new String[]{"TLSv1"},
+                    null,
+                    new DefaultHostnameVerifier());
+
+            connManager = new BasicHttpClientConnectionManager(
+                    RegistryBuilder.<ConnectionSocketFactory>create()
+                            .register("http", PlainConnectionSocketFactory.getSocketFactory())
+                            .register("https", sslConnectionSocketFactory)
+                            .build(),
+                    null,
+                    null,
+                    null
+            );
+        }
+        else {
+            connManager = new BasicHttpClientConnectionManager(
+                    RegistryBuilder.<ConnectionSocketFactory>create()
+                            .register("http", PlainConnectionSocketFactory.getSocketFactory())
+                            .register("https", SSLConnectionSocketFactory.getSocketFactory())
+                            .build(),
+                    null,
+                    null,
+                    null
+            );
+        }
+
+        HttpClient httpClient = HttpClientBuilder.create()
+                .setConnectionManager(connManager)
+                .build();
+
+        String url = "https://" + domain + urlSuffix;
+        HttpPost httpPost = new HttpPost(url);
+
+        RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(readTimeoutMs).setConnectTimeout(connectTimeoutMs).build();
+        httpPost.setConfig(requestConfig);
+
+        StringEntity postEntity = new StringEntity(data, "UTF-8");
+        httpPost.addHeader("Content-Type", "text/xml");
+        httpPost.addHeader("User-Agent", USER_AGENT + " " + config.getMchID());
+        httpPost.setEntity(postEntity);
+
+        HttpResponse httpResponse = httpClient.execute(httpPost);
+        HttpEntity httpEntity = httpResponse.getEntity();
+        return EntityUtils.toString(httpEntity, "UTF-8");
+
+    }
+
+
+    private String request(String urlSuffix, String uuid, String data, int connectTimeoutMs, int readTimeoutMs, boolean useCert, boolean autoReport) throws Exception {
+        Exception exception = null;
+        long elapsedTimeMillis = 0;
+        long startTimestampMs = WXPayUtil.getCurrentTimestampMs();
+        boolean firstHasDnsErr = false;
+        boolean firstHasConnectTimeout = false;
+        boolean firstHasReadTimeout = false;
+        IWXPayDomain.DomainInfo domainInfo = config.getWXPayDomain().getDomain(config);
+        if(domainInfo == null){
+            throw new Exception("WXPayConfig.getWXPayDomain().getDomain() is empty or null");
+        }
+        try {
+            String result = requestOnce(domainInfo.domain, urlSuffix, uuid, data, connectTimeoutMs, readTimeoutMs, useCert);
+            elapsedTimeMillis = WXPayUtil.getCurrentTimestampMs()-startTimestampMs;
+            config.getWXPayDomain().report(domainInfo.domain, elapsedTimeMillis, null);
+            WXPayReport.getInstance(config).report(
+                    uuid,
+                    elapsedTimeMillis,
+                    domainInfo.domain,
+                    domainInfo.primaryDomain,
+                    connectTimeoutMs,
+                    readTimeoutMs,
+                    firstHasDnsErr,
+                    firstHasConnectTimeout,
+                    firstHasReadTimeout);
+            return result;
+        }
+        catch (UnknownHostException ex) {  // dns 解析错误,或域名不存在
+            exception = ex;
+            firstHasDnsErr = true;
+            elapsedTimeMillis = WXPayUtil.getCurrentTimestampMs()-startTimestampMs;
+            WXPayUtil.getLogger().warn("UnknownHostException for domainInfo {}", domainInfo);
+            WXPayReport.getInstance(config).report(
+                    uuid,
+                    elapsedTimeMillis,
+                    domainInfo.domain,
+                    domainInfo.primaryDomain,
+                    connectTimeoutMs,
+                    readTimeoutMs,
+                    firstHasDnsErr,
+                    firstHasConnectTimeout,
+                    firstHasReadTimeout
+            );
+        }
+        catch (ConnectTimeoutException ex) {
+            exception = ex;
+            firstHasConnectTimeout = true;
+            elapsedTimeMillis = WXPayUtil.getCurrentTimestampMs()-startTimestampMs;
+            WXPayUtil.getLogger().warn("connect timeout happened for domainInfo {}", domainInfo);
+            WXPayReport.getInstance(config).report(
+                    uuid,
+                    elapsedTimeMillis,
+                    domainInfo.domain,
+                    domainInfo.primaryDomain,
+                    connectTimeoutMs,
+                    readTimeoutMs,
+                    firstHasDnsErr,
+                    firstHasConnectTimeout,
+                    firstHasReadTimeout
+            );
+        }
+        catch (SocketTimeoutException ex) {
+            exception = ex;
+            firstHasReadTimeout = true;
+            elapsedTimeMillis = WXPayUtil.getCurrentTimestampMs()-startTimestampMs;
+            WXPayUtil.getLogger().warn("timeout happened for domainInfo {}", domainInfo);
+            WXPayReport.getInstance(config).report(
+                    uuid,
+                    elapsedTimeMillis,
+                    domainInfo.domain,
+                    domainInfo.primaryDomain,
+                    connectTimeoutMs,
+                    readTimeoutMs,
+                    firstHasDnsErr,
+                    firstHasConnectTimeout,
+                    firstHasReadTimeout);
+        }
+        catch (Exception ex) {
+            exception = ex;
+            elapsedTimeMillis = WXPayUtil.getCurrentTimestampMs()-startTimestampMs;
+            WXPayReport.getInstance(config).report(
+                    uuid,
+                    elapsedTimeMillis,
+                    domainInfo.domain,
+                    domainInfo.primaryDomain,
+                    connectTimeoutMs,
+                    readTimeoutMs,
+                    firstHasDnsErr,
+                    firstHasConnectTimeout,
+                    firstHasReadTimeout);
+        }
+        config.getWXPayDomain().report(domainInfo.domain, elapsedTimeMillis, exception);
+        throw exception;
+    }
+
+
+    /**
+     * 可重试的,非双向认证的请求
+     * @param urlSuffix
+     * @param uuid
+     * @param data
+     * @return
+     */
+    public String requestWithoutCert(String urlSuffix, String uuid, String data, boolean autoReport) throws Exception {
+        return this.request(urlSuffix, uuid, data, config.getHttpConnectTimeoutMs(), config.getHttpReadTimeoutMs(), false, autoReport);
+    }
+
+    /**
+     * 可重试的,非双向认证的请求
+     * @param urlSuffix
+     * @param uuid
+     * @param data
+     * @param connectTimeoutMs
+     * @param readTimeoutMs
+     * @return
+     */
+    public String requestWithoutCert(String urlSuffix, String uuid, String data, int connectTimeoutMs, int readTimeoutMs,  boolean autoReport) throws Exception {
+        return this.request(urlSuffix, uuid, data, connectTimeoutMs, readTimeoutMs, false, autoReport);
+    }
+
+    /**
+     * 可重试的,双向认证的请求
+     * @param urlSuffix
+     * @param uuid
+     * @param data
+     * @return
+     */
+    public String requestWithCert(String urlSuffix, String uuid, String data, boolean autoReport) throws Exception {
+        return this.request(urlSuffix, uuid, data, config.getHttpConnectTimeoutMs(), config.getHttpReadTimeoutMs(), true, autoReport);
+    }
+
+    /**
+     * 可重试的,双向认证的请求
+     * @param urlSuffix
+     * @param uuid
+     * @param data
+     * @param connectTimeoutMs
+     * @param readTimeoutMs
+     * @return
+     */
+    public String requestWithCert(String urlSuffix, String uuid, String data, int connectTimeoutMs, int readTimeoutMs, boolean autoReport) throws Exception {
+        return this.request(urlSuffix, uuid, data, connectTimeoutMs, readTimeoutMs, true, autoReport);
+    }
+}

+ 195 - 0
src/main/java/com/kede/sdk/service/WxService.java

@@ -0,0 +1,195 @@
+package com.kede.sdk.service;
+
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.net.InetAddress;
+import java.security.GeneralSecurityException;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.kede.admin.service.OrderService;
+import com.kede.common.bo.CallBackBo;
+import com.kede.common.dao.OrderMapper;
+import com.kede.common.error.BusinessException;
+import com.kede.common.model.Order;
+import com.kede.common.model.Project;
+import com.kede.common.utils.LoggerUtils;
+import com.kede.common.utils.StringUtils;
+import com.kede.common.utils.WxAPIV3AesUtil;
+import com.kede.core.mybatis.JDBCIdGenerator;
+import com.kede.core.shiro.token.TokenManager;
+import com.kede.sdk.WXPayUtil;
+
+@Service
+public class WxService {
+	
+	
+	@Value(value = "${wx.appId}")
+	private String appId;
+	@Value(value = "${wx.appSecret}")
+	private String appSecret;
+	@Value(value = "${wx.mchId}")
+	private String mchId;
+	@Value(value = "${wx.apiKiy}")
+	private String apiKiy;
+	@Value(value = "${wx.notifyUrl}")
+	private String notifyUrl;
+	@Value(value = "${wx.apiv3}")
+	private String apiv3;
+	
+	@Autowired
+	private JDBCIdGenerator	idGenerator;
+	@Autowired
+	private OrderService	orderService;
+	@Autowired
+	private OrderMapper	orderMapper;
+	
+	/**
+	 * 	下单
+	 * @param p
+	 * @return
+	 */
+	public Map<String , String > pushUnifiedOrder(Project p){
+				WXPay wxpay = null;
+				Map<String, String> map=new HashMap<>();
+				try {
+					IWxPayConfig iWxPayConfig=new IWxPayConfig(appId,mchId,apiKiy);
+				    wxpay = new WXPay(iWxPayConfig,null, true, false); // *** 注入自己实现的微信配置类, 创建WXPay核心类, WXPay 包括统一下单接口
+					InetAddress addr = InetAddress.getLocalHost();
+					String ip = addr.getHostAddress();
+				    Map<String, String> data = new HashMap<String, String>();
+				    data.put("body", p.getName());
+				    String orderNo=idGenerator.generateId().toString();
+				    data.put("out_trade_no", orderNo); // 订单唯一编号, 不允许重复
+				    // 订单金额, 单位分
+				    String amout=p.getAmount().multiply(new BigDecimal(100)).stripTrailingZeros().toPlainString();
+				    data.put("total_fee", amout); 
+				    data.put("spbill_create_ip", ip); // 下单ip
+//				    String openId=(String) TokenManager.getVal2Session("openId");
+				    String openId="oGNT65WX5ysEnCUmAvaXOdIrMswA";
+				    if (StringUtils.isBlank(openId)) {
+				    	throw new BusinessException("无法获取正确的openId");
+					}
+				    data.put("openid", openId); // 微信公众号统一标示openid
+				    data.put("notify_url", notifyUrl); // 订单结果通知, 微信主动回调此接口
+				    data.put("trade_type", "JSAPI"); // 固定填写
+				    LoggerUtils.debug(getClass(), "发起微信支付下单接口, request=%s",data);
+				    Map<String, String> response = wxpay.unifiedOrder(data); // 微信sdk集成方法, 统一下单接口unifiedOrder, 此处请求   MD5加密   加密方式
+				    LoggerUtils.debug(getClass(),"微信支付下单成功, 返回值 response=%s", response);
+				    Order o=new Order();
+				    o.setCreateTime(new Date());
+				    o.setOrderNo(orderNo);
+				    o.setPayAmount(new BigDecimal(0));
+				    o.setPayStatus(0);
+				    o.setProjectAmount(p.getAmount());
+				    o.setProjectId(p.getId());
+				    o.setProjectName(p.getName());
+				    o.setStatus(0);
+				    o.setUid(TokenManager.getUserId());
+				    String prepayId = response.get("prepay_id");
+				    if (prepayId == null) {
+				    	throw new BusinessException("无法获取正确的prepayId");
+				    }
+				    orderService.insert(o);
+				    //  前端调起微信支付必要参数
+				    String packages = "prepay_id=" + prepayId;
+				    Map<String, String> wxPayMap = new HashMap<String, String>();
+				    String uuid=UUID.randomUUID().toString().replace("-", "").toLowerCase();
+				    wxPayMap.put("appId", iWxPayConfig.getAppID());
+				    wxPayMap.put("timeStamp", String.valueOf(new Date().getTime()));
+				    wxPayMap.put("nonceStr", uuid);
+				    wxPayMap.put("package", packages);
+				    wxPayMap.put("signType", "MD5");
+				    // 加密串中包括 appId timeStamp nonceStr package signType 5个参数, 通过sdk WXPayUtil类加密
+				    String sign = WXPayUtil.generateSignature(wxPayMap, iWxPayConfig.getKey());
+				    //  返回给前端调起微信支付的必要参数
+				    map.put("prepay_id", prepayId);
+				    map.put("out_trade_no", orderNo);
+				    map.put("paySign", sign);
+				    map.putAll(wxPayMap);
+				} catch (Exception e) {
+					e.printStackTrace();
+					throw new BusinessException("支付异常");
+				}
+				return map;
+	}
+	
+	/**
+	 * 	订单查询
+	 * @param orderNo
+	 * @return
+	 */
+	public Map<String, String> orderQuery(String orderNo){
+		// 发起微信支付
+				WXPay wxpay = null;
+				Map<String, String> map=new HashMap<>();
+				try {
+					IWxPayConfig iWxPayConfig=new IWxPayConfig(appId,mchId,apiKiy);
+				    wxpay = new WXPay(iWxPayConfig,null, true, false); // *** 注入自己实现的微信配置类, 创建WXPay核心类, WXPay 包括统一下单接口
+					Map<String, String> data = new HashMap<String, String>();
+					data.put("transaction_id", orderNo); 
+					data.put("mchid", mchId); 
+					map = wxpay.orderQuery(data); 
+					LoggerUtils.debug(getClass(),"微信查询成功, 返回值 response={%s}", map);
+				}catch (Exception e) {
+					e.printStackTrace();
+					throw new BusinessException("查询异常");
+				}
+				return map;
+	}
+	
+	/**
+	 *	 微信撤销订单
+	 * @param orderNo
+	 * @return
+	 */
+	public Map<String, String> closeOrder(String orderNo){
+		// 发起微信支付
+				WXPay wxpay = null;
+				Map<String, String> map=new HashMap<>();
+				try {
+					IWxPayConfig iWxPayConfig=new IWxPayConfig(appId,mchId,apiKiy);
+				    wxpay = new WXPay(iWxPayConfig,null, true, false); // *** 注入自己实现的微信配置类, 创建WXPay核心类, WXPay 包括统一下单接口
+					Map<String, String> data = new HashMap<String, String>();
+					data.put("out_trade_no", orderNo);
+					data.put("sp_mchid", mchId); 
+					map = wxpay.closeOrder(data);
+					LoggerUtils.debug(getClass(),"微信撤销成功, 返回值 response={%s}", map);
+				}catch (Exception e) {
+					throw new BusinessException("撤销异常");
+				}
+				return map;
+	}
+
+	
+	public void wxPayCallBack(CallBackBo cb) {
+		//解密回调信息
+		byte[] bytes = StringUtils.strToByte(apiv3);
+		byte[] associatedData=StringUtils.strToByte(cb.getResource().getAssociatedData());
+		byte[] nonce=StringUtils.strToByte(cb.getResource().getNonce());
+		WxAPIV3AesUtil aesUtil = new WxAPIV3AesUtil(bytes);
+		String decryptToString = "";
+		try {
+			decryptToString = aesUtil.decryptToString(associatedData,nonce,cb.getResource().getCiphertext());
+		} catch (GeneralSecurityException | IOException e) {
+			e.printStackTrace();
+		}
+		JSONObject json=JSON.parseObject(decryptToString);
+		String transaction_id=(String) json.get("transaction_id");
+		String out_trade_no=(String) json.get("out_trade_no");
+		LoggerUtils.debug(getClass(), "transaction_id="+transaction_id+",out_trade_no="+out_trade_no);
+		orderMapper.updateByOrderNo(out_trade_no,transaction_id);
+	}
+
+	
+
+	
+}

+ 26 - 0
src/main/java/com/kede/user/bo/UserBo.java

@@ -0,0 +1,26 @@
+package com.kede.user.bo;
+
+import com.kede.common.model.User;
+
+public class UserBo extends User{
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
+	
+	
+	private String createTimes;
+
+
+	public String getCreateTimes() {
+		return createTimes;
+	}
+
+
+	public void setCreateTimes(String createTimes) {
+		this.createTimes = createTimes;
+	}
+	
+
+}

+ 68 - 0
src/main/java/com/kede/user/controller/UserApiController.java

@@ -0,0 +1,68 @@
+package com.kede.user.controller;
+
+import java.util.Map;
+
+import javax.annotation.Resource;
+
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.kede.admin.service.OrderService;
+import com.kede.common.bo.Result;
+import com.kede.common.constant.ErrorConstants;
+import com.kede.common.controller.BaseController;
+import com.kede.common.model.Project;
+import com.kede.project.service.ProjectService;
+import com.kede.sdk.service.WxService;
+import com.kede.user.service.UserService;
+
+@RestController
+@RequestMapping(value = "/open/user")
+public class UserApiController extends BaseController{
+
+	
+	@Resource
+	private UserService userService;
+	@Resource
+	private ProjectService projectService;
+	@Resource
+	private OrderService orderService;
+	@Resource
+	private WxService wxService;
+
+	
+	@RequestMapping(value = "/wxPush", method = RequestMethod.POST)
+	public Result wxPush(Integer id) {
+		Result res=new Result();
+		if (id==null) {	
+			res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"id","id"));
+			return res;
+		}
+		Project p=projectService.get(id);
+		if (p==null) {	
+			res.getError().add(buildError("","项目不存在"));
+			return res;
+		}
+		Map<String, String> map=wxService.pushUnifiedOrder(p);
+		return res.data(map);
+	}
+	
+	@RequestMapping(value = "/wxClose", method = RequestMethod.GET)
+	public Result wxClose(String orderNo) {
+		Result res=new Result();
+		res.data(wxService.closeOrder(orderNo));
+		return res;
+	}
+	
+	
+	
+	@RequestMapping(value = "/wxQuery", method = RequestMethod.GET)
+	public Result wxQuery(String orderNo) {
+		Result res=new Result();
+		res.data(wxService.orderQuery(orderNo));
+		return res;
+	}
+	
+	
+}

+ 8 - 0
src/main/java/com/kede/user/service/UserService.java

@@ -0,0 +1,8 @@
+package com.kede.user.service;
+
+
+public interface UserService {
+
+	Object list(String name, Integer pageNo, Integer pageSize);
+
+}

+ 25 - 0
src/main/java/com/kede/user/service/impl/UserServiceImpl.java

@@ -0,0 +1,25 @@
+package com.kede.user.service.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.springframework.stereotype.Service;
+
+import com.kede.common.dao.UserMapper;
+import com.kede.core.mybatis.BaseMybatisDao;
+import com.kede.user.service.UserService;
+
+@Service
+public class UserServiceImpl extends BaseMybatisDao<UserMapper> implements UserService{
+	
+
+
+	@Override
+	public Object list(String name, Integer pageNo, Integer pageSize) {
+		Map<String,Object> params=new HashMap<String, Object>();
+		params.put("name", name);
+		return findPage("selectUserList", "selectUserCount", params, pageNo, pageSize);
+	}
+	
+
+}

+ 10 - 0
src/main/resources/props/config_local.properties

@@ -86,3 +86,13 @@ easemob.client.secret=YXA61NHE0renI5N8gEgizoI5ivM9SYE
 jiguang.appKey=dbcea43366e038073452a04e
 jiguang.masterSecret=59792298288e4f635c737def
 jiguang.pushUrl=https://api.jpush.cn/v3/push
+
+
+wx.appId=wxcf634bc22ab19eac
+wx.appSecret=0d23307f1342e90781c0208b16954060
+wx.mchId=1608092419
+wx.apiKiy=2Pd6okHJYfLg7avkeHwVNsVqxphgcYcn
+wx.apiv3=wJwYEP494Cdek0P83tk08IxbvlhsqBdl
+wx.notifyUrl=https://www.kedexinxi.com/open/payCallback
+
+

+ 8 - 0
src/main/resources/props/config_prod.properties

@@ -91,3 +91,11 @@ easemob.client.secret=YXA61NHE0renI5N8gEgizoI5ivM9SYE
 jiguang.appKey=dbcea43366e038073452a04e
 jiguang.masterSecret=59792298288e4f635c737def
 jiguang.pushUrl=https://api.jpush.cn/v3/push
+
+
+wx.appId=wxcf634bc22ab19eac
+wx.appSecret=0d23307f1342e90781c0208b16954060
+wx.mchId=1608092419
+wx.apiKiy=2Pd6okHJYfLg7avkeHwVNsVqxphgcYcn
+wx.apiv3=wJwYEP494Cdek0P83tk08IxbvlhsqBdl
+wx.notifyUrl=https://www.kedexinxi.com/open/payCallback

+ 4 - 1
src/main/resources/shiro_base_auth.ini

@@ -11,15 +11,18 @@
 /mlogin=anon
 /signin=anon
 /adminLogin=anon
+/wxLogin=anon
 /register=anon
 /mregister=anon
-/open/**=anon
 /favicon.ico=anon
 /static/**=anon
 /portal/**=anon
 /api/portal/**=anon
 /api/admin/**=admin
+/api/user/**=user
 /admin/**=admin
 /role/**=admin,permission
 /permission/**=admin,permission
+/open/**=anon
+/open/user/**=anon
 /**=login

+ 5 - 0
src/main/resources/spring/spring-shiro.xml

@@ -160,6 +160,11 @@
 						<property name="loginUrl" value="/portal/index" />
 					</bean>
 				</entry>
+				<entry key="user">
+					<bean id="user" class="com.kede.core.shiro.filter.UserFilter">
+						<property name="loginUrl" value="/error" />
+					</bean>
+				</entry>
 			</util:map>
 		</property>
 	</bean>

+ 1 - 1
src/main/webapp/WEB-INF/views/error.html

@@ -13,6 +13,6 @@
 <p th:text="${message}">未知错误</p>
 <p th:text="${status}">404</p>
 
-<div th:replace="common::footer(~{})"></div>
+<div th:replace="common::footer(~{},'')"></div>
 </body>
 </html>