dev-discount
胡锐 4 years ago
commit d5e792a81a
  1. 18
      hai-cweb/src/main/java/com/cweb/controller/HighDiscountController.java
  2. 15
      hai-cweb/src/main/java/com/cweb/controller/HighUserDiscountController.java
  3. 12
      hai-cweb/src/test/common/RegionTest.java
  4. 2
      hai-schedule/src/main/java/com/hai/schedule/HighCouponSchedule.java
  5. 2
      hai-schedule/src/main/java/com/hai/schedule/HighDiscountSchedule.java
  6. 2
      hai-schedule/src/main/java/com/hai/schedule/HighOrderSchedule.java
  7. 6
      hai-schedule/src/main/java/com/hai/schedule/SynchronizeCNPC.java
  8. 6
      hai-service/src/main/java/com/hai/common/utils/HttpsUtils.java

@ -6,9 +6,11 @@ import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode;
import com.hai.common.security.AESEncodeUtil;
import com.hai.common.utils.ResponseMsgUtil;
import com.hai.entity.HighDiscount;
import com.hai.model.ResponseData;
import com.hai.service.HighDiscountAgentRelService;
import com.hai.service.HighDiscountCouponRelService;
import com.hai.service.HighDiscountService;
import com.hai.service.HighDiscountUserRelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -38,7 +40,7 @@ public class HighDiscountController {
private HighDiscountCouponRelService highDiscountCouponRelService;
@Resource
private HighDiscountUserRelService highDiscountUserRelService;
private HighDiscountService highDiscountService;
@RequestMapping(value="/getDiscountByQrCode",method = RequestMethod.GET)
@ResponseBody
@ -60,6 +62,20 @@ public class HighDiscountController {
}
}
@RequestMapping(value="/getDiscountById",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "根据id 查询优惠券详情")
public ResponseData getDiscountById(@RequestParam(name = "id", required = true) Long id) {
try {
return ResponseMsgUtil.success(highDiscountService.getDiscountById(id));
} catch (Exception e) {
log.error("HighDiscountController -> getDiscountById() error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/getCouponByDiscount",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "根据优惠券查询卡券")

@ -105,6 +105,21 @@ public class HighUserDiscountController {
}
}
@RequestMapping(value="/getDiscountByUserDiscountId",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "根据用户和优惠券关系id 查询优惠券详情")
public ResponseData getDiscountByUserDiscountId(@RequestParam(name = "userDiscountId", required = true) Long userDiscountId) {
try {
return ResponseMsgUtil.success(highDiscountUserRelService.getRelById(userDiscountId));
} catch (Exception e) {
log.error("HighDiscountController -> getDiscountByUserDiscountId() error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/getUserNormalDiscountList",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "根据卡券,查询【可以使用】优惠券列表")

@ -87,7 +87,6 @@ public class RegionTest {
tokenMap.put("appId", "jsVpwDoHZfR2rrpjhA");
tokenMap.put("appSecret", "R7yJjinikdPhOlTrVgmdS7cblWMMOf99zEJkfPgaTIoDtKGlX51JKueLV725a6S4");
JSONObject jsonObject = HttpsUtils.doPost("https://app.zshcqsy.com/api-provider/api/open/merchant/token", JSON.toJSONString(tokenMap));
System.out.println(jsonObject.toJSONString());
if (jsonObject != null && jsonObject.getBoolean("success") == true) {
JSONObject data = jsonObject.getJSONObject("data");
String token = data.getString("token");
@ -98,20 +97,21 @@ public class RegionTest {
bodyMap.put("pageSize", 10);
bodyMap.put("startTime", "2021-3-31 00:00:00");
bodyMap.put("endTime", "2021-3-31 23:00:00");
bodyMap.put("customerCode", "48464274");
//bodyMap.put("customerCode", "48464274");
bodyMap.put("customerCode", "hAFO76ZqXmIqosNw3PTAP4wxGJTN7MPawSU0QFDzzNioLjKMEaVFDlNKRIQX6n0DgyoVMy170T0b13P8uUTAQsbk9UNRPFO5i0fWp1hHOhNdaaQ2BdC0WXQz5QQ5epyK");
String signature = "hAFO76ZqXmIqosNw3PTAP4wxGJTN7MPawSU0QFDzzNioLjKMEaVFDlNKRIQX6n0DgyoVMy170T0b13P8uUTAQsbk9UNRPFO5i0fWp1hHOhNdaaQ2BdC0WXQz5QQ5epyK";
Long date = new Date().getTime();
String sha256 = encodeBySHA256(signature + JSON.toJSONString(bodyMap) + date);
Map<String,Object> headerMap = new HashMap<>();
/* Map<String,Object> headerMap = new HashMap<>();
headerMap.put("token", token);
headerMap.put("sign", sha256);
headerMap.put("ts", date);
headerMap.put("ts", date);*/
//map2.put("sign", sha256);
HttpsUtils.doPost("https://app.zshcqsy.com/api-provider/sapapi/open/coupon/customerRedeemcodeList", JSON.toJSONString(bodyMap), token,sha256 ,date);
//System.out.println(jsonObject.toJSONString());
JSONObject object = HttpsUtils.doPost("https://app.zshcqsy.com/api-provider/sapapi/open/coupon/customerRedeemcodeList", JSON.toJSONString(bodyMap), token, sha256, date);
System.out.println(JSON.toJSONString(object));
}

@ -30,7 +30,7 @@ public class HighCouponSchedule {
* @Date 2021/4/4 22:44
**/
// @Scheduled(cron="0 0/1 * * * ?") //每1分钟执行一次
@Scheduled(cron = "0 0 0 * * ?") //每天 凌晨0点执行
//@Scheduled(cron = "0 0 0 * * ?") //每天 凌晨0点执行
public void expiredCoupon() {
// 查询过期的卡券
List<HighUserCoupon> userCoupons = highUserCouponService.getOverdueCoupon();

@ -29,7 +29,7 @@ public class HighDiscountSchedule {
* @Description 处理过期的优惠券
* @Date 2021/4/4 22:44
**/
@Scheduled(cron = "0 0 0 * * ?") //每1分钟执行一次
//@Scheduled(cron = "0 0 0 * * ?") //每1分钟执行一次
public void expiredDiscount() {
List<HighDiscountUserRel> expiredDiscount = highDiscountUserRelService.getExpiredDiscount();
for (HighDiscountUserRel rel : expiredDiscount) {

@ -33,7 +33,7 @@ public class HighOrderSchedule {
* @Description 取消订单 15分钟
* @Date 2021/4/4 22:45
**/
@Scheduled(cron="0 0/1 * * * ?") //每1分钟执行一次
//@Scheduled(cron="0 0/1 * * * ?") //每1分钟执行一次
public void cancelOrder() {
List<HighOrder> orderList = highOrderService.getCloseOrder();
if (orderList != null && orderList.size() > 0) {

@ -29,7 +29,7 @@ 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"};
//@Scheduled(cron="0 0/1 * * * ?") //每1分钟执行一次
@Scheduled(cron="0 0/1 * * * ?") //每1分钟执行一次
public void certification() {
Map<String, Object> tokenMap = new HashMap<>();
tokenMap.put("appId", "jsVpwDoHZfR2rrpjhA");
@ -53,10 +53,10 @@ public class SynchronizeCNPC {
Long date = new Date().getTime();
String sha256 = encodeBySHA256(signature + JSON.toJSONString(bodyMap) + date);
Map<String,Object> headerMap = new HashMap<>();
/* Map<String,Object> headerMap = new HashMap<>();
headerMap.put("token", token);
headerMap.put("sign", sha256);
headerMap.put("ts", date);
headerMap.put("ts", date);*/
//map2.put("sign", sha256);
JSONObject object = HttpsUtils.doPost("https://app.zshcqsy.com/api-provider/sapapi/open/coupon/customerRedeemcodeList", JSON.toJSONString(bodyMap), token, sha256, date);
log.error(object.toJSONString());

@ -317,9 +317,9 @@ public class HttpsUtils {
try {
HttpPost httpPost = new HttpPost(apiUrl);
httpPost.setConfig(requestConfig);
httpPost.setHeader("token", token);
httpPost.setHeader("sign", sign);
httpPost.setHeader("ts", ts.toString());
//httpPost.setHeader("token", token);
//httpPost.setHeader("sign", sign);
//httpPost.setHeader("ts", ts.toString());
StringEntity stringEntity = new StringEntity(str, "UTF-8");// 解决中文乱码问题
stringEntity.setContentEncoding("UTF-8");
stringEntity.setContentType("application/json");

Loading…
Cancel
Save