Ejemplo n.º 1
0
 @Override
 @Transactional
 public void applyStore(Store store) {
   Assert.notNull(store);
   Assert.notNull(store.getName());
   Assert.notNull(store.getServiceTelephone());
   Assert.notNull(store.getContactTelephone());
   Assert.notNull(store.getEmail());
   Assert.notNull(store.getApplyMan());
   store.setCreateDate(new Date()); // 设置创建日期
   store.setCheckStatus(Store.CheckStatus.wait); // 设置申请状态:待审核
   store.setIsEnabled(false); // 设置启用状态:未启用
   storeDao.persist(store); // 持久化
 }
Ejemplo n.º 2
0
 /** 初始化新的店铺管理员 */
 private Admin initStoreAdmin(Store store) {
   Admin admin = new Admin();
   admin.setCreateDate(new Date()); // 设置创建日期
   admin.setEntcode("macro"); // 设置企业号
   admin.setIsEnabled(true); // 设置是否启用:启用
   admin.setIsLocked(false); // 设置是否锁定:否
   admin.setStore(store); // 设置店铺属性
   Role role = roleDao.findByName("店铺管理员"); // 根据角色名称,查找角色
   admin.setLoginFailureCount(0); // 设置连续登录失败次数
   Set<Role> roles = new HashSet<Role>();
   roles.add(role);
   admin.setRoles(roles); // 设置角色属性
   admin.setEmail(store.getEmail()); // 设置申请邮箱为管理员邮箱
   admin.setPassword(DigestUtils.md5Hex("888888")); // 初始密码 888888(md5加密)
   admin.setName(store.getApplyMan()); // 默认申请开店人名称为管理员名称
   String userName = admin.getName();
   String tempStr = userName;
   while (adminDao.usernameExists(userName)) {
     userName = tempStr + "_" + (int) (Math.random() * 1000); // 生成三位随机数
   }
   admin.setUsername(userName); // 用户名 为管理员名称(或 (如果用户名已存在)管理员名称 + "_" +  三位随机数)
   return admin;
 }
Ejemplo n.º 3
0
  @Override
  @Transactional
  public void check(Long id, String status) {
    Assert.notNull(id);
    Assert.notNull(status);
    Admin admin = null;
    try {
      Store store = storeDao.find(id, LockModeType.PESSIMISTIC_WRITE); // 加悲观锁
      store.setModifyDate(new Date()); // 设置修改时间
      Assert.notNull(store);
      if ("F".equals(status.trim())) {
        store.setCheckStatus(Store.CheckStatus.failure); // 审核未通过
        store.setIsEnabled(false); // 设置不启用
      } else if ("T".equals(status.trim())) {
        store.setCheckStatus(Store.CheckStatus.success); // 审核通过
        store.setIsEnabled(true); // 设置启用
        String indexUrl = SettingUtils.get().getSiteUrl() + "/" + store.getId() + ".jhtml";
        store.setIndexUrl(indexUrl);

        /** 设置移动端店铺首页 wmd 2014/11/28 */
        String indexMobileUrl =
            SettingUtils.get().getSiteUrl() + "/mobile/" + store.getId() + ".jhtml";
        store.setIndexMobileUrl(indexMobileUrl);

        initStoragePlugin(store);

        admin = initStoreAdmin(store);
        adminDao.persist(admin);

        initStoreAdPosition(store, "头部广告1号位", "店铺头部广告1号位", 1190, 150);
        initStoreAdPosition(store, "头部广告2号位", "店铺头部广告2号位", 1190, 354);

        /** 移动端店铺广告位 wmd 2014/12/2 */
        initStoreAdPosition(store, "微商城广告位", "微商城广告位", 380, 720);

        initStoreNavigation(
            store, "店铺首页", Navigation.Position.top, 1, "/" + store.getId() + ".jhtml");
        initStoreNavigation(
            store,
            "所有商品",
            Navigation.Position.top,
            2,
            "/dp/product/list.jhtml?storeId=" + store.getId());

        initAlipayDirect(store);
      }
      storeDao.merge(store); // 合并实体对象
      if ("F".equals(status.trim())) {
        mailService.sendApplyStoreFailureNofyMail(store); // 发邮件通知
      } else if ("T".equals(status.trim())) {
        mailService.sendApplyStoreSuccessNofyMail(admin, "888888"); // 发邮件通知
      }
    } catch (Exception e) {
      System.out.println("开店审核异常!-->" + StoreServiceImpl.class.getName());
      //			e.printStackTrace();
    }
  }