小程序支付

This commit is contained in:
cun-nan 2023-12-22 16:33:34 +08:00
parent 0c222c88a5
commit b9bac4a4b0
24 changed files with 463 additions and 94 deletions

View File

@ -0,0 +1,2 @@
1、 transaction_id存储
2、

View File

@ -1,9 +1,14 @@
package com.fuint.api.fuyou.controller; package com.fuint.api.fuyou.controller;
import cn.hutool.core.util.ObjectUtil;
import com.fuint.api.fuyou.entity.Const; import com.fuint.api.fuyou.entity.Const;
import com.fuint.api.fuyou.service.FyPayService; import com.fuint.api.fuyou.service.FyPayService;
import com.fuint.api.fuyou.util.Utils; 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.business.order.service.OilOrderService;
import com.fuint.common.util.RedisLock;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -12,7 +17,9 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.URLDecoder; import java.net.URLDecoder;
import java.util.Date;
import java.util.Map; import java.util.Map;
import java.util.concurrent.TimeUnit;
@RestController @RestController
@RequestMapping("/api/fyPay") @RequestMapping("/api/fyPay")
@ -20,6 +27,11 @@ public class FyPayController {
@Autowired @Autowired
@Lazy @Lazy
private OilOrderService orderService; private OilOrderService orderService;
@Autowired
@Lazy
private AllOrderInfoService allOrderInfoService;
@Autowired
private RedisLock redisLock;
// 接收支付平台异步通知的接口 // 接收支付平台异步通知的接口
@PostMapping("/notify") @PostMapping("/notify")
@ -30,7 +42,25 @@ public class FyPayController {
Map<String, String> reqMap = Utils.xmlStr2Map(decode); Map<String, String> reqMap = Utils.xmlStr2Map(decode);
if (reqMap.get("result_msg").equals("SUCCESS")){ if (reqMap.get("result_msg").equals("SUCCESS")){
String orderNo = reqMap.get("mchnt_order_no"); 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"; return "1";
}else { }else {
return "0"; return "0";

View File

@ -46,6 +46,7 @@ public class Const {
//富友回调公钥 //富友回调公钥
public static String INS_PUBLIC_KEYS="MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCj1SsMt4S9SMcNpXrcQ9ET4hHdX0UX/1RTdD9GzxzSDwTEsLQuUNaX0VP8NQ7NWvMdgCYnST74oV81ht0GQd3aax6fyXjDETYC5tq0sHkJxwtiynTcssPBjM2LipTeY6Sv8cUS1MPnvRX2Cs1RXkB8ZdUp9dCaNnTxFOPJGB1E4wIDAQAB"; 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"; // public static String notify_url = "https://www.fuint.cn/fuint-application/clientApi/pay/aliPayCallback";

View File

@ -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;
}

View File

@ -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;
}

View File

@ -1,5 +1,7 @@
package com.fuint.api.fuyou.service; package com.fuint.api.fuyou.service;
import com.fuint.api.fuyou.entity.ReceiveParameter;
import java.util.Map; import java.util.Map;
public interface FyPayService { public interface FyPayService {
@ -22,7 +24,7 @@ public interface FyPayService {
* @return * @return
* @throws Exception * @throws Exception
*/ */
public Map<String, String> applet(Map<String, String> map) throws Exception; public Map<String, Object> applet(ReceiveParameter receiveParameter) throws Exception;
/** /**
* 退款 * 退款

View File

@ -16,6 +16,13 @@ public interface MerchantConfigService extends IService<MerchantConfig> {
*/ */
public MerchantConfig selectMeChByIsUse(String isUse); public MerchantConfig selectMeChByIsUse(String isUse);
/**
* 根据店铺id查询正在使用的商户信息
* @param storeId
* @return
*/
public MerchantConfig selectMeChByIdIsUse(int storeId);
/** /**
* 根据店铺id查询商户信息 * 根据店铺id查询商户信息
* @return * @return

View File

@ -5,13 +5,9 @@ import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.fuint.api.fuyou.entity.Builder; import com.fuint.api.fuyou.entity.*;
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.service.FyPayService; import com.fuint.api.fuyou.service.FyPayService;
import com.fuint.api.fuyou.service.MerchantConfigService; import com.fuint.api.fuyou.service.MerchantConfigService;
import com.fuint.api.fuyou.util.HttpUtils;
import com.fuint.api.fuyou.util.Utils; import com.fuint.api.fuyou.util.Utils;
import com.fuint.business.integral.service.IntegralOrdersService; import com.fuint.business.integral.service.IntegralOrdersService;
import com.fuint.business.marketingActivity.cardFavorable.entity.CardFavorableRecord; 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.marketingActivity.cardValue.service.CardValueRecordService;
import com.fuint.business.order.entity.*; import com.fuint.business.order.entity.*;
import com.fuint.business.order.service.*; 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 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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.net.URLDecoder;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.net.URLEncoder;
import java.util.*; import java.util.*;
@Service @Service
@ -117,6 +109,8 @@ public class FyPayServiceImpl implements FyPayService {
private CardFavorableRecordService cardFavorableRecordService; private CardFavorableRecordService cardFavorableRecordService;
@Autowired @Autowired
private OrderGoodsService orderGoodsService; private OrderGoodsService orderGoodsService;
@Autowired
private LJUserService userService;
@Override @Override
public Map<String, String> queryOrder(Map<String, String> map1) throws Exception { public Map<String, String> queryOrder(Map<String, String> map1) throws Exception {
@ -321,38 +315,93 @@ public class FyPayServiceImpl implements FyPayService {
} }
@Override @Override
public Map<String, String> applet(Map<String, String> map1) throws Exception { public Map<String, Object> applet(ReceiveParameter receiveParameter) throws Exception {
String publicKey = map1.get("publicKey"); Map<String, Object> res = new HashMap<>();
String privateKey = map1.get("privateKey"); try {
Const.INS_PUBLIC_KEY = publicKey; // 查询商户配置信息
Const.INS_PRIVATE_KEY = privateKey; MerchantConfig merchantConfig = merchantConfigService.selectMeChByIdIsUse(receiveParameter.getStoreId());
String orderNo = map1.get("orderNo"); // 查询用户信息
String allAmount = map1.get("allAmount"); LJUserVo userVo = userService.selectUserById(receiveParameter.getUserId());
String insCd = map1.get("insCd");
String mchntCd = map1.get("mchntCd");
String goodsDes = map1.get("goodsDes");
Map<String, String> 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"));
// 请求报文 // 公钥
String reqBody = Message.requestMsg(map); Const.INS_PUBLIC_KEY = merchantConfig.getPublicKey();
// 响应报文 // 私钥
String rspXml = Message.responseMsg(reqBody,Const.fuiou_32_url); Const.INS_PRIVATE_KEY = merchantConfig.getPrivateKey();
//响应报文验签 Map<String, String> map = Builder.buildFuiou23();
Map<String, String> resMap = Utils.xmlStr2Map(rspXml); // 微信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<String, String> 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 res;
return resMap; }
@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 @Override

View File

@ -24,6 +24,15 @@ public class MerchantConfigServiceImpl extends ServiceImpl<MerchantConfigMapper,
return merchantConfig; return merchantConfig;
} }
@Override
public MerchantConfig selectMeChByIdIsUse(int storeId) {
QueryWrapper queryWrapper = new QueryWrapper<>();
queryWrapper.eq("is_use","1");
queryWrapper.eq("store_id",storeId);
MerchantConfig merchantConfig = baseMapper.selectOne(queryWrapper);
return merchantConfig;
}
@Override @Override
public List<MerchantConfig> selectMeChByIsOpen() { public List<MerchantConfig> selectMeChByIsOpen() {
QueryWrapper queryWrapper = new QueryWrapper<>(); QueryWrapper queryWrapper = new QueryWrapper<>();

View File

@ -103,8 +103,9 @@ public class Utils {
Map<String, String> mapNew = paraFilter(map); Map<String, String> mapNew = paraFilter(map);
String preSignStr = createLinkString(mapNew); 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);
} }
/** /**

View File

@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fuint.api.fuyou.entity.MerchantConfig; 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.FyPayService;
import com.fuint.api.fuyou.service.MerchantConfigService; import com.fuint.api.fuyou.service.MerchantConfigService;
import com.fuint.business.commission.entity.CommissionRecord; import com.fuint.business.commission.entity.CommissionRecord;
@ -126,10 +127,18 @@ public class CardValueRecordServiceImpl extends ServiceImpl<CardValueRecordMappe
map.put("privateKey",merchantConfig.getPrivateKey()); map.put("privateKey",merchantConfig.getPrivateKey());
map.put("type","CVR"); map.put("type","CVR");
map.put("orderId",cardValueRecordDTO.getId().toString()); map.put("orderId",cardValueRecordDTO.getId().toString());
// 处理支付需要的数据
ReceiveParameter receiveParameter = new ReceiveParameter();
receiveParameter.setOrderNo(orderNo);
receiveParameter.setType("油品订单");
receiveParameter.setContent("油品订单");
receiveParameter.setGoodsMoney(theAmountToBePaid);
receiveParameter.setStoreId(0);
receiveParameter.setPayType("WECHAT");
receiveParameter.setUserId(101);
// 调用支付接口 // 调用支付接口
try { try {
fyPayService.applet(map); fyPayService.applet(receiveParameter);
pay = true; pay = true;
} catch (Exception e){ } catch (Exception e){
e.printStackTrace(); e.printStackTrace();

View File

@ -0,0 +1,31 @@
package com.fuint.business.order.controller;
import com.fuint.business.order.service.AllOrderInfoService;
import com.fuint.framework.web.BaseController;
import com.fuint.framework.web.ResponseObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
@RestController
@RequestMapping("/business/allOrderInfo")
public class AllOrderInfoController extends BaseController {
@Autowired
private AllOrderInfoService allOrderInfoService;
/**
* 根据订单号修改订单支付状态
* @param map
* @return
*/
@PostMapping("/orderStatus")
public ResponseObject editStatus(@RequestBody Map<String,String> map){
String orderNo = map.get("orderNo");
String status = map.get("status");
return getSuccessResult(allOrderInfoService.updateAllOrderInfoByOrderNo(orderNo,status));
}
}

View File

@ -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;
}

View File

@ -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<AllOrderInfo> {
}

View File

@ -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);
}

View File

@ -84,7 +84,7 @@ public interface OilOrderService extends IService<OilOrder> {
* 小程序订单支付 * 小程序订单支付
* @param map * @param map
*/ */
public Map<String, String> appletPay(Map<String,String> map); public Map<String, Object> appletPay(Map<String,String> map);
/** /**
* 根据订单号修改订单支付状态 * 根据订单号修改订单支付状态

View File

@ -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<AllOrderInfoMapper,AllOrderInfo> 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;
}
}

View File

@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fuint.api.fuyou.entity.MerchantConfig; 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.FyPayService;
import com.fuint.api.fuyou.service.MerchantConfigService; import com.fuint.api.fuyou.service.MerchantConfigService;
import com.fuint.api.fuyou.service.OilConfigService; import com.fuint.api.fuyou.service.OilConfigService;
@ -435,7 +436,7 @@ public class OilOrderServiceImpl extends ServiceImpl<OilOrderMapper, OilOrder> i
private OilNumberService oilNumberService; private OilNumberService oilNumberService;
@Override @Override
public Map<String, String> appletPay(Map<String, String> map) { public Map<String, Object> appletPay(Map<String, String> map) {
String orderNo = map.get("orderNo"); String orderNo = map.get("orderNo");
// 支付金额 // 支付金额
Integer payAmount = (int) (Double.valueOf(map.get("payAmount"))*100); Integer payAmount = (int) (Double.valueOf(map.get("payAmount"))*100);
@ -487,7 +488,7 @@ public class OilOrderServiceImpl extends ServiceImpl<OilOrderMapper, OilOrder> i
oilOrder.setTankId(tankId); oilOrder.setTankId(tankId);
Map<String, String> applet = null; Map<String, Object> applet = null;
if (!map.get("payAmount").equals("0")) { if (!map.get("payAmount").equals("0")) {
// 调用支付接口 // 调用支付接口
@ -496,36 +497,18 @@ public class OilOrderServiceImpl extends ServiceImpl<OilOrderMapper, OilOrder> i
if (list.size() > 0) { if (list.size() > 0) {
oilConfigService.oilRule(); oilConfigService.oilRule();
} }
// 根据店铺id查询商户配置信息
MerchantConfig merchantConfig = merchantConfigService.selectMeChByIsUse("1");
LJUserVo userVo = userService.selectUserById(oilOrder.getUserId());
// 处理支付需要的数据 // 处理支付需要的数据
Map<String, String> map1 = new HashMap<>(); ReceiveParameter receiveParameter = new ReceiveParameter();
// 需要支付的总金额 receiveParameter.setOrderNo(orderNo);
map1.put("allAmount", payAmount.toString()); receiveParameter.setType("油品订单");
// 订单号 receiveParameter.setContent("油品订单");
map1.put("orderNo", oilOrder.getOrderNo()); receiveParameter.setGoodsMoney(oilOrder.getOrderAmount());
// 机构号 receiveParameter.setStoreId(oilOrder.getStoreId());
map1.put("insCd", merchantConfig.getInsCd()); receiveParameter.setPayType(oilOrder.getPayType());
// 商户号 receiveParameter.setUserId(oilOrder.getUserId());
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());
// 调用支付接口 // 调用支付接口
try { try {
applet = fyPayService.applet(map1); applet = fyPayService.applet(receiveParameter);
applet.put("orderNo",orderNo); applet.put("orderNo",orderNo);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();

View File

@ -28,7 +28,7 @@ public class LJStoreController extends BaseController {
return getSuccessResult(store); return getSuccessResult(store);
} }
@GetMapping("storeInfoUni") @GetMapping("storeInfoUni")
public ResponseObject storeInfoUni(Integer storeId){ public ResponseObject storeInfoUni(Integer storeId){
LJStore store = storeService.selectStoreByIdUni(storeId); LJStore store = storeService.selectStoreByIdUni(storeId);
return getSuccessResult(store); return getSuccessResult(store);

View File

@ -32,7 +32,7 @@ public class LJUserVo extends BaseEntity {
private String name; private String name;
// 微信 // 微信
@ExcelProperty(value = "微信") // @ExcelProperty(value = "微信")
private String openId; private String openId;
// 手机号码 // 手机号码

View File

@ -349,16 +349,16 @@
} }
}) })
uni.showToast({ // uni.showToast({
title: "获取位置信息成功", // title: "",
icon: "none" // icon: "none"
}) // })
}, },
fail: function(err) { fail: function(err) {
_this.getStore(2); _this.getStore(2);
uni.showToast({ // uni.showToast({
title: "获取位置信息失败" // title: ""
}) // })
console.log('获取位置信息失败: ' + err.errMsg); console.log('获取位置信息失败: ' + err.errMsg);
} }
}); });

View File

@ -73,7 +73,7 @@
userInfo: { userInfo: {
storeId: 0, storeId: 0,
staffId: "", staffId: "",
phone: '15426845715' phone: '18457621459'
}, },
type: 'phone', type: 'phone',

View File

@ -46,11 +46,21 @@
<view class="" v-if="item.orderStatus=='paid'">{{parseTime(item.payTime)}}</view> <view class="" v-if="item.orderStatus=='paid'">{{parseTime(item.payTime)}}</view>
<view class="" v-else>{{item.createTime}}</view> <view class="" v-else>{{item.createTime}}</view>
</view> </view>
<view class="end-box" @click="goComment()"> <view v-if="item.orderStatus=='paid'" class="end-box" @click="goComment()">
<view class="anniu"> <view class="anniu">
<text>评价有礼</text> <text>评价有礼</text>
</view> </view>
</view> </view>
<view v-else-if="item.orderStatus=='unpaid'" class="end-box" @click="goPayment()">
<view class="anniu">
<text>去支付</text>
</view>
</view>
<view v-else class="end-box">
<!-- <view class="anniu">
<text>去支付</text>
</view> -->
</view>
</view> </view>
<!-- 储值卡订单列表 --> <!-- 储值卡订单列表 -->
<view class="box-order" v-for="(item,index) in balanceList" :key="index"> <view class="box-order" v-for="(item,index) in balanceList" :key="index">
@ -114,7 +124,7 @@
balanceList:[], balanceList:[],
map: { map: {
page: 1, page: 1,
pageSize: 5, pageSize: 10,
storeId: "", storeId: "",
orderStatus: "", orderStatus: "",
remark: "", remark: "",
@ -133,7 +143,7 @@
onLoad(option) { onLoad(option) {
this.tapindex = option.id this.tapindex = option.id
this.getTapIndex(option.id) this.getTapIndex(option.id)
this.getMyOrder() // this.getMyOrder()
this.getStores() this.getStores()
this.getPayList() this.getPayList()
}, },
@ -211,7 +221,7 @@
getStores() { getStores() {
let _this = this; let _this = this;
request({ request({
url: "business/storeInformation/store/stores", url: "business/storeInformation/store/list",
method: 'get', method: 'get',
}).then((res) => { }).then((res) => {
_this.storeList = res.data _this.storeList = res.data
@ -247,6 +257,7 @@
} }
_this.total = res.data.total _this.total = res.data.total
uni.hideLoading(); uni.hideLoading();
console.log(res,_this.map,_this.map.page)
} }
}) })
@ -255,6 +266,8 @@
this.tapindex = index this.tapindex = index
if (this.tapindex == 0) { if (this.tapindex == 0) {
this.map = { this.map = {
page: 1,
pageSize: 10,
storeId: "", storeId: "",
orderStatus: "", orderStatus: "",
remark: "", remark: "",
@ -263,7 +276,7 @@
} else if (this.tapindex == 1) { } else if (this.tapindex == 1) {
this.map = { this.map = {
page: 1, page: 1,
pageSize: 5, pageSize: 10,
storeId: "", storeId: "",
orderStatus: "unpaid", orderStatus: "unpaid",
remark: "", remark: "",
@ -272,7 +285,7 @@
} else if (this.tapindex == 2) { } else if (this.tapindex == 2) {
this.map = { this.map = {
page: 1, page: 1,
pageSize: 5, pageSize: 10,
storeId: "", storeId: "",
orderStatus: "paid", orderStatus: "paid",
remark: "", remark: "",
@ -281,13 +294,16 @@
} else { } else {
this.map = { this.map = {
page: 1, page: 1,
pageSize: 5, pageSize: 10,
storeId: "", storeId: "",
orderStatus: "paid", orderStatus: "paid",
remark: "待评价", remark: "待评价",
} }
this.getMyOrder() this.getMyOrder()
} }
},
goPayment(){
}, },
goComment() { goComment() {
uni.navigateTo({ uni.navigateTo({

View File

@ -400,14 +400,19 @@
// }else{ // }else{
// payProvider = "alipay" // payProvider = "alipay"
// } // }
_this.orderInfo = JSON.parse(res.data.reserved_pay_info); _this.orderInfo = JSON.parse(res.data.data.reservedPayInfo);
uni.requestPayment({ uni.requestPayment({
// provider: 'wxpay' 'alipay' // provider: 'wxpay' 'alipay'
provider: payProvider, provider: payProvider,
//
timeStamp: _this.orderInfo.timeStamp, timeStamp: _this.orderInfo.timeStamp,
//
nonceStr: _this.orderInfo.nonceStr, nonceStr: _this.orderInfo.nonceStr,
//
package: _this.orderInfo.package, package: _this.orderInfo.package,
//
signType: 'MD5', signType: 'MD5',
//
paySign: _this.orderInfo.paySign, paySign: _this.orderInfo.paySign,
success: function (res) { success: function (res) {
console.log('success:',res); console.log('success:',res);
@ -417,7 +422,7 @@
}, },
fail: function (err) { fail: function (err) {
request({ request({
url: "business/oilOrder/orderStatus", url: "/business/allOrderInfo/orderStatus",
method: 'post', method: 'post',
data: {"orderNo":res.data.orderNo,"status":"payFail"}, data: {"orderNo":res.data.orderNo,"status":"payFail"},
}).then((res)=>{ }).then((res)=>{