lsw před 11 měsíci
rodič
revize
aef77ddc78

+ 20 - 3
admin-ui/src/views/work/platform/index.vue

@@ -1,7 +1,7 @@
 <template>
-  <div class="app-container" style="overflow-y: auto;">
+  <div class="app-container" style="overflow-y: auto">
     <div class="cmain">
-      <el-form ref="form" :model="form" :rules="rules" label-width="120px">
+      <el-form ref="form" :model="form" :rules="rules" label-width="130px">
         <div class="bos">
           <div class="lab">
             <div class="bsg"></div>
@@ -22,6 +22,15 @@
           <el-form-item label="平台邮箱" prop="email">
             <el-input v-model="form.email" placeholder="请输入邮箱" clearable />
           </el-form-item>
+          <el-form-item label="兼职服务费率(%)" prop="partTimeService">
+            <el-input type="number" v-model="form.partTimeService" placeholder="请输入兼职服务费率" clearable />
+          </el-form-item>
+          <el-form-item label="提现服务费率(%)" prop="cashOutService">
+            <el-input type="number" v-model="form.cashOutService" placeholder="请输入提现服务费率" clearable />
+          </el-form-item>
+          <el-form-item label="最少提现金额" prop="cashOutMoney">
+            <el-input type="number" v-model="form.cashOutMoney" placeholder="请输入最少提现金额" clearable />
+          </el-form-item>
         </div>
         <div class="bos">
           <div class="lab">
@@ -46,6 +55,9 @@
           <el-form-item label="隐私政策" prop="privacy">
             <editor v-model="form.privacy" placeholder="请输入内容"></editor>
           </el-form-item>
+          <el-form-item label="兼职须知" prop="guide">
+            <editor v-model="form.guide" placeholder="请输入内容"></editor>
+          </el-form-item>
         </div>
       </el-form>
       <div>
@@ -68,7 +80,12 @@ export default {
         email: [{ required: true, message: '不能为空', trigger: 'blur' }],
         bankName: [{ required: true, message: '不能为空', trigger: 'blur' }],
         bankAccount: [{ required: true, message: '不能为空', trigger: 'blur' }],
-        rate: [{ required: true, message: '不能为空', trigger: 'blur' }]
+        partTimeService: [{ required: true, message: '不能为空', trigger: 'blur' }],
+        cashOutService: [{ required: true, message: '不能为空', trigger: 'blur' }],
+        cashOutMoney: [{ required: true, message: '不能为空', trigger: 'blur' }],
+        privacy: [{ required: true, message: '不能为空', trigger: 'blur' }],
+        agreement: [{ required: true, message: '不能为空', trigger: 'blur' }],
+        guide: [{ required: true, message: '不能为空', trigger: 'blur' }]
       }
     };
   },

+ 25 - 0
app/common/common.scss

@@ -228,6 +228,31 @@
 	padding: 15px;
 	background-color: white;
 	border-radius: 10px;
+	.mtt{
+		text-align: center;
+		font-size: 18px;
+		padding-top: 25px;
+	}
+	.money{
+		text-align: center;
+		font-size: 30px;
+		padding-top: 5px;
+		font-weight: bold;
+	}
+	.item{
+		overflow: hidden;
+		border-bottom: 1px solid $line;
+		padding: 10px;
+		&:last-child{
+			border: 0px;
+		}
+		.tt{
+			float: left;
+		}
+		.la{
+			float: right;
+		}
+	}
 }
 .search {
 	overflow: hidden;

+ 2 - 2
app/common/http.js

@@ -1,6 +1,6 @@
 //const ip = 'http://127.0.0.1:9191';
-const ip = 'https://chenglantimes.com/prod-api';
-//const ip = 'http://192.168.0.102:9191';
+//const ip = 'https://chenglantimes.com/prod-api';
+const ip = 'http://192.168.0.105:9191';
 /**
  * 封装的http请求
  */

+ 1 - 1
app/components/leditor/leditor.vue

@@ -108,7 +108,7 @@ export default {
 								let result = JSON.parse(res.data);
 								if (result.code === 200) {
 									this.editorCtx.insertImage({
-										src: this.http.urls.ip + JSON.parse(res.data).fileName,
+										src: this.http.ip + JSON.parse(res.data).fileName,
 										alt: '图像'
 									});
 								} else {

+ 1 - 1
app/pages.json

@@ -218,7 +218,7 @@
 		{
 			"path": "pages/statement/user/info",
 			"style": {
-				"navigationBarTitleText": "结算信息"
+				"navigationBarTitleText": "银行卡信息"
 			}
 		},
 		{

+ 56 - 13
app/pages/job/position/manage/part_time_push.vue

@@ -8,7 +8,7 @@
 			<view class="lable re">兼职类型</view>
 			<picker :disabled="true" @click="go('/pages/job/position/classification')">
 				<input placeholder="请选择" v-model="item.positionName" :disabled="true" />
-				<view class="icon more">&#xe8f2;</view>
+				<view class="icon more">&#xe62b;</view>
 			</picker>
 		</view>
 		<view class="form_group">
@@ -46,6 +46,10 @@
 			</view>
 		</view>
 		<view class="form_group">
+			<view class="lable re">结算方式</view>
+			<input value="完工结算" :disabled="true" />
+		</view>
+		<view class="form_group">
 			<view class="lable">兼职地点</view>
 			<picker :disabled="true" @click="chooseLocation()">
 				<input :placeholder="item.type == 0 ? '请选择' : '留空不限工作地点'" v-model="item.location" :disabled="true" />
@@ -55,6 +59,27 @@
 			<view class="bz">如需应聘者去现场请选择兼职地点</view>
 		</view>
 		<button class="btn" @click="save()">{{ item.id ? '编辑' : '保存' }}</button>
+		<u-popup :show="show" round="15" mode="center" :closeable="true" :closeOnClickOverlay="false" :customStyle="{ width: '85%' }" @close="show = false">
+			<view class="popup">
+				<view class="mtt">兼职金额</view>
+				<view class="money">¥{{ item.salary }}</view>
+				<view>
+					<view class="item">
+						<text class="tt">服务费</text>
+						<text class="la">¥{{ item.serviceMoney }}</text>
+					</view>
+					<view class="item">
+						<text class="tt">费率</text>
+						<text class="la">{{ platform.cashOutService }}%</text>
+					</view>
+					<view class="item">
+						<text class="tt">实际扣除</text>
+						<text class="la">¥{{ item.realMoney }}</text>
+					</view>
+				</view>
+				<button class="btn" @click="ok()">确定</button>
+			</view>
+		</u-popup>
 	</view>
 </template>
 <script>
@@ -64,13 +89,8 @@ export default {
 			money: 0,
 			item: { type: 1 },
 			end: this.util.getDate('day'),
-			dict: {
-				positionName: this.util.getData('positionName'),
-				experience: this.util.getData('experience'),
-				salary: [['面议'], ['']],
-				location: this.util.getData('address'),
-				unit: this.util.getData('unit')
-			}
+			platform: {},
+			show: false
 		};
 	},
 	onLoad(e) {
@@ -89,17 +109,23 @@ export default {
 			this.item.positionId = res.id;
 			this.$forceUpdate();
 		});
+		this.getPlatform();
 	},
 	onShow() {
 		this.money = uni.getStorageSync('money');
 	},
 	methods: {
+		//平台服务费信息
+		getPlatform() {
+			this.http.request({
+				url: '/app/pay/getPlatform',
+				success: (res) => {
+					this.platform = res.data.data;
+				}
+			});
+		},
 		picker(e, tag) {
-			if (tag == 'startDate' || tag == 'endDate') {
-				this.item[tag] = e.detail.value;
-			} else {
-				this.item[tag] = this.dict[tag][e.detail.value];
-			}
+			this.item[tag] = e.detail.value;
 			this.$forceUpdate();
 		},
 		go(url) {
@@ -124,6 +150,23 @@ export default {
 			});
 		},
 		save() {
+			let rule = [
+				{ name: 'title', checkType: 'notnull', errorMsg: '请输入兼职名称' },
+				{ name: 'positionName', checkType: 'notnull', errorMsg: '请选择兼职类型' },
+				{ name: 'contents', checkType: 'notnull', errorMsg: '请输入兼职描述(要求)' },
+				{ name: 'salary', checkType: 'notnull', errorMsg: '请输入兼职金额' },
+				{ name: 'startDate', checkType: 'notnull', errorMsg: '请选择兼职开始时间' },
+				{ name: 'endDate', checkType: 'notnull', errorMsg: '请选择兼职结束时间' }
+			];
+			if (!this.verify.check(this.item, rule)) {
+				uni.showModal({ content: this.verify.error, showCancel: false });
+				return false;
+			}
+			this.show = true;
+			this.item.serviceMoney = (this.item.salary * (this.platform.cashOutService / 100)).toFixed(2);
+			this.item.realMoney = (parseFloat(this.item.salary) + parseFloat(this.item.serviceMoney)).toFixed(2);
+		},
+		ok() {
 			this.http.request({
 				url: this.item.id ? '/app/position/manage/edit' : '/app/position/manage/add',
 				data: this.item,

+ 10 - 1
app/pages/user/money/add.vue

@@ -41,7 +41,16 @@ export default {
 							});
 						},
 						fail: (r) => {
-							uni.showModal({ content: r.data.msg, showCancel: false });
+							console.log('asd:' + JSON.stringify(r));
+							uni.showModal({
+								title: '提示',
+								content: r.errMsg.includes('cancel') ? '支付取消' : '支付异常',
+								showCancel: false,
+								success: (res) => {
+									uni.$emit('payMoney');
+									uni.navigateBack();
+								}
+							});
 						}
 					});
 				}

+ 75 - 38
app/pages/user/money/cash_out.vue

@@ -4,7 +4,7 @@
 			<view class="money">{{ money }}</view>
 			<view class="desc">可提现余额(元)</view>
 		</view>
-		<view class="mcard mt10">
+		<view class="mcard mt10 pd0">
 			<view class="form_group">
 				<view class="lable re">提现金额</view>
 				<view class="bgm">
@@ -19,7 +19,7 @@
 						<text class="icon tb" style="color: #ff9800">&#xe635;</text>
 						<view class="title">
 							<text>提现到银行卡</text>
-							<text class="desc" v-if="!bankName">(未填)</text>
+							<text class="desc" @click="go()">{{ bankName ? '查看' : '(未填)' }}</text>
 						</view>
 						<text class="icon check" v-if="item.way == 0">&#xe612;</text>
 					</view>
@@ -31,7 +31,29 @@
 				</view>
 			</view>
 		</view>
+		<view class="bz" v-if="platform.cashOutMoney > 0">最少提现金额:¥{{ platform.cashOutMoney }}起</view>
 		<button class="btn" @click="save()">确认</button>
+		<u-popup :show="show" round="15" mode="center" :closeable="true" :closeOnClickOverlay="false" :customStyle="{ width: '85%' }" @close="show = false">
+			<view class="popup">
+				<view class="mtt">提现</view>
+				<view class="money">¥{{ item.money }}</view>
+				<view>
+					<view class="item">
+						<text class="tt">服务费</text>
+						<text class="la">¥{{ item.serviceMoney }}</text>
+					</view>
+					<view class="item">
+						<text class="tt">费率</text>
+						<text class="la">{{ platform.cashOutService || 0 }}%</text>
+					</view>
+					<view class="item">
+						<text class="tt">实际到账</text>
+						<text class="la">¥{{ item.realMoney }}</text>
+					</view>
+				</view>
+				<button class="btn" @click="ok()">确定</button>
+			</view>
+		</u-popup>
 	</view>
 </template>
 
@@ -39,19 +61,35 @@
 export default {
 	data() {
 		return {
-			money: 0,
-			bankName: '',
-			item: { way: 0 }
+			money: 0, //提现金额
+			bankName: '', //是否填写银行卡
+			item: { way: 0, money: '' },
+			show: false,
+			platform: { cashOutMoney: 0 }
 		};
 	},
 	onShow() {
 		this.money = uni.getStorageSync('money');
 		this.bankName = uni.getStorageSync('bankName');
 	},
+	onLoad() {
+		this.getPlatform();
+	},
 	methods: {
+		//平台服务费信息
+		getPlatform() {
+			this.http.request({
+				url: '/app/pay/getPlatform',
+				success: (res) => {
+					this.platform = res.data.data;
+				}
+			});
+		},
 		all() {
 			this.item.money = this.money;
-			this.$forceUpdate();
+		},
+		go() {
+			uni.navigateTo({ url: '/pages/statement/user/info' });
 		},
 		save() {
 			let rule = [{ name: 'money', checkType: 'notnull', errorMsg: '请输入提现金额' }];
@@ -65,39 +103,36 @@ export default {
 					content: '请先填写银行卡信息',
 					showCancel: false,
 					success: (res) => {
-						uni.navigateTo({ url: '/pages/statement/user/info' });
+						this.go();
 					}
 				});
 				return;
 			}
-			uni.showModal({
-				title: '提示',
-				content: '确定提现' + this.item.money + '元',
+			this.item.serviceMoney = (this.item.money * (this.platform.cashOutService / 100)).toFixed(2);
+			this.item.realMoney = (this.item.money - this.item.serviceMoney).toFixed(2);
+			this.show = true;
+		},
+		ok() {
+			this.http.request({
+				url: '/app/pay/cashOut',
+				data: this.item,
+				method: 'POST',
 				success: (res) => {
-					if (res.confirm) {
-						this.http.request({
-							url: '/app/pay/cashOut',
-							data: this.item,
-							method: 'POST',
-							success: (res) => {
-								//通知模板订阅消息
-								uni.requestSubscribeMessage({
-									tmplIds: ['PtdKbqfzmpvGsJPx_YekDX4-cljbhOXcvoUB3XJaVLg', 'NIqSQq0j765o9Iz9gMiSelnuxMgPIPeCnk3lvEnWJlo'],
-									complete: (c) => {
-										uni.showModal({
-											title: '提示',
-											content: '提现申请成功,等待平台审核打款',
-											showCancel: false,
-											success: (res) => {
-												uni.$emit('payMoney');
-												uni.navigateBack();
-											}
-										});
-									}
-								});
-							}
-						});
-					}
+					//通知模板订阅消息
+					uni.requestSubscribeMessage({
+						tmplIds: ['PtdKbqfzmpvGsJPx_YekDX4-cljbhOXcvoUB3XJaVLg', 'NIqSQq0j765o9Iz9gMiSelnuxMgPIPeCnk3lvEnWJlo'],
+						complete: (c) => {
+							uni.showModal({
+								title: '提示',
+								content: '提现申请成功,等待平台审核打款',
+								showCancel: false,
+								success: (res) => {
+									uni.$emit('payMoney');
+									uni.navigateBack();
+								}
+							});
+						}
+					});
 				}
 			});
 		}
@@ -112,12 +147,13 @@ export default {
 	}
 }
 .lit {
-	padding: 15px 0px 10px 0px;
+	padding: 15px 0px 15px 0px;
 	border-bottom: 1px solid $line;
 	.tb {
-		padding-right: 5px;
+		padding-right: 6px;
 		font-size: 25px;
 		float: left;
+		margin-top: -3px;
 	}
 	.desc {
 		font-size: 13px;
@@ -127,11 +163,12 @@ export default {
 	.check {
 		float: right;
 		color: $main-color;
-		margin-top: -18px;
+		margin-top: -22px;
+		font-size: 20px;
 	}
 	&:last-child {
 		border: 0px;
-		padding-bottom: 0px;
+		padding-bottom: 5px;
 	}
 }
 </style>

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

@@ -1,9 +1,12 @@
 package com.ruoyi.web.work.api;
 
+import com.ruoyi.common.constant.CacheConstants;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.page.TableDataInfo;
+import com.ruoyi.common.core.redis.RedisCache;
 import com.ruoyi.web.work.api.config.BaseController;
 import com.ruoyi.web.work.domain.Pay;
+import com.ruoyi.web.work.domain.Platform;
 import com.ruoyi.web.work.domain.dto.PayCashOutDto;
 import com.ruoyi.web.work.service.IPayService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -25,6 +28,9 @@ public class Api_PayController extends BaseController {
     @Autowired
     private IPayService payService;
 
+    @Autowired
+    private RedisCache redisCache;
+
     @GetMapping("/list")
     public TableDataInfo list(Pay pay) {
         pay.setUserId(getUser().getId());
@@ -32,10 +38,18 @@ public class Api_PayController extends BaseController {
         List<Pay> list = payService.selectList(pay);
         return getDataTable(list);
     }
+
+    @GetMapping("/getPlatform")
+    public AjaxResult getPlatform() {
+        Platform platform = redisCache.getCacheObject(CacheConstants.APP_PLATFORM);
+        return AjaxResult.success(platform);
+    }
+
     @PostMapping("/cashOut")
     public AjaxResult cashOut(@Validated @RequestBody PayCashOutDto dto) throws ServerException {
         return payService.cashOut(dto);
     }
+
     @GetMapping(value = "/detail/{id}")
     public AjaxResult detail(@PathVariable("id") Long id) {
         return AjaxResult.success(payService.getById(id));

+ 10 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/work/domain/Pay.java

@@ -66,4 +66,14 @@ public class Pay extends BaseData {
     @TableField(fill = FieldFill.UPDATE)
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private Date updateTime;
+
+    @ApiModelProperty(value = "服务费")
+    private BigDecimal serviceMoney;
+
+    @ApiModelProperty(value = "费率")
+    private BigDecimal rate;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "完成时间")
+    private Date completeTime;
 }

+ 13 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/work/domain/Platform.java

@@ -8,6 +8,7 @@ import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.experimental.Accessors;
 
+import java.math.BigDecimal;
 import java.util.Date;
 /**
  * @author lsw
@@ -42,12 +43,24 @@ public class Platform{
     @ApiModelProperty(value = "平台邮箱")
     private String email;
 
+    @ApiModelProperty(value = "兼职服务费率")
+    private BigDecimal partTimeService;
+
+    @ApiModelProperty(value = "提现服务费率")
+    private BigDecimal cashOutService;
+
+    @ApiModelProperty(value = "多少钱起才能提现")
+    private BigDecimal cashOutMoney;
+
     @ApiModelProperty(value = "用户协议")
     private String agreement;
 
     @ApiModelProperty(value = "隐私政策")
     private String privacy;
 
+    @ApiModelProperty(value = "兼职须知")
+    private String guide;
+
     @TableField(fill = FieldFill.INSERT)
     private String createBy;
 

+ 7 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/work/domain/Position.java

@@ -10,6 +10,7 @@ import lombok.Data;
 import lombok.experimental.Accessors;
 
 import javax.validation.constraints.*;
+import java.math.BigDecimal;
 import java.util.Date;
 
 /**
@@ -61,6 +62,12 @@ public class Position extends BaseData {
     @ApiModelProperty(value = "薪资范围")
     private String salary;
 
+    @ApiModelProperty(value = "兼职服务费")
+    private BigDecimal serviceMoney;
+
+    @ApiModelProperty(value = "费率")
+    private BigDecimal rate;
+
     @ApiModelProperty(value = "最小薪资")
     private Integer min;
 

+ 8 - 2
ruoyi-admin/src/main/java/com/ruoyi/web/work/domain/dto/PayCashOutDto.java

@@ -13,8 +13,14 @@ public class PayCashOutDto {
     @DecimalMin(value = "0.01", message = "提现金额必须大于0")
     private BigDecimal money;
 
+    @NotNull(message = "实际到账金额不能为空")
+    private BigDecimal realMoney;
+
+    @NotNull(message = "服务费不能为空")
+    private BigDecimal serviceMoney;
+
     @NotNull(message = "提现方式不能为空")
-    @Min(value = 0, message = "参数错误")
-    @Max(value = 1, message = "参数错误")
+    @Min(value = 0, message = "提现方式错误")
+    @Max(value = 1, message = "提现方式错误")
     private Integer way;
 }

+ 5 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/work/domain/dto/PositionDto.java

@@ -9,6 +9,7 @@ import javax.validation.constraints.Max;
 import javax.validation.constraints.Min;
 import javax.validation.constraints.NotBlank;
 import javax.validation.constraints.NotNull;
+import java.math.BigDecimal;
 import java.util.Date;
 
 /**
@@ -91,4 +92,8 @@ public class PositionDto {
     @ApiModelProperty(value = "结束时间")
     private Date endDate;
 
+    private BigDecimal realMoney;
+
+    private BigDecimal serviceMoney;
+
 }

+ 27 - 3
ruoyi-admin/src/main/java/com/ruoyi/web/work/service/impl/PayServiceImpl.java

@@ -4,11 +4,14 @@ import cn.hutool.http.HttpUtil;
 import cn.hutool.json.JSONObject;
 import cn.hutool.json.JSONUtil;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.common.constant.CacheConstants;
 import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.redis.RedisCache;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.web.work.api.util.AppUtil;
 import com.ruoyi.web.work.domain.Pay;
+import com.ruoyi.web.work.domain.Platform;
 import com.ruoyi.web.work.domain.User;
 import com.ruoyi.web.work.domain.dto.PayAuditDto;
 import com.ruoyi.web.work.domain.dto.PayCashOutDto;
@@ -20,7 +23,10 @@ import org.springframework.core.env.Environment;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.rmi.ServerException;
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -36,6 +42,9 @@ public class PayServiceImpl extends ServiceImpl<PayMapper, Pay> implements IPayS
     IUserService userService;
 
     @Autowired
+    private RedisCache redisCache;
+
+    @Autowired
     private Environment env;
 
     @Override
@@ -48,21 +57,35 @@ public class PayServiceImpl extends ServiceImpl<PayMapper, Pay> implements IPayS
         return payMapper.selectByNums(nums);
     }
 
+    @Transactional
     @Override
     public AjaxResult cashOut(PayCashOutDto dto) throws ServerException {
+        Platform platform = redisCache.getCacheObject(CacheConstants.APP_PLATFORM);
         User user = userService.getById(AppUtil.getUser().getId());
+        if (dto.getWay() == 0 && StringUtils.isEmpty(user.getBankAccount())) {
+            return AjaxResult.error("银行卡信息未完善,无法提现");
+        }
+        if (dto.getMoney().compareTo(platform.getCashOutMoney()) < 0) {
+            return AjaxResult.error("最少提现金额:" + platform.getCashOutMoney() + "起");
+        }
         if (dto.getMoney().compareTo(user.getMoney()) > 0) {
             return AjaxResult.error("提现金额超过账户余额");
         }
-        if (dto.getWay() == 0 && StringUtils.isEmpty(user.getBankAccount())) {
-            return AjaxResult.error("银行卡信息未完善,无法提现");
+        //服务费
+        BigDecimal serviceMoney = platform.getCashOutService().divide(new BigDecimal("100")).multiply(dto.getMoney()).setScale(2, RoundingMode.HALF_UP);
+        //实际到账
+        BigDecimal realMoney = dto.getMoney().subtract(serviceMoney).setScale(2, RoundingMode.HALF_UP);
+        if (!serviceMoney.equals(dto.getServiceMoney()) || !realMoney.equals(dto.getRealMoney())) {
+            return AjaxResult.error("提现金额异常");
         }
         //保存提现记录
         Pay pay = new Pay();
         pay.setUserId(AppUtil.getUser().getId());
-        pay.setMoney(dto.getMoney());
+        pay.setMoney(dto.getRealMoney());
         pay.setState(0);
         pay.setType(2);
+        pay.setServiceMoney(serviceMoney);
+        pay.setRate(platform.getCashOutService());
         pay.setWay(dto.getWay());
         pay.setTitle("余额提现");
         pay.setVersion(System.currentTimeMillis());
@@ -90,6 +113,7 @@ public class PayServiceImpl extends ServiceImpl<PayMapper, Pay> implements IPayS
         }
         pay.setState(dto.getState());
         pay.setMsg(dto.getMsg());
+        pay.setCompleteTime(new Date());
         if (!updateById(pay)) {
             throw new ServerException("提现失败,请联系平台");
         }

+ 38 - 9
ruoyi-admin/src/main/java/com/ruoyi/web/work/service/impl/PositionServiceImpl.java

@@ -1,7 +1,9 @@
 package com.ruoyi.web.work.service.impl;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.common.constant.CacheConstants;
 import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.redis.RedisCache;
 import com.ruoyi.common.exception.ServiceException;
 import com.ruoyi.common.utils.PageUtils;
 import com.ruoyi.common.utils.StringUtils;
@@ -19,6 +21,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.List;
 
 /**
@@ -45,6 +48,9 @@ public class PositionServiceImpl extends ServiceImpl<PositionMapper, Position> i
     @Autowired
     private IResumeDeliverService resumeDeliverService;
 
+    @Autowired
+    private RedisCache redisCache;
+
     @Override
     public List<Position> selectList(Position position) {
         return positionMapper.selectList(position);
@@ -93,10 +99,13 @@ public class PositionServiceImpl extends ServiceImpl<PositionMapper, Position> i
     @Transactional
     @Override
     public AjaxResult manageAdd(PositionDto dto) {
+        Platform platform = redisCache.getCacheObject(CacheConstants.APP_PLATFORM);
         if (AppUtil.getUser().getIsAuthentication() != 1) {
             return AjaxResult.error(7878, "发布全职或兼职需要实名认证");
         }
         User user = userService.getById(AppUtil.getUser().getId());
+        Position position = new Position();
+        BeanUtils.copyProperties(dto, position);
         //全职
         if (dto.getType() == 0) {
             if (user.getType() != 1) {
@@ -108,18 +117,36 @@ public class PositionServiceImpl extends ServiceImpl<PositionMapper, Position> i
         }
         //兼职
         if (dto.getType() == 1) {
-            if (new BigDecimal(dto.getSalary()).compareTo(BigDecimal.ZERO) <= 0) {
+            Object salaryObj = new BigDecimal(dto.getSalary());
+            if (!(salaryObj instanceof BigDecimal)) {
+                return AjaxResult.error("兼职金额不是一个有效类型");
+            }
+            BigDecimal salary = (BigDecimal) salaryObj;
+            if (salary.compareTo(BigDecimal.ZERO) <= 0) {
                 return AjaxResult.error("兼职金额必须大于0");
             }
-            if (new BigDecimal(dto.getSalary()).compareTo(user.getMoney()) > 0) {
+            if (salary.stripTrailingZeros().scale() > 2) {
+                return AjaxResult.error("兼职金额最多只能有两位小数");
+            }
+            //计算服务费
+            BigDecimal serviceMoney = platform.getPartTimeService().divide(new BigDecimal("100")).multiply(salary).setScale(2, RoundingMode.HALF_UP);
+            //计算总费用
+            BigDecimal totalMoney = serviceMoney.add(salary).setScale(2, RoundingMode.HALF_UP);
+            if (totalMoney.compareTo(user.getMoney()) > 0) {
                 return AjaxResult.error(8080, "余额不足请先充值");
             }
+            if (!serviceMoney.equals(dto.getServiceMoney()) || !totalMoney.equals(dto.getRealMoney())) {
+                return AjaxResult.error("扣除金额异常");
+            }
+            position.setRate(platform.getPartTimeService());
+            position.setServiceMoney(serviceMoney);
         }
-        Position position = new Position();
-        BeanUtils.copyProperties(dto, position);
-        Column region = columnService.selectRegion(new Column().setTitle(position.getRegionName()).setLevel(3));
-        if (region != null) {
-            position.setAncestors(region.getAncestors() + "," + region.getId());
+        //根据地区名称找到对应的Ancestors
+        if (StringUtils.isNotEmpty(position.getRegionName())) {
+            Column region = columnService.selectRegion(new Column().setTitle(position.getRegionName()).setLevel(3));
+            if (region != null) {
+                position.setAncestors(region.getAncestors() + "," + region.getId());
+            }
         }
         //全职薪资
         if (!position.getSalary().equals("面议") && position.getType() == 0) {
@@ -137,14 +164,16 @@ public class PositionServiceImpl extends ServiceImpl<PositionMapper, Position> i
         //发布兼职更新账户和保存支出记录
         if (dto.getType() == 1) {
             //更新用户账户余额
-            user.setMoney(user.getMoney().subtract(new BigDecimal(dto.getSalary())));
+            user.setMoney(user.getMoney().subtract(dto.getRealMoney()));
             if (!userService.updateById(user)) {
                 throw new ServiceException("更新账户余额失败,请联系平台");
             }
             //添加支出记录
             Pay pay = new Pay();
             pay.setUserId(user.getId());
-            pay.setMoney(new BigDecimal(dto.getSalary()));
+            pay.setMoney(dto.getRealMoney());
+            pay.setServiceMoney(dto.getServiceMoney());
+            pay.setRate(platform.getCashOutService());
             pay.setState(1);
             pay.setType(1);
             pay.setTitle(position.getTitle());