| | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.baomidou.mybatisplus.plugins.Page; |
| | | import com.baomidou.mybatisplus.toolkit.CollectionUtils; |
| | | import com.google.common.collect.Lists; |
| | | import com.sinata.common.enums.EnumCityRole; |
| | | import com.sinata.common.enums.EnumMemberGrade; |
| | |
| | | import com.sinata.modular.member.model.MemUserRelation; |
| | | import com.sinata.modular.member.service.IMemUserRelationService; |
| | | import com.sinata.modular.member.service.IMemUserService; |
| | | import com.sinata.modular.system.model.Role; |
| | | import com.sinata.modular.system.service.IMyCouponService; |
| | | import com.sinata.modular.system.service.IRoleService; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.ui.Model; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | |
| | | |
| | | @Resource |
| | | private IMallOrderDetailGroupSpecService mallOrderDetailGroupSpecService; |
| | | |
| | | @Resource |
| | | private IRoleService roleService; |
| | | @Resource |
| | | private IMallGoodsSkuService mallGoodsSkuService; |
| | | |
| | | private MallOrder selectById(String orderNo) { |
| | | return this.mallOrderService.selectOne(new EntityWrapper<MallOrder>() |
| | |
| | | try { |
| | | // 【城市管理员】数据查询 |
| | | ShiroUser shiroUser = ShiroKit.getUser(); |
| | | if (shiroUser.getRoleList().contains(EnumCityRole.PROVINCE_ROLE.index)) { |
| | | // 省级城市管理员 |
| | | wrapper.like("o.city_code", shiroUser.getCityCode().substring(0, 2), SqlLike.RIGHT); |
| | | } else if (shiroUser.getRoleList().contains(EnumCityRole.CITY_ROLE.index)) { |
| | | List<Integer> roleList = shiroUser.getRoleList(); |
| | | List<Integer> cityRoleList = roleService.selectList( |
| | | new EntityWrapper<Role>().in("id", roleList)).stream().map(Role::getCityRole) |
| | | .collect( |
| | | Collectors.toList()); |
| | | if (cityRoleList.contains(EnumCityRole.CITY_ROLE.index)) { |
| | | // 市级城市管理员 |
| | | wrapper.like("o.city_code", shiroUser.getCityCode().substring(0, 4), SqlLike.RIGHT); |
| | | } |
| | | else if (cityRoleList.contains(EnumCityRole.PROVINCE_ROLE.index)) { |
| | | // 省级城市管理员 |
| | | wrapper.like("o.city_code", shiroUser.getCityCode().substring(0, 2), SqlLike.RIGHT); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | |
| | | */ |
| | | @ResponseBody |
| | | @RequestMapping(value = "/orderShip") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Object orderShip(String orderNo, Integer expressCompany) { |
| | | MallOrder order = this.mallOrderService.selectOne( |
| | | new EntityWrapper<MallOrder>() |
| | |
| | | } |
| | | |
| | | this.mallOrderService.updateById(order); |
| | | |
| | | //退回库存 |
| | | List<MallOrderDetail> orderDetailList = this.mallOrderDetailService.selectList(new EntityWrapper<MallOrderDetail>().eq("order_no", orderNo)); |
| | | if (CollectionUtils.isNotEmpty(orderDetailList)) { |
| | | Map<Integer, MallOrderDetail> orderDetailMap = orderDetailList.stream() |
| | | .collect(Collectors.toMap(MallOrderDetail::getSkuId, e -> e)); |
| | | Set<Integer> skuIdList = orderDetailList.stream().map(MallOrderDetail::getSkuId) |
| | | .collect(Collectors.toSet()); |
| | | List<MallGoodsSku> skuList = mallGoodsSkuService.selectList( |
| | | new EntityWrapper<MallGoodsSku>().in("id", skuIdList)); |
| | | for (MallGoodsSku mallGoodsSku : skuList) { |
| | | MallOrderDetail mallOrderDetail = orderDetailMap.get(mallGoodsSku.getId()); |
| | | mallGoodsSku.setStock(mallGoodsSku.getStock() + mallOrderDetail.getGoodsNum()); |
| | | mallGoodsSkuService.updateById(mallGoodsSku); |
| | | } |
| | | } |
| | | return SUCCESS_TIP; |
| | | } |
| | | } |