Merge branch 'feature/mall_product' of http://117.33.142.185:3000/zenghuapei/cyywl_server into feature/mall_product

pull/16/head
TianYu 2023-05-25 15:35:15 +08:00
commit 503e5034d9
6 changed files with 71 additions and 32 deletions

View File

@ -25,4 +25,10 @@ services:
test: ["CMD", "curl", "-f", "http://localhost:48080/actuator/health"]
timeout: 30s
interval: 45s
retries: 3
retries: 3
networks:
- app_net
networks:
app_net:
external: true
name: cyywlnet

View File

@ -0,0 +1,22 @@
package cn.iocoder.yudao.module.shop.request.product;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.List;
/**
* @Title:DelectCartRequest
* @Description: TODO
* @author: tangqian
* @date: 2023/5/25 13:03
* @version: V1.0.0
*/
@Data
public class DeleteCartRequest implements Serializable {
private static final long serialVersionUID = 8471460222619043734L;
@Schema(description = "商品id")
private List<Long> ids;
}

View File

@ -6,6 +6,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.module.shop.request.product.CartNumRequest;
import cn.iocoder.yudao.module.shop.request.product.CartRequest;
import cn.iocoder.yudao.module.shop.request.product.CartResetRequest;
import cn.iocoder.yudao.module.shop.request.product.DeleteCartRequest;
import cn.iocoder.yudao.module.shop.response.product.CartInfoResponse;
import cn.iocoder.yudao.module.shop.service.product.StoreCartService;
import com.github.pagehelper.PageInfo;
@ -78,12 +79,11 @@ public class CartController {
/**
*
* @param ids ids
*/
@Operation(summary = "删除")
@RequestMapping(value = "/delete", method = RequestMethod.POST)
public CommonResult<String> delete(@RequestParam(value = "ids") List<Long> ids) {
if (storeCartService.deleteCartByIds(ids)) {
public CommonResult<String> delete(@RequestBody @Validated DeleteCartRequest request) {
if (storeCartService.deleteCartByIds(request.getIds())) {
return CommonResult.success("删除购物车成功");
} else {
return CommonResult.error(GlobalErrorCodeConstants.OPERATION_ERROR.getCode(), "删除购物车失败");

View File

@ -1223,8 +1223,8 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
//删除提报记录
try {
phoneRecordService.deletePhoneGear(orderDO.getOrderId());
}catch (Exception e) {
log.error("删除提报记录异常{}",e);
} catch (Exception e) {
log.error("删除提报记录异常{}", e);
}
//删除本地提报记录
phoneRecordService.deletePhoneRecord(orderDO.getId());
@ -1268,7 +1268,7 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
phoneRecordDO.setRefundFeeAmount(replace(info.getPrice()));
phoneRecordDO.setRechargeGearId(Long.valueOf(info.getRechargeGearId()));
LocalDateTime localDateTime = LocalDateTime.now();
LocalDateTime newLocalDateTime = LocalDateTimeUtil.offset(localDateTime,12, ChronoUnit.MONTHS);
LocalDateTime newLocalDateTime = LocalDateTimeUtil.offset(localDateTime, 12, ChronoUnit.MONTHS);
phoneRecordDO.setRefundFeeEndDate(newLocalDateTime);
phoneRecordDO.setRefundFeeNumber(12);
phoneRecordAdd.setChannel(deptRespDTO.getParentOrganizationName());
@ -1276,15 +1276,15 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
phoneRecordAdd.setMoney(info.getPrice());
phoneRecordAdd.setOrderNo(orderDO.getOrderId());
phoneRecordAdd.setOrderTime(LocalDateTimeUtil.formatNormal(orderDO.getPayTime().toLocalDate()));
phoneRecordAdd.setGear(rechargeGearDO.getRefundAmount().intValue()+"");
phoneRecordAdd.setGear(rechargeGearDO.getRefundAmount().intValue() + "");
phoneRecordAdds.add(phoneRecordAdd);
recordDOS.add(phoneRecordDO);
});
phoneRecordMapper.insertBatch(recordDOS);
try {
phoneRecordService.insertPhone(phoneRecordAdds);
}catch (Exception e){
log.info("调取提报新增报错{}",e);
} catch (Exception e) {
log.info("调取提报新增报错{}", e);
}
}
@ -1401,7 +1401,7 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
private RechargeOrderDO initializeOrder(OrderContentRequest request, String code, MemberUserRespDTO user, PromoterDTO promoterDTO) {
Long tenantId = TenantContextHolder.getTenantId();
Long deptId = promoterDTO.getDeptId();
if(deptId==null){
if (deptId == null) {
DeptRespDTO deptRespDTO = deptApi.findParentDept(tenantId);
deptId = deptRespDTO.getId();
}
@ -1448,6 +1448,7 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
rechargeOrderInfoMapper.insertBatch(infoDOS);
return orderDO;
}
private void orderCheck(OrderContentRequest request, MemberUserRespDTO user) {
List<OrderContentRequest.OrderInfo> orderInfos = request.getOrderInfos();
Assert.isTrue(!CollectionUtils.isEmpty(orderInfos), "订单信息不能为空!");
@ -1455,15 +1456,16 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
//先查询提报总表
List<Long> collect = orderInfos.stream().map(OrderContentRequest.OrderInfo::getGearId).collect(Collectors.toList());
List<RechargeGearDO> rechargeGearDOList = rechargeGearService.getRechargeGearList(collect);
rechargeGearDOList.forEach(rechargeGearDO->{
Boolean flag = phoneRecordService.verifyPhone(request.getConfirmPhone(),rechargeGearDO.getRefundAmount().intValue()+"");
rechargeGearDOList.forEach(rechargeGearDO -> {
Boolean flag = phoneRecordService.verifyPhone(request.getUserPhone(), rechargeGearDO.getRefundAmount().intValue() + "");
if (flag) {
throw new ServiceException("该挡位:" + rechargeGearDO.getName() + "你已购买,请勿重复操作");
}
});
List<PhoneRecordDO> infoDOS = phoneRecordMapper.selectList(Wrappers.<PhoneRecordDO>lambdaQuery()
.eq(PhoneRecordDO::getUserId, user.getMobile())
.eq(PhoneRecordDO::getPhone, user.getMobile())
.eq(PhoneRecordDO::getDeleted, 0)
.in(PhoneRecordDO::getRechargeGearId, collect));
if (!CollectionUtils.isEmpty(infoDOS)) {
@ -1481,7 +1483,7 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
MemberUserRespDTO userByMobile = userService.getUserByMobile(request.getUserPhone());
// 初始化一个账号
if (Objects.isNull(userByMobile)) {
userService.saveMemberUser(request.getUserPhone(),user.getPromoterId());
userService.saveMemberUser(request.getUserPhone(), user.getPromoterId());
}
}
}

View File

@ -7,15 +7,21 @@ import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
import cn.iocoder.yudao.module.shop.controller.app.recharge.vo.PhoneRecordAdd;
import cn.iocoder.yudao.module.shop.dal.dataobject.order.StoreOrder;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import java.util.*;
import cn.iocoder.yudao.module.shop.controller.admin.recharge.vo.*;
import cn.iocoder.yudao.module.shop.dal.dataobject.recharge.PhoneRecordDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
@ -70,11 +76,12 @@ public class PhoneRecordServiceImpl implements PhoneRecordService {
// 校验存在
validatePhoneRecordExists(id);
// 删除
phoneRecordMapper.deleteById(id);
phoneRecordMapper.delete(Wrappers.<PhoneRecordDO>lambdaQuery().eq(PhoneRecordDO::getRechargeOrderId, id));
}
private void validatePhoneRecordExists(Long id) {
if (phoneRecordMapper.selectById(id) == null) {
PhoneRecordDO phoneRecordDO = phoneRecordMapper.selectOne(Wrappers.<PhoneRecordDO>lambdaQuery().eq(PhoneRecordDO::getRechargeOrderId, id));
if (phoneRecordDO == null) {
throw exception(PHONE_RECORD_NOT_EXISTS);
}
}
@ -92,7 +99,7 @@ public class PhoneRecordServiceImpl implements PhoneRecordService {
@Override
public PageResult<PhoneRecordRespVO> getPhoneRecordPage(PhoneRecordPageReqVO pageReqVO) {
Page<PhoneRecordRespVO> page = new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize());
phoneRecordMapper.findListPage(page,pageReqVO);
phoneRecordMapper.findListPage(page, pageReqVO);
return new PageResult<>(page.getRecords(), page.getTotal());
}
@ -115,17 +122,18 @@ public class PhoneRecordServiceImpl implements PhoneRecordService {
@Override
public Boolean verifyPhone(String phone, String gear) {
JSONObject param = new JSONObject();
param.put("phone",phone);
param.put("gear",gear);
String result = HttpRequest.post(phoneUrl+"query/verify")
.header("token",token)
param.put("phone", phone);
param.put("gear", gear);
String result = HttpRequest.post(phoneUrl + "query/verify")
.header("token", token)
.body(JSONObject.toJSONString(param))
.execute()
.body();
JSONObject resultJson = JSONObject.parseObject(result);
if("0000".equals(resultJson.get("code"))){
log.info("query/verify:返回参数{}", resultJson);
if ("0000".equals(resultJson.get("code"))) {
return resultJson.getBoolean("body");
}else{
} else {
throw new ServiceException("手机号档位验证失败");
}
}
@ -141,13 +149,13 @@ public class PhoneRecordServiceImpl implements PhoneRecordService {
*/
@Override
public Boolean deletePhoneGear(String orderId) {
String result = HttpRequest.post(phoneUrl+"query/deleteReport?orderNo="+orderId)
.header("token",token)
String result = HttpRequest.post(phoneUrl + "query/deleteReport?orderNo=" + orderId)
.header("token", token)
.execute()
.body();
JSONObject resultJson = JSONObject.parseObject(result);
log.info("删除提报{}",JSONObject.toJSONString(resultJson));
if("0000".equals(resultJson.get("code"))){
log.info("删除提报{}", JSONObject.toJSONString(resultJson));
if ("0000".equals(resultJson.get("code"))) {
return true;
}
return false;
@ -166,14 +174,14 @@ public class PhoneRecordServiceImpl implements PhoneRecordService {
*/
@Override
public Boolean insertPhone(List<PhoneRecordAdd> data) {
String result = HttpRequest.post(phoneUrl+"query/createReport")
.header("token",token)
String result = HttpRequest.post(phoneUrl + "query/createReport")
.header("token", token)
.body(JSONObject.toJSONString(data))
.execute()
.body();
JSONObject resultJson = JSONObject.parseObject(result);
log.info("提报新增返回结果{}",JSONObject.toJSONString(resultJson));
if("0000".equals(resultJson.get("code"))){
log.info("提报新增返回结果{}", JSONObject.toJSONString(resultJson));
if ("0000".equals(resultJson.get("code"))) {
return true;
}
return false;

View File

@ -170,6 +170,7 @@
}
.box-member {
padding: 36rpx 40rpx;
border-radius: 20rpx;