| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.math.BigDecimal; |
| | | import java.security.NoSuchAlgorithmException; |
| | | import java.util.*; |
| | | |
| | |
| | | private SysGoodsTypeDao sysGoodsTypeDao; |
| | | @Autowired |
| | | private ShoppingGoodsDao shoppingGoodsDao; |
| | | @Autowired |
| | | private ShoppingGoodsAssembleDao shoppingGoodsAssembleDao; |
| | | |
| | | @Autowired |
| | | private RedisClient redisClient; |
| | |
| | | list.add(object); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | public <T> T mapToBane(Map<String, Object> map, Class<T> t) { |
| | | String s = JSONObject.toJSONString(map); |
| | | return JSONObject.parseObject(s, t); |
| | | } |
| | | |
| | | /** |
| | |
| | | vipInfoIds.put(oldId, sysVipInfo.getId()); |
| | | sysVipInfoService.addVipDefaultCard(sysVipInfo.getId()); |
| | | } |
| | | |
| | | redisClient.saveMapValue("vip_info", vipInfoIds); |
| | | } |
| | | } |
| | | |
| | |
| | | List<Map<String, Object>> maps = jdbcTemplate.queryForList("select * from shopping_goods where good_type='"+goodType+"'"); |
| | | List<ShoppingGoods> shoppingGoods = mapsToListBean(maps, ShoppingGoods.class); |
| | | |
| | | |
| | | Map<String, Integer> goodsTypeIds = getRedisIds("goods_type"); |
| | | Map<String, Integer> supplierInfoIds = getRedisIds("supplier_info"); |
| | | for (ShoppingGoods shoppingGood : shoppingGoods) { |
| | |
| | | |
| | | shoppingGood.setGoodsNo((String) sysGoods.get("goods_no")); |
| | | shoppingGood.setCode((String) sysGoods.get("goods_no")); |
| | | shoppingGood.setName(goodsName+ "->" + (String) sysGoods.get("name")); |
| | | shoppingGood.setName(goodsName+ "->" + sysGoods.get("name")); |
| | | shoppingGood.setUnit((String) sysGoods.get("unit")); |
| | | shoppingGood.setMeasure((String) sysGoods.get("measure")); |
| | | shoppingGood.setAlarmNum((Integer) sku.get("alarm_num")); |
| | |
| | | |
| | | shoppingGood.setWeiDescription("数据迁移"); |
| | | |
| | | shoppingGood.setId((Long) goodsAssemble.get("assemble_proj_id")); |
| | | } |
| | | return shoppingGoods; |
| | | } |
| | | |
| | | @DS("slave") |
| | | public List<ShoppingGoods> shoppingGoodsTcList() { |
| | | return null; |
| | | List<Map<String, Object>> maps = jdbcTemplate.queryForList("select * from shopping_goods where good_type='套餐'"); |
| | | List<ShoppingGoods> shoppingGoods = mapsToListBean(maps, ShoppingGoods.class); |
| | | |
| | | Map<String, Integer> goodsSku = getRedisIds("shopping_goods_sku"); |
| | | Map<String, Integer> goodProj = getRedisIds("shopping_goods_proj"); |
| | | Map<String, Integer> goodsTypeIds = getRedisIds("goods_type"); |
| | | Map<String, Integer> supplierInfoIds = getRedisIds("supplier_info"); |
| | | |
| | | List<Long> projExist = new ArrayList<>(); |
| | | List<Long> skuExist = new ArrayList<>(); |
| | | for (ShoppingGoods shoppingGood : shoppingGoods) { |
| | | List<Map<String, Object>> assembles = jdbcTemplate.queryForList("select * from shopping_goods_assemble where shopping_goods_id=" + shoppingGood.getId()); |
| | | |
| | | shoppingGood.setCompanyId(companyId); |
| | | shoppingGood.setHeadquarters(1); |
| | | shoppingGood.setIsDel(1); |
| | | shoppingGood.setZjm(StringUtils.toHanyuPinyin(shoppingGood.getName()) + "," + StringUtils.toHeadWordHanyuPinyin(shoppingGood.getName())); |
| | | |
| | | shoppingGood.setWeiDescription("数据迁移-tc"); |
| | | |
| | | List<ShoppingGoodsAssemble> assembleList = mapsToListBean(assembles, ShoppingGoodsAssemble.class); |
| | | |
| | | for (ShoppingGoodsAssemble assembleGood : assembleList) { |
| | | if(assembleGood.getAssembleSkuId() != null) { |
| | | Integer skuId = goodsSku.get(assembleGood.getAssembleSkuId().toString()); |
| | | // assembleGood.setAssembleSkuId(null); |
| | | |
| | | if (skuId == null && !skuExist.contains(assembleGood.getAssembleSkuId())) { |
| | | Map<String, Object> goodsMap = jdbcTemplate.queryForMap("select * from shopping_goods where id=" + assembleGood.getShoppingGoodsId()); |
| | | ShoppingGoods goods = mapToBane(goodsMap, ShoppingGoods.class); |
| | | |
| | | Map<String, Object> sku = jdbcTemplate.queryForMap("select * from sku where id=" + assembleGood.getAssembleSkuId()); |
| | | Map<String, Object> sysGoods = jdbcTemplate.queryForMap("select * from sys_goods where id=" + sku.get("goods_id")); |
| | | |
| | | goods.setGoodsNo((String) sysGoods.get("goods_no")); |
| | | goods.setCode((String) sysGoods.get("goods_no")); |
| | | goods.setName(goods.getName()+ "->" + sysGoods.get("name")); |
| | | goods.setUnit((String) sysGoods.get("unit")); |
| | | goods.setMeasure((String) sysGoods.get("measure")); |
| | | goods.setAlarmNum((Integer) sku.get("alarm_num")); |
| | | goods.setHeadquarters(1); |
| | | goods.setIsDel(1); |
| | | goods.setGoodType("家居产品"); |
| | | goods.setZjm(StringUtils.toHanyuPinyin(shoppingGood.getName()) + "," + StringUtils.toHeadWordHanyuPinyin(shoppingGood.getName())); |
| | | |
| | | goods.setWeiDescription("数据迁移-tc"); |
| | | Integer goodsSortId = goodsTypeIds.get(sysGoods.get("goods_sort_id").toString()); |
| | | goods.setGoodsSortId(Long.parseLong(goodsSortId.toString())); |
| | | |
| | | Integer supplierId = supplierInfoIds.get(sysGoods.get("supplier_id").toString()); |
| | | if (supplierId != null) { |
| | | shoppingGood.setSupplierId(Long.parseLong(supplierId.toString())); |
| | | } |
| | | |
| | | assembleGood.setShoppingGoods(goods); |
| | | skuExist.add(assembleGood.getAssembleSkuId()); |
| | | } else { |
| | | if (skuId != null) { |
| | | assembleGood.setAssembleGoodId(skuId.longValue()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (assembleGood.getAssembleProjId() != null) { |
| | | Integer projId = goodProj.get(assembleGood.getAssembleProjId().toString()); |
| | | |
| | | // 若为空,则需创建一个shopping_goods |
| | | if (projId == null && !projExist.contains(assembleGood.getAssembleProjId())) { |
| | | Map<String, Object> goodsMap = jdbcTemplate.queryForMap("select * from shopping_goods where id=" + assembleGood.getShoppingGoodsId()); |
| | | ShoppingGoods goods = mapToBane(goodsMap, ShoppingGoods.class); |
| | | Map<String, Object> projMap = jdbcTemplate.queryForMap("select * from sys_proj_info where id=" + assembleGood.getAssembleProjId()); |
| | | |
| | | goods.setTimeLength((Integer) projMap.get("time_length")); |
| | | goods.setCode((String) projMap.get("proj_no")); |
| | | goods.setCompanyId(companyId); |
| | | goods.setHeadquarters(1); |
| | | goods.setIsDel(1); |
| | | goods.setGoodType("项目"); |
| | | goods.setZjm(StringUtils.toHanyuPinyin(goods.getName()) + "," + StringUtils.toHeadWordHanyuPinyin(goods.getName())); |
| | | |
| | | goods.setWeiDescription("数据迁移-tc"); |
| | | assembleGood.setShoppingGoods(goods); |
| | | projExist.add(assembleGood.getAssembleProjId()); |
| | | } else { |
| | | if (projId != null) { |
| | | assembleGood.setAssembleGoodId(projId.longValue()); |
| | | } |
| | | } |
| | | |
| | | // assembleGood.setAssembleProjId(null); |
| | | } |
| | | } |
| | | |
| | | if (CollUtil.isNotEmpty(assembleList)) { |
| | | shoppingGood.setAssembleGoods(assembleList); |
| | | } |
| | | } |
| | | return shoppingGoods; |
| | | } |
| | | |
| | | @DS("slave") |
| | | public List<ShoppingGoods> shoppingGoodsCzkOld() { |
| | | List<Map<String, Object>> maps = jdbcTemplate.queryForList("select * from shopping_goods where good_type='充值卡'"); |
| | | List<ShoppingGoods> shoppingGoods = mapsToListBean(maps, ShoppingGoods.class); |
| | | |
| | | for (ShoppingGoods shoppingGood : shoppingGoods) { |
| | | shoppingGood.setCompanyId(companyId); |
| | | shoppingGood.setHeadquarters(1); |
| | | shoppingGood.setIsDel(1); |
| | | shoppingGood.setZjm(StringUtils.toHanyuPinyin(shoppingGood.getName()) + "," + StringUtils.toHeadWordHanyuPinyin(shoppingGood.getName())); |
| | | |
| | | shoppingGood.setWeiDescription("数据迁移"); |
| | | } |
| | | |
| | | return shoppingGoods; |
| | | } |
| | | |
| | | @DS("slave") |
| | | public List<ShoppingGoods> shoppingGoodsZhkOld() { |
| | | List<Map<String, Object>> maps = jdbcTemplate.queryForList("select * from shopping_goods where good_type='综合卡'"); |
| | | List<ShoppingGoods> shoppingGoods = mapsToListBean(maps, ShoppingGoods.class); |
| | | |
| | | |
| | | Map<String, Integer> goodsSku = getRedisIds("shopping_goods_sku"); |
| | | Map<String, Integer> goodProj = getRedisIds("shopping_goods_proj"); |
| | | Map<String, Integer> goodTc = getRedisIds("shopping_goods_tc"); |
| | | Map<String, Integer> goodCzk = getRedisIds("shopping_goods_czk"); |
| | | for (ShoppingGoods shoppingGood : shoppingGoods) { |
| | | List<Map<String, Object>> assembles = jdbcTemplate.queryForList("select * from shopping_goods_assemble where shopping_goods_id=" + shoppingGood.getId()); |
| | | |
| | | List<ShoppingGoodsAssemble> assembleList = mapsToListBean(assembles, ShoppingGoodsAssemble.class); |
| | | for (ShoppingGoodsAssemble shoppingGoodsAssemble : assembleList) { |
| | | Long goodsId = shoppingGoodsAssemble.getAssembleGoodId(); |
| | | System.out.println("----->" + goodsId); |
| | | if (goodsId == 8521 || goodsId == 8522) { |
| | | continue; |
| | | } |
| | | Map<String, Object> goodsMap = jdbcTemplate.queryForMap("select * from shopping_goods where id=" + goodsId); |
| | | ShoppingGoods goods = mapToBane(goodsMap, ShoppingGoods.class); |
| | | if ("套餐".equals(goods.getGoodType())) { |
| | | Integer tcId = goodTc.get(goodsId.toString()); |
| | | shoppingGoodsAssemble.setAssembleGoodId(tcId.longValue()); |
| | | } else if("充值卡".equals(goods.getGoodType())) { |
| | | Integer czkId = goodCzk.get(goodsId.toString()); |
| | | shoppingGoodsAssemble.setShoppingGoodsId(czkId.longValue()); |
| | | } else if ("家居产品".equals(goods.getGoodType())) { |
| | | Map<String, Object> skuMap = jdbcTemplate.queryForMap("select * from shopping_goods_assemble where shopping_goods_id=" + goods.getId()); |
| | | ShoppingGoodsAssemble sku = mapToBane(skuMap, ShoppingGoodsAssemble.class); |
| | | Integer skuId = goodsSku.get(sku.getAssembleSkuId().toString()); |
| | | shoppingGoodsAssemble.setAssembleGoodId(skuId.longValue()); |
| | | } else if ("项目".equals(goods.getGoodType())) { |
| | | Map<String, Object> projMap = jdbcTemplate.queryForMap("select * from shopping_goods_assemble where shopping_goods_id=" + goods.getId()); |
| | | ShoppingGoodsAssemble proj = mapToBane(projMap, ShoppingGoodsAssemble.class); |
| | | Integer projId = goodProj.get(proj.getAssembleProjId().toString()); |
| | | shoppingGoodsAssemble.setAssembleGoodId(projId.longValue()); |
| | | } |
| | | } |
| | | |
| | | shoppingGood.setAssembleGoods(assembleList); |
| | | } |
| | | |
| | | return shoppingGoods; |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void shoppingGoodsNew(List<ShoppingGoods> list) { |
| | | public void shoppingGoodsNew(List<ShoppingGoods> list, String goodsType) { |
| | | if (CollUtil.isNotEmpty(list)) { |
| | | Map<Long, Long> map = new HashMap<>(); |
| | | Map<String, Integer> goodsCategory = getRedisIds("goods_category"); |
| | | |
| | | Map<String, Integer> goodsSku = getRedisIds("shopping_goods_sku"); |
| | | Map<String, Integer> goodProj = getRedisIds("shopping_goods_proj"); |
| | | Map<Long, Long> sku = new HashMap<>(); |
| | | Map<Long, Long> proj = new HashMap<>(); |
| | | for (ShoppingGoods shoppingGoods : list) { |
| | | shoppingGoods.setCompanyId(companyId); |
| | | |
| | | Integer cateId = goodsCategory.get(shoppingGoods.getCateId().toString()); |
| | | if (cateId != null) { |
| | | shoppingGoods.setCateId(Long.parseLong(cateId.toString())); |
| | | if (shoppingGoods.getCateId() != null) { |
| | | Integer cateId = goodsCategory.get(shoppingGoods.getCateId().toString()); |
| | | if (cateId != null) { |
| | | shoppingGoods.setCateId(Long.parseLong(cateId.toString())); |
| | | } |
| | | } |
| | | |
| | | Long oldId = shoppingGoods.getId(); |
| | | shoppingGoods.setId(null); |
| | | shoppingGoodsDao.insert(shoppingGoods); |
| | | map.put(oldId, shoppingGoods.getId()); |
| | | |
| | | if ("套餐".equals(goodsType)) { |
| | | List<ShoppingGoodsAssemble> assembleGoods = shoppingGoods.getAssembleGoods(); |
| | | if (CollUtil.isNotEmpty(assembleGoods)) { |
| | | for (ShoppingGoodsAssemble assembleGood : assembleGoods) { |
| | | assembleGood.setShoppingGoodsId(shoppingGoods.getId()); |
| | | |
| | | Long oldIdTc = assembleGood.getAssembleSkuId() == null ? assembleGood.getAssembleProjId() : assembleGood.getAssembleSkuId(); |
| | | if (assembleGood.getShoppingGoods() != null) { |
| | | |
| | | assembleGood.getShoppingGoods().setId(null); |
| | | shoppingGoodsDao.insert(assembleGood.getShoppingGoods()); |
| | | |
| | | if (assembleGood.getAssembleSkuId() == null) { |
| | | proj.put(oldIdTc, assembleGood.getShoppingGoods().getId()); |
| | | goodProj.put(oldIdTc.toString(), assembleGood.getShoppingGoods().getId().intValue()); |
| | | } else { |
| | | sku.put(oldIdTc, assembleGood.getShoppingGoods().getId()); |
| | | goodsSku.put(oldIdTc.toString(), assembleGood.getShoppingGoods().getId().intValue()); |
| | | } |
| | | assembleGood.setAssembleGoodId(assembleGood.getShoppingGoods().getId()); |
| | | |
| | | } else { |
| | | if (assembleGood.getAssembleSkuId() == null) { |
| | | Integer projTc = goodProj.get(oldIdTc.toString()); |
| | | Long goodsId = null; |
| | | if (projTc == null) { |
| | | goodsId = proj.get(oldIdTc); |
| | | } else { |
| | | goodsId = projTc.longValue(); |
| | | } |
| | | |
| | | assembleGood.setAssembleGoodId(goodsId); |
| | | } else { |
| | | Integer skuTc = goodsSku.get(oldIdTc.toString()); |
| | | Long goodsId = null; |
| | | if (skuTc == null) { |
| | | goodsId = sku.get(oldIdTc); |
| | | } else { |
| | | goodsId = skuTc.longValue(); |
| | | } |
| | | |
| | | assembleGood.setAssembleGoodId(goodsId); |
| | | } |
| | | |
| | | } |
| | | assembleGood.setId(null); |
| | | } |
| | | shoppingGoodsAssembleDao.batchInsert(assembleGoods); |
| | | } |
| | | } |
| | | } |
| | | |
| | | redisClient.saveMapValue("shopping_goods_sku", map); |
| | | if ("家居产品".equals(goodsType)) { |
| | | redisClient.saveMapValue("shopping_goods_sku", map); |
| | | } else if ("项目".equals(goodsType)) { |
| | | redisClient.saveMapValue("shopping_goods_proj", map); |
| | | } else if ("套餐".equals(goodsType)) { |
| | | redisClient.saveMapValue("shopping_goods_tc", map); |
| | | redisClient.saveMapValue("shopping_goods_sku", goodsSku); |
| | | redisClient.saveMapValue("shopping_goods_proj", goodProj); |
| | | } else if ("充值卡".equals(goodsType)) { |
| | | redisClient.saveMapValue("shopping_goods_czk", map); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void shoppingGoodsZhkNew(List<ShoppingGoods> list) { |
| | | if (CollUtil.isNotEmpty(list)) { |
| | | Map<Long, Long> map = new HashMap<>(); |
| | | Map<String, Integer> goodsCategory = getRedisIds("goods_category"); |
| | | |
| | | for (ShoppingGoods shoppingGoods : list) { |
| | | shoppingGoods.setCompanyId(companyId); |
| | | |
| | | if (shoppingGoods.getCateId() != null) { |
| | | Integer cateId = goodsCategory.get(shoppingGoods.getCateId().toString()); |
| | | if (cateId != null) { |
| | | shoppingGoods.setCateId(Long.parseLong(cateId.toString())); |
| | | } |
| | | } |
| | | |
| | | Long oldId = shoppingGoods.getId(); |
| | | shoppingGoods.setId(null); |
| | | shoppingGoodsDao.insert(shoppingGoods); |
| | | map.put(oldId, shoppingGoods.getId()); |
| | | |
| | | for (ShoppingGoodsAssemble assembleGood : shoppingGoods.getAssembleGoods()) { |
| | | assembleGood.setShoppingGoodsId(shoppingGoods.getId()); |
| | | assembleGood.setId(null); |
| | | } |
| | | |
| | | shoppingGoodsAssembleDao.batchInsert(shoppingGoods.getAssembleGoods()); |
| | | |
| | | } |
| | | |
| | | redisClient.saveMapValue("shopping_goods_zhk", map); |
| | | } |
| | | } |
| | | |
| | | public Map<String, Integer> getRedisIds(String key) { |
| | | String idsStr = redisClient.getCachedValue(key); |
| | | return JSONObject.parseObject(idsStr, HashMap.class); |
| | | } |
| | | |
| | | @DS("slave") |
| | | public List<SysOrder> orderOld() { |
| | | List<Map<String, Object>> maps = jdbcTemplate.queryForList("select * from sys_order"); |
| | | List<SysOrder> orders = mapsToListBean(maps, SysOrder.class); |
| | | |
| | | |
| | | Map<String, Integer> goodsSku = getRedisIds("shopping_goods_sku"); |
| | | Map<String, Integer> goodProj = getRedisIds("shopping_goods_proj"); |
| | | Map<String, Integer> goodTc = getRedisIds("shopping_goods_tc"); |
| | | Map<String, Integer> goodCZK = getRedisIds("shopping_goods_czk"); |
| | | Map<String, Integer> goodZHK = getRedisIds("shopping_goods_zhk"); |
| | | Map<String, Integer> shopIds = getRedisIds("shopId"); |
| | | Map<String, Integer> sysUsers = getRedisIds("sys_users"); |
| | | Map<String, Integer> vipInfos = getRedisIds("vip_info"); |
| | | for (SysOrder order : orders) { |
| | | List<Map<String, Object>> itemsMap = jdbcTemplate.queryForList("select * from sys_order_item where ORDER_ID=" + order.getId()); |
| | | |
| | | Integer shopId = shopIds.get(order.getShopId().toString()); |
| | | order.setShopId(shopId.longValue()); |
| | | |
| | | Integer statffId = sysUsers.get(order.getStaffId().toString()); |
| | | if (statffId != null) { |
| | | order.setStaffId(statffId.longValue()); |
| | | } else { |
| | | order.setStaffId(-order.getStaffId()); |
| | | } |
| | | Integer vipId = vipInfos.get(order.getVipId().toString()); |
| | | if (vipId != null) { |
| | | order.setVipId(vipId.longValue()); |
| | | } else { |
| | | order.setVipId(-order.getVipId()); |
| | | } |
| | | |
| | | order.setCompanyId(companyId); |
| | | |
| | | List<SysOrderItem> items = mapsToListBean(itemsMap, SysOrderItem.class); |
| | | |
| | | Double cardPay = 0D; |
| | | Double cashPay = 0D; |
| | | Double arrears = 0D; |
| | | Map<Long, Long> shoppingGoodsIds = new HashMap<>(); |
| | | if (CollUtil.isNotEmpty(items)) { |
| | | Long goodsId = items.get(0).getGoodsId(); |
| | | Map<String, Object> goods = jdbcTemplate.queryForMap("select * from shopping_goods where id=" + goodsId); |
| | | order.setShopShortName((String) goods.get("name")); |
| | | for (SysOrderItem item : items) { |
| | | Double itemCard = item.getCardPay() == null ? 0D : item.getCardPay(); |
| | | Double itemCash = item.getCashPay() == null ? 0D : item.getCashPay(); |
| | | Double itemArrears = item.getArrears() == null ? 0D : item.getArrears(); |
| | | |
| | | cardPay += itemCard; |
| | | cashPay += itemCash; |
| | | arrears += itemArrears; |
| | | |
| | | if (itemCard != 0) { |
| | | item.setPayMethod("划扣"); |
| | | } else { |
| | | item.setPayMethod("现金"); |
| | | } |
| | | |
| | | Long oldID = item.getGoodsId(); |
| | | switch (item.getType()) { |
| | | case "家居产品" : |
| | | Map<String, Object> skuMap = jdbcTemplate.queryForMap("select * from shopping_goods_assemble where id=" + item.getAssembleId()); |
| | | Long skuId = (Long) skuMap.get("assemble_sku_id"); |
| | | Integer skuGoodsId = goodsSku.get(skuId.toString()); |
| | | if (skuGoodsId != null) { |
| | | item.setGoodsId(skuGoodsId.longValue()); |
| | | } else { |
| | | item.setGoodsId(-item.getAssembleId()); |
| | | } |
| | | break; |
| | | case "项目" : |
| | | Map<String, Object> projMap = jdbcTemplate.queryForMap("select * from shopping_goods_assemble where id=" + item.getAssembleId()); |
| | | Long projId = (Long) projMap.get("assemble_proj_id"); |
| | | Integer projGoodsId = goodProj.get(projId.toString()); |
| | | if (projGoodsId != null) { |
| | | item.setGoodsId(projGoodsId.longValue()); |
| | | } else { |
| | | item.setGoodsId(-item.getAssembleId()); |
| | | } |
| | | break; |
| | | case "套餐" : |
| | | Integer tcId = goodTc.get(item.getGoodsId().toString()); |
| | | if (tcId != null) { |
| | | item.setGoodsId(tcId.longValue()); |
| | | } else { |
| | | item.setGoodsId(-item.getGoodsId()); |
| | | } |
| | | break; |
| | | case "充值卡" : |
| | | Integer czkId = goodCZK.get(item.getGoodsId().toString()); |
| | | if (czkId != null) { |
| | | item.setGoodsId(czkId.longValue()); |
| | | } else { |
| | | item.setGoodsId(-item.getGoodsId()); |
| | | } |
| | | break; |
| | | case "综合卡" : |
| | | Integer zhkId = goodZHK.get(item.getGoodsId().toString()); |
| | | if (zhkId != null) { |
| | | item.setGoodsId(zhkId.longValue()); |
| | | } else { |
| | | item.setGoodsId(-item.getGoodsId()); |
| | | } |
| | | break; |
| | | default: |
| | | } |
| | | |
| | | shoppingGoodsIds.put(oldID, item.getGoodsId()); |
| | | } |
| | | order.setItems(items); |
| | | } |
| | | |
| | | List<SysOrderFlow> flows = new ArrayList<>(); |
| | | if (cardPay != 0D) { |
| | | flows.add(setOrderFLow(order, "储值卡", cardPay, 1)); |
| | | } |
| | | |
| | | if (cashPay != 0D) { |
| | | flows.add(setOrderFLow(order, "现金支付", cashPay, 1)); |
| | | } |
| | | |
| | | if (arrears != 0D) { |
| | | flows.add(setOrderFLow(order, "欠款", arrears, 1)); |
| | | } |
| | | order.setFlows(flows); |
| | | |
| | | List<Map<String, Object>> achievesMap = jdbcTemplate.queryForList("select sale_id, beault_id, shop_id, datatime, order_id, order_item_id, shopping_goods_id, vip_id, order_type, sum(t1) as t1 from achieve_new where order_type='订单' and order_id="+ order.getId() + " group by sale_id, beault_id, shop_id, datatime, order_id, order_item_id, shopping_goods_id, vip_id, order_type"); |
| | | if (CollUtil.isNotEmpty(achievesMap)) { |
| | | List<AchieveNew> achieves = mapsToListBean(achievesMap, AchieveNew.class); |
| | | for (AchieveNew achieve : achieves) { |
| | | Integer achiShopId = shopIds.get(achieve.getShopId().toString()); |
| | | achieve.setShopId(achiShopId.longValue()); |
| | | |
| | | if (achieve.getBeaultId() == null) { |
| | | achieve.setBeaultId(achieve.getSaleId()); |
| | | achieve.setAchieveType("顾问业绩"); |
| | | } else { |
| | | achieve.setAchieveType("美疗师业绩"); |
| | | } |
| | | Integer beaultId = sysUsers.get(achieve.getBeaultId().toString()); |
| | | if (beaultId != null) { |
| | | achieve.setBeaultId(beaultId.longValue()); |
| | | } else { |
| | | achieve.setBeaultId(-achieve.getBeaultId()); |
| | | } |
| | | |
| | | Integer saleId = sysUsers.get(achieve.getSaleId().toString()); |
| | | if (saleId != null) { |
| | | achieve.setSaleId(saleId.longValue()); |
| | | } else { |
| | | achieve.setSaleId(-achieve.getSaleId()); |
| | | } |
| | | |
| | | Integer achiVipId = vipInfos.get(achieve.getVipId().toString()); |
| | | if (achiVipId != null) { |
| | | achieve.setVipId(achiVipId.longValue()); |
| | | } else { |
| | | achieve.setVipId(-achieve.getVipId()); |
| | | } |
| | | achieve.setGoodsCash(Double.parseDouble(achieve.getT1())); |
| | | achieve.setCompanyId(companyId); |
| | | achieve.setShoppingGoodsId(shoppingGoodsIds.get(achieve.getShoppingGoodsId())); |
| | | |
| | | } |
| | | order.setAchieveNews(achieves); |
| | | } |
| | | } |
| | | return orders; |
| | | } |
| | | |
| | | public SysOrderFlow setOrderFLow(SysOrder sysOrder, String type, Double amount, int index) { |
| | | SysOrderFlow flow = new SysOrderFlow(); |
| | | flow.setFlowContent(sysOrder.getShopShortName() + "等" + sysOrder.getItems().size() + "件产品"); |
| | | flow.setFlowType(SysOrderFlow.FLOW_TYPE_BUY); |
| | | flow.setAmount(new BigDecimal(amount)); |
| | | flow.setFlowNo("F" + sysOrder.getOrderNo() + "-" + index); |
| | | flow.setVipId(sysOrder.getVipId()); |
| | | flow.setShopId(sysOrder.getShopId()); |
| | | flow.setCompanyId(sysOrder.getCompanyId()); |
| | | flow.setPayMethod(type); |
| | | return flow; |
| | | } |
| | | |
| | | @Autowired |
| | | private SysOrderDao sysOrderDao; |
| | | @Autowired |
| | | private SysOrderItemDao sysOrderItemDao; |
| | | @Autowired |
| | | private SysOrderFlowDao sysOrderFlowDao; |
| | | @Autowired |
| | | private AchieveNewDao achieveNewDao; |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void orderNew(List<SysOrder> list) { |
| | | if (CollUtil.isNotEmpty(list)) { |
| | | Map<Long, Long> orderIds = new HashMap<>(); |
| | | Map<Long, Long> itemIds = new HashMap<>(); |
| | | |
| | | for (SysOrder sysOrder : list) { |
| | | Long oldOrderId = sysOrder.getId(); |
| | | sysOrder.setId(null); |
| | | sysOrderDao.insert(sysOrder); |
| | | orderIds.put(oldOrderId, sysOrder.getId()); |
| | | |
| | | if (CollUtil.isNotEmpty(sysOrder.getItems())) { |
| | | for (SysOrderItem item : sysOrder.getItems()) { |
| | | Long oldItemId = item.getId(); |
| | | item.setOrderId(sysOrder.getId()); |
| | | item.setId(null); |
| | | sysOrderItemDao.insert(item); |
| | | itemIds.put(oldItemId, item.getId()); |
| | | } |
| | | } |
| | | |
| | | if (CollUtil.isNotEmpty(sysOrder.getFlows())) { |
| | | for (SysOrderFlow flow : sysOrder.getFlows()) { |
| | | flow.setOrderId(oldOrderId); |
| | | sysOrderFlowDao.insert(flow); |
| | | } |
| | | } |
| | | |
| | | if (CollUtil.isNotEmpty(sysOrder.getAchieveNews())) { |
| | | for (AchieveNew achieveNew : sysOrder.getAchieveNews()) { |
| | | achieveNew.setOrderId(oldOrderId); |
| | | Long item = itemIds.get(achieveNew.getOrderItemId()); |
| | | achieveNew.setOrderItemId(item); |
| | | } |
| | | |
| | | achieveNewDao.batchInsert(sysOrder.getAchieveNews()); |
| | | } |
| | | } |
| | | |
| | | redisClient.saveMapValue("order", orderIds); |
| | | redisClient.saveMapValue("order_item", itemIds); |
| | | } |
| | | } |
| | | |
| | | @DS("slave") |
| | | public List<SysBedInfo> bedInfoOld() { |
| | | List<Map<String, Object>> maps = jdbcTemplate.queryForList("select * from sys_bed_info"); |
| | | List<SysBedInfo> beds = mapsToListBean(maps, SysBedInfo.class); |
| | | |
| | | Map<String, Integer> shopIds = getRedisIds("shopId"); |
| | | for (SysBedInfo bed : beds) { |
| | | Integer shopId = shopIds.get(bed.getShopId().toString()); |
| | | if (shopId != null) { |
| | | bed.setShopId(shopId.longValue()); |
| | | } else { |
| | | bed.setShopId(-bed.getShopId()); |
| | | } |
| | | } |
| | | return beds; |
| | | } |
| | | |
| | | @Autowired |
| | | private SysBedInfoDao sysBedInfoDao; |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void bedInfoNew(List<SysBedInfo> list) { |
| | | if (CollUtil.isNotEmpty(list)) { |
| | | Map<Long, Long> map = new HashMap<>(); |
| | | for (SysBedInfo bed : list) { |
| | | Long oldId = bed.getId(); |
| | | bed.setId(null); |
| | | sysBedInfoDao.insert(bed); |
| | | map.put(oldId, bed.getId()); |
| | | } |
| | | |
| | | redisClient.saveMapValue("bed_info", map); |
| | | } |
| | | } |
| | | |
| | | } |