| | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.convert.Convert; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.hutool.json.JSONObject; |
| | | import cn.hutool.json.JSONUtil; |
| | | import com.baomidou.mybatisplus.enums.SqlLike; |
| | | import com.baomidou.mybatisplus.mapper.Condition; |
| | | 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.common.enums.mall.EnumMallGoodsGroupType; |
| | | import com.sinata.common.enums.mall.EnumMallOrderState; |
| | | import com.sinata.core.base.controller.BaseController; |
| | | import com.sinata.core.common.annotion.BussinessLog; |
| | | import com.sinata.core.common.annotion.Permission; |
| | | import com.sinata.core.common.constant.factory.PageFactory; |
| | | import com.sinata.core.shiro.ShiroKit; |
| | | import com.sinata.core.shiro.ShiroUser; |
| | | import com.sinata.core.util.DateUtils2; |
| | | import com.sinata.core.util.ExcelExportUtil; |
| | | import com.sinata.core.util.ExpressApi; |
| | | import com.sinata.core.util.PayUtil; |
| | | import com.sinata.modular.mall.dto.OrderSearchDto; |
| | | import com.sinata.modular.mall.model.MallGoods; |
| | | import com.sinata.modular.mall.model.MallGoodsSet; |
| | | import com.sinata.modular.mall.model.MallOrder; |
| | | import com.sinata.modular.mall.model.MallOrderDetail; |
| | | import com.sinata.modular.mall.model.*; |
| | | import com.sinata.modular.mall.service.*; |
| | | import com.sinata.modular.member.model.MemUser; |
| | | 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.service.IMallOrderDetailUseService; |
| | | 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; |
| | |
| | | private IMemUserService memUserService; |
| | | |
| | | @Resource |
| | | private IMemUserRelationService userRelationService; |
| | | |
| | | @Resource |
| | | private IMyCouponService myCouponService; |
| | | |
| | | @Autowired |
| | | private IMallOrderService mallOrderService; |
| | | |
| | | @Resource |
| | | private IMallOrderDetailUseService useService; |
| | | |
| | | @Resource |
| | | private IMallGoodsSetService mallGoodsSetService; |
| | |
| | | @Resource |
| | | private IMallExpressCompanyService mallExpressCompanyService; |
| | | |
| | | @Resource |
| | | private IMallOrderDetailGroupSpecService mallOrderDetailGroupSpecService; |
| | | @Resource |
| | | private IRoleService roleService; |
| | | @Resource |
| | | private IMallGoodsSkuService mallGoodsSkuService; |
| | | |
| | | private MallOrder selectById(String orderNo) { |
| | | return this.mallOrderService.selectOne(new EntityWrapper<MallOrder>() |
| | |
| | | } |
| | | |
| | | /** |
| | | * 订单发货页面 |
| | | * 退款页面 |
| | | */ |
| | | @RequestMapping(value = "/deliverAuth/{orderNo}") |
| | | public String deliverAuth(@PathVariable String orderNo, Model model) { |
| | |
| | | /** |
| | | * 跳转商品订单详情 |
| | | */ |
| | | @RequestMapping(value = "/detail/{orderNo}") |
| | | public Object detail(@PathVariable("orderNo") String orderNo, Model model) { |
| | | @RequestMapping(value = "/detail") |
| | | public Object detail(String orderNo, Integer orderType, Model model) { |
| | | Page<MallOrder> page = new PageFactory().defaultPage(1, 0); |
| | | |
| | | Wrapper<?> wrapper = new EntityWrapper<MallOrder>() |
| | |
| | | |
| | | // 订单详情 |
| | | List<MallOrderDetail> orderDetailList = this.mallOrderDetailService.selectList(new EntityWrapper<MallOrderDetail>().eq("order_no", orderNo)); |
| | | |
| | | |
| | | // 订单详情-商品信息 |
| | | List<Integer> goodsIdList = orderDetailList.stream().map(MallOrderDetail::getGoodsId).collect(Collectors.toList()); |
| | | |
| | | // 订单详情套餐规格组商品 |
| | | List<MallOrderDetailGroupSpec> mallOrderDetailGroupSpecList = mallOrderDetailGroupSpecService.selectList(new EntityWrapper<MallOrderDetailGroupSpec>().eq("order_no", mallOrder.getOrderNo())); |
| | | if (CollUtil.isNotEmpty(mallOrderDetailGroupSpecList)) { |
| | | List<Integer> mallOrderDetailGroupSpecGroupSpecGoodsIds = mallOrderDetailGroupSpecList.stream().map(MallOrderDetailGroupSpec::getGroupSpecGoodsId).collect(Collectors.toList()); |
| | | goodsIdList.addAll(mallOrderDetailGroupSpecGroupSpecGoodsIds); |
| | | } |
| | | |
| | | List<MallGoods> goodsList = mallGoodsService.selectList(new EntityWrapper<MallGoods>().in("id", goodsIdList)); |
| | | |
| | | // 封装商品信息 |
| | |
| | | mallOrder.setUserPhone(memUser.getPhone()); |
| | | mallOrder.setUserNickname(memUser.getNickName()); |
| | | } |
| | | mallOrder.setUseList(useService.getUseList(mallOrder.getOrderNo())); |
| | | //mallOrder.setUseList(useService.getUseList(mallOrder.getOrderNo())); |
| | | mallOrder.setUseOrderDetailGroupSpecList(mallOrderDetailGroupSpecService.getUseOrderDetailGroupSpec(mallOrder.getOrderNo())); |
| | | model.addAttribute("item", mallOrder); |
| | | |
| | | String v4ShowId = "", v4Team = "", v5ShowId = "", v5Team = ""; |
| | | |
| | | // 计算订单业绩 |
| | | BigDecimal saleGoodsMoney = BigDecimal.ZERO; |
| | |
| | | if (saleUser.getMemberGradeId() == EnumMemberGrade.G_5.index) { |
| | | saleGoodsMoney = mallOrder.getPayMoney().multiply(goodsSet.getV5BuyCoef()); |
| | | } |
| | | |
| | | // 获取合伙人、市场总监 |
| | | MemUserRelation saleUserRelation = userRelationService.selectById(mallOrder.getSaleUserId()); |
| | | Integer saleUserMemberGradeId = saleUser.getMemberGradeId(); |
| | | MemUser[] parentV4V5User = userRelationService.getParentV4V5ByRelationPath(null, null, saleUserRelation.getRelationPath(), saleUserMemberGradeId); |
| | | if (parentV4V5User[0] != null) { |
| | | v4ShowId = parentV4V5User[0].getShowId(); |
| | | v4Team = parentV4V5User[0].getRealName(); |
| | | } |
| | | if (parentV4V5User[1] != null) { |
| | | v5ShowId = parentV4V5User[1].getShowId(); |
| | | v5Team = parentV4V5User[1].getRealName(); |
| | | } |
| | | |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | model.addAttribute("v4ShowId", v4ShowId); |
| | | model.addAttribute("v4Team", v4Team); |
| | | model.addAttribute("v5ShowId", v5ShowId); |
| | | model.addAttribute("v5Team", v5Team); |
| | | |
| | | model.addAttribute("saleGoodsMoney", saleGoodsMoney.setScale(2, BigDecimal.ROUND_HALF_UP)); |
| | | |
| | | return PREFIX + "mallOrder_detail.html"; |
| | | model.addAttribute("orderType", orderType); |
| | | if (orderType == null || orderType == EnumMallGoodsGroupType.GOODS.index) { |
| | | // 普通商品 |
| | | return PREFIX + "mallOrder_detail.html"; |
| | | } else { |
| | | model.addAttribute("mallOrderDetailGroupSpecList", mallOrderDetailGroupSpecList.stream() |
| | | .map(o -> { |
| | | JSONObject json = JSONUtil.parseObj(o); |
| | | |
| | | for (MallGoods g : goodsList) { |
| | | if (g.getId().equals(o.getGroupSpecGoodsId())) { |
| | | json.set("groupSpecGoodsName", g.getGoodsName()); |
| | | json.set("groupSpecGoodsNo", g.getGoodsNo()); |
| | | json.set("groupSpecGoodsImage", g.getGoodsImage()); |
| | | } |
| | | } |
| | | |
| | | return json; |
| | | }) |
| | | .collect(Collectors.toList())); |
| | | |
| | | // 套餐商品 |
| | | return PREFIX + "mallOrder_detail_group.html"; |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | .eq(StrUtil.isNotBlank(dto.getUserShowId()), "u.show_id", dto.getUserShowId()) |
| | | .eq(StrUtil.isNotBlank(dto.getUserPhone()), "u.phone", dto.getUserPhone()) |
| | | //.like(StrUtil.isNotBlank(dto.getUserNickname()), "user.nick_name", dto.getUserNickname()); |
| | | .like(StrUtil.isNotBlank(dto.getUserNickname()), "o.take_name", dto.getUserNickname()); |
| | | .like(StrUtil.isNotBlank(dto.getUserNickname()), "o.take_name", dto.getUserNickname()) |
| | | .like(StrUtil.isNotBlank(dto.getGoodsName()), "order_goods.goods_name", dto.getGoodsName()); |
| | | |
| | | try { |
| | | // 【城市管理员】数据查询 |
| | | ShiroUser shiroUser = ShiroKit.getUser(); |
| | | 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(); |
| | | } |
| | | |
| | | if (null != dto.getState()) { |
| | | if (dto.getState().equals(1)) { |
| | |
| | | "商品名称", |
| | | "规格组", |
| | | "购买数量", |
| | | "下单用户昵称", |
| | | "客户姓名", |
| | | "下单用户手机", |
| | | "预约门店", |
| | | "核销次数", |
| | |
| | | |
| | | |
| | | /** |
| | | * 退款 |
| | | * 退款操作 |
| | | */ |
| | | @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; |
| | | } |
| | | } |