Browse Source

task_order

master
陈裕财 4 years ago
parent
commit
384252bee3
  1. 4
      xm-core/src/main/java/com/xm/core/ctrl/XmTaskOrderController.java
  2. 11
      xm-core/src/main/java/com/xm/core/entity/XmTaskOrder.java
  3. 147
      xm-core/src/main/java/com/xm/core/service/XmTaskOrderService.java
  4. 28
      xm-core/src/main/resources/mybatis/mapper/xm/core/dao/XmTaskOrderMapper.xml

4
xm-core/src/main/java/com/xm/core/ctrl/XmTaskOrderController.java

@ -118,8 +118,8 @@ public class XmTaskOrderController {
BeanUtils.copyProperties(xmTaskDb,order);
order.setId(this.xmTaskOrderService.createKey("id"));
order.setTaskId(xmTaskDb.getId());
order.setUserid(user.getUserid());
order.setBranchId(user.getBranchId());
order.setOuserid(user.getUserid());
order.setObranchId(user.getBranchId());
BigDecimal originFee=BigDecimal.ZERO;
if("1".equals(xmTaskDb.getEstate())){
order.setEfunds(xmTaskDb.getBudgetAt());

11
xm-core/src/main/java/com/xm/core/entity/XmTaskOrder.java

@ -9,7 +9,7 @@ import java.math.BigDecimal;
/**
* 组织 com 顶级模块 xm 大模块 core 小模块 <br>
* 实体 XmTaskOrder所有属性名: <br>
* "userid","用户编号","branchId","公司ID-下单客户对应的企业","ostatus","订单状态0-初始,1-待确认,2-待付款,3-已付款,4-已完成,5-已取消-未付款前可取消,取消后可删除,6-退单-退单后变为已取消,8已关闭-售后完成后可以关闭订单","ctime","创建时间","ltime","更新时间","payType","支付方式","payStatus","支付状态0待付款,1已付款","payTime","支付时间","prepayId","第三方支付订单编号","id","订单编号","finalFee","最终总费用=origin_fee","othFee","其它费用","originFee","原始价格=top_fee+urgent_fee+crm_sup_fee+hot_fee+efunds+share_fee","payAt","最终付款金额-客户付款后回填","payAuthId","支付授权码","payOpenid","支付账户对应的第三方openid,注意,下单根付款不一定是同一个人","payUserid","付款用户编号","payUsername","付款用户名称","discount","折扣率0-199","topFee","置顶费用","topStime","置顶开始时间","topEtime","置顶结束时间","hotFee","热搜费用","hotStime","热搜开始时间","hotEtime","热搜结束时间","top","是否置顶0否1待付款2已开通3已过期","hot","是否热搜0否1待付款2已开通3已过期","crmSupFee","客服包办费用","urgentFee","加急费用","urgent","是否加急0否1待付款2已开通3已过期","crmSup","是否客服包办0否1待付款2已开通3已过期","efunds","托管金额","estate","资金托管状况0-无须托管,1-待付款,2-已托管资金,3-已付款给服务商,4-已退款","etoPlatTime","托管资金付款给平台的时间","etoDevTime","托管资金支付给服务商的时间","ebackTime","托管资金退回甲方时间","taskId","任务编号","topDays","置顶天数","hotDays","热搜天数","urgentDays","加急天数","urgentStime","加急开始时间","urgentEtime","加急结束时间","calcStatus","定时检查日期是否已过期,已过期则取消任务中的置顶、加急、热搜状态计算状态0-无须计算,1-本周期已计算待下周期计算,2-结束","calcTime","计算时间","oshare","是否开启分享赚0否1待付款2已开通3已过期","shareFee","分享赚佣金","payId","付款流水号(内部生成,传给第三方原样传回,如果不正确,不允许更新数据库,防止作弊)";<br>
* "ouserid","下单用户编号","obranchId","公司ID-下单客户对应的企业","ostatus","订单状态0-初始,1-待确认,2-待付款,3-已付款,4-已完成,5-已取消-未付款前可取消,取消后可删除,6-退单-退单后变为已取消,8已关闭-售后完成后可以关闭订单","ctime","创建时间","ltime","更新时间","payType","支付方式","payStatus","支付状态0待付款,1已付款","payTime","支付时间","prepayId","第三方支付订单编号","id","订单编号","finalFee","最终总费用=origin_fee","othFee","其它费用","originFee","原始价格=top_fee+urgent_fee+crm_sup_fee+hot_fee+efunds+share_fee","payAt","最终付款金额-客户付款后回填","payAuthId","支付授权码","payOpenid","支付账户对应的第三方openid,注意,下单根付款不一定是同一个人","payUserid","付款用户编号","payUsername","付款用户名称","discount","折扣率0-199","topFee","置顶费用","topStime","置顶开始时间","topEtime","置顶结束时间","hotFee","热搜费用","hotStime","热搜开始时间","hotEtime","热搜结束时间","top","是否置顶0否1待付款2已开通3已过期","hot","是否热搜0否1待付款2已开通3已过期","crmSupFee","客服包办费用","urgentFee","加急费用","urgent","是否加急0否1待付款2已开通3已过期","crmSup","是否客服包办0否1待付款2已开通3已过期","efunds","托管金额","estate","资金托管状况0-无须托管,1-待付款,2-已托管资金,3-已付款给服务商,4-已退款","etoPlatTime","托管资金付款给平台的时间","etoDevTime","托管资金支付给服务商的时间","ebackTime","托管资金退回甲方时间","taskId","任务编号","topDays","置顶天数","hotDays","热搜天数","urgentDays","加急天数","urgentStime","加急开始时间","urgentEtime","加急结束时间","calcStatus","定时检查日期是否已过期,已过期则取消任务中的置顶、加急、热搜状态计算状态0-无须计算,1-本周期已计算待下周期计算,2-结束","calcTime","计算时间","oshare","是否开启分享赚0否1待付款2已开通3已过期","shareFee","分享赚佣金","payId","付款流水号(内部生成,传给第三方原样传回,如果不正确,不允许更新数据库,防止作弊)","tranId","第三方付款事务号";<br>
* 当前主键(包括多主键):<br>
* id;<br>
*/
@ -23,11 +23,11 @@ public class XmTaskOrder implements java.io.Serializable {
String id;
@ApiModelProperty(notes="用户编号",allowEmptyValue=true,example="",allowableValues="")
String userid;
@ApiModelProperty(notes="下单用户编号",allowEmptyValue=true,example="",allowableValues="")
String ouserid;
@ApiModelProperty(notes="公司ID-下单客户对应的企业",allowEmptyValue=true,example="",allowableValues="")
String branchId;
String obranchId;
@ApiModelProperty(notes="订单状态0-初始,1-待确认,2-待付款,3-已付款,4-已完成,5-已取消-未付款前可取消,取消后可删除,6-退单-退单后变为已取消,8已关闭-售后完成后可以关闭订单",allowEmptyValue=true,example="",allowableValues="")
String ostatus;
@ -161,6 +161,9 @@ public class XmTaskOrder implements java.io.Serializable {
@ApiModelProperty(notes="付款流水号(内部生成,传给第三方原样传回,如果不正确,不允许更新数据库,防止作弊)",allowEmptyValue=true,example="",allowableValues="")
String payId;
@ApiModelProperty(notes="第三方付款事务号",allowEmptyValue=true,example="",allowableValues="")
String tranId;
/**
*订单编号
**/

147
xm-core/src/main/java/com/xm/core/service/XmTaskOrderService.java

@ -2,21 +2,15 @@ package com.xm.core.service;
import com.mdp.core.err.BizException;
import com.mdp.core.service.BaseService;
import com.mdp.core.utils.DateUtils;
import com.xm.core.entity.XmTaskOrder;
import org.apache.poi.ss.usermodel.DateUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* 父类已经支持增删改查操作,因此,即使本类什么也不写,也已经可以满足一般的增删改查操作了.<br>
@ -32,153 +26,28 @@ public class XmTaskOrderService extends BaseService {
public void orderPaySuccess(String orderId, String payId, String prepayId, String tranId, BigDecimal payAt, String remarks) {
//更新订单状态
if(!StringUtils.hasText(payId)){
throw new BizException("payId-0","参数不正确,payId不能为空");
if (!StringUtils.hasText(payId)) {
throw new BizException("payId-0", "参数不正确,payId不能为空");
}
XmTaskOrder moOrder = this.selectOneById(orderId);
if(!payId.equals(moOrder.getPayId())) {
if (!payId.equals(moOrder.getPayId())) {
throw new BizException("payId-err", "参数不正确,payId与实际不匹配");
}
if("1".equals(moOrder.getSstatus())) {
throw new BizException("该订单已经结算");
}
if(!"2".equals(moOrder.getStatus())) {
if (!"2".equals(moOrder.getOstatus())) {
throw new BizException("该订单状态出错");
}
// if(payAt.compareTo(moOrder.getOfinalFee()) != 0) {
// throw new BizException("该订单支付金额与实际金额不符");
// }
//设置第三方付款号
moOrder.setTranId(tranId);
moOrder.setPayAt(payAt);
//设置结算状态为已结算
moOrder.setSstatus("1");
moOrder.setPayStatus("1");
//设置状态为已付款
moOrder.setStatus("3");
moOrder.setOstatus("3");
//设置付款确认时间
moOrder.setPayCtime(new Date());
//设置结算时间
moOrder.setSetTime(new Date());
//开通模块
//获取订单模块
MoOrderModule params = new MoOrderModule();
params.setOrderId(orderId);
List<MoOrderModule> orderModules = moOrderModuleService.selectListByWhere(params);
List<MenuModuleBranch> menuModuleBranches = new ArrayList<>();
for (MoOrderModule orderModule : orderModules) {
MenuModuleBranch menuModuleBranch = new MenuModuleBranch();
BeanUtils.copyProperties(orderModule,menuModuleBranch);
menuModuleBranch.setBranchId(moOrder.getObranchId());
menuModuleBranch.setModuleId(orderModule.getModuleId());
menuModuleBranch.setModuleName(orderModule.getName());
//模块启用
menuModuleBranch.setStatus("1");
menuModuleBranch.setMusers(orderModule.getMusers());
menuModuleBranch.setStartTime(new Date());
menuModuleBranch.setEndTime(DateUtil.offsetDay(menuModuleBranch.getStartTime(),orderModule.getDays()));
menuModuleBranch.setCtime(new Date());
menuModuleBranch.setLtime(new Date());
menuModuleBranch.setFeeDate(new Date());
menuModuleBranch.setVer("1");
menuModuleBranches.add(menuModuleBranch);
}
moOrder.setStartTime(new Date());
moOrder.setEndTime(DateUtil.offsetDay(moOrder.getStartTime(),moOrder.getOdays()));
if(moOrder.getPayTime()==null){
moOrder.setPayTime(new Date());
}
//保存订单信息
this.updateSomeFieldByPk(moOrder);
List<MenuModuleBranch> adds=new ArrayList<>();
List<MenuModuleBranch> updates=new ArrayList<>();
List<MenuModuleBranch> menuModuleBranchListDb = menuModuleBranchService.selectListByIds(menuModuleBranches.stream().map(i->map("branchId",i.getBranchId(),"moduleId",i.getModuleId())).collect(Collectors.toList()));
if(menuModuleBranchListDb==null || menuModuleBranchListDb.size()<=0){
adds=menuModuleBranches;
}else{
if("3".equals(moOrder.getOoper())){
for (MenuModuleBranch edit : menuModuleBranches) {
Optional<MenuModuleBranch> moduleBranchDb=menuModuleBranchListDb.stream().filter(i->i.getBranchId().equals(edit.getBranchId()) && i.getModuleId().equals(edit.getModuleId())).findAny();
if(moduleBranchDb.isPresent()){
MenuModuleBranch mdb=moduleBranchDb.get();
mdb.setOusers(mdb.getOusers()+edit.getOusers());
mdb.setMusers(mdb.getMusers()+edit.getMusers());
updates.add(mdb);
}else {
adds.add(edit);
}
}
}else {
for (MenuModuleBranch edit : menuModuleBranches) {
Optional<MenuModuleBranch> moduleBranchDb=menuModuleBranchListDb.stream().filter(i->i.getBranchId().equals(edit.getBranchId()) && i.getModuleId().equals(edit.getModuleId())).findAny();
if(moduleBranchDb.isPresent()){
MenuModuleBranch mdb=moduleBranchDb.get();
if("2".equals(moOrder.getOoper())){
edit.setEndTime(DateUtil.offsetDay(mdb.getEndTime(),moOrder.getOdays()));
}
if(mdb.getStartTime()==null){
edit.setStartTime(new Date());
}else {
edit.setStartTime(mdb.getStartTime());
}
if(mdb.getCtime()==null){
edit.setCtime(new Date());
}else {
edit.setCtime(mdb.getCtime());
}
edit.setLtime(new Date());
updates.add(edit);
}else{
adds.add(edit);
}
}
}
}
if(updates.size()>0){
menuModuleBranchService.batchUpdate(updates);
}
if(adds.size()>0){
menuModuleBranchService.batchInsert(adds);
}
BranchInterests branchInterests= branchInterestsService.selectOneById(moOrder.getObranchId());
if(branchInterests==null){
branchInterests=this.branchInterestsService.getDefaultBranchInterests(moOrder.getObranchId());
branchInterests.setMaxUsers(moOrder.getOusers());
branchInterests.setMver("1");
branchInterests.setMaxRtime(DateUtils.format(moOrder.getEndTime(),"yyyy-MM-dd"));
branchInterestsService.insert(branchInterests);
}else {
if("3".equals(moOrder.getOoper())){
BranchInterests branchInterestsUpdate=new BranchInterests();
branchInterestsUpdate.setMaxUsers(branchInterests.getMaxUsers()+moOrder.getOusers());
branchInterestsUpdate.setBranchId(moOrder.getObranchId());
branchInterestsUpdate.setLtime(new Date());
branchInterestsService.updateSomeFieldByPk(branchInterestsUpdate);
}else {
BranchInterests branchInterestsUpdate=new BranchInterests();
if(branchInterests.getMaxUsers()< moOrder.getOusers()) {
branchInterestsUpdate.setMaxUsers(moOrder.getOusers());
}
branchInterestsUpdate.setBranchId(moOrder.getObranchId());
branchInterestsUpdate.setMver("1");
branchInterestsUpdate.setLtime(new Date());
branchInterests.setMaxRtime(DateUtils.format(moOrder.getEndTime(),"yyyy-MM-dd"));
branchInterestsService.updateSomeFieldByPk(branchInterestsUpdate);
}
}
moOrder.setPayTime(new Date());
}
}

28
xm-core/src/main/resources/mybatis/mapper/xm/core/dao/XmTaskOrderMapper.xml

@ -67,7 +67,7 @@
insert into xm_task_order(
<include refid="columns"/>
) values (
#{userid},#{branchId},#{ostatus},#{ctime},#{ltime},#{payType},#{payStatus},#{payTime},#{prepayId},#{id},#{finalFee},#{othFee},#{originFee},#{payAt},#{payAuthId},#{payOpenid},#{payUserid},#{payUsername},#{discount},#{topFee},#{topStime},#{topEtime},#{hotFee},#{hotStime},#{hotEtime},#{top},#{hot},#{crmSupFee},#{urgentFee},#{urgent},#{crmSup},#{efunds},#{estate},#{etoPlatTime},#{etoDevTime},#{ebackTime},#{taskId},#{topDays},#{hotDays},#{urgentDays},#{urgentStime},#{urgentEtime},#{calcStatus},#{calcTime},#{oshare},#{shareFee},#{payId}
#{ouserid},#{obranchId},#{ostatus},#{ctime},#{ltime},#{payType},#{payStatus},#{payTime},#{prepayId},#{id},#{finalFee},#{othFee},#{originFee},#{payAt},#{payAuthId},#{payOpenid},#{payUserid},#{payUsername},#{discount},#{topFee},#{topStime},#{topEtime},#{hotFee},#{hotStime},#{hotEtime},#{top},#{hot},#{crmSupFee},#{urgentFee},#{urgent},#{crmSup},#{efunds},#{estate},#{etoPlatTime},#{etoDevTime},#{ebackTime},#{taskId},#{topDays},#{hotDays},#{urgentDays},#{urgentStime},#{urgentEtime},#{calcStatus},#{calcTime},#{oshare},#{shareFee},#{payId},#{tranId}
)
</insert>
@ -142,13 +142,13 @@
<!--sql片段 列-->
<sql id="columns">
userid,branch_id,ostatus,ctime,ltime,pay_type,pay_status,pay_time,prepay_id,id,final_fee,oth_fee,origin_fee,pay_at,pay_auth_id,pay_openid,pay_userid,pay_username,discount,top_fee,top_stime,top_etime,hot_fee,hot_stime,hot_etime,top,hot,crm_sup_fee,urgent_fee,urgent,crm_sup,efunds,estate,eto_plat_time,eto_dev_time,eback_time,task_id,top_days,hot_days,urgent_days,urgent_stime,urgent_etime,calc_status,calc_time,oshare,share_fee,pay_id
ouserid,obranch_id,ostatus,ctime,ltime,pay_type,pay_status,pay_time,prepay_id,id,final_fee,oth_fee,origin_fee,pay_at,pay_auth_id,pay_openid,pay_userid,pay_username,discount,top_fee,top_stime,top_etime,hot_fee,hot_stime,hot_etime,top,hot,crm_sup_fee,urgent_fee,urgent,crm_sup,efunds,estate,eto_plat_time,eto_dev_time,eback_time,task_id,top_days,hot_days,urgent_days,urgent_stime,urgent_etime,calc_status,calc_time,oshare,share_fee,pay_id,tran_id
</sql>
<!--sql片段 动态条件 YYYY-MM-DD HH24:MI:SS-->
<sql id="where">
<if test="userid != null and userid != ''"> and res.userid = #{userid} </if>
<if test="branchId != null and branchId != ''"> and res.branch_id = #{branchId} </if>
<if test="ouserid != null and ouserid != ''"> and res.ouserid = #{ouserid} </if>
<if test="obranchId != null and obranchId != ''"> and res.obranch_id = #{obranchId} </if>
<if test="ostatus != null and ostatus != ''"> and res.ostatus = #{ostatus} </if>
<if test="ctime != null"> and date_format(res.ctime,'%Y-%m-%d') = date_format(#{ctime},'%Y-%m-%d') </if>
<if test="ltime != null"> and date_format(res.ltime,'%Y-%m-%d') = date_format(#{ltime},'%Y-%m-%d') </if>
@ -194,11 +194,12 @@
<if test="oshare != null and oshare != ''"> and res.oshare = #{oshare} </if>
<if test="shareFee != null and shareFee != ''"> and res.share_fee = #{shareFee} </if>
<if test="payId != null and payId != ''"> and res.pay_id = #{payId} </if>
<if test="tranId != null and tranId != ''"> and res.tran_id = #{tranId} </if>
</sql>
<!--sql片段 更新字段 -->
<sql id="set">
userid = #{userid},
branch_id = #{branchId},
ouserid = #{ouserid},
obranch_id = #{obranchId},
ostatus = #{ostatus},
ctime = #{ctime},
ltime = #{ltime},
@ -242,11 +243,12 @@
calc_time = #{calcTime},
oshare = #{oshare},
share_fee = #{shareFee},
pay_id = #{payId}
pay_id = #{payId},
tran_id = #{tranId}
</sql>
<sql id="someFieldSet">
<if test="userid != null and userid != ''"> userid = #{userid}, </if>
<if test="branchId != null and branchId != ''"> branch_id = #{branchId}, </if>
<if test="ouserid != null and ouserid != ''"> ouserid = #{ouserid}, </if>
<if test="obranchId != null and obranchId != ''"> obranch_id = #{obranchId}, </if>
<if test="ostatus != null and ostatus != ''"> ostatus = #{ostatus}, </if>
<if test="ctime != null"> ctime = #{ctime}, </if>
<if test="ltime != null"> ltime = #{ltime}, </if>
@ -291,11 +293,12 @@
<if test="oshare != null and oshare != ''"> oshare = #{oshare}, </if>
<if test="shareFee != null and shareFee != ''"> share_fee = #{shareFee}, </if>
<if test="payId != null and payId != ''"> pay_id = #{payId}, </if>
<if test="tranId != null and tranId != ''"> tran_id = #{tranId}, </if>
</sql>
<!--sql片段 批量更新 -->
<sql id="batchSet">
userid = #{item.userid},
branch_id = #{item.branchId},
ouserid = #{item.ouserid},
obranch_id = #{item.obranchId},
ostatus = #{item.ostatus},
ctime = #{item.ctime},
ltime = #{item.ltime},
@ -339,6 +342,7 @@
calc_time = #{item.calcTime},
oshare = #{item.oshare},
share_fee = #{item.shareFee},
pay_id = #{item.payId}
pay_id = #{item.payId},
tran_id = #{item.tranId}
</sql>
</mapper>
Loading…
Cancel
Save