'修复已知问题'

dev-discount
199901012 4 years ago
parent 8d22528028
commit 659ad7ea5f
  1. 16
      hai-cweb/src/main/java/com/cweb/controller/HighCouponController.java
  2. 1
      hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java
  3. 64
      hai-schedule/src/main/java/com/hai/schedule/SynchronizeCNPC.java
  4. 7
      hai-service/src/main/java/com/hai/service/HighCouponCodeService.java
  5. 8
      hai-service/src/main/java/com/hai/service/HighUserCouponService.java
  6. 2
      hai-service/src/main/java/com/hai/service/SecSinopecConfigService.java
  7. 32
      hai-service/src/main/java/com/hai/service/impl/HighCouponCodeServiceImpl.java
  8. 9
      hai-service/src/main/java/com/hai/service/impl/HighUserCouponServiceImpl.java
  9. 2
      hai-service/src/main/java/com/hai/service/impl/SecSinopecConfigServiceImpl.java

@ -149,24 +149,20 @@ public class HighCouponController {
@RequestMapping(value = "/getUserCouponDetail", method = RequestMethod.GET) @RequestMapping(value = "/getUserCouponDetail", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "获取用户卡卷详细") @ApiOperation(value = "获取用户卡卷详细")
public ResponseData getUserCouponDetail(@RequestParam(name = "couponId", required = true) Long couponId, public ResponseData getUserCouponDetail(@RequestParam(name = "userCouponId", required = true) Long userCouponId,
HttpServletRequest request) { HttpServletRequest request) {
try { try {
// 用户 HighUserCoupon coupon = highUserCouponService.getDetailById(userCouponId);
SessionObject sessionObject = userCenter.getSessionObject(request);
HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject();
HighUserCoupon coupon = highUserCouponService.getUserCoupon(userInfoModel.getHighUser().getId(), couponId);
if (coupon == null) { if (coupon == null) {
log.error("HighCouponController --> getUserCouponDetail() error!", "卡卷库存数量不足"); log.error("HighCouponController --> getUserCouponDetail() error!", "未找到卡券");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, ""); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到卡券");
} }
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("highUserCoupon", coupon); map.put("highUserCoupon", coupon);
map.put("couponInfo", highCouponService.getCouponById(coupon.getCouponId())); map.put("couponInfo", highCouponService.getCouponById(coupon.getCouponId()));
map.put("couponCodeInfo", highCouponCodeService.getCouponCodeById(coupon.getCouponCodeId())); //map.put("couponCodeInfo", highCouponCodeService.getCouponCodeById(coupon.getCouponCodeId()));
return ResponseMsgUtil.success(map); return ResponseMsgUtil.success(map);
@ -194,7 +190,7 @@ public class HighCouponController {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("highUserCoupon", userCoupon); map.put("highUserCoupon", userCoupon);
map.put("couponInfo", highCouponService.getCouponById(userCoupon.getCouponId())); map.put("couponInfo", highCouponService.getCouponById(userCoupon.getCouponId()));
map.put("couponCodeInfo", highCouponCodeService.getCouponCodeById(userCoupon.getCouponCodeId())); //map.put("couponCodeInfo", highCouponCodeService.getCouponCodeById(userCoupon.getCouponCodeId()));
return ResponseMsgUtil.success(map); return ResponseMsgUtil.success(map);
} catch (Exception e) { } catch (Exception e) {

@ -159,6 +159,7 @@ public class HighOrderController {
childOrder.setGoodsSpecName("默认"); childOrder.setGoodsSpecName("默认");
} }
childOrder.setMemId(userInfoModel.getHighUser().getId());
childOrder.setTotalPrice(childOrder.getGoodsPrice().multiply(new BigDecimal(childOrder.getSaleCount().toString()))); childOrder.setTotalPrice(childOrder.getGoodsPrice().multiply(new BigDecimal(childOrder.getSaleCount().toString())));
childOrder.setGiveawayType(false); // 是否是赠品 0:否 1:是 childOrder.setGiveawayType(false); // 是否是赠品 0:否 1:是
childOrder.setChildOrdeStatus(1); // 1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消 childOrder.setChildOrdeStatus(1); // 1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消

@ -1,21 +1,25 @@
package com.hai.schedule; package com.hai.schedule;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.hai.common.utils.DateUtil;
import com.hai.common.utils.HttpsUtils; import com.hai.common.utils.HttpsUtils;
import com.hai.entity.HighOrder; import com.hai.entity.HighOrder;
import com.hai.entity.SecSinopecConfig;
import com.hai.service.HighCouponCodeService;
import com.hai.service.SecSinopecConfigService;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import springfox.documentation.spring.web.json.Json;
import javax.annotation.Resource;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.util.Date; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/** /**
* @Auther: 胡锐 * @Auther: 胡锐
@ -29,33 +33,65 @@ public class SynchronizeCNPC {
private static final String[] HEX_DIGITS = {"0" ,"1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"}; private static final String[] HEX_DIGITS = {"0" ,"1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"};
//@Scheduled(cron="0 0/1 * * * ?") //每1分钟执行一次 @Resource
private HighCouponCodeService highCouponCodeService;
@Resource
private SecSinopecConfigService secSinopecConfigService;
@Scheduled(cron="0 0/1 * * * ?") //每1分钟执行一次
public void certification() { public void certification() {
List<SecSinopecConfig> sinopecConfig = secSinopecConfigService.getListSinopecConfig(new HashMap<>());
for (SecSinopecConfig config : sinopecConfig) {
Map<String, Object> tokenMap = new HashMap<>(); Map<String, Object> tokenMap = new HashMap<>();
tokenMap.put("appId", "jsVpwDoHZfR2rrpjhA"); tokenMap.put("appId", config.getAppId());
tokenMap.put("appSecret", "R7yJjinikdPhOlTrVgmdS7cblWMMOf99zEJkfPgaTIoDtKGlX51JKueLV725a6S4"); tokenMap.put("appSecret", config.getAppSecret());
JSONObject jsonObject = HttpsUtils.doPost("https://app.zshcqsy.com/api-provider/api/open/merchant/token", JSON.toJSONString(tokenMap)); JSONObject jsonObject = HttpsUtils.doPost("https://app.zshcqsy.com/api-provider/api/open/merchant/token", JSON.toJSONString(tokenMap));
log.error(jsonObject.toJSONString()); log.error(jsonObject.toJSONString());
if (jsonObject != null && jsonObject.getBoolean("success") == true) { if (jsonObject != null && jsonObject.getBoolean("success") == true) {
JSONObject data = jsonObject.getJSONObject("data"); JSONObject data = jsonObject.getJSONObject("data");
String token = data.getString("token"); String token = data.getString("token");
Calendar instance = Calendar.getInstance();
instance.add(Calendar.MINUTE, -10);
Map<String,Object> bodyMap = new HashMap<>(); Map<String,Object> bodyMap = new HashMap<>();
bodyMap.put("appId", "jsVpwDoHZfR2rrpjhA"); bodyMap.put("appId", config.getAppId());
bodyMap.put("pageNo", 1); bodyMap.put("pageNo", 1);
bodyMap.put("pageSize", 10); bodyMap.put("pageSize", 100);
bodyMap.put("startTime", new Date()); bodyMap.put("startTime", instance.getTime());
bodyMap.put("endTime", new Date()); bodyMap.put("endTime", new Date());
bodyMap.put("customerCode", "48464274"); bodyMap.put("customerCode", config.getCode());
String signature = "hAFO76ZqXmIqosNw3PTAP4wxGJTN7MPawSU0QFDzzNioLjKMEaVFDlNKRIQX6n0DgyoVMy170T0b13P8uUTAQsbk9UNRPFO5i0fWp1hHOhNdaaQ2BdC0WXQz5QQ5epyK";
Long date = new Date().getTime(); Long date = new Date().getTime();
String sha256 = encodeBySHA256(signature + JSON.toJSONString(bodyMap) + date); String sha256 = encodeBySHA256(config.getSignkey() + JSON.toJSONString(bodyMap) + date);
JSONObject object = HttpsUtils.doPost("https://app.zshcqsy.com/api-provider/sapapi/open/coupon/customerRedeemcodeList", JSON.toJSONString(bodyMap), token, sha256, date); JSONObject object = HttpsUtils.doPost("https://app.zshcqsy.com/api-provider/sapapi/open/coupon/customerRedeemcodeList", JSON.toJSONString(bodyMap), token, sha256, date);
//JSONObject object = JSONObject.parseObject("{\"code\":1000,\"data\":{\"pageNo\":1,\"pageSize\":100,\"rowCount\":\"2\",\"list\":[{\"nodeName\":\"中国石油化工股份有限公司重庆江南石油分公司大学城南二路加油加\",\"totalAmount\":150.00,\"codeId\":\"01DIhbtPzIghPP0mPWaWzO13\",\"nodeNo\":\"50000105\",\"name\":\"重庆惠昕石化有限责任公司11.02日150元券\",\"useTime\":\"2021-04-03 06:11:14\"},{\"nodeName\":\"中国石化销售有限公司重庆三峡分公司忠县经营部三台加油站\",\"totalAmount\":100.00,\"codeId\":\"201126141728001027\",\"nodeNo\":\"50000238\",\"name\":\"重庆惠昕石化有限责任公司11.26日100元券\",\"useTime\":\"2021-04-03 15:16:03\"}]},\"success\":true}");
if(Objects.equals(object.get("success"), true)) {
log.error(JSONObject.toJSONString(object.get("data")));
Object dataJson = JSONObject.parse(JSONObject.toJSONString(object.get("data")));
JSONObject dataObject = JSON.parseObject(JSONObject.toJSONString(dataJson));
JSONArray list = dataObject.getJSONArray("list");
for (Object dataJsonObject : list) {
try {
JSONObject parseObject = JSON.parseObject(JSON.toJSONString(dataJsonObject));
String codeId = parseObject.getString("codeId");
Date useTime = DateUtil.format(parseObject.getString("useTime"), "yyyy-MM-dd HH:mm:ss");
highCouponCodeService.cnpcCallbackCouponCode(codeId, useTime);
} catch (Exception e) {
log.error("HighCouponSchedule --> expiredCoupon() error!", e);
}
}
}
log.error(object.toJSONString()); log.error(object.toJSONString());
} }
} }
}
public String encodeBySHA256(String str) { public String encodeBySHA256(String str) {
try{ try{

@ -43,6 +43,13 @@ public interface HighCouponCodeService {
**/ **/
void useCouponCode(String code, UserInfoModel userInfoModel); void useCouponCode(String code, UserInfoModel userInfoModel);
/**
* @Author 胡锐
* @Description 中石化回调已使用的消核码
* @Date 2021/4/19 21:53
**/
void cnpcCallbackCouponCode(String salesCode,Date useTime);
/** /**
* @Author 胡锐 * @Author 胡锐
* @Description 根据订单id查询 * @Description 根据订单id查询

@ -1,5 +1,6 @@
package com.hai.service; package com.hai.service;
import com.hai.entity.HighUser;
import com.hai.entity.HighUserCoupon; import com.hai.entity.HighUserCoupon;
import com.hai.model.HighUserCouponModel; import com.hai.model.HighUserCouponModel;
@ -41,6 +42,13 @@ public interface HighUserCouponService {
**/ **/
HighUserCoupon getDetailByCodeId(Long couponCodeId); HighUserCoupon getDetailByCodeId(Long couponCodeId);
/**
* @Author 胡锐
* @Description 根据关系id查询
* @Date 2021/4/20 19:23
**/
HighUserCoupon getDetailById(Long userCouponId);
/** /**
* @Author 胡锐 * @Author 胡锐
* @Description 查询用户列表 * @Description 查询用户列表

@ -26,7 +26,7 @@ public interface SecSinopecConfigService {
* @throws Exception 抛出异常 * @throws Exception 抛出异常
*/ */
List<SecSinopecConfig> getListSinopecConfig(Map<String , String> map) throws Exception; List<SecSinopecConfig> getListSinopecConfig(Map<String , String> map);
/** /**
* *

@ -111,7 +111,7 @@ public class HighCouponCodeServiceImpl implements HighCouponCodeService {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "卡卷状态异常"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "卡卷状态异常");
} }
HighChildOrder order = highOrderService.getChildOrderByUserGoods(userCoupon.getUserId(), 1, userCoupon.getCouponCodeId()); HighChildOrder order = highOrderService.getChildOrderByUserGoods(userCoupon.getUserId(), 1, userCoupon.getCouponId());
if (order == null) { if (order == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单");
} }
@ -122,6 +122,36 @@ public class HighCouponCodeServiceImpl implements HighCouponCodeService {
highOrderService.childOrderComplete(order.getId()); highOrderService.childOrderComplete(order.getId());
} }
@Override
@Transactional
public void cnpcCallbackCouponCode(String salesCode, Date useTime) {
HighCouponCode code = getCouponCodeBySalesCode(salesCode);
if (code != null && code.getStatus() != 3) {
code.setStatus(3);
code.setConsumeTime(useTime);
updateCouponCode(code);
Map<String, Object> map = new HashMap<>();
map.put("status", "1");
map.put("couponCodeId", code.getId());
List<HighUserCoupon> list = highUserCouponService.getUserCouponList(map);
for (HighUserCoupon userCoupon : list) {
userCoupon.setStatus(2);
userCoupon.setConsumeTime(useTime);
HighChildOrder order = highOrderService.getChildOrderByUserGoods(userCoupon.getUserId(), 1, userCoupon.getCouponId());
if (order == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单");
}
userCoupon.setConsumeTime(new Date());
userCoupon.setStatus(2); // 状态 0:已过期 1:未使用 2:已使用
highUserCouponService.updateUserCoupon(userCoupon);
highOrderService.childOrderComplete(order.getId());
}
}
}
@Override @Override
public HighCouponCode getCouponCodeByOrderId(Long childOrderId) { public HighCouponCode getCouponCodeByOrderId(Long childOrderId) {
HighCouponCodeExample example = new HighCouponCodeExample(); HighCouponCodeExample example = new HighCouponCodeExample();

@ -71,6 +71,11 @@ public class HighUserCouponServiceImpl implements HighUserCouponService {
return null; return null;
} }
@Override
public HighUserCoupon getDetailById(Long userCouponId) {
return highUserCouponMapper.selectByPrimaryKey(userCouponId);
}
@Override @Override
public List<HighUserCoupon> getUserCouponList(Map<String, Object> map) { public List<HighUserCoupon> getUserCouponList(Map<String, Object> map) {
HighUserCouponExample example = new HighUserCouponExample(); HighUserCouponExample example = new HighUserCouponExample();
@ -88,6 +93,10 @@ public class HighUserCouponServiceImpl implements HighUserCouponService {
criteria.andStatusEqualTo(MapUtils.getInteger(map, "status")); criteria.andStatusEqualTo(MapUtils.getInteger(map, "status"));
} }
if (MapUtils.getLong(map, "couponCodeId") != null) {
criteria.andCouponCodeIdEqualTo(MapUtils.getLong(map, "couponCodeId"));
}
criteria.andStatusNotEqualTo(100); criteria.andStatusNotEqualTo(100);
example.setOrderByClause("create_time desc"); example.setOrderByClause("create_time desc");
List<HighUserCoupon> highUserCoupons = highUserCouponMapper.selectByExample(example); List<HighUserCoupon> highUserCoupons = highUserCouponMapper.selectByExample(example);

@ -18,7 +18,7 @@ public class SecSinopecConfigServiceImpl implements SecSinopecConfigService {
private SecSinopecConfigMapper secSinopecConfigMapper; private SecSinopecConfigMapper secSinopecConfigMapper;
@Override @Override
public List<SecSinopecConfig> getListSinopecConfig(Map<String, String> map) throws Exception { public List<SecSinopecConfig> getListSinopecConfig(Map<String, String> map) {
SecSinopecConfigExample example = new SecSinopecConfigExample(); SecSinopecConfigExample example = new SecSinopecConfigExample();
SecSinopecConfigExample.Criteria criteria = example.createCriteria(); SecSinopecConfigExample.Criteria criteria = example.createCriteria();

Loading…
Cancel
Save