新增移动端自提核销支持

main
alsszer 4 months ago
parent 4041ce666b
commit 5a07db3cdb

@ -19,6 +19,7 @@ public class LoginUser {
public static final String INFO_KEY_NICKNAME = "nickname";
public static final String INFO_KEY_DEPT_ID = "deptId";
public static final String INFO_KEY_MOBILE = "mobile";
/**
*

@ -112,6 +112,17 @@ public class SecurityFrameworkUtils {
return loginUser != null ? MapUtil.getLong(loginUser.getInfo(), LoginUser.INFO_KEY_DEPT_ID) : null;
}
/**
*
*
* @return
*/
@Nullable
public static String getLoginUserMobile() {
LoginUser loginUser = getLoginUser();
return loginUser != null ? MapUtil.getStr(loginUser.getInfo(), LoginUser.INFO_KEY_MOBILE) : null;
}
/**
*
*

@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.trade.controller.admin.order;
import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
import cn.iocoder.yudao.module.trade.controller.admin.order.vo.*;
@ -31,6 +32,7 @@ import java.util.Set;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.*;
@Tag(name = "管理后台 - 交易订单")
@RestController
@ -153,7 +155,10 @@ public class TradeOrderController {
@Parameter(name = "pickUpVerifyCode", description = "自提核销码")
@PreAuthorize("@ss.hasPermission('trade:order:pick-up')")
public CommonResult<Boolean> pickUpOrderByVerifyCode(@RequestParam("pickUpVerifyCode") String pickUpVerifyCode) {
tradeOrderUpdateService.pickUpOrderByAdmin(pickUpVerifyCode);
// 根据管理系统登录用户信息获取APP系统用户信息
String mobile = getLoginUserMobile();
MemberUserRespDTO userByMobile = memberUserApi.getUserByMobile(mobile);
tradeOrderUpdateService.pickUpOrderByAdmin(userByMobile.getId(),pickUpVerifyCode);
return success(true);
}

@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.trade.controller.app.order;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated;
import cn.iocoder.yudao.module.pay.api.notify.dto.PayOrderNotifyReqDTO;
import cn.iocoder.yudao.module.trade.controller.app.order.vo.*;
@ -17,6 +18,7 @@ import cn.iocoder.yudao.module.trade.service.aftersale.AfterSaleService;
import cn.iocoder.yudao.module.trade.service.delivery.DeliveryExpressService;
import cn.iocoder.yudao.module.trade.service.order.TradeOrderQueryService;
import cn.iocoder.yudao.module.trade.service.order.TradeOrderUpdateService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.google.common.collect.Maps;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
@ -32,6 +34,7 @@ import java.util.Map;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUser;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
@Tag(name = "用户 App - 交易订单")
@ -65,6 +68,9 @@ public class AppTradeOrderController {
@Operation(summary = "创建订单")
@PreAuthenticated
public CommonResult<AppTradeOrderCreateRespVO> createOrder(@Valid @RequestBody AppTradeOrderCreateReqVO createReqVO) {
LoginUser loginUser = getLoginUser();
createReqVO.setReceiverName(loginUser.getInfo().getOrDefault("nickname",""));
createReqVO.setReceiverMobile(loginUser.getInfo().getOrDefault("mobile",""));
TradeOrderDO order = tradeOrderUpdateService.createOrder(getLoginUserId(), createReqVO);
return success(new AppTradeOrderCreateRespVO().setId(order.getId()).setPayOrderId(order.getPayOrderId()));
}
@ -116,6 +122,13 @@ public class AppTradeOrderController {
return success(TradeOrderConvert.INSTANCE.convertPage02(pageResult, orderItems));
}
@GetMapping("/getPickUpVerifyCode")
@Operation(summary = "根据订单id获取自提核销码")
public CommonResult<String> getPickUpVerifyCode(String id) {
String pickUpVerifyCode = tradeOrderQueryService.getPickUpVerifyCode(id);
return success(pickUpVerifyCode);
}
@GetMapping("/get-count")
@Operation(summary = "获得交易订单数量")
public CommonResult<Map<String, Long>> getOrderCount() {

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.trade.controller.app.order.vo;
import cn.iocoder.yudao.module.trade.controller.app.order.vo.item.AppTradeOrderItemRespVO;
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@ -45,6 +46,19 @@ public class AppTradeOrderPageItemRespVO {
@Schema(description = "配送方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Integer deliveryType;
/**
*
*
* {@link DeliveryPickUpStoreDO#getId()}
*/
@Schema(description = "核销单位id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Long pickUpStoreId;
/**
*
*/
@Schema(description = "核销码", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private String pickUpVerifyCode;
/**
*
*/

@ -130,6 +130,7 @@ public class TradeOrderItemDO extends BaseDO {
*/
private Integer payPrice;
// ========== 营销基本信息 ==========
/**

@ -53,6 +53,20 @@ public interface BrokerageUserMapper extends BaseMapperX<BrokerageUserDO> {
update(null, lambdaUpdateWrapper);
}
/**
*
*
* @param id
* @param incrCount
*/
default void updateUserPriceByBindUserIdIncr(Long id, Integer incrCount) {
Assert.isTrue(incrCount > 0);
LambdaUpdateWrapper<BrokerageUserDO> lambdaUpdateWrapper = new LambdaUpdateWrapper<BrokerageUserDO>()
.setSql(" brokerage_price = brokerage_price + " + incrCount)
.eq(BrokerageUserDO::getBindUserId, id);
update(null, lambdaUpdateWrapper);
}
/**
*
*
@ -69,6 +83,22 @@ public interface BrokerageUserMapper extends BaseMapperX<BrokerageUserDO> {
return update(null, lambdaUpdateWrapper);
}
/**
*
*
*
* @param id
* @param incrCount
* @return
*/
default int updateUserPriceByBindUserIdDecr(Long id, Integer incrCount) {
Assert.isTrue(incrCount < 0);
LambdaUpdateWrapper<BrokerageUserDO> lambdaUpdateWrapper = new LambdaUpdateWrapper<BrokerageUserDO>()
.setSql(" brokerage_price = brokerage_price + " + incrCount) // 负数,所以使用 + 号
.eq(BrokerageUserDO::getBindUserId, id);
return update(null, lambdaUpdateWrapper);
}
/**
*
*

@ -124,4 +124,7 @@ public interface TradeOrderMapper extends BaseMapperX<TradeOrderDO> {
);
}
default String getPickUpVerifyCode(String id){
return selectOne(TradeOrderDO::getId, id).getPickUpVerifyCode();
};
}

@ -76,6 +76,16 @@ public interface BrokerageUserService {
*/
boolean updateUserPrice(Long id, Integer price);
/**
*
*
* @param id
* @param price
* @return
*/
boolean updateUserPriceByBindUserId(Long id, Integer price);
/**
*
*

@ -138,6 +138,16 @@ public class BrokerageUserServiceImpl implements BrokerageUserService {
return true;
}
@Override
public boolean updateUserPriceByBindUserId(Long id, Integer price) {
if (price > 0) {
brokerageUserMapper.updateUserPriceByBindUserIdIncr(id, price);
} else if (price < 0) {
return brokerageUserMapper.updateUserPriceByBindUserIdDecr(id, price) > 0;
}
return true;
}
@Override
public void updateUserFrozenPrice(Long id, Integer frozenPrice) {
if (frozenPrice > 0) {

@ -155,4 +155,5 @@ public interface TradeOrderQueryService {
*/
List<TradeOrderItemDO> getOrderItemListByOrderId(Collection<Long> orderIds);
String getPickUpVerifyCode(String id);
}

@ -248,6 +248,11 @@ public class TradeOrderQueryServiceImpl implements TradeOrderQueryService {
return tradeOrderItemMapper.selectListByOrderId(orderIds);
}
@Override
public String getPickUpVerifyCode(String id) {
return tradeOrderMapper.getPickUpVerifyCode(id);
}
/**
* AOP
*

@ -126,8 +126,9 @@ public interface TradeOrderUpdateService {
*
*
* @param pickUpVerifyCode
* @param id id
*/
void pickUpOrderByAdmin(String pickUpVerifyCode);
void pickUpOrderByAdmin(Long id, String pickUpVerifyCode);
/**
*

@ -40,6 +40,7 @@ import cn.iocoder.yudao.module.trade.enums.order.*;
import cn.iocoder.yudao.module.trade.framework.order.config.TradeOrderProperties;
import cn.iocoder.yudao.module.trade.framework.order.core.annotations.TradeOrderLog;
import cn.iocoder.yudao.module.trade.framework.order.core.utils.TradeOrderLogUtils;
import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageUserService;
import cn.iocoder.yudao.module.trade.service.cart.CartService;
import cn.iocoder.yudao.module.trade.service.delivery.DeliveryExpressService;
import cn.iocoder.yudao.module.trade.service.message.TradeMessageService;
@ -107,6 +108,10 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
@Resource
private TradeOrderProperties tradeOrderProperties;
@Resource
private BrokerageUserService brokerageUserService;
// =================== Order ===================
@Override
@ -679,7 +684,8 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
@Override
@TradeOrderLog(operateType = TradeOrderOperateTypeEnum.ADMIN_PICK_UP_RECEIVE)
public void pickUpOrderByAdmin(String pickUpVerifyCode) {
public void pickUpOrderByAdmin(Long id, String pickUpVerifyCode) {
boolean b = brokerageUserService.updateUserPriceByBindUserId(id, 30);
getSelf().pickUpOrder(tradeOrderMapper.selectOneByPickUpVerifyCode(pickUpVerifyCode));
}

@ -29,6 +29,7 @@ public interface MemberUserConvert {
@Mapping(source = "level", target = "level")
@Mapping(source = "bean.experience", target = "experience")
@Mapping(source = "bean.id",target = "id")
AppMemberUserInfoRespVO convert(MemberUserDO bean, MemberLevelDO level);
MemberUserRespDTO convert2(MemberUserDO bean);

@ -178,7 +178,8 @@ public class OAuth2TokenServiceImpl implements OAuth2TokenService {
if (userType.equals(UserTypeEnum.ADMIN.getValue())) {
AdminUserDO user = adminUserService.getUser(userId);
return MapUtil.builder(LoginUser.INFO_KEY_NICKNAME, user.getNickname())
.put(LoginUser.INFO_KEY_DEPT_ID, StrUtil.toStringOrNull(user.getDeptId())).build();
.put(LoginUser.INFO_KEY_DEPT_ID, StrUtil.toStringOrNull(user.getDeptId()))
.put(LoginUser.INFO_KEY_MOBILE,StrUtil.toStringOrNull(user.getMobile())).build();
} else if (userType.equals(UserTypeEnum.MEMBER.getValue())) {
// 注意:目前 Member 暂时不读取,可以按需实现
return Collections.emptyMap();

Loading…
Cancel
Save