修改商城购买联合支付

This commit is contained in:
yangjun 2024-07-18 17:13:45 +08:00
parent d5044e1b76
commit e562a74eb2
14 changed files with 186 additions and 20 deletions

View File

@ -15,4 +15,6 @@ public interface UserMoneyDao extends BaseMapper<UserMoney> {
void updateCashDeposit(@Param("type") Integer type, @Param("userId") Long userId,@Param("cashDeposit") Double cashDeposit);
void updateMoney(UserMoney userMoney);
void updateMaySad(@Param("type") Integer type, @Param("userId") Long userId, @Param("money") Double money);
}

View File

@ -45,4 +45,8 @@ public class UserMoney implements Serializable {
@TableField("user_id")
private Long userId;
@ApiModelProperty("盛安豆")
@TableField("sad")
private BigDecimal sad;
}

View File

@ -28,4 +28,5 @@ public interface UserMoneyService extends IService<UserMoney> {
Result profitDetailed(@RequestAttribute Long userId, Page ipage, String startTime,String endTime);
void updateSad(int i, Long userId, double payMoney);
}

View File

@ -173,4 +173,9 @@ public class UserMoneyServiceImpl extends ServiceImpl<UserMoneyDao, UserMoney> i
return Result.success().put("data", page2);
}
@Override
public void updateSad(int i, Long userId, double payMoney) {
baseMapper.updateMaySad(i, userId, payMoney);
}
}

View File

@ -4,6 +4,7 @@ import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.sqx.modules.app.entity.UserMoneyDetails;
import com.sqx.modules.app.entity.UserSadDetails;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
@ -29,6 +30,10 @@ public class FundDetailsResult implements Serializable {
* 钱包明细
*/
private IPage<UserMoneyDetails> userMoneyDetailsList;
/**
* 钱包明细
*/
private IPage<UserSadDetails> userSadDetailsList;
/**
* 查询开始时间
*/

View File

@ -491,6 +491,7 @@ public class ArtificerServiceImpl extends ServiceImpl<ArtificerDao, Artificer> i
result.put("monthMoney",monthMoney);
result.put("cashMoney",cashMoney);
result.put("money",userMoney.getMoney());
result.put("mysad",userMoney.getSad());//盛安豆
return Result.success().put("data",result);
}

View File

@ -94,6 +94,13 @@ public class AppOrdersController {
return service.changePay(ordersId);
}
@Login
@ApiOperation("盛安豆支付")
@GetMapping("/changeSadPay")
public Result changeSadPay(String ordersId){
return service.changeSadPay(ordersId);
}
@ApiOperation("检测是否完成支付")
@GetMapping("/wxPay")
public Result wxPayWeb(Long ordersId){

View File

@ -73,5 +73,9 @@ public class SelfGoods implements Serializable {
@Transient
private SelfGoodsBrand brand; //品牌实体
@Column
private Long sad; //购买获得盛安豆
}

View File

@ -112,6 +112,8 @@ public class SelfOrders {
private Long userCouponsId; //用户优惠券id
@Column
private Double couponMoney; //优惠券优惠金额
@Column
private Long sfrxdh; //是否允许兑换
/**分销*/
@Transient
private List<SelfOrderRelation> relationList; //订单分销列表

View File

@ -85,4 +85,5 @@ public interface OrdersService {
//查快递
Result findExpress(String expressNumber);
Result changeSadPay(String ordersId);
}

View File

@ -2,6 +2,7 @@ package com.sqx.modules.shopping.service.impl;
import com.sqx.modules.app.entity.UserMoney;
import com.sqx.modules.app.entity.UserMoneyDetails;
import com.sqx.modules.app.entity.UserSadDetails;
import com.sqx.modules.app.service.UserMoneyDetailsService;
import com.sqx.modules.app.service.UserMoneyService;
import com.sqx.modules.app.service.UserService;
@ -155,7 +156,7 @@ public class OrdersRelationServiceImpl implements OrdersRelationService {
userMoneyDetails.setType(1);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
userMoneyDetails.setCreateTime(simpleDateFormat.format(new Date()));
userMoneyDetailsService.save(userMoneyDetails);
userMoneyDetailsService.insert(userMoneyDetails);
//3.修改分销记录为已到账
s.setStatus(2); //已到账
this.updateBody(s);
@ -164,6 +165,7 @@ public class OrdersRelationServiceImpl implements OrdersRelationService {
SelfOrders order = ordersJpaRepository.getOne(orderId);
order.setIsRefund(2); //不可退款
ordersJpaRepository.save(order);
}
/**

View File

@ -1,6 +1,7 @@
package com.sqx.modules.shopping.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.sqx.modules.common.service.CommonInfoService;
import com.sqx.modules.shopping.controller.SkuUtil;
import com.sqx.modules.shopping.dao.*;
import com.sqx.modules.shopping.entity.*;
@ -52,6 +53,9 @@ public class SelfGoodsServiceImpl implements GoodsService {
@Autowired
private GoodsTypeService goodsTypeService;
@Autowired
private CommonInfoService commonRepository;
/**
* 后台管理商品列表创建时间排序
* @param page 页数
@ -397,6 +401,7 @@ public class SelfGoodsServiceImpl implements GoodsService {
if (g.getBrandId() != null){
g.setBrand(selfGoodsBrandJpaRepository.findById(g.getBrandId()).orElse(null));
}
return ResultUtil.success(g);
}

View File

@ -1,14 +1,8 @@
package com.sqx.modules.shopping.service.impl;
import com.alibaba.fastjson.JSON;
import com.sqx.modules.app.entity.UserEntity;
import com.sqx.modules.app.entity.UserMoney;
import com.sqx.modules.app.entity.UserMoneyDetails;
import com.sqx.modules.app.entity.UserVip;
import com.sqx.modules.app.service.UserMoneyDetailsService;
import com.sqx.modules.app.service.UserMoneyService;
import com.sqx.modules.app.service.UserService;
import com.sqx.modules.app.service.UserVipService;
import com.sqx.modules.app.entity.*;
import com.sqx.modules.app.service.*;
import com.sqx.modules.common.service.CommonInfoService;
import com.sqx.modules.material.service.MaterialArtificerService;
import com.sqx.modules.shopping.dao.*;
@ -80,6 +74,8 @@ public class SelfOrdersServiceImpl implements OrdersService {
private UserVipService userVipService;
@Autowired
private MaterialArtificerService materialArtificerService;
@Autowired
private UserSadDetailsService userSadDetailsService;
@ -322,7 +318,7 @@ public class SelfOrdersServiceImpl implements OrdersService {
/*
* 支付金额 需要后端去验证金额
*/
UserEntity userById = userService.selectUserById(entity.getUserId());
// UserEntity userById = userService.selectUserById(entity.getUserId());
Long goodsId = entity.getGoodsId();
SelfGoods byId = goodsService.findById(goodsId);
if(byId.getStatus().equals(2)){
@ -334,19 +330,45 @@ public class SelfOrdersServiceImpl implements OrdersService {
}
skuService.lessStock(entity.getSkuId(), entity.getNumber()); //sku库存减少对应数量
entity.setPrice(byId.getPrice());
entity.setPrice(byId.getMemberPrice());
entity.setMemberPrice(byId.getMemberPrice());
UserVip userVip = userVipService.selectUserVipByUserId(userById.getUserId());
if(userVip==null || userVip.getIsVip()!=1){
Double aDouble = AmountCalUtil.moneyMul(byId.getPrice(), entity.getNumber());
entity.setPayMoney(aDouble);
}else{
Double aDouble = AmountCalUtil.moneyMul(byId.getMemberPrice(), entity.getNumber());
entity.setPayMoney(aDouble);
}
// UserVip userVip = userVipService.selectUserVipByUserId(userById.getUserId());
// if(userVip==null || userVip.getIsVip()!=1){
// Double aDouble = AmountCalUtil.moneyMul(byId.getPrice(), entity.getNumber());
// entity.setPayMoney(aDouble);
// }else{
// Double aDouble = AmountCalUtil.moneyMul(byId.getMemberPrice(), entity.getNumber());
// entity.setPayMoney(aDouble);
// }
if(entity.getSendWay()==1 && byId.getPostagePrice()!=null){
entity.setPayMoney(AmountCalUtil.add(entity.getPayMoney(),byId.getPostagePrice()));
}
if(entity.getSfrxdh()!=null && entity.getSfrxdh()>0){
UserSadDetails userMoneyDetails=new UserSadDetails();
userMoneyService.updateSad(2,entity.getUserId(),entity.getSfrxdh());
//查询用户当前余额
UserMoney userNowMoney = userMoneyService.selectUserMoneyByUserId(entity.getUserId());
//插入余额
userMoneyDetails.setBalance(userNowMoney.getSad());
//插入操作类型为已操作用户余额
userMoneyDetails.setManipulateType(2);
userMoneyDetails.setUserId(entity.getUserId());
userMoneyDetails.setTitle("[购买商品]标题:"+entity.getTitle());
userMoneyDetails.setContent("盛安豆优惠:"+entity.getSfrxdh());
userMoneyDetails.setType(2);
userMoneyDetails.setMoney(userNowMoney.getSad());
userMoneyDetails.setCreateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
userMoneyDetails.setBlRole(2);
userMoneyDetails.setBlFlag(1);
userSadDetailsService.insert(userMoneyDetails);
}
//添加盛安豆
this.addSad(entity);
return ResultUtil.success(jpaRepository.save(entity));
}
@ -552,10 +574,12 @@ public class SelfOrdersServiceImpl implements OrdersService {
//立刻到账
s.setFinishTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
ordersRelationService.addMoney(s);
}
Long userId = orders.getUserId();
//8.商品销量+1
goodsService.salesAddOne(orders.getGoodsId());
return ResultUtil.success(jpaRepository.save(orders));
}
@ -598,7 +622,7 @@ public class SelfOrdersServiceImpl implements OrdersService {
userMoneyDetails.setCreateTime(date);
userMoneyDetails.setBlRole(2);
userMoneyDetails.setBlFlag(1);
userMoneyDetailsService.save(userMoneyDetails);
userMoneyDetailsService.insert(userMoneyDetails);
//订单分销
this.fenXiao(orders);
//4.支付成功处理订单
@ -628,6 +652,36 @@ public class SelfOrdersServiceImpl implements OrdersService {
return ResultUtil.success();
}
//添加盛安豆及盛安豆记录
public void addSad(SelfOrders orders){
Long goodsId = orders.getGoodsId();
SelfGoods goodsPar = goodsService.findById(goodsId);
Double sad = 0.0;
if(goodsPar.getSad()>0){
sad = Double.parseDouble(goodsPar.getSad()+"") * orders.getNumber();
}
if(sad>0){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String date=sdf.format(new Date());
userMoneyService.updateSad(1,orders.getUserId(),sad);
UserSadDetails userMoneyDetails=new UserSadDetails();
//查询用户当前余额
UserMoney userNowMoney = userMoneyService.selectUserMoneyByUserId(orders.getUserId());
//插入余额
userMoneyDetails.setBalance(userNowMoney.getSad());
//插入操作类型为已操作用户余额
userMoneyDetails.setManipulateType(2);
userMoneyDetails.setUserId(orders.getUserId());
userMoneyDetails.setTitle("[购买商品]标题:"+orders.getTitle());
userMoneyDetails.setContent("获得盛安豆:"+sad);
userMoneyDetails.setType(1);
userMoneyDetails.setMoney(userNowMoney.getSad());
userMoneyDetails.setCreateTime(date);
userMoneyDetails.setBlRole(2);
userMoneyDetails.setBlFlag(1);
userSadDetailsService.insert(userMoneyDetails);
}
}
/**
* 订单分销处理
@ -953,6 +1007,68 @@ public class SelfOrdersServiceImpl implements OrdersService {
return ResultUtil.error(-1, "查询失败");
}
@Override
public Result changeSadPay(String ordersId) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String date=sdf.format(new Date());
String[] ids = ordersId.split(",");
for (String s : ids) {
//1.获取订单用户信息
SelfOrders orders = jpaRepository.findById(Long.valueOf(s)).orElse(null);
if(orders==null){
continue;
}
double payMoney = orders.getPayMoney();
UserMoney userMoney = userMoneyService.selectUserMoneyByUserId(orders.getUserId());
double money = userMoney.getSad().doubleValue();
if (payMoney > money){
return ResultUtil.error(500,"盛安豆余额不足!");
}
userMoneyService.updateSad(2,orders.getUserId(),payMoney);
UserSadDetails userMoneyDetails=new UserSadDetails();
//查询用户当前余额
UserMoney userNowMoney = userMoneyService.selectUserMoneyByUserId(orders.getUserId());
//插入余额
userMoneyDetails.setBalance(userNowMoney.getSad());
//插入操作类型为已操作用户余额
userMoneyDetails.setManipulateType(2);
userMoneyDetails.setUserId(orders.getUserId());
userMoneyDetails.setTitle("[购买商品]标题:"+orders.getTitle());
userMoneyDetails.setContent("盛安豆支付:"+payMoney);
userMoneyDetails.setType(2);
userMoneyDetails.setMoney(userNowMoney.getSad());
userMoneyDetails.setCreateTime(date);
userMoneyDetails.setBlRole(2);
userMoneyDetails.setBlFlag(1);
userSadDetailsService.insert(userMoneyDetails);
//4.支付成功处理订单
orders.setPayWay(6); //支付方式1app微信 2微信公众号 3微信小程序 4app支付宝 5H5支付宝 6零钱
orders.setPayTime(DateUtil.createTime()); //设置支付时间
orders.setStatus(2); //订单状态1待付款 2已付款 3已发货 4已收货 5已取消 6退款中 7已退款 8拒绝退款 9拼团中
//虚拟商品处理
if (orders.getOrderType() == 1) { //普通订单
if (orders.getIsExpress() == 2){ //是否需要发货(1需要发货 2无需发货)
//虚拟商品发货发货成功为确认收货否则不做变化
SelfGoodsVirtual v = this.sendExpress(orders);
if (v != null){
orders.setVirtualId(v.getId()); //虚拟商品id
orders.setExpressTime(DateUtil.createTime()); //发货时间
orders.setStatus(4); //确认收货
}
}else if (orders.getIsExpress() == 3){ //核销订单
orders.setStatus(3); //待收货待使用
}
}
jpaRepository.save(orders);
//执行物料包添加操作
materialArtificerService.changePay(orders.getGoodsId(),orders.getUserId(),orders.getNumber());
//公众号消息通知
//userService.orderPay(orders.getUserId(), orders.getOrderNum(),orders.getPayMoney().toString(),orders.getCreateAt());
}
return ResultUtil.success();
}
/*
* 读取返回结果
*/

View File

@ -14,6 +14,17 @@
where user_id=#{userId}
</update>
<update id="updateMaySad">
update user_money set
<if test="type==1">
sad=sad+#{money}
</if>
<if test="type==2">
sad=sad-#{money}
</if>
where user_id=#{userId}
</update>
<update id="updateCashDeposit">
update user_money set
<if test="type==1">