小程序支付
This commit is contained in:
parent
0c222c88a5
commit
b9bac4a4b0
2
fuintBackend/db/待优化项
Normal file
2
fuintBackend/db/待优化项
Normal file
@ -0,0 +1,2 @@
|
||||
1、 transaction_id存储
|
||||
2、
|
@ -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<String, String> 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";
|
||||
|
@ -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";
|
||||
|
@ -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;
|
||||
}
|
@ -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;
|
||||
}
|
@ -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<String, String> applet(Map<String, String> map) throws Exception;
|
||||
public Map<String, Object> applet(ReceiveParameter receiveParameter) throws Exception;
|
||||
|
||||
/**
|
||||
* 退款
|
||||
|
@ -16,6 +16,13 @@ public interface MerchantConfigService extends IService<MerchantConfig> {
|
||||
*/
|
||||
public MerchantConfig selectMeChByIsUse(String isUse);
|
||||
|
||||
/**
|
||||
* 根据店铺id查询正在使用的商户信息
|
||||
* @param storeId
|
||||
* @return
|
||||
*/
|
||||
public MerchantConfig selectMeChByIdIsUse(int storeId);
|
||||
|
||||
/**
|
||||
* 根据店铺id查询商户信息
|
||||
* @return
|
||||
|
@ -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<String, String> queryOrder(Map<String, String> map1) throws Exception {
|
||||
@ -321,38 +315,93 @@ public class FyPayServiceImpl implements FyPayService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> applet(Map<String, String> 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<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"));
|
||||
public Map<String, Object> applet(ReceiveParameter receiveParameter) throws Exception {
|
||||
Map<String, Object> 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<String, String> resMap = Utils.xmlStr2Map(rspXml);
|
||||
// 公钥
|
||||
Const.INS_PUBLIC_KEY = merchantConfig.getPublicKey();
|
||||
// 私钥
|
||||
Const.INS_PRIVATE_KEY = merchantConfig.getPrivateKey();
|
||||
Map<String, String> 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<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 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
|
||||
|
@ -24,6 +24,15 @@ public class MerchantConfigServiceImpl extends ServiceImpl<MerchantConfigMapper,
|
||||
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
|
||||
public List<MerchantConfig> selectMeChByIsOpen() {
|
||||
QueryWrapper queryWrapper = new QueryWrapper<>();
|
||||
|
@ -103,8 +103,9 @@ public class Utils {
|
||||
Map<String, String> 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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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<CardValueRecordMappe
|
||||
map.put("privateKey",merchantConfig.getPrivateKey());
|
||||
map.put("type","CVR");
|
||||
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 {
|
||||
fyPayService.applet(map);
|
||||
fyPayService.applet(receiveParameter);
|
||||
pay = true;
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
||||
}
|
||||
|
@ -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> {
|
||||
}
|
@ -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);
|
||||
}
|
@ -84,7 +84,7 @@ public interface OilOrderService extends IService<OilOrder> {
|
||||
* 小程序订单支付
|
||||
* @param map
|
||||
*/
|
||||
public Map<String, String> appletPay(Map<String,String> map);
|
||||
public Map<String, Object> appletPay(Map<String,String> map);
|
||||
|
||||
/**
|
||||
* 根据订单号修改订单支付状态
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -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<OilOrderMapper, OilOrder> i
|
||||
private OilNumberService oilNumberService;
|
||||
|
||||
@Override
|
||||
public Map<String, String> appletPay(Map<String, String> map) {
|
||||
public Map<String, Object> appletPay(Map<String, String> map) {
|
||||
String orderNo = map.get("orderNo");
|
||||
// 支付金额
|
||||
Integer payAmount = (int) (Double.valueOf(map.get("payAmount"))*100);
|
||||
@ -487,7 +488,7 @@ public class OilOrderServiceImpl extends ServiceImpl<OilOrderMapper, OilOrder> i
|
||||
|
||||
oilOrder.setTankId(tankId);
|
||||
|
||||
Map<String, String> applet = null;
|
||||
Map<String, Object> applet = null;
|
||||
|
||||
if (!map.get("payAmount").equals("0")) {
|
||||
// 调用支付接口
|
||||
@ -496,36 +497,18 @@ public class OilOrderServiceImpl extends ServiceImpl<OilOrderMapper, OilOrder> i
|
||||
if (list.size() > 0) {
|
||||
oilConfigService.oilRule();
|
||||
}
|
||||
// 根据店铺id查询商户配置信息
|
||||
MerchantConfig merchantConfig = merchantConfigService.selectMeChByIsUse("1");
|
||||
LJUserVo userVo = userService.selectUserById(oilOrder.getUserId());
|
||||
// 处理支付需要的数据
|
||||
Map<String, String> 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();
|
||||
|
@ -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);
|
||||
|
@ -32,7 +32,7 @@ public class LJUserVo extends BaseEntity {
|
||||
private String name;
|
||||
|
||||
// 微信
|
||||
@ExcelProperty(value = "微信")
|
||||
// @ExcelProperty(value = "微信")
|
||||
private String openId;
|
||||
|
||||
// 手机号码
|
||||
|
@ -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);
|
||||
}
|
||||
});
|
||||
|
@ -73,7 +73,7 @@
|
||||
userInfo: {
|
||||
storeId: 0,
|
||||
staffId: "",
|
||||
phone: '15426845715'
|
||||
phone: '18457621459'
|
||||
},
|
||||
|
||||
type: 'phone',
|
||||
|
@ -46,11 +46,21 @@
|
||||
<view class="" v-if="item.orderStatus=='paid'">{{parseTime(item.payTime)}}</view>
|
||||
<view class="" v-else>{{item.createTime}}</view>
|
||||
</view>
|
||||
<view class="end-box" @click="goComment()">
|
||||
<view v-if="item.orderStatus=='paid'" class="end-box" @click="goComment()">
|
||||
<view class="anniu">
|
||||
<text>评价有礼</text>
|
||||
</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 class="box-order" v-for="(item,index) in balanceList" :key="index">
|
||||
@ -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({
|
||||
|
@ -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)=>{
|
||||
|
Loading…
Reference in New Issue
Block a user