From b9bac4a4b0005bd4b7414160db2a1fab7130ba93 Mon Sep 17 00:00:00 2001 From: cun-nan <19819293608@163.com> Date: Fri, 22 Dec 2023 16:33:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E6=94=AF=E4=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fuintBackend/db/待优化项 | 2 + .../api/fuyou/controller/FyPayController.java | 32 ++++- .../com/fuint/api/fuyou/entity/Const.java | 1 + .../api/fuyou/entity/ReceiveParameter.java | 38 ++++++ .../api/fuyou/entity/ReturnParameter.java | 20 +++ .../fuint/api/fuyou/service/FyPayService.java | 4 +- .../fuyou/service/MerchantConfigService.java | 7 + .../fuyou/service/impl/FyPayServiceImpl.java | 127 ++++++++++++------ .../impl/MerchantConfigServiceImpl.java | 9 ++ .../java/com/fuint/api/fuyou/util/Utils.java | 5 +- .../impl/CardValueRecordServiceImpl.java | 13 +- .../controller/AllOrderInfoController.java | 31 +++++ .../business/order/entity/AllOrderInfo.java | 79 +++++++++++ .../order/mapper/AllOrderInfoMapper.java | 7 + .../order/service/AllOrderInfoService.java | 33 +++++ .../order/service/OilOrderService.java | 2 +- .../service/impl/AllOrderInfoServiceImpl.java | 47 +++++++ .../service/impl/OilOrderServiceImpl.java | 41 ++---- .../controller/LJStoreController.java | 2 +- .../business/userManager/vo/LJUserVo.java | 2 +- gasStation-uni/pages/index/index.vue | 14 +- gasStation-uni/pagesLogin/login/login.vue | 2 +- gasStation-uni/pagesMy/myorder/myorder.vue | 30 ++++- .../pagesRefuel/orderDetail/index.vue | 9 +- 24 files changed, 463 insertions(+), 94 deletions(-) create mode 100644 fuintBackend/db/待优化项 create mode 100644 fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/entity/ReceiveParameter.java create mode 100644 fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/entity/ReturnParameter.java create mode 100644 fuintBackend/fuint-application/src/main/java/com/fuint/business/order/controller/AllOrderInfoController.java create mode 100644 fuintBackend/fuint-application/src/main/java/com/fuint/business/order/entity/AllOrderInfo.java create mode 100644 fuintBackend/fuint-application/src/main/java/com/fuint/business/order/mapper/AllOrderInfoMapper.java create mode 100644 fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/AllOrderInfoService.java create mode 100644 fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/AllOrderInfoServiceImpl.java diff --git a/fuintBackend/db/待优化项 b/fuintBackend/db/待优化项 new file mode 100644 index 000000000..353e3d020 --- /dev/null +++ b/fuintBackend/db/待优化项 @@ -0,0 +1,2 @@ +1、 transaction_id存储 +2、 \ No newline at end of file diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/controller/FyPayController.java b/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/controller/FyPayController.java index 4f9ba1f4f..38653a466 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/controller/FyPayController.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/controller/FyPayController.java @@ -1,9 +1,14 @@ package com.fuint.api.fuyou.controller; +import cn.hutool.core.util.ObjectUtil; import com.fuint.api.fuyou.entity.Const; import com.fuint.api.fuyou.service.FyPayService; import com.fuint.api.fuyou.util.Utils; +import com.fuint.business.order.entity.AllOrderInfo; +import com.fuint.business.order.entity.OilOrder; +import com.fuint.business.order.service.AllOrderInfoService; import com.fuint.business.order.service.OilOrderService; +import com.fuint.common.util.RedisLock; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.web.bind.annotation.*; @@ -12,7 +17,9 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.UnsupportedEncodingException; import java.net.URLDecoder; +import java.util.Date; import java.util.Map; +import java.util.concurrent.TimeUnit; @RestController @RequestMapping("/api/fyPay") @@ -20,6 +27,11 @@ public class FyPayController { @Autowired @Lazy private OilOrderService orderService; + @Autowired + @Lazy + private AllOrderInfoService allOrderInfoService; + @Autowired + private RedisLock redisLock; // 接收支付平台异步通知的接口 @PostMapping("/notify") @@ -30,7 +42,25 @@ public class FyPayController { Map reqMap = Utils.xmlStr2Map(decode); if (reqMap.get("result_msg").equals("SUCCESS")){ String orderNo = reqMap.get("mchnt_order_no"); - orderService.updateOrderStatus(orderNo,"paid"); + String transactionId = reqMap.get("transaction_id"); + String settleOrderAmt = reqMap.get("settle_order_amt"); + String orderLock = "orderLock_notify"+orderNo; + if (redisLock.tryLock(orderLock,5000, TimeUnit.MILLISECONDS)){ +// 业务逻辑 判断订单状态 + AllOrderInfo allOrderInfo = allOrderInfoService.selectAllOrderInfoByOrderNo(orderNo); + if (ObjectUtil.isNotEmpty(allOrderInfo)){ + allOrderInfo.setPayMoney(Double.valueOf(settleOrderAmt)); + allOrderInfo.setTransactionId(transactionId); + allOrderInfo.setStatus("paid"); + allOrderInfo.setPayTime(new Date()); + allOrderInfoService.updateAllOrderInfo(allOrderInfo); + } + +// 修改油品订单支付状态 + orderService.updateOrderStatus(orderNo,"paid"); + redisLock.unlock(orderLock); + } +// transaction_id 加锁 return "1"; }else { return "0"; diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/entity/Const.java b/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/entity/Const.java index 14d070e6c..286a876bd 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/entity/Const.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/entity/Const.java @@ -46,6 +46,7 @@ public class Const { //富友回调公钥 public static String INS_PUBLIC_KEYS="MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCj1SsMt4S9SMcNpXrcQ9ET4hHdX0UX/1RTdD9GzxzSDwTEsLQuUNaX0VP8NQ7NWvMdgCYnST74oV81ht0GQd3aax6fyXjDETYC5tq0sHkJxwtiynTcssPBjM2LipTeY6Sv8cUS1MPnvRX2Cs1RXkB8ZdUp9dCaNnTxFOPJGB1E4wIDAQAB"; + public static String NOTIFY_PUBLIC_KEYS="MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCbBAl3xSB7YeUnze4yYZmnTeT7OtXZr0sP10TsDVRH2SY/VEjgS9KPmHMmVeKZT3+6xKsUvulgVyie46GGtZPrnoh+glF1gzsYAXJ7dvR/R5nYO5VvfwK/ChPFTiKhbTtO4OKtchgBZuqCbsemG+gFIiVJo37dY0Kg0zISmFHdOQIDAQAB"; //异步通知(回调地址) // public static String notify_url = "https://www.fuint.cn/fuint-application/clientApi/pay/aliPayCallback"; diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/entity/ReceiveParameter.java b/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/entity/ReceiveParameter.java new file mode 100644 index 000000000..3c15b8a06 --- /dev/null +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/entity/ReceiveParameter.java @@ -0,0 +1,38 @@ +package com.fuint.api.fuyou.entity; + +import lombok.Data; + +/** + * 接收的参数 + */ +@Data +public class ReceiveParameter { + /** + * 订单号(与业务表统一) + */ + private String orderNo; + /** + * 类型:1、油品;2、商品;3、储值卡;4、积分;5、囤油卡;6、油品加商品 + */ + private String type; + /** + * 店铺id + */ + private Integer storeId; + /** + * 原价 不需要做(*100)的处理 + */ + private Double goodsMoney; + /** + * 付款方式(数据字典) + */ + private String payType; + /** + * 用户id + */ + private Integer userId; + /** + * 订单描述 + */ + private String content; +} diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/entity/ReturnParameter.java b/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/entity/ReturnParameter.java new file mode 100644 index 000000000..db20baafd --- /dev/null +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/entity/ReturnParameter.java @@ -0,0 +1,20 @@ +package com.fuint.api.fuyou.entity; + +import lombok.Data; + +import java.util.Map; + +/** + * 返回的参数 + */ +@Data +public class ReturnParameter { + /** + * 订单号(与业务表统一) + */ + private String orderNo; + /** + * 响应报文 + */ + private String reservedPayInfo; +} diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/FyPayService.java b/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/FyPayService.java index d458fbeb0..80e577ba3 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/FyPayService.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/FyPayService.java @@ -1,5 +1,7 @@ package com.fuint.api.fuyou.service; +import com.fuint.api.fuyou.entity.ReceiveParameter; + import java.util.Map; public interface FyPayService { @@ -22,7 +24,7 @@ public interface FyPayService { * @return * @throws Exception */ - public Map applet(Map map) throws Exception; + public Map applet(ReceiveParameter receiveParameter) throws Exception; /** * 退款 diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/MerchantConfigService.java b/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/MerchantConfigService.java index 869ed4e66..c6b2adb45 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/MerchantConfigService.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/MerchantConfigService.java @@ -16,6 +16,13 @@ public interface MerchantConfigService extends IService { */ public MerchantConfig selectMeChByIsUse(String isUse); + /** + * 根据店铺id查询正在使用的商户信息 + * @param storeId + * @return + */ + public MerchantConfig selectMeChByIdIsUse(int storeId); + /** * 根据店铺id查询商户信息 * @return diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/impl/FyPayServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/impl/FyPayServiceImpl.java index a6d8ee0e2..9c5e75067 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/impl/FyPayServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/impl/FyPayServiceImpl.java @@ -5,13 +5,9 @@ import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.util.ObjectUtil; import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONObject; -import com.fuint.api.fuyou.entity.Builder; -import com.fuint.api.fuyou.entity.Const; -import com.fuint.api.fuyou.entity.MerchantConfig; -import com.fuint.api.fuyou.entity.Message; +import com.fuint.api.fuyou.entity.*; import com.fuint.api.fuyou.service.FyPayService; import com.fuint.api.fuyou.service.MerchantConfigService; -import com.fuint.api.fuyou.util.HttpUtils; import com.fuint.api.fuyou.util.Utils; import com.fuint.business.integral.service.IntegralOrdersService; import com.fuint.business.marketingActivity.cardFavorable.entity.CardFavorableRecord; @@ -20,17 +16,13 @@ import com.fuint.business.marketingActivity.cardFule.service.CardFuelRecordServi import com.fuint.business.marketingActivity.cardValue.service.CardValueRecordService; import com.fuint.business.order.entity.*; import com.fuint.business.order.service.*; -import com.fuint.common.util.StringUtils; +import com.fuint.business.userManager.service.LJUserService; +import com.fuint.business.userManager.vo.LJUserVo; import lombok.extern.slf4j.Slf4j; -import org.dom4j.Document; -import org.dom4j.DocumentHelper; -import org.dom4j.Element; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.net.URLDecoder; import javax.annotation.Resource; -import java.net.URLEncoder; import java.util.*; @Service @@ -117,6 +109,8 @@ public class FyPayServiceImpl implements FyPayService { private CardFavorableRecordService cardFavorableRecordService; @Autowired private OrderGoodsService orderGoodsService; + @Autowired + private LJUserService userService; @Override public Map queryOrder(Map map1) throws Exception { @@ -321,38 +315,93 @@ public class FyPayServiceImpl implements FyPayService { } @Override - public Map applet(Map map1) throws Exception { - String publicKey = map1.get("publicKey"); - String privateKey = map1.get("privateKey"); - Const.INS_PUBLIC_KEY = publicKey; - Const.INS_PRIVATE_KEY = privateKey; - String orderNo = map1.get("orderNo"); - String allAmount = map1.get("allAmount"); - String insCd = map1.get("insCd"); - String mchntCd = map1.get("mchntCd"); - String goodsDes = map1.get("goodsDes"); - Map map = Builder.buildFuiou23(); - map.put("ins_cd", insCd); - map.put("mchnt_cd", mchntCd); - map.put("goods_des", goodsDes); - map.put("mchnt_order_no",orderNo); - map.put("order_amt", allAmount); - map.put("sub_openid", map1.get("openId")); - map.put("sub_appid", map1.get("appid")); + public Map applet(ReceiveParameter receiveParameter) throws Exception { + Map res = new HashMap<>(); + try { +// 查询商户配置信息 + MerchantConfig merchantConfig = merchantConfigService.selectMeChByIdIsUse(receiveParameter.getStoreId()); +// 查询用户信息 + LJUserVo userVo = userService.selectUserById(receiveParameter.getUserId()); - // 请求报文 - String reqBody = Message.requestMsg(map); -// 响应报文 - String rspXml = Message.responseMsg(reqBody,Const.fuiou_32_url); - //响应报文验签 - Map resMap = Utils.xmlStr2Map(rspXml); + // 公钥 + Const.INS_PUBLIC_KEY = merchantConfig.getPublicKey(); + // 私钥 + Const.INS_PRIVATE_KEY = merchantConfig.getPrivateKey(); + Map map = Builder.buildFuiou23(); + // 微信open_id + map.put("sub_openid", userVo.getOpenId()); + // 机构号 + map.put("ins_cd", merchantConfig.getInsCd()); + // 商户号 + map.put("mchnt_cd", merchantConfig.getMchntCd()); + // appid + map.put("sub_appid", merchantConfig.getAppid()); + // 订单号 + map.put("mchnt_order_no",receiveParameter.getOrderNo()); + // 订单总金额 + Integer goodsMoney = (int) (receiveParameter.getGoodsMoney() * 100); + map.put("order_amt", goodsMoney.toString()); + // 订单描述 + map.put("goods_des", receiveParameter.getContent()); + if (receiveParameter.getPayType().equals("WECHAT")){ + map.put("trade_type","LETPAY"); + } else if (receiveParameter.getPayType().equals("ALIPAY")){ + map.put("trade_type","FWC"); + }else { + res.put("code","error"); + res.put("msg","暂不支持其他支付方式"); + return res; + } - String str = resMap.get("sign"); - if (Utils.verifySign(resMap, str)){ + // 请求报文 + String reqBody = Message.requestMsg(map); + // 响应报文 + String rspXml = Message.responseMsg(reqBody,Const.fuiou_32_url); + //响应报文验签 + Map resMap = Utils.xmlStr2Map(rspXml); + String str = resMap.get("sign"); + if (Utils.verifySign(resMap, str)){ + System.out.println(resMap); +// 添加订单信息 + this.insertAllOrderInfo(receiveParameter); + + res.put("code","success"); + res.put("msg","成功"); + + ReturnParameter returnParameter = new ReturnParameter(); + returnParameter.setOrderNo(receiveParameter.getOrderNo()); + returnParameter.setReservedPayInfo(resMap.get("reserved_pay_info")); + + res.put("data",returnParameter); + return res; + }else { + throw new Exception("验签失败,请联系管理员!"); + } + + }catch (Exception e){ + res.put("code","error"); + res.put("msg",e.getMessage()); + e.printStackTrace(); } - System.out.println(resMap); - return resMap; + return res; + } + + @Autowired + private AllOrderInfoService allOrderInfoService; + + private void insertAllOrderInfo(ReceiveParameter receiveParameter){ + AllOrderInfo allOrderInfo = new AllOrderInfo(); + allOrderInfo.setOrderNo(receiveParameter.getOrderNo()); + allOrderInfo.setType(receiveParameter.getType()); + allOrderInfo.setStoreId(receiveParameter.getStoreId()); + allOrderInfo.setGoodsMoney(receiveParameter.getGoodsMoney()); + allOrderInfo.setPayType(receiveParameter.getPayType()); + allOrderInfo.setUserId(receiveParameter.getUserId()); + allOrderInfo.setPayChannel("applet"); + allOrderInfo.setStatus("unpaid"); + allOrderInfo.setContent(receiveParameter.getContent()); + allOrderInfoService.insertAllOrderInfo(allOrderInfo); } @Override diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/impl/MerchantConfigServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/impl/MerchantConfigServiceImpl.java index a6e3df6b7..2ff1b9ed4 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/impl/MerchantConfigServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/impl/MerchantConfigServiceImpl.java @@ -24,6 +24,15 @@ public class MerchantConfigServiceImpl extends ServiceImpl(); + queryWrapper.eq("is_use","1"); + queryWrapper.eq("store_id",storeId); + MerchantConfig merchantConfig = baseMapper.selectOne(queryWrapper); + return merchantConfig; + } + @Override public List selectMeChByIsOpen() { QueryWrapper queryWrapper = new QueryWrapper<>(); diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/util/Utils.java b/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/util/Utils.java index 36da50bc6..42adff213 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/util/Utils.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/util/Utils.java @@ -103,8 +103,9 @@ public class Utils { Map mapNew = paraFilter(map); String preSignStr = createLinkString(mapNew); -// System.out.println(Sign.verify(preSignStr.getBytes(Const.charset), Const.INS_PUBLIC_KEY, sign)); - return Sign.verify(preSignStr.getBytes(Const.charset), Const.INS_PUBLIC_KEYS, sign); + +// return Sign.verify(preSignStr.getBytes(Const.charset), Const.INS_PUBLIC_KEYS, sign); + return Sign.verify(preSignStr.getBytes(Const.charset), Const.NOTIFY_PUBLIC_KEYS, sign); } /** diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardValue/service/impl/CardValueRecordServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardValue/service/impl/CardValueRecordServiceImpl.java index 398a6cb02..5a1386127 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardValue/service/impl/CardValueRecordServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardValue/service/impl/CardValueRecordServiceImpl.java @@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.fuint.api.fuyou.entity.MerchantConfig; +import com.fuint.api.fuyou.entity.ReceiveParameter; import com.fuint.api.fuyou.service.FyPayService; import com.fuint.api.fuyou.service.MerchantConfigService; import com.fuint.business.commission.entity.CommissionRecord; @@ -126,10 +127,18 @@ public class CardValueRecordServiceImpl extends ServiceImpl map){ + String orderNo = map.get("orderNo"); + String status = map.get("status"); + return getSuccessResult(allOrderInfoService.updateAllOrderInfoByOrderNo(orderNo,status)); + } +} diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/entity/AllOrderInfo.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/entity/AllOrderInfo.java new file mode 100644 index 000000000..8100ebcb5 --- /dev/null +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/entity/AllOrderInfo.java @@ -0,0 +1,79 @@ +package com.fuint.business.order.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fuint.framework.entity.BaseEntity; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; +import java.io.Serializable; + +/** + * 所有订单详情表(AllOrderInfo)实体类 + */ +@Data +@TableName("all_order_info") +@ApiModel(value = "AllOrderInfo对象", description = "所有订单详情表") +public class AllOrderInfo extends BaseEntity implements Serializable { + + private static final long serialVersionUID = 1L; + /** + * 主键 + */ + @ApiModelProperty("自增ID") + @TableId(value = "ID", type = IdType.AUTO) + private Integer id; + /** + * 订单号(与业务表统一) + */ + private String orderNo; + /** + * 类型:1、油品;2、商品;3、储值卡;4、积分;5、囤油卡;6、油品加商品 + */ + private String type; + /** + * 渠道订单号 + */ + private String transactionId; + /** + * 店铺id + */ + private Integer storeId; + /** + * 原价 + */ + private Double goodsMoney; + /** + * 支付金额 + */ + private Double payMoney; + /** + * 支付时间 + */ + private Date payTime; + /** + * 付款方式(数据字典) + */ + private String payType; + /** + * 用户id + */ + private Integer userId; + /** + * 支付渠道(小程序/收银台) + */ + private String payChannel; + /** + * 状态:0、待支付(数据字典) + */ + private String status; + /** + * 订单描述 + */ + private String content; + +} + diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/mapper/AllOrderInfoMapper.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/mapper/AllOrderInfoMapper.java new file mode 100644 index 000000000..033f7e338 --- /dev/null +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/mapper/AllOrderInfoMapper.java @@ -0,0 +1,7 @@ +package com.fuint.business.order.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.fuint.business.order.entity.AllOrderInfo; + +public interface AllOrderInfoMapper extends BaseMapper { +} diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/AllOrderInfoService.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/AllOrderInfoService.java new file mode 100644 index 000000000..659915ee9 --- /dev/null +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/AllOrderInfoService.java @@ -0,0 +1,33 @@ +package com.fuint.business.order.service; + +import com.fuint.business.order.entity.AllOrderInfo; + +public interface AllOrderInfoService { + /** + * 根据订单号查询所有订单信息 + * @param orderNo + * @return + */ + public AllOrderInfo selectAllOrderInfoByOrderNo(String orderNo); + + /** + * 添加所有订单信息 + * @param allOrderInfo + * @return + */ + public int insertAllOrderInfo(AllOrderInfo allOrderInfo); + + /** + * 修改所有订单信息 + * @param allOrderInfo + * @return + */ + public int updateAllOrderInfo(AllOrderInfo allOrderInfo); + + /** + * 根据订单号修改订单状态 + * @param orderNo + * @return + */ + public int updateAllOrderInfoByOrderNo(String orderNo,String status); +} diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/OilOrderService.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/OilOrderService.java index 61469540a..7ed9c8e1f 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/OilOrderService.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/OilOrderService.java @@ -84,7 +84,7 @@ public interface OilOrderService extends IService { * 小程序订单支付 * @param map */ - public Map appletPay(Map map); + public Map appletPay(Map map); /** * 根据订单号修改订单支付状态 diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/AllOrderInfoServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/AllOrderInfoServiceImpl.java new file mode 100644 index 000000000..78e014d64 --- /dev/null +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/AllOrderInfoServiceImpl.java @@ -0,0 +1,47 @@ +package com.fuint.business.order.service.impl; + +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.fuint.business.order.entity.AllOrderInfo; +import com.fuint.business.order.mapper.AllOrderInfoMapper; +import com.fuint.business.order.service.AllOrderInfoService; +import com.fuint.business.order.service.OilOrderService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class AllOrderInfoServiceImpl extends ServiceImpl implements AllOrderInfoService { + @Override + public AllOrderInfo selectAllOrderInfoByOrderNo(String orderNo) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("order_no",orderNo); + return baseMapper.selectOne(queryWrapper); + } + + @Override + public int insertAllOrderInfo(AllOrderInfo allOrderInfo) { + return baseMapper.insert(allOrderInfo); + } + + @Override + public int updateAllOrderInfo(AllOrderInfo allOrderInfo) { + return baseMapper.updateById(allOrderInfo); + } + + @Autowired + private OilOrderService orderService; + + @Override + public int updateAllOrderInfoByOrderNo(String orderNo, String status) { + int row = 0; + AllOrderInfo allOrderInfo = this.selectAllOrderInfoByOrderNo(orderNo); + if (ObjectUtil.isNotEmpty(allOrderInfo)){ + allOrderInfo.setStatus(status); + row = this.updateAllOrderInfo(allOrderInfo); +// 修改油品订单状态 + orderService.updateOrderStatus(orderNo,status); + } + return 0; + } +} diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/OilOrderServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/OilOrderServiceImpl.java index e640b6f26..7e0f12efd 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/OilOrderServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/OilOrderServiceImpl.java @@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.fuint.api.fuyou.entity.MerchantConfig; +import com.fuint.api.fuyou.entity.ReceiveParameter; import com.fuint.api.fuyou.service.FyPayService; import com.fuint.api.fuyou.service.MerchantConfigService; import com.fuint.api.fuyou.service.OilConfigService; @@ -435,7 +436,7 @@ public class OilOrderServiceImpl extends ServiceImpl i private OilNumberService oilNumberService; @Override - public Map appletPay(Map map) { + public Map appletPay(Map map) { String orderNo = map.get("orderNo"); // 支付金额 Integer payAmount = (int) (Double.valueOf(map.get("payAmount"))*100); @@ -487,7 +488,7 @@ public class OilOrderServiceImpl extends ServiceImpl i oilOrder.setTankId(tankId); - Map applet = null; + Map applet = null; if (!map.get("payAmount").equals("0")) { // 调用支付接口 @@ -496,36 +497,18 @@ public class OilOrderServiceImpl extends ServiceImpl i if (list.size() > 0) { oilConfigService.oilRule(); } - // 根据店铺id查询商户配置信息 - MerchantConfig merchantConfig = merchantConfigService.selectMeChByIsUse("1"); - LJUserVo userVo = userService.selectUserById(oilOrder.getUserId()); // 处理支付需要的数据 - Map map1 = new HashMap<>(); -// 需要支付的总金额 - map1.put("allAmount", payAmount.toString()); -// 订单号 - map1.put("orderNo", oilOrder.getOrderNo()); -// 机构号 - map1.put("insCd", merchantConfig.getInsCd()); -// 商户号 - map1.put("mchntCd", merchantConfig.getMchntCd()); -// 商品名称:油号id+油枪 - map1.put("goodsDes", oilOrder.getOils() + oilOrder.getOilGunNum()); -// 公钥 - map1.put("publicKey", merchantConfig.getPublicKey()); -// 私钥 - map1.put("privateKey", merchantConfig.getPrivateKey()); - map1.put("discountAmount", discountAmount); - map1.put("oilCardAmount", oilCardAmount); - map1.put("balanceAmount", balanceAmount); -// oppid - map1.put("openId", userVo.getOpenId()); -// 小程序appid - map1.put("appid", merchantConfig.getAppid()); - + ReceiveParameter receiveParameter = new ReceiveParameter(); + receiveParameter.setOrderNo(orderNo); + receiveParameter.setType("油品订单"); + receiveParameter.setContent("油品订单"); + receiveParameter.setGoodsMoney(oilOrder.getOrderAmount()); + receiveParameter.setStoreId(oilOrder.getStoreId()); + receiveParameter.setPayType(oilOrder.getPayType()); + receiveParameter.setUserId(oilOrder.getUserId()); // 调用支付接口 try { - applet = fyPayService.applet(map1); + applet = fyPayService.applet(receiveParameter); applet.put("orderNo",orderNo); } catch (Exception e) { e.printStackTrace(); diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/storeInformation/controller/LJStoreController.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/storeInformation/controller/LJStoreController.java index c3fdf2b38..19579f2d8 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/storeInformation/controller/LJStoreController.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/storeInformation/controller/LJStoreController.java @@ -28,7 +28,7 @@ public class LJStoreController extends BaseController { return getSuccessResult(store); } - @GetMapping("storeInfoUni") + @GetMapping("storeInfoUni") public ResponseObject storeInfoUni(Integer storeId){ LJStore store = storeService.selectStoreByIdUni(storeId); return getSuccessResult(store); diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/vo/LJUserVo.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/vo/LJUserVo.java index b3fd0f409..1cee0357f 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/vo/LJUserVo.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/vo/LJUserVo.java @@ -32,7 +32,7 @@ public class LJUserVo extends BaseEntity { private String name; // 微信 - @ExcelProperty(value = "微信") +// @ExcelProperty(value = "微信") private String openId; // 手机号码 diff --git a/gasStation-uni/pages/index/index.vue b/gasStation-uni/pages/index/index.vue index ec2ae5b13..b40e119e6 100644 --- a/gasStation-uni/pages/index/index.vue +++ b/gasStation-uni/pages/index/index.vue @@ -349,16 +349,16 @@ } }) - uni.showToast({ - title: "获取位置信息成功", - icon: "none" - }) + // uni.showToast({ + // title: "获取位置信息成功", + // icon: "none" + // }) }, fail: function(err) { _this.getStore(2); - uni.showToast({ - title: "获取位置信息失败" - }) + // uni.showToast({ + // title: "获取位置信息失败" + // }) console.log('获取位置信息失败: ' + err.errMsg); } }); diff --git a/gasStation-uni/pagesLogin/login/login.vue b/gasStation-uni/pagesLogin/login/login.vue index b66ab36e5..3ad91b37b 100644 --- a/gasStation-uni/pagesLogin/login/login.vue +++ b/gasStation-uni/pagesLogin/login/login.vue @@ -73,7 +73,7 @@ userInfo: { storeId: 0, staffId: "", - phone: '15426845715' + phone: '18457621459' }, type: 'phone', diff --git a/gasStation-uni/pagesMy/myorder/myorder.vue b/gasStation-uni/pagesMy/myorder/myorder.vue index 136d2019d..dc26ea4a9 100644 --- a/gasStation-uni/pagesMy/myorder/myorder.vue +++ b/gasStation-uni/pagesMy/myorder/myorder.vue @@ -46,11 +46,21 @@ {{parseTime(item.payTime)}} {{item.createTime}} - + 评价有礼 + + + 去支付 + + + + + @@ -114,7 +124,7 @@ balanceList:[], map: { page: 1, - pageSize: 5, + pageSize: 10, storeId: "", orderStatus: "", remark: "", @@ -133,7 +143,7 @@ onLoad(option) { this.tapindex = option.id this.getTapIndex(option.id) - this.getMyOrder() + // this.getMyOrder() this.getStores() this.getPayList() }, @@ -211,7 +221,7 @@ getStores() { let _this = this; request({ - url: "business/storeInformation/store/stores", + url: "business/storeInformation/store/list", method: 'get', }).then((res) => { _this.storeList = res.data @@ -247,6 +257,7 @@ } _this.total = res.data.total uni.hideLoading(); + console.log(res,_this.map,_this.map.page) } }) @@ -255,6 +266,8 @@ this.tapindex = index if (this.tapindex == 0) { this.map = { + page: 1, + pageSize: 10, storeId: "", orderStatus: "", remark: "", @@ -263,7 +276,7 @@ } else if (this.tapindex == 1) { this.map = { page: 1, - pageSize: 5, + pageSize: 10, storeId: "", orderStatus: "unpaid", remark: "", @@ -272,7 +285,7 @@ } else if (this.tapindex == 2) { this.map = { page: 1, - pageSize: 5, + pageSize: 10, storeId: "", orderStatus: "paid", remark: "", @@ -281,13 +294,16 @@ } else { this.map = { page: 1, - pageSize: 5, + pageSize: 10, storeId: "", orderStatus: "paid", remark: "待评价", } this.getMyOrder() } + }, + goPayment(){ + }, goComment() { uni.navigateTo({ diff --git a/gasStation-uni/pagesRefuel/orderDetail/index.vue b/gasStation-uni/pagesRefuel/orderDetail/index.vue index d3fba1fca..3ec7a8b8d 100644 --- a/gasStation-uni/pagesRefuel/orderDetail/index.vue +++ b/gasStation-uni/pagesRefuel/orderDetail/index.vue @@ -400,14 +400,19 @@ // }else{ // payProvider = "alipay" // } - _this.orderInfo = JSON.parse(res.data.reserved_pay_info); + _this.orderInfo = JSON.parse(res.data.data.reservedPayInfo); uni.requestPayment({ // 微信支付provider: 'wxpay' 支付宝支付 'alipay' provider: payProvider, + // 时间戳 timeStamp: _this.orderInfo.timeStamp, + // 随机字符串 nonceStr: _this.orderInfo.nonceStr, + // 固定值 package: _this.orderInfo.package, + // 解密方式 signType: 'MD5', + // 支付签名 paySign: _this.orderInfo.paySign, success: function (res) { console.log('success:',res); @@ -417,7 +422,7 @@ }, fail: function (err) { request({ - url: "business/oilOrder/orderStatus", + url: "/business/allOrderInfo/orderStatus", method: 'post', data: {"orderNo":res.data.orderNo,"status":"payFail"}, }).then((res)=>{