Compare commits

..

No commits in common. "ad7d2a8bde3445e9a7a36976fa799030cda89d6e" and "079685b766f0d142b8ed935fe1760ce8559032d5" have entirely different histories.

12 changed files with 67 additions and 661 deletions

View File

@ -19,9 +19,7 @@ import com.suisung.mall.common.pojo.req.WxUserInfoReq;
import com.suisung.mall.common.utils.I18nUtil;
import com.suisung.mall.common.utils.phone.PhoneNumberUtils;
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -39,7 +37,6 @@ import java.util.UUID;
* @author Xinze
* @since 2021-04-28
*/
@Slf4j
@Service
public class AccountUserBindConnectServiceImpl extends BaseServiceImpl<AccountUserBindConnectMapper, AccountUserBindConnect> implements AccountUserBindConnectService {
@ -400,26 +397,12 @@ public class AccountUserBindConnectServiceImpl extends BaseServiceImpl<AccountUs
return null;
}
/**
* 初始化账户用户绑定信息
*
* @param bindId 绑定ID
* @param bindType 绑定类型
* @param userId 用户ID
* @param userType 用户类型
* @return 账户用户绑定连接对象如果初始化失败则返回null
*/
public AccountUserBindConnect initAccountUserBindConnect(String bindId, Integer bindType, Integer userId, Integer userType) {
// 1. 校验入参任何一个为空直接返回null
if (StrUtil.isBlank(bindId)
|| ObjectUtil.isNull(bindType)
|| ObjectUtil.isNull(bindType)
|| ObjectUtil.isNull(bindType)) {
log.warn("初始化账户用户绑定信息失败参数存在空值bindId={}, bindType={}, userId={}, userType={}", bindId, bindType, userId, userType);
if (StrUtil.isBlank(bindId) || bindType == null || userId == null || userType == null) {
return null;
}
// 2. 查询是否已存在绑定关系
QueryWrapper<AccountUserBindConnect> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("bind_id", bindId)
.eq("bind_type", bindType)
@ -427,44 +410,29 @@ public class AccountUserBindConnectServiceImpl extends BaseServiceImpl<AccountUs
.eq("user_id", userId)
.eq("bind_active", CommonConstant.Enable);
AccountUserBindConnect existingBindConnect = findOne(queryWrapper);
if (existingBindConnect != null) {
log.info("账户用户绑定信息已存在bindId={}, bindType={}, userId={}, userType={}", bindId, bindType, userId, userType);
return existingBindConnect;
AccountUserBindConnect accountUserBindConnect = findOne(queryWrapper);
if (accountUserBindConnect != null) {
return accountUserBindConnect;
}
// 3. 创建新的绑定关系
AccountUserBindConnect newBindConnect = new AccountUserBindConnect();
newBindConnect.setBind_id(bindId);
newBindConnect.setBind_type(bindType);
newBindConnect.setUser_id(userId);
newBindConnect.setUser_type(userType);
newBindConnect.setBind_active(CommonConstant.Enable);
newBindConnect.setBind_time(new Date());
newBindConnect.setBind_expires_in(0);
newBindConnect.setBind_token_ttl(0);
newBindConnect.setBind_level(0);
newBindConnect.setBind_vip(0);
// 新增一条绑定数据
AccountUserBindConnect record = new AccountUserBindConnect();
record.setBind_id(bindId);
record.setBind_type(bindType);
record.setUser_id(userId);
record.setUser_type(userType);
record.setBind_active(CommonConstant.Enable);
record.setBind_time(new Date());
record.setBind_expires_in(0);
record.setBind_token_ttl(0);
record.setBind_level(0);
record.setBind_vip(0);
// log.debug("准备创建新的账户用户绑定信息: {}", JSONUtil.toJsonStr(newBindConnect));
// 4. 插入新的绑定关系处理唯一索引冲突异常
try {
if (add(newBindConnect)) {
log.info("成功创建账户用户绑定信息: bindId={}, bindType={}, userId={}, userType={}", bindId, bindType, userId, userType);
return newBindConnect;
} else {
log.error("创建账户用户绑定信息失败数据库操作返回false");
return null;
}
} catch (DuplicateKeyException e) {
// 5. 捕获唯一索引冲突异常
log.error("创建账户用户绑定信息失败违反唯一约束bindId={}, bindType={}, userId={}, userType={}", bindId, bindType, userId, userType, e);
return null;
} catch (Exception e) {
// 6. 捕获其他异常
log.error("创建账户用户绑定信息时发生未知异常bindId={}, bindType={}, userId={}, userType={}", bindId, bindType, userId, userType, e);
return null;
// 一定是 insert 新增不能 saveOrUpdate
if (add(record)) {
return record;
}
return null;
}
}

View File

@ -12,7 +12,6 @@ import lombok.experimental.Accessors;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
* <p>
@ -102,9 +101,4 @@ public class PayUserResource implements Serializable {
@ApiModelProperty(value = "乐观锁")
private Integer version;
@ApiModelProperty(value = "新增时间,默认当前时间")
private Date created_at;
@ApiModelProperty(value = "最后更新时间,默认当前时间")
private Date updated_at;
}

View File

@ -28,6 +28,16 @@ redis:
separator: ":"
expire: 3600
redisson:
address: redis://@redis.host@:@redis.port@
database: @redis.database@ # Redis 库索引
password: @redis.password@ # Redis 密码
connectionPoolSize: 64 # 连接池大小
connectionMinimumIdleSize: 10 # 最小空闲连接数
idleConnectionTimeout: 10000 # 空闲连接超时时间(毫秒)
connectTimeout: 10000 # 连接超时时间(毫秒)
timeout: 3000 # 命令等待超时时间(毫秒)
baidu:
map:
app_id: 116444176

View File

@ -333,12 +333,6 @@ public class PayController {
return flag;
}
/**
* 订单退款远程调用
*
* @param shopOrderReturnList 退款列表
* @return 是否成功
*/
@RequestMapping(value = "/doRefund", method = RequestMethod.POST)
public boolean doRefund(@RequestBody List<ShopOrderReturn> shopOrderReturnList) {
boolean flag = false;

File diff suppressed because one or more lines are too long

View File

@ -746,7 +746,7 @@ public class ShopActivityGroupbookingServiceImpl extends BaseServiceImpl<ShopAct
Integer return_next_state_id = StateCode.RETURN_PROCESS_FINISH;
//执行退货申请
flag = shopOrderReturnService.processReviewList(Collections.singletonList(return_id), Collections.singletonList(orderReturn), StateCode.RETURN_PROCESS_CHECK, return_next_state_id);
flag = shopOrderReturnService.review(Collections.singletonList(return_id), Collections.singletonList(orderReturn), StateCode.RETURN_PROCESS_CHECK, return_next_state_id);
if (!flag) {
throw new ApiException(ResultCode.FAILED);

View File

@ -76,7 +76,7 @@ public class ShopOrderReturnController extends BaseControllerImpl {
return CommonResult.success(shopOrderReturnService.saveOrUpdate(shopOrderReturn));
}
@ApiOperation(value = "退货单审核 - 商家同意退款退库", notes = "退货单审核 - 同意退款退库")
@ApiOperation(value = "退货单审核 - 同意退款退库", notes = "退货单审核 - 同意退款退库")
@RequestMapping(value = "/review", method = RequestMethod.POST)
public CommonResult review(@RequestParam(name = "return_id") String return_id,
@RequestParam(name = "return_flag", defaultValue = "0") Integer return_flag,
@ -86,10 +86,10 @@ public class ShopOrderReturnController extends BaseControllerImpl {
shopOrderReturn.setReturn_id(return_id);
shopOrderReturn.setReturn_flag(return_flag);
shopOrderReturn.setReturn_store_message(return_store_message);
return CommonResult.success(shopOrderReturnService.processReviewList(shopOrderReturn, receiving_address));
return CommonResult.success(shopOrderReturnService.review(shopOrderReturn, receiving_address));
}
@ApiOperation(value = "退货单审核 - 家拒绝退款", notes = "退货单审核 - 卖家拒绝退款")
@ApiOperation(value = "退货单审核 - 家拒绝退款", notes = "退货单审核 - 卖家拒绝退款")
@RequestMapping(value = "/refused", method = RequestMethod.POST)
public CommonResult refused(ShopOrderReturn shopOrderReturn) {
String return_store_message = shopOrderReturn.getReturn_store_message();
@ -123,7 +123,7 @@ public class ShopOrderReturnController extends BaseControllerImpl {
ShopOrderReturn shopOrderReturn = shopOrderReturnService.get(return_id);
if (CheckUtil.checkDataRights(store_id, shopOrderReturn, ShopOrderReturn::getStore_id)) {
shopOrderReturnService.processReviewList(Collections.singletonList(return_id), Collections.singletonList(shopOrderReturn), StateCode.RETURN_PROCESS_RECEIVED, null);
shopOrderReturnService.review(Collections.singletonList(return_id), Collections.singletonList(shopOrderReturn), StateCode.RETURN_PROCESS_RECEIVED, null);
} else {
throw new ApiException(ResultCode.FORBIDDEN);
}

View File

@ -58,7 +58,7 @@ public class UserReturnController extends BaseControllerImpl {
return shopOrderReturnService.returnItem();
}
@ApiOperation(value = "添加退款退货-部分退货,卖家也可以决定不退货退款,买家申请退款不支持。卖家可以主动退款。", notes = "添加退款退货-发货退货,卖家也可以决定不退货退款,买家申请退款不支持。卖家可以主动退款。")
@ApiOperation(value = "添加退款退货-发货退货,卖家也可以决定不退货退款,买家申请退款不支持。卖家可以主动退款。", notes = "添加退款退货-发货退货,卖家也可以决定不退货退款,买家申请退款不支持。卖家可以主动退款。")
@RequestMapping(value = "/addItem", method = RequestMethod.GET)
public CommonResult addItem(OrderReturnVo orderReturnVo) {
OrderReturnInputVo orderReturnInput = BeanUtil.copyProperties(orderReturnVo, OrderReturnInputVo.class);

View File

@ -43,7 +43,7 @@ public interface ShopOrderReturnService extends IBaseService<ShopOrderReturn> {
Map getReturnDetail(String return_id);
boolean processReviewList(ShopOrderReturn shopOrderReturn, Integer receiving_address);
boolean review(ShopOrderReturn shopOrderReturn, Integer receiving_address);
/**
* 退单审核
@ -54,7 +54,7 @@ public interface ShopOrderReturnService extends IBaseService<ShopOrderReturn> {
* @param return_next_state_id
* @return
*/
boolean processReviewList(List<String> return_ids, List<ShopOrderReturn> return_rows, Integer state_id, Integer return_next_state_id);
boolean review(List<String> return_ids, List<ShopOrderReturn> return_rows, Integer state_id, Integer return_next_state_id);
/**
* 卖家拒绝退款

View File

@ -744,7 +744,7 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
ShopOrderReturn orderReturn = get(return_id);
if (CheckUtil.checkDataRights(store_id, orderReturn, ShopOrderReturn::getStore_id)) {
processReviewList(Collections.singletonList(return_id), Collections.singletonList(orderReturn), StateCode.RETURN_PROCESS_REFUND, null);
review(Collections.singletonList(return_id), Collections.singletonList(orderReturn), StateCode.RETURN_PROCESS_REFUND, null);
} else {
throw new ApiException(I18nUtil._("无操作权限!"));
}
@ -875,7 +875,7 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
}
// 订单审核
processReviewList(return_ids, Collections.singletonList(shopOrderReturn), StateCode.RETURN_PROCESS_CHECK, null);
review(return_ids, Collections.singletonList(shopOrderReturn), StateCode.RETURN_PROCESS_CHECK, null);
} else {
throw new ApiException(ResultCode.FORBIDDEN);
}
@ -1115,23 +1115,22 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
}
/**
* 退货单审核 - 商家同意退款退库
* 退货单审核 - 同意退款退库
*
* @param shopOrderReturn
* @return
*/
@Override
@GlobalTransactional
public boolean processReviewList(ShopOrderReturn shopOrderReturn, Integer receiving_address) {
public boolean review(ShopOrderReturn shopOrderReturn, Integer receiving_address) {
Integer store_id;
Integer store_id = null;
if (shopOrderReturn.getStore_id() == null) {
UserDto user = getCurrentUser();
store_id = Convert.toInt(user.getStore_id());
} else {
store_id = shopOrderReturn.getStore_id();
}
String str_return_id = shopOrderReturn.getReturn_id();
List<String> return_ids = Convert.toList(String.class, str_return_id);
@ -1141,19 +1140,17 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
Integer return_flag = shopOrderReturn.getReturn_flag();
if (ObjectUtil.equal(return_flag, 0)) {
//无需退货直接修改退货单状态为完成并调用 review 方法进行审核
if (!edit(shopOrderReturn)) {
throw new ApiException(I18nUtil._("修改订单信息失败!"));
}
Integer return_next_state_id = StateCode.RETURN_PROCESS_FINISH;
// 订单审核
if (!processReviewList(return_ids, orderReturns, StateCode.RETURN_PROCESS_CHECK, return_next_state_id)) {
if (!review(return_ids, orderReturns, StateCode.RETURN_PROCESS_CHECK, return_next_state_id)) {
throw new ApiException(I18nUtil._("审核失败!"));
}
} else {
//需要退货获取收货地址信息并更新退货单的相关字段如地址联系方式等随后调用 review 方法进行审核
ShopStoreShippingAddress address_row = shopStoreShippingAddressService.get(receiving_address);
if (address_row != null) {
String return_addr = address_row.getSs_province() + address_row.getSs_city() + address_row.getSs_county() + address_row.getSs_address();
@ -1170,7 +1167,7 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
}
// 订单审核
if (!processReviewList(return_ids, orderReturns, StateCode.RETURN_PROCESS_CHECK, 0)) {
if (!review(return_ids, orderReturns, StateCode.RETURN_PROCESS_CHECK, 0)) {
throw new ApiException(I18nUtil._("审核失败!"));
}
} else {
@ -1178,10 +1175,8 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
}
}
} else {
// 没有权限
throw new ApiException(ResultCode.FORBIDDEN);
}
// 通知买家退货退款成功
String message_id = "refunds-and-reminders";
Map args = new HashMap();
@ -1189,6 +1184,7 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
args.put("return_refund_amount", shopOrderReturn.getReturn_refund_amount());
messageService.sendNoticeMsg(shopOrderReturn.getBuyer_user_id(), 0, message_id, args);
return true;
}
@ -1228,7 +1224,7 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
}
@Override
public boolean processReviewList(List<String> return_ids, List<ShopOrderReturn> return_rows, Integer state_id, Integer return_next_state_id) {
public boolean review(List<String> return_ids, List<ShopOrderReturn> return_rows, Integer state_id, Integer return_next_state_id) {
if (CollUtil.isEmpty(return_ids)) {
throw new ApiException(I18nUtil._("请选择需要审核的退单!"));
}
@ -1282,17 +1278,9 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
*
* @param return_ids 退货订单id
* @param store_id 所属店铺
* @param return_state_id 当前退单状态
* RETURN_PROCESS_SUBMIT = 3100; //客户提交退单1ReturnReturn
* RETURN_PROCESS_CHECK = 3105; //退单审核1ReturnReturn
* RETURN_PROCESS_RECEIVED = 3110; //收货确认0ReturnReturn
* RETURN_PROCESS_REFUND = 3115; //退款确认0ReturnReturn
* RETURN_PROCESS_RECEIPT_CONFIRMATION = 3120; //客户收款确认0ReturnReturn
* RETURN_PROCESS_FINISH = 3125; //完成1ReturnReturn3130-商家拒绝退货
* RETURN_PROCESS_REFUSED = 3130; //-商家拒绝退货
* RETURN_PROCESS_CANCEL = 3135; //-买家取消
* @param return_rows 退货订单列表
* @param return_next_state_id 下一个退单状态
* @param return_state_id
* @param return_rows
* @param return_next_state_id 当前订单状态
* @return
*/
@GlobalTransactional
@ -1345,7 +1333,6 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
}
}
// 判断是否需要退款
if (shopStoreConfigService.checkNeedRefund(return_state_id, return_next_state_id)) {
// 执行真正退款逻辑
// 卖家账户扣款买家账户增加
@ -1359,7 +1346,6 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
}
}
//修改退货订单及其相关商品为下一个待处理状态
editReturnNextState(return_ids, return_state_id, shopOrderReturn);
// 当前状态 - 旧状态
@ -1471,8 +1457,7 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
}
/**
* 修改退货订单及其相关商品为下一个待处理状态
* 这段代码实现了一个方法用于将退货订单及其相关商品的状态更新为下一个待处理状态
* 修改订单为下一个待处理状态
*
* @param return_ids 退货订单id
* @param return_state_id 前订单状态

View File

@ -198,20 +198,6 @@ public class ShopStoreConfigServiceImpl extends BaseServiceImpl<ShopStoreConfigM
}
}
/**
* 检查是否需要退款
*
* @param return_state_id RETURN_PROCESS_SUBMIT = 3100; //客户提交退单1ReturnReturn
* RETURN_PROCESS_CHECK = 3105; //退单审核1ReturnReturn
* RETURN_PROCESS_RECEIVED = 3110; //收货确认0ReturnReturn
* RETURN_PROCESS_REFUND = 3115; //退款确认0ReturnReturn
* RETURN_PROCESS_RECEIPT_CONFIRMATION = 3120; //客户收款确认0ReturnReturn
* RETURN_PROCESS_FINISH = 3125; //完成1ReturnReturn3130-商家拒绝退货
* RETURN_PROCESS_REFUSED = 3130; //-商家拒绝退货
* RETURN_PROCESS_CANCEL = 3135; //-买家取消
* @param return_next_state_id
* @return
*/
@Override
public boolean checkNeedRefund(Integer return_state_id, Integer return_next_state_id) {
Integer return_process_refund = StateCode.RETURN_PROCESS_MAP.get(StateCode.RETURN_PROCESS_REFUND);

View File

@ -760,7 +760,7 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
// 使用 Redis HINCRBY 保证原子性和高性能
redisTemplate.opsForHash().increment(RedisKey.STOREDATARELEASE, productKey, delta);
} catch (Exception e) {
logger.error("库存累失败productKey={}, delta={}, error={}", productKey, delta, e.getMessage(), e);
logger.error("库存累失败productKey={}, delta={}, error={}", productKey, delta, e.getMessage(), e);
}
}
}