二维码
This commit is contained in:
parent
6faf9677e1
commit
9edf62a5a2
@ -92,9 +92,12 @@ weixin.official.appSecret=1f55e8749332234d9a074873d8e6a3
|
||||
# \u8D22\u5229\u5B9D
|
||||
#wxpay.appId = wx033c30e366eff6ac
|
||||
#wxpay.appSecret = e46a9a5947380fb70a1aa33a5b427ba4
|
||||
#alipay.appid = 2021004128651378
|
||||
# \u6765\u4E2A\u6CB9\u6167
|
||||
wxpay.appId = wxd8014eaf9bd72e93
|
||||
wxpay.appSecret = 0194125b13cece10d5f6cdd664847b55
|
||||
alipay.appid = 2021004130635045
|
||||
|
||||
wxpay.mchId=1636980812
|
||||
wxpay.apiV2=34354320201030y323e432342343
|
||||
wxpay.certPath=/usr/local/fuint/cert/apiclient_cert.p12
|
||||
|
@ -68,6 +68,14 @@ public class FyPayServiceImpl implements FyPayService {
|
||||
map.put("ins_cd", insCd);
|
||||
map.put("mchnt_cd", mchntCd);
|
||||
map.put("goods_des", goodsDes);
|
||||
// ReceiveParameter receiveParameter = new ReceiveParameter();
|
||||
// receiveParameter.setOrderNo(orderNo);
|
||||
// receiveParameter.setType("油品订单");
|
||||
// receiveParameter.setContent(map1.get("goodsDes"));
|
||||
// receiveParameter.setGoodsMoney(Double.valueOf(map1.get("allAmount")));
|
||||
// receiveParameter.setStoreId(oilOrder.getStoreId());
|
||||
// receiveParameter.setPayType(oilOrder.getPayType());
|
||||
// receiveParameter.setUserId(oilOrder.getUserId());
|
||||
|
||||
// 请求报文
|
||||
String reqBody = Message.requestMsg(map);
|
||||
@ -79,6 +87,7 @@ public class FyPayServiceImpl implements FyPayService {
|
||||
|
||||
String str = resMap.get("sign");
|
||||
if (Utils.verifySign(resMap, str)){
|
||||
// this.insertAllOrderInfo(receiveParameter);
|
||||
ThreadUtil.execAsync(() -> {
|
||||
Timer timer = new Timer();
|
||||
timer.schedule(new TimerTask() {
|
||||
|
@ -91,7 +91,7 @@ public class OilOrderController extends BaseController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量添加订单信息
|
||||
* 批量添加订单信息 并支付
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
@ -101,6 +101,17 @@ public class OilOrderController extends BaseController {
|
||||
return getSuccessResult(order);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量添加订单信息 并支付
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/scanAppletQrCode")
|
||||
public ResponseObject scanAppletQrCode(@Validated @RequestBody Map<String,String> map){
|
||||
Map<String, String> order = orderService.scanAppletQrCode(map);
|
||||
return getSuccessResult(order);
|
||||
}
|
||||
|
||||
/**
|
||||
* 小程序支付接口
|
||||
* @param map
|
||||
|
@ -0,0 +1,17 @@
|
||||
package com.fuint.business.order.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 囤油卡信息
|
||||
*/
|
||||
@Data
|
||||
public class RefuelMoney {
|
||||
private String type;
|
||||
private String oilType;
|
||||
private String refuelMoney;
|
||||
|
||||
// public String toString(){
|
||||
// return "{'type':'"+type+"','oilType':'"+oilType+"','refuelMoney':'"+refuelMoney+"'}";
|
||||
// }
|
||||
}
|
@ -73,6 +73,12 @@ public interface OilOrderService extends IService<OilOrder> {
|
||||
*/
|
||||
public Map<String,Object> insertOilOrder(Map<String ,String> map);
|
||||
|
||||
/**
|
||||
* 扫描小程序中二维码所处理的逻辑
|
||||
* @param map
|
||||
*/
|
||||
Map<String,String> scanAppletQrCode(Map<String,String> map);
|
||||
|
||||
/**
|
||||
* 小程序添加油品订单信息
|
||||
* @param oilOrder
|
||||
|
@ -48,6 +48,7 @@ import com.fuint.common.dto.AccountInfo;
|
||||
import com.fuint.common.util.TokenUtil;
|
||||
import com.fuint.system.config.service.SysConfigService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@ -358,7 +359,7 @@ public class OilOrderServiceImpl extends ServiceImpl<OilOrderMapper, OilOrder> i
|
||||
oilConfigService.oilRule();
|
||||
}
|
||||
// 根据店铺id查询商户配置信息
|
||||
MerchantConfig merchantConfig = merchantConfigService.selectMeChByIsUse("1");
|
||||
MerchantConfig merchantConfig = merchantConfigService.selectMeChByIdIsUse(storeId);
|
||||
// 处理支付需要的数据
|
||||
Map<String,String> map1 = new HashMap<>();
|
||||
map1.put("authCode",map.get("authCode"));
|
||||
@ -396,6 +397,257 @@ public class OilOrderServiceImpl extends ServiceImpl<OilOrderMapper, OilOrder> i
|
||||
return orders;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String,String> scanAppletQrCode(Map<String, String> map) {
|
||||
Map<String,String> res = new HashMap<>();
|
||||
String authCode = map.get("authCode");
|
||||
// 油品订单金额
|
||||
Double oilAmount = Double.valueOf(map.get("oilAmount"));
|
||||
// 将油品订单信息的json数据转换为数组
|
||||
List<JSONObject> oilOrders = null;
|
||||
|
||||
if (!map.get("oilOrder").equals("[]")) {
|
||||
oilOrders = JSONArray.parseArray(map.get("oilOrder"), JSONObject.class);
|
||||
// 条码支付
|
||||
if (authCode.contains("19")) {
|
||||
String[] split = authCode.split("19");
|
||||
// 获取用户id
|
||||
Integer userId = Integer.valueOf(split[1]);
|
||||
res = this.updateUserBalanceAndInsetOrder(userId,map,oilAmount,oilOrders);
|
||||
}
|
||||
// 二维码支付
|
||||
if (authCode.contains("9E")) {
|
||||
String[] split = authCode.split("9E");
|
||||
// 获取用户id
|
||||
Integer userId = Integer.valueOf(split[1]);
|
||||
res = this.updateUserBalanceAndInsetOrder(userId,map,oilAmount,oilOrders);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private LJUserService userService;
|
||||
|
||||
/**
|
||||
* 修改用户储值卡信息并添加订单信息
|
||||
* @param userId 用户id
|
||||
* @param oilAmount 油品订单金额
|
||||
* @param oilOrders 油品订单
|
||||
* @return 是否成功
|
||||
*/
|
||||
private Map<String,String> updateUserBalanceAndInsetOrder(int userId,Map<String, String> map,Double oilAmount,List<JSONObject> oilOrders){
|
||||
Map<String,String> res = new HashMap<>();
|
||||
// 根据userId查询用户储值卡信息
|
||||
UserBalance balance = userBalanceService.selectUserBalance(userId);
|
||||
// 根据用户id查询用户信息
|
||||
LJUserVo userVo1 = userService.selectUserById(userId);
|
||||
|
||||
// 根据日期生成订单信息
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
String timestamp = dateFormat.format(new Date());
|
||||
String randomString = UUID.randomUUID().toString().replace("-","").substring(0,6);
|
||||
String orderNo = "2345"+timestamp+randomString;
|
||||
AccountInfo accountInfo = TokenUtil.getNowAccountInfo();
|
||||
|
||||
Double cardBalance = balance.getCardBalance();
|
||||
JSONArray refuelMoneys = JSONArray.parseArray(balance.getRefuelMoney());
|
||||
if (cardBalance >= oilAmount) {
|
||||
// 添加油品订单信息
|
||||
OilOrder order = new OilOrder();
|
||||
for (int i = 0;i < oilOrders.size();i++) {
|
||||
Double amount = Double.valueOf(oilOrders.get(i).get("amount").toString());
|
||||
Double oilPrice = Double.valueOf(oilOrders.get(i).get("oilPrice").toString());
|
||||
Double oilNum = amount / oilPrice;
|
||||
if (i == 0) {
|
||||
order.setOrderType("主订单");
|
||||
order.setOrderAmount(amount);
|
||||
order.setPayAmount(0.0);
|
||||
order.setOrderNo(orderNo);
|
||||
} else {
|
||||
order.setOrderType("子订单");
|
||||
order.setOrderAmount(amount);
|
||||
order.setPayAmount(0.0);
|
||||
order.setOrderNo(orderNo + "1");
|
||||
}
|
||||
order.setStoreId(accountInfo.getStoreId());
|
||||
order.setUserId(userId);
|
||||
order.setCommissionAmount(Double.valueOf(map.get("commissionAmount")));
|
||||
order.setStaffId(Integer.valueOf(map.get("staffId")));
|
||||
order.setTerminal(map.get("terminal"));
|
||||
order.setOils((String) oilOrders.get(i).get("oilName"));
|
||||
order.setOilGunNum(oilOrders.get(i).get("gunName").toString());
|
||||
order.setOilNum(oilNum);
|
||||
// order.setDiscountAmount(Double.valueOf(map.get("oilDiscount")));
|
||||
order.setPayUser(userVo1.getMobile());
|
||||
order.setPayType(map.get("payType"));
|
||||
order.setInvoicing("未开票");
|
||||
order.setOrderStatus("paid");
|
||||
order.setPayTime(new Date());
|
||||
|
||||
this.addOilTrack(oilOrders.get(i), accountInfo.getStoreId());
|
||||
baseMapper.insert(order);
|
||||
}
|
||||
OilOrder oilOrder = this.selectOilOrderByOrderNo(orderNo);
|
||||
|
||||
// 添加收银台订单信息
|
||||
CashierOrder cashierOrder = new CashierOrder();
|
||||
cashierOrder.setStaffId(Integer.valueOf(map.get("staffId")));
|
||||
cashierOrder.setStoreId(accountInfo.getStoreId());
|
||||
cashierOrder.setPayUser(userVo1.getMobile());
|
||||
cashierOrder.setAmount(oilAmount);
|
||||
cashierOrder.setPayAmount(oilAmount);
|
||||
cashierOrder.setStatus("paid");
|
||||
cashierOrder.setPayTime(new Date());
|
||||
cashierOrder.setOrderNo(orderNo);
|
||||
cashierOrder.setOilOrderAmount(oilAmount);
|
||||
// cashierOrder.setOilDiscountAmount(Double.valueOf(map.get("oilDiscount")));
|
||||
cashierOrder.setTerminal(map.get("terminal"));
|
||||
cashierOrder.setOilOrderId(oilOrder.getId());
|
||||
cashierOrderService.insertCashierOrder(cashierOrder);
|
||||
this.updateGrowthValue1(oilAmount,userId, Integer.valueOf(oilOrder.getOils()),0.0);
|
||||
this.insertAllOrderInfo(orderNo,accountInfo.getStoreId(),oilAmount,map.get("payType"),userId);
|
||||
|
||||
res.put("success","success");
|
||||
} else {
|
||||
|
||||
if (ObjectUtil.isNotEmpty(refuelMoneys)){
|
||||
for (Object refuelMoney : refuelMoneys) {
|
||||
// System.out.println(refuelMoney);
|
||||
String oilType = ((JSONObject) refuelMoney).get("oilType").toString();
|
||||
Double refuelMoneyLiters = Double.valueOf(((JSONObject) refuelMoney).get("refuelMoney").toString());
|
||||
// 根据油品名称查询油品id
|
||||
OilName oilName = oilNameService.selectOilNameByOilName(oilType);
|
||||
OilOrder order = new OilOrder();
|
||||
OilOrder oilOrder = null;
|
||||
|
||||
// 添加收银台订单信息
|
||||
CashierOrder cashierOrder = new CashierOrder();
|
||||
for (int i = 0;i < oilOrders.size();i++) {
|
||||
if (oilOrders.get(i).get("oilName").equals(oilName.getId().toString())){
|
||||
if (refuelMoneyLiters>=Double.valueOf(oilOrders.get(i).get("liters").toString())){
|
||||
Double amount = Double.valueOf(oilOrders.get(i).get("amount").toString());
|
||||
Double oilPrice = Double.valueOf(oilOrders.get(i).get("oilPrice").toString());
|
||||
Double oilNum = amount / oilPrice;
|
||||
if (i == 0) {
|
||||
order.setOrderType("主订单");
|
||||
order.setOrderAmount(amount);
|
||||
order.setPayAmount(0.0);
|
||||
order.setOrderNo(orderNo);
|
||||
} else {
|
||||
order.setOrderType("子订单");
|
||||
order.setOrderAmount(amount);
|
||||
order.setPayAmount(0.0);
|
||||
order.setOrderNo(orderNo + "1");
|
||||
}
|
||||
order.setStoreId(accountInfo.getStoreId());
|
||||
order.setUserId(userId);
|
||||
order.setCommissionAmount(Double.valueOf(map.get("commissionAmount")));
|
||||
order.setStaffId(Integer.valueOf(map.get("staffId")));
|
||||
order.setTerminal(map.get("terminal"));
|
||||
order.setOils((String) oilOrders.get(i).get("oilName"));
|
||||
order.setOilGunNum(oilOrders.get(i).get("gunName").toString());
|
||||
order.setOilNum(oilNum);
|
||||
// order.setDiscountAmount(Double.valueOf(map.get("oilDiscount")));
|
||||
order.setPayUser(userVo1.getMobile());
|
||||
order.setPayType(map.get("payType"));
|
||||
order.setInvoicing("未开票");
|
||||
order.setOrderStatus("paid");
|
||||
order.setPayTime(new Date());
|
||||
|
||||
this.addOilTrack(oilOrders.get(i), accountInfo.getStoreId());
|
||||
baseMapper.insert(order);
|
||||
|
||||
oilOrder = this.selectOilOrderByOrderNo(orderNo);
|
||||
cashierOrder.setStaffId(Integer.valueOf(map.get("staffId")));
|
||||
cashierOrder.setStoreId(accountInfo.getStoreId());
|
||||
cashierOrder.setPayUser(userVo1.getMobile());
|
||||
cashierOrder.setAmount(oilAmount);
|
||||
cashierOrder.setPayAmount(oilAmount);
|
||||
cashierOrder.setStatus("paid");
|
||||
cashierOrder.setPayTime(new Date());
|
||||
cashierOrder.setOrderNo(orderNo);
|
||||
cashierOrder.setOilOrderAmount(oilAmount);
|
||||
// cashierOrder.setOilDiscountAmount(Double.valueOf(map.get("oilDiscount")));
|
||||
cashierOrder.setTerminal(map.get("terminal"));
|
||||
cashierOrder.setOilOrderId(oilOrder.getId());
|
||||
this.updateGrowthValue1(0.0,userId, Integer.valueOf(oilOrder.getOils()),refuelMoneyLiters-Double.valueOf(oilOrders.get(i).get("liters").toString()));
|
||||
|
||||
}
|
||||
}else {
|
||||
res.put("error","囤油卡余额不足!");
|
||||
}
|
||||
}
|
||||
|
||||
cashierOrderService.insertCashierOrder(cashierOrder);
|
||||
this.insertAllOrderInfo(orderNo,accountInfo.getStoreId(),oilAmount,map.get("payType"),userId);
|
||||
res.put("success","success");
|
||||
}
|
||||
|
||||
}else {
|
||||
res.put("error","储值卡余额不足!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
@Lazy
|
||||
private AllOrderInfoService allOrderInfoService;
|
||||
|
||||
/**
|
||||
* 添加所有订单信息
|
||||
*/
|
||||
private void insertAllOrderInfo(String orderNo,Integer storeId,Double goodsMoney,String payType,Integer userId){
|
||||
AllOrderInfo allOrderInfo = new AllOrderInfo();
|
||||
allOrderInfo.setOrderNo(orderNo);
|
||||
allOrderInfo.setType("油品订单");
|
||||
allOrderInfo.setStoreId(storeId);
|
||||
allOrderInfo.setGoodsMoney(goodsMoney);
|
||||
allOrderInfo.setPayType(payType);
|
||||
allOrderInfo.setUserId(userId);
|
||||
allOrderInfo.setPayChannel("applet");
|
||||
allOrderInfo.setStatus("paid");
|
||||
allOrderInfo.setContent("油品订单");
|
||||
allOrderInfoService.insertAllOrderInfo(allOrderInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户成长储值卡信息
|
||||
* @param oilActualPay 消费金额
|
||||
* @param userid 用户id
|
||||
* @param oilId 油号id
|
||||
* @param refuelMoney 扣除的囤油卡升数
|
||||
*/
|
||||
private void updateGrowthValue1(Double oilActualPay,Integer userid,Integer oilId,Double refuelMoney){
|
||||
UserBalance balance = userBalanceService.selectUserBalance(userid);
|
||||
JSONArray refuelMoneys = JSONArray.parseArray(balance.getRefuelMoney());
|
||||
if (oilActualPay==0.0){
|
||||
if (ObjectUtil.isNotEmpty(refuelMoneys)){
|
||||
List<RefuelMoney> list = new ArrayList<>();
|
||||
for (Object money : refuelMoneys) {
|
||||
RefuelMoney refuelMoney1 = new RefuelMoney();
|
||||
refuelMoney1.setType(((JSONObject) money).get("type").toString());
|
||||
refuelMoney1.setOilType(((JSONObject) money).get("oilType").toString());
|
||||
refuelMoney1.setRefuelMoney(((JSONObject) money).get("refuelMoney").toString());
|
||||
Double refuelMoneyLiters = Double.valueOf(((JSONObject) money).get("refuelMoney").toString());
|
||||
// 根据油品名称查询油品id
|
||||
OilName oilName = oilNameService.selectOilNameByOilName(((JSONObject) money).get("oilType").toString());
|
||||
if (oilName.getId().toString().equals(oilId.toString())){
|
||||
refuelMoney1.setRefuelMoney(String.valueOf(refuelMoney));
|
||||
}
|
||||
list.add(refuelMoney1);
|
||||
}
|
||||
balance.setRefuelMoney(JSONObject.toJSONString(list));
|
||||
}
|
||||
}else {
|
||||
balance.setCardBalance(balance.getCardBalance()-oilActualPay);
|
||||
}
|
||||
userBalanceService.updateUserBalance(balance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String addOilOrder(OilOrder oilOrder) {
|
||||
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
|
||||
@ -493,10 +745,10 @@ public class OilOrderServiceImpl extends ServiceImpl<OilOrderMapper, OilOrder> i
|
||||
if (!map.get("payAmount").equals("0")) {
|
||||
// 调用支付接口
|
||||
// 判断是否开启支付规则
|
||||
List<MerchantConfig> list = merchantConfigService.selectMeChByIsOpen();
|
||||
if (list.size() > 0) {
|
||||
oilConfigService.oilRule();
|
||||
}
|
||||
// List<MerchantConfig> list = merchantConfigService.selectMeChByIsOpen();
|
||||
// if (list.size() > 0) {
|
||||
// oilConfigService.oilRule();
|
||||
// }
|
||||
// 处理支付需要的数据
|
||||
ReceiveParameter receiveParameter = new ReceiveParameter();
|
||||
receiveParameter.setOrderNo(orderNo);
|
||||
@ -610,8 +862,6 @@ public class OilOrderServiceImpl extends ServiceImpl<OilOrderMapper, OilOrder> i
|
||||
@Autowired
|
||||
private SysConfigService sysConfigService;
|
||||
@Autowired
|
||||
private LJUserService userService;
|
||||
@Autowired
|
||||
private LJUserGradeService userGradeService;
|
||||
@Autowired
|
||||
private ILJStoreService storeService;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.fuint.business.petrolStationManagement.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import com.fuint.repository.model.base.BaseEntity;
|
||||
@ -22,14 +23,19 @@ public class OilName extends BaseEntity {
|
||||
public Long id; //id(主键)
|
||||
private String oilType; // 油品类型
|
||||
private String oilName; //油品名称
|
||||
@TableField(exist = false)
|
||||
private Double oilPrice; //油品单价
|
||||
private Double oilDensity; //油品密度
|
||||
private String state; // 状态 启用或禁用(0禁用1启用)
|
||||
private String sort; //排序
|
||||
@TableField(exist = false)
|
||||
private String remark; //
|
||||
private String ifDelete; //
|
||||
@TableField(exist = false)
|
||||
private String receivingUnits; //
|
||||
@TableField(exist = false)
|
||||
private String unit; //
|
||||
@TableField(exist = false)
|
||||
private Integer storeId; //
|
||||
|
||||
|
||||
|
@ -32,6 +32,13 @@ public interface OilNameService extends IService<OilName> {
|
||||
*/
|
||||
public OilName selectOilNameById(int id);
|
||||
|
||||
/**
|
||||
* 根据油品名称查询油号信息
|
||||
* @param oilName
|
||||
* @return
|
||||
*/
|
||||
public OilName selectOilNameByOilName(String oilName);
|
||||
|
||||
// /**
|
||||
// * 根据条件分页查询员工信息
|
||||
// * @param page
|
||||
|
@ -2,6 +2,7 @@ package com.fuint.business.petrolStationManagement.service.impl;
|
||||
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
@ -44,6 +45,13 @@ public class OilNameServiceImpl extends ServiceImpl<OilNameMapper, OilName> impl
|
||||
return oilName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OilName selectOilNameByOilName(String oilName) {
|
||||
QueryWrapper queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("oil_name",oilName);
|
||||
return baseMapper.selectOne(queryWrapper);
|
||||
}
|
||||
|
||||
|
||||
// @Override
|
||||
// public IPage<OilNumber> selectOilNumberList(Page page, OilNumber oilNumber) {
|
||||
|
@ -48,9 +48,12 @@ public class LJUser extends BaseEntity implements Serializable {
|
||||
@ApiModelProperty("称呼")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("微信")
|
||||
@ApiModelProperty("微信open_id")
|
||||
private String openId;
|
||||
|
||||
@ApiModelProperty("支付宝user_id")
|
||||
private String userId;
|
||||
|
||||
@ApiModelProperty("手机号码")
|
||||
private String mobile;
|
||||
|
||||
|
@ -0,0 +1,36 @@
|
||||
package com.fuint.module.AlipayApi.controller;
|
||||
|
||||
import com.alipay.api.AlipayApiException;
|
||||
import com.alipay.api.response.AlipaySystemOauthTokenResponse;
|
||||
import com.fuint.framework.web.BaseController;
|
||||
import com.fuint.framework.web.ResponseObject;
|
||||
import com.fuint.module.AlipayApi.service.AlipayService1;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
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("/api/alipay")
|
||||
public class AlipayController extends BaseController {
|
||||
@Autowired
|
||||
private AlipayService1 alipayService;
|
||||
|
||||
/**
|
||||
* 获取支付宝userId
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/getUserid")
|
||||
public ResponseObject getUserId(@Validated @RequestBody Map<String,String> map) throws AlipayApiException {
|
||||
String authCode = map.get("authCode");
|
||||
AlipaySystemOauthTokenResponse alipayProfile = alipayService.getAlipayProfile(authCode);
|
||||
String userId = alipayProfile.getUserId();
|
||||
|
||||
return getSuccessResult("");
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package com.fuint.module.AlipayApi.service;
|
||||
|
||||
import com.alipay.api.AlipayApiException;
|
||||
import com.alipay.api.response.AlipaySystemOauthTokenResponse;
|
||||
|
||||
public interface AlipayService1 {
|
||||
public AlipaySystemOauthTokenResponse getAlipayProfile(String code) throws AlipayApiException;
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package com.fuint.module.AlipayApi.service.impl;
|
||||
|
||||
import com.alipay.api.AlipayClient;
|
||||
import com.alipay.api.AlipayConfig;
|
||||
import com.alipay.api.DefaultAlipayClient;
|
||||
import com.alipay.api.request.AlipaySystemOauthTokenRequest;
|
||||
import com.alipay.api.request.AlipayUserInfoShareRequest;
|
||||
import com.alipay.api.response.AlipaySystemOauthTokenResponse;
|
||||
import com.alipay.api.response.AlipayUserInfoShareResponse;
|
||||
import com.fuint.module.AlipayApi.service.AlipayService1;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class AlipayServiceImpl1 implements AlipayService1 {
|
||||
private static final Logger logger = LoggerFactory.getLogger(AlipayServiceImpl1.class);
|
||||
@Autowired
|
||||
private Environment env;
|
||||
|
||||
@Override
|
||||
public AlipaySystemOauthTokenResponse getAlipayProfile(String authCode){
|
||||
String alipayAppId = env.getProperty("alipay.appid");
|
||||
String alipayPrivateKey = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCJJM2nlUCidns6anNtGUiCL+J83kNL1nrr6hNktHkrX9bhR8LiBU3qBX+MkGDY4snlbdz+anGWu8YkcMlfBlAr82AsdIS9UTHh3lgsIAZTBZHgzZrxn7vwHfHI6Kw7uGZJbZ320JEG3s0KyvGiW0eqGuWI4BW+sD7b6JoLtNfBq+yF9ObOcs76rNCWz+04BmhCH7i6d8arK8NKgEiI9EjBThGjLRDFK1ryacKpz4UVvIXgxEW5w0MTjo/Q7gp2VLpwE/4jc8QfDFwmGU75L+nhK0rr1l0wwSo7svWFAXvberzMCGyuuLomuh2ldDfERJbIjg/qU66gx0EML1tgpVtFAgMBAAECggEARTArDJuwswXBH3Rq7SRvPza3NbXQD6eR9gjuZcTiyG4ecyMH/40bhK/nbFu+cEzh/HxTnIrI6Xmr+eBoxybhNXsgDu1ttjELUF8i7oftiN7rfJVd0P58CySgQXKYybw65lqF8enA8M1gdkxyYS1Z10igelBKyBwUak9LwBIpM0wrPIFrLhoxIEJC6QJ8EDnm6lKbytvcCa2mMZmtWs8oFxNA/SLRWtdEgHk4hslQVqq4R8B/xUy9Cu4kjdnVMHG2MqFXOiTas3gyKZLGN1ACBfpxxtyw0RAfX294ChV4SIvp10s1VqBFudcQeXeV5ph0NXP1eNt/8o3HIu0vjc0jAQKBgQD5ZtOR19M5vAcxJykh5u01CPdfz2LztqdinCpkBIpFviceW/k1euQFaWbOKdYFUrPnuLgX7Ds6dhSrkoL1+1RiVKUR6AtqIMa4fZJIMJWEPNNYWl8s6u6j11Dkd0B10g5+KV/kKLSlwFuBQnDyHw1ND+WKHqj9vkkzimzfcwedBQKBgQCMxao2IKX8CNjXDuryGkmXac0wxql0nN8AFHjCQGm16GPwlp805nAwsHKfJK45ACeixnWH9Cn6sje3yOUpCw6KG4OougRkrQEkQpoPVrZuXEcZ4j4Wg64VgW9tUAVH/WOV0VDnOBpsM8mbKsLLglb1H9Bx7813IX1pmhm93a0ZQQKBgD6U48/75T/eg7t8xSCBrtIZDuHWy1C2a6gd4bE5Rm0buvsuPwmBbchB248uBktNpmEmA+PU3kPcL3GiEQSibVlDPiyRGpQl51eSAuvkbRBCpxHLk4hU507rj5vUpLMr44Ea5rn80N+qtgtoXakTy6WjsIiJCwSpA/tP5+PmHGn1AoGASY/VhZmEA3OAFMnX3pH8GOKR9kYqMST0p28LN78/Pm7lIskjAxrUT601CJK7dE/vZnE848Gk2judQC38CnmbrHH6WAZ020NI0HD5XsCabotMIGuItG01YEmWN9JUIC16h8Ss+Vbo/9gEJ1CuIHjJBikM3S1J+lIG3lNH1l7r4MECgYEA2eAV0x55cmjC6VIMk3EAVUFbJ1LY1U9irmI6B5e7k/OVcdRksJfMRJwcquYVSfAk4hDrl7x0Qy36XELGvMe/hx07HxeAOXON8gL1b3UHP1zxvXb90YLHseHn9lssABsXS6Enyv3nrzqUi/uzBvpdDE2SRVS6nUr7Yyui6Yl+UPA=";
|
||||
String alipayPublicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnwDxxSNpBKL8xjtU3leNBy9mIOMYOr0WgxGbCxTMfhUPka9nr8Hbt0GN+7ylNBmxCYvW8kmge4dCOLUPqseM9+HyF9R1NrWBB3zQPVqnD0mKCYr9cEgtx6/eU7oIK1FqAl0G+jNIT3IKWMSXEX09yPKJWS6zk7+FRzOzn11vShTFjmrqWdrisJgRsQ54PHhPkQz7xFojDRqIunlpICWUVA8GwUg02hm5ZEhxpMHEWoJZ6Dj1wPH2Vh4CpIT/mjtD+SvssCpT0/XOEDPajcMRfgoV8fyyN0JNQDVZdMZgSO4aRHQqhC3X5CBXSuv40hHnwjcDjsPcbVav5BtaPp3wPQIDAQAB";
|
||||
String alipayAccessUrl = "https://openapi.alipay.com/gateway.do";
|
||||
AlipayConfig alipayConfig = new AlipayConfig();
|
||||
alipayConfig.setAlipayPublicKey(alipayPublicKey);
|
||||
alipayConfig.setServerUrl(alipayAccessUrl);
|
||||
alipayConfig.setAppId(alipayAppId);
|
||||
alipayConfig.setPrivateKey(alipayPrivateKey);
|
||||
alipayConfig.setFormat("json");
|
||||
alipayConfig.setCharset("UTF-8");
|
||||
alipayConfig.setSignType("RSA2");
|
||||
try {
|
||||
AlipayClient alipayClient = new DefaultAlipayClient(alipayConfig);
|
||||
AlipaySystemOauthTokenRequest request = new AlipaySystemOauthTokenRequest();
|
||||
|
||||
request.setGrantType("authorization_code");
|
||||
request.setCode(authCode);
|
||||
AlipaySystemOauthTokenResponse response = alipayClient.execute(request);
|
||||
|
||||
|
||||
|
||||
AlipayUserInfoShareRequest request2 = new AlipayUserInfoShareRequest();
|
||||
|
||||
AlipayUserInfoShareResponse response2 = alipayClient.execute(request2,response.getAccessToken());
|
||||
if(response.isSuccess()){
|
||||
logger.error("调用成功:" + response.getBody());
|
||||
return response;
|
||||
} else {
|
||||
logger.error("调用失败");
|
||||
}
|
||||
}catch (Exception e){
|
||||
logger.error("获取支付宝getAlipayProfile异常:" + e.getMessage());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
@ -42,6 +42,9 @@ public class MtUser implements Serializable {
|
||||
@ApiModelProperty("微信open_id")
|
||||
private String openId;
|
||||
|
||||
@ApiModelProperty("支付宝user_id")
|
||||
private String userId;
|
||||
|
||||
@ApiModelProperty("手机号码")
|
||||
private String mobile;
|
||||
|
||||
|
@ -26,6 +26,15 @@ export function addLJGoods(data) {
|
||||
})
|
||||
}
|
||||
|
||||
// 新增油品订单信息
|
||||
export function scanAppletQrCode(data) {
|
||||
return request({
|
||||
url: '/business/oilOrder/scanAppletQrCode',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 根据订单号查询油品订单信息
|
||||
export function oilOrder(data) {
|
||||
return request({
|
||||
|
@ -788,7 +788,7 @@
|
||||
import {listgoods} from "@/api/cashier/ljgoods";
|
||||
import {getUserVoMobile, getUserVoName} from "@/api/cashier/user";
|
||||
import {queryStaffs, staffInfo} from "@/api/cashier/staff";
|
||||
import {addLJGoods, goodsOrder, oilOrder} from "@/api/cashier/oilorder";
|
||||
import {addLJGoods, goodsOrder, oilOrder, scanAppletQrCode} from "@/api/cashier/oilorder";
|
||||
import {getUserGrade, listUserGrade, userGradeInfo} from "@/api/cashier/usergrade";
|
||||
import {getOilGun, getOilTank} from "@/api/cashier/oilGuns";
|
||||
import {listCardFavorableRecord} from "@/api/cashier/cardfavorablerecord";
|
||||
@ -2291,6 +2291,23 @@
|
||||
this.map.couponId = this.useCouponIds
|
||||
|
||||
let _this = this;
|
||||
if (this.payType=="APPLET_CODE"){
|
||||
this.loading = true;
|
||||
scanAppletQrCode(_this.map).then( resp => {
|
||||
if (resp.data.success!=undefined){
|
||||
setTimeout(function (){
|
||||
_this.isPaySuccess = true;
|
||||
this.loading = false;
|
||||
_this.isPay = false;
|
||||
_this.resetting1();
|
||||
},3000)
|
||||
}else {
|
||||
this.$modal.msgError(resp.data.error)
|
||||
}
|
||||
})
|
||||
return;
|
||||
}
|
||||
|
||||
addLJGoods(_this.map).then( response => {
|
||||
if (response.data.oilOrder!=null){
|
||||
_this.orderNo = response.data.oilOrder.orderNo;
|
||||
@ -2324,7 +2341,10 @@
|
||||
setTimeout(function (){
|
||||
clearInterval(timer);
|
||||
},30000)
|
||||
|
||||
_this.resetting1();
|
||||
},
|
||||
resetting1(){
|
||||
let _this = this;
|
||||
this.authCode = "";
|
||||
if (_this.isPaySuccess == true){
|
||||
_this.oilAmount = 0;
|
||||
@ -2453,6 +2473,7 @@
|
||||
// 支付方式
|
||||
payMethod(payType){
|
||||
this.map.payType = payType;
|
||||
this.payType = payType;
|
||||
},
|
||||
// 获取支付方式
|
||||
getPayList(){
|
||||
|
@ -23,15 +23,19 @@
|
||||
<w-qrcode :options="options"></w-qrcode>
|
||||
</view>
|
||||
<view class="dis-size">
|
||||
<u-icon name="reload" color="#2979ff" size="18"></u-icon>
|
||||
<text style="margin-left: 10px;">0秒后自动刷新</text>
|
||||
<u-icon name="reload" @click="refresh" color="#2979ff" size="18"></u-icon>
|
||||
<!-- <u-count-down :timestamp="timestamp"></u-count-down> -->
|
||||
<text style="margin-left: 10px;">
|
||||
{{timestamp}}秒后自动刷新
|
||||
</text>
|
||||
</view>
|
||||
<view class="bottom-box" @click="bottomShow()">
|
||||
<view style="display: flex;align-items: center;">
|
||||
<uni-icons type="wallet-filled" color="#2979ff" size="30"></uni-icons>
|
||||
<view style="margin-left: 10px;">
|
||||
<view class="">自动识别</view>
|
||||
<view style="font-size: 14px; color: #666666;">根据账户自动识别的付款方式</view>
|
||||
<view class="">{{value}}</view>
|
||||
<view style="font-size: 14px; color: #666666;">优先使用此付款方式</view>
|
||||
<!-- <view style="font-size: 14px; color: #666666;">根据账户自动识别的付款方式</view> -->
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@ -52,12 +56,12 @@
|
||||
<view class="title">请选择用户类型</view>
|
||||
<view class="hui-size">如果付款失败尝试使用其他方式完成付款</view>
|
||||
</view>
|
||||
<view class="bottom-box">
|
||||
<view class="bottom-box" v-for="(item,index) in deduction" :key="index" @click="choosePayMethod(item.value)">
|
||||
<view style="display: flex;align-items: center;">
|
||||
<uni-icons type="wallet-filled" color="#2979ff" size="30"></uni-icons>
|
||||
<view style="margin-left: 10px;">
|
||||
<view class="">自动识别</view>
|
||||
<view style="font-size: 14px; color: #666666;">根据账户自动识别的付款方式</view>
|
||||
<view class="">{{item.value}}</view>
|
||||
<!-- <view style="font-size: 14px; color: #666666;">根据账户自动识别的付款方式</view> -->
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@ -65,18 +69,18 @@
|
||||
<u-icon name="arrow-right"></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
<view class="bottom-box">
|
||||
<!-- <view class="bottom-box">
|
||||
<view style="display: flex;align-items: center;">
|
||||
<uni-icons type="wallet-filled" color="#2979ff" size="30"></uni-icons>
|
||||
<view style="margin-left: 10px;">
|
||||
<view class="">自动识别</view>
|
||||
<view class="">囤油卡</view>
|
||||
<view style="font-size: 14px; color: #666666;">根据账户自动识别的付款方式</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="">
|
||||
<u-icon name="arrow-right"></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
</view> -->
|
||||
|
||||
</view>
|
||||
</u-popup>
|
||||
@ -88,6 +92,7 @@
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
timestamp: 60,
|
||||
title: '',
|
||||
show: false,
|
||||
option: {
|
||||
@ -99,24 +104,54 @@
|
||||
code: 'https://qm.qq.com/cgi-bin/qm/qr?k=LKqML292dD2WvwQfAJXBUmvgbiB_TZWF&noverify=0', // 生成二维码的值
|
||||
size: 460, // 460代表生成的二维码的宽高均为460rpx
|
||||
},
|
||||
|
||||
deduction:[
|
||||
{key:"balance",value:"储值卡扣款"},
|
||||
{key:"oilStorageCard",value:"囤油卡扣款"},
|
||||
],
|
||||
value:"储值卡扣款",
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
this.getBarCode()
|
||||
this.getQrCode()
|
||||
this.countdown()
|
||||
},
|
||||
components: {
|
||||
|
||||
},
|
||||
methods: {
|
||||
// 倒计时刷新
|
||||
countdown(){
|
||||
let _this = this
|
||||
setInterval(() => {
|
||||
// countdown减1
|
||||
_this.timestamp--;
|
||||
// 如果倒计时为0,清除定时器
|
||||
if(_this.timestamp === 0) {
|
||||
_this.getBarCode()
|
||||
_this.getQrCode()
|
||||
_this.timestamp = 60
|
||||
}
|
||||
}, 1000);
|
||||
},
|
||||
// 刷新二维码信息
|
||||
refresh(){
|
||||
this.getBarCode()
|
||||
this.getQrCode()
|
||||
this.timestamp = 60
|
||||
},
|
||||
// 选择扣款方式
|
||||
choosePayMethod(val){
|
||||
this.value = val
|
||||
this.show = false
|
||||
},
|
||||
// 获取条码信息
|
||||
getBarCode(){
|
||||
request({
|
||||
url: 'business/qrCode/createBarCode',
|
||||
method: 'get',
|
||||
}).then(res => {
|
||||
// console.log(res,111)
|
||||
console.log(res,111)
|
||||
this.option.code = res.data
|
||||
})
|
||||
},
|
||||
@ -126,7 +161,7 @@
|
||||
url: 'business/qrCode/createQrCode',
|
||||
method: 'get',
|
||||
}).then(res => {
|
||||
// console.log(2222,res)
|
||||
console.log(2222,res)
|
||||
this.options.code = res.data
|
||||
})
|
||||
},
|
||||
|
@ -39,6 +39,28 @@
|
||||
},
|
||||
components: {},
|
||||
methods: {
|
||||
// 获取支付宝userid
|
||||
getUserLogin1() {
|
||||
let _this = this;
|
||||
my.getAuthCode({
|
||||
scopes: 'auth_base',
|
||||
success: res => {
|
||||
const authCode = res.authCode;
|
||||
console.log(res)
|
||||
request({
|
||||
url: "api/alipay/getUserid",
|
||||
method: 'post',
|
||||
data: {authCode:authCode},
|
||||
}).then((resp)=>{
|
||||
console.log(resp)
|
||||
// uni.setStorageSync("userId",resp.data)
|
||||
})
|
||||
},
|
||||
fail: err => {
|
||||
console.log('my.getAuthCode 调用失败', err)
|
||||
}
|
||||
});
|
||||
},
|
||||
wxlogin() {},
|
||||
getPhone(e) {
|
||||
let that = this
|
||||
|
@ -400,6 +400,7 @@
|
||||
// }else{
|
||||
// payProvider = "alipay"
|
||||
// }
|
||||
if (res.data.reservedPayInfo!=null && res.data.reservedPayInfo!=""){
|
||||
_this.orderInfo = JSON.parse(res.data.data.reservedPayInfo);
|
||||
uni.requestPayment({
|
||||
// 微信支付provider: 'wxpay' 支付宝支付 'alipay'
|
||||
@ -424,7 +425,7 @@
|
||||
request({
|
||||
url: "/business/allOrderInfo/orderStatus",
|
||||
method: 'post',
|
||||
data: {"orderNo":res.data.orderNo,"status":"payFail"},
|
||||
data: {"orderNo":res.data.data.orderNo,"status":"payFail"},
|
||||
}).then((res)=>{
|
||||
uni.showToast({
|
||||
title:"支付失败!",
|
||||
@ -434,6 +435,25 @@
|
||||
console.log('fail:',err);
|
||||
}
|
||||
});
|
||||
}else{
|
||||
my.tradePay({ tradeNO: res.data.data.reservedTransactionId }, function(resp){
|
||||
if(resp.resultCode == '9000'){
|
||||
console.log("支付成功")
|
||||
}else{
|
||||
request({
|
||||
url: "/business/allOrderInfo/orderStatus",
|
||||
method: 'post',
|
||||
data: {"orderNo":res.data.data.orderNo,"status":"payFail"},
|
||||
}).then((res)=>{
|
||||
uni.showToast({
|
||||
title:"支付失败!",
|
||||
icon:"error"
|
||||
})
|
||||
})
|
||||
console.log('支付失败,'+resp.resultCode);
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
},
|
||||
// 囤油卡变化后总金额的变化
|
||||
|
Loading…
Reference in New Issue
Block a user