袁野 2 months ago
parent 752e68f359
commit c68e2d6b08
  1. 81
      order/src/main/java/com/order/controller/OrderController.java
  2. 43
      order/src/main/resources/dev/logback.xml
  3. 28
      order/src/main/resources/prod/logback.xml
  4. 78
      service/src/main/java/com/hfkj/common/utils/SignatureUtil.java
  5. 8
      service/src/main/java/com/hfkj/config/CommonSysConfig.java
  6. 67
      service/src/main/java/com/hfkj/haioil/HaiOilService.java
  7. 2
      service/src/main/java/com/hfkj/model/order/orderExport/OrderGoodsExportModel.java
  8. 52
      service/src/main/java/com/hfkj/service/SecConfigService.java
  9. 34
      service/src/main/java/com/hfkj/service/impl/SecConfigServiceImpl.java
  10. 6
      service/src/main/resources/dev/commonConfig.properties

@ -9,23 +9,30 @@ import com.hfkj.common.exception.SysCode;
import com.hfkj.common.security.UserCenter;
import com.hfkj.common.utils.PageUtil;
import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.common.utils.SignatureUtil;
import com.hfkj.config.CommonSysConst;
import com.hfkj.entity.BsOrder;
import com.hfkj.entity.BsOrderChild;
import com.hfkj.entity.BsOrderGoods;
import com.hfkj.entity.GoodsSpecs;
import com.hfkj.haioil.HaiOilService;
import com.hfkj.model.ResponseData;
import com.hfkj.model.UserSessionObject;
import com.hfkj.model.order.OrderChildModel;
import com.hfkj.model.order.OrderModel;
import com.hfkj.service.goods.BsOrderGoodsService;
import com.hfkj.service.goods.GoodsSpecsService;
import com.hfkj.service.order.BsOrderService;
import com.hfkj.service.order.impl.BsOrderChildServiceImpl;
import com.hfkj.service.pay.HuiPayService;
import com.hfkj.sysenum.UserStatusEnum;
import com.hfkj.sysenum.order.OrderChildProductTypeEnum;
import com.hfkj.sysenum.order.OrderPayChannelEnum;
import com.hfkj.sysenum.order.OrderPayTypeEnum;
import com.hfkj.sysenum.order.OrderStatusEnum;
import com.hfkj.sysenum.order.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
@ -49,6 +56,12 @@ public class OrderController {
private UserCenter userCenter;
@Resource
private BsOrderService orderService;
@Resource
private BsOrderChildServiceImpl orderChildService;
@Resource
private GoodsSpecsService goodsSpecsService;
@Resource
private BsOrderGoodsService orderGoodsService;
@RequestMapping(value="/create",method = RequestMethod.POST)
@ResponseBody
@ -265,4 +278,64 @@ public class OrderController {
}
}
@RequestMapping(value="/completeActivation",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "完成激活")
public ResponseData completeActivation(@RequestBody JSONObject body) {
try {
if (body == null|| StringUtils.isBlank(body.getString("childOrderNo"))) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
BsOrderChild bsOrderChild = orderChildService.getDetail(body.getString("childOrderNo"));
if (bsOrderChild.getStatus() != OrderChildStatusEnum.status2.getCode()) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前状态不可完成激活!");
}
// 子订单完成
orderService.childOrderComplete(bsOrderChild.getChildOrderNo());
// 赠送优惠券包
GoodsSpecs goodsSpecs = goodsSpecsService.queryDetailByGoodsId(bsOrderChild.getProductSpecId());
BsOrderGoods orderGoods = orderGoodsService.findGoodsOrderByChild(bsOrderChild.getChildOrderNo());
Map<String , Object> map = new HashMap<>();
map.put("discountPkNo" , goodsSpecs.getExt1());
map.put("number" , bsOrderChild.getProductCount());
map.put("phone" , orderGoods.getUserPhone());
HaiOilService.pushPk(map);
return ResponseMsgUtil.success("操作成功");
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/haiOilLogin",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "嗨加油登陆参数")
public ResponseData haiOilLogin(@RequestBody JSONObject body) {
try {
if (body == null|| StringUtils.isBlank(body.getString("phone"))) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
Map<String , Object> map = new HashMap<>();
map.put("appId" , CommonSysConst.getSysConfig().getHaiOilAppid());
map.put("phone" , body.getString("phone"));
map.put("sign" , SignatureUtil.createSign(map , CommonSysConst.getSysConfig().getHaiOilAppSecret()));
return ResponseMsgUtil.success(map);
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -268,4 +268,47 @@
</logger>
<!-- 美团接口 -->
<!--娱尚接口 -->
<appender name="YuShangLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>log/YuShangLog.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>log/YuShangLog/YuShangLog.log.%d.%i</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!-- or whenever the file size reaches 64 MB -->
<maxFileSize>64 MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<pattern>
%d %p (%file:%line\)- %m%n
</pattern>
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
</encoder>
</appender>
<logger name="com.hfkj.yushang.YuShangService" level="INFO">
<appender-ref ref="YuShangLog" />
</logger>
<!-- 娱尚接口 -->
<!--嗨加油接口 -->
<appender name="HaiOilLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>log/HaiOilLog.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>log/HaiOilLog/HaiOilLog.log.%d.%i</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!-- or whenever the file size reaches 64 MB -->
<maxFileSize>64 MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<pattern>
%d %p (%file:%line\)- %m%n
</pattern>
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
</encoder>
</appender>
<logger name="com.hfkj.haioil.HaiOilService" level="INFO">
<appender-ref ref="HaiOilLog" />
</logger>
<!-- 嗨加油接口 -->
</configuration>

@ -267,7 +267,7 @@
</logger>
<!-- 美团接口 -->
<!--美团接口 -->
<!--娱尚接口 -->
<appender name="YuShangLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>log/YuShangLog.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
@ -276,7 +276,7 @@
<!-- or whenever the file size reaches 64 MB -->
<maxFileSize>64 MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>7
</rollingPolicy>
<encoder>
<pattern>
%d %p (%file:%line\)- %m%n
@ -287,6 +287,28 @@
<logger name="com.hfkj.yushang.YuShangService" level="INFO">
<appender-ref ref="YuShangLog" />
</logger>
<!-- 美团接口 -->
<!-- 娱尚接口 -->
<!--嗨加油接口 -->
<appender name="HaiOilLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>log/HaiOilLog.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>log/HaiOilLog/HaiOilLog.log.%d.%i</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!-- or whenever the file size reaches 64 MB -->
<maxFileSize>64 MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<pattern>
%d %p (%file:%line\)- %m%n
</pattern>
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
</encoder>
</appender>
<logger name="com.hfkj.haioil.HaiOilService" level="INFO">
<appender-ref ref="HaiOilLog" />
</logger>
<!-- 嗨加油接口 -->
</configuration>

@ -0,0 +1,78 @@
package com.hfkj.common.utils;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import javax.xml.bind.annotation.adapters.HexBinaryAdapter;
import java.security.MessageDigest;
import java.util.Arrays;
import java.util.Map;
import java.util.Set;
public class SignatureUtil {
/**
* 参数签名
* @param param 参数
* @param key 秘钥
* @return
* @throws Exception
*/
public static String createSign(Object param, String key) throws Exception {
Map map = JSONObject.parseObject(JSONObject.toJSONString(param), Map.class);
return md5Encode(paramSort(map, key).getBytes());
}
/**
* 验证签名
* @param checkSign 需验证的签名字符串
* @param param 参数
* @param key 秘钥
* @return
* @throws Exception
*/
public static Boolean checkSign(String checkSign,Object param, String key) throws Exception {
Map map = JSONObject.parseObject(JSONObject.toJSONString(param), Map.class);
// 去除签名
map.remove("sign");
if (checkSign.equals(createSign(map, key))) {
return true;
}
return false;
}
/**
* 参数排序
* @param param
* @return
*/
public static String paramSort(final Map<String, Object> param, String key) {
Set<String> keySet = param.keySet();
String[] keyArray = keySet.toArray(new String[keySet.size()]);
Arrays.sort(keyArray);
StringBuilder sb = new StringBuilder();
for (String k : keyArray) {
if (StringUtils.isBlank(sb.toString())) {
sb.append(k).append("=").append(param.get(k));
} else {
sb.append("&").append(k).append("=").append(param.get(k));
}
}
sb.append("&key=").append(key);
return sb.toString();
}
/**
* MD5加密
* @param data
* @return
* @throws Exception
*/
public static String md5Encode(byte[] data) throws Exception {
// 初始化MessageDigest
MessageDigest md = MessageDigest.getInstance("MD5");
// 执行摘要信息
byte[] digest = md.digest(data);
// 将摘要信息转换为32位的十六进制字符串
return new String(new HexBinaryAdapter().marshal(digest));
}
}

@ -145,4 +145,12 @@ public class CommonSysConfig {
private String yuShangAppKey;
private String yuShangAppSecret;
private String yuShangPostUrl;
/**
* 嗨加油请求参数
*/
private String haiOilPostUrl;
private String haiOilAppid;
private String haiOilAppSecret;
}

@ -0,0 +1,67 @@
package com.hfkj.haioil;
import com.alibaba.fastjson.JSONObject;
import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode;
import com.hfkj.common.utils.HttpsUtils;
import com.hfkj.common.utils.SignatureUtil;
import com.hfkj.config.CommonSysConst;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Date;
import java.util.Map;
import java.util.Objects;
public class HaiOilService {
private static Logger log = LoggerFactory.getLogger(HaiOilService.class);
/**
* @MethodName pushPk
* @Description: 推送优惠券包
* @param map
* @return: com.alibaba.fastjson.JSONObject
* @Author: Sum1Dream
* @Date: 2024/9/9 下午2:57
*/
public static JSONObject pushPk(Map<String , Object> map) throws Exception {
JSONObject object = request("/openapi/discount/pushPk" , map);
if (Objects.equals(object.getString("return_code"), "000000")) {
return object;
} else {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请求失败!");
}
}
/**
* 请求
* @param postUrl 接口请求地址
* @param param 参数
* @return
* @throws Exception
*/
public static JSONObject request(String postUrl, Map<String,Object> param) throws Exception {
log.info("============ 嗨加油请求-START =============");
param.put("appId", CommonSysConst.getSysConfig().getHaiOilAppid());
param.put("reqId", new Date().getTime());
param.put("sign", SignatureUtil.createSign(param , CommonSysConst.getSysConfig().getHaiOilAppSecret()));
log.info("请求接口:" + postUrl);
log.info("请求参数:" + JSONObject.toJSONString(param));
JSONObject response = HttpsUtils.doPost(CommonSysConst.getSysConfig().getHaiOilPostUrl()+ postUrl, JSONObject.toJSONString(param));
log.info("响应参数:" + response.toJSONString());
log.info("============ 嗨加油请求-END ==============");
return response;
}
}

@ -113,7 +113,7 @@ public class OrderGoodsExportModel {
public Date updateTime;
@ColumnWidth(20)
@ExcelProperty("签收时间")
@ExcelProperty("确认收货时间")
public Date finishTime;

@ -0,0 +1,52 @@
package com.hfkj.service;
import com.hfkj.entity.SecConfig;
/**
* @ClassName SecConfigService.java
* @author Sum1Dream
* @version 1.0.0
* @Description //TODO
* @createTime 17:29 2021/6/23
**/
public interface SecConfigService {
/**
* @Author Sum1Dream
* @Name create
* @Description // 创建
* @Date 15:11 2024/4/19
* @Param GoodsBrand
* @return void
*/
void create(SecConfig secConfig);
/**
* @Author Sum1Dream
* @Name update
* @Description // 修改
* @Date 15:12 2024/4/19
* @Param GoodsBrand
* @return void
*/
void update(SecConfig secConfig);
/**
* @Author Sum1Dream
* @Name delete
* @Description // 修改
* @Date 15:12 2024/4/19
* @Param id
* @return void
*/
void delete(Integer id);
/**
* @Author Sum1Dream
* @Name queryDetail
* @Description // 根据ID查询产品类型详情
* @Date 15:12 2024/4/19
* @Param id
* @return com.hfkj.entity.GoodsBrand
*/
SecConfig queryDetail(Integer id);
}

@ -0,0 +1,34 @@
package com.hfkj.service.impl;
import com.hfkj.dao.SecConfigMapper;
import com.hfkj.entity.SecConfig;
import com.hfkj.service.SecConfigService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@Service("secConfigService")
public class SecConfigServiceImpl implements SecConfigService {
@Resource
private SecConfigMapper secConfigMapper;
@Override
public void create(SecConfig secConfig) {
secConfigMapper.insert(secConfig);
}
@Override
public void update(SecConfig secConfig) {
secConfigMapper.updateByPrimaryKeySelective(secConfig);
}
@Override
public void delete(Integer id) {
secConfigMapper.deleteByPrimaryKey(id);
}
@Override
public SecConfig queryDetail(Integer id) {
return secConfigMapper.selectByPrimaryKey(id);
}
}

@ -79,4 +79,8 @@ mtPostUrl=https://waimai-openapi.apigw.test.meituan.com/api/sqt/open/login/h5/lo
yuShangAppKey=211394653
yuShangAppSecret=cyQpQKMaGUG186iEZRt1uQ==
yuShangPostUrl=http://mbsmemberwebapi.test.onfishes.com/
yuShangPostUrl=http://mbsmemberwebapi.test.onfishes.com/
haiOilPostUrl = https://test-oil.dctpay.com
haiOilAppid = hf7356c71fb97ab0
haiOilAppSecret = 8aef995ff71485dc19b36e35f04c4016

Loading…
Cancel
Save