This commit is contained in:
cun-nan 2023-12-29 15:27:06 +08:00
parent 53a7cce4dc
commit a5d998b02d
19 changed files with 172 additions and 65 deletions

View File

@ -63,9 +63,12 @@ public class MerchantConfig extends BaseEntity implements Serializable {
*/
private Double amount;
/**
* 小程序appid
* 微信小程序appid
*/
private String appid;
/**
* 支付宝小程序appid
*/
private String alipayAppid;
}

View File

@ -341,14 +341,10 @@ public class FyPayServiceImpl implements FyPayService {
// 私钥
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());
// 订单总金额
@ -358,8 +354,16 @@ public class FyPayServiceImpl implements FyPayService {
map.put("goods_des", receiveParameter.getContent());
if (receiveParameter.getPayType().equals("WECHAT")){
map.put("trade_type","LETPAY");
// 微信open_id
map.put("sub_openid", userVo.getOpenId());
// appid
map.put("sub_appid", merchantConfig.getAppid());
} else if (receiveParameter.getPayType().equals("ALIPAY")){
map.put("trade_type","FWC");
// 支付宝userId
map.put("sub_openid", userVo.getUserId());
// appid
map.put("sub_appid", merchantConfig.getAlipayAppid());
}else {
res.put("code","error");
res.put("msg","暂不支持其他支付方式");

View File

@ -97,8 +97,8 @@ public class ActiveExchangeController extends BaseController {
* @param paymentActiveDTO
* @return
*/
@GetMapping("test")
public ResponseObject paymentActiveVO(@Param("transferDTO") PaymentActiveDTO paymentActiveDTO) {
@PostMapping("test")
public ResponseObject paymentActiveVO(@RequestBody PaymentActiveDTO paymentActiveDTO) {
return getSuccessResult(this.activeExchangeService.paymentActive(paymentActiveDTO));
}

View File

@ -395,10 +395,10 @@ public class ActiveExchangeServiceImpl implements ActiveExchangeService {
if (activeDiscountPayVO.getOilId().contains(paymentActiveDTO.getOilId().toString()) &&
activeDiscountPayVO.getAdaptUser().contains(paymentActiveDTO.getMtUserLevel().toString())){
if (activeDiscountPayVO.getDiscount() * activeDiscountPayVO.getAmount() > amount){
amount = activeDiscountPayVO.getDiscount() * activeDiscountPayVO.getAmount();
amount = paymentActiveDTO.getAmount() - (activeDiscountPayVO.getDiscount() * activeDiscountPayVO.getAmount());
paymentActiveVO.setActiveId(activeDiscountPayVO.getActiveId());
paymentActiveVO.setAmount(activeDiscountPayVO.getAmount());
paymentActiveVO.setFavorableAmount(amount);
paymentActiveVO.setAmount(amount);
paymentActiveVO.setFavorableAmount(activeDiscountPayVO.getAmount());
}
}
}
@ -410,10 +410,10 @@ public class ActiveExchangeServiceImpl implements ActiveExchangeService {
if (activeDiscountPayVO.getOilId().contains(paymentActiveDTO.getOilId().toString()) &&
activeDiscountPayVO.getAdaptUser().contains(paymentActiveDTO.getMtUserLevel().toString())){
if (activeDiscountPayVO.getAmount() > amount){
amount = activeDiscountPayVO.getDiscount() * activeDiscountPayVO.getAmount();
amount = paymentActiveDTO.getAmount() - activeDiscountPayVO.getAmount();
paymentActiveVO.setActiveId(activeDiscountPayVO.getActiveId());
paymentActiveVO.setAmount(activeDiscountPayVO.getAmount());
paymentActiveVO.setFavorableAmount(amount);
paymentActiveVO.setAmount(amount);
paymentActiveVO.setFavorableAmount(activeDiscountPayVO.getAmount());
}
}
}

View File

@ -359,7 +359,7 @@
adc.deduction_amount discount
FROM
active_fullminus af
LEFT JOIN active_discount_child adc ON af.id = adc.active_discount_id
LEFT JOIN active_discount_child adc ON af.id = adc.active_fullminus_id
where af.store_id = #{storeId}
and adc.amount &lt;= #{amount}
</select>

View File

@ -890,8 +890,7 @@ public class OilOrderServiceImpl extends ServiceImpl<OilOrderMapper, OilOrder> i
// 查询会员等级列表信息
Page page = new Page(1,20);
LJUserGrade ljUserGrade1 = new LJUserGrade();
IPage<LJUserGrade> ljUserGradeIPage = userGradeService.selectUserGradeList(page, ljUserGrade1);
List<LJUserGrade> records = ljUserGradeIPage.getRecords();
List<LJUserGrade> records = userGradeService.selectUserGradeAll(storeId);
if (oilName.getOilType().equals("汽油")){
gasGrowthValue = Integer.valueOf(sysConfigService.getValueByKey("gas_growth_value"));
Integer addVal = (int) (gasGrowthValue * oilActualPay);

View File

@ -132,7 +132,7 @@
</select>
<select id="selectOilNumberNameByStoreId" resultType="com.fuint.business.petrolStationManagement.vo.OilNumberNameVo"
parameterType="java.lang.Integer">
select onu.*,ona.oil_type,ona.oil_name oilNames,ot.id tankId from oil_tank ot
select onu.*,ona.oil_type,ona.oil_name oilNames,ona.id oilId,ot.id tankId from oil_tank ot
left join oil_number onu on ot.number_id = onu.number_id
left join oil_name ona on onu.oil_name = ona.id
<where>

View File

@ -11,4 +11,6 @@ public class OilNumberNameVo extends OilNumber {
private String oilNames;
// 油罐id
private String tankId;
// 油品id
private Integer oilId;
}

View File

@ -117,6 +117,7 @@
<include refid="selectUser"></include>
<where>
mu.id = #{id}
limit 1
</where>
</select>

View File

@ -19,6 +19,13 @@ public interface LJUserGradeService extends IService<LJUserGrade> {
*/
public IPage<LJUserGrade> selectUserGradeList(Page page, LJUserGrade userGrade);
/**
* 根据店铺id查询当前店铺所有等级列表信息
* @param storeId
* @return
*/
public List<LJUserGrade> selectUserGradeAll(int storeId);
/**
* 查询所有会员等级信息
* @return

View File

@ -46,6 +46,14 @@ public class LJUserGradeServiceImpl extends ServiceImpl<LJUserGradeMapper, LJUse
return ljUserGradeIPage;
}
@Override
public List<LJUserGrade> selectUserGradeAll(int storeId) {
QueryWrapper queryWrapper = new QueryWrapper<>();
queryWrapper.eq("status","qy");
queryWrapper.eq("store_id",storeId);
return baseMapper.selectList(queryWrapper);
}
@Override
public List<LJUserGrade> selectUserGradeAll() {
QueryWrapper queryWrapper = new QueryWrapper<>();

View File

@ -234,6 +234,7 @@ public class LJUserServiceImpl extends ServiceImpl<LJUserMapper, LJUser> impleme
user1.setName(user.getName());
}
user1.setOpenId(user.getOpenId());
user1.setUserId(user.getUserId());
user1.setMobile(user.getMobile());
user1.setIdcard(user.getIdcard());
user1.setSex(user.getSex());

View File

@ -35,6 +35,9 @@ public class LJUserVo extends BaseEntity {
// @ExcelProperty(value = "微信")
private String openId;
// 支付宝userid
private String userId;
// 手机号码
@ExcelProperty(value = "手机号码(必填)")
private String mobile;

View File

@ -4,12 +4,17 @@ import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.alipay.api.AlipayApiException;
import com.alipay.api.response.AlipaySystemOauthTokenResponse;
import com.fuint.business.storeInformation.entity.LJStore;
import com.fuint.business.storeInformation.service.ILJStoreService;
import com.fuint.business.userManager.entity.LJUser;
import com.fuint.business.userManager.service.LJUserService;
import com.fuint.business.userManager.vo.LJUserVo;
import com.fuint.common.dto.AccountInfo;
import com.fuint.common.util.TokenUtil;
import com.fuint.framework.web.BaseController;
import com.fuint.framework.web.ResponseObject;
import com.fuint.module.AlipayApi.service.AlipayService1;
import com.fuint.module.backendApi.response.LoginResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -19,6 +24,8 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.Map;
@RestController
@ -29,6 +36,8 @@ public class AlipayController extends BaseController {
private AlipayService1 alipayService;
@Autowired
private LJUserService userService;
@Autowired
private ILJStoreService iljStoreService;
/**
* 获取支付宝userId
@ -36,32 +45,51 @@ public class AlipayController extends BaseController {
* @return
*/
@PostMapping("/getUserid")
public ResponseObject getUserId(@Validated @RequestBody Map<String,String> map) throws AlipayApiException {
public ResponseObject getUserId(@RequestBody Map<String,String> map,HttpServletRequest request) throws AlipayApiException {
String authCode = map.get("authCode");
JSONObject paramsObj = new JSONObject(map.isEmpty());
logger.info("微信授权登录参数:{}", map);
JSONObject userInfo = paramsObj.getJSONObject("userInfo");
String storeId = ObjectUtil.isEmpty(userInfo.get("storeId"))? "" : userInfo.get("storeId").toString();
if ("".equals(storeId)) return getFailureResult(0, "微信登录失败");
logger.info("支付宝授权登录参数:{}", map);
String storeId = map.get("storeId");
if ("".equals(storeId)) return getFailureResult(0, "支付宝登录失败");
// 根据storeId查找对应的连锁店id
LJStore ljStore = iljStoreService.selectStoreByIdUni(Integer.parseInt(storeId));
// 获取支付宝userid
AlipaySystemOauthTokenResponse alipayProfile = alipayService.getAlipayProfile(authCode);
if (alipayProfile == null) {
return getFailureResult(0, "支付宝登录失败");
}
String userId = alipayProfile.getUserId();
// 根据手机号查询用户信息
LJUser user = userService.selectUserByMobile(userInfo.get("phone").toString());
LJUser user = userService.selectUserByMobile(map.get("phone"));
if (ObjectUtil.isNotEmpty(user)){
// 添加用户的支付宝userid
// 存在则修改用户的支付宝userid
user.setUserId(userId);
userService.updateById(user);
}else {
// 不存在则添加用户的支付宝userid
LJUserVo ljUser = new LJUserVo();
ljUser.setMobile(userInfo.get("phone").toString());
ljUser.setMobile(map.get("phone"));
ljUser.setUserId(userId);
userService.insertUser(ljUser);
}
LJUser ljUser = userService.selectUserByMobile(map.get("phone"));
return getSuccessResult("");
String userAgent = request.getHeader("user-agent");
AccountInfo accountInfo = new AccountInfo();
accountInfo.setId(ljUser.getId());
accountInfo.setDeptId(-1L);
if (ObjectUtil.isNotEmpty(storeId) && storeId!= "") {
accountInfo.setStoreId(Integer.parseInt(storeId));
}
String token = TokenUtil.generateToken(userAgent, ljUser.getId());
accountInfo.setToken(token);
TokenUtil.saveAccountToken(accountInfo);
LoginResponse response = new LoginResponse();
response.setLogin(true);
response.setChainStoreId(ljStore.getChainStoreId());
response.setToken(token);
response.setTokenCreatedTime(new Date());
return getSuccessResult("登录成功",response);
}
}

View File

@ -41,7 +41,7 @@
// #ifdef MP-ALIPAY
uni.setStorageSync("appltType","ALIPAY")
console.log("支付宝")
my.canIUse('button.open-type.getAuthorize')
// #endif
},
onShow: function() {

View File

@ -277,10 +277,11 @@
let _this = this;
// this.getAddress();
wx.getSetting({
uni.getSetting({
success(res) {
console.log(res,111)
if (!res.authSetting['scope.userLocation']) {
wx.authorize({
uni.authorize({
scope: 'scope.userLocation',
success() {
//

View File

@ -113,7 +113,7 @@
data() {
return {
value: '',
liters:"",
liters:"",
show: false,
pic: 0,
hindex: 0,
@ -159,7 +159,7 @@
orderAmount:0,
discountAmount:0,
payAmount:0,
payType:"WECHAT",
payType:uni.getStorageSync("appltType"),
},
}
},
@ -188,7 +188,8 @@
},
onShow() {
// this.isExistStoreId();
this.getStore(uni.getStorageSync("storeId"));
// this.getStore(uni.getStorageSync("storeId"));
this.getStore(0);
},
methods: {
isExistStoreId(){

View File

@ -57,6 +57,7 @@
// return;
// }
console.log(e)
let _this = this;
my.getAuthCode({
scopes: 'auth_base',
@ -68,15 +69,23 @@
method: 'post',
data: {
authCode:authCode,
userInfo: {
storeId: 0,
staffId: "",
phone: '18457621459'
},
storeId:0,
staffId:"",
phone:"18457621459",
},
}).then((resp)=>{
console.log(resp)
// uni.setStorageSync("userId",resp.data)
if (resp.code == 200) {
uni.setStorageSync('App-Token', resp.data.token);
uni.setStorageSync('chainStoreId', resp.data.chainStoreId);
uni.navigateTo({
url: '/pages/index/index'
})
}
console.log("swq", uni.getStorageSync(
'App-Token'));
})
},
fail: err => {

View File

@ -60,15 +60,15 @@
<view class="desc" >
<view style="display: flex;">
满减活动优惠
<span style="display: flex;">(满减活动})</span>
活动优惠
<!-- <span style="display: flex;">(满减活动)</span> -->
</view>
<view style="display: flex;">
<span style="margin-right: 10px;">-{{fullRedece}}</span>
</view>
</view>
<view class="desc" >
<!-- <view class="desc" >
<view style="display: flex;">
优惠券优惠
<span style="display: flex;">(优惠券)</span>
@ -76,7 +76,7 @@
<view style="display: flex;">
<span style="margin-right: 10px;">-{{couponRedece}}</span>
</view>
</view>
</view> -->
<view class="desc" v-if="isGradePreferential">
<view style="display: flex;">
@ -94,17 +94,20 @@
<view style="background-color: white;width: 94%;margin: 15px auto;height: 100px;">
<view style="font-weight: bold;height: 40px;line-height: 40px;margin-left: 10px;margin-top: 20px;">支付方式
</view>
<!-- <view class="desc">
<view>微信支付</view>
<u-radio-group v-model="value">
<u-radio name="wx"></u-radio>
</u-radio-group>
</view> -->
<!-- #ifdef MP-WEIXIN -->
<view class="scc">
<image src="@/static/imgs/wechat.png" class="imgIcon"></image>
<span style="width: 70%;margin-top: 5px;">微信支付</span>
<radio value="r1" checked="true" />
</view>
<!-- #endif -->
<!-- #ifdef MP-ALIPAY -->
<view class="scc">
<image src="@/static/imgs/alipay.png" class="imgIcon"></image>
<span style="width: 70%;margin-top: 5px;">支付宝支付</span>
<radio value="r1" checked="true" />
</view>
<!-- #endif -->
</view>
<!-- 支付信息 -->
@ -130,7 +133,7 @@
data() {
return {
// WECHAT ALIPAY
appltType: "WECHAT",
appltType: uni.getStorageSync("appltType"),
gradeDis:"",
title: '',
value: true,
@ -146,6 +149,8 @@
oilName: "",
//
oilType:"",
// id
oilId:"",
//
user:{
cardBalance:0,
@ -179,11 +184,17 @@
isStoreValueCard:false,
// 使
isGradePreferential:false,
transferDTO:{
type:0,
amount:0,
oilId:"",
mtUserLevel:"",
}
}
},
onLoad(e) {
this.orderNo = e.orderNo
// this.orderNo = "234520231226154037a1f53b"
// this.orderNo = e.orderNo
this.orderNo = "234520231229140854e4c4ca"
},
onShow() {
this.getOilOrder();
@ -205,8 +216,8 @@
oilCardLiters : this.oilCardRedece,
balanceAmount : this.balanceRedece,
isOilStorageCard : this.isOilStorageCard,
tankId : uni.getStorageSync("tankId"),
// tankId : 6,
// tankId : uni.getStorageSync("tankId"),
tankId : 6,
};
let _this = this;
request({
@ -214,14 +225,14 @@
method: 'post',
data: map,
}).then(res => {
// console.log(res)
console.log(res,_this.appltType)
let payProvider = "wxpay"
if (_this.appltType== "WECHAT"){
payProvider = "wxpay"
}else{
payProvider = "alipay"
}
if (res.data.reservedPayInfo!=null && res.data.reservedPayInfo!=""){
if (res.data.data.reservedPayInfo!=null && res.data.data.reservedPayInfo!=""){
_this.orderInfo = JSON.parse(res.data.data.reservedPayInfo);
uni.requestPayment({
// provider: 'wxpay' 'alipay'
@ -260,6 +271,9 @@
my.tradePay({ tradeNO: res.data.data.reservedTransactionId }, function(resp){
if(resp.resultCode == '9000'){
console.log("支付成功")
uni.reLaunch({
url: '/pagesRefuel/orderSuccess/index'
})
}else{
request({
url: "/business/allOrderInfo/orderStatus",
@ -312,6 +326,7 @@
this.deductAmount = this.oilOrder.orderAmount - this.balanceRedece
this.payAmount = this.oilOrder.orderAmount - this.balanceRedece
}
this.preferential.amount = this.deductAmount
}else{
// 使
//
@ -325,6 +340,7 @@
}
}else{
this.deductAmount = this.oilOrder.orderAmount
this.transferDTO.amount = this.deductAmount
}
},
// 使
@ -336,6 +352,7 @@
}).then((res) => {
if (res.data != null && res.data != ""){
that.userGrade = res.data
that.chooseFullOrCoupon();
if (res.data.preferential== "自定义优惠"){
if (that.oilType == "汽油"){
//
@ -477,6 +494,25 @@
}
})
},
// 使
chooseFullOrCoupon(){
this.transferDTO.amount = this.deductAmount
this.transferDTO.mtUserLevel = this.userGrade.id
this.transferDTO.oilId = this.oilId
console.log(this.transferDTO)
let _this = this;
request({
url: "business/marketingActivity/activeExchange/test",
method: 'post',
data:_this.transferDTO,
}).then((res) => {
console.log(res)
if (res.data.amount!=0){
_this.payAmount = res.data.amount - _this.gradeRedece
_this.fullRedece = res.data.favorableAmount
}
})
},
//
countPayMent(){
@ -510,11 +546,14 @@
orderNo: _this.orderNo
},
}).then((res) => {
_this.oilOrder = res.data
_this.getStaffList(res.data.staffId)
_this.getStore(res.data.storeId)
_this.getOilNumber(res.data.storeId)
_this.getUser(res.data.userId)
// console.log(res)
if(res.data!=null){
_this.oilOrder = res.data
_this.getStaffList(res.data.staffId)
_this.getStore(res.data.storeId)
_this.getOilNumber(res.data.storeId)
_this.getUser(res.data.userId)
}
})
},
//
@ -552,6 +591,7 @@
_this.oilPrice = item.gbPrice;
_this.oilName = item.oilNames;
_this.oilType = item.oilType;
_this.oilId = item.oilId;
}
})
})