diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java b/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java index c4171277..9b398a48 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java @@ -70,6 +70,9 @@ public class HighCouponController { @Resource private HighApproveService highApproveService; + @Resource + private HuiLianTongConfig huiLianTongConfig; + @RequestMapping(value="/insertCoupon",method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "增加卡卷") @@ -588,14 +591,10 @@ public class HighCouponController { } // 获取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失败"); - } + String token = huiLianTongConfig.getToken(); // 查询电子卡券类型 - JSONObject corpCouTypes = HuiLianTongConfig.getCorpCouTypes(tokenObject.getString("data")); + JSONObject corpCouTypes = HuiLianTongConfig.getCorpCouTypes(token); System.out.println(corpCouTypes.toJSONString()); if (!corpCouTypes.getString("result").equals("success")) { log.error("HighCouponController -> insertCoupon() error!","获取电子卡券列表失败"); diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighGasController.java b/hai-cweb/src/main/java/com/cweb/controller/HighGasController.java index 0c62423d..01ec3769 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighGasController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighGasController.java @@ -17,6 +17,7 @@ import com.hai.entity.HighGasDiscountOilPrice; import com.hai.entity.HighGasOrderPush; import com.hai.entity.HighOrder; import com.hai.entity.SecRegion; +import com.hai.enum_type.OrderPushType; import com.hai.model.ResponseData; import com.hai.service.CommonService; import com.hai.service.HighGasDiscountOilPriceService; @@ -245,6 +246,8 @@ public class HighGasController { JSONObject orderPushObject = TuanYouConfig.refuelingOrderPush(map); // 推送团油订单记录 HighGasOrderPush highGasOrderPush = new HighGasOrderPush(); + highGasOrderPush.setType(OrderPushType.type1.getType()); + highGasOrderPush.setOrderNo(MapUtils.getString(map, "thirdSerialNo")); highGasOrderPush.setCreateTime(new Date()); highGasOrderPush.setCode(orderPushObject.getString("code")); highGasOrderPush.setRequestContent(JSONObject.toJSONString(map)); diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighTestController.java b/hai-cweb/src/main/java/com/cweb/controller/HighTestController.java index 0f3d52c2..17bc8728 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighTestController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighTestController.java @@ -72,9 +72,12 @@ public class HighTestController { @Resource private HighGasOrderPushMapper highGasOrderPushMapper; + @Resource + private HuiLianTongConfig huiLianTongConfig; + @RequestMapping(value = "/initTYMerchantStore", method = RequestMethod.GET) @ResponseBody - @ApiOperation(value = "初始化") + @ApiOperation(value = "初始化加油站") public ResponseData initTYMerchantStore(@RequestParam(name = "merchantId", required = true) Long merchantId) throws Exception { HighMerchantModel merchant = highMerchantService.getMerchantById(merchantId); @@ -233,7 +236,7 @@ public class HighTestController { @ApiOperation(value = "获取汇联通Token") public ResponseData test2() { try { - return ResponseMsgUtil.success(HuiLianTongConfig.getToken()); + return ResponseMsgUtil.success(huiLianTongConfig.getToken()); } catch (Exception e) { log.error("HighOrderController --> getOrderById() error!", e); return ResponseMsgUtil.exception(e); @@ -270,7 +273,7 @@ public class HighTestController { @ApiOperation(value = "测试") public ResponseData couJointDist(@RequestParam(name = "token", required = true) String token) { try { - return ResponseMsgUtil.success(HuiLianTongConfig.couJointDist(token,"HF"+new Date().getTime(),"20JY000251",2,"17726395120", "oArhO6XxKSvjI9wLP3cTK-iSG8yY")); + return ResponseMsgUtil.success(HuiLianTongConfig.couJointDist(token,"HF"+System.currentTimeMillis(),"20JY000251",2,"17726395120", "oArhO6XxKSvjI9wLP3cTK-iSG8yY")); } catch (Exception e) { log.error("HighOrderController --> getOrderById() error!", e); return ResponseMsgUtil.exception(e); @@ -295,10 +298,8 @@ public class HighTestController { this.wxProfitsharing(order.getPaySerialNo(),order.getOrderNo(),profitSharingAmount);*/ // 获取token - JSONObject tokenObject = HuiLianTongConfig.getToken(); - if (!tokenObject.getString("result").equals("success")) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "获取token失败"); - } + String token = huiLianTongConfig.getToken(); + /*Map push = new HashMap<>(); push.put("token", tokenObject.getString("data")); push.put("couTypeCode", "20JY000575"); @@ -308,7 +309,7 @@ public class HighTestController { // 推送给高速 JSONObject returnParam = HuiLianTongConfig.couJointDist( - tokenObject.getString("data"), + token, "HF20210926163742075051", "20JY000573", 1, diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighUserCommonController.java b/hai-cweb/src/main/java/com/cweb/controller/HighUserCommonController.java index 42829754..43de0c4b 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighUserCommonController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighUserCommonController.java @@ -5,6 +5,7 @@ import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.security.*; import com.hai.common.utils.IDGenerator; +import com.hai.common.utils.RedisUtil; import com.hai.common.utils.ResponseMsgUtil; import com.hai.entity.HighUser; import com.hai.model.HighUserModel; @@ -12,6 +13,7 @@ import com.hai.model.ResponseData; import com.hai.service.HighUserService; 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.stereotype.Controller; @@ -24,6 +26,7 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.util.Date; +import java.util.Objects; @Controller @RequestMapping(value = "/user") @@ -35,6 +38,9 @@ public class HighUserCommonController { @Resource private HighUserService highUserService; + @Resource + private RedisUtil redisUtil; + @Resource private UserCenter userCenter; @@ -45,15 +51,15 @@ public class HighUserCommonController { @RequestParam(value = "code", required = true) String code, HttpServletRequest request, HttpServletResponse response) { try { - VerifyCode verifyCode = VerifyCodeStorage.getDate(phone); - if(verifyCode == null) { - log.error("HighUserController --> bindUserPhone() error!", "验证码错误"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "验证码错误"); - } - if(!verifyCode.getObject().equals(code)) { + + // 获取手机号验证码 + String phoneSmsCode = (String) redisUtil.get(phone); + // 校验验证码 + if (StringUtils.isBlank(phoneSmsCode) || !Objects.equals(phoneSmsCode,code)) { log.error("HighUserController --> bindUserPhone() error!", "验证码错误"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "验证码错误"); } + redisUtil.del(phone); HighUser user = highUserService.findByPhone(phone); if(user == null) { @@ -65,11 +71,13 @@ public class HighUserCommonController { user.setStatus(1); highUserService.insertUser(user); } + HighUserModel highUserModel = new HighUserModel(); HighUser detailData = highUserService.getDetailDataByUser(user.getId()); detailData.setPassword(null); highUserModel.setHighUser(detailData); - SessionObject so = new SessionObject(detailData.getUnionId(), 1 , highUserModel); + SessionObject so = new SessionObject(StringUtils.isNotBlank(user.getUnionId())?user.getUnionId():detailData.getId().toString(), 1 , highUserModel); + userCenter.save(request, response, so); return ResponseMsgUtil.success(so); } catch (Exception e) { return ResponseMsgUtil.exception(e); diff --git a/hai-cweb/src/main/java/com/cweb/controller/pay/OrderController.java b/hai-cweb/src/main/java/com/cweb/controller/pay/OrderController.java index 58429e56..022d805a 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/pay/OrderController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/pay/OrderController.java @@ -210,7 +210,6 @@ public class OrderController { } } - @RequestMapping(value="/orderToGoldPay",method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "订单支付发起金币支付") @@ -389,7 +388,6 @@ public class OrderController { } } - @RequestMapping(value="/qzOrderToPay",method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "千猪订单支付发起支付") diff --git a/hai-cweb/src/test/common/test.java b/hai-cweb/src/test/common/test.java new file mode 100644 index 00000000..dafbac71 --- /dev/null +++ b/hai-cweb/src/test/common/test.java @@ -0,0 +1,80 @@ +package common; + +import com.CWebApplication; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.hai.common.QRCodeGenerator; +import com.hai.common.utils.DateUtil; +import com.hai.common.utils.HttpsUtils; +import com.hai.common.utils.IDGenerator; +import com.hai.entity.HighCouponCode; +import com.hai.entity.SecRegion; +import com.hai.service.CommonService; +import com.hai.service.HighCouponCodeService; +import com.hai.service.HighMerchantStoreService; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.web.WebAppConfiguration; + +import javax.annotation.Resource; +import java.io.FileOutputStream; +import java.io.OutputStreamWriter; +import java.io.UnsupportedEncodingException; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.*; + +/** + * @ClassName RegionTest + * @Description: TODO () + * @Author 胡锐 + * @Date 2020/12/29 + **/ +@RunWith(SpringJUnit4ClassRunner.class) +@SpringBootTest(classes = CWebApplication.class) +@WebAppConfiguration +public class test { + + + public static void main(String[] args) { + + requestOrder(); + } + + public static void requestOrder(){ + + Map heard = new HashMap<>(); + heard.put("Cookie", "_ida=oArhO6XxKSvjI9wLP3cTK-iSG8yY"); + + + Map map = new HashMap<>();; + map.put("goodsId", "23423529"); + map.put("goodsType", "1"); + map.put("saleCount", "1"); + + List> orderList = new ArrayList<>(); + orderList.add(map); + + Map param = new HashMap<>(); + param.put("highChildOrderList", orderList); + + int success = 0 ; + int fail = 0; + + JSONObject object = HttpsUtils.doPost("https://hsgcs.dctpay.com/crest/highOrder/addOrder", param, heard); + if (object.getString("return_code").equals("000000")) { + success++; + System.out.println("提交订单成功"); + } else { + fail++; + System.out.println(object.getString("return_msg")); + } + + System.out.println("成功数量" + success); + System.out.println("失败数量" + fail); + + } + +} diff --git a/hai-schedule/src/main/java/com/hai/schedule/HighCouponSchedule.java b/hai-schedule/src/main/java/com/hai/schedule/HighCouponSchedule.java index 4e7088b9..5c9143ec 100644 --- a/hai-schedule/src/main/java/com/hai/schedule/HighCouponSchedule.java +++ b/hai-schedule/src/main/java/com/hai/schedule/HighCouponSchedule.java @@ -42,6 +42,9 @@ public class HighCouponSchedule { @Resource private HighOrderService highOrderService; + @Resource + private HuiLianTongConfig huiLianTongConfig; + /** * @Author 胡锐 * @Description 处理过期的卡券 @@ -73,14 +76,10 @@ public class HighCouponSchedule { List otherList = highCouponCodeOtherMapper.selectByExample(example); // 获取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失败"); - } + String token = huiLianTongConfig.getToken(); for (HighCouponCodeOther couponCodeOther : otherList) { - JSONObject data = HuiLianTongConfig.getCouState(tokenObject.getString("data"), couponCodeOther.getCouNo()); + JSONObject data = HuiLianTongConfig.getCouState(token, couponCodeOther.getCouNo()); if (data.getString("result").equals("success")) { if (data.getJSONObject("data").getInteger("state") != 20) { couponCodeOther.setStatus(data.getJSONObject("data").getInteger("state")); diff --git a/hai-service/src/main/java/com/hai/config/HuiLianTongConfig.java b/hai-service/src/main/java/com/hai/config/HuiLianTongConfig.java index ec3849f0..c32dc4b7 100644 --- a/hai-service/src/main/java/com/hai/config/HuiLianTongConfig.java +++ b/hai-service/src/main/java/com/hai/config/HuiLianTongConfig.java @@ -2,12 +2,18 @@ package com.hai.config; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import com.hai.common.exception.ErrorCode; +import com.hai.common.exception.ErrorHelp; +import com.hai.common.exception.SysCode; import com.hai.common.utils.HttpsUtils; import com.hai.common.utils.MD5Util; +import com.hai.common.utils.RedisUtil; import com.hai.dao.HighGasOrderPushMapper; import com.hai.entity.HighGasOrderPush; import org.apache.commons.collections4.MapUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; +import org.springframework.stereotype.Component; import sun.misc.BASE64Decoder; import sun.misc.BASE64Encoder; @@ -26,17 +32,36 @@ import java.util.*; * @description: 汇联通接口配置 * @date 2021/7/5 14:18 */ +@Component public class HuiLianTongConfig { + + @Resource + private RedisUtil redisUtil; + /** * 获取token * @return * @throws Exception */ - public static JSONObject getToken() throws Exception { + public String getToken() throws Exception { + Object token = redisUtil.get(CommonSysConst.getSysConfig().getHuiliantongAppNo()); + if (token != null) { + return token.toString(); + } + Map map = new HashMap<>(); 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)); + + // 获取token + JSONObject tokenObject = HttpsUtils.doPost(CommonSysConst.getSysConfig().getHuiliantongUrl()+"/api/api/auth/getAccessToken", JSON.toJSONString(map)); + if (tokenObject.getString("result").equals("success")) { + // 缓存到redis 有效期30分钟 + redisUtil.set(CommonSysConst.getSysConfig().getHuiliantongAppNo(),tokenObject.getString("data"),60*30); + return tokenObject.getString("data"); + } + + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "获取token失败"); } /** diff --git a/hai-service/src/main/java/com/hai/dao/HighGasOrderPushMapper.java b/hai-service/src/main/java/com/hai/dao/HighGasOrderPushMapper.java index f1f681b4..580f3520 100644 --- a/hai-service/src/main/java/com/hai/dao/HighGasOrderPushMapper.java +++ b/hai-service/src/main/java/com/hai/dao/HighGasOrderPushMapper.java @@ -39,10 +39,12 @@ public interface HighGasOrderPushMapper extends HighGasOrderPushMapperExt { int deleteByPrimaryKey(Long id); @Insert({ - "insert into high_gas_order_push (code, request_content, ", + "insert into high_gas_order_push (`type`, order_no, ", + "code, request_content, ", "return_content, create_time, ", "ext_1, ext_2, ext_3)", - "values (#{code,jdbcType=VARCHAR}, #{requestContent,jdbcType=VARCHAR}, ", + "values (#{type,jdbcType=INTEGER}, #{orderNo,jdbcType=VARCHAR}, ", + "#{code,jdbcType=VARCHAR}, #{requestContent,jdbcType=VARCHAR}, ", "#{returnContent,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, ", "#{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" }) @@ -56,6 +58,8 @@ public interface HighGasOrderPushMapper extends HighGasOrderPushMapperExt { @SelectProvider(type=HighGasOrderPushSqlProvider.class, method="selectByExample") @Results({ @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), + @Result(column="type", property="type", jdbcType=JdbcType.INTEGER), + @Result(column="order_no", property="orderNo", jdbcType=JdbcType.VARCHAR), @Result(column="code", property="code", jdbcType=JdbcType.VARCHAR), @Result(column="request_content", property="requestContent", jdbcType=JdbcType.VARCHAR), @Result(column="return_content", property="returnContent", jdbcType=JdbcType.VARCHAR), @@ -68,12 +72,15 @@ public interface HighGasOrderPushMapper extends HighGasOrderPushMapperExt { @Select({ "select", - "id, code, request_content, return_content, create_time, ext_1, ext_2, ext_3", + "id, `type`, order_no, code, request_content, return_content, create_time, ext_1, ", + "ext_2, ext_3", "from high_gas_order_push", "where id = #{id,jdbcType=BIGINT}" }) @Results({ @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), + @Result(column="type", property="type", jdbcType=JdbcType.INTEGER), + @Result(column="order_no", property="orderNo", jdbcType=JdbcType.VARCHAR), @Result(column="code", property="code", jdbcType=JdbcType.VARCHAR), @Result(column="request_content", property="requestContent", jdbcType=JdbcType.VARCHAR), @Result(column="return_content", property="returnContent", jdbcType=JdbcType.VARCHAR), @@ -95,7 +102,9 @@ public interface HighGasOrderPushMapper extends HighGasOrderPushMapperExt { @Update({ "update high_gas_order_push", - "set code = #{code,jdbcType=VARCHAR},", + "set `type` = #{type,jdbcType=INTEGER},", + "order_no = #{orderNo,jdbcType=VARCHAR},", + "code = #{code,jdbcType=VARCHAR},", "request_content = #{requestContent,jdbcType=VARCHAR},", "return_content = #{returnContent,jdbcType=VARCHAR},", "create_time = #{createTime,jdbcType=TIMESTAMP},", diff --git a/hai-service/src/main/java/com/hai/dao/HighGasOrderPushSqlProvider.java b/hai-service/src/main/java/com/hai/dao/HighGasOrderPushSqlProvider.java index 044020d8..d5ef6d38 100644 --- a/hai-service/src/main/java/com/hai/dao/HighGasOrderPushSqlProvider.java +++ b/hai-service/src/main/java/com/hai/dao/HighGasOrderPushSqlProvider.java @@ -28,6 +28,14 @@ public class HighGasOrderPushSqlProvider { SQL sql = new SQL(); sql.INSERT_INTO("high_gas_order_push"); + if (record.getType() != null) { + sql.VALUES("`type`", "#{type,jdbcType=INTEGER}"); + } + + if (record.getOrderNo() != null) { + sql.VALUES("order_no", "#{orderNo,jdbcType=VARCHAR}"); + } + if (record.getCode() != null) { sql.VALUES("code", "#{code,jdbcType=VARCHAR}"); } @@ -66,6 +74,8 @@ public class HighGasOrderPushSqlProvider { } else { sql.SELECT("id"); } + sql.SELECT("`type`"); + sql.SELECT("order_no"); sql.SELECT("code"); sql.SELECT("request_content"); sql.SELECT("return_content"); @@ -94,6 +104,14 @@ public class HighGasOrderPushSqlProvider { sql.SET("id = #{record.id,jdbcType=BIGINT}"); } + if (record.getType() != null) { + sql.SET("`type` = #{record.type,jdbcType=INTEGER}"); + } + + if (record.getOrderNo() != null) { + sql.SET("order_no = #{record.orderNo,jdbcType=VARCHAR}"); + } + if (record.getCode() != null) { sql.SET("code = #{record.code,jdbcType=VARCHAR}"); } @@ -131,6 +149,8 @@ public class HighGasOrderPushSqlProvider { sql.UPDATE("high_gas_order_push"); sql.SET("id = #{record.id,jdbcType=BIGINT}"); + sql.SET("`type` = #{record.type,jdbcType=INTEGER}"); + sql.SET("order_no = #{record.orderNo,jdbcType=VARCHAR}"); sql.SET("code = #{record.code,jdbcType=VARCHAR}"); sql.SET("request_content = #{record.requestContent,jdbcType=VARCHAR}"); sql.SET("return_content = #{record.returnContent,jdbcType=VARCHAR}"); @@ -148,6 +168,14 @@ public class HighGasOrderPushSqlProvider { SQL sql = new SQL(); sql.UPDATE("high_gas_order_push"); + if (record.getType() != null) { + sql.SET("`type` = #{type,jdbcType=INTEGER}"); + } + + if (record.getOrderNo() != null) { + sql.SET("order_no = #{orderNo,jdbcType=VARCHAR}"); + } + if (record.getCode() != null) { sql.SET("code = #{code,jdbcType=VARCHAR}"); } diff --git a/hai-service/src/main/java/com/hai/entity/HighGasOrderPush.java b/hai-service/src/main/java/com/hai/entity/HighGasOrderPush.java index 48f26e7c..4a1bb32d 100644 --- a/hai-service/src/main/java/com/hai/entity/HighGasOrderPush.java +++ b/hai-service/src/main/java/com/hai/entity/HighGasOrderPush.java @@ -18,6 +18,16 @@ public class HighGasOrderPush implements Serializable { */ private Long id; + /** + * 类型 + */ + private Integer type; + + /** + * 订单号 + */ + private String orderNo; + /** * 推送状态 */ @@ -54,6 +64,22 @@ public class HighGasOrderPush implements Serializable { this.id = id; } + public Integer getType() { + return type; + } + + public void setType(Integer type) { + this.type = type; + } + + public String getOrderNo() { + return orderNo; + } + + public void setOrderNo(String orderNo) { + this.orderNo = orderNo; + } + public String getCode() { return code; } @@ -123,6 +149,8 @@ public class HighGasOrderPush implements Serializable { } HighGasOrderPush other = (HighGasOrderPush) that; return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) + && (this.getType() == null ? other.getType() == null : this.getType().equals(other.getType())) + && (this.getOrderNo() == null ? other.getOrderNo() == null : this.getOrderNo().equals(other.getOrderNo())) && (this.getCode() == null ? other.getCode() == null : this.getCode().equals(other.getCode())) && (this.getRequestContent() == null ? other.getRequestContent() == null : this.getRequestContent().equals(other.getRequestContent())) && (this.getReturnContent() == null ? other.getReturnContent() == null : this.getReturnContent().equals(other.getReturnContent())) @@ -137,6 +165,8 @@ public class HighGasOrderPush implements Serializable { final int prime = 31; int result = 1; result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); + result = prime * result + ((getType() == null) ? 0 : getType().hashCode()); + result = prime * result + ((getOrderNo() == null) ? 0 : getOrderNo().hashCode()); result = prime * result + ((getCode() == null) ? 0 : getCode().hashCode()); result = prime * result + ((getRequestContent() == null) ? 0 : getRequestContent().hashCode()); result = prime * result + ((getReturnContent() == null) ? 0 : getReturnContent().hashCode()); @@ -154,6 +184,8 @@ public class HighGasOrderPush implements Serializable { sb.append(" ["); sb.append("Hash = ").append(hashCode()); sb.append(", id=").append(id); + sb.append(", type=").append(type); + sb.append(", orderNo=").append(orderNo); sb.append(", code=").append(code); sb.append(", requestContent=").append(requestContent); sb.append(", returnContent=").append(returnContent); diff --git a/hai-service/src/main/java/com/hai/entity/HighGasOrderPushExample.java b/hai-service/src/main/java/com/hai/entity/HighGasOrderPushExample.java index 58526200..15c00f65 100644 --- a/hai-service/src/main/java/com/hai/entity/HighGasOrderPushExample.java +++ b/hai-service/src/main/java/com/hai/entity/HighGasOrderPushExample.java @@ -185,6 +185,136 @@ public class HighGasOrderPushExample { return (Criteria) this; } + public Criteria andTypeIsNull() { + addCriterion("`type` is null"); + return (Criteria) this; + } + + public Criteria andTypeIsNotNull() { + addCriterion("`type` is not null"); + return (Criteria) this; + } + + public Criteria andTypeEqualTo(Integer value) { + addCriterion("`type` =", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeNotEqualTo(Integer value) { + addCriterion("`type` <>", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeGreaterThan(Integer value) { + addCriterion("`type` >", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeGreaterThanOrEqualTo(Integer value) { + addCriterion("`type` >=", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeLessThan(Integer value) { + addCriterion("`type` <", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeLessThanOrEqualTo(Integer value) { + addCriterion("`type` <=", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeIn(List values) { + addCriterion("`type` in", values, "type"); + return (Criteria) this; + } + + public Criteria andTypeNotIn(List values) { + addCriterion("`type` not in", values, "type"); + return (Criteria) this; + } + + public Criteria andTypeBetween(Integer value1, Integer value2) { + addCriterion("`type` between", value1, value2, "type"); + return (Criteria) this; + } + + public Criteria andTypeNotBetween(Integer value1, Integer value2) { + addCriterion("`type` not between", value1, value2, "type"); + return (Criteria) this; + } + + public Criteria andOrderNoIsNull() { + addCriterion("order_no is null"); + return (Criteria) this; + } + + public Criteria andOrderNoIsNotNull() { + addCriterion("order_no is not null"); + return (Criteria) this; + } + + public Criteria andOrderNoEqualTo(String value) { + addCriterion("order_no =", value, "orderNo"); + return (Criteria) this; + } + + public Criteria andOrderNoNotEqualTo(String value) { + addCriterion("order_no <>", value, "orderNo"); + return (Criteria) this; + } + + public Criteria andOrderNoGreaterThan(String value) { + addCriterion("order_no >", value, "orderNo"); + return (Criteria) this; + } + + public Criteria andOrderNoGreaterThanOrEqualTo(String value) { + addCriterion("order_no >=", value, "orderNo"); + return (Criteria) this; + } + + public Criteria andOrderNoLessThan(String value) { + addCriterion("order_no <", value, "orderNo"); + return (Criteria) this; + } + + public Criteria andOrderNoLessThanOrEqualTo(String value) { + addCriterion("order_no <=", value, "orderNo"); + return (Criteria) this; + } + + public Criteria andOrderNoLike(String value) { + addCriterion("order_no like", value, "orderNo"); + return (Criteria) this; + } + + public Criteria andOrderNoNotLike(String value) { + addCriterion("order_no not like", value, "orderNo"); + return (Criteria) this; + } + + public Criteria andOrderNoIn(List values) { + addCriterion("order_no in", values, "orderNo"); + return (Criteria) this; + } + + public Criteria andOrderNoNotIn(List values) { + addCriterion("order_no not in", values, "orderNo"); + return (Criteria) this; + } + + public Criteria andOrderNoBetween(String value1, String value2) { + addCriterion("order_no between", value1, value2, "orderNo"); + return (Criteria) this; + } + + public Criteria andOrderNoNotBetween(String value1, String value2) { + addCriterion("order_no not between", value1, value2, "orderNo"); + return (Criteria) this; + } + public Criteria andCodeIsNull() { addCriterion("code is null"); return (Criteria) this; diff --git a/hai-service/src/main/java/com/hai/enum_type/OrderPushType.java b/hai-service/src/main/java/com/hai/enum_type/OrderPushType.java new file mode 100644 index 00000000..69cbf691 --- /dev/null +++ b/hai-service/src/main/java/com/hai/enum_type/OrderPushType.java @@ -0,0 +1,51 @@ +package com.hai.enum_type; + +import java.util.Objects; + +/** + * 订单推送类型 + * @author hurui + */ +public enum OrderPushType { + type1(1 , "加油订单"), + type2(2 , "话费订单"), + type3(3 , "KFC订单"), + type4(4 , "电影票订单"), + type5(5 , "汇联通会员卡"), + type6(6 , "汇联通卡券"), + ; + + private Integer type; + private String name; + + + OrderPushType(int type , String name) { + this.type = type; + this.name = name; + } + + public static String getNameByType(Integer type) { + for (OrderPushType ele : values()) { + if (Objects.equals(type,ele.getType())) { + return ele.getName(); + } + } + return null; + } + + public Integer getType() { + return type; + } + + public void setType(Integer type) { + this.type = type; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java index f6157f63..464410d8 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java @@ -3,32 +3,26 @@ package com.hai.service.impl; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; 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.*; import com.hai.dao.*; import com.hai.entity.*; -import com.hai.enum_type.GoodsType; -import com.hai.enum_type.PayType; +import com.hai.enum_type.OrderPushType; import com.hai.model.*; import com.hai.service.*; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; -import org.apache.poi.util.StringUtil; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Isolation; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; -import java.io.File; import java.math.BigDecimal; import java.util.*; -import java.util.stream.Collectors; /** * @Auther: 胡锐 @@ -92,6 +86,9 @@ public class HighOrderServiceImpl implements HighOrderService { @Resource private HighActivityUserLotteryNumService highActivityUserLotteryNumService; + @Resource + private HuiLianTongConfig huiLianTongConfig; + @Override @Transactional( isolation = Isolation.SERIALIZABLE, @@ -205,19 +202,17 @@ public class HighOrderServiceImpl implements HighOrderService { // 贵州高速 if (coupon.getCouponSource() == 4) { // 获取token - JSONObject tokenObject = HuiLianTongConfig.getToken(); - if (!tokenObject.getString("result").equals("success")) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "获取token失败"); - } + String token = huiLianTongConfig.getToken(); + Map push = new HashMap<>(); - push.put("token", tokenObject.getString("data")); + push.put("token", token); 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"), highOrder.getOrderNo(), coupon.getCouponKey(), highChildOrder.getSaleCount(), highUser.getPhone(), highUser.getUnionId()); + JSONObject returnParam = HuiLianTongConfig.couJointDist(token, highOrder.getOrderNo(), coupon.getCouponKey(), highChildOrder.getSaleCount(), highUser.getPhone(), highUser.getUnionId()); if (returnParam != null && returnParam.getString("result").equals("success")) { JSONArray dataArray = returnParam.getJSONArray("data"); for (Object data : dataArray) { @@ -249,6 +244,8 @@ public class HighOrderServiceImpl implements HighOrderService { } // 推送记录 HighGasOrderPush highGasOrderPush = new HighGasOrderPush(); + highGasOrderPush.setType(OrderPushType.type6.getType()); + highGasOrderPush.setOrderNo(highOrder.getOrderNo()); highGasOrderPush.setCreateTime(new Date()); highGasOrderPush.setCode(returnParam.getString("result")); highGasOrderPush.setRequestContent(JSONObject.toJSONString(push)); @@ -325,6 +322,19 @@ public class HighOrderServiceImpl implements HighOrderService { tranDesc = "嗨森逛积分充值"+order.getPayPrice()+"元"; } else if (order.getHighChildOrderList().get(0).getGoodsType() == 3) { + // 查询团油账号余额 + JSONObject accountInfo2JD = TuanYouConfig.queryCompanyAccountInfo2JD(); + JSONArray result = accountInfo2JD.getJSONArray("result"); + for (Object accountObject : result) { + JSONObject account = (JSONObject)accountObject; + // 1:汽油:2:柴油;3:天然气 + if (account.getInteger("energyType").equals(order.getHighChildOrderList().get(0).getGasOilType())) { + // 支付金额 大于 团油账号余额 + if(order.getPayPrice().compareTo(account.getBigDecimal("accountBalance")) == 1){ + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法进行支付,请联系平台客服"); + } + } + } goodsDesc = "加油站加"+order.getPayPrice()+"元油"; tranDesc = "【"+order.getHighChildOrderList().get(0).getGoodsName()+"】加油"+order.getPayPrice()+"元"; } else { @@ -334,6 +344,27 @@ public class HighOrderServiceImpl implements HighOrderService { // 工会卡支付 JSONObject consumption = HuiLianTongUnionCardConfig.consumption(order.getOrderNo(), userCard.getCardNo(), order.getPayPrice(), businessType, instCode, goodsDesc, tranDesc); System.out.println("工会卡支付响应参数" + consumption.toJSONString()); + + Map dataMap = new HashMap<>(); + dataMap.put("orderNo", order.getOrderNo()); + dataMap.put("cardType", "ghk"); + dataMap.put("cardNo", userCard.getCardNo()); + dataMap.put("checkPassword", "N"); + dataMap.put("tranAmount", order.getPayPrice()); + dataMap.put("tranChannel", "HiSen"); + dataMap.put("businessType", businessType); + dataMap.put("instCode", instCode); + dataMap.put("goodsDesc", goodsDesc); + dataMap.put("tranDesc", tranDesc); + HighGasOrderPush payPush = new HighGasOrderPush(); + payPush.setType(OrderPushType.type5.getType()); + payPush.setOrderNo(userCard.getCardNo()); + payPush.setCreateTime(new Date()); + payPush.setCode(consumption.getString("respCode")); + payPush.setRequestContent(JSON.toJSONString(dataMap)); + payPush.setReturnContent(consumption.toJSONString()); + highGasOrderPushMapper.insert(payPush); + if(!consumption.getString("respCode").equals("0000")) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, consumption.getString("respMessage")); } @@ -364,19 +395,17 @@ public class HighOrderServiceImpl implements HighOrderService { // 贵州中石化 if (coupon.getCouponSource() == 4) { // 获取token - JSONObject tokenObject = HuiLianTongConfig.getToken(); - if (!tokenObject.getString("result").equals("success")) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "获取token失败"); - } + String token = huiLianTongConfig.getToken(); + Map push = new HashMap<>(); - push.put("token", tokenObject.getString("data")); + push.put("token",token); 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"), order.getOrderNo(),coupon.getCouponKey(), highChildOrder.getSaleCount(), highUser.getPhone(), highUser.getUnionId()); + JSONObject returnParam = HuiLianTongConfig.couJointDist(token, order.getOrderNo(),coupon.getCouponKey(), highChildOrder.getSaleCount(), highUser.getPhone(), highUser.getUnionId()); if (returnParam != null && returnParam.getString("result").equals("success")) { JSONArray dataArray = returnParam.getJSONArray("data"); for (Object data : dataArray) { @@ -409,6 +438,8 @@ public class HighOrderServiceImpl implements HighOrderService { // 推送记录 HighGasOrderPush highGasOrderPush = new HighGasOrderPush(); + highGasOrderPush.setType(OrderPushType.type6.getType()); + highGasOrderPush.setOrderNo(order.getOrderNo()); highGasOrderPush.setCreateTime(new Date()); highGasOrderPush.setCode(returnParam.getString("result")); highGasOrderPush.setRequestContent(JSONObject.toJSONString(push)); @@ -485,6 +516,8 @@ public class HighOrderServiceImpl implements HighOrderService { JSONObject orderPushObject = TuanYouConfig.refuelingOrderPush(paramMap); // 推送团油订单记录 HighGasOrderPush highGasOrderPush = new HighGasOrderPush(); + highGasOrderPush.setType(OrderPushType.type1.getType()); + highGasOrderPush.setOrderNo(order.getOrderNo()); highGasOrderPush.setCreateTime(new Date()); highGasOrderPush.setCode(orderPushObject.getString("code")); highGasOrderPush.setRequestContent(JSONObject.toJSONString(paramMap)); diff --git a/hai-service/src/main/java/com/hai/service/pay/impl/CinemaOrderService.java b/hai-service/src/main/java/com/hai/service/pay/impl/CinemaOrderService.java index 82e68ae5..3c93da1d 100644 --- a/hai-service/src/main/java/com/hai/service/pay/impl/CinemaOrderService.java +++ b/hai-service/src/main/java/com/hai/service/pay/impl/CinemaOrderService.java @@ -8,6 +8,7 @@ import com.hai.entity.HighGasOrderPush; import com.hai.entity.HighOrder; import com.hai.entity.HighUser; import com.hai.enum_type.GoodsType; +import com.hai.enum_type.OrderPushType; import com.hai.enum_type.PayType; import com.hai.service.HighOrderService; import com.hai.service.HighUserService; @@ -55,6 +56,8 @@ public class CinemaOrderService implements PayService { JSONObject object = QianZhuConfig.payMovieOrder(order.getOrderNo()); // 推送订单记录 HighGasOrderPush highGasOrderPush = new HighGasOrderPush(); + highGasOrderPush.setType(OrderPushType.type4.getType()); + highGasOrderPush.setOrderNo(order.getOrderNo()); highGasOrderPush.setCreateTime(new Date()); highGasOrderPush.setRequestContent(order.getOrderNo()); highGasOrderPush.setReturnContent(object.toJSONString()); diff --git a/hai-service/src/main/java/com/hai/service/pay/impl/GoodsOrderServiceImpl.java b/hai-service/src/main/java/com/hai/service/pay/impl/GoodsOrderServiceImpl.java index 53285717..afbe88b3 100644 --- a/hai-service/src/main/java/com/hai/service/pay/impl/GoodsOrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/pay/impl/GoodsOrderServiceImpl.java @@ -16,6 +16,7 @@ import com.hai.dao.HighGasOrderPushMapper; import com.hai.dao.HighUserCouponMapper; import com.hai.entity.*; import com.hai.enum_type.GoodsType; +import com.hai.enum_type.OrderPushType; import com.hai.enum_type.PayType; import com.hai.model.HighMerchantStoreModel; import com.hai.model.ResultProfitSharing; @@ -91,6 +92,9 @@ public class GoodsOrderServiceImpl implements PayService { @Resource private NotifyService notifyService; + @Resource + private HuiLianTongConfig huiLianTongConfig; + @Override @Transactional(propagation= Propagation.REQUIRES_NEW) public void paySuccess(Map map, String payType) throws Exception { @@ -125,20 +129,17 @@ public class GoodsOrderServiceImpl implements PayService { // 贵州中石化 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失败"); - } + String token = huiLianTongConfig.getToken(); + Map push = new HashMap<>(); - push.put("token", tokenObject.getString("data")); + push.put("token", token); 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"), order.getOrderNo(),coupon.getCouponKey(), highChildOrder.getSaleCount(), highUser.getPhone(), highUser.getUnionId()); + JSONObject returnParam = HuiLianTongConfig.couJointDist(token, order.getOrderNo(),coupon.getCouponKey(), highChildOrder.getSaleCount(), highUser.getPhone(), highUser.getUnionId()); if (returnParam != null && returnParam.getString("result").equals("success")) { JSONArray dataArray = returnParam.getJSONArray("data"); for (Object data : dataArray) { @@ -171,6 +172,8 @@ public class GoodsOrderServiceImpl implements PayService { // 推送记录 HighGasOrderPush highGasOrderPush = new HighGasOrderPush(); + highGasOrderPush.setType(OrderPushType.type6.getType()); + highGasOrderPush.setOrderNo(order.getOrderNo()); highGasOrderPush.setCreateTime(new Date()); highGasOrderPush.setCode(returnParam.getString("result")); highGasOrderPush.setRequestContent(JSONObject.toJSONString(push)); @@ -246,6 +249,8 @@ public class GoodsOrderServiceImpl implements PayService { JSONObject orderPushObject = TuanYouConfig.refuelingOrderPush(paramMap); // 推送团油订单记录 HighGasOrderPush highGasOrderPush = new HighGasOrderPush(); + highGasOrderPush.setType(OrderPushType.type1.getType()); + highGasOrderPush.setOrderNo(order.getOrderNo()); highGasOrderPush.setCreateTime(new Date()); highGasOrderPush.setCode(orderPushObject.getString("code")); highGasOrderPush.setRequestContent(JSONObject.toJSONString(paramMap)); diff --git a/hai-service/src/main/java/com/hai/service/pay/impl/KfcOrderService.java b/hai-service/src/main/java/com/hai/service/pay/impl/KfcOrderService.java index c01e0ed2..f5f83a9f 100644 --- a/hai-service/src/main/java/com/hai/service/pay/impl/KfcOrderService.java +++ b/hai-service/src/main/java/com/hai/service/pay/impl/KfcOrderService.java @@ -9,6 +9,7 @@ import com.hai.entity.HighGasOrderPush; import com.hai.entity.HighOrder; import com.hai.entity.HighUser; import com.hai.enum_type.GoodsType; +import com.hai.enum_type.OrderPushType; import com.hai.enum_type.PayType; import com.hai.service.HighOrderService; import com.hai.service.HighUserService; @@ -57,6 +58,8 @@ public class KfcOrderService implements PayService { // 推送订单记录 HighGasOrderPush highGasOrderPush = new HighGasOrderPush(); + highGasOrderPush.setType(OrderPushType.type3.getType()); + highGasOrderPush.setOrderNo(order.getOrderNo()); highGasOrderPush.setCreateTime(new Date()); highGasOrderPush.setRequestContent(order.getOrderNo()); highGasOrderPush.setReturnContent(object.toJSONString()); diff --git a/hai-service/src/main/java/com/hai/service/pay/impl/MobileOrderServiceImpl.java b/hai-service/src/main/java/com/hai/service/pay/impl/MobileOrderServiceImpl.java index bfcc4a3a..82ec0edb 100644 --- a/hai-service/src/main/java/com/hai/service/pay/impl/MobileOrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/pay/impl/MobileOrderServiceImpl.java @@ -8,6 +8,7 @@ import com.hai.entity.HighGasOrderPush; import com.hai.entity.HighOrder; import com.hai.entity.HighUser; import com.hai.enum_type.GoodsType; +import com.hai.enum_type.OrderPushType; import com.hai.enum_type.PayType; import com.hai.service.HighOrderService; import com.hai.service.HighUserService; @@ -63,6 +64,8 @@ public class MobileOrderServiceImpl implements PayService { // 推送订单记录 HighGasOrderPush highGasOrderPush = new HighGasOrderPush(); + highGasOrderPush.setType(OrderPushType.type2.getType()); + highGasOrderPush.setOrderNo(order.getOrderNo()); highGasOrderPush.setCreateTime(new Date()); highGasOrderPush.setRequestContent(order.getOrderNo()); highGasOrderPush.setReturnContent(object.toJSONString());