From 93abb5496b178c0d925e4d025e541ddb33d3b261 Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Tue, 18 Oct 2022 14:16:17 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/HighDiscountController.java | 33 ++++++- .../cweb/controller/HighTestController.java | 2 +- .../hai/dao/HighCouponCodeOtherMapper.java | 25 +++--- .../dao/HighCouponCodeOtherSqlProvider.java | 14 +++ .../com/hai/entity/HighCouponCodeOther.java | 18 +++- .../entity/HighCouponCodeOtherExample.java | 60 +++++++++++++ .../service/HighDiscountAgentCodeService.java | 7 ++ .../service/HighDiscountUserRelService.java | 7 ++ .../impl/HighCouponCodeOtherServiceImpl.java | 25 +++++- .../HighDiscountAgentCodeServiceImpl.java | 86 +++++++++++++++++++ .../impl/HighDiscountUserRelServiceImpl.java | 11 +++ 11 files changed, 272 insertions(+), 16 deletions(-) diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighDiscountController.java b/hai-cweb/src/main/java/com/cweb/controller/HighDiscountController.java index 17211dd8..9236a4a3 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighDiscountController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighDiscountController.java @@ -1,16 +1,21 @@ package com.cweb.controller; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.hai.common.Base64Util; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.security.AESEncodeUtil; +import com.hai.common.security.UserCenter; +import com.hai.common.utils.DateUtil; import com.hai.common.utils.ResponseMsgUtil; -import com.hai.entity.HighDiscountAgentCode; -import com.hai.entity.HighDiscountAgentRel; +import com.hai.config.ChongQingCNPCService; +import com.hai.entity.*; +import com.hai.model.HighUserModel; import com.hai.model.ResponseData; +import com.hai.model.UserInfoModel; import com.hai.service.HighDiscountAgentCodeService; import com.hai.service.HighDiscountAgentRelService; import com.hai.service.HighDiscountCouponRelService; @@ -20,13 +25,17 @@ import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.dao.DeadlockLoserDataAccessException; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.net.URLDecoder; +import java.util.Date; import java.util.HashMap; +import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** * @Auther: 胡锐 @@ -158,4 +167,24 @@ public class HighDiscountController { } } + + @RequestMapping(value="/useDiscount",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "使用优惠券") + public ResponseData useDiscount(@RequestParam(name = "discountAgentCodeId", required = true) Long discountAgentCodeId) { + try { + + highDiscountAgentCodeService.useDiscount(discountAgentCodeId); + return ResponseMsgUtil.success("操作成功"); + + } catch (DeadlockLoserDataAccessException deadlockLoserDataAccessException) { + log.error("HighActivityController -> userLottery() error!", "服务器繁忙"); + return ResponseMsgUtil.builderResponse(ErrorCode.SERVER_BUSY_ERROR.getCode(),ErrorCode.SERVER_BUSY_ERROR.getMsg(),null); + + } catch (Exception e) { + log.error("HighDiscountController -> useDiscount() error!",e); + return ResponseMsgUtil.exception(e); + } + } + } 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 598fc8de..23e235f3 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighTestController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighTestController.java @@ -1 +1 @@ - package com.cweb.controller; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.cweb.config.SysConst; import com.hai.common.Base64Util; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.pay.util.XmlUtil; import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.security.SessionObject; import com.hai.common.utils.*; import com.hai.config.*; import com.hai.dao.HighGasOrderPushMapper; import com.hai.entity.*; import com.hai.enum_type.MerchantStoreSourceType; import com.hai.model.*; import com.hai.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpPost; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.ssl.SSLContexts; import org.apache.http.util.EntityUtils; import org.bouncycastle.util.encoders.UrlBase64; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.util.IdGenerator; import org.springframework.web.bind.annotation.*; import sun.nio.cs.StreamEncoder; import javax.annotation.Resource; import javax.net.ssl.SSLContext; import javax.servlet.http.HttpServletRequest; import java.io.*; import java.math.BigDecimal; import java.nio.charset.StandardCharsets; import java.security.KeyStore; import java.util.*; /** * @Auther: 胡锐 * @Description: * @Date: 2021/3/26 23:08 */ @Controller @RequestMapping(value = "/test") @Api(value = "订单接口") public class HighTestController { private static Logger log = LoggerFactory.getLogger(HighTestController.class); @Resource private HighMerchantService highMerchantService; @Resource private HighMerchantStoreService highMerchantStoreService; @Resource private HighGasOilPriceService highGasOilPriceService; @Resource private HighOrderService highOrderService; @Resource private HighProfitSharingRecordService highProfitSharingRecordService; @Resource private HighGasOilGunNoService gasOilGunNoService; @Resource private HighGasOrderPushMapper highGasOrderPushMapper; @Resource private HuiLianTongConfig huiLianTongConfig; @Resource private UnionPayConfig unionPayConfig; @Resource private UnionStagingPayConfig unionStagingPayConfig; @Resource private UnionUserConfig unionUserConfig; @Resource private OutRechargeOrderService outRechargeOrderService; @Resource private HighOilCardService oilCardService; @Resource private BaiduVoiceService baiduVoiceService; @Resource private MqttProviderConfig mqttProviderConfig; @Autowired private WebSocket webSocket; @Resource private ShellGroupService shellGroupService; @Resource private HighGasService gasService; @Resource private JinZhuJiaYouService jinZhuJiaYouService; @RequestMapping(value = "/spPrint", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "发送打印机消息") public ResponseData spPrint(@RequestParam(name = "orderNo", required = true) String orderNo, HttpServletRequest request) { try { HighOrder highOrder = highOrderService.getOrderByOrderNo(orderNo); for (HighChildOrder highChildOrder : highOrder.getHighChildOrderList()) { HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreById(highChildOrder.getGoodsId()); new Thread(() -> { try { SpPrinterConfig sp = new SpPrinterConfig(); sp.print(store.getDeviceSn(), SpPrinterTemplate.oilCashierStubTemp( highChildOrder.getGoodsName(), highOrder.getOrderNo(), DateUtil.date2String(highOrder.getPayTime(), "yyyy-MM-dd HH:mm:ss"), "嗨森逛", highChildOrder.getGasGunNo(), highChildOrder.getGasOilNo(), highChildOrder.getGasOilLiters().toString(), highOrder.getTotalPrice().toString(), new HashMap<>(), false ), 1); Thread.sleep(6000); sp.print(store.getDeviceSn(), SpPrinterTemplate.oilClientStubTemp( highChildOrder.getGoodsName(), highOrder.getOrderNo(), DateUtil.date2String(highOrder.getPayTime(), "yyyy-MM-dd HH:mm:ss"), "嗨森逛", highChildOrder.getGasGunNo(), highChildOrder.getGasOilNo(), highChildOrder.getGasOilLiters().toString(), highOrder.getTotalPrice().toString(), new HashMap<>(), false ), 1); } catch (Exception e) { e.printStackTrace(); } }).start(); } return ResponseMsgUtil.success("发送成功"); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardInfo() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/sendCNPCTicket", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "根据油站 id 拉取最新的油站数据") public ResponseData sendCNPCTicket(@RequestParam(name = "gasId", required = true) String gasId, HttpServletRequest request) { try { /* JSONObject jsonObject = ChongQingCNPCService.sendCNPCTicket("1663921911751", System.currentTimeMillis() + "", 1, "17726395120"); return ResponseMsgUtil.success(jsonObject);*/ // return ResponseMsgUtil.success(ChongQingCNPCService.queryCoupon("202156655333911202")); return ResponseMsgUtil.success(ChongQingCNPCService.getCNPCCheckCode("202127538335697222", "HF2022101015395966800")); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardInfo() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryGasInfoByGasId", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "根据油站 id 拉取最新的油站数据") public ResponseData queryGasInfoByGasId(@RequestParam(name = "gasId", required = true) String gasId, HttpServletRequest request) { try { return ResponseMsgUtil.success(TuanYouConfig.queryGasInfoByGasId(gasId)); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardInfo() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/initTYMerchantStore", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "初始化加油站") public ResponseData initTYMerchantStore(@RequestParam(name = "merchantId", required = true) Long merchantId) throws Exception { HighMerchantModel merchant = highMerchantService.getMerchantById(merchantId); if (merchant == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到商户"); } JSONObject jsonObjectP = TuanYouConfig.queryGasInfoListByPage(1, 1000); JSONObject resultObjectP = jsonObjectP.getObject("result", JSONObject.class); for (int i = 1; i <= resultObjectP.getInteger("totalPageNum").intValue(); i++) { JSONObject jsonObject = TuanYouConfig.queryGasInfoListByPage(i, 1000); JSONObject resultObject = jsonObject.getObject("result", JSONObject.class); JSONArray jsonArray = resultObject.getJSONArray("gasInfoList"); HighMerchantStore highMerchantStore; HighGasOilPrice highGasOilPrice; for (Object gasObject : jsonArray) { JSONObject object = JSONObject.parseObject(JSONObject.toJSONString(gasObject)); HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreByKey(object.getString("gasId")); if (store != null) { store.setType(1); store.setMerchantId(merchant.getId()); store.setCompanyId(merchant.getCompanyId()); store.setStoreKey(object.getString("gasId")); store.setStoreName(object.getString("gasName")); store.setStoreLogo(object.getString("gasLogoSmall")); store.setRegionId(object.getLong("provinceCode")); store.setRegionName(object.getString("provinceName")); store.setAddress(object.getString("gasAddress")); store.setLongitude(object.getString("gasAddressLongitude")); store.setLatitude(object.getString("gasAddressLatitude")); store.setStatus(object.getInteger("gasStatus")); store.setOperatorId(0L); store.setOperatorName("系统创建"); store.setUpdateTime(new Date()); store.setExt1(object.getString("gasSourceId")); highMerchantStoreService.updateMerchantStoreDetail(store); JSONArray oilPriceList = object.getJSONArray("oilPriceList"); for (Object oilPrice : oilPriceList) { JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); // 查询门店油号 highGasOilPrice = highGasOilPriceService.getGasOilPriceByStoreAndOilNo(store.getId(), oilPriceObject.getInteger("oilNo")); if (highGasOilPrice == null) { highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getInteger("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); } else { highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getInteger("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); } highGasOilPriceService.editGasOilPrice(highGasOilPrice); } } else { highMerchantStore = new HighMerchantStore(); highMerchantStore.setType(1); highMerchantStore.setMerchantId(merchant.getId()); highMerchantStore.setCompanyId(merchant.getCompanyId()); highMerchantStore.setStoreKey(object.getString("gasId")); highMerchantStore.setStoreName(object.getString("gasName")); highMerchantStore.setStoreLogo(object.getString("gasLogoSmall")); highMerchantStore.setRegionId(object.getLong("provinceCode")); highMerchantStore.setRegionName(object.getString("provinceName")); highMerchantStore.setAddress(object.getString("gasAddress")); highMerchantStore.setLongitude(object.getString("gasAddressLongitude")); highMerchantStore.setLatitude(object.getString("gasAddressLatitude")); highMerchantStore.setStatus(1); highMerchantStore.setOperatorId(0L); highMerchantStore.setOperatorName("系统创建"); highMerchantStore.setCreateTime(new Date()); highMerchantStore.setUpdateTime(new Date()); highMerchantStore.setExt1(object.getString("gasSourceId")); HighMerchantStoreModel merchantStoreModel = new HighMerchantStoreModel(); BeanUtils.copyProperties(highMerchantStore, merchantStoreModel); highMerchantStoreService.insertMerchantStore(merchantStoreModel); JSONArray oilPriceList = object.getJSONArray("oilPriceList"); for (Object oilPrice : oilPriceList) { JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(merchantStoreModel.getId()); highGasOilPrice.setOilNo(oilPriceObject.getInteger("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); highGasOilPriceService.editGasOilPrice(highGasOilPrice); } } } } return ResponseMsgUtil.success("初始化完成"); } @RequestMapping(value = "/detectTYMerchantStore", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "检测加油站") public ResponseData detectTYMerchantStore(@RequestParam(name = "merchantId", required = true) Long merchantId) throws Exception { HighMerchantModel merchant = highMerchantService.getMerchantById(merchantId); if (merchant == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到商户"); } Map param = new HashMap<>(); param.put("merchantId", merchant.getId()); List stores = highMerchantStoreService.getMerchantStoreList(param); for (HighMerchantStore store : stores) { JSONObject jsonObject = TuanYouConfig.queryGasInfoByGasId(store.getStoreKey()); if (jsonObject != null && jsonObject.getString("code").equals("200")) { JSONObject result = jsonObject.getJSONObject("result"); store.setStatus(result.getInteger("gasStatus")); } else { store.setStatus(0); } highMerchantStoreService.updateMerchantStoreDetail(store); } return ResponseMsgUtil.success("初始化完成"); } /* @RequestMapping(value = "/pushTuanYouOrder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "推送团油订单") public ResponseData pushTuanYouOrder(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); for (HighChildOrder highChildOrder : order.getHighChildOrderList()) { HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreById(highChildOrder.getGoodsId()); // 推送团油订单 Map paramMap = new HashMap<>(); paramMap.put("gasId", store.getStoreKey()); paramMap.put("oilNo", highChildOrder.getGasOilNo()); paramMap.put("gunNo", highChildOrder.getGasGunNo()); BigDecimal priceGun = highChildOrder.getGasPriceGun(); BigDecimal priceVip = highChildOrder.getGasPriceVip(); paramMap.put("priceGun", priceGun); // 枪单价 paramMap.put("priceVip", priceVip); // 优惠价 paramMap.put("driverPhone", order.getMemPhone()); // paramMap.put("driverPhone", "17726395120"); paramMap.put("thirdSerialNo", order.getOrderNo()); paramMap.put("refuelingAmount", highChildOrder.getTotalPrice()); // 油品类型 1:汽油:2:柴油;3:天然气 if (highChildOrder.getGasOilType() == 1) { paramMap.put("accountNo", CommonSysConst.getSysConfig().getTuanYouGasolineAccount()); } else if (highChildOrder.getGasOilType() == 2) { paramMap.put("accountNo", CommonSysConst.getSysConfig().getTuanYouDieselAccount()); } JSONObject orderPushObject = TuanYouConfig.refuelingOrderPush(paramMap); // 推送团油订单记录 HighGasOrderPush highGasOrderPush = new HighGasOrderPush(); highGasOrderPush.setCreateTime(new Date()); highGasOrderPush.setCode(orderPushObject.getString("code")); highGasOrderPush.setRequestContent(JSONObject.toJSONString(paramMap)); highGasOrderPush.setReturnContent(orderPushObject.toJSONString()); highGasOrderPushMapper.insert(highGasOrderPush); if (orderPushObject != null && orderPushObject.getString("code").equals("200")) { highChildOrder.setGasOrderNo(orderPushObject.getJSONObject("result").getString("orderNo")); } highOrderService.updateOrder(order); } return ResponseMsgUtil.success(order); } catch (Exception e) { log.error("HighOrderController --> getOrderById() error!", e); return ResponseMsgUtil.exception(e); } } */ @RequestMapping(value = "/queryCompanyAccountInfo2JD", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询团油余额") public ResponseData queryCompanyAccountInfo2JD() { try { return ResponseMsgUtil.success(TuanYouConfig.queryCompanyAccountInfo2JD()); } catch (Exception e) { log.error("HighOrderController --> queryCompanyAccountInfo2JD() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryCompanyPriceDetail", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询团油余额") public ResponseData queryCompanyPriceDetail() { try { return ResponseMsgUtil.success(TuanYouConfig.queryCompanyPriceDetail("LW000115995", "92")); } catch (Exception e) { log.error("HighOrderController --> queryCompanyAccountInfo2JD() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/starbucksOrdersPay", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "星巴克支付") public ResponseData starbucksOrdersPay(@RequestParam(name = "orderNo", required = true) String orderNo) { try { return ResponseMsgUtil.success(QianZhuConfig.starbucksOrdersPay(orderNo)); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/payKfcOrder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "肯德基支付") public ResponseData payKfcOrder(@RequestParam(name = "orderNo", required = true) String orderNo) { try { return ResponseMsgUtil.success(QianZhuConfig.payKfcOrder(orderNo)); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/wxSplitAccount", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "微信分账") public ResponseData wxSplitAccount() { try { HighOrder orderNo = highOrderService.getOrderByOrderNo("HF2021101812025050304"); wxProfitsharing(orderNo.getOrderNo(), orderNo.getPaySerialNo(), orderNo.getPayRealPrice()); return ResponseMsgUtil.success("分账成功"); } catch (Exception e) { log.error("HighOrderController --> getOrderById() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryStaging", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "分期查询") public ResponseData queryStaging(@RequestParam(name = "oriOrgTrace", required = true) String oriOrgTrace, HttpServletRequest request) { try { String orgTrace = CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(0, 4) + CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length() - 4, CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length()) + DateUtil.format(new Date(), DateUtil.YMDHMS) + IDGenerator.nextId(6); return ResponseMsgUtil.success(UnionStagingPayConfig.queryStaging(orgTrace, oriOrgTrace, "", new Date(), request)); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } /* @RequestMapping(value = "/orderToRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "退款") public ResponseData orderToRefund(HttpServletRequest request) { try { OrderRefundModel orderRefundModel = WxOrderConfig.orderToRefund("4200001301202202035413938093", new BigDecimal("30.80"), new BigDecimal("16.90")); return ResponseMsgUtil.success(orderRefundModel); } catch (Exception e) { log.error("HighOrderController --> orderToRefund() error!", e); return ResponseMsgUtil.exception(e); } }*/ @RequestMapping(value = "/query", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "订单查询") public ResponseData query(@RequestParam(name = "oriOrgTrace", required = true) String oriOrgTrace, HttpServletRequest request) { try { String orgTrace = CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(0, 4) + CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length() - 4, CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length()) + DateUtil.format(new Date(), DateUtil.YMDHMS) + IDGenerator.nextId(6); return ResponseMsgUtil.success(UnionStagingPayConfig.query(orgTrace, oriOrgTrace, "", new Date(), request)); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } public void wxProfitsharing(String transaction_id, String out_order_no, BigDecimal amount) { try { Map param = new LinkedHashMap<>(); param.put("appid", "wx637bd6f7314daa46"); param.put("mch_id", "1289663601"); param.put("sub_mch_id", "1609882817"); // 个体户黎杨珍 param.put("transaction_id", transaction_id); param.put("out_order_no", out_order_no); param.put("nonce_str", WxUtils.makeNonStr()); // 分账金额 BigDecimal porofitSharingAmount = amount; List> receiversList = new ArrayList<>(); Map receiversMap = new LinkedHashMap<>(); receiversMap.put("type", "MERCHANT_ID"); receiversMap.put("account", "1603942866"); receiversMap.put("amount", porofitSharingAmount.multiply(new BigDecimal("100")).intValue()); receiversMap.put("description", "分给商户【惠昕石化】"); receiversList.add(receiversMap); param.put("receivers", JSONObject.toJSONString(receiversList)); String signStr = WxUtils.generateSignature(param, "Skufk5oi85wDFGl888i6wsRSTkdd5df5", WXPayConstants.SignType.HMACSHA256); param.put("sign", signStr); String resultXmL = this.doRefundRequest(param.get("mch_id"), null, WxUtils.mapToXml(param)); // 请求分账返回的结果 ResultProfitSharing resultProfitSharing = XmlUtil.getObjectFromXML(resultXmL, ResultProfitSharing.class); if (!resultProfitSharing.getResult_code().equals("FAIL")) { HighProfitSharingRecord sharingRecord = new HighProfitSharingRecord(); sharingRecord.setOutOrderNo(resultProfitSharing.getOut_order_no()); sharingRecord.setTransactionId(resultProfitSharing.getTransaction_id()); sharingRecord.setOrderId(resultProfitSharing.getOrder_id()); sharingRecord.setStatus(resultProfitSharing.getResult_code()); sharingRecord.setPrice(amount); sharingRecord.setCreateTime(new Date()); sharingRecord.setContent(resultXmL); highProfitSharingRecordService.insert(sharingRecord); } } catch (Exception e) { log.error("CmsContentController --> getCorporateAdvertising() error!", e); } } public CloseableHttpClient readCertificate(String mchId) throws Exception { /** * 注意PKCS12证书 是从微信商户平台-》账户设置-》 API安全 中下载的 */ KeyStore keyStore = KeyStore.getInstance("PKCS12"); //P12文件目录 证书路径,这里需要你自己修改,linux下还是windows下的根路径 FileInputStream instream = new FileInputStream("/home/project/wx_cert/1289663601_apiclient_cert.p12"); // FileInputStream instream = new FileInputStream("G:\\hurui-project/hai-parent/hai-service/src/main/java/privatekey/1289663601_apiclient_cert.p12"); try { keyStore.load(instream, "1289663601".toCharArray());//这里写密码..默认是你的MCHID } finally { instream.close(); } SSLContext sslcontext = SSLContexts.custom().loadKeyMaterial(keyStore, "1289663601".toCharArray()).build();//这里也是写密码的 SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslcontext, SSLConnectionSocketFactory.getDefaultHostnameVerifier()); // Allow TLSv1 protocol only return HttpClients.custom().setSSLSocketFactory(sslsf).build(); } public String doRefundRequest(String mchId, String url, String data) throws Exception { //小程序退款需要调用双向证书的认证 CloseableHttpClient httpClient = readCertificate(mchId); try { HttpPost httpost = new HttpPost("https://api.mch.weixin.qq.com/secapi/pay/profitsharing"); // 设置响应头信息 httpost.addHeader("Connection", "keep-alive"); httpost.addHeader("Accept", "*/*"); httpost.addHeader("Content-Type", "text/xml"); httpost.addHeader("Host", "api.mch.weixin.qq.com"); httpost.addHeader("X-Requested-With", "XMLHttpRequest"); httpost.addHeader("Cache-Control", "max-age=0"); httpost.addHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0) "); httpost.setEntity(new StringEntity(data, "UTF-8")); CloseableHttpResponse response = httpClient.execute(httpost); try { HttpEntity entity = response.getEntity(); String jsonStr = EntityUtils.toString(response.getEntity(), "UTF-8"); EntityUtils.consume(entity); return jsonStr; } finally { response.close(); } } catch (Exception e) { throw new RuntimeException(e); } finally { httpClient.close(); } } @RequestMapping(value = "/websocket", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "websocket") public ResponseData websocket(@RequestParam(name = "orderNo", required = true) String orderNo ) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); if (order.getHighChildOrderList().get(0).getGoodsType().equals(3)) { Map pushMsg = new HashMap<>(); pushMsg.put("userId", order.getHighChildOrderList().get(0).getGoodsId()); Map msgContent = new HashMap<>(); msgContent.put("order", highOrderService.getGasOrderDetail(order.getOrderNo())); msgContent.put("voice", baiduVoiceService.text2audio(order.getHighChildOrderList().get(0).getGoodsName() + "加油站,收款:" + order.getTotalPrice())); pushMsg.put("message", JSONObject.toJSONString(msgContent)); HttpsUtils.doPost("http://127.0.0.1:9901/msg/test/websocket", pushMsg, new HashMap<>()); } return ResponseMsgUtil.success("null"); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/gasStationQueryDetail", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "gasStationQueryDetail") public ResponseData gasStationQueryDetail() { try { return ResponseMsgUtil.success(shellGroupService.gasStationQueryDetail("0001")); } catch (Exception e) { log.error("HighOrderController --> gasStationQueryDetail() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/gasPageQueryAllStation", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "gasPageQueryAllStation") public ResponseData gasPageQueryAllStation() { try { gasService.getJiaHaoYouAllStation(); return ResponseMsgUtil.success(null); } catch (Exception e) { log.error("HighOrderController --> gasPageQueryAllStation() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/gasSyncPayment", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "gasSyncPayment") public ResponseData gasSyncPayment(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOrder order = highOrderService.getOrderByOrderNo("orderNo"); for (HighChildOrder childOrder : order.getHighChildOrderList()) { HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreById(childOrder.getGoodsId()); // 推送加好油 shellGroupService.gasSyncPayment(order.getOrderNo(), store.getStoreKey(), order.getPayTime(), childOrder.getTotalPrice(), childOrder.getGasOilNo(), childOrder.getGasGunNo(), order.getPayablePrice(), order.getDeductionPrice() ); } return ResponseMsgUtil.success(null); } catch (Exception e) { log.error("HighOrderController --> gasPageQueryAllStation() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/gasSyncRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "gasSyncRefund") public ResponseData gasSyncRefund() { try { shellGroupService.gasSyncRefund(new Date(1659511289000L), "1659511289357"); return ResponseMsgUtil.success(null); } catch (Exception e) { log.error("HighOrderController --> gasSyncRefund() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getJzStationListPage", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "getJzStationListPage") public ResponseData getJzStationListPage() { try { gasService.getJinZhuAllStation(); return ResponseMsgUtil.success(null); } catch (Exception e) { log.error("HighOrderController --> gasSyncRefund() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/test", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "test") public ResponseData test() { try { JSONObject data = HuiLianTongUnionCardConfig.resolveResponse("Gbkl57c3fECXJRiCSOspjsb3bIyyFrE4TyMKKGsSAMzeXLElQQU00GoYZSYkJYg1G2Xlic2QvOd3\\nhJC7bc6qAg+9aoZr3IJi"); return ResponseMsgUtil.success(data); } catch (Exception e) { log.error("HighOrderController --> gasSyncRefund() error!", e); return ResponseMsgUtil.exception(e); } } public static String hexStringToString(String s) { if (s == null || s.equals("")) { return null; } s = s.replace(" ", ""); byte[] baKeyword = new byte[s.length() / 2]; for (int i = 0; i < baKeyword.length; i++) { try { baKeyword[i] = (byte) (0xff & Integer.parseInt(s.substring(i * 2, i * 2 + 2), 16)); } catch (Exception e) { e.printStackTrace(); } } try { s = new String(baKeyword, "UTF-8"); } catch (Exception e1) { e1.printStackTrace(); } return s; } /** * 获取打印内容,适用于云打印机 * * @param printText 打印文本 * @param pageCount 打印联数 * @param encodingStr 编码方式,默认UTF-8 * @return */ public byte[] getPrinterBytes(final byte[] printText, final int pageCount, String encodingStr) { try { byte[] array = new byte[printText.length + 9]; array[0] = 30; array[1] = 16; array[2] = (byte) pageCount;//打印份数 int num = array.length - 5; array[3] = (byte) (num >> 8); //array[4] = (byte)((uint)num & 0xFFu); array[4] = (byte) (num & 0xFF); for (int i = 0; i < printText.length; i++) { array[i + 5] = printText[i]; } array[array.length - 4] = 27; array[array.length - 3] = 99; byte[] crc16CodeArray = getCRC(printText); array[array.length - 2] = crc16CodeArray[0]; array[array.length - 1] = crc16CodeArray[1]; return array; /* if(encodingStr.equals("")){ encodingStr="UTF-8"; } byte[] msgByte = printText; // 消息数组 final byte[] dataByte = new byte[msgByte.length + 9]; dataByte[0] = 0x1E; dataByte[1] = 0x10; dataByte[2] = (byte) pageCount;// 打印多联 // 有效数据长度 final int len = dataByte.length - 5; dataByte[3] = (byte) (len >> 8); dataByte[4] = (byte) (len & 0xff); // 数据内容 System.arraycopy(msgByte, 0, dataByte, 5, msgByte.length); // 标识字节 dataByte[dataByte.length - 4] = 0x1b; dataByte[dataByte.length - 3] = 0x63; // 打印内容CRC校验 final byte[] dtCRC = getCRC(msgByte); dataByte[dataByte.length - 2] = (byte) (dtCRC[0]); dataByte[dataByte.length - 1] = (byte) (dtCRC[1]); msgByte = dataByte; return msgByte;*/ } catch (Exception ex) { System.out.println(ex.getStackTrace()); } return null; } /** * 获取打印内容,适用于云打印机 * * @param printText 打印文本 * @param pageCount 打印联数 * @param encodingStr 编码方式,默认UTF-8 * @return */ public byte[] getPrinterBytes(final String printText, final int pageCount, String encodingStr) { try { if (encodingStr.equals("")) { encodingStr = "UTF-8"; } byte[] msgByte = printText.getBytes(encodingStr); // 消息数组 final byte[] dataByte = new byte[msgByte.length + 9]; dataByte[0] = 0x1E; dataByte[1] = 0x10; dataByte[2] = (byte) pageCount;// 打印多联 // 有效数据长度 final int len = dataByte.length - 5; dataByte[3] = (byte) (len >> 8); dataByte[4] = (byte) (len & 0xff); // 数据内容 System.arraycopy(msgByte, 0, dataByte, 5, msgByte.length); // 标识字节 dataByte[dataByte.length - 4] = 0x1b; dataByte[dataByte.length - 3] = 0x63; // 打印内容CRC校验 final byte[] dtCRC = getCRC(msgByte); dataByte[dataByte.length - 2] = (byte) (dtCRC[0]); dataByte[dataByte.length - 1] = (byte) (dtCRC[1]); msgByte = dataByte; return msgByte; } catch (Exception ex) { System.out.println(ex.getStackTrace()); } return null; } private static int[] CRC16Table = {0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf, 0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7, 0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e, 0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876, 0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd, 0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5, 0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c, 0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974, 0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb, 0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3, 0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a, 0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72, 0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9, 0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1, 0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738, 0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70, 0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7, 0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff, 0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036, 0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e, 0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5, 0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd, 0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134, 0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c, 0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3, 0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb, 0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232, 0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a, 0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1, 0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9, 0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330, 0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78}; private static byte[] getCRC(byte[] bytes) { int crc = 0xFFFF; // 初始值 for (byte b : bytes) { crc = (crc >> 8) ^ CRC16Table[(crc ^ b) & 0xff]; } byte[] b = new byte[2]; b[0] = (byte) ((crc >> 8) ^ 0xff); b[1] = (byte) ((crc & 0xff) ^ 0xff); return b; } private static final char[] HEXES = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; /** * byte数组 转换成 16进制小写字符串 */ private String bytes2Hex(byte[] bytes) { if (bytes == null || bytes.length == 0) { return null; } StringBuilder hex = new StringBuilder(); for (byte b : bytes) { hex.append(HEXES[(b >> 4) & 0x0F]); hex.append(HEXES[b & 0x0F]); } return hex.toString(); } @RequestMapping(value = "/insertV2", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "支付") public ResponseData insertV2() { try { String orderNo = "HF2022080818504922206"; JSONObject object = QianZhuConfig.insertV2("PLM100024", orderNo, "15585850137"); object.put("orderNo", orderNo); return ResponseMsgUtil.success(object); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/QueryV2", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询订单号") public ResponseData QueryV2(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); JSONObject orderObject = QianZhuConfig.QueryV2(orderNo); if (orderObject != null && orderObject.getLong("Code") == 999) { // 订单失败 // 订单状态 1:订单正在处理中 2;订单成功: 3 订单失败 if (orderObject.getJSONObject("Data").getInteger("OrderState") == 3) { // 订单失败 if (order.getOrderStatus() == 2) { highOrderService.thirdOrderToRefund(order.getId()); } else { highOrderService.thirdCancelOrder(order.getId()); } } // 订单状态 1:订单正在处理中 2;订单成功: 3 订单失败 if (orderObject.getJSONObject("Data").getInteger("OrderState") == 2) { for (HighChildOrder childOrder : order.getHighChildOrderList()) { childOrder.setChildOrdeStatus(3); } order.setOrderStatus(3); order.setFinishTime(new Date()); highOrderService.updateOrder(order); } } return ResponseMsgUtil.success(QianZhuConfig.QueryV2(orderNo)); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getKfcOrderByOrderNo", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询肯德基订单") public ResponseData getKfcOrderByOrderNo(@RequestParam(name = "orderNo", required = true) String orderNo) { try { return ResponseMsgUtil.success(QianZhuConfig.getKfcOrderByOrderNo(orderNo)); } catch (Exception e) { log.error("HighOrderController -> addOrder() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/starbucksOrderByOrderNo", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询星巴克订单") public ResponseData starbucksOrderByOrderNo(@RequestParam(name = "orderNo", required = true) String orderNo) { try { return ResponseMsgUtil.success(QianZhuConfig.starbucksOrderByOrderNo(orderNo)); } catch (Exception e) { log.error("HighOrderController -> addOrder() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/thirdOrderToRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "第三方退款") public ResponseData thirdOrderToRefund(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); highOrderService.thirdOrderToRefund(order.getId()); return ResponseMsgUtil.success(""); } catch (Exception e) { log.error("HighOrderController -> addOrder() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/rechargeOrderByCy", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "城宇话费充值 ") public ResponseData rechargeOrderByCy() { try { JSONObject object = new JSONObject(); object.put("mobile" , "18090580471"); object.put("productId" , 172); object.put("agentOrderId" , "RCG" + DateUtil.date2String(new Date(), "yyyyMMddHHmmss") + IDGenerator.nextId(5)); return ResponseMsgUtil.success(RechargeConfig.rechargeOrderByCy(object)); } catch (Exception e) { log.error("HighOrderController -> addOrder() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryRechargeByCy", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "城宇查询订单") public ResponseData queryRechargeByCy(@RequestParam(name = "orderNo", required = true) String orderNo) { try { JSONObject object = new JSONObject(); object.put("orderNo" , orderNo); return ResponseMsgUtil.success(RechargeConfig.queryRechargeByCy(object)); } catch (Exception e) { log.error("HighOrderController -> addOrder() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/postIp", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "请求ip地址") public ResponseData postIp(HttpServletRequest request) { try { request.getHeader("regionId"); if (request.getHeader("regionId") != null && request.getHeader("regionId").length() != 0) { System.out.println("111"); } return ResponseMsgUtil.success(HttpsUtils.doPost("https://hsgcs.dctpay.com/brest/openApi/test")); } catch (Exception e) { log.error("HighOrderController -> addOrder() error!", e); return ResponseMsgUtil.exception(e); } } } \ No newline at end of file + package com.cweb.controller; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.cweb.config.SysConst; import com.hai.common.Base64Util; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.pay.util.XmlUtil; import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.security.SessionObject; import com.hai.common.utils.*; import com.hai.config.*; import com.hai.dao.HighGasOrderPushMapper; import com.hai.entity.*; import com.hai.enum_type.MerchantStoreSourceType; import com.hai.model.*; import com.hai.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpPost; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.ssl.SSLContexts; import org.apache.http.util.EntityUtils; import org.bouncycastle.util.encoders.UrlBase64; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.util.IdGenerator; import org.springframework.web.bind.annotation.*; import sun.nio.cs.StreamEncoder; import javax.annotation.Resource; import javax.net.ssl.SSLContext; import javax.servlet.http.HttpServletRequest; import java.io.*; import java.math.BigDecimal; import java.nio.charset.StandardCharsets; import java.security.KeyStore; import java.util.*; /** * @Auther: 胡锐 * @Description: * @Date: 2021/3/26 23:08 */ @Controller @RequestMapping(value = "/test") @Api(value = "订单接口") public class HighTestController { private static Logger log = LoggerFactory.getLogger(HighTestController.class); @Resource private HighMerchantService highMerchantService; @Resource private HighMerchantStoreService highMerchantStoreService; @Resource private HighGasOilPriceService highGasOilPriceService; @Resource private HighOrderService highOrderService; @Resource private HighProfitSharingRecordService highProfitSharingRecordService; @Resource private HighGasOilGunNoService gasOilGunNoService; @Resource private HighGasOrderPushMapper highGasOrderPushMapper; @Resource private HuiLianTongConfig huiLianTongConfig; @Resource private UnionPayConfig unionPayConfig; @Resource private UnionStagingPayConfig unionStagingPayConfig; @Resource private UnionUserConfig unionUserConfig; @Resource private OutRechargeOrderService outRechargeOrderService; @Resource private HighOilCardService oilCardService; @Resource private BaiduVoiceService baiduVoiceService; @Resource private MqttProviderConfig mqttProviderConfig; @Autowired private WebSocket webSocket; @Resource private ShellGroupService shellGroupService; @Resource private HighGasService gasService; @Resource private JinZhuJiaYouService jinZhuJiaYouService; @RequestMapping(value = "/spPrint", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "发送打印机消息") public ResponseData spPrint(@RequestParam(name = "orderNo", required = true) String orderNo, HttpServletRequest request) { try { HighOrder highOrder = highOrderService.getOrderByOrderNo(orderNo); for (HighChildOrder highChildOrder : highOrder.getHighChildOrderList()) { HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreById(highChildOrder.getGoodsId()); new Thread(() -> { try { SpPrinterConfig sp = new SpPrinterConfig(); sp.print(store.getDeviceSn(), SpPrinterTemplate.oilCashierStubTemp( highChildOrder.getGoodsName(), highOrder.getOrderNo(), DateUtil.date2String(highOrder.getPayTime(), "yyyy-MM-dd HH:mm:ss"), "嗨森逛", highChildOrder.getGasGunNo(), highChildOrder.getGasOilNo(), highChildOrder.getGasOilLiters().toString(), highOrder.getTotalPrice().toString(), new HashMap<>(), false ), 1); Thread.sleep(6000); sp.print(store.getDeviceSn(), SpPrinterTemplate.oilClientStubTemp( highChildOrder.getGoodsName(), highOrder.getOrderNo(), DateUtil.date2String(highOrder.getPayTime(), "yyyy-MM-dd HH:mm:ss"), "嗨森逛", highChildOrder.getGasGunNo(), highChildOrder.getGasOilNo(), highChildOrder.getGasOilLiters().toString(), highOrder.getTotalPrice().toString(), new HashMap<>(), false ), 1); } catch (Exception e) { e.printStackTrace(); } }).start(); } return ResponseMsgUtil.success("发送成功"); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardInfo() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/sendCNPCTicket", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "根据油站 id 拉取最新的油站数据") public ResponseData sendCNPCTicket(@RequestParam(name = "gasId", required = true) String gasId, HttpServletRequest request) { try { /* JSONObject jsonObject = ChongQingCNPCService.sendCNPCTicket("1663921911751", System.currentTimeMillis() + "", 1, "17726395120"); return ResponseMsgUtil.success(jsonObject);*/ // return ResponseMsgUtil.success(ChongQingCNPCService.queryCoupon("202156655333911202")); return ResponseMsgUtil.success(ChongQingCNPCService.getCNPCCheckCode("202127538335697222", "HF2022101015395966800")); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardInfo() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryGasInfoByGasId", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "根据油站 id 拉取最新的油站数据") public ResponseData queryGasInfoByGasId(@RequestParam(name = "gasId", required = true) String gasId, HttpServletRequest request) { try { return ResponseMsgUtil.success(TuanYouConfig.queryGasInfoByGasId(gasId)); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardInfo() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/initTYMerchantStore", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "初始化加油站") public ResponseData initTYMerchantStore(@RequestParam(name = "merchantId", required = true) Long merchantId) throws Exception { HighMerchantModel merchant = highMerchantService.getMerchantById(merchantId); if (merchant == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到商户"); } JSONObject jsonObjectP = TuanYouConfig.queryGasInfoListByPage(1, 1000); JSONObject resultObjectP = jsonObjectP.getObject("result", JSONObject.class); for (int i = 1; i <= resultObjectP.getInteger("totalPageNum").intValue(); i++) { JSONObject jsonObject = TuanYouConfig.queryGasInfoListByPage(i, 1000); JSONObject resultObject = jsonObject.getObject("result", JSONObject.class); JSONArray jsonArray = resultObject.getJSONArray("gasInfoList"); HighMerchantStore highMerchantStore; HighGasOilPrice highGasOilPrice; for (Object gasObject : jsonArray) { JSONObject object = JSONObject.parseObject(JSONObject.toJSONString(gasObject)); HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreByKey(object.getString("gasId")); if (store != null) { store.setType(1); store.setMerchantId(merchant.getId()); store.setCompanyId(merchant.getCompanyId()); store.setStoreKey(object.getString("gasId")); store.setStoreName(object.getString("gasName")); store.setStoreLogo(object.getString("gasLogoSmall")); store.setRegionId(object.getLong("provinceCode")); store.setRegionName(object.getString("provinceName")); store.setAddress(object.getString("gasAddress")); store.setLongitude(object.getString("gasAddressLongitude")); store.setLatitude(object.getString("gasAddressLatitude")); store.setStatus(object.getInteger("gasStatus")); store.setOperatorId(0L); store.setOperatorName("系统创建"); store.setUpdateTime(new Date()); store.setExt1(object.getString("gasSourceId")); highMerchantStoreService.updateMerchantStoreDetail(store); JSONArray oilPriceList = object.getJSONArray("oilPriceList"); for (Object oilPrice : oilPriceList) { JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); // 查询门店油号 highGasOilPrice = highGasOilPriceService.getGasOilPriceByStoreAndOilNo(store.getId(), oilPriceObject.getInteger("oilNo")); if (highGasOilPrice == null) { highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getInteger("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); } else { highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getInteger("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); } highGasOilPriceService.editGasOilPrice(highGasOilPrice); } } else { highMerchantStore = new HighMerchantStore(); highMerchantStore.setType(1); highMerchantStore.setMerchantId(merchant.getId()); highMerchantStore.setCompanyId(merchant.getCompanyId()); highMerchantStore.setStoreKey(object.getString("gasId")); highMerchantStore.setStoreName(object.getString("gasName")); highMerchantStore.setStoreLogo(object.getString("gasLogoSmall")); highMerchantStore.setRegionId(object.getLong("provinceCode")); highMerchantStore.setRegionName(object.getString("provinceName")); highMerchantStore.setAddress(object.getString("gasAddress")); highMerchantStore.setLongitude(object.getString("gasAddressLongitude")); highMerchantStore.setLatitude(object.getString("gasAddressLatitude")); highMerchantStore.setStatus(1); highMerchantStore.setOperatorId(0L); highMerchantStore.setOperatorName("系统创建"); highMerchantStore.setCreateTime(new Date()); highMerchantStore.setUpdateTime(new Date()); highMerchantStore.setExt1(object.getString("gasSourceId")); HighMerchantStoreModel merchantStoreModel = new HighMerchantStoreModel(); BeanUtils.copyProperties(highMerchantStore, merchantStoreModel); highMerchantStoreService.insertMerchantStore(merchantStoreModel); JSONArray oilPriceList = object.getJSONArray("oilPriceList"); for (Object oilPrice : oilPriceList) { JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(merchantStoreModel.getId()); highGasOilPrice.setOilNo(oilPriceObject.getInteger("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); highGasOilPriceService.editGasOilPrice(highGasOilPrice); } } } } return ResponseMsgUtil.success("初始化完成"); } @RequestMapping(value = "/detectTYMerchantStore", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "检测加油站") public ResponseData detectTYMerchantStore(@RequestParam(name = "merchantId", required = true) Long merchantId) throws Exception { HighMerchantModel merchant = highMerchantService.getMerchantById(merchantId); if (merchant == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到商户"); } Map param = new HashMap<>(); param.put("merchantId", merchant.getId()); List stores = highMerchantStoreService.getMerchantStoreList(param); for (HighMerchantStore store : stores) { JSONObject jsonObject = TuanYouConfig.queryGasInfoByGasId(store.getStoreKey()); if (jsonObject != null && jsonObject.getString("code").equals("200")) { JSONObject result = jsonObject.getJSONObject("result"); store.setStatus(result.getInteger("gasStatus")); } else { store.setStatus(0); } highMerchantStoreService.updateMerchantStoreDetail(store); } return ResponseMsgUtil.success("初始化完成"); } /* @RequestMapping(value = "/pushTuanYouOrder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "推送团油订单") public ResponseData pushTuanYouOrder(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); for (HighChildOrder highChildOrder : order.getHighChildOrderList()) { HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreById(highChildOrder.getGoodsId()); // 推送团油订单 Map paramMap = new HashMap<>(); paramMap.put("gasId", store.getStoreKey()); paramMap.put("oilNo", highChildOrder.getGasOilNo()); paramMap.put("gunNo", highChildOrder.getGasGunNo()); BigDecimal priceGun = highChildOrder.getGasPriceGun(); BigDecimal priceVip = highChildOrder.getGasPriceVip(); paramMap.put("priceGun", priceGun); // 枪单价 paramMap.put("priceVip", priceVip); // 优惠价 paramMap.put("driverPhone", order.getMemPhone()); // paramMap.put("driverPhone", "17726395120"); paramMap.put("thirdSerialNo", order.getOrderNo()); paramMap.put("refuelingAmount", highChildOrder.getTotalPrice()); // 油品类型 1:汽油:2:柴油;3:天然气 if (highChildOrder.getGasOilType() == 1) { paramMap.put("accountNo", CommonSysConst.getSysConfig().getTuanYouGasolineAccount()); } else if (highChildOrder.getGasOilType() == 2) { paramMap.put("accountNo", CommonSysConst.getSysConfig().getTuanYouDieselAccount()); } JSONObject orderPushObject = TuanYouConfig.refuelingOrderPush(paramMap); // 推送团油订单记录 HighGasOrderPush highGasOrderPush = new HighGasOrderPush(); highGasOrderPush.setCreateTime(new Date()); highGasOrderPush.setCode(orderPushObject.getString("code")); highGasOrderPush.setRequestContent(JSONObject.toJSONString(paramMap)); highGasOrderPush.setReturnContent(orderPushObject.toJSONString()); highGasOrderPushMapper.insert(highGasOrderPush); if (orderPushObject != null && orderPushObject.getString("code").equals("200")) { highChildOrder.setGasOrderNo(orderPushObject.getJSONObject("result").getString("orderNo")); } highOrderService.updateOrder(order); } return ResponseMsgUtil.success(order); } catch (Exception e) { log.error("HighOrderController --> getOrderById() error!", e); return ResponseMsgUtil.exception(e); } } */ @RequestMapping(value = "/queryCompanyAccountInfo2JD", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询团油余额") public ResponseData queryCompanyAccountInfo2JD() { try { return ResponseMsgUtil.success(TuanYouConfig.queryCompanyAccountInfo2JD()); } catch (Exception e) { log.error("HighOrderController --> queryCompanyAccountInfo2JD() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryCompanyPriceDetail", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询团油余额") public ResponseData queryCompanyPriceDetail() { try { return ResponseMsgUtil.success(TuanYouConfig.queryCompanyPriceDetail("LW000115995", "92")); } catch (Exception e) { log.error("HighOrderController --> queryCompanyAccountInfo2JD() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/starbucksOrdersPay", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "星巴克支付") public ResponseData starbucksOrdersPay(@RequestParam(name = "orderNo", required = true) String orderNo) { try { return ResponseMsgUtil.success(QianZhuConfig.starbucksOrdersPay(orderNo)); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/payKfcOrder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "肯德基支付") public ResponseData payKfcOrder(@RequestParam(name = "orderNo", required = true) String orderNo) { try { return ResponseMsgUtil.success(QianZhuConfig.payKfcOrder(orderNo)); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/wxSplitAccount", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "微信分账") public ResponseData wxSplitAccount() { try { HighOrder orderNo = highOrderService.getOrderByOrderNo("HF2021101812025050304"); wxProfitsharing(orderNo.getOrderNo(), orderNo.getPaySerialNo(), orderNo.getPayRealPrice()); return ResponseMsgUtil.success("分账成功"); } catch (Exception e) { log.error("HighOrderController --> getOrderById() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryStaging", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "分期查询") public ResponseData queryStaging(@RequestParam(name = "oriOrgTrace", required = true) String oriOrgTrace, HttpServletRequest request) { try { String orgTrace = CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(0, 4) + CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length() - 4, CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length()) + DateUtil.format(new Date(), DateUtil.YMDHMS) + IDGenerator.nextId(6); return ResponseMsgUtil.success(UnionStagingPayConfig.queryStaging(orgTrace, oriOrgTrace, "", new Date(), request)); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } /* @RequestMapping(value = "/orderToRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "退款") public ResponseData orderToRefund(HttpServletRequest request) { try { OrderRefundModel orderRefundModel = WxOrderConfig.orderToRefund("4200001301202202035413938093", new BigDecimal("30.80"), new BigDecimal("16.90")); return ResponseMsgUtil.success(orderRefundModel); } catch (Exception e) { log.error("HighOrderController --> orderToRefund() error!", e); return ResponseMsgUtil.exception(e); } }*/ @RequestMapping(value = "/query", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "订单查询") public ResponseData query(@RequestParam(name = "oriOrgTrace", required = true) String oriOrgTrace, HttpServletRequest request) { try { String orgTrace = CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(0, 4) + CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length() - 4, CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length()) + DateUtil.format(new Date(), DateUtil.YMDHMS) + IDGenerator.nextId(6); return ResponseMsgUtil.success(UnionStagingPayConfig.query(orgTrace, oriOrgTrace, "", new Date(), request)); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } public void wxProfitsharing(String transaction_id, String out_order_no, BigDecimal amount) { try { Map param = new LinkedHashMap<>(); param.put("appid", "wx637bd6f7314daa46"); param.put("mch_id", "1289663601"); param.put("sub_mch_id", "1609882817"); // 个体户黎杨珍 param.put("transaction_id", transaction_id); param.put("out_order_no", out_order_no); param.put("nonce_str", WxUtils.makeNonStr()); // 分账金额 BigDecimal porofitSharingAmount = amount; List> receiversList = new ArrayList<>(); Map receiversMap = new LinkedHashMap<>(); receiversMap.put("type", "MERCHANT_ID"); receiversMap.put("account", "1603942866"); receiversMap.put("amount", porofitSharingAmount.multiply(new BigDecimal("100")).intValue()); receiversMap.put("description", "分给商户【惠昕石化】"); receiversList.add(receiversMap); param.put("receivers", JSONObject.toJSONString(receiversList)); String signStr = WxUtils.generateSignature(param, "Skufk5oi85wDFGl888i6wsRSTkdd5df5", WXPayConstants.SignType.HMACSHA256); param.put("sign", signStr); String resultXmL = this.doRefundRequest(param.get("mch_id"), null, WxUtils.mapToXml(param)); // 请求分账返回的结果 ResultProfitSharing resultProfitSharing = XmlUtil.getObjectFromXML(resultXmL, ResultProfitSharing.class); if (!resultProfitSharing.getResult_code().equals("FAIL")) { HighProfitSharingRecord sharingRecord = new HighProfitSharingRecord(); sharingRecord.setOutOrderNo(resultProfitSharing.getOut_order_no()); sharingRecord.setTransactionId(resultProfitSharing.getTransaction_id()); sharingRecord.setOrderId(resultProfitSharing.getOrder_id()); sharingRecord.setStatus(resultProfitSharing.getResult_code()); sharingRecord.setPrice(amount); sharingRecord.setCreateTime(new Date()); sharingRecord.setContent(resultXmL); highProfitSharingRecordService.insert(sharingRecord); } } catch (Exception e) { log.error("CmsContentController --> getCorporateAdvertising() error!", e); } } public CloseableHttpClient readCertificate(String mchId) throws Exception { /** * 注意PKCS12证书 是从微信商户平台-》账户设置-》 API安全 中下载的 */ KeyStore keyStore = KeyStore.getInstance("PKCS12"); //P12文件目录 证书路径,这里需要你自己修改,linux下还是windows下的根路径 FileInputStream instream = new FileInputStream("/home/project/wx_cert/1289663601_apiclient_cert.p12"); // FileInputStream instream = new FileInputStream("G:\\hurui-project/hai-parent/hai-service/src/main/java/privatekey/1289663601_apiclient_cert.p12"); try { keyStore.load(instream, "1289663601".toCharArray());//这里写密码..默认是你的MCHID } finally { instream.close(); } SSLContext sslcontext = SSLContexts.custom().loadKeyMaterial(keyStore, "1289663601".toCharArray()).build();//这里也是写密码的 SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslcontext, SSLConnectionSocketFactory.getDefaultHostnameVerifier()); // Allow TLSv1 protocol only return HttpClients.custom().setSSLSocketFactory(sslsf).build(); } public String doRefundRequest(String mchId, String url, String data) throws Exception { //小程序退款需要调用双向证书的认证 CloseableHttpClient httpClient = readCertificate(mchId); try { HttpPost httpost = new HttpPost("https://api.mch.weixin.qq.com/secapi/pay/profitsharing"); // 设置响应头信息 httpost.addHeader("Connection", "keep-alive"); httpost.addHeader("Accept", "*/*"); httpost.addHeader("Content-Type", "text/xml"); httpost.addHeader("Host", "api.mch.weixin.qq.com"); httpost.addHeader("X-Requested-With", "XMLHttpRequest"); httpost.addHeader("Cache-Control", "max-age=0"); httpost.addHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0) "); httpost.setEntity(new StringEntity(data, "UTF-8")); CloseableHttpResponse response = httpClient.execute(httpost); try { HttpEntity entity = response.getEntity(); String jsonStr = EntityUtils.toString(response.getEntity(), "UTF-8"); EntityUtils.consume(entity); return jsonStr; } finally { response.close(); } } catch (Exception e) { throw new RuntimeException(e); } finally { httpClient.close(); } } @RequestMapping(value = "/websocket", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "websocket") public ResponseData websocket(@RequestParam(name = "orderNo", required = true) String orderNo ) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); if (order.getHighChildOrderList().get(0).getGoodsType().equals(3)) { Map pushMsg = new HashMap<>(); pushMsg.put("userId", order.getHighChildOrderList().get(0).getGoodsId()); Map msgContent = new HashMap<>(); msgContent.put("order", highOrderService.getGasOrderDetail(order.getOrderNo())); msgContent.put("voice", baiduVoiceService.text2audio(order.getHighChildOrderList().get(0).getGoodsName() + "加油站,收款:" + order.getTotalPrice())); pushMsg.put("message", JSONObject.toJSONString(msgContent)); HttpsUtils.doPost("http://127.0.0.1:9901/msg/test/websocket", pushMsg, new HashMap<>()); } return ResponseMsgUtil.success("null"); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/gasStationQueryDetail", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "gasStationQueryDetail") public ResponseData gasStationQueryDetail() { try { return ResponseMsgUtil.success(shellGroupService.gasStationQueryDetail("0001")); } catch (Exception e) { log.error("HighOrderController --> gasStationQueryDetail() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/gasPageQueryAllStation", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "gasPageQueryAllStation") public ResponseData gasPageQueryAllStation() { try { gasService.getJiaHaoYouAllStation(); return ResponseMsgUtil.success(null); } catch (Exception e) { log.error("HighOrderController --> gasPageQueryAllStation() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/gasSyncPayment", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "gasSyncPayment") public ResponseData gasSyncPayment(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOrder order = highOrderService.getOrderByOrderNo("orderNo"); for (HighChildOrder childOrder : order.getHighChildOrderList()) { HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreById(childOrder.getGoodsId()); // 推送加好油 shellGroupService.gasSyncPayment(order.getOrderNo(), store.getStoreKey(), order.getPayTime(), childOrder.getTotalPrice(), childOrder.getGasOilNo(), childOrder.getGasGunNo(), order.getPayablePrice(), order.getDeductionPrice() ); } return ResponseMsgUtil.success(null); } catch (Exception e) { log.error("HighOrderController --> gasPageQueryAllStation() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/gasSyncRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "gasSyncRefund") public ResponseData gasSyncRefund() { try { shellGroupService.gasSyncRefund(new Date(1659511289000L), "1659511289357"); return ResponseMsgUtil.success(null); } catch (Exception e) { log.error("HighOrderController --> gasSyncRefund() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getJzStationListPage", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "getJzStationListPage") public ResponseData getJzStationListPage() { try { gasService.getJinZhuAllStation(); return ResponseMsgUtil.success(null); } catch (Exception e) { log.error("HighOrderController --> gasSyncRefund() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/test", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "test") public ResponseData test() { try { JSONObject data = HuiLianTongUnionCardConfig.resolveResponse("Gbkl57c3fECXJRiCSOspjsb3bIyyFrE4TyMKKGsSAMzeXLElQQU00GoYZSYkJYg1G2Xlic2QvOd3\\nhJC7bc6qAg+9aoZr3IJi"); return ResponseMsgUtil.success(data); } catch (Exception e) { log.error("HighOrderController --> gasSyncRefund() error!", e); return ResponseMsgUtil.exception(e); } } public static String hexStringToString(String s) { if (s == null || s.equals("")) { return null; } s = s.replace(" ", ""); byte[] baKeyword = new byte[s.length() / 2]; for (int i = 0; i < baKeyword.length; i++) { try { baKeyword[i] = (byte) (0xff & Integer.parseInt(s.substring(i * 2, i * 2 + 2), 16)); } catch (Exception e) { e.printStackTrace(); } } try { s = new String(baKeyword, "UTF-8"); } catch (Exception e1) { e1.printStackTrace(); } return s; } /** * 获取打印内容,适用于云打印机 * * @param printText 打印文本 * @param pageCount 打印联数 * @param encodingStr 编码方式,默认UTF-8 * @return */ public byte[] getPrinterBytes(final byte[] printText, final int pageCount, String encodingStr) { try { byte[] array = new byte[printText.length + 9]; array[0] = 30; array[1] = 16; array[2] = (byte) pageCount;//打印份数 int num = array.length - 5; array[3] = (byte) (num >> 8); //array[4] = (byte)((uint)num & 0xFFu); array[4] = (byte) (num & 0xFF); for (int i = 0; i < printText.length; i++) { array[i + 5] = printText[i]; } array[array.length - 4] = 27; array[array.length - 3] = 99; byte[] crc16CodeArray = getCRC(printText); array[array.length - 2] = crc16CodeArray[0]; array[array.length - 1] = crc16CodeArray[1]; return array; /* if(encodingStr.equals("")){ encodingStr="UTF-8"; } byte[] msgByte = printText; // 消息数组 final byte[] dataByte = new byte[msgByte.length + 9]; dataByte[0] = 0x1E; dataByte[1] = 0x10; dataByte[2] = (byte) pageCount;// 打印多联 // 有效数据长度 final int len = dataByte.length - 5; dataByte[3] = (byte) (len >> 8); dataByte[4] = (byte) (len & 0xff); // 数据内容 System.arraycopy(msgByte, 0, dataByte, 5, msgByte.length); // 标识字节 dataByte[dataByte.length - 4] = 0x1b; dataByte[dataByte.length - 3] = 0x63; // 打印内容CRC校验 final byte[] dtCRC = getCRC(msgByte); dataByte[dataByte.length - 2] = (byte) (dtCRC[0]); dataByte[dataByte.length - 1] = (byte) (dtCRC[1]); msgByte = dataByte; return msgByte;*/ } catch (Exception ex) { System.out.println(ex.getStackTrace()); } return null; } /** * 获取打印内容,适用于云打印机 * * @param printText 打印文本 * @param pageCount 打印联数 * @param encodingStr 编码方式,默认UTF-8 * @return */ public byte[] getPrinterBytes(final String printText, final int pageCount, String encodingStr) { try { if (encodingStr.equals("")) { encodingStr = "UTF-8"; } byte[] msgByte = printText.getBytes(encodingStr); // 消息数组 final byte[] dataByte = new byte[msgByte.length + 9]; dataByte[0] = 0x1E; dataByte[1] = 0x10; dataByte[2] = (byte) pageCount;// 打印多联 // 有效数据长度 final int len = dataByte.length - 5; dataByte[3] = (byte) (len >> 8); dataByte[4] = (byte) (len & 0xff); // 数据内容 System.arraycopy(msgByte, 0, dataByte, 5, msgByte.length); // 标识字节 dataByte[dataByte.length - 4] = 0x1b; dataByte[dataByte.length - 3] = 0x63; // 打印内容CRC校验 final byte[] dtCRC = getCRC(msgByte); dataByte[dataByte.length - 2] = (byte) (dtCRC[0]); dataByte[dataByte.length - 1] = (byte) (dtCRC[1]); msgByte = dataByte; return msgByte; } catch (Exception ex) { System.out.println(ex.getStackTrace()); } return null; } private static int[] CRC16Table = {0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf, 0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7, 0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e, 0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876, 0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd, 0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5, 0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c, 0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974, 0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb, 0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3, 0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a, 0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72, 0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9, 0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1, 0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738, 0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70, 0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7, 0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff, 0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036, 0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e, 0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5, 0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd, 0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134, 0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c, 0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3, 0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb, 0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232, 0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a, 0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1, 0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9, 0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330, 0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78}; private static byte[] getCRC(byte[] bytes) { int crc = 0xFFFF; // 初始值 for (byte b : bytes) { crc = (crc >> 8) ^ CRC16Table[(crc ^ b) & 0xff]; } byte[] b = new byte[2]; b[0] = (byte) ((crc >> 8) ^ 0xff); b[1] = (byte) ((crc & 0xff) ^ 0xff); return b; } private static final char[] HEXES = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; /** * byte数组 转换成 16进制小写字符串 */ private String bytes2Hex(byte[] bytes) { if (bytes == null || bytes.length == 0) { return null; } StringBuilder hex = new StringBuilder(); for (byte b : bytes) { hex.append(HEXES[(b >> 4) & 0x0F]); hex.append(HEXES[b & 0x0F]); } return hex.toString(); } @RequestMapping(value = "/insertV2", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "支付") public ResponseData insertV2() { try { String orderNo = "HF2022080818504922206"; JSONObject object = QianZhuConfig.insertV2("PLM100024", orderNo, "15585850137"); object.put("orderNo", orderNo); return ResponseMsgUtil.success(object); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/QueryV2", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询订单号") public ResponseData QueryV2(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); JSONObject orderObject = QianZhuConfig.QueryV2(orderNo); if (orderObject != null && orderObject.getLong("Code") == 999) { // 订单失败 // 订单状态 1:订单正在处理中 2;订单成功: 3 订单失败 if (orderObject.getJSONObject("Data").getInteger("OrderState") == 3) { // 订单失败 if (order.getOrderStatus() == 2) { highOrderService.thirdOrderToRefund(order.getId()); } else { highOrderService.thirdCancelOrder(order.getId()); } } // 订单状态 1:订单正在处理中 2;订单成功: 3 订单失败 if (orderObject.getJSONObject("Data").getInteger("OrderState") == 2) { for (HighChildOrder childOrder : order.getHighChildOrderList()) { childOrder.setChildOrdeStatus(3); } order.setOrderStatus(3); order.setFinishTime(new Date()); highOrderService.updateOrder(order); } } return ResponseMsgUtil.success(QianZhuConfig.QueryV2(orderNo)); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getKfcOrderByOrderNo", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询肯德基订单") public ResponseData getKfcOrderByOrderNo(@RequestParam(name = "orderNo", required = true) String orderNo) { try { return ResponseMsgUtil.success(QianZhuConfig.getKfcOrderByOrderNo(orderNo)); } catch (Exception e) { log.error("HighOrderController -> addOrder() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/starbucksOrderByOrderNo", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询星巴克订单") public ResponseData starbucksOrderByOrderNo(@RequestParam(name = "orderNo", required = true) String orderNo) { try { return ResponseMsgUtil.success(QianZhuConfig.starbucksOrderByOrderNo(orderNo)); } catch (Exception e) { log.error("HighOrderController -> addOrder() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/thirdOrderToRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "第三方退款") public ResponseData thirdOrderToRefund(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); highOrderService.thirdOrderToRefund(order.getId()); return ResponseMsgUtil.success(""); } catch (Exception e) { log.error("HighOrderController -> addOrder() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getPayOrderByCouNo", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "第三方退款") public ResponseData getPayOrderByCouNo(@RequestParam(name = "couNo", required = true) String couNo) { try { JSONObject object = HuiLianTongConfig.getPayOrderByCouNo(couNo); return ResponseMsgUtil.success(HuiLianTongUnionCardConfig.resolveResponse(object.getString("data"))); } catch (Exception e) { log.error("HighOrderController -> addOrder() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/rechargeOrderByCy", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "城宇话费充值 ") public ResponseData rechargeOrderByCy() { try { JSONObject object = new JSONObject(); object.put("mobile" , "18090580471"); object.put("productId" , 172); object.put("agentOrderId" , "RCG" + DateUtil.date2String(new Date(), "yyyyMMddHHmmss") + IDGenerator.nextId(5)); return ResponseMsgUtil.success(RechargeConfig.rechargeOrderByCy(object)); } catch (Exception e) { log.error("HighOrderController -> addOrder() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryRechargeByCy", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "城宇查询订单") public ResponseData queryRechargeByCy(@RequestParam(name = "orderNo", required = true) String orderNo) { try { JSONObject object = new JSONObject(); object.put("orderNo" , orderNo); return ResponseMsgUtil.success(RechargeConfig.queryRechargeByCy(object)); } catch (Exception e) { log.error("HighOrderController -> addOrder() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/postIp", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "请求ip地址") public ResponseData postIp(HttpServletRequest request) { try { request.getHeader("regionId"); if (request.getHeader("regionId") != null && request.getHeader("regionId").length() != 0) { System.out.println("111"); } return ResponseMsgUtil.success(HttpsUtils.doPost("https://hsgcs.dctpay.com/brest/openApi/test")); } catch (Exception e) { log.error("HighOrderController -> addOrder() error!", e); return ResponseMsgUtil.exception(e); } } } \ No newline at end of file diff --git a/hai-service/src/main/java/com/hai/dao/HighCouponCodeOtherMapper.java b/hai-service/src/main/java/com/hai/dao/HighCouponCodeOtherMapper.java index a71f9aba..7e6e0fd3 100644 --- a/hai-service/src/main/java/com/hai/dao/HighCouponCodeOtherMapper.java +++ b/hai-service/src/main/java/com/hai/dao/HighCouponCodeOtherMapper.java @@ -39,18 +39,18 @@ public interface HighCouponCodeOtherMapper extends HighCouponCodeOtherMapperExt int deleteByPrimaryKey(Long id); @Insert({ - "insert into high_coupon_code_other (`type`, coupon_agent_code_id, ", - "order_id, child_order_id, ", - "cou_type_code, cou_no, ", - "`status`, active_time, ", + "insert into high_coupon_code_other (`type`, discount_agent_code_id, ", + "coupon_agent_code_id, order_id, ", + "child_order_id, cou_type_code, ", + "cou_no, `status`, active_time, ", "valid_start_date, valid_end_date, ", "use_time, station_code, ", "station_name, create_time, ", "ext_1, ext_2, ext_3)", - "values (#{type,jdbcType=INTEGER}, #{couponAgentCodeId,jdbcType=BIGINT}, ", - "#{orderId,jdbcType=BIGINT}, #{childOrderId,jdbcType=BIGINT}, ", - "#{couTypeCode,jdbcType=VARCHAR}, #{couNo,jdbcType=VARCHAR}, ", - "#{status,jdbcType=INTEGER}, #{activeTime,jdbcType=TIMESTAMP}, ", + "values (#{type,jdbcType=INTEGER}, #{discountAgentCodeId,jdbcType=BIGINT}, ", + "#{couponAgentCodeId,jdbcType=BIGINT}, #{orderId,jdbcType=BIGINT}, ", + "#{childOrderId,jdbcType=BIGINT}, #{couTypeCode,jdbcType=VARCHAR}, ", + "#{couNo,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, #{activeTime,jdbcType=TIMESTAMP}, ", "#{validStartDate,jdbcType=TIMESTAMP}, #{validEndDate,jdbcType=TIMESTAMP}, ", "#{useTime,jdbcType=TIMESTAMP}, #{stationCode,jdbcType=VARCHAR}, ", "#{stationName,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, ", @@ -67,6 +67,7 @@ public interface HighCouponCodeOtherMapper extends HighCouponCodeOtherMapperExt @Results({ @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), @Result(column="type", property="type", jdbcType=JdbcType.INTEGER), + @Result(column="discount_agent_code_id", property="discountAgentCodeId", jdbcType=JdbcType.BIGINT), @Result(column="coupon_agent_code_id", property="couponAgentCodeId", jdbcType=JdbcType.BIGINT), @Result(column="order_id", property="orderId", jdbcType=JdbcType.BIGINT), @Result(column="child_order_id", property="childOrderId", jdbcType=JdbcType.BIGINT), @@ -88,15 +89,16 @@ public interface HighCouponCodeOtherMapper extends HighCouponCodeOtherMapperExt @Select({ "select", - "id, `type`, coupon_agent_code_id, order_id, child_order_id, cou_type_code, cou_no, ", - "`status`, active_time, valid_start_date, valid_end_date, use_time, station_code, ", - "station_name, create_time, ext_1, ext_2, ext_3", + "id, `type`, discount_agent_code_id, coupon_agent_code_id, order_id, child_order_id, ", + "cou_type_code, cou_no, `status`, active_time, valid_start_date, valid_end_date, ", + "use_time, station_code, station_name, create_time, ext_1, ext_2, ext_3", "from high_coupon_code_other", "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="discount_agent_code_id", property="discountAgentCodeId", jdbcType=JdbcType.BIGINT), @Result(column="coupon_agent_code_id", property="couponAgentCodeId", jdbcType=JdbcType.BIGINT), @Result(column="order_id", property="orderId", jdbcType=JdbcType.BIGINT), @Result(column="child_order_id", property="childOrderId", jdbcType=JdbcType.BIGINT), @@ -128,6 +130,7 @@ public interface HighCouponCodeOtherMapper extends HighCouponCodeOtherMapperExt @Update({ "update high_coupon_code_other", "set `type` = #{type,jdbcType=INTEGER},", + "discount_agent_code_id = #{discountAgentCodeId,jdbcType=BIGINT},", "coupon_agent_code_id = #{couponAgentCodeId,jdbcType=BIGINT},", "order_id = #{orderId,jdbcType=BIGINT},", "child_order_id = #{childOrderId,jdbcType=BIGINT},", diff --git a/hai-service/src/main/java/com/hai/dao/HighCouponCodeOtherSqlProvider.java b/hai-service/src/main/java/com/hai/dao/HighCouponCodeOtherSqlProvider.java index e13ac9f3..8a5cf442 100644 --- a/hai-service/src/main/java/com/hai/dao/HighCouponCodeOtherSqlProvider.java +++ b/hai-service/src/main/java/com/hai/dao/HighCouponCodeOtherSqlProvider.java @@ -32,6 +32,10 @@ public class HighCouponCodeOtherSqlProvider { sql.VALUES("`type`", "#{type,jdbcType=INTEGER}"); } + if (record.getDiscountAgentCodeId() != null) { + sql.VALUES("discount_agent_code_id", "#{discountAgentCodeId,jdbcType=BIGINT}"); + } + if (record.getCouponAgentCodeId() != null) { sql.VALUES("coupon_agent_code_id", "#{couponAgentCodeId,jdbcType=BIGINT}"); } @@ -107,6 +111,7 @@ public class HighCouponCodeOtherSqlProvider { sql.SELECT("id"); } sql.SELECT("`type`"); + sql.SELECT("discount_agent_code_id"); sql.SELECT("coupon_agent_code_id"); sql.SELECT("order_id"); sql.SELECT("child_order_id"); @@ -148,6 +153,10 @@ public class HighCouponCodeOtherSqlProvider { sql.SET("`type` = #{record.type,jdbcType=INTEGER}"); } + if (record.getDiscountAgentCodeId() != null) { + sql.SET("discount_agent_code_id = #{record.discountAgentCodeId,jdbcType=BIGINT}"); + } + if (record.getCouponAgentCodeId() != null) { sql.SET("coupon_agent_code_id = #{record.couponAgentCodeId,jdbcType=BIGINT}"); } @@ -222,6 +231,7 @@ public class HighCouponCodeOtherSqlProvider { sql.SET("id = #{record.id,jdbcType=BIGINT}"); sql.SET("`type` = #{record.type,jdbcType=INTEGER}"); + sql.SET("discount_agent_code_id = #{record.discountAgentCodeId,jdbcType=BIGINT}"); sql.SET("coupon_agent_code_id = #{record.couponAgentCodeId,jdbcType=BIGINT}"); sql.SET("order_id = #{record.orderId,jdbcType=BIGINT}"); sql.SET("child_order_id = #{record.childOrderId,jdbcType=BIGINT}"); @@ -252,6 +262,10 @@ public class HighCouponCodeOtherSqlProvider { sql.SET("`type` = #{type,jdbcType=INTEGER}"); } + if (record.getDiscountAgentCodeId() != null) { + sql.SET("discount_agent_code_id = #{discountAgentCodeId,jdbcType=BIGINT}"); + } + if (record.getCouponAgentCodeId() != null) { sql.SET("coupon_agent_code_id = #{couponAgentCodeId,jdbcType=BIGINT}"); } diff --git a/hai-service/src/main/java/com/hai/entity/HighCouponCodeOther.java b/hai-service/src/main/java/com/hai/entity/HighCouponCodeOther.java index a00c99c5..457b735c 100644 --- a/hai-service/src/main/java/com/hai/entity/HighCouponCodeOther.java +++ b/hai-service/src/main/java/com/hai/entity/HighCouponCodeOther.java @@ -19,10 +19,15 @@ public class HighCouponCodeOther implements Serializable { private Long id; /** - * 类型: 1 贵州中石化 2 重庆中石油 + * 类型: 1 贵州中石化 2 重庆中石油 3 优惠券 */ private Integer type; + /** + * 代理商优惠券code + */ + private Long discountAgentCodeId; + /** * 代理商卡券销售码id */ @@ -112,6 +117,14 @@ public class HighCouponCodeOther implements Serializable { this.type = type; } + public Long getDiscountAgentCodeId() { + return discountAgentCodeId; + } + + public void setDiscountAgentCodeId(Long discountAgentCodeId) { + this.discountAgentCodeId = discountAgentCodeId; + } + public Long getCouponAgentCodeId() { return couponAgentCodeId; } @@ -254,6 +267,7 @@ public class HighCouponCodeOther implements Serializable { HighCouponCodeOther other = (HighCouponCodeOther) 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.getDiscountAgentCodeId() == null ? other.getDiscountAgentCodeId() == null : this.getDiscountAgentCodeId().equals(other.getDiscountAgentCodeId())) && (this.getCouponAgentCodeId() == null ? other.getCouponAgentCodeId() == null : this.getCouponAgentCodeId().equals(other.getCouponAgentCodeId())) && (this.getOrderId() == null ? other.getOrderId() == null : this.getOrderId().equals(other.getOrderId())) && (this.getChildOrderId() == null ? other.getChildOrderId() == null : this.getChildOrderId().equals(other.getChildOrderId())) @@ -278,6 +292,7 @@ public class HighCouponCodeOther implements Serializable { int result = 1; result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); result = prime * result + ((getType() == null) ? 0 : getType().hashCode()); + result = prime * result + ((getDiscountAgentCodeId() == null) ? 0 : getDiscountAgentCodeId().hashCode()); result = prime * result + ((getCouponAgentCodeId() == null) ? 0 : getCouponAgentCodeId().hashCode()); result = prime * result + ((getOrderId() == null) ? 0 : getOrderId().hashCode()); result = prime * result + ((getChildOrderId() == null) ? 0 : getChildOrderId().hashCode()); @@ -305,6 +320,7 @@ public class HighCouponCodeOther implements Serializable { sb.append("Hash = ").append(hashCode()); sb.append(", id=").append(id); sb.append(", type=").append(type); + sb.append(", discountAgentCodeId=").append(discountAgentCodeId); sb.append(", couponAgentCodeId=").append(couponAgentCodeId); sb.append(", orderId=").append(orderId); sb.append(", childOrderId=").append(childOrderId); diff --git a/hai-service/src/main/java/com/hai/entity/HighCouponCodeOtherExample.java b/hai-service/src/main/java/com/hai/entity/HighCouponCodeOtherExample.java index 27799024..e979a942 100644 --- a/hai-service/src/main/java/com/hai/entity/HighCouponCodeOtherExample.java +++ b/hai-service/src/main/java/com/hai/entity/HighCouponCodeOtherExample.java @@ -245,6 +245,66 @@ public class HighCouponCodeOtherExample { return (Criteria) this; } + public Criteria andDiscountAgentCodeIdIsNull() { + addCriterion("discount_agent_code_id is null"); + return (Criteria) this; + } + + public Criteria andDiscountAgentCodeIdIsNotNull() { + addCriterion("discount_agent_code_id is not null"); + return (Criteria) this; + } + + public Criteria andDiscountAgentCodeIdEqualTo(Long value) { + addCriterion("discount_agent_code_id =", value, "discountAgentCodeId"); + return (Criteria) this; + } + + public Criteria andDiscountAgentCodeIdNotEqualTo(Long value) { + addCriterion("discount_agent_code_id <>", value, "discountAgentCodeId"); + return (Criteria) this; + } + + public Criteria andDiscountAgentCodeIdGreaterThan(Long value) { + addCriterion("discount_agent_code_id >", value, "discountAgentCodeId"); + return (Criteria) this; + } + + public Criteria andDiscountAgentCodeIdGreaterThanOrEqualTo(Long value) { + addCriterion("discount_agent_code_id >=", value, "discountAgentCodeId"); + return (Criteria) this; + } + + public Criteria andDiscountAgentCodeIdLessThan(Long value) { + addCriterion("discount_agent_code_id <", value, "discountAgentCodeId"); + return (Criteria) this; + } + + public Criteria andDiscountAgentCodeIdLessThanOrEqualTo(Long value) { + addCriterion("discount_agent_code_id <=", value, "discountAgentCodeId"); + return (Criteria) this; + } + + public Criteria andDiscountAgentCodeIdIn(List values) { + addCriterion("discount_agent_code_id in", values, "discountAgentCodeId"); + return (Criteria) this; + } + + public Criteria andDiscountAgentCodeIdNotIn(List values) { + addCriterion("discount_agent_code_id not in", values, "discountAgentCodeId"); + return (Criteria) this; + } + + public Criteria andDiscountAgentCodeIdBetween(Long value1, Long value2) { + addCriterion("discount_agent_code_id between", value1, value2, "discountAgentCodeId"); + return (Criteria) this; + } + + public Criteria andDiscountAgentCodeIdNotBetween(Long value1, Long value2) { + addCriterion("discount_agent_code_id not between", value1, value2, "discountAgentCodeId"); + return (Criteria) this; + } + public Criteria andCouponAgentCodeIdIsNull() { addCriterion("coupon_agent_code_id is null"); return (Criteria) this; diff --git a/hai-service/src/main/java/com/hai/service/HighDiscountAgentCodeService.java b/hai-service/src/main/java/com/hai/service/HighDiscountAgentCodeService.java index b5e79ad0..7cc86947 100644 --- a/hai-service/src/main/java/com/hai/service/HighDiscountAgentCodeService.java +++ b/hai-service/src/main/java/com/hai/service/HighDiscountAgentCodeService.java @@ -94,4 +94,11 @@ public interface HighDiscountAgentCodeService { Integer getSalesDiscount(Long discountAgentId); List getDiscountAgentCodByLimit(Long discountAgentId , Long num); + + /** + * 优惠券前往使用 + * @param discountAgentCodeId + * @throws Exception + */ + void useDiscount(Long discountAgentCodeId) throws Exception; } diff --git a/hai-service/src/main/java/com/hai/service/HighDiscountUserRelService.java b/hai-service/src/main/java/com/hai/service/HighDiscountUserRelService.java index becdd024..a746f720 100644 --- a/hai-service/src/main/java/com/hai/service/HighDiscountUserRelService.java +++ b/hai-service/src/main/java/com/hai/service/HighDiscountUserRelService.java @@ -48,6 +48,13 @@ public interface HighDiscountUserRelService { **/ HighDiscountUserRel getRelByDiscount(Long discountId); + /** + * 根据代理商优惠券code查询 + * @param agentCodeId + * @return + */ + HighDiscountUserRel getRelByAgentCodeId(Long agentCodeId); + /** * @Author 胡锐 * @Description 根据id查询 diff --git a/hai-service/src/main/java/com/hai/service/impl/HighCouponCodeOtherServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighCouponCodeOtherServiceImpl.java index c7675a13..209d0b5f 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighCouponCodeOtherServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighCouponCodeOtherServiceImpl.java @@ -7,6 +7,8 @@ import com.hai.dao.HighCouponCodeOtherMapper; import com.hai.dao.HighUserCouponMapper; import com.hai.entity.*; import com.hai.service.HighCouponCodeOtherService; +import com.hai.service.HighDiscountAgentCodeService; +import com.hai.service.HighDiscountUserRelService; import com.hai.service.HighOrderService; import org.apache.commons.collections4.MapUtils; import org.springframework.stereotype.Service; @@ -31,6 +33,12 @@ public class HighCouponCodeOtherServiceImpl implements HighCouponCodeOtherServic @Resource private HighOrderService highOrderService; + @Resource + private HighDiscountAgentCodeService discountAgentCodeService; + + @Resource + private HighDiscountUserRelService discountUserRelService; + @Override public void update(HighCouponCodeOther couponCodeOther) { highCouponCodeOtherMapper.updateByPrimaryKey(couponCodeOther); @@ -102,11 +110,26 @@ public class HighCouponCodeOtherServiceImpl implements HighCouponCodeOtherServic if (couponCodeOther.getCouponAgentCodeId() != null) { HighCouponAgentCode agentCode = highCouponAgentCodeMapper.selectByPrimaryKey(couponCodeOther.getCouponAgentCodeId()); - if (agentCode == null) { + if (agentCode != null) { agentCode.setStatus(3); highCouponAgentCodeMapper.updateByPrimaryKey(agentCode); } } + + if (couponCodeOther.getDiscountAgentCodeId() != null) { + HighDiscountAgentCode discountAgentCode = discountAgentCodeService.getCodeById(couponCodeOther.getDiscountAgentCodeId()); + if (discountAgentCode != null) { + discountAgentCode.setStatus(3); + discountAgentCodeService.updateCode(discountAgentCode); + + HighDiscountUserRel discountUserRel = discountUserRelService.getRelByAgentCodeId(couponCodeOther.getDiscountAgentCodeId()); + if (discountUserRel != null) { + discountUserRel.setStatus(2); + discountUserRel.setUseTime(couponCodeOther.getUseTime()); + discountUserRelService.updateDiscountUserRel(discountUserRel); + } + } + } } } } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighDiscountAgentCodeServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighDiscountAgentCodeServiceImpl.java index 7c56120a..c4493210 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighDiscountAgentCodeServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighDiscountAgentCodeServiceImpl.java @@ -1,12 +1,23 @@ package com.hai.service.impl; +import com.alibaba.fastjson.JSONArray; +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.security.UserCenter; import com.hai.common.utils.DateUtil; +import com.hai.config.ChongQingCNPCService; import com.hai.dao.HighCouponCodeMapper; +import com.hai.dao.HighCouponCodeOtherMapper; import com.hai.dao.HighDiscountAgentCodeMapper; import com.hai.entity.*; +import com.hai.model.HighUserModel; import com.hai.service.*; import org.apache.commons.collections4.MapUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Isolation; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; @@ -14,6 +25,7 @@ import javax.annotation.Resource; import java.util.Date; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** * @Auther: 胡锐 @@ -47,6 +59,15 @@ public class HighDiscountAgentCodeServiceImpl implements HighDiscountAgentCodeSe @Resource private HighDiscountUserRelService highDiscountUserRelService; + @Resource + private HighCouponCodeOtherMapper highCouponCodeOtherMapper; + + @Resource + private HighDiscountCouponRelService highDiscountCouponRelService; + + @Resource + private UserCenter userCenter; + @Override public void insertCodeList(List discountAgentCodeList) { highDiscountAgentCodeMapper.insertListCode(discountAgentCodeList); @@ -158,4 +179,69 @@ public class HighDiscountAgentCodeServiceImpl implements HighDiscountAgentCodeSe public List getDiscountAgentCodByLimit(Long discountAgentId, Long num) { return highDiscountAgentCodeMapper.getDiscountAgentCodByLimit(discountAgentId,num); } + + @Override + @Transactional(rollbackFor=Exception.class,isolation = Isolation.SERIALIZABLE,propagation= Propagation.REQUIRES_NEW, timeout = 30) + public void useDiscount(Long discountAgentCodeId) throws Exception { + HighUserModel userModel = userCenter.getSessionModel(HighUserModel.class); + if (userModel == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.SEC_USER_EXPIRED, ""); + } + if (StringUtils.isBlank(userModel.getHighUser().getPhone())) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "客户未设置手机号"); + } + // 查询优惠券code + HighDiscountAgentCode discountAgentCode = getCodeById(discountAgentCodeId); + if (discountAgentCode == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "优惠券code错误"); + } + if (!discountAgentCode.getStatus().equals(2)) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "优惠券状态错误"); + } + if (StringUtils.isBlank(discountAgentCode.getExt2())) { + HighDiscountAgentRel rel = highDiscountAgentRelService.getRelById(discountAgentCode.getDiscountAgentId()); + if (rel == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到代理商关联关系"); + } + HighDiscount discount = highDiscountService.getDiscountById(rel.getDiscountId()); + if (discount == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到优惠券"); + } + List couponRelList = highDiscountCouponRelService.getRelByDiscount(discount.getId()); + if (couponRelList.size() == 0) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "优惠券未配置卡券"); + } + List couponList = couponRelList.stream().filter(o -> o.getHighCoupon().getCouponSource().equals(5)).collect(Collectors.toList()); + if (couponList.size() == 0) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "优惠券未配置重庆中石油卡券"); + } + String tradeId = discountAgentCode.getId()+""+System.currentTimeMillis()+""; + // 给用户发码 + JSONObject response = ChongQingCNPCService.sendCNPCTicket( + couponList.get(0).getHighCoupon().getCouponKey(), + tradeId, + 1, + userModel.getHighUser().getPhone()); + JSONObject couponDetail = response.getJSONObject("ticketDetail"); + JSONArray codeList = response.getJSONArray("codeList"); + + for (Object data : codeList) { + HighCouponCodeOther couponCodeOther = new HighCouponCodeOther(); + couponCodeOther.setType(3); + couponCodeOther.setDiscountAgentCodeId(discountAgentCode.getId()); + couponCodeOther.setCouTypeCode(couponDetail.getString("requestCode")); + couponCodeOther.setCouNo(ChongQingCNPCService.decryptCouponCode(String.valueOf(data))); + couponCodeOther.setActiveTime(new Date()); + couponCodeOther.setValidStartDate(DateUtil.format(couponDetail.getString("effectiveTime"), "yyyy-MM-dd")); + couponCodeOther.setValidEndDate(DateUtil.format(couponDetail.getString("expiredDate"), "yyyy-MM-dd")); + couponCodeOther.setStatus(20); + couponCodeOther.setCreateTime(new Date()); + highCouponCodeOtherMapper.insert(couponCodeOther); + } + + discountAgentCode.setExt2(tradeId); + updateCode(discountAgentCode); + } + } + } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighDiscountUserRelServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighDiscountUserRelServiceImpl.java index 822fa1b1..5f0c368b 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighDiscountUserRelServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighDiscountUserRelServiceImpl.java @@ -199,6 +199,17 @@ public class HighDiscountUserRelServiceImpl implements HighDiscountUserRelServic return null; } + @Override + public HighDiscountUserRel getRelByAgentCodeId(Long agentCodeId) { + HighDiscountUserRelExample example = new HighDiscountUserRelExample(); + example.createCriteria().andDiscountAgentCodeIdEqualTo(agentCodeId); + List list = highDiscountUserRelMapper.selectByExample(example); + if (list.size() > 0) { + return list.get(0); + } + return null; + } + @Override public HighDiscountUserRel getRelById(Long id) { HighDiscountUserRel rel = highDiscountUserRelMapper.selectByPrimaryKey(id); From 27f3e6992e970b1879b267865d088c9dbc993b03 Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Wed, 19 Oct 2022 09:26:17 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/cweb/config/AuthConfig.java | 1 + .../controller/HighUserCommonController.java | 21 +++++++++--- .../com/hai/common/utils/RequestUtils.java | 33 +++++++++++++++++++ 3 files changed, 51 insertions(+), 4 deletions(-) diff --git a/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java b/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java index 262691f1..01a1ca7b 100644 --- a/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java +++ b/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java @@ -114,6 +114,7 @@ public class AuthConfig implements WebMvcConfigurer { .excludePathPatterns("/user/login") .excludePathPatterns("/user/unionPhoneLogin") .excludePathPatterns("/user/getUnionId") + .excludePathPatterns("/user/ip") .excludePathPatterns("/highUser/setCacheParam") .excludePathPatterns("/highUser/getCacheParam") .excludePathPatterns("/highUser/delCacheParam") 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 e9ee316e..53098386 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighUserCommonController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighUserCommonController.java @@ -5,10 +5,7 @@ import com.hai.common.exception.ErrorCode; 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.common.utils.UnionUtils; +import com.hai.common.utils.*; import com.hai.config.UnionUserConfig; import com.hai.entity.HighUser; import com.hai.model.HighUserModel; @@ -182,6 +179,22 @@ public class HighUserCommonController { } } + + @RequestMapping(value = "/ip", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "退出登录") + public ResponseData ip(HttpServletRequest request, HttpServletResponse response) { + try { + // 113.205.199.32 + // ; + // return ResponseMsgUtil.success(RequestUtils.getRequestIp()); + return ResponseMsgUtil.success(HttpsUtils.doGet("https://api.map.baidu.com/location/ip?ak=X4sSdXsohVOMb1tNiLZloD9ows5FaNjq&ip=113.205.199.32&coor=gcj02")); + + } catch (Exception e) { + return ResponseMsgUtil.exception(e); + } + } + } diff --git a/hai-service/src/main/java/com/hai/common/utils/RequestUtils.java b/hai-service/src/main/java/com/hai/common/utils/RequestUtils.java index 7802084b..481606b7 100644 --- a/hai-service/src/main/java/com/hai/common/utils/RequestUtils.java +++ b/hai-service/src/main/java/com/hai/common/utils/RequestUtils.java @@ -1,4 +1,7 @@ package com.hai.common.utils; +import org.springframework.web.context.request.RequestAttributes; +import org.springframework.web.context.request.RequestContextHolder; + import javax.servlet.http.HttpServletRequest; public class RequestUtils { @@ -18,4 +21,34 @@ public class RequestUtils { return ip; } + + /** + * 获取请求的ip + */ + public static String getRequestIp() { + + RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes(); + + // 从获取RequestAttributes中获取HttpServletRequest的信息 + HttpServletRequest request = (HttpServletRequest) requestAttributes.resolveReference(RequestAttributes.REFERENCE_REQUEST); + + String ip = request.getHeader("x-forwarded-for"); + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("Proxy-Client-IP"); + } + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("WL-Proxy-Client-IP"); + } + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("HTTP_CLIENT_IP"); + } + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("HTTP_X_FORWARDED_FOR"); + } + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getRemoteAddr(); + } + + return ip; + } } From c751f35d9e60af9757489264b0353768526948a5 Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Wed, 19 Oct 2022 17:11:14 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/HighDiscountController.java | 1 + .../HighDiscountAgentCodeServiceImpl.java | 107 +++++++++++------- 2 files changed, 67 insertions(+), 41 deletions(-) diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighDiscountController.java b/hai-cweb/src/main/java/com/cweb/controller/HighDiscountController.java index 9236a4a3..94076ef6 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighDiscountController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighDiscountController.java @@ -175,6 +175,7 @@ public class HighDiscountController { try { highDiscountAgentCodeService.useDiscount(discountAgentCodeId); + return ResponseMsgUtil.success("操作成功"); } catch (DeadlockLoserDataAccessException deadlockLoserDataAccessException) { diff --git a/hai-service/src/main/java/com/hai/service/impl/HighDiscountAgentCodeServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighDiscountAgentCodeServiceImpl.java index c4493210..86dc8316 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighDiscountAgentCodeServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighDiscountAgentCodeServiceImpl.java @@ -16,6 +16,7 @@ import com.hai.model.HighUserModel; import com.hai.service.*; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; +import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Isolation; import org.springframework.transaction.annotation.Propagation; @@ -68,6 +69,9 @@ public class HighDiscountAgentCodeServiceImpl implements HighDiscountAgentCodeSe @Resource private UserCenter userCenter; + @Resource + private RedisTemplate redisTemplate; + @Override public void insertCodeList(List discountAgentCodeList) { highDiscountAgentCodeMapper.insertListCode(discountAgentCodeList); @@ -181,7 +185,7 @@ public class HighDiscountAgentCodeServiceImpl implements HighDiscountAgentCodeSe } @Override - @Transactional(rollbackFor=Exception.class,isolation = Isolation.SERIALIZABLE,propagation= Propagation.REQUIRES_NEW, timeout = 30) + @Transactional(rollbackFor=Exception.class,propagation= Propagation.REQUIRES_NEW, timeout = 30) public void useDiscount(Long discountAgentCodeId) throws Exception { HighUserModel userModel = userCenter.getSessionModel(HighUserModel.class); if (userModel == null) { @@ -198,49 +202,70 @@ public class HighDiscountAgentCodeServiceImpl implements HighDiscountAgentCodeSe if (!discountAgentCode.getStatus().equals(2)) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "优惠券状态错误"); } - if (StringUtils.isBlank(discountAgentCode.getExt2())) { - HighDiscountAgentRel rel = highDiscountAgentRelService.getRelById(discountAgentCode.getDiscountAgentId()); - if (rel == null) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到代理商关联关系"); - } - HighDiscount discount = highDiscountService.getDiscountById(rel.getDiscountId()); - if (discount == null) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到优惠券"); - } - List couponRelList = highDiscountCouponRelService.getRelByDiscount(discount.getId()); - if (couponRelList.size() == 0) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "优惠券未配置卡券"); + HighDiscountUserRel discountUserRel = highDiscountUserRelService.getRelByAgentCodeId(discountAgentCodeId); + if (discountUserRel != null) { + if (!userModel.getHighUser().getId().equals(discountUserRel.getUserId())) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法使用,领取人和使用人不一致。"); } - List couponList = couponRelList.stream().filter(o -> o.getHighCoupon().getCouponSource().equals(5)).collect(Collectors.toList()); - if (couponList.size() == 0) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "优惠券未配置重庆中石油卡券"); - } - String tradeId = discountAgentCode.getId()+""+System.currentTimeMillis()+""; - // 给用户发码 - JSONObject response = ChongQingCNPCService.sendCNPCTicket( - couponList.get(0).getHighCoupon().getCouponKey(), - tradeId, - 1, - userModel.getHighUser().getPhone()); - JSONObject couponDetail = response.getJSONObject("ticketDetail"); - JSONArray codeList = response.getJSONArray("codeList"); - - for (Object data : codeList) { - HighCouponCodeOther couponCodeOther = new HighCouponCodeOther(); - couponCodeOther.setType(3); - couponCodeOther.setDiscountAgentCodeId(discountAgentCode.getId()); - couponCodeOther.setCouTypeCode(couponDetail.getString("requestCode")); - couponCodeOther.setCouNo(ChongQingCNPCService.decryptCouponCode(String.valueOf(data))); - couponCodeOther.setActiveTime(new Date()); - couponCodeOther.setValidStartDate(DateUtil.format(couponDetail.getString("effectiveTime"), "yyyy-MM-dd")); - couponCodeOther.setValidEndDate(DateUtil.format(couponDetail.getString("expiredDate"), "yyyy-MM-dd")); - couponCodeOther.setStatus(20); - couponCodeOther.setCreateTime(new Date()); - highCouponCodeOtherMapper.insert(couponCodeOther); + } + String key = "DiscountAgentId_" + discountAgentCode.getDiscountAgentId(); + try { + // 分布式锁占坑 + Boolean lock = redisTemplate.opsForValue().setIfAbsent(key, discountAgentCode.getId()); + if(lock) { + if (StringUtils.isBlank(discountAgentCode.getExt2())) { + HighDiscountAgentRel rel = highDiscountAgentRelService.getRelById(discountAgentCode.getDiscountAgentId()); + if (rel == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到代理商关联关系"); + } + HighDiscount discount = highDiscountService.getDiscountById(rel.getDiscountId()); + if (discount == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到优惠券"); + } + List couponRelList = highDiscountCouponRelService.getRelByDiscount(discount.getId()); + if (couponRelList.size() == 0) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "优惠券未配置卡券"); + } + List couponList = couponRelList.stream().filter(o -> o.getHighCoupon().getCouponSource().equals(5)).collect(Collectors.toList()); + if (couponList.size() == 0) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "优惠券未配置重庆中石油卡券"); + } + String tradeId = discountAgentCode.getId()+""+System.currentTimeMillis()+""; + // 给用户发码 + JSONObject response = ChongQingCNPCService.sendCNPCTicket( + couponList.get(0).getHighCoupon().getCouponKey(), + tradeId, + 1, + userModel.getHighUser().getPhone()); + JSONObject couponDetail = response.getJSONObject("ticketDetail"); + JSONArray codeList = response.getJSONArray("codeList"); + + for (Object data : codeList) { + HighCouponCodeOther couponCodeOther = new HighCouponCodeOther(); + couponCodeOther.setType(3); + couponCodeOther.setDiscountAgentCodeId(discountAgentCode.getId()); + couponCodeOther.setCouTypeCode(couponDetail.getString("requestCode")); + couponCodeOther.setCouNo(ChongQingCNPCService.decryptCouponCode(String.valueOf(data))); + couponCodeOther.setActiveTime(new Date()); + couponCodeOther.setValidStartDate(DateUtil.format(couponDetail.getString("effectiveTime"), "yyyy-MM-dd")); + couponCodeOther.setValidEndDate(DateUtil.format(couponDetail.getString("expiredDate"), "yyyy-MM-dd")); + couponCodeOther.setStatus(20); + couponCodeOther.setCreateTime(new Date()); + highCouponCodeOtherMapper.insert(couponCodeOther); + } + discountAgentCode.setExt2(tradeId); + updateCode(discountAgentCode); + } + } else { + // 加锁失败,重试 + Thread.sleep(100); + useDiscount(discountAgentCodeId); } + } catch (Exception e) { - discountAgentCode.setExt2(tradeId); - updateCode(discountAgentCode); + } finally { + // 删除key,释放锁 + redisTemplate.delete(key); } } From d3f57a533bb4f3355347afdd0abd0c458638c764 Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Mon, 24 Oct 2022 11:34:34 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 6 +- .../com/bweb/controller/LoginController.java | 2 +- .../bweb/controller/SecRoleController.java | 2 +- .../controller/HighGasOrderController.java | 75 ++ hai-order/pom.xml | 2 +- .../com/web/controller/OrderController.java | 1 + .../web/controller/OrderPayController.java | 68 +- .../src/main/resources/dev/application.yml | 10 +- .../hai/common/security/SessionObject.java | 2 +- .../java/com/hai/common/utils/BaiduUtils.java | 30 + .../com/hai/common/utils/RequestUtils.java | 36 +- .../java/com/hai/config/MessageConfig.java | 64 + .../com/hai/dao/HighChildOrderMapper.java | 49 +- .../hai/dao/HighChildOrderSqlProvider.java | 14 + .../java/com/hai/dao/HighOrderMapper.java | 30 +- .../com/hai/dao/HighOrderSqlProvider.java | 44 +- .../com/hai/dao/HighUserLoginLogMapper.java | 128 ++ .../hai/dao/HighUserLoginLogMapperExt.java | 7 + .../hai/dao/HighUserLoginLogSqlProvider.java | 346 ++++++ .../java/com/hai/entity/HighChildOrder.java | 16 + .../com/hai/entity/HighChildOrderExample.java | 60 + .../main/java/com/hai/entity/HighOrder.java | 52 +- .../java/com/hai/entity/HighOrderExample.java | 168 ++- .../java/com/hai/entity/HighUserLoginLog.java | 257 ++++ .../hai/entity/HighUserLoginLogExample.java | 1093 +++++++++++++++++ .../java/com/hai/enum_type/LoginPlatform.java | 53 + .../com/hai/enum_type/RedisFileFolder.java | 53 + .../main/java/com/hai/model/UserModel.java | 34 +- .../impl/OrderCreateHandleServiceImpl.java | 5 +- .../impl/OrderPaySuccessServiceImpl.java | 2 +- .../order/service/impl/OrderServiceImpl.java | 23 +- .../java/com/hai/order/utils/OrderUtil.java | 11 +- .../com/hai/service/HighOrderService.java | 2 +- .../java/com/hai/service/HighUserService.java | 11 + .../service/impl/HighOrderServiceImpl.java | 6 +- .../service/impl/HighQzOrderServiceImpl.java | 2 +- .../hai/service/impl/HighUserServiceImpl.java | 73 ++ hai-user/pom.xml | 61 + .../src/main/java/com/UserApplication.java | 30 + .../main/java/com/web/config/AuthConfig.java | 85 ++ .../java/com/web/config/ConfigListener.java | 23 + .../main/java/com/web/config/CorsConfig.java | 49 + .../java/com/web/config/MultipartConfig.java | 26 + .../main/java/com/web/config/RedisConfig.java | 110 ++ .../com/web/config/SentinelFilterConfig.java | 23 + .../java/com/web/config/SwaggerConfig.java | 47 + .../main/java/com/web/config/SysConfig.java | 21 + .../main/java/com/web/config/SysConst.java | 19 + .../com/web/config/WxMaConfiguration.java | 31 + .../com/web/controller/CoresController.java | 75 ++ .../com/web/controller/LoginController.java | 1 + .../com/web/controller/SmsController.java | 1 + .../com/web/controller/TestController.java | 1 + .../src/main/java/com/web/type/LoginType.java | 51 + .../src/main/resources/dev/application.yml | 102 ++ .../src/main/resources/dev/config.properties | 27 + hai-user/src/main/resources/dev/logback.xml | 93 ++ pom.xml | 1 + 58 files changed, 3583 insertions(+), 131 deletions(-) create mode 100644 hai-cweb/src/main/java/com/cweb/controller/HighGasOrderController.java create mode 100644 hai-service/src/main/java/com/hai/common/utils/BaiduUtils.java create mode 100644 hai-service/src/main/java/com/hai/dao/HighUserLoginLogMapper.java create mode 100644 hai-service/src/main/java/com/hai/dao/HighUserLoginLogMapperExt.java create mode 100644 hai-service/src/main/java/com/hai/dao/HighUserLoginLogSqlProvider.java create mode 100644 hai-service/src/main/java/com/hai/entity/HighUserLoginLog.java create mode 100644 hai-service/src/main/java/com/hai/entity/HighUserLoginLogExample.java create mode 100644 hai-service/src/main/java/com/hai/enum_type/LoginPlatform.java create mode 100644 hai-service/src/main/java/com/hai/enum_type/RedisFileFolder.java create mode 100644 hai-user/pom.xml create mode 100644 hai-user/src/main/java/com/UserApplication.java create mode 100644 hai-user/src/main/java/com/web/config/AuthConfig.java create mode 100644 hai-user/src/main/java/com/web/config/ConfigListener.java create mode 100644 hai-user/src/main/java/com/web/config/CorsConfig.java create mode 100644 hai-user/src/main/java/com/web/config/MultipartConfig.java create mode 100644 hai-user/src/main/java/com/web/config/RedisConfig.java create mode 100644 hai-user/src/main/java/com/web/config/SentinelFilterConfig.java create mode 100644 hai-user/src/main/java/com/web/config/SwaggerConfig.java create mode 100644 hai-user/src/main/java/com/web/config/SysConfig.java create mode 100644 hai-user/src/main/java/com/web/config/SysConst.java create mode 100644 hai-user/src/main/java/com/web/config/WxMaConfiguration.java create mode 100644 hai-user/src/main/java/com/web/controller/CoresController.java create mode 100644 hai-user/src/main/java/com/web/controller/LoginController.java create mode 100644 hai-user/src/main/java/com/web/controller/SmsController.java create mode 100644 hai-user/src/main/java/com/web/controller/TestController.java create mode 100644 hai-user/src/main/java/com/web/type/LoginType.java create mode 100644 hai-user/src/main/resources/dev/application.yml create mode 100644 hai-user/src/main/resources/dev/config.properties create mode 100644 hai-user/src/main/resources/dev/logback.xml diff --git a/.gitignore b/.gitignore index b445f7b7..228c8faf 100644 --- a/.gitignore +++ b/.gitignore @@ -30,7 +30,11 @@ hai-schedule/hai-schedule.iml v1/target/* v1/log/* -v1/hai-schedule.iml +v1/v1.iml + +hai-user/target/* +hai-user/log/* +hai-user/hai-user.iml diff --git a/hai-bweb/src/main/java/com/bweb/controller/LoginController.java b/hai-bweb/src/main/java/com/bweb/controller/LoginController.java index af6de63d..818069c6 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/LoginController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/LoginController.java @@ -239,7 +239,7 @@ public class LoginController { String aesStr = AESEncodeUtil.aesEncrypt(secUser.getId().toString()); userInfoModel.setToken(aesStr); SessionObject so = new SessionObject(aesStr, secUser.getObjectType(), userInfoModel); - userCenter.save(request, response, so); + userCenter.save(null,null,so); return ResponseMsgUtil.success(so); } catch (Exception e) { log.error("login error!",e); diff --git a/hai-bweb/src/main/java/com/bweb/controller/SecRoleController.java b/hai-bweb/src/main/java/com/bweb/controller/SecRoleController.java index f702ad37..f5c8df0e 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/SecRoleController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/SecRoleController.java @@ -293,7 +293,7 @@ public class SecRoleController { userInfoModel.setPermissionList(permissionList); SessionObject so = new SessionObject(secUser.getId()+"", 3, userInfoModel); - userCenter.save(request, response, so); + userCenter.save(null,null,so); return ResponseMsgUtil.success(so); } catch (Exception e) { log.error("SecRoleController --> refreshRole() error!", e); diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighGasOrderController.java b/hai-cweb/src/main/java/com/cweb/controller/HighGasOrderController.java new file mode 100644 index 00000000..955cec94 --- /dev/null +++ b/hai-cweb/src/main/java/com/cweb/controller/HighGasOrderController.java @@ -0,0 +1,75 @@ +package com.cweb.controller; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.github.pagehelper.PageInfo; +import com.hai.common.exception.ErrorCode; +import com.hai.common.exception.ErrorHelp; +import com.hai.common.exception.SysCode; +import com.hai.common.utils.CoordCommonUtil; +import com.hai.common.utils.PageUtil; +import com.hai.common.utils.ResponseMsgUtil; +import com.hai.config.CommonSysConst; +import com.hai.config.TuanYouConfig; +import com.hai.dao.HighGasOrderPushMapper; +import com.hai.entity.*; +import com.hai.enum_type.GasOilPriceStatusEnum; +import com.hai.enum_type.MerchantStoreSourceType; +import com.hai.model.HighMerchantStoreModel; +import com.hai.model.ResponseData; +import com.hai.service.*; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.collections4.MapUtils; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.util.*; +import java.util.stream.Collectors; + +@Controller +@RequestMapping(value = "/gasOrder") +@Api(value = "加油订单") +public class HighGasOrderController { + + private static Logger log = LoggerFactory.getLogger(HighGasOrderController.class); + + @Resource + private HighGasOrderService gasOrderService; + + @RequestMapping(value="/getOrderByOrderNo",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "根据订单号查询") + public ResponseData getOrderByOrderNo(@RequestParam(name = "orderNo", required = true) String orderNo) { + try { + + return ResponseMsgUtil.success(gasOrderService.getDetailByOrderNo(orderNo)); + + } catch (Exception e) { + log.error("HighGasOrderController -> getOrderByOrderNo() error!",e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value="/getOrderByChildOrderNo",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "根据子订单号查询") + public ResponseData getOrderByChildOrderNo(@RequestParam(name = "childOrderNo", required = true) String childOrderNo) { + try { + + return ResponseMsgUtil.success(gasOrderService.getDetailByChildOrderNo(childOrderNo)); + + } catch (Exception e) { + log.error("HighGasOrderController -> getOrderByChildOrderNo() error!",e); + return ResponseMsgUtil.exception(e); + } + } + + +} diff --git a/hai-order/pom.xml b/hai-order/pom.xml index 037d3ef1..961f53bb 100644 --- a/hai-order/pom.xml +++ b/hai-order/pom.xml @@ -9,7 +9,7 @@ 4.0.0 - com.hgj + com.hsg hai-order diff --git a/hai-order/src/main/java/com/web/controller/OrderController.java b/hai-order/src/main/java/com/web/controller/OrderController.java index dfe5243b..96d0b179 100644 --- a/hai-order/src/main/java/com/web/controller/OrderController.java +++ b/hai-order/src/main/java/com/web/controller/OrderController.java @@ -218,6 +218,7 @@ public class OrderController { } Map param = new HashMap<>(); + param.put("userId", userModel.getHighUser().getId()); param.put("title", title); param.put("searchTitle", searchTitle); param.put("orderNo", orderNo); diff --git a/hai-order/src/main/java/com/web/controller/OrderPayController.java b/hai-order/src/main/java/com/web/controller/OrderPayController.java index d772f522..4de25d6c 100644 --- a/hai-order/src/main/java/com/web/controller/OrderPayController.java +++ b/hai-order/src/main/java/com/web/controller/OrderPayController.java @@ -17,6 +17,7 @@ import com.hai.entity.*; import com.hai.enum_type.GasChannel; import com.hai.enum_type.GasChannelPayPlatformType; import com.hai.enum_type.MerchantStoreSourceType; +import com.hai.enum_type.UserCardType; import com.hai.model.HighMerchantStoreModel; import com.hai.model.HighUserModel; import com.hai.model.ResponseData; @@ -100,7 +101,6 @@ public class OrderPayController { if (body == null || StringUtils.isBlank(body.getString("orderNo")) // || body.getInteger("openIdType") == null - || StringUtils.isBlank(body.getString("orderScene")) || StringUtils.isBlank(body.getString("openId")) ) { log.error("wxPay error!", "参数错误"); @@ -218,7 +218,7 @@ public class OrderPayController { weChatPayReqInfo.setSpbill_create_ip("122.9.135.148"); // 终端ip weChatPayReqInfo.setNotify_url(SysConst.getSysConfig().getWxPayNotifyUrl()); // 通知url weChatPayReqInfo.setTrade_type("JSAPI"); // 交易类型 - weChatPayReqInfo.setAttach(body.getString("orderScene")); // 附件参数 + weChatPayReqInfo.setAttach(null); // 附件参数 weChatPayReqInfo.setProfit_sharing(profitSharing); // 是否分账 Y:是 N:否 //附加数据,区分订单类型 @@ -240,6 +240,70 @@ public class OrderPayController { } } + @RequestMapping(value="/cardPay",method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "卡支付") + public ResponseData cardPay(@RequestBody JSONObject body) { + try { + if (body == null + || StringUtils.isBlank(body.getString("orderNo")) + || StringUtils.isBlank(body.getString("cardNo")) + || StringUtils.isBlank(body.getString("password"))) { + log.error("oilCardPay error!", "参数错误"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + + // 获取当前操作人信息 + HighUserModel userInfoModel = userCenter.getSessionModel(HighUserModel.class); + if (userInfoModel == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.SEC_USER_EXPIRED, ""); + } + String password = body.getString("password"); + + // 查询用户与卡号的关系 + HighUserCard userCard = userCardService.getDetailByUserCardNo(userInfoModel.getHighUser().getId(), body.getString("cardNo")); + if (userCard == null) { + log.error("OrderController --> cardPay() ERROR", "未绑定卡号"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未绑定卡号"); + } + // 查询用户支付密码 + HighUserPayPassword userPayPassword = userPayPasswordService.getDetailByUser(userInfoModel.getHighUser().getId()); + if (userPayPassword == null) { + log.error("cardPay error!", "未设置支付密码"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_SET_USER_PAY_PWD, ""); + } + if (StringUtils.isBlank(password)) { + log.error("cardPay error!", "未输入支付密码"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_ENTER_USER_PAY_PWD, ""); + } + // 支付密码是否正确 + if (!AESEncodeUtil.aesEncrypt(password).equals(userPayPassword.getPassword())) { + log.error("cardPay error!", ""); + throw ErrorHelp.genException(SysCode.System, ErrorCode.USER_PAY_PWD_ERROR, ""); + } + // 查询订单 + HighOrder order = orderService.getOrderDetailByNo(body.getString("orderNo")); + if(!order.getOrderStatus().equals(OrderStatus.STATUS1.getNumber())) { + log.error("OrderController --> cardPay() ERROR", "订单不处于待支付状态"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.ORDER_NO_STAY_PAY, ""); + } + + if (userCard.getType().equals(UserCardType.type1.getType())) { + return ResponseMsgUtil.success(orderPayService.hltCardPay(order, userCard)); + + } else if (userCard.getType().equals(UserCardType.type2.getType())) { + return ResponseMsgUtil.success(orderPayService.oilCardPay(order, userCard)); + + } else { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的卡号类型"); + } + + } catch (Exception e) { + log.error("OrderPayController -> cardPay() error!",e); + return ResponseMsgUtil.exception(e); + } + } + @RequestMapping(value="/oilCardPay",method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "嗨森逛油卡支付") diff --git a/hai-order/src/main/resources/dev/application.yml b/hai-order/src/main/resources/dev/application.yml index d683fefb..780fa8c5 100644 --- a/hai-order/src/main/resources/dev/application.yml +++ b/hai-order/src/main/resources/dev/application.yml @@ -53,16 +53,18 @@ spring: #MQTT默认的消息推送主题,实际可在调用接口是指定 # default: # topic: topic + + #配置日期返回至前台为时间戳 + jackson: + serialization: + write-dates-as-timestamps: true + rocketmq: name-server: 139.159.177.244:9876 producer: #必须指定group group: default-group - #配置日期返回至前台为时间戳 - jackson: - serialization: - write-dates-as-timestamps: true mybatis: mapperLocations: - classpath*:sqlmap*/*.xml diff --git a/hai-service/src/main/java/com/hai/common/security/SessionObject.java b/hai-service/src/main/java/com/hai/common/security/SessionObject.java index 215d5ff3..bb00e055 100644 --- a/hai-service/src/main/java/com/hai/common/security/SessionObject.java +++ b/hai-service/src/main/java/com/hai/common/security/SessionObject.java @@ -10,7 +10,7 @@ public class SessionObject { private String uniqueCode; /** - * 1:会员;2:渠道;3.管理员 + * 1: 用户 2:管理 */ private Integer type; diff --git a/hai-service/src/main/java/com/hai/common/utils/BaiduUtils.java b/hai-service/src/main/java/com/hai/common/utils/BaiduUtils.java new file mode 100644 index 00000000..7f8d8fb0 --- /dev/null +++ b/hai-service/src/main/java/com/hai/common/utils/BaiduUtils.java @@ -0,0 +1,30 @@ +package com.hai.common.utils; + +import com.alibaba.fastjson.JSONObject; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * 百度工具 + * @className: BaiduUtis + * @author: HuRui + * @date: 2022/10/21 + **/ +public class BaiduUtils { + + private static Logger log = LoggerFactory.getLogger(BaiduUtils.class); + + /** + * IP 定位 + * @param ip ip地址 + * @return + */ + public static JSONObject ipLocation(String ip) { + JSONObject response = HttpsUtils.doGet("https://api.map.baidu.com/location/ip?ak=X4sSdXsohVOMb1tNiLZloD9ows5FaNjq&ip=" + ip); + log.info(response.toJSONString()); + return response; + } + + +} diff --git a/hai-service/src/main/java/com/hai/common/utils/RequestUtils.java b/hai-service/src/main/java/com/hai/common/utils/RequestUtils.java index 481606b7..d4d735e6 100644 --- a/hai-service/src/main/java/com/hai/common/utils/RequestUtils.java +++ b/hai-service/src/main/java/com/hai/common/utils/RequestUtils.java @@ -7,16 +7,32 @@ import javax.servlet.http.HttpServletRequest; public class RequestUtils { public static String getIpAddress(HttpServletRequest request) { - // 获取请求主机IP地址,如果通过代理进来,则透过防火墙获取真实IP地址 - String ip = request.getHeader("x-forwarded-for"); - if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { - ip = request.getHeader("Proxy-Client-IP"); - } - if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { - ip = request.getHeader("WL-Proxy-Client-IP"); - } - if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { - ip = request.getRemoteAddr(); + String ip = request.getHeader("X-Forwarded-For"); + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("Proxy-Client-IP"); + } + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("WL-Proxy-Client-IP"); + } + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("HTTP_CLIENT_IP"); + } + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("HTTP_X_FORWARDED_FOR"); + } + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getRemoteAddr(); + } + } else if (ip.length() > 15) { + String[] ips = ip.split(","); + for (int index = 0; index < ips.length; index++) { + String strIp = ips[index]; + if (!("unknown".equalsIgnoreCase(strIp))) { + ip = strIp; + break; + } + } } return ip; } diff --git a/hai-service/src/main/java/com/hai/config/MessageConfig.java b/hai-service/src/main/java/com/hai/config/MessageConfig.java index 96504c84..af33df68 100644 --- a/hai-service/src/main/java/com/hai/config/MessageConfig.java +++ b/hai-service/src/main/java/com/hai/config/MessageConfig.java @@ -1,5 +1,6 @@ package com.hai.config; +import com.alibaba.fastjson.JSONObject; import com.fasterxml.jackson.databind.ObjectMapper; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; @@ -56,9 +57,72 @@ public class MessageConfig { */ private static final HostnameVerifier DO_NOT_VERIFY = (hostname, session) -> true; + private static final String reqUrl = "https://139.9.32.119:18312/common/sms/sendTemplateMessage"; + private static final String account = "760887"; + private static final String password = "Z.o'&mO%7_?5M,Br"; + @Resource private RedisUtil redisUtil; + public static void req(String phone,String smsCode, String HWMSG) throws Exception { + HttpsURLConnection connection; + InputStream is = null; + BufferedReader br = null; + try { + // ip:port根据实际情况填写 + Map templateParas = new HashMap<>(); + templateParas.put("code", smsCode); + + trustAllHttpsCertificates(); + + URL realUrl = new URL(reqUrl); + connection = (HttpsURLConnection) realUrl.openConnection(); + connection.setHostnameVerifier(DO_NOT_VERIFY); + connection.setDoInput(true); // 设置可输入 + connection.setDoOutput(true); // 设置该连接是可以输出的 + connection.setRequestMethod("POST"); // 设置请求方式 + connection.setRequestProperty("Content-Type", "application/json;charset=UTF-8"); + + // 如果请求正文不包含签名名称,则设置签名为空 + Map body = buildRequestBody(phone, HWMSG, templateParas, account, password); + if (null == body || body.isEmpty()) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "参数校验失败"); + } + ObjectMapper objectMapper = new ObjectMapper(); + PrintWriter pw = new PrintWriter(new OutputStreamWriter(connection.getOutputStream(), "UTF-8")); + pw.write(objectMapper.writeValueAsString(body)); + pw.flush(); + pw.close(); + + int status = connection.getResponseCode(); + if (200 == status) { // 200 + is = connection.getInputStream(); + } else { // 400/401 + is = connection.getErrorStream(); + } + br = new BufferedReader(new InputStreamReader(is, "UTF-8")); + String line = null; + StringBuilder result = new StringBuilder(); + while ((line = br.readLine()) != null) { // 读取数据 + result.append(line + ""); + } + JSONObject resultObject = JSONObject.parseObject(result.toString()); + if (result == null + || resultObject.getJSONArray("resultLists") == null + || resultObject.getJSONArray("resultLists").size() == 0) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "短信发送失败,请稍后重试"); + } + System.out.println(result.toString()); + connection.disconnect(); + + } catch (Exception e) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "短信发送失败,请稍后重试"); + } finally { + is.close(); + br.close(); + } + } + /** * @Author Sum1Dream * @name sendSmsCodeHw.java diff --git a/hai-service/src/main/java/com/hai/dao/HighChildOrderMapper.java b/hai-service/src/main/java/com/hai/dao/HighChildOrderMapper.java index 098cd199..741667e4 100644 --- a/hai-service/src/main/java/com/hai/dao/HighChildOrderMapper.java +++ b/hai-service/src/main/java/com/hai/dao/HighChildOrderMapper.java @@ -48,15 +48,16 @@ public interface HighChildOrderMapper extends HighChildOrderMapperExt { "goods_img, goods_spec_name, ", "goods_price, goods_actual_price, ", "total_price, total_actual_price, ", - "sale_count, surplus_refund_num, ", - "surplus_refund_price, surplus_refund_integral, ", - "channel_order_no, giveaway_type, ", - "child_order_status, praise_status, ", - "create_time, pay_time, ", - "finish_time, refund_time, ", - "refund_remarks, cancel_time, ", - "ext_1, ext_2, ext_3, ", - "ext_4, ext_5, ext_6)", + "total_deduction_price, sale_count, ", + "surplus_refund_num, surplus_refund_price, ", + "surplus_refund_integral, channel_order_no, ", + "giveaway_type, child_order_status, ", + "praise_status, create_time, ", + "pay_time, finish_time, ", + "refund_time, refund_remarks, ", + "cancel_time, ext_1, ", + "ext_2, ext_3, ext_4, ", + "ext_5, ext_6)", "values (#{orderId,jdbcType=BIGINT}, #{orderNo,jdbcType=VARCHAR}, ", "#{memId,jdbcType=BIGINT}, #{memName,jdbcType=VARCHAR}, #{memPhone,jdbcType=VARCHAR}, ", "#{childOrderNo,jdbcType=VARCHAR}, #{storeId,jdbcType=BIGINT}, ", @@ -66,15 +67,16 @@ public interface HighChildOrderMapper extends HighChildOrderMapperExt { "#{goodsImg,jdbcType=VARCHAR}, #{goodsSpecName,jdbcType=VARCHAR}, ", "#{goodsPrice,jdbcType=DECIMAL}, #{goodsActualPrice,jdbcType=DECIMAL}, ", "#{totalPrice,jdbcType=DECIMAL}, #{totalActualPrice,jdbcType=DECIMAL}, ", - "#{saleCount,jdbcType=INTEGER}, #{surplusRefundNum,jdbcType=INTEGER}, ", - "#{surplusRefundPrice,jdbcType=DECIMAL}, #{surplusRefundIntegral,jdbcType=INTEGER}, ", - "#{channelOrderNo,jdbcType=VARCHAR}, #{giveawayType,jdbcType=BIT}, ", - "#{childOrderStatus,jdbcType=INTEGER}, #{praiseStatus,jdbcType=INTEGER}, ", - "#{createTime,jdbcType=TIMESTAMP}, #{payTime,jdbcType=TIMESTAMP}, ", - "#{finishTime,jdbcType=TIMESTAMP}, #{refundTime,jdbcType=TIMESTAMP}, ", - "#{refundRemarks,jdbcType=VARCHAR}, #{cancelTime,jdbcType=TIMESTAMP}, ", - "#{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR}, ", - "#{ext4,jdbcType=VARCHAR}, #{ext5,jdbcType=VARCHAR}, #{ext6,jdbcType=VARCHAR})" + "#{totalDeductionPrice,jdbcType=DECIMAL}, #{saleCount,jdbcType=INTEGER}, ", + "#{surplusRefundNum,jdbcType=INTEGER}, #{surplusRefundPrice,jdbcType=DECIMAL}, ", + "#{surplusRefundIntegral,jdbcType=INTEGER}, #{channelOrderNo,jdbcType=VARCHAR}, ", + "#{giveawayType,jdbcType=BIT}, #{childOrderStatus,jdbcType=INTEGER}, ", + "#{praiseStatus,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, ", + "#{payTime,jdbcType=TIMESTAMP}, #{finishTime,jdbcType=TIMESTAMP}, ", + "#{refundTime,jdbcType=TIMESTAMP}, #{refundRemarks,jdbcType=VARCHAR}, ", + "#{cancelTime,jdbcType=TIMESTAMP}, #{ext1,jdbcType=VARCHAR}, ", + "#{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR}, #{ext4,jdbcType=VARCHAR}, ", + "#{ext5,jdbcType=VARCHAR}, #{ext6,jdbcType=VARCHAR})" }) @Options(useGeneratedKeys=true,keyProperty="id") int insert(HighChildOrder record); @@ -105,6 +107,7 @@ public interface HighChildOrderMapper extends HighChildOrderMapperExt { @Result(column="goods_actual_price", property="goodsActualPrice", jdbcType=JdbcType.DECIMAL), @Result(column="total_price", property="totalPrice", jdbcType=JdbcType.DECIMAL), @Result(column="total_actual_price", property="totalActualPrice", jdbcType=JdbcType.DECIMAL), + @Result(column="total_deduction_price", property="totalDeductionPrice", jdbcType=JdbcType.DECIMAL), @Result(column="sale_count", property="saleCount", jdbcType=JdbcType.INTEGER), @Result(column="surplus_refund_num", property="surplusRefundNum", jdbcType=JdbcType.INTEGER), @Result(column="surplus_refund_price", property="surplusRefundPrice", jdbcType=JdbcType.DECIMAL), @@ -133,10 +136,10 @@ public interface HighChildOrderMapper extends HighChildOrderMapperExt { "id, order_id, order_no, mem_id, mem_name, mem_phone, child_order_no, store_id, ", "store_name, store_address, goods_type, goods_id, goods_name, goods_desc, goods_img, ", "goods_spec_name, goods_price, goods_actual_price, total_price, total_actual_price, ", - "sale_count, surplus_refund_num, surplus_refund_price, surplus_refund_integral, ", - "channel_order_no, giveaway_type, child_order_status, praise_status, create_time, ", - "pay_time, finish_time, refund_time, refund_remarks, cancel_time, ext_1, ext_2, ", - "ext_3, ext_4, ext_5, ext_6", + "total_deduction_price, sale_count, surplus_refund_num, surplus_refund_price, ", + "surplus_refund_integral, channel_order_no, giveaway_type, child_order_status, ", + "praise_status, create_time, pay_time, finish_time, refund_time, refund_remarks, ", + "cancel_time, ext_1, ext_2, ext_3, ext_4, ext_5, ext_6", "from high_child_order", "where id = #{id,jdbcType=BIGINT}" }) @@ -161,6 +164,7 @@ public interface HighChildOrderMapper extends HighChildOrderMapperExt { @Result(column="goods_actual_price", property="goodsActualPrice", jdbcType=JdbcType.DECIMAL), @Result(column="total_price", property="totalPrice", jdbcType=JdbcType.DECIMAL), @Result(column="total_actual_price", property="totalActualPrice", jdbcType=JdbcType.DECIMAL), + @Result(column="total_deduction_price", property="totalDeductionPrice", jdbcType=JdbcType.DECIMAL), @Result(column="sale_count", property="saleCount", jdbcType=JdbcType.INTEGER), @Result(column="surplus_refund_num", property="surplusRefundNum", jdbcType=JdbcType.INTEGER), @Result(column="surplus_refund_price", property="surplusRefundPrice", jdbcType=JdbcType.DECIMAL), @@ -214,6 +218,7 @@ public interface HighChildOrderMapper extends HighChildOrderMapperExt { "goods_actual_price = #{goodsActualPrice,jdbcType=DECIMAL},", "total_price = #{totalPrice,jdbcType=DECIMAL},", "total_actual_price = #{totalActualPrice,jdbcType=DECIMAL},", + "total_deduction_price = #{totalDeductionPrice,jdbcType=DECIMAL},", "sale_count = #{saleCount,jdbcType=INTEGER},", "surplus_refund_num = #{surplusRefundNum,jdbcType=INTEGER},", "surplus_refund_price = #{surplusRefundPrice,jdbcType=DECIMAL},", diff --git a/hai-service/src/main/java/com/hai/dao/HighChildOrderSqlProvider.java b/hai-service/src/main/java/com/hai/dao/HighChildOrderSqlProvider.java index 92cbd951..8fd46ba2 100644 --- a/hai-service/src/main/java/com/hai/dao/HighChildOrderSqlProvider.java +++ b/hai-service/src/main/java/com/hai/dao/HighChildOrderSqlProvider.java @@ -104,6 +104,10 @@ public class HighChildOrderSqlProvider { sql.VALUES("total_actual_price", "#{totalActualPrice,jdbcType=DECIMAL}"); } + if (record.getTotalDeductionPrice() != null) { + sql.VALUES("total_deduction_price", "#{totalDeductionPrice,jdbcType=DECIMAL}"); + } + if (record.getSaleCount() != null) { sql.VALUES("sale_count", "#{saleCount,jdbcType=INTEGER}"); } @@ -213,6 +217,7 @@ public class HighChildOrderSqlProvider { sql.SELECT("goods_actual_price"); sql.SELECT("total_price"); sql.SELECT("total_actual_price"); + sql.SELECT("total_deduction_price"); sql.SELECT("sale_count"); sql.SELECT("surplus_refund_num"); sql.SELECT("surplus_refund_price"); @@ -330,6 +335,10 @@ public class HighChildOrderSqlProvider { sql.SET("total_actual_price = #{record.totalActualPrice,jdbcType=DECIMAL}"); } + if (record.getTotalDeductionPrice() != null) { + sql.SET("total_deduction_price = #{record.totalDeductionPrice,jdbcType=DECIMAL}"); + } + if (record.getSaleCount() != null) { sql.SET("sale_count = #{record.saleCount,jdbcType=INTEGER}"); } @@ -438,6 +447,7 @@ public class HighChildOrderSqlProvider { sql.SET("goods_actual_price = #{record.goodsActualPrice,jdbcType=DECIMAL}"); sql.SET("total_price = #{record.totalPrice,jdbcType=DECIMAL}"); sql.SET("total_actual_price = #{record.totalActualPrice,jdbcType=DECIMAL}"); + sql.SET("total_deduction_price = #{record.totalDeductionPrice,jdbcType=DECIMAL}"); sql.SET("sale_count = #{record.saleCount,jdbcType=INTEGER}"); sql.SET("surplus_refund_num = #{record.surplusRefundNum,jdbcType=INTEGER}"); sql.SET("surplus_refund_price = #{record.surplusRefundPrice,jdbcType=DECIMAL}"); @@ -544,6 +554,10 @@ public class HighChildOrderSqlProvider { sql.SET("total_actual_price = #{totalActualPrice,jdbcType=DECIMAL}"); } + if (record.getTotalDeductionPrice() != null) { + sql.SET("total_deduction_price = #{totalDeductionPrice,jdbcType=DECIMAL}"); + } + if (record.getSaleCount() != null) { sql.SET("sale_count = #{saleCount,jdbcType=INTEGER}"); } diff --git a/hai-service/src/main/java/com/hai/dao/HighOrderMapper.java b/hai-service/src/main/java/com/hai/dao/HighOrderMapper.java index 3297c3e9..250fee57 100644 --- a/hai-service/src/main/java/com/hai/dao/HighOrderMapper.java +++ b/hai-service/src/main/java/com/hai/dao/HighOrderMapper.java @@ -47,7 +47,8 @@ public interface HighOrderMapper extends HighOrderMapperExt { "order_no, pay_serial_no, ", "pay_type, mem_card_id, ", "mem_card_type, mem_card_no, ", - "total_price, deduction_price, ", + "total_price, total_deduction_price, ", + "deduction_coupon_price, deduction_product_price, ", "pay_gold, payable_price, ", "pay_price, pay_real_price, ", "order_status, remarks, ", @@ -69,7 +70,8 @@ public interface HighOrderMapper extends HighOrderMapperExt { "#{orderNo,jdbcType=VARCHAR}, #{paySerialNo,jdbcType=VARCHAR}, ", "#{payType,jdbcType=INTEGER}, #{memCardId,jdbcType=BIGINT}, ", "#{memCardType,jdbcType=INTEGER}, #{memCardNo,jdbcType=VARCHAR}, ", - "#{totalPrice,jdbcType=DECIMAL}, #{deductionPrice,jdbcType=DECIMAL}, ", + "#{totalPrice,jdbcType=DECIMAL}, #{totalDeductionPrice,jdbcType=DECIMAL}, ", + "#{deductionCouponPrice,jdbcType=DECIMAL}, #{deductionProductPrice,jdbcType=DECIMAL}, ", "#{payGold,jdbcType=INTEGER}, #{payablePrice,jdbcType=DECIMAL}, ", "#{payPrice,jdbcType=DECIMAL}, #{payRealPrice,jdbcType=DECIMAL}, ", "#{orderStatus,jdbcType=INTEGER}, #{remarks,jdbcType=VARCHAR}, ", @@ -112,7 +114,9 @@ public interface HighOrderMapper extends HighOrderMapperExt { @Result(column="mem_card_type", property="memCardType", jdbcType=JdbcType.INTEGER), @Result(column="mem_card_no", property="memCardNo", jdbcType=JdbcType.VARCHAR), @Result(column="total_price", property="totalPrice", jdbcType=JdbcType.DECIMAL), - @Result(column="deduction_price", property="deductionPrice", jdbcType=JdbcType.DECIMAL), + @Result(column="total_deduction_price", property="totalDeductionPrice", jdbcType=JdbcType.DECIMAL), + @Result(column="deduction_coupon_price", property="deductionCouponPrice", jdbcType=JdbcType.DECIMAL), + @Result(column="deduction_product_price", property="deductionProductPrice", jdbcType=JdbcType.DECIMAL), @Result(column="pay_gold", property="payGold", jdbcType=JdbcType.INTEGER), @Result(column="payable_price", property="payablePrice", jdbcType=JdbcType.DECIMAL), @Result(column="pay_price", property="payPrice", jdbcType=JdbcType.DECIMAL), @@ -147,12 +151,12 @@ public interface HighOrderMapper extends HighOrderMapperExt { "select", "id, title, search_title, product_type, company_id, company_name, promote_code, ", "mem_discount_id, mem_discount_name, mem_id, mem_name, mem_phone, order_no, pay_serial_no, ", - "pay_type, mem_card_id, mem_card_type, mem_card_no, total_price, deduction_price, ", - "pay_gold, payable_price, pay_price, pay_real_price, order_status, remarks, create_time, ", - "surplus_refund_price, surplus_refund_integral, pay_time, finish_time, cancel_time, ", - "cancel_remarks, refund_time, account_merchant_num, profit_sharing_status, profit_sharing_record_id, ", - "whether_check, whether_rebate, exception_status, exception_content, ext_1, ext_2, ", - "ext_3, ext_4, ext_5, ext_6", + "pay_type, mem_card_id, mem_card_type, mem_card_no, total_price, total_deduction_price, ", + "deduction_coupon_price, deduction_product_price, pay_gold, payable_price, pay_price, ", + "pay_real_price, order_status, remarks, create_time, surplus_refund_price, surplus_refund_integral, ", + "pay_time, finish_time, cancel_time, cancel_remarks, refund_time, account_merchant_num, ", + "profit_sharing_status, profit_sharing_record_id, whether_check, whether_rebate, ", + "exception_status, exception_content, ext_1, ext_2, ext_3, ext_4, ext_5, ext_6", "from high_order", "where id = #{id,jdbcType=BIGINT}" }) @@ -176,7 +180,9 @@ public interface HighOrderMapper extends HighOrderMapperExt { @Result(column="mem_card_type", property="memCardType", jdbcType=JdbcType.INTEGER), @Result(column="mem_card_no", property="memCardNo", jdbcType=JdbcType.VARCHAR), @Result(column="total_price", property="totalPrice", jdbcType=JdbcType.DECIMAL), - @Result(column="deduction_price", property="deductionPrice", jdbcType=JdbcType.DECIMAL), + @Result(column="total_deduction_price", property="totalDeductionPrice", jdbcType=JdbcType.DECIMAL), + @Result(column="deduction_coupon_price", property="deductionCouponPrice", jdbcType=JdbcType.DECIMAL), + @Result(column="deduction_product_price", property="deductionProductPrice", jdbcType=JdbcType.DECIMAL), @Result(column="pay_gold", property="payGold", jdbcType=JdbcType.INTEGER), @Result(column="payable_price", property="payablePrice", jdbcType=JdbcType.DECIMAL), @Result(column="pay_price", property="payPrice", jdbcType=JdbcType.DECIMAL), @@ -236,7 +242,9 @@ public interface HighOrderMapper extends HighOrderMapperExt { "mem_card_type = #{memCardType,jdbcType=INTEGER},", "mem_card_no = #{memCardNo,jdbcType=VARCHAR},", "total_price = #{totalPrice,jdbcType=DECIMAL},", - "deduction_price = #{deductionPrice,jdbcType=DECIMAL},", + "total_deduction_price = #{totalDeductionPrice,jdbcType=DECIMAL},", + "deduction_coupon_price = #{deductionCouponPrice,jdbcType=DECIMAL},", + "deduction_product_price = #{deductionProductPrice,jdbcType=DECIMAL},", "pay_gold = #{payGold,jdbcType=INTEGER},", "payable_price = #{payablePrice,jdbcType=DECIMAL},", "pay_price = #{payPrice,jdbcType=DECIMAL},", diff --git a/hai-service/src/main/java/com/hai/dao/HighOrderSqlProvider.java b/hai-service/src/main/java/com/hai/dao/HighOrderSqlProvider.java index edd1212f..0d2295b9 100644 --- a/hai-service/src/main/java/com/hai/dao/HighOrderSqlProvider.java +++ b/hai-service/src/main/java/com/hai/dao/HighOrderSqlProvider.java @@ -100,8 +100,16 @@ public class HighOrderSqlProvider { sql.VALUES("total_price", "#{totalPrice,jdbcType=DECIMAL}"); } - if (record.getDeductionPrice() != null) { - sql.VALUES("deduction_price", "#{deductionPrice,jdbcType=DECIMAL}"); + if (record.getTotalDeductionPrice() != null) { + sql.VALUES("total_deduction_price", "#{totalDeductionPrice,jdbcType=DECIMAL}"); + } + + if (record.getDeductionCouponPrice() != null) { + sql.VALUES("deduction_coupon_price", "#{deductionCouponPrice,jdbcType=DECIMAL}"); + } + + if (record.getDeductionProductPrice() != null) { + sql.VALUES("deduction_product_price", "#{deductionProductPrice,jdbcType=DECIMAL}"); } if (record.getPayGold() != null) { @@ -240,7 +248,9 @@ public class HighOrderSqlProvider { sql.SELECT("mem_card_type"); sql.SELECT("mem_card_no"); sql.SELECT("total_price"); - sql.SELECT("deduction_price"); + sql.SELECT("total_deduction_price"); + sql.SELECT("deduction_coupon_price"); + sql.SELECT("deduction_product_price"); sql.SELECT("pay_gold"); sql.SELECT("payable_price"); sql.SELECT("pay_price"); @@ -361,8 +371,16 @@ public class HighOrderSqlProvider { sql.SET("total_price = #{record.totalPrice,jdbcType=DECIMAL}"); } - if (record.getDeductionPrice() != null) { - sql.SET("deduction_price = #{record.deductionPrice,jdbcType=DECIMAL}"); + if (record.getTotalDeductionPrice() != null) { + sql.SET("total_deduction_price = #{record.totalDeductionPrice,jdbcType=DECIMAL}"); + } + + if (record.getDeductionCouponPrice() != null) { + sql.SET("deduction_coupon_price = #{record.deductionCouponPrice,jdbcType=DECIMAL}"); + } + + if (record.getDeductionProductPrice() != null) { + sql.SET("deduction_product_price = #{record.deductionProductPrice,jdbcType=DECIMAL}"); } if (record.getPayGold() != null) { @@ -500,7 +518,9 @@ public class HighOrderSqlProvider { sql.SET("mem_card_type = #{record.memCardType,jdbcType=INTEGER}"); sql.SET("mem_card_no = #{record.memCardNo,jdbcType=VARCHAR}"); sql.SET("total_price = #{record.totalPrice,jdbcType=DECIMAL}"); - sql.SET("deduction_price = #{record.deductionPrice,jdbcType=DECIMAL}"); + sql.SET("total_deduction_price = #{record.totalDeductionPrice,jdbcType=DECIMAL}"); + sql.SET("deduction_coupon_price = #{record.deductionCouponPrice,jdbcType=DECIMAL}"); + sql.SET("deduction_product_price = #{record.deductionProductPrice,jdbcType=DECIMAL}"); sql.SET("pay_gold = #{record.payGold,jdbcType=INTEGER}"); sql.SET("payable_price = #{record.payablePrice,jdbcType=DECIMAL}"); sql.SET("pay_price = #{record.payPrice,jdbcType=DECIMAL}"); @@ -610,8 +630,16 @@ public class HighOrderSqlProvider { sql.SET("total_price = #{totalPrice,jdbcType=DECIMAL}"); } - if (record.getDeductionPrice() != null) { - sql.SET("deduction_price = #{deductionPrice,jdbcType=DECIMAL}"); + if (record.getTotalDeductionPrice() != null) { + sql.SET("total_deduction_price = #{totalDeductionPrice,jdbcType=DECIMAL}"); + } + + if (record.getDeductionCouponPrice() != null) { + sql.SET("deduction_coupon_price = #{deductionCouponPrice,jdbcType=DECIMAL}"); + } + + if (record.getDeductionProductPrice() != null) { + sql.SET("deduction_product_price = #{deductionProductPrice,jdbcType=DECIMAL}"); } if (record.getPayGold() != null) { diff --git a/hai-service/src/main/java/com/hai/dao/HighUserLoginLogMapper.java b/hai-service/src/main/java/com/hai/dao/HighUserLoginLogMapper.java new file mode 100644 index 00000000..52696ad7 --- /dev/null +++ b/hai-service/src/main/java/com/hai/dao/HighUserLoginLogMapper.java @@ -0,0 +1,128 @@ +package com.hai.dao; + +import com.hai.entity.HighUserLoginLog; +import com.hai.entity.HighUserLoginLogExample; +import java.util.List; +import org.apache.ibatis.annotations.Delete; +import org.apache.ibatis.annotations.DeleteProvider; +import org.apache.ibatis.annotations.Insert; +import org.apache.ibatis.annotations.InsertProvider; +import org.apache.ibatis.annotations.Options; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Result; +import org.apache.ibatis.annotations.Results; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.annotations.SelectProvider; +import org.apache.ibatis.annotations.Update; +import org.apache.ibatis.annotations.UpdateProvider; +import org.apache.ibatis.type.JdbcType; +import org.springframework.stereotype.Repository; + +/** + * + * 代码由工具生成,请勿修改!!! + * 如果需要扩展请在其父类进行扩展 + * + **/ +@Repository +public interface HighUserLoginLogMapper extends HighUserLoginLogMapperExt { + @SelectProvider(type=HighUserLoginLogSqlProvider.class, method="countByExample") + long countByExample(HighUserLoginLogExample example); + + @DeleteProvider(type=HighUserLoginLogSqlProvider.class, method="deleteByExample") + int deleteByExample(HighUserLoginLogExample example); + + @Delete({ + "delete from high_user_login_log", + "where id = #{id,jdbcType=BIGINT}" + }) + int deleteByPrimaryKey(Long id); + + @Insert({ + "insert into high_user_login_log (user_id, user_phone, ", + "platform, ip, province_name, ", + "city_code, city_name, ", + "`status`, create_time, ", + "ext_1, ext_2, ext_3)", + "values (#{userId,jdbcType=BIGINT}, #{userPhone,jdbcType=VARCHAR}, ", + "#{platform,jdbcType=VARCHAR}, #{ip,jdbcType=VARCHAR}, #{provinceName,jdbcType=VARCHAR}, ", + "#{cityCode,jdbcType=VARCHAR}, #{cityName,jdbcType=VARCHAR}, ", + "#{status,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, ", + "#{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" + }) + @Options(useGeneratedKeys=true,keyProperty="id") + int insert(HighUserLoginLog record); + + @InsertProvider(type=HighUserLoginLogSqlProvider.class, method="insertSelective") + @Options(useGeneratedKeys=true,keyProperty="id") + int insertSelective(HighUserLoginLog record); + + @SelectProvider(type=HighUserLoginLogSqlProvider.class, method="selectByExample") + @Results({ + @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), + @Result(column="user_id", property="userId", jdbcType=JdbcType.BIGINT), + @Result(column="user_phone", property="userPhone", jdbcType=JdbcType.VARCHAR), + @Result(column="platform", property="platform", jdbcType=JdbcType.VARCHAR), + @Result(column="ip", property="ip", jdbcType=JdbcType.VARCHAR), + @Result(column="province_name", property="provinceName", jdbcType=JdbcType.VARCHAR), + @Result(column="city_code", property="cityCode", jdbcType=JdbcType.VARCHAR), + @Result(column="city_name", property="cityName", jdbcType=JdbcType.VARCHAR), + @Result(column="status", property="status", jdbcType=JdbcType.INTEGER), + @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), + @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) + }) + List selectByExample(HighUserLoginLogExample example); + + @Select({ + "select", + "id, user_id, user_phone, platform, ip, province_name, city_code, city_name, ", + "`status`, create_time, ext_1, ext_2, ext_3", + "from high_user_login_log", + "where id = #{id,jdbcType=BIGINT}" + }) + @Results({ + @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), + @Result(column="user_id", property="userId", jdbcType=JdbcType.BIGINT), + @Result(column="user_phone", property="userPhone", jdbcType=JdbcType.VARCHAR), + @Result(column="platform", property="platform", jdbcType=JdbcType.VARCHAR), + @Result(column="ip", property="ip", jdbcType=JdbcType.VARCHAR), + @Result(column="province_name", property="provinceName", jdbcType=JdbcType.VARCHAR), + @Result(column="city_code", property="cityCode", jdbcType=JdbcType.VARCHAR), + @Result(column="city_name", property="cityName", jdbcType=JdbcType.VARCHAR), + @Result(column="status", property="status", jdbcType=JdbcType.INTEGER), + @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), + @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) + }) + HighUserLoginLog selectByPrimaryKey(Long id); + + @UpdateProvider(type=HighUserLoginLogSqlProvider.class, method="updateByExampleSelective") + int updateByExampleSelective(@Param("record") HighUserLoginLog record, @Param("example") HighUserLoginLogExample example); + + @UpdateProvider(type=HighUserLoginLogSqlProvider.class, method="updateByExample") + int updateByExample(@Param("record") HighUserLoginLog record, @Param("example") HighUserLoginLogExample example); + + @UpdateProvider(type=HighUserLoginLogSqlProvider.class, method="updateByPrimaryKeySelective") + int updateByPrimaryKeySelective(HighUserLoginLog record); + + @Update({ + "update high_user_login_log", + "set user_id = #{userId,jdbcType=BIGINT},", + "user_phone = #{userPhone,jdbcType=VARCHAR},", + "platform = #{platform,jdbcType=VARCHAR},", + "ip = #{ip,jdbcType=VARCHAR},", + "province_name = #{provinceName,jdbcType=VARCHAR},", + "city_code = #{cityCode,jdbcType=VARCHAR},", + "city_name = #{cityName,jdbcType=VARCHAR},", + "`status` = #{status,jdbcType=INTEGER},", + "create_time = #{createTime,jdbcType=TIMESTAMP},", + "ext_1 = #{ext1,jdbcType=VARCHAR},", + "ext_2 = #{ext2,jdbcType=VARCHAR},", + "ext_3 = #{ext3,jdbcType=VARCHAR}", + "where id = #{id,jdbcType=BIGINT}" + }) + int updateByPrimaryKey(HighUserLoginLog record); +} \ No newline at end of file diff --git a/hai-service/src/main/java/com/hai/dao/HighUserLoginLogMapperExt.java b/hai-service/src/main/java/com/hai/dao/HighUserLoginLogMapperExt.java new file mode 100644 index 00000000..2a0e63cf --- /dev/null +++ b/hai-service/src/main/java/com/hai/dao/HighUserLoginLogMapperExt.java @@ -0,0 +1,7 @@ +package com.hai.dao; + +/** + * mapper扩展类 + */ +public interface HighUserLoginLogMapperExt { +} \ No newline at end of file diff --git a/hai-service/src/main/java/com/hai/dao/HighUserLoginLogSqlProvider.java b/hai-service/src/main/java/com/hai/dao/HighUserLoginLogSqlProvider.java new file mode 100644 index 00000000..e9c8f1f1 --- /dev/null +++ b/hai-service/src/main/java/com/hai/dao/HighUserLoginLogSqlProvider.java @@ -0,0 +1,346 @@ +package com.hai.dao; + +import com.hai.entity.HighUserLoginLog; +import com.hai.entity.HighUserLoginLogExample.Criteria; +import com.hai.entity.HighUserLoginLogExample.Criterion; +import com.hai.entity.HighUserLoginLogExample; +import java.util.List; +import java.util.Map; +import org.apache.ibatis.jdbc.SQL; + +public class HighUserLoginLogSqlProvider { + + public String countByExample(HighUserLoginLogExample example) { + SQL sql = new SQL(); + sql.SELECT("count(*)").FROM("high_user_login_log"); + applyWhere(sql, example, false); + return sql.toString(); + } + + public String deleteByExample(HighUserLoginLogExample example) { + SQL sql = new SQL(); + sql.DELETE_FROM("high_user_login_log"); + applyWhere(sql, example, false); + return sql.toString(); + } + + public String insertSelective(HighUserLoginLog record) { + SQL sql = new SQL(); + sql.INSERT_INTO("high_user_login_log"); + + if (record.getUserId() != null) { + sql.VALUES("user_id", "#{userId,jdbcType=BIGINT}"); + } + + if (record.getUserPhone() != null) { + sql.VALUES("user_phone", "#{userPhone,jdbcType=VARCHAR}"); + } + + if (record.getPlatform() != null) { + sql.VALUES("platform", "#{platform,jdbcType=VARCHAR}"); + } + + if (record.getIp() != null) { + sql.VALUES("ip", "#{ip,jdbcType=VARCHAR}"); + } + + if (record.getProvinceName() != null) { + sql.VALUES("province_name", "#{provinceName,jdbcType=VARCHAR}"); + } + + if (record.getCityCode() != null) { + sql.VALUES("city_code", "#{cityCode,jdbcType=VARCHAR}"); + } + + if (record.getCityName() != null) { + sql.VALUES("city_name", "#{cityName,jdbcType=VARCHAR}"); + } + + if (record.getStatus() != null) { + sql.VALUES("`status`", "#{status,jdbcType=INTEGER}"); + } + + if (record.getCreateTime() != null) { + sql.VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}"); + } + + if (record.getExt1() != null) { + sql.VALUES("ext_1", "#{ext1,jdbcType=VARCHAR}"); + } + + if (record.getExt2() != null) { + sql.VALUES("ext_2", "#{ext2,jdbcType=VARCHAR}"); + } + + if (record.getExt3() != null) { + sql.VALUES("ext_3", "#{ext3,jdbcType=VARCHAR}"); + } + + return sql.toString(); + } + + public String selectByExample(HighUserLoginLogExample example) { + SQL sql = new SQL(); + if (example != null && example.isDistinct()) { + sql.SELECT_DISTINCT("id"); + } else { + sql.SELECT("id"); + } + sql.SELECT("user_id"); + sql.SELECT("user_phone"); + sql.SELECT("platform"); + sql.SELECT("ip"); + sql.SELECT("province_name"); + sql.SELECT("city_code"); + sql.SELECT("city_name"); + sql.SELECT("`status`"); + sql.SELECT("create_time"); + sql.SELECT("ext_1"); + sql.SELECT("ext_2"); + sql.SELECT("ext_3"); + sql.FROM("high_user_login_log"); + applyWhere(sql, example, false); + + if (example != null && example.getOrderByClause() != null) { + sql.ORDER_BY(example.getOrderByClause()); + } + + return sql.toString(); + } + + public String updateByExampleSelective(Map parameter) { + HighUserLoginLog record = (HighUserLoginLog) parameter.get("record"); + HighUserLoginLogExample example = (HighUserLoginLogExample) parameter.get("example"); + + SQL sql = new SQL(); + sql.UPDATE("high_user_login_log"); + + if (record.getId() != null) { + sql.SET("id = #{record.id,jdbcType=BIGINT}"); + } + + if (record.getUserId() != null) { + sql.SET("user_id = #{record.userId,jdbcType=BIGINT}"); + } + + if (record.getUserPhone() != null) { + sql.SET("user_phone = #{record.userPhone,jdbcType=VARCHAR}"); + } + + if (record.getPlatform() != null) { + sql.SET("platform = #{record.platform,jdbcType=VARCHAR}"); + } + + if (record.getIp() != null) { + sql.SET("ip = #{record.ip,jdbcType=VARCHAR}"); + } + + if (record.getProvinceName() != null) { + sql.SET("province_name = #{record.provinceName,jdbcType=VARCHAR}"); + } + + if (record.getCityCode() != null) { + sql.SET("city_code = #{record.cityCode,jdbcType=VARCHAR}"); + } + + if (record.getCityName() != null) { + sql.SET("city_name = #{record.cityName,jdbcType=VARCHAR}"); + } + + if (record.getStatus() != null) { + sql.SET("`status` = #{record.status,jdbcType=INTEGER}"); + } + + if (record.getCreateTime() != null) { + sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}"); + } + + if (record.getExt1() != null) { + sql.SET("ext_1 = #{record.ext1,jdbcType=VARCHAR}"); + } + + if (record.getExt2() != null) { + sql.SET("ext_2 = #{record.ext2,jdbcType=VARCHAR}"); + } + + if (record.getExt3() != null) { + sql.SET("ext_3 = #{record.ext3,jdbcType=VARCHAR}"); + } + + applyWhere(sql, example, true); + return sql.toString(); + } + + public String updateByExample(Map parameter) { + SQL sql = new SQL(); + sql.UPDATE("high_user_login_log"); + + sql.SET("id = #{record.id,jdbcType=BIGINT}"); + sql.SET("user_id = #{record.userId,jdbcType=BIGINT}"); + sql.SET("user_phone = #{record.userPhone,jdbcType=VARCHAR}"); + sql.SET("platform = #{record.platform,jdbcType=VARCHAR}"); + sql.SET("ip = #{record.ip,jdbcType=VARCHAR}"); + sql.SET("province_name = #{record.provinceName,jdbcType=VARCHAR}"); + sql.SET("city_code = #{record.cityCode,jdbcType=VARCHAR}"); + sql.SET("city_name = #{record.cityName,jdbcType=VARCHAR}"); + sql.SET("`status` = #{record.status,jdbcType=INTEGER}"); + sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}"); + sql.SET("ext_1 = #{record.ext1,jdbcType=VARCHAR}"); + sql.SET("ext_2 = #{record.ext2,jdbcType=VARCHAR}"); + sql.SET("ext_3 = #{record.ext3,jdbcType=VARCHAR}"); + + HighUserLoginLogExample example = (HighUserLoginLogExample) parameter.get("example"); + applyWhere(sql, example, true); + return sql.toString(); + } + + public String updateByPrimaryKeySelective(HighUserLoginLog record) { + SQL sql = new SQL(); + sql.UPDATE("high_user_login_log"); + + if (record.getUserId() != null) { + sql.SET("user_id = #{userId,jdbcType=BIGINT}"); + } + + if (record.getUserPhone() != null) { + sql.SET("user_phone = #{userPhone,jdbcType=VARCHAR}"); + } + + if (record.getPlatform() != null) { + sql.SET("platform = #{platform,jdbcType=VARCHAR}"); + } + + if (record.getIp() != null) { + sql.SET("ip = #{ip,jdbcType=VARCHAR}"); + } + + if (record.getProvinceName() != null) { + sql.SET("province_name = #{provinceName,jdbcType=VARCHAR}"); + } + + if (record.getCityCode() != null) { + sql.SET("city_code = #{cityCode,jdbcType=VARCHAR}"); + } + + if (record.getCityName() != null) { + sql.SET("city_name = #{cityName,jdbcType=VARCHAR}"); + } + + if (record.getStatus() != null) { + sql.SET("`status` = #{status,jdbcType=INTEGER}"); + } + + if (record.getCreateTime() != null) { + sql.SET("create_time = #{createTime,jdbcType=TIMESTAMP}"); + } + + if (record.getExt1() != null) { + sql.SET("ext_1 = #{ext1,jdbcType=VARCHAR}"); + } + + if (record.getExt2() != null) { + sql.SET("ext_2 = #{ext2,jdbcType=VARCHAR}"); + } + + if (record.getExt3() != null) { + sql.SET("ext_3 = #{ext3,jdbcType=VARCHAR}"); + } + + sql.WHERE("id = #{id,jdbcType=BIGINT}"); + + return sql.toString(); + } + + protected void applyWhere(SQL sql, HighUserLoginLogExample example, boolean includeExamplePhrase) { + if (example == null) { + return; + } + + String parmPhrase1; + String parmPhrase1_th; + String parmPhrase2; + String parmPhrase2_th; + String parmPhrase3; + String parmPhrase3_th; + if (includeExamplePhrase) { + parmPhrase1 = "%s #{example.oredCriteria[%d].allCriteria[%d].value}"; + parmPhrase1_th = "%s #{example.oredCriteria[%d].allCriteria[%d].value,typeHandler=%s}"; + parmPhrase2 = "%s #{example.oredCriteria[%d].allCriteria[%d].value} and #{example.oredCriteria[%d].criteria[%d].secondValue}"; + parmPhrase2_th = "%s #{example.oredCriteria[%d].allCriteria[%d].value,typeHandler=%s} and #{example.oredCriteria[%d].criteria[%d].secondValue,typeHandler=%s}"; + parmPhrase3 = "#{example.oredCriteria[%d].allCriteria[%d].value[%d]}"; + parmPhrase3_th = "#{example.oredCriteria[%d].allCriteria[%d].value[%d],typeHandler=%s}"; + } else { + parmPhrase1 = "%s #{oredCriteria[%d].allCriteria[%d].value}"; + parmPhrase1_th = "%s #{oredCriteria[%d].allCriteria[%d].value,typeHandler=%s}"; + parmPhrase2 = "%s #{oredCriteria[%d].allCriteria[%d].value} and #{oredCriteria[%d].criteria[%d].secondValue}"; + parmPhrase2_th = "%s #{oredCriteria[%d].allCriteria[%d].value,typeHandler=%s} and #{oredCriteria[%d].criteria[%d].secondValue,typeHandler=%s}"; + parmPhrase3 = "#{oredCriteria[%d].allCriteria[%d].value[%d]}"; + parmPhrase3_th = "#{oredCriteria[%d].allCriteria[%d].value[%d],typeHandler=%s}"; + } + + StringBuilder sb = new StringBuilder(); + List oredCriteria = example.getOredCriteria(); + boolean firstCriteria = true; + for (int i = 0; i < oredCriteria.size(); i++) { + Criteria criteria = oredCriteria.get(i); + if (criteria.isValid()) { + if (firstCriteria) { + firstCriteria = false; + } else { + sb.append(" or "); + } + + sb.append('('); + List criterions = criteria.getAllCriteria(); + boolean firstCriterion = true; + for (int j = 0; j < criterions.size(); j++) { + Criterion criterion = criterions.get(j); + if (firstCriterion) { + firstCriterion = false; + } else { + sb.append(" and "); + } + + if (criterion.isNoValue()) { + sb.append(criterion.getCondition()); + } else if (criterion.isSingleValue()) { + if (criterion.getTypeHandler() == null) { + sb.append(String.format(parmPhrase1, criterion.getCondition(), i, j)); + } else { + sb.append(String.format(parmPhrase1_th, criterion.getCondition(), i, j,criterion.getTypeHandler())); + } + } else if (criterion.isBetweenValue()) { + if (criterion.getTypeHandler() == null) { + sb.append(String.format(parmPhrase2, criterion.getCondition(), i, j, i, j)); + } else { + sb.append(String.format(parmPhrase2_th, criterion.getCondition(), i, j, criterion.getTypeHandler(), i, j, criterion.getTypeHandler())); + } + } else if (criterion.isListValue()) { + sb.append(criterion.getCondition()); + sb.append(" ("); + List listItems = (List) criterion.getValue(); + boolean comma = false; + for (int k = 0; k < listItems.size(); k++) { + if (comma) { + sb.append(", "); + } else { + comma = true; + } + if (criterion.getTypeHandler() == null) { + sb.append(String.format(parmPhrase3, i, j, k)); + } else { + sb.append(String.format(parmPhrase3_th, i, j, k, criterion.getTypeHandler())); + } + } + sb.append(')'); + } + } + sb.append(')'); + } + } + + if (sb.length() > 0) { + sql.WHERE(sb.toString()); + } + } +} \ No newline at end of file diff --git a/hai-service/src/main/java/com/hai/entity/HighChildOrder.java b/hai-service/src/main/java/com/hai/entity/HighChildOrder.java index b59c59f4..4dd30819 100644 --- a/hai-service/src/main/java/com/hai/entity/HighChildOrder.java +++ b/hai-service/src/main/java/com/hai/entity/HighChildOrder.java @@ -124,6 +124,11 @@ public class HighChildOrder implements Serializable { */ private BigDecimal totalActualPrice; + /** + * 商品总优惠金额 + */ + private BigDecimal totalDeductionPrice; + /** * 商品的数量 */ @@ -375,6 +380,14 @@ public class HighChildOrder implements Serializable { this.totalActualPrice = totalActualPrice; } + public BigDecimal getTotalDeductionPrice() { + return totalDeductionPrice; + } + + public void setTotalDeductionPrice(BigDecimal totalDeductionPrice) { + this.totalDeductionPrice = totalDeductionPrice; + } + public Integer getSaleCount() { return saleCount; } @@ -567,6 +580,7 @@ public class HighChildOrder implements Serializable { && (this.getGoodsActualPrice() == null ? other.getGoodsActualPrice() == null : this.getGoodsActualPrice().equals(other.getGoodsActualPrice())) && (this.getTotalPrice() == null ? other.getTotalPrice() == null : this.getTotalPrice().equals(other.getTotalPrice())) && (this.getTotalActualPrice() == null ? other.getTotalActualPrice() == null : this.getTotalActualPrice().equals(other.getTotalActualPrice())) + && (this.getTotalDeductionPrice() == null ? other.getTotalDeductionPrice() == null : this.getTotalDeductionPrice().equals(other.getTotalDeductionPrice())) && (this.getSaleCount() == null ? other.getSaleCount() == null : this.getSaleCount().equals(other.getSaleCount())) && (this.getSurplusRefundNum() == null ? other.getSurplusRefundNum() == null : this.getSurplusRefundNum().equals(other.getSurplusRefundNum())) && (this.getSurplusRefundPrice() == null ? other.getSurplusRefundPrice() == null : this.getSurplusRefundPrice().equals(other.getSurplusRefundPrice())) @@ -613,6 +627,7 @@ public class HighChildOrder implements Serializable { result = prime * result + ((getGoodsActualPrice() == null) ? 0 : getGoodsActualPrice().hashCode()); result = prime * result + ((getTotalPrice() == null) ? 0 : getTotalPrice().hashCode()); result = prime * result + ((getTotalActualPrice() == null) ? 0 : getTotalActualPrice().hashCode()); + result = prime * result + ((getTotalDeductionPrice() == null) ? 0 : getTotalDeductionPrice().hashCode()); result = prime * result + ((getSaleCount() == null) ? 0 : getSaleCount().hashCode()); result = prime * result + ((getSurplusRefundNum() == null) ? 0 : getSurplusRefundNum().hashCode()); result = prime * result + ((getSurplusRefundPrice() == null) ? 0 : getSurplusRefundPrice().hashCode()); @@ -662,6 +677,7 @@ public class HighChildOrder implements Serializable { sb.append(", goodsActualPrice=").append(goodsActualPrice); sb.append(", totalPrice=").append(totalPrice); sb.append(", totalActualPrice=").append(totalActualPrice); + sb.append(", totalDeductionPrice=").append(totalDeductionPrice); sb.append(", saleCount=").append(saleCount); sb.append(", surplusRefundNum=").append(surplusRefundNum); sb.append(", surplusRefundPrice=").append(surplusRefundPrice); diff --git a/hai-service/src/main/java/com/hai/entity/HighChildOrderExample.java b/hai-service/src/main/java/com/hai/entity/HighChildOrderExample.java index 2f5736de..b91675af 100644 --- a/hai-service/src/main/java/com/hai/entity/HighChildOrderExample.java +++ b/hai-service/src/main/java/com/hai/entity/HighChildOrderExample.java @@ -1426,6 +1426,66 @@ public class HighChildOrderExample { return (Criteria) this; } + public Criteria andTotalDeductionPriceIsNull() { + addCriterion("total_deduction_price is null"); + return (Criteria) this; + } + + public Criteria andTotalDeductionPriceIsNotNull() { + addCriterion("total_deduction_price is not null"); + return (Criteria) this; + } + + public Criteria andTotalDeductionPriceEqualTo(BigDecimal value) { + addCriterion("total_deduction_price =", value, "totalDeductionPrice"); + return (Criteria) this; + } + + public Criteria andTotalDeductionPriceNotEqualTo(BigDecimal value) { + addCriterion("total_deduction_price <>", value, "totalDeductionPrice"); + return (Criteria) this; + } + + public Criteria andTotalDeductionPriceGreaterThan(BigDecimal value) { + addCriterion("total_deduction_price >", value, "totalDeductionPrice"); + return (Criteria) this; + } + + public Criteria andTotalDeductionPriceGreaterThanOrEqualTo(BigDecimal value) { + addCriterion("total_deduction_price >=", value, "totalDeductionPrice"); + return (Criteria) this; + } + + public Criteria andTotalDeductionPriceLessThan(BigDecimal value) { + addCriterion("total_deduction_price <", value, "totalDeductionPrice"); + return (Criteria) this; + } + + public Criteria andTotalDeductionPriceLessThanOrEqualTo(BigDecimal value) { + addCriterion("total_deduction_price <=", value, "totalDeductionPrice"); + return (Criteria) this; + } + + public Criteria andTotalDeductionPriceIn(List values) { + addCriterion("total_deduction_price in", values, "totalDeductionPrice"); + return (Criteria) this; + } + + public Criteria andTotalDeductionPriceNotIn(List values) { + addCriterion("total_deduction_price not in", values, "totalDeductionPrice"); + return (Criteria) this; + } + + public Criteria andTotalDeductionPriceBetween(BigDecimal value1, BigDecimal value2) { + addCriterion("total_deduction_price between", value1, value2, "totalDeductionPrice"); + return (Criteria) this; + } + + public Criteria andTotalDeductionPriceNotBetween(BigDecimal value1, BigDecimal value2) { + addCriterion("total_deduction_price not between", value1, value2, "totalDeductionPrice"); + return (Criteria) this; + } + public Criteria andSaleCountIsNull() { addCriterion("sale_count is null"); return (Criteria) this; diff --git a/hai-service/src/main/java/com/hai/entity/HighOrder.java b/hai-service/src/main/java/com/hai/entity/HighOrder.java index dceb7bbe..0c35ac2c 100644 --- a/hai-service/src/main/java/com/hai/entity/HighOrder.java +++ b/hai-service/src/main/java/com/hai/entity/HighOrder.java @@ -115,14 +115,24 @@ public class HighOrder implements Serializable { private String memCardNo; /** - * 订单总金额 + * 交易总金额 */ private BigDecimal totalPrice; /** - * 优惠金额 + * 交易总优惠金额(优惠券优惠金额+商品优惠金额) */ - private BigDecimal deductionPrice; + private BigDecimal totalDeductionPrice; + + /** + * 优惠券优惠金额 + */ + private BigDecimal deductionCouponPrice; + + /** + * 产品优惠金额 + */ + private BigDecimal deductionProductPrice; /** * 积分抵扣 @@ -405,12 +415,28 @@ public class HighOrder implements Serializable { this.totalPrice = totalPrice; } - public BigDecimal getDeductionPrice() { - return deductionPrice; + public BigDecimal getTotalDeductionPrice() { + return totalDeductionPrice; + } + + public void setTotalDeductionPrice(BigDecimal totalDeductionPrice) { + this.totalDeductionPrice = totalDeductionPrice; + } + + public BigDecimal getDeductionCouponPrice() { + return deductionCouponPrice; + } + + public void setDeductionCouponPrice(BigDecimal deductionCouponPrice) { + this.deductionCouponPrice = deductionCouponPrice; + } + + public BigDecimal getDeductionProductPrice() { + return deductionProductPrice; } - public void setDeductionPrice(BigDecimal deductionPrice) { - this.deductionPrice = deductionPrice; + public void setDeductionProductPrice(BigDecimal deductionProductPrice) { + this.deductionProductPrice = deductionProductPrice; } public Integer getPayGold() { @@ -660,7 +686,9 @@ public class HighOrder implements Serializable { && (this.getMemCardType() == null ? other.getMemCardType() == null : this.getMemCardType().equals(other.getMemCardType())) && (this.getMemCardNo() == null ? other.getMemCardNo() == null : this.getMemCardNo().equals(other.getMemCardNo())) && (this.getTotalPrice() == null ? other.getTotalPrice() == null : this.getTotalPrice().equals(other.getTotalPrice())) - && (this.getDeductionPrice() == null ? other.getDeductionPrice() == null : this.getDeductionPrice().equals(other.getDeductionPrice())) + && (this.getTotalDeductionPrice() == null ? other.getTotalDeductionPrice() == null : this.getTotalDeductionPrice().equals(other.getTotalDeductionPrice())) + && (this.getDeductionCouponPrice() == null ? other.getDeductionCouponPrice() == null : this.getDeductionCouponPrice().equals(other.getDeductionCouponPrice())) + && (this.getDeductionProductPrice() == null ? other.getDeductionProductPrice() == null : this.getDeductionProductPrice().equals(other.getDeductionProductPrice())) && (this.getPayGold() == null ? other.getPayGold() == null : this.getPayGold().equals(other.getPayGold())) && (this.getPayablePrice() == null ? other.getPayablePrice() == null : this.getPayablePrice().equals(other.getPayablePrice())) && (this.getPayPrice() == null ? other.getPayPrice() == null : this.getPayPrice().equals(other.getPayPrice())) @@ -713,7 +741,9 @@ public class HighOrder implements Serializable { result = prime * result + ((getMemCardType() == null) ? 0 : getMemCardType().hashCode()); result = prime * result + ((getMemCardNo() == null) ? 0 : getMemCardNo().hashCode()); result = prime * result + ((getTotalPrice() == null) ? 0 : getTotalPrice().hashCode()); - result = prime * result + ((getDeductionPrice() == null) ? 0 : getDeductionPrice().hashCode()); + result = prime * result + ((getTotalDeductionPrice() == null) ? 0 : getTotalDeductionPrice().hashCode()); + result = prime * result + ((getDeductionCouponPrice() == null) ? 0 : getDeductionCouponPrice().hashCode()); + result = prime * result + ((getDeductionProductPrice() == null) ? 0 : getDeductionProductPrice().hashCode()); result = prime * result + ((getPayGold() == null) ? 0 : getPayGold().hashCode()); result = prime * result + ((getPayablePrice() == null) ? 0 : getPayablePrice().hashCode()); result = prime * result + ((getPayPrice() == null) ? 0 : getPayPrice().hashCode()); @@ -769,7 +799,9 @@ public class HighOrder implements Serializable { sb.append(", memCardType=").append(memCardType); sb.append(", memCardNo=").append(memCardNo); sb.append(", totalPrice=").append(totalPrice); - sb.append(", deductionPrice=").append(deductionPrice); + sb.append(", totalDeductionPrice=").append(totalDeductionPrice); + sb.append(", deductionCouponPrice=").append(deductionCouponPrice); + sb.append(", deductionProductPrice=").append(deductionProductPrice); sb.append(", payGold=").append(payGold); sb.append(", payablePrice=").append(payablePrice); sb.append(", payPrice=").append(payPrice); diff --git a/hai-service/src/main/java/com/hai/entity/HighOrderExample.java b/hai-service/src/main/java/com/hai/entity/HighOrderExample.java index 4a8935b1..858b0283 100644 --- a/hai-service/src/main/java/com/hai/entity/HighOrderExample.java +++ b/hai-service/src/main/java/com/hai/entity/HighOrderExample.java @@ -1366,63 +1366,183 @@ public class HighOrderExample { return (Criteria) this; } - public Criteria andDeductionPriceIsNull() { - addCriterion("deduction_price is null"); + public Criteria andTotalDeductionPriceIsNull() { + addCriterion("total_deduction_price is null"); return (Criteria) this; } - public Criteria andDeductionPriceIsNotNull() { - addCriterion("deduction_price is not null"); + public Criteria andTotalDeductionPriceIsNotNull() { + addCriterion("total_deduction_price is not null"); return (Criteria) this; } - public Criteria andDeductionPriceEqualTo(BigDecimal value) { - addCriterion("deduction_price =", value, "deductionPrice"); + public Criteria andTotalDeductionPriceEqualTo(BigDecimal value) { + addCriterion("total_deduction_price =", value, "totalDeductionPrice"); return (Criteria) this; } - public Criteria andDeductionPriceNotEqualTo(BigDecimal value) { - addCriterion("deduction_price <>", value, "deductionPrice"); + public Criteria andTotalDeductionPriceNotEqualTo(BigDecimal value) { + addCriterion("total_deduction_price <>", value, "totalDeductionPrice"); return (Criteria) this; } - public Criteria andDeductionPriceGreaterThan(BigDecimal value) { - addCriterion("deduction_price >", value, "deductionPrice"); + public Criteria andTotalDeductionPriceGreaterThan(BigDecimal value) { + addCriterion("total_deduction_price >", value, "totalDeductionPrice"); return (Criteria) this; } - public Criteria andDeductionPriceGreaterThanOrEqualTo(BigDecimal value) { - addCriterion("deduction_price >=", value, "deductionPrice"); + public Criteria andTotalDeductionPriceGreaterThanOrEqualTo(BigDecimal value) { + addCriterion("total_deduction_price >=", value, "totalDeductionPrice"); return (Criteria) this; } - public Criteria andDeductionPriceLessThan(BigDecimal value) { - addCriterion("deduction_price <", value, "deductionPrice"); + public Criteria andTotalDeductionPriceLessThan(BigDecimal value) { + addCriterion("total_deduction_price <", value, "totalDeductionPrice"); return (Criteria) this; } - public Criteria andDeductionPriceLessThanOrEqualTo(BigDecimal value) { - addCriterion("deduction_price <=", value, "deductionPrice"); + public Criteria andTotalDeductionPriceLessThanOrEqualTo(BigDecimal value) { + addCriterion("total_deduction_price <=", value, "totalDeductionPrice"); return (Criteria) this; } - public Criteria andDeductionPriceIn(List values) { - addCriterion("deduction_price in", values, "deductionPrice"); + public Criteria andTotalDeductionPriceIn(List values) { + addCriterion("total_deduction_price in", values, "totalDeductionPrice"); return (Criteria) this; } - public Criteria andDeductionPriceNotIn(List values) { - addCriterion("deduction_price not in", values, "deductionPrice"); + public Criteria andTotalDeductionPriceNotIn(List values) { + addCriterion("total_deduction_price not in", values, "totalDeductionPrice"); return (Criteria) this; } - public Criteria andDeductionPriceBetween(BigDecimal value1, BigDecimal value2) { - addCriterion("deduction_price between", value1, value2, "deductionPrice"); + public Criteria andTotalDeductionPriceBetween(BigDecimal value1, BigDecimal value2) { + addCriterion("total_deduction_price between", value1, value2, "totalDeductionPrice"); return (Criteria) this; } - public Criteria andDeductionPriceNotBetween(BigDecimal value1, BigDecimal value2) { - addCriterion("deduction_price not between", value1, value2, "deductionPrice"); + public Criteria andTotalDeductionPriceNotBetween(BigDecimal value1, BigDecimal value2) { + addCriterion("total_deduction_price not between", value1, value2, "totalDeductionPrice"); + return (Criteria) this; + } + + public Criteria andDeductionCouponPriceIsNull() { + addCriterion("deduction_coupon_price is null"); + return (Criteria) this; + } + + public Criteria andDeductionCouponPriceIsNotNull() { + addCriterion("deduction_coupon_price is not null"); + return (Criteria) this; + } + + public Criteria andDeductionCouponPriceEqualTo(BigDecimal value) { + addCriterion("deduction_coupon_price =", value, "deductionCouponPrice"); + return (Criteria) this; + } + + public Criteria andDeductionCouponPriceNotEqualTo(BigDecimal value) { + addCriterion("deduction_coupon_price <>", value, "deductionCouponPrice"); + return (Criteria) this; + } + + public Criteria andDeductionCouponPriceGreaterThan(BigDecimal value) { + addCriterion("deduction_coupon_price >", value, "deductionCouponPrice"); + return (Criteria) this; + } + + public Criteria andDeductionCouponPriceGreaterThanOrEqualTo(BigDecimal value) { + addCriterion("deduction_coupon_price >=", value, "deductionCouponPrice"); + return (Criteria) this; + } + + public Criteria andDeductionCouponPriceLessThan(BigDecimal value) { + addCriterion("deduction_coupon_price <", value, "deductionCouponPrice"); + return (Criteria) this; + } + + public Criteria andDeductionCouponPriceLessThanOrEqualTo(BigDecimal value) { + addCriterion("deduction_coupon_price <=", value, "deductionCouponPrice"); + return (Criteria) this; + } + + public Criteria andDeductionCouponPriceIn(List values) { + addCriterion("deduction_coupon_price in", values, "deductionCouponPrice"); + return (Criteria) this; + } + + public Criteria andDeductionCouponPriceNotIn(List values) { + addCriterion("deduction_coupon_price not in", values, "deductionCouponPrice"); + return (Criteria) this; + } + + public Criteria andDeductionCouponPriceBetween(BigDecimal value1, BigDecimal value2) { + addCriterion("deduction_coupon_price between", value1, value2, "deductionCouponPrice"); + return (Criteria) this; + } + + public Criteria andDeductionCouponPriceNotBetween(BigDecimal value1, BigDecimal value2) { + addCriterion("deduction_coupon_price not between", value1, value2, "deductionCouponPrice"); + return (Criteria) this; + } + + public Criteria andDeductionProductPriceIsNull() { + addCriterion("deduction_product_price is null"); + return (Criteria) this; + } + + public Criteria andDeductionProductPriceIsNotNull() { + addCriterion("deduction_product_price is not null"); + return (Criteria) this; + } + + public Criteria andDeductionProductPriceEqualTo(BigDecimal value) { + addCriterion("deduction_product_price =", value, "deductionProductPrice"); + return (Criteria) this; + } + + public Criteria andDeductionProductPriceNotEqualTo(BigDecimal value) { + addCriterion("deduction_product_price <>", value, "deductionProductPrice"); + return (Criteria) this; + } + + public Criteria andDeductionProductPriceGreaterThan(BigDecimal value) { + addCriterion("deduction_product_price >", value, "deductionProductPrice"); + return (Criteria) this; + } + + public Criteria andDeductionProductPriceGreaterThanOrEqualTo(BigDecimal value) { + addCriterion("deduction_product_price >=", value, "deductionProductPrice"); + return (Criteria) this; + } + + public Criteria andDeductionProductPriceLessThan(BigDecimal value) { + addCriterion("deduction_product_price <", value, "deductionProductPrice"); + return (Criteria) this; + } + + public Criteria andDeductionProductPriceLessThanOrEqualTo(BigDecimal value) { + addCriterion("deduction_product_price <=", value, "deductionProductPrice"); + return (Criteria) this; + } + + public Criteria andDeductionProductPriceIn(List values) { + addCriterion("deduction_product_price in", values, "deductionProductPrice"); + return (Criteria) this; + } + + public Criteria andDeductionProductPriceNotIn(List values) { + addCriterion("deduction_product_price not in", values, "deductionProductPrice"); + return (Criteria) this; + } + + public Criteria andDeductionProductPriceBetween(BigDecimal value1, BigDecimal value2) { + addCriterion("deduction_product_price between", value1, value2, "deductionProductPrice"); + return (Criteria) this; + } + + public Criteria andDeductionProductPriceNotBetween(BigDecimal value1, BigDecimal value2) { + addCriterion("deduction_product_price not between", value1, value2, "deductionProductPrice"); return (Criteria) this; } diff --git a/hai-service/src/main/java/com/hai/entity/HighUserLoginLog.java b/hai-service/src/main/java/com/hai/entity/HighUserLoginLog.java new file mode 100644 index 00000000..015f9f16 --- /dev/null +++ b/hai-service/src/main/java/com/hai/entity/HighUserLoginLog.java @@ -0,0 +1,257 @@ +package com.hai.entity; + +import java.io.Serializable; +import java.util.Date; + +/** + * high_user_login_log + * @author + */ +/** + * + * 代码由工具生成 + * + **/ +public class HighUserLoginLog implements Serializable { + /** + * 主键 + */ + private Long id; + + /** + * 用户id + */ + private Long userId; + + /** + * 用户电话 + */ + private String userPhone; + + /** + * 登录平台 + */ + private String platform; + + /** + * ip地址 + */ + private String ip; + + /** + * 省份名称 + */ + private String provinceName; + + /** + * 城市编码 + */ + private String cityCode; + + /** + * 城市名称 + */ + private String cityName; + + /** + * 状态 0:删除 1:正常 + */ + private Integer status; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * ext_1 + */ + private String ext1; + + /** + * ext_2 + */ + private String ext2; + + /** + * ext_3 + */ + private String ext3; + + private static final long serialVersionUID = 1L; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getUserId() { + return userId; + } + + public void setUserId(Long userId) { + this.userId = userId; + } + + public String getUserPhone() { + return userPhone; + } + + public void setUserPhone(String userPhone) { + this.userPhone = userPhone; + } + + public String getPlatform() { + return platform; + } + + public void setPlatform(String platform) { + this.platform = platform; + } + + public String getIp() { + return ip; + } + + public void setIp(String ip) { + this.ip = ip; + } + + public String getProvinceName() { + return provinceName; + } + + public void setProvinceName(String provinceName) { + this.provinceName = provinceName; + } + + public String getCityCode() { + return cityCode; + } + + public void setCityCode(String cityCode) { + this.cityCode = cityCode; + } + + public String getCityName() { + return cityName; + } + + public void setCityName(String cityName) { + this.cityName = cityName; + } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public String getExt1() { + return ext1; + } + + public void setExt1(String ext1) { + this.ext1 = ext1; + } + + public String getExt2() { + return ext2; + } + + public void setExt2(String ext2) { + this.ext2 = ext2; + } + + public String getExt3() { + return ext3; + } + + public void setExt3(String ext3) { + this.ext3 = ext3; + } + + @Override + public boolean equals(Object that) { + if (this == that) { + return true; + } + if (that == null) { + return false; + } + if (getClass() != that.getClass()) { + return false; + } + HighUserLoginLog other = (HighUserLoginLog) that; + return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) + && (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId())) + && (this.getUserPhone() == null ? other.getUserPhone() == null : this.getUserPhone().equals(other.getUserPhone())) + && (this.getPlatform() == null ? other.getPlatform() == null : this.getPlatform().equals(other.getPlatform())) + && (this.getIp() == null ? other.getIp() == null : this.getIp().equals(other.getIp())) + && (this.getProvinceName() == null ? other.getProvinceName() == null : this.getProvinceName().equals(other.getProvinceName())) + && (this.getCityCode() == null ? other.getCityCode() == null : this.getCityCode().equals(other.getCityCode())) + && (this.getCityName() == null ? other.getCityName() == null : this.getCityName().equals(other.getCityName())) + && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus())) + && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime())) + && (this.getExt1() == null ? other.getExt1() == null : this.getExt1().equals(other.getExt1())) + && (this.getExt2() == null ? other.getExt2() == null : this.getExt2().equals(other.getExt2())) + && (this.getExt3() == null ? other.getExt3() == null : this.getExt3().equals(other.getExt3())); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); + result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode()); + result = prime * result + ((getUserPhone() == null) ? 0 : getUserPhone().hashCode()); + result = prime * result + ((getPlatform() == null) ? 0 : getPlatform().hashCode()); + result = prime * result + ((getIp() == null) ? 0 : getIp().hashCode()); + result = prime * result + ((getProvinceName() == null) ? 0 : getProvinceName().hashCode()); + result = prime * result + ((getCityCode() == null) ? 0 : getCityCode().hashCode()); + result = prime * result + ((getCityName() == null) ? 0 : getCityName().hashCode()); + result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode()); + result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode()); + result = prime * result + ((getExt1() == null) ? 0 : getExt1().hashCode()); + result = prime * result + ((getExt2() == null) ? 0 : getExt2().hashCode()); + result = prime * result + ((getExt3() == null) ? 0 : getExt3().hashCode()); + return result; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(getClass().getSimpleName()); + sb.append(" ["); + sb.append("Hash = ").append(hashCode()); + sb.append(", id=").append(id); + sb.append(", userId=").append(userId); + sb.append(", userPhone=").append(userPhone); + sb.append(", platform=").append(platform); + sb.append(", ip=").append(ip); + sb.append(", provinceName=").append(provinceName); + sb.append(", cityCode=").append(cityCode); + sb.append(", cityName=").append(cityName); + sb.append(", status=").append(status); + sb.append(", createTime=").append(createTime); + sb.append(", ext1=").append(ext1); + sb.append(", ext2=").append(ext2); + sb.append(", ext3=").append(ext3); + sb.append(", serialVersionUID=").append(serialVersionUID); + sb.append("]"); + return sb.toString(); + } +} \ No newline at end of file diff --git a/hai-service/src/main/java/com/hai/entity/HighUserLoginLogExample.java b/hai-service/src/main/java/com/hai/entity/HighUserLoginLogExample.java new file mode 100644 index 00000000..b526a695 --- /dev/null +++ b/hai-service/src/main/java/com/hai/entity/HighUserLoginLogExample.java @@ -0,0 +1,1093 @@ +package com.hai.entity; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +public class HighUserLoginLogExample { + protected String orderByClause; + + protected boolean distinct; + + protected List oredCriteria; + + private Integer limit; + + private Long offset; + + public HighUserLoginLogExample() { + oredCriteria = new ArrayList(); + } + + public void setOrderByClause(String orderByClause) { + this.orderByClause = orderByClause; + } + + public String getOrderByClause() { + return orderByClause; + } + + public void setDistinct(boolean distinct) { + this.distinct = distinct; + } + + public boolean isDistinct() { + return distinct; + } + + public List getOredCriteria() { + return oredCriteria; + } + + public void or(Criteria criteria) { + oredCriteria.add(criteria); + } + + public Criteria or() { + Criteria criteria = createCriteriaInternal(); + oredCriteria.add(criteria); + return criteria; + } + + public Criteria createCriteria() { + Criteria criteria = createCriteriaInternal(); + if (oredCriteria.size() == 0) { + oredCriteria.add(criteria); + } + return criteria; + } + + protected Criteria createCriteriaInternal() { + Criteria criteria = new Criteria(); + return criteria; + } + + public void clear() { + oredCriteria.clear(); + orderByClause = null; + distinct = false; + } + + public void setLimit(Integer limit) { + this.limit = limit; + } + + public Integer getLimit() { + return limit; + } + + public void setOffset(Long offset) { + this.offset = offset; + } + + public Long getOffset() { + return offset; + } + + protected abstract static class GeneratedCriteria { + protected List criteria; + + protected GeneratedCriteria() { + super(); + criteria = new ArrayList(); + } + + public boolean isValid() { + return criteria.size() > 0; + } + + public List getAllCriteria() { + return criteria; + } + + public List getCriteria() { + return criteria; + } + + protected void addCriterion(String condition) { + if (condition == null) { + throw new RuntimeException("Value for condition cannot be null"); + } + criteria.add(new Criterion(condition)); + } + + protected void addCriterion(String condition, Object value, String property) { + if (value == null) { + throw new RuntimeException("Value for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value)); + } + + protected void addCriterion(String condition, Object value1, Object value2, String property) { + if (value1 == null || value2 == null) { + throw new RuntimeException("Between values for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value1, value2)); + } + + public Criteria andIdIsNull() { + addCriterion("id is null"); + return (Criteria) this; + } + + public Criteria andIdIsNotNull() { + addCriterion("id is not null"); + return (Criteria) this; + } + + public Criteria andIdEqualTo(Long value) { + addCriterion("id =", value, "id"); + return (Criteria) this; + } + + public Criteria andIdNotEqualTo(Long value) { + addCriterion("id <>", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThan(Long value) { + addCriterion("id >", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThanOrEqualTo(Long value) { + addCriterion("id >=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThan(Long value) { + addCriterion("id <", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThanOrEqualTo(Long value) { + addCriterion("id <=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdIn(List values) { + addCriterion("id in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdNotIn(List values) { + addCriterion("id not in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdBetween(Long value1, Long value2) { + addCriterion("id between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andIdNotBetween(Long value1, Long value2) { + addCriterion("id not between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andUserIdIsNull() { + addCriterion("user_id is null"); + return (Criteria) this; + } + + public Criteria andUserIdIsNotNull() { + addCriterion("user_id is not null"); + return (Criteria) this; + } + + public Criteria andUserIdEqualTo(Long value) { + addCriterion("user_id =", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotEqualTo(Long value) { + addCriterion("user_id <>", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdGreaterThan(Long value) { + addCriterion("user_id >", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdGreaterThanOrEqualTo(Long value) { + addCriterion("user_id >=", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdLessThan(Long value) { + addCriterion("user_id <", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdLessThanOrEqualTo(Long value) { + addCriterion("user_id <=", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdIn(List values) { + addCriterion("user_id in", values, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotIn(List values) { + addCriterion("user_id not in", values, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdBetween(Long value1, Long value2) { + addCriterion("user_id between", value1, value2, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotBetween(Long value1, Long value2) { + addCriterion("user_id not between", value1, value2, "userId"); + return (Criteria) this; + } + + public Criteria andUserPhoneIsNull() { + addCriterion("user_phone is null"); + return (Criteria) this; + } + + public Criteria andUserPhoneIsNotNull() { + addCriterion("user_phone is not null"); + return (Criteria) this; + } + + public Criteria andUserPhoneEqualTo(String value) { + addCriterion("user_phone =", value, "userPhone"); + return (Criteria) this; + } + + public Criteria andUserPhoneNotEqualTo(String value) { + addCriterion("user_phone <>", value, "userPhone"); + return (Criteria) this; + } + + public Criteria andUserPhoneGreaterThan(String value) { + addCriterion("user_phone >", value, "userPhone"); + return (Criteria) this; + } + + public Criteria andUserPhoneGreaterThanOrEqualTo(String value) { + addCriterion("user_phone >=", value, "userPhone"); + return (Criteria) this; + } + + public Criteria andUserPhoneLessThan(String value) { + addCriterion("user_phone <", value, "userPhone"); + return (Criteria) this; + } + + public Criteria andUserPhoneLessThanOrEqualTo(String value) { + addCriterion("user_phone <=", value, "userPhone"); + return (Criteria) this; + } + + public Criteria andUserPhoneLike(String value) { + addCriterion("user_phone like", value, "userPhone"); + return (Criteria) this; + } + + public Criteria andUserPhoneNotLike(String value) { + addCriterion("user_phone not like", value, "userPhone"); + return (Criteria) this; + } + + public Criteria andUserPhoneIn(List values) { + addCriterion("user_phone in", values, "userPhone"); + return (Criteria) this; + } + + public Criteria andUserPhoneNotIn(List values) { + addCriterion("user_phone not in", values, "userPhone"); + return (Criteria) this; + } + + public Criteria andUserPhoneBetween(String value1, String value2) { + addCriterion("user_phone between", value1, value2, "userPhone"); + return (Criteria) this; + } + + public Criteria andUserPhoneNotBetween(String value1, String value2) { + addCriterion("user_phone not between", value1, value2, "userPhone"); + return (Criteria) this; + } + + public Criteria andPlatformIsNull() { + addCriterion("platform is null"); + return (Criteria) this; + } + + public Criteria andPlatformIsNotNull() { + addCriterion("platform is not null"); + return (Criteria) this; + } + + public Criteria andPlatformEqualTo(String value) { + addCriterion("platform =", value, "platform"); + return (Criteria) this; + } + + public Criteria andPlatformNotEqualTo(String value) { + addCriterion("platform <>", value, "platform"); + return (Criteria) this; + } + + public Criteria andPlatformGreaterThan(String value) { + addCriterion("platform >", value, "platform"); + return (Criteria) this; + } + + public Criteria andPlatformGreaterThanOrEqualTo(String value) { + addCriterion("platform >=", value, "platform"); + return (Criteria) this; + } + + public Criteria andPlatformLessThan(String value) { + addCriterion("platform <", value, "platform"); + return (Criteria) this; + } + + public Criteria andPlatformLessThanOrEqualTo(String value) { + addCriterion("platform <=", value, "platform"); + return (Criteria) this; + } + + public Criteria andPlatformLike(String value) { + addCriterion("platform like", value, "platform"); + return (Criteria) this; + } + + public Criteria andPlatformNotLike(String value) { + addCriterion("platform not like", value, "platform"); + return (Criteria) this; + } + + public Criteria andPlatformIn(List values) { + addCriterion("platform in", values, "platform"); + return (Criteria) this; + } + + public Criteria andPlatformNotIn(List values) { + addCriterion("platform not in", values, "platform"); + return (Criteria) this; + } + + public Criteria andPlatformBetween(String value1, String value2) { + addCriterion("platform between", value1, value2, "platform"); + return (Criteria) this; + } + + public Criteria andPlatformNotBetween(String value1, String value2) { + addCriterion("platform not between", value1, value2, "platform"); + return (Criteria) this; + } + + public Criteria andIpIsNull() { + addCriterion("ip is null"); + return (Criteria) this; + } + + public Criteria andIpIsNotNull() { + addCriterion("ip is not null"); + return (Criteria) this; + } + + public Criteria andIpEqualTo(String value) { + addCriterion("ip =", value, "ip"); + return (Criteria) this; + } + + public Criteria andIpNotEqualTo(String value) { + addCriterion("ip <>", value, "ip"); + return (Criteria) this; + } + + public Criteria andIpGreaterThan(String value) { + addCriterion("ip >", value, "ip"); + return (Criteria) this; + } + + public Criteria andIpGreaterThanOrEqualTo(String value) { + addCriterion("ip >=", value, "ip"); + return (Criteria) this; + } + + public Criteria andIpLessThan(String value) { + addCriterion("ip <", value, "ip"); + return (Criteria) this; + } + + public Criteria andIpLessThanOrEqualTo(String value) { + addCriterion("ip <=", value, "ip"); + return (Criteria) this; + } + + public Criteria andIpLike(String value) { + addCriterion("ip like", value, "ip"); + return (Criteria) this; + } + + public Criteria andIpNotLike(String value) { + addCriterion("ip not like", value, "ip"); + return (Criteria) this; + } + + public Criteria andIpIn(List values) { + addCriterion("ip in", values, "ip"); + return (Criteria) this; + } + + public Criteria andIpNotIn(List values) { + addCriterion("ip not in", values, "ip"); + return (Criteria) this; + } + + public Criteria andIpBetween(String value1, String value2) { + addCriterion("ip between", value1, value2, "ip"); + return (Criteria) this; + } + + public Criteria andIpNotBetween(String value1, String value2) { + addCriterion("ip not between", value1, value2, "ip"); + return (Criteria) this; + } + + public Criteria andProvinceNameIsNull() { + addCriterion("province_name is null"); + return (Criteria) this; + } + + public Criteria andProvinceNameIsNotNull() { + addCriterion("province_name is not null"); + return (Criteria) this; + } + + public Criteria andProvinceNameEqualTo(String value) { + addCriterion("province_name =", value, "provinceName"); + return (Criteria) this; + } + + public Criteria andProvinceNameNotEqualTo(String value) { + addCriterion("province_name <>", value, "provinceName"); + return (Criteria) this; + } + + public Criteria andProvinceNameGreaterThan(String value) { + addCriterion("province_name >", value, "provinceName"); + return (Criteria) this; + } + + public Criteria andProvinceNameGreaterThanOrEqualTo(String value) { + addCriterion("province_name >=", value, "provinceName"); + return (Criteria) this; + } + + public Criteria andProvinceNameLessThan(String value) { + addCriterion("province_name <", value, "provinceName"); + return (Criteria) this; + } + + public Criteria andProvinceNameLessThanOrEqualTo(String value) { + addCriterion("province_name <=", value, "provinceName"); + return (Criteria) this; + } + + public Criteria andProvinceNameLike(String value) { + addCriterion("province_name like", value, "provinceName"); + return (Criteria) this; + } + + public Criteria andProvinceNameNotLike(String value) { + addCriterion("province_name not like", value, "provinceName"); + return (Criteria) this; + } + + public Criteria andProvinceNameIn(List values) { + addCriterion("province_name in", values, "provinceName"); + return (Criteria) this; + } + + public Criteria andProvinceNameNotIn(List values) { + addCriterion("province_name not in", values, "provinceName"); + return (Criteria) this; + } + + public Criteria andProvinceNameBetween(String value1, String value2) { + addCriterion("province_name between", value1, value2, "provinceName"); + return (Criteria) this; + } + + public Criteria andProvinceNameNotBetween(String value1, String value2) { + addCriterion("province_name not between", value1, value2, "provinceName"); + return (Criteria) this; + } + + public Criteria andCityCodeIsNull() { + addCriterion("city_code is null"); + return (Criteria) this; + } + + public Criteria andCityCodeIsNotNull() { + addCriterion("city_code is not null"); + return (Criteria) this; + } + + public Criteria andCityCodeEqualTo(String value) { + addCriterion("city_code =", value, "cityCode"); + return (Criteria) this; + } + + public Criteria andCityCodeNotEqualTo(String value) { + addCriterion("city_code <>", value, "cityCode"); + return (Criteria) this; + } + + public Criteria andCityCodeGreaterThan(String value) { + addCriterion("city_code >", value, "cityCode"); + return (Criteria) this; + } + + public Criteria andCityCodeGreaterThanOrEqualTo(String value) { + addCriterion("city_code >=", value, "cityCode"); + return (Criteria) this; + } + + public Criteria andCityCodeLessThan(String value) { + addCriterion("city_code <", value, "cityCode"); + return (Criteria) this; + } + + public Criteria andCityCodeLessThanOrEqualTo(String value) { + addCriterion("city_code <=", value, "cityCode"); + return (Criteria) this; + } + + public Criteria andCityCodeLike(String value) { + addCriterion("city_code like", value, "cityCode"); + return (Criteria) this; + } + + public Criteria andCityCodeNotLike(String value) { + addCriterion("city_code not like", value, "cityCode"); + return (Criteria) this; + } + + public Criteria andCityCodeIn(List values) { + addCriterion("city_code in", values, "cityCode"); + return (Criteria) this; + } + + public Criteria andCityCodeNotIn(List values) { + addCriterion("city_code not in", values, "cityCode"); + return (Criteria) this; + } + + public Criteria andCityCodeBetween(String value1, String value2) { + addCriterion("city_code between", value1, value2, "cityCode"); + return (Criteria) this; + } + + public Criteria andCityCodeNotBetween(String value1, String value2) { + addCriterion("city_code not between", value1, value2, "cityCode"); + return (Criteria) this; + } + + public Criteria andCityNameIsNull() { + addCriterion("city_name is null"); + return (Criteria) this; + } + + public Criteria andCityNameIsNotNull() { + addCriterion("city_name is not null"); + return (Criteria) this; + } + + public Criteria andCityNameEqualTo(String value) { + addCriterion("city_name =", value, "cityName"); + return (Criteria) this; + } + + public Criteria andCityNameNotEqualTo(String value) { + addCriterion("city_name <>", value, "cityName"); + return (Criteria) this; + } + + public Criteria andCityNameGreaterThan(String value) { + addCriterion("city_name >", value, "cityName"); + return (Criteria) this; + } + + public Criteria andCityNameGreaterThanOrEqualTo(String value) { + addCriterion("city_name >=", value, "cityName"); + return (Criteria) this; + } + + public Criteria andCityNameLessThan(String value) { + addCriterion("city_name <", value, "cityName"); + return (Criteria) this; + } + + public Criteria andCityNameLessThanOrEqualTo(String value) { + addCriterion("city_name <=", value, "cityName"); + return (Criteria) this; + } + + public Criteria andCityNameLike(String value) { + addCriterion("city_name like", value, "cityName"); + return (Criteria) this; + } + + public Criteria andCityNameNotLike(String value) { + addCriterion("city_name not like", value, "cityName"); + return (Criteria) this; + } + + public Criteria andCityNameIn(List values) { + addCriterion("city_name in", values, "cityName"); + return (Criteria) this; + } + + public Criteria andCityNameNotIn(List values) { + addCriterion("city_name not in", values, "cityName"); + return (Criteria) this; + } + + public Criteria andCityNameBetween(String value1, String value2) { + addCriterion("city_name between", value1, value2, "cityName"); + return (Criteria) this; + } + + public Criteria andCityNameNotBetween(String value1, String value2) { + addCriterion("city_name not between", value1, value2, "cityName"); + return (Criteria) this; + } + + public Criteria andStatusIsNull() { + addCriterion("`status` is null"); + return (Criteria) this; + } + + public Criteria andStatusIsNotNull() { + addCriterion("`status` is not null"); + return (Criteria) this; + } + + public Criteria andStatusEqualTo(Integer value) { + addCriterion("`status` =", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusNotEqualTo(Integer value) { + addCriterion("`status` <>", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusGreaterThan(Integer value) { + addCriterion("`status` >", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusGreaterThanOrEqualTo(Integer value) { + addCriterion("`status` >=", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusLessThan(Integer value) { + addCriterion("`status` <", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusLessThanOrEqualTo(Integer value) { + addCriterion("`status` <=", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusIn(List values) { + addCriterion("`status` in", values, "status"); + return (Criteria) this; + } + + public Criteria andStatusNotIn(List values) { + addCriterion("`status` not in", values, "status"); + return (Criteria) this; + } + + public Criteria andStatusBetween(Integer value1, Integer value2) { + addCriterion("`status` between", value1, value2, "status"); + return (Criteria) this; + } + + public Criteria andStatusNotBetween(Integer value1, Integer value2) { + addCriterion("`status` not between", value1, value2, "status"); + return (Criteria) this; + } + + public Criteria andCreateTimeIsNull() { + addCriterion("create_time is null"); + return (Criteria) this; + } + + public Criteria andCreateTimeIsNotNull() { + addCriterion("create_time is not null"); + return (Criteria) this; + } + + public Criteria andCreateTimeEqualTo(Date value) { + addCriterion("create_time =", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotEqualTo(Date value) { + addCriterion("create_time <>", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeGreaterThan(Date value) { + addCriterion("create_time >", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeGreaterThanOrEqualTo(Date value) { + addCriterion("create_time >=", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeLessThan(Date value) { + addCriterion("create_time <", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeLessThanOrEqualTo(Date value) { + addCriterion("create_time <=", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeIn(List values) { + addCriterion("create_time in", values, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotIn(List values) { + addCriterion("create_time not in", values, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeBetween(Date value1, Date value2) { + addCriterion("create_time between", value1, value2, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotBetween(Date value1, Date value2) { + addCriterion("create_time not between", value1, value2, "createTime"); + return (Criteria) this; + } + + public Criteria andExt1IsNull() { + addCriterion("ext_1 is null"); + return (Criteria) this; + } + + public Criteria andExt1IsNotNull() { + addCriterion("ext_1 is not null"); + return (Criteria) this; + } + + public Criteria andExt1EqualTo(String value) { + addCriterion("ext_1 =", value, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1NotEqualTo(String value) { + addCriterion("ext_1 <>", value, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1GreaterThan(String value) { + addCriterion("ext_1 >", value, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1GreaterThanOrEqualTo(String value) { + addCriterion("ext_1 >=", value, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1LessThan(String value) { + addCriterion("ext_1 <", value, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1LessThanOrEqualTo(String value) { + addCriterion("ext_1 <=", value, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1Like(String value) { + addCriterion("ext_1 like", value, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1NotLike(String value) { + addCriterion("ext_1 not like", value, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1In(List values) { + addCriterion("ext_1 in", values, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1NotIn(List values) { + addCriterion("ext_1 not in", values, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1Between(String value1, String value2) { + addCriterion("ext_1 between", value1, value2, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1NotBetween(String value1, String value2) { + addCriterion("ext_1 not between", value1, value2, "ext1"); + return (Criteria) this; + } + + public Criteria andExt2IsNull() { + addCriterion("ext_2 is null"); + return (Criteria) this; + } + + public Criteria andExt2IsNotNull() { + addCriterion("ext_2 is not null"); + return (Criteria) this; + } + + public Criteria andExt2EqualTo(String value) { + addCriterion("ext_2 =", value, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2NotEqualTo(String value) { + addCriterion("ext_2 <>", value, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2GreaterThan(String value) { + addCriterion("ext_2 >", value, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2GreaterThanOrEqualTo(String value) { + addCriterion("ext_2 >=", value, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2LessThan(String value) { + addCriterion("ext_2 <", value, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2LessThanOrEqualTo(String value) { + addCriterion("ext_2 <=", value, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2Like(String value) { + addCriterion("ext_2 like", value, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2NotLike(String value) { + addCriterion("ext_2 not like", value, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2In(List values) { + addCriterion("ext_2 in", values, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2NotIn(List values) { + addCriterion("ext_2 not in", values, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2Between(String value1, String value2) { + addCriterion("ext_2 between", value1, value2, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2NotBetween(String value1, String value2) { + addCriterion("ext_2 not between", value1, value2, "ext2"); + return (Criteria) this; + } + + public Criteria andExt3IsNull() { + addCriterion("ext_3 is null"); + return (Criteria) this; + } + + public Criteria andExt3IsNotNull() { + addCriterion("ext_3 is not null"); + return (Criteria) this; + } + + public Criteria andExt3EqualTo(String value) { + addCriterion("ext_3 =", value, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3NotEqualTo(String value) { + addCriterion("ext_3 <>", value, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3GreaterThan(String value) { + addCriterion("ext_3 >", value, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3GreaterThanOrEqualTo(String value) { + addCriterion("ext_3 >=", value, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3LessThan(String value) { + addCriterion("ext_3 <", value, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3LessThanOrEqualTo(String value) { + addCriterion("ext_3 <=", value, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3Like(String value) { + addCriterion("ext_3 like", value, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3NotLike(String value) { + addCriterion("ext_3 not like", value, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3In(List values) { + addCriterion("ext_3 in", values, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3NotIn(List values) { + addCriterion("ext_3 not in", values, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3Between(String value1, String value2) { + addCriterion("ext_3 between", value1, value2, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3NotBetween(String value1, String value2) { + addCriterion("ext_3 not between", value1, value2, "ext3"); + return (Criteria) this; + } + } + + /** + */ + public static class Criteria extends GeneratedCriteria { + + protected Criteria() { + super(); + } + } + + public static class Criterion { + private String condition; + + private Object value; + + private Object secondValue; + + private boolean noValue; + + private boolean singleValue; + + private boolean betweenValue; + + private boolean listValue; + + private String typeHandler; + + public String getCondition() { + return condition; + } + + public Object getValue() { + return value; + } + + public Object getSecondValue() { + return secondValue; + } + + public boolean isNoValue() { + return noValue; + } + + public boolean isSingleValue() { + return singleValue; + } + + public boolean isBetweenValue() { + return betweenValue; + } + + public boolean isListValue() { + return listValue; + } + + public String getTypeHandler() { + return typeHandler; + } + + protected Criterion(String condition) { + super(); + this.condition = condition; + this.typeHandler = null; + this.noValue = true; + } + + protected Criterion(String condition, Object value, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.typeHandler = typeHandler; + if (value instanceof List) { + this.listValue = true; + } else { + this.singleValue = true; + } + } + + protected Criterion(String condition, Object value) { + this(condition, value, null); + } + + protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.secondValue = secondValue; + this.typeHandler = typeHandler; + this.betweenValue = true; + } + + protected Criterion(String condition, Object value, Object secondValue) { + this(condition, value, secondValue, null); + } + } +} \ No newline at end of file diff --git a/hai-service/src/main/java/com/hai/enum_type/LoginPlatform.java b/hai-service/src/main/java/com/hai/enum_type/LoginPlatform.java new file mode 100644 index 00000000..43413286 --- /dev/null +++ b/hai-service/src/main/java/com/hai/enum_type/LoginPlatform.java @@ -0,0 +1,53 @@ +package com.hai.enum_type; + +import java.util.Objects; + +/** + * 登录平台 + * @className: LoginType + * @author: HuRui + * @date: 2022/10/20 + **/ +public enum LoginPlatform { + H5("WEB", "H5客户端"), + WXAPPLETS("WXAPPLETS", "微信小程序"), + UNIONPAY("UNIONPAY", "云闪付"), + ; + + private String code; + + private String name; + + LoginPlatform(String code, String name) { + this.code = code; + this.name = name; + } + + /** + * 根据类型查询数据 + * @param code + * @return + */ + public static LoginPlatform getDataByType(String code) { + for (LoginPlatform ele : values()) { + if(Objects.equals(code,ele.getCode())) return ele; + } + return null; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/hai-service/src/main/java/com/hai/enum_type/RedisFileFolder.java b/hai-service/src/main/java/com/hai/enum_type/RedisFileFolder.java new file mode 100644 index 00000000..6c071279 --- /dev/null +++ b/hai-service/src/main/java/com/hai/enum_type/RedisFileFolder.java @@ -0,0 +1,53 @@ +package com.hai.enum_type; + +import java.util.Objects; + +/** + * redis文件夹 + * @className: RedisFileFolder + * @author: HuRui + * @date: 2022/10/20 + **/ +public enum RedisFileFolder { + SMS_CODE("SMS_CODE:", "短信验证码"), + USER("USER:", "用户信息"), + ADMIN("ADMIN:", "管理信息"), + ; + + private String code; + + private String name; + + RedisFileFolder(String code, String name) { + this.code = code; + this.name = name; + } + + /** + * 根据类型查询数据 + * @param code + * @return + */ + public static RedisFileFolder getDataByType(String code) { + for (RedisFileFolder ele : values()) { + if(Objects.equals(code,ele.getCode())) return ele; + } + return null; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/hai-service/src/main/java/com/hai/model/UserModel.java b/hai-service/src/main/java/com/hai/model/UserModel.java index 13a41a3e..ed71bc41 100644 --- a/hai-service/src/main/java/com/hai/model/UserModel.java +++ b/hai-service/src/main/java/com/hai/model/UserModel.java @@ -18,13 +18,13 @@ public class UserModel { private Integer unusedDiscount; // 待支付数量 - private Integer unpaid; + private Long unpaid; // 待支付数量 private Long whetherCheckNum; // 支付数量 - private Integer orderPayNum; + private Long orderPayNum; // 充值订单待支付数量 private Integer rechargeOrderNum; @@ -92,13 +92,6 @@ public class UserModel { this.unusedDiscount = unusedDiscount; } - public Integer getUnpaid() { - return unpaid; - } - - public void setUnpaid(Integer unpaid) { - this.unpaid = unpaid; - } public Boolean getIsSetPayPwd() { return isSetPayPwd; @@ -132,13 +125,6 @@ public class UserModel { this.rechargeOrderNum = rechargeOrderNum; } - public Integer getOrderPayNum() { - return orderPayNum; - } - - public void setOrderPayNum(Integer orderPayNum) { - this.orderPayNum = orderPayNum; - } public Boolean getSetOilCard() { return isSetOilCard; @@ -155,4 +141,20 @@ public class UserModel { public void setWhetherCheckNum(Long whetherCheckNum) { this.whetherCheckNum = whetherCheckNum; } + + public Long getUnpaid() { + return unpaid; + } + + public void setUnpaid(Long unpaid) { + this.unpaid = unpaid; + } + + public Long getOrderPayNum() { + return orderPayNum; + } + + public void setOrderPayNum(Long orderPayNum) { + this.orderPayNum = orderPayNum; + } } diff --git a/hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java b/hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java index 5906878a..06a67a1f 100644 --- a/hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java +++ b/hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java @@ -190,6 +190,7 @@ public class OrderCreateHandleServiceImpl implements OrderCreateHandleService { childOrder.setTotalPrice(childOrder.getGoodsPrice().multiply(new BigDecimal(childOrder.getSaleCount().toString()))); childOrder.setTotalActualPrice(childOrder.getGoodsActualPrice().multiply(new BigDecimal(childOrder.getSaleCount().toString()))); + childOrder.setTotalDeductionPrice(childOrder.getTotalPrice().subtract(childOrder.getTotalActualPrice())); childOrderList.add(childOrder); // 是否赠送卡卷 @@ -224,7 +225,8 @@ public class OrderCreateHandleServiceImpl implements OrderCreateHandleService { childOrder.setChildOrderStatus(OrderChildStatus.STATUS1.getNumber()); childOrder.setPraiseStatus(0); childOrder.setTotalPrice(childOrder.getGoodsPrice().multiply(new BigDecimal(childOrder.getSaleCount().toString()))); - childOrder.setTotalActualPrice(childOrder.getGoodsActualPrice().multiply(new BigDecimal(childOrder.getSaleCount().toString()))); + childOrder.setTotalActualPrice(new BigDecimal("0")); + childOrder.setTotalDeductionPrice(childOrder.getTotalPrice().subtract(childOrder.getTotalActualPrice())); childOrder.setCreateTime(new Date()); childOrderList.add(childOrder); } @@ -319,6 +321,7 @@ public class OrderCreateHandleServiceImpl implements OrderCreateHandleService { childOrder.setChildOrderStatus(OrderChildStatus.STATUS1.getNumber()); childOrder.setTotalPrice(new BigDecimal(childOrder.getSaleCount().toString()).multiply(childOrder.getGoodsPrice())); childOrder.setTotalActualPrice(new BigDecimal(childOrder.getSaleCount().toString()).multiply(childOrder.getGoodsActualPrice())); + childOrder.setTotalDeductionPrice(childOrder.getTotalPrice().subtract(childOrder.getTotalActualPrice())); childOrder.setPraiseStatus(0); childOrder.setCreateTime(new Date()); diff --git a/hai-service/src/main/java/com/hai/order/service/impl/OrderPaySuccessServiceImpl.java b/hai-service/src/main/java/com/hai/order/service/impl/OrderPaySuccessServiceImpl.java index 2ec159a5..ce2137e1 100644 --- a/hai-service/src/main/java/com/hai/order/service/impl/OrderPaySuccessServiceImpl.java +++ b/hai-service/src/main/java/com/hai/order/service/impl/OrderPaySuccessServiceImpl.java @@ -275,7 +275,7 @@ public class OrderPaySuccessServiceImpl implements OrderPaySuccessService { gasOrder.getGasOilNo(), gasOrder.getGasGunNo(), order.getPayablePrice(), - order.getDeductionPrice() + order.getTotalDeductionPrice() ); } else if (gasOrder.getChannelType().equals(MerchantStoreSourceType.type4.getNumber())) { diff --git a/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java b/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java index 046c66bf..062e93af 100644 --- a/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java @@ -143,6 +143,7 @@ public class OrderServiceImpl implements OrderService { order.setExceptionStatus(false); order.setCreateTime(new Date()); order.setPayGold(0); + order.setDeductionCouponPrice(new BigDecimal("0")); /*********** 组装处理子订单 商品业务************/ List childOrderList = new ArrayList<>(); @@ -216,13 +217,6 @@ public class OrderServiceImpl implements OrderService { order.setHighChildOrderList(childOrderList); /*********** 组装处理子订单 商品业务************/ - // 计算订单金额 - Map calculateOrderPrice = OrderUtil.calculateOrderPrice(order.getHighChildOrderList()); - order.setTotalPrice(new BigDecimal(calculateOrderPrice.get("totalPrice").toString())); - order.setPayablePrice(new BigDecimal(calculateOrderPrice.get("payablePrice").toString())); - order.setDeductionPrice(order.getTotalPrice().subtract(order.getPayablePrice())); - order.setPayPrice(order.getPayablePrice()); - // 是否使用了优惠券 if (discountUserRel != null) { order.setMemDiscountName(discountUserRel.getHighDiscount().getDiscountName()); @@ -254,7 +248,7 @@ public class OrderServiceImpl implements OrderService { // 订单总额 - 满减额度 BigDecimal payablePrice = order.getTotalPrice().subtract(discountUserRel.getHighDiscount().getDiscountPrice()); - order.setDeductionPrice(discountUserRel.getHighDiscount().getDiscountPrice()); + order.setDeductionCouponPrice(discountUserRel.getHighDiscount().getDiscountPrice()); // 如果总额小于0 if (payablePrice.compareTo(new BigDecimal("0")) < 0) { order.setPayablePrice(new BigDecimal("0")); @@ -265,7 +259,7 @@ public class OrderServiceImpl implements OrderService { else if (discountUserRel.getHighDiscount().getDiscountType() == 2) { // 订单总额 - 满减额度 BigDecimal payablePrice = order.getTotalPrice().subtract(discountUserRel.getHighDiscount().getDiscountPrice()); - order.setDeductionPrice(discountUserRel.getHighDiscount().getDiscountPrice()); + order.setDeductionCouponPrice(discountUserRel.getHighDiscount().getDiscountPrice()); // 如果总额小于0 if (payablePrice.compareTo(new BigDecimal("0")) == -1) { @@ -279,11 +273,18 @@ public class OrderServiceImpl implements OrderService { BigDecimal discountPrice = discountUserRel.getHighDiscount().getDiscountPrice(); // 订单总额 * 折扣 BigDecimal payablePrice = order.getTotalPrice().multiply(discountPrice).setScale(2, BigDecimal.ROUND_HALF_DOWN); - order.setDeductionPrice(order.getTotalPrice().subtract(payablePrice)); + order.setDeductionCouponPrice(order.getTotalPrice().subtract(payablePrice)); order.setPayablePrice(payablePrice); } } + // 计算订单金额 + Map calculateOrderPrice = OrderUtil.calculateOrderPrice(order.getHighChildOrderList()); + order.setTotalPrice(new BigDecimal(calculateOrderPrice.get("totalPrice").toString())); + order.setTotalDeductionPrice(new BigDecimal(calculateOrderPrice.get("deductionPrice").toString()).add(order.getDeductionCouponPrice())); + order.setPayablePrice(order.getTotalPrice().subtract(order.getTotalDeductionPrice())); + order.setPayPrice(order.getPayablePrice()); + // 积分抵扣 if (createOrderModel.getPayGold() != null && createOrderModel.getPayGold().compareTo(0) == 1) { // 查询用户 @@ -599,7 +600,7 @@ public class OrderServiceImpl implements OrderService { criteria.andOrderStatusEqualTo(MapUtils.getInteger(param, "status")); } - example.setOrderByClause("createTime desc"); + example.setOrderByClause("create_time desc"); return orderMapper.selectByExample(example); } } diff --git a/hai-service/src/main/java/com/hai/order/utils/OrderUtil.java b/hai-service/src/main/java/com/hai/order/utils/OrderUtil.java index abac6f7f..ea3e8038 100644 --- a/hai-service/src/main/java/com/hai/order/utils/OrderUtil.java +++ b/hai-service/src/main/java/com/hai/order/utils/OrderUtil.java @@ -1,5 +1,8 @@ package com.hai.order.utils; +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.entity.HighChildOrder; @@ -21,19 +24,25 @@ public class OrderUtil { * @return * @throws Exception */ - public static Map calculateOrderPrice(List childOrderList) throws Exception { + public static Map calculateOrderPrice(List childOrderList) { BigDecimal totalPrice = new BigDecimal("0"); BigDecimal payablePrice = new BigDecimal("0"); + BigDecimal deductionPrice = new BigDecimal("0"); for (HighChildOrder childOrder : childOrderList) { // 不是赠品才会计算金额 if (childOrder.getGiveawayType() == false) { + if (childOrder.getTotalPrice() == null || childOrder.getGoodsActualPrice() == null || childOrder.getTotalDeductionPrice() == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "缺少计算金额"); + } totalPrice = totalPrice.add(childOrder.getTotalPrice()); payablePrice = payablePrice.add(childOrder.getGoodsActualPrice()); + deductionPrice = deductionPrice.add(childOrder.getTotalDeductionPrice()); } } Map param = new HashMap<>(); param.put("totalPrice", totalPrice); param.put("payablePrice", payablePrice); + param.put("deductionPrice", deductionPrice); return param; } diff --git a/hai-service/src/main/java/com/hai/service/HighOrderService.java b/hai-service/src/main/java/com/hai/service/HighOrderService.java index a5088d21..22218d5a 100644 --- a/hai-service/src/main/java/com/hai/service/HighOrderService.java +++ b/hai-service/src/main/java/com/hai/service/HighOrderService.java @@ -236,7 +236,7 @@ public interface HighOrderService { * @Description 根据用户查询订单统计 * @Date 2021/3/27 15:50 **/ - Integer countOrderByUserId(Long memId , Integer status); + Long countOrderByUserId(Long memId , Integer status); /** * @Author 袁野 diff --git a/hai-service/src/main/java/com/hai/service/HighUserService.java b/hai-service/src/main/java/com/hai/service/HighUserService.java index 89d38d05..9adbf653 100644 --- a/hai-service/src/main/java/com/hai/service/HighUserService.java +++ b/hai-service/src/main/java/com/hai/service/HighUserService.java @@ -2,6 +2,8 @@ package com.hai.service; import com.alibaba.fastjson.JSONObject; import com.hai.entity.HighUser; +import com.hai.enum_type.LoginPlatform; +import com.hai.model.HighUserModel; import javax.servlet.http.HttpServletRequest; import java.util.List; @@ -16,6 +18,15 @@ import java.util.Map; */ public interface HighUserService { + /** + * 登录并注册 + * @param platForm 平台 + * @param phone 手机号 + * @param popularizeUserId 手机号 + * @return + * @throws Exception + */ + HighUserModel loginAndRegister(LoginPlatform platForm, String phone, Long popularizeUserId, Map other) throws Exception; /** * 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 2fdf6eaf..9a5427a8 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 @@ -2089,14 +2089,14 @@ public class HighOrderServiceImpl implements HighOrderService { } @Override - public Integer countOrderByUserId(Long memId, Integer status) { + public Long countOrderByUserId(Long memId, Integer status) { HighOrderExample example = new HighOrderExample(); HighOrderExample.Criteria criteria = example.createCriteria(); criteria.andMemIdEqualTo(memId); criteria.andOrderStatusEqualTo(status); - return highOrderMapper.selectByExample(example).size(); + return highOrderMapper.countByExample(example); } @Override @@ -2795,7 +2795,7 @@ public class HighOrderServiceImpl implements HighOrderService { } } - highOrder.setDeductionPrice(discountPrice); + highOrder.setTotalDeductionPrice(discountPrice); highOrder.setPayGold(object.getInteger("integralNum")); highOrder.setTotalPrice(orderPayPrice); diff --git a/hai-service/src/main/java/com/hai/service/impl/HighQzOrderServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighQzOrderServiceImpl.java index c80bc855..73276a8b 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighQzOrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighQzOrderServiceImpl.java @@ -63,7 +63,7 @@ public class HighQzOrderServiceImpl implements HighQzOrderService { highOrder.setPayType(2); highOrder.setPayPrice(data.getBigDecimal("totalPrice")); highOrder.setTotalPrice(data.getBigDecimal("totalPrice")); - highOrder.setDeductionPrice(new BigDecimal("0")); + highOrder.setTotalDeductionPrice(new BigDecimal("0")); highOrder.setOrderStatus(1); highOrder.setCreateTime(data.getDate("createTime")); diff --git a/hai-service/src/main/java/com/hai/service/impl/HighUserServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighUserServiceImpl.java index 884935a7..e8031b7c 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighUserServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighUserServiceImpl.java @@ -4,16 +4,23 @@ 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.security.AESEncodeUtil; import com.hai.common.security.SessionObject; import com.hai.common.security.UserCenter; +import com.hai.common.utils.BaiduUtils; import com.hai.common.utils.DateUtil; +import com.hai.common.utils.HttpsUtils; +import com.hai.common.utils.RequestUtils; import com.hai.dao.HighGoldRecMapper; +import com.hai.dao.HighUserLoginLogMapper; import com.hai.dao.HighUserMapper; import com.hai.entity.*; +import com.hai.enum_type.LoginPlatform; import com.hai.enum_type.OilCardBindStatusEnum; import com.hai.enum_type.UserCardType; import com.hai.model.HighUserModel; import com.hai.service.*; +import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; @@ -65,6 +72,72 @@ public class HighUserServiceImpl implements HighUserService { @Resource private BsDistributionUserRelService distributionUserRelService; + @Resource + private CommonService commonService; + + @Resource + private HighUserLoginLogMapper userLoginLogMapper; + + @Override + @Transactional(propagation = Propagation.REQUIRES_NEW, timeout = 30, rollbackFor = Exception.class) + public HighUserModel loginAndRegister(LoginPlatform platform,String phone, Long popularizeUserId, Map other) throws Exception { + // 记录登录信息 + String requestIp = RequestUtils.getRequestIp(); + HighUserLoginLog loginLog = new HighUserLoginLog(); + loginLog.setUserPhone(phone); + loginLog.setPlatform(platform.getName()); + loginLog.setIp(requestIp); + loginLog.setProvinceName("未知"); + loginLog.setCityName("未知"); + loginLog.setStatus(1); + loginLog.setCreateTime(new Date()); + JSONObject ipResponse = BaiduUtils.ipLocation(requestIp); + if (ipResponse != null && ipResponse.getInteger("status").equals(0)) { + JSONObject ipAddressDetail = ipResponse.getJSONObject("content").getJSONObject("address_detail"); + loginLog.setProvinceName(StringUtils.isBlank(ipAddressDetail.getString("province"))?"未知":ipAddressDetail.getString("province")); + loginLog.setCityName(StringUtils.isBlank(ipAddressDetail.getString("city"))?"未知":ipAddressDetail.getString("city")); + } + + HighUser user = findByPhone(phone); + if (user == null) { + user = new HighUser(); + user.setName("嗨用户"); + user.setPhone(phone); + user.setRegTime(new Date()); + user.setGold(0); + user.setStatus(1); + user.setInfoCompleteStatus(1); // 用户信息完整状态 0:完整 1:需要填写用户信息 2:需要填写手机号 + user.setOpenId(MapUtils.getString(other, "openId")); + user.setUnionId(MapUtils.getString(other, "unionId")); + user.setUnionUnionId(MapUtils.getString(other, "unionUnionId")); + highUserMapper.insert(user); + + // 检查是否有的预留油卡 + HighOilCard oilCard = oilCardService.getOilCardByPhone(user.getPhone()); + if (oilCard != null && oilCard.getBindStatus().equals(OilCardBindStatusEnum.status0.getStatus())) { + highUserCardService.bindCard(UserCardType.type2.getType(), oilCard.getCardNo(), user.getId()); + } + + SecRegion region = commonService.getRegionsByName(loginLog.getProvinceName()); + if (region != null) { + // 绑定推广关联关系 + distributionUserRelService.insertDistributionRebate(user.getId(), popularizeUserId, region.getRegionId().toString()); + } + } + + loginLog.setUserId(user.getId()); + userLoginLogMapper.insert(loginLog); + + // 缓存登录信息 + HighUserModel highUserModel = new HighUserModel(); + highUserModel.setHighUser(getDetailDataByUser(user.getId())); + SessionObject so = new SessionObject(AESEncodeUtil.base64Encode(AESEncodeUtil.aesEncryptToBytes(user.getPhone(), "123")), 1 , highUserModel); + so.setType(1); + userCenter.save(null,null,so); + + return highUserModel; + } + @Override public List getListUser(Map map) { HighUserExample example = new HighUserExample(); diff --git a/hai-user/pom.xml b/hai-user/pom.xml new file mode 100644 index 00000000..9f43f22b --- /dev/null +++ b/hai-user/pom.xml @@ -0,0 +1,61 @@ + + + + com.hai + hai-parent + 1.0-SNAPSHOT + + 4.0.0 + + com.hsg + hai-user + + + + com.hai + hai-service + PACKT-SNAPSHOT + + + com.alibaba.csp + sentinel-core + 1.8.2 + + + com.alibaba.csp + sentinel-transport-simple-http + 1.8.2 + + + com.alibaba.csp + sentinel-web-servlet + 1.8.2 + + + + + + + src/main/resources/${env} + false + + + + + org.apache.maven.plugins + maven-surefire-plugin + + true + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + + diff --git a/hai-user/src/main/java/com/UserApplication.java b/hai-user/src/main/java/com/UserApplication.java new file mode 100644 index 00000000..4f4dc28b --- /dev/null +++ b/hai-user/src/main/java/com/UserApplication.java @@ -0,0 +1,30 @@ +package com; + +import com.alicp.jetcache.anno.config.EnableCreateCacheAnnotation; +import com.alicp.jetcache.anno.config.EnableMethodCache; +import com.hai.common.utils.SpringContextUtil; +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.ServletComponentScan; +import org.springframework.context.ApplicationContext; +import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +@SpringBootApplication +//@ComponentScan +@EnableTransactionManagement +@EnableScheduling +@EnableMethodCache(basePackages = "com.hai") +@EnableCreateCacheAnnotation +@ServletComponentScan +@MapperScan("com.hai.dao") +public class UserApplication +{ + public static void main( String[] args ) + { + ApplicationContext app = SpringApplication.run(UserApplication.class, args); + SpringContextUtil.setApplicationContext(app); + } + +} diff --git a/hai-user/src/main/java/com/web/config/AuthConfig.java b/hai-user/src/main/java/com/web/config/AuthConfig.java new file mode 100644 index 00000000..0f8cd206 --- /dev/null +++ b/hai-user/src/main/java/com/web/config/AuthConfig.java @@ -0,0 +1,85 @@ +package com.web.config; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.module.SimpleModule; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import com.hai.common.security.UserCenter; +import com.hai.common.utils.RequestUtils; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.converter.HttpMessageConverter; +import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; +import org.springframework.web.multipart.support.StandardMultipartHttpServletRequest; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.List; + +@Configuration +public class AuthConfig implements WebMvcConfigurer { + + private static Logger log = LoggerFactory.getLogger(AuthConfig.class); + + @Resource + private UserCenter userCenter; + + /** + * 获取配置文件debug变量 + */ + @Value("${debug}") + private boolean debug = false; + + /** + * 解决18位long类型数据转json失去精度问题 + * @param converters + */ + @Override + public void configureMessageConverters(List> converters){ + MappingJackson2HttpMessageConverter jsonConverter = new MappingJackson2HttpMessageConverter(); + + ObjectMapper objectMapper = jsonConverter.getObjectMapper(); + SimpleModule simpleModule = new SimpleModule(); + simpleModule.addSerializer(Long.class, ToStringSerializer.instance); + simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance); + objectMapper.registerModule(simpleModule); + + converters.add(jsonConverter); + } + + public void addInterceptors(InterceptorRegistry registry) { + registry.addInterceptor(new HandlerInterceptorAdapter() { + + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, + Object handler) throws Exception { + if(debug){ + return true; + } + String token = request.getHeader("Authorization"); + if (StringUtils.isNotBlank(token)) { + if(userCenter.isLogin(request) == true) { + return true; + } + } + log.error("the user is not logged in,remoteAddr:"+ RequestUtils.getIpAddress(request)+",requestUrl:"+request.getRequestURL()); + response.setStatus(401); + return false; + } + }) + .addPathPatterns("/**") + .excludePathPatterns("/swagger-resources/**") + .excludePathPatterns("/**/api-docs") + .excludePathPatterns("/**/springfox-swagger-ui/**") + .excludePathPatterns("/**/swagger-ui.html") + .excludePathPatterns("/login/*") + .excludePathPatterns("/sms/*") + ; + } +} diff --git a/hai-user/src/main/java/com/web/config/ConfigListener.java b/hai-user/src/main/java/com/web/config/ConfigListener.java new file mode 100644 index 00000000..f2ad9491 --- /dev/null +++ b/hai-user/src/main/java/com/web/config/ConfigListener.java @@ -0,0 +1,23 @@ +package com.web.config; + +import javax.annotation.Resource; +import javax.servlet.ServletContextEvent; +import javax.servlet.ServletContextListener; +import javax.servlet.annotation.WebListener; + +@WebListener +public class ConfigListener implements ServletContextListener { + + @Resource + private SysConfig sysConfig; + + @Override + public void contextInitialized(ServletContextEvent sce) { + SysConst.setSysConfig(sysConfig); + } + + @Override + public void contextDestroyed(ServletContextEvent sce) { + } + +} diff --git a/hai-user/src/main/java/com/web/config/CorsConfig.java b/hai-user/src/main/java/com/web/config/CorsConfig.java new file mode 100644 index 00000000..ad0aaeae --- /dev/null +++ b/hai-user/src/main/java/com/web/config/CorsConfig.java @@ -0,0 +1,49 @@ +package com.web.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.cors.CorsConfiguration; +import org.springframework.web.cors.UrlBasedCorsConfigurationSource; +import org.springframework.web.filter.CorsFilter; +import org.springframework.web.servlet.config.annotation.CorsRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; + +import java.util.ArrayList; +import java.util.List; + +/** + * @ClassName CorsConfig + * @Description: TODO () + * @Author 胡锐 + * @Date 2020/12/16 + **/ +@Configuration +public class CorsConfig extends WebMvcConfigurerAdapter { + @Override + public void addCorsMappings(CorsRegistry registry) { + registry.addMapping("/**") + .allowedOrigins("*") + .allowCredentials(true) + .allowedMethods("GET", "POST", "DELETE", "PUT") + .maxAge(3600); + } + private CorsConfiguration buildConfig() { + CorsConfiguration corsConfiguration = new CorsConfiguration(); + List list = new ArrayList<>(); + list.add("*"); + corsConfiguration.setAllowedOrigins(list); + /* + // 请求常用的三种配置,*代表允许所有,当时你也可以自定义属性(比如header只能带什么,只能是post方式等等) + */ + corsConfiguration.addAllowedOrigin("*"); + corsConfiguration.addAllowedHeader("*"); + corsConfiguration.addAllowedMethod("*"); + return corsConfiguration; + } + @Bean + public CorsFilter corsFilter() { + UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); + source.registerCorsConfiguration("/**", buildConfig()); + return new CorsFilter(source); + } +} diff --git a/hai-user/src/main/java/com/web/config/MultipartConfig.java b/hai-user/src/main/java/com/web/config/MultipartConfig.java new file mode 100644 index 00000000..e38f7afc --- /dev/null +++ b/hai-user/src/main/java/com/web/config/MultipartConfig.java @@ -0,0 +1,26 @@ +package com.web.config; + +import org.springframework.boot.web.servlet.MultipartConfigFactory; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import javax.servlet.MultipartConfigElement; + +@Configuration +public class MultipartConfig { + + /** + * 文件上传配置 + * @return + */ + @Bean + public MultipartConfigElement multipartConfigElement() { + MultipartConfigFactory factory = new MultipartConfigFactory(); + //文件最大 + factory.setMaxFileSize("300MB"); //KB,MB + //设置总上传数据总大小 + factory.setMaxRequestSize("350MB"); + return factory.createMultipartConfig(); + } + +} diff --git a/hai-user/src/main/java/com/web/config/RedisConfig.java b/hai-user/src/main/java/com/web/config/RedisConfig.java new file mode 100644 index 00000000..179a555b --- /dev/null +++ b/hai-user/src/main/java/com/web/config/RedisConfig.java @@ -0,0 +1,110 @@ +package com.web.config; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.PropertyAccessor; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.springframework.cache.annotation.CachingConfigurerSupport; +import org.springframework.cache.annotation.EnableCaching; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.redis.connection.RedisConnectionFactory; +import org.springframework.data.redis.core.*; +import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; +import org.springframework.data.redis.serializer.StringRedisSerializer; + + +@Configuration +@EnableCaching //开启注解 +public class RedisConfig extends CachingConfigurerSupport { + + /** + * retemplate相关配置 + * @param factory + * @return + */ + @Bean + public RedisTemplate redisTemplate(RedisConnectionFactory factory) { + + RedisTemplate template = new RedisTemplate<>(); + // 配置连接工厂 + template.setConnectionFactory(factory); + + //使用Jackson2JsonRedisSerializer来序列化和反序列化redis的value值(默认使用JDK的序列化方式) + Jackson2JsonRedisSerializer jacksonSeial = new Jackson2JsonRedisSerializer(Object.class); + + ObjectMapper om = new ObjectMapper(); + // 指定要序列化的域,field,get和set,以及修饰符范围,ANY是都有包括private和public + om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); + // 指定序列化输入的类型,类必须是非final修饰的,final修饰的类,比如String,Integer等会跑出异常 + om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL); + jacksonSeial.setObjectMapper(om); + + // 值采用json序列化 + template.setValueSerializer(jacksonSeial); + //使用StringRedisSerializer来序列化和反序列化redis的key值 + template.setKeySerializer(new StringRedisSerializer()); + + // 设置hash key 和value序列化模式 + template.setHashKeySerializer(new StringRedisSerializer()); + template.setHashValueSerializer(jacksonSeial); + template.afterPropertiesSet(); + + return template; + } + + /** + * 对hash类型的数据操作 + * + * @param redisTemplate + * @return + */ + @Bean + public HashOperations hashOperations(RedisTemplate redisTemplate) { + return redisTemplate.opsForHash(); + } + + /** + * 对redis字符串类型数据操作 + * + * @param redisTemplate + * @return + */ + @Bean + public ValueOperations valueOperations(RedisTemplate redisTemplate) { + return redisTemplate.opsForValue(); + } + + /** + * 对链表类型的数据操作 + * + * @param redisTemplate + * @return + */ + @Bean + public ListOperations listOperations(RedisTemplate redisTemplate) { + return redisTemplate.opsForList(); + } + + /** + * 对无序集合类型的数据操作 + * + * @param redisTemplate + * @return + */ + @Bean + public SetOperations setOperations(RedisTemplate redisTemplate) { + return redisTemplate.opsForSet(); + } + + /** + * 对有序集合类型的数据操作 + * + * @param redisTemplate + * @return + */ + @Bean + public ZSetOperations zSetOperations(RedisTemplate redisTemplate) { + return redisTemplate.opsForZSet(); + } + +} diff --git a/hai-user/src/main/java/com/web/config/SentinelFilterConfig.java b/hai-user/src/main/java/com/web/config/SentinelFilterConfig.java new file mode 100644 index 00000000..0622bdf0 --- /dev/null +++ b/hai-user/src/main/java/com/web/config/SentinelFilterConfig.java @@ -0,0 +1,23 @@ +package com.web.config; + +import com.alibaba.csp.sentinel.adapter.servlet.CommonFilter; +import org.springframework.boot.web.servlet.FilterRegistrationBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import javax.servlet.Filter; + +@Configuration +public class SentinelFilterConfig { + + @Bean + public FilterRegistrationBean sentinelFilterRegistration() { + FilterRegistrationBean registration = new FilterRegistrationBean<>(); + registration.setFilter(new CommonFilter()); + registration.addUrlPatterns("/*"); + registration.setName("sentinelFilter"); + registration.setOrder(1); + + return registration; + } +} diff --git a/hai-user/src/main/java/com/web/config/SwaggerConfig.java b/hai-user/src/main/java/com/web/config/SwaggerConfig.java new file mode 100644 index 00000000..02caa7a8 --- /dev/null +++ b/hai-user/src/main/java/com/web/config/SwaggerConfig.java @@ -0,0 +1,47 @@ +package com.web.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Contact; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +/** +* SwaggerConfig.java +* 项目名称: +* 包: +* 类名称: SwaggerConfig.java +* 类描述: 构建restful api接口文档 +* 创建人: +* 创建时间: 2017 下午4:23:45 +*/ +@Configuration +@EnableSwagger2 +public class SwaggerConfig +{ + + /** + * 描述api的基本信息 + * 基本信息会展现在文档页面中 + * @return [api的基本信息] + */ + ApiInfo apiInfo() + { + return new ApiInfoBuilder().title("hsg-order").description("订单业务接口").termsOfServiceUrl("").version("1.0.0") + .contact(new Contact("", "", "")).build(); + } + + @Bean + public Docket customImplementation() + { + return new Docket(DocumentationType.SWAGGER_2).select() + .apis(RequestHandlerSelectors.basePackage("com")) + .build().directModelSubstitute(org.joda.time.LocalDate.class, java.sql.Date.class) + .directModelSubstitute(org.joda.time.DateTime.class, java.util.Date.class).apiInfo(apiInfo()); + } + +} diff --git a/hai-user/src/main/java/com/web/config/SysConfig.java b/hai-user/src/main/java/com/web/config/SysConfig.java new file mode 100644 index 00000000..eacb4c64 --- /dev/null +++ b/hai-user/src/main/java/com/web/config/SysConfig.java @@ -0,0 +1,21 @@ +package com.web.config; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.PropertySource; +import org.springframework.stereotype.Component; + +@Component("sysConfig") +@ConfigurationProperties +@PropertySource("classpath:/config.properties") +@Data +public class SysConfig { + + private String fileUrl; + + // 微信小程序Appid + private String wxMiniAppId; + // 微信小程序appSecret + private String wxMiniAppSecret; + +} diff --git a/hai-user/src/main/java/com/web/config/SysConst.java b/hai-user/src/main/java/com/web/config/SysConst.java new file mode 100644 index 00000000..cad41bc7 --- /dev/null +++ b/hai-user/src/main/java/com/web/config/SysConst.java @@ -0,0 +1,19 @@ +package com.web.config; + +public class SysConst { + + private static SysConfig sysConfig; + + public static void setSysConfig(SysConfig arg){ + sysConfig = arg; + } + + public static SysConfig getSysConfig(){ + if (null == sysConfig) { + //防止空指针异常 + sysConfig = new SysConfig(); + return sysConfig; + } + return sysConfig; + } +} diff --git a/hai-user/src/main/java/com/web/config/WxMaConfiguration.java b/hai-user/src/main/java/com/web/config/WxMaConfiguration.java new file mode 100644 index 00000000..c960714d --- /dev/null +++ b/hai-user/src/main/java/com/web/config/WxMaConfiguration.java @@ -0,0 +1,31 @@ +package com.web.config; + +import cn.binarywang.wx.miniapp.api.WxMaService; +import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl; +import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl; +import org.springframework.context.annotation.Configuration; + +import javax.annotation.PostConstruct; + +@Configuration +public class WxMaConfiguration { + + private static WxMaService maService; + + public static WxMaService getMaService() { + if (maService == null) { + throw new IllegalArgumentException(String.format("未找到对应的配置,请核实!")); + } + return maService; + } + + @PostConstruct + public void init() { + WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl(); + config.setAppid(SysConst.getSysConfig().getWxMiniAppId()); + config.setSecret(SysConst.getSysConfig().getWxMiniAppSecret()); + maService = new WxMaServiceImpl(); + maService.setWxMaConfig(config); + } + +} diff --git a/hai-user/src/main/java/com/web/controller/CoresController.java b/hai-user/src/main/java/com/web/controller/CoresController.java new file mode 100644 index 00000000..3ac133c6 --- /dev/null +++ b/hai-user/src/main/java/com/web/controller/CoresController.java @@ -0,0 +1,75 @@ +package com.web.controller; + +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.security.UserCenter; +import com.hai.common.utils.MemberValidateUtil; +import com.hai.common.utils.RedisUtil; +import com.hai.common.utils.ResponseMsgUtil; +import com.hai.enum_type.LoginPlatform; +import com.hai.enum_type.RedisFileFolder; +import com.hai.model.HighUserModel; +import com.hai.model.ResponseData; +import com.hai.model.UserInfoModel; +import com.hai.service.HighUserService; +import com.web.type.LoginType; +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; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.HashMap; + +/** + * @className: CoresController + * @author: HuRui + * @date: 2022/10/21 + **/ + +@Controller +@RequestMapping(value = "/cores") +@Api(value = "用户核心业务") +public class CoresController { + + private static Logger log = LoggerFactory.getLogger(CoresController.class); + + @Resource + private RedisUtil redisUtil; + + @Resource + private HighUserService userService; + + @Resource + private UserCenter userCenter; + + @RequestMapping(value = "/outLogin", method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "退出登录") + public ResponseData outLogin(HttpServletRequest request, HttpServletResponse response) { + try { + HighUserModel userInfoModel = userCenter.getSessionModel(HighUserModel.class); + if (userInfoModel == null) { + log.error("CoresController --> outLogin() error!", "用户身份错误或已过期"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.SEC_USER_EXPIRED, ""); + } + userCenter.remove(request, response); + return ResponseMsgUtil.success("退出登录成功"); + + } catch (Exception e) { + log.error("CoresController --> outLogin() error!", e); + return ResponseMsgUtil.exception(e); + } + } + +} diff --git a/hai-user/src/main/java/com/web/controller/LoginController.java b/hai-user/src/main/java/com/web/controller/LoginController.java new file mode 100644 index 00000000..a484df79 --- /dev/null +++ b/hai-user/src/main/java/com/web/controller/LoginController.java @@ -0,0 +1 @@ +package com.web.controller; import cn.binarywang.wx.miniapp.api.WxMaService; import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo; 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.security.SessionObject; import com.hai.common.utils.*; import com.hai.config.UnionUserConfig; import com.hai.entity.HighUser; import com.hai.enum_type.LoginPlatform; import com.hai.model.HighUserModel; import com.hai.model.ResponseData; import com.hai.service.HighUserService; import com.web.config.WxMaConfiguration; import com.web.type.LoginType; import com.hai.enum_type.RedisFileFolder; 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; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.util.Date; import java.util.HashMap; import java.util.Map; /** * @Auther: 胡锐 * @Description: * @Date: 2021/3/26 23:08 */ @Controller @RequestMapping(value = "/login") @Api(value = "登录业务") public class LoginController { private static Logger log = LoggerFactory.getLogger(LoginController.class); @Resource private RedisUtil redisUtil; @Resource private HighUserService userService; @Resource private WxMaConfiguration wxMaConfiguration; @Resource private UnionUserConfig unionUserConfig; @RequestMapping(value = "/phone", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "手机号登录") public ResponseData phone(@RequestBody JSONObject body) { try { if (body == null || StringUtils.isBlank(body.getString("platform")) || StringUtils.isBlank(body.getString("type")) || StringUtils.isBlank(body.getString("phone")) ) { log.error("LoginController --> phone() error!", "请求参数校验失败"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } String phone = body.getString("phone"); // 客户端 LoginPlatform platform = LoginPlatform.getDataByType(body.getString("platform")); if (platform == null) { log.error("LoginController --> phone() error!", "未知客户端"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知客户端"); } // 校验手机号格式 if (MemberValidateUtil.validatePhone(phone) == false) { log.error("LoginController --> phone() error!", "请输入正确的手机号"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请输入正确的手机号"); } // 登录类型 LoginType loginType = LoginType.getDataByType(body.getString("type")); if (loginType == null) { log.error("LoginController --> phone() error!", "未知登录类型;" + body.getString("type")); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知登录类型"); } if (body.getString("type").equals(LoginType.SMS.getCode())) { if (StringUtils.isBlank(body.getString("smsCode"))) { log.error("LoginController --> phone() error!", "请输入短信验证码"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请输入短信验证码"); } // 手机号的验证码 Object phoneCodeObject = redisUtil.get(RedisFileFolder.SMS_CODE.getCode() + phone); if (phoneCodeObject == null) { log.error("LoginController --> phone() error!", "短信验证码错误"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "短信验证码错误"); } if (!body.getString("smsCode").equals(phoneCodeObject.toString())) { log.error("LoginController --> phone() error!", "短信验证码错误"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "短信验证码错误"); } // redisUtil.del(RedisFileFolder.SMS_CODE.getCode() + phone); return ResponseMsgUtil.success(userService.loginAndRegister(platform, phone, body.getLong("popularizeUserId"), new HashMap<>())); } throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "登录失败"); } catch (Exception e) { log.error("LoginController --> phone() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/wxMiniHandleCode", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "微信小程序code解析") public ResponseData wxMiniHandleCode(@RequestBody JSONObject body) { try { if (body == null|| StringUtils.isBlank(body.getString("code"))) { log.error("LoginController --> phone() error!", "请求参数校验失败"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } //请求微信api,获取用户session_key以及openId WxMaJscode2SessionResult session = WxMaConfiguration.getMaService().jsCode2SessionInfo(body.getString("code")); //保存小程序用户登录的openId及sessionKey信息 redisUtil.hset("WX_OPENID_SESSION_REDIS", session.getOpenid(), session); JSONObject jo = new JSONObject(); jo.put("openId", session.getOpenid()); return ResponseMsgUtil.success(jo); } catch (Exception e) { return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/wxMini", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "微信小程序") public ResponseData wxMini(@RequestBody JSONObject body) { try { if (body == null || StringUtils.isBlank(body.getString("encryptedData")) || StringUtils.isBlank(body.getString("iv")) || StringUtils.isBlank(body.getString("openId"))) { log.error("LoginController --> phone() error!", "请求参数校验失败"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } String encryptedData = body.getString("encryptedData").replace(" ", "+"); String iv = body.getString("iv").replace(" ", "+"); //请求微信api,获取用户session_key以及openId Object skObject = redisUtil.hget("WX_OPENID_SESSION_REDIS", body.getString("openId")); if (skObject == null) { throw ErrorHelp.genException(SysCode.MiniProgram, ErrorCode.WECHAT_LOGIN_ERROR); } WxMaJscode2SessionResult session = (WxMaJscode2SessionResult) skObject; WxMaPhoneNumberInfo phoneNoInfo = WxMaConfiguration .getMaService() .getUserService() .getPhoneNoInfo(session.getSessionKey(), encryptedData, iv); if (phoneNoInfo == null || StringUtils.isEmpty(phoneNoInfo.getPurePhoneNumber())) { log.error("LoginController --> wxMini() error!", "登录失败! 用户手机号解析失败"); throw ErrorHelp.genException(SysCode.MiniProgram, ErrorCode.WECHAT_DECRYPT_ERROR, "登录失败! 用户手机号解析失败"); } Map other = new HashMap<>(); other.put("openId", session.getOpenid()); return ResponseMsgUtil.success(userService.loginAndRegister(LoginPlatform.WXAPPLETS, phoneNoInfo.getPurePhoneNumber(), body.getLong("popularizeUserId"), other)); } catch (Exception e) { log.error("LoginController --> wxMini() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/union", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "银联授权手机号登录接口") public ResponseData union(@RequestBody JSONObject body) { try { if (body == null || StringUtils.isBlank(body.getString("code"))) { log.error("LoginController --> phone() error!", "请求参数校验失败"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } // 获取应用访问令牌 String backendToken = unionUserConfig.getBackendToken(); // 获取授权访问令牌 JSONObject token = unionUserConfig.getAccessToken(backendToken, body.getString("code")); if (token == null || !token.getString("resp").equals("00")) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, token.getString("msg")); } // 获取用户手机号 JSONObject userMobile = unionUserConfig.getUserMobile(backendToken, token.getJSONObject("params").getString("accessToken"), token.getJSONObject("params").getString("openId")); if (userMobile == null || !userMobile.getString("resp").equals("00")) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, userMobile.getString("msg")); } // 解密,获取手机号 String mobile = UnionUtils.getDecryptedValue(userMobile.getJSONObject("params").getString("mobile"), unionUserConfig.getRsaKey()); Map other = new HashMap<>(); other.put("unionId", token.getJSONObject("params").getString("openId")); other.put("unionUnionId", token.getJSONObject("params").getString("unionId")); return ResponseMsgUtil.success(userService.loginAndRegister(LoginPlatform.UNIONPAY, mobile, body.getLong("popularizeUserId"), other)); } catch (Exception e) { return ResponseMsgUtil.exception(e); } } } \ No newline at end of file diff --git a/hai-user/src/main/java/com/web/controller/SmsController.java b/hai-user/src/main/java/com/web/controller/SmsController.java new file mode 100644 index 00000000..72ec6d62 --- /dev/null +++ b/hai-user/src/main/java/com/web/controller/SmsController.java @@ -0,0 +1 @@ +package com.web.controller; 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.MemberValidateUtil; import com.hai.common.utils.RedisUtil; import com.hai.common.utils.ResponseMsgUtil; import com.hai.config.MessageConfig; import com.hai.model.ResponseData; import com.hai.service.HighUserService; import com.hai.enum_type.RedisFileFolder; 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; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import javax.annotation.Resource; import java.util.Random; /** * @Auther: 胡锐 * @Description: * @Date: 2021/3/26 23:08 */ @Controller @RequestMapping(value = "/sms") @Api(value = "短信服务") public class SmsController { private static Logger log = LoggerFactory.getLogger(SmsController.class); @Resource private RedisUtil redisUtil; @Resource private HighUserService userService; @RequestMapping(value = "/getLoginSMSCode", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "获取登录验证码") public ResponseData getLoginSMSCode(@RequestBody JSONObject body) { try { if (body == null || StringUtils.isBlank(body.getString("phone"))) { log.error("LoginController --> phone() error!", "请求参数校验失败"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } String phone = body.getString("phone"); // 校验手机号格式 if (MemberValidateUtil.validatePhone(phone) == false) { log.error("LoginController --> phone() error!", "请输入正确的手机号"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请输入正确的手机号"); } // 生成随机6位验证码 String smsCode = String.valueOf(new Random().nextInt(899999) + 100000); MessageConfig.req(phone,smsCode, MessageConfig.HWMSG_ID5); redisUtil.set(RedisFileFolder.SMS_CODE.getCode()+phone, smsCode, 60*5); return ResponseMsgUtil.success("短信发送成功"); } catch (Exception e) { log.error("SMSController --> getLoginSMSCode() error!", e); return ResponseMsgUtil.exception(e); } } } \ No newline at end of file diff --git a/hai-user/src/main/java/com/web/controller/TestController.java b/hai-user/src/main/java/com/web/controller/TestController.java new file mode 100644 index 00000000..5bef80c0 --- /dev/null +++ b/hai-user/src/main/java/com/web/controller/TestController.java @@ -0,0 +1 @@ +package com.web.controller; import com.hai.common.utils.DateUtil; import com.hai.common.utils.RedisUtil; import com.hai.common.utils.ResponseMsgUtil; import com.hai.entity.HighOrder; import com.hai.model.ResponseData; import com.hai.order.model.CreateOrderModel; import com.hai.order.service.OrderService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.rocketmq.spring.core.RocketMQTemplate; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import javax.annotation.Resource; import java.util.Date; /** * @Auther: 胡锐 * @Description: * @Date: 2021/3/26 23:08 */ @Controller @RequestMapping(value = "/test") @Api(value = "订单接口") public class TestController { private static Logger log = LoggerFactory.getLogger(TestController.class); @Autowired private RocketMQTemplate rocketMQTemplate; @Resource private OrderService orderService; @Resource private RedisUtil redisUtil; @Autowired private RedisTemplate redisTemplate; @RequestMapping(value = "/q", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "") public ResponseData q(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOrder order = orderService.getOrderDetailByNo(orderNo); if (order != null) { orderService.refundOrder(orderNo, DateUtil.date2String(new Date(), "yyyy-MM-dd HH:mm:ss")); // order.setRefundTime(new Date()); // orderService.updateOrderData(order); return ResponseMsgUtil.success("修改成功"); } return ResponseMsgUtil.success(null); } catch (Exception e) { log.error("HighUserCardController --> rocketMq() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/rocketMq", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "") public ResponseData rocketMq(@RequestParam(name = "topicGroup", required = true) String topicGroup, @RequestParam(name = "body", required = true) String body) { try { long startTime = System.currentTimeMillis(); // org.springframework.messaging.Message message = MessageBuilder.withPayload(order).build(); CreateOrderModel createOrder = new CreateOrderModel(); //发送对象消息 HighOrder order = rocketMQTemplate.sendAndReceive("order-topic:create", createOrder, HighOrder.class); System.out.println("订单号:" + order.getOrderNo()); // SendResult sendResult = rocketMQTemplate.syncSend("order-topic:create", message, 3000); /*List list = new LinkedList<>(); for (int i = 0; i <= 100;i++) { list.add(orderService.getDetailByOrderNo("HF2022080918014365701")); *//* list.add(orderService.getDetailByOrderNo("HF2022080918014365701"));*//* *//* updateUserWithRedisLock("coupon_" + couponKey, i+""); new Thread(() -> {*//* *//* redisTemplate.opsForValue().setIfAbsent("coupon_" + couponKey, i); System.out.println("加入数据" + i);*//* // redisTemplate.delete("coupon" + couponKey); // System.out.println("释放数据" + index); *//* });*//* }*/ System.out.println(System.currentTimeMillis() - startTime); return ResponseMsgUtil.success(null); } catch (Exception e) { log.error("HighUserCardController --> rocketMq() error!", e); return ResponseMsgUtil.exception(e); } } public void updateUserWithRedisLock(String couponKey, String value) throws InterruptedException { // 占分布式锁,去redis占坑 // 1. 分布式锁占坑 Boolean lock = redisTemplate.opsForValue().setIfAbsent("coupon" + couponKey, value); if(lock) { //加锁成功... // todo business System.out.println("加锁成功: " + value); redisTemplate.delete("coupon" + couponKey); //删除key,释放锁 } else { System.out.println("加锁失败"); /* Thread.sleep(100); // 加锁失败,重试 updateUserWithRedisLock("sysUser");*/ } } } \ No newline at end of file diff --git a/hai-user/src/main/java/com/web/type/LoginType.java b/hai-user/src/main/java/com/web/type/LoginType.java new file mode 100644 index 00000000..dd949857 --- /dev/null +++ b/hai-user/src/main/java/com/web/type/LoginType.java @@ -0,0 +1,51 @@ +package com.web.type; + +import java.util.Objects; + +/** + * 登录方式 + * @className: LoginType + * @author: HuRui + * @date: 2022/10/20 + **/ +public enum LoginType { + SMS("SMS", "短信登录"), + ; + + private String code; + + private String name; + + LoginType(String code, String name) { + this.code = code; + this.name = name; + } + + /** + * 根据类型查询数据 + * @param code + * @return + */ + public static LoginType getDataByType(String code) { + for (LoginType ele : values()) { + if(Objects.equals(code,ele.getCode())) return ele; + } + return null; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/hai-user/src/main/resources/dev/application.yml b/hai-user/src/main/resources/dev/application.yml new file mode 100644 index 00000000..b57983f1 --- /dev/null +++ b/hai-user/src/main/resources/dev/application.yml @@ -0,0 +1,102 @@ +server: + port: 9305 + servlet: + context-path: /user + +#配置是否为debug模式,debug模式下,不开启权限校验 +debug: false + +#datasource数据源设置 +spring: + datasource: + url: jdbc:mysql://139.159.177.244:3306/hsg_order?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false + username: root + password: HF123456. + type: com.alibaba.druid.pool.DruidDataSource + driver-class-name: com.mysql.jdbc.Driver + filters: stat + maxActive: 10 + initialSize: 5 + maxWait: 60000 + minIdle: 5 + timeBetweenEvictionRunsMillis: 60000 + minEvictableIdleTimeMillis: 300000 + validationQuery: select 'x' + testWhileIdle: true + testOnBorrow: false + testOnReturn: false + poolPreparedStatements: true + maxOpenPreparedStatements: 20 + redis: + database: 0 + host: 139.159.177.244 + port: 36379 + password: HF123456.Redis + timeout: 1000 + jedis: + pool: + max-active: 20 + max-wait: -1 + max-idle: 10 + min-idle: 0 + #MQTT配置信息 + mqtt: + #MQTT服务地址 + url: ws://139.159.177.244:8083/mqtt + #用户名 + username: printer_provider + #密码 + password: 123654 + #客户端id(不能重复) + # client: + # id: provider-id + #MQTT默认的消息推送主题,实际可在调用接口是指定 + # default: + # topic: topic +rocketmq: + name-server: 139.159.177.244:9876 + producer: + #必须指定group + group: default-group + + #配置日期返回至前台为时间戳 + jackson: + serialization: + write-dates-as-timestamps: true +mybatis: + mapperLocations: + - classpath*:sqlmap*/*.xml + type-aliases-package: + org.springboot.sample.entity + configuration: + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl + #开启MyBatis的二级缓存 + cache-enabled: true + +jetcache: + statIntervalMinutes: 15 + areaInCacheName: false + local: + default: + type: linkedhashmap + keyConvertor: fastjson + remote: + default: + type: redis + host: 139.159.177.244 + port: 36379 + password: HF123456.Redis + keyConvertor: fastjson + broadcastChannel: projectA + valueEncoder: java + valueDecoder: java + poolConfig: + minIdle: 5 + maxIdle: 20 + maxTotal: 50 + +pagehelper: + helperDialect: mysql + reasonable: true + supportMethodsArguments: true + params: count=countSql diff --git a/hai-user/src/main/resources/dev/config.properties b/hai-user/src/main/resources/dev/config.properties new file mode 100644 index 00000000..64ff8af1 --- /dev/null +++ b/hai-user/src/main/resources/dev/config.properties @@ -0,0 +1,27 @@ +# \u03A2\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD +wxAppId=wx8d49e2f83025229d +wxAppSecret=d8d6dcaef77d3b659258a01b5ddba5df + +wxH5AppId=wxa075e8509802f826 +wxH5AppSecret=0e606fc1378d35e359fcf3f15570b2c5 + +wxApiKey=Skufk5oi85wDFGl888i6wsRSTkdd5df5 +wxMchAppId=wx637bd6f7314daa46 +wxMchId=1289663601 +wxSubAppId=wx8d49e2f83025229d +wxSubMchId=1609882817 +wxUnifiedOrderUrl=https://api.mch.weixin.qq.com/pay/unifiedorder +wxGzSubAppId=wxa075e8509802f826 +wxGzSubMchId=1619676214 + +# ???????????? +HDAppId = 1614670195 + +notifyUrl=https://hsgcs.dctpay.com/crest/wechatpay/notify +imgUrl=https://hsgcs.dctpay.com/filesystem/ + +fileUrl=/home/project/hsg/filesystem +cmsPath=/home/project/hsg/filesystem/cmsPath +couponCodePath=/home/project/hsg/filesystem/couponCode + +qrCodeUrl=https://hsgcs.dctpay.com/hsgH5?accountId=0000010&key=&code= diff --git a/hai-user/src/main/resources/dev/logback.xml b/hai-user/src/main/resources/dev/logback.xml new file mode 100644 index 00000000..8d23e06c --- /dev/null +++ b/hai-user/src/main/resources/dev/logback.xml @@ -0,0 +1,93 @@ + + + + + %d %p (%file:%line\)- %m%n + UTF-8 + + + + log/base.log + + log/base.log.%d.%i + + + 64 MB + + + + + %d %p (%file:%line\)- %m%n + + UTF-8 + + + + log/dao.log + + log/dao.log.%d.%i + + + 64 MB + + + + + %d %p (%file:%line\)- %m%n + + UTF-8 + + + + log/error.log + + log/error.log.%d.%i + + + 64 MB + + + + + %d %p (%file:%line\)- %m%n + + UTF-8 + + + + + + + + + + + + + + + + + + log/ChongQingCNPCService.log + + log/ChongQingCNPCService.log.%d.%i + + + 64 MB + + + + + %d %p (%file:%line\)- %m%n + + UTF-8 + + + + + + diff --git a/pom.xml b/pom.xml index a0f74f18..d1d1a8c2 100644 --- a/pom.xml +++ b/pom.xml @@ -68,6 +68,7 @@ hai-order hai-msg v1 + hai-user From 70ce2b2526069b7f77c9b1b868727236fcb1b56d Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Mon, 24 Oct 2022 17:35:56 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../business/OrderOilController.java | 2 +- .../java/com/hai/dao/HighGasOrderMapper.java | 124 ++++----- .../com/hai/dao/HighGasOrderSqlProvider.java | 58 ++++- .../hai/dao/HighMerchantAccountMapperExt.java | 9 +- .../java/com/hai/entity/HighGasOrder.java | 66 ++++- .../com/hai/entity/HighGasOrderExample.java | 238 ++++++++++++++++-- .../impl/OrderCreateHandleServiceImpl.java | 19 +- .../hai/service/impl/HighUserServiceImpl.java | 1 - .../main/java/com/web/config/AuthConfig.java | 100 +++++--- .../com/web/controller/CoresController.java | 75 ++++++ 10 files changed, 551 insertions(+), 141 deletions(-) diff --git a/hai-order/src/main/java/com/web/controller/business/OrderOilController.java b/hai-order/src/main/java/com/web/controller/business/OrderOilController.java index 270c9a6c..eee3ec02 100644 --- a/hai-order/src/main/java/com/web/controller/business/OrderOilController.java +++ b/hai-order/src/main/java/com/web/controller/business/OrderOilController.java @@ -293,7 +293,7 @@ public class OrderOilController { model.setGasPricePlatform(gasOrder.getGasPricePlatform()); model.setGasPriceGun(gasOrder.getGasPriceGun()); model.setGasPriceOfficial(gasOrder.getGasPriceOfficial()); - model.setDeductionPrice(gasOrder.getDeductionPrice()); + model.setDeductionPrice(gasOrder.getTotalDeductionPrice()); model.setPayablePrice(gasOrder.getPayablePrice()); model.setPayGold(gasOrder.getPayGold()); model.setPayPrice(gasOrder.getPayPrice()!=null?gasOrder.getPayPrice().toString():"未支付"); diff --git a/hai-service/src/main/java/com/hai/dao/HighGasOrderMapper.java b/hai-service/src/main/java/com/hai/dao/HighGasOrderMapper.java index a648d288..260da886 100644 --- a/hai-service/src/main/java/com/hai/dao/HighGasOrderMapper.java +++ b/hai-service/src/main/java/com/hai/dao/HighGasOrderMapper.java @@ -44,55 +44,57 @@ public interface HighGasOrderMapper extends HighGasOrderMapperExt { "mem_id, mem_phone, ", "company_id, company_name, ", "mer_id, mer_name, store_id, ", - "store_name, deduction_price, ", - "payable_price, pay_gold, ", - "pay_price, gas_refuel_price, ", - "gas_oil_no, gas_gun_no, ", - "gas_oil_type, gas_price_platform, ", - "gas_price_gun, gas_price_vip, ", - "gas_price_official, gas_price_cost, ", - "gas_price_cost_total, gas_price_channel_pay, ", - "gas_oil_liters, gas_discount, ", - "gas_oil_subsidy, gas_liters_preferences, ", - "gas_price_preferences, gas_class_group_id, ", - "gas_class_group_name, gas_class_group_task_id, ", - "gas_staff_id, gas_staff_name, ", - "gas_salesman_id, gas_salesman_name, ", - "gas_agent_id, gas_agent_name, ", - "gas_org_id, gas_org_name, ", - "pay_type, `status`, ", - "create_time, cancel_time, ", - "pay_time, refund_time, ", - "refund_remarks, ext_1, ", - "ext_2, ext_3, ext_4, ", - "ext_5, ext_6)", + "store_name, store_address, ", + "total_deduction_price, deduction_coupon_price, ", + "deduction_product_price, payable_price, ", + "pay_gold, pay_price, ", + "gas_refuel_price, gas_oil_no, ", + "gas_gun_no, gas_oil_type, ", + "gas_price_platform, gas_price_gun, ", + "gas_price_vip, gas_price_official, ", + "gas_price_cost, gas_price_cost_total, ", + "gas_price_channel_pay, gas_oil_liters, ", + "gas_discount, gas_oil_subsidy, ", + "gas_liters_preferences, gas_price_preferences, ", + "gas_class_group_id, gas_class_group_name, ", + "gas_class_group_task_id, gas_staff_id, ", + "gas_staff_name, gas_salesman_id, ", + "gas_salesman_name, gas_agent_id, ", + "gas_agent_name, gas_org_id, ", + "gas_org_name, pay_type, ", + "`status`, create_time, ", + "cancel_time, pay_time, ", + "refund_time, refund_remarks, ", + "ext_1, ext_2, ext_3, ", + "ext_4, ext_5, ext_6)", "values (#{orderNo,jdbcType=VARCHAR}, #{childOrderNo,jdbcType=VARCHAR}, ", "#{channelType,jdbcType=INTEGER}, #{channelOrderNo,jdbcType=VARCHAR}, ", "#{memId,jdbcType=BIGINT}, #{memPhone,jdbcType=VARCHAR}, ", "#{companyId,jdbcType=BIGINT}, #{companyName,jdbcType=VARCHAR}, ", "#{merId,jdbcType=BIGINT}, #{merName,jdbcType=VARCHAR}, #{storeId,jdbcType=BIGINT}, ", - "#{storeName,jdbcType=VARCHAR}, #{deductionPrice,jdbcType=DECIMAL}, ", - "#{payablePrice,jdbcType=DECIMAL}, #{payGold,jdbcType=INTEGER}, ", - "#{payPrice,jdbcType=DECIMAL}, #{gasRefuelPrice,jdbcType=DECIMAL}, ", - "#{gasOilNo,jdbcType=VARCHAR}, #{gasGunNo,jdbcType=VARCHAR}, ", - "#{gasOilType,jdbcType=INTEGER}, #{gasPricePlatform,jdbcType=DECIMAL}, ", - "#{gasPriceGun,jdbcType=DECIMAL}, #{gasPriceVip,jdbcType=DECIMAL}, ", - "#{gasPriceOfficial,jdbcType=DECIMAL}, #{gasPriceCost,jdbcType=DECIMAL}, ", - "#{gasPriceCostTotal,jdbcType=DECIMAL}, #{gasPriceChannelPay,jdbcType=DECIMAL}, ", - "#{gasOilLiters,jdbcType=DECIMAL}, #{gasDiscount,jdbcType=DECIMAL}, ", - "#{gasOilSubsidy,jdbcType=DECIMAL}, #{gasLitersPreferences,jdbcType=DECIMAL}, ", - "#{gasPricePreferences,jdbcType=DECIMAL}, #{gasClassGroupId,jdbcType=BIGINT}, ", - "#{gasClassGroupName,jdbcType=VARCHAR}, #{gasClassGroupTaskId,jdbcType=BIGINT}, ", - "#{gasStaffId,jdbcType=BIGINT}, #{gasStaffName,jdbcType=VARCHAR}, ", - "#{gasSalesmanId,jdbcType=BIGINT}, #{gasSalesmanName,jdbcType=VARCHAR}, ", - "#{gasAgentId,jdbcType=BIGINT}, #{gasAgentName,jdbcType=VARCHAR}, ", - "#{gasOrgId,jdbcType=BIGINT}, #{gasOrgName,jdbcType=VARCHAR}, ", - "#{payType,jdbcType=INTEGER}, #{status,jdbcType=INTEGER}, ", - "#{createTime,jdbcType=TIMESTAMP}, #{cancelTime,jdbcType=TIMESTAMP}, ", - "#{payTime,jdbcType=TIMESTAMP}, #{refundTime,jdbcType=TIMESTAMP}, ", - "#{refundRemarks,jdbcType=VARCHAR}, #{ext1,jdbcType=VARCHAR}, ", - "#{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR}, #{ext4,jdbcType=VARCHAR}, ", - "#{ext5,jdbcType=VARCHAR}, #{ext6,jdbcType=VARCHAR})" + "#{storeName,jdbcType=VARCHAR}, #{storeAddress,jdbcType=VARCHAR}, ", + "#{totalDeductionPrice,jdbcType=DECIMAL}, #{deductionCouponPrice,jdbcType=DECIMAL}, ", + "#{deductionProductPrice,jdbcType=DECIMAL}, #{payablePrice,jdbcType=DECIMAL}, ", + "#{payGold,jdbcType=INTEGER}, #{payPrice,jdbcType=DECIMAL}, ", + "#{gasRefuelPrice,jdbcType=DECIMAL}, #{gasOilNo,jdbcType=VARCHAR}, ", + "#{gasGunNo,jdbcType=VARCHAR}, #{gasOilType,jdbcType=INTEGER}, ", + "#{gasPricePlatform,jdbcType=DECIMAL}, #{gasPriceGun,jdbcType=DECIMAL}, ", + "#{gasPriceVip,jdbcType=DECIMAL}, #{gasPriceOfficial,jdbcType=DECIMAL}, ", + "#{gasPriceCost,jdbcType=DECIMAL}, #{gasPriceCostTotal,jdbcType=DECIMAL}, ", + "#{gasPriceChannelPay,jdbcType=DECIMAL}, #{gasOilLiters,jdbcType=DECIMAL}, ", + "#{gasDiscount,jdbcType=DECIMAL}, #{gasOilSubsidy,jdbcType=DECIMAL}, ", + "#{gasLitersPreferences,jdbcType=DECIMAL}, #{gasPricePreferences,jdbcType=DECIMAL}, ", + "#{gasClassGroupId,jdbcType=BIGINT}, #{gasClassGroupName,jdbcType=VARCHAR}, ", + "#{gasClassGroupTaskId,jdbcType=BIGINT}, #{gasStaffId,jdbcType=BIGINT}, ", + "#{gasStaffName,jdbcType=VARCHAR}, #{gasSalesmanId,jdbcType=BIGINT}, ", + "#{gasSalesmanName,jdbcType=VARCHAR}, #{gasAgentId,jdbcType=BIGINT}, ", + "#{gasAgentName,jdbcType=VARCHAR}, #{gasOrgId,jdbcType=BIGINT}, ", + "#{gasOrgName,jdbcType=VARCHAR}, #{payType,jdbcType=INTEGER}, ", + "#{status,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, ", + "#{cancelTime,jdbcType=TIMESTAMP}, #{payTime,jdbcType=TIMESTAMP}, ", + "#{refundTime,jdbcType=TIMESTAMP}, #{refundRemarks,jdbcType=VARCHAR}, ", + "#{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR}, ", + "#{ext4,jdbcType=VARCHAR}, #{ext5,jdbcType=VARCHAR}, #{ext6,jdbcType=VARCHAR})" }) @Options(useGeneratedKeys=true,keyProperty="id") int insert(HighGasOrder record); @@ -116,7 +118,10 @@ public interface HighGasOrderMapper extends HighGasOrderMapperExt { @Result(column="mer_name", property="merName", jdbcType=JdbcType.VARCHAR), @Result(column="store_id", property="storeId", jdbcType=JdbcType.BIGINT), @Result(column="store_name", property="storeName", jdbcType=JdbcType.VARCHAR), - @Result(column="deduction_price", property="deductionPrice", jdbcType=JdbcType.DECIMAL), + @Result(column="store_address", property="storeAddress", jdbcType=JdbcType.VARCHAR), + @Result(column="total_deduction_price", property="totalDeductionPrice", jdbcType=JdbcType.DECIMAL), + @Result(column="deduction_coupon_price", property="deductionCouponPrice", jdbcType=JdbcType.DECIMAL), + @Result(column="deduction_product_price", property="deductionProductPrice", jdbcType=JdbcType.DECIMAL), @Result(column="payable_price", property="payablePrice", jdbcType=JdbcType.DECIMAL), @Result(column="pay_gold", property="payGold", jdbcType=JdbcType.INTEGER), @Result(column="pay_price", property="payPrice", jdbcType=JdbcType.DECIMAL), @@ -166,15 +171,16 @@ public interface HighGasOrderMapper extends HighGasOrderMapperExt { @Select({ "select", "id, order_no, child_order_no, channel_type, channel_order_no, mem_id, mem_phone, ", - "company_id, company_name, mer_id, mer_name, store_id, store_name, deduction_price, ", - "payable_price, pay_gold, pay_price, gas_refuel_price, gas_oil_no, gas_gun_no, ", - "gas_oil_type, gas_price_platform, gas_price_gun, gas_price_vip, gas_price_official, ", - "gas_price_cost, gas_price_cost_total, gas_price_channel_pay, gas_oil_liters, ", - "gas_discount, gas_oil_subsidy, gas_liters_preferences, gas_price_preferences, ", - "gas_class_group_id, gas_class_group_name, gas_class_group_task_id, gas_staff_id, ", - "gas_staff_name, gas_salesman_id, gas_salesman_name, gas_agent_id, gas_agent_name, ", - "gas_org_id, gas_org_name, pay_type, `status`, create_time, cancel_time, pay_time, ", - "refund_time, refund_remarks, ext_1, ext_2, ext_3, ext_4, ext_5, ext_6", + "company_id, company_name, mer_id, mer_name, store_id, store_name, store_address, ", + "total_deduction_price, deduction_coupon_price, deduction_product_price, payable_price, ", + "pay_gold, pay_price, gas_refuel_price, gas_oil_no, gas_gun_no, gas_oil_type, ", + "gas_price_platform, gas_price_gun, gas_price_vip, gas_price_official, gas_price_cost, ", + "gas_price_cost_total, gas_price_channel_pay, gas_oil_liters, gas_discount, gas_oil_subsidy, ", + "gas_liters_preferences, gas_price_preferences, gas_class_group_id, gas_class_group_name, ", + "gas_class_group_task_id, gas_staff_id, gas_staff_name, gas_salesman_id, gas_salesman_name, ", + "gas_agent_id, gas_agent_name, gas_org_id, gas_org_name, pay_type, `status`, ", + "create_time, cancel_time, pay_time, refund_time, refund_remarks, ext_1, ext_2, ", + "ext_3, ext_4, ext_5, ext_6", "from high_gas_order", "where id = #{id,jdbcType=BIGINT}" }) @@ -192,7 +198,10 @@ public interface HighGasOrderMapper extends HighGasOrderMapperExt { @Result(column="mer_name", property="merName", jdbcType=JdbcType.VARCHAR), @Result(column="store_id", property="storeId", jdbcType=JdbcType.BIGINT), @Result(column="store_name", property="storeName", jdbcType=JdbcType.VARCHAR), - @Result(column="deduction_price", property="deductionPrice", jdbcType=JdbcType.DECIMAL), + @Result(column="store_address", property="storeAddress", jdbcType=JdbcType.VARCHAR), + @Result(column="total_deduction_price", property="totalDeductionPrice", jdbcType=JdbcType.DECIMAL), + @Result(column="deduction_coupon_price", property="deductionCouponPrice", jdbcType=JdbcType.DECIMAL), + @Result(column="deduction_product_price", property="deductionProductPrice", jdbcType=JdbcType.DECIMAL), @Result(column="payable_price", property="payablePrice", jdbcType=JdbcType.DECIMAL), @Result(column="pay_gold", property="payGold", jdbcType=JdbcType.INTEGER), @Result(column="pay_price", property="payPrice", jdbcType=JdbcType.DECIMAL), @@ -262,7 +271,10 @@ public interface HighGasOrderMapper extends HighGasOrderMapperExt { "mer_name = #{merName,jdbcType=VARCHAR},", "store_id = #{storeId,jdbcType=BIGINT},", "store_name = #{storeName,jdbcType=VARCHAR},", - "deduction_price = #{deductionPrice,jdbcType=DECIMAL},", + "store_address = #{storeAddress,jdbcType=VARCHAR},", + "total_deduction_price = #{totalDeductionPrice,jdbcType=DECIMAL},", + "deduction_coupon_price = #{deductionCouponPrice,jdbcType=DECIMAL},", + "deduction_product_price = #{deductionProductPrice,jdbcType=DECIMAL},", "payable_price = #{payablePrice,jdbcType=DECIMAL},", "pay_gold = #{payGold,jdbcType=INTEGER},", "pay_price = #{payPrice,jdbcType=DECIMAL},", diff --git a/hai-service/src/main/java/com/hai/dao/HighGasOrderSqlProvider.java b/hai-service/src/main/java/com/hai/dao/HighGasOrderSqlProvider.java index 52908b0b..df512d08 100644 --- a/hai-service/src/main/java/com/hai/dao/HighGasOrderSqlProvider.java +++ b/hai-service/src/main/java/com/hai/dao/HighGasOrderSqlProvider.java @@ -76,8 +76,20 @@ public class HighGasOrderSqlProvider { sql.VALUES("store_name", "#{storeName,jdbcType=VARCHAR}"); } - if (record.getDeductionPrice() != null) { - sql.VALUES("deduction_price", "#{deductionPrice,jdbcType=DECIMAL}"); + if (record.getStoreAddress() != null) { + sql.VALUES("store_address", "#{storeAddress,jdbcType=VARCHAR}"); + } + + if (record.getTotalDeductionPrice() != null) { + sql.VALUES("total_deduction_price", "#{totalDeductionPrice,jdbcType=DECIMAL}"); + } + + if (record.getDeductionCouponPrice() != null) { + sql.VALUES("deduction_coupon_price", "#{deductionCouponPrice,jdbcType=DECIMAL}"); + } + + if (record.getDeductionProductPrice() != null) { + sql.VALUES("deduction_product_price", "#{deductionProductPrice,jdbcType=DECIMAL}"); } if (record.getPayablePrice() != null) { @@ -274,7 +286,10 @@ public class HighGasOrderSqlProvider { sql.SELECT("mer_name"); sql.SELECT("store_id"); sql.SELECT("store_name"); - sql.SELECT("deduction_price"); + sql.SELECT("store_address"); + sql.SELECT("total_deduction_price"); + sql.SELECT("deduction_coupon_price"); + sql.SELECT("deduction_product_price"); sql.SELECT("payable_price"); sql.SELECT("pay_gold"); sql.SELECT("pay_price"); @@ -387,8 +402,20 @@ public class HighGasOrderSqlProvider { sql.SET("store_name = #{record.storeName,jdbcType=VARCHAR}"); } - if (record.getDeductionPrice() != null) { - sql.SET("deduction_price = #{record.deductionPrice,jdbcType=DECIMAL}"); + if (record.getStoreAddress() != null) { + sql.SET("store_address = #{record.storeAddress,jdbcType=VARCHAR}"); + } + + if (record.getTotalDeductionPrice() != null) { + sql.SET("total_deduction_price = #{record.totalDeductionPrice,jdbcType=DECIMAL}"); + } + + if (record.getDeductionCouponPrice() != null) { + sql.SET("deduction_coupon_price = #{record.deductionCouponPrice,jdbcType=DECIMAL}"); + } + + if (record.getDeductionProductPrice() != null) { + sql.SET("deduction_product_price = #{record.deductionProductPrice,jdbcType=DECIMAL}"); } if (record.getPayablePrice() != null) { @@ -584,7 +611,10 @@ public class HighGasOrderSqlProvider { sql.SET("mer_name = #{record.merName,jdbcType=VARCHAR}"); sql.SET("store_id = #{record.storeId,jdbcType=BIGINT}"); sql.SET("store_name = #{record.storeName,jdbcType=VARCHAR}"); - sql.SET("deduction_price = #{record.deductionPrice,jdbcType=DECIMAL}"); + sql.SET("store_address = #{record.storeAddress,jdbcType=VARCHAR}"); + sql.SET("total_deduction_price = #{record.totalDeductionPrice,jdbcType=DECIMAL}"); + sql.SET("deduction_coupon_price = #{record.deductionCouponPrice,jdbcType=DECIMAL}"); + sql.SET("deduction_product_price = #{record.deductionProductPrice,jdbcType=DECIMAL}"); sql.SET("payable_price = #{record.payablePrice,jdbcType=DECIMAL}"); sql.SET("pay_gold = #{record.payGold,jdbcType=INTEGER}"); sql.SET("pay_price = #{record.payPrice,jdbcType=DECIMAL}"); @@ -686,8 +716,20 @@ public class HighGasOrderSqlProvider { sql.SET("store_name = #{storeName,jdbcType=VARCHAR}"); } - if (record.getDeductionPrice() != null) { - sql.SET("deduction_price = #{deductionPrice,jdbcType=DECIMAL}"); + if (record.getStoreAddress() != null) { + sql.SET("store_address = #{storeAddress,jdbcType=VARCHAR}"); + } + + if (record.getTotalDeductionPrice() != null) { + sql.SET("total_deduction_price = #{totalDeductionPrice,jdbcType=DECIMAL}"); + } + + if (record.getDeductionCouponPrice() != null) { + sql.SET("deduction_coupon_price = #{deductionCouponPrice,jdbcType=DECIMAL}"); + } + + if (record.getDeductionProductPrice() != null) { + sql.SET("deduction_product_price = #{deductionProductPrice,jdbcType=DECIMAL}"); } if (record.getPayablePrice() != null) { diff --git a/hai-service/src/main/java/com/hai/dao/HighMerchantAccountMapperExt.java b/hai-service/src/main/java/com/hai/dao/HighMerchantAccountMapperExt.java index a805c217..46951c49 100644 --- a/hai-service/src/main/java/com/hai/dao/HighMerchantAccountMapperExt.java +++ b/hai-service/src/main/java/com/hai/dao/HighMerchantAccountMapperExt.java @@ -14,12 +14,9 @@ public interface HighMerchantAccountMapperExt { @Select({"select " + - " case when sum(a.gas_price_cost_total) is not null then sum(a.gas_price_cost_total) ELSE 0 end " + - " from high_child_order a, high_order b" + - " where goods_type = 3 " + - " and a.order_id = b.id" + - " and goods_id in (SELECT id from high_merchant_store where merchant_id = #{merId}) " + - " and b.order_status in (2,3,6,7)"}) + " case when sum(gas_price_cost) is not null then sum(gas_price_cost) ELSE 0 end " + + " from high_gas_order " + + " where store_id in (SELECT id from high_merchant_store where merchant_id = #{merId}) and `status` in (2,5,6)"}) BigDecimal countMerGasOilAmount(@Param("merId") Long merId); @Select({ diff --git a/hai-service/src/main/java/com/hai/entity/HighGasOrder.java b/hai-service/src/main/java/com/hai/entity/HighGasOrder.java index 5c3a5b4e..83664020 100644 --- a/hai-service/src/main/java/com/hai/entity/HighGasOrder.java +++ b/hai-service/src/main/java/com/hai/entity/HighGasOrder.java @@ -80,9 +80,24 @@ public class HighGasOrder implements Serializable { private String storeName; /** - * 优惠金额 + * 门店地址 */ - private BigDecimal deductionPrice; + private String storeAddress; + + /** + * 交易总优惠金额(优惠券优惠金额+产品优惠金额 + */ + private BigDecimal totalDeductionPrice; + + /** + * 优惠券优惠金额 + */ + private BigDecimal deductionCouponPrice; + + /** + * 产品优惠金额 + */ + private BigDecimal deductionProductPrice; /** * 应付金额 @@ -393,12 +408,36 @@ public class HighGasOrder implements Serializable { this.storeName = storeName; } - public BigDecimal getDeductionPrice() { - return deductionPrice; + public String getStoreAddress() { + return storeAddress; + } + + public void setStoreAddress(String storeAddress) { + this.storeAddress = storeAddress; + } + + public BigDecimal getTotalDeductionPrice() { + return totalDeductionPrice; + } + + public void setTotalDeductionPrice(BigDecimal totalDeductionPrice) { + this.totalDeductionPrice = totalDeductionPrice; + } + + public BigDecimal getDeductionCouponPrice() { + return deductionCouponPrice; + } + + public void setDeductionCouponPrice(BigDecimal deductionCouponPrice) { + this.deductionCouponPrice = deductionCouponPrice; + } + + public BigDecimal getDeductionProductPrice() { + return deductionProductPrice; } - public void setDeductionPrice(BigDecimal deductionPrice) { - this.deductionPrice = deductionPrice; + public void setDeductionProductPrice(BigDecimal deductionProductPrice) { + this.deductionProductPrice = deductionProductPrice; } public BigDecimal getPayablePrice() { @@ -770,7 +809,10 @@ public class HighGasOrder implements Serializable { && (this.getMerName() == null ? other.getMerName() == null : this.getMerName().equals(other.getMerName())) && (this.getStoreId() == null ? other.getStoreId() == null : this.getStoreId().equals(other.getStoreId())) && (this.getStoreName() == null ? other.getStoreName() == null : this.getStoreName().equals(other.getStoreName())) - && (this.getDeductionPrice() == null ? other.getDeductionPrice() == null : this.getDeductionPrice().equals(other.getDeductionPrice())) + && (this.getStoreAddress() == null ? other.getStoreAddress() == null : this.getStoreAddress().equals(other.getStoreAddress())) + && (this.getTotalDeductionPrice() == null ? other.getTotalDeductionPrice() == null : this.getTotalDeductionPrice().equals(other.getTotalDeductionPrice())) + && (this.getDeductionCouponPrice() == null ? other.getDeductionCouponPrice() == null : this.getDeductionCouponPrice().equals(other.getDeductionCouponPrice())) + && (this.getDeductionProductPrice() == null ? other.getDeductionProductPrice() == null : this.getDeductionProductPrice().equals(other.getDeductionProductPrice())) && (this.getPayablePrice() == null ? other.getPayablePrice() == null : this.getPayablePrice().equals(other.getPayablePrice())) && (this.getPayGold() == null ? other.getPayGold() == null : this.getPayGold().equals(other.getPayGold())) && (this.getPayPrice() == null ? other.getPayPrice() == null : this.getPayPrice().equals(other.getPayPrice())) @@ -833,7 +875,10 @@ public class HighGasOrder implements Serializable { result = prime * result + ((getMerName() == null) ? 0 : getMerName().hashCode()); result = prime * result + ((getStoreId() == null) ? 0 : getStoreId().hashCode()); result = prime * result + ((getStoreName() == null) ? 0 : getStoreName().hashCode()); - result = prime * result + ((getDeductionPrice() == null) ? 0 : getDeductionPrice().hashCode()); + result = prime * result + ((getStoreAddress() == null) ? 0 : getStoreAddress().hashCode()); + result = prime * result + ((getTotalDeductionPrice() == null) ? 0 : getTotalDeductionPrice().hashCode()); + result = prime * result + ((getDeductionCouponPrice() == null) ? 0 : getDeductionCouponPrice().hashCode()); + result = prime * result + ((getDeductionProductPrice() == null) ? 0 : getDeductionProductPrice().hashCode()); result = prime * result + ((getPayablePrice() == null) ? 0 : getPayablePrice().hashCode()); result = prime * result + ((getPayGold() == null) ? 0 : getPayGold().hashCode()); result = prime * result + ((getPayPrice() == null) ? 0 : getPayPrice().hashCode()); @@ -899,7 +944,10 @@ public class HighGasOrder implements Serializable { sb.append(", merName=").append(merName); sb.append(", storeId=").append(storeId); sb.append(", storeName=").append(storeName); - sb.append(", deductionPrice=").append(deductionPrice); + sb.append(", storeAddress=").append(storeAddress); + sb.append(", totalDeductionPrice=").append(totalDeductionPrice); + sb.append(", deductionCouponPrice=").append(deductionCouponPrice); + sb.append(", deductionProductPrice=").append(deductionProductPrice); sb.append(", payablePrice=").append(payablePrice); sb.append(", payGold=").append(payGold); sb.append(", payPrice=").append(payPrice); diff --git a/hai-service/src/main/java/com/hai/entity/HighGasOrderExample.java b/hai-service/src/main/java/com/hai/entity/HighGasOrderExample.java index 53b7c9eb..bdf025fe 100644 --- a/hai-service/src/main/java/com/hai/entity/HighGasOrderExample.java +++ b/hai-service/src/main/java/com/hai/entity/HighGasOrderExample.java @@ -976,63 +976,253 @@ public class HighGasOrderExample { return (Criteria) this; } - public Criteria andDeductionPriceIsNull() { - addCriterion("deduction_price is null"); + public Criteria andStoreAddressIsNull() { + addCriterion("store_address is null"); return (Criteria) this; } - public Criteria andDeductionPriceIsNotNull() { - addCriterion("deduction_price is not null"); + public Criteria andStoreAddressIsNotNull() { + addCriterion("store_address is not null"); return (Criteria) this; } - public Criteria andDeductionPriceEqualTo(BigDecimal value) { - addCriterion("deduction_price =", value, "deductionPrice"); + public Criteria andStoreAddressEqualTo(String value) { + addCriterion("store_address =", value, "storeAddress"); return (Criteria) this; } - public Criteria andDeductionPriceNotEqualTo(BigDecimal value) { - addCriterion("deduction_price <>", value, "deductionPrice"); + public Criteria andStoreAddressNotEqualTo(String value) { + addCriterion("store_address <>", value, "storeAddress"); return (Criteria) this; } - public Criteria andDeductionPriceGreaterThan(BigDecimal value) { - addCriterion("deduction_price >", value, "deductionPrice"); + public Criteria andStoreAddressGreaterThan(String value) { + addCriterion("store_address >", value, "storeAddress"); return (Criteria) this; } - public Criteria andDeductionPriceGreaterThanOrEqualTo(BigDecimal value) { - addCriterion("deduction_price >=", value, "deductionPrice"); + public Criteria andStoreAddressGreaterThanOrEqualTo(String value) { + addCriterion("store_address >=", value, "storeAddress"); return (Criteria) this; } - public Criteria andDeductionPriceLessThan(BigDecimal value) { - addCriterion("deduction_price <", value, "deductionPrice"); + public Criteria andStoreAddressLessThan(String value) { + addCriterion("store_address <", value, "storeAddress"); return (Criteria) this; } - public Criteria andDeductionPriceLessThanOrEqualTo(BigDecimal value) { - addCriterion("deduction_price <=", value, "deductionPrice"); + public Criteria andStoreAddressLessThanOrEqualTo(String value) { + addCriterion("store_address <=", value, "storeAddress"); return (Criteria) this; } - public Criteria andDeductionPriceIn(List values) { - addCriterion("deduction_price in", values, "deductionPrice"); + public Criteria andStoreAddressLike(String value) { + addCriterion("store_address like", value, "storeAddress"); return (Criteria) this; } - public Criteria andDeductionPriceNotIn(List values) { - addCriterion("deduction_price not in", values, "deductionPrice"); + public Criteria andStoreAddressNotLike(String value) { + addCriterion("store_address not like", value, "storeAddress"); return (Criteria) this; } - public Criteria andDeductionPriceBetween(BigDecimal value1, BigDecimal value2) { - addCriterion("deduction_price between", value1, value2, "deductionPrice"); + public Criteria andStoreAddressIn(List values) { + addCriterion("store_address in", values, "storeAddress"); return (Criteria) this; } - public Criteria andDeductionPriceNotBetween(BigDecimal value1, BigDecimal value2) { - addCriterion("deduction_price not between", value1, value2, "deductionPrice"); + public Criteria andStoreAddressNotIn(List values) { + addCriterion("store_address not in", values, "storeAddress"); + return (Criteria) this; + } + + public Criteria andStoreAddressBetween(String value1, String value2) { + addCriterion("store_address between", value1, value2, "storeAddress"); + return (Criteria) this; + } + + public Criteria andStoreAddressNotBetween(String value1, String value2) { + addCriterion("store_address not between", value1, value2, "storeAddress"); + return (Criteria) this; + } + + public Criteria andTotalDeductionPriceIsNull() { + addCriterion("total_deduction_price is null"); + return (Criteria) this; + } + + public Criteria andTotalDeductionPriceIsNotNull() { + addCriterion("total_deduction_price is not null"); + return (Criteria) this; + } + + public Criteria andTotalDeductionPriceEqualTo(BigDecimal value) { + addCriterion("total_deduction_price =", value, "totalDeductionPrice"); + return (Criteria) this; + } + + public Criteria andTotalDeductionPriceNotEqualTo(BigDecimal value) { + addCriterion("total_deduction_price <>", value, "totalDeductionPrice"); + return (Criteria) this; + } + + public Criteria andTotalDeductionPriceGreaterThan(BigDecimal value) { + addCriterion("total_deduction_price >", value, "totalDeductionPrice"); + return (Criteria) this; + } + + public Criteria andTotalDeductionPriceGreaterThanOrEqualTo(BigDecimal value) { + addCriterion("total_deduction_price >=", value, "totalDeductionPrice"); + return (Criteria) this; + } + + public Criteria andTotalDeductionPriceLessThan(BigDecimal value) { + addCriterion("total_deduction_price <", value, "totalDeductionPrice"); + return (Criteria) this; + } + + public Criteria andTotalDeductionPriceLessThanOrEqualTo(BigDecimal value) { + addCriterion("total_deduction_price <=", value, "totalDeductionPrice"); + return (Criteria) this; + } + + public Criteria andTotalDeductionPriceIn(List values) { + addCriterion("total_deduction_price in", values, "totalDeductionPrice"); + return (Criteria) this; + } + + public Criteria andTotalDeductionPriceNotIn(List values) { + addCriterion("total_deduction_price not in", values, "totalDeductionPrice"); + return (Criteria) this; + } + + public Criteria andTotalDeductionPriceBetween(BigDecimal value1, BigDecimal value2) { + addCriterion("total_deduction_price between", value1, value2, "totalDeductionPrice"); + return (Criteria) this; + } + + public Criteria andTotalDeductionPriceNotBetween(BigDecimal value1, BigDecimal value2) { + addCriterion("total_deduction_price not between", value1, value2, "totalDeductionPrice"); + return (Criteria) this; + } + + public Criteria andDeductionCouponPriceIsNull() { + addCriterion("deduction_coupon_price is null"); + return (Criteria) this; + } + + public Criteria andDeductionCouponPriceIsNotNull() { + addCriterion("deduction_coupon_price is not null"); + return (Criteria) this; + } + + public Criteria andDeductionCouponPriceEqualTo(BigDecimal value) { + addCriterion("deduction_coupon_price =", value, "deductionCouponPrice"); + return (Criteria) this; + } + + public Criteria andDeductionCouponPriceNotEqualTo(BigDecimal value) { + addCriterion("deduction_coupon_price <>", value, "deductionCouponPrice"); + return (Criteria) this; + } + + public Criteria andDeductionCouponPriceGreaterThan(BigDecimal value) { + addCriterion("deduction_coupon_price >", value, "deductionCouponPrice"); + return (Criteria) this; + } + + public Criteria andDeductionCouponPriceGreaterThanOrEqualTo(BigDecimal value) { + addCriterion("deduction_coupon_price >=", value, "deductionCouponPrice"); + return (Criteria) this; + } + + public Criteria andDeductionCouponPriceLessThan(BigDecimal value) { + addCriterion("deduction_coupon_price <", value, "deductionCouponPrice"); + return (Criteria) this; + } + + public Criteria andDeductionCouponPriceLessThanOrEqualTo(BigDecimal value) { + addCriterion("deduction_coupon_price <=", value, "deductionCouponPrice"); + return (Criteria) this; + } + + public Criteria andDeductionCouponPriceIn(List values) { + addCriterion("deduction_coupon_price in", values, "deductionCouponPrice"); + return (Criteria) this; + } + + public Criteria andDeductionCouponPriceNotIn(List values) { + addCriterion("deduction_coupon_price not in", values, "deductionCouponPrice"); + return (Criteria) this; + } + + public Criteria andDeductionCouponPriceBetween(BigDecimal value1, BigDecimal value2) { + addCriterion("deduction_coupon_price between", value1, value2, "deductionCouponPrice"); + return (Criteria) this; + } + + public Criteria andDeductionCouponPriceNotBetween(BigDecimal value1, BigDecimal value2) { + addCriterion("deduction_coupon_price not between", value1, value2, "deductionCouponPrice"); + return (Criteria) this; + } + + public Criteria andDeductionProductPriceIsNull() { + addCriterion("deduction_product_price is null"); + return (Criteria) this; + } + + public Criteria andDeductionProductPriceIsNotNull() { + addCriterion("deduction_product_price is not null"); + return (Criteria) this; + } + + public Criteria andDeductionProductPriceEqualTo(BigDecimal value) { + addCriterion("deduction_product_price =", value, "deductionProductPrice"); + return (Criteria) this; + } + + public Criteria andDeductionProductPriceNotEqualTo(BigDecimal value) { + addCriterion("deduction_product_price <>", value, "deductionProductPrice"); + return (Criteria) this; + } + + public Criteria andDeductionProductPriceGreaterThan(BigDecimal value) { + addCriterion("deduction_product_price >", value, "deductionProductPrice"); + return (Criteria) this; + } + + public Criteria andDeductionProductPriceGreaterThanOrEqualTo(BigDecimal value) { + addCriterion("deduction_product_price >=", value, "deductionProductPrice"); + return (Criteria) this; + } + + public Criteria andDeductionProductPriceLessThan(BigDecimal value) { + addCriterion("deduction_product_price <", value, "deductionProductPrice"); + return (Criteria) this; + } + + public Criteria andDeductionProductPriceLessThanOrEqualTo(BigDecimal value) { + addCriterion("deduction_product_price <=", value, "deductionProductPrice"); + return (Criteria) this; + } + + public Criteria andDeductionProductPriceIn(List values) { + addCriterion("deduction_product_price in", values, "deductionProductPrice"); + return (Criteria) this; + } + + public Criteria andDeductionProductPriceNotIn(List values) { + addCriterion("deduction_product_price not in", values, "deductionProductPrice"); + return (Criteria) this; + } + + public Criteria andDeductionProductPriceBetween(BigDecimal value1, BigDecimal value2) { + addCriterion("deduction_product_price between", value1, value2, "deductionProductPrice"); + return (Criteria) this; + } + + public Criteria andDeductionProductPriceNotBetween(BigDecimal value1, BigDecimal value2) { + addCriterion("deduction_product_price not between", value1, value2, "deductionProductPrice"); return (Criteria) this; } diff --git a/hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java b/hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java index 06a67a1f..e4d58198 100644 --- a/hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java +++ b/hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java @@ -338,12 +338,16 @@ public class OrderCreateHandleServiceImpl implements OrderCreateHandleService { gasOrder.setMerName(merchant.getMerchantName()); gasOrder.setStoreId(store.getId()); gasOrder.setStoreName(store.getStoreName()); + gasOrder.setStoreAddress(store.getAddress()); gasOrder.setGasRefuelPrice(childOrder.getGoodsPrice()); gasOrder.setGasOilNo(createOrderChild.getGasOilNo()); gasOrder.setGasGunNo(createOrderChild.getGasGunNo()); gasOrder.setGasOilType(Integer.parseInt(gasOilType.getExt1())); gasOrder.setStatus(OrderOilStatus.STATUS1.getNumber()); gasOrder.setGasDiscount(new BigDecimal("0")); + gasOrder.setTotalDeductionPrice(new BigDecimal("0")); + gasOrder.setDeductionCouponPrice(new BigDecimal("0")); + gasOrder.setDeductionProductPrice(new BigDecimal("0")); // 成本价 油站价 减 营销策略价 gasOrder.setGasPriceCost(priceModel.getPriceGun().subtract(marketingPrice)); @@ -364,20 +368,20 @@ public class OrderCreateHandleServiceImpl implements OrderCreateHandleService { if (gasOrder.getGasRefuelPrice().compareTo(discountUserRel.getHighDiscount().getDiscountCondition()) > 1) { throw ErrorHelp.genException(SysCode.System, ErrorCode.UN_MEMBER_ERROR, "订单未达到"+discountUserRel.getHighDiscount().getDiscountCondition()+"元,无法使用此优惠券"); } - gasOrder.setDeductionPrice(discountUserRel.getHighDiscount().getDiscountPrice()); + gasOrder.setDeductionCouponPrice(discountUserRel.getHighDiscount().getDiscountPrice()); } else if (discountUserRel.getHighDiscount().getDiscountType() == 2) { - gasOrder.setDeductionPrice(discountUserRel.getHighDiscount().getDiscountPrice()); + gasOrder.setDeductionCouponPrice(discountUserRel.getHighDiscount().getDiscountPrice()); } else if (discountUserRel.getHighDiscount().getDiscountType() == 3) { // 加油金额 * 折扣 BigDecimal deductionPrice = gasOrder.getGasRefuelPrice() .multiply(discountUserRel.getHighDiscount().getDiscountPrice()) .setScale(2, BigDecimal.ROUND_HALF_DOWN); - gasOrder.setDeductionPrice(gasOrder.getGasRefuelPrice().subtract(deductionPrice)); + gasOrder.setDeductionCouponPrice(gasOrder.getGasRefuelPrice().subtract(deductionPrice)); } - gasOrder.setPayablePrice(gasOrder.getGasRefuelPrice().subtract(gasOrder.getDeductionPrice())); + gasOrder.setPayablePrice(gasOrder.getGasRefuelPrice().subtract(gasOrder.getTotalDeductionPrice())); if (gasOrder.getPayablePrice().compareTo(new BigDecimal("0")) < 0) { gasOrder.setPayablePrice(new BigDecimal("0")); } @@ -392,11 +396,10 @@ public class OrderCreateHandleServiceImpl implements OrderCreateHandleService { gasOrder.setGasOilSubsidy(new BigDecimal("0")); gasOrder.setGasLitersPreferences(new BigDecimal("0")); gasOrder.setGasPricePreferences(priceModel.getPriceGun()); - } - else { + } else { // 支付价格 childOrder.setGoodsActualPrice(priceModel.getPayPrice()); - gasOrder.setDeductionPrice(priceModel.getTotalPreferences()); + gasOrder.setDeductionCouponPrice(priceModel.getTotalPreferences()); gasOrder.setPayablePrice(priceModel.getPayPrice()); // 油价信息 @@ -410,7 +413,7 @@ public class OrderCreateHandleServiceImpl implements OrderCreateHandleService { gasOrder.setGasLitersPreferences(priceModel.getLitersPreferences()); gasOrder.setGasPricePreferences(priceModel.getPricePreferences()); } - + childOrder.setTotalDeductionPrice(childOrder.getTotalPrice().subtract(childOrder.getTotalActualPrice())); gasOrder.setPayGold(createOrderModel.getPayGold()!=null?createOrderModel.getPayGold():0); if (store.getSourceType().equals(MerchantStoreSourceType.type4.getNumber())) { diff --git a/hai-service/src/main/java/com/hai/service/impl/HighUserServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighUserServiceImpl.java index e8031b7c..e5de6753 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighUserServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighUserServiceImpl.java @@ -132,7 +132,6 @@ public class HighUserServiceImpl implements HighUserService { HighUserModel highUserModel = new HighUserModel(); highUserModel.setHighUser(getDetailDataByUser(user.getId())); SessionObject so = new SessionObject(AESEncodeUtil.base64Encode(AESEncodeUtil.aesEncryptToBytes(user.getPhone(), "123")), 1 , highUserModel); - so.setType(1); userCenter.save(null,null,so); return highUserModel; diff --git a/hai-user/src/main/java/com/web/config/AuthConfig.java b/hai-user/src/main/java/com/web/config/AuthConfig.java index 0f8cd206..ff6367b1 100644 --- a/hai-user/src/main/java/com/web/config/AuthConfig.java +++ b/hai-user/src/main/java/com/web/config/AuthConfig.java @@ -4,7 +4,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.module.SimpleModule; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import com.hai.common.security.UserCenter; -import com.hai.common.utils.RequestUtils; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -54,32 +53,77 @@ public class AuthConfig implements WebMvcConfigurer { } public void addInterceptors(InterceptorRegistry registry) { - registry.addInterceptor(new HandlerInterceptorAdapter() { + registry.addInterceptor(new HandlerInterceptorAdapter() { + + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, + Object handler) throws Exception { + if(debug){ + return true; + } + String token = request.getParameter("Authorization"); + if (StringUtils.isBlank(token)) { + token = request.getHeader("Authorization"); + } + if((StringUtils.isNotBlank(token) && userCenter.isTokenLogin(token)) || userCenter.isLogin(request)){//如果未登录,将无法使用任何接口 + userCenter.refreshCookie(request, response); + return true; + } else if(request instanceof StandardMultipartHttpServletRequest) { + StandardMultipartHttpServletRequest re = (StandardMultipartHttpServletRequest)request; + if(userCenter.isLogin(re.getRequest())){ + return true; + } else { + log.error("the user is not logged in,remoteAddr:"+getIpAddress(request)+",requestUrl:"+request.getRequestURL()); + response.setStatus(401); + return false; + } + } else{ + log.error("the user is not logged in,remoteAddr:"+getIpAddress(request)+",requestUrl:"+request.getRequestURL()); + response.setStatus(401); + return false; + } + } + }) + .addPathPatterns("/**") + .excludePathPatterns("/swagger-resources/**") + .excludePathPatterns("/**/api-docs") + .excludePathPatterns("/**/springfox-swagger-ui/**") + .excludePathPatterns("/**/swagger-ui.html") + .excludePathPatterns("/login/*") + .excludePathPatterns("/sms/*") + ; + } + + public String getIpAddress(HttpServletRequest request) { + // 获取请求主机IP地址,如果通过代理进来,则透过防火墙获取真实IP地址 + String ip = request.getHeader("X-Forwarded-For"); + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("Proxy-Client-IP"); + } + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("WL-Proxy-Client-IP"); + } + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("HTTP_CLIENT_IP"); + } + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("HTTP_X_FORWARDED_FOR"); + } + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getRemoteAddr(); + } + } else if (ip.length() > 15) { + String[] ips = ip.split(","); + for (int index = 0; index < ips.length; index++) { + String strIp = ips[index]; + if (!("unknown".equalsIgnoreCase(strIp))) { + ip = strIp; + break; + } + } + } + return ip; + } - @Override - public boolean preHandle(HttpServletRequest request, HttpServletResponse response, - Object handler) throws Exception { - if(debug){ - return true; - } - String token = request.getHeader("Authorization"); - if (StringUtils.isNotBlank(token)) { - if(userCenter.isLogin(request) == true) { - return true; - } - } - log.error("the user is not logged in,remoteAddr:"+ RequestUtils.getIpAddress(request)+",requestUrl:"+request.getRequestURL()); - response.setStatus(401); - return false; - } - }) - .addPathPatterns("/**") - .excludePathPatterns("/swagger-resources/**") - .excludePathPatterns("/**/api-docs") - .excludePathPatterns("/**/springfox-swagger-ui/**") - .excludePathPatterns("/**/swagger-ui.html") - .excludePathPatterns("/login/*") - .excludePathPatterns("/sms/*") - ; - } } diff --git a/hai-user/src/main/java/com/web/controller/CoresController.java b/hai-user/src/main/java/com/web/controller/CoresController.java index 3ac133c6..fd7124cc 100644 --- a/hai-user/src/main/java/com/web/controller/CoresController.java +++ b/hai-user/src/main/java/com/web/controller/CoresController.java @@ -8,11 +8,17 @@ import com.hai.common.security.UserCenter; import com.hai.common.utils.MemberValidateUtil; import com.hai.common.utils.RedisUtil; import com.hai.common.utils.ResponseMsgUtil; +import com.hai.config.HuiLianTongUnionCardConfig; +import com.hai.entity.HighOilCard; +import com.hai.entity.HighUserCard; import com.hai.enum_type.LoginPlatform; import com.hai.enum_type.RedisFileFolder; +import com.hai.enum_type.UserCardType; import com.hai.model.HighUserModel; import com.hai.model.ResponseData; import com.hai.model.UserInfoModel; +import com.hai.service.HighOilCardService; +import com.hai.service.HighUserCardService; import com.hai.service.HighUserService; import com.web.type.LoginType; import io.swagger.annotations.Api; @@ -30,6 +36,8 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.util.HashMap; +import java.util.List; +import java.util.Map; /** * @className: CoresController @@ -50,9 +58,76 @@ public class CoresController { @Resource private HighUserService userService; + @Resource + private HighUserCardService userCardService; + + @Resource + private HighOilCardService oilCardService; + @Resource private UserCenter userCenter; + @RequestMapping(value = "/getUserDetail", method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "获取用户详情") + public ResponseData getUserDetail(HttpServletRequest request, HttpServletResponse response) { + try { + HighUserModel userInfoModel = userCenter.getSessionModel(HighUserModel.class); + if (userInfoModel == null) { + log.error("CoresController --> outLogin() error!", "用户身份错误或已过期"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.SEC_USER_EXPIRED, ""); + } + return ResponseMsgUtil.success(userService.getDetailDataByUser(userInfoModel.getHighUser().getId())); + + } catch (Exception e) { + log.error("CoresController --> getUserDetail() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/getUserAccount", method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "获取用户账户余额") + public ResponseData getUserAccount(HttpServletRequest request, HttpServletResponse response) { + try { + HighUserModel userInfoModel = userCenter.getSessionModel(HighUserModel.class); + if (userInfoModel == null) { + log.error("CoresController --> outLogin() error!", "用户身份错误或已过期"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.SEC_USER_EXPIRED, ""); + } + + Map map = new HashMap<>(); + map.put("integral", userService.findByUserId(userInfoModel.getHighUser().getId()).getGold()); + map.put("oilCardPrice", 0); + map.put("hltCardPrice", 0); + + // 嗨森逛油卡 + List oilCardList = userCardService.getListByUser(userInfoModel.getHighUser().getId(), UserCardType.type2.getType()); + if (oilCardList.size() > 0) { + // 查询油卡 + HighOilCard oilCard = oilCardService.getOilCardByCardNo(oilCardList.get(0).getCardNo()); + if (oilCard != null) { + map.put("oilCardPrice", oilCard.getAmount()); + } + } + + // 贵州汇联通工会卡 + List hltCardList = userCardService.getListByUser(userInfoModel.getHighUser().getId(), UserCardType.type1.getType()); + if (hltCardList.size() > 0) { + // 查询油卡 + JSONObject cardInfo = HuiLianTongUnionCardConfig.queryBalance(oilCardList.get(0).getCardNo()); + if (StringUtils.isBlank(cardInfo.getString("data"))) { + map.put("hltCardPrice", cardInfo.getString("data")); + } + } + return ResponseMsgUtil.success(map); + + } catch (Exception e) { + log.error("CoresController --> getUserAccount() error!", e); + return ResponseMsgUtil.exception(e); + } + } + @RequestMapping(value = "/outLogin", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "退出登录")