Compare commits
5 Commits
24bb7b5eac
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| ca32ddc062 | |||
| df96d40a0e | |||
| 83fc611574 | |||
| fdb3e7a4bd | |||
| 3cfd76e6f1 |
@@ -1357,7 +1357,7 @@ public class BuyOrderController {
|
||||
return false;
|
||||
}
|
||||
System.out.println("=======GoodsType======"+product.getGoodsType());
|
||||
return "02".equals(product.getGoodsType()) || "03".equals(product.getGoodsType()) || "04".equals(product.getGoodsType());
|
||||
return "02".equals(product.getGoodsType()) || "03".equals(product.getGoodsType()) || "04".equals(product.getGoodsType()) || "07".equals(product.getGoodsType());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,6 +20,8 @@ import com.peanut.modules.common.entity.*;
|
||||
import com.peanut.modules.common.service.UserContributionService;
|
||||
import com.peanut.modules.common.service.UserInviteRegisterService;
|
||||
import com.peanut.modules.common.service.UserVipService;
|
||||
import com.peanut.modules.sys.entity.SysUserTokenEntity;
|
||||
import com.peanut.modules.sys.service.ShiroService;
|
||||
import com.peanut.modules.sys.service.SysUserTokenService;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -51,6 +53,8 @@ public class MyUserController {
|
||||
@Autowired
|
||||
private SysUserTokenService sysUserTokenService;
|
||||
@Autowired
|
||||
private ShiroService shiroService;
|
||||
@Autowired
|
||||
private TransactionDetailsService transactionDetailsService;
|
||||
@Autowired
|
||||
private UserInviteRegisterService inviteRegisterService;
|
||||
@@ -126,15 +130,27 @@ public class MyUserController {
|
||||
|
||||
/**
|
||||
* 信息
|
||||
* 通过 token 获取当前用户:管理员可按 id 查询任意用户;其他角色仅可查询自身信息
|
||||
* 说明:/book/user/** 为 anon,需手动解析 token,不能依赖 Shiro principal
|
||||
*/
|
||||
@RequestMapping("/info/{id}")
|
||||
// @RequiresPermissions("book:user:info")
|
||||
public R info(@PathVariable("id") String id){
|
||||
MyUserEntity user = userService.getById(id);
|
||||
// List<CouponHistoryEntity> list = couponHistoryService.getBaseMapper().selectList(new QueryWrapper<CouponHistoryEntity>().eq("member_id", id)
|
||||
// .eq("use_status", 0));
|
||||
// user.setConponsCount(list.size());
|
||||
|
||||
public R info(@PathVariable("id") String id, HttpServletRequest request){
|
||||
String token = request.getHeader("token");
|
||||
if (StringUtils.isEmpty(token)) {
|
||||
return R.error("无权限访问");
|
||||
}
|
||||
SysUserTokenEntity tokenEntity = shiroService.queryByToken(token);
|
||||
if (tokenEntity == null || tokenEntity.getExpireTime() == null
|
||||
|| tokenEntity.getExpireTime().getTime() < System.currentTimeMillis()) {
|
||||
return R.error("无权限访问");
|
||||
}
|
||||
Long tokenUserId = tokenEntity.getUserId();
|
||||
// 与 OAuth2Realm 一致:userId < 10000 为后台管理员,可查任意用户;否则仅可查自身
|
||||
if (tokenUserId >= 10000 && !String.valueOf(tokenUserId).equals(id)) {
|
||||
return R.error("无权限访问");
|
||||
}
|
||||
MyUserEntity user = userService.getById(id);
|
||||
return R.ok().put("user", user);
|
||||
}
|
||||
|
||||
|
||||
@@ -498,7 +498,7 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
|
||||
b1.setProduct(byId);
|
||||
b1.setExpressOrder(expressOrderDao.selectById(b1.getExpressOrderId()));
|
||||
boolean refundableStatusProduct = false;
|
||||
if(b1.getProduct()!=null && b1.getProduct().getGoodsType().equals("05") && (paymentDateTime > timestamp-7*24*60*60*1000 || isHT)){
|
||||
if(b1.getProduct()!=null && ("05".equals(b1.getProduct().getGoodsType()) || "07".equals(b1.getProduct().getGoodsType())) && (paymentDateTime > timestamp-7*24*60*60*1000 || isHT)){
|
||||
refundableStatusProduct = true;
|
||||
}else if(b1.getProduct()!=null && !b1.getProduct().getGoodsType().equals("05") && b.getOrderStatus().equals("1") && b1.getExpressOrderId()==0){
|
||||
refundableStatusProduct = true;
|
||||
@@ -609,7 +609,7 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
|
||||
bb.setRecordId(userRecord.getId());
|
||||
}
|
||||
boolean refundableStatusProduct = false;
|
||||
if (bb.getProduct()!=null && bb.getProduct().getGoodsType().equals("05") && paymentDateTime > timestamp - 7 * 24 * 60 * 60 * 1000) {
|
||||
if (bb.getProduct()!=null && ("05".equals(bb.getProduct().getGoodsType()) || "07".equals(bb.getProduct().getGoodsType())) && paymentDateTime > timestamp - 7 * 24 * 60 * 60 * 1000) {
|
||||
refundableStatusProduct = true;
|
||||
} else if (bb.getProduct()!=null && !bb.getProduct().getGoodsType().equals("05") && b.getOrderStatus().equals(Constants.ORDER_STATUS_TO_BE_SHIPPED) && bb.getExpressOrderId()==0){
|
||||
refundableStatusProduct = true;
|
||||
@@ -665,8 +665,8 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
|
||||
ExpressCommodity commodity = new ExpressCommodity();
|
||||
String productName = product.getProductName()+" ×"+buyOrderProduct.getQuantity()+";";
|
||||
remark += productName;
|
||||
//商品类型01挂图02书籍03预售书04仪器05课程06小店商品
|
||||
if ("02".equals(product.getGoodsType())||"03".equals(product.getGoodsType())){
|
||||
//商品类型01挂图02书籍03预售书04仪器05课程06小店商品07书课组合
|
||||
if ("02".equals(product.getGoodsType())||"03".equals(product.getGoodsType())||"07".equals(product.getGoodsType())){
|
||||
commodity.setGoodsName("书籍");
|
||||
}else if ("01".equals(product.getGoodsType())){
|
||||
commodity.setGoodsName("挂图");
|
||||
@@ -885,6 +885,42 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
|
||||
@Override
|
||||
public void addCourseToUser(String payType,BuyOrder orderEntity){
|
||||
List<ShopProductCourseEntity> orderCourse = getOrderCourse(orderEntity.getOrderSn());
|
||||
BigDecimal realMoney = orderEntity.getRealMoney() == null ? BigDecimal.ZERO : orderEntity.getRealMoney();
|
||||
BigDecimal jfDeduction = orderEntity.getJfDeduction() == null ? BigDecimal.ZERO : orderEntity.getJfDeduction();
|
||||
|
||||
// 07 书课组合:按 shop_product_book/course.product_price 占比分摊实付与积分
|
||||
Map<Integer, BigDecimal> comboTotalMap = new HashMap<>();
|
||||
Map<Integer, BigDecimal> comboCourseSumMap = new HashMap<>();
|
||||
Map<Integer, BigDecimal> comboAllocatedFee = new HashMap<>();
|
||||
Map<Integer, BigDecimal> comboAllocatedJf = new HashMap<>();
|
||||
Map<Integer, Integer> comboRemainCount = new HashMap<>();
|
||||
Set<Integer> comboProductIds = orderCourse.stream()
|
||||
.filter(c -> "07".equals(c.getGoodsType()) && c.getProductId() != null)
|
||||
.map(ShopProductCourseEntity::getProductId)
|
||||
.collect(Collectors.toSet());
|
||||
for (Integer productId : comboProductIds) {
|
||||
BigDecimal bookSum = shopProductBookDao.selectList(new LambdaQueryWrapper<ShopProductBookEntity>()
|
||||
.eq(ShopProductBookEntity::getProductId, productId))
|
||||
.stream()
|
||||
.map(ShopProductBookEntity::getProductPrice)
|
||||
.filter(Objects::nonNull)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
BigDecimal courseSum = shopProductCourseDao.selectList(new LambdaQueryWrapper<ShopProductCourseEntity>()
|
||||
.eq(ShopProductCourseEntity::getProductId, productId))
|
||||
.stream()
|
||||
.map(ShopProductCourseEntity::getProductPrice)
|
||||
.filter(Objects::nonNull)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
comboTotalMap.put(productId, bookSum.add(courseSum));
|
||||
comboCourseSumMap.put(productId, courseSum);
|
||||
comboAllocatedFee.put(productId, BigDecimal.ZERO);
|
||||
comboAllocatedJf.put(productId, BigDecimal.ZERO);
|
||||
long cnt = orderCourse.stream()
|
||||
.filter(c -> "07".equals(c.getGoodsType()) && productId.equals(c.getProductId()))
|
||||
.count();
|
||||
comboRemainCount.put(productId, (int) cnt);
|
||||
}
|
||||
|
||||
for (int i=0;i<orderCourse.size();i++){
|
||||
ShopProductCourseEntity s = orderCourse.get(i);
|
||||
LambdaQueryWrapper<UserCourseBuyEntity> wrapper2 = new LambdaQueryWrapper<>();
|
||||
@@ -926,16 +962,44 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
|
||||
userCourseBuyLog.setBeginDay(0);
|
||||
userCourseBuyLog.setDays(s.getDays());
|
||||
}
|
||||
//商品类型不是课程,视为赠送课程,报表金额为0
|
||||
if (!"05".equals(s.getGoodsType())){
|
||||
if ("07".equals(s.getGoodsType())) {
|
||||
// 书课组合:课价部分进摊销,书价部分不进
|
||||
Integer productId = s.getProductId();
|
||||
BigDecimal total = comboTotalMap.getOrDefault(productId, BigDecimal.ZERO);
|
||||
BigDecimal courseSum = comboCourseSumMap.getOrDefault(productId, BigDecimal.ZERO);
|
||||
BigDecimal coursePrice = s.getProductPrice() == null ? BigDecimal.ZERO : s.getProductPrice();
|
||||
if (total.compareTo(BigDecimal.ZERO) <= 0 || courseSum.compareTo(BigDecimal.ZERO) <= 0) {
|
||||
userCourseBuyLog.setFee(BigDecimal.ZERO);
|
||||
userCourseBuyLog.setJf(BigDecimal.ZERO);
|
||||
} else {
|
||||
int remain = comboRemainCount.getOrDefault(productId, 1);
|
||||
BigDecimal coursePool = realMoney.multiply(courseSum).divide(total, 2, RoundingMode.HALF_UP);
|
||||
BigDecimal jfPool = jfDeduction.multiply(courseSum).divide(total, 2, RoundingMode.HALF_UP);
|
||||
BigDecimal fee;
|
||||
BigDecimal jf;
|
||||
if (remain <= 1) {
|
||||
fee = coursePool.subtract(comboAllocatedFee.getOrDefault(productId, BigDecimal.ZERO));
|
||||
jf = jfPool.subtract(comboAllocatedJf.getOrDefault(productId, BigDecimal.ZERO));
|
||||
} else {
|
||||
fee = realMoney.multiply(coursePrice).divide(total, 2, RoundingMode.HALF_UP);
|
||||
jf = jfDeduction.multiply(coursePrice).divide(total, 2, RoundingMode.HALF_UP);
|
||||
comboAllocatedFee.put(productId, comboAllocatedFee.get(productId).add(fee));
|
||||
comboAllocatedJf.put(productId, comboAllocatedJf.get(productId).add(jf));
|
||||
}
|
||||
comboRemainCount.put(productId, remain - 1);
|
||||
userCourseBuyLog.setFee(fee);
|
||||
userCourseBuyLog.setJf(jf);
|
||||
}
|
||||
} else if (!"05".equals(s.getGoodsType())){
|
||||
//商品类型不是课程,视为赠送课程,报表金额为0
|
||||
userCourseBuyLog.setFee(BigDecimal.ZERO);
|
||||
userCourseBuyLog.setJf(BigDecimal.ZERO);
|
||||
}else {
|
||||
BigDecimal fee = orderEntity.getRealMoney().divide(new BigDecimal(orderCourse.size()),2, BigDecimal.ROUND_HALF_UP);
|
||||
BigDecimal jf = orderEntity.getJfDeduction().divide(new BigDecimal(orderCourse.size()),2, BigDecimal.ROUND_HALF_UP);
|
||||
BigDecimal fee = realMoney.divide(new BigDecimal(orderCourse.size()),2, RoundingMode.HALF_UP);
|
||||
BigDecimal jf = jfDeduction.divide(new BigDecimal(orderCourse.size()),2, RoundingMode.HALF_UP);
|
||||
if (i==(orderCourse.size()-1)){
|
||||
userCourseBuyLog.setFee(orderEntity.getRealMoney().subtract(fee.multiply(new BigDecimal(orderCourse.size()-1))));
|
||||
userCourseBuyLog.setJf(orderEntity.getJfDeduction().subtract(jf.multiply(new BigDecimal(orderCourse.size()-1))));
|
||||
userCourseBuyLog.setFee(realMoney.subtract(fee.multiply(new BigDecimal(orderCourse.size()-1))));
|
||||
userCourseBuyLog.setJf(jfDeduction.subtract(jf.multiply(new BigDecimal(orderCourse.size()-1))));
|
||||
}else {
|
||||
userCourseBuyLog.setFee(fee);
|
||||
userCourseBuyLog.setJf(jf);
|
||||
@@ -949,7 +1013,7 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
|
||||
public boolean checkWlOrder(String orderSn) {
|
||||
BuyOrder one = this.getOne(new LambdaQueryWrapper<BuyOrder>().eq(BuyOrder::getOrderSn, orderSn));
|
||||
List<Integer> collect = buyOrderProductDao.selectList(new LambdaQueryWrapper<BuyOrderProduct>().eq(BuyOrderProduct::getOrderId, one.getOrderId())).stream().map(BuyOrderProduct::getProductId).collect(Collectors.toList());
|
||||
List<ShopProduct> shopProducts = shopProductDao.selectList(new LambdaQueryWrapper<ShopProduct>().in(ShopProduct::getProductId, collect).ne(ShopProduct::getGoodsType,5));
|
||||
List<ShopProduct> shopProducts = shopProductDao.selectList(new LambdaQueryWrapper<ShopProduct>().in(ShopProduct::getProductId, collect).ne(ShopProduct::getGoodsType,"05"));
|
||||
return shopProducts.size()>0?true:false;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.peanut.modules.common.dao;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.peanut.modules.common.entity.InvProductCost;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface InvProductCostDao extends MPJBaseMapper<InvProductCost> {
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.peanut.modules.common.dao;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.peanut.modules.common.entity.InvStockRecord;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface InvStockRecordDao extends MPJBaseMapper<InvStockRecord> {
|
||||
}
|
||||
@@ -25,4 +25,9 @@ public interface TransactionDetailsDao extends BaseMapper<TransactionDetailsEnti
|
||||
List<Map<String,Object>> getTransactionDetailsInfo(@Param("date") String date);
|
||||
|
||||
List<Map<String,Object>> getRefundTransactionDetails(@Param("date") String date);
|
||||
|
||||
/**
|
||||
* 书课组合(07)订单拆分标价与名称,按 order_sn 批量查询
|
||||
*/
|
||||
List<Map<String,Object>> getComboSplitByOrderSns(@Param("orderSns") List<String> orderSns);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.peanut.modules.common.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 商品成本价
|
||||
*/
|
||||
@Data
|
||||
@TableName("inv_product_cost")
|
||||
public class InvProductCost {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
/** 商品ID */
|
||||
private Integer productId;
|
||||
/** 商品名称 */
|
||||
private String name;
|
||||
/** 成本价 */
|
||||
private BigDecimal costPrice;
|
||||
/** 商户标识 1灵枢 2众秒 */
|
||||
private Integer merchantId;
|
||||
private Date createTime;
|
||||
private Date updateTime;
|
||||
}
|
||||
@@ -137,7 +137,7 @@ public class ShopProduct implements Serializable {
|
||||
*/
|
||||
private Integer sumSales;
|
||||
/**
|
||||
* 商品类型01挂图02书籍03预售书04仪器05课程06小店商品
|
||||
* 商品类型01挂图02书籍03预售书04仪器05课程06小店商品07书课组合
|
||||
*/
|
||||
private String goodsType;
|
||||
private String goodsTypeCode;
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.peanut.modules.common.entity;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
|
||||
@@ -30,6 +31,11 @@ public class ShopProductBookEntity {
|
||||
*/
|
||||
@TableField("book_ids")
|
||||
private Integer bookIds;
|
||||
/**
|
||||
* 书籍拆分标价(组合商品按比例分摊用)
|
||||
*/
|
||||
@TableField("product_price")
|
||||
private BigDecimal productPrice;
|
||||
/**
|
||||
* 删除标记
|
||||
*/
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@@ -23,6 +24,11 @@ public class ShopProductCourseEntity {
|
||||
|
||||
private Integer days;
|
||||
|
||||
/**
|
||||
* 课程拆分标价(组合商品按比例分摊用)
|
||||
*/
|
||||
private BigDecimal productPrice;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
@TableLogic
|
||||
|
||||
@@ -124,7 +124,7 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
|
||||
w.disableLogicDel().eq(ShopProduct::getProductId,bb.getProductId());
|
||||
bb.setProduct(shopProductDao.selectOne(w));
|
||||
boolean refundableStatusProduct = false;
|
||||
if(bb.getProduct()!=null && bb.getProduct().getGoodsType().equals("05") && (paymentDateTime > timestamp-7*24*60*60*1000)){
|
||||
if(bb.getProduct()!=null && ("05".equals(bb.getProduct().getGoodsType()) || "07".equals(bb.getProduct().getGoodsType())) && (paymentDateTime > timestamp-7*24*60*60*1000)){
|
||||
refundableStatusProduct = true;
|
||||
}else if(bb.getProduct()!=null && !bb.getProduct().getGoodsType().equals("05") && b.getOrderStatus().equals("1") && bb.getExpressOrderId()==0){
|
||||
refundableStatusProduct = true;
|
||||
@@ -203,7 +203,7 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
|
||||
List<ShopProduct> productInfo = buyOrderProductDao.selectJoinList(ShopProduct.class,buyOrderProductWrapper);
|
||||
//添加关联课程id
|
||||
for (ShopProduct sp:productInfo){
|
||||
if (sp.getGoodsType()!=null&&"05".equals(sp.getGoodsType())){
|
||||
if (sp.getGoodsType()!=null&&("05".equals(sp.getGoodsType()) || "07".equals(sp.getGoodsType()))){
|
||||
List<ShopProductCourseEntity> list = shopProductCourseDao.selectList(new LambdaQueryWrapper<ShopProductCourseEntity>()
|
||||
.eq(ShopProductCourseEntity::getProductId,sp.getProductId()));
|
||||
sp.setCourseIds(list);
|
||||
|
||||
@@ -7,8 +7,15 @@ import com.peanut.modules.common.service.TransactionDetailsService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Service("commonTransactionDetailsService")
|
||||
@@ -31,6 +38,91 @@ public class TransactionDetailsServiceImpl extends ServiceImpl<TransactionDetail
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> getTransactionDetailsInfo(String date) {
|
||||
return this.baseMapper.getTransactionDetailsInfo(date);
|
||||
List<Map<String, Object>> list = this.baseMapper.getTransactionDetailsInfo(date);
|
||||
List<String> comboOrderSns = list.stream()
|
||||
.filter(row -> "实物、课程".equals(Objects.toString(row.get("goodsType"), "")))
|
||||
.map(row -> Objects.toString(row.get("payNo"), ""))
|
||||
.filter(sn -> !sn.isEmpty())
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
if (comboOrderSns.isEmpty()) {
|
||||
return list;
|
||||
}
|
||||
Map<String, Map<String, Object>> splitBySn = new HashMap<>();
|
||||
for (Map<String, Object> split : this.baseMapper.getComboSplitByOrderSns(comboOrderSns)) {
|
||||
splitBySn.put(Objects.toString(split.get("orderSn"), ""), split);
|
||||
}
|
||||
List<Map<String, Object>> result = new ArrayList<>(list.size() + comboOrderSns.size());
|
||||
for (Map<String, Object> row : list) {
|
||||
if (!"实物、课程".equals(Objects.toString(row.get("goodsType"), ""))) {
|
||||
result.add(row);
|
||||
continue;
|
||||
}
|
||||
Map<String, Object> split = splitBySn.get(Objects.toString(row.get("payNo"), ""));
|
||||
if (split == null
|
||||
|| toInt(split.get("comboCnt")) <= 0
|
||||
|| toInt(split.get("otherCnt")) > 0) {
|
||||
result.add(row);
|
||||
continue;
|
||||
}
|
||||
BigDecimal coursePrice = toBd(split.get("coursePriceSum"));
|
||||
BigDecimal bookPrice = toBd(split.get("bookPriceSum"));
|
||||
BigDecimal priceSum = coursePrice.add(bookPrice);
|
||||
if (priceSum.compareTo(BigDecimal.ZERO) <= 0) {
|
||||
result.add(row);
|
||||
continue;
|
||||
}
|
||||
BigDecimal total = toBd(row.get("changeAmount"));
|
||||
BigDecimal courseAmt = total.multiply(coursePrice).divide(priceSum, 2, RoundingMode.HALF_UP);
|
||||
BigDecimal bookAmt = total.subtract(courseAmt);
|
||||
String originName = Objects.toString(row.get("productName"), "");
|
||||
String courseNames = Objects.toString(split.get("courseNames"), "");
|
||||
String bookNames = Objects.toString(split.get("bookNames"), "");
|
||||
|
||||
Map<String, Object> courseRow = new LinkedHashMap<>(row);
|
||||
courseRow.put("goodsType", "课程");
|
||||
courseRow.put("productName", courseNames.isEmpty() ? originName : courseNames);
|
||||
courseRow.put("changeAmount", courseAmt);
|
||||
|
||||
Map<String, Object> bookRow = new LinkedHashMap<>(row);
|
||||
bookRow.put("goodsType", "实物");
|
||||
bookRow.put("productName", bookNames.isEmpty() ? originName : bookNames);
|
||||
bookRow.put("changeAmount", bookAmt);
|
||||
|
||||
result.add(courseRow);
|
||||
result.add(bookRow);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static int toInt(Object v) {
|
||||
if (v == null) {
|
||||
return 0;
|
||||
}
|
||||
if (v instanceof Number) {
|
||||
return ((Number) v).intValue();
|
||||
}
|
||||
try {
|
||||
return new BigDecimal(v.toString()).intValue();
|
||||
} catch (Exception e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private static BigDecimal toBd(Object v) {
|
||||
if (v == null) {
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
if (v instanceof BigDecimal) {
|
||||
return (BigDecimal) v;
|
||||
}
|
||||
if (v instanceof Number) {
|
||||
return BigDecimal.valueOf(((Number) v).doubleValue());
|
||||
}
|
||||
try {
|
||||
return new BigDecimal(v.toString());
|
||||
} catch (Exception e) {
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.peanut.modules.common.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class CourseCatalogueVo {
|
||||
|
||||
@@ -16,4 +18,7 @@ public class CourseCatalogueVo {
|
||||
private String image;
|
||||
|
||||
private Integer days;
|
||||
|
||||
/** 课程拆分标价(组合商品分摊用) */
|
||||
private BigDecimal productPrice;
|
||||
}
|
||||
|
||||
@@ -317,7 +317,6 @@ public class InventoryManagementServiceImpl extends ServiceImpl<InvStockRecordDa
|
||||
if (relations == null || relations.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
Integer componentProductId = null;
|
||||
for (ShopProductBookEntity rel : relations) {
|
||||
Integer candidateId = rel.getProductId();
|
||||
if (candidateId == null) {
|
||||
@@ -328,19 +327,20 @@ public class InventoryManagementServiceImpl extends ServiceImpl<InvStockRecordDa
|
||||
new LambdaQueryWrapper<ShopProductBookEntity>()
|
||||
.eq(ShopProductBookEntity::getProductId, candidateId)
|
||||
);
|
||||
if (bookCount != null && bookCount == 1) {
|
||||
componentProductId = candidateId;
|
||||
break;
|
||||
if (bookCount == null || bookCount != 1) {
|
||||
continue;
|
||||
}
|
||||
ShopProduct product = shopProductDao.selectById(candidateId);
|
||||
if (product == null || (product.getDelFlag() != null && product.getDelFlag() != 0)) {
|
||||
continue;
|
||||
}
|
||||
// 只要纯书/预售书,排除书课组合(07)等
|
||||
String goodsType = product.getGoodsType();
|
||||
if ("02".equals(goodsType) || "03".equals(goodsType)) {
|
||||
return product;
|
||||
}
|
||||
}
|
||||
if (componentProductId == null) {
|
||||
return null;
|
||||
}
|
||||
ShopProduct product = shopProductDao.selectById(componentProductId);
|
||||
if (product == null || (product.getDelFlag() != null && product.getDelFlag() != 0)) {
|
||||
return null;
|
||||
}
|
||||
return product;
|
||||
return null;
|
||||
}
|
||||
|
||||
private void validateSetBookComponentStock(List<Integer> bookIds, Integer merchantId, int quantity, Integer setProductId) {
|
||||
|
||||
@@ -282,6 +282,7 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
|
||||
wrapper.selectAs(CourseEntity::getId,"courseId");
|
||||
wrapper.selectAs(CourseCatalogueEntity::getId,"catalogueId");
|
||||
wrapper.select(ShopProductCourseEntity::getDays);
|
||||
wrapper.select(ShopProductCourseEntity::getProductPrice);
|
||||
wrapper.leftJoin(CourseCatalogueEntity.class,CourseCatalogueEntity::getId,ShopProductCourseEntity::getCatalogueId);
|
||||
wrapper.leftJoin(CourseEntity.class,CourseEntity::getId,ShopProductCourseEntity::getCourseId);
|
||||
wrapper.eq(ShopProductCourseEntity::getProductId,productId);
|
||||
|
||||
@@ -235,24 +235,13 @@ public class UserCourseBuyServiceImpl extends ServiceImpl<UserCourseBuyDao, User
|
||||
result.add(row);
|
||||
}
|
||||
}
|
||||
Map<String, Integer> refundChapterCountMap = new HashMap<>();
|
||||
for (Map<String, Object> refund : refundMap.values()) {
|
||||
String orderCourseKey = String.valueOf(refund.get("orderSn")) + "|" + String.valueOf(refund.get("ctitle"));
|
||||
refundChapterCountMap.merge(orderCourseKey, 1, Integer::sum);
|
||||
}
|
||||
for (Map<String, Object> refund : refundMap.values()) {
|
||||
String key = refundKey(refund);
|
||||
if (matchedKeys.contains(key)) {
|
||||
continue;
|
||||
}
|
||||
// fee 已在 getRefundInfo 按目录数/组合占比拆好,此处不再按课程名二次平分
|
||||
Map<String, Object> adjustedRefund = new HashMap<>(refund);
|
||||
String orderCourseKey = String.valueOf(refund.get("orderSn")) + "|" + String.valueOf(refund.get("ctitle"));
|
||||
int chapterCount = refundChapterCountMap.getOrDefault(orderCourseKey, 1);
|
||||
if (chapterCount > 1) {
|
||||
BigDecimal dividedFee = toBigDecimal(refund.get("fee"))
|
||||
.divide(BigDecimal.valueOf(chapterCount), 2, RoundingMode.HALF_UP);
|
||||
adjustedRefund.put("fee", dividedFee);
|
||||
}
|
||||
String payMonth = getPayMonth(refund);
|
||||
if (exportMonth.equals(payMonth)) {
|
||||
Map<String, Object> paidRow = buildPaidRowFromRefund(adjustedRefund);
|
||||
|
||||
@@ -148,6 +148,17 @@ public class CourseController {
|
||||
return R.ok().put("data",chapterDetail);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取下一章节详情
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/getNextCourseCatalogueChapter")
|
||||
public R getNextCourseCatalogueChapter(@RequestBody ParamTo param){
|
||||
Map<String, Object> chapterDetail = courseCatalogueChapterService.getNextChapterDetail(param.getId());
|
||||
return R.ok().put("data",chapterDetail);
|
||||
}
|
||||
|
||||
/**
|
||||
* 开通免费课程
|
||||
* @param map
|
||||
|
||||
@@ -10,4 +10,5 @@ public interface CourseCatalogueChapterService extends IService<CourseCatalogueC
|
||||
List<CourseCatalogueChapterEntity> getCourseCatalogueChapterList(int id);
|
||||
|
||||
Map<String,Object> getChapterDetail(Integer chapterId);
|
||||
Map<String, Object> getNextChapterDetail(Integer chapterId);
|
||||
}
|
||||
|
||||
@@ -83,6 +83,26 @@ public class CourseCatalogueChapterServiceImpl extends ServiceImpl<CourseCatalog
|
||||
return flag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getNextChapterDetail(Integer chapterId) {
|
||||
CourseCatalogueChapterEntity currentChapter = this.getById(chapterId);
|
||||
if (currentChapter == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 复用目录章节列表,保证下一章顺序与列表接口完全一致
|
||||
List<CourseCatalogueChapterEntity> chapterList = getCourseCatalogueChapterList(currentChapter.getCatalogueId());
|
||||
for (int i = 0; i < chapterList.size(); i++) {
|
||||
if (chapterId.equals(chapterList.get(i).getId())) {
|
||||
if (i + 1 >= chapterList.size()) {
|
||||
return null;
|
||||
}
|
||||
return getChapterDetail(chapterList.get(i + 1).getId());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private int getCurrentVideo(Integer chapterId){
|
||||
MPJLambdaWrapper<CourseCatalogueChapterVideoEntity> wrapper = new MPJLambdaWrapper<>();
|
||||
|
||||
@@ -17,7 +17,7 @@ spring:
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
druid:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://rm-2zev4157t67trxuu3yo.mysql.rds.aliyuncs.com:3306/e_book_test2?rewriteBatchedStatements=true
|
||||
url: jdbc:mysql://rm-2zev4157t67trxuu3yo.mysql.rds.aliyuncs.com:3306/e_book_test?rewriteBatchedStatements=true
|
||||
# username: root
|
||||
# password: HSXY1234hsxy
|
||||
# password: Jgll2023Nutty
|
||||
@@ -53,10 +53,10 @@ spring:
|
||||
initSQL: SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci
|
||||
|
||||
rabbitmq:
|
||||
host: 127.0.0.1
|
||||
host: 47.93.127.115
|
||||
port: 5672
|
||||
username: guest
|
||||
password: guest
|
||||
username: admin
|
||||
password: 751019
|
||||
virtualHost: /
|
||||
aliyun:
|
||||
oss:
|
||||
@@ -98,18 +98,18 @@ wxpay:
|
||||
mchId: 1612860909
|
||||
serialNo: 679AECB2F7AC4183033F713828892BA640E4EEE3
|
||||
apiV3Key: 4aYFklzaULeGlr7oJPZ6rHWKcxjihZUF
|
||||
wechatPayCertificateUrl: F:\hs\nuttyreading-server\src\main\resources\cent\wechatpay_7B5676E3CDF56680D0414A009CE501C844DBE2D6.pem
|
||||
privateKeyUrl: F:\hs\nuttyreading-server\src\main\resources\cent\apiclient_key.pem
|
||||
keyPemPath: F:\hs\nuttyreading-server\src\main\resources\cent\apiclient_key.pem
|
||||
wechatPayCertificateUrl: F:\hs\nuttyreading-java\src\main\resources\cent\wechatpay_7B5676E3CDF56680D0414A009CE501C844DBE2D6.pem
|
||||
privateKeyUrl: F:\hs\nuttyreading-java\src\main\resources\cent\apiclient_key.pem
|
||||
keyPemPath: F:\hs\nuttyreading-java\src\main\resources\cent\apiclient_key.pem
|
||||
notifyUrl: http://z6f8f828.natappfree.cc/pb/pay/payNotify
|
||||
refundNotifyUrl: https://testapi.nuttyreading.com/pay/refundNotify
|
||||
#灵枢商户号
|
||||
lsMchId: 1700371158
|
||||
lsSerialNo: 3132D23C3130B74B87890DC6E7C80256C75113B9
|
||||
lsApiV3Key: 4aYFklzaULeGlr7oJPZ6rHWKcxjihZUF
|
||||
lsWechatPayCertificateUrl: F:\hs\nuttyreading-server\src\main\resources\cent\lscent\wechatpay_30CFE19A12EDB4D9E0C7DF01DBF457C657566D04.pem
|
||||
lsPrivateKeyUrl: F:\hs\nuttyreading-server\src\main\resources\cent\lscent\apiclient_key.pem
|
||||
lsKeyPemPath: F:\hs\nuttyreading-server\src\main\resources\cent\lscent\apiclient_key.pem
|
||||
lsWechatPayCertificateUrl: F:\hs\nuttyreading-java\src\main\resources\cent\lscent\wechatpay_30CFE19A12EDB4D9E0C7DF01DBF457C657566D04.pem
|
||||
lsPrivateKeyUrl: F:\hs\nuttyreading-java\src\main\resources\cent\lscent\apiclient_key.pem
|
||||
lsKeyPemPath: F:\hs\nuttyreading-java\src\main\resources\cent\lscent\apiclient_key.pem
|
||||
lsNotifyUrl: http://z6f8f828.natappfree.cc/pb/pay/lsPayNotify
|
||||
lsRefundNotifyUrl: https://testapi.nuttyreading.com/pay/refundNotify
|
||||
|
||||
|
||||
@@ -50,13 +50,66 @@
|
||||
<!-- <resultMap id="OrderDetailResult" type="com.peanut.modules.book.entity.BuyOrderDetail">-->
|
||||
|
||||
<!-- </resultMap>-->
|
||||
|
||||
<!-- 按订单预聚合:纯课程(05)标价合计、书课组合(07)书/课拆分标价合计(避免相关子查询) -->
|
||||
<sql id="physicalAmountJoins">
|
||||
left join (
|
||||
select bop05.order_id,
|
||||
SUM(IF(sp05.activity_price < sp05.price, sp05.activity_price, sp05.price)) course05Sum
|
||||
from buy_order_product bop05
|
||||
inner join shop_product sp05 on sp05.product_id = bop05.product_id and sp05.goods_type = '05'
|
||||
group by bop05.order_id
|
||||
) c05 on c05.order_id = t.order_id
|
||||
left join (
|
||||
select bop07.order_id,
|
||||
IFNULL(SUM(spc_sum.s), 0) cs,
|
||||
IFNULL(SUM(spb_sum.s), 0) bs
|
||||
from buy_order_product bop07
|
||||
inner join shop_product sp07 on sp07.product_id = bop07.product_id and sp07.goods_type = '07'
|
||||
left join (
|
||||
select product_id, SUM(IFNULL(product_price, 0)) s
|
||||
from shop_product_course
|
||||
where del_flag = 0
|
||||
group by product_id
|
||||
) spc_sum on spc_sum.product_id = sp07.product_id
|
||||
left join (
|
||||
select product_id, SUM(IFNULL(product_price, 0)) s
|
||||
from shop_product_book
|
||||
where del_flag = 0
|
||||
group by product_id
|
||||
) spb_sum on spb_sum.product_id = sp07.product_id
|
||||
group by bop07.order_id
|
||||
) c07 on c07.order_id = t.order_id
|
||||
</sql>
|
||||
|
||||
<!-- 实物金额 = 订单/退款金额 - 纯课程(05)标价 - 书课组合(07)课价分摊部分 -->
|
||||
<sql id="physicalAmountExpr">
|
||||
${baseAmount}
|
||||
- IFNULL(c05.course05Sum, 0)
|
||||
- IFNULL(ROUND(${baseAmount} * IFNULL(c07.cs, 0) / NULLIF(IFNULL(c07.cs, 0) + IFNULL(c07.bs, 0), 0), 2), 0)
|
||||
</sql>
|
||||
|
||||
<sql id="physicalProductNameExpr">
|
||||
GROUP_CONCAT(
|
||||
IF(sp.goods_type = '07',
|
||||
IFNULL((
|
||||
select GROUP_CONCAT(bk.name SEPARATOR '/')
|
||||
from shop_product_book spb
|
||||
inner join book bk on bk.id = spb.book_id
|
||||
where spb.product_id = sp.product_id and spb.del_flag = 0
|
||||
), sp.product_name),
|
||||
sp.product_name
|
||||
) SEPARATOR ', '
|
||||
)
|
||||
</sql>
|
||||
|
||||
<select id="getPhysicalBuyOrderTotal" resultType="map">
|
||||
select payType,count(1) count,SUM(price) totalPrice from (
|
||||
select q.*,pzo.trade_no zfbOrder
|
||||
from (
|
||||
select t.createTime,t.name,t.tel,t.orderSn,t.orderStatus,t.payType,t.orderPrice,
|
||||
t.orderPrice-(select IF(SUM(if(sp2.activity_price<sp2.price,sp2.activity_price,sp2.price)) is NULL,0,SUM(if(sp2.activity_price<sp2.price,sp2.activity_price,sp2.price))) from shop_product sp2 where sp2.goods_type = '05' and sp2.product_id in (GROUP_CONCAT(sp.product_id SEPARATOR ','))) price,
|
||||
GROUP_CONCAT(sp.product_name SEPARATOR ', ') productName,t.remark
|
||||
MAX(<include refid="physicalAmountExpr"><property name="baseAmount" value="t.orderPrice"/></include>) price,
|
||||
<include refid="physicalProductNameExpr"/> productName,t.remark
|
||||
from (
|
||||
select bo.order_id,DATE_FORMAT(bo.create_time,'%Y-%m-%d %H:%i:%s') createTime,u.name,if(u.tel is null,if(u.email is null,'',u.email),u.tel) tel,bo.order_sn orderSn,
|
||||
IF(bo.payment_method=1,'微信',IF(bo.payment_method=2,'支付宝',IF(bo.payment_method=4,'天医币','0'))) payType,
|
||||
@@ -84,6 +137,7 @@
|
||||
) t
|
||||
left join buy_order_product bop on bop.order_id = t.order_id
|
||||
left join shop_product sp on sp.product_id = bop.product_id
|
||||
<include refid="physicalAmountJoins"/>
|
||||
group by t.orderSn
|
||||
) q
|
||||
left join pay_zfb_order pzo on pzo.relevanceOid = q.orderSn and pzo.trade_no is not null
|
||||
@@ -95,8 +149,8 @@
|
||||
select q.*,pzo.trade_no zfbOrder
|
||||
from (
|
||||
select t.createTime,t.name,t.tel,t.orderSn,t.orderStatus,t.payType,t.refundFee,
|
||||
t.refundFee-(select IF(SUM(if(sp2.activity_price<sp2.price,sp2.activity_price,sp2.price)) is NULL,0,SUM(if(sp2.activity_price<sp2.price,sp2.activity_price,sp2.price))) from shop_product sp2 where sp2.goods_type = '05' and sp2.product_id in (GROUP_CONCAT(sp.product_id SEPARATOR ','))) price,
|
||||
GROUP_CONCAT(sp.product_name SEPARATOR ', ') productName,t.remark
|
||||
MAX(<include refid="physicalAmountExpr"><property name="baseAmount" value="t.refundFee"/></include>) price,
|
||||
<include refid="physicalProductNameExpr"/> productName,t.remark
|
||||
from (
|
||||
select bo.order_id,DATE_FORMAT(bor.create_time,'%Y-%m-%d %H:%i:%s') createTime,u.name,if(u.tel is null,if(u.email is null,'',u.email),u.tel) tel,bo.order_sn orderSn,
|
||||
IF(bo.payment_method=1,'微信',IF(bo.payment_method=2,'支付宝',IF(bo.payment_method=4,'天医币','0'))) payType,
|
||||
@@ -125,6 +179,7 @@
|
||||
) t
|
||||
left join buy_order_product bop on bop.order_id = t.order_id
|
||||
left join shop_product sp on sp.product_id = bop.product_id
|
||||
<include refid="physicalAmountJoins"/>
|
||||
group by t.orderSn
|
||||
) q
|
||||
left join pay_zfb_order pzo on pzo.relevanceOid = q.orderSn and pzo.trade_no is not null
|
||||
@@ -135,8 +190,8 @@
|
||||
select q.*,pzo.trade_no zfbOrder
|
||||
from (
|
||||
select t.createTime,t.name,t.tel,t.orderSn,t.orderStatus,t.payType,t.orderPrice,
|
||||
t.orderPrice-(select IF(SUM(if(sp2.activity_price<sp2.price,sp2.activity_price,sp2.price)) is NULL,0,SUM(if(sp2.activity_price<sp2.price,sp2.activity_price,sp2.price))) from shop_product sp2 where sp2.goods_type = '05' and sp2.product_id in (GROUP_CONCAT(sp.product_id SEPARATOR ','))) price,
|
||||
GROUP_CONCAT(sp.product_name SEPARATOR ', ') productName,IF(count(1)=1,bop.quantity,'') quantity,t.remark
|
||||
MAX(<include refid="physicalAmountExpr"><property name="baseAmount" value="t.orderPrice"/></include>) price,
|
||||
<include refid="physicalProductNameExpr"/> productName,IF(count(1)=1,bop.quantity,'') quantity,t.remark
|
||||
from (
|
||||
select bo.order_id,DATE_FORMAT(bo.create_time,'%Y-%m-%d %H:%i:%s') createTime,u.name,if(u.tel is null,if(u.email is null,'',u.email),u.tel) tel,bo.order_sn orderSn,
|
||||
IF(bo.payment_method=1,'微信',IF(bo.payment_method=2,'支付宝',IF(bo.payment_method=4,'天医币','0'))) payType,
|
||||
@@ -164,6 +219,7 @@
|
||||
) t
|
||||
left join buy_order_product bop on bop.order_id = t.order_id
|
||||
left join shop_product sp on sp.product_id = bop.product_id
|
||||
<include refid="physicalAmountJoins"/>
|
||||
group by t.orderSn
|
||||
) q
|
||||
left join pay_zfb_order pzo on pzo.relevanceOid = q.orderSn and pzo.trade_no is not null
|
||||
@@ -172,8 +228,8 @@
|
||||
select q.*,pzo.trade_no zfbOrder
|
||||
from (
|
||||
select t.createTime,t.name,t.tel,t.orderSn,t.orderStatus,t.payType,t.orderPrice,
|
||||
t.orderPrice-(select IF(SUM(if(sp2.activity_price<sp2.price,sp2.activity_price,sp2.price)) is NULL,0,SUM(if(sp2.activity_price<sp2.price,sp2.activity_price,sp2.price))) from shop_product sp2 where sp2.goods_type = '05' and sp2.product_id in (GROUP_CONCAT(sp.product_id SEPARATOR ','))) price,
|
||||
GROUP_CONCAT(sp.product_name SEPARATOR ', ') productName,IF(count(1)=1,bop.quantity,'') quantity,t.remark,t.refund_no
|
||||
MAX(<include refid="physicalAmountExpr"><property name="baseAmount" value="t.orderPrice"/></include>) price,
|
||||
<include refid="physicalProductNameExpr"/> productName,IF(count(1)=1,bop.quantity,'') quantity,t.remark,t.refund_no
|
||||
from (
|
||||
select bo.order_id,DATE_FORMAT(bor.create_time,'%Y-%m-%d %H:%i:%s') createTime,u.name,if(u.tel is null,if(u.email is null,'',u.email),u.tel) tel,bo.order_sn orderSn,
|
||||
IF(bo.payment_method=1,'微信',IF(bo.payment_method=2,'支付宝',IF(bo.payment_method=4,'天医币','0'))) payType,
|
||||
@@ -202,6 +258,7 @@
|
||||
) t
|
||||
left join buy_order_product bop on bop.order_id = t.order_id
|
||||
left join shop_product sp on sp.product_id = bop.product_id
|
||||
<include refid="physicalAmountJoins"/>
|
||||
group by t.orderSn
|
||||
) q
|
||||
left join pay_zfb_order pzo on pzo.relevanceOid = q.orderSn and pzo.trade_no is not null
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
<result property="delFlag" column="del_flag"/>
|
||||
<result property="bookId" column="book_id"/>
|
||||
<result property="bookIds" column="book_ids"/>
|
||||
<result property="productPrice" column="product_price"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="getOrderBookId" parameterType="string" resultType="int">
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
select q.*,pzo.trade_no zfbOrder
|
||||
from (
|
||||
select t.*,
|
||||
IF(IF(GROUP_CONCAT(sp.product_name SEPARATOR ',') is NULL,IF(bo.order_type='vip',vbc.title,bo.remark),GROUP_CONCAT(sp.product_name SEPARATOR ',')) is NULL,'',IF((GROUP_CONCAT(sp.goods_type SEPARATOR ',') like '%,05%') or (GROUP_CONCAT(sp.goods_type SEPARATOR ',') like '05,'),'实物、课程',IF(GROUP_CONCAT(sp.goods_type SEPARATOR ',')='05','课程',IF(bo.order_type='relearn','课程',IF(bo.order_type='trainingClass','培训班',IF(bo.order_type='vip','VIP','实物')))))) goodsType,
|
||||
IF(IF(GROUP_CONCAT(sp.product_name SEPARATOR ',') is NULL,IF(bo.order_type='vip',vbc.title,bo.remark),GROUP_CONCAT(sp.product_name SEPARATOR ',')) is NULL,'',IF(FIND_IN_SET('07',GROUP_CONCAT(sp.goods_type SEPARATOR ',')) or (GROUP_CONCAT(sp.goods_type SEPARATOR ',') like '%,05%') or (GROUP_CONCAT(sp.goods_type SEPARATOR ',') like '05,'),'实物、课程',IF(GROUP_CONCAT(sp.goods_type SEPARATOR ',')='05','课程',IF(bo.order_type='relearn','课程',IF(bo.order_type='trainingClass','培训班',IF(bo.order_type='vip','VIP','实物')))))) goodsType,
|
||||
IF(IF(GROUP_CONCAT(sp.product_name SEPARATOR ',') is NULL,IF(bo.order_type='vip',vbc.title,bo.remark),GROUP_CONCAT(sp.product_name SEPARATOR ',')) is NULL,'',IF(GROUP_CONCAT(sp.product_name SEPARATOR ',') is NULL,IF(bo.order_type='vip',vbc.title,bo.remark),GROUP_CONCAT(sp.product_name SEPARATOR ','))) productName
|
||||
from (
|
||||
select td.transaction_id id,DATE_FORMAT(td.create_time,'%Y-%m-%d %H:%i:%s') createTime,u.name,if(u.tel is null,if(u.email is null,'',u.email),u.tel) tel
|
||||
@@ -61,8 +61,8 @@
|
||||
IF(bo.order_type='relearn','课程',
|
||||
IF(bo.order_type='trainingClass','培训班',
|
||||
IF(bo.order_type='vip','VIP',
|
||||
IF((GROUP_CONCAT(sp.goods_type SEPARATOR ',') like '%,05%') or (GROUP_CONCAT(sp.goods_type SEPARATOR ',') like '05,%') or (GROUP_CONCAT(sp.goods_type SEPARATOR ',')='05'),
|
||||
IF((GROUP_CONCAT(sp.goods_type SEPARATOR ',') like '%,05%') or (GROUP_CONCAT(sp.goods_type SEPARATOR ',') like '05,%'),'实物、课程','课程'),
|
||||
IF(FIND_IN_SET('07',GROUP_CONCAT(sp.goods_type SEPARATOR ',')) or (GROUP_CONCAT(sp.goods_type SEPARATOR ',') like '%,05%') or (GROUP_CONCAT(sp.goods_type SEPARATOR ',') like '05,%') or (GROUP_CONCAT(sp.goods_type SEPARATOR ',')='05'),
|
||||
IF(FIND_IN_SET('07',GROUP_CONCAT(sp.goods_type SEPARATOR ',')) or (GROUP_CONCAT(sp.goods_type SEPARATOR ',') like '%,05%') or (GROUP_CONCAT(sp.goods_type SEPARATOR ',') like '05,%'),'实物、课程','课程'),
|
||||
'实物')))) goodsType,
|
||||
IF(IF(GROUP_CONCAT(sp.product_name SEPARATOR ',') is NULL,IF(bo.order_type='vip',vbc.title,bo.remark),GROUP_CONCAT(sp.product_name SEPARATOR ',')) is NULL,'',IF(GROUP_CONCAT(sp.product_name SEPARATOR ',') is NULL,IF(bo.order_type='vip',vbc.title,bo.remark),GROUP_CONCAT(sp.product_name SEPARATOR ','))) productName
|
||||
from (
|
||||
@@ -92,7 +92,7 @@
|
||||
select q.*,pzo.trade_no zfbOrder
|
||||
from (
|
||||
select t.*,
|
||||
IF(IF(GROUP_CONCAT(sp.product_name SEPARATOR ',') is NULL,IF(bo.order_type='vip',vbc.title,bo.remark),GROUP_CONCAT(sp.product_name SEPARATOR ',')) is NULL,'',IF((GROUP_CONCAT(sp.goods_type SEPARATOR ',') like '%,05%') or (GROUP_CONCAT(sp.goods_type SEPARATOR ',') like '05,'),'实物、课程',IF(GROUP_CONCAT(sp.goods_type SEPARATOR ',')='05','课程',IF(bo.order_type='relearn','课程',IF(bo.order_type='trainingClass','培训班',IF(bo.order_type='vip','VIP','实物')))))) goodsType,
|
||||
IF(IF(GROUP_CONCAT(sp.product_name SEPARATOR ',') is NULL,IF(bo.order_type='vip',vbc.title,bo.remark),GROUP_CONCAT(sp.product_name SEPARATOR ',')) is NULL,'',IF(FIND_IN_SET('07',GROUP_CONCAT(sp.goods_type SEPARATOR ',')) or (GROUP_CONCAT(sp.goods_type SEPARATOR ',') like '%,05%') or (GROUP_CONCAT(sp.goods_type SEPARATOR ',') like '05,'),'实物、课程',IF(GROUP_CONCAT(sp.goods_type SEPARATOR ',')='05','课程',IF(bo.order_type='relearn','课程',IF(bo.order_type='trainingClass','培训班',IF(bo.order_type='vip','VIP','实物')))))) goodsType,
|
||||
IF(IF(GROUP_CONCAT(sp.product_name SEPARATOR ',') is NULL,IF(bo.order_type='vip',vbc.title,bo.remark),GROUP_CONCAT(sp.product_name SEPARATOR ',')) is NULL,'',IF(GROUP_CONCAT(sp.product_name SEPARATOR ',') is NULL,IF(bo.order_type='vip',vbc.title,bo.remark),GROUP_CONCAT(sp.product_name SEPARATOR ','))) productName
|
||||
from (
|
||||
select td.transaction_id id,DATE_FORMAT(td.create_time,'%Y-%m-%d %H:%i:%s') createTime,u.name,if(u.tel is null,if(u.email is null,'',u.email),u.tel) tel
|
||||
@@ -113,4 +113,49 @@
|
||||
left join pay_zfb_order pzo on pzo.relevanceOid = q.payNo and pzo.trade_no is not null
|
||||
</select>
|
||||
|
||||
<select id="getComboSplitByOrderSns" resultType="map">
|
||||
select
|
||||
bo.order_sn orderSn,
|
||||
IFNULL(SUM(IF(sp.goods_type = '07', 1, 0)), 0) comboCnt,
|
||||
IFNULL(SUM(IF(sp.product_id is not null and sp.goods_type <> '07', 1, 0)), 0) otherCnt,
|
||||
IFNULL((
|
||||
select SUM(IFNULL(spc.product_price, 0))
|
||||
from buy_order_product bop2
|
||||
inner join shop_product sp2 on sp2.product_id = bop2.product_id and sp2.goods_type = '07'
|
||||
inner join shop_product_course spc on spc.product_id = sp2.product_id and spc.del_flag = 0
|
||||
where bop2.order_id = bo.order_id
|
||||
), 0) coursePriceSum,
|
||||
IFNULL((
|
||||
select SUM(IFNULL(spb.product_price, 0))
|
||||
from buy_order_product bop2
|
||||
inner join shop_product sp2 on sp2.product_id = bop2.product_id and sp2.goods_type = '07'
|
||||
inner join shop_product_book spb on spb.product_id = sp2.product_id and spb.del_flag = 0
|
||||
where bop2.order_id = bo.order_id
|
||||
), 0) bookPriceSum,
|
||||
IFNULL((
|
||||
select GROUP_CONCAT(DISTINCT c.title ORDER BY c.id SEPARATOR '/')
|
||||
from buy_order_product bop2
|
||||
inner join shop_product sp2 on sp2.product_id = bop2.product_id and sp2.goods_type = '07'
|
||||
inner join shop_product_course spc on spc.product_id = sp2.product_id and spc.del_flag = 0
|
||||
inner join course c on c.id = spc.course_id
|
||||
where bop2.order_id = bo.order_id
|
||||
), '') courseNames,
|
||||
IFNULL((
|
||||
select GROUP_CONCAT(DISTINCT bk.name ORDER BY bk.id SEPARATOR '/')
|
||||
from buy_order_product bop2
|
||||
inner join shop_product sp2 on sp2.product_id = bop2.product_id and sp2.goods_type = '07'
|
||||
inner join shop_product_book spb on spb.product_id = sp2.product_id and spb.del_flag = 0
|
||||
inner join book bk on bk.id = spb.book_id
|
||||
where bop2.order_id = bo.order_id
|
||||
), '') bookNames
|
||||
from buy_order bo
|
||||
left join buy_order_product bop on bop.order_id = bo.order_id
|
||||
left join shop_product sp on sp.product_id = bop.product_id
|
||||
where bo.order_sn in
|
||||
<foreach collection="orderSns" item="sn" open="(" separator="," close=")">
|
||||
#{sn}
|
||||
</foreach>
|
||||
group by bo.order_id, bo.order_sn
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -68,7 +68,33 @@
|
||||
select pay_type,SUM(fee) fee
|
||||
from (
|
||||
select IF(bo.payment_method='1','App微信',IF(bo.payment_method='2','App支付宝',IF(bo.payment_method='4','App天医币','其他'))) pay_type,
|
||||
bor.fee
|
||||
CASE
|
||||
WHEN EXISTS (
|
||||
select 1 from buy_order_product bop0
|
||||
inner join shop_product sp0 on sp0.product_id = bop0.product_id
|
||||
where bop0.order_id = bo.order_id and sp0.goods_type = '07'
|
||||
) THEN ROUND(bor.fee * (
|
||||
(select IFNULL(SUM(spc.product_price), 0)
|
||||
from buy_order_product bop1
|
||||
inner join shop_product sp1 on sp1.product_id = bop1.product_id and sp1.goods_type = '07'
|
||||
inner join shop_product_course spc on spc.product_id = sp1.product_id and spc.del_flag = 0
|
||||
where bop1.order_id = bo.order_id)
|
||||
/ NULLIF((
|
||||
(select IFNULL(SUM(spc.product_price), 0)
|
||||
from buy_order_product bop1
|
||||
inner join shop_product sp1 on sp1.product_id = bop1.product_id and sp1.goods_type = '07'
|
||||
inner join shop_product_course spc on spc.product_id = sp1.product_id and spc.del_flag = 0
|
||||
where bop1.order_id = bo.order_id)
|
||||
+
|
||||
(select IFNULL(SUM(spb.product_price), 0)
|
||||
from buy_order_product bop1
|
||||
inner join shop_product sp1 on sp1.product_id = bop1.product_id and sp1.goods_type = '07'
|
||||
inner join shop_product_book spb on spb.product_id = sp1.product_id and spb.del_flag = 0
|
||||
where bop1.order_id = bo.order_id)
|
||||
), 0)
|
||||
), 2)
|
||||
ELSE bor.fee
|
||||
END as fee
|
||||
from buy_order_refund bor
|
||||
inner join buy_order bo on bo.order_id = bor.order_id and bo.del_flag = 0
|
||||
where bo.order_status = '6'
|
||||
@@ -78,7 +104,7 @@
|
||||
and (bo.order_type = 'relearn' or exists (
|
||||
select 1 from buy_order_product bop
|
||||
inner join shop_product sp on sp.product_id = bop.product_id
|
||||
where bop.order_id = bo.order_id and sp.goods_type = '05'
|
||||
where bop.order_id = bo.order_id and sp.goods_type in ('05','07')
|
||||
))
|
||||
) t
|
||||
GROUP BY pay_type
|
||||
@@ -87,7 +113,33 @@
|
||||
select pay_type,SUM(fee) fee
|
||||
from (
|
||||
select IF(bo.payment_method='1','微信',IF(bo.payment_method='2','支付宝',IF(bo.payment_method='4','天医币','其他'))) pay_type,
|
||||
bor.fee
|
||||
CASE
|
||||
WHEN EXISTS (
|
||||
select 1 from buy_order_product bop0
|
||||
inner join shop_product sp0 on sp0.product_id = bop0.product_id
|
||||
where bop0.order_id = bo.order_id and sp0.goods_type = '07'
|
||||
) THEN ROUND(bor.fee * (
|
||||
(select IFNULL(SUM(spc.product_price), 0)
|
||||
from buy_order_product bop1
|
||||
inner join shop_product sp1 on sp1.product_id = bop1.product_id and sp1.goods_type = '07'
|
||||
inner join shop_product_course spc on spc.product_id = sp1.product_id and spc.del_flag = 0
|
||||
where bop1.order_id = bo.order_id)
|
||||
/ NULLIF((
|
||||
(select IFNULL(SUM(spc.product_price), 0)
|
||||
from buy_order_product bop1
|
||||
inner join shop_product sp1 on sp1.product_id = bop1.product_id and sp1.goods_type = '07'
|
||||
inner join shop_product_course spc on spc.product_id = sp1.product_id and spc.del_flag = 0
|
||||
where bop1.order_id = bo.order_id)
|
||||
+
|
||||
(select IFNULL(SUM(spb.product_price), 0)
|
||||
from buy_order_product bop1
|
||||
inner join shop_product sp1 on sp1.product_id = bop1.product_id and sp1.goods_type = '07'
|
||||
inner join shop_product_book spb on spb.product_id = sp1.product_id and spb.del_flag = 0
|
||||
where bop1.order_id = bo.order_id)
|
||||
), 0)
|
||||
), 2)
|
||||
ELSE bor.fee
|
||||
END as fee
|
||||
from buy_order_refund bor
|
||||
inner join buy_order bo on bo.order_id = bor.order_id and bo.del_flag = 0
|
||||
where bo.order_status = '6'
|
||||
@@ -98,7 +150,7 @@
|
||||
and (bo.order_type = 'relearn' or exists (
|
||||
select 1 from buy_order_product bop
|
||||
inner join shop_product sp on sp.product_id = bop.product_id
|
||||
where bop.order_id = bo.order_id and sp.goods_type = '05'
|
||||
where bop.order_id = bo.order_id and sp.goods_type in ('05','07')
|
||||
))
|
||||
) t
|
||||
GROUP BY pay_type
|
||||
@@ -112,31 +164,89 @@
|
||||
DATE_FORMAT(IF(bo.success_time is null,bo.create_time,bo.success_time),'%Y-%m-%d %H:%i:%s') payTime,
|
||||
bo.order_sn orderSn,pzo.trade_no zfbOrder,
|
||||
0 beginDay,IFNULL(spc.days,0) days,
|
||||
ROUND(
|
||||
bor.fee / (
|
||||
case
|
||||
when bo.order_type='relearn' then
|
||||
IFNULL((
|
||||
select count(1)
|
||||
from shop_product_course spc2
|
||||
where spc2.product_id = (
|
||||
case
|
||||
when bo.remark is null or bo.remark = '' then null
|
||||
else cast(SUBSTRING_INDEX(bo.remark, ',', 1) as unsigned)
|
||||
end
|
||||
)
|
||||
and spc2.del_flag = 0
|
||||
),1)
|
||||
else
|
||||
IFNULL((
|
||||
CASE
|
||||
WHEN sp.goods_type = '07' THEN
|
||||
CASE
|
||||
WHEN spc.id = (
|
||||
select MAX(spc_last.id) from shop_product_course spc_last
|
||||
where spc_last.product_id = sp.product_id and spc_last.del_flag = 0
|
||||
) THEN
|
||||
ROUND(bor.fee * (
|
||||
select IFNULL(SUM(spc_cs.product_price), 0) from shop_product_course spc_cs
|
||||
where spc_cs.product_id = sp.product_id and spc_cs.del_flag = 0
|
||||
) / NULLIF((
|
||||
(select IFNULL(SUM(spc_cs.product_price), 0) from shop_product_course spc_cs where spc_cs.product_id = sp.product_id and spc_cs.del_flag = 0)
|
||||
+ (select IFNULL(SUM(spb.product_price), 0) from shop_product_book spb where spb.product_id = sp.product_id and spb.del_flag = 0)
|
||||
), 0), 2)
|
||||
- IFNULL((
|
||||
select SUM(ROUND(bor.fee * IFNULL(spc_o.product_price, 0) / NULLIF((
|
||||
(select IFNULL(SUM(spc_cs.product_price), 0) from shop_product_course spc_cs where spc_cs.product_id = sp.product_id and spc_cs.del_flag = 0)
|
||||
+ (select IFNULL(SUM(spb.product_price), 0) from shop_product_book spb where spb.product_id = sp.product_id and spb.del_flag = 0)
|
||||
), 0), 2))
|
||||
from shop_product_course spc_o
|
||||
where spc_o.product_id = sp.product_id and spc_o.del_flag = 0
|
||||
and spc_o.id <> (
|
||||
select MAX(spc_last.id) from shop_product_course spc_last
|
||||
where spc_last.product_id = sp.product_id and spc_last.del_flag = 0
|
||||
)
|
||||
), 0)
|
||||
ELSE
|
||||
ROUND(bor.fee * IFNULL(spc.product_price, 0) / NULLIF((
|
||||
(select IFNULL(SUM(spc_cs.product_price), 0) from shop_product_course spc_cs where spc_cs.product_id = sp.product_id and spc_cs.del_flag = 0)
|
||||
+ (select IFNULL(SUM(spb.product_price), 0) from shop_product_book spb where spb.product_id = sp.product_id and spb.del_flag = 0)
|
||||
), 0), 2)
|
||||
END
|
||||
WHEN bo.order_type = 'relearn' THEN
|
||||
CASE
|
||||
WHEN spc.id = (
|
||||
select MAX(spc_last.id) from shop_product_course spc_last
|
||||
where spc_last.product_id = sp.product_id and spc_last.del_flag = 0
|
||||
) THEN
|
||||
bor.fee - ROUND(bor.fee / IFNULL((
|
||||
select count(1) from shop_product_course spc2
|
||||
where spc2.product_id = sp.product_id and spc2.del_flag = 0
|
||||
), 1), 2) * (IFNULL((
|
||||
select count(1) from shop_product_course spc2
|
||||
where spc2.product_id = sp.product_id and spc2.del_flag = 0
|
||||
), 1) - 1)
|
||||
ELSE
|
||||
ROUND(bor.fee / IFNULL((
|
||||
select count(1) from shop_product_course spc2
|
||||
where spc2.product_id = sp.product_id and spc2.del_flag = 0
|
||||
), 1), 2)
|
||||
END
|
||||
ELSE
|
||||
CASE
|
||||
WHEN spc.id = (
|
||||
select MAX(spc_last.id)
|
||||
from buy_order_product bop_last
|
||||
inner join shop_product sp_last on sp_last.product_id = bop_last.product_id and sp_last.goods_type = '05'
|
||||
inner join shop_product_course spc_last on spc_last.product_id = sp_last.product_id and spc_last.del_flag = 0
|
||||
where bop_last.order_id = bo.order_id
|
||||
) THEN
|
||||
bor.fee - ROUND(bor.fee / IFNULL((
|
||||
select count(1)
|
||||
from buy_order_product bop2
|
||||
inner join shop_product sp2 on sp2.product_id = bop2.product_id
|
||||
where bop2.order_id = bo.order_id and sp2.goods_type = '05'
|
||||
),1)
|
||||
end
|
||||
),2
|
||||
) fee,
|
||||
inner join shop_product sp2 on sp2.product_id = bop2.product_id and sp2.goods_type = '05'
|
||||
inner join shop_product_course spc2 on spc2.product_id = sp2.product_id and spc2.del_flag = 0
|
||||
where bop2.order_id = bo.order_id
|
||||
), 1), 2) * (IFNULL((
|
||||
select count(1)
|
||||
from buy_order_product bop2
|
||||
inner join shop_product sp2 on sp2.product_id = bop2.product_id and sp2.goods_type = '05'
|
||||
inner join shop_product_course spc2 on spc2.product_id = sp2.product_id and spc2.del_flag = 0
|
||||
where bop2.order_id = bo.order_id
|
||||
), 1) - 1)
|
||||
ELSE
|
||||
ROUND(bor.fee / IFNULL((
|
||||
select count(1)
|
||||
from buy_order_product bop2
|
||||
inner join shop_product sp2 on sp2.product_id = bop2.product_id and sp2.goods_type = '05'
|
||||
inner join shop_product_course spc2 on spc2.product_id = sp2.product_id and spc2.del_flag = 0
|
||||
where bop2.order_id = bo.order_id
|
||||
), 1), 2)
|
||||
END
|
||||
END fee,
|
||||
if(bo.remark like '%退%',bo.remark,if(bor.remark is null,'',bor.remark)) remark,
|
||||
DATE_FORMAT(bor.create_time,'%Y-%m-%d %H:%i:%s') refundTime,
|
||||
'已退款' orderStatus
|
||||
@@ -154,7 +264,7 @@
|
||||
else bop.product_id
|
||||
end
|
||||
)
|
||||
and sp.goods_type = '05'
|
||||
and sp.goods_type in ('05','07')
|
||||
left join shop_product_course spc on spc.product_id = sp.product_id and spc.del_flag = 0
|
||||
left join course c on c.id = spc.course_id
|
||||
left join course_catalogue cc on cc.id = spc.catalogue_id
|
||||
@@ -219,7 +329,7 @@
|
||||
left join user_course_buy_log ucbl on ucbl.user_course_buy_id = ucb.id
|
||||
left join buy_order bo on bo.order_sn = ucbl.order_sn
|
||||
left join buy_order_product bop on bop.order_id = bo.order_id
|
||||
left join shop_product sp on sp.product_id = bop.product_id and sp.goods_type = '05'
|
||||
left join shop_product sp on sp.product_id = bop.product_id and sp.goods_type in ('05','07')
|
||||
where u.del_flag = 0 and u.tester_flag = 0
|
||||
and ucb.course_id = #{courseId} and catalogue_id = #{catalogueId}
|
||||
order by pay_time desc
|
||||
|
||||
Reference in New Issue
Block a user