商品模块
This commit is contained in:
parent
967cac5d8c
commit
b249bf73e1
|
|
@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
|
||||||
import com.ghy.common.adapay.AdapayService;
|
import com.ghy.common.adapay.AdapayService;
|
||||||
import com.ghy.common.adapay.callback.model.WxLiteExpend;
|
import com.ghy.common.adapay.callback.model.WxLiteExpend;
|
||||||
import com.ghy.common.adapay.callback.reply.WxPubPayCallBack;
|
import com.ghy.common.adapay.callback.reply.WxPubPayCallBack;
|
||||||
|
import com.ghy.common.config.WxConfig;
|
||||||
import com.ghy.common.core.controller.BaseController;
|
import com.ghy.common.core.controller.BaseController;
|
||||||
import com.ghy.common.core.domain.AjaxResult;
|
import com.ghy.common.core.domain.AjaxResult;
|
||||||
import com.ghy.common.utils.ExceptionUtil;
|
import com.ghy.common.utils.ExceptionUtil;
|
||||||
|
|
@ -21,6 +22,9 @@ import java.util.Map;
|
||||||
@RequestMapping("/pay/wx")
|
@RequestMapping("/pay/wx")
|
||||||
public class WxPayController extends BaseController {
|
public class WxPayController extends BaseController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private WxConfig wxConfig;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private AdapayService adapayService;
|
private AdapayService adapayService;
|
||||||
|
|
||||||
|
|
@ -41,7 +45,7 @@ public class WxPayController extends BaseController {
|
||||||
// String orderId = request.getParameter("orderId");
|
// String orderId = request.getParameter("orderId");
|
||||||
// 查询回订单信息。如果订单不存在,则退出.
|
// 查询回订单信息。如果订单不存在,则退出.
|
||||||
try {
|
try {
|
||||||
JSONObject wxUser = WxUtils.getOpenid(code);
|
JSONObject wxUser = WxUtils.getOpenid(code, wxConfig.getAppId(), wxConfig.getSecret());
|
||||||
String openId = wxUser.getString("openid");
|
String openId = wxUser.getString("openid");
|
||||||
logger.info("open id is " + openId);
|
logger.info("open id is " + openId);
|
||||||
//调用adapay微信公众号支付.
|
//调用adapay微信公众号支付.
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,14 @@
|
||||||
package com.ghy.web.controller.tool;
|
package com.ghy.web.controller.tool;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.ghy.common.config.WxConfig;
|
||||||
import com.ghy.common.core.controller.BaseController;
|
import com.ghy.common.core.controller.BaseController;
|
||||||
|
import com.ghy.common.core.domain.AjaxResult;
|
||||||
import com.ghy.common.utils.WxUtils;
|
import com.ghy.common.utils.WxUtils;
|
||||||
|
import com.ghy.common.utils.http.HttpUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
@ -14,10 +19,18 @@ import java.security.MessageDigest;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author clunt
|
||||||
|
* 微信通用请求接口
|
||||||
|
*/
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/wx")
|
@RequestMapping("/wx")
|
||||||
|
@CrossOrigin(origins = "*", maxAge = 3600)
|
||||||
public class WxController extends BaseController {
|
public class WxController extends BaseController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private WxConfig wxConfig;
|
||||||
|
|
||||||
@GetMapping("/token")
|
@GetMapping("/token")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String token(String timestamp, String nonce, String signature, String echostr) throws IOException {
|
public String token(String timestamp, String nonce, String signature, String echostr) throws IOException {
|
||||||
|
|
@ -30,11 +43,21 @@ public class WxController extends BaseController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/auth")
|
||||||
|
@ResponseBody
|
||||||
|
public AjaxResult auth(String code) {
|
||||||
|
String url = "https://api.weixin.qq.com/sns/jscode2session?appid=" + wxConfig.getAppId() + "&secret=" + wxConfig.getSecret() + "&js_code=" + code + "&grant_type=authorization_code";
|
||||||
|
String data = HttpUtils.sendGet(url, null);
|
||||||
|
JSONObject result = JSONObject.parseObject(data);
|
||||||
|
return AjaxResult.success(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/openid")
|
@GetMapping("/openid")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String openId(HttpServletRequest request) throws Exception{
|
public String openId(HttpServletRequest request) throws Exception {
|
||||||
String code = request.getParameter("code");
|
String code = request.getParameter("code");
|
||||||
JSONObject wxUser = WxUtils.getOpenid(code);
|
JSONObject wxUser = WxUtils.getOpenid(code, wxConfig.getAppId(), wxConfig.getSecret());
|
||||||
return wxUser.getString("openid");
|
return wxUser.getString("openid");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -141,6 +141,12 @@ swagger:
|
||||||
# 是否开启swagger
|
# 是否开启swagger
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|
||||||
|
#小程序配置
|
||||||
|
wx:
|
||||||
|
appId: 'wx404f2439a8c24e15'
|
||||||
|
secret: '49ade04a817067fe2d65ab2f17afce75'
|
||||||
|
|
||||||
|
#七牛云配置
|
||||||
qiniu:
|
qiniu:
|
||||||
accessKey: 'QTNOppkvtufxTxLjt1V7YZwvzV2Rc6WLD5yXLBVY'
|
accessKey: 'QTNOppkvtufxTxLjt1V7YZwvzV2Rc6WLD5yXLBVY'
|
||||||
secretKey: 'V8SM9nkbO-dft4JmG7UaCH6RYxXdqzrvQ0zWO2W3'
|
secretKey: 'V8SM9nkbO-dft4JmG7UaCH6RYxXdqzrvQ0zWO2W3'
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
package com.ghy.common.config;
|
package com.ghy.common.config;
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
package com.ghy.common.config;
|
||||||
|
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 七牛云配置
|
||||||
|
* @author clunt
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@ConfigurationProperties(prefix = "wx")
|
||||||
|
public class WxConfig {
|
||||||
|
|
||||||
|
public String appId;
|
||||||
|
|
||||||
|
public String secret;
|
||||||
|
|
||||||
|
public String getAppId() {
|
||||||
|
return appId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAppId(String appId) {
|
||||||
|
this.appId = appId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSecret() {
|
||||||
|
return secret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSecret(String secret) {
|
||||||
|
this.secret = secret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -14,9 +14,9 @@ public class WxUtils {
|
||||||
public static String getOpenIdUrl = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=APPID&secret=SECRET&code=CODE&grant_type=authorization_code";
|
public static String getOpenIdUrl = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=APPID&secret=SECRET&code=CODE&grant_type=authorization_code";
|
||||||
|
|
||||||
/*通过code获取用户openid*/
|
/*通过code获取用户openid*/
|
||||||
public static JSONObject getOpenid(String code) throws IOException {
|
public static JSONObject getOpenid(String code, String appId, String secret) throws IOException {
|
||||||
JSONObject jsonObject = null;
|
JSONObject jsonObject = null;
|
||||||
String path = getOpenIdUrl.replace("APPID", "wx404f2439a8c24e15").replace("SECRET", "49ade04a817067fe2d65ab2f17afce75").replace("CODE", code);
|
String path = getOpenIdUrl.replace("APPID", appId).replace("SECRET", secret).replace("CODE", code);
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuffer buffer = new StringBuffer();
|
||||||
URL url = new URL(path);
|
URL url = new URL(path);
|
||||||
HttpsURLConnection httpUrlConn = (HttpsURLConnection) url.openConnection();
|
HttpsURLConnection httpUrlConn = (HttpsURLConnection) url.openConnection();
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,12 @@ public class Goods extends BaseEntity {
|
||||||
|
|
||||||
@Excel(name = "价格")
|
@Excel(name = "价格")
|
||||||
private BigDecimal goodsPrice;
|
private BigDecimal goodsPrice;
|
||||||
|
|
||||||
|
@Excel(name = "优惠价")
|
||||||
|
private BigDecimal discountsPrice;
|
||||||
|
|
||||||
|
@Excel(name = "团购价")
|
||||||
|
private BigDecimal groupPrice;
|
||||||
|
|
||||||
/** 岗位排序 */
|
/** 岗位排序 */
|
||||||
@Excel(name = "商品排序", cellType = Excel.ColumnType.NUMERIC)
|
@Excel(name = "商品排序", cellType = Excel.ColumnType.NUMERIC)
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@
|
||||||
<result property="deptId" column="dept_id" />
|
<result property="deptId" column="dept_id" />
|
||||||
<result property="goodsName" column="goods_name" />
|
<result property="goodsName" column="goods_name" />
|
||||||
<result property="goodsPrice" column="goods_price" />
|
<result property="goodsPrice" column="goods_price" />
|
||||||
|
<result property="discountsPrice" column="discounts_price" />
|
||||||
|
<result property="groupPrice" column="group_price" />
|
||||||
<result property="goodsSort" column="goods_sort"/>
|
<result property="goodsSort" column="goods_sort"/>
|
||||||
<result property="goodsCategoryId" column="goods_category_id"/>
|
<result property="goodsCategoryId" column="goods_category_id"/>
|
||||||
<result property="goodsImgUrl" column="goods_img_url"/>
|
<result property="goodsImgUrl" column="goods_img_url"/>
|
||||||
|
|
@ -23,7 +25,7 @@
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectGoods">
|
<sql id="selectGoods">
|
||||||
select goods_id, goods_code, dept_id, goods_name, goods_price, goods_sort, goods_category_id,
|
select goods_id, goods_code, dept_id, goods_name, goods_price, discounts_price, group_price, goods_sort, goods_category_id,
|
||||||
goods_img_url, goods_number, status, create_by, create_time, remark
|
goods_img_url, goods_number, status, create_by, create_time, remark
|
||||||
from goods
|
from goods
|
||||||
</sql>
|
</sql>
|
||||||
|
|
@ -34,9 +36,6 @@
|
||||||
<if test="goodsCode != null and goodsCode != ''">
|
<if test="goodsCode != null and goodsCode != ''">
|
||||||
AND goods_code like concat('%', #{goodsCode}, '%')
|
AND goods_code like concat('%', #{goodsCode}, '%')
|
||||||
</if>
|
</if>
|
||||||
<if test="deptId != null and deptId != 0">
|
|
||||||
AND dept_id = #{deptId}
|
|
||||||
</if>
|
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
7
pom.xml
7
pom.xml
|
|
@ -38,6 +38,7 @@
|
||||||
<gson.version>2.8.5</gson.version>
|
<gson.version>2.8.5</gson.version>
|
||||||
<wxpay.version>0.4.3</wxpay.version>
|
<wxpay.version>0.4.3</wxpay.version>
|
||||||
<Adapay.version>1.2.10</Adapay.version>
|
<Adapay.version>1.2.10</Adapay.version>
|
||||||
|
<commons.codec.version>1.10</commons.codec.version>
|
||||||
<httpcomponents.version>4.5.13</httpcomponents.version>
|
<httpcomponents.version>4.5.13</httpcomponents.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
|
@ -45,6 +46,12 @@
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-codec</groupId>
|
||||||
|
<artifactId>commons-codec</artifactId>
|
||||||
|
<version>${commons.codec.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.code.gson</groupId>
|
<groupId>com.google.code.gson</groupId>
|
||||||
<artifactId>gson</artifactId>
|
<artifactId>gson</artifactId>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue