'提交代码'

dev-discount
= 4 years ago
parent 27d2ae09aa
commit ed24a97bb0
  1. 1
      hai-bweb/src/main/java/com/bweb/config/AuthConfig.java
  2. 81
      hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java
  3. 2
      hai-bweb/src/main/resources/dev/application.yml
  4. 11
      hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java
  5. 22
      hai-cweb/src/main/java/com/cweb/controller/HighTestController.java
  6. 35
      hai-service/src/main/java/com/hai/common/utils/HttpsUtils.java
  7. 37
      hai-service/src/main/java/com/hai/config/CommonSysConfig.java
  8. 77
      hai-service/src/main/java/com/hai/config/HuiLianTongConfig.java
  9. 30
      hai-service/src/main/java/com/hai/dao/HighCouponCodeMapperExt.java
  10. 16
      hai-service/src/main/java/com/hai/model/HighDiscountAgentCodeModel.java
  11. 8
      hai-service/src/main/java/com/hai/service/HighCouponCodeService.java
  12. 7
      hai-service/src/main/java/com/hai/service/HighCouponService.java
  13. 2
      hai-service/src/main/java/com/hai/service/HighOrderService.java
  14. 5
      hai-service/src/main/java/com/hai/service/impl/HighCouponCodeServiceImpl.java
  15. 11
      hai-service/src/main/java/com/hai/service/impl/HighCouponServiceImpl.java
  16. 15
      hai-service/src/main/java/com/hai/service/impl/HighDiscountAgentCodeServiceImpl.java
  17. 46
      hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java
  18. 33
      hai-service/src/main/java/com/hai/service/pay/impl/GoodsOrderServiceImpl.java
  19. 5
      hai-service/src/main/resources/dev/commonConfig.properties

@ -94,6 +94,7 @@ public class AuthConfig implements WebMvcConfigurer {
.excludePathPatterns("/common/*")
.excludePathPatterns("/sms/*")
.excludePathPatterns("/telApi/*")
.excludePathPatterns("/coupon/getGuizhouSinopec")
.excludePathPatterns("/cmsContent/get*")
;
}

@ -2,6 +2,7 @@ package com.bweb.controller;
import com.alibaba.excel.EasyExcel;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.bweb.excelListener.ImportCouponListener;
import com.bweb.model.ImportCouponModel;
@ -16,6 +17,7 @@ import com.hai.common.security.UserCenter;
import com.hai.common.utils.DateUtil;
import com.hai.common.utils.MemberValidateUtil;
import com.hai.common.utils.ResponseMsgUtil;
import com.hai.config.HuiLianTongConfig;
import com.hai.entity.*;
import com.hai.enum_type.ApproveType;
import com.hai.model.HighCouponHandselModel;
@ -295,11 +297,14 @@ public class HighCouponController {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COUPON_UNABLE_UP_SHELF, "");
}
// 中石化
if (coupon.getCouponSource() != 4) {
// 根据卡卷查询 销售码库存
if (highCouponCodeService.getStockCountByCoupon(coupon.getId()) == 0) {
log.error("HighCouponController -> upShelfApprove() error!","卡卷库存数量错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COUPON_STOCK_ERROR, "");
}
}
HighApprove approve = new HighApprove();
approve.setObjectType(ApproveType.UP_SHELF_APPROVE.getType());
@ -564,4 +569,80 @@ public class HighCouponController {
}
}
@RequestMapping(value="/getGuizhouSinopec",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "获取贵州中石化电子卡券")
public ResponseData getGuizhouSinopec(HttpServletRequest request) {
try {
SessionObject sessionObject = userCenter.getSessionObject(request);
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject();
if (userInfoModel.getBsCompany() == null) {
log.error("HighCouponController -> insertCoupon() error!","该主角色没有权限");
throw ErrorHelp.genException(SysCode.System, ErrorCode.MENU_TREE_HAS_NOT_ERROR, "");
}
// 查询商户
HighMerchant merchant = highMerchantService.getMerchantById(40L);
if (merchant == null) {
log.error("HighCouponController -> insertCoupon() error!","未找到商户");
throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_NOF_FOUND, "");
}
// 获取token
JSONObject tokenObject = HuiLianTongConfig.getToken();
if (!tokenObject.getString("result").equals("success")) {
log.error("HighCouponController -> insertCoupon() error!","获取token失败");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "获取token失败");
}
// 查询电子卡券类型
JSONObject corpCouTypes = HuiLianTongConfig.getCorpCouTypes(tokenObject.getString("data"));
if (!corpCouTypes.getString("result").equals("success")) {
log.error("HighCouponController -> insertCoupon() error!","获取电子卡券列表失败");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "获取电子卡券列表失败");
}
HighCoupon coupon;
JSONArray dataArray = corpCouTypes.getJSONArray("data");
if (dataArray != null && dataArray.size() > 0) {
for (Object object : dataArray) {
JSONObject dataObject = (JSONObject)object;
HighCoupon highCoupon = highCouponService.getCouponDetail(dataObject.getString("couTypeCode"));
if (highCoupon != null) {
continue;
}
coupon = new HighCoupon();
coupon.setCompanyId(userInfoModel.getBsCompany().getId());
coupon.setMerchantId(merchant.getId());
coupon.setCouponKey(dataObject.getString("couTypeCode"));
coupon.setCouponName(dataObject.getString("couTypeTitle"));
coupon.setCouponPrice(dataObject.getBigDecimal("couFaceValue"));
coupon.setCouponImg(dataObject.getString("couPic"));
coupon.setCouponCarouselImg(dataObject.getString("couPic"));
coupon.setCouponDesc(dataObject.getString("couDesc"));
coupon.setCouponType(2);
coupon.setSalesEndTime(dataObject.getDate("validEndDate"));
coupon.setRecycleDay(99);
coupon.setLimitNumber(99);
coupon.setSalesPrice(dataObject.getBigDecimal("couFaceValue"));
coupon.setDiscountPrice(dataObject.getBigDecimal("couFaceValue"));
coupon.setSalesCount(0);
coupon.setIsPresent(false);
coupon.setCreateTime(new Date());
coupon.setUpdateTime(new Date());
coupon.setOperatorId(0L);
coupon.setOperatorName("系统自动生成");
coupon.setPayType(2);
coupon.setStatus(1);
coupon.setDisplayArea(2);
coupon.setCouponSource(4);
highCouponService.insertCoupon(coupon);
}
}
return ResponseMsgUtil.success("操作成功");
} catch (Exception e) {
log.error("HighCouponController -> getGuizhouSinopec() error!",e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -9,7 +9,7 @@ debug: false
#datasource数据源设置
spring:
datasource:
url: jdbc:mysql://139.159.177.244:3306/hfkj?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false
url: jdbc:mysql://139.159.177.244:3306/hsg_pre?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false
username: root
password: HF123456.
type: com.alibaba.druid.pool.DruidDataSource

@ -140,14 +140,18 @@ public class HighOrderController {
} else {
childOrder.setGoodsPrice(coupon.getDiscountPrice());
}
// 贵州中石化
if (coupon.getCouponSource() != 4) {
if (highCouponCodeService.getStockCountByCoupon(coupon.getId()) <= 0) {
log.error("HighOrderController --> addOrder() error!", "卡卷库存数量不足");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COUPON_STOCK_INSUFFICIENT, "");
}
}
childOrder.setGoodsActualPrice(childOrder.getGoodsPrice());
childOrder.setGoodsName(coupon.getCouponName());
childOrder.setGoodsImg(coupon.getCouponImg());
childOrder.setGoodsSpecName("默认");
childOrder.setExt1(coupon.getCouponSource().toString());
}
if (childOrder.getGoodsType() == 2) {
@ -426,11 +430,4 @@ public class HighOrderController {
return ResponseMsgUtil.exception(e);
}
}
/*
public static void main(String[] args) {
BigDecimal bigDecimal1 = new BigDecimal("1200").divide(new BigDecimal("5.58"), 10, BigDecimal.ROUND_DOWN);
System.out.println(bigDecimal1);
BigDecimal bigDecimal2 = bigDecimal1.multiply(new BigDecimal("5.40")).setScale(2, BigDecimal.ROUND_HALF_UP);
System.out.println(bigDecimal2);
}*/
}

@ -173,7 +173,7 @@ public class HighTestController {
}
@RequestMapping(value = "/test2", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "测试")
@ApiOperation(value = "获取汇联通Token")
public ResponseData test2() {
try {
return ResponseMsgUtil.success(HuiLianTongConfig.getToken());
@ -186,9 +186,9 @@ public class HighTestController {
@RequestMapping(value = "/getCorpCouTypes", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "测试")
public ResponseData getCorpCouTypes() {
public ResponseData getCorpCouTypes(@RequestParam(name = "token", required = true) String token) {
try {
return ResponseMsgUtil.success(HuiLianTongConfig.getCorpCouTypes());
return ResponseMsgUtil.success(HuiLianTongConfig.getCorpCouTypes(token));
} catch (Exception e) {
log.error("HighOrderController --> getOrderById() error!", e);
return ResponseMsgUtil.exception(e);
@ -198,25 +198,13 @@ public class HighTestController {
@RequestMapping(value = "/couJointDist", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "测试")
public ResponseData couJointDist() {
public ResponseData couJointDist(@RequestParam(name = "token", required = true) String token) {
try {
return ResponseMsgUtil.success(HuiLianTongConfig.couJointDist());
return ResponseMsgUtil.success(HuiLianTongConfig.couJointDist(token,"20JY000251",2,"17726395120", "oArhO6XxKSvjI9wLP3cTK-iSG8yY"));
} catch (Exception e) {
log.error("HighOrderController --> getOrderById() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/queryOilCardAccount", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "测试")
public ResponseData queryOilCardAccount() {
try {
return ResponseMsgUtil.success(TuanYouConfig.queryCompanyAccountInfo2JD());
} catch (Exception e) {
log.error("HighOrderController --> queryOilCardAccount() error!", e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -343,6 +343,41 @@ public class HttpsUtils {
return null;
}
public static JSONObject doHuiLianTongPost(String apiUrl) {
CloseableHttpClient httpClient = null;
if (apiUrl.startsWith("https")) {
httpClient = HttpClients.custom().setSSLSocketFactory(createSSLConnSocketFactory())
.setConnectionManager(connMgr).setDefaultRequestConfig(requestConfig).build();
} else {
httpClient = HttpClients.createDefault();
}
String httpStr = null;
CloseableHttpResponse response = null;
try {
HttpPost httpPost = new HttpPost(apiUrl);
httpPost.setConfig(requestConfig);
StringEntity stringEntity = new StringEntity("", "UTF-8");// 解决中文乱码问题
stringEntity.setContentEncoding("UTF-8");
stringEntity.setContentType("application/x-www-form-urlencoded");
httpPost.setEntity(stringEntity);
response = httpClient.execute(httpPost);
HttpEntity entity = response.getEntity();
httpStr = EntityUtils.toString(entity, "UTF-8");
return JSON.parseObject(httpStr);
} catch (Exception e) {
log.error(e.getMessage(),e);
} finally {
if (response != null) {
try {
EntityUtils.consume(response.getEntity());
} catch (IOException e) {
log.error(e.getMessage(),e);
}
}
}
return null;
}
public static JSONObject doWxPost(String apiUrl, Map<String,String> body, Map<String,Object> header) {
CloseableHttpClient httpClient = null;
if (apiUrl.startsWith("https")) {

@ -22,6 +22,11 @@ public class CommonSysConfig {
private String qinzhuSecret;
private String qianzhuOrderNotify;
private String huiliantongUrl;
private String huiliantongAppNo;
private String huiliantongAppkey;
private String huiliantongAppsecret;
private String wx_cert;
private String telApiKey;
@ -30,6 +35,38 @@ public class CommonSysConfig {
private String telUrl;
private String czOrderNotify;
public String getHuiliantongAppNo() {
return huiliantongAppNo;
}
public void setHuiliantongAppNo(String huiliantongAppNo) {
this.huiliantongAppNo = huiliantongAppNo;
}
public String getHuiliantongUrl() {
return huiliantongUrl;
}
public void setHuiliantongUrl(String huiliantongUrl) {
this.huiliantongUrl = huiliantongUrl;
}
public String getHuiliantongAppkey() {
return huiliantongAppkey;
}
public void setHuiliantongAppkey(String huiliantongAppkey) {
this.huiliantongAppkey = huiliantongAppkey;
}
public String getHuiliantongAppsecret() {
return huiliantongAppsecret;
}
public void setHuiliantongAppsecret(String huiliantongAppsecret) {
this.huiliantongAppsecret = huiliantongAppsecret;
}
public String getQinzhuHtmlUrl() {
return qinzhuHtmlUrl;
}

@ -1,21 +1,20 @@
package com.hai.config;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hai.common.pay.util.sdk.WXPayConstants;
import com.hai.common.utils.HttpsUtils;
import com.hai.common.utils.MD5Util;
import com.hai.common.utils.WxUtils;
import com.hai.dao.HighGasOrderPushMapper;
import com.hai.entity.HighGasOrderPush;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.context.annotation.Configuration;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
import javax.annotation.Resource;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.security.MessageDigest;
import java.util.*;
@ -28,7 +27,6 @@ import java.util.*;
* @date 2021/7/5 14:18
*/
public class HuiLianTongConfig {
/**
* 获取token
* @return
@ -36,62 +34,67 @@ public class HuiLianTongConfig {
*/
public static JSONObject getToken() throws Exception {
Map<String,Object> map = new HashMap<>();
map.put("appNo", "guizhouhltcs");
map.put("appKey", MD5Util.encode("g%2BNnjR54YSUWM2iKg%2Fd82A9x9hg2kYV7".getBytes()));
return HttpsUtils.doPost("https://gzapitest.deepermobile.com.cn:441/api/api/auth/getAccessToken", JSON.toJSONString(map));
map.put("appNo",CommonSysConst.getSysConfig().getHuiliantongAppNo());
map.put("appKey", MD5Util.encode(CommonSysConst.getSysConfig().getHuiliantongAppkey().getBytes()));
return HttpsUtils.doPost(CommonSysConst.getSysConfig().getHuiliantongUrl()+"/api/api/auth/getAccessToken", JSON.toJSONString(map));
}
public static JSONObject getCorpCouTypes() throws Exception {
/**
* 获取电子券类型列表
* @param token
* @return
* @throws Exception
*/
public static JSONObject getCorpCouTypes(String token) {
Map<String,Object> param = new HashMap<>();
Map<String,Object> map = new HashMap<>();
map.put("token", "a::57D9BBA185484EAD82737168B28EDA62");
map.put("jsonData", get3DESEncryptECB(JSON.toJSONString(param), "FA28E95ACABFA4B2B8E25857437B07F1"));
map.put("token", token);
/* map.put("jsonData", get3DESEncryptECB(JSON.toJSONString(param), CommonSysConst.getSysConfig().getHuiliantongAppsecret()));
StringJoiner urlParamStr = new StringJoiner("&");
urlParamStr.add(String.format("jsonData=%s", param));
urlParamStr.add(String.format("secretKey=%s","FA28E95ACABFA4B2B8E25857437B07F1"));
map.put("sign", md5Capital(urlParamStr.toString()));
return HttpsUtils.doPost("https://gzapitest.deepermobile.com.cn:441/coupon/api/coupon_corp/getCorpCouTypes", JSON.toJSONString(map));
urlParamStr.add(String.format("secretKey=%s",CommonSysConst.getSysConfig().getHuiliantongAppsecret()));
map.put("sign", md5Capital(urlParamStr.toString()));*/
return HttpsUtils.doPost(CommonSysConst.getSysConfig().getHuiliantongUrl()+"/coupon/api/coupon_corp/getCorpCouTypes", JSON.toJSONString(map));
}
public static JSONObject couJointDist() throws Exception {
/**
* 商户派发电子券
* @param token
* @param couTypeCode 电子卡券类型
* @param distCouCount 分配数量
* @param userPhone 用户手机号
* @param thirdUserId 用户编号
* @return
* @throws Exception
*/
public static JSONObject couJointDist(String token,String couTypeCode,Integer distCouCount,String userPhone,String thirdUserId) throws Exception {
// 券列表
List<Map<String,Object>> objectList = new ArrayList<>();
Map<String,Object> object = new HashMap<>();
object.put("couTypeCode", "20JY000251");
object.put("distCouCount", 1);
object.put("couTypeCode", couTypeCode);
object.put("distCouCount", distCouCount);
objectList.add(object);
// 参数
Map<String,Object> param = new HashMap<>();
param.put("coupons", objectList);
param.put("phone", "17726395120");
param.put("thirdUserId", "oArhO6XxKSvjI9wLP3cTK-iSG8yY");
param.put("phone", userPhone);
param.put("thirdUserId", thirdUserId);
param.put("orderNo", "HF"+new Date().getTime());
param.put("distOuCode", "guizhouhltcs");
String appKey = "g%2BNnjR54YSUWM2iKg%2Fd82A9x9hg2kYV7";
String appSecret = "FA28E95ACABFA4B2B8E25857437B07F1";
Map<String,Object> map = new HashMap<>();
map.put("token", "a::57D9BBA185484EAD82737168B28EDA62");
map.put("jsonData", get3DESEncryptECB(JSON.toJSONString(param), appKey));
map.put("token", token);
map.put("jsonData", get3DESEncryptECB(JSON.toJSONString(param), CommonSysConst.getSysConfig().getHuiliantongAppkey()));
StringJoiner joiner = new StringJoiner("&");
joiner.add("jsonData=" + JSON.toJSONString(param));
joiner.add("secretKey=" + appSecret);
joiner.add("secretKey=" + CommonSysConst.getSysConfig().getHuiliantongAppsecret());
map.put("sign", md5Capital(joiner.toString()));
Map<String,Object> map1 = new HashMap<>();
String fromStr = "token="+MapUtils.getString(map, "token")+"&sign=" + MapUtils.getString(map, "sign")+"&jsonData=" + URLEncoder.encode(MapUtils.getString(map, "jsonData"),"UTF-8");
map1.put("from", "");
return HttpsUtils.doSmsPost("https://gzapitest.deepermobile.com.cn:441/coupon/api/coupon_corp/couJointDist?"+fromStr, map1, new HashMap<>());
String paramStr = "token="+MapUtils.getString(map, "token")+"&sign=" + MapUtils.getString(map, "sign")+"&jsonData=" + URLEncoder.encode(MapUtils.getString(map, "jsonData"),"UTF-8");
return HttpsUtils.doHuiLianTongPost(CommonSysConst.getSysConfig().getHuiliantongUrl() + "/coupon/api/coupon_corp/couJointDist?" + paramStr);
}
public static void main(String[] args) throws UnsupportedEncodingException {
String decode = URLDecoder.decode("jkE2O4ZKfL6F2IWQyf01oNXbCY%252FM1xZ7OP1%252BJVeXCfpWZgaFjIjZaVTPdJHkxRUlPJikskS6rQs1OMbMiu9ZgKaHftjA%252BJ7f%252BSFzsOPDPpnACegOBBR%252BjN5ZxOH%252FDPe9pOoGA53gBbAIEuqkDlqirxJyNR%252FJHip%252BoAQ2%252FN00pD1pIyvBqGsks%252Bx0w2w7GzYGcacU7iQrVHPhcFdyGFJUhWOaBMhRgNi0lJw9Pjt8xuY5IXwAjgk0EQ%253D%253D", "UTF-8");
System.out.println(decode);
System.out.println(get3DESDecryptECB(decode, "FA28E95ACABFA4B2B8E25857437B07F1"));
}
public static String get3DESEncryptECB(String src,String secretKey) {
try {

@ -1,8 +1,8 @@
package com.hai.dao;
import com.hai.entity.HighCouponCode;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;
import java.util.List;
@ -57,4 +57,30 @@ public interface HighCouponCodeMapperExt {
})
void insertList(@Param(value = "list") List<HighCouponCode> list);
@Select("select * from high_coupon_code where child_order_id = (SELECT b.id child_order_id FROM high_order a,high_child_order b where a.mem_discount_id = #{discountUserRelId} and a.id = b.order_id and b.goods_type = 1 and b.child_orde_status in (2,3,4))")
@Results({
@Result(column="id", property="id", jdbcType= JdbcType.BIGINT, id=true),
@Result(column="coupon_id", property="couponId", jdbcType=JdbcType.BIGINT),
@Result(column="merchant_id", property="merchantId", jdbcType=JdbcType.BIGINT),
@Result(column="is_assign_agent", property="isAssignAgent", jdbcType=JdbcType.BIT),
@Result(column="agent_id", property="agentId", jdbcType=JdbcType.BIGINT),
@Result(column="store_id", property="storeId", jdbcType=JdbcType.BIGINT),
@Result(column="store_name", property="storeName", jdbcType=JdbcType.VARCHAR),
@Result(column="child_order_id", property="childOrderId", jdbcType=JdbcType.BIGINT),
@Result(column="code_key", property="codeKey", jdbcType=JdbcType.VARCHAR),
@Result(column="sales_code", property="salesCode", jdbcType=JdbcType.VARCHAR),
@Result(column="sales_end_time", property="salesEndTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="use_end_time", property="useEndTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="receive_time", property="receiveTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="consume_time", property="consumeTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
@Result(column="operator_id", property="operatorId", jdbcType=JdbcType.BIGINT),
@Result(column="operator_name", property="operatorName", jdbcType=JdbcType.VARCHAR),
@Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR),
@Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR),
@Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR)
})
HighCouponCode selectCouponCodeByUserDiscount(@Param("discountUserRelId") Long discountUserRelId);
}

@ -1,9 +1,6 @@
package com.hai.model;
import com.hai.entity.HighAgent;
import com.hai.entity.HighDiscount;
import com.hai.entity.HighOrder;
import com.hai.entity.HighUser;
import com.hai.entity.*;
/**
* 优惠券码
@ -16,12 +13,23 @@ public class HighDiscountAgentCodeModel {
// 优惠券
private HighDiscount highDiscount;
// 卡券码
private HighCouponCode highCouponCode;
// 订单
private HighOrder highOrder;
// 用户
private HighUser highUser;
public HighCouponCode getHighCouponCode() {
return highCouponCode;
}
public void setHighCouponCode(HighCouponCode highCouponCode) {
this.highCouponCode = highCouponCode;
}
public HighAgent getHighAgent() {
return highAgent;
}

@ -1,5 +1,6 @@
package com.hai.service;
import com.hai.entity.HighCoupon;
import com.hai.entity.HighCouponCode;
import com.hai.model.UserInfoModel;
@ -56,6 +57,13 @@ public interface HighCouponCodeService {
**/
HighCouponCode getCouponCodeByOrderId(Long childOrderId);
/**
* 根据用户优惠券查询
* @param discountUserRelId
* @return
*/
HighCouponCode getCouponCodeByUserDiscount(Long discountUserRelId);
/**
* @Author 胡锐
* @Description 根据销售码查询

@ -91,6 +91,13 @@ public interface HighCouponService {
**/
HighCoupon getCouponDetail(Long id);
/**
* 根据卡券key查询
* @param couponKey
* @return
*/
HighCoupon getCouponDetail(String couponKey);
/**
* @Author 胡锐
* @Description 获取卡卷集合

@ -33,7 +33,7 @@ public interface HighOrderService {
* @Description 金币支付订单
* @Date 2021/3/27 11:20
**/
void goldPayOrder(Long userId, Long orderId);
void goldPayOrder(Long userId, Long orderId) throws Exception;
/**
* @Author 胡锐

@ -195,6 +195,11 @@ public class HighCouponCodeServiceImpl implements HighCouponCodeService {
return null;
}
@Override
public HighCouponCode getCouponCodeByUserDiscount(Long discountUserRelId) {
return null;
}
@Override
public HighCouponCode getCouponCodeBySalesCode(String code) {
HighCouponCodeExample example = new HighCouponCodeExample();

@ -320,6 +320,17 @@ public class HighCouponServiceImpl implements HighCouponService {
return model;
}
@Override
public HighCoupon getCouponDetail(String couponKey) {
HighCouponExample example = new HighCouponExample();
example.createCriteria().andCouponKeyEqualTo(couponKey).andStatusNotEqualTo(0);
List<HighCoupon> list = highCouponMapper.selectByExample(example);
if (list.size() > 0) {
return list.get(0);
}
return null;
}
@Override
public List<HighCoupon> getCouponList(Map<String, Object> map) {
HighCouponExample example = new HighCouponExample();

@ -1,5 +1,6 @@
package com.hai.service.impl;
import com.hai.dao.HighCouponCodeMapper;
import com.hai.dao.HighDiscountAgentCodeMapper;
import com.hai.entity.*;
import com.hai.service.*;
@ -24,6 +25,9 @@ public class HighDiscountAgentCodeServiceImpl implements HighDiscountAgentCodeSe
@Resource
private HighDiscountAgentRelService highDiscountAgentRelService;
@Resource
private HighCouponCodeMapper highCouponCodeMapper;
@Resource
private HighDiscountService highDiscountService;
@ -71,16 +75,15 @@ public class HighDiscountAgentCodeServiceImpl implements HighDiscountAgentCodeSe
List<HighDiscountAgentCode> list = highDiscountAgentCodeMapper.selectByExample(example);
for (HighDiscountAgentCode code : list) {
HighDiscountAgentRel rel = highDiscountAgentRelService.getRelById(code.getDiscountAgentId());
if (rel != null) {
code.setHighDiscount(highDiscountService.getDiscountById(rel.getDiscountId()));
code.setHighAgent(highAgentService.findByAgentMsgId(rel.getAgentId()));
}
HighDiscountUserRel userRel = highDiscountUserRelService.getRelByDiscount(code.getId());
if (userRel != null) {
code.setHighUser(highUserService.findByUserId(userRel.getUserId()));
}
if (rel != null) {
code.setHighDiscount(highDiscountService.getDiscountById(rel.getDiscountId()));
code.setHighAgent(highAgentService.findByAgentMsgId(rel.getAgentId()));
code.setHighCouponCode(highCouponCodeMapper.selectCouponCodeByUserDiscount(userRel.getId()));
}
}
return list;

@ -1,11 +1,13 @@
package com.hai.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.hai.common.QRCodeGenerator;
import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode;
import com.hai.common.utils.DateUtil;
import com.hai.common.utils.IDGenerator;
import com.hai.config.HuiLianTongConfig;
import com.hai.dao.*;
import com.hai.entity.*;
import com.hai.model.HighCouponHandselModel;
@ -49,6 +51,9 @@ public class HighOrderServiceImpl implements HighOrderService {
@Resource
private HighCouponService highCouponService;
@Resource
private HighGasOrderPushMapper highGasOrderPushMapper;
@Resource
private HighCouponHandselService highCouponHandselService;
@ -91,6 +96,9 @@ public class HighOrderServiceImpl implements HighOrderService {
// 商品类型 1:卡卷
if (childOrder.getGoodsType() == 1) {
// 查询卡券
HighCoupon couponDetail = highCouponService.getCouponDetail(childOrder.getGoodsId());
if (couponDetail.getCouponSource() != 4) {
// 查询待销售
List<HighCouponCode> list = highCouponCodeService.getNoSaleCode(childOrder.getGoodsId());
if (list == null || list.size() == 0) {
@ -99,10 +107,9 @@ public class HighOrderServiceImpl implements HighOrderService {
list.get(0).setChildOrderId(childOrder.getId());
list.get(0).setStatus(99); // 状态:1.待销售 2.未使用 3.已使用 99.预支付
highCouponCodeService.updateCouponCode(list.get(0));
childOrder.setExt1(list.get(0).getExt1());
highChildOrderMapper.updateByPrimaryKey(childOrder);
}
if(!childOrder.getGiveawayType()) {
// 查看是否需要赠送卡卷
List<HighCouponHandselModel> handselListByCoupon = highCouponHandselService.getHandselListByCoupon(childOrder.getGoodsId());
@ -146,12 +153,15 @@ public class HighOrderServiceImpl implements HighOrderService {
@Override
@Transactional(propagation= Propagation.REQUIRES_NEW)
public void goldPayOrder(Long userId, Long orderId) {
public void goldPayOrder(Long userId, Long orderId) throws Exception {
HighOrder highOrder = getOrderById(orderId);
if(highOrder == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_ORDER, "");
}
// 查询用户
HighUser highUser = highUserService.findByUserId(highOrder.getMemId());
// 金币 1:100
Integer goldNum = new BigDecimal(highOrder.getTotalPrice().toString()).multiply(new BigDecimal("100")).intValue();
highUserService.goldHandle(userId, goldNum, 2, 2, highOrder.getId());
@ -167,13 +177,38 @@ public class HighOrderServiceImpl implements HighOrderService {
// 商品类型 商品类型 1:卡卷 2:金币充值
if (highChildOrder.getGoodsType() == 1) {
// 查询卡券
HighCoupon coupon = highCouponService.getCouponDetail(highChildOrder.getGoodsId());
// 贵州高速
if (coupon.getCouponSource() == 4) {
// 获取token
JSONObject tokenObject = HuiLianTongConfig.getToken();
if (!tokenObject.getString("result").equals("success")) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "获取token失败");
}
Map<String,Object> push = new HashMap<>();
push.put("token", "data");
push.put("couTypeCode", coupon.getCouponKey());
push.put("distCouCount", highChildOrder.getSaleCount());
push.put("userPhone", highUser.getPhone());
push.put("thirdUserId", highUser.getUnionId());
// 推送给高速
JSONObject returnParam = HuiLianTongConfig.couJointDist(tokenObject.getString("data"), coupon.getCouponKey(), highChildOrder.getSaleCount(), highUser.getPhone(), highUser.getUnionId());
// 推送记录
HighGasOrderPush highGasOrderPush = new HighGasOrderPush();
highGasOrderPush.setCreateTime(new Date());
highGasOrderPush.setCode(returnParam.getString("result"));
highGasOrderPush.setRequestContent(JSONObject.toJSONString(push));
highGasOrderPush.setReturnContent(returnParam.toJSONString());
highGasOrderPushMapper.insert(highGasOrderPush);
} else {
HighCouponCode code = highCouponCodeService.getCouponCodeByOrderId(highChildOrder.getId());
code.setStatus(2); // 状态:1.待销售 2.未使用 3.已使用 99.预支付
code.setReceiveTime(new Date());
highCouponCodeService.updateCouponCode(code);
HighCoupon coupon = highCouponService.getCouponById(highChildOrder.getGoodsId());
// 卡卷关联用户
HighUserCoupon highUserCoupon = new HighUserCoupon();
highUserCoupon.setMerchantId(code.getMerchantId());
@ -200,6 +235,7 @@ public class HighOrderServiceImpl implements HighOrderService {
highUserCouponMapper.insert(highUserCoupon);
}
}
}
updateOrder(highOrder);
}

@ -8,6 +8,7 @@ import com.hai.common.pay.util.XmlUtil;
import com.hai.common.pay.util.sdk.WXPayConstants;
import com.hai.common.utils.WxUtils;
import com.hai.config.CommonSysConst;
import com.hai.config.HuiLianTongConfig;
import com.hai.config.TuanYouConfig;
import com.hai.dao.HighGasOrderPushMapper;
import com.hai.dao.HighUserCouponMapper;
@ -85,6 +86,10 @@ public class GoodsOrderServiceImpl implements PayService {
if (order == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_ORDER, "");
}
// 查询用户
HighUser highUser = highUserService.findByUserId(order.getMemId());
if (order.getOrderStatus() == 1) {
order.setPaySerialNo(map.get("transaction_id")); // 支付流水号
order.setPayRealPrice(new BigDecimal(map.get("total_fee")).divide(new BigDecimal("100"))); // 实付金额
@ -103,7 +108,34 @@ public class GoodsOrderServiceImpl implements PayService {
highCouponCodeService.updateCouponCode(code);
HighCoupon coupon = highCouponService.getCouponById(highChildOrder.getGoodsId());
// 贵州中石化
if (coupon.getCouponSource() != 4) {
// 获取token
JSONObject tokenObject = HuiLianTongConfig.getToken();
if (!tokenObject.getString("result").equals("success")) {
log.error("HighCouponController -> insertCoupon() error!","获取token失败");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "获取token失败");
}
Map<String,Object> push = new HashMap<>();
push.put("token", "data");
push.put("couTypeCode", coupon.getCouponKey());
push.put("distCouCount", highChildOrder.getSaleCount());
push.put("userPhone", highUser.getPhone());
push.put("thirdUserId", highUser.getUnionId());
// 推送给高速
JSONObject returnParam = HuiLianTongConfig.couJointDist(tokenObject.getString("data"), coupon.getCouponKey(), highChildOrder.getSaleCount(), highUser.getPhone(), highUser.getUnionId());
// 推送记录
HighGasOrderPush highGasOrderPush = new HighGasOrderPush();
highGasOrderPush.setCreateTime(new Date());
highGasOrderPush.setCode(returnParam.getString("result"));
highGasOrderPush.setRequestContent(JSONObject.toJSONString(push));
highGasOrderPush.setReturnContent(returnParam.toJSONString());
highGasOrderPushMapper.insert(highGasOrderPush);
} else {
// 卡卷关联用户
HighUserCoupon highUserCoupon = new HighUserCoupon();
highUserCoupon.setMerchantId(code.getMerchantId());
@ -128,6 +160,7 @@ public class GoodsOrderServiceImpl implements PayService {
highUserCoupon.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用
highUserCouponMapper.insert(highUserCoupon);
}
}
if (highChildOrder.getGoodsType() == 2) {
highChildOrder.setChildOrdeStatus(3); // 子订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消

@ -10,6 +10,11 @@ qinzhuPlatformId=10376
qinzhuSecret=ktxb49sh2jfhgn8g
qianzhuOrderNotify=https://hsg.dctpay.com/crest/qianzhu/orderNotify
huiliantongUrl=https://gzapitest.deepermobile.com.cn:441
huiliantongAppNo=guizhouhltcs
huiliantongAppkey=g%2BNnjR54YSUWM2iKg%2Fd82A9x9hg2kYV7
huiliantongAppsecret=FA28E95ACABFA4B2B8E25857437B07F1
wx_cert=/home/project/wx_cert/
TelApiKey=2d01f6b520254b1a80f6b167832cea18

Loading…
Cancel
Save