lsw 9 månader sedan
förälder
incheckning
3063af7ca4

+ 7 - 0
app/pages.json

@@ -260,6 +260,13 @@
 			{
 				"navigationBarTitleText" : "资金管理"
 			}
+		},
+		{
+			"path" : "pages/user/money/add",
+			"style" : 
+			{
+				"navigationBarTitleText" : "金额充值"
+			}
 		}
 	],
 	"tabBar": {

+ 0 - 31
app/pages/other/setting.vue

@@ -1,7 +1,6 @@
 <template>
 	<view class="main pt0">
 		<button class="btn" @click="exit()">退出登陆</button>
-		<button class="btn" @click="pay()">支付测试</button>
 	</view>
 </template>
 
@@ -11,36 +10,6 @@ export default {
 		return {};
 	},
 	methods: {
-		pay() {
-			this.http.request({
-				url: '/app/wxPay/jsApiPay',
-				method: 'POST',
-				data:{money:0.01},
-				success: (res) => {
-					wx.requestPayment({
-						appId: res.data.data.appId,
-						nonceStr: res.data.data.nonceStr,
-						package: res.data.data.package,
-						paySign: res.data.data.paySign,
-						timeStamp: res.data.data.timeStamp,
-						signType: res.data.data.signType,
-						success: (r) => {
-							uni.showModal({
-								title: '提示',
-								content: '下单成功',
-								showCancel: false,
-								success: (res) => {
-									uni.navigateBack({ delta: 2 });
-								}
-							});
-						},
-						fail: (r) => {
-							uni.showModal({ content: r.data.msg, showCancel: false });
-						}
-					});
-				}
-			});
-		},
 		exit() {
 			uni.showModal({
 				title: '提示',

+ 0 - 1
app/pages/user/auth.vue

@@ -65,7 +65,6 @@ export default {
 		getData() {
 			this.http.request({
 				url: '/app/user/info',
-				data: this.item,
 				success: (res) => {
 					this.item = res.data.data;
 					if (this.item.isAuthentication === 1) {

+ 8 - 8
app/pages/user/index.vue

@@ -34,11 +34,11 @@
 					</view>
 				</view>
 			</view>
-			<view class="row">
+			<view class="row" @click="go('/pages/user/money/index')">
 				<view class="out">
 					<view class="int">
-						<view class="num">{{ user.agree || 0 }}</view>
-						<view class="desc">面试人数</view>
+						<view class="num">{{ user.money || 0 }}</view>
+						<view class="desc">账户余额</view>
 					</view>
 				</view>
 			</view>
@@ -61,11 +61,11 @@
 					</view>
 				</view>
 			</view>
-			<view class="row">
+			<view class="row" @click="go('/pages/user/money/index')">
 				<view class="out">
 					<view class="int">
-						<view class="num">{{ user.invite || 0 }}</view>
-						<view class="desc">面试次数</view>
+						<view class="num">{{ user.money || 0 }}</view>
+						<view class="desc">账户余额</view>
 					</view>
 				</view>
 			</view>
@@ -216,8 +216,8 @@ export default {
 		};
 	},
 	onShow() {
-		/* 		 		 		 		 	 this.user = {
-				token: 'eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjZkOTE1NTNkLWE1ZjktNDU4Yy05MTM2LTU2MDc0Y2M2ZmNkZiJ9.j4mYCmtjhup6CyxxQXznMjqdWi1HoAaF2nT4PpMWTl3B3UrQMwDACrYUWctml83wg4uf43PjIPOvfkFpaUADOw'
+/* 		 	this.user = {
+				token: 'eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6ImIwNzE0MjFkLTg1NTAtNDk4Yy1iOTAzLTQ1NTBkMmJhYThkZSJ9.y6PAxUng74T4gq1apPRqTowMGVPqdx0fiNrBmeiP3l7mqgKibRrlOrZUYdaNWE3GxhiGklZ1wHEmzuiq9Tez7Q'
 			};
 			uni.setStorageSync('user', this.user); */
 

+ 54 - 0
app/pages/user/money/add.vue

@@ -0,0 +1,54 @@
+<template>
+	<view class="main">
+		<view class="form_group">
+			<view class="lable re">充值金额</view>
+			<input type="number" v-model="item.money" placeholder="请输入充值金额" />
+		</view>
+		<button class="btn" @click="pay()">确认</button>
+	</view>
+</template>
+
+<script>
+export default {
+	data() {
+		return {
+			item: {}
+		};
+	},
+	methods: {
+		pay() {
+			this.http.request({
+				url: '/app/wxPay/pay',
+				method: 'POST',
+				data: this.item,
+				success: (res) => {
+					wx.requestPayment({
+						appId: res.data.data.appId,
+						nonceStr: res.data.data.nonceStr,
+						package: res.data.data.package,
+						paySign: res.data.data.paySign,
+						timeStamp: res.data.data.timeStamp,
+						signType: res.data.data.signType,
+						success: (r) => {
+							uni.showModal({
+								title: '提示',
+								content: '充值成功:' + this.item.money + ' 元',
+								showCancel: false,
+								success: (res) => {
+									uni.$emit('payMoney');
+									uni.navigateBack();
+								}
+							});
+						},
+						fail: (r) => {
+							uni.showModal({ content: r.data.msg, showCancel: false });
+						}
+					});
+				}
+			});
+		}
+	}
+};
+</script>
+
+<style lang="scss"></style>

+ 166 - 8
app/pages/user/money/index.vue

@@ -1,19 +1,177 @@
 <template>
-	<view>
-		
+	<view class="main">
+		<view class="card">
+			<view class="money">{{ item.money }}</view>
+			<view class="desc">账户余额(元)</view>
+			<view class="flex">
+				<view class="f">
+					<button class="btn" style="background-color: #607d8b">
+						<text class="icon">&#xe612;</text>
+						<text>提现</text>
+					</button>
+				</view>
+				<view class="f">
+					<button class="btn" @click="go('/pages/user/money/add')">
+						<text class="icon">&#xe7c4;</text>
+						<text>充值</text>
+					</button>
+				</view>
+			</view>
+		</view>
+		<view class="tab">
+			<u-tabs :list="type" @click="click($event, 'type')"></u-tabs>
+		</view>
+		<view class="list">
+			<view class="item" v-for="(item, index) in list" :key="index">
+				<view class="title">{{ item.title }}</view>
+				<view class="desc">
+					<text v-if="item.state == 0 && item.type == 0" style="color: #f44336">未支付</text>
+					<text v-if="item.state == 1 && item.type == 0" style="color: #4caf50">充值成功</text>
+					<text>{{ item.createTime }}</text>
+				</view>
+				<view class="price">
+					<text v-if="item.type == 0" style="color: orangered">+{{ item.money }}</text>
+					<text v-if="item.type == 1" style="color: orangered">-{{ item.money }}</text>
+				</view>
+			</view>
+			<view class="loading" v-if="loadMore"><u-loadmore :status="loadMore ? 'loading' : 'nomore'" /></view>
+			<u-empty v-if="!loadMore && list.length == 0"></u-empty>
+		</view>
 	</view>
 </template>
 
 <script>
-	export default {
-		data() {
-			return {
-				
-			};
+export default {
+	data() {
+		return {
+			item: {},
+			current: 0,
+			type: [
+				{ name: '全部', value: '' },
+				{ name: '充值', value: 0 },
+				{ name: '支出', value: 1 },
+				{ name: '提现', value: 2 },
+				{ name: '收入', value: 3 }
+			],
+			list: [],
+			param: { pageNum: 1, pageSize: 10, type: 0 },
+			loadMore: true
+		};
+	},
+	onLoad(e) {
+		this.getInfo();
+		this.getData();
+		uni.$on('payMoney', (res) => {
+			this.getInfo();
+			this.getData();
+		});
+	},
+	methods: {
+		getInfo() {
+			this.http.request({
+				url: '/app/user/info',
+				success: (res) => {
+					this.item = res.data.data;
+				}
+			});
+		},
+		getData() {
+			this.http.request({
+				url: '/app/pay/list',
+				data: this.param,
+				loading: 'false',
+				success: (res) => {
+					this.loadMore = res.data.pages > this.param.pageNum ? true : false;
+					this.list.push(...res.data.rows);
+				}
+			});
+		},
+		click(e) {
+			this.param.type = e.value;
+			this.refresh();
+		},
+		go(url) {
+			uni.navigateTo({ url: url });
+		},
+		//刷新数据
+		refresh() {
+			this.loadMore = true;
+			this.param.pageNum = 1;
+			this.list = [];
+			this.getData();
+		}
+	},
+	//下拉刷新
+	onPullDownRefresh() {
+		setTimeout(() => {
+			this.refresh();
+			uni.stopPullDownRefresh();
+		}, 1000);
+	},
+	//上拉加载
+	onReachBottom() {
+		if (this.loadMore) {
+			this.param.pageNum++;
+			this.getData();
 		}
 	}
+};
 </script>
 
 <style lang="scss">
-
+.card {
+	background-color: white;
+	padding: 15px;
+	border-radius: 8px;
+	.money {
+		font-size: 22px;
+		font-weight: bold;
+	}
+	.desc {
+		padding-top: 10px;
+		font-size: 14px;
+		color: $font-c;
+	}
+	.f {
+		padding: 10px;
+		.btn {
+			padding: 0px;
+			.icon {
+				padding-right: 3px;
+			}
+		}
+	}
+}
+.list {
+	background-color: white;
+	border-radius: 8px;
+	padding: 15px 15px 15px 15px;
+	.item {
+		padding: 15px 0px 15px 0px;
+		border-bottom: 1px solid $line;
+		padding-bottom: 10px;
+		&:first-child {
+			padding-top: 0px;
+		}
+		&:last-child {
+			border: 0px;
+			padding-bottom: 5px;
+		}
+		.title {
+			width: 70%;
+		}
+		.desc {
+			font-size: 14px;
+			padding-top: 5px;
+			color: $font-c;
+			text {
+				padding-right: 15px;
+			}
+		}
+		.price {
+			float: right;
+			margin-top: -35px;
+		}
+	}
+}
 </style>

+ 41 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/work/api/Api_PayController.java

@@ -0,0 +1,41 @@
+package com.ruoyi.web.work.api;
+
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.page.TableDataInfo;
+import com.ruoyi.web.work.api.config.BaseController;
+import com.ruoyi.web.work.domain.Pay;
+import com.ruoyi.web.work.service.IPayService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * 微信在线充值记录
+ *
+ * @author lsw
+ * @date 2024-07-01
+ */
+@RestController
+@RequestMapping("/app/pay")
+public class Api_PayController extends BaseController {
+    @Autowired
+    private IPayService payService;
+
+    @GetMapping("/list")
+    public TableDataInfo list(Pay pay) {
+        pay.setUserId(getUser().getId());
+        startPage();
+        List<Pay> list = payService.selectList(pay);
+        return getDataTable(list);
+    }
+
+    @GetMapping(value = "/detail/{id}")
+    public AjaxResult detail(@PathVariable("id") Long id) {
+        return AjaxResult.success(payService.getById(id));
+    }
+
+}

+ 1 - 3
ruoyi-admin/src/main/java/com/ruoyi/web/work/api/config/InterceptorConfig.java

@@ -33,9 +33,7 @@ public class InterceptorConfig implements WebMvcConfigurer {
         registration.excludePathPatterns("/app/common/type/*"); //排除
         registration.excludePathPatterns("/app/common/agreement/*"); //排除
         registration.excludePathPatterns("/app/enterprise/list"); //排除
-        registration.excludePathPatterns("/app/wxPay/payNotify"); //排除
-        registration.excludePathPatterns("/app/wxPay/platformCert"); //排除
-        registration.excludePathPatterns("/app/wxPay/get"); //排除
+        registration.excludePathPatterns("/app/wxPay/notify"); //排除
     }
 
     @Override

+ 8 - 7
ruoyi-admin/src/main/java/com/ruoyi/web/work/domain/Pay.java

@@ -31,10 +31,16 @@ public class Pay{
     @ApiModelProperty(value = "充值金额")
     private BigDecimal money;
 
-    @ApiModelProperty(value = "状态:0=待充值,1=成功,2=失败")
+    @ApiModelProperty(value = "状态:0=待支付,1=支付成功")
     private Integer state;
 
-    @ApiModelProperty(value = "充值无效原因")
+    @ApiModelProperty(value = "标题")
+    private String title;
+
+    @ApiModelProperty(value = "类型:0=充值,1=支出")
+    private Integer type;
+
+    @ApiModelProperty(value = "原因")
     private String msg;
 
     @ApiModelProperty(value = "乐观锁")
@@ -45,11 +51,6 @@ public class Pay{
     private Date createTime;
 
     @TableField(fill = FieldFill.UPDATE)
-    private String updateBy;
-
-    @TableField(fill = FieldFill.UPDATE)
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private Date updateTime;
-
-
 }

+ 11 - 67
ruoyi-admin/src/main/java/com/ruoyi/web/work/wxpay/UserPayController.java

@@ -5,7 +5,6 @@ import cn.hutool.http.ContentType;
 import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson2.JSONObject;
 import com.ijpay.core.IJPayHttpResponse;
-import com.ijpay.core.enums.AuthTypeEnum;
 import com.ijpay.core.enums.RequestMethodEnum;
 import com.ijpay.core.kit.HttpKit;
 import com.ijpay.core.kit.PayKit;
@@ -17,26 +16,21 @@ import com.ijpay.wxpay.enums.v3.BasePayApiEnum;
 import com.ijpay.wxpay.model.v3.Amount;
 import com.ijpay.wxpay.model.v3.Payer;
 import com.ijpay.wxpay.model.v3.UnifiedOrderModel;
-import com.ruoyi.common.annotation.Log;
 import com.ruoyi.common.core.domain.AjaxResult;
-import com.ruoyi.common.enums.BusinessType;
 import com.ruoyi.common.exception.ServiceException;
-import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.web.work.api.config.BaseController;
 import com.ruoyi.web.work.domain.Pay;
-import com.ruoyi.web.work.domain.Recharge;
 import com.ruoyi.web.work.domain.User;
-import com.ruoyi.web.work.domain.dto.CompanyPayDto;
 import com.ruoyi.web.work.domain.dto.PayDto;
-import com.ruoyi.web.work.domain.dto.PayStateDto;
-import com.ruoyi.web.work.service.ICompanyService;
 import com.ruoyi.web.work.service.IPayService;
-import com.ruoyi.web.work.service.IRechargeService;
 import com.ruoyi.web.work.service.IUserService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.*;
+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 javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
@@ -58,70 +52,17 @@ public class UserPayController extends BaseController {
     @Autowired
     private IUserService userService;
 
-    @Autowired
-    private IRechargeService rechargeService;
 
     @Autowired
     private IPayService payService;
 
-    @Autowired
-    private ICompanyService companyService;
 
     /**
-     * PC扫码支付
-     *
      * @param dto
      * @return
      */
-    @Log(title = "微信充值", businessType = BusinessType.PAY)
-    @PostMapping("/companyPay")
-    @Transactional(rollbackFor = Exception.class)
-    public AjaxResult companyPay(@Validated @RequestBody CompanyPayDto dto) {
-        try {
-            String orderNum = PayKit.generateStr();
-            UnifiedOrderModel unifiedOrderModel = new UnifiedOrderModel();
-            unifiedOrderModel.setAppid(wxPayV3Bean.getAppId());
-            unifiedOrderModel.setMchid(wxPayV3Bean.getMchId());
-            unifiedOrderModel.setDescription("企业账户充值");
-            unifiedOrderModel.setOut_trade_no(orderNum);
-            unifiedOrderModel.setTime_expire(DateTimeZoneUtil.dateToTimeZone(System.currentTimeMillis() + 1000 * 60 * 3));
-            unifiedOrderModel.setAttach("企业账户充值");
-            unifiedOrderModel.setNotify_url(wxPayV3Bean.getDomain().concat("/app/wxPay/companyNotify"));
-            unifiedOrderModel.setAmount(new Amount().setTotal(dto.getMoney().multiply(new BigDecimal(100)).intValue()));
-            IJPayHttpResponse response = WxPayApi.v3(RequestMethodEnum.POST, WxDomainEnum.CHINA.toString(), BasePayApiEnum.NATIVE_PAY.toString(), wxPayV3Bean.getMchId(), getSerialNumber(), null, wxPayV3Bean.getKeyPath(), JSONUtil.toJsonStr(unifiedOrderModel), AuthTypeEnum.RSA.getCode());
-            boolean verifySignature = WxPayKit.verifySignature(response, wxPayV3Bean.getPlatformCertPath());
-            if (response.getStatus() == 200 && verifySignature) {
-                //保存订单信息
-                Recharge recharge = new Recharge();
-                recharge.setCompanyId(SecurityUtils.getLoginUser().getUser().getCompanyId());
-                recharge.setState(0);
-                recharge.setType(1);
-                recharge.setIdent(dto.getIdent());
-                recharge.setNums(orderNum);
-                recharge.setMoney(dto.getMoney());
-                recharge.setVersion(System.currentTimeMillis());
-                recharge.setOpBy(SecurityUtils.getLoginUser().getUser().getNickName());
-                recharge.setUserId(SecurityUtils.getLoginUser().getUser().getUserId());
-                if (!rechargeService.save(recharge)) {
-                    return AjaxResult.error("充值失败,请联系平台或者转账充值");
-                }
-                return AjaxResult.success(response.getBody());
-            }
-            return AjaxResult.error("支付异常,请联系平台或者转账充值");
-        } catch (Exception e) {
-            throw new ServiceException(e.getMessage());
-        }
-    }
-    @GetMapping("/payState")
-    public AjaxResult payState(@Validated PayStateDto dto) {
-        return AjaxResult.success(rechargeService.selectByIdent(dto.getIdent()) == null ? false : true);
-    }
-    /**
-     * @param dto
-     * @return
-     */
-    @PostMapping("/jsApiPay")
-    public AjaxResult jsApiPay(@Validated @RequestBody PayDto dto) {
+    @PostMapping("/pay")
+    public AjaxResult pay(@Validated @RequestBody PayDto dto) {
         try {
             String orderNum = PayKit.generateStr();
             UnifiedOrderModel unifiedOrderModel = new UnifiedOrderModel();
@@ -132,7 +73,7 @@ public class UserPayController extends BaseController {
             unifiedOrderModel.setTime_expire(DateTimeZoneUtil.dateToTimeZone(System.currentTimeMillis() + 1000 * 60 * 3));
             unifiedOrderModel.setAttach("账户充值");
             unifiedOrderModel.setAmount(new Amount().setTotal(dto.getMoney().multiply(new BigDecimal(100)).intValue()));
-            unifiedOrderModel.setNotify_url(wxPayV3Bean.getDomain().concat("/app/wxPay/payNotify"));
+            unifiedOrderModel.setNotify_url(wxPayV3Bean.getDomain().concat("/app/wxPay/notify"));
             unifiedOrderModel.setPayer(new Payer().setOpenid(getUser().getOpenId()));
             IJPayHttpResponse response = WxPayApi.v3(RequestMethodEnum.POST, WxDomainEnum.CHINA.toString(), BasePayApiEnum.JS_API_PAY.toString(), wxPayV3Bean.getMchId(), getSerialNumber(), null, wxPayV3Bean.getKeyPath(), JSONUtil.toJsonStr(unifiedOrderModel));
             System.out.println("统一下单响应:" + response);
@@ -146,6 +87,8 @@ public class UserPayController extends BaseController {
                 pay.setUserId(getUser().getId());
                 pay.setMoney(dto.getMoney());
                 pay.setState(0);
+                pay.setType(0);
+                pay.setTitle("在线充值");
                 pay.setVersion(System.currentTimeMillis());
                 pay.setNums(orderNum);
                 if (!payService.save(pay)) {
@@ -160,7 +103,7 @@ public class UserPayController extends BaseController {
     }
 
     @Transactional
-    @PostMapping(value = "/payNotify")
+    @PostMapping(value = "/notify")
     public void payNotify(HttpServletRequest request, HttpServletResponse response) {
         Map<String, String> map = new HashMap<>(12);
         try {
@@ -202,6 +145,7 @@ public class UserPayController extends BaseController {
             throw new ServiceException(e.getMessage());
         }
     }
+
     /**
      * 获取证书序列号
      *

+ 1 - 2
ruoyi-admin/src/main/resources/mapper/work/PayMapper.xml

@@ -11,8 +11,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="nums != null  and nums != ''"> and nums = #{nums}</if>
             <if test="money != null "> and money = #{money}</if>
             <if test="state != null "> and state = #{state}</if>
-            <if test="msg != null  and msg != ''"> and msg = #{msg}</if>
-            <if test="version != null "> and version = #{version}</if>
+            <if test="type != null "> and type = #{type}</if>
         </where>
     </select>