dev-discount
袁野 4 years ago
commit 9c8247e800
  1. 19
      hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java
  2. 2
      hai-bweb/src/main/java/com/bweb/controller/HighGoodsPriceReferController.java
  3. 6
      hai-cweb/src/main/java/com/cweb/controller/HighCouponController.java
  4. 4
      hai-cweb/src/main/java/com/cweb/controller/HighMerchantStoreController.java
  5. 2
      hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java
  6. 4
      hai-cweb/src/main/java/com/cweb/controller/pay/OrderController.java
  7. 50
      hai-cweb/src/test/common/RegionTest.java
  8. 2
      hai-schedule/src/main/java/com/hai/schedule/HighCouponSchedule.java
  9. 5
      hai-schedule/src/main/java/com/hai/schedule/HighOrderSchedule.java
  10. 6
      hai-schedule/src/main/resources/dev/application.yml
  11. 5
      hai-schedule/src/main/resources/dev/config.properties
  12. 8
      hai-schedule/src/main/resources/prod/application.yml
  13. 1
      hai-schedule/src/main/resources/prod/config.properties
  14. 311
      hai-service/src/main/java/com/hai/common/utils/HttpUtils.java
  15. 2
      hai-service/src/main/java/com/hai/common/utils/HttpsUtils.java
  16. 4
      hai-service/src/main/java/com/hai/entity/HighCoupon.java
  17. 12
      hai-service/src/main/java/com/hai/entity/HighUserCoupon.java
  18. 2
      hai-service/src/main/java/com/hai/model/HighCouponModel.java
  19. 10
      hai-service/src/main/java/com/hai/service/HighCouponService.java
  20. 2
      hai-service/src/main/java/com/hai/service/HighUserCouponService.java
  21. 37
      hai-service/src/main/java/com/hai/service/impl/HighCouponServiceImpl.java
  22. 2
      hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java
  23. 14
      hai-service/src/main/java/com/hai/service/impl/HighUserCouponServiceImpl.java

@ -1,6 +1,7 @@
package com.bweb.controller;
import com.alibaba.excel.EasyExcel;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.bweb.excelListener.ImportCouponListener;
import com.bweb.model.ImportCouponModel;
@ -70,7 +71,7 @@ public class HighCouponController {
@RequestMapping(value="/insertCoupon",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "增加卡卷")
public ResponseData insertCoupon(@RequestBody HighCouponModel highCoupon, HttpServletRequest request) {
public ResponseData insertCoupon(@RequestBody HighCoupon highCoupon, HttpServletRequest request) {
try {
SessionObject sessionObject = userCenter.getSessionObject(request);
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject();
@ -153,7 +154,7 @@ public class HighCouponController {
@RequestMapping(value="/updateCoupon",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "修改卡卷")
public ResponseData updateCoupon(@RequestBody HighCouponModel highCoupon, HttpServletRequest request) {
public ResponseData updateCoupon(@RequestBody HighCoupon highCoupon, HttpServletRequest request) {
try {
SessionObject sessionObject = userCenter.getSessionObject(request);
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject();
@ -188,7 +189,7 @@ public class HighCouponController {
map.put("couponName", highCoupon.getCouponName());
// 查询卡券
HighCouponModel coupon = highCouponService.getCouponById(highCoupon.getId());
HighCoupon coupon = highCouponService.getCouponById(highCoupon.getId());
if (coupon == null) {
log.error("HighCouponController -> updateCoupon() error!","未找到卡卷信息");
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_COUPON, "");
@ -260,7 +261,7 @@ public class HighCouponController {
SessionObject sessionObject = userCenter.getSessionObject(request);
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject();
// 查询卡券
HighCouponModel coupon = highCouponService.getCouponById(id);
HighCoupon coupon = highCouponService.getCouponById(id);
if (coupon == null) {
log.error("HighCouponController -> upShelfApprove() error!","未找到卡卷信息");
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_COUPON, "");
@ -354,15 +355,14 @@ public class HighCouponController {
@RequestParam(name = "pageNum", required = true) Integer pageNum,
@RequestParam(name = "pageSize", required = true) Integer pageSize, HttpServletRequest request) {
try {
Map<String, Object> map = new HashMap<>();
SessionObject sessionObject = userCenter.getSessionObject(request);
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject();
if (userInfoModel.getBsCompany() == null) {
log.error("HighCouponController -> getCouponList() error!","权限不足");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMPETENCE_INSUFFICIENT, "");
}
Map<String, Object> map = new HashMap<>();
map.put("companyId", userInfoModel.getBsCompany().getId());
map.put("merchantId", merchantId);
map.put("couponName", couponName);
@ -370,6 +370,7 @@ public class HighCouponController {
map.put("displayArea", displayArea);
map.put("status", status);
PageHelper.startPage(pageNum, pageSize);
@ -392,7 +393,7 @@ public class HighCouponController {
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject();
// 查找卡卷
HighCouponModel coupon = highCouponService.getCouponById(couponId);
HighCoupon coupon = highCouponService.getCouponById(couponId);
if (coupon == null) {
log.error("HighCouponController -> writeStock() error!","未找到卡卷信息");
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_COUPON, "");
@ -441,7 +442,7 @@ public class HighCouponController {
}
// 查找商户
HighCouponModel coupon = highCouponService.getCouponById(couponId);
HighCoupon coupon = highCouponService.getCouponById(couponId);
if (coupon == null) {
log.error("HighCouponController -> writeStock() error!","未找到商户");
throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_NOF_FOUND, "");

@ -101,7 +101,7 @@ public class HighGoodsPriceReferController {
// 卡卷
if (addGoodsPriceModel.getObjectType() == 1) {
HighCouponModel coupon = highCouponService.getCouponById(objectId);
HighCoupon coupon = highCouponService.getCouponById(objectId);
if (coupon == null) {
log.error("HighGoodsPriceReferController -> insertGoodsPriceRefer() error!","未找到卡卷信息");
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_COUPON, "");

@ -121,11 +121,7 @@ public class HighCouponController {
map.put("status", status);
PageHelper.startPage(pageNum, pageSize);
List<HighUserCouponModel> list = highUserCouponService.getUserCouponList(map);
for (HighUserCouponModel highUserCouponModel : list) {
highUserCouponModel.setHighCouponModel(highCouponService.getCouponById(highUserCouponModel.getCouponId()));
}
return ResponseMsgUtil.success(new PageInfo<>(list));
return ResponseMsgUtil.success(new PageInfo<>(highUserCouponService.getUserCouponList(map)));
} catch (Exception e) {
log.error("HighCouponController --> getUserCouponList() error!", e);

@ -82,7 +82,7 @@ public class HighMerchantStoreController {
@RequestParam(name = "pageSize", required = true) Integer pageSize) {
try {
HighCouponModel coupon = highCouponService.getCouponById(couponId);
HighCoupon coupon = highCouponService.getCouponById(couponId);
if (coupon == null) {
return ResponseMsgUtil.success(new PageInfo<>());
}
@ -93,7 +93,7 @@ public class HighMerchantStoreController {
List<HighMerchantStore> storeList = highMerchantStoreService.getMerchantStoreList(map);
if (storeList != null && storeList.size() > 0) {
HighMerchantModel merchant = highMerchantService.getMerchantById(coupon.getMerchantId());
HighMerchant merchant = highMerchantService.getMerchantById(coupon.getMerchantId());
for (HighMerchantStore store : storeList) {
store.setExt1(merchant.getMerchantLogo());
}

@ -91,7 +91,7 @@ public class HighOrderController {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "卡卷只能购买一张");
}
// 查询卡卷信息
HighCouponModel coupon = highCouponService.getCouponById(childOrder.getGoodsId());
HighCoupon coupon = highCouponService.getCouponById(childOrder.getGoodsId());
if (coupon == null) {
log.error("HighOrderController --> addOrder() error!", "未找到卡卷信息");
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_COUPON, "");

@ -110,7 +110,7 @@ public class OrderController {
// 商品类型 1:卡卷 2:金币充值
for (HighChildOrder childOrder : order.getHighChildOrderList()) {
if (childOrder.getGoodsType() == 1) {
HighCouponModel coupon = highCouponService.getCouponById(childOrder.getGoodsId());
HighCoupon coupon = highCouponService.getCouponById(childOrder.getGoodsId());
// 支付类型:1.微信支付 2.金币支付
if (coupon.getPayType() != 1) {
log.error("OrderController --> orderToPay() ERROR", "只支持微信支持");
@ -190,7 +190,7 @@ public class OrderController {
// 商品类型 1:卡卷 2:金币充值
for (HighChildOrder childOrder : order.getHighChildOrderList()) {
if (childOrder.getGoodsType() == 2) {
HighCouponModel coupon = highCouponService.getCouponById(childOrder.getGoodsId());
HighCoupon coupon = highCouponService.getCouponById(childOrder.getGoodsId());
// 支付类型:1.微信支付 2.金币支付
if (coupon.getPayType() != 2) {
log.error("OrderController --> orderToPay() ERROR", "只支持金币支持");

@ -3,7 +3,7 @@ package common;
import com.CWebApplication;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.cweb.config.HttpsUtils;
import com.hai.common.utils.HttpsUtils;
import com.hai.entity.SecRegion;
import com.hai.service.CommonService;
@ -16,10 +16,10 @@ import org.springframework.test.context.web.WebAppConfiguration;
import javax.annotation.Resource;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.*;
/**
* @ClassName RegionTest
@ -35,6 +35,8 @@ public class RegionTest {
@Resource
private CommonService commonService;
private static final String[] HEX_DIGITS = {"0" ,"1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"};
@Test
public void addLogs(){
try {
@ -77,7 +79,16 @@ public class RegionTest {
Map<String,Object> map = new HashMap<>();
map.put("appId", "js3w7K4W0SglB6bNPVjs3w7K4W0SglB6bNPV");
map.put("appSecret", "SoIXquKSKT8s7sa6ySjfyBXxKTC4Jhqx7fiE1qT0XWrrnkScurMGsLdGrz5ThLo5");
JSONObject jsonObject = HttpsUtils.doPost("http://oilcps.51vip.biz:33013/api-provider/api/open/merchant/token", map);
Long date = new Date().getTime();
String signature = "mUGcV7CxPYRuzIWXd72bVknKYCXuT7d1tRxQUdVR9iAcxxTdmWC8lTo0rL5wDZwLmTwQnpCqeHz3MtAIVBrm99WmtPv93pRdgWcIkkgPt18pAFyavYrPt80Yh8iyFr8s";
String sha256 = encodeBySHA256(signature + JSON.toJSONString(map) + date);
Map<String,Object> map2 = new HashMap<>();
map2.put("signature", signature);
map2.put("body", JSON.toJSONString(map));
map2.put("ts", date);
JSONObject jsonObject = HttpsUtils.doPost("https://app.zshcqsy.com/api-provider/api/open/merchant/token", JSON.toJSONString(map2));
System.out.println(jsonObject.toJSONString());
}catch (Exception e){
@ -85,4 +96,31 @@ public class RegionTest {
}
}
public String encodeBySHA256(String str) {
try{
MessageDigest messageDigest = MessageDigest.getInstance("SHA-256");
messageDigest.reset();
messageDigest.update(str.getBytes("UTF-8"));
return getFormattedText(messageDigest.digest());
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (Exception e) {
throw new RuntimeException(e);
}
return "";
}
private String getFormattedText(byte[] bytes) {
int len = bytes.length;
StringBuilder buf = new StringBuilder(len * 2);
// 把密文转换成十六进制的字符串形式
for (int j=0;j<len;j++){
buf.append(HEX_DIGITS[(bytes[j] >> 4) & 0x0f]);
buf.append(HEX_DIGITS[bytes[j] & 0x0f]);
}
return buf.toString();
}
}

@ -20,7 +20,7 @@ public class HighCouponSchedule {
private HighUserCouponService highUserCouponService;
// @Scheduled(cron="0 0/1 * * * ?") //每1分钟执行一次
@Scheduled(cron = "0 0 0 * * ?") //每天 凌晨0点执行
// @Scheduled(cron = "0 0 0 * * ?") //每天 凌晨0点执行
public void certification() {
List<HighUserCoupon> userCoupons = highUserCouponService.getOverdueCoupon();
for (HighUserCoupon highUserCoupon : userCoupons) {

@ -1,5 +1,7 @@
package com.hai.schedule;
import com.alibaba.fastjson.JSONObject;
import com.hai.common.utils.HttpsUtils;
import com.hai.entity.HighOrder;
import com.hai.service.HighOrderService;
import org.springframework.context.annotation.Configuration;
@ -7,7 +9,9 @@ import org.springframework.scheduling.annotation.Scheduled;
import javax.annotation.Resource;
import javax.xml.ws.RespectBinding;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Auther: 胡锐
@ -30,4 +34,5 @@ public class HighOrderSchedule {
}
}
}
}

@ -1,10 +1,10 @@
server:
port: 9302
port: 9303
servlet:
context-path: /brest
context-path: /schedule
#配置是否为debug模式,debug模式下,不开启权限校验
debug: true
debug: false
#datasource数据源设置
spring:

@ -1,5 +0,0 @@
wxAppId=wx01898d5209357d68
wxAppSecret=5c52d0526fcdb425075f6d51381d5c03
fileUrl=F:/hurui_probject/filesystem
cmsPath=F:/hurui_probject/filesystem

@ -1,7 +1,7 @@
server:
port: 9302
port: 9303
servlet:
context-path: /crest
context-path: /schedule
#配置是否为debug模式,debug模式下,不开启权限校验
debug: false
@ -9,8 +9,8 @@ debug: false
#datasource数据源设置
spring:
datasource:
url: jdbc:mysql://139.159.177.244:3306/hfkj?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8
username: hfkj
url: jdbc:mysql://127.0.0.1:3306/hsg?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8
username: root
password: HF123456.
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.jdbc.Driver

@ -0,0 +1,311 @@
package com.hai.common.utils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.conn.ClientConnectionManager;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class HttpUtils {
/**
* get
*
* @param host
* @param path
* @param method
* @param headers
* @param querys
* @return
* @throws Exception
*/
public static HttpResponse doGet(String host, String path, String method,
Map<String, String> headers,
Map<String, String> querys)
throws Exception {
HttpClient httpClient = wrapClient(host);
HttpGet request = new HttpGet(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader(e.getKey(), e.getValue());
}
return httpClient.execute(request);
}
/**
* post form
*
* @param host
* @param path
* @param method
* @param headers
* @param querys
* @param bodys
* @return
* @throws Exception
*/
public static HttpResponse doPost(String host, String path, String method,
Map<String, String> headers,
Map<String, String> querys,
Map<String, String> bodys)
throws Exception {
HttpClient httpClient = wrapClient(host);
HttpPost request = new HttpPost(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader(e.getKey(), e.getValue());
}
if (bodys != null) {
List<NameValuePair> nameValuePairList = new ArrayList<NameValuePair>();
for (String key : bodys.keySet()) {
nameValuePairList.add(new BasicNameValuePair(key, bodys.get(key)));
}
UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(nameValuePairList, "utf-8");
formEntity.setContentType("application/x-www-form-urlencoded; charset=UTF-8");
request.setEntity(formEntity);
}
return httpClient.execute(request);
}
/**
* Post String
*
* @param host
* @param path
* @param method
* @param headers
* @param querys
* @param body
* @return
* @throws Exception
*/
public static HttpResponse doPost(String host, String path, String method,
Map<String, String> headers,
Map<String, String> querys,
String body)
throws Exception {
HttpClient httpClient = wrapClient(host);
HttpPost request = new HttpPost(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader(e.getKey(), e.getValue());
}
if (StringUtils.isNotBlank(body)) {
request.setEntity(new StringEntity(body, "utf-8"));
}
return httpClient.execute(request);
}
/**
* Post stream
*
* @param host
* @param path
* @param method
* @param headers
* @param querys
* @param body
* @return
* @throws Exception
*/
public static HttpResponse doPost(String host, String path, String method,
Map<String, String> headers,
Map<String, String> querys,
byte[] body)
throws Exception {
HttpClient httpClient = wrapClient(host);
HttpPost request = new HttpPost(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader(e.getKey(), e.getValue());
}
if (body != null) {
request.setEntity(new ByteArrayEntity(body));
}
return httpClient.execute(request);
}
/**
* Put String
* @param host
* @param path
* @param method
* @param headers
* @param querys
* @param body
* @return
* @throws Exception
*/
public static HttpResponse doPut(String host, String path, String method,
Map<String, String> headers,
Map<String, String> querys,
String body)
throws Exception {
HttpClient httpClient = wrapClient(host);
HttpPut request = new HttpPut(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader(e.getKey(), e.getValue());
}
if (StringUtils.isNotBlank(body)) {
request.setEntity(new StringEntity(body, "utf-8"));
}
return httpClient.execute(request);
}
/**
* Put stream
* @param host
* @param path
* @param method
* @param headers
* @param querys
* @param body
* @return
* @throws Exception
*/
public static HttpResponse doPut(String host, String path, String method,
Map<String, String> headers,
Map<String, String> querys,
byte[] body)
throws Exception {
HttpClient httpClient = wrapClient(host);
HttpPut request = new HttpPut(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader(e.getKey(), e.getValue());
}
if (body != null) {
request.setEntity(new ByteArrayEntity(body));
}
return httpClient.execute(request);
}
/**
* Delete
*
* @param host
* @param path
* @param method
* @param headers
* @param querys
* @return
* @throws Exception
*/
public static HttpResponse doDelete(String host, String path, String method,
Map<String, String> headers,
Map<String, String> querys)
throws Exception {
HttpClient httpClient = wrapClient(host);
HttpDelete request = new HttpDelete(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader(e.getKey(), e.getValue());
}
return httpClient.execute(request);
}
private static String buildUrl(String host, String path, Map<String, String> querys) throws UnsupportedEncodingException {
StringBuilder sbUrl = new StringBuilder();
sbUrl.append(host);
if (!StringUtils.isBlank(path)) {
sbUrl.append(path);
}
if (null != querys) {
StringBuilder sbQuery = new StringBuilder();
for (Map.Entry<String, String> query : querys.entrySet()) {
if (0 < sbQuery.length()) {
sbQuery.append("&");
}
if (StringUtils.isBlank(query.getKey()) && !StringUtils.isBlank(query.getValue())) {
sbQuery.append(query.getValue());
}
if (!StringUtils.isBlank(query.getKey())) {
sbQuery.append(query.getKey());
if (!StringUtils.isBlank(query.getValue())) {
sbQuery.append("=");
sbQuery.append(URLEncoder.encode(query.getValue(), "utf-8"));
}
}
}
if (0 < sbQuery.length()) {
sbUrl.append("?").append(sbQuery);
}
}
return sbUrl.toString();
}
private static HttpClient wrapClient(String host) {
HttpClient httpClient = new DefaultHttpClient();
if (host.startsWith("https://")) {
sslClient(httpClient);
}
return httpClient;
}
private static void sslClient(HttpClient httpClient) {
try {
SSLContext ctx = SSLContext.getInstance("TLS");
X509TrustManager tm = new X509TrustManager() {
public X509Certificate[] getAcceptedIssuers() {
return null;
}
public void checkClientTrusted(X509Certificate[] xcs, String str) {
}
public void checkServerTrusted(X509Certificate[] xcs, String str) {
}
};
ctx.init(null, new TrustManager[] { tm }, null);
SSLSocketFactory ssf = new SSLSocketFactory(ctx);
ssf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
ClientConnectionManager ccm = httpClient.getConnectionManager();
SchemeRegistry registry = ccm.getSchemeRegistry();
registry.register(new Scheme("https", 443, ssf));
} catch (KeyManagementException ex) {
throw new RuntimeException(ex);
} catch (NoSuchAlgorithmException ex) {
throw new RuntimeException(ex);
}
}
}

@ -1,4 +1,4 @@
package com.cweb.config;
package com.hai.common.utils;
import com.alibaba.fastjson.JSON;

@ -1,5 +1,7 @@
package com.hai.entity;
import com.hai.model.HighCouponModel;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
@ -13,7 +15,7 @@ import java.util.Date;
* 代码由工具生成
*
**/
public class HighCoupon implements Serializable {
public class HighCoupon extends HighCouponModel implements Serializable {
/**
* 主键
*/

@ -1,5 +1,7 @@
package com.hai.entity;
import com.hai.model.HighCouponModel;
import java.io.Serializable;
import java.util.Date;
@ -61,6 +63,16 @@ public class HighUserCoupon implements Serializable {
private String ext4;
private HighCouponModel highCouponModel;
public HighCouponModel getHighCouponModel() {
return highCouponModel;
}
public void setHighCouponModel(HighCouponModel highCouponModel) {
this.highCouponModel = highCouponModel;
}
private static final long serialVersionUID = 1L;
public Long getId() {

@ -10,7 +10,7 @@ import java.util.List;
* @Description: 卡卷模型
* @Date: 2021/3/11 22:27
*/
public class HighCouponModel extends HighCoupon {
public class HighCouponModel {
// 商户名称
private String merchantName;

@ -20,14 +20,14 @@ public interface HighCouponService {
* @Description 增加卡卷业务
* @Date 2021/3/11 22:05
**/
void insertCoupon(HighCouponModel highCouponModel);
void insertCoupon(HighCoupon highCouponModel);
/**
* @Author 胡锐
* @Description 修改卡卷业务
* @Date 2021/3/12 20:41
**/
void updateCoupon(HighCouponModel highCouponModel);
void updateCoupon(HighCoupon highCouponModel);
/**
* @Author 胡锐
@ -80,7 +80,7 @@ public interface HighCouponService {
* @Description 根据id查询卡卷基本信息赠送信息
* @Date 2021/3/14 16:58
**/
HighCouponModel getCouponById(Long id);
HighCoupon getCouponById(Long id);
/**
*
@ -91,14 +91,14 @@ public interface HighCouponService {
* @Param [id]
* @return com.hai.model.HighCouponModel
**/
HighCouponModel getCouponDetail(Long id);
HighCoupon getCouponDetail(Long id);
/**
* @Author 胡锐
* @Description 获取卡卷集合
* @Date 2021/3/15 23:12
**/
List<HighCouponModel> getCouponList(Map<String, Object> map);
List<HighCoupon> getCouponList(Map<String, Object> map);
/**
* @Author 胡锐

@ -46,7 +46,7 @@ public interface HighUserCouponService {
* @Description 查询用户列表
* @Date 2021/3/27 17:21
**/
List<HighUserCouponModel> getUserCouponList(Map<String,Object> map);
List<HighUserCoupon> getUserCouponList(Map<String,Object> map);
/**
* @Author 胡锐

@ -51,7 +51,7 @@ public class HighCouponServiceImpl implements HighCouponService {
@Override
@Transactional(propagation= Propagation.REQUIRES_NEW)
public void insertCoupon(HighCouponModel highCouponModel) {
public void insertCoupon(HighCoupon highCouponModel) {
highCouponMapper.insert(highCouponModel);
// 增加赠送卡卷
@ -96,7 +96,7 @@ public class HighCouponServiceImpl implements HighCouponService {
@Override
@Transactional(propagation= Propagation.REQUIRES_NEW)
public void updateCoupon(HighCouponModel highCouponModel) {
public void updateCoupon(HighCoupon highCouponModel) {
highCouponMapper.updateByPrimaryKey(highCouponModel);
// 赠送卡卷
@ -114,7 +114,7 @@ public class HighCouponServiceImpl implements HighCouponService {
}
}
HighCouponModel coupon = getCouponById(highCouponModel.getId());
HighCoupon coupon = getCouponById(highCouponModel.getId());
// 如果卡卷销售价格进行了修改
if (!coupon.getSalesPrice().equals(highCouponModel.getSalesPrice())) {
@ -167,7 +167,7 @@ public class HighCouponServiceImpl implements HighCouponService {
@Transactional(propagation= Propagation.REQUIRES_NEW)
public void upShelfApprove(Long id) {
// 查询卡卷
HighCouponModel coupon = getCouponById(id);
HighCoupon coupon = getCouponById(id);
if (coupon == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_COUPON, "");
}
@ -180,7 +180,7 @@ public class HighCouponServiceImpl implements HighCouponService {
@Transactional(propagation= Propagation.REQUIRES_NEW)
public void upShelfApproveResult(HighApprove highApprove) {
// 查询卡卷
HighCouponModel couponDetail = getCouponDetail(highApprove.getObjectId());
HighCoupon couponDetail = getCouponDetail(highApprove.getObjectId());
if (couponDetail == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_COUPON, "");
}
@ -215,7 +215,7 @@ public class HighCouponServiceImpl implements HighCouponService {
@Override
@Transactional(propagation= Propagation.REQUIRES_NEW)
public void ofShelfCoupon(Long id) {
HighCouponModel coupon = getCouponById(id);
HighCoupon coupon = getCouponById(id);
if (coupon == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_COUPON, "");
}
@ -232,7 +232,7 @@ public class HighCouponServiceImpl implements HighCouponService {
@Override
public void deleteCoupon(Long id) {
HighCouponModel coupon = getCouponById(id);
HighCoupon coupon = getCouponById(id);
if (coupon == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_COUPON, "");
}
@ -256,7 +256,7 @@ public class HighCouponServiceImpl implements HighCouponService {
throw ErrorHelp.genException(SysCode.System, ErrorCode.STATUS_ERROR, "");
}
// 卡卷信息
HighCouponModel coupon = getCouponById(highGoodsPriceRefer.getObjectId());
HighCoupon coupon = getCouponById(highGoodsPriceRefer.getObjectId());
if (coupon == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_COUPON, "");
}
@ -278,12 +278,12 @@ public class HighCouponServiceImpl implements HighCouponService {
}
@Override
public HighCouponModel getCouponById(Long id) {
public HighCoupon getCouponById(Long id) {
HighCoupon highCoupon = highCouponMapper.selectByPrimaryKey(id);
if (highCoupon == null) {
return null;
}
HighCouponModel model = new HighCouponModel();
HighCoupon model = new HighCoupon();
BeanUtils.copyProperties(highCoupon, model);
// 查询有效库存
model.setStockCount(highCouponCodeService.getStockCountByCoupon(highCoupon.getId()));
@ -305,12 +305,12 @@ public class HighCouponServiceImpl implements HighCouponService {
}
@Override
public HighCouponModel getCouponDetail(Long id) {
public HighCoupon getCouponDetail(Long id) {
HighCoupon highCoupon = highCouponMapper.selectByPrimaryKey(id);
if (highCoupon == null) {
return null;
}
HighCouponModel model = new HighCouponModel();
HighCoupon model = new HighCoupon();
BeanUtils.copyProperties(highCoupon, model);
// 查询有效库存
model.setSalesCount(highCouponCodeService.getStockCountByCoupon(highCoupon.getId()));
@ -318,7 +318,7 @@ public class HighCouponServiceImpl implements HighCouponService {
}
@Override
public List<HighCouponModel> getCouponList(Map<String, Object> map) {
public List<HighCoupon> getCouponList(Map<String, Object> map) {
HighCouponExample example = new HighCouponExample();
HighCouponExample.Criteria criteria = example.createCriteria();
@ -346,16 +346,15 @@ public class HighCouponServiceImpl implements HighCouponService {
criteria.andStatusEqualTo(MapUtils.getInteger(map, "status"));
}
example.setOrderByClause("create_time desc");
List<HighCoupon> coupons = highCouponMapper.selectByExample(example);
if (coupons != null && coupons.size() > 0) {
List<HighCouponModel> models = JSON.parseArray(JSON.toJSONString(coupons), HighCouponModel.class);
for (HighCouponModel highCouponModel : models) {
highCouponModel.setMerchantName(highMerchantService.getMerchantById(highCouponModel.getMerchantId()).getMerchantName());
highCouponModel.setStockCount(highCouponCodeService.getStockCountByCoupon(highCouponModel.getId()));
for (HighCoupon highCoupon : coupons) {
highCoupon.setMerchantName(highMerchantService.getMerchantById(highCoupon.getMerchantId()).getMerchantName());
highCoupon.setStockCount(highCouponCodeService.getStockCountByCoupon(highCoupon.getId()));
}
return models;
}
return new ArrayList<>();
return coupons;
}
@Override

@ -86,7 +86,7 @@ public class HighOrderServiceImpl implements HighOrderService {
if (handselListByCoupon != null && handselListByCoupon.size() > 0) {
for (HighCouponHandsel highCouponHandsel : handselListByCoupon) {
// 查询卡卷信息
HighCouponModel coupon = highCouponService.getCouponById(highCouponHandsel.getHandselCouponId());
HighCoupon coupon = highCouponService.getCouponById(highCouponHandsel.getHandselCouponId());
if (coupon == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_COUPON, "");
}

@ -5,6 +5,7 @@ import com.hai.dao.HighUserCouponMapper;
import com.hai.entity.HighUserCoupon;
import com.hai.entity.HighUserCouponExample;
import com.hai.model.HighUserCouponModel;
import com.hai.service.HighCouponService;
import com.hai.service.HighUserCouponService;
import org.apache.commons.collections4.MapUtils;
import org.springframework.stereotype.Service;
@ -26,6 +27,9 @@ public class HighUserCouponServiceImpl implements HighUserCouponService {
@Resource
private HighUserCouponMapper highUserCouponMapper;
@Resource
private HighCouponService highCouponService;
@Override
public void insertUserCoupon(HighUserCoupon highUserCoupon) {
highUserCouponMapper.insert(highUserCoupon);
@ -56,7 +60,7 @@ public class HighUserCouponServiceImpl implements HighUserCouponService {
}
@Override
public List<HighUserCouponModel> getUserCouponList(Map<String, Object> map) {
public List<HighUserCoupon> getUserCouponList(Map<String, Object> map) {
HighUserCouponExample example = new HighUserCouponExample();
HighUserCouponExample.Criteria criteria = example.createCriteria();
@ -70,10 +74,12 @@ public class HighUserCouponServiceImpl implements HighUserCouponService {
example.setOrderByClause("create_time desc");
List<HighUserCoupon> highUserCoupons = highUserCouponMapper.selectByExample(example);
if (highUserCoupons != null && highUserCoupons.size() > 0) {
return JSON.parseArray(JSON.toJSONString(highUserCoupons), HighUserCouponModel.class);
if (highUserCoupons.size() > 0) {
for (HighUserCoupon highUserCoupon : highUserCoupons) {
highUserCoupon.setHighCouponModel(highCouponService.getCouponById(highUserCoupon.getCouponId()));
}
}
return new ArrayList<>();
return highUserCoupons;
}
@Override

Loading…
Cancel
Save